diff options
author | obo <obo@openoffice.org> | 2010-06-22 05:59:20 +0200 |
---|---|---|
committer | obo <obo@openoffice.org> | 2010-06-22 05:59:20 +0200 |
commit | 5acd61eaee3a7d46dd367d36ab52fbc0a8e37af1 (patch) | |
tree | 7b8ecd09e3ce7364a0c662393afb2ca957a7b546 /filter | |
parent | 70067cc8bc27b695b1c5ad70c7e7844de676b178 (diff) | |
parent | d90bbc5dd13e751ec630871eab55ac333841c241 (diff) |
CWS-TOOLING: integrate CWS mib16
Diffstat (limited to 'filter')
-rw-r--r-- | filter/inc/filter/msfilter/msvbahelper.hxx | 3 | ||||
-rw-r--r-- | filter/source/msfilter/msvbahelper.cxx | 31 | ||||
-rw-r--r-- | filter/source/msfilter/msvbasic.cxx | 71 | ||||
-rw-r--r-- | filter/source/msfilter/svxmsbas.cxx | 5 |
4 files changed, 44 insertions, 66 deletions
diff --git a/filter/inc/filter/msfilter/msvbahelper.hxx b/filter/inc/filter/msfilter/msvbahelper.hxx index 540097c054dc..81607c9b296c 100644 --- a/filter/inc/filter/msfilter/msvbahelper.hxx +++ b/filter/inc/filter/msfilter/msvbahelper.hxx @@ -48,7 +48,8 @@ namespace ooo { namespace vba }; MSFILTER_DLLPUBLIC String makeMacroURL( const String& sMacroName ); - MSFILTER_DLLPUBLIC VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& sMod, bool bSearchGlobalTemplates = false ); + MSFILTER_DLLPUBLIC ::rtl::OUString extractMacroName( const ::rtl::OUString& rMacroUrl ); + MSFILTER_DLLPUBLIC VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& sMod, bool bSearchGlobalTemplates = false ); MSFILTER_DLLPUBLIC sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArgs, com::sun::star::uno::Any& aRet, const com::sun::star::uno::Any& aCaller ); } } diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 97529c22eae6..18ecc5ae6530 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -41,16 +41,27 @@ using namespace ::com::sun::star; +namespace ooo { namespace vba { + const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:"); const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); -namespace ooo { namespace vba { - String makeMacroURL( const String& sMacroName ) { return sUrlPart0.concat( sMacroName ).concat( sUrlPart1 ) ; } +::rtl::OUString extractMacroName( const ::rtl::OUString& rMacroUrl ) +{ + if( (rMacroUrl.getLength() > sUrlPart0.getLength() + sUrlPart1.getLength()) && + rMacroUrl.match( sUrlPart0 ) && + rMacroUrl.match( sUrlPart1, rMacroUrl.getLength() - sUrlPart1.getLength() ) ) + { + return rMacroUrl.copy( sUrlPart0.getLength(), rMacroUrl.getLength() - sUrlPart0.getLength() - sUrlPart1.getLength() ); + } + return ::rtl::OUString(); +} + SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) { SfxObjectShell* pFoundShell=NULL; @@ -186,9 +197,15 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin if ( !pShell ) return aRes; aRes.SetMacroDocContext( pShell ); + + // the name may be enclosed in apostrophs + ::rtl::OUString sMacroUrl = MacroName; + sal_Int32 nMacroLen = MacroName.getLength(); + if( (nMacroLen >= 2) && (MacroName[0] == '\'') && (MacroName[nMacroLen-1] == '\'') ) + sMacroUrl = MacroName.copy( 1, nMacroLen - 2 ); + // parse the macro name - sal_Int32 nDocSepIndex = MacroName.indexOfAsciiL( "!", 1 ); - String sMacroUrl = MacroName; + sal_Int32 nDocSepIndex = sMacroUrl.indexOf( '!' ); String sContainer; String sModule; @@ -201,8 +218,8 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin // recursively // assume for now that the document name is *this* document - String sDocUrlOrPath = MacroName.copy( 0, nDocSepIndex ); - sMacroUrl = MacroName.copy( nDocSepIndex + 1 ); + String sDocUrlOrPath = sMacroUrl.copy( 0, nDocSepIndex ); + sMacroUrl = sMacroUrl.copy( nDocSepIndex + 1 ); OSL_TRACE("doc search, current shell is 0x%x", pShell ); SfxObjectShell* pFoundShell = findShellForUrl( sDocUrlOrPath ); OSL_TRACE("doc search, after find, found shell is 0x%x", pFoundShell ); @@ -215,7 +232,7 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin // document is created from ) // macro format = Container.Module.Procedure - parseMacro( MacroName, sContainer, sModule, sProcedure ); + parseMacro( sMacroUrl, sContainer, sModule, sProcedure ); uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY); uno::Reference< container::XNameContainer > xPrjNameCache; if ( xSF.is() ) diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx index be8ee6bd30e5..65d39953ec20 100644 --- a/filter/source/msfilter/msvbasic.cxx +++ b/filter/source/msfilter/msvbasic.cxx @@ -170,75 +170,36 @@ int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage) return 0; } - static const sal_uInt8 aOffice2003LE_2[] = - { - 0x79, 0x00, 0x00, 0x01, 0x00, 0xFF - }; - - static const sal_uInt8 aOffice2003LE[] = - { - 0x76, 0x00, 0x00, 0x01, 0x00, 0xFF - }; - - static const sal_uInt8 aOfficeXPLE[] = - { - 0x73, 0x00, 0x00, 0x01, 0x00, 0xFF - }; - - static const sal_uInt8 aOfficeXPBE[] = - { - 0x63, 0x00, 0x00, 0x0E, 0x00, 0xFF - }; + static const sal_uInt8 aOffice2007LE[] = { 0x88, 0x00, 0x00, 0x01, 0x00, 0xFF }; + static const sal_uInt8 aOffice2003LE_2[] = { 0x79, 0x00, 0x00, 0x01, 0x00, 0xFF }; + static const sal_uInt8 aOffice2003LE[] = { 0x76, 0x00, 0x00, 0x01, 0x00, 0xFF }; + static const sal_uInt8 aOfficeXPLE[] = { 0x73, 0x00, 0x00, 0x01, 0x00, 0xFF }; + static const sal_uInt8 aOfficeXPBE[] = { 0x63, 0x00, 0x00, 0x0E, 0x00, 0xFF }; + static const sal_uInt8 aOffice2000LE[] = { 0x6D, 0x00, 0x00, 0x01, 0x00, 0xFF }; + static const sal_uInt8 aOffice98BE[] = { 0x60, 0x00, 0x00, 0x0E, 0x00, 0xFF }; + static const sal_uInt8 aOffice97LE[] = { 0x5E, 0x00, 0x00, 0x01, 0x00, 0xFF }; - static const sal_uInt8 aOffice2000LE[] = - { - 0x6D, 0x00, 0x00, 0x01, 0x00, 0xFF - }; - static const sal_uInt8 aOffice98BE[] = - { - 0x60, 0x00, 0x00, 0x0E, 0x00, 0xFF - }; - static const sal_uInt8 aOffice97LE[] = - { - 0x5E, 0x00, 0x00, 0x01, 0x00, 0xFF - }; sal_uInt8 aProduct[6]; xVBAProject->Read( aProduct, sizeof(aProduct) ); bool bIsUnicode; - if (!(memcmp(aProduct, aOffice2003LE, sizeof(aProduct))) || - !(memcmp(aProduct, aOffice2003LE_2, sizeof(aProduct))) ) - { - xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - bIsUnicode = true; - } - else if (!(memcmp(aProduct, aOfficeXPLE, sizeof(aProduct)))) + if (!(memcmp(aProduct, aOffice2007LE, sizeof(aProduct))) || + !(memcmp(aProduct, aOffice2003LE, sizeof(aProduct))) || + !(memcmp(aProduct, aOffice2003LE_2, sizeof(aProduct))) || + !(memcmp(aProduct, aOfficeXPLE, sizeof(aProduct))) || + !(memcmp(aProduct, aOffice2000LE, sizeof(aProduct))) || + !(memcmp(aProduct, aOffice97LE, sizeof(aProduct))) ) { xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); bIsUnicode = true; } - else if (!(memcmp(aProduct, aOfficeXPBE, sizeof(aProduct)))) + else if (!(memcmp(aProduct, aOfficeXPBE, sizeof(aProduct))) || + !(memcmp(aProduct, aOffice98BE, sizeof(aProduct))) ) { xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); mbMac = true; bIsUnicode = false; } - else if (!(memcmp(aProduct, aOffice2000LE, sizeof(aProduct)))) - { - xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - bIsUnicode = true; - } - else if (!(memcmp(aProduct, aOffice98BE, sizeof(aProduct)))) - { - xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); - mbMac = true; - bIsUnicode = false; - } - else if (!(memcmp(aProduct, aOffice97LE, sizeof(aProduct)))) - { - xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - bIsUnicode = true; - } else { switch (aProduct[3]) diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 55465850d8c8..49fd4a7544f3 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -360,10 +360,9 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, static ::rtl::OUString sClassOption( RTL_CONSTASCII_USTRINGPARAM( "Option ClassModule\n" ) ); if ( !bAsComment ) { - modeTypeComment = modeTypeComment + sVBAOption; + modeTypeComment += sVBAOption; if ( mType == ModuleType::CLASS ) - modeTypeComment = modeTypeComment + sClassOption; - + modeTypeComment += sClassOption; } String sModule(sBasicModule); //#i52606# no need to split Macros in 64KB blocks any more! |