Use SolarMutexGuard directly
Change-Id: I8e76a9cc9c06420fde3a1c5564410624ce5a91ec
This commit is contained in:
@@ -74,8 +74,7 @@ namespace framework
|
|||||||
|
|
||||||
|
|
||||||
XMLBasedAcceleratorConfiguration::XMLBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
|
XMLBasedAcceleratorConfiguration::XMLBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
|
||||||
: ThreadHelpBase (&Application::GetSolarMutex())
|
: m_xContext (xContext )
|
||||||
, m_xContext (xContext )
|
|
||||||
, m_aPresetHandler(xContext )
|
, m_aPresetHandler(xContext )
|
||||||
, m_pWriteCache (0 )
|
, m_pWriteCache (0 )
|
||||||
{
|
{
|
||||||
@@ -91,14 +90,10 @@ XMLBasedAcceleratorConfiguration::~XMLBasedAcceleratorConfiguration()
|
|||||||
css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfiguration::getAllKeyEvents()
|
css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfiguration::getAllKeyEvents()
|
||||||
throw(css::uno::RuntimeException, std::exception)
|
throw(css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG();
|
AcceleratorCache& rCache = impl_getCFG();
|
||||||
AcceleratorCache::TKeyList lKeys = rCache.getAllKeys();
|
AcceleratorCache::TKeyList lKeys = rCache.getAllKeys();
|
||||||
return lKeys.getAsConstList();
|
return lKeys.getAsConstList();
|
||||||
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,17 +101,13 @@ OUString SAL_CALL XMLBasedAcceleratorConfiguration::getCommandByKeyEvent(const c
|
|||||||
throw(css::container::NoSuchElementException,
|
throw(css::container::NoSuchElementException,
|
||||||
css::uno::RuntimeException, std::exception )
|
css::uno::RuntimeException, std::exception )
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG();
|
AcceleratorCache& rCache = impl_getCFG();
|
||||||
if (!rCache.hasKey(aKeyEvent))
|
if (!rCache.hasKey(aKeyEvent))
|
||||||
throw css::container::NoSuchElementException(
|
throw css::container::NoSuchElementException(
|
||||||
OUString(),
|
OUString(),
|
||||||
static_cast< ::cppu::OWeakObject* >(this));
|
static_cast< ::cppu::OWeakObject* >(this));
|
||||||
return rCache.getCommandByKey(aKeyEvent);
|
return rCache.getCommandByKey(aKeyEvent);
|
||||||
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,14 +133,9 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::setKeyEvent(const css::awt::KeyE
|
|||||||
static_cast< ::cppu::OWeakObject* >(this),
|
static_cast< ::cppu::OWeakObject* >(this),
|
||||||
1);
|
1);
|
||||||
|
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aWriteLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG(sal_True); // sal_True => force getting of a writeable cache!
|
AcceleratorCache& rCache = impl_getCFG(sal_True); // sal_True => force getting of a writeable cache!
|
||||||
rCache.setKeyCommandPair(aKeyEvent, sCommand);
|
rCache.setKeyCommandPair(aKeyEvent, sCommand);
|
||||||
|
|
||||||
aWriteLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,17 +143,13 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::removeKeyEvent(const css::awt::K
|
|||||||
throw(css::container::NoSuchElementException,
|
throw(css::container::NoSuchElementException,
|
||||||
css::uno::RuntimeException, std::exception )
|
css::uno::RuntimeException, std::exception )
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aWriteLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG(sal_True); // true => force using of a writeable cache
|
AcceleratorCache& rCache = impl_getCFG(sal_True); // true => force using of a writeable cache
|
||||||
if (!rCache.hasKey(aKeyEvent))
|
if (!rCache.hasKey(aKeyEvent))
|
||||||
throw css::container::NoSuchElementException(
|
throw css::container::NoSuchElementException(
|
||||||
OUString(),
|
OUString(),
|
||||||
static_cast< ::cppu::OWeakObject* >(this));
|
static_cast< ::cppu::OWeakObject* >(this));
|
||||||
rCache.removeKey(aKeyEvent);
|
rCache.removeKey(aKeyEvent);
|
||||||
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,9 +164,7 @@ css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfigurati
|
|||||||
static_cast< ::cppu::OWeakObject* >(this),
|
static_cast< ::cppu::OWeakObject* >(this),
|
||||||
1);
|
1);
|
||||||
|
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG();
|
AcceleratorCache& rCache = impl_getCFG();
|
||||||
if (!rCache.hasCommand(sCommand))
|
if (!rCache.hasCommand(sCommand))
|
||||||
throw css::container::NoSuchElementException(
|
throw css::container::NoSuchElementException(
|
||||||
@@ -193,8 +173,6 @@ css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfigurati
|
|||||||
|
|
||||||
AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(sCommand);
|
AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(sCommand);
|
||||||
return lKeys.getAsConstList();
|
return lKeys.getAsConstList();
|
||||||
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,8 +180,7 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XMLBasedAcceleratorConfiguration::g
|
|||||||
throw(css::lang::IllegalArgumentException ,
|
throw(css::lang::IllegalArgumentException ,
|
||||||
css::uno::RuntimeException, std::exception )
|
css::uno::RuntimeException, std::exception )
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
|
|
||||||
sal_Int32 i = 0;
|
sal_Int32 i = 0;
|
||||||
sal_Int32 c = lCommandList.getLength();
|
sal_Int32 c = lCommandList.getLength();
|
||||||
@@ -230,9 +207,6 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XMLBasedAcceleratorConfiguration::g
|
|||||||
rAny <<= *(lKeys.begin());
|
rAny <<= *(lKeys.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
aReadLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
return lPreferredOnes;
|
return lPreferredOnes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,18 +222,13 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::removeCommandFromAllKeyEvents(co
|
|||||||
static_cast< ::cppu::OWeakObject* >(this),
|
static_cast< ::cppu::OWeakObject* >(this),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aWriteLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache& rCache = impl_getCFG(sal_True); // sal_True => force getting of a writeable cache!
|
AcceleratorCache& rCache = impl_getCFG(sal_True); // sal_True => force getting of a writeable cache!
|
||||||
if (!rCache.hasCommand(sCommand))
|
if (!rCache.hasCommand(sCommand))
|
||||||
throw css::container::NoSuchElementException(
|
throw css::container::NoSuchElementException(
|
||||||
OUString("Command does not exists inside this container."),
|
OUString("Command does not exists inside this container."),
|
||||||
static_cast< ::cppu::OWeakObject* >(this));
|
static_cast< ::cppu::OWeakObject* >(this));
|
||||||
rCache.removeCommand(sCommand);
|
rCache.removeCommand(sCommand);
|
||||||
|
|
||||||
aWriteLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -267,18 +236,17 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::reload()
|
|||||||
throw(css::uno::Exception ,
|
throw(css::uno::Exception ,
|
||||||
css::uno::RuntimeException, std::exception)
|
css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
|
css::uno::Reference< css::io::XStream > xStream;
|
||||||
css::uno::Reference< css::io::XStream > xStreamNoLang;
|
css::uno::Reference< css::io::XStream > xStreamNoLang;
|
||||||
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
||||||
css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
xStreamNoLang = m_aPresetHandler.openPreset(PresetHandler::PRESET_DEFAULT(), sal_True);
|
xStreamNoLang = m_aPresetHandler.openPreset(PresetHandler::PRESET_DEFAULT(), sal_True);
|
||||||
}
|
}
|
||||||
catch(const css::io::IOException&) {} // does not have to exist
|
catch(const css::io::IOException&) {} // does not have to exist
|
||||||
aReadLock.unlock();
|
}
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
css::uno::Reference< css::io::XInputStream > xIn;
|
css::uno::Reference< css::io::XInputStream > xIn;
|
||||||
if (xStream.is())
|
if (xStream.is())
|
||||||
@@ -289,11 +257,10 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::reload()
|
|||||||
static_cast< ::cppu::OWeakObject* >(this));
|
static_cast< ::cppu::OWeakObject* >(this));
|
||||||
|
|
||||||
// impl_ts_load() does not clear the cache
|
// impl_ts_load() does not clear the cache
|
||||||
// SAFE -> ----------------------------------
|
{
|
||||||
Guard aWriteLock(m_aLock);
|
SolarMutexGuard g;
|
||||||
m_aReadCache = AcceleratorCache();
|
m_aReadCache = AcceleratorCache();
|
||||||
aWriteLock.unlock();
|
}
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
impl_ts_load(xIn);
|
impl_ts_load(xIn);
|
||||||
|
|
||||||
@@ -312,11 +279,11 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::store()
|
|||||||
throw(css::uno::Exception ,
|
throw(css::uno::Exception ,
|
||||||
css::uno::RuntimeException, std::exception)
|
css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
css::uno::Reference< css::io::XStream > xStream;
|
||||||
Guard aReadLock(m_aLock);
|
{
|
||||||
css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
SolarMutexGuard g;
|
||||||
aReadLock.unlock();
|
xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
||||||
// <- SAFE ----------------------------------
|
}
|
||||||
|
|
||||||
css::uno::Reference< css::io::XOutputStream > xOut;
|
css::uno::Reference< css::io::XOutputStream > xOut;
|
||||||
if (xStream.is())
|
if (xStream.is())
|
||||||
@@ -363,21 +330,19 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::storeToStorage(const css::uno::R
|
|||||||
::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isModified()
|
::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isModified()
|
||||||
throw(css::uno::RuntimeException, std::exception)
|
throw(css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
return (m_pWriteCache != 0);
|
return (m_pWriteCache != 0);
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isReadOnly()
|
::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isReadOnly()
|
||||||
throw(css::uno::RuntimeException, std::exception)
|
throw(css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
css::uno::Reference< css::io::XStream > xStream;
|
||||||
Guard aReadLock(m_aLock);
|
{
|
||||||
css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
SolarMutexGuard g;
|
||||||
aReadLock.unlock();
|
xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // sal_True => open or create!
|
||||||
// <- SAFE ----------------------------------
|
}
|
||||||
|
|
||||||
css::uno::Reference< css::io::XOutputStream > xOut;
|
css::uno::Reference< css::io::XOutputStream > xOut;
|
||||||
if (xStream.is())
|
if (xStream.is())
|
||||||
@@ -418,11 +383,10 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::removeConfigurationListener(cons
|
|||||||
void SAL_CALL XMLBasedAcceleratorConfiguration::reset()
|
void SAL_CALL XMLBasedAcceleratorConfiguration::reset()
|
||||||
throw(css::uno::RuntimeException, std::exception)
|
throw(css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
{
|
||||||
Guard aWriteLock(m_aLock);
|
SolarMutexGuard g;
|
||||||
m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
|
m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
|
||||||
aWriteLock.unlock();
|
}
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
@@ -451,10 +415,10 @@ void XMLBasedAcceleratorConfiguration::changesOccurred(const OUString& /*sPath*/
|
|||||||
|
|
||||||
void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream)
|
void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
css::uno::Reference< css::uno::XComponentContext > xContext;
|
||||||
Guard aWriteLock(m_aLock);
|
{
|
||||||
|
SolarMutexGuard g;
|
||||||
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
|
xContext = m_xContext;
|
||||||
if (m_pWriteCache)
|
if (m_pWriteCache)
|
||||||
{
|
{
|
||||||
// be aware of reentrance problems - use temp variable for calling delete ... :-)
|
// be aware of reentrance problems - use temp variable for calling delete ... :-)
|
||||||
@@ -462,17 +426,13 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c
|
|||||||
m_pWriteCache = 0;
|
m_pWriteCache = 0;
|
||||||
delete pTemp;
|
delete pTemp;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
aWriteLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
|
css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
|
||||||
if (xSeek.is())
|
if (xSeek.is())
|
||||||
xSeek->seek(0);
|
xSeek->seek(0);
|
||||||
|
|
||||||
// add accelerators to the cache (the cache is not cleared)
|
SolarMutexGuard g;
|
||||||
// SAFE -> ----------------------------------
|
|
||||||
aWriteLock.lock();
|
|
||||||
|
|
||||||
// create the parser queue
|
// create the parser queue
|
||||||
// Note: Use special filter object between parser and reader
|
// Note: Use special filter object between parser and reader
|
||||||
@@ -492,27 +452,23 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c
|
|||||||
|
|
||||||
// TODO think about error handling
|
// TODO think about error handling
|
||||||
xParser->parseStream(aSource);
|
xParser->parseStream(aSource);
|
||||||
|
|
||||||
aWriteLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream)
|
void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
sal_Bool bChanged;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
|
|
||||||
AcceleratorCache aCache;
|
AcceleratorCache aCache;
|
||||||
sal_Bool bChanged = (m_pWriteCache != 0);
|
css::uno::Reference< css::uno::XComponentContext > xContext;
|
||||||
|
{
|
||||||
|
SolarMutexGuard g;
|
||||||
|
bChanged = (m_pWriteCache != 0);
|
||||||
if (bChanged)
|
if (bChanged)
|
||||||
aCache.takeOver(*m_pWriteCache);
|
aCache.takeOver(*m_pWriteCache);
|
||||||
else
|
else
|
||||||
aCache.takeOver(m_aReadCache);
|
aCache.takeOver(m_aReadCache);
|
||||||
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
|
xContext = m_xContext;
|
||||||
|
}
|
||||||
aReadLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
css::uno::Reference< css::io::XTruncate > xClearable(xStream, css::uno::UNO_QUERY_THROW);
|
css::uno::Reference< css::io::XTruncate > xClearable(xStream, css::uno::UNO_QUERY_THROW);
|
||||||
xClearable->truncate();
|
xClearable->truncate();
|
||||||
@@ -531,10 +487,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
|
|||||||
AcceleratorConfigurationWriter aWriter(aCache, xHandler);
|
AcceleratorConfigurationWriter aWriter(aCache, xHandler);
|
||||||
aWriter.flush();
|
aWriter.flush();
|
||||||
|
|
||||||
// take over all changes into the original container
|
SolarMutexGuard g;
|
||||||
// SAFE -> ----------------------------------
|
|
||||||
Guard aWriteLock(m_aLock);
|
|
||||||
|
|
||||||
// take over all changes into the readonly cache ...
|
// take over all changes into the readonly cache ...
|
||||||
// and forget the copy-on-write copied cache
|
// and forget the copy-on-write copied cache
|
||||||
if (bChanged)
|
if (bChanged)
|
||||||
@@ -545,16 +498,12 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
|
|||||||
m_pWriteCache = 0;
|
m_pWriteCache = 0;
|
||||||
delete pTemp;
|
delete pTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
aWriteLock.unlock();
|
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteAccessRequested)
|
AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteAccessRequested)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aWriteLock(m_aLock);
|
|
||||||
|
|
||||||
//create copy of our readonly-cache, if write access is forced ... but
|
//create copy of our readonly-cache, if write access is forced ... but
|
||||||
//not still possible!
|
//not still possible!
|
||||||
@@ -572,7 +521,6 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteA
|
|||||||
return *m_pWriteCache;
|
return *m_pWriteCache;
|
||||||
else
|
else
|
||||||
return m_aReadCache;
|
return m_aReadCache;
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include <xml/acceleratorconfigurationwriter.hxx>
|
#include <xml/acceleratorconfigurationwriter.hxx>
|
||||||
#include <xml/saxnamespacefilter.hxx>
|
#include <xml/saxnamespacefilter.hxx>
|
||||||
|
|
||||||
#include <threadhelp/guard.hxx>
|
|
||||||
#include <acceleratorconst.h>
|
#include <acceleratorconst.h>
|
||||||
|
|
||||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||||
@@ -36,6 +35,7 @@
|
|||||||
#include <comphelper/sequenceashashmap.hxx>
|
#include <comphelper/sequenceashashmap.hxx>
|
||||||
#include <i18nlangtag/languagetag.hxx>
|
#include <i18nlangtag/languagetag.hxx>
|
||||||
#include <rtl/ref.hxx>
|
#include <rtl/ref.hxx>
|
||||||
|
#include <vcl/svapp.hxx>
|
||||||
|
|
||||||
using namespace framework;
|
using namespace framework;
|
||||||
|
|
||||||
@@ -115,8 +115,8 @@ DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(
|
|||||||
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& lArguments)
|
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& lArguments)
|
||||||
: DocumentAcceleratorConfiguration_BASE(xContext)
|
: DocumentAcceleratorConfiguration_BASE(xContext)
|
||||||
{
|
{
|
||||||
Guard aWriteLock(m_aLock);
|
{
|
||||||
|
SolarMutexGuard g;
|
||||||
css::uno::Reference<css::embed::XStorage> xRoot;
|
css::uno::Reference<css::embed::XStorage> xRoot;
|
||||||
if (lArguments.getLength() == 1 && (lArguments[0] >>= xRoot))
|
if (lArguments.getLength() == 1 && (lArguments[0] >>= xRoot))
|
||||||
{
|
{
|
||||||
@@ -129,8 +129,7 @@ DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(
|
|||||||
OUString("DocumentRoot"),
|
OUString("DocumentRoot"),
|
||||||
css::uno::Reference< css::embed::XStorage >());
|
css::uno::Reference< css::embed::XStorage >());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
aWriteLock.unlock();
|
|
||||||
|
|
||||||
impl_ts_fillCache();
|
impl_ts_fillCache();
|
||||||
}
|
}
|
||||||
@@ -147,12 +146,12 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer
|
|||||||
{
|
{
|
||||||
// Attention! xStorage must be accepted too, if it's NULL !
|
// Attention! xStorage must be accepted too, if it's NULL !
|
||||||
|
|
||||||
// SAFE -> ----------------------------------
|
sal_Bool bForgetOldStorages;
|
||||||
Guard aWriteLock(m_aLock);
|
{
|
||||||
sal_Bool bForgetOldStorages = m_xDocumentRoot.is();
|
SolarMutexGuard g;
|
||||||
|
bForgetOldStorages = m_xDocumentRoot.is();
|
||||||
m_xDocumentRoot = xStorage;
|
m_xDocumentRoot = xStorage;
|
||||||
aWriteLock.unlock();
|
}
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
|
|
||||||
if (bForgetOldStorages)
|
if (bForgetOldStorages)
|
||||||
impl_ts_clearCache();
|
impl_ts_clearCache();
|
||||||
@@ -165,20 +164,18 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer
|
|||||||
sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
|
sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
|
||||||
throw(css::uno::RuntimeException, std::exception)
|
throw(css::uno::RuntimeException, std::exception)
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
SolarMutexGuard g;
|
||||||
Guard aReadLock(m_aLock);
|
|
||||||
return m_xDocumentRoot.is();
|
return m_xDocumentRoot.is();
|
||||||
// <- SAFE ----------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DocumentAcceleratorConfiguration::impl_ts_fillCache()
|
void DocumentAcceleratorConfiguration::impl_ts_fillCache()
|
||||||
{
|
{
|
||||||
// SAFE -> ----------------------------------
|
css::uno::Reference< css::embed::XStorage > xDocumentRoot;
|
||||||
Guard aReadLock(m_aLock);
|
{
|
||||||
css::uno::Reference< css::embed::XStorage > xDocumentRoot = m_xDocumentRoot;
|
SolarMutexGuard g;
|
||||||
aReadLock.unlock();
|
xDocumentRoot = m_xDocumentRoot;
|
||||||
// <- SAFE ----------------------------------
|
}
|
||||||
|
|
||||||
// Sometimes we must live without a document root.
|
// Sometimes we must live without a document root.
|
||||||
// E.g. if the document is readonly ...
|
// E.g. if the document is readonly ...
|
||||||
|
@@ -69,8 +69,7 @@ typedef PresetHandler AcceleratorPresets;
|
|||||||
/**
|
/**
|
||||||
implements a read/write access to the accelerator configuration.
|
implements a read/write access to the accelerator configuration.
|
||||||
*/
|
*/
|
||||||
class XMLBasedAcceleratorConfiguration : protected ThreadHelpBase, // attention! Must be the first base class to guarentee right initialize lock ...
|
class XMLBasedAcceleratorConfiguration : public IStorageListener,
|
||||||
public IStorageListener,
|
|
||||||
public ::cppu::WeakImplHelper2<
|
public ::cppu::WeakImplHelper2<
|
||||||
css::form::XReset, // TODO use XPresetHandler instead if available
|
css::form::XReset, // TODO use XPresetHandler instead if available
|
||||||
css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence
|
css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence
|
||||||
|
Reference in New Issue
Block a user