/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// used to mark a dispatch as comment (mostly it indicates an error) Changing of this define will impact all using of such comments...
constexpr OUString REM_AS_COMMENT = u"rem "_ustr;
void DispatchRecorder::AppendToBuffer( const css::uno::Any& aValue, OUStringBuffer& aArgumentBuffer )
{ // if value == bool if (aValue.getValueTypeClass() == css::uno::TypeClass_STRUCT )
{ // structs are recorded as arrays, convert to "Sequence of any"
Sequence< Any > aSeq = make_seq_out_of_struct( aValue );
aArgumentBuffer.append("Array("); for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
{
AppendToBuffer( aSeq[nAny], aArgumentBuffer ); if ( nAny+1 < aSeq.getLength() ) // not last argument
aArgumentBuffer.append(",");
}
// encode non printable characters or '"' by using the CHR$ function if ( !sVal.isEmpty() )
{ const sal_Unicode* pChars = sVal.getStr(); bool bInString = false; for ( sal_Int32 nChar=0; nChar<sVal.getLength(); nChar ++ )
{ if ( pChars[nChar] < 32 || pChars[nChar] == '"' )
{ // problematic character detected if ( bInString )
{ // close current string
aArgumentBuffer.append("\"");
bInString = false;
}
if ( nChar>0 ) // if this is not the first character, parts of the string have already been added
aArgumentBuffer.append("+");
// add the character constant
aArgumentBuffer.append("CHR$(");
aArgumentBuffer.append( static_cast<sal_Int32>(pChars[nChar]) );
aArgumentBuffer.append(")");
} else
{ if ( !bInString )
{ if ( nChar>0 ) // if this is not the first character, parts of the string have already been added
aArgumentBuffer.append("+");
// start a new string
aArgumentBuffer.append("\"");
bInString = true;
}
aArgumentBuffer.append( pChars[nChar] );
}
}
// close string if ( bInString )
aArgumentBuffer.append("\"");
} else
aArgumentBuffer.append("\"\"");
} elseif (auto nVal = o3tl::tryAccess<sal_Unicode>(aValue))
{ // character variables are recorded as strings, back conversion must be handled in client code
aArgumentBuffer.append("\""); if ( *nVal == '\"' ) // encode \" to \"\"
aArgumentBuffer.append(*nVal);
aArgumentBuffer.append(*nVal);
aArgumentBuffer.append("\"");
} else
{
css::uno::Any aNew; try
{
aNew = m_xConverter->convertToSimpleType( aValue, css::uno::TypeClass_STRING );
} catch (const css::script::CannotConvertException&) {} catch (const css::uno::Exception&) {}
OUString sVal;
aNew >>= sVal;
void DispatchRecorder::implts_recordMacro( std::u16string_view aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments, bool bAsComment, OUStringBuffer& aScriptBuffer )
{
OUStringBuffer aArgumentBuffer(1000); // this value is used to name the arrays of aArgumentBuffer
OUString sArrayName = "args" + OUString::number(m_nRecordingID);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.