From 67f4b1791d5b9e1bf7f5b969174de322adbaec21 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- filter/inc/filter/msfilter/svxmsbas.hxx | 4 + filter/source/msfilter/msvbasic.cxx | 16 ++-- filter/source/msfilter/msvbasic.hxx | 9 +-- filter/source/msfilter/svxmsbas.cxx | 128 +++++++++++++++++++++++++++----- 4 files changed, 127 insertions(+), 30 deletions(-) diff --git a/filter/inc/filter/msfilter/svxmsbas.hxx b/filter/inc/filter/msfilter/svxmsbas.hxx index f488017e4804..716c6788989c 100644 --- a/filter/inc/filter/msfilter/svxmsbas.hxx +++ b/filter/inc/filter/msfilter/svxmsbas.hxx @@ -64,6 +64,9 @@ public: // bit 1 = 1 -> the VBA - storage is copy to the ObjectShell storage int Import( const String& rStorageName, const String &rSubStorageName, BOOL bAsComment=TRUE, BOOL bStripped=TRUE ); + int Import( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, + BOOL bAsComment=TRUE, BOOL bStripped=TRUE ); // only for the export - copy or delete the saved VBA-macro-storage // form the ObjectShell @@ -84,6 +87,7 @@ private: MSFILTER_DLLPRIVATE BOOL ImportCode_Impl( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped); MSFILTER_DLLPRIVATE bool ImportForms_Impl(const String& rStorageName, const String &rSubStorageName); diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx index 91348043b75f..8a87c70f19d0 100644 --- a/filter/source/msfilter/msvbasic.cxx +++ b/filter/source/msfilter/msvbasic.cxx @@ -38,6 +38,8 @@ #include //rtl_getTextEncodingFromWindowsCodePage #include "msvbasic.hxx" +using namespace ::com::sun::star::script; + /* A few urls which may in the future be of some use http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf @@ -429,7 +431,7 @@ int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage) * */ -ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName ) +ModType VBA_Impl::GetModuleType( const UniString& rModuleName ) { ModuleTypeHash::iterator iter = mhModHash.find( rModuleName ); ModuleTypeHash::iterator iterEnd = mhModHash.end(); @@ -437,7 +439,7 @@ ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName ) { return iter->second; } - return Unknown; + return ModuleType::Unknown; } bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) @@ -480,7 +482,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) ); static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) ); static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) ); - mhModHash[ sThisDoc ] = Class; + mhModHash[ sThisDoc ] = ModuleType::Class; while ( pStp->ReadByteStringLine( tmp, meCharSet ) ) { xub_StrLen index = tmp.Search( '=' ); @@ -490,14 +492,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) String value = tmp.Copy( index + 1 ); if ( key == sClass ) { - mhModHash[ value ] = Class; + mhModHash[ value ] = ModuleType::Class; OSL_TRACE("Module %s is of type Class", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sBaseClass ) { - mhModHash[ value ] = Form; + mhModHash[ value ] = ModuleType::Form; OSL_TRACE("Module %s is of type Form", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); @@ -510,14 +512,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) // value is of form /&H, strip the identifier value.Erase( value.Search( '/' ) ); - mhModHash[ value ] = Document; + mhModHash[ value ] = ModuleType::Document; OSL_TRACE("Module %s is of type Document VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sModule ) { - mhModHash[ value ] = Normal; + mhModHash[ value ] = ModuleType::Normal; OSL_TRACE("Module %s is of type Normal VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); diff --git a/filter/source/msfilter/msvbasic.hxx b/filter/source/msfilter/msvbasic.hxx index 5b361518c0f5..ed77b34c4f48 100644 --- a/filter/source/msfilter/msvbasic.hxx +++ b/filter/source/msfilter/msvbasic.hxx @@ -40,6 +40,7 @@ #include #endif #include +#include /* class VBA: * The VBA class provides a set of methods to handle Visual Basic For @@ -63,13 +64,12 @@ DECLARE_DYNARRAY(StringArray,String *) // #117718# define internal types to distinguish between // module types, form, class & normal // #i37965# DR 2004-12-03: add "Document", used in Excel for macros attached to sheet -enum ModuleType { Unknown = 0, Normal, Class, Form, Document }; // #117718# define map to hold types of module // - +typedef sal_Int32 ModType; typedef ::std::map< UniString, - ModuleType > ModuleTypeHash; + ModType > ModuleTypeHash; class VBA_Impl { @@ -90,8 +90,7 @@ public: void Output(int len, const sal_uInt8 *data); // // #117718# member map of module names to types of module - ModuleType GetModuleType( const UniString& rModuleName ); - + ModType GetModuleType( const UniString& rModuleName ); std::vector maReferences; private: struct VBAOffset_Impl diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index e4305c2e4e65..0b42fe7e4843 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -50,6 +50,10 @@ using namespace com::sun::star::awt; #include #include +#include +#include +#include + using namespace com::sun::star::container; using namespace com::sun::star::script; using namespace com::sun::star::uno; @@ -58,12 +62,23 @@ using namespace com::sun::star; using rtl::OUString; +static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ); + +int SvxImportMSVBasic::Import( const String& rStorageName, + const String &rSubStorageName, + BOOL bAsComment, BOOL bStripped ) +{ + std::vector< String > codeNames; + return Import( rStorageName, rSubStorageName, codeNames, bAsComment, bStripped ); +} + int SvxImportMSVBasic::Import( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped ) { int nRet = 0; - if( bImport && ImportCode_Impl( rStorageName, rSubStorageName, + if( bImport && ImportCode_Impl( rStorageName, rSubStorageName, codeNames, bAsComment, bStripped )) nRet |= 1; @@ -225,6 +240,7 @@ BOOL SvxImportMSVBasic::CopyStorage_Impl( const String& rStorageName, BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped ) { BOOL bRet = FALSE; @@ -233,13 +249,18 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, { SFX_APP()->EnterBasicCall(); Reference xLibContainer = rDocSh.GetBasicContainer(); + Reference xVBACompat( xLibContainer, UNO_QUERY ); + + if ( xVBACompat.is() && !bAsComment ) + xVBACompat->setVBACompatModeOn( sal_True ); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); UINT16 nStreamCount = aVBA.GetNoStreams(); Reference xLib; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); if( xLibContainer.is() && nStreamCount ) { - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); if( !xLibContainer->hasByName( aLibName ) ) xLibContainer->createLibrary( aLibName ); @@ -248,6 +269,28 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, } if( xLib.is() ) { + Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); + Reference< container::XNameAccess > xVBACodeNamedObjectAccess; + if ( !bAsComment ) + { + Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY); + if ( xSF.is() ) + { + try + { + xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), UNO_QUERY ); + } + catch( Exception& ) { } + } + } + typedef std::hash_map< rtl::OUString, uno::Any, ::rtl::OUStringHash, +::std::equal_to< ::rtl::OUString > > NameModuleDataHash; + typedef std::hash_map< rtl::OUString, script::ModuleInfo, ::rtl::OUStringHash, +::std::equal_to< ::rtl::OUString > > NameModuleInfoHash; + + NameModuleDataHash moduleData; + NameModuleInfoHash moduleInfos; + for( UINT16 i=0; ihasByName( aModName ) ) - xLib->replaceByName( aModName, aSourceAny ); - else - xLib->insertByName( aModName, aSourceAny ); + if ( !bAsComment ) + { + OSL_TRACE("vba processing %d", mType ); + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = mType; + moduleInfos[ aModName ] = sModuleInfo; + } + moduleData[ aModName ] = aSourceAny; + } + // Hack for missing codenames ( only know to happen in excel but... ) + // only makes sense to do this if we are importing non-commented basic + if ( !bAsComment ) + { + for ( std::vector< String >::const_iterator it = codeNames.begin(); it != codeNames.end(); ++it ) + { + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = ModuleType::Document; + moduleInfos[ *it ] = sModuleInfo; + moduleData[ *it ] = uno::makeAny( sVBAOption ); + } + } + NameModuleDataHash::iterator it_end = moduleData.end(); + for ( NameModuleDataHash::iterator it = moduleData.begin(); it != it_end; ++it ) + { + NameModuleInfoHash::iterator it_info = moduleInfos.find( it->first ); + if ( it_info != moduleInfos.end() ) + { + ModuleInfo& sModuleInfo = it_info->second; + if ( sModuleInfo.ModuleType == ModuleType::Form ) + // hack, the module ( imo document basic should... + // know the XModel... ) but it doesn't + sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY ); + // document modules, we should be able to access + // the api objects at this time + else if ( sModuleInfo.ModuleType == ModuleType::Document ) + { + if ( xVBACodeNamedObjectAccess.is() ) + { + try + { + sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( it->first ), uno::UNO_QUERY ); + OSL_TRACE("** Straight up creation of Module"); + } + catch(uno::Exception& e) + { + OSL_TRACE("Failed to get documument object for %s", rtl::OUStringToOString( it->first, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } + } + xVBAModuleInfo->insertModuleInfo( it->first, sModuleInfo ); } - bRet = true; + if( xLib->hasByName( it->first ) ) + xLib->replaceByName( it->first, it->second ); + else + xLib->insertByName( it->first, it->second ); } + bRet = true; } SFX_APP()->LeaveBasicCall(); } -- cgit From c5fc57de562850a7d2f708e3936296d24677012d Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 15:04:15 +0000 Subject: npower14miscfixes: #i109706# move back msvbahelper to the filter module --- filter/inc/filter/msfilter/msvbahelper.hxx | 55 +++++ filter/source/msfilter/makefile.mk | 3 +- filter/source/msfilter/msvbahelper.cxx | 382 +++++++++++++++++++++++++++++ 3 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 filter/inc/filter/msfilter/msvbahelper.hxx create mode 100644 filter/source/msfilter/msvbahelper.cxx diff --git a/filter/inc/filter/msfilter/msvbahelper.hxx b/filter/inc/filter/msfilter/msvbahelper.hxx new file mode 100644 index 000000000000..540097c054dc --- /dev/null +++ b/filter/inc/filter/msfilter/msvbahelper.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _MSVBAHELPER_HXX +#define _MSVBAHELPER_HXX + +#include +#include "filter/msfilter/msfilterdllapi.h" + +namespace ooo { namespace vba +{ + class MSFILTER_DLLPUBLIC VBAMacroResolvedInfo + { + SfxObjectShell* mpDocContext; + bool mbFound; + String msResolvedMacro; + public: + VBAMacroResolvedInfo() : mpDocContext(NULL), mbFound( false ){} + void SetResolved( bool bRes ) { mbFound = bRes; } + bool IsResolved() { return mbFound; } + void SetMacroDocContext(SfxObjectShell* pShell ) { mpDocContext = pShell; } + SfxObjectShell* MacroDocContext() { return mpDocContext; } + String ResolvedMacro() { return msResolvedMacro; } + void SetResolvedMacro(const String& sMacro ) { msResolvedMacro = sMacro; } + }; + + MSFILTER_DLLPUBLIC String makeMacroURL( const String& sMacroName ); + 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 ); +} } + +#endif diff --git a/filter/source/msfilter/makefile.mk b/filter/source/msfilter/makefile.mk index 6056213ddecf..954009185a50 100644 --- a/filter/source/msfilter/makefile.mk +++ b/filter/source/msfilter/makefile.mk @@ -51,7 +51,8 @@ SLOFILES= \ $(SLO)$/mscodec.obj \ $(SLO)$/msfiltertracer.obj \ $(SLO)$/svdfppt.obj \ - $(SLO)$/svxmsbas2.obj + $(SLO)$/svxmsbas2.obj \ + $(SLO)$/msvbahelper.obj \ SHL1TARGET= msfilter$(DLLPOSTFIX) SHL1IMPLIB= i$(TARGET) diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx new file mode 100644 index 000000000000..97529c22eae6 --- /dev/null +++ b/filter/source/msfilter/msvbahelper.cxx @@ -0,0 +1,382 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_filter.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; + +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 ) ; +} + +SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) +{ + SfxObjectShell* pFoundShell=NULL; + SfxObjectShell* pShell = SfxObjectShell::GetFirst(); + INetURLObject aObj; + aObj.SetURL( sMacroURLOrPath ); + bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; + rtl::OUString aURL; + if ( bIsURL ) + aURL = sMacroURLOrPath; + else + { + osl::FileBase::getFileURLFromSystemPath( sMacroURLOrPath, aURL ); + aObj.SetURL( aURL ); + } + OSL_TRACE("Trying to find shell for url %s", rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() ); + while ( pShell ) + { + + uno::Reference< frame::XModel > xModel = pShell->GetModel(); + // are we searching for a template? if so we have to cater for the + // fact that in openoffice a document opened from a template is always + // a new document :/ + if ( xModel.is() ) + { + OSL_TRACE("shell 0x%x has model with url %s and we look for %s", pShell + , rtl::OUStringToOString( xModel->getURL(), RTL_TEXTENCODING_UTF8 ).getStr() + , rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() + ); + if ( sMacroURLOrPath.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) ) + { + uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( xModel, uno::UNO_QUERY ); + if( xDocInfoSupp.is() ) + { + uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); + rtl::OUString sCurrName = xDocProps->getTemplateName(); + if( sMacroURLOrPath.lastIndexOf( sCurrName ) >= 0 ) + { + pFoundShell = pShell; + break; + } + } + } + else + { + if ( aURL.equals( xModel->getURL() ) ) + { + pFoundShell = pShell; + break; + } + } + } + pShell = SfxObjectShell::GetNext( *pShell ); + } + return pFoundShell; +} + +// sMod can be empty ( but we really need the library to search in ) +// if sMod is empty and a macro is found then sMod is updated +bool hasMacro( SfxObjectShell* pShell, const String& sLibrary, String& sMod, const String& sMacro ) +{ + bool bFound = false; + if ( sLibrary.Len() && sMacro.Len() ) + { + OSL_TRACE("** Searching for %s.%s in library %s" + ,rtl::OUStringToOString( sMod, RTL_TEXTENCODING_UTF8 ).getStr() + ,rtl::OUStringToOString( sMacro, RTL_TEXTENCODING_UTF8 ).getStr() + ,rtl::OUStringToOString( sLibrary, RTL_TEXTENCODING_UTF8 ).getStr() ); + BasicManager* pBasicMgr = pShell-> GetBasicManager(); + if ( pBasicMgr ) + { + StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary ); + if ( !pBasic ) + { + USHORT nId = pBasicMgr->GetLibId( sLibrary ); + pBasicMgr->LoadLib( nId ); + pBasic = pBasicMgr->GetLib( sLibrary ); + } + if ( pBasic ) + { + if ( sMod.Len() ) // we wish to find the macro is a specific module + { + SbModule* pModule = pBasic->FindModule( sMod ); + if ( pModule ) + { + SbxArray* pMethods = pModule->GetMethods(); + if ( pMethods ) + { + SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) ); + if ( pMethod ) + bFound = true; + } + } + } + else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) ) + { + if( SbModule* pModule = pMethod->GetModule() ) + { + sMod = pModule->GetName(); + bFound = true; + } + } + } + } + } + return bFound; +} +void parseMacro( const rtl::OUString& sMacro, String& sContainer, String& sModule, String& sProcedure ) +{ + sal_Int32 nMacroDot = sMacro.lastIndexOf( '.' ); + + if ( nMacroDot != -1 ) + { + sProcedure = sMacro.copy( nMacroDot + 1 ); + + sal_Int32 nContainerDot = sMacro.lastIndexOf( '.', nMacroDot - 1 ); + if ( nContainerDot != -1 ) + { + sModule = sMacro.copy( nContainerDot + 1, nMacroDot - nContainerDot - 1 ); + sContainer = sMacro.copy( 0, nContainerDot ); + } + else + sModule = sMacro.copy( 0, nMacroDot ); + } + else + sProcedure = sMacro; +} + +VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& MacroName, bool bSearchGlobalTemplates ) +{ + VBAMacroResolvedInfo aRes; + if ( !pShell ) + return aRes; + aRes.SetMacroDocContext( pShell ); + // parse the macro name + sal_Int32 nDocSepIndex = MacroName.indexOfAsciiL( "!", 1 ); + String sMacroUrl = MacroName; + + String sContainer; + String sModule; + String sProcedure; + + if( nDocSepIndex > 0 ) + { + // macro specified by document name + // find document shell for document name and call ourselves + // recursively + + // assume for now that the document name is *this* document + String sDocUrlOrPath = MacroName.copy( 0, nDocSepIndex ); + sMacroUrl = MacroName.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 ); + aRes = resolveVBAMacro( pFoundShell, sMacroUrl ); + } + else + { + // macro is contained in 'this' document ( or code imported from a template + // where that template is a global template or perhaps the template this + // document is created from ) + + // macro format = Container.Module.Procedure + parseMacro( MacroName, sContainer, sModule, sProcedure ); + uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY); + uno::Reference< container::XNameContainer > xPrjNameCache; + if ( xSF.is() ) + xPrjNameCache.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAProjectNameProvider" ) ) ), uno::UNO_QUERY ); + + std::vector< rtl::OUString > sSearchList; + + if ( sContainer.Len() > 0 ) + { + // get the Project associated with the Container + if ( xPrjNameCache.is() ) + { + if ( xPrjNameCache->hasByName( sContainer ) ) + { + rtl::OUString sProject; + xPrjNameCache->getByName( sContainer ) >>= sProject; + sContainer = sProject; + } + } + sSearchList.push_back( sContainer ); // First Lib to search + } + else + { + // Ok, if we have no Container specified then we need to search them in order, this document, template this document created from, global templates, + // get the name of Project/Library for 'this' document + rtl::OUString sThisProject; + BasicManager* pBasicMgr = pShell-> GetBasicManager(); + if ( pBasicMgr ) + { + if ( pBasicMgr->GetName().Len() ) + sThisProject = pBasicMgr->GetName(); + else // cater for the case where VBA is not enabled + sThisProject = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + } + sSearchList.push_back( sThisProject ); // First Lib to search + if ( xPrjNameCache.is() ) + { + // is this document created from a template? + uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( pShell->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); + + rtl::OUString sCreatedFrom = xDocProps->getTemplateURL(); + if ( sCreatedFrom.getLength() ) + { + INetURLObject aObj; + aObj.SetURL( sCreatedFrom ); + bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; + rtl::OUString aURL; + if ( bIsURL ) + aURL = sCreatedFrom; + else + { + osl::FileBase::getFileURLFromSystemPath( sCreatedFrom, aURL ); + aObj.SetURL( aURL ); + } + sCreatedFrom = aObj.GetLastName(); + } + + sal_Int32 nIndex = sCreatedFrom.lastIndexOf( '.' ); + if ( nIndex != -1 ) + sCreatedFrom = sCreatedFrom.copy( 0, nIndex ); + + rtl::OUString sPrj; + if ( sCreatedFrom.getLength() && xPrjNameCache->hasByName( sCreatedFrom ) ) + { + xPrjNameCache->getByName( sCreatedFrom ) >>= sPrj; + // Make sure we don't double up with this project + if ( !sPrj.equals( sThisProject ) ) + sSearchList.push_back( sPrj ); + } + + // get list of global template Names + uno::Sequence< rtl::OUString > sTemplateNames = xPrjNameCache->getElementNames(); + sal_Int32 nLen = sTemplateNames.getLength(); + for ( sal_Int32 index = 0; ( bSearchGlobalTemplates && index < nLen ); ++index ) + { + + if ( !sCreatedFrom.equals( sTemplateNames[ index ] ) ) + { + if ( xPrjNameCache->hasByName( sTemplateNames[ index ] ) ) + { + xPrjNameCache->getByName( sTemplateNames[ index ] ) >>= sPrj; + // Make sure we don't double up with this project + if ( !sPrj.equals( sThisProject ) ) + sSearchList.push_back( sPrj ); + } + } + + } + } + } + std::vector< rtl::OUString >::iterator it_end = sSearchList.end(); + for ( std::vector< rtl::OUString >::iterator it = sSearchList.begin(); it != it_end; ++it ) + { + bool bRes = hasMacro( pShell, *it, sModule, sProcedure ); + if ( bRes ) + { + aRes.SetResolved( true ); + aRes.SetMacroDocContext( pShell ); + sContainer = *it; + break; + } + } + } + aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); + + return aRes; +} + +// Treat the args as possible inouts ( convertion at bottom of method ) +sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& /*aRet*/, const uno::Any& aCaller ) +{ + sal_Bool bRes = sal_False; + if ( !pShell ) + return bRes; + rtl::OUString sUrl = makeMacroURL( sMacroName ); + + uno::Sequence< sal_Int16 > aOutArgsIndex; + uno::Sequence< uno::Any > aOutArgs; + + try + { + uno::Reference< script::provider::XScriptProvider > xScriptProvider; + uno::Reference< script::provider::XScriptProviderSupplier > xSPS( pShell->GetModel(), uno::UNO_QUERY_THROW ); + + xScriptProvider.set( xSPS->getScriptProvider(), uno::UNO_QUERY_THROW ); + + uno::Reference< script::provider::XScript > xScript( xScriptProvider->getScript( sUrl ), uno::UNO_QUERY_THROW ); + + if ( aCaller.hasValue() ) + { + uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); + if ( xProps.is() ) + { + uno::Sequence< uno::Any > aCallerHack(1); + aCallerHack[ 0 ] = aCaller; + xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) ); + } + } + + + xScript->invoke( aArgs, aOutArgsIndex, aOutArgs ); + + sal_Int32 nLen = aOutArgs.getLength(); + // convert any out params to seem like they were inouts + if ( nLen ) + { + for ( sal_Int32 index=0; index < nLen; ++index ) + { + sal_Int32 nOutIndex = aOutArgsIndex[ index ]; + aArgs[ nOutIndex ] = aOutArgs[ index ]; + } + } + + bRes = sal_True; + } + catch ( uno::Exception& e ) + { + bRes = sal_False; + } + return bRes; +} +} } // vba // ooo -- cgit From e19003d128d4bc415e88a8c83c2665abb90b079b Mon Sep 17 00:00:00 2001 From: npower Developer Date: Fri, 5 Mar 2010 20:14:25 +0000 Subject: npower13_objectmodule: wae fixes --- filter/source/msfilter/svxmsbas.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 0b42fe7e4843..3b32b951c16a 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -356,7 +356,6 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, DBG_ERRORFILE( "SvxImportMSVBasic::ImportCode_Impl - unknown module type" ); break; } - static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ); static ::rtl::OUString sClassOption( RTL_CONSTASCII_USTRINGPARAM( "Option ClassModule\n" ) ); if ( !bAsComment ) { -- cgit From a0147bb5d9e421d6458722196cef6d4caf2cf2fe Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 8 Mar 2010 23:24:53 +0000 Subject: npower13objectmodules: clean build breaks vbahelper/filter --- filter/prj/build.lst | 2 +- filter/source/msfilter/makefile.mk | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/filter/prj/build.lst b/filter/prj/build.lst index b4be1c83e63e..bed99e401b7f 100644 --- a/filter/prj/build.lst +++ b/filter/prj/build.lst @@ -1,4 +1,4 @@ -fl filter : vbahelper l10n svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt NULL +fl filter : l10n svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt NULL fl filter usr1 - all fl_mkout NULL fl filter\prj get - all fl_prj NULL fl filter\inc nmake - all fl_inc NULL diff --git a/filter/source/msfilter/makefile.mk b/filter/source/msfilter/makefile.mk index 954009185a50..7780529b5580 100644 --- a/filter/source/msfilter/makefile.mk +++ b/filter/source/msfilter/makefile.mk @@ -60,7 +60,6 @@ SHL1OBJS= $(SLOFILES) SHL1USE_EXPORTS=name SHL1STDLIBS= \ $(EDITENGLIB) \ - $(VBAHELPERLIB) \ $(SVXCORELIB) \ $(SFX2LIB) \ $(XMLOFFLIB) \ -- cgit From 319c08647f115aaba7f5633376531cbfb4746b2f Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- oox/inc/oox/core/filterbase.hxx | 22 +- .../oox/drawingml/chart/chartdrawingfragment.hxx | 6 +- oox/inc/oox/drawingml/color.hxx | 4 +- oox/inc/oox/drawingml/customshapeproperties.hxx | 5 +- oox/inc/oox/drawingml/fillproperties.hxx | 9 +- oox/inc/oox/drawingml/lineproperties.hxx | 4 +- oox/inc/oox/dump/biffdumper.hxx | 8 +- oox/inc/oox/dump/dumperbase.hxx | 109 +- oox/inc/oox/dump/oledumper.hxx | 418 +++++-- oox/inc/oox/dump/xlsbdumper.hxx | 2 +- oox/inc/oox/helper/binaryinputstream.hxx | 69 ++ oox/inc/oox/helper/binaryoutputstream.hxx | 5 - oox/inc/oox/helper/binarystreambase.hxx | 15 +- oox/inc/oox/helper/containerhelper.hxx | 131 ++- oox/inc/oox/helper/graphichelper.hxx | 74 +- oox/inc/oox/helper/helper.hxx | 24 +- oox/inc/oox/helper/modelobjecthelper.hxx | 2 +- oox/inc/oox/helper/olestorage.hxx | 103 -- oox/inc/oox/helper/propertyset.hxx | 4 + oox/inc/oox/helper/storagebase.hxx | 65 +- oox/inc/oox/helper/textinputstream.hxx | 58 + oox/inc/oox/helper/zipstorage.hxx | 6 +- oox/inc/oox/ole/axbinaryreader.hxx | 109 +- oox/inc/oox/ole/axcontrol.hxx | 568 +++++++-- oox/inc/oox/ole/axcontrolfragment.hxx | 14 +- oox/inc/oox/ole/axcontrolhelper.hxx | 118 -- oox/inc/oox/ole/olehelper.hxx | 79 +- oox/inc/oox/ole/olestorage.hxx | 116 ++ oox/inc/oox/ole/vbacontrol.hxx | 205 ++++ oox/inc/oox/ole/vbahelper.hxx | 233 ++++ oox/inc/oox/ole/vbamodule.hxx | 96 ++ oox/inc/oox/ole/vbaproject.hxx | 289 +++++ oox/inc/oox/ppt/pptimport.hxx | 5 +- oox/inc/oox/vml/vmldrawing.hxx | 14 +- oox/inc/oox/vml/vmlformatting.hxx | 21 +- oox/inc/oox/xls/biffhelper.hxx | 2 + oox/inc/oox/xls/excelfilter.hxx | 22 +- oox/inc/oox/xls/excelvbaproject.hxx | 73 ++ oox/inc/oox/xls/stylesbuffer.hxx | 19 +- oox/inc/oox/xls/workbookfragment.hxx | 3 + oox/inc/oox/xls/workbookhelper.hxx | 107 +- oox/inc/oox/xls/worksheetsettings.hxx | 2 + oox/prj/build.lst | 2 +- oox/prj/d.lst | 5 + oox/source/core/binaryfilterbase.cxx | 6 +- oox/source/core/filterbase.cxx | 105 +- oox/source/core/filterdetect.cxx | 4 +- oox/source/core/recordparser.cxx | 7 +- oox/source/docprop/docprophandler.cxx | 2 +- .../drawingml/chart/chartdrawingfragment.cxx | 6 +- oox/source/drawingml/chart/objectformatter.cxx | 8 +- oox/source/drawingml/clrschemecontext.cxx | 2 +- oox/source/drawingml/color.cxx | 12 +- oox/source/drawingml/customshapeproperties.cxx | 5 +- oox/source/drawingml/fillproperties.cxx | 54 +- .../drawingml/fillpropertiesgroupcontext.cxx | 12 +- oox/source/drawingml/lineproperties.cxx | 15 +- oox/source/drawingml/linepropertiescontext.cxx | 2 +- oox/source/drawingml/shape.cxx | 17 +- oox/source/drawingml/table/tablecell.cxx | 4 +- oox/source/drawingml/textcharacterproperties.cxx | 4 +- oox/source/drawingml/textfont.cxx | 4 +- oox/source/drawingml/textparagraphproperties.cxx | 2 +- oox/source/dump/biffdumper.cxx | 333 +++--- oox/source/dump/biffdumper.ini | 4 +- oox/source/dump/dffdumper.cxx | 32 +- oox/source/dump/dumperbase.cxx | 371 +++--- oox/source/dump/oledumper.cxx | 1237 ++++++++++++++------ oox/source/dump/oledumper.ini | 439 +++++-- oox/source/dump/pptxdumper.cxx | 9 +- oox/source/dump/xlsbdumper.cxx | 241 ++-- oox/source/helper/binaryinputstream.cxx | 97 +- oox/source/helper/binaryoutputstream.cxx | 20 - oox/source/helper/binarystreambase.cxx | 21 +- oox/source/helper/graphichelper.cxx | 224 +++- oox/source/helper/makefile.mk | 2 +- oox/source/helper/modelobjecthelper.cxx | 10 +- oox/source/helper/olestorage.cxx | 180 --- oox/source/helper/propertyset.cxx | 44 +- oox/source/helper/storagebase.cxx | 145 ++- oox/source/helper/textinputstream.cxx | 128 ++ oox/source/helper/zipstorage.cxx | 56 +- oox/source/ole/axbinaryreader.cxx | 100 +- oox/source/ole/axcontrol.cxx | 1120 ++++++++++++------ oox/source/ole/axcontrolfragment.cxx | 35 +- oox/source/ole/axcontrolhelper.cxx | 175 --- oox/source/ole/makefile.mk | 8 +- oox/source/ole/olehelper.cxx | 113 +- oox/source/ole/olestorage.cxx | 420 +++++++ oox/source/ole/vbacontrol.cxx | 811 +++++++++++++ oox/source/ole/vbahelper.cxx | 248 ++++ oox/source/ole/vbamodule.cxx | 241 ++++ oox/source/ole/vbaproject.cxx | 519 ++++++++ oox/source/ppt/animvariantcontext.cxx | 2 +- oox/source/ppt/pptimport.cxx | 30 + oox/source/ppt/slidepersist.cxx | 2 +- oox/source/ppt/timenodelistcontext.cxx | 12 +- oox/source/token/properties.txt | 18 + oox/source/vml/vmldrawing.cxx | 20 +- oox/source/vml/vmlformatting.cxx | 41 +- oox/source/vml/vmlshape.cxx | 22 +- oox/source/vml/vmlshapecontainer.cxx | 1 - oox/source/xls/biffdetector.cxx | 6 +- oox/source/xls/biffhelper.cxx | 97 +- oox/source/xls/excelfilter.cxx | 56 +- oox/source/xls/excelvbaproject.cxx | 214 ++++ oox/source/xls/formulaparser.cxx | 3 - oox/source/xls/makefile.mk | 1 + oox/source/xls/sheetdatacontext.cxx | 4 - oox/source/xls/stylesbuffer.cxx | 77 +- oox/source/xls/unitconverter.cxx | 2 +- oox/source/xls/viewsettings.cxx | 2 +- oox/source/xls/workbookfragment.cxx | 73 +- oox/source/xls/workbookhelper.cxx | 202 +--- oox/source/xls/workbooksettings.cxx | 5 +- oox/source/xls/worksheetfragment.cxx | 3 +- oox/source/xls/worksheethelper.cxx | 63 +- oox/source/xls/worksheetsettings.cxx | 11 + oox/util/makefile.mk | 3 +- 119 files changed, 8634 insertions(+), 3235 deletions(-) delete mode 100644 oox/inc/oox/helper/olestorage.hxx create mode 100755 oox/inc/oox/helper/textinputstream.hxx delete mode 100644 oox/inc/oox/ole/axcontrolhelper.hxx create mode 100755 oox/inc/oox/ole/olestorage.hxx create mode 100755 oox/inc/oox/ole/vbacontrol.hxx create mode 100755 oox/inc/oox/ole/vbahelper.hxx create mode 100755 oox/inc/oox/ole/vbamodule.hxx create mode 100755 oox/inc/oox/ole/vbaproject.hxx create mode 100755 oox/inc/oox/xls/excelvbaproject.hxx delete mode 100644 oox/source/helper/olestorage.cxx create mode 100755 oox/source/helper/textinputstream.cxx delete mode 100644 oox/source/ole/axcontrolhelper.cxx create mode 100755 oox/source/ole/olestorage.cxx create mode 100755 oox/source/ole/vbacontrol.cxx create mode 100755 oox/source/ole/vbahelper.cxx create mode 100755 oox/source/ole/vbamodule.cxx create mode 100755 oox/source/ole/vbaproject.cxx create mode 100755 oox/source/xls/excelvbaproject.cxx diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index b086538db73e..b2709ea4b33b 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -145,12 +145,12 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate + @param bCreateMissing True = create missing sub storages (for export filters). */ StorageRef openSubStorage( const ::rtl::OUString& rStorageName, - bool bCreate ) const; + bool bCreateMissing ) const; /** Opens and returns the specified input stream from the base storage. @@ -189,20 +189,6 @@ public: /** Returns a helper for the handling of OLE obejcts. */ ::oox::ole::OleObjectHelper& getOleObjectHelper() const; - /** Returns information about the output device. */ - const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; - /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelX( double fPixelX ) const; - /** Converts the passed value from vertical screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelY( double fPixelY ) const; - - /** Returns a system color specified by the passed XML token identifier. */ - sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; - /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - /** Derived classes may implement to resolve a palette index to an RGB color. */ - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - /** Requests a password from the media descriptor or from the user. On success, the password will be inserted into the media descriptor. */ ::rtl::OUString requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const; @@ -282,6 +268,10 @@ private: void setMediaDescriptor( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq ); + /** Derived classes may create a specialized graphic helper, e.g. for + resolving palette colors. */ + virtual GraphicHelper* implCreateGraphicHelper() const; + virtual ::rtl::OUString implGetImplementationName() const = 0; virtual StorageRef implCreateStorage( diff --git a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx index e38311394046..0b5a7f6374a4 100644 --- a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx +++ b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx @@ -2,14 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: chartdrawingfragment.hxx,v $ - * - * $Revision: 1.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/oox/inc/oox/drawingml/color.hxx b/oox/inc/oox/drawingml/color.hxx index 830959b77db9..51e9501205cf 100644 --- a/oox/inc/oox/drawingml/color.hxx +++ b/oox/inc/oox/drawingml/color.hxx @@ -35,7 +35,7 @@ #include #include "oox/helper/helper.hxx" -namespace oox { namespace core { class FilterBase; } } +namespace oox { class GraphicHelper; } namespace oox { namespace drawingml { @@ -90,7 +90,7 @@ public: bool isPlaceHolder() const { return meMode == COLOR_PH; } /** Returns the final RGB color value. @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ - sal_Int32 getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; + sal_Int32 getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Returns true, if the color has a transparence set. */ bool hasTransparence() const; diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx index 4e4b82cd5acd..44e91d6e797b 100644 --- a/oox/inc/oox/drawingml/customshapeproperties.hxx +++ b/oox/inc/oox/drawingml/customshapeproperties.hxx @@ -43,9 +43,7 @@ #include #include #include -#ifndef __com_sun_star_beans_PropertyValues_hpp__ #include -#endif #include #include @@ -69,8 +67,7 @@ public: virtual ~CustomShapeProperties(); void apply( const CustomShapePropertiesPtr& ); - void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, - const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, + void pushToPropSet( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; void setShapePresetType( const rtl::OUString& rShapePresetType ){ maShapePresetType = rShapePresetType; }; diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index be6561c970d3..42457e6f4dde 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -35,6 +35,7 @@ #include "oox/helper/helper.hxx" namespace oox { + class GraphicHelper; class ModelObjectHelper; class PropertyMap; class PropertySet; @@ -156,8 +157,8 @@ struct FillProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -165,8 +166,8 @@ struct FillProperties /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -184,13 +185,13 @@ struct GraphicProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/drawingml/lineproperties.hxx b/oox/inc/oox/drawingml/lineproperties.hxx index 9a538db30156..0f034a89f65b 100644 --- a/oox/inc/oox/drawingml/lineproperties.hxx +++ b/oox/inc/oox/drawingml/lineproperties.hxx @@ -104,16 +104,16 @@ struct LineProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property map. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/dump/biffdumper.hxx b/oox/inc/oox/dump/biffdumper.hxx index 5a7e390d19a4..e9016fdf0b2b 100644 --- a/oox/inc/oox/dump/biffdumper.hxx +++ b/oox/inc/oox/dump/biffdumper.hxx @@ -217,7 +217,7 @@ protected: void dumpDffClientRect(); void dumpEmbeddedDff(); - void dumpOcxControl(); + void dumpControl(); private: typedef ::boost::shared_ptr< BiffSharedData > BiffSharedDataRef; @@ -242,7 +242,7 @@ void BiffObjectBase::writeRectItem( const String& rName, Type nLeft, Type nTop, Type nWidth, Type nHeight, const NameListWrapper& rListWrp, FormatType eFmtType ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeValueItem( "x-pos", nLeft, eFmtType, rListWrp ); writeValueItem( "y-pos", nTop, eFmtType, rListWrp ); @@ -508,6 +508,10 @@ protected: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); }; // ============================================================================ diff --git a/oox/inc/oox/dump/dumperbase.hxx b/oox/inc/oox/dump/dumperbase.hxx index ecca5751c16c..f65eeceebf27 100644 --- a/oox/inc/oox/dump/dumperbase.hxx +++ b/oox/inc/oox/dump/dumperbase.hxx @@ -61,6 +61,7 @@ namespace comphelper { namespace oox { class BinaryOutputStream; + class TextInputStream; } namespace oox { namespace core { @@ -576,43 +577,41 @@ protected: // ============================================================================ // ============================================================================ -typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > ConfigInputStreamRef; - class ConfigItemBase { public: virtual ~ConfigItemBase(); - void readConfigBlock( const ConfigInputStreamRef& rxStrm ); + void readConfigBlock( TextInputStream& rStrm ); protected: inline explicit ConfigItemBase() {} virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); void readConfigBlockContents( - const ConfigInputStreamRef& rxStrm ); + TextInputStream& rStrm ); private: enum LineType { LINETYPE_DATA, LINETYPE_END }; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, ::rtl::OUString& orKey, ::rtl::OUString& orData ) const; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm ) const; + TextInputStream& rStrm ) const; void processConfigItem( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); }; @@ -673,12 +672,12 @@ protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); @@ -721,7 +720,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -750,7 +749,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -777,7 +776,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -917,14 +916,14 @@ public: protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); private: bool readConfigFile( const ::rtl::OUString& rFileUrl ); template< typename ListType > - void readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ); + void readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ); void createShortList( const ::rtl::OUString& rData ); void createUnitConverter( const ::rtl::OUString& rData ); @@ -960,11 +959,11 @@ template< typename ListType > } template< typename ListType > -void SharedConfigData::readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ) +void SharedConfigData::readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ) { NameListRef xList = createNameList< ListType >( rListName ); if( xList.get() ) - xList->readConfigBlock( rxStrm ); + xList->readConfigBlock( rStrm ); } // ============================================================================ @@ -1182,7 +1181,7 @@ typedef ::boost::shared_ptr< Output > OutputRef; class IndentGuard { public: - inline explicit IndentGuard( Output& rOut ) : mrOut( rOut ) { mrOut.incIndent(); } + inline explicit IndentGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.incIndent(); } inline ~IndentGuard() { mrOut.decIndent(); } private: IndentGuard( const IndentGuard& ); @@ -1196,17 +1195,17 @@ private: class TableGuard { public: - inline explicit TableGuard( Output& rOut, sal_Int32 nW1 ) : - mrOut( rOut ) { mrOut.startTable( nW1 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } - inline explicit TableGuard( Output& rOut, size_t nColCount, + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } + inline explicit TableGuard( const OutputRef& rxOut, size_t nColCount, const sal_Int32* pnColWidths ) : - mrOut( rOut ) { mrOut.startTable( nColCount, pnColWidths ); } + mrOut( *rxOut ) { mrOut.startTable( nColCount, pnColWidths ); } inline ~TableGuard() { mrOut.endTable(); } inline void tab() { mrOut.tab(); } inline void tab( size_t nCol ) { mrOut.tab( nCol ); } @@ -1222,8 +1221,8 @@ private: class ItemGuard { public: - inline explicit ItemGuard( Output& rOut, const String& rName = EMPTY_STRING ) : - mrOut( rOut ) { mrOut.startItem( rName ); } + inline explicit ItemGuard( const OutputRef& rxOut, const String& rName = EMPTY_STRING ) : + mrOut( *rxOut ) { mrOut.startItem( rName ); } inline ~ItemGuard() { mrOut.endItem(); } inline void cont() { mrOut.contItem(); } private: @@ -1238,7 +1237,7 @@ private: class MultiItemsGuard { public: - inline explicit MultiItemsGuard( Output& rOut ) : mrOut( rOut ) { mrOut.startMultiItems(); } + inline explicit MultiItemsGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.startMultiItems(); } inline ~MultiItemsGuard() { mrOut.endMultiItems(); } private: MultiItemsGuard( const MultiItemsGuard& ); @@ -1280,7 +1279,8 @@ class ObjectBase : public Base public: virtual ~ObjectBase(); - inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxConfig->getFactory(); } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& + getFactory() const { return mxConfig->getFactory(); } void dump(); @@ -1333,6 +1333,10 @@ protected: const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); + void addPreferredStream( const String& rStrmName ); void addPreferredStorage( const String& rStrgPath ); @@ -1355,7 +1359,7 @@ private: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rItemName, - const ::rtl::OUString& rSysOutPath, + const ::rtl::OUString& rSysPath, bool bIsStrg, bool bIsStrm ); private: @@ -1397,10 +1401,6 @@ protected: // ------------------------------------------------------------------------ - inline Output& out() const { return *mxOut; } - - // ------------------------------------------------------------------------ - void writeEmptyItem( const String& rName ); void writeInfoItem( const String& rName, const String& rData ); void writeCharItem( const String& rName, sal_Unicode cData ); @@ -1451,7 +1451,7 @@ protected: template< typename Type > void writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' ); -private: +protected: OutputRef mxOut; }; @@ -1472,14 +1472,14 @@ void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWr template< typename Type > void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeName( cfg(), nData, rListWrp ); } template< typename Type > void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); addNameToItem( nData, rListWrp ); } @@ -1487,7 +1487,7 @@ void OutputObjectBase::writeDecItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1495,7 +1495,7 @@ void OutputObjectBase::writeHexItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeShortHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1503,7 +1503,7 @@ void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const template< typename Type > void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeBin( nData ); addNameToItem( nData, rListWrp ); } @@ -1511,7 +1511,7 @@ void OutputObjectBase::writeBinItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeFix( nData ); addNameToItem( nData, rListWrp ); } @@ -1519,7 +1519,7 @@ void OutputObjectBase::writeFixItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); aItem.cont(); mxOut->writeBool( nData != 0 ); @@ -1533,7 +1533,7 @@ void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatTy writeDecBoolItem( rName, nData, rListWrp ); else { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeValue( nData, eFmtType ); addNameToItem( nData, rListWrp ); } @@ -1549,7 +1549,7 @@ void OutputObjectBase::writeValueItem( const ItemFormat& rItemFmt, Type nData ) template< typename Type > void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData1 ); mxOut->writeChar( cSep ); mxOut->writeDec( nData2 ); @@ -1558,7 +1558,7 @@ void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type template< typename Type > void OutputObjectBase::writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData1 ); mxOut->writeChar( cSep ); mxOut->writeHex( nData2 ); @@ -1586,7 +1586,6 @@ protected: // ------------------------------------------------------------------------ - inline BinaryInputStream& in() const { return *mxStrm; } ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > getXInputStream() const; @@ -1655,7 +1654,7 @@ protected: template< typename Type > void dumpHexPair( const String& rName, sal_Unicode cSep = ',' ); -private: +protected: BinaryInputStreamRef mxStrm; }; @@ -1822,16 +1821,12 @@ public: rtl_TextEncoding eTextEnc ); protected: + virtual bool implIsValid() const; virtual void implDump(); virtual void implDumpLine( const ::rtl::OUString& rLine, sal_uInt32 nLine ); private: - bool readCharLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readUcs2Line( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - -private: - rtl_TextEncoding meTextEnc; + ::boost::shared_ptr< TextInputStream > mxTextStrm; }; // ============================================================================ diff --git a/oox/inc/oox/dump/oledumper.hxx b/oox/inc/oox/dump/oledumper.hxx index 539ca2a412d1..a0e9cd55e337 100644 --- a/oox/inc/oox/dump/oledumper.hxx +++ b/oox/inc/oox/dump/oledumper.hxx @@ -43,7 +43,26 @@ namespace dump { // ============================================================================ // ============================================================================ -class StdFontObject : public InputObjectBase +class OleInputObjectBase : public InputObjectBase +{ +protected: + inline explicit OleInputObjectBase() {} + + ::rtl::OUString dumpAnsiString32( const String& rName ); + ::rtl::OUString dumpUniString32( const String& rName ); + + sal_Int32 dumpStdClipboardFormat( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpAnsiString32OrStdClip( const String& rName ); + ::rtl::OUString dumpUniString32OrStdClip( const String& rName ); + + void writeOleColorItem( const String& rName, sal_uInt32 nColor ); + sal_uInt32 dumpOleColor( const String& rName ); +}; + +// ============================================================================ +// ============================================================================ + +class StdFontObject : public OleInputObjectBase { public: explicit StdFontObject( const InputObjectBase& rParent ); @@ -54,7 +73,7 @@ protected: // ============================================================================ -class StdPicObject : public InputObjectBase +class StdPicObject : public OleInputObjectBase { public: explicit StdPicObject( const InputObjectBase& rParent ); @@ -65,7 +84,7 @@ protected: // ============================================================================ -class StdHlinkObject : public InputObjectBase +class StdHlinkObject : public OleInputObjectBase { public: explicit StdHlinkObject( const InputObjectBase& rParent ); @@ -87,7 +106,27 @@ private: // ============================================================================ // ============================================================================ -class OlePropertyStreamObject : public BinaryStreamObject +class OleStreamObject : public OleInputObjectBase +{ +public: + explicit OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ + +class OleCompObjObject : public OleStreamObject +{ +public: + explicit OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + +protected: + virtual void implDump(); +}; + +// ============================================================================ +// ============================================================================ + +class OlePropertyStreamObject : public InputObjectBase { public: explicit OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); @@ -146,35 +185,140 @@ protected: // ============================================================================ // ============================================================================ -struct OcxFormSiteInfo +class ComCtlObjectBase : public OleInputObjectBase { - ::rtl::OUString maProgId; - sal_Int32 mnId; - sal_uInt32 mnLength; - bool mbInStream; +protected: + explicit ComCtlObjectBase( + const InputObjectBase& rParent, + sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual void implDump(); + virtual void implDumpProperties() = 0; + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); + +private: + bool dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor = SAL_MAX_UINT16, sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + bool dumpComCtlSize(); + bool dumpComCtlData( sal_uInt32& ornCommonPartSize ); + bool dumpComCtlCommon( sal_uInt32 nPartSize ); + bool dumpComCtlComplex(); - inline explicit OcxFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +protected: + sal_uInt32 mnDataId5; + sal_uInt32 mnDataId6; + sal_uInt16 mnVersion; + bool mbCommonPart; + bool mbComplexPart; }; -typedef ::std::vector< OcxFormSiteInfo > OcxFormSiteInfoVector; +// ============================================================================ -// ---------------------------------------------------------------------------- +class ComCtlScrollBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); -struct OcxFormSharedData +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlProgressBarObject : public ComCtlObjectBase { - OUStringVector maClassInfoProgIds; - OcxFormSiteInfoVector maSiteInfos; +public: + explicit ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlSliderObject : public ComCtlObjectBase +{ +public: + explicit ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); }; // ============================================================================ + +class ComCtlUpDownObject : public ComCtlObjectBase +{ +public: + explicit ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + // ============================================================================ -class OcxPropertyObjectBase : public InputObjectBase +class ComCtlImageListObject : public ComCtlObjectBase { +public: + explicit ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + protected: - inline explicit OcxPropertyObjectBase() {} + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; + +// ============================================================================ + +class ComCtlTabStripObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); +}; + +// ============================================================================ + +class ComCtlTreeViewObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + +private: + sal_uInt32 mnStringFlags; +}; + +// ============================================================================ + +class ComCtlStatusBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; - using InputObjectBase::construct; +// ============================================================================ +// ============================================================================ + +class AxPropertyObjectBase : public OleInputObjectBase +{ +protected: + inline explicit AxPropertyObjectBase() {} + + using OleInputObjectBase::construct; void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, @@ -213,19 +357,19 @@ protected: inline bool dumpBoolProperty() { return startNextProperty(); } inline sal_Int32 dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); } - inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-MOUSEPTR" ); } + inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OLE-MOUSEPTR" ); } template< typename Type > - inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-BORDERSTYLE" ); } + inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-BORDERSTYLE" ); } template< typename Type > - inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-SPECIALEFFECT" ); } - inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "OCX-ENABLED" ); } - inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "OCX-ORIENTATION" ); } - inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "OCX-CONV-MS" ); } - inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "OCX-IMAGEPOS" ); } - inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-IMAGESIZEMODE" ); } - inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "OCX-IMAGEALIGN" ); } - - sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "OCX-FLAGS" ); + inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-SPECIALEFFECT" ); } + inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "AX-ENABLED" ); } + inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "AX-ORIENTATION" ); } + inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "AX-CONV-MS" ); } + inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "AX-IMAGEPOS" ); } + inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "AX-IMAGESIZEMODE" ); } + inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "AX-IMAGEALIGN" ); } + + sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "AX-FLAGS" ); sal_uInt32 dumpColorProperty( sal_uInt32 nDefault ); sal_Unicode dumpUnicodeProperty(); void dumpUnknownProperty(); @@ -241,7 +385,7 @@ protected: void dumpToPosition( sal_Int64 nPos ); private: - void constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ); + void constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags ); void dumpVersion(); ::rtl::OUString dumpString( const String& rName, sal_uInt32 nSize, bool bArray ); @@ -285,13 +429,13 @@ private: // ---------------------------------------------------------------------------- template< typename Type > -void OcxPropertyObjectBase::alignInput() +void AxPropertyObjectBase::alignInput() { - in().skip( (sizeof( Type ) - ((in().tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); + mxStrm->skip( (sizeof( Type ) - ((mxStrm->tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); } template< typename Type > -Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -302,7 +446,7 @@ Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrappe } template< typename Type > -Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -314,10 +458,10 @@ Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrappe // ============================================================================ -class OcxCFontNewObject : public OcxPropertyObjectBase +class AxCFontNewObject : public AxPropertyObjectBase { public: - explicit OcxCFontNewObject( const InputObjectBase& rParent ); + explicit AxCFontNewObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -325,10 +469,10 @@ protected: // ============================================================================ -class OcxColumnInfoObject : public OcxPropertyObjectBase +class AxColumnInfoObject : public AxPropertyObjectBase { public: - explicit OcxColumnInfoObject( const InputObjectBase& rParent ); + explicit AxColumnInfoObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -336,10 +480,10 @@ protected: // ============================================================================ -class OcxCommandButtonObject : public OcxPropertyObjectBase +class AxCommandButtonObject : public AxPropertyObjectBase { public: - explicit OcxCommandButtonObject( const InputObjectBase& rParent ); + explicit AxCommandButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -348,10 +492,10 @@ protected: // ============================================================================ -class OcxMorphControlObject : public OcxPropertyObjectBase +class AxMorphControlObject : public AxPropertyObjectBase { public: - explicit OcxMorphControlObject( const InputObjectBase& rParent ); + explicit AxMorphControlObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -367,10 +511,10 @@ private: // ============================================================================ -class OcxLabelObject : public OcxPropertyObjectBase +class AxLabelObject : public AxPropertyObjectBase { public: - explicit OcxLabelObject( const InputObjectBase& rParent ); + explicit AxLabelObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -379,10 +523,10 @@ protected: // ============================================================================ -class OcxImageObject : public OcxPropertyObjectBase +class AxImageObject : public AxPropertyObjectBase { public: - explicit OcxImageObject( const InputObjectBase& rParent ); + explicit AxImageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -390,10 +534,10 @@ protected: // ============================================================================ -class OcxScrollBarObject : public OcxPropertyObjectBase +class AxScrollBarObject : public AxPropertyObjectBase { public: - explicit OcxScrollBarObject( const InputObjectBase& rParent ); + explicit AxScrollBarObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -401,10 +545,10 @@ protected: // ============================================================================ -class OcxSpinButtonObject : public OcxPropertyObjectBase +class AxSpinButtonObject : public AxPropertyObjectBase { public: - explicit OcxSpinButtonObject( const InputObjectBase& rParent ); + explicit AxSpinButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -412,10 +556,10 @@ protected: // ============================================================================ -class OcxTabStripObject : public OcxPropertyObjectBase +class AxTabStripObject : public AxPropertyObjectBase { public: - explicit OcxTabStripObject( const InputObjectBase& rParent ); + explicit AxTabStripObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -425,182 +569,189 @@ private: sal_Int32 mnTabFlagCount; }; +// ============================================================================ // ============================================================================ -class OcxControlObject : public InputObjectBase +class FormControlStreamObject : public OleInputObjectBase { public: - explicit OcxControlObject( - const InputObjectBase& rParent, - const ::rtl::OUString& rProgId, - sal_Int64 nLength ); + explicit FormControlStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + const ::rtl::OUString* pProgId = 0 ); + explicit FormControlStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString* pProgId = 0 ); protected: virtual void implDump(); +private: + void constructFormCtrlStrmObj( const ::rtl::OUString* pProgId ); + private: ::rtl::OUString maProgId; - sal_Int64 mnLength; + bool mbReadGuid; }; +// ============================================================================ // ============================================================================ -class OcxGuidControlObject : public InputObjectBase +struct VbaFormSiteInfo { -public: - explicit OcxGuidControlObject( - const InputObjectBase& rParent, - sal_Int64 nLength ); - explicit OcxGuidControlObject( - const OutputObjectBase& rParent, - const BinaryInputStreamRef& rxStrm ); - explicit OcxGuidControlObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName ); + ::rtl::OUString maProgId; + sal_Int32 mnId; + sal_uInt32 mnLength; + bool mbInStream; -protected: - virtual void implDump(); + inline explicit VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +}; -private: - sal_Int64 mnLength; +typedef ::std::vector< VbaFormSiteInfo > VbaFormSiteInfoVector; + +// ============================================================================ + +struct VbaFormSharedData +{ + OUStringVector maClassInfoProgIds; + VbaFormSiteInfoVector maSiteInfos; }; // ============================================================================ -class OcxControlsStreamObject : public InputObjectBase +class VbaFormClassInfoObject : public AxPropertyObjectBase { public: - explicit OcxControlsStreamObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + explicit VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; -// ============================================================================ // ============================================================================ -class OcxPageObject : public OcxPropertyObjectBase +class VbaFormSiteObject : public AxPropertyObjectBase { public: - explicit OcxPageObject( const InputObjectBase& rParent ); + explicit VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: virtual void implDumpShortProperties(); + +private: + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxMultiPageObject : public OcxPropertyObjectBase +class VbaFormDesignExtObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageObject( const InputObjectBase& rParent ); + explicit VbaFormDesignExtObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - sal_Int32 mnPageCount; }; // ============================================================================ -class OcxMultiPageStreamObject : public InputObjectBase +class VbaFStreamObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageStreamObject( + explicit VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + void dumpClassInfos(); + void dumpFormSites( sal_uInt32 nCount ); + void dumpSiteData(); + void dumpDesignExtender(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; + sal_uInt32 mnFlags; }; -// ============================================================================ // ============================================================================ -class OcxFormClassInfoObject : public OcxPropertyObjectBase +class VbaOStreamObject : public OleInputObjectBase { public: - explicit OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaOStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormSiteObject : public OcxPropertyObjectBase +class VbaPageObject : public AxPropertyObjectBase { public: - explicit OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - -private: - OcxFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormDesignExtObject : public OcxPropertyObjectBase +class VbaMultiPageObject : public AxPropertyObjectBase { public: - explicit OcxFormDesignExtObject( const InputObjectBase& rParent ); + explicit VbaMultiPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + sal_Int32 mnPageCount; }; // ============================================================================ -class OcxFormObject : public OcxPropertyObjectBase +class VbaXStreamObject : public InputObjectBase { public: - explicit OcxFormObject( + explicit VbaXStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - void dumpClassInfos(); - void dumpFormSites( sal_uInt32 nCount ); - void dumpSiteData(); - void dumpDesignExtender(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; - sal_uInt32 mnFlags; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormStorageObject : public OleStorageObject +class VbaContainerStorageObject : public OleStorageObject { public: - explicit OcxFormStorageObject( + explicit VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); @@ -621,7 +772,7 @@ private: bool isFormStorage( const ::rtl::OUString& rStrgPath ) const; private: - OcxFormSharedData maFormData; + VbaFormSharedData maFormData; }; // ============================================================================ @@ -713,7 +864,7 @@ private: // ============================================================================ -class VbaFormStorageObject : public OcxFormStorageObject +class VbaFormStorageObject : public VbaContainerStorageObject { public: explicit VbaFormStorageObject( @@ -759,6 +910,23 @@ private: // ============================================================================ // ============================================================================ +class ActiveXStorageObject : public VbaContainerStorageObject +{ +public: + explicit ActiveXStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath ); + +protected: + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ +// ============================================================================ + } // namespace dump } // namespace oox diff --git a/oox/inc/oox/dump/xlsbdumper.hxx b/oox/inc/oox/dump/xlsbdumper.hxx index 95723f6b8d4e..345202f67a4a 100644 --- a/oox/inc/oox/dump/xlsbdumper.hxx +++ b/oox/inc/oox/dump/xlsbdumper.hxx @@ -98,7 +98,7 @@ private: private: typedef ::boost::shared_ptr< RecordInputStream > RecordInputStreamRef; - RecordInputStreamRef mxStrm; + RecordInputStreamRef mxBiffStrm; NameListRef mxErrCodes; }; diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx index 19933ca03c04..8f58e2de4d9e 100644 --- a/oox/inc/oox/helper/binaryinputstream.hxx +++ b/oox/inc/oox/helper/binaryinputstream.hxx @@ -34,6 +34,8 @@ namespace oox { +class BinaryOutputStream; + // ============================================================================ /** Interface for binary input stream classes. @@ -108,6 +110,8 @@ public: False = NUL characters are replaced by question marks (default). */ ::rtl::OUString readUnicodeArray( sal_Int32 nChars, bool bAllowNulChars = false ); + /** Copies nBytes bytes from the current position to the passed output stream. */ + void copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); private: /** Used by the readValue() template functions to read built-in types. @@ -216,6 +220,71 @@ typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef; // ============================================================================ +/** Wraps a BinaryInputStream and provides access to a specific part of the + stream data. + + @descr + Provides access to the stream data block starting at the current + position of the stream, and with a specific length. If the wrapped + stream is seekable, this wrapper will treat the position the wrapped + has at construction time as position "0" (therefore the class name). + */ +class RelativeInputStream : public BinaryInputStream +{ +public: + /** Constructs the wrapper object for the passed stream. + + @attention + The passed input stream MUST live at least as long as this stream + wrapper. The stream MUST NOT be changed from outside as long as + this stream wrapper is used to read from it. + + @param nLength + If specified, restricts the amount of data that can be read from + the passed input stream. + */ + explicit RelativeInputStream( + BinaryInputStream& rInStrm, + sal_Int64 nLength = SAL_MAX_INT64 ); + + /** Returns whether the wrapped stream is seekable. */ + virtual bool isSeekable() const; + /** Returns the size of the data block in the wrapped stream offered by + this wrapper. */ + virtual sal_Int64 getLength() const; + /** Returns the current relative stream position. */ + virtual sal_Int64 tell() const; + /** Seeks the stream to the passed relative position, if the wrapped stream + is seekable. */ + virtual void seek( sal_Int64 nPos ); + + /** Reads nBytes bytes to the passed sequence. Does not read out of the + data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. Does not read out of + the data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. This works for + non-seekable streams too. Does not seek out of the data block. */ + virtual void skip( sal_Int32 nBytes ); + + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline RelativeInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + +private: + BinaryInputStream& mrInStrm; + sal_Int64 mnStartPos; + sal_Int64 mnRelPos; + sal_Int64 mnLength; +}; + +typedef ::boost::shared_ptr< RelativeInputStream > RelativeInputStreamRef; + +// ============================================================================ + } // namespace oox #endif diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx index b229dbd18901..d2f0f8b36ffa 100644 --- a/oox/inc/oox/helper/binaryoutputstream.hxx +++ b/oox/inc/oox/helper/binaryoutputstream.hxx @@ -34,8 +34,6 @@ namespace oox { -class BinaryInputStream; - // ============================================================================ /** Interface for binary output stream classes. @@ -50,9 +48,6 @@ public: /** Derived classes implement writing from the (existing) buffer pMem. */ virtual void writeMemory( const void* pMem, sal_Int32 nBytes ) = 0; - /** Copies nBytes bytes from the current position of the passed input stream. */ - void copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); - /** Writes a value to the stream and converts it to platform byte order. Supported types: SAL integers (8 to 64 bit), float, double. */ template< typename Type > diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 18d868660faa..5cebdc681e8d 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -38,7 +38,8 @@ typedef ::com::sun::star::uno::Sequence< sal_Int8 > StreamDataSequence; // ============================================================================ -/** Base interface for seekable binary stream classes. */ +/** Base interface for binary stream classes. Implemenetations may or may not + support seeking the stream. */ class BinaryStreamBase { public: @@ -46,11 +47,14 @@ public: /** Derived classes return whether the stream is seekable. Default: false. */ virtual bool isSeekable() const; - /** Derived classes returns the size of the stream, if seekable, otherwise/default: -1. */ + /** Derived classes return the size of the stream, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 getLength() const; - /** Derived classes return the current stream position, if seekable, otherwise/default: -1. */ + /** Derived classes return the current stream position, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 tell() const; - /** Derived classes implement seeking the stream to the passed position, if seekable. */ + /** Derived classes implement seeking the stream to the passed position, if + the stream is seekable. */ virtual void seek( sal_Int64 nPos ); /** Returns true, if the stream position is invalid (EOF). This flag turns @@ -63,6 +67,9 @@ public: inline void seekToStart() { seek( 0 ); } /** Seeks the stream to the end, if stream is seekable. */ inline void seekToEnd() { seek( getLength() ); } + /** Seeks the stream forward to a position that is a multiple of the passed + block size, relative to the passed stream position, if stream is seekable. */ + void align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); protected: inline explicit BinaryStreamBase() : mbEof( false ) {} diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index a077c667ae4c..f4f3717eac3f 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -84,34 +84,86 @@ public: Does *not* check whether the last element is an empty reference. */ inline sal_Int32 getLastIndex() const { return static_cast< sal_Int32 >( this->size() ) - 1; } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > - inline void forEach( const FunctorType& rFunctor ) const + inline void forEach( FunctorType aFunctor ) const { - ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); + ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( aFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } + + /** Calls the passed functor for every contained object. Passes the index as + first argument and the object reference as second argument to rFunctor. */ + template< typename FunctorType > + inline void forEachWithIndex( const FunctorType& rFunctor ) const + { + ::std::for_each( this->begin(), this->end(), ForEachFunctorWithIndex< FunctorType >( rFunctor ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index to the member function. */ + template< typename FuncType > + inline void forEachMemWithIndex( FuncType pFunc ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType > + inline void forEachMemWithIndex( FuncType pFunc, ParamType aParam ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + /** Searches for an element by using the passed functor that takes a constant reference of the object type (const ObjType&). */ template< typename FunctorType > @@ -125,17 +177,26 @@ private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rxValue ) const { if( rxValue.get() ) mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( *rxValue ); } + }; + + template< typename FunctorType > + struct ForEachFunctorWithIndex + { + FunctorType maFunctor; + sal_Int32 mnIndex; + inline explicit ForEachFunctorWithIndex( const FunctorType& rFunctor ) : maFunctor( rFunctor ), mnIndex( 0 ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( mnIndex, *rxValue ); ++mnIndex; } }; template< typename FunctorType > struct FindFunctor { - const FunctorType& mrFunctor; - inline explicit FindFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline bool operator()( const value_type& rxValue ) const { return rxValue.get() && mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit FindFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline bool operator()( const value_type& rxValue ) { return rxValue.get() && maFunctor( *rxValue ); } }; inline const value_type* getRef( sal_Int32 nIndex ) const @@ -173,41 +234,53 @@ public: return pxRef && pxRef->get(); } - /** Returns a reference to the object accossiated to the passed key, or 0 on error. */ + /** Returns a reference to the object accossiated to the passed key, or an + empty reference on error. */ inline mapped_type get( key_type nKey ) const { if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef; return mapped_type(); } - /** Calls the passed functor for every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > inline void forEach( const FunctorType& rFunctor ) const { ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } /** Calls the passed functor for every contained object. Passes the key as first argument and the object reference as second argument to rFunctor. */ template< typename FunctorType > @@ -240,21 +313,29 @@ public: forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object. + Passes the object key as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithKey( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( *rValue.second ); } }; template< typename FunctorType > struct ForEachFunctorWithKey { - const FunctorType& mrFunctor; - inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( rValue.first, *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( rValue.first, *rValue.second ); } }; inline const mapped_type* getRef( key_type nKey ) const @@ -453,7 +534,7 @@ public: /** Returns the reference to an existing element of the passed vector, or the passed default value, if the passed index is out of bounds. */ template< typename Type > - static Type& getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); + static Type& getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); /** Returns the pointer to an existing element of the passed map, or a null pointer, if an element with the passed key does not exist. */ @@ -522,7 +603,7 @@ const Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVec } template< typename Type > -Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) +Type& ContainerHelper::getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) { return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault; } diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index d6e01d0fff6b..dc9dddfea7e8 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -29,24 +29,30 @@ #define OOX_HELPER_GRAPHICHELPER_HXX #include +#include #include +#include #include #include "oox/helper/binarystreambase.hxx" namespace com { namespace sun { namespace star { - namespace uno { class XComponentContext; } - namespace lang { class XMultiServiceFactory; } + namespace awt { struct Point; } + namespace awt { struct Size; } + namespace awt { class XUnitConversion; } namespace io { class XInputStream; } namespace graphic { class XGraphic; } namespace graphic { class XGraphicObject; } namespace graphic { class XGraphicProvider; } + namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } } } } namespace oox { // ============================================================================ -/** Provides helper functions for graphics and graphic objects handling. +/** Provides helper functions for colors, device measurement conversion, + graphics, and graphic objects handling. All createGraphicObject() and importGraphicObject() functions create persistent graphic objects internally and store them in an internal @@ -60,39 +66,83 @@ class GraphicHelper { public: explicit GraphicHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); - ~GraphicHelper(); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory ); + virtual ~GraphicHelper(); + + /** Returns a system color specified by the passed XML token identifier. */ + sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; + + /** Returns information about the output device. */ + const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; + + /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const; + /** Converts the passed value from vertical screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const; + /** Converts the passed point from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Point convertScreenPixelToHmm( const ::com::sun::star::awt::Point& rPixel ) const; + /** Converts the passed size from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Size convertScreenPixelToHmm( const ::com::sun::star::awt::Size& rPixel ) const; + + /** Converts the passed value from 1/100 mm to horizontal screen pixels. */ + double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const; + /** Converts the passed value from 1/100 mm to vertical screen pixels. */ + double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const; + /** Converts the passed point from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Point convertHmmToScreenPixel( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Size convertHmmToScreenPixel( const ::com::sun::star::awt::Size& rHmm ) const; + + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Point convertAppFontToHmm( const ::com::sun::star::awt::Point& rAppFont ) const; + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Size convertAppFontToHmm( const ::com::sun::star::awt::Size& rAppFont ) const; + + /** Converts the passed point from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Point convertHmmToAppFont( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Size convertHmmToAppFont( const ::com::sun::star::awt::Size& rHmm ) const; /** Imports a graphic from the passed input stream. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > importGraphic( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Imports a graphic from the passed binary memory block. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > - importGraphic( const StreamDataSequence& rGraphicData ); + importGraphic( const StreamDataSequence& rGraphicData ) const; /** Creates a persistent graphic object from the passed graphic. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString createGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); + const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const; /** Creates a persistent graphic object from the passed input stream. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString importGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Creates a persistent graphic object from the passed binary memory block. @return The URL of the created and internally cached graphic object. */ - ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ); + ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ) const; private: + typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > > GraphicObjectDeque; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicProvider > mxGraphicProvider; - GraphicObjectDeque maGraphicObjects; - const ::rtl::OUString maGraphicObjScheme; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion; + ::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info. + SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values. + mutable GraphicObjectDeque maGraphicObjects; /// Caches all created graphic objects to keep them alive. + const ::rtl::OUString maGraphicObjScheme; /// The URL scheme name for graphic objects. + double mfPixelPerHmmX; /// Number of screen pixels per 1/100 mm in X direction. + double mfPixelPerHmmY; /// Number of screen pixels per 1/100 mm in Y direction. }; // ============================================================================ diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx index 5884855bc50d..c68fe9ce83f8 100644 --- a/oox/inc/oox/helper/helper.hxx +++ b/oox/inc/oox/helper/helper.hxx @@ -69,7 +69,29 @@ namespace oox { #define OUSTRING_TO_CSTR( str ) \ ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr() -// ============================================================================ +// Common constants =========================================================== + +const sal_uInt8 WINDOWS_CHARSET_ANSI = 0; +const sal_uInt8 WINDOWS_CHARSET_DEFAULT = 1; +const sal_uInt8 WINDOWS_CHARSET_SYMBOL = 2; +const sal_uInt8 WINDOWS_CHARSET_APPLE_ROMAN = 77; +const sal_uInt8 WINDOWS_CHARSET_SHIFTJIS = 128; +const sal_uInt8 WINDOWS_CHARSET_HANGEUL = 129; +const sal_uInt8 WINDOWS_CHARSET_JOHAB = 130; +const sal_uInt8 WINDOWS_CHARSET_GB2312 = 134; +const sal_uInt8 WINDOWS_CHARSET_BIG5 = 136; +const sal_uInt8 WINDOWS_CHARSET_GREEK = 161; +const sal_uInt8 WINDOWS_CHARSET_TURKISH = 162; +const sal_uInt8 WINDOWS_CHARSET_VIETNAMESE = 163; +const sal_uInt8 WINDOWS_CHARSET_HEBREW = 177; +const sal_uInt8 WINDOWS_CHARSET_ARABIC = 178; +const sal_uInt8 WINDOWS_CHARSET_BALTIC = 186; +const sal_uInt8 WINDOWS_CHARSET_RUSSIAN = 204; +const sal_uInt8 WINDOWS_CHARSET_THAI = 222; +const sal_uInt8 WINDOWS_CHARSET_EASTERN = 238; +const sal_uInt8 WINDOWS_CHARSET_OEM = 255; + +// ---------------------------------------------------------------------------- const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color for API calls. const sal_Int32 API_RGB_BLACK = 0x00000; /// Black color for API calls. diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx index cead2ad74fb1..a9ef27e8cb98 100644 --- a/oox/inc/oox/helper/modelobjecthelper.hxx +++ b/oox/inc/oox/helper/modelobjecthelper.hxx @@ -53,7 +53,7 @@ class ModelObjectHelper { public: explicit ModelObjectHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory ); /** Returns true, if the model contains a line marker with the passed name. */ bool hasLineMarker( const ::rtl::OUString& rMarkerName ) const; diff --git a/oox/inc/oox/helper/olestorage.hxx b/oox/inc/oox/helper/olestorage.hxx deleted file mode 100644 index a8174a167729..000000000000 --- a/oox/inc/oox/helper/olestorage.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_HELPER_OLESTORAGE_HXX -#define OOX_HELPER_OLESTORAGE_HXX - -#include "oox/helper/storagebase.hxx" - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace container { class XNameContainer; } - namespace container { class XNameAccess; } -} } } - -namespace oox { - -// ============================================================================ - -/** Implements stream access for binary OLE storages. */ -class OleStorage : public StorageBase -{ -public: - explicit OleStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream, - bool bBaseStreamAccess ); - - explicit OleStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxStream, - bool bBaseStreamAccess ); - - virtual ~OleStorage(); - -private: - explicit OleStorage( - const OleStorage& rParentStorage, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxElementsAccess, - const ::rtl::OUString& rElementName ); - - /** Returns true, if the object represents a valid storage. */ - virtual bool implIsStorage() const; - - /** Returns the com.sun.star.embed.XStorage interface of the current storage. - - @attention - This function is not implemented for binary OLE storages. - */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - implGetXStorage() const; - - /** Returns the names of all elements of this storage. */ - virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; - - /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); - - /** Opens and returns the specified input stream from the storage. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > - implOpenInputStream( const ::rtl::OUString& rElementName ); - - /** Opens and returns the specified output stream from the storage. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > - implOpenOutputStream( const ::rtl::OUString& rElementName ); - -private: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > XNameContainerRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > XNameAccessRef; - - XNameContainerRef mxStorage; /// Complete storage based on input or output stream. - XNameAccessRef mxElements; /// Access to elements of current sub storage. -}; - -// ============================================================================ - -} // namespace oox - -#endif - diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx index bdb81c6c3e83..a1769374d959 100644 --- a/oox/inc/oox/helper/propertyset.hxx +++ b/oox/inc/oox/helper/propertyset.hxx @@ -92,6 +92,10 @@ public: template< typename Type > inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const; + /** Gets the specified property from the property set. + @return the property value, or an empty Any, if the property is missing. */ + ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const; + /** Gets the specified boolean property from the property set. @return true = property contains true; false = property contains false or error occured. */ bool getBoolProperty( sal_Int32 nPropId ) const; diff --git a/oox/inc/oox/helper/storagebase.hxx b/oox/inc/oox/helper/storagebase.hxx index b23032fe2ac0..5a179e73cf75 100644 --- a/oox/inc/oox/helper/storagebase.hxx +++ b/oox/inc/oox/helper/storagebase.hxx @@ -28,12 +28,8 @@ #ifndef OOX_HELPER_STORAGEBASE_HXX #define OOX_HELPER_STORAGEBASE_HXX -#include -#include -#include -#include -#include -#include +#include "oox/dllapi.h" +#include "oox/helper/containerhelper.hxx" namespace com { namespace sun { namespace star { namespace embed { class XStorage; } @@ -71,6 +67,13 @@ public: /** Returns true, if the object represents a valid storage. */ bool isStorage() const; + /** Returns true, if the object represents the root storage. */ + bool isRootStorage() const; + + /** Returns true, if the storage operates in read-only mode (based on an + input stream). */ + bool isReadOnly() const; + /** Returns the com.sun.star.embed.XStorage interface of the current storage. */ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getXStorage() const; @@ -81,7 +84,8 @@ public: /** Returns the full path of this storage. */ ::rtl::OUString getPath() const; - /** Fills the passed vector with the names of all elements of this storage. */ + /** Fills the passed vector with the names of all direct elements of this + storage. */ void getElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. @@ -89,10 +93,11 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate - True = create missing sub storages (for export filters). + @param bCreateMissing + True = create missing sub storages (for export filters). Must be + false for storages based on input streams. */ - StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreate ); + StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. @@ -116,13 +121,27 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > openOutputStream( const ::rtl::OUString& rStreamName ); - /** Commits the changes to the storage and all the substorages. (in case it is transacted object) + /** Copies the specified element from this storage to the passed + destination storage. + + @param rElementName + The name of the embedded storage or stream. The name may contain + slashes to specify an element in an embedded substorage. In this + case, the element will be copied to the same substorage in the + destination storage. */ - void commit(); + void copyToStorage( StorageBase& rDestStrg, const ::rtl::OUString& rElementName ); + + /** Copies all streams of this storage and of all substorages to the passed + destination. */ + void copyStorageToStorage( StorageBase& rDestStrg ); + + /** Commits the changes to the storage and all substorages. */ + void commit(); protected: /** Special constructor for sub storage objects. */ - explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName ); + explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName, bool bReadOnly ); private: StorageBase( const StorageBase& ); @@ -149,19 +168,24 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ) = 0; - StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + /** Commits the current storage. */ + virtual void implCommit() const = 0; + + /** Helper that opens and caches the specified direct substorage. */ + StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); private: - typedef ::std::map< ::rtl::OUString, StorageRef > SubStorageMap; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > XInputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > XStreamRef; + typedef RefMap< ::rtl::OUString, StorageBase > SubStorageMap; SubStorageMap maSubStorages; /// Map of direct sub storages. - XInputStreamRef mxInStream; /// Cached base input stream (to keep it alive). - XStreamRef mxOutStream; /// Cached base output stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + mxInStream; /// Cached base input stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > + mxOutStream; /// Cached base output stream (to keep it alive). + ::rtl::OUString maParentPath; /// Full path of parent storage. ::rtl::OUString maStorageName; /// Name of this storage, if it is a substorage. - const StorageBase* mpParentStorage; /// Parent storage if this is a sub storage. bool mbBaseStreamAccess; /// True = access base streams with empty stream name. + bool mbReadOnly; /// True = storage opened read-only (based on input stream). }; // ============================================================================ @@ -169,4 +193,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/helper/textinputstream.hxx b/oox/inc/oox/helper/textinputstream.hxx new file mode 100755 index 000000000000..1e74825ee713 --- /dev/null +++ b/oox/inc/oox/helper/textinputstream.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX +#define OOX_HELPER_RECORDINPUTSTREAM_HXX + +#include "oox/helper/binaryinputstream.hxx" + +namespace oox { + +// ============================================================================ + +class TextInputStream +{ +public: + explicit TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc ); + + /** Returns true, if the wrapped input stream is in EOF state. */ + bool isEof() const; + /** Reads a text line from the stream. */ + ::rtl::OUString readLine(); + +private: + BinaryInputStream& mrInStrm; + rtl_TextEncoding meTextEnc; + sal_Unicode mcLastEolChar; +}; + +// ============================================================================ + +} // namespace oox + +#endif + diff --git a/oox/inc/oox/helper/zipstorage.hxx b/oox/inc/oox/helper/zipstorage.hxx index b6eef63b47de..0c9a15c10077 100644 --- a/oox/inc/oox/helper/zipstorage.hxx +++ b/oox/inc/oox/helper/zipstorage.hxx @@ -69,7 +69,7 @@ private: virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > @@ -79,6 +79,9 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ); + /** Commits the current storage. */ + virtual void implCommit() const; + private: typedef ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > XStorageRef; @@ -90,4 +93,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axbinaryreader.hxx b/oox/inc/oox/ole/axbinaryreader.hxx index 3db0bae7cee4..d036e958a446 100644 --- a/oox/inc/oox/ole/axbinaryreader.hxx +++ b/oox/inc/oox/ole/axbinaryreader.hxx @@ -28,6 +28,7 @@ #ifndef OOX_OLE_AXBINARYREADER_HXX #define OOX_OLE_AXBINARYREADER_HXX +#include #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/containerhelper.hxx" @@ -36,15 +37,24 @@ namespace ole { // ============================================================================ -/** A wrapper for an unseekable binary input stream. */ +/** A wrapper for a binary input stream that supports aligned read operations. + + The implementation does not support seeking back the wrapped stream. All + seeking operations (tell, seek, align) are performed relative to the + position of the wrapped stream at construction time of this wrapper. It is + possible to construct this wrapper with an unseekable input stream without + loosing any functionality. + */ class AxAlignedInputStream : public BinaryInputStream { public: explicit AxAlignedInputStream( BinaryInputStream& rInStrm ); - /** Return the current stream position (relative to position at construction time). */ + /** Return the current relative stream position (relative to position of + the wrapped stream at construction time). */ virtual sal_Int64 tell() const; - /** Seeks the stream to the passed position, if it is behind the current position. */ + /** Seeks the stream to the passed relative position, if it is behind the + current position. */ virtual void seek( sal_Int64 nPos ); /** Reads nBytes bytes to the passed sequence. @@ -56,7 +66,8 @@ public: /** Seeks the stream forward by the passed number of bytes. */ virtual void skip( sal_Int32 nBytes ); - /** Aligns the stream to a multiple of the passed size. */ + /** Aligns the stream to a multiple of the passed size (relative to the + position of the wrapped stream at construction time). */ void align( size_t nSize ); /** Aligns the stream according to the passed type and reads an atomar value. */ @@ -73,6 +84,50 @@ private: // ============================================================================ +/** A pair of integer values as a property. */ +typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData; + +// ============================================================================ + +const sal_uInt32 AX_FONTDATA_BOLD = 0x00000001; +const sal_uInt32 AX_FONTDATA_ITALIC = 0x00000002; +const sal_uInt32 AX_FONTDATA_UNDERLINE = 0x00000004; +const sal_uInt32 AX_FONTDATA_STRIKEOUT = 0x00000008; +const sal_uInt32 AX_FONTDATA_DISABLED = 0x00002000; +const sal_uInt32 AX_FONTDATA_AUTOCOLOR = 0x40000000; + +const sal_Int32 AX_FONTDATA_LEFT = 1; +const sal_Int32 AX_FONTDATA_RIGHT = 2; +const sal_Int32 AX_FONTDATA_CENTER = 3; + +/** All entries of a font property. */ +struct AxFontData +{ + ::rtl::OUString maFontName; /// Name of the used font. + sal_uInt32 mnFontEffects; /// Font effect flags. + sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). + sal_Int32 mnFontCharSet; /// Windows character set of the font. + sal_Int32 mnHorAlign; /// Horizontal text alignment. + + explicit AxFontData(); + + /** Converts the internal representation of the font height to points. */ + sal_Int16 getHeightPoints() const; + /** Converts the passed font height from points to the internal representation. */ + void setHeightPoints( sal_Int16 nPoints ); + + /** Reads the font data settings from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream that contains + an OLE StdFont structure. */ + bool importStdFont( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream depending on + the GUID preceding the actual font data. */ + bool importGuidAndFont( BinaryInputStream& rInStrm ); +}; + +// ============================================================================ + /** Import helper to read simple and complex ActiveX form control properties from a binary input stream. */ class AxBinaryPropertyReader @@ -90,10 +145,16 @@ public: void readBoolProperty( bool& orbValue, bool bReverse = false ); /** Reads the next pair property from the stream, if the respective flag in the property mask is set. */ - void readPairProperty( sal_Int32& ornValue1, sal_Int32& ornValue2 ); + void readPairProperty( AxPairData& orPairData ); /** Reads the next string property from the stream, if the respective flag in the property mask is set. */ void readStringProperty( ::rtl::OUString& orValue ); + /** Reads the next GUID property from the stream, if the respective flag + in the property mask is set. The GUID will be enclosed in braces. */ + void readGuidProperty( ::rtl::OUString& orGuid ); + /** Reads the next font property from the stream, if the respective flag in + the property mask is set. */ + void readFontProperty( AxFontData& orFontData ); /** Reads the next picture property from the stream, if the respective flag in the property mask is set. */ void readPictureProperty( StreamDataSequence& orPicData ); @@ -105,9 +166,18 @@ public: /** Skips the next boolean property value in the stream, if the respective flag in the property mask is set. */ inline void skipBoolProperty() { startNextProperty(); } + /** Skips the next pair property in the stream, if the respective flag in + the property mask is set. */ + void skipPairProperty() { readPairProperty( maDummyPairData ); } /** Skips the next string property in the stream, if the respective flag in the property mask is set. */ inline void skipStringProperty() { readStringProperty( maDummyString ); } + /** Skips the next GUID property in the stream, if the respective flag in + the property mask is set. */ + inline void skipGuidProperty() { readGuidProperty( maDummyString ); } + /** Skips the next font property in the stream, if the respective flag in + the property mask is set. */ + inline void skipFontProperty() { readFontProperty( maDummyFontData ); } /** Skips the next picture property in the stream, if the respective flag in the property mask is set. */ inline void skipPictureProperty() { readPictureProperty( maDummyPicData ); } @@ -133,11 +203,10 @@ private: /** Complex property for a 32-bit value pair, e.g. point or size. */ struct PairProperty : public ComplexProperty { - sal_Int32& mrnValue1; - sal_Int32& mrnValue2; + AxPairData& mrPairData; - inline explicit PairProperty( sal_Int32& rnValue1, sal_Int32& rnValue2 ) : - mrnValue1( rnValue1 ), mrnValue2( rnValue2 ) {} + inline explicit PairProperty( AxPairData& rPairData ) : + mrPairData( rPairData ) {} virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; @@ -152,6 +221,26 @@ private: virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; + /** Complex property for a GUID value. */ + struct GuidProperty : public ComplexProperty + { + ::rtl::OUString& mrGuid; + + inline explicit GuidProperty( ::rtl::OUString& rGuid ) : + mrGuid( rGuid ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + /** Stream property for a font structure. */ + struct FontProperty : public ComplexProperty + { + AxFontData& mrFontData; + + inline explicit FontProperty( AxFontData& rFontData ) : + mrFontData( rFontData ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + /** Stream property for a picture or mouse icon. */ struct PictureProperty : public ComplexProperty { @@ -168,6 +257,8 @@ private: AxAlignedInputStream maInStrm; /// The input stream to read from. ComplexPropVector maLargeProps; /// Stores info for all used large properties. ComplexPropVector maStreamProps; /// Stores info for all used stream data properties. + AxPairData maDummyPairData; /// Dummy pair for unsupported properties. + AxFontData maDummyFontData; /// Dummy font for unsupported properties. StreamDataSequence maDummyPicData; /// Dummy picture for unsupported properties. ::rtl::OUString maDummyString; /// Dummy string for unsupported properties. sal_Int64 mnPropFlags; /// Flags specifying existing properties. diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx index b5a5741d134d..7c533334cc49 100644 --- a/oox/inc/oox/ole/axcontrol.hxx +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -28,82 +28,389 @@ #ifndef OOX_OLE_AXCONTROL_HXX #define OOX_OLE_AXCONTROL_HXX -#include +#include #include "oox/helper/binarystreambase.hxx" +#include "oox/ole/axbinaryreader.hxx" +#include "oox/ole/olehelper.hxx" namespace com { namespace sun { namespace star { namespace awt { class XControlModel; } + namespace container { class XIndexContainer; } + namespace drawing { class XDrawPage; } + namespace form { class XFormsSupplier; } + namespace lang { class XMultiServiceFactory; } } } } namespace oox { class BinaryInputStream; + class GraphicHelper; class PropertyMap; } namespace oox { namespace ole { -class AxControlHelper; +// ============================================================================ + +const sal_Char* const COMCTL_GUID_SCROLLBAR_60 = "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_50 = "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_60 = "{35053A22-8589-11D1-B16A-00C0F0283628}"; + +// ---------------------------------------------------------------------------- + +const sal_Char* const AX_GUID_COMMANDBUTTON = "{D7053240-CE69-11CD-A777-00DD01143C57}"; +const sal_Char* const AX_GUID_LABEL = "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}"; +const sal_Char* const AX_GUID_IMAGE = "{4C599241-6926-101B-9992-00000B65C6F9}"; +const sal_Char* const AX_GUID_TOGGLEBUTTON = "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_CHECKBOX = "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_OPTIONBUTTON = "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_TEXTBOX = "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_LISTBOX = "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_COMBOBOX = "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_SPINBUTTON = "{79176FB0-B7F2-11CE-97EF-00AA006D2776}"; +const sal_Char* const AX_GUID_SCROLLBAR = "{DFD181E0-5E2F-11CE-A449-00AA004A803D}"; +const sal_Char* const AX_GUID_FRAME = "{6E182020-F460-11CE-9BCD-00AA00608E01}"; + +const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; +const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; +const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; +const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; +const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; + +const sal_Int32 AX_BORDERSTYLE_NONE = 0; +const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; + +const sal_Int32 AX_SPECIALEFFECT_FLAT = 0; +const sal_Int32 AX_SPECIALEFFECT_RAISED = 1; +const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2; +const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3; +const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6; + +const sal_Int32 AX_PICSIZE_CLIP = 0; +const sal_Int32 AX_PICSIZE_STRETCH = 1; +const sal_Int32 AX_PICSIZE_ZOOM = 3; + +const sal_Int32 AX_PICALIGN_TOPLEFT = 0; +const sal_Int32 AX_PICALIGN_TOPRIGHT = 1; +const sal_Int32 AX_PICALIGN_CENTER = 2; +const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; +const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; + +// ---------------------------------------------------------------------------- + +/** Enumerates all UNO API control types supported by these filters. */ +enum ApiControlType +{ + API_CONTROL_BUTTON, + API_CONTROL_FIXEDTEXT, + API_CONTROL_IMAGE, + API_CONTROL_CHECKBOX, + API_CONTROL_RADIOBUTTON, + API_CONTROL_EDIT, + API_CONTROL_LISTBOX, + API_CONTROL_COMBOBOX, + API_CONTROL_SPINBUTTON, + API_CONTROL_SCROLLBAR, + API_CONTROL_PROGRESSBAR, + API_CONTROL_GROUPBOX, + API_CONTROL_DIALOG +}; + +// ============================================================================ + +/** Specifies how a form control supports transparent background. */ +enum ApiTransparencyMode +{ + API_TRANSPARENCY_NOTSUPPORTED, /// Control does not support transparency. + API_TRANSPARENCY_VOID, /// Transparency is enabled by missing fill color. + API_TRANSPARENCY_PAINTTRANSPARENT /// Transparency is enabled by the 'PaintTransparent' property. +}; + +/** Specifies how a form control supports the DefaultState property. */ +enum ApiDefaultStateMode +{ + API_DEFAULTSTATE_BOOLEAN, /// Control does not support tri-state, state is given as boolean. + API_DEFAULTSTATE_SHORT, /// Control does not support tri-state, state is given as short. + API_DEFAULTSTATE_TRISTATE /// Control supports tri-state, state is given as short. +}; + +// ---------------------------------------------------------------------------- + +/** A base class with useful helper functions for something that is able to + convert ActiveX and ComCtl form controls. + */ +class ControlConverter +{ +public: + explicit ControlConverter( + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + virtual ~ControlConverter(); + + // Generic conversion ----------------------------------------------------- + + /** Converts the passed position in 1/100 mm to UNO properties. */ + void convertPosition( + PropertyMap& rPropMap, + const AxPairData& rPos ) const; + + /** Converts the passed size in 1/100 mm to UNO properties. */ + void convertSize( + PropertyMap& rPropMap, + const AxPairData& rSize ) const; + + /** Converts the passed encoded OLE color to UNO properties. */ + void convertColor( + PropertyMap& rPropMap, + sal_Int32 nPropId, + sal_uInt32 nOleColor ) const; + + /** Converts the passed StdPic picture stream to UNO properties. */ + void convertPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData ) const; + + /** Converts the control orientation to UNO properties. */ + void convertOrientation( + PropertyMap& rPropMap, + bool bHorizontal ) const; + + /** Converts common scrollbar settings to UNO properties. */ + void convertScrollBar( + PropertyMap& rPropMap, + sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition, + sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const; + + // ActiveX (Forms 2.0) specific conversion -------------------------------- + + /** Converts the Forms 2.0 background formatting to UNO properties. */ + void convertAxBackground( + PropertyMap& rPropMap, + sal_uInt32 nBackColor, + sal_uInt32 nFlags, + ApiTransparencyMode eTranspMode ) const; + + /** Converts the Forms 2.0 border formatting to UNO properties. */ + void convertAxBorder( + PropertyMap& rPropMap, + sal_uInt32 nBorderColor, + sal_Int32 nBorderStyle, + sal_Int32 nSpecialEffect ) const; + + /** Converts the Forms 2.0 special effect to UNO properties. */ + void convertAxVisualEffect( + PropertyMap& rPropMap, + sal_Int32 nSpecialEffect ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_uInt32 nPicPos ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_Int32 nPicSizeMode, + sal_Int32 nPicAlign, + bool bPicTiling ) const; + + /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO + properties. */ + void convertAxState( + PropertyMap& rPropMap, + const ::rtl::OUString& rValue, + sal_Int32 nMultiSelect, + ApiDefaultStateMode eDefStateMode, + bool bAwtModel ) const; + + /** Converts the Forms 2.0 control orientation to UNO properties. */ + void convertAxOrientation( + PropertyMap& rPropMap, + const AxPairData& rSize, + sal_Int32 nOrientation ) const; + +private: + const GraphicHelper& mrGraphicHelper; + bool mbDefaultColorBgr; +}; // ============================================================================ -/** Base class for all models of ActiveX form controls. */ -class AxControlModelBase +/** Base class for all models of form controls. */ +class ControlModelBase { public: - virtual ~AxControlModelBase(); + explicit ControlModelBase(); + virtual ~ControlModelBase(); + + /** Sets this control model to AWT model mode. */ + inline void setAwtModelMode() { mbAwtModel = true; } + /** Sets this control model to form component mode. */ + inline void setFormComponentMode() { mbAwtModel = false; } + + /** Returns the UNO service name used to construct the AWT control model, + or the control form component. */ + ::rtl::OUString getServiceName() const; /** Derived classes set specific OOXML properties at the model structure. */ virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); /** Derived classes set binary data (picture, mouse icon) at the model structure. */ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); /** Derived classes import a form control model from the passed input stream. */ - virtual void importBinaryModel( BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0; - /** Derived classes return the UNO service name used to construct the control component. */ - virtual ::rtl::OUString getServiceName() const = 0; + /** Derived classes return the UNO control type enum value. */ + virtual ApiControlType getControlType() const = 0; /** Derived classes convert all control properties. */ - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Converts the control size to UNO properties. */ + void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - explicit AxControlModelBase(); + AxPairData maSize; /// Size of the control in 1/100 mm. + bool mbAwtModel; /// True = AWT control model, false = form component. +}; + +typedef ::boost::shared_ptr< ControlModelBase > ControlModelRef; + +// ============================================================================ + +/** Base class for all models of ComCtl form controls. */ +class ComCtlModelBase : public ControlModelBase +{ +public: + explicit ComCtlModelBase( + sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ) = 0; + virtual void importCommonExtraData( BinaryInputStream& rInStrm ); + virtual void importCommonTrailingData( BinaryInputStream& rInStrm ); + +private: + /** Returns the data part identifier according to the model version. */ + sal_uInt32 getDataPartId() const; + + bool readPartHeader( BinaryInputStream& rInStrm, + sal_uInt32 nExpPartId, + sal_uInt16 nExpMajor = SAL_MAX_UINT16, + sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + + bool importSizePart( BinaryInputStream& rInStrm ); + bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize ); + bool importComplexPart( BinaryInputStream& rInStrm ); + +protected: + StdFontInfo maFontData; /// Font formatting. + StreamDataSequence maMouseIcon; /// Binary picture stream for mouse icon. + sal_uInt32 mnFlags; /// Common flags for ComCtl controls. + const sal_uInt16 mnVersion; /// Current version of the ComCtl control model. + +private: + sal_uInt32 mnDataPartId5; /// Identifier for version 5.0 control data. + sal_uInt32 mnDataPartId6; /// Identifier for version 6.0 control data. + bool mbCommonPart; /// True = the COMCTL_COMMONDATA part exists. + bool mbComplexPart; /// True = the COMCTL_COMPLEXDATA part exists. +}; + +// ============================================================================ + +/** Model for a ComCtl scroll bar. */ +class ComCtlScrollBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlScrollBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + sal_uInt32 mnScrollBarFlags; /// Special flags for scroll bar model. + sal_Int32 mnLargeChange; /// Increment step size (thumb). + sal_Int32 mnSmallChange; /// Increment step size (buttons). + sal_Int32 mnMin; /// Minimum of the value range. + sal_Int32 mnMax; /// Maximum of the value range. + sal_Int32 mnPosition; /// Value of the spin button. +}; + +// ============================================================================ + +/** Model for a ComCtl progress bar. */ +class ComCtlProgressBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlProgressBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - sal_Int32 mnWidth; - sal_Int32 mnHeight; + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + float mfMin; /// Minimum of the value range. + float mfMax; /// Maximum of the value range. + sal_uInt16 mnVertical; /// 0 = horizontal, 1 = vertical. + sal_uInt16 mnSmooth; /// 0 = progress blocks, 1 = pixel resolution. }; // ============================================================================ +/** Base class for all models of Form 2.0 form controls. */ +class AxControlModelBase : public ControlModelBase +{ +public: + explicit AxControlModelBase(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); +}; + +// ============================================================================ + +/** Base class for Forms 2.0 controls supporting text formatting. */ class AxFontDataModel : public AxControlModelBase { public: - explicit AxFontDataModel(); + explicit AxFontDataModel( bool bSupportsAlign = true ); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: - ::rtl::OUString maFontName; /// Name of the used font. - sal_uInt32 mnFontEffects; /// Font effect flags. - sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). - sal_Int32 mnFontCharSet; /// Windows character set of the font. - sal_Int32 mnHorAlign; /// Horizontal text alignment. + /** Returns the font height in points. */ + inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); } + +protected: + AxFontData maFontData; /// The font settings. + bool mbSupportsAlign; /// True = UNO model supports Align property. }; // ============================================================================ +/** Model for a Forms 2.0 command button. */ class AxCommandButtonModel : public AxFontDataModel { public: explicit AxCommandButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -117,15 +424,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 label. */ class AxLabelModel : public AxFontDataModel { public: explicit AxLabelModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: ::rtl::OUString maCaption; /// Visible caption of the button. @@ -139,16 +448,18 @@ private: // ============================================================================ +/** Model for a Forms 2.0 image. */ class AxImageModel : public AxControlModelBase { public: explicit AxImageModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -164,15 +475,16 @@ private: // ============================================================================ -class AxMorphDataModel : public AxFontDataModel +/** Base class for a Forms 2.0 morph data control. */ +class AxMorphDataModelBase : public AxFontDataModel { public: - explicit AxMorphDataModel(); + explicit AxMorphDataModelBase(); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: StreamDataSequence maPictureData; /// Binary picture stream. @@ -198,81 +510,92 @@ protected: // ============================================================================ -class AxToggleButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 toggle button. */ +class AxToggleButtonModel : public AxMorphDataModelBase { public: explicit AxToggleButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxCheckBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 check box. */ +class AxCheckBoxModel : public AxMorphDataModelBase { public: explicit AxCheckBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxOptionButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 option button. */ +class AxOptionButtonModel : public AxMorphDataModelBase { public: explicit AxOptionButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + /** Returns the group name used to goup several option buttons gogether. */ + inline const ::rtl::OUString& getGroupName() const { return maGroupName; } + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxTextBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 text box. */ +class AxTextBoxModel : public AxMorphDataModelBase { public: explicit AxTextBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxListBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 list box. */ +class AxListBoxModel : public AxMorphDataModelBase { public: explicit AxListBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxComboBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 combo box. */ +class AxComboBoxModel : public AxMorphDataModelBase { public: explicit AxComboBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ +/** Model for a Forms 2.0 spin button. */ class AxSpinButtonModel : public AxControlModelBase { public: explicit AxSpinButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -288,15 +611,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 scroll bar. */ class AxScrollBarModel : public AxControlModelBase { public: explicit AxScrollBarModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -314,39 +639,130 @@ private: // ============================================================================ -/** Container for all ActiveX form control model implementations. */ -class AxControl +typedef ::std::vector< ::rtl::OUString > AxClassTable; + +/** Base class for ActiveX container controls. */ +class AxContainerModelBase : public AxFontDataModel { public: - explicit AxControl( const ::rtl::OUString& rName ); - ~AxControl(); + explicit AxContainerModelBase(); + + /** Allows to set single properties specified by XML token identifier. */ + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Reads the leading structure in the 'f' stream containing the model for + this control. */ + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the class table structure for embedded controls following the own + model from the 'f' stream. */ + bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ); + +protected: + StreamDataSequence maPictureData; /// Binary picture stream. + ::rtl::OUString maCaption; /// Visible caption of the form. + AxPairData maLogicalSize; /// Logical form size (scroll area). + AxPairData maScrollPos; /// Scroll position. + sal_uInt32 mnBackColor; /// Fill color. + sal_uInt32 mnTextColor; /// Text color. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnBorderColor; /// Flat border color. + sal_Int32 mnBorderStyle; /// Flat border style. + sal_Int32 mnScrollBars; /// Horizontal/vertical scroll bar. + sal_Int32 mnCycleType; /// Cycle in all forms or in this form. + sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnPicAlign; /// Anchor position of the picture. + sal_Int32 mnPicSizeMode; /// Clip, stretch, zoom. + bool mbPicTiling; /// True = picture is repeated. +}; + +typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef; + +// ============================================================================ + +/** Model for a Forms 2.0 frame (group box). */ +class AxFrameModel : public AxContainerModelBase +{ +public: + explicit AxFrameModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 user form. */ +class AxUserFormModel : public AxContainerModelBase +{ +public: + explicit AxUserFormModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** A form control embedded in a document draw page. Contains a specific model + structure according to the type of the control. */ +class EmbeddedControl +{ +public: + explicit EmbeddedControl( const ::rtl::OUString& rName ); + ~EmbeddedControl(); /** Creates and returns the internal control model according to the passed MS class identifier. */ - AxControlModelBase* createModel( const ::rtl::OUString& rClassId ); - /** Imports a form control model from the passed input stream. */ - void importBinaryModel( BinaryInputStream& rInStrm ); + ControlModelRef createModel( const ::rtl::OUString& rClassId ); - /** Returns the internal control model. */ - inline const AxControlModelBase* getModel() const { return mxModel.get(); } - /** Returns the MS class identifier used to create the internal control model. */ - inline const ::rtl::OUString& getClassId() const { return maClassId; } + /** Returns true, if the internal control model exists. */ + inline bool hasModel() const { return mxModel.get() != 0; } + /** Returns the UNO service name needed to construct the control model. */ + ::rtl::OUString getServiceName() const; - /** Creates and returns the UNO form component object for this control and - inserts it into the form wrapped by the passed helper. */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > - convertAndInsert( AxControlHelper& rHelper ) const; + /** Converts all control properties and inserts them into the passed model. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv ) const; private: - ::std::auto_ptr< AxControlModelBase > mxModel; - ::rtl::OUString maClassId; /// Class identifier of the control model. + ControlModelRef mxModel; /// Control model containing the properties. ::rtl::OUString maName; /// Name of the control. }; // ============================================================================ +/** A wrapper for a control form embedded directly in a draw page. */ +class EmbeddedForm : public ControlConverter +{ +public: + explicit EmbeddedForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Converts the passed ActiveX control and inserts it into the form. + @return The API control model, if conversion was successful. */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > + convertAndInsert( const EmbeddedControl& rControl ); + +private: + /** Tries to insert the passed control model into the form. */ + bool insertControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel ); + + /** Creates the form that will hold the form controls. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > + createForm(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxModelFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier > mxFormsSupp; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxFormIC; +}; + +// ============================================================================ + } // namespace ole } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axcontrolfragment.hxx b/oox/inc/oox/ole/axcontrolfragment.hxx index 9bccbd11a0de..3c9aed61bd3e 100644 --- a/oox/inc/oox/ole/axcontrolfragment.hxx +++ b/oox/inc/oox/ole/axcontrolfragment.hxx @@ -33,8 +33,8 @@ namespace oox { namespace ole { -class AxControl; -class AxControlModelBase; +class ControlModelBase; +class EmbeddedControl; // ============================================================================ @@ -44,32 +44,32 @@ class AxControlPropertyContext : public ::oox::core::ContextHandler2 public: explicit AxControlPropertyContext( ::oox::core::FragmentHandler2& rFragment, - AxControlModelBase& rModel ); + ControlModelBase& rModel ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControlModelBase& mrModel; + ControlModelBase& mrModel; sal_Int32 mnPropId; /// Identifier of currently processed property. }; // ============================================================================ -/** Fragment handler for an ActiveX form control fragment. */ +/** Fragment handler for an embedded ActiveX form control fragment. */ class AxControlFragment : public ::oox::core::FragmentHandler2 { public: explicit AxControlFragment( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, - AxControl& rControl ); + EmbeddedControl& rControl ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControl& mrControl; + EmbeddedControl& mrControl; }; // ============================================================================ diff --git a/oox/inc/oox/ole/axcontrolhelper.hxx b/oox/inc/oox/ole/axcontrolhelper.hxx deleted file mode 100644 index d34cf45f3654..000000000000 --- a/oox/inc/oox/ole/axcontrolhelper.hxx +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_OLE_AXCONTROLHELPER_HXX -#define OOX_OLE_AXCONTROLHELPER_HXX - -#include - -namespace com { namespace sun { namespace star { - namespace graphic { class XGraphic; } - namespace drawing { class XDrawPage; } - namespace form { class XForm; } -} } } - -namespace oox { namespace core { class FilterBase; } } - -namespace oox { -namespace ole { - -// ============================================================================ - -const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; -const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; -const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; -const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; -const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; - -// ============================================================================ - -enum AxDefaultColorMode -{ - AX_DEFAULTCOLORMODE_BGR, /// OLE default color type is interpreted as BGR color. - AX_DEFAULTCOLORMODE_PALETTE /// OLE default color type is interpreted as palette color. -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form control filters. */ -class AxControlHelper -{ -public: - explicit AxControlHelper( - const ::oox::core::FilterBase& rFilter, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - virtual ~AxControlHelper(); - - /** Returns the filter object that imports/exports the form controls. */ - inline const ::oox::core::FilterBase& getFilter() const { return mrFilter; } - /** Returns the UNO form used to insert the control models. */ - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - getControlForm() const; - /** Returns the UNO RGB color from the passed encoded OLE color. */ - sal_Int32 convertColor( sal_uInt32 nAxColor ) const; - -protected: - /** Derived classes returns the UNO form of the current context. Called exactly once. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const = 0; - -private: - const ::oox::core::FilterBase& mrFilter; - const AxDefaultColorMode meColorMode; - mutable ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > mxForm; - mutable bool mbHasFormQuerried; -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form controls embedded in a - document. */ -class AxEmbeddedControlHelper : public AxControlHelper -{ -public: - explicit AxEmbeddedControlHelper( - const ::oox::core::FilterBase& rFilter, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - -protected: - /** Creates and returns the standard UNO form in the wrapped draw page. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const; - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; -}; - -// ============================================================================ - -} // namespace ole -} // namespace oox - -#endif - diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx index 91ca73a38a67..ba46d3baf6df 100644 --- a/oox/inc/oox/ole/olehelper.hxx +++ b/oox/inc/oox/ole/olehelper.hxx @@ -31,13 +31,49 @@ #include #include "oox/helper/binarystreambase.hxx" -namespace oox { class BinaryInputStream; } +namespace oox { + class BinaryInputStream; + class GraphicHelper; +} namespace oox { namespace ole { // ============================================================================ +const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; + +// ============================================================================ + +const sal_uInt16 OLE_STDFONT_NORMAL = 400; +const sal_uInt16 OLE_STDFONT_BOLD = 700; + +const sal_uInt8 OLE_STDFONT_ITALIC = 0x02; +const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04; +const sal_uInt8 OLE_STDFONT_STRIKE = 0x08; + +/** Stores data about a StdFont font structure. */ +struct StdFontInfo +{ + ::rtl::OUString maName; /// Font name. + sal_uInt32 mnHeight; /// Font height (1/10,000 points). + sal_uInt16 mnWeight; /// Font weight (normal/bold). + sal_uInt16 mnCharSet; /// Font charset. + sal_uInt8 mnFlags; /// Font flags. + + explicit StdFontInfo(); + explicit StdFontInfo( + const ::rtl::OUString& rName, + sal_uInt32 nHeight, + sal_uInt16 nWeight = OLE_STDFONT_NORMAL, + sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI, + sal_uInt8 nFlags = 0 ); +}; + +// ============================================================================ + /** Stores data about a StdHlink hyperlink. */ struct StdHlinkInfo { @@ -53,14 +89,45 @@ struct StdHlinkInfo class OleHelper { public: - /** Imports a GUID from the passed binary stream and returns its string representation. */ + /** Returns the UNO RGB color from the passed encoded OLE color. + + @param bDefaultColorBgr + True = OLE default color type is treated as BGR color. + False = OLE default color type is treated as palette color. + */ + static sal_Int32 decodeOleColor( + const GraphicHelper& rGraphicHelper, + sal_uInt32 nOleColor, + bool bDefaultColorBgr = true ); + + /** Imports a GUID from the passed binary stream and returns its string + representation (in uppercase characters). + */ static ::rtl::OUString importGuid( BinaryInputStream& rInStrm ); - /** Imports an OLE StdPic picture from the current position of the passed binary stream. */ - static bool importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid ); + /** Imports an OLE StdFont font structure from the current position of the + passed binary stream. + */ + static bool importStdFont( + StdFontInfo& orFontInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); + + /** Imports an OLE StdPic picture from the current position of the passed + binary stream. + */ + static bool importStdPic( + StreamDataSequence& orGraphicData, + BinaryInputStream& rInStrm, + bool bWithGuid ); - /** Imports an OLE StdHlink from the current position of the passed binary stream. */ - static bool importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bWithGuid ); + /** Imports an OLE StdHlink from the current position of the passed binary + stream. + */ + static bool importStdHlink( + StdHlinkInfo& orHlinkInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); private: OleHelper(); // not implemented diff --git a/oox/inc/oox/ole/olestorage.hxx b/oox/inc/oox/ole/olestorage.hxx new file mode 100755 index 000000000000..a84fadfadc92 --- /dev/null +++ b/oox/inc/oox/ole/olestorage.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_OLESTORAGE_HXX +#define OOX_OLE_OLESTORAGE_HXX + +#include "oox/helper/storagebase.hxx" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } + namespace container { class XNameContainer; } +} } } + +namespace oox { +namespace ole { + +// ============================================================================ + +/** Implements stream access for binary OLE storages. */ +class OleStorage : public StorageBase +{ +public: + explicit OleStorage( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream, + bool bBaseStreamAccess ); + + explicit OleStorage( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, + bool bBaseStreamAccess ); + + virtual ~OleStorage(); + +private: + explicit OleStorage( + const OleStorage& rParentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxStorage, + const ::rtl::OUString& rElementName, + bool bReadOnly ); + explicit OleStorage( + const OleStorage& rParentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, + const ::rtl::OUString& rElementName ); + + /** Initializes the API storage object for input. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ); + /** Initializes the API storage object for input/output. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ); + + /** Returns true, if the object represents a valid storage. */ + virtual bool implIsStorage() const; + + /** Returns the com.sun.star.embed.XStorage interface of the current storage. + + @attention + This function is not implemented for binary OLE storages. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + implGetXStorage() const; + + /** Returns the names of all elements of this storage. */ + virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; + + /** Opens and returns the specified sub storage from the storage. */ + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); + + /** Opens and returns the specified input stream from the storage. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + implOpenInputStream( const ::rtl::OUString& rElementName ); + + /** Opens and returns the specified output stream from the storage. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > + implOpenOutputStream( const ::rtl::OUString& rElementName ); + + /** Commits the current storage. */ + virtual void implCommit() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxFactory; /// Factory for storage/stream creation. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxStorage; /// Access to elements of this sub storage. + const OleStorage* mpParentStorage; /// Parent OLE storage that contains this storage. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbacontrol.hxx b/oox/inc/oox/ole/vbacontrol.hxx new file mode 100755 index 000000000000..ec1c25be6952 --- /dev/null +++ b/oox/inc/oox/ole/vbacontrol.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBACONTROL_HXX +#define OOX_OLE_VBACONTROL_HXX + +#include "oox/ole/axcontrol.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } +} } } + +namespace oox { class StorageBase; } + +namespace oox { +namespace ole { + +class VbaFormControl; + +// ============================================================================ + +/** Common properties for all controls that are part of a VBA user form or of + another container control in a VBA user form. */ +class VbaSiteModel +{ +public: + explicit VbaSiteModel(); + virtual ~VbaSiteModel(); + + /** Allows to set single properties specified by XML token identifier. */ + void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Imports the site model data from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + + /** Returns the programmatical name of the control. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the position of the control in its parent. */ + inline const AxPairData& getPosition() const { return maPos; } + /** Returns true, if this control is a container control. */ + bool isContainer() const; + /** Returns the length of the stream data for stream based controls. */ + sal_uInt32 getStreamLength() const; + /** Returns the name of the substorage for the container control data. */ + ::rtl::OUString getSubStorageName() const; + /** Returns the tab index of the control. */ + inline sal_Int16 getTabIndex() const { return mnTabIndex; } + + /** Tries to create the control model according to the site model. */ + ControlModelRef createControlModel( const AxClassTable& rClassTable ) const; + /** Converts all form site properties. */ + void convertProperties( + PropertyMap& rPropMap, + const ControlConverter& rConv, + ApiControlType eCtrlType, + sal_Int32 nCtrlIndex ) const; + +protected: + ::rtl::OUString maName; /// Name of the control. + ::rtl::OUString maTag; /// User defined tag. + ::rtl::OUString maToolTip; /// Tool tip for the control. + ::rtl::OUString maLinkedCell; /// Linked cell for the control value in a spreadsheet. + ::rtl::OUString maSourceRange; /// Source data for the control in a spreadsheet. + AxPairData maPos; /// Position in parent container. + sal_Int32 mnId; /// Control identifier. + sal_Int32 mnHelpContextId; /// Help context identifier. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnStreamLen; /// Size of control stream data. + sal_Int16 mnTabIndex; /// Tab order index. + sal_uInt16 mnClassIdOrCache; /// Class name identifier or GUID cache index. + sal_uInt16 mnGroupId; /// Group identifier for grouped controls. +}; + +typedef ::boost::shared_ptr< VbaSiteModel > VbaSiteModelRef; + +// ============================================================================ + +/** A control that is embedded in a VBA user form or in another container + control in a VBA user form. + + The control may be a 'simple' control with its data stored in the 'o' + stream, or it may be a container control with its data stored in an own + substorage. + */ +class VbaFormControl +{ +public: + explicit VbaFormControl(); + virtual ~VbaFormControl(); + + /** Imports the model from the passed stream or storage, depending on the + control's type. Imports all embedded controls, if this is a container. */ + void importModelOrStorage( + BinaryInputStream& rInStrm, + StorageBase& rStrg, + const AxClassTable& rClassTable ); + + /** Returns the programmatical name of the control. */ + ::rtl::OUString getControlName() const; + + /** Creates the UNO control model, inserts it into the passed container, + and converts all control properties. */ + void createAndConvert( + sal_Int32 nCtrlIndex, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC, + const ControlConverter& rConv ) const; + +protected: + /** Creates and imports the control model containing properties of the control. */ + void importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable ); + /** Creates and imports the control model, and imports all embedded + controls from the passed substorage. */ + void importStorage( StorageBase& rStrg, const AxClassTable& rClassTable ); + + /** Converts all control properties, and inserts and converts embedded controls. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv, + sal_Int32 nCtrlIndex ) const; + +private: + typedef RefVector< VbaFormControl > VbaFormControlVector; + typedef VbaFormControlVector::value_type VbaFormControlRef; + + /** Creates the control model according to the current site model. */ + void createControlModel( const AxClassTable& rClassTable ); + /** Imports the site model data containing common properties of the control. */ + bool importSiteModel( BinaryInputStream& rInStrm ); + + /** Imports the site models of all embedded controls from the 'f' stream. */ + bool importEmbeddedSiteModels( BinaryInputStream& rInStrm ); + /* Final processing of all embedded controls after import. */ + void finalizeEmbeddedControls(); + + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + /** Moves all embedded controls from their relative position in this + control to an absolute position in the parent of this control. */ + void moveEmbeddedToAbsoluteParent(); + + /** Functor for comparing controls by their tab index. */ + static bool compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight ); + +protected: + VbaSiteModelRef mxSiteModel; /// Common control properties. + ControlModelRef mxCtrlModel; /// Specific control properties. + +private: + VbaFormControlVector maControls; /// All embedded form controls. + AxClassTable maClassTable; /// Class identifiers for exotic embedded controls. +}; + +// ============================================================================ + +class VbaUserForm : public VbaFormControl, public ControlConverter +{ +public: + explicit VbaUserForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Imports the form and its embedded controls, and inserts the form with + all its controls into the passed dialog library. */ + void importForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, + const ::rtl::OUString& rModuleName, + rtl_TextEncoding eTextEnc ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx new file mode 100755 index 000000000000..76dc1c736025 --- /dev/null +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAHELPER_HXX +#define OOX_OLE_VBAHELPER_HXX + +#include "oox/helper/binarystreambase.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } +} } } + +namespace oox { class BinaryInputStream; } + +namespace oox { +namespace ole { + +// Directory stream record identifiers ======================================== + +const sal_uInt16 VBA_ID_MODULECOOKIE = 0x002C; +const sal_uInt16 VBA_ID_MODULEDOCSTRING = 0x001C; +const sal_uInt16 VBA_ID_MODULEDOCSTRINGUNICODE = 0x0048; +const sal_uInt16 VBA_ID_MODULEEND = 0x002B; +const sal_uInt16 VBA_ID_MODULEHELPCONTEXT = 0x001E; +const sal_uInt16 VBA_ID_MODULENAME = 0x0019; +const sal_uInt16 VBA_ID_MODULENAMEUNICODE = 0x0047; +const sal_uInt16 VBA_ID_MODULEOFFSET = 0x0031; +const sal_uInt16 VBA_ID_MODULEPRIVATE = 0x0028; +const sal_uInt16 VBA_ID_MODULEREADONLY = 0x0025; +const sal_uInt16 VBA_ID_MODULESTREAMNAME = 0x001A; +const sal_uInt16 VBA_ID_MODULESTREAMNAMEUNICODE = 0x0032; +const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT = 0x0022; +const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL = 0x0021; +const sal_uInt16 VBA_ID_PROJECTCODEPAGE = 0x0003; +const sal_uInt16 VBA_ID_PROJECTEND = 0x0010; +const sal_uInt16 VBA_ID_PROJECTMODULES = 0x000F; +const sal_uInt16 VBA_ID_PROJECTVERSION = 0x0009; + +// ============================================================================ + +/** Static helper functions for the VBA filters. */ +class VbaHelper +{ +public: + /** Returns the full Basic script URL from a VBA module and macro name. + The script is assumed to be in a document library. */ + static ::rtl::OUString getBasicScriptUrl( + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Reads the next record from the VBA directory stream 'dir'. + + @param rnRecId (out parameter) The record identifier of the new record. + @param rRecData (out parameter) The contents of the new record. + @param rInStrm The 'dir' stream. + + @return True = next record successfully read. False on any error, or + if the stream is EOF. + */ + static bool readDirRecord( + sal_uInt16& rnRecId, + StreamDataSequence& rRecData, + BinaryInputStream& rInStrm ); + + /** Extracts a key/value pair from a string separated by an equality sign. + + @param rKey (out parameter) The key before the separator. + @param rValue (out parameter) The value following the separator. + @param rCodeLine The source key/value pair. + + @return True = Equality sign separator found, and the returned key and + value are not empty. False otherwise. + */ + static bool extractKeyValue( + ::rtl::OUString& rKey, + ::rtl::OUString& rValue, + const ::rtl::OUString& rKeyValue ); + + /** Removes whitespace characters from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @return True = at least one whitespace character found and removed + from rCodeLine. False = rCodeLine is empty or does not start with + a whitespace character. + */ + static bool eatWhitespace( ::rtl::OUString& rCodeLine ); + + /** Removes the passed keyword from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @param rKeyword The keyword to be removed from the beginning of the + rCodeLine string. + + @return True = rCodeLine starts with the passed keyword (case + insensitive), and is followed by whitespace characters, or it ends + right after the keyword. The keyword and the following whitespace + characters have been removed from rCodeLine. False = rCodeLine is + empty or does not start with the specified keyword, or the keyword + is not followed by whitespace characters. + */ + static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword ); + + /** Returns the VBA source code of the specified module, or an empty + string, if the module does not exist. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA code module. + */ + static ::rtl::OUString getSourceCode( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName ); + + /** Checks, if a macro with the specified name exists in the passed VBA + source code. + + @param rSourceCode The VBA source code. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::rtl::OUString& rSourceCode, + const ::rtl::OUString& rMacroName ); + + /** Checks, if a macro with the specified name exists in the specified + module. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA module to check for the macro. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub ( ) + + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function ( ) As + + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + static bool insertMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + /** Tries to attach a VBA macro to an event of the passed events supplier. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rLibraryName The name of the Basic library containing the macro. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + */ + static bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + +private: + VbaHelper(); + ~VbaHelper(); +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbamodule.hxx b/oox/inc/oox/ole/vbamodule.hxx new file mode 100755 index 000000000000..3b529ceee129 --- /dev/null +++ b/oox/inc/oox/ole/vbamodule.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAMODULE_HXX +#define OOX_OLE_VBAMODULE_HXX + +#include +#include + +namespace com { namespace sun { namespace star { + namespace container { class XNameAccess; } + namespace container { class XNameContainer; } + namespace frame { class XModel; } +} } } + +namespace oox { + class BinaryInputStream; + class StorageBase; +} + +namespace oox { +namespace ole { + +// ============================================================================ + +class VbaModule +{ +public: + explicit VbaModule( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rName, + rtl_TextEncoding eTextEnc, + bool bExecutable ); + + /** Returns the module type (com.sun.star.script.ModuleType constant). */ + inline sal_Int32 getType() const { return mnType; } + /** Sets the passed module type. */ + inline void setType( sal_Int32 nType ) { mnType = nType; } + + /** Returns the name of the module. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the stream name of the module. */ + inline const ::rtl::OUString& getStreamName() const { return maStreamName; } + + /** Imports all records for this module until the MODULEEND record. */ + void importDirRecords( BinaryInputStream& rDirStrm ); + /** Imports the Basic source code into the passed Basic library. */ + void importSourceCode( + StorageBase& rVbaStrg, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::rtl::OUString maName; + ::rtl::OUString maStreamName; + ::rtl::OUString maDocString; + rtl_TextEncoding meTextEnc; + sal_Int32 mnType; + sal_uInt32 mnOffset; + bool mbReadOnly; + bool mbPrivate; + bool mbExecutable; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx new file mode 100755 index 000000000000..0422ccbd0cf8 --- /dev/null +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -0,0 +1,289 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAPROJECT_HXX +#define OOX_OLE_VBAPROJECT_HXX + +#include "oox/helper/storagebase.hxx" +#include +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } + namespace frame { class XModel; } + namespace script { class XLibraryContainer; } + namespace lang { class XMultiServiceFactory; } +} } } + +namespace oox { class GraphicHelper; } + +namespace oox { +namespace ole { + +// ============================================================================ + +class OOX_DLLPUBLIC VbaFilterConfig +{ +public: + explicit VbaFilterConfig( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::rtl::OUString& rConfigCompName ); + ~VbaFilterConfig(); + + /** Returns true, if the VBA source code and forms should be imported. */ + bool isImportVba() const; + /** Returns true, if the VBA source code should be imported executable. */ + bool isImportVbaExecutable() const; + /** Returns true, if the VBA source code and forms should be exported. */ + bool isExportVba() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + mxConfigAccess; +}; + +// ============================================================================ + +class OOX_DLLPUBLIC VbaProject : public VbaFilterConfig +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rConfigCompName ); + virtual ~VbaProject(); + + /** Imports the entire VBA project from the passed storage. + + @param rVbaPrjStrg The root storage of the entire VBA project. + */ + void importVbaProject( + StorageBase& rVbaPrjStrg, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Returns true, if the document contains at least one code module. */ + bool hasModules() const; + /** Returns true, if the document contains the specified code module. */ + bool hasModule( const ::rtl::OUString& rModuleName ) const; + + /** Returns true, if the document contains at least one dialog. */ + bool hasDialogs() const; + /** Returns true, if the document contains the specified dialog. */ + bool hasDialog( const ::rtl::OUString& rDialogName ) const; + + // Insert VBA code modules and VBA macros into modules -------------------- + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub ( ) + + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function ( ) As + + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + bool insertMacro( + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + // Attach VBA macros to generic or document events ------------------------ + + /** Tries to attach the specified VBA macro to an event directly. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to a document event directly. + + @descr The function checks if the specified macro exists and attaches + it to the document event. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified document event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to an event via a generated + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + + /** Tries to attach the specified VBA macro to a document event via a + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + document event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + +private: + VbaProject( const VbaProject& ); + VbaProject& operator=( const VbaProject& ); + + /** Returns the Basic or dialog library container. */ + ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > + getLibraryContainer( sal_Int32 nPropId ); + /** Opens a Basic or dialog library (creates missing if specified). */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + openLibrary( sal_Int32 nPropId, bool bCreateMissing ); + /** Creates and returns the Basic library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createBasicLibrary(); + /** Creates and returns the dialog library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createDialogLibrary(); + /** Imports the VBA code modules and forms. */ + void importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ); + /** Copies the entire VBA project storage to the passed document model. */ + void copyStorage( StorageBase& rVbaPrjStrg ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxGlobalFactory; /// Global service factory. + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxBasicLib; /// The Basic library of the document used for import. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxDialogLib; /// The dialog library of the document used for import. + const ::rtl::OUString maLibName; /// Name for Basic and dialog library used for import. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ppt/pptimport.hxx b/oox/inc/oox/ppt/pptimport.hxx index 7d04e1c492fa..c4ee29447c64 100644 --- a/oox/inc/oox/ppt/pptimport.hxx +++ b/oox/inc/oox/ppt/pptimport.hxx @@ -53,8 +53,6 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const oox::drawingml::table::TableStyleListPtr getTableStyles(); @@ -66,7 +64,10 @@ public: std::vector< SlidePersistPtr >& getMasterPages(){ return maMasterPages; }; std::vector< SlidePersistPtr >& getNotesPages(){ return maNotesPages; }; + sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; private: diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx index 1af14903793b..2312514d7117 100644 --- a/oox/inc/oox/vml/vmldrawing.hxx +++ b/oox/inc/oox/vml/vmldrawing.hxx @@ -39,7 +39,7 @@ namespace com { namespace sun { namespace star { } } } namespace oox { namespace core { class XmlFilterBase; } } -namespace oox { namespace ole { class AxControlHelper; } } +namespace oox { namespace ole { class EmbeddedForm; } } namespace oox { namespace vml { @@ -110,8 +110,8 @@ public: inline ShapeContainer& getShapes() { return *mxShapes; } /** Returns read access to the container of shapes and templates. */ inline const ShapeContainer& getShapes() const { return *mxShapes; } - /** Returns the helper object used to process ActiveX form controls. */ - ::oox::ole::AxControlHelper& getControlHelper() const; + /** Returns the form object used to process ActiveX form controls. */ + ::oox::ole::EmbeddedForm& getControlForm() const; /** Registers the passed embedded OLE object. The related shape will then load the OLE object data from the specified fragment. */ @@ -146,12 +146,8 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, const ShapeClientData& rClientData ) const; -protected: - /** Derived classes may create a specialized form control helper object. */ - virtual ::oox::ole::AxControlHelper* createControlHelper() const; - private: - typedef ::std::auto_ptr< ::oox::ole::AxControlHelper > AxControlHelperPtr; + typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm > EmbeddedFormPtr; typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr; typedef ::std::map< ::rtl::OUString, OleObjectInfo > OleObjectInfoMap; typedef ::std::map< ::rtl::OUString, ControlInfo > ControlInfoMap; @@ -159,7 +155,7 @@ private: ::oox::core::XmlFilterBase& mrFilter; /// Filter object that imports/exports the VML drawing. ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; /// UNO draw page used to insert the shapes. - mutable AxControlHelperPtr mxCtrlHelper;/// Form control helper. + mutable EmbeddedFormPtr mxCtrlForm; /// The control form used to process ActiveX controls. ShapeContainerPtr mxShapes; /// All shapes and shape templates. OleObjectInfoMap maOleObjects; /// Info about all embedded OLE objects, mapped by shape id. ControlInfoMap maControls; /// Info about all embedded form controls, mapped by control name. diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx index b997c7451fe4..1a9c1811cf6b 100644 --- a/oox/inc/oox/vml/vmlformatting.hxx +++ b/oox/inc/oox/vml/vmlformatting.hxx @@ -30,8 +30,11 @@ #include "oox/helper/helper.hxx" -namespace oox { class PropertyMap; } -namespace oox { namespace core { class FilterBase; } } +namespace oox { + class GraphicHelper; + class ModelObjectHelper; + class PropertyMap; +} namespace oox { namespace vml { @@ -71,7 +74,7 @@ public: /** Converts the passed VML measure string to EMU (English Metric Units). - @param rFilter The core filter object needed to perform pixel + @param rGraphicHelper The graphic helper needed to perform pixel conversion according to the current output device. @param rValue The VML measure value. This is a floating-point value @@ -88,7 +91,7 @@ public: pixel. Set to false if omitted measure unit means EMU. */ static sal_Int32 decodeMeasureToEmu( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -96,14 +99,14 @@ public: /** Converts the passed VML measure string to 1/100 mm. - @param rFilter See above. + @param rGraphicHelper See above. @param rValue See above. @param nRefValue See above. @param bPixelX See above. @param bDefaultAsPixel See above. */ static sal_Int32 decodeMeasureToHmm( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -147,7 +150,8 @@ struct StrokeModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ @@ -172,7 +176,8 @@ struct FillModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index f425b983ada2..b4f36c113c3d 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -493,6 +493,8 @@ const sal_uInt16 BIFF_ID_TOPMARGIN = 0x0028; const sal_uInt16 BIFF_ID_TXO = 0x01B6; const sal_uInt16 BIFF_ID_UNCALCED = 0x005E; const sal_uInt16 BIFF_ID_USESELFS = 0x0160; +const sal_uInt16 BIFF_ID_VBAPROJECT = 0x00D3; +const sal_uInt16 BIFF_ID_VBAPROJECTEMPTY = 0x01BD; const sal_uInt16 BIFF_ID_VCENTER = 0x0084; const sal_uInt16 BIFF_ID_VERPAGEBREAKS = 0x001A; const sal_uInt16 BIFF_ID_WINDOW1 = 0x003D; diff --git a/oox/inc/oox/xls/excelfilter.hxx b/oox/inc/oox/xls/excelfilter.hxx index 5da8b50d7f92..b5d7a97f33b5 100644 --- a/oox/inc/oox/xls/excelfilter.hxx +++ b/oox/inc/oox/xls/excelfilter.hxx @@ -34,22 +34,23 @@ namespace oox { namespace xls { -// ============================================================================ +class WorkbookData; -class WorkbookHelper; +// ============================================================================ class ExcelFilterBase { +public: + void registerWorkbookData( WorkbookData& rData ); + WorkbookData& getWorkbookData() const; + void unregisterWorkbookData(); + protected: explicit ExcelFilterBase(); virtual ~ExcelFilterBase(); - void setWorkbookHelper( WorkbookHelper& rHelper ); - WorkbookHelper& getWorkbookHelper() const; - void clearWorkbookHelper(); - private: - WorkbookHelper* mpHelper; /// Nonowning pointer to helper base. + WorkbookData* mpData; }; // ============================================================================ @@ -64,15 +65,13 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles(); virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; @@ -88,9 +87,8 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; diff --git a/oox/inc/oox/xls/excelvbaproject.hxx b/oox/inc/oox/xls/excelvbaproject.hxx new file mode 100755 index 000000000000..6a517d13cd88 --- /dev/null +++ b/oox/inc/oox/xls/excelvbaproject.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_XLS_EXCELVBAPROJECT_HXX +#define OOX_XLS_EXCELVBAPROJECT_HXX + +#include "oox/ole/vbaproject.hxx" +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace sheet { class XSpreadsheetDocument; } +} } } + +namespace oox { +namespace xls { + +// ============================================================================ + +/** Special implementation of the VBA project for the Excel filters. */ +class OOX_DLLPUBLIC VbaProject : public ::oox::ole::VbaProject +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument ); + + /** Attaches all document and sheet events to existing VBA macros. */ + void attachToEvents(); + +private: + /** Attaches VBA macros to all supported document events. */ + void attachToDocumentEvents( const ::rtl::OUString& rCodeName ); + + /** Attaches VBA macros to all supported sheet events. */ + void attachToSheetEvents( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rCodeName ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > + mxDocument; +}; + +// ============================================================================ + +} // namespace xls +} // namespace oox + +#endif diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx index 8af5127143de..0cef90019809 100644 --- a/oox/inc/oox/xls/stylesbuffer.hxx +++ b/oox/inc/oox/xls/stylesbuffer.hxx @@ -35,6 +35,7 @@ #include #include #include "oox/helper/containerhelper.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/drawingml/color.hxx" #include "oox/xls/numberformatsbuffer.hxx" @@ -78,6 +79,22 @@ const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; /// Relative character h // ============================================================================ +/** Special implementation of the GraphicHelper for Excel palette and scheme + colors. + */ +class ExcelGraphicHelper : public GraphicHelper, public WorkbookHelper +{ +public: + explicit ExcelGraphicHelper( const WorkbookHelper& rHelper ); + + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; +}; + +// ============================================================================ + class Color : public ::oox::drawingml::Color { public: @@ -205,7 +222,7 @@ struct ApiScriptFontName { ::rtl::OUString maName; /// Font name. sal_Int16 mnFamily; /// Font family. - sal_Int16 mnCharSet; /// Font character set. + sal_Int16 mnTextEnc; /// Font text encoding. explicit ApiScriptFontName(); }; diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index f9f0bb25c78f..0a4853748bf5 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -92,6 +92,9 @@ private: bool importSheetFragment( ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int16 nCalcSheet ); + +private: + bool mbImportVbaProject; /// True = import VBA project at end of filter. }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 90c0f33c3c50..8a6f436bbaaf 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -29,9 +29,8 @@ #define OOX_XLS_WORKBOOKHELPER_HXX #include -#include #include -#include +//#include "oox/helper/storagebase.hxx" #include "oox/xls/biffhelper.hxx" namespace com { namespace sun { namespace star { @@ -72,87 +71,8 @@ namespace oox { namespace drawingml { namespace oox { namespace xls { -// DEBUG ====================================================================== - -// Set this define to 1 to show the load/save time of a document in an assertion (nonpro only). -#define OOX_SHOW_LOADSAVE_TIME 0 - -// ---------------------------------------------------------------------------- - -#define OOX_LOADSAVE_TIMER( eTimerType ) (void)0 - -#if OSL_DEBUG_LEVEL > 0 -namespace dbg { - -// ---------------------------------------------------------------------------- - -#if OOX_SHOW_LOADSAVE_TIME > 0 - -enum TimerType -{ - TIMER_IMPORTFORMULA, - TIMER_IMPORTSHEETFRAGMENT, - TIMER_ONCREATESHEETCONTEXT, - TIMER_IMPORTROW, - TIMER_CONVERTROWFORMAT, - TIMER_CONVERTCOLUMNFORMAT, - TIMER_IMPORTCELL, - TIMER_ONENDSHEETELEMENT, - TIMER_SETCELL, - TIMER_SETCELLFORMAT, - TIMER_MERGECELLFORMAT, - TIMER_WRITECELLPROPERTIES, - TIMER_FINALIZESHEETDATA, - TIMER_FINALIZEDRAWING, - TIMER_FINALIZEBOOKDATA, - - // TIMER_TOTAL must be the last entry! - TIMER_TOTAL -}; - -// ---------------------------------------------------------------------------- - -struct TimeCount; - -class Timer -{ -public: - explicit Timer( TimeCount& rTimeCount ); - ~Timer(); -private: - TimeCount& mrTimeCount; - TimeValue maStartTime; -}; - -// ---------------------------------------------------------------------------- - -#undef OOX_LOADSAVE_TIMER -#define OOX_LOADSAVE_TIMER( TimerType ) ::oox::xls::dbg::Timer aDbgTimer##TimerType( getTimeCount( ::oox::xls::dbg::TIMER_##TimerType ) ) - -#endif - -// ---------------------------------------------------------------------------- - -struct WorkbookData; - -class WorkbookHelper -{ -protected: - explicit WorkbookHelper( WorkbookData& rBookData ); - explicit WorkbookHelper( const WorkbookHelper& rCopy ); - virtual ~WorkbookHelper(); -#if OOX_SHOW_LOADSAVE_TIME > 0 -public: - TimeCount& getTimeCount( TimerType eType ) const; -#endif -private: - WorkbookData& mrDbgBookData; -}; - -// ---------------------------------------------------------------------------- - -} // namespace dbg -#endif +class ExcelFilter; +class ExcelBiffFilter; // ============================================================================ @@ -193,6 +113,7 @@ class UnitConverter; class AddressConverter; class ExcelChartConverter; class PageSettingsConverter; +class VbaProject; class BiffCodecHelper; /** Helper class to provice access to global workbook data. @@ -201,14 +122,15 @@ class BiffCodecHelper; object of type WorkbookData containing global workbook settings, buffers, converters, etc. Nearly all classes in this filter implementation are derived directly or indirectly from this class. + + This class contains just a simple reference to the WorkbookData object to + prevent circular references, as the WorkbookData object contains a lot of + objects derived from this class. */ class WorkbookHelper -#if OSL_DEBUG_LEVEL > 0 - : public dbg::WorkbookHelper -#endif { public: - /*implicit*/ WorkbookHelper( WorkbookData& rBookData ); + inline /*implicit*/ WorkbookHelper( WorkbookData& rBookData ) : mrBookData( rBookData ) {} virtual ~WorkbookHelper(); // filter ----------------------------------------------------------------- @@ -333,8 +255,10 @@ public: ExcelChartConverter& getChartConverter() const; /** Returns the page and print settings converter. */ PageSettingsConverter& getPageSettingsConverter() const; + /** Returns the VBA project used to import/export VBA and attach events. */ + VbaProject& getVbaProject() const; - // OOX specific ----------------------------------------------------------- + // OOX specific (MUST NOT be called in BIFF filter) ----------------------- /** Returns the base OOX filter object. Must not be called, if current filter is not the OOX filter. */ @@ -344,7 +268,7 @@ public: the full path to the fragment stream. */ bool importOoxFragment( const ::rtl::Reference< ::oox::core::FragmentHandler >& rxHandler ); - // BIFF specific ---------------------------------------------------------- + // BIFF specific (MUST NOT be called in OOX filter) ----------------------- /** Returns the base BIFF filter object. */ ::oox::core::BinaryFilterBase& getBiffFilter() const; @@ -392,8 +316,8 @@ struct WorkbookDataOwner class WorkbookHelperRoot : private prv::WorkbookDataOwner, public WorkbookHelper { public: - explicit WorkbookHelperRoot( ::oox::core::XmlFilterBase& rFilter ); - explicit WorkbookHelperRoot( ::oox::core::BinaryFilterBase& rFilter, BiffType eBiff ); + explicit WorkbookHelperRoot( ExcelFilter& rFilter ); + explicit WorkbookHelperRoot( ExcelBiffFilter& rFilter, BiffType eBiff ); /** Returns true, if this helper refers to a valid document. */ bool isValid() const; @@ -409,4 +333,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/xls/worksheetsettings.hxx b/oox/inc/oox/xls/worksheetsettings.hxx index c96f12605911..17e22dc5342c 100644 --- a/oox/inc/oox/xls/worksheetsettings.hxx +++ b/oox/inc/oox/xls/worksheetsettings.hxx @@ -120,6 +120,8 @@ public: void importPassword( BiffInputStream& rStrm ); /** Imports protection settings from the SHEETPROTECTION record. */ void importSheetProtection( BiffInputStream& rStrm ); + /** Imports the VBA code module name from the CODENAME record. */ + void importCodeName( BiffInputStream& rStrm ); /** Imports phonetic settings from the PHONETICPR record. */ void importPhoneticPr( BiffInputStream& rStrm ); diff --git a/oox/prj/build.lst b/oox/prj/build.lst index a1dfa584543c..345c72e00558 100644 --- a/oox/prj/build.lst +++ b/oox/prj/build.lst @@ -1,4 +1,4 @@ -oox oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools vcl BOOST:boost OPENSSL:openssl NULL +oox oox : vos cppu cppuhelper comphelper sal offapi sax basegfx xmlscript tools vcl BOOST:boost OPENSSL:openssl NULL oox oox usr1 - all oox_mkout NULL oox oox\prj get - all oox_prj NULL oox oox\source\token nmake - all oox_token NULL diff --git a/oox/prj/d.lst b/oox/prj/d.lst index 2c9d8d5bae74..482a270926a3 100644 --- a/oox/prj/d.lst +++ b/oox/prj/d.lst @@ -4,7 +4,9 @@ mkdir: %_DEST%\inc%_EXT%\oox\core mkdir: %_DEST%\inc%_EXT%\oox\drawingml mkdir: %_DEST%\inc%_EXT%\oox\drawingml\chart mkdir: %_DEST%\inc%_EXT%\oox\drawingml\table +mkdir: %_DEST%\inc%_EXT%\oox\ole mkdir: %_DEST%\inc%_EXT%\oox\vml +mkdir: %_DEST%\inc%_EXT%\oox\xls ..\%__SRC%\misc\*.map %_DEST%\bin%_EXT%\*.map ..\%__SRC%\lib\ixo.lib %_DEST%\lib%_EXT%\ixo.lib @@ -22,6 +24,7 @@ mkdir: %_DEST%\inc%_EXT%\oox\vml ..\inc\oox\dllapi.h %_DEST%\inc%_EXT%\oox\dllapi.h ..\inc\oox\helper\binarystreambase.hxx %_DEST%\inc%_EXT%\oox\helper\binarystreambase.hxx ..\inc\oox\helper\helper.hxx %_DEST%\inc%_EXT%\oox\helper\helper.hxx +..\inc\oox\helper\containerhelper.hxx %_DEST%\inc%_EXT%\oox\helper\containerhelper.hxx ..\inc\oox\helper\storagebase.hxx %_DEST%\inc%_EXT%\oox\helper\storagebase.hxx ..\inc\oox\helper\zipstorage.hxx %_DEST%\inc%_EXT%\oox\helper\zipstorage.hxx ..\inc\oox\core\filterbase.hxx %_DEST%\inc%_EXT%\oox\core\filterbase.hxx @@ -30,8 +33,10 @@ mkdir: %_DEST%\inc%_EXT%\oox\vml ..\inc\oox\core\xmlfilterbase.hxx %_DEST%\inc%_EXT%\oox\core\xmlfilterbase.hxx ..\inc\oox\drawingml\chart\chartconverter.hxx %_DEST%\inc%_EXT%\oox\drawingml\chart\chartconverter.hxx ..\inc\oox\drawingml\table\tablestylelist.hxx %_DEST%\inc%_EXT%\oox\drawingml\table\tablestylelist.hxx +..\inc\oox\ole\vbaproject.hxx %_DEST%\inc%_EXT%\oox\ole\vbaproject.hxx ..\inc\oox\vml\vmldrawing.hxx %_DEST%\inc%_EXT%\oox\vml\vmldrawing.hxx ..\inc\oox\vml\vmlshape.hxx %_DEST%\inc%_EXT%\oox\vml\vmlshape.hxx +..\inc\oox\xls\excelvbaproject.hxx %_DEST%\inc%_EXT%\oox\xls\excelvbaproject.hxx dos: sh -c "if test %OS% = MACOSX; then create-bundle %_DEST%\lib%_EXT%\*.dylib; fi" diff --git a/oox/source/core/binaryfilterbase.cxx b/oox/source/core/binaryfilterbase.cxx index 1dd2e0e9086c..f308f02ac9dc 100644 --- a/oox/source/core/binaryfilterbase.cxx +++ b/oox/source/core/binaryfilterbase.cxx @@ -26,7 +26,7 @@ ************************************************************************/ #include "oox/core/binaryfilterbase.hxx" -#include "oox/helper/olestorage.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Reference; @@ -52,12 +52,12 @@ BinaryFilterBase::~BinaryFilterBase() StorageRef BinaryFilterBase::implCreateStorage( const Reference< XInputStream >& rxInStream ) const { - return StorageRef( new OleStorage( getGlobalFactory(), rxInStream, true ) ); + return StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), rxInStream, true ) ); } StorageRef BinaryFilterBase::implCreateStorage( const Reference< XStream >& rxOutStream ) const { - return StorageRef( new OleStorage( getGlobalFactory(), rxOutStream, true ) ); + return StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), rxOutStream, true ) ); } // ============================================================================ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 07c31736e9e7..27a1b26fbcfd 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -27,8 +27,6 @@ #include "oox/core/filterbase.hxx" #include -#include -#include #include #include #include @@ -57,10 +55,6 @@ using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::XComponent; using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::awt::DeviceInfo; -using ::com::sun::star::awt::XDevice; -using ::com::sun::star::frame::XFrame; -using ::com::sun::star::frame::XFramesSupplier; using ::com::sun::star::frame::XModel; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; @@ -139,12 +133,10 @@ struct FilterBaseImpl typedef ::boost::shared_ptr< ModelObjectHelper > ModelObjHelperRef; typedef ::boost::shared_ptr< OleObjectHelper > OleObjHelperRef; typedef ::std::map< OUString, Reference< XGraphic > > EmbeddedGraphicMap; - typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; FilterDirection meDirection; SequenceAsHashMap maArguments; MediaDescriptor maMediaDesc; - DeviceInfo maDeviceInfo; OUString maFileUrl; StorageRef mxStorage; @@ -152,7 +144,6 @@ struct FilterBaseImpl ModelObjHelperRef mxModelObjHelper; /// Tables to create new named drawing objects. OleObjHelperRef mxOleObjHelper; /// OLE object handling. EmbeddedGraphicMap maEmbeddedGraphics; /// Maps all imported embedded graphics by their path. - SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values. Reference< XMultiServiceFactory > mxGlobalFactory; Reference< XModel > mxModel; @@ -178,53 +169,6 @@ FilterBaseImpl::FilterBaseImpl( const Reference< XMultiServiceFactory >& rxGloba mxGlobalFactory( rxGlobalFactory ) { OSL_ENSURE( mxGlobalFactory.is(), "FilterBaseImpl::FilterBaseImpl - missing service factory" ); - if( mxGlobalFactory.is() ) - { - // get the metric of the output device - try - { - Reference< XFramesSupplier > xFramesSupp( mxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); - Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); - Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); - maDeviceInfo = xDevice->getInfo(); - } - catch( Exception& ) - { - OSL_ENSURE( false, "FilterBaseImpl::FilterBaseImpl - cannot get output device info" ); - } - } - - //! TODO: get colors from system - maSystemPalette[ XML_3dDkShadow ] = 0x716F64; - maSystemPalette[ XML_3dLight ] = 0xF1EFE2; - maSystemPalette[ XML_activeBorder ] = 0xD4D0C8; - maSystemPalette[ XML_activeCaption ] = 0x0054E3; - maSystemPalette[ XML_appWorkspace ] = 0x808080; - maSystemPalette[ XML_background ] = 0x004E98; - maSystemPalette[ XML_btnFace ] = 0xECE9D8; - maSystemPalette[ XML_btnHighlight ] = 0xFFFFFF; - maSystemPalette[ XML_btnShadow ] = 0xACA899; - maSystemPalette[ XML_btnText ] = 0x000000; - maSystemPalette[ XML_captionText ] = 0xFFFFFF; - maSystemPalette[ XML_gradientActiveCaption ] = 0x3D95FF; - maSystemPalette[ XML_gradientInactiveCaption ] = 0xD8E4F8; - maSystemPalette[ XML_grayText ] = 0xACA899; - maSystemPalette[ XML_highlight ] = 0x316AC5; - maSystemPalette[ XML_highlightText ] = 0xFFFFFF; - maSystemPalette[ XML_hotLight ] = 0x000080; - maSystemPalette[ XML_inactiveBorder ] = 0xD4D0C8; - maSystemPalette[ XML_inactiveCaption ] = 0x7A96DF; - maSystemPalette[ XML_inactiveCaptionText ] = 0xD8E4F8; - maSystemPalette[ XML_infoBk ] = 0xFFFFE1; - maSystemPalette[ XML_infoText ] = 0x000000; - maSystemPalette[ XML_menu ] = 0xFFFFFF; - maSystemPalette[ XML_menuBar ] = 0xECE9D8; - maSystemPalette[ XML_menuHighlight ] = 0x316AC5; - maSystemPalette[ XML_menuText ] = 0x000000; - maSystemPalette[ XML_scrollBar ] = 0xD4D0C8; - maSystemPalette[ XML_window ] = 0xFFFFFF; - maSystemPalette[ XML_windowFrame ] = 0x000000; - maSystemPalette[ XML_windowText ] = 0x000000; } void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponent ) @@ -404,9 +348,9 @@ StorageRef FilterBase::getStorage() const return mxImpl->mxStorage; } -StorageRef FilterBase::openSubStorage( const OUString& rStorageName, bool bCreate ) const +StorageRef FilterBase::openSubStorage( const OUString& rStorageName, bool bCreateMissing ) const { - return mxImpl->mxStorage->openSubStorage( rStorageName, bCreate ); + return mxImpl->mxStorage->openSubStorage( rStorageName, bCreateMissing ); } Reference< XInputStream > FilterBase::openInputStream( const OUString& rStreamName ) const @@ -429,7 +373,7 @@ void FilterBase::commitStorage() const GraphicHelper& FilterBase::getGraphicHelper() const { if( !mxImpl->mxGraphicHelper ) - mxImpl->mxGraphicHelper.reset( new GraphicHelper( mxImpl->mxGlobalFactory ) ); + mxImpl->mxGraphicHelper.reset( implCreateGraphicHelper() ); return *mxImpl->mxGraphicHelper; } @@ -447,42 +391,6 @@ OleObjectHelper& FilterBase::getOleObjectHelper() const return *mxImpl->mxOleObjHelper; } -const DeviceInfo& FilterBase::getDeviceInfo() const -{ - return mxImpl->maDeviceInfo; -} - -sal_Int32 FilterBase::convertScreenPixelX( double fPixelX ) const -{ - return (mxImpl->maDeviceInfo.PixelPerMeterX > 0) ? - static_cast< sal_Int32 >( (fPixelX * 100000.0) / mxImpl->maDeviceInfo.PixelPerMeterX ) : 0; -} - -sal_Int32 FilterBase::convertScreenPixelY( double fPixelY ) const -{ - return (mxImpl->maDeviceInfo.PixelPerMeterY > 0) ? - static_cast< sal_Int32 >( (fPixelY * 100000.0) / mxImpl->maDeviceInfo.PixelPerMeterY ) : 0; -} - -sal_Int32 FilterBase::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const -{ - FilterBaseImpl::SystemPalette::const_iterator aIt = mxImpl->maSystemPalette.find( nToken ); - OSL_ENSURE( aIt != mxImpl->maSystemPalette.end(), "FilterBase::getSystemColor - invalid token identifier" ); - return (aIt == mxImpl->maSystemPalette.end()) ? nDefaultRgb : aIt->second; -} - -sal_Int32 FilterBase::getSchemeColor( sal_Int32 /*nToken*/ ) const -{ - OSL_ENSURE( false, "FilterBase::getSchemeColor - scheme colors not implemented" ); - return API_RGB_TRANSPARENT; -} - -sal_Int32 FilterBase::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const -{ - OSL_ENSURE( false, "FilterBase::getPaletteColor - palette colors not implemented" ); - return API_RGB_TRANSPARENT; -} - OUString FilterBase::requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const { ::std::vector< OUString > aDefaultPasswords; @@ -504,7 +412,7 @@ bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString // copy the entire stream to the passed sequence SequenceOutputStream aOutStrm( orDataSeq ); - aOutStrm.copyStream( aInStrm ); + aInStrm.copyToStream( aOutStrm ); return true; } @@ -668,6 +576,11 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() ); } +GraphicHelper* FilterBase::implCreateGraphicHelper() const +{ + // default: return base implementation without any special behaviour + return new GraphicHelper( mxImpl->mxGlobalFactory ); +} // ============================================================================ diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index 3997d0b9af6d..12cafc48305a 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -35,10 +35,10 @@ #include "oox/helper/attributelist.hxx" #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/binaryoutputstream.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/core/fasttokenhandler.hxx" #include "oox/core/namespaces.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Exception; @@ -485,7 +485,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript } // try to decrypt an encrypted OLE package - OleStorage aOleStorage( mxFactory, xInStrm, false ); + ::oox::ole::OleStorage aOleStorage( mxFactory, xInStrm, false ); if( aOleStorage.isStorage() ) try { // open the required input streams in the encrypted package diff --git a/oox/source/core/recordparser.cxx b/oox/source/core/recordparser.cxx index b1749ae7be07..8f0de9c2894a 100644 --- a/oox/source/core/recordparser.cxx +++ b/oox/source/core/recordparser.cxx @@ -277,7 +277,6 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S // try to leave a context, there may be other incomplete contexts on the stack if( const RecordInfo* pEndRecInfo = getEndRecordInfo( nRecId ) ) { - (void)pEndRecInfo; // shut warning up in non-debug // finalize contexts without record identifier for context end while( !mxStack->empty() && !mxStack->hasCurrentEndRecId() ) mxStack->popContext(); @@ -288,7 +287,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S if( xCurrContext.is() ) { // context end record may contain some data, handle it as simple record - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext->startRecord( nRecId, aRecStrm ); xCurrContext->endRecord( nRecId ); } @@ -303,7 +302,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S ContextHandlerRef xCurrContext = mxStack->getCurrentContext(); if( xCurrContext.is() ) { - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext = xCurrContext->createRecordContext( nRecId, aRecStrm ); } // track all context identifiers on the stack (do not push simple records) @@ -314,7 +313,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S if( xCurrContext.is() ) { // import the record - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext->startRecord( nRecId, aRecStrm ); // end simple records (context records are finished in ContextStack::popContext) if( !pStartRecInfo ) diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index da7daa9a058e..97453d5bddb0 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -179,7 +179,7 @@ uno::Sequence< ::rtl::OUString > OOXMLDocPropHandler::GetKeywordsSet( const ::rt case (sal_Unicode)',': case (sal_Unicode)';': case (sal_Unicode)':': - case (sal_Unicode)' ': + case (sal_Unicode)'\t': // this is a delimiter // unfortunately I did not find any specification for the possible delimiters if ( aResult[nCounter].getLength() ) diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index 9df064125457..fcc350b583c3 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -2,14 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: chartdrawingfragment.cxx,v $ - * - * $Revision: 1.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 08ca5f44bec3..5b898d4da6ed 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -847,7 +847,7 @@ sal_Int32 DetailFormatterBase::getPhColor( sal_Int32 nSeriesIdx ) const Color aColor; aColor.setSrgbClr( nPhClr ); aColor.addChartTintTransformation( fShadeTint ); - nPhClr = aColor.getColor( mrData.mrFilter ); + nPhClr = aColor.getColor( mrData.mrFilter.getGraphicHelper() ); } return nPhClr; @@ -859,7 +859,7 @@ sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 aColor.setSchemeClr( nColorToken ); if( nModToken != XML_TOKEN_INVALID ) aColor.addTransformation( nModToken, nModValue ); - return aColor.getColor( mrData.mrFilter ); + return aColor.getColor( mrData.mrFilter.getGraphicHelper() ); } // ============================================================================ @@ -888,7 +888,7 @@ void LineFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aLineProps.assignUsed( *mxAutoLine ); if( rxShapeProp.is() ) aLineProps.assignUsed( rxShapeProp->getLineProperties() ); - aLineProps.pushToPropSet( rPropSet, mrData.mrFilter, mrData.maModelObjHelper, mrLinePropIds, getPhColor( nSeriesIdx ) ); + aLineProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrLinePropIds, getPhColor( nSeriesIdx ) ); } // ============================================================================ @@ -916,7 +916,7 @@ void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aFillProps.assignUsed( rxShapeProp->getFillProperties() ); if( pPicOptions ) lclConvertPictureOptions( aFillProps, *pPicOptions ); - aFillProps.pushToPropSet( rPropSet, mrData.mrFilter, mrData.maModelObjHelper, mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); + aFillProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); } // ============================================================================ diff --git a/oox/source/drawingml/clrschemecontext.cxx b/oox/source/drawingml/clrschemecontext.cxx index d91f15c56e18..996ddef2ab0f 100644 --- a/oox/source/drawingml/clrschemecontext.cxx +++ b/oox/source/drawingml/clrschemecontext.cxx @@ -73,7 +73,7 @@ clrSchemeColorContext::clrSchemeColorContext( ContextHandler& rParent, ClrScheme clrSchemeColorContext::~clrSchemeColorContext() { - mrClrScheme.setColor( mnColorToken, getColor( getFilter() ) ); + mrClrScheme.setColor( mnColorToken, getColor( getFilter().getGraphicHelper() ) ); } clrSchemeContext::clrSchemeContext( ContextHandler& rParent, ClrScheme& rClrScheme ) : diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index ebf62f17a01e..8653d787517d 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -30,8 +30,8 @@ #include #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/core/namespaces.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" using ::rtl::OUString; @@ -350,7 +350,7 @@ void Color::clearTransparence() mnAlpha = MAX_PERCENT; } -sal_Int32 Color::getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr ) const +sal_Int32 Color::getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { /* Special handling for theme style list placeholder colors (state COLOR_PH), Color::getColor() may be called with different placeholder @@ -368,10 +368,10 @@ sal_Int32 Color::getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPh case COLOR_CRGB: break; // nothing to do case COLOR_HSL: break; // nothing to do - case COLOR_SCHEME: setResolvedRgb( rFilter.getSchemeColor( mnC1 ) ); break; - case COLOR_PALETTE: setResolvedRgb( rFilter.getPaletteColor( mnC1 ) ); break; - case COLOR_SYSTEM: setResolvedRgb( rFilter.getSystemColor( mnC1, mnC2 ) ); break; - case COLOR_PH: setResolvedRgb( nPhClr ); bIsPh = true; break; + case COLOR_SCHEME: setResolvedRgb( rGraphicHelper.getSchemeColor( mnC1 ) ); break; + case COLOR_PALETTE: setResolvedRgb( rGraphicHelper.getPaletteColor( mnC1 ) ); break; + case COLOR_SYSTEM: setResolvedRgb( rGraphicHelper.getSystemColor( mnC1, mnC2 ) ); break; + case COLOR_PH: setResolvedRgb( nPhClr ); bIsPh = true; break; case COLOR_FINAL: return mnC1; } diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 28e84e72e2cc..4459c5936cfa 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -39,7 +39,6 @@ #include using rtl::OUString; -using namespace ::oox::core; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -60,8 +59,8 @@ void CustomShapeProperties::apply( const CustomShapePropertiesPtr& /* rSourceCus // not sure if this needs to be implemented } -void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFilterBase */, - const Reference < XPropertySet >& xPropSet, const Reference < XShape > & xShape ) const +void CustomShapeProperties::pushToPropSet( + const Reference < XPropertySet >& xPropSet, const Reference < XShape > & xShape ) const { if ( maShapePresetType.getLength() ) { diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 0e4d56a6634b..168055935104 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -41,7 +41,6 @@ #include "oox/helper/modelobjecthelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" using namespace ::com::sun::star; @@ -54,7 +53,6 @@ using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::geometry::IntegerRectangle2D; -using ::oox::core::FilterBase; namespace oox { namespace drawingml { @@ -105,30 +103,26 @@ RectanglePoint lclGetRectanglePoint( sal_Int32 nToken ) return RectanglePoint_LEFT_TOP; } -const awt::Size lclGetOriginalSize( const FilterBase& rFilter, const Reference< XGraphic >& rxGraphic ) +const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic ) { - awt::Size aSize100thMM( 0, 0 ); + awt::Size aSizeHmm( 0, 0 ); try { Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW ); - if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "Size100thMM" ) ) >>= aSize100thMM ) + if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "Size100thMM" ) ) >>= aSizeHmm ) { - if( !aSize100thMM.Width && !aSize100thMM.Height ) + if( !aSizeHmm.Width && !aSizeHmm.Height ) { // MAPMODE_PIXEL USED :-( awt::Size aSourceSizePixel( 0, 0 ); if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "SizePixel" ) ) >>= aSourceSizePixel ) - { - aSize100thMM = awt::Size( - rFilter.convertScreenPixelX( aSourceSizePixel.Width ), - rFilter.convertScreenPixelY( aSourceSizePixel.Height ) ); - } + aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel ); } } } catch( Exception& ) { } - return aSize100thMM; + return aSizeHmm; } } // namespace @@ -221,8 +215,8 @@ Color FillProperties::getBestSolidColor() const return aSolidColor; } -void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const FillPropertyIds& rPropIds, +void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { if( moFillType.has() ) @@ -237,7 +231,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi case XML_solidFill: if( maFillColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rGraphicHelper, nPhClr ) ); if( maFillColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ FillTransparenceId ], maFillColor.getTransparence() ); eFillStyle = FillStyle_SOLID; @@ -256,8 +250,8 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi size_t nColorCount = maGradientProps.maGradientStops.size(); if( nColorCount > 1 ) { - aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rFilter, nPhClr ); - aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rFilter, nPhClr ); + aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ); + aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr ); } // "rotate with shape" not set, or set to false -> do not rotate @@ -288,7 +282,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi { GradientFillProperties::GradientStopMap::const_iterator aIt = maGradientProps.maGradientStops.begin(); // API StartColor is inner color in axial gradient - aGradient.StartColor = (++aIt)->second.getColor( rFilter, nPhClr ); + aGradient.StartColor = (++aIt)->second.getColor( rGraphicHelper, nPhClr ); } nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation; } @@ -319,7 +313,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi { // TODO: "rotate with shape" is not possible with our current core - OUString aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( maBlipProps.mxGraphic ); + OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic ); if( aGraphicUrl.getLength() > 0 ) { // push bitmap or named bitmap to property map @@ -353,7 +347,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) ); rPropMap.setProperty( rPropIds[ FillBitmapRectanglePointId ], eRectPoint ); - awt::Size aOriginalSize = lclGetOriginalSize( rFilter, maBlipProps.mxGraphic ); + awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic ); if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) ) { // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm @@ -381,7 +375,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi Color aColor = getBestSolidColor(); if( aColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rGraphicHelper, nPhClr ) ); if( aColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ FillTransparenceId ], aColor.getTransparence() ); eFillStyle = FillStyle_SOLID; @@ -400,12 +394,12 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi } } -void FillProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const FillPropertyIds& rPropIds, +void FillProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, rModelObjHelper, rPropIds, nShapeRotation, nPhClr ); + pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nShapeRotation, nPhClr ); rPropSet.setProperties( aPropMap ); } @@ -416,7 +410,7 @@ void GraphicProperties::assignUsed( const GraphicProperties& rSourceProps ) maBlipProps.assignUsed( rSourceProps.maBlipProps ); } -void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, sal_Int32 nPhClr ) const +void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { if( maBlipProps.mxGraphic.is() ) { @@ -424,8 +418,8 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& Reference< XGraphic > xGraphic = maBlipProps.mxGraphic; if( maBlipProps.maColorChangeFrom.isUsed() && maBlipProps.maColorChangeTo.isUsed() ) { - sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rFilter, nPhClr ); - sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rFilter, nPhClr ); + sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr ); + sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr ); if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparence() ) try { sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparence(); @@ -438,7 +432,7 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& } } - OUString aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( xGraphic ); + OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); if( aGraphicUrl.getLength() > 0 ) rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl; } @@ -461,10 +455,10 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rPropMap[ PROP_AdjustContrast ] <<= nContrast; } -void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, sal_Int32 nPhClr ) const +void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, nPhClr ); + pushToPropMap( aPropMap, rGraphicHelper, nPhClr ); rPropSet.setProperties( aPropMap ); } diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index 454222bc52e6..8adffb265240 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -270,12 +270,12 @@ Reference< XFastContextHandler > FillPropertiesContext::createFastChildContext( { switch( nElement ) { - case A_TOKEN( noFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; - case A_TOKEN( solidFill ): { rFillProps.moFillType = getToken( nElement ); return new SolidFillContext( rParent, rxAttribs, rFillProps ); }; - case A_TOKEN( gradFill ): { rFillProps.moFillType = getToken( nElement ); return new GradientFillContext( rParent, rxAttribs, rFillProps.maGradientProps ); }; - case A_TOKEN( pattFill ): { rFillProps.moFillType = getToken( nElement ); return new PatternFillContext( rParent, rxAttribs, rFillProps.maPatternProps ); }; - case A_TOKEN( blipFill ): { rFillProps.moFillType = getToken( nElement ); return new BlipFillContext( rParent, rxAttribs, rFillProps.maBlipProps ); }; - case A_TOKEN( grpFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; // TODO + case A_TOKEN( noFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; + case A_TOKEN( solidFill ): { rFillProps.moFillType = getToken( nElement ); return new SolidFillContext( rParent, rxAttribs, rFillProps ); }; + case A_TOKEN( gradFill ): { rFillProps.moFillType = getToken( nElement ); return new GradientFillContext( rParent, rxAttribs, rFillProps.maGradientProps ); }; + case A_TOKEN( pattFill ): { rFillProps.moFillType = getToken( nElement ); return new PatternFillContext( rParent, rxAttribs, rFillProps.maPatternProps ); }; + case A_TOKEN( blipFill ): { rFillProps.moFillType = getToken( nElement ); return new BlipFillContext( rParent, rxAttribs, rFillProps.maBlipProps ); }; + case A_TOKEN( grpFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; // TODO } return 0; } diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 4a9a0d04e1e5..9f23cf466d30 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -37,10 +37,10 @@ #include #include "properties.hxx" #include "tokens.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/modelobjecthelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" #include "oox/core/namespaces.hxx" #include "oox/drawingml/drawingmltypes.hxx" @@ -52,7 +52,6 @@ using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::Point; using ::com::sun::star::container::XNameContainer; -using ::oox::core::FilterBase; namespace oox { namespace drawingml { @@ -395,8 +394,8 @@ void LineProperties::assignUsed( const LineProperties& rSourceProps ) moLineJoint.assignIfUsed( rSourceProps.moLineJoint ); } -void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const { // line fill type must exist, otherwise ignore other properties if( maLineFill.moFillType.has() ) @@ -453,7 +452,7 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi Color aLineColor = maLineFill.getBestSolidColor(); if( aLineColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rGraphicHelper, nPhClr ) ); if( aLineColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ LineTransparenceId ], aLineColor.getTransparence() ); } @@ -464,11 +463,11 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi } } -void LineProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, rModelObjHelper, rPropIds, nPhClr ); + pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nPhClr ); rPropSet.setProperties( aPropMap ); } diff --git a/oox/source/drawingml/linepropertiescontext.cxx b/oox/source/drawingml/linepropertiescontext.cxx index 200af2eb6fb5..a2cf4111a524 100644 --- a/oox/source/drawingml/linepropertiescontext.cxx +++ b/oox/source/drawingml/linepropertiescontext.cxx @@ -93,7 +93,7 @@ Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( case A_TOKEN( headEnd ): // CT_LineEndProperties case A_TOKEN( tailEnd ): // CT_LineEndProperties - { // ST_LineEndType + { // ST_LineEndType bool bTailEnd = nElement == A_TOKEN( tailEnd ); LineArrowProperties& rArrowProps = bTailEnd ? mrLineProperties.maEndArrow : mrLineProperties.maStartArrow; rArrowProps.moArrowType = aAttribs.getToken( XML_type ); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index cab64f11c166..e017ce0188f9 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -376,6 +376,9 @@ Reference< XShape > Shape::createAndInsert( } } + ModelObjectHelper& rModelObjectHelper = rFilterBase.getModelObjectHelper(); + const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper(); + LineProperties aLineProperties; aLineProperties.maLineFill.moFillType = XML_noFill; sal_Int32 nLinePhClr = -1; @@ -389,19 +392,19 @@ Reference< XShape > Shape::createAndInsert( { if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) aLineProperties.assignUsed( *pLineProps ); - nLinePhClr = pLineRef->maPhClr.getColor( rFilterBase ); + nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper ); } if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) ) { if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) ) aFillProperties.assignUsed( *pFillProps ); - nFillPhClr = pFillRef->maPhClr.getColor( rFilterBase ); + nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper ); } // if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_fillRef ) ) // { // if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) ) // aEffectProperties.assignUsed( *pEffectProps ); -// nEffectPhClr = pEffectRef->maPhClr.getColor( rFilterBase ); +// nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper ); // } } @@ -420,11 +423,11 @@ Reference< XShape > Shape::createAndInsert( // applying properties PropertySet aPropSet( xSet ); if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) - mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rFilterBase ); + mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rGraphicHelper ); if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.TableShape" ) ) ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); - aFillProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper(), FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); - aLineProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper(), LineProperties::DEFAULT_IDS, nLinePhClr ); + aFillProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); + aLineProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, LineProperties::DEFAULT_IDS, nLinePhClr ); // applying autogrowheight property before setting shape size, because // the shape size might be changed if currently autogrowheight is true @@ -440,7 +443,7 @@ Reference< XShape > Shape::createAndInsert( aPropSet.setProperties( aShapeProperties ); if( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.CustomShape" ) ) - mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape ); + mpCustomShapePropertiesPtr->pushToPropSet( xSet, mxShape ); // in some cases, we don't have any text body. if( getTextBody() ) diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 1684414eea2b..ee3ac495f4d6 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -80,7 +80,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ) ) { Color aColor = rLineProperties.maLineFill.getBestSolidColor(); - aBorderLine.Color = aColor.getColor( rFilterBase ); + aBorderLine.Color = aColor.getColor( rFilterBase.getGraphicHelper() ); aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); aBorderLine.LineDistance = 0; @@ -360,7 +360,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo aFillProperties.assignUsed( maFillProperties ); PropertySet aPropSet( xPropSet ); // TODO: phClr? - aFillProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper() ); + aFillProperties.pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); } } } } diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index aa08218053ac..4dbd632b2191 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -98,7 +98,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil // symbol font not supported if( maCharColor.isUsed() ) - rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter ); + rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter.getGraphicHelper() ); if( moLang.has() && (moLang.get().getLength() > 0) ) { @@ -144,7 +144,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText ) { rPropMap[ PROP_CharUnderlineHasColor ] <<= true; - rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter ); + rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter.getGraphicHelper() ); } } diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx index f20c9b53511b..8d58787e544a 100644 --- a/oox/source/drawingml/textfont.cxx +++ b/oox/source/drawingml/textfont.cxx @@ -63,7 +63,7 @@ sal_Int16 lclGetFontFamily( sal_Int32 nOoxValue ) TextFont::TextFont() : mnPitch( 0 ), - mnCharset( 0 ) + mnCharset( WINDOWS_CHARSET_ANSI ) { } @@ -72,7 +72,7 @@ void TextFont::setAttributes( const AttributeList& rAttribs ) maTypeface = rAttribs.getString( XML_typeface, OUString() ); maPanose = rAttribs.getString( XML_panose, OUString() ); mnPitch = rAttribs.getInteger( XML_pitchFamily, 0 ); - mnCharset = rAttribs.getInteger( XML_charset, 1 ); + mnCharset = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT ); } void TextFont::assignIfUsed( const TextFont& rTextFont ) diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 3416d4918e7b..2f5954168d37 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -322,7 +322,7 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, P if ( maStyleName.hasValue() ) rPropMap[ PROP_CharStyleName ] <<= maStyleName; if ( maBulletColorPtr->isUsed() ) - rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase ); + rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase.getGraphicHelper() ); } TextParagraphProperties::TextParagraphProperties() diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 21aa341107fa..ea1944d935a4 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -30,8 +30,8 @@ #include #include #include "oox/dump/oledumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/xls/biffdetector.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/formulabase.hxx" @@ -100,30 +100,30 @@ const sal_uInt16 BIFF_PT_NOSTRING = 0xFFFF; namespace { -void lclDumpDffClientPos( Output& rOut, BinaryInputStream& rStrm, const String& rName, sal_uInt16 nSubScale ) +void lclDumpDffClientPos( const OutputRef& rxOut, const BinaryInputStreamRef& rxStrm, const String& rName, sal_uInt16 nSubScale ) { - MultiItemsGuard aMultiGuard( rOut ); - TableGuard aTabGuard( rOut, 17 ); + MultiItemsGuard aMultiGuard( rxOut ); + TableGuard aTabGuard( rxOut, 17 ); { - sal_uInt16 nPos = rStrm.readuInt16(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nPos ); + sal_uInt16 nPos = rxStrm->readuInt16(); + ItemGuard aItem( rxOut, rName ); + rxOut->writeDec( nPos ); } { - sal_uInt16 nSubUnits = rStrm.readuInt16(); - ItemGuard aItem( rOut, "sub-units" ); - rOut.writeDec( nSubUnits ); - rOut.writeChar( '/' ); - rOut.writeDec( nSubScale ); + sal_uInt16 nSubUnits = rxStrm->readuInt16(); + ItemGuard aItem( rxOut, "sub-units" ); + rxOut->writeDec( nSubUnits ); + rxOut->writeChar( '/' ); + rxOut->writeDec( nSubScale ); } } -void lclDumpDffClientRect( Output& rOut, BinaryInputStream& rStrm ) +void lclDumpDffClientRect( const OutputRef& rxOut, const BinaryInputStreamRef& rxStrm ) { - lclDumpDffClientPos( rOut, rStrm, "start-col", 1024 ); - lclDumpDffClientPos( rOut, rStrm, "start-row", 256 ); - lclDumpDffClientPos( rOut, rStrm, "end-col", 1024 ); - lclDumpDffClientPos( rOut, rStrm, "end-row", 256 ); + lclDumpDffClientPos( rxOut, rxStrm, "start-col", 1024 ); + lclDumpDffClientPos( rxOut, rxStrm, "start-row", 256 ); + lclDumpDffClientPos( rxOut, rxStrm, "end-col", 1024 ); + lclDumpDffClientPos( rxOut, rxStrm, "end-row", 256 ); } } // namespace @@ -138,7 +138,7 @@ BiffDffStreamObject::BiffDffStreamObject( const OutputObjectBase& rParent, const void BiffDffStreamObject::implDumpClientAnchor() { dumpHex< sal_uInt16 >( "flags", "DFF-CLIENTANCHOR-FLAGS" ); - lclDumpDffClientRect( out(), in() ); + lclDumpDffClientRect( mxOut, mxStrm ); } // ============================================================================ @@ -161,15 +161,16 @@ void BiffCtlsStreamObject::implDump() { if( mnLength > 0 ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "CTLS-START" ); { - IndentGuard aIndGuard( out() ); - in().seek( mnStartPos ); - OcxGuidControlObject( *this, mnLength ).dump(); + IndentGuard aIndGuard( mxOut ); + mxStrm->seek( mnStartPos ); + RelativeInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, mnLength ) ); + FormControlStreamObject( *this, xRelStrm ).dump(); } writeEmptyItem( "CTLS-END" ); - out().emptyLine(); + mxOut->emptyLine(); } } @@ -315,7 +316,7 @@ bool BiffObjectBase::implStartRecord( BinaryInputStream&, sal_Int64& ornRecPos, switch( mnLastRecId ) { case BIFF_ID_CHBEGIN: - out().incIndent(); + mxOut->incIndent(); break; } @@ -351,7 +352,7 @@ bool BiffObjectBase::implStartRecord( BinaryInputStream&, sal_Int64& ornRecPos, mxBiffStrm->enableDecoder( false ); break; case BIFF_ID_CHEND: - out().decIndent(); + mxOut->decIndent(); break; } @@ -416,10 +417,10 @@ void BiffObjectBase::writeFontPortions( const FontPortionModelList& rPortions ) if( !rPortions.empty() ) { writeDecItem( "font-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - TableGuard aTabGuard( out(), 14 ); + TableGuard aTabGuard( mxOut, 14 ); for( FontPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "font-idx", aIt->mnFontId, "FONTNAMES" ); } @@ -497,7 +498,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl // #122185# bRich flag may be set, but format runs may be missing if( nFontCount > 0 ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); FontPortionModelList aPortions; aPortions.importPortions( *mxBiffStrm, nFontCount, BIFF_FONTPORTION_16BIT ); writeFontPortions( aPortions ); @@ -508,7 +509,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl if( nPhoneticSize > 0 ) { sal_Int64 nStrmPos = mxBiffStrm->tell(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); writeEmptyItem( "phonetic-data" ); dumpUnused( 2 ); dumpDec< sal_uInt16 >( "size" ); @@ -520,7 +521,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl if( nLen == 0 ) dumpUnused( 2 ); for( sal_uInt16 nPortion = 0; !mxBiffStrm->isEof() && (nPortion < nCount); ++nPortion ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); dumpDec< sal_uInt16 >( "first-portion-char" ); dumpDec< sal_uInt16 >( "first-main-char" ); dumpDec< sal_uInt16 >( "main-char-count" ); @@ -560,7 +561,7 @@ rtl_TextEncoding BiffObjectBase::dumpCodePage( const String& rName ) void BiffObjectBase::dumpFormulaResult( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); sal_uInt8 pnResult[ 8 ]; mxBiffStrm->readMemory( pnResult, 8 ); writeArrayItem( rName( "result" ), pnResult, 8 ); @@ -638,8 +639,7 @@ void BiffObjectBase::dumpRangeList( const String& rName, bool bCol16Bit, bool bR void BiffObjectBase::dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRows ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); rnCols = dumpDec< sal_uInt8 >( "width" ); rnRows = dumpDec< sal_uInt16 >( "height" ); switch( getBiff() ) @@ -651,18 +651,17 @@ void BiffObjectBase::dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRow case BIFF8: ++rnCols; ++rnRows; break; case BIFF_UNKNOWN: break; } - ItemGuard aItem( rOut, "size" ); - rOut.writeDec( rnCols ); - rOut.writeChar( 'x' ); - rOut.writeDec( rnRows ); + ItemGuard aItem( mxOut, "size" ); + mxOut->writeDec( rnCols ); + mxOut->writeChar( 'x' ); + mxOut->writeDec( rnRows ); aItem.cont(); - rOut.writeDec( rnCols * rnRows ); + mxOut->writeDec( rnCols * rnRows ); } OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); OUStringBuffer aValue; switch( dumpDec< sal_uInt8 >( "type", mxConstType ) ) { @@ -672,7 +671,7 @@ OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) break; case BIFF_DATATYPE_DOUBLE: dumpDec< double >( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case BIFF_DATATYPE_STRING: aValue.append( dumpString( "value", BIFF_STR_8BITLENGTH ) ); @@ -680,12 +679,12 @@ OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) break; case BIFF_DATATYPE_BOOL: dumpBoolean( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 7 ); break; case BIFF_DATATYPE_ERROR: dumpErrorCode( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 7 ); break; } @@ -712,22 +711,22 @@ void BiffObjectBase::dumpFrHeader( bool bWithFlags, bool bWithRange ) void BiffObjectBase::dumpDffClientRect() { - lclDumpDffClientRect( out(), in() ); + lclDumpDffClientRect( mxOut, mxStrm ); } void BiffObjectBase::dumpEmbeddedDff() { - out().decIndent(); + mxOut->decIndent(); writeEmptyItem( "EMBEDDED-DFF-START" ); - out().incIndent(); + mxOut->incIndent(); mxDffObj->dump(); - out().emptyLine(); - out().decIndent(); + mxOut->emptyLine(); + mxOut->decIndent(); writeEmptyItem( "EMBEDDED-DFF-END" ); - out().incIndent(); + mxOut->incIndent(); } -void BiffObjectBase::dumpOcxControl() +void BiffObjectBase::dumpControl() { sal_uInt32 nStartPos = dumpHex< sal_uInt32 >( "ctls-stream-pos", "CONV-DEC" ); sal_uInt32 nLength = dumpHex< sal_uInt32 >( "ctls-stream-length", "CONV-DEC" ); @@ -784,26 +783,25 @@ void FormulaObject::dumpNameFormula( const String& rName ) void FormulaObject::implDump() { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize == 0 ) return; - BinaryInputStream& rStrm = in(); - sal_Int64 nStartPos = rStrm.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); + sal_Int64 nStartPos = mxStrm->tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, mxStrm->getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); maAddData.clear(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); { - TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && !rStrm.isEof() && (rStrm.tell() < nEndPos) ) + TableGuard aTabGuard( mxOut, 8, 18 ); + while( bValid && !mxStrm->isEof() && (mxStrm->tell() < nEndPos) ) { - MultiItemsGuard aMultiGuard( out() ); - writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( mxStrm->tell() - nStartPos ) ); sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) @@ -881,7 +879,7 @@ void FormulaObject::implDump() } } } - bValid = nEndPos == rStrm.tell(); + bValid = nEndPos == mxStrm->tell(); if( bValid ) { dumpAddTokenData(); @@ -889,7 +887,7 @@ void FormulaObject::implDump() writeInfoItem( "classes", mxStack->getClassesString() ); } else - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos - rStrm.tell(), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos - mxStrm->tell(), false ); mnSize = 0; } @@ -1006,12 +1004,12 @@ OUString FormulaObject::createPlaceHolder() const sal_uInt16 FormulaObject::readFuncId() { - return (getBiff() >= BIFF4) ? in().readuInt16() : in().readuInt8(); + return (getBiff() >= BIFF4) ? mxStrm->readuInt16() : mxStrm->readuInt8(); } OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { - ItemGuard aItemGuard( out(), "func-id" ); + ItemGuard aItemGuard( mxOut, "func-id" ); writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromBiffFuncId( nFuncId ); @@ -1025,9 +1023,9 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* } OUString aFuncName = aBuffer.makeStringAndClear(); aItemGuard.cont(); - out().writeChar( OOX_DUMP_STRQUOTE ); - out().writeString( aFuncName ); - out().writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeString( aFuncName ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } @@ -1133,13 +1131,13 @@ OUString FormulaObject::dumpTokenRefTabIdxs() void FormulaObject::dumpIntToken() { dumpDec< sal_uInt16 >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpDoubleToken() { dumpDec< double >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpStringToken() @@ -1153,13 +1151,13 @@ void FormulaObject::dumpStringToken() void FormulaObject::dumpBoolToken() { dumpBoolean( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpErrorToken() { dumpErrorCode( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpMissArgToken() @@ -1201,14 +1199,14 @@ void FormulaObject::dumpRefToken( const OUString& rTokClass, bool bNameMode ) { TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddressItem( "addr", aPos, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpAreaToken( const OUString& rTokClass, bool bNameMode ) { TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRangeItem( "range", aRange, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpRefErrToken( const OUString& rTokClass, bool bArea ) @@ -1222,7 +1220,7 @@ void FormulaObject::dumpRef3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefTabIdxs(); TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddress3dItem( "addr", aRef, aPos, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) @@ -1230,7 +1228,7 @@ void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefTabIdxs(); TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRange3dItem( "range", aRef, aRange, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpRefErr3dToken( const OUString& rTokClass, bool bArea ) @@ -1260,7 +1258,7 @@ void FormulaObject::dumpExpToken( const String& rName ) aPos.mnCol = dumpDec< sal_uInt16, sal_uInt8 >( getBiff() != BIFF2, "col" ); writeAddressItem( "base-addr", aPos ); OUStringBuffer aOp( rName ); - StringHelper::appendIndex( aOp, out().getLastItemValue() ); + StringHelper::appendIndex( aOp, mxOut->getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); } @@ -1288,7 +1286,7 @@ void FormulaObject::dumpFuncToken( const OUString& rTokClass ) void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) { sal_uInt8 nParamCount; - in() >> nParamCount; + *mxStrm >> nParamCount; sal_uInt16 nFuncId = readFuncId(); bool bCmd = getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ); if( bCmd ) @@ -1345,7 +1343,7 @@ bool FormulaObject::dumpAttrToken() case BIFF_TOK_ATTR_CHOOSE: { sal_uInt16 nCount = dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "choices" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "#skip" ); dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "skip-err" ); @@ -1431,7 +1429,7 @@ void FormulaObject::dumpNlrColRowToken( const OUString& rTokClass, bool bAddData { TokenAddress aPos = dumpTokenAddress( false ); writeInfoItem( "addr", lclCreateNlr( aPos ) ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } } @@ -1447,7 +1445,7 @@ void FormulaObject::dumpNlrRangeToken( const OUString& rTokClass, bool bAddData { TokenAddress aPos = dumpTokenAddress( false ); writeInfoItem( "addr", lclCreateNlr( aPos ) ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } dumpUnknown( 1 ); dumpRange( "target-range" ); @@ -1462,24 +1460,23 @@ void FormulaObject::dumpNlrRangeErrToken() void FormulaObject::dumpAddTokenData() { - Output& rOut = out(); - rOut.resetItemIndex(); + mxOut->resetItemIndex(); for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); aIt != aEnd; ++aIt ) { AddDataType eType = *aIt; { - ItemGuard aItem( rOut, "#add-data" ); + ItemGuard aItem( mxOut, "#add-data" ); switch( eType ) { - case ADDDATA_NLR: rOut.writeAscii( "tNlr" ); break; - case ADDDATA_ARRAY: rOut.writeAscii( "tArray" ); break; - case ADDDATA_MEMAREA: rOut.writeAscii( "tMemArea" ); break; + case ADDDATA_NLR: mxOut->writeAscii( "tNlr" ); break; + case ADDDATA_ARRAY: mxOut->writeAscii( "tArray" ); break; + case ADDDATA_MEMAREA: mxOut->writeAscii( "tMemArea" ); break; } } size_t nIdx = aIt - maAddData.begin(); - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( eType ) { case ADDDATA_NLR: dumpAddDataNlr( nIdx ); break; @@ -1513,7 +1510,7 @@ void FormulaObject::dumpAddDataArray( size_t nIdx ) dumpConstArrayHeader( nCols, nRows ); OUStringBuffer aOp; - TableGuard aTabGuard( out(), 17 ); + TableGuard aTabGuard( mxOut, 17 ); for( sal_uInt32 nRow = 0; nRow < nRows; ++nRow ) { OUStringBuffer aArrayLine; @@ -1779,7 +1776,7 @@ void WorkbookStreamObject::implDumpRecordBody() dumpDec< sal_uInt8 >( "creator", "CHFRINFO-APPVERSION" ); dumpDec< sal_uInt8 >( "writer", "CHFRINFO-APPVERSION" ); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "rec-range-count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) dumpHexPair< sal_uInt16 >( "#rec-range", '-' ); } @@ -1995,7 +1992,7 @@ void WorkbookStreamObject::implDumpRecordBody() break; case BIFF_ID_COLUMNDEFAULT: - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int32 nCol = 0, nCount = dumpColRange(); nCol < nCount; ++nCol ) dumpXfIdx( "#xf-idx", true ); dumpUnused( 2 ); @@ -2018,11 +2015,11 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_COORDLIST: { - out().resetItemIndex(); - TableGuard aTabGuard( out(), 12, 10 ); + mxOut->resetItemIndex(); + TableGuard aTabGuard( mxOut, 12, 10 ); while( rStrm.getRemaining() >= 4 ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#point" ); dumpDec< sal_uInt16 >( "x" ); dumpDec< sal_uInt16 >( "y" ); @@ -2040,10 +2037,10 @@ void WorkbookStreamObject::implDumpRecordBody() sal_Int32 nCol2 = dumpColIndex( "last-col-idx", false ); sal_Int32 nCol1 = dumpColIndex( "first-col-idx", false ); sal_Int32 nRow = dumpRowIndex( "row-idx" ); - TableGuard aTabGuard( out(), 14, 17 ); + TableGuard aTabGuard( mxOut, 14, 17 ); for( Address aPos( nCol1, nRow ); !rStrm.isEof() && (aPos.mnCol <= nCol2); ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpConstValue(); } @@ -2117,7 +2114,7 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_DBCELL: dumpDec< sal_uInt32 >( "reverse-offset-to-row" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= 2 ) dumpDec< sal_uInt16 >( "#cell-offset" ); break; @@ -2181,7 +2178,7 @@ void WorkbookStreamObject::implDumpRecordBody() else { dumpString( "workbook-url" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nSheet = 0; !rStrm.isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); } @@ -2214,11 +2211,11 @@ void WorkbookStreamObject::implDumpRecordBody() if( eBiff == BIFF8 ) { sal_uInt16 nCount = dumpDec< sal_uInt16 >( "ref-count" ); - TableGuard aTabGuard( out(), 10, 17, 24 ); - out().resetItemIndex(); + TableGuard aTabGuard( mxOut, 10, 17, 24 ); + mxOut->resetItemIndex(); for( sal_uInt16 nRefId = 0; !rStrm.isEof() && (nRefId < nCount); ++nRefId ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#ref" ); dumpDec< sal_uInt16 >( "extbook-idx" ); dumpDec< sal_Int16 >( "first-sheet", "EXTERNSHEET-IDX" ); @@ -2353,7 +2350,7 @@ void WorkbookStreamObject::implDumpRecordBody() if( nFormat == 9 ) { writeEmptyItem( "bitmap-header" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( dumpDec< sal_uInt32 >( "header-size" ) == 12 ) { dumpDec< sal_Int16 >( "width" ); @@ -2374,7 +2371,7 @@ void WorkbookStreamObject::implDumpRecordBody() dumpRowIndex( "first-row-with-cell", eBiff == BIFF8 ); dumpRowIndex( "first-free-row", eBiff == BIFF8 ); if( nRecId == BIFF3_ID_INDEX ) dumpHex< sal_uInt32 >( (eBiff <= BIFF4) ? "first-xf-pos" : "defcolwidth-pos", "CONV-DEC" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= 4 ) dumpHex< sal_uInt32 >( "#first-row-pos-of-block", "CONV-DEC" ); break; @@ -2424,10 +2421,10 @@ void WorkbookStreamObject::implDumpRecordBody() { Address aPos = dumpAddress(); { - TableGuard aTabGuard( out(), 12 ); + TableGuard aTabGuard( mxOut, 12 ); for( ; rStrm.getRemaining() >= 4; ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpXfIdx(); } @@ -2440,10 +2437,10 @@ void WorkbookStreamObject::implDumpRecordBody() { Address aPos = dumpAddress(); { - TableGuard aTabGuard( out(), 12, 12 ); + TableGuard aTabGuard( mxOut, 12, 12 ); for( ; rStrm.getRemaining() >= 8; ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpXfIdx(); dumpRk( "value" ); @@ -2611,13 +2608,13 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_PTPAGEFIELDS: { - out().resetItemIndex(); - TableGuard aTabGuard( out(), 17, 17, 17 ); + mxOut->resetItemIndex(); + TableGuard aTabGuard( mxOut, 17, 17, 17 ); while( rStrm.getRemaining() >= 6 ) { writeEmptyItem( "#page-field" ); - MultiItemsGuard aMultiGuard( out() ); - IndentGuard aIndGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); + IndentGuard aIndGuard( mxOut ); dumpDec< sal_Int16 >( "base-field" ); dumpDec< sal_Int16 >( "item", "PTPAGEFIELDS-ITEM" ); dumpDec< sal_uInt16 >( "dropdown-obj-id" ); @@ -2626,7 +2623,7 @@ void WorkbookStreamObject::implDumpRecordBody() break; case BIFF_ID_PTROWCOLFIELDS: - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int64 nIdx = 0, nCount = rStrm.getRemaining() / 2; nIdx < nCount; ++nIdx ) dumpDec< sal_Int16 >( "#field-idx" ); break; @@ -2636,19 +2633,19 @@ void WorkbookStreamObject::implDumpRecordBody() { sal_uInt16 nCount = (mnPTRowColItemsIdx == 0) ? mnPTRowFields : mnPTColFields; sal_Int64 nLineSize = 8 + 2 * nCount; - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= nLineSize ) { writeEmptyItem( "#line-data" ); - IndentGuard aIndGuard( out() ); - MultiItemsGuard aMultiGuard( out() ); + IndentGuard aIndGuard( mxOut ); + MultiItemsGuard aMultiGuard( mxOut ); dumpDec< sal_uInt16 >( "ident-count" ); dumpDec< sal_uInt16 >( "item-type", "PTROWCOLITEMS-ITEMTYPE" ); dumpDec< sal_uInt16 >( "used-count" ); dumpHex< sal_uInt16 >( "flags", "PTROWCOLITEMS-FLAGS" ); OUStringBuffer aItemList; for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) - StringHelper::appendToken( aItemList, in().readInt16() ); + StringHelper::appendToken( aItemList, mxStrm->readInt16() ); writeInfoItem( "item-idxs", aItemList.makeStringAndClear() ); } ++mnPTRowColItemsIdx; @@ -2714,10 +2711,10 @@ void WorkbookStreamObject::implDumpRecordBody() writeStringItem( "name", rStrm.readUniStringBody( nNameLen, true ) ); if( nUserLen > 0 ) dumpUniString( "user" ); // repeated string length if( nCommentLen > 0 ) dumpUniString( "comment" ); // repeated string length - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nCell = 0; !rStrm.isEof() && (nCell < nCellCount); ++nCell ) dumpAddress( "#pos" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nCell = 0; !rStrm.isEof() && (nCell < nCellCount); ++nCell ) dumpString( "#value" ); dumpUnused( 2 * nCellCount ); @@ -2803,7 +2800,7 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_SST: dumpDec< sal_uInt32 >( "string-cell-count" ); dumpDec< sal_uInt32 >( "sst-size" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( !rStrm.isEof() && (rStrm.getRemaining() >= 3) ) dumpUniString( "#entry" ); break; @@ -3029,7 +3026,7 @@ void WorkbookStreamObject::dumpExtColorValue( sal_uInt32 nColorType ) void WorkbookStreamObject::dumpExtColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); switch( extractValue< sal_uInt8 >( dumpDec< sal_uInt8 >( "flags", "EXTCOLOR-FLAGS" ), 1, 7 ) ) { @@ -3046,7 +3043,7 @@ void WorkbookStreamObject::dumpExtColor( const String& rName ) void WorkbookStreamObject::dumpExtCfColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); dumpExtColorValue( dumpExtColorType< sal_uInt32 >() ); dumpDec< double >( "tint", "CONV-FLOAT-TO-PERC" ); @@ -3089,7 +3086,7 @@ sal_uInt16 WorkbookStreamObject::dumpCellHeader( bool bBiff2Style ) void WorkbookStreamObject::dumpBoolErr() { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); sal_uInt8 nValue = dumpHex< sal_uInt8 >( "value" ); bool bErrCode = dumpBool< sal_uInt8 >( "is-errorcode" ); if( bErrCode ) @@ -3106,7 +3103,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x02000000 ) ) { writeEmptyItem( "numfmt-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( getFlag< sal_uInt16 >( nFlags2, 0x0001 ) ) { dumpDec< sal_uInt16 >( "size" ); @@ -3121,7 +3118,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x04000000 ) ) { writeEmptyItem( "font-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nRecPos = rStrm.tell(); dumpUniString( "name", BIFF_STR_8BITLENGTH ); dumpUnused( static_cast< sal_Int32 >( nRecPos + 64 - rStrm.tell() ) ); @@ -3147,7 +3144,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x08000000 ) ) { writeEmptyItem( "alignment-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt8 >( "alignent", "CFRULE-ALIGNMENT" ); dumpHex< sal_uInt8 >( "rotation", "TEXTROTATION" ); dumpHex< sal_uInt16 >( "indent", "CFRULE-INDENT" ); @@ -3156,7 +3153,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x10000000 ) ) { writeEmptyItem( "border-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "border-style", "XF-BORDERSTYLE" ); dumpHex< sal_uInt16 >( "border-color1", "XF-BORDERCOLOR1" ); dumpHex< sal_uInt32 >( "border-color2", "CFRULE-BORDERCOLOR2" ); @@ -3164,13 +3161,13 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x20000000 ) ) { writeEmptyItem( "pattern-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt32 >( "pattern", "CFRULE-FILLBLOCK" ); } if( getFlag< sal_uInt32 >( nFlags1, 0x40000000 ) ) { writeEmptyItem( "protection-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "flags", "CFRULE-PROTECTION-FLAGS" ); } } @@ -3180,14 +3177,14 @@ void WorkbookStreamObject::dumpXfExtProp() BiffInputStream& rStrm = getBiffStream(); for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); + mxOut->startMultiItems(); sal_Int64 nStartPos = rStrm.tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "XFEXT-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 4: case 5: case 7: case 8: case 9: case 10: case 11: case 13: @@ -3200,11 +3197,11 @@ void WorkbookStreamObject::dumpXfExtProp() break; case 6: dumpExtGradientHead(); - out().resetItemIndex(); - for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !in().isEof(); ++nStop ) + mxOut->resetItemIndex(); + for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !mxStrm->isEof(); ++nStop ) { writeEmptyItem( "#stop" ); - IndentGuard aIndGuard2( out() ); + IndentGuard aIndGuard2( mxOut ); sal_uInt16 nColorType = dumpExtColorType< sal_uInt16 >(); dumpExtColorValue( nColorType ); dumpDec< double >( "stop-pos" ); @@ -3228,14 +3225,14 @@ void WorkbookStreamObject::dumpDxfProp() dumpUnused( 2 ); for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); + mxOut->startMultiItems(); sal_Int64 nStartPos = rStrm.tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "DXF-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 0: @@ -3325,7 +3322,7 @@ void WorkbookStreamObject::dumpDxf12Prop() { BiffInputStream& rStrm = getBiffStream(); writeEmptyItem( "dxf-data" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_uInt32 nSize = dumpDec< sal_uInt32 >( "dxf-size" ); if( nSize == 0 ) { @@ -3350,7 +3347,7 @@ void WorkbookStreamObject::dumpCfRule12Param( sal_uInt16 nSubType ) sal_Int64 nEndPos = getBiffStream().tell() + nSize; { writeEmptyItem( "params" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); switch( nSubType ) { case 5: @@ -3380,7 +3377,7 @@ void WorkbookStreamObject::dumpCfRule12Param( sal_uInt16 nSubType ) void WorkbookStreamObject::dumpFontRec() { sal_uInt16 nFontId = getBiffData().getFontCount(); - out().resetItemIndex( nFontId ); + mxOut->resetItemIndex( nFontId ); writeEmptyItem( "#font" ); sal_uInt16 nHeight = dumpDec< sal_uInt16 >( "height", "CONV-TWIP-TO-PT" ); sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "FONT-FLAGS" ); @@ -3420,19 +3417,19 @@ void WorkbookStreamObject::dumpFormatRec() case BIFF2: case BIFF3: nFormatIdx = mnFormatIdx++; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); break; case BIFF4: nFormatIdx = mnFormatIdx++; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); dumpUnused( 2 ); break; case BIFF5: case BIFF8: getBiffStream() >> nFormatIdx; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); writeDecItem( "fmt-idx", nFormatIdx ); break; @@ -3445,7 +3442,7 @@ void WorkbookStreamObject::dumpFormatRec() void WorkbookStreamObject::dumpXfRec() { sal_uInt16 nXfId = getBiffData().getXfCount(); - out().resetItemIndex( nXfId ); + mxOut->resetItemIndex( nXfId ); writeEmptyItem( "#xf" ); sal_uInt16 nFontId = dumpFontIdx( EMPTY_STRING, getBiff() >= BIFF5 ); switch( getBiff() ) @@ -3824,7 +3821,6 @@ void WorkbookStreamObject::dumpObjRecBiff5() void WorkbookStreamObject::dumpObjRecBiff8() { - Output& rOut = out(); BiffInputStream& rStrm = getBiffStream(); NameListRef xRecNames = cfg().getNameList( "OBJ-RECNAMES" ); sal_uInt16 nObjType = 0xFFFF; @@ -3833,10 +3829,10 @@ void WorkbookStreamObject::dumpObjRecBiff8() bool bLoop = true; while( bLoop && (rStrm.getRemaining() >= 4) ) { - rOut.emptyLine(); + mxOut->emptyLine(); sal_uInt16 nSubRecId, nSubRecSize; { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "OBJREC" ); writeHexItem( "pos", static_cast< sal_uInt32 >( rStrm.tell() ) ); rStrm >> nSubRecId >> nSubRecSize; @@ -3849,7 +3845,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() sal_Int64 nRealRecSize = ::std::min< sal_Int64 >( nSubRecSize, rStrm.getRemaining() ); sal_Int64 nSubRecEnd = nSubRecStart + nRealRecSize; - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case BIFF_ID_OBJMACRO: @@ -3871,7 +3867,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() if( rStrm.tell() + 4 <= nSubRecEnd ) { if( bControl && bCtlsStrm ) - dumpOcxControl(); + dumpControl(); else dumpHex< sal_uInt32 >( "ole-storage-id" ); } @@ -3880,7 +3876,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() sal_uInt32 nKeySize = dumpDec< sal_uInt32 >( "licence-key-size" ); if( nKeySize > 0 ) { - IndentGuard aIndGuard2( rOut ); + IndentGuard aIndGuard2( mxOut ); sal_Int64 nKeyEnd = rStrm.tell() + nKeySize; dumpArray( "licence-key", static_cast< sal_Int32 >( nKeySize ) ); rStrm.seek( nKeyEnd ); @@ -4052,7 +4048,7 @@ void WorkbookStreamObject::dumpObjRecPadding() { if( getBiffStream().tell() & 1 ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt8 >( "padding" ); } } @@ -4090,7 +4086,7 @@ void WorkbookStreamObject::dumpObjRecFmla( const String& rName, sal_uInt16 nFmla if( nFmlaSize > 0 ) { writeEmptyItem( rName ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; dumpObjRecFmlaRaw(); if( rStrm.isEof() || (rStrm.tell() != nStrmEnd) ) @@ -4105,7 +4101,7 @@ void WorkbookStreamObject::dumpObjRecPictFmla( sal_uInt16 nFmlaSize ) if( nFmlaSize > 0 ) { writeEmptyItem( "pic-link" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; if( (getBiff() == BIFF3) && (nStrmEnd & 1) ) ++nStrmEnd; // BIFF3 size without padding dumpObjRecFmlaRaw(); @@ -4152,7 +4148,7 @@ void PivotCacheStreamObject::implDumpRecordBody() break; case BIFF_ID_PCDFDISCRETEPR: - out().resetItemIndex(); + mxOut->resetItemIndex(); while( !rStrm.isEof() && (rStrm.getRemaining() >= 2) ) dumpDec< sal_uInt16 >( "#item-index" ); break; @@ -4172,12 +4168,12 @@ void PivotCacheStreamObject::implDumpRecordBody() case BIFF_ID_PCITEM_DATE: { DateTime aDateTime; - aDateTime.Year = in().readuInt16(); - aDateTime.Month = in().readuInt16(); - aDateTime.Day = in().readuInt8(); - aDateTime.Hours = in().readuInt8(); - aDateTime.Minutes = in().readuInt8(); - aDateTime.Seconds = in().readuInt8(); + aDateTime.Year = mxStrm->readuInt16(); + aDateTime.Month = mxStrm->readuInt16(); + aDateTime.Day = mxStrm->readuInt8(); + aDateTime.Hours = mxStrm->readuInt8(); + aDateTime.Minutes = mxStrm->readuInt8(); + aDateTime.Seconds = mxStrm->readuInt8(); writeDateTimeItem( "value", aDateTime ); } break; @@ -4214,10 +4210,17 @@ void RootStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUStrin { if( rStrgPath.equalsAscii( "_VBA_PROJECT_CUR" ) ) VbaProjectStorageObject( *this, rxStrg, rSysPath ).dump(); + else if( rStrgPath.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "MBD" ) ) ) + VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump(); else OleStorageObject::implDumpStorage( rxStrg, rStrgPath, rSysPath ); } +void RootStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + WorkbookStreamObject( *this, rxStrm, rSysFileName ).dump(); +} + // ============================================================================ // ============================================================================ @@ -4233,7 +4236,7 @@ Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Refere { if( rxFactory.is() && rxInStrm.is() ) { - StorageRef xStrg( new OleStorage( rxFactory, rxInStrm, true ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( rxFactory, rxInStrm, true ) ); MediaDescriptor aMediaDesc; ConfigRef xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName, aMediaDesc ) ); DumperBase::construct( xCfg ); @@ -4242,17 +4245,7 @@ Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Refere void Dumper::implDump() { - RootStorageObject aRootStrg( *this ); - if( aRootStrg.isValid() ) - { - aRootStrg.dump(); - } - else if( StorageBase* pRootStrg = cfg().getRootStorage().get() ) - { - // try to dump plain BIFF stream - BinaryInputStreamRef xStrm( new BinaryXInputStream( pRootStrg->openInputStream( OUString() ), false ) ); - WorkbookStreamObject( *this, xStrm, cfg().getSysFileName() ).dump(); - } + RootStorageObject( *this ).dump(); } // ============================================================================ diff --git a/oox/source/dump/biffdumper.ini b/oox/source/dump/biffdumper.ini index 618e89c996e0..16c3fb883149 100644 --- a/oox/source/dump/biffdumper.ini +++ b/oox/source/dump/biffdumper.ini @@ -350,7 +350,7 @@ multilist=RECORD-NAMES-BIFF5 0x00B8=DOCROUTE,RECIPNAME,,,,MULTRK,MULTBLANK,TOOLBARHDR 0x00C0=TOOLBAREND,MMS,ADDMENU,DELMENU,,PTDATAFIELD,PCDEFINITION,PCDFIELD 0x00C8=PCITEM_INDEXLIST,PCITEM_DOUBLE,PCITEM_BOOL,PCITEM_ERROR,PCITEM_INTEGER,PCITEM_STRING,PCITEM_DATE,PCITEM_MISSING - 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,OBPROJ,,PIVOTCACHE,RSTRING,DBCELL + 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,VBAPROJECT,,PIVOTCACHE,RSTRING,DBCELL 0x00D8=PCDFRANGEPR,PCDFDISCRETEPR,BOOKBOOL,REVERT,SXEXT|PARAMQRY,SCENPROTECT,OLESIZE,UDDESC 0x00E0=XF,INTERFACEHDR,INTERFACEEND,PCDSOURCE,,,, 0x0206=FORMULA @@ -381,7 +381,7 @@ multilist=RECORD-NAMES-BIFF8 0x0190=,,,,,,CHTRHEADER, 0x01A8=,USERBVIEW,USERSVIEWBEGIN,USERSVIEWEND,,QSI,EXTERNALBOOK,PROT4REV 0x01B0=CFHEADER,CFRULE,DATAVALIDATIONS,,,DCONBINAME,TXO,REFRESHALL - 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,PCDFSQLTYPE,PROT4REVPASS,,DATAVALIDATION, + 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,PCDFSQLTYPE,PROT4REVPASS,VBAPROJECTEMPTY,DATAVALIDATION, 0x01C0=XL9FILE,RECALCID,INTCACHEDDATA,,,,, 0x0800=SCREENTIP,,,WEBQRYSETTINGS,WEBQRYTABLES,,, 0x0850=CHFRINFO,CHFRWRAPPER,CHFRBLOCKBEGIN,CHFRBLOCKEND,,,,CHFRUNITPROPS diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 599687f5bd50..1b93d9b213c4 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -93,7 +93,7 @@ void DffStreamObject::implWriteExtHeader() case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors } - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeHexItem( "instance", mnInstVer, pcListName ); if( isContainer() ) writeDecItem( "container-size", mnRealSize ); } @@ -137,11 +137,11 @@ void DffStreamObject::implDumpRecordBody() sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" ); dumpDec< sal_uInt32 >( "shape-count" ); dumpDec< sal_uInt32 >( "drawing-count" ); - out().resetItemIndex( 1 ); - TableGuard aTabGuard( out(), 15, 16 ); - for( sal_uInt32 nCluster = 1; !in().isEof() && (nCluster < nClusters); ++nCluster ) + mxOut->resetItemIndex( 1 ); + TableGuard aTabGuard( *mxOut, 15, 16 ); + for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( *mxOut ); writeEmptyItem( "#cluster" ); dumpDec< sal_uInt32 >( "drawing-id" ); dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" ); @@ -223,14 +223,14 @@ void DffStreamObject::dumpDffOpt() { sal_uInt16 nPropCount = getInst(); PropInfoVector aPropInfos; - out().resetItemIndex(); - for( sal_uInt16 nPropIdx = 0; !in().isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + mxOut->resetItemIndex(); + for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx ) { sal_uInt16 nPropId = dumpDffOptPropHeader(); sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK; - sal_uInt32 nValue = in().readuInt32(); + sal_uInt32 nValue = mxStrm->readuInt32(); - IndentGuard aIndent( out() ); + IndentGuard aIndent( mxOut ); if( getFlag( nPropId, DFF_OPT_COMPLEX ) ) { writeHexItem( "complex-size", nValue, "CONV-DEC" ); @@ -280,14 +280,14 @@ void DffStreamObject::dumpDffOpt() } } - out().resetItemIndex(); - for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !in().isEof() && (aIt != aEnd); ++aIt ) + mxOut->resetItemIndex(); + for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) { - out().startMultiItems(); + mxOut->startMultiItems(); writeEmptyItem( "#complex-data" ); writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" ); - out().endMultiItems(); - IndentGuard aIndent( out() ); + mxOut->endMultiItems(); + IndentGuard aIndent( *mxOut ); switch( aIt->meType ) { case PROPTYPE_BINARY: @@ -308,8 +308,8 @@ void DffStreamObject::dumpDffOpt() sal_uInt16 DffStreamObject::dumpDffOptPropHeader() { - MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 11 ); + MultiItemsGuard aMultiGuard( mxOut ); + TableGuard aTabGuard( mxOut, 11 ); writeEmptyItem( "#prop" ); return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" ); } diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index 8e0e9a4e1225..807a5ec74715 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -38,6 +38,7 @@ #include #include #include "oox/helper/binaryoutputstream.hxx" +#include "oox/helper/textinputstream.hxx" #include "oox/core/filterbase.hxx" #include "oox/xls/biffhelper.hxx" @@ -1042,31 +1043,31 @@ ConfigItemBase::~ConfigItemBase() { } -void ConfigItemBase::readConfigBlock( const ConfigInputStreamRef& rxStrm ) +void ConfigItemBase::readConfigBlock( TextInputStream& rStrm ) { - readConfigBlockContents( rxStrm ); + readConfigBlockContents( rStrm ); } void ConfigItemBase::implProcessConfigItemStr( - const ConfigInputStreamRef& /*rxStrm*/, const OUString& /*rKey*/, const OUString& /*rData*/ ) + TextInputStream& /*rStrm*/, const OUString& /*rKey*/, const OUString& /*rData*/ ) { } void ConfigItemBase::implProcessConfigItemInt( - const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 /*nKey*/, const OUString& /*rData*/ ) + TextInputStream& /*rStrm*/, sal_Int64 /*nKey*/, const OUString& /*rData*/ ) { } -void ConfigItemBase::readConfigBlockContents( const ConfigInputStreamRef& rxStrm ) +void ConfigItemBase::readConfigBlockContents( TextInputStream& rStrm ) { bool bLoop = true; - while( bLoop && !rxStrm->isEOF() ) + while( bLoop && !rStrm.isEof() ) { OUString aKey, aData; - switch( readConfigLine( rxStrm, aKey, aData ) ) + switch( readConfigLine( rStrm, aKey, aData ) ) { case LINETYPE_DATA: - processConfigItem( rxStrm, aKey, aData ); + processConfigItem( rStrm, aKey, aData ); break; case LINETYPE_END: bLoop = false; @@ -1076,12 +1077,12 @@ void ConfigItemBase::readConfigBlockContents( const ConfigInputStreamRef& rxStrm } ConfigItemBase::LineType ConfigItemBase::readConfigLine( - const ConfigInputStreamRef& rxStrm, OUString& orKey, OUString& orData ) const + TextInputStream& rStrm, OUString& orKey, OUString& orData ) const { OUString aLine; - while( !rxStrm->isEOF() && (aLine.getLength() == 0) ) + while( !rStrm.isEof() && (aLine.getLength() == 0) ) { - try { aLine = rxStrm->readLine(); } catch( Exception& ) { aLine = OUString(); } + aLine = rStrm.readLine(); if( (aLine.getLength() > 0) && (aLine[ 0 ] == OOX_DUMP_BOM) ) aLine = aLine.copy( 1 ); aLine = StringHelper::trimSpaces( aLine ); @@ -1101,20 +1102,20 @@ ConfigItemBase::LineType ConfigItemBase::readConfigLine( LINETYPE_DATA : LINETYPE_END; } -ConfigItemBase::LineType ConfigItemBase::readConfigLine( const ConfigInputStreamRef& rxStrm ) const +ConfigItemBase::LineType ConfigItemBase::readConfigLine( TextInputStream& rStrm ) const { OUString aKey, aData; - return readConfigLine( rxStrm, aKey, aData ); + return readConfigLine( rStrm, aKey, aData ); } void ConfigItemBase::processConfigItem( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { sal_Int64 nKey; if( StringHelper::convertStringToInt( nKey, rKey ) ) - implProcessConfigItemInt( rxStrm, nKey, rData ); + implProcessConfigItemInt( rStrm, nKey, rData ); else - implProcessConfigItemStr( rxStrm, rKey, rData ); + implProcessConfigItemStr( rStrm, rKey, rData ); } // ============================================================================ @@ -1144,18 +1145,18 @@ bool NameListBase::implIsValid() const } void NameListBase::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "include" ) ) include( rData ); else if( rKey.equalsAscii( "exclude" ) ) exclude( rData ); else - ConfigItemBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + ConfigItemBase::implProcessConfigItemStr( rStrm, rKey, rData ); } void NameListBase::implProcessConfigItemInt( - const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 nKey, const OUString& rData ) + TextInputStream& /*rStrm*/, sal_Int64 nKey, const OUString& rData ) { implSetName( nKey, rData ); } @@ -1206,14 +1207,14 @@ ConstList::ConstList( const SharedConfigData& rCfgData ) : } void ConstList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "default" ) ) setDefaultName( rData ); else if( rKey.equalsAscii( "quote-names" ) ) setQuoteNames( StringHelper::convertStringToBool( rData ) ); else - NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + NameListBase::implProcessConfigItemStr( rStrm, rKey, rData ); } void ConstList::implSetName( sal_Int64 nKey, const OUString& rName ) @@ -1265,12 +1266,12 @@ void MultiList::setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNam } void MultiList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "ignore-empty" ) ) mbIgnoreEmpty = StringHelper::convertStringToBool( rData ); else - ConstList::implProcessConfigItemStr( rxStrm, rKey, rData ); + ConstList::implProcessConfigItemStr( rStrm, rKey, rData ); } void MultiList::implSetName( sal_Int64 nKey, const OUString& rName ) @@ -1289,7 +1290,7 @@ FlagsList::FlagsList( const SharedConfigData& rCfgData ) : } void FlagsList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "ignore" ) ) { @@ -1299,7 +1300,7 @@ void FlagsList::implProcessConfigItemStr( } else { - NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + NameListBase::implProcessConfigItemStr( rStrm, rKey, rData ); } } @@ -1600,18 +1601,18 @@ bool SharedConfigData::implIsValid() const } void SharedConfigData::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "include-config-file" ) ) readConfigFile( maConfigPath + rData ); else if( rKey.equalsAscii( "constlist" ) ) - readNameList< ConstList >( rxStrm, rData ); + readNameList< ConstList >( rStrm, rData ); else if( rKey.equalsAscii( "multilist" ) ) - readNameList< MultiList >( rxStrm, rData ); + readNameList< MultiList >( rStrm, rData ); else if( rKey.equalsAscii( "flagslist" ) ) - readNameList< FlagsList >( rxStrm, rData ); + readNameList< FlagsList >( rStrm, rData ); else if( rKey.equalsAscii( "combilist" ) ) - readNameList< CombiList >( rxStrm, rData ); + readNameList< CombiList >( rStrm, rData ); else if( rKey.equalsAscii( "shortlist" ) ) createShortList( rData ); else if( rKey.equalsAscii( "unitconverter" ) ) @@ -1625,12 +1626,13 @@ bool SharedConfigData::readConfigFile( const OUString& rFileUrl ) bool bLoaded = maConfigFiles.count( rFileUrl ) > 0; if( !bLoaded ) { - Reference< XTextInputStream > xTextInStrm = - InputOutputHelper::openTextInputStream( mxFactory, rFileUrl, CREATE_OUSTRING( "UTF-8" ) ); - if( xTextInStrm.is() ) + Reference< XInputStream > xInStrm = InputOutputHelper::openInputStream( mxFactory, rFileUrl ); + BinaryXInputStream aInStrm( xInStrm, true ); + TextInputStream aTxtStrm( aInStrm, RTL_TEXTENCODING_UTF8 ); + if( !aTxtStrm.isEof() ) { maConfigFiles.insert( rFileUrl ); - readConfigBlockContents( xTextInStrm ); + readConfigBlockContents( aTxtStrm ); bLoaded = true; } } @@ -2220,20 +2222,38 @@ void StorageObjectBase::construct( const ObjectBase& rParent ) bool StorageObjectBase::implIsValid() const { - return mxStrg.get() && mxStrg->isStorage() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid(); + return mxStrg.get() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid(); } void StorageObjectBase::implDump() { - try + bool bIsStrg = mxStrg->isStorage(); + bool bIsRoot = mxStrg->isRootStorage(); + Reference< XInputStream > xBaseStrm; + if( !bIsStrg ) + xBaseStrm = mxStrg->openInputStream( OUString() ); + + OUString aSysOutPath = maSysPath; + if( bIsRoot ) try { + aSysOutPath += OOX_DUMP_DUMPEXT; Reference< XSimpleFileAccess > xFileAccess( getFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); - xFileAccess->kill( maSysPath + OOX_DUMP_DUMPEXT ); + xFileAccess->kill( aSysOutPath ); } catch( Exception& ) { } - extractStorage( mxStrg, OUString(), maSysPath ); + + if( bIsStrg ) + { + extractStorage( mxStrg, OUString(), aSysOutPath ); + } + else if( xBaseStrm.is() ) + { + BinaryInputStreamRef xInStrm( new BinaryXInputStream( xBaseStrm, false ) ); + xInStrm->seekToStart(); + implDumpBaseStream( xInStrm, aSysOutPath ); + } } void StorageObjectBase::implDumpStream( const BinaryInputStreamRef&, const OUString&, const OUString&, const OUString& ) @@ -2245,6 +2265,10 @@ void StorageObjectBase::implDumpStorage( const StorageRef& rxStrg, const OUStrin extractStorage( rxStrg, rStrgPath, rSysPath ); } +void StorageObjectBase::implDumpBaseStream( const BinaryInputStreamRef&, const OUString& ) +{ +} + void StorageObjectBase::addPreferredStream( const String& rStrmName ) { if( rStrmName.has() ) @@ -2280,7 +2304,7 @@ void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrg { BinaryXOutputStream aOutStrm( InputOutputHelper::openOutputStream( getFactory(), rSysFileName ), true ); if( !aOutStrm.isEof() ) - aOutStrm.copyStream( aInStrm ); + aInStrm.copyToStream( aOutStrm ); } BinaryXInputStreamRef xDumpStrm( new BinaryXInputStream( InputOutputHelper::openInputStream( getFactory(), rSysFileName ), true ) ); if( !xDumpStrm->isEof() ) @@ -2289,17 +2313,15 @@ void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrg void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { - OUString aSysOutPath = rSysPath + OOX_DUMP_DUMPEXT; - // create directory in file system - ::osl::FileBase::RC eRes = ::osl::Directory::create( aSysOutPath ); + ::osl::FileBase::RC eRes = ::osl::Directory::create( rSysPath ); if( (eRes != ::osl::FileBase::E_None) && (eRes != ::osl::FileBase::E_EXIST) ) return; // process preferred storages and streams in root storage first if( rStrgPath.getLength() == 0 ) for( PreferredItemVector::iterator aIt = maPreferred.begin(), aEnd = maPreferred.end(); aIt != aEnd; ++aIt ) - extractItem( rxStrg, rStrgPath, aIt->maName, aSysOutPath, aIt->mbStorage, !aIt->mbStorage ); + extractItem( rxStrg, rStrgPath, aIt->maName, rSysPath, aIt->mbStorage, !aIt->mbStorage ); // process children of the storage for( StorageIterator aIt( rxStrg ); aIt.isValid(); ++aIt ) @@ -2311,13 +2333,13 @@ void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString for( PreferredItemVector::iterator aIIt = maPreferred.begin(), aIEnd = maPreferred.end(); !bFound && (aIIt != aIEnd); ++aIIt ) bFound = aIIt->maName == aItemName; if( !bFound ) - extractItem( rxStrg, rStrgPath, aItemName, aSysOutPath, aIt.isStorage(), aIt.isStream() ); + extractItem( rxStrg, rStrgPath, aItemName, rSysPath, aIt.isStorage(), aIt.isStream() ); } } -void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysOutPath, bool bIsStrg, bool bIsStrm ) +void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysPath, bool bIsStrg, bool bIsStrm ) { - OUString aSysFileName = getSysFileName( rItemName, rSysOutPath ); + OUString aSysFileName = getSysFileName( rItemName, rSysPath ); if( bIsStrg ) { OUStringBuffer aStrgPath( rStrgPath ); @@ -2362,18 +2384,18 @@ bool OutputObjectBase::implIsValid() const void OutputObjectBase::writeEmptyItem( const String& rName ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); } void OutputObjectBase::writeInfoItem( const String& rName, const String& rData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeString( rData ); } void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeChar( OOX_DUMP_STRQUOTE ); mxOut->writeChar( cData ); mxOut->writeChar( OOX_DUMP_STRQUOTE ); @@ -2381,7 +2403,7 @@ void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData ) void OutputObjectBase::writeStringItem( const String& rName, const OUString& rData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeAscii( "(len=" ); mxOut->writeDec( rData.getLength() ); mxOut->writeAscii( ")," ); @@ -2394,19 +2416,19 @@ void OutputObjectBase::writeStringItem( const String& rName, const OUString& rDa void OutputObjectBase::writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeArray( pnData, nSize, cSep ); } void OutputObjectBase::writeBoolItem( const String& rName, bool bData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeBool( bData ); } double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeHexItem( rName, static_cast< sal_uInt32 >( nRk ), "RK-FLAGS" ); double fValue = ::oox::xls::BiffHelper::calcDoubleFromRk( nRk ); writeDecItem( "decoded", fValue ); @@ -2415,20 +2437,20 @@ double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk ) void OutputObjectBase::writeColorABGRItem( const String& rName, sal_Int32 nColor ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); writeHexItem( rName, nColor ); mxOut->writeColorABGR( nColor ); } void OutputObjectBase::writeDateTimeItem( const String& rName, const DateTime& rDateTime ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDateTime( rDateTime ); } void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeString( rGuid ); aItem.cont(); mxOut->writeString( cfg().getStringOption( rGuid, OUString() ) ); @@ -2436,85 +2458,81 @@ void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid void OutputObjectBase::writeColIndexItem( const String& rName, sal_Int32 nCol ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nCol ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeDec( nCol ); aItem.cont(); - rOut.writeColIndex( nCol ); + mxOut->writeColIndex( nCol ); } void OutputObjectBase::writeRowIndexItem( const String& rName, sal_Int32 nRow ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nRow ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeDec( nRow ); aItem.cont(); - rOut.writeRowIndex( nRow ); + mxOut->writeRowIndex( nRow ); } void OutputObjectBase::writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeColRowRange( nCol1, nCol2 ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeColRowRange( nCol1, nCol2 ); aItem.cont(); - rOut.writeColRange( nCol1, nCol2 ); + mxOut->writeColRange( nCol1, nCol2 ); } void OutputObjectBase::writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeColRowRange( nRow1, nRow2 ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeColRowRange( nRow1, nRow2 ); aItem.cont(); - rOut.writeRowRange( nRow1, nRow2 ); + mxOut->writeRowRange( nRow1, nRow2 ); } void OutputObjectBase::writeAddressItem( const String& rName, const Address& rPos ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendAddress( out().getLine(), rPos ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendAddress( mxOut->getLine(), rPos ); } void OutputObjectBase::writeRangeItem( const String& rName, const Range& rRange ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendRange( out().getLine(), rRange ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendRange( mxOut->getLine(), rRange ); } void OutputObjectBase::writeRangeListItem( const String& rName, const RangeList& rRanges ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeDecItem( "count", static_cast< sal_uInt16 >( rRanges.size() ) ); - ItemGuard aItem( out(), "ranges" ); - StringHelper::appendRangeList( out().getLine(), rRanges ); + ItemGuard aItem( mxOut, "ranges" ); + StringHelper::appendRangeList( mxOut->getLine(), rRanges ); } void OutputObjectBase::writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendAddress( mxOut->getLine(), rPos, bNameMode ); } void OutputObjectBase::writeTokenAddress3dItem( const String& rName, const OUString& rRef, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - out().writeString( rRef ); - StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeString( rRef ); + StringHelper::appendAddress( mxOut->getLine(), rPos, bNameMode ); } void OutputObjectBase::writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendRange( out().getLine(), rRange, bNameMode ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendRange( mxOut->getLine(), rRange, bNameMode ); } void OutputObjectBase::writeTokenRange3dItem( const String& rName, const OUString& rRef, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - out().writeString( rRef ); - StringHelper::appendRange( out().getLine(), rRange, bNameMode ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeString( rRef ); + StringHelper::appendRange( mxOut->getLine(), rRange, bNameMode ); } // ============================================================================ @@ -2565,8 +2583,7 @@ void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize ) void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bStream ) { - Output& rOut = out(); - TableGuard aTabGuard( rOut, + TableGuard aTabGuard( mxOut, bShowOffset ? 12 : 0, 3 * OOX_DUMP_BYTESPERLINE / 2 + 1, 3 * OOX_DUMP_BYTESPERLINE / 2 + 1, @@ -2583,8 +2600,8 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS while( bLoop && (nPos < nDumpEnd) ) { - rOut.writeHex( static_cast< sal_uInt32 >( nPos ) ); - rOut.tab(); + mxOut->writeHex( static_cast< sal_uInt32 >( nPos ) ); + mxOut->tab(); sal_uInt8 pnLineData[ OOX_DUMP_BYTESPERLINE ]; sal_Int32 nLineSize = bSeekable ? ::std::min( static_cast< sal_Int32 >( nDumpEnd - mxStrm->tell() ), OOX_DUMP_BYTESPERLINE ) : OOX_DUMP_BYTESPERLINE; @@ -2598,18 +2615,18 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS const sal_uInt8* pnEnd = 0; for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte ) { - if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab(); - rOut.writeHex( *pnByte, false ); - rOut.writeChar( ' ' ); + if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) mxOut->tab(); + mxOut->writeHex( *pnByte, false ); + mxOut->writeChar( ' ' ); } aTabGuard.tab( 3 ); for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte ) { - if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab(); - rOut.writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) ); + if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) mxOut->tab(); + mxOut->writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) ); } - rOut.newLine(); + mxOut->newLine(); } } @@ -2621,11 +2638,11 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS void InputObjectBase::dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset ) { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeDecItem( "size", nBytes ); } - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpRawBinary( nBytes, bShowOffset ); } @@ -2642,7 +2659,7 @@ void InputObjectBase::dumpRemaining( sal_Int64 nBytes ) void InputObjectBase::dumpRemainingTo( sal_Int64 nPos ) { - if( mxStrm->isEof() ) + if( mxStrm->isEof() || (mxStrm->tell() > nPos) ) writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); else dumpRemaining( nPos - mxStrm->tell() ); @@ -2760,7 +2777,7 @@ DateTime InputObjectBase::dumpFileTime( const String& rName ) { DateTime aDateTime; - ItemGuard aItem( out(), rName( "file-time" ) ); + ItemGuard aItem( mxOut, rName( "file-time" ) ); sal_Int64 nFileTime = dumpDec< sal_Int64 >( EMPTY_STRING ); // file time is in 10^-7 seconds (100 nanoseconds), convert to 1/100 seconds nFileTime /= 100000; @@ -2871,9 +2888,9 @@ BinaryStreamObject::BinaryStreamObject( const OutputObjectBase& rParent, const B void BinaryStreamObject::dumpBinaryStream( bool bShowOffset ) { - in().seek( 0 ); - dumpRawBinary( in().getLength(), bShowOffset, true ); - out().emptyLine(); + mxStrm->seekToStart(); + dumpRawBinary( mxStrm->getLength(), bShowOffset, true ); + mxOut->emptyLine(); } void BinaryStreamObject::implDump() @@ -2883,110 +2900,47 @@ void BinaryStreamObject::implDump() // ============================================================================ -namespace { - -bool lclIsEof( BinaryInputStream& rStrm ) -{ - return rStrm.isEof() || (rStrm.isSeekable() && (rStrm.tell() >= rStrm.getLength())); -} - -template< typename BufferType, typename CharType > -CharType lclAppendChar( BufferType& orBuffer, CharType cChar ) -{ - if( (cChar == 0x0A) || (cChar == 0x0D) ) - return cChar; - orBuffer.append( cChar ); - return 0; -} - -template< typename BufferType, typename CharType, typename StreamDataType > -bool lclReadLine( BufferType& orBuffer, sal_Unicode& orcNextLineChar, BinaryInputStream& rStrm ) -{ - CharType cLineEndChar = (orcNextLineChar == 0) ? 0 : lclAppendChar( orBuffer, static_cast< CharType >( orcNextLineChar ) ); - orcNextLineChar = 0; - - // read chars until EOF or line end character (LF or CR) - bool bIsEof = lclIsEof( rStrm ); - while( !bIsEof && (cLineEndChar == 0) ) - { - CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); - bIsEof = rStrm.isEof(); - cLineEndChar = bIsEof ? 0 : lclAppendChar( orBuffer, cChar ); - } - - // try to skip LF following CR, or CR following LF - if( !lclIsEof( rStrm ) && (cLineEndChar != 0) ) - { - CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); - bool bLineEnd = ((cChar == 0x0A) || (cChar == 0x0D)) && (cChar != cLineEndChar); - if( !rStrm.isEof() && !bLineEnd ) - orcNextLineChar = static_cast< sal_Unicode >( cChar ); - } - - return (cLineEndChar != 0) || (orBuffer.getLength() > 0); -} - -} // namespace - -// ---------------------------------------------------------------------------- - TextStreamObject::TextStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) : - meTextEnc( eTextEnc ) + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) { InputObjectBase::construct( rParent, rxStrm, rSysFileName ); + if( rxStrm.get() ) + mxTextStrm.reset( new TextInputStream( *rxStrm, eTextEnc ) ); } TextStreamObject::TextStreamObject( const OutputObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) : - meTextEnc( eTextEnc ) + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) { InputObjectBase::construct( rParent, rxStrm ); + if( rxStrm.get() ) + mxTextStrm.reset( new TextInputStream( *rxStrm, eTextEnc ) ); +} + +bool TextStreamObject::implIsValid() const +{ + return InputObjectBase::implIsValid() && mxTextStrm.get(); } void TextStreamObject::implDump() { OUString aLine; - sal_Unicode cNextLineChar = 0; sal_uInt32 nLine = 0; - while( readLine( aLine, cNextLineChar ) ) - implDumpLine( aLine, ++nLine ); - out().emptyLine(); + while( !mxTextStrm->isEof() ) + { + aLine = mxTextStrm->readLine(); + if( !mxTextStrm->isEof() ) + implDumpLine( aLine, ++nLine ); + } + mxOut->emptyLine(); } void TextStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 nLine ) { - Output& rOut = out(); - TableGuard aTabGuard( rOut, 8 ); - rOut.writeDec( nLine, 6 ); - rOut.tab(); - rOut.writeString( rLine ); - rOut.newLine(); -} - -bool TextStreamObject::readCharLine( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - OStringBuffer aBuffer; - bool bHasData = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, orcNextLineChar, in() ); - if( bHasData ) - orLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc ); - return bHasData; -} - -bool TextStreamObject::readUcs2Line( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - OUStringBuffer aBuffer; - bool bHasData = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, orcNextLineChar, in() ); - if( bHasData ) - orLine = aBuffer.makeStringAndClear(); - return bHasData; -} - -bool TextStreamObject::readLine( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - return (meTextEnc == RTL_TEXTENCODING_UCS2) ? - readUcs2Line( orLine, orcNextLineChar ) : - readCharLine( orLine, orcNextLineChar ); + TableGuard aTabGuard( mxOut, 8 ); + mxOut->writeDec( nLine, 6 ); + mxOut->tab(); + mxOut->writeString( rLine ); + mxOut->newLine(); } // ============================================================================ @@ -3002,9 +2956,9 @@ void XmlStreamObject::implDump() TextStreamObject::implDump(); if( maIncompleteLine.getLength() > 0 ) { - out().resetIndent(); - out().writeString( maIncompleteLine ); - out().emptyLine(); + mxOut->resetIndent(); + mxOut->writeString( maIncompleteLine ); + mxOut->emptyLine(); writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); } } @@ -3018,10 +2972,9 @@ void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 ) aLine.append( rLine ); maIncompleteLine = OUString(); - Output& rOut = out(); if( aLine.getLength() == 0 ) { - rOut.newLine(); + mxOut->newLine(); return; } @@ -3092,10 +3045,10 @@ void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 ) // flush output line if( maIncompleteLine.getLength() == 0 ) { - if( !bIsStartElement && bIsEndElement ) rOut.decIndent(); - rOut.writeString( aOutLine.makeStringAndClear() ); - rOut.newLine(); - if( bIsStartElement && !bIsEndElement ) rOut.incIndent(); + if( !bIsStartElement && bIsEndElement ) mxOut->decIndent(); + mxOut->writeString( aOutLine.makeStringAndClear() ); + mxOut->newLine(); + if( bIsStartElement && !bIsEndElement ) mxOut->incIndent(); } } } @@ -3131,11 +3084,11 @@ void RecordObjectBase::implDump() while( implStartRecord( *mxBaseStrm, mnRecPos, mnRecId, mnRecSize ) ) { // record header - out().emptyLine(); + mxOut->emptyLine(); writeHeader(); implWriteExtHeader(); - IndentGuard aIndGuard( out() ); - sal_Int64 nRecPos = in().tell(); + IndentGuard aIndGuard( mxOut ); + sal_Int64 nRecPos = mxStrm->tell(); // record body if( !mbBinaryOnly && cfg().hasName( xRecNames, mnRecId ) ) @@ -3148,7 +3101,7 @@ void RecordObjectBase::implDump() } // remaining undumped data - if( !in().isEof() && (in().tell() == nRecPos) ) + if( !mxStrm->isEof() && (mxStrm->tell() == nRecPos) ) dumpRawBinary( mnRecSize, false ); else dumpRemainingTo( nRecPos + mnRecSize ); @@ -3176,13 +3129,13 @@ void RecordObjectBase::constructRecObjBase( const BinaryInputStreamRef& rxBaseSt void RecordObjectBase::writeHeader() { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "REC" ); if( mbShowRecPos && mxBaseStrm->isSeekable() ) writeShortHexItem( "pos", mnRecPos, "CONV-DEC" ); writeShortHexItem( "size", mnRecSize, "CONV-DEC" ); - ItemGuard aItem( out(), "id" ); - out().writeShortHex( mnRecId ); + ItemGuard aItem( mxOut, "id" ); + mxOut->writeShortHex( mnRecId ); addNameToItem( mnRecId, "CONV-DEC" ); addNameToItem( mnRecId, maRecNames ); } @@ -3224,7 +3177,7 @@ bool SequenceRecordObjectBase::implStartRecord( BinaryInputStream& rBaseStrm, sa sal_Int32 nRecSize = static_cast< sal_Int32 >( ornRecSize ); mxRecData->realloc( nRecSize ); bValid = (nRecSize == 0) || (rBaseStrm.readData( *mxRecData, nRecSize ) == nRecSize); - in().seekToStart(); + mxStrm->seekToStart(); } return bValid; } diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index b7750d4113b8..9c3e00fdcf30 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -33,8 +33,8 @@ #include #include "oox/helper/binaryoutputstream.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/ole/vbainputstream.hxx" -#include "oox/xls/biffhelper.hxx" #if OOX_INCLUDE_DUMPER @@ -52,9 +52,52 @@ namespace dump { // ============================================================================ // ============================================================================ -StdFontObject::StdFontObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +OUString OleInputObjectBase::dumpAnsiString32( const String& rName ) { + return dumpCharArray( rName, mxStrm->readInt32(), RTL_TEXTENCODING_MS_1252 ); +} + +OUString OleInputObjectBase::dumpUniString32( const String& rName ) +{ + return dumpUnicodeArray( rName, mxStrm->readInt32() ); +} + +sal_Int32 OleInputObjectBase::dumpStdClipboardFormat( const String& rName ) +{ + return dumpDec< sal_Int32 >( rName( "clipboard-format" ), "OLE-STD-CLIPBOARD-FORMAT" ); +} + +OUString OleInputObjectBase::dumpAnsiString32OrStdClip( const String& rName ) +{ + sal_Int32 nLen = mxStrm->readInt32(); + return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpCharArray( rName, nLen, RTL_TEXTENCODING_MS_1252 ); +} + +OUString OleInputObjectBase::dumpUniString32OrStdClip( const String& rName ) +{ + sal_Int32 nLen = mxStrm->readInt32(); + return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpUnicodeArray( rName, nLen ); +} + +void OleInputObjectBase::writeOleColorItem( const String& rName, sal_uInt32 nColor ) +{ + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( rName, nColor, "OLE-COLOR" ); +} + +sal_uInt32 OleInputObjectBase::dumpOleColor( const String& rName ) +{ + sal_uInt32 nOleColor = mxStrm->readuInt32(); + writeOleColorItem( rName, nOleColor ); + return nOleColor; +} + +// ============================================================================ +// ============================================================================ + +StdFontObject::StdFontObject( const InputObjectBase& rParent ) +{ + construct( rParent ); } void StdFontObject::implDump() @@ -64,19 +107,19 @@ void StdFontObject::implDump() dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" ); dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" ); dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" ); - dumpCharArray( "name", in().readuInt8(), RTL_TEXTENCODING_ASCII_US ); + dumpCharArray( "name", mxStrm->readuInt8(), RTL_TEXTENCODING_ASCII_US ); } // ============================================================================ -StdPicObject::StdPicObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +StdPicObject::StdPicObject( const InputObjectBase& rParent ) { + construct( rParent ); } void StdPicObject::implDump() { - dumpHex< sal_uInt32 >( "identifier" ); + dumpHex< sal_uInt32 >( "identifier", "STDPIC-ID" ); sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" ); dumpBinary( "image-data", nSize ); } @@ -96,9 +139,9 @@ const sal_uInt32 STDHLINK_ASSTRING = 0x00000100; /// Hyperlink as sim } // namespace -StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent ) { + construct( rParent ); } void StdHlinkObject::implDump() @@ -126,15 +169,14 @@ void StdHlinkObject::implDump() OUString StdHlinkObject::dumpHyperlinkString( const String& rName, bool bUnicode ) { - sal_Int32 nLen = in().readInt32(); - return bUnicode ? dumpUnicodeArray( rName, nLen ) : dumpCharArray( rName, nLen, osl_getThreadTextEncoding() ); + return bUnicode ? dumpUniString32( rName ) : dumpAnsiString32( rName ); } bool StdHlinkObject::dumpGuidAndMoniker() { bool bValidMoniker = true; OUString aGuid = cfg().getStringOption( dumpGuid( "moniker" ), OUString() ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( aGuid.equalsAscii( "URLMoniker" ) ) dumpUrlMoniker(); else if( aGuid.equalsAscii( "FileMoniker" ) ) @@ -153,9 +195,9 @@ bool StdHlinkObject::dumpGuidAndMoniker() void StdHlinkObject::dumpUrlMoniker() { sal_Int32 nBytes = dumpDec< sal_Int32 >( "url-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); dumpNullUnicodeArray( "url" ); - if( in().tell() + 24 == nEndPos ) + if( mxStrm->tell() + 24 == nEndPos ) { dumpGuid( "implementation-id" ); dumpDec< sal_uInt32 >( "version" ); @@ -172,7 +214,7 @@ void StdHlinkObject::dumpFileMoniker() dumpHex< sal_uInt16 >( "version" ); dumpUnused( 20 ); sal_Int32 nBytes = dumpDec< sal_Int32 >( "total-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); if( nBytes > 0 ) { sal_Int32 nFileBytes = dumpDec< sal_Int32 >( "uni-filename-bytes" ); @@ -185,18 +227,18 @@ void StdHlinkObject::dumpFileMoniker() void StdHlinkObject::dumpItemMoniker() { sal_Int32 nBytes = dumpDec< sal_Int32 >( "delimiter-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); - dumpNullCharArray( "ansi-delimiter", osl_getThreadTextEncoding() ); - if( in().tell() < nEndPos ) - dumpUnicodeArray( "unicode-delimiter", (nEndPos - in().tell()) / 2 ); - in().seek( nEndPos ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-delimiter", RTL_TEXTENCODING_MS_1252 ); + if( mxStrm->tell() < nEndPos ) + dumpUnicodeArray( "unicode-delimiter", (nEndPos - mxStrm->tell()) / 2 ); + mxStrm->seek( nEndPos ); nBytes = dumpDec< sal_Int32 >( "item-bytes" ); - nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); - dumpNullCharArray( "ansi-item", osl_getThreadTextEncoding() ); - if( in().tell() < nEndPos ) - dumpUnicodeArray( "unicode-item", (nEndPos - in().tell()) / 2 ); - in().seek( nEndPos ); + nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-item", RTL_TEXTENCODING_MS_1252 ); + if( mxStrm->tell() < nEndPos ) + dumpUnicodeArray( "unicode-item", (nEndPos - mxStrm->tell()) / 2 ); + mxStrm->seek( nEndPos ); } void StdHlinkObject::dumpAntiMoniker() @@ -207,13 +249,54 @@ void StdHlinkObject::dumpAntiMoniker() void StdHlinkObject::dumpCompositeMoniker() { sal_Int32 nCount = dumpDec< sal_Int32 >( "moniker-count" ); - for( sal_Int32 nIndex = 0; !in().isEof() && (nIndex < nCount); ++nIndex ) + for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nCount); ++nIndex ) dumpGuidAndMoniker(); } // ============================================================================ // ============================================================================ +OleStreamObject::OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + construct( rParent, rxStrm, rSysFileName ); +} + +// ============================================================================ + +OleCompObjObject::OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : + OleStreamObject( rParent, rxStrm, rSysFileName ) +{ +} + +void OleCompObjObject::implDump() +{ + dumpUnused( 4 ); + dumpDec< sal_uInt32 >( "version" ); + dumpUnused( 20 ); + dumpAnsiString32( "ansi-display-name" ); + dumpAnsiString32OrStdClip( "ansi-clipboard-format" ); + if( mxStrm->getRemaining() >= 4 ) + { + sal_Int32 nLen = mxStrm->readInt32(); + if( (0 <= nLen) && (nLen <= 40) ) + { + dumpCharArray( "ansi-unused", nLen, RTL_TEXTENCODING_MS_1252 ); + if( (mxStrm->getRemaining() >= 4) && (dumpHex< sal_Int32 >( "unicode-marker" ) == 0x71B239F4) ) + { + dumpUniString32( "unicode-display-name" ); + dumpUniString32OrStdClip( "unicode-clipboard-format" ); + dumpUniString32( "unicode-unused" ); + } + } + else + writeDecItem( "length", nLen ); + } + dumpRemainingStream(); +} + +// ============================================================================ +// ============================================================================ + namespace { const sal_Int32 OLEPROP_ID_DICTIONARY = 0; @@ -244,29 +327,26 @@ const sal_Int32 OLEPROP_TYPE_CLIPFMT = 71; const sal_uInt16 CODEPAGE_UNICODE = 1200; -const sal_uInt32 OCX_STRING_COMPRESSED = 0x80000000; +const sal_uInt32 AX_STRING_COMPRESSED = 0x80000000; } // namespace // ============================================================================ -OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : - BinaryStreamObject( rParent, rxStrm, rSysFileName ) +OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { + construct( rParent, rxStrm, rSysFileName ); } void OlePropertyStreamObject::implDump() { - BinaryInputStream& rStrm = in(); - Output& rOut = out(); - OUStringVector aGuidVec; ::std::vector< sal_uInt32 > aStartPosVec; // dump header writeEmptyItem( "HEADER" ); { - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" ); dumpDec< sal_uInt16 >( "version" ); dumpDec< sal_uInt16 >( "os-minor" ); @@ -276,29 +356,26 @@ void OlePropertyStreamObject::implDump() // dump table of section positions { - TableGuard aTabGuard( rOut, 15, 60 ); - rOut.resetItemIndex(); - for( sal_Int32 nSectIdx = 0; !rStrm.isEof() && (nSectIdx < nSectCount); ++nSectIdx ) + TableGuard aTabGuard( mxOut, 15, 60 ); + mxOut->resetItemIndex(); + for( sal_Int32 nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < nSectCount); ++nSectIdx ) { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#section" ); aGuidVec.push_back( dumpGuid( "guid" ) ); aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) ); } } } - rOut.emptyLine(); + mxOut->emptyLine(); // dump sections - for( size_t nSectIdx = 0; !rStrm.isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx ) + for( size_t nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx ) dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] ); } void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos ) { - BinaryInputStream& rStrm = in(); - Output& rOut = out(); - // property ID names mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" ); OUString aGuidName = cfg().getStringOption( rGuid, OUString() ); @@ -317,7 +394,7 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt writeSectionHeader( rGuid, nStartPos ); // seek to section - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { // dump section header @@ -326,11 +403,11 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt // dump table of property positions { - TableGuard aTabGuard( rOut, 15, 25 ); - rOut.resetItemIndex(); - for( sal_Int32 nPropIdx = 0; !rStrm.isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + TableGuard aTabGuard( mxOut, 15, 25 ); + mxOut->resetItemIndex(); + for( sal_Int32 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx ) { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#property" ); sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds ); sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ); @@ -338,10 +415,10 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt } } } - rOut.emptyLine(); + mxOut->emptyLine(); // code page property - meTextEnc = osl_getThreadTextEncoding(); + meTextEnc = RTL_TEXTENCODING_MS_1252; mbIsUnicode = false; PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE ); if( aCodePageIt != aPropMap.end() ) @@ -369,16 +446,16 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ) { writePropertyHeader( nPropId, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) dumpPropertyContents( nPropId ); - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) { writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { sal_Int32 nType = dumpPropertyType(); @@ -393,27 +470,27 @@ void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) else dumpPropertyContents( OLEPROP_ID_CODEPAGE ); } - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos ) { writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); - for( sal_Int32 nIdx = 0; !in().isEof() && (nIdx < nCount); ++nIdx ) + for( sal_Int32 nIdx = 0; !mxStrm->isEof() && (nIdx < nCount); ++nIdx ) { - MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 10, 20 ); + MultiItemsGuard aMultiGuard( mxOut ); + TableGuard aTabGuard( mxOut, 10, 20 ); sal_Int32 nId = dumpDec< sal_Int32 >( "id" ); OUString aName = dumpString8( "name" ); if( mxPropIds.get() ) mxPropIds->setName( nId, aName ); } } - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) @@ -423,11 +500,11 @@ void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) { sal_Int32 nBaseType = nType & 0x0FFF; sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" ); - for( sal_Int32 nElemIdx = 0; !in().isEof() && (nElemIdx < nElemCount); ++nElemIdx ) + for( sal_Int32 nElemIdx = 0; !mxStrm->isEof() && (nElemIdx < nElemCount); ++nElemIdx ) { - out().resetItemIndex( nElemIdx ); + mxOut->resetItemIndex( nElemIdx ); writeEmptyItem( "#element" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpPropertyValue( nPropId, nBaseType ); } } @@ -491,7 +568,7 @@ OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 if( nNewLen > 0 ) { ::std::vector< sal_Char > aBuffer( nNewLen + 1 ); - in().readMemory( &aBuffer.front(), nNewLen ); + mxStrm->readMemory( &aBuffer.front(), nNewLen ); aBuffer[ nNewLen ] = 0; aData = OStringToOUString( OString( &aBuffer.front() ), meTextEnc ); } @@ -511,7 +588,7 @@ OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int3 ::std::vector< sal_Unicode > aBuffer; aBuffer.reserve( nNewLen + 1 ); for( size_t nIdx = 0; nIdx < nNewLen; ++nIdx ) - aBuffer.push_back( static_cast< sal_Unicode >( in().readuInt16() ) ); + aBuffer.push_back( static_cast< sal_Unicode >( mxStrm->readuInt16() ) ); aBuffer.push_back( 0 ); OUString aData( &aBuffer.front() ); writeStringItem( rName, aData ); @@ -521,15 +598,15 @@ OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int3 bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos ) { - in().seek( nStartPos ); - if( in().isEof() ) + mxStrm->seek( nStartPos ); + if( mxStrm->isEof() ) writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); - return !in().isEof(); + return !mxStrm->isEof(); } void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "SECTION" ); writeHexItem( "pos", nStartPos, "CONV-DEC" ); writeGuidItem( "guid", rGuid ); @@ -537,7 +614,7 @@ void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uIn void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "PROPERTY" ); writeHexItem( "pos", nStartPos, "CONV-DEC" ); writeDecItem( "id", nPropId, mxPropIds ); @@ -562,7 +639,9 @@ void OleStorageObject::construct( const ObjectBase& rParent ) void OleStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) + if( rStrmName.equalsAscii( "\001CompObj" ) ) + OleCompObjObject( *this, rxStrm, rSysFileName ).dump(); + else if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump(); else BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); @@ -571,40 +650,394 @@ void OleStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const // ============================================================================ // ============================================================================ -void OcxPropertyObjectBase::construct( const ObjectBase& rParent, +ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent, + sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) : + mnDataId5( nDataId5 ), + mnDataId6( nDataId6 ), + mnVersion( nVersion ), + mbCommonPart( bCommonPart ), + mbComplexPart( bComplexPart ) +{ + construct( rParent ); +} + +void ComCtlObjectBase::implDump() +{ + sal_uInt32 nCommonSize = 0; + dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex()); +} + +void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ +} + +void ComCtlObjectBase::implDumpCommonTrailing() +{ +} + +bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor ) +{ + // no idea if all this is correct... + sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" ); + ItemGuard aItem( mxOut, "version" ); + sal_uInt16 nMinor, nMajor; + *mxStrm >> nMinor >> nMajor; + mxOut->writeDec( nMajor ); + mxOut->writeChar( '.' ); + mxOut->writeDec( nMinor ); + return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor)); +} + +bool ComCtlObjectBase::dumpComCtlSize() +{ + if( dumpComCtlHeader( 0x12344321, 0, 8 ) ) + { + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" ); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize ) +{ + if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) ) + { + IndentGuard aIndGuard( mxOut ); + if( mbCommonPart ) + ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" ); + implDumpProperties(); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize ) +{ + sal_Int64 nEndPos = mxStrm->tell() + nPartSize; + if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) ) + { + IndentGuard aIndGuard( mxOut ); + dumpUnknown( 4 ); + dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" ); + implDumpCommonExtra( nEndPos ); + dumpRemainingTo( nEndPos ); + implDumpCommonTrailing(); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlComplex() +{ + if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) ) + { + IndentGuard aIndGuard( mxOut ); + sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" ); + if( !mxStrm->isEof() && (nFlags & 0x01) ) + { + writeEmptyItem( "font" ); + IndentGuard aIndGuard2( mxOut ); + OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); + if( aClassName.equalsAscii( "StdFont" ) ) + StdFontObject( *this ).dump(); + } + if( !mxStrm->isEof() && (nFlags & 0x02) ) + { + writeEmptyItem( "mouse-icon" ); + IndentGuard aIndGuard2( mxOut ); + OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); + if( aClassName.equalsAscii( "StdPic" ) ) + StdPicObject( *this ).dump(); + } + return !mxStrm->isEof(); + } + return false; +} + +// ============================================================================ + +ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true ) +{ +} + +void ComCtlScrollBarObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" ); + dumpDec< sal_Int32 >( "large-change" ); + dumpDec< sal_Int32 >( "small-change" ); + dumpDec< sal_Int32 >( "min" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int32 >( "value" ); +} + +// ============================================================================ + +ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true ) +{ +} + +void ComCtlProgressBarObject::implDumpProperties() +{ + dumpDec< float >( "min" ); + dumpDec< float >( "max" ); + if( mnVersion == 6 ) + { + dumpBool< sal_uInt16 >( "vertical" ); + dumpBool< sal_uInt16 >( "smooth-scroll" ); + } +} + +// ============================================================================ + +ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true ) +{ +} + +void ComCtlSliderObject::implDumpProperties() +{ + dumpBool< sal_Int32 >( "vertical" ); + dumpDec< sal_Int32 >( "large-change" ); + dumpDec< sal_Int32 >( "small-change" ); + dumpDec< sal_Int32 >( "min" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" ); + dumpUnused( 2 ); + dumpDec< sal_Int32 >( "select-start" ); + dumpDec< sal_Int32 >( "select-length" ); + dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" ); + dumpDec< sal_Int32 >( "tick-frequency" ); + dumpDec< sal_Int32 >( "value" ); + if( mnVersion == 6 ) + dumpBool< sal_Int32 >( "tooltip-below" ); +} + +// ============================================================================ + +ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false ) +{ +} + +void ComCtlUpDownObject::implDumpProperties() +{ + dumpUnknown( 16 ); // buddy-property, somehow + dumpDec< sal_Int32 >( "buddy-control" ); + dumpUnknown( 8 ); + dumpDec< sal_Int32 >( "value" ); + dumpUnknown( 4 ); + dumpDec< sal_Int32 >( "increment" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int32 >( "min" ); + dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" ); + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" ); + dumpUnknown( 4 ); +} + +// ============================================================================ + +ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false ) +{ +} + +void ComCtlImageListObject::implDumpProperties() +{ + dumpDec< sal_uInt16 >( "image-width" ); + dumpDec< sal_uInt16 >( "image-height" ); + dumpOleColor( "mask-color" ); + dumpBool< sal_Int16 >( "use-mask-color" ); + dumpUnknown( 2 ); +} + +void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 4 ); + dumpOleColor( "back-color" ); + dumpUnknown( 4 ); + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" ); + if( nFlags & 0x01 ) dumpUniString32( "caption" ); + if( nFlags & 0x02 ) dumpUniString32( "key" ); + } +} + +void ComCtlImageListObject::implDumpCommonTrailing() +{ + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "index" ); + StdPicObject( *this ).dump(); + } +} + +// ============================================================================ + +ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true ) +{ +} + +void ComCtlTabStripObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" ); + dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" ); + dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" ); + if( mnVersion == 6 ) + { + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" ); + dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" ); + dumpUnknown( 2 ); + dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" ); + } +} + +void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 12 ); + dumpUniString32( "image-list" ); + sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex ) + { + writeEmptyItem( "#tab" ); + IndentGuard aIndGuard( mxOut ); + dumpUnknown( 4 ); + sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" ); + if( nTabFlags & 0x01 ) dumpUniString32( "caption" ); + if( nTabFlags & 0x02 ) dumpUniString32( "key" ); + if( nTabFlags & 0x04 ) dumpUniString32( "tag" ); + if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" ); + dumpDec< sal_uInt16 >( "image-id" ); + } +} + +// ============================================================================ + +ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ), + mnStringFlags( 0 ) +{ +} + +void ComCtlTreeViewObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" ); + dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" ); + if( mnVersion == 6 ) + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" ); + mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" ); +} + +void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 nEndPos ) +{ + dumpOleColor( "text-color" ); + dumpOleColor( "back-color" ); + dumpUnknown( 4 ); + if( mnStringFlags & 0x02 ) + dumpUniString32( "image-list" ); + dumpUniString32( "path-separator" ); +} + +// ============================================================================ + +ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true ) +{ +} + +void ComCtlStatusBarObject::implDumpProperties() +{ + dumpBool< sal_Int32 >( "style-simple-text" ); + dumpBool< sal_Int16 >( "show-tips" ); + dumpUnknown( 2 ); +} + +void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 12 ); + dumpUniString32( "simple-text" ); + sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex ) + { + writeEmptyItem( "#panel" ); + IndentGuard aIndGuard( mxOut ); + dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" ); + dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" ); + sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" ); + if( nTextFlags & 0x01 ) dumpUniString32( "text" ); + if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" ); + if( nTextFlags & 0x04 ) dumpUniString32( "key" ); + if( nTextFlags & 0x08 ) dumpUniString32( "tag" ); + if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" ); + } +} + +void ComCtlStatusBarObject::implDumpCommonTrailing() +{ + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "panel-index" ); + StdPicObject( *this ).dump(); + } +} + +// ============================================================================ +// ============================================================================ + +void AxPropertyObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent, rxStrm, rSysFileName ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -void OcxPropertyObjectBase::construct( const OutputObjectBase& rParent, +void AxPropertyObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent, rxStrm ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent, rxStrm ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -void OcxPropertyObjectBase::construct( const InputObjectBase& rParent, +void AxPropertyObjectBase::construct( const InputObjectBase& rParent, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -bool OcxPropertyObjectBase::implIsValid() const +bool AxPropertyObjectBase::implIsValid() const { - return InputObjectBase::implIsValid() && in().isSeekable(); + return OleInputObjectBase::implIsValid() && mxStrm->isSeekable(); } -void OcxPropertyObjectBase::implDump() +void AxPropertyObjectBase::implDump() { mbValid = true; // header setAlignAnchor(); dumpVersion(); sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" ); - mnPropertiesEnd = in().tell() + nSize; + mnPropertiesEnd = mxStrm->tell() + nSize; // property flags maLargeProps.clear(); maStreamProps.clear(); @@ -618,17 +1051,17 @@ void OcxPropertyObjectBase::implDump() implDumpExtended(); } -void OcxPropertyObjectBase::implDumpShortProperties() +void AxPropertyObjectBase::implDumpShortProperties() { } -void OcxPropertyObjectBase::implDumpExtended() +void AxPropertyObjectBase::implDumpExtended() { } -bool OcxPropertyObjectBase::ensureValid( bool bCondition ) +bool AxPropertyObjectBase::ensureValid( bool bCondition ) { - if( mbValid && (!bCondition || in().isEof()) ) + if( mbValid && (!bCondition || mxStrm->isEof()) ) { if( !bCondition ) writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) ); @@ -637,12 +1070,12 @@ bool OcxPropertyObjectBase::ensureValid( bool bCondition ) return mbValid; } -void OcxPropertyObjectBase::setAlignAnchor() +void AxPropertyObjectBase::setAlignAnchor() { - mnPropertiesStart = in().tell(); + mnPropertiesStart = mxStrm->tell(); } -bool OcxPropertyObjectBase::startNextProperty() +bool AxPropertyObjectBase::startNextProperty() { if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1; bool bHasProp = getFlag( mnPropFlags, mnCurrProp ); @@ -650,12 +1083,12 @@ bool OcxPropertyObjectBase::startNextProperty() return ensureValid() && bHasProp; } -OUString OcxPropertyObjectBase::getPropertyName() const +OUString AxPropertyObjectBase::getPropertyName() const { return cfg().getName( mxPropNames, mnCurrProp ); } -sal_uInt32 OcxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList ) +sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList ) { if( startNextProperty() ) { @@ -669,9 +1102,8 @@ sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) { if( startNextProperty() ) { - MultiItemsGuard aMultiGuard( out() ); alignInput< sal_uInt32 >(); - return dumpHex< sal_uInt32 >( getPropertyName(), "OCX-COLOR" ); + return dumpOleColor( getPropertyName() ); } return nDefault; } @@ -686,41 +1118,41 @@ sal_Unicode OcxPropertyObjectBase::dumpUnicodeProperty() return '\0'; } -void OcxPropertyObjectBase::dumpUnknownProperty() +void AxPropertyObjectBase::dumpUnknownProperty() { if( startNextProperty() ) ensureValid( false ); } -void OcxPropertyObjectBase::dumpPosProperty() +void AxPropertyObjectBase::dumpPosProperty() { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 ) ); } -void OcxPropertyObjectBase::dumpSizeProperty() +void AxPropertyObjectBase::dumpSizeProperty() { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 ) ); } -void OcxPropertyObjectBase::dumpGuidProperty( OUString* pValue ) +void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue ) { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue ) ); } -void OcxPropertyObjectBase::dumpStringProperty( OUString* pValue ) +void AxPropertyObjectBase::dumpStringProperty( OUString* pValue ) { if( startNextProperty() ) { alignInput< sal_uInt32 >(); - sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "OCX-STRINGLEN" ); + sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" ); maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue ) ); } } -void OcxPropertyObjectBase::dumpStringArrayProperty() +void AxPropertyObjectBase::dumpStringArrayProperty() { if( startNextProperty() ) { @@ -730,7 +1162,7 @@ void OcxPropertyObjectBase::dumpStringArrayProperty() } } -void OcxPropertyObjectBase::dumpStreamProperty() +void AxPropertyObjectBase::dumpStreamProperty() { if( startNextProperty() ) { @@ -740,26 +1172,26 @@ void OcxPropertyObjectBase::dumpStreamProperty() } } -void OcxPropertyObjectBase::dumpEmbeddedFont() +void AxPropertyObjectBase::dumpEmbeddedFont() { if( ensureValid() ) { writeEmptyItem( "embedded-fontdata" ); - IndentGuard aIndGuard( out() ); - OcxCFontNewObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + AxCFontNewObject( *this ).dump(); } } -void OcxPropertyObjectBase::dumpToPosition( sal_Int64 nPos ) +void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos ) { dumpRemainingTo( nPos ); mbValid = true; ensureValid(); } -void OcxPropertyObjectBase::constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ) +void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags ) { - if( InputObjectBase::implIsValid() ) + if( OleInputObjectBase::implIsValid() ) { mxPropNames = cfg().getNameList( rPropNameList ); mb64BitPropFlags = b64BitPropFlags; @@ -767,19 +1199,19 @@ void OcxPropertyObjectBase::constructOcxPropObj( const String& rPropNameList, bo } } -void OcxPropertyObjectBase::dumpVersion() +void AxPropertyObjectBase::dumpVersion() { - ItemGuard aItem( out(), "version" ); + ItemGuard aItem( mxOut, "version" ); sal_uInt8 nMinor, nMajor; - in() >> nMinor >> nMajor; - out().writeDec( nMajor ); - out().writeChar( '.' ); - out().writeDec( nMinor ); + *mxStrm >> nMinor >> nMajor; + mxOut->writeDec( nMajor ); + mxOut->writeChar( '.' ); + mxOut->writeDec( nMinor ); } -OUString OcxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray ) +OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray ) { - bool bCompressed = getFlag( nSize, OCX_STRING_COMPRESSED ); + bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED ); sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 ); OUString aString = bCompressed ? dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) : @@ -788,30 +1220,30 @@ OUString OcxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSiz return aString; } -void OcxPropertyObjectBase::dumpShortProperties() +void AxPropertyObjectBase::dumpShortProperties() { if( ensureValid() ) { writeEmptyItem( "short-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); implDumpShortProperties(); alignInput< sal_uInt32 >(); } } -void OcxPropertyObjectBase::dumpLargeProperties() +void AxPropertyObjectBase::dumpLargeProperties() { if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() ) { writeEmptyItem( "large-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) { switch( aIt->mePropType ) { case LargeProperty::PROPTYPE_POS: { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( aIt->maItemName ); dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" ); dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" ); @@ -819,7 +1251,7 @@ void OcxPropertyObjectBase::dumpLargeProperties() break; case LargeProperty::PROPTYPE_SIZE: { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( aIt->maItemName ); dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" ); dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" ); @@ -842,13 +1274,13 @@ void OcxPropertyObjectBase::dumpLargeProperties() case LargeProperty::PROPTYPE_STRINGARRAY: { writeEmptyItem( aIt->maItemName ); - IndentGuard aIndGuard2( out() ); - out().resetItemIndex(); - sal_Int64 nEndPos = in().tell() + aIt->mnDataSize; - while( in().tell() < nEndPos ) + IndentGuard aIndGuard2( mxOut ); + mxOut->resetItemIndex(); + sal_Int64 nEndPos = mxStrm->tell() + aIt->mnDataSize; + while( mxStrm->tell() < nEndPos ) { - MultiItemsGuard aMultiGuard( out() ); - sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "OCX-ARRAYSTRINGLEN" ); + MultiItemsGuard aMultiGuard( mxOut ); + sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" ); dumpString( "string", nDataSize, true ); } dumpToPosition( nEndPos ); @@ -862,20 +1294,20 @@ void OcxPropertyObjectBase::dumpLargeProperties() if( ensureValid() && !maStreamProps.empty() ) { writeEmptyItem( "stream-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) { writeEmptyItem( aIt->maItemName ); if( ensureValid( aIt->mnData == 0xFFFF ) ) { - IndentGuard aIndGuard2( out() ); + IndentGuard aIndGuard2( mxOut ); OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); if( aClassName.equalsAscii( "StdFont" ) ) StdFontObject( *this ).dump(); else if( aClassName.equalsAscii( "StdPic" ) ) StdPicObject( *this ).dump(); else if( aClassName.equalsAscii( "CFontNew" ) ) - OcxCFontNewObject( *this ).dump(); + AxCFontNewObject( *this ).dump(); else ensureValid( false ); } @@ -885,43 +1317,43 @@ void OcxPropertyObjectBase::dumpLargeProperties() // ============================================================================ -OcxCFontNewObject::OcxCFontNewObject( const InputObjectBase& rParent ) +AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-CFONTNEW-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" ); } -void OcxCFontNewObject::implDumpShortProperties() +void AxCFontNewObject::implDumpShortProperties() { dumpStringProperty(); - dumpFlagsProperty( 0, "OCX-CFONTNEW-FLAGS" ); + dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" ); dumpDecProperty< sal_Int32 >( 160 ); dumpDecProperty< sal_Int32 >( 0 ); - dumpDecProperty< sal_uInt8 >( 1, "CHARSET" ); + dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" ); dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" ); - dumpDecProperty< sal_uInt8 >( 1, "OCX-CFONTNEW-ALIGNMENT" ); + dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" ); dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" ); } // ============================================================================ -OcxColumnInfoObject::OcxColumnInfoObject( const InputObjectBase& rParent ) +AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-COLUMNINFO-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" ); } -void OcxColumnInfoObject::implDumpShortProperties() +void AxColumnInfoObject::implDumpShortProperties() { dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" ); } // ============================================================================ -OcxCommandButtonObject::OcxCommandButtonObject( const InputObjectBase& rParent ) +AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-COMMANDBUTTON-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" ); } -void OcxCommandButtonObject::implDumpShortProperties() +void AxCommandButtonObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x80000008 ); @@ -936,42 +1368,42 @@ void OcxCommandButtonObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxCommandButtonObject::implDumpExtended() +void AxCommandButtonObject::implDumpExtended() { dumpEmbeddedFont(); } // ============================================================================ -OcxMorphControlObject::OcxMorphControlObject( const InputObjectBase& rParent ) +AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-MORPH-PROPERTIES", true ); + AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true ); } -void OcxMorphControlObject::implDumpShortProperties() +void AxMorphControlObject::implDumpShortProperties() { dumpFlagsProperty( 0x2C80081B ); dumpColorProperty( 0x80000005 ); dumpColorProperty( 0x80000008 ); dumpDecProperty< sal_uInt32 >( 0 ); dumpBorderStyleProperty< sal_uInt8 >( 0 ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SCROLLBARS" ); - mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-CONTROLTYPE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" ); + mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" ); dumpMousePtrProperty(); dumpSizeProperty(); dumpUnicodeProperty(); dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" ); - dumpDecProperty< sal_uInt16 >( 1, "OCX-MORPH-BOUNDCOLUMN" ); - dumpDecProperty< sal_Int16 >( -1, "OCX-MORPH-TEXTCOLUMN" ); - dumpDecProperty< sal_Int16 >( 1, "OCX-MORPH-COLUMNCOUNT" ); + dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" ); + dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" ); + dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" ); dumpDecProperty< sal_uInt16 >( 8 ); mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 ); - dumpDecProperty< sal_uInt8 >( 2, "OCX-MORPH-MATCHENTRYTYPE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-LISTSTYLE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SHOWDROPDOWNMODE" ); + dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" ); dumpUnknownProperty(); - dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-DROPDOWNSTYLE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SELECTIONTYPE" ); + dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" ); dumpStringProperty(); dumpStringProperty(); dumpImagePosProperty(); @@ -985,34 +1417,34 @@ void OcxMorphControlObject::implDumpShortProperties() dumpStringProperty(); } -void OcxMorphControlObject::implDumpExtended() +void AxMorphControlObject::implDumpExtended() { dumpEmbeddedFont(); dumpColumnInfos(); } -void OcxMorphControlObject::dumpColumnInfos() +void AxMorphControlObject::dumpColumnInfos() { if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx ) { writeEmptyItem( "#column-info" ); - IndentGuard aIndGuard( out() ); - OcxColumnInfoObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + AxColumnInfoObject( *this ).dump(); } } } // ============================================================================ -OcxLabelObject::OcxLabelObject( const InputObjectBase& rParent ) +AxLabelObject::AxLabelObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-LABEL-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" ); } -void OcxLabelObject::implDumpShortProperties() +void AxLabelObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1029,19 +1461,19 @@ void OcxLabelObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxLabelObject::implDumpExtended() +void AxLabelObject::implDumpExtended() { dumpEmbeddedFont(); } // ============================================================================ -OcxImageObject::OcxImageObject( const InputObjectBase& rParent ) +AxImageObject::AxImageObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-IMAGE-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" ); } -void OcxImageObject::implDumpShortProperties() +void AxImageObject::implDumpShortProperties() { dumpUnknownProperty(); dumpUnknownProperty(); @@ -1062,12 +1494,12 @@ void OcxImageObject::implDumpShortProperties() // ============================================================================ -OcxScrollBarObject::OcxScrollBarObject( const InputObjectBase& rParent ) +AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-SCROLLBAR-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" ); } -void OcxScrollBarObject::implDumpShortProperties() +void AxScrollBarObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1083,19 +1515,19 @@ void OcxScrollBarObject::implDumpShortProperties() dumpDecProperty< sal_Int32 >( 1 ); dumpDecProperty< sal_Int32 >( 1 ); dumpOrientationProperty(); - dumpDecProperty< sal_Int16 >( -1, "OCX-SCROLLBAR-PROPTHUMB" ); + dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" ); dumpDelayProperty(); dumpStreamProperty(); } // ============================================================================ -OcxSpinButtonObject::OcxSpinButtonObject( const InputObjectBase& rParent ) +AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-SPINBUTTON-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" ); } -void OcxSpinButtonObject::implDumpShortProperties() +void AxSpinButtonObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1116,12 +1548,12 @@ void OcxSpinButtonObject::implDumpShortProperties() // ============================================================================ -OcxTabStripObject::OcxTabStripObject( const InputObjectBase& rParent ) +AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-TABSTRIP-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" ); } -void OcxTabStripObject::implDumpShortProperties() +void AxTabStripObject::implDumpShortProperties() { dumpDecProperty< sal_Int32 >( -1 ); dumpColorProperty( 0x8000000F ); @@ -1131,8 +1563,8 @@ void OcxTabStripObject::implDumpShortProperties() dumpStringArrayProperty(); dumpMousePtrProperty(); dumpUnknownProperty(); - dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-ORIENTATION" ); - dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-TABSTYLE" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" ); dumpBoolProperty(); dumpHmmProperty(); dumpHmmProperty(); @@ -1150,35 +1582,43 @@ void OcxTabStripObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxTabStripObject::implDumpExtended() +void AxTabStripObject::implDumpExtended() { dumpEmbeddedFont(); if( mnTabFlagCount > 0 ) { writeEmptyItem( "tab-flags" ); - IndentGuard aIndGuard( out() ); - out().resetItemIndex(); + IndentGuard aIndGuard( mxOut ); + mxOut->resetItemIndex(); for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx ) - dumpHex< sal_uInt32 >( "#flags", "OCX-TABSTRIP-FLAGS" ); + dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" ); } } +// ============================================================================ // ============================================================================ -OcxControlObject::OcxControlObject( const InputObjectBase& rParent, const OUString& rProgId, sal_Int64 nLength ) : - maProgId( rProgId ), - mnLength( nLength ) +FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId ) { - InputObjectBase::construct( rParent ); + construct( rParent, rxStrm, rSysFileName ); + constructFormCtrlStrmObj( pProgId ); } -void OcxControlObject::implDump() +FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId ) { - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int64 >( mnLength, 0 ); - if( (maProgId.getLength() > 0) && (mnLength > 0) && !in().isEof() ) + construct( rParent, rxStrm ); + constructFormCtrlStrmObj( pProgId ); +} + +void FormControlStreamObject::implDump() +{ + if( mbReadGuid ) + maProgId = cfg().getStringOption( dumpGuid(), OUString() ); + + if( (maProgId.getLength() > 0) && !mxStrm->isEof() ) { if( maProgId.equalsAscii( "Forms.CommandButton.1" ) ) - OcxCommandButtonObject( *this ).dump(); + AxCommandButtonObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.TextBox.1" ) || maProgId.equalsAscii( "Forms.ListBox.1" ) || maProgId.equalsAscii( "Forms.ComboBox.1" ) || @@ -1186,161 +1626,76 @@ void OcxControlObject::implDump() maProgId.equalsAscii( "Forms.OptionButton.1" ) || maProgId.equalsAscii( "Forms.ToggleButton.1" ) || maProgId.equalsAscii( "RefEdit.Ctrl" ) ) - OcxMorphControlObject( *this ).dump(); + AxMorphControlObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.Label.1" ) ) - OcxLabelObject( *this ).dump(); + AxLabelObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.Image.1" ) ) - OcxImageObject( *this ).dump(); + AxImageObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.ScrollBar.1" ) ) - OcxScrollBarObject( *this ).dump(); + AxScrollBarObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.SpinButton.1" ) ) - OcxSpinButtonObject( *this ).dump(); + AxSpinButtonObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.TabStrip.1" ) ) - OcxTabStripObject( *this ).dump(); + AxTabStripObject( *this ).dump(); + else if( maProgId.equalsAscii( "MSComCtl2.FlatScrollBar.2" ) ) + ComCtlScrollBarObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.ProgCtrl.1" ) ) + ComCtlProgressBarObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.ProgCtrl.2" ) ) + ComCtlProgressBarObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.Slider.1" ) ) + ComCtlSliderObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.Slider.2" ) ) + ComCtlSliderObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "ComCtl2.UpDown.1" ) ) + ComCtlUpDownObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComCtl2.UpDown.2" ) ) + ComCtlUpDownObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.ImageListCtrl.1" ) ) + ComCtlImageListObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.ImageListCtrl.2" ) ) + ComCtlImageListObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.TabStrip.1" ) ) + ComCtlTabStripObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.TabStrip.2" ) ) + ComCtlTabStripObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.TreeCtrl.1" ) ) + ComCtlTreeViewObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.TreeCtrl.2" ) ) + ComCtlTreeViewObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.SBarCtrl.1" ) ) + ComCtlStatusBarObject( *this, 5 ).dump(); else if( maProgId.equalsAscii( "StdPic" ) ) StdPicObject( *this ).dump(); } - dumpRemainingTo( nEndPos ); -} - -// ============================================================================ - -OcxGuidControlObject::OcxGuidControlObject( const InputObjectBase& rParent, sal_Int64 nLength ) : - mnLength( nLength ) -{ - InputObjectBase::construct( rParent ); -} - -OcxGuidControlObject::OcxGuidControlObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) -{ - mnLength = rxStrm.get() ? rxStrm->getLength() : -1; - InputObjectBase::construct( rParent, rxStrm ); -} - -OcxGuidControlObject::OcxGuidControlObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) -{ - mnLength = rxStrm.get() ? rxStrm->getLength() : -1; - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); -} - -void OcxGuidControlObject::implDump() -{ - OUString aProgId = cfg().getStringOption( dumpGuid(), OUString() ); - OcxControlObject( *this, aProgId, mnLength - 16 ).dump(); -} - -// ============================================================================ - -OcxControlsStreamObject::OcxControlsStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : - mrFormData( rFormData ) -{ - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); -} - -void OcxControlsStreamObject::implDump() -{ - for( OcxFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !in().isEof() && (aIt != aEnd); ++aIt ) - { - if( (aIt->mbInStream) && (aIt->mnLength > 0) ) - { - out().emptyLine(); - writeDecItem( "control-id", aIt->mnId ); - writeInfoItem( "prog-id", aIt->maProgId ); - IndentGuard aIndGuard( out() ); - OcxControlObject( *this, aIt->maProgId, aIt->mnLength ).dump(); - } - } dumpRemainingStream(); } -// ============================================================================ -// ============================================================================ - -OcxPageObject::OcxPageObject( const InputObjectBase& rParent ) +void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId ) { - OcxPropertyObjectBase::construct( rParent, "OCX-PAGE-PROPERTIES" ); -} - -void OcxPageObject::implDumpShortProperties() -{ - dumpUnknownProperty(); - dumpDecProperty< sal_uInt32 >( 0, "OCX-PAGE-TRANSITIONEFFECT" ); - dumpDecProperty< sal_uInt32 >( 0, "OCX-CONV-MS" ); + mbReadGuid = pProgId == 0; + if( pProgId ) + maProgId = *pProgId; } // ============================================================================ - -OcxMultiPageObject::OcxMultiPageObject( const InputObjectBase& rParent ) -{ - OcxPropertyObjectBase::construct( rParent, "OCX-MULTIPAGE-PROPERTIES" ); -} - -void OcxMultiPageObject::implDumpShortProperties() -{ - dumpUnknownProperty(); - mnPageCount = dumpDecProperty< sal_Int32 >( 0 ); - dumpDecProperty< sal_Int32 >( 0 ); - dumpBoolProperty(); -} - -void OcxMultiPageObject::implDumpExtended() -{ - if( ensureValid() && (mnPageCount > 0) ) - { - writeEmptyItem( "page-ids" ); - IndentGuard aIndGuard( out() ); - out().resetItemIndex(); - for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx ) - dumpDec< sal_Int32 >( "#id" ); - } -} - // ============================================================================ -OcxMultiPageStreamObject::OcxMultiPageStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : +VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); + AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" ); } -void OcxMultiPageStreamObject::implDump() -{ - for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !in().isEof() && (nIdx < nCount); ++nIdx ) - { - out().emptyLine(); - writeEmptyItem( "page" ); - IndentGuard aIndGuard( out() ); - OcxPageObject( *this ).dump(); - } - if( !in().isEof() ) - { - out().emptyLine(); - writeEmptyItem( "multi-page" ); - IndentGuard aIndGuard( out() ); - OcxMultiPageObject( *this ).dump(); - } - dumpRemainingStream(); -} - -// ============================================================================ -// ============================================================================ - -OcxFormClassInfoObject::OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : - mrFormData( rFormData ) -{ - OcxPropertyObjectBase::construct( rParent, "OCX-CLASSINFO-PROPERTIES" ); -} - -void OcxFormClassInfoObject::implDumpShortProperties() +void VbaFormClassInfoObject::implDumpShortProperties() { mrFormData.maClassInfoProgIds.push_back( OUString() ); dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() ); dumpGuidProperty(); dumpUnknownProperty(); dumpGuidProperty(); - dumpFlagsProperty( 0, "OCX-CLASSINFO-FLAGS" ); + dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" ); + dumpDecProperty< sal_uInt32 >( 0 ); dumpDecProperty< sal_Int32 >( -1 ); dumpDecProperty< sal_uInt16 >( 0 ); dumpDecProperty< sal_uInt16 >( 0 ); @@ -1356,32 +1711,32 @@ void OcxFormClassInfoObject::implDumpShortProperties() namespace { -const sal_uInt32 OCX_FORMSITE_OBJSTREAM = 0x0010; +const sal_uInt32 VBA_FORMSITE_OBJSTREAM = 0x0010; -const sal_uInt16 OCX_FORMSITE_CLASSTABLEINDEX = 0x8000; -const sal_uInt16 OCX_FORMSITE_CLASSTABLEMASK = 0x7FFF; +const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX = 0x8000; +const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK = 0x7FFF; } // namespace // ---------------------------------------------------------------------------- -OcxFormSiteObject::OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : +VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - OcxPropertyObjectBase::construct( rParent, "OCX-FORMSITE-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" ); } -void OcxFormSiteObject::implDumpShortProperties() +void VbaFormSiteObject::implDumpShortProperties() { - OcxFormSiteInfo aSiteInfo; + VbaFormSiteInfo aSiteInfo; dumpStringProperty(); dumpStringProperty(); sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 ); dumpDecProperty< sal_Int32 >( 0 ); - sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "OCX-FORMSITE-FLAGS" ); + sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" ); sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 ); dumpDecProperty< sal_Int16 >( -1 ); - sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "OCX-FORMSITE-CLASSIDCACHE" ); + sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" ); dumpPosProperty(); dumpDecProperty< sal_uInt16 >( 0 ); dumpUnknownProperty(); @@ -1390,38 +1745,38 @@ void OcxFormSiteObject::implDumpShortProperties() dumpStringProperty(); dumpStringProperty(); - sal_uInt16 nIndex = nClassId & OCX_FORMSITE_CLASSTABLEMASK; - if( getFlag( nClassId, OCX_FORMSITE_CLASSTABLEINDEX ) ) + sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK; + if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) ) { if( nIndex < mrFormData.maClassInfoProgIds.size() ) aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ]; } else { - if( cfg().hasName( "OCX-FORMSITE-CLASSNAMES", nIndex ) ) - aSiteInfo.maProgId = cfg().getName( "OCX-FORMSITE-CLASSNAMES", nIndex ); + if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) ) + aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex ); } aSiteInfo.mnId = nId; aSiteInfo.mnLength = nLength; - aSiteInfo.mbInStream = getFlag( nFlags, OCX_FORMSITE_OBJSTREAM ); + aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM ); mrFormData.maSiteInfos.push_back( aSiteInfo ); } // ============================================================================ -OcxFormDesignExtObject::OcxFormDesignExtObject( const InputObjectBase& rParent ) +VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-FORMDESIGNEXT-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" ); } -void OcxFormDesignExtObject::implDumpShortProperties() +void VbaFormDesignExtObject::implDumpShortProperties() { - dumpFlagsProperty( 0x00015F55, "OCX-FORMDESIGNEXT-FLAGS" ); + dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" ); dumpHmmProperty(); dumpHmmProperty(); - dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-CLICKCTRLMODE" ); - dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE" ); + dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" ); + dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" ); } // ============================================================================ @@ -1438,13 +1793,13 @@ const sal_uInt8 OCX_FORM_SITECOUNTTYPE_MASK = 0x7F; // ---------------------------------------------------------------------------- -OcxFormObject::OcxFormObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : +VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - OcxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "OCX-FORM-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" ); } -void OcxFormObject::implDumpShortProperties() +void VbaFStreamObject::implDumpShortProperties() { dumpUnknownProperty(); dumpColorProperty( 0x8000000F ); @@ -1452,17 +1807,17 @@ void OcxFormObject::implDumpShortProperties() dumpDecProperty< sal_uInt32 >( 0 ); dumpUnknownProperty(); dumpUnknownProperty(); - mnFlags = dumpFlagsProperty( 0x00000004, "OCX-FORM-FLAGS" ); + mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" ); dumpBorderStyleProperty< sal_uInt8 >( 0 ); dumpMousePtrProperty(); - dumpHexProperty< sal_uInt8 >( 0x0C, "OCX-FORM-SCROLLBARS" ); + dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" ); dumpSizeProperty(); dumpSizeProperty(); dumpPosProperty(); dumpDecProperty< sal_uInt32 >( 0 ); dumpUnknownProperty(); dumpStreamProperty(); - dumpDecProperty< sal_uInt8 >( 0, "OCX-FORM-CYCLE" ); + dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" ); dumpSpecialEffectProperty< sal_uInt8 >( 0 ); dumpColorProperty( 0x80000012 ); dumpStringProperty(); @@ -1476,7 +1831,7 @@ void OcxFormObject::implDumpShortProperties() dumpDecProperty< sal_uInt32 >( 0 ); } -void OcxFormObject::implDumpExtended() +void VbaFStreamObject::implDumpExtended() { dumpClassInfos(); dumpSiteData(); @@ -1484,54 +1839,54 @@ void OcxFormObject::implDumpExtended() dumpRemainingStream(); } -void OcxFormObject::dumpClassInfos() +void VbaFStreamObject::dumpClassInfos() { if( ensureValid() && !getFlag( mnFlags, OCX_FORM_SKIPCLASSTABLE ) ) { - out().emptyLine(); + mxOut->emptyLine(); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) { writeEmptyItem( "#class-info" ); - IndentGuard aIndGuard( out() ); - OcxFormClassInfoObject( *this, mrFormData ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormClassInfoObject( *this, mrFormData ).dump(); } } } -void OcxFormObject::dumpFormSites( sal_uInt32 nCount ) +void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "#form-site" ); - IndentGuard aIndGuard( out() ); - OcxFormSiteObject( *this, mrFormData ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormSiteObject( *this, mrFormData ).dump(); } } -void OcxFormObject::dumpSiteData() +void VbaFStreamObject::dumpSiteData() { if( ensureValid() ) { - out().emptyLine(); + mxOut->emptyLine(); setAlignAnchor(); sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" ); sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" ); - sal_Int64 nEndPos = in().tell() + nSiteLength; - if( ensureValid( nEndPos <= in().getLength() ) ) + sal_Int64 nEndPos = mxStrm->tell() + nSiteLength; + if( ensureValid( nEndPos <= mxStrm->getLength() ) ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); sal_uInt32 nSiteIdx = 0; while( ensureValid() && (nSiteIdx < nSiteCount) ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "#site-info" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpDec< sal_uInt8 >( "depth" ); - sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "OCX-FORM-SITE-TYPECOUNT" ); + sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" ); if( getFlag( nTypeCount, OCX_FORM_SITECOUNTTYPE_COUNT ) ) { dumpDec< sal_uInt8 >( "repeated-type" ); @@ -1549,46 +1904,141 @@ void OcxFormObject::dumpSiteData() } } -void OcxFormObject::dumpDesignExtender() +void VbaFStreamObject::dumpDesignExtender() { if( ensureValid() && getFlag( mnFlags, OCX_FORM_HASDESIGNEXTENDER ) ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "design-extender" ); - IndentGuard aIndGuard( out() ); - OcxFormDesignExtObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormDesignExtObject( *this ).dump(); + } +} + +// ============================================================================ + +VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + OleInputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void VbaOStreamObject::implDump() +{ + for( VbaFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) + { + if( (aIt->mbInStream) && (aIt->mnLength > 0) ) + { + mxOut->emptyLine(); + writeDecItem( "control-id", aIt->mnId ); + writeInfoItem( "prog-id", aIt->maProgId ); + IndentGuard aIndGuard( mxOut ); + RelativeInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, aIt->mnLength ) ); + FormControlStreamObject( *this, xRelStrm, &aIt->maProgId ).dump(); + } } + dumpRemainingStream(); +} + +// ============================================================================ + +VbaPageObject::VbaPageObject( const InputObjectBase& rParent ) +{ + AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" ); +} + +void VbaPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" ); } // ============================================================================ -OcxFormStorageObject::OcxFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : +VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent ) +{ + AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" ); +} + +void VbaMultiPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + mnPageCount = dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpBoolProperty(); +} + +void VbaMultiPageObject::implDumpExtended() +{ + if( ensureValid() && (mnPageCount > 0) ) + { + writeEmptyItem( "page-ids" ); + IndentGuard aIndGuard( mxOut ); + mxOut->resetItemIndex(); + for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx ) + dumpDec< sal_Int32 >( "#id" ); + } +} + +// ============================================================================ + +VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void VbaXStreamObject::implDump() +{ + for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx ) + { + mxOut->emptyLine(); + writeEmptyItem( "page" ); + IndentGuard aIndGuard( mxOut ); + VbaPageObject( *this ).dump(); + } + if( !mxStrm->isEof() ) + { + mxOut->emptyLine(); + writeEmptyItem( "multi-page" ); + IndentGuard aIndGuard( mxOut ); + VbaMultiPageObject( *this ).dump(); + } + dumpRemainingStream(); +} + +// ============================================================================ + +VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : OleStorageObject( rParent, rxStrg, rSysPath ) { addPreferredStream( "f" ); } -void OcxFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +void VbaContainerStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { if( rStrmName.equalsAscii( "f" ) ) - OcxFormObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else if( rStrmName.equalsAscii( "o" ) ) - OcxControlsStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else if( rStrmName.equalsAscii( "x" ) ) - OcxMultiPageStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); } -void OcxFormStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) +void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { if( isFormStorage( rStrgPath ) ) - OcxFormStorageObject( *this, rxStrg, rSysPath ).dump(); + VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump(); else OleStorageObject( *this, rxStrg, rSysPath ).dump(); } -bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const +bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const { if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') ) { @@ -1597,7 +2047,7 @@ bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const aId = aId.copy( 1 ); sal_Int32 nId = aId.toInt32(); if( (nId > 0) && (OUString::valueOf( nId ) == aId) ) - for( OcxFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt ) + for( VbaFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt ) if( aIt->mnId == nId ) return true; } @@ -1608,7 +2058,7 @@ bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const // ============================================================================ VbaSharedData::VbaSharedData() : - meTextEnc( osl_getThreadTextEncoding() ) + meTextEnc( RTL_TEXTENCODING_MS_1252 ) { } @@ -1659,7 +2109,7 @@ void VbaDirStreamObject::implDumpRecordBody() switch( getRecId() ) { case 0x0003: - mrVbaData.meTextEnc = ::oox::xls::BiffHelper::calcTextEncodingFromCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) ); + mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) ); break; case 0x0004: dumpByteString( "name" ); @@ -1730,7 +2180,7 @@ void VbaDirStreamObject::implDumpRecordBody() dumpUniString( "constants" ); break; case 0x003D: - dumpUniString( "helpfile-path" ); + dumpByteString( "helpfile-path" ); break; case 0x003E: dumpUniString( "name" ); @@ -1759,7 +2209,7 @@ OUString VbaDirStreamObject::dumpUniString( const String& rName ) OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName ) { - return dumpCharArray( rName, in().readInt32(), mrVbaData.meTextEnc ); + return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc ); } // ============================================================================ @@ -1776,10 +2226,10 @@ VbaModuleStreamObject::VbaModuleStreamObject( void VbaModuleStreamObject::implDump() { dumpBinary( "perf-cache", mnStrmOffset ); - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "source-code" ); - IndentGuard aIndGuard( out() ); - BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( in() ) ); + IndentGuard aIndGuard( mxOut ); + BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) ); TextStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump(); } @@ -1805,7 +2255,7 @@ void VbaStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const // ============================================================================ VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) : - OcxFormStorageObject( rParent, rxStrg, rSysPath ), + VbaContainerStorageObject( rParent, rxStrg, rSysPath ), mrVbaData( rVbaData ) { } @@ -1815,7 +2265,7 @@ void VbaFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, c if( rStrmName.equalsAscii( "\003VBFrame" ) ) TextStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump(); else - OcxFormStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); + VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); } // ============================================================================ @@ -1845,6 +2295,19 @@ void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const O // ============================================================================ // ============================================================================ +ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : + VbaContainerStorageObject( rParent, rxStrg, rSysPath ) +{ +} + +void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + FormControlStreamObject( *this, rxStrm, rSysFileName ).dump(); +} + +// ============================================================================ +// ============================================================================ + } // namespace dump } // namespace oox diff --git a/oox/source/dump/oledumper.ini b/oox/source/dump/oledumper.ini index c398b0c01e51..7efe424b0ddc 100644 --- a/oox/source/dump/oledumper.ini +++ b/oox/source/dump/oledumper.ini @@ -4,7 +4,39 @@ # Path to additional configuration data, relative to this file. include-config-file=dumperbase.ini -# StdFont ==================================================================== +# OLE name lists ============================================================= + +constlist=OLE-STD-CLIPBOARD-FORMAT + 2=bmp + 3=wmf + 8=dib + 14=emf +end + +combilist=OLE-COLOR + 0x0000FFFF=uint32,dec,palette-index,,filter=0xFF000000~0x01000000 + 0x000000FF=uint32,dec,red,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x0000FF00=uint32,dec,green,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x00FF0000=uint32,dec,blue,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x0000FFFF=uint32,dec,system-color,SYSTEMCOLOR,filter=0xFF000000~0x80000000 + 0xFF000000=uint8,dec,type,OLE-COLORTYPE +end + +constlist=OLE-COLORTYPE + 0x00=default + 0x01=palette + 0x02=rgb + 0x80=system-color +end + +multilist=OLE-MOUSEPTR + 0=default,arrow,cross,i-beam + 6=size-diag-down,size-vert,size-diag-up,size-hor + 10=up-arrow,hour-glass,no-drop,app-starting,help,size-all + 99=custom +end + +# StdFont -------------------------------------------------------------------- {0BE35203-8F91-11CE-9DE3-00AA004BB851}=StdFont @@ -17,11 +49,13 @@ end unitconverter=STDFONT-HEIGHT,/10000,pt -# StdPic ===================================================================== +# StdPic --------------------------------------------------------------------- {0BE35204-8F91-11CE-9DE3-00AA004BB851}=StdPic -# StdHlink =================================================================== +shortlist=STDPIC-ID,0x0000746C,StdPic + +# StdHlink ------------------------------------------------------------------- {79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}=StdHlink {79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}=URLMoniker @@ -62,7 +96,7 @@ flagslist=STDHLINK-URL-FLAGS 0x00008000=no-encode-forbidden-chars end -# OLE name lists ============================================================= +# OLE property stream -------------------------------------------------------- {F29F85E0-4FF9-1068-AB91-08002B27B3D9}=GlobalDocProp {D5CDD502-2E9C-101B-9397-08002B2CF9AE}=BuiltinDocProp @@ -110,37 +144,210 @@ combilist=OLEPROP-TYPE 0x4000=byref end -# OCX name lists ============================================================= +# ComCtl controls ============================================================ + +constlist=COMCTL-HEADER-IDS + 0x0A2BAE11=COMCTL_SLIDER_60 + 0x12344321=COMCTL_SIZE + 0x6AC13CB1=COMCTL_TREEVIEW_60 + 0x97AB8A01=COMCTL_PROGRESSBAR_60 + 0x99470A83=COMCTL_SCROLLBAR_60 + 0xABCDEF01=COMCTL_COMMONDATA + 0xBDECDE1F=COMCTL_COMPLEXDATA + 0xD12A7AC1=COMCTL_TABSTRIP_60 + 0xE6E17E80=COMCTL_IMAGELIST_50_60 + 0xE6E17E84=COMCTL_PROGRESSBAR_50 + 0xE6E17E86=COMCTL_SLIDER_50 + 0xE6E17E88=COMCTL_STATUSBAR_50 + 0xE6E17E8A=COMCTL_TABSTRIP_50 + 0xE6E17E8E=COMCTL_TREEVIEW_50 + 0xFF3626A0=COMCTL_UPDOWN_50_60 +end + +combilist=COMCTL-COMMON-FLAGS + ignore=0xFFFF8000 + 0x00000001=flat-border + 0x00000002=enabled + 0x00000004=3d-border + 0x000007F8=uint8,dec,mouse-ptr,OLE-MOUSEPTR + 0x00000800=ole-drag-auto + 0x00002000=ole-drop-manual +end + +flagslist=COMCTL-COMPLEX-FLAGS + ignore=0xFFFFFFFC + 0x00000001=font + 0x00000002=mouse-icon +end + +# flat scrollbar ------------------------------------------------------------- + +{FE38753A-44A3-11D1-B5B7-0000C09000C4}=MSComCtl2.FlatScrollBar.2 + +combilist=COMCTL-SCROLLBAR-FLAGS + 0x00000003=uint8,dec,appearance,COMCTL-SCROLLBAR-APPEARANCE + 0x0000000C=uint8,dec,arrows,COMCTL-SCROLLBAR-ARROWS + 0x00000010=!vertical!horizontal +end + +shortlist=COMCTL-SCROLLBAR-APPEARANCE,0,3d,flat,track-3d +shortlist=COMCTL-SCROLLBAR-ARROWS,0,both,left-up,right-down + +# progress bar --------------------------------------------------------------- {0713E8D2-850A-101B-AFC0-4210102A8DA7}=COMCTL.ProgCtrl.1 +{35053A22-8589-11D1-B16A-00C0F0283628}=MSComctlLib.ProgCtrl.2 -combilist=OCX-COLOR - 0x0000FFFF=uint32,dec,palette-index,,filter=0xFF000000~0x01000000 - 0x000000FF=uint32,dec,red,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x0000FF00=uint32,dec,green,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x00FF0000=uint32,dec,blue,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x0000FFFF=uint32,dec,system-color,SYSTEMCOLOR,filter=0xFF000000~0x80000000 - 0xFF000000=uint8,dec,type,OCX-COLORTYPE +# slider --------------------------------------------------------------------- + +{373FF7F0-EB8B-11CD-8820-08002B2F4F5A}=COMCTL.Slider.1 +{F08DF954-8592-11D1-B16A-00C0F0283628}=MSComctlLib.Slider.2 + +constlist=COMCTL-SLIDER-SELECTRANGE + 0x00000000=off + 0x0000FFFF=on + end + +shortlist=COMCTL-SLIDER-TICKSTYLE,0,bottom-right,top-left,both,no-ticks + +# updown --------------------------------------------------------------------- + +{026371C0-1B7C-11CF-9D53-00AA003C9CB6}=ComCtl2.UpDown.1 +{603C7E80-87C2-11D1-8BE3-0000F8754DA1}=MSComCtl2.UpDown.2 + +flagslist=COMCTL-UPDOWN-FLAGS1 + 0x00000001=!align-left!align-right + 0x00000004=!vertical!horizontal + end + +flagslist=COMCTL-UPDOWN-FLAGS2 + 0x00000004=wrap + 0x00000020=ole-drop-manual + 0x00000080=enabled + end + +# image list ----------------------------------------------------------------- + +{58DA8D8F-9D6A-101B-AFC0-4210102A8DA7}=COMCTL.ImageListCtrl.1 +{2C247F23-8591-11D1-B16A-00C0F0283628}=MSComctlLib.ImageListCtrl.2 + +flagslist=COMCTL-IMAGELIST-TEXTFLAGS + 0x01=key + 0x02=tag end -constlist=OCX-COLORTYPE - 0x00=default - 0x01=palette - 0x02=rgb - 0x80=system-color +# tab strip ------------------------------------------------------------------ + +{9ED94440-E5E8-101B-B9B5-444553540000}=COMCTL.TabStrip.1 +{1EFB6596-857C-11D1-B16A-00C0F0283628}=MSComctlLib.TabStrip.2 + +combilist=COMCTL-TABSTRIP-FLAGS1 + ignore=0xFFFFFFE0 + 0x00000001=multi-row + 0x00000002=show-tooltips + 0x00000018=uint8,dec,tab-width-style,COMCTL-TABSTRIP-TABWIDTHSTYLE +end + +combilist=COMCTL-TABSTRIP-FLAGS2 + ignore=0xFFFF0000 + 0x00000003=uint8,dec,style,COMCTL-TABSTRIP-STYLE + 0x00000004=hot-tracking + 0x00000008=multi-select + 0x00000030=uint8,dec,placement,COMCTL-TABSTRIP-PLACEMENT + 0x00000040=separators +end + +flagslist=COMCTL-TABSTRIP-FLAGS3 + ignore=0xFFFF0000 + 0x00000001=tabstyle-opposite +end + +shortlist=COMCTL-TABSTRIP-TABWIDTHSTYLE,0,justified,non-justified,fixed +shortlist=COMCTL-TABSTRIP-STYLE,0,tabs,tab-buttons,flat-buttons +shortlist=COMCTL-TABSTRIP-PLACEMENT,0,top,bottom,left,right + +flagslist=COMCTL-TABSTRIP-TABFLAGS + 0x00000001=caption + 0x00000002=key + 0x00000004=tag + 0x00000008=tooltip +end + +# tree view ------------------------------------------------------------------ + +{0713E8A2-850A-101B-AFC0-4210102A8DA7}=COMCTL.TreeCtrl.1 +{C74190B6-8589-11D1-B16A-00C0F0283628}=MSComctlLib.TreeCtrl.2 + +combilist=COMCTL-TREEVIEW-FLAGS + ignore=0xFFFF0000 + 0x00000001=!tree-lines!root-lines + 0x0000001C=uint8,dec,style,COMCTL-TREEVIEW-STYLE + 0x00000020=label-edit + 0x00000080=hide-selection + 0x00000100=sorted +end + +flagslist=COMCTL-TREEVIEW-STRINGFLAGS + ignore=0xFFFFFFF8 + 0x00000001=separator + 0x00000002=image-list +end + +shortlist=COMCTL-TREEVIEW-STYLE,0,text,pic-text,plusminus-text,plusminus-pic-text,treelines-text,treelines-pic-text,treelines-plusminus-text,treelines-plusminus-pic-text + +flagslist=COMCTL-TREEVIEW-FLAGS2 + 0x00000001=checkboxes + 0x00000002=full-row-select + 0x00000004=hot-tracking + 0x00000008=scroll + 0x00000010=single-select +end + +# status bar ----------------------------------------------------------------- + +{6B7E638F-850A-101B-AFC0-4210102A8DA7}=COMCTL.SBarCtrl.1 + +combilist=COMCTL-STATUSBAR-PANELFLAGS + ignore=0xFFFFF000 + 0x00000007=uint8,dec,style,COMCTL-STATUSBAR-STYLE + 0x00000018=uint8,dec,alignment,COMCTL-STATUSBAR-ALIGN + 0x00000060=uint8,dec,bevel,COMCTL-STATUSBAR-BEVEL + 0x00000080=enabled + 0x00000300=uint8,dec,autosize,COMCTL-STATUSBAR-AUTOSIZE + 0x00000400=visible +end + +shortlist=COMCTL-STATUSBAR-STYLE,0,text,caps,num,ins,scrl,time,date,kana +shortlist=COMCTL-STATUSBAR-ALIGN,0,left,center,right +shortlist=COMCTL-STATUSBAR-BEVEL,0,no-bevel,inset,raised +shortlist=COMCTL-STATUSBAR-AUTOSIZE,0,no-auto,spring,content + +flagslist=COMCTL-STATUSBAR-TEXTFLAGS + 0x00000001=text + 0x00000002=vis-text + 0x00000004=key + 0x00000008=tag + 0x00000010=tooltip end -combilist=OCX-STRINGLEN +# other controls ============================================================= + +# Microsoft Web Browser +{8856F961-340A-11D0-A96B-00C04FD705A2}=Shell.Explorer.2 + +# ActiveX name lists ========================================================= + +combilist=AX-STRINGLEN 0x80000000=!unicode!compressed 0x7FFFFFFF=int32,dec,buffer-size end -combilist=OCX-ARRAYSTRINGLEN +combilist=AX-ARRAYSTRINGLEN 0x80000000=!unicode!compressed 0x7FFFFFFF=int32,dec,len end -combilist=OCX-FLAGS +combilist=AX-FLAGS 0x00000001=reserved-1 0x00000002=enabled 0x00000004=locked @@ -151,7 +358,7 @@ combilist=OCX-FLAGS 0x00001000=existing-entries-only 0x00002000=caption-left 0x00004000=editable - 0x00078000=uint8,dec,ime-mode,OCX-IMEMODE + 0x00078000=uint8,dec,ime-mode,AX-IMEMODE 0x00080000=drag-enabled 0x00100000=enter-as-newline 0x00200000=keep-selection @@ -166,7 +373,7 @@ combilist=OCX-FLAGS 0x80000000=multi-line end -multilist=OCX-IMEMODE +multilist=AX-IMEMODE 0=no-control,on,off,disabled 4=hiragana,fillwidth-katakana,halfwidth-katakana 7=fullwidth-alpha,halfwidth-alpha @@ -174,33 +381,26 @@ multilist=OCX-IMEMODE 11=fullwidth-hanzi,halfwidth-hanzi end -multilist=OCX-MOUSEPTR - 0=default,arrow,cross,i-beam - 6=size-diag-down,size-vert,size-diag-up,size-hor - 10=up-arrow,hour-glass,no-drop,app-starting,help,size-all - 99=custom +combilist=AX-IMAGEPOS + 0x0000FFFF=uint16,dec,image,AX-POS + 0xFFFF0000=uint16,dec,label,AX-POS end -combilist=OCX-IMAGEPOS - 0x0000FFFF=uint16,dec,image,OCX-POS - 0xFFFF0000=uint16,dec,label,OCX-POS -end - -unitconverter=OCX-CONV-MS,1,ms +unitconverter=AX-CONV-MS,1,ms -shortlist=OCX-ENABLED,0,disabled,enabled -shortlist=OCX-BORDERSTYLE,0,none,single -shortlist=OCX-SPECIALEFFECT,0,flat,raised,sunken,etched,,,bump -shortlist=OCX-ORIENTATION,-1,auto,vertical,horizontal -shortlist=OCX-POS,0,top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right -shortlist=OCX-IMAGEALIGN,0,top-left,top-right,center,bottom-left,bottom-right -shortlist=OCX-IMAGESIZEMODE,0,clip,stretch,,stretch-ratio +shortlist=AX-ENABLED,0,disabled,enabled +shortlist=AX-BORDERSTYLE,0,none,single +shortlist=AX-SPECIALEFFECT,0,flat,raised,sunken,etched,,,bump +shortlist=AX-ORIENTATION,-1,auto,vertical,horizontal +shortlist=AX-POS,0,top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right +shortlist=AX-IMAGEALIGN,0,top-left,top-right,center,bottom-left,bottom-right +shortlist=AX-IMAGESIZEMODE,0,clip,stretch,,stretch-ratio # CFontNew ------------------------------------------------------------------- {AFC20920-DA4E-11CE-B94300AA006887B4}=CFontNew -flagslist=OCX-CFONTNEW-PROPERTIES +flagslist=AX-CFONTNEW-PROPERTIES 0x0001=font-name 0x0002=flags 0x0004=font-size @@ -211,7 +411,7 @@ flagslist=OCX-CFONTNEW-PROPERTIES 0x0080=font-weight end -flagslist=OCX-CFONTNEW-FLAGS +flagslist=AX-CFONTNEW-FLAGS 0x00000001=bold 0x00000002=italic 0x00000004=underline @@ -221,11 +421,11 @@ flagslist=OCX-CFONTNEW-FLAGS 0x40000000=auto-color end -shortlist=OCX-CFONTNEW-ALIGNMENT,1,left,right,center +shortlist=AX-CFONTNEW-ALIGNMENT,1,left,right,center # column info ---------------------------------------------------------------- -flagslist=OCX-COLUMNINFO-PROPERTIES +flagslist=AX-COLUMNINFO-PROPERTIES 0x00000001=column-width end @@ -233,7 +433,7 @@ end {D7053240-CE69-11CD-A777-00DD01143C57}=Forms.CommandButton.1 -flagslist=OCX-COMMANDBUTTON-PROPERTIES +flagslist=AX-COMMANDBUTTON-PROPERTIES 0x00000001=text-color 0x00000002=fill-color 0x00000004=flags @@ -257,7 +457,7 @@ end {8BD21D60-EC42-11CE-9E0D-00AA006002F3}=Forms.ToggleButton.1 {00024512-0000-0000-C000-000000000046}=RefEdit.Ctrl -flagslist=OCX-MORPH-PROPERTIES +flagslist=AX-MORPH-PROPERTIES 0x0000000000000001=flags 0x0000000000000002=fill-color 0x0000000000000004=text-color @@ -291,26 +491,26 @@ flagslist=OCX-MORPH-PROPERTIES 0x0000000100000000=groupname end -shortlist=OCX-MORPH-SCROLLBARS,0,none,horizontal,vertical,both -shortlist=OCX-MORPH-CONTROLTYPE,1,edit,listbox,combobox,checkbox,optionbutton,togglebutton,dropdown-listbox -shortlist=OCX-MORPH-MATCHENTRYTYPE,0,first-letter,complete,none -shortlist=OCX-MORPH-LISTSTYLE,0,plain,with-buttons -shortlist=OCX-MORPH-SHOWDROPDOWNMODE,0,never,on-focus,always -shortlist=OCX-MORPH-DROPDOWNSTYLE,0,no-symbol,arrow,ellipsis,underline -shortlist=OCX-MORPH-SELECTIONTYPE,0,single,multi,range +shortlist=AX-MORPH-SCROLLBARS,0,none,horizontal,vertical,both +shortlist=AX-MORPH-CONTROLTYPE,1,edit,listbox,combobox,checkbox,optionbutton,togglebutton,dropdown-listbox +shortlist=AX-MORPH-MATCHENTRYTYPE,0,first-letter,complete,none +shortlist=AX-MORPH-LISTSTYLE,0,plain,with-buttons +shortlist=AX-MORPH-SHOWDROPDOWNMODE,0,never,on-focus,always +shortlist=AX-MORPH-DROPDOWNSTYLE,0,no-symbol,arrow,ellipsis,underline +shortlist=AX-MORPH-SELECTIONTYPE,0,single,multi,range -constlist=OCX-MORPH-BOUNDCOLUMN +constlist=AX-MORPH-BOUNDCOLUMN default= 0=value-is-row-index end -constlist=OCX-MORPH-TEXTCOLUMN +constlist=AX-MORPH-TEXTCOLUMN default= -1=first-column-with-width 0=row-numbers end -constlist=OCX-MORPH-COLUMNCOUNT +constlist=AX-MORPH-COLUMNCOUNT default= -1=all-columns end @@ -319,7 +519,7 @@ end {978C9E23-D4B0-11CE-BF2D-00AA003F40D0}=Forms.Label.1 -flagslist=OCX-LABEL-PROPERTIES +flagslist=AX-LABEL-PROPERTIES 0x00000001=text-color 0x00000002=fill-color 0x00000004=flags @@ -339,7 +539,7 @@ end {4C599241-6926-101B-9992-00000B65C6F9}=Forms.Image.1 -flagslist=OCX-IMAGE-PROPERTIES +flagslist=AX-IMAGE-PROPERTIES 0x00000004=auto-size 0x00000008=border-color 0x00000010=fill-color @@ -359,7 +559,7 @@ end {DFD181E0-5E2F-11CE-A449-00AA004A803D}=Forms.ScrollBar.1 -flagslist=OCX-SCROLLBAR-PROPERTIES +flagslist=AX-SCROLLBAR-PROPERTIES 0x00000001=arrow-color 0x00000002=fill-color 0x00000004=flags @@ -379,13 +579,13 @@ flagslist=OCX-SCROLLBAR-PROPERTIES 0x00010000=mouse-icon end -shortlist=OCX-SCROLLBAR-PROPTHUMB,-1,proportional,fixed +shortlist=AX-SCROLLBAR-PROPTHUMB,-1,proportional,fixed # spin button ---------------------------------------------------------------- {79176FB0-B7F2-11CE-97EF-00AA006D2776}=Forms.SpinButton.1 -flagslist=OCX-SPINBUTTON-PROPERTIES +flagslist=AX-SPINBUTTON-PROPERTIES 0x00000001=arrow-color 0x00000002=fill-color 0x00000004=flags @@ -407,7 +607,7 @@ end {EAE50EB0-4A62-11CE-BED6-00AA00611080}=Forms.TabStrip.1 -flagslist=OCX-TABSTRIP-PROPERTIES +flagslist=AX-TABSTRIP-PROPERTIES 0x00000001=selected-tab 0x00000002=fill-color 0x00000004=text-color @@ -431,40 +631,19 @@ flagslist=OCX-TABSTRIP-PROPERTIES 0x01000000=mouse-icon end -shortlist=OCX-TABSTRIP-ORIENTATION,0,top,bottom,left,right -shortlist=OCX-TABSTRIP-TABSTYLE,0,tabs,buttons,none +shortlist=AX-TABSTRIP-ORIENTATION,0,top,bottom,left,right +shortlist=AX-TABSTRIP-TABSTYLE,0,tabs,buttons,none -flagslist=OCX-TABSTRIP-FLAGS +flagslist=AX-TABSTRIP-FLAGS 0x00000001=visible 0x00000002=enabled end -# frame ---------------------------------------------------------------------- - -{6E182020-F460-11CE-9BCD-00AA00608E01}=Forms.Frame.1 - -# page ----------------------------------------------------------------------- - -flagslist=OCX-PAGE-PROPERTIES - 0x00000002=transition-effect - 0x00000004=transition-period -end - -shortlist=OCX-PAGE-TRANSITIONEFFECT,0,none,cover-up,cover-right-up,cover-right,cover-right-down,cover-down,cover-left-down,cover-left,cover-left-up,push-up,push-right,push-down,push-left - -# multi page ----------------------------------------------------------------- - -{46E31370-3F7A-11CE-BED6-00AA00611080}=Forms.MultiPage.1 - -flagslist=OCX-MULTIPAGE-PROPERTIES - 0x00000002=page-count - 0x00000004=id - 0x00000008=enabled -end +# VBA forms ================================================================== # form class info ------------------------------------------------------------ -flagslist=OCX-CLASSINFO-PROPERTIES +flagslist=VBA-CLASSINFO-PROPERTIES 0x00000001=class-id 0x00000002=disp-event 0x00000008=default-prog @@ -481,18 +660,18 @@ flagslist=OCX-CLASSINFO-PROPERTIES 0x00004000=set-rowset end -combilist=OCX-CLASSINFO-FLAGS - 0x0000FFFF=uint16,hex,classtable-flags,OCX-CLASSTABLE-CLASSFLAGS - 0xFFFF0000=uint16,hex,var-flags,OCX-CLASSTABLE-VARFLAGS +combilist=VBA-CLASSINFO-FLAGS + 0x0000FFFF=uint16,hex,classtable-flags,VBA-CLASSTABLE-CLASSFLAGS + 0xFFFF0000=uint16,hex,var-flags,VBA-CLASSTABLE-VARFLAGS end -flagslist=OCX-CLASSTABLE-CLASSFLAGS +flagslist=VBA-CLASSTABLE-CLASSFLAGS 0x0001=exclusive-value 0x0002=dual-interface 0x0004=no-aggregation end -flagslist=OCX-CLASSTABLE-VARFLAGS +flagslist=VBA-CLASSTABLE-VARFLAGS 0x0001=read-only 0x0002=source 0x0004=bindable @@ -510,7 +689,7 @@ end # form site ------------------------------------------------------------------ -flagslist=OCX-FORMSITE-PROPERTIES +flagslist=VBA-FORMSITE-PROPERTIES 0x00000001=name 0x00000002=tag 0x00000004=id @@ -527,7 +706,7 @@ flagslist=OCX-FORMSITE-PROPERTIES 0x00004000=row-source end -flagslist=OCX-FORMSITE-FLAGS +flagslist=VBA-FORMSITE-FLAGS 0x00000001=tabstop 0x00000002=visible 0x00000004=default @@ -540,7 +719,18 @@ flagslist=OCX-FORMSITE-FLAGS 0x00040000=container end -constlist=OCX-FORMSITE-CLASSNAMES +combilist=VBA-FORMSITE-CLASSIDCACHE + 0x7FFF=uint16,dec,cache-idx,VBA-FORMSITE-CLASSIDCACHEINDEX,filter=0x8000~0x0000 + 0x7FFF=uint16,dec,class-table-idx,,filter=0x8000~0x8000 + 0x8000=!predefined-class-id!class-table-index +end + +constlist=VBA-FORMSITE-CLASSIDCACHEINDEX + include=VBA-FORMSITE-CLASSNAMES + 0x7FFF=invalid +end + +constlist=VBA-FORMSITE-CLASSNAMES 7=Forms.Form.1 12=Forms.Image.1 14=Forms.Frame.1 @@ -559,20 +749,9 @@ constlist=OCX-FORMSITE-CLASSNAMES 57=Forms.MultiPage.1 end -constlist=OCX-FORMSITE-CLASSIDCACHEINDEX - include=OCX-FORMSITE-CLASSNAMES - 0x7FFF=invalid -end - -combilist=OCX-FORMSITE-CLASSIDCACHE - 0x7FFF=uint16,dec,cache-idx,OCX-FORMSITE-CLASSIDCACHEINDEX,filter=0x8000~0x0000 - 0x7FFF=uint16,dec,class-table-idx,,filter=0x8000~0x8000 - 0x8000=!predefined-class-id!class-table-index -end - # form design extender ------------------------------------------------------ -flagslist=OCX-FORMDESIGNEXT-PROPERTIES +flagslist=VBA-FORMDESIGNEXT-PROPERTIES 0x00000001=flags 0x00000002=grid-x 0x00000004=grid-y @@ -580,7 +759,7 @@ flagslist=OCX-FORMDESIGNEXT-PROPERTIES 0x00000010=dblclick-control-mode end -flagslist=OCX-FORMDESIGNEXT-FLAGS +flagslist=VBA-FORMDESIGNEXT-FLAGS 0x00000001=inherit-design-mode 0x00000002=design-mode 0x00000004=inherit-show-toolbox @@ -601,14 +780,15 @@ flagslist=OCX-FORMDESIGNEXT-FLAGS 0x00020000=immediate-layout end -shortlist=OCX-FORMDESIGNEXT-CLICKCTRLMODE,-2,inherit,default,insertion-point,select-then-insert -shortlist=OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE,-2,inherit,,select-text,edit-code,edit-properties +shortlist=VBA-FORMDESIGNEXT-CLICKCTRLMODE,-2,inherit,default,insertion-point,select-then-insert +shortlist=VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE,-2,inherit,,select-text,edit-code,edit-properties # form ----------------------------------------------------------------------- {C62A69F0-16DC-11CE-9E98-00AA00574A4F}=Forms.Form.1 +{6E182020-F460-11CE-9BCD-00AA00608E01}=Forms.Frame.1 -flagslist=OCX-FORM-PROPERTIES +flagslist=VBA-FORM-PROPERTIES 0x00000002=fill-color 0x00000004=text-color 0x00000008=next-available-id @@ -635,13 +815,13 @@ flagslist=OCX-FORM-PROPERTIES 0x08000000=draw-buffer end -flagslist=OCX-FORM-FLAGS +flagslist=VBA-FORM-FLAGS 0x00000004=enabled 0x00004000=has-design-extender 0x00008000=!has-class-table!skip-class-table end -flagslist=OCX-FORM-SCROLLBARS +flagslist=VBA-FORM-SCROLLBARS 0x01=horizontal 0x02=vertical 0x04=keep-horizontal @@ -649,24 +829,43 @@ flagslist=OCX-FORM-SCROLLBARS 0x10=vertical-left end -shortlist=OCX-FORM-CYCLE,0,all-forms,,current-form +shortlist=VBA-FORM-CYCLE,0,all-forms,,current-form -combilist=OCX-FORM-SITE-TYPECOUNT +combilist=VBA-FORM-SITE-TYPECOUNT 0x7F=uint8,dec,type-count 0x80=!type!count end -# VBA name lists ============================================================= +# page ----------------------------------------------------------------------- + +flagslist=VBA-PAGE-PROPERTIES + 0x00000002=transition-effect + 0x00000004=transition-period +end + +shortlist=VBA-PAGE-TRANSITIONEFFECT,0,none,cover-up,cover-right-up,cover-right,cover-right-down,cover-down,cover-left-down,cover-left,cover-left-up,push-up,push-right,push-down,push-left + +# multi page ----------------------------------------------------------------- + +{46E31370-3F7A-11CE-BED6-00AA00611080}=Forms.MultiPage.1 + +flagslist=VBA-MULTIPAGE-PROPERTIES + 0x00000002=page-count + 0x00000004=id + 0x00000008=enabled +end + +# VBA project name lists ===================================================== multilist=VBA-DIR-RECORD-NAMES - 0x0000=,PROJECTSYSKIND,PROJECTLCID,PROJECTCODEPAGE,PROJECTNAME,PROJECTDOCSTRING,PROJECTHELPFILEPATH,PROJECTHELPCONTEXT + 0x0000=,PROJECTSYSKIND,PROJECTLCID,PROJECTCODEPAGE,PROJECTNAME,PROJECTDOCSTRING,PROJECTHELPFILEPATH1,PROJECTHELPCONTEXT 0x0008=PROJECTLIBFLAGS,PROJECTVERSION,,,PROJECTCONSTANTS,REFERENCEREGISTERED,REFERENCEPROJECT,PROJECTMODULES 0x0010=PROJECTEND,,,PROJECTCOOKIE,PROJECTLCIDINVOKE,,REFERENCENAME, 0x0018=,MODULENAME,MODULESTREAMNAME,,MODULEDOCSTRING,,MODULEHELPCONTEXT, - 0x0020=,PROCEDURALMODULE,DOCUMENTMODULE,,,MODULEREADONLY,, + 0x0020=,MODULETYPEPROCEDURAL,MODULETYPEDOCUMENT,,,MODULEREADONLY,, 0x0028=MODULEPRIVATE,,,MODULEEND,MODULECOOKIE,,,REFERENCECONTROL 0x0030=REFERENCEEXTENDED,MODULEOFFSET,MODULESTREAMNAMEUNICODE,REFERENCEORIGINAL,,,, - 0x0038=,,,,PROJECTCONSTANTSUNICODE,PROJECTHELPFILEPATHUNICODE,REFERENCENAMEUNICODE, + 0x0038=,,,,PROJECTCONSTANTSUNICODE,PROJECTHELPFILEPATH2,REFERENCENAMEUNICODE, 0x0040=PROJECTDOCSTRINGUNICODE,,,,,,,MODULENAMEUNICODE 0x0048=MODULEDOCSTRINGUNICODE,,,,,,, end diff --git a/oox/source/dump/pptxdumper.cxx b/oox/source/dump/pptxdumper.cxx index e58991dbecc9..e01d7d349855 100644 --- a/oox/source/dump/pptxdumper.cxx +++ b/oox/source/dump/pptxdumper.cxx @@ -26,8 +26,8 @@ ************************************************************************/ #include "oox/dump/pptxdumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/dump/biffdumper.hxx" #include "oox/dump/oledumper.hxx" #include "oox/dump/xlsbdumper.hxx" @@ -91,17 +91,18 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons { if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "ppt/embeddings" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "ppt/activeX" ) ) { - OcxGuidControlObject( *this, rxStrm, rSysFileName ).dump(); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, true ) ); + ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); } else { diff --git a/oox/source/dump/xlsbdumper.cxx b/oox/source/dump/xlsbdumper.cxx index a9674951225b..80fccddff2ea 100644 --- a/oox/source/dump/xlsbdumper.cxx +++ b/oox/source/dump/xlsbdumper.cxx @@ -30,9 +30,9 @@ #include "oox/dump/biffdumper.hxx" #include "oox/dump/oledumper.hxx" #include "oox/dump/pptxdumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/xls/biffhelper.hxx" #include "oox/xls/formulabase.hxx" #include "oox/xls/richstring.hxx" @@ -82,8 +82,8 @@ RecordObjectBase::~RecordObjectBase() void RecordObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - mxStrm.reset( new RecordInputStream( getRecordDataSequence() ) ); - SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); + mxBiffStrm.reset( new RecordInputStream( getRecordDataSequence() ) ); + SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxBiffStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); if( SequenceRecordObjectBase::implIsValid() ) mxErrCodes = cfg().getNameList( "ERRORCODES" ); } @@ -111,22 +111,22 @@ OUString RecordObjectBase::getErrorName( sal_uInt8 nErrCode ) const void RecordObjectBase::readAddress( Address& orAddress ) { - in() >> orAddress.mnRow >> orAddress.mnCol; + *mxStrm >> orAddress.mnRow >> orAddress.mnCol; } void RecordObjectBase::readRange( Range& orRange ) { - in() >> orRange.maFirst.mnRow >> orRange.maLast.mnRow >> orRange.maFirst.mnCol >> orRange.maLast.mnCol; + *mxStrm >> orRange.maFirst.mnRow >> orRange.maLast.mnRow >> orRange.maFirst.mnCol >> orRange.maLast.mnCol; } void RecordObjectBase::readRangeList( RangeList& orRanges ) { sal_Int32 nCount; - in() >> nCount; + *mxStrm >> nCount; if( nCount >= 0 ) { orRanges.resize( getLimitedValue< size_t, sal_Int32 >( nCount, 0, SAL_MAX_UINT16 ) ); - for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !in().isEof() && (aIt != aEnd); ++aIt ) + for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) readRange( *aIt ); } else @@ -150,11 +150,11 @@ void RecordObjectBase::writeFontPortions( const FontPortionModelList& rPortions if( !rPortions.empty() ) { writeDecItem( "font-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - IndentGuard aIndGuard( out() ); - TableGuard aTabGuard( out(), 14 ); + IndentGuard aIndGuard( mxOut ); + TableGuard aTabGuard( mxOut, 14 ); for( FontPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "font-id", aIt->mnFontId, "FONTNAMES" ); } @@ -166,11 +166,11 @@ void RecordObjectBase::writePhoneticPortions( const PhoneticPortionModelList& rP if( !rPortions.empty() ) { writeDecItem( "portion-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - IndentGuard aIndGuard( out() ); - TableGuard aTabGuard( out(), 14, 21 ); + IndentGuard aIndGuard( mxOut ); + TableGuard aTabGuard( mxOut, 14, 21 ); for( PhoneticPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "base-text-start", aIt->mnBasePos ); writeDecItem( "base-text-length", aIt->mnBaseLen ); @@ -183,7 +183,7 @@ void RecordObjectBase::writePhoneticPortions( const PhoneticPortionModelList& rP sal_uInt8 RecordObjectBase::dumpBoolean( const String& rName ) { sal_uInt8 nBool; - in() >> nBool; + *mxStrm >> nBool; writeBooleanItem( rName( "boolean" ), nBool ); return nBool; } @@ -191,7 +191,7 @@ sal_uInt8 RecordObjectBase::dumpBoolean( const String& rName ) sal_uInt8 RecordObjectBase::dumpErrorCode( const String& rName ) { sal_uInt8 nErrCode; - in() >> nErrCode; + *mxStrm >> nErrCode; writeErrorCodeItem( rName( "error-code" ), nErrCode ); return nErrCode; } @@ -200,25 +200,25 @@ OUString RecordObjectBase::dumpString( const String& rName, bool bRich, bool b32 { sal_uInt8 nFlags = bRich ? dumpHex< sal_uInt8 >( "flags", "STRING-FLAGS" ) : 0; - OUString aString = mxStrm->readString( b32BitLen ); + OUString aString = mxBiffStrm->readString( b32BitLen ); writeStringItem( rName( "text" ), aString ); // --- formatting --- if( getFlag( nFlags, OOBIN_STRINGFLAG_FONTS ) ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); FontPortionModelList aPortions; - aPortions.importPortions( *mxStrm ); + aPortions.importPortions( *mxBiffStrm ); writeFontPortions( aPortions ); } // --- phonetic text --- if( getFlag( nFlags, OOBIN_STRINGFLAG_PHONETICS ) ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpString( "phonetic-text" ); PhoneticPortionModelList aPortions; - aPortions.importPortions( *mxStrm ); + aPortions.importPortions( *mxBiffStrm ); writePhoneticPortions( aPortions ); dumpDec< sal_uInt16 >( "font-id", "FONTNAMES" ); dumpHex< sal_uInt16 >( "flags", "PHONETIC-FLAGS" ); @@ -229,7 +229,7 @@ OUString RecordObjectBase::dumpString( const String& rName, bool bRich, bool b32 void RecordObjectBase::dumpColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); switch( extractValue< sal_uInt8 >( dumpDec< sal_uInt8 >( "flags", "COLOR-FLAGS" ), 1, 7 ) ) { @@ -246,12 +246,12 @@ void RecordObjectBase::dumpColor( const String& rName ) DateTime RecordObjectBase::dumpPivotDateTime( const String& rName ) { DateTime aDateTime; - aDateTime.Year = in().readuInt16(); - aDateTime.Month = in().readuInt16(); - aDateTime.Day = in().readuInt8(); - aDateTime.Hours = in().readuInt8(); - aDateTime.Minutes = in().readuInt8(); - aDateTime.Seconds = in().readuInt8(); + aDateTime.Year = mxStrm->readuInt16(); + aDateTime.Month = mxStrm->readuInt16(); + aDateTime.Day = mxStrm->readuInt8(); + aDateTime.Hours = mxStrm->readuInt8(); + aDateTime.Minutes = mxStrm->readuInt8(); + aDateTime.Seconds = mxStrm->readuInt8(); writeDateTimeItem( rName, aDateTime ); return aDateTime; } @@ -259,7 +259,7 @@ DateTime RecordObjectBase::dumpPivotDateTime( const String& rName ) sal_Int32 RecordObjectBase::dumpColIndex( const String& rName ) { sal_Int32 nCol; - in() >> nCol; + *mxStrm >> nCol; writeColIndexItem( rName( "col-idx" ), nCol ); return nCol; } @@ -267,7 +267,7 @@ sal_Int32 RecordObjectBase::dumpColIndex( const String& rName ) sal_Int32 RecordObjectBase::dumpRowIndex( const String& rName ) { sal_Int32 nRow; - in() >> nRow; + *mxStrm >> nRow; writeRowIndexItem( rName( "row-idx" ), nRow ); return nRow; } @@ -275,7 +275,7 @@ sal_Int32 RecordObjectBase::dumpRowIndex( const String& rName ) sal_Int32 RecordObjectBase::dumpColRange( const String& rName ) { sal_Int32 nCol1, nCol2; - in() >> nCol1 >> nCol2; + *mxStrm >> nCol1 >> nCol2; writeColRangeItem( rName( "col-range" ), nCol1, nCol2 ); return nCol2 - nCol1 + 1; } @@ -283,7 +283,7 @@ sal_Int32 RecordObjectBase::dumpColRange( const String& rName ) sal_Int32 RecordObjectBase::dumpRowRange( const String& rName ) { sal_Int32 nRow1, nRow2; - in() >> nRow1 >> nRow2; + *mxStrm >> nRow1 >> nRow2; writeRowRangeItem( rName( "row-range" ), nRow1, nRow2 ); return nRow2 - nRow1 + 1; } @@ -363,26 +363,25 @@ void FormulaObject::dumpNameFormula( const String& rName ) void FormulaObject::implDump() { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize < 0 ) return; - BinaryInputStream& rStrm = in(); - sal_Int64 nStartPos = rStrm.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); + sal_Int64 nStartPos = mxStrm->tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, mxStrm->getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); maAddData.clear(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); { - TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && (rStrm.tell() < nEndPos) ) + TableGuard aTabGuard( mxOut, 8, 18 ); + while( bValid && (mxStrm->tell() < nEndPos) ) { - MultiItemsGuard aMultiGuard( out() ); - writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( mxStrm->tell() - nStartPos ) ); sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) @@ -457,7 +456,7 @@ void FormulaObject::implDump() } } - if( nEndPos == rStrm.tell() ) + if( nEndPos == mxStrm->tell() ) { dumpAddTokenData(); if( mnSize > 0 ) @@ -468,7 +467,7 @@ void FormulaObject::implDump() } else { - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - rStrm.tell() ), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - mxStrm->tell() ), false ); sal_Int32 nAddDataSize = dumpDec< sal_Int32 >( "add-data-size" ); dumpBinary( "add-data", nAddDataSize, false ); } @@ -479,7 +478,7 @@ void FormulaObject::implDump() void FormulaObject::dumpFormula( const String& rName, bool bNameMode ) { maName = rName( "formula" ); - in() >> mnSize; + *mxStrm >> mnSize; mbNameMode = bNameMode; dump(); } @@ -565,7 +564,7 @@ OUString FormulaObject::createPlaceHolder() const OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { - ItemGuard aItemGuard( out(), "func-id" ); + ItemGuard aItem( mxOut, "func-id" ); writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromOobFuncId( nFuncId ); @@ -578,10 +577,10 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* StringHelper::appendIndex( aBuffer, nFuncId & BIFF_TOK_FUNCVAR_FUNCIDMASK ); } OUString aFuncName = aBuffer.makeStringAndClear(); - aItemGuard.cont(); - out().writeChar( OOX_DUMP_STRQUOTE ); - out().writeString( aFuncName ); - out().writeChar( OOX_DUMP_STRQUOTE ); + aItem.cont(); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeString( aFuncName ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } @@ -641,13 +640,13 @@ OUString FormulaObject::dumpTokenRefId() void FormulaObject::dumpIntToken() { dumpDec< sal_uInt16 >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpDoubleToken() { dumpDec< double >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpStringToken() @@ -660,13 +659,13 @@ void FormulaObject::dumpStringToken() void FormulaObject::dumpBoolToken() { dumpBoolean( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpErrorToken() { dumpErrorCode( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpMissArgToken() @@ -698,14 +697,14 @@ void FormulaObject::dumpRefToken( const OUString& rTokClass, bool bNameMode ) { TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddressItem( "addr", aPos, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpAreaToken( const OUString& rTokClass, bool bNameMode ) { TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRangeItem( "range", aRange, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpRefErrToken( const OUString& rTokClass, bool bArea ) @@ -719,7 +718,7 @@ void FormulaObject::dumpRef3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefId(); TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddress3dItem( "addr", aRef, aPos, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) @@ -727,7 +726,7 @@ void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefId(); TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRange3dItem( "range", aRef, aRange, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpRefErr3dToken( const OUString& rTokClass, bool bArea ) @@ -755,7 +754,7 @@ void FormulaObject::dumpExpToken( const String& rName ) Address aPos; dumpRowIndex( "base-row" ); OUStringBuffer aOp( rName ); - StringHelper::appendIndex( aOp, createPlaceHolder() + out().getLastItemValue() ); + StringHelper::appendIndex( aOp, createPlaceHolder() + mxOut->getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); maAddData.push_back( ADDDATA_EXP ); } @@ -773,7 +772,7 @@ void FormulaObject::dumpBinaryOpToken( const String& rOp ) void FormulaObject::dumpFuncToken( const OUString& rTokClass ) { sal_uInt16 nFuncId; - in() >> nFuncId; + *mxStrm >> nFuncId; const FunctionInfo* pFuncInfo = 0; OUString aFuncName = writeFuncIdItem( nFuncId, &pFuncInfo ); if( pFuncInfo && (pFuncInfo->mnMinParamCount == pFuncInfo->mnMaxParamCount) ) @@ -786,7 +785,7 @@ void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) { sal_uInt8 nParamCount; sal_uInt16 nFuncId; - in() >> nParamCount >> nFuncId; + *mxStrm >> nParamCount >> nFuncId; bool bCmd = getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ); if( bCmd ) writeHexItem( "param-count", nParamCount, "PARAMCOUNT-CMD" ); @@ -803,24 +802,23 @@ void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) bool FormulaObject::dumpTableToken() { - Output& rOut = out(); dumpUnused( 3 ); sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "TABLEFLAGS" ); sal_uInt16 nTabId = dumpDec< sal_uInt16 >( "table-id" ); dumpUnused( 2 ); { sal_uInt16 nCol1, nCol2; - in() >> nCol1 >> nCol2; - ItemGuard aItem( rOut, "cols" ); - rOut.writeDec( nCol1 ); + *mxStrm >> nCol1 >> nCol2; + ItemGuard aItem( mxOut, "cols" ); + mxOut->writeDec( nCol1 ); if( nCol1 != nCol2 ) { - rOut.writeChar( OOX_DUMP_RANGESEP ); - rOut.writeDec( nCol2 ); + mxOut->writeChar( OOX_DUMP_RANGESEP ); + mxOut->writeDec( nCol2 ); } } OUStringBuffer aColRange; - StringHelper::appendIndex( aColRange, rOut.getLastItemValue() ); + StringHelper::appendIndex( aColRange, mxOut->getLastItemValue() ); OUStringBuffer aParams; size_t nParams = 0; if( getFlag( nFlags, OOBIN_TOK_TABLE_ALL ) && ++nParams ) @@ -860,7 +858,7 @@ bool FormulaObject::dumpAttrToken() case OOBIN_TOK_ATTR_CHOOSE: { sal_uInt16 nCount = dumpDec< sal_uInt16 >( "choices" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) dumpDec< sal_uInt16 >( "#skip" ); dumpDec< sal_uInt16 >( "skip-err" ); @@ -892,27 +890,25 @@ bool FormulaObject::dumpAttrToken() void FormulaObject::dumpAddTokenData() { - Output& rOut = out(); - rOut.resetItemIndex(); - BinaryInputStream& rStrm = in(); - sal_Int32 nAddDataSize = (in().getLength() - in().tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; - sal_Int64 nEndPos = ::std::min< sal_Int64 >( rStrm.tell() + nAddDataSize, rStrm.getLength() ); - for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && !rStrm.isEof() && (rStrm.tell() < nEndPos); ++aIt ) + mxOut->resetItemIndex(); + sal_Int32 nAddDataSize = (mxStrm->getLength() - mxStrm->tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; + sal_Int64 nEndPos = ::std::min< sal_Int64 >( mxStrm->tell() + nAddDataSize, mxStrm->getLength() ); + for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && !mxStrm->isEof() && (mxStrm->tell() < nEndPos); ++aIt ) { AddDataType eType = *aIt; { - ItemGuard aItem( rOut, "#add-data" ); + ItemGuard aItem( mxOut, "#add-data" ); switch( eType ) { - case ADDDATA_EXP: rOut.writeAscii( "tExp" ); break; - case ADDDATA_ARRAY: rOut.writeAscii( "tArray" ); break; - case ADDDATA_MEMAREA: rOut.writeAscii( "tMemArea" ); break; + case ADDDATA_EXP: mxOut->writeAscii( "tExp" ); break; + case ADDDATA_ARRAY: mxOut->writeAscii( "tArray" ); break; + case ADDDATA_MEMAREA: mxOut->writeAscii( "tMemArea" ); break; } } size_t nIdx = aIt - maAddData.begin(); - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( eType ) { case ADDDATA_EXP: dumpAddDataExp( nIdx ); break; @@ -926,7 +922,7 @@ void FormulaObject::dumpAddTokenData() void FormulaObject::dumpAddDataExp( size_t nIdx ) { dumpColIndex( "base-col" ); - mxStack->replaceOnTop( createPlaceHolder( nIdx ), out().getLastItemValue() ); + mxStack->replaceOnTop( createPlaceHolder( nIdx ), mxOut->getLastItemValue() ); } void FormulaObject::dumpAddDataArray( size_t nIdx ) @@ -935,7 +931,7 @@ void FormulaObject::dumpAddDataArray( size_t nIdx ) dumpaddDataArrayHeader( nCols, nRows ); OUStringBuffer aOp; - TableGuard aTabGuard( out(), 17 ); + TableGuard aTabGuard( mxOut, 17 ); for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) { OUStringBuffer aArrayLine; @@ -954,28 +950,26 @@ void FormulaObject::dumpAddDataMemArea( size_t /*nIdx*/ ) void FormulaObject::dumpaddDataArrayHeader( sal_Int32& rnCols, sal_Int32& rnRows ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); rnRows = dumpDec< sal_Int32 >( "height" ); rnCols = dumpDec< sal_Int32 >( "width" ); - ItemGuard aItem( rOut, "size" ); - rOut.writeDec( rnCols ); - rOut.writeChar( 'x' ); - rOut.writeDec( rnRows ); + ItemGuard aItem( mxOut, "size" ); + mxOut->writeDec( rnCols ); + mxOut->writeChar( 'x' ); + mxOut->writeDec( rnRows ); aItem.cont(); - rOut.writeDec( rnCols * rnRows ); + mxOut->writeDec( rnCols * rnRows ); } OUString FormulaObject::dumpaddDataArrayValue() { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); OUStringBuffer aValue; switch( dumpDec< sal_uInt8 >( "type", "ARRAYVALUE-TYPE" ) ) { case OOBIN_TOK_ARRAY_DOUBLE: dumpDec< double >( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case OOBIN_TOK_ARRAY_STRING: aValue.append( dumpString( "value", false, false ) ); @@ -983,11 +977,11 @@ OUString FormulaObject::dumpaddDataArrayValue() break; case OOBIN_TOK_ARRAY_BOOL: dumpBoolean( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case OOBIN_TOK_ARRAY_ERROR: dumpErrorCode( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 3 ); break; } @@ -1150,11 +1144,11 @@ void RecordStreamObject::implDumpRecordBody() dumpDec< sal_Int32 >( "formula2-size" ); dumpDec< sal_Int32 >( "formula3-size" ); dumpString( "text" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula1" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula2" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula3" ); } break; @@ -1272,10 +1266,10 @@ void RecordStreamObject::implDumpRecordBody() dumpString( "name" ); mxFmlaObj->dumpNameFormula(); dumpString( "comment" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "menu-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "description-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "help-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "statusbar-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "menu-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "description-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "help-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "statusbar-text" ); break; case OOBIN_ID_DIMENSION: @@ -1288,16 +1282,16 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_DXF: dumpHex< sal_uInt32 >( "flags", "DXF-FLAGS" ); - for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !in().isEof() && (nIndex < nCount); ++nIndex ) + for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !mxStrm->isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); - sal_Int64 nStartPos = in().tell(); + mxOut->startMultiItems(); + sal_Int64 nStartPos = mxStrm->tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "DXF-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 0: @@ -1438,11 +1432,11 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_EXTERNALSHEETS: { sal_Int32 nCount = dumpDec< sal_Int32 >( "ref-count" ); - TableGuard aTabGuard( out(), 13, 17, 24 ); - out().resetItemIndex(); - for( sal_Int32 nRefId = 0; !in().isEof() && (nRefId < nCount); ++nRefId ) + TableGuard aTabGuard( mxOut, 13, 17, 24 ); + mxOut->resetItemIndex(); + for( sal_Int32 nRefId = 0; !mxStrm->isEof() && (nRefId < nCount); ++nRefId ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#ref" ); dumpDec< sal_Int32 >( "extref-id" ); dumpDec< sal_Int32 >( "first-sheet", "EXTERNALSHEETS-ID" ); @@ -1461,8 +1455,8 @@ void RecordStreamObject::implDumpRecordBody() break; case OOBIN_ID_EXTSHEETNAMES: - out().resetItemIndex(); - for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); !in().isEof() && (nSheet < nCount); ++nSheet ) + mxOut->resetItemIndex(); + for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); !mxStrm->isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); break; @@ -1477,11 +1471,11 @@ void RecordStreamObject::implDumpRecordBody() dumpColor( "fg-color" ); dumpColor( "bg-color" ); dumpGradientHead(); - out().resetItemIndex(); - for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !in().isEof(); ++nStop ) + mxOut->resetItemIndex(); + for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !mxStrm->isEof(); ++nStop ) { writeEmptyItem( "#stop" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpColor( "stop-color" ); dumpDec< double >( "stop-position" ); } @@ -1739,7 +1733,7 @@ void RecordStreamObject::implDumpRecordBody() { sal_uInt16 nType = dumpDec< sal_uInt16 >( "type", "PCITEM_ARRAY-TYPE" ); sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx ) { switch( nType ) @@ -1839,8 +1833,8 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_PTCOLFIELDS: dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); - while( in().getRemaining() >= 4 ) + mxOut->resetItemIndex(); + while( mxStrm->getRemaining() >= 4 ) dumpDec< sal_Int32 >( "#field", "PT-FIELDINDEX" ); break; @@ -1948,8 +1942,8 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_PTROWFIELDS: dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); - while( in().getRemaining() >= 4 ) + mxOut->resetItemIndex(); + while( mxStrm->getRemaining() >= 4 ) dumpDec< sal_Int32 >( "#field", "PT-FIELDINDEX" ); break; @@ -1959,8 +1953,8 @@ void RecordStreamObject::implDumpRecordBody() dumpDec< sal_uInt16 >( "height", "CONV-TWIP-TO-PT" ); dumpHex< sal_uInt16 >( "flags", "ROW-FLAGS1" ); dumpHex< sal_uInt8 >( "flags", "ROW-FLAGS2" ); - out().resetItemIndex(); - for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); !in().isEof() && (nSpan < nSpanCount); ++nSpan ) + mxOut->resetItemIndex(); + for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); !mxStrm->isEof() && (nSpan < nSpanCount); ++nSpan ) dumpRowRange( "#row-spans" ); break; @@ -2205,12 +2199,12 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons { if( rStrgPath.equalsAscii( "xl" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "xl/embeddings" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( @@ -2228,7 +2222,8 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons } else if( rStrgPath.equalsAscii( "xl/activeX" ) ) { - OcxGuidControlObject( *this, rxStrm, rSysFileName ).dump(); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, true ) ); + ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); } else { diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 5ba4a8b0b73b..9ca6938f2ff1 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -30,6 +30,7 @@ #include #include #include +#include "oox/helper/binaryoutputstream.hxx" using ::rtl::OString; using ::rtl::OStringBuffer; @@ -102,6 +103,25 @@ OUString BinaryInputStream::readUnicodeArray( sal_Int32 nChars, bool bAllowNulCh return aBuffer.makeStringAndClear(); } +void BinaryInputStream::copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes ) +{ + if( nBytes > 0 ) + { + sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, INPUTSTREAM_BUFFERSIZE ); + StreamDataSequence aBuffer( nBufferSize ); + while( nBytes > 0 ) + { + sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); + sal_Int32 nBytesRead = readData( aBuffer, nReadSize ); + rOutStrm.writeData( aBuffer ); + if( nReadSize == nBytesRead ) + nBytes -= nReadSize; + else + nBytes = 0; + } + } +} + void BinaryInputStream::readAtom( void* opMem, sal_uInt8 nSize ) { readMemory( opMem, nSize ); @@ -214,7 +234,7 @@ sal_Int32 SequenceInputStream::readMemory( void* opMem, sal_Int32 nBytes ) sal_Int32 nReadBytes = 0; if( !mbEof ) { - nReadBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + nReadBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos ); if( nReadBytes > 0 ) memcpy( opMem, mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) ); mnPos += nReadBytes; @@ -227,7 +247,7 @@ void SequenceInputStream::skip( sal_Int32 nBytes ) { if( !mbEof ) { - sal_Int32 nSkipBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos ); mnPos += nSkipBytes; mbEof = nSkipBytes < nBytes; } @@ -235,5 +255,78 @@ void SequenceInputStream::skip( sal_Int32 nBytes ) // ============================================================================ +RelativeInputStream::RelativeInputStream( BinaryInputStream& rInStrm, sal_Int64 nLength ) : + mrInStrm( rInStrm ), + mnStartPos( rInStrm.tell() ), + mnRelPos( 0 ) +{ + sal_Int64 nRemaining = rInStrm.getRemaining(); + mnLength = (nRemaining >= 0) ? ::std::min( nLength, nRemaining ) : nLength; + mbEof = mnLength < 0; +} + +bool RelativeInputStream::isSeekable() const +{ + return mrInStrm.isSeekable(); +} + +sal_Int64 RelativeInputStream::getLength() const +{ + return mnLength; +} + +sal_Int64 RelativeInputStream::tell() const +{ + return mnRelPos; +} + +void RelativeInputStream::seek( sal_Int64 nPos ) +{ + if( mrInStrm.isSeekable() && (mnStartPos >= 0) ) + { + mnRelPos = getLimitedValue< sal_Int64, sal_Int64 >( nPos, 0, mnLength ); + mrInStrm.seek( mnStartPos + mnRelPos ); + mbEof = (mnRelPos != nPos) || mrInStrm.isEof(); + } +} + +sal_Int32 RelativeInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + sal_Int32 nRealBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + nReadBytes = mrInStrm.readData( orData, nRealBytes ); + mnRelPos += nReadBytes; + mbEof = (nRealBytes < nBytes) || mrInStrm.isEof(); + } + return nReadBytes; +} + +sal_Int32 RelativeInputStream::readMemory( void* opMem, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + sal_Int32 nRealBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + nReadBytes = mrInStrm.readMemory( opMem, nRealBytes ); + mnRelPos += nReadBytes; + mbEof = (nRealBytes < nBytes) || mrInStrm.isEof(); + } + return nReadBytes; +} + +void RelativeInputStream::skip( sal_Int32 nBytes ) +{ + if( !mbEof ) + { + sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + mnRelPos += nSkipBytes; + mbEof = nSkipBytes < nBytes; + } +} + +// ============================================================================ + } // namespace oox diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index be6bc6d67577..f39ac9d8f1b2 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -27,7 +27,6 @@ #include "oox/helper/binaryoutputstream.hxx" #include -#include "oox/helper/binaryinputstream.hxx" #include using ::com::sun::star::uno::UNO_QUERY; @@ -42,25 +41,6 @@ const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000; // ============================================================================ -void BinaryOutputStream::copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes ) -{ - if( nBytes > 0 ) - { - sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE ); - StreamDataSequence aBuffer( nBufferSize ); - while( nBytes > 0 ) - { - sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); - sal_Int32 nBytesRead = rInStrm.readData( aBuffer, nReadSize ); - writeData( aBuffer ); - if( nReadSize == nBytesRead ) - nBytes -= nReadSize; - else - nBytes = 0; - } - } -} - void BinaryOutputStream::writeAtom( const void* pMem, sal_uInt8 nSize ) { writeMemory( pMem, nSize ); diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index be6b17d3aab9..86eae793a3c1 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -61,7 +61,24 @@ void BinaryStreamBase::seek( sal_Int64 ) sal_Int64 BinaryStreamBase::getRemaining() const { - return isSeekable() ? ::std::max< sal_Int64 >( getLength() - tell(), 0 ) : -1; + // do not use isSeekable(), implementations may provide stream position and size even if not seekable + sal_Int64 nPos = tell(); + sal_Int64 nLen = getLength(); + return ((nPos >= 0) && (nLen >= 0)) ? ::std::max< sal_Int64 >( nLen - nPos, 0 ) : -1; +} + +void BinaryStreamBase::align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) +{ + sal_Int64 nStrmPos = tell(); + // nothing to do, if stream is at anchor position + if( isSeekable() && (0 <= nAnchorPos) && (nAnchorPos != nStrmPos) && (nBlockSize > 1) ) + { + // prevent modulo with negative arguments... + sal_Int64 nSkipSize = (nAnchorPos < nStrmPos) ? + (nBlockSize - ((nStrmPos - nAnchorPos - 1) % nBlockSize) - 1) : + ((nAnchorPos - nStrmPos) % nBlockSize); + seek( nStrmPos + nSkipSize ); + } } // ============================================================================ @@ -135,7 +152,7 @@ sal_Int64 SequenceSeekableStream::tell() const void SequenceSeekableStream::seek( sal_Int64 nPos ) { mnPos = getLimitedValue< sal_Int32, sal_Int64 >( nPos, 0, mrData.getLength() ); - mbEof = mnPos < nPos; + mbEof = mnPos != nPos; } // ============================================================================ diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 3e54cd16c2bc..6e57ac8f2b2f 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -26,42 +26,236 @@ ************************************************************************/ #include "oox/helper/graphichelper.hxx" +#include +#include +#include +#include +#include #include #include +#include #include #include +#include "tokens.hxx" +#include "oox/helper/containerhelper.hxx" using ::rtl::OUString; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::awt::DeviceInfo; +using ::com::sun::star::awt::Point; +using ::com::sun::star::awt::Size; +using ::com::sun::star::awt::XDevice; +using ::com::sun::star::awt::XUnitConversion; using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::io::XInputStream; -using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::frame::XFramesSupplier; using ::com::sun::star::graphic::GraphicObject; using ::com::sun::star::graphic::XGraphic; using ::com::sun::star::graphic::XGraphicObject; using ::com::sun::star::graphic::XGraphicProvider; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; namespace oox { // ============================================================================ -GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxFactory ) : - mxGraphicProvider( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), +namespace { + +inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm ) +{ + return static_cast< sal_Int32 >( (fPixelPerHmm > 0.0) ? (fPixel / fPixelPerHmm + 0.5) : 0.0 ); +} + +} // namespace + +// ============================================================================ + +GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory ) : + mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) ) { - ::comphelper::ComponentContext aContext( rxFactory ); + ::comphelper::ComponentContext aContext( rxGlobalFactory ); mxCompContext = aContext.getUNOContext(); + + //! TODO: get colors from system + maSystemPalette[ XML_3dDkShadow ] = 0x716F64; + maSystemPalette[ XML_3dLight ] = 0xF1EFE2; + maSystemPalette[ XML_activeBorder ] = 0xD4D0C8; + maSystemPalette[ XML_activeCaption ] = 0x0054E3; + maSystemPalette[ XML_appWorkspace ] = 0x808080; + maSystemPalette[ XML_background ] = 0x004E98; + maSystemPalette[ XML_btnFace ] = 0xECE9D8; + maSystemPalette[ XML_btnHighlight ] = 0xFFFFFF; + maSystemPalette[ XML_btnShadow ] = 0xACA899; + maSystemPalette[ XML_btnText ] = 0x000000; + maSystemPalette[ XML_captionText ] = 0xFFFFFF; + maSystemPalette[ XML_gradientActiveCaption ] = 0x3D95FF; + maSystemPalette[ XML_gradientInactiveCaption ] = 0xD8E4F8; + maSystemPalette[ XML_grayText ] = 0xACA899; + maSystemPalette[ XML_highlight ] = 0x316AC5; + maSystemPalette[ XML_highlightText ] = 0xFFFFFF; + maSystemPalette[ XML_hotLight ] = 0x000080; + maSystemPalette[ XML_inactiveBorder ] = 0xD4D0C8; + maSystemPalette[ XML_inactiveCaption ] = 0x7A96DF; + maSystemPalette[ XML_inactiveCaptionText ] = 0xD8E4F8; + maSystemPalette[ XML_infoBk ] = 0xFFFFE1; + maSystemPalette[ XML_infoText ] = 0x000000; + maSystemPalette[ XML_menu ] = 0xFFFFFF; + maSystemPalette[ XML_menuBar ] = 0xECE9D8; + maSystemPalette[ XML_menuHighlight ] = 0x316AC5; + maSystemPalette[ XML_menuText ] = 0x000000; + maSystemPalette[ XML_scrollBar ] = 0xD4D0C8; + maSystemPalette[ XML_window ] = 0xFFFFFF; + maSystemPalette[ XML_windowFrame ] = 0x000000; + maSystemPalette[ XML_windowText ] = 0x000000; + + // get the metric of the output device + if( rxGlobalFactory.is() ) try + { + Reference< XFramesSupplier > xFramesSupp( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); + Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); + Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); + mxUnitConversion.set( xDevice, UNO_QUERY ); + maDeviceInfo = xDevice->getInfo(); + mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; + mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; + } + catch( Exception& ) + { + OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); + } } GraphicHelper::~GraphicHelper() { } -Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) +sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const +{ + const sal_Int32* pnColor = ContainerHelper::getMapElement( maSystemPalette, nToken ); + return pnColor ? *pnColor : nDefaultRgb; +} + +sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const +{ + OSL_ENSURE( false, "GraphicHelper::getSchemeColor - scheme colors not implemented" ); + return API_RGB_TRANSPARENT; +} + +sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const +{ + OSL_ENSURE( false, "GraphicHelper::getPaletteColor - palette colors not implemented" ); + return API_RGB_TRANSPARENT; +} + +const DeviceInfo& GraphicHelper::getDeviceInfo() const +{ + return maDeviceInfo; +} + +sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const +{ + return lclConvertScreenPixelToHmm( fPixelX, mfPixelPerHmmX ); +} + +sal_Int32 GraphicHelper::convertScreenPixelYToHmm( double fPixelY ) const +{ + return lclConvertScreenPixelToHmm( fPixelY, mfPixelPerHmmY ); +} + +Point GraphicHelper::convertScreenPixelToHmm( const Point& rPixel ) const +{ + return Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) ); +} + +Size GraphicHelper::convertScreenPixelToHmm( const Size& rPixel ) const +{ + return Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) ); +} + +double GraphicHelper::convertHmmToScreenPixelX( sal_Int32 nHmmX ) const +{ + return nHmmX * mfPixelPerHmmX; +} + +double GraphicHelper::convertHmmToScreenPixelY( sal_Int32 nHmmY ) const +{ + return nHmmY * mfPixelPerHmmY; +} + +Point GraphicHelper::convertHmmToScreenPixel( const Point& rHmm ) const +{ + return Point( + static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.X ) + 0.5 ), + static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Y ) + 0.5 ) ); +} + +Size GraphicHelper::convertHmmToScreenPixel( const Size& rHmm ) const +{ + return Size( + static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.Width ) + 0.5 ), + static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Height ) + 0.5 ) ); +} + +Point GraphicHelper::convertAppFontToHmm( const Point& rAppFont ) const +{ + if( mxUnitConversion.is() ) try + { + Point aPixel = mxUnitConversion->convertPointToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); + return convertScreenPixelToHmm( aPixel ); + } + catch( Exception& ) + { + } + return Point( 0, 0 ); +} + +Size GraphicHelper::convertAppFontToHmm( const Size& rAppFont ) const +{ + if( mxUnitConversion.is() ) try + { + Size aPixel = mxUnitConversion->convertSizeToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); + return convertScreenPixelToHmm( aPixel ); + } + catch( Exception& ) + { + } + return Size( 0, 0 ); +} + +Point GraphicHelper::convertHmmToAppFont( const Point& rHmm ) const +{ + if( mxUnitConversion.is() ) try + { + Point aPixel = convertHmmToScreenPixel( rHmm ); + return mxUnitConversion->convertPointToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); + } + catch( Exception& ) + { + } + return Point( 0, 0 ); +} + +Size GraphicHelper::convertHmmToAppFont( const Size& rHmm ) const +{ + if( mxUnitConversion.is() ) try + { + Size aPixel = convertHmmToScreenPixel( rHmm ); + return mxUnitConversion->convertSizeToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); + } + catch( Exception& ) + { + } + return Size( 0, 0 ); +} + +Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) const { Reference< XGraphic > xGraphic; if( rxInStrm.is() && mxGraphicProvider.is() ) try @@ -77,7 +271,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea return xGraphic; } -Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) +Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) const { Reference< XGraphic > xGraphic; if( rGraphicData.hasElements() ) @@ -88,7 +282,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rG return xGraphic; } -OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) +OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) const { OUString aGraphicObjUrl; if( mxCompContext.is() && rxGraphic.is() ) try @@ -104,12 +298,12 @@ OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGrap return aGraphicObjUrl; } -OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) +OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) const { return createGraphicObject( importGraphic( rxInStrm ) ); } -OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) +OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) const { return createGraphicObject( importGraphic( rGraphicData ) ); } diff --git a/oox/source/helper/makefile.mk b/oox/source/helper/makefile.mk index 4a91a7a47764..3518db0c6d7c 100644 --- a/oox/source/helper/makefile.mk +++ b/oox/source/helper/makefile.mk @@ -48,12 +48,12 @@ SLOFILES = \ $(SLO)$/containerhelper.obj \ $(SLO)$/graphichelper.obj \ $(SLO)$/modelobjecthelper.obj \ - $(SLO)$/olestorage.obj \ $(SLO)$/progressbar.obj \ $(SLO)$/propertymap.obj \ $(SLO)$/propertyset.obj \ $(SLO)$/recordinputstream.obj \ $(SLO)$/storagebase.obj \ + $(SLO)$/textinputstream.obj \ $(SLO)$/zipstorage.obj # --- Targets ------------------------------------------------------- diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx index d1996991090a..6528fea5634d 100644 --- a/oox/source/helper/modelobjecthelper.cxx +++ b/oox/source/helper/modelobjecthelper.cxx @@ -44,11 +44,11 @@ namespace oox { // ============================================================================ -ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxFactory ) : - maMarkerContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), - maDashContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), - maGradientContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), - maBitmapContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), +ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxModelFactory ) : + maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), + maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), + maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), + maBitmapContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ), maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ), maBitmapNameBase( CREATE_OUSTRING( "msFillBitmap " ) ) diff --git a/oox/source/helper/olestorage.cxx b/oox/source/helper/olestorage.cxx deleted file mode 100644 index fe660b27ff2b..000000000000 --- a/oox/source/helper/olestorage.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/helper/olestorage.hxx" -#include -#include -#include -#include -#include -#include -#include "oox/helper/helper.hxx" - -using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::container::XNameAccess; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::embed::XStorage; -using ::com::sun::star::io::XInputStream; -using ::com::sun::star::io::XOutputStream; -using ::com::sun::star::io::XStream; - -namespace oox { - -// ============================================================================ - -OleStorage::OleStorage( - const Reference< XMultiServiceFactory >& rxFactory, - const Reference< XInputStream >& rxInStream, - bool bBaseStreamAccess ) : - StorageBase( rxInStream, bBaseStreamAccess ) -{ - OSL_ENSURE( rxFactory.is(), "OleStorage::OleStorage - missing service factory" ); - // create base storage object - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= rxInStream; - aArgs[ 1 ] <<= true; // true = do not create a copy of the input stream - mxStorage.set( rxFactory->createInstanceWithArguments( - CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY ); - mxElements.set( mxStorage, UNO_QUERY ); -} - -OleStorage::OleStorage( - const Reference< XMultiServiceFactory >& rxFactory, - const Reference< XStream >& rxStream, - bool bBaseStreamAccess ) : - StorageBase( rxStream, bBaseStreamAccess ) -{ - OSL_ENSURE( rxFactory.is(), "OleStorage::OleStorage - missing service factory" ); - (void)rxFactory; // prevent compiler warning - OSL_ENSURE( false, "OleStorage::OleStorage - not implemented" ); - mxElements.set( mxStorage, UNO_QUERY ); -} - -OleStorage::OleStorage( const OleStorage& rParentStorage, const Reference< XNameAccess >& rxElementsAccess, const OUString& rElementName ) : - StorageBase( rParentStorage, rElementName ), - mxStorage( rParentStorage.mxStorage ), - mxElements( rxElementsAccess ) -{ - OSL_ENSURE( mxElements.is(), "OleStorage::OleStorage - missing elements access" ); -} - -OleStorage::~OleStorage() -{ -} - -// StorageBase interface ------------------------------------------------------ - -bool OleStorage::implIsStorage() const -{ - if( mxStorage.is() && mxElements.is() ) try - { - /* If this is not a storage, hasElements() throws an exception. But we - do not return the result of hasElements(), because an empty storage - is a valid storage too. */ - mxElements->hasElements(); - return true; - } - catch( Exception& ) - { - } - return false; -} - -Reference< XStorage > OleStorage::implGetXStorage() const -{ - OSL_ENSURE( false, "OleStorage::getXStorage - not implemented" ); - return Reference< XStorage >(); -} - -void OleStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const -{ - Sequence< OUString > aNames; - if( mxElements.is() ) try - { - aNames = mxElements->getElementNames(); - if( aNames.getLength() > 0 ) - orElementNames.insert( orElementNames.end(), aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() ); - } - catch( Exception& ) - { - } -} - -StorageRef OleStorage::implOpenSubStorage( const OUString& rElementName, bool bCreate ) -{ - OSL_ENSURE( !bCreate, "OleStorage::implOpenSubStorage - creating substorages not implemented" ); - (void)bCreate; // prevent compiler warning - StorageRef xSubStorage; - if( mxElements.is() ) try - { - Reference< XNameAccess > xSubElements( mxElements->getByName( rElementName ), UNO_QUERY_THROW ); - xSubStorage.reset( new OleStorage( *this, xSubElements, rElementName ) ); - } - catch( Exception& ) - { - } - return xSubStorage; -} - -Reference< XInputStream > OleStorage::implOpenInputStream( const OUString& rElementName ) -{ - Reference< XInputStream > xInStream; - if( mxElements.is() ) try - { - xInStream.set( mxElements->getByName( rElementName ), UNO_QUERY ); - } - catch( Exception& ) - { - } - return xInStream; -} - -Reference< XOutputStream > OleStorage::implOpenOutputStream( const OUString& rElementName ) -{ - Reference< XOutputStream > xOutStream; - if( mxElements.is() && (rElementName.getLength() > 0) ) try - { - (void)rElementName; // prevent compiler warning - OSL_ENSURE( false, "OleStorage::implOpenOutputStream - not implemented" ); - } - catch( Exception& ) - { - } - return xOutStream; -} - -// ============================================================================ - -} // namespace oox - diff --git a/oox/source/helper/propertyset.cxx b/oox/source/helper/propertyset.cxx index 5477224b9461..c52872e50f2f 100644 --- a/oox/source/helper/propertyset.cxx +++ b/oox/source/helper/propertyset.cxx @@ -57,6 +57,12 @@ bool PropertySet::getAnyProperty( Any& orValue, sal_Int32 nPropId ) const return getAnyProperty( orValue, PropertyMap::getPropertyName( nPropId ) ); } +Any PropertySet::getAnyProperty( sal_Int32 nPropId ) const +{ + Any aValue; + return getAnyProperty( aValue, nPropId ) ? aValue : Any(); +} + bool PropertySet::getBoolProperty( sal_Int32 nPropId ) const { Any aAny; @@ -66,18 +72,17 @@ bool PropertySet::getBoolProperty( sal_Int32 nPropId ) const void PropertySet::getProperties( Sequence< Any >& orValues, const Sequence< OUString >& rPropNames ) const { - if( mxMultiPropSet.is() ) // first try the XMultiPropertySet + if( mxMultiPropSet.is() ) try { - try - { - orValues = mxMultiPropSet->getPropertyValues( rPropNames ); - } - catch( Exception& ) - { - OSL_ENSURE( false, "PropertySet::getProperties - cannot get all property values" ); - } + orValues = mxMultiPropSet->getPropertyValues( rPropNames ); + return; } - else if( mxPropSet.is() ) + catch( Exception& ) + { + OSL_ENSURE( false, "PropertySet::getProperties - cannot get all property values - fallback to single mode" ); + } + + if( mxPropSet.is() ) { sal_Int32 nLen = rPropNames.getLength(); const OUString* pPropName = rPropNames.getConstArray(); @@ -101,18 +106,17 @@ void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const S OSL_ENSURE( rPropNames.getLength() == rValues.getLength(), "PropertySet::setProperties - length of sequences different" ); - if( mxMultiPropSet.is() ) // first try the XMultiPropertySet + if( mxMultiPropSet.is() ) try { - try - { - mxMultiPropSet->setPropertyValues( rPropNames, rValues ); - } - catch( Exception& ) - { - OSL_ENSURE( false, "PropertySet::setProperties - cannot set all property values" ); - } + mxMultiPropSet->setPropertyValues( rPropNames, rValues ); + return; } - else if( mxPropSet.is() ) + catch( Exception& ) + { + OSL_ENSURE( false, "PropertySet::setProperties - cannot set all property values, fallback to single mode" ); + } + + if( mxPropSet.is() ) { const OUString* pPropName = rPropNames.getConstArray(); const OUString* pPropNameEnd = pPropName + rPropNames.getLength(); diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx index 6f174a74593c..4a05f66db81b 100644 --- a/oox/source/helper/storagebase.cxx +++ b/oox/source/helper/storagebase.cxx @@ -29,11 +29,14 @@ #include #include #include +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/binaryoutputstream.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; +using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::embed::XStorage; using ::com::sun::star::embed::XTransactedObject; using ::com::sun::star::io::XInputStream; @@ -66,24 +69,25 @@ void lclSplitFirstElement( OUString& orElement, OUString& orRemainder, const OUS StorageBase::StorageBase( const Reference< XInputStream >& rxInStream, bool bBaseStreamAccess ) : mxInStream( rxInStream ), - mpParentStorage( 0 ), - mbBaseStreamAccess( bBaseStreamAccess ) + mbBaseStreamAccess( bBaseStreamAccess ), + mbReadOnly( true ) { OSL_ENSURE( mxInStream.is(), "StorageBase::StorageBase - missing base input stream" ); } StorageBase::StorageBase( const Reference< XStream >& rxOutStream, bool bBaseStreamAccess ) : mxOutStream( rxOutStream ), - mpParentStorage( 0 ), - mbBaseStreamAccess( bBaseStreamAccess ) + mbBaseStreamAccess( bBaseStreamAccess ), + mbReadOnly( false ) { OSL_ENSURE( mxOutStream.is(), "StorageBase::StorageBase - missing base output stream" ); } -StorageBase::StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName ) : +StorageBase::StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName, bool bReadOnly ) : + maParentPath( rParentStorage.getPath() ), maStorageName( rStorageName ), - mpParentStorage( &rParentStorage ), - mbBaseStreamAccess( false ) + mbBaseStreamAccess( false ), + mbReadOnly( bReadOnly ) { } @@ -96,6 +100,16 @@ bool StorageBase::isStorage() const return implIsStorage(); } +bool StorageBase::isRootStorage() const +{ + return implIsStorage() && (maStorageName.getLength() == 0); +} + +bool StorageBase::isReadOnly() const +{ + return mbReadOnly; +} + Reference< XStorage > StorageBase::getXStorage() const { return implGetXStorage(); @@ -108,9 +122,7 @@ const OUString& StorageBase::getName() const OUString StorageBase::getPath() const { - OUStringBuffer aBuffer; - if( mpParentStorage ) - aBuffer.append( mpParentStorage->getPath() ); + OUStringBuffer aBuffer( maParentPath ); if( aBuffer.getLength() > 0 ) aBuffer.append( sal_Unicode( '/' ) ); aBuffer.append( maStorageName ); @@ -123,15 +135,19 @@ void StorageBase::getElementNames( ::std::vector< OUString >& orElementNames ) c implGetElementNames( orElementNames ); } -StorageRef StorageBase::openSubStorage( const OUString& rStorageName, bool bCreate ) +StorageRef StorageBase::openSubStorage( const OUString& rStorageName, bool bCreateMissing ) { StorageRef xSubStorage; - OUString aElement, aRemainder; - lclSplitFirstElement( aElement, aRemainder, rStorageName ); - if( aElement.getLength() > 0 ) - xSubStorage = getSubStorage( aElement, bCreate ); - if( xSubStorage.get() && (aRemainder.getLength() > 0) ) - xSubStorage = xSubStorage->openSubStorage( aRemainder, bCreate ); + OSL_ENSURE( !bCreateMissing || !mbReadOnly, "StorageBase::openSubStorage - cannot create substorage in read-only mode" ); + if( !bCreateMissing || !mbReadOnly ) + { + OUString aElement, aRemainder; + lclSplitFirstElement( aElement, aRemainder, rStorageName ); + if( aElement.getLength() > 0 ) + xSubStorage = getSubStorage( aElement, bCreateMissing ); + if( xSubStorage.get() && (aRemainder.getLength() > 0) ) + xSubStorage = xSubStorage->openSubStorage( aRemainder, bCreateMissing ); + } return xSubStorage; } @@ -163,47 +179,96 @@ Reference< XInputStream > StorageBase::openInputStream( const OUString& rStreamN Reference< XOutputStream > StorageBase::openOutputStream( const OUString& rStreamName ) { Reference< XOutputStream > xOutStream; - OUString aElement, aRemainder; - lclSplitFirstElement( aElement, aRemainder, rStreamName ); - if( aElement.getLength() > 0 ) + OSL_ENSURE( !mbReadOnly, "StorageBase::openOutputStream - cannot create output stream in read-only mode" ); + if( !mbReadOnly ) { - if( aRemainder.getLength() > 0 ) + OUString aElement, aRemainder; + lclSplitFirstElement( aElement, aRemainder, rStreamName ); + if( aElement.getLength() > 0 ) { - StorageRef xSubStorage = getSubStorage( aElement, true ); - if( xSubStorage.get() ) - xOutStream = xSubStorage->openOutputStream( aRemainder ); + if( aRemainder.getLength() > 0 ) + { + StorageRef xSubStorage = getSubStorage( aElement, true ); + if( xSubStorage.get() ) + xOutStream = xSubStorage->openOutputStream( aRemainder ); + } + else + { + xOutStream = implOpenOutputStream( aElement ); + } } - else + else if( mbBaseStreamAccess ) { - xOutStream = implOpenOutputStream( aElement ); + xOutStream = mxOutStream->getOutputStream(); } } - else if( mbBaseStreamAccess ) + return xOutStream; +} + +void StorageBase::copyToStorage( StorageBase& rDestStrg, const OUString& rElementName ) +{ + OSL_ENSURE( rDestStrg.isStorage() && !rDestStrg.isReadOnly(), "StorageBase::copyToStorage - invalid destination" ); + OSL_ENSURE( rElementName.getLength() > 0, "StorageBase::copyToStorage - invalid element name" ); + if( rDestStrg.isStorage() && !rDestStrg.isReadOnly() && (rElementName.getLength() > 0) ) { - xOutStream = mxOutStream->getOutputStream(); + StorageRef xSubStrg = openSubStorage( rElementName, false ); + if( xSubStrg.get() ) + { + StorageRef xDestSubStrg = rDestStrg.openSubStorage( rElementName, true ); + if( xDestSubStrg.get() ) + xSubStrg->copyStorageToStorage( *xDestSubStrg ); + } + else + { + Reference< XInputStream > xInStrm = openInputStream( rElementName ); + if( xInStrm.is() ) + { + Reference< XOutputStream > xOutStrm = rDestStrg.openOutputStream( rElementName ); + if( xOutStrm.is() ) + { + BinaryXInputStream aInStrm( xInStrm, true ); + BinaryXOutputStream aOutStrm( xOutStrm, true ); + aInStrm.copyToStream( aOutStrm ); + } + } + } } - return xOutStream; } -StorageRef StorageBase::getSubStorage( const OUString& rElementName, bool bCreate ) +void StorageBase::copyStorageToStorage( StorageBase& rDestStrg ) { - SubStorageMap::iterator aIt = maSubStorages.find( rElementName ); - return (aIt == maSubStorages.end()) ? - (maSubStorages[ rElementName ] = implOpenSubStorage( rElementName, bCreate )) : aIt->second; + OSL_ENSURE( rDestStrg.isStorage() && !rDestStrg.isReadOnly(), "StorageBase::copyToStorage - invalid destination" ); + if( rDestStrg.isStorage() && !rDestStrg.isReadOnly() ) + { + ::std::vector< OUString > aElements; + getElementNames( aElements ); + for( ::std::vector< OUString >::iterator aIt = aElements.begin(), aEnd = aElements.end(); aIt != aEnd; ++aIt ) + copyToStorage( rDestStrg, *aIt ); + } } void StorageBase::commit() { - for( SubStorageMap::iterator aIt = maSubStorages.begin(); aIt != maSubStorages.end(); aIt ++ ) - aIt->second->commit(); + OSL_ENSURE( !mbReadOnly, "StorageBase::commit - cannot commit in read-only mode" ); + if( !mbReadOnly ) + { + // commit all open substorages + maSubStorages.forEachMem( &StorageBase::commit ); + // commit this storage + implCommit(); + } +} - Reference< XTransactedObject > xTransactedObj( getXStorage(), UNO_QUERY ); +// private -------------------------------------------------------------------- - if( xTransactedObj.is() ) - xTransactedObj->commit(); +StorageRef StorageBase::getSubStorage( const OUString& rElementName, bool bCreateMissing ) +{ + StorageRef& rxSubStrg = maSubStorages[ rElementName ]; + if( !rxSubStrg ) + rxSubStrg = implOpenSubStorage( rElementName, bCreateMissing ); + return rxSubStrg; } // ============================================================================ } // namespace oox - diff --git a/oox/source/helper/textinputstream.cxx b/oox/source/helper/textinputstream.cxx new file mode 100755 index 000000000000..d6d4736f3ca2 --- /dev/null +++ b/oox/source/helper/textinputstream.cxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/helper/textinputstream.hxx" +#include +#include +#include "oox/helper/binaryinputstream.hxx" + +using ::rtl::OStringBuffer; +using ::rtl::OStringToOUString; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +namespace oox { + +// ============================================================================ + +namespace { + +/** Reads a text line from stream. First, tries to skip the second character of + a two-character line end sequence. Returns the new line-end character. */ +template< typename BufferType, typename CharType, typename StreamDataType > +sal_Unicode lclReadLine( BufferType& orBuffer, BinaryInputStream& rInStrm, sal_Unicode cLastEolChar ) +{ + // try to skip LF following CR, or CR following LF + if( !rInStrm.isEof() && (cLastEolChar != 0) ) + { + CharType cChar = static_cast< CharType >( rInStrm.readValue< StreamDataType >() ); + // return on EOF after line-end + if( rInStrm.isEof() ) + return 0; + // return on sequence of equal line-end characters + bool bIsEolChar = (cChar == 10) || (cChar == 13); + if( bIsEolChar && (cChar == cLastEolChar) ) + return cChar; + // append the character, if it is not the other line-end charcter + if( !bIsEolChar ) + orBuffer.append( cChar ); + } + + // read chars until EOF or line end character (LF or CR) + while( true ) + { + CharType cChar = static_cast< CharType >( rInStrm.readValue< StreamDataType >() ); + if( rInStrm.isEof() ) + return 0; + if( (cChar == 10) || (cChar == 13) ) + return cChar; + orBuffer.append( cChar ); + } +} + +} // namespace + +// ============================================================================ + +TextInputStream::TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc ) : + mrInStrm( rInStrm ), + meTextEnc( eTextEnc ), + mcLastEolChar( 0 ) +{ +} + +bool TextInputStream::isEof() const +{ + // do not return EOF, if last text line missed line-end character (see below) + return mrInStrm.isEof() && (mcLastEolChar == 0); +} + +OUString TextInputStream::readLine() +{ + if( mrInStrm.isEof() ) + { + mcLastEolChar = 0; + return OUString(); + } + + OUString aLine; + if( meTextEnc == RTL_TEXTENCODING_UCS2 ) + { + // read 16-bit characters for UCS2 encoding + OUStringBuffer aBuffer; + mcLastEolChar = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, mrInStrm, mcLastEolChar ); + aLine = aBuffer.makeStringAndClear(); + } + else + { + // otherwise, read 8-bit characters and convert according to text encoding + OStringBuffer aBuffer; + mcLastEolChar = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, mrInStrm, mcLastEolChar ); + aLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc ); + } + + // if last line is not empty but line-end character is missing, do not return EOF + if( mrInStrm.isEof() && (aLine.getLength() > 0) ) + mcLastEolChar = 10; + + return aLine; +} + +// ============================================================================ + +} // namespace oox + diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx index c90b2071b133..72b6fcd1bff0 100644 --- a/oox/source/helper/zipstorage.cxx +++ b/oox/source/helper/zipstorage.cxx @@ -26,26 +26,29 @@ ************************************************************************/ #include "oox/helper/zipstorage.hxx" -#include -#include -#include #include +#include +#include #include #include +#include #include #include "oox/helper/helper.hxx" using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::container::NoSuchElementException; using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; namespace oox { @@ -93,7 +96,7 @@ ZipStorage::ZipStorage( } ZipStorage::ZipStorage( const ZipStorage& rParentStorage, const Reference< XStorage >& rxStorage, const OUString& rElementName ) : - StorageBase( rParentStorage, rElementName ), + StorageBase( rParentStorage, rElementName, rParentStorage.isReadOnly() ), mxStorage( rxStorage ) { OSL_ENSURE( mxStorage.is(), "ZipStorage::ZipStorage - missing storage" ); @@ -127,7 +130,7 @@ void ZipStorage::implGetElementNames( ::std::vector< OUString >& orElementNames } } -StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bCreate ) +StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) { Reference< XStorage > xSubXStorage; bool bMissing = false; @@ -138,7 +141,7 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bC xSubXStorage = mxStorage->openStorageElement( rElementName, ::com::sun::star::embed::ElementModes::READ ); } - catch( ::com::sun::star::container::NoSuchElementException& ) + catch( NoSuchElementException& ) { bMissing = true; } @@ -146,15 +149,14 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bC { } - if( bMissing && bCreate ) - try - { - xSubXStorage = mxStorage->openStorageElement( - rElementName, ::com::sun::star::embed::ElementModes::READWRITE ); - } - catch( Exception& ) - { - } + if( bMissing && bCreateMissing ) try + { + xSubXStorage = mxStorage->openStorageElement( + rElementName, ::com::sun::star::embed::ElementModes::READWRITE ); + } + catch( Exception& ) + { + } StorageRef xSubStorage; if( xSubXStorage.is() ) @@ -188,7 +190,17 @@ Reference< XOutputStream > ZipStorage::implOpenOutputStream( const OUString& rEl return xOutStream; } +void ZipStorage::implCommit() const +{ + try + { + Reference< XTransactedObject >( mxStorage, UNO_QUERY_THROW )->commit(); + } + catch( Exception& ) + { + } +} + // ============================================================================ } // namespace oox - diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index f49776ef70e5..cb7e292b8cf4 100644 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -89,13 +89,80 @@ void AxAlignedInputStream::align( size_t nSize ) // ============================================================================ +AxFontData::AxFontData() : + mnFontEffects( 0 ), + mnFontHeight( 160 ), + mnFontCharSet( WINDOWS_CHARSET_DEFAULT ), + mnHorAlign( AX_FONTDATA_LEFT ) +{ +} + +sal_Int16 AxFontData::getHeightPoints() const +{ + /* MSO uses weird font sizes: + 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135, + 8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */ + return getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 ); +} + +void AxFontData::setHeightPoints( sal_Int16 nPoints ) +{ + mnFontHeight = getLimitedValue< sal_Int32, sal_Int32 >( ((nPoints * 4 + 1) / 3) * 15, 30, 4294967 ); +} + +bool AxFontData::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readStringProperty( maFontName ); + aReader.readIntProperty< sal_uInt32 >( mnFontEffects ); + aReader.readIntProperty< sal_Int32 >( mnFontHeight ); + aReader.skipIntProperty< sal_Int32 >(); // font offset + aReader.readIntProperty< sal_uInt8 >( mnFontCharSet ); + aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family + aReader.readIntProperty< sal_uInt8 >( mnHorAlign ); + aReader.skipIntProperty< sal_uInt16 >(); // font weight + return aReader.finalizeImport(); +} + +bool AxFontData::importStdFont( BinaryInputStream& rInStrm ) +{ + StdFontInfo aFontInfo; + if( OleHelper::importStdFont( aFontInfo, rInStrm, false ) ) + { + maFontName = aFontInfo.maName; + mnFontEffects = 0; + setFlag( mnFontEffects, AX_FONTDATA_BOLD, aFontInfo.mnWeight >= OLE_STDFONT_BOLD ); + setFlag( mnFontEffects, AX_FONTDATA_ITALIC, getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) ); + setFlag( mnFontEffects, AX_FONTDATA_UNDERLINE, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) ); + setFlag( mnFontEffects, AX_FONTDATA_STRIKEOUT, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) ); + // StdFont stores font height in 1/10,000 of points + setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) ); + mnFontCharSet = aFontInfo.mnCharSet; + mnHorAlign = AX_FONTDATA_LEFT; + return true; + } + return false; +} + +bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm ) +{ + OUString aGuid = OleHelper::importGuid( rInStrm ); + if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{AFC20920-DA4E-11CE-B943-00AA006887B4}" ) ) ) + return importBinaryModel( rInStrm ); + if( aGuid.equalsAscii( OLE_GUID_STDFONT ) ) + return importStdFont( rInStrm ); + return false; +} + +// ============================================================================ + AxBinaryPropertyReader::ComplexProperty::~ComplexProperty() { } bool AxBinaryPropertyReader::PairProperty::readProperty( AxAlignedInputStream& rInStrm ) { - rInStrm >> mrnValue1 >> mrnValue2; + rInStrm >> mrPairData.first >> mrPairData.second; return true; } @@ -116,6 +183,17 @@ bool AxBinaryPropertyReader::StringProperty::readProperty( AxAlignedInputStream& return bValidChars; } +bool AxBinaryPropertyReader::GuidProperty::readProperty( AxAlignedInputStream& rInStrm ) +{ + mrGuid = OleHelper::importGuid( rInStrm ); + return true; +} + +bool AxBinaryPropertyReader::FontProperty::readProperty( AxAlignedInputStream& rInStrm ) +{ + return mrFontData.importGuidAndFont( rInStrm ); +} + bool AxBinaryPropertyReader::PictureProperty::readProperty( AxAlignedInputStream& rInStrm ) { return OleHelper::importStdPic( mrPicData, rInStrm, true ); @@ -145,10 +223,10 @@ void AxBinaryPropertyReader::readBoolProperty( bool& orbValue, bool bReverse ) orbValue = startNextProperty() != bReverse; } -void AxBinaryPropertyReader::readPairProperty( sal_Int32& ornValue1, sal_Int32& ornValue2 ) +void AxBinaryPropertyReader::readPairProperty( AxPairData& orPairData ) { if( startNextProperty() ) - maLargeProps.push_back( ComplexPropVector::value_type( new PairProperty( ornValue1, ornValue2 ) ) ); + maLargeProps.push_back( ComplexPropVector::value_type( new PairProperty( orPairData ) ) ); } void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) @@ -160,6 +238,22 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) } } +void AxBinaryPropertyReader::readGuidProperty( ::rtl::OUString& orGuid ) +{ + if( startNextProperty() ) + maLargeProps.push_back( ComplexPropVector::value_type( new GuidProperty( orGuid ) ) ); +} + +void AxBinaryPropertyReader::readFontProperty( AxFontData& orFontData ) +{ + if( startNextProperty() ) + { + sal_Int16 nData = maInStrm.readAligned< sal_Int16 >(); + if( ensureValid( nData == -1 ) ) + maStreamProps.push_back( ComplexPropVector::value_type( new FontProperty( orFontData ) ) ); + } +} + void AxBinaryPropertyReader::readPictureProperty( StreamDataSequence& orPicData ) { if( startNextProperty() ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 9f99bf625333..da0acd233cbb 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -27,20 +27,24 @@ #include "oox/ole/axcontrol.hxx" #include -#include -#include #include #include #include #include #include #include +#include #include +#include #include #include #include -#include +#include +#include #include +#include +#include +#include #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/attributelist.hxx" @@ -48,20 +52,23 @@ #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" -#include "oox/ole/axbinaryreader.hxx" -#include "oox/ole/axcontrolhelper.hxx" -#include "oox/ole/olehelper.hxx" using ::rtl::OUString; +using ::com::sun::star::awt::Point; +using ::com::sun::star::awt::Size; +using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::container::XIndexContainer; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::drawing::XDrawPage; +using ::com::sun::star::form::XForm; +using ::com::sun::star::form::XFormComponent; +using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::container::XIndexContainer; -using ::com::sun::star::awt::XControlModel; -using ::com::sun::star::form::XFormComponent; -using ::oox::core::FilterBase; +using ::com::sun::star::uno::UNO_SET_THROW; namespace oox { namespace ole { @@ -70,6 +77,29 @@ namespace ole { namespace { +const sal_uInt32 COMCTL_ID_SIZE = 0x12344321; + +const sal_uInt32 COMCTL_ID_COMMONDATA = 0xABCDEF01; +const sal_uInt32 COMCTL_COMMON_FLATBORDER = 0x00000001; +const sal_uInt32 COMCTL_COMMON_ENABLED = 0x00000002; +const sal_uInt32 COMCTL_COMMON_3DBORDER = 0x00000004; +const sal_uInt32 COMCTL_COMMON_OLEDROPMAN = 0x00002000; + +const sal_uInt32 COMCTL_ID_COMPLEXDATA = 0xBDECDE1F; +const sal_uInt32 COMCTL_COMPLEX_FONT = 0x00000001; +const sal_uInt32 COMCTL_COMPLEX_MOUSEICON = 0x00000002; + +const sal_uInt32 COMCTL_ID_SCROLLBAR_60 = 0x99470A83; +const sal_uInt32 COMCTL_SCROLLBAR_HOR = 0x00000010; +const sal_Int32 COMCTL_SCROLLBAR_3D = 0; +const sal_Int32 COMCTL_SCROLLBAR_FLAT = 1; +const sal_Int32 COMCTL_SCROLLBAR_TRACK3D = 2; + +const sal_uInt32 COMCTL_ID_PROGRESSBAR_50 = 0xE6E17E84; +const sal_uInt32 COMCTL_ID_PROGRESSBAR_60 = 0x97AB8A01; + +// ---------------------------------------------------------------------------- + const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002; const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004; const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008; @@ -99,26 +129,6 @@ const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B; const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B; const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B; -const sal_uInt32 AX_FONT_BOLD = 0x00000001; -const sal_uInt32 AX_FONT_ITALIC = 0x00000002; -const sal_uInt32 AX_FONT_UNDERLINE = 0x00000004; -const sal_uInt32 AX_FONT_STRIKEOUT = 0x00000008; -const sal_uInt32 AX_FONT_DISABLED = 0x00002000; -const sal_uInt32 AX_FONT_AUTOCOLOR = 0x40000000; - -const sal_Int32 AX_FONTALIGN_LEFT = 1; -const sal_Int32 AX_FONTALIGN_RIGHT = 2; -const sal_Int32 AX_FONTALIGN_CENTER = 3; - -const sal_Int32 AX_BORDERSTYLE_NONE = 0; -const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; - -const sal_Int32 AX_SPECIALEFFECT_FLAT = 0; -const sal_Int32 AX_SPECIALEFFECT_RAISED = 1; -const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2; -const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3; -const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6; - const sal_uInt16 AX_POS_TOPLEFT = 0; const sal_uInt16 AX_POS_TOP = 1; const sal_uInt16 AX_POS_TOPRIGHT = 2; @@ -129,31 +139,21 @@ const sal_uInt16 AX_POS_BOTTOMLEFT = 6; const sal_uInt16 AX_POS_BOTTOM = 7; const sal_uInt16 AX_POS_BOTTOMRIGHT = 8; -#define AX_PICPOS( label, image ) ((AX_POS_##label << 16) | AX_POS_##image) -const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS( TOPRIGHT, TOPLEFT ); -const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS( RIGHT, LEFT ); -const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS( BOTTOMRIGHT, BOTTOMLEFT ); -const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS( TOPLEFT, TOPRIGHT ); -const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS( LEFT, RIGHT ); -const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS( BOTTOMLEFT, BOTTOMRIGHT ); -const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS( BOTTOMLEFT, TOPLEFT ); -const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS( BOTTOM, TOP ); -const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS( BOTTOMRIGHT, TOPRIGHT ); -const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS( TOPLEFT, BOTTOMLEFT ); -const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS( TOP, BOTTOM ); -const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS( TOPRIGHT, BOTTOMRIGHT ); -const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS( CENTER, CENTER ); -#undef AX_PICPOS - -const sal_Int32 AX_PICSIZE_CLIP = 0; -const sal_Int32 AX_PICSIZE_STRETCH = 1; -const sal_Int32 AX_PICSIZE_ZOOM = 3; - -const sal_Int32 AX_PICALIGN_TOPLEFT = 0; -const sal_Int32 AX_PICALIGN_TOPRIGHT = 1; -const sal_Int32 AX_PICALIGN_CENTER = 2; -const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; -const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; +#define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image) +const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS_IMPL( TOPRIGHT, TOPLEFT ); +const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS_IMPL( RIGHT, LEFT ); +const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT ); +const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS_IMPL( TOPLEFT, TOPRIGHT ); +const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS_IMPL( LEFT, RIGHT ); +const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS_IMPL( BOTTOMLEFT, BOTTOMRIGHT ); +const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS_IMPL( BOTTOMLEFT, TOPLEFT ); +const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS_IMPL( BOTTOM, TOP ); +const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT ); +const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS_IMPL( TOPLEFT, BOTTOMLEFT ); +const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS_IMPL( TOP, BOTTOM ); +const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS_IMPL( TOPRIGHT, BOTTOMRIGHT ); +const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS_IMPL( CENTER, CENTER ); +#undef AX_PICPOS_IMPL const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1; const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2; @@ -186,6 +186,25 @@ const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1; const sal_Int32 AX_PROPTHUMB_ON = -1; const sal_Int32 AX_PROPTHUMB_OFF = 0; +const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004; +const sal_uInt32 AX_CONTAINER_HASDESIGNEXT = 0x00004000; +const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000; + +const sal_uInt32 AX_CONTAINER_DEFFLAGS = 0x00000004; + +const sal_Int32 AX_CONTAINER_DEFWIDTH = 4000; +const sal_Int32 AX_CONTAINER_DEFHEIGHT = 3000; + +const sal_Int32 AX_CONTAINER_CYCLEALL = 0; +const sal_Int32 AX_CONTAINER_CYCLECURRENT = 2; + +const sal_Int32 AX_CONTAINER_SCR_NONE = 0x00; +const sal_Int32 AX_CONTAINER_SCR_HOR = 0x01; +const sal_Int32 AX_CONTAINER_SCR_VER = 0x02; +const sal_Int32 AX_CONTAINER_SCR_KEEP_HOR = 0x04; +const sal_Int32 AX_CONTAINER_SCR_KEEP_VER = 0x08; +const sal_Int32 AX_CONTAINER_SCR_SHOW_LEFT = 0x10; + // ---------------------------------------------------------------------------- const sal_Int16 API_BORDER_NONE = 0; @@ -196,27 +215,82 @@ const sal_Int16 API_STATE_UNCHECKED = 0; const sal_Int16 API_STATE_CHECKED = 1; const sal_Int16 API_STATE_DONTKNOW = 2; -// ---------------------------------------------------------------------------- +} // namespace + +// ============================================================================ -/** Specifies how a form control supports transparent background. */ -enum ApiTransparencyMode +ControlConverter::ControlConverter( const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + mrGraphicHelper( rGraphicHelper ), + mbDefaultColorBgr( bDefaultColorBgr ) { - API_TRANSPARENCY_NOTSUPPORTED, /// Control does not support transparency. - API_TRANSPARENCY_VOID, /// Transparency is enabled by missing fill color. - API_TRANSPARENCY_PAINTTRANSPARENT /// Transparency is enabled by the 'PaintTransparent' property. -}; +} -// ---------------------------------------------------------------------------- +ControlConverter::~ControlConverter() +{ +} + +// Generic conversion --------------------------------------------------------- + +void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const +{ + // size is given in 1/100 mm, UNO needs AppFont units + Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( Size( rSize.first, rSize.second ) ); + rPropMap.setProperty( PROP_Width, aAppFontSize.Width ); + rPropMap.setProperty( PROP_Height, aAppFontSize.Height ); +} + +void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const +{ + // position is given in 1/100 mm, UNO needs AppFont units + Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( Point( rPos.first, rPos.second ) ); + rPropMap.setProperty( PROP_PositionX, aAppFontPos.X ); + rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y ); +} + +void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const +{ + rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) ); +} + +void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const +{ + if( rPicData.hasElements() ) + { + OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData ); + if( aGraphicUrl.getLength() > 0 ) + rPropMap.setProperty( PROP_ImageURL, aGraphicUrl ); + } +} + +void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal ) const +{ + namespace AwtScrollBarOrient = ::com::sun::star::awt::ScrollBarOrientation; + sal_Int32 nScrollOrient = bHorizontal ? AwtScrollBarOrient::HORIZONTAL : AwtScrollBarOrient::VERTICAL; + rPropMap.setProperty( PROP_Orientation, nScrollOrient ); +} + +void ControlConverter::convertScrollBar( PropertyMap& rPropMap, + sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition, + sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const +{ + rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) ); + rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) ); + rPropMap.setProperty( PROP_LineIncrement, nSmallChange ); + rPropMap.setProperty( PROP_BlockIncrement, nLargeChange ); + rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition ); +} -/** Converts the AX background formatting to UNO properties. */ -void lclConvertBackground( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) +// ActiveX (Forms 2.0) specific conversion ------------------------------------ + +void ControlConverter::convertAxBackground( PropertyMap& rPropMap, + sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const { bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE ); switch( eTranspMode ) { case API_TRANSPARENCY_NOTSUPPORTED: // fake transparency by using system window background if needed - rPropMap.setProperty( PROP_BackgroundColor, rHelper.convertColor( bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK ) ); + convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK ); break; case API_TRANSPARENCY_PAINTTRANSPARENT: rPropMap.setProperty( PROP_PaintTransparent, !bOpaque ); @@ -224,52 +298,31 @@ void lclConvertBackground( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_ case API_TRANSPARENCY_VOID: // keep transparency by leaving the (void) default property value if( bOpaque ) - rPropMap.setProperty( PROP_BackgroundColor, rHelper.convertColor( nBackColor ) ); + convertColor( rPropMap, PROP_BackgroundColor, nBackColor ); break; } } -// ---------------------------------------------------------------------------- - -/** Converts the AX border formatting to UNO properties. */ -void lclConvertBorder( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) +void ControlConverter::convertAxBorder( PropertyMap& rPropMap, + sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const { sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT : ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN); rPropMap.setProperty( PROP_Border, nBorder ); - rPropMap.setProperty( PROP_BorderColor, rHelper.convertColor( nBorderColor ) ); + convertColor( rPropMap, PROP_BorderColor, nBorderColor ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX special effect to UNO properties. */ -void lclConvertVisualEffect( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) +void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const { namespace AwtVisualEffect = ::com::sun::star::awt::VisualEffect; sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? AwtVisualEffect::FLAT : AwtVisualEffect::LOOK3D; rPropMap.setProperty( PROP_VisualEffect, nVisualEffect ); } -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData ) -{ - if( rPicData.hasElements() ) - { - OUString aGraphicUrl = rHelper.getFilter().getGraphicHelper().importGraphicObject( rPicData ); - if( aGraphicUrl.getLength() > 0 ) - rPropMap.setProperty( PROP_ImageURL, aGraphicUrl ); - } -} - -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream and position to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) +void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const { // the picture - lclConvertPicture( rHelper, rPropMap, rPicData ); + convertPicture( rPropMap, rPicData ); // picture position namespace AwtImagePos = ::com::sun::star::awt::ImagePosition; @@ -289,18 +342,16 @@ void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const S case AX_PICPOS_BELOWCENTER: nImagePos = AwtImagePos::BelowCenter; break; case AX_PICPOS_BELOWRIGHT: nImagePos = AwtImagePos::BelowRight; break; case AX_PICPOS_CENTER: nImagePos = AwtImagePos::Centered; break; - default: OSL_ENSURE( false, "lclConvertPicture - unknown picture position" ); + default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture position" ); } rPropMap.setProperty( PROP_ImagePosition, nImagePos ); } -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream and position to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) +void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, + sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) const { // the picture - lclConvertPicture( rHelper, rPropMap, rPicData ); + convertPicture( rPropMap, rPicData ); // picture scale mode namespace AwtScaleMode = ::com::sun::star::awt::ImageScaleMode; @@ -310,16 +361,17 @@ void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const S case AX_PICSIZE_CLIP: nScaleMode = AwtScaleMode::None; break; case AX_PICSIZE_STRETCH: nScaleMode = AwtScaleMode::Anisotropic; break; case AX_PICSIZE_ZOOM: nScaleMode = AwtScaleMode::Isotropic; break; - default: OSL_ENSURE( false, "lclConvertPicture - unknown picture size mode" ); + default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture size mode" ); } rPropMap.setProperty( PROP_ScaleMode, nScaleMode ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX value for checked/unchecked/dontknow to UNO properties. */ -void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const OUString& rValue, sal_Int32 nMultiSelect, bool bSupportsTriState ) +void ControlConverter::convertAxState( PropertyMap& rPropMap, + const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const { + bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN; + bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE; + // state sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED; if( rValue.getLength() == 1 ) switch( rValue[ 0 ] ) @@ -328,41 +380,280 @@ void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const case '1': nState = API_STATE_CHECKED; break; // any other string (also empty) means 'dontknow' } - rPropMap.setProperty( PROP_DefaultState, nState ); + sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState; + if( bBooleanState ) + rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED ); + else + rPropMap.setProperty( nPropId, nState ); // tristate if( bSupportsTriState ) rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELCTION_MULTI ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX control orientation to UNO properties. */ -void lclConvertOrientation( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, sal_Int32 nOrientation, sal_Int32 nWidth, sal_Int32 nHeight ) +void ControlConverter::convertAxOrientation( PropertyMap& rPropMap, + const AxPairData& rSize, sal_Int32 nOrientation ) const { - namespace AwtScrollBarOrient = ::com::sun::star::awt::ScrollBarOrientation; - sal_Int32 nScrollOrient = AwtScrollBarOrient::HORIZONTAL; + bool bHorizontal = true; switch( nOrientation ) { - case AX_ORIENTATION_AUTO: if( nWidth <= nHeight) nScrollOrient = AwtScrollBarOrient::VERTICAL; break; - case AX_ORIENTATION_VERTICAL: nScrollOrient = AwtScrollBarOrient::VERTICAL; break; - case AX_ORIENTATION_HORIZONTAL: nScrollOrient = AwtScrollBarOrient::HORIZONTAL; break; - default: OSL_ENSURE( false, "lclConvertOrientation - unknown orientation" ); + case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break; + case AX_ORIENTATION_VERTICAL: bHorizontal = false; break; + case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break; + default: OSL_ENSURE( false, "ControlConverter::convertAxOrientation - unknown orientation" ); } - rPropMap.setProperty( PROP_Orientation, nScrollOrient ); + convertOrientation( rPropMap, bHorizontal ); } -} // namespace +// ============================================================================ + +ControlModelBase::ControlModelBase() : + maSize( 0, 0 ), + mbAwtModel( false ) +{ +} + +ControlModelBase::~ControlModelBase() +{ +} + +OUString ControlModelBase::getServiceName() const +{ + ApiControlType eCtrlType = getControlType(); + if( mbAwtModel ) switch( eCtrlType ) + { + case API_CONTROL_BUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlButtonModel" ); + case API_CONTROL_FIXEDTEXT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlFixedTextModel" ); + case API_CONTROL_IMAGE: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlImageControlModel" ); + case API_CONTROL_CHECKBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlCheckBoxModel" ); + case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlRadioButtonModel" ); + case API_CONTROL_EDIT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlEditModel" ); + case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlListBoxModel" ); + case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlComboBoxModel" ); + case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlSpinButtonModel" ); + case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlScrollBarModel" ); + case API_CONTROL_PROGRESSBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlProgressBarModel" ); + case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlGroupBoxModel" ); + case API_CONTROL_DIALOG: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlDialogModel" ); + default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no AWT model service supported" ); + } + else switch( eCtrlType ) + { + case API_CONTROL_BUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + case API_CONTROL_FIXEDTEXT: return CREATE_OUSTRING( "com.sun.star.form.component.FixedText" ); + case API_CONTROL_IMAGE: return CREATE_OUSTRING( "com.sun.star.form.component.DatabaseImageControl" ); + case API_CONTROL_CHECKBOX: return CREATE_OUSTRING( "com.sun.star.form.component.CheckBox" ); + case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" ); + case API_CONTROL_EDIT: return CREATE_OUSTRING( "com.sun.star.form.component.TextField" ); + case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ); + case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" ); + case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); + case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); + case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.form.component.GroupBox" ); + default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no form component service supported" ); + } + return OUString(); +} + +void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ ) +{ +} + +void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ ) +{ +} + +void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const +{ +} + +void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rConv.convertSize( rPropMap, maSize ); +} + +// ============================================================================ + +ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, + sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) : + maFontData( CREATE_OUSTRING( "Tahoma" ), 82500 ), + mnFlags( 0 ), + mnVersion( nVersion ), + mnDataPartId5( nDataPartId5 ), + mnDataPartId6( nDataPartId6 ), + mbCommonPart( bCommonPart ), + mbComplexPart( bComplexPart ) +{ +} + +bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm ) +{ + // read initial size part and header of the control data part + if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) ) + { + // if flags part exists, the first int32 of the data part contains its size + sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0; + // implementations must read the exact amount of data, stream must point to its end afterwards + importControlData( rInStrm ); + // read following parts + if( !rInStrm.isEof() && + (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) && + (!mbComplexPart || importComplexPart( rInStrm )) ) + { + return !rInStrm.isEof(); + } + } + return false; +} + +void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + if( mbCommonPart ) + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) ); + ControlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlModelBase::importCommonExtraData( BinaryInputStream& /*rInStrm*/ ) +{ +} + +void ComCtlModelBase::importCommonTrailingData( BinaryInputStream& /*rInStrm*/ ) +{ +} + +sal_uInt32 ComCtlModelBase::getDataPartId() const +{ + switch( mnVersion ) + { + case 5: return mnDataPartId5; + case 6: return mnDataPartId6; + } + OSL_ENSURE( false, "ComCtlObjectBase::getDataPartId - unxpected version" ); + return SAL_MAX_UINT32; +} + +bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor ) +{ + // no idea if all this is correct... + sal_uInt32 nPartId; + sal_uInt16 nMajor, nMinor; + rInStrm >> nPartId >> nMinor >> nMajor; + bool bPartId = nPartId == nExpPartId; + OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" ); + bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor)); + OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" ); + return !rInStrm.isEof() && bPartId && bVersion; +} + +bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm ) +{ + if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) ) + { + rInStrm >> maSize.first >> maSize.second; + return !rInStrm.isEof(); + } + return false; +} + +bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize ) +{ + sal_Int64 nEndPos = rInStrm.tell() + nPartSize; + if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) ) + { + rInStrm.skip( 4 ); + rInStrm >> mnFlags; + // implementations may read less than the exact amount of data + importCommonExtraData( rInStrm ); + rInStrm.seek( nEndPos ); + // implementations must read the exact amount of data, stream must point to its end afterwards + importCommonTrailingData( rInStrm ); + return !rInStrm.isEof(); + } + return false; +} + +bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm ) +{ + if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) ) + { + sal_uInt32 nContFlags; + rInStrm >> nContFlags; + bool bReadOk = + (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) && + (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true )); + return bReadOk && !rInStrm.isEof(); + } + return false; +} + +// ============================================================================ + +ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) : + ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion, true, true ), + mnScrollBarFlags( 0x00000011 ), + mnLargeChange( 1 ), + mnSmallChange( 1 ), + mnMin( 0 ), + mnMax( 32767 ), + mnPosition( 0 ) +{ +} + +ApiControlType ComCtlScrollBarModel::getControlType() const +{ + return API_CONTROL_SCROLLBAR; +} + +void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); + rConv.convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) ); + rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel ); + ComCtlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm ) +{ + rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition; +} // ============================================================================ -AxControlModelBase::AxControlModelBase() : - mnWidth( 0 ), - mnHeight( 0 ) +ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) : + ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion, true, true ), + mfMin( 0.0 ), + mfMax( 100.0 ), + mnVertical( 0 ), + mnSmooth( 0 ) { } -AxControlModelBase::~AxControlModelBase() +ApiControlType ComCtlProgressBarModel::getControlType() const +{ + return API_CONTROL_PROGRESSBAR; +} + +void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN : + (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE); + rPropMap.setProperty( PROP_Border, nBorder ); + rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) ); + rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) ); + // ComCtl model does not provide current value? + ComCtlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm ) +{ + rInStrm >> mfMin >> mfMax; + if( mnVersion == 6 ) + rInStrm >> mnVertical >> mnSmooth; +} + +// ============================================================================ + +AxControlModelBase::AxControlModelBase() { } @@ -377,33 +668,18 @@ void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rVal OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" ); if( nSepPos >= 0 ) { - mnWidth = rValue.copy( 0, nSepPos ).toInt32(); - mnHeight = rValue.copy( nSepPos + 1 ).toInt32(); + maSize.first = rValue.copy( 0, nSepPos ).toInt32(); + maSize.second = rValue.copy( nSepPos + 1 ).toInt32(); } } break; } } -void AxControlModelBase::importBinaryModel( BinaryInputStream& /*rInStrm*/ ) -{ -} - -void AxControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ ) -{ -} - -void AxControlModelBase::convertProperties( AxControlHelper& /*rHelper*/, PropertyMap& /*rPropMap*/ ) const -{ -} - // ============================================================================ -AxFontDataModel::AxFontDataModel() : - mnFontEffects( 0 ), - mnFontHeight( 160 ), - mnFontCharSet( 1 ), - mnHorAlign( AX_FONTALIGN_LEFT ) +AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) : + mbSupportsAlign( bSupportsAlign ) { } @@ -411,70 +687,59 @@ void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue { switch( nPropId ) { - case XML_FontName: maFontName = rValue; break; - case XML_FontEffects: mnFontEffects = AttributeList::decodeUnsigned( rValue ); break; - case XML_FontHeight: mnFontHeight = AttributeList::decodeInteger( rValue ); break; - case XML_FontCharSet: mnFontCharSet = AttributeList::decodeInteger( rValue ); break; - case XML_ParagraphAlign: mnHorAlign = AttributeList::decodeInteger( rValue ); break; + case XML_FontName: maFontData.maFontName = rValue; break; + case XML_FontEffects: maFontData.mnFontEffects = AttributeList::decodeUnsigned( rValue ); break; + case XML_FontHeight: maFontData.mnFontHeight = AttributeList::decodeInteger( rValue ); break; + case XML_FontCharSet: maFontData.mnFontCharSet = AttributeList::decodeInteger( rValue ); break; + case XML_ParagraphAlign: maFontData.mnHorAlign = AttributeList::decodeInteger( rValue ); break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } -void AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm ) { - AxBinaryPropertyReader aReader( rInStrm ); - aReader.readStringProperty( maFontName ); - aReader.readIntProperty< sal_uInt32 >( mnFontEffects ); - aReader.readIntProperty< sal_Int32 >( mnFontHeight ); - aReader.skipIntProperty< sal_Int32 >(); // font offset - aReader.readIntProperty< sal_uInt8 >( mnFontCharSet ); - aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family - aReader.readIntProperty< sal_uInt8 >( mnHorAlign ); - aReader.skipIntProperty< sal_uInt16 >(); // font weight - aReader.finalizeImport(); + return maFontData.importBinaryModel( rInStrm ); } -void AxFontDataModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { namespace cssa = ::com::sun::star::awt; // font name - if( maFontName.getLength() > 0 ) - rPropMap.setProperty( PROP_FontName, maFontName ); + if( maFontData.maFontName.getLength() > 0 ) + rPropMap.setProperty( PROP_FontName, maFontData.maFontName ); // font effects - rPropMap.setProperty( PROP_FontWeight, getFlagValue( mnFontEffects, AX_FONT_BOLD, cssa::FontWeight::BOLD, cssa::FontWeight::NORMAL ) ); - rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( mnFontEffects, AX_FONT_ITALIC, cssa::FontSlant_ITALIC, cssa::FontSlant_NONE ) ); - rPropMap.setProperty( PROP_FontUnderline, getFlagValue( mnFontEffects, AX_FONT_UNDERLINE, cssa::FontUnderline::SINGLE, cssa::FontUnderline::NONE ) ); - rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( mnFontEffects, AX_FONT_STRIKEOUT, cssa::FontStrikeout::SINGLE, cssa::FontStrikeout::NONE ) ); - - /* font height in points. MSO uses weird font sizes: - 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135, - 8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */ - sal_Int16 nHeight = getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 ); - rPropMap.setProperty( PROP_FontHeight, nHeight ); + rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, cssa::FontWeight::BOLD, cssa::FontWeight::NORMAL ) ); + rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, cssa::FontSlant_ITALIC, cssa::FontSlant_NONE ) ); + rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, cssa::FontUnderline::SINGLE, cssa::FontUnderline::NONE ) ); + rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, cssa::FontStrikeout::SINGLE, cssa::FontStrikeout::NONE ) ); + rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() ); // font character set rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW; - if( (0 <= mnFontCharSet) && (mnFontCharSet <= SAL_MAX_UINT8) ) - eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( mnFontCharSet ) ); + if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) ) + eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) ); if( eFontEnc != RTL_TEXTENCODING_DONTKNOW ) rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) ); // text alignment - sal_Int32 nAlign = cssa::TextAlign::LEFT; - switch( mnHorAlign ) + if( mbSupportsAlign ) { - case AX_FONTALIGN_LEFT: nAlign = cssa::TextAlign::LEFT; break; - case AX_FONTALIGN_RIGHT: nAlign = cssa::TextAlign::RIGHT; break; - case AX_FONTALIGN_CENTER: nAlign = cssa::TextAlign::CENTER; break; - default: OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" ); + sal_Int32 nAlign = cssa::TextAlign::LEFT; + switch( maFontData.mnHorAlign ) + { + case AX_FONTDATA_LEFT: nAlign = cssa::TextAlign::LEFT; break; + case AX_FONTDATA_RIGHT: nAlign = cssa::TextAlign::RIGHT; break; + case AX_FONTDATA_CENTER: nAlign = cssa::TextAlign::CENTER; break; + default: OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" ); + } + // form controls expect short value + rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) ); } - // form controls expect short value - rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) ); // process base class properties - AxControlModelBase::convertProperties( rHelper, rPropMap ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -511,7 +776,7 @@ void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStre } } -void AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnTextColor ); @@ -519,32 +784,31 @@ void AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.readStringProperty( maCaption ); aReader.readIntProperty< sal_uInt32 >( mnPicturePos ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readPictureProperty( maPictureData ); aReader.skipIntProperty< sal_uInt16 >(); // accelerator aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus" aReader.skipPictureProperty(); // mouse icon - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -OUString AxCommandButtonModel::getServiceName() const +ApiControlType AxCommandButtonModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + return API_CONTROL_BUTTON; } -void AxCommandButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -574,7 +838,7 @@ void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) } } -void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnTextColor ); @@ -582,7 +846,7 @@ void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.readStringProperty( maCaption ); aReader.skipIntProperty< sal_uInt32 >(); // picture position - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_uInt32 >( mnBorderColor ); aReader.readIntProperty< sal_uInt16 >( mnBorderStyle ); @@ -590,25 +854,24 @@ void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipPictureProperty(); // picture aReader.skipIntProperty< sal_uInt16 >(); // accelerator aReader.skipPictureProperty(); // mouse icon - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -OUString AxLabelModel::getServiceName() const +ApiControlType AxLabelModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.FixedText" ); + return API_CONTROL_FIXEDTEXT; } -void AxLabelModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_TOP ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -650,7 +913,7 @@ void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInS } } -void AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.skipUndefinedProperty(); @@ -662,32 +925,32 @@ void AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode ); aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.readPictureProperty( maPictureData ); aReader.readIntProperty< sal_uInt8 >( mnPicAlign ); aReader.readBoolProperty( mbPicTiling ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.skipPictureProperty(); // mouse icon - aReader.finalizeImport(); + return aReader.finalizeImport(); } -OUString AxImageModel::getServiceName() const +ApiControlType AxImageModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.DatabaseImageControl" ); + return API_CONTROL_IMAGE; } -void AxImageModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ -AxMorphDataModel::AxMorphDataModel() : +AxMorphDataModelBase::AxMorphDataModelBase() : mnTextColor( AX_SYSCOLOR_WINDOWTEXT ), mnBackColor( AX_SYSCOLOR_WINDOWBACK ), mnFlags( AX_MORPHDATA_DEFFLAGS ), @@ -706,7 +969,7 @@ AxMorphDataModel::AxMorphDataModel() : { } -void AxMorphDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) +void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue ) { switch( nPropId ) { @@ -732,7 +995,7 @@ void AxMorphDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue } } -void AxMorphDataModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) +void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) { switch( nPropId ) { @@ -741,7 +1004,7 @@ void AxMorphDataModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& } } -void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm, true ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); @@ -752,7 +1015,7 @@ void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt8 >( mnScrollBars ); aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.readIntProperty< sal_uInt16 >( mnPasswordChar ); aReader.skipIntProperty< sal_uInt32 >(); // list width aReader.skipIntProperty< sal_uInt16 >(); // bound column @@ -777,15 +1040,14 @@ void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipUndefinedProperty(); aReader.skipBoolProperty(); aReader.readStringProperty( maGroupName ); - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -void AxMorphDataModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -794,21 +1056,21 @@ AxToggleButtonModel::AxToggleButtonModel() { } -OUString AxToggleButtonModel::getServiceName() const +ApiControlType AxToggleButtonModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" ); + return API_CONTROL_BUTTON; } -void AxToggleButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); rPropMap.setProperty( PROP_Toggle, true ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -817,22 +1079,22 @@ AxCheckBoxModel::AxCheckBoxModel() { } -OUString AxCheckBoxModel::getServiceName() const +ApiControlType AxCheckBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.CheckBox" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" ); + return API_CONTROL_CHECKBOX; } -void AxCheckBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, true ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -841,22 +1103,22 @@ AxOptionButtonModel::AxOptionButtonModel() { } -OUString AxOptionButtonModel::getServiceName() const +ApiControlType AxOptionButtonModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" ); + return API_CONTROL_RADIOBUTTON; } -void AxOptionButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, false ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -865,25 +1127,25 @@ AxTextBoxModel::AxTextBoxModel() { } -OUString AxTextBoxModel::getServiceName() const +ApiControlType AxTextBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.TextField" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" ); + return API_CONTROL_EDIT; } -void AxTextBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) ); rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) ); - rPropMap.setProperty( PROP_DefaultText, maValue ); + rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue ); rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) ); if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) ) rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) ); rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) ); rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -892,20 +1154,20 @@ AxListBoxModel::AxListBoxModel() { } -OUString AxListBoxModel::getServiceName() const +ApiControlType AxListBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" ); + return API_CONTROL_LISTBOX; } -void AxListBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { bool bMultiSelect = (mnMultiSelect == AX_SELCTION_MULTI) || (mnMultiSelect == AX_SELCTION_EXTENDED); rPropMap.setProperty( PROP_MultiSelection, bMultiSelect ); rPropMap.setProperty( PROP_Dropdown, false ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -914,18 +1176,18 @@ AxComboBoxModel::AxComboBoxModel() { } -OUString AxComboBoxModel::getServiceName() const +ApiControlType AxComboBoxModel::getControlType() const { - OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getServiceName - invalid control type" ); - return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ) : CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" ); + OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" ); + return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX; } -void AxComboBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN ) { rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) ); - rPropMap.setProperty( PROP_DefaultText, maValue ); + rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue ); rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) ); bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE); rPropMap.setProperty( PROP_Autocomplete, bAutoComplete ); @@ -933,9 +1195,9 @@ void AxComboBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS); rPropMap.setProperty( PROP_Dropdown, bShowDropdown ); rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -953,9 +1215,9 @@ AxSpinButtonModel::AxSpinButtonModel() : { } -OUString AxSpinButtonModel::getServiceName() const +ApiControlType AxSpinButtonModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); + return API_CONTROL_SPINBUTTON; } void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) @@ -975,13 +1237,13 @@ void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValu } } -void AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnArrowColor ); aReader.readIntProperty< sal_uInt32 >( mnBackColor ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt32 >(); // unused aReader.readIntProperty< sal_Int32 >( mnMin ); aReader.readIntProperty< sal_Int32 >( mnMax ); @@ -993,25 +1255,25 @@ void AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_Int32 >( mnDelay ); aReader.skipPictureProperty(); // mouse icon aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer - aReader.finalizeImport(); + return aReader.finalizeImport(); } -void AxSpinButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { sal_Int32 nMin = ::std::min( mnMin, mnMax ); sal_Int32 nMax = ::std::max( mnMin, mnMax ); - rPropMap.setProperty( PROP_SymbolColor, rHelper.convertColor( mnArrowColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_SpinValueMin, nMin ); rPropMap.setProperty( PROP_SpinValueMax, nMax ); rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange ); - rPropMap.setProperty( PROP_DefaultSpinValue, mnPosition ); + rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition ); rPropMap.setProperty( PROP_Repeat, true ); rPropMap.setProperty( PROP_RepeatDelay, mnDelay ); rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertOrientation( rHelper, rPropMap, mnOrientation, mnWidth, mnHeight ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxOrientation( rPropMap, maSize, mnOrientation ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -1031,9 +1293,9 @@ AxScrollBarModel::AxScrollBarModel() : { } -OUString AxScrollBarModel::getServiceName() const +ApiControlType AxScrollBarModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); + return API_CONTROL_SCROLLBAR; } void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) @@ -1055,13 +1317,13 @@ void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue } } -void AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnArrowColor ); aReader.readIntProperty< sal_uInt32 >( mnBackColor ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_Int32 >( mnMin ); aReader.readIntProperty< sal_Int32 >( mnMax ); @@ -1075,114 +1337,292 @@ void AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_Int16 >( mnPropThumb ); aReader.readIntProperty< sal_Int32 >( mnDelay ); aReader.skipPictureProperty(); // mouse icon - aReader.finalizeImport(); + return aReader.finalizeImport(); } -void AxScrollBarModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { - sal_Int32 nMin = ::std::min( mnMin, mnMax ); - sal_Int32 nMax = ::std::max( mnMin, mnMax ); - rPropMap.setProperty( PROP_SymbolColor, rHelper.convertColor( mnArrowColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - rPropMap.setProperty( PROP_ScrollValueMin, nMin ); - rPropMap.setProperty( PROP_ScrollValueMax, nMax ); - rPropMap.setProperty( PROP_LineIncrement, mnSmallChange ); - rPropMap.setProperty( PROP_BlockIncrement, mnLargeChange ); - rPropMap.setProperty( PROP_DefaultScrollValue, mnPosition ); rPropMap.setProperty( PROP_RepeatDelay, mnDelay ); rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); - if( (mnPropThumb == AX_PROPTHUMB_ON) && (nMin < nMax) && (mnLargeChange > 0) ) + if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) ) { - double fInterval = nMax - nMin; // prevent integer overflow (fInterval+mnLargeChange may become 0 when int is used) + // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int) + double fInterval = fabs( static_cast< double >( mnMax - mnMin ) ); sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 ); rPropMap.setProperty( PROP_VisibleSize, nThumbLen ); } - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertOrientation( rHelper, rPropMap, mnOrientation, mnWidth, mnHeight ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxOrientation( rPropMap, maSize, mnOrientation ); + rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel ); + AxControlModelBase::convertProperties( rPropMap, rConv ); +} + +// ============================================================================ + +AxContainerModelBase::AxContainerModelBase() : + AxFontDataModel( false ), // no support for Align property + maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ), + maScrollPos( 0, 0 ), + mnBackColor( AX_SYSCOLOR_BUTTONFACE ), + mnTextColor( AX_SYSCOLOR_BUTTONTEXT ), + mnFlags( AX_CONTAINER_DEFFLAGS ), + mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ), + mnBorderStyle( AX_BORDERSTYLE_NONE ), + mnScrollBars( AX_CONTAINER_SCR_NONE ), + mnCycleType( AX_CONTAINER_CYCLEALL ), + mnSpecialEffect( AX_SPECIALEFFECT_FLAT ), + mnPicAlign( AX_PICALIGN_CENTER ), + mnPicSizeMode( AX_PICSIZE_CLIP ), + mbPicTiling( false ) +{ + setAwtModelMode(); + // different default size for frame + maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ); +} + +void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue ) +{ + if( nPropId == XML_Caption ) + maCaption = rValue; +} + +bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.skipUndefinedProperty(); + aReader.readIntProperty< sal_uInt32 >( mnBackColor ); + aReader.readIntProperty< sal_uInt32 >( mnTextColor ); + aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID + aReader.skipUndefinedProperty(); + aReader.skipUndefinedProperty(); + aReader.readIntProperty< sal_uInt32 >( mnFlags ); + aReader.readIntProperty< sal_uInt8 >( mnBorderStyle ); + aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer + aReader.readIntProperty< sal_uInt8 >( mnScrollBars ); + aReader.readPairProperty( maSize ); + aReader.readPairProperty( maLogicalSize ); + aReader.readPairProperty( maScrollPos ); + aReader.skipIntProperty< sal_uInt32 >(); // number of control groups + aReader.skipUndefinedProperty(); + aReader.skipPictureProperty(); // mouse icon + aReader.readIntProperty< sal_uInt8 >( mnCycleType ); + aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect ); + aReader.readIntProperty< sal_uInt32 >( mnBorderColor ); + aReader.readStringProperty( maCaption ); + aReader.readFontProperty( maFontData ); + aReader.readPictureProperty( maPictureData ); + aReader.skipIntProperty< sal_Int32 >(); // zoom + aReader.readIntProperty< sal_uInt8 >( mnPicAlign ); + aReader.readBoolProperty( mbPicTiling ); + aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode ); + aReader.skipIntProperty< sal_uInt32 >(); // shape cookie + aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size + return aReader.finalizeImport(); +} + +bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ) +{ + bool bValid = true; + orClassTable.clear(); + if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) ) + { + sal_uInt16 nCount = rInStrm.readuInt16(); + for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex ) + { + orClassTable.push_back( OUString() ); + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readGuidProperty( orClassTable.back() ); + aReader.skipGuidProperty(); // source interface GUID + aReader.skipUndefinedProperty(); + aReader.skipGuidProperty(); // default interface GUID + aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags + aReader.skipIntProperty< sal_uInt32 >(); // method count + aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type + aReader.skipIntProperty< sal_uInt16 >(); // get function index of value + aReader.skipIntProperty< sal_uInt16 >(); // put function index of value + aReader.skipIntProperty< sal_uInt16 >(); // value type + aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access + aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access + bValid = aReader.finalizeImport(); + } + } + return bValid; +} + +// ============================================================================ + +AxFrameModel::AxFrameModel() +{ +} + +ApiControlType AxFrameModel::getControlType() const +{ + return API_CONTROL_GROUPBOX; +} + +void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Label, maCaption ); + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); +} + +// ============================================================================ + +AxUserFormModel::AxUserFormModel() +{ +} + +ApiControlType AxUserFormModel::getControlType() const +{ + return API_CONTROL_DIALOG; +} + +void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Title, maCaption ); + rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ -AxControl::AxControl( const OUString& rName ) : +EmbeddedControl::EmbeddedControl( const OUString& rName ) : maName( rName ) { } -AxControl::~AxControl() +EmbeddedControl::~EmbeddedControl() { } -AxControlModelBase* AxControl::createModel( const OUString& rClassId ) +ControlModelRef EmbeddedControl::createModel( const OUString& rClassId ) { - // TODO: move into a factory - maClassId = rClassId.toAsciiUpperCase(); - if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{D7053240-CE69-11CD-A777-00DD01143C57}" ) ) ) // Forms.CommandButton.1 + OUString aClassId = rClassId.toAsciiUpperCase(); + if( aClassId.equalsAscii( AX_GUID_COMMANDBUTTON ) ) mxModel.reset( new AxCommandButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}" ) ) ) // Forms.Label.1 + else if( aClassId.equalsAscii( AX_GUID_LABEL ) ) mxModel.reset( new AxLabelModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{4C599241-6926-101B-9992-00000B65C6F9}" ) ) ) // Forms.Image.1 + else if( aClassId.equalsAscii( AX_GUID_IMAGE ) ) mxModel.reset( new AxImageModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ToggleButton.1 + else if( aClassId.equalsAscii( AX_GUID_TOGGLEBUTTON ) ) mxModel.reset( new AxToggleButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.CheckBox.1 + else if( aClassId.equalsAscii( AX_GUID_CHECKBOX ) ) mxModel.reset( new AxCheckBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.OptionButton.1 + else if( aClassId.equalsAscii( AX_GUID_OPTIONBUTTON ) ) mxModel.reset( new AxOptionButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.TextBox.1 + else if( aClassId.equalsAscii( AX_GUID_TEXTBOX ) ) mxModel.reset( new AxTextBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ListBox.1 + else if( aClassId.equalsAscii( AX_GUID_LISTBOX ) ) mxModel.reset( new AxListBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ComboBox.1 + else if( aClassId.equalsAscii( AX_GUID_COMBOBOX ) ) mxModel.reset( new AxComboBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{79176FB0-B7F2-11CE-97EF-00AA006D2776}" ) ) ) // Forms.SpinButton.1 + else if( aClassId.equalsAscii( AX_GUID_SPINBUTTON ) ) mxModel.reset( new AxSpinButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{DFD181E0-5E2F-11CE-A449-00AA004A803D}" ) ) ) // Forms.ScrollBar.1 + else if( aClassId.equalsAscii( AX_GUID_SCROLLBAR ) ) mxModel.reset( new AxScrollBarModel ); + else if( aClassId.equalsAscii( AX_GUID_FRAME ) ) + mxModel.reset( new AxFrameModel ); + else if( aClassId.equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) + mxModel.reset( new ComCtlScrollBarModel( 6 ) ); else mxModel.reset(); - return mxModel.get(); + // embedded controls are form component instances + if( mxModel.get() ) + mxModel->setFormComponentMode(); + + return mxModel; } -void AxControl::importBinaryModel( BinaryInputStream& rInStrm ) +OUString EmbeddedControl::getServiceName() const { - if( AxControlModelBase* pModel = createModel( OleHelper::importGuid( rInStrm ) ) ) - pModel->importBinaryModel( rInStrm ); + return mxModel.get() ? mxModel->getServiceName() : OUString(); } -Reference< XControlModel > AxControl::convertAndInsert( AxControlHelper& rHelper ) const +bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const { - Reference< XControlModel > xCtrlModel; - if( mxModel.get() ) try + if( mxModel.get() && rxCtrlModel.is() && (maName.getLength() > 0) ) { - Reference< XIndexContainer > xFormIC( rHelper.getControlForm(), UNO_QUERY_THROW ); + PropertyMap aPropMap; + aPropMap.setProperty( PROP_Name, maName ); + mxModel->convertProperties( aPropMap, rConv ); + PropertySet aPropSet( rxCtrlModel ); + aPropSet.setProperties( aPropMap ); + return true; + } + return false; +} + +// ============================================================================ - // document model creates the form control model - xCtrlModel.set( rHelper.getFilter().getModelFactory()->createInstance( mxModel->getServiceName() ), UNO_QUERY_THROW ); - Reference< XFormComponent > xFormComp( xCtrlModel, UNO_QUERY_THROW ); +EmbeddedForm::EmbeddedForm( const Reference< XMultiServiceFactory >& rxModelFactory, + const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + ControlConverter( rGraphicHelper, bDefaultColorBgr ), + mxModelFactory( rxModelFactory ), + mxFormsSupp( rxDrawPage, UNO_QUERY ) +{ + OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" ); +} + +Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl ) +{ + if( mxModelFactory.is() && rControl.hasModel() ) try + { + // create the UNO control model + OUString aServiceName = rControl.getServiceName(); + Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW ); - // insert control model into the passed form + // insert the control into the form + Reference< XIndexContainer > xFormIC( createForm(), UNO_SET_THROW ); sal_Int32 nNewIndex = xFormIC->getCount(); xFormIC->insertByIndex( nNewIndex, Any( xFormComp ) ); - // convert all control properties - PropertyMap aPropMap; - aPropMap.setProperty( PROP_Name, maName ); - mxModel->convertProperties( rHelper, aPropMap ); - - PropertySet aPropSet( xCtrlModel ); - aPropSet.setProperties( aPropMap ); + // convert the control properties + if( rControl.convertProperties( xCtrlModel, *this ) ) + return xCtrlModel; } catch( Exception& ) { - xCtrlModel.clear(); // on error: forget the created form control model } - return xCtrlModel; + return Reference< XControlModel >(); +} + +Reference< XIndexContainer > EmbeddedForm::createForm() +{ + if( mxFormsSupp.is() ) + { + try + { + Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW ); + OUString aFormName = CREATE_OUSTRING( "Standard" ); + if( xFormsNC->hasByName( aFormName ) ) + { + mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW ); + } + else if( mxModelFactory.is() ) + { + Reference< XForm > xForm( mxModelFactory->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW ); + xFormsNC->insertByName( aFormName, Any( xForm ) ); + mxFormIC.set( xForm, UNO_QUERY_THROW ); + } + } + catch( Exception& ) + { + } + // always clear the forms supplier to not try to create the form again + mxFormsSupp.clear(); + } + return mxFormIC; } // ============================================================================ } // namespace ole } // namespace oox - diff --git a/oox/source/ole/axcontrolfragment.cxx b/oox/source/ole/axcontrolfragment.cxx index e641ec40d71b..ecd782da2cb0 100644 --- a/oox/source/ole/axcontrolfragment.cxx +++ b/oox/source/ole/axcontrolfragment.cxx @@ -30,8 +30,12 @@ #include "oox/helper/binaryoutputstream.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/ole/axcontrol.hxx" +#include "oox/ole/olehelper.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::uno::Reference; using ::oox::core::ContextHandler2; using ::oox::core::ContextHandlerRef; using ::oox::core::FragmentHandler2; @@ -42,7 +46,7 @@ namespace ole { // ============================================================================ -AxControlPropertyContext::AxControlPropertyContext( FragmentHandler2& rFragment, AxControlModelBase& rModel ) : +AxControlPropertyContext::AxControlPropertyContext( FragmentHandler2& rFragment, ControlModelBase& rModel ) : ContextHandler2( rFragment ), mrModel( rModel ), mnPropId( XML_TOKEN_INVALID ) @@ -87,7 +91,7 @@ ContextHandlerRef AxControlPropertyContext::onCreateContext( sal_Int32 nElement, // ============================================================================ -AxControlFragment::AxControlFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, AxControl& rControl ) : +AxControlFragment::AxControlFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, EmbeddedControl& rControl ) : FragmentHandler2( rFilter, rFragmentPath, true ), mrControl( rControl ) { @@ -101,7 +105,7 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const switch( rAttribs.getToken( AX_TOKEN( persistence ), XML_TOKEN_INVALID ) ) { case XML_persistPropertyBag: - if( AxControlModelBase* pModel = mrControl.createModel( aClassId ) ) + if( ControlModelBase* pModel = mrControl.createModel( aClassId ).get() ) return new AxControlPropertyContext( *this, *pModel ); break; @@ -113,10 +117,30 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const BinaryXInputStream aInStrm( getFilter().openInputStream( aFragmentPath ), true ); if( !aInStrm.isEof() ) { - mrControl.importBinaryModel( aInStrm ); // binary stream contains a copy of the class ID, must be equal to attribute value - OSL_ENSURE( !mrControl.getModel() || aClassId.equalsIgnoreAsciiCase( mrControl.getClassId() ), + OUString aStrmClassId = OleHelper::importGuid( aInStrm ); + OSL_ENSURE( aClassId.equalsIgnoreAsciiCase( aStrmClassId ), "AxControlFragment::importBinaryControl - form control class ID mismatch" ); + if( ControlModelBase* pModel = mrControl.createModel( aStrmClassId ).get() ) + pModel->importBinaryModel( aInStrm ); + } + } + } + break; + + case XML_persistStorage: + { + OUString aFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + if( aFragmentPath.getLength() > 0 ) + { + Reference< XInputStream > xStrgStrm = getFilter().openInputStream( aFragmentPath ); + if( xStrgStrm.is() ) + { + OleStorage aStorage( getFilter().getGlobalFactory(), xStrgStrm, false ); + BinaryXInputStream aInStrm( aStorage.openInputStream( CREATE_OUSTRING( "f" ) ), true ); + if( !aInStrm.isEof() ) + if( AxContainerModelBase* pModel = dynamic_cast< AxContainerModelBase* >( mrControl.createModel( aClassId ).get() ) ) + pModel->importBinaryModel( aInStrm ); } } } @@ -130,4 +154,3 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const } // namespace ole } // namespace oox - diff --git a/oox/source/ole/axcontrolhelper.cxx b/oox/source/ole/axcontrolhelper.cxx deleted file mode 100644 index 1ffb4343aaf5..000000000000 --- a/oox/source/ole/axcontrolhelper.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/ole/axcontrolhelper.hxx" -#include -#include -#include -#include "tokens.hxx" -#include "oox/helper/containerhelper.hxx" -#include "oox/core/filterbase.hxx" -#include "oox/drawingml/color.hxx" - -using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::graphic::XGraphic; -using ::com::sun::star::drawing::XDrawPage; -using ::com::sun::star::form::XForm; -using ::com::sun::star::form::XFormsSupplier; -using ::oox::core::FilterBase; - -namespace oox { -namespace ole { - -// ============================================================================ - -namespace { - -const sal_uInt32 AX_COLORTYPE_MASK = 0xFF000000; -const sal_uInt32 AX_COLORTYPE_CLIENT = 0x00000000; -const sal_uInt32 AX_COLORTYPE_PALETTE = 0x01000000; -const sal_uInt32 AX_COLORTYPE_BGR = 0x02000000; -const sal_uInt32 AX_COLORTYPE_SYSCOLOR = 0x80000000; - -const sal_uInt32 AX_PALETTECOLOR_MASK = 0x0000FFFF; -const sal_uInt32 AX_BGRCOLOR_MASK = 0x00FFFFFF; -const sal_uInt32 AX_SYSTEMCOLOR_MASK = 0x0000FFFF; - -// ---------------------------------------------------------------------------- - -/** Returns the UNO RGB color from the passed encoded OLE BGR color. */ -inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nAxColor ) -{ - return static_cast< sal_Int32 >( ((nAxColor & 0x0000FF) << 16) | (nAxColor & 0x00FF00) | ((nAxColor & 0xFF0000) >> 16) ); -} - -} // namespace - -// ============================================================================ - -AxControlHelper::AxControlHelper( const FilterBase& rFilter, AxDefaultColorMode eColorMode ) : - mrFilter( rFilter ), - meColorMode( eColorMode ), - mbHasFormQuerried( false ) -{ -} - -AxControlHelper::~AxControlHelper() -{ -} - -Reference< XForm > AxControlHelper::getControlForm() const -{ - if( !mbHasFormQuerried ) - { - mbHasFormQuerried = true; - mxForm = createControlForm(); // virtual call - } - return mxForm; -} - -sal_Int32 AxControlHelper::convertColor( sal_uInt32 nAxColor ) const -{ - static const sal_Int32 spnSystemColors[] = - { - XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption, - XML_menu, XML_window, XML_windowFrame, XML_menuText, - XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder, - XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace, - XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText, - XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText, - XML_infoBk - }; - - switch( nAxColor & AX_COLORTYPE_MASK ) - { - case AX_COLORTYPE_CLIENT: - switch( meColorMode ) - { - case AX_DEFAULTCOLORMODE_BGR: return lclDecodeBgrColor( nAxColor ); - case AX_DEFAULTCOLORMODE_PALETTE: return mrFilter.getPaletteColor( nAxColor & AX_PALETTECOLOR_MASK ); - } - break; - - case AX_COLORTYPE_PALETTE: - return mrFilter.getPaletteColor( nAxColor & AX_PALETTECOLOR_MASK ); - - case AX_COLORTYPE_BGR: - return lclDecodeBgrColor( nAxColor ); - - case AX_COLORTYPE_SYSCOLOR: - return mrFilter.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nAxColor & AX_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE ); - } - OSL_ENSURE( false, "AxControlHelper::convertColor - unknown color type" ); - return 0; -} - -// ============================================================================ - -AxEmbeddedControlHelper::AxEmbeddedControlHelper( const FilterBase& rFilter, - const Reference< XDrawPage >& rxDrawPage, AxDefaultColorMode eColorMode ) : - AxControlHelper( rFilter, eColorMode ), - mxDrawPage( rxDrawPage ) -{ -} - -Reference< XForm > AxEmbeddedControlHelper::createControlForm() const -{ - Reference< XForm > xForm; - try - { - Reference< XFormsSupplier > xFormsSupplier( mxDrawPage, UNO_QUERY_THROW ); - Reference< XNameContainer > xFormsNC( xFormsSupplier->getForms(), UNO_SET_THROW ); - OUString aFormName = CREATE_OUSTRING( "Standard" ); - if( xFormsNC->hasByName( aFormName ) ) - { - xFormsNC->getByName( aFormName ) >>= xForm; - } - else - { - Reference< XForm > xNewForm( getFilter().getModelFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW ); - xFormsNC->insertByName( aFormName, Any( xNewForm ) ); - // return the form if insertion did not fail - xForm = xNewForm; - } - } - catch( Exception& ) - { - } - return xForm; -} - -// ============================================================================ - -} // namespace ole -} // namespace oox - diff --git a/oox/source/ole/makefile.mk b/oox/source/ole/makefile.mk index 5fe0c08dbd6f..4e01392d4a57 100644 --- a/oox/source/ole/makefile.mk +++ b/oox/source/ole/makefile.mk @@ -44,10 +44,14 @@ SLOFILES = \ $(SLO)$/axbinaryreader.obj \ $(SLO)$/axcontrol.obj \ $(SLO)$/axcontrolfragment.obj \ - $(SLO)$/axcontrolhelper.obj \ $(SLO)$/olehelper.obj \ $(SLO)$/oleobjecthelper.obj \ - $(SLO)$/vbainputstream.obj + $(SLO)$/olestorage.obj \ + $(SLO)$/vbacontrol.obj \ + $(SLO)$/vbahelper.obj \ + $(SLO)$/vbainputstream.obj \ + $(SLO)$/vbamodule.obj \ + $(SLO)$/vbaproject.obj # --- Targets ------------------------------------------------------- diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index f26fb9d0cec3..68ae8c90802e 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -27,7 +27,9 @@ #include "oox/ole/olehelper.hxx" #include +#include "tokens.hxx" #include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/graphichelper.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -39,9 +41,24 @@ namespace ole { namespace { -const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; -const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; -const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; +const sal_uInt32 OLE_COLORTYPE_MASK = 0xFF000000; +const sal_uInt32 OLE_COLORTYPE_CLIENT = 0x00000000; +const sal_uInt32 OLE_COLORTYPE_PALETTE = 0x01000000; +const sal_uInt32 OLE_COLORTYPE_BGR = 0x02000000; +const sal_uInt32 OLE_COLORTYPE_SYSCOLOR = 0x80000000; + +const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF; +const sal_uInt32 OLE_BGRCOLOR_MASK = 0x00FFFFFF; +const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF; + +/** Returns the UNO RGB color from the passed encoded OLE BGR color. */ +inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nOleColor ) +{ + return static_cast< sal_Int32 >( ((nOleColor & 0x0000FF) << 16) | (nOleColor & 0x00FF00) | ((nOleColor & 0xFF0000) >> 16) ); +} + +// ---------------------------------------------------------------------------- + const sal_Char* const OLE_GUID_URLMONIKER = "{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}"; const sal_Char* const OLE_GUID_FILEMONIKER = "{00000303-0000-0000-C000-000000000046}"; @@ -69,14 +86,15 @@ void lclAppendHex( OUStringBuffer& orBuffer, Type nValue ) orBuffer.setCharAt( nCharIdx, spcHexChars[ nValue & 0xF ] ); } -OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bUnicode ) +OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, bool bUnicode ) { OUString aRet; sal_Int32 nChars = rInStrm.readInt32(); if( nChars > 0 ) { sal_Int32 nReadChars = getLimitedValue< sal_Int32, sal_Int32 >( nChars, 0, SAL_MAX_UINT16 ); - aRet = bUnicode ? rInStrm.readUnicodeArray( nReadChars, true ) : rInStrm.readCharArrayUC( nReadChars, eTextEnc, true ); + // byte strings are always in ANSI (Windows 1252) encoding + aRet = bUnicode ? rInStrm.readUnicodeArray( nReadChars, true ) : rInStrm.readCharArrayUC( nReadChars, RTL_TEXTENCODING_MS_1252, true ); // strings are NUL terminated, remove trailing NUL and possible other garbage sal_Int32 nNulPos = aRet.indexOf( '\0' ); if( nNulPos >= 0 ) @@ -91,6 +109,59 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // ============================================================================ +StdFontInfo::StdFontInfo() : + mnHeight( 0 ), + mnWeight( OLE_STDFONT_NORMAL ), + mnCharSet( WINDOWS_CHARSET_ANSI ), + mnFlags( 0 ) +{ +} + +StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, + sal_uInt16 nWeight, sal_uInt16 nCharSet, sal_uInt8 nFlags ) : + maName( rName ), + mnHeight( nHeight ), + mnWeight( nWeight ), + mnCharSet( nCharSet ), + mnFlags( nFlags ) +{ +} + +// ============================================================================ + +/*static*/ sal_Int32 OleHelper::decodeOleColor( + const GraphicHelper& rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr ) +{ + static const sal_Int32 spnSystemColors[] = + { + XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption, + XML_menu, XML_window, XML_windowFrame, XML_menuText, + XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder, + XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace, + XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText, + XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText, + XML_infoBk + }; + + switch( nOleColor & OLE_COLORTYPE_MASK ) + { + case OLE_COLORTYPE_CLIENT: + return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); + break; + + case OLE_COLORTYPE_PALETTE: + return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); + + case OLE_COLORTYPE_BGR: + return lclDecodeBgrColor( nOleColor ); + + case OLE_COLORTYPE_SYSCOLOR: + return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE ); + } + OSL_ENSURE( false, "OleHelper::decodeOleColor - unknown color type" ); + return API_RGB_BLACK; +} + /*static*/ OUString OleHelper::importGuid( BinaryInputStream& rInStrm ) { OUStringBuffer aBuffer; @@ -110,6 +181,24 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe return aBuffer.makeStringAndClear(); } +/*static*/ bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInStrm, bool bWithGuid ) +{ + if( bWithGuid ) + { + bool bIsStdFont = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDFONT ); + OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" ); + if( !bIsStdFont ) + return false; + } + + sal_uInt8 nVersion, nNameLen; + rInStrm >> nVersion >> orFontInfo.mnCharSet >> orFontInfo.mnFlags >> orFontInfo.mnWeight >> orFontInfo.mnHeight >> nNameLen; + // according to spec the name is ASCII + orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US ); + OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" ); + return !rInStrm.isEof() && (nVersion <= 1); +} + /*static*/ bool OleHelper::importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid ) { if( bWithGuid ) @@ -127,7 +216,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes); } -/*static*/ bool OleHelper::importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bWithGuid ) +/*static*/ bool OleHelper::importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, bool bWithGuid ) { if( bWithGuid ) { @@ -145,10 +234,10 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // display string if( getFlag( nFlags, OLE_STDHLINK_HASDISPLAY ) ) - orHlinkInfo.maDisplay = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maDisplay = lclReadStdHlinkString( rInStrm, true ); // frame string if( getFlag( nFlags, OLE_STDHLINK_HASFRAME ) ) - orHlinkInfo.maFrame = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maFrame = lclReadStdHlinkString( rInStrm, true ); // target if( getFlag( nFlags, OLE_STDHLINK_HASTARGET ) ) @@ -156,7 +245,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe if( getFlag( nFlags, OLE_STDHLINK_ASSTRING ) ) { OSL_ENSURE( getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - link not absolute" ); - orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, true ); } else // hyperlink moniker { @@ -167,7 +256,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe sal_Int16 nUpLevels; rInStrm >> nUpLevels; OSL_ENSURE( (nUpLevels == 0) || !getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - absolute filename with upcount" ); - orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, eTextEnc, false ); + orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, false ); rInStrm.skip( 24 ); sal_Int32 nBytes = rInStrm.readInt32(); if( nBytes > 0 ) @@ -200,9 +289,9 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // target location if( getFlag( nFlags, OLE_STDHLINK_HASLOCATION ) ) - orHlinkInfo.maLocation = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maLocation = lclReadStdHlinkString( rInStrm, true ); - return true; + return !rInStrm.isEof(); } // ============================================================================ diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx new file mode 100755 index 000000000000..39ecbb84a062 --- /dev/null +++ b/oox/source/ole/olestorage.cxx @@ -0,0 +1,420 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/olestorage.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "oox/helper/helper.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/binaryoutputstream.hxx" + +using ::rtl::OUString; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; +using ::com::sun::star::io::BufferSizeExceededException; +using ::com::sun::star::io::IOException; +using ::com::sun::star::io::NotConnectedException; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::io::XSeekable; +using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +typedef ::cppu::WeakImplHelper2< XSeekable, XOutputStream > OleOutputStreamBase; + +/** Implementation of an OLE storage output stream that inserts itself into the + storage when it is closed. + */ +class OleOutputStream : public OleOutputStreamBase +{ +public: + explicit OleOutputStream( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XNameContainer >& rxStorage, + const OUString& rElementName ); + virtual ~OleOutputStream(); + + virtual void SAL_CALL seek( sal_Int64 nPos ) throw( IllegalArgumentException, IOException, RuntimeException ); + virtual sal_Int64 SAL_CALL getPosition() throw( IOException, RuntimeException ); + virtual sal_Int64 SAL_CALL getLength() throw( IOException, RuntimeException ); + + virtual void SAL_CALL writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + virtual void SAL_CALL flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + virtual void SAL_CALL closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + +private: + void ensureSeekable() const throw( IOException ); + void ensureConnected() const throw( NotConnectedException ); + +private: + Reference< XNameContainer > mxStorage; + Reference< XStream > mxTempFile; + Reference< XOutputStream > mxOutStrm; + Reference< XSeekable > mxSeekable; + OUString maElementName; +}; + +// ---------------------------------------------------------------------------- + +OleOutputStream::OleOutputStream( const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XNameContainer >& rxStorage, const OUString& rElementName ) : + mxStorage( rxStorage ), + maElementName( rElementName ) +{ + try + { + mxTempFile.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + mxOutStrm = mxTempFile->getOutputStream(); + mxSeekable.set( mxOutStrm, UNO_QUERY ); + } + catch( Exception& ) + { + } +} + +OleOutputStream::~OleOutputStream() +{ +} + +void SAL_CALL OleOutputStream::seek( sal_Int64 nPos ) throw( IllegalArgumentException, IOException, RuntimeException ) +{ + ensureSeekable(); + mxSeekable->seek( nPos ); +} + +sal_Int64 SAL_CALL OleOutputStream::getPosition() throw( IOException, RuntimeException ) +{ + ensureSeekable(); + return mxSeekable->getPosition(); +} + +sal_Int64 SAL_CALL OleOutputStream::getLength() throw( IOException, RuntimeException ) +{ + ensureSeekable(); + return mxSeekable->getLength(); +} + +void SAL_CALL OleOutputStream::writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + mxOutStrm->writeBytes( rData ); +} + +void SAL_CALL OleOutputStream::flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + mxOutStrm->flush(); +} + +void SAL_CALL OleOutputStream::closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + ensureSeekable(); + // remember the class members + Reference< XOutputStream > xOutStrm = mxOutStrm; + Reference< XSeekable > xSeekable = mxSeekable; + // reset all class members + mxOutStrm.clear(); + mxSeekable.clear(); + // close stream (and let it throw something if needed) + xOutStrm->closeOutput(); + // on success, insert the stream into the OLE storage (must be seeked back before) + xSeekable->seek( 0 ); + if( !ContainerHelper::insertByName( mxStorage, maElementName, Any( mxTempFile ) ) ) + throw IOException(); +} + +void OleOutputStream::ensureSeekable() const throw( IOException ) +{ + if( !mxSeekable.is() ) + throw IOException(); +} + +void OleOutputStream::ensureConnected() const throw( NotConnectedException ) +{ + if( !mxOutStrm.is() ) + throw NotConnectedException(); +} + +} // namespace + +// ============================================================================ + +OleStorage::OleStorage( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XInputStream >& rxInStream, + bool bBaseStreamAccess ) : + StorageBase( rxInStream, bBaseStreamAccess ), + mxFactory( rxFactory ), + mpParentStorage( 0 ) +{ + OSL_ENSURE( mxFactory.is(), "OleStorage::OleStorage - missing service factory" ); + initStorage( rxInStream ); +} + +OleStorage::OleStorage( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XStream >& rxOutStream, + bool bBaseStreamAccess ) : + StorageBase( rxOutStream, bBaseStreamAccess ), + mxFactory( rxFactory ), + mpParentStorage( 0 ) +{ + OSL_ENSURE( mxFactory.is(), "OleStorage::OleStorage - missing service factory" ); + initStorage( rxOutStream ); +} + +OleStorage::OleStorage( + const OleStorage& rParentStorage, + const Reference< XNameContainer >& rxStorage, + const OUString& rElementName, + bool bReadOnly ) : + StorageBase( rParentStorage, rElementName, bReadOnly ), + mxFactory( rParentStorage.mxFactory ), + mxStorage( rxStorage ), + mpParentStorage( &rParentStorage ) +{ + OSL_ENSURE( mxStorage.is(), "OleStorage::OleStorage - missing substorage elements" ); +} + +OleStorage::OleStorage( + const OleStorage& rParentStorage, + const Reference< XStream >& rxOutStream, + const OUString& rElementName ) : + StorageBase( rParentStorage, rElementName, false ), + mxFactory( rParentStorage.mxFactory ), + mpParentStorage( &rParentStorage ) +{ + initStorage( rxOutStream ); +} + +OleStorage::~OleStorage() +{ +} + +// ---------------------------------------------------------------------------- + +void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) +{ + // if stream is not seekable, create temporary copy + Reference< XInputStream > xInStrm = rxInStream; + if( !Reference< XSeekable >( xInStrm, UNO_QUERY ).is() ) try + { + Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + { + Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW ); + BinaryXOutputStream aOutStrm( xOutStrm, true ); // true = close output stream on destruction of aOutStrm + BinaryXInputStream aInStrm( xInStrm, false ); // false = do not close intput stream on destruction of aInStrm + aInStrm.copyToStream( aOutStrm ); + } // scope closes output stream of tempfile + xInStrm = xTempFile->getInputStream(); + } + catch( Exception& ) + { + OSL_ENSURE( false, "OleStorage::initStorage - cannot create temporary copy of input stream" ); + } + + // create base storage object + if( xInStrm.is() ) try + { + Sequence< Any > aArgs( 2 ); + aArgs[ 0 ] <<= xInStrm; + aArgs[ 1 ] <<= true; // true = do not create a copy of the input stream + mxStorage.set( mxFactory->createInstanceWithArguments( + CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } +} + +void OleStorage::initStorage( const Reference< XStream >& rxOutStream ) +{ + // create base storage object + if( rxOutStream.is() ) try + { + Sequence< Any > aArgs( 2 ); + aArgs[ 0 ] <<= rxOutStream; + aArgs[ 1 ] <<= true; // true = do not create a copy of the stream + mxStorage.set( mxFactory->createInstanceWithArguments( + CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } +} + +// StorageBase interface ------------------------------------------------------ + +bool OleStorage::implIsStorage() const +{ + if( mxStorage.is() ) try + { + /* If this is not an OLE storage, hasElements() of the OLESimpleStorage + implementation throws an exception. But we do not return the result + of hasElements(), because an empty storage is a valid storage too. */ + mxStorage->hasElements(); + return true; + } + catch( Exception& ) + { + } + return false; +} + +Reference< XStorage > OleStorage::implGetXStorage() const +{ + OSL_ENSURE( false, "OleStorage::getXStorage - not implemented" ); + return Reference< XStorage >(); +} + +void OleStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const +{ + Sequence< OUString > aNames; + if( mxStorage.is() ) try + { + aNames = mxStorage->getElementNames(); + if( aNames.getLength() > 0 ) + orElementNames.insert( orElementNames.end(), aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() ); + } + catch( Exception& ) + { + } +} + +StorageRef OleStorage::implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) +{ + StorageRef xSubStorage; + if( mxStorage.is() && (rElementName.getLength() > 0) ) + { + try + { + Reference< XNameContainer > xSubElements( mxStorage->getByName( rElementName ), UNO_QUERY_THROW ); + xSubStorage.reset( new OleStorage( *this, xSubElements, rElementName, true ) ); + } + catch( Exception& ) + { + } + + /* The OLESimpleStorage API implementation seems to be buggy in the + area of writable inplace substorage (sometimes it overwrites other + unrelated streams with zero bytes). We go the save way and create a + new OLE storage based on a temporary file. All operations are + performed on this clean storage. On committing, the storage will be + completely re-inserted into the parent storage. */ + if( !isReadOnly() && (bCreateMissing || xSubStorage.get()) ) try + { + // create new storage based on a temp file + Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + StorageRef xTempStorage( new OleStorage( *this, xTempFile, rElementName ) ); + // copy existing substorage into temp storage + if( xSubStorage.get() ) + xSubStorage->copyStorageToStorage( *xTempStorage ); + // return the temp storage to caller + xSubStorage = xTempStorage; + } + catch( Exception& ) + { + } + } + return xSubStorage; +} + +Reference< XInputStream > OleStorage::implOpenInputStream( const OUString& rElementName ) +{ + Reference< XInputStream > xInStream; + if( mxStorage.is() ) try + { + xInStream.set( mxStorage->getByName( rElementName ), UNO_QUERY ); + } + catch( Exception& ) + { + } + return xInStream; +} + +Reference< XOutputStream > OleStorage::implOpenOutputStream( const OUString& rElementName ) +{ + Reference< XOutputStream > xOutStream; + if( mxStorage.is() && (rElementName.getLength() > 0) ) + xOutStream.set( new OleOutputStream( mxFactory, mxStorage, rElementName ) ); + return xOutStream; +} + +void OleStorage::implCommit() const +{ + try + { + // commit this storage (finalizes the file this storage is based on) + Reference< XTransactedObject >( mxStorage, UNO_QUERY_THROW )->commit(); + // re-insert this storage into the parent storage + if( mpParentStorage ) + { + if( mpParentStorage->mxStorage->hasByName( getName() ) ) + { + // replaceByName() does not work (#i109539#) + mpParentStorage->mxStorage->removeByName( getName() ); + Reference< XTransactedObject >( mpParentStorage->mxStorage, UNO_QUERY_THROW )->commit(); + } + mpParentStorage->mxStorage->insertByName( getName(), Any( mxStorage ) ); + // this requires another commit(), which will be performed by the parent storage + } + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx new file mode 100755 index 000000000000..2674c30d9a73 --- /dev/null +++ b/oox/source/ole/vbacontrol.cxx @@ -0,0 +1,811 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbacontrol.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "tokens.hxx" +#include "oox/helper/attributelist.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/helper/storagebase.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/vbahelper.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::io::XInputStreamProvider; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::XComponentContext; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +const sal_uInt16 VBA_SITE_CLASSIDINDEX = 0x8000; +const sal_uInt16 VBA_SITE_INDEXMASK = 0x7FFF; +const sal_uInt16 VBA_SITE_FORM = 7; +const sal_uInt16 VBA_SITE_IMAGE = 12; +const sal_uInt16 VBA_SITE_FRAME = 14; +const sal_uInt16 VBA_SITE_SPINBUTTON = 16; +const sal_uInt16 VBA_SITE_COMMANDBUTTON = 17; +const sal_uInt16 VBA_SITE_TABSTRIP = 18; +const sal_uInt16 VBA_SITE_LABEL = 21; +const sal_uInt16 VBA_SITE_TEXTBOX = 23; +const sal_uInt16 VBA_SITE_LISTBOX = 24; +const sal_uInt16 VBA_SITE_COMBOBOX = 25; +const sal_uInt16 VBA_SITE_CHECKBOX = 26; +const sal_uInt16 VBA_SITE_OPTIONBUTTON = 27; +const sal_uInt16 VBA_SITE_TOGGLEBUTTON = 28; +const sal_uInt16 VBA_SITE_SCROLLBAR = 47; +const sal_uInt16 VBA_SITE_MULTIPAGE = 57; +const sal_uInt16 VBA_SITE_UNKNOWN = 0x7FFF; + +const sal_uInt32 VBA_SITE_TABSTOP = 0x00000001; +const sal_uInt32 VBA_SITE_VISIBLE = 0x00000002; +const sal_uInt32 VBA_SITE_DEFAULTBUTTON = 0x00000004; +const sal_uInt32 VBA_SITE_CANCELBUTTON = 0x00000008; +const sal_uInt32 VBA_SITE_OSTREAM = 0x00000010; +const sal_uInt32 VBA_SITE_DEFFLAGS = 0x00000033; + +const sal_uInt8 VBA_SITEINFO_COUNT = 0x80; +const sal_uInt8 VBA_SITEINFO_MASK = 0x7F; + +// ---------------------------------------------------------------------------- + +/** Collects names of all controls in a user form or container control. Allows + to generate unused names for dummy controls separating option groups. + */ +class VbaControlNamesSet +{ +public: + explicit VbaControlNamesSet(); + + /** Inserts the name of the passed control. */ + void insertName( const VbaFormControl& rControl ); + /** Returns a name that is not contained in this set. */ + OUString generateDummyName(); + +private: + typedef ::std::set< OUString > OUStringSet; + OUStringSet maCtrlNames; + const OUString maDummyBaseName; + sal_Int32 mnIndex; +}; + +VbaControlNamesSet::VbaControlNamesSet() : + maDummyBaseName( CREATE_OUSTRING( "DummyGroupSep" ) ), + mnIndex( 0 ) +{ +} + +void VbaControlNamesSet::insertName( const VbaFormControl& rControl ) +{ + OUString aName = rControl.getControlName(); + if( aName.getLength() > 0 ) + maCtrlNames.insert( aName ); +} + +OUString VbaControlNamesSet::generateDummyName() +{ + OUString aCtrlName; + do + { + aCtrlName = OUStringBuffer( maDummyBaseName ).append( ++mnIndex ).makeStringAndClear(); + } + while( maCtrlNames.count( aCtrlName ) > 0 ); + maCtrlNames.insert( aCtrlName ); + return aCtrlName; +} + +// ---------------------------------------------------------------------------- + +/** Functor that inserts the name of a control into a VbaControlNamesSet. */ +struct VbaControlNameInserter +{ +public: + VbaControlNamesSet& mrCtrlNames; + inline explicit VbaControlNameInserter( VbaControlNamesSet& rCtrlNames ) : mrCtrlNames( rCtrlNames ) {} + inline void operator()( const VbaFormControl& rControl ) { mrCtrlNames.insertName( rControl ); } +}; + +// ---------------------------------------------------------------------------- + +/** A dummy invisible form control (fixed label without text) that is used to + separate two groups of option buttons. + */ +class VbaDummyFormControl : public VbaFormControl +{ +public: + explicit VbaDummyFormControl( const OUString& rName ); +}; + +VbaDummyFormControl::VbaDummyFormControl( const OUString& rName ) +{ + mxSiteModel.reset( new VbaSiteModel ); + mxSiteModel->importProperty( XML_Name, rName ); + mxSiteModel->importProperty( XML_VariousPropertyBits, OUString( sal_Unicode( '0' ) ) ); + + mxCtrlModel.reset( new AxLabelModel ); + mxCtrlModel->setAwtModelMode(); + mxCtrlModel->importProperty( XML_Size, CREATE_OUSTRING( "10;10" ) ); +} + +} // namespace + +// ============================================================================ + +VbaSiteModel::VbaSiteModel() : + maPos( 0, 0 ), + mnId( 0 ), + mnHelpContextId( 0 ), + mnFlags( VBA_SITE_DEFFLAGS ), + mnStreamLen( 0 ), + mnTabIndex( -1 ), + mnClassIdOrCache( VBA_SITE_UNKNOWN ), + mnGroupId( 0 ) +{ +} + +VbaSiteModel::~VbaSiteModel() +{ +} + +void VbaSiteModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) +{ + switch( nPropId ) + { + case XML_Name: maName = rValue; break; + case XML_Tag: maTag = rValue; break; + case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; + } +} + +bool VbaSiteModel::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readStringProperty( maName ); + aReader.readStringProperty( maTag ); + aReader.readIntProperty< sal_Int32 >( mnId ); + aReader.readIntProperty< sal_Int32 >( mnHelpContextId ); + aReader.readIntProperty< sal_uInt32 >( mnFlags ); + aReader.readIntProperty< sal_uInt32 >( mnStreamLen ); + aReader.readIntProperty< sal_Int16 >( mnTabIndex ); + aReader.readIntProperty< sal_uInt16 >( mnClassIdOrCache ); + aReader.readPairProperty( maPos ); + aReader.readIntProperty< sal_uInt16 >( mnGroupId ); + aReader.skipUndefinedProperty(); + aReader.readStringProperty( maToolTip ); + aReader.skipStringProperty(); // license key + aReader.readStringProperty( maLinkedCell ); + aReader.readStringProperty( maSourceRange ); + return aReader.finalizeImport(); +} + +void VbaSiteModel::moveRelative( const AxPairData& rDistance ) +{ + maPos.first += rDistance.first; + maPos.second += rDistance.second; +} + +bool VbaSiteModel::isContainer() const +{ + return !getFlag( mnFlags, VBA_SITE_OSTREAM ); +} + +sal_uInt32 VbaSiteModel::getStreamLength() const +{ + return isContainer() ? 0 : mnStreamLen; +} + +OUString VbaSiteModel::getSubStorageName() const +{ + if( mnId >= 0 ) + { + OUStringBuffer aBuffer; + aBuffer.append( sal_Unicode( 'i' ) ); + if( mnId < 10 ) + aBuffer.append( sal_Unicode( '0' ) ); + aBuffer.append( mnId ); + return aBuffer.makeStringAndClear(); + } + return OUString(); +} + +ControlModelRef VbaSiteModel::createControlModel( const AxClassTable& rClassTable ) const +{ + ControlModelRef xCtrlModel; + + sal_Int32 nTypeIndex = static_cast< sal_Int32 >( mnClassIdOrCache & VBA_SITE_INDEXMASK ); + if( !getFlag( mnClassIdOrCache, VBA_SITE_CLASSIDINDEX ) ) + { + switch( nTypeIndex ) + { + case VBA_SITE_COMMANDBUTTON: xCtrlModel.reset( new AxCommandButtonModel ); break; + case VBA_SITE_LABEL: xCtrlModel.reset( new AxLabelModel ); break; + case VBA_SITE_IMAGE: xCtrlModel.reset( new AxImageModel ); break; + case VBA_SITE_TOGGLEBUTTON: xCtrlModel.reset( new AxToggleButtonModel ); break; + case VBA_SITE_CHECKBOX: xCtrlModel.reset( new AxCheckBoxModel ); break; + case VBA_SITE_OPTIONBUTTON: xCtrlModel.reset( new AxOptionButtonModel ); break; + case VBA_SITE_TEXTBOX: xCtrlModel.reset( new AxTextBoxModel ); break; + case VBA_SITE_LISTBOX: xCtrlModel.reset( new AxListBoxModel ); break; + case VBA_SITE_COMBOBOX: xCtrlModel.reset( new AxComboBoxModel ); break; + case VBA_SITE_SPINBUTTON: /*xCtrlModel.reset( new AxSpinButtonModel );*/ break; // not supported (?) + case VBA_SITE_SCROLLBAR: xCtrlModel.reset( new AxScrollBarModel ); break; + case VBA_SITE_TABSTRIP: break; // not supported + case VBA_SITE_FRAME: xCtrlModel.reset( new AxFrameModel ); break; + case VBA_SITE_MULTIPAGE: break; // not supported + case VBA_SITE_FORM: break; // not supported + default: OSL_ENSURE( false, "VbaSiteModel::createControlModel - unknown type index" ); + } + } + else + { + const OUString* pGuid = ContainerHelper::getVectorElement( rClassTable, nTypeIndex ); + OSL_ENSURE( pGuid, "VbaSiteModel::createControlModel - invalid class table index" ); + if( pGuid ) + { + if( pGuid->equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) + xCtrlModel.reset( new ComCtlScrollBarModel( 6 ) ); + else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_50 ) ) + xCtrlModel.reset( new ComCtlProgressBarModel( 5 ) ); + else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_60 ) ) + xCtrlModel.reset( new ComCtlProgressBarModel( 6 ) ); + } + } + + if( xCtrlModel.get() ) + { + // user form controls are AWT models + xCtrlModel->setAwtModelMode(); + + // check that container model matches container flag in site data + bool bModelIsContainer = dynamic_cast< const AxContainerModelBase* >( xCtrlModel.get() ) != 0; + bool bTypeMatch = bModelIsContainer == isContainer(); + OSL_ENSURE( bTypeMatch, "VbaSiteModel::createControlModel - container type does not match container flag" ); + if( !bTypeMatch ) + xCtrlModel.reset(); + } + return xCtrlModel; +} + +void VbaSiteModel::convertProperties( PropertyMap& rPropMap, + const ControlConverter& rConv, ApiControlType eCtrlType, sal_Int32 nCtrlIndex ) const +{ + rPropMap.setProperty( PROP_Name, maName ); + rPropMap.setProperty( PROP_Tag, maTag ); + + if( eCtrlType != API_CONTROL_DIALOG ) + { + rPropMap.setProperty( PROP_HelpText, maToolTip ); + rPropMap.setProperty( PROP_EnableVisible, getFlag( mnFlags, VBA_SITE_VISIBLE ) ); + // we need to set the passed control index to make option button groups work + if( (0 <= nCtrlIndex) && (nCtrlIndex <= SAL_MAX_INT16) ) + rPropMap.setProperty( PROP_TabIndex, static_cast< sal_Int16 >( nCtrlIndex ) ); + // progress bar and group box support TabIndex, but not Tabstop... + if( (eCtrlType != API_CONTROL_PROGRESSBAR) && (eCtrlType != API_CONTROL_GROUPBOX) ) + rPropMap.setProperty( PROP_Tabstop, getFlag( mnFlags, VBA_SITE_TABSTOP ) ); + rConv.convertPosition( rPropMap, maPos ); + } +} + +// ============================================================================ + +VbaFormControl::VbaFormControl() +{ +} + +VbaFormControl::~VbaFormControl() +{ +} + +void VbaFormControl::importModelOrStorage( BinaryInputStream& rInStrm, StorageBase& rStrg, const AxClassTable& rClassTable ) +{ + if( mxSiteModel.get() ) + { + if( mxSiteModel->isContainer() ) + { + StorageRef xSubStrg = rStrg.openSubStorage( mxSiteModel->getSubStorageName(), false ); + OSL_ENSURE( xSubStrg.get(), "VbaFormControl::importModelOrStorage - cannot find storage for embedded control" ); + if( xSubStrg.get() ) + importStorage( *xSubStrg, rClassTable ); + } + else if( !rInStrm.isEof() ) + { + sal_Int64 nNextStrmPos = rInStrm.tell() + mxSiteModel->getStreamLength(); + importControlModel( rInStrm, rClassTable ); + rInStrm.seek( nNextStrmPos ); + } + } +} + +OUString VbaFormControl::getControlName() const +{ + return mxSiteModel.get() ? mxSiteModel->getName() : OUString(); +} + +void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex, + const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const +{ + if( rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get() ) try + { + // create the control model + OUString aServiceName = mxCtrlModel->getServiceName(); + Reference< XMultiServiceFactory > xModelFactory( rxParentNC, UNO_QUERY_THROW ); + Reference< XControlModel > xCtrlModel( xModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + + // convert all properties and embedded controls + if( convertProperties( xCtrlModel, rConv, nCtrlIndex ) ) + { + // insert into parent container + const OUString& rCtrlName = mxSiteModel->getName(); + OSL_ENSURE( !rxParentNC->hasByName( rCtrlName ), "VbaFormControl::createAndConvert - multiple controls with equal name" ); + ContainerHelper::insertByName( rxParentNC, rCtrlName, Any( xCtrlModel ) ); + } + } + catch( Exception& ) + { + } +} + +// protected ------------------------------------------------------------------ + +void VbaFormControl::importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable ) +{ + createControlModel( rClassTable ); + if( mxCtrlModel.get() ) + mxCtrlModel->importBinaryModel( rInStrm ); +} + +void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rClassTable ) +{ + createControlModel( rClassTable ); + AxContainerModelBase* pContainerModel = dynamic_cast< AxContainerModelBase* >( mxCtrlModel.get() ); + OSL_ENSURE( pContainerModel, "VbaFormControl::importStorage - missing container control model" ); + if( pContainerModel ) + { + /* Open the 'f' stream containing the model of this control and a list + of site models for all child controls. */ + BinaryXInputStream aFStrm( rStrg.openInputStream( CREATE_OUSTRING( "f" ) ), true ); + OSL_ENSURE( !aFStrm.isEof(), "VbaFormControl::importStorage - missing 'f' stream" ); + + /* Read the properties of this container control and the class table + (into the maClassTable vector) containing a list of GUIDs for + exotic embedded controls. */ + if( !aFStrm.isEof() && pContainerModel->importBinaryModel( aFStrm ) && pContainerModel->importClassTable( aFStrm, maClassTable ) ) + { + /* Read the site models of all embedded controls (this fills the + maControls vector). Ignore failure of importSiteModels() but + try to import as much controls as possible. */ + importEmbeddedSiteModels( aFStrm ); + + /* Open the 'o' stream containing models of embedded simple + controls. Stream may be empty or missing, if this control + contains no controls or only container controls. */ + BinaryXInputStream aOStrm( rStrg.openInputStream( CREATE_OUSTRING( "o" ) ), true ); + + /* Iterate over all embedded controls, import model from 'o' + stream (for embedded simple controls) or from the substorage + (for embedded container controls). */ + maControls.forEachMem( &VbaFormControl::importModelOrStorage, + ::boost::ref( aOStrm ), ::boost::ref( rStrg ), ::boost::cref( maClassTable ) ); + + /* Reorder the controls (sorts all option buttons of an option + group together), and move all children of all embedded frames + (group boxes) to this control (UNO group boxes cannot contain + other controls). */ + finalizeEmbeddedControls(); + } + } +} + +bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, + const ControlConverter& rConv, sal_Int32 nCtrlIndex ) const +{ + if( rxCtrlModel.is() && mxSiteModel.get() && mxCtrlModel.get() ) + { + const OUString& rCtrlName = mxSiteModel->getName(); + OSL_ENSURE( rCtrlName.getLength() > 0, "VbaFormControl::convertProperties - control without name" ); + if( rCtrlName.getLength() > 0 ) + { + // convert all properties + PropertyMap aPropMap; + mxSiteModel->convertProperties( aPropMap, rConv, mxCtrlModel->getControlType(), nCtrlIndex ); + mxCtrlModel->convertProperties( aPropMap, rConv ); + mxCtrlModel->convertSize( aPropMap, rConv ); + PropertySet aPropSet( rxCtrlModel ); + aPropSet.setProperties( aPropMap ); + + // create and convert all embedded controls + if( !maControls.empty() ) try + { + Reference< XNameContainer > xCtrlModelNC( rxCtrlModel, UNO_QUERY_THROW ); + /* Call conversion for all controls. Pass vector index as new + tab order to make option button groups work correctly. */ + maControls.forEachMemWithIndex( &VbaFormControl::createAndConvert, + ::boost::cref( xCtrlModelNC ), ::boost::cref( rConv ) ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "VbaFormControl::convertProperties - cannot get control container interface" ); + } + + return true; + } + } + return false; +} + +// private -------------------------------------------------------------------- + +void VbaFormControl::createControlModel( const AxClassTable& rClassTable ) +{ + // derived classes may have created their own control model + if( !mxCtrlModel && mxSiteModel.get() ) + mxCtrlModel = mxSiteModel->createControlModel( rClassTable ); +} + +bool VbaFormControl::importSiteModel( BinaryInputStream& rInStrm ) +{ + mxSiteModel.reset( new VbaSiteModel ); + return mxSiteModel->importBinaryModel( rInStrm ); +} + +bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) +{ + sal_uInt64 nAnchorPos = rInStrm.tell(); + sal_uInt32 nSiteCount, nSiteDataSize; + rInStrm >> nSiteCount >> nSiteDataSize; + sal_Int64 nSiteEndPos = rInStrm.tell() + nSiteDataSize; + + // skip the site info structure + sal_uInt32 nSiteIndex = 0; + while( !rInStrm.isEof() && (nSiteIndex < nSiteCount) ) + { + rInStrm.skip( 1 ); // site depth + sal_uInt8 nTypeCount = rInStrm.readuInt8(); // 'type-or-count' byte + if( getFlag( nTypeCount, VBA_SITEINFO_COUNT ) ) + { + /* Count flag is set: the 'type-or-count' byte contains the number + of controls in the lower bits, the type specifier follows in + the next byte. The type specifier should always be 1 according + to the specification. */ + rInStrm.skip( 1 ); + nSiteIndex += (nTypeCount & VBA_SITEINFO_MASK); + } + else + { + /* Count flag is not set: the 'type-or-count' byte contains the + type specifier of *one* control in the lower bits (this type + should be 1, see above). */ + ++nSiteIndex; + } + } + // align the stream to 32bit, relative to start of entire site info + rInStrm.align( 4, nAnchorPos ); + + // import the site models for all embedded controls + maControls.clear(); + bool bValid = !rInStrm.isEof(); + for( nSiteIndex = 0; bValid && (nSiteIndex < nSiteCount); ++nSiteIndex ) + { + VbaFormControlRef xControl( new VbaFormControl ); + maControls.push_back( xControl ); + bValid = xControl->importSiteModel( rInStrm ); + } + + rInStrm.seek( nSiteEndPos ); + return bValid; +} + +void VbaFormControl::finalizeEmbeddedControls() +{ + /* This function performs two tasks: + + 1) Reorder the controls appropriately (sort all option buttons of an + option group together to make grouping work). + 2) Move all children of all embedded frames (group boxes) to this + control (UNO group boxes cannot contain other controls). + */ + + // first, sort all controls by original tab index + ::std::sort( maControls.begin(), maControls.end(), &compareByTabIndex ); + + /* Collect the programmatical names of all embedded controls (needed to be + able to set unused names to new dummy controls created below). Also + collect the names of all children of embedded frames (group boxes). + Luckily, names of controls must be unique in the entire form, not just + in the current container. */ + VbaControlNamesSet aControlNames; + VbaControlNameInserter aInserter( aControlNames ); + maControls.forEach( aInserter ); + for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) + if( (*aIt)->mxCtrlModel.get() && ((*aIt)->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) + (*aIt)->maControls.forEach( aInserter ); + + /* Reprocess the sorted list and collect all option button controls that + are part of the same option group (determined by group name). All + controls will be stored in a vector of vectors, that collects every + option button group in one vector element, and other controls between + these option groups (or leading or trailing controls) in other vector + elements. If an option button group follows another group, a dummy + separator control has to be inserted. */ + typedef RefVector< VbaFormControlVector > VbaFormControlVectorVector; + VbaFormControlVectorVector aControlGroups; + + typedef RefMap< OUString, VbaFormControlVector > VbaFormControlVectorMap; + VbaFormControlVectorMap aOptionGroups; + + typedef VbaFormControlVectorMap::mapped_type VbaFormControlVectorRef; + bool bLastWasOptionButton = false; + for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) + { + VbaFormControlRef xControl = *aIt; + const ControlModelBase* pCtrlModel = xControl->mxCtrlModel.get(); + + if( const AxOptionButtonModel* pOptButtonModel = dynamic_cast< const AxOptionButtonModel* >( pCtrlModel ) ) + { + // check if a new option group needs to be created + const OUString& rGroupName = pOptButtonModel->getGroupName(); + VbaFormControlVectorRef& rxOptionGroup = aOptionGroups[ rGroupName ]; + if( !rxOptionGroup ) + { + /* If last control was an option button too, we have two + option groups following each other, so a dummy separator + control is needed. */ + if( bLastWasOptionButton ) + { + VbaFormControlVectorRef xDummyGroup( new VbaFormControlVector ); + aControlGroups.push_back( xDummyGroup ); + OUString aName = aControlNames.generateDummyName(); + VbaFormControlRef xDummyControl( new VbaDummyFormControl( aName ) ); + xDummyGroup->push_back( xDummyControl ); + } + rxOptionGroup.reset( new VbaFormControlVector ); + aControlGroups.push_back( rxOptionGroup ); + } + /* Append the option button to the control group (which is now + referred by the vector aControlGroups and by the map + aOptionGroups). */ + rxOptionGroup->push_back( xControl ); + bLastWasOptionButton = true; + } + else + { + // open a new control group, if the last group is an option group + if( bLastWasOptionButton || aControlGroups.empty() ) + { + VbaFormControlVectorRef xControlGroup( new VbaFormControlVector ); + aControlGroups.push_back( xControlGroup ); + } + // append the control to the last control group + VbaFormControlVector& rLastGroup = *aControlGroups.back(); + rLastGroup.push_back( xControl ); + bLastWasOptionButton = false; + + // if control is a group box, move all its children to this control + if( pCtrlModel && (pCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) + { + /* Move all embedded controls of the group box relative to the + position of the group box. */ + xControl->moveEmbeddedToAbsoluteParent(); + /* Insert all children of the group box into the last control + group (following the group box). */ + rLastGroup.insert( rLastGroup.end(), xControl->maControls.begin(), xControl->maControls.end() ); + xControl->maControls.clear(); + // check if last control of the group box is an option button + bLastWasOptionButton = dynamic_cast< const AxOptionButtonModel* >( rLastGroup.back()->mxCtrlModel.get() ) != 0; + } + } + } + + // flatten the vector of vectors of form controls to a single vector + maControls.clear(); + for( VbaFormControlVectorVector::iterator aIt = aControlGroups.begin(), aEnd = aControlGroups.end(); aIt != aEnd; ++aIt ) + maControls.insert( maControls.end(), (*aIt)->begin(), (*aIt)->end() ); +} + +void VbaFormControl::moveRelative( const AxPairData& rDistance ) +{ + if( mxSiteModel.get() ) + mxSiteModel->moveRelative( rDistance ); +} + +void VbaFormControl::moveEmbeddedToAbsoluteParent() +{ + if( mxSiteModel.get() && !maControls.empty() ) + { + // distance to move is equal to position of this control in its parent + AxPairData aDistance = mxSiteModel->getPosition(); + + /* For group boxes: add half of the font height to Y position (VBA + positions relative to frame border line, not to 'top' of frame). */ + const AxFontDataModel* pFontModel = dynamic_cast< const AxFontDataModel* >( mxCtrlModel.get() ); + if( pFontModel && (pFontModel->getControlType() == API_CONTROL_GROUPBOX) ) + { + // convert points to 1/100 mm (1 pt = 1/72 inch = 2.54/72 cm = 2540/72 1/100 mm) + sal_Int32 nFontHeight = static_cast< sal_Int32 >( pFontModel->getFontHeight() * 2540 / 72 ); + aDistance.second += nFontHeight / 2; + } + + // move the embedded controls + maControls.forEachMem( &VbaFormControl::moveRelative, ::boost::cref( aDistance ) ); + } +} + +/*static*/ bool VbaFormControl::compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight ) +{ + // sort controls without model to the end + sal_Int32 nLeftTabIndex = rxLeft->mxSiteModel.get() ? rxLeft->mxSiteModel->getTabIndex() : SAL_MAX_INT32; + sal_Int32 nRightTabIndex = rxRight->mxSiteModel.get() ? rxRight->mxSiteModel->getTabIndex() : SAL_MAX_INT32; + return nLeftTabIndex < nRightTabIndex; +} + +// ============================================================================ + +namespace { + +OUString lclGetQuotedString( const OUString& rCodeLine ) +{ + OUStringBuffer aBuffer; + sal_Int32 nLen = rCodeLine.getLength(); + if( (nLen > 0) && (rCodeLine[ 0 ] == '"') ) + { + bool bExitLoop = false; + for( sal_Int32 nIndex = 1; !bExitLoop && (nIndex < nLen); ++nIndex ) + { + sal_Unicode cChar = rCodeLine[ nIndex ]; + // exit on closing quote char (but check on double quote chars) + bExitLoop = (cChar == '"') && ((nIndex + 1 == nLen) || (rCodeLine[ nIndex + 1 ] != '"')); + if( !bExitLoop ) + { + aBuffer.append( cChar ); + // skip second quote char + if( cChar == '"' ) + ++nIndex; + } + } + } + return aBuffer.makeStringAndClear(); +} + +} // namespace + +// ---------------------------------------------------------------------------- + +VbaUserForm::VbaUserForm( const Reference< XMultiServiceFactory >& rxGlobalFactory, + const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + ControlConverter( rGraphicHelper, bDefaultColorBgr ), + mxGlobalFactory( rxGlobalFactory ) +{ + OSL_ENSURE( mxGlobalFactory.is(), "VbaUserForm::VbaUserForm - missing service factory" ); +} + +void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, const OUString& rModuleName, rtl_TextEncoding eTextEnc ) +{ + OSL_ENSURE( rxDialogLib.is(), "VbaUserForm::importForm - missing dialog library" ); + if( !mxGlobalFactory.is() || !rxDialogLib.is() ) + return; + + // check that the '03VBFrame' stream exists, this is required for forms + BinaryXInputStream aInStrm( rVbaFormStrg.openInputStream( CREATE_OUSTRING( "\003VBFrame" ) ), true ); + OSL_ENSURE( !aInStrm.isEof(), "VbaUserForm::importForm - missing \\003VBFrame stream" ); + if( aInStrm.isEof() ) + return; + + // scan for the line 'Begin {GUID} ' + TextInputStream aFrameTextStrm( aInStrm, eTextEnc ); + const OUString aBegin = CREATE_OUSTRING( "Begin" ); + OUString aLine; + bool bBeginFound = false; + while( !bBeginFound && !aFrameTextStrm.isEof() ) + { + aLine = aFrameTextStrm.readLine().trim(); + bBeginFound = VbaHelper::eatKeyword( aLine, aBegin ); + } + // check for the specific GUID that represents VBA forms + if( !bBeginFound || !VbaHelper::eatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) + return; + + // remaining line is the form name + OUString aFormName = aLine.trim(); + OSL_ENSURE( aFormName.getLength() > 0, "VbaUserForm::importForm - missing form name" ); + OSL_ENSURE( rModuleName.equalsIgnoreAsciiCase( aFormName ), "VbaUserForm::importFrameStream - form and module name mismatch" ); + if( aFormName.getLength() == 0 ) + aFormName = rModuleName; + if( aFormName.getLength() == 0 ) + return; + mxSiteModel.reset( new VbaSiteModel ); + mxSiteModel->importProperty( XML_Name, aFormName ); + + // read the form properties (caption is contained in this '03VBFrame' stream, not in the 'f' stream) + mxCtrlModel.reset( new AxUserFormModel ); + OUString aKey, aValue; + bool bExitLoop = false; + while( !bExitLoop && !aFrameTextStrm.isEof() ) + { + aLine = aFrameTextStrm.readLine().trim(); + bExitLoop = aLine.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "End" ) ); + if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) + { + if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Caption" ) ) ) + mxCtrlModel->importProperty( XML_Caption, lclGetQuotedString( aValue ) ); + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Tag" ) ) ) + mxSiteModel->importProperty( XML_Tag, lclGetQuotedString( aValue ) ); + } + } + + // use generic container control functionality to import the embedded controls + importStorage( rVbaFormStrg, AxClassTable() ); + + try + { + // create the dialog model + OUString aServiceName = mxCtrlModel->getServiceName(); + Reference< XControlModel > xDialogModel( mxGlobalFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + Reference< XNameContainer > xDialogNC( xDialogModel, UNO_QUERY_THROW ); + + // convert properties and embedded controls + if( convertProperties( xDialogModel, *this, 0 ) ) + { + // export the dialog to XML and insert it into the dialog library + PropertySet aFactoryProps( mxGlobalFactory ); + Reference< XComponentContext > xCompContext( aFactoryProps.getAnyProperty( PROP_DefaultContext ), UNO_QUERY_THROW ); + Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, xCompContext ), UNO_SET_THROW ); + OSL_ENSURE( !rxDialogLib->hasByName( aFormName ), "VbaUserForm::importForm - multiple dialogs with equal name" ); + ContainerHelper::insertByName( rxDialogLib, aFormName, Any( xDialogSource ) ); + } + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx new file mode 100755 index 000000000000..7293e357e746 --- /dev/null +++ b/oox/source/ole/vbahelper.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbahelper.hxx" +#include +#include +#include +#include +#include +#include "oox/helper/binaryinputstream.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::container::XNameReplace; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace ole { + +// ============================================================================ + +/*static*/ OUString VbaHelper::getBasicScriptUrl( + const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) +{ + OSL_ENSURE( rLibraryName.getLength() > 0, "VbaHelper::getBasicScriptUrl - library name is empty" ); + OSL_ENSURE( rModuleName.getLength() > 0, "VbaHelper::getBasicScriptUrl - module name is empty" ); + OSL_ENSURE( rMacroName.getLength() > 0, "VbaHelper::getBasicScriptUrl - macro name is empty" ); + const sal_Unicode cDot = '.'; + return OUStringBuffer(). + appendAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.script:" ) ). + append( rLibraryName ).append( cDot ).append( rModuleName ).append( cDot ).append( rMacroName ). + appendAscii( RTL_CONSTASCII_STRINGPARAM( "?language=Basic&location=document" ) ). + makeStringAndClear(); +} + +/*static*/ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData, BinaryInputStream& rInStrm ) +{ + // read the record header + sal_Int32 nRecSize; + rInStrm >> rnRecId >> nRecSize; + // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long + if( rnRecId == VBA_ID_PROJECTVERSION ) + { + OSL_ENSURE( nRecSize == 4, "VbaHelper::readDirRecord - unexpected record size for PROJECTVERSION" ); + nRecSize = 6; + } + // read the record contents into the passed sequence + return !rInStrm.isEof() && (rInStrm.readData( rRecData, nRecSize ) == nRecSize); +} + +/*static*/ bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, const OUString& rKeyValue ) +{ + sal_Int32 nEqSignPos = rKeyValue.indexOf( '=' ); + if( nEqSignPos > 0 ) + { + rKey = rKeyValue.copy( 0, nEqSignPos ).trim(); + rValue = rKeyValue.copy( nEqSignPos + 1 ).trim(); + return (rKey.getLength() > 0) && (rValue.getLength() > 0); + } + return false; +} + +/*static*/ bool VbaHelper::eatWhitespace( OUString& rCodeLine ) +{ + sal_Int32 nIndex = 0; + while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) + ++nIndex; + if( nIndex > 0 ) + { + rCodeLine = rCodeLine.copy( nIndex ); + return true; + } + return false; +} + +/*static*/ bool VbaHelper::eatKeyword( OUString& rCodeLine, const OUString& rKeyword ) +{ + if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) + { + rCodeLine = rCodeLine.copy( rKeyword.getLength() ); + // success, if code line ends after keyword, or if whitespace follows + return (rCodeLine.getLength() == 0) || eatWhitespace( rCodeLine ); + } + return false; +} + +/*static*/ OUString VbaHelper::getSourceCode( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName ) +{ + OUString aSourceCode; + if( rxBasicLib.is() ) try + { + rxBasicLib->getByName( rModuleName ) >>= aSourceCode; + } + catch( Exception& ) + { + } + return aSourceCode; +} + +namespace { + +bool lclGetLine( OUString& rCodeLine, sal_Int32& rnIndex, const OUString& rSourceCode ) +{ + if( rnIndex < rSourceCode.getLength() ) + { + sal_Int32 nPosLF = rSourceCode.indexOf( '\n', rnIndex ); + if( nPosLF >= rnIndex ) + { + rCodeLine = rSourceCode.copy( rnIndex, nPosLF - rnIndex ).trim(); + rnIndex = nPosLF + 1; + return true; + } + } + return false; +} + +} // namespace + +/*static*/ bool VbaHelper::hasMacro( const OUString& rSourceCode, const OUString& rMacroName ) +{ + // scan all text lines for '[Public|Private] [Static] Sub (...)' + const OUString aPublic = CREATE_OUSTRING( "Public" ); + const OUString aPrivate = CREATE_OUSTRING( "Private" ); + const OUString aStatic = CREATE_OUSTRING( "Static" ); + const OUString aSub = CREATE_OUSTRING( "Sub" ); + + OUString aCodeLine; + sal_Int32 nIndex = 0; + while( lclGetLine( aCodeLine, nIndex, rSourceCode ) ) + { + // eat optional 'Private' or 'Public', but do not accept both keywords in a row (therefore the ||) + eatKeyword( aCodeLine, aPublic ) || eatKeyword( aCodeLine, aPrivate ); + // eat optional 'Static' + eatKeyword( aCodeLine, aStatic ); + // eat 'Sub' keyword, check if macro name follows + if( eatKeyword( aCodeLine, aSub ) && aCodeLine.matchIgnoreAsciiCase( rMacroName ) ) + { + // eat macro name and following whitespace + aCodeLine = aCodeLine.copy( rMacroName.getLength() ); + eatWhitespace( aCodeLine ); + // opening bracket must follow the macro name + if( (aCodeLine.getLength() >= 2) && (aCodeLine[ 0 ] == '(') ) + return true; + } + } + return false; +} + +/*static*/ bool VbaHelper::hasMacro( const Reference< XNameContainer >& rxBasicLib, + const OUString& rModuleName, const OUString& rMacroName ) +{ + return hasMacro( getSourceCode( rxBasicLib, rModuleName ), rMacroName ); +} + +/*static*/ bool VbaHelper::insertMacro( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName, + const OUString& rMacroName, const OUString& rMacroArgs, const OUString& rMacroType, const OUString& rMacroCode ) +{ + if( rxBasicLib.is() ) try + { + // receive module source code and check that the specified macro does not exist + OUString aSourceCode = getSourceCode( rxBasicLib, rModuleName ); + if( !hasMacro( aSourceCode, rMacroName ) ) + { + bool bFunction = rMacroType.getLength() > 0; + const sal_Char* pcSubFunc = bFunction ? "Function" : "Sub"; + OUStringBuffer aBuffer( aSourceCode ); + // generate the source code for the new macro + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\nPrivate " ) ). + appendAscii( pcSubFunc ).append( sal_Unicode( ' ' ) ). + append( rMacroName ).append( sal_Unicode( '(' ) ); + if( rMacroArgs.getLength() > 0 ) + aBuffer.append( sal_Unicode( ' ' ) ).append( rMacroArgs ).append( sal_Unicode( ' ' ) ); + aBuffer.append( sal_Unicode( ')' ) ); + if( bFunction ) + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " As " ) ).append( rMacroType ); + aBuffer.append( sal_Unicode( '\n' ) ); + // replace all $MACRO placeholders with macro name + if( rMacroCode.getLength() > 0 ) + { + OUString aMacroCode = ::comphelper::string::searchAndReplaceAsciiL( rMacroCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); + aBuffer.append( aMacroCode ).append( sal_Unicode( '\n' ) ); + } + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End " ) ).appendAscii( pcSubFunc ).append( sal_Unicode( '\n' ) ); + rxBasicLib->replaceByName( rModuleName, Any( aBuffer.makeStringAndClear() ) ); + return true; + } + } + catch( Exception& ) + { + } + return false; +} + +/*static*/ bool VbaHelper::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) +{ + if( rxEventsSupp.is() ) try + { + Reference< XNameReplace > xEvents( rxEventsSupp->getEvents(), UNO_SET_THROW ); + Sequence< PropertyValue > aEvent( 2 ); + aEvent[ 0 ].Name = CREATE_OUSTRING( "EventType" ); + aEvent[ 0 ].Value <<= CREATE_OUSTRING( "Script" ); + aEvent[ 1 ].Name = CREATE_OUSTRING( "Script" ); + aEvent[ 1 ].Value <<= getBasicScriptUrl( rLibraryName, rModuleName, rMacroName ); + xEvents->replaceByName( rEventName, Any( aEvent ) ); + return true; + } + catch( Exception& ) + { + } + return false; +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx new file mode 100755 index 000000000000..b5319672d538 --- /dev/null +++ b/oox/source/ole/vbamodule.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbamodule.hxx" +#include +#include +#include +#include +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/storagebase.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/vbahelper.hxx" +#include "oox/ole/vbainputstream.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::script::ModuleInfo; +using ::com::sun::star::script::XVBAModuleInfo; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; + +namespace ApiModuleType = ::com::sun::star::script::ModuleType; + +namespace oox { +namespace ole { + +// ============================================================================ + +VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rName, rtl_TextEncoding eTextEnc, bool bExecutable ) : + mxDocModel( rxDocModel ), + maName( rName ), + meTextEnc( eTextEnc ), + mnType( ApiModuleType::Unknown ), + mnOffset( SAL_MAX_UINT32 ), + mbReadOnly( false ), + mbPrivate( false ), + mbExecutable( bExecutable ) +{ +} + +void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) +{ + sal_uInt16 nRecId = 0; + StreamDataSequence aRecData; + while( VbaHelper::readDirRecord( nRecId, aRecData, rDirStrm ) && (nRecId != VBA_ID_MODULEEND) ) + { + SequenceInputStream aRecStrm( aRecData ); + sal_Int32 nRecSize = aRecData.getLength(); + switch( nRecId ) + { +#define OOX_ENSURE_RECORDSIZE( cond ) OSL_ENSURE( cond, "VbaModule::importDirRecords - invalid record size" ) + case VBA_ID_MODULENAME: + OSL_ENSURE( false, "VbaModule::importDirRecords - unexpected MODULENAME record" ); + maName = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULENAMEUNICODE: + break; + case VBA_ID_MODULESTREAMNAME: + maStreamName = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULESTREAMNAMEUNICODE: + break; + case VBA_ID_MODULEDOCSTRING: + maDocString = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULEDOCSTRINGUNICODE: + break; + case VBA_ID_MODULEOFFSET: + OOX_ENSURE_RECORDSIZE( nRecSize == 4 ); + aRecStrm >> mnOffset; + break; + case VBA_ID_MODULEHELPCONTEXT: + OOX_ENSURE_RECORDSIZE( nRecSize == 4 ); + break; + case VBA_ID_MODULECOOKIE: + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + break; + case VBA_ID_MODULETYPEPROCEDURAL: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::Normal; + break; + case VBA_ID_MODULETYPEDOCUMENT: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::Document; + break; + case VBA_ID_MODULEREADONLY: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + mbReadOnly = true; + break; + case VBA_ID_MODULEPRIVATE: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + mbPrivate = true; + break; + default: + OSL_ENSURE( false, "VbaModule::importDirRecords - unknown module record" ); +#undef OOX_ENSURE_RECORDSIZE + } + } + OSL_ENSURE( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" ); + OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream name" ); + OSL_ENSURE( mnType != ApiModuleType::Unknown, "VbaModule::importDirRecords - missing module type" ); + OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" ); +} + +void VbaModule::importSourceCode( StorageBase& rVbaStrg, + const Reference< XNameContainer >& rxBasicLib, const Reference< XNameAccess >& rxDocObjectNA ) const +{ + if( (maName.getLength() == 0) || (maStreamName.getLength() == 0) || (mnOffset == SAL_MAX_UINT32) ) + return; + + BinaryXInputStream aInStrm( rVbaStrg.openInputStream( maStreamName ), true ); + OSL_ENSURE( !aInStrm.isEof(), "VbaModule::importSourceCode - cannot open module stream" ); + // skip the 'performance cache' stored before the actual source code + aInStrm.seek( mnOffset ); + // if stream is still valid, load the source code + if( aInStrm.isEof() ) + return; + + // prepare the Basic module + ModuleInfo aModuleInfo; + aModuleInfo.ModuleType = mnType; + OUStringBuffer aSourceCode; + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); + switch( mnType ) + { + case ApiModuleType::Normal: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); + break; + case ApiModuleType::Class: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); + break; + case ApiModuleType::Form: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); + // hack from old filter, document Basic should know the XModel, but it doesn't + aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); + break; + case ApiModuleType::Document: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); + // get the VBA object associated to the document module + if( rxDocObjectNA.is() ) try + { + aModuleInfo.ModuleObject.set( rxDocObjectNA->getByName( maName ), UNO_QUERY ); + } + catch( Exception& ) + { + } + break; + default: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAUnknown" ) ); + } + aSourceCode.append( sal_Unicode( '\n' ) ); + if( mbExecutable ) + { + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); + if( mnType == ApiModuleType::Class ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); + } + else + { + // add a subroutine named after the module itself + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Sub " ) ). + append( maName.replace( ' ', '_' ) ).append( sal_Unicode( '\n' ) ); + } + + // decompression starts at current stream position of aInStrm + VbaInputStream aVbaStrm( aInStrm ); + // load the source code line-by-line, with some more processing + TextInputStream aVbaTextStrm( aVbaStrm, meTextEnc ); + while( !aVbaTextStrm.isEof() ) + { + OUString aCodeLine = aVbaTextStrm.readLine(); + // skip all 'Attribute' statements + if( !aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) ) + { + if( !mbExecutable ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) ); + aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) ); + } + } + + // close the subroutine named after the module + if( !mbExecutable ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) ); + + // insert the module into the passed Basic library + try + { + rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); + } + + // insert extended module info + try + { + Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); + xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx new file mode 100755 index 000000000000..92a556d8b885 --- /dev/null +++ b/oox/source/ole/vbaproject.cxx @@ -0,0 +1,519 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbaproject.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "tokens.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/containerhelper.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/olestorage.hxx" +#include "oox/ole/vbacontrol.hxx" +#include "oox/ole/vbahelper.hxx" +#include "oox/ole/vbainputstream.hxx" +#include "oox/ole/vbamodule.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::document::XStorageBasedDocument; +using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::script::XLibraryContainer; +using ::com::sun::star::script::XVBACompat; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::XInterface; +using ::comphelper::ConfigurationHelper; + +namespace ApiModuleType = ::com::sun::star::script::ModuleType; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +bool lclReadConfigItem( const Reference< XInterface >& rxConfigAccess, const OUString& rItemName ) +{ + // some applications do not support all configuration items, assume 'false' in this case + try + { + Any aItem = ConfigurationHelper::readRelativeKey( rxConfigAccess, CREATE_OUSTRING( "Filter/Import/VBA" ), rItemName ); + return aItem.has< bool >() && aItem.get< bool >(); + } + catch( Exception& ) + { + } + return false; +} + +} // namespace + +// ---------------------------------------------------------------------------- + +VbaFilterConfig::VbaFilterConfig( const Reference< XMultiServiceFactory >& rxGlobalFactory, const OUString& rConfigCompName ) +{ + OSL_ENSURE( rxGlobalFactory.is(), "VbaFilterConfig::VbaFilterConfig - missing service factory" ); + try + { + OSL_ENSURE( rConfigCompName.getLength() > 0, "VbaFilterConfig::VbaFilterConfig - invalid configuration component name" ); + OUString aConfigPackage = CREATE_OUSTRING( "org.openoffice.Office." ) + rConfigCompName; + mxConfigAccess = ConfigurationHelper::openConfig( rxGlobalFactory, aConfigPackage, ConfigurationHelper::E_READONLY ); + } + catch( Exception& ) + { + } + OSL_ENSURE( mxConfigAccess.is(), "VbaFilterConfig::VbaFilterConfig - cannot open configuration" ); +} + +VbaFilterConfig::~VbaFilterConfig() +{ +} + +bool VbaFilterConfig::isImportVba() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Load" ) ); +} + +bool VbaFilterConfig::isImportVbaExecutable() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Executable" ) ); +} + +bool VbaFilterConfig::isExportVba() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Save" ) ); +} + +// ============================================================================ + +VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, + const Reference< XModel >& rxDocModel, const OUString& rConfigCompName ) : + VbaFilterConfig( rxGlobalFactory, rConfigCompName ), + mxGlobalFactory( rxGlobalFactory ), + mxDocModel( rxDocModel ), + maLibName( CREATE_OUSTRING( "Standard" ) ) +{ + OSL_ENSURE( mxDocModel.is(), "VbaProject::VbaProject - missing document model" ); + mxBasicLib = openLibrary( PROP_BasicLibraries, false ); + mxDialogLib = openLibrary( PROP_DialogLibraries, false ); +} + +VbaProject::~VbaProject() +{ +} + +void VbaProject::importVbaProject( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) +{ + if( rVbaPrjStrg.isStorage() ) + { + // load the code modules and forms + if( isImportVba() ) + importVba( rVbaPrjStrg, rGraphicHelper, bDefaultColorBgr ); + // copy entire storage into model + if( isExportVba() ) + copyStorage( rVbaPrjStrg ); + } +} + +bool VbaProject::hasModules() const +{ + return mxBasicLib.is() && mxBasicLib->hasElements(); +} + +bool VbaProject::hasModule( const OUString& rModuleName ) const +{ + return mxBasicLib.is() && mxBasicLib->hasByName( rModuleName ); +} + +bool VbaProject::hasDialogs() const +{ + return mxDialogLib.is() && mxDialogLib->hasElements(); +} + +bool VbaProject::hasDialog( const OUString& rDialogName ) const +{ + return mxDialogLib.is() && mxDialogLib->hasByName( rDialogName ); +} + +// Insert VBA code modules and VBA macros into modules ------------------------ + +bool VbaProject::insertMacro( const OUString& rModuleName, + const OUString& rMacroName, const OUString& rMacroArgs, + const OUString& rMacroType, const OUString& rMacroCode ) +{ + return + // do nothing if macros are imported as comments + isImportVbaExecutable() && + // try to insert the macro (will check that the macro does not exist yet) + VbaHelper::insertMacro( mxBasicLib, rModuleName, rMacroName, rMacroArgs, rMacroType, rMacroCode ); +} + +// Attach VBA macros to generic or document events ---------------------------- + +bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName ) +{ + return + // do not attach if macros are imported as comments + isImportVbaExecutable() && + // check that the specified macro exists in the module + VbaHelper::hasMacro( mxBasicLib, rModuleName, rMacroName ) && + // attach the macro to the events supplier + VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, rMacroName ); +} + +bool VbaProject::attachMacroToDocumentEvent( const OUString& rEventName, + const OUString& rModuleName, const OUString& rMacroName ) +{ + Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); + return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName ); +} + +bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, + const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) +{ + // receive module source code, and check that the specified macro exists in the module + OUString aSourceCode = VbaHelper::getSourceCode( mxBasicLib, rModuleName ); + if( isImportVbaExecutable() && VbaHelper::hasMacro( aSourceCode, rMacroName ) ) + { + // create the name of the proxy macro, and the macro source code + OUString aProxyName = OUStringBuffer( rMacroName ).append( sal_Unicode( '_' ) ). + append( rEventName ).appendAscii( "_Proxy" ).makeStringAndClear(); + // replace $MACRO and $PROXY placeholders in proxy source code + OUString aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( rProxyCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); + aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( aProxyCode, RTL_CONSTASCII_STRINGPARAM( "$PROXY" ), aProxyName ); + // insert the new macro into the code module and attach it to the event + return + VbaHelper::insertMacro( mxBasicLib, rModuleName, aProxyName, rProxyArgs, rProxyType, aProxyCode ) && + VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, aProxyName ); + } + return false; +} + +bool VbaProject::attachMacroToDocumentEvent( + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, + const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) +{ + Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); + return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName, rProxyArgs, rProxyType, rProxyCode ); +} + +// private -------------------------------------------------------------------- + +Reference< XLibraryContainer > VbaProject::getLibraryContainer( sal_Int32 nPropId ) +{ + PropertySet aDocProp( mxDocModel ); + Reference< XLibraryContainer > xLibContainer( aDocProp.getAnyProperty( nPropId ), UNO_QUERY ); + return xLibContainer; +} + +Reference< XNameContainer > VbaProject::openLibrary( sal_Int32 nPropId, bool bCreateMissing ) +{ + Reference< XNameContainer > xLibrary; + try + { + Reference< XLibraryContainer > xLibContainer( getLibraryContainer( nPropId ), UNO_SET_THROW ); + if( bCreateMissing && !xLibContainer->hasByName( maLibName ) ) + xLibContainer->createLibrary( maLibName ); + xLibrary.set( xLibContainer->getByName( maLibName ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } + OSL_ENSURE( !bCreateMissing || xLibrary.is(), "VbaProject::openLibrary - cannot create library" ); + return xLibrary; +} + +Reference< XNameContainer > VbaProject::createBasicLibrary() +{ + if( !mxBasicLib.is() ) + mxBasicLib = openLibrary( PROP_BasicLibraries, true ); + return mxBasicLib; +} + +Reference< XNameContainer > VbaProject::createDialogLibrary() +{ + if( !mxDialogLib.is() ) + mxDialogLib = openLibrary( PROP_DialogLibraries, true ); + return mxDialogLib; +} + +void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) +{ + StorageRef xVbaStrg = rVbaPrjStrg.openSubStorage( CREATE_OUSTRING( "VBA" ), false ); + OSL_ENSURE( xVbaStrg.get(), "VbaProject::importVba - cannot open 'VBA' substorage" ); + if( !xVbaStrg ) + return; + + /* Read the 'VBA/dir' stream which contains general settings of the VBA + project such as the text encoding used throughout several streams, and + a list of all code modules. + */ + BinaryXInputStream aInStrm( xVbaStrg->openInputStream( CREATE_OUSTRING( "dir" ) ), true ); + // VbaInputStream implements decompression + VbaInputStream aDirStrm( aInStrm ); + OSL_ENSURE( !aDirStrm.isEof(), "VbaProject::importVba - cannot open 'dir' stream" ); + if( aDirStrm.isEof() ) + return; + + // read all records of the directory + rtl_TextEncoding eTextEnc = RTL_TEXTENCODING_MS_1252; + sal_uInt16 nModuleCount = 0; + bool bExecutable = isImportVbaExecutable(); + + typedef RefMap< OUString, VbaModule > VbaModuleMap; + VbaModuleMap aModules, aModulesByStrm; + + sal_uInt16 nRecId = 0; + StreamDataSequence aRecData; + while( VbaHelper::readDirRecord( nRecId, aRecData, aDirStrm ) && (nRecId != VBA_ID_PROJECTEND) ) + { + // create record stream object from imported record data + SequenceInputStream aRecStrm( aRecData ); + sal_Int32 nRecSize = aRecData.getLength(); + switch( nRecId ) + { +#define OOX_ENSURE_RECORDSIZE( cond ) OSL_ENSURE( cond, "VbaProject::importVba - invalid record size" ) + case VBA_ID_PROJECTCODEPAGE: + { + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + OSL_ENSURE( aModules.empty(), "VbaProject::importVba - unexpected PROJECTCODEPAGE record" ); + rtl_TextEncoding eNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( aRecStrm.readuInt16() ); + OSL_ENSURE( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW, "VbaProject::importVba - unknown text encoding" ); + if( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW ) + eTextEnc = eNewTextEnc; + } + break; + case VBA_ID_PROJECTMODULES: + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + OSL_ENSURE( aModules.empty(), "VbaProject::importVba - unexpected PROJECTMODULES record" ); + aRecStrm >> nModuleCount; + break; + case VBA_ID_MODULENAME: + { + OUString aName = aRecStrm.readCharArrayUC( nRecSize, eTextEnc ); + OSL_ENSURE( aName.getLength() > 0, "VbaProject::importVba - invalid module name" ); + OSL_ENSURE( !aModules.has( aName ), "VbaProject::importVba - multiple modules with the same name" ); + VbaModuleMap::mapped_type& rxModule = aModules[ aName ]; + rxModule.reset( new VbaModule( mxDocModel, aName, eTextEnc, bExecutable ) ); + // read all remaining records until the MODULEEND record + rxModule->importDirRecords( aDirStrm ); + OSL_ENSURE( !aModulesByStrm.has( rxModule->getStreamName() ), "VbaProject::importVba - multiple modules with the same stream name" ); + aModulesByStrm[ rxModule->getStreamName() ] = rxModule; + } + break; +#undef OOX_ENSURE_RECORDSIZE + } + } + OSL_ENSURE( nModuleCount == aModules.size(), "VbaProject::importVba - invalid module count" ); + + /* The directory does not contain the real type of the modules, it + distinguishes only between 'procedural' and 'document' (the latter + includes class and form modules). Now, the exact type of all modules + will be read from the 'PROJECT' stream. It consists of text lines in + 'key=value' format which list the code modules by type. + + - The line 'document=/&HXXXXXXXX' declares document + modules. These are attached to the Word document (usually called + 'ThisDocument'), the Excel workbook (usually called + 'ThisWorkbook'), or single Excel worksheets or chartsheets (usually + called 'SheetX' or 'ChartX', X being a decimal number). Of course, + users may rename all these modules. The slash character separates + an automation server version number (hexadecimal 'XXXXXXXX') from + the module name. + - The line 'Module=' declares common procedural code + modules. + - The line 'Class=' declares a class module. + - The line 'BaseClass=' declares a code module attached + to a user form with the same name. + */ + BinaryXInputStream aPrjStrm( rVbaPrjStrg.openInputStream( CREATE_OUSTRING( "PROJECT" ) ), true ); + OSL_ENSURE( !aPrjStrm.isEof(), "VbaProject::importVba - cannot open 'PROJECT' stream" ); + // do not exit if this stream does not exist, but proceed to load the modules below + if( !aPrjStrm.isEof() ) + { + TextInputStream aPrjTextStrm( aPrjStrm, eTextEnc ); + OUString aKey, aValue; + bool bExitLoop = false; + while( !bExitLoop && !aPrjTextStrm.isEof() ) + { + // read a text line from the stream + OUString aLine = aPrjTextStrm.readLine().trim(); + sal_Int32 nLineLen = aLine.getLength(); + // exit if a subsection starts (section name is given in brackets) + bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); + if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) + { + sal_Int32 nType = ApiModuleType::Unknown; + if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) + { + nType = ApiModuleType::Document; + // strip automation server version from module names + sal_Int32 nSlashPos = aValue.indexOf( '/' ); + if( nSlashPos >= 0 ) + aValue = aValue.copy( 0, nSlashPos ); + } + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) + nType = ApiModuleType::Normal; + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) + nType = ApiModuleType::Class; + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) + nType = ApiModuleType::Form; + + if( (nType != ApiModuleType::Unknown) && (aValue.getLength() > 0) ) + { + OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" ); + if( VbaModule* pModule = aModules.get( aValue ).get() ) + pModule->setType( nType ); + } + } + } + } + + /* Now it is time to load the source code. All modules will be inserted + into the Basic library of the document specified by the 'maLibName' + member. Do not create the Basic library, if there are no modules + specified. */ + if( !aModules.empty() ) try + { + // get the basic library + Reference< XNameContainer > xBasicLib( createBasicLibrary(), UNO_SET_THROW ); + + // set library container to VBA compatibility mode + try + { + Reference< XVBACompat >( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW )->setVBACompatModeOn( sal_True ); + } + catch( Exception& ) + { + } + + // try to get access to document objects related to code modules + Reference< XNameAccess > xDocObjectNA; + try + { + Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); + xDocObjectNA.set( xModelFactory->createInstance( CREATE_OUSTRING( "ooo.vba.VBAObjectModuleObjectProvider" ) ), UNO_QUERY ); + } + catch( Exception& ) + { + // not all documents support this + } + + // call Basic source code import for each module, boost::[c]ref enforces pass-by-ref + if( xBasicLib.is() ) + aModules.forEachMem( &VbaModule::importSourceCode, + ::boost::ref( *xVbaStrg ), ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ) ); + } + catch( Exception& ) + { + } + + /* Load the forms. The file format specification requires that a module + must exist for every form. We are a bit more tolerant and scan the + project storage for all form substorages. This may 'repair' broken VBA + storages that misses to mention a module for an existing form. */ + ::std::vector< OUString > aElements; + rVbaPrjStrg.getElementNames( aElements ); + for( ::std::vector< OUString >::iterator aIt = aElements.begin(), aEnd = aElements.end(); aIt != aEnd; ++aIt ) + { + // try to open the element as storage + if( !aIt->equals( CREATE_OUSTRING( "VBA" ) ) ) + { + StorageRef xSubStrg = rVbaPrjStrg.openSubStorage( *aIt, false ); + if( xSubStrg.get() ) try + { + // resolve module name from storage name (which equals the module stream name) + VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); + OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::Form), + "VbaProject::importVba - form substorage without form module" ); + OUString aModuleName; + if( pModule ) + aModuleName = pModule->getName(); + + // create and import the form + Reference< XNameContainer > xDialogLib( createDialogLibrary(), UNO_SET_THROW ); + VbaUserForm aForm( mxGlobalFactory, rGraphicHelper, bDefaultColorBgr ); + aForm.importForm( xDialogLib, *xSubStrg, aModuleName, eTextEnc ); + } + catch( Exception& ) + { + } + } + } +} + +void VbaProject::copyStorage( StorageBase& rVbaPrjStrg ) +{ + try + { + Reference< XStorageBasedDocument > xStorageBasedDoc( mxDocModel, UNO_QUERY_THROW ); + Reference< XStorage > xDocStorage( xStorageBasedDoc->getDocumentStorage(), UNO_QUERY_THROW ); + { + using namespace ::com::sun::star::embed::ElementModes; + Reference< XStream > xDocStream( xDocStorage->openStreamElement( CREATE_OUSTRING( "_MS_VBA_Macros" ), SEEKABLE | WRITE | TRUNCATE ), UNO_SET_THROW ); + OleStorage aDestStorage( mxGlobalFactory, xDocStream, false ); + rVbaPrjStrg.copyStorageToStorage( aDestStorage ); + aDestStorage.commit(); + } + Reference< XTransactedObject >( xDocStorage, UNO_QUERY_THROW )->commit(); + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx index ea639c8c6f5c..e2eca9a36dca 100644 --- a/oox/source/ppt/animvariantcontext.cxx +++ b/oox/source/ppt/animvariantcontext.cxx @@ -65,7 +65,7 @@ namespace oox { namespace ppt { { if( ( aElement == mnElement ) && maColor.isUsed() ) { - maValue = makeAny( maColor.getColor( getFilter() ) ); + maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) ); } } diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 79341081f1d0..578d469395db 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -29,6 +29,7 @@ #include "oox/drawingml/chart/chartconverter.hxx" #include "oox/dump/pptxdumper.hxx" #include "oox/drawingml/table/tablestylelistfragmenthandler.hxx" +#include "oox/helper/graphichelper.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -150,6 +151,35 @@ const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles( return *mxChartConv; } +namespace { + +class PptGraphicHelper : public GraphicHelper +{ +public: + explicit PptGraphicHelper( const PowerPointImport& rFilter ); + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; +private: + const PowerPointImport& mrFilter; +}; + +PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : + GraphicHelper( rFilter.getGlobalFactory() ), + mrFilter( rFilter ) +{ +} + +sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + return mrFilter.getSchemeColor( nToken ); +} + +} // namespace + +GraphicHelper* PowerPointImport::implCreateGraphicHelper() const +{ + return new PptGraphicHelper( *this ); +} + OUString PowerPointImport::implGetImplementationName() const { return PowerPointImport_getImplementationName(); diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index c91a1bd1fd79..7c2c4ccfd06d 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -177,7 +177,7 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase ) uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() ); PropertySet aPropSet( xPropertySet ); - mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper() ); + mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) ); } catch( Exception ) diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 3edca28aecac..7e40e3be4db4 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -504,19 +504,13 @@ namespace oox { namespace ppt { NodePropertyMap & pProps(mpNode->getNodeProperties()); pProps[ NP_DIRECTION ] = makeAny( mnDir == XML_cw ); pProps[ NP_COLORINTERPOLATION ] = makeAny( mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB ); + const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper(); if( maToClr.isUsed() ) - { - mpNode->setTo( Any( maToClr.getColor( getFilter() ) ) ); - } + mpNode->setTo( Any( maToClr.getColor( rGraphicHelper ) ) ); if( maFromClr.isUsed() ) - { - mpNode->setFrom( Any( maFromClr.getColor( getFilter() ) ) ); - } + mpNode->setFrom( Any( maFromClr.getColor( rGraphicHelper ) ) ); if( mbHasByColor ) - { mpNode->setBy( Any ( m_byColor.get() ) ); - } - } } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0ecd40ee6595..655bd40d6e1f 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -15,6 +15,7 @@ Autocomplete BackGraphicLocation BackGraphicURL BackgroundColor +BasicLibraries BlackDay BlockIncrement Border @@ -72,6 +73,7 @@ CharUnderlineHasColor CharWeight CharWeightAsian CharWeightComplex +CodeName Color ColumnGrand ColumnLabelRanges @@ -97,16 +99,19 @@ D3DScenePerspective D3DSceneShadeMode DDELinks DatabaseRanges +DefaultContext DefaultScrollValue DefaultSpinValue DefaultState DefaultText DiagonalBLTR DiagonalTLBR +DialogLibraries DisplayLabels DrillDownOnDoubleClick Dropdown EchoChar +EnableVisible Enabled EndPosition ErrorAlertStyle @@ -173,6 +178,7 @@ HeaderIsDynamicHeight HeaderIsOn HeaderIsShared Height +HelpText HideInactiveSelection HoriJustify HorizontalSplitMode @@ -279,6 +285,8 @@ PositionBottom PositionLeft PositionRight PositionTop +PositionX +PositionY PositiveError Prefix PrintAnnotations @@ -287,6 +295,8 @@ PrintDownFirst PrintGrid PrintHeaders Printable +ProgressValueMax +ProgressValueMin Protected Reference ReferenceDevice @@ -312,6 +322,7 @@ ScaleMode ScaleToPages ScaleToPagesX ScaleToPagesY +ScrollValue ScrollValueMax ScrollValueMin SelectedPage @@ -343,6 +354,7 @@ Sound SoundOn Speed SpinIncrement +SpinValue SpinValueMax SpinValueMin StackCharacters @@ -350,16 +362,21 @@ StackingDirection StartPosition StartWith StartingAngle +State Subtotals Suffix SwapXAndYAxis Symbol SymbolColor +TabIndex TableBorder TableLayout TableSelected Tables +Tabstop +Tag TargetFrame +Text TextAutoGrowHeight TextBreak TextColor @@ -371,6 +388,7 @@ TextRotation TextUpperDistance TextWordWrap TextWritingMode +Title Toggle TokenIndex TopBorder diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index 9c1bb761532a..9a5f4451ec04 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -29,7 +29,7 @@ #include #include "tokens.hxx" #include "oox/core/xmlfilterbase.hxx" -#include "oox/ole/axcontrolhelper.hxx" +#include "oox/ole/axcontrol.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/vml/vmlshapecontainer.hxx" @@ -97,15 +97,12 @@ Drawing::~Drawing() { } -::oox::ole::AxControlHelper& Drawing::getControlHelper() const +::oox::ole::EmbeddedForm& Drawing::getControlForm() const { - // create the helper object on demand - if( !mxCtrlHelper.get() ) - { - mxCtrlHelper.reset( createControlHelper() ); - OSL_ENSURE( mxCtrlHelper.get(), "Drawing::getControlHelper - cannot create form controls helper" ); - } - return *mxCtrlHelper; + if( !mxCtrlForm.get() ) + mxCtrlForm.reset( new ::oox::ole::EmbeddedForm( + mrFilter.getModelFactory(), mxDrawPage, mrFilter.getGraphicHelper() ) ); + return *mxCtrlForm; } void Drawing::registerOleObject( const OleObjectInfo& rOleObject ) @@ -158,11 +155,6 @@ void Drawing::convertControlClientData( const Reference< XControlModel >& /*rxCt { } -::oox::ole::AxControlHelper* Drawing::createControlHelper() const -{ - return new ::oox::ole::AxEmbeddedControlHelper( mrFilter, mxDrawPage ); -} - // ============================================================================ } // namespace vml diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index be3f3dd19e8c..6baea708c8a2 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -29,8 +29,8 @@ #include #include "tokens.hxx" #include "oox/token/tokenmap.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/color.hxx" #include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/fillproperties.hxx" @@ -39,7 +39,6 @@ using ::rtl::OStringBuffer; using ::rtl::OUString; using ::com::sun::star::geometry::IntegerRectangle2D; -using ::oox::core::FilterBase; using ::oox::drawingml::Color; using ::oox::drawingml::FillProperties; using ::oox::drawingml::LineArrowProperties; @@ -106,7 +105,7 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r return fDefValue; } -/*static*/ sal_Int32 ConversionHelper::decodeMeasureToEmu( const FilterBase& rFilter, +/*static*/ sal_Int32 ConversionHelper::decodeMeasureToEmu( const GraphicHelper& rGraphicHelper, const OUString& rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel ) { // default for missing values is 0 @@ -150,7 +149,9 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r else if( (cChar1 == 'p') && (cChar2 == 'c') ) // 1 pica = 1/6 inch = 152,400 EMU fValue *= 152400.0; else if( (cChar1 == 'p') && (cChar2 == 'x') ) // 1 pixel, dependent on output device, factor 360 to convert 1/100mm to EMU - fValue = bPixelX ? rFilter.convertScreenPixelX( 360.0 * fValue ) : rFilter.convertScreenPixelY( 360.0 * fValue ); + fValue = bPixelX ? + rGraphicHelper.convertScreenPixelXToHmm( 360.0 * fValue ) : + rGraphicHelper.convertScreenPixelYToHmm( 360.0 * fValue ); } else if( (aUnit.getLength() == 1) && (aUnit[ 0 ] == '%') ) { @@ -164,10 +165,10 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r return static_cast< sal_Int32 >( fValue + 0.5 ); } -/*static*/ sal_Int32 ConversionHelper::decodeMeasureToHmm( const FilterBase& rFilter, +/*static*/ sal_Int32 ConversionHelper::decodeMeasureToHmm( const GraphicHelper& rGraphicHelper, const OUString& rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel ) { - return (decodeMeasureToEmu( rFilter, rValue, nRefValue, bPixelX, bDefaultAsPixel ) + 180) / 360; + return (decodeMeasureToEmu( rGraphicHelper, rValue, nRefValue, bPixelX, bDefaultAsPixel ) + 180) / 360; } // ============================================================================ @@ -195,7 +196,7 @@ namespace { specifies the color to be used to resolve the color modifiers used in one-color gradients. */ -void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, +void lclGetColor( Color& orDmlColor, const GraphicHelper& rGraphicHelper, const OptValue< OUString >& roVmlColor, const OptValue< double >& roVmlOpacity, sal_Int32 nDefaultRgb, sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT ) { @@ -239,7 +240,7 @@ void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, sal_Int32 nColorToken = StaticTokenMap::get().getTokenFromUnicode( aColorName ); sal_Int32 nRgbValue = Color::getVmlPresetColor( nColorToken, API_RGB_TRANSPARENT ); if( nRgbValue == API_RGB_TRANSPARENT ) - nRgbValue = rFilter.getSystemColor( nColorToken, API_RGB_TRANSPARENT ); + nRgbValue = rGraphicHelper.getSystemColor( nColorToken, API_RGB_TRANSPARENT ); if( nRgbValue != API_RGB_TRANSPARENT ) { orDmlColor.setSrgbClr( nRgbValue ); @@ -284,9 +285,9 @@ void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, orDmlColor.setSrgbClr( nDefaultRgb ); } -sal_Int32 lclGetEmu( const FilterBase& rFilter, const OptValue< OUString >& roValue, sal_Int32 nDefValue ) +sal_Int32 lclGetEmu( const GraphicHelper& rGraphicHelper, const OptValue< OUString >& roValue, sal_Int32 nDefValue ) { - return roValue.has() ? ConversionHelper::decodeMeasureToEmu( rFilter, roValue.get(), 0, false, false ) : nDefValue; + return roValue.has() ? ConversionHelper::decodeMeasureToEmu( rGraphicHelper, roValue.get(), 0, false, false ) : nDefValue; } void lclGetDmlLineDash( OptValue< sal_Int32 >& oroPresetDash, LineProperties::DashStopVector& orCustomDash, const OptValue< OUString >& roDashStyle ) @@ -428,7 +429,8 @@ void StrokeModel::assignUsed( const StrokeModel& rSource ) moJoinStyle.assignIfUsed( rSource.moJoinStyle ); } -void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter ) const +void StrokeModel::pushToPropMap( PropertyMap& rPropMap, + ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const { /* Convert VML line formatting to DrawingML line formatting and let the DrawingML code do the hard work. */ @@ -439,8 +441,8 @@ void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilte aLineProps.maLineFill.moFillType = XML_solidFill; lclConvertArrow( aLineProps.maStartArrow, maStartArrow ); lclConvertArrow( aLineProps.maEndArrow, maEndArrow ); - lclGetColor( aLineProps.maLineFill.maFillColor, rFilter, moColor, moOpacity, API_RGB_BLACK ); - aLineProps.moLineWidth = lclGetEmu( rFilter, moWeight, 1 ); + lclGetColor( aLineProps.maLineFill.maFillColor, rGraphicHelper, moColor, moOpacity, API_RGB_BLACK ); + aLineProps.moLineWidth = lclGetEmu( rGraphicHelper, moWeight, 1 ); lclGetDmlLineDash( aLineProps.moPresetDash, aLineProps.maCustomDash, moDashStyle ); aLineProps.moLineCompound = lclGetDmlLineCompound( moLineStyle ); aLineProps.moLineCap = lclGetDmlLineCap( moEndCap ); @@ -451,7 +453,7 @@ void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilte aLineProps.maLineFill.moFillType = XML_noFill; } - aLineProps.pushToPropMap( rPropMap, rFilter, rFilter.getModelObjectHelper() ); + aLineProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); } // ============================================================================ @@ -471,7 +473,8 @@ void FillModel::assignUsed( const FillModel& rSource ) moRotate.assignIfUsed( rSource.moRotate ); } -void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter ) const +void FillModel::pushToPropMap( PropertyMap& rPropMap, + ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const { /* Convert VML fill formatting to DrawingML fill formatting and let the DrawingML code do the hard work. */ @@ -491,8 +494,8 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter // prepare colors Color aColor1, aColor2; - lclGetColor( aColor1, rFilter, moColor, moOpacity, API_RGB_WHITE ); - lclGetColor( aColor2, rFilter, moColor2, moOpacity2, API_RGB_WHITE, aColor1.getColor( rFilter ) ); + lclGetColor( aColor1, rGraphicHelper, moColor, moOpacity, API_RGB_WHITE ); + lclGetColor( aColor2, rGraphicHelper, moColor2, moOpacity2, API_RGB_WHITE, aColor1.getColor( rGraphicHelper ) ); // type XML_gradient is linear or axial gradient if( nFillType == XML_gradient ) @@ -563,7 +566,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter { aFillProps.moFillType = XML_solidFill; // fill color (default is white) - lclGetColor( aFillProps.maFillColor, rFilter, moColor, moOpacity, API_RGB_WHITE ); + lclGetColor( aFillProps.maFillColor, rGraphicHelper, moColor, moOpacity, API_RGB_WHITE ); } } } @@ -572,7 +575,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter aFillProps.moFillType = XML_noFill; } - aFillProps.pushToPropMap( rPropMap, rFilter, rFilter.getModelObjectHelper() ); + aFillProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); } // ============================================================================ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 014f1edf4c45..40b3e9952b43 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -195,12 +195,12 @@ Rectangle ShapeType::getRectangle( const ShapeParentAnchor* pParentAnchor ) cons Rectangle ShapeType::getAbsRectangle() const { - const XmlFilterBase& rFilter = mrDrawing.getFilter(); + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); return Rectangle( - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maLeft, 0, true, true ) + ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maMarginLeft, 0, true, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maMarginTop, 0, false, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maWidth, 0, true, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maHeight, 0, false, true ) ); + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maLeft, 0, true, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginTop, 0, false, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maWidth, 0, true, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, false, true ) ); } Rectangle ShapeType::getRelRectangle() const @@ -305,10 +305,12 @@ Rectangle ShapeBase::calcShapeRectangle( const ShapeParentAnchor* pParentAnchor void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) const { - PropertyMap aPropMap; + ModelObjectHelper& rModelObjectHelper = mrDrawing.getFilter().getModelObjectHelper(); + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); - maTypeModel.maStrokeModel.pushToPropMap( aPropMap, mrDrawing.getFilter() ); - maTypeModel.maFillModel.pushToPropMap( aPropMap, mrDrawing.getFilter() ); + PropertyMap aPropMap; + maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); + maTypeModel.maFillModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); PropertySet aPropSet( rxShape ); aPropSet.setProperties( aPropMap ); @@ -440,12 +442,12 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes if( pControlInfo && (pControlInfo->maFragmentPath.getLength() > 0) && (maTypeModel.maName.getLength() > 0) ) { OSL_ENSURE( maTypeModel.maName == pControlInfo->maName, "ComplexShape::implConvertAndInsert - control name mismatch" ); - ::oox::ole::AxControl aControl( maTypeModel.maName ); + ::oox::ole::EmbeddedControl aControl( maTypeModel.maName ); // load the control properties from fragment if( rFilter.importFragment( new ::oox::ole::AxControlFragment( rFilter, pControlInfo->maFragmentPath, aControl ) ) ) try { // create control model and insert it into the form of the draw page - Reference< XControlModel > xCtrlModel( aControl.convertAndInsert( mrDrawing.getControlHelper() ), UNO_SET_THROW ); + Reference< XControlModel > xCtrlModel( mrDrawing.getControlForm().convertAndInsert( aControl ), UNO_SET_THROW ); if( maShapeModel.mxClientData.get() ) mrDrawing.convertControlClientData( xCtrlModel, *maShapeModel.mxClientData ); diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx index 6b1711f3c0f9..8e36e4b0054e 100644 --- a/oox/source/vml/vmlshapecontainer.cxx +++ b/oox/source/vml/vmlshapecontainer.cxx @@ -33,7 +33,6 @@ using ::rtl::OUString; using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::Rectangle; using ::com::sun::star::drawing::XShapes; -using ::oox::core::XmlFilterBase; namespace oox { namespace vml { diff --git a/oox/source/xls/biffdetector.cxx b/oox/source/xls/biffdetector.cxx index 82c7cb822d83..fc3e1e710bcb 100644 --- a/oox/source/xls/biffdetector.cxx +++ b/oox/source/xls/biffdetector.cxx @@ -31,7 +31,7 @@ #include #include #include "oox/helper/binaryinputstream.hxx" -#include "oox/helper/olestorage.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::rtl::OStringBuffer; @@ -85,7 +85,7 @@ BiffType BiffDetector::detectStreamBiffVersion( BinaryInputStream& rInStream ) if( !rInStream.isEof() && rInStream.isSeekable() && (rInStream.getLength() > 4) ) { sal_Int64 nOldPos = rInStream.tell(); - rInStream.seek( 0 ); + rInStream.seekToStart(); sal_uInt16 nBofId, nBofSize; rInStream >> nBofId >> nBofSize; @@ -211,7 +211,7 @@ OUString SAL_CALL BiffDetector::detect( Sequence< PropertyValue >& rDescriptor ) if( xInStrm.is() ) { OUString aWorkbookName; - StorageRef xStorage( new OleStorage( mxFactory, xInStrm, true ) ); + StorageRef xStorage( new ::oox::ole::OleStorage( mxFactory, xInStrm, true ) ); switch( detectStorageBiffVersion( aWorkbookName, xStorage ) ) { case BIFF2: diff --git a/oox/source/xls/biffhelper.cxx b/oox/source/xls/biffhelper.cxx index f69cac731ee7..68699766804d 100644 --- a/oox/source/xls/biffhelper.cxx +++ b/oox/source/xls/biffhelper.cxx @@ -26,8 +26,8 @@ ************************************************************************/ #include "oox/xls/biffhelper.hxx" -#include #include +#include #include "oox/xls/biffinputstream.hxx" #include "oox/xls/biffoutputstream.hxx" #include "oox/xls/worksheethelper.hxx" @@ -56,69 +56,6 @@ const sal_uInt16 BIFF_IMGDATA_NATIVE = 14; // ---------------------------------------------------------------------------- -static const struct CodePageEntry -{ - sal_uInt16 mnCodePage; - rtl_TextEncoding meTextEnc; -} -spCodePages[] = -{ - { 437, RTL_TEXTENCODING_IBM_437 }, // OEM US -// { 720, RTL_TEXTENCODING_IBM_720 }, // OEM Arabic - { 737, RTL_TEXTENCODING_IBM_737 }, // OEM Greek - { 775, RTL_TEXTENCODING_IBM_775 }, // OEM Baltic - { 850, RTL_TEXTENCODING_IBM_850 }, // OEM Latin I - { 852, RTL_TEXTENCODING_IBM_852 }, // OEM Latin II (Central European) - { 855, RTL_TEXTENCODING_IBM_855 }, // OEM Cyrillic - { 857, RTL_TEXTENCODING_IBM_857 }, // OEM Turkish -// { 858, RTL_TEXTENCODING_IBM_858 }, // OEM Multilingual Latin I with Euro - { 860, RTL_TEXTENCODING_IBM_860 }, // OEM Portugese - { 861, RTL_TEXTENCODING_IBM_861 }, // OEM Icelandic - { 862, RTL_TEXTENCODING_IBM_862 }, // OEM Hebrew - { 863, RTL_TEXTENCODING_IBM_863 }, // OEM Canadian (French) - { 864, RTL_TEXTENCODING_IBM_864 }, // OEM Arabic - { 865, RTL_TEXTENCODING_IBM_865 }, // OEM Nordic - { 866, RTL_TEXTENCODING_IBM_866 }, // OEM Cyrillic (Russian) - { 869, RTL_TEXTENCODING_IBM_869 }, // OEM Greek (Modern) - { 874, RTL_TEXTENCODING_MS_874 }, // MS Windows Thai - { 932, RTL_TEXTENCODING_MS_932 }, // MS Windows Japanese Shift-JIS - { 936, RTL_TEXTENCODING_MS_936 }, // MS Windows Chinese Simplified GBK - { 949, RTL_TEXTENCODING_MS_949 }, // MS Windows Korean (Wansung) - { 950, RTL_TEXTENCODING_MS_950 }, // MS Windows Chinese Traditional BIG5 - { 1200, RTL_TEXTENCODING_DONTKNOW }, // Unicode (BIFF8) - return *_DONTKNOW to preserve old code page - { 1250, RTL_TEXTENCODING_MS_1250 }, // MS Windows Latin II (Central European) - { 1251, RTL_TEXTENCODING_MS_1251 }, // MS Windows Cyrillic - { 1252, RTL_TEXTENCODING_MS_1252 }, // MS Windows Latin I (BIFF4-BIFF8) - { 1253, RTL_TEXTENCODING_MS_1253 }, // MS Windows Greek - { 1254, RTL_TEXTENCODING_MS_1254 }, // MS Windows Turkish - { 1255, RTL_TEXTENCODING_MS_1255 }, // MS Windows Hebrew - { 1256, RTL_TEXTENCODING_MS_1256 }, // MS Windows Arabic - { 1257, RTL_TEXTENCODING_MS_1257 }, // MS Windows Baltic - { 1258, RTL_TEXTENCODING_MS_1258 }, // MS Windows Vietnamese - { 1361, RTL_TEXTENCODING_MS_1361 }, // MS Windows Korean (Johab) - { 10000, RTL_TEXTENCODING_APPLE_ROMAN }, // Apple Roman - { 32768, RTL_TEXTENCODING_APPLE_ROMAN }, // Apple Roman - { 32769, RTL_TEXTENCODING_MS_1252 } // MS Windows Latin I (BIFF2-BIFF3) -}; - -/** Predicate to search by given code page. */ -struct CodePageEntry_CPPred -{ - inline explicit CodePageEntry_CPPred( sal_uInt16 nCodePage ) : mnCodePage( nCodePage ) {} - inline bool operator()( const CodePageEntry& rEntry ) const { return rEntry.mnCodePage == mnCodePage; } - sal_uInt16 mnCodePage; -}; - -/** Predicate to search by given text encoding. */ -struct CodePageEntry_TEPred -{ - inline explicit CodePageEntry_TEPred( rtl_TextEncoding eTextEnc ) : meTextEnc( eTextEnc ) {} - inline bool operator()( const CodePageEntry& rEntry ) const { return rEntry.meTextEnc == meTextEnc; } - rtl_TextEncoding meTextEnc; -}; - -// ---------------------------------------------------------------------------- - bool lclCalcRkFromDouble( sal_Int32& ornRkValue, double fValue ) { // double @@ -193,7 +130,7 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, aOutStrm << sal_uInt16( 0x4D42 ) << nBmpSize << sal_Int32( 0 ) << nOffset; // copy the DIB header - aOutStrm.copyStream( rStrm, nDibHdrSize ); + rStrm.copyToStream( aOutStrm, nDibHdrSize ); nBytes -= nDibHdrSize; /* Excel 3.x and Excel 4.x seem to write broken or out-dated DIB data. @@ -215,8 +152,8 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, aOutStrm.seek( nOutStrmPos ); } - // copy remaining pixel data top output stream - aOutStrm.copyStream( rStrm, nBytes ); + // copy remaining pixel data to output stream + rStrm.copyToStream( aOutStrm, nBytes ); } rStrm.seek( nInStrmPos + nBytes ); } @@ -225,8 +162,6 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, // ============================================================================ -// conversion ----------------------------------------------------------------- - /*static*/ double BiffHelper::calcDoubleFromRk( sal_Int32 nRkValue ) { double fValue = 0.0; @@ -284,24 +219,24 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, /*static*/ rtl_TextEncoding BiffHelper::calcTextEncodingFromCodePage( sal_uInt16 nCodePage ) { - const CodePageEntry* pEntry = ::std::find_if( spCodePages, STATIC_ARRAY_END( spCodePages ), CodePageEntry_CPPred( nCodePage ) ); - if( pEntry == STATIC_ARRAY_END( spCodePages ) ) + // some specials for BIFF + switch( nCodePage ) { - OSL_ENSURE( false, "UnitConverter::calcTextEncodingFromCodePage - unknown code page" ); - return RTL_TEXTENCODING_DONTKNOW; + case 1200: return RTL_TEXTENCODING_DONTKNOW; // BIFF8 Unicode + case 32768: return RTL_TEXTENCODING_APPLE_ROMAN; + case 32769: return RTL_TEXTENCODING_MS_1252; // BIFF2-BIFF3 } - return pEntry->meTextEnc; + + rtl_TextEncoding eTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage ); + OSL_ENSURE( eTextEnc != RTL_TEXTENCODING_DONTKNOW, "BiffHelper::calcTextEncodingFromCodePage - unknown code page" ); + return eTextEnc; } /*static*/ sal_uInt16 BiffHelper::calcCodePageFromTextEncoding( rtl_TextEncoding eTextEnc ) { - const CodePageEntry* pEntry = ::std::find_if( spCodePages, STATIC_ARRAY_END( spCodePages ), CodePageEntry_TEPred( eTextEnc ) ); - if( pEntry == STATIC_ARRAY_END( spCodePages ) ) - { - OSL_ENSURE( false, "UnitConverter::calcCodePageFromTextEncoding - unsupported text encoding" ); - return 1252; - } - return pEntry->mnCodePage; + sal_uInt32 nCodePage = rtl_getWindowsCodePageFromTextEncoding( eTextEnc ); + OSL_ENSURE( (0 < nCodePage) && (nCodePage <= SAL_MAX_UINT16), "BiffHelper::calcCodePageFromTextEncoding - unknown text encoding" ); + return static_cast< sal_uInt16 >( (nCodePage == 0) ? 1252 : nCodePage ); } /*static*/ void BiffHelper::importImgData( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, BiffType eBiff ) diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index d5627c56b4a3..71475790851f 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -30,6 +30,7 @@ #include "oox/xls/biffdetector.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/excelchartconverter.hxx" +#include "oox/xls/stylesbuffer.hxx" #include "oox/xls/themebuffer.hxx" #include "oox/xls/workbookfragment.hxx" #include "oox/dump/biffdumper.hxx" @@ -56,29 +57,29 @@ namespace xls { // ============================================================================ ExcelFilterBase::ExcelFilterBase() : - mpHelper( 0 ) + mpData( 0 ) { } ExcelFilterBase::~ExcelFilterBase() { - OSL_ENSURE( !mpHelper, "ExcelFilterBase::~ExcelFilterBase - workbook helper not cleared" ); + OSL_ENSURE( !mpData, "ExcelFilterBase::~ExcelFilterBase - workbook data not cleared" ); } -void ExcelFilterBase::setWorkbookHelper( WorkbookHelper& rHelper ) +void ExcelFilterBase::registerWorkbookData( WorkbookData& rData ) { - mpHelper = &rHelper; + mpData = &rData; } -WorkbookHelper& ExcelFilterBase::getWorkbookHelper() const +WorkbookData& ExcelFilterBase::getWorkbookData() const { - OSL_ENSURE( mpHelper, "ExcelFilterBase::getWorkbookHelper - missing workbook helper" ); - return *mpHelper; + OSL_ENSURE( mpData, "ExcelFilterBase::getWorkbookData - missing workbook data" ); + return *mpData; } -void ExcelFilterBase::clearWorkbookHelper() +void ExcelFilterBase::unregisterWorkbookData() { - mpHelper = 0; + mpData = 0; } // ============================================================================ @@ -124,12 +125,7 @@ bool ExcelFilter::importDocument() throw() if( aWorkbookPath.getLength() > 0 ) { WorkbookHelperRoot aHelper( *this ); - if( aHelper.isValid() ) - { - setWorkbookHelper( aHelper ); // needed for callbacks - bRet = importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); - clearWorkbookHelper(); - } + bRet = aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); } return bRet; } @@ -139,19 +135,9 @@ bool ExcelFilter::exportDocument() throw() return false; } -sal_Int32 ExcelFilter::getSchemeColor( sal_Int32 nToken ) const -{ - return getWorkbookHelper().getTheme().getColorByToken( nToken ); -} - -sal_Int32 ExcelFilter::getPaletteColor( sal_Int32 nPaletteIdx ) const -{ - return getWorkbookHelper().getStyles().getPaletteColor( nPaletteIdx ); -} - const ::oox::drawingml::Theme* ExcelFilter::getCurrentTheme() const { - return &getWorkbookHelper().getTheme(); + return &WorkbookHelper( getWorkbookData() ).getTheme(); } ::oox::vml::Drawing* ExcelFilter::getVmlDrawing() @@ -166,7 +152,12 @@ const TableStyleListPtr ExcelFilter::getTableStyles() ::oox::drawingml::chart::ChartConverter& ExcelFilter::getChartConverter() { - return getWorkbookHelper().getChartConverter(); + return WorkbookHelper( getWorkbookData() ).getChartConverter(); +} + +GraphicHelper* ExcelFilter::implCreateGraphicHelper() const +{ + return new ExcelGraphicHelper( getWorkbookData() ); } OUString ExcelFilter::implGetImplementationName() const @@ -229,12 +220,7 @@ bool ExcelBiffFilter::importDocument() throw() if( eBiff != BIFF_UNKNOWN ) { WorkbookHelperRoot aHelper( *this, eBiff ); - if( aHelper.isValid() ) - { - setWorkbookHelper( aHelper ); // needed for callbacks - bRet = BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); - clearWorkbookHelper(); - } + bRet = aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); } return bRet; } @@ -244,9 +230,9 @@ bool ExcelBiffFilter::exportDocument() throw() return false; } -sal_Int32 ExcelBiffFilter::getPaletteColor( sal_Int32 nPaletteIdx ) const +GraphicHelper* ExcelBiffFilter::implCreateGraphicHelper() const { - return getWorkbookHelper().getStyles().getPaletteColor( nPaletteIdx ); + return new ExcelGraphicHelper( getWorkbookData() ); } OUString ExcelBiffFilter::implGetImplementationName() const diff --git a/oox/source/xls/excelvbaproject.cxx b/oox/source/xls/excelvbaproject.cxx new file mode 100755 index 000000000000..fc3caf7e59aa --- /dev/null +++ b/oox/source/xls/excelvbaproject.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/xls/excelvbaproject.hxx" +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "oox/helper/helper.hxx" +#include "oox/helper/propertyset.hxx" + +using ::rtl::OUString; +using ::com::sun::star::container::XEnumeration; +using ::com::sun::star::container::XEnumerationAccess; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::sheet::XSpreadsheetDocument; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace xls { + +// ============================================================================ + +VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XSpreadsheetDocument >& rxDocument ) : + ::oox::ole::VbaProject( rxGlobalFactory, Reference< XModel >( rxDocument, UNO_QUERY ), CREATE_OUSTRING( "Calc" ) ), + mxDocument( rxDocument ) +{ +} + +void VbaProject::attachToEvents() +{ + // do nothing is code is not executable + if( !isImportVbaExecutable() ) + return; + + // document events + PropertySet aDocProp( mxDocument ); + OUString aCodeName; + aDocProp.getProperty( aCodeName, PROP_CodeName ); + attachToDocumentEvents( aCodeName ); + + // sheet events + if( mxDocument.is() ) try + { + Reference< XEnumerationAccess > xSheetsEA( mxDocument->getSheets(), UNO_QUERY_THROW ); + Reference< XEnumeration > xSheetsEnum( xSheetsEA->createEnumeration(), UNO_SET_THROW ); + // own try/catch for every sheet + while( xSheetsEnum->hasMoreElements() ) try + { + // TODO: once we have chart sheets we need a switch/case on sheet type + Reference< XEventsSupplier > xEventsSupp( xSheetsEnum->nextElement(), UNO_QUERY_THROW ); + PropertySet aSheetProp( xEventsSupp ); + aSheetProp.getProperty( aCodeName, PROP_CodeName ); + attachToSheetEvents( xEventsSupp, aCodeName ); + } + catch( Exception& ) + { + } + } + catch( Exception& ) + { + } +} + +// private -------------------------------------------------------------------- + +void VbaProject::attachToDocumentEvents( const OUString& rCodeName ) +{ + if( (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) + return; + + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnLoad" ), rCodeName, CREATE_OUSTRING( "Workbook_Open" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Activate" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Deactivate" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSave" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False, False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAs" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True, False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrint" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforePrint" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrepareUnload" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeClose" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); +} + +void VbaProject::attachToSheetEvents( const Reference< XEventsSupplier >& rxEventsSupp, const OUString& rCodeName ) +{ + if( !rxEventsSupp.is() || (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) + return; + + // attach macros to simple sheet events directly + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Activate" ) ); + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Deactivate" ) ); + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnCalculate" ), rCodeName, CREATE_OUSTRING( "Worksheet_Calculate" ) ); + + /* Attach macros to complex sheet events. The events pass a cell range or + a collection of cell ranges depending on the event type and sheet + selection. The generated proxy macros need to convert these UNO renges + to VBA compatible ranges. + */ + +#define VBA_MACRONAME_RANGECONV "Local_GetVbaRangeFromUnoRange" +#define VBA_MACRONAME_TARGETCONV "Local_GetVbaTargetFromUnoTarget" + + /* If this variable turns to true, the macros that convert UNO cell ranges + to VBA Range objects have to be inserted. + */ + bool bNeedsTargetHelper = false; + + /* Insert the proxy macros attached to sheet events that notify something + has changed (changed selection and changed cell contents). These events + cannot be cancelled. The proxy macro converts the passed UNO cell range + or collection of cell ranges to a VBA Range object, and calls the VBA + event handler. + */ + OUString aChangeProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aChangeProxyCode = CREATE_OUSTRING( + "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" + "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget" ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnChange" ), rCodeName, CREATE_OUSTRING( "Worksheet_Change" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnSelect" ), rCodeName, CREATE_OUSTRING( "Worksheet_SelectionChange" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); + + /* Insert the proxy macros attached to sheet events that notify an ongoing + mouse click event (double click and right click). These events can be + cancelled by returning false (in VBA: as a Boolean output parameter, in + UNO: as return value of the Basic function). The proxy macro converts + the passed UNO cell range or collection of cell ranges to a VBA Range + object, calls the VBA event handler, and returns the Boolean value + provided by the VBA event handler. + */ + OUString aClickProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aClickProxyRetT = CREATE_OUSTRING( "Boolean" ); + OUString aClickProxyCode = CREATE_OUSTRING( + "\tDim Cancel As Boolean : Cancel = False\n" + "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" + "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget, Cancel\n" + "\t$PROXY = Cancel" ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnDoubleClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeDoubleClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnRightClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeRightClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); + + if( bNeedsTargetHelper ) + { + /* Generate a helper function that converts a + com.sun.star.sheet.SheetCellRange object to a VBA Range object. + */ + OUString aRangeConvName = CREATE_OUSTRING( VBA_MACRONAME_RANGECONV ); + OUString aRangeConvArgs = CREATE_OUSTRING( "ByVal unoRange As com.sun.star.sheet.SheetCellRange" ); + OUString aRangeConvRetT = CREATE_OUSTRING( "Range" ); + OUString aRangeConvCode = CREATE_OUSTRING( + "\tDim unoAddress As com.sun.star.table.CellRangeAddress : Set unoAddress = unoRange.RangeAddress\n" + "\tDim vbaSheet As Worksheet : Set vbaSheet = Application.ThisWorkbook.Sheets( unoAddress.Sheet + 1 )\n" + "\tSet $MACRO = vbaSheet.Range( vbaSheet.Cells( unoAddress.StartRow + 1, unoAddress.StartColumn + 1 ), vbaSheet.Cells( unoAddress.EndRow + 1, unoAddress.EndColumn + 1 ) )" ); + insertMacro( rCodeName, aRangeConvName, aRangeConvArgs, aRangeConvRetT, aRangeConvCode ); + + /* Generate a helper function that converts a generic range selection + object (com.sun.star.sheet.SheetCellRange or + com.sun.star.sheet.SheetCellRanges) to a VBA Range object. + */ + OUString aTargetConvName = CREATE_OUSTRING( VBA_MACRONAME_TARGETCONV ); + OUString aTargetConvArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aTargetConvRetT = CREATE_OUSTRING( "Range" ); + OUString aTargetConvCode = CREATE_OUSTRING( + "\tDim vbaTarget As Range\n" + "\tIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRange\" ) Then\n" + "\t\tSet vbaTarget = " VBA_MACRONAME_RANGECONV "( unoTarget )\n" + "\tElseIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRanges\" ) Then\n" + "\t\tDim unoRangeEnum As Object : Set unoRangeEnum = unoTarget.createEnumeration\n" + "\t\tIf unoRangeEnum.hasMoreElements Then Set vbaTarget = " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement )\n" + "\t\tWhile unoRangeEnum.hasMoreElements\n" + "\t\t\tSet vbaTarget = Application.Union( vbaTarget, " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement ) )\n" + "\t\tWend\n" + "\tEnd If\n" + "\tSet $MACRO = vbaTarget" ); + insertMacro( rCodeName, aTargetConvName, aTargetConvArgs, aTargetConvRetT, aTargetConvCode ); + } +#undef VBA_MACRONAME_RANGECONV +#undef VBA_MACRONAME_TARGETCONV +} + +// ============================================================================ + +} // namespace xls +} // namespace oox diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index c0337444f59d..12deadecd695 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -2751,19 +2751,16 @@ FormulaParser::~FormulaParser() void FormulaParser::importFormula( FormulaContext& rContext, const OUString& rFormulaString ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importOoxFormula( rContext, rFormulaString ); } void FormulaParser::importFormula( FormulaContext& rContext, RecordInputStream& rStrm ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importOobFormula( rContext, rStrm ); } void FormulaParser::importFormula( FormulaContext& rContext, BiffInputStream& rStrm, const sal_uInt16* pnFmlaSize ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importBiffFormula( rContext, rStrm, pnFmlaSize ); } diff --git a/oox/source/xls/makefile.mk b/oox/source/xls/makefile.mk index cdb2e18c262d..b5ede953bbfe 100644 --- a/oox/source/xls/makefile.mk +++ b/oox/source/xls/makefile.mk @@ -59,6 +59,7 @@ SLOFILES = \ $(SLO)$/excelchartconverter.obj \ $(SLO)$/excelfilter.obj \ $(SLO)$/excelhandlers.obj \ + $(SLO)$/excelvbaproject.obj \ $(SLO)$/externallinkbuffer.obj \ $(SLO)$/externallinkfragment.obj \ $(SLO)$/formulabase.obj \ diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index be5644554d6d..43c2f1b0b654 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -171,7 +171,6 @@ OoxSheetDataContext::OoxSheetDataContext( OoxWorksheetFragmentBase& rFragment ) ContextHandlerRef OoxSheetDataContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( ONCREATESHEETCONTEXT ); switch( getCurrentElement() ) { case XLS_TOKEN( sheetData ): @@ -201,7 +200,6 @@ ContextHandlerRef OoxSheetDataContext::onCreateContext( sal_Int32 nElement, cons void OoxSheetDataContext::onEndElement( const OUString& rChars ) { - OOX_LOADSAVE_TIMER( ONENDSHEETELEMENT ); switch( getCurrentElement() ) { case XLS_TOKEN( v ): @@ -342,7 +340,6 @@ ContextHandlerRef OoxSheetDataContext::onCreateRecordContext( sal_Int32 nRecId, void OoxSheetDataContext::importRow( const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( IMPORTROW ); RowModel aModel; aModel.mnFirstRow = aModel.mnLastRow = rAttribs.getInteger( XML_r, -1 ); aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 ); @@ -361,7 +358,6 @@ void OoxSheetDataContext::importRow( const AttributeList& rAttribs ) void OoxSheetDataContext::importCell( const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( IMPORTCELL ); maCurrCell.reset(); maCurrCell.mxCell = getCell( rAttribs.getString( XML_r, OUString() ), &maCurrCell.maAddress ); maCurrCell.mnCellType = rAttribs.getToken( XML_t, XML_n ); diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index 3eac90040667..e18f47a378ed 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -94,10 +94,6 @@ const sal_Int32 OOX_FONTFAMILY_MODERN = 3; const sal_Int32 OOX_FONTFAMILY_SCRIPT = 4; const sal_Int32 OOX_FONTFAMILY_DECORATIVE = 5; -// OOX font charset (also used in BIFF) -const sal_Int32 OOX_FONTCHARSET_UNUSED = -1; -const sal_Int32 OOX_FONTCHARSET_ANSI = 0; - // OOX cell text direction (also used in BIFF) const sal_Int32 OOX_XF_TEXTDIR_CONTEXT = 0; const sal_Int32 OOX_XF_TEXTDIR_LTR = 1; @@ -306,7 +302,27 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) } // namespace -// ---------------------------------------------------------------------------- +// ============================================================================ + +ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) : + GraphicHelper( rHelper.getGlobalFactory() ), + WorkbookHelper( rHelper ) +{ +} + +sal_Int32 ExcelGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + if( getFilterType() == FILTER_OOX ) + return getTheme().getColorByToken( nToken ); + return GraphicHelper::getSchemeColor( nToken ); +} + +sal_Int32 ExcelGraphicHelper::getPaletteColor( sal_Int32 nPaletteIdx ) const +{ + return getStyles().getPaletteColor( nPaletteIdx ); +} + +// ============================================================================ void Color::setAuto() { @@ -539,15 +555,15 @@ sal_Int32 ColorPalette::getColor( sal_Int32 nPaletteIdx ) const { case OOX_COLOR_WINDOWTEXT3: case OOX_COLOR_WINDOWTEXT: - case OOX_COLOR_CHWINDOWTEXT: nColor = getBaseFilter().getSystemColor( XML_windowText ); break; + case OOX_COLOR_CHWINDOWTEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_windowText ); break; case OOX_COLOR_WINDOWBACK3: case OOX_COLOR_WINDOWBACK: - case OOX_COLOR_CHWINDOWBACK: nColor = getBaseFilter().getSystemColor( XML_window ); break; - case OOX_COLOR_BUTTONBACK: nColor = getBaseFilter().getSystemColor( XML_btnFace ); break; - case OOX_COLOR_CHBORDERAUTO: nColor = API_RGB_BLACK; /* really always black? */ break; - case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getSystemColor( XML_infoBk ); break; - case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getSystemColor( XML_infoText ); break; - case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break; + case OOX_COLOR_CHWINDOWBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_window ); break; + case OOX_COLOR_BUTTONBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_btnFace ); break; + case OOX_COLOR_CHBORDERAUTO: nColor = API_RGB_BLACK; /* really always black? */ break; + case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk ); break; + case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText ); break; + case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break; default: OSL_ENSURE( false, "ColorPalette::getColor - unknown color index" ); } return nColor; @@ -572,7 +588,8 @@ void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDe { rFontName.maName = rFontDesc.Name; rFontName.mnFamily = rFontDesc.Family; - rFontName.mnCharSet = rFontDesc.CharSet; + // API font descriptor contains rtl_TextEncoding constants + rFontName.mnTextEnc = rFontDesc.CharSet; } else { @@ -587,7 +604,7 @@ void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDe FontModel::FontModel() : mnScheme( XML_none ), mnFamily( OOX_FONTFAMILY_NONE ), - mnCharSet( OOX_FONTCHARSET_ANSI ), + mnCharSet( WINDOWS_CHARSET_DEFAULT ), mfHeight( 0.0 ), mnUnderline( XML_none ), mnEscapement( XML_baseline ), @@ -655,7 +672,7 @@ ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed ) : ApiScriptFontName::ApiScriptFontName() : mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW ), - mnCharSet( RTL_TEXTENCODING_DONTKNOW ) + mnTextEnc( RTL_TEXTENCODING_DONTKNOW ) { } @@ -977,13 +994,13 @@ void Font::finalizeImport() case OOX_FONTFAMILY_DECORATIVE: maApiData.maDesc.Family = cssawt::FontFamily::DECORATIVE; break; } - // character set - if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= 255) ) + // character set (API font descriptor uses rtl_TextEncoding in member CharSet!) + if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= SAL_MAX_UINT8) ) maApiData.maDesc.CharSet = static_cast< sal_Int16 >( rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maModel.mnCharSet ) ) ); // color, height, weight, slant, strikeout, outline, shadow - maApiData.mnColor = maModel.maColor.getColor( getBaseFilter() ); + maApiData.mnColor = maModel.maColor.getColor( getBaseFilter().getGraphicHelper() ); maApiData.maDesc.Height = static_cast< sal_Int16 >( maModel.mfHeight * 20.0 ); maApiData.maDesc.Weight = maModel.mbBold ? cssawt::FontWeight::BOLD : cssawt::FontWeight::NORMAL; maApiData.maDesc.Slant = maModel.mbItalic ? cssawt::FontSlant_ITALIC : cssawt::FontSlant_NONE; @@ -1084,19 +1101,19 @@ void Font::writeToPropertyMap( PropertyMap& rPropMap, FontPropertyType ePropType { rPropMap[ PROP_CharFontName ] <<= maApiData.maLatinFont.maName; rPropMap[ PROP_CharFontFamily ] <<= maApiData.maLatinFont.mnFamily; - rPropMap[ PROP_CharFontCharSet ] <<= maApiData.maLatinFont.mnCharSet; + rPropMap[ PROP_CharFontCharSet ] <<= maApiData.maLatinFont.mnTextEnc; } if( maApiData.maAsianFont.maName.getLength() > 0 ) { rPropMap[ PROP_CharFontNameAsian ] <<= maApiData.maAsianFont.maName; rPropMap[ PROP_CharFontFamilyAsian ] <<= maApiData.maAsianFont.mnFamily; - rPropMap[ PROP_CharFontCharSetAsian ] <<= maApiData.maAsianFont.mnCharSet; + rPropMap[ PROP_CharFontCharSetAsian ] <<= maApiData.maAsianFont.mnTextEnc; } if( maApiData.maCmplxFont.maName.getLength() > 0 ) { rPropMap[ PROP_CharFontNameComplex ] <<= maApiData.maCmplxFont.maName; rPropMap[ PROP_CharFontFamilyComplex ] <<= maApiData.maCmplxFont.mnFamily; - rPropMap[ PROP_CharFontCharSetComplex ] <<= maApiData.maCmplxFont.mnCharSet; + rPropMap[ PROP_CharFontCharSetComplex ] <<= maApiData.maCmplxFont.mnTextEnc; } } // font height @@ -1159,7 +1176,7 @@ void Font::importFontData2( BiffInputStream& rStrm ) maModel.setBiffHeight( nHeight ); maModel.mnFamily = OOX_FONTFAMILY_NONE; - maModel.mnCharSet = OOX_FONTCHARSET_UNUSED; // ensure to not use font charset in byte string import + maModel.mnCharSet = -1; // ensure to not use font charset in byte string import maModel.mnUnderline = getFlagValue( nFlags, BIFF_FONTFLAG_UNDERLINE, XML_single, XML_none ); maModel.mnEscapement = XML_none; maModel.mbBold = getFlag( nFlags, BIFF_FONTFLAG_BOLD ); @@ -1720,7 +1737,7 @@ BorderLineModel* Border::getBorderLine( sal_Int32 nElement ) bool Border::convertBorderLine( BorderLine& rBorderLine, const BorderLineModel& rModel ) { - rBorderLine.Color = rModel.maColor.getColor( getBaseFilter(), API_RGB_BLACK ); + rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK ); switch( rModel.mnStyle ) { case XML_dashDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; @@ -2016,7 +2033,7 @@ void Fill::importCfRule( BiffInputStream& rStrm, sal_uInt32 nFlags ) void Fill::finalizeImport() { - const FilterBase& rFilter = getBaseFilter(); + const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper(); if( mxPatternModel.get() ) { @@ -2068,16 +2085,16 @@ void Fill::finalizeImport() case XML_solid: nAlpha = 0x80; break; } - sal_Int32 nWinTextColor = rFilter.getSystemColor( XML_windowText ); - sal_Int32 nWinColor = rFilter.getSystemColor( XML_window ); + sal_Int32 nWinTextColor = rGraphicHelper.getSystemColor( XML_windowText ); + sal_Int32 nWinColor = rGraphicHelper.getSystemColor( XML_window ); if( !rModel.mbPattColorUsed ) rModel.maPatternColor.setAuto(); - sal_Int32 nPattColor = rModel.maPatternColor.getColor( rFilter, nWinTextColor ); + sal_Int32 nPattColor = rModel.maPatternColor.getColor( rGraphicHelper, nWinTextColor ); if( !rModel.mbFillColorUsed ) rModel.maFillColor.setAuto(); - sal_Int32 nFillColor = rModel.maFillColor.getColor( rFilter, nWinColor ); + sal_Int32 nFillColor = rModel.maFillColor.getColor( rGraphicHelper, nWinColor ); maApiData.mnColor = lclGetMixedColor( nPattColor, nFillColor, nAlpha ); maApiData.mbTransparent = false; @@ -2089,11 +2106,11 @@ void Fill::finalizeImport() maApiData.mbUsed = true; // no support for differential attributes GradientFillModel::ColorMap::const_iterator aIt = rModel.maColors.begin(); OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" ); - maApiData.mnColor = aIt->second.getColor( rFilter, API_RGB_WHITE ); + maApiData.mnColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE ); if( ++aIt != rModel.maColors.end() ) { OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" ); - sal_Int32 nEndColor = aIt->second.getColor( rFilter, API_RGB_WHITE ); + sal_Int32 nEndColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE ); maApiData.mnColor = lclGetMixedColor( maApiData.mnColor, nEndColor, 0x40 ); maApiData.mbTransparent = false; } diff --git a/oox/source/xls/unitconverter.cxx b/oox/source/xls/unitconverter.cxx index 6f287581c854..170a1f66f2e2 100644 --- a/oox/source/xls/unitconverter.cxx +++ b/oox/source/xls/unitconverter.cxx @@ -108,7 +108,7 @@ UnitConverter::UnitConverter( const WorkbookHelper& rHelper ) : mnNullDate( lclGetDays( Date( 30, 12, 1899 ) ) ) { // initialize constant and default coefficients - const DeviceInfo& rDeviceInfo = getBaseFilter().getDeviceInfo(); + const DeviceInfo& rDeviceInfo = getBaseFilter().getGraphicHelper().getDeviceInfo(); maCoeffs[ UNIT_INCH ] = MM100_PER_INCH; maCoeffs[ UNIT_POINT ] = MM100_PER_POINT; maCoeffs[ UNIT_TWIP ] = MM100_PER_TWIP; diff --git a/oox/source/xls/viewsettings.cxx b/oox/source/xls/viewsettings.cxx index 69af326c2471..3d88e64dbb12 100644 --- a/oox/source/xls/viewsettings.cxx +++ b/oox/source/xls/viewsettings.cxx @@ -199,7 +199,7 @@ sal_Int32 SheetViewModel::getPageBreakZoom() const sal_Int32 SheetViewModel::getGridColor( const FilterBase& rFilter ) const { - return mbDefGridColor ? API_RGB_TRANSPARENT : maGridColor.getColor( rFilter ); + return mbDefGridColor ? API_RGB_TRANSPARENT : maGridColor.getColor( rFilter.getGraphicHelper() ); } const PaneSelectionModel* SheetViewModel::getPaneSelection( sal_Int32 nPaneId ) const diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index e61820a2e620..b5eb9a11dd2c 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -31,10 +31,13 @@ #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" #include "oox/helper/recordinputstream.hxx" +#include "oox/ole/olestorage.hxx" +#include "oox/core/filterbase.hxx" #include "oox/drawingml/themefragmenthandler.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/chartsheetfragment.hxx" #include "oox/xls/connectionsfragment.hxx" +#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/externallinkfragment.hxx" #include "oox/xls/pivotcachebuffer.hxx" @@ -53,6 +56,8 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::io::XInputStream; using ::com::sun::star::table::CellAddress; using ::oox::core::ContextHandlerRef; using ::oox::core::FragmentHandlerRef; @@ -284,13 +289,24 @@ void OoxWorkbookFragment::finalizeImport() // load all worksheets for( SheetFragmentVector::iterator aIt = aSheetFragments.begin(), aEnd = aSheetFragments.end(); aIt != aEnd; ++aIt ) { - OOX_LOADSAVE_TIMER( IMPORTSHEETFRAGMENT ); // import the sheet fragment importOoxFragment( *aIt ); // delete fragment object, will free all allocated sheet buffers aIt->clear(); } + // import the VBA project (after loading the sheets, as they have imported the code names) + OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATIONSTYPE( "vbaProject" ) ); + if( aVbaFragmentPath.getLength() > 0 ) + { + Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath ); + if( xInStrm.is() ) + { + ::oox::ole::OleStorage aVbaStrg( getGlobalFactory(), xInStrm, false ); + getVbaProject().importVbaProject( aVbaStrg, getBaseFilter().getGraphicHelper() ); + } + } + // final conversions, e.g. calculation settings and view settings finalizeWorkbookImport(); } @@ -344,7 +360,8 @@ void OoxWorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, s // ============================================================================ BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper, const OUString& rStrmName ) : - BiffWorkbookFragmentBase( rHelper, rStrmName ) + BiffWorkbookFragmentBase( rHelper, rStrmName ), + mbImportVbaProject( false ) { } @@ -372,6 +389,13 @@ bool BiffWorkbookFragment::importFragment() sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet ); bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nCalcSheet ); } + // import the VBA project (after loading the sheets, as they have imported the code names) + if( mbImportVbaProject ) + { + StorageRef xVbaStrg = getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ); + if( xVbaStrg.get() ) + getVbaProject().importVbaProject( *xVbaStrg, getBaseFilter().getGraphicHelper() ); + } } break; @@ -462,6 +486,8 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress StylesBuffer& rStyles = getStyles(); WorksheetBuffer& rWorksheets = getWorksheets(); PivotCacheBuffer& rPivotCaches = getPivotCaches(); + bool bHasVbaProject = false; + bool bEmptyVbaProject = false; // collect records that need to be loaded in a second pass typedef ::std::vector< sal_Int64 > RecordHandleVec; @@ -562,25 +588,27 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress case BIFF8: switch( nRecId ) { - case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; - case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( mrStrm ); break; - case BIFF_ID_CRN: bExtLinkRec = true; break; - case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; - case BIFF_ID_EXTERNALBOOK: bExtLinkRec = true; break; - case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; - case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF_ID_FILESHARING: rWorkbookSett.importFileSharing( mrStrm ); break; - case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; - case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; - case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break; - case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; - case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; - case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break; - case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; + case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; + case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( mrStrm ); break; + case BIFF_ID_CRN: bExtLinkRec = true; break; + case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; + case BIFF_ID_EXTERNALBOOK: bExtLinkRec = true; break; + case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; + case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; + case BIFF_ID_FILESHARING: rWorkbookSett.importFileSharing( mrStrm ); break; + case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_VBAPROJECT: bHasVbaProject = true; break; + case BIFF_ID_VBAPROJECTEMPTY: bEmptyVbaProject = true; break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break; + case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; + case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; + case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break; + case BIFF_ID_XCT: bExtLinkRec = true; break; + case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; } break; @@ -618,6 +646,9 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress bRet = mrStrm.startRecordByHandle( nEofHandle ); } + // import the VBA project + mbImportVbaProject = bHasVbaProject && !bEmptyVbaProject; + // #i56376# missing EOF - rewind before worksheet BOF record (see above) if( bRet && isBofRecord() ) mrStrm.rewindRecord(); diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index 93ad0a65422f..9794b58e6a1b 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -27,7 +27,6 @@ #include "oox/xls/workbookhelper.hxx" #include -#include #include #include #include @@ -44,14 +43,14 @@ #include "properties.hxx" #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/binaryfilterbase.hxx" -#include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/theme.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/biffcodec.hxx" #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelchartconverter.hxx" +#include "oox/xls/excelfilter.hxx" +#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/formulaparser.hxx" #include "oox/xls/pagesettings.hxx" @@ -68,7 +67,6 @@ #include "oox/xls/workbooksettings.hxx" #include "oox/xls/worksheetbuffer.hxx" -using ::rtl::OStringBuffer; using ::rtl::OUString; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; @@ -103,148 +101,6 @@ using ::oox::drawingml::Theme; namespace oox { namespace xls { -// DEBUG ====================================================================== - -#if OSL_DEBUG_LEVEL > 0 -namespace dbg { - -// ---------------------------------------------------------------------------- - -#if OOX_SHOW_LOADSAVE_TIME > 0 - -struct TimeCount -{ - sal_Int64 mnTime; - sal_Int32 mnCount; - inline explicit TimeCount() : mnTime( 0 ), mnCount( 0 ) {} -}; - -Timer::Timer( TimeCount& rTimeCount ) : - mrTimeCount( rTimeCount ) -{ - ++mrTimeCount.mnCount; - osl_getSystemTime( &maStartTime ); -} - -Timer::~Timer() -{ - TimeValue aEndTime; - osl_getSystemTime( &aEndTime ); - mrTimeCount.mnTime += (SAL_CONST_INT64( 1000000000 ) * (aEndTime.Seconds - maStartTime.Seconds) + aEndTime.Nanosec - maStartTime.Nanosec); -} - -#endif - -// ---------------------------------------------------------------------------- - -struct WorkbookData -{ -#if OOX_SHOW_LOADSAVE_TIME > 0 - typedef ::std::vector< TimeCount > TimeCountVector; - typedef ::boost::shared_ptr< Timer > TimerRef; - TimeCountVector maTimeCounts; - TimerRef mxTotal; -#endif - sal_Int32 mnObjCount; - - explicit WorkbookData(); - ~WorkbookData(); -#if OOX_SHOW_LOADSAVE_TIME > 0 - TimeCount& getTimeCount( TimerType eType ); -#endif -}; - -WorkbookData::WorkbookData() : -#if OOX_SHOW_LOADSAVE_TIME > 0 - maTimeCounts( static_cast< size_t >( TIMER_TOTAL + 1 ) ), - mxTotal( new Timer( getTimeCount( TIMER_TOTAL ) ) ), -#endif - mnObjCount( 0 ) -{ -} - -WorkbookData::~WorkbookData() -{ -#if OOX_SHOW_LOADSAVE_TIME > 0 - mxTotal.reset(); - static const sal_Char* sppcNames[] = - { - "importFormula\t", - "importSheetFragment", - " onCreateSheetContext", - " importRow\t", - " convertRowFormat", - " convertColumnFormat", - " importCell\t", - " onEndSheetElement", - " setCell\t\t", - " setCellFormat\t", - " mergeCellFormats", - " writeCellProperties", - " finalizeSheetData", - " finalizeDrawing", - "finalizeBookData", - "total\t\t" - }; - OStringBuffer aBuffer( "Call counts and load/save times:\n" ); - sal_Int32 nIdx = 0; - for( TimeCountVector::iterator aIt = maTimeCounts.begin(), aEnd = maTimeCounts.end(); aIt != aEnd; ++aIt, ++nIdx ) - { - if( aIt->mnCount > 0 ) - { - aBuffer.append( nIdx ).append( ":\t" ).append( sppcNames[ nIdx ] ). - append( "\tn=" ).append( aIt->mnCount ).append( ',' ). - append( "\tt=" ).append( (aIt->mnTime / 100000000) / 10.0 ).append( 's' ). - append( "\t(" ).append( static_cast< sal_Int32 >( ((aIt->mnTime * 1000) / maTimeCounts.back().mnTime) / 10 ) ).append( "%)" ); - if( aIt->mnCount > 1 ) - aBuffer.append( "\tt/n=" ).append( static_cast< sal_Int32 >( aIt->mnTime / aIt->mnCount / 1000 ) ).append( "mys" ); - aBuffer.append( '\n' ); - } - } - OSL_ENSURE( false, aBuffer.getStr() ); -#endif - OSL_ENSURE( mnObjCount == 0, - OStringBuffer( "WorkbookData::~WorkbookData - failed to delete " ).append( mnObjCount ).append( " objects" ).getStr() ); -} - -#if OOX_SHOW_LOADSAVE_TIME > 0 -TimeCount& WorkbookData::getTimeCount( TimerType eType ) -{ - return maTimeCounts[ static_cast< size_t >( eType ) ]; -} -#endif - -// ---------------------------------------------------------------------------- - -WorkbookHelper::WorkbookHelper( WorkbookData& rBookData ) : - mrDbgBookData( rBookData ) -{ - ++mrDbgBookData.mnObjCount; -} - -WorkbookHelper::WorkbookHelper( const WorkbookHelper& rCopy ) : - mrDbgBookData( rCopy.mrDbgBookData ) -{ - ++mrDbgBookData.mnObjCount; -} - -WorkbookHelper::~WorkbookHelper() -{ - --mrDbgBookData.mnObjCount; -} - -#if OOX_SHOW_LOADSAVE_TIME > 0 -TimeCount& WorkbookHelper::getTimeCount( TimerType eType ) const -{ - return mrDbgBookData.getTimeCount( eType ); -} -#endif - -// ---------------------------------------------------------------------------- - -} // namespace dbg -#endif - // ============================================================================ bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const @@ -257,13 +113,10 @@ bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rNam // ============================================================================ class WorkbookData -#if OSL_DEBUG_LEVEL > 0 - : public dbg::WorkbookData -#endif { public: - explicit WorkbookData( XmlFilterBase& rFilter ); - explicit WorkbookData( BinaryFilterBase& rFilter, BiffType eBiff ); + explicit WorkbookData( ExcelFilter& rFilter ); + explicit WorkbookData( ExcelBiffFilter& rFilter, BiffType eBiff ); ~WorkbookData(); /** Returns true, if this helper refers to a valid document. */ @@ -348,6 +201,8 @@ public: inline ExcelChartConverter& getChartConverter() const { return *mxChartConverter; } /** Returns the page/print settings converter. */ inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; } + /** Returns the VBA project used to import/export VBA and attach events. */ + inline VbaProject& getVbaProject() const { return *mxVbaProject; } // OOX specific ----------------------------------------------------------- @@ -396,11 +251,12 @@ private: typedef ::std::auto_ptr< WebQueryBuffer > WebQueryBfrPtr; typedef ::std::auto_ptr< PivotCacheBuffer > PivotCacheBfrPtr; typedef ::std::auto_ptr< PivotTableBuffer > PivotTableBfrPtr; + typedef ::std::auto_ptr< FormulaParser > FormulaParserPtr; typedef ::std::auto_ptr< UnitConverter > UnitConvPtr; typedef ::std::auto_ptr< AddressConverter > AddressConvPtr; typedef ::std::auto_ptr< ExcelChartConverter > ExcelChartConvPtr; typedef ::std::auto_ptr< PageSettingsConverter > PageSettConvPtr; - typedef ::std::auto_ptr< FormulaParser > FormulaParserPtr; + typedef ::std::auto_ptr< VbaProject > VbaProjectPtr; typedef ::std::auto_ptr< BiffCodecHelper > BiffCodecHelperPtr; OUString maCellStyles; /// Style family name for cell styles. @@ -409,6 +265,7 @@ private: OUString maPageStyleServ; /// Service name for a page style. Reference< XSpreadsheetDocument > mxDoc; /// Document model. FilterBase& mrBaseFilter; /// Base filter object. + ExcelFilterBase& mrExcelBase; /// Base object for registration of this structure. FilterType meFilterType; /// File type of the filter. ProgressBarPtr mxProgressBar; /// The progress bar. sal_Int16 mnCurrSheet; /// Current sheet index in Calc dcument. @@ -435,6 +292,7 @@ private: AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter. ExcelChartConvPtr mxChartConverter; /// Chart object converter. PageSettConvPtr mxPageSettConverter; /// Page/print settings converter. + VbaProjectPtr mxVbaProject; /// VBA project. // OOX specific XmlFilterBase* mpOoxFilter; /// Base OOX filter object. @@ -449,27 +307,36 @@ private: // ---------------------------------------------------------------------------- -WorkbookData::WorkbookData( XmlFilterBase& rFilter ) : +WorkbookData::WorkbookData( ExcelFilter& rFilter ) : mrBaseFilter( rFilter ), + mrExcelBase( rFilter ), meFilterType( FILTER_OOX ), mpOoxFilter( &rFilter ), + mpBiffFilter( 0 ), meBiff( BIFF_UNKNOWN ) { + // register at the filter, needed for virtual callbacks (even during construction) + mrExcelBase.registerWorkbookData( *this ); initialize( true ); } -WorkbookData::WorkbookData( BinaryFilterBase& rFilter, BiffType eBiff ) : +WorkbookData::WorkbookData( ExcelBiffFilter& rFilter, BiffType eBiff ) : mrBaseFilter( rFilter ), + mrExcelBase( rFilter ), meFilterType( FILTER_BIFF ), + mpOoxFilter( 0 ), mpBiffFilter( &rFilter ), meBiff( eBiff ) { + // register at the filter, needed for virtual callbacks (even during construction) + mrExcelBase.registerWorkbookData( *this ); initialize( eBiff >= BIFF5 ); } WorkbookData::~WorkbookData() { finalize(); + mrExcelBase.unregisterWorkbookData(); } // document model ------------------------------------------------------------- @@ -681,8 +548,8 @@ void WorkbookData::initialize( bool bWorkbookFile ) mxUnitConverter.reset( new UnitConverter( *this ) ); mxAddrConverter.reset( new AddressConverter( *this ) ); mxChartConverter.reset( new ExcelChartConverter( *this ) ); - mxPageSettConverter.reset( new PageSettingsConverter( *this ) ); + mxVbaProject.reset( new VbaProject( mrBaseFilter.getGlobalFactory(), mxDoc ) ); // set some document properties needed during import if( mrBaseFilter.isImportFilter() ) @@ -715,7 +582,7 @@ void WorkbookData::initialize( bool bWorkbookFile ) switch( getFilterType() ) { case FILTER_BIFF: - mxCodecHelper.reset( new BiffCodecHelper( * this ) ); + mxCodecHelper.reset( new BiffCodecHelper( *this ) ); break; case FILTER_OOX: @@ -728,7 +595,6 @@ void WorkbookData::initialize( bool bWorkbookFile ) void WorkbookData::finalize() { - OOX_LOADSAVE_TIMER( FINALIZEBOOKDATA ); // set some document properties needed after import if( mrBaseFilter.isImportFilter() ) { @@ -752,14 +618,6 @@ void WorkbookData::finalize() // ============================================================================ -WorkbookHelper::WorkbookHelper( WorkbookData& rBookData ) : -#if OSL_DEBUG_LEVEL > 0 - dbg::WorkbookHelper( rBookData ), -#endif - mrBookData( rBookData ) -{ -} - WorkbookHelper::~WorkbookHelper() { } @@ -822,6 +680,9 @@ void WorkbookHelper::finalizeWorkbookImport() sheets. Automatic numbering is set by passing the value 0. */ PropertySet aDefPageStyle( getStyleObject( CREATE_OUSTRING( "Default" ), true ) ); aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); + + // attach VBA macros to document and sheet events + getVbaProject().attachToEvents(); } // document model ------------------------------------------------------------- @@ -1026,13 +887,16 @@ ExcelChartConverter& WorkbookHelper::getChartConverter() const return mrBookData.getChartConverter(); } -// property helpers ----------------------------------------------------------- - PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const { return mrBookData.getPageSettingsConverter(); } +VbaProject& WorkbookHelper::getVbaProject() const +{ + return mrBookData.getVbaProject(); +} + // OOX specific --------------------------------------------------------------- XmlFilterBase& WorkbookHelper::getOoxFilter() const @@ -1111,13 +975,13 @@ WorkbookDataOwner::~WorkbookDataOwner() // ---------------------------------------------------------------------------- -WorkbookHelperRoot::WorkbookHelperRoot( ::oox::core::XmlFilterBase& rFilter ) : +WorkbookHelperRoot::WorkbookHelperRoot( ExcelFilter& rFilter ) : prv::WorkbookDataOwner( prv::WorkbookDataRef( new WorkbookData( rFilter ) ) ), WorkbookHelper( *mxBookData ) { } -WorkbookHelperRoot::WorkbookHelperRoot( ::oox::core::BinaryFilterBase& rFilter, BiffType eBiff ) : +WorkbookHelperRoot::WorkbookHelperRoot( ExcelBiffFilter& rFilter, BiffType eBiff ) : prv::WorkbookDataOwner( prv::WorkbookDataRef( new WorkbookData( rFilter, eBiff ) ) ), WorkbookHelper( *mxBookData ) { diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx index 1277b0879e7a..40d400da7757 100644 --- a/oox/source/xls/workbooksettings.cxx +++ b/oox/source/xls/workbooksettings.cxx @@ -130,7 +130,7 @@ void WorkbookSettings::importFileSharing( const AttributeList& rAttribs ) void WorkbookSettings::importWorkbookPr( const AttributeList& rAttribs ) { - maBookSettings.maCodeName = rAttribs.getString( XML_codePage, OUString() ); + maBookSettings.maCodeName = rAttribs.getString( XML_codeName, OUString() ); maBookSettings.mnShowObjectMode = rAttribs.getToken( XML_showObjects, XML_all ); maBookSettings.mnUpdateLinksMode = rAttribs.getToken( XML_updateLinks, XML_userSet ); maBookSettings.mnDefaultThemeVer = rAttribs.getInteger( XML_defaultThemeVersion, -1 ); @@ -318,6 +318,9 @@ void WorkbookSettings::finalizeImport() Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY ); if( xCalculatable.is() ) xCalculatable->enableAutomaticCalculation( (maCalcSettings.mnCalcMode == XML_auto) || (maCalcSettings.mnCalcMode == XML_autoNoTable) ); + + // VBA code name + aPropSet.setProperty( PROP_CodeName, maBookSettings.maCodeName ); } sal_Int16 WorkbookSettings::getApiShowObjectMode() const diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index ff42c6afb704..14cf80a91d52 100644 --- a/oox/source/xls/worksheetfragment.cxx +++ b/oox/source/xls/worksheetfragment.cxx @@ -870,6 +870,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF8: switch( nRecId ) { case BIFF_ID_CFHEADER: rCondFormats.importCfHeader( mrStrm ); break; + case BIFF_ID_CODENAME: rWorksheetSett.importCodeName( mrStrm ); break; case BIFF_ID_COLINFO: importColInfo(); break; case BIFF_ID_DATAVALIDATION: importDataValidation(); break; case BIFF_ID_DATAVALIDATIONS: importDataValidations(); break; @@ -1080,7 +1081,7 @@ void BiffWorksheetFragment::importHyperlink() return; // try to read the StdHlink data - if( !::oox::ole::OleHelper::importStdHlink( aModel, mrStrm, getTextEncoding(), true ) ) + if( !::oox::ole::OleHelper::importStdHlink( aModel, mrStrm, true ) ) return; // try to read the optional following SCREENTIP record diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index e28df89cd7b3..381def644ce5 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -30,15 +30,10 @@ #include #include #include -#include #include #include -#include -#include -#include -#include #include -#include +#include #include #include #include @@ -52,7 +47,12 @@ #include #include #include +#include #include +#include +#include +#include +#include #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" @@ -75,30 +75,13 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::lang::Locale; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::beans::XPropertySet; -using ::com::sun::star::util::DateTime; -using ::com::sun::star::util::XMergeable; -using ::com::sun::star::util::XNumberFormatsSupplier; -using ::com::sun::star::util::XNumberFormatTypes; using ::com::sun::star::awt::Point; using ::com::sun::star::awt::Size; +using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::drawing::XDrawPage; using ::com::sun::star::drawing::XDrawPageSupplier; -using ::com::sun::star::table::BorderLine; -using ::com::sun::star::table::CellAddress; -using ::com::sun::star::table::CellRangeAddress; -using ::com::sun::star::table::XCell; -using ::com::sun::star::table::XCellRange; -using ::com::sun::star::table::XColumnRowRange; -using ::com::sun::star::table::XTableColumns; -using ::com::sun::star::table::XTableRows; +using ::com::sun::star::lang::Locale; +using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::sheet::ConditionOperator; using ::com::sun::star::sheet::ValidationType; using ::com::sun::star::sheet::ValidationAlertStyle; @@ -113,9 +96,26 @@ using ::com::sun::star::sheet::XSheetCellRanges; using ::com::sun::star::sheet::XSheetCondition; using ::com::sun::star::sheet::XSheetOutline; using ::com::sun::star::sheet::XSpreadsheet; +using ::com::sun::star::table::BorderLine; +using ::com::sun::star::table::CellAddress; +using ::com::sun::star::table::CellRangeAddress; +using ::com::sun::star::table::XCell; +using ::com::sun::star::table::XCellRange; +using ::com::sun::star::table::XColumnRowRange; +using ::com::sun::star::table::XTableColumns; +using ::com::sun::star::table::XTableRows; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextRange; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::util::DateTime; +using ::com::sun::star::util::XMergeable; +using ::com::sun::star::util::XNumberFormatsSupplier; +using ::com::sun::star::util::XNumberFormatTypes; namespace oox { namespace xls { @@ -792,7 +792,6 @@ void WorksheetData::setDimension( const CellRangeAddress& rRange ) void WorksheetData::setCellFormat( const CellModel& rModel ) { - OOX_LOADSAVE_TIMER( SETCELLFORMAT ); if( rModel.mxCell.is() && ((rModel.mnXfId >= 0) || (rModel.mnNumFmtId >= 0)) ) { // try to merge existing ranges and to write some formatting properties @@ -954,7 +953,6 @@ void WorksheetData::setRowModel( const RowModel& rModel ) void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId ) const { - OOX_LOADSAVE_TIMER( CONVERTCOLUMNFORMAT ); CellRangeAddress aRange( mnSheet, nFirstCol, 0, nLastCol, mrMaxApiPos.Row ); if( getAddressConverter().validateCellRange( aRange, true, false ) ) { @@ -965,7 +963,6 @@ void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol void WorksheetData::convertRowFormat( sal_Int32 nFirstRow, sal_Int32 nLastRow, sal_Int32 nXfId ) const { - OOX_LOADSAVE_TIMER( CONVERTROWFORMAT ); CellRangeAddress aRange( mnSheet, 0, nFirstRow, mrMaxApiPos.Column, nLastRow ); if( getAddressConverter().validateCellRange( aRange, true, false ) ) { @@ -987,13 +984,13 @@ void WorksheetData::initializeWorksheetImport() void WorksheetData::finalizeWorksheetImport() { - OOX_LOADSAVE_TIMER( FINALIZESHEETDATA ); lclUpdateProgressBar( mxRowProgress, 1.0 ); finalizeXfIdRanges(); lclUpdateProgressBar( mxFinalProgress, 0.25 ); finalizeHyperlinkRanges(); finalizeValidationRanges(); finalizeMergedRanges(); + maSheetSett.finalizeImport(); maCondFormats.finalizeImport(); maPageSett.finalizeImport(); maSheetViewSett.finalizeImport(); @@ -1117,7 +1114,6 @@ void WorksheetData::writeXfIdRowRangeProperties( const XfIdRowRange& rXfIdRowRan void WorksheetData::writeXfIdRangeProperties( const XfIdRange& rXfIdRange ) const { - OOX_LOADSAVE_TIMER( WRITECELLPROPERTIES ); StylesBuffer& rStyles = getStyles(); PropertyMap aPropMap; if( rXfIdRange.mnXfId >= 0 ) @@ -1132,7 +1128,6 @@ void WorksheetData::mergeXfIdRanges() { if( !maXfIdRanges.empty() ) { - OOX_LOADSAVE_TIMER( MERGECELLFORMAT ); // get row index of last range sal_Int32 nLastRow = maXfIdRanges.rbegin()->second.maRange.StartRow; // process all ranges located in the same row of the last range @@ -1397,10 +1392,7 @@ void WorksheetData::finalizeDrawing() OSL_ENSURE( (getFilterType() == FILTER_OOX) || (maDrawingPath.getLength() == 0), "WorksheetData::finalizeDrawing - unexpected DrawingML path" ); if( (getFilterType() == FILTER_OOX) && (maDrawingPath.getLength() > 0) ) - { - OOX_LOADSAVE_TIMER( FINALIZEDRAWING ); importOoxFragment( new OoxDrawingFragment( *this, maDrawingPath ) ); - } } void WorksheetData::finalizeVmlDrawing() @@ -1822,7 +1814,6 @@ void WorksheetHelper::setErrorCell( const Reference< XCell >& rxCell, sal_uInt8 void WorksheetHelper::setCell( CellModel& orModel ) const { OSL_ENSURE( orModel.mxCell.is(), "WorksheetHelper::setCell - missing cell interface" ); - OOX_LOADSAVE_TIMER( SETCELL ); if( orModel.mbHasValueStr ) switch( orModel.mnCellType ) { case XML_b: diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx index b9e4f4b8babc..6a42c38e1647 100644 --- a/oox/source/xls/worksheetsettings.cxx +++ b/oox/source/xls/worksheetsettings.cxx @@ -27,6 +27,7 @@ #include "oox/xls/worksheetsettings.hxx" #include +#include "properties.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/recordinputstream.hxx" #include "oox/xls/biffinputstream.hxx" @@ -293,6 +294,11 @@ void WorksheetSettings::importSheetProtection( BiffInputStream& rStrm ) maSheetProt.mbSelectUnlocked = !getFlag( nFlags, BIFF_SHEETPROT_SELECT_UNLOCKED ); } +void WorksheetSettings::importCodeName( BiffInputStream& rStrm ) +{ + maSheetSettings.maCodeName = rStrm.readUniString(); +} + void WorksheetSettings::importPhoneticPr( BiffInputStream& rStrm ) { maPhoneticSett.importPhoneticPr( rStrm ); @@ -300,6 +306,7 @@ void WorksheetSettings::importPhoneticPr( BiffInputStream& rStrm ) void WorksheetSettings::finalizeImport() { + // sheet protection if( maSheetProt.mbSheet ) try { Reference< XProtectable > xProtectable( getSheet(), UNO_QUERY_THROW ); @@ -308,6 +315,10 @@ void WorksheetSettings::finalizeImport() catch( Exception& ) { } + + // VBA code name + PropertySet aPropSet( getSheet() ); + aPropSet.setProperty( PROP_CodeName, maSheetSettings.maCodeName ); } // ============================================================================ diff --git a/oox/util/makefile.mk b/oox/util/makefile.mk index 3d3aba15dd2e..8bbf8a3650f2 100644 --- a/oox/util/makefile.mk +++ b/oox/util/makefile.mk @@ -68,7 +68,8 @@ SHL1STDLIBS= \ $(RTLLIB) \ $(SALLIB) \ $(BASEGFXLIB) \ - $(SAXLIB) + $(SAXLIB) \ + $(XMLSCRIPTLIB) # link openssl, copied this bit from ucb/source/ucp/webdav/makefile.mk .IF "$(GUI)"=="WNT" -- cgit From 1110315ea427c77a9ca630fc80d1f9e15242f29e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 19:14:53 +0200 Subject: npower13_objectmodules: compiler errors --- oox/inc/oox/helper/binarystreambase.hxx | 2 +- oox/source/dump/dffdumper.cxx | 6 +++--- oox/source/dump/oledumper.cxx | 20 ++++++++++---------- oox/source/helper/binarystreambase.cxx | 2 +- oox/source/ole/vbacontrol.cxx | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 5cebdc681e8d..abe4c5f1c274 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -69,7 +69,7 @@ public: inline void seekToEnd() { seek( getLength() ); } /** Seeks the stream forward to a position that is a multiple of the passed block size, relative to the passed stream position, if stream is seekable. */ - void align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); + void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); protected: inline explicit BinaryStreamBase() : mbEof( false ) {} diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 1b93d9b213c4..8730698561ce 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -138,10 +138,10 @@ void DffStreamObject::implDumpRecordBody() dumpDec< sal_uInt32 >( "shape-count" ); dumpDec< sal_uInt32 >( "drawing-count" ); mxOut->resetItemIndex( 1 ); - TableGuard aTabGuard( *mxOut, 15, 16 ); + TableGuard aTabGuard( mxOut, 15, 16 ); for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster ) { - MultiItemsGuard aMultiGuard( *mxOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#cluster" ); dumpDec< sal_uInt32 >( "drawing-id" ); dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" ); @@ -287,7 +287,7 @@ void DffStreamObject::dumpDffOpt() writeEmptyItem( "#complex-data" ); writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" ); mxOut->endMultiItems(); - IndentGuard aIndent( *mxOut ); + IndentGuard aIndent( mxOut ); switch( aIt->meType ) { case PROPTYPE_BINARY: diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index 9c3e00fdcf30..4e358801a513 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -1098,7 +1098,7 @@ sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const s return nDefault; } -sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) +sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) { if( startNextProperty() ) { @@ -1108,7 +1108,7 @@ sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) return nDefault; } -sal_Unicode OcxPropertyObjectBase::dumpUnicodeProperty() +sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty() { if( startNextProperty() ) { @@ -1783,11 +1783,11 @@ void VbaFormDesignExtObject::implDumpShortProperties() namespace { -const sal_uInt32 OCX_FORM_HASDESIGNEXTENDER = 0x00004000; -const sal_uInt32 OCX_FORM_SKIPCLASSTABLE = 0x00008000; +const sal_uInt32 AX_FORM_HASDESIGNEXTENDER = 0x00004000; +const sal_uInt32 AX_FORM_SKIPCLASSTABLE = 0x00008000; -const sal_uInt8 OCX_FORM_SITECOUNTTYPE_COUNT = 0x80; -const sal_uInt8 OCX_FORM_SITECOUNTTYPE_MASK = 0x7F; +const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT = 0x80; +const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK = 0x7F; } // namespace @@ -1841,7 +1841,7 @@ void VbaFStreamObject::implDumpExtended() void VbaFStreamObject::dumpClassInfos() { - if( ensureValid() && !getFlag( mnFlags, OCX_FORM_SKIPCLASSTABLE ) ) + if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) ) { mxOut->emptyLine(); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" ); @@ -1887,10 +1887,10 @@ void VbaFStreamObject::dumpSiteData() IndentGuard aIndGuard( mxOut ); dumpDec< sal_uInt8 >( "depth" ); sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" ); - if( getFlag( nTypeCount, OCX_FORM_SITECOUNTTYPE_COUNT ) ) + if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) ) { dumpDec< sal_uInt8 >( "repeated-type" ); - nSiteIdx += (nTypeCount & OCX_FORM_SITECOUNTTYPE_MASK); + nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK); } else { @@ -1906,7 +1906,7 @@ void VbaFStreamObject::dumpSiteData() void VbaFStreamObject::dumpDesignExtender() { - if( ensureValid() && getFlag( mnFlags, OCX_FORM_HASDESIGNEXTENDER ) ) + if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) ) { mxOut->emptyLine(); writeEmptyItem( "design-extender" ); diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index 86eae793a3c1..a8f9320ffc94 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -67,7 +67,7 @@ sal_Int64 BinaryStreamBase::getRemaining() const return ((nPos >= 0) && (nLen >= 0)) ? ::std::max< sal_Int64 >( nLen - nPos, 0 ) : -1; } -void BinaryStreamBase::align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) +void BinaryStreamBase::alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) { sal_Int64 nStrmPos = tell(); // nothing to do, if stream is at anchor position diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 2674c30d9a73..b43e8289a592 100755 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -525,7 +525,7 @@ bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) } } // align the stream to 32bit, relative to start of entire site info - rInStrm.align( 4, nAnchorPos ); + rInStrm.alignToBlock( 4, nAnchorPos ); // import the site models for all embedded controls maControls.clear(); -- cgit From dbd1daa7f89f25ca26a526207690789a351828d4 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 21:08:24 +0200 Subject: npower13_objectmodules: load vba after applying workbook codename --- oox/inc/oox/xls/workbookfragment.hxx | 3 --- oox/inc/oox/xls/workbookhelper.hxx | 7 +++---- oox/source/xls/workbookfragment.cxx | 23 ++++++----------------- oox/source/xls/workbookhelper.cxx | 32 ++++++++++++++++++++------------ 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index 0a4853748bf5..f9f0bb25c78f 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -92,9 +92,6 @@ private: bool importSheetFragment( ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int16 nCalcSheet ); - -private: - bool mbImportVbaProject; /// True = import VBA project at end of filter. }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 8a6f436bbaaf..0ff8c0f9d3e5 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -30,7 +30,7 @@ #include #include -//#include "oox/helper/storagebase.hxx" +#include "oox/helper/storagebase.hxx" #include "oox/xls/biffhelper.hxx" namespace com { namespace sun { namespace star { @@ -113,7 +113,6 @@ class UnitConverter; class AddressConverter; class ExcelChartConverter; class PageSettingsConverter; -class VbaProject; class BiffCodecHelper; /** Helper class to provice access to global workbook data. @@ -151,6 +150,8 @@ public: /** Sets the index of the current sheet in the Calc document. */ void setCurrentSheetIndex( sal_Int16 nSheet ); + /** Sets the VBA project storage. */ + void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ); /** Final conversion after importing the workbook. */ void finalizeWorkbookImport(); @@ -255,8 +256,6 @@ public: ExcelChartConverter& getChartConverter() const; /** Returns the page and print settings converter. */ PageSettingsConverter& getPageSettingsConverter() const; - /** Returns the VBA project used to import/export VBA and attach events. */ - VbaProject& getVbaProject() const; // OOX specific (MUST NOT be called in BIFF filter) ----------------------- diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index b5eb9a11dd2c..d64abf268008 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -37,7 +37,6 @@ #include "oox/xls/biffinputstream.hxx" #include "oox/xls/chartsheetfragment.hxx" #include "oox/xls/connectionsfragment.hxx" -#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/externallinkfragment.hxx" #include "oox/xls/pivotcachebuffer.hxx" @@ -295,16 +294,13 @@ void OoxWorkbookFragment::finalizeImport() aIt->clear(); } - // import the VBA project (after loading the sheets, as they have imported the code names) + // open the VBA project storage OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATIONSTYPE( "vbaProject" ) ); if( aVbaFragmentPath.getLength() > 0 ) { Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath ); if( xInStrm.is() ) - { - ::oox::ole::OleStorage aVbaStrg( getGlobalFactory(), xInStrm, false ); - getVbaProject().importVbaProject( aVbaStrg, getBaseFilter().getGraphicHelper() ); - } + setVbaProjectStorage( StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), xInStrm, false ) ) ); } // final conversions, e.g. calculation settings and view settings @@ -360,8 +356,7 @@ void OoxWorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, s // ============================================================================ BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper, const OUString& rStrmName ) : - BiffWorkbookFragmentBase( rHelper, rStrmName ), - mbImportVbaProject( false ) + BiffWorkbookFragmentBase( rHelper, rStrmName ) { } @@ -389,13 +384,6 @@ bool BiffWorkbookFragment::importFragment() sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet ); bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nCalcSheet ); } - // import the VBA project (after loading the sheets, as they have imported the code names) - if( mbImportVbaProject ) - { - StorageRef xVbaStrg = getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ); - if( xVbaStrg.get() ) - getVbaProject().importVbaProject( *xVbaStrg, getBaseFilter().getGraphicHelper() ); - } } break; @@ -646,8 +634,9 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress bRet = mrStrm.startRecordByHandle( nEofHandle ); } - // import the VBA project - mbImportVbaProject = bHasVbaProject && !bEmptyVbaProject; + // open the VBA project storage + if( bHasVbaProject && !bEmptyVbaProject ) + setVbaProjectStorage( getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ) ); // #i56376# missing EOF - rewind before worksheet BOF record (see above) if( bRet && isBofRecord() ) diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index 9794b58e6a1b..afeed95accca 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -136,6 +136,10 @@ public: inline sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; } /** Sets the index of the current sheet in the Calc document. */ inline void setCurrentSheetIndex( sal_Int16 nSheet ) { mnCurrSheet = nSheet; } + /** Returns the VBA project storage. */ + inline StorageRef getVbaProjectStorage() const { return mxVbaPrjStrg; } + /** Sets the VBA project storage. */ + inline void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; } // document model --------------------------------------------------------- @@ -201,8 +205,6 @@ public: inline ExcelChartConverter& getChartConverter() const { return *mxChartConverter; } /** Returns the page/print settings converter. */ inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; } - /** Returns the VBA project used to import/export VBA and attach events. */ - inline VbaProject& getVbaProject() const { return *mxVbaProject; } // OOX specific ----------------------------------------------------------- @@ -256,7 +258,6 @@ private: typedef ::std::auto_ptr< AddressConverter > AddressConvPtr; typedef ::std::auto_ptr< ExcelChartConverter > ExcelChartConvPtr; typedef ::std::auto_ptr< PageSettingsConverter > PageSettConvPtr; - typedef ::std::auto_ptr< VbaProject > VbaProjectPtr; typedef ::std::auto_ptr< BiffCodecHelper > BiffCodecHelperPtr; OUString maCellStyles; /// Style family name for cell styles. @@ -268,6 +269,7 @@ private: ExcelFilterBase& mrExcelBase; /// Base object for registration of this structure. FilterType meFilterType; /// File type of the filter. ProgressBarPtr mxProgressBar; /// The progress bar. + StorageRef mxVbaPrjStrg; /// Storage containing the VBA project. sal_Int16 mnCurrSheet; /// Current sheet index in Calc dcument. bool mbWorkbook; /// True = multi-sheet file. @@ -292,7 +294,6 @@ private: AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter. ExcelChartConvPtr mxChartConverter; /// Chart object converter. PageSettConvPtr mxPageSettConverter; /// Page/print settings converter. - VbaProjectPtr mxVbaProject; /// VBA project. // OOX specific XmlFilterBase* mpOoxFilter; /// Base OOX filter object. @@ -549,7 +550,6 @@ void WorkbookData::initialize( bool bWorkbookFile ) mxAddrConverter.reset( new AddressConverter( *this ) ); mxChartConverter.reset( new ExcelChartConverter( *this ) ); mxPageSettConverter.reset( new PageSettingsConverter( *this ) ); - mxVbaProject.reset( new VbaProject( mrBaseFilter.getGlobalFactory(), mxDoc ) ); // set some document properties needed during import if( mrBaseFilter.isImportFilter() ) @@ -659,6 +659,11 @@ void WorkbookHelper::setCurrentSheetIndex( sal_Int16 nSheet ) mrBookData.setCurrentSheetIndex( nSheet ); } +void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) +{ + mrBookData.setVbaProjectStorage( rxVbaPrjStrg ); +} + void WorkbookHelper::finalizeWorkbookImport() { // workbook settings, document and sheet view settings @@ -681,8 +686,16 @@ void WorkbookHelper::finalizeWorkbookImport() PropertySet aDefPageStyle( getStyleObject( CREATE_OUSTRING( "Default" ), true ) ); aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); - // attach VBA macros to document and sheet events - getVbaProject().attachToEvents(); + /* Import the VBA project (after finalizing workbook settings which + contains the workbook code name), and attach VBA macros to document and + sheet events. */ + StorageRef xVbaPrjStrg = mrBookData.getVbaProjectStorage(); + if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() ) + { + VbaProject aVbaProject( getGlobalFactory(), getDocument() ); + aVbaProject.importVbaProject( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() ); + aVbaProject.attachToEvents(); + } } // document model ------------------------------------------------------------- @@ -892,11 +905,6 @@ PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const return mrBookData.getPageSettingsConverter(); } -VbaProject& WorkbookHelper::getVbaProject() const -{ - return mrBookData.getVbaProject(); -} - // OOX specific --------------------------------------------------------------- XmlFilterBase& WorkbookHelper::getOoxFilter() const -- cgit From 0f0f6396110e83a99f979a37f0cfe3e11ec6faa6 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 14 Apr 2010 20:47:35 +0100 Subject: npower13_objectmodules: fix order of XModuleInfo/Module creation order --- oox/source/ole/vbamodule.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index b5319672d538..ff4c37e93b88 100755 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -214,24 +214,24 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, if( !mbExecutable ) aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) ); - // insert the module into the passed Basic library + // insert extended module info try { - rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); + Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); + xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); } catch( Exception& ) { - OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); } - // insert extended module info + // insert the module into the passed Basic library try { - Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); - xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); + rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); } catch( Exception& ) { + OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); } } -- cgit From dc295f1cf1c99b2dbe0760c7542a92febb33a27d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Apr 2010 19:46:12 +0200 Subject: npower13_objectmodules: would be a good idea to really seek the wrapped stream... --- oox/source/helper/binaryinputstream.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 9ca6938f2ff1..a5a3cf9a2c30 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -321,6 +321,7 @@ void RelativeInputStream::skip( sal_Int32 nBytes ) if( !mbEof ) { sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + mrInStrm.skip( nSkipBytes ); mnRelPos += nSkipBytes; mbEof = nSkipBytes < nBytes; } -- cgit From 02f50ebfc8097e6bebb607b9faa82f3baff0421e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 14:47:11 +0200 Subject: npower13_objectmodules: use document frame from media descriptor --- oox/inc/oox/core/filterbase.hxx | 5 +++++ oox/inc/oox/helper/graphichelper.hxx | 4 +++- oox/source/core/filterbase.cxx | 10 +++++++++- oox/source/helper/graphichelper.cxx | 28 ++++++++++++++++++++-------- oox/source/ppt/pptimport.cxx | 2 +- oox/source/xls/stylesbuffer.cxx | 2 +- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index b2709ea4b33b..31e26d38f590 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -49,6 +49,7 @@ namespace com { namespace sun { namespace star { namespace frame { class XModel; } namespace task { class XStatusIndicator; } namespace task { class XInteractionHandler; } + namespace frame { class XFrame; } namespace io { class XInputStream; } namespace io { class XOutputStream; } namespace io { class XStream; } @@ -123,6 +124,10 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getModelFactory() const; + /** Returns the frame that will contain the document model. */ + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& + getTargetFrame() const; + /** Returns the status indicator (may be null). */ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& getStatusIndicator() const; diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index dc9dddfea7e8..2d0964b37715 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -40,6 +40,7 @@ namespace com { namespace sun { namespace star { namespace awt { struct Size; } namespace awt { class XUnitConversion; } namespace io { class XInputStream; } + namespace frame { class XFrame; } namespace graphic { class XGraphic; } namespace graphic { class XGraphicObject; } namespace graphic { class XGraphicProvider; } @@ -66,7 +67,8 @@ class GraphicHelper { public: explicit GraphicHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory ); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxTargetFrame ); virtual ~GraphicHelper(); /** Returns a system color specified by the passed XML token identifier. */ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 27a1b26fbcfd..902784cafe80 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -55,6 +55,7 @@ using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::XComponent; using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::frame::XFrame; using ::com::sun::star::frame::XModel; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; @@ -148,6 +149,7 @@ struct FilterBaseImpl Reference< XMultiServiceFactory > mxGlobalFactory; Reference< XModel > mxModel; Reference< XMultiServiceFactory > mxModelFactory; + Reference< XFrame > mxTargetFrame; Reference< XInputStream > mxInStream; Reference< XStream > mxOutStream; Reference< XStatusIndicator > mxStatusIndicator; @@ -261,6 +263,11 @@ const Reference< XMultiServiceFactory >& FilterBase::getModelFactory() const return mxImpl->mxModelFactory; } +const Reference< XFrame >& FilterBase::getTargetFrame() const +{ + return mxImpl->mxTargetFrame; +} + const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const { return mxImpl->mxStatusIndicator; @@ -572,6 +579,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc } mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() ); + mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() ); mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() ); mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() ); } @@ -579,7 +587,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc GraphicHelper* FilterBase::implCreateGraphicHelper() const { // default: return base implementation without any special behaviour - return new GraphicHelper( mxImpl->mxGlobalFactory ); + return new GraphicHelper( mxImpl->mxGlobalFactory, mxImpl->mxTargetFrame ); } // ============================================================================ diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 6e57ac8f2b2f..6b294f61abef 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -76,7 +76,7 @@ inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm // ============================================================================ -GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory ) : +GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XFrame >& rxTargetFrame ) : mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) ) { @@ -115,21 +115,34 @@ GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalF maSystemPalette[ XML_windowFrame ] = 0x000000; maSystemPalette[ XML_windowText ] = 0x000000; - // get the metric of the output device - if( rxGlobalFactory.is() ) try + // if no target frame has been passed (e.g. OLE objects), try to fallback to the active frame + // TODO: we need some mechanism to keep and pass the parent frame + Reference< XFrame > xFrame = rxTargetFrame; + if( !xFrame.is() && rxGlobalFactory.is() ) try { Reference< XFramesSupplier > xFramesSupp( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); - Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); + xFrame = xFramesSupp->getActiveFrame(); + } + catch( Exception& ) + { + } + + // get the metric of the output device + OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" ); + maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case + if( xFrame.is() ) try + { Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); mxUnitConversion.set( xDevice, UNO_QUERY ); + OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" ); maDeviceInfo = xDevice->getInfo(); - mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; - mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; } catch( Exception& ) { OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); } + mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; + mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; } GraphicHelper::~GraphicHelper() @@ -138,8 +151,7 @@ GraphicHelper::~GraphicHelper() sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const { - const sal_Int32* pnColor = ContainerHelper::getMapElement( maSystemPalette, nToken ); - return pnColor ? *pnColor : nDefaultRgb; + return ContainerHelper::getMapElement( maSystemPalette, nToken, nDefaultRgb ); } sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 578d469395db..39ad52316a92 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -163,7 +163,7 @@ private: }; PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : - GraphicHelper( rFilter.getGlobalFactory() ), + GraphicHelper( rFilter.getGlobalFactory(), rFilter.getTargetFrame() ), mrFilter( rFilter ) { } diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index e18f47a378ed..e48104065315 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -305,7 +305,7 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) // ============================================================================ ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) : - GraphicHelper( rHelper.getGlobalFactory() ), + GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame() ), WorkbookHelper( rHelper ) { } -- cgit From d66af9e10fa0f8fcf82b7c06dac789b5e5f4910b Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- filter/source/msfilter/msvbasic.cxx | 14 ++++++++------ filter/source/msfilter/msvbasic.hxx | 7 +------ filter/source/msfilter/svxmsbas.cxx | 19 ++++++++++--------- oox/source/ole/vbamodule.cxx | 22 +++++++++++----------- oox/source/ole/vbaproject.cxx | 14 +++++++------- 5 files changed, 37 insertions(+), 39 deletions(-) diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx index 8a87c70f19d0..be8ee6bd30e5 100644 --- a/filter/source/msfilter/msvbasic.cxx +++ b/filter/source/msfilter/msvbasic.cxx @@ -38,6 +38,8 @@ #include //rtl_getTextEncodingFromWindowsCodePage #include "msvbasic.hxx" +#include + using namespace ::com::sun::star::script; /* @@ -439,7 +441,7 @@ ModType VBA_Impl::GetModuleType( const UniString& rModuleName ) { return iter->second; } - return ModuleType::Unknown; + return ModuleType::UNKNOWN; } bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) @@ -482,7 +484,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) ); static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) ); static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) ); - mhModHash[ sThisDoc ] = ModuleType::Class; + mhModHash[ sThisDoc ] = ModuleType::CLASS; while ( pStp->ReadByteStringLine( tmp, meCharSet ) ) { xub_StrLen index = tmp.Search( '=' ); @@ -492,14 +494,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) String value = tmp.Copy( index + 1 ); if ( key == sClass ) { - mhModHash[ value ] = ModuleType::Class; + mhModHash[ value ] = ModuleType::CLASS; OSL_TRACE("Module %s is of type Class", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sBaseClass ) { - mhModHash[ value ] = ModuleType::Form; + mhModHash[ value ] = ModuleType::FORM; OSL_TRACE("Module %s is of type Form", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); @@ -512,14 +514,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) // value is of form /&H, strip the identifier value.Erase( value.Search( '/' ) ); - mhModHash[ value ] = ModuleType::Document; + mhModHash[ value ] = ModuleType::DOCUMENT; OSL_TRACE("Module %s is of type Document VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sModule ) { - mhModHash[ value ] = ModuleType::Normal; + mhModHash[ value ] = ModuleType::NORMAL; OSL_TRACE("Module %s is of type Normal VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); diff --git a/filter/source/msfilter/msvbasic.hxx b/filter/source/msfilter/msvbasic.hxx index ed77b34c4f48..171671e8cd5c 100644 --- a/filter/source/msfilter/msvbasic.hxx +++ b/filter/source/msfilter/msvbasic.hxx @@ -30,17 +30,12 @@ #ifndef _MSVBASIC_HXX #define _MSVBASIC_HXX -#ifdef _SOLAR_H #include -#endif #include #include #include -#ifndef __SGI_STL_VECTOR #include -#endif -#include -#include +#include /* class VBA: * The VBA class provides a set of methods to handle Visual Basic For diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 3b32b951c16a..55465850d8c8 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -51,6 +51,7 @@ using namespace com::sun::star::awt; #include #include #include +#include #include #include @@ -332,23 +333,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, switch( mType ) { - case ModuleType::Class: + case ModuleType::CLASS: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) ); break; - case ModuleType::Form: + case ModuleType::FORM: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) ); break; - case ModuleType::Document: + case ModuleType::DOCUMENT: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) ); break; - case ModuleType::Normal: + case ModuleType::NORMAL: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) ); break; - case ModuleType::Unknown: + case ModuleType::UNKNOWN: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) ); break; @@ -360,7 +361,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, if ( !bAsComment ) { modeTypeComment = modeTypeComment + sVBAOption; - if ( mType == ModuleType::Class ) + if ( mType == ModuleType::CLASS ) modeTypeComment = modeTypeComment + sClassOption; } @@ -443,7 +444,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, for ( std::vector< String >::const_iterator it = codeNames.begin(); it != codeNames.end(); ++it ) { script::ModuleInfo sModuleInfo; - sModuleInfo.ModuleType = ModuleType::Document; + sModuleInfo.ModuleType = ModuleType::DOCUMENT; moduleInfos[ *it ] = sModuleInfo; moduleData[ *it ] = uno::makeAny( sVBAOption ); } @@ -455,13 +456,13 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, if ( it_info != moduleInfos.end() ) { ModuleInfo& sModuleInfo = it_info->second; - if ( sModuleInfo.ModuleType == ModuleType::Form ) + if ( sModuleInfo.ModuleType == ModuleType::FORM ) // hack, the module ( imo document basic should... // know the XModel... ) but it doesn't sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY ); // document modules, we should be able to access // the api objects at this time - else if ( sModuleInfo.ModuleType == ModuleType::Document ) + else if ( sModuleInfo.ModuleType == ModuleType::DOCUMENT ) { if ( xVBACodeNamedObjectAccess.is() ) { diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index ff4c37e93b88..e9388e54215a 100755 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -60,7 +60,7 @@ VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rNa mxDocModel( rxDocModel ), maName( rName ), meTextEnc( eTextEnc ), - mnType( ApiModuleType::Unknown ), + mnType( ApiModuleType::UNKNOWN ), mnOffset( SAL_MAX_UINT32 ), mbReadOnly( false ), mbPrivate( false ), @@ -107,13 +107,13 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) break; case VBA_ID_MODULETYPEPROCEDURAL: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::Normal; + OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::NORMAL; break; case VBA_ID_MODULETYPEDOCUMENT: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::Document; + OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::DOCUMENT; break; case VBA_ID_MODULEREADONLY: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); @@ -130,7 +130,7 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) } OSL_ENSURE( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" ); OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream name" ); - OSL_ENSURE( mnType != ApiModuleType::Unknown, "VbaModule::importDirRecords - missing module type" ); + OSL_ENSURE( mnType != ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - missing module type" ); OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" ); } @@ -155,18 +155,18 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); switch( mnType ) { - case ApiModuleType::Normal: + case ApiModuleType::NORMAL: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); break; - case ApiModuleType::Class: + case ApiModuleType::CLASS: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); break; - case ApiModuleType::Form: + case ApiModuleType::FORM: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); // hack from old filter, document Basic should know the XModel, but it doesn't aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); break; - case ApiModuleType::Document: + case ApiModuleType::DOCUMENT: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); // get the VBA object associated to the document module if( rxDocObjectNA.is() ) try @@ -184,7 +184,7 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, if( mbExecutable ) { aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); - if( mnType == ApiModuleType::Class ) + if( mnType == ApiModuleType::CLASS ) aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); } else diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index 92a556d8b885..a370fb3d168e 100755 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -394,23 +394,23 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) { - sal_Int32 nType = ApiModuleType::Unknown; + sal_Int32 nType = ApiModuleType::UNKNOWN; if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) { - nType = ApiModuleType::Document; + nType = ApiModuleType::DOCUMENT; // strip automation server version from module names sal_Int32 nSlashPos = aValue.indexOf( '/' ); if( nSlashPos >= 0 ) aValue = aValue.copy( 0, nSlashPos ); } else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) - nType = ApiModuleType::Normal; + nType = ApiModuleType::NORMAL; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) - nType = ApiModuleType::Class; + nType = ApiModuleType::CLASS; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) - nType = ApiModuleType::Form; + nType = ApiModuleType::FORM; - if( (nType != ApiModuleType::Unknown) && (aValue.getLength() > 0) ) + if( (nType != ApiModuleType::UNKNOWN) && (aValue.getLength() > 0) ) { OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" ); if( VbaModule* pModule = aModules.get( aValue ).get() ) @@ -475,7 +475,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap { // resolve module name from storage name (which equals the module stream name) VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); - OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::Form), + OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::FORM), "VbaProject::importVba - form substorage without form module" ); OUString aModuleName; if( pModule ) -- cgit From a5858e6d95685ee5f54b0879b42529c3df49ee83 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 19:03:55 +0200 Subject: npower13_objectmodules: solaris compiler warning --- oox/source/ole/olehelper.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 68ae8c90802e..0a0796e15a7e 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -147,7 +147,6 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, { case OLE_COLORTYPE_CLIENT: return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); - break; case OLE_COLORTYPE_PALETTE: return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); -- cgit From ac07edec79149c8e90846b8a794a893e91c65c0d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 17 May 2010 14:10:13 +0200 Subject: npower13_objectmodules: #i111007# do not close output stream of tempfile for OLE storage too early --- oox/source/dump/oledumper.cxx | 2 +- oox/source/ole/olestorage.cxx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index 4e358801a513..cc49ee050ea6 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -942,7 +942,7 @@ void ComCtlTreeViewObject::implDumpProperties() mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" ); } -void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 nEndPos ) +void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) { dumpOleColor( "text-color" ); dumpOleColor( "back-color" ); diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx index 39ecbb84a062..0ca2992d47ad 100755 --- a/oox/source/ole/olestorage.cxx +++ b/oox/source/ole/olestorage.cxx @@ -252,8 +252,11 @@ void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); { Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW ); - BinaryXOutputStream aOutStrm( xOutStrm, true ); // true = close output stream on destruction of aOutStrm - BinaryXInputStream aInStrm( xInStrm, false ); // false = do not close intput stream on destruction of aInStrm + /* Pass false to both binary stream objects to keep the UNO + streams alive. Life time of these streams is controlled by the + tempfile implementation. */ + BinaryXOutputStream aOutStrm( xOutStrm, false ); + BinaryXInputStream aInStrm( xInStrm, false ); aInStrm.copyToStream( aOutStrm ); } // scope closes output stream of tempfile xInStrm = xTempFile->getInputStream(); -- cgit