summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorAndreas Schlüns <as@openoffice.org>2004-12-07 12:18:17 +0000
committerAndreas Schlüns <as@openoffice.org>2004-12-07 12:18:17 +0000
commitc2b13b71485d3f912731a75c28e7b5f6fbc3532c (patch)
tree13755977b47f308a988d19c989dee1f54c09e0ac /framework
parentd06797b2e126db11d15d187d7505ab02a3a4fe55 (diff)
#i38373#, #i38471#, #i38386# forget storages on reload
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uiconfiguration/uiconfigurationmanager.hxx5
-rw-r--r--framework/source/accelerators/documentacceleratorconfiguration.cxx60
-rw-r--r--framework/source/accelerators/presethandler.cxx108
-rw-r--r--framework/source/accelerators/storageholder.cxx25
-rw-r--r--framework/source/inc/accelerators/documentacceleratorconfiguration.hxx21
-rw-r--r--framework/source/inc/accelerators/presethandler.hxx19
-rw-r--r--framework/source/inc/accelerators/storageholder.hxx9
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx27
8 files changed, 219 insertions, 55 deletions
diff --git a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx
index f1b80d2c44..65589cd5a4 100644
--- a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx
+++ b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: uiconfigurationmanager.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: obo $ $Date: 2004-07-06 16:51:32 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -290,6 +290,7 @@ namespace framework
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xImageManager;
+ com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xAccConfig;
};
}
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx
index a451ce5fdc..63311ad5a4 100644
--- a/framework/source/accelerators/documentacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentacceleratorconfiguration.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: as $ $Date: 2004-10-14 09:26:21 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -100,15 +100,17 @@ namespace framework
//-----------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
-DEFINE_XINTERFACE_2(DocumentAcceleratorConfiguration ,
- AcceleratorConfiguration ,
- DIRECT_INTERFACE(css::lang::XServiceInfo) ,
- DIRECT_INTERFACE(css::lang::XInitialization))
-
-DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(DocumentAcceleratorConfiguration,
- AcceleratorConfiguration ,
- css::lang::XServiceInfo ,
- css::lang::XInitialization )
+DEFINE_XINTERFACE_3(DocumentAcceleratorConfiguration ,
+ AcceleratorConfiguration ,
+ DIRECT_INTERFACE(css::lang::XServiceInfo) ,
+ DIRECT_INTERFACE(css::lang::XInitialization) ,
+ DIRECT_INTERFACE(dcss::ui::XUIConfigurationStorage))
+
+DEFINE_XTYPEPROVIDER_3_WITH_BASECLASS(DocumentAcceleratorConfiguration ,
+ AcceleratorConfiguration ,
+ css::lang::XServiceInfo ,
+ css::lang::XInitialization ,
+ dcss::ui::XUIConfigurationStorage)
DEFINE_XSERVICEINFO_MULTISERVICE(DocumentAcceleratorConfiguration ,
::cppu::OWeakObject ,
@@ -155,6 +157,36 @@ void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Seque
impl_ts_fillCache();
}
+
+//-----------------------------------------------
+void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::RuntimeException)
+{
+ // Attention! xStorage must be accepted too, if it's NULL !
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+ sal_Bool bForgetOldStorages = m_xDocumentRoot.is();
+ m_xDocumentRoot = xStorage;
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ if (bForgetOldStorages)
+ impl_ts_clearCache();
+
+ if (xStorage.is())
+ impl_ts_fillCache();
+}
+
+//-----------------------------------------------
+sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
+ throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ return m_xDocumentRoot.is();
+ // <- SAFE ----------------------------------
+}
//-----------------------------------------------
void DocumentAcceleratorConfiguration::impl_ts_fillCache()
@@ -199,4 +231,10 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
{}
}
+//-----------------------------------------------
+void DocumentAcceleratorConfiguration::impl_ts_clearCache()
+{
+ m_aPresetHandler.forgetCachedStorages();
+}
+
} // namespace framework
diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx
index 3c159eb30f..e1ebe80faa 100644
--- a/framework/source/accelerators/presethandler.cxx
+++ b/framework/source/accelerators/presethandler.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: presethandler.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2004-11-26 20:36:46 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -211,11 +211,25 @@ PresetHandler::PresetHandler(const PresetHandler& rCopy)
//-----------------------------------------------
PresetHandler::~PresetHandler()
{
- m_aSharedStorages->m_lStoragesUser.closePath(m_sRelPath);
- // in document case share and user are the same ...
- // so we would close the same path a second time, which isnt allowed!
- if (m_eConfigType != E_DOCUMENT)
- m_aSharedStorages->m_lStoragesShare.closePath(m_sRelPath);
+ forgetCachedStorages();
+}
+
+//-----------------------------------------------
+void PresetHandler::forgetCachedStorages()
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ m_xWorkingStorageShare.clear();
+ m_xWorkingStorageUser.clear();
+
+ m_aSharedStorages->m_lStoragesUser.forgetCachedStorages();
+ m_aSharedStorages->m_lStoragesShare.forgetCachedStorages();
+
+ m_lDocumentStorages.forgetCachedStorages();
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
}
//-----------------------------------------------
@@ -389,8 +403,19 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
xUser = getOrCreateRootStorageUser();
}
- sal_Int32 eShareMode = (css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE); // means: use existing storage or create empty one!
- sal_Int32 eUserMode = (css::embed::ElementModes::READWRITE ); // means: use existing storage or create empty one ... and use it readonly if no write access!
+ // a) inside share layer we should not create any new structures ... We jave to use
+ // existing ones only!
+ // b) inside user layer we can (SOFT mode!) but sometimes we shouldnt (HARD mode!)
+ // create new empty structures. We should preferr using of any existing structure.
+ sal_Int32 eShareMode = (css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE);
+ sal_Int32 eUserModeHard = (css::embed::ElementModes::READWRITE | css::embed::ElementModes::NOCREATE);
+ sal_Int32 eUserModeSoft = (css::embed::ElementModes::READWRITE );
+
+ // Prefer HARD mode for user layer (especialy for global or module based configurations, where
+ // our setup is responsible to create all needed structures.
+ // But switch to SOFT mode in case document based configuration is used.
+ // Then we may be must create our own structures!
+ sal_Int32 eUserMode = eUserModeHard;
::rtl::OUStringBuffer sRelPathBuf(1024);
::rtl::OUString sRelPath;
@@ -424,6 +449,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
case E_DOCUMENT :
{
+ eUserMode = eUserModeSoft;
sRelPathBuf.append(sResource);
sRelPath = sRelPathBuf.makeStringAndClear();
@@ -440,7 +466,6 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
break;
}
-
if (
(aLocale != ::comphelper::Locale::X_NOTRANSLATE()) && // localized level?
(eConfigType != E_DOCUMENT ) // no localization in document mode!
@@ -797,30 +822,55 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
sal_Bool bShare ,
const ::comphelper::Locale& aLocale)
{
- css::uno::Reference< css::embed::XStorage > xPath;
- ::rtl::OUString sLocalizedPath;
- ::comphelper::Locale aTryLocale = aLocale;
- while (sal_True)
- {
- sLocalizedPath = sPath;
- sLocalizedPath += PATH_SEPERATOR;
- sLocalizedPath += aTryLocale.toISO();
+ css::uno::Reference< css::embed::XStorage > xPath = impl_openPathIgnoringErrors(sPath, eMode, bShare);
+ ::std::vector< ::rtl::OUString > lSubFolders = impl_getSubFolderNames(xPath);
+ ::std::vector< ::rtl::OUString >::const_iterator pLocaleFolder = ::comphelper::Locale::getFallback(lSubFolders, aLocale.toISO());
- xPath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
- if (!xPath.is())
- {
- if (::comphelper::Locale::getFallback(aTryLocale))
- continue;
- }
- break;
- }
+ if (pLocaleFolder == lSubFolders.end())
+ return css::uno::Reference< css::embed::XStorage >();
+
+ ::rtl::OUString sLocalizedPath;
+ sLocalizedPath = sPath;
+ sLocalizedPath += PATH_SEPERATOR;
+ sLocalizedPath += *pLocaleFolder;
+
+ css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
- // return localized path as result too
- if (xPath.is())
+ if (xLocalePath.is())
sPath = sLocalizedPath;
else
sPath = ::rtl::OUString();
- return xPath;
+
+ return xLocalePath;
+}
+
+//-----------------------------------------------
+::std::vector< ::rtl::OUString > PresetHandler::impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder)
+{
+ css::uno::Reference< css::container::XNameAccess > xAccess(xFolder, css::uno::UNO_QUERY);
+ if (!xAccess.is())
+ return ::std::vector< ::rtl::OUString >();
+
+ ::std::vector< ::rtl::OUString > lSubFolders;
+ const css::uno::Sequence< ::rtl::OUString > lNames = xAccess->getElementNames();
+ const ::rtl::OUString* pNames = lNames.getConstArray();
+ sal_Int32 c = lNames.getLength();
+ sal_Int32 i = 0;
+
+ for (i=0; i<c; ++i)
+ {
+ try
+ {
+ if (xFolder->isStorageElement(pNames[i]))
+ lSubFolders.push_back(pNames[i]);
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+ }
+
+ return lSubFolders;
}
//-----------------------------------------------
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index ab934c82c0..a309d6ae99 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: storageholder.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: rt $ $Date: 2004-09-20 10:06:44 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -157,6 +157,27 @@ StorageHolder::~StorageHolder()
}
//-----------------------------------------------
+void StorageHolder::forgetCachedStorages()
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ TPath2StorageInfo::iterator pIt;
+ for ( pIt = m_lStorages.begin();
+ pIt != m_lStorages.end() ;
+ ++pIt )
+ {
+ TStorageInfo& rInfo = pIt->second;
+ // TODO think about listener !
+ rInfo.Storage.clear();
+ }
+ m_lStorages.clear();
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
void StorageHolder::setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot)
{
// SAFE -> ----------------------------------
diff --git a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx b/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
index 4e8fafc2d8..8ad2590e4a 100644
--- a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentacceleratorconfiguration.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: rt $ $Date: 2004-09-20 10:07:15 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,6 +92,10 @@
#include <com/sun/star/lang/XInitialization.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_UI_XUICONFIGURATIONSTORAGE_HPP_
+#include <drafts/com/sun/star/ui/XUIConfigurationStorage.hpp>
+#endif
+
//__________________________________________
// other includes
@@ -109,6 +113,7 @@ namespace framework
class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
, public css::lang::XServiceInfo
, public css::lang::XInitialization
+ , public dcss::ui::XUIConfigurationStorage
{
//______________________________________
// member
@@ -143,6 +148,13 @@ class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
throw(css::uno::Exception ,
css::uno::RuntimeException);
+
+ // XUIConfigurationStorage
+ virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasStorage()
+ throw(css::uno::RuntimeException);
//______________________________________
// helper
@@ -152,6 +164,11 @@ class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
//----------------------------------
/** read all data into the cache. */
void impl_ts_fillCache();
+
+ //----------------------------------
+ /** forget all currently cached data AND(!)
+ forget all currently used storages. */
+ void impl_ts_clearCache();
};
} // namespace framework
diff --git a/framework/source/inc/accelerators/presethandler.hxx b/framework/source/inc/accelerators/presethandler.hxx
index e6573be39f..d1406a676e 100644
--- a/framework/source/inc/accelerators/presethandler.hxx
+++ b/framework/source/inc/accelerators/presethandler.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: presethandler.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: obo $ $Date: 2004-11-16 14:53:27 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -313,6 +313,10 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
virtual ~PresetHandler();
//---------------------------------------
+ /** @short free all currently cache(!) storages. */
+ void forgetCachedStorages();
+
+ //---------------------------------------
/** @short return access to the internaly used and cached root storage.
@descr These root storages are the base of all further opened
@@ -570,6 +574,17 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
sal_Int32 eMode ,
sal_Bool bShare ,
const ::comphelper::Locale& aLocale);
+
+ //---------------------------------------
+ /** @short returns the names of all sub storages of specified storage.
+
+ @param xFolder
+ the base storage for this operation.
+
+ @return [vector< string >]
+ a list of folder names.
+ */
+ ::std::vector< ::rtl::OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder);
};
} // namespace framework
diff --git a/framework/source/inc/accelerators/storageholder.hxx b/framework/source/inc/accelerators/storageholder.hxx
index 7d59132a88..8092aef0e0 100644
--- a/framework/source/inc/accelerators/storageholder.hxx
+++ b/framework/source/inc/accelerators/storageholder.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: storageholder.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: rt $ $Date: 2004-09-20 10:08:14 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -179,6 +179,11 @@ class StorageHolder : private ThreadHelpBase // attention! Must be the first bas
//---------------------------------------
/** @short TODO
*/
+ virtual void forgetCachedStorages();
+
+ //---------------------------------------
+ /** @short TODO
+ */
virtual void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
//---------------------------------------
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index 7917d55ef8..ed06c04237 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: uiconfigurationmanager.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: hr $ $Date: 2004-11-26 20:37:38 $
+ * last change: $Author: as $ $Date: 2004-12-07 13:18:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1161,13 +1161,20 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager() throw
Reference< XInterface > SAL_CALL UIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException)
{
+ // SAFE ->
ResetableGuard aGuard( m_aLock );
+
+ if (m_xAccConfig.is())
+ return m_xAccConfig;
+
Reference< XMultiServiceFactory > xSMGR = m_xServiceManager;
Reference< XStorage > xDocumentRoot = m_xDocConfigStorage;
+
aGuard.unlock();
+ // <- SAFE
- Reference< XInterface > xManager = xSMGR->createInstance(SERVICENAME_DOCUMENTACCELERATORCONFIGURATION);
- Reference< XInitialization > xInit (xManager, UNO_QUERY_THROW);
+ Reference< XInterface > xAccConfig = xSMGR->createInstance(SERVICENAME_DOCUMENTACCELERATORCONFIGURATION);
+ Reference< XInitialization > xInit (xAccConfig, UNO_QUERY_THROW);
PropertyValue aProp;
aProp.Name = ::rtl::OUString::createFromAscii("DocumentRoot");
@@ -1178,7 +1185,13 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getShortCutManager() th
xInit->initialize(lArgs);
- return xManager;
+ // SAFE ->
+ aGuard.lock();
+ m_xAccConfig = xAccConfig;
+ aGuard.unlock();
+ // <- SAFE
+
+ return xAccConfig;
}
Reference< XInterface > SAL_CALL UIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException)
@@ -1212,6 +1225,10 @@ void SAL_CALL UIConfigurationManager::setStorage( const Reference< XStorage >& S
m_xDocConfigStorage = Storage;
m_bReadOnly = sal_True;
+ Reference< XUIConfigurationStorage > xAccUpdate(m_xAccConfig, UNO_QUERY);
+ if ( xAccUpdate.is() )
+ xAccUpdate->setStorage( m_xDocConfigStorage );
+
if ( m_xImageManager.is() )
{
ImageManager* pImageManager = (ImageManager*)m_xImageManager.get();