diff options
258 files changed, 9860 insertions, 6970 deletions
diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx index 5c62c347fbdd..720a6efd2182 100644 --- a/basic/inc/basic/basmgr.hxx +++ b/basic/inc/basic/basmgr.hxx @@ -237,6 +237,13 @@ public: */ bool LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames ); + /// determines whether the Basic Manager has a given macro, given by fully qualified name + bool HasMacro( String const& i_fullyQualifiedName ) const; + /// executes a given macro + ErrCode ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ); + /// executes a given macro + ErrCode ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ); + private: BOOL IsReference( USHORT nLib ); diff --git a/basic/inc/pch/precompiled_basic.hxx b/basic/inc/pch/precompiled_basic.hxx index e8f9e004ca6a..ae45c383c74d 100644 --- a/basic/inc/pch/precompiled_basic.hxx +++ b/basic/inc/pch/precompiled_basic.hxx @@ -272,7 +272,7 @@ #include "vcl/timer.hxx" #include "vcl/toolbox.hxx" #include "vcl/window.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vcl/wrkwin.hxx" #include "vos/diagnose.hxx" diff --git a/basic/source/app/appedit.cxx b/basic/source/app/appedit.cxx index d5769f3acb31..a969d227395c 100644 --- a/basic/source/app/appedit.cxx +++ b/basic/source/app/appedit.cxx @@ -201,8 +201,8 @@ long AppEdit::InitMenu( Menu* pMenu ) if( pDataEdit ) { - USHORT UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount(); - USHORT RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount(); + size_t UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount(); + size_t RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount(); pMenu->EnableItem( RID_EDITUNDO, UndoCount > 0 ); pMenu->EnableItem( RID_EDITREDO, RedoCount > 0 ); diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index a5a1d4c8ca12..695f57ff2e02 100644 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -507,6 +507,13 @@ namespace basic // register as listener for the BasicManager being destroyed StartListening( *_out_rpBasicManager ); + + // #i104876: Library container must not be modified just after + // creation. This happens as side effect when creating default + // "Standard" libraries and needs to be corrected here + xBasicLibs->setModified( sal_False ); + xDialogLibs->setModified( sal_False ); + } //-------------------------------------------------------------------- diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 84763468e64c..a491b957fef6 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -42,6 +42,8 @@ #include <tools/diagnose_ex.h> #include <basic/sbmod.hxx> #include <basic/sbobjmod.hxx> +#include <unotools/intlwrapper.hxx> +#include <comphelper/processfactory.hxx> #include <basic/sbuno.hxx> #include <basic/basmgr.hxx> @@ -1868,6 +1870,116 @@ bool BasicManager::LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequen return false; } + +namespace +{ + SbMethod* lcl_queryMacro( BasicManager* i_manager, String const& i_fullyQualifiedName ) + { + sal_uInt16 nLast = 0; + String sMacro = i_fullyQualifiedName; + String sLibName = sMacro.GetToken( 0, '.', nLast ); + String sModule = sMacro.GetToken( 0, '.', nLast ); + sMacro.Erase( 0, nLast ); + + IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); + const CollatorWrapper* pCollator = aIntlWrapper.getCollator(); + sal_uInt16 nLibCount = i_manager->GetLibCount(); + for ( sal_uInt16 nLib = 0; nLib < nLibCount; ++nLib ) + { + if ( COMPARE_EQUAL == pCollator->compareString( i_manager->GetLibName( nLib ), sLibName ) ) + { + StarBASIC* pLib = i_manager->GetLib( nLib ); + if( !pLib ) + { + i_manager->LoadLib( nLib ); + pLib = i_manager->GetLib( nLib ); + } + + if( pLib ) + { + sal_uInt16 nModCount = pLib->GetModules()->Count(); + for( sal_uInt16 nMod = 0; nMod < nModCount; ++nMod ) + { + SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod ); + if ( pMod && COMPARE_EQUAL == pCollator->compareString( pMod->GetName(), sModule ) ) + { + SbMethod* pMethod = (SbMethod*)pMod->Find( sMacro, SbxCLASS_METHOD ); + if( pMethod ) + return pMethod; + } + } + } + } + } + return 0; + } +} + +bool BasicManager::HasMacro( String const& i_fullyQualifiedName ) const +{ + return ( NULL != lcl_queryMacro( const_cast< BasicManager* >( this ), i_fullyQualifiedName ) ); +} + +ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ) +{ + SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); + ErrCode nError = 0; + if ( pMethod ) + { + if ( i_arguments ) + pMethod->SetParameters( i_arguments ); + nError = pMethod->Call( i_retValue ); + } + else + nError = ERRCODE_BASIC_PROC_UNDEFINED; + return nError; +} + +ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ) +{ + SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); + if ( !pMethod ) + return ERRCODE_BASIC_PROC_UNDEFINED; + + // arguments must be quoted + String sQuotedArgs; + String sArgs( i_commaSeparatedArgs ); + if ( sArgs.Len()<2 || sArgs.GetBuffer()[1] == '\"') + // no args or already quoted args + sQuotedArgs = sArgs; + else + { + // quote parameters + sArgs.Erase( 0, 1 ); + sArgs.Erase( sArgs.Len()-1, 1 ); + + sQuotedArgs = '('; + + sal_uInt16 nCount = sArgs.GetTokenCount(','); + for ( sal_uInt16 n=0; n<nCount; ++n ) + { + sQuotedArgs += '\"'; + sQuotedArgs += sArgs.GetToken( n, ',' ); + sQuotedArgs += '\"'; + if ( n<nCount-1 ) + sQuotedArgs += ','; + } + + sQuotedArgs += ')'; + } + + // add quoted arguments and do the call + String sCall( '[' ); + sCall += pMethod->GetName(); + sCall += sQuotedArgs; + sCall += ']'; + + SbxVariable* pRet = pMethod->GetParent()->Execute( sCall ); + if ( pRet ) + *i_retValue = *pRet; + return SbxBase::GetError(); +} + //===================================================================== class ModuleInfo_Impl : public ModuleInfoHelper diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index e176eb9e3654..51a93ce94e4a 100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -1297,6 +1297,30 @@ Any sbxToUnoValue( SbxVariable* pVar ) return sbxToUnoValueImpl( pVar ); } + +// Funktion, um einen globalen Bezeichner im +// UnoScope zu suchen und fuer Sbx zu wrappen +static bool implGetTypeByName( const String& rName, Type& rRetType ) +{ + bool bSuccess = false; + + Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl(); + if( xTypeAccess->hasByHierarchicalName( rName ) ) + { + Any aRet = xTypeAccess->getByHierarchicalName( rName ); + Reference< XTypeDescription > xTypeDesc; + aRet >>= xTypeDesc; + + if( xTypeDesc.is() ) + { + rRetType = Type( xTypeDesc->getTypeClass(), xTypeDesc->getName() ); + bSuccess = true; + } + } + return bSuccess; +} + + // Konvertierung von Sbx nach Uno mit bekannter Zielklasse Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty ) { @@ -1387,6 +1411,39 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty } break; + case TypeClass_TYPE: + { + if( eBaseType == SbxOBJECT ) + { + // XIdlClass? + Reference< XIdlClass > xIdlClass; + + SbxBaseRef pObj = (SbxBase*)pVar->GetObject(); + if( pObj && pObj->ISA(SbUnoObject) ) + { + Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny(); + aUnoAny >>= xIdlClass; + } + + if( xIdlClass.is() ) + { + ::rtl::OUString aClassName = xIdlClass->getName(); + Type aType( xIdlClass->getTypeClass(), aClassName.getStr() ); + aRetVal <<= aType; + } + } + else if( eBaseType == SbxSTRING ) + { + // String representing type? + String aTypeName = pVar->GetString(); + Type aType; + bool bSuccess = implGetTypeByName( aTypeName, aType ); + if( bSuccess ) + aRetVal <<= aType; + } + } + break; + /* folgende Typen lassen wir erstmal weg case TypeClass_SERVICE: break; case TypeClass_CLASS: break; @@ -4237,6 +4294,8 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ) (void)pBasic; (void)bWrite; + static String aTypeTypeString( RTL_CONSTASCII_USTRINGPARAM("type") ); + // 2 parameters needed if ( rPar.Count() != 3 ) { @@ -4248,6 +4307,41 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ) String aTypeName = rPar.Get(1)->GetString(); SbxVariable* pVal = rPar.Get(2); + if( aTypeName == aTypeTypeString ) + { + SbxDataType eBaseType = pVal->SbxValue::GetType(); + String aValTypeName; + if( eBaseType == SbxSTRING ) + { + aValTypeName = pVal->GetString(); + } + else if( eBaseType == SbxOBJECT ) + { + // XIdlClass? + Reference< XIdlClass > xIdlClass; + + SbxBaseRef pObj = (SbxBase*)pVal->GetObject(); + if( pObj && pObj->ISA(SbUnoObject) ) + { + Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny(); + aUnoAny >>= xIdlClass; + } + + if( xIdlClass.is() ) + aValTypeName = xIdlClass->getName(); + } + Type aType; + bool bSuccess = implGetTypeByName( aValTypeName, aType ); + if( bSuccess ) + { + Any aTypeAny( aType ); + SbxVariableRef refVar = rPar.Get(0); + SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny ); + refVar->PutObject( xUnoAnyObject ); + } + return; + } + // Check the type Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl(); Any aRet; diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr.cxx index 04f1ee0a8acc..dbef947f4e94 100644 --- a/basic/source/runtime/dllmgr.cxx +++ b/basic/source/runtime/dllmgr.cxx @@ -206,7 +206,8 @@ SbError marshalString( return e; } std::vector< char > * blob = data.newBlob(); - blob->insert(blob->begin(), str.getStr(), str.getStr() + str.getLength()); + blob->insert( + blob->begin(), str.getStr(), str.getStr() + str.getLength() + 1); *buffer = address(*blob); data.unmarshalStrings.push_back(StringData(variable, *buffer, special)); return ERRCODE_NONE; diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 97f6ed227d47..cfd84567644a 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -37,7 +37,7 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/sound.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/msgbox.hxx> #include <basic/sbx.hxx> #include <svl/zforlist.hxx> diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 8eb4dd3cc25b..b64327bd7232 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -65,6 +65,8 @@ class Desktop : public Application { friend class UserInstall; + void doShutdown(); + public: enum BootstrapError { diff --git a/desktop/scripts/unopkg.sh b/desktop/scripts/unopkg.sh index 77172e549534..5020b89194d1 100644 --- a/desktop/scripts/unopkg.sh +++ b/desktop/scripts/unopkg.sh @@ -44,16 +44,27 @@ cd "$sd_cwd" #collect all bootstrap variables specified on the command line #so that they can be passed as arguments to javaldx later on +#Recognize the "sync" option. sync must be applied without any other +#options except bootstrap variables or the verbose option for arg in $@ do case "$arg" in -env:*) BOOTSTRAPVARS=$BOOTSTRAPVARS" ""$arg";; + sync) OPTSYNC=true;; + -v) VERBOSE=true;; + --verbose) VERBOSE=true;; + *) OPTOTHER=$arg;; esac done +if [ "$OPTSYNC" = "true" ] && [ -z "$OPTOTHER" ] +then + JVMFWKPARAMS='-env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml -env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1' +fi + # extend the ld_library_path for java: javaldx checks the sofficerc for us if [ -x "$sd_prog/../basis-link/ure-link/bin/javaldx" ] ; then - my_path=`"$sd_prog/../basis-link/ure-link/bin/javaldx" $BOOTSTRAPVARS \ + my_path=`"$sd_prog/../basis-link/ure-link/bin/javaldx" $BOOTSTRAPVARS $JVMFWKPARAMS \ "-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc"` if [ -n "$my_path" ] ; then LD_LIBRARY_PATH=$my_path${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} @@ -70,6 +81,6 @@ unset XENVIRONMENT # SAL_NO_XINITTHREADS=true; export SAL_NO_XINITTHREADS # execute binary -exec "$sd_prog/unopkg.bin" "$@" \ +exec "$sd_prog/unopkg.bin" "$@" "$JVMFWKPARAMS" \ "-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc" diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index a49cabc90bed..82af26653b84 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -202,6 +202,7 @@ static const ::rtl::OUString CFG_PATH_REG ( RTL_CONSTASCII_USTRINGP static const ::rtl::OUString CFG_ENTRY_REGURL ( RTL_CONSTASCII_USTRINGPARAM( "URL" )); static const ::rtl::OUString CFG_ENTRY_TEMPLATEREGURL ( RTL_CONSTASCII_USTRINGPARAM( "TemplateURL" )); +static ::rtl::OUString getBrandSharePreregBundledPathURL(); // ---------------------------------------------------------------------------- ResMgr* Desktop::GetDesktopResManager() @@ -578,6 +579,44 @@ static ::rtl::OUString getLastSyncFileURLFromUserInstallation() return aTmp.makeStringAndClear(); } +//Checks if the argument src is the folder of the help or configuration +//backend in the prereg folder +static bool excludeTmpFilesAndFolders(const rtl::OUString & src) +{ + const char helpBackend[] = "com.sun.star.comp.deployment.help.PackageRegistryBackend"; + const char configBackend[] = "com.sun.star.comp.deployment.configuration.PackageRegistryBackend"; + if (src.endsWithAsciiL(helpBackend, sizeof(helpBackend) - 1 ) + || src.endsWithAsciiL(configBackend, sizeof(configBackend) - 1)) + { + return true; + } + return false; +} + +//If we are about to copy the contents of some special folder as determined +//by excludeTmpFilesAndFolders, then we omit those files or folders with a name +//derived from temporary folders. +static bool isExcludedFileOrFolder( const rtl::OUString & name) +{ + char const * allowed[] = { + "backenddb.xml", + "configmgr.ini", + "registered_packages.db" + }; + + const unsigned int size = sizeof(allowed) / sizeof (char const *); + bool bExclude = true; + for (unsigned int i= 0; i < size; i ++) + { + ::rtl::OUString allowedName = ::rtl::OUString::createFromAscii(allowed[i]); + if (allowedName.equals(name)) + { + bExclude = false; + break; + } + } + return bExclude; +} static osl::FileBase::RC copy_bundled_recursive( const rtl::OUString& srcUnqPath, @@ -605,6 +644,7 @@ throw() sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type; osl::DirectoryItem aDirItem; + bool bExcludeFiles = excludeTmpFilesAndFolders(srcUnqPath); while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None ) { @@ -634,7 +674,12 @@ throw() // Special treatment for "lastsychronized" file. Must not be // copied from the bundled folder! - if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName )) + //Also do not copy *.tmp files and *.tmp_ folders. This affects the files/folders + //from the help and configuration backend + if ( IsDoc && (aFileName.equalsAscii( pLastSyncFileName ) + || bExcludeFiles && isExcludedFileOrFolder(aFileName))) + bFilter = true; + else if (!IsDoc && bExcludeFiles && isExcludedFileOrFolder(aFileName)) bFilter = true; } @@ -1486,8 +1531,26 @@ void Desktop::AppEvent( const ApplicationEvent& rAppEvent ) HandleAppEvent( rAppEvent ); } +struct ExecuteGlobals +{ + Reference < css::document::XEventListener > xGlobalBroadcaster; + sal_Bool bRestartRequested; + sal_Bool bUseSystemFileDialog; + std::auto_ptr<SvtLanguageOptions> pLanguageOptions; + std::auto_ptr<SvtPathOptions> pPathOptions; + + ExecuteGlobals() + : bRestartRequested( sal_False ) + , bUseSystemFileDialog( sal_True ) + {} +}; + +static ExecuteGlobals* pExecGlobals = NULL; + void Desktop::Main() { + pExecGlobals = new ExecuteGlobals(); + RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Main" ); // Remember current context object @@ -1545,14 +1608,8 @@ void Desktop::Main() Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory(); - std::auto_ptr<SvtLanguageOptions> pLanguageOptions; - std::auto_ptr<SvtPathOptions> pPathOptions; - Reference< ::com::sun::star::task::XRestartManager > xRestartManager; - sal_Bool bRestartRequested( sal_False ); - sal_Bool bUseSystemFileDialog(sal_True); int nAcquireCount( 0 ); - Reference < css::document::XEventListener > xGlobalBroadcaster; try { RegisterServices( xSMgr ); @@ -1638,7 +1695,7 @@ void Desktop::Main() SetDisplayName( aTitle ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" ); - pPathOptions.reset( new SvtPathOptions); + pExecGlobals->pPathOptions.reset( new SvtPathOptions); SetSplashScreenProgress(40); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" ); @@ -1655,7 +1712,7 @@ void Desktop::Main() } // create service for loadin SFX (still needed in startup) - xGlobalBroadcaster = Reference < css::document::XEventListener > + pExecGlobals->xGlobalBroadcaster = Reference < css::document::XEventListener > ( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY ); @@ -1711,13 +1768,13 @@ void Desktop::Main() } // keep a language options instance... - pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); + pExecGlobals->pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); - if (xGlobalBroadcaster.is()) + if (pExecGlobals->xGlobalBroadcaster.is()) { css::document::EventObject aEvent; aEvent.EventName = ::rtl::OUString::createFromAscii("OnStartApp"); - xGlobalBroadcaster->notifyEvent(aEvent); + pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent); } SetSplashScreenProgress(50); @@ -1737,7 +1794,7 @@ void Desktop::Main() } // check whether the shutdown is caused by restart - bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); if ( pCmdLineArgs->IsHeadless() ) { @@ -1745,11 +1802,11 @@ void Desktop::Main() // headless mode relies on Application::EnableHeadlessMode() // which does only work for VCL dialogs!! SvtMiscOptions aMiscOptions; - bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); + pExecGlobals->bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); aMiscOptions.SetUseSystemFileDialog( sal_False ); } - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { if ((!pCmdLineArgs->WantsToLoadDocument() ) && (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) && @@ -1821,10 +1878,9 @@ void Desktop::Main() SvtAccessibilityOptions aOptions; aOptions.SetVCLSettings(); - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) ); - sal_Bool bTerminateRequested = sal_False; // Preload function depends on an initialized sfx application! @@ -1880,9 +1936,9 @@ void Desktop::Main() new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); // check whether the shutdown is caused by restart just before entering the Execute - bRestartRequested = bRestartRequested || ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + pExecGlobals->bRestartRequested = pExecGlobals->bRestartRequested || ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { // if this run of the office is triggered by restart, some additional actions should be done DoRestartActionsIfNecessary( !pCmdLineArgs->IsInvisible() && !pCmdLineArgs->IsNoQuickstart() ); @@ -1901,44 +1957,57 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); } } + // CAUTION: you do not necessarily get here e.g. on the Mac. + // please put all deinitialization code into doShutdown + doShutdown(); +} - if ( bRestartRequested ) +void Desktop::doShutdown() +{ + if( ! pExecGlobals ) + return; + + if ( pExecGlobals->bRestartRequested ) SetRestartState(); - if (xGlobalBroadcaster.is()) + if (pExecGlobals->xGlobalBroadcaster.is()) { css::document::EventObject aEvent; aEvent.EventName = ::rtl::OUString::createFromAscii("OnCloseApp"); - xGlobalBroadcaster->notifyEvent(aEvent); + pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent); } - delete pResMgr; + delete pResMgr, pResMgr = NULL; // Restore old value + CommandLineArgs* pCmdLineArgs = GetCommandLineArgs(); if ( pCmdLineArgs->IsHeadless() ) - SvtMiscOptions().SetUseSystemFileDialog( bUseSystemFileDialog ); + SvtMiscOptions().SetUseSystemFileDialog( pExecGlobals->bUseSystemFileDialog ); // remove temp directory RemoveTemporaryDirectory(); FlushConfiguration(); // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: - nAcquireCount = Application::ReleaseSolarMutex(); + ULONG nAcquireCount = Application::ReleaseSolarMutex(); DeregisterServices(); Application::AcquireSolarMutex(nAcquireCount); tools::DeInitTestToolLib(); // be sure that path/language options gets destroyed before // UCB is deinitialized RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> dispose path/language options" ); - pLanguageOptions.reset( 0 ); - pPathOptions.reset( 0 ); + pExecGlobals->pLanguageOptions.reset( 0 ); + pExecGlobals->pPathOptions.reset( 0 ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- dispose path/language options" ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> deinit ucb" ); ::ucbhelper::ContentBroker::deinitialize(); RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" ); + sal_Bool bRR = pExecGlobals->bRestartRequested; + delete pExecGlobals, pExecGlobals = NULL; + RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" ); - if ( bRestartRequested ) + if ( bRR ) { restartOnMac(true); // wouldn't the solution be more clean if SalMain returns the exit code to the system? @@ -2053,9 +2122,9 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r // unfortunately this broke the QUARTZ behavior which is to always run // in quickstart mode since Mac applications do not usually quit // when the last document closes - #ifndef QUARTZ + //#ifndef QUARTZ if ( bQuickstart ) - #endif + //#endif { Reference < XComponent > xQuickstart( rSMgr->createInstanceWithArguments( DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" ), aSeq ), @@ -2123,17 +2192,6 @@ void Desktop::SystemSettingsChanging( AllSettings& rSettings, Window* ) } hStyleSettings.SetUseImagesInMenus(bUseImagesInMenus); - sal_uInt16 nTabStyle = hStyleSettings.GetTabControlStyle(); - nTabStyle &= ~STYLE_TABCONTROL_SINGLELINE; - if( aAppearanceCfg.IsSingleLineTabCtrl() ) - nTabStyle |=STYLE_TABCONTROL_SINGLELINE; - - nTabStyle &= ~STYLE_TABCONTROL_COLOR; - if( aAppearanceCfg.IsColoredTabCtrl() ) - nTabStyle |= STYLE_TABCONTROL_COLOR; - - hStyleSettings.SetTabControlStyle(nTabStyle); - hStyleSettings.SetDragFullOptions( nDragFullOptions ); rSettings.SetStyleSettings ( hStyleSettings ); } @@ -3135,6 +3193,13 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) catch(const css::uno::Exception&) {} } + else if( rAppEvent.GetEvent() == "PRIVATE:DOSHUTDOWN" ) + { + Desktop* pD = dynamic_cast<Desktop*>(GetpApp()); + OSL_ENSURE( pD, "no desktop ?!?" ); + if( pD ) + pD->doShutdown(); + } } void Desktop::OpenSplashScreen() diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 001dfecc6932..ea0b66245988 100755 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -387,6 +387,10 @@ void UpdateDialog::Thread::execute() uno::Reference<ucb::XCommandEnvironment>()); } catch (lang::IllegalArgumentException& ) { OSL_ASSERT(0); + continue; + } catch (css::ucb::CommandFailedException& ) { + OSL_ASSERT(0); + continue; } OSL_ASSERT(extensions.getLength() == 3); if (extensions[0].is() ) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 709cca86c631..6eb547c4e98a 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -183,12 +183,8 @@ ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& x ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >(getMutex()), m_xContext( xContext ) { - Reference<deploy::XPackageManagerFactory> xPackageManagerFactory( - deploy::thePackageManagerFactory::get(m_xContext)); - m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user")); - m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared")); - m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled")); - m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp")); + m_xPackageManagerFactory = deploy::thePackageManagerFactory::get(m_xContext); + OSL_ASSERT(m_xPackageManagerFactory.is()); m_repositoryNames.push_back(OUSTR("user")); m_repositoryNames.push_back(OUSTR("shared")); @@ -201,6 +197,23 @@ ExtensionManager::~ExtensionManager() { } +Reference<deploy::XPackageManager> ExtensionManager::getUserRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("user")); +} +Reference<deploy::XPackageManager> ExtensionManager::getSharedRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("shared")); +} +Reference<deploy::XPackageManager> ExtensionManager::getBundledRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("bundled")); +} +Reference<deploy::XPackageManager> ExtensionManager::getTmpRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("tmp")); +} + Reference<task::XAbortChannel> ExtensionManager::createAbortChannel() throw (uno::RuntimeException) { @@ -213,11 +226,11 @@ ExtensionManager::getPackageManager(::rtl::OUString const & repository) { Reference<deploy::XPackageManager> xPackageManager; if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else if (repository.equals(OUSTR("bundled"))) - xPackageManager = m_bundledRepository; + xPackageManager = getBundledRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -288,7 +301,7 @@ void ExtensionManager::addExtensionsToMap( ::std::list<Reference<deploy::XPackage> > extensionList; try { //will throw an exception if the extension does not exist - extensionList.push_back(m_userRepository->getDeployedPackage( + extensionList.push_back(getUserRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch(lang::IllegalArgumentException &) { @@ -296,7 +309,7 @@ void ExtensionManager::addExtensionsToMap( } try { - extensionList.push_back(m_sharedRepository->getDeployedPackage( + extensionList.push_back(getSharedRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch (lang::IllegalArgumentException &) { @@ -304,7 +317,7 @@ void ExtensionManager::addExtensionsToMap( } try { - extensionList.push_back(m_bundledRepository->getDeployedPackage( + extensionList.push_back(getBundledRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch (lang::IllegalArgumentException &) { @@ -508,7 +521,7 @@ Reference<deploy::XPackage> ExtensionManager::backupExtension( if (xOldExtension.is()) { - xBackup = m_tmpRepository->addPackage( + xBackup = getTmpRepository()->addPackage( xOldExtension->getURL(), uno::Sequence<beans::NamedValue>(), OUString(), Reference<task::XAbortChannel>(), tmpCmdEnv); @@ -529,7 +542,7 @@ uno::Sequence< Reference<deploy::XPackageTypeInfo> > ExtensionManager::getSupportedPackageTypes() throw (uno::RuntimeException) { - return m_userRepository->getSupportedPackageTypes(); + return getUserRepository()->getSupportedPackageTypes(); } //Do some necessary checks and user interaction. This function does not //aquire the extension manager mutex and that mutex must not be aquired @@ -649,9 +662,9 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( //Determine the repository to use Reference<deploy::XPackageManager> xPackageManager; if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -664,7 +677,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( getTempExtension(url, xAbortChannel, xCmdEnv); //Make sure the extension is removed from the tmp repository in case //of an exception - ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension, m_tmpRepository); + ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension, getTmpRepository()); const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); const OUString sFileName = xTmpExtension->getName(); Reference<deploy::XPackage> xOldExtension; @@ -708,7 +721,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( //the xTmpExtension //no command environment supplied, only this class shall interact //with the user! - xExtensionBackup = m_tmpRepository->importExtension( + xExtensionBackup = getTmpRepository()->importExtension( xOldExtension, Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>()); tmpExtensionRemoveGuard.reset(xExtensionBackup); @@ -857,9 +870,9 @@ void ExtensionManager::removeExtension( { //Determine the repository to use if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -919,7 +932,7 @@ void ExtensionManager::removeExtension( Reference<task::XAbortChannel>(), tmpCmdEnv); - m_tmpRepository->removePackage( + getTmpRepository()->removePackage( dp_misc::getIdentifier(xExtensionBackup), xExtensionBackup->getName(), xAbortChannel, xCmdEnv); fireModified(); @@ -932,7 +945,7 @@ void ExtensionManager::removeExtension( } if (xExtensionBackup.is()) - m_tmpRepository->removePackage( + getTmpRepository()->removePackage( dp_misc::getIdentifier(xExtensionBackup), xExtensionBackup->getName(), xAbortChannel, xCmdEnv); } @@ -1160,13 +1173,13 @@ uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > > id2extensions mapExt; uno::Sequence<Reference<deploy::XPackage> > userExt = - m_userRepository->getDeployedPackages(xAbort, xCmdEnv); + getUserRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, userExt, OUSTR("user")); uno::Sequence<Reference<deploy::XPackage> > sharedExt = - m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv); + getSharedRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, sharedExt, OUSTR("shared")); uno::Sequence<Reference<deploy::XPackage> > bundledExt = - m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv); + getBundledRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled")); //copy the values of the map to a vector for sorting @@ -1236,7 +1249,7 @@ void ExtensionManager::reinstallDeployedExtensions( const OUString id = dp_misc::getIdentifier(extensions[ pos ]); const OUString fileName = extensions[ pos ]->getName(); OSL_ASSERT(id.getLength()); - activateExtension(id, fileName, false, false, xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, false, true, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1260,6 +1273,64 @@ void ExtensionManager::reinstallDeployedExtensions( } } +/** Works on the bundled repository. That is using the variables + BUNDLED_EXTENSIONS and BUNDLED_EXTENSIONS_USER. + */ +void ExtensionManager::synchronizeBundledPrereg( + Reference<task::XAbortChannel> const & xAbortChannel, + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) + throw (deploy::DeploymentException, + uno::RuntimeException) +{ + try + { + String sSynchronizingBundled(StrSyncRepository::get()); + sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled")); + dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled); + + Reference<deploy::XPackageManagerFactory> xPackageManagerFactory( + deploy::thePackageManagerFactory::get(m_xContext)); + + Reference<deploy::XPackageManager> xMgr = + xPackageManagerFactory->getPackageManager(OUSTR("bundled_prereg")); + xMgr->synchronize(xAbortChannel, xCmdEnv); + progressBundled.update(OUSTR("\n\n")); + + uno::Sequence<Reference<deploy::XPackage> > extensions = xMgr->getDeployedPackages( + xAbortChannel, xCmdEnv); + try + { + for (sal_Int32 i = 0; i < extensions.getLength(); i++) + { + extensions[i]->registerPackage(true, xAbortChannel, xCmdEnv); + } + } + catch (...) + { + OSL_ASSERT(0); + } + OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_PREREG/lastsynchronized")); + writeLastModified(lastSyncBundled, xCmdEnv); + + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception in synchronize"), + static_cast<OWeakObject*>(this), exc); + } +} + sal_Bool ExtensionManager::synchronize( Reference<task::XAbortChannel> const & xAbortChannel, Reference<ucb::XCommandEnvironment> const & xCmdEnv ) @@ -1277,13 +1348,13 @@ sal_Bool ExtensionManager::synchronize( String sSynchronizingShared(StrSyncRepository::get()); sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared")); dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared); - bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv); + bModified = getSharedRepository()->synchronize(xAbortChannel, xCmdEnv); progressShared.update(OUSTR("\n\n")); String sSynchronizingBundled(StrSyncRepository::get()); sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled")); dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled); - bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv); + bModified |= getBundledRepository()->synchronize(xAbortChannel, xCmdEnv); progressBundled.update(OUSTR("\n\n")); //Always determine the active extension. This is necessary for the @@ -1410,7 +1481,7 @@ Reference<deploy::XPackage> ExtensionManager::getTempExtension( { Reference<ucb::XCommandEnvironment> tmpCmdEnvA(new TmpRepositoryCommandEnv()); - Reference<deploy::XPackage> xTmpPackage = m_tmpRepository->addPackage( + Reference<deploy::XPackage> xTmpPackage = getTmpRepository()->addPackage( url, uno::Sequence<beans::NamedValue>(),OUString(), xAbortChannel, tmpCmdEnvA); if (!xTmpPackage.is()) { diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 683f45a1bd6e..e7a180a05de1 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -205,6 +205,12 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual void SAL_CALL synchronizeBundledPrereg( + css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL getExtensionsWithUnacceptedLicenses( ::rtl::OUString const & repository, @@ -229,11 +235,7 @@ private: }; css::uno::Reference< css::uno::XComponentContext> m_xContext; - - css::uno::Reference<css::deployment::XPackageManager> m_userRepository; - css::uno::Reference<css::deployment::XPackageManager> m_sharedRepository; - css::uno::Reference<css::deployment::XPackageManager> m_bundledRepository; - css::uno::Reference<css::deployment::XPackageManager> m_tmpRepository; + css::uno::Reference<css::deployment::XPackageManagerFactory> m_xPackageManagerFactory; //only to be used within addExtension ::osl::Mutex m_addMutex; @@ -243,6 +245,11 @@ private: */ ::std::list< ::rtl::OUString > m_repositoryNames; + css::uno::Reference<css::deployment::XPackageManager> getUserRepository(); + css::uno::Reference<css::deployment::XPackageManager> getSharedRepository(); + css::uno::Reference<css::deployment::XPackageManager> getBundledRepository(); + css::uno::Reference<css::deployment::XPackageManager> getTmpRepository(); + bool isUserDisabled(::rtl::OUString const & identifier, ::rtl::OUString const & filename); diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 4cc43a8386d8..6d4750bb2447 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -40,9 +40,8 @@ #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" #include "com/sun/star/task/XAbortChannel.hpp" -#include "com/sun/star/ucb/CommandFailedException.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/xml/dom/XElement.hpp" #include "com/sun/star/xml/dom/XNode.hpp" @@ -71,9 +70,8 @@ namespace xml = com::sun::star::xml ; namespace dp_info { class PackageInformationProvider : - public ::cppu::WeakImplHelper3< deployment::XPackageInformationProvider, - css_ucb::XCommandEnvironment, - task::XInteractionHandler > + public ::cppu::WeakImplHelper1< deployment::XPackageInformationProvider > + { public: PackageInformationProvider( uno::Reference< uno::XComponentContext >const& xContext); @@ -82,16 +80,6 @@ class PackageInformationProvider : static uno::Sequence< rtl::OUString > getServiceNames(); static rtl::OUString getImplName(); - // XInteractionHandler - virtual void SAL_CALL handle( const uno::Reference< task::XInteractionRequest >& Request ) - throw( uno::RuntimeException ); - // XCommandEnvironment - virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() - throw ( uno::RuntimeException ) { return static_cast<task::XInteractionHandler*>(this); }; - - virtual uno::Reference< css_ucb::XProgressHandler > SAL_CALL getProgressHandler() - throw ( uno::RuntimeException ) { return uno::Reference< css_ucb::XProgressHandler >(); }; - // XPackageInformationProvider virtual rtl::OUString SAL_CALL getPackageLocation( const rtl::OUString& extensionId ) throw ( uno::RuntimeException ); @@ -125,17 +113,6 @@ PackageInformationProvider::~PackageInformationProvider() } //------------------------------------------------------------------------------ -void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInteractionRequest > const & rRequest) - throw (uno::RuntimeException) -{ - uno::Sequence< uno::Reference< task::XInteractionContinuation > > xContinuations = rRequest->getContinuations(); - if ( xContinuations.getLength() == 1 ) - { - xContinuations[0]->select(); - } -} - -//------------------------------------------------------------------------------ rtl::OUString PackageInformationProvider::getPackageLocation( const rtl::OUString & repository, const rtl::OUString& _rExtensionId ) @@ -150,7 +127,7 @@ rtl::OUString PackageInformationProvider::getPackageLocation( xManager->getDeployedExtensions( repository, uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ) ); + uno::Reference< css_ucb::XCommandEnvironment > () ) ); for ( int pos = packages.getLength(); pos--; ) { @@ -320,7 +297,7 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi const uno::Sequence< uno::Sequence< uno::Reference<deployment::XPackage > > > allExt = mgr->getAllExtensions( uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ); + uno::Reference< css_ucb::XCommandEnvironment > () ); uno::Sequence< uno::Sequence< rtl::OUString > > retList; diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 44bc4d469f2f..2e2c5e2a2f53 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -370,6 +370,24 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create( //No stamp file. We assume that bundled is always readonly. It must not be //modified from ExtensionManager but only by the installer } + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled_prereg") )) { + //This is a bundled repository but the registration data + //is in the brand layer: share/prereg + //It is special because the registration data are copied at the first startup + //into the user installation. The processed help and xcu files are not + //copied. Instead the backenddb.xml for the help backend references the help + //by using $BUNDLED_EXTENSION_PREREG instead $BUNDLED_EXTENSIONS_USER. The + //configmgr.ini also used $BUNDLED_EXTENSIONS_PREREG to refer to the xcu file + //which contain the replacement for %origin%. + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG/log.txt"); + } else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) { that->m_activePackages = OUSTR( "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions"); @@ -949,6 +967,8 @@ void PackageManagerImpl::removePackage( contentRemoved.writeStream( xData, true /* replace existing */ ); } m_activePackagesDB->erase( id, fileName ); // to be removed upon next start + //remove any cached data hold by the backend + m_xRegistry->packageRemoved(xPackage->getURL(), xPackage->getPackageType()->getMediaType()); } try_dispose( xPackage ); @@ -989,7 +1009,8 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data ) //The bundled extensions are not contained in an additional folder //with a unique name. data.temporaryName contains already the //UTF8 encoded folder name. See PackageManagerImpl::synchronize - if (!m_context.equals(OUSTR("bundled"))) + if (!m_context.equals(OUSTR("bundled")) + && !m_context.equals(OUSTR("bundled_prereg"))) { buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, @@ -1341,6 +1362,8 @@ bool PackageManagerImpl::synchronizeAddedExtensions( Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) { bool bModified = false; + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); //check if the folder exist at all. The shared extension folder //may not exist for a normal user. @@ -1366,8 +1389,8 @@ bool PackageManagerImpl::synchronizeAddedExtensions( //The temporary folders of user and shared have an '_' at then end. //But the name in ActivePackages.temporaryName is saved without. OUString title2 = title; - bool bNotBundled = !m_context.equals(OUSTR("bundled")); - if (bNotBundled) + bool bShared = m_context.equals(OUSTR("shared")); + if (bShared) { OSL_ASSERT(title2[title2.getLength() -1] == '_'); title2 = title2.copy(0, title2.getLength() -1); @@ -1389,7 +1412,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( // an added extension OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); OUString sExtFolder; - if (bNotBundled) //that is, shared + if (bShared) //that is, shared { //Check if the extension was not "deleted" already which is indicated //by a xxx.tmpremoved file @@ -1411,7 +1434,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( ActivePackages::Data dbData; dbData.temporaryName = titleEncoded; - if (bNotBundled) + if (bShared) dbData.fileName = sExtFolder; else dbData.fileName = title; diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index 898e7c931f6d..458ece3d0bd8 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -82,26 +82,29 @@ OUString ComponentBackendDb::getKeyElementName() void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url); - writeSimpleElement(OUSTR("java-type-library"), - OUString::valueOf((sal_Bool) data.javaTypeLibrary), - componentNode); - - writeSimpleList( - data.implementationNames, - OUSTR("implementation-names"), - OUSTR("name"), - componentNode); - - writeVectorOfPair( - data.singletons, - OUSTR("singletons"), - OUSTR("item"), - OUSTR("key"), - OUSTR("value"), - componentNode); - - save(); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url); + writeSimpleElement(OUSTR("java-type-library"), + OUString::valueOf((sal_Bool) data.javaTypeLibrary), + componentNode); + + writeSimpleList( + data.implementationNames, + OUSTR("implementation-names"), + OUSTR("name"), + componentNode); + + writeVectorOfPair( + data.singletons, + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value"), + componentNode); + + save(); + } } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index d1511952a92a..650a7585d929 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -270,8 +270,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend std::auto_ptr<ComponentBackendDb> m_backendDb; void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); - void deleteDataFromDb(OUString const & url); ComponentBackendDb::Data readDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); //These rdbs are for writing new service entries. The rdb files are copies @@ -327,6 +327,10 @@ public: virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + using PackageRegistryBackend::disposing; //Will be called from ComponentPackageImpl @@ -660,12 +664,6 @@ void BackendImpl::addDataToDb( m_backendDb->addEntry(url, data); } -void BackendImpl::deleteDataFromDb(OUString const & url) -{ - if (m_backendDb.get()) - m_backendDb->removeEntry(url); -} - ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) { ComponentBackendDb::Data data; @@ -674,6 +672,12 @@ ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) return data; } +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference<deployment::XPackageTypeInfo> > @@ -682,6 +686,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -1437,6 +1449,9 @@ void BackendImpl::ComponentPackageImpl::getComponentInfo( // Package //______________________________________________________________________________ +//We could use here BackendImpl::hasActiveEntry. However, this check is just as well. +//And it also shows the problem if another extension has overwritten an implementation +//entry, because it contains the same service implementation beans::Optional< beans::Ambiguous<sal_Bool> > BackendImpl::ComponentPackageImpl::isRegistered_( ::osl::ResettableMutexGuard &, @@ -1590,7 +1605,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( that->releaseObject(url); } m_registered = REG_NOT_REGISTERED; - that->deleteDataFromDb(url); + getMyBackend()->revokeEntryFromDb(url); } } @@ -1803,7 +1818,7 @@ void BackendImpl::ComponentsPackageImpl::processPackage_( that->componentLiveRemoval(that->readDataFromDb(url)); } that->releaseObject(url); - that->deleteDataFromDb(url); + that->revokeEntryFromDb(url); } } diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 1e7ee5bfac8a..24e5587cd0cc 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -132,15 +132,21 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference<XCommandEnvironment> const & xCmdEnv ); void configmgrini_flush( Reference<XCommandEnvironment> const & xCmdEnv ); - bool addToConfigmgrIni( bool isSchema, OUString const & url, + /* The paramter isURL is false in the case of adding the conf:ini-entry + value from the backend db. This entry already contains the path as it + is used in the configmgr.ini. + */ + bool addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); bool removeFromConfigmgrIni( bool isSchema, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data); ::boost::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url); - OUString deleteDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); ::std::list<OUString> getAllIniEntries(); + bool hasActiveEntry(OUString const & url); + bool activateEntry(OUString const & url); public: BackendImpl( Sequence<Any> const & args, @@ -149,6 +155,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using PackageRegistryBackend::disposing; }; @@ -240,18 +249,10 @@ void BackendImpl::addDataToDb( return data; } -OUString BackendImpl::deleteDataFromDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { - OUString url2(url); - if (m_backendDb.get()) { - boost::optional< ConfigurationBackendDb::Data > data( - m_backendDb->getEntry(url)); - if (data) { - url2 = expandUnoRcTerm(data->iniEntry); - } - m_backendDb->removeEntry(url); - } - return url2; + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); } ::std::list<OUString> BackendImpl::getAllIniEntries() @@ -262,6 +263,20 @@ OUString BackendImpl::deleteDataFromDb(OUString const & url) return ::std::list<OUString>(); } +bool BackendImpl::hasActiveEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->hasActiveEntry(url); + return false; +} + +bool BackendImpl::activateEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->activateEntry(url); + return false; +} + // XPackageRegistry @@ -271,6 +286,13 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) { return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend //______________________________________________________________________________ @@ -457,10 +479,10 @@ void BackendImpl::configmgrini_flush( } //______________________________________________________________________________ -bool BackendImpl::addToConfigmgrIni( bool isSchema, OUString const & url_, +bool BackendImpl::addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url_, Reference<XCommandEnvironment> const & xCmdEnv ) { - const OUString rcterm( dp_misc::makeRcTerm(url_) ); + const OUString rcterm( isURL ? dp_misc::makeRcTerm(url_) : url_ ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); @@ -509,6 +531,7 @@ bool BackendImpl::removeFromConfigmgrIni( // Package //______________________________________________________________________________ + BackendImpl * BackendImpl::PackageImpl::getMyBackend() const { BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get()); @@ -534,7 +557,7 @@ BackendImpl::PackageImpl::isRegistered_( const rtl::OUString url(getURL()); bool bReg = false; - if (that->readDataFromDb(getURL())) + if (that->hasActiveEntry(getURL())) bReg = true; if (!bReg) //fallback for user extension registered in berkeley DB @@ -677,38 +700,48 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { - ConfigurationBackendDb::Data data; - if (!m_isSchema) + if (getMyBackend()->activateEntry(getURL())) { - const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); - bool out_replaced = false; - url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); - if (out_replaced) - data.dataUrl = sModFolder; - else - deleteTempFolder(sModFolder); + ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); + OSL_ASSERT(data); + that->addToConfigmgrIni( m_isSchema, false, data->iniEntry, xCmdEnv ); } - //No need for live-deployment for bundled extension, because OOo - //restarts after installation - if (that->m_eContext != CONTEXT_BUNDLED - && !startup) + else { - if (m_isSchema) + ConfigurationBackendDb::Data data; + if (!m_isSchema) { - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcsFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); + bool out_replaced = false; + url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); + if (out_replaced) + data.dataUrl = sModFolder; + else + deleteTempFolder(sModFolder); } - else + //No need for live-deployment for bundled extension, because OOo + //restarts after installation + if (that->m_eContext != CONTEXT_BUNDLED + && that->m_eContext != CONTEXT_BUNDLED_PREREG + && !startup) { - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcuFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + if (m_isSchema) + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcsFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } + else + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcuFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } } + that->addToConfigmgrIni( m_isSchema, true, url, xCmdEnv ); + data.iniEntry = dp_misc::makeRcTerm(url); + that->addDataToDb(getURL(), data); } - that->addToConfigmgrIni( m_isSchema, url, xCmdEnv ); - data.iniEntry = dp_misc::makeRcTerm(url); - that->addDataToDb(getURL(), data); } else // revoke { @@ -741,7 +774,7 @@ void BackendImpl::PackageImpl::processPackage_( else deleteTempFolder(sModFolder); } - that->addToConfigmgrIni(schema, url_replaced, xCmdEnv); + that->addToConfigmgrIni(schema, true, url_replaced, xCmdEnv); data.iniEntry = dp_misc::makeRcTerm(url_replaced); that->addDataToDb(url2, data); } @@ -759,12 +792,17 @@ void BackendImpl::PackageImpl::processPackage_( OSL_ASSERT(0); } } - url = that->deleteDataFromDb(url); - if (!m_isSchema) { + + ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); + //If an xcu file was life deployed then always a data entry is written. + //If the xcu file was already in the configmr.ini then there is also + //a data entry + if (!m_isSchema && data) + { com::sun::star::configuration::Update::get( - that->m_xComponentContext)->removeExtensionXcuFile( - expandUnoRcUrl(url)); + that->m_xComponentContext)->removeExtensionXcuFile(expandUnoRcTerm(data->iniEntry)); } + that->revokeEntryFromDb(url); } } diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx index 2a02c6d8efa0..2437c54ec734 100644 --- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx @@ -83,12 +83,15 @@ OUString ConfigurationBackendDb::getKeyElementName() void ConfigurationBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> helpNode - = writeKeyElement(url); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> helpNode + = writeKeyElement(url); - writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); - writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); - save(); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); + save(); + } } catch (css::deployment::DeploymentException& ) { diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index fa53d4e78a15..266d4406cfde 100755 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -39,6 +39,7 @@ #include "ucbhelper/content.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" +#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "com/sun/star/ucb/IOErrorCode.hpp" #include "com/sun/star/beans/StringPair.hpp" @@ -99,6 +100,8 @@ PackageRegistryBackend::PackageRegistryBackend( m_eContext = CONTEXT_BUNDLED; else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) m_eContext = CONTEXT_TMP; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled_prereg") )) + m_eContext = CONTEXT_BUNDLED_PREREG; else if (m_context.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) m_eContext = CONTEXT_DOCUMENT; @@ -121,6 +124,9 @@ void PackageRegistryBackend::check() void PackageRegistryBackend::disposing() { try { + for ( t_string2ref::const_iterator i = m_bound.begin(); i != m_bound.end(); i++) + i->second->removeEventListener(this); + m_bound.clear(); m_xComponentContext.clear(); WeakComponentImplHelperBase::disposing(); } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 14b4f2374c5b..9629855aaf11 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -187,6 +187,74 @@ void BackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression.makeStringAndClear()); } +void BackendDb::revokeEntry(::rtl::OUString const & url) +{ + try + { + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + entry->setAttribute(OUSTR("revoked"), OUSTR("true")); + save(); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to revoke data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool BackendDb::activateEntry(::rtl::OUString const & url) +{ + try + { + bool ret = false; + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + //no attribute "active" means it is active, that is, registered. + entry->removeAttribute(OUSTR("revoked")); + save(); + ret = true; + } + return ret; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to revoke data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool BackendDb::hasActiveEntry(::rtl::OUString const & url) +{ + try + { + bool ret = false; + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + OUString sActive = entry->getAttribute(OUSTR("revoked")); + if (!sActive.equals(OUSTR("true"))) + ret = true; + } + return ret; + + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to determine an active entry in backend db: ") + + m_urlDb, 0, exc); + } +} + Reference<css::xml::dom::XNode> BackendDb::getKeyElement( ::rtl::OUString const & url) { @@ -577,32 +645,34 @@ RegisteredDb::RegisteredDb( void RegisteredDb::addEntry(::rtl::OUString const & url) { try{ + if (!activateEntry(url)) + { + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - const OUString sEntry = getKeyElementName(); - - Reference<css::xml::dom::XDocument> doc = getDocument(); - Reference<css::xml::dom::XNode> root = doc->getFirstChild(); + Reference<css::xml::dom::XDocument> doc = getDocument(); + Reference<css::xml::dom::XNode> root = doc->getFirstChild(); #if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); - Reference<css::xml::dom::XNode> _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference<css::xml::dom::XNode> _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); #endif - Reference<css::xml::dom::XElement> helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); + Reference<css::xml::dom::XElement> helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); - helpElement->setAttribute(OUSTR("url"), url); + helpElement->setAttribute(OUSTR("url"), url); - Reference<css::xml::dom::XNode> helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); + Reference<css::xml::dom::XNode> helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); - save(); + save(); + } } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 0f309a5b729f..eecae4e391b7 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -135,6 +135,10 @@ public: lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + RuntimeException); + }; //______________________________________________________________________________ @@ -185,6 +189,20 @@ OUString normalizeMediaType( OUString const & mediaType ) //______________________________________________________________________________ +void PackageRegistryImpl::packageRemoved( + ::rtl::OUString const & url, ::rtl::OUString const & mediaType) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException) +{ + const t_string2registry::const_iterator i = + m_mediaType2backend.find(mediaType); + + if (i != m_mediaType2backend.end()) + { + i->second->packageRemoved(url, mediaType); + } +} + void PackageRegistryImpl::insertBackend( Reference<deployment::XPackageRegistry> const & xBackend ) { diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 968ee7297b0f..5ec739153831 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -71,6 +71,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool getFileAttributes(sal_uInt64& out_Attributes); bool isUrlTargetInExtension(); + public: inline ExecutablePackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -92,8 +93,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); void addDataToDb(OUString const & url); - bool isRegisteredInDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); Reference<deployment::XPackageTypeInfo> m_xExecutableTypeInfo; std::auto_ptr<ExecutableBackendDb> m_backendDb; @@ -104,6 +105,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using PackageRegistryBackend::disposing; }; @@ -134,20 +138,20 @@ void BackendImpl::addDataToDb(OUString const & url) m_backendDb->addEntry(url); } -bool BackendImpl::isRegisteredInDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { - bool ret = false; if (m_backendDb.get()) - ret = m_backendDb->getEntry(url); - return ret; + m_backendDb->revokeEntry(url); } -void BackendImpl::deleteDataFromDb(OUString const & url) +bool BackendImpl::hasActiveEntry(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + return m_backendDb->hasActiveEntry(url); + return false; } + // XPackageRegistry Sequence< Reference<deployment::XPackageTypeInfo> > BackendImpl::getSupportedPackageTypes() throw (RuntimeException) @@ -156,6 +160,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) & m_xExecutableTypeInfo, 1); } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType, sal_Bool bRemoved, @@ -217,7 +229,7 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( ::rtl::Reference<dp_misc::AbortChannel> const &, Reference<XCommandEnvironment> const & ) { - bool registered = getMyBackend()->isRegisteredInDb(getURL()); + bool registered = getMyBackend()->hasActiveEntry(getURL()); return beans::Optional< beans::Ambiguous<sal_Bool> >( sal_True /* IsPresent */, beans::Ambiguous<sal_Bool>( @@ -248,7 +260,8 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( else if (getMyBackend()->m_context.equals(OUSTR("shared"))) attributes |= (osl_File_Attribute_OwnExe | osl_File_Attribute_GrpExe | osl_File_Attribute_OthExe); - else if (!getMyBackend()->m_context.equals(OUSTR("bundled"))) + else if (!getMyBackend()->m_context.equals(OUSTR("bundled")) + && !getMyBackend()->m_context.equals(OUSTR("bundled_prereg"))) //Bundled extension are required to be in the properly //installed. That is an executable must have the right flags OSL_ASSERT(0); @@ -261,7 +274,7 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( } else { - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); } } @@ -277,7 +290,8 @@ bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension() sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_USER_PACKAGES_CACHE")); else if (getMyBackend()->m_context.equals(OUSTR("shared"))) sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_SHARED_PACKAGES_CACHE")); - else if (getMyBackend()->m_context.equals(OUSTR("bundled"))) + else if (getMyBackend()->m_context.equals(OUSTR("bundled")) + || getMyBackend()->m_context.equals(OUSTR("bundled_prereg"))) sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$BUNDLED_EXTENSIONS")); else OSL_ASSERT(0); diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 53a7ba1c316d..0adb63614828 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -80,7 +80,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference<AbortChannel> const & abortChannel, Reference<XCommandEnvironment> const & xCmdEnv ); - bool extensionContainsCompiledHelp(); + public: PackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -88,6 +88,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference<deployment::XPackageTypeInfo> const & xPackageType, bool bRemoved, OUString const & identifier); + bool extensionContainsCompiledHelp(); + //XPackage virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() throw (deployment::ExtensionRemovedException, css::uno::RuntimeException); @@ -100,14 +102,16 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); - void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, - bool compiledHelp, Reference<ucb::XCommandEnvironment> const & xCmdEnv); + void implProcessHelp( PackageImpl * package, bool doRegisterPackage, + Reference<ucb::XCommandEnvironment> const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); ::boost::optional<HelpBackendDb::Data> readDataFromDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); + bool activateEntry(OUString const & url); Reference< ucb::XSimpleFileAccess > getFileAccess( void ); Reference< ucb::XSimpleFileAccess > m_xSFA; @@ -123,6 +127,10 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + }; //______________________________________________________________________________ @@ -162,6 +170,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -220,12 +236,27 @@ void BackendImpl::addDataToDb( return data; } -void BackendImpl::deleteDataFromDb(OUString const & url) +bool BackendImpl::hasActiveEntry(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + return m_backendDb->hasActiveEntry(url); + return false; +} + +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); } +bool BackendImpl::activateEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->activateEntry(url); + return false; +} + + //############################################################################## BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -235,13 +266,6 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { -// if (bRemoved) -// { -// ::boost::optional<HelpBackendDb::Data> opt = -// getMyBackend()->readDataFromDb(url); -// if (opt) -// m_dbData = *opt; -// } } // Package @@ -260,7 +284,6 @@ BackendImpl * BackendImpl::PackageImpl::getMyBackend() const return pBackend; } - bool BackendImpl::PackageImpl::extensionContainsCompiledHelp() { bool bCompiled = true; @@ -311,6 +334,7 @@ bool BackendImpl::PackageImpl::extensionContainsCompiledHelp() } return bCompiled; } + //______________________________________________________________________________ beans::Optional< beans::Ambiguous<sal_Bool> > BackendImpl::PackageImpl::isRegistered_( @@ -321,7 +345,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); bool bReg = false; - if (that->readDataFromDb(getURL())) + if (that->hasActiveEntry(getURL())) bReg = true; return beans::Optional< beans::Ambiguous<sal_Bool> >( true, beans::Ambiguous<sal_Bool>( bReg, false ) ); @@ -340,9 +364,7 @@ void BackendImpl::PackageImpl::processPackage_( (void)xCmdEnv; BackendImpl* that = getMyBackend(); - Reference< deployment::XPackage > xThisPackage( this ); - that->implProcessHelp( xThisPackage, doRegisterPackage, - extensionContainsCompiledHelp(), xCmdEnv); + that->implProcessHelp( this, doRegisterPackage, xCmdEnv); } beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() @@ -355,7 +377,7 @@ beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() ::boost::optional<HelpBackendDb::Data> data = getMyBackend()->readDataFromDb(getURL()); - if (data) + if (data && getMyBackend()->hasActiveEntry(getURL())) return beans::Optional<OUString>(true, data->dataUrl); return beans::Optional<OUString>(true, OUString()); @@ -368,224 +390,225 @@ static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); static rtl::OUString aHelpStr( rtl::OUString::createFromAscii( "help" ) ); -void BackendImpl::implProcessHelp -( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, bool compiledHelp, - Reference<ucb::XCommandEnvironment> const & xCmdEnv) +void BackendImpl::implProcessHelp( + PackageImpl * package, bool doRegisterPackage, + Reference<ucb::XCommandEnvironment> const & xCmdEnv) { + Reference< deployment::XPackage > xPackage(package); OSL_ASSERT(xPackage.is()); if (doRegisterPackage) { - HelpBackendDb::Data data; - - if (compiledHelp) + //revive already processed help if possible + if ( !activateEntry(xPackage->getURL())) { + HelpBackendDb::Data data; data.dataUrl = xPackage->getURL(); - } - else - { - const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); - data.dataUrl = sHelpFolder; - - Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); - rtl::OUString aHelpURL = xPackage->getURL(); - rtl::OUString aExpandedHelpURL = dp_misc::expandUnoRcUrl( aHelpURL ); - rtl::OUString aName = xPackage->getName(); - if( !xSFA->isFolder( aExpandedHelpURL ) ) + if (!package->extensionContainsCompiledHelp()) { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); - } - - Reference<XComponentContext> const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) - { - try + const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; + + Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); + rtl::OUString aHelpURL = xPackage->getURL(); + rtl::OUString aExpandedHelpURL = dp_misc::expandUnoRcUrl( aHelpURL ); + rtl::OUString aName = xPackage->getName(); + if( !xSFA->isFolder( aExpandedHelpURL ) ) { - xInvocation = Reference< script::XInvocation >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); + aErrStr += rtl::OUString::createFromAscii( "No help folder" ); + OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - catch (Exception &) + + Reference<XComponentContext> const & xContext = getComponentContext(); + Reference< script::XInvocation > xInvocation; + if( xContext.is() ) { - // i98680: Survive missing lucene + try + { + xInvocation = Reference< script::XInvocation >( + xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( + "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + } + catch (Exception &) + { + // i98680: Survive missing lucene + } } - } - // Scan languages - Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); - sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); - const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); - for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) - { - rtl::OUString aLangURL = pSeq[iLang]; - if( xSFA->isFolder( aLangURL ) ) + // Scan languages + Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); + sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); + const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); + for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) { - std::vector< rtl::OUString > aXhpFileVector; - - // calculate jar file URL - sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); - // for example "/en" - OUString langFolderURLSegment( - aLangURL.copy( - indexStartSegment + 1, aLangURL.getLength() - indexStartSegment - 1)); - - //create the folder in the "temporary folder" - ::ucbhelper::Content langFolderContent; - const OUString langFolderDest = makeURL(sHelpFolder, langFolderURLSegment); - const OUString langFolderDestExpanded = ::dp_misc::expandUnoRcUrl(langFolderDest); - ::dp_misc::create_folder( - &langFolderContent, - langFolderDest, xCmdEnv); - - rtl::OUString aJarFile( - makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + - OUSTR(".jar"))); - aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); - - rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( - aJarFile, rtl_UriCharClassPchar, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.zip://" ); - aDestBasePath += aEncodedJarFilePath; - aDestBasePath += rtl::OUString::createFromAscii( "/" ); - - sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; - - Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); - sal_Int32 nSubLangCount = aSubLangSeq.getLength(); - const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); - for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + rtl::OUString aLangURL = pSeq[iLang]; + if( xSFA->isFolder( aLangURL ) ) { - rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; - if( !xSFA->isFolder( aSubFolderURL ) ) - continue; - - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + std::vector< rtl::OUString > aXhpFileVector; + + // calculate jar file URL + sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); + // for example "/en" + OUString langFolderURLSegment( + aLangURL.copy( + indexStartSegment + 1, aLangURL.getLength() - indexStartSegment - 1)); + + //create the folder in the "temporary folder" + ::ucbhelper::Content langFolderContent; + const OUString langFolderDest = makeURL(sHelpFolder, langFolderURLSegment); + const OUString langFolderDestExpanded = ::dp_misc::expandUnoRcUrl(langFolderDest); + ::dp_misc::create_folder( + &langFolderContent, + langFolderDest, xCmdEnv); + + rtl::OUString aJarFile( + makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + + OUSTR(".jar"))); + aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); + + rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( + aJarFile, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.zip://" ); + aDestBasePath += aEncodedJarFilePath; + aDestBasePath += rtl::OUString::createFromAscii( "/" ); + + sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; + + Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); + sal_Int32 nSubLangCount = aSubLangSeq.getLength(); + const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); + for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + { + rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; + if( !xSFA->isFolder( aSubFolderURL ) ) + continue; - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // Call compiler - sal_Int32 nXhpFileCount = aXhpFileVector.size(); - rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = aXhpFileVector[iXhp]; - rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); - pXhpFiles[iXhp] = aXhpRelFile; - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + // Call compiler + sal_Int32 nXhpFileCount = aXhpFileVector.size(); + rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; + for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) + { + rtl::OUString aXhpFile = aXhpFileVector[iXhp]; + rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); + pXhpFiles[iXhp] = aXhpRelFile; + } - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( - aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, - langFolderDestExpanded, aErrorInfo ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - if( bSuccess && xInvocation.is() ) - { - Sequence<uno::Any> aParamsSeq( 6 ); - - aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); - - rtl::OUString aLang; - sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); - if( nLastSlash != -1 ) - aLang = aLangURL.copy( nLastSlash + 1 ); - else - aLang = rtl::OUString::createFromAscii( "en" ); - aParamsSeq[1] = uno::makeAny( aLang ); - - aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); - aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); - - aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); - rtl::OUString aSystemPath; - osl::FileBase::getSystemPathFromFileURL( - langFolderDestExpanded, aSystemPath ); - aParamsSeq[5] = uno::makeAny( aSystemPath ); - - Sequence< sal_Int16 > aOutParamIndex; - Sequence< uno::Any > aOutParam; - uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), - aParamsSeq, aOutParamIndex, aOutParam ); - } + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( + aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, + langFolderDestExpanded, aErrorInfo ); - if( !bSuccess ) - { - USHORT nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + if( bSuccess && xInvocation.is() ) { - case HELPPROCESSING_GENERAL_ERROR: - case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; - case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; - default: ; - }; - - rtl::OUString aErrStr; - if( nErrStrId != 0 ) + Sequence<uno::Any> aParamsSeq( 6 ); + + aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); + + rtl::OUString aLang; + sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); + if( nLastSlash != -1 ) + aLang = aLangURL.copy( nLastSlash + 1 ); + else + aLang = rtl::OUString::createFromAscii( "en" ); + aParamsSeq[1] = uno::makeAny( aLang ); + + aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); + aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); + + aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); + rtl::OUString aSystemPath; + osl::FileBase::getSystemPathFromFileURL( + langFolderDestExpanded, aSystemPath ); + aParamsSeq[5] = uno::makeAny( aSystemPath ); + + Sequence< sal_Int16 > aOutParamIndex; + Sequence< uno::Any > aOutParam; + uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), + aParamsSeq, aOutParamIndex, aOutParam ); + } + + if( !bSuccess ) { - aErrStr = getResourceString( nErrStrId ); - - // Remoce CR/LF - rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); - sal_Unicode nCR = 13, nLF = 10; - sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); - sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); - sal_Int32 nCopy; - if( nSearchCR != -1 || nSearchLF != -1 ) + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) { - if( nSearchCR == -1 ) - nCopy = nSearchLF; - else if( nSearchLF == -1 ) - nCopy = nSearchCR; - else - nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; - - aErrMsg = aErrMsg.copy( 0, nCopy ); - } - aErrStr += aErrMsg; - if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) + case HELPPROCESSING_GENERAL_ERROR: + case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; + case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; + default: ; + }; + + rtl::OUString aErrStr; + if( nErrStrId != 0 ) { - aErrStr += rtl::OUString::createFromAscii( " in " ); - - rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - aErrStr += aDecodedFile; - if( aErrorInfo.m_nXMLParsingLine != -1 ) + aErrStr = getResourceString( nErrStrId ); + + // Remoce CR/LF + rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); + sal_Unicode nCR = 13, nLF = 10; + sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); + sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); + sal_Int32 nCopy; + if( nSearchCR != -1 || nSearchLF != -1 ) + { + if( nSearchCR == -1 ) + nCopy = nSearchLF; + else if( nSearchLF == -1 ) + nCopy = nSearchCR; + else + nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; + + aErrMsg = aErrMsg.copy( 0, nCopy ); + } + aErrStr += aErrMsg; + if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) { - aErrStr += rtl::OUString::createFromAscii( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + aErrStr += rtl::OUString::createFromAscii( " in " ); + + rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + aErrStr += aDecodedFile; + if( aErrorInfo.m_nXMLParsingLine != -1 ) + { + aErrStr += rtl::OUString::createFromAscii( ", line " ); + aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + } } } - } - OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + } } } } + //Writing the data entry replaces writing the flag file. If we got to this + //point the registration was successful. + addDataToDb(xPackage->getURL(), data); } - //Writing the data entry replaces writing the flag file. If we got to this - //point the registration was successful. - addDataToDb(xPackage->getURL(), data); } //if (doRegisterPackage) else { - deleteDataFromDb(xPackage->getURL()); + revokeEntryFromDb(xPackage->getURL()); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 8ec9a39d5050..81057f744640 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -83,11 +83,14 @@ OUString HelpBackendDb::getKeyElementName() void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> helpNode - = writeKeyElement(url); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> helpNode + = writeKeyElement(url); - writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); - save(); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + save(); + } } catch (css::deployment::DeploymentException& ) { diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index c7b730fd1b99..bcff008c00ae 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -76,6 +76,8 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); ::boost::optional<Data> getEntry(::rtl::OUString const & url); + //must also return the data urls for entries with @activ="false". That is, + //those are currently revoked. ::std::list< ::rtl::OUString> getAllDataUrls(); }; diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 20fc2a8dc7e1..80aec2402a59 100755 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -299,7 +299,7 @@ protected: // currently only for library containers: enum { CONTEXT_UNKNOWN, - CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, + CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, CONTEXT_BUNDLED_PREREG, CONTEXT_DOCUMENT } m_eContext; bool m_readOnly; @@ -345,6 +345,18 @@ protected: static void deleteTempFolder( ::rtl::OUString const & folderUrl); + ::rtl::OUString getSharedRegistrationDataURL( + css::uno::Reference<css::deployment::XPackage> const & extension, + css::uno::Reference<css::deployment::XPackage> const & item); + + /* The backends must implement this function, which is called + from XPackageRegistry::packageRemoved (also implemented here). + This ensure that the backends clean up their registration data + when an extension was removed. + */ +// virtual void deleteDbEntry( ::rtl::OUString const & url) = 0; + + public: struct StrRegisteringPackage : public ::dp_misc::StaticResourceString< @@ -373,6 +385,12 @@ public: css::deployment::InvalidRemovedParameterException, css::ucb::CommandFailedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); + +// virtual void SAL_CALL packageRemoved( +// ::rtl::OUString const & url, ::rtl::OUString const & mediaType) +// throw (css::deployment::DeploymentException, +// css::uno::RuntimeException); + }; } diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index a0e477979f8c..299a6ec328ce 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -147,6 +147,18 @@ public: virtual ~BackendDb() {}; void removeEntry(::rtl::OUString const & url); + + /* This is called to write the "revoked" attribute to the entry. + This is done when XPackage::revokePackage is called. + */ + void revokeEntry(::rtl::OUString const & url); + + /* returns false if the entry does not exist yet. + */ + bool activateEntry(::rtl::OUString const & url); + + bool hasActiveEntry(::rtl::OUString const & url); + }; class RegisteredDb: public BackendDb diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 2e92a907f8fb..660d6bb374c3 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -82,15 +82,19 @@ OUString ExtensionBackendDb::getKeyElementName() void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url); - writeVectorOfPair( - data.items, - OUSTR("extension-items"), - OUSTR("item"), - OUSTR("url"), - OUSTR("media-type"), - extensionNodeNode); - save(); + //reactive revoked entry if possible. + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url); + writeVectorOfPair( + data.items, + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), + extensionNodeNode); + save(); + } } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 262bbef420f2..d247597a808f 100755..100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -250,7 +250,7 @@ class BackendImpl : public ImplBaseT void addDataToDb(OUString const & url, ExtensionBackendDb::Data const & data); ExtensionBackendDb::Data readDataFromDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( @@ -276,6 +276,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using ImplBaseT::disposing; }; @@ -360,6 +363,21 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + //Notify the backend responsible for processing the different media + //types that this extension was removed. + ExtensionBackendDb::Data data = readDataFromDb(url); + for (ExtensionBackendDb::Data::ITC_ITEMS i = data.items.begin(); i != data.items.end(); i++) + { + m_xRootRegistry->packageRemoved(i->first, i->second); + } + + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend @@ -460,10 +478,10 @@ ExtensionBackendDb::Data BackendImpl::readDataFromDb( return data; } -void BackendImpl::deleteDataFromDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + m_backendDb->revokeEntry(url); } @@ -973,7 +991,7 @@ void BackendImpl::PackageImpl::processPackage_( // selected } } - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); } } diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index edeae256cbaf..dddf82e09790 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -101,13 +101,8 @@ class BackendImpl : public t_helper Reference<XCommandEnvironment> const & xCmdEnv ); void addDataToDb(OUString const & url); - void deleteDataFromDb(OUString const & url); - bool isRegisteredInDb(OUString const & url); - - - -// Reference< ucb::XSimpleFileAccess > getFileAccess( void ); -// Reference< ucb::XSimpleFileAccess > m_xSFA; + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); const Reference<deployment::XPackageTypeInfo> m_xBasicLibTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xDialogLibTypeInfo; @@ -123,6 +118,10 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + }; //______________________________________________________________________________ @@ -191,18 +190,11 @@ void BackendImpl::addDataToDb(OUString const & url) m_backendDb->addEntry(url); } -bool BackendImpl::isRegisteredInDb(OUString const & url) +bool BackendImpl::hasActiveEntry(OUString const & url) { - bool registered = false; if (m_backendDb.get()) - registered = m_backendDb->getEntry(url); - return registered; -} - -void BackendImpl::deleteDataFromDb(OUString const & url) -{ - if (m_backendDb.get()) - m_backendDb->removeEntry(url); + return m_backendDb->hasActiveEntry(url); + return false; } // XUpdatable @@ -219,6 +211,19 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) { return m_typeInfos; } +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); +} + +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend //______________________________________________________________________________ @@ -321,7 +326,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - bool registered = that->isRegisteredInDb(getURL()); + bool registered = that->hasActiveEntry(getURL()); return beans::Optional< beans::Ambiguous<sal_Bool> >( true /* IsPresent */, beans::Ambiguous<sal_Bool>( registered, false /* IsAmbiguous */ ) ); @@ -367,7 +372,7 @@ void BackendImpl::PackageImpl::processPackage_( xComponentContext ), UNO_QUERY_THROW ); } } - bool bRegistered = getMyBackend()->isRegisteredInDb(getURL()); + bool bRegistered = getMyBackend()->hasActiveEntry(getURL()); if( !doRegisterPackage ) { //We cannot just call removeLibrary(name) because this could remove a @@ -399,7 +404,7 @@ void BackendImpl::PackageImpl::processPackage_( xDialogLibs->removeLibrary(m_dialogName); } } - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); return; } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index f3195701fc7c..7e4be0f4e35a 100755 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -100,6 +100,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const Reference<deployment::XPackageTypeInfo> m_xTypeInfo; + public: BackendImpl( Sequence<Any> const & args, @@ -108,6 +109,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); }; BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -218,6 +222,8 @@ BackendImpl::BackendImpl( } } + + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference<deployment::XPackageTypeInfo> > @@ -226,6 +232,12 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return Sequence< Reference<deployment::XPackageTypeInfo> >(&m_xTypeInfo, 1); } +void BackendImpl::packageRemoved(OUString const & /*url*/, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -338,6 +350,11 @@ void BackendImpl::PackageImpl:: initPackageHandler() { aContext <<= OUSTR("bundled"); } + else if ( that->m_eContext == CONTEXT_BUNDLED_PREREG ) + { + aContext <<= OUSTR("bundled_prereg"); + } + else { OSL_ASSERT( 0 ); diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 4545ed862271..83552cb7c4c6 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -380,7 +380,12 @@ extern "C" int unopkg_main() } else if (subCommand.equals(OUSTR("sync"))) { - //sync is private!!!! Only for bundled extensions!!! + //sync is private!!!! Only to be called from setup!!! + //The UserInstallation is diverted to the prereg folder. But only + //the lock file is written! This requires that + //-env:UNO_JAVA_JFW_INSTALL_DATA is passed to javaldx and unopkg otherwise the + //javasettings file is written to the prereg folder. + // //For performance reasons unopkg sync is called during the setup and //creates the registration data for the repository of the bundled //extensions. It is then copied to the user installation during @@ -395,10 +400,21 @@ extern "C" int unopkg_main() //$BUNDLED_EXTENSIONS_USER if (hasNoFolder(OUSTR("$BRAND_BASE_DIR/share/extensions"))) { - removeFolder(OUSTR("$BUNDLED_EXTENSIONS_USER")); + removeFolder(OUSTR("$BUNDLED_EXTENSIONS_PREREG")); //return otherwise we create the registration data again return 0; } + //redirect the UserInstallation, so we do not create a + //user installation for the admin and we also do not need + //to call unopkg with -env:UserInstallation + ::rtl::Bootstrap::set(OUSTR("UserInstallation"), + OUSTR("$BUNDLED_EXTENSIONS_PREREG/..")); + //Setting UNO_JAVA_JFW_INSTALL_DATA causes the javasettings to be written + //in the office installation. We do not want to create the user data folder + //for the admin. The value must also be set in the unopkg script (Linux, etc.) + //when calling javaldx + ::rtl::Bootstrap::set(OUSTR("UNO_JAVA_JFW_INSTALL_DATA"), + OUSTR("$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")); } @@ -418,6 +434,7 @@ extern "C" int unopkg_main() //prevent the deletion of the registry data folder //synching is done in XExtensionManager.reinstall if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall")) + && ! subCommand.equals(OUSTR("sync")) && ! dp_misc::office_is_running()) dp_misc::syncRepositories(xCmdEnv); @@ -613,12 +630,15 @@ extern "C" int unopkg_main() } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("sync"))) { - //This sub command may be removed later and is only there to have a - //possibility to start extension synching without any output. - //This is just here so we do not get an error, because of an unknown - //sub-command. We do synching before - //the sub-commands are processed. - + if (! dp_misc::office_is_running()) + { + xExtensionManager->synchronizeBundledPrereg( + Reference<task::XAbortChannel>(), xCmdEnv); + } + else + { + dp_misc::writeConsoleError(OUSTR("\nError: office is running")); + } } else { diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index d7b6e1ca2336..f6773b768062 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -396,6 +396,7 @@ Reference<XComponentContext> bootstrapStandAlone( if (! ::ucbhelper::ContentBroker::initialize( xServiceManager, ucb_args )) throw RuntimeException( OUSTR("cannot initialize UCB!"), 0 ); + disposeGuard.setDeinitUCB(); return xContext; } @@ -627,7 +628,7 @@ void removeFolder(OUString const & folderUrl) dir.close(); ::osl::Directory::remove(url); } - else + else if (rc != osl::File::E_NOENT) { dp_misc::writeConsole( OUSTR("unopkg: Error while removing ") + url + OUSTR("\n")); diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 4975cc4c087b..55c86260ca8f 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -34,6 +34,7 @@ #include "tools/resmgr.hxx" #include "rtl/ustring.hxx" #include "unotools/configmgr.hxx" +#include "ucbhelper/contentbroker.hxx" #define APP_NAME "unopkg" @@ -137,15 +138,14 @@ bool isBootstrapVariable(sal_uInt32 * pIndex); class DisposeGuard { css::uno::Reference<css::lang::XComponent> m_xComp; - + bool m_bDeinitUCB; public: - inline DisposeGuard() {} - inline DisposeGuard( - css::uno::Reference<css::lang::XComponent> const & xComp ) - : m_xComp( xComp ) {} - + DisposeGuard(): m_bDeinitUCB(false) {} inline ~DisposeGuard() { + if (m_bDeinitUCB) + ::ucbhelper::ContentBroker::deinitialize(); + if (m_xComp.is()) m_xComp->dispose(); } @@ -155,6 +155,12 @@ public: { m_xComp = xComp; } + + inline void setDeinitUCB() + { + m_bDeinitUCB = true; + } + }; //============================================================================== diff --git a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx index 80e34ba27701..752bf6d13849 100644 --- a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx +++ b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx @@ -84,19 +84,18 @@ namespace drawinglayer aOutlineRange.transform(aSimpleObjectMatrix); } - // prepare dest coor - const sal_uInt32 nDiscreteWidth(basegfx::fround(aOutlineRange.getMaxX())); - const sal_uInt32 nDiscreteHeight(basegfx::fround(aOutlineRange.getMaxY())); - const Rectangle aDestRectPixel( - basegfx::fround(aOutlineRange.getMinX()), - basegfx::fround(aOutlineRange.getMinY()), - nDiscreteWidth > 0 ? nDiscreteWidth - 1 : 0, - nDiscreteHeight > 0 ? nDiscreteHeight - 1 : 0); + // prepare dest coordinates + const Point aPoint( + basegfx::fround(aOutlineRange.getMinX()), + basegfx::fround(aOutlineRange.getMinY())); + const Size aSize( + basegfx::fround(aOutlineRange.getWidth()), + basegfx::fround(aOutlineRange.getHeight())); // paint it using GraphicManager Graphic aGraphic(rBitmapEx); GraphicObject aGraphicObject(aGraphic); - aGraphicObject.Draw(&rOutDev, aDestRectPixel.TopLeft(), aDestRectPixel.GetSize(), &aAttributes); + aGraphicObject.Draw(&rOutDev, aPoint, aSize, &aAttributes); } void RenderBitmapPrimitive2D_BitmapEx( @@ -110,13 +109,13 @@ namespace drawinglayer // prepare dest coor. Necessary to expand since vcl's DrawBitmapEx draws one pix less basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); aOutlineRange.transform(rTransform); - const sal_uInt32 nDiscreteWidth(basegfx::fround(aOutlineRange.getMaxX())); - const sal_uInt32 nDiscreteHeight(basegfx::fround(aOutlineRange.getMaxY())); - const Rectangle aDestRectPixel( - basegfx::fround(aOutlineRange.getMinX()), - basegfx::fround(aOutlineRange.getMinY()), - nDiscreteWidth > 0 ? nDiscreteWidth - 1 : 0, - nDiscreteHeight > 0 ? nDiscreteHeight - 1 : 0); + // prepare dest coordinates + const Point aPoint( + basegfx::fround(aOutlineRange.getMinX()), + basegfx::fround(aOutlineRange.getMinY())); + const Size aSize( + basegfx::fround(aOutlineRange.getWidth()), + basegfx::fround(aOutlineRange.getHeight())); // decompose matrix to check for shear, rotate and mirroring basegfx::B2DVector aScale, aTranslate; @@ -142,7 +141,7 @@ namespace drawinglayer } // draw bitmap - rOutDev.DrawBitmapEx(aDestRectPixel.TopLeft(), aDestRectPixel.GetSize(), aContent); + rOutDev.DrawBitmapEx(aPoint, aSize, aContent); } void RenderBitmapPrimitive2D_self( @@ -153,13 +152,11 @@ namespace drawinglayer // process self with free transformation (containing shear and rotate). Get dest rect in pixels. basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); aOutlineRange.transform(rTransform); - const sal_uInt32 nDiscreteWidth(basegfx::fround(aOutlineRange.getMaxX())); - const sal_uInt32 nDiscreteHeight(basegfx::fround(aOutlineRange.getMaxY())); const Rectangle aDestRectLogic( basegfx::fround(aOutlineRange.getMinX()), basegfx::fround(aOutlineRange.getMinY()), - nDiscreteWidth > 0 ? nDiscreteWidth - 1 : 0, - nDiscreteHeight > 0 ? nDiscreteHeight - 1 : 0); + basegfx::fround(aOutlineRange.getMaxX()), + basegfx::fround(aOutlineRange.getMaxY())); const Rectangle aDestRectPixel(rOutDev.LogicToPixel(aDestRectLogic)); // #i96708# check if Metafile is recorded diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 7e53a5dfa5c4..69b45f468c82 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1379,6 +1379,7 @@ namespace drawinglayer { // need to handle PolyPolygonHatchPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END const primitive2d::PolyPolygonHatchPrimitive2D& rHatchCandidate = static_cast< const primitive2d::PolyPolygonHatchPrimitive2D& >(rCandidate); + const attribute::FillHatchAttribute& rFillHatchAttribute = rHatchCandidate.getFillHatch(); basegfx::B2DPolyPolygon aLocalPolyPolygon(rHatchCandidate.getB2DPolyPolygon()); // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points @@ -1386,8 +1387,20 @@ namespace drawinglayer while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) ; + if(rFillHatchAttribute.isFillBackground()) + { + // with fixing #i111954# (see below) the possible background + // fill of a hatched object was lost.Generate a background fill + // primitive and render it + const primitive2d::Primitive2DReference xBackground( + new primitive2d::PolyPolygonColorPrimitive2D( + aLocalPolyPolygon, + rHatchCandidate.getBackgroundColor())); + + process(primitive2d::Primitive2DSequence(&xBackground, 1)); + } + SvtGraphicFill* pSvtGraphicFill = 0; - const attribute::FillHatchAttribute& rFillHatchAttribute = rHatchCandidate.getFillHatch(); aLocalPolyPolygon.transform(maCurrentTransformation); if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count()) diff --git a/editeng/inc/editeng/editeng.hxx b/editeng/inc/editeng/editeng.hxx index 84f4802e7b44..642c290f4853 100755 --- a/editeng/inc/editeng/editeng.hxx +++ b/editeng/inc/editeng/editeng.hxx @@ -33,7 +33,6 @@ class EditView; class OutputDevice; class EditUndo; class SvxFont; -class SfxUndoManager; class SfxItemPool; class SfxStyleSheet; class String; @@ -83,6 +82,9 @@ namespace svx{ struct SpellPortion; typedef std::vector<SpellPortion> SpellPortions; } +namespace svl{ +class IUndoManager; +} namespace basegfx { class B2DPolyPolygon; } #include <rsc/rscsfx.hxx> @@ -268,7 +270,8 @@ public: void ShowParagraph( USHORT nParagraph, BOOL bShow = TRUE ); BOOL IsParagraphVisible( USHORT nParagraph ); - SfxUndoManager& GetUndoManager(); + ::svl::IUndoManager& + GetUndoManager(); void UndoActionStart( USHORT nId ); void UndoActionEnd( USHORT nId ); BOOL IsInUndo(); diff --git a/editeng/inc/editeng/editund2.hxx b/editeng/inc/editeng/editund2.hxx index 4d037a72c9b9..14091ea3e1a7 100644 --- a/editeng/inc/editeng/editund2.hxx +++ b/editeng/inc/editeng/editund2.hxx @@ -33,7 +33,7 @@ class ImpEditEngine; -class EDITENG_DLLPUBLIC EditUndoManager : public SfxUndoManager +class EDITENG_DLLPRIVATE EditUndoManager : public SfxUndoManager { using SfxUndoManager::Undo; using SfxUndoManager::Redo; @@ -43,8 +43,8 @@ private: public: EditUndoManager( ImpEditEngine* pImpEE ); - virtual BOOL Undo( USHORT nCount=1 ); - virtual BOOL Redo( USHORT nCount=1 ); + virtual BOOL Undo(); + virtual BOOL Redo(); }; // ----------------------------------------------------------------------- diff --git a/editeng/inc/editeng/outliner.hxx b/editeng/inc/editeng/outliner.hxx index d167d2a30f8f..900ee69af2d5 100644 --- a/editeng/inc/editeng/outliner.hxx +++ b/editeng/inc/editeng/outliner.hxx @@ -74,10 +74,15 @@ class SfxItemSet; class SvxNumBulletItem; class SvxNumberFormat; class SvxLRSpaceItem; -class SfxUndoManager; class EditEngine; class SvKeyValueIterator; class SvxForbiddenCharactersTable; + +namespace svl +{ + class IUndoManager; +} + #include <com/sun/star/uno/Reference.h> #include <vos/ref.hxx> @@ -938,7 +943,8 @@ public: // nFormat muss ein Wert aus dem enum EETextFormat sein (wg.CLOOKS) ULONG Read( SvStream& rInput, const String& rBaseURL, USHORT, SvKeyValueIterator* pHTTPHeaderAttrs = NULL ); - SfxUndoManager& GetUndoManager(); + ::svl::IUndoManager& + GetUndoManager(); void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ); void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ); diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx index d53bfcf1aaf2..83f0ab6c54e8 100644..100755 --- a/editeng/inc/pch/precompiled_editeng.hxx +++ b/editeng/inc/pch/precompiled_editeng.hxx @@ -853,7 +853,7 @@ #include "vcl/cursor.hxx" #include "vcl/decoview.hxx" #include "vcl/dndhelp.hxx" -#include "vcl/fldunit.hxx" +#include "tools/fldunit.hxx" #include "vcl/fntstyle.hxx" #include "unotools/fontcvt.hxx" #include "vcl/gdimtf.hxx" @@ -872,7 +872,7 @@ #include "vcl/unohelp.hxx" #include "vcl/unohelp2.hxx" #include "vcl/wall.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vos/mutex.hxx" #include "vos/ref.hxx" #include "vos/refernce.hxx" diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 1b61a405dc18..74527ec2b86f 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -145,7 +145,7 @@ sal_Bool EditEngine::IsInUndo() return pImpEditEngine->IsInUndo(); } -SfxUndoManager& EditEngine::GetUndoManager() +::svl::IUndoManager& EditEngine::GetUndoManager() { DBG_CHKTHIS( EditEngine, 0 ); return pImpEditEngine->GetUndoManager(); diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index 054971c240fd..f2f28642209c 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -74,7 +74,7 @@ EditUndoManager::EditUndoManager( ImpEditEngine* p ) pImpEE = p; } -BOOL __EXPORT EditUndoManager::Undo( USHORT nCount ) +BOOL __EXPORT EditUndoManager::Undo() { if ( GetUndoActionCount() == 0 ) return FALSE; @@ -95,7 +95,7 @@ BOOL __EXPORT EditUndoManager::Undo( USHORT nCount ) pImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen pImpEE->SetUndoMode( TRUE ); - BOOL bDone = SfxUndoManager::Undo( nCount ); + BOOL bDone = SfxUndoManager::Undo(); pImpEE->SetUndoMode( FALSE ); EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() ); @@ -109,7 +109,7 @@ BOOL __EXPORT EditUndoManager::Undo( USHORT nCount ) return bDone; } -BOOL __EXPORT EditUndoManager::Redo( USHORT nCount ) +BOOL __EXPORT EditUndoManager::Redo() { if ( GetRedoActionCount() == 0 ) return FALSE; @@ -130,7 +130,7 @@ BOOL __EXPORT EditUndoManager::Redo( USHORT nCount ) pImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen pImpEE->SetUndoMode( TRUE ); - BOOL bDone = SfxUndoManager::Redo( nCount ); + BOOL bDone = SfxUndoManager::Redo(); pImpEE->SetUndoMode( FALSE ); EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() ); diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 2efbb60b6c0f..d03f6bc40cea 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -310,7 +310,7 @@ BOOL ImpEditEngine::Undo( EditView* pView ) if ( HasUndoManager() && GetUndoManager().GetUndoActionCount() ) { SetActiveView( pView ); - GetUndoManager().Undo( 1 ); + GetUndoManager().Undo(); return TRUE; } return FALSE; @@ -321,7 +321,7 @@ BOOL ImpEditEngine::Redo( EditView* pView ) if ( HasUndoManager() && GetUndoManager().GetRedoActionCount() ) { SetActiveView( pView ); - GetUndoManager().Redo( 0 ); + GetUndoManager().Redo(); return TRUE; } return FALSE; diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 328a762fec54..19b5b67e28d4 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1227,7 +1227,7 @@ void Outliner::ImpFilterIndents( ULONG nFirstPara, ULONG nLastPara ) pEditEngine->SetUpdateMode( bUpdate ); } -SfxUndoManager& Outliner::GetUndoManager() +::svl::IUndoManager& Outliner::GetUndoManager() { DBG_CHKTHIS(Outliner,0); return pEditEngine->GetUndoManager(); diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 3d360245f1ea..a459c0ad9bd3 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -165,7 +165,7 @@ void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) { // TODO: may be needs interaction handler to detect wherether the object state - // can be changed even after errors + // can be changed even after errors if ( m_nObjectState == embed::EmbedStates::LOADED ) { @@ -235,7 +235,10 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) { if ( !m_xClientSite.is() ) - throw embed::WrongStateException(); //TODO: client site is not set! + throw embed::WrongStateException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "client site not set, yet" ) ), + *this + ); uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() ) @@ -485,14 +488,19 @@ void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState ) { if ( nOldState != m_nObjectState ) // notify listeners that the object has changed the state - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ,aGuard); + StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState, aGuard ); throw; } } // notify listeners that the object has changed the state - StateChangeNotification_Impl( sal_False, nOldState, nNewState,aGuard ); + StateChangeNotification_Impl( sal_False, nOldState, nNewState, aGuard ); + + // let the object window be shown + if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE ) + PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ), + uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); } } @@ -501,7 +509,6 @@ uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates() throw ( embed::WrongStateException, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -517,7 +524,6 @@ sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState() throw ( embed::WrongStateException, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -538,7 +544,7 @@ void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID ) { RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" ); - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ResettableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -561,7 +567,10 @@ void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID ) // TODO/LATER: check if the verb is a supported one and if it is produce related operation } else + { + aGuard.clear(); changeState( nNewState ); + } } //---------------------------------------------- @@ -569,7 +578,6 @@ uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSuppor throw ( embed::WrongStateException, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -606,7 +614,6 @@ uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClie throw ( embed::WrongStateException, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -659,7 +666,6 @@ sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 ) throw ( embed::WrongStateException, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index e0ff1266921a..f4c0c90162ed 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -342,7 +342,7 @@ void OCommonEmbeddedObject::PostEvent_Impl( const ::rtl::OUString& aEventName, aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ); // For now all the events are sent as object events // aEvent.Source = ( xSource.is() ? xSource - // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); + // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); ::cppu::OInterfaceIteratorHelper aIt( *pIC ); while( aIt.hasMoreElements() ) { @@ -476,9 +476,8 @@ uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getImplementationId() uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getClassID() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) - throw lang::DisposedException(); // TODO + throw lang::DisposedException(); return m_aClassID; } @@ -487,9 +486,8 @@ uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getClassID() ::rtl::OUString SAL_CALL OCommonEmbeddedObject::getClassName() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) - throw lang::DisposedException(); // TODO + throw lang::DisposedException(); return m_aClassName; } @@ -521,9 +519,9 @@ uno::Reference< util::XCloseable > SAL_CALL OCommonEmbeddedObject::getComponent( } // if ( m_bWaitSaveCompleted ) - // throw embed::WrongStateException( - // ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), - // uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + // throw embed::WrongStateException( + // ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), + // uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); return uno::Reference< util::XCloseable >( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); } diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx index 21839554aefc..c203924f6e51 100644 --- a/fpicker/source/office/OfficeFilePicker.hxx +++ b/fpicker/source/office/OfficeFilePicker.hxx @@ -42,7 +42,7 @@ #endif -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include "commonpicker.hxx" #include "pickercallbacks.hxx" diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx index fdf4866daf24..cfb3574f702e 100644 --- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx @@ -1445,7 +1445,7 @@ uno::Sequence<sal_Int16> SAL_CALL SalGtkFilePicker::getSupportedImageFormats() t OSL_ASSERT( m_pDialog != NULL ); // TODO return m_pImpl->getSupportedImageFormats(); - return 0; + return uno::Sequence<sal_Int16>(); } sal_Int32 SAL_CALL SalGtkFilePicker::getTargetColorDepth() throw( uno::RuntimeException ) diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk index 33d8959a474e..86abf25f4f95 100644 --- a/framework/Library_fwe.mk +++ b/framework/Library_fwe.mk @@ -77,6 +77,8 @@ $(eval $(call gb_Library_add_exception_objects,fwe,\ framework/source/fwe/helper/imageproducer \ framework/source/fwe/helper/propertysetcontainer \ framework/source/fwe/helper/titlehelper \ + framework/source/fwe/helper/documentundoguard \ + framework/source/fwe/helper/undomanagerhelper \ framework/source/fwe/helper/uiconfigelementwrapperbase \ framework/source/fwe/helper/uielementwrapperbase \ framework/source/fwe/interaction/preventduplicateinteraction \ @@ -105,11 +107,24 @@ $(eval $(call gb_Library_add_linked_libs,fwe,\ )) endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,fwe,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + mingwex \ + kernel32 \ + msvcrt \ +)) +else $(eval $(call gb_Library_add_linked_libs,fwe,\ kernel32 \ msvcrt \ uwinapi \ )) endif +endif # TODO: visibility # vim: set noet sw=4 ts=4: diff --git a/framework/Library_fwi.mk b/framework/Library_fwi.mk index 568f0a1eb22a..8512b3a874fe 100644 --- a/framework/Library_fwi.mk +++ b/framework/Library_fwi.mk @@ -84,6 +84,21 @@ $(eval $(call gb_Library_add_linked_libs,fwi,\ )) endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,fwi,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + kernel32 \ + msvcrt \ + unicows \ +)) +else $(eval $(call gb_Library_add_linked_libs,fwi,\ advapi32 \ kernel32 \ @@ -93,5 +108,6 @@ $(eval $(call gb_Library_add_linked_libs,fwi,\ uwinapi \ )) endif +endif # TODO: visibility # vim: set noet sw=4 ts=4: diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index 50c16b83b42a..1df0c931e564 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -190,10 +190,23 @@ $(eval $(call gb_Library_add_linked_libs,fwk,\ )) endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,fwk,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + mingwex \ + kernel32 \ + msvcrt \ +)) +else $(eval $(call gb_Library_add_linked_libs,fwk,\ kernel32 \ msvcrt \ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/framework/Library_fwl.mk b/framework/Library_fwl.mk index d2002115eaf0..b8b5290f1749 100644 --- a/framework/Library_fwl.mk +++ b/framework/Library_fwl.mk @@ -90,10 +90,23 @@ $(eval $(call gb_Library_add_linked_libs,fwl,\ )) endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,fwl,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + mingwex \ + kernel32 \ + msvcrt \ +)) +else $(eval $(call gb_Library_add_linked_libs,fwl,\ kernel32 \ msvcrt \ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/framework/Library_fwm.mk b/framework/Library_fwm.mk index 9ff49719148a..e67c2a627091 100644 --- a/framework/Library_fwm.mk +++ b/framework/Library_fwm.mk @@ -72,10 +72,23 @@ $(eval $(call gb_Library_add_linked_libs,fwm,\ )) endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,fwm,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + mingwex \ + kernel32 \ + msvcrt \ +)) +else $(eval $(call gb_Library_add_linked_libs,fwm,\ kernel32 \ msvcrt \ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/framework/Package_inc.mk b/framework/Package_inc.mk index adefc3ccbd56..9db346cf1acf 100644 --- a/framework/Package_inc.mk +++ b/framework/Package_inc.mk @@ -34,6 +34,10 @@ $(eval $(call gb_Package_add_file,framework_inc,inc/framework/bmkmenu.hxx,framew $(eval $(call gb_Package_add_file,framework_inc,inc/framework/configimporter.hxx,framework/configimporter.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/eventsconfiguration.hxx,framework/eventsconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/framelistanalyzer.hxx,framework/framelistanalyzer.hxx)) +$(eval $(call gb_Package_add_file,framework_inc,inc/framework/documentundoguard.hxx,framework/documentundoguard.hxx)) +$(eval $(call gb_Package_add_file,framework_inc,inc/framework/undomanagerhelper.hxx,framework/undomanagerhelper.hxx)) +$(eval $(call gb_Package_add_file,framework_inc,inc/framework/imutex.hxx,framework/imutex.hxx)) +$(eval $(call gb_Package_add_file,framework_inc,inc/framework/iguard.hxx,framework/iguard.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imageproducer.hxx,framework/imageproducer.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imagesconfiguration.hxx,framework/imagesconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/interaction.hxx,framework/interaction.hxx)) diff --git a/framework/inc/framework/documentundoguard.hxx b/framework/inc/framework/documentundoguard.hxx new file mode 100755 index 000000000000..da2976e895e1 --- /dev/null +++ b/framework/inc/framework/documentundoguard.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef FRAMEWORK_DOCUMENTUNDOGUARD_HXX +#define FRAMEWORK_DOCUMENTUNDOGUARD_HXX + +#include "framework/fwedllapi.h" + +/** === begin UNO includes === **/ +#include <com/sun/star/uno/XInterface.hpp> +/** === end UNO includes === **/ + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + //================================================================================================================== + //= DocumentUndoGuard + //================================================================================================================== + struct DocumentUndoGuard_Data; + /** a helper class guarding the Undo manager of a document + + This class guards, within a given scope, the Undo Manager of a document (or another component supporting + the XUndoManagerSupplier interface). When entering the scope (i.e. when the <code>DocumentUndoGuard</code> + instances is constructed), the current state of the undo contexts of the undo manager is examined. + Upon leaving the scope (i.e. when the <code>DocumentUndoGuard</code> is destructed), the guard will execute + as many calls to <member scope="com::sun::star::document">XUndoManager::leaveUndoContext</member> as are + necessary to restore the manager's initial state. + */ + class FWE_DLLPUBLIC DocumentUndoGuard + { + public: + DocumentUndoGuard( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_undoSupplierComponent ); + ~DocumentUndoGuard(); + + private: + ::boost::scoped_ptr< DocumentUndoGuard_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... + +#endif // FRAMEWORK_DOCUMENTUNDOGUARD_HXX diff --git a/framework/inc/framework/iguard.hxx b/framework/inc/framework/iguard.hxx new file mode 100755 index 000000000000..7c00858b208d --- /dev/null +++ b/framework/inc/framework/iguard.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_THREADHELP_IGUARD_H_ +#define __FRAMEWORK_THREADHELP_IGUARD_H_ + +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#include <sal/types.h> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// declarations +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @descr interface for guarding a lock +*//*-*************************************************************************************************************/ +class SAL_NO_VTABLE IGuard +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + /** clears the lock. If the guard does not currently hold the lock, nothing happens. + */ + virtual void clear() = 0; + + /** attempts to re-establishes the lock, blocking until the attempt is successful. + */ + virtual void reset() = 0; + +}; // class IGuard + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_THREADHELP_IGUARD_H_ diff --git a/framework/inc/threadhelp/imutex.h b/framework/inc/framework/imutex.hxx index 70784c312b87..5466edc4cf76 100644 --- a/framework/inc/threadhelp/imutex.h +++ b/framework/inc/framework/imutex.hxx @@ -32,6 +32,8 @@ // includes //_________________________________________________________________________________________________________________ +#include <sal/types.h> + //_________________________________________________________________________________________________________________ // namespace //_________________________________________________________________________________________________________________ @@ -45,7 +47,7 @@ namespace framework{ /*-************************************************************************************************************//** @descr We need this interface to support using of different mutex implementations in a generic way. *//*-*************************************************************************************************************/ -class IMutex +class SAL_NO_VTABLE IMutex { //------------------------------------------------------------------------------------------------------------- // public methods diff --git a/framework/inc/framework/undomanagerhelper.hxx b/framework/inc/framework/undomanagerhelper.hxx new file mode 100755 index 000000000000..9cd7266b33c8 --- /dev/null +++ b/framework/inc/framework/undomanagerhelper.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef FRAMEWORK_UNDOMANAGERHELPER_HXX +#define FRAMEWORK_UNDOMANAGERHELPER_HXX + +#include "framework/fwedllapi.h" +#include "framework/iguard.hxx" +#include "framework/imutex.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/document/XUndoManager.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +/** === end UNO includes === **/ + +#include <boost/scoped_ptr.hpp> + +namespace svl +{ + class IUndoManager; +} + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + //================================================================================================================== + //= IMutexGuard + //================================================================================================================== + class SAL_NO_VTABLE IMutexGuard : public IGuard + { + public: + /** returns the mutex guarded by the instance. + + Even if the guard currently has not a lock on the mutex, this method must succeed. + */ + virtual IMutex& getGuardedMutex() = 0; + }; + + //================================================================================================================== + //= IUndoManagerImplementation + //================================================================================================================== + class SAL_NO_VTABLE IUndoManagerImplementation + { + public: + /** returns the IUndoManager interface to the actual Undo stack + + @throws com::sun::star::lang::DisposedException + when the instance is already disposed, and no IUndoManager can be provided + + @throws com::sun::star::lang::NotInitializedException + when the instance is not initialized, yet, and no IUndoManager can be provided + */ + virtual ::svl::IUndoManager& getImplUndoManager() = 0; + + /** provides access to an UNO interface for the XUndoManager implementation. Used when throwing exceptions. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > + getThis() = 0; + }; + + //================================================================================================================== + //= UndoManagerHelper + //================================================================================================================== + class UndoManagerHelper_Impl; + /** helper class for implementing an XUndoManager + + Several of the methods of the class take an IMutexGuard instance. It is assumed that this guard has a lock on + its mutext at the moment the method is entered. The lock will be released before any notifications to the + registered XUndoManagerListeners happen. + + The following locking strategy is used for this mutex: + <ul><li>Any notifications to the registered XUndoManagerListeners are after the guard has been cleared. i.e. + without the mutex being locked.</p> + <li>Any calls into the <code>IUndoManager</code> implementation is made without the mutex being locked. + Note that this implies that the <code>IUndoManager</code> implementation must be thread-safe in itself + (which is true for the default implementation, SfxUndoManager).</li> + <li>An exception to the previous item are the <member>IUndoManager::Undo</member> and + <member>IUndoManager::Redo</member> methods: They're called with the given external mutex being + locked.</li> + </ul> + + The reason for the exception for IUndoManager::Undo and IUndoManager::Redo is that those are expected to + modify the actual document which the UndoManager works for. And as long as our documents are not thread-safe, + and as long as we do not re-fit <strong>all</strong> existing SfxUndoImplementations to <em>not</em> expect + the dreaded SolarMutex being locked when they're called, the above behavior is a compromise between "how it should + be" and "how it can realistically be". + */ + class FWE_DLLPUBLIC UndoManagerHelper + { + public: + UndoManagerHelper( IUndoManagerImplementation& i_undoManagerImpl ); + ~UndoManagerHelper(); + + // life time control + void disposing(); + + // XUndoManager equivalents + void enterUndoContext( const ::rtl::OUString& i_title, IMutexGuard& i_instanceLock ); + void enterHiddenUndoContext( IMutexGuard& i_instanceLock ); + void leaveUndoContext( IMutexGuard& i_instanceLock ); + void addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action, IMutexGuard& i_instanceLock ); + void undo( IMutexGuard& i_instanceLock ); + void redo( IMutexGuard& i_instanceLock ); + ::sal_Bool isUndoPossible() const; + ::sal_Bool isRedoPossible() const; + ::rtl::OUString getCurrentUndoActionTitle() const; + ::rtl::OUString getCurrentRedoActionTitle() const; + ::com::sun::star::uno::Sequence< ::rtl::OUString > + getAllUndoActionTitles() const; + ::com::sun::star::uno::Sequence< ::rtl::OUString > + getAllRedoActionTitles() const; + void clear( IMutexGuard& i_instanceLock ); + void clearRedo( IMutexGuard& i_instanceLock ); + void reset( IMutexGuard& i_instanceLock ); + void addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ); + void removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ); + + // XLockable, base of XUndoManager, equivalents + void lock(); + void unlock(); + ::sal_Bool isLocked(); + + // XModifyBroadcaster equivalents + void addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& i_listener ); + void removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& i_listener ); + + private: + ::boost::scoped_ptr< UndoManagerHelper_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... + +#endif // FRAMEWORK_UNDOMANAGERHELPER_HXX diff --git a/framework/inc/pch/precompiled_framework.hxx b/framework/inc/pch/precompiled_framework.hxx index 45919a31047b..b4afb017ebab 100644 --- a/framework/inc/pch/precompiled_framework.hxx +++ b/framework/inc/pch/precompiled_framework.hxx @@ -463,7 +463,7 @@ #include "vcl/keycod.hxx" #include "vcl/keycodes.hxx" #include "vcl/lstbox.hxx" -#include "vcl/mapunit.hxx" +#include "tools/mapunit.hxx" #include "vcl/menu.hxx" #include "vcl/mnemonic.hxx" #include "vcl/morebtn.hxx" @@ -482,7 +482,7 @@ #include "vcl/timer.hxx" #include "vcl/wall.hxx" #include "vcl/window.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vos/mutex.hxx" #include "vos/process.hxx" diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 0110a0b40b9e..e6a638c654e9 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -85,7 +85,7 @@ #include <cppuhelper/implbase8.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <comphelper/propertycontainer.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <svtools/miscopt.hxx> #include <vcl/toolbox.hxx> #include <vcl/timer.hxx> diff --git a/framework/inc/threadhelp/lockhelper.hxx b/framework/inc/threadhelp/lockhelper.hxx index d6ebae6d4b9c..0210ad975c29 100644 --- a/framework/inc/threadhelp/lockhelper.hxx +++ b/framework/inc/threadhelp/lockhelper.hxx @@ -33,7 +33,7 @@ //_________________________________________________________________________________________________________________ #include <threadhelp/inoncopyable.h> -#include <threadhelp/imutex.h> +#include <framework/imutex.hxx> #include <threadhelp/irwlock.h> #include <threadhelp/fairrwlock.hxx> diff --git a/framework/inc/threadhelp/resetableguard.hxx b/framework/inc/threadhelp/resetableguard.hxx index 58830189e052..3b88294a80e3 100644 --- a/framework/inc/threadhelp/resetableguard.hxx +++ b/framework/inc/threadhelp/resetableguard.hxx @@ -33,7 +33,7 @@ //_________________________________________________________________________________________________________________ #include <threadhelp/inoncopyable.h> -#include <threadhelp/imutex.h> +#include <framework/imutex.hxx> //#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_ //#include <threadhelp/threadhelpbase.hxx> diff --git a/framework/prj/build.lst b/framework/prj/build.lst index 2c847918fee4..3a2eb98457f7 100644 --- a/framework/prj/build.lst +++ b/framework/prj/build.lst @@ -1,2 +1,3 @@ fr framework : LIBXSLT:libxslt l10n svtools NULL fr framework\prj nmake - all fr_all NULL +fr framework\qa\unoapi nmake - all fr_qa_unoapi NULL diff --git a/framework/qa/unoapi/makefile.mk b/framework/qa/unoapi/makefile.mk new file mode 100644 index 000000000000..38a6cf7cced8 --- /dev/null +++ b/framework/qa/unoapi/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# 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 +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../.. +PRJNAME = framework +TARGET = qa_unoapi + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/framework/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/framework/source/fwe/helper/documentundoguard.cxx b/framework/source/fwe/helper/documentundoguard.cxx new file mode 100755 index 000000000000..91265cf45170 --- /dev/null +++ b/framework/source/fwe/helper/documentundoguard.cxx @@ -0,0 +1,271 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_framework.hxx" + +#include "framework/documentundoguard.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/document/XUndoManagerSupplier.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> +#include <rtl/ref.hxx> +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::document::XUndoManagerSupplier; + using ::com::sun::star::document::XUndoManager; + using ::com::sun::star::document::XUndoManagerListener; + using ::com::sun::star::document::UndoManagerEvent; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //================================================================================================================== + //= UndoManagerContextListener + //================================================================================================================== + typedef ::cppu::WeakImplHelper1 < XUndoManagerListener + > UndoManagerContextListener_Base; + class UndoManagerContextListener : public UndoManagerContextListener_Base + { + public: + UndoManagerContextListener( const Reference< XUndoManager >& i_undoManager ) + :m_xUndoManager( i_undoManager, UNO_QUERY_THROW ) + ,m_nRelativeContextDepth( 0 ) + ,m_documentDisposed( false ) + { + osl_incrementInterlockedCount( &m_refCount ); + { + m_xUndoManager->addUndoManagerListener( this ); + } + osl_decrementInterlockedCount( &m_refCount ); + } + + UndoManagerContextListener() + { + } + + void finish() + { + OSL_ENSURE( m_nRelativeContextDepth >= 0, "UndoManagerContextListener: more contexts left than entered?" ); + + if ( m_documentDisposed ) + return; + + // work with a copy of m_nRelativeContextDepth, to be independent from possible bugs in the + // listener notifications (where it would be decremented with every leaveUndoContext) + sal_Int32 nDepth = m_nRelativeContextDepth; + while ( nDepth-- > 0 ) + { + m_xUndoManager->leaveUndoContext(); + } + m_xUndoManager->removeUndoManagerListener( this ); + } + + // XUndoManagerListener + virtual void SAL_CALL undoActionAdded( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL actionUndone( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL actionRedone( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL allActionsCleared( const EventObject& i_event ) throw (RuntimeException); + virtual void SAL_CALL redoActionsCleared( const EventObject& i_event ) throw (RuntimeException); + virtual void SAL_CALL resetAll( const EventObject& i_event ) throw (RuntimeException); + virtual void SAL_CALL enteredContext( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL enteredHiddenContext( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL leftContext( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL leftHiddenContext( const UndoManagerEvent& i_event ) throw (RuntimeException); + virtual void SAL_CALL cancelledContext( const UndoManagerEvent& i_event ) throw (RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const EventObject& i_event ) throw (RuntimeException); + + private: + Reference< XUndoManager > const m_xUndoManager; + oslInterlockedCount m_nRelativeContextDepth; + bool m_documentDisposed; + }; + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::undoActionAdded( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + // not interested in + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::actionUndone( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + // not interested in + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::actionRedone( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + // not interested in + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::allActionsCleared( const EventObject& i_event ) throw (RuntimeException) + { + (void)i_event; + // not interested in + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::redoActionsCleared( const EventObject& i_event ) throw (RuntimeException) + { + (void)i_event; + // not interested in + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::resetAll( const EventObject& i_event ) throw (RuntimeException) + { + (void)i_event; + m_nRelativeContextDepth = 0; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::enteredContext( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + osl_incrementInterlockedCount( &m_nRelativeContextDepth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::enteredHiddenContext( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + osl_incrementInterlockedCount( &m_nRelativeContextDepth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::leftContext( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + osl_decrementInterlockedCount( &m_nRelativeContextDepth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::leftHiddenContext( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + osl_decrementInterlockedCount( &m_nRelativeContextDepth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::cancelledContext( const UndoManagerEvent& i_event ) throw (RuntimeException) + { + (void)i_event; + osl_decrementInterlockedCount( &m_nRelativeContextDepth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManagerContextListener::disposing( const EventObject& i_event ) throw (RuntimeException) + { + (void)i_event; + m_documentDisposed = true; + } + + //================================================================================================================== + //= DocumentUndoGuard_Data + //================================================================================================================== + struct DocumentUndoGuard_Data + { + Reference< XUndoManager > xUndoManager; + ::rtl::Reference< UndoManagerContextListener > pContextListener; + }; + + namespace + { + //-------------------------------------------------------------------------------------------------------------- + void lcl_init( DocumentUndoGuard_Data& i_data, const Reference< XInterface >& i_undoSupplierComponent ) + { + try + { + Reference< XUndoManagerSupplier > xUndoSupplier( i_undoSupplierComponent, UNO_QUERY ); + if ( xUndoSupplier.is() ) + i_data.xUndoManager.set( xUndoSupplier->getUndoManager(), UNO_QUERY_THROW ); + + if ( i_data.xUndoManager.is() ) + i_data.pContextListener.set( new UndoManagerContextListener( i_data.xUndoManager ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_restore( DocumentUndoGuard_Data& i_data ) + { + try + { + if ( i_data.pContextListener.is() ) + i_data.pContextListener->finish(); + i_data.pContextListener.clear(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + //================================================================================================================== + //= DocumentUndoGuard + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DocumentUndoGuard::DocumentUndoGuard( const Reference< XInterface >& i_undoSupplierComponent ) + :m_pData( new DocumentUndoGuard_Data ) + { + lcl_init( *m_pData, i_undoSupplierComponent ); + } + + DocumentUndoGuard::~DocumentUndoGuard() + { + lcl_restore( *m_pData ); + } + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx new file mode 100755 index 000000000000..a37451339234 --- /dev/null +++ b/framework/source/fwe/helper/undomanagerhelper.cxx @@ -0,0 +1,1165 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_framework.hxx" + +#include "framework/undomanagerhelper.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/XComponent.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <comphelper/flagguard.hxx> +#include <comphelper/asyncnotification.hxx> +#include <svl/undo.hxx> +#include <tools/diagnose_ex.h> +#include <osl/conditn.hxx> + +#include <stack> +#include <queue> +#include <boost/function.hpp> + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + 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::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::document::XUndoManagerListener; + using ::com::sun::star::document::UndoManagerEvent; + using ::com::sun::star::document::EmptyUndoStackException; + using ::com::sun::star::document::UndoContextNotClosedException; + using ::com::sun::star::document::UndoFailedException; + using ::com::sun::star::util::NotLockedException; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::document::XUndoAction; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::document::XUndoManager; + using ::com::sun::star::util::InvalidStateException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::util::XModifyListener; + /** === end UNO using === **/ + using ::svl::IUndoManager; + + //================================================================================================================== + //= UndoActionWrapper + //================================================================================================================== + class UndoActionWrapper : public SfxUndoAction + { + public: + UndoActionWrapper( + Reference< XUndoAction > const& i_undoAction + ); + virtual ~UndoActionWrapper(); + + virtual String GetComment() const; + virtual void Undo(); + virtual void Redo(); + virtual BOOL CanRepeat(SfxRepeatTarget&) const; + + private: + const Reference< XUndoAction > m_xUndoAction; + }; + + //------------------------------------------------------------------------------------------------------------------ + UndoActionWrapper::UndoActionWrapper( Reference< XUndoAction > const& i_undoAction ) + :SfxUndoAction() + ,m_xUndoAction( i_undoAction ) + { + ENSURE_OR_THROW( m_xUndoAction.is(), "illegal undo action" ); + } + + //------------------------------------------------------------------------------------------------------------------ + UndoActionWrapper::~UndoActionWrapper() + { + try + { + Reference< XComponent > xComponent( m_xUndoAction, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + String UndoActionWrapper::GetComment() const + { + String sComment; + try + { + sComment = m_xUndoAction->getTitle(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sComment; + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoActionWrapper::Undo() + { + m_xUndoAction->undo(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoActionWrapper::Redo() + { + m_xUndoAction->redo(); + } + + //------------------------------------------------------------------------------------------------------------------ + BOOL UndoActionWrapper::CanRepeat(SfxRepeatTarget&) const + { + return FALSE; + } + + //================================================================================================================== + //= UndoManagerRequest + //================================================================================================================== + class UndoManagerRequest : public ::comphelper::AnyEvent + { + public: + UndoManagerRequest( ::boost::function0< void > const& i_request ) + :m_request( i_request ) + ,m_caughtException() + ,m_finishCondition() + { + m_finishCondition.reset(); + } + + void execute() + { + try + { + m_request(); + } + catch( const Exception& ) + { + m_caughtException = ::cppu::getCaughtException(); + } + m_finishCondition.set(); + } + + void wait() + { + m_finishCondition.wait(); + if ( m_caughtException.hasValue() ) + ::cppu::throwException( m_caughtException ); + } + + void cancel( const Reference< XInterface >& i_context ) + { + m_caughtException <<= RuntimeException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Concurrency error: an ealier operation on the stack failed." ) ), + i_context + ); + m_finishCondition.set(); + } + + protected: + ~UndoManagerRequest() + { + } + + private: + ::boost::function0< void > m_request; + Any m_caughtException; + ::osl::Condition m_finishCondition; + }; + + //------------------------------------------------------------------------------------------------------------------ + + //================================================================================================================== + //= UndoManagerHelper_Impl + //================================================================================================================== + class UndoManagerHelper_Impl : public SfxUndoListener + { + private: + ::osl::Mutex m_aMutex; + ::osl::Mutex m_aQueueMutex; + bool m_disposed; + bool m_bAPIActionRunning; + bool m_bProcessingEvents; + ::cppu::OInterfaceContainerHelper m_aUndoListeners; + ::cppu::OInterfaceContainerHelper m_aModifyListeners; + IUndoManagerImplementation& m_rUndoManagerImplementation; + UndoManagerHelper& m_rAntiImpl; + ::std::stack< bool > m_aContextVisibilities; +#if OSL_DEBUG_LEVEL > 0 + ::std::stack< bool > m_aContextAPIFlags; +#endif + ::std::queue< ::rtl::Reference< UndoManagerRequest > > + m_aEventQueue; + + public: + ::osl::Mutex& getMutex() { return m_aMutex; } + + public: + UndoManagerHelper_Impl( UndoManagerHelper& i_antiImpl, IUndoManagerImplementation& i_undoManagerImpl ) + :m_aMutex() + ,m_aQueueMutex() + ,m_disposed( false ) + ,m_bAPIActionRunning( false ) + ,m_bProcessingEvents( false ) + ,m_aUndoListeners( m_aMutex ) + ,m_aModifyListeners( m_aMutex ) + ,m_rUndoManagerImplementation( i_undoManagerImpl ) + ,m_rAntiImpl( i_antiImpl ) + { + getUndoManager().AddUndoListener( *this ); + } + + virtual ~UndoManagerHelper_Impl() + { + } + + //.............................................................................................................. + IUndoManager& getUndoManager() const + { + return m_rUndoManagerImplementation.getImplUndoManager(); + } + + //.............................................................................................................. + Reference< XUndoManager > getXUndoManager() const + { + return m_rUndoManagerImplementation.getThis(); + } + + // SfxUndoListener + virtual void actionUndone( const String& i_actionComment ); + virtual void actionRedone( const String& i_actionComment ); + virtual void undoActionAdded( const String& i_actionComment ); + virtual void cleared(); + virtual void clearedRedo(); + virtual void resetAll(); + virtual void listActionEntered( const String& i_comment ); + virtual void listActionLeft( const String& i_comment ); + virtual void listActionLeftAndMerged(); + virtual void listActionCancelled(); + virtual void undoManagerDying(); + + // public operations + void disposing(); + + void enterUndoContext( const ::rtl::OUString& i_title, const bool i_hidden, IMutexGuard& i_instanceLock ); + void leaveUndoContext( IMutexGuard& i_instanceLock ); + void addUndoAction( const Reference< XUndoAction >& i_action, IMutexGuard& i_instanceLock ); + void undo( IMutexGuard& i_instanceLock ); + void redo( IMutexGuard& i_instanceLock ); + void clear( IMutexGuard& i_instanceLock ); + void clearRedo( IMutexGuard& i_instanceLock ); + void reset( IMutexGuard& i_instanceLock ); + + void addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) + { + m_aUndoListeners.addInterface( i_listener ); + } + + void removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) + { + m_aUndoListeners.removeInterface( i_listener ); + } + + void addModifyListener( const Reference< XModifyListener >& i_listener ) + { + m_aModifyListeners.addInterface( i_listener ); + } + + void removeModifyListener( const Reference< XModifyListener >& i_listener ) + { + m_aModifyListeners.removeInterface( i_listener ); + } + + UndoManagerEvent + buildEvent( ::rtl::OUString const& i_title ) const; + + void impl_notifyModified(); + void notify( ::rtl::OUString const& i_title, + void ( SAL_CALL XUndoManagerListener::*i_notificationMethod )( const UndoManagerEvent& ) + ); + void notify( void ( SAL_CALL XUndoManagerListener::*i_notificationMethod )( const UndoManagerEvent& ) ) + { + notify( ::rtl::OUString(), i_notificationMethod ); + } + + void notify( void ( SAL_CALL XUndoManagerListener::*i_notificationMethod )( const EventObject& ) ); + + private: + /// adds a function to be called to the request processor's queue + void impl_processRequest( ::boost::function0< void > const& i_request, IMutexGuard& i_instanceLock ); + + /// impl-versions of the XUndoManager API. + void impl_enterUndoContext( const ::rtl::OUString& i_title, const bool i_hidden ); + void impl_leaveUndoContext(); + void impl_addUndoAction( const Reference< XUndoAction >& i_action ); + void impl_doUndoRedo( IMutexGuard& i_externalLock, const bool i_undo ); + void impl_clear(); + void impl_clearRedo(); + void impl_reset(); + }; + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::disposing() + { + EventObject aEvent; + aEvent.Source = getXUndoManager(); + m_aUndoListeners.disposeAndClear( aEvent ); + m_aModifyListeners.disposeAndClear( aEvent ); + + ::osl::MutexGuard aGuard( m_aMutex ); + + getUndoManager().RemoveUndoListener( *this ); + + m_disposed = true; + } + + //------------------------------------------------------------------------------------------------------------------ + UndoManagerEvent UndoManagerHelper_Impl::buildEvent( ::rtl::OUString const& i_title ) const + { + UndoManagerEvent aEvent; + aEvent.Source = getXUndoManager(); + aEvent.UndoActionTitle = i_title; + aEvent.UndoContextDepth = getUndoManager().GetListActionDepth(); + return aEvent; + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_notifyModified() + { + const EventObject aEvent( getXUndoManager() ); + m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::notify( ::rtl::OUString const& i_title, + void ( SAL_CALL XUndoManagerListener::*i_notificationMethod )( const UndoManagerEvent& ) ) + { + const UndoManagerEvent aEvent( buildEvent( i_title ) ); + + // TODO: this notification method here is used by UndoManagerHelper_Impl, to multiplex the notifications we + // receive from the IUndoManager. Those notitications are sent with a locked SolarMutex, which means + // we're doing the multiplexing here with a locked SM, too. Which is Bad (TM). + // Fixing this properly would require outsourcing all the notifications into an own thread - which might lead + // to problems of its own, since clients might expect synchronous notifications. + + m_aUndoListeners.notifyEach( i_notificationMethod, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::notify( void ( SAL_CALL XUndoManagerListener::*i_notificationMethod )( const EventObject& ) ) + { + const EventObject aEvent( getXUndoManager() ); + + // TODO: the same comment as in the other notify, regarding SM locking applies here ... + + m_aUndoListeners.notifyEach( i_notificationMethod, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::enterUndoContext( const ::rtl::OUString& i_title, const bool i_hidden, IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_enterUndoContext, + this, + ::boost::cref( i_title ), + i_hidden + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::leaveUndoContext( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_leaveUndoContext, + this + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::addUndoAction( const Reference< XUndoAction >& i_action, IMutexGuard& i_instanceLock ) + { + if ( !i_action.is() ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal undo action object" ) ), + getXUndoManager(), + 1 + ); + + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_addUndoAction, + this, + ::boost::ref( i_action ) + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::clear( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_clear, + this + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::clearRedo( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_clearRedo, + this + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::reset( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_reset, + this + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_processRequest( ::boost::function0< void > const& i_request, IMutexGuard& i_instanceLock ) + { + // create the request, and add it to our queue + ::rtl::Reference< UndoManagerRequest > pRequest( new UndoManagerRequest( i_request ) ); + { + ::osl::MutexGuard aQueueGuard( m_aQueueMutex ); + m_aEventQueue.push( pRequest ); + } + + i_instanceLock.clear(); + + if ( m_bProcessingEvents ) + { + // another thread is processing the event queue currently => it will also process the event which we just added + pRequest->wait(); + return; + } + + m_bProcessingEvents = true; + do + { + pRequest.clear(); + { + ::osl::MutexGuard aQueueGuard( m_aQueueMutex ); + if ( m_aEventQueue.empty() ) + { + // reset the flag before releasing the queue mutex, otherwise it's possible that another thread + // could add an event after we release the mutex, but before we reset the flag. If then this other + // thread checks the flag before be reset it, this thread's event would starve. + m_bProcessingEvents = false; + return; + } + pRequest = m_aEventQueue.front(); + m_aEventQueue.pop(); + } + try + { + pRequest->execute(); + pRequest->wait(); + } + catch( ... ) + { + { + // no chance to process further requests, if the current one failed + // => discard them + ::osl::MutexGuard aQueueGuard( m_aQueueMutex ); + while ( !m_aEventQueue.empty() ) + { + pRequest = m_aEventQueue.front(); + m_aEventQueue.pop(); + pRequest->cancel( getXUndoManager() ); + } + m_bProcessingEvents = false; + } + // re-throw the error + throw; + } + } + while ( true ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_enterUndoContext( const ::rtl::OUString& i_title, const bool i_hidden ) + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( !rUndoManager.IsUndoEnabled() ) + // ignore this request if the manager is locked + return; + + if ( i_hidden && ( rUndoManager.GetUndoActionCount( IUndoManager::CurrentLevel ) == 0 ) ) + throw EmptyUndoStackException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "can't enter a hidden context without a previous Undo action" ) ), + m_rUndoManagerImplementation.getThis() + ); + + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + rUndoManager.EnterListAction( i_title, ::rtl::OUString() ); + } + + m_aContextVisibilities.push( i_hidden ); + + const UndoManagerEvent aEvent( buildEvent( i_title ) ); + aGuard.clear(); + // <--- SYNCHRONIZED + + m_aUndoListeners.notifyEach( i_hidden ? &XUndoManagerListener::enteredHiddenContext : &XUndoManagerListener::enteredContext, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_leaveUndoContext() + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( !rUndoManager.IsUndoEnabled() ) + // ignore this request if the manager is locked + return; + + if ( !rUndoManager.IsInListAction() ) + throw InvalidStateException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no active undo context" ) ), + getXUndoManager() + ); + + size_t nContextElements = 0; + + const bool isHiddenContext = m_aContextVisibilities.top();; + m_aContextVisibilities.pop(); + + const bool bHadRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0 ); + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + if ( isHiddenContext ) + nContextElements = rUndoManager.LeaveAndMergeListAction(); + else + nContextElements = rUndoManager.LeaveListAction(); + } + const bool bHasRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0 ); + + // prepare notification + void ( SAL_CALL XUndoManagerListener::*notificationMethod )( const UndoManagerEvent& ) = NULL; + + UndoManagerEvent aContextEvent( buildEvent( ::rtl::OUString() ) ); + const EventObject aClearedEvent( getXUndoManager() ); + if ( nContextElements == 0 ) + { + notificationMethod = &XUndoManagerListener::cancelledContext; + } + else if ( isHiddenContext ) + { + notificationMethod = &XUndoManagerListener::leftHiddenContext; + } + else + { + aContextEvent.UndoActionTitle = rUndoManager.GetUndoActionComment( 0, IUndoManager::CurrentLevel ); + notificationMethod = &XUndoManagerListener::leftContext; + } + + aGuard.clear(); + // <--- SYNCHRONIZED + + if ( bHadRedoActions && !bHasRedoActions ) + m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aClearedEvent ); + m_aUndoListeners.notifyEach( notificationMethod, aContextEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_doUndoRedo( IMutexGuard& i_externalLock, const bool i_undo ) + { + ::osl::Guard< ::framework::IMutex > aExternalGuard( i_externalLock.getGuardedMutex() ); + // note that this assumes that the mutex has been released in the thread which added the + // Undo/Redo request, so we can successfully acquire it + + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( rUndoManager.IsInListAction() ) + throw UndoContextNotClosedException( ::rtl::OUString(), getXUndoManager() ); + + const size_t nElements = i_undo + ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + if ( nElements == 0 ) + throw EmptyUndoStackException( ::rtl::OUString::createFromAscii( "stack is empty" ), getXUndoManager() ); + + aGuard.clear(); + // <--- SYNCHRONIZED + + try + { + if ( i_undo ) + rUndoManager.Undo(); + else + rUndoManager.Redo(); + } + catch( const RuntimeException& ) { /* allowed to leave here */ throw; } + catch( const UndoFailedException& ) { /* allowed to leave here */ throw; } + catch( const Exception& ) + { + // not allowed to leave + const Any aError( ::cppu::getCaughtException() ); + throw UndoFailedException( ::rtl::OUString(), getXUndoManager(), aError ); + } + + // note that in opposite to all of the other methods, we do *not* have our mutex locked when calling + // into the IUndoManager implementation. This ensures that an actual XUndoAction::undo/redo is also + // called without our mutex being locked. + // As a consequence, we do not set m_bAPIActionRunning here. Instead, our actionUndone/actionRedone methods + // *always* multiplex the event to our XUndoManagerListeners, not only when m_bAPIActionRunning is FALSE (This + // again is different from all other SfxUndoListener methods). + // So, we do not need to do this notification here ourself. + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_addUndoAction( const Reference< XUndoAction >& i_action ) + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( !rUndoManager.IsUndoEnabled() ) + // ignore the request if the manager is locked + return; + + const UndoManagerEvent aEventAdd( buildEvent( i_action->getTitle() ) ); + const EventObject aEventClear( getXUndoManager() ); + + const bool bHadRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::CurrentLevel ) > 0 ); + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + rUndoManager.AddUndoAction( new UndoActionWrapper( i_action ) ); + } + const bool bHasRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::CurrentLevel ) > 0 ); + + aGuard.clear(); + // <--- SYNCHRONIZED + + m_aUndoListeners.notifyEach( &XUndoManagerListener::undoActionAdded, aEventAdd ); + if ( bHadRedoActions && !bHasRedoActions ) + m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aEventClear ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_clear() + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( rUndoManager.IsInListAction() ) + throw UndoContextNotClosedException( ::rtl::OUString(), getXUndoManager() ); + + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + rUndoManager.Clear(); + } + + const EventObject aEvent( getXUndoManager() ); + aGuard.clear(); + // <--- SYNCHRONIZED + + m_aUndoListeners.notifyEach( &XUndoManagerListener::allActionsCleared, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_clearRedo() + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + if ( rUndoManager.IsInListAction() ) + throw UndoContextNotClosedException( ::rtl::OUString(), getXUndoManager() ); + + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + rUndoManager.ClearRedo(); + } + + const EventObject aEvent( getXUndoManager() ); + aGuard.clear(); + // <--- SYNCHRONIZED + + m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::impl_reset() + { + // SYNCHRONIZED ---> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + IUndoManager& rUndoManager = getUndoManager(); + { + ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); + rUndoManager.Reset(); + } + + const EventObject aEvent( getXUndoManager() ); + aGuard.clear(); + // <--- SYNCHRONIZED + + m_aUndoListeners.notifyEach( &XUndoManagerListener::resetAll, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::actionUndone( const String& i_actionComment ) + { + UndoManagerEvent aEvent; + aEvent.Source = getXUndoManager(); + aEvent.UndoActionTitle = i_actionComment; + aEvent.UndoContextDepth = 0; // Undo can happen on level 0 only + m_aUndoListeners.notifyEach( &XUndoManagerListener::actionUndone, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::actionRedone( const String& i_actionComment ) + { + UndoManagerEvent aEvent; + aEvent.Source = getXUndoManager(); + aEvent.UndoActionTitle = i_actionComment; + aEvent.UndoContextDepth = 0; // Redo can happen on level 0 only + m_aUndoListeners.notifyEach( &XUndoManagerListener::actionRedone, aEvent ); + impl_notifyModified(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::undoActionAdded( const String& i_actionComment ) + { + if ( m_bAPIActionRunning ) + return; + + notify( i_actionComment, &XUndoManagerListener::undoActionAdded ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::cleared() + { + if ( m_bAPIActionRunning ) + return; + + notify( &XUndoManagerListener::allActionsCleared ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::clearedRedo() + { + if ( m_bAPIActionRunning ) + return; + + notify( &XUndoManagerListener::redoActionsCleared ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::resetAll() + { + if ( m_bAPIActionRunning ) + return; + + notify( &XUndoManagerListener::resetAll ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::listActionEntered( const String& i_comment ) + { +#if OSL_DEBUG_LEVEL > 0 + m_aContextAPIFlags.push( m_bAPIActionRunning ); +#endif + + if ( m_bAPIActionRunning ) + return; + + notify( i_comment, &XUndoManagerListener::enteredContext ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::listActionLeft( const String& i_comment ) + { +#if OSL_DEBUG_LEVEL > 0 + const bool bCurrentContextIsAPIContext = m_aContextAPIFlags.top(); + m_aContextAPIFlags.pop(); + OSL_ENSURE( bCurrentContextIsAPIContext == m_bAPIActionRunning, "UndoManagerHelper_Impl::listActionLeft: API and non-API contexts interwoven!" ); +#endif + + if ( m_bAPIActionRunning ) + return; + + notify( i_comment, &XUndoManagerListener::leftContext ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::listActionLeftAndMerged() + { +#if OSL_DEBUG_LEVEL > 0 + const bool bCurrentContextIsAPIContext = m_aContextAPIFlags.top(); + m_aContextAPIFlags.pop(); + OSL_ENSURE( bCurrentContextIsAPIContext == m_bAPIActionRunning, "UndoManagerHelper_Impl::listActionLeftAndMerged: API and non-API contexts interwoven!" ); +#endif + + if ( m_bAPIActionRunning ) + return; + + notify( &XUndoManagerListener::leftHiddenContext ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::listActionCancelled() + { +#if OSL_DEBUG_LEVEL > 0 + const bool bCurrentContextIsAPIContext = m_aContextAPIFlags.top(); + m_aContextAPIFlags.pop(); + OSL_ENSURE( bCurrentContextIsAPIContext == m_bAPIActionRunning, "UndoManagerHelper_Impl::listActionCancelled: API and non-API contexts interwoven!" ); +#endif + + if ( m_bAPIActionRunning ) + return; + + notify( &XUndoManagerListener::cancelledContext ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::undoManagerDying() + { + // TODO: do we need to care? Or is this the responsibility of our owner? + } + + //================================================================================================================== + //= UndoManagerHelper + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + UndoManagerHelper::UndoManagerHelper( IUndoManagerImplementation& i_undoManagerImpl ) + :m_pImpl( new UndoManagerHelper_Impl( *this, i_undoManagerImpl ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + UndoManagerHelper::~UndoManagerHelper() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::disposing() + { + m_pImpl->disposing(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::enterUndoContext( const ::rtl::OUString& i_title, IMutexGuard& i_instanceLock ) + { + m_pImpl->enterUndoContext( i_title, false, i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::enterHiddenUndoContext( IMutexGuard& i_instanceLock ) + { + m_pImpl->enterUndoContext( ::rtl::OUString(), true, i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::leaveUndoContext( IMutexGuard& i_instanceLock ) + { + m_pImpl->leaveUndoContext( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::undo( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_doUndoRedo, + this, + ::boost::ref( i_instanceLock ), + true + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper_Impl::redo( IMutexGuard& i_instanceLock ) + { + impl_processRequest( + ::boost::bind( + &UndoManagerHelper_Impl::impl_doUndoRedo, + this, + ::boost::ref( i_instanceLock ), + false + ), + i_instanceLock + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::addUndoAction( const Reference< XUndoAction >& i_action, IMutexGuard& i_instanceLock ) + { + m_pImpl->addUndoAction( i_action, i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::undo( IMutexGuard& i_instanceLock ) + { + m_pImpl->undo( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::redo( IMutexGuard& i_instanceLock ) + { + m_pImpl->redo( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool UndoManagerHelper::isUndoPossible() const + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( m_pImpl->getMutex() ); + IUndoManager& rUndoManager = m_pImpl->getUndoManager(); + if ( rUndoManager.IsInListAction() ) + return sal_False; + return rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) > 0; + // <--- SYNCHRONIZED + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool UndoManagerHelper::isRedoPossible() const + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( m_pImpl->getMutex() ); + const IUndoManager& rUndoManager = m_pImpl->getUndoManager(); + if ( rUndoManager.IsInListAction() ) + return sal_False; + return rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0; + // <--- SYNCHRONIZED + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + //.............................................................................................................. + ::rtl::OUString lcl_getCurrentActionTitle( UndoManagerHelper_Impl& i_impl, const bool i_undo ) + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( i_impl.getMutex() ); + + const IUndoManager& rUndoManager = i_impl.getUndoManager(); + const size_t nActionCount = i_undo + ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + if ( nActionCount == 0 ) + throw EmptyUndoStackException( + i_undo ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no action on the undo stack" ) ) + : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no action on the redo stack" ) ), + i_impl.getXUndoManager() + ); + return i_undo + ? rUndoManager.GetUndoActionComment( 0, IUndoManager::TopLevel ) + : rUndoManager.GetRedoActionComment( 0, IUndoManager::TopLevel ); + // <--- SYNCHRONIZED + } + + //.............................................................................................................. + Sequence< ::rtl::OUString > lcl_getAllActionTitles( UndoManagerHelper_Impl& i_impl, const bool i_undo ) + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( i_impl.getMutex() ); + + const IUndoManager& rUndoManager = i_impl.getUndoManager(); + const size_t nCount = i_undo + ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + + Sequence< ::rtl::OUString > aTitles( nCount ); + for ( size_t i=0; i<nCount; ++i ) + { + aTitles[i] = i_undo + ? rUndoManager.GetUndoActionComment( i, IUndoManager::TopLevel ) + : rUndoManager.GetRedoActionComment( i, IUndoManager::TopLevel ); + } + return aTitles; + // <--- SYNCHRONIZED + } + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString UndoManagerHelper::getCurrentUndoActionTitle() const + { + return lcl_getCurrentActionTitle( *m_pImpl, true ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString UndoManagerHelper::getCurrentRedoActionTitle() const + { + return lcl_getCurrentActionTitle( *m_pImpl, false ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > UndoManagerHelper::getAllUndoActionTitles() const + { + return lcl_getAllActionTitles( *m_pImpl, true ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > UndoManagerHelper::getAllRedoActionTitles() const + { + return lcl_getAllActionTitles( *m_pImpl, false ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::clear( IMutexGuard& i_instanceLock ) + { + m_pImpl->clear( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::clearRedo( IMutexGuard& i_instanceLock ) + { + m_pImpl->clearRedo( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::reset( IMutexGuard& i_instanceLock ) + { + m_pImpl->reset( i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::lock() + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( m_pImpl->getMutex() ); + + IUndoManager& rUndoManager = m_pImpl->getUndoManager(); + rUndoManager.EnableUndo( false ); + // <--- SYNCHRONIZED + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::unlock() + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( m_pImpl->getMutex() ); + + IUndoManager& rUndoManager = m_pImpl->getUndoManager(); + if ( rUndoManager.IsUndoEnabled() ) + throw NotLockedException( ::rtl::OUString::createFromAscii( "Undo manager is not locked" ), m_pImpl->getXUndoManager() ); + rUndoManager.EnableUndo( true ); + // <--- SYNCHRONIZED + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool UndoManagerHelper::isLocked() + { + // SYNCHRONIZED ---> + ::osl::MutexGuard aGuard( m_pImpl->getMutex() ); + + IUndoManager& rUndoManager = m_pImpl->getUndoManager(); + return !rUndoManager.IsUndoEnabled(); + // <--- SYNCHRONIZED + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) + { + if ( i_listener.is() ) + m_pImpl->addUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) + { + if ( i_listener.is() ) + m_pImpl->removeUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::addModifyListener( const Reference< XModifyListener >& i_listener ) + { + if ( i_listener.is() ) + m_pImpl->addModifyListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManagerHelper::removeModifyListener( const Reference< XModifyListener >& i_listener ) + { + if ( i_listener.is() ) + m_pImpl->removeModifyListener( i_listener ); + } + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... diff --git a/framework/source/helper/tagwindowasmodified.cxx b/framework/source/helper/tagwindowasmodified.cxx index a71c5263455b..67c047dfefd4 100644 --- a/framework/source/helper/tagwindowasmodified.cxx +++ b/framework/source/helper/tagwindowasmodified.cxx @@ -61,7 +61,7 @@ #include <vcl/syswin.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> //_________________________________________________________________________________________________________________ // namespace diff --git a/framework/source/layoutmanager/uielement.cxx b/framework/source/layoutmanager/uielement.cxx index dda5aa352a08..722ca164f2b5 100755..100644 --- a/framework/source/layoutmanager/uielement.cxx +++ b/framework/source/layoutmanager/uielement.cxx @@ -132,24 +132,27 @@ namespace framework UIElement& UIElement::operator= ( const UIElement& rUIElement ) { - m_aType = rUIElement.m_aType; - m_aName = rUIElement.m_aName; - m_aUIName = rUIElement.m_aUIName; - m_xUIElement = rUIElement.m_xUIElement; - m_bFloating = rUIElement.m_bFloating; - m_bVisible = rUIElement.m_bVisible; - m_bUserActive = rUIElement.m_bUserActive; - m_bCreateNewRowCol0 = rUIElement.m_bCreateNewRowCol0; - m_bDeactiveHide = rUIElement.m_bDeactiveHide; - m_bMasterHide = rUIElement.m_bMasterHide; - m_bContextSensitive = rUIElement.m_bContextSensitive; - m_bContextActive = rUIElement.m_bContextActive; - m_bNoClose = rUIElement.m_bNoClose; - m_bSoftClose = rUIElement.m_bSoftClose; - m_bStateRead = rUIElement.m_bStateRead; - m_nStyle = rUIElement.m_nStyle; - m_aDockedData = rUIElement.m_aDockedData; - m_aFloatingData = rUIElement.m_aFloatingData; + if (&rUIElement != this) + { + m_aType = rUIElement.m_aType; + m_aName = rUIElement.m_aName; + m_aUIName = rUIElement.m_aUIName; + m_xUIElement = rUIElement.m_xUIElement; + m_bFloating = rUIElement.m_bFloating; + m_bVisible = rUIElement.m_bVisible; + m_bUserActive = rUIElement.m_bUserActive; + m_bCreateNewRowCol0 = rUIElement.m_bCreateNewRowCol0; + m_bDeactiveHide = rUIElement.m_bDeactiveHide; + m_bMasterHide = rUIElement.m_bMasterHide; + m_bContextSensitive = rUIElement.m_bContextSensitive; + m_bContextActive = rUIElement.m_bContextActive; + m_bNoClose = rUIElement.m_bNoClose; + m_bSoftClose = rUIElement.m_bSoftClose; + m_bStateRead = rUIElement.m_bStateRead; + m_nStyle = rUIElement.m_nStyle; + m_aDockedData = rUIElement.m_aDockedData; + m_aFloatingData = rUIElement.m_aFloatingData; + } return *this; } diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index 58cf3a3b02be..0b1a0d003133 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -51,7 +51,7 @@ #ifndef _VCL_MENU_HXX_ #include <vcl/menu.hxx> #endif -#include <vcl/mapunit.hxx> +#include <tools/mapunit.hxx> #ifndef _VCL_SVAPP_HXX_ #include <vcl/svapp.hxx> #endif diff --git a/linguistic/source/misc2.cxx b/linguistic/source/misc2.cxx index 16874c4ff830..9c02a976fcbd 100644 --- a/linguistic/source/misc2.cxx +++ b/linguistic/source/misc2.cxx @@ -249,7 +249,10 @@ String GetWritableDictionaryURL( const String &rDicName ) aURLObj.Append( rDicName, INetURLObject::ENCODE_ALL ); DBG_ASSERT(!aURLObj.HasError(), "lng : invalid URL"); - return aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); + // NO_DECODE preserves the escape sequences that might be included in aDirName + // depending on the characters used in the path string. (Needed when comparing + // the dictionary URL with GetDictionaryWriteablePath in DicList::createDictionary.) + return aURLObj.GetMainURL( INetURLObject::NO_DECODE ); } diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index 5c735744104b..2616566225b9 100755..100644 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -1698,7 +1698,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -1893,7 +1893,7 @@ </node> </node> <node oor:name="com.sun.star.presentation.PresentationDocument" oor:op="replace"> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"> <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> @@ -2739,7 +2739,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -3374,7 +3374,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -3979,7 +3979,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -4589,7 +4589,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -5204,7 +5204,7 @@ <value xml:lang="es">.uno:Bold</value> </prop> </node> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> </prop> @@ -5567,7 +5567,7 @@ </node> </node> <node oor:name="com.sun.star.drawing.DrawingDocument" oor:op="replace"> - <node oor:name="N_MOD1_MOD2" oor:op="replace"> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> <prop oor:name="Command"> <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:InsertAnnotation</value> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 46611715f998..7b83b162338e 100755 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -3412,7 +3412,7 @@ </node> <node oor:name=".uno:BmpMask" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">~Eyedropper</value> + <value xml:lang="en-US">Color ~Replacer</value> </prop> </node> <node oor:name=".uno:GoLeftBlock" oor:op="replace"> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu index 4ed9be5a3d27..07a717f31442 100755 --- a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu @@ -42,9 +42,6 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Import Formula...</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:FitInWindow" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -111,7 +108,7 @@ </node> <node oor:name=".uno:View100" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">1</value> + <value xml:lang="en-US">Zoom 100%</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> @@ -119,7 +116,7 @@ </node> <node oor:name=".uno:View200" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">2</value> + <value xml:lang="en-US">Zoom 200%</value> </prop> </node> <node oor:name=".uno:ZoomIn" oor:op="replace"> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 9bc07c592f0f..ae171230dd13 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2600,39 +2600,6 @@ </constraints> <value>100</value> </prop> - <prop oor:name="LookAndFeel" oor:type="xs:short"> - <!-- OldPath: General/View --> - <!-- OldLocation: soffice.cfg --> - <!-- UIHints: Tools Options - General View [Section] Display --> - <info> - <author>PB</author> - <desc>Determines the look and feel of the application.</desc> - <label>Look & Feel</label> - </info> - <constraints> - <enumeration oor:value="0"> - <info> - <desc>Standard</desc> - </info> - </enumeration> - <enumeration oor:value="1"> - <info> - <desc>Macintosh</desc> - </info> - </enumeration> - <enumeration oor:value="2"> - <info> - <desc>X Window</desc> - </info> - </enumeration> - <enumeration oor:value="3"> - <info> - <desc>OS/2</desc> - </info> - </enumeration> - </constraints> - <value>0</value> - </prop> <group oor:name="NewDocumentHandling"> <info> <author>CD</author> @@ -2714,17 +2681,6 @@ </info> <value>true</value> </prop> - <prop oor:name="ColoredTab" oor:type="xs:boolean"> - <!-- OldPath: General/View --> - <!-- OldLocation: soffice.cfg --> - <!-- UIHints: Tools Options - General View [Section] Options --> - <info> - <author>PB</author> - <desc>Specifies TabDialogs with colored tab control (True)</desc> - <label>Colored tab controls</label> - </info> - <value>false</value> - </prop> <prop oor:name="MousePositioning" oor:type="xs:short"> <!-- OldPath: General/View --> <!-- OldLocation: soffice.cfg --> @@ -2780,17 +2736,6 @@ </constraints> <value>1</value> </prop> - <prop oor:name="SingleLineTab" oor:type="xs:boolean"> - <!-- OldPath: General/View --> - <!-- OldLocation: soffice.cfg --> - <!-- UIHints: Tools Options - General View [Section] Options --> - <info> - <author>PB</author> - <desc>Specifies TabDialogs with single line tab control (True).</desc> - <label>Single line tab controls</label> - </info> - <value>false</value> - </prop> </group> <group oor:name="Localisation"> <info> diff --git a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs index e133b7a5a957..6dd518250d4a 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs @@ -282,7 +282,7 @@ <desc>Indicates whether moving while holding the Control key makes a copy of the moved object.</desc> <label>Copy while moving</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="ObjectMoveable" oor:type="xs:boolean"> <!-- OldPath: Draw/Other --> @@ -410,7 +410,7 @@ <desc>Indicates whether a simple click on a text object changes it to edit mode.</desc> <label>Allow quick editing</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="Selectable" oor:type="xs:boolean"> <!-- OldPath: Draw/Other/Text_Objects --> @@ -824,7 +824,7 @@ <desc>Specifies the number of points between two grid points on the X axis.</desc> <label>X Axis Subdivision</label> </info> - <value>1</value> + <value>9</value> </prop> <prop oor:name="YAxis" oor:type="xs:double"> <!-- OldPath: Draw/Grid/Subdivision --> @@ -836,7 +836,7 @@ <desc>Specifies the number of points between two grid points on the Y axis.</desc> <label>Y Axis Subdivision</label> </info> - <value>1</value> + <value>9</value> </prop> </group> <group oor:name="SnapGrid"> diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 8317e3e0082d..871c5c2c1494 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -331,7 +331,7 @@ <desc>Indicates whether moving while holding the Control key makes a copy of the moved object.</desc> <label>Copy while moving</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="ObjectMoveable" oor:type="xs:boolean"> <!-- OldPath: Impress/Other --> @@ -371,7 +371,7 @@ <desc>Indicates whether a double-click on an object activates the rotation mode.</desc> <label>Rotation Mode after clicking object</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="Preview" oor:type="xs:double"> <!-- OldPath: Impress/Other --> @@ -426,7 +426,7 @@ <desc>Indicates whether to show big (true) or small (false) handles.</desc> <label>Big Handles</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="ModifyWithAttributes" oor:type="xs:boolean"> <!-- OldPath: Impress/Other --> @@ -537,6 +537,29 @@ </info> <value>0</value> </prop> + <prop oor:name="PenColor" oor:type="xs:int"> + <!-- OldPath: --> + <!-- OldLocation: --> + <!-- UIHints: slide show context menu --> + <info> + <author>CL</author> + <desc>Color of the pen during slideshow.</desc> + <label>Pen Color</label> + </info> + <value>16711680</value> + </prop> + <prop oor:name="PenWidth" oor:type="xs:double"> + <!-- OldPath: --> + <!-- OldLocation: --> + <!-- UIHints: slide show context menu --> + <info> + <author>CL</author> + <desc>Width of the pen during slideshow.</desc> + <label>Pen Width</label> + </info> + <value>150</value> + </prop> + <group oor:name="TextObject"> <info> <desc>Contains text editing related configuration items.</desc> @@ -679,7 +702,7 @@ <desc>Indicates whether to snap at snap lines.</desc> <label>Snap lines</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="PageMargin" oor:type="xs:boolean"> <!-- OldPath: Impress/Snap/Objects --> @@ -699,7 +722,7 @@ <desc>Indicates whether to justify the outline of an object to that of an adjacent object.</desc> <label>Object frame</label> </info> - <value>false</value> + <value>true</value> </prop> <prop oor:name="ObjectPoint" oor:type="xs:boolean"> <!-- OldPath: Impress/Snap/Objects --> @@ -871,14 +894,14 @@ <desc>Defines the horizontal distance between adjacent grid points in 1/100 mm, used when the metric system is active.</desc> <label/> </info> - <value>1000</value> + <value>2000</value> </prop> <prop oor:name="NonMetric" oor:type="xs:int"> <info> <desc>Defines the horizontal distance between adjacent grid points in 1/100 mm, used when the non-metric system is active.</desc> <label/> </info> - <value>1270</value> + <value>2540</value> </prop> </group> <group oor:name="YAxis"> @@ -895,14 +918,14 @@ <desc>Defines the vertical distance between adjacent grid points in 1/100 mm, used when the metric system is active.</desc> <label/> </info> - <value>1000</value> + <value>2000</value> </prop> <prop oor:name="NonMetric" oor:type="xs:int"> <info> <desc>Defines the vertical distance between adjacent grid points in 1/100 mm, used when the non-metric system is active.</desc> <label/> </info> - <value>1270</value> + <value>2540</value> </prop> </group> </group> @@ -919,7 +942,7 @@ <desc>Specifies the number of points between two adjacent grid points on the X axis.</desc> <label>X Axis Subdivision</label> </info> - <value>1</value> + <value>9</value> </prop> <prop oor:name="YAxis" oor:type="xs:double"> <!-- OldPath: Impress/Grid/Subdivision --> @@ -930,7 +953,7 @@ <desc>Specifies the number of intervals between two adjacent grid points on the Y axis</desc> <label>Y Axis Subdivision</label> </info> - <value>1</value> + <value>9</value> </prop> </group> <group oor:name="SnapGrid"> @@ -961,7 +984,7 @@ <desc>Defines the horizontal distance between adjacent points of the snap grid in 1/100 mm, used when the metric system is selected.</desc> <label/> </info> - <value>1000</value> + <value>100</value> </prop> <prop oor:name="NonMetric" oor:type="xs:int"> <info> @@ -985,7 +1008,7 @@ <desc>Defines the vertical distance between adjacent points of the snap grid in 1/100 mm, used when the metric system is selected.</desc> <label/> </info> - <value>1000</value> + <value>100</value> </prop> <prop oor:name="NonMetric" oor:type="xs:int"> <info> diff --git a/officecfg/registry/schema/org/openoffice/Office/Math.xcs b/officecfg/registry/schema/org/openoffice/Office/Math.xcs index 31f6e00a230a..13a566dc6746 100644..100755 --- a/officecfg/registry/schema/org/openoffice/Office/Math.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Math.xcs @@ -316,6 +316,20 @@ <value>100</value> </prop> </group> + <group oor:name="LoadSave"> + <info> + <desc>Contains settings related to load and save operations.</desc> + </info> + <prop oor:name="IsSaveOnlyUsedSymbols" oor:type="xs:boolean"> + <!-- UIHints: - Tools/Options - OpenOffice Maths - Settings --> + <info> + <author>TL</author> + <desc>When set only symbols used in the current formula will be saved. Otherwise all user defined symbols will be saved in each formula.</desc> + <label>Save only used symbols.</label> + </info> + <value>true</value> + </prop> + </group> <group oor:name="Misc"> <info> <desc>Contains miscellaneous settings.</desc> diff --git a/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs b/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs index b77cb00f8cac..90acb2a110bf 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs @@ -48,28 +48,5 @@ <desc>Lists the registered Scripting Framework runtimes.</desc> </info> </set> - <group oor:name="ScriptDisplaySettings"> - <info> - <desc> Specifies display settings for assignment dialogs </desc> - </info> - <prop oor:name="ShowBasic" oor:type="xs:boolean"> - <info> - <desc>Show Basic scripts in assignment dialogs</desc> - </info> - <value>false</value> - </prop> - <prop oor:name="ShowSF" oor:type="xs:boolean"> - <info> - <desc>Show Scripting Framework scripts in assignment dialogs</desc> - </info> - <value>true</value> - </prop> - <prop oor:name="UseNewToolsConfigure" oor:type="xs:boolean"> - <info> - <desc>Use New Tools Configure dialog</desc> - </info> - <value>true</value> - </prop> - </group> </component> </oor:component-schema> diff --git a/scripting/source/dlgprov/DialogModelProvider.cxx b/scripting/source/dlgprov/DialogModelProvider.cxx new file mode 100644 index 000000000000..fe8da6e511d7 --- /dev/null +++ b/scripting/source/dlgprov/DialogModelProvider.cxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_scripting.hxx" + +#include "DialogModelProvider.hxx" +#include "dlgprov.hxx" +#include <com/sun/star/resource/XStringResourceManager.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> + + +// component helper namespace +namespace comp_DialogModelProvider { + +namespace css = ::com::sun::star; +using namespace ::com::sun::star; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; + + +// component and service helper functions: +::rtl::OUString SAL_CALL _getImplementationName(); +css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames(); +css::uno::Reference< css::uno::XInterface > SAL_CALL _create( css::uno::Reference< css::uno::XComponentContext > const & context ); + +} // closing component helper namespace + + + +/// anonymous implementation namespace +namespace dlgprov { + +namespace css = ::com::sun::star; +using namespace ::com::sun::star; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; + + +DialogModelProvider::DialogModelProvider(Reference< XComponentContext > const & context) : + m_xContext(context) +{} + +// lang::XInitialization: +void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception) +{ + if ( aArguments.getLength() == 1 ) + { + ::rtl::OUString sURL; + if ( !( aArguments[ 0 ] >>= sURL )) + throw css::lang::IllegalArgumentException(); + // Try any other URL with SimpleFileAccess + Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY_THROW ); + Reference< ucb::XSimpleFileAccess > xSFI = + Reference< ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext + ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ), UNO_QUERY ); + + try + { + Reference< io::XInputStream > xInput = xSFI->openFileRead( sURL ); + Reference< resource::XStringResourceManager > xStringResourceManager; + if ( xInput.is() ) + { + xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL); + Any aDialogSourceURLAny; + aDialogSourceURLAny <<= sURL; + + m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext,xInput , xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); + m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW); + } + } + catch( Exception& ) + {} + //m_sURL = sURL; + } +} + +// container::XElementAccess: +uno::Type SAL_CALL DialogModelProvider::getElementType() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->getElementType(); +} + +::sal_Bool SAL_CALL DialogModelProvider::hasElements() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->hasElements(); +} + +// container::XNameAccess: +uno::Any SAL_CALL DialogModelProvider::getByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + return m_xDialogModel->getByName(aName); +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getElementNames() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->getElementNames(); +} + +::sal_Bool SAL_CALL DialogModelProvider::hasByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException) +{ + return m_xDialogModel->hasByName(aName); +} + +// container::XNameReplace: +void SAL_CALL DialogModelProvider::replaceByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + m_xDialogModel->replaceByName(aName,aElement); +} + +// container::XNameContainer: +void SAL_CALL DialogModelProvider::insertByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException) +{ + m_xDialogModel->insertByName(aName,aElement); +} + +void SAL_CALL DialogModelProvider::removeByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + m_xDialogModel->removeByName(aName); +} +uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException) +{ + return m_xDialogModelProp->getPropertySetInfo(); +} +void SAL_CALL DialogModelProvider::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_xDialogModelProp->getPropertyValue(PropertyName); +} +void SAL_CALL DialogModelProvider::addPropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::removePropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::addVetoableChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::removeVetoableChangeListener( const ::rtl::OUString& ,const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} + +// com.sun.star.uno.XServiceInfo: +::rtl::OUString SAL_CALL DialogModelProvider::getImplementationName() throw (css::uno::RuntimeException) +{ + return comp_DialogModelProvider::_getImplementationName(); +} + +::sal_Bool SAL_CALL DialogModelProvider::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException) +{ + css::uno::Sequence< ::rtl::OUString > serviceNames = comp_DialogModelProvider::_getSupportedServiceNames(); + for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) { + if (serviceNames[i] == serviceName) + return sal_True; + } + return sal_False; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getSupportedServiceNames() throw (css::uno::RuntimeException) +{ + return comp_DialogModelProvider::_getSupportedServiceNames(); +} + +} // closing anonymous implementation namespace + diff --git a/scripting/source/dlgprov/DialogModelProvider.hxx b/scripting/source/dlgprov/DialogModelProvider.hxx new file mode 100644 index 000000000000..bc74dfe661dd --- /dev/null +++ b/scripting/source/dlgprov/DialogModelProvider.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "sal/config.h" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase4.hxx" +#include "com/sun/star/lang/XInitialization.hpp" +#include "com/sun/star/container/XNameContainer.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" + +/// anonymous implementation namespace +namespace dlgprov{ + +namespace css = ::com::sun::star; + +class DialogModelProvider: + public ::cppu::WeakImplHelper4< + css::lang::XInitialization, + css::container::XNameContainer, + css::beans::XPropertySet, + css::lang::XServiceInfo> +{ +public: + explicit DialogModelProvider(css::uno::Reference< css::uno::XComponentContext > const & context); +private: + // ::com::sun::star::lang::XInitialization: + virtual void SAL_CALL initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception); + + // ::com::sun::star::container::XElementAccess: + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); + + // ::com::sun::star::container::XNameAccess: + virtual ::com::sun::star::uno::Any SAL_CALL getByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException); + + // ::com::sun::star::container::XNameReplace: + virtual void SAL_CALL replaceByName(const ::rtl::OUString & aName, const ::com::sun::star::uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + + // ::com::sun::star::container::XNameContainer: + virtual void SAL_CALL insertByName(const ::rtl::OUString & aName, const ::com::sun::star::uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException); + virtual void SAL_CALL removeByName(const ::rtl::OUString & Name) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + DialogModelProvider(const DialogModelProvider &); // not defined + DialogModelProvider& operator=(const DialogModelProvider &); // not defined + + // destructor is private and will be called indirectly by the release call virtual ~DialogModelProvider() {} + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::container::XNameContainer> m_xDialogModel; + css::uno::Reference< css::beans::XPropertySet> m_xDialogModelProp; +}; +} // closing anonymous implementation namespace diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index ffa128381d39..8a577ab03e1c 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_scripting.hxx" +#include "DialogModelProvider.hxx" #include "dlgprov.hxx" #include "dlgevtatt.hxx" #include <com/sun/star/awt/XControlContainer.hpp> @@ -60,20 +61,103 @@ #include <util/MiscUtils.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::document; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; +using namespace document; using namespace ::sf_misc; +// component helper namespace +namespace comp_DialogModelProvider +{ + + ::rtl::OUString SAL_CALL _getImplementationName() + { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogModelProvider")); + } + + uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames() + { + uno::Sequence< ::rtl::OUString > s(1); + s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDialogModelProvider")); + return s; + } + + uno::Reference< uno::XInterface > SAL_CALL _create(const uno::Reference< uno::XComponentContext > & context) SAL_THROW((uno::Exception)) + { + return static_cast< ::cppu::OWeakObject * >(new dlgprov::DialogModelProvider(context)); + } +} // closing component helper namespace //......................................................................... namespace dlgprov { //......................................................................... static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAscii( "ResourceResolver" ); + + Reference< resource::XStringResourceManager > lcl_getStringResourceManager(const Reference< XComponentContext >& i_xContext,const ::rtl::OUString& i_sURL) + { + INetURLObject aInetObj( i_sURL ); + ::rtl::OUString aDlgName = aInetObj.GetBase(); + aInetObj.removeSegment(); + ::rtl::OUString aDlgLocation = aInetObj.GetMainURL( INetURLObject::NO_DECODE ); + bool bReadOnly = true; + ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); + ::rtl::OUString aComment; + + Sequence<Any> aArgs( 6 ); + aArgs[0] <<= aDlgLocation; + aArgs[1] <<= bReadOnly; + aArgs[2] <<= aLocale; + aArgs[3] <<= aDlgName; + aArgs[4] <<= aComment; + + Reference< task::XInteractionHandler > xDummyHandler; + aArgs[5] <<= xDummyHandler; + Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW ); + // TODO: Ctor + Reference< resource::XStringResourceManager > xStringResourceManager( xSMgr_->createInstanceWithContext + ( ::rtl::OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ), + i_xContext ), UNO_QUERY ); + if( xStringResourceManager.is() ) + { + Reference< XInitialization > xInit( xStringResourceManager, UNO_QUERY ); + if( xInit.is() ) + xInit->initialize( aArgs ); + } + return xStringResourceManager; + } + Reference< container::XNameContainer > lcl_createControlModel(const Reference< XComponentContext >& i_xContext) + { + Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW ); + Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ), i_xContext ), UNO_QUERY_THROW ); + return xControlModel; + } + Reference< container::XNameContainer > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext, + const Reference< io::XInputStream >& xInput, + const Reference< resource::XStringResourceManager >& xStringResourceManager, + const Any &aDialogSourceURL) throw ( Exception ) + { + Reference< container::XNameContainer > xDialogModel( lcl_createControlModel(i_xContext) ); + + ::rtl::OUString aDlgSrcUrlPropName( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" ) ); + Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); + xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); + + ::xmlscript::importDialogModel( xInput, xDialogModel, i_xContext ); + // Set resource property + if( xStringResourceManager.is() ) + { + Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); + Any aStringResourceManagerAny; + aStringResourceManagerAny <<= xStringResourceManager; + xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny ); + } + + return xDialogModel; + } // ============================================================================= // component operations // ============================================================================= @@ -173,9 +257,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< container::XNameContainer > DialogProviderImpl::createControlModel() throw ( Exception ) { - Reference< XMultiComponentFactory > xSMgr_( m_xContext->getServiceManager(), UNO_QUERY_THROW ); - Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ), m_xContext ), UNO_QUERY_THROW ); - return xControlModel; + return lcl_createControlModel(m_xContext); } Reference< container::XNameContainer > DialogProviderImpl::createDialogModel( @@ -183,23 +265,9 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs const Reference< resource::XStringResourceManager >& xStringResourceManager, const Any &aDialogSourceURL) throw ( Exception ) { - Reference< container::XNameContainer > xDialogModel( createControlModel() ); - - ::rtl::OUString aDlgSrcUrlPropName( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" ) ); - Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); - xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); - ::xmlscript::importDialogModel( xInput, xDialogModel, m_xContext ); - // Set resource property - if( xStringResourceManager.is() ) - { - Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); - Any aStringResourceManagerAny; - aStringResourceManagerAny <<= xStringResourceManager; - xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny ); - } - return xDialogModel; + return lcl_createDialogModel(m_xContext,xInput,xStringResourceManager,aDialogSourceURL); } Reference< XControlModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception ) @@ -280,8 +348,8 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs bSingleDialog = true; // Try any other URL with SimpleFileAccess - Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSFI = - Reference< ::com::sun::star::ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext + Reference< ucb::XSimpleFileAccess > xSFI = + Reference< ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ), UNO_QUERY ); try @@ -412,34 +480,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< resource::XStringResourceManager > xStringResourceManager; if( bSingleDialog ) { - INetURLObject aInetObj( aURL ); - ::rtl::OUString aDlgName = aInetObj.GetBase(); - aInetObj.removeSegment(); - ::rtl::OUString aDlgLocation = aInetObj.GetMainURL( INetURLObject::NO_DECODE ); - bool bReadOnly = true; - ::com::sun ::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); - ::rtl::OUString aComment; - - Sequence<Any> aArgs( 6 ); - aArgs[0] <<= aDlgLocation; - aArgs[1] <<= bReadOnly; - aArgs[2] <<= aLocale; - aArgs[3] <<= aDlgName; - aArgs[4] <<= aComment; - - Reference< task::XInteractionHandler > xDummyHandler; - aArgs[5] <<= xDummyHandler; - Reference< XMultiComponentFactory > xSMgr_( m_xContext->getServiceManager(), UNO_QUERY_THROW ); - // TODO: Ctor - xStringResourceManager = Reference< resource::XStringResourceManager >( xSMgr_->createInstanceWithContext - ( ::rtl::OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ), - m_xContext ), UNO_QUERY ); - if( xStringResourceManager.is() ) - { - Reference< XInitialization > xInit( xStringResourceManager, UNO_QUERY ); - if( xInit.is() ) - xInit->initialize( aArgs ); - } + xStringResourceManager = lcl_getStringResourceManager(m_xContext,aURL); } else if( xDialogLib.is() ) { @@ -794,7 +835,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< XWindow > DialogProviderImpl::createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const Reference< XWindowPeer >& xParent, const Reference< XInterface >& xHandler ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + throw (lang::IllegalArgumentException, RuntimeException) { (void)WindowType; // for future use if( !xParent.is() ) @@ -824,11 +865,8 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs static struct ::cppu::ImplementationEntry s_component_entries [] = { - { - create_DialogProviderImpl, getImplementationName_DialogProviderImpl, - getSupportedServiceNames_DialogProviderImpl, ::cppu::createSingleComponentFactory, - 0, 0 - }, + {create_DialogProviderImpl, getImplementationName_DialogProviderImpl,getSupportedServiceNames_DialogProviderImpl, ::cppu::createSingleComponentFactory,0, 0}, + { &comp_DialogModelProvider::_create,&comp_DialogModelProvider::_getImplementationName,&comp_DialogModelProvider::_getSupportedServiceNames,&::cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index bc15831d2ff1..cbe3727b045e 100644 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -61,6 +61,13 @@ namespace dlgprov // ============================================================================= // class DialogProviderImpl // ============================================================================= + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext); + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const ::rtl::OUString& i_sURL); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, + const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, + const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); typedef ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo, diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 111dca58edc2..c3a99aa81aff 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -41,6 +41,7 @@ DLLPRE = SLOFILES= \ $(SLO)$/dlgprov.obj \ + $(SLO)$/DialogModelProvider.obj \ $(SLO)$/dlgevtatt.obj SHL1TARGET= $(TARGET)$(DLLPOSTFIX).uno diff --git a/scripting/source/inc/util/util.hxx b/scripting/source/inc/util/util.hxx index 27e5c19ccc91..a07d66452e0d 100644 --- a/scripting/source/inc/util/util.hxx +++ b/scripting/source/inc/util/util.hxx @@ -29,21 +29,6 @@ #ifndef _COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ #define _COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ -#include <rtl/ustrbuf.hxx> -#include <osl/diagnose.h> - #define OUSTR(x) ::rtl::OUString( ::rtl::OUString::createFromAscii(x) ) -namespace scripting_util -{ - inline void validateXRef(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRef, const sal_Char* Msg) throw (::com::sun::star::uno::RuntimeException) - { - OSL_ENSURE( xRef.is(), Msg ); - - if(!xRef.is()) - { - throw ::com::sun::star::uno::RuntimeException(OUSTR(Msg), ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >()); - } - } -} #endif //_COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ diff --git a/scripting/source/protocolhandler/makefile.mk b/scripting/source/protocolhandler/makefile.mk index ec69c00b209d..5a2e92bbbac3 100644 --- a/scripting/source/protocolhandler/makefile.mk +++ b/scripting/source/protocolhandler/makefile.mk @@ -45,6 +45,7 @@ SHL1TARGET= $(TARGET)$(DLLPOSTFIX) SHL1STDLIBS= \ $(SFXLIB) \ + $(FWELIB) \ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(VCLLIB) \ diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 4e81426d7d53..e9d12be12b5e 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -49,10 +49,12 @@ #include <sfx2/frame.hxx> #include <sfx2/sfxdlg.hxx> #include <vcl/abstdlg.hxx> +#include <tools/diagnose_ex.h> #include <cppuhelper/factory.hxx> #include <cppuhelper/exc_hlp.hxx> #include <util/util.hxx> +#include <framework/documentundoguard.hxx> #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uri/XUriReference.hpp" @@ -69,7 +71,6 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::script; using namespace ::com::sun::star::script::provider; using namespace ::com::sun::star::document; -using namespace ::scripting_util; namespace scripting_protocolhandler { @@ -97,8 +98,7 @@ void SAL_CALL ScriptProtocolHandler::initialize( throw RuntimeException( temp, Reference< XInterface >() ); } - validateXRef( m_xFactory, - "ScriptProtocolHandler::initialize: No Service Manager available" ); + ENSURE_OR_THROW( m_xFactory.is(), "ScriptProtocolHandler::initialize: No Service Manager available" ); m_bInitialised = true; } @@ -162,7 +162,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( { try { - bool bIsDocumentScript = ( aURL.Complete.indexOf( ::rtl::OUString::createFromAscii( "document" ) ) !=-1 ); + bool bIsDocumentScript = ( aURL.Complete.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "document" ) ) !=-1 ); // TODO: isn't this somewhat strange? This should be a test for a location=document parameter, shouldn't it? if ( bIsDocumentScript ) @@ -182,7 +182,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( Reference< provider::XScript > xFunc = m_xScriptProvider->getScript( aURL.Complete ); - validateXRef( xFunc, + ENSURE_OR_THROW( xFunc.is(), "ScriptProtocolHandler::dispatchWithNotification: validate xFunc - unable to obtain XScript interface" ); @@ -207,6 +207,11 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( } } + // attempt to protect the document against the script tampering with its Undo Context + ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard; + if ( bIsDocumentScript ) + pUndoGuard.reset( new ::framework::DocumentUndoGuard( m_xScriptInvocation ) ); + bSuccess = sal_False; while ( !bSuccess ) { @@ -248,16 +253,6 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( bCaughtException = TRUE; } -#ifdef _DEBUG - catch ( ... ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught unknown exception" ); - - invokeResult <<= reason; - } -#endif - } else { @@ -358,13 +353,11 @@ ScriptProtocolHandler::getScriptInvocation() return m_xScriptInvocation.is(); } -void -ScriptProtocolHandler::createScriptProvider() +void ScriptProtocolHandler::createScriptProvider() { if ( m_xScriptProvider.is() ) - { return; - } + try { // first, ask the component supporting the XScriptInvocationContext interface @@ -397,6 +390,7 @@ ScriptProtocolHandler::createScriptProvider() m_xScriptProvider = xSPS->getScriptProvider(); } + // if nothing of this is successful, use the master script provider if ( !m_xScriptProvider.is() ) { Reference< XPropertySet > xProps( m_xFactory, UNO_QUERY_THROW ); @@ -430,15 +424,6 @@ ScriptProtocolHandler::createScriptProvider() ::rtl::OUString temp = OUSTR( "ScriptProtocolHandler::createScriptProvider: " ); throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } -#ifdef _DEBUG - catch ( ... ) - { - throw RuntimeException( - OUSTR( "ScriptProtocolHandler::createScriptProvider: UnknownException: " ), - Reference< XInterface > () ); - } -#endif - } ScriptProtocolHandler::ScriptProtocolHandler( diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index 3c6206d8d051..bbabbb21405c 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -49,7 +49,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::script; -using namespace ::scripting_util; using namespace ::sf_misc; namespace func_provider diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index 94ea78f80c73..33d371e3d51b 100755 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -33,6 +33,8 @@ #include <cppuhelper/implementationentry.hxx> #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/factory.hxx> +#include <tools/diagnose_ex.h> + #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> @@ -60,7 +62,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::script; using namespace ::com::sun::star::document; using namespace ::sf_misc; -using namespace ::scripting_util; namespace func_provider { @@ -95,10 +96,9 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > m_xContext( xContext ), m_bIsValid( false ), m_bInitialised( false ), m_bIsPkgMSP( false ), m_pPCache( 0 ) { - validateXRef( m_xContext, "MasterScriptProvider::MasterScriptProvider: No context available\n" ); + ENSURE_OR_THROW( m_xContext.is(), "MasterScriptProvider::MasterScriptProvider: No context available\n" ); m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "MasterScriptProvider::MasterScriptProvider: No service manager available\n" ); + ENSURE_OR_THROW( m_xMgr.is(), "MasterScriptProvider::MasterScriptProvider: No service manager available\n" ); m_bIsValid = true; } diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx index 5d3350f635e3..bea38a67a8f1 100644 --- a/scripting/source/provider/ProviderCache.cxx +++ b/scripting/source/provider/ProviderCache.cxx @@ -29,6 +29,7 @@ #include "precompiled_scripting.hxx" #include <cppuhelper/implementationentry.hxx> #include <cppuhelper/factory.hxx> +#include <tools/diagnose_ex.h> #include <util/scriptingconstants.hxx> #include <util/util.hxx> @@ -39,7 +40,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::script; -using namespace ::scripting_util; namespace func_provider { @@ -51,7 +51,7 @@ ProviderCache::ProviderCache( const Reference< XComponentContext >& xContext, co // will use createContentEnumeration m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); + ENSURE_OR_THROW( m_xMgr.is(), "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); populateCache(); } @@ -64,7 +64,7 @@ ProviderCache::ProviderCache( const Reference< XComponentContext >& xContext, co // will use createContentEnumeration m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); + ENSURE_OR_THROW( m_xMgr.is(), "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); populateCache(); } @@ -163,14 +163,8 @@ ProviderCache::populateCache() throw ( RuntimeException ) while ( xEnum->hasMoreElements() ) { - Reference< lang::XSingleComponentFactory > factory; - if ( sal_False == ( xEnum->nextElement() >>= factory ) ) - { - throw new RuntimeException( ::rtl::OUString::createFromAscii( " error extracting XSingleComponentFactory from Content enumeration. " ), Reference< XInterface >() ); - } - validateXRef( factory, "ProviderCache::populateCache() invalid factory" ); + Reference< lang::XSingleComponentFactory > factory( xEnum->nextElement(), UNO_QUERY_THROW ); Reference< lang::XServiceInfo > xServiceInfo( factory, UNO_QUERY_THROW ); - validateXRef( xServiceInfo, "ProviderCache::populateCache() failed to get XServiceInfo from factory" ); Sequence< ::rtl::OUString > serviceNames = xServiceInfo->getSupportedServiceNames(); @@ -207,9 +201,8 @@ ProviderCache::createProvider( ProviderDetails& details ) throw ( RuntimeExcepti { try { - details.provider = Reference< provider::XScriptProvider >( + details.provider.set( details.factory->createInstanceWithArgumentsAndContext( m_Sctx, m_xContext ), UNO_QUERY_THROW ); - validateXRef( details.provider, "ProviderCache::createProvider, failed to create provider"); } catch ( RuntimeException& e ) { diff --git a/scripting/source/provider/ScriptImpl.cxx b/scripting/source/provider/ScriptImpl.cxx index f5b93a802138..08d548e3461c 100644 --- a/scripting/source/provider/ScriptImpl.cxx +++ b/scripting/source/provider/ScriptImpl.cxx @@ -46,15 +46,11 @@ ScriptImpl::ScriptImpl( const Reference< runtime::XScriptInvocation > & runtimeMgr, const ::rtl::OUString& scriptURI ) throw ( RuntimeException ) : - m_XScriptingContext( scriptingContext ), - m_RunTimeManager( runtimeMgr ), + m_XScriptingContext( scriptingContext, UNO_SET_THROW ), + m_RunTimeManager( runtimeMgr, UNO_SET_THROW ), m_ScriptURI( scriptURI ) { OSL_TRACE( "<!constucting a ScriptImpl>\n" ); - validateXRef( m_XScriptingContext, - "ScriptImpl::ScriptImpl: No XScriptingContext\n" ); - validateXRef( m_RunTimeManager, - "ScriptImpl::ScriptImpl: No XScriptInvocation\n" ); } //************************************************************************* diff --git a/scripting/source/provider/ScriptingContext.cxx b/scripting/source/provider/ScriptingContext.cxx index 08a27a19562f..0394bd3653d1 100755 --- a/scripting/source/provider/ScriptingContext.cxx +++ b/scripting/source/provider/ScriptingContext.cxx @@ -55,13 +55,10 @@ namespace func_provider //************************************************************************* ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : //ScriptingContextImpl_BASE( GetMutex()), OPropertyContainer( GetBroadcastHelper() ), - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptingContext ctor called >\n" ); - validateXRef( m_xContext, - "ScriptingContext::ScriptingContext: No context available\n" ); - Any nullAny; scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = diff --git a/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx index 48b960c6c9aa..8dafab0e8d4c 100644 --- a/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx +++ b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx @@ -70,13 +70,11 @@ static ::std::vector< sal_Int32 >* m_pSearchIDs = NULL; //************************************************************************* ScriptNameResolverImpl::ScriptNameResolverImpl( const Reference< XComponentContext > & xContext ) : - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptNameResolverImpl ctor called >\n" ); validateXRef( m_xContext, "ScriptNameResolverImpl::ScriptNameResolverImpl: invalid context" ); - m_xMultiComFac = m_xContext->getServiceManager(); - - validateXRef( m_xMultiComFac, "ScriptNameResolverImpl::ScriptNameResolverImpl: invalid XMultiComponentFactory " ); + m_xMultiComFac.set( m_xContext->getServiceManager(), UNO_SET_THROW ); if( !m_pSearchIDs ) { @@ -220,11 +218,13 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: " ); throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } - Reference< XInterface > xInterface = m_xMultiComFac->createInstanceWithContext( - ::rtl::OUString::createFromAscii( - "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ); - validateXRef( xInterface, - "ScriptProvider::initialise: cannot get SimpleFileAccess Service\n" ); + Reference< XInterface > xInterface( + m_xMultiComFac->createInstanceWithContext( + ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), + m_xContext + ), + UNO_SET_THROW + ); Reference < ucb::XSimpleFileAccess > xSimpleFileAccess = Reference < ucb::XSimpleFileAccess > ( xInterface, UNO_QUERY_THROW ); @@ -236,15 +236,8 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE try { // need to get the ScriptStorageManager - Any a = m_xContext->getValueByName( - scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ); - if ( sal_False == ( a >>= xScriptStorageMgr ) ) - { - OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: failed to get ScriptStorageManager" ); - throw RuntimeException( temp, Reference< XInterface >() ); - // need to throw - } - validateXRef( xScriptStorageMgr, "Cannot get ScriptStorageManager" ); + xScriptStorageMgr.set( m_xContext->getValueByName( + scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ), UNO_QUERY_THROW ); filesysScriptStorageID = xScriptStorageMgr->createScriptStorageWithURI( xSimpleFileAccess, filesysURL ); @@ -364,20 +357,12 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE if( filesysScriptStorageID > 2 ) { // get the filesys storage and dispose of it - Reference< XInterface > xScriptStorage = - xScriptStorageMgr->getScriptStorage( filesysScriptStorageID ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); + Reference< XInterface > xScriptStorage( xScriptStorageMgr->getScriptStorage( filesysScriptStorageID ), UNO_SET_THROW ); Reference< storage::XScriptInfoAccess > xScriptInfoAccess = Reference< storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); - validateXRef( xScriptInfoAccess, - "ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptInfoAccess" ); Sequence< Reference< storage::XScriptInfo > > results = xScriptInfoAccess->getAllImplementations( ); - Reference < lang::XEventListener > xEL_ScriptStorageMgr = - Reference< lang::XEventListener > - ( xScriptStorageMgr ,UNO_QUERY_THROW ); - validateXRef( xEL_ScriptStorageMgr, "ScriptNameResolverImpl::resolve: can't get ScriptStorageManager XEventListener interface when trying to dispose of filesystem storage" ); + Reference < lang::XEventListener > xEL_ScriptStorageMgr(( xScriptStorageMgr ,UNO_QUERY_THROW ); lang::EventObject event( results[ 0 ] ); xEL_ScriptStorageMgr->disposing( event ); } @@ -447,9 +432,7 @@ SAL_THROW ( ( lang::IllegalArgumentException, css::security::AccessControlExcept throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } } - Reference< storage::XScriptInfoAccess > storage = getStorageInstance( sid, permissionURI ); - validateXRef( storage, - "ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptInfoAccess" ); + Reference< storage::XScriptInfoAccess > storage( getStorageInstance( sid, permissionURI ), UNO_SET_THROW ); Sequence< Reference< storage::XScriptInfo > > results = storage->getImplementations( scriptURI ); @@ -516,22 +499,10 @@ const ::rtl::OUString & permissionURI ) SAL_THROW ( ( RuntimeException, css::sec Reference< storage::XScriptInfoAccess > xScriptInfoAccess; try { - Reference< XInterface > xInterface; - - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - OUSTR( "ScriptNameResolverImpl::getStorageInstance: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptNameResolverImpl::getStorageInstance: cannot get Storage service" ); + Reference< XInterface > xInterface( m_xContext->getValueByName( + OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ), UNO_QUERY_THROW ); // check that we have permissions for this storage Reference< dcsssf::security::XScriptSecurity > xScriptSecurity( xInterface, UNO_QUERY_THROW ); - validateXRef( xScriptSecurity, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Security service" ); scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = scripting_constants::ScriptingConstantsPool::instance(); // if we dealing with a document storage (ie. not user or share @@ -546,14 +517,8 @@ const ::rtl::OUString & permissionURI ) SAL_THROW ( ( RuntimeException, css::sec OSL_TRACE( "ScriptNameResolverImpl::getStorageInstance: got execute permission for ID=%d", sid ); } Reference< storage::XScriptStorageManager > xScriptStorageManager( xInterface, UNO_QUERY_THROW ); - validateXRef( xScriptStorageManager, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage Manager service" ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( sid ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); - xScriptInfoAccess = Reference< - storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); + Reference< XInterface > xScriptStorage( ScriptStorageManager->getScriptStorage( sid ), UNO_SET_THROW ); + xScriptInfoAccess.set( xScriptStorage, UNO_QUERY_THROW ); } catch ( lang::IllegalArgumentException & e ) { diff --git a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx index 4780d58acc88..79a44bebce7d 100755 --- a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx +++ b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx @@ -37,6 +37,7 @@ #include <util/scriptingconstants.hxx> #include <cppuhelper/implementationentry.hxx> +#include <tools/diagnose_ex.h> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XEventListener.hpp> @@ -68,14 +69,10 @@ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceNam // ScriptRuntimeManager Constructor ScriptRuntimeManager::ScriptRuntimeManager( const Reference< XComponentContext > & xContext ) : - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptRuntimeManager ctor called >\n" ); - validateXRef( m_xContext, - "ScriptRuntimeManager::ScriptRuntimeManager: invalid context" ); - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptRuntimeManager::ScriptRuntimeManager: cannot get ServiceManager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); // test //scripting_securitymgr::ScriptSecurityManager ssm(xContext); @@ -106,22 +103,12 @@ throw( RuntimeException ) Reference< storage::XScriptInfo > sinfo = Reference< storage::XScriptInfo >( scriptInfo, UNO_QUERY_THROW ); - OUStringBuffer *buf = new OUStringBuffer(80); - buf->appendAscii("/singletons/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeFor"); - buf->append(sinfo->getLanguage()); + OUStringBuffer* buf( 80 ); + buf.appendAscii("/singletons/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeFor"); + buf.append(sinfo->getLanguage()); - Any a = m_xContext->getValueByName(buf->makeStringAndClear()); - - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - sinfo->getLanguage().concat( OUSTR( " runtime support is not installed for this language" ) ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptRuntimeManager::GetScriptRuntime: cannot get appropriate ScriptRuntime Service" - ); - xScriptInvocation = Reference< runtime::XScriptInvocation >( xInterface, UNO_QUERY_THROW ); + xInterface.set( m_xContext->getValueByName( buf.makeStringAndClear() ), UNO_QUERY_THROW ); + xScriptInvocation.set( xInterface, UNO_QUERY_THROW ); } catch ( Exception & e ) { @@ -143,13 +130,14 @@ throw( RuntimeException ) try { - Reference< XInterface > xInterface = m_xMgr->createInstanceWithContext( - OUString::createFromAscii( - "drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ), - m_xContext ); - validateXRef( xInterface, - "ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" ); - xScriptNameResolver = Reference< runtime::XScriptNameResolver >( xInterface, UNO_QUERY_THROW ); + Reference< XInterface > xInterface( + m_xMgr->createInstanceWithContext( + OUString::createFromAscii("drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ), + m_xContext + ), + UNO_SET_THROW + ); + xScriptNameResolver.set( xInterface, UNO_QUERY_THROW ); } catch ( Exception & e ) { @@ -182,9 +170,8 @@ Any SAL_CALL ScriptRuntimeManager::invoke( try { - Reference< storage::XScriptInfo > resolvedScript = resolve( scriptURI, - resolvedCtx ); - validateXRef( resolvedScript, "ScriptRuntimeManager::invoke: No resolvedURI" ); + Reference< storage::XScriptInfo > resolvedScript = resolve( scriptURI, resolvedCtx ); + ENSURE_OR_THROW( resolvedScript.is(), "ScriptRuntimeManager::invoke: No resolvedURI" ); Reference< beans::XPropertySet > xPropSetResolvedCtx; if ( sal_False == ( resolvedCtx >>= xPropSetResolvedCtx ) ) @@ -216,7 +203,7 @@ Any SAL_CALL ScriptRuntimeManager::invoke( Reference< runtime::XScriptInvocation > xScriptInvocation = getScriptRuntime( resolvedScript ); - validateXRef( xScriptInvocation, + ENSURE_OR_THROW( xScriptInvocation.is(), "ScriptRuntimeManager::invoke: cannot get instance of language specific runtime." ); // the scriptURI is currently passed to the language-dept runtime but @@ -232,13 +219,7 @@ Any SAL_CALL ScriptRuntimeManager::invoke( { Any a = m_xContext->getValueByName( scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ); - Reference < lang::XEventListener > xEL_ScriptStorageManager; - if ( sal_False == ( a >>= xEL_ScriptStorageManager ) ) - { - throw RuntimeException( OUSTR( "ScriptRuntimeManager::invoke: can't get ScriptStorageManager XEventListener interface when trying to dispose of filesystem storage" ), - Reference< XInterface > () ); - } - validateXRef( xEL_ScriptStorageManager, "Cannot get XEventListener from ScriptStorageManager" ); + Reference < lang::XEventListener > xEL_ScriptStorageManager( a, UNO_QUERY_THROW ); lang::EventObject event(resolvedScript); xEL_ScriptStorageManager->disposing( event ); } @@ -310,7 +291,7 @@ throw( lang::IllegalArgumentException, script::CannotConvertException, RuntimeEx Reference< storage::XScriptInfo > resolvedURI; Reference< runtime::XScriptNameResolver > xScriptNameResolver = getScriptNameResolver(); - validateXRef( xScriptNameResolver, + ENSURE_OR_THROW( xScriptNameResolver.is(), "ScriptRuntimeManager::resolve: No ScriptNameResolver" ); try diff --git a/scripting/source/runtimemgr/StorageBridge.cxx b/scripting/source/runtimemgr/StorageBridge.cxx index d1915afba9e5..1e15cf808870 100644 --- a/scripting/source/runtimemgr/StorageBridge.cxx +++ b/scripting/source/runtimemgr/StorageBridge.cxx @@ -54,9 +54,8 @@ const int STORAGEPROXY = 0; //************************************************************************* // StorageBridge Constructor StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext, - sal_Int32 sid ) : m_xContext( xContext ), m_sid( sid ) + sal_Int32 sid ) : m_xContext( xContext, UNO_SET_THROW ), m_sid( sid ) { - validateXRef( m_xContext, "StorageBridge::StorageBridge: invalid context" ); try { initStorage(); @@ -74,31 +73,12 @@ StorageBridge::initStorage() throw ( ::com::sun::star::uno::RuntimeException ) { try { - Reference< lang::XMultiComponentFactory > xMultiComFac = - m_xContext->getServiceManager(); - validateXRef( xMultiComFac, - "StorageBridge::StorageBridge: cannot get multicomponentfactory from multiservice factory" ); - Reference< XInterface > temp; - - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= temp ) ) - { - throw RuntimeException( - OUSTR( "StorageBridge::StorageBridge: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( temp, - "StorageBridge::StorageBridge: cannot get Storage service" ); + Reference< lang::XMultiComponentFactory > xMultiComFac( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< XInterface > temp( m_xContext->getValueByName( + OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ), UNO_QUERY_THROW ); Reference< storage::XScriptStorageManager > xScriptStorageManager( temp, UNO_QUERY_THROW ); - validateXRef( xScriptStorageManager, - "StorageBridge::StorageBridge: cannot get Script Storage Manager service" ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( m_sid ); - validateXRef( xScriptStorage, - "StorageBridge::StorageBridge: cannot get Script Storage service" ); - m_xScriptInfoAccess = - Reference< storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); + Reference< XInterface > xScriptStorage( xScriptStorageManager->getScriptStorage( m_sid ), UNO_SET_THROW ); + m_xScriptInfoAccess.set( xScriptStorage, UNO_QUERY_THROW ); } catch ( RuntimeException & re ) { diff --git a/scripting/source/storage/ScriptMetadataImporter.cxx b/scripting/source/storage/ScriptMetadataImporter.cxx index 64dd87b2546b..96faf6e9c1f4 100644 --- a/scripting/source/storage/ScriptMetadataImporter.cxx +++ b/scripting/source/storage/ScriptMetadataImporter.cxx @@ -38,7 +38,7 @@ #include <com/sun/star/xml/sax/XParser.hpp> #include <rtl/string.h> - +#include <tools/diagnose_ex.h> #include <util/util.hxx> @@ -82,31 +82,14 @@ void ScriptMetadataImporter::parseMetaData( ms_parcelURI = parcelURI; //Get the parser service - validateXRef( m_xContext, + ENSURE_OR_THROW( m_xContext.is(), "ScriptMetadataImporter::parseMetaData: No context available" ); - Reference< lang::XMultiComponentFactory > xMgr = - m_xContext->getServiceManager(); - - validateXRef( xMgr, - "ScriptMetadataImporter::parseMetaData: No service manager available" ); - - Reference< XInterface > xInterface = xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); - validateXRef( xInterface, "ScriptMetadataImporter::parseMetaData: cannot get SAX Parser" ); - Reference< xml::sax::XParser > xParser; - try - { - xParser.set( xInterface ,UNO_QUERY_THROW ); - } - catch (RuntimeException & re ) - { - OUString msg = OUString::createFromAscii( - "ScriptMetadata:Importer::parserMetaData cannot get XParser" ); - msg.concat( re.Message ); - throw RuntimeException( msg, Reference< XInterface > () ); - } + Reference< xml::sax::XParser > xParser( + xMgr->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext ), + UNO_QUERY_THROW ); // xxx todo: error handler, entity resolver omitted // This class is the document handler for the parser diff --git a/scripting/source/storage/ScriptSecurityManager.cxx b/scripting/source/storage/ScriptSecurityManager.cxx index 3fde4e466974..fbe6f41b4663 100755 --- a/scripting/source/storage/ScriptSecurityManager.cxx +++ b/scripting/source/storage/ScriptSecurityManager.cxx @@ -47,7 +47,7 @@ #include "ScriptSecurityManager.hxx" #include <util/util.hxx> #include <util/scriptingconstants.hxx> - +#include <tools/diagnose_ex.h> using namespace ::rtl; using namespace ::osl; @@ -85,28 +85,15 @@ static const int ADD_TO_PATH = 2; // ScriptSecurityManager Constructor ScriptSecurityManager::ScriptSecurityManager( const Reference< XComponentContext > & xContext ) throw ( RuntimeException ) - : m_xContext( xContext) + : m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptSecurityManager ctor called >\n" ); - validateXRef( m_xContext, - "ScriptSecurityManager::ScriptSecurityManager: invalid context" ); // get the service manager from the context - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::ScriptSecurityManager: cannot get ServiceManager" ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); // create an instance of the ConfigurationProvider - Reference< XInterface > xInterface = xMgr->createInstanceWithContext( - s_configProv, m_xContext ); - validateXRef( xInterface, - "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" ); - // create an instance of the ConfigurationAccess for accessing the - // scripting security settings - m_xConfigProvFactory = Reference < lang::XMultiServiceFactory > ( xInterface, UNO_QUERY ); - validateXRef( m_xConfigProvFactory, - "ScriptSecurityManager::ScriptSecurityManager: cannot get XMultiServiceFactory interface from ConfigurationProvider" ); - + m_xConfigProvFactory.set( xMgr->createInstanceWithContext( s_configProv, m_xContext ), UNO_QUERY_THROW ); } void ScriptSecurityManager::addScriptStorage( rtl::OUString scriptStorageURL, @@ -131,35 +118,6 @@ throw ( RuntimeException ) //need to check if storage has any scripts try { - /* need to replace this with something better, now logical names are - * gone - - Reference< XInterface > xInterface; - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager::addScriptStorage: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptSecurityManager::addScriptStorage: cannot get Storage service" ); - Reference< storage::XScriptStorageManager > xScriptStorageManager( - xInterface, UNO_QUERY_THROW ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( storageID ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); - Reference< storage::XScriptInfoAccess > xScriptInfoAccess = - Reference< storage::XScriptInfoAccess > ( xScriptStorage, - UNO_QUERY_THROW ); - Sequence< ::rtl::OUString > logicalNames = xScriptInfoAccess->getScriptLogicalNames(); - if( !logicalNames.getLength() ) // we have no logical names - { - return; - } */ - // we have some scripts so read config & decide on that basis // Setup flags: m_runMacroSetting, m_warning, m_confirmationRequired, readConfiguration(); @@ -317,17 +275,12 @@ throw ( RuntimeException ) short result; try { - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::executeDialog: cannot get ServiceManager" ); - Reference< XInterface > xInterface = - xMgr->createInstanceWithArgumentsAndContext( s_securityDialog, - aArgs, m_xContext ); - validateXRef( xInterface, "ScriptSecurityManager::executeDialog: Can't create SecurityDialog" ); - Reference< awt::XDialog > xDialog( xInterface, UNO_QUERY_THROW ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< awt::XDialog > xDialog( + xMgr->createInstanceWithArgumentsAndContext( s_securityDialog, aArgs, m_xContext ), + UNO_QUERY_THROW ); result = xDialog->execute(); - Reference< lang::XComponent > xComponent( xInterface, UNO_QUERY_THROW ); - validateXRef( xInterface, "ScriptSecurityManager::executeDialog: Can't get XComponent to dispose dialog" ); + Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY_THROW ); xComponent->dispose(); } catch ( RuntimeException & rte ) @@ -410,31 +363,20 @@ void ScriptSecurityManager::removePermissionSettings ( ::rtl::OUString & scriptS void ScriptSecurityManager::readConfiguration() throw ( RuntimeException) { - Reference< XInterface > xInterface; try { - beans::PropertyValue configPath; - configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); - configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); - Sequence < Any > aargs( 1 ); - aargs[ 0 ] <<= configPath; - validateXRef( m_xConfigProvFactory, - "ScriptSecurityManager::readConfiguration: ConfigProviderFactory no longer valid!" ); - xInterface = m_xConfigProvFactory->createInstanceWithArguments( s_configAccess, - aargs ); - validateXRef( xInterface, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationAccess" ); - // get the XPropertySet interface from the ConfigurationAccess service - Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY ); - Any value; - - value=xPropSet->getPropertyValue( OUSTR( "Confirmation" ) ); - if ( sal_False == ( value >>= m_confirmationRequired ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get Confirmation setting" ), - Reference< XInterface > () ); - } + beans::PropertyValue configPath; + configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); + configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); + Sequence < Any > aargs( 1 ); + aargs[ 0 ] <<= configPath; + ENSURE_OR_THROW( m_xConfigProvFactory.is(), + "ScriptSecurityManager::readConfiguration: ConfigProviderFactory no longer valid!" ); + // get the XPropertySet interface from the ConfigurationAccess service + Reference < beans::XPropertySet > xPropSet( m_xConfigProvFactory->createInstanceWithArguments( s_configAccess, aargs ), UNO_QUERY_THROW ); + + m_confirmationRequired = sal_True; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "Confirmation" ) ) >>= m_confirmationRequired ); if ( m_confirmationRequired == sal_True ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration: confirmation is true" ); @@ -443,13 +385,10 @@ void ScriptSecurityManager::readConfiguration() { OSL_TRACE( "ScriptSecurityManager:readConfiguration: confirmation is false" ); } - value=xPropSet->getPropertyValue( OUSTR( "Warning" ) ); - if ( sal_False == ( value >>= m_warning ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get Warning setting" ), - Reference< XInterface > () ); - } + + m_warning = true; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "Warning" ) ) >>= m_warning ); + if ( m_warning == sal_True ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration: warning is true" ); @@ -458,21 +397,13 @@ void ScriptSecurityManager::readConfiguration() { OSL_TRACE( "ScriptSecurityManager:readConfiguration: warning is false" ); } - value=xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) ); - if ( sal_False == ( value >>= m_runMacroSetting ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get OfficeBasic setting" ), - Reference< XInterface > () ); - } + + m_runMacroSetting = sal_True; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) ) >>= m_runMacroSetting ); OSL_TRACE( "ScriptSecurityManager:readConfiguration: OfficeBasic = %d", m_runMacroSetting ); - value=xPropSet->getPropertyValue( OUSTR( "SecureURL" ) ); - if ( sal_False == ( value >>= m_secureURL ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get SecureURL setting" ), - Reference< XInterface > () ); - } + + m_secureURL = ::rtl::OUString(); + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "SecureURL" ) ) >>= m_secureURL ); } catch ( beans::UnknownPropertyException & upe ) { @@ -508,18 +439,14 @@ void ScriptSecurityManager::readConfiguration() int length = m_secureURL.getLength(); // PathSubstitution needed to interpret variables found in config - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::readConfiguration: cannot get XMultiComponentFactory" ); - xInterface = xMgr->createInstanceWithContext( - ::rtl::OUString::createFromAscii( - "com.sun.star.util.PathSubstitution"), m_xContext); - validateXRef( xInterface, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationProvider" ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< XInterface > xInterface = ); Reference< util::XStringSubstitution > xStringSubstitution( - xInterface, UNO_QUERY); - validateXRef( xStringSubstitution, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationProvider" ); + xMgr->createInstanceWithContext( + ::rtl::OUString::createFromAscii( "com.sun.star.util.PathSubstitution" ), m_xContext + ), + UNO_QUERY_THROW + ); for( int i = 0; i < length; i++ ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration path = %s", @@ -552,16 +479,9 @@ throw ( RuntimeException ) configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); Sequence < Any > aargs( 1 ); aargs[ 0 ] <<= configPath; - Reference< XInterface > xInterface = m_xConfigProvFactory->createInstanceWithArguments( s_configUpdate, - aargs ); - validateXRef( xInterface, - "ScriptSecurityManager::addToSecurePaths: ScriptSecurityManager: cannot get ConfigurationUpdateAccess" ); - Reference < container::XNameReplace > xNameReplace( xInterface, UNO_QUERY ); - validateXRef( xNameReplace, - "ScriptSecurityManager::addToSecurePaths: ScriptSecurityManager: cannot get XNameReplace" ); - Reference < util::XChangesBatch > xChangesBatch( xInterface, UNO_QUERY ); - validateXRef( xChangesBatch, - "ScriptSecurityManager::addToSecurePaths: cannot get XChangesBatch" ); + Reference < container::XNameReplace > xNameReplace( + m_xConfigProvFactory->createInstanceWithArguments( s_configUpdate, aargs ), UNO_QUERY_THROW ); + Reference < util::XChangesBatch > xChangesBatch( xNameReplace, UNO_QUERY_THROW ); OSL_TRACE( "--->ScriptSecurityManager::addToSecurePaths: after if stuff" ); Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY ); diff --git a/scripting/source/storage/ScriptStorage.cxx b/scripting/source/storage/ScriptStorage.cxx index 7315e9d35dd5..e4ea5f231f47 100644 --- a/scripting/source/storage/ScriptStorage.cxx +++ b/scripting/source/storage/ScriptStorage.cxx @@ -84,16 +84,11 @@ const sal_uInt16 NUMBER_STORAGE_INITIALIZE_ARGS = 3; ScriptStorage::ScriptStorage( const Reference < XComponentContext > & xContext ) throw ( RuntimeException ) - : m_xContext( xContext ), m_bInitialised( false ) + : m_xContext( xContext, UNO_SET_THROW ), m_bInitialised( false ) { OSL_TRACE( "< ScriptStorage ctor called >\n" ); - validateXRef( m_xContext, - "ScriptStorage::ScriptStorage : cannot get component context" ); - - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptStorage::ScriptStorage : cannot get service manager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); if( !mh_scriptLangs ) { @@ -101,47 +96,30 @@ throw ( RuntimeException ) if( !mh_scriptLangs ) { mh_scriptLangs = new ScriptLanguages_hash(); - Reference< XInterface > xInterface = - m_xMgr->createInstanceWithContext( - OUString::createFromAscii( - "com.sun.star.configuration.ConfigurationProvider" ) - , m_xContext ); - validateXRef( xInterface, - "ScriptStorage::ScriptStorage: cannot get ConfigurationProvider" ); + Reference< lang::XMultiServiceFactory > xConfigProvFactory( + m_xMgr->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), m_xContext ), + UNO_QUERY_THROW ); // create an instance of the ConfigurationAccess for accessing the // scripting runtime settings - Reference< lang::XMultiServiceFactory > xConfigProvFactory = - Reference < lang::XMultiServiceFactory > - ( xInterface, UNO_QUERY_THROW ); - validateXRef( xConfigProvFactory, - "ScriptStorage::ScriptStorage: cannot get XMultiServiceFactory interface from ConfigurationProvider" ); beans::PropertyValue configPath; configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Scripting/ScriptRuntimes" ); Sequence < Any > aargs( 1 ); aargs[ 0 ] <<= configPath; - xInterface = xConfigProvFactory->createInstanceWithArguments( - OUString::createFromAscii( - "com.sun.star.configuration.ConfigurationAccess"), - aargs ); - validateXRef( xInterface, - "ScriptStorage::ScriptStorage: cannot get ConfigurationAccess" ); - Reference< container::XNameAccess > xNameAccess = - Reference < container::XNameAccess > ( xInterface, - UNO_QUERY_THROW ); - validateXRef( xNameAccess, - "ScriptStorage::ScriptStorage: cannot get ConfigurationAccess" ); + Reference< container::XNameAccess > xNameAccess( + xConfigProvFactory->createInstanceWithArguments( + OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ), + aargs + ), + UNO_QUERY_THROW ); + Sequence< OUString > names = xNameAccess->getElementNames(); for( int i = 0 ; i < names.getLength() ; i++ ) { OSL_TRACE( "Getting propertyset for Lang=%s", ::rtl::OUStringToOString( names[i], RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< beans::XPropertySet > xPropSet = - Reference< beans::XPropertySet >( xNameAccess->getByName(names[i]), - UNO_QUERY_THROW ); - validateXRef( xPropSet, - "ScriptStorage::ScriptStorage: cannot get XPropertySet for name" ); + Reference< beans::XPropertySet > xPropSet( xNameAccess->getByName( names[i] ), UNO_QUERY_THROW ); Any aProp = xPropSet->getPropertyValue( OUString::createFromAscii( "SupportedFileExtensions") ); Sequence< OUString > extns; @@ -285,9 +263,7 @@ throw ( RuntimeException, Exception ) OUString xStringUri(m_stringUri); ScriptMetadataImporter* SMI = new ScriptMetadataImporter( m_xContext ); - Reference< xml::sax::XExtendedDocumentHandler > xSMI( SMI ); - - validateXRef( xSMI, "ScriptStorage::create: failed to obtain valid XExtendedDocumentHandler" ); + Reference< xml::sax::XExtendedDocumentHandler > xSMI( SMI, UNO_SET_THROW ); xStringUri = xStringUri.concat( ::rtl::OUString::createFromAscii( SCRIPT_DIR ) ); @@ -587,15 +563,14 @@ throw ( RuntimeException ) "/parcel.xml" ) ), RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< XInterface > xInterface = + xHandler.set( m_xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ), - m_xContext ); - validateXRef( xInterface, "ScriptStorage::save: cannot get sax.Writer" ); - xHandler = Reference<xml::sax::XExtendedDocumentHandler>( - xInterface, UNO_QUERY_THROW ); - xSource = Reference< io::XActiveDataSource >( - xHandler, UNO_QUERY_THROW ); + OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ), + m_xContext + ), + UNO_QUERY_THROW + ); + xSource.set( xHandler, UNO_QUERY_THROW ); xSource->setOutputStream( xOS ); writeMetadataHeader( xHandler ); diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx index 77ca5a45dd15..424f2752bc47 100644 --- a/scripting/source/storage/ScriptStorageManager.cxx +++ b/scripting/source/storage/ScriptStorageManager.cxx @@ -45,6 +45,7 @@ #include "ScriptStorageManager.hxx" #include <util/util.hxx> #include <util/scriptingconstants.hxx> +#include <tools/diagnose_ex.h> using namespace ::rtl; using namespace ::com::sun::star; @@ -70,32 +71,19 @@ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceNam // ScriptStorageManager Constructor ScriptStorageManager::ScriptStorageManager( const Reference< XComponentContext > & xContext ) SAL_THROW ( ( RuntimeException ) ) - : m_xContext( xContext ), m_count( 0 ), m_securityMgr( xContext ) + : m_xContext( xContext, UNO_SET_THROW ), m_count( 0 ), m_securityMgr( xContext ) { OSL_TRACE( "< ScriptStorageManager ctor called >\n" ); //s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); - validateXRef( m_xContext, - "ScriptStorageManager::ScriptStorageManager : cannot get component context" ); - - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptStorageManager::ScriptStorageManager : cannot get service manager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); try { // obtain the macro expander singleton to use in determining the // location of the application script storage - Any aAny = m_xContext->getValueByName( OUString::createFromAscii( - "/singletons/com.sun.star.util.theMacroExpander" ) ); - Reference< util::XMacroExpander > xME; - if ( sal_False == ( aAny >>= xME ) ) - { - throw RuntimeException( - OUSTR( "ScriptStorageManager::ScriptStorageManager: can't get XMacroExpander" ), - Reference< XInterface >() ); - } - validateXRef( xME, "ScriptStorageManager constructor: can't get MacroExpander" ); + Reference< util::XMacroExpander > xME( m_xContext->getValueByName( OUString::createFromAscii( + "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY_THROW ); OUString base = OUString::createFromAscii( SAL_CONFIGFILE( "${$BRAND_BASE_DIR/program/bootstrap" ) ); @@ -126,12 +114,13 @@ SAL_THROW ( ( RuntimeException ) ) { try { - Reference< XInterface > xInterface = + Reference< ucb::XSimpleFileAccess > xSFA( m_xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ); - validateXRef( xInterface, - "ScriptStorageManager constructor: can't get SimpleFileAccess XInterface" ); - Reference< ucb::XSimpleFileAccess > xSFA( xInterface, UNO_QUERY_THROW ); + OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), + m_xContext + ), + UNO_QUERY_THROW + ); setupAnyStorage( xSFA, xME->expandMacros( storageStr ), appStr ); } @@ -168,13 +157,14 @@ SAL_THROW ( ( RuntimeException ) ) ::rtl::OUStringToOString( storageStr, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< XInterface > xInterface = + Reference< XInterface > xInterface( m_xMgr->createInstanceWithArgumentsAndContext( - OUString::createFromAscii( - "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), - aArgs, m_xContext ); - - validateXRef( xInterface, "ScriptStorageManager:: setupAnyStorage: Can't create ScriptStorage for share" ); + OUString::createFromAscii( "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), + aArgs, + m_xContext + ), + UNO_QUERY_THROW + ); // and place it in the hash_map. Increment the counter m_ScriptStorageMap[ m_count++ ] = xInterface; @@ -215,8 +205,7 @@ ScriptStorageManager::createScriptStorage( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorage\n" ); - validateXRef( xSFA, - "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); return setupAnyStorage( xSFA, ::rtl::OUString::createFromAscii( "" ), ::rtl::OUString::createFromAscii( "" ) ); @@ -229,7 +218,7 @@ ScriptStorageManager::createScriptStorageWithURI( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorageWithURI\n" ); - validateXRef( xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); // related to issue 11866 // warning dialog gets launched when adding binding to script in doc @@ -313,7 +302,7 @@ throw( RuntimeException ) OUSTR( "ScriptStorageManager::getScriptStorage: invalid storage ID" ), Reference< XInterface >() ); } - validateXRef( itr->second, + ENSURE_OR_THROW( itr->second.is(), "ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash" ); return itr->second; } diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk index aa3270e08a07..ad1419add42a 100644 --- a/sfx2/AllLangResTarget_sfx2.mk +++ b/sfx2/AllLangResTarget_sfx2.mk @@ -63,8 +63,11 @@ $(eval $(call gb_SrsTarget_add_files,sfx/res,\ sfx2/source/dialog/passwd.src \ sfx2/source/dialog/printopt.src \ sfx2/source/dialog/recfloat.src \ + sfx2/source/dialog/securitypage.src \ sfx2/source/dialog/srchdlg.src \ + sfx2/source/dialog/taskpane.src \ sfx2/source/dialog/templdlg.src \ + sfx2/source/dialog/titledockwin.src \ sfx2/source/dialog/versdlg.src \ sfx2/source/doc/doc.src \ sfx2/source/doc/doctdlg.src \ diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index ed941d5b9a9f..fb4d1a51857e 100755 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -137,7 +137,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/bindings \ sfx2/source/control/ctrlitem \ sfx2/source/control/dispatch \ - sfx2/source/control/macrconf \ sfx2/source/control/macro \ sfx2/source/control/minfitem \ sfx2/source/control/msg \ @@ -215,6 +214,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/doc/plugin \ sfx2/source/doc/printhelper \ sfx2/source/doc/querytemplate \ + sfx2/source/doc/docundomanager \ sfx2/source/doc/sfxbasemodel \ sfx2/source/doc/sfxmodelfactory \ sfx2/source/doc/syspath \ @@ -285,6 +285,25 @@ $(eval $(call gb_Library_add_cxxobjects,sfx,\ , $(gb_LinkTarget_EXCEPTIONFLAGS) -nologo -UPRECOMPILED_HEADERS \ )) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,sfx,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + gdi32 \ + kernel32 \ + msvcrt \ + ole32 \ + shell32 \ + user32 \ + uuid \ +)) +else $(eval $(call gb_Library_add_linked_libs,sfx,\ advapi32 \ gdi32 \ @@ -297,6 +316,7 @@ $(eval $(call gb_Library_add_linked_libs,sfx,\ uuid \ uwinapi \ )) +endif else $(eval $(call gb_Library_add_cxxobjects,sfx,\ sfx2/source/appl/shutdowniconw32 \ diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index 6ad8b0209c4e..85ce4143323c 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -81,7 +81,6 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/layout.hxx,sfx2/layout.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/linkmgr.hxx,sfx2/linkmgr.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/linksrc.hxx,sfx2/linksrc.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/lnkbase.hxx,sfx2/lnkbase.hxx)) -$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/macrconf.hxx,sfx2/macrconf.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mailmodelapi.hxx,sfx2/mailmodelapi.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mgetempl.hxx,sfx2/mgetempl.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mieclip.hxx,sfx2/mieclip.hxx)) diff --git a/sfx2/inc/frmload.hxx b/sfx2/inc/frmload.hxx index b03bdd724c20..74c5a1ff35d1 100644 --- a/sfx2/inc/frmload.hxx +++ b/sfx2/inc/frmload.hxx @@ -113,7 +113,7 @@ private: const ::rtl::OUString& i_rFactoryURL ) const; - SfxObjectShellLock impl_findObjectShell( + SfxObjectShellRef impl_findObjectShell( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel2 >& i_rxDocument ) const; diff --git a/sfx2/inc/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx index 1d4003fa44e6..45755cdd8799 100644 --- a/sfx2/inc/pch/precompiled_sfx2.hxx +++ b/sfx2/inc/pch/precompiled_sfx2.hxx @@ -654,7 +654,7 @@ #include "vcl/stdtext.hxx" #include "vcl/timer.hxx" #include "vcl/unohelp.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vos/diagnose.hxx" #include "vos/module.hxx" #include "vos/mutex.hxx" diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 980eec04cfa6..964b684fdb21 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -31,6 +31,7 @@ #include "sfx2/dllapi.h" #include "sal/types.h" #include <tools/solar.h> +#include <tools/errcode.hxx> #include <svl/smplhint.hxx> #include <svl/poolitem.hxx> #include <vcl/image.hxx> @@ -98,6 +99,8 @@ struct SfxStbCtrlFactory; struct SfxTbxCtrlFactory; class SimpleResMgr; class ModalDialog; +class SbxArray; +class SbxValue; namespace sfx2 { @@ -218,17 +221,18 @@ public: // members SfxFilterMatcher& GetFilterMatcher(); - SfxMacroConfig* GetMacroConfig() const; SfxProgress* GetProgress() const; const String& GetLastSaveDirectory() const; USHORT GetFreeIndex(); void ReleaseIndex(USHORT i); - SfxEventConfiguration* GetEventConfig() const; // Basic/Scripting static sal_Bool IsXScriptURL( const String& rScriptURL ); static ::rtl::OUString ChooseScript(); static void MacroOrganizer( INT16 nTabId ); + static ErrCode CallBasic( const String&, BasicManager*, SbxArray *pArgs, SbxValue *pRet ); + static ErrCode CallAppBasic( const String& i_macroName, SbxArray* i_args = NULL, SbxValue* i_ret = NULL ) + { return CallBasic( i_macroName, SfxApplication::GetOrCreate()->GetBasicManager(), i_args, i_ret ); } BasicManager* GetBasicManager(); com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > GetDialogContainer(); @@ -237,9 +241,6 @@ public: StarBASIC* GetBasic(); USHORT SaveBasicManager() const; USHORT SaveBasicAndDialogContainer() const; - void EnterBasicCall(); - FASTBOOL IsInBasicCall() const; - void LeaveBasicCall(); void RegisterBasicConstants( const char *pPrefix, const SfxConstant *pConsts, USHORT nCount ); @@ -293,8 +294,6 @@ public: SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); SAL_DLLPRIVATE void PropExec_Impl(SfxRequest &); SAL_DLLPRIVATE void PropState_Impl(SfxItemSet &); - SAL_DLLPRIVATE void MacroExec_Impl(SfxRequest &); - SAL_DLLPRIVATE void MacroState_Impl(SfxItemSet &); SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &); @@ -303,7 +302,6 @@ public: SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *); SAL_DLLPRIVATE const String& GetLastDir_Impl() const; SAL_DLLPRIVATE void SetLastDir_Impl( const String & ); - SAL_DLLPRIVATE void PlayMacro_Impl( SfxRequest &rReq, StarBASIC *pBas ); SAL_DLLPRIVATE void EnterAsynchronCall_Impl(); SAL_DLLPRIVATE FASTBOOL IsInAsynchronCall_Impl() const; diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx index 8d99d6efd9f4..4a1bacf089d1 100644 --- a/sfx2/inc/sfx2/dispatch.hxx +++ b/sfx2/inc/sfx2/dispatch.hxx @@ -211,9 +211,6 @@ public: Window *pWin, const Point *pPosPixel, const SfxPoolItem *pArg1, ... ); - void EnterAction( const String& rName ); - void LeaveAction(); - BOOL IsAppDispatcher() const; BOOL IsFlushed() const; void Flush(); diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 35656202650f..f2253a8f2b67 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -75,7 +75,6 @@ class SvStringsDtor; #define OWEAKOBJECT ::cppu::OWeakObject #define REFERENCE ::com::sun::star::uno::Reference #define XINTERFACE ::com::sun::star::uno::XInterface -#define SEQUENCE ::com::sun::star::uno::Sequence #define EXCEPTION ::com::sun::star::uno::Exception #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException #define ANY ::com::sun::star::uno::Any diff --git a/sfx2/inc/sfx2/event.hxx b/sfx2/inc/sfx2/event.hxx index b9beb12bfeff..9b144b3c20b6 100644 --- a/sfx2/inc/sfx2/event.hxx +++ b/sfx2/inc/sfx2/event.hxx @@ -119,7 +119,6 @@ public: SfxObjectShell* GetObjShell() const { return _pObjShell; } }; -class PrintDialog; class Printer; class SfxPrintingHint : public SfxHint { diff --git a/sfx2/inc/sfx2/evntconf.hxx b/sfx2/inc/sfx2/evntconf.hxx index 17080ec2d51e..5b41d3a32935 100644 --- a/sfx2/inc/sfx2/evntconf.hxx +++ b/sfx2/inc/sfx2/evntconf.hxx @@ -45,10 +45,6 @@ #define ITEMID_MACRO SID_ATTR_MACROITEM #include <svl/macitem.hxx> -class SfxMacroInfo; -class SfxMacroInfoArr_Impl; -class SfxEventConfigItem_Impl; -class SfxEventInfoArr_Impl; class SfxObjectShell; class SvxMacroTableDtor; diff --git a/sfx2/inc/sfx2/macrconf.hxx b/sfx2/inc/sfx2/macrconf.hxx deleted file mode 100644 index 6b50ddf3497a..000000000000 --- a/sfx2/inc/sfx2/macrconf.hxx +++ /dev/null @@ -1,155 +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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SFX_MACROCONF_HXX -#define _SFX_MACROCONF_HXX - -#include "sal/config.h" -#include "sfx2/dllapi.h" -#include "sal/types.h" -#include <tools/errcode.hxx> -#define _SVSTDARR_USHORTS -#include <svl/svstdarr.hxx> // SvUShorts -#include <sfx2/evntconf.hxx> - -class SfxMacroInfo; -class SfxSlot; -class SfxMacroInfoItem; -class SfxObjectShell; -class BasicManager; -struct SfxMacroConfig_Impl; -class SbMethod; -class SbxValue; -class SbxObject; -class SbxArray; -class SvStream; -class SvxMacro; - -typedef SfxMacroInfo* SfxMacroInfoPtr; -//#if 0 // _SOLAR__PRIVATE -SV_DECL_PTRARR(SfxMacroInfoArr_Impl, SfxMacroInfoPtr, 5, 5) -//#else -//class SfxMacroInfoArr_Impl; -//#endif - -class SFX2_DLLPUBLIC SfxMacroInfo -{ -friend class SfxMacroConfig; -friend class SfxEventConfiguration; -friend SvStream& operator >> (SvStream& rStream, SfxMacroInfo& rInfo); -friend SvStream& operator << (SvStream& rStream, const SfxMacroInfo& rInfo); - - String* pHelpText; - sal_uInt16 nRefCnt; - sal_Bool bAppBasic; - String aLibName; - String aModuleName; - String aMethodName; - sal_uInt16 nSlotId; - SfxSlot* pSlot; - -public: - SfxMacroInfo( const String& rURL ); - SfxMacroInfo( bool _bAppBasic = true ); - SfxMacroInfo( bool _bAppBasic, const String& rQualifiedName ); - SfxMacroInfo(SfxMacroInfo& rOther); - SfxMacroInfo(bool _bAppBasic, const String& rLibName, - const String& rModuleName, const String& rMethodName); - ~SfxMacroInfo(); - sal_Bool operator==(const SfxMacroInfo& rOther) const; - int Load (SvStream&); - int Store (SvStream&); - String GetMacroName() const; - String GetQualifiedName() const; - String GetFullQualifiedName() const; - BasicManager* GetBasicManager() const; - String GetBasicName() const; - String GetHelpText() const; - sal_Bool IsAppMacro() const - { return bAppBasic; } - const String& GetModuleName() const - { return aModuleName; } - const String& GetLibName() const - { return aLibName; } - const String& GetMethodName() const - { return aMethodName; } - sal_uInt16 GetSlotId() const - { return nSlotId; } - SfxSlot* GetSlot() const - { return pSlot; } - - sal_Bool Compare( const SvxMacro& ) const; - void SetHelpText( const String& rText ); - String GetURL() const; -}; - -//ASDBG obsolete >= 582 -//ASDBG class ::com::sun::star::uno::Reference< ::com::sun::star::script::XEngine > ; -//ASDBG class ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ; - -class SFX2_DLLPUBLIC SfxMacroConfig -{ -friend class SfxEventConfiguration; - - SAL_DLLPRIVATE static SfxMacroConfig* pMacroConfig; - - SfxMacroConfig_Impl* pImp; - SvUShorts aIdArray; - -public: - SfxMacroConfig(); - ~SfxMacroConfig(); - - static SfxMacroConfig* GetOrCreate(); - - static String RequestHelp( sal_uInt16 nId ); - static sal_Bool IsMacroSlot( sal_uInt16 nId ); - static sal_Bool IsBasic( SbxObject*, const String&, BasicManager* ); - static ErrCode Call( SbxObject*, const String&, BasicManager*, - SbxArray *pArgs=NULL, SbxValue *pRet=NULL ); -//ASDBG obsolete >= 582 -//ASDBG static void CallStarScript( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XEngine > & rxEngine, const String & rCode, -//ASDBG const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rSource, void *pArgs, void *pRet ); - static SbMethod* GetMethod_Impl( const String&, BasicManager* ); - - sal_uInt16 GetSlotId(SfxMacroInfoPtr); - void ReleaseSlotId(sal_uInt16 nId); - void RegisterSlotId(sal_uInt16 nId); - SfxMacroInfo* GetMacroInfo(sal_uInt16 nId) const; - sal_Bool ExecuteMacro(sal_uInt16 nId, const String& rArgs ) const; - sal_Bool ExecuteMacro( SfxObjectShell*, const SvxMacro*, const String& ) const; - sal_Bool CheckMacro(sal_uInt16 nId) const; - sal_Bool CheckMacro( SfxObjectShell*, const SvxMacro* ) const; - -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE static void Release_Impl(); - SAL_DLLPRIVATE const SfxMacroInfo* GetMacroInfo_Impl( const SvxMacro *pMacro ) const; - DECL_DLLPRIVATE_LINK( CallbackHdl_Impl, SfxMacroConfig*); - DECL_DLLPRIVATE_LINK( EventHdl_Impl, SfxMacroInfo*); -//#endif -}; - -#endif diff --git a/sfx2/inc/sfx2/mnumgr.hxx b/sfx2/inc/sfx2/mnumgr.hxx index f1df0f0aa547..f5cc509dbf0a 100644 --- a/sfx2/inc/sfx2/mnumgr.hxx +++ b/sfx2/inc/sfx2/mnumgr.hxx @@ -32,7 +32,7 @@ #ifndef _MENU_HXX //autogen //wg. MENU_APPEND !!!! #include <vcl/menu.hxx> #endif -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <tools/link.hxx> #include <com/sun/star/embed/VerbDescriptor.hpp> #include <com/sun/star/uno/Sequence.hxx> diff --git a/sfx2/inc/sfx2/module.hxx b/sfx2/inc/sfx2/module.hxx index ad83bb4a7418..3cf84cf6139e 100644 --- a/sfx2/inc/sfx2/module.hxx +++ b/sfx2/inc/sfx2/module.hxx @@ -33,7 +33,7 @@ #include <sfx2/shell.hxx> #include <sfx2/imgdef.hxx> #include <sal/types.h> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> class ImageList; diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 9473ac126bd7..e8afa44ae91f 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -73,7 +73,6 @@ class BasicManager; class SfxMedium; class SfxObjectFactory; class SfxDocumentInfoDialog; -class SfxEventConfigItem_Impl; class SfxStyleSheetBasePool; class INote; class SfxStyleSheetPool; @@ -158,11 +157,6 @@ typedef sal_uInt32 SfxObjectShellFlags; //-------------------------------------------------------------------- -#define SEQUENCE ::com::sun::star::uno::Sequence -#define OUSTRING ::rtl::OUString - -//-------------------------------------------------------------------- - #define HIDDENINFORMATION_RECORDEDCHANGES 0x0001 #define HIDDENINFORMATION_NOTES 0x0002 #define HIDDENINFORMATION_DOCUMENTVERSIONS 0x0004 @@ -195,12 +189,6 @@ in fremde Objekte integriert werden k"onnen. ----------------------------------------------------------------------*/ -enum SfxTitleQuery -{ - SFX_TITLE_QUERY_SAVE_NAME_PROPOSAL -}; - - class SfxToolBoxConfig; struct TransferableObjectDescriptor; @@ -209,6 +197,7 @@ class SFX2_DLLPUBLIC SfxObjectShell : public ::comphelper::IEmbeddedHelper, public ::sfx2::IXmlIdRegistrySupplier { friend struct ModifyBlocker_Impl; +friend class SfxObjectShellLock; private: struct SfxObjectShell_Impl* pImp; // interne Daten @@ -367,36 +356,11 @@ public: sal_uInt16 GetScriptingSignatureState(); void SignScriptingContent(); - virtual String QueryTitle( SfxTitleQuery ) const; virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( Window *pParent, const SfxItemSet& ); - sal_Bool IsBasic( const String & rCode, SbxObject * pVCtrl = NULL ); ErrCode CallBasic( const String& rMacro, const String& rBasicName, - SbxObject* pVCtrl, SbxArray* pArgs = 0, SbxValue* pRet = 0 ); - ErrCode Call( const String & rCode, sal_Bool bIsBasicReturn, SbxObject * pVCtrl = NULL ); - - ErrCode CallScript( - const String & rScriptType, const String & rCode, const void* pArgs = NULL, void* pRet = NULL ); - - /** calls a StarBasic script without magic - @param _rMacroName - specifies the name of the method to execute - @param _rLocation - specifies the location of the script to execute. Allowed values are "application" and "document". - @param _pArguments - This is a pointer to a Sequence< Any >. All elements of the Sequence are wrapped into Basic objects - and passed as arguments to the method specified by <arg>_rMacroName</arg> - @param _pReturn - If not <NULL/>, the Any pointed to by this argument contains the return value of the (synchronous) call - to the StarBasic macro - */ - ErrCode CallStarBasicScript( - const String& _rMacroName, - const String& _rLocation, - const void* _pArguments = NULL, - void* _pReturn = NULL - ); + SbxArray* pArgs = 0, SbxValue* pRet = 0 ); ErrCode CallXScript( const String& rScriptURL, @@ -617,7 +581,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetBaseModel() const; // Nur uebergangsweise fuer die Applikationen !!! - virtual SEQUENCE< OUSTRING > GetEventNames(); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > GetEventNames(); Window* GetDialogParent( SfxMedium* pMedium=0 ); String UpdateTitle( SfxMedium* pMed=NULL, USHORT nDocViewNo=0 ); @@ -791,7 +755,6 @@ public: SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl(); // configuration items - SAL_DLLPRIVATE SfxEventConfigItem_Impl* GetEventConfig_Impl( sal_Bool bForce=sal_False ); SAL_DLLPRIVATE SfxToolBoxConfig* GetToolBoxConfig_Impl(); SAL_DLLPRIVATE sal_uInt16 ImplGetSignatureState( sal_Bool bScriptingContent = FALSE ); @@ -831,7 +794,6 @@ public: //#endif //-------------------------------------------------------------------- - #ifndef SFX_DECL_OBJECTSHELL_DEFINED #define SFX_DECL_OBJECTSHELL_DEFINED SV_DECL_REF(SfxObjectShell) @@ -840,8 +802,6 @@ SV_DECL_LOCK(SfxObjectShell) SV_IMPL_LOCK(SfxObjectShell) SV_IMPL_REF(SfxObjectShell) -SfxObjectShellRef MakeObjectShellForOrganizer_Impl( const String& rName, BOOL bWriting ); - //#if 0 // _SOLAR__PRIVATE //-------------------------------------------------------------------- class AutoReloadTimer_Impl : public Timer diff --git a/sfx2/inc/sfx2/printer.hxx b/sfx2/inc/sfx2/printer.hxx index a96033835a84..11f07ea9e7db 100644 --- a/sfx2/inc/sfx2/printer.hxx +++ b/sfx2/inc/sfx2/printer.hxx @@ -34,60 +34,11 @@ #include <vcl/print.hxx> #endif -class SfxFont; class SfxTabPage; class SfxItemSet; struct SfxPrinter_Impl; -#define SFX_RANGE_NOTSET ((USHORT)0xFFFF) - -// class SfxFontSizeInfo ------------------------------------------------- - -class SfxFontSizeInfo -{ -private: - static USHORT pStaticSizes[]; - Size* pSizes; - USHORT nSizes; - BOOL bScalable; - -public: - SfxFontSizeInfo( const SfxFont& rFont, const OutputDevice& rDevice ); - ~SfxFontSizeInfo(); - - BOOL HasSize(const Size &rSize) const; - BOOL IsScalable() const { return bScalable; } - - USHORT SizeCount() const { return nSizes; } - const Size& GetSize( USHORT nNo ) const - { return pSizes[nNo]; } -}; - -// class SfxFont --------------------------------------------------------- - -class SFX2_DLLPUBLIC SfxFont -{ -private: - String aName; - FontFamily eFamily; - FontPitch ePitch; - CharSet eCharSet; - - SfxFont& operator=(const SfxFont& rFont); // not implemented - -public: - SfxFont( const FontFamily eFam, - const String& aName, - const FontPitch eFontPitch = PITCH_DONTKNOW, - const CharSet eFontCharSet = RTL_TEXTENCODING_DONTKNOW ); - // ZugriffsMethoden: - inline const String& GetName() const { return aName; } - inline FontFamily GetFamily() const { return eFamily; } - inline FontPitch GetPitch() const { return ePitch; } - inline CharSet GetCharSet() const { return eCharSet; } -}; - // class SfxPrinter ------------------------------------------------------ class SFX2_DLLPUBLIC SfxPrinter : public Printer @@ -125,19 +76,8 @@ public: const SfxItemSet& GetOptions() const { return *pOptions; } void SetOptions( const SfxItemSet &rNewOptions ); - void EnableRange( USHORT nRange ); - void DisableRange( USHORT nRange ); - BOOL IsRangeEnabled( USHORT nRange ) const; - BOOL IsKnown() const { return bKnown; } BOOL IsOriginal() const { return bKnown; } - - using OutputDevice::GetFont; - USHORT GetFontCount(); - const SfxFont* GetFont( USHORT nNo ) const; - const SfxFont* GetFontByName( const String &rFontName ); - - BOOL InitJob( Window* pUIParent, BOOL bAskAboutTransparentObjects ); }; #endif diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 44c00cc93018..dfc2dec2f5ff 100644..100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -222,7 +222,6 @@ #define RID_BUILDVERSION (RID_SFX_START+5) #define RID_DOCALREADYLOADED_DLG (RID_SFX_START+1) -#define RID_CANTLOADDOC_DLG (RID_SFX_START+2) #define TP_DOCINFODESC (RID_SFX_START+3) #define TP_DOCINFODOC (RID_SFX_START+4) @@ -313,16 +312,8 @@ // ------------------------------------------------------------------------ -#define BMP_COLS 21 -#define BMP_SFX_SMALL 1 -#define BMP_SFX_LARGE 2 - #define RID_SFX_GLOBALS 1000 -#define BMP_SFX_COLOR (RID_SFX_GLOBALS + 1) -#define BMP_SFX_MONO (RID_SFX_GLOBALS + 2) -#define SFX_MSG_RES (RID_SFX_GLOBALS + 3) - // ========================================================================= #define RID_OPTIONS_START (SID_LIB_START + 2000) @@ -330,24 +321,6 @@ // ResId's ------------------------------------------------------------------ -#define RID_SFXLANG_BEGIN (RID_OPTIONS_START + 0) -#define RID_SFXLANG_NO (RID_SFXLANG_BEGIN + 0) -#define RID_SFXLANG_GERMAN (RID_SFXLANG_BEGIN + 1) -#define RID_SFXLANG_SWISS_GERMAN (RID_SFXLANG_BEGIN + 2) -#define RID_SFXLANG_US_ENGLISH (RID_SFXLANG_BEGIN + 3) -#define RID_SFXLANG_UK_ENGLISH (RID_SFXLANG_BEGIN + 4) -#define RID_SFXLANG_FRENCH (RID_SFXLANG_BEGIN + 5) -#define RID_SFXLANG_ITALIAN (RID_SFXLANG_BEGIN + 6) -#define RID_SFXLANG_CAST_SPANISH (RID_SFXLANG_BEGIN + 7) -#define RID_SFXLANG_PORTUGUESE (RID_SFXLANG_BEGIN + 8) -#define RID_SFXLANG_DANISH (RID_SFXLANG_BEGIN + 9) -#define RID_SFXLANG_DUTCH (RID_SFXLANG_BEGIN + 10) -#define RID_SFXLANG_SWEDISH (RID_SFXLANG_BEGIN + 11) -#define RID_SFXLANG_FINNISH (RID_SFXLANG_BEGIN + 12) -#define RID_SFXLANG_NORWEG_BOKMAL (RID_SFXLANG_BEGIN + 13) -#define RID_SFXLANG_NORWEG_NYNORSK (RID_SFXLANG_BEGIN + 14) -#define RID_SFXLANG_ALL (RID_SFXLANG_BEGIN + 15) - #define RID_SFXPAGE_SAVE (RID_OPTIONS_START + 0) #define RID_SFXPAGE_GENERAL (RID_OPTIONS_START + 1) #define RID_SFXPAGE_SPELL (RID_OPTIONS_START + 2) @@ -356,10 +329,7 @@ #define RID_SFXQB_DELDICT (RID_OPTIONS_START + 5) #define RID_SFXPAGE_PATH (RID_OPTIONS_START + 6) #define RID_SFXPAGE_LINGU (RID_OPTIONS_START + 7) -#define RID_SFXPAGE_INET (RID_OPTIONS_START + 8) -#define RID_SFXQB_DEL_IGNORELIST (RID_OPTIONS_START + 9) #define RID_SFXQB_SET_LANGUAGE (RID_OPTIONS_START + 10) -#define RID_ITEMLIST_LINGU (RID_OPTIONS_START + 11) #define RID_SFXPAGE_PRINTOPTIONS (RID_OPTIONS_START + 12) #define RID_STR_NEW_TASK (RID_SFX_DOC_START+ 76) diff --git a/sfx2/inc/sfx2/sfxbasecontroller.hxx b/sfx2/inc/sfx2/sfxbasecontroller.hxx index ca30d243bbac..de01f1965d74 100644 --- a/sfx2/inc/sfx2/sfxbasecontroller.hxx +++ b/sfx2/inc/sfx2/sfxbasecontroller.hxx @@ -66,7 +66,6 @@ // Some defines to write better code :-) #define REFERENCE ::com::sun::star::uno::Reference #define ANY ::com::sun::star::uno::Any -#define SEQUENCE ::com::sun::star::uno::Sequence #define XDISPATCH ::com::sun::star::frame::XDispatch #define DISPATCHDESCRIPTOR ::com::sun::star::frame::DispatchDescriptor #define XMODEL ::com::sun::star::frame::XModel @@ -304,7 +303,7 @@ public: @onerror - */ - virtual SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescriptor ) throw( RUNTIMEEXCEPTION ) ; + virtual ::com::sun::star::uno::Sequence< REFERENCE< XDISPATCH > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< DISPATCHDESCRIPTOR >& seqDescriptor ) throw( RUNTIMEEXCEPTION ) ; //____________________________________________________________________________________________________ // XControllerBorder diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 26122419e661..017486d251de 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -44,6 +44,7 @@ #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentRecovery.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> @@ -97,9 +98,9 @@ #include <com/sun/star/task/XInteractionHandler.hpp> //________________________________________________________________________________________________________ -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 31 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_32) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_32 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 32 #include <comphelper/implbase_var.hxx> #endif @@ -161,7 +162,6 @@ #define EVENTOBJECT ::com::sun::star::lang::EventObject #define PROPERTYVALUE ::com::sun::star::beans::PropertyValue #define REFERENCE ::com::sun::star::uno::Reference -#define SEQUENCE ::com::sun::star::uno::Sequence #define MUTEX ::osl::Mutex #define OUSTRING ::rtl::OUString #define UNOTYPE ::com::sun::star::uno::Type @@ -239,11 +239,12 @@ namespace sfx { namespace intern { SfxListener */ -typedef ::comphelper::WeakImplHelper31 < XCHILD +typedef ::comphelper::WeakImplHelper32 < XCHILD , XDOCUMENTINFOSUPPLIER , ::com::sun::star::document::XDocumentPropertiesSupplier , ::com::sun::star::rdf::XDocumentMetadataAccess , ::com::sun::star::document::XDocumentRecovery + , ::com::sun::star::document::XUndoManagerSupplier , XEVENTBROADCASTER , XDOCUMENTEVENTBROADCASTER , XEVENTLISTENER @@ -385,7 +386,7 @@ public: @onerror A RuntimeException is thrown. */ - virtual SEQUENCE< UNOTYPE > SAL_CALL getTypes() throw( RUNTIMEEXCEPTION ) ; + virtual ::com::sun::star::uno::Sequence< UNOTYPE > SAL_CALL getTypes() throw( RUNTIMEEXCEPTION ) ; /**___________________________________________________________________________________________________ @short get implementation id @@ -401,7 +402,7 @@ public: @onerror A RuntimeException is thrown. */ - virtual SEQUENCE< sal_Int8 > SAL_CALL getImplementationId() throw( RUNTIMEEXCEPTION ) ; + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( RUNTIMEEXCEPTION ) ; //____________________________________________________________________________________________________ @@ -580,7 +581,7 @@ public: */ virtual sal_Bool SAL_CALL attachResource( const OUSTRING& sURL , - const SEQUENCE< PROPERTYVALUE >& aArgs ) + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& aArgs ) throw (::com::sun::star::uno::RuntimeException); /**___________________________________________________________________________________________________ @@ -611,7 +612,7 @@ public: @onerror - */ - virtual SEQUENCE< PROPERTYVALUE > SAL_CALL getArgs() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< PROPERTYVALUE > SAL_CALL getArgs() throw (::com::sun::star::uno::RuntimeException); /**___________________________________________________________________________________________________ @short - @@ -861,7 +862,7 @@ public: @onerror - */ - virtual SEQUENCE< PROPERTYVALUE > SAL_CALL getPrinter() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< PROPERTYVALUE > SAL_CALL getPrinter() throw (::com::sun::star::uno::RuntimeException); /**___________________________________________________________________________________________________ @short - @@ -876,7 +877,7 @@ public: @onerror - */ - virtual void SAL_CALL setPrinter( const SEQUENCE< PROPERTYVALUE >& seqPrinter ) + virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqPrinter ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); /**___________________________________________________________________________________________________ @short - @@ -891,14 +892,14 @@ public: @onerror - */ - virtual void SAL_CALL print( const SEQUENCE< PROPERTYVALUE >& seqOptions ) + virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); //____________________________________________________________________________________________________ // XStorable2 //____________________________________________________________________________________________________ - virtual void SAL_CALL storeSelf( const SEQUENCE< PROPERTYVALUE >& seqArguments ) + virtual void SAL_CALL storeSelf( const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqArguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); //____________________________________________________________________________________________________ @@ -979,7 +980,7 @@ public: */ virtual void SAL_CALL storeAsURL( const OUSTRING& sURL , - const SEQUENCE< PROPERTYVALUE >& seqArguments ) + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ; /**___________________________________________________________________________________________________ @@ -996,7 +997,7 @@ public: */ virtual void SAL_CALL storeToURL( const OUSTRING& sURL , - const SEQUENCE< PROPERTYVALUE >& seqArguments ) + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); @@ -1037,7 +1038,7 @@ public: @onerror - */ - virtual void SAL_CALL load( const SEQUENCE< PROPERTYVALUE >& seqArguments ) + virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, @@ -1058,7 +1059,7 @@ public: //____________________________________________________________________________________________________ virtual void SAL_CALL loadFromStorage( const REFERENCE< XSTORAGE >& xStorage, - const SEQUENCE< PROPERTYVALUE >& aMediaDescriptor ) + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& aMediaDescriptor ) throw ( ILLEGALARGUMENTEXCEPTION, DOUBLEINITIALIZATIONEXCEPTION, IOEXCEPTION, @@ -1066,7 +1067,7 @@ public: RUNTIMEEXCEPTION ); virtual void SAL_CALL storeToStorage( const REFERENCE< XSTORAGE >& xStorage, - const SEQUENCE< PROPERTYVALUE >& aMediaDescriptor ) + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& aMediaDescriptor ) throw ( ILLEGALARGUMENTEXCEPTION, IOEXCEPTION, EXCEPTION, @@ -1164,7 +1165,7 @@ public: */ - virtual SEQUENCE< DATAFLAVOR > SAL_CALL getTransferDataFlavors() + virtual ::com::sun::star::uno::Sequence< DATAFLAVOR > SAL_CALL getTransferDataFlavors() throw (::com::sun::star::uno::RuntimeException); /**___________________________________________________________________________________________________ @@ -1321,6 +1322,9 @@ public: ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException ); + // css.document.XUndoManagerSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL getUndoManager( ) throw (::com::sun::star::uno::RuntimeException); + //____________________________________________________________________________________________________ // ::com::sun::star::rdf::XNode: @@ -1485,22 +1489,11 @@ public: SfxObjectShell* GetObjectShell() const ; SAL_DLLPRIVATE SfxObjectShell* impl_getObjectShell() const ; - /**___________________________________________________________________________________________________ - @short - - @descr - - - @seealso - - - @param - - - @return - - - @onerror - - */ - SAL_DLLPRIVATE sal_Bool impl_isDisposed() const ; sal_Bool IsInitialized() const; + sal_Bool IsDisposed() const { return impl_isDisposed(); } void MethodEntryCheck( const bool i_mustBeInitialized ) const; + ::osl::Mutex& getMutex() const { return m_aMutex; } ::com::sun::star::uno::Reference < ::com::sun::star::container::XIndexAccess > SAL_CALL getViewData() throw (::com::sun::star::uno::RuntimeException); void SAL_CALL setViewData( const ::com::sun::star::uno::Reference < ::com::sun::star::container::XIndexAccess >& aData ) throw (::com::sun::star::uno::RuntimeException); @@ -1544,7 +1537,7 @@ private: SAL_DLLPRIVATE ::rtl::OUString GetMediumFilterName_Impl(); SAL_DLLPRIVATE void impl_store( const OUSTRING& sURL , - const SEQUENCE< PROPERTYVALUE >& seqArguments , + const ::com::sun::star::uno::Sequence< PROPERTYVALUE >& seqArguments , sal_Bool bSaveTo ) ; SAL_DLLPRIVATE void postEvent_Impl( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& xController = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >() ); @@ -1576,6 +1569,44 @@ private: } ; // class SfxBaseModel +/** base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the SfxBaseModel +*/ +class SFX2_DLLPUBLIC SfxModelSubComponent +{ +public: + /** checks whether the instance is alive, i.e. properly initialized, and not yet disposed + */ + void MethodEntryCheck() + { + m_rModel.MethodEntryCheck( true ); + } + + // called when the SfxBaseModel which the component is superordinate of is being disposed + virtual void disposing(); + +protected: + SfxModelSubComponent( SfxBaseModel& i_model ) + :m_rModel( i_model ) + { + } + virtual ~SfxModelSubComponent(); + + // helpers for implementing XInterface - delegates ref counting to the SfxBaseModel + void acquire() { m_rModel.acquire(); } + void release() { m_rModel.release(); } + + bool isDisposed() const { return m_rModel.IsDisposed(); } + +protected: + const SfxBaseModel& getBaseModel() const { return m_rModel; } + SfxBaseModel& getBaseModel() { return m_rModel; } + + ::osl::Mutex& getMutex() { return m_rModel.getMutex(); } + +private: + SfxBaseModel& m_rModel; +}; + class SFX2_DLLPUBLIC SfxModelGuard { public: @@ -1592,17 +1623,27 @@ public: { i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING ); } + SfxModelGuard( SfxModelSubComponent& i_rSubComponent ) + :m_aGuard( Application::GetSolarMutex() ) + { + i_rSubComponent.MethodEntryCheck(); + } ~SfxModelGuard() { } + void reset() + { + m_aGuard.reset(); + } + void clear() { m_aGuard.clear(); } private: - ::vos::OClearableGuard m_aGuard; + ::osl::ResettableGuard< ::vos::IMutex > m_aGuard; }; #undef css diff --git a/sfx2/inc/sfx2/sfxcommands.h b/sfx2/inc/sfx2/sfxcommands.h index bdf27baac7b3..035f2f187bb8 100644..100755 --- a/sfx2/inc/sfx2/sfxcommands.h +++ b/sfx2/inc/sfx2/sfxcommands.h @@ -1,345 +1,342 @@ -/*************************************************************************
- *
- * 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
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef SFX2_SFXCOMMANDS_HRC
-#define SFX2_SFXCOMMANDS_HRC
-
-#define CMD_SID_VIEWSHELL0 ".uno:_SwitchViewShell0"
-#define CMD_SID_VIEWSHELL1 ".uno:_SwitchViewShell1"
-#define CMD_SID_VIEWSHELL2 ".uno:_SwitchViewShell2"
-#define CMD_SID_VIEWSHELL3 ".uno:_SwitchViewShell3"
-#define CMD_SID_VIEWSHELL4 ".uno:_SwitchViewShell4"
-#define CMD_SID_ABOUT ".uno:About"
-#define CMD_SID_ACTIVATE ".uno:Activate"
-#define CMD_SID_HELPBALLOONS ".uno:ActiveHelp"
-#define CMD_SID_STYLE_FAMILY ".uno:ActualStyleFamily"
-#define CMD_SID_NEWDOC ".uno:NewDoc"
-#define CMD_SID_CREATELINK ".uno:AddBookmark"
-#define CMD_SID_NEWDOCDIRECT ".uno:AddDirect"
-#define CMD_SID_TEMPLATE_ADDRESSBOKSOURCE ".uno:AddressBookSource"
-#define CMD_SID_BASICIDE_ADDWATCH ".uno:AddWatch"
-#define CMD_SID_DOCINFO_AUTHOR ".uno:Author"
-#define CMD_SID_AUTOHIDE ".uno:AutoHide"
-#define CMD_SID_AUTOPILOTMENU ".uno:AutoPilotMenu"
-#define CMD_SID_GALLERY_BG_BRUSH ".uno:BackgroundImage"
-#define CMD_SID_BACKSPACE ".uno:Backspace"
-#define CMD_SID_BASICBREAK ".uno:BasicBreak"
-#define CMD_SID_BASICIDE_APPEAR ".uno:BasicIDEAppear"
-#define CMD_SID_BASICSTEPINTO ".uno:BasicStepInto"
-#define CMD_SID_BASICSTEPOUT ".uno:BasicStepOut"
-#define CMD_SID_BASICSTEPOVER ".uno:BasicStepOver"
-#define CMD_SID_BASICSTOP ".uno:BasicStop"
-#define CMD_SID_BROWSER ".uno:Beamer"
-#define CMD_SID_BASICIDE_BRKPNTSCHANGED ".uno:BreakPointsChanged"
-#define CMD_SID_BROWSE_BACKWARD ".uno:BrowseBackward"
-#define CMD_SID_BROWSE_FORWARD ".uno:BrowseForward"
-#define CMD_SID_BROWSER_MODE ".uno:BrowseView"
-#define CMD_SID_BUILD_VERSION ".uno:BuildVersion"
-#define CMD_SID_CAPTION ".uno:Caption"
-#define CMD_SID_STYLE_FAMILY1 ".uno:CharStyle"
-#define CMD_SID_CHECK_KEY ".uno:CheckKey"
-#define CMD_SID_BASICIDE_CHOOSEMACRO ".uno:ChooseMacro"
-#define CMD_SID_CLEARHISTORY ".uno:ClearHistory"
-#define CMD_SID_CLOSEWINS ".uno:CloseWins"
-#define CMD_SID_CLOSEDOCS ".uno:CloseDocs"
-#define CMD_SID_CLOSEDOC ".uno:CloseDoc"
-#define CMD_SID_CLOSEWIN ".uno:CloseWin"
-#define CMD_SID_CLOSING ".uno:Closing"
-#define CMD_SID_DOCINFO_COMMENTS ".uno:Comments"
-#define CMD_SID_OFFICE_COMMERCIAL_USE ".uno:CommercialUse"
-#define CMD_SID_DOCUMENT_COMPARE ".uno:CompareDocuments"
-#define CMD_SID_BASICCOMPILE ".uno:CompileBasic"
-#define CMD_SID_CONFIG ".uno:ConfigureDialog"
-#define CMD_SID_CONTEXT ".uno:Context"
-#define CMD_SID_COPY ".uno:Copy"
-#define CMD_SID_CRASH ".uno:Crash"
-#define CMD_SID_BASICIDE_CREATEMACRO ".uno:CreateMacro"
-#define CMD_SID_CURRENT_URL ".uno:CurrentURL"
-#define CMD_SID_CURSORENDOFSCREEN ".uno:CursorEndOfScreen"
-#define CMD_SID_CURSORTOPOFSCREEN ".uno:CursorTopOfScreen"
-#define CMD_SID_OFFICE_CUSTOMERNUMBER ".uno:CustomerNumber"
-#define CMD_SID_CUT ".uno:Cut"
-#define CMD_SID_DEFAULTFILEPATH ".uno:DefaultFilePath"
-#define CMD_SID_DEFAULTFILENAME ".uno:DefaultFileName"
-#define CMD_SID_DELETE ".uno:Delete"
-#define CMD_SID_BASICIDE_DELETECURRENT ".uno:DeleteCurrent"
-#define CMD_SID_STYLE_DELETE ".uno:DeleteStyle"
-#define CMD_SID_STYLE_DESIGNER ".uno:DesignerDialog"
-#define CMD_SID_STYLE_DRAGHIERARCHIE ".uno:DragHierarchy"
-#define CMD_SID_EDITDOC ".uno:EditDoc"
-#define CMD_SID_BASICIDE_EDITMACRO ".uno:EditMacro"
-#define CMD_SID_STYLE_EDIT ".uno:EditStyle"
-#define CMD_FID_SEARCH_NOW ".uno:ExecuteSearch"
-#define CMD_SID_EXTENDEDHELP ".uno:ExtendedHelp"
-#define CMD_SID_FILE_NAME ".uno:FileName"
-#define CMD_SID_FOCUSURLBOX ".uno:FocusUrlBox"
-#define CMD_SID_FORMATMENU ".uno:FormatMenu"
-#define CMD_SID_STYLE_FAMILY3 ".uno:FrameStyle"
-#define CMD_SID_FRAMETITLE ".uno:FrameTitle"
-#define CMD_SID_PROGFILENAME ".uno:FullName"
-#define CMD_SID_DOCFULLNAME ".uno:FullName"
-#define CMD_SID_WIN_FULLSCREEN ".uno:FullScreen"
-#define CMD_SID_FILLFRAME ".uno:GetFrameWindow"
-#define CMD_SID_CURSORDOWN ".uno:GoDown"
-#define CMD_SID_CURSORPAGEDOWN ".uno:GoDownBlock"
-#define CMD_SID_CURSORPAGEDOWN_SEL ".uno:GoDownBlockSel"
-#define CMD_SID_CURSORDOWN_SEL ".uno:GoDownSel"
-#define CMD_SID_CURSORLEFT ".uno:GoLeft"
-#define CMD_SID_CURSORPAGELEFT ".uno:GoLeftBlock"
-#define CMD_SID_CURSORPAGELEFT_SEL ".uno:GoLeftBlockSel"
-#define CMD_SID_CURSORLEFT_SEL ".uno:GoLeftSel"
-#define CMD_SID_CURSORRIGHT ".uno:GoRight"
-#define CMD_SID_CURSORRIGHT_SEL ".uno:GoRightSel"
-#define CMD_SID_CURSORENDOFFILE ".uno:GoToEndOfData"
-#define CMD_SID_CURSORENDOFFILE_SEL ".uno:GoToEndOfDataSel"
-#define CMD_SID_CURSOREND ".uno:GoToEndOfRow"
-#define CMD_SID_CURSOREND_SEL ".uno:GoToEndOfRowSel"
-#define CMD_SID_CURSORTOPOFFILE ".uno:GoToStart"
-#define CMD_SID_CURSORHOME ".uno:GoToStartOfRow"
-#define CMD_SID_CURSORHOME_SEL ".uno:GoToStartOfRowSel"
-#define CMD_SID_CURSORTOPOFFILE_SEL ".uno:GoToStartSel"
-#define CMD_SID_CURSORUP ".uno:GoUp"
-#define CMD_SID_CURSORPAGEUP ".uno:GoUpBlock"
-#define CMD_SID_CURSORPAGEUP_SEL ".uno:GoUpBlockSel"
-#define CMD_SID_CURSORUP_SEL ".uno:GoUpSel"
-#define CMD_SID_HELP_ANNOTATE ".uno:HelpAnnotate"
-#define CMD_SID_HELP_BOOKMARK ".uno:HelpBookmark"
-#define CMD_SID_HELP_HELPFILEBOX ".uno:HelpChooseFile"
-#define CMD_SID_HELP_DOWNLOAD ".uno:HelpDownload"
-#define CMD_SID_HELP_PI ".uno:HelperDialog"
-#define CMD_SID_HELPINDEX ".uno:HelpIndex"
-#define CMD_SID_HELPMENU ".uno:HelpMenu"
-#define CMD_SID_HELPONHELP ".uno:HelpOnHelp"
-#define CMD_SID_HELP_SEARCH ".uno:HelpSearch"
-#define CMD_SID_HELPTIPS ".uno:HelpTip"
-#define CMD_SID_HELP_ZOOMIN ".uno:HelpZoomIn"
-#define CMD_SID_HELP_ZOOMOUT ".uno:HelpZoomOut"
-#define CMD_SID_BASICIDE_HIDECURPAGE ".uno:HideCurPage"
-#define CMD_SID_HYPERLINK_DIALOG ".uno:HyperlinkDialog"
-#define CMD_SID_INSERTDOC ".uno:InsertDoc"
-#define CMD_SID_HYPERLINK_INSERT ".uno:InsertHyperlink"
-#define CMD_SID_INSERT_FLOATINGFRAME ".uno:InsertObjectFloatingFrame"
-#define CMD_SID_INTERNET_ONLINE ".uno:InternetOnline"
-#define CMD_SID_INTERNET_SEARCH ".uno:InternetSearch"
-#define CMD_SID_DOC_LOADING ".uno:IsLoading"
-#define CMD_SID_IMG_LOADING ".uno:IsLoadingImages"
-#define CMD_SID_PRINTOUT ".uno:IsPrinting"
-#define CMD_SID_JUMPTOMARK ".uno:JumpToMark"
-#define CMD_SID_DOCINFO_KEYWORDS ".uno:Keywords"
-#define CMD_SID_BASICIDE_LIBLOADED ".uno:LibLoaded"
-#define CMD_SID_BASICIDE_LIBREMOVED ".uno:LibRemoved"
-#define CMD_SID_BASICIDE_LIBSELECTED ".uno:LibSelect"
-#define CMD_SID_BASICIDE_LIBSELECTOR ".uno:LibSelector"
-#define CMD_SID_OFFICE_PLK ".uno:LicenceKey"
-#define CMD_SID_CONFIGACCEL ".uno:LoadAccel"
-#define CMD_SID_BASICLOAD ".uno:LoadBasic"
-#define CMD_SID_LOADCONFIG ".uno:LoadConfiguration"
-#define CMD_SID_CONFIGEVENT ".uno:LoadEvents"
-#define CMD_SID_CONFIGMENU ".uno:LoadMenu"
-#define CMD_SID_CONFIGSTATUSBAR ".uno:LoadStatusBar"
-#define CMD_SID_TOOLBOXOPTIONS ".uno:LoadToolBox"
-#define CMD_SID_LOGOUT ".uno:Logout"
-#define CMD_SID_SCRIPTORGANIZER ".uno:ScriptOrganizer"
-#define CMD_SID_MACROORGANIZER ".uno:MacroOrganizer"
-#define CMD_SID_RUNMACRO ".uno:RunMacro"
-#define CMD_SID_BASICCHOOSER ".uno:MacroDialog"
-#define CMD_SID_MAIL_NOTIFY ".uno:MailReceipt"
-#define CMD_SID_MAIL_CHILDWIN ".uno:MailWindow"
-#define CMD_SID_BASICIDE_MATCHGROUP ".uno:MatchGroup"
-#define CMD_SID_TOGGLE_MENUBAR ".uno:MenuBarVisible"
-#define CMD_SID_DOCUMENT_MERGE ".uno:MergeDocuments"
-#define CMD_SID_ATTR_METRIC ".uno:MetricUnit"
-#define CMD_SID_MODIFIED ".uno:Modified"
-#define CMD_SID_DOC_MODIFIED ".uno:ModifiedStatus"
-#define CMD_SID_BASICIDE_MODULEDLG ".uno:ModuleDialog"
-#define CMD_SID_BASICIDE_NAMECHANGEDONTAB ".uno:NameChangedOnTab"
-#define CMD_SID_NAVIGATOR ".uno:Navigator"
-#define CMD_SID_RESTORE_EDITING_VIEW ".uno:RestoreEditingView"
-#define CMD_SID_BASICIDE_NEWDIALOG ".uno:NewDialog"
-#define CMD_SID_BASICIDE_NEWMODULE ".uno:NewModule"
-#define CMD_SID_CREATE_BASICOBJECT ".uno:NewObject"
-#define CMD_SID_STYLE_NEW ".uno:NewStyle"
-#define CMD_SID_NEWWINDOW ".uno:NewWindow"
-#define CMD_SID_BASICIDE_OBJCAT ".uno:ObjectCatalog"
-#define CMD_SID_OBJECT ".uno:ObjectMenue"
-#define CMD_SID_OLD_PALK ".uno:OldPALK"
-#define CMD_SID_OPENDOC ".uno:Open"
-#define CMD_SID_WEBHTML ".uno:WebHtml"
-#define CMD_SID_OPENHYPERLINK ".uno:OpenHyperlink"
-#define CMD_SID_DOCINFO_TITLE ".uno:DocInfoTitle"
-#define CMD_SID_OPENTEMPLATE ".uno:OpenTemplate"
-#define CMD_SID_OPENURL ".uno:OpenUrl"
-#define CMD_SID_OPTIONS ".uno:Options"
-#define CMD_SID_ORGANIZER ".uno:Organizer"
-#define CMD_SID_STYLE_FAMILY4 ".uno:PageStyle"
-#define CMD_SID_STYLE_FAMILY2 ".uno:ParaStyle"
-#define CMD_SID_PARTWIN ".uno:PartWindow"
-#define CMD_SID_PASTE ".uno:Paste"
-#define CMD_SID_CLIPBOARD_FORMAT_ITEMS ".uno:ClipboardFormatItems"
-#define CMD_SID_PASTE_SPECIAL ".uno:PasteSpecial"
-#define CMD_SID_DOCPATH ".uno:DocPath"
-#define CMD_SID_PICKLIST ".uno:PickList"
-#define CMD_SID_PLAYMACRO ".uno:PlayMacro"
-#define CMD_SID_PLUGINS_ACTIVE ".uno:PlugInsActive"
-#define CMD_SID_PRINTDOC ".uno:Print"
-#define CMD_SID_PRINTDOCDIRECT ".uno:PrintDefault"
-#define CMD_SID_PRINTER_NAME ".uno:Printer"
-#define CMD_SID_SETUPPRINTER ".uno:PrinterSetup"
-#define CMD_SID_PRINTPREVIEW ".uno:PrintPreview"
-#define CMD_SID_OFFICE_PRIVATE_USE ".uno:PrivateUse"
-#define CMD_SID_DOCINFO ".uno:SetDocumentProperties"
-#define CMD_SID_QUITAPP ".uno:Quit"
-#define CMD_SID_DOC_READONLY ".uno:ReadOnly"
-#define CMD_SID_RECORDMACRO ".uno:MacroRecorder"
-#define CMD_SID_STOP_RECORDING ".uno:StopRecording"
-#define CMD_SID_RECORDING_FLOATWINDOW ".uno:MacroRecordingFloat"
-#define CMD_SID_REDO ".uno:Redo"
-#define CMD_SID_DELETE_BASICOBJECT ".uno:ReleaseObject"
-#define CMD_SID_RELOAD ".uno:Reload"
-#define CMD_SID_BASICIDE_REMOVEWATCH ".uno:RemoveWatch"
-#define CMD_SID_BASICIDE_RENAMECURRENT ".uno:RenameCurrent"
-#define CMD_SID_REPAINT ".uno:Repaint"
-#define CMD_SID_REPEAT ".uno:RepeatAction"
-#define CMD_SID_RUBY_DIALOG ".uno:RubyDialog"
-#define CMD_SID_BASICRUN ".uno:RunBasic"
-#define CMD_SID_STARTSW ".uno:RunStarWriter"
-#define CMD_SID_SAVEDOC ".uno:Save"
-#define CMD_SID_SAVEDOCS ".uno:SaveAll"
-#define CMD_SID_SAVEASDOC ".uno:SaveAs"
-#define CMD_SID_DOCTEMPLATE ".uno:SaveAsTemplate"
-#define CMD_SID_BASICSAVEAS ".uno:SaveBasicAs"
-#define CMD_SID_EXPORT_DIALOG ".uno:ExportDialog"
-#define CMD_SID_IMPORT_DIALOG ".uno:ImportDialog"
-#define CMD_SID_SAVECONFIG ".uno:SaveConfiguration"
-#define CMD_SID_DOC_SAVED ".uno:Saved"
-#define CMD_SID_BASICIDE_SBXDELETED ".uno:SbxDeleted"
-#define CMD_SID_BASICIDE_SBXINSERTED ".uno:SbxInserted"
-#define CMD_SID_BASICIDE_SBXRENAMED ".uno:SbxRenamed"
-#define CMD_SID_MAIL_SCROLLBODY_PAGEDOWN ".uno:ScrollBodyPageDown"
-#define CMD_SID_SEARCH_DLG ".uno:SearchDialog"
-#define CMD_SID_SEARCH_OPTIONS ".uno:SearchOptions"
-#define CMD_SID_SEARCH_ITEM ".uno:SearchProperties"
-#define CMD_SID_SELECTALL ".uno:SelectAll"
-#define CMD_FN_FAX ".uno:SendFax"
-#define CMD_SID_MAIL_SENDDOC ".uno:SendMail"
-#define CMD_SID_MAIL_SENDDOCASPDF ".uno:SendMailDocAsPDF"
-#define CMD_SID_MAIL_SENDDOCASFORMAT ".uno:SendMailDocAsFormat"
-#define CMD_SID_MAIL_SENDDOCASMS ".uno:SendMailDocAsMS"
-#define CMD_SID_MAIL_SENDDOCASOOO ".uno:SendMailDocAsOOo"
-#define CMD_SID_SETOPTIONS ".uno:SetOptions"
-#define CMD_SID_OFFICE_PALK ".uno:SetPALK"
-#define CMD_SID_SHOW_BROWSER ".uno:ShowBrowser"
-#define CMD_SID_SHOWPOPUPS ".uno:ShowPopups"
-#define CMD_SID_BASICIDE_SHOWSBX ".uno:ShowSbx"
-#define CMD_SID_SOURCEVIEW ".uno:SourceView"
-#define CMD_SID_ONLINE_REGISTRATION_DLG ".uno:StartRegistrationDialog"
-#define CMD_SID_STATUSBARTEXT ".uno:StatusBar"
-#define CMD_SID_TOGGLESTATUSBAR ".uno:StatusBarVisible"
-#define CMD_SID_BASICIDE_STAT_DATE ".uno:StatusGetDate"
-#define CMD_SID_BASICIDE_STAT_POS ".uno:StatusGetPosition"
-#define CMD_SID_BASICIDE_STAT_TITLE ".uno:StatusGetTitle"
-#define CMD_SID_BASICIDE_STOREALLMODULESOURCES ".uno:StoreAllModuleSources"
-#define CMD_SID_BASICIDE_STOREMODULESOURCE ".uno:StoreModuleSource"
-#define CMD_SID_STYLE_APPLY ".uno:StyleApplyState"
-#define CMD_SID_STYLE_CATALOG ".uno:StyleCatalog"
-#define CMD_SID_STYLE_NEW_BY_EXAMPLE ".uno:StyleNewByExample"
-#define CMD_SID_STYLE_UPDATE_BY_EXAMPLE ".uno:StyleUpdateByExample"
-#define CMD_SID_STYLE_WATERCAN ".uno:StyleWatercanMode"
-#define CMD_SID_VIEWSHELL ".uno:SwitchViewShell"
-#define CMD_SID_TASKBAR ".uno:TaskBarVisible"
-#define CMD_SID_STYLE_FAMILY5 ".uno:ListStyle"
-#define CMD_SID_TIPWINDOW ".uno:TipsDialog"
-#define CMD_SID_DOCTITLE ".uno:Title"
-#define CMD_SID_TITLE ".uno:Title"
-#define CMD_SID_BASICIDE_TOGGLEBRKPNT ".uno:ToggleBreakPoint"
-#define CMD_SID_BASICIDE_SHOWWINDOW ".uno:BasicIDEShowWindow"
-#define CMD_SID_EDITMACRO ".uno:ToolsMacroEdit"
-#define CMD_SID_UNDO ".uno:Undo"
-#define CMD_SID_FORMATPAINTBRUSH ".uno:FormatPaintbrush"
-#define CMD_SID_ATTR_UNDO_COUNT ".uno:UndoCount"
-#define CMD_SID_BASICIDE_UPDATEALLMODULESOURCES ".uno:UpdateAllModuleSources"
-#define CMD_SID_BASICIDE_UPDATEMODULESOURCE ".uno:UpdateModuleSource"
-#define CMD_SID_BASICIDE_MANAGEBRKPNTS ".uno:ManageBreakPoints"
-#define CMD_SID_BASICIDE_TOGGLEBRKPNTENABLED ".uno:ToggleBreakPointEnabled"
-#define CMD_SID_UPDATE_VERSION ".uno:UpdateVersion"
-#define CMD_SID_VERSION ".uno:VersionDialog"
-#define CMD_SID_SIGNATURE ".uno:Signature"
-#define CMD_SID_MACRO_SIGNATURE ".uno:MacroSignature"
-#define CMD_SID_VERSION_VISIBLE ".uno:VersionVisible"
-#define CMD_SID_VIEW_DATA_SOURCE_BROWSER ".uno:ViewDataSourceBrowser"
-#define CMD_SID_WIN_VISIBLE ".uno:WinVisible"
-#define CMD_SID_MDIWINDOWLIST ".uno:WindowList"
-#define CMD_SID_ZOOM_IN ".uno:ZoomMinus"
-#define CMD_SID_ZOOM ".uno:Zooming"
-#define CMD_SID_ZOOM_NEXT ".uno:ZoomNext"
-#define CMD_SID_ZOOM_OUT ".uno:ZoomPlus"
-#define CMD_SID_ZOOM_PREV ".uno:ZoomPrevious"
-#define CMD_SID_ZOOM_TOOLBOX ".uno:ZoomToolBox"
-#define CMD_SID_EXPORTDOC ".uno:ExportTo"
-#define CMD_SID_EXPORTDOCASPDF ".uno:ExportToPDF"
-#define CMD_SID_DIRECTEXPORTDOCASPDF ".uno:ExportDirectToPDF"
-#define CMD_SID_IMAGE_ORIENTATION ".uno:ImageOrientation"
-#define CMD_SID_SAVE_VERSION_ON_CLOSE ".uno:SaveVersionOnClose"
-#define CMD_SID_ADDONS ".uno:Addons"
-#define CMD_SID_SHOW_IME_STATUS_WINDOW ".uno:ShowImeStatusWindow"
-#define CMD_SID_UPDATE_CONFIG ".uno:UpdateConfiguration"
-#define CMD_SID_HELP_SUPPORTPAGE ".uno:HelpSupport"
-#define CMD_SID_HELP_TUTORIALS ".uno:HelpTutorials"
-#define CMD_SID_ADDONHELP ".uno:AddonHelp"
-#define CMD_SID_FORMATMENUSTATE ".uno:FormatMenuState"
-#define CMD_SID_INET_DLG ".uno:InternetDialog"
-#define CMD_SID_ONLINE_REGISTRATION ".uno:OnlineRegistrationDlg"
-#define CMD_SID_OFFICE_CHECK_PLZ ".uno:CheckPLZ"
-#define CMD_SID_ADDRESS_DATA_SOURCE ".uno:AutoPilotAddressDataSource"
-#define CMD_FN_BUSINESS_CARD ".uno:InsertBusinessCard"
-#define CMD_FN_LABEL ".uno:InsertLabels"
-#define CMD_FN_XFORMS_INIT ".uno:NewXForms"
-#define CMD_SID_SD_AUTOPILOT ".uno:AutoPilotPresentations"
-#define CMD_SID_NEWSD ".uno:NewPresentation"
-#define CMD_SID_COMP_BIBLIOGRAPHY ".uno:BibliographyComponent"
-#define CMD_SID_MINIMIZED ".uno:Minimized"
-#define CMD_SID_AUTO_CORRECT_DLG ".uno:AutoCorrectDlg"
-#define CMD_SID_OPTIONS_TREEDIALOG ".uno:OptionsTreeDialog"
-#define CMD_SID_TERMINATE_INPLACEACTIVATION ".uno:TerminateInplaceActivation"
-#define CMD_SID_RECENTFILELIST ".uno:RecentFileList"
-#define CMD_SID_AVAILABLE_TOOLBARS ".uno:AvailableToolbars"
-#define CMD_SID_AVMEDIA_PLAYER ".uno:AVMediaPlayer"
-#define CMD_SID_INSERT_AVMEDIA ".uno:InsertAVMedia"
-#define CMD_SID_MORE_DICTIONARIES ".uno:MoreDictionaries"
-#define CMD_SID_ACTIVATE_STYLE_APPLY ".uno:ActivateStyleApply"
-#define CMD_SID_DOCKWIN_0 ".uno:DockingWindow0"
-#define CMD_SID_DOCKWIN_1 ".uno:DockingWindow1"
-#define CMD_SID_DOCKWIN_2 ".uno:DockingWindow2"
-#define CMD_SID_DOCKWIN_3 ".uno:DockingWindow3"
-#define CMD_SID_DOCKWIN_4 ".uno:DockingWindow4"
-#define CMD_SID_DOCKWIN_5 ".uno:DockingWindow5"
-#define CMD_SID_DOCKWIN_6 ".uno:DockingWindow6"
-#define CMD_SID_DOCKWIN_7 ".uno:DockingWindow7"
-#define CMD_SID_DOCKWIN_8 ".uno:DockingWindow8"
-#define CMD_SID_DOCKWIN_9 ".uno:DockingWindow9"
-#define CMD_SID_PASTE_UNFORMATTED ".uno:PasteUnformatted"
-
-#endif
+/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SFX2_SFXCOMMANDS_HRC +#define SFX2_SFXCOMMANDS_HRC + +#define CMD_SID_VIEWSHELL0 ".uno:_SwitchViewShell0" +#define CMD_SID_VIEWSHELL1 ".uno:_SwitchViewShell1" +#define CMD_SID_VIEWSHELL2 ".uno:_SwitchViewShell2" +#define CMD_SID_VIEWSHELL3 ".uno:_SwitchViewShell3" +#define CMD_SID_VIEWSHELL4 ".uno:_SwitchViewShell4" +#define CMD_SID_ABOUT ".uno:About" +#define CMD_SID_ACTIVATE ".uno:Activate" +#define CMD_SID_HELPBALLOONS ".uno:ActiveHelp" +#define CMD_SID_STYLE_FAMILY ".uno:ActualStyleFamily" +#define CMD_SID_NEWDOC ".uno:NewDoc" +#define CMD_SID_CREATELINK ".uno:AddBookmark" +#define CMD_SID_NEWDOCDIRECT ".uno:AddDirect" +#define CMD_SID_TEMPLATE_ADDRESSBOKSOURCE ".uno:AddressBookSource" +#define CMD_SID_BASICIDE_ADDWATCH ".uno:AddWatch" +#define CMD_SID_DOCINFO_AUTHOR ".uno:Author" +#define CMD_SID_AUTOHIDE ".uno:AutoHide" +#define CMD_SID_AUTOPILOTMENU ".uno:AutoPilotMenu" +#define CMD_SID_GALLERY_BG_BRUSH ".uno:BackgroundImage" +#define CMD_SID_BACKSPACE ".uno:Backspace" +#define CMD_SID_BASICBREAK ".uno:BasicBreak" +#define CMD_SID_BASICIDE_APPEAR ".uno:BasicIDEAppear" +#define CMD_SID_BASICSTEPINTO ".uno:BasicStepInto" +#define CMD_SID_BASICSTEPOUT ".uno:BasicStepOut" +#define CMD_SID_BASICSTEPOVER ".uno:BasicStepOver" +#define CMD_SID_BASICSTOP ".uno:BasicStop" +#define CMD_SID_BROWSER ".uno:Beamer" +#define CMD_SID_BASICIDE_BRKPNTSCHANGED ".uno:BreakPointsChanged" +#define CMD_SID_BROWSE_BACKWARD ".uno:BrowseBackward" +#define CMD_SID_BROWSE_FORWARD ".uno:BrowseForward" +#define CMD_SID_BROWSER_MODE ".uno:BrowseView" +#define CMD_SID_BUILD_VERSION ".uno:BuildVersion" +#define CMD_SID_CAPTION ".uno:Caption" +#define CMD_SID_STYLE_FAMILY1 ".uno:CharStyle" +#define CMD_SID_CHECK_KEY ".uno:CheckKey" +#define CMD_SID_BASICIDE_CHOOSEMACRO ".uno:ChooseMacro" +#define CMD_SID_CLEARHISTORY ".uno:ClearHistory" +#define CMD_SID_CLOSEWINS ".uno:CloseWins" +#define CMD_SID_CLOSEDOCS ".uno:CloseDocs" +#define CMD_SID_CLOSEDOC ".uno:CloseDoc" +#define CMD_SID_CLOSEWIN ".uno:CloseWin" +#define CMD_SID_CLOSING ".uno:Closing" +#define CMD_SID_DOCINFO_COMMENTS ".uno:Comments" +#define CMD_SID_OFFICE_COMMERCIAL_USE ".uno:CommercialUse" +#define CMD_SID_DOCUMENT_COMPARE ".uno:CompareDocuments" +#define CMD_SID_BASICCOMPILE ".uno:CompileBasic" +#define CMD_SID_CONFIG ".uno:ConfigureDialog" +#define CMD_SID_CONTEXT ".uno:Context" +#define CMD_SID_COPY ".uno:Copy" +#define CMD_SID_CRASH ".uno:Crash" +#define CMD_SID_BASICIDE_CREATEMACRO ".uno:CreateMacro" +#define CMD_SID_CURRENT_URL ".uno:CurrentURL" +#define CMD_SID_CURSORENDOFSCREEN ".uno:CursorEndOfScreen" +#define CMD_SID_CURSORTOPOFSCREEN ".uno:CursorTopOfScreen" +#define CMD_SID_OFFICE_CUSTOMERNUMBER ".uno:CustomerNumber" +#define CMD_SID_CUT ".uno:Cut" +#define CMD_SID_DEFAULTFILEPATH ".uno:DefaultFilePath" +#define CMD_SID_DEFAULTFILENAME ".uno:DefaultFileName" +#define CMD_SID_DELETE ".uno:Delete" +#define CMD_SID_BASICIDE_DELETECURRENT ".uno:DeleteCurrent" +#define CMD_SID_STYLE_DELETE ".uno:DeleteStyle" +#define CMD_SID_STYLE_DESIGNER ".uno:DesignerDialog" +#define CMD_SID_STYLE_DRAGHIERARCHIE ".uno:DragHierarchy" +#define CMD_SID_EDITDOC ".uno:EditDoc" +#define CMD_SID_BASICIDE_EDITMACRO ".uno:EditMacro" +#define CMD_SID_STYLE_EDIT ".uno:EditStyle" +#define CMD_FID_SEARCH_NOW ".uno:ExecuteSearch" +#define CMD_SID_EXTENDEDHELP ".uno:ExtendedHelp" +#define CMD_SID_FILE_NAME ".uno:FileName" +#define CMD_SID_FOCUSURLBOX ".uno:FocusUrlBox" +#define CMD_SID_FORMATMENU ".uno:FormatMenu" +#define CMD_SID_STYLE_FAMILY3 ".uno:FrameStyle" +#define CMD_SID_FRAMETITLE ".uno:FrameTitle" +#define CMD_SID_PROGFILENAME ".uno:FullName" +#define CMD_SID_DOCFULLNAME ".uno:FullName" +#define CMD_SID_WIN_FULLSCREEN ".uno:FullScreen" +#define CMD_SID_FILLFRAME ".uno:GetFrameWindow" +#define CMD_SID_CURSORDOWN ".uno:GoDown" +#define CMD_SID_CURSORPAGEDOWN ".uno:GoDownBlock" +#define CMD_SID_CURSORPAGEDOWN_SEL ".uno:GoDownBlockSel" +#define CMD_SID_CURSORDOWN_SEL ".uno:GoDownSel" +#define CMD_SID_CURSORLEFT ".uno:GoLeft" +#define CMD_SID_CURSORPAGELEFT ".uno:GoLeftBlock" +#define CMD_SID_CURSORPAGELEFT_SEL ".uno:GoLeftBlockSel" +#define CMD_SID_CURSORLEFT_SEL ".uno:GoLeftSel" +#define CMD_SID_CURSORRIGHT ".uno:GoRight" +#define CMD_SID_CURSORRIGHT_SEL ".uno:GoRightSel" +#define CMD_SID_CURSORENDOFFILE ".uno:GoToEndOfData" +#define CMD_SID_CURSORENDOFFILE_SEL ".uno:GoToEndOfDataSel" +#define CMD_SID_CURSOREND ".uno:GoToEndOfRow" +#define CMD_SID_CURSOREND_SEL ".uno:GoToEndOfRowSel" +#define CMD_SID_CURSORTOPOFFILE ".uno:GoToStart" +#define CMD_SID_CURSORHOME ".uno:GoToStartOfRow" +#define CMD_SID_CURSORHOME_SEL ".uno:GoToStartOfRowSel" +#define CMD_SID_CURSORTOPOFFILE_SEL ".uno:GoToStartSel" +#define CMD_SID_CURSORUP ".uno:GoUp" +#define CMD_SID_CURSORPAGEUP ".uno:GoUpBlock" +#define CMD_SID_CURSORPAGEUP_SEL ".uno:GoUpBlockSel" +#define CMD_SID_CURSORUP_SEL ".uno:GoUpSel" +#define CMD_SID_HELP_ANNOTATE ".uno:HelpAnnotate" +#define CMD_SID_HELP_BOOKMARK ".uno:HelpBookmark" +#define CMD_SID_HELP_HELPFILEBOX ".uno:HelpChooseFile" +#define CMD_SID_HELP_DOWNLOAD ".uno:HelpDownload" +#define CMD_SID_HELP_PI ".uno:HelperDialog" +#define CMD_SID_HELPINDEX ".uno:HelpIndex" +#define CMD_SID_HELPMENU ".uno:HelpMenu" +#define CMD_SID_HELPONHELP ".uno:HelpOnHelp" +#define CMD_SID_HELP_SEARCH ".uno:HelpSearch" +#define CMD_SID_HELPTIPS ".uno:HelpTip" +#define CMD_SID_HELP_ZOOMIN ".uno:HelpZoomIn" +#define CMD_SID_HELP_ZOOMOUT ".uno:HelpZoomOut" +#define CMD_SID_BASICIDE_HIDECURPAGE ".uno:HideCurPage" +#define CMD_SID_HYPERLINK_DIALOG ".uno:HyperlinkDialog" +#define CMD_SID_INSERTDOC ".uno:InsertDoc" +#define CMD_SID_HYPERLINK_INSERT ".uno:InsertHyperlink" +#define CMD_SID_INSERT_FLOATINGFRAME ".uno:InsertObjectFloatingFrame" +#define CMD_SID_INTERNET_ONLINE ".uno:InternetOnline" +#define CMD_SID_INTERNET_SEARCH ".uno:InternetSearch" +#define CMD_SID_DOC_LOADING ".uno:IsLoading" +#define CMD_SID_IMG_LOADING ".uno:IsLoadingImages" +#define CMD_SID_PRINTOUT ".uno:IsPrinting" +#define CMD_SID_JUMPTOMARK ".uno:JumpToMark" +#define CMD_SID_DOCINFO_KEYWORDS ".uno:Keywords" +#define CMD_SID_BASICIDE_LIBLOADED ".uno:LibLoaded" +#define CMD_SID_BASICIDE_LIBREMOVED ".uno:LibRemoved" +#define CMD_SID_BASICIDE_LIBSELECTED ".uno:LibSelect" +#define CMD_SID_BASICIDE_LIBSELECTOR ".uno:LibSelector" +#define CMD_SID_OFFICE_PLK ".uno:LicenceKey" +#define CMD_SID_CONFIGACCEL ".uno:LoadAccel" +#define CMD_SID_BASICLOAD ".uno:LoadBasic" +#define CMD_SID_LOADCONFIG ".uno:LoadConfiguration" +#define CMD_SID_CONFIGEVENT ".uno:LoadEvents" +#define CMD_SID_CONFIGMENU ".uno:LoadMenu" +#define CMD_SID_CONFIGSTATUSBAR ".uno:LoadStatusBar" +#define CMD_SID_TOOLBOXOPTIONS ".uno:LoadToolBox" +#define CMD_SID_LOGOUT ".uno:Logout" +#define CMD_SID_SCRIPTORGANIZER ".uno:ScriptOrganizer" +#define CMD_SID_MACROORGANIZER ".uno:MacroOrganizer" +#define CMD_SID_RUNMACRO ".uno:RunMacro" +#define CMD_SID_BASICCHOOSER ".uno:MacroDialog" +#define CMD_SID_MAIL_NOTIFY ".uno:MailReceipt" +#define CMD_SID_MAIL_CHILDWIN ".uno:MailWindow" +#define CMD_SID_BASICIDE_MATCHGROUP ".uno:MatchGroup" +#define CMD_SID_TOGGLE_MENUBAR ".uno:MenuBarVisible" +#define CMD_SID_DOCUMENT_MERGE ".uno:MergeDocuments" +#define CMD_SID_ATTR_METRIC ".uno:MetricUnit" +#define CMD_SID_MODIFIED ".uno:Modified" +#define CMD_SID_DOC_MODIFIED ".uno:ModifiedStatus" +#define CMD_SID_BASICIDE_MODULEDLG ".uno:ModuleDialog" +#define CMD_SID_BASICIDE_NAMECHANGEDONTAB ".uno:NameChangedOnTab" +#define CMD_SID_NAVIGATOR ".uno:Navigator" +#define CMD_SID_RESTORE_EDITING_VIEW ".uno:RestoreEditingView" +#define CMD_SID_BASICIDE_NEWDIALOG ".uno:NewDialog" +#define CMD_SID_BASICIDE_NEWMODULE ".uno:NewModule" +#define CMD_SID_CREATE_BASICOBJECT ".uno:NewObject" +#define CMD_SID_STYLE_NEW ".uno:NewStyle" +#define CMD_SID_NEWWINDOW ".uno:NewWindow" +#define CMD_SID_BASICIDE_OBJCAT ".uno:ObjectCatalog" +#define CMD_SID_OBJECT ".uno:ObjectMenue" +#define CMD_SID_OLD_PALK ".uno:OldPALK" +#define CMD_SID_OPENDOC ".uno:Open" +#define CMD_SID_WEBHTML ".uno:WebHtml" +#define CMD_SID_OPENHYPERLINK ".uno:OpenHyperlink" +#define CMD_SID_DOCINFO_TITLE ".uno:DocInfoTitle" +#define CMD_SID_OPENTEMPLATE ".uno:OpenTemplate" +#define CMD_SID_OPENURL ".uno:OpenUrl" +#define CMD_SID_OPTIONS ".uno:Options" +#define CMD_SID_ORGANIZER ".uno:Organizer" +#define CMD_SID_STYLE_FAMILY4 ".uno:PageStyle" +#define CMD_SID_STYLE_FAMILY2 ".uno:ParaStyle" +#define CMD_SID_PARTWIN ".uno:PartWindow" +#define CMD_SID_PASTE ".uno:Paste" +#define CMD_SID_CLIPBOARD_FORMAT_ITEMS ".uno:ClipboardFormatItems" +#define CMD_SID_PASTE_SPECIAL ".uno:PasteSpecial" +#define CMD_SID_DOCPATH ".uno:DocPath" +#define CMD_SID_PICKLIST ".uno:PickList" +#define CMD_SID_PLUGINS_ACTIVE ".uno:PlugInsActive" +#define CMD_SID_PRINTDOC ".uno:Print" +#define CMD_SID_PRINTDOCDIRECT ".uno:PrintDefault" +#define CMD_SID_PRINTER_NAME ".uno:Printer" +#define CMD_SID_SETUPPRINTER ".uno:PrinterSetup" +#define CMD_SID_PRINTPREVIEW ".uno:PrintPreview" +#define CMD_SID_OFFICE_PRIVATE_USE ".uno:PrivateUse" +#define CMD_SID_DOCINFO ".uno:SetDocumentProperties" +#define CMD_SID_QUITAPP ".uno:Quit" +#define CMD_SID_DOC_READONLY ".uno:ReadOnly" +#define CMD_SID_RECORDMACRO ".uno:MacroRecorder" +#define CMD_SID_STOP_RECORDING ".uno:StopRecording" +#define CMD_SID_RECORDING_FLOATWINDOW ".uno:MacroRecordingFloat" +#define CMD_SID_REDO ".uno:Redo" +#define CMD_SID_DELETE_BASICOBJECT ".uno:ReleaseObject" +#define CMD_SID_RELOAD ".uno:Reload" +#define CMD_SID_BASICIDE_REMOVEWATCH ".uno:RemoveWatch" +#define CMD_SID_BASICIDE_RENAMECURRENT ".uno:RenameCurrent" +#define CMD_SID_REPAINT ".uno:Repaint" +#define CMD_SID_REPEAT ".uno:RepeatAction" +#define CMD_SID_RUBY_DIALOG ".uno:RubyDialog" +#define CMD_SID_BASICRUN ".uno:RunBasic" +#define CMD_SID_SAVEDOC ".uno:Save" +#define CMD_SID_SAVEDOCS ".uno:SaveAll" +#define CMD_SID_SAVEASDOC ".uno:SaveAs" +#define CMD_SID_DOCTEMPLATE ".uno:SaveAsTemplate" +#define CMD_SID_BASICSAVEAS ".uno:SaveBasicAs" +#define CMD_SID_EXPORT_DIALOG ".uno:ExportDialog" +#define CMD_SID_IMPORT_DIALOG ".uno:ImportDialog" +#define CMD_SID_SAVECONFIG ".uno:SaveConfiguration" +#define CMD_SID_DOC_SAVED ".uno:Saved" +#define CMD_SID_BASICIDE_SBXDELETED ".uno:SbxDeleted" +#define CMD_SID_BASICIDE_SBXINSERTED ".uno:SbxInserted" +#define CMD_SID_BASICIDE_SBXRENAMED ".uno:SbxRenamed" +#define CMD_SID_MAIL_SCROLLBODY_PAGEDOWN ".uno:ScrollBodyPageDown" +#define CMD_SID_SEARCH_DLG ".uno:SearchDialog" +#define CMD_SID_SEARCH_OPTIONS ".uno:SearchOptions" +#define CMD_SID_SEARCH_ITEM ".uno:SearchProperties" +#define CMD_SID_SELECTALL ".uno:SelectAll" +#define CMD_FN_FAX ".uno:SendFax" +#define CMD_SID_MAIL_SENDDOC ".uno:SendMail" +#define CMD_SID_MAIL_SENDDOCASPDF ".uno:SendMailDocAsPDF" +#define CMD_SID_MAIL_SENDDOCASFORMAT ".uno:SendMailDocAsFormat" +#define CMD_SID_MAIL_SENDDOCASMS ".uno:SendMailDocAsMS" +#define CMD_SID_MAIL_SENDDOCASOOO ".uno:SendMailDocAsOOo" +#define CMD_SID_SETOPTIONS ".uno:SetOptions" +#define CMD_SID_OFFICE_PALK ".uno:SetPALK" +#define CMD_SID_SHOW_BROWSER ".uno:ShowBrowser" +#define CMD_SID_SHOWPOPUPS ".uno:ShowPopups" +#define CMD_SID_BASICIDE_SHOWSBX ".uno:ShowSbx" +#define CMD_SID_SOURCEVIEW ".uno:SourceView" +#define CMD_SID_ONLINE_REGISTRATION_DLG ".uno:StartRegistrationDialog" +#define CMD_SID_STATUSBARTEXT ".uno:StatusBar" +#define CMD_SID_TOGGLESTATUSBAR ".uno:StatusBarVisible" +#define CMD_SID_BASICIDE_STAT_DATE ".uno:StatusGetDate" +#define CMD_SID_BASICIDE_STAT_POS ".uno:StatusGetPosition" +#define CMD_SID_BASICIDE_STAT_TITLE ".uno:StatusGetTitle" +#define CMD_SID_BASICIDE_STOREALLMODULESOURCES ".uno:StoreAllModuleSources" +#define CMD_SID_BASICIDE_STOREMODULESOURCE ".uno:StoreModuleSource" +#define CMD_SID_STYLE_APPLY ".uno:StyleApplyState" +#define CMD_SID_STYLE_CATALOG ".uno:StyleCatalog" +#define CMD_SID_STYLE_NEW_BY_EXAMPLE ".uno:StyleNewByExample" +#define CMD_SID_STYLE_UPDATE_BY_EXAMPLE ".uno:StyleUpdateByExample" +#define CMD_SID_STYLE_WATERCAN ".uno:StyleWatercanMode" +#define CMD_SID_VIEWSHELL ".uno:SwitchViewShell" +#define CMD_SID_TASKBAR ".uno:TaskBarVisible" +#define CMD_SID_STYLE_FAMILY5 ".uno:ListStyle" +#define CMD_SID_TIPWINDOW ".uno:TipsDialog" +#define CMD_SID_DOCTITLE ".uno:Title" +#define CMD_SID_TITLE ".uno:Title" +#define CMD_SID_BASICIDE_TOGGLEBRKPNT ".uno:ToggleBreakPoint" +#define CMD_SID_BASICIDE_SHOWWINDOW ".uno:BasicIDEShowWindow" +#define CMD_SID_UNDO ".uno:Undo" +#define CMD_SID_FORMATPAINTBRUSH ".uno:FormatPaintbrush" +#define CMD_SID_ATTR_UNDO_COUNT ".uno:UndoCount" +#define CMD_SID_BASICIDE_UPDATEALLMODULESOURCES ".uno:UpdateAllModuleSources" +#define CMD_SID_BASICIDE_UPDATEMODULESOURCE ".uno:UpdateModuleSource" +#define CMD_SID_BASICIDE_MANAGEBRKPNTS ".uno:ManageBreakPoints" +#define CMD_SID_BASICIDE_TOGGLEBRKPNTENABLED ".uno:ToggleBreakPointEnabled" +#define CMD_SID_UPDATE_VERSION ".uno:UpdateVersion" +#define CMD_SID_VERSION ".uno:VersionDialog" +#define CMD_SID_SIGNATURE ".uno:Signature" +#define CMD_SID_MACRO_SIGNATURE ".uno:MacroSignature" +#define CMD_SID_VERSION_VISIBLE ".uno:VersionVisible" +#define CMD_SID_VIEW_DATA_SOURCE_BROWSER ".uno:ViewDataSourceBrowser" +#define CMD_SID_WIN_VISIBLE ".uno:WinVisible" +#define CMD_SID_MDIWINDOWLIST ".uno:WindowList" +#define CMD_SID_ZOOM_IN ".uno:ZoomMinus" +#define CMD_SID_ZOOM ".uno:Zooming" +#define CMD_SID_ZOOM_NEXT ".uno:ZoomNext" +#define CMD_SID_ZOOM_OUT ".uno:ZoomPlus" +#define CMD_SID_ZOOM_PREV ".uno:ZoomPrevious" +#define CMD_SID_ZOOM_TOOLBOX ".uno:ZoomToolBox" +#define CMD_SID_EXPORTDOC ".uno:ExportTo" +#define CMD_SID_EXPORTDOCASPDF ".uno:ExportToPDF" +#define CMD_SID_DIRECTEXPORTDOCASPDF ".uno:ExportDirectToPDF" +#define CMD_SID_IMAGE_ORIENTATION ".uno:ImageOrientation" +#define CMD_SID_SAVE_VERSION_ON_CLOSE ".uno:SaveVersionOnClose" +#define CMD_SID_ADDONS ".uno:Addons" +#define CMD_SID_SHOW_IME_STATUS_WINDOW ".uno:ShowImeStatusWindow" +#define CMD_SID_UPDATE_CONFIG ".uno:UpdateConfiguration" +#define CMD_SID_HELP_SUPPORTPAGE ".uno:HelpSupport" +#define CMD_SID_HELP_TUTORIALS ".uno:HelpTutorials" +#define CMD_SID_ADDONHELP ".uno:AddonHelp" +#define CMD_SID_FORMATMENUSTATE ".uno:FormatMenuState" +#define CMD_SID_INET_DLG ".uno:InternetDialog" +#define CMD_SID_ONLINE_REGISTRATION ".uno:OnlineRegistrationDlg" +#define CMD_SID_OFFICE_CHECK_PLZ ".uno:CheckPLZ" +#define CMD_SID_ADDRESS_DATA_SOURCE ".uno:AutoPilotAddressDataSource" +#define CMD_FN_BUSINESS_CARD ".uno:InsertBusinessCard" +#define CMD_FN_LABEL ".uno:InsertLabels" +#define CMD_FN_XFORMS_INIT ".uno:NewXForms" +#define CMD_SID_SD_AUTOPILOT ".uno:AutoPilotPresentations" +#define CMD_SID_NEWSD ".uno:NewPresentation" +#define CMD_SID_COMP_BIBLIOGRAPHY ".uno:BibliographyComponent" +#define CMD_SID_MINIMIZED ".uno:Minimized" +#define CMD_SID_AUTO_CORRECT_DLG ".uno:AutoCorrectDlg" +#define CMD_SID_OPTIONS_TREEDIALOG ".uno:OptionsTreeDialog" +#define CMD_SID_TERMINATE_INPLACEACTIVATION ".uno:TerminateInplaceActivation" +#define CMD_SID_RECENTFILELIST ".uno:RecentFileList" +#define CMD_SID_AVAILABLE_TOOLBARS ".uno:AvailableToolbars" +#define CMD_SID_AVMEDIA_PLAYER ".uno:AVMediaPlayer" +#define CMD_SID_INSERT_AVMEDIA ".uno:InsertAVMedia" +#define CMD_SID_MORE_DICTIONARIES ".uno:MoreDictionaries" +#define CMD_SID_ACTIVATE_STYLE_APPLY ".uno:ActivateStyleApply" +#define CMD_SID_DOCKWIN_0 ".uno:DockingWindow0" +#define CMD_SID_DOCKWIN_1 ".uno:DockingWindow1" +#define CMD_SID_DOCKWIN_2 ".uno:DockingWindow2" +#define CMD_SID_DOCKWIN_3 ".uno:DockingWindow3" +#define CMD_SID_DOCKWIN_4 ".uno:DockingWindow4" +#define CMD_SID_DOCKWIN_5 ".uno:DockingWindow5" +#define CMD_SID_DOCKWIN_6 ".uno:DockingWindow6" +#define CMD_SID_DOCKWIN_7 ".uno:DockingWindow7" +#define CMD_SID_DOCKWIN_8 ".uno:DockingWindow8" +#define CMD_SID_DOCKWIN_9 ".uno:DockingWindow9" +#define CMD_SID_PASTE_UNFORMATTED ".uno:PasteUnformatted" + +#endif diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 561a41b04387..17d47097fb46 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -522,41 +522,29 @@ #define SID_CURSORTOPOFSCREEN (SID_SFX_START + 744) #define SID_CURSORHOME (SID_SFX_START + 745) #define SID_CURSOREND (SID_SFX_START + 746) -#define SID_SCROLLDOWN (SID_SFX_START + 751) -#define SID_SCROLLUP (SID_SFX_START + 752) #define SID_FORMATMENU (SID_SFX_START + 780) #define SID_OBJECTMENU0 SID_FORMATMENU #define SID_OBJECTMENU1 (SID_SFX_START + 781) #define SID_OBJECTMENU2 (SID_SFX_START + 782) #define SID_OBJECTMENU3 (SID_SFX_START + 783) #define SID_OBJECTMENU_LAST SID_OBJECTMENU3 -#define SID_EDITMENU (SID_SFX_START + 790) #define SID_FORMATMENUSTATE (SID_SFX_START + 791) // default-ids for macros #define SID_RECORDING_FLOATWINDOW (SID_SFX_START + 800) #define SID_RECORDMACRO (SID_SFX_START + 1669) -#define SID_PLAYMACRO (SID_SFX_START + 801) -#define SID_EDITMACRO (SID_SFX_START + 802) -#define SID_MACROLIBMANAGER (SID_SFX_START + 803) -#define SID_LOADMACROLIB (SID_SFX_START + 804) -#define SID_RELEASEMACROLIB (SID_SFX_START + 805) -#define SID_BASICNAME (SID_SFX_START + 806) -#define SID_LIBNAME (SID_SFX_START + 807) -#define SID_MODULENAME (SID_SFX_START + 808) -#define SID_STATEMENT (SID_SFX_START + 810) + // FREE: SID_SFX_START + 801 + // FREE: SID_SFX_START + 802 + // FREE: SID_SFX_START + 803 + // FREE: SID_SFX_START + 804 + // FREE: SID_SFX_START + 805 + // FREE: SID_SFX_START + 806 + // FREE: SID_SFX_START + 807 + // FREE: SID_SFX_START + 808 + // FREE: SID_SFX_START + 809 + // FREE: SID_SFX_START + 810 #define SID_ASYNCHRON (SID_SFX_START + 811) -#define SID_START_APP (SID_SFX_START + 820) -#define SID_START_BEGIN (SID_SFX_START + 821) -#define SID_STARTSW SID_START_BEGIN -#define SID_STARTSC (SID_START_BEGIN + 1) -#define SID_STARTSD (SID_START_BEGIN + 2) -#define SID_STARTSIM (SID_START_BEGIN + 3) -#define SID_STARTSCH (SID_START_BEGIN + 4) -#define SID_STARTSMA (SID_START_BEGIN + 5) -#define SID_START_END SID_STARTSMA - // default-ids for configuration #define SID_RESTOREMENU (SID_SFX_START + 901) #define SID_RESTOREACCELS (SID_SFX_START + 902) @@ -622,11 +610,9 @@ #define SID_OBJECTRESIZE (SID_SFX_START + 1000) #define SID_INSERT_TEXT (SID_SFX_START + 1001) -#define SID_MACRO_START (SID_SFX_START + 1002) -#define SID_MACRO_END (SID_SFX_START + 1100) -#define SID_EVENTCONFIG (SID_MACRO_END + 1) -#define SID_VERB_START (SID_MACRO_END + 2) -#define SID_VERB_END (SID_MACRO_END + 21) +#define SID_EVENTCONFIG (SID_SFX_START + 1101) +#define SID_VERB_START (SID_SFX_START + 1100) +#define SID_VERB_END (SID_SFX_START + 1121) #define SID_BROWSER_TASK (SID_MACRO_END + 22) diff --git a/sfx2/inc/sfx2/shell.hxx b/sfx2/inc/sfx2/shell.hxx index 314c16fdbf1f..4d93a7b422aa 100644 --- a/sfx2/inc/sfx2/shell.hxx +++ b/sfx2/inc/sfx2/shell.hxx @@ -65,12 +65,16 @@ class SfxShellSubObject; class SfxDispatcher; class SfxViewFrame; class SfxSlot; -class SfxUndoManager; class SfxRepeatTarget; class SbxVariable; class SbxBase; class SfxBindings; +namespace svl +{ + class IUndoManager; +} + //==================================================================== enum SfxInterfaceId @@ -162,7 +166,7 @@ class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster SfxShell_Impl* pImp; SfxItemPool* pPool; - SfxUndoManager* pUndoMgr; + ::svl::IUndoManager* pUndoMgr; private: SfxShell( const SfxShell & ); // n.i. @@ -212,8 +216,9 @@ public: inline SfxItemPool& GetPool() const; inline void SetPool( SfxItemPool *pNewPool ) ; - virtual SfxUndoManager* GetUndoManager(); - void SetUndoManager( SfxUndoManager *pNewUndoMgr ); + virtual ::svl::IUndoManager* + GetUndoManager(); + void SetUndoManager( ::svl::IUndoManager *pNewUndoMgr ); SfxRepeatTarget* GetRepeatTarget() const; void SetRepeatTarget( SfxRepeatTarget *pTarget ); diff --git a/sfx2/inc/sfx2/viewsh.hxx b/sfx2/inc/sfx2/viewsh.hxx index b58a9e7bdf73..5a032af30050 100644 --- a/sfx2/inc/sfx2/viewsh.hxx +++ b/sfx2/inc/sfx2/viewsh.hxx @@ -59,7 +59,6 @@ class SfxItemPool; class SfxTabPage; class SfxPrintMonitor; class SfxFrameSetDescriptor; -class PrintDialog; class Printer; class SfxPrinter; class SfxProgress; @@ -215,6 +214,7 @@ public: virtual String GetSelectionText( BOOL bCompleteWords = FALSE ); virtual BOOL HasSelection( BOOL bText = TRUE ) const; virtual SdrView* GetDrawView() const; + void SetSubShell( SfxShell *pShell ); SfxShell* GetSubShell() const { return pSubShell; } void AddSubShell( SfxShell& rShell ); @@ -239,13 +239,9 @@ public: void AdjustVisArea(const Rectangle& rRect); // Printing Interface - virtual void PreparePrint( PrintDialog *pPrintDialog = 0 ); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ); - virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 ); virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=FALSE ); virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ); - virtual PrintDialog* CreatePrintDialog( Window *pParent ); void LockPrinter( BOOL bLock = TRUE ); BOOL IsPrinterLocked() const; virtual JobSetup GetJobSetup() const; diff --git a/sfx2/prj/build.lst b/sfx2/prj/build.lst index f8fddef145a6..dc0b094ac4fb 100644 --- a/sfx2/prj/build.lst +++ b/sfx2/prj/build.lst @@ -1,11 +1,5 @@ -sf sfx2 : l10n idl basic xmlscript framework readlicense_oo shell setup_native sax SYSTRAY_GTK:libegg LIBXML2:libxml2 LIBXSLT:libxslt NULL -sf sfx2 usr1 - all sf_mkout NULL -sf sfx2\prj nmake - all sf_prj NULL - - -# fails on unxsoli4 -# sf sfx2\qa\complex\standalonedocumentinfo nmake - all sf_qa_complex_standalonedocumentinfo sf_util NULL - -# sf sfx2\qa\complex\framework nmake - all sf_qa_complex_framework sf_qa_complex_framework_dochelper NULL -# sf sfx2\qa\complex\docinfo nmake - all sf_qa_complex_docinfo sf_util NULL - +sf sfx2 : l10n idl basic xmlscript framework readlicense_oo shell setup_native sax SYSTRAY_GTK:libegg LIBXML2:libxml2 LIBXSLT:libxslt test NULL +sf sfx2 usr1 - all sf_mkout NULL +sf sfx2\prj nmake - all sf_prj NULL +sf sfx2\qa\cppunit nmake - all sf_qa_cppunit NULL +sf sfx2\qa\unoapi nmake - all sf_qa_unoapi NULL diff --git a/sfx2/qa/complex/docinfo/DocumentProperties.java b/sfx2/qa/complex/sfx2/DocumentInfo.java index 0c4eb44c4a35..ca7ae8b1dda0 100644 --- a/sfx2/qa/complex/docinfo/DocumentProperties.java +++ b/sfx2/qa/complex/sfx2/DocumentInfo.java @@ -24,9 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.docinfo; +package complex.sfx2; -import com.sun.star.beans.*; +import com.sun.star.beans.PropertyAttribute; import com.sun.star.beans.Property; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertyContainer; @@ -49,22 +49,17 @@ import util.WriterTools; import org.junit.After; import org.junit.AfterClass; -// import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; import static org.junit.Assert.*; -public class DocumentProperties +public class DocumentInfo { - XMultiServiceFactory m_xMSF = null; XTextDocument xTextDoc = null; XTextDocument xTextDocSecond = null; -// public String[] getTestMethodNames() { -// return new String[] {"checkDocInfo", "cleanup"}; -// } @Test public void checkDocInfo() { m_xMSF = getMSF(); @@ -349,14 +344,18 @@ public class DocumentProperties // setup and close connections @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "starting class: " + DocumentInfo.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.setUp(); } @AfterClass public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception { - System.out.println("tearDownConnection()"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "finishing class: " + DocumentInfo.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.tearDown(); } private static final OfficeConnection connection = new OfficeConnection(); diff --git a/sfx2/qa/complex/framework/DocumentMetadataAccessTest.java b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java index 3f61cb21b3dd..d145b9028473 100644 --- a/sfx2/qa/complex/framework/DocumentMetadataAccessTest.java +++ b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java @@ -25,9 +25,27 @@ * ************************************************************************/ -package complex.framework; +package complex.sfx2; // import complexlib.ComplexTestCase; +import com.sun.star.beans.Pair; +import com.sun.star.rdf.Literal; +import com.sun.star.rdf.XLiteral; +import com.sun.star.rdf.XNamedGraph; +import com.sun.star.rdf.BlankNode; +import com.sun.star.rdf.XQuerySelectResult; +import com.sun.star.rdf.XNode; +import com.sun.star.rdf.XDocumentRepository; +import com.sun.star.rdf.XMetadatable; +import com.sun.star.rdf.Statement; +import com.sun.star.rdf.FileFormat; +import com.sun.star.rdf.URIs; +import com.sun.star.rdf.URI; +import com.sun.star.rdf.XDocumentMetadataAccess; +import com.sun.star.rdf.XRepositorySupplier; +import com.sun.star.rdf.XRepository; +import com.sun.star.rdf.XBlankNode; +import com.sun.star.rdf.XURI; import helper.StreamSimulator; import com.sun.star.uno.UnoRuntime; @@ -41,7 +59,6 @@ import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.WrappedTargetRuntimeException; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.Pair; import com.sun.star.beans.StringPair; import com.sun.star.container.XEnumerationAccess; import com.sun.star.container.XEnumeration; @@ -51,7 +68,7 @@ import com.sun.star.frame.XStorable; import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextRange; import com.sun.star.text.XText; -import com.sun.star.rdf.*; +import complex.sfx2.tools.TestDocument; import lib.TestParameters; @@ -73,7 +90,7 @@ import static org.junit.Assert.*; * * @author mst */ -public class DocumentMetadataAccessTest +public class DocumentMetadataAccess { XMultiServiceFactory xMSF; XComponentContext xContext; @@ -196,22 +213,22 @@ public class DocumentMetadataAccessTest PropertyValue[] loadProps = new PropertyValue[1]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; - loadProps[0].Value = new Boolean(true); + loadProps[0].Value = true; xComp = util.DesktopTools.openNewDoc(xMSF, "swriter", loadProps); XTextDocument xText = UnoRuntime.queryInterface(XTextDocument.class, xComp); - XRepositorySupplier xRS = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); - assertNotNull("xRS null", xRS); - XDocumentMetadataAccess xDMA = UnoRuntime.queryInterface(XDocumentMetadataAccess.class, xRS); - assertNotNull("xDMA null", xDMA); - xRep = xRS.getRDFRepository(); + XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); + assertNotNull("xRS null", xRepoSupplier); + XDocumentMetadataAccess xDocMDAccess = UnoRuntime.queryInterface(XDocumentMetadataAccess.class, xRepoSupplier); + assertNotNull("xDMA null", xDocMDAccess); + xRep = xRepoSupplier.getRDFRepository(); assertNotNull("xRep null", xRep); System.out.println("...done"); System.out.println("Checking that new repository is initialized..."); - XURI xBaseURI = (XURI) xDMA; + XURI xBaseURI = (XURI) xDocMDAccess; String baseURI = xBaseURI.getStringValue(); assertNotNull("new: baseURI", xBaseURI ); assertTrue("new: baseURI", !xBaseURI.getStringValue().equals("")); @@ -235,79 +252,79 @@ public class DocumentMetadataAccessTest XMetadatable xM = (XMetadatable) xTR; try { - xDMA.getElementByURI(null); + xDocMDAccess.getElementByURI(null); fail("getElementByURI: null allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.getMetadataGraphsWithType(null); + xDocMDAccess.getMetadataGraphsWithType(null); fail("getMetadataGraphsWithType: null URI allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("", new XURI[0]); + xDocMDAccess.addMetadataFile("", new XURI[0]); fail("addMetadataFile: empty filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("/foo", new XURI[0]); + xDocMDAccess.addMetadataFile("/foo", new XURI[0]); fail("addMetadataFile: absolute filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("fo\"o", new XURI[0]); + xDocMDAccess.addMetadataFile("fo\"o", new XURI[0]); fail("addMetadataFile: invalid filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("../foo", new XURI[0]); + xDocMDAccess.addMetadataFile("../foo", new XURI[0]); fail("addMetadataFile: filename with .. allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("foo/../../bar", new XURI[0]); + xDocMDAccess.addMetadataFile("foo/../../bar", new XURI[0]); fail("addMetadataFile: filename with nest .. allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("foo/././bar", new XURI[0]); + xDocMDAccess.addMetadataFile("foo/././bar", new XURI[0]); fail("addMetadataFile: filename with nest . allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("content.xml", new XURI[0]); + xDocMDAccess.addMetadataFile("content.xml", new XURI[0]); fail("addMetadataFile: content.xml allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("styles.xml", new XURI[0]); + xDocMDAccess.addMetadataFile("styles.xml", new XURI[0]); fail("addMetadataFile: styles.xml allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("meta.xml", new XURI[0]); + xDocMDAccess.addMetadataFile("meta.xml", new XURI[0]); fail("addMetadataFile: meta.xml allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addMetadataFile("settings.xml", new XURI[0]); + xDocMDAccess.addMetadataFile("settings.xml", new XURI[0]); fail("addMetadataFile: settings.xml allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.importMetadataFile(FileFormat.RDF_XML, null, "foo", + xDocMDAccess.importMetadataFile(FileFormat.RDF_XML, null, "foo", foo, new XURI[0]); fail("importMetadataFile: null stream allowed"); } catch (IllegalArgumentException e) { @@ -317,7 +334,7 @@ public class DocumentMetadataAccessTest final String sEmptyRDF = TestDocument.getUrl("empty.rdf"); try { XInputStream xFooIn = new StreamSimulator(sEmptyRDF, true, param); - xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "", + xDocMDAccess.importMetadataFile(FileFormat.RDF_XML, xFooIn, "", foo, new XURI[0]); fail("importMetadataFile: empty filename allowed"); } catch (IllegalArgumentException e) { @@ -326,7 +343,7 @@ public class DocumentMetadataAccessTest try { XInputStream xFooIn = new StreamSimulator(sEmptyRDF, true, param); - xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "meta.xml", + xDocMDAccess.importMetadataFile(FileFormat.RDF_XML, xFooIn, "meta.xml", foo, new XURI[0]); fail("importMetadataFile: meta.xml filename allowed"); } catch (IllegalArgumentException e) { @@ -335,7 +352,7 @@ public class DocumentMetadataAccessTest try { XInputStream xFooIn = new StreamSimulator(sEmptyRDF, true, param); - xDMA.importMetadataFile(FileFormat.RDF_XML, + xDocMDAccess.importMetadataFile(FileFormat.RDF_XML, xFooIn, "foo", null, new XURI[0]); fail("importMetadataFile: null base URI allowed"); } catch (IllegalArgumentException e) { @@ -344,62 +361,62 @@ public class DocumentMetadataAccessTest try { XInputStream xFooIn = new StreamSimulator(sEmptyRDF, true, param); - xDMA.importMetadataFile(FileFormat.RDF_XML, + xDocMDAccess.importMetadataFile(FileFormat.RDF_XML, xFooIn, "foo", rdf_type, new XURI[0]); fail("importMetadataFile: non-absolute base URI allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.removeMetadataFile(null); + xDocMDAccess.removeMetadataFile(null); fail("removeMetadataFile: null URI allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addContentOrStylesFile(""); + xDocMDAccess.addContentOrStylesFile(""); fail("addContentOrStylesFile: empty filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addContentOrStylesFile("/content.xml"); + xDocMDAccess.addContentOrStylesFile("/content.xml"); fail("addContentOrStylesFile: absolute filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.addContentOrStylesFile("foo.rdf"); + xDocMDAccess.addContentOrStylesFile("foo.rdf"); fail("addContentOrStylesFile: invalid filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.removeContentOrStylesFile(""); + xDocMDAccess.removeContentOrStylesFile(""); fail("removeContentOrStylesFile: empty filename allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.loadMetadataFromStorage(null, foo, null); + xDocMDAccess.loadMetadataFromStorage(null, foo, null); fail("loadMetadataFromStorage: null storage allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.storeMetadataToStorage(null/*, base*/); + xDocMDAccess.storeMetadataToStorage(null/*, base*/); fail("storeMetadataToStorage: null storage allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.loadMetadataFromMedium(new PropertyValue[0]); + xDocMDAccess.loadMetadataFromMedium(new PropertyValue[0]); fail("loadMetadataFromMedium: empty medium allowed"); } catch (IllegalArgumentException e) { // ignore } try { - xDMA.storeMetadataToMedium(new PropertyValue[0]); + xDocMDAccess.storeMetadataToMedium(new PropertyValue[0]); fail("storeMetadataToMedium: empty medium allowed"); } catch (IllegalArgumentException e) { // ignore @@ -409,26 +426,26 @@ public class DocumentMetadataAccessTest System.out.println("Checking file addition/removal..."); - xDMA.removeContentOrStylesFile(contentPath); + xDocMDAccess.removeContentOrStylesFile(contentPath); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("removeContentOrStylesFile (content)", eq(xStmtsEnum, new Statement[] { manifestStmts[0], manifestStmts[2], manifestStmts[4] })); - xDMA.addContentOrStylesFile(contentPath); + xDocMDAccess.addContentOrStylesFile(contentPath); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("addContentOrStylesFile (content)", eq(xStmtsEnum, manifestStmts)); - xDMA.removeContentOrStylesFile(stylesPath); + xDocMDAccess.removeContentOrStylesFile(stylesPath); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("removeContentOrStylesFile (styles)", eq(xStmtsEnum, new Statement[] { manifestStmts[0], manifestStmts[1], manifestStmts[3] })); - xDMA.addContentOrStylesFile(stylesPath); + xDocMDAccess.addContentOrStylesFile(stylesPath); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("addContentOrStylesFile (styles)", eq(xStmtsEnum, manifestStmts)); @@ -441,19 +458,19 @@ public class DocumentMetadataAccessTest new Statement(xFoo, rdf_type, pkg_MetadataFile, manifest); Statement xM_FooTypeBar = new Statement(xFoo, rdf_type, bar, manifest); - xDMA.addMetadataFile(fooPath, new XURI[] { bar }); + xDocMDAccess.addMetadataFile(fooPath, new XURI[] { bar }); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("addMetadataFile", eq(xStmtsEnum, merge(manifestStmts, new Statement[] { xM_BaseHaspartFoo, xM_FooTypeMetadata, xM_FooTypeBar }))); - XURI[] graphsBar = xDMA.getMetadataGraphsWithType(bar); + XURI[] graphsBar = xDocMDAccess.getMetadataGraphsWithType(bar); assertTrue("getMetadataGraphsWithType", graphsBar.length == 1 && eq(graphsBar[0], xFoo)); - xDMA.removeMetadataFile(xFoo); + xDocMDAccess.removeMetadataFile(xFoo); xStmtsEnum = xManifest.getStatements(null, null, null); assertTrue("removeMetadataFile", eq(xStmtsEnum, manifestStmts)); @@ -468,7 +485,7 @@ public class DocumentMetadataAccessTest XURI uri; XMetadatable xMeta; - xMeta = xDMA.getElementByURI(xMeta1); + xMeta = xDocMDAccess.getElementByURI(xMeta1); assertTrue("getElementByURI: null", null != xMeta); String XmlId = xMeta.getMetadataReference().Second; String XmlId1 = xMeta1.getMetadataReference().Second; @@ -483,7 +500,7 @@ public class DocumentMetadataAccessTest fooBarPath); Statement[] metadataStmts = getMetadataFileStmts(xBaseURI, fooBarPath); - xDMA.addMetadataFile(fooBarPath, new XURI[0]); + xDocMDAccess.addMetadataFile(fooBarPath, new XURI[0]); xStmtsEnum = xRep.getStatements(null, null, null); assertTrue("addMetadataFile", eq(xStmtsEnum, merge(manifestStmts, metadataStmts ))); @@ -520,15 +537,15 @@ public class DocumentMetadataAccessTest xStmtsEnum = xRep.getStatements(null, null, null); XURI[] graphs = xRep.getGraphNames(); - xDMA.storeMetadataToMedium(args); + xDocMDAccess.storeMetadataToMedium(args); // this should re-init - xDMA.loadMetadataFromMedium(argsEmptyNoContent); - xRep = xRS.getRDFRepository(); + xDocMDAccess.loadMetadataFromMedium(argsEmptyNoContent); + xRep = xRepoSupplier.getRDFRepository(); assertTrue("xRep null", null != xRep); assertTrue("baseURI still tdoc?", - !baseURI.equals(xDMA.getStringValue())); - Statement[] manifestStmts2 = getManifestStmts((XURI) xDMA); + !baseURI.equals(xDocMDAccess.getStringValue())); + Statement[] manifestStmts2 = getManifestStmts((XURI) xDocMDAccess); xStmtsEnum = xRep.getStatements(null, null, null); // there is no content or styles file in here, so we have just // the package stmt @@ -536,29 +553,29 @@ public class DocumentMetadataAccessTest eq(xStmtsEnum, new Statement[] { manifestStmts2[0] })); // this should re-init - xDMA.loadMetadataFromMedium(argsEmpty); - xRep = xRS.getRDFRepository(); + xDocMDAccess.loadMetadataFromMedium(argsEmpty); + xRep = xRepoSupplier.getRDFRepository(); assertTrue("xRep null", null != xRep); assertTrue("baseURI still tdoc?", - !baseURI.equals(xDMA.getStringValue())); - Statement[] manifestStmts3 = getManifestStmts((XURI) xDMA); + !baseURI.equals(xDocMDAccess.getStringValue())); + Statement[] manifestStmts3 = getManifestStmts((XURI) xDocMDAccess); xStmtsEnum = xRep.getStatements(null, null, null); assertTrue("loadMetadataFromMedium (no metadata)", eq(xStmtsEnum, manifestStmts3)); - xDMA.loadMetadataFromMedium(args); - xRep = xRS.getRDFRepository(); + xDocMDAccess.loadMetadataFromMedium(args); + xRep = xRepoSupplier.getRDFRepository(); assertTrue("xRep null", null != xRep); - Statement[] manifestStmts4 = getManifestStmts((XURI) xDMA); - Statement[] metadataStmts4 = getMetadataFileStmts((XURI) xDMA, + Statement[] manifestStmts4 = getManifestStmts((XURI) xDocMDAccess); + Statement[] metadataStmts4 = getMetadataFileStmts((XURI) xDocMDAccess, fooBarPath); xStmtsEnum = xRep.getStatements(null, null, null); assertTrue("some graph(s) not reloaded", graphs.length == xRep.getGraphNames().length); - XURI xFoobar4 = URI.createNS(xContext, xDMA.getStringValue(), + XURI xFoobar4 = URI.createNS(xContext, xDocMDAccess.getStringValue(), fooBarPath); Statement xFoobar_FooBarFoo4 = new Statement(foo, bar, foo, xFoobar4); @@ -572,7 +589,7 @@ public class DocumentMetadataAccessTest String f = tempDir + "TESTPARA.odt"; - XStorable xStor = UnoRuntime.queryInterface(XStorable.class, xRS); + XStorable xStor = UnoRuntime.queryInterface(XStorable.class, xRepoSupplier); xStor.storeToURL(f, new PropertyValue[0]); @@ -656,17 +673,17 @@ public class DocumentMetadataAccessTest PropertyValue[] loadProps = new PropertyValue[1]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; - loadProps[0].Value = new Boolean(true); + loadProps[0].Value = true; xComp = util.DesktopTools.loadDoc(xMSF, file, loadProps); - XRepositorySupplier xRS = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); - assertTrue("xRS null", null != xRS); + XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); + assertTrue("xRS null", null != xRepoSupplier); - XDocumentRepository xRep = UnoRuntime.queryInterface(XDocumentRepository.class, xRS.getRDFRepository()); - assertTrue("xRep null", null != xRep); + XDocumentRepository xDocRepository = UnoRuntime.queryInterface(XDocumentRepository.class, xRepoSupplier.getRDFRepository()); + assertTrue("xRep null", null != xDocRepository); XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp); @@ -684,7 +701,7 @@ public class DocumentMetadataAccessTest Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 1", !result.Second && eq(result.First, new Statement[] { @@ -693,7 +710,7 @@ public class DocumentMetadataAccessTest Statement x_FooBarLit2 = new Statement(foo, bar, mkLit("2"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 2", !result.Second && eq(result.First, new Statement[] { @@ -703,7 +720,7 @@ public class DocumentMetadataAccessTest Statement x_BlankBarLit3 = new Statement(blank1, bar, mkLit("3"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 3", !result.Second && eq(result.First, new Statement[] { @@ -714,7 +731,7 @@ public class DocumentMetadataAccessTest Statement x_BlankBarLit4 = new Statement(blank2, bar, mkLit("4"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 4", !result.Second && eq(result.First, new Statement[] { @@ -725,7 +742,7 @@ public class DocumentMetadataAccessTest Statement x_BlankBarLit5 = new Statement(blank1, bar, mkLit("5"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 5", !result.Second && eq(result.First, new Statement[] { @@ -741,7 +758,7 @@ public class DocumentMetadataAccessTest Statement x_FooBarLit6 = new Statement(foo, bar, mkLit("6"), null); Statement x_FooBazLit6 = new Statement(foo, baz, mkLit("6"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 6", !result.Second && eq(result.First, new Statement[] { @@ -752,7 +769,7 @@ public class DocumentMetadataAccessTest Statement x_FooBazLit7 = new Statement(foo, baz, mkLit("7"), null); Statement x_FooFooLit7 = new Statement(foo, foo, mkLit("7"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 7", !result.Second && eq(result.First, new Statement[] { @@ -765,7 +782,7 @@ public class DocumentMetadataAccessTest Statement x_FooBarLittype = new Statement(foo, bar, lit_type, null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 8", result.Second && eq(result.First, new Statement[] { @@ -773,7 +790,7 @@ public class DocumentMetadataAccessTest })); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 9", result.Second && eq(result.First, new Statement[] { @@ -781,7 +798,7 @@ public class DocumentMetadataAccessTest })); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 10", result.Second && eq(result.First, new Statement[] { @@ -791,7 +808,7 @@ public class DocumentMetadataAccessTest Statement x_FooBarLit11 = new Statement(foo, bar, mkLit("11", bar), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 11", !result.Second && eq(result.First, new Statement[] { @@ -802,7 +819,7 @@ public class DocumentMetadataAccessTest Statement x_FileBarLit12 = new Statement(xFile, bar, mkLit("12"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 12", !result.Second && eq(result.First, new Statement[] { @@ -810,7 +827,7 @@ public class DocumentMetadataAccessTest })); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 13", result.Second && eq(result.First, new Statement[] { @@ -820,7 +837,7 @@ public class DocumentMetadataAccessTest Statement x_FooLabelLit14 = new Statement(foo, rdfs_label, mkLit("14"), null); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 14", result.Second && eq(result.First, new Statement[] { @@ -828,33 +845,33 @@ public class DocumentMetadataAccessTest })); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 15", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 16", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 17", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 18", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 19", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface( XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 20", eq(result.First, new Statement[] { } )); xPara = UnoRuntime.queryInterface( XMetadatable.class, xEnum.nextElement()); - result = xRep.getStatementRDFa(xPara); + result = xDocRepository.getStatementRDFa(xPara); assertTrue("RDFa: 21", eq(result.First, new Statement[] { } )); System.out.println("...done"); @@ -889,7 +906,7 @@ public class DocumentMetadataAccessTest public void report(Exception e) { System.out.println("Exception occurred:"); - e.printStackTrace(); + e.printStackTrace(System.out); report2(e); fail(); } @@ -1275,14 +1292,18 @@ public class DocumentMetadataAccessTest // setup and close connections @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "starting class: " + DocumentMetadataAccess.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.setUp(); } @AfterClass public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception { - System.out.println("tearDownConnection() DocumentMetadataAccessTest"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "finishing class: " + DocumentMetadataAccess.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.tearDown(); } diff --git a/sfx2/qa/complex/framework/DocumentPropertiesTest.java b/sfx2/qa/complex/sfx2/DocumentProperties.java index 20a0746c8322..01ccaa21619b 100644 --- a/sfx2/qa/complex/framework/DocumentPropertiesTest.java +++ b/sfx2/qa/complex/sfx2/DocumentProperties.java @@ -25,9 +25,10 @@ * ************************************************************************/ -package complex.framework; +package complex.sfx2; +import complex.sfx2.tools.TestDocument; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.lang.XInitialization; @@ -53,7 +54,6 @@ import com.sun.star.document.XDocumentProperties; import org.junit.After; import org.junit.AfterClass; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; @@ -66,12 +66,8 @@ import static org.junit.Assert.*; * * @author mst */ -public class DocumentPropertiesTest +public class DocumentProperties { -// public String[] getTestMethodNames () { -// return new String[] { "check", "cleanup" }; -// } - @After public void cleanup() { // nothing to do } @@ -80,7 +76,7 @@ public class DocumentPropertiesTest class Listener implements XModifyListener { private boolean m_Called; - public Listener() { + Listener() { m_Called = false; } @@ -235,8 +231,7 @@ public class DocumentPropertiesTest new NamedValue("PageCount", new Integer(1)))); XPropertyContainer udpc = xDP.getUserDefinedProperties(); - XPropertySet udps = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, udpc); + XPropertySet udps = UnoRuntime.queryInterface( XPropertySet.class, udpc ); assertTrue("UserDefined 1", "Dies ist ein wichtiger Hinweis" .equals(udps.getPropertyValue("Hinweis"))); assertTrue("UserDefined 2", ("Kann Spuren von N" @@ -366,8 +361,7 @@ public class DocumentPropertiesTest dur.Seconds = 555; dur.MilliSeconds = 444; - udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE, - new Boolean(b)); + udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE, b); udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, dur); udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVEABLE, t); udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVEABLE, date); @@ -433,8 +427,7 @@ public class DocumentPropertiesTest System.out.println("Checking user-defined meta-data from stored file..."); udpc = xDP.getUserDefinedProperties(); - udps = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, udpc); + udps = UnoRuntime.queryInterface( XPropertySet.class, udpc ); assertTrue("UserDefined bool", new Boolean(b).equals( udps.getPropertyValue("Frobnicate"))); @@ -467,8 +460,7 @@ public class DocumentPropertiesTest System.out.println("Checking notification listener interface..."); Listener listener = new Listener(); - XModifyBroadcaster xMB = (XModifyBroadcaster) - UnoRuntime.queryInterface(XModifyBroadcaster.class, xDP); + XModifyBroadcaster xMB = UnoRuntime.queryInterface( XModifyBroadcaster.class, xDP ); xMB.addModifyListener(listener); xDP.setAuthor("not me"); assertTrue("Listener Author", listener.reset()); @@ -542,20 +534,24 @@ public class DocumentPropertiesTest private XMultiServiceFactory getMSF() { - final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface( XMultiServiceFactory.class, connection.getComponentContext().getServiceManager() ); return xMSF1; } // setup and close connections @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "starting class: " + DocumentProperties.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.setUp(); } @AfterClass public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception { - System.out.println("tearDownConnection() DocumentPropertiesTest"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "finishing class: " + DocumentProperties.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.tearDown(); } diff --git a/sfx2/qa/complex/framework/CheckGlobalEventBroadcaster_writer1.java b/sfx2/qa/complex/sfx2/GlobalEventBroadcaster.java index c6dc073095b1..41bd66ccb5b9 100644 --- a/sfx2/qa/complex/framework/CheckGlobalEventBroadcaster_writer1.java +++ b/sfx2/qa/complex/sfx2/GlobalEventBroadcaster.java @@ -24,7 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.framework; +package complex.sfx2; import com.sun.star.awt.XWindow; import com.sun.star.document.XEventBroadcaster; @@ -33,7 +33,7 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sheet.XSpreadsheetDocument; import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; -import complex.framework.DocHelper.WriterHelper; +import complex.sfx2.tools.WriterHelper; import java.util.ArrayList; @@ -53,7 +53,7 @@ import static org.junit.Assert.*; * it will add an XEventListener and verify the Events * raised when opening/changing and closing Office Documents */ -public class CheckGlobalEventBroadcaster_writer1 { +public class GlobalEventBroadcaster { XMultiServiceFactory m_xMSF = null; XEventBroadcaster m_xEventBroadcaster = null; ArrayList notifyEvents = new ArrayList(); @@ -61,12 +61,6 @@ public class CheckGlobalEventBroadcaster_writer1 { XSpreadsheetDocument xSheetDoc; XEventListener m_xEventListener = new EventListenerImpl(); -// public String[] getTestMethodNames() { -// return new String[] { -// "initialize", "checkWriter", "cleanup" -// }; -// } - @Before public void initialize() { m_xMSF = getMSF(); System.out.println("check wether there is a valid MultiServiceFactory"); @@ -79,7 +73,6 @@ public class CheckGlobalEventBroadcaster_writer1 { "Create an instance of com.sun.star.frame.GlobalEventBroadcaster"); Object GlobalEventBroadcaster = null; - Object dispatcher = null; try { GlobalEventBroadcaster = m_xMSF.createInstance( @@ -116,7 +109,6 @@ public class CheckGlobalEventBroadcaster_writer1 { WriterHelper wHelper = new WriterHelper(m_xMSF); String[] expected; - boolean locRes = true; System.out.println("opening an empty writer doc"); notifyEvents.clear(); { diff --git a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoUnitTest.java b/sfx2/qa/complex/sfx2/StandaloneDocumentInfo.java index 29fcaba8cb7a..1e9cbb1f4738 100644 --- a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoUnitTest.java +++ b/sfx2/qa/complex/sfx2/StandaloneDocumentInfo.java @@ -24,10 +24,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.standalonedocumentinfo; +package complex.sfx2; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; +import complex.sfx2.standalonedocinfo.StandaloneDocumentInfoTest; +import complex.sfx2.standalonedocinfo.Test01; import org.junit.After; import org.junit.AfterClass; @@ -40,18 +42,9 @@ import static org.junit.Assert.*; /* Document here */ -public class StandaloneDocumentInfoUnitTest { +public class StandaloneDocumentInfo { private XMultiServiceFactory m_xMSF = null; -// public String[] getTestMethodNames() { -// return new String[] { -// "ExecuteTest01"}; -// } - -// public String[] getTestObjectNames() { -// return new String[] {"StandaloneDocumentInfoUnitTest"}; -// } - @Before public void before() { try { m_xMSF = getMSF(); @@ -82,15 +75,20 @@ public class StandaloneDocumentInfoUnitTest { } // setup and close connections - @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); + @BeforeClass public static void setUpConnection() throws Exception + { + System.out.println( "------------------------------------------------------------" ); + System.out.println( "starting class: " + StandaloneDocumentInfo.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.setUp(); } @AfterClass public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception { - System.out.println("tearDownConnection()"); + System.out.println( "------------------------------------------------------------" ); + System.out.println( "finishing class: " + StandaloneDocumentInfo.class.getName() ); + System.out.println( "------------------------------------------------------------" ); connection.tearDown(); } diff --git a/sfx2/qa/complex/sfx2/UndoManager.java b/sfx2/qa/complex/sfx2/UndoManager.java new file mode 100755 index 000000000000..ab1b9de910b8 --- /dev/null +++ b/sfx2/qa/complex/sfx2/UndoManager.java @@ -0,0 +1,1464 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.sfx2; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XChild; +import com.sun.star.container.XIndexContainer; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNameReplace; +import com.sun.star.container.XSet; +import com.sun.star.document.EmptyUndoStackException; +import com.sun.star.document.UndoContextNotClosedException; +import com.sun.star.document.UndoFailedException; +import com.sun.star.document.UndoManagerEvent; +import com.sun.star.document.XEmbeddedScripts; +import com.sun.star.document.XEventsSupplier; +import com.sun.star.document.XUndoAction; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.XEventListener; +import java.lang.reflect.InvocationTargetException; +import org.openoffice.test.tools.OfficeDocument; +import com.sun.star.document.XUndoManagerSupplier; +import com.sun.star.document.XUndoManager; +import com.sun.star.document.XUndoManagerListener; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.script.ScriptEventDescriptor; +import com.sun.star.script.XEventAttacherManager; +import com.sun.star.script.XLibraryContainer; +import com.sun.star.task.XJob; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.InvalidStateException; +import com.sun.star.util.NotLockedException; +import com.sun.star.view.XControlAccess; +import complex.sfx2.undo.CalcDocumentTest; +import complex.sfx2.undo.ChartDocumentTest; +import complex.sfx2.undo.DocumentTest; +import complex.sfx2.undo.DrawDocumentTest; +import complex.sfx2.undo.ImpressDocumentTest; +import complex.sfx2.undo.WriterDocumentTest; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Stack; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import org.openoffice.test.OfficeConnection; +import org.openoffice.test.tools.DocumentType; +import org.openoffice.test.tools.SpreadsheetDocument; + +/** + * Unit test for the UndoManager API + * + * @author frank.schoenheit@oracle.com + */ +public class UndoManager +{ + // ----------------------------------------------------------------------------------------------------------------- + @Before + public void beforeTest() throws com.sun.star.uno.Exception + { + m_currentTestCase = null; + m_currentDocument = null; + m_undoListener = null; + + // at our service factory, insert a new factory for our CallbackComponent + // this will allow the Basic code in our test documents to call back into this test case + // here, by just instantiating this service + final XSet globalFactory = UnoRuntime.queryInterface( XSet.class, getORB() ); + m_callbackFactory = new CallbackComponentFactory(); + globalFactory.insert( m_callbackFactory ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkWriterUndo() throws Exception + { + m_currentTestCase = new WriterDocumentTest( getORB() ); + impl_checkUndo(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkCalcUndo() throws Exception + { + m_currentTestCase = new CalcDocumentTest( getORB() ); + impl_checkUndo(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkDrawUndo() throws Exception + { + m_currentTestCase = new DrawDocumentTest( getORB() ); + impl_checkUndo(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkImpressUndo() throws Exception + { + m_currentTestCase = new ImpressDocumentTest( getORB() ); + impl_checkUndo(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkChartUndo() throws Exception + { + m_currentTestCase = new ChartDocumentTest( getORB() ); + impl_checkUndo(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkBrokenScripts() throws com.sun.star.uno.Exception, InterruptedException + { + System.out.println( "testing: broken scripts" ); + + m_currentDocument = OfficeDocument.blankDocument( getORB(), DocumentType.CALC ); + m_undoListener = new UndoListener(); + getUndoManager().addUndoManagerListener( m_undoListener ); + + impl_setupBrokenBasicScript(); + final String scriptURI = "vnd.sun.star.script:default.callbacks.brokenScript?language=Basic&location=document"; + + // ............................................................................................................. + // scenario 1: Pressing a button which is bound to execute the script + // (This is one of the many cases where SfxObjectShell::CallXScript is invoked) + + // set up the button + final XPropertySet buttonModel = impl_setupButton(); + buttonModel.setPropertyValue( "Label", "exec broken script" ); + impl_assignScript( buttonModel, "XActionListener", "actionPerformed", + scriptURI ); + + // switch the doc's view to form alive mode (so the button will actually work) + m_currentDocument.getCurrentView().dispatch( ".uno:SwitchControlDesignMode" ); + + // click the button + m_callbackCalled = false; + impl_clickButton( buttonModel ); + // the macro is executed asynchronously by the button, so wait at most 2 seconds for the callback to be + // triggered + impl_waitFor( m_callbackCondition, 2000 ); + // check the callback has actually been called + assertTrue( "clicking the test button did not work as expected - basic script not called", m_callbackCalled ); + + // again, since the script is executed asynchronously, we might arrive here while its execution + // is not completely finished. Give OOo another (at most) 2 seconds to finish it. + m_undoListener.waitForAllContextsClosed( 20000 ); + // assure that the Undo Context Depth of the doc is still "0": The Basic script entered such a + // context, and didn't close it (thus it is broken), but the application framework should have + // auto-closed the context after the macro finished. + assertEquals( "undo context was not auto-closed as expected", 0, m_undoListener.getCurrentUndoContextDepth() ); + + // ............................................................................................................. + // scenario 2: dispatching the script URL. Technically, this is equivalent to configuring the + // script into a menu or toolbar, and selecting the respective menu/toolbar item + m_callbackCalled = false; + m_currentDocument.getCurrentView().dispatch( scriptURI ); + assertTrue( "dispatching the Script URL did not work as expected - basic script not called", m_callbackCalled ); + // same as above: The script didn't close the context, but the OOo framework should have + assertEquals( "undo context was not auto-closed as expected", 0, m_undoListener.getCurrentUndoContextDepth() ); + + // ............................................................................................................. + // scenario 3: assigning the script to some document event, and triggering this event + final XEventsSupplier eventSupplier = UnoRuntime.queryInterface( XEventsSupplier.class, m_currentDocument.getDocument() ); + final XNameReplace events = UnoRuntime.queryInterface( XNameReplace.class, eventSupplier.getEvents() ); + final NamedValue[] scriptDescriptor = new NamedValue[] { + new NamedValue( "EventType", "Script" ), + new NamedValue( "Script", scriptURI ) + }; + events.replaceByName( "OnViewCreated", scriptDescriptor ); + + // The below doesn't work: event notification is broken in m96, see http://www.openoffice.org/issues/show_bug.cgi?id=116313 +/* m_callbackCalled = false; + m_currentDocument.getCurrentView().dispatch( ".uno:NewWindow" ); + assertTrue( "triggering an event did not work as expected - basic script not called", m_callbackCalled ); + // same as above: The script didn't close the context, but the OOo framework should have + assertEquals( "undo context was not auto-closed as expected", 0, m_undoListener.getCurrentUndoContextDepth() ); + */ + + // ............................................................................................................. + // scenario 4: let the script enter an Undo context, but not close it, as usual. + // Additionally, let the script close the document - the OOo framework code which cares for + // auto-closing of Undo contexts should survive this, ideally ... + m_closeAfterCallback = true; + m_callbackCalled = false; + m_currentDocument.getCurrentView().dispatch( scriptURI ); + assertTrue( m_callbackCalled ); + assertTrue( "The Basic script should have closed the document.", m_undoListener.isDisposed() ); + m_currentDocument = null; + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void checkSerialization() throws com.sun.star.uno.Exception, InterruptedException + { + System.out.println( "testing: request serialization" ); + + m_currentDocument = OfficeDocument.blankDocument( getORB(), DocumentType.CALC ); + final XUndoManager undoManager = getUndoManager(); + + final int threadCount = 10; + final int actionsPerThread = 10; + final int actionCount = threadCount * actionsPerThread; + + // add some actions to the UndoManager, each knowing its position on the stack + final Object lock = new Object(); + final Integer actionsUndone[] = new Integer[] { 0 }; + for ( int i=actionCount; i>0; ) + undoManager.addUndoAction( new CountingUndoAction( --i, lock, actionsUndone ) ); + + // some concurrent threads which undo the actions + Thread[] threads = new Thread[threadCount]; + for ( int i=0; i<threadCount; ++i ) + { + threads[i] = new Thread() + { + @Override + public void run() + { + for ( int j=0; j<actionsPerThread; ++j ) + { + try { undoManager.undo(); } + catch ( final Exception e ) + { + fail( "Those dummy actions are not expected to fail." ); + return; + } + } + } + }; + } + + // start the threads + for ( int i=0; i<threadCount; ++i ) + threads[i].start(); + + // wait for them to be finished + for ( int i=0; i<threadCount; ++i ) + threads[i].join(); + + // ensure all actions have been undone + assertEquals( "not all actions have been undone", actionCount, actionsUndone[0].intValue() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @After + public void afterTest() + { + if ( m_currentTestCase != null ) + m_currentTestCase.closeDocument(); + else if ( m_currentDocument != null ) + m_currentDocument.close(); + m_currentTestCase = null; + m_currentDocument = null; + m_callbackFactory.dispose(); + } + + // ----------------------------------------------------------------------------------------------------------------- + /** + * returns the undo manager belonging to a given document + * @return + */ + private XUndoManager getUndoManager() + { + final XUndoManagerSupplier suppUndo = UnoRuntime.queryInterface( XUndoManagerSupplier.class, m_currentDocument.getDocument() ); + final XUndoManager undoManager = suppUndo.getUndoManager(); + assertTrue( UnoRuntime.areSame( undoManager.getParent(), m_currentDocument.getDocument() ) ); + return undoManager; + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_waitFor( final Object i_condition, final int i_milliSeconds ) throws InterruptedException + { + synchronized( i_condition ) + { + i_condition.wait( i_milliSeconds ); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_setupBrokenBasicScript() + { + try + { + final XEmbeddedScripts embeddedScripts = UnoRuntime.queryInterface( XEmbeddedScripts.class, m_currentDocument.getDocument() ); + final XLibraryContainer basicLibs = embeddedScripts.getBasicLibraries(); + final XNameContainer basicLib = basicLibs.createLibrary( "default" ); + + final String brokenScriptCode = + "Option Explicit\n" + + "\n" + + "Sub brokenScript\n" + + " Dim callback as Object\n" + + " ThisComponent.UndoManager.enterUndoContext( \"" + getCallbackUndoContextTitle() + "\" )\n" + + "\n" + + " callback = createUnoService( \"" + getCallbackComponentServiceName() + "\" )\n" + + " Dim emptyArgs() as new com.sun.star.beans.NamedValue\n" + + " Dim result as String\n" + + " result = callback.execute( emptyArgs() )\n" + + " If result = \"close\" Then\n" + + " ThisComponent.close( TRUE )\n" + + " End If\n" + + "End Sub\n" + + "\n"; + + basicLib.insertByName( "callbacks", brokenScriptCode ); + } + catch( com.sun.star.uno.Exception e ) + { + fail( "caught an exception while setting up the script: " + e.toString() ); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private XPropertySet impl_setupButton() throws com.sun.star.uno.Exception + { + // let the document create a shape + final XMultiServiceFactory docAsFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, + m_currentDocument.getDocument() ); + final XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, + docAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) ); + + // position and size of the shape + xShape.setSize( new Size( 28 * 100, 10 * 100 ) ); + xShape.setPosition( new Point( 10 * 100, 10 * 100 ) ); + + // create the form component (the model of a form control) + final String sQualifiedComponentName = "com.sun.star.form.component.CommandButton"; + final XControlModel controlModel = UnoRuntime.queryInterface( XControlModel.class, + getORB().createInstance( sQualifiedComponentName ) ); + + // knitt both + xShape.setControl( controlModel ); + + // add the shape to the shapes collection of the document + SpreadsheetDocument spreadsheetDoc = (SpreadsheetDocument)m_currentDocument; + final XDrawPageSupplier suppDrawPage = UnoRuntime.queryInterface( XDrawPageSupplier.class, + spreadsheetDoc.getSheet( 0 ) ); + final XDrawPage insertIntoPage = suppDrawPage.getDrawPage(); + + final XShapes sheetShapes = UnoRuntime.queryInterface( XShapes.class, insertIntoPage ); + sheetShapes.add( xShape ); + + return UnoRuntime.queryInterface( XPropertySet.class, controlModel ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_assignScript( final XPropertySet i_controlModel, final String i_interfaceName, + final String i_interfaceMethod, final String i_scriptURI ) + { + try + { + final XChild modelAsChild = UnoRuntime.queryInterface( XChild.class, i_controlModel ); + final XIndexContainer parentForm = UnoRuntime.queryInterface( XIndexContainer.class, modelAsChild.getParent() ); + + final XEventAttacherManager manager = UnoRuntime.queryInterface( XEventAttacherManager.class, parentForm ); + + int containerPosition = -1; + for ( int i = 0; i < parentForm.getCount(); ++i ) + { + final XPropertySet child = UnoRuntime.queryInterface( XPropertySet.class, parentForm.getByIndex( i ) ); + if ( UnoRuntime.areSame( child, i_controlModel ) ) + { + containerPosition = i; + break; + } + } + assertFalse( "could not find the given control model within its parent", containerPosition == -1 ); + manager.registerScriptEvent( containerPosition, new ScriptEventDescriptor( + i_interfaceName, + i_interfaceMethod, + "", + "Script", + i_scriptURI + ) ); + } + catch( com.sun.star.uno.Exception e ) + { + fail( "caught an exception while assigning the script event to the button: " + e.toString() ); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_clickButton( final XPropertySet i_buttonModel ) throws NoSuchElementException, IndexOutOfBoundsException + { + final XControlAccess controlAccess = UnoRuntime.queryInterface( XControlAccess.class, + m_currentDocument.getCurrentView().getController() ); + final XControl control = controlAccess.getControl( UnoRuntime.queryInterface( XControlModel.class, i_buttonModel ) ); + final XAccessible accessible = UnoRuntime.queryInterface( XAccessible.class, control ); + final XAccessibleAction controlActions = UnoRuntime.queryInterface( XAccessibleAction.class, accessible.getAccessibleContext() ); + for ( int i=0; i<controlActions.getAccessibleActionCount(); ++i ) + { + if ( controlActions.getAccessibleActionDescription(i).equals( "click" ) ) + { + controlActions.doAccessibleAction(i); + return; + } + } + fail( "did not find the accessible action named 'click'" ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private static class UndoListener implements XUndoManagerListener + { + public void undoActionAdded( UndoManagerEvent i_event ) + { + assertFalse( "|undoActionAdded| called after document was disposed", m_isDisposed ); + + ++m_undoActionsAdded; + m_mostRecentlyAddedAction = i_event.UndoActionTitle; + } + + public void actionUndone( UndoManagerEvent i_event ) + { + assertFalse( "|actionUndone| called after document was disposed", m_isDisposed ); + + ++m_undoCount; + m_mostRecentlyUndone = i_event.UndoActionTitle; + } + + public void actionRedone( UndoManagerEvent i_event ) + { + assertFalse( "|actionRedone| called after document was disposed", m_isDisposed ); + + ++m_redoCount; + } + + public void allActionsCleared( EventObject eo ) + { + assertFalse( "|allActionsCleared| called after document was disposed", m_isDisposed ); + + m_wasCleared = true; + } + + public void redoActionsCleared( EventObject eo ) + { + assertFalse( "|redoActionsCleared| called after document was disposed", m_isDisposed ); + + m_redoWasCleared = true; + } + + public void resetAll( EventObject i_event ) + { + assertFalse( "|resetAll| called after document was disposed", m_isDisposed ); + + m_managerWasReset = true; + m_activeUndoContexts.clear(); + } + + public void enteredContext( UndoManagerEvent i_event ) + { + assertFalse( "|enteredContext| called after document was disposed", m_isDisposed ); + + m_activeUndoContexts.push( i_event.UndoActionTitle ); + assertEquals( "different opinions on the context nesting level (after entering)", + m_activeUndoContexts.size(), i_event.UndoContextDepth ); + } + + public void enteredHiddenContext( UndoManagerEvent i_event ) + { + assertFalse( "|enteredHiddenContext| called after document was disposed", m_isDisposed ); + + m_activeUndoContexts.push( i_event.UndoActionTitle ); + assertEquals( "different opinions on the context nesting level (after entering hidden)", + m_activeUndoContexts.size(), i_event.UndoContextDepth ); + } + + public void leftContext( UndoManagerEvent i_event ) + { + assertFalse( "|leftContext| called after document was disposed", m_isDisposed ); + + assertEquals( "nested undo context descriptions do not match", m_activeUndoContexts.pop(), i_event.UndoActionTitle ); + assertEquals( "different opinions on the context nesting level (after leaving)", + m_activeUndoContexts.size(), i_event.UndoContextDepth ); + m_leftContext = true; + impl_notifyContextDepth(); + } + + public void leftHiddenContext( UndoManagerEvent i_event ) + { + assertFalse( "|leftHiddenContext| called after document was disposed", m_isDisposed ); + assertEquals( "|leftHiddenContext| is not expected to notify an action title", 0, i_event.UndoActionTitle.length() ); + + m_activeUndoContexts.pop(); + assertEquals( "different opinions on the context nesting level (after leaving)", + m_activeUndoContexts.size(), i_event.UndoContextDepth ); + m_leftHiddenContext = true; + impl_notifyContextDepth(); + } + + public void cancelledContext( UndoManagerEvent i_event ) + { + assertFalse( "|cancelledContext| called after document was disposed", m_isDisposed ); + assertEquals( "|cancelledContext| is not expected to notify an action title", 0, i_event.UndoActionTitle.length() ); + + m_activeUndoContexts.pop(); + assertEquals( "different opinions on the context nesting level (after cancelling)", + m_activeUndoContexts.size(), i_event.UndoContextDepth ); + m_cancelledContext = true; + impl_notifyContextDepth(); + } + + public void disposing( EventObject i_event ) + { + m_isDisposed = true; + } + + public void waitForAllContextsClosed( final int i_milliSeconds ) throws InterruptedException + { + synchronized ( m_allContextsClosedCondition ) + { + if ( m_activeUndoContexts.empty() ) + return; + m_allContextsClosedCondition.wait( i_milliSeconds ); + } + } + + private void impl_notifyContextDepth() + { + synchronized ( m_allContextsClosedCondition ) + { + if ( m_activeUndoContexts.empty() ) + { + m_allContextsClosedCondition.notifyAll(); + } + } + } + + private int getUndoActionsAdded() { return m_undoActionsAdded; } + private int getUndoActionCount() { return m_undoCount; } + private int getRedoActionCount() { return m_redoCount; } + private String getCurrentUndoContextTitle() { return m_activeUndoContexts.peek(); } + private String getMostRecentlyAddedActionTitle() { return m_mostRecentlyAddedAction; }; + private String getMostRecentlyUndoneTitle() { return m_mostRecentlyUndone; } + private int getCurrentUndoContextDepth() { return m_activeUndoContexts.size(); } + private boolean isDisposed() { return m_isDisposed; } + private boolean wasContextLeft() { return m_leftContext; } + private boolean wasHiddenContextLeft() { return m_leftHiddenContext; } + private boolean hasContextBeenCancelled() { return m_cancelledContext; } + private boolean wereStacksCleared() { return m_wasCleared; } + private boolean wasRedoStackCleared() { return m_redoWasCleared; } + private boolean wasManagerReset() { return m_managerWasReset; } + + void reset() + { + m_undoActionsAdded = m_undoCount = m_redoCount = 0; + m_activeUndoContexts.clear(); + m_mostRecentlyAddedAction = m_mostRecentlyUndone = null; + // m_isDisposed is not cleared, intentionally + m_leftContext = m_leftHiddenContext = m_cancelledContext = m_wasCleared = m_redoWasCleared = m_managerWasReset = false; + } + + private int m_undoActionsAdded = 0; + private int m_undoCount = 0; + private int m_redoCount = 0; + private boolean m_isDisposed = false; + private boolean m_leftContext = false; + private boolean m_leftHiddenContext = false; + private boolean m_cancelledContext = false; + private boolean m_wasCleared = false; + private boolean m_redoWasCleared = false; + private boolean m_managerWasReset = false; + private Stack< String > + m_activeUndoContexts = new Stack<String>(); + private String m_mostRecentlyAddedAction = null; + private String m_mostRecentlyUndone = null; + private final Object m_allContextsClosedCondition = new Object(); + }; + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_checkUndo() throws Exception + { + System.out.println( "testing: " + m_currentTestCase.getDocumentDescription() ); + m_currentDocument = m_currentTestCase.getDocument(); + m_currentTestCase.initializeDocument(); + m_currentTestCase.verifyInitialDocumentState(); + + final XUndoManager undoManager = getUndoManager(); + undoManager.clear(); + assertFalse( "clearing the Undo manager should result in the impossibility to undo anything", undoManager.isUndoPossible() ); + assertFalse( "clearing the Undo manager should result in the impossibility to redo anything", undoManager.isRedoPossible() ); + + m_undoListener = new UndoListener(); + undoManager.addUndoManagerListener( m_undoListener ); + + impl_testSingleModification( undoManager ); + impl_testMultipleModifications( undoManager ); + impl_testCustomUndoActions( undoManager ); + impl_testLocking( undoManager ); + impl_testNestedContexts( undoManager ); + impl_testErrorHandling( undoManager ); + impl_testContextHandling( undoManager ); + impl_testStackHandling( undoManager ); + impl_testClearance( undoManager ); + impl_testHiddenContexts( undoManager ); + + // close the document, ensure the Undo manager listener gets notified + m_currentTestCase.closeDocument(); + m_currentTestCase = null; + m_currentDocument = null; + assertTrue( "document is closed, but the UndoManagerListener has not been notified of the disposal", m_undoListener.isDisposed() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testSingleModification( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + m_currentTestCase.doSingleModification(); + m_currentTestCase.verifySingleModificationDocumentState(); + + // undo the modification, ensure the listener got the proper notifications + assertEquals( "We did not yet do a undo!", 0, m_undoListener.getUndoActionCount() ); + i_undoManager.undo(); + assertEquals( "A simple undo does not result in the proper Undo count.", + 1, m_undoListener.getUndoActionCount() ); + + // verify the document is in its initial state, again + m_currentTestCase.verifyInitialDocumentState(); + + // redo the modification, ensure the listener got the proper notifications + assertEquals( "did not yet do a redo!", 0, m_undoListener.getRedoActionCount() ); + i_undoManager.redo(); + assertEquals( "did a redo, but got no notification of it!", 1, m_undoListener.getRedoActionCount() ); + // ensure the document is in the proper state, again + m_currentTestCase.verifySingleModificationDocumentState(); + + // now do an Undo via the UI (aka the dispatch API), and see if this works, and notifies the listener as + // expected + m_currentTestCase.getDocument().getCurrentView().dispatch( ".uno:Undo" ); + m_currentTestCase.verifyInitialDocumentState(); + assertEquals( "UI-Undo does not notify the listener", 2, m_undoListener.getUndoActionCount() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testMultipleModifications( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + m_undoListener.reset(); + assertEquals( "unexpected initial undo context depth", 0, m_undoListener.getCurrentUndoContextDepth() ); + i_undoManager.enterUndoContext( "Batch Changes" ); + assertEquals( "unexpected undo context depth after entering a context", + 1, m_undoListener.getCurrentUndoContextDepth() ); + assertEquals( "entering an Undo context has not been notified properly", + "Batch Changes", m_undoListener.getCurrentUndoContextTitle() ); + + final int modifications = m_currentTestCase.doMultipleModifications(); + assertEquals( "unexpected number of undo actions while doing batch changes to the document", + modifications, m_undoListener.getUndoActionsAdded() ); + assertEquals( "seems the document operations touched the undo context depth", + 1, m_undoListener.getCurrentUndoContextDepth() ); + + i_undoManager.leaveUndoContext(); + assertEquals( "unexpected undo context depth after leaving the last context", + 0, m_undoListener.getCurrentUndoContextDepth() ); + assertEquals( "no Undo done, yet - still the listener has been notified of an Undo action", + 0, m_undoListener.getUndoActionCount() ); + + i_undoManager.undo(); + assertEquals( "Just did an undo - the listener should have been notified", 1, m_undoListener.getUndoActionCount() ); + m_currentTestCase.verifyInitialDocumentState(); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testCustomUndoActions( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.clear(); + m_undoListener.reset(); + assertFalse( "undo stack not empty after clearing the undo manager", i_undoManager.isUndoPossible() ); + assertFalse( "redo stack not empty after clearing the undo manager", i_undoManager.isRedoPossible() ); + assertArrayEquals( ">0 descriptions for an empty undo stack?", + new String[0], i_undoManager.getAllUndoActionTitles() ); + assertArrayEquals( ">0 descriptions for an empty redo stack?", + new String[0], i_undoManager.getAllRedoActionTitles() ); + + // add two actions, one directly, one within a context + final CustomUndoAction action1 = new CustomUndoAction( "UndoAction1" ); + i_undoManager.addUndoAction( action1 ); + assertEquals( "Adding an undo action not observed by the listener", 1, m_undoListener.getUndoActionsAdded() ); + assertEquals( "Adding an undo action did not notify the proper title", + action1.getTitle(), m_undoListener.getMostRecentlyAddedActionTitle() ); + final String contextTitle = "Undo Context"; + i_undoManager.enterUndoContext( contextTitle ); + final CustomUndoAction action2 = new CustomUndoAction( "UndoAction2" ); + i_undoManager.addUndoAction( action2 ); + assertEquals( "Adding an undo action not observed by the listener", + 2, m_undoListener.getUndoActionsAdded() ); + assertEquals( "Adding an undo action did not notify the proper title", + action2.getTitle(), m_undoListener.getMostRecentlyAddedActionTitle() ); + i_undoManager.leaveUndoContext(); + + // see if the manager has proper descriptions + assertArrayEquals( "unexpected Redo descriptions after adding two actions", + new String[0], i_undoManager.getAllRedoActionTitles() ); + assertArrayEquals( "unexpected Undo descriptions after adding two actions", + new String[]{contextTitle, action1.getTitle()}, i_undoManager.getAllUndoActionTitles() ); + + // undo one action + i_undoManager.undo(); + assertEquals( "improper action title notified during programmatic Undo", + contextTitle, m_undoListener.getMostRecentlyUndoneTitle() ); + assertTrue( "nested custom undo action has not been undone as expected", action2.undoCalled() ); + assertFalse( "nested custom undo action has not been undone as expected", action1.undoCalled() ); + assertArrayEquals( "unexpected Redo descriptions after undoing a nested custom action", + new String[]{contextTitle}, i_undoManager.getAllRedoActionTitles() ); + assertArrayEquals( "unexpected Undo descriptions after undoing a nested custom action", + new String[]{action1.getTitle()}, i_undoManager.getAllUndoActionTitles() ); + + // undo the second action, via UI dispatches + m_currentTestCase.getDocument().getCurrentView().dispatch( ".uno:Undo" ); + assertEquals( "improper action title notified during UI Undo", action1.getTitle(), m_undoListener.getMostRecentlyUndoneTitle() ); + assertTrue( "nested custom undo action has not been undone as expected", action1.undoCalled() ); + assertArrayEquals( "unexpected Redo descriptions after undoing the second custom action", + new String[]{action1.getTitle(), contextTitle}, i_undoManager.getAllRedoActionTitles() ); + assertArrayEquals( "unexpected Undo descriptions after undoing the second custom action", + new String[0], i_undoManager.getAllUndoActionTitles() ); + + // check the actions are disposed when the stacks are cleared + i_undoManager.clear(); + assertTrue( action1.disposed() && action2.disposed() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testLocking( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + + // implicit Undo actions, triggered by changes to the document + assertFalse( "unexpected initial locking state", i_undoManager.isLocked() ); + i_undoManager.lock(); + assertTrue( "just locked the manager, why does it lie?", i_undoManager.isLocked() ); + m_currentTestCase.doSingleModification(); + assertEquals( "when the Undo manager is locked, no implicit additions should happen", + 0, m_undoListener.getUndoActionsAdded() ); + i_undoManager.unlock(); + assertEquals( "unlock is not expected to add collected actions - they should be discarded", + 0, m_undoListener.getUndoActionsAdded() ); + assertFalse( "just unlocked the manager, why does it lie?", i_undoManager.isLocked() ); + + // explicit Undo actions + i_undoManager.lock(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.unlock(); + assertEquals( "explicit Undo actions are expected to be ignored when the manager is locked", + 0, m_undoListener.getUndoActionsAdded() ); + + // Undo contexts while being locked + i_undoManager.lock(); + i_undoManager.enterUndoContext( "Dummy Context" ); + i_undoManager.enterHiddenUndoContext(); + assertEquals( "entering Undo contexts should be ignored when the manager is locked", 0, m_undoListener.getCurrentUndoContextDepth() ); + i_undoManager.leaveUndoContext(); + i_undoManager.leaveUndoContext(); + i_undoManager.unlock(); + + // |unlock| error handling + assertFalse( "internal error: manager should not be locked at this point in time", i_undoManager.isLocked() ); + boolean caughtExpected = false; + try { i_undoManager.unlock(); } catch ( final NotLockedException e ) { caughtExpected = true; } + assertTrue( "unlocking the manager when it is not locked should throw", caughtExpected ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testContextHandling( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + // ............................................................................................................. + // part I: non-empty contexts + i_undoManager.reset(); + m_undoListener.reset(); + + // put one action on the undo and one on the redo stack, as precondition for the following tests + final XUndoAction undoAction1 = new CustomUndoAction( "Undo Action 1" ); + i_undoManager.addUndoAction( undoAction1 ); + final XUndoAction undoAction2 = new CustomUndoAction( "Undo Action 2" ); + i_undoManager.addUndoAction( undoAction2 ); + i_undoManager.undo(); + assertTrue( "precondition for context handling tests not met (1)", i_undoManager.isUndoPossible() ); + assertTrue( "precondition for context handling tests not met (2)", i_undoManager.isRedoPossible() ); + assertArrayEquals( new String[] { undoAction1.getTitle() }, i_undoManager.getAllUndoActionTitles() ); + assertArrayEquals( new String[] { undoAction2.getTitle() }, i_undoManager.getAllRedoActionTitles() ); + + final String[] expectedRedoActionComments = new String[] { undoAction2.getTitle() }; + assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() ); + + // enter a context + i_undoManager.enterUndoContext( "Undo Context" ); + // this should not (yet) touch the redo stack + assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() ); + assertEquals( "unexpected undo context depth after entering a context", 1, m_undoListener.getCurrentUndoContextDepth() ); + // add a single action + XUndoAction undoAction3 = new CustomUndoAction( "Undo Action 3" ); + i_undoManager.addUndoAction( undoAction3 ); + // still, the redo stack should be untouched - added at a lower level does not affect it at all + assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() ); + + // while the context is open, its title should already contribute to the stack, ... + assertEquals( "Undo Context", i_undoManager.getCurrentUndoActionTitle() ); + // ... getAllUndo/RedoActionTitles should operate on the top level, not on the level defined by the open + // context, ... + assertArrayEquals( new String[] { "Undo Context", undoAction1.getTitle() }, + i_undoManager.getAllUndoActionTitles() ); + // ... but Undo and Redo should be impossible as long as the context is open + assertFalse( i_undoManager.isUndoPossible() ); + assertFalse( i_undoManager.isRedoPossible() ); + + // leave the context, check the listener has been notified properly, and the notified context depth is correct + i_undoManager.leaveUndoContext(); + assertTrue( m_undoListener.wasContextLeft() ); + assertFalse( m_undoListener.wasHiddenContextLeft() ); + assertFalse( m_undoListener.hasContextBeenCancelled() ); + assertEquals( "unexpected undo context depth leaving a non-empty context", 0, m_undoListener.getCurrentUndoContextDepth() ); + // leaving a non-empty context should have cleare the redo stack + assertArrayEquals( new String[0], i_undoManager.getAllRedoActionTitles() ); + assertTrue( m_undoListener.wasRedoStackCleared() ); + + // ............................................................................................................. + // part II: empty contexts + i_undoManager.reset(); + m_undoListener.reset(); + + // enter a context, leave it immediately without adding an action to it + i_undoManager.enterUndoContext( "Undo Context" ); + i_undoManager.leaveUndoContext(); + assertFalse( m_undoListener.wasContextLeft() ); + assertFalse( m_undoListener.wasHiddenContextLeft() ); + assertTrue( m_undoListener.hasContextBeenCancelled() ); + assertFalse( "leaving an empty context should silently remove it, and not contribute to the stack", + i_undoManager.isUndoPossible() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testNestedContexts( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + i_undoManager.enterUndoContext( "context 1" ); + i_undoManager.enterUndoContext( "context 1.1" ); + final CustomUndoAction action1 = new CustomUndoAction( "action 1.1.1" ); + i_undoManager.addUndoAction( action1 ); + i_undoManager.enterUndoContext( "context 1.1.2" ); + final CustomUndoAction action2 = new CustomUndoAction( "action 1.1.2.1" ); + i_undoManager.addUndoAction( action2 ); + i_undoManager.leaveUndoContext(); + final CustomUndoAction action3 = new CustomUndoAction( "action 1.1.3" ); + i_undoManager.addUndoAction( action3 ); + i_undoManager.leaveUndoContext(); + i_undoManager.leaveUndoContext(); + final CustomUndoAction action4 = new CustomUndoAction( "action 1.2" ); + i_undoManager.addUndoAction( action4 ); + + i_undoManager.undo(); + assertEquals( "undoing a single action notifies a wrong title", action4.getTitle(), m_undoListener.getMostRecentlyUndoneTitle() ); + assertTrue( "custom Undo not called", action4.undoCalled() ); + assertFalse( "too many custom Undos called", action1.undoCalled() || action2.undoCalled() || action3.undoCalled() ); + i_undoManager.undo(); + assertTrue( "nested actions not properly undone", action1.undoCalled() && action2.undoCalled() && action3.undoCalled() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testErrorHandling( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + + // try retrieving the comments for the current Undo/Redo - this should fail + boolean caughtExpected = false; + try { i_undoManager.getCurrentUndoActionTitle(); } + catch( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "trying the title of the current Undo action is expected to fail for an empty stack", caughtExpected ); + + caughtExpected = false; + try { i_undoManager.getCurrentRedoActionTitle(); } + catch( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "trying the title of the current Redo action is expected to fail for an empty stack", caughtExpected ); + + caughtExpected = false; + try { i_undoManager.undo(); } catch ( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "undo should throw if no Undo action is on the stack", caughtExpected ); + + caughtExpected = false; + try { i_undoManager.redo(); } catch ( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "redo should throw if no Redo action is on the stack", caughtExpected ); + + caughtExpected = false; + try { i_undoManager.leaveUndoContext(); } catch ( final InvalidStateException e ) { caughtExpected = true; } + assertTrue( "leaveUndoContext should throw if no context is currently open", caughtExpected ); + + caughtExpected = false; + try { i_undoManager.addUndoAction( null ); } catch ( com.sun.star.lang.IllegalArgumentException e ) { caughtExpected = true; } + assertTrue( "adding a NULL action should be rejected", caughtExpected ); + + i_undoManager.reset(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.undo(); + i_undoManager.enterUndoContext( "Undo Context" ); + // those methods should fail when a context is open: + final String[] methodNames = new String[] { "undo", "redo", "clear", "clearRedo" }; + for ( int i=0; i<methodNames.length; ++i ) + { + caughtExpected = false; + try + { + Method method = i_undoManager.getClass().getMethod( methodNames[i], new Class[0] ); + method.invoke( i_undoManager, new Object[0] ); + } + catch ( IllegalAccessException ex ) { } + catch ( IllegalArgumentException ex ) { } + catch ( InvocationTargetException ex ) + { + Throwable targetException = ex.getTargetException(); + caughtExpected = ( targetException instanceof UndoContextNotClosedException ); + } + catch ( NoSuchMethodException ex ) { } + catch ( SecurityException ex ) { } + + assertTrue( methodNames[i] + " should be rejected when there is an open context", caughtExpected ); + } + i_undoManager.leaveUndoContext(); + + // try Undo actions which fail in their Undo/Redo + for ( int i=0; i<4; ++i ) + { + final boolean undo = ( i < 2 ); + final boolean doByAPI = ( i % 2 ) == 0; + + i_undoManager.reset(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.addUndoAction( new FailingUndoAction( undo ? FAIL_UNDO : FAIL_REDO ) ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.undo(); + if ( !undo ) + i_undoManager.undo(); + // assert preconditions for the below test + assertTrue( i_undoManager.isUndoPossible() ); + assertTrue( i_undoManager.isRedoPossible() ); + + boolean caughtUndoFailed = false; + try + { + if ( undo ) + if ( doByAPI ) + i_undoManager.undo(); + else + m_currentTestCase.getDocument().getCurrentView().dispatch( ".uno:Undo" ); + else + if ( doByAPI ) + i_undoManager.redo(); + else + m_currentTestCase.getDocument().getCurrentView().dispatch( ".uno:Redo" ); + } + catch ( UndoFailedException e ) + { + caughtUndoFailed = true; + } + if ( doByAPI ) + assertTrue( "Exceptions in XUndoAction.undo should be propagated at the API", caughtUndoFailed ); + else + assertFalse( "Undo/Redo by UI should not let escape Exceptions", caughtUndoFailed ); + if ( undo ) + { + assertFalse( "a failing Undo should clear the Undo stack", i_undoManager.isUndoPossible() ); + assertTrue( "a failing Undo should /not/ clear the Redo stack", i_undoManager.isRedoPossible() ); + } + else + { + assertTrue( "a failing Redo should /not/ clear the Undo stack", i_undoManager.isUndoPossible() ); + assertFalse( "a failing Redo should clear the Redo stack", i_undoManager.isRedoPossible() ); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testStackHandling( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + + assertFalse( i_undoManager.isUndoPossible() ); + assertFalse( i_undoManager.isRedoPossible() ); + + i_undoManager.addUndoAction( new CustomUndoAction() ); + assertTrue( i_undoManager.isUndoPossible() ); + assertFalse( i_undoManager.isRedoPossible() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + assertTrue( i_undoManager.isUndoPossible() ); + assertFalse( i_undoManager.isRedoPossible() ); + i_undoManager.undo(); + assertTrue( i_undoManager.isUndoPossible() ); + assertTrue( i_undoManager.isRedoPossible() ); + i_undoManager.undo(); + assertFalse( i_undoManager.isUndoPossible() ); + assertTrue( i_undoManager.isRedoPossible() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + assertTrue( i_undoManager.isUndoPossible() ); + assertFalse( "adding a new action should have cleared the Redo stack", i_undoManager.isRedoPossible() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testClearance( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + + // add an action, clear the stack, verify the listener has been called + i_undoManager.addUndoAction( new CustomUndoAction() ); + assertFalse( "clearance listener unexpectedly called", m_undoListener.wereStacksCleared() ); + assertFalse( "redo-clearance listener unexpectedly called", m_undoListener.wasRedoStackCleared() ); + i_undoManager.clear(); + assertTrue( "clearance listener not called as expected", m_undoListener.wereStacksCleared() ); + assertFalse( "redo-clearance listener unexpectedly called (2)", m_undoListener.wasRedoStackCleared() ); + + // ensure the listener is also called if the stack is actually empty at the moment of the call + m_undoListener.reset(); + assertFalse( i_undoManager.isUndoPossible() ); + i_undoManager.clear(); + assertTrue( "clearance listener is also expected to be called if the stack was empty before", m_undoListener.wereStacksCleared() ); + + // ensure the proper listeners are called for clearRedo + m_undoListener.reset(); + i_undoManager.clearRedo(); + assertFalse( m_undoListener.wereStacksCleared() ); + assertTrue( m_undoListener.wasRedoStackCleared() ); + + // ensure the redo listener is also called upon implicit redo stack clearance + m_undoListener.reset(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.undo(); + assertTrue( i_undoManager.isUndoPossible() ); + assertTrue( i_undoManager.isRedoPossible() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + assertFalse( i_undoManager.isRedoPossible() ); + assertTrue( "implicit clearance of the Redo stack does not notify listeners", m_undoListener.wasRedoStackCleared() ); + + // test resetting the manager + m_undoListener.reset(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.undo(); + assertTrue( i_undoManager.isUndoPossible() ); + assertTrue( i_undoManager.isRedoPossible() ); + i_undoManager.reset(); + assertFalse( i_undoManager.isUndoPossible() ); + assertFalse( i_undoManager.isRedoPossible() ); + assertTrue( "|reset| does not properly notify", m_undoListener.wasManagerReset() ); + + // resetting the manager, with open undo contexts + m_undoListener.reset(); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.enterUndoContext( "Undo Context" ); + i_undoManager.addUndoAction( new CustomUndoAction() ); + i_undoManager.enterHiddenUndoContext(); + i_undoManager.reset(); + assertTrue( "|reset| while contexts are open does not properly notify", m_undoListener.wasManagerReset() ); + // verify the manager really has the proper context depth now + i_undoManager.enterUndoContext( "Undo Context" ); + assertEquals( "seems that |reset| did not really close the open contexts", 1, m_undoListener.getCurrentUndoContextDepth() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_testHiddenContexts( final XUndoManager i_undoManager ) throws com.sun.star.uno.Exception + { + i_undoManager.reset(); + m_undoListener.reset(); + assertFalse( "precondition for testing hidden undo contexts not met", i_undoManager.isUndoPossible() ); + + // entering a hidden context should be rejected if the stack is empty + boolean caughtExpected = false; + try { i_undoManager.enterHiddenUndoContext(); } + catch ( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "entering hidden contexts should be denied on an empty stack", caughtExpected ); + + // but it should be allowed if the context is not empty + final CustomUndoAction undoAction0 = new CustomUndoAction( "Step 0" ); + i_undoManager.addUndoAction( undoAction0 ); + final CustomUndoAction undoAction1 = new CustomUndoAction( "Step 1" ); + i_undoManager.addUndoAction( undoAction1 ); + i_undoManager.enterHiddenUndoContext(); + final CustomUndoAction hiddenUndoAction = new CustomUndoAction( "hidden context action" ); + i_undoManager.addUndoAction( hiddenUndoAction ); + i_undoManager.leaveUndoContext(); + assertFalse( "leaving a hidden should not call |leftUndocontext|", m_undoListener.wasContextLeft() ); + assertTrue( "leaving a hidden does not call |leftHiddenUndocontext|", m_undoListener.wasHiddenContextLeft() ); + assertFalse( "leaving a non-empty hidden context claims to have cancelled it", m_undoListener.hasContextBeenCancelled() ); + assertEquals( "leaving a hidden context is not properly notified", 0, m_undoListener.getCurrentUndoContextDepth() ); + assertArrayEquals( "unexpected Undo stack after leaving a hidden context", + new String[] { undoAction1.getTitle(), undoAction0.getTitle() }, + i_undoManager.getAllUndoActionTitles() ); + + // and then calling |undo| once should not only undo everything in the hidden context, but also + // the previous action - but not more + i_undoManager.undo(); + assertTrue( "Undo after leaving a hidden context does not actually undo the context actions", + hiddenUndoAction.undoCalled() ); + assertTrue( "Undo after leaving a hidden context does not undo the predecessor action", + undoAction1.undoCalled() ); + assertFalse( "Undo after leaving a hidden context undoes too much", + undoAction0.undoCalled() ); + + // leaving an empty hidden context should call the proper notification method + m_undoListener.reset(); + i_undoManager.enterHiddenUndoContext(); + i_undoManager.leaveUndoContext(); + assertFalse( m_undoListener.wasContextLeft() ); + assertFalse( m_undoListener.wasHiddenContextLeft() ); + assertTrue( m_undoListener.hasContextBeenCancelled() ); + + // nesting hidden and normal contexts + m_undoListener.reset(); + i_undoManager.reset(); + final CustomUndoAction action0 = new CustomUndoAction( "action 0" ); + i_undoManager.addUndoAction( action0 ); + i_undoManager.enterUndoContext( "context 1" ); + final CustomUndoAction action1 = new CustomUndoAction( "action 1" ); + i_undoManager.addUndoAction( action1 ); + i_undoManager.enterHiddenUndoContext(); + final CustomUndoAction action2 = new CustomUndoAction( "action 2" ); + i_undoManager.addUndoAction( action2 ); + i_undoManager.enterUndoContext( "context 2" ); + // is entering a hidden context rejected even at the nesting level > 0 (the above test was for nesting level == 0)? + caughtExpected = false; + try { i_undoManager.enterHiddenUndoContext(); } + catch( final EmptyUndoStackException e ) { caughtExpected = true; } + assertTrue( "at a nesting level > 0, denied hidden contexts does not work as expected", caughtExpected ); + final CustomUndoAction action3 = new CustomUndoAction( "action 3" ); + i_undoManager.addUndoAction( action3 ); + i_undoManager.enterHiddenUndoContext(); + assertEquals( "mixed hidden/normal context do are not properly notified", 4, m_undoListener.getCurrentUndoContextDepth() ); + i_undoManager.leaveUndoContext(); + assertTrue( "the left context was empty - why wasn't 'cancelled' notified?", m_undoListener.hasContextBeenCancelled() ); + assertFalse( m_undoListener.wasContextLeft() ); + assertFalse( m_undoListener.wasHiddenContextLeft() ); + i_undoManager.leaveUndoContext(); + i_undoManager.leaveUndoContext(); + i_undoManager.leaveUndoContext(); + i_undoManager.undo(); + assertFalse( "one action too much has been undone", action0.undoCalled() ); + assertTrue( action1.undoCalled() ); + assertTrue( action2.undoCalled() ); + assertTrue( action3.undoCalled() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private XComponentContext getContext() + { + return m_connection.getComponentContext(); + } + + // ----------------------------------------------------------------------------------------------------------------- + private XMultiServiceFactory getORB() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface( + XMultiServiceFactory.class, getContext().getServiceManager() ); + return xMSF1; + } + + // ----------------------------------------------------------------------------------------------------------------- + @BeforeClass + public static void setUpConnection() throws Exception + { + System.out.println( "--------------------------------------------------------------------------------" ); + System.out.println( "starting class: " + UndoManager.class.getName() ); + System.out.println( "connecting ..." ); + m_connection.setUp(); + } + + // ----------------------------------------------------------------------------------------------------------------- + @AfterClass + public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println(); + System.out.println( "tearing down connection" ); + m_connection.tearDown(); + System.out.println( "finished class: " + UndoManager.class.getName() ); + System.out.println( "--------------------------------------------------------------------------------" ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private static class CustomUndoAction implements XUndoAction, XComponent + { + CustomUndoAction() + { + m_title = "Custom Undo Action"; + } + + CustomUndoAction( final String i_title ) + { + m_title = i_title; + } + + public String getTitle() + { + return m_title; + } + + public void undo() throws UndoFailedException + { + m_undoCalled = true; + } + + public void redo() throws UndoFailedException + { + m_redoCalled = true; + } + + public void dispose() + { + m_disposed = true; + } + + public void addEventListener( XEventListener xl ) + { + fail( "addEventListener is not expected to be called in the course of this test" ); + } + + public void removeEventListener( XEventListener xl ) + { + fail( "removeEventListener is not expected to be called in the course of this test" ); + } + + boolean undoCalled() { return m_undoCalled; } + boolean redoCalled() { return m_redoCalled; } + boolean disposed() { return m_disposed; } + + private final String m_title; + private boolean m_undoCalled = false; + private boolean m_redoCalled = false; + private boolean m_disposed = false; + } + + private static short FAIL_UNDO = 1; + private static short FAIL_REDO = 2; + + private static class FailingUndoAction implements XUndoAction + { + FailingUndoAction( final short i_failWhich ) + { + m_failWhich = i_failWhich; + } + + public String getTitle() + { + return "failing undo"; + } + + public void undo() throws UndoFailedException + { + if ( m_failWhich != FAIL_REDO ) + impl_throw(); + } + + public void redo() throws UndoFailedException + { + if ( m_failWhich != FAIL_UNDO ) + impl_throw(); + } + + private void impl_throw() throws UndoFailedException + { + throw new UndoFailedException(); + } + + private final short m_failWhich; + } + + // ----------------------------------------------------------------------------------------------------------------- + private static class CountingUndoAction implements XUndoAction + { + CountingUndoAction( final int i_expectedOrder, final Object i_lock, final Integer[] i_actionsUndoneCounter ) + { + m_expectedOrder = i_expectedOrder; + m_lock = i_lock; + m_actionsUndoneCounter = i_actionsUndoneCounter; + } + + public String getTitle() + { + return "Counting Undo Action"; + } + + public void undo() throws UndoFailedException + { + synchronized( m_lock ) + { + assertEquals( "Undo action called out of order", m_expectedOrder, m_actionsUndoneCounter[0].intValue() ); + ++m_actionsUndoneCounter[0]; + } + } + + public void redo() throws UndoFailedException + { + fail( "CountingUndoAction.redo is not expected to be called in this test." ); + } + private final int m_expectedOrder; + private final Object m_lock; + private Integer[] m_actionsUndoneCounter; + } + + // ----------------------------------------------------------------------------------------------------------------- + private static String getCallbackUndoContextTitle() + { + return "Some Unfinished Undo Context"; + } + + // ----------------------------------------------------------------------------------------------------------------- + private static String getCallbackComponentServiceName() + { + return "org.openoffice.complex.sfx2.Callback"; + } + + // ----------------------------------------------------------------------------------------------------------------- + /** + * a factory for a callback component which, at OOo runtime, is inserted into OOo's "component repository" + */ + private class CallbackComponentFactory implements XSingleComponentFactory, XServiceInfo, XComponent + { + public Object createInstanceWithContext( XComponentContext i_context ) throws com.sun.star.uno.Exception + { + return new CallbackComponent(); + } + + public Object createInstanceWithArgumentsAndContext( Object[] i_arguments, XComponentContext i_context ) throws com.sun.star.uno.Exception + { + return createInstanceWithContext( i_context ); + } + + public String getImplementationName() + { + return "org.openoffice.complex.sfx2.CallbackComponent"; + } + + public boolean supportsService( String i_serviceName ) + { + return i_serviceName.equals( getCallbackComponentServiceName() ); + } + + public String[] getSupportedServiceNames() + { + return new String[] { getCallbackComponentServiceName() }; + } + + public void dispose() + { + final EventObject event = new EventObject( this ); + + final ArrayList eventListenersCopy = (ArrayList)m_eventListeners.clone(); + final Iterator iter = eventListenersCopy.iterator(); + while ( iter.hasNext() ) + { + ((XEventListener)iter.next()).disposing( event ); + } + } + + public void addEventListener( XEventListener i_listener ) + { + if ( i_listener != null ) + m_eventListeners.add( i_listener ); + } + + public void removeEventListener( XEventListener i_listener ) + { + m_eventListeners.remove( i_listener ); + } + + private final ArrayList m_eventListeners = new ArrayList(); + }; + + // ----------------------------------------------------------------------------------------------------------------- + private class CallbackComponent implements XJob, XTypeProvider + { + CallbackComponent() + { + } + + public Object execute( NamedValue[] i_parameters ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception + { + // this method is called from within the Basic script which is to check whether the OOo framework + // properly cleans up unfinished Undo contexts. It is called immediately after the context has been + // entered, so verify the expected Undo manager state. + assertEquals( getCallbackUndoContextTitle(), m_undoListener.getCurrentUndoContextTitle() ); + assertEquals( 1, m_undoListener.getCurrentUndoContextDepth() ); + + synchronized( m_callbackCondition ) + { + m_callbackCalled = true; + m_callbackCondition.notifyAll(); + } + return m_closeAfterCallback ? "close" : ""; + } + + public Type[] getTypes() + { + final Class interfaces[] = getClass().getInterfaces(); + Type types[] = new Type[ interfaces.length ]; + for ( int i = 0; i < interfaces.length; ++i ) + types[i] = new Type(interfaces[i]); + return types; + } + + public byte[] getImplementationId() + { + return getClass().toString().getBytes(); + } + } + + private static final OfficeConnection m_connection = new OfficeConnection(); + private DocumentTest m_currentTestCase; + private OfficeDocument m_currentDocument; + private UndoListener m_undoListener; + private CallbackComponentFactory m_callbackFactory = null; + private boolean m_callbackCalled = false; + private boolean m_closeAfterCallback = false; + private final Object m_callbackCondition = new Object(); +} diff --git a/sfx2/qa/complex/sfx2/makefile.mk b/sfx2/qa/complex/sfx2/makefile.mk new file mode 100644 index 000000000000..20b170fba3b4 --- /dev/null +++ b/sfx2/qa/complex/sfx2/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# 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 +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_JUNIT_JAR)" == "" +nothing .PHONY: + @echo ----------------------------------------------------- + @echo - JUnit not available, not building anything + @echo ----------------------------------------------------- +.ELSE # IF "$(OOO_JUNIT_JAR)" != "" + +PRJ = ../../.. +PRJNAME = sfx2 +TARGET = qa_complex +PACKAGE = complex/sfx2 + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + +#----- compile .java files ----------------------------------------- + +JARFILES = OOoRunnerLight.jar ridl.jar test.jar test-tools.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +JAVAFILES = $(shell @$(FIND) . -name "*.java") \ + +#----- create a jar from compiled files ---------------------------- + +JARTARGET = $(TARGET).jar + +#----- JUnit tests class ------------------------------------------- + +JAVATESTFILES = \ + DocumentInfo.java \ + DocumentProperties.java \ + StandaloneDocumentInfo.java \ + DocumentMetadataAccess.java \ + UndoManager.java \ + +# disabled: #i115674# +# GlobalEventBroadcaster.java \ + +# --- Targets ------------------------------------------------------ + +.INCLUDE: target.mk + +ALL : ALLTAR + +# --- subsequent tests --------------------------------------------- + +.IF "$(OOO_SUBSEQUENT_TESTS)" != "" + +.INCLUDE: installationtest.mk + +ALLTAR : javatest + + # Sample how to debug + # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y + +.END # "$(OOO_SUBSEQUENT_TESTS)" == "" + +.END # ELSE "$(OOO_JUNIT_JAR)" != "" diff --git a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoTest.java b/sfx2/qa/complex/sfx2/standalonedocinfo/StandaloneDocumentInfoTest.java index f5512bf9723b..d255f3d16822 100644 --- a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoTest.java +++ b/sfx2/qa/complex/sfx2/standalonedocinfo/StandaloneDocumentInfoTest.java @@ -24,7 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.standalonedocumentinfo; +package complex.sfx2.standalonedocinfo; public interface StandaloneDocumentInfoTest { boolean test(); diff --git a/sfx2/qa/complex/standalonedocumentinfo/Test01.java b/sfx2/qa/complex/sfx2/standalonedocinfo/Test01.java index 2f9a6266b4e2..bf54bb4ca90b 100644 --- a/sfx2/qa/complex/standalonedocumentinfo/Test01.java +++ b/sfx2/qa/complex/sfx2/standalonedocinfo/Test01.java @@ -24,8 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.standalonedocumentinfo; +package complex.sfx2.standalonedocinfo; +import complex.sfx2.standalonedocinfo.TestHelper; +import complex.sfx2.standalonedocinfo.StandaloneDocumentInfoTest; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.document.XStandaloneDocumentInfo; import com.sun.star.io.XTempFile; diff --git a/sfx2/qa/complex/standalonedocumentinfo/TestHelper.java b/sfx2/qa/complex/sfx2/standalonedocinfo/TestHelper.java index f6d63e1b7793..a650ce9bb2e4 100644 --- a/sfx2/qa/complex/standalonedocumentinfo/TestHelper.java +++ b/sfx2/qa/complex/sfx2/standalonedocinfo/TestHelper.java @@ -24,7 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.standalonedocumentinfo; +package complex.sfx2.standalonedocinfo; public class TestHelper { diff --git a/sfx2/qa/complex/framework/testdocuments/CUSTOM.odt b/sfx2/qa/complex/sfx2/testdocuments/CUSTOM.odt Binary files differindex 831a8f451dfd..831a8f451dfd 100644 --- a/sfx2/qa/complex/framework/testdocuments/CUSTOM.odt +++ b/sfx2/qa/complex/sfx2/testdocuments/CUSTOM.odt diff --git a/sfx2/qa/complex/framework/testdocuments/TEST.odt b/sfx2/qa/complex/sfx2/testdocuments/TEST.odt Binary files differindex 7c6f0b60f7b0..7c6f0b60f7b0 100644 --- a/sfx2/qa/complex/framework/testdocuments/TEST.odt +++ b/sfx2/qa/complex/sfx2/testdocuments/TEST.odt diff --git a/sfx2/qa/complex/framework/testdocuments/TESTRDFA.odt b/sfx2/qa/complex/sfx2/testdocuments/TESTRDFA.odt Binary files differindex d59739142df6..d59739142df6 100644 --- a/sfx2/qa/complex/framework/testdocuments/TESTRDFA.odt +++ b/sfx2/qa/complex/sfx2/testdocuments/TESTRDFA.odt diff --git a/sfx2/qa/complex/framework/testdocuments/empty.rdf b/sfx2/qa/complex/sfx2/testdocuments/empty.rdf index af62bab39dfa..af62bab39dfa 100644 --- a/sfx2/qa/complex/framework/testdocuments/empty.rdf +++ b/sfx2/qa/complex/sfx2/testdocuments/empty.rdf diff --git a/sfx2/qa/complex/framework/DialogThread.java b/sfx2/qa/complex/sfx2/tools/DialogThread.java index 7151ccbb292d..e67e65f218db 100644 --- a/sfx2/qa/complex/framework/DialogThread.java +++ b/sfx2/qa/complex/sfx2/tools/DialogThread.java @@ -24,7 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.framework.DocHelper; +package complex.sfx2.tools; import com.sun.star.beans.PropertyValue; import com.sun.star.frame.XController; @@ -37,9 +37,6 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.util.URL; import com.sun.star.util.XURLTransformer; -import java.lang.Thread; - - /** * This class opens a given dialog in a separate Thread by dispatching an url * @@ -55,21 +52,17 @@ public class DialogThread extends Thread { this.m_url = url; } + @Override public void run() { - XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, - m_xDoc); + XModel aModel = UnoRuntime.queryInterface( XModel.class, m_xDoc ); XController xController = aModel.getCurrentController(); //Opening Dialog try { - XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface( - XDispatchProvider.class, - xController.getFrame()); - XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( - XURLTransformer.class, - m_xMSF.createInstance( - "com.sun.star.util.URLTransformer")); + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, xController.getFrame() ); + XURLTransformer xParser = UnoRuntime.queryInterface( XURLTransformer.class, + m_xMSF.createInstance( "com.sun.star.util.URLTransformer" ) ); // Because it's an in/out parameter // we must use an array of URL objects. diff --git a/sfx2/qa/complex/framework/TestDocument.java b/sfx2/qa/complex/sfx2/tools/TestDocument.java index 8cc6ef7756b1..120dca978bba 100644 --- a/sfx2/qa/complex/framework/TestDocument.java +++ b/sfx2/qa/complex/sfx2/tools/TestDocument.java @@ -25,12 +25,12 @@ * ************************************************************************/ -package complex.framework; +package complex.sfx2.tools; import java.io.File; import org.openoffice.test.OfficeFileUrl; -final class TestDocument { +public final class TestDocument { public static String getUrl(String name) { return OfficeFileUrl.getAbsolute(new File("testdocuments", name)); } diff --git a/sfx2/qa/complex/framework/WriterHelper.java b/sfx2/qa/complex/sfx2/tools/WriterHelper.java index d3f19703bb9d..4767028572bb 100644 --- a/sfx2/qa/complex/framework/WriterHelper.java +++ b/sfx2/qa/complex/sfx2/tools/WriterHelper.java @@ -24,7 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -package complex.framework.DocHelper; +package complex.sfx2.tools; import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; @@ -40,7 +40,6 @@ import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XCloseable; -import complex.framework.DocHelper.DialogThread; import java.io.PrintWriter; import util.AccessibilityTools; @@ -104,13 +103,12 @@ public class WriterHelper { if (createButton.length() > 1) { XExtendedToolkit tk = getToolkit(); - AccessibilityTools at = new AccessibilityTools(); Object atw = tk.getActiveTopWindow(); XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, atw); - XAccessible xRoot = at.getAccessibleObject(xWindow); - XAccessibleContext buttonContext = at.getAccessibleObjectForRole( + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + XAccessibleContext buttonContext = AccessibilityTools.getAccessibleObjectForRole( xRoot, AccessibleRole.PUSH_BUTTON, createButton); @@ -154,28 +152,26 @@ public class WriterHelper { public XTextDocument DocByAutopilot(XMultiServiceFactory msf, int[] indexes, boolean destroyLocal, String bName) { - XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF); + XTextDocument xTextDoc = WriterTools.createTextDoc(m_xMSF); Object toolkit = null; try { toolkit = msf.createInstance("com.sun.star.awt.Toolkit"); } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(); + e.printStackTrace( System.err ); } XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, toolkit); shortWait(); - AccessibilityTools at = new AccessibilityTools(); - Object atw = tk.getActiveTopWindow(); XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, atw); - XAccessible xRoot = at.getAccessibleObject(xWindow); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); - XAccessibleContext ARoot = at.getAccessibleObjectForRole(xRoot, + XAccessibleContext ARoot = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.MENU_BAR); XAccessibleSelection sel = UnoRuntime.queryInterface(XAccessibleSelection.class, ARoot); @@ -196,11 +192,11 @@ public class WriterHelper { xWindow = UnoRuntime.queryInterface(XWindow.class, atw); - xRoot = at.getAccessibleObject(xWindow); + xRoot = AccessibilityTools.getAccessibleObject(xWindow); //at.printAccessibleTree(new PrintWriter(System.out),xRoot); - XAccessibleAction action = UnoRuntime.queryInterface(XAccessibleAction.class, at.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, bName)); + XAccessibleAction action = UnoRuntime.queryInterface(XAccessibleAction.class, AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, bName)); try { action.doAccessibleAction(0); @@ -213,11 +209,11 @@ public class WriterHelper { xWindow = UnoRuntime.queryInterface(XWindow.class, atw); - xRoot = at.getAccessibleObject(xWindow); + xRoot = AccessibilityTools.getAccessibleObject(xWindow); - at.printAccessibleTree(new PrintWriter(System.out),xRoot); + AccessibilityTools.printAccessibleTree(new PrintWriter(System.out),xRoot); - action = UnoRuntime.queryInterface(XAccessibleAction.class, at.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, "Yes")); + action = UnoRuntime.queryInterface(XAccessibleAction.class, AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, "Yes")); try { if (action != null) action.doAccessibleAction(0); @@ -231,7 +227,7 @@ public class WriterHelper { XTextDocument returnDoc = UnoRuntime.queryInterface(XTextDocument.class, xDesktop.getCurrentComponent()); if (destroyLocal) { - closeDoc(xLocalDoc); + closeDoc(xTextDoc); } return returnDoc; @@ -259,7 +255,7 @@ public class WriterHelper { toolkit = m_xMSF.createInstance("com.sun.star.awt.Toolkit"); } catch (com.sun.star.uno.Exception e) { System.out.println("Couldn't get toolkit"); - e.printStackTrace(); + e.printStackTrace( System.err ); } XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, toolkit); @@ -277,7 +273,7 @@ public class WriterHelper { desk = m_xMSF.createInstance("com.sun.star.frame.Desktop"); } catch (com.sun.star.uno.Exception e) { System.out.println("Couldn't get desktop"); - e.printStackTrace(); + e.printStackTrace( System.err ); } XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desk); diff --git a/sfx2/qa/complex/sfx2/undo/CalcDocumentTest.java b/sfx2/qa/complex/sfx2/undo/CalcDocumentTest.java new file mode 100755 index 000000000000..34825fdbada9 --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/CalcDocumentTest.java @@ -0,0 +1,96 @@ +package complex.sfx2.undo; + +import org.openoffice.test.tools.SpreadsheetDocument; +import com.sun.star.table.XCellRange; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCell; +import com.sun.star.uno.UnoRuntime; +import org.openoffice.test.tools.DocumentType; +import static org.junit.Assert.*; + +/** + * implements the {@link DocumentTest} interface on top of a spreadsheet document + * @author frank.schoenheit@oracle.com + */ +public class CalcDocumentTest extends DocumentTestBase +{ + public CalcDocumentTest( final XMultiServiceFactory i_orb ) throws Exception + { + super( i_orb, DocumentType.CALC ); + } + + public String getDocumentDescription() + { + return "spreadsheet document"; + } + + public void initializeDocument() throws com.sun.star.uno.Exception + { + final XCell cellA1 = getCellA1(); + cellA1.setValue( INIT_VALUE ); + assertEquals( "initializing the cell value didn't work", cellA1.getValue(), INIT_VALUE, 0 ); + + XCellRange range = UnoRuntime.queryInterface( XCellRange.class, + ((SpreadsheetDocument)m_document).getSheet(0) ); + + for ( int i=0; i<12; ++i ) + { + XCell cell = range.getCellByPosition( 1, i ); + cell.setFormula( "" ); + } + } + + public void doSingleModification() throws com.sun.star.uno.Exception + { + final XCell cellA1 = getCellA1(); + assertEquals( "initial cell value not as expected", INIT_VALUE, cellA1.getValue(), 0 ); + cellA1.setValue( MODIFIED_VALUE ); + assertEquals( "modified cell value not as expected", MODIFIED_VALUE, cellA1.getValue(), 0 ); + } + + public void verifyInitialDocumentState() throws com.sun.star.uno.Exception + { + final XCell cellA1 = getCellA1(); + assertEquals( "cell A1 doesn't have its initial value", INIT_VALUE, cellA1.getValue(), 0 ); + + XCellRange range = UnoRuntime.queryInterface( XCellRange.class, + ((SpreadsheetDocument)m_document).getSheet(0) ); + for ( int i=0; i<12; ++i ) + { + final XCell cell = range.getCellByPosition( 1, i ); + assertEquals( "Cell B" + (i+1) + " not having its initial value (an empty string)", "", cell.getFormula() ); + } + } + + public void verifySingleModificationDocumentState() throws com.sun.star.uno.Exception + { + final XCell cellA1 = getCellA1(); + assertEquals( "cell A1 doesn't have the value which we gave it", MODIFIED_VALUE, cellA1.getValue(), 0 ); + } + + public int doMultipleModifications() throws com.sun.star.uno.Exception + { + XCellRange range = UnoRuntime.queryInterface( XCellRange.class, + ((SpreadsheetDocument)m_document).getSheet(0) ); + + final String[] months = new String[] { + "January", "February", "March", "April", "May", "June", "July", "August", + "September", "October", "November", "December" }; + for ( int i=0; i<12; ++i ) + { + final XCell cell = range.getCellByPosition( 1, i ); + cell.setFormula( months[i] ); + } + return 12; + } + + private XCell getCellA1() throws com.sun.star.uno.Exception + { + XCellRange range = UnoRuntime.queryInterface( XCellRange.class, + ((SpreadsheetDocument)m_document).getSheet(0) ); + return range.getCellByPosition( 0, 0 ); + } + + private static final double INIT_VALUE = 100.0; + private static final double MODIFIED_VALUE = 200.0; +} diff --git a/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java new file mode 100755 index 000000000000..7c8421ec6e5b --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java @@ -0,0 +1,277 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + *************************************************************************/ + +package complex.sfx2.undo; + +import com.sun.star.chart2.XAxis; +import com.sun.star.chart2.XCoordinateSystem; +import com.sun.star.chart2.XCoordinateSystemContainer; +import com.sun.star.awt.Size; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart2.XChartDocument; +import com.sun.star.chart2.XDiagram; +import com.sun.star.container.XIndexAccess; +import com.sun.star.document.UndoFailedException; +import com.sun.star.document.XUndoAction; +import com.sun.star.document.XUndoManager; +import com.sun.star.document.XUndoManagerSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.embed.EmbedStates; +import com.sun.star.embed.EmbedVerbs; +import com.sun.star.embed.VerbDescriptor; +import com.sun.star.embed.WrongStateException; +import com.sun.star.embed.XEmbeddedObject; +import com.sun.star.embed.XStateChangeBroadcaster; +import com.sun.star.embed.XStateChangeListener; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.XSelectionSupplier; +import org.openoffice.test.tools.DocumentType; +import org.openoffice.test.tools.OfficeDocument; +import static org.junit.Assert.*; + +/** + * @author frank.schoenheit@oracle.com + */ +public class ChartDocumentTest implements DocumentTest +{ + public ChartDocumentTest( final XMultiServiceFactory i_orb ) throws com.sun.star.uno.Exception, InterruptedException + { + m_textDocument = OfficeDocument.blankDocument( i_orb, DocumentType.WRITER ); + + // create a OLE shape in the document + final XMultiServiceFactory factory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_textDocument.getDocument() ); + final String shapeServiceName = "com.sun.star.text.TextEmbeddedObject"; + final XPropertySet shapeProps = UnoRuntime.queryInterface( XPropertySet.class, factory.createInstance( shapeServiceName ) ); + shapeProps.setPropertyValue("CLSID", "12dcae26-281f-416f-a234-c3086127382e"); + + final XShape shape = UnoRuntime.queryInterface( XShape.class, shapeProps ); + shape.setSize( new Size( 16000, 9000 ) ); + + final XTextContent chartTextContent = UnoRuntime.queryInterface( XTextContent.class, shapeProps ); + + final XSelectionSupplier selSupplier = UnoRuntime.queryInterface( XSelectionSupplier.class, + m_textDocument.getCurrentView().getController() ); + final Object selection = selSupplier.getSelection(); + final XTextRange textRange = getAssociatedTextRange( selection ); + if ( textRange == null ) + throw new RuntimeException( "can't locate a text range" ); + + // insert the chart + textRange.getText().insertTextContent(textRange, chartTextContent, false); + + // retrieve the chart model + XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, shapeProps.getPropertyValue( "Model" ) ); + m_chartDocument = new OfficeDocument( i_orb, chartDoc ); + + // actually activate the object + final XEmbeddedObject embeddedChart = UnoRuntime.queryInterface( XEmbeddedObject.class, + shapeProps.getPropertyValue( "EmbeddedObject" ) ); + embeddedChart.doVerb( EmbedVerbs.MS_OLEVERB_SHOW ); + + final int state = embeddedChart.getCurrentState(); + if ( state != EmbedStates.UI_ACTIVE ) + fail( "unable to activate the embedded chart" ); + } + + public String getDocumentDescription() + { + return "chart document"; + } + + public void initializeDocument() throws com.sun.star.uno.Exception + { + final XPropertySet wallProperties = impl_getWallProperties(); + wallProperties.setPropertyValue( "FillStyle", com.sun.star.drawing.FillStyle.SOLID ); + wallProperties.setPropertyValue( "FillColor", 0x00FFFFFF ); + } + + public void closeDocument() + { + m_textDocument.close(); + } + + private XPropertySet impl_getWallProperties() + { + final XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, m_chartDocument.getDocument() ); + final XDiagram diagram = chartDoc.getFirstDiagram(); + final XPropertySet wallProperties = diagram.getWall(); + return wallProperties; + } + + private XPropertySet impl_getYAxisProperties() + { + XPropertySet axisProperties = null; + try + { + final XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, m_chartDocument.getDocument() ); + final XDiagram diagram = chartDoc.getFirstDiagram(); + final XCoordinateSystemContainer coordContainer = UnoRuntime.queryInterface( XCoordinateSystemContainer.class, diagram ); + final XCoordinateSystem[] coordSystems = coordContainer.getCoordinateSystems(); + final XCoordinateSystem coordSystem = coordSystems[0]; + final XAxis primaryYAxis = coordSystem.getAxisByDimension( 1, 0 ); + axisProperties = UnoRuntime.queryInterface( XPropertySet.class, primaryYAxis ); + } + catch ( Exception ex ) + { + fail( "internal error: could not retrieve primary Y axis properties" ); + } + return axisProperties; + } + + private XUndoManager impl_getUndoManager() + { + final XUndoManagerSupplier undoManagerSupp = UnoRuntime.queryInterface( XUndoManagerSupplier.class, m_chartDocument.getDocument() ); + final XUndoManager undoManager = undoManagerSupp.getUndoManager(); + return undoManager; + } + + public void doSingleModification() throws com.sun.star.uno.Exception + { + final XPropertySet wallProperties = impl_getWallProperties(); + + // simulate an Undo action, as long as the chart implementation doesn't add Undo actions itself + final XUndoManager undoManager = impl_getUndoManager(); + undoManager.addUndoAction( new PropertyUndoAction( wallProperties, "FillColor", 0xCCFF44 ) ); + // (the UndoAction will actually set the property value) + } + + public void verifyInitialDocumentState() throws com.sun.star.uno.Exception + { + final XPropertySet wallProperties = impl_getWallProperties(); + assertEquals( 0x00FFFFFF, ((Integer)wallProperties.getPropertyValue( "FillColor" )).intValue() ); + } + + public void verifySingleModificationDocumentState() throws com.sun.star.uno.Exception + { + final XPropertySet wallProperties = impl_getWallProperties(); + assertEquals( 0xCCFF44, ((Integer)wallProperties.getPropertyValue( "FillColor" )).intValue() ); + } + + public int doMultipleModifications() throws com.sun.star.uno.Exception + { + final XPropertySet axisProperties = impl_getYAxisProperties(); + + final XUndoManager undoManager = impl_getUndoManager(); + undoManager.addUndoAction( new PropertyUndoAction( axisProperties, "LineWidth", 300 ) ); + undoManager.addUndoAction( new PropertyUndoAction( axisProperties, "LineColor", 0x000000 ) ); + + return 2; + } + + public OfficeDocument getDocument() + { + return m_chartDocument; + } + + private XTextRange getAssociatedTextRange( final Object i_object ) throws WrappedTargetException, IndexOutOfBoundsException + { + // possible cases: + // 1. a container of other objects - e.g. selection of 0 to n text portions, or 1 to n drawing objects + final XIndexAccess indexer = UnoRuntime.queryInterface( XIndexAccess.class, i_object ); + if ((indexer != null) && indexer.getCount() > 0) { + final int count = indexer.getCount(); + for (int i = 0; i < count; ++i) { + final XTextRange range = getAssociatedTextRange( indexer.getByIndex(i) ); + if (range != null) { + return range; + } + } + } + // 2. another TextContent, having an anchor we can use + final XTextContent textContent = UnoRuntime.queryInterface(XTextContent.class, i_object); + if (textContent != null) { + final XTextRange range = textContent.getAnchor(); + if (range != null) { + return range; + } + } + + // an object which supports XTextRange directly + final XTextRange range = UnoRuntime.queryInterface(XTextRange.class, i_object); + if (range != null) { + return range; + } + + return null; + } + + private static class PropertyUndoAction implements XUndoAction + { + PropertyUndoAction( final XPropertySet i_component, final String i_propertyName, final Object i_newValue ) throws com.sun.star.uno.Exception + { + m_component = i_component; + m_propertyName = i_propertyName; + m_newValue = i_newValue; + + m_oldValue = i_component.getPropertyValue( m_propertyName ); + i_component.setPropertyValue( m_propertyName, m_newValue ); + } + + public String getTitle() + { + return "some dummy Undo Action"; + } + + public void undo() throws UndoFailedException + { + try + { + m_component.setPropertyValue( m_propertyName, m_oldValue ); + } + catch ( com.sun.star.uno.Exception ex ) + { + throw new UndoFailedException( "", this, ex ); + } + } + + public void redo() throws UndoFailedException + { + try + { + m_component.setPropertyValue( m_propertyName, m_newValue ); + } + catch ( com.sun.star.uno.Exception ex ) + { + throw new UndoFailedException( "", this, ex ); + } + } + + private final XPropertySet m_component; + private final String m_propertyName; + private final Object m_oldValue; + private final Object m_newValue; + } + + private final OfficeDocument m_textDocument; + private final OfficeDocument m_chartDocument; +} diff --git a/sfx2/qa/complex/sfx2/undo/DocumentTest.java b/sfx2/qa/complex/sfx2/undo/DocumentTest.java new file mode 100755 index 000000000000..d6de90884673 --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/DocumentTest.java @@ -0,0 +1,61 @@ +package complex.sfx2.undo; + +import org.openoffice.test.tools.OfficeDocument; + +/** + * wrapper around an OfficeDocument, for running a standardized test procedure (related do Undo functionality) + * on the document. + * + * @author frank.schoenheit@oracle.com + */ +public interface DocumentTest +{ + /** + * returns a human-readable description for the document/type which the tests operates on + */ + public String getDocumentDescription(); + + /** + * initializes the document to a state where the subsequent tests can be ran + */ + public void initializeDocument() throws com.sun.star.uno.Exception; + + /** + * closes the document which the test is based on + */ + public void closeDocument(); + + /** + * does a simple modification to the document, which results in one Undo action being auto-generated + * by the OOo implementation + */ + public void doSingleModification() throws com.sun.star.uno.Exception; + + /** + * verifies the document is in the same state as after {@link #initializeDocument} + */ + public void verifyInitialDocumentState() throws com.sun.star.uno.Exception; + + /** + * verifies the document is in the state as expected after {@link #doSingleModification} + * @throws com.sun.star.uno.Exception + */ + public void verifySingleModificationDocumentState() throws com.sun.star.uno.Exception; + + /** + * does multiple modifications do the document, which would normally result in multiple Undo actions. + * + * The test framework will encapsulate the call into an {@link XUndoManager.enterUndoContext()} and + * {@link XUndoManager.leaveUndoContext()} call. + * + * @return + * the number of modifications done to the document. The caller assumes (and asserts) that the number + * of actions on the Undo stack equals this number. + */ + public int doMultipleModifications() throws com.sun.star.uno.Exception; + + /** + * returns the document which the test operates on + */ + public OfficeDocument getDocument(); +} diff --git a/sfx2/qa/complex/sfx2/undo/DocumentTestBase.java b/sfx2/qa/complex/sfx2/undo/DocumentTestBase.java new file mode 100755 index 000000000000..11adc80c2e85 --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/DocumentTestBase.java @@ -0,0 +1,29 @@ +package complex.sfx2.undo; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Exception; +import org.openoffice.test.tools.DocumentType; +import org.openoffice.test.tools.OfficeDocument; + +/** + * @author frank.schoenheit@oracle.com + */ +abstract class DocumentTestBase implements DocumentTest +{ + DocumentTestBase( final XMultiServiceFactory i_orb, final DocumentType i_docType ) throws Exception + { + m_document = OfficeDocument.blankDocument( i_orb, i_docType ); + } + + public OfficeDocument getDocument() + { + return m_document; + } + + public void closeDocument() + { + m_document.close(); + } + + protected final OfficeDocument m_document; +} diff --git a/sfx2/source/config/config.src b/sfx2/qa/complex/sfx2/undo/DrawDocumentTest.java index cb3259e09ad0..d98e1372dea5 100644..100755 --- a/sfx2/source/config/config.src +++ b/sfx2/qa/complex/sfx2/undo/DrawDocumentTest.java @@ -1,5 +1,4 @@ /************************************************************************* - * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. @@ -23,13 +22,25 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * - ************************************************************************/ + *************************************************************************/ + +package complex.sfx2.undo; -//#include "config.hrc" -//#include "sfxlocal.hrc" -#include <sfx2/sfx.hrc> +import com.sun.star.lang.XMultiServiceFactory; +import org.openoffice.test.tools.DocumentType; -String STR_FILTERNAME_CFG +/** + * @author frank.schoenheit@oracle.com + */ +public class DrawDocumentTest extends DrawingOrPresentationDocumentTest { - Text [ en-US ] = "Configuration" ; -}; + public DrawDocumentTest( XMultiServiceFactory i_orb ) throws com.sun.star.uno.Exception + { + super( i_orb, DocumentType.DRAWING ); + } + + public String getDocumentDescription() + { + return "drawing document"; + } +} diff --git a/sfx2/qa/complex/sfx2/undo/DrawingOrPresentationDocumentTest.java b/sfx2/qa/complex/sfx2/undo/DrawingOrPresentationDocumentTest.java new file mode 100755 index 000000000000..916e1908e93d --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/DrawingOrPresentationDocumentTest.java @@ -0,0 +1,196 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package complex.sfx2.undo; + +import com.sun.star.awt.Rectangle; +import com.sun.star.document.XUndoManager; +import com.sun.star.document.XUndoManagerSupplier; +import com.sun.star.document.XUndoAction; +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.CircleKind; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import org.openoffice.test.tools.DocumentType; +import static org.junit.Assert.*; + +/** + * implements the {@link DocumentTest} interface on top of a drawing document + * @author frank.schoenheit@oracle.com + */ +public abstract class DrawingOrPresentationDocumentTest extends DocumentTestBase +{ + public DrawingOrPresentationDocumentTest( XMultiServiceFactory i_orb, final DocumentType i_docType ) throws com.sun.star.uno.Exception + { + super( i_orb, i_docType ); + } + + public void initializeDocument() throws com.sun.star.uno.Exception + { + // remove all shapes - Impress has two default shapes in a new doc; just get rid of them + final XShapes firstPageShapes = getFirstPageShapes(); + while ( firstPageShapes.getCount() > 0 ) + firstPageShapes.remove( UnoRuntime.queryInterface( XShape.class, firstPageShapes.getByIndex( 0 ) ) ); + } + + public void doSingleModification() throws com.sun.star.uno.Exception + { + // add a simple centered shape to the first page + Rectangle pagePlayground = impl_getFirstPagePlayground(); + impl_createCircleShape( + ( pagePlayground.X + ( pagePlayground.Width - BIG_CIRCLE_SIZE ) / 2 ), + ( pagePlayground.Y + ( pagePlayground.Height - BIG_CIRCLE_SIZE ) / 2 ), + BIG_CIRCLE_SIZE, + FILL_COLOR + ); + } + + public void verifyInitialDocumentState() throws com.sun.star.uno.Exception + { + final XShapes firstPageShapes = getFirstPageShapes(); + assertEquals( "there should be no shapes at all", 0, firstPageShapes.getCount() ); + } + + public void verifySingleModificationDocumentState() throws com.sun.star.uno.Exception + { + final XShapes firstPageShapes = getFirstPageShapes(); + assertEquals( "there should be one shape, not more, not less", 1, firstPageShapes.getCount() ); + + final Object shape = firstPageShapes.getByIndex(0); + verifyShapeGeometry( shape, BIG_CIRCLE_SIZE, BIG_CIRCLE_SIZE ); + final XPropertySet shapeProps = UnoRuntime.queryInterface( XPropertySet.class, shape ); + assertEquals( "wrong circle tpye", CIRCLE_TYPE.getValue(), ((CircleKind)shapeProps.getPropertyValue( "CircleKind" )).getValue() ); + //assertEquals( "wrong circle fill color", FILL_COLOR, ((Integer)shapeProps.getPropertyValue( "FillColor" )).intValue() ); + // disable this particular check: A bug in the drawing layer API restores the FillColor to its + // default value upon re-insertion. This is issue #i115080# + } + + public int doMultipleModifications() throws com.sun.star.uno.Exception + { + // add a simple centered shape to the first page + Rectangle pagePlayground = impl_getFirstPagePlayground(); + impl_createCircleShape( + pagePlayground.X, + pagePlayground.Y, + SMALL_CIRCLE_SIZE, + ALTERNATE_FILL_COLOR + ); + impl_createCircleShape( + pagePlayground.X + pagePlayground.Width - SMALL_CIRCLE_SIZE, + pagePlayground.Y, + SMALL_CIRCLE_SIZE, + ALTERNATE_FILL_COLOR + ); + impl_createCircleShape( + pagePlayground.X, + pagePlayground.Y + pagePlayground.Height - SMALL_CIRCLE_SIZE, + SMALL_CIRCLE_SIZE, + ALTERNATE_FILL_COLOR + ); + impl_createCircleShape( + pagePlayground.X + pagePlayground.Width - SMALL_CIRCLE_SIZE, + pagePlayground.Y + pagePlayground.Height - SMALL_CIRCLE_SIZE, + SMALL_CIRCLE_SIZE, + ALTERNATE_FILL_COLOR + ); + return 4; + } + + private void impl_createCircleShape( final int i_x, final int i_y, final int i_size, final int i_color ) throws com.sun.star.uno.Exception + { + final XPropertySet shapeProps = getDocument().createInstance( "com.sun.star.drawing.EllipseShape", XPropertySet.class ); + shapeProps.setPropertyValue( "CircleKind", CIRCLE_TYPE ); + shapeProps.setPropertyValue( "FillColor", i_color ); + + final XShape shape = UnoRuntime.queryInterface( XShape.class, shapeProps ); + final Size shapeSize = new Size( i_size, i_size ); + shape.setSize( shapeSize ); + final Point shapePos = new Point( i_x, i_y ); + shape.setPosition( shapePos ); + + final XShapes pageShapes = UnoRuntime.queryInterface( XShapes.class, getFirstPageShapes() ); + pageShapes.add( shape ); + + // Sadly, Draw/Impress currently do not create Undo actions for programmatic changes to the document. + // Which renders the test here slightly useless ... unless we fake the Undo actions ourself. + final XUndoManagerSupplier suppUndoManager = UnoRuntime.queryInterface( XUndoManagerSupplier.class, getDocument().getDocument() ); + final XUndoManager undoManager = suppUndoManager.getUndoManager(); + undoManager.addUndoAction( new ShapeInsertionUndoAction( shape, pageShapes ) ); + } + + private Rectangle impl_getFirstPagePlayground() throws com.sun.star.uno.Exception + { + final XShapes firstPageShapes = getFirstPageShapes(); + final XPropertySet firstPageProps = UnoRuntime.queryInterface( XPropertySet.class, firstPageShapes ); + final int pageWidth = ((Integer)firstPageProps.getPropertyValue( "Width" )).intValue(); + final int pageHeight = ((Integer)firstPageProps.getPropertyValue( "Height" )).intValue(); + final int borderLeft = ((Integer)firstPageProps.getPropertyValue( "BorderLeft" )).intValue(); + final int borderTop = ((Integer)firstPageProps.getPropertyValue( "BorderTop" )).intValue(); + final int borderRight = ((Integer)firstPageProps.getPropertyValue( "BorderRight" )).intValue(); + final int borderBottom = ((Integer)firstPageProps.getPropertyValue( "BorderBottom" )).intValue(); + return new Rectangle( borderLeft, borderTop, pageWidth - borderLeft - borderRight, pageHeight - borderTop - borderBottom ); + } + + /** + * returns the XShapes interface of the first page of our drawing document + */ + private XShapes getFirstPageShapes() throws com.sun.star.uno.Exception + { + final XDrawPagesSupplier suppPages = UnoRuntime.queryInterface( XDrawPagesSupplier.class, getDocument().getDocument() ); + final XDrawPages pages = suppPages.getDrawPages(); + return UnoRuntime.queryInterface( XShapes.class, pages.getByIndex( 0 ) ); + } + + /** + * verifies the given shape has the given size + */ + private void verifyShapeGeometry( final Object i_shapeObject, final int i_expectedWidth, final int i_expectedHeight ) + throws com.sun.star.uno.Exception + { + final XShape shape = UnoRuntime.queryInterface( XShape.class, i_shapeObject ); + final Size shapeSize = shape.getSize(); + assertEquals( "unexpected shape width", i_expectedWidth, shapeSize.Width ); + assertEquals( "unexpected shape height", i_expectedHeight, shapeSize.Height ); + } + + private static class ShapeInsertionUndoAction implements XUndoAction + { + ShapeInsertionUndoAction( final XShape i_shape, final XShapes i_shapeCollection ) + { + m_shape = i_shape; + m_shapeCollection = i_shapeCollection; + } + + public String getTitle() + { + return "insert shape"; + } + + public void undo() + { + m_shapeCollection.remove( m_shape ); + } + + public void redo() + { + m_shapeCollection.add( m_shape ); + } + + private final XShape m_shape; + private final XShapes m_shapeCollection; + } + + private static CircleKind CIRCLE_TYPE = CircleKind.FULL; + private static int FILL_COLOR = 0xCC2244; + private static int ALTERNATE_FILL_COLOR = 0x44CC22; + private static int BIG_CIRCLE_SIZE = 5000; + private static int SMALL_CIRCLE_SIZE = 2000; +} diff --git a/sfx2/inc/sfxbasic.hxx b/sfx2/qa/complex/sfx2/undo/ImpressDocumentTest.java index ff5f097500a5..c15fc760e0c3 100644..100755 --- a/sfx2/inc/sfxbasic.hxx +++ b/sfx2/qa/complex/sfx2/undo/ImpressDocumentTest.java @@ -1,5 +1,4 @@ /************************************************************************* - * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. @@ -23,20 +22,25 @@ * <http://www.openoffice.org/license.html> * for a copy of the LGPLv3 License. * - ************************************************************************/ -#ifndef _SFXBASIC_HXX -#define _SFXBASIC_HXX - -class BasicManager; -class SbMethod; - -//------------------------------------------------------------------ - -SbMethod* SfxQueryMacro( BasicManager* pMgr, const String& rMacro ); + *************************************************************************/ -ErrCode SfxCallMacro( BasicManager* pMgr, const String& rMacro, - SbxArray *pArgs = 0, SbxValue *pRet = 0 ); +package complex.sfx2.undo; +import com.sun.star.lang.XMultiServiceFactory; +import org.openoffice.test.tools.DocumentType; -#endif +/** + * @author frank.schoenheit@oracle.com + */ +public class ImpressDocumentTest extends DrawingOrPresentationDocumentTest +{ + public ImpressDocumentTest( XMultiServiceFactory i_orb ) throws com.sun.star.uno.Exception + { + super( i_orb, DocumentType.PRESENTATION ); + } + public String getDocumentDescription() + { + return "presentation document"; + } +} diff --git a/sfx2/qa/complex/sfx2/undo/WriterDocumentTest.java b/sfx2/qa/complex/sfx2/undo/WriterDocumentTest.java new file mode 100755 index 000000000000..702fb85ebb11 --- /dev/null +++ b/sfx2/qa/complex/sfx2/undo/WriterDocumentTest.java @@ -0,0 +1,104 @@ +package complex.sfx2.undo; + +import com.sun.star.text.XTextRange; +import com.sun.star.beans.XPropertySet; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import org.openoffice.test.tools.DocumentType; +import static org.junit.Assert.*; + +/** + * implements the {@link DocumentTest} interface on top of a spreadsheet document + * @author frank.schoenheit@oracle.com + */ +public class WriterDocumentTest extends DocumentTestBase +{ + public WriterDocumentTest( final XMultiServiceFactory i_orb ) throws com.sun.star.uno.Exception + { + super( i_orb, DocumentType.WRITER ); + } + + public String getDocumentDescription() + { + return "text document"; + } + + public void initializeDocument() throws com.sun.star.uno.Exception + { + // TODO? + } + + public void doSingleModification() throws com.sun.star.uno.Exception + { + final XTextDocument textDoc = UnoRuntime.queryInterface( XTextDocument.class, getDocument().getDocument() ); + final XText docText = textDoc.getText(); + docText.setString( s_blindText ); + } + + public void verifyInitialDocumentState() throws com.sun.star.uno.Exception + { + final XTextDocument textDoc = UnoRuntime.queryInterface( XTextDocument.class, getDocument().getDocument() ); + final XText docText = textDoc.getText(); + assertEquals( "document should be empty", "", docText.getString() ); + } + + public void verifySingleModificationDocumentState() throws com.sun.star.uno.Exception + { + final XTextDocument textDoc = UnoRuntime.queryInterface( XTextDocument.class, getDocument().getDocument() ); + final XText docText = textDoc.getText(); + assertEquals( "blind text not found", s_blindText, docText.getString() ); + } + + public int doMultipleModifications() throws com.sun.star.uno.Exception + { + final XTextDocument textDoc = UnoRuntime.queryInterface( XTextDocument.class, getDocument().getDocument() ); + final XText docText = textDoc.getText(); + + int expectedUndoActions = 0; + + // create a cursor + final XTextCursor cursor = docText.createTextCursor(); + + // create a table + final XTextTable textTable = UnoRuntime.queryInterface( XTextTable.class, + getDocument().createInstance( "com.sun.star.text.TextTable" ) ); + textTable.initialize( 3, 3 ); + final XPropertySet tableProps = UnoRuntime.queryInterface( XPropertySet.class, textTable ); + tableProps.setPropertyValue( "BackColor", 0xCCFF44 ); + + // insert the table into the doc + docText.insertTextContent( cursor, textTable, false ); + ++expectedUndoActions; //FIXME this will create 2 actions! currently the event is sent for every individual action; should it be sent for top-level actions only? how many internal actions are created is an implementation detail! + ++expectedUndoActions; + + // write some content into the center cell + final XCellRange cellRange = UnoRuntime.queryInterface( XCellRange.class, textTable ); + final XCell centerCell = cellRange.getCellByPosition( 1, 1 ); + final XTextRange cellText = UnoRuntime.queryInterface( XTextRange.class, centerCell ); + cellText.setString( "Undo Manager API Test" ); + ++expectedUndoActions; + + // give it another color + final XPropertySet cellProps = UnoRuntime.queryInterface( XPropertySet.class, centerCell ); + cellProps.setPropertyValue( "BackColor", 0x44CCFF ); + ++expectedUndoActions; + + return expectedUndoActions; + } + + private static final String s_blindText = + "Lorem ipsum dolor. Sit amet penatibus. A cum turpis. Aenean ac eu. " + + "Ligula est urna nulla vestibulum ullamcorper. Nec sit in amet tincidunt mus. " + + "Tellus sagittis mi. Suscipit cursus in vestibulum in eros ipsum felis cursus lectus " + + "nunc quis condimentum in risus nec wisi aenean luctus hendrerit magna habitasse commodo orci. " + + "Nisl etiam quis. Vestibulum justo eleifend aliquet luctus sed turpis volutpat ullamcorper " + + "aliquam penatibus sagittis pede tincidunt egestas. Nibh massa lectus. Sem mattis purus morbi " + + "scelerisque turpis donec urna phasellus. Quis at lacus. Viverra mauris mollis. " + + "Dolor tincidunt condimentum."; +} diff --git a/sfx2/qa/complex/tests.sce b/sfx2/qa/complex/tests.sce deleted file mode 100644 index c38852927ede..000000000000 --- a/sfx2/qa/complex/tests.sce +++ /dev/null @@ -1,3 +0,0 @@ --o complex.framework.DocumentMetaData --o complex.framework.DocumentMetadataAccessTest -#-o complex.framework.CheckGlobalEventBroadcaster_writer1 diff --git a/sfx2/qa/cppunit/makefile.mk b/sfx2/qa/cppunit/makefile.mk new file mode 100644 index 000000000000..b53a04ec43f9 --- /dev/null +++ b/sfx2/qa/cppunit/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# 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 +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ=../.. +PRJNAME=sfx2 +TARGET=qa_cppunit + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +#building with stlport, but cppunit was not built with stlport +.IF "$(USE_SYSTEM_STL)"!="YES" +.IF "$(SYSTEM_CPPUNIT)"=="YES" +CFLAGSCXX+=-DADAPT_EXT_STL +.ENDIF +.ENDIF + +CFLAGSCXX += $(CPPUNIT_CFLAGS) +DLLPRE = # no leading "lib" on .so files + +# --- Libs --------------------------------------------------------- + +SHL1OBJS= \ + $(SLO)/test_metadatable.obj \ + + +SHL1STDLIBS= \ + $(CPPUNITLIB) \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VCLLIB) \ + $(SFXLIB) \ + + +SHL1TARGET= test_metadatable +SHL1RPATH = NONE +SHL1IMPLIB= i$(SHL1TARGET) +# SHL1DEF= $(MISC)/$(SHL1TARGET).def +DEF1NAME=$(SHL1TARGET) +# DEF1EXPORTFILE= export.exp +SHL1VERSIONMAP= version.map + +# --- All object files --------------------------------------------- + +SLOFILES= \ + $(SHL1OBJS) \ + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : _cppunit.mk + +.END diff --git a/sfx2/qa/unoapi/makefile.mk b/sfx2/qa/unoapi/makefile.mk new file mode 100644 index 000000000000..ea91ba4d1c44 --- /dev/null +++ b/sfx2/qa/unoapi/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# 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 +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../.. +PRJNAME = sfx2 +TARGET = qa_unoapi + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/sfx2/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sfx2/sdi/docslots.sdi b/sfx2/sdi/docslots.sdi index d16239535193..0e4a302d9d13 100644 --- a/sfx2/sdi/docslots.sdi +++ b/sfx2/sdi/docslots.sdi @@ -171,11 +171,6 @@ interface OfficeDocument : Document [ StateMethod = StateProps_Impl ; ] - SID_PLAYMACRO // ole(no) api(final/play/norec) - [ - ExecMethod = ExecProps_Impl ; - StateMethod = StateProps_Impl ; - ] SID_VERSION [ ExecMethod = ExecFile_Impl; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index aadd57185880..a9c5ca6e7330 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4635,31 +4635,6 @@ SfxVoidItem PickList SID_PICKLIST ] //-------------------------------------------------------------------------- -SfxBoolItem PlayMacro SID_PLAYMACRO -(SfxStringItem Statement SID_STATEMENT,SfxBoolItem Asynchron SID_ASYNCHRON) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - NoRecord; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_MACRO; -] - -//-------------------------------------------------------------------------- SfxBoolItem PlugInsActive SID_PLUGINS_ACTIVE [ @@ -5238,31 +5213,6 @@ SfxVoidItem RunBasic SID_BASICRUN ] //-------------------------------------------------------------------------- -SfxVoidItem RunStarWriter SID_STARTSW -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_APPLICATION; -] - -//-------------------------------------------------------------------------- SfxBoolItem Save SID_SAVEDOC (SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem Author SID_DOCINFO_AUTHOR) [ @@ -6570,31 +6520,6 @@ SfxVoidItem BasicIDEShowWindow SID_BASICIDE_SHOWWINDOW ] //-------------------------------------------------------------------------- -SfxVoidItem ToolsMacroEdit SID_EDITMACRO -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = TRUE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_MACRO; -] - -//-------------------------------------------------------------------------- SfxVoidItem Undo SID_UNDO ( SfxUInt16Item Undo SID_UNDO ) [ diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 727d9f17c493..303586762ac2 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -41,6 +41,8 @@ #include <tools/simplerm.hxx> #include <tools/config.hxx> #include <basic/basrdll.hxx> +#include <basic/sbmeth.hxx> +#include <basic/sbmod.hxx> #include <svtools/asynclink.hxx> #include <svl/stritem.hxx> #include <vcl/sound.hxx> @@ -375,6 +377,8 @@ SfxApplication::SfxApplication() SfxApplication::~SfxApplication() { + OSL_ENSURE( GetObjectShells_Impl().Count() == 0, "Memory leak: some object shells were not removed!" ); + Broadcast( SfxSimpleHint(SFX_HINT_DYING) ); SfxModule::DestroyModules_Impl(); @@ -829,3 +833,7 @@ void SfxApplication::MacroOrganizer( INT16 nTabId ) pSymbol( nTabId ); } +ErrCode SfxApplication::CallBasic( const String& rCode, BasicManager* pMgr, SbxArray* pArgs, SbxValue* pRet ) +{ + return pMgr->ExecuteMacro( rCode, pArgs, pRet); +} diff --git a/sfx2/source/appl/app.hrc b/sfx2/source/appl/app.hrc index dca172269443..ff01fd358d4d 100644 --- a/sfx2/source/appl/app.hrc +++ b/sfx2/source/appl/app.hrc @@ -32,11 +32,6 @@ // #defines ***************************************************************** #define ACC_IBM (RID_SFX_APP_START+2) -#define MSG_ERR_WRITE_CFG (RID_SFX_APP_START+2) -#define MSG_ERR_READ_CFG (RID_SFX_APP_START+3) -#define MSG_ERR_OPEN_CFG (RID_SFX_APP_START+4) -#define MSG_ERR_FILETYPE_CFG (RID_SFX_APP_START+5) -#define MSG_ERR_VERSION_CFG (RID_SFX_APP_START+6) #define MSG_ERR_NO_WEBBROWSER_FOUND (RID_SFX_APP_START+7) // Note: no longer in use @@ -45,101 +40,22 @@ #define MSG_ISPRINTING_QUERYABORT (RID_SFX_APP_START+9) #define MSG_CANT_QUIT (RID_SFX_APP_START+10) #define STR_ISMODIFIED (RID_SFX_APP_START+11) -#define STR_AUTOSAVE (RID_SFX_APP_START+12) -#define STR_MAIL (RID_SFX_APP_START+13) -#define MSG_ERR_WRITE_SBL (RID_SFX_APP_START+14) -#define MSG_IS_SERVER (RID_SFX_APP_START+15) - -#define STR_RESEXCEPTION (RID_SFX_APP_START+21) -#define STR_SYSRESEXCEPTION (RID_SFX_APP_START+22) -#define STR_DOUBLEEXCEPTION (RID_SFX_APP_START+23) -#define STR_RESWARNING (RID_SFX_APP_START+24) -#define STR_ERR_NOTEMPLATE (RID_SFX_APP_START+27) -#define STR_RECOVER_TITLE (RID_SFX_APP_START+28) -#define STR_RECOVER_QUERY (RID_SFX_APP_START+29) -#define STR_RECOVER_PREPARED (RID_SFX_APP_START+30) -#define MSG_ERR_SOINIT (RID_SFX_APP_START+31) - -#define MSG_IOERR_FILE_NOT_FOUND (RID_SFX_APP_START+32) -#define MSG_IOERR_PATH_NOT_FOUND (RID_SFX_APP_START+33) -#define MSG_IOERR_TOO_MANY_OPEN_FILES (RID_SFX_APP_START+34) -#define MSG_IOERR_ACCESS_DENIED (RID_SFX_APP_START+35) -#define MSG_IOERR_INVALID_ACCESS (RID_SFX_APP_START+36) -#define MSG_IOERR_INVALID_HANDLE (RID_SFX_APP_START+37) -#define MSG_IOERR_CANNOT_MAKE (RID_SFX_APP_START+38) -#define MSG_IOERR_SHARING (RID_SFX_APP_START+39) -#define MSG_IOERR_INVALID_PARAMETER (RID_SFX_APP_START+40) -#define MSG_IOERR_GENERAL (RID_SFX_APP_START+41) #define RID_FULLSCREENTOOLBOX (RID_SFX_APP_START+42) #define RID_RECORDINGTOOLBOX (RID_SFX_APP_START+43) #define RID_ENVTOOLBOX (RID_SFX_APP_START+44) #define STR_QUITAPP (RID_SFX_APP_START+59) -#define STR_EXITANDRETURN (RID_SFX_APP_START+60) -#define STR_ERR_NOFILE (RID_SFX_APP_START+61) -#define STR_EXTHELPSTATUS (RID_SFX_APP_START+62) - -#define STR_ADDRESS_NAME (RID_SFX_APP_START+65) #define RID_STR_HLPFILENOTEXIST (RID_SFX_APP_START+68) -#define RID_STR_HLPAPPNOTSTARTED (RID_SFX_APP_START+69) - -#define STR_NODOUBLE (RID_SFX_APP_START+75) -#define STR_NOPRINTER (RID_SFX_APP_START+76) - -#define MSG_SIGNAL (RID_SFX_APP_START+77) #define RID_STR_HELP (RID_SFX_APP_START+79) #define RID_STR_NOAUTOSTARTHELPAGENT (RID_SFX_APP_START+80) #define RID_HELPBAR (RID_SFX_APP_START+81) #define RID_SPECIALCONFIG_ERROR (RID_SFX_APP_START+82) -#define STR_MEMINFO_HEADER (RID_SFX_APP_START+84) -#define STR_MEMINFO_FOOTER (RID_SFX_APP_START+85) -#define STR_MEMINFO_OBJINFO (RID_SFX_APP_START+86) - -#define RID_PLUGIN (RID_SFX_APP_START+87) - -#define RID_WARN_POST_MAILTO (RID_SFX_APP_START+88) - -#define RID_STR_NOWELCOMESCREEN (RID_SFX_APP_START+91) - -// --> PB 2004-08-20 #i33095# -/* obsolete -#define STR_EDITOBJECT (RID_SFX_APP_START+92) -#define STR_OPENOBJECT (RID_SFX_APP_START+93) -*/ - -#define STR_CORRUPT_INSTALLATION (RID_SFX_APP_START+94) -#define IDS_SBERR_STOREREF (RID_SFX_APP_START+97) - #define CONFIG_PATH_START (RID_SFX_APP_START+98) -#define STR_KEY_ADDINS_PATH (CONFIG_PATH_START+0) -#define STR_KEY_AUTOCORRECT_DIR (CONFIG_PATH_START+1) -#define STR_KEY_GLOSSARY_PATH (CONFIG_PATH_START+2) -#define STR_KEY_BACKUP_PATH (CONFIG_PATH_START+3) -#define STR_KEY_BASIC_PATH (CONFIG_PATH_START+4) -#define STR_KEY_BITMAP_PATH (CONFIG_PATH_START+5) -#define STR_KEY_CONFIG_DIR (CONFIG_PATH_START+6) -#define STR_KEY_DICTIONARY_PATH (CONFIG_PATH_START+7) -#define STR_KEY_FAVORITES_DIR (CONFIG_PATH_START+8) -#define STR_KEY_FILTER_PATH (CONFIG_PATH_START+9) -#define STR_KEY_GALLERY_DIR (CONFIG_PATH_START+10) -#define STR_KEY_GRAPHICS_PATH (CONFIG_PATH_START+11) -#define STR_KEY_HELP_DIR (CONFIG_PATH_START+12) -#define STR_KEY_LINGUISTIC_DIR (CONFIG_PATH_START+13) -#define STR_KEY_MODULES_PATH (CONFIG_PATH_START+14) -#define STR_KEY_PALETTE_PATH (CONFIG_PATH_START+15) -#define STR_KEY_PLUGINS_PATH (CONFIG_PATH_START+16) -#define STR_KEY_STORAGE_DIR (CONFIG_PATH_START+17) -#define STR_KEY_TEMP_PATH (CONFIG_PATH_START+18) -#define STR_KEY_TEMPLATE_PATH (CONFIG_PATH_START+19) -#define STR_KEY_USERCONFIG_PATH (CONFIG_PATH_START+20) -#define STR_KEY_USERDICTIONARY_DIR (CONFIG_PATH_START+21) -#define STR_KEY_WORK_PATH (CONFIG_PATH_START+22) - #define WIN_HELPINDEX (RID_SFX_APP_START+99) #define TP_HELP_CONTENT (RID_SFX_APP_START+100) #define TP_HELP_INDEX (RID_SFX_APP_START+101) @@ -168,11 +84,6 @@ #define IMG_HELP_CONTENT_DOC_HC (RID_SFX_APP_START+125) // image -#define IMG_MISSING_1 (RID_SFX_APP_START+126) // image -#define IMG_MISSING_2 (RID_SFX_APP_START+127) // image -#define IMG_MISSING_3 (RID_SFX_APP_START+128) // image -#define IMG_MISSING_4 (RID_SFX_APP_START+129) // image - #define STR_HELP_WINDOW_TITLE (RID_SFX_APP_START+125) // string #define STR_HELP_BUTTON_INDEX_ON (RID_SFX_APP_START+126) @@ -236,8 +147,6 @@ #define RID_SECURITY_WARNING_HYPERLINK (RID_SFX_APP_START + 180) #define RID_SECURITY_WARNING_TITLE (RID_SFX_APP_START + 181) -#define RID_INVALID_URL_MSG (RID_SFX_APP_START + 182) -#define RID_INVALID_URL_TITLE (RID_SFX_APP_START + 183) #define RID_DESKTOP (RID_SFX_APP_START + 184) // #define RID_XMLSEC_WARNING_BROKENSIGNATURE (RID_SFX_APP_START + 185) diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src index f8a387bba79b..fa5a1fc1c335 100644 --- a/sfx2/source/appl/app.src +++ b/sfx2/source/appl/app.src @@ -75,60 +75,6 @@ InfoBox RID_DOCALREADYLOADED_DLG Message [ en-US ] = "Document already open." ; }; -ErrorBox RID_CANTLOADDOC_DLG -{ - Message [ en-US ] = "Cannot open document." ; -}; - -ErrorBox MSG_ERR_READ_CFG -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "Error reading configuration file." ; -}; - -ErrorBox MSG_ERR_WRITE_CFG -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "Error writing configuration file." ; -}; - -ErrorBox MSG_ERR_OPEN_CFG -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "Error opening configuration file." ; -}; - -ErrorBox MSG_ERR_FILETYPE_CFG -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "File is not a configuration file." ; -}; - -ErrorBox MSG_ERR_VERSION_CFG -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "Configuration file contains the wrong version." ; -}; - -ErrorBox MSG_ERR_WRITE_SBL -{ - BUTTONS = WB_OK ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "Error recording BASIC library in\n'@'." ; -}; - -ErrorBox MSG_SIGNAL -{ - BUTTONS = WB_YES_NO ; - DEFBUTTON = WB_DEF_YES ; - Message [ en-US ] = "An unexpected program error has occurred.\n\nDo you want to try to save your changes in all open documents before the program is terminated?" ; -}; - ErrorBox MSG_ERR_NO_WEBBROWSER_FOUND { BUTTONS = WB_OK ; @@ -141,89 +87,6 @@ Resource SID_UNKNOWN String 1 "-" ; }; -Resource BMP_SFX_COLOR -{ - ExtraData = - { - SID_NEWDOC; // 043 - SID_OPENDOC; // 044 - SID_CLOSEDOC; // 045 - SID_RELOAD; // 046 - SID_SAVEASDOC; // 047 - SID_PRINTDOC; // 051 - SID_SETUPPRINTER; // 053 - SID_QUITAPP; // 054 - SID_UNDO; // 055 - SID_REDO; // 056 - SID_REPEAT; // 057 - SID_CUT; // 058 - SID_COPY; // 059 - SID_PASTE; // 060 - SID_DELETE; // 061 - SID_SELECTALL; // 062 - SID_SAVEDOC; // 063 vormals 046 - SID_EXITANDRETURN; // 064 vormals 054 - SID_RECORDMACRO; // 095 - SID_EDITMACRO; // 096 - SID_HELPMENU; // 098 - SID_CONFIG; // 123 - SID_CONFIGTOOLBOX; // 124 - 0; - }; - Bitmap BMP_SFX_SMALL { File = "sco.bmp" ; }; - Bitmap BMP_SFX_LARGE { File = "lco.bmp" ; }; -}; - -Resource BMP_SFX_MONO -{ - ExtraData = - { - SID_NEWDOC; // 043 - SID_OPENDOC; // 044 - SID_CLOSEDOC; // 045 - SID_RELOAD; // 046 - SID_SAVEASDOC; // 047 - SID_PRINTDOC; // 051 - SID_SETUPPRINTER; // 053 - SID_QUITAPP; // 054 - SID_UNDO; // 055 - SID_REDO; // 056 - SID_REPEAT; // 057 - SID_CUT; // 058 - SID_COPY; // 059 - SID_PASTE; // 060 - SID_DELETE; // 061 - SID_SELECTALL; // 062 - SID_SAVEDOC; // 063 vormals 046 - SID_EXITANDRETURN; // 064 vormals 054 - SID_RECORDMACRO; // 095 - SID_EDITMACRO; // 096 - SID_HELPMENU; // 098 - SID_CONFIG; // 123 - SID_CONFIGTOOLBOX; // 124 - 0; - }; - Bitmap BMP_SFX_SMALL { File = "smo.bmp" ; }; - Bitmap BMP_SFX_LARGE { File = "lmo.bmp" ; }; -}; - -WarningBox RID_WARN_POST_MAILTO -{ - BUTTONS = WB_OK_CANCEL ; - DEFBUTTON = WB_DEF_OK ; - Message [ en-US ] = "A form is to be sent by e-mail.\nThis means that the receiver will get to see your e-mail address." ; -}; - -String STR_RECOVER_TITLE -{ - Text [ en-US ] = "File Recovery" ; -}; - -String STR_RECOVER_QUERY -{ - Text [ en-US ] = "Should the file \"$1\" be restored?" ; -}; - String GID_INTERN { Text [ en-US ] = "Internal" ; @@ -354,155 +217,16 @@ String GID_CONTROLS Text [ en-US ] = "Controls" ; }; -TabDialog SID_OPTIONS -{ - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 244 , 155 ) ; - Text [ en-US ] = "Options" ; - Moveable = TRUE ; - Closeable = TRUE ; - TabControl 1 - { - SVLook = TRUE ; - Pos = MAP_APPFONT ( 3 , 15 ) ; - Size = MAP_APPFONT ( 221 , 130 ) ; - PageList = - { - PageItem - { - Identifier = RID_SFXPAGE_GENERAL ; - Text [ en-US ] = "General" ; - PageResID = 256 ; - }; - PageItem - { - Identifier = RID_SFXPAGE_SAVE ; - Text [ en-US ] = "Save" ; - PageResID = 257 ; - }; - PageItem - { - Identifier = RID_SFXPAGE_PATH ; - Text [ en-US ] = "Paths" ; - PageResID = 258 ; - }; - PageItem - { - Identifier = RID_SFXPAGE_SPELL ; - Text [ en-US ] = "Spellcheck" ; - PageResID = 259 ; - }; - }; - }; -}; - InfoBox MSG_CANT_QUIT { Message [ en-US ] = "The application cannot be terminated at the moment.\nPlease wait until all print jobs and/or\nOLE actions have finished and close all dialogs." ; }; -QueryBox MSG_IS_SERVER -{ - Buttons = WB_YES_NO ; - DefButton = WB_DEF_NO ; - Message [ en-US ] = "This application is as object or print server active.\nDo you want to terminate anyway?" ; -}; - -String STR_NODOUBLE -{ - Text [ en-US ] = "%PRODUCTNAME cannot be started more than once." ; -}; - -String STR_NOPRINTER -{ - Text [ en-US ] = "Some %PRODUCTNAME functions will not work properly without a printer driver.\nPlease install a printer driver." ; -}; - String STR_ISMODIFIED { Text [ en-US ] = "Do you want to save the changes to %1?" ; }; -String STR_AUTOSAVE -{ - Text [ en-US ] = "AutoSave" ; -}; - -String STR_RESWARNING -{ - Text [ en-US ] = "Limited system resources. Please quit other applications or close some windows before continuing." ; -}; -String STR_RESEXCEPTION -{ - Text [ en-US ] = "There are files missing. Please check application setup." ; -}; - -String STR_DOUBLEEXCEPTION -{ - Text [ en-US ] = "Another error occurred during the save recovery.\nPossibly, the data could not be entirely saved." ; -}; - -String STR_SYSRESEXCEPTION -{ - Text [ en-US ] = "System resources exhausted. Please restart the application." ; -}; - -ErrorBox MSG_ERR_SOINIT -{ - Message [ en-US ] = "Error initializing object-system." ; -}; - -String MSG_IOERR_FILE_NOT_FOUND -{ - Text [ en-US ] = "The file $(FILE) doesn't exist." ; -}; - -String MSG_IOERR_PATH_NOT_FOUND -{ - Text [ en-US ] = "The path to file $(FILE) doesn't exist." ; -}; - -String MSG_IOERR_TOO_MANY_OPEN_FILES -{ - Text [ en-US ] = "The file $(FILE) could not be opened,\nbecause too many files are open.\nPlease close some files and try again." ; -}; - -String MSG_IOERR_ACCESS_DENIED -{ - Text [ en-US ] = "The file $(FILE) could not be opened due to missing access rights." ; -}; - -String MSG_IOERR_INVALID_ACCESS -{ - Text [ en-US ] = "The file $(FILE) could not be accessed." ; -}; - -String MSG_IOERR_INVALID_HANDLE -{ - Text [ en-US ] = "The file $(FILE) could not be opened due to an invalid file handle." ; -}; - -String MSG_IOERR_CANNOT_MAKE -{ - Text [ en-US ] = "The file $(FILE) could not be created." ; -}; - -String MSG_IOERR_SHARING -{ - Text [ en-US ] = "Error by shared access to $(FILE)." ; -}; - -String MSG_IOERR_INVALID_PARAMETER -{ - Text [ en-US ] = "" ; -}; - -String MSG_IOERR_GENERAL -{ - Text [ en-US ] = "General I/O error accessing $(FILE)." ; -}; - String RID_FULLSCREENTOOLBOX { Text = "" ; @@ -538,41 +262,11 @@ ToolBox RID_FULLSCREENTOOLBOX }; }; -String STR_ERR_NOTEMPLATE -{ - Text [ en-US ] = "The selected template has an incorrect format" ; -}; - -String STR_ERR_NOFILE -{ - Text [ en-US ] = "Can't open file $." ; -}; - String STR_QUITAPP { Text [ en-US ] = "E~xit" ; }; -String STR_EXITANDRETURN -{ - Text [ en-US ] = "E~xit & return to " ; -}; - -String STR_EXTHELPSTATUS -{ - Text [ en-US ] = "Select a command or click to select a theme." ; -}; - -String STR_MAIL -{ - Text [ en-US ] = "Mail" ; -}; - -String STR_ADDRESS_NAME -{ - Text [ en-US ] = "Addresses" ; -}; - String RID_STR_HELP { Text [ en-US ] = "Help" ; @@ -583,11 +277,6 @@ String RID_STR_NOAUTOSTARTHELPAGENT Text [ en-US ] = "No automatic start at 'XX'" ; }; -String RID_STR_NOWELCOMESCREEN -{ - Text [ en-US ] = "Don't display tips" ; -}; - String RID_HELPBAR { Text [ en-US ] = "Help Bar" ; @@ -653,11 +342,6 @@ String RID_STR_HLPFILENOTEXIST Text [ en-US ] = "The help file for this topic is not installed." ; }; -String RID_STR_HLPAPPNOTSTARTED -{ - Text [ en-US ] = "The help system could not be started" ; -}; - //---------------------------------------------------------------------------- String RID_ENVTOOLBOX @@ -670,129 +354,6 @@ String RID_SPECIALCONFIG_ERROR Text [ en-US ] = "An error has occurred in the special configuration.\nPlease contact your administrator." ; }; -String STR_MEMINFO_HEADER -{ -}; - -String STR_MEMINFO_FOOTER -{ - Text = "</table>" ; -}; - -String STR_MEMINFO_OBJINFO -{ - Text = "<tr><td >$(VISIBLE)</td><td>$(CACHED)</td><td>$(EXPIRE)</td><td>$(JSDIRTY)</td><td>$(JSEXEC)</td><td>$(FORBID)</td><td>$(FACTORY)</td><td>$(URL)</td><td>$(ORIGURL)</td><td>$(POSTSTRING)</td></tr>" ; -}; - -String RID_PLUGIN -{ - Text [ en-US ] = "Enable plug-ins" ; -}; - -String STR_CORRUPT_INSTALLATION -{ - Text [ en-US ] = "Important program components could not be initialized correctly.\nPlease start the setup program with the option /Repair." ; -}; - -String IDS_SBERR_STOREREF -{ - Text [ en-US ] = "Reference will not be saved: " ; -}; - -String STR_KEY_CONFIG_DIR -{ - Text [ en-US ] = "Configuration" ; -}; -String STR_KEY_WORK_PATH -{ - Text [ en-US ] = "My Documents" ; -}; -String STR_KEY_GRAPHICS_PATH -{ - Text [ en-US ] = "Graphics" ; -}; -String STR_KEY_BITMAP_PATH -{ - Text [ en-US ] = "Icons" ; -}; -String STR_KEY_BASIC_PATH -{ - Text = "BASIC" ; -}; - -String STR_KEY_PALETTE_PATH -{ - Text [ en-US ] = "Palettes" ; -}; -String STR_KEY_BACKUP_PATH -{ - Text [ en-US ] = "Backups" ; -}; -String STR_KEY_MODULES_PATH -{ - Text [ en-US ] = "Modules" ; -}; -String STR_KEY_TEMPLATE_PATH -{ - Text [ en-US ] = "Templates" ; -}; -String STR_KEY_GLOSSARY_PATH -{ - Text [ en-US ] = "AutoText" ; -}; -String STR_KEY_DICTIONARY_PATH -{ - Text [ en-US ] = "Dictionaries" ; -}; -String STR_KEY_HELP_DIR -{ - Text [ en-US ] = "Help" ; -}; -String STR_KEY_GALLERY_DIR -{ - Text [ en-US ] = "Gallery" ; -}; - -String STR_KEY_STORAGE_DIR -{ - Text [ en-US ] = "Message Storage" ; -}; -String STR_KEY_TEMP_PATH -{ - Text [ en-US ] = "Temporary files" ; -}; -String STR_KEY_PLUGINS_PATH -{ - Text [ en-US ] = "Plug-ins" ; -}; -String STR_KEY_FAVORITES_DIR -{ - Text [ en-US ] = "Folder Bookmarks" ; -}; -String STR_KEY_FILTER_PATH -{ - Text [ en-US ] = "Filters" ; -}; -String STR_KEY_ADDINS_PATH -{ - Text [ en-US ] = "Add-ins" ; -}; -String STR_KEY_USERCONFIG_PATH -{ - Text [ en-US ] = "User Configuration" ; -}; -String STR_KEY_USERDICTIONARY_DIR -{ - Text [ en-US ] = "User-defined dictionaries" ; -}; -String STR_KEY_AUTOCORRECT_DIR -{ - Text [ en-US ] = "AutoCorrect" ; -}; -String STR_KEY_LINGUISTIC_DIR -{ - Text [ en-US ] = "Writing aids" ; -}; String STR_QUICKSTART_EXIT { Text [ en-US ] = "Exit Quickstarter" ; @@ -867,17 +428,6 @@ String RID_SECURITY_WARNING_TITLE Text [ en-US ] = "Security Warning" ; }; -ErrorBox RID_INVALID_URL_MSG -{ - Buttons = WB_OK ; - Message [ en-US ] = "The URL is not valid." ; -}; - -String RID_INVALID_URL_TITLE -{ - Text = "%PRODUCTNAME %PRODUCTVERSION" ; -}; - String RID_DESKTOP { Text = "%PRODUCTNAME" ; @@ -910,26 +460,6 @@ String RID_XMLSEC_DOCUMENTSIGNED Text [ en-US ] = " (Signed)" ; }; -Image IMG_MISSING_1 -{ - ImageBitmap = Bitmap { File = "sc05539.bmp" ; }; -}; - -Image IMG_MISSING_2 -{ - ImageBitmap = Bitmap { File = "sc05700.bmp" ; }; -}; - -Image IMG_MISSING_3 -{ - ImageBitmap = Bitmap { File = "sc06302.bmp" ; }; -}; - -Image IMG_MISSING_4 -{ - ImageBitmap = Bitmap { File = "sn064.bmp" ; }; -}; - String STR_STANDARD { Text [ en-US ] = "Standard" ; diff --git a/sfx2/source/appl/appbas.cxx b/sfx2/source/appl/appbas.cxx index 7e775cbbb502..3dfe8c6a855b 100644 --- a/sfx2/source/appl/appbas.cxx +++ b/sfx2/source/appl/appbas.cxx @@ -73,7 +73,6 @@ #include "sfx2/minfitem.hxx" #include "app.hrc" #include <sfx2/evntconf.hxx> -#include <sfx2/macrconf.hxx> #include <sfx2/request.hxx> #include <sfx2/dinfdlg.hxx> #include "appdata.hxx" @@ -257,12 +256,6 @@ SbxVariable* MakeVariable( StarBASIC *pBas, SbxObject *pObject, BasicManager* SfxApplication::GetBasicManager() { -// DBG_ASSERT( pAppData_Impl->nBasicCallLevel != 0, -// "unnecessary call to GetBasicManager() - inefficient!" ); - if ( pAppData_Impl->nBasicCallLevel == 0 ) - // sicherheitshalber - EnterBasicCall(); - return BasicManagerRepository::getApplicationBasicManager( true ); } @@ -291,106 +284,6 @@ StarBASIC* SfxApplication::GetBasic() return GetBasicManager()->GetLib(0); } -//-------------------------------------------------------------------- - -FASTBOOL SfxApplication::IsInBasicCall() const -{ - return 0 != pAppData_Impl->nBasicCallLevel; -} - -//-------------------------------------------------------------------- - -void SfxApplication::EnterBasicCall() -{ - if ( 1 == ++pAppData_Impl->nBasicCallLevel ) - { - DBG_TRACE( "SfxShellObject: BASIC-on-demand" ); - - // das kann l"anger dauern, da Progress nicht geht, wenigstens Sanduhr -//(mba)/task SfxWaitCursor aWait; - - // zuerst das BASIC laden - GetBasic(); -/* - // als erstes SfxShellObject das SbxObject der SfxApplication erzeugen - SbxObject *pSbx = GetSbxObject(); - DBG_ASSERT( pSbx, "SfxShellObject: can't create SbxObject for SfxApplication" ); - - // die SbxObjects aller Module erzeugen - SfxModuleArr_Impl& rArr = GetModules_Impl(); - for ( sal_uInt16 n = 0; n < rArr.Count(); ++n ) - { - SfxModule *pMod = rArr.GetObject(n); - if ( pMod->IsLoaded() ) - { - pSbx = pMod->GetSbxObject(); - DBG_ASSERT( pSbx, "SfxModule: can't create SbxObject" ); - } - } - - // die SbxObjects aller Tasks erzeugen - for ( SfxTask *pTask = SfxTask::GetFirst(); pTask; pTask = SfxTask::GetNext( *pTask ) ) - pTask->GetSbxObject(); - - // die SbxObjects aller SfxObjectShells erzeugen (ggf. Frame-los!) - for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst( NULL, sal_False ); - pObjSh; - pObjSh = SfxObjectShell::GetNext(*pObjSh, NULL, sal_False) ) - { - // kein IP-Object oder wenn doch dann initialisiert? - SvStorageRef aStorage; - if ( !pObjSh->IsHandsOff() ) - aStorage = pObjSh->GetStorage(); - if ( !pObjSh->GetInPlaceObject() || aStorage.Is() ) - { - DBG( DbgOutf( "SfxShellObject: BASIC-on-demand for %s", - pObjSh->SfxShell::GetName().GetBuffer() ) ); - pSbx = pObjSh->GetSbxObject(); - DBG_ASSERT( pSbx, "SfxShellObject: can't create SbxObject" ); - } - } - - // die SbxObjects der SfxShells auf den Stacks der Frames erzeugen - for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(0,sal_False); - pFrame; - pFrame = SfxViewFrame::GetNext(*pFrame,0,0,sal_False) ) - { - // den Dispatcher des Frames rausholen - SfxDispatcher *pDispat = pFrame->GetDispatcher(); - pDispat->Flush(); - - // "uber alle SfxShells auf dem Stack des Dispatchers iterieren - // Frame selbst wird ausgespart, da er indirekt angezogen wird, - // sofern er ein Dokument enth"alt. - for ( sal_uInt16 nStackIdx = pDispat->GetShellLevel(*pFrame); - 0 != nStackIdx; - --nStackIdx ) - { - DBG( DbgOutf( "SfxShellObject: BASIC-on-demand for level %u", nStackIdx-1 ); ) - pSbx = pDispat->GetShell(nStackIdx - 1)->GetSbxObject(); - DBG_ASSERT( pSbx, "SfxShellObject: can't create SbxObject" ); - } - - if ( !pFrame->GetObjectShell() ) - { - DBG( DbgOutf( "SfxShellObject: BASIC-on-demand for empty frame" ); ) - pSbx = pFrame->GetSbxObject(); - DBG_ASSERT( pSbx, "SfxShellObject: can't create SbxObject" ); - } - } -*/ - // Factories anmelden -// SbxBase::AddFactory( new SfxSbxObjectFactory_Impl ); - } -} - -//-------------------------------------------------------------------- - -void SfxApplication::LeaveBasicCall() -{ - --pAppData_Impl->nBasicCallLevel; -} - //------------------------------------------------------------------------- void SfxApplication::PropExec_Impl( SfxRequest &rReq ) { @@ -445,10 +338,6 @@ void SfxApplication::PropExec_Impl( SfxRequest &rReq ) break; } - case SID_PLAYMACRO: - PlayMacro_Impl( rReq, GetBasic() ); - break; - case SID_OFFICE_PRIVATE_USE: case SID_OFFICE_COMMERCIAL_USE: { @@ -523,68 +412,3 @@ void SfxApplication::PropState_Impl( SfxItemSet &rSet ) } } -//-------------------------------------------------------------------- -void SfxApplication::MacroExec_Impl( SfxRequest& rReq ) -{ - DBG_MEMTEST(); - if ( SfxMacroConfig::IsMacroSlot( rReq.GetSlot() ) ) - { - // SlotId referenzieren, damit nicht im Execute der Slot abgeschossen - // werden kann - GetMacroConfig()->RegisterSlotId(rReq.GetSlot()); - SFX_REQUEST_ARG(rReq, pArgs, SfxStringItem, - rReq.GetSlot(), sal_False); - String aArgs; - if( pArgs ) aArgs = pArgs->GetValue(); - if ( GetMacroConfig()->ExecuteMacro(rReq.GetSlot(), aArgs ) ) - rReq.Done(); - GetMacroConfig()->ReleaseSlotId(rReq.GetSlot()); - } -} - -//-------------------------------------------------------------------- -void SfxApplication::MacroState_Impl( SfxItemSet& ) -{ - DBG_MEMTEST(); -} - -//------------------------------------------------------------------------- - -void SfxApplication::PlayMacro_Impl( SfxRequest &rReq, StarBASIC *pBasic ) -{ - EnterBasicCall(); - sal_Bool bOK = sal_False; - - // Makro und asynch-Flag - SFX_REQUEST_ARG(rReq,pMacro,SfxStringItem,SID_STATEMENT,sal_False); - SFX_REQUEST_ARG(rReq,pAsynch,SfxBoolItem,SID_ASYNCHRON,sal_False); - - if ( pAsynch && pAsynch->GetValue() ) - { - // asynchron ausf"uhren - GetDispatcher_Impl()->Execute( SID_PLAYMACRO, SFX_CALLMODE_ASYNCHRON, pMacro, 0L ); - rReq.Done(); - } - else if ( pMacro ) - { - // Statement aufbereiten - DBG_ASSERT( pBasic, "no BASIC found" ) ; - String aStatement( '[' ); - aStatement += pMacro->GetValue(); - aStatement += ']'; - - // P"aventiv den Request abschlie\sen, da er ggf. zerst"ort wird - rReq.Done(); - rReq.ReleaseArgs(); - - // Statement ausf"uhren - pBasic->Execute( aStatement ); - bOK = 0 == SbxBase::GetError(); - SbxBase::ResetError(); - } - - LeaveBasicCall(); - rReq.SetReturnValue(SfxBoolItem(0,bOK)); -} - - diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index c876db373d35..e94635063727 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -88,7 +88,6 @@ #include <sfx2/evntconf.hxx> #include "appdata.hxx" #include "workwin.hxx" -#include <sfx2/macrconf.hxx> #include "helper.hxx" // SfxContentHelper::... #include "app.hrc" #include "sfx2/sfxresid.hxx" @@ -718,7 +717,7 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) pSh; ++nIdx, pSh = pDispat->GetShell(nIdx) ) { - SfxUndoManager *pShUndoMgr = pSh->GetUndoManager(); + ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager(); if ( pShUndoMgr ) pShUndoMgr->SetMaxUndoActionCount( nUndoCount ); } @@ -987,26 +986,9 @@ BOOL SfxApplication::SaveAll_Impl(BOOL bPrompt, BOOL bAutoSave) //-------------------------------------------------------------------- -SfxMacroConfig* SfxApplication::GetMacroConfig() const -{ - return SfxMacroConfig::GetOrCreate(); -} - -//-------------------------------------------------------------------- -SfxEventConfiguration* SfxApplication::GetEventConfig() const -{ - if (!pAppData_Impl->pEventConfig) - pAppData_Impl->pEventConfig = new SfxEventConfiguration; - return pAppData_Impl->pEventConfig; -} - -//-------------------------------------------------------------------- - //-------------------------------------------------------------------- void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, FASTBOOL bSynchron ) { - //DBG_ASSERT(pAppData_Impl->pEventConfig,"Keine Events angemeldet!"); - SfxObjectShell *pDoc = rEventHint.GetObjShell(); if ( pDoc && ( pDoc->IsPreview() || !pDoc->Get_Impl()->bInitialized ) ) return; diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 32b56717293c..ce0dda051886 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -102,7 +102,6 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pAppDispatch(NULL), pTemplates( 0 ), pPool(0), - pEventConfig(0), pDisabledSlotList( 0 ), pSecureURLs(0), pSaveOptions( 0 ), @@ -112,7 +111,6 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pTemplateCommon( 0 ), nDocModalMode(0), nAutoTabPageId(0), - nBasicCallLevel(0), nRescheduleLocks(0), nInReschedule(0), nAsynchronCalls(0), diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx index 808731f8bba8..55a8764ac0c5 100644 --- a/sfx2/source/appl/appdde.cxx +++ b/sfx2/source/appl/appdde.cxx @@ -38,6 +38,7 @@ #include <sfx2/linkmgr.hxx> #include <tools/urlobj.hxx> +#include <tools/diagnose_ex.h> #include <unotools/pathoptions.hxx> #ifndef GCC #endif @@ -197,11 +198,9 @@ long SfxApplication::DdeExecute else { // alle anderen per BASIC - EnterBasicCall(); StarBASIC* pBasic = GetBasic(); - DBG_ASSERT( pBasic, "Wo ist mein Basic???" ); + ENSURE_OR_RETURN( pBasic, "where's my basic?", 0 ); SbxVariable* pRet = pBasic->Execute( rCmd ); - LeaveBasicCall(); if( !pRet ) { SbxBase::ResetError(); diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index 2aa19901d87c..a3d25de8ee61 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -74,7 +74,6 @@ #include <sfx2/docfac.hxx> #include <sfx2/evntconf.hxx> #include "intro.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/mnumgr.hxx> #include <sfx2/msgpool.hxx> #include <sfx2/progress.hxx> @@ -86,7 +85,7 @@ #include <sfx2/fcontnr.hxx> #include "helper.hxx" // SfxContentHelper::Kill() #include "sfxpicklist.hxx" -#include <tools/svlibrary.hxx>
+#include <tools/svlibrary.hxx> #ifdef UNX #define stricmp(a,b) strcmp(a,b) @@ -213,7 +212,7 @@ String GetSpecialCharsForEdit(Window* pParent, const Font& rFont) { bDetermineFunction = true; - static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "cui" ) ) );
+ static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "cui" ) ) ); oslModule handleMod = osl_loadModuleRelative( &thisModule, aLibName.pData, 0 ); diff --git a/sfx2/source/appl/appmain.cxx b/sfx2/source/appl/appmain.cxx index 546b6b1c6558..1bde50fec224 100644 --- a/sfx2/source/appl/appmain.cxx +++ b/sfx2/source/appl/appmain.cxx @@ -116,21 +116,6 @@ void SfxApplication::Init <SfxApplication::OpenClients()> */ { -#ifdef DDE_AVAILABLE -#ifndef DBG_UTIL - InitializeDde(); -#else - if( !InitializeDde() ) - { - ByteString aStr( "Kein DDE-Service moeglich. Fehler: " ); - if( GetDdeService() ) - aStr += GetDdeService()->GetError(); - else - aStr += '?'; - DBG_ASSERT( sal_False, aStr.GetBuffer() ) - } -#endif -#endif } //-------------------------------------------------------------------- diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index e7d0fd70bf58..2a5456989aa7 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -44,6 +44,7 @@ #include "app.hrc" #include <sfx2/app.hxx> +#include <sfx2/evntconf.hxx> #include <sfx2/unoctitm.hxx> #include "appdata.hxx" #include <sfx2/viewsh.hxx> @@ -52,7 +53,6 @@ #include "arrdecl.hxx" #include "sfx2/sfxresid.hxx" #include <sfx2/event.hxx> -#include <sfx2/macrconf.hxx> #include <sfx2/mnumgr.hxx> #include <sfx2/templdlg.hxx> #include <sfx2/msgpool.hxx> @@ -149,8 +149,6 @@ void SfxApplication::Deinitialize() delete pAppData_Impl->pLabelResMgr; DELETEX(pAppData_Impl->pSlotPool); - DELETEX(pAppData_Impl->pEventConfig); - SfxMacroConfig::Release_Impl(); DELETEX(pAppData_Impl->pFactArr); DELETEX(pAppData_Impl->pInitLinkList); diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index c1858c5b33fb..d90e68d6c764 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -107,7 +107,6 @@ #include <sfx2/new.hxx> #include <sfx2/templdlg.hxx> #include "sfxtypes.hxx" -#include "sfxbasic.hxx" #include <sfx2/tabdlg.hxx> #include "arrdecl.hxx" #include "fltfnc.hxx" @@ -118,7 +117,6 @@ #include "arrdecl.hxx" #include <sfx2/childwin.hxx> #include "appdata.hxx" -#include <sfx2/macrconf.hxx> #include "sfx2/minfitem.hxx" #include <sfx2/event.hxx> #include <sfx2/module.hxx> @@ -129,7 +127,7 @@ #include <sfx2/dialogs.hrc> #include "sorgitm.hxx" #include "sfx2/sfxhelp.hxx" -#include <tools/svlibrary.hxx>
+#include <tools/svlibrary.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -746,7 +744,7 @@ extern "C" { static void SAL_CALL thisModule() {} } ::rtl::OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc = ::rtl::OUString() ) { // get basctl dllname - static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
+ static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); // load module oslModule handleMod = osl_loadModuleRelative( @@ -766,7 +764,7 @@ extern "C" { static void SAL_CALL thisModule() {} } void MacroOrganizer( INT16 nTabId ) { // get basctl dllname - static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
+ static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) ); // load module oslModule handleMod = osl_loadModuleRelative( diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 60b684d7385f..9d2025d1e23e 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -94,6 +94,7 @@ #include <tools/cachestr.hxx> #include <osl/mutex.hxx> #include <comphelper/sequence.hxx> +#include <framework/documentundoguard.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/interaction.hxx> @@ -116,7 +117,6 @@ using namespace ::com::sun::star::io; #include <sfx2/fcontnr.hxx> #include "frmload.hxx" #include <sfx2/frame.hxx> -#include "sfxbasic.hxx" #include <sfx2/objsh.hxx> #include <sfx2/objuno.hxx> #include <sfx2/unoctitm.hxx> @@ -1770,12 +1770,9 @@ void SAL_CALL SfxMacroLoader::removeStatusListener( { } -// ----------------------------------------------------------------------- ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh ) throw ( ::com::sun::star::uno::RuntimeException ) { - SfxApplication* pApp = SFX_APP(); - pApp->EnterBasicCall(); SfxObjectShell* pCurrent = pSh; if ( !pCurrent ) // all not full qualified names use the BASIC of the given or current document @@ -1821,18 +1818,21 @@ ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star:: if ( pBasMgr ) { - if ( pSh && pDoc ) + const bool bIsAppBasic = ( pBasMgr == pAppMgr ); + const bool bIsDocBasic = ( pBasMgr != pAppMgr ); + + if ( pDoc ) { - // security check for macros from document basic if an SFX context (pSh) is given + // security check for macros from document basic if an SFX doc is given if ( !pDoc->AdjustMacroMode( String() ) ) // check forbids execution return ERRCODE_IO_ACCESSDENIED; } - else if ( pSh && pSh->GetMedium() ) + else if ( pDoc && pDoc->GetMedium() ) { - pSh->AdjustMacroMode( String() ); - SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); - SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False); + pDoc->AdjustMacroMode( String() ); + SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); + SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False); if ( pUpdateDocItem && pMacroExecModeItem && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE ) @@ -1849,79 +1849,49 @@ ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star:: aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 ); } - SbxMethod *pMethod = SfxQueryMacro( pBasMgr, aQualifiedMethod ); - if ( pMethod ) + if ( pBasMgr->HasMacro( aQualifiedMethod ) ) { - // arguments must be quoted - String aQuotedArgs; - if ( aArgs.Len()<2 || aArgs.GetBuffer()[1] == '\"') - // no args or already quoted args - aQuotedArgs = aArgs; - else + Any aOldThisComponent; + const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic; + const bool bSetGlobalThisComponent = ( pDoc != NULL ) && bIsAppBasic; + if ( bSetDocMacroMode ) { - // quote parameters - aArgs.Erase(0,1); - aArgs.Erase( aArgs.Len()-1,1); - - aQuotedArgs = '('; - - sal_uInt16 nCount = aArgs.GetTokenCount(','); - for ( sal_uInt16 n=0; n<nCount; n++ ) - { - aQuotedArgs += '\"'; - aQuotedArgs += aArgs.GetToken( n, ',' ); - aQuotedArgs += '\"'; - if ( n<nCount-1 ) - aQuotedArgs += ','; - } - - aQuotedArgs += ')'; + // mark document: it executes an own macro, so it's in a modal mode + pDoc->SetMacroMode_Impl( TRUE ); } - Any aOldThisComponent; - if ( pSh ) + if ( bSetGlobalThisComponent ) { - if ( pBasMgr != pAppMgr ) - // mark document: it executes an own macro, so it's in a modal mode - pSh->SetMacroMode_Impl( TRUE ); - if ( pBasMgr == pAppMgr ) - { - // document is executed via AppBASIC, adjust ThisComponent variable - aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pSh->GetModel() ) ); - } + // document is executed via AppBASIC, adjust ThisComponent variable + aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pDoc->GetModel() ) ); } - // add quoted arguments and do the call - String aCall( '[' ); - aCall += pMethod->GetName(); - aCall += aQuotedArgs; - aCall += ']'; - // just to let the shell be alive - SfxObjectShellRef rSh = pSh; + SfxObjectShellRef xKeepDocAlive = pDoc; - // execute function using its Sbx parent, - //SbxVariable* pRet = pMethod->GetParent()->Execute( aCall ); - //rRetval = sbxToUnoValue( pRet ); - - SbxVariable* pRet = pMethod->GetParent()->Execute( aCall ); - if ( pRet ) { - USHORT nFlags = pRet->GetFlags(); - pRet->SetFlag( SBX_READWRITE | SBX_NO_BROADCAST ); - rRetval = sbxToUnoValue( pRet ); - pRet->SetFlags( nFlags ); + // attempt to protect the document against the script tampering with its Undo Context + ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard; + if ( bIsDocBasic ) + pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) ); + + // execute the method + SbxVariableRef retValRef = new SbxVariable; + nErr = pBasMgr->ExecuteMacro( aQualifiedMethod, aArgs, retValRef ); + if ( nErr == ERRCODE_NONE ) + rRetval = sbxToUnoValue( retValRef ); } - nErr = SbxBase::GetError(); - if ( ( pBasMgr == pAppMgr ) && pSh ) + if ( bSetGlobalThisComponent ) { pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent ); } - if ( pSh && pSh->GetModel().is() ) - // remove flag for modal mode - pSh->SetMacroMode_Impl( FALSE ); + if ( bSetDocMacroMode ) + { + // remove flag for modal mode + pDoc->SetMacroMode_Impl( FALSE ); + } } else nErr = ERRCODE_BASIC_PROC_UNDEFINED; @@ -1940,7 +1910,6 @@ ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star:: nErr = SbxBase::GetError(); } - pApp->LeaveBasicCall(); SbxBase::ResetError(); return nErr; } diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index 12f824ea4255..06e17e232041 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -111,7 +111,6 @@ using namespace ::vos; #include <unotools/syslocale.hxx> #include "sfx2/sfxhelp.hxx" -#include "sfxbasic.hxx" #include <sfx2/docfilt.hxx> #include <sfx2/docfac.hxx> #include "sfxtypes.hxx" @@ -590,37 +589,6 @@ sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, const SfxFilter** if( STRING_NOTFOUND != aFlags.Search( 'H' ) ) bHidden = sal_True; } -/* - if ( ( !pFilter || nErr == ERRCODE_SFX_CONSULTUSER ) && !bAPI && !bHidden ) - { - if ( !pFilter ) - pFilter = pOldFilter; - - String aTmpName; - if ( pFilter ) - aTmpName = pFilter->GetUIName(); - - SfxFilterMatcher *pMatcher; - if( bPlugIn && pFilter ) - pMatcher = new SfxFilterMatcher( (SfxFilterContainer *) pFilter->GetFilterContainer() ); - else - pMatcher = (SfxFilterMatcher*) this; - - SfxFilterDialog *pDlg = new SfxFilterDialog( 0, &rMedium, *pMatcher, pFilter ? &aTmpName: 0, 0 ); - const sal_Bool bOk = RET_OK == pDlg->Execute(); - if (bOk) - pFilter = pMatcher->GetFilter4UIName( pDlg->GetSelectEntry()); - - if( bPlugIn && pFilter ) - delete pMatcher; - delete pDlg; - - if ( !bOk) - nErr = ERRCODE_ABORT; - else - nErr = ERRCODE_NONE; - } -*/ *ppFilter = pFilter; if ( bHidden || (bAPI && nErr == ERRCODE_SFX_CONSULTUSER) ) @@ -773,22 +741,6 @@ const SfxFilter* SfxFilterMatcher::GetFilter4Extension( const String& rExt, SfxF const SfxFilter* SfxFilterMatcher::GetFilter4ClipBoardId( sal_uInt32 nId, SfxFilterFlags nMust, SfxFilterFlags nDont ) const { - /* - if ( pImpl->pList ) - { - sal_uInt16 nCount = ( sal_uInt16 ) pImpl->pList->Count(); - for( sal_uInt16 n = 0; n < nCount; n++ ) - { - const SfxFilter* pFilter = pImpl->pList->GetObject( n ); - SfxFilterFlags nFlags = pFilter->GetFilterFlags(); - if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetFormat() == nId ) - return pFilter; - } - - return 0; - } - */ - if (nId == 0) return 0; diff --git a/sfx2/source/config/config.hrc b/sfx2/source/config/config.hrc deleted file mode 100644 index 582a2972f913..000000000000 --- a/sfx2/source/config/config.hrc +++ /dev/null @@ -1,41 +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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SFX_CONFIG_HRC -#define _SFX_CONFIG_HRC - -#include <sfx2/sfx.hrc> - -// #defines ***************************************************************** - -#define BTN_OK 2 -#define BTN_CANCEL 3 -#define FT_OK 4 -#define FT_CANCEL 5 - -#endif - diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx index 185ec0626c51..2ab7b1c9602b 100644 --- a/sfx2/source/config/evntconf.cxx +++ b/sfx2/source/config/evntconf.cxx @@ -34,7 +34,7 @@ #include <basic/sbmod.hxx> #include <tools/urlobj.hxx> #include <basic/sbx.hxx> - #include <sot/storage.hxx> +#include <sot/storage.hxx> #include <unotools/securityoptions.hxx> #include <rtl/ustring.h> @@ -42,12 +42,11 @@ #include <framework/eventsconfiguration.hxx> #include <comphelper/processfactory.hxx> #include <sfx2/evntconf.hxx> -#include <sfx2/macrconf.hxx> + #include <sfx2/docfile.hxx> #include <sfx2/app.hxx> #include <sfx2/objsh.hxx> #include <sfx2/dispatch.hxx> -#include "config.hrc" #include "sfx2/sfxresid.hxx" #include "eventsupplier.hxx" diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 40f6346de8ee..cf04de2cb3a4 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -64,7 +64,6 @@ #include <sfx2/objface.hxx> #include "sfxtypes.hxx" #include "workwin.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/unoctitm.hxx> #include <sfx2/sfx.hrc> #include <sfx2/sfxuno.hxx> @@ -1118,13 +1117,7 @@ void SfxBindings::Release( SfxControllerItem& rItem ) delete (*pImp->pCaches)[nPos]; pImp->pCaches->Remove(nPos, 1); #endif - if ( SfxMacroConfig::IsMacroSlot( nId ) ) - { - delete (*pImp->pCaches)[nPos]; - pImp->pCaches->Remove(nPos, 1); - } - else - pImp->bCtrlReleased = sal_True; + pImp->bCtrlReleased = sal_True; } } @@ -1474,7 +1467,7 @@ SfxItemSet* SfxBindings::CreateSet_Impl rFound.Insert( pFound ); USHORT nSlot = pRealSlot->GetSlotId(); - if ( !SfxMacroConfig::IsMacroSlot( nSlot ) && !(nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) ) + if ( !(nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) ) { pInterface = pInterface->GetRealInterfaceForSlot( pRealSlot ); DBG_ASSERT (pInterface,"Slot in angegebener Shell nicht gefunden!"); diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index c08d713547a0..ddf3422744cb 100755 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -69,7 +69,6 @@ #include "slotserv.hxx" #include <sfx2/ipclient.hxx> #include "sfxtypes.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/childwin.hxx> @@ -159,7 +158,6 @@ struct SfxDispatcher_Impl SfxObjectBars_Impl aObjBars[SFX_OBJECTBAR_MAX]; SfxObjectBars_Impl aFixedObjBars[SFX_OBJECTBAR_MAX]; SvULongs aChildWins; - sal_uInt16 nActionLevel; // in EnterAction sal_uInt32 nEventId; // EventId UserEvent sal_Bool bUILocked; // Update abgeklemmt (!zappeln) sal_Bool bNoUI; // UI nur vom Parent Dispatcher @@ -367,7 +365,6 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent ) pImp->pParent = pParent; pImp->bInvalidateOnUnlock = sal_False; - pImp->nActionLevel = 0; for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++) pImp->aObjBars[n].nResId = 0; @@ -488,9 +485,6 @@ void SfxDispatcher::Pop DBG_MEMTEST(); DBG_ASSERT( rShell.GetInterface(), "pushing SfxShell without previous RegisterInterface()" ); - DBG_ASSERT( pImp->nActionLevel == 0, "Push or Pop within Action" ); -// DBG_ASSERT( SFX_APP()->IsInAsynchronCall_Impl(), -// "Dispatcher Push/Pop in synchron-call-stack" ); bool bDelete = (nMode & SFX_SHELL_POP_DELETE) == SFX_SHELL_POP_DELETE; bool bUntil = (nMode & SFX_SHELL_POP_UNTIL) == SFX_SHELL_POP_UNTIL; @@ -1029,10 +1023,6 @@ void SfxDispatcher::_Execute if ( IsLocked( rSlot.GetSlotId() ) ) return; - sal_uInt16 nSlot = rSlot.GetSlotId(); - if ( SfxMacroConfig::IsMacroSlot( nSlot ) ) - SFX_APP()->GetMacroConfig()->RegisterSlotId( nSlot ); - if ( (eCallMode & SFX_CALLMODE_ASYNCHRON) || ( !(eCallMode & SFX_CALLMODE_SYNCHRON) && rSlot.IsMode(SFX_SLOT_ASYNCHRON) ) ) @@ -1618,38 +1608,6 @@ IMPL_LINK( SfxDispatcher, PostMsgHandler, SfxRequest*, pReq ) return 0; } //-------------------------------------------------------------------- -void SfxDispatcher::EnterAction( const String& rName ) - -// marks the beginning of a block of actions - -{ - DBG_MEMTEST(); - Flush(); - DBG_ASSERT( pImp->aStack.Count() > 0, "EnterAction on empty dispatcher stack" ); - if ( ++pImp->nActionLevel == 1 ) - { - SfxUndoManager *pUndoMgr = GetShell(0)->GetUndoManager(); - if ( pUndoMgr ) - pUndoMgr->EnterListAction( rName, rName HACK(RepeatComment), 0 HACK(ID) ); - } -} -//-------------------------------------------------------------------- -void SfxDispatcher::LeaveAction() - -// marks the end of a block of actions - -{ - DBG_MEMTEST(); - DBG_ASSERT( pImp->nActionLevel > 0, "EnterAction without LeaveAction" ); - if ( --pImp->nActionLevel == 0 ) - { - SfxUndoManager *pUndoMgr = GetShell(0)->GetUndoManager(); - if ( pUndoMgr ) - pUndoMgr->LeaveListAction(); - } -} - -//-------------------------------------------------------------------- void SfxDispatcher::SetMenu_Impl() { if ( pImp->pFrame ) @@ -2298,7 +2256,6 @@ sal_Bool SfxDispatcher::_FindServer SFX_STACK(SfxDispatcher::_FindServer); // Dispatcher gelockt? (SID_HELP_PI trotzdem durchlassen) - SfxApplication *pSfxApp = SFX_APP(); if ( IsLocked(nSlot) ) { pImp->bInvalidateOnUnlock = sal_True; @@ -2318,25 +2275,8 @@ sal_Bool SfxDispatcher::_FindServer } } - // Makro-Slot? - if ( SfxMacroConfig::IsMacroSlot( nSlot ) ) - { - const SfxMacroInfo* pInfo = pSfxApp->GetMacroConfig()->GetMacroInfo(nSlot); - if ( pInfo ) - { - const SfxSlot* pSlot = pInfo->GetSlot(); - if ( pSlot ) - { - rServer.SetShellLevel(nTotCount-1); - rServer.SetSlot( pSlot ); - return sal_True; - } - } - - return sal_False; - } // Verb-Slot? - else if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) + if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) { for ( sal_uInt16 nShell = 0;; ++nShell ) { @@ -2474,10 +2414,7 @@ sal_Bool SfxDispatcher::HasSlot_Impl( sal_uInt16 nSlot ) nTotCount = nTotCount + pImp->aStack.Count(); } - if ( SfxMacroConfig::IsMacroSlot( nSlot ) ) - // Makro-Slot? - return sal_True; - else if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) + if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) { // Verb-Slot? for ( sal_uInt16 nShell = 0;; ++nShell ) @@ -2658,10 +2595,6 @@ const SfxPoolItem* SfxDispatcher::_Execute( const SfxSlotServer &rSvr ) { Flush(); - sal_uInt16 nSlot = pSlot->GetSlotId(); - if ( SfxMacroConfig::IsMacroSlot( nSlot ) ) - SFX_APP()->GetMacroConfig()->RegisterSlotId( nSlot ); - if ( pSlot->IsMode(SFX_SLOT_ASYNCHRON) ) //! ignoriert rSvr { diff --git a/sfx2/source/control/macrconf.cxx b/sfx2/source/control/macrconf.cxx deleted file mode 100644 index 079c7180ac1a..000000000000 --- a/sfx2/source/control/macrconf.cxx +++ /dev/null @@ -1,874 +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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sfx2.hxx" -#include <basic/sbstar.hxx> -#include <basic/basmgr.hxx> -#ifndef _SBX_HXX //autogen -#include <basic/sbx.hxx> -#endif -#include <svl/intitem.hxx> -#include <basic/sbmeth.hxx> -#include <basic/sbmod.hxx> -#ifndef _BASIC_SBUNO_HXX -#include <basic/sbuno.hxx> -#endif - -#include <osl/mutex.hxx> - -#include <com/sun/star/script/XEngine.hpp> -#include <com/sun/star/document/MacroExecMode.hpp> - -#ifndef GCC -#endif - -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include <comphelper/processfactory.hxx> -#endif -#include <unotools/intlwrapper.hxx> - -#include <sfx2/msgpool.hxx> -#include <sfx2/macrconf.hxx> -#include "sfxbasic.hxx" -#include <sfx2/sfx.hrc> -#include <sfx2/app.hxx> -#include <sfx2/objsh.hxx> -#include <sfx2/dispatch.hxx> -#include "sfx2/minfitem.hxx" -#include "sfx2/imgmgr.hxx" -#include <sfx2/evntconf.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/genlink.hxx> -#include <sfx2/viewfrm.hxx> -#include <appdata.hxx> -#include "objshimp.hxx" -#include <sfx2/request.hxx> - -static const sal_uInt16 nCompatVersion = 2; -static const sal_uInt16 nVersion = 3; - -// Static member -SfxMacroConfig* SfxMacroConfig::pMacroConfig = NULL; - -SfxMacroConfig* SfxMacroConfig::GetOrCreate() -{ - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pMacroConfig ) - pMacroConfig = new SfxMacroConfig; - return pMacroConfig; -} - -void SfxMacroConfig::Release_Impl() -{ - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - DELETEZ( pMacroConfig ); -} - -//========================================================================== - -struct SfxMacroConfig_Impl -{ - SfxMacroInfoArr_Impl aArr; - sal_uInt32 nEventId; - sal_Bool bWaitingForCallback; - - SfxMacroConfig_Impl() - : nEventId( 0 ) - , bWaitingForCallback( sal_False ) - {} -}; - -//========================================================================== - -SbMethod* SfxQueryMacro_Impl( BasicManager* pMgr , const String& rMacro, - const String &rLibName, const String& rModule ) -{ - IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); - const CollatorWrapper* pCollator = aIntlWrapper.getCollator(); - sal_uInt16 nLibCount = pMgr->GetLibCount(); - for ( sal_uInt16 nLib = 0; nLib < nLibCount; ++nLib ) - { - if ( COMPARE_EQUAL == pCollator->compareString( pMgr->GetLibName( nLib ), rLibName ) ) - { - StarBASIC* pLib = pMgr->GetLib( nLib ); - if( !pLib ) - { - pMgr->LoadLib( nLib ); - pLib = pMgr->GetLib( nLib ); - } - - if( pLib ) - { - sal_uInt16 nModCount = pLib->GetModules()->Count(); - for( sal_uInt16 nMod = 0; nMod < nModCount; ++nMod ) - { - SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod ); - if ( pMod && COMPARE_EQUAL == pCollator->compareString( pMod->GetName(), rModule ) ) - { - SbMethod* pMethod = (SbMethod*)pMod->Find( rMacro, SbxCLASS_METHOD ); - if( pMethod ) - return pMethod; - } - } - } - } - } - return 0; -} - -SbMethod* SfxQueryMacro( BasicManager* pMgr , const String& rMacro ) -{ - sal_uInt16 nLast = 0; - String aMacro = rMacro; - String aLibName = aMacro.GetToken( 0, '.', nLast ); - String aModule = aMacro.GetToken( 0, '.', nLast ); - aMacro.Erase( 0, nLast ); - - return SfxQueryMacro_Impl( pMgr, aMacro, aLibName, aModule ); -} - -ErrCode SfxCallMacro( BasicManager* pMgr, const String& rCode, - SbxArray *pArgs, SbxValue *pRet ) -{ - ErrCode nErr; - SfxApplication *pApp = SFX_APP(); - pApp->EnterBasicCall(); - SbMethod* pMethod = SfxQueryMacro( pMgr, rCode ); - if ( pMethod ) - { - if ( pArgs ) - pMethod->SetParameters( pArgs ); - nErr = pMethod->Call( pRet ); - } - else - nErr = ERRCODE_BASIC_PROC_UNDEFINED; - - pApp->LeaveBasicCall(); - return nErr; -} - -//========================================================================== - -SfxMacroInfo::SfxMacroInfo( const String& rURL ) : - pHelpText(0), - nRefCnt(0), - bAppBasic(TRUE), - nSlotId(0), - pSlot(0) -{ - if ( rURL.CompareToAscii( "macro:", 6 ) == COMPARE_EQUAL ) - { - String aTmp = rURL.Copy( 6 ); - if ( aTmp.GetTokenCount('/') > 3 ) - { - // 'macro:///lib.mod.proc(args)' => Macro via App-BASIC-Mgr - // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via zugehoerigen Doc-BASIC-Mgr - if ( aTmp.CompareToAscii("///", 3 ) != COMPARE_EQUAL ) - bAppBasic = FALSE; - aTmp = rURL.GetToken( 3, '/' ); - if ( aTmp.GetTokenCount('.') == 3 ) - { - aLibName = aTmp.GetToken( 0, '.' ); - aModuleName = aTmp.GetToken( 1, '.' ); - aMethodName = aTmp.GetToken( 2, '.' ); - - // Remove arguments to be compatible - aMethodName.SearchAndReplaceAscii( "()", String(), sal::static_int_cast< xub_StrLen >(std::max( aMethodName.Len()-2, 0 ))); - } - } - - DBG_ASSERT( aLibName.Len() && aModuleName.Len() && aMethodName.Len(), "Wrong macro URL!" ); - } - else - aMethodName = rURL; -} - -SfxMacroInfo::SfxMacroInfo( bool _bAppBasic ) : - pHelpText(0), - nRefCnt(0), - bAppBasic(_bAppBasic), - nSlotId(0), - pSlot(0) -{} - -//========================================================================== - -SfxMacroInfo::SfxMacroInfo(bool _bAppBasic, const String& rLibName, - const String& rModuleName, const String& rMethodName) : - pHelpText(0), - nRefCnt(0), - bAppBasic(_bAppBasic), - aLibName(rLibName), - aModuleName(rModuleName), - aMethodName(rMethodName), - nSlotId(0), - pSlot(0) -{ -} - -//========================================================================== - -SfxMacroInfo::SfxMacroInfo(bool _bAppBasic, const String& rQualifiedName ) -: pHelpText(0), - nRefCnt(0), - bAppBasic(_bAppBasic), - nSlotId(0), - pSlot(0) -{ - sal_uInt16 nCount = rQualifiedName.GetTokenCount('.'); - aMethodName = rQualifiedName.GetToken( nCount-1, '.' ); - if ( nCount > 1 ) - aModuleName = rQualifiedName.GetToken( nCount-2, '.' ); - if ( nCount > 2 ) - aLibName = rQualifiedName.GetToken( 0, '.' ); -} - -//========================================================================== - -SfxMacroInfo::SfxMacroInfo(SfxMacroInfo& rOther) : - pHelpText(0), - nRefCnt(0), - bAppBasic(rOther.bAppBasic), - aLibName(rOther.aLibName), - aModuleName(rOther.aModuleName), - aMethodName(rOther.aMethodName), - nSlotId(rOther.nSlotId), - pSlot(0) -{} - -//========================================================================== - -SfxMacroInfo::~SfxMacroInfo() -{ - delete pSlot; - delete pHelpText; -} - -//========================================================================== - -sal_Bool SfxMacroInfo::operator==(const SfxMacroInfo& rOther) const -{ - if ( GetQualifiedName() == rOther.GetQualifiedName() && - bAppBasic == rOther.bAppBasic ) - return sal_True; - else - return sal_False; -} - -//========================================================================== - -String SfxMacroInfo::GetMacroName() const -{ - String aMacroName = aMethodName; - aMacroName += '('; - aMacroName += aLibName; - aMacroName += '.'; - aMacroName += aModuleName; - aMacroName += ')'; - return aMacroName; -} - -//========================================================================== - -String SfxMacroInfo::GetQualifiedName() const -{ - String aMacroName; - if( aMacroName.Len() || aLibName.Len() ) - { - // Altes Format - aMacroName = aLibName; - aMacroName += '.'; - aMacroName += aModuleName; - aMacroName += '.'; - } - - // Wg. ::com::sun::star::script::JavaScript kein Zerlegen des Strings mehr - aMacroName += aMethodName; - return aMacroName; -} - -String SfxMacroInfo::GetFullQualifiedName() const -{ - // Liefert nur Unsinn, wenn f"ur ein ::com::sun::star::script::JavaScript aufgerufen ! - String aRet; - if ( bAppBasic ) - aRet = SFX_APP()->GetName(); - aRet += '.'; - aRet += GetQualifiedName(); - return aRet; -} - -String SfxMacroInfo::GetURL() const -{ - if ( !aLibName.Len() ) - return aMethodName; - - // 'macro:///lib.mod.proc(args)' => Macro via App-BASIC-Mgr - // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via zugehoerigen Doc-BASIC-Mgr - // 'macro://obj.method(args)' => Object via App-BASIC-Mgr - String aURL( String::CreateFromAscii("macro://") ); - if ( !bAppBasic ) - aURL += '.'; - aURL += '/'; - aURL += aLibName; - aURL += '.'; - aURL += aModuleName; - aURL += '.'; - aURL += aMethodName; - aURL += String::CreateFromAscii("()"); - - return aURL; -} - -//========================================================================== - -BasicManager* SfxMacroInfo::GetBasicManager() const -{ - if (bAppBasic) - { - return SFX_APP()->GetBasicManager(); - } - else - { - SfxObjectShell *pCurrDocShell = SfxObjectShell::Current(); - return pCurrDocShell ? pCurrDocShell->GetBasicManager() : - SFX_APP()->GetBasicManager(); - } -} - -//========================================================================== - -String SfxMacroInfo::GetBasicName() const -{ - if (bAppBasic) - { - return SFX_APP()->GetName(); - } - else - { - SfxObjectShell *pCurrDocShell = SfxObjectShell::Current(); - if ( pCurrDocShell ) - return pCurrDocShell->GetTitle(); - else - return SFX_APP()->GetName(); - } -} - -String SfxMacroInfo::GetHelpText() const -{ - if ( pHelpText ) - return *pHelpText; - return String(); -} - -String SfxMacroConfig::RequestHelp( sal_uInt16 nId ) -{ - SfxMacroInfo *pInfo = SFX_APP()->GetMacroConfig()->GetMacroInfo( nId ); - if ( !pInfo ) - return String(); - - if ( !pInfo->pHelpText ) - { - SbMethod *pMethod = - SfxQueryMacro_Impl( pInfo->GetBasicManager(), pInfo->aMethodName, - pInfo->aLibName, pInfo->aModuleName ); - if ( pMethod && pMethod->GetInfo() ) - pInfo->pHelpText = new String( pMethod->GetInfo()->GetComment() ); - } - - return pInfo->GetHelpText(); -} - -void SfxMacroInfo::SetHelpText( const String& rName ) -{ - if ( !pHelpText ) - pHelpText = new String; - *pHelpText = rName; -} - -//========================================================================== - -SvStream& operator >> (SvStream& rStream, SfxMacroInfo& rInfo) -{ - sal_uInt16 nAppBasic, nFileVersion; - String aDocName; - - rStream >> nFileVersion; - if ( nVersion < nCompatVersion ) - { - // In der 1.Version ohne Versionskennung - nAppBasic = nVersion; - nFileVersion = 1; - rStream.ReadByteString(aDocName,RTL_TEXTENCODING_UTF8); - rStream.ReadByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8); - rStream.ReadByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8); - rStream.ReadByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8); - } - else - { - String aInput; - rStream >> nAppBasic; - rStream.ReadByteString(aDocName,RTL_TEXTENCODING_UTF8); // Vorsicht: kann bei AppName Unsinn sein! - rStream.ReadByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8); - rStream.ReadByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8); - rStream.ReadByteString(aInput,RTL_TEXTENCODING_UTF8); - - if ( nFileVersion == nCompatVersion ) - rInfo.aMethodName = aInput; - else - { - sal_uInt16 nCount = aInput.GetTokenCount('.'); - rInfo.aMethodName = aInput.GetToken( nCount-1, '.' ); - if ( nCount > 1 ) - rInfo.aModuleName = aInput.GetToken( nCount-2, '.' ); - if ( nCount > 2 ) - rInfo.aLibName = aInput.GetToken( 0, '.' ); - } - } - - rInfo.bAppBasic = (sal_Bool) nAppBasic; - return rStream; -} - -int SfxMacroInfo::Load( SvStream& rStream ) -{ - rStream >> (*this); - nSlotId = SFX_APP()->GetMacroConfig()->GetSlotId(this); - return 0; -} - -//========================================================================== - -SvStream& operator << (SvStream& rStream, const SfxMacroInfo& rInfo) -{ - if ( rInfo.bAppBasic ) - { - rStream << nVersion - << (sal_uInt16) rInfo.bAppBasic; - rStream.WriteByteString(rInfo.GetBasicName(),RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8); - } - else - { - rStream << nVersion - << (sal_uInt16) rInfo.bAppBasic; - rStream.WriteByteString(SFX_APP()->GetName(),RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8); - rStream.WriteByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8); - } - - return rStream; -} - -sal_Bool SfxMacroInfo::Compare( const SvxMacro& rMacro ) const -{ - String aName = rMacro.GetLibName(); - aName += '.'; - aName += rMacro.GetMacName(); - if ( GetFullQualifiedName() == aName ) - return sal_True; - return sal_False; -} - -//========================================================================== - -SfxMacroConfig::SfxMacroConfig() -{ - pImp = new SfxMacroConfig_Impl; -} - -//========================================================================== - -SfxMacroConfig::~SfxMacroConfig() -{ - if ( pImp->nEventId ) - Application::RemoveUserEvent( pImp->nEventId ); - delete pImp; -} - -//========================================================================== - -SFX_STATE_STUB( SfxApplication, MacroState_Impl ) -SFX_EXEC_STUB( SfxApplication, MacroExec_Impl ) - -sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo) -{ - sal_uInt16 nCount = pImp->aArr.Count(); // Macro suchen - sal_uInt16 i; - for (i=0; i<nCount; i++) - if ((*(pImp->aArr)[i]) == (*pInfo)) - break; - - if (i == nCount) - { // Macro noch unbekannt - nCount = aIdArray.Count(); - sal_uInt16 n; - for (n=0; n<nCount; n++) // freie SlotId suchen - if (aIdArray[n] > SID_MACRO_START + n) - break; - - sal_uInt16 nNewSlotId = SID_MACRO_START + n; - if ( nNewSlotId > SID_MACRO_END ) - return 0; - aIdArray.Insert( SID_MACRO_START + n, n ); - - SfxSlot *pNewSlot = new SfxSlot; - pNewSlot->nSlotId = SID_MACRO_START + n; - pNewSlot->nGroupId = 0; - pNewSlot->nFlags = SFX_SLOT_ASYNCHRON; - pNewSlot->nMasterSlotId = 0; - pNewSlot->nValue = 0; - pNewSlot->fnExec = SFX_STUB_PTR(SfxApplication,MacroExec_Impl); - pNewSlot->fnState = SFX_STUB_PTR(SfxApplication,MacroState_Impl); - pNewSlot->pType = 0; HACK(SFX_TYPE(SfxVoidItem)) - pNewSlot->pName = pNewSlot->pMethodName = U2S(pInfo->aMethodName).getStr(); - pNewSlot->pLinkedSlot = 0; - pNewSlot->nArgDefCount = 0; - pNewSlot->pFirstArgDef = 0; - pNewSlot->pUnoName = 0; - - if (nCount) - { - SfxSlot *pSlot = (pImp->aArr)[0]->pSlot; - pNewSlot->pNextSlot = pSlot->pNextSlot; - pSlot->pNextSlot = pNewSlot; - } - else - pNewSlot->pNextSlot = pNewSlot; - - // Macro uebernehmen - SfxMacroInfoPtr pNewInfo = new SfxMacroInfo(*pInfo); - pNewInfo->nSlotId = SID_MACRO_START + n; - pImp->aArr.Insert(pNewInfo,n); - pNewInfo->pSlot = pNewSlot; - pInfo->nSlotId = pNewInfo->nSlotId; - pNewInfo->nRefCnt++; - } - else - { - pInfo->nSlotId = (pImp->aArr)[i]->nSlotId; - (pImp->aArr)[i]->nRefCnt++; - } - - return pInfo->nSlotId; -} - -//========================================================================== - -void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId) -{ - DBG_ASSERT( IsMacroSlot( nId ), "SlotId ist kein Macro!"); - - sal_uInt16 nCount = pImp->aArr.Count(); - for (sal_uInt16 i=0; i<nCount; i++) - { - SfxMacroInfo *pInfo = (pImp->aArr)[i]; - if (pInfo->nSlotId == nId) - { - pInfo->nRefCnt--; - if (pInfo->nRefCnt == 0) - { - // Slot wird nicht mehr referenziert, also holen - SfxSlot *pSlot = pInfo->pSlot; - - // Slot aus der Verkettung rausnehmen - while (pSlot->pNextSlot != pInfo->pSlot) - pSlot = (SfxSlot*) pSlot->pNextSlot; - pSlot->pNextSlot = pInfo->pSlot->pNextSlot; - - // Slot selbst kurz schlie\sen - pSlot = pInfo->pSlot; - pSlot->pNextSlot = pSlot; - - // MacroInfo aus Array entfernen, damit sie kein Unheil - // anrichten kann - pImp->aArr.Remove(i); - - // SlotId wieder freigeben - sal_uInt16 nIdCount = aIdArray.Count(); - for (sal_uInt16 n=0; n<nIdCount; n++) - { - if (aIdArray[n] == nId) - { - aIdArray.Remove(n); - break; - } - } - - // Sofern nicht die Applikation heruntergefahren wird, mu\s - // der Slot asynchron gel"oscht werden, falls er in seinem - // eigenen Execute abgeschossen wird! - if ( !SFX_APP()->Get_Impl()->bInQuit ) - pImp->nEventId = Application::PostUserEvent( LINK(this, SfxMacroConfig, EventHdl_Impl), pInfo ); - else - EventHdl_Impl( pInfo ); - } - return; - } - } - - DBG_ERROR("Macro-SlotId nicht gefunden!"); -} - -//========================================================================== - -void SfxMacroConfig::RegisterSlotId(sal_uInt16 nId) -{ - DBG_ASSERT( IsMacroSlot( nId ), "SlotId ist kein Macro!"); - - sal_uInt16 nCount = pImp->aArr.Count(); - for (sal_uInt16 i=0; i<nCount; i++) - { - if ((pImp->aArr)[i]->nSlotId == nId) - { - (pImp->aArr)[i]->nRefCnt++; - return; - } - } - - DBG_ERROR("Macro-SlotId nicht gefunden!"); -} - -//========================================================================== - -SfxMacroInfo* SfxMacroConfig::GetMacroInfo(sal_uInt16 nId) const -{ - sal_uInt16 nCount = pImp->aArr.Count(); - for (sal_uInt16 i=0; i<nCount; i++) - if ((pImp->aArr)[i]->nSlotId == nId) - return (pImp->aArr)[i]; - - return 0; -} - -//========================================================================== - -const SfxMacroInfo* SfxMacroConfig::GetMacroInfo_Impl( const SvxMacro *pMacro ) const -{ - sal_uInt16 nCount = pImp->aArr.Count(); - for (sal_uInt16 i=0; i<nCount; i++) - if ((pImp->aArr)[i]->Compare(*pMacro) ) - return (pImp->aArr)[i]; - return 0; -} - -//========================================================================== - -sal_Bool SfxMacroConfig::ExecuteMacro( sal_uInt16 nId, const String& rArgs ) const -{ - const SfxMacroInfo* pInfo = GetMacroInfo( nId ); - if ( !pInfo ) - return sal_False; - - SfxObjectShell* pSh = SfxObjectShell::Current(); - - SvxMacro aMacro( pInfo->GetQualifiedName(), pInfo->GetBasicName(), STARBASIC ); - sal_Bool bRet = ExecuteMacro( pSh, &aMacro, rArgs ); - - // Release, da im Dispatcher-Execute ein Register gemacht wurde - ((SfxMacroConfig*)this)->ReleaseSlotId( nId ); - return bRet; -} - -sal_Bool SfxMacroConfig::ExecuteMacro( SfxObjectShell *pSh, const SvxMacro* pMacro, const String& /*rArgs*/ ) const -{ - SfxApplication *pApp = SFX_APP(); - - // Name des Macros oder Scripts bzw. ScriptCode - String aCode( pMacro->GetMacName() ); - ErrCode nErr = ERRCODE_NONE; - - // Ist es ein Basic-Macro ? - ScriptType eSType = pMacro->GetScriptType(); - sal_Bool bIsBasic = eSType == STARBASIC; - sal_Bool bIsStarScript = ( eSType == EXTENDED_STYPE && pMacro->GetLibName().SearchAscii( "StarScript" ) != STRING_NOTFOUND ); - sal_Bool bIsBasicLibBased = bIsBasic || bIsStarScript || !pSh; - - if ( bIsBasicLibBased ) - { - pApp->EnterBasicCall(); - BasicManager *pAppMgr = SFX_APP()->GetBasicManager(); - if( bIsBasic ) - { - // BasicManager von Document? - BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL; - - // Da leider der Name zwischendurch h"aufig gewechselt hat ... - if( SFX_APP()->GetName() == pMacro->GetLibName() || - pMacro->GetLibName().EqualsAscii("StarDesktop") ) - pMgr = pAppMgr; - else if ( pMgr == pAppMgr ) - pMgr = NULL; - - if ( pSh && pMgr && pMgr != pAppMgr ) - { - if ( !pSh->AdjustMacroMode( String() ) ) - return sal_False; - } - - if ( pSh && pMgr && pMgr == pAppMgr ) - { - ::com::sun::star::uno::Any aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pSh->GetModel() ) ); - nErr = Call( 0, aCode, pMgr ); - pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent ); - } - else if ( pMgr ) - nErr = Call( 0, aCode, pMgr ); - else - nErr = SbxERR_NO_METHOD; - - } - - pApp->LeaveBasicCall(); - } - else - { - nErr = SbxERR_NO_METHOD; - } - - return ( nErr == ERRCODE_NONE ); -} - -sal_Bool SfxMacroConfig::CheckMacro( SfxObjectShell *pSh, const SvxMacro* pMacro ) const -{ - SfxApplication *pApp = SFX_APP(); - - // Name des Macros oder Scripts bzw. ScriptCode - String aCode( pMacro->GetMacName() ); - ErrCode nErr = ERRCODE_NONE; - - // BasicManager von Document oder Application - pApp->EnterBasicCall(); - BasicManager *pAppMgr = SFX_APP()->GetBasicManager(); - BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL; - - // Da leider der Name zwischendurch h"aufig gewechselt hat ... - if( SFX_APP()->GetName() == pMacro->GetLibName() || - pMacro->GetLibName().EqualsAscii("StarDesktop") ) - pMgr = pAppMgr; - else if ( pMgr == pAppMgr ) - pMgr = NULL; - - if ( !pMgr || !SfxQueryMacro( pMgr, aCode ) ) - nErr = SbxERR_NO_METHOD; - pApp->LeaveBasicCall(); - return ( nErr == ERRCODE_NONE ); -} - -//========================================================================== - -sal_Bool SfxMacroConfig::CheckMacro( sal_uInt16 nId ) const -{ - const SfxMacroInfo* pInfo = GetMacroInfo( nId ); - if ( !pInfo ) - return sal_False; - - // Basic nur initialisieren, wenn default nicht ::com::sun::star::script::JavaScript; dann mu\s - // in IsBasic() sowieso das Basic angelegt werden - SfxObjectShell* pSh = SfxObjectShell::Current(); - - SfxApplication *pApp = SFX_APP(); - pApp->EnterBasicCall(); - - // BasicManager von Document oder Application - BasicManager *pAppMgr = SFX_APP()->GetBasicManager(); - BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL; - - if( SFX_APP()->GetName() == pInfo->GetBasicName() ) - pMgr = SFX_APP()->GetBasicManager(); - else if ( pMgr == pAppMgr ) - pMgr = NULL; - - String aFull( pInfo->GetQualifiedName() ); - sal_Bool bIsBasic = pMgr ? IsBasic( 0, aFull, pMgr ) : sal_False; - pApp->LeaveBasicCall(); - return bIsBasic; -} - -//========================================================================== - -IMPL_LINK( SfxMacroConfig, CallbackHdl_Impl, SfxMacroConfig*, pConfig ) -{ - (void)pConfig; // unused - pImp->bWaitingForCallback = sal_False; - return 0; -} - -IMPL_LINK( SfxMacroConfig, EventHdl_Impl, SfxMacroInfo*, pInfo ) -{ - delete pInfo; - pImp->nEventId = 0; - return 0; -} - -sal_Bool SfxMacroConfig::IsBasic( - SbxObject* /*pVCtrl*/, - const String& rCode, - BasicManager* pMgr ) -{ - sal_Bool bFound; - SFX_APP()->EnterBasicCall(); - bFound = SfxQueryMacro( pMgr, rCode ) != 0; - SFX_APP()->LeaveBasicCall(); - return bFound; -} - -ErrCode SfxMacroConfig::Call( - SbxObject* /*pVCtrl*/, - const String& rCode, - BasicManager* pMgr, - SbxArray *pArgs, - SbxValue *pRet ) -{ - SfxApplication *pApp = SFX_APP(); - pApp->EnterBasicCall(); - SbMethod* pMethod = SfxQueryMacro( pMgr, rCode ); - ErrCode nErr = 0; - if( pMethod ) - { - if ( pArgs ) - pMethod->SetParameters( pArgs ); - nErr = pMethod->Call( pRet ); - } - else - nErr = ERRCODE_BASIC_PROC_UNDEFINED; - - pApp->LeaveBasicCall(); - return nErr; -} - - -sal_Bool SfxMacroConfig::IsMacroSlot( sal_uInt16 nId ) -{ - return ( nId >= SID_MACRO_START && nId <= SID_MACRO_END ); -} - - diff --git a/sfx2/source/control/msgpool.cxx b/sfx2/source/control/msgpool.cxx index 10359ba20f73..9d3661ef1bc1 100644 --- a/sfx2/source/control/msgpool.cxx +++ b/sfx2/source/control/msgpool.cxx @@ -40,7 +40,6 @@ #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include "sfxtypes.hxx" -#include <sfx2/macrconf.hxx> #include "sfx2/sfxresid.hxx" #include "arrdecl.hxx" #include <sfx2/module.hxx> diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index f3df5dc36d0c..d1605754680a 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -46,7 +46,6 @@ #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> -#include "sfxbasic.hxx" #include <sfx2/objface.hxx> #include <sfx2/objsh.hxx> #include <sfx2/viewsh.hxx> @@ -55,7 +54,6 @@ #include <sfx2/request.hxx> #include <sfx2/mnumgr.hxx> #include "statcach.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/msgpool.hxx> //==================================================================== @@ -483,7 +481,7 @@ SfxBroadcaster* SfxShell::GetBroadcaster() //-------------------------------------------------------------------- -SfxUndoManager* SfxShell::GetUndoManager() +::svl::IUndoManager* SfxShell::GetUndoManager() /* [Beschreibung] @@ -501,7 +499,7 @@ SfxUndoManager* SfxShell::GetUndoManager() //-------------------------------------------------------------------- -void SfxShell::SetUndoManager( SfxUndoManager *pNewUndoMgr ) +void SfxShell::SetUndoManager( ::svl::IUndoManager *pNewUndoMgr ) /* [Beschreibung] @@ -517,6 +515,12 @@ void SfxShell::SetUndoManager( SfxUndoManager *pNewUndoMgr ) */ { + OSL_ENSURE( ( pUndoMgr == NULL ) || ( pNewUndoMgr == NULL ) || ( pUndoMgr == pNewUndoMgr ), + "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" ); + // there's at least one client of our UndoManager - the DocumentUndoManager at the SfxBaseModel - which + // caches the UndoManager, and registers itself as listener. If exchanging non-NULL UndoManagers is really + // a supported scenario (/me thinks it is not), then we would need to notify all such clients instances. + pUndoMgr = pNewUndoMgr; if ( pUndoMgr ) pUndoMgr->SetMaxUndoActionCount( (USHORT) SvtUndoOptions().GetUndoCount() ); @@ -947,13 +951,6 @@ const SfxPoolItem* SfxShell::ExecuteSlot pSlot = GetVerbSlot_Impl(nSlot); if ( !pSlot ) pSlot = pIF->GetSlot(nSlot); - if ( !pSlot && SfxMacroConfig::IsMacroSlot( nSlot ) ) - { - SfxMacroInfo* pInfo = SFX_APP()->GetMacroConfig()->GetMacroInfo(nSlot); - if ( pInfo ) - pSlot = pInfo->GetSlot(); - } - DBG_ASSERT( pSlot, "slot not supported" ); SfxExecFunc pFunc = pSlot->GetExecFnc(); @@ -1022,13 +1019,6 @@ const SfxPoolItem* SfxShell::GetSlotState pSlot = GetVerbSlot_Impl(nSlotId); if ( !pSlot ) pSlot = pIF->GetSlot(nSlotId); - if ( !pSlot && SfxMacroConfig::IsMacroSlot( nSlotId ) ) - { - SfxMacroInfo* pInfo = SFX_APP()->GetMacroConfig()->GetMacroInfo(nSlotId); - if ( pInfo ) - pSlot = pInfo->GetSlot(); - } - if ( pSlot ) // ggf. auf Which-Id mappen nSlotId = pSlot->GetWhich( rPool ); diff --git a/sfx2/source/doc/doc.hrc b/sfx2/source/doc/doc.hrc index 7e8fd688af52..c3cbf01cfc9a 100644 --- a/sfx2/source/doc/doc.hrc +++ b/sfx2/source/doc/doc.hrc @@ -146,11 +146,6 @@ #define RID_CNT_STR_WAITING (RID_SFX_DOC_START+ 83) #define STR_OBJECT (RID_SFX_DOC_START+ 84) -#define STR_EDITOBJECT (RID_SFX_DOC_START+ 85) -// --> PB 2004-08-20 #i33095# -/* obsolete -#define STR_OPENOBJECT (RID_SFX_DOC_START+ 86) -*/ #define DLOAD_URL 1 #define DLOAD_STATUS 2 diff --git a/sfx2/source/doc/doc.src b/sfx2/source/doc/doc.src index 497d4ccd7c97..bbf3ccb33253 100644 --- a/sfx2/source/doc/doc.src +++ b/sfx2/source/doc/doc.src @@ -371,19 +371,6 @@ String STR_OBJECT Text [ en-US ] = "Object" ; }; -String STR_EDITOBJECT -{ - Text [ en-US ] = "~Edit"; -}; - -// --> PB 2004-08-20 #i33095# -/* obsolete -String STR_OPENOBJECT -{ - Text [ en-US ] = "~Open"; -}; -*/ - QueryBox DLG_MACROQUERY { Buttons = WB_OK_CANCEL; diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index f5ea04e5e08d..f962542aac10 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -137,7 +137,11 @@ namespace DocTempl { class DocTempl_EntryData_Impl { RegionData_Impl* mpParent; + + // the following member must be SfxObjectShellLock since it controlls that SfxObjectShell lifetime by design + // and users of this class expect it to be so. SfxObjectShellLock mxObjShell; + OUString maTitle; OUString maOwnURL; OUString maTargetURL; diff --git a/sfx2/source/doc/docundomanager.cxx b/sfx2/source/doc/docundomanager.cxx new file mode 100755 index 000000000000..8fa7dd29ac39 --- /dev/null +++ b/sfx2/source/doc/docundomanager.cxx @@ -0,0 +1,457 @@ +/************************************************************************* + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "docundomanager.hxx" +#include "sfx2/sfxbasemodel.hxx" +#include "sfx2/objsh.hxx" +#include "sfx2/viewfrm.hxx" +#include "sfx2/viewsh.hxx" +#include "sfx2/bindings.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/XComponent.hpp> +/** === end UNO includes === **/ + +#include <comphelper/anytostring.hxx> +#include <comphelper/flagguard.hxx> +#include <svl/undo.hxx> +#include <tools/diagnose_ex.h> +#include <framework/undomanagerhelper.hxx> + +#include <boost/noncopyable.hpp> +#include <stack> + +//...................................................................................................................... +namespace sfx2 +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + 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::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::util::InvalidStateException; + using ::com::sun::star::document::EmptyUndoStackException; + using ::com::sun::star::util::NotLockedException; + using ::com::sun::star::document::UndoContextNotClosedException; + using ::com::sun::star::document::XUndoAction; + using ::com::sun::star::document::XUndoManagerSupplier; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::NotInitializedException; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::document::UndoManagerEvent; + using ::com::sun::star::document::XUndoManagerListener; + using ::com::sun::star::document::UndoFailedException; + using ::com::sun::star::document::XUndoManager; + using ::com::sun::star::lang::NoSupportException; + using ::com::sun::star::frame::XModel; + /** === end UNO using === **/ + + using ::svl::IUndoManager; + + //================================================================================================================== + //= DocumentUndoManager_Impl + //================================================================================================================== + struct DocumentUndoManager_Impl : public ::framework::IUndoManagerImplementation + { + DocumentUndoManager& rAntiImpl; + IUndoManager* pUndoManager; + ::framework::UndoManagerHelper aUndoHelper; + + DocumentUndoManager_Impl( DocumentUndoManager& i_antiImpl ) + :rAntiImpl( i_antiImpl ) + ,pUndoManager( impl_retrieveUndoManager( i_antiImpl.getBaseModel() ) ) + // do this *before* the construction of aUndoHelper (which actually means: put pUndoManager before + // aUndoHelper in the member list)! + ,aUndoHelper( *this ) + { + } + + const SfxObjectShell* getObjectShell() const { return rAntiImpl.getBaseModel().GetObjectShell(); } + SfxObjectShell* getObjectShell() { return rAntiImpl.getBaseModel().GetObjectShell(); } + + // IUndoManagerImplementation + virtual ::svl::IUndoManager& getImplUndoManager(); + virtual Reference< XUndoManager > getThis(); + + void disposing() + { + aUndoHelper.disposing(); + ENSURE_OR_RETURN_VOID( pUndoManager, "DocumentUndoManager_Impl::disposing: already disposed!" ); + pUndoManager = NULL; + } + + void invalidateXDo_nolck(); + + private: + static IUndoManager* impl_retrieveUndoManager( SfxBaseModel& i_baseModel ) + { + IUndoManager* pUndoManager( NULL ); + SfxObjectShell* pObjectShell = i_baseModel.GetObjectShell(); + if ( pObjectShell != NULL ) + pUndoManager = pObjectShell->GetUndoManager(); + if ( !pUndoManager ) + throw NotInitializedException( ::rtl::OUString(), *&i_baseModel ); + return pUndoManager; + } + }; + + //------------------------------------------------------------------------------------------------------------------ + ::svl::IUndoManager& DocumentUndoManager_Impl::getImplUndoManager() + { + ENSURE_OR_THROW( pUndoManager != NULL, "DocumentUndoManager_Impl::getImplUndoManager: no access to the doc's UndoManager implementation!" ); + +#if OSL_DEBUG_LEVEL > 0 + // in a non-product build, assert if the current UndoManager at the shell is not the same we obtained + // (and cached) at construction time + SfxObjectShell* pObjectShell = rAntiImpl.getBaseModel().GetObjectShell(); + OSL_ENSURE( ( pObjectShell != NULL ) && ( pUndoManager == pObjectShell->GetUndoManager() ), + "DocumentUndoManager_Impl::getImplUndoManager: the UndoManager changed meanwhile - what about our listener?" ); +#endif + + return *pUndoManager; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XUndoManager > DocumentUndoManager_Impl::getThis() + { + return static_cast< XUndoManager* >( &rAntiImpl ); + } + + //------------------------------------------------------------------------------------------------------------------ + void DocumentUndoManager_Impl::invalidateXDo_nolck() + { + SfxModelGuard aGuard( rAntiImpl ); + + const SfxObjectShell* pDocShell = getObjectShell(); + ENSURE_OR_THROW( pDocShell != NULL, "lcl_invalidateUndo: no access to the doc shell!" ); + SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( pDocShell ); + while ( pViewFrame ) + { + pViewFrame->GetBindings().Invalidate( SID_UNDO ); + pViewFrame->GetBindings().Invalidate( SID_REDO ); + pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDocShell ); + } + } + + //================================================================================================================== + //= SolarMutexFacade + //================================================================================================================== + /** a facade for the SolarMutex, implementing ::framework::IMutex (as opposed to ::vos::IMutex) + */ + class SolarMutexFacade : public ::framework::IMutex + { + public: + SolarMutexFacade() + { + } + + virtual void acquire() + { + Application::GetSolarMutex().acquire(); + } + + virtual void release() + { + Application::GetSolarMutex().release(); + } + }; + + //================================================================================================================== + //= UndoManagerGuard + //================================================================================================================== + class UndoManagerGuard :public ::framework::IMutexGuard + ,public ::boost::noncopyable + { + public: + UndoManagerGuard( DocumentUndoManager& i_undoManager ) + :m_guard( i_undoManager ) + ,m_solarMutexFacade() + { + } + + ~UndoManagerGuard() + { + } + + virtual void reset() + { + m_guard.reset(); + } + + virtual void clear() + { + m_guard.clear(); + } + + virtual ::framework::IMutex& getGuardedMutex() + { + // note that this means that we *know* that SfxModelGuard also locks the SolarMutex (nothing more, nothing less). + // If this ever changes, we need to adjust this code here, too. + return m_solarMutexFacade; + } + + private: + SfxModelGuard m_guard; + SolarMutexFacade m_solarMutexFacade; + }; + + //================================================================================================================== + //= DocumentUndoManager + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DocumentUndoManager::DocumentUndoManager( SfxBaseModel& i_document ) + :SfxModelSubComponent( i_document ) + ,m_pImpl( new DocumentUndoManager_Impl( *this ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + DocumentUndoManager::~DocumentUndoManager() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void DocumentUndoManager::disposing() + { + m_pImpl->disposing(); + } + + //------------------------------------------------------------------------------------------------------------------ + bool DocumentUndoManager::isInContext() const + { + // No mutex locking within this method, no disposal check - this is the responsibility of the owner. + return m_pImpl->getImplUndoManager().IsInListAction(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::acquire( ) throw () + { + SfxModelSubComponent::acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::release( ) throw () + { + SfxModelSubComponent::release(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.leaveUndoContext( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (RuntimeException, IllegalArgumentException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.undo( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.redo( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL DocumentUndoManager::isUndoPossible( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.isUndoPossible(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL DocumentUndoManager::isRedoPossible( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.isRedoPossible(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.getCurrentUndoActionTitle(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.getCurrentRedoActionTitle(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllUndoActionTitles( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.getAllUndoActionTitles(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllRedoActionTitles( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.getAllRedoActionTitles(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.clear( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.clearRedo( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::reset() throw (RuntimeException) + { + // SYNCHRONIZED ---> + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.reset( aGuard ); + // <--- SYNCHRONIZED + m_pImpl->invalidateXDo_nolck(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::lock( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.lock(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::unlock( ) throw (RuntimeException, NotLockedException) + { + UndoManagerGuard aGuard( *this ); + m_pImpl->aUndoHelper.unlock(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL DocumentUndoManager::isLocked( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.isLocked(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.addUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL DocumentUndoManager::getParent( ) throw (RuntimeException) + { + UndoManagerGuard aGuard( *this ); + return static_cast< XModel* >( &getBaseModel() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DocumentUndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException) + { + (void)i_parent; + throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() ); + } + +//...................................................................................................................... +} // namespace sfx2 +//...................................................................................................................... diff --git a/sfx2/source/doc/docvor.cxx b/sfx2/source/doc/docvor.cxx index 6367f2a65d76..c017a5779cdd 100644 --- a/sfx2/source/doc/docvor.cxx +++ b/sfx2/source/doc/docvor.cxx @@ -546,6 +546,9 @@ BOOL SfxOrganizeListBox_Impl::Select( SvLBoxEntry* pEntry, BOOL bSelect ) return SvTreeListBox::Select(pEntry,bSelect); Path aPath(this, pEntry); + + // it is ok to use the SfxObjectShellRef here since the object that + // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it GetObjectShell(aPath)->TriggerHelpPI( aPath[nLevel+1], aPath[nLevel+2], aPath[nLevel+3]); return SvTreeListBox::Select(pEntry,bSelect); @@ -691,10 +694,12 @@ BOOL SfxOrganizeListBox_Impl::MoveOrCopyContents(SvLBox *pSourceBox, BOOL bRemovedFromSource = FALSE; Path aSource(pSourceBox, pSource); Path aTarget(this, pTarget); - SfxObjectShellRef aSourceDoc = - ((SfxOrganizeListBox_Impl *)pSourceBox)->GetObjectShell(aSource); + // it is ok to use the SfxObjectShellRef here since the object that + // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it + SfxObjectShellRef aSourceDoc = ((SfxOrganizeListBox_Impl *)pSourceBox)->GetObjectShell(aSource); SfxObjectShellRef aTargetDoc = GetObjectShell(aTarget); + const USHORT nSLevel = ((SfxOrganizeListBox_Impl *)pSourceBox)->GetDocLevel(); const USHORT nTLevel = GetDocLevel(); @@ -1210,6 +1215,9 @@ void SfxOrganizeListBox_Impl::RequestingChilds( SvLBoxEntry* pEntry ) { const USHORT nDocLevel = GetDocLevel(); Path aPath(this, pEntry); + + // it is ok to use the SfxObjectShellRef here since the object that + // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it SfxObjectShellRef aRef = GetObjectShell(aPath); if(aRef.Is()) { @@ -1887,6 +1895,9 @@ long SfxOrganizeDlg_Impl::Dispatch_Impl( USHORT nId, Menu* _pMenu ) if(!QueryDelete_Impl(pDialog, STR_DELETE_TEMPLATE, pFocusBox->GetEntryText(pEntry))) return 1; Path aPath(pFocusBox, pEntry); + + // it is ok to use the SfxObjectShellRef here since the object that + // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it SfxObjectShellRef aRef = pFocusBox->GetObjectShell(aPath); if(aRef.Is() && aRef->Remove(aPath[1+pFocusBox->GetDocLevel()], @@ -1953,6 +1964,9 @@ long SfxOrganizeDlg_Impl::Dispatch_Impl( USHORT nId, Menu* _pMenu ) if ( !pEntry ) return 1; Path aPath( pFocusBox, pEntry ); + + // it is ok to use the SfxObjectShellRef here since the object that + // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it SfxObjectShellRef aRef = pFocusBox->GetObjectShell( aPath ); if ( aRef.Is() ) { diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index bceb7477a61e..2ccf5fa7a849 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -747,7 +747,7 @@ sal_Int8 ModelData_Impl::CheckFilter( const ::rtl::OUString& aFilterName ) return STATUS_SAVEAS_STANDARDNAME; } else if ( ( !( nFiltFlags & SFX_FILTER_OWN ) || ( nFiltFlags & SFX_FILTER_ALIEN ) ) - && !( nFiltFlags & SFX_FILTER_SILENTEXPORT ) && aDefFiltPropsHM.size() + && aDefFiltPropsHM.size() && ( nDefFiltFlags & SFX_FILTER_EXPORT ) && !( nDefFiltFlags & SFX_FILTER_INTERNAL )) { // the default filter is acceptable and the old filter is alian one diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 91f5842c1fb7..4aea842e44e9 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1088,60 +1088,10 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) //REPLACE pInfo->Save(xDocStor); } } -/* - SfxConfigManager *pCfgMgr = SFX_CFGMANAGER(); - { - SfxConfigManager *pTemplCfg = new SfxConfigManager(aTemplStor, pCfgMgr); - SetConfigManager(pTemplCfg); - SetTemplateConfig(TRUE); - - // Falls der gerade zerst"orte CfgMgr des Dokuments der - // aktive war, pCfgMgr lieber neu holen - pCfgMgr = SFX_CFGMANAGER(); - - // ggf. den neuen ConfigManager aktivieren - if ( this == SfxObjectShell::Current() ) - pTemplCfg->Activate(pCfgMgr); - } -*/ - // Template und Template-DocInfo werden nicht mehr gebraucht -// delete pTemplInfo; } } } -SfxObjectShellRef MakeObjectShellForOrganizer_Impl( const String& aTargetURL, BOOL bForWriting ) -{ - // check for own format - SfxObjectShellRef xDoc; - StreamMode nMode = bForWriting ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY; - SfxMedium *pMed = new SfxMedium( aTargetURL, nMode, FALSE, 0 ); - const SfxFilter* pFilter = NULL; - pMed->UseInteractionHandler(TRUE); - if( SFX_APP()->GetFilterMatcher().GuessFilter( *pMed, &pFilter ) == ERRCODE_NONE && pFilter && pFilter->IsOwnFormat() ) - { - // create document - xDoc = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_ORGANIZER ); - if ( xDoc.Is() ) - { - // partially load, so don't use DoLoad! - xDoc->DoInitNew(0); - // TODO/LATER: make sure that we don't use binary templates! - if( xDoc->LoadFrom( *pMed ) ) - { - // connect to storage, abandon temp. storage - xDoc->DoSaveCompleted( pMed ); - } - else - xDoc.Clear(); - } - } - else - delete pMed; - - return xDoc; -} - sal_Bool SfxObjectShell::IsHelpDocument() const { const SfxFilter* pFilter = GetMedium()->GetFilter(); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 71c7e0e78383..3b27db855e39 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -118,6 +118,7 @@ using namespace ::com::sun::star::container; #include <rtl/bootstrap.hxx> #include <vcl/svapp.hxx> #include <framework/interaction.hxx> +#include <framework/documentundoguard.hxx> #include <comphelper/interaction.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/documentconstants.hxx> @@ -141,7 +142,6 @@ using namespace ::com::sun::star::container; #include <sfx2/ctrlitem.hxx> #include "arrdecl.hxx" #include <sfx2/module.hxx> -#include <sfx2/macrconf.hxx> #include <sfx2/docfac.hxx> #include "helper.hxx" #include "doc.hrc" @@ -1652,15 +1652,8 @@ SfxModule* SfxObjectShell::GetModule() const return GetFactory().GetModule(); } -sal_Bool SfxObjectShell::IsBasic( - const String & rCode, SbxObject * pVCtrl ) -{ - if( !rCode.Len() ) return sal_False; - return SfxMacroConfig::IsBasic( pVCtrl, rCode, GetBasicManager() ); -} - ErrCode SfxObjectShell::CallBasic( const String& rMacro, - const String& rBasic, SbxObject* pVCtrl, SbxArray* pArgs, + const String& rBasic, SbxArray* pArgs, SbxValue* pRet ) { SfxApplication* pApp = SFX_APP(); @@ -1670,23 +1663,13 @@ ErrCode SfxObjectShell::CallBasic( const String& rMacro, return ERRCODE_IO_ACCESSDENIED; } - pApp->EnterBasicCall(); BasicManager *pMgr = GetBasicManager(); if( pApp->GetName() == rBasic ) pMgr = pApp->GetBasicManager(); - ErrCode nRet = SfxMacroConfig::Call( pVCtrl, rMacro, pMgr, pArgs, pRet ); - pApp->LeaveBasicCall(); + ErrCode nRet = SfxApplication::CallBasic( rMacro, pMgr, pArgs, pRet ); return nRet; } -ErrCode SfxObjectShell::Call( const String & rCode, sal_Bool bIsBasicReturn, SbxObject * pVCtrl ) -{ - ErrCode nErr = ERRCODE_NONE; - if ( bIsBasicReturn ) - CallBasic( rCode, String(), pVCtrl ); - return nErr; -} - namespace { static bool lcl_isScriptAccessAllowed_nothrow( const Reference< XInterface >& _rxScriptContext ) @@ -1740,9 +1723,11 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon xScriptProvider.set( xScriptProviderFactory->createScriptProvider( makeAny( _rxScriptContext ) ), UNO_SET_THROW ); } + // ry to protect the invocation context's undo manager (if present), just in case the script tampers with it + ::framework::DocumentUndoGuard aUndoGuard( _rxScriptContext.get() ); + // obtain the script, and execute it Reference< provider::XScript > xScript( xScriptProvider->getScript( _rScriptURL ), UNO_QUERY_THROW ); - aRet = xScript->invoke( aParams, aOutParamIndex, aOutParam ); } catch ( const uno::Exception& ) @@ -1782,118 +1767,6 @@ ErrCode SfxObjectShell::CallXScript( const String& rScriptURL, } //------------------------------------------------------------------------- -namespace { - using namespace ::com::sun::star::uno; - - //..................................................................... - static SbxArrayRef lcl_translateUno2Basic( const void* _pAnySequence ) - { - SbxArrayRef xReturn; - if ( _pAnySequence ) - { - // in real it's a sequence of Any (by convention) - const Sequence< Any >* pArguments = static_cast< const Sequence< Any >* >( _pAnySequence ); - - // do we have arguments ? - if ( pArguments->getLength() ) - { - // yep - xReturn = new SbxArray; - String sEmptyName; - - // loop through the sequence - const Any* pArg = pArguments->getConstArray(); - const Any* pArgEnd = pArg + pArguments->getLength(); - - for ( sal_uInt16 nArgPos=1; pArg != pArgEnd; ++pArg, ++nArgPos ) - // and create a Sb object for every Any - xReturn->Put( GetSbUnoObject( sEmptyName, *pArg ), nArgPos ); - } - } - return xReturn; - } - //..................................................................... - void lcl_translateBasic2Uno( const SbxVariableRef& _rBasicValue, void* _pAny ) - { - if ( _pAny ) - *static_cast< Any* >( _pAny ) = sbxToUnoValue( _rBasicValue ); - } -} -//------------------------------------------------------------------------- -ErrCode SfxObjectShell::CallStarBasicScript( const String& _rMacroName, const String& _rLocation, - const void* _pArguments, void* _pReturn ) -{ - OSL_TRACE("in CallSBS"); - ::vos::OClearableGuard aGuard( Application::GetSolarMutex() ); - - // the arguments for the call - SbxArrayRef xMacroArguments = lcl_translateUno2Basic( _pArguments ); - - // the return value - SbxVariableRef xReturn = _pReturn ? new SbxVariable : NULL; - - // the location (document or application) - String sMacroLocation; - if ( _rLocation.EqualsAscii( "application" ) ) - sMacroLocation = SFX_APP()->GetName(); -#ifdef DBG_UTIL - else - DBG_ASSERT( _rLocation.EqualsAscii( "document" ), - "SfxObjectShell::CallStarBasicScript: invalid (unknown) location!" ); -#endif - - // call the script - ErrCode eError = CallBasic( _rMacroName, sMacroLocation, NULL, xMacroArguments, xReturn ); - - // translate the return value - lcl_translateBasic2Uno( xReturn, _pReturn ); - - // outta here - return eError; -} - -//------------------------------------------------------------------------- -ErrCode SfxObjectShell::CallScript( - const String & rScriptType, - const String & rCode, - const void *pArgs, - void *pRet -) -{ - ::vos::OClearableGuard aGuard( Application::GetSolarMutex() ); - ErrCode nErr = ERRCODE_NONE; - if( rScriptType.EqualsAscii( "StarBasic" ) ) - { - // the arguments for the call - SbxArrayRef xMacroArguments = lcl_translateUno2Basic( pArgs ); - - // the return value - SbxVariableRef xReturn = pRet ? new SbxVariable : NULL; - - // call the script - nErr = CallBasic( rCode, String(), NULL, xMacroArguments, xReturn ); - - // translate the return value - lcl_translateBasic2Uno( xReturn, pRet ); - - // did this fail because the method was not found? - if ( nErr == ERRCODE_BASIC_PROC_UNDEFINED ) - { // yep-> look in the application BASIC module - nErr = CallBasic( rCode, SFX_APP()->GetName(), NULL, xMacroArguments, xReturn ); - } - } - else if( rScriptType.EqualsAscii( "JavaScript" ) ) - { - DBG_ERROR( "JavaScript not allowed" ); - return 0; - } - else - { - DBG_ERROR( "StarScript not allowed" ); - } - return nErr; -} - SfxFrame* SfxObjectShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ ) { return pSelf; @@ -1911,51 +1784,6 @@ void SfxObjectShell::SetFlags( SfxObjectShellFlags eFlags ) pImp->eFlags = eFlags; } -/* -void SfxObjectShell::SetBaseURL( const String& rURL ) -{ - pImp->aBaseURL = rURL; - pImp->bNoBaseURL = FALSE; -} - -const String& SfxObjectShell::GetBaseURLForSaving() const -{ - if ( pImp->bNoBaseURL ) - return String(); - return GetBaseURL(); -} - -const String& SfxObjectShell::GetBaseURL() const -{ - if ( pImp->aBaseURL.Len() ) - return pImp->aBaseURL; - return pMedium->GetBaseURL(); -} - -void SfxObjectShell::SetEmptyBaseURL() -{ - pImp->bNoBaseURL = TRUE; -} -*/ -String SfxObjectShell::QueryTitle( SfxTitleQuery eType ) const -{ - String aRet; - - switch( eType ) - { - case SFX_TITLE_QUERY_SAVE_NAME_PROPOSAL: - { - SfxMedium* pMed = GetMedium(); - const INetURLObject aObj( pMed->GetName() ); - aRet = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - if ( !aRet.Len() ) - aRet = GetTitle( SFX_TITLE_CAPTION ); - break; - } - } - return aRet; -} - void SfxHeaderAttributes_Impl::SetAttributes() { bAlert = sal_True; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index c9b5e6f37293..e53e7148e561 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1089,13 +1089,6 @@ void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq) rReq.Done(); break; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_PLAYMACRO: - { - SFX_APP()->PlayMacro_Impl( rReq, GetBasic() ); - break; - } - case SID_DOCINFO_AUTHOR : { ::rtl::OUString aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue(); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 0575660877a3..60921e825e20 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -3025,7 +3025,7 @@ sal_Bool SfxObjectShell::IsInformationLost() { const SfxFilter *pFilt = GetMedium()->GetFilter(); DBG_ASSERT( pFilt && aFilterName.equals( pFilt->GetName() ), "MediaDescriptor contains wrong filter!\n" ); - return ( pFilt && pFilt->IsAlienFormat() && !(pFilt->GetFilterFlags() & SFX_FILTER_SILENTEXPORT ) ); + return ( pFilt && pFilt->IsAlienFormat() ); } return sal_False; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 693911f0404c..a5141662fa3d 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -172,12 +172,7 @@ void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::Even SfxObjectShell::SetCurrentComponent( Reference< XInterface >() ); } - if ( mpDoc->Get_Impl()->bHiddenLockedByAPI ) - { - mpDoc->Get_Impl()->bHiddenLockedByAPI = FALSE; - mpDoc->OwnerLock(FALSE); - } - else if ( !mpDoc->Get_Impl()->bClosing ) + if ( !mpDoc->Get_Impl()->bClosing ) // GCC stuerzt ab, wenn schon im dtor, also vorher Flag abfragen mpDoc->DoClose(); } @@ -835,22 +830,6 @@ void SfxObjectShell::InitBasicManager_Impl() } //-------------------------------------------------------------------- -#if 0 //(mba) -SotObjectRef SfxObjectShell::CreateAggObj( const SotFactory* pFact ) -{ - // SvDispatch? - SotFactory* pDispFact = SvDispatch::ClassFactory(); - if( pFact == pDispFact ) - return( (SfxShellObject*)GetSbxObject() ); - - // sonst unbekannte Aggregation - DBG_ERROR("unkekannte Factory"); - SotObjectRef aSvObjectRef; - return aSvObjectRef; -} -#endif - -//-------------------------------------------------------------------- sal_uInt16 SfxObjectShell::Count() { @@ -873,7 +852,7 @@ SfxObjectShell* SfxObjectShell::GetObjectShell() //-------------------------------------------------------------------- -SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames() +uno::Sequence< ::rtl::OUString > SfxObjectShell::GetEventNames() { static uno::Sequence< ::rtl::OUString >* pEventNameContainer = NULL; diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index 2cd195976832..d088f6981f49 100755 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -53,7 +53,6 @@ #include <ucbhelper/content.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <vos/mutex.hxx> -#include <svtools/printdlg.hxx> #include <cppuhelper/implbase1.hxx> #include <sfx2/viewfrm.hxx> @@ -345,7 +344,7 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue > // Name-Property? if ( rProp.Name.compareToAscii( "Name" ) == 0 ) { - OUSTRING sTemp; + ::rtl::OUString sTemp; if ( ( rProp.Value >>= sTemp ) == sal_False ) throw ::com::sun::star::lang::IllegalArgumentException(); @@ -619,9 +618,9 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& if ( rProp.Name.compareToAscii( "FileName" ) == 0 ) { // unpack th URL and check for a valid and well known protocol - OUSTRING sTemp; + ::rtl::OUString sTemp; if ( - ( rProp.Value.getValueType()!=::getCppuType((const OUSTRING*)0)) || + ( rProp.Value.getValueType()!=::getCppuType((const ::rtl::OUString*)0)) || (!(rProp.Value>>=sTemp)) ) { @@ -718,7 +717,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // Pages-Property else if ( rProp.Name.compareToAscii( "Pages" ) == 0 ) { - OUSTRING sTemp; + ::rtl::OUString sTemp; if( rProp.Value >>= sTemp ) { aCheckedArgs[nProps].Name = rProp.Name; @@ -799,81 +798,8 @@ void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHin { if ( !m_xPrintJob.is() ) m_xPrintJob = new SfxPrintJob_Impl( this ); -/* - PrintDialog* pDlg = pPrintHint->GetPrintDialog(); - Printer* pPrinter = pPrintHint->GetPrinter(); - ::rtl::OUString aPrintFile ( ( pPrinter && pPrinter->IsPrintFileEnabled() ) ? pPrinter->GetPrintFile() : String() ); - ::rtl::OUString aRangeText ( ( pDlg && pDlg->IsRangeChecked(PRINTDIALOG_RANGE) ) ? pDlg->GetRangeText() : String() ); - sal_Bool bSelectionOnly = ( ( pDlg && pDlg->IsRangeChecked(PRINTDIALOG_SELECTION) ) ? sal_True : sal_False ); - - sal_Int32 nArgs = 2; - if ( aPrintFile.getLength() ) - nArgs++; - if ( aRangeText.getLength() ) - nArgs++; - else if ( bSelectionOnly ) - nArgs++; - - m_aPrintOptions.realloc(nArgs); - m_aPrintOptions[0].Name = DEFINE_CONST_UNICODE("CopyCount"); - m_aPrintOptions[0].Value <<= (sal_Int16) (pPrinter ? pPrinter->GetCopyCount() : 1 ); - m_aPrintOptions[1].Name = DEFINE_CONST_UNICODE("Collate"); - m_aPrintOptions[1].Value <<= (sal_Bool) (pDlg ? pDlg->IsCollateChecked() : sal_False ); - - if ( bSelectionOnly ) - { - m_aPrintOptions[2].Name = DEFINE_CONST_UNICODE("Selection"); - m_aPrintOptions[2].Value <<= bSelectionOnly; - } - else if ( aRangeText.getLength() ) - { - m_aPrintOptions[2].Name = DEFINE_CONST_UNICODE("Pages"); - m_aPrintOptions[2].Value <<= aRangeText; - } - - if ( aPrintFile.getLength() ) - { - m_aPrintOptions[nArgs-1].Name = DEFINE_CONST_UNICODE("FileName"); - m_aPrintOptions[nArgs-1].Value <<= aPrintFile; - } -*/ m_aPrintOptions = pPrintHint->GetOptions(); } -/* - else if ( pPrintHint->GetWhich() == -3 ) // -3 : AdditionalPrintOptions - { - uno::Sequence < beans::PropertyValue >& lOldOpts = m_aPrintOptions; - const uno::Sequence < beans::PropertyValue >& lNewOpts = pPrintHint->GetAdditionalOptions(); - sal_Int32 nOld = lOldOpts.getLength(); - sal_Int32 nAdd = lNewOpts.getLength(); - lOldOpts.realloc( nOld + nAdd ); - - // assume that all new elements are overwriting old ones and so don't need to be added - sal_Int32 nTotal = nOld; - for ( sal_Int32 n=0; n<nAdd; n++ ) - { - sal_Int32 m; - for ( m=0; m<nOld; m++ ) - if ( lNewOpts[n].Name == lOldOpts[m].Name ) - // new option overwrites old one - break; - - if ( m == nOld ) - { - // this is a new option, so add it to the resulting sequence - counter must be incremented - lOldOpts[nTotal].Name = lNewOpts[n].Name; - lOldOpts[nTotal++].Value = lNewOpts[n].Value; - } - else - // overwrite old option with new value, counter stays unmodified - lOldOpts[m].Value = lNewOpts[n].Value; - } - - if ( nTotal != lOldOpts.getLength() ) - // at least one new options has overwritten an old one, so we allocated too much - lOldOpts.realloc( nTotal ); - } -*/ else if ( pPrintHint->GetWhich() != -2 ) // -2 : CancelPrintJob { view::PrintJobEvent aEvent; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 81e0ba2a1d8d..13a42e3721c4 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -127,6 +127,7 @@ #include "sfx2/docstoragemodifylistener.hxx" #include "sfx2/brokenpackageint.hxx" #include "graphhelp.hxx" +#include "docundomanager.hxx" #include <sfx2/msgpool.hxx> #include <sfx2/DocumentMetadataAccess.hxx> @@ -153,6 +154,10 @@ using ::com::sun::star::lang::WrappedTargetException; using ::com::sun::star::uno::Type; using ::com::sun::star::uno::Sequence; using ::com::sun::star::document::XDocumentRecovery; +using ::com::sun::star::document::XUndoManager; +using ::com::sun::star::document::XUndoAction; +using ::com::sun::star::document::UndoFailedException; +using ::com::sun::star::frame::XModel; /** This Listener is used to get notified when the XDocumentProperties of the XModel change. @@ -227,10 +232,11 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument uno::Reference< script::provider::XScriptProvider > m_xScriptProvider; uno::Reference< ui::XUIConfigurationManager > m_xUIConfigurationManager; ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListen; - ::rtl::OUString m_sModuleIdentifier; + ::rtl::OUString m_sModuleIdentifier; css::uno::Reference< css::frame::XTitle > m_xTitleHelper; css::uno::Reference< css::frame::XUntitledNumbers > m_xNumberedControllers; - uno::Reference< rdf::XDocumentMetadataAccess> m_xDocumentMetadata; + uno::Reference< rdf::XDocumentMetadataAccess> m_xDocumentMetadata; + ::rtl::Reference< ::sfx2::DocumentUndoManager > m_pDocumentUndoManager; IMPL_SfxBaseModel_DataContainer( ::osl::Mutex& rMutex, SfxObjectShell* pObjectShell ) @@ -248,6 +254,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument , m_xTitleHelper () , m_xNumberedControllers () , m_xDocumentMetadata () // lazy + , m_pDocumentUndoManager () { // increase global instance counter. ++g_nInstanceCounter; @@ -788,6 +795,12 @@ void SAL_CALL SfxBaseModel::dispose() throw(::com::sun::star::uno::RuntimeExcept m_pData->m_pStorageModifyListen = NULL; } + if ( m_pData->m_pDocumentUndoManager.is() ) + { + m_pData->m_pDocumentUndoManager->disposing(); + m_pData->m_pDocumentUndoManager = NULL; + } + lang::EventObject aEvent( (frame::XModel *)this ); m_pData->m_aInterfaceContainer.disposeAndClear( aEvent ); @@ -1185,6 +1198,51 @@ void SAL_CALL SfxBaseModel::disconnectController( const uno::Reference< frame::X m_pData->m_xCurrent = uno::Reference< frame::XController > (); } +namespace +{ + typedef ::cppu::WeakImplHelper1< XUndoAction > ControllerLockUndoAction_Base; + class ControllerLockUndoAction : public ControllerLockUndoAction_Base + { + public: + ControllerLockUndoAction( const Reference< XModel >& i_model, const bool i_undoIsUnlock ) + :m_xModel( i_model ) + ,m_bUndoIsUnlock( i_undoIsUnlock ) + { + } + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (RuntimeException); + virtual void SAL_CALL undo( ) throw (UndoFailedException, RuntimeException); + virtual void SAL_CALL redo( ) throw (UndoFailedException, RuntimeException); + + private: + const Reference< XModel > m_xModel; + const bool m_bUndoIsUnlock; + }; + + ::rtl::OUString SAL_CALL ControllerLockUndoAction::getTitle() throw (RuntimeException) + { + // this action is intended to be used within an UndoContext only, so nobody will ever see this title ... + return ::rtl::OUString(); + } + + void SAL_CALL ControllerLockUndoAction::undo( ) throw (UndoFailedException, RuntimeException) + { + if ( m_bUndoIsUnlock ) + m_xModel->unlockControllers(); + else + m_xModel->lockControllers(); + } + + void SAL_CALL ControllerLockUndoAction::redo( ) throw (UndoFailedException, RuntimeException) + { + if ( m_bUndoIsUnlock ) + m_xModel->lockControllers(); + else + m_xModel->unlockControllers(); + } +} + //________________________________________________________________________________________________________ // frame::XModel //________________________________________________________________________________________________________ @@ -1194,6 +1252,14 @@ void SAL_CALL SfxBaseModel::lockControllers() throw(::com::sun::star::uno::Runti SfxModelGuard aGuard( *this ); ++m_pData->m_nControllerLockCount ; + + if ( m_pData->m_pDocumentUndoManager.is() + && m_pData->m_pDocumentUndoManager->isInContext() + && !m_pData->m_pDocumentUndoManager->isLocked() + ) + { + m_pData->m_pDocumentUndoManager->addUndoAction( new ControllerLockUndoAction( this, true ) ); + } } //________________________________________________________________________________________________________ @@ -1205,6 +1271,14 @@ void SAL_CALL SfxBaseModel::unlockControllers() throw(::com::sun::star::uno::Run SfxModelGuard aGuard( *this ); --m_pData->m_nControllerLockCount ; + + if ( m_pData->m_pDocumentUndoManager.is() + && m_pData->m_pDocumentUndoManager->isInContext() + && !m_pData->m_pDocumentUndoManager->isLocked() + ) + { + m_pData->m_pDocumentUndoManager->addUndoAction( new ControllerLockUndoAction( this, false ) ); + } } //________________________________________________________________________________________________________ @@ -1646,6 +1720,17 @@ void SAL_CALL SfxBaseModel::storeAsURL( const ::rtl::OUString& } //________________________________________________________________________________________________________ +// XUndoManagerSupplier +//________________________________________________________________________________________________________ +Reference< XUndoManager > SAL_CALL SfxBaseModel::getUndoManager( ) throw (RuntimeException) +{ + SfxModelGuard aGuard( *this ); + if ( !m_pData->m_pDocumentUndoManager.is() ) + m_pData->m_pDocumentUndoManager.set( new ::sfx2::DocumentUndoManager( *this ) ); + return m_pData->m_pDocumentUndoManager.get(); +} + +//________________________________________________________________________________________________________ // XStorable //________________________________________________________________________________________________________ @@ -4374,3 +4459,16 @@ throw (uno::RuntimeException, lang::IllegalArgumentException, return xDMA->storeMetadataToMedium(i_rMedium); } +// ===================================================================================================================== +// = SfxModelSubComponent +// ===================================================================================================================== + +SfxModelSubComponent::~SfxModelSubComponent() +{ +} + +void SfxModelSubComponent::disposing() +{ + // nothing to do here +} + diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index bd12f3db80dc..1b3a943c4690 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -116,7 +116,6 @@ public: // global pointers SfxItemPool* pPool; - SfxEventConfiguration* pEventConfig; SvUShorts* pDisabledSlotList; SvStrings* pSecureURLs; SvtSaveOptions* pSaveOptions; @@ -129,7 +128,6 @@ public: USHORT nDocModalMode; // counts documents in modal mode USHORT nAutoTabPageId; - USHORT nBasicCallLevel; USHORT nRescheduleLocks; USHORT nInReschedule; USHORT nAsynchronCalls; diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx new file mode 100755 index 000000000000..9b37671662fd --- /dev/null +++ b/sfx2/source/inc/docundomanager.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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DOCUMENT_UNDO_MANAGER_HXX +#define DOCUMENT_UNDO_MANAGER_HXX + +#include "sfx2/sfxbasemodel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/document/XUndoManager.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> + +#include <boost/scoped_ptr.hpp> +#include <boost/noncopyable.hpp> + +namespace svl +{ + class IUndoManager; +} + +//...................................................................................................................... +namespace sfx2 +{ +//...................................................................................................................... + + //================================================================================================================== + //= DocumentUndoManager + //================================================================================================================== + typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager + > DocumentUndoManager_Base; + struct DocumentUndoManager_Impl; + class DocumentUndoManager :public DocumentUndoManager_Base + ,public SfxModelSubComponent + ,public ::boost::noncopyable + { + friend struct DocumentUndoManager_Impl; + + public: + DocumentUndoManager( SfxBaseModel& i_document ); + virtual ~DocumentUndoManager(); + + // SfxModelSubComponent overridables + virtual void disposing(); + + // non-UNO API for our owner + /** determines whether we have an open Undo context. No mutex locking within this method, no disposal check - this + is the responsibility of the owner. + */ + bool isInContext() const; + + // XInterface + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + + // XUndoManager + virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL enterHiddenUndoContext( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL leaveUndoContext( ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isUndoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isRedoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clear( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearRedo( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + + // XLockable, base of XUndoManager + virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); + + // XChild, base of XUndoManager + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + private: + ::boost::scoped_ptr< DocumentUndoManager_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace sfx2 +//...................................................................................................................... + +#endif // DOCUMENT_UNDO_MANAGER_HXX diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx index e012eea39c2d..83ed69ccb78e 100644 --- a/sfx2/source/inc/eventsupplier.hxx +++ b/sfx2/source/inc/eventsupplier.hxx @@ -57,6 +57,11 @@ #include <svl/lstner.hxx> #include <unotools/eventcfg.hxx> +namespace comphelper +{ + class NamedValueCollection; +} + //-------------------------------------------------------------------------------------------------------- #define NOSUCHELEMENTEXCEPTION ::com::sun::star::container::NoSuchElementException @@ -125,8 +130,12 @@ public: virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw( RUNTIMEEXCEPTION ); - static SvxMacro* ConvertToMacro( const ANY& rElement, SfxObjectShell* pDoc, BOOL bBlowUp ); - static void BlowUpMacro( const ANY& rIn, ANY& rOut, SfxObjectShell* pDoc ); + static SvxMacro* ConvertToMacro( const ANY& rElement, SfxObjectShell* pDoc, BOOL bNormalizeMacro ); + static void NormalizeMacro( const ANY& rIn, ANY& rOut, SfxObjectShell* pDoc ); + static void NormalizeMacro( + const ::comphelper::NamedValueCollection& i_eventDescriptor, + ::comphelper::NamedValueCollection& o_normalizedDescriptor, + SfxObjectShell* i_document ); }; //============================================================================= diff --git a/sfx2/source/menu/mnuitem.cxx b/sfx2/source/menu/mnuitem.cxx index f101b0d426b9..3d2f2db47def 100644 --- a/sfx2/source/menu/mnuitem.cxx +++ b/sfx2/source/menu/mnuitem.cxx @@ -64,7 +64,6 @@ #include <sfx2/dispatch.hxx> #include "idpool.hxx" #include "sfxtypes.hxx" -#include <sfx2/macrconf.hxx> #include "virtmenu.hxx" #include <sfx2/mnuitem.hxx> #include <sfx2/tbxctrl.hxx> @@ -232,8 +231,6 @@ SfxMenuControl::SfxMenuControl(USHORT nSlotId, SfxBindings& rBindings): SfxMenuControl::~SfxMenuControl() { - if ( SfxMacroConfig::IsMacroSlot( GetId() ) ) - SFX_APP()->GetMacroConfig()->ReleaseSlotId(GetId()); delete pSubMenu; } diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx index 77dbd0dcb885..f1eadf744863 100755 --- a/sfx2/source/menu/mnumgr.cxx +++ b/sfx2/source/menu/mnumgr.cxx @@ -77,7 +77,6 @@ #include <sfx2/bindings.hxx> #include "mnucfga.hxx" #include "sfx2/sfxresid.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/msgpool.hxx> #include <sfx2/sfx.hrc> #include "menu.hrc" diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index f0408a66a408..b60681e95afa 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -54,7 +54,6 @@ #include <sfx2/sfx.hrc> #include <sfx2/viewsh.hxx> #include "sfxpicklist.hxx" -#include <sfx2/macrconf.hxx> #include "sfx2/sfxresid.hxx" #include "menu.hrc" #include "sfx2/imagemgr.hxx" @@ -476,24 +475,6 @@ void SfxVirtualMenu::CreateFromSVMenu() { SfxMenuControl *pMnuCtrl=0; String aCmd( pSVMenu->GetItemCommand( nSlotId ) ); - if ( aCmd.CompareToAscii("slot:", 5) == 0 ) - { - SfxMacroConfig* pCfg = SFX_APP()->GetMacroConfig(); - if ( pCfg->IsMacroSlot( nSlotId ) ) - { - if ( pCfg->GetMacroInfo( nSlotId ) ) - { - pCfg->RegisterSlotId( nSlotId ); - pSVMenu->SetItemCommand( nSlotId, String() ); - aCmd.Erase(); - } - else - { - pSVMenu->SetItemCommand( nSlotId, String::CreateFromAscii("macro:///macro.not.founc") ); - } - } - } - if ( aCmd.Len() && (( nSlotId < SID_SFX_START ) || ( nSlotId > SHRT_MAX )) ) { // try to create control via comand name diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index 1ca10c6d9390..9ffc2200cfe8 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -48,6 +48,7 @@ #include <unotools/securityoptions.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/namedvaluecollection.hxx> #include "eventsupplier.hxx" #include <sfx2/app.hxx> @@ -88,9 +89,9 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & { if ( maEventNames[i] == aName ) { - Sequence< PropertyValue > aProperties; + const ::comphelper::NamedValueCollection aEventDescriptor( rElement ); // check for correct type of the element - if ( rElement.hasValue() && !( rElement >>= aProperties ) ) + if ( rElement.hasValue() && aEventDescriptor.empty() ) throw ILLEGALARGUMENTEXCEPTION(); // create Configuration at first, creation might call this method also and that would overwrite everything @@ -98,31 +99,27 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & if ( mpObjShell && !mpObjShell->IsLoading() ) mpObjShell->SetModified( TRUE ); - if ( aProperties.getLength() ) + ::comphelper::NamedValueCollection aNormalizedDescriptor; + NormalizeMacro( aEventDescriptor, aNormalizedDescriptor, mpObjShell ); + + ::rtl::OUString sType; + if ( ( aNormalizedDescriptor.size() == 1 ) + && ( aNormalizedDescriptor.has( PROP_EVENT_TYPE ) == 0 ) + && ( aNormalizedDescriptor.get( PROP_EVENT_TYPE ) >>= sType ) + && ( sType.getLength() == 0 ) + ) { - // "normalize" the macro descriptor - ANY aValue; - BlowUpMacro( rElement, aValue, mpObjShell ); - aValue >>= aProperties; - - ::rtl::OUString sType; - if ( ( aProperties.getLength() == 1 ) - && ( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) - && ( aProperties[0].Value >>= sType ) - && ( sType.getLength() == 0 ) - ) - { - // An empty event type means no binding. Therefore reset data - // to reflect that state. - // (that's for compatibility only. Nowadays, the Tools/Customize dialog should - // set an empty sequence to indicate the request for resetting the assignment.) - aProperties.realloc( 0 ); - } + // An empty event type means no binding. Therefore reset data + // to reflect that state. + // (that's for compatibility only. Nowadays, the Tools/Customize dialog should + // set an empty sequence to indicate the request for resetting the assignment.) + OSL_ENSURE( false, "legacy event assignment format detected" ); + aNormalizedDescriptor.clear(); } - if ( aProperties.getLength() ) + if ( !aNormalizedDescriptor.empty() ) { - maEventData[i] = makeAny( aProperties ); + maEventData[i] <<= aNormalizedDescriptor.getPropertyValues(); } else { @@ -378,13 +375,13 @@ SfxEvents_Impl::~SfxEvents_Impl() } //-------------------------------------------------------------------------------------------------------- -SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* pObjShell, BOOL bBlowUp ) +SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* pObjShell, BOOL bNormalizeMacro ) { SvxMacro* pMacro = NULL; SEQUENCE < PROPERTYVALUE > aProperties; ANY aAny; - if ( bBlowUp ) - BlowUpMacro( rElement, aAny, pObjShell ); + if ( bNormalizeMacro ) + NormalizeMacro( rElement, aAny, pObjShell ); else aAny = rElement; @@ -444,58 +441,38 @@ SvxMacro* SfxEvents_Impl::ConvertToMacro( const ANY& rElement, SfxObjectShell* p return pMacro; } -void SfxEvents_Impl::BlowUpMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell* pDoc ) +void SfxEvents_Impl::NormalizeMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell* pDoc ) { - if ( !pDoc ) - pDoc = SfxObjectShell::Current(); - - SEQUENCE < PROPERTYVALUE > aInProps; - SEQUENCE < PROPERTYVALUE > aOutProps(2); - - if ( !( rEvent >>= aInProps ) ) - return; + const ::comphelper::NamedValueCollection aEventDescriptor( rEvent ); + ::comphelper::NamedValueCollection aEventDescriptorOut; - sal_Int32 nCount = aInProps.getLength(); + NormalizeMacro( aEventDescriptor, aEventDescriptorOut, pDoc ); - if ( !nCount ) - return; + rRet <<= aEventDescriptorOut.getPropertyValues(); +} - OUSTRING aType; - OUSTRING aScript; - OUSTRING aLibrary; - OUSTRING aMacroName; +void SfxEvents_Impl::NormalizeMacro( const ::comphelper::NamedValueCollection& i_eventDescriptor, + ::comphelper::NamedValueCollection& o_normalizedDescriptor, SfxObjectShell* i_document ) +{ + SfxObjectShell* pDoc = i_document; + if ( !pDoc ) + pDoc = SfxObjectShell::Current(); - sal_Int32 nIndex = 0; + ::rtl::OUString aType = i_eventDescriptor.getOrDefault( PROP_EVENT_TYPE, ::rtl::OUString() ); + ::rtl::OUString aScript = i_eventDescriptor.getOrDefault( PROP_SCRIPT, ::rtl::OUString() ); + ::rtl::OUString aLibrary = i_eventDescriptor.getOrDefault( PROP_LIBRARY, ::rtl::OUString() ); + ::rtl::OUString aMacroName = i_eventDescriptor.getOrDefault( PROP_MACRO_NAME, ::rtl::OUString() ); - while ( nIndex < nCount ) - { - if ( aInProps[ nIndex ].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) - { - aInProps[nIndex].Value >>= aType; - aOutProps[0] = aInProps[nIndex]; - } - else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_SCRIPT ) == 0 ) - { - aInProps[nIndex].Value >>= aScript; - aOutProps[1] = aInProps[nIndex]; - } - else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_LIBRARY ) == 0 ) - { - aInProps[ nIndex ].Value >>= aLibrary; - } - else if ( aInProps[ nIndex ].Name.compareToAscii( PROP_MACRO_NAME ) == 0 ) - { - aInProps[ nIndex ].Value >>= aMacroName; - } - nIndex += 1; - } + if ( aType.getLength() ) + o_normalizedDescriptor.put( PROP_EVENT_TYPE, aType ); + if ( aScript.getLength() ) + o_normalizedDescriptor.put( PROP_SCRIPT, aScript ); if ( aType.compareToAscii( STAR_BASIC ) == 0 ) { - aOutProps.realloc(4); if ( aScript.getLength() ) { - if( ! aMacroName.getLength() || ! aLibrary.getLength() ) + if ( !aMacroName.getLength() || !aLibrary.getLength() ) { sal_Int32 nHashPos = aScript.indexOf( '/', 8 ); sal_Int32 nArgsPos = aScript.indexOf( '(' ); @@ -542,22 +519,9 @@ void SfxEvents_Impl::BlowUpMacro( const ANY& rEvent, ANY& rRet, SfxObjectShell* aLibrary = String::CreateFromAscii("application"); } - aOutProps[1].Name = OUSTRING::createFromAscii( PROP_SCRIPT ); - aOutProps[1].Value <<= aScript; - aOutProps[2].Name = OUSTRING::createFromAscii( PROP_LIBRARY ); - aOutProps[2].Value <<= aLibrary; - aOutProps[3].Name = OUSTRING::createFromAscii( PROP_MACRO_NAME ); - aOutProps[3].Value <<= aMacroName; - rRet <<= aOutProps; - } - else if ( aType.compareToAscii( SVX_MACRO_LANGUAGE_JAVASCRIPT ) == 0 ) - { - aOutProps[1] = aInProps[1]; - rRet <<= aOutProps; - } - else - { - rRet <<= aOutProps; + o_normalizedDescriptor.put( PROP_SCRIPT, aScript ); + o_normalizedDescriptor.put( PROP_LIBRARY, aLibrary ); + o_normalizedDescriptor.put( PROP_MACRO_NAME, aMacroName ); } } diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 7cc25c872eb1..6bf2dc26edd6 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -90,7 +90,6 @@ #include <sfx2/viewfrm.hxx> #include "arrdecl.hxx" #include "sfxtypes.hxx" -#include <sfx2/macrconf.hxx> #include <sfx2/genlink.hxx> #include "sfx2/sfxresid.hxx" #include <sfx2/sfx.hrc> diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index a4707f03d364..4dbb8a3c640e 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -263,25 +263,6 @@ sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlo } // -------------------------------------------------------------------------------------------------------------------- -void SfxFrameLoader_Impl::impl_lockHiddenDocument( SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor ) const -{ - const sal_Bool bHidden = i_rDescriptor.getOrDefault( "Hidden", sal_False ); - if ( !bHidden ) - return; - - const SfxViewFrame* pExistingViewFrame = SfxViewFrame::GetFirst( &i_rDocument ); - if ( pExistingViewFrame ) - return; - - // the document is to be loaded hidden, and it is not yet displayed in any other frame - // To prevent it from being closed when the loader returns, increase its OwnerLock - // (the OwnerLock is normally increased by every frame in which the document is displayed, and by this loader) - i_rDocument.RestoreNoDelete(); - i_rDocument.OwnerLock( TRUE ); - i_rDocument.Get_Impl()->bHiddenLockedByAPI = TRUE; -} - -// -------------------------------------------------------------------------------------------------------------------- void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollection& io_rDescriptor ) const { const ::rtl::OUString sURL = io_rDescriptor.getOrDefault( "URL", ::rtl::OUString() ); @@ -331,7 +312,7 @@ void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollecti } // -------------------------------------------------------------------------------------------------------------------- -SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const +SfxObjectShellRef SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const { for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) ) { @@ -635,15 +616,12 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA // tell the doc its (current) load args. impl_removeLoaderArguments( aDescriptor ); xModel->attachResource( xModel->getURL(), aDescriptor.getPropertyValues() ); - // TODO: not sure this is correct. The original, pre-refactoring code did it this way. However, I could - // imagine scenarios where it is *not* correct to overrule the *existing* model args (XModel::getArgs) - // with the ones passed to the loader here. For instance, what about the MacroExecutionMode? The document - // might have a mode other than the one passed to the loader, and we always overwrite the former with - // the latter. } // get the SfxObjectShell (still needed at the moment) - const SfxObjectShellLock xDoc = impl_findObjectShell( xModel ); + // SfxObjectShellRef is used here ( instead of ...Lock ) since the model is closed below if necessary + // SfxObjectShellLock would be even dangerous here, since the lifetime control should be done outside in case of success + const SfxObjectShellRef xDoc = impl_findObjectShell( xModel ); ENSURE_OR_THROW( xDoc.Is(), "no SfxObjectShell for the given model" ); // ensure the ID of the to-be-created view is in the descriptor, if possible @@ -651,16 +629,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA const sal_Int16 nViewNo = xDoc->GetFactory().GetViewNo_Impl( nViewId, 0 ); const ::rtl::OUString sViewName( xDoc->GetFactory().GetViewFactory( nViewNo ).GetAPIViewName() ); - // if the document is created hidden, prevent it from being deleted until it is shown or disposed - impl_lockHiddenDocument( *xDoc, aDescriptor ); - // TODO; if we wouldn't use a SfxObjectShellLock instance for xDoc, but a simple SfxObjectShellRef, - // then this would not be necessary, /me thinks. That is, the *Lock classes inc/dec a "Lock" counter - // (additional to the ref counter) in their ctor/dtor, and if the lock counter goes to 0, the - // object is closed (DoClose). The impl_lockHiddenDocument is to prevent exactly that premature - // closing. However, a *Ref object wouldn't close, anyway. And in case of unsuccessfull loading, the - // code at the very end of this method cares for closing the XModel, which should also close the - // ObjectShell. - // plug the document into the frame impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName ); bLoadSuccess = sal_True; diff --git a/sfx2/source/view/printer.cxx b/sfx2/source/view/printer.cxx index 310c1a58a578..64bebccd60fd 100644 --- a/sfx2/source/view/printer.cxx +++ b/sfx2/source/view/printer.cxx @@ -30,7 +30,6 @@ #include <vcl/virdev.hxx> #include <vcl/metric.hxx> #include <vcl/msgbox.hxx> -#include <svtools/printdlg.hxx> #include <unotools/printwarningoptions.hxx> #include <svtools/printoptions.hxx> #include <vector> @@ -47,54 +46,23 @@ #include "sfx2/sfxresid.hxx" #include "view.hrc" -#ifdef MSC -// der ist buggy -#define NEW_OBJECTS(Class, nCount) ((Class*) new char[ sizeof(Class) * (nCount) ]) -#else -#define NEW_OBJECTS(Class, nCount) (new Class[nCount]) -#endif - - -USHORT SfxFontSizeInfo::pStaticSizes[] = -{ - 60, - 80, - 100, - 120, - 140, - 180, - 240, - 360, - 480, - 600, - 720 -}; - -//-------------------------------------------------------------------- - -SV_DECL_PTRARR_DEL(SfxFontArr_Impl,SfxFont*,10,5) - // struct SfxPrinter_Impl ------------------------------------------------ struct SfxPrinter_Impl { - SfxFontArr_Impl* mpFonts; BOOL mbAll; BOOL mbSelection; BOOL mbFromTo; BOOL mbRange; SfxPrinter_Impl() : - mpFonts ( NULL ), mbAll ( TRUE ), mbSelection ( TRUE ), mbFromTo ( TRUE ), mbRange ( TRUE ) {} - ~SfxPrinter_Impl() { delete mpFonts; } + ~SfxPrinter_Impl() {} }; -#define FONTS() pImpl->mpFonts - struct SfxPrintOptDlg_Impl { sal_Bool mbHelpDisabled; @@ -103,98 +71,6 @@ struct SfxPrintOptDlg_Impl mbHelpDisabled ( sal_False ) {} }; -//-------------------------------------------------------------------- - -SfxFontSizeInfo::SfxFontSizeInfo( const SfxFont &rFont, - const OutputDevice &rDevice ) : - - pSizes(0), - nSizes(0), - bScalable(TRUE) - -{ - if ( 0 == rDevice.GetDevFontCount() ) - bScalable = FALSE; - else - { - OutputDevice &rDev = (OutputDevice&) rDevice; - Font aFont(rFont.GetName(), Size(0,12)); - aFont.SetFamily(rFont.GetFamily()); - aFont.SetPitch(rFont.GetPitch()); - aFont.SetCharSet(rFont.GetCharSet()); - - // verfuegbare Groessen in die Liste eintragen, Groesse in 10tel Punkt - int nSizeCount = rDev.GetDevFontSizeCount(aFont); - pSizes = NEW_OBJECTS(Size, nSizeCount); - const MapMode aOldMapMode = rDev.GetMapMode(); - MapMode aMap(aOldMapMode); - aMap.SetMapUnit(MAP_POINT); - const Fraction aTen(1, 10); - aMap.SetScaleX(aTen); - aMap.SetScaleY(aTen); - rDev.SetMapMode(aMap); - - // Es gibt Fonts mit Bitmaps und skalierbaren Groessen - // In diesem Fall wird der Fonts als skalierbar behandelt. - BOOL bFoundScalable = FALSE; - for ( int i = 0; i < nSizeCount; ++i ) - { - const Size aSize( rDev.GetDevFontSize(aFont, i) ); - if ( aSize.Height() != 0 ) - pSizes[nSizes++] = aSize; - else - bFoundScalable |= TRUE; - } - if( !bFoundScalable ) - bScalable = FALSE; - else - { - // statische Font-Sizes verwenden - delete [] pSizes; - nSizes = 0; - } - rDev.SetMapMode(aOldMapMode); - } - - if ( 0 == nSizes ) - { - nSizes = sizeof(pStaticSizes) / sizeof(USHORT); - pSizes = NEW_OBJECTS(Size, nSizes); - for ( USHORT nPos = 0; nPos <nSizes; ++nPos ) - pSizes[nPos] = Size( 0, pStaticSizes[nPos] ); - } -} - -//-------------------------------------------------------------------- - -SfxFontSizeInfo::~SfxFontSizeInfo() -{ - delete [] pSizes; -} - -//-------------------------------------------------------------------- - -BOOL SfxFontSizeInfo::HasSize(const Size &rSize) const -{ - if ( bScalable ) - return TRUE; - for ( USHORT i = 0; i < nSizes; ++i) - if ( pSizes[i] == rSize ) - return TRUE; - return FALSE; -} - -//-------------------------------------------------------------------- - -SfxFont::SfxFont( const FontFamily eFontFamily, const String& aFontName, - const FontPitch eFontPitch, const CharSet eFontCharSet ): - aName( aFontName ), - eFamily( eFontFamily ), - ePitch( eFontPitch ), - eCharSet( eFontCharSet ) -{ -} - // class SfxPrinter ------------------------------------------------------ SfxPrinter* SfxPrinter::Create( SvStream& rStream, SfxItemSet* pOptions ) @@ -335,194 +211,6 @@ void SfxPrinter::SetOptions( const SfxItemSet &rNewOptions ) //-------------------------------------------------------------------- -void SfxPrinter::EnableRange( USHORT nRange ) -{ - PrintDialogRange eRange = (PrintDialogRange)nRange; - - if ( eRange == PRINTDIALOG_ALL ) - pImpl->mbAll = TRUE; - else if ( eRange == PRINTDIALOG_SELECTION ) - pImpl->mbSelection = TRUE; - else if ( eRange == PRINTDIALOG_FROMTO ) - pImpl->mbFromTo = TRUE; - else if ( eRange == PRINTDIALOG_RANGE ) - pImpl->mbRange = TRUE; -} - -//-------------------------------------------------------------------- - -void SfxPrinter::DisableRange( USHORT nRange ) -{ - PrintDialogRange eRange = (PrintDialogRange)nRange; - - if ( eRange == PRINTDIALOG_ALL ) - pImpl->mbAll = FALSE; - else if ( eRange == PRINTDIALOG_SELECTION ) - pImpl->mbSelection = FALSE; - else if ( eRange == PRINTDIALOG_FROMTO ) - pImpl->mbFromTo = FALSE; - else if ( eRange == PRINTDIALOG_RANGE ) - pImpl->mbRange = FALSE; -} - -//-------------------------------------------------------------------- - -BOOL SfxPrinter::IsRangeEnabled( USHORT nRange ) const -{ - PrintDialogRange eRange = (PrintDialogRange)nRange; - BOOL bRet = FALSE; - - if ( eRange == PRINTDIALOG_ALL ) - bRet = pImpl->mbAll; - else if ( eRange == PRINTDIALOG_SELECTION ) - bRet = pImpl->mbSelection; - else if ( eRange == PRINTDIALOG_FROMTO ) - bRet = pImpl->mbFromTo; - else if ( eRange == PRINTDIALOG_RANGE ) - bRet = pImpl->mbRange; - - return bRet; -} - -//-------------------------------------------------------------------- - -SV_IMPL_PTRARR(SfxFontArr_Impl,SfxFont*) - -//-------------------------------------------------------------------- - -const SfxFont* SfxFindFont_Impl( const SfxFontArr_Impl& rArr, - const String& rName ) -{ - const USHORT nCount = rArr.Count(); - for ( USHORT i = 0; i < nCount; ++i ) - { - const SfxFont *pFont = rArr[i]; - if ( pFont->GetName() == rName ) - return pFont; - } - return NULL; -} - -//-------------------------------------------------------------------- - -void SfxPrinter::UpdateFonts_Impl() -{ - VirtualDevice *pVirDev = 0; - const OutputDevice *pOut = this; - - // falls kein Drucker gefunden werden konnte, ein - // temp. Device erzeugen fuer das Erfragen der Fonts - if( !IsValid() ) - pOut = pVirDev = new VirtualDevice; - - int nCount = pOut->GetDevFontCount(); - FONTS() = new SfxFontArr_Impl((BYTE)nCount); - - std::vector< Font > aNonRegularFonts; - for(int i = 0;i < nCount;++i) - { - Font aFont(pOut->GetDevFont(i)); - if ( (aFont.GetItalic() != ITALIC_NONE) || - (aFont.GetWeight() != WEIGHT_MEDIUM) ) - { - // First: Don't add non-regular fonts. The font name is not unique so we have - // to filter the device font list. - aNonRegularFonts.push_back( aFont ); - } - else if ( FONTS()->Count() == 0 || - (*FONTS())[FONTS()->Count()-1]->GetName() != aFont.GetName() ) - { - DBG_ASSERT(0 == SfxFindFont_Impl(*FONTS(), aFont.GetName()), "Doppelte Fonts vom SV-Device!"); - SfxFont* pTmp = new SfxFont( aFont.GetFamily(), aFont.GetName(), - aFont.GetPitch(), aFont.GetCharSet() ); - FONTS()->C40_INSERT(SfxFont, pTmp, FONTS()->Count()); - } - } - delete pVirDev; - - // Try to add all non-regular fonts. It could be that there was no regular font - // with the same name added. - std::vector< Font >::const_iterator pIter; - for ( pIter = aNonRegularFonts.begin(); pIter != aNonRegularFonts.end(); pIter++ ) - { - if ( SfxFindFont_Impl( *FONTS(), pIter->GetName() ) == 0 ) - { - SfxFont* pTmp = new SfxFont( pIter->GetFamily(), pIter->GetName(), - pIter->GetPitch(), pIter->GetCharSet() ); - FONTS()->C40_INSERT( SfxFont, pTmp, FONTS()->Count() ); - } - } -} - -//-------------------------------------------------------------------- - -USHORT SfxPrinter::GetFontCount() -{ - if ( !FONTS() ) - UpdateFonts_Impl(); - return FONTS()->Count(); -} - -//-------------------------------------------------------------------- - -const SfxFont* SfxPrinter::GetFont( USHORT nNo ) const -{ - DBG_ASSERT( FONTS(), "bitte erst GetFontCount() abfragen!" ); - return (*FONTS())[ nNo ]; -} - -//-------------------------------------------------------------------- - -const SfxFont* SfxPrinter::GetFontByName( const String &rFontName ) -{ - if ( !FONTS() ) - UpdateFonts_Impl(); - return SfxFindFont_Impl(*FONTS(), rFontName); -} - -//-------------------------------------------------------------------- - -BOOL SfxPrinter::InitJob( Window* pUIParent, BOOL bAskAboutTransparentObjects ) -{ - const SvtPrinterOptions aPrinterOpt; - const SvtPrintFileOptions aPrintFileOpt; - const SvtBasePrintOptions* pPrinterOpt = &aPrinterOpt; - const SvtBasePrintOptions* pPrintFileOpt = &aPrintFileOpt; - PrinterOptions aNewPrinterOptions; - BOOL bRet = TRUE; - - ( ( IsPrintFileEnabled() && GetPrintFile().Len() ) ? pPrintFileOpt : pPrinterOpt )->GetPrinterOptions( aNewPrinterOptions ); - - if( bAskAboutTransparentObjects && !aNewPrinterOptions.IsReduceTransparency() ) - { - if ( !Application::IsHeadlessModeEnabled() ) - { - SvtPrintWarningOptions aWarnOpt; - - if( aWarnOpt.IsTransparency() ) - { - TransparencyPrintWarningBox aWarnBox( pUIParent ); - const USHORT nRet = aWarnBox.Execute(); - - if( nRet == RET_CANCEL ) - bRet = FALSE; - else - { - aNewPrinterOptions.SetReduceTransparency( nRet != RET_NO ); - aWarnOpt.SetTransparency( !aWarnBox.IsNoWarningChecked() ); - } - } - } - } - - if( bRet ) - SetPrinterOptions( aNewPrinterOptions ); - - return bRet; -} - -//-------------------------------------------------------------------- - SfxPrintOptionsDialog::SfxPrintOptionsDialog( Window *pParent, SfxViewShell *pViewShell, const SfxItemSet *pSet ) : diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index b8ad1cfc61f7..8fd223279372 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -734,7 +734,7 @@ ANY SfxBaseController::getViewData() throw( ::com::sun::star::uno::RuntimeExcept if ( m_pData->m_pViewShell ) { m_pData->m_pViewShell->WriteUserData( sData1 ) ; - OUSTRING sData( sData1 ); + ::rtl::OUString sData( sData1 ); aAny <<= sData ; } @@ -750,7 +750,7 @@ void SAL_CALL SfxBaseController::restoreViewData( const ANY& aValue ) throw( ::c ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pData->m_pViewShell ) { - OUSTRING sData; + ::rtl::OUString sData; aValue >>= sData ; m_pData->m_pViewShell->ReadUserData( sData ) ; } @@ -781,7 +781,7 @@ REFERENCE< XMODEL > SAL_CALL SfxBaseController::getModel() throw( ::com::sun::st //________________________________________________________________________________________________________ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOURL& aURL , - const OUSTRING& sTargetFrameName, + const ::rtl::OUString& sTargetFrameName, sal_Int32 eSearchFlags ) throw( RUNTIMEEXCEPTION ) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); @@ -938,12 +938,12 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU // SfxBaseController -> XDispatchProvider //________________________________________________________________________________________________________ -SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SfxBaseController::queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException ) +uno::Sequence< REFERENCE< XDISPATCH > > SAL_CALL SfxBaseController::queryDispatches( const uno::Sequence< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException ) { // Create return list - which must have same size then the given descriptor // It's not allowed to pack it! sal_Int32 nCount = seqDescripts.getLength(); - SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount ); + uno::Sequence< REFERENCE< XDISPATCH > > lDispatcher( nCount ); for( sal_Int32 i=0; i<nCount; ++i ) { diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index dbadbc54ebd4..4dcd4bb4709e 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -953,7 +953,7 @@ void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq ) { // gibt es an der obersten Shell einen Undo-Manager? SfxShell *pSh = GetDispatcher()->GetShell(0); - SfxUndoManager* pShUndoMgr = pSh->GetUndoManager(); + ::svl::IUndoManager* pShUndoMgr = pSh->GetUndoManager(); sal_Bool bOK = sal_False; if ( pShUndoMgr ) { @@ -965,20 +965,20 @@ void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq ) break; case SID_UNDO: - pShUndoMgr->Undo(0); + pShUndoMgr->Undo(); GetBindings().InvalidateAll(sal_False); bOK = sal_True; break; case SID_REDO: - pShUndoMgr->Redo(0); + pShUndoMgr->Redo(); GetBindings().InvalidateAll(sal_False); bOK = sal_True; break; case SID_REPEAT: if ( pSh->GetRepeatTarget() ) - pShUndoMgr->Repeat( *pSh->GetRepeatTarget(), 0); + pShUndoMgr->Repeat( *pSh->GetRepeatTarget() ); bOK = sal_True; break; } @@ -1004,7 +1004,7 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet ) // Ich bin gerade am Reloaden und Yielde so vor mich hin ... return; - SfxUndoManager *pShUndoMgr = pSh->GetUndoManager(); + ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager(); if ( !pShUndoMgr ) { // der SW hat eigenes Undo an der View @@ -1040,10 +1040,10 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet ) rSet.DisableItem( SID_REDO ); SfxRepeatTarget *pTarget = pSh->GetRepeatTarget(); if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() && - pShUndoMgr->CanRepeat(*pTarget, 0) ) + pShUndoMgr->CanRepeat(*pTarget) ) { String aTmp( SvtResId(STR_REPEAT) ); - aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget, 0); + aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget); rSet.Put( SfxStringItem( SID_REPEAT, aTmp ) ); } else @@ -2876,8 +2876,6 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString& sMacro ) } } - pSfxApp->EnterBasicCall(); - BasicManager* pBasMgr = 0; if ( aLocation.EqualsIgnoreCaseAscii( "application" ) ) { @@ -3010,19 +3008,11 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString& sMacro ) } } } - - pSfxApp->LeaveBasicCall(); } else { // add code for "session only" macro } - - /* - FILE* pFile = fopen( "macro.bas", "a" ); - fprintf( pFile, "%s", ::rtl::OUStringToOString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8).getStr() ); - fclose ( pFile ); - */ } void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 4ef4244f28e6..24ed85556466 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -34,7 +34,6 @@ #include <svl/itempool.hxx> #include <vcl/msgbox.hxx> -#include <svtools/printdlg.hxx> #include <svtools/prnsetup.hxx> #include <svl/flagitem.hxx> #include <svl/stritem.hxx> @@ -352,30 +351,6 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt } } -// ----------------------------------------------------------------------- - -void DisableRanges( PrintDialog& rDlg, SfxPrinter* pPrinter ) - -/* [Beschreibung] - - Mit dieser Funktion werden die nicht verf"ugbaren Ranges - vom Printer zum PrintDialog geforwarded. -*/ - -{ - if ( !pPrinter ) - return; - - if ( !pPrinter->IsRangeEnabled( PRINTDIALOG_ALL ) ) - rDlg.DisableRange( PRINTDIALOG_ALL ); - if ( !pPrinter->IsRangeEnabled( PRINTDIALOG_SELECTION ) ) - rDlg.DisableRange( PRINTDIALOG_SELECTION ); - if ( !pPrinter->IsRangeEnabled( PRINTDIALOG_FROMTO ) ) - rDlg.DisableRange( PRINTDIALOG_FROMTO ); - if ( !pPrinter->IsRangeEnabled( PRINTDIALOG_RANGE ) ) - rDlg.DisableRange( PRINTDIALOG_RANGE ); -} - //==================================================================== class SfxDialogExecutor_Impl @@ -392,7 +367,6 @@ class SfxDialogExecutor_Impl { private: SfxViewShell* _pViewSh; - PrintDialog* _pPrintParent; PrinterSetupDialog* _pSetupParent; SfxItemSet* _pOptions; sal_Bool _bModified; @@ -401,7 +375,6 @@ private: DECL_LINK( Execute, void * ); public: - SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrintDialog* pParent ); SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent ); ~SfxDialogExecutor_Impl() { delete _pOptions; } @@ -412,22 +385,9 @@ public: //-------------------------------------------------------------------- -SfxDialogExecutor_Impl::SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrintDialog* pParent ) : - - _pViewSh ( pViewSh ), - _pPrintParent ( pParent ), - _pSetupParent ( NULL ), - _pOptions ( NULL ), - _bModified ( sal_False ), - _bHelpDisabled ( sal_False ) - -{ -} - SfxDialogExecutor_Impl::SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent ) : _pViewSh ( pViewSh ), - _pPrintParent ( NULL ), _pSetupParent ( pParent ), _pOptions ( NULL ), _bModified ( sal_False ), @@ -443,27 +403,13 @@ IMPL_LINK( SfxDialogExecutor_Impl, Execute, void *, EMPTYARG ) // Options lokal merken if ( !_pOptions ) { - DBG_ASSERT( _pPrintParent || _pSetupParent, "no dialog parent" ); - if( _pPrintParent ) - _pOptions = ( (SfxPrinter*)_pPrintParent->GetPrinter() )->GetOptions().Clone(); - else if( _pSetupParent ) + DBG_ASSERT( _pSetupParent, "no dialog parent" ); + if( _pSetupParent ) _pOptions = ( (SfxPrinter*)_pSetupParent->GetPrinter() )->GetOptions().Clone(); } - if ( _pOptions && _pPrintParent && _pPrintParent->IsSheetRangeAvailable() ) - { - SfxItemState eState = _pOptions->GetItemState( SID_PRINT_SELECTEDSHEET ); - if ( eState != SFX_ITEM_UNKNOWN ) - { - PrintSheetRange eRange = _pPrintParent->GetCheckedSheetRange(); - BOOL bValue = ( PRINTSHEETS_ALL != eRange ); - _pOptions->Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, bValue ) ); - } - } - // Dialog ausf"uhren - SfxPrintOptionsDialog* pDlg = new SfxPrintOptionsDialog( _pPrintParent ? static_cast<Window*>(_pPrintParent) - : static_cast<Window*>(_pSetupParent), + SfxPrintOptionsDialog* pDlg = new SfxPrintOptionsDialog( static_cast<Window*>(_pSetupParent), _pViewSh, _pOptions ); if ( _bHelpDisabled ) pDlg->DisableHelp(); @@ -472,15 +418,6 @@ IMPL_LINK( SfxDialogExecutor_Impl, Execute, void *, EMPTYARG ) delete _pOptions; _pOptions = pDlg->GetOptions().Clone(); - if ( _pOptions && _pPrintParent && _pPrintParent->IsSheetRangeAvailable() ) - { - const SfxPoolItem* pItem; - if ( SFX_ITEM_SET == _pOptions->GetItemState( SID_PRINT_SELECTEDSHEET, FALSE , &pItem ) ) - { - _pPrintParent->CheckSheetRange( ( (const SfxBoolItem*)pItem )->GetValue() - ? PRINTSHEETS_SELECTED_SHEETS : PRINTSHEETS_ALL ); - } - } } delete pDlg; @@ -687,7 +624,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) USHORT nDialogRet = RET_CANCEL; // BOOL bCollate=FALSE; SfxPrinter* pPrinter = 0; - PrintDialog* pPrintDlg = 0; SfxDialogExecutor_Impl* pExecutor = 0; bool bSilent = false; BOOL bIsAPI = rReq.GetArgs() && rReq.GetArgs()->Count(); @@ -895,16 +831,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // forget new printer, it was taken over (as pPrinter) or deleted pDlgPrinter = NULL; - /* Now lets reset the Dialog printer, since its freed */ - if (pPrintDlg) - pPrintDlg->SetPrinter (pPrinter); } else { // PrinterDialog is used to transfer information on printing, // so it will only be deleted here if dialog was cancelled DELETEZ( pDlgPrinter ); - DELETEZ( pPrintDlg ); rReq.Ignore(); if ( SID_PRINTDOC == nId ) rReq.SetReturnValue(SfxBoolItem(0,FALSE)); @@ -923,80 +855,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) //-------------------------------------------------------------------- -PrintDialog* SfxViewShell::CreatePrintDialog( Window* /*pParent*/ ) - -/* [Beschreibung] - - Diese Methode kann "uberladen werden, um einen speziellen PrintDialog - zu erzeugen. Dies ist z.B. notwendig wenn spezielle <StarView> Features - wie drucken von Seitenbereichen. -*/ - -{ - #if 0 - PrintDialog *pDlg = new PrintDialog( pParent, false ); - pDlg->SetFirstPage( 1 ); - pDlg->SetLastPage( 9999 ); - pDlg->EnableCollate(); - return pDlg; - #else - return NULL; - #endif -} - -//-------------------------------------------------------------------- - -void SfxViewShell::PreparePrint( PrintDialog * ) -{ -} - -//-------------------------------------------------------------------- - - -ErrCode SfxViewShell::DoPrint( SfxPrinter* /*pPrinter*/, - PrintDialog* /*pPrintDlg*/, - BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) -{ - #if 0 - // Printer-Dialogbox waehrend des Ausdrucks mu\s schon vor - // StartJob erzeugt werden, da SV bei einem Quit-Event h"angt - SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - SfxPrinter *pDocPrinter = GetPrinter(TRUE); - if ( !pPrinter ) - pPrinter = pDocPrinter; - else if ( pDocPrinter != pPrinter ) - { - pProgress->RestoreOnEndPrint( pDocPrinter->Clone() ); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - } - pProgress->SetWaitMode(FALSE); - - // Drucker starten - PreparePrint( pPrintDlg ); - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); - if ( pPrinter->StartJob(pObjShell->GetTitle(0)) ) - { - // Drucken - Print( *pProgress, bIsAPI, pPrintDlg ); - pProgress->Stop(); - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); - } - else - { - // Printer konnte nicht gestartet werden - delete pProgress; - } - - return pPrinter->GetError(); - #else - DBG_ERROR( "DoPrint called, dead code !" ); - return ERRCODE_IO_NOTSUPPORTED; - #endif -} - -//-------------------------------------------------------------------- - BOOL SfxViewShell::IsPrinterLocked() const { return pImp->m_nPrinterLocks > 0; @@ -1026,13 +884,6 @@ void SfxViewShell::LockPrinter( BOOL bLock) //-------------------------------------------------------------------- -USHORT SfxViewShell::Print( SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/, PrintDialog* /*pDlg*/ ) -{ - return 0; -} - -//-------------------------------------------------------------------- - SfxPrinter* SfxViewShell::GetPrinter( BOOL /*bCreate*/ ) { return 0; diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 59d156f82018..f6c1a594fdd5 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -919,7 +919,7 @@ #include "vcl/cursor.hxx" #include "vcl/decoview.hxx" #include "vcl/dndhelp.hxx" -#include "vcl/fldunit.hxx" +#include "tools/fldunit.hxx" #include "vcl/fntstyle.hxx" #include "unotools/fontcvt.hxx" #include "vcl/gdimtf.hxx" @@ -938,7 +938,7 @@ #include "vcl/unohelp.hxx" #include "vcl/unohelp2.hxx" #include "vcl/wall.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vos/mutex.hxx" #include "vos/ref.hxx" #include "vos/refernce.hxx" diff --git a/svx/inc/svx/fmgridif.hxx b/svx/inc/svx/fmgridif.hxx index 886db3280d60..df21245bc99b 100644 --- a/svx/inc/svx/fmgridif.hxx +++ b/svx/inc/svx/fmgridif.hxx @@ -49,7 +49,7 @@ #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <toolkit/controls/unocontrol.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <comphelper/uno3.hxx> diff --git a/svx/inc/svx/fmtools.hxx b/svx/inc/svx/fmtools.hxx index b39f46e85d14..f98919fe47d8 100644 --- a/svx/inc/svx/fmtools.hxx +++ b/svx/inc/svx/fmtools.hxx @@ -71,7 +71,7 @@ #include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/util/XNumberFormats.hpp> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <cppuhelper/weakref.hxx> #include <comphelper/uno3.hxx> #include <comphelper/stl_types.hxx> diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index b1bb7d74887f..21e9b5c5a05f 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -632,6 +632,7 @@ public: /** application can set it's own undo manager, BegUndo, EndUndo and AddUndoAction calls are routet to this interface if given */ void SetSdrUndoManager( SfxUndoManager* pUndoManager ); + SfxUndoManager* GetSdrUndoManager() const; /** applications can set their own undo factory to overide creation of undo actions. The SdrModel will become owner of the given SdrUndoFactory diff --git a/svx/inc/svx/unoshtxt.hxx b/svx/inc/svx/unoshtxt.hxx index c06d3955b442..07e6ef79f7ca 100644 --- a/svx/inc/svx/unoshtxt.hxx +++ b/svx/inc/svx/unoshtxt.hxx @@ -90,6 +90,8 @@ public: void ChangeModel( SdrModel* pNewModel ); + void UpdateOutliner(); + private: SVX_DLLPRIVATE SvxTextEditSource( SvxTextEditSourceImpl* pImpl ); diff --git a/svx/inc/svx/xdef.hxx b/svx/inc/svx/xdef.hxx index 963e4935c617..dd0fbd802291 100644 --- a/svx/inc/svx/xdef.hxx +++ b/svx/inc/svx/xdef.hxx @@ -36,7 +36,8 @@ |* \************************************************************************/ -#define COL_DEFAULT_SHAPE_FILLING RGB_COLORDATA( 153, 204, 255 ) // blue 8 +#define COL_DEFAULT_SHAPE_FILLING RGB_COLORDATA( 0xCF, 0xE7, 0xE5 ) +#define COL_DEFAULT_SHAPE_STROKE RGB_COLORDATA( 128, 128, 128 ) #define XATTR_START 1000 diff --git a/svx/prj/makefile.mk b/svx/prj/makefile.mk deleted file mode 100644 index 2a0b99e72fd5..000000000000 --- a/svx/prj/makefile.mk +++ /dev/null @@ -1,2 +0,0 @@ -all: - cd .. && make -srj9 diff --git a/svx/source/dialog/bmpmask.src b/svx/source/dialog/bmpmask.src index a9cd2fe60b2f..7823007dbe7c 100644 --- a/svx/source/dialog/bmpmask.src +++ b/svx/source/dialog/bmpmask.src @@ -289,7 +289,7 @@ DockingWindow RID_SVXDLG_BMPMASK ImageBitmap = Bitmap { File = "sc10350.bmp" ; }; MASKCOLOR }; - Text [ en-US ] = "Eyedropper" ; + Text [ en-US ] = "Pipette" ; }; }; }; @@ -300,7 +300,7 @@ DockingWindow RID_SVXDLG_BMPMASK Pos = MAP_APPFONT ( 22 , 6 ) ; Size = MAP_APPFONT ( 43 , 14 ) ; }; - Text [ en-US ] = "Eyedropper" ; + Text [ en-US ] = "Color Replacer" ; Image IMG_PIPETTE { diff --git a/svx/source/dialog/contdlg.src b/svx/source/dialog/contdlg.src index bf587b3b1fda..989bdd93d336 100644 --- a/svx/source/dialog/contdlg.src +++ b/svx/source/dialog/contdlg.src @@ -170,7 +170,7 @@ FloatingWindow RID_SVXDLG_CONTOUR { Identifier = TBI_PIPETTE ; HelpId = HID_CONTDLG_PIPETTE ; - Text [ en-US ] = "Eyedropper" ; + Text [ en-US ] = "Pipette" ; AutoCheck = TRUE ; }; }; diff --git a/svx/source/dialog/optgrid.cxx b/svx/source/dialog/optgrid.cxx index f281580b93db..8a5bfa75f7fa 100644 --- a/svx/source/dialog/optgrid.cxx +++ b/svx/source/dialog/optgrid.cxx @@ -276,8 +276,8 @@ BOOL SvxGridTabPage::FillItemSet( SfxItemSet& rCoreSet ) aGridItem.nFldDrawX = (UINT32) nX; aGridItem.nFldDrawY = (UINT32) nY; - aGridItem.nFldDivisionX = static_cast<long>(aNumFldDivisionX.GetValue()); - aGridItem.nFldDivisionY = static_cast<long>(aNumFldDivisionY.GetValue()); + aGridItem.nFldDivisionX = static_cast<long>(aNumFldDivisionX.GetValue()-1); + aGridItem.nFldDivisionY = static_cast<long>(aNumFldDivisionY.GetValue()-1); rCoreSet.Put( aGridItem ); } @@ -303,12 +303,8 @@ void SvxGridTabPage::Reset( const SfxItemSet& rSet ) SetMetricValue( aMtrFldDrawX , pGridAttr->nFldDrawX, eUnit ); SetMetricValue( aMtrFldDrawY , pGridAttr->nFldDrawY, eUnit ); -// UINT32 nFineX = pGridAttr->nFldDivisionX; -// UINT32 nFineY = pGridAttr->nFldDivisionY; -// aNumFldDivisionX.SetValue( nFineX ? (pGridAttr->nFldDrawX / nFineX - 1) : 0 ); -// aNumFldDivisionY.SetValue( nFineY ? (pGridAttr->nFldDrawY / nFineY - 1) : 0 ); - aNumFldDivisionX.SetValue( pGridAttr->nFldDivisionX ); - aNumFldDivisionY.SetValue( pGridAttr->nFldDivisionY ); + aNumFldDivisionX.SetValue( pGridAttr->nFldDivisionX+1 ); + aNumFldDivisionY.SetValue( pGridAttr->nFldDivisionY+1 ); } ChangeGridsnapHdl_Impl( &aCbxUseGridsnap ); diff --git a/svx/source/dialog/optgrid.src b/svx/source/dialog/optgrid.src index 2bc7b430f807..0d65c63f5d2f 100644 --- a/svx/source/dialog/optgrid.src +++ b/svx/source/dialog/optgrid.src @@ -140,6 +140,7 @@ TabPage RID_SVXPAGE_GRID TabStop = TRUE ; Repeat = TRUE ; Spin = TRUE ; + Minimum = 1 ; Maximum = 99 ; Last = 99 ; StrictFormat = TRUE ; @@ -149,7 +150,7 @@ TabPage RID_SVXPAGE_GRID { Pos = MAP_APPFONT ( 223 , 56 ) ; Size = MAP_APPFONT ( 29 , 8 ) ; - Text [ en-US ] = "point(s)" ; + Text [ en-US ] = "space(s)" ; }; NumericField NUM_FLD_DIVISION_Y { @@ -160,6 +161,7 @@ TabPage RID_SVXPAGE_GRID TabStop = TRUE ; Repeat = TRUE ; Spin = TRUE ; + Minimum = 1 ; Maximum = 99 ; Last = 99 ; StrictFormat = TRUE ; diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index f546a2cef0b8..33a7dde794b4 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -1653,11 +1653,14 @@ DbCheckBox::DbCheckBox( DbGridColumn& _rColumn ) namespace { - void setCheckBoxStyle( Window* _pWindow, USHORT nStyle ) + void setCheckBoxStyle( Window* _pWindow, bool bMono ) { AllSettings aSettings = _pWindow->GetSettings(); StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetCheckBoxStyle( nStyle ); + if( bMono ) + aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO ); + else + aStyleSettings.SetOptions( aStyleSettings.GetOptions() & (~STYLE_OPTION_MONO) ); aSettings.SetStyleSettings( aStyleSettings ); _pWindow->SetSettings( aSettings ); } @@ -1683,8 +1686,8 @@ void DbCheckBox::Init( Window& rParent, const Reference< XRowSet >& xCursor ) sal_Int16 nStyle = awt::VisualEffect::LOOK3D; OSL_VERIFY( xModel->getPropertyValue( FM_PROP_VISUALEFFECT ) >>= nStyle ); - setCheckBoxStyle( m_pWindow, nStyle == awt::VisualEffect::FLAT ? STYLE_CHECKBOX_MONO : STYLE_CHECKBOX_WIN ); - setCheckBoxStyle( m_pPainter, nStyle == awt::VisualEffect::FLAT ? STYLE_CHECKBOX_MONO : STYLE_CHECKBOX_WIN ); + setCheckBoxStyle( m_pWindow, nStyle == awt::VisualEffect::FLAT ); + setCheckBoxStyle( m_pPainter, nStyle == awt::VisualEffect::FLAT ); sal_Bool bTristate = sal_True; OSL_VERIFY( xModel->getPropertyValue( FM_PROP_TRISTATE ) >>= bTristate ); diff --git a/svx/source/form/fmscriptingenv.cxx b/svx/source/form/fmscriptingenv.cxx index 154999333296..3e8aa88a2612 100644 --- a/svx/source/form/fmscriptingenv.cxx +++ b/svx/source/form/fmscriptingenv.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" #include "fmscriptingenv.hxx" -#include <svx/fmmodel.hxx> +#include "svx/fmmodel.hxx" /** === begin UNO includes === **/ #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -37,6 +37,7 @@ #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> #include <com/sun/star/lang/DisposedException.hpp> /** === end UNO includes === **/ + #include <tools/diagnose_ex.h> #include <cppuhelper/implbase1.hxx> #include <comphelper/implementationreference.hxx> @@ -45,6 +46,8 @@ #include <vcl/svapp.hxx> #include <vos/mutex.hxx> #include <sfx2/objsh.hxx> +#include <sfx2/app.hxx> +#include <basic/basmgr.hxx> #include <boost/shared_ptr.hpp> @@ -416,60 +419,6 @@ namespace svxform m_rObjectShell.CallXScript( m_sScriptCode, _rArguments, _rSynchronousResult, aOutArgsIndex, aOutArgs ); } - - //................................................................ - //. QualifiedBasicScript - //................................................................ - class QualifiedBasicScript : public IScript - { - SfxObjectShell& m_rObjectShell; - const ::rtl::OUString m_sMacroLocation; - const ::rtl::OUString m_sScriptCode; - - public: - QualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rLocation, const ::rtl::OUString& _rScriptCode ) - :m_rObjectShell( _rObjectShell ) - ,m_sMacroLocation( _rLocation ) - ,m_sScriptCode( _rScriptCode ) - { - } - - // IScript - virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ); - }; - - //................................................................ - void QualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ) - { - m_rObjectShell.CallStarBasicScript( m_sScriptCode, m_sMacroLocation, - &_rArguments, &_rSynchronousResult ); - } - - //................................................................ - //. UnqualifiedBasicScript - //................................................................ - class UnqualifiedBasicScript : public IScript - { - SfxObjectShell& m_rObjectShell; - const ::rtl::OUString m_sScriptCode; - - public: - UnqualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rScriptCode ) - :m_rObjectShell( _rObjectShell ) - ,m_sScriptCode( _rScriptCode ) - { - } - - // IScript - virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ); - }; - - //................................................................ - void UnqualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ) - { - m_rObjectShell.CallScript( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ), m_sScriptCode, - &_rArguments, &_rSynchronousResult ); - } } //-------------------------------------------------------------------- @@ -481,6 +430,7 @@ namespace svxform if ( m_bDisposed ) return; + // SfxObjectShellRef is good here since the model controls the lifetime of the object SfxObjectShellRef xObjectShell = m_rFormModel.GetObjectShell(); if( !xObjectShell.Is() ) return; @@ -513,14 +463,24 @@ namespace svxform sScriptCode = sScriptCode.copy( nPrefixLen + 1 ); } - if ( sMacroLocation.getLength() ) - { // we have a StarBasic macro with fully-qualified macro location - pScript.reset( new QualifiedBasicScript( *xObjectShell, sMacroLocation, sScriptCode ) ); - } - else - { // we have a StarBasic macro without qualified location - let the object shell gues .... - pScript.reset( new UnqualifiedBasicScript( *xObjectShell, sScriptCode ) ); + if ( !sMacroLocation.getLength() ) + { + // legacy format: use the app-wide Basic, if it has a respective method, otherwise fall back to the doc's Basic + if ( SFX_APP()->GetBasicManager()->HasMacro( sScriptCode ) ) + sMacroLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application" ) ); + else + sMacroLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "document" ) ); } + + ::rtl::OUStringBuffer aScriptURI; + aScriptURI.appendAscii( "vnd.sun.star.script:" ); + aScriptURI.append( sScriptCode ); + aScriptURI.appendAscii( "?language=Basic" ); + aScriptURI.appendAscii( "&location=" ); + aScriptURI.append( sMacroLocation ); + + const ::rtl::OUString sScriptURI( aScriptURI.makeStringAndClear() ); + pScript.reset( new NewStyleUNOScript( *xObjectShell, sScriptURI ) ); } OSL_ENSURE( pScript.get(), "FormScriptingEnvironment::doFireScriptEvent: no script to execute!" ); diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index e63325f710e9..ed0d57b96f97 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -130,6 +130,8 @@ private: { Reference< XMultiComponentFactory > xMFac( xCtx->getServiceManager(), UNO_QUERY ); + + // SfxObjectShellRef is good here since the model controls the lifetime of the shell SfxObjectShellRef xObjSh = pModel->GetObjectShell(); Reference< XMultiServiceFactory > xDocFac; if ( xObjSh.Is() ) @@ -150,6 +152,7 @@ private: { try { + // SfxObjectShellRef is good here since the model controls the lifetime of the shell SfxObjectShellRef xObjSh = pModel->GetObjectShell(); if ( xObjSh.Is() && m_vbaListener.is() ) { diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index f9980284993d..1147e71b0731 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -46,7 +46,6 @@ #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <basic/sbuno.hxx> -#include <sfx2/macrconf.hxx> #include <basic/sbx.hxx> #include "fmitems.hxx" #include "fmobj.hxx" diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 7087e3d6793f..528661d2abe4 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -81,7 +81,7 @@ #include <comphelper/property.hxx> #include <comphelper/sequence.hxx> #include <comphelper/uno3.hxx> -#include <comphelper/scopeguard.hxx> +#include <comphelper/flagguard.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <toolkit/controls/unocontrol.hxx> diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 32ad01aca4a2..9198f02278bb 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -626,7 +626,7 @@ BOOL Gallery::CreateTheme( const String& rThemeName, UINT32 nNumFrom ) if( !HasTheme( rThemeName ) && ( GetUserURL().GetProtocol() != INET_PROT_NOT_VALID ) ) { - nLastFileNumber=nNumFrom > nLastFileNumber ? nNumFrom : ++nLastFileNumber; + nLastFileNumber = nNumFrom > nLastFileNumber ? nNumFrom : nLastFileNumber + 1; GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( GetUserURL(), rThemeName, nLastFileNumber, FALSE, FALSE, TRUE, 0, FALSE ); diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx index c7a401ed4054..08eebe99b3df 100644 --- a/svx/source/items/customshapeitem.cxx +++ b/svx/source/items/customshapeitem.cxx @@ -60,7 +60,7 @@ size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustom return (size_t)r1.first.hashCode() + r1.second.hashCode(); }; -TYPEINIT1_FACTORY( SdrCustomShapeGeometryItem, SfxPoolItem , new SdrCustomShapeGeometryItem(0)); +TYPEINIT1_FACTORY( SdrCustomShapeGeometryItem, SfxPoolItem , new SdrCustomShapeGeometryItem); SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem() : SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) {} diff --git a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx index e24aa1c29de7..5d4e6d71fbe9 100644 --- a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx +++ b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx @@ -121,7 +121,7 @@ namespace sdr aViewRange, GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)), 0.0, - 0); + com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>()); updateViewInformation2D(aNewViewInformation2D); // collect primitive data in a sequence; this will already use the updated ViewInformation2D diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index d2264e219c48..d804cce575a1 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -241,7 +241,7 @@ namespace sdr aViewRange, GetXDrawPageForSdrPage(GetSdrPage()), fCurrentTime, - 0); + uno::Sequence<beans::PropertyValue>()); updateViewInformation2D(aNewViewInformation2D); // get whole Primitive2DSequence; this will already make use of updated ViewInformation2D diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index d4748a14ed98..845f1c813325 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -296,7 +296,7 @@ namespace sdr // decompose immediately with neutral ViewInformation. This will // layout the text to more simple TextPrimitives from drawinglayer - const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0); + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence( xRetval, diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx index f52205d88e45..93e3b03d072d 100644 --- a/svx/source/sdr/overlay/overlaymanager.cxx +++ b/svx/source/sdr/overlay/overlaymanager.cxx @@ -138,7 +138,7 @@ namespace sdr mnStripeLengthPixel(5), maDrawinglayerOpt(), maViewTransformation(), - maViewInformation2D(0), + maViewInformation2D(), mfDiscreteOne(0.0) { // set Property 'ReducedDisplayQuality' to true to allow simpler interaction diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index d41b5b1a1c34..058ba94cf3a6 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -902,6 +902,9 @@ void SdrDragMovHdl::TakeSdrDragComment(XubString& rStr) const bool SdrDragMovHdl::BeginSdrDrag() { + if( !GetDragHdl() ) + return false; + DragStat().Ref1()=GetDragHdl()->GetPos(); DragStat().SetShown(!DragStat().IsShown()); SdrHdlKind eKind=GetDragHdl()->GetKind(); @@ -931,7 +934,7 @@ void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt) { Point aPnt(rNoSnapPnt); - if (DragStat().CheckMinMoved(rNoSnapPnt)) + if ( GetDragHdl() && DragStat().CheckMinMoved(rNoSnapPnt)) { if (GetDragHdl()->GetKind()==HDL_MIRX) { @@ -1042,22 +1045,25 @@ void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt) bool SdrDragMovHdl::EndSdrDrag(bool /*bCopy*/) { - switch (GetDragHdl()->GetKind()) + if( GetDragHdl() ) { - case HDL_REF1: - Ref1()=DragStat().GetNow(); - break; + switch (GetDragHdl()->GetKind()) + { + case HDL_REF1: + Ref1()=DragStat().GetNow(); + break; - case HDL_REF2: - Ref2()=DragStat().GetNow(); - break; + case HDL_REF2: + Ref2()=DragStat().GetNow(); + break; - case HDL_MIRX: - Ref1()+=DragStat().GetNow()-DragStat().GetStart(); - Ref2()+=DragStat().GetNow()-DragStat().GetStart(); - break; + case HDL_MIRX: + Ref1()+=DragStat().GetNow()-DragStat().GetStart(); + Ref2()+=DragStat().GetNow()-DragStat().GetStart(); + break; - default: break; + default: break; + } } return true; @@ -1066,7 +1072,11 @@ bool SdrDragMovHdl::EndSdrDrag(bool /*bCopy*/) void SdrDragMovHdl::CancelSdrDrag() { Hide(); - GetDragHdl()->SetPos(DragStat().GetRef1()); + + SdrHdl* pHdl = GetDragHdl(); + if( pHdl ) + pHdl->SetPos(DragStat().GetRef1()); + SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX); if(pHM) diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 7718451ab945..80b586c01600 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -2115,6 +2115,11 @@ void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager ) mpImpl->mpUndoManager = pUndoManager; } +SfxUndoManager* SdrModel::GetSdrUndoManager() const +{ + return mpImpl->mpUndoManager; +} + SdrUndoFactory& SdrModel::GetSdrUndoFactory() const { if( !mpImpl->mpUndoFactory ) diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 0a0c35aec524..18e04f648725 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -940,7 +940,7 @@ void SdrObject::RecalcBoundRect() if(xPrimitives.hasElements()) { // use neutral ViewInformation and get the range of the primitives - const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0); + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; const basegfx::B2DRange aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives, aViewInformation2D)); if(!aRange.isEmpty()) @@ -1202,7 +1202,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const if(xSequence.hasElements()) { // use neutral ViewInformation - const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0); + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; // create extractor, process and get result drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D); @@ -2431,7 +2431,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, BOOL bForceLineDas if(xSequence.hasElements()) { // use neutral ViewInformation - const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0); + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; // create extractor, process and get result drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 7b9185ca7d3b..f10e3bf33fc3 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1430,8 +1430,6 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaint FASTBOOL bContourFrame=IsContourTextFrame(); - ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg ); - if( GetModel() ) { MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0), @@ -1439,6 +1437,8 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaint GetModel()->GetScaleFraction()); rOutl.SetRefMapMode(aMapMode); } + + ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg ); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 4559dacb31d8..65514307bb86 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -354,7 +354,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const if(xSequence.hasElements()) { // create an extractor with neutral ViewInformation - const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0); + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; drawinglayer::processor2d::TextAsPolygonExtractor2D aExtractor(aViewInformation2D); // extract text as polygons diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index 1320aef9b17b..51ab577ca74c 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -988,8 +988,6 @@ Pointer SdrView::GetPreferedPointer(const Point& rMousePos, const OutputDevice* if ((IsDraggingPoints() || IsDraggingGluePoints()) && IsMouseHideWhileDraggingPoints()) return Pointer(POINTER_NULL); - OSL_TRACE("SdrView::GetPreferedPointer(%lx) %lx\n", this, mpCurrentSdrDragMethod); - return mpCurrentSdrDragMethod->GetSdrDragPointer(); } if (IsMarkObj() || IsMarkPoints() || IsMarkGluePoints() || IsEncirclement() || IsSetPageOrg()) return Pointer(POINTER_ARROW); diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx index a905aa0fd2f4..af6a35ddd5ef 100644 --- a/svx/source/unodraw/unopage.cxx +++ b/svx/source/unodraw/unopage.cxx @@ -58,6 +58,7 @@ #include <svx/extrud3d.hxx> #include <svx/lathe3d.hxx> #include <vcl/svapp.hxx> +#include <tools/diagnose_ex.h> using ::rtl::OUString; using namespace ::vos; @@ -306,7 +307,7 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape { OGuard aGuard( Application::GetSolarMutex() ); - if( (mpModel == 0) || (mpPage == 0) ) + if ( ( mpModel == NULL ) || ( mpPage == NULL ) ) throw lang::DisposedException(); SvxShape* pShape = SvxShape::getImplementation( xShape ); @@ -319,6 +320,7 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape if(!pObj) { pObj = CreateSdrObject( xShape ); + ENSURE_OR_RETURN_VOID( pObj != NULL, "SvxDrawPage::add: no SdrObject was created!" ); } else if ( !pObj->IsInserted() ) { @@ -326,14 +328,10 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape mpPage->InsertObject( pObj ); } - if(pObj == NULL) - return; - - if(pShape) - pShape->Create( pObj, this ); + pShape->Create( pObj, this ); + OSL_ENSURE( pShape->GetSdrObject() == pObj, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" ); - if( mpModel ) - mpModel->SetChanged(); + mpModel->SetChanged(); } //---------------------------------------------------------------------- diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index ffc6c28f9fec..6132139e0164 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -39,7 +39,7 @@ #include <com/sun/star/media/ZoomLevel.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <tools/shl.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 0f1482adaf5d..839c4553a859 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -147,7 +147,7 @@ struct SvxShapeImpl * SdrObject so a multiple call to SvxShape::Create() with same SdrObject * is prohibited. */ - SdrObject* mpCreatedObj; + ::tools::WeakReference< SdrObject > mpCreatedObj; // for xComponent ::cppu::OInterfaceContainerHelper maDisposeListeners; @@ -160,7 +160,7 @@ struct SvxShapeImpl ,mpMaster( NULL ) ,mbHasSdrObjectOwnership( false ) ,mbDisposing( false ) - ,mpCreatedObj( NULL ) + ,mpCreatedObj() ,maDisposeListeners( _rMutex ) ,maPropertyNotifier( _rAntiImpl, _rMutex ) { @@ -468,11 +468,12 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) if ( !pNewObj ) return; - OSL_ENSURE( ( mpImpl->mpCreatedObj == NULL ) || ( mpImpl->mpCreatedObj == pNewObj ), + SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get(); + OSL_ENSURE( ( pCreatedObj == NULL ) || ( pCreatedObj == pNewObj ), "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); // --> CL, OD 2005-07-19 #i52126# - correct condition - if ( mpImpl->mpCreatedObj != pNewObj ) + if ( pCreatedObj != pNewObj ) // <-- { DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" ); diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 04770faf694b..f82283417be6 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -122,7 +122,6 @@ private: SvxDrawOutlinerViewForwarder* CreateViewForwarder(); void SetupOutliner(); - void UpdateOutliner(); sal_Bool HasView() const { return mpView ? sal_True : sal_False; } sal_Bool IsEditMode() const @@ -168,6 +167,8 @@ public: virtual void ObjectInDestruction(const SdrObject& rObject); void ChangeModel( SdrModel* pNewModel ); + + void UpdateOutliner(); }; //------------------------------------------------------------------------ @@ -1147,3 +1148,8 @@ void SvxTextEditSource::ChangeModel( SdrModel* pNewModel ) { mpImpl->ChangeModel( pNewModel ); } + +void SvxTextEditSource::UpdateOutliner() +{ + mpImpl->UpdateOutliner(); +} diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index 3d377c88fa4d..0435b62cd3c8 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -52,8 +52,8 @@ XOutdevItemPool::XOutdevItemPool( const XubString aNullStr; const Bitmap aNullBmp; const basegfx::B2DPolyPolygon aNullPol; - const Color aNullLineCol(RGB_Color(COL_BLACK)); - const Color aNullFillCol(RGB_Color(COL_DEFAULT_SHAPE_FILLING)); // "Blue 8" + const Color aNullLineCol(RGB_Color(COL_DEFAULT_SHAPE_STROKE)); + const Color aNullFillCol(RGB_Color(COL_DEFAULT_SHAPE_FILLING)); const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY)); const XDash aNullDash; const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE)); diff --git a/ucb/source/ucp/webdav/ContentProperties.cxx b/ucb/source/ucp/webdav/ContentProperties.cxx index 2285ad28a888..95bc573ecaf7 100644 --- a/ucb/source/ucp/webdav/ContentProperties.cxx +++ b/ucb/source/ucp/webdav/ContentProperties.cxx @@ -120,14 +120,14 @@ ContentProperties::ContentProperties( const DAVResource& rResource ) std::vector< DAVPropertyValue >::const_iterator it = rResource.properties.begin(); - std::vector< DAVPropertyValue >::const_iterator end + std::vector< DAVPropertyValue >::const_iterator end = rResource.properties.end(); - while ( it != end ) - { + while ( it != end ) + { addProperty( (*it) ); ++it; - } + } if ( rResource.uri.getStr()[ rResource.uri.getLength() - 1 ] == sal_Unicode( '/' ) ) @@ -158,6 +158,13 @@ ContentProperties::ContentProperties( const rtl::OUString & rTitle ) } //========================================================================= +ContentProperties::ContentProperties() +: m_xProps( new PropertyValueMap ), + m_bTrailingSlash( sal_False ) +{ +} + +//========================================================================= ContentProperties::ContentProperties( const ContentProperties & rOther ) : m_aEscapedTitle( rOther.m_aEscapedTitle ), m_xProps( rOther.m_xProps.get() @@ -254,7 +261,7 @@ void ContentProperties::UCBNamesToDAVNames( { if ( !bCreationDate ) { - propertyNames.push_back( DAVProperties::CREATIONDATE ); + propertyNames.push_back( DAVProperties::CREATIONDATE ); bCreationDate = sal_True; } } @@ -265,7 +272,7 @@ void ContentProperties::UCBNamesToDAVNames( { if ( !bLastModified ) { - propertyNames.push_back( + propertyNames.push_back( DAVProperties::GETLASTMODIFIED ); bLastModified = sal_True; } @@ -277,7 +284,7 @@ void ContentProperties::UCBNamesToDAVNames( { if ( !bContentType ) { - propertyNames.push_back( + propertyNames.push_back( DAVProperties::GETCONTENTTYPE ); bContentType = sal_True; } @@ -289,7 +296,7 @@ void ContentProperties::UCBNamesToDAVNames( { if ( !bContentLength ) { - propertyNames.push_back( + propertyNames.push_back( DAVProperties::GETCONTENTLENGTH ); bContentLength = sal_True; } @@ -307,7 +314,7 @@ void ContentProperties::UCBNamesToDAVNames( { if ( !bResourceType ) { - propertyNames.push_back( DAVProperties::RESOURCETYPE ); + propertyNames.push_back( DAVProperties::RESOURCETYPE ); bResourceType = sal_True; } } @@ -436,7 +443,7 @@ void ContentProperties::addProperties( const std::vector< DAVPropertyValue > & rProps ) { std::vector< DAVPropertyValue >::const_iterator it = rProps.begin(); - std::vector< DAVPropertyValue >::const_iterator end = rProps.end(); + const std::vector< DAVPropertyValue >::const_iterator end = rProps.end(); while ( it != end ) { @@ -571,3 +578,96 @@ void ContentProperties::addProperty( const rtl::OUString & rName, // Save property. (*m_xProps)[ rName ] = PropertyValue( rValue, bIsCaseSensitive ); } + +//========================================================================= +//========================================================================= +// +// CachableContentProperties Implementation. +// +//========================================================================= +//========================================================================= + +namespace +{ + bool isCachable( rtl::OUString const & rName, + bool isCaseSensitive ) + { + static rtl::OUString aNonCachableProps [] = + { + DAVProperties::LOCKDISCOVERY, + + DAVProperties::GETETAG, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ETag" ) ), + + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Last-Modified" ) ), + DAVProperties::GETLASTMODIFIED, + + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Content-Length" ) ), + DAVProperties::GETCONTENTLENGTH, + + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Date" ) ) + }; + + for ( sal_uInt32 n = 0; + n < ( sizeof( aNonCachableProps ) + / sizeof( aNonCachableProps[ 0 ] ) ); + ++n ) + { + if ( isCaseSensitive ) + { + if ( rName.equals( aNonCachableProps[ n ] ) ) + return false; + } + else + if ( rName.equalsIgnoreAsciiCase( aNonCachableProps[ n ] ) ) + return false; + } + return true; + } + +} // namespace + +//========================================================================= +CachableContentProperties::CachableContentProperties( + const ContentProperties & rProps ) +{ + addProperties( rProps ); +} + +//========================================================================= +void CachableContentProperties::addProperties( + const ContentProperties & rProps ) +{ + const std::auto_ptr< PropertyValueMap > & props = rProps.getProperties(); + + PropertyValueMap::const_iterator it = props->begin(); + const PropertyValueMap::const_iterator end = props->end(); + + while ( it != end ) + { + if ( isCachable( (*it).first, (*it).second.isCaseSensitive() ) ) + m_aProps.addProperty( (*it).first, + (*it).second.value(), + (*it).second.isCaseSensitive() ); + + ++it; + } +} + +//========================================================================= +void CachableContentProperties::addProperties( + const std::vector< DAVPropertyValue > & rProps ) +{ + std::vector< DAVPropertyValue >::const_iterator it = rProps.begin(); + const std::vector< DAVPropertyValue >::const_iterator end = rProps.end(); + + while ( it != end ) + { + if ( isCachable( (*it).Name, (*it).IsCaseSensitive ) ) + m_aProps.addProperty( (*it) ); + + ++it; + } +} diff --git a/ucb/source/ucp/webdav/ContentProperties.hxx b/ucb/source/ucp/webdav/ContentProperties.hxx index 7819698bf667..fb07ad19a705 100644 --- a/ucb/source/ucp/webdav/ContentProperties.hxx +++ b/ucb/source/ucp/webdav/ContentProperties.hxx @@ -102,10 +102,12 @@ struct DAVResource; class ContentProperties { public: - ContentProperties( const DAVResource& rResource ); + ContentProperties(); + + ContentProperties( const DAVResource& rResource ); // Mini props for transient contents. - ContentProperties( const rtl::OUString & rTitle, sal_Bool bFolder ); + ContentProperties( const rtl::OUString & rTitle, sal_Bool bFolder ); // Micro props for non-existing contents. ContentProperties( const rtl::OUString & rTitle ); @@ -181,7 +183,7 @@ public: { return m_xProps; } private: - ::rtl::OUString m_aEscapedTitle; // escaped Title + ::rtl::OUString m_aEscapedTitle; std::auto_ptr< PropertyValueMap > m_xProps; bool m_bTrailingSlash; @@ -192,6 +194,34 @@ private: const PropertyValue * get( const rtl::OUString & rName ) const; }; -} +class CachableContentProperties +{ +private: + ContentProperties m_aProps; + + CachableContentProperties & operator=( const CachableContentProperties & ); // n.i. + CachableContentProperties( const CachableContentProperties & ); // n.i. + +public: + CachableContentProperties( const ContentProperties & rProps ); + + void addProperties( const ContentProperties & rProps ); + + void addProperties( const std::vector< DAVPropertyValue > & rProps ); + + bool containsAllNames( + const com::sun::star::uno::Sequence< + com::sun::star::beans::Property >& rProps, + std::vector< rtl::OUString > & rNamesNotContained ) const + { return m_aProps.containsAllNames( rProps, rNamesNotContained ); } + + const com::sun::star::uno::Any & + getValue( const rtl::OUString & rName ) const + { return m_aProps.getValue( rName ); } + + operator const ContentProperties & () const { return m_aProps; } +}; + +} // namespace webdav_ucp #endif /* !_WEBDAV_UCP_CONTENTPROPERTIES_HXX */ diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index c58ba207199f..9a77a7e941c1 100644 --- a/ucb/source/ucp/webdav/webdavcontent.cxx +++ b/ucb/source/ucp/webdav/webdavcontent.cxx @@ -1476,7 +1476,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( !m_xCachedProps.get() ) - m_xCachedProps.reset( new ContentProperties( *xProps.get() ) ); + m_xCachedProps.reset( new CachableContentProperties( *xProps.get() ) ); else m_xCachedProps->addProperties( *xProps.get() ); @@ -2012,7 +2012,7 @@ uno::Any Content::open( // cache headers. if ( !m_xCachedProps.get()) m_xCachedProps.reset( - new ContentProperties( aResource ) ); + new CachableContentProperties( aResource ) ); else m_xCachedProps->addProperties( aResource ); @@ -2058,7 +2058,7 @@ uno::Any Content::open( // cache headers. if ( !m_xCachedProps.get()) m_xCachedProps.reset( - new ContentProperties( aResource ) ); + new CachableContentProperties( aResource ) ); else m_xCachedProps->addProperties( aResource.properties ); @@ -3229,7 +3229,7 @@ const Content::ResourceType & Content::getResourceType( if ( resources.size() == 1 ) { m_xCachedProps.reset( - new ContentProperties( resources[ 0 ] ) ); + new CachableContentProperties( resources[ 0 ] ) ); m_xCachedProps->containsAllNames( aProperties, m_aFailedPropNames ); } diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx index 0568b2bfbb54..dcc544a9b2b5 100644 --- a/ucb/source/ucp/webdav/webdavcontent.hxx +++ b/ucb/source/ucp/webdav/webdavcontent.hxx @@ -68,6 +68,7 @@ namespace webdav_ucp class ContentProvider; class ContentProperties; +class CachableContentProperties; class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator @@ -81,7 +82,8 @@ class Content : public ::ucbhelper::ContentImplHelper, }; std::auto_ptr< DAVResourceAccess > m_xResAccess; - std::auto_ptr< ContentProperties > m_xCachedProps; // locally cached props + std::auto_ptr< CachableContentProperties > + m_xCachedProps; // locally cached props rtl::OUString m_aEscapedTitle; ResourceType m_eResourceType; ContentProvider* m_pProvider; // No need for a ref, base class holds object diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx index 6402653d3bda..b0630a5514b2 100755 --- a/uui/source/iahndl.hxx +++ b/uui/source/iahndl.hxx @@ -42,7 +42,7 @@ #include "tools/solar.h" // USHORT #include "tools/errcode.hxx" // ErrCode #include "tools/rc.hxx" // Resource -#include "vcl/wintypes.hxx" // WinBits +#include "tools/wintypes.hxx" // WinBits namespace com { namespace sun { namespace star { namespace awt { diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index cf6d655ff353..bddd756f6836 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -311,8 +311,8 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u if ( !xModel.is() ) xModel = getCurrentDocument(); - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName ); - if( aMacroInfo.IsResolved() ) + MacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName ); + if( aMacroInfo.mbFound ) { // handle the arguments const uno::Any* aArgsPtrArray[] = { &varg1, &varg2, &varg3, &varg4, &varg5, &varg6, &varg7, &varg8, &varg9, &varg10, &varg11, &varg12, &varg13, &varg14, &varg15, &varg16, &varg17, &varg18, &varg19, &varg20, &varg21, &varg22, &varg23, &varg24, &varg25, &varg26, &varg27, &varg28, &varg29, &varg30 }; @@ -338,7 +338,7 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u uno::Any aRet; uno::Any aDummyCaller; - executeMacro( aMacroInfo.MacroDocContext(), aMacroInfo.ResolvedMacro(), aArgs, aRet, aDummyCaller ); + executeMacro( aMacroInfo.mpDocContext, aMacroInfo.msResolvedMacro, aArgs, aRet, aDummyCaller ); } else { diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index 56b89c27bb5b..157d54eca7d5 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -78,10 +78,10 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u { // get the current model uno::Reference< frame::XModel > xModel( pCBarHelper->getModel() ); - VBAMacroResolvedInfo aResolvedMacro = ooo::vba::resolveVBAMacro( getSfxObjShell( xModel ), _onaction, true ); - if ( aResolvedMacro.IsResolved() ) + MacroResolvedInfo aResolvedMacro = ooo::vba::resolveVBAMacro( getSfxObjShell( xModel ), _onaction, true ); + if ( aResolvedMacro.mbFound ) { - rtl::OUString aCommandURL = ooo::vba::makeMacroURL( aResolvedMacro.ResolvedMacro() ); + rtl::OUString aCommandURL = ooo::vba::makeMacroURL( aResolvedMacro.msResolvedMacro ); OSL_TRACE(" ScVbaCommandBarControl::setOnAction: %s", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr() ); setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURL ) ); ApplyChange(); diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index b88086cd6d1d..8000a7cdf66e 100755 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -196,8 +196,8 @@ const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandle append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); break; } - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false ); - return aMacroInfo.IsResolved() ? ::rtl::OUString( aMacroInfo.ResolvedMacro() ) : ::rtl::OUString(); + MacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false ); + return aMacroInfo.mbFound ? ::rtl::OUString( aMacroInfo.msResolvedMacro ) : ::rtl::OUString(); } void VbaEventsHelperBase::stopListening() diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index f1113c1e114f..d798f6c42f81 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -42,6 +42,7 @@ #include <string.h> // Extensible help +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -1587,10 +1588,9 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextUserHelpPack if( !m_bUserPackagesLoaded ) { - Reference< XPackageManager > xUserManager = - thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("user") ); - m_aUserPackagesSeq = xUserManager->getDeployedPackages - ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + Reference< XExtensionManager > xExtensionManager = ExtensionManager::get(m_xContext); + m_aUserPackagesSeq = xExtensionManager->getDeployedExtensions + ( rtl::OUString::createFromAscii("user"), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); m_bUserPackagesLoaded = true; } @@ -1616,10 +1616,9 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa if( !m_bSharedPackagesLoaded ) { - Reference< XPackageManager > xSharedManager = - thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("shared") ); - m_aSharedPackagesSeq = xSharedManager->getDeployedPackages - ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + Reference< XExtensionManager > xExtensionManager = ExtensionManager::get(m_xContext); + m_aSharedPackagesSeq = xExtensionManager->getDeployedExtensions + ( rtl::OUString::createFromAscii("shared"), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); m_bSharedPackagesLoaded = true; } @@ -1645,10 +1644,9 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextBundledHelpP if( !m_bBundledPackagesLoaded ) { - Reference< XPackageManager > xBundledManager = - thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("bundled") ); - m_aBundledPackagesSeq = xBundledManager->getDeployedPackages - ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + Reference< XExtensionManager > xExtensionManager = ExtensionManager::get(m_xContext); + m_aBundledPackagesSeq = xExtensionManager->getDeployedExtensions + ( rtl::OUString::createFromAscii("bundled"), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); m_bBundledPackagesLoaded = true; } diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index 2e335b4175c4..b8cd18a64684 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -67,6 +67,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\ xmloff/source/chart/ColorPropertySet \ xmloff/source/chart/PropertyMaps \ xmloff/source/chart/SchXMLAutoStylePoolP \ + xmloff/source/chart/SchXMLAxisContext \ xmloff/source/chart/SchXMLCalculationSettingsContext \ xmloff/source/chart/SchXMLChartContext \ xmloff/source/chart/SchXMLExport \ @@ -390,6 +391,20 @@ $(eval $(call gb_Library_add_linked_libs,xo,\ endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,xo,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,xo,\ kernel32 \ msvcrt \ @@ -398,4 +413,5 @@ $(eval $(call gb_Library_add_linked_libs,xo,\ uwinapi \ )) endif +endif # vim: set noet ts=4 sw=4: diff --git a/xmloff/Library_xof.mk b/xmloff/Library_xof.mk index 6880eb1a1fd9..e809935d12ba 100644 --- a/xmloff/Library_xof.mk +++ b/xmloff/Library_xof.mk @@ -101,6 +101,20 @@ $(eval $(call gb_Library_add_linked_libs,xof,\ endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,xof,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,xof,\ kernel32 \ msvcrt \ @@ -109,4 +123,5 @@ $(eval $(call gb_Library_add_linked_libs,xof,\ uwinapi \ )) endif +endif # vim: set noet ts=4 sw=4: diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 7168b2b811a8..936217fb8dc5 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -90,13 +90,6 @@ enum SchXMLSeriesElemTokenMap XML_TOK_SERIES_ERROR_INDICATOR }; -enum SchXMLAxisElemTokenMap -{ - XML_TOK_AXIS_TITLE, - XML_TOK_AXIS_CATEGORIES, - XML_TOK_AXIS_GRID -}; - // ---------------------------------------- enum SchXMLChartAttrMap @@ -134,13 +127,6 @@ enum SchXMLPlotAreaAttrTokenMap XML_TOK_PA_LIGHTING_MODE }; -enum SchXMLAxisAttrTokenMap -{ - XML_TOK_AXIS_DIMENSION, - XML_TOK_AXIS_NAME, - XML_TOK_AXIS_STYLE_NAME -}; - enum SchXMLLegendAttrMap { XML_TOK_LEGEND_POSITION, diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx index 03fa8c8e16c0..d15b19ee5d38 100644 --- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx +++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx @@ -80,11 +80,9 @@ private: SvXMLTokenMap* mpChartElemTokenMap; SvXMLTokenMap* mpPlotAreaElemTokenMap; SvXMLTokenMap* mpSeriesElemTokenMap; - SvXMLTokenMap* mpAxisElemTokenMap; SvXMLTokenMap* mpChartAttrTokenMap; SvXMLTokenMap* mpPlotAreaAttrTokenMap; - SvXMLTokenMap* mpAxisAttrTokenMap; SvXMLTokenMap* mpLegendAttrTokenMap; SvXMLTokenMap* mpAutoStyleAttrTokenMap; SvXMLTokenMap* mpCellAttrTokenMap; @@ -123,11 +121,9 @@ public: const SvXMLTokenMap& GetChartElemTokenMap(); const SvXMLTokenMap& GetPlotAreaElemTokenMap(); const SvXMLTokenMap& GetSeriesElemTokenMap(); - const SvXMLTokenMap& GetAxisElemTokenMap(); const SvXMLTokenMap& GetChartAttrTokenMap(); const SvXMLTokenMap& GetPlotAreaAttrTokenMap(); - const SvXMLTokenMap& GetAxisAttrTokenMap(); const SvXMLTokenMap& GetLegendAttrTokenMap(); const SvXMLTokenMap& GetAutoStyleAttrTokenMap(); const SvXMLTokenMap& GetCellAttrTokenMap(); diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 291c99c7be21..ecadbbdc196f 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3113,6 +3113,14 @@ namespace xmloff { namespace token { XML_OUTSIDE_MINIMUM,//#i114142# XML_OUTSIDE_MAXIMUM,//#i114142# + XML_AXIS_TYPE, //#i25706# + XML_DATE_SCALE, + XML_BASE_TIME_UNIT, + XML_MAJOR_INTERVAL_VALUE, + XML_MINOR_INTERVAL_VALUE, + XML_MAJOR_INTERVAL_UNIT, + XML_MINOR_INTERVAL_UNIT, + XML_MIN_VALUE, XML_MAX_VALUE, diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx new file mode 100755 index 000000000000..d08e4937ff22 --- /dev/null +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -0,0 +1,1053 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_xmloff.hxx" + +#include "SchXMLAxisContext.hxx" +#include "SchXMLChartContext.hxx" +#include "SchXMLTools.hxx" +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmlement.hxx> +#include <xmloff/xmlstyle.hxx> +#include <xmloff/prstylei.hxx> +#include <xmloff/nmspmap.hxx> +#include <xmloff/xmluconv.hxx> + +#include <tools/debug.hxx> + +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <com/sun/star/chart/TimeIncrement.hpp> +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> +#include <com/sun/star/chart/XAxis.hpp> +#include <com/sun/star/chart/XAxisSupplier.hpp> +#include <com/sun/star/chart2/AxisType.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> + +#include <com/sun/star/drawing/LineStyle.hpp> + +using namespace ::xmloff::token; +using namespace com::sun::star; + +using rtl::OUString; +using com::sun::star::uno::Reference; + +//---------------------------------------- +//---------------------------------------- + +static SvXMLEnumMapEntry aXMLAxisDimensionMap[] = +{ + { XML_X, SCH_XML_AXIS_X }, + { XML_Y, SCH_XML_AXIS_Y }, + { XML_Z, SCH_XML_AXIS_Z }, + { XML_TOKEN_INVALID, 0 } +}; + +static SvXMLEnumMapEntry aXMLAxisTypeMap[] = +{ + { XML_AUTO, ::com::sun::star::chart::ChartAxisType::AUTOMATIC }, + { XML_TEXT, ::com::sun::star::chart::ChartAxisType::CATEGORY }, + { XML_DATE, ::com::sun::star::chart::ChartAxisType::DATE }, + { XML_TOKEN_INVALID, 0 } +}; + +//---------------------------------------- +//---------------------------------------- + +class SchXMLCategoriesContext : public SvXMLImportContext +{ +private: + SchXMLImportHelper& m_rImportHelper; + OUString& mrAddress; + +public: + SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + OUString& rAddress ); + virtual ~SchXMLCategoriesContext(); + virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); +}; + +//---------------------------------------- +//---------------------------------------- + + +class DateScaleContext : public SvXMLImportContext +{ +public: + DateScaleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, + sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< beans::XPropertySet > xAxisProps ); + + virtual ~DateScaleContext(); + virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + +private: + SchXMLImportHelper& m_rImportHelper; + Reference< beans::XPropertySet > m_xAxisProps; +}; + + +//---------------------------------------- +//---------------------------------------- + +SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, const OUString& rLocalName, + Reference< chart::XDiagram > xDiagram, + std::vector< SchXMLAxis >& rAxes, + OUString & rCategoriesAddress, + bool bAddMissingXAxisForNetCharts, + bool bAdaptWrongPercentScaleValues, + bool bAdaptXAxisOrientationForOld2DBarCharts, + bool& rbAxisPositionAttributeImported ) : + SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), + m_rImportHelper( rImpHelper ), + m_xDiagram( xDiagram ), + m_rAxes( rAxes ), + m_rCategoriesAddress( rCategoriesAddress ), + m_nAxisType(chart::ChartAxisType::AUTOMATIC), + m_bAxisTypeImported(false), + m_bDateScaleImported(false), + m_bAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ), + m_bAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ), + m_bAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ), + m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported ) +{ +} + +SchXMLAxisContext::~SchXMLAxisContext() +{} + +Reference< chart::XAxis > lcl_getChartAxis( SchXMLAxis aCurrentAxis, const Reference< chart::XDiagram > xDiagram ) +{ + Reference< chart::XAxis > xAxis; + Reference< chart::XAxisSupplier > xAxisSuppl( xDiagram, uno::UNO_QUERY ); + if( !xAxisSuppl.is() ) + return xAxis; + if( aCurrentAxis.nAxisIndex == 0 ) + xAxis = xAxisSuppl->getAxis(aCurrentAxis.eDimension); + else + xAxis = xAxisSuppl->getSecondaryAxis(aCurrentAxis.eDimension); + return xAxis; +} + +/* returns a shape for the current axis's title. The property + "Has...AxisTitle" is set to "True" to get the shape + */ +Reference< drawing::XShape > SchXMLAxisContext::getTitleShape() +{ + Reference< drawing::XShape > xResult; + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xDiaProp.is() || !xAxis.is() ) + return xResult; + + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii( "HasXAxisTitle" ); + else + aPropName = OUString::createFromAscii( "HasSecondaryXAxisTitle" ); + break; + case SCH_XML_AXIS_Y: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii( "HasYAxisTitle" ); + else + aPropName = OUString::createFromAscii( "HasSecondaryYAxisTitle" ); + break; + case SCH_XML_AXIS_Z: + aPropName = OUString::createFromAscii( "HasZAxisTitle" ); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + xResult = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xResult; +} + +void SchXMLAxisContext::CreateGrid( OUString sAutoStyleName, bool bIsMajor ) +{ + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xDiaProp.is() || !xAxis.is() ) + return; + + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasXAxisGrid"); + else + aPropName = OUString::createFromAscii("HasXAxisHelpGrid"); + break; + case SCH_XML_AXIS_Y: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasYAxisGrid"); + else + aPropName = OUString::createFromAscii("HasYAxisHelpGrid"); + break; + case SCH_XML_AXIS_Z: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasZAxisGrid"); + else + aPropName = OUString::createFromAscii("HasZAxisHelpGrid"); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + + Reference< beans::XPropertySet > xGridProp; + if( bIsMajor ) + xGridProp = xAxis->getMajorGrid(); + else + xGridProp = xAxis->getMinorGrid(); + + // set properties + if( xGridProp.is()) + { + // the line color is black as default, in the model it is a light gray + xGridProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), + uno::makeAny( COL_BLACK )); + if( sAutoStyleName.getLength()) + { + const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) + { + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + m_rImportHelper.GetChartFamilyID(), sAutoStyleName ); + + if( pStyle && pStyle->ISA( XMLPropStyleContext )) + (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp ); + } + } + } +} + +namespace +{ +enum AxisAttributeTokens +{ + XML_TOK_AXIS_DIMENSION, + XML_TOK_AXIS_NAME, + XML_TOK_AXIS_STYLE_NAME, + XML_TOK_AXIS_TYPE, + XML_TOK_AXIS_TYPE_EXT +}; + +SvXMLTokenMapEntry aAxisAttributeTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION }, + { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME }, + { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME }, + { XML_NAMESPACE_CHART, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE }, + { XML_NAMESPACE_CHART_EXT, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE_EXT }, + XML_TOKEN_MAP_END +}; + +class AxisAttributeTokenMap : public SvXMLTokenMap +{ +public: + AxisAttributeTokenMap(): SvXMLTokenMap( aAxisAttributeTokenMap ) {} + virtual ~AxisAttributeTokenMap() {} +}; + +//a AxisAttributeTokenMap Singleton +struct theAxisAttributeTokenMap : public rtl::Static< AxisAttributeTokenMap, theAxisAttributeTokenMap > {}; +} + +void SchXMLAxisContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + // parse attributes + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + SchXMLImport& rImport = ( SchXMLImport& )GetImport(); + const SvXMLTokenMap& rAttrTokenMap = theAxisAttributeTokenMap::get(); + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + OUString aValue = xAttrList->getValueByIndex( i ); + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName )) + { + case XML_TOK_AXIS_DIMENSION: + { + USHORT nEnumVal; + if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisDimensionMap )) + m_aCurrentAxis.eDimension = ( SchXMLAxisDimension )nEnumVal; + } + break; + case XML_TOK_AXIS_NAME: + m_aCurrentAxis.aName = aValue; + break; + case XML_TOK_AXIS_TYPE: + case XML_TOK_AXIS_TYPE_EXT: + USHORT nEnumVal; + if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisTypeMap )) + { + m_nAxisType = nEnumVal; + m_bAxisTypeImported = true; + } + break; + case XML_TOK_AXIS_STYLE_NAME: + m_aAutoStyleName = aValue; + break; + } + } + + // check for number of axes with same dimension + m_aCurrentAxis.nAxisIndex = 0; + sal_Int32 nNumOfAxes = m_rAxes.size(); + for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) + { + if( m_rAxes[ nCurrent ].eDimension == m_aCurrentAxis.eDimension ) + m_aCurrentAxis.nAxisIndex++; + } + CreateAxis(); +} +namespace +{ + +Reference< chart2::XAxis > lcl_getAxis( const Reference< frame::XModel >& xChartModel, + sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) +{ + Reference< chart2::XAxis > xAxis; + + try + { + Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY ); + if( xChart2Document.is() ) + { + Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram()); + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + uno::Sequence< Reference< chart2::XCoordinateSystem > > + aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + sal_Int32 nCooSysIndex = 0; + if( nCooSysIndex < aCooSysSeq.getLength() ) + { + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] ); + if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() ) + { + const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); + if( nAxisIndex <= nMaxAxisIndex ) + xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); + } + } + } + } + catch( uno::Exception & ) + { + DBG_ERROR( "Couldn't get axis" ); + } + + return xAxis; +} + +bool lcl_divideBy100( uno::Any& rDoubleAny ) +{ + bool bChanged = false; + double fValue=0.0; + if( (rDoubleAny>>=fValue) && (fValue!=0.0) ) + { + fValue/=100.0; + rDoubleAny = uno::makeAny(fValue); + bChanged = true; + } + return bChanged; +} + +bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData) +{ + bool bChanged = lcl_divideBy100( rScaleData.Minimum ); + bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged; + bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged; + bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged; + return bChanged; +} + +}//end anonymous namespace + +void SchXMLAxisContext::CreateAxis() +{ + m_rAxes.push_back( m_aCurrentAxis ); + + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + if( !xDiaProp.is() ) + return; + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasXAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryXAxis"); + break; + case SCH_XML_AXIS_Y: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasYAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryYAxis"); + break; + case SCH_XML_AXIS_Z: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasXAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryXAxis"); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + try + { + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on axis" ); + } + if( m_aCurrentAxis.eDimension==SCH_XML_AXIS_Z ) + { + bool bSettingZAxisSuccedded = false; + try + { + xDiaProp->getPropertyValue( aPropName ) >>= bSettingZAxisSuccedded; + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on z axis" ); + } + if( !bSettingZAxisSuccedded ) + return; + } + + + m_xAxisProps = Reference<beans::XPropertySet>( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ), uno::UNO_QUERY ); + + if( m_bAddMissingXAxisForNetCharts && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y && m_aCurrentAxis.nAxisIndex==0 ) + { + try + { + xDiaProp->setPropertyValue( OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on x axis" ); + } + } + + // set properties + if( m_xAxisProps.is()) + { + uno::Any aTrueBool( uno::makeAny( sal_True )); + uno::Any aFalseBool( uno::makeAny( sal_False )); + + // #i109879# the line color is black as default, in the model it is a light gray + m_xAxisProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), + uno::makeAny( COL_BLACK )); + + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); + + // #88077# AutoOrigin 'on' is default + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AutoOrigin" ), aTrueBool ); + + if( m_bAxisTypeImported ) + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AxisType" ), uno::makeAny(m_nAxisType) ); + + if( m_aAutoStyleName.getLength()) + { + const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) + { + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + m_rImportHelper.GetChartFamilyID(), m_aAutoStyleName ); + + if( pStyle && pStyle->ISA( XMLPropStyleContext )) + { + // note: SvXMLStyleContext::FillPropertySet is not const + XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); + if( pPropStyleContext ) + pPropStyleContext->FillPropertySet( m_xAxisProps ); + + if( m_bAdaptWrongPercentScaleValues && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y ) + { + //set scale data of added x axis back to default + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), + m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData( xAxis->getScaleData()); + if( lcl_AdaptWrongPercentScaleValues(aScaleData) ) + xAxis->setScaleData( aScaleData ); + } + } + + if( m_bAddMissingXAxisForNetCharts ) + { + //copy style from y axis to added x axis: + + Reference< chart::XAxisSupplier > xAxisSuppl( xDiaProp, uno::UNO_QUERY ); + if( xAxisSuppl.is() ) + { + Reference< beans::XPropertySet > xXAxisProp( xAxisSuppl->getAxis(0), uno::UNO_QUERY ); + (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp ); + } + + //set scale data of added x axis back to default + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), + 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData; + aScaleData.AxisType = chart2::AxisType::CATEGORY; + aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL; + xAxis->setScaleData( aScaleData ); + } + + //set line style of added x axis to invisible + Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY ); + if( xNewAxisProp.is() ) + { + xNewAxisProp->setPropertyValue( OUString::createFromAscii("LineStyle") + , uno::makeAny(drawing::LineStyle_NONE)); + } + } + + if( m_bAdaptXAxisOrientationForOld2DBarCharts && m_aCurrentAxis.eDimension == SCH_XML_AXIS_X ) + { + bool bIs3DChart = false; + if( xDiaProp.is() && ( xDiaProp->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart ) + && !bIs3DChart ) + { + Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY ); + if( xChart2Document.is() ) + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY ); + if( xCooSysCnt.is() ) + { + uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); + if( aCooSysSeq.getLength() ) + { + bool bSwapXandYAxis = false; + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); + Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); + if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis ) + && bSwapXandYAxis ) + { + Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, m_aCurrentAxis.nAxisIndex ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData = xAxis->getScaleData(); + aScaleData.Orientation = chart2::AxisOrientation_REVERSE; + xAxis->setScaleData( aScaleData ); + } + } + } + } + } + } + } + + m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext( + OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue(); + } + } + } + } +} + +void SchXMLAxisContext::SetAxisTitle() +{ + if( !m_aCurrentAxis.aTitle.getLength() ) + return; + + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xAxis.is() ) + return; + + Reference< beans::XPropertySet > xTitleProp( xAxis->getAxisTitle() ); + if( xTitleProp.is() ) + { + try + { + xTitleProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), uno::makeAny(m_aCurrentAxis.aTitle) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Property String for Title not available" ); + } + } +} + +//----------------------------------------------------------------------- +namespace +{ +enum AxisChildTokens +{ + XML_TOK_AXIS_TITLE, + XML_TOK_AXIS_CATEGORIES, + XML_TOK_AXIS_GRID, + XML_TOK_AXIS_DATE_SCALE, + XML_TOK_AXIS_DATE_SCALE_EXT +}; + +SvXMLTokenMapEntry aAxisChildTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE }, + { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES }, + { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID }, + { XML_NAMESPACE_CHART, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE }, + { XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE_EXT }, + XML_TOKEN_MAP_END +}; + +class AxisChildTokenMap : public SvXMLTokenMap +{ +public: + AxisChildTokenMap(): SvXMLTokenMap( aAxisChildTokenMap ) {} + virtual ~AxisChildTokenMap() {} +}; + +//a AxisChildTokenMap Singleton +struct theAxisChildTokenMap : public rtl::Static< AxisChildTokenMap, theAxisChildTokenMap > {}; +} + +SvXMLImportContext* SchXMLAxisContext::CreateChildContext( + USHORT p_nPrefix, + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + SvXMLImportContext* pContext = 0; + const SvXMLTokenMap& rTokenMap = theAxisChildTokenMap::get(); + + switch( rTokenMap.Get( p_nPrefix, rLocalName )) + { + case XML_TOK_AXIS_TITLE: + { + Reference< drawing::XShape > xTitleShape = getTitleShape(); + pContext = new SchXMLTitleContext( m_rImportHelper, GetImport(), rLocalName, + m_aCurrentAxis.aTitle, + xTitleShape ); + } + break; + + case XML_TOK_AXIS_CATEGORIES: + pContext = new SchXMLCategoriesContext( m_rImportHelper, GetImport(), + p_nPrefix, rLocalName, + m_rCategoriesAddress ); + m_aCurrentAxis.bHasCategories = true; + break; + + case XML_TOK_AXIS_DATE_SCALE: + case XML_TOK_AXIS_DATE_SCALE_EXT: + pContext = new DateScaleContext( m_rImportHelper, GetImport(), + p_nPrefix, rLocalName, m_xAxisProps ); + m_bDateScaleImported = true; + break; + + case XML_TOK_AXIS_GRID: + { + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + bool bIsMajor = true; // default value for class is "major" + OUString sAutoStyleName; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if( nPrefix == XML_NAMESPACE_CHART ) + { + if( IsXMLToken( aLocalName, XML_CLASS ) ) + { + if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) ) + bIsMajor = false; + } + else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + sAutoStyleName = xAttrList->getValueByIndex( i ); + } + } + + CreateGrid( sAutoStyleName, bIsMajor ); + + // don't create a context => use default context. grid elements are empty + pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + } + break; + + default: + pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + break; + } + + return pContext; +} + +void SchXMLAxisContext::EndElement() +{ + if( !m_bDateScaleImported && m_nAxisType==chart::ChartAxisType::AUTOMATIC ) + { + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData( xAxis->getScaleData()); + aScaleData.AutoDateAxis = false;//different default for older documents + xAxis->setScaleData( aScaleData ); + } + } + + SetAxisTitle(); +} + +// ======================================== + +namespace +{ + +Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) +{ + Reference< chart2::XAxis > xAxis; + try + { + xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); + } + catch( uno::Exception & ) + { + } + return xAxis; +} + +} // anonymous namespace + +void SchXMLAxisContext::CorrectAxisPositions( const Reference< chart2::XChartDocument >& xNewDoc, + const OUString& rChartTypeServiceName, + const OUString& rODFVersionOfFile, + bool bAxisPositionAttributeImported ) +{ + if( ( !rODFVersionOfFile.getLength() || rODFVersionOfFile.equalsAscii("1.0") + || rODFVersionOfFile.equalsAscii("1.1") + || ( rODFVersionOfFile.equalsAscii("1.2") && !bAxisPositionAttributeImported ) ) ) + { + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); + uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + if( aCooSysSeq.getLength() ) + { + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); + if( xCooSys.is() ) + { + Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 ); + Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 ); + //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 ); + Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 ); + Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 ); + + Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY ); + + if( xMainXAxisProp.is() && xMainYAxisProp.is() ) + { + chart2::ScaleData aMainXScale = xMainXAxis->getScaleData(); + if( 0 == rChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); + double fCrossoverValue = 0.0; + aMainXScale.Origin >>= fCrossoverValue; + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") + , uno::makeAny( fCrossoverValue ) ); + + if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + else + { + if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + + chart2::ScaleData aMainYScale = xMainYAxis->getScaleData(); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); + double fCrossoverValue = 0.0; + aMainYScale.Origin >>= fCrossoverValue; + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") + , uno::makeAny( fCrossoverValue ) ); + + if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryXAxisProp.is() ) + xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryXAxisProp.is() ) + xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + } + } + } + catch( uno::Exception & ) + { + } + } +} + +// ======================================== + +SchXMLCategoriesContext::SchXMLCategoriesContext( + SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + OUString& rAddress ) : + SvXMLImportContext( rImport, nPrefix, rLocalName ), + m_rImportHelper( rImpHelper ), + mrAddress( rAddress ) +{ +} + +SchXMLCategoriesContext::~SchXMLCategoriesContext() +{ +} + +void SchXMLCategoriesContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if( nPrefix == XML_NAMESPACE_TABLE && + IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) ) + { + Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY ); + mrAddress = xAttrList->getValueByIndex( i ); + } + } +} + +// ======================================== + +DateScaleContext::DateScaleContext( + SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< beans::XPropertySet > xAxisProps ) : + SvXMLImportContext( rImport, nPrefix, rLocalName ), + m_rImportHelper( rImpHelper ), + m_xAxisProps( xAxisProps ) +{ +} + +DateScaleContext::~DateScaleContext() +{ +} + +namespace +{ +enum DateScaleAttributeTokens +{ + XML_TOK_DATESCALE_BASE_TIME_UNIT, + XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE, + XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT, + XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE, + XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT +}; + +SvXMLTokenMapEntry aDateScaleAttributeTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, XML_TOK_DATESCALE_BASE_TIME_UNIT }, + { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE }, + { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT }, + { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE }, + { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT }, + XML_TOKEN_MAP_END +}; + +class DateScaleAttributeTokenMap : public SvXMLTokenMap +{ +public: + DateScaleAttributeTokenMap(): SvXMLTokenMap( aDateScaleAttributeTokenMap ) {} + virtual ~DateScaleAttributeTokenMap() {} +}; + +struct theDateScaleAttributeTokenMap : public rtl::Static< DateScaleAttributeTokenMap, theDateScaleAttributeTokenMap > {}; + +sal_Int32 lcl_getTimeUnit( const OUString& rValue ) +{ + sal_Int32 nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; + if( IsXMLToken( rValue, XML_DAYS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; + else if( IsXMLToken( rValue, XML_MONTHS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::MONTH; + else if( IsXMLToken( rValue, XML_YEARS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::YEAR; + return nTimeUnit; +} + +} + +void DateScaleContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + if( !m_xAxisProps.is() ) + return; + + // parse attributes + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + const SvXMLTokenMap& rAttrTokenMap = theDateScaleAttributeTokenMap::get(); + + bool bSetNewIncrement=false; + chart::TimeIncrement aIncrement; + m_xAxisProps->getPropertyValue( OUString::createFromAscii( "TimeIncrement" )) >>= aIncrement; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + OUString aValue = xAttrList->getValueByIndex( i ); + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName )) + { + case XML_TOK_DATESCALE_BASE_TIME_UNIT: + { + aIncrement.TimeResolution = uno::makeAny( lcl_getTimeUnit(aValue) ); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MajorTimeInterval >>= aInterval; + SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); + aIncrement.MajorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MajorTimeInterval >>= aInterval; + aInterval.TimeUnit = lcl_getTimeUnit(aValue); + aIncrement.MajorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MinorTimeInterval >>= aInterval; + SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); + aIncrement.MinorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MinorTimeInterval >>= aInterval; + aInterval.TimeUnit = lcl_getTimeUnit(aValue); + aIncrement.MinorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + } + } + + if( bSetNewIncrement ) + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "TimeIncrement" ), uno::makeAny( aIncrement ) ); +} + +// ======================================== diff --git a/xmloff/source/chart/SchXMLAxisContext.hxx b/xmloff/source/chart/SchXMLAxisContext.hxx new file mode 100755 index 000000000000..78ce22415630 --- /dev/null +++ b/xmloff/source/chart/SchXMLAxisContext.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SCH_XMLAXISCONTEXT_HXX_ +#define _SCH_XMLAXISCONTEXT_HXX_ + +#include "SchXMLImport.hxx" +#include "transporttypes.hxx" + +// ---------------------------------------- + +class SchXMLAxisContext : public SvXMLImportContext +{ +public: + SchXMLAxisContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, const rtl::OUString& rLocalName, + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > xDiagram, + std::vector< SchXMLAxis >& aAxes, + ::rtl::OUString& rCategoriesAddress, + bool bAddMissingXAxisForNetCharts, + bool bAdaptWrongPercentScaleValues, + bool bAdaptXAxisOrientationForOld2DBarCharts, + bool& rbAxisPositionAttributeImported ); + virtual ~SchXMLAxisContext(); + + virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + virtual void EndElement(); + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + static void CorrectAxisPositions( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xNewDoc, + const ::rtl::OUString& rChartTypeServiceName, + const ::rtl::OUString& rODFVersionOfFile, + bool bAxisPositionAttributeImported ); + +private: + SchXMLImportHelper& m_rImportHelper; + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > m_xDiagram; + SchXMLAxis m_aCurrentAxis; + std::vector< SchXMLAxis >& m_rAxes; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAxisProps; + rtl::OUString m_aAutoStyleName; + rtl::OUString& m_rCategoriesAddress; + sal_Int32 m_nAxisType;//::com::sun::star::chart::ChartAxisType + bool m_bAxisTypeImported; + bool m_bDateScaleImported; + bool m_bAddMissingXAxisForNetCharts; //to correct errors from older versions + bool m_bAdaptWrongPercentScaleValues; //to correct errors from older versions + bool m_bAdaptXAxisOrientationForOld2DBarCharts; //to correct different behaviour from older versions + bool& m_rbAxisPositionAttributeImported; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTitleShape(); + void CreateGrid( ::rtl::OUString sAutoStyleName, bool bIsMajor ); + void CreateAxis(); + void SetAxisTitle(); +}; + +#endif // _SCH_XMLAXISCONTEXT_HXX_ diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 9df601407199..2a19d2949ff9 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -63,7 +63,6 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XChartTypeTemplate.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -78,48 +77,6 @@ using namespace ::SchXMLTools; namespace { -uno::Reference< chart2::XChartTypeTemplate > lcl_getTemplate( const uno::Reference< chart2::XChartDocument > & xDoc ) -{ - uno::Reference< chart2::XChartTypeTemplate > xResult; - try - { - if( !xDoc.is()) - return xResult; - uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( xDoc->getChartTypeManager(), uno::UNO_QUERY ); - if( !xChartTypeManager.is()) - return xResult; - uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram()); - if( !xDiagram.is()) - return xResult; - - uno::Sequence< ::rtl::OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames()); - const sal_Int32 nLength = aServiceNames.getLength(); - - for( sal_Int32 i = 0; i < nLength; ++i ) - { - try - { - uno::Reference< chart2::XChartTypeTemplate > xTempl( - xChartTypeManager->createInstance( aServiceNames[ i ] ), uno::UNO_QUERY_THROW ); - - if( xTempl->matchesTemplate( xDiagram, sal_True )) - { - xResult.set( xTempl ); - break; - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Exception during determination of chart type template" ); - } - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Exception during import lcl_getTemplate" ); - } - return xResult; -} void lcl_setRoleAtLabeledSequence( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq, @@ -685,10 +642,6 @@ void lcl_ApplyDataFromRectangularRangeToDiagram( if( !xNewDia.is() || !xDataProvider.is() ) return; - uno::Reference< chart2::XChartTypeTemplate > xTemplate( lcl_getTemplate( xNewDoc )); - if(!xTemplate.is()) - return; - sal_Bool bFirstCellAsLabel = (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels; sal_Bool bHasCateories = @@ -754,13 +707,17 @@ void lcl_ApplyDataFromRectangularRangeToDiagram( uno::Reference< chart2::data::XDataSource > xDataSource( xDataProvider->createDataSource( aArgs )); - aArgs.realloc( aArgs.getLength() + 1 ); - aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue( + aArgs.realloc( aArgs.getLength() + 2 ); + aArgs[ aArgs.getLength() - 2 ] = beans::PropertyValue( ::rtl::OUString::createFromAscii("HasCategories"), -1, uno::makeAny( bHasCateories ), beans::PropertyState_DIRECT_VALUE ); + aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("UseCategoriesAsX"), + -1, uno::makeAny( sal_False ),//categories in ODF files are not to be used as x values (independent from what is offered in our ui) + beans::PropertyState_DIRECT_VALUE ); - xTemplate->changeDiagramData( xNewDia, xDataSource, aArgs ); + xNewDia->setDiagramData( xDataSource, aArgs ); } void SchXMLChartContext::EndElement() @@ -810,8 +767,7 @@ void SchXMLChartContext::EndElement() // cleanup: remove empty chart type groups lcl_removeEmptyChartTypeGroups( xNewDoc ); - // set stack mode before a potential template detection (in case we have a - // rectangular range) + // set stack mode before a potential chart type detection (in case we have a rectangular range) uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() ); uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); if( xDiaProp.is()) @@ -890,8 +846,7 @@ void SchXMLChartContext::EndElement() { //apply data from rectangular range - // create datasource from data provider with rectangular range - // parameters and change the diagram via template mechanism + // create datasource from data provider with rectangular range parameters and change the diagram setDiagramData try { if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 358cb023199c..cc13eb2de733 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -64,20 +64,24 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/chart/XAxis.hpp> +#include <com/sun/star/chart/XAxisSupplier.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart/ChartLegendPosition.hpp> -#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> -#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> -#include <com/sun/star/chart/XAxisZSupplier.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/ChartAxisAssign.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <com/sun/star/chart/TimeIncrement.hpp> +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/chart/X3DDisplay.hpp> #include <com/sun/star/chart/XStatisticDisplay.hpp> #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XDiagram.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> @@ -201,6 +205,13 @@ public: void exportAxes( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > & xDiagram, const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram, sal_Bool bExportContent ); + void exportAxis( enum XMLTokenEnum eDimension, enum XMLTokenEnum eAxisName, + const Reference< beans::XPropertySet > xAxisProps, const Reference< chart2::XAxis >& xChart2Axis, + const OUString& rCategoriesRanges, + bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, bool bExportContent ); + void exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent ); + void exportDateScale( const Reference< beans::XPropertySet > xAxisProps ); + void exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent ); void exportSeries( const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram, @@ -694,6 +705,7 @@ bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSeque } typedef vector< OUString > tStringVector; +typedef vector< double > tDoubleVector; typedef vector< vector< OUString > > t2DStringVector; typedef vector< vector< double > > t2DNumberContainer; @@ -708,8 +720,8 @@ struct lcl_TableData tStringVector aRowDescriptions; tStringVector aRowDescriptions_Ranges; - Sequence< Sequence< OUString > > aComplexColumnDescriptions;//outer index is columns - inner index is level - Sequence< Sequence< OUString > > aComplexRowDescriptions;//outer index is rows - inner index is level + Sequence< Sequence< uno::Any > > aComplexColumnDescriptions;//outer index is columns - inner index is level + Sequence< Sequence< uno::Any > > aComplexRowDescriptions;//outer index is rows - inner index is level ::std::vector< sal_Int32 > aHiddenColumns; }; @@ -776,7 +788,7 @@ void lcl_ReorderInternalSequencesAccordingToTheirRangeName( lcl_TableData lcl_getDataForLocalTable( const SchXMLExportHelper_Impl::tDataSequenceCont & aSequencesToExport, - const Reference< chart::XComplexDescriptionAccess >& xComplexDescriptionAccess, + const Reference< chart2::XAnyDescriptionAccess >& xAnyDescriptionAccess, const OUString& rCategoriesRange, bool bSeriesFromColumns, const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion ) @@ -786,15 +798,15 @@ lcl_TableData lcl_getDataForLocalTable( try { Sequence< OUString > aSimpleCategories; - if( xComplexDescriptionAccess.is() ) + if( xAnyDescriptionAccess.is() ) { if( bSeriesFromColumns ) - aSimpleCategories = xComplexDescriptionAccess->getRowDescriptions(); + aSimpleCategories = xAnyDescriptionAccess->getRowDescriptions(); else - aSimpleCategories = xComplexDescriptionAccess->getColumnDescriptions(); + aSimpleCategories = xAnyDescriptionAccess->getColumnDescriptions(); - aResult.aComplexColumnDescriptions = xComplexDescriptionAccess->getComplexColumnDescriptions(); - aResult.aComplexRowDescriptions = xComplexDescriptionAccess->getComplexRowDescriptions(); + aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions(); + aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions(); } SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size(); @@ -1580,7 +1592,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& delete pElChart; } -void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExport& rExport ) +void lcl_exportComplexLabel( const Sequence< uno::Any >& rComplexLabel, SvXMLExport& rExport ) { sal_Int32 nLength = rComplexLabel.getLength(); if( nLength<=1 ) @@ -1589,7 +1601,12 @@ void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExp for(sal_Int32 nN=0; nN<nLength; nN++) { SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, sal_True, sal_True ); - SchXMLTools::exportText( rExport, rComplexLabel[nN], false /*bConvertTabsLFs*/ ); + OUString aString; + if( !(rComplexLabel[nN]>>=aString) ) + { + //todo? + } + SchXMLTools::exportText( rExport, aString, false /*bConvertTabsLFs*/ ); } } @@ -1598,6 +1615,21 @@ void SchXMLExportHelper_Impl::exportTable() // table element // ------------- mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, msTableName ); + + try + { + bool bProtected = false; + Reference< beans::XPropertySet > xProps( mrExport.GetModel(), uno::UNO_QUERY_THROW ); + if ( ( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bProtected ) && + bProtected ) + { + mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE ); + } + } + catch ( uno::Exception& ) + { + } + SvXMLElementExport aTable( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True ); bool bHasOwnData = false; @@ -1609,17 +1641,17 @@ void SchXMLExportHelper_Impl::exportTable() xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY ); } - Reference< chart::XComplexDescriptionAccess > xComplexDescriptionAccess; + Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess; { Reference< chart::XChartDocument > xChartDoc( mrExport.GetModel(), uno::UNO_QUERY ); if( xChartDoc.is() ) - xComplexDescriptionAccess = Reference< chart::XComplexDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY ); + xAnyDescriptionAccess = Reference< chart2::XAnyDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY ); } if( bHasOwnData ) lcl_ReorderInternalSequencesAccordingToTheirRangeName( m_aDataSequencesToExport ); lcl_TableData aData( lcl_getDataForLocalTable( m_aDataSequencesToExport - , xComplexDescriptionAccess, maCategoriesRange + , xAnyDescriptionAccess, maCategoriesRange , mbRowSourceColumns, xRangeConversion )); tStringVector::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin()); @@ -1680,17 +1712,40 @@ void SchXMLExportHelper_Impl::exportTable() //export column descriptions tStringVector::const_iterator aColumnDescriptions_RangeIter( aData.aColumnDescriptions_Ranges.begin()); const tStringVector::const_iterator aColumnDescriptions_RangeEnd( aData.aColumnDescriptions_Ranges.end()); - const Sequence< Sequence< OUString > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions; + const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions; sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength(); sal_Int32 nC = 0; - for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin()); - aIt != aData.aColumnDescriptions.end(); ++aIt ) + for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin()) + ; (aIt != aData.aColumnDescriptions.end()) + ; aIt++, nC++ ) { - mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + bool bExportString = true; + if( nC < nComplexCount ) + { + const Sequence< uno::Any >& rComplexLabel = rComplexColumnDescriptions[nC]; + if( rComplexLabel.getLength()>0 ) + { + double fValue=0.0; + if( rComplexLabel[0] >>=fValue ) + { + bExportString = false; + + SvXMLUnitConverter::convertDouble( msStringBuffer, fValue ); + msString = msStringBuffer.makeStringAndClear(); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT ); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString ); + } + } + } + if( bExportString ) + { + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + } + SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); exportText( *aIt ); if( nC < nComplexCount ) - lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport ); + lcl_exportComplexLabel( rComplexColumnDescriptions[nC], mrExport ); if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd ) { // remind the original range to allow a correct re-association when copying via clipboard @@ -1706,25 +1761,47 @@ void SchXMLExportHelper_Impl::exportTable() { SvXMLElementExport aRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROWS, sal_True, sal_True ); tStringVector::const_iterator aRowDescriptionsIter( aData.aRowDescriptions.begin()); - const Sequence< Sequence< OUString > >& rComplexRowDescriptions = aData.aComplexRowDescriptions; + const Sequence< Sequence< uno::Any > >& rComplexRowDescriptions = aData.aComplexRowDescriptions; sal_Int32 nComplexCount = rComplexRowDescriptions.getLength(); sal_Int32 nC = 0; - for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin()); - aRowIt != aData.aDataInRows.end(); ++aRowIt ) + for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin()) + ; aRowIt != aData.aDataInRows.end() + ; aRowIt++, nC++, aRowDescriptionsIter++ ) { SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True ); //export row descriptions { - mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + bool bExportString = true; + if( nC < nComplexCount ) + { + const Sequence< uno::Any >& rComplexLabel = rComplexRowDescriptions[nC]; + if( rComplexLabel.getLength()>0 ) + { + double fValue=0.0; + if( rComplexLabel[0] >>=fValue ) + { + bExportString = false; + + SvXMLUnitConverter::convertDouble( msStringBuffer, fValue ); + msString = msStringBuffer.makeStringAndClear(); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT ); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString ); + } + } + } + if( bExportString ) + { + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + } + SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); if( aRowDescriptionsIter != aData.aRowDescriptions.end()) { exportText( *aRowDescriptionsIter ); - ++aRowDescriptionsIter; if( nC < nComplexCount ) - lcl_exportComplexLabel( rComplexRowDescriptions[nC++], mrExport ); + lcl_exportComplexLabel( rComplexRowDescriptions[nC], mrExport ); if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd ) { // remind the original range to allow a correct re-association when copying via clipboard @@ -1760,6 +1837,57 @@ void SchXMLExportHelper_Impl::exportTable() OSL_ASSERT( bHasOwnData || (aRowDescriptions_RangeIter == aRowDescriptions_RangeEnd) ); } +namespace +{ + +Reference< chart2::XCoordinateSystem > lcl_getCooSys( const Reference< chart2::XDiagram > & xNewDiagram ) +{ + Reference< chart2::XCoordinateSystem > xCooSys; + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDiagram, uno::UNO_QUERY ); + if(xCooSysCnt.is()) + { + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); + if(aCooSysSeq.getLength()>0) + xCooSys = aCooSysSeq[0]; + } + return xCooSys; +} + +Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem >& xCooSys, + enum XMLTokenEnum eDimension, bool bPrimary=true ) +{ + Reference< chart2::XAxis > xNewAxis; + try + { + if( xCooSys.is() ) + { + sal_Int32 nDimensionIndex=0; + switch( eDimension ) + { + case XML_X: + nDimensionIndex=0; + break; + case XML_Y: + nDimensionIndex=1; + break; + case XML_Z: + nDimensionIndex=2; + break; + default: + break; + } + + xNewAxis = xCooSys->getAxisByDimension( nDimensionIndex, bPrimary ? 0 : 1 ); + } + } + catch( const uno::Exception & ) + { + } + return xNewAxis; +} + +} + void SchXMLExportHelper_Impl::exportPlotArea( Reference< chart::XDiagram > xDiagram, Reference< chart2::XDiagram > xNewDiagram, @@ -1775,8 +1903,6 @@ void SchXMLExportHelper_Impl::exportPlotArea( Reference< beans::XPropertySet > xPropSet; std::vector< XMLPropertyState > aPropertyStates; - OUString aASName; - sal_Bool bHasTwoYAxes = sal_False; sal_Bool bIs3DChart = sal_False; drawing::HomogenMatrix aTransMatrix; @@ -1884,16 +2010,6 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xPropSet.is()) { Any aAny; - try - { - aAny = xPropSet->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSecondaryYAxis" ))); - aAny >>= bHasTwoYAxes; - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property HasSecondaryYAxis not found in Diagram" ); - } // 3d attributes try @@ -1944,7 +2060,8 @@ void SchXMLExportHelper_Impl::exportPlotArea( // series elements // --------------- - exportSeries( xNewDiagram, rPageSize, bExportContent, bHasTwoYAxes ); + Reference< chart2::XAxis > xSecondYAxis = lcl_getAxis( lcl_getCooSys( xNewDiagram ), XML_Y, false ); + exportSeries( xNewDiagram, rPageSize, bExportContent, xSecondYAxis.is() ); // stock-chart elements OUString sChartType ( xDiagram->getDiagramType()); @@ -2106,6 +2223,222 @@ void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< char SvXMLElementExport aCoordinateRegion( mrExport, XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, sal_True, sal_True );//#i100778# todo: change to chart namespace in future - dependent on fileformat } +namespace +{ + XMLTokenEnum lcl_getTimeUnitToken( sal_Int32 nTimeUnit ) + { + XMLTokenEnum eToken = XML_DAYS; + switch( nTimeUnit ) + { + case ::com::sun::star::chart::TimeUnit::YEAR: + eToken = XML_YEARS; + break; + case ::com::sun::star::chart::TimeUnit::MONTH: + eToken = XML_MONTHS; + break; + default://days + break; + } + return eToken; + } +} + +void SchXMLExportHelper_Impl::exportDateScale( const Reference< beans::XPropertySet > xAxisProps ) +{ + if( !xAxisProps.is() ) + return; + + chart::TimeIncrement aIncrement; + if( (xAxisProps->getPropertyValue( OUString::createFromAscii( "TimeIncrement" )) >>= aIncrement) ) + { + sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::DAY; + if( aIncrement.TimeResolution >>= nTimeResolution ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, lcl_getTimeUnitToken( nTimeResolution ) ); + + OUStringBuffer aValue; + chart::TimeInterval aInterval; + if( aIncrement.MajorTimeInterval >>= aInterval ) + { + SvXMLUnitConverter::convertNumber( aValue, aInterval.Number ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, aValue.makeStringAndClear() ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) ); + } + if( aIncrement.MinorTimeInterval >>= aInterval ) + { + SvXMLUnitConverter::convertNumber( aValue, aInterval.Number ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, aValue.makeStringAndClear() ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) ); + } + + SvXMLElementExport aDateScale( mrExport, XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, sal_True, sal_True );//#i25706#todo: change namespace for next ODF version + } +} + +void SchXMLExportHelper_Impl::exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent ) +{ + if( !xTitleProps.is() ) + return; + std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xTitleProps ); + if( bExportContent ) + { + OUString aText; + Any aAny( xTitleProps->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); + aAny >>= aText; + + Reference< drawing::XShape > xShape( xTitleProps, uno::UNO_QUERY ); + if( xShape.is()) + addPosition( xShape ); + + AddAutoStyleAttribute( aPropertyStates ); + SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); + + // paragraph containing title + exportText( aText ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); +} + +void SchXMLExportHelper_Impl::exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent ) +{ + if( !xGridProperties.is() ) + return; + std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xGridProperties ); + if( bExportContent ) + { + AddAutoStyleAttribute( aPropertyStates ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, bMajor ? XML_MAJOR : XML_MINOR ); + SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); +} + +namespace +{ + +//returns true if a date scale needs to be exported +bool lcl_exportAxisType( const Reference< chart2::XAxis > xChart2Axis, SvXMLExport& rExport) +{ + bool bExportDateScale = false; + if( !xChart2Axis.is() ) + return bExportDateScale; + + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion != SvtSaveOptions::ODFVER_LATEST ) //#i25706#todo: change version for next ODF version + return bExportDateScale; + + chart2::ScaleData aScale( xChart2Axis->getScaleData() ); + //#i25706#todo: change namespace for next ODF version + sal_uInt16 nNameSpace = XML_NAMESPACE_CHART_EXT; + + switch(aScale.AxisType) + { + case chart2::AxisType::CATEGORY: + if( aScale.AutoDateAxis ) + { + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO ); + bExportDateScale = true; + } + else + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_TEXT ); + break; + case chart2::AxisType::DATE: + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_DATE ); + bExportDateScale = true; + break; + default: //AUTOMATIC + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO ); + break; + } + + return bExportDateScale; +} + +} + +void SchXMLExportHelper_Impl::exportAxis( + enum XMLTokenEnum eDimension, + enum XMLTokenEnum eAxisName, + const Reference< beans::XPropertySet > xAxisProps, + const Reference< chart2::XAxis >& xChart2Axis, + const OUString& rCategoriesRange, + bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, + bool bExportContent ) +{ + static const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" )); + std::vector< XMLPropertyState > aPropertyStates; + SvXMLElementExport* pAxis = NULL; + + // get property states for autostyles + if( xAxisProps.is() && mxExpPropMapper.is() ) + { + lcl_exportNumberFormat( sNumFormat, xAxisProps, mrExport ); + aPropertyStates = mxExpPropMapper->Filter( xAxisProps ); + } + + bool bExportDateScale = false; + if( bExportContent ) + { + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, eDimension ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, eAxisName ); + AddAutoStyleAttribute( aPropertyStates ); // write style name + if( rCategoriesRange.getLength() ) + bExportDateScale = lcl_exportAxisType( xChart2Axis, mrExport ); + + // open axis element + pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); + + //date scale + if( bExportDateScale ) + exportDateScale( xAxisProps ); + + Reference< beans::XPropertySet > xTitleProps; + Reference< beans::XPropertySet > xMajorGridProps; + Reference< beans::XPropertySet > xMinorGridProps; + Reference< chart::XAxis > xAxis( xAxisProps, uno::UNO_QUERY ); + if( xAxis.is() ) + { + xTitleProps = bHasTitle ? xAxis->getAxisTitle() : 0; + xMajorGridProps = bHasMajorGrid ? xAxis->getMajorGrid() : 0; + xMinorGridProps = bHasMinorGrid ? xAxis->getMinorGrid() : 0; + } + + // axis-title + exportAxisTitle( xTitleProps , bExportContent ); + + // categories if we have a categories chart + if( bExportContent && rCategoriesRange.getLength() ) + { + mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, rCategoriesRange ); + SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True ); + } + + // grid + exportGrid( xMajorGridProps, true, bExportContent ); + exportGrid( xMinorGridProps, false, bExportContent ); + + if( pAxis ) + { + //close axis element + delete pAxis; + pAxis = NULL; + } +} + void SchXMLExportHelper_Impl::exportAxes( const Reference< chart::XDiagram > & xDiagram, const Reference< chart2::XDiagram > & xNewDiagram, @@ -2115,13 +2448,6 @@ void SchXMLExportHelper_Impl::exportAxes( if( ! xDiagram.is()) return; - // variables for autostyles - const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" )); - Reference< beans::XPropertySet > xPropSet; - std::vector< XMLPropertyState > aPropertyStates; - - OUString aASName; - // get some properties from document first sal_Bool bHasXAxis = sal_False, bHasYAxis = sal_False, @@ -2139,46 +2465,20 @@ void SchXMLExportHelper_Impl::exportAxes( bHasYAxisMinorGrid = sal_False, bHasZAxisMajorGrid = sal_False, bHasZAxisMinorGrid = sal_False; - sal_Bool bIs3DChart = sal_False; // get multiple properties using XMultiPropertySet MultiPropertySetHandler aDiagramProperties (xDiagram); - // Check for supported services and then the properties provided by this service. - Reference<lang::XServiceInfo> xServiceInfo (xDiagram, uno::UNO_QUERY); - if (xServiceInfo.is()) - { - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisXSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis")), bHasXAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisYSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis")), bHasYAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisZSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis")), bHasZAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisXSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis")), bHasSecondaryXAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisYSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis")), bHasSecondaryYAxis); - } - } + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis")), bHasXAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis")), bHasYAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis")), bHasZAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis")), bHasSecondaryXAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis")), bHasSecondaryYAxis); aDiagramProperties.Add ( OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle")), bHasXAxisTitle); @@ -2205,506 +2505,139 @@ void SchXMLExportHelper_Impl::exportAxes( aDiagramProperties.Add ( OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid")), bHasZAxisMinorGrid); - aDiagramProperties.Add( - OUString (RTL_CONSTASCII_USTRINGPARAM ("Dim3D")), bIs3DChart); - if ( ! aDiagramProperties.GetProperties ()) { DBG_WARNING ("Required properties not found in Chart diagram"); } - SvXMLElementExport* pAxis = NULL; + Reference< chart2::XCoordinateSystem > xCooSys( lcl_getCooSys(xNewDiagram) ); + + // write an axis element also if the axis itself is not visible, but a grid or a title + + OUString aCategoriesRange; + Reference< chart::XAxisSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); // x axis // ------- - - // write axis element also if the axis itself is not visible, but a grid or - // title - Reference< chart::XAxisXSupplier > xAxisXSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisXSupp.is()) + Reference< ::com::sun::star::chart2::XAxis > xNewAxis = lcl_getAxis( xCooSys, XML_X ); + if( xNewAxis.is() ) { - bool bHasAxisProperties = false; - // get property states for autostyles - if( mxExpPropMapper.is()) + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(0) : 0, uno::UNO_QUERY ); + if( mbHasCategoryLabels && bExportContent ) { - xPropSet = xAxisXSupp->getXAxis(); - if( xPropSet.is()) - { - bHasAxisProperties = true; - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - } - - if( bHasXAxis || - bHasXAxisTitle || bHasXAxisMajorGrid || bHasXAxisMinorGrid || - mbHasCategoryLabels || bHasAxisProperties ) - { - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_X ); - - // write style name - AddAutoStyleAttribute( aPropertyStates ); - - // element - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - // axis-title - if( bHasXAxisTitle ) - { - Reference< beans::XPropertySet > xTitleProp( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - // categories if we have a categories chart - if( bExportContent && - mbHasCategoryLabels ) - { - OUString aCategoriesRange; - // fill msString with cell-range-address of categories - // export own table references - if( xNewDiagram.is()) - { - Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); - if( xCategories.is() ) - { - Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); - if( xValues.is()) - { - Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); - maCategoriesRange = xValues->getSourceRangeRepresentation(); - aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc ); - } - } - } - - if( aCategoriesRange.getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aCategoriesRange ); - SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True ); - } - - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY ); - if( bHasXAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - Reference< beans::XPropertySet > xMinorGrid( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY ); - if( bHasXAxisMinorGrid && xMinorGrid.is()) + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); + if( xCategories.is() ) { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else + Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); + if( xValues.is() ) { - CollectAutoStyle( aPropertyStates ); + Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); + maCategoriesRange = xValues->getSourceRangeRepresentation(); + aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc ); } - aPropertyStates.clear(); - } - if( pAxis ) - { - delete pAxis; - pAxis = NULL; } } + exportAxis( XML_X, XML_PRIMARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasXAxisTitle, bHasXAxisMajorGrid, bHasXAxisMinorGrid, bExportContent ); + aCategoriesRange = OUString(); } // secondary x axis - if( bHasSecondaryXAxis || bHasSecondaryXAxisTitle ) + // ------- + Reference< chart::XSecondAxisTitleSupplier > xSecondTitleSupp( xDiagram, uno::UNO_QUERY ); + xNewAxis = lcl_getAxis( xCooSys, XML_X, false ); + if( xNewAxis.is() ) { - Reference< chart::XTwoAxisXSupplier > xAxisTwoXSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisTwoXSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisTwoXSupp->getSecondaryXAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_X ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - if( bHasSecondaryXAxisTitle ) - { - Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); - Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(0) : 0, uno::UNO_QUERY ); + exportAxis( XML_X, XML_SECONDARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryXAxisTitle, false, false, bExportContent ); } // y axis // ------- - - // write axis element also if the axis itself is not visible, but a grid or - // title - Reference< chart::XAxisYSupplier > xAxisYSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisYSupp.is()) + xNewAxis = lcl_getAxis( xCooSys, XML_Y ); + if( xNewAxis.is() ) { - bool bHasAxisProperties = false; - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisYSupp->getYAxis(); - if( xPropSet.is()) - { - bHasAxisProperties = true; - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - } - - if( bHasYAxis || - bHasYAxisTitle || bHasYAxisMajorGrid || bHasYAxisMinorGrid || bHasAxisProperties ) - { - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Y ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - // axis-title - if( bHasYAxisTitle ) - { - Reference< beans::XPropertySet > xTitleProp( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY ); - if( bHasYAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - // minor grid - Reference< beans::XPropertySet > xMinorGrid( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); - if( bHasYAxisMinorGrid && xMinorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(1) : 0, uno::UNO_QUERY ); + exportAxis( XML_Y, XML_PRIMARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasYAxisTitle, bHasYAxisMajorGrid, bHasYAxisMinorGrid, bExportContent ); } - if( bHasSecondaryYAxis || bHasSecondaryYAxisTitle ) + // secondary y axis + // ------- + xNewAxis = lcl_getAxis( xCooSys, XML_Y, false ); + if( xNewAxis.is() ) { - Reference< chart::XTwoAxisYSupplier > xAxisTwoYSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisTwoYSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisTwoYSupp->getSecondaryYAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_Y ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - if( bHasSecondaryYAxisTitle ) - { - Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); - Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(1) : 0, uno::UNO_QUERY ); + exportAxis( XML_Y, XML_SECONDARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryYAxisTitle, false, false, bExportContent ); } // z axis // ------- + xNewAxis = lcl_getAxis( xCooSys, XML_Z ); + if( xNewAxis.is() ) + { + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(2) : 0, uno::UNO_QUERY ); + exportAxis( XML_Z, XML_PRIMARY_Z, xAxisProps, xNewAxis, aCategoriesRange, bHasZAxisTitle, bHasZAxisMajorGrid, bHasZAxisMinorGrid, bExportContent ); + } +} - if( bHasZAxis && - bIs3DChart ) +namespace +{ + bool lcl_hasNoValuesButText( const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) { - Reference< chart::XAxisZSupplier > xAxisZSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisZSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisZSupp->getZAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Z ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Z ); + if( !xDataSequence.is() ) + return false;//have no data - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else + Sequence< uno::Any > aData; + Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY ); + if( xNumericalDataSequence.is() ) + { + Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() ); + sal_Int32 nCount = aDoubles.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - CollectAutoStyle( aPropertyStates ); + if( !::rtl::math::isNan( aDoubles[i] ) ) + return false;//have double value } - aPropertyStates.clear(); - - // axis-title - if( bHasZAxisTitle ) + } + else + { + aData = xDataSequence->getData(); + double fDouble = 0.0; + sal_Int32 nCount = aData.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - Reference< beans::XPropertySet > xTitleProp( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } + if( (aData[i] >>= fDouble) && !::rtl::math::isNan( fDouble ) ) + return false;//have double value } - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY ); - if( bHasZAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); + } + //no values found - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - // minor grid - Reference< beans::XPropertySet > xMinorGrid( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY ); - if( bHasZAxisMinorGrid && xMinorGrid.is()) + Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); + if( xTextualDataSequence.is() ) + { + uno::Sequence< rtl::OUString > aStrings( xTextualDataSequence->getTextualData() ); + sal_Int32 nCount = aStrings.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); + if( aStrings[i].getLength() ) + return true;//have text } } - if( pAxis ) + else { - delete pAxis; - pAxis = NULL; + if( !aData.getLength() ) + aData = xDataSequence->getData(); + uno::Any aAny; + OUString aString; + sal_Int32 nCount = aData.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) + { + if( (aData[i]>>=aString) && aString.getLength() ) + return true;//have text + } } + //no doubles and no texts + return false; } } @@ -2949,6 +2882,17 @@ void SchXMLExportHelper_Impl::exportSeries( if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ) ) m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues )); } + else if( nSeriesIdx==0 ) + { + //might be that the categories are used as x-values (e.g. for date axis) -> export them accordingly + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); + if( xCategories.is() ) + { + Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); + if( !lcl_hasNoValuesButText( xValues ) ) + lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ); + } + } } if( xYValuesForBubbleChart.is() ) m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xYValuesForBubbleChart )); diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 338b9c23a004..72a324fe772b 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -143,11 +143,9 @@ SchXMLImportHelper::SchXMLImportHelper() : mpChartElemTokenMap( 0 ), mpPlotAreaElemTokenMap( 0 ), mpSeriesElemTokenMap( 0 ), - mpAxisElemTokenMap( 0 ), mpChartAttrTokenMap( 0 ), mpPlotAreaAttrTokenMap( 0 ), - mpAxisAttrTokenMap( 0 ), mpLegendAttrTokenMap( 0 ), mpAutoStyleAttrTokenMap( 0 ), mpCellAttrTokenMap( 0 ), @@ -169,15 +167,11 @@ SchXMLImportHelper::~SchXMLImportHelper() delete mpPlotAreaElemTokenMap; if( mpSeriesElemTokenMap ) delete mpSeriesElemTokenMap; - if( mpAxisElemTokenMap ) - delete mpAxisElemTokenMap; if( mpChartAttrTokenMap ) delete mpChartAttrTokenMap; if( mpPlotAreaAttrTokenMap ) delete mpPlotAreaAttrTokenMap; - if( mpAxisAttrTokenMap ) - delete mpAxisAttrTokenMap; if( mpLegendAttrTokenMap ) delete mpLegendAttrTokenMap; if( mpAutoStyleAttrTokenMap ) @@ -320,24 +314,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap() return *mpSeriesElemTokenMap; } -const SvXMLTokenMap& SchXMLImportHelper::GetAxisElemTokenMap() -{ - if( ! mpAxisElemTokenMap ) - { - static __FAR_DATA SvXMLTokenMapEntry aAxisElemTokenMap[] = -{ - { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE }, - { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES }, - { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID }, - XML_TOKEN_MAP_END -}; - - mpAxisElemTokenMap = new SvXMLTokenMap( aAxisElemTokenMap ); - } // if( ! mpAxisElemTokenMap ) - - return *mpAxisElemTokenMap; -} - // ---------------------------------------- const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap() @@ -395,24 +371,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap() return *mpPlotAreaAttrTokenMap; } -const SvXMLTokenMap& SchXMLImportHelper::GetAxisAttrTokenMap() -{ - if( ! mpAxisAttrTokenMap ) - { - static __FAR_DATA SvXMLTokenMapEntry aAxisAttrTokenMap[] = -{ - { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION }, - { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME }, - { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME }, - XML_TOKEN_MAP_END -}; - - mpAxisAttrTokenMap = new SvXMLTokenMap( aAxisAttrTokenMap ); - } // if( ! mpAxisAttrTokenMap ) - - return *mpAxisAttrTokenMap; -} - const SvXMLTokenMap& SchXMLImportHelper::GetLegendAttrTokenMap() { if( ! mpLegendAttrTokenMap ) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index ef1544b4a280..91b99bb1ff2d 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -30,6 +30,7 @@ #include "SchXMLPlotAreaContext.hxx" #include "SchXMLImport.hxx" +#include "SchXMLAxisContext.hxx" #include "SchXMLSeries2Context.hxx" #include "SchXMLTools.hxx" #include <tools/debug.hxx> @@ -39,7 +40,6 @@ #include <comphelper/processfactory.hxx> #include "xmloff/xmlnmspe.hxx" -#include <xmloff/xmltoken.hxx> #include <xmloff/xmlement.hxx> #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> @@ -51,29 +51,18 @@ #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> -#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> -#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> -#include <com/sun/star/chart/ChartAxisPosition.hpp> -#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> -#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> -#include <com/sun/star/chart/XAxisZSupplier.hpp> -#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/X3DDisplay.hpp> #include <com/sun/star/chart/XStatisticDisplay.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> -#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/drawing/CameraGeometry.hpp> #include <com/sun/star/drawing/FillStyle.hpp> -#include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XStringMapping.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> @@ -84,14 +73,6 @@ using namespace ::xmloff::token; using ::rtl::OUString; using com::sun::star::uno::Reference; -static __FAR_DATA SvXMLEnumMapEntry aXMLAxisClassMap[] = -{ - { XML_X, SCH_XML_AXIS_X }, - { XML_Y, SCH_XML_AXIS_Y }, - { XML_Z, SCH_XML_AXIS_Z }, - { XML_TOKEN_INVALID, 0 } -}; - namespace { @@ -115,19 +96,6 @@ OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< return aResult; } -Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) -{ - Reference< chart2::XAxis > xAxis; - try - { - xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); - } - catch( uno::Exception & ) - { - } - return xAxis; -} - } // anonymous namespace SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter ) @@ -239,47 +207,33 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext( { try { - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisXSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool ); - } - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisXSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool ); - } + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool ); + + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool ); + + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool ); - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisYSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool ); - } - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisYSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool ); - } - - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisZSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool ); - } uno::Any aAny; chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS; aAny <<= eSource; @@ -623,7 +577,7 @@ void SchXMLPlotAreaContext::EndElement() ::std::vector< SchXMLAxis >::const_iterator aIt( ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories())); if( aIt != maAxes.end()) - nDimension = static_cast< sal_Int32 >( (*aIt).eClass ); + nDimension = static_cast< sal_Int32 >( (*aIt).eDimension ); SchXMLTools::CreateCategories( xDataProvider, mxNewDoc, mrCategoriesAddress, 0 /* nCooSysIndex */, @@ -708,875 +662,7 @@ void SchXMLPlotAreaContext::EndElement() } } - CorrectAxisPositions(); -} - -void SchXMLPlotAreaContext::CorrectAxisPositions() -{ - ::rtl::OUString aODFVersionOfFile( GetImport().GetODFVersion() ); - - if( ( !aODFVersionOfFile.getLength() || aODFVersionOfFile.equalsAscii("1.0") - || aODFVersionOfFile.equalsAscii("1.1") - || ( aODFVersionOfFile.equalsAscii("1.2") && !m_bAxisPositionAttributeImported ) ) ) - { - uno::Reference< chart2::XChartDocument > xNewDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - try - { - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); - uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - if( aCooSysSeq.getLength() ) - { - Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); - if( xCooSys.is() ) - { - Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 ); - Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 ); - //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 ); - Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 ); - Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 ); - - uno::Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY ); - - if( xMainXAxisProp.is() && xMainYAxisProp.is() ) - { - chart2::ScaleData aMainXScale = xMainXAxis->getScaleData(); - if( 0 == maChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); - double fCrossoverValue = 0.0; - aMainXScale.Origin >>= fCrossoverValue; - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue") - , uno::makeAny( fCrossoverValue ) ); - - if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - else - { - if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - - chart2::ScaleData aMainYScale = xMainYAxis->getScaleData(); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); - double fCrossoverValue = 0.0; - aMainYScale.Origin >>= fCrossoverValue; - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue") - , uno::makeAny( fCrossoverValue ) ); - - if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryXAxisProp.is() ) - xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryXAxisProp.is() ) - xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - } - } - } - catch( uno::Exception & ) - { - } - } -} - -// ======================================== - -SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName, - uno::Reference< chart::XDiagram > xDiagram, - std::vector< SchXMLAxis >& aAxes, - ::rtl::OUString & rCategoriesAddress, - bool bAddMissingXAxisForNetCharts, - bool bAdaptWrongPercentScaleValues, - bool bAdaptXAxisOrientationForOld2DBarCharts, - bool& rbAxisPositionAttributeImported ) : - SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), - mrImportHelper( rImpHelper ), - mxDiagram( xDiagram ), - maAxes( aAxes ), - mrCategoriesAddress( rCategoriesAddress ), - mbAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ), - mbAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ), - mbAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ), - m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported ) -{ -} - -SchXMLAxisContext::~SchXMLAxisContext() -{} - -/* returns a shape for the current axis's title. The property - "Has...AxisTitle" is set to "True" to get the shape - */ -uno::Reference< drawing::XShape > SchXMLAxisContext::getTitleShape() -{ - uno::Reference< drawing::XShape > xResult; - uno::Any aTrueBool; - aTrueBool <<= (sal_Bool)(sal_True); - uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasXAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getXAxisTitle(), uno::UNO_QUERY ); - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - if( xDiaProp.is() ) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryXAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY ); - } - } - break; - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasYAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getYAxisTitle(), uno::UNO_QUERY ); - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - if( xDiaProp.is() ) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryYAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY ); - } - } - break; - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasZAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getZAxisTitle(), uno::UNO_QUERY ); - } - break; - } - case SCH_XML_AXIS_UNDEF: - DBG_ERROR( "Invalid axis" ); - break; - } - - return xResult; -} - -void SchXMLAxisContext::CreateGrid( ::rtl::OUString sAutoStyleName, - sal_Bool bIsMajor ) -{ - uno::Reference< chart::XDiagram > xDia = mrImportHelper.GetChartDocument()->getDiagram(); - uno::Reference< beans::XPropertySet > xGridProp; - ::rtl::OUString sPropertyName; - DBG_ASSERT( xDia.is(), "diagram object is invalid!" ); - - uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); - uno::Any aTrueBool( uno::makeAny( true )); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - { - uno::Reference< chart::XAxisXSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getXMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getXHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_Y: - { - uno::Reference< chart::XAxisYSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getYMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getYHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getZMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getZHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_UNDEF: - DBG_ERROR( "Invalid axis" ); - break; - } - - // set properties - if( xGridProp.is()) - { - // the line color is black as default, in the model it is a light gray - xGridProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), - uno::makeAny( COL_BLACK )); - if( sAutoStyleName.getLength()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), sAutoStyleName ); - - if( pStyle && pStyle->ISA( XMLPropStyleContext )) - (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp ); - } - } - } -} - -void SchXMLAxisContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - // parse attributes - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - SchXMLImport& rImport = ( SchXMLImport& )GetImport(); - const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetAxisAttrTokenMap(); - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - rtl::OUString aValue = xAttrList->getValueByIndex( i ); - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName )) - { - case XML_TOK_AXIS_DIMENSION: - { - USHORT nEnumVal; - if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisClassMap )) - maCurrentAxis.eClass = ( SchXMLAxisClass )nEnumVal; - } - break; - case XML_TOK_AXIS_NAME: - maCurrentAxis.aName = aValue; - break; - case XML_TOK_AXIS_STYLE_NAME: - msAutoStyleName = aValue; - break; - } - } - - // check for number of axes with same category - maCurrentAxis.nIndexInCategory = 0; - sal_Int32 nNumOfAxes = maAxes.size(); - for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) - { - if( maAxes[ nCurrent ].eClass == maCurrentAxis.eClass ) - maCurrentAxis.nIndexInCategory++; - } - CreateAxis(); -} -namespace -{ - -uno::Reference< chart2::XAxis > lcl_getAxis( const uno::Reference< frame::XModel >& xChartModel, - sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) -{ - uno::Reference< chart2::XAxis > xAxis; - - try - { - uno::Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY ); - if( xChart2Document.is() ) - { - uno::Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram()); - uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > - aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - sal_Int32 nCooSysIndex = 0; - if( nCooSysIndex < aCooSysSeq.getLength() ) - { - uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] ); - if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() ) - { - const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); - if( nAxisIndex <= nMaxAxisIndex ) - xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); - } - } - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Couldn't get axis" ); - } - - return xAxis; -} - -bool lcl_divideBy100( uno::Any& rDoubleAny ) -{ - bool bChanged = false; - double fValue=0.0; - if( (rDoubleAny>>=fValue) && (fValue!=0.0) ) - { - fValue/=100.0; - rDoubleAny = uno::makeAny(fValue); - bChanged = true; - } - return bChanged; -} - -bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData) -{ - bool bChanged = lcl_divideBy100( rScaleData.Minimum ); - bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged; - bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged; - bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged; - return bChanged; -} - -}//end anonymous namespace - -void SchXMLAxisContext::CreateAxis() -{ - // add new Axis to list - maAxes.push_back( maCurrentAxis ); - - // set axis at chart - uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xProp; - uno::Any aTrueBool; - aTrueBool <<= (sal_Bool)(sal_True); - uno::Any aFalseBool; - aFalseBool <<= (sal_Bool)(sal_False); - uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on x axis" ); - } - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getXAxis(); - } - else - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on second x axis" ); - } - uno::Reference< chart::XTwoAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getSecondaryXAxis(); - } - break; - - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on y axis" ); - } - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getYAxis(); - - - if( mbAddMissingXAxisForNetCharts ) - { - if( xDiaProp.is() ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on x axis" ); - } - } - } - } - else - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on second y axis" ); - } - uno::Reference< chart::XTwoAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getSecondaryYAxis(); - } - break; - - case SCH_XML_AXIS_Z: - { - bool bSettingZAxisSuccedded = false; - try - { - rtl::OUString sHasZAxis( rtl::OUString::createFromAscii( "HasZAxis" ) ); - xDiaProp->setPropertyValue( sHasZAxis, aTrueBool ); - xDiaProp->getPropertyValue( sHasZAxis ) >>= bSettingZAxisSuccedded; - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on z axis" ); - } - if( bSettingZAxisSuccedded ) - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getZAxis(); - } - } - break; - case SCH_XML_AXIS_UNDEF: - // nothing - break; - } - - // set properties - if( xProp.is()) - { - // #i109879# the line color is black as default, in the model it is a light gray - xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), - uno::makeAny( COL_BLACK )); - - xProp->setPropertyValue( rtl::OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); - - // #88077# AutoOrigin 'on' is default - xProp->setPropertyValue( rtl::OUString::createFromAscii( "AutoOrigin" ), aTrueBool ); - - if( msAutoStyleName.getLength()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), msAutoStyleName ); - - if( pStyle && pStyle->ISA( XMLPropStyleContext )) - { - // note: SvXMLStyleContext::FillPropertySet is not const - XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - if( pPropStyleContext ) - pPropStyleContext->FillPropertySet( xProp ); - - if( mbAdaptWrongPercentScaleValues && maCurrentAxis.eClass==SCH_XML_AXIS_Y ) - { - //set scale data of added x axis back to default - uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), - 1 /*nDimensionIndex*/, maCurrentAxis.nIndexInCategory /*nAxisIndex*/ ) ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData( xAxis->getScaleData()); - if( lcl_AdaptWrongPercentScaleValues(aScaleData) ) - xAxis->setScaleData( aScaleData ); - } - } - - if( mbAddMissingXAxisForNetCharts ) - { - //copy style from y axis to added x axis: - - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - uno::Reference< beans::XPropertySet > xXAxisProp( xSuppl->getXAxis() ); - (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp ); - } - - //set scale data of added x axis back to default - uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), - 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData; - aScaleData.AxisType = chart2::AxisType::CATEGORY; - aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL; - xAxis->setScaleData( aScaleData ); - } - - //set line style of added x axis to invisible - uno::Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY ); - if( xNewAxisProp.is() ) - { - xNewAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LineStyle") - , uno::makeAny(drawing::LineStyle_NONE)); - } - } - - if( mbAdaptXAxisOrientationForOld2DBarCharts && maCurrentAxis.eClass == SCH_XML_AXIS_X ) - { - bool bIs3DChart = false; - if( xDiaProp.is() && ( xDiaProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart ) - && !bIs3DChart ) - { - uno::Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY ); - if( xChart2Document.is() ) - { - uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY ); - if( xCooSysCnt.is() ) - { - uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); - if( aCooSysSeq.getLength() ) - { - bool bSwapXandYAxis = false; - uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); - uno::Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); - if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis ) - && bSwapXandYAxis ) - { - uno::Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, maCurrentAxis.nIndexInCategory ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData = xAxis->getScaleData(); - aScaleData.Orientation = chart2::AxisOrientation_REVERSE; - xAxis->setScaleData( aScaleData ); - } - } - } - } - } - } - } - - m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue(); - } - } - } - } -} - -void SchXMLAxisContext::SetAxisTitle() -{ - // add new Axis to list - maAxes.push_back( maCurrentAxis ); - - // set axis at chart - sal_Bool bHasTitle = ( maCurrentAxis.aTitle.getLength() > 0 ); - uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getZAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - case SCH_XML_AXIS_UNDEF: - // nothing - break; - } -} - -SvXMLImportContext* SchXMLAxisContext::CreateChildContext( - USHORT p_nPrefix, - const rtl::OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - SvXMLImportContext* pContext = 0; - const SvXMLTokenMap& rTokenMap = mrImportHelper.GetAxisElemTokenMap(); - - switch( rTokenMap.Get( p_nPrefix, rLocalName )) - { - case XML_TOK_AXIS_TITLE: - { - uno::Reference< drawing::XShape > xTitleShape = getTitleShape(); - pContext = new SchXMLTitleContext( mrImportHelper, GetImport(), rLocalName, - maCurrentAxis.aTitle, - xTitleShape ); - } - break; - - case XML_TOK_AXIS_CATEGORIES: - pContext = new SchXMLCategoriesContext( mrImportHelper, GetImport(), - p_nPrefix, rLocalName, - mrCategoriesAddress ); - maCurrentAxis.bHasCategories = true; - break; - - case XML_TOK_AXIS_GRID: - { - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - sal_Bool bIsMajor = sal_True; // default value for class is "major" - rtl::OUString sAutoStyleName; - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_CHART ) - { - if( IsXMLToken( aLocalName, XML_CLASS ) ) - { - if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) ) - bIsMajor = sal_False; - } - else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) - sAutoStyleName = xAttrList->getValueByIndex( i ); - } - } - - CreateGrid( sAutoStyleName, bIsMajor ); - - // don't create a context => use default context. grid elements are empty - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - } - break; - - default: - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - break; - } - - return pContext; -} - -void SchXMLAxisContext::EndElement() -{ - SetAxisTitle(); + SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported ); } // ======================================== @@ -1636,44 +722,6 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr // ======================================== -SchXMLCategoriesContext::SchXMLCategoriesContext( - SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const rtl::OUString& rLocalName, - rtl::OUString& rAddress ) : - SvXMLImportContext( rImport, nPrefix, rLocalName ), - mrImportHelper( rImpHelper ), - mrAddress( rAddress ) -{ -} - -SchXMLCategoriesContext::~SchXMLCategoriesContext() -{ -} - -void SchXMLCategoriesContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_TABLE && - IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) ) - { - uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY ); - mrAddress = xAttrList->getValueByIndex( i ); - // lcl_ConvertRange( xAttrList->getValueByIndex( i ), xNewDoc ); - } - } -} - -// ======================================== - SchXMLPositonAttributesHelper::SchXMLPositonAttributesHelper( SvXMLImport& rImporter ) : m_rImport( rImporter ) , m_aPosition(0,0) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx index 1f0de466dcb1..ca44e127cfb8 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx @@ -131,8 +131,6 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); virtual void EndElement(); - void CorrectAxisPositions(); - private: SchXMLImportHelper& mrImportHelper; ::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram; @@ -166,47 +164,6 @@ private: ::com::sun::star::awt::Size maChartSize; }; -// ---------------------------------------- - -class SchXMLAxisContext : public SvXMLImportContext -{ -private: - SchXMLImportHelper& mrImportHelper; - ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > mxDiagram; - SchXMLAxis maCurrentAxis; - std::vector< SchXMLAxis >& maAxes; - rtl::OUString msAutoStyleName; - rtl::OUString& mrCategoriesAddress; - bool mbAddMissingXAxisForNetCharts; //to correct errors from older versions - bool mbAdaptWrongPercentScaleValues; //to correct errors from older versions - bool mbAdaptXAxisOrientationForOld2DBarCharts; //to correct different behaviour from older versions - bool& m_rbAxisPositionAttributeImported; - - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTitleShape(); - void CreateGrid( ::rtl::OUString sAutoStyleName, sal_Bool bIsMajor ); - void CreateAxis(); - void SetAxisTitle(); - -public: - SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName, - ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > xDiagram, - std::vector< SchXMLAxis >& aAxes, - ::rtl::OUString& rCategoriesAddress, - bool bAddMissingXAxisForNetCharts, - bool bAdaptWrongPercentScaleValues, - bool bAdaptXAxisOrientationForOld2DBarCharts, - bool& rbAxisPositionAttributeImported ); - virtual ~SchXMLAxisContext(); - - virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); - virtual void EndElement(); - virtual SvXMLImportContext* CreateChildContext( - USHORT nPrefix, - const rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); -}; - //---------------------------------------- class SchXMLDataPointContext : public SvXMLImportContext @@ -233,24 +190,6 @@ public: // ---------------------------------------- -class SchXMLCategoriesContext : public SvXMLImportContext -{ -private: - SchXMLImportHelper& mrImportHelper; - rtl::OUString& mrAddress; - -public: - SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const rtl::OUString& rLocalName, - rtl::OUString& rAddress ); - virtual ~SchXMLCategoriesContext(); - virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); -}; - -// ---------------------------------------- - class SchXMLCoordinateRegionContext : public SvXMLImportContext { public: diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index b3b322568ea6..f42154b056c9 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -336,7 +336,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) { if( aValue.equals( mrAxes[ nCurrent ].aName ) && - mrAxes[ nCurrent ].eClass == SCH_XML_AXIS_Y ) + mrAxes[ nCurrent ].eDimension == SCH_XML_AXIS_Y ) { mpAttachedAxis = &( mrAxes[ nCurrent ] ); } @@ -364,7 +364,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib if( mpAttachedAxis ) { - if( mpAttachedAxis->nIndexInCategory > 0 ) + if( mpAttachedAxis->nAxisIndex > 0 ) { // secondary axis => property has to be set (primary is default) mnAttachedAxis = 2; diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index cc01a7d1c050..a7214fa558bd 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -42,11 +42,11 @@ #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> @@ -375,12 +375,19 @@ void SchXMLTableContext::StartElement( const uno::Reference< xml::sax::XAttribut rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); rtl::OUString aLocalName; USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_TABLE && - IsXMLToken( aLocalName, XML_NAME ) ) + if ( nPrefix == XML_NAMESPACE_TABLE ) { - mrTable.aTableNameOfFile = xAttrList->getValueByIndex( i ); - break; // we only need this attribute + if ( IsXMLToken( aLocalName, XML_NAME ) ) + { + mrTable.aTableNameOfFile = xAttrList->getValueByIndex( i ); + } + else if ( IsXMLToken( aLocalName, XML_PROTECTED ) ) + { + if ( IsXMLToken( xAttrList->getValueByIndex( i ), XML_TRUE ) ) + { + mrTable.bProtected = true; + } + } } } } @@ -839,15 +846,25 @@ void SchXMLTableCellContext::EndElement() // ======================================== -void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< OUString >& rComplexLabel ) +void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< uno::Any >& rComplexLabel ) { if( rCell.eType == SCH_CELL_TYPE_STRING ) { rComplexLabel.realloc(1); - rComplexLabel[0] = rCell.aString; + rComplexLabel[0] = uno::makeAny( rCell.aString ); } else if( rCell.pComplexString && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING ) - rComplexLabel = *rCell.pComplexString; + { + sal_Int32 nCount = rCell.pComplexString->getLength(); + rComplexLabel.realloc( nCount ); + for( sal_Int32 nN=0; nN<nCount; nN++) + rComplexLabel[nN] = uno::makeAny((*rCell.pComplexString)[nN]); + } + else if( rCell.eType == SCH_CELL_TYPE_FLOAT ) + { + rComplexLabel.realloc(1); + rComplexLabel[0] = uno::makeAny( rCell.fValue ); + } } void SchXMLTableHelper::applyTableToInternalDataProvider( @@ -878,8 +895,8 @@ void SchXMLTableHelper::applyTableToInternalDataProvider( } Sequence< Sequence< double > > aDataInRows( nNumRows ); - Sequence< Sequence< OUString > > aComplexRowDescriptions( nNumRows ); - Sequence< Sequence< OUString > > aComplexColumnDescriptions( nNumColumns ); + Sequence< Sequence< uno::Any > > aComplexRowDescriptions( nNumRows ); + Sequence< Sequence< uno::Any > > aComplexColumnDescriptions( nNumColumns ); for( sal_Int32 i=0; i<nNumRows; ++i ) aDataInRows[i].realloc( nNumColumns ); @@ -919,15 +936,28 @@ void SchXMLTableHelper::applyTableToInternalDataProvider( } //apply the collected data to the chart - Reference< chart::XComplexDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY ); + Reference< chart2::XAnyDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY ); if( !xDataAccess.is() ) return; xDataAccess->setData( aDataInRows ); if( rTable.bHasHeaderColumn ) - xDataAccess->setComplexRowDescriptions( aComplexRowDescriptions ); + xDataAccess->setAnyRowDescriptions( aComplexRowDescriptions ); if( rTable.bHasHeaderRow ) - xDataAccess->setComplexColumnDescriptions( aComplexColumnDescriptions ); + xDataAccess->setAnyColumnDescriptions( aComplexColumnDescriptions ); + + if ( rTable.bProtected ) + { + try + { + Reference< beans::XPropertySet > xProps( xChartDoc, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ), uno::makeAny( sal_True ) ); + xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ), uno::makeAny( sal_True ) ); + } + catch ( uno::Exception& ) + { + } + } } void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk new file mode 100644 index 000000000000..2f61a3d6f0e5 --- /dev/null +++ b/xmloff/source/chart/makefile.mk @@ -0,0 +1,71 @@ +#************************************************************************* +# +# 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 +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/.. +PRJNAME = xmloff +TARGET = chart +AUTOSEG = true +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = $(SLO)$/ColorPropertySet.obj \ + $(SLO)$/SchXMLTools.obj \ + $(SLO)$/SchXMLExport.obj \ + $(SLO)$/SchXMLImport.obj \ + $(SLO)$/contexts.obj \ + $(SLO)$/SchXMLTableContext.obj \ + $(SLO)$/SchXMLChartContext.obj \ + $(SLO)$/SchXMLPlotAreaContext.obj \ + $(SLO)$/SchXMLAxisContext.obj \ + $(SLO)$/SchXMLParagraphContext.obj \ + $(SLO)$/SchXMLTextListContext.obj \ + $(SLO)$/SchXMLSeriesHelper.obj \ + $(SLO)$/SchXMLSeries2Context.obj \ + $(SLO)$/PropertyMaps.obj \ + $(SLO)$/XMLChartStyleContext.obj \ + $(SLO)$/XMLErrorIndicatorPropertyHdl.obj \ + $(SLO)$/XMLErrorBarStylePropertyHdl.obj \ + $(SLO)$/SchXMLAutoStylePoolP.obj \ + $(SLO)$/XMLChartPropertyContext.obj \ + $(SLO)$/XMLSymbolImageContext.obj \ + $(SLO)$/XMLLabelSeparatorContext.obj \ + $(SLO)$/XMLTextOrientationHdl.obj \ + $(SLO)$/XMLSymbolTypePropertyHdl.obj \ + $(SLO)$/XMLAxisPositionPropertyHdl.obj \ + $(SLO)$/SchXMLCalculationSettingsContext.obj \ + $(SLO)$/transporttypes.obj + +# --- Targets -------------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx index 27c8850e2b81..30f70d882ed0 100644 --- a/xmloff/source/chart/transporttypes.hxx +++ b/xmloff/source/chart/transporttypes.hxx @@ -87,12 +87,15 @@ struct SchXMLTable ::std::vector< sal_Int32 > aHiddenColumns; + bool bProtected; + SchXMLTable() : nRowIndex( -1 ), nColumnIndex( -1 ), nMaxColumnIndex( -1 ), nNumberOfColsEstimate( 0 ), bHasHeaderRow( false ), - bHasHeaderColumn( false ) + bHasHeaderColumn( false ), + bProtected( false ) {} }; @@ -132,7 +135,7 @@ struct SchNumericCellRangeAddress // ---------------------------------------- -enum SchXMLAxisClass +enum SchXMLAxisDimension { SCH_XML_AXIS_X = 0, SCH_XML_AXIS_Y, @@ -142,13 +145,13 @@ enum SchXMLAxisClass struct SchXMLAxis { - enum SchXMLAxisClass eClass; - sal_Int8 nIndexInCategory; + enum SchXMLAxisDimension eDimension; + sal_Int8 nAxisIndex;//0->primary axis; 1->secondary axis rtl::OUString aName; rtl::OUString aTitle; bool bHasCategories; - SchXMLAxis() : eClass( SCH_XML_AXIS_UNDEF ), nIndexInCategory( 0 ), bHasCategories( false ) {} + SchXMLAxis() : eDimension( SCH_XML_AXIS_UNDEF ), nAxisIndex( 0 ), bHasCategories( false ) {} }; // ---------------------------------------- diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 6cfacbd93905..824d28a51a5c 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3113,6 +3113,14 @@ namespace xmloff { namespace token { TOKEN( "outside-minimum", XML_OUTSIDE_MINIMUM ), TOKEN( "outside-maximum", XML_OUTSIDE_MAXIMUM ), + TOKEN( "axis-type", XML_AXIS_TYPE ), //#i25706# + TOKEN( "date-scale", XML_DATE_SCALE ), + TOKEN( "base-time-unit", XML_BASE_TIME_UNIT ), + TOKEN( "major-interval-value", XML_MAJOR_INTERVAL_VALUE ), + TOKEN( "minor-interval-value", XML_MINOR_INTERVAL_VALUE ), + TOKEN( "major-interval-unit", XML_MAJOR_INTERVAL_UNIT ), + TOKEN( "minor-interval-unit", XML_MINOR_INTERVAL_UNIT ), + TOKEN( "min-value", XML_MIN_VALUE ), TOKEN( "max-value", XML_MAX_VALUE ), |