summaryrefslogtreecommitdiff
path: root/sfx2/source/notify
diff options
context:
space:
mode:
authorCarsten Driesner <cd@openoffice.org>2011-02-07 13:06:08 +0100
committerCarsten Driesner <cd@openoffice.org>2011-02-07 13:06:08 +0100
commitbebf85efd10e676c8a9409c6ebd98a6e767d16f0 (patch)
treeab9f9265bb021e5eb6fc357e79234bba20bc4b8f /sfx2/source/notify
parente4ee5496696455f7ef6657c15696f36d3da78659 (diff)
parenta1a2a5a68046e75aba3dfd6ba06083a314f12182 (diff)
removetooltypes01: Rebase to DEV300m99
Diffstat (limited to 'sfx2/source/notify')
-rw-r--r--sfx2/source/notify/eventsupplier.cxx130
1 files changed, 47 insertions, 83 deletions
diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx
index 849115e5efe7..fd1327e423ca 100644
--- a/sfx2/source/notify/eventsupplier.cxx
+++ b/sfx2/source/notify/eventsupplier.cxx
@@ -48,6 +48,7 @@
#include <unotools/securityoptions.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/namedvaluecollection.hxx>
#include "eventsupplier.hxx"
#include <sfx2/app.hxx>
@@ -88,9 +89,9 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY &
{
if ( maEventNames[i] == aName )
{
- Sequence< PropertyValue > aProperties;
+ const ::comphelper::NamedValueCollection aEventDescriptor( rElement );
// check for correct type of the element
- if ( rElement.hasValue() && !( rElement >>= aProperties ) )
+ if ( rElement.hasValue() && aEventDescriptor.empty() )
throw ILLEGALARGUMENTEXCEPTION();
// create Configuration at first, creation might call this method also and that would overwrite everything
@@ -98,31 +99,27 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY &
if ( mpObjShell && !mpObjShell->IsLoading() )
mpObjShell->SetModified( sal_True );
- if ( aProperties.getLength() )
+ ::comphelper::NamedValueCollection aNormalizedDescriptor;
+ NormalizeMacro( aEventDescriptor, aNormalizedDescriptor, mpObjShell );
+
+ ::rtl::OUString sType;
+ if ( ( aNormalizedDescriptor.size() == 1 )
+ && ( aNormalizedDescriptor.has( PROP_EVENT_TYPE ) == 0 )
+ && ( aNormalizedDescriptor.get( PROP_EVENT_TYPE ) >>= sType )
+ && ( sType.getLength() == 0 )
+ )
{
- // "normalize" the macro descriptor
- ANY aValue;
- BlowUpMacro( rElement, aValue, mpObjShell );
- aValue >>= aProperties;
-
- ::rtl::OUString sType;
- if ( ( aProperties.getLength() == 1 )
- && ( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 )
- && ( aProperties[0].Value >>= sType )
- && ( sType.getLength() == 0 )
- )
- {
- // An empty event type means no binding. Therefore reset data
- // to reflect that state.
- // (that's for compatibility only. Nowadays, the Tools/Customize dialog should
- // set an empty sequence to indicate the request for resetting the assignment.)
- aProperties.realloc( 0 );
- }
+ // An empty event type means no binding. Therefore reset data
+ // to reflect that state.
+ // (that's for compatibility only. Nowadays, the Tools/Customize dialog should
+ // set an empty sequence to indicate the request for resetting the assignment.)
+ OSL_ENSURE( false, "legacy event assignment format detected" );
+ aNormalizedDescriptor.clear();
}
- if ( aProperties.getLength() )
+ if ( !aNormalizedDescriptor.empty() )
{
- maEventData[i] = makeAny( aProperties );
+ maEventData[i] <<= aNormalizedDescriptor.getPropertyValues();
}
else
{
@@ -378,13 +375,13 @@ SfxEvents_Impl::~SfxEvents_Impl()
}
//--------------------------------------------------------------------------------------------------------
-SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* pObjShell, sal_Bool bBlowUp )
+SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* pObjShell, sal_Bool bNormalizeMacro )
{
SvxMacro* pMacro = NULL;
SEQUENCE < PROPERTYVALUE > aProperties;
ANY aAny;
- if ( bBlowUp )
- BlowUpMacro( rElement, aAny, pObjShell );
+ if ( bNormalizeMacro )
+ NormalizeMacro( rElement, aAny, pObjShell );
else
aAny = rElement;
@@ -444,58 +441,38 @@ SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* p
return pMacro;
}
-void SfxEvents_Impl::BlowUpMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell* pDoc )
+void SfxEvents_Impl::NormalizeMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell* pDoc )
{
- if ( !pDoc )
- pDoc = SfxObjectShell::Current();
-
- SEQUENCE < PROPERTYVALUE > aInProps;
- SEQUENCE < PROPERTYVALUE > aOutProps(2);
-
- if ( !( rEvent >>= aInProps ) )
- return;
+ const ::comphelper::NamedValueCollection aEventDescriptor( rEvent );
+ ::comphelper::NamedValueCollection aEventDescriptorOut;
- sal_Int32 nCount = aInProps.getLength();
+ NormalizeMacro( aEventDescriptor, aEventDescriptorOut, pDoc );
- if ( !nCount )
- return;
+ rRet <<= aEventDescriptorOut.getPropertyValues();
+}
- OUSTRING aType;
- OUSTRING aScript;
- OUSTRING aLibrary;
- OUSTRING aMacroName;
+void SfxEvents_Impl::NormalizeMacro( const ::comphelper::NamedValueCollection& i_eventDescriptor,
+ ::comphelper::NamedValueCollection& o_normalizedDescriptor, SfxObjectShell* i_document )
+{
+ SfxObjectShell* pDoc = i_document;
+ if ( !pDoc )
+ pDoc = SfxObjectShell::Current();
- sal_Int32 nIndex = 0;
+ ::rtl::OUString aType = i_eventDescriptor.getOrDefault( PROP_EVENT_TYPE, ::rtl::OUString() );
+ ::rtl::OUString aScript = i_eventDescriptor.getOrDefault( PROP_SCRIPT, ::rtl::OUString() );
+ ::rtl::OUString aLibrary = i_eventDescriptor.getOrDefault( PROP_LIBRARY, ::rtl::OUString() );
+ ::rtl::OUString aMacroName = i_eventDescriptor.getOrDefault( PROP_MACRO_NAME, ::rtl::OUString() );
- while ( nIndex < nCount )
- {
- if ( aInProps[ nIndex ].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 )
- {
- aInProps[nIndex].Value >>= aType;
- aOutProps[0] = aInProps[nIndex];
- }
- else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_SCRIPT ) == 0 )
- {
- aInProps[nIndex].Value >>= aScript;
- aOutProps[1] = aInProps[nIndex];
- }
- else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_LIBRARY ) == 0 )
- {
- aInProps[ nIndex ].Value >>= aLibrary;
- }
- else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_MACRO_NAME ) == 0 )
- {
- aInProps[ nIndex ].Value >>= aMacroName;
- }
- nIndex += 1;
- }
+ if ( aType.getLength() )
+ o_normalizedDescriptor.put( PROP_EVENT_TYPE, aType );
+ if ( aScript.getLength() )
+ o_normalizedDescriptor.put( PROP_SCRIPT, aScript );
if ( aType.compareToAscii( STAR_BASIC ) == 0 )
{
- aOutProps.realloc(4);
if ( aScript.getLength() )
{
- if( ! aMacroName.getLength() || ! aLibrary.getLength() )
+ if ( !aMacroName.getLength() || !aLibrary.getLength() )
{
sal_Int32 nHashPos = aScript.indexOf( '/', 8 );
sal_Int32 nArgsPos = aScript.indexOf( '(' );
@@ -542,22 +519,9 @@ void SfxEvents_Impl::BlowUpMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell*
aLibrary = String::CreateFromAscii("application");
}
- aOutProps[1].Name = OUSTRING::createFromAscii( PROP_SCRIPT );
- aOutProps[1].Value <<= aScript;
- aOutProps[2].Name = OUSTRING::createFromAscii( PROP_LIBRARY );
- aOutProps[2].Value <<= aLibrary;
- aOutProps[3].Name = OUSTRING::createFromAscii( PROP_MACRO_NAME );
- aOutProps[3].Value <<= aMacroName;
- rRet <<= aOutProps;
- }
- else if ( aType.compareToAscii( SVX_MACRO_LANGUAGE_JAVASCRIPT ) == 0 )
- {
- aOutProps[1] = aInProps[1];
- rRet <<= aOutProps;
- }
- else
- {
- rRet <<= aOutProps;
+ o_normalizedDescriptor.put( PROP_SCRIPT, aScript );
+ o_normalizedDescriptor.put( PROP_LIBRARY, aLibrary );
+ o_normalizedDescriptor.put( PROP_MACRO_NAME, aMacroName );
}
}