summaryrefslogtreecommitdiff
path: root/framework/source/recording/dispatchrecorder.cxx
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2002-06-27 06:27:48 +0000
committerMathias Bauer <mba@openoffice.org>2002-06-27 06:27:48 +0000
commit8e52d29886f5ffd61160c93466cea6c960160880 (patch)
tree67a98a999160cade0f000377addb86b4e2ff427e /framework/source/recording/dispatchrecorder.cxx
parent586766df5c02a54179e0b1b6f228b4bcb253b48c (diff)
#99907#: record enums
Diffstat (limited to 'framework/source/recording/dispatchrecorder.cxx')
-rw-r--r--framework/source/recording/dispatchrecorder.cxx170
1 files changed, 98 insertions, 72 deletions
diff --git a/framework/source/recording/dispatchrecorder.cxx b/framework/source/recording/dispatchrecorder.cxx
index 386ef65a7929..fd1e6fb9493f 100644
--- a/framework/source/recording/dispatchrecorder.cxx
+++ b/framework/source/recording/dispatchrecorder.cxx
@@ -213,7 +213,98 @@ void SAL_CALL DispatchRecorder::endRecording() throw( css::uno::RuntimeException
void SAL_CALL DispatchRecorder::AppendToBuffer( css::uno::Any aValue, ::rtl::OUStringBuffer& aArgumentBuffer )
{
// if value == bool
- if (aValue.getValueType() == getBooleanCppuType())
+ 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.appendAscii("Array(");
+ for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
+ {
+ AppendToBuffer( aSeq[nAny], aArgumentBuffer );
+ if ( nAny+1 < aSeq.getLength() )
+ // not last argument
+ aArgumentBuffer.appendAscii(",");
+ }
+
+ aArgumentBuffer.appendAscii(")");
+ }
+ else if (aValue.getValueTypeClass() == css::uno::TypeClass_SEQUENCE )
+ {
+ // convert to "Sequence of any"
+ css::uno::Sequence < css::uno::Any > aSeq;
+ css::uno::Any aNew;
+ try { aNew = m_xConverter->convertTo( aValue, ::getCppuType((const css::uno::Sequence < css::uno::Any >*)0) ); }
+ catch (css::uno::Exception&) {}
+
+ aNew >>= aSeq;
+ aArgumentBuffer.appendAscii("Array(");
+ for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
+ {
+ AppendToBuffer( aSeq[nAny], aArgumentBuffer );
+ if ( nAny+1 < aSeq.getLength() )
+ // not last argument
+ aArgumentBuffer.appendAscii(",");
+ }
+
+ aArgumentBuffer.appendAscii(")");
+ }
+ else if (aValue.getValueTypeClass() == css::uno::TypeClass_STRING )
+ {
+ // strings need \"
+ ::rtl::OUString sVal;
+ aValue >>= sVal;
+
+ // open string
+ aArgumentBuffer.appendAscii("\"");
+
+ // encode \" inside the string to \"\"
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString aToken = sVal.getToken( 0, '"', nIndex );
+ aArgumentBuffer.append( aToken );
+ if ( nIndex>=0 )
+ aArgumentBuffer.appendAscii("\"\"");
+ }
+ while ( nIndex >= 0 );
+
+ // close string
+ aArgumentBuffer.appendAscii("\"");
+ }
+ else if (aValue.getValueType() == getCppuCharType())
+ {
+ // character variables are recorded as strings, back conversion must be handled in client code
+ sal_Unicode nVal = *((sal_Unicode*)aValue.getValue());
+ aArgumentBuffer.appendAscii("\"");
+ if ( (sal_Unicode(nVal) == '\"') )
+ // encode \" to \"\"
+ aArgumentBuffer.append((sal_Unicode)nVal);
+ aArgumentBuffer.append((sal_Unicode)nVal);
+ aArgumentBuffer.appendAscii("\"");
+ }
+ else
+ {
+ css::uno::Any aNew;
+ try
+ {
+ aNew = m_xConverter->convertToSimpleType( aValue, css::uno::TypeClass_STRING );
+ }
+ catch (css::script::CannotConvertException&) { LOG_WARNING("","Type not scriptable!") }
+ catch (css::uno::Exception&) {}
+ ::rtl::OUString sVal;
+ aNew >>= sVal;
+
+ if (aValue.getValueTypeClass() == css::uno::TypeClass_ENUM )
+ {
+ ::rtl::OUString aName = aValue.getValueType().getTypeName();
+ aArgumentBuffer.append( aName );
+ aArgumentBuffer.appendAscii(".");
+ }
+
+ aArgumentBuffer.append(sVal);
+ }
+/*
+ else if (aValue.getValueType() == getBooleanCppuType())
{
sal_Bool bVal;
aValue >>= bVal;
@@ -222,106 +313,41 @@ void SAL_CALL DispatchRecorder::AppendToBuffer( css::uno::Any aValue, ::rtl::OUS
else
aArgumentBuffer.appendAscii("false");
}
- else
- // if value == sal_Int8
- if (aValue.getValueType() == getCppuType((sal_Int8*)0))
+ else if (aValue.getValueType() == getCppuType((sal_Int8*)0))
{
sal_Int8 nVal;
aValue >>= nVal;
aArgumentBuffer.append((sal_Int32)nVal);
}
- else
- // if value == sal_Int16
- if (aValue.getValueType() == getCppuType((sal_Int16*)0))
+ else if (aValue.getValueType() == getCppuType((sal_Int16*)0))
{
sal_Int16 nVal;
aValue >>= nVal;
aArgumentBuffer.append((sal_Int32)nVal);
}
- else
- // if value == sal_Int32
- if (aValue.getValueType() == getCppuType((sal_Int32*)0))
+ else if (aValue.getValueType() == getCppuType((sal_Int32*)0))
{
sal_Int32 nVal;
aValue >>= nVal;
aArgumentBuffer.append((sal_Int32)nVal);
}
- else
- // if value == sal_UniCode
- if (aValue.getValueType() == getCppuCharType())
- {
- sal_Unicode nVal = *((sal_Unicode*)aValue.getValue());
- aArgumentBuffer.appendAscii("\"");
- aArgumentBuffer.append((sal_Unicode)nVal);
- aArgumentBuffer.appendAscii("\"");
- }
- else
- // if value == float
- if (aValue.getValueType() == getCppuType((float*)0))
+ else if (aValue.getValueType() == getCppuType((float*)0))
{
float fVal;
aValue >>= fVal;
aArgumentBuffer.append(fVal);
}
- else
- // if value == double
- if (aValue.getValueType() == getCppuType((double*)0))
+ else if (aValue.getValueType() == getCppuType((double*)0))
{
double fVal;
aValue >>= fVal;
aArgumentBuffer.append(fVal);
}
else
- // if value == string
- if (aValue.getValueType() == getCppuType((::rtl::OUString*)0))
- {
- ::rtl::OUString sVal;
- aValue >>= sVal;
- aArgumentBuffer.appendAscii("\"");
- aArgumentBuffer.append (sVal);
- aArgumentBuffer.appendAscii("\"");
- }
- else if (aValue.getValueTypeClass() == css::uno::TypeClass_ENUM )
- {
- sal_Int32 nVal = *(sal_Int32*)aValue.getValue();
- aArgumentBuffer.append((sal_Int32)nVal);
- }
- else if (aValue.getValueTypeClass() == css::uno::TypeClass_STRUCT )
- {
- Sequence< Any > aSeq = make_seq_out_of_struct( aValue );
- aArgumentBuffer.appendAscii("Array(");
- for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
- {
- AppendToBuffer( aSeq[nAny], aArgumentBuffer );
- if ( nAny+1 < aSeq.getLength() )
- // not last argument
- aArgumentBuffer.appendAscii(",");
- }
-
- aArgumentBuffer.appendAscii(")");
- }
- else if (aValue.getValueTypeClass() == css::uno::TypeClass_SEQUENCE )
{
- css::uno::Sequence < css::uno::Any > aSeq;
- css::uno::Any aNew;
- try { aNew = m_xConverter->convertTo( aValue, ::getCppuType((const css::uno::Sequence < css::uno::Any >*)0) ); }
- catch (css::uno::Exception&) {}
-
- aNew >>= aSeq;
- aArgumentBuffer.appendAscii("Array(");
- for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
- {
- AppendToBuffer( aSeq[nAny], aArgumentBuffer );
- if ( nAny+1 < aSeq.getLength() )
- // not last argument
- aArgumentBuffer.appendAscii(",");
- }
-
- aArgumentBuffer.appendAscii(")");
- }
- else {
LOG_WARNING("","Type not scriptable!")
}
+ */
}
void SAL_CALL DispatchRecorder::implts_recordMacro( const ::rtl::OUString& aURL,