summaryrefslogtreecommitdiff
path: root/framework/source
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source')
-rw-r--r--framework/source/accelerators/acceleratorcache.cxx31
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx108
-rw-r--r--framework/source/accelerators/documentacceleratorconfiguration.cxx8
-rw-r--r--framework/source/accelerators/globalacceleratorconfiguration.cxx20
-rw-r--r--framework/source/accelerators/keymapping.cxx20
-rw-r--r--framework/source/accelerators/moduleacceleratorconfiguration.cxx4
-rw-r--r--framework/source/accelerators/presethandler.cxx66
-rw-r--r--framework/source/accelerators/storageholder.cxx45
-rw-r--r--framework/source/classes/taskcreator.cxx43
-rw-r--r--framework/source/dispatch/closedispatcher.cxx48
-rw-r--r--framework/source/dispatch/dispatchdisabler.cxx8
-rw-r--r--framework/source/dispatch/dispatchinformationprovider.cxx16
-rw-r--r--framework/source/dispatch/dispatchprovider.cxx77
-rw-r--r--framework/source/dispatch/interceptionhelper.cxx34
-rw-r--r--framework/source/dispatch/isstartmoduledispatch.hxx5
-rw-r--r--framework/source/dispatch/loaddispatcher.cxx5
-rw-r--r--framework/source/dispatch/mailtodispatcher.cxx12
-rw-r--r--framework/source/dispatch/oxt_handler.cxx14
-rw-r--r--framework/source/dispatch/popupmenudispatcher.cxx106
-rw-r--r--framework/source/dispatch/servicehandler.cxx19
-rw-r--r--framework/source/dispatch/startmoduledispatcher.cxx5
-rw-r--r--framework/source/dispatch/systemexec.cxx15
-rw-r--r--framework/source/dispatch/windowcommanddispatch.cxx18
-rw-r--r--framework/source/fwe/classes/actiontriggercontainer.cxx15
-rw-r--r--framework/source/fwe/classes/actiontriggerpropertyset.cxx8
-rw-r--r--framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx6
-rw-r--r--framework/source/fwe/classes/addonmenu.cxx17
-rw-r--r--framework/source/fwe/classes/addonsoptions.cxx588
-rw-r--r--framework/source/fwe/classes/framelistanalyzer.cxx2
-rw-r--r--framework/source/fwe/classes/fwkresid.cxx3
-rw-r--r--framework/source/fwe/classes/imagewrapper.cxx91
-rw-r--r--framework/source/fwe/classes/rootactiontriggercontainer.cxx60
-rw-r--r--framework/source/fwe/classes/sfxhelperfunctions.cxx13
-rw-r--r--framework/source/fwe/dispatch/interaction.cxx12
-rw-r--r--framework/source/fwe/helper/actiontriggerhelper.cxx113
-rw-r--r--framework/source/fwe/helper/documentundoguard.cxx70
-rw-r--r--framework/source/fwe/helper/propertysetcontainer.cxx20
-rw-r--r--framework/source/fwe/helper/titlehelper.cxx237
-rw-r--r--framework/source/fwe/helper/undomanagerhelper.cxx163
-rw-r--r--framework/source/fwe/xml/menuconfiguration.cxx9
-rw-r--r--framework/source/fwe/xml/menudocumenthandler.cxx127
-rw-r--r--framework/source/fwe/xml/saxnamespacefilter.cxx10
-rw-r--r--framework/source/fwe/xml/statusbarconfiguration.cxx1
-rw-r--r--framework/source/fwe/xml/statusbardocumenthandler.cxx122
-rw-r--r--framework/source/fwe/xml/toolboxconfiguration.cxx1
-rw-r--r--framework/source/fwe/xml/toolboxdocumenthandler.cxx136
-rw-r--r--framework/source/fwi/classes/converter.cxx16
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx39
-rw-r--r--framework/source/fwi/helper/mischelper.cxx6
-rw-r--r--framework/source/fwi/jobs/configaccess.cxx27
-rw-r--r--framework/source/fwi/threadhelp/transactionmanager.cxx8
-rw-r--r--framework/source/fwi/uielement/constitemcontainer.cxx53
-rw-r--r--framework/source/fwi/uielement/itemcontainer.cxx27
-rw-r--r--framework/source/fwi/uielement/rootitemcontainer.cxx37
-rw-r--r--framework/source/helper/dockingareadefaultacceptor.cxx50
-rw-r--r--framework/source/helper/ocomponentaccess.cxx9
-rw-r--r--framework/source/helper/ocomponentenumeration.cxx5
-rw-r--r--framework/source/helper/oframes.cxx11
-rw-r--r--framework/source/helper/persistentwindowstate.cxx21
-rw-r--r--framework/source/helper/statusindicator.cxx2
-rw-r--r--framework/source/helper/statusindicatorfactory.cxx233
-rw-r--r--framework/source/helper/tagwindowasmodified.cxx96
-rw-r--r--framework/source/helper/titlebarupdate.cxx13
-rw-r--r--framework/source/helper/uiconfigelementwrapperbase.cxx40
-rw-r--r--framework/source/helper/uielementwrapperbase.cxx6
-rw-r--r--framework/source/helper/vclstatusindicator.cxx7
-rw-r--r--framework/source/helper/wakeupthread.cxx14
-rw-r--r--framework/source/inc/accelerators/acceleratorcache.hxx25
-rw-r--r--framework/source/inc/accelerators/acceleratorconfiguration.hxx17
-rw-r--r--framework/source/inc/accelerators/keymapping.hxx7
-rw-r--r--framework/source/inc/accelerators/presethandler.hxx19
-rw-r--r--framework/source/inc/accelerators/storageholder.hxx10
-rw-r--r--framework/source/inc/dispatch/dispatchdisabler.hxx7
-rw-r--r--framework/source/inc/dispatch/loaddispatcher.hxx9
-rw-r--r--framework/source/inc/dispatch/windowcommanddispatch.hxx12
-rw-r--r--framework/source/inc/loadenv/actionlockguard.hxx17
-rw-r--r--framework/source/inc/loadenv/loadenv.hxx22
-rw-r--r--framework/source/inc/loadenv/loadenvexception.hxx12
-rw-r--r--framework/source/inc/loadenv/targethelper.hxx7
-rw-r--r--framework/source/inc/pattern/frame.hxx5
-rw-r--r--framework/source/inc/pattern/window.hxx5
-rw-r--r--framework/source/interaction/quietinteraction.cxx3
-rw-r--r--framework/source/jobs/helponstartup.cxx29
-rw-r--r--framework/source/jobs/job.cxx106
-rw-r--r--framework/source/jobs/jobdata.cxx62
-rw-r--r--framework/source/jobs/jobdispatch.cxx35
-rw-r--r--framework/source/jobs/jobexecutor.cxx163
-rw-r--r--framework/source/jobs/jobresult.cxx19
-rw-r--r--framework/source/jobs/joburl.cxx24
-rw-r--r--framework/source/jobs/shelljob.cxx9
-rw-r--r--framework/source/layoutmanager/helpers.cxx52
-rw-r--r--framework/source/layoutmanager/helpers.hxx20
-rw-r--r--framework/source/layoutmanager/layoutmanager.cxx482
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.cxx526
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.hxx33
-rw-r--r--framework/source/loadenv/loadenv.cxx258
-rw-r--r--framework/source/loadenv/targethelper.cxx6
-rw-r--r--framework/source/recording/dispatchrecorder.cxx55
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx59
-rw-r--r--framework/source/services/autorecovery.cxx597
-rw-r--r--framework/source/services/desktop.cxx126
-rw-r--r--framework/source/services/dispatchhelper.cxx40
-rw-r--r--framework/source/services/frame.cxx179
-rw-r--r--framework/source/services/mediatypedetectionhelper.cxx3
-rw-r--r--framework/source/services/modulemanager.cxx57
-rw-r--r--framework/source/services/pathsettings.cxx171
-rw-r--r--framework/source/services/sessionlistener.cxx20
-rw-r--r--framework/source/services/substitutepathvars.cxx68
-rw-r--r--framework/source/services/taskcreatorsrv.cxx76
-rw-r--r--framework/source/services/urltransformer.cxx71
-rw-r--r--framework/source/uiconfiguration/CommandImageResolver.cxx2
-rw-r--r--framework/source/uiconfiguration/CommandImageResolver.hxx7
-rw-r--r--framework/source/uiconfiguration/ImageList.cxx4
-rw-r--r--framework/source/uiconfiguration/ImageList.hxx7
-rw-r--r--framework/source/uiconfiguration/globalsettings.cxx82
-rw-r--r--framework/source/uiconfiguration/graphicnameaccess.cxx2
-rw-r--r--framework/source/uiconfiguration/imagemanager.cxx8
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.cxx269
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.hxx22
-rw-r--r--framework/source/uiconfiguration/moduleimagemanager.cxx155
-rw-r--r--framework/source/uiconfiguration/moduleuicfgsupplier.cxx46
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx208
-rw-r--r--framework/source/uiconfiguration/uicategorydescription.cxx39
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx204
-rw-r--r--framework/source/uiconfiguration/windowstateconfiguration.cxx142
-rw-r--r--framework/source/uielement/FixedImageToolbarController.cxx13
-rw-r--r--framework/source/uielement/FixedTextToolbarController.cxx13
-rw-r--r--framework/source/uielement/addonstoolbarwrapper.cxx29
-rw-r--r--framework/source/uielement/buttontoolbarcontroller.cxx37
-rw-r--r--framework/source/uielement/comboboxtoolbarcontroller.cxx16
-rw-r--r--framework/source/uielement/complextoolbarcontroller.cxx20
-rw-r--r--framework/source/uielement/controlmenucontroller.cxx228
-rw-r--r--framework/source/uielement/dropdownboxtoolbarcontroller.cxx17
-rw-r--r--framework/source/uielement/edittoolbarcontroller.cxx15
-rw-r--r--framework/source/uielement/fontmenucontroller.cxx44
-rw-r--r--framework/source/uielement/fontsizemenucontroller.cxx119
-rw-r--r--framework/source/uielement/footermenucontroller.cxx5
-rw-r--r--framework/source/uielement/genericstatusbarcontroller.cxx4
-rw-r--r--framework/source/uielement/generictoolbarcontroller.cxx155
-rw-r--r--framework/source/uielement/headermenucontroller.cxx57
-rw-r--r--framework/source/uielement/imagebuttontoolbarcontroller.cxx46
-rw-r--r--framework/source/uielement/langselectionmenucontroller.cxx64
-rw-r--r--framework/source/uielement/langselectionstatusbarcontroller.cxx18
-rw-r--r--framework/source/uielement/macrosmenucontroller.cxx44
-rw-r--r--framework/source/uielement/menubarmanager.cxx494
-rw-r--r--framework/source/uielement/menubarmerger.cxx19
-rw-r--r--framework/source/uielement/menubarwrapper.cxx98
-rw-r--r--framework/source/uielement/newmenucontroller.cxx138
-rw-r--r--framework/source/uielement/objectmenucontroller.cxx27
-rw-r--r--framework/source/uielement/popuptoolbarcontroller.cxx78
-rw-r--r--framework/source/uielement/progressbarwrapper.cxx13
-rw-r--r--framework/source/uielement/recentfilesmenucontroller.cxx237
-rw-r--r--framework/source/uielement/resourcemenucontroller.cxx114
-rw-r--r--framework/source/uielement/spinfieldtoolbarcontroller.cxx38
-rw-r--r--framework/source/uielement/statusbaritem.cxx15
-rw-r--r--framework/source/uielement/statusbarmanager.cxx92
-rw-r--r--framework/source/uielement/statusbarmerger.cxx7
-rw-r--r--framework/source/uielement/statusbarwrapper.cxx35
-rw-r--r--framework/source/uielement/statusindicatorinterfacewrapper.cxx1
-rw-r--r--framework/source/uielement/styletoolbarcontroller.cxx23
-rw-r--r--framework/source/uielement/subtoolbarcontroller.cxx152
-rw-r--r--framework/source/uielement/thesaurusmenucontroller.cxx46
-rw-r--r--framework/source/uielement/togglebuttontoolbarcontroller.cxx21
-rw-r--r--framework/source/uielement/toolbarmanager.cxx1125
-rw-r--r--framework/source/uielement/toolbarmerger.cxx44
-rw-r--r--framework/source/uielement/toolbarmodemenucontroller.cxx49
-rw-r--r--framework/source/uielement/toolbarsmenucontroller.cxx150
-rw-r--r--framework/source/uielement/toolbarwrapper.cxx188
-rw-r--r--framework/source/uielement/uicommanddescription.cxx142
-rw-r--r--framework/source/uifactory/addonstoolbarfactory.cxx32
-rw-r--r--framework/source/uifactory/factoryconfiguration.cxx65
-rw-r--r--framework/source/uifactory/menubarfactory.cxx12
-rw-r--r--framework/source/uifactory/statusbarfactory.cxx5
-rw-r--r--framework/source/uifactory/toolbarfactory.cxx4
-rw-r--r--framework/source/uifactory/uicontrollerfactory.cxx101
-rw-r--r--framework/source/uifactory/uielementfactorymanager.cxx197
-rw-r--r--framework/source/uifactory/windowcontentfactorymanager.cxx63
-rw-r--r--framework/source/xml/acceleratorconfigurationreader.cxx16
-rw-r--r--framework/source/xml/acceleratorconfigurationwriter.cxx34
-rw-r--r--framework/source/xml/imagesdocumenthandler.cxx66
180 files changed, 6195 insertions, 6681 deletions
diff --git a/framework/source/accelerators/acceleratorcache.cxx b/framework/source/accelerators/acceleratorcache.cxx
index 98596a895036..c0b819a2a9e8 100644
--- a/framework/source/accelerators/acceleratorcache.cxx
+++ b/framework/source/accelerators/acceleratorcache.cxx
@@ -27,19 +27,16 @@ namespace framework
{
bool AcceleratorCache::hasKey(const css::awt::KeyEvent& aKey) const
{
- SolarMutexGuard g;
return (m_lKey2Commands.find(aKey) != m_lKey2Commands.end());
}
bool AcceleratorCache::hasCommand(const OUString& sCommand) const
{
- SolarMutexGuard g;
return (m_lCommand2Keys.find(sCommand) != m_lCommand2Keys.end());
}
AcceleratorCache::TKeyList AcceleratorCache::getAllKeys() const
{
- SolarMutexGuard g;
TKeyList lKeys;
lKeys.reserve(m_lKey2Commands.size());
@@ -53,8 +50,6 @@ AcceleratorCache::TKeyList AcceleratorCache::getAllKeys() const
void AcceleratorCache::setKeyCommandPair(const css::awt::KeyEvent& aKey, const OUString& sCommand)
{
- SolarMutexGuard g;
-
// register command for the specified key
m_lKey2Commands[aKey] = sCommand;
@@ -65,7 +60,6 @@ void AcceleratorCache::setKeyCommandPair(const css::awt::KeyEvent& aKey, const O
AcceleratorCache::TKeyList AcceleratorCache::getKeysByCommand(const OUString& sCommand) const
{
- SolarMutexGuard g;
TCommand2Keys::const_iterator pCommand = m_lCommand2Keys.find(sCommand);
if (pCommand == m_lCommand2Keys.end())
throw css::container::NoSuchElementException();
@@ -74,7 +68,6 @@ AcceleratorCache::TKeyList AcceleratorCache::getKeysByCommand(const OUString& sC
OUString AcceleratorCache::getCommandByKey(const css::awt::KeyEvent& aKey) const
{
- SolarMutexGuard g;
TKey2Commands::const_iterator pKey = m_lKey2Commands.find(aKey);
if (pKey == m_lKey2Commands.end())
throw css::container::NoSuchElementException();
@@ -83,8 +76,6 @@ OUString AcceleratorCache::getCommandByKey(const css::awt::KeyEvent& aKey) const
void AcceleratorCache::removeKey(const css::awt::KeyEvent& aKey)
{
- SolarMutexGuard g;
-
// check if key exists
TKey2Commands::const_iterator pKey = m_lKey2Commands.find(aKey);
if (pKey == m_lKey2Commands.end())
@@ -99,20 +90,32 @@ void AcceleratorCache::removeKey(const css::awt::KeyEvent& aKey)
// remove key from primary list
m_lKey2Commands.erase(aKey);
- // remove key from optimized command list
- m_lCommand2Keys.erase(sCommand);
+ // get keylist for that command
+ TCommand2Keys::iterator pCommand = m_lCommand2Keys.find(sCommand);
+ if (pCommand == m_lCommand2Keys.end())
+ return;
+ TKeyList& lKeys = pCommand->second;
+
+ // one or more keys assign
+ if (lKeys.size() == 1)
+ // remove key from optimized command list
+ m_lCommand2Keys.erase(sCommand);
+ else // only remove this key from the keylist
+ {
+ auto pKeys = ::std::find(lKeys.begin(), lKeys.end(), aKey);
+
+ if (pKeys != lKeys.end())
+ lKeys.erase(pKeys);
+ }
}
void AcceleratorCache::removeCommand(const OUString& sCommand)
{
- SolarMutexGuard g;
-
const TKeyList& lKeys = getKeysByCommand(sCommand);
for (auto const& lKey : lKeys)
{
removeKey(lKey);
}
- m_lCommand2Keys.erase(sCommand);
}
} // namespace framework
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 85edc3833025..4f34dfc0141b 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -51,19 +51,23 @@
#include <svtools/acceleratorexecute.hxx>
#include <sal/log.hxx>
#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
-#define PRESET_DEFAULT u"default"
-#define TARGET_CURRENT "current"
+constexpr OUString PRESET_DEFAULT = u"default"_ustr;
+constexpr OUString TARGET_CURRENT = u"current"_ustr;
namespace framework
{
- constexpr OUStringLiteral CFG_ENTRY_SECONDARY = u"SecondaryKeys";
- constexpr OUStringLiteral CFG_PROP_COMMAND = u"Command";
+ constexpr OUString CFG_ENTRY_SECONDARY = u"SecondaryKeys"_ustr;
+ constexpr OUString CFG_PROP_COMMAND = u"Command"_ustr;
static OUString lcl_getKeyString(const css::awt::KeyEvent& aKeyEvent)
{
const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of an identifier...
- OUStringBuffer sKeyBuffer((KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex));
+ OUString sKey(KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode));
+ if (sKey.getLength() < nBeginIndex) // dead key
+ return OUString();
+ OUStringBuffer sKeyBuffer(sKey.subView(nBeginIndex));
if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT )
sKeyBuffer.append("_SHIFT");
@@ -171,6 +175,7 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XMLBasedAcceleratorConfiguration::g
css::uno::Sequence< css::uno::Any > lPreferredOnes (c); // don't pack list!
AcceleratorCache& rCache = impl_getCFG();
+ auto lPreferredOnesRange = asNonConstRange(lPreferredOnes);
for (i=0; i<c; ++i)
{
const OUString& rCommand = lCommandList[i];
@@ -187,7 +192,7 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XMLBasedAcceleratorConfiguration::g
if ( lKeys.empty() )
continue;
- css::uno::Any& rAny = lPreferredOnes[i];
+ css::uno::Any& rAny = lPreferredOnesRange[i];
rAny <<= *(lKeys.begin());
}
@@ -217,7 +222,7 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::reload()
css::uno::Reference< css::io::XStream > xStreamNoLang;
{
SolarMutexGuard g;
- xStream = m_aPresetHandler.openTarget(u"" TARGET_CURRENT,
+ xStream = m_aPresetHandler.openTarget(TARGET_CURRENT,
css::embed::ElementModes::READ);
try
{
@@ -257,7 +262,7 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::store()
css::uno::Reference< css::io::XStream > xStream;
{
SolarMutexGuard g;
- xStream = m_aPresetHandler.openTarget(u"" TARGET_CURRENT,
+ xStream = m_aPresetHandler.openTarget(TARGET_CURRENT,
css::embed::ElementModes::READWRITE); // open or create!
}
@@ -308,7 +313,7 @@ sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isReadOnly()
css::uno::Reference< css::io::XStream > xStream;
{
SolarMutexGuard g;
- xStream = m_aPresetHandler.openTarget(u"" TARGET_CURRENT,
+ xStream = m_aPresetHandler.openTarget(TARGET_CURRENT,
css::embed::ElementModes::READWRITE); // open or create!
}
@@ -343,7 +348,7 @@ void SAL_CALL XMLBasedAcceleratorConfiguration::reset()
{
{
SolarMutexGuard g;
- m_aPresetHandler.copyPresetToTarget(PRESET_DEFAULT, u"" TARGET_CURRENT);
+ m_aPresetHandler.copyPresetToTarget(PRESET_DEFAULT, TARGET_CURRENT);
}
reload();
@@ -384,14 +389,12 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c
// Note: Use special filter object between parser and reader
// to get filtered xml with right namespaces ...
// Use further a temp cache for reading!
- AcceleratorConfigurationReader* pReader = new AcceleratorConfigurationReader(m_aReadCache);
- css::uno::Reference< css::xml::sax::XDocumentHandler > xReader (static_cast< ::cppu::OWeakObject* >(pReader), css::uno::UNO_QUERY_THROW);
- SaxNamespaceFilter* pFilter = new SaxNamespaceFilter(xReader);
- css::uno::Reference< css::xml::sax::XDocumentHandler > xFilter (static_cast< ::cppu::OWeakObject* >(pFilter), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<AcceleratorConfigurationReader> pReader = new AcceleratorConfigurationReader(m_aReadCache);
+ rtl::Reference<SaxNamespaceFilter> pFilter = new SaxNamespaceFilter(pReader);
// connect parser, filter and stream
css::uno::Reference< css::xml::sax::XParser > xParser = css::xml::sax::Parser::create(xContext);
- xParser->setDocumentHandler(xFilter);
+ xParser->setDocumentHandler(pFilter);
css::xml::sax::InputSource aSource;
aSource.aInputStream = xStream;
@@ -461,7 +464,8 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(bool bWriteAcces
return m_aReadCache;
}
-OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
+// static
+OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale()
{
OUString sISOLocale = officecfg::Setup::L10N::ooLocale::get();
@@ -476,8 +480,8 @@ OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
*
*******************************************************************************/
-XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext )
+XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
{
m_xCfg.set(
::comphelper::ConfigurationHelper::openConfig( m_xContext, "org.openoffice.Office.Accelerators", ::comphelper::EConfigurationModes::AllLocales ),
@@ -614,10 +618,9 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::removeKeyEvent(const css::awt::K
if (rPrimaryCache.hasKey(aKeyEvent))
{
- OUString sDelCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
- if (!sDelCommand.isEmpty())
+ OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
+ if (!sOriginalCommand.isEmpty())
{
- OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
if (rSecondaryCache.hasCommand(sOriginalCommand))
{
AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sOriginalCommand);
@@ -679,6 +682,7 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XCUBasedAcceleratorConfiguration::g
css::uno::Sequence< css::uno::Any > lPreferredOnes (c); // don't pack list!
AcceleratorCache& rCache = impl_getCFG(true);
+ auto lPreferredOnesRange = asNonConstRange(lPreferredOnes);
for (i=0; i<c; ++i)
{
const OUString& rCommand = lCommandList[i];
@@ -698,7 +702,7 @@ css::uno::Sequence< css::uno::Any > SAL_CALL XCUBasedAcceleratorConfiguration::g
AcceleratorCache::TKeyList::const_iterator pPreferredKey = lcl_getPreferredKey(lKeys);
if (pPreferredKey != lKeys.end ())
{
- css::uno::Any& rAny = lPreferredOnes[i];
+ css::uno::Any& rAny = lPreferredOnesRange[i];
rAny <<= *pPreferredKey;
}
}
@@ -959,7 +963,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
}
const OUString sIsoLang = impl_ts_getLocale();
- const OUString sDefaultLocale("en-US");
+ static constexpr OUStringLiteral sDefaultLocale(u"en-US");
css::uno::Reference< css::container::XNameAccess > xKey;
css::uno::Reference< css::container::XNameAccess > xCommand;
@@ -973,12 +977,8 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
xAccess->getByName(sKey) >>= xKey;
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
- css::uno::Sequence< OUString > lLocales = xCommand->getElementNames();
- sal_Int32 nLocales = lLocales.getLength();
- ::std::vector< OUString > aLocales;
- aLocales.reserve(nLocales);
- for (sal_Int32 j = 0; j < nLocales; ++j)
- aLocales.push_back(lLocales[j]);
+ const css::uno::Sequence< OUString > lLocales = xCommand->getElementNames();
+ ::std::vector< OUString > aLocales { lLocales.begin(), lLocales.end() };
OUString sLocale;
for (auto const& locale : aLocales)
@@ -1013,32 +1013,31 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
css::awt::KeyEvent aKeyEvent;
sal_Int32 nIndex = 0;
- OUString sKeyCommand = sKey.getToken(0, '_', nIndex);
- aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode("KEY_" + sKeyCommand);
+ std::u16string_view sKeyCommand = o3tl::getToken(sKey, 0, '_', nIndex);
+ aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(OUString::Concat("KEY_") + sKeyCommand);
- css::uno::Sequence< OUString > sToken(4);
const sal_Int32 nToken = 4;
bool bValid = true;
sal_Int32 k;
- for (k=0; k<nToken; ++k)
+ for (k = 0; k < nToken; ++k)
{
if (nIndex < 0)
break;
- sToken[k] = sKey.getToken(0, '_', nIndex);
- if (sToken[k].isEmpty())
+ std::u16string_view sToken = o3tl::getToken(sKey, 0, '_', nIndex);
+ if (sToken.empty())
{
bValid = false;
break;
}
- if ( sToken[k] == "SHIFT" )
+ if ( sToken == u"SHIFT" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
- else if ( sToken[k] == "MOD1" )
+ else if ( sToken == u"MOD1" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
- else if ( sToken[k] == "MOD2" )
+ else if ( sToken == u"MOD2" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
- else if ( sToken[k] == "MOD3" )
+ else if ( sToken == u"MOD3" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3;
else
{
@@ -1157,7 +1156,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
{
xFac.set(xModules, css::uno::UNO_QUERY);
xInst = xFac->createInstance();
- xModules->insertByName(m_sModuleCFG, css::uno::makeAny(xInst));
+ xModules->insertByName(m_sModuleCFG, css::uno::Any(xInst));
}
xModules->getByName(m_sModuleCFG) >>= xContainer;
}
@@ -1169,16 +1168,16 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
{
xFac.set(xContainer, css::uno::UNO_QUERY);
xInst = xFac->createInstance();
- xContainer->insertByName(sKey, css::uno::makeAny(xInst));
+ xContainer->insertByName(sKey, css::uno::Any(xInst));
}
xContainer->getByName(sKey) >>= xKey;
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
OUString sLocale = impl_ts_getLocale();
if ( !xCommand->hasByName(sLocale) )
- xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
+ xCommand->insertByName(sLocale, css::uno::Any(sCommand));
else
- xCommand->replaceByName(sLocale, css::uno::makeAny(sCommand));
+ xCommand->replaceByName(sLocale, css::uno::Any(sCommand));
}
void XCUBasedAcceleratorConfiguration::removeKeyFromConfiguration( const css::awt::KeyEvent& aKeyEvent, const bool bPreferred )
@@ -1224,27 +1223,25 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySe
}
css::awt::KeyEvent aKeyEvent;
- OUString sKeyIdentifier;
sal_Int32 nIndex = 0;
- sKeyIdentifier = sKey.getToken(0, '_', nIndex);
- aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode("KEY_"+sKeyIdentifier);
+ std::u16string_view sKeyIdentifier = o3tl::getToken(sKey, 0, '_', nIndex);
+ aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(OUString::Concat("KEY_") + sKeyIdentifier);
- css::uno::Sequence< OUString > sToken(3);
- const sal_Int32 nToken = 3;
- for (sal_Int32 i=0; i<nToken; ++i)
+ const int nToken = 4;
+ for (sal_Int32 i = 0; i < nToken; ++i)
{
if ( nIndex < 0 )
break;
- sToken[i] = sKey.getToken(0, '_', nIndex);
- if ( sToken[i] == "SHIFT" )
+ std::u16string_view sToken = o3tl::getToken(sKey, 0, '_', nIndex);
+ if ( sToken == u"SHIFT" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
- else if ( sToken[i] == "MOD1" )
+ else if ( sToken == u"MOD1" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
- else if ( sToken[i] == "MOD2" )
+ else if ( sToken == u"MOD2" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
- else if ( sToken[i] == "MOD3" )
+ else if ( sToken == u"MOD3" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3;
}
@@ -1315,7 +1312,8 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred,
}
}
-OUString XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
+// static
+OUString XCUBasedAcceleratorConfiguration::impl_ts_getLocale()
{
OUString sISOLocale = officecfg::Setup::L10N::ooLocale::get();
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx
index 33f4e877a534..c86895f0de32 100644
--- a/framework/source/accelerators/documentacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx
@@ -30,7 +30,7 @@
using namespace framework;
-#define RESOURCETYPE_ACCELERATOR "accelerator"
+constexpr OUStringLiteral RESOURCETYPE_ACCELERATOR = u"accelerator";
namespace {
@@ -167,7 +167,7 @@ void DocumentAcceleratorConfiguration::fillCache()
m_aPresetHandler.connectToResource(
PresetHandler::E_DOCUMENT,
RESOURCETYPE_ACCELERATOR,
- OUString(),
+ u"",
xDocumentRoot,
aLanguageTag);
@@ -185,8 +185,8 @@ com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &arguments)
{
- DocumentAcceleratorConfiguration *inst = new DocumentAcceleratorConfiguration(context, arguments);
- css::uno::XInterface *acquired_inst = cppu::acquire(inst);
+ rtl::Reference<DocumentAcceleratorConfiguration> inst = new DocumentAcceleratorConfiguration(context, arguments);
+ css::uno::XInterface *acquired_inst = cppu::acquire(inst.get());
inst->fillCache();
diff --git a/framework/source/accelerators/globalacceleratorconfiguration.cxx b/framework/source/accelerators/globalacceleratorconfiguration.cxx
index 359fbcd5be42..e54a05a03be3 100644
--- a/framework/source/accelerators/globalacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/globalacceleratorconfiguration.cxx
@@ -109,22 +109,6 @@ void GlobalAcceleratorConfiguration::fillCache()
{}
}
-struct Instance
-{
- explicit Instance(css::uno::Reference<css::uno::XComponentContext> const & context)
- : instance(new GlobalAcceleratorConfiguration(context))
- {
- instance->fillCache();
- }
-
- rtl::Reference<GlobalAcceleratorConfiguration> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -132,7 +116,9 @@ com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject*>(Singleton::get(context).instance.get()));
+ rtl::Reference<GlobalAcceleratorConfiguration> xGAC = new GlobalAcceleratorConfiguration(context);
+ xGAC->fillCache();
+ return cppu::acquire(xGAC.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/accelerators/keymapping.cxx b/framework/source/accelerators/keymapping.cxx
index 5f78d6dd65b0..be0c4c27f291 100644
--- a/framework/source/accelerators/keymapping.cxx
+++ b/framework/source/accelerators/keymapping.cxx
@@ -21,7 +21,7 @@
#include <com/sun/star/awt/Key.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <rtl/instance.hxx>
+#include <o3tl/string_view.hxx>
namespace framework
{
@@ -136,6 +136,9 @@ KeyMapping::KeyIdentifierInfo const KeyMapping::KeyIdentifierMap[] =
{css::awt::Key::BRACKETRIGHT , "KEY_BRACKETRIGHT" },
{css::awt::Key::SEMICOLON , "KEY_SEMICOLON" },
{css::awt::Key::QUOTERIGHT , "KEY_QUOTERIGHT" },
+ {css::awt::Key::RIGHTCURLYBRACKET, "KEY_RIGHTCURLYBRACKET" },
+ {css::awt::Key::NUMBERSIGN, "KEY_NUMBERSIGN" },
+ {css::awt::Key::COLON , "KEY_COLON" },
{0 , "" } // mark the end of this array!
};
@@ -154,14 +157,9 @@ KeyMapping::KeyMapping()
}
}
-namespace {
-
-struct Instance: public rtl::Static<KeyMapping, Instance> {};
-
-}
-
KeyMapping & KeyMapping::get() {
- return Instance::get();
+ static KeyMapping KEYS;
+ return KEYS;
}
sal_uInt16 KeyMapping::mapIdentifierToCode(const OUString& sIdentifier)
@@ -192,10 +190,10 @@ OUString KeyMapping::mapCodeToIdentifier(sal_uInt16 nCode)
return OUString::number(nCode);
}
-bool KeyMapping::impl_st_interpretIdentifierAsPureKeyCode(const OUString& sIdentifier,
+bool KeyMapping::impl_st_interpretIdentifierAsPureKeyCode(std::u16string_view sIdentifier,
sal_uInt16& rCode )
{
- sal_Int32 nCode = sIdentifier.toInt32();
+ sal_Int32 nCode = o3tl::toInt32(sIdentifier);
if (nCode > 0)
{
rCode = static_cast<sal_uInt16>(nCode);
@@ -205,7 +203,7 @@ bool KeyMapping::impl_st_interpretIdentifierAsPureKeyCode(const OUString& sIdent
// 0 is normally an error of the called method toInt32() ...
// But we must be aware, that the identifier is "0"!
rCode = 0;
- return sIdentifier == "0";
+ return sIdentifier == u"0";
}
} // namespace framework
diff --git a/framework/source/accelerators/moduleacceleratorconfiguration.cxx b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
index 71f33bc5b0ab..c8ce39fec495 100644
--- a/framework/source/accelerators/moduleacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
@@ -146,8 +146,8 @@ com_sun_star_comp_framework_ModuleAcceleratorConfiguration_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &arguments)
{
- ModuleAcceleratorConfiguration *inst = new ModuleAcceleratorConfiguration(context, arguments);
- css::uno::XInterface *acquired_inst = cppu::acquire(inst);
+ rtl::Reference<ModuleAcceleratorConfiguration> inst = new ModuleAcceleratorConfiguration(context, arguments);
+ css::uno::XInterface *acquired_inst = cppu::acquire(inst.get());
inst->fillCache();
diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx
index bce2e3861499..f1879af97f70 100644
--- a/framework/source/accelerators/presethandler.cxx
+++ b/framework/source/accelerators/presethandler.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/util/thePathSettings.hpp>
+#include <utility>
#include <vcl/svapp.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <rtl/ustrbuf.hxx>
@@ -57,8 +58,6 @@ struct TSharedStorages final
StorageHolder m_lStoragesUser;
TSharedStorages()
- : m_lStoragesShare()
- , m_lStoragesUser ()
{};
};
@@ -66,14 +65,17 @@ struct TSharedStorages final
a) shared root storages
b) shared "inbetween" storages
of the share and user layer. */
-struct SharedStorages: public rtl::Static<TSharedStorages, SharedStorages> {};
+TSharedStorages& SharedStorages()
+{
+ static TSharedStorages theStorages;
+ return theStorages;
+}
}
-PresetHandler::PresetHandler(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext(xContext)
+PresetHandler::PresetHandler(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext(std::move(xContext))
, m_eConfigType(E_GLOBAL)
- , m_lDocumentStorages()
{
}
@@ -105,7 +107,7 @@ PresetHandler::~PresetHandler()
Otherwise we will disconnect all other open configuration access
objects which base on these storages.
*/
- auto & sharedStorages = SharedStorages::get();
+ auto & sharedStorages = SharedStorages();
sharedStorages.m_lStoragesShare.closePath(m_sRelPathShare);
sharedStorages.m_lStoragesUser.closePath (m_sRelPathUser );
@@ -171,7 +173,7 @@ void lcl_throwCorruptedUIConfigurationException(
css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageShare()
{
- auto & sharedStorages = SharedStorages::get();
+ auto & sharedStorages = SharedStorages();
css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesShare.getRootStorage();
if (xRoot.is())
return xRoot;
@@ -204,9 +206,10 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
// based of a system directory. This must be used so, till the storage implementation
// can work on directories too.
*/
- css::uno::Sequence< css::uno::Any > lArgs(2);
- lArgs[0] <<= sShareLayer;
- lArgs[1] <<= css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE;
+ css::uno::Sequence< css::uno::Any > lArgs{
+ css::uno::Any(sShareLayer),
+ css::uno::Any(css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE)
+ };
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( xContext );
css::uno::Reference< css::embed::XStorage > xStorage;
@@ -229,7 +232,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageUser()
{
- auto & sharedStorages = SharedStorages::get();
+ auto & sharedStorages = SharedStorages();
css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesUser.getRootStorage();
if (xRoot.is())
return xRoot;
@@ -252,9 +255,8 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
sUserLayer += "soffice.cfg"; // storage file
- css::uno::Sequence< css::uno::Any > lArgs(2);
- lArgs[0] <<= sUserLayer;
- lArgs[1] <<= css::embed::ElementModes::READWRITE;
+ css::uno::Sequence< css::uno::Any > lArgs{ css::uno::Any(sUserLayer),
+ css::uno::Any(css::embed::ElementModes::READWRITE) };
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( xContext );
css::uno::Reference< css::embed::XStorage > xStorage;
@@ -289,7 +291,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageShare
xWorking = m_xWorkingStorageShare;
}
- return SharedStorages::get().m_lStoragesShare.getParentStorage(xWorking);
+ return SharedStorages().m_lStoragesShare.getParentStorage(xWorking);
}
css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser()
@@ -300,12 +302,12 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser(
xWorking = m_xWorkingStorageUser;
}
- return SharedStorages::get().m_lStoragesUser.getParentStorage(xWorking);
+ return SharedStorages().m_lStoragesUser.getParentStorage(xWorking);
}
void PresetHandler::connectToResource( PresetHandler::EConfigType eConfigType ,
- const OUString& sResource ,
- const OUString& sModule ,
+ std::u16string_view sResource ,
+ std::u16string_view sModule ,
const css::uno::Reference< css::embed::XStorage >& xDocumentRoot,
const LanguageTag& rLanguageTag )
{
@@ -355,10 +357,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
{
case E_GLOBAL :
{
- sRelPathBuf.append("global");
- sRelPathBuf.append("/");
- sRelPathBuf.append(sResource);
- sRelPathShare = sRelPathBuf.makeStringAndClear();
+ sRelPathShare = OUString::Concat("global/") + sResource;
sRelPathUser = sRelPathShare;
xShare = impl_openPathIgnoringErrors(sRelPathShare, eShareMode, true );
@@ -368,12 +367,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
case E_MODULES :
{
- sRelPathBuf.append("modules");
- sRelPathBuf.append("/");
- sRelPathBuf.append(sModule);
- sRelPathBuf.append("/");
- sRelPathBuf.append(sResource);
- sRelPathShare = sRelPathBuf.makeStringAndClear();
+ sRelPathShare = OUString::Concat("modules/") + sModule + "/" + sResource;
sRelPathUser = sRelPathShare;
xShare = impl_openPathIgnoringErrors(sRelPathShare, eShareMode, true );
@@ -548,7 +542,7 @@ void PresetHandler::commitUserChanges()
case E_GLOBAL :
case E_MODULES :
{
- auto & sharedStorages = SharedStorages::get();
+ auto & sharedStorages = SharedStorages();
sPath = sharedStorages.m_lStoragesUser.getPathOfStorage(xWorking);
sharedStorages.m_lStoragesUser.commitPath(sPath);
sharedStorages.m_lStoragesUser.notifyPath(sPath);
@@ -583,7 +577,7 @@ void PresetHandler::addStorageListener(XMLBasedAcceleratorConfiguration* pListen
case E_GLOBAL :
case E_MODULES :
{
- SharedStorages::get().m_lStoragesUser.addStorageListener(pListener, sRelPath);
+ SharedStorages().m_lStoragesUser.addStorageListener(pListener, sRelPath);
}
break;
@@ -613,7 +607,7 @@ void PresetHandler::removeStorageListener(XMLBasedAcceleratorConfiguration* pLis
case E_GLOBAL :
case E_MODULES :
{
- SharedStorages::get().m_lStoragesUser.removeStorageListener(pListener, sRelPath);
+ SharedStorages().m_lStoragesUser.removeStorageListener(pListener, sRelPath);
}
break;
@@ -625,6 +619,7 @@ void PresetHandler::removeStorageListener(XMLBasedAcceleratorConfiguration* pLis
}
}
+// static
css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoringErrors(const OUString& sPath ,
sal_Int32 eMode ,
bool bShare)
@@ -633,9 +628,9 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
try
{
if (bShare)
- xPath = SharedStorages::get().m_lStoragesShare.openPath(sPath, eMode);
+ xPath = SharedStorages().m_lStoragesShare.openPath(sPath, eMode);
else
- xPath = SharedStorages::get().m_lStoragesUser.openPath(sPath, eMode);
+ xPath = SharedStorages().m_lStoragesUser.openPath(sPath, eMode);
}
catch(const css::uno::RuntimeException&)
{ throw; }
@@ -644,6 +639,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
return xPath;
}
+// static
::std::vector< OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(
const ::std::vector< OUString >& lLocalizedValues,
OUString& rLanguageTag,
@@ -668,6 +664,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
return pFound;
}
+// static
css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPathIgnoringErrors(
OUString& sPath ,
sal_Int32 eMode ,
@@ -705,6 +702,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
return xLocalePath;
}
+// static
::std::vector< OUString > PresetHandler::impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder)
{
if (!xFolder.is())
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 4c7702e579ca..6cef699bfb14 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -26,10 +26,11 @@
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
#include <algorithm>
-#define PATH_SEPARATOR "/"
+constexpr OUString PATH_SEPARATOR = u"/"_ustr;
#define PATH_SEPARATOR_UNICODE u'/'
namespace framework
@@ -47,7 +48,7 @@ StorageHolder::~StorageHolder()
void StorageHolder::forgetCachedStorages()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
for (auto & lStorage : m_lStorages)
{
TStorageInfo& rInfo = lStorage.second;
@@ -59,13 +60,13 @@ void StorageHolder::forgetCachedStorages()
void StorageHolder::setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
m_xRoot = xRoot;
}
css::uno::Reference< css::embed::XStorage > StorageHolder::getRootStorage() const
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
return m_xRoot;
}
@@ -76,9 +77,9 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
std::vector<OUString> lFolders = StorageHolder::impl_st_parsePath(sNormedPath);
// SAFE -> ----------------------------------
- osl::ResettableMutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
css::uno::Reference< css::embed::XStorage > xParent = m_xRoot;
- aReadLock.clear();
+ aReadLock.unlock();
// <- SAFE ----------------------------------
css::uno::Reference< css::embed::XStorage > xChild;
@@ -89,7 +90,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
OUString sCheckPath (sRelPath + lFolder + PATH_SEPARATOR);
// SAFE -> ------------------------------
- aReadLock.reset();
+ aReadLock.lock();
// If we found an already open storage ... we must increase
// its use count. Otherwise it will may be closed too early :-)
@@ -101,12 +102,12 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
++(pInfo->UseCount);
xChild = pInfo->Storage;
- aReadLock.clear();
+ aReadLock.unlock();
// <- SAFE ------------------------------
}
else
{
- aReadLock.clear();
+ aReadLock.unlock();
// <- SAFE ------------------------------
try
@@ -130,7 +131,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
throw;
}
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
pInfo = &(m_lStorages[sCheckPath]);
pInfo->Storage = xChild;
pInfo->UseCount = 1;
@@ -154,7 +155,7 @@ StorageHolder::TStorageList StorageHolder::getAllPathStorages(const OUString& sP
StorageHolder::TStorageList lStoragesOfPath;
OUString sRelPath;
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
for (auto const& lFolder : lFolders)
{
@@ -196,7 +197,7 @@ void StorageHolder::commitPath(const OUString& sPath)
// SAFE -> ------------------------------
{
- osl::MutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
xCommit.set(m_xRoot, css::uno::UNO_QUERY);
}
// <- SAFE ------------------------------
@@ -223,7 +224,7 @@ void StorageHolder::closePath(const OUString& rPath)
sParentPath = sCurrentRelPath;
}
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
std::vector<OUString>::reverse_iterator pIt2;
for ( pIt2 = lFolders.rbegin();
@@ -249,7 +250,7 @@ void StorageHolder::notifyPath(const OUString& sPath)
{
OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
if (pIt1 == m_lStorages.end())
@@ -268,7 +269,7 @@ void StorageHolder::addStorageListener( XMLBasedAcceleratorConfiguration* p
{
OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
if (pIt1 == m_lStorages.end())
@@ -285,7 +286,7 @@ void StorageHolder::removeStorageListener( XMLBasedAcceleratorConfiguration
{
OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
if (pIt1 == m_lStorages.end())
@@ -299,7 +300,7 @@ void StorageHolder::removeStorageListener( XMLBasedAcceleratorConfiguration
OUString StorageHolder::getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
for (auto const& lStorage : m_lStorages)
{
@@ -334,7 +335,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
// SAFE -> ----------------------------------
{
- osl::MutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
// b)
if (c < 2)
@@ -345,7 +346,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
sal_Int32 i = 0;
for (i = 0; i < c - 1; ++i)
{
- sParentPath.append(lFolders[i]).append(PATH_SEPARATOR);
+ sParentPath.append(lFolders[i] + PATH_SEPARATOR);
}
auto pParent = m_lStorages.find(sParentPath.makeStringAndClear());
@@ -361,7 +362,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
StorageHolder& StorageHolder::operator=(const StorageHolder& rCopy)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
m_xRoot = rCopy.m_xRoot;
m_lStorages = rCopy.m_lStorages;
return *this;
@@ -427,13 +428,13 @@ OUString StorageHolder::impl_st_normPath(const OUString& sPath)
return sNormedPath;
}
-std::vector<OUString> StorageHolder::impl_st_parsePath(const OUString& sPath)
+std::vector<OUString> StorageHolder::impl_st_parsePath(std::u16string_view sPath)
{
std::vector<OUString> lToken;
sal_Int32 i = 0;
while (true)
{
- OUString sToken = sPath.getToken(0, PATH_SEPARATOR_UNICODE, i);
+ OUString sToken( o3tl::getToken(sPath, 0, PATH_SEPARATOR_UNICODE, i) );
if (i < 0)
break;
lToken.push_back(sToken);
diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx
index baaaa7aba708..f84bcb711467 100644
--- a/framework/source/classes/taskcreator.cxx
+++ b/framework/source/classes/taskcreator.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/frame/TaskCreator.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include <utility>
namespace framework{
@@ -36,8 +37,8 @@ namespace framework{
@param xContext
points to the valid uno service manager
*//*-*****************************************************************************************************/
-TaskCreator::TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : m_xContext ( xContext )
+TaskCreator::TaskCreator( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
{
}
@@ -70,35 +71,15 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
if ( ! xCreator.is())
xCreator = css::frame::TaskCreator::create(m_xContext);
- css::uno::Sequence< css::uno::Any > lArgs(6);
- css::beans::NamedValue aArg;
-
- aArg.Name = ARGUMENT_PARENTFRAME;
- aArg.Value <<= css::uno::Reference< css::frame::XFrame >( css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY_THROW);
- lArgs[0] <<= aArg;
-
- aArg.Name = ARGUMENT_CREATETOPWINDOW;
- aArg.Value <<= true;
- lArgs[1] <<= aArg;
-
- aArg.Name = ARGUMENT_MAKEVISIBLE;
- aArg.Value <<= false;
- lArgs[2] <<= aArg;
-
- aArg.Name = ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE;
- aArg.Value <<= true;
- lArgs[3] <<= aArg;
-
- aArg.Name = ARGUMENT_FRAMENAME;
- aArg.Value <<= sName;
- lArgs[4] <<= aArg;
-
- bool bHidden
- = rDescriptor.getUnpackedValueOrDefault("HiddenForConversion", false);
- aArg.Name = "HiddenForConversion";
- aArg.Value <<= bHidden;
- lArgs[5] <<= aArg;
-
+ css::uno::Sequence< css::uno::Any > lArgs
+ {
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_PARENTFRAME, css::uno::Any(css::uno::Reference< css::frame::XFrame >( css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY_THROW)))) ,
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_CREATETOPWINDOW, css::uno::Any(true))),
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_MAKEVISIBLE, css::uno::Any(false))),
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE, css::uno::Any(true))),
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_FRAMENAME, css::uno::Any(sName))),
+ css::uno::Any(css::beans::NamedValue(ARGUMENT_HIDDENFORCONVERSION, css::uno::Any(rDescriptor.getUnpackedValueOrDefault(ARGUMENT_HIDDENFORCONVERSION, false))))
+ };
css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
return xTask;
}
diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx
index 2dc4795abdc4..2fd3bc91e39f 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -36,10 +36,12 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <osl/diagnose.h>
+#include <utility>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <vcl/syswin.hxx>
#include <unotools/moduleoptions.hxx>
+#include <o3tl/string_view.hxx>
using namespace com::sun::star;
@@ -50,14 +52,14 @@ namespace framework{
#endif
namespace fpf = ::framework::pattern::frame;
-const char URL_CLOSEDOC[] = ".uno:CloseDoc";
-const char URL_CLOSEWIN[] = ".uno:CloseWin";
+constexpr OUString URL_CLOSEDOC = u".uno:CloseDoc"_ustr;
+constexpr OUString URL_CLOSEWIN = u".uno:CloseWin"_ustr;
const char URL_CLOSEFRAME[] = ".uno:CloseFrame";
-CloseDispatcher::CloseDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
+CloseDispatcher::CloseDispatcher(css::uno::Reference< css::uno::XComponentContext > xContext ,
const css::uno::Reference< css::frame::XFrame >& xFrame ,
- const OUString& sTarget)
- : m_xContext (rxContext )
+ std::u16string_view sTarget)
+ : m_xContext(std::move(xContext))
, m_aAsyncCallback(
new vcl::EventPoster(LINK(this, CloseDispatcher, impl_asyncCallback)))
, m_eOperation(E_CLOSE_DOC)
@@ -101,16 +103,16 @@ css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL CloseDispatcher::
/* Attention: Don't add .uno:CloseFrame here. Because it's not really
a configurable feature ... and further it does not have
a valid UIName entry inside the GenericCommands.xcu ... */
- css::uno::Sequence< css::frame::DispatchInformation > lViewInfos(1);
- lViewInfos[0].Command = URL_CLOSEWIN;
- lViewInfos[0].GroupId = css::frame::CommandGroup::VIEW;
+ css::uno::Sequence< css::frame::DispatchInformation > lViewInfos{
+ { URL_CLOSEWIN, css::frame::CommandGroup::VIEW }
+ };
return lViewInfos;
}
else if (nCommandGroup == css::frame::CommandGroup::DOCUMENT)
{
- css::uno::Sequence< css::frame::DispatchInformation > lDocInfos(1);
- lDocInfos[0].Command = URL_CLOSEDOC;
- lDocInfos[0].GroupId = css::frame::CommandGroup::DOCUMENT;
+ css::uno::Sequence< css::frame::DispatchInformation > lDocInfos{
+ { URL_CLOSEDOC, css::frame::CommandGroup::DOCUMENT }
+ };
return lDocInfos;
}
@@ -329,8 +331,11 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone*, void)
// c1) there is as minimum 1 frame open, which is visible and contains a document
// different from our one. And it's not the help!
+ // (tdf#30920 consider that closing a frame which is not the backing window (start center) while there is
+ // another frame that is the backing window open only closes the frame, and not terminate the app, so
+ // closing the license frame doesn't terminate the app if launched from the start center)
// => close our frame only - nothing else.
- if (!aCheck2.m_lOtherVisibleFrames.empty())
+ if (!aCheck2.m_lOtherVisibleFrames.empty() || (!aCheck2.m_bReferenceIsBacking && aCheck2.m_xBackingComponent.is()))
bCloseFrame = true;
else
@@ -351,12 +356,17 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone*, void)
// application or establish the backing mode now.
// And that depends from the dispatched URL ...
{
- if (bHasActiveConnections)
- bCloseFrame = true;
- else if (eOperation == E_CLOSE_FRAME)
- bTerminateApp = true;
+ if (eOperation == E_CLOSE_FRAME)
+ {
+ if (bHasActiveConnections)
+ bCloseFrame = true;
+ else
+ bTerminateApp = true;
+ }
else if( SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::STARTMODULE) )
bEstablishBackingMode = true;
+ else if (bHasActiveConnections)
+ bCloseFrame = true;
else
bTerminateApp = true;
}
@@ -558,12 +568,12 @@ void CloseDispatcher::implts_notifyResultListener(const css::uno::Reference< css
}
css::uno::Reference< css::frame::XFrame > CloseDispatcher::static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame ,
- const OUString& sTarget)
+ std::u16string_view sTarget)
{
- if (sTarget.equalsIgnoreAsciiCase("_self"))
+ if (o3tl::equalsIgnoreAsciiCase(sTarget, u"_self"))
return xFrame;
- OSL_ENSURE(sTarget.isEmpty(), "CloseDispatch used for unexpected target. Magic things will happen now .-)");
+ OSL_ENSURE(sTarget.empty(), "CloseDispatch used for unexpected target. Magic things will happen now .-)");
css::uno::Reference< css::frame::XFrame > xTarget = xFrame;
while(true)
diff --git a/framework/source/dispatch/dispatchdisabler.cxx b/framework/source/dispatch/dispatchdisabler.cxx
index b38fe3d521d5..b09e6109459f 100644
--- a/framework/source/dispatch/dispatchdisabler.cxx
+++ b/framework/source/dispatch/dispatchdisabler.cxx
@@ -29,7 +29,7 @@ void SAL_CALL DispatchDisabler::initialize( const uno::Sequence< uno::Any >& aAr
if( aArguments.hasElements() &&
( aArguments[0] >>= aDisabledURLs ) )
{
- for( OUString const & url : std::as_const(aDisabledURLs) )
+ for (OUString const& url : aDisabledURLs)
maDisabledURLs.insert(url);
}
}
@@ -52,8 +52,9 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL
DispatchDisabler::queryDispatches( const uno::Sequence< frame::DispatchDescriptor >& rRequests )
{
uno::Sequence< uno::Reference< frame::XDispatch > > aResult(rRequests.getLength());
+ auto aResultRange = asNonConstRange(aResult);
for( sal_Int32 i = 0; i < rRequests.getLength(); ++i )
- aResult[i] = queryDispatch(rRequests[i].FeatureURL,
+ aResultRange[i] = queryDispatch(rRequests[i].FeatureURL,
rRequests[i].FrameName,
rRequests[i].SearchFlags);
return aResult;
@@ -87,9 +88,10 @@ uno::Sequence< OUString > SAL_CALL
DispatchDisabler::getInterceptedURLs()
{
uno::Sequence< OUString > aDisabledURLs(maDisabledURLs.size());
+ auto aDisabledURLsRange = asNonConstRange(aDisabledURLs);
sal_Int32 n = 0;
for (auto const& disabledURL : maDisabledURLs)
- aDisabledURLs[n++] = disabledURL;
+ aDisabledURLsRange[n++] = disabledURL;
return aDisabledURLs;
}
diff --git a/framework/source/dispatch/dispatchinformationprovider.cxx b/framework/source/dispatch/dispatchinformationprovider.cxx
index 47234f4d6a02..a5a0bd6980e6 100644
--- a/framework/source/dispatch/dispatchinformationprovider.cxx
+++ b/framework/source/dispatch/dispatchinformationprovider.cxx
@@ -25,12 +25,13 @@
#include <comphelper/sequence.hxx>
#include <unordered_map>
+#include <utility>
namespace framework{
-DispatchInformationProvider::DispatchInformationProvider(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
+DispatchInformationProvider::DispatchInformationProvider(css::uno::Reference< css::uno::XComponentContext > xContext ,
const css::uno::Reference< css::frame::XFrame >& xFrame)
- : m_xContext (xContext )
+ : m_xContext (std::move(xContext ))
, m_xFrame (xFrame )
{
}
@@ -113,16 +114,13 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvide
if (!xFrame.is())
return css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > >();
- CloseDispatcher* pCloser = new CloseDispatcher(m_xContext, xFrame, "_self"); // explicit "_self" ... not "" ... see implementation of close dispatcher itself!
- css::uno::Reference< css::uno::XInterface > xCloser(static_cast< css::frame::XDispatch* >(pCloser), css::uno::UNO_QUERY);
+ rtl::Reference<CloseDispatcher> xCloser = new CloseDispatcher(m_xContext, xFrame, u"_self"); // explicit "_self" ... not "" ... see implementation of close dispatcher itself!
- css::uno::Reference< css::frame::XDispatchInformationProvider > xCloseDispatch(xCloser , css::uno::UNO_QUERY);
css::uno::Reference< css::frame::XDispatchInformationProvider > xController (xFrame->getController() , css::uno::UNO_QUERY);
css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher = css::frame::AppDispatchProvider::create(m_xContext);
- css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider(3);
- lProvider[0] = xController;
- lProvider[1] = xCloseDispatch;
- lProvider[2] = xAppDispatcher;
+ css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider{
+ xController, xCloser, xAppDispatcher
+ };
return lProvider;
}
diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx
index 9d86254061a7..a1125016ce30 100644
--- a/framework/source/dispatch/dispatchprovider.cxx
+++ b/framework/source/dispatch/dispatchprovider.cxx
@@ -32,10 +32,13 @@
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/util/XCacheInfo.hpp>
#include <rtl/ustring.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
+#include <framework/dispatchhelper.hxx>
namespace framework{
@@ -53,9 +56,9 @@ namespace framework{
@param xFrame
reference to our owner frame.
*/
-DispatchProvider::DispatchProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
- const css::uno::Reference< css::frame::XFrame >& xFrame )
- : m_xContext ( rxContext )
+DispatchProvider::DispatchProvider( css::uno::Reference< css::uno::XComponentContext > xContext ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame )
+ : m_xContext (std::move( xContext ))
, m_xFrame ( xFrame )
{
}
@@ -126,11 +129,11 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Disp
// It's not allowed to pack it!
sal_Int32 nCount = lDescriptions.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
-
+ auto lDispatcherRange = asNonConstRange(lDispatcher);
// Step over all descriptors and try to get any dispatcher for it.
for( sal_Int32 i=0; i<nCount; ++i )
{
- lDispatcher[i] = queryDispatch( lDescriptions[i].FeatureURL ,
+ lDispatcherRange[i] = queryDispatch( lDescriptions[i].FeatureURL ,
lDescriptions[i].FrameName ,
lDescriptions[i].SearchFlags );
}
@@ -433,25 +436,43 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt
ProtocolHandler aHandler;
// This member is threadsafe by himself and lives if we live - we don't need any mutex here.
- if (m_aProtocolHandlerCache.search(aURL,&aHandler))
+ if (framework::HandlerCache::search(aURL,&aHandler))
{
css::uno::Reference< css::frame::XDispatchProvider > xHandler;
{
SolarMutexGuard g;
// create it
+ bool bInitialize = true;
try
{
- xHandler.set(
- css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
- ->createInstance(aHandler.m_sUNOName),
- css::uno::UNO_QUERY);
+ // Only create the protocol handler instance once, the creation is expensive.
+ auto it = m_aProtocolHandlers.find(aHandler.m_sUNOName);
+ if (it == m_aProtocolHandlers.end())
+ {
+ xHandler.set(
+ css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
+ ->createInstance(aHandler.m_sUNOName),
+ css::uno::UNO_QUERY);
+
+ // Check if the handler explicitly requested to avoid caching.
+ css::uno::Reference<css::util::XCacheInfo> xCacheInfo(xHandler, css::uno::UNO_QUERY);
+ if (!xCacheInfo.is() || xCacheInfo->isCachingAllowed())
+ {
+ m_aProtocolHandlers.emplace(aHandler.m_sUNOName, xHandler);
+ }
+ }
+ else
+ {
+ xHandler = it->second;
+ bInitialize = false;
+ }
}
catch(const css::uno::Exception&) {}
// look if initialization is necessary
css::uno::Reference< css::lang::XInitialization > xInit( xHandler, css::uno::UNO_QUERY );
- if (xInit.is())
+ if (xInit.is() && bInitialize)
{
css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY );
SAL_WARN_IF(!xOwner.is(), "fwk", "DispatchProvider::implts_searchProtocolHandler(): Couldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.");
@@ -460,8 +481,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt
try
{
// but do it only, if all context information is OK
- css::uno::Sequence< css::uno::Any > lContext(1);
- lContext[0] <<= xOwner;
+ css::uno::Sequence< css::uno::Any > lContext{ css::uno::Any(xOwner) };
xInit->initialize(lContext);
}
catch(const css::uno::Exception&) {}
@@ -509,51 +529,33 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
switch (eHelper)
{
case E_CREATEDISPATCHER :
- {
- LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags);
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags);
break;
case E_BLANKDISPATCHER :
{
if (xOwner.is())
- {
- LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0);
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0);
}
break;
case E_DEFAULTDISPATCHER :
{
if (xOwner.is())
- {
- LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0);
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0);
}
break;
case E_SELFDISPATCHER :
- {
- LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_SELF, 0);
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_SELF, 0);
break;
case E_CLOSEDISPATCHER :
- {
- CloseDispatcher* pDispatcher = new CloseDispatcher( m_xContext, xOwner, sTarget );
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new CloseDispatcher( m_xContext, xOwner, sTarget );
break;
case E_STARTMODULEDISPATCHER :
- {
- StartModuleDispatcher* pDispatcher = new StartModuleDispatcher( m_xContext );
- xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
- }
+ xDispatchHelper = new StartModuleDispatcher( m_xContext );
break;
}
@@ -572,6 +574,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
@threadsafe yes
*/
+// static
bool DispatchProvider::implts_isLoadableContent( const css::util::URL& aURL )
{
LoadEnv::EContentType eType = LoadEnv::classifyContent(aURL.Complete, css::uno::Sequence< css::beans::PropertyValue >());
diff --git a/framework/source/dispatch/interceptionhelper.cxx b/framework/source/dispatch/interceptionhelper.cxx
index 899ce2440946..40cfe404edc3 100644
--- a/framework/source/dispatch/interceptionhelper.cxx
+++ b/framework/source/dispatch/interceptionhelper.cxx
@@ -17,18 +17,24 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <dispatch/dispatchprovider.hxx>
#include <dispatch/interceptionhelper.hxx>
#include <com/sun/star/frame/XInterceptorInfo.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
#include <osl/diagnose.h>
+#include <utility>
#include <vcl/svapp.hxx>
+#include <comphelper/diagnose_ex.hxx>
+
+using namespace com::sun::star;
namespace framework{
InterceptionHelper::InterceptionHelper(const css::uno::Reference< css::frame::XFrame >& xOwner,
- const css::uno::Reference< css::frame::XDispatchProvider >& xSlave)
+ rtl::Reference< DispatchProvider > xSlave)
: m_xOwnerWeak (xOwner )
- , m_xSlave (xSlave )
+ , m_xSlave (std::move(xSlave ))
{
}
@@ -98,7 +104,7 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Inte
void SAL_CALL InterceptionHelper::registerDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
{
// reject incorrect calls of this interface method
- css::uno::Reference< css::frame::XDispatchProvider > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XDispatchProvider > xThis(this);
if (!xInterceptor.is())
throw css::uno::RuntimeException("NULL references not allowed as in parameter", xThis);
@@ -112,10 +118,7 @@ void SAL_CALL InterceptionHelper::registerDispatchProviderInterceptor(const css:
if (xInfo.is())
aInfo.lURLPattern = xInfo->getInterceptedURLs();
else
- {
- aInfo.lURLPattern.realloc(1);
- aInfo.lURLPattern[0] = "*";
- }
+ aInfo.lURLPattern = { "*" };
// SAFE {
SolarMutexClearableGuard aWriteLock;
@@ -161,7 +164,7 @@ void SAL_CALL InterceptionHelper::registerDispatchProviderInterceptor(const css:
void SAL_CALL InterceptionHelper::releaseDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
{
// reject wrong calling of this interface method
- css::uno::Reference< css::frame::XDispatchProvider > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XDispatchProvider > xThis(this);
if (!xInterceptor.is())
throw css::uno::RuntimeException("NULL references not allowed as in parameter", xThis);
@@ -185,7 +188,18 @@ void SAL_CALL InterceptionHelper::releaseDispatchProviderInterceptor(const css::
xMasterI->setSlaveDispatchProvider(xSlaveD);
if (xSlaveI.is())
- xSlaveI->setMasterDispatchProvider(xMasterD);
+ {
+ try
+ {
+ xSlaveI->setMasterDispatchProvider(xMasterD);
+ }
+ catch (const lang::DisposedException&)
+ {
+ TOOLS_WARN_EXCEPTION("fwk.dispatch",
+ "InterceptionHelper::releaseDispatchProviderInterceptor: "
+ "xSlaveI is disposed: ");
+ }
+ }
xInterceptor->setSlaveDispatchProvider (css::uno::Reference< css::frame::XDispatchProvider >());
xInterceptor->setMasterDispatchProvider(css::uno::Reference< css::frame::XDispatchProvider >());
@@ -222,7 +236,7 @@ void SAL_CALL InterceptionHelper::disposing(const css::lang::EventObject& aEvent
// We need a full copy of all currently registered interceptor objects.
// Otherwise we can't iterate over this vector without the risk, that our iterator will be invalid.
- // Because this vetor will be influenced by every deregistered interceptor.
+ // Because this vector will be influenced by every deregistered interceptor.
InterceptionHelper::InterceptorList aCopy = m_lInterceptionRegs;
aReadLock.clear();
diff --git a/framework/source/dispatch/isstartmoduledispatch.hxx b/framework/source/dispatch/isstartmoduledispatch.hxx
index e48c84d744bb..a968a36f68db 100644
--- a/framework/source/dispatch/isstartmoduledispatch.hxx
+++ b/framework/source/dispatch/isstartmoduledispatch.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_DISPATCH_ISSTARTMODULEDISPATCH_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_DISPATCH_ISSTARTMODULEDISPATCH_HXX
+#pragma once
#include <com/sun/star/util/URL.hpp>
@@ -30,6 +29,4 @@ inline bool isStartModuleDispatch(css::util::URL const& url)
}
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/dispatch/loaddispatcher.cxx b/framework/source/dispatch/loaddispatcher.cxx
index 92c15de422ab..04ea5cf5c0d0 100644
--- a/framework/source/dispatch/loaddispatcher.cxx
+++ b/framework/source/dispatch/loaddispatcher.cxx
@@ -22,15 +22,16 @@
#include <sal/log.hxx>
#include <com/sun/star/frame/DispatchResultState.hpp>
+#include <utility>
namespace framework{
LoadDispatcher::LoadDispatcher(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
const css::uno::Reference< css::frame::XFrame >& xOwnerFrame ,
- const OUString& sTargetName ,
+ OUString sTargetName ,
sal_Int32 nSearchFlags)
: m_xOwnerFrame (xOwnerFrame )
- , m_sTarget (sTargetName )
+ , m_sTarget (std::move(sTargetName ))
, m_nSearchFlags(nSearchFlags)
, m_aLoader (xContext )
{
diff --git a/framework/source/dispatch/mailtodispatcher.cxx b/framework/source/dispatch/mailtodispatcher.cxx
index 7dcdb073203d..9149b9b40dc0 100644
--- a/framework/source/dispatch/mailtodispatcher.cxx
+++ b/framework/source/dispatch/mailtodispatcher.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/frame/DispatchResultState.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
namespace framework{
@@ -54,8 +55,8 @@ css::uno::Sequence< OUString > SAL_CALL MailToDispatcher::getSupportedServiceNam
@param rxContext
reference to uno servicemanager for creation of new services
*/
-MailToDispatcher::MailToDispatcher( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- : m_xContext ( rxContext )
+MailToDispatcher::MailToDispatcher( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
{
}
@@ -92,9 +93,10 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Mail
{
sal_Int32 nCount = lDescriptor.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
+ auto lDispatcherRange = asNonConstRange(lDispatcher);
for( sal_Int32 i=0; i<nCount; ++i )
{
- lDispatcher[i] = queryDispatch(
+ lDispatcherRange[i] = queryDispatch(
lDescriptor[i].FeatureURL,
lDescriptor[i].FrameName,
lDescriptor[i].SearchFlags);
@@ -118,7 +120,7 @@ void SAL_CALL MailToDispatcher::dispatch( const css::util::URL&
{
// dispatch() is an [oneway] call ... and may our user release his reference to us immediately.
// So we should hold us self alive till this call ends.
- css::uno::Reference< css::frame::XNotifyingDispatch > xSelfHold(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XNotifyingDispatch > xSelfHold(this);
implts_dispatch(aURL);
// No notification for status listener!
}
@@ -142,7 +144,7 @@ void SAL_CALL MailToDispatcher::dispatchWithNotification( const css::util::URL&
// This class was designed to die by reference. And if user release his reference to us immediately after calling this method
// we can run into some problems. So we hold us self alive till this method ends.
// Another reason: We can use this reference as source of sending event at the end too.
- css::uno::Reference< css::frame::XNotifyingDispatch > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XNotifyingDispatch > xThis(this);
bool bState = implts_dispatch(aURL);
if (xListener.is())
diff --git a/framework/source/dispatch/oxt_handler.cxx b/framework/source/dispatch/oxt_handler.cxx
index 254e07fed72e..df956c7eed8a 100644
--- a/framework/source/dispatch/oxt_handler.cxx
+++ b/framework/source/dispatch/oxt_handler.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/task/XJobExecutor.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <tools/long.hxx>
+#include <utility>
namespace framework{
@@ -55,8 +56,8 @@ css::uno::Sequence< OUString > SAL_CALL Oxt_Handler::getSupportedServiceNames()
@onerror Show an assertion and do nothing else.
@threadsafe yes
*//*-*************************************************************************************************************/
-Oxt_Handler::Oxt_Handler( const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : m_xContext ( xContext )
+Oxt_Handler::Oxt_Handler( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
{
}
@@ -91,10 +92,9 @@ void SAL_CALL Oxt_Handler::dispatchWithNotification( const css::util::URL& aURL,
const css::uno::Sequence< css::beans::PropertyValue >& /*lArguments*/,
const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
- css::uno::Sequence< css::uno::Any > lParams(1);
- lParams[0] <<= aURL.Main;
+ css::uno::Sequence< css::uno::Any > lParams{ css::uno::Any(aURL.Main) };
css::uno::Reference< css::uno::XInterface > xService = m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.deployment.ui.PackageManagerDialog", lParams, m_xContext );
css::uno::Reference< css::task::XJobExecutor > xExecutable( xService, css::uno::UNO_QUERY );
@@ -143,7 +143,7 @@ OUString SAL_CALL Oxt_Handler::detect( css::uno::Sequence< css::beans::PropertyV
// Analyze given descriptor to find filename or input stream or...
utl::MediaDescriptor aDescriptor( lDescriptor );
- OUString sURL = aDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL(), OUString() );
+ OUString sURL = aDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL, OUString() );
tools::Long nLength = sURL.getLength();
if ( ( nLength > 4 ) && sURL.matchIgnoreAsciiCase( ".oxt", nLength-4 ) )
@@ -154,7 +154,7 @@ OUString SAL_CALL Oxt_Handler::detect( css::uno::Sequence< css::beans::PropertyV
// a) look for given extension of url to map our type decision HARD CODED!!!
// b) return preferred type every time... it's easy :-)
sTypeName = "oxt_OpenOffice_Extension";
- aDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sTypeName;
+ aDescriptor[utl::MediaDescriptor::PROP_TYPENAME] <<= sTypeName;
aDescriptor >> lDescriptor;
}
diff --git a/framework/source/dispatch/popupmenudispatcher.cxx b/framework/source/dispatch/popupmenudispatcher.cxx
index 1b845347454f..3220ceece227 100644
--- a/framework/source/dispatch/popupmenudispatcher.cxx
+++ b/framework/source/dispatch/popupmenudispatcher.cxx
@@ -28,6 +28,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <sal/log.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
namespace framework{
@@ -44,8 +45,8 @@ using namespace ::cppu;
using namespace ::osl;
PopupMenuDispatcher::PopupMenuDispatcher(
- const uno::Reference< XComponentContext >& xContext )
- : m_xContext ( xContext )
+ uno::Reference< XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
, m_bAlreadyDisposed ( false )
, m_bActivateListener ( false )
{
@@ -86,8 +87,7 @@ void SAL_CALL PopupMenuDispatcher::initialize( const css::uno::Sequence< css::un
m_xWeakFrame = xFrame;
m_bActivateListener = true;
- uno::Reference< css::frame::XFrameActionListener > xFrameActionListener(
- static_cast<OWeakObject *>(this), css::uno::UNO_QUERY );
+ uno::Reference< css::frame::XFrameActionListener > xFrameActionListener(this);
xFrame->addFrameActionListener( xFrameActionListener );
}
}
@@ -99,58 +99,57 @@ SAL_CALL PopupMenuDispatcher::queryDispatch(
const OUString& sTarget ,
sal_Int32 nFlags )
{
- css::uno::Reference< css::frame::XDispatch > xDispatch;
+ if ( !rURL.Complete.startsWith( "vnd.sun.star.popup:" ) )
+ return {};
- if ( rURL.Complete.startsWith( "vnd.sun.star.popup:" ) )
- {
- // --- SAFE ---
- SolarMutexClearableGuard aGuard;
- impl_RetrievePopupControllerQuery();
- if ( !m_xUriRefFactory.is() )
- m_xUriRefFactory = css::uri::UriReferenceFactory::create( m_xContext );
+ // --- SAFE ---
+ SolarMutexClearableGuard aGuard;
+ impl_RetrievePopupControllerQuery();
+ if ( !m_xUriRefFactory.is() )
+ m_xUriRefFactory = css::uri::UriReferenceFactory::create( m_xContext );
+
+ css::uno::Reference< css::container::XNameAccess > xPopupCtrlQuery( m_xPopupCtrlQuery );
+ aGuard.clear();
+ // --- SAFE ---
+
+ if ( !xPopupCtrlQuery.is() )
+ return {};
- css::uno::Reference< css::container::XNameAccess > xPopupCtrlQuery( m_xPopupCtrlQuery );
- aGuard.clear();
- // --- SAFE ---
+ css::uno::Reference< css::frame::XDispatch > xDispatch;
- if ( xPopupCtrlQuery.is() )
+ try
+ {
+ // Just use the main part of the URL for popup menu controllers
+ sal_Int32 nSchemePart( 0 );
+ OUString aBaseURL( "vnd.sun.star.popup:" );
+ OUString aURL( rURL.Complete );
+
+ nSchemePart = aURL.indexOf( ':' );
+ if (( nSchemePart > 0 ) &&
+ ( aURL.getLength() > ( nSchemePart+1 )))
{
- try
- {
- // Just use the main part of the URL for popup menu controllers
- sal_Int32 nSchemePart( 0 );
- OUString aBaseURL( "vnd.sun.star.popup:" );
- OUString aURL( rURL.Complete );
-
- nSchemePart = aURL.indexOf( ':' );
- if (( nSchemePart > 0 ) &&
- ( aURL.getLength() > ( nSchemePart+1 )))
- {
- sal_Int32 nQueryPart = aURL.indexOf( '?', nSchemePart );
- if ( nQueryPart > 0 )
- aBaseURL += aURL.subView( nSchemePart+1, nQueryPart-(nSchemePart+1) );
- else if ( nQueryPart == -1 )
- aBaseURL += aURL.subView( nSchemePart+1 );
- }
-
- css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider;
-
- // Find popup menu controller using the base URL
- xPopupCtrlQuery->getByName( aBaseURL ) >>= xDispatchProvider;
- aGuard.clear();
-
- // Ask popup menu dispatch provider for dispatch object
- if ( xDispatchProvider.is() )
- xDispatch = xDispatchProvider->queryDispatch( rURL, sTarget, nFlags );
- }
- catch ( const RuntimeException& )
- {
- throw;
- }
- catch ( const Exception& )
- {
- }
+ sal_Int32 nQueryPart = aURL.indexOf( '?', nSchemePart );
+ if ( nQueryPart > 0 )
+ aBaseURL += aURL.subView( nSchemePart+1, nQueryPart-(nSchemePart+1) );
+ else if ( nQueryPart == -1 )
+ aBaseURL += aURL.subView( nSchemePart+1 );
}
+
+ css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider;
+
+ // Find popup menu controller using the base URL
+ xPopupCtrlQuery->getByName( aBaseURL ) >>= xDispatchProvider;
+
+ // Ask popup menu dispatch provider for dispatch object
+ if ( xDispatchProvider.is() )
+ xDispatch = xDispatchProvider->queryDispatch( rURL, sTarget, nFlags );
+ }
+ catch ( const RuntimeException& )
+ {
+ throw;
+ }
+ catch ( const Exception& )
+ {
}
return xDispatch;
}
@@ -161,9 +160,10 @@ PopupMenuDispatcher::queryDispatches(
{
sal_Int32 nCount = lDescriptor.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
+ auto lDispatcherRange = asNonConstRange(lDispatcher);
for( sal_Int32 i=0; i<nCount; ++i )
{
- lDispatcher[i] = queryDispatch(
+ lDispatcherRange[i] = queryDispatch(
lDescriptor[i].FeatureURL,
lDescriptor[i].FrameName,
lDescriptor[i].SearchFlags);
@@ -212,7 +212,7 @@ void SAL_CALL PopupMenuDispatcher::disposing( const EventObject& )
uno::Reference< XFrame > xFrame( m_xWeakFrame.get(), UNO_QUERY );
if ( xFrame.is() )
{
- xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( static_cast<OWeakObject *>(this), UNO_QUERY ));
+ xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >(this) );
m_bActivateListener = false;
}
}
diff --git a/framework/source/dispatch/servicehandler.cxx b/framework/source/dispatch/servicehandler.cxx
index cf99c16c27a0..cb29898350b9 100644
--- a/framework/source/dispatch/servicehandler.cxx
+++ b/framework/source/dispatch/servicehandler.cxx
@@ -24,13 +24,13 @@
#include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
namespace framework{
-#define PROTOCOL_VALUE "service:"
-#define PROTOCOL_LENGTH 8
+constexpr OUString PROTOCOL_VALUE = u"service:"_ustr;
// XInterface, XTypeProvider, XServiceInfo
@@ -57,8 +57,8 @@ css::uno::Sequence< OUString > SAL_CALL ServiceHandler::getSupportedServiceNames
@param xFactory
reference to uno servicemanager for creation of new services
*/
-ServiceHandler::ServiceHandler( const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : m_xContext ( xContext )
+ServiceHandler::ServiceHandler( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
{
}
@@ -95,9 +95,10 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Serv
{
sal_Int32 nCount = lDescriptor.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
+ auto lDispatcherRange = asNonConstRange(lDispatcher);
for( sal_Int32 i=0; i<nCount; ++i )
{
- lDispatcher[i] = queryDispatch(
+ lDispatcherRange[i] = queryDispatch(
lDescriptor[i].FeatureURL,
lDescriptor[i].FrameName,
lDescriptor[i].SearchFlags);
@@ -120,7 +121,7 @@ void SAL_CALL ServiceHandler::dispatch( const css::util::URL&
{
// dispatch() is an [oneway] call ... and may our user release his reference to us immediately.
// So we should hold us self alive till this call ends.
- css::uno::Reference< css::frame::XNotifyingDispatch > xSelfHold(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XNotifyingDispatch > xSelfHold(this);
implts_dispatch(aURL);
// No notification for status listener!
}
@@ -144,7 +145,7 @@ void SAL_CALL ServiceHandler::dispatchWithNotification( const css::util::URL&
// This class was designed to die by reference. And if user release his reference to us immediately after calling this method
// we can run into some problems. So we hold us self alive till this method ends.
// Another reason: We can use this reference as source of sending event at the end too.
- css::uno::Reference< css::frame::XNotifyingDispatch > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XNotifyingDispatch > xThis(this);
css::uno::Reference< css::uno::XInterface > xService = implts_dispatch(aURL);
if (xListener.is())
@@ -178,7 +179,7 @@ css::uno::Reference< css::uno::XInterface > ServiceHandler::implts_dispatch( con
{
// extract service name and may optional given parameters from given URL
// and use it to create and start the component
- OUString sServiceAndArguments = aURL.Complete.copy(PROTOCOL_LENGTH);
+ OUString sServiceAndArguments = aURL.Complete.copy(PROTOCOL_VALUE.getLength());
OUString sServiceName;
OUString sArguments;
diff --git a/framework/source/dispatch/startmoduledispatcher.cxx b/framework/source/dispatch/startmoduledispatcher.cxx
index c6ec312070c0..39ac70ee1479 100644
--- a/framework/source/dispatch/startmoduledispatcher.cxx
+++ b/framework/source/dispatch/startmoduledispatcher.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/frame/StartModule.hpp>
#include <unotools/moduleoptions.hxx>
+#include <utility>
namespace framework{
@@ -36,8 +37,8 @@ namespace framework{
#error "Who uses \"fpf\" as define. It will overwrite my namespace alias ..."
#endif
-StartModuleDispatcher::StartModuleDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
- : m_xContext (rxContext )
+StartModuleDispatcher::StartModuleDispatcher(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
{
}
diff --git a/framework/source/dispatch/systemexec.cxx b/framework/source/dispatch/systemexec.cxx
index ec2d20413614..1891b9b62b1f 100644
--- a/framework/source/dispatch/systemexec.cxx
+++ b/framework/source/dispatch/systemexec.cxx
@@ -26,11 +26,11 @@
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/frame/DispatchResultState.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
namespace framework{
-#define PROTOCOL_VALUE "systemexecute:"
-#define PROTOCOL_LENGTH 14
+constexpr OUString PROTOCOL_VALUE = u"systemexecute:"_ustr;
// XInterface, XTypeProvider, XServiceInfo
@@ -49,8 +49,8 @@ css::uno::Sequence< OUString > SAL_CALL SystemExec::getSupportedServiceNames()
return { SERVICENAME_PROTOCOLHANDLER };
}
-SystemExec::SystemExec( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- : m_xContext ( rxContext )
+SystemExec::SystemExec( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move( xContext ))
{
}
@@ -72,9 +72,10 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Syst
{
sal_Int32 nCount = lDescriptor.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
+ auto lDispatcherRange = asNonConstRange(lDispatcher);
for( sal_Int32 i=0; i<nCount; ++i )
{
- lDispatcher[i] = queryDispatch(
+ lDispatcherRange[i] = queryDispatch(
lDescriptor[i].FeatureURL,
lDescriptor[i].FrameName,
lDescriptor[i].SearchFlags);
@@ -93,13 +94,13 @@ void SAL_CALL SystemExec::dispatchWithNotification( const css::util::URL&
const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
{
// convert "systemexec:file:///c:/temp/test.html" => "file:///c:/temp/test.html"
- sal_Int32 c = aURL.Complete.getLength()-PROTOCOL_LENGTH;
+ sal_Int32 c = aURL.Complete.getLength()-PROTOCOL_VALUE.getLength();
if (c<1) // we don't check for valid URLs here! The system will show an error message ...
{
impl_notifyResultListener(xListener, css::frame::DispatchResultState::FAILURE);
return;
}
- OUString sSystemURLWithVariables = aURL.Complete.copy(PROTOCOL_LENGTH, c);
+ OUString sSystemURLWithVariables = aURL.Complete.copy(PROTOCOL_VALUE.getLength(), c);
// TODO check security settings ...
diff --git a/framework/source/dispatch/windowcommanddispatch.cxx b/framework/source/dispatch/windowcommanddispatch.cxx
index 97e5de5ca2c7..abad29dc7529 100644
--- a/framework/source/dispatch/windowcommanddispatch.cxx
+++ b/framework/source/dispatch/windowcommanddispatch.cxx
@@ -25,17 +25,17 @@
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
+#include <utility>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <vcl/commandevent.hxx>
-#include <osl/mutex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
namespace framework{
-WindowCommandDispatch::WindowCommandDispatch(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
+WindowCommandDispatch::WindowCommandDispatch(css::uno::Reference< css::uno::XComponentContext > xContext ,
const css::uno::Reference< css::frame::XFrame >& xFrame)
- : m_xContext (xContext )
+ : m_xContext (std::move(xContext ))
, m_xFrame (xFrame )
, m_xWindow (xFrame->getContainerWindow())
{
@@ -50,9 +50,9 @@ WindowCommandDispatch::~WindowCommandDispatch()
void WindowCommandDispatch::impl_startListening()
{
- osl::ClearableMutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
css::uno::Reference< css::awt::XWindow > xWindow( m_xWindow.get(), css::uno::UNO_QUERY );
- aReadLock.clear();
+ aReadLock.unlock();
if ( ! xWindow.is())
return;
@@ -70,9 +70,9 @@ void WindowCommandDispatch::impl_startListening()
void WindowCommandDispatch::impl_stopListening()
{
- osl::ClearableMutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
css::uno::Reference< css::awt::XWindow > xWindow( m_xWindow.get(), css::uno::UNO_QUERY );
- aReadLock.clear();
+ aReadLock.unlock();
if (!xWindow.is())
return;
@@ -130,10 +130,10 @@ IMPL_LINK(WindowCommandDispatch, impl_notifyCommand, VclWindowEvent&, rEvent, vo
try
{
// SYNCHRONIZED ->
- osl::ClearableMutexGuard aReadLock(m_mutex);
+ std::unique_lock aReadLock(m_mutex);
css::uno::Reference< css::frame::XDispatchProvider > xProvider(m_xFrame.get(), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
- aReadLock.clear();
+ aReadLock.unlock();
// <- SYNCHRONIZED
// check provider ... we know it's weak reference only
diff --git a/framework/source/fwe/classes/actiontriggercontainer.cxx b/framework/source/fwe/classes/actiontriggercontainer.cxx
index 331eb5cb935e..360223e6eb67 100644
--- a/framework/source/fwe/classes/actiontriggercontainer.cxx
+++ b/framework/source/fwe/classes/actiontriggercontainer.cxx
@@ -32,8 +32,7 @@ using namespace com::sun::star::container;
namespace framework
{
-ActionTriggerContainer::ActionTriggerContainer() :
- PropertySetContainer()
+ActionTriggerContainer::ActionTriggerContainer()
{
}
@@ -58,12 +57,12 @@ Any SAL_CALL ActionTriggerContainer::queryInterface( const Type& aType )
return PropertySetContainer::queryInterface( aType );
}
-void ActionTriggerContainer::acquire() throw()
+void ActionTriggerContainer::acquire() noexcept
{
PropertySetContainer::acquire();
}
-void ActionTriggerContainer::release() throw()
+void ActionTriggerContainer::release() noexcept
{
PropertySetContainer::release();
}
@@ -88,11 +87,9 @@ Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstanceWithArgum
Sequence< OUString > SAL_CALL ActionTriggerContainer::getAvailableServiceNames()
{
- Sequence< OUString > aSeq( 3 );
-
- aSeq[0] = SERVICENAME_ACTIONTRIGGER;
- aSeq[1] = SERVICENAME_ACTIONTRIGGERCONTAINER;
- aSeq[2] = SERVICENAME_ACTIONTRIGGERSEPARATOR;
+ Sequence< OUString > aSeq{ SERVICENAME_ACTIONTRIGGER,
+ SERVICENAME_ACTIONTRIGGERCONTAINER,
+ SERVICENAME_ACTIONTRIGGERSEPARATOR };
return aSeq;
}
diff --git a/framework/source/fwe/classes/actiontriggerpropertyset.cxx b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
index 128f5815bb1a..36790f9d7aa1 100644
--- a/framework/source/fwe/classes/actiontriggerpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
@@ -58,7 +58,6 @@ namespace framework
ActionTriggerPropertySet::ActionTriggerPropertySet()
: OBroadcastHelper ( m_aMutex )
, OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) )
- , OWeakObject ()
{
}
@@ -87,12 +86,12 @@ Any SAL_CALL ActionTriggerPropertySet::queryInterface( const Type& aType )
return OWeakObject::queryInterface( aType );
}
-void SAL_CALL ActionTriggerPropertySet::acquire() throw ()
+void SAL_CALL ActionTriggerPropertySet::acquire() noexcept
{
OWeakObject::acquire();
}
-void SAL_CALL ActionTriggerPropertySet::release() throw ()
+void SAL_CALL ActionTriggerPropertySet::release() noexcept
{
OWeakObject::release();
}
@@ -265,6 +264,7 @@ Sequence< Property > ActionTriggerPropertySet::impl_getStaticPropertyDescriptor(
};
}
+// static
bool ActionTriggerPropertySet::impl_tryToChangeProperty(
const OUString& sCurrentValue ,
const Any& aNewValue ,
@@ -299,6 +299,7 @@ bool ActionTriggerPropertySet::impl_tryToChangeProperty(
return bReturn;
}
+// static
bool ActionTriggerPropertySet::impl_tryToChangeProperty(
const Reference< XBitmap >& aCurrentValue ,
const Any& aNewValue ,
@@ -333,6 +334,7 @@ bool ActionTriggerPropertySet::impl_tryToChangeProperty(
return bReturn;
}
+// static
bool ActionTriggerPropertySet::impl_tryToChangeProperty(
const Reference< XInterface >& aCurrentValue ,
const Any& aNewValue ,
diff --git a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
index eb9d6d2ec71f..2f46ae5f0579 100644
--- a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
@@ -52,7 +52,6 @@ namespace framework
ActionTriggerSeparatorPropertySet::ActionTriggerSeparatorPropertySet()
: OBroadcastHelper ( m_aMutex )
, OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) )
- , OWeakObject ()
, m_nSeparatorType( 0 )
{
}
@@ -82,12 +81,12 @@ Any SAL_CALL ActionTriggerSeparatorPropertySet::queryInterface( const Type& aTyp
return OWeakObject::queryInterface( aType );
}
-void ActionTriggerSeparatorPropertySet::acquire() throw()
+void ActionTriggerSeparatorPropertySet::acquire() noexcept
{
OWeakObject::acquire();
}
-void ActionTriggerSeparatorPropertySet::release() throw()
+void ActionTriggerSeparatorPropertySet::release() noexcept
{
OWeakObject::release();
}
@@ -207,6 +206,7 @@ Sequence< Property > ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDe
};
}
+// static
bool ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
sal_Int16 aCurrentValue ,
const Any& aNewValue ,
diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx
index 582460a0ed2c..db6a7435ac14 100644
--- a/framework/source/fwe/classes/addonmenu.cxx
+++ b/framework/source/fwe/classes/addonmenu.cxx
@@ -124,9 +124,9 @@ void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame,
{
nInsSepAfterPos += ( pHelpMenu->GetItemCount() - nItemCount );
if ( pHelpMenu->GetItemType( nInsSepAfterPos ) != MenuItemType::SEPARATOR )
- pHelpMenu->InsertSeparator(OString(), nInsSepAfterPos);
+ pHelpMenu->InsertSeparator({}, nInsSepAfterPos);
}
- pHelpMenu->InsertSeparator(OString(), nItemCount);
+ pHelpMenu->InsertSeparator({}, nItemCount);
}
}
@@ -171,7 +171,7 @@ void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame,
if ( pAddonPopupMenu->GetItemCount() > 0 )
{
- pMergeMenuBar->InsertItem( nId, aTitle, MenuItemBits::NONE, OString(), nInsertPos++ );
+ pMergeMenuBar->InsertItem( nId, aTitle, MenuItemBits::NONE, {}, nInsertPos++);
pMergeMenuBar->SetPopupMenu( nId, pAddonPopupMenu );
// Store the command URL into the VCL menu bar for later identification
@@ -233,12 +233,12 @@ void AddonMenuManager::BuildMenu( PopupMenu* pCurrent
// have already one before us
nElements = 0;
bInsertSeparator = false;
- pCurrentMenu->InsertSeparator(OString(), nInsPos);
+ pCurrentMenu->InsertSeparator({}, nInsPos);
nInsPos = AddonMenuManager::GetNextPos( nInsPos );
}
sal_uInt16 nId = nUniqueMenuId++;
- pCurrentMenu->InsertItem(nId, aTitle, MenuItemBits::NONE, OString(), nInsPos);
+ pCurrentMenu->InsertItem(nId, aTitle, MenuItemBits::NONE, {}, nInsPos);
nInsPos = AddonMenuManager::GetNextPos( nInsPos );
++nElements;
@@ -281,15 +281,14 @@ void AddonMenuManager::GetMenuEntry( const Sequence< PropertyValue >& rAddonMenu
}
// Check if the context string matches the provided xModel context
-bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& rContext )
+bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view rContext )
{
- if ( rContext.isEmpty() )
+ if ( rContext.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
- sal_Int32 nIndex = rContext.indexOf( rModuleIdentifier );
- return ( nIndex >= 0 );
+ return rContext.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index a8aed7ab7e4d..6f9dc8d87130 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -43,7 +43,6 @@
// namespaces
-using namespace ::std;
using namespace ::utl;
using namespace ::osl;
using namespace ::com::sun::star::uno;
@@ -51,9 +50,9 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star;
-#define ROOTNODE_ADDONMENU "Office.Addons"
-#define PATHDELIMITER OUString("/" )
-#define SEPARATOR_URL "private:separator"
+constexpr OUStringLiteral ROOTNODE_ADDONMENU = u"Office.Addons";
+constexpr OUStringLiteral PATHDELIMITER = u"/";
+constexpr OUString SEPARATOR_URL = u"private:separator"_ustr;
#define PROPERTYNAME_URL ADDONSMENUITEM_STRING_URL
#define PROPERTYNAME_TITLE ADDONSMENUITEM_STRING_TITLE
@@ -62,7 +61,7 @@ using namespace ::com::sun::star;
#define PROPERTYNAME_CONTEXT ADDONSMENUITEM_STRING_CONTEXT
#define PROPERTYNAME_SUBMENU ADDONSMENUITEM_STRING_SUBMENU
-#define IMAGES_NODENAME "UserDefinedImages"
+constexpr OUStringLiteral IMAGES_NODENAME = u"UserDefinedImages";
// The following order is mandatory. Please add properties at the end!
#define INDEX_URL 0
@@ -291,21 +290,21 @@ class AddonsOptions_Impl : public ConfigItem
void ReadStatusbarMergeInstructions( MergeStatusbarInstructionContainer& rContainer );
void ReadMergeMenuData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeMenu );
- bool ReadMergeToolbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems );
- bool ReadMergeNotebookBarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeNotebookBarItems );
- bool ReadMergeStatusbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeStatusbar );
+ void ReadMergeToolbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems );
+ void ReadMergeNotebookBarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeNotebookBarItems );
+ void ReadMergeStatusbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeStatusbar );
bool ReadMenuItem( std::u16string_view aMenuItemNodeName, Sequence< PropertyValue >& aMenuItem, bool bIgnoreSubMenu = false );
bool ReadPopupMenu( std::u16string_view aPopupMenuNodeName, Sequence< PropertyValue >& aPopupMenu );
- void AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
+ static void AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
bool ReadToolBarItem( std::u16string_view aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem );
bool ReadNotebookBarItem( std::u16string_view aNotebookBarItemNodeName, Sequence< PropertyValue >& aNotebookBarItem );
bool ReadStatusBarItem( std::u16string_view aStatusbarItemNodeName, Sequence< PropertyValue >& aStatusbarItem );
std::unique_ptr<ImageEntry> ReadImageData( std::u16string_view aImagesNodeName );
void ReadAndAssociateImages( const OUString& aURL, const OUString& aImageId );
- BitmapEx ReadImageFromURL( const OUString& aURL );
+ static BitmapEx ReadImageFromURL( const OUString& aURL );
bool HasAssociatedImages( const OUString& aURL );
- void SubstituteVariables( OUString& aURL );
+ static void SubstituteVariables( OUString& aURL );
void ReadSubMenuEntries( const Sequence< OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenu );
OUString GeneratePrefixURL();
@@ -320,7 +319,7 @@ class AddonsOptions_Impl : public ConfigItem
Sequence< OUString > GetPropertyNamesStatusbarItem( std::u16string_view aPropertyRootNode ) const;
Sequence< OUString > GetPropertyNamesImages( std::u16string_view aPropertyRootNode ) const;
- bool CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const;
+ static bool CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq );
DECL_LINK(NotifyEvent, void*, void);
@@ -612,29 +611,29 @@ BitmapEx AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, b
OneImageEntry& rSizeEntry = pIter->second.aSizeEntry[nIdx];
OneImageEntry& rOtherEntry = pIter->second.aSizeEntry[nOtherIdx];
// actually read the image ...
- if (!rSizeEntry.aImage)
+ if (rSizeEntry.aImage.IsEmpty())
rSizeEntry.aImage = ReadImageFromURL(rSizeEntry.aURL);
- if (!rSizeEntry.aImage)
+ if (rSizeEntry.aImage.IsEmpty())
{ // try the other size and scale it
aImage = ScaleImage(ReadImageFromURL(rOtherEntry.aURL), bBig);
rSizeEntry.aImage = aImage;
- if (!rSizeEntry.aImage)
+ if (rSizeEntry.aImage.IsEmpty())
SAL_WARN("fwk", "failed to load addons image " << aURL);
}
// FIXME: bNoScale is not terribly meaningful or useful
- if (!aImage && bNoScale)
+ if (aImage.IsEmpty() && bNoScale)
aImage = rSizeEntry.aImage;
- if (!aImage && !!rSizeEntry.aScaled)
+ if (aImage.IsEmpty() && !rSizeEntry.aScaled.IsEmpty())
aImage = rSizeEntry.aScaled;
else // scale to the correct size for the theme / toolbox
{
aImage = rSizeEntry.aImage;
- if (!aImage) // use and scale the other if one size is missing
+ if (aImage.IsEmpty()) // use and scale the other if one size is missing
aImage = rOtherEntry.aImage;
aImage = ScaleImage(aImage, bBig);
@@ -655,14 +654,14 @@ void AddonsOptions_Impl::ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >
sal_uInt32 nCount = aAddonMenuNodeSeq.getLength();
sal_uInt32 nIndex = 0;
Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
-
+ auto pMenuItem = aMenuItem.getArray();
// Init the property value sequence
- aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
- aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
+ pMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
+ pMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
for ( sal_uInt32 n = 0; n < nCount; n++ )
{
@@ -674,7 +673,7 @@ void AddonsOptions_Impl::ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >
// Successfully read a menu item, append to our list
sal_uInt32 nMenuItemCount = rAddonMenuSeq.getLength() + 1;
rAddonMenuSeq.realloc( nMenuItemCount );
- rAddonMenuSeq[nIndex++] = aMenuItem;
+ rAddonMenuSeq.getArray()[nIndex++] = aMenuItem;
}
}
}
@@ -689,14 +688,14 @@ void AddonsOptions_Impl::ReadOfficeHelpSet( Sequence< Sequence< PropertyValue >
sal_uInt32 nCount = aAddonHelpMenuNodeSeq.getLength();
sal_uInt32 nIndex = 0;
Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
-
+ auto pMenuItem = aMenuItem.getArray();
// Init the property value sequence
- aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
- aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
+ pMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
+ pMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
for ( sal_uInt32 n = 0; n < nCount; n++ )
{
@@ -708,7 +707,7 @@ void AddonsOptions_Impl::ReadOfficeHelpSet( Sequence< Sequence< PropertyValue >
// Successfully read a menu item, append to our list
sal_uInt32 nMenuItemCount = rAddonOfficeHelpMenuSeq.getLength() + 1;
rAddonOfficeHelpMenuSeq.realloc( nMenuItemCount );
- rAddonOfficeHelpMenuSeq[nIndex++] = aMenuItem;
+ rAddonOfficeHelpMenuSeq.getArray()[nIndex++] = aMenuItem;
}
}
}
@@ -723,15 +722,15 @@ void AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue
sal_uInt32 nCount = aAddonMenuBarNodeSeq.getLength();
sal_uInt32 nIndex = 0;
Sequence< PropertyValue > aPopupMenu( PROPERTYCOUNT_POPUPMENU );
-
+ auto pPopupMenu = aPopupMenu.getArray();
// Init the property value sequence
- aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
- aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT];
- aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU];
- aPopupMenu[ OFFSET_POPUPMENU_URL ].Name = m_aPropNames[ INDEX_URL ];
+ pPopupMenu[ OFFSET_POPUPMENU_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
+ pPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT];
+ pPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU];
+ pPopupMenu[ OFFSET_POPUPMENU_URL ].Name = m_aPropNames[ INDEX_URL ];
StringToIndexMap aTitleToIndexMap;
-
+ auto pAddonOfficeMenuBarSeq = rAddonOfficeMenuBarSeq.getArray();
for ( sal_uInt32 n = 0; n < nCount; n++ )
{
OUString aPopupMenuNode( aAddonMenuBarNode + aAddonMenuBarNodeSeq[n] );
@@ -747,7 +746,7 @@ void AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue
if ( pIter != aTitleToIndexMap.end() )
{
// title already there => concat both popup menus
- Sequence< PropertyValue >& rOldPopupMenu = rAddonOfficeMenuBarSeq[pIter->second];
+ Sequence< PropertyValue >& rOldPopupMenu = pAddonOfficeMenuBarSeq[pIter->second];
AppendPopupMenu( rOldPopupMenu, aPopupMenu );
}
else
@@ -755,7 +754,8 @@ void AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue
// not found
sal_uInt32 nMenuItemCount = rAddonOfficeMenuBarSeq.getLength() + 1;
rAddonOfficeMenuBarSeq.realloc( nMenuItemCount );
- rAddonOfficeMenuBarSeq[nIndex] = aPopupMenu;
+ pAddonOfficeMenuBarSeq = rAddonOfficeMenuBarSeq.getArray();
+ pAddonOfficeMenuBarSeq[nIndex] = aPopupMenu;
aTitleToIndexMap.emplace( aPopupTitle, nIndex );
++nIndex;
}
@@ -788,15 +788,15 @@ bool AddonsOptions_Impl::ReadToolBarItemSet( const OUString& rToolBarItemSetNode
OUString aAddonToolBarItemSetNode( rToolBarItemSetNodeName + m_aPathDelimiter );
Sequence< OUString > aAddonToolBarItemSetNodeSeq = GetNodeNames( rToolBarItemSetNodeName );
Sequence< PropertyValue > aToolBarItem( PROPERTYCOUNT_TOOLBARITEM );
-
+ auto pToolBarItem = aToolBarItem.getArray();
// Init the property value sequence
- aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
- aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
- aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
- aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Name = m_aPropNames[ INDEX_CONTROLTYPE ];
- aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
+ pToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Name = m_aPropNames[ INDEX_CONTROLTYPE ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
sal_uInt32 nCount = aAddonToolBarItemSetNodeSeq.getLength();
for ( sal_uInt32 n = 0; n < nCount; n++ )
@@ -809,7 +809,7 @@ bool AddonsOptions_Impl::ReadToolBarItemSet( const OUString& rToolBarItemSetNode
// Successfully read a toolbar item, append to our list
sal_uInt32 nAddonCount = rAddonOfficeToolBarSeq.getLength();
rAddonOfficeToolBarSeq.realloc( nAddonCount+1 );
- rAddonOfficeToolBarSeq[nAddonCount] = aToolBarItem;
+ rAddonOfficeToolBarSeq.getArray()[nAddonCount] = aToolBarItem;
}
}
@@ -844,17 +844,17 @@ bool AddonsOptions_Impl::ReadNotebookBarItemSet(
OUString aAddonNotebookBarItemSetNode(rNotebookBarItemSetNodeName + m_aPathDelimiter);
Sequence<OUString> aAddonNotebookBarItemSetNodeSeq = GetNodeNames(rNotebookBarItemSetNodeName);
Sequence<PropertyValue> aNotebookBarItem(PROPERTYCOUNT_NOTEBOOKBARITEM);
-
+ auto pNotebookBarItem = aNotebookBarItem.getArray();
// Init the property value sequence
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_URL].Name = m_aPropNames[INDEX_URL];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_TITLE].Name = m_aPropNames[INDEX_TITLE];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER].Name
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_URL].Name = m_aPropNames[INDEX_URL];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_TITLE].Name = m_aPropNames[INDEX_TITLE];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER].Name
= m_aPropNames[INDEX_IMAGEIDENTIFIER];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_TARGET].Name = m_aPropNames[INDEX_TARGET];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_CONTEXT].Name = m_aPropNames[INDEX_CONTEXT];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_CONTROLTYPE].Name = m_aPropNames[INDEX_CONTROLTYPE];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_WIDTH].Name = m_aPropNames[INDEX_WIDTH];
- aNotebookBarItem[OFFSET_NOTEBOOKBARITEM_STYLE].Name = m_aPropNames[INDEX_STYLE];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_TARGET].Name = m_aPropNames[INDEX_TARGET];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_CONTEXT].Name = m_aPropNames[INDEX_CONTEXT];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_CONTROLTYPE].Name = m_aPropNames[INDEX_CONTROLTYPE];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_WIDTH].Name = m_aPropNames[INDEX_WIDTH];
+ pNotebookBarItem[OFFSET_NOTEBOOKBARITEM_STYLE].Name = m_aPropNames[INDEX_STYLE];
sal_uInt32 nCount = aAddonNotebookBarItemSetNodeSeq.getLength();
for (sal_uInt32 n = 0; n < nCount; n++)
@@ -867,7 +867,7 @@ bool AddonsOptions_Impl::ReadNotebookBarItemSet(
// Successfully read a toolbar item, append to our list
sal_uInt32 nAddonCount = rAddonOfficeNotebookBarSeq.getLength();
rAddonOfficeNotebookBarSeq.realloc(nAddonCount + 1);
- rAddonOfficeNotebookBarSeq[nAddonCount] = aNotebookBarItem;
+ rAddonOfficeNotebookBarSeq.getArray()[nAddonCount] = aNotebookBarItem;
}
}
@@ -885,7 +885,6 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
sal_uInt32 nCount = aAddonImagesNodeSeq.getLength();
// Init the property value sequence
- Sequence< OUString > aAddonImageItemNodePropNames( 1 );
OUString aURL;
for ( sal_uInt32 n = 0; n < nCount; n++ )
@@ -893,9 +892,9 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
OUString aImagesItemNode( aAddonImagesNode + aAddonImagesNodeSeq[n] );
// Create sequence for data access
- aAddonImageItemNodePropNames[0] = aImagesItemNode +
+ Sequence< OUString > aAddonImageItemNodePropNames = { aImagesItemNode +
m_aPathDelimiter +
- m_aPropNames[ OFFSET_MENUITEM_URL ];
+ m_aPropNames[ OFFSET_MENUITEM_URL ] };
Sequence< Any > aAddonImageItemNodeValues = GetProperties( aAddonImageItemNodePropNames );
@@ -924,17 +923,12 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
OUString AddonsOptions_Impl::GeneratePrefixURL()
{
// Create a unique prefixed Add-On popup menu URL so it can be identified later as a runtime popup menu.
- OUString aPopupMenuURL;
- OUStringBuffer aBuf( m_aRootAddonPopupMenuURLPrexfix.getLength() + 3 );
- aBuf.append( m_aRootAddonPopupMenuURLPrexfix );
- aBuf.append( OUString::number( ++m_nRootAddonPopupMenuId ));
- aPopupMenuURL = aBuf.makeStringAndClear();
- return aPopupMenuURL;
+ return m_aRootAddonPopupMenuURLPrexfix + OUString::number( ++m_nRootAddonPopupMenuId );
}
void AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContainer& aContainer )
{
- const OUString aMenuMergeRootName( "AddonUI/OfficeMenuBarMerging/" );
+ static constexpr OUString aMenuMergeRootName( u"AddonUI/OfficeMenuBarMerging/"_ustr );
Sequence< OUString > aAddonMergeNodesSeq = GetNodeNames( aMenuMergeRootName );
@@ -942,6 +936,7 @@ void AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContaine
// Init the property value sequence
Sequence< OUString > aNodePropNames( 5 );
+ auto pNodePropNames = aNodePropNames.getArray();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
@@ -952,31 +947,26 @@ void AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContaine
for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
{
- OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
- aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
+ OUString aMergeAddonInstructionBase = aMergeAddonInstructions +
+ m_aPathDelimiter +
+ aAddonInstMergeNodesSeq[j] +
+ m_aPathDelimiter;
// Create sequence for data access
- OUStringBuffer aBuffer( aMergeAddonInstructionBase );
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] );
- aNodePropNames[0] = aBuffer.makeStringAndClear();
+ pNodePropNames[0] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] );
- aNodePropNames[1] = aBuffer.makeStringAndClear();
+ pNodePropNames[1] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] );
- aNodePropNames[2] = aBuffer.makeStringAndClear();
+ pNodePropNames[2] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] );
- aNodePropNames[3] = aBuffer.makeStringAndClear();
+ pNodePropNames[3] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] );
- aNodePropNames[4] = aBuffer.makeStringAndClear();
+ pNodePropNames[4] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ];
Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
@@ -987,8 +977,7 @@ void AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContaine
aNodePropValues[3] >>= aMergeMenuInstruction.aMergeFallback;
aNodePropValues[4] >>= aMergeMenuInstruction.aMergeContext;
- OUString aMergeMenuBase = aMergeAddonInstructionBase.makeStringAndClear();
- ReadMergeMenuData( aMergeMenuBase, aMergeMenuInstruction.aMergeMenu );
+ ReadMergeMenuData( aMergeAddonInstructionBase, aMergeMenuInstruction.aMergeMenu );
aContainer.push_back( aMergeMenuInstruction );
}
@@ -1003,7 +992,7 @@ void AddonsOptions_Impl::ReadMergeMenuData( std::u16string_view aMergeAddonInstr
aMergeMenuBaseNode += m_aPathDelimiter;
// extend the node names to have full path strings
- for ( OUString& rName : aSubMenuNodeNames )
+ for ( OUString& rName : asNonConstRange(aSubMenuNodeNames) )
rName = aMergeMenuBaseNode + rName;
ReadSubMenuEntries( aSubMenuNodeNames, rMergeMenu );
@@ -1011,13 +1000,14 @@ void AddonsOptions_Impl::ReadMergeMenuData( std::u16string_view aMergeAddonInstr
void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstructions& rCachedToolbarMergingInstructions )
{
- const OUString aToolbarMergeRootName( "AddonUI/OfficeToolbarMerging/" );
+ static constexpr OUString aToolbarMergeRootName( u"AddonUI/OfficeToolbarMerging/"_ustr );
Sequence< OUString > aAddonMergeNodesSeq = GetNodeNames( aToolbarMergeRootName );
sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
// Init the property value sequence
Sequence< OUString > aNodePropNames( 6 );
+ auto pNodePropNames = aNodePropNames.getArray();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
@@ -1028,35 +1018,29 @@ void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstruction
for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
{
- OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
- aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
+ OUString aMergeAddonInstructionBase = aMergeAddonInstructions +
+ m_aPathDelimiter +
+ aAddonInstMergeNodesSeq[j] +
+ m_aPathDelimiter;
// Create sequence for data access
- OUStringBuffer aBuffer( aMergeAddonInstructionBase );
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ] );
- aNodePropNames[0] = aBuffer.makeStringAndClear();
+ pNodePropNames[0] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ] );
- aNodePropNames[1] = aBuffer.makeStringAndClear();
+ pNodePropNames[1] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ] );
- aNodePropNames[2] = aBuffer.makeStringAndClear();
+ pNodePropNames[2] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ] );
- aNodePropNames[3] = aBuffer.makeStringAndClear();
+ pNodePropNames[3] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ] );
- aNodePropNames[4] = aBuffer.makeStringAndClear();
+ pNodePropNames[4] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] );
- aNodePropNames[5] = aBuffer.makeStringAndClear();
+ pNodePropNames[5] = aMergeAddonInstructionBase +
+ m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ];
Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
@@ -1068,7 +1052,7 @@ void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstruction
aNodePropValues[4] >>= aMergeToolbarInstruction.aMergeFallback;
aNodePropValues[5] >>= aMergeToolbarInstruction.aMergeContext;
- ReadMergeToolbarData( aMergeAddonInstructionBase.makeStringAndClear(),
+ ReadMergeToolbarData( aMergeAddonInstructionBase,
aMergeToolbarInstruction.aMergeToolbarItems );
MergeToolbarInstructionContainer& rVector = rCachedToolbarMergingInstructions[ aMergeToolbarInstruction.aMergeToolbar ];
@@ -1077,24 +1061,25 @@ void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstruction
}
}
-bool AddonsOptions_Impl::ReadMergeToolbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems )
+void AddonsOptions_Impl::ReadMergeToolbarData( std::u16string_view aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems )
{
OUString aMergeToolbarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ];
- return ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems );
+ ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems );
}
void AddonsOptions_Impl::ReadNotebookBarMergeInstructions(
NotebookBarMergingInstructions& rCachedNotebookBarMergingInstructions)
{
- const OUString aNotebookBarMergeRootName("AddonUI/OfficeNotebookBarMerging/");
+ static constexpr OUString aNotebookBarMergeRootName(u"AddonUI/OfficeNotebookBarMerging/"_ustr);
Sequence<OUString> aAddonMergeNodesSeq = GetNodeNames(aNotebookBarMergeRootName);
sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
// Init the property value sequence
Sequence<OUString> aNodePropNames(6);
+ auto pNodePropNames = aNodePropNames.getArray();
for (sal_uInt32 i = 0; i < nCount; i++)
{
@@ -1105,36 +1090,29 @@ void AddonsOptions_Impl::ReadNotebookBarMergeInstructions(
for (sal_uInt32 j = 0; j < nCountAddons; j++)
{
- OUStringBuffer aMergeAddonInstructionBase(aMergeAddonInstructions);
- aMergeAddonInstructionBase.append(m_aPathDelimiter);
- aMergeAddonInstructionBase.append(aAddonInstMergeNodesSeq[j]);
- aMergeAddonInstructionBase.append(m_aPathDelimiter);
+ OUString aMergeAddonInstructionBase = aMergeAddonInstructions +
+ m_aPathDelimiter +
+ aAddonInstMergeNodesSeq[j] +
+ m_aPathDelimiter;
// Create sequence for data access
- OUStringBuffer aBuffer(aMergeAddonInstructionBase);
- aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBAR]);
- aNodePropNames[0] = aBuffer.makeStringAndClear();
+ pNodePropNames[0] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBAR];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGEPOINT]);
- aNodePropNames[1] = aBuffer.makeStringAndClear();
+ pNodePropNames[1] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGEPOINT];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECOMMAND]);
- aNodePropNames[2] = aBuffer.makeStringAndClear();
+ pNodePropNames[2] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECOMMAND];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append(
- m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECOMMANDPARAMETER]);
- aNodePropNames[3] = aBuffer.makeStringAndClear();
+ pNodePropNames[3] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECOMMANDPARAMETER];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGEFALLBACK]);
- aNodePropNames[4] = aBuffer.makeStringAndClear();
+ pNodePropNames[4] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGEFALLBACK];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECONTEXT]);
- aNodePropNames[5] = aBuffer.makeStringAndClear();
+ pNodePropNames[5] = aMergeAddonInstructionBase +
+ m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_MERGECONTEXT];
Sequence<Any> aNodePropValues = GetProperties(aNodePropNames);
@@ -1146,7 +1124,7 @@ void AddonsOptions_Impl::ReadNotebookBarMergeInstructions(
aNodePropValues[4] >>= aMergeNotebookBarInstruction.aMergeFallback;
aNodePropValues[5] >>= aMergeNotebookBarInstruction.aMergeContext;
- ReadMergeNotebookBarData(aMergeAddonInstructionBase.makeStringAndClear(),
+ ReadMergeNotebookBarData(aMergeAddonInstructionBase,
aMergeNotebookBarInstruction.aMergeNotebookBarItems);
MergeNotebookBarInstructionContainer& rVector
@@ -1157,24 +1135,25 @@ void AddonsOptions_Impl::ReadNotebookBarMergeInstructions(
}
}
-bool AddonsOptions_Impl::ReadMergeNotebookBarData(
+void AddonsOptions_Impl::ReadMergeNotebookBarData(
std::u16string_view aMergeAddonInstructionBase,
Sequence<Sequence<PropertyValue>>& rMergeNotebookBarItems)
{
OUString aMergeNotebookBarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBARITEMS];
- return ReadNotebookBarItemSet(aMergeNotebookBarBaseNode, rMergeNotebookBarItems);
+ ReadNotebookBarItemSet(aMergeNotebookBarBaseNode, rMergeNotebookBarItems);
}
void AddonsOptions_Impl::ReadStatusbarMergeInstructions( MergeStatusbarInstructionContainer& aContainer )
{
- const OUString aStatusbarMergeRootName( "AddonUI/OfficeStatusbarMerging/" );
+ static constexpr OUString aStatusbarMergeRootName( u"AddonUI/OfficeStatusbarMerging/"_ustr );
Sequence< OUString > aAddonMergeNodesSeq = GetNodeNames( aStatusbarMergeRootName );
sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
Sequence< OUString > aNodePropNames( 5 );
+ auto pNodePropNames = aNodePropNames.getArray();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
@@ -1185,31 +1164,26 @@ void AddonsOptions_Impl::ReadStatusbarMergeInstructions( MergeStatusbarInstructi
for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
{
- OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
- aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
- aMergeAddonInstructionBase.append( m_aPathDelimiter );
+ OUString aMergeAddonInstructionBase = aMergeAddonInstructions +
+ m_aPathDelimiter +
+ aAddonInstMergeNodesSeq[j] +
+ m_aPathDelimiter;
// Create sequence for data access
- OUStringBuffer aBuffer( aMergeAddonInstructionBase );
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGEPOINT ] );
- aNodePropNames[0] = aBuffer.makeStringAndClear();
+ pNodePropNames[0] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGEPOINT ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECOMMAND ] );
- aNodePropNames[1] = aBuffer.makeStringAndClear();
+ pNodePropNames[1] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECOMMAND ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECOMMANDPARAMETER ] );
- aNodePropNames[2] = aBuffer.makeStringAndClear();
+ pNodePropNames[2] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECOMMANDPARAMETER ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGEFALLBACK ] );
- aNodePropNames[3] = aBuffer.makeStringAndClear();
+ pNodePropNames[3] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGEFALLBACK ];
- aBuffer = aMergeAddonInstructionBase;
- aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECONTEXT ] );
- aNodePropNames[4] = aBuffer.makeStringAndClear();
+ pNodePropNames[4] = aMergeAddonInstructionBase +
+ m_aPropMergeMenuNames[ OFFSET_MERGESTATUSBAR_MERGECONTEXT ];
Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
@@ -1220,7 +1194,7 @@ void AddonsOptions_Impl::ReadStatusbarMergeInstructions( MergeStatusbarInstructi
// aNodePropValues[3] >>= aMergeStatusbarInstruction.aMergeFallback;
aNodePropValues[4] >>= aMergeStatusbarInstruction.aMergeContext;
- ReadMergeStatusbarData( aMergeAddonInstructionBase.makeStringAndClear(),
+ ReadMergeStatusbarData( aMergeAddonInstructionBase,
aMergeStatusbarInstruction.aMergeStatusbarItems );
aContainer.push_back( aMergeStatusbarInstruction );
@@ -1228,12 +1202,10 @@ void AddonsOptions_Impl::ReadStatusbarMergeInstructions( MergeStatusbarInstructi
}
}
-bool AddonsOptions_Impl::ReadMergeStatusbarData(
+void AddonsOptions_Impl::ReadMergeStatusbarData(
std::u16string_view aMergeAddonInstructionBase,
Sequence< Sequence< PropertyValue > >& rMergeStatusbarItems )
{
- sal_uInt32 nStatusbarItemCount = rMergeStatusbarItems.getLength();
-
OUString aMergeStatusbarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ];
@@ -1241,14 +1213,15 @@ bool AddonsOptions_Impl::ReadMergeStatusbarData(
Sequence< OUString > aAddonStatusbarItemSetNodeSeq = GetNodeNames( aMergeStatusbarBaseNode );
Sequence< PropertyValue > aStatusbarItem( PROPERTYCOUNT_STATUSBARITEM );
- aStatusbarItem[ OFFSET_STATUSBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Name = m_aPropNames[ INDEX_ALIGN ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Name = m_aPropNames[ INDEX_AUTOSIZE ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Name = m_aPropNames[ INDEX_OWNERDRAW ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Name = m_aPropNames[ INDEX_MANDATORY ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
+ auto pStatusbarItem = aStatusbarItem.getArray();
+ pStatusbarItem[ OFFSET_STATUSBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Name = m_aPropNames[ INDEX_ALIGN ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Name = m_aPropNames[ INDEX_AUTOSIZE ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Name = m_aPropNames[ INDEX_OWNERDRAW ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Name = m_aPropNames[ INDEX_MANDATORY ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
sal_uInt32 nCount = aAddonStatusbarItemSetNodeSeq.getLength();
for ( sal_uInt32 n = 0; n < nCount; n++ )
@@ -1259,11 +1232,9 @@ bool AddonsOptions_Impl::ReadMergeStatusbarData(
{
sal_uInt32 nAddonCount = rMergeStatusbarItems.getLength();
rMergeStatusbarItems.realloc( nAddonCount+1 );
- rMergeStatusbarItems[nAddonCount] = aStatusbarItem;
+ rMergeStatusbarItems.getArray()[nAddonCount] = aStatusbarItem;
}
}
-
- return ( o3tl::make_unsigned(rMergeStatusbarItems.getLength()) > nStatusbarItemCount );
}
bool AddonsOptions_Impl::ReadStatusBarItem(
@@ -1279,18 +1250,19 @@ bool AddonsOptions_Impl::ReadStatusBarItem(
// Command URL is required
if (( aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_URL ] >>= aURL ) && aURL.getLength() > 0 )
{
- aStatusbarItem[ OFFSET_STATUSBARITEM_URL ].Value <<= aURL;
- aStatusbarItem[ OFFSET_STATUSBARITEM_TITLE ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_TITLE ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_CONTEXT ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_CONTEXT ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_ALIGN ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_AUTOSIZE ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_OWNERDRAW ];
- aStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_MANDATORY ];
+ auto pStatusbarItem = aStatusbarItem.getArray();
+ pStatusbarItem[ OFFSET_STATUSBARITEM_URL ].Value <<= aURL;
+ pStatusbarItem[ OFFSET_STATUSBARITEM_TITLE ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_TITLE ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_CONTEXT ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_CONTEXT ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_ALIGN ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_AUTOSIZE ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_OWNERDRAW ];
+ pStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_MANDATORY ];
// Configuration uses hyper for long. Therefore transform into sal_Int32
sal_Int64 nValue( 0 );
aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_WIDTH ] >>= nValue;
- aStatusbarItem[ OFFSET_STATUSBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
+ pStatusbarItem[ OFFSET_STATUSBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
bResult = true;
}
@@ -1307,7 +1279,8 @@ bool AddonsOptions_Impl::ReadMenuItem( std::u16string_view aMenuNodeName, Sequen
Sequence< Any > aMenuItemNodePropValues = GetProperties( GetPropertyNamesMenuItem( aAddonMenuItemTreeNode ) );
if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_TITLE ] >>= aStrValue ) && !aStrValue.isEmpty() )
{
- aMenuItem[ OFFSET_MENUITEM_TITLE ].Value <<= aStrValue;
+ auto pMenuItem = aMenuItem.getArray();
+ pMenuItem[ OFFSET_MENUITEM_TITLE ].Value <<= aStrValue;
OUString aRootSubMenuName( aAddonMenuItemTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
Sequence< OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
@@ -1322,18 +1295,18 @@ bool AddonsOptions_Impl::ReadMenuItem( std::u16string_view aMenuNodeName, Sequen
// A popup menu must have a title and can have a URL and ImageIdentifier
// Set the other property values to empty
- aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aPopupMenuURL;
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= OUString();
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aPopupMenuImageId;
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
+ pMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aPopupMenuURL;
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= OUString();
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aPopupMenuImageId;
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
// Continue to read the sub menu nodes
Sequence< Sequence< PropertyValue > > aSubMenuSeq;
OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
- for ( OUString& rName : aRootSubMenuNodeNames )
+ for ( OUString& rName : asNonConstRange(aRootSubMenuNodeNames) )
rName = aSubMenuRootNodeName + rName;
ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= aSubMenuSeq;
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= aSubMenuSeq;
bResult = true;
}
else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) && !aStrValue.isEmpty() )
@@ -1344,11 +1317,11 @@ bool AddonsOptions_Impl::ReadMenuItem( std::u16string_view aMenuNodeName, Sequen
aMenuItemNodePropValues[ OFFSET_MENUITEM_IMAGEIDENTIFIER ] >>= aMenuImageId;
ReadAndAssociateImages( aStrValue, aMenuImageId );
- aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_TARGET ];
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aMenuImageId;
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
+ pMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_TARGET ];
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aMenuImageId;
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value = aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
bResult = true;
}
@@ -1356,12 +1329,14 @@ bool AddonsOptions_Impl::ReadMenuItem( std::u16string_view aMenuNodeName, Sequen
else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) &&
aStrValue == SEPARATOR_URL )
{
+ auto pMenuItem = aMenuItem.getArray();
+
// Separator
- aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= OUString();
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= OUString();
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= OUString();
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
+ pMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= OUString();
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= OUString();
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= OUString();
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
bResult = true;
}
@@ -1378,7 +1353,8 @@ bool AddonsOptions_Impl::ReadPopupMenu( std::u16string_view aPopupMenuNodeName,
if (( aPopupMenuNodePropValues[ OFFSET_POPUPMENU_TITLE ] >>= aStrValue ) &&
!aStrValue.isEmpty() )
{
- aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Value <<= aStrValue;
+ auto pPopupMenu = aPopupMenu.getArray();
+ pPopupMenu[ OFFSET_POPUPMENU_TITLE ].Value <<= aStrValue;
OUString aRootSubMenuName( aAddonPopupMenuTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
Sequence< OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
@@ -1388,16 +1364,16 @@ bool AddonsOptions_Impl::ReadPopupMenu( std::u16string_view aPopupMenuNodeName,
// Set a unique prefixed Add-On popup menu URL so it can be identified later
OUString aPopupMenuURL = GeneratePrefixURL();
- aPopupMenu[ OFFSET_POPUPMENU_URL ].Value <<= aPopupMenuURL;
- aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Value = aPopupMenuNodePropValues[ OFFSET_POPUPMENU_CONTEXT ];
+ pPopupMenu[ OFFSET_POPUPMENU_URL ].Value <<= aPopupMenuURL;
+ pPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Value = aPopupMenuNodePropValues[ OFFSET_POPUPMENU_CONTEXT ];
// Continue to read the sub menu nodes
Sequence< Sequence< PropertyValue > > aSubMenuSeq;
OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
- for ( OUString& rName : aRootSubMenuNodeNames )
+ for ( OUString& rName : asNonConstRange(aRootSubMenuNodeNames) )
rName = aSubMenuRootNodeName + rName;
ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
- aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aSubMenuSeq;
+ pPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aSubMenuSeq;
bResult = true;
}
}
@@ -1405,6 +1381,7 @@ bool AddonsOptions_Impl::ReadPopupMenu( std::u16string_view aPopupMenuNodeName,
return bResult;
}
+// static
void AddonsOptions_Impl::AppendPopupMenu( Sequence< PropertyValue >& rTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu )
{
Sequence< Sequence< PropertyValue > > aTargetSubMenuSeq;
@@ -1415,9 +1392,10 @@ void AddonsOptions_Impl::AppendPopupMenu( Sequence< PropertyValue >& rTargetPopu
{
sal_uInt32 nIndex = aTargetSubMenuSeq.getLength();
aTargetSubMenuSeq.realloc( nIndex + aSourceSubMenuSeq.getLength() );
- for ( Sequence<PropertyValue> const & rSeq : std::as_const(aSourceSubMenuSeq) )
- aTargetSubMenuSeq[nIndex++] = rSeq;
- rTargetPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aTargetSubMenuSeq;
+ auto pTargetSubMenuSeq = aTargetSubMenuSeq.getArray();
+ for (Sequence<PropertyValue> const& rSeq : aSourceSubMenuSeq)
+ pTargetSubMenuSeq[nIndex++] = rSeq;
+ rTargetPopupMenu.getArray()[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aTargetSubMenuSeq;
}
}
@@ -1435,19 +1413,23 @@ bool AddonsOptions_Impl::ReadToolBarItem( std::u16string_view aToolBarItemNodeNa
OUString aTitle;
if ( aURL == SEPARATOR_URL )
{
+ auto pToolBarItem = aToolBarItem.getArray();
+
// A separator toolbar item only needs a URL
- aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
- aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= OUString();
- aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= OUString();
- aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= OUString();
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= OUString();
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= OUString();
- aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
+ pToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
+ pToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= OUString();
+ pToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= OUString();
+ pToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= OUString();
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= OUString();
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= OUString();
+ pToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
bResult = true;
}
else if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TITLE ] >>= aTitle ) && !aTitle.isEmpty() )
{
+ auto pToolBarItem = aToolBarItem.getArray();
+
// A normal toolbar item must also have title => read the other properties;
OUString aImageId;
@@ -1455,17 +1437,17 @@ bool AddonsOptions_Impl::ReadToolBarItem( std::u16string_view aToolBarItemNodeNa
aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ] >>= aImageId;
ReadAndAssociateImages( aURL, aImageId );
- aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
- aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= aTitle;
- aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TARGET ];
- aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTEXT ];
- aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTROLTYPE ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
+ pToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= aTitle;
+ pToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TARGET ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTEXT ];
+ pToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value = aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTROLTYPE ];
// Configuration uses hyper for long. Therefore transform into sal_Int32
sal_Int64 nValue( 0 );
aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_WIDTH ] >>= nValue;
- aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
+ pToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
bResult = true;
}
@@ -1488,20 +1470,24 @@ bool AddonsOptions_Impl::ReadNotebookBarItem( std::u16string_view aNotebookBarIt
OUString aTitle;
if ( aURL == SEPARATOR_URL )
{
+ auto pNotebookBarItem = aNotebookBarItem.getArray();
+
// A separator toolbar item only needs a URL
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_URL ].Value <<= aURL;
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TITLE ].Value <<= OUString();
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TARGET ].Value <<= OUString();
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER ].Value <<= OUString();
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTEXT ].Value <<= OUString();
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ].Value <<= OUString();
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_STYLE ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_URL ].Value <<= aURL;
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TITLE ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TARGET ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTEXT ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ].Value <<= OUString();
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_STYLE ].Value <<= OUString();
bResult = true;
}
else if (( aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_TITLE ] >>= aTitle ) && !aTitle.isEmpty() )
{
+ auto pNotebookBarItem = aNotebookBarItem.getArray();
+
// A normal toolbar item must also have title => read the other properties;
OUString aImageId;
@@ -1509,18 +1495,18 @@ bool AddonsOptions_Impl::ReadNotebookBarItem( std::u16string_view aNotebookBarIt
aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER ] >>= aImageId;
ReadAndAssociateImages( aURL, aImageId );
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_URL ].Value <<= aURL;
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TITLE ].Value <<= aTitle;
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TARGET ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_TARGET ];
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTEXT ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_CONTEXT ];
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ];
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_URL ].Value <<= aURL;
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TITLE ].Value <<= aTitle;
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_TARGET ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_TARGET ];
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTEXT ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_CONTEXT ];
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_CONTROLTYPE ];
// Configuration uses hyper for long. Therefore transform into sal_Int32
sal_Int64 nValue( 0 );
aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_WIDTH ] >>= nValue;
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
- aNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_STYLE ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_STYLE ];
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
+ pNotebookBarItem[ OFFSET_NOTEBOOKBARITEM_STYLE ].Value = aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_STYLE ];
bResult = true;
}
@@ -1532,14 +1518,15 @@ bool AddonsOptions_Impl::ReadNotebookBarItem( std::u16string_view aNotebookBarIt
void AddonsOptions_Impl::ReadSubMenuEntries( const Sequence< OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenuSeq )
{
Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
+ auto pMenuItem = aMenuItem.getArray();
// Init the property value sequence
- aMenuItem[ OFFSET_MENUITEM_URL ].Name = PROPERTYNAME_URL;
- aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = PROPERTYNAME_TITLE;
- aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = PROPERTYNAME_TARGET;
- aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = PROPERTYNAME_IMAGEIDENTIFIER;
- aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = PROPERTYNAME_CONTEXT;
- aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = PROPERTYNAME_SUBMENU; // Submenu set!
+ pMenuItem[ OFFSET_MENUITEM_URL ].Name = PROPERTYNAME_URL;
+ pMenuItem[ OFFSET_MENUITEM_TITLE ].Name = PROPERTYNAME_TITLE;
+ pMenuItem[ OFFSET_MENUITEM_TARGET ].Name = PROPERTYNAME_TARGET;
+ pMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = PROPERTYNAME_IMAGEIDENTIFIER;
+ pMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = PROPERTYNAME_CONTEXT;
+ pMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = PROPERTYNAME_SUBMENU; // Submenu set!
sal_uInt32 nIndex = 0;
sal_uInt32 nCount = aSubMenuNodeNames.getLength();
@@ -1549,7 +1536,7 @@ void AddonsOptions_Impl::ReadSubMenuEntries( const Sequence< OUString >& aSubMen
{
sal_uInt32 nSubMenuCount = rSubMenuSeq.getLength() + 1;
rSubMenuSeq.realloc( nSubMenuCount );
- rSubMenuSeq[nIndex++] = aMenuItem;
+ rSubMenuSeq.getArray()[nIndex++] = aMenuItem;
}
}
}
@@ -1561,12 +1548,14 @@ bool AddonsOptions_Impl::HasAssociatedImages( const OUString& aURL )
return ( pIter != m_aImageManager.end() );
}
+// static
void AddonsOptions_Impl::SubstituteVariables( OUString& aURL )
{
aURL = comphelper::getExpandedUri(
comphelper::getProcessComponentContext(), aURL);
}
+// static
BitmapEx AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
{
BitmapEx aImage;
@@ -1578,7 +1567,7 @@ BitmapEx AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
Graphic aGraphic;
GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
- rGF.ImportGraphic( aGraphic, OUString(), *pStream );
+ rGF.ImportGraphic( aGraphic, u"", *pStream );
BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
@@ -1586,7 +1575,7 @@ BitmapEx AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
if ( !aBmpSize.IsEmpty() )
{
// Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
- if( !aBitmapEx.IsTransparent() )
+ if( !aBitmapEx.IsAlpha() )
aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
aImage = aBitmapEx;
@@ -1608,7 +1597,7 @@ void AddonsOptions_Impl::ReadAndAssociateImages( const OUString& aURL, const OUS
// Loop to create the two possible image names and try to read the bitmap files
static const char* aExtArray[] = { "_16", "_26" };
- for ( size_t i = 0; i < SAL_N_ELEMENTS(aExtArray); i++ )
+ for ( size_t i = 0; i < std::size(aExtArray); i++ )
{
OUStringBuffer aFileURL( aImageURL );
aFileURL.appendAscii( aExtArray[i] );
@@ -1665,7 +1654,8 @@ std::unique_ptr<AddonsOptions_Impl::ImageEntry> AddonsOptions_Impl::ReadImageDat
return pEntry;
}
-bool AddonsOptions_Impl::CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const
+// static
+bool AddonsOptions_Impl::CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq )
{
bool bResult = false;
@@ -1675,7 +1665,7 @@ bool AddonsOptions_Impl::CreateImageFromSequence( BitmapEx& rImage, Sequence< sa
ReadDIBBitmapEx(rImage, aMemStream);
- if( !rImage.IsTransparent() )
+ if( !rImage.IsAlpha() )
{
// Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
rImage = BitmapEx( rImage.GetBitmap(), COL_LIGHTMAGENTA );
@@ -1690,14 +1680,15 @@ bool AddonsOptions_Impl::CreateImageFromSequence( BitmapEx& rImage, Sequence< sa
Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesMenuItem( std::u16string_view aPropertyRootNode ) const
{
Sequence< OUString > lResult( PROPERTYCOUNT_MENUITEM );
+ auto plResult = lResult.getArray();
// Create property names dependent from the root node name
- lResult[OFFSET_MENUITEM_URL] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
- lResult[OFFSET_MENUITEM_TITLE] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
- lResult[OFFSET_MENUITEM_IMAGEIDENTIFIER] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER ];
- lResult[OFFSET_MENUITEM_TARGET] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
- lResult[OFFSET_MENUITEM_CONTEXT] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
- lResult[OFFSET_MENUITEM_SUBMENU] = aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ];
+ plResult[OFFSET_MENUITEM_URL] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
+ plResult[OFFSET_MENUITEM_TITLE] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
+ plResult[OFFSET_MENUITEM_IMAGEIDENTIFIER] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER ];
+ plResult[OFFSET_MENUITEM_TARGET] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
+ plResult[OFFSET_MENUITEM_CONTEXT] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
+ plResult[OFFSET_MENUITEM_SUBMENU] = aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ];
return lResult;
}
@@ -1706,11 +1697,12 @@ Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesPopupMenu( std::u16stri
{
// The URL is automatically set and not read from the configuration.
Sequence< OUString > lResult( PROPERTYCOUNT_POPUPMENU-1 );
+ auto plResult = lResult.getArray();
// Create property names dependent from the root node name
- lResult[OFFSET_POPUPMENU_TITLE] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
- lResult[OFFSET_POPUPMENU_CONTEXT] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
- lResult[OFFSET_POPUPMENU_SUBMENU] = aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ];
+ plResult[OFFSET_POPUPMENU_TITLE] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
+ plResult[OFFSET_POPUPMENU_CONTEXT] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
+ plResult[OFFSET_POPUPMENU_SUBMENU] = aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ];
return lResult;
}
@@ -1718,15 +1710,16 @@ Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesPopupMenu( std::u16stri
Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesToolBarItem( std::u16string_view aPropertyRootNode ) const
{
Sequence< OUString > lResult( PROPERTYCOUNT_TOOLBARITEM );
+ auto plResult = lResult.getArray();
// Create property names dependent from the root node name
- lResult[0] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
- lResult[1] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
- lResult[2] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER];
- lResult[3] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
- lResult[4] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
- lResult[5] = aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ];
- lResult[6] = aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ];
+ plResult[0] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
+ plResult[1] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
+ plResult[2] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER];
+ plResult[3] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
+ plResult[4] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
+ plResult[5] = aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ];
+ plResult[6] = aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ];
return lResult;
}
@@ -1734,16 +1727,17 @@ Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesToolBarItem( std::u16st
Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesNotebookBarItem( std::u16string_view aPropertyRootNode ) const
{
Sequence< OUString > lResult( PROPERTYCOUNT_NOTEBOOKBARITEM );
+ auto plResult = lResult.getArray();
// Create property names dependent from the root node name
- lResult[0] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
- lResult[1] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
- lResult[2] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER];
- lResult[3] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
- lResult[4] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
- lResult[5] = aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ];
- lResult[6] = aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ];
- lResult[7] = aPropertyRootNode + m_aPropNames[ INDEX_STYLE ];
+ plResult[0] = aPropertyRootNode + m_aPropNames[ INDEX_URL ];
+ plResult[1] = aPropertyRootNode + m_aPropNames[ INDEX_TITLE ];
+ plResult[2] = aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER];
+ plResult[3] = aPropertyRootNode + m_aPropNames[ INDEX_TARGET ];
+ plResult[4] = aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ];
+ plResult[5] = aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ];
+ plResult[6] = aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ];
+ plResult[7] = aPropertyRootNode + m_aPropNames[ INDEX_STYLE ];
return lResult;
}
@@ -1752,15 +1746,16 @@ Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesStatusbarItem(
std::u16string_view aPropertyRootNode ) const
{
Sequence< OUString > lResult( PROPERTYCOUNT_STATUSBARITEM );
+ auto plResult = lResult.getArray();
- lResult[0] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
- lResult[1] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
- lResult[2] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
- lResult[3] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_ALIGN ] );
- lResult[4] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_AUTOSIZE ] );
- lResult[5] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_OWNERDRAW ] );
- lResult[6] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_MANDATORY ] );
- lResult[7] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] );
+ plResult[0] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
+ plResult[1] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
+ plResult[2] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
+ plResult[3] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_ALIGN ] );
+ plResult[4] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_AUTOSIZE ] );
+ plResult[5] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_OWNERDRAW ] );
+ plResult[6] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_MANDATORY ] );
+ plResult[7] = OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] );
return lResult;
}
@@ -1768,16 +1763,17 @@ Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesStatusbarItem(
Sequence< OUString > AddonsOptions_Impl::GetPropertyNamesImages( std::u16string_view aPropertyRootNode ) const
{
Sequence< OUString > lResult( PROPERTYCOUNT_IMAGES );
+ auto plResult = lResult.getArray();
// Create property names dependent from the root node name
- lResult[0] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL ];
- lResult[1] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG ];
- lResult[2] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ];
- lResult[3] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ];
- lResult[4] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ];
- lResult[5] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ];
- lResult[6] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL];
- lResult[7] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ];
+ plResult[0] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL ];
+ plResult[1] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG ];
+ plResult[2] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ];
+ plResult[3] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ];
+ plResult[4] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ];
+ plResult[5] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ];
+ plResult[6] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL];
+ plResult[7] = aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ];
return lResult;
}
diff --git a/framework/source/fwe/classes/framelistanalyzer.cxx b/framework/source/fwe/classes/framelistanalyzer.cxx
index 55edf314703c..d524d23fdf2f 100644
--- a/framework/source/fwe/classes/framelistanalyzer.cxx
+++ b/framework/source/fwe/classes/framelistanalyzer.cxx
@@ -29,7 +29,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <comphelper/processfactory.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
namespace framework{
diff --git a/framework/source/fwe/classes/fwkresid.cxx b/framework/source/fwe/classes/fwkresid.cxx
index 00bc8232370f..e9a1d639d386 100644
--- a/framework/source/fwe/classes/fwkresid.cxx
+++ b/framework/source/fwe/classes/fwkresid.cxx
@@ -18,8 +18,7 @@
*/
#include <classes/fwkresid.hxx>
-#include <unotools/resmgr.hxx>
-OUString FwkResId(const char* pId) { return Translate::get(pId, Translate::Create("fwk")); }
+OUString FwkResId(TranslateId aId) { return Translate::get(aId, Translate::Create("fwk")); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/fwe/classes/imagewrapper.cxx b/framework/source/fwe/classes/imagewrapper.cxx
deleted file mode 100644
index b95bbbc34e01..000000000000
--- a/framework/source/fwe/classes/imagewrapper.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <classes/imagewrapper.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/bitmapex.hxx>
-#include <vcl/BitmapTools.hxx>
-#include <tools/stream.hxx>
-#include <vcl/dibtools.hxx>
-
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
-
-namespace framework
-{
-
-static Sequence< sal_Int8 > const & impl_getStaticIdentifier()
-{
- static const sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 };
- static css::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16);
- return seqID;
-}
-
-ImageWrapper::ImageWrapper( const Image& aImage ) : m_aImage( aImage )
-{
-}
-
-ImageWrapper::~ImageWrapper()
-{
-}
-
-Sequence< sal_Int8 > const & ImageWrapper::GetUnoTunnelId()
-{
- return impl_getStaticIdentifier();
-}
-
-// XBitmap
-css::awt::Size SAL_CALL ImageWrapper::getSize()
-{
- SolarMutexGuard aGuard;
-
- BitmapEx aBitmapEx( m_aImage.GetBitmapEx() );
- Size aBitmapSize( aBitmapEx.GetSizePixel() );
-
- return css::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() );
-}
-
-Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB()
-{
- SolarMutexGuard aGuard;
-
- SvMemoryStream aMem;
- WriteDIB(m_aImage.GetBitmapEx().GetBitmap(), aMem, false, true);
- return Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
-}
-
-Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB()
-{
- SolarMutexGuard aGuard;
-
- return vcl::bitmap::GetMaskDIB(m_aImage.GetBitmapEx());
-}
-
-// XUnoTunnel
-sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier )
-{
- if ( aIdentifier == impl_getStaticIdentifier() )
- return reinterpret_cast< sal_Int64 >( this );
- else
- return 0;
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/fwe/classes/rootactiontriggercontainer.cxx b/framework/source/fwe/classes/rootactiontriggercontainer.cxx
index 4181011db25a..1493f08bf429 100644
--- a/framework/source/fwe/classes/rootactiontriggercontainer.cxx
+++ b/framework/source/fwe/classes/rootactiontriggercontainer.cxx
@@ -21,10 +21,12 @@
#include <classes/actiontriggercontainer.hxx>
#include <classes/actiontriggerpropertyset.hxx>
#include <classes/actiontriggerseparatorpropertyset.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <framework/actiontriggerhelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
using namespace cppu;
@@ -36,18 +38,11 @@ using namespace com::sun::star::beans;
namespace framework
{
-static Sequence< sal_Int8 > const & impl_getStaticIdentifier()
-{
- static const sal_uInt8 pGUID[16] = { 0x17, 0x0F, 0xA2, 0xC9, 0xCA, 0x50, 0x4A, 0xD3, 0xA6, 0x3B, 0x39, 0x99, 0xC5, 0x96, 0x43, 0x27 };
- static css::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16);
- return seqID;
-}
-
-RootActionTriggerContainer::RootActionTriggerContainer( const Menu* pMenu, const OUString* pMenuIdentifier ) :
- PropertySetContainer()
- , m_bContainerCreated( false )
- , m_pMenu( pMenu )
- , m_pMenuIdentifier( pMenuIdentifier )
+RootActionTriggerContainer::RootActionTriggerContainer(css::uno::Reference<css::awt::XPopupMenu> xMenu,
+ const OUString* pMenuIdentifier)
+ : m_bContainerCreated(false)
+ , m_xMenu(std::move(xMenu))
+ , m_pMenuIdentifier(pMenuIdentifier)
{
}
@@ -62,7 +57,6 @@ Any SAL_CALL RootActionTriggerContainer::queryInterface( const Type& aType )
aType ,
static_cast< XMultiServiceFactory* >(this),
static_cast< XServiceInfo* >(this),
- static_cast< XUnoTunnel* >(this),
static_cast< XTypeProvider* >(this),
static_cast< XNamed* >(this));
@@ -74,12 +68,12 @@ Any SAL_CALL RootActionTriggerContainer::queryInterface( const Type& aType )
return PropertySetContainer::queryInterface( aType );
}
-void SAL_CALL RootActionTriggerContainer::acquire() throw ()
+void SAL_CALL RootActionTriggerContainer::acquire() noexcept
{
PropertySetContainer::acquire();
}
-void SAL_CALL RootActionTriggerContainer::release() throw ()
+void SAL_CALL RootActionTriggerContainer::release() noexcept
{
PropertySetContainer::release();
}
@@ -104,12 +98,9 @@ Reference< XInterface > SAL_CALL RootActionTriggerContainer::createInstanceWithA
Sequence< OUString > SAL_CALL RootActionTriggerContainer::getAvailableServiceNames()
{
- Sequence< OUString > aSeq( 3 );
-
- aSeq[0] = SERVICENAME_ACTIONTRIGGER;
- aSeq[1] = SERVICENAME_ACTIONTRIGGERCONTAINER;
- aSeq[2] = SERVICENAME_ACTIONTRIGGERSEPARATOR;
-
+ Sequence< OUString > aSeq{ SERVICENAME_ACTIONTRIGGER,
+ SERVICENAME_ACTIONTRIGGERCONTAINER,
+ SERVICENAME_ACTIONTRIGGERSEPARATOR };
return aSeq;
}
@@ -152,11 +143,8 @@ sal_Int32 SAL_CALL RootActionTriggerContainer::getCount()
if ( !m_bContainerCreated )
{
- if ( m_pMenu )
- {
- SolarMutexGuard aSolarMutexGuard;
- return m_pMenu->GetItemCount();
- }
+ if ( m_xMenu )
+ return m_xMenu->getItemCount();
else
return 0;
}
@@ -184,12 +172,8 @@ Type SAL_CALL RootActionTriggerContainer::getElementType()
sal_Bool SAL_CALL RootActionTriggerContainer::hasElements()
{
- if ( m_pMenu )
- {
- SolarMutexGuard aSolarMutexGuard;
- return ( m_pMenu->GetItemCount() > 0 );
- }
-
+ if (m_xMenu)
+ return m_xMenu->getItemCount() > 0;
return false;
}
@@ -209,15 +193,6 @@ Sequence< OUString > SAL_CALL RootActionTriggerContainer::getSupportedServiceNam
return { SERVICENAME_ACTIONTRIGGERCONTAINER };
}
-// XUnoTunnel
-sal_Int64 SAL_CALL RootActionTriggerContainer::getSomething( const Sequence< sal_Int8 >& aIdentifier )
-{
- if ( aIdentifier == impl_getStaticIdentifier() )
- return reinterpret_cast< sal_Int64 >( this );
- else
- return 0;
-}
-
// XTypeProvider
Sequence< Type > SAL_CALL RootActionTriggerContainer::getTypes()
{
@@ -243,8 +218,7 @@ void RootActionTriggerContainer::FillContainer()
{
m_bContainerCreated = true;
ActionTriggerHelper::FillActionTriggerContainerFromMenu(
- this,
- m_pMenu );
+ this, m_xMenu);
}
OUString RootActionTriggerContainer::getName()
{
diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx
index c6fe0bf030f1..5a1cc0d716d5 100644
--- a/framework/source/fwe/classes/sfxhelperfunctions.cxx
+++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx
@@ -20,6 +20,8 @@
#include <framework/sfxhelperfunctions.hxx>
#include <framework/ContextChangeEventMultiplexerTunnel.hxx>
#include <helper/mischelper.hxx>
+#include <svtools/toolboxcontroller.hxx>
+#include <svtools/statusbarcontroller.hxx>
static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = nullptr;
static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = nullptr;
@@ -41,7 +43,7 @@ pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator( pfunc_setToolBoxC
return pOldSetToolBoxControllerCreator;
}
-svt::ToolboxController* CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL )
+rtl::Reference<svt::ToolboxController> CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL )
{
pfunc_setToolBoxControllerCreator pFactory = nullptr;
{
@@ -63,7 +65,7 @@ pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStat
return pOldSetStatusBarControllerCreator;
}
-svt::StatusbarController* CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL )
+rtl::Reference<svt::StatusbarController> CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL )
{
pfunc_setStatusBarControllerCreator pFactory = nullptr;
{
@@ -107,7 +109,7 @@ pfunc_createDockingWindow SetDockingWindowCreator( pfunc_createDockingWindow pNe
return pOldFunc;
}
-void CreateDockingWindow( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rResourceURL )
+void CreateDockingWindow( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL )
{
pfunc_createDockingWindow pFactory = nullptr;
{
@@ -128,7 +130,7 @@ pfunc_isDockingWindowVisible SetIsDockingWindowVisible( pfunc_isDockingWindowVis
return pOldFunc;
}
-bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rResourceURL )
+bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rResourceURL )
{
pfunc_isDockingWindowVisible pCall = nullptr;
{
@@ -144,10 +146,11 @@ bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rF
using namespace ::com::sun::star;
uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
- return GetFirstListenerWith_Impl(xEventFocus, rPredicate);
+ return GetFirstListenerWith_Impl(xComponentContext, xEventFocus, rPredicate);
}
}
diff --git a/framework/source/fwe/dispatch/interaction.cxx b/framework/source/fwe/dispatch/interaction.cxx
index 01411804fb8b..d0cf88e6f6f8 100644
--- a/framework/source/fwe/dispatch/interaction.cxx
+++ b/framework/source/fwe/dispatch/interaction.cxx
@@ -21,6 +21,7 @@
#include <framework/interaction.hxx>
#include <com/sun/star/document/XInteractionFilterSelect.hpp>
#include <com/sun/star/document/NoSuchFilterRequest.hpp>
+#include <utility>
using namespace ::com::sun::star;
@@ -70,7 +71,6 @@ class ContinuationFilterSelect : public comphelper::OInteraction< css::document:
// initialize continuation with right start values
ContinuationFilterSelect::ContinuationFilterSelect()
- : m_sFilter( OUString() )
{
}
@@ -151,7 +151,7 @@ css::uno::Any SAL_CALL RequestFilterSelect_Impl::getRequest()
css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL RequestFilterSelect_Impl::getContinuations()
{
- return { m_xAbort.get(), m_xFilter.get() };
+ return { m_xAbort, m_xFilter };
}
RequestFilterSelect::RequestFilterSelect( const OUString& sURL )
@@ -179,9 +179,9 @@ OUString RequestFilterSelect::getFilter() const
return mxImpl->getFilter();
}
-uno::Reference < task::XInteractionRequest > RequestFilterSelect::GetRequest()
+uno::Reference < task::XInteractionRequest > RequestFilterSelect::GetRequest() const
{
- return mxImpl.get();
+ return mxImpl;
}
namespace {
@@ -192,9 +192,9 @@ class InteractionRequest_Impl : public ::cppu::WeakImplHelper< css::task::XInter
uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > m_lContinuations;
public:
- InteractionRequest_Impl( const css::uno::Any& aRequest,
+ InteractionRequest_Impl( css::uno::Any aRequest,
const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& lContinuations )
- : m_aRequest(aRequest), m_lContinuations(lContinuations)
+ : m_aRequest(std::move(aRequest)), m_lContinuations(lContinuations)
{
}
diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx
index aca142bcee8e..88edd70beb79 100644
--- a/framework/source/fwe/helper/actiontriggerhelper.cxx
+++ b/framework/source/fwe/helper/actiontriggerhelper.cxx
@@ -20,16 +20,18 @@
#include <framework/actiontriggerhelper.hxx>
#include <classes/actiontriggerseparatorpropertyset.hxx>
#include <classes/rootactiontriggercontainer.hxx>
-#include <classes/imagewrapper.hxx>
#include <framework/addonsoptions.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/awt/XPopupMenu.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/awt/XBitmap.hpp>
-#include <vcl/svapp.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <tools/stream.hxx>
-#include <cppuhelper/weak.hxx>
#include <vcl/dibtools.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
const sal_uInt16 START_ITEMID = 1000;
@@ -94,7 +96,8 @@ static void GetMenuItemAttributes( const Reference< XPropertySet >& xActionTrigg
}
}
-static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Reference< XIndexContainer >& xActionTriggerContainer )
+static void InsertSubMenuItems(const Reference<XPopupMenu>& rSubMenu, sal_uInt16& nItemId,
+ const Reference<XIndexContainer>& xActionTriggerContainer)
{
if ( !xActionTriggerContainer.is() )
return;
@@ -113,7 +116,7 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
{
// Separator
SolarMutexGuard aGuard;
- pSubMenu->InsertSeparator();
+ rSubMenu->insertSeparator(i);
}
else
{
@@ -137,13 +140,13 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
// command url but uses the item id as a unique identifier. These entries
// got a special url during conversion from menu=>actiontriggercontainer.
// Now we have to extract this special url and set the correct item id!!!
- nNewItemId = static_cast<sal_uInt16>(aCommandURL.copy( nIndex+aSlotURL.getLength() ).toInt32());
- pSubMenu->InsertItem( nNewItemId, aLabel );
+ nNewItemId = static_cast<sal_uInt16>(o3tl::toInt32(aCommandURL.subView( nIndex+aSlotURL.getLength() )));
+ rSubMenu->insertItem(nNewItemId, aLabel, 0, i);
}
else
{
- pSubMenu->InsertItem( nNewItemId, aLabel );
- pSubMenu->SetItemCommand( nNewItemId, aCommandURL );
+ rSubMenu->insertItem(nNewItemId, aLabel, 0, i);
+ rSubMenu->setCommand(nNewItemId, aCommandURL);
}
// handle bitmap
@@ -151,29 +154,18 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
{
bool bImageSet = false;
- Reference< XUnoTunnel > xUnoTunnel( xBitmap, UNO_QUERY );
- if ( xUnoTunnel.is() )
+ Reference<css::graphic::XGraphic> xGraphic(xBitmap, UNO_QUERY);
+ if (xGraphic.is())
{
- // Try to get implementation pointer through XUnoTunnel
- sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::GetUnoTunnelId() );
- if ( nPointer )
- {
- // This is our own optimized implementation of menu images!
- ImageWrapper* pImageWrapper = reinterpret_cast< ImageWrapper * >( nPointer );
- const Image& aMenuImage = pImageWrapper->GetImage();
-
- if ( !!aMenuImage )
- pSubMenu->SetItemImage( nNewItemId, aMenuImage );
-
- bImageSet = true;
- }
+ // we can take the optimized route if XGraphic is supported
+ rSubMenu->setItemImage(nNewItemId, xGraphic, false);
+ bImageSet = true;
}
if ( !bImageSet )
{
// This is an unknown implementation of a XBitmap interface. We have to
// use a more time consuming way to build an Image!
- Image aImage;
BitmapEx aBitmap;
Sequence< sal_Int8 > aDIBSeq;
@@ -189,30 +181,28 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
Bitmap aMaskBitmap;
SvMemoryStream aMem( const_cast<sal_Int8 *>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ );
ReadDIB(aMaskBitmap, aMem, true);
- aImage = Image(BitmapEx(aBitmap.GetBitmap(), aMaskBitmap));
+ aBitmap = BitmapEx(aBitmap.GetBitmap(), aMaskBitmap);
}
- else
- aImage = Image( aBitmap );
- if ( !!aImage )
- pSubMenu->SetItemImage( nNewItemId, aImage );
+ if (!aBitmap.IsEmpty())
+ rSubMenu->setItemImage(nNewItemId, Graphic(aBitmap).GetXGraphic(), false);
}
}
else
{
// Support add-on images for context menu interceptors
- Image aImage(aAddonOptions.GetImageFromURL(aCommandURL, false, true));
- if ( !!aImage )
- pSubMenu->SetItemImage( nNewItemId, aImage );
+ BitmapEx aBitmap(aAddonOptions.GetImageFromURL(aCommandURL, false, true));
+ if (!aBitmap.IsEmpty())
+ rSubMenu->setItemImage(nNewItemId, Graphic(aBitmap).GetXGraphic(), false);
}
if ( xSubContainer.is() )
{
- VclPtr<PopupMenu> pNewSubMenu = VclPtr<PopupMenu>::Create();
+ rtl::Reference xNewSubMenu(new VCLXPopupMenu);
// Sub menu (recursive call CreateSubMenu )
- InsertSubMenuItems( pNewSubMenu, nItemId, xSubContainer );
- pSubMenu->SetPopupMenu( nNewItemId, pNewSubMenu );
+ InsertSubMenuItems(xNewSubMenu, nItemId, xSubContainer);
+ rSubMenu->setPopupMenu(nNewItemId, xNewSubMenu);
}
}
}
@@ -236,7 +226,9 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
// implementation helper ( ActionTrigger => menu )
/// @throws RuntimeException
-static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const Menu* pMenu, const Reference< XIndexContainer >& rActionTriggerContainer )
+static Reference< XPropertySet > CreateActionTrigger(sal_uInt16 nItemId,
+ const Reference<XPopupMenu>& rMenu,
+ const Reference<XIndexContainer>& rActionTriggerContainer)
{
Reference< XPropertySet > xPropSet;
@@ -251,11 +243,11 @@ static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const
try
{
// Retrieve the menu attributes and set them in our PropertySet
- OUString aLabel = pMenu->GetItemText( nItemId );
+ OUString aLabel = rMenu->getItemText(nItemId);
a <<= aLabel;
xPropSet->setPropertyValue("Text", a );
- OUString aCommandURL = pMenu->GetItemCommand( nItemId );
+ OUString aCommandURL = rMenu->getCommand(nItemId);
if ( aCommandURL.isEmpty() )
{
@@ -265,11 +257,9 @@ static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const
a <<= aCommandURL;
xPropSet->setPropertyValue("CommandURL", a );
- Image aImage = pMenu->GetItemImage( nItemId );
- if ( !!aImage )
+ Reference<XBitmap> xBitmap(rMenu->getItemImage(nItemId), UNO_QUERY);
+ if (xBitmap.is())
{
- // We use our own optimized XBitmap implementation
- Reference< XBitmap > xBitmap( static_cast< cppu::OWeakObject* >( new ImageWrapper( aImage )), UNO_QUERY );
a <<= xBitmap;
xPropSet->setPropertyValue("Image", a );
}
@@ -310,21 +300,22 @@ static Reference< XIndexContainer > CreateActionTriggerContainer( const Referenc
return Reference< XIndexContainer >();
}
-static void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XIndexContainer > const & rActionTriggerContainer )
+static void FillActionTriggerContainerWithMenu(const Reference<XPopupMenu>& rMenu,
+ const Reference<XIndexContainer>& rActionTriggerContainer)
{
SolarMutexGuard aGuard;
- for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ )
+ for (sal_uInt16 nPos = 0, nCount = rMenu->getItemCount(); nPos < nCount; ++nPos)
{
- sal_uInt16 nItemId = pMenu->GetItemId( nPos );
- ::MenuItemType nType = pMenu->GetItemType( nPos );
+ sal_uInt16 nItemId = rMenu->getItemId(nPos);
+ css::awt::MenuItemType nType = rMenu->getItemType(nPos);
try
{
Any a;
Reference< XPropertySet > xPropSet;
- if ( nType == ::MenuItemType::SEPARATOR )
+ if (nType == css::awt::MenuItemType_SEPARATOR)
{
xPropSet = CreateActionTriggerSeparator( rActionTriggerContainer );
@@ -333,20 +324,20 @@ static void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XI
}
else
{
- xPropSet = CreateActionTrigger( nItemId, pMenu, rActionTriggerContainer );
+ xPropSet = CreateActionTrigger(nItemId, rMenu, rActionTriggerContainer);
a <<= xPropSet;
rActionTriggerContainer->insertByIndex( nPos, a );
- PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId );
- if ( pPopupMenu )
+ css::uno::Reference<XPopupMenu> xPopupMenu = rMenu->getPopupMenu(nItemId);
+ if (xPopupMenu.is())
{
// recursive call to build next sub menu
Reference< XIndexContainer > xSubContainer = CreateActionTriggerContainer( rActionTriggerContainer );
a <<= xSubContainer;
xPropSet->setPropertyValue("SubContainer", a );
- FillActionTriggerContainerWithMenu( pPopupMenu, xSubContainer );
+ FillActionTriggerContainerWithMenu(xPopupMenu, xSubContainer);
}
}
}
@@ -357,27 +348,27 @@ static void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XI
}
void ActionTriggerHelper::CreateMenuFromActionTriggerContainer(
- Menu* pNewMenu,
- const Reference< XIndexContainer >& rActionTriggerContainer )
+ const Reference<XPopupMenu>& rNewMenu,
+ const Reference<XIndexContainer>& rActionTriggerContainer)
{
sal_uInt16 nItemId = START_ITEMID;
if ( rActionTriggerContainer.is() )
- InsertSubMenuItems( pNewMenu, nItemId, rActionTriggerContainer );
+ InsertSubMenuItems(rNewMenu, nItemId, rActionTriggerContainer);
}
void ActionTriggerHelper::FillActionTriggerContainerFromMenu(
Reference< XIndexContainer > const & xActionTriggerContainer,
- const Menu* pMenu )
+ const css::uno::Reference<XPopupMenu>& rMenu)
{
- FillActionTriggerContainerWithMenu( pMenu, xActionTriggerContainer );
+ FillActionTriggerContainerWithMenu(rMenu, xActionTriggerContainer);
}
Reference< XIndexContainer > ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
- const Menu* pMenu,
+ const css::uno::Reference<XPopupMenu>& rMenu,
const OUString* pMenuIdentifier )
{
- return new RootActionTriggerContainer( pMenu, pMenuIdentifier );
+ return new RootActionTriggerContainer(rMenu, pMenuIdentifier);
}
}
diff --git a/framework/source/fwe/helper/documentundoguard.cxx b/framework/source/fwe/helper/documentundoguard.cxx
index 5f7d16041caa..f578d8682731 100644
--- a/framework/source/fwe/helper/documentundoguard.cxx
+++ b/framework/source/fwe/helper/documentundoguard.cxx
@@ -23,7 +23,7 @@
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace framework
{
@@ -31,7 +31,6 @@ namespace framework
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::document::XUndoManagerSupplier;
using ::com::sun::star::document::XUndoManager;
@@ -44,8 +43,6 @@ namespace framework
typedef ::cppu::WeakImplHelper < XUndoManagerListener
> UndoManagerContextListener_Base;
- namespace {
-
class UndoManagerContextListener : public UndoManagerContextListener_Base
{
public:
@@ -100,8 +97,6 @@ namespace framework
bool m_documentDisposed;
};
- }
-
void SAL_CALL UndoManagerContextListener::undoActionAdded( const UndoManagerEvent& )
{
// not interested in
@@ -162,60 +157,37 @@ namespace framework
m_documentDisposed = true;
}
- //= DocumentUndoGuard_Data
-
- struct DocumentUndoGuard_Data
- {
- Reference< XUndoManager > xUndoManager;
- ::rtl::Reference< UndoManagerContextListener > pContextListener;
- };
+ //= DocumentUndoGuard
- namespace
+ DocumentUndoGuard::DocumentUndoGuard( const Reference< XInterface >& i_undoSupplierComponent )
{
-
- void lcl_init( DocumentUndoGuard_Data& i_data, const Reference< XInterface >& i_undoSupplierComponent )
+ try
{
- try
- {
- Reference< XUndoManagerSupplier > xUndoSupplier( i_undoSupplierComponent, UNO_QUERY );
- if ( xUndoSupplier.is() )
- i_data.xUndoManager.set( xUndoSupplier->getUndoManager(), css::uno::UNO_SET_THROW );
+ Reference< XUndoManagerSupplier > xUndoSupplier( i_undoSupplierComponent, UNO_QUERY );
+ if ( xUndoSupplier.is() )
+ mxUndoManager.set( xUndoSupplier->getUndoManager(), css::uno::UNO_SET_THROW );
- if ( i_data.xUndoManager.is() )
- i_data.pContextListener.set( new UndoManagerContextListener( i_data.xUndoManager ) );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("fwk");
- }
+ if ( mxUndoManager.is() )
+ mxContextListener.set( new UndoManagerContextListener( mxUndoManager ) );
}
-
- void lcl_restore( DocumentUndoGuard_Data& i_data )
+ catch( const Exception& )
{
- try
- {
- if ( i_data.pContextListener.is() )
- i_data.pContextListener->finish();
- i_data.pContextListener.clear();
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("fwk");
- }
+ DBG_UNHANDLED_EXCEPTION("fwk");
}
}
- //= DocumentUndoGuard
-
- DocumentUndoGuard::DocumentUndoGuard( const Reference< XInterface >& i_undoSupplierComponent )
- :m_xData( new DocumentUndoGuard_Data )
- {
- lcl_init( *m_xData, i_undoSupplierComponent );
- }
-
DocumentUndoGuard::~DocumentUndoGuard()
{
- lcl_restore( *m_xData );
+ try
+ {
+ if ( mxContextListener.is() )
+ mxContextListener->finish();
+ mxContextListener.clear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("fwk");
+ }
}
} // namespace framework
diff --git a/framework/source/fwe/helper/propertysetcontainer.cxx b/framework/source/fwe/helper/propertysetcontainer.cxx
index 5d129d36b01a..c766b40db56b 100644
--- a/framework/source/fwe/helper/propertysetcontainer.cxx
+++ b/framework/source/fwe/helper/propertysetcontainer.cxx
@@ -23,7 +23,7 @@
#include <cppuhelper/queryinterface.hxx>
#include <vcl/svapp.hxx>
-#define WRONG_TYPE_EXCEPTION "Only XPropertSet allowed!"
+constexpr OUString WRONG_TYPE_EXCEPTION = u"Only XPropertSet allowed!"_ustr;
using namespace cppu;
using namespace com::sun::star::uno;
@@ -35,8 +35,6 @@ namespace framework
{
PropertySetContainer::PropertySetContainer()
- : OWeakObject()
-
{
}
@@ -45,12 +43,12 @@ PropertySetContainer::~PropertySetContainer()
}
// XInterface
-void SAL_CALL PropertySetContainer::acquire() throw ()
+void SAL_CALL PropertySetContainer::acquire() noexcept
{
OWeakObject::acquire();
}
-void SAL_CALL PropertySetContainer::release() throw ()
+void SAL_CALL PropertySetContainer::release() noexcept
{
OWeakObject::release();
}
@@ -75,7 +73,7 @@ Any SAL_CALL PropertySetContainer::queryInterface( const Type& rType )
// XIndexContainer
void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::uno::Any& Element )
{
- SolarMutexGuard g;
+ std::unique_lock g(m_aMutex);
sal_Int32 nSize = m_aPropertySetVector.size();
@@ -103,7 +101,7 @@ void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::u
void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
{
- SolarMutexGuard g;
+ std::unique_lock g(m_aMutex);
if ( static_cast<sal_Int32>(m_aPropertySetVector.size()) <= nIndex )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
@@ -114,6 +112,8 @@ void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
// XIndexReplace
void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element )
{
+ std::unique_lock g(m_aMutex);
+
if ( static_cast<sal_Int32>(m_aPropertySetVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
@@ -132,14 +132,14 @@ void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::
// XIndexAccess
sal_Int32 SAL_CALL PropertySetContainer::getCount()
{
- SolarMutexGuard g;
+ std::unique_lock g(m_aMutex);
return m_aPropertySetVector.size();
}
Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
{
- SolarMutexGuard g;
+ std::unique_lock g(m_aMutex);
if ( static_cast<sal_Int32>(m_aPropertySetVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
@@ -150,7 +150,7 @@ Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
// XElementAccess
sal_Bool SAL_CALL PropertySetContainer::hasElements()
{
- SolarMutexGuard g;
+ std::unique_lock g(m_aMutex);
return !( m_aPropertySetVector.empty() );
}
diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx
index 5936d9133ff3..58c28f8f8ef9 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <config_features.h>
-
#include <framework/titlehelper.hxx>
#include <classes/fwkresid.hxx>
#include <strings.hrc>
@@ -28,8 +26,10 @@
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/frame/XModel3.hpp>
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <comphelper/configuration.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/bootstrap.hxx>
#include <unotools/mediadescriptor.hxx>
@@ -37,7 +37,7 @@
#include <rtl/ustrbuf.hxx>
#include <osl/mutex.hxx>
#include <tools/urlobj.hxx>
-#include <vcl/skia/SkiaHelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
@@ -47,59 +47,39 @@ using namespace css::frame;
namespace framework{
-TitleHelper::TitleHelper(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
- : ::cppu::BaseMutex ()
- , m_xContext (rxContext)
- , m_xOwner ()
- , m_xUntitledNumbers()
- , m_xSubTitle ()
+TitleHelper::TitleHelper(css::uno::Reference< css::uno::XComponentContext > xContext,
+ const css::uno::Reference< css::uno::XInterface >& xOwner,
+ const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers)
+ :
+ m_xContext (std::move(xContext))
+ , m_xOwner (xOwner)
+ , m_xUntitledNumbers(xNumbers)
, m_bExternalTitle (false)
- , m_sTitle ()
, m_nLeasedNumber (css::frame::UntitledNumbersConst::INVALID_NUMBER)
- , m_aListener (m_aMutex)
-{
-}
-
-TitleHelper::~TitleHelper()
-{
-}
-
-void TitleHelper::setOwner(const css::uno::Reference< css::uno::XInterface >& xOwner)
{
- // SYNCHRONIZED ->
- {
- osl::MutexGuard aLock(m_aMutex);
-
- m_xOwner = xOwner;
- }
- // <- SYNCHRONIZED
-
- css::uno::Reference< css::frame::XModel > xModel(xOwner, css::uno::UNO_QUERY);
- if (xModel.is ())
+ if (css::uno::Reference<css::frame::XModel> xModel{ xOwner, css::uno::UNO_QUERY })
{
impl_startListeningForModel (xModel);
- return;
}
-
- css::uno::Reference< css::frame::XController > xController(xOwner, css::uno::UNO_QUERY);
- if (xController.is ())
+ else if (css::uno::Reference<css::frame::XController> xController{ xOwner,
+ css::uno::UNO_QUERY })
{
impl_startListeningForController (xController);
- return;
}
-
- css::uno::Reference< css::frame::XFrame > xFrame(xOwner, css::uno::UNO_QUERY);
- if (xFrame.is ())
+ else if (css::uno::Reference<css::frame::XFrame> xFrame{ xOwner, css::uno::UNO_QUERY })
{
impl_startListeningForFrame (xFrame);
- return;
}
}
+TitleHelper::~TitleHelper()
+{
+}
+
OUString SAL_CALL TitleHelper::getTitle()
{
// SYNCHRONIZED ->
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// An external title will win always and disable all internal logic about
// creating/using a title value.
@@ -111,27 +91,20 @@ OUString SAL_CALL TitleHelper::getTitle()
if (!m_sTitle.isEmpty())
return m_sTitle;
- // Title seems to be unused till now ... do bootstraping
+ // Title seems to be unused till now ... do bootstrapping
+ aLock.unlock();
impl_updateTitle (true);
+ aLock.lock();
return m_sTitle;
// <- SYNCHRONIZED
}
-void TitleHelper::connectWithUntitledNumbers (const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers)
-{
- // SYNCHRONIZED ->
- osl::MutexGuard aLock(m_aMutex);
-
- m_xUntitledNumbers = xNumbers;
- // <- SYNCHRONIZED
-}
-
void SAL_CALL TitleHelper::setTitle(const OUString& sTitle)
{
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
m_bExternalTitle = true;
m_sTitle = sTitle;
@@ -143,14 +116,14 @@ void SAL_CALL TitleHelper::setTitle(const OUString& sTitle)
void SAL_CALL TitleHelper::addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
{
- // container is threadsafe by himself
- m_aListener.addInterface( cppu::UnoType<css::frame::XTitleChangeListener>::get(), xListener );
+ std::unique_lock aLock(m_aMutex);
+ m_aTitleChangeListeners.addInterface( aLock, xListener );
}
void SAL_CALL TitleHelper::removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
{
- // container is threadsafe by himself
- m_aListener.removeInterface( cppu::UnoType<css::frame::XTitleChangeListener>::get(), xListener );
+ std::unique_lock aLock(m_aMutex);
+ m_aTitleChangeListeners.removeInterface( aLock, xListener );
}
void SAL_CALL TitleHelper::titleChanged(const css::frame::TitleChangedEvent& aEvent)
@@ -158,9 +131,9 @@ void SAL_CALL TitleHelper::titleChanged(const css::frame::TitleChangedEvent& aEv
css::uno::Reference< css::frame::XTitle > xSubTitle;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- xSubTitle.set(m_xSubTitle.get (), css::uno::UNO_QUERY);
+ xSubTitle = m_xSubTitle;
}
// <- SYNCHRONIZED
@@ -180,9 +153,9 @@ void SAL_CALL TitleHelper::documentEventOccured(const css::document::DocumentEve
css::uno::Reference< css::frame::XModel > xOwner;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- xOwner.set(m_xOwner.get (), css::uno::UNO_QUERY);
+ xOwner.set(m_xOwner, css::uno::UNO_QUERY);
}
// <- SYNCHRONIZED
@@ -202,9 +175,9 @@ void SAL_CALL TitleHelper::frameAction(const css::frame::FrameActionEvent& aEven
css::uno::Reference< css::frame::XFrame > xOwner;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- xOwner.set(m_xOwner.get (), css::uno::UNO_QUERY);
+ xOwner.set(m_xOwner, css::uno::UNO_QUERY);
}
// <- SYNCHRONIZED
@@ -231,10 +204,10 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent)
::sal_Int32 nLeasedNumber;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
xOwner = m_xOwner;
- xNumbers.set(m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
+ xNumbers = m_xUntitledNumbers;
nLeasedNumber = m_nLeasedNumber;
}
// <- SYNCHRONIZED
@@ -242,6 +215,10 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent)
if ( ! xOwner.is ())
return;
+ css::uno::Reference< css::frame::XFrame > xFrame(xOwner, css::uno::UNO_QUERY);
+ if (xFrame.is())
+ xFrame->removeFrameActionListener(this);
+
if (xOwner != aEvent.Source)
return;
@@ -253,10 +230,10 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent)
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- m_xOwner = nullptr;
- m_sTitle = OUString ();
+ m_xOwner.clear();
+ m_sTitle.clear();
m_nLeasedNumber = css::frame::UntitledNumbersConst::INVALID_NUMBER;
}
// <- SYNCHRONIZED
@@ -267,7 +244,7 @@ void TitleHelper::impl_sendTitleChangedEvent ()
css::uno::Reference<css::uno::XInterface> xOwner;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
xOwner = m_xOwner;
}
@@ -278,61 +255,68 @@ void TitleHelper::impl_sendTitleChangedEvent ()
if( ! aEvent.Source.is() )
return;
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListener.getContainer( cppu::UnoType<css::frame::XTitleChangeListener>::get());
- if ( ! pContainer)
- return;
-
- ::cppu::OInterfaceIteratorHelper pIt( *pContainer );
+ std::unique_lock aLock(m_aMutex);
+ comphelper::OInterfaceIteratorHelper4 pIt( aLock, m_aTitleChangeListeners );
while ( pIt.hasMoreElements() )
{
+ aLock.unlock();
try
{
- static_cast<css::frame::XTitleChangeListener*>(pIt.next())->titleChanged( aEvent );
+ uno::Reference<css::frame::XTitleChangeListener> i = pIt.next();
+ i->titleChanged( aEvent );
}
catch(const css::uno::Exception&)
{
- pIt.remove();
+ aLock.lock();
+ pIt.remove(aLock);
+ aLock.unlock();
}
+ aLock.lock();
}
}
void TitleHelper::impl_updateTitle (bool init)
{
- css::uno::Reference< css::frame::XModel > xModel;
- css::uno::Reference< css::frame::XController > xController;
- css::uno::Reference< css::frame::XFrame > xFrame;
+ css::uno::Reference<css::uno::XInterface> xOwner;
+
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- xModel.set (m_xOwner.get(), css::uno::UNO_QUERY);
- xController.set(m_xOwner.get(), css::uno::UNO_QUERY);
- xFrame.set (m_xOwner.get(), css::uno::UNO_QUERY);
+ xOwner = m_xOwner;
}
// <- SYNCHRONIZED
- if (xModel.is ())
+ if (css::uno::Reference<css::frame::XModel3> xModel{ xOwner, css::uno::UNO_QUERY })
{
impl_updateTitleForModel (xModel, init);
}
- else if (xController.is ())
+ else if (css::uno::Reference<css::frame::XController> xController{ xOwner,
+ css::uno::UNO_QUERY })
{
impl_updateTitleForController (xController, init);
}
- else if (xFrame.is ())
+ else if (css::uno::Reference<css::frame::XFrame> xFrame{ xOwner, css::uno::UNO_QUERY })
{
impl_updateTitleForFrame (xFrame, init);
}
}
-void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel >& xModel, bool init)
+static OUString getURLFromModel(const css::uno::Reference< css::frame::XModel3 >& xModel)
+{
+ if (css::uno::Reference<css::frame::XStorable> xURLProvider{ xModel, css::uno::UNO_QUERY })
+ return xURLProvider->getLocation();
+ return {};
+}
+
+void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel3 >& xModel, bool init)
{
css::uno::Reference< css::uno::XInterface > xOwner;
css::uno::Reference< css::frame::XUntitledNumbers > xNumbers;
::sal_Int32 nLeasedNumber;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// external title won't be updated internally!
// It has to be set from outside new.
@@ -340,7 +324,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
return;
xOwner = m_xOwner;
- xNumbers.set (m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
+ xNumbers = m_xUntitledNumbers;
nLeasedNumber = m_nLeasedNumber;
}
// <- SYNCHRONIZED
@@ -353,24 +337,27 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
return;
OUString sTitle;
- OUString sURL;
-
- css::uno::Reference< css::frame::XStorable > xURLProvider(xModel , css::uno::UNO_QUERY);
- if (xURLProvider.is())
- sURL = xURLProvider->getLocation ();
- utl::MediaDescriptor aDescriptor(xModel->getArgs());
- const OUString sSuggestedSaveAsName = aDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME(), OUString());
+ utl::MediaDescriptor aDescriptor(
+ xModel->getArgs2({ utl::MediaDescriptor::PROP_DOCUMENTTITLE,
+ utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME }));
- if (!sURL.isEmpty())
+ if (const OUString sMediaTitle = aDescriptor.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_DOCUMENTTITLE, OUString());
+ !sMediaTitle.isEmpty())
+ {
+ sTitle = sMediaTitle;
+ }
+ else if (const OUString sURL = getURLFromModel(xModel); !sURL.isEmpty())
{
sTitle = impl_convertURL2Title(sURL);
if (nLeasedNumber != css::frame::UntitledNumbersConst::INVALID_NUMBER)
xNumbers->releaseNumber (nLeasedNumber);
nLeasedNumber = css::frame::UntitledNumbersConst::INVALID_NUMBER;
}
- else if (!sSuggestedSaveAsName.isEmpty())
+ else if (const OUString sSuggestedSaveAsName = aDescriptor.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME, OUString());
+ !sSuggestedSaveAsName.isEmpty())
{
// tdf#121537 Use suggested save as name for title if file has not yet been saved
sTitle = sSuggestedSaveAsName;
@@ -380,20 +367,16 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
if (nLeasedNumber == css::frame::UntitledNumbersConst::INVALID_NUMBER)
nLeasedNumber = xNumbers->leaseNumber (xOwner);
- OUStringBuffer sNewTitle(256);
- sNewTitle.append (xNumbers->getUntitledPrefix ());
if (nLeasedNumber != css::frame::UntitledNumbersConst::INVALID_NUMBER)
- sNewTitle.append(nLeasedNumber);
+ sTitle = xNumbers->getUntitledPrefix() + OUString::number(nLeasedNumber);
else
- sNewTitle.append("?");
-
- sTitle = sNewTitle.makeStringAndClear ();
+ sTitle = xNumbers->getUntitledPrefix() + "?";
}
bool bChanged;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// WORKAROUND: the notification is currently sent always,
// can be changed after shared mode is supported per UNO API
@@ -415,7 +398,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
::sal_Int32 nLeasedNumber;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// external title won't be updated internally!
// It has to be set from outside new.
@@ -423,7 +406,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
return;
xOwner = m_xOwner;
- xNumbers.set (m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
+ xNumbers = m_xUntitledNumbers;
nLeasedNumber = m_nLeasedNumber;
}
// <- SYNCHRONIZED
@@ -449,8 +432,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
sTitle.append (xModelTitle->getTitle ());
if ( nLeasedNumber > 1 )
{
- sTitle.append(" : ");
- sTitle.append(nLeasedNumber);
+ sTitle.append(" : " + OUString::number(nLeasedNumber));
}
if (xModel.is ())
{
@@ -475,7 +457,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
bool bChanged;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
OUString sNewTitle = sTitle.makeStringAndClear ();
bChanged = !init && m_sTitle != sNewTitle;
@@ -495,7 +477,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// external title won't be updated internally!
// It has to be set from outside new.
@@ -512,18 +494,21 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram
impl_appendComponentTitle (sTitle, xComponent);
#ifndef MACOSX
- // fdo#70376: We want the window title to contain just the
- // document name (from the above "component title").
- impl_appendProductName (sTitle);
- impl_appendModuleName (sTitle);
- impl_appendDebugVersion (sTitle);
+ if (!comphelper::IsFuzzing())
+ {
+ // fdo#70376: We want the window title to contain just the
+ // document name (from the above "component title").
+ impl_appendProductName (sTitle);
+ impl_appendModuleName (sTitle);
+ impl_appendDebugVersion (sTitle);
+ }
#endif
impl_appendSafeMode (sTitle);
bool bChanged;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
OUString sNewTitle = sTitle.makeStringAndClear ();
bChanged = !init && m_sTitle != sNewTitle;
@@ -535,6 +520,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram
impl_sendTitleChangedEvent ();
}
+// static
void TitleHelper::impl_appendComponentTitle ( OUStringBuffer& sTitle ,
const css::uno::Reference< css::uno::XInterface >& xComponent)
{
@@ -545,13 +531,17 @@ void TitleHelper::impl_appendComponentTitle ( OUStringBuffer&
sTitle.append (xTitle->getTitle ());
}
+// static
void TitleHelper::impl_appendProductName (OUStringBuffer& sTitle)
{
OUString name(utl::ConfigManager::getProductName());
if (!name.isEmpty())
{
if (!sTitle.isEmpty())
- sTitle.append(" - ");
+ {
+ OUString separator (FwkResId (STR_EMDASH_SEPARATOR));
+ sTitle.append(separator);
+ }
sTitle.append(name);
}
}
@@ -562,9 +552,9 @@ void TitleHelper::impl_appendModuleName (OUStringBuffer& sTitle)
css::uno::Reference< css::uno::XComponentContext > xContext;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
- xOwner = m_xOwner.get();
+ xOwner = m_xOwner;
xContext = m_xContext;
}
// <- SYNCHRONIZED
@@ -591,6 +581,7 @@ void TitleHelper::impl_appendModuleName (OUStringBuffer& sTitle)
}
#ifdef DBG_UTIL
+// static
void TitleHelper::impl_appendDebugVersion (OUStringBuffer& sTitle)
{
OUString version(utl::ConfigManager::getProductVersion());
@@ -607,6 +598,7 @@ void TitleHelper::impl_appendDebugVersion (OUStringBuffer&)
}
#endif
+// static
void TitleHelper::impl_appendSafeMode (OUStringBuffer& sTitle)
{
if (Application::IsSafeModeEnabled())
@@ -646,10 +638,10 @@ void TitleHelper::impl_setSubTitle (const css::uno::Reference< css::frame::XTitl
css::uno::Reference< css::frame::XTitle > xOldSubTitle;
// SYNCHRONIZED ->
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
// ignore duplicate calls. Makes outside using of this helper more easy :-)
- xOldSubTitle.set(m_xSubTitle.get(), css::uno::UNO_QUERY);
+ xOldSubTitle = m_xSubTitle;
if (xOldSubTitle == xSubTitle)
return;
@@ -659,7 +651,7 @@ void TitleHelper::impl_setSubTitle (const css::uno::Reference< css::frame::XTitl
css::uno::Reference< css::frame::XTitleChangeBroadcaster > xOldBroadcaster(xOldSubTitle , css::uno::UNO_QUERY );
css::uno::Reference< css::frame::XTitleChangeBroadcaster > xNewBroadcaster(xSubTitle , css::uno::UNO_QUERY );
- css::uno::Reference< css::frame::XTitleChangeListener > xThis (static_cast< css::frame::XTitleChangeListener* >(this), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::frame::XTitleChangeListener > xThis(this);
if (xOldBroadcaster.is())
xOldBroadcaster->removeTitleChangeListener (xThis);
@@ -668,7 +660,8 @@ void TitleHelper::impl_setSubTitle (const css::uno::Reference< css::frame::XTitl
xNewBroadcaster->addTitleChangeListener (xThis);
}
-OUString TitleHelper::impl_convertURL2Title(const OUString& sURL)
+// static
+OUString TitleHelper::impl_convertURL2Title(std::u16string_view sURL)
{
INetURLObject aURL (sURL);
OUString sTitle;
diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index a621a39ae320..3a2fdd6c066b 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -29,17 +29,20 @@
#include <com/sun/star/util/NotLockedException.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
-#include <comphelper/interfacecontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/flagguard.hxx>
#include <comphelper/asyncnotification.hxx>
#include <svl/undo.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <osl/conditn.hxx>
+#include <vcl/svapp.hxx>
#include <functional>
+#include <mutex>
#include <stack>
#include <queue>
+#include <utility>
namespace framework
{
@@ -89,8 +92,7 @@ namespace framework
}
UndoActionWrapper::UndoActionWrapper( Reference< XUndoAction > const& i_undoAction )
- :SfxUndoAction()
- ,m_xUndoAction( i_undoAction )
+ : m_xUndoAction( i_undoAction )
{
ENSURE_OR_THROW( m_xUndoAction.is(), "illegal undo action" );
}
@@ -145,10 +147,8 @@ namespace framework
class UndoManagerRequest : public ::comphelper::AnyEvent
{
public:
- explicit UndoManagerRequest( ::std::function<void ()> const& i_request )
- :m_request( i_request )
- ,m_caughtException()
- ,m_finishCondition()
+ explicit UndoManagerRequest( ::std::function<void ()> i_request )
+ :m_request(std::move( i_request ))
{
m_finishCondition.reset();
}
@@ -201,15 +201,18 @@ namespace framework
{
private:
::osl::Mutex m_aMutex;
- ::osl::Mutex m_aQueueMutex;
+ /// Use different mutex for listeners to prevent ABBA deadlocks
+ std::mutex m_aListenerMutex;
+ std::mutex m_aQueueMutex;
bool m_bAPIActionRunning;
bool m_bProcessingEvents;
sal_Int32 m_nLockCount;
- ::comphelper::OInterfaceContainerHelper2 m_aUndoListeners;
- ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners;
+ ::comphelper::OInterfaceContainerHelper4<XUndoManagerListener> m_aUndoListeners;
+ ::comphelper::OInterfaceContainerHelper4<XModifyListener> m_aModifyListeners;
IUndoManagerImplementation& m_rUndoManagerImplementation;
::std::stack< bool > m_aContextVisibilities;
#if OSL_DEBUG_LEVEL > 0
+ bool m_bContextAPIFlagsEverPushed = {false};
::std::stack< bool > m_aContextAPIFlags;
#endif
::std::queue< ::rtl::Reference< UndoManagerRequest > >
@@ -220,13 +223,9 @@ namespace framework
public:
explicit UndoManagerHelper_Impl( IUndoManagerImplementation& i_undoManagerImpl )
- :m_aMutex()
- ,m_aQueueMutex()
- ,m_bAPIActionRunning( false )
+ :m_bAPIActionRunning( false )
,m_bProcessingEvents( false )
,m_nLockCount( 0 )
- ,m_aUndoListeners( m_aMutex )
- ,m_aModifyListeners( m_aMutex )
,m_rUndoManagerImplementation( i_undoManagerImpl )
{
getUndoManager().AddUndoListener( *this );
@@ -274,22 +273,26 @@ namespace framework
void addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener )
{
- m_aUndoListeners.addInterface( i_listener );
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.addInterface( g, i_listener );
}
void removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener )
{
- m_aUndoListeners.removeInterface( i_listener );
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.removeInterface( g, i_listener );
}
void addModifyListener( const Reference< XModifyListener >& i_listener )
{
- m_aModifyListeners.addInterface( i_listener );
+ std::unique_lock g(m_aListenerMutex);
+ m_aModifyListeners.addInterface( g, i_listener );
}
void removeModifyListener( const Reference< XModifyListener >& i_listener )
{
- m_aModifyListeners.removeInterface( i_listener );
+ std::unique_lock g(m_aListenerMutex);
+ m_aModifyListeners.removeInterface( g, i_listener );
}
UndoManagerEvent
@@ -319,9 +322,11 @@ namespace framework
{
EventObject aEvent;
aEvent.Source = getXUndoManager();
- m_aUndoListeners.disposeAndClear( aEvent );
- m_aModifyListeners.disposeAndClear( aEvent );
-
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.disposeAndClear( g, aEvent );
+ m_aModifyListeners.disposeAndClear( g, aEvent );
+ }
::osl::MutexGuard aGuard( m_aMutex );
getUndoManager().RemoveUndoListener( *this );
@@ -339,7 +344,8 @@ namespace framework
void UndoManagerHelper_Impl::impl_notifyModified()
{
const EventObject aEvent( getXUndoManager() );
- m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
+ std::unique_lock g(m_aListenerMutex);
+ m_aModifyListeners.notifyEach( g, &XModifyListener::modified, aEvent );
}
void UndoManagerHelper_Impl::notify( OUString const& i_title,
@@ -353,7 +359,10 @@ namespace framework
// 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 );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, i_notificationMethod, aEvent );
+ }
impl_notifyModified();
}
@@ -362,8 +371,10 @@ namespace framework
const EventObject aEvent( getXUndoManager() );
// TODO: the same comment as in the other notify, regarding SM locking applies here ...
-
- m_aUndoListeners.notifyEach( i_notificationMethod, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, i_notificationMethod, aEvent );
+ }
impl_notifyModified();
}
@@ -456,7 +467,7 @@ namespace framework
// create the request, and add it to our queue
::rtl::Reference< UndoManagerRequest > pRequest( new UndoManagerRequest( i_request ) );
{
- ::osl::MutexGuard aQueueGuard( m_aQueueMutex );
+ std::unique_lock aQueueGuard( m_aQueueMutex );
m_aEventQueue.push( pRequest );
}
@@ -474,7 +485,7 @@ namespace framework
{
pRequest.clear();
{
- ::osl::MutexGuard aQueueGuard( m_aQueueMutex );
+ std::unique_lock aQueueGuard( m_aQueueMutex );
if ( m_aEventQueue.empty() )
{
// reset the flag before releasing the queue mutex, otherwise it's possible that another thread
@@ -496,7 +507,7 @@ namespace framework
{
// no chance to process further requests, if the current one failed
// => discard them
- ::osl::MutexGuard aQueueGuard( m_aQueueMutex );
+ std::unique_lock aQueueGuard( m_aQueueMutex );
while ( !m_aEventQueue.empty() )
{
pRequest = m_aEventQueue.front();
@@ -539,7 +550,10 @@ namespace framework
aGuard.clear();
// <--- SYNCHRONIZED
- m_aUndoListeners.notifyEach( i_hidden ? &XUndoManagerListener::enteredHiddenContext : &XUndoManagerListener::enteredContext, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, i_hidden ? &XUndoManagerListener::enteredHiddenContext : &XUndoManagerListener::enteredContext, aEvent );
+ }
impl_notifyModified();
}
@@ -596,9 +610,12 @@ namespace framework
aGuard.clear();
// <--- SYNCHRONIZED
- if ( bHadRedoActions && !bHasRedoActions )
- m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aClearedEvent );
- m_aUndoListeners.notifyEach( notificationMethod, aContextEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ if ( bHadRedoActions && !bHasRedoActions )
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::redoActionsCleared, aClearedEvent );
+ m_aUndoListeners.notifyEach( g, notificationMethod, aContextEvent );
+ }
impl_notifyModified();
}
@@ -672,31 +689,38 @@ namespace framework
aGuard.clear();
// <--- SYNCHRONIZED
- m_aUndoListeners.notifyEach( &XUndoManagerListener::undoActionAdded, aEventAdd );
- if ( bHadRedoActions && !bHasRedoActions )
- m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aEventClear );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::undoActionAdded, aEventAdd );
+ if ( bHadRedoActions && !bHasRedoActions )
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::redoActionsCleared, aEventClear );
+ }
impl_notifyModified();
}
void UndoManagerHelper_Impl::impl_clear()
{
- // SYNCHRONIZED --->
- ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ EventObject aEvent;
+ {
+ SolarMutexGuard aGuard;
+ ::osl::MutexGuard aGuard2( m_aMutex );
- SfxUndoManager& rUndoManager = getUndoManager();
- if ( rUndoManager.IsInListAction() )
- throw UndoContextNotClosedException( OUString(), getXUndoManager() );
+ SfxUndoManager& rUndoManager = getUndoManager();
+ if ( rUndoManager.IsInListAction() )
+ throw UndoContextNotClosedException( OUString(), getXUndoManager() );
- {
- ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning );
- rUndoManager.Clear();
- }
+ {
+ ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning );
+ rUndoManager.Clear();
+ }
- const EventObject aEvent( getXUndoManager() );
- aGuard.clear();
- // <--- SYNCHRONIZED
+ aEvent = EventObject( getXUndoManager() );
+ }
- m_aUndoListeners.notifyEach( &XUndoManagerListener::allActionsCleared, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::allActionsCleared, aEvent );
+ }
impl_notifyModified();
}
@@ -718,7 +742,10 @@ namespace framework
aGuard.clear();
// <--- SYNCHRONIZED
- m_aUndoListeners.notifyEach( &XUndoManagerListener::redoActionsCleared, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::redoActionsCleared, aEvent );
+ }
impl_notifyModified();
}
@@ -737,7 +764,10 @@ namespace framework
aGuard.clear();
// <--- SYNCHRONIZED
- m_aUndoListeners.notifyEach( &XUndoManagerListener::resetAll, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::resetAll, aEvent );
+ }
impl_notifyModified();
}
@@ -747,7 +777,10 @@ namespace framework
aEvent.Source = getXUndoManager();
aEvent.UndoActionTitle = i_actionComment;
aEvent.UndoContextDepth = 0; // Undo can happen on level 0 only
- m_aUndoListeners.notifyEach( &XUndoManagerListener::actionUndone, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::actionUndone, aEvent );
+ }
impl_notifyModified();
}
@@ -757,7 +790,10 @@ namespace framework
aEvent.Source = getXUndoManager();
aEvent.UndoActionTitle = i_actionComment;
aEvent.UndoContextDepth = 0; // Redo can happen on level 0 only
- m_aUndoListeners.notifyEach( &XUndoManagerListener::actionRedone, aEvent );
+ {
+ std::unique_lock g(m_aListenerMutex);
+ m_aUndoListeners.notifyEach( g, &XUndoManagerListener::actionRedone, aEvent );
+ }
impl_notifyModified();
}
@@ -797,6 +833,7 @@ namespace framework
{
#if OSL_DEBUG_LEVEL > 0
m_aContextAPIFlags.push( m_bAPIActionRunning );
+ m_bContextAPIFlagsEverPushed = true;
#endif
if ( m_bAPIActionRunning )
@@ -808,9 +845,18 @@ namespace framework
void UndoManagerHelper_Impl::listActionLeft( const OUString& 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!" );
+ // It may happen that the very first event listener is added during a
+ // list action after listActionEntered() was already called, e.g. Calc
+ // formula calculation event listener during the input of the very
+ // first formula. Instead of checking m_aContextAPIFlags for empty,
+ // still assert (on calling top()) other stack mismatches but ignore
+ // this one case. See tdf#142980
+ if (m_bContextAPIFlagsEverPushed)
+ {
+ 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 )
@@ -952,9 +998,10 @@ namespace framework
: rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel );
Sequence< OUString > aTitles( nCount );
+ auto aTitlesRange = asNonConstRange(aTitles);
for ( size_t i=0; i<nCount; ++i )
{
- aTitles[i] = i_undo
+ aTitlesRange[i] = i_undo
? rUndoManager.GetUndoActionComment( i, SfxUndoManager::TopLevel )
: rUndoManager.GetRedoActionComment( i, SfxUndoManager::TopLevel );
}
diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx
index e5a548640a58..1047422ed775 100644
--- a/framework/source/fwe/xml/menuconfiguration.cxx
+++ b/framework/source/fwe/xml/menuconfiguration.cxx
@@ -20,6 +20,7 @@
#include <menuconfiguration.hxx>
#include <addonmenu.hxx>
+#include <utility>
#include <xml/menudocumenthandler.hxx>
#include <xml/saxnamespacefilter.hxx>
@@ -33,7 +34,6 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::io;
@@ -41,9 +41,8 @@ using namespace ::com::sun::star::io;
namespace framework
{
-MenuConfiguration::MenuConfiguration(
- const css::uno::Reference< css::uno::XComponentContext >& rxContext )
-: m_xContext( rxContext )
+MenuConfiguration::MenuConfiguration( css::uno::Reference< css::uno::XComponentContext > xContext )
+: m_xContext(std::move( xContext ))
{
}
@@ -62,7 +61,7 @@ Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML(
aInputSource.aInputStream = rInputStream;
// create menu bar
- Reference< XIndexContainer > xItemContainer( static_cast< cppu::OWeakObject *>( new RootItemContainer()), UNO_QUERY );
+ Reference< XIndexContainer > xItemContainer( new RootItemContainer() );
// create namespace filter and set menudocument handler inside to support xml namespaces
diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx
index dbc6f7a22444..96e4b2324ba8 100644
--- a/framework/source/fwe/xml/menudocumenthandler.cxx
+++ b/framework/source/fwe/xml/menudocumenthandler.cxx
@@ -31,53 +31,52 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/attributelist.hxx>
#ifdef ATTRIBUTE_HELPID
#undef ATTRIBUTE_HELPID
#endif
-#define XMLNS_MENU "http://openoffice.org/2001/menu"
+constexpr OUStringLiteral XMLNS_MENU = u"http://openoffice.org/2001/menu";
-#define ELEMENT_MENUBAR "http://openoffice.org/2001/menu^menubar"
-#define ELEMENT_MENU "http://openoffice.org/2001/menu^menu"
-#define ELEMENT_MENUPOPUP "http://openoffice.org/2001/menu^menupopup"
-#define ELEMENT_MENUITEM "http://openoffice.org/2001/menu^menuitem"
-#define ELEMENT_MENUSEPARATOR "http://openoffice.org/2001/menu^menuseparator"
+constexpr OUString ELEMENT_MENUBAR = u"http://openoffice.org/2001/menu^menubar"_ustr;
+constexpr OUString ELEMENT_MENU = u"http://openoffice.org/2001/menu^menu"_ustr;
+constexpr OUString ELEMENT_MENUPOPUP = u"http://openoffice.org/2001/menu^menupopup"_ustr;
+constexpr OUString ELEMENT_MENUITEM = u"http://openoffice.org/2001/menu^menuitem"_ustr;
+constexpr OUString ELEMENT_MENUSEPARATOR = u"http://openoffice.org/2001/menu^menuseparator"_ustr;
-#define ELEMENT_NS_MENUBAR "menu:menubar"
-#define ELEMENT_NS_MENU "menu:menu"
-#define ELEMENT_NS_MENUPOPUP "menu:menupopup"
-#define ELEMENT_NS_MENUITEM "menu:menuitem"
-#define ELEMENT_NS_MENUSEPARATOR "menu:menuseparator"
+constexpr OUStringLiteral ELEMENT_NS_MENUBAR = u"menu:menubar";
+constexpr OUString ELEMENT_NS_MENU = u"menu:menu"_ustr;
+constexpr OUString ELEMENT_NS_MENUPOPUP = u"menu:menupopup"_ustr;
+constexpr OUString ELEMENT_NS_MENUITEM = u"menu:menuitem"_ustr;
+constexpr OUString ELEMENT_NS_MENUSEPARATOR = u"menu:menuseparator"_ustr;
-#define ATTRIBUTE_ID "http://openoffice.org/2001/menu^id"
-#define ATTRIBUTE_LABEL "http://openoffice.org/2001/menu^label"
-#define ATTRIBUTE_HELPID "http://openoffice.org/2001/menu^helpid"
-#define ATTRIBUTE_STYLE "http://openoffice.org/2001/menu^style"
+constexpr OUString ATTRIBUTE_ID = u"http://openoffice.org/2001/menu^id"_ustr;
+constexpr OUString ATTRIBUTE_LABEL = u"http://openoffice.org/2001/menu^label"_ustr;
+constexpr OUString ATTRIBUTE_HELPID = u"http://openoffice.org/2001/menu^helpid"_ustr;
+constexpr OUString ATTRIBUTE_STYLE = u"http://openoffice.org/2001/menu^style"_ustr;
-#define ATTRIBUTE_NS_ID "menu:id"
-#define ATTRIBUTE_NS_LABEL "menu:label"
-#define ATTRIBUTE_NS_HELPID "menu:helpid"
-#define ATTRIBUTE_NS_STYLE "menu:style"
+constexpr OUString ATTRIBUTE_NS_ID = u"menu:id"_ustr;
+constexpr OUString ATTRIBUTE_NS_LABEL = u"menu:label"_ustr;
+constexpr OUStringLiteral ATTRIBUTE_NS_HELPID = u"menu:helpid";
+constexpr OUStringLiteral ATTRIBUTE_NS_STYLE = u"menu:style";
-#define ATTRIBUTE_XMLNS_MENU "xmlns:menu"
+constexpr OUStringLiteral ATTRIBUTE_XMLNS_MENU = u"xmlns:menu";
-#define ATTRIBUTE_TYPE_CDATA "CDATA"
-
-#define MENUBAR_DOCTYPE "<!DOCTYPE menu:menubar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"menubar.dtd\">"
+constexpr OUStringLiteral MENUBAR_DOCTYPE = u"<!DOCTYPE menu:menubar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"menubar.dtd\">";
#define ATTRIBUTE_ITEMSTYLE_TEXT "text"
#define ATTRIBUTE_ITEMSTYLE_IMAGE "image"
#define ATTRIBUTE_ITEMSTYLE_RADIO "radio"
// Property names of a menu/menu item ItemDescriptor
-constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL = u"HelpURL";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
+constexpr OUString ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_HELPURL = u"HelpURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_LABEL = u"Label"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_TYPE = u"Type"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_STYLE = u"Style"_ustr;
// using namespaces
@@ -122,7 +121,6 @@ static void ExtractMenuParameters( const Sequence< PropertyValue >& rProp,
if ( p.Name == ITEM_DESCRIPTOR_COMMANDURL )
{
p.Value >>= rCommandURL;
- rCommandURL = rCommandURL.intern();
}
else if ( p.Name == ITEM_DESCRIPTOR_HELPURL )
{
@@ -191,20 +189,22 @@ void ReadMenuDocumentHandlerBase::initPropertyCommon(
Sequence< PropertyValue > &rProps, const OUString &rCommandURL,
const OUString &rHelpId, const OUString &rLabel, sal_Int16 nItemStyleBits )
{
- rProps[0].Name = m_aCommandURL;
- rProps[1].Name = m_aHelpURL;
- rProps[2].Name = m_aContainer;
- rProps[3].Name = m_aLabel;
- rProps[4].Name = m_aStyle;
- rProps[5].Name = m_aType;
+ auto pProps = rProps.getArray();
+
+ pProps[0].Name = m_aCommandURL;
+ pProps[1].Name = m_aHelpURL;
+ pProps[2].Name = m_aContainer;
+ pProps[3].Name = m_aLabel;
+ pProps[4].Name = m_aStyle;
+ pProps[5].Name = m_aType;
// Common values
- rProps[0].Value <<= rCommandURL.intern();
- rProps[1].Value <<= rHelpId;
- rProps[2].Value <<= Reference< XIndexContainer >();
- rProps[3].Value <<= rLabel;
- rProps[4].Value <<= nItemStyleBits;
- rProps[5].Value <<= css::ui::ItemType::DEFAULT;
+ pProps[0].Value <<= rCommandURL;
+ pProps[1].Value <<= rHelpId;
+ pProps[2].Value <<= Reference< XIndexContainer >();
+ pProps[3].Value <<= rLabel;
+ pProps[4].Value <<= nItemStyleBits;
+ pProps[5].Value <<= css::ui::ItemType::DEFAULT;
}
OReadMenuDocumentHandler::OReadMenuDocumentHandler(
@@ -376,9 +376,9 @@ void SAL_CALL OReadMenuBarHandler::startElement(
{
Sequence< PropertyValue > aSubMenuProp( 6 );
initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits );
- aSubMenuProp[2].Value <<= xSubItemContainer;
+ aSubMenuProp.getArray()[2].Value <<= xSubItemContainer;
- m_xMenuBarContainer->insertByIndex( m_xMenuBarContainer->getCount(), makeAny( aSubMenuProp ) );
+ m_xMenuBarContainer->insertByIndex( m_xMenuBarContainer->getCount(), Any( aSubMenuProp ) );
}
else
{
@@ -577,9 +577,9 @@ void SAL_CALL OReadMenuPopupHandler::startElement(
{
Sequence< PropertyValue > aSubMenuProp( 6 );
initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits );
- aSubMenuProp[2].Value <<= xSubItemContainer;
+ aSubMenuProp.getArray()[2].Value <<= xSubItemContainer;
- m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aSubMenuProp ) );
+ m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), Any( aSubMenuProp ) );
}
else
{
@@ -633,20 +633,19 @@ void SAL_CALL OReadMenuPopupHandler::startElement(
{
Sequence< PropertyValue > aMenuItem( 6 );
initPropertyCommon( aMenuItem, aCommandId, aHelpId, aLabel, nItemBits );
- aMenuItem[2].Value <<= Reference< XIndexContainer >();
+ aMenuItem.getArray()[2].Value <<= Reference< XIndexContainer >();
- m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aMenuItem ) );
+ m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), Any( aMenuItem ) );
}
m_nNextElementExpected = ELEM_CLOSE_MENUITEM;
}
else if ( rName == ELEMENT_MENUSEPARATOR )
{
- Sequence< PropertyValue > aMenuSeparator( 1 );
- aMenuSeparator[0].Name = ITEM_DESCRIPTOR_TYPE;
- aMenuSeparator[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
+ Sequence< PropertyValue > aMenuSeparator{ comphelper::makePropertyValue(
+ ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::SEPARATOR_LINE) };
- m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aMenuSeparator ) );
+ m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), Any( aMenuSeparator ) );
m_nNextElementExpected = ELEM_CLOSE_MENUSEPARATOR;
}
@@ -717,9 +716,7 @@ OWriteMenuDocumentHandler::OWriteMenuDocumentHandler(
m_xWriteDocumentHandler( rDocumentHandler ),
m_bIsMenuBar( bIsMenuBar )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY );
- m_aAttributeType = ATTRIBUTE_TYPE_CDATA;
+ m_xEmptyList = new ::comphelper::AttributeList;
}
OWriteMenuDocumentHandler::~OWriteMenuDocumentHandler()
@@ -741,12 +738,10 @@ void OWriteMenuDocumentHandler::WriteMenuDocument()
}
pList->AddAttribute( ATTRIBUTE_XMLNS_MENU,
- m_aAttributeType,
XMLNS_MENU );
if ( m_bIsMenuBar ) //FIXME
pList->AddAttribute( ATTRIBUTE_NS_ID,
- m_aAttributeType,
"menubar" );
OUString aRootElement;
@@ -754,7 +749,7 @@ void OWriteMenuDocumentHandler::WriteMenuDocument()
aRootElement = ELEMENT_NS_MENUBAR;
else
aRootElement = ELEMENT_NS_MENUPOPUP;
- m_xWriteDocumentHandler->startElement( aRootElement, pList.get() );
+ m_xWriteDocumentHandler->startElement( aRootElement, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
WriteMenu( m_xMenuBarContainer );
@@ -789,20 +784,17 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen
{
if ( !aCommandURL.isEmpty() )
{
- ::comphelper::AttributeList* pListMenu = new ::comphelper::AttributeList;
- Reference< XAttributeList > xListMenu( static_cast<XAttributeList *>(pListMenu) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pListMenu = new ::comphelper::AttributeList;
pListMenu->AddAttribute( ATTRIBUTE_NS_ID,
- m_aAttributeType,
aCommandURL );
if ( !aLabel.isEmpty() )
pListMenu->AddAttribute( ATTRIBUTE_NS_LABEL,
- m_aAttributeType,
aLabel );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENU, xListMenu );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENU, pListMenu );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUPOPUP, m_xEmptyList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
@@ -840,24 +832,20 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen
void OWriteMenuDocumentHandler::WriteMenuItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( ATTRIBUTE_NS_ID,
- m_aAttributeType,
aCommandURL );
if ( !aHelpURL.isEmpty() )
{
pList->AddAttribute( ATTRIBUTE_NS_HELPID,
- m_aAttributeType,
aHelpURL );
}
if ( !aLabel.isEmpty() )
{
pList->AddAttribute( ATTRIBUTE_NS_LABEL,
- m_aAttributeType,
aLabel );
}
if ( nStyle > 0 )
@@ -875,12 +863,11 @@ void OWriteMenuDocumentHandler::WriteMenuItem( const OUString& aCommandURL, cons
}
}
pList->AddAttribute( ATTRIBUTE_NS_STYLE,
- m_aAttributeType,
aValue.makeStringAndClear() );
}
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUITEM, xList );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUITEM, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->endElement( ELEMENT_NS_MENUITEM );
}
diff --git a/framework/source/fwe/xml/saxnamespacefilter.cxx b/framework/source/fwe/xml/saxnamespacefilter.cxx
index 5a05dfb54e43..b5349eb4887d 100644
--- a/framework/source/fwe/xml/saxnamespacefilter.cxx
+++ b/framework/source/fwe/xml/saxnamespacefilter.cxx
@@ -17,9 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
- with solaris headers ...
-*/
+#include <sal/config.h>
+
#include <vector>
#include <com/sun/star/xml/sax/SAXException.hpp>
@@ -27,6 +26,7 @@
#include <xml/saxnamespacefilter.hxx>
#include <comphelper/attributelist.hxx>
+#include <rtl/ref.hxx>
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
@@ -58,7 +58,7 @@ void SAL_CALL SaxNamespaceFilter::startElement(
if ( !m_aNamespaceStack.empty() )
aXMLNamespaces = m_aNamespaceStack.top();
- ::comphelper::AttributeList* pNewList = new ::comphelper::AttributeList();
+ rtl::Reference<::comphelper::AttributeList> pNewList = new ::comphelper::AttributeList();
// examine all namespaces for this level
::std::vector< sal_Int16 > aAttributeIndexes;
@@ -84,7 +84,7 @@ void SAL_CALL SaxNamespaceFilter::startElement(
OUString aAttributeName = xAttribs->getNameByIndex(attributeIndex);
OUString aValue = xAttribs->getValueByIndex(attributeIndex);
OUString aNamespaceAttributeName = aXMLNamespaces.applyNSToAttributeName( aAttributeName );
- pNewList->AddAttribute( aNamespaceAttributeName, "CDATA", aValue );
+ pNewList->AddAttribute(aNamespaceAttributeName, aValue);
}
}
catch ( SAXException& e )
diff --git a/framework/source/fwe/xml/statusbarconfiguration.cxx b/framework/source/fwe/xml/statusbarconfiguration.cxx
index ce974237b286..98130700ef26 100644
--- a/framework/source/fwe/xml/statusbarconfiguration.cxx
+++ b/framework/source/fwe/xml/statusbarconfiguration.cxx
@@ -29,7 +29,6 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::container;
diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index 94dd1817872f..cafd3258eca1 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -27,10 +27,10 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
-#include <vcl/svapp.hxx>
#include <vcl/status.hxx>
#include <comphelper/attributelist.hxx>
+#include <comphelper/propertyvalue.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
@@ -38,12 +38,12 @@ using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::container;
-#define XMLNS_STATUSBAR "http://openoffice.org/2001/statusbar"
-#define XMLNS_XLINK "http://www.w3.org/1999/xlink"
-#define XMLNS_STATUSBAR_PREFIX "statusbar:"
-#define XMLNS_XLINK_PREFIX "xlink:"
+constexpr OUString XMLNS_STATUSBAR = u"http://openoffice.org/2001/statusbar"_ustr;
+constexpr OUString XMLNS_XLINK = u"http://www.w3.org/1999/xlink"_ustr;
+constexpr OUStringLiteral XMLNS_STATUSBAR_PREFIX = u"statusbar:";
+constexpr OUStringLiteral XMLNS_XLINK_PREFIX = u"xlink:";
-#define XMLNS_FILTER_SEPARATOR "^"
+constexpr OUString XMLNS_FILTER_SEPARATOR = u"^"_ustr;
#define ELEMENT_STATUSBAR "statusbar"
#define ELEMENT_STATUSBARITEM "statusbaritem"
@@ -58,37 +58,35 @@ using namespace ::com::sun::star::container;
#define ATTRIBUTE_HELPURL "helpid"
#define ATTRIBUTE_MANDATORY "mandatory"
-#define ELEMENT_NS_STATUSBAR "statusbar:statusbar"
-#define ELEMENT_NS_STATUSBARITEM "statusbar:statusbaritem"
+constexpr OUString ELEMENT_NS_STATUSBAR = u"statusbar:statusbar"_ustr;
+constexpr OUString ELEMENT_NS_STATUSBARITEM = u"statusbar:statusbaritem"_ustr;
-#define ATTRIBUTE_XMLNS_STATUSBAR "xmlns:statusbar"
-#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink"
+constexpr OUStringLiteral ATTRIBUTE_XMLNS_STATUSBAR = u"xmlns:statusbar";
+constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK = u"xmlns:xlink";
-#define ATTRIBUTE_TYPE_CDATA "CDATA"
+constexpr OUString ATTRIBUTE_BOOLEAN_TRUE = u"true"_ustr;
+constexpr OUString ATTRIBUTE_BOOLEAN_FALSE = u"false"_ustr;
-#define ATTRIBUTE_BOOLEAN_TRUE "true"
-#define ATTRIBUTE_BOOLEAN_FALSE "false"
+constexpr OUString ATTRIBUTE_ALIGN_LEFT = u"left"_ustr;
+constexpr OUString ATTRIBUTE_ALIGN_RIGHT = u"right"_ustr;
+constexpr OUString ATTRIBUTE_ALIGN_CENTER = u"center"_ustr;
-#define ATTRIBUTE_ALIGN_LEFT "left"
-#define ATTRIBUTE_ALIGN_RIGHT "right"
-#define ATTRIBUTE_ALIGN_CENTER "center"
+constexpr OUStringLiteral ATTRIBUTE_STYLE_IN = u"in";
+constexpr OUString ATTRIBUTE_STYLE_OUT = u"out"_ustr;
+constexpr OUString ATTRIBUTE_STYLE_FLAT = u"flat"_ustr;
-#define ATTRIBUTE_STYLE_IN "in"
-#define ATTRIBUTE_STYLE_OUT "out"
-#define ATTRIBUTE_STYLE_FLAT "flat"
-
-#define STATUSBAR_DOCTYPE "<!DOCTYPE statusbar:statusbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"statusbar.dtd\">"
+constexpr OUStringLiteral STATUSBAR_DOCTYPE = u"<!DOCTYPE statusbar:statusbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"statusbar.dtd\">";
namespace framework
{
// Property names of a menu/menu item ItemDescriptor
-const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
-const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
-const char ITEM_DESCRIPTOR_OFFSET[] = "Offset";
-const char ITEM_DESCRIPTOR_STYLE[] = "Style";
-const char ITEM_DESCRIPTOR_WIDTH[] = "Width";
-const char ITEM_DESCRIPTOR_TYPE[] = "Type";
+constexpr OUString ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_HELPURL = u"HelpURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_OFFSET = u"Offset"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_STYLE = u"Style"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_WIDTH = u"Width"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_TYPE = u"Type"_ustr;
static void ExtractStatusbarItemParameters(
const Sequence< PropertyValue >& rProp,
@@ -103,7 +101,6 @@ static void ExtractStatusbarItemParameters(
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
{
rEntry.Value >>= rCommandURL;
- rCommandURL = rCommandURL.intern();
}
else if ( rEntry.Name == ITEM_DESCRIPTOR_HELPURL )
{
@@ -154,17 +151,17 @@ OReadStatusBarDocumentHandler::OReadStatusBarDocumentHandler(
m_aStatusBarItems( rStatusBarItems )
{
// create hash map
- for ( int i = 0; i < int(SB_XML_ENTRY_COUNT); i++ )
+ for ( int i = 0; i < SB_XML_ENTRY_COUNT; i++ )
{
if ( StatusBarEntries[i].nNamespace == SB_NS_STATUSBAR )
{
- OUString temp = XMLNS_STATUSBAR XMLNS_FILTER_SEPARATOR +
+ OUString temp = XMLNS_STATUSBAR + XMLNS_FILTER_SEPARATOR +
OUString::createFromAscii( StatusBarEntries[i].aEntryName );
m_aStatusBarMap.emplace( temp, static_cast<StatusBar_XML_Entry>(i) );
}
else
{
- OUString temp = XMLNS_XLINK XMLNS_FILTER_SEPARATOR +
+ OUString temp = XMLNS_XLINK + XMLNS_FILTER_SEPARATOR +
OUString::createFromAscii( StatusBarEntries[i].aEntryName );
m_aStatusBarMap.emplace( temp, static_cast<StatusBar_XML_Entry>(i) );
}
@@ -185,8 +182,6 @@ void SAL_CALL OReadStatusBarDocumentHandler::startDocument()
void SAL_CALL OReadStatusBarDocumentHandler::endDocument()
{
- SolarMutexGuard g;
-
if ( m_bStatusBarStartFound )
{
OUString aErrorMessage = getErrorLineString() + "No matching start or end element 'statusbar' found!";
@@ -197,8 +192,6 @@ void SAL_CALL OReadStatusBarDocumentHandler::endDocument()
void SAL_CALL OReadStatusBarDocumentHandler::startElement(
const OUString& aName, const Reference< XAttributeList > &xAttribs )
{
- SolarMutexGuard g;
-
StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName );
if ( pStatusBarEntry == m_aStatusBarMap.end() )
return;
@@ -374,22 +367,16 @@ void SAL_CALL OReadStatusBarDocumentHandler::startElement(
}
else
{
- Sequence< PropertyValue > aStatusbarItemProp( 6 );
- aStatusbarItemProp[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
- aStatusbarItemProp[1].Name = ITEM_DESCRIPTOR_HELPURL;
- aStatusbarItemProp[2].Name = ITEM_DESCRIPTOR_OFFSET;
- aStatusbarItemProp[3].Name = ITEM_DESCRIPTOR_STYLE;
- aStatusbarItemProp[4].Name = ITEM_DESCRIPTOR_WIDTH;
- aStatusbarItemProp[5].Name = ITEM_DESCRIPTOR_TYPE;
-
- aStatusbarItemProp[0].Value <<= aCommandURL;
- aStatusbarItemProp[1].Value <<= aHelpURL;
- aStatusbarItemProp[2].Value <<= nOffset;
- aStatusbarItemProp[3].Value <<= nItemBits;
- aStatusbarItemProp[4].Value <<= nWidth;
- aStatusbarItemProp[5].Value <<= css::ui::ItemType::DEFAULT;
-
- m_aStatusBarItems->insertByIndex( m_aStatusBarItems->getCount(), makeAny( aStatusbarItemProp ) );
+ Sequence< PropertyValue > aStatusbarItemProp{
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_COMMANDURL, aCommandURL),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_HELPURL, aHelpURL),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_OFFSET, nOffset),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_STYLE, nItemBits),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_WIDTH, nWidth),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::DEFAULT)
+ };
+
+ m_aStatusBarItems->insertByIndex( m_aStatusBarItems->getCount(), Any( aStatusbarItemProp ) );
}
}
break;
@@ -401,8 +388,6 @@ void SAL_CALL OReadStatusBarDocumentHandler::startElement(
void SAL_CALL OReadStatusBarDocumentHandler::endElement(const OUString& aName)
{
- SolarMutexGuard g;
-
StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName );
if ( pStatusBarEntry == m_aStatusBarMap.end() )
return;
@@ -453,15 +438,11 @@ void SAL_CALL OReadStatusBarDocumentHandler::processingInstruction(
void SAL_CALL OReadStatusBarDocumentHandler::setDocumentLocator(
const Reference< XLocator > &xLocator)
{
- SolarMutexGuard g;
-
m_xLocator = xLocator;
}
OUString OReadStatusBarDocumentHandler::getErrorLineString()
{
- SolarMutexGuard g;
-
if ( m_xLocator.is() )
return "Line: " + OUString::number( m_xLocator->getLineNumber() ) + " - ";
else
@@ -476,9 +457,7 @@ OWriteStatusBarDocumentHandler::OWriteStatusBarDocumentHandler(
m_aStatusBarItems( aStatusBarItems ),
m_xWriteDocumentHandler( rWriteDocumentHandler )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY );
- m_aAttributeType = ATTRIBUTE_TYPE_CDATA;
+ m_xEmptyList = new ::comphelper::AttributeList;
m_aXMLXlinkNS = XMLNS_XLINK_PREFIX;
m_aXMLStatusBarNS = XMLNS_STATUSBAR_PREFIX;
}
@@ -489,8 +468,6 @@ OWriteStatusBarDocumentHandler::~OWriteStatusBarDocumentHandler()
void OWriteStatusBarDocumentHandler::WriteStatusBarDocument()
{
- SolarMutexGuard g;
-
m_xWriteDocumentHandler->startDocument();
// write DOCTYPE line!
@@ -504,14 +481,12 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarDocument()
rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( ATTRIBUTE_XMLNS_STATUSBAR,
- m_aAttributeType,
XMLNS_STATUSBAR );
pList->AddAttribute( ATTRIBUTE_XMLNS_XLINK,
- m_aAttributeType,
XMLNS_XLINK );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBAR, pList.get() );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBAR, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
sal_Int32 nItemCount = m_aStatusBarItems->getCount();
@@ -556,8 +531,7 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
sal_Int16 nStyle,
sal_Int16 nWidth )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
if (m_aAttributeURL.isEmpty() )
{
@@ -565,25 +539,22 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
}
// save required attribute (URL)
- pList->AddAttribute( m_aAttributeURL, m_aAttributeType, rCommandURL );
+ pList->AddAttribute( m_aAttributeURL, rCommandURL );
// alignment
if ( nStyle & ItemStyle::ALIGN_RIGHT )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_ALIGN,
- m_aAttributeType,
ATTRIBUTE_ALIGN_RIGHT );
}
else if ( nStyle & ItemStyle::ALIGN_CENTER )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_ALIGN,
- m_aAttributeType,
ATTRIBUTE_ALIGN_CENTER );
}
else
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_ALIGN,
- m_aAttributeType,
ATTRIBUTE_ALIGN_LEFT );
}
@@ -591,13 +562,11 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( nStyle & ItemStyle::DRAW_FLAT )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_STYLE,
- m_aAttributeType,
ATTRIBUTE_STYLE_FLAT );
}
else if ( nStyle & ItemStyle::DRAW_OUT3D )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_STYLE,
- m_aAttributeType,
ATTRIBUTE_STYLE_OUT );
}
@@ -605,7 +574,6 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( nStyle & ItemStyle::AUTO_SIZE )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_AUTOSIZE,
- m_aAttributeType,
ATTRIBUTE_BOOLEAN_TRUE );
}
@@ -613,7 +581,6 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( nStyle & ItemStyle::OWNER_DRAW )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_OWNERDRAW,
- m_aAttributeType,
ATTRIBUTE_BOOLEAN_TRUE );
}
@@ -621,7 +588,6 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( nWidth > 0 )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_WIDTH,
- m_aAttributeType,
OUString::number( nWidth ) );
}
@@ -629,7 +595,6 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( nOffset != STATUSBAR_OFFSET )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_OFFSET,
- m_aAttributeType,
OUString::number( nOffset ) );
}
@@ -637,12 +602,11 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
if ( !( nStyle & ItemStyle::MANDATORY ) )
{
pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_MANDATORY,
- m_aAttributeType,
ATTRIBUTE_BOOLEAN_FALSE );
}
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBARITEM, xList );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBARITEM, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->endElement( ELEMENT_NS_STATUSBARITEM );
}
diff --git a/framework/source/fwe/xml/toolboxconfiguration.cxx b/framework/source/fwe/xml/toolboxconfiguration.cxx
index d9e34baabc98..c88b3c01da2d 100644
--- a/framework/source/fwe/xml/toolboxconfiguration.cxx
+++ b/framework/source/fwe/xml/toolboxconfiguration.cxx
@@ -29,7 +29,6 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::container;
diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
index 8d7b9835c3f4..7464939e1e03 100644
--- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx
+++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
@@ -30,29 +30,30 @@
#include <sal/config.h>
#include <sal/macros.h>
-#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/attributelist.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::xml::sax;
-#define TOOLBAR_DOCTYPE "<!DOCTYPE toolbar:toolbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"toolbar.dtd\">"
+constexpr OUStringLiteral TOOLBAR_DOCTYPE = u"<!DOCTYPE toolbar:toolbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"toolbar.dtd\">";
namespace framework
{
// Property names of a menu/menu item ItemDescriptor
-constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_VISIBLE = u"IsVisible";
+constexpr OUString ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_LABEL = u"Label"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_TYPE = u"Type"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_STYLE = u"Style"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_VISIBLE = u"IsVisible"_ustr;
static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
OUString& rCommandURL,
@@ -64,10 +65,7 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
for ( const PropertyValue& rEntry : rProp )
{
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
- {
rEntry.Value >>= rCommandURL;
- rCommandURL = rCommandURL.intern();
- }
else if ( rEntry.Name == ITEM_DESCRIPTOR_LABEL )
rEntry.Value >>= rLabel;
else if ( rEntry.Name == ITEM_DESCRIPTOR_TYPE )
@@ -84,12 +82,12 @@ namespace {
struct ToolboxStyleItem
{
sal_Int16 nBit;
- const char* attrName;
+ OUString attrName;
};
}
-const ToolboxStyleItem Styles[ ] = {
+constexpr ToolboxStyleItem Styles[ ] = {
{ css::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO },
{ css::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT },
{ css::ui::ItemStyle::AUTO_SIZE, ATTRIBUTE_ITEMSTYLE_AUTO },
@@ -135,7 +133,7 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
m_aCommandURL( ITEM_DESCRIPTOR_COMMANDURL )
{
// create hash map
- for ( int i = 0; i < int(TB_XML_ENTRY_COUNT); i++ )
+ for ( int i = 0; i < TB_XML_ENTRY_COUNT; i++ )
{
if ( ToolBoxEntries[i].nNamespace == TB_NS_TOOLBAR )
{
@@ -151,16 +149,6 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
}
}
- // pre-calculate a hash code for all style strings to speed up xml read process
- m_nHashCode_Style_Radio = OUString( ATTRIBUTE_ITEMSTYLE_RADIO ).hashCode();
- m_nHashCode_Style_Left = OUString( ATTRIBUTE_ITEMSTYLE_LEFT ).hashCode();
- m_nHashCode_Style_AutoSize = OUString( ATTRIBUTE_ITEMSTYLE_AUTOSIZE ).hashCode();
- m_nHashCode_Style_DropDown = OUString( ATTRIBUTE_ITEMSTYLE_DROPDOWN ).hashCode();
- m_nHashCode_Style_Repeat = OUString( ATTRIBUTE_ITEMSTYLE_REPEAT ).hashCode();
- m_nHashCode_Style_DropDownOnly = OUString( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY ).hashCode();
- m_nHashCode_Style_Text = OUString( ATTRIBUTE_ITEMSTYLE_TEXT ).hashCode();
- m_nHashCode_Style_Image = OUString( ATTRIBUTE_ITEMSTYLE_IMAGE ).hashCode();
-
m_bToolBarStartFound = false;
m_bToolBarItemStartFound = false;
m_bToolBarSpaceStartFound = false;
@@ -179,8 +167,6 @@ void SAL_CALL OReadToolBoxDocumentHandler::startDocument()
void SAL_CALL OReadToolBoxDocumentHandler::endDocument()
{
- SolarMutexGuard g;
-
if ( m_bToolBarStartFound )
{
OUString aErrorMessage = getErrorLineString() + "No matching start or end element 'toolbar' found!";
@@ -191,8 +177,6 @@ void SAL_CALL OReadToolBoxDocumentHandler::endDocument()
void SAL_CALL OReadToolBoxDocumentHandler::startElement(
const OUString& aName, const Reference< XAttributeList > &xAttribs )
{
- SolarMutexGuard g;
-
ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName );
if ( pToolBoxEntry == m_aToolBoxMap.end() )
return;
@@ -233,7 +217,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
{
try
{
- xPropSet->setPropertyValue("UIName", makeAny( aUIName ) );
+ xPropSet->setPropertyValue("UIName", Any( aUIName ) );
}
catch ( const UnknownPropertyException& )
{
@@ -287,7 +271,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
case TB_ATTRIBUTE_URL:
{
bAttributeURL = true;
- aCommandURL = xAttribs->getValueByIndex( n ).intern();
+ aCommandURL = xAttribs->getValueByIndex( n );
}
break;
@@ -316,22 +300,21 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
OUString aToken = aTemp.getToken( 0, ' ', nIndex );
if ( !aToken.isEmpty() )
{
- sal_Int32 nHashCode = aToken.hashCode();
- if ( nHashCode == m_nHashCode_Style_Radio )
+ if ( aToken == ATTRIBUTE_ITEMSTYLE_RADIO )
nItemBits |= css::ui::ItemStyle::RADIO_CHECK;
- else if ( nHashCode == m_nHashCode_Style_Left )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_LEFT )
nItemBits |= css::ui::ItemStyle::ALIGN_LEFT;
- else if ( nHashCode == m_nHashCode_Style_AutoSize )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_AUTOSIZE )
nItemBits |= css::ui::ItemStyle::AUTO_SIZE;
- else if ( nHashCode == m_nHashCode_Style_Repeat )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_REPEAT )
nItemBits |= css::ui::ItemStyle::REPEAT;
- else if ( nHashCode == m_nHashCode_Style_DropDownOnly )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY )
nItemBits |= css::ui::ItemStyle::DROPDOWN_ONLY;
- else if ( nHashCode == m_nHashCode_Style_DropDown )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_DROPDOWN )
nItemBits |= css::ui::ItemStyle::DROP_DOWN;
- else if ( nHashCode == m_nHashCode_Style_Text )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_TEXT )
nItemBits |= css::ui::ItemStyle::TEXT;
- else if ( nHashCode == m_nHashCode_Style_Image )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_IMAGE )
nItemBits |= css::ui::ItemStyle::ICON;
}
}
@@ -375,14 +358,14 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
}
auto aToolbarItemProp( comphelper::InitPropertySequence( {
- { m_aCommandURL, css::uno::makeAny( aCommandURL ) },
- { m_aLabel, css::uno::makeAny( aLabel ) },
- { m_aType, css::uno::makeAny( css::ui::ItemType::DEFAULT ) },
- { m_aStyle, css::uno::makeAny( nItemBits ) },
- { m_aIsVisible, css::uno::makeAny( bVisible ) },
+ { m_aCommandURL, css::uno::Any( aCommandURL ) },
+ { m_aLabel, css::uno::Any( aLabel ) },
+ { m_aType, css::uno::Any( css::ui::ItemType::DEFAULT ) },
+ { m_aStyle, css::uno::Any( nItemBits ) },
+ { m_aIsVisible, css::uno::Any( bVisible ) },
} ) );
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
}
break;
@@ -400,14 +383,12 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
m_bToolBarSpaceStartFound = true;
- Sequence< PropertyValue > aToolbarItemProp( 2 );
- aToolbarItemProp[0].Name = m_aCommandURL;
- aToolbarItemProp[1].Name = m_aType;
-
- aToolbarItemProp[0].Value <<= OUString();
- aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_SPACE;
+ Sequence< PropertyValue > aToolbarItemProp{
+ comphelper::makePropertyValue(m_aCommandURL, OUString()),
+ comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_SPACE)
+ };
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -424,14 +405,12 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
m_bToolBarBreakStartFound = true;
- Sequence< PropertyValue > aToolbarItemProp( 2 );
- aToolbarItemProp[0].Name = m_aCommandURL;
- aToolbarItemProp[1].Name = m_aType;
-
- aToolbarItemProp[0].Value <<= OUString();
- aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINEBREAK;
+ Sequence< PropertyValue > aToolbarItemProp{
+ comphelper::makePropertyValue(m_aCommandURL, OUString()),
+ comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_LINEBREAK)
+ };
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -448,14 +427,12 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
m_bToolBarSeparatorStartFound = true;
- Sequence< PropertyValue > aToolbarItemProp( 2 );
- aToolbarItemProp[0].Name = m_aCommandURL;
- aToolbarItemProp[1].Name = m_aType;
+ Sequence< PropertyValue > aToolbarItemProp{
+ comphelper::makePropertyValue(m_aCommandURL, OUString()),
+ comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_LINE)
+ };
- aToolbarItemProp[0].Value <<= OUString();
- aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINE;
-
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -466,8 +443,6 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
void SAL_CALL OReadToolBoxDocumentHandler::endElement(const OUString& aName)
{
- SolarMutexGuard g;
-
ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName );
if ( pToolBoxEntry == m_aToolBoxMap.end() )
return;
@@ -554,15 +529,11 @@ void SAL_CALL OReadToolBoxDocumentHandler::processingInstruction(
void SAL_CALL OReadToolBoxDocumentHandler::setDocumentLocator(
const Reference< XLocator > &xLocator)
{
- SolarMutexGuard g;
-
m_xLocator = xLocator;
}
OUString OReadToolBoxDocumentHandler::getErrorLineString()
{
- SolarMutexGuard g;
-
if ( m_xLocator.is() )
return "Line: " + OUString::number( m_xLocator->getLineNumber() ) + " - ";
else
@@ -577,9 +548,7 @@ OWriteToolBoxDocumentHandler::OWriteToolBoxDocumentHandler(
m_xWriteDocumentHandler( rWriteDocumentHandler ),
m_rItemAccess( rItemAccess )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY );
- m_aAttributeType = ATTRIBUTE_TYPE_CDATA;
+ m_xEmptyList = new ::comphelper::AttributeList;
m_aXMLXlinkNS = XMLNS_XLINK_PREFIX;
m_aXMLToolbarNS = XMLNS_TOOLBAR_PREFIX;
}
@@ -590,8 +559,6 @@ OWriteToolBoxDocumentHandler::~OWriteToolBoxDocumentHandler()
void OWriteToolBoxDocumentHandler::WriteToolBoxDocument()
{
- SolarMutexGuard g;
-
m_xWriteDocumentHandler->startDocument();
// write DOCTYPE line!
@@ -618,19 +585,16 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxDocument()
rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( ATTRIBUTE_XMLNS_TOOLBAR,
- m_aAttributeType,
XMLNS_TOOLBAR );
pList->AddAttribute( ATTRIBUTE_XMLNS_XLINK,
- m_aAttributeType,
XMLNS_XLINK );
if ( !aUIName.isEmpty() )
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_UINAME,
- m_aAttributeType,
aUIName );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBAR, pList.get() );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBAR, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
sal_Int32 nItemCount = m_rItemAccess->getCount();
@@ -674,8 +638,7 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
sal_Int16 nStyle,
bool bVisible )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
if ( m_aAttributeURL.isEmpty() )
{
@@ -683,19 +646,17 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
}
// save required attribute (URL)
- pList->AddAttribute( m_aAttributeURL, m_aAttributeType, rCommandURL );
+ pList->AddAttribute( m_aAttributeURL, rCommandURL );
if ( !rLabel.isEmpty() )
{
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_TEXT,
- m_aAttributeType,
rLabel );
}
if ( !bVisible )
{
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_VISIBLE,
- m_aAttributeType,
ATTRIBUTE_BOOLEAN_FALSE );
}
@@ -710,16 +671,15 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
{
if ( !aValue.isEmpty() )
aValue.append(" ");
- aValue.appendAscii( pStyle->attrName );
+ aValue.append( pStyle->attrName );
}
}
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_ITEMSTYLE,
- m_aAttributeType,
aValue.makeStringAndClear() );
}
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBARITEM, xList );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBARITEM, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->endElement( ELEMENT_NS_TOOLBARITEM );
}
diff --git a/framework/source/fwi/classes/converter.cxx b/framework/source/fwi/classes/converter.cxx
index 33af820202c9..59ae35d396b5 100644
--- a/framework/source/fwi/classes/converter.cxx
+++ b/framework/source/fwi/classes/converter.cxx
@@ -29,10 +29,11 @@ css::uno::Sequence< css::beans::NamedValue > Converter::convert_seqPropVal2seqNa
{
sal_Int32 nCount = lSource.getLength();
css::uno::Sequence< css::beans::NamedValue > lDestination(nCount);
+ auto lDestinationRange = asNonConstRange(lDestination);
for (sal_Int32 nItem=0; nItem<nCount; ++nItem)
{
- lDestination[nItem].Name = lSource[nItem].Name;
- lDestination[nItem].Value = lSource[nItem].Value;
+ lDestinationRange[nItem].Name = lSource[nItem].Name;
+ lDestinationRange[nItem].Value = lSource[nItem].Value;
}
return lDestination;
}
@@ -75,36 +76,37 @@ OUString Converter::convert_DateTime2ISO8601( const DateTime& aSource )
sBuffer.append("0");
sBuffer.append( nYear );
- sBuffer.append("-");
// write month formatted as "MM"
+ sBuffer.append("-");
if (nMonth<10)
sBuffer.append("0");
sBuffer.append( nMonth );
- sBuffer.append("-");
// write day formatted as "DD"
+ sBuffer.append("-");
if (nDay<10)
sBuffer.append("0");
sBuffer.append( nDay );
- sBuffer.append("T");
// write hours formatted as "hh"
+ sBuffer.append("T");
if (nHour<10)
sBuffer.append("0");
sBuffer.append( nHour );
- sBuffer.append(":");
// write min formatted as "mm"
+ sBuffer.append(":");
if (nMin<10)
sBuffer.append("0");
sBuffer.append( nMin );
- sBuffer.append(":");
// write sec formatted as "ss"
+ sBuffer.append(":");
if (nSec<10)
sBuffer.append("0");
sBuffer.append( nSec );
+ // write time-zone
sBuffer.append("Z");
return sBuffer.makeStringAndClear();
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 9288536480d9..97831aca5e94 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -31,7 +31,7 @@
#include <sal/log.hxx>
#include <vcl/svapp.hxx>
-#define SETNAME_HANDLER "HandlerSet" // name of configuration set inside package
+constexpr OUString SETNAME_HANDLER = u"HandlerSet"_ustr; // name of configuration set inside package
namespace framework{
@@ -68,8 +68,8 @@ PatternHash::const_iterator findPatternKey(PatternHash const * hash, const OUStr
That means it use two static member list to hold all necessary information
and a ref count mechanism to create/destroy it on demand.
*/
-std::unique_ptr<HandlerHash> HandlerCache::s_pHandler;
-std::unique_ptr<PatternHash> HandlerCache::s_pPattern;
+std::optional<HandlerHash> HandlerCache::s_pHandler;
+std::optional<PatternHash> HandlerCache::s_pPattern;
sal_Int32 HandlerCache::m_nRefCount = 0;
HandlerCFGAccess* HandlerCache::s_pConfig = nullptr;
@@ -86,8 +86,8 @@ HandlerCache::HandlerCache()
if (m_nRefCount==0)
{
- s_pHandler.reset(new HandlerHash);
- s_pPattern.reset(new PatternHash);
+ s_pHandler.emplace();
+ s_pPattern.emplace();
s_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
s_pConfig->read(*s_pHandler, *s_pPattern);
s_pConfig->setCache(this);
@@ -123,13 +123,14 @@ HandlerCache::~HandlerCache()
@descr It frees all used memory. In further implementations (may if we support write access too)
it's a good place to flush changes back to the configuration - but not needed yet.
*/
-bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) const
+// static
+bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn )
{
bool bFound = false;
SolarMutexGuard aGuard;
- PatternHash::const_iterator pItem = findPatternKey(s_pPattern.get(), sURL);
+ PatternHash::const_iterator pItem = findPatternKey(s_pPattern ? &*s_pPattern : nullptr, sURL);
if (pItem != s_pPattern->end())
{
*pReturn = (*s_pHandler)[pItem->second];
@@ -145,17 +146,19 @@ bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) cons
and call our other search method ...
It's a helper for outside code.
*/
-bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pReturn ) const
+// static
+bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pReturn )
{
return search( aURL.Complete, pReturn );
}
-void HandlerCache::takeOver(std::unique_ptr<HandlerHash> pHandler, std::unique_ptr<PatternHash> pPattern)
+// static
+void HandlerCache::takeOver(HandlerHash aHandler, PatternHash aPattern)
{
SolarMutexGuard aGuard;
- s_pHandler = std::move(pHandler);
- s_pPattern = std::move(pPattern);
+ s_pHandler = std::move(aHandler);
+ s_pPattern = std::move(aPattern);
}
/**
@@ -193,14 +196,14 @@ void HandlerCFGAccess::read( HandlerHash& rHandlerHash, PatternHash& rPatternHas
sal_Int32 nTargetCount = nSourceCount;
// list of all full qualified path names of configuration entries
css::uno::Sequence< OUString > lFullNames ( nTargetCount );
-
+ auto lFullNamesRange = asNonConstRange(lFullNames);
// expand names to full path names
sal_Int32 nSource=0;
sal_Int32 nTarget=0;
for( nSource=0; nSource<nSourceCount; ++nSource )
{
- lFullNames[nTarget] =
- SETNAME_HANDLER
+ lFullNamesRange[nTarget] =
+ SETNAME_HANDLER +
CFG_PATH_SEPARATOR +
lNames[nSource] +
CFG_PATH_SEPARATOR
@@ -240,12 +243,12 @@ void HandlerCFGAccess::read( HandlerHash& rHandlerHash, PatternHash& rPatternHas
void HandlerCFGAccess::Notify(const css::uno::Sequence< OUString >& /*lPropertyNames*/)
{
- std::unique_ptr<HandlerHash> pHandler(new HandlerHash);
- std::unique_ptr<PatternHash> pPattern(new PatternHash);
+ HandlerHash aHandler;
+ PatternHash aPattern;
- read(*pHandler, *pPattern);
+ read(aHandler, aPattern);
if (m_pCache)
- m_pCache->takeOver(std::move(pHandler), std::move(pPattern));
+ framework::HandlerCache::takeOver(std::move(aHandler), std::move(aPattern));
}
void HandlerCFGAccess::ImplCommit()
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index b53cd0f2672d..af83c5867356 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -31,8 +31,6 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
namespace framework
@@ -133,17 +131,19 @@ void FillLangItems( std::set< OUString > &rLangItems,
}
auto (*g_pGetMultiplexerListener)(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const&,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const&)
-> uno::Reference<ui::XContextChangeEventListener> = nullptr;
uno::Reference<ui::XContextChangeEventListener>
GetFirstListenerWith_Impl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(g_pGetMultiplexerListener != nullptr); // should not be called too early, nor too late
- return g_pGetMultiplexerListener(xEventFocus, rPredicate);
+ return g_pGetMultiplexerListener(xComponentContext, xEventFocus, rPredicate);
}
diff --git a/framework/source/fwi/jobs/configaccess.cxx b/framework/source/fwi/jobs/configaccess.cxx
index bcb739c09cdb..045da5ba401f 100644
--- a/framework/source/fwi/jobs/configaccess.cxx
+++ b/framework/source/fwi/jobs/configaccess.cxx
@@ -23,8 +23,9 @@
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
+#include <utility>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace framework{
@@ -39,10 +40,10 @@ namespace framework{
@param eMode
force opening of the configuration access in readonly or in read/write mode
*/
-ConfigAccess::ConfigAccess( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
- /*IN*/ const OUString& sRoot )
- : m_xContext ( rxContext)
- , m_sRoot ( sRoot )
+ConfigAccess::ConfigAccess( /*IN*/ css::uno::Reference< css::uno::XComponentContext > xContext,
+ /*IN*/ OUString sRoot )
+ : m_xContext (std::move( xContext))
+ , m_sRoot (std::move( sRoot ))
, m_eMode ( E_CLOSED )
{
}
@@ -67,7 +68,7 @@ ConfigAccess::~ConfigAccess()
*/
ConfigAccess::EOpenMode ConfigAccess::getMode() const
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
return m_eMode;
}
@@ -87,7 +88,7 @@ ConfigAccess::EOpenMode ConfigAccess::getMode() const
*/
void ConfigAccess::open( /*IN*/ EOpenMode eMode )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
// check if configuration is already open in the right mode.
// By the way: Don't allow closing by using this method!
@@ -99,7 +100,7 @@ void ConfigAccess::open( /*IN*/ EOpenMode eMode )
// can be called without checks! It does the checks by itself ...
// e.g. for already closed or not opened configuration.
// Flushing of all made changes will be done here too.
- close();
+ closeImpl();
// create the configuration provider, which provides sub access points
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = css::configuration::theDefaultProvider::get(m_xContext);
@@ -107,8 +108,7 @@ void ConfigAccess::open( /*IN*/ EOpenMode eMode )
aParam.Name = "nodepath";
aParam.Value <<= m_sRoot;
- css::uno::Sequence< css::uno::Any > lParams(1);
- lParams[0] <<= aParam;
+ css::uno::Sequence< css::uno::Any > lParams{ css::uno::Any(aParam) };
// open it
try
@@ -136,7 +136,12 @@ void ConfigAccess::open( /*IN*/ EOpenMode eMode )
*/
void ConfigAccess::close()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
+ closeImpl();
+}
+
+void ConfigAccess::closeImpl()
+{
// check already closed configuration
if (m_xConfig.is())
{
diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx
index 21c8fb69bf13..86d5b354a064 100644
--- a/framework/source/fwi/threadhelp/transactionmanager.cxx
+++ b/framework/source/fwi/threadhelp/transactionmanager.cxx
@@ -71,7 +71,7 @@ void TransactionManager::setWorkingMode( EWorkingMode eMode )
// Safe member access.
bool bWaitFor = false;
{
- osl::MutexGuard aAccessGuard(m_aAccessLock);
+ std::unique_lock aAccessGuard(m_aAccessLock);
// Change working mode first!
if (
(m_eWorkingMode == E_INIT && eMode == E_WORK) ||
@@ -137,7 +137,7 @@ void TransactionManager::setWorkingMode( EWorkingMode eMode )
EWorkingMode TransactionManager::getWorkingMode() const
{
// Synchronize access to internal member!
- ::osl::MutexGuard aAccessLock( m_aAccessLock );
+ std::unique_lock aAccessLock( m_aAccessLock );
return m_eWorkingMode;
}
@@ -154,7 +154,7 @@ EWorkingMode TransactionManager::getWorkingMode() const
*//*-*****************************************************************************************************/
void TransactionManager::registerTransaction( EExceptionMode eMode )
{
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
+ std::unique_lock aAccessGuard( m_aAccessLock );
switch( m_eWorkingMode )
{
case E_INIT:
@@ -201,7 +201,7 @@ void TransactionManager::unregisterTransaction()
{
// This call could not rejected!
// Safe access to internal member.
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
+ std::unique_lock aAccessGuard( m_aAccessLock );
// Deregister this transaction.
// If it was the last one ... open gate to enable changing of working mode!
diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx
index e02fb7aa3d9a..40865c8f1b81 100644
--- a/framework/source/fwi/uielement/constitemcontainer.cxx
+++ b/framework/source/fwi/uielement/constitemcontainer.cxx
@@ -25,6 +25,7 @@
#include <comphelper/propertysetinfo.hxx>
#include <comphelper/servicehelper.hxx>
+#include <rtl/ref.hxx>
using namespace cppu;
using namespace com::sun::star::uno;
@@ -33,7 +34,7 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::container;
const int PROPHANDLE_UINAME = 1;
-constexpr OUStringLiteral PROPNAME_UINAME = u"UIName";
+constexpr OUString PROPNAME_UINAME = u"UIName"_ustr;
namespace framework
{
@@ -99,7 +100,7 @@ ConstItemContainer::ConstItemContainer( const Reference< XIndexAccess >& rSource
}
if ( xIndexAccess.is() && nContainerIndex >= 0 )
- aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
+ aPropSeq.getArray()[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
m_aItemVector.push_back( aPropSeq );
}
@@ -135,7 +136,7 @@ void ConstItemContainer::copyItemContainer( const std::vector< Sequence< Propert
}
if ( xIndexAccess.is() && nContainerIndex >= 0 )
- aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
+ aPropSeq.getArray()[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
m_aItemVector.push_back( aPropSeq );
}
@@ -146,38 +147,18 @@ Reference< XIndexAccess > ConstItemContainer::deepCopyContainer( const Reference
Reference< XIndexAccess > xReturn;
if ( rSubContainer.is() )
{
- ItemContainer* pSource = comphelper::getUnoTunnelImplementation<ItemContainer>( rSubContainer );
- ConstItemContainer* pSubContainer( nullptr );
+ ItemContainer* pSource = dynamic_cast<ItemContainer*>( rSubContainer.get() );
+ rtl::Reference<ConstItemContainer> pSubContainer;
if ( pSource )
pSubContainer = new ConstItemContainer( *pSource );
else
pSubContainer = new ConstItemContainer( rSubContainer );
- xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY );
+ xReturn = pSubContainer;
}
return xReturn;
}
-// XUnoTunnel
-sal_Int64 ConstItemContainer::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if( isUnoTunnelId<ConstItemContainer>(rIdentifier) )
- {
- return reinterpret_cast< sal_Int64 >( this );
- }
- return 0;
-}
-
-namespace
-{
- class theConstItemContainerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theConstItemContainerUnoTunnelId > {};
-}
-
-const Sequence< sal_Int8 >& ConstItemContainer::getUnoTunnelId() throw()
-{
- return theConstItemContainerUnoTunnelId::get().getSeq();
-}
-
// XElementAccess
sal_Bool SAL_CALL ConstItemContainer::hasElements()
{
@@ -194,7 +175,18 @@ Any SAL_CALL ConstItemContainer::getByIndex( sal_Int32 Index )
{
if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
- return makeAny( m_aItemVector[Index] );
+ return Any( m_aItemVector[Index] );
+}
+
+namespace
+{
+ std::vector<comphelper::PropertyMapEntry> makePropertyMap(const css::uno::Sequence<css::beans::Property>& rProps)
+ {
+ std::vector<comphelper::PropertyMapEntry> aEntries;
+ for (auto const& it : rProps)
+ aEntries.emplace_back(it.Name, it.Handle, it.Type, it.Attributes, 0);
+ return aEntries;
+ }
}
// XPropertySet
@@ -202,7 +194,8 @@ Reference< XPropertySetInfo > SAL_CALL ConstItemContainer::getPropertySetInfo()
{
// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
// (Use method "getInfoHelper()".)
- static Reference< XPropertySetInfo > xInfo(new comphelper::PropertySetInfo(getInfoHelper().getProperties()));
+ static std::vector<comphelper::PropertyMapEntry> aPropertyInfos(makePropertyMap(getInfoHelper().getProperties()));
+ static Reference< XPropertySetInfo > xInfo(new comphelper::PropertySetInfo(aPropertyInfos));
return xInfo;
}
@@ -214,7 +207,7 @@ void SAL_CALL ConstItemContainer::setPropertyValue( const OUString&, const Any&
Any SAL_CALL ConstItemContainer::getPropertyValue( const OUString& PropertyName )
{
if ( PropertyName == PROPNAME_UINAME )
- return makeAny( m_aUIName );
+ return Any( m_aUIName );
throw UnknownPropertyException(PropertyName);
}
@@ -246,7 +239,7 @@ void SAL_CALL ConstItemContainer::setFastPropertyValue( sal_Int32, const css::un
Any SAL_CALL ConstItemContainer::getFastPropertyValue( sal_Int32 nHandle )
{
if ( nHandle == PROPHANDLE_UINAME )
- return makeAny( m_aUIName );
+ return Any( m_aUIName );
throw UnknownPropertyException(OUString::number(nHandle));
}
diff --git a/framework/source/fwi/uielement/itemcontainer.cxx b/framework/source/fwi/uielement/itemcontainer.cxx
index de2b047653ab..22bd077fced3 100644
--- a/framework/source/fwi/uielement/itemcontainer.cxx
+++ b/framework/source/fwi/uielement/itemcontainer.cxx
@@ -23,6 +23,7 @@
#include <uielement/itemcontainer.hxx>
#include <uielement/constitemcontainer.hxx>
#include <comphelper/servicehelper.hxx>
+#include <rtl/ref.hxx>
using namespace cppu;
using namespace com::sun::star::uno;
@@ -30,8 +31,8 @@ using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::container;
-constexpr OUStringLiteral WRONG_TYPE_EXCEPTION
- = u"Type must be css::uno::Sequence< css::beans::PropertyValue >";
+constexpr OUString WRONG_TYPE_EXCEPTION
+ = u"Type must be css::uno::Sequence< css::beans::PropertyValue >"_ustr;
namespace framework
{
@@ -75,7 +76,7 @@ ItemContainer::ItemContainer( const Reference< XIndexAccess >& rSourceContainer,
}
if ( xIndexAccess.is() && nContainerIndex >= 0 )
- aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex );
+ aPropSeq.getArray()[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex );
m_aItemVector.push_back( aPropSeq );
}
@@ -110,7 +111,7 @@ void ItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValu
}
if ( xIndexAccess.is() && nContainerIndex >= 0 )
- aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex );
+ aPropSeq.getArray()[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex );
m_aItemVector.push_back( aPropSeq );
}
@@ -121,28 +122,18 @@ Reference< XIndexAccess > ItemContainer::deepCopyContainer( const Reference< XIn
Reference< XIndexAccess > xReturn;
if ( rSubContainer.is() )
{
- ConstItemContainer* pSource = comphelper::getUnoTunnelImplementation<ConstItemContainer>( rSubContainer );
- ItemContainer* pSubContainer( nullptr );
+ ConstItemContainer* pSource = dynamic_cast<ConstItemContainer*>( rSubContainer.get() );
+ rtl::Reference<ItemContainer> pSubContainer;
if ( pSource )
pSubContainer = new ItemContainer( *pSource, rMutex );
else
pSubContainer = new ItemContainer( rSubContainer, rMutex );
- xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY );
+ xReturn = pSubContainer;
}
return xReturn;
}
-namespace
-{
- class theItemContainerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theItemContainerUnoTunnelId > {};
-}
-
-const Sequence< sal_Int8 >& ItemContainer::getUnoTunnelId() throw()
-{
- return theItemContainerUnoTunnelId::get().getSeq();
-}
-
// XElementAccess
sal_Bool SAL_CALL ItemContainer::hasElements()
{
@@ -163,7 +154,7 @@ Any SAL_CALL ItemContainer::getByIndex( sal_Int32 Index )
if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
- return makeAny( m_aItemVector[Index] );
+ return Any( m_aItemVector[Index] );
}
// XIndexContainer
diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx
index b570154f2eb0..652f0dd8029f 100644
--- a/framework/source/fwi/uielement/rootitemcontainer.cxx
+++ b/framework/source/fwi/uielement/rootitemcontainer.cxx
@@ -26,6 +26,7 @@
#include <properties.h>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <rtl/ref.hxx>
using namespace cppu;
using namespace com::sun::star::uno;
@@ -33,11 +34,11 @@ using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::container;
-constexpr OUStringLiteral WRONG_TYPE_EXCEPTION
- = u"Type must be css::uno::Sequence< css::beans::PropertyValue >";
+constexpr OUString WRONG_TYPE_EXCEPTION
+ = u"Type must be css::uno::Sequence< css::beans::PropertyValue >"_ustr;
const int PROPHANDLE_UINAME = 1;
-constexpr OUStringLiteral PROPNAME_UINAME = u"UIName";
+constexpr OUString PROPNAME_UINAME = u"UIName"_ustr;
namespace framework
{
@@ -89,7 +90,7 @@ RootItemContainer::RootItemContainer( const Reference< XIndexAccess >& rSourceCo
}
if ( xIndexAccess.is() && nContainerIndex >= 0 )
- aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
+ aPropSeq.getArray()[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
m_aItemVector.push_back( aPropSeq );
}
@@ -125,36 +126,18 @@ Reference< XIndexAccess > RootItemContainer::deepCopyContainer( const Reference<
Reference< XIndexAccess > xReturn;
if ( rSubContainer.is() )
{
- ConstItemContainer* pSource = comphelper::getUnoTunnelImplementation<ConstItemContainer>( rSubContainer );
- ItemContainer* pSubContainer( nullptr );
+ ConstItemContainer* pSource = dynamic_cast<ConstItemContainer*>( rSubContainer.get() );
+ rtl::Reference<ItemContainer> pSubContainer;
if ( pSource )
pSubContainer = new ItemContainer( *pSource, m_aShareMutex );
else
pSubContainer = new ItemContainer( rSubContainer, m_aShareMutex );
- xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY );
+ xReturn = pSubContainer;
}
return xReturn;
}
-// XUnoTunnel
-sal_Int64 RootItemContainer::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if( isUnoTunnelId<RootItemContainer>(rIdentifier) )
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
- return 0;
-}
-
-namespace
-{
- class theRootItemContainerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theRootItemContainerUnoTunnelId > {};
-}
-
-const Sequence< sal_Int8 >& RootItemContainer::getUnoTunnelId() throw()
-{
- return theRootItemContainerUnoTunnelId::get().getSeq();
-}
-
// XElementAccess
sal_Bool SAL_CALL RootItemContainer::hasElements()
{
@@ -175,7 +158,7 @@ Any SAL_CALL RootItemContainer::getByIndex( sal_Int32 Index )
if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
- return makeAny( m_aItemVector[Index] );
+ return Any( m_aItemVector[Index] );
}
// XIndexContainer
@@ -244,7 +227,7 @@ sal_Bool SAL_CALL RootItemContainer::convertFastPropertyValue( Any& aConve
{
case PROPHANDLE_UINAME:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_aUIName),
+ css::uno::Any(m_aUIName),
aValue,
aOldValue,
aConvertedValue);
diff --git a/framework/source/helper/dockingareadefaultacceptor.cxx b/framework/source/helper/dockingareadefaultacceptor.cxx
index d167bc11157f..13afa6656e7f 100644
--- a/framework/source/helper/dockingareadefaultacceptor.cxx
+++ b/framework/source/helper/dockingareadefaultacceptor.cxx
@@ -26,12 +26,10 @@
namespace framework{
-using namespace ::com::sun::star::container;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::cppu;
-using namespace ::osl;
// constructor
@@ -64,32 +62,30 @@ sal_Bool SAL_CALL DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css
// Try to "lock" the frame for access to taskscontainer.
css::uno::Reference< XFrame > xFrame( m_xOwner );
- if ( xFrame.is() )
- {
- css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
- css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
-
- if ( xContainerWindow.is() && xComponentWindow.is() )
- {
- css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
- // Convert relative size to output size.
- css::awt::Rectangle aRectangle = xContainerWindow->getPosSize();
- css::awt::DeviceInfo aInfo = xDevice->getInfo();
- css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
- aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
-
- css::awt::Size aMinSize( 0, 0 ); // = xLayoutConstraints->getMinimumSize();
-
- // Check if request border space would decrease component window size below minimum size
- if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) ||
- (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height ) )
- return false;
-
- return true;
- }
- }
+ if ( !xFrame.is() )
+ return false;
+
+ css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
+ css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
+
+ if ( !xContainerWindow.is() || !xComponentWindow.is() )
+ return false;
+
+ css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
+ // Convert relative size to output size.
+ css::awt::Rectangle aRectangle = xContainerWindow->getPosSize();
+ css::awt::DeviceInfo aInfo = xDevice->getInfo();
+ css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
+ aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
+
+ css::awt::Size aMinSize( 0, 0 ); // = xLayoutConstraints->getMinimumSize();
+
+ // Check if request border space would decrease component window size below minimum size
+ if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) ||
+ (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height ) )
+ return false;
- return false;
+ return true;
}
void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle& BorderSpace )
diff --git a/framework/source/helper/ocomponentaccess.cxx b/framework/source/helper/ocomponentaccess.cxx
index b814fc49b83a..578f5ce2751e 100644
--- a/framework/source/helper/ocomponentaccess.cxx
+++ b/framework/source/helper/ocomponentaccess.cxx
@@ -32,7 +32,6 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::cppu;
-using namespace ::osl;
// constructor
@@ -68,8 +67,7 @@ css::uno::Reference< XEnumeration > SAL_CALL OComponentAccess::createEnumeration
std::vector< css::uno::Reference< XComponent > > seqComponents;
impl_collectAllChildComponents( css::uno::Reference< XFramesSupplier >( xLock, UNO_QUERY ), seqComponents );
- OComponentEnumeration* pEnumeration = new OComponentEnumeration( seqComponents );
- xReturn.set( static_cast<OWeakObject*>(pEnumeration), UNO_QUERY );
+ xReturn = new OComponentEnumeration( std::move(seqComponents) );
}
// Return result of this operation.
@@ -104,7 +102,7 @@ sal_Bool SAL_CALL OComponentAccess::hasElements()
return bReturn;
}
-
+// static
void OComponentAccess::impl_collectAllChildComponents( const css::uno::Reference< XFramesSupplier >& xNode ,
std::vector< css::uno::Reference< XComponent > >& seqComponents )
{
@@ -132,7 +130,8 @@ void OComponentAccess::impl_collectAllChildComponents( const css::uno::Referenc
// ... otherwise break a recursive path and go back at current stack!
}
-css::uno::Reference< XComponent > OComponentAccess::impl_getFrameComponent( const css::uno::Reference< XFrame >& xFrame ) const
+// static
+css::uno::Reference< XComponent > OComponentAccess::impl_getFrameComponent( const css::uno::Reference< XFrame >& xFrame )
{
// Set default return value, if method failed.
css::uno::Reference< XComponent > xComponent;
diff --git a/framework/source/helper/ocomponentenumeration.cxx b/framework/source/helper/ocomponentenumeration.cxx
index 2a06c558c3e4..6b8112124d9b 100644
--- a/framework/source/helper/ocomponentenumeration.cxx
+++ b/framework/source/helper/ocomponentenumeration.cxx
@@ -28,13 +28,12 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::cppu;
-using namespace ::osl;
// constructor
-OComponentEnumeration::OComponentEnumeration( const std::vector< css::uno::Reference< XComponent > >& seqComponents )
+OComponentEnumeration::OComponentEnumeration( std::vector< css::uno::Reference< XComponent > >&& seqComponents )
: m_nPosition ( 0 ) // 0 is the first position for a valid list and the right value for an invalid list to!
- , m_seqComponents ( seqComponents )
+ , m_seqComponents ( std::move(seqComponents) )
{}
// destructor
diff --git a/framework/source/helper/oframes.cxx b/framework/source/helper/oframes.cxx
index 048d5ad79b54..9da5b6f27e55 100644
--- a/framework/source/helper/oframes.cxx
+++ b/framework/source/helper/oframes.cxx
@@ -26,13 +26,10 @@
namespace framework{
-using namespace ::com::sun::star::container;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::cppu;
-using namespace ::osl;
-using namespace ::std;
// constructor
@@ -143,18 +140,14 @@ Sequence< css::uno::Reference< XFrame > > SAL_CALL OFrames::queryFrames( sal_Int
css::uno::Reference< XFrame > xParent = xOwner->getCreator();
if( xParent.is() )
{
- Sequence< css::uno::Reference< XFrame > > seqParent( 1 );
- seqParent[0] = xParent;
- impl_appendSequence( seqFrames, seqParent );
+ impl_appendSequence( seqFrames, { xParent } );
}
}
// Add owner to list if SELF is searched.
if( nSearchFlags & FrameSearchFlag::SELF )
{
- Sequence< css::uno::Reference< XFrame > > seqSelf( 1 );
- seqSelf[0] = xOwner;
- impl_appendSequence( seqFrames, seqSelf );
+ impl_appendSequence( seqFrames, { xOwner } );
}
// Add SIBLINGS to list.
diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx
index d2e78df8d98c..995812dd4693 100644
--- a/framework/source/helper/persistentwindowstate.cxx
+++ b/framework/source/helper/persistentwindowstate.cxx
@@ -25,6 +25,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/configurationhelper.hxx>
+#include <utility>
#include <vcl/window.hxx>
#include <vcl/syswin.hxx>
@@ -34,8 +35,8 @@
namespace framework{
-PersistentWindowState::PersistentWindowState(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext )
+PersistentWindowState::PersistentWindowState(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
, m_bWindowStateAlreadySet(false )
{
}
@@ -134,6 +135,10 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv
void SAL_CALL PersistentWindowState::disposing(const css::lang::EventObject&)
{
+ css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), css::uno::UNO_QUERY);
+ if (xFrame.is())
+ xFrame->removeFrameActionListener(this);
+
// nothing todo here - because we hold the frame as weak reference only
}
@@ -188,7 +193,7 @@ void PersistentWindowState::implst_setWindowStateOnConfig(
"org.openoffice.Setup/",
OUString::Concat("Office/Factories/*[\"") + sModuleName + "\"]",
"ooSetupFactoryWindowAttributes",
- css::uno::makeAny(sWindowState),
+ css::uno::Any(sWindowState),
::comphelper::EConfigurationModes::Standard);
}
catch(const css::uno::RuntimeException&)
@@ -210,10 +215,8 @@ OUString PersistentWindowState::implst_getWindowStateFromWindow(const css::uno::
// check for system window is necessary to guarantee correct pointer cast!
if ( pWindow && pWindow->IsSystemWindow() )
{
- WindowStateMask const nMask = WindowStateMask::All & ~WindowStateMask::Minimized;
- sWindowState = OStringToOUString(
- static_cast<SystemWindow*>(pWindow.get())->GetWindowState(nMask),
- RTL_TEXTENCODING_UTF8);
+ vcl::WindowDataMask const nMask = vcl::WindowDataMask::All & ~vcl::WindowDataMask::Minimized;
+ sWindowState = static_cast<SystemWindow*>(pWindow.get())->GetWindowState(nMask);
}
// <- SOLAR SAFE ------------------------
}
@@ -251,9 +254,9 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere
if (pWorkWindow->IsMinimized())
return;
- OUString sOldWindowState = OStringToOUString( pSystemWindow->GetWindowState(), RTL_TEXTENCODING_ASCII_US );
+ OUString sOldWindowState = pSystemWindow->GetWindowState();
if ( sOldWindowState != sWindowState )
- pSystemWindow->SetWindowState(OUStringToOString(sWindowState,RTL_TEXTENCODING_UTF8));
+ pSystemWindow->SetWindowState(sWindowState);
// <- SOLAR SAFE ------------------------
}
diff --git a/framework/source/helper/statusindicator.cxx b/framework/source/helper/statusindicator.cxx
index 2073b8e68d9d..2deb4a0ae5b2 100644
--- a/framework/source/helper/statusindicator.cxx
+++ b/framework/source/helper/statusindicator.cxx
@@ -38,7 +38,7 @@ void SAL_CALL StatusIndicator::start(const OUString& sText, sal_Int32 nRange)
m_nRange = nRange;
m_nLastCallbackPercent = -1;
- comphelper::LibreOfficeKit::statusIndicatorStart();
+ comphelper::LibreOfficeKit::statusIndicatorStart(sText);
}
#if !defined(IOS) && !defined(ANDROID)
css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index 62efba05933f..64cf3543c22a 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -33,7 +33,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <unotools/mediadescriptor.hxx>
#include <vcl/svapp.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <rtl/ref.hxx>
#include <officecfg/Office/Common.hxx>
@@ -42,16 +42,10 @@ namespace framework{
sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0; ///< static counter for rescheduling
-namespace {
+constexpr OUString PROGRESS_RESOURCE = u"private:resource/progressbar/progressbar"_ustr;
-struct RescheduleLock: public rtl::Static<osl::Mutex, RescheduleLock> {}; ///< mutex to guard the m_nInReschedule
-
-}
-
-constexpr OUStringLiteral PROGRESS_RESOURCE = u"private:resource/progressbar/progressbar";
-
-StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext )
+StatusIndicatorFactory::StatusIndicatorFactory(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
, m_bAllowReschedule (false)
, m_bAllowParentShow (false)
, m_bDisableReschedule(false)
@@ -66,7 +60,7 @@ StatusIndicatorFactory::~StatusIndicatorFactory()
void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
{
if (lArguments.hasElements()) {
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
css::uno::Reference< css::frame::XFrame > xTmpFrame;
css::uno::Reference< css::awt::XWindow > xTmpWindow;
@@ -93,20 +87,20 @@ void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css::
}
}
+#ifdef EMSCRIPTEN
+ m_bDisableReschedule = true;
+#endif
impl_createProgress();
}
css::uno::Reference< css::task::XStatusIndicator > SAL_CALL StatusIndicatorFactory::createStatusIndicator()
{
- StatusIndicator* pIndicator = new StatusIndicator(this);
- css::uno::Reference< css::task::XStatusIndicator > xIndicator(static_cast< ::cppu::OWeakObject* >(pIndicator), css::uno::UNO_QUERY_THROW);
-
- return xIndicator;
+ return new StatusIndicator(this);
}
void SAL_CALL StatusIndicatorFactory::update()
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
m_bAllowReschedule = true;
}
@@ -114,20 +108,21 @@ void StatusIndicatorFactory::start(const css::uno::Reference< css::task::XStatus
const OUString& sText ,
sal_Int32 nRange)
{
+ css::uno::Reference< css::task::XStatusIndicator > xProgress;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aWriteLock(m_mutex);
-
- // create new info structure for this child or move it to the front of our stack
- IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
- if (pItem != m_aStack.end())
- m_aStack.erase(pItem);
- IndicatorInfo aInfo(xChild, sText);
- m_aStack.push_back (aInfo );
+ {
+ std::scoped_lock aWriteLock(m_mutex);
- m_xActiveChild = xChild;
- css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
+ // create new info structure for this child or move it to the front of our stack
+ IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
+ if (pItem != m_aStack.end())
+ m_aStack.erase(pItem);
+ IndicatorInfo aInfo(xChild, sText);
+ m_aStack.push_back (aInfo );
- aWriteLock.clear();
+ m_xActiveChild = xChild;
+ xProgress = m_xProgress;
+ }
// <- SAFE ----------------------------------
implts_makeParentVisibleIfAllowed();
@@ -141,21 +136,23 @@ void StatusIndicatorFactory::start(const css::uno::Reference< css::task::XStatus
void StatusIndicatorFactory::reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
{
+ css::uno::Reference< css::task::XStatusIndicator > xActive;
+ css::uno::Reference< css::task::XStatusIndicator > xProgress;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
-
- // reset the internal info structure related to this child
- IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
- if (pItem != m_aStack.end())
{
- pItem->m_nValue = 0;
- pItem->m_sText.clear();
- }
+ std::scoped_lock aReadLock(m_mutex);
- css::uno::Reference< css::task::XStatusIndicator > xActive = m_xActiveChild;
- css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
+ // reset the internal info structure related to this child
+ IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
+ if (pItem != m_aStack.end())
+ {
+ pItem->m_nValue = 0;
+ pItem->m_sText.clear();
+ }
- aReadLock.clear();
+ xActive = m_xActiveChild;
+ xProgress = m_xProgress;
+ }
// <- SAFE ----------------------------------
// not the top most child => don't change UI
@@ -171,30 +168,32 @@ void StatusIndicatorFactory::reset(const css::uno::Reference< css::task::XStatus
void StatusIndicatorFactory::end(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
{
+ css::uno::Reference< css::task::XStatusIndicator > xActive;
+ css::uno::Reference< css::task::XStatusIndicator > xProgress;
+ OUString sText;
+ sal_Int32 nValue = 0;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aWriteLock(m_mutex);
-
- // remove this child from our stack
- IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
- if (pItem != m_aStack.end())
- m_aStack.erase(pItem);
-
- // activate next child ... or finish the progress if there is no further one.
- m_xActiveChild.clear();
- OUString sText;
- sal_Int32 nValue = 0;
- IndicatorStack::reverse_iterator pNext = m_aStack.rbegin();
- if (pNext != m_aStack.rend())
{
- m_xActiveChild = pNext->m_xIndicator;
- sText = pNext->m_sText;
- nValue = pNext->m_nValue;
- }
+ std::scoped_lock aWriteLock(m_mutex);
+
+ // remove this child from our stack
+ IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
+ if (pItem != m_aStack.end())
+ m_aStack.erase(pItem);
- css::uno::Reference< css::task::XStatusIndicator > xActive = m_xActiveChild;
- css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
+ // activate next child ... or finish the progress if there is no further one.
+ m_xActiveChild.clear();
+ IndicatorStack::reverse_iterator pNext = m_aStack.rbegin();
+ if (pNext != m_aStack.rend())
+ {
+ m_xActiveChild = pNext->m_xIndicator;
+ sText = pNext->m_sText;
+ nValue = pNext->m_nValue;
+ }
- aWriteLock.clear();
+ xActive = m_xActiveChild;
+ xProgress = m_xProgress;
+ }
// <- SAFE ----------------------------------
if (xActive.is())
@@ -225,17 +224,19 @@ void StatusIndicatorFactory::end(const css::uno::Reference< css::task::XStatusIn
void StatusIndicatorFactory::setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
const OUString& sText )
{
+ css::uno::Reference< css::task::XStatusIndicator > xActive;
+ css::uno::Reference< css::task::XStatusIndicator > xProgress;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aWriteLock(m_mutex);
-
- IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
- if (pItem != m_aStack.end())
- pItem->m_sText = sText;
+ {
+ std::scoped_lock aWriteLock(m_mutex);
- css::uno::Reference< css::task::XStatusIndicator > xActive = m_xActiveChild;
- css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
+ IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
+ if (pItem != m_aStack.end())
+ pItem->m_sText = sText;
- aWriteLock.clear();
+ xActive = m_xActiveChild;
+ xProgress = m_xProgress;
+ }
// SAFE -> ----------------------------------
// paint only the top most indicator
@@ -254,21 +255,23 @@ void StatusIndicatorFactory::setText(const css::uno::Reference< css::task::XStat
void StatusIndicatorFactory::setValue( const css::uno::Reference< css::task::XStatusIndicator >& xChild ,
sal_Int32 nValue )
{
- // SAFE -> ----------------------------------
- osl::ClearableMutexGuard aWriteLock(m_mutex);
-
sal_Int32 nOldValue = 0;
- IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
- if (pItem != m_aStack.end())
+ css::uno::Reference< css::task::XStatusIndicator > xActive;
+ css::uno::Reference< css::task::XStatusIndicator > xProgress;
+ // SAFE -> ----------------------------------
{
- nOldValue = pItem->m_nValue;
- pItem->m_nValue = nValue;
- }
+ std::scoped_lock aWriteLock(m_mutex);
- css::uno::Reference< css::task::XStatusIndicator > xActive = m_xActiveChild;
- css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
+ IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
+ if (pItem != m_aStack.end())
+ {
+ nOldValue = pItem->m_nValue;
+ pItem->m_nValue = nValue;
+ }
- aWriteLock.clear();
+ xActive = m_xActiveChild;
+ xProgress = m_xProgress;
+ }
// SAFE -> ----------------------------------
if (
@@ -285,17 +288,20 @@ void StatusIndicatorFactory::setValue( const css::uno::Reference< css::task::XSt
void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
{
+ css::uno::Reference< css::frame::XFrame > xFrame;
+ css::uno::Reference< css::awt::XWindow > xPluggWindow;
+ css::uno::Reference< css::uno::XComponentContext > xContext;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
-
- if (!m_bAllowParentShow)
- return;
+ {
+ std::scoped_lock aReadLock(m_mutex);
- css::uno::Reference< css::frame::XFrame > xFrame (m_xFrame.get() , css::uno::UNO_QUERY);
- css::uno::Reference< css::awt::XWindow > xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
- css::uno::Reference< css::uno::XComponentContext > xContext( m_xContext);
+ if (!m_bAllowParentShow)
+ return;
- aReadLock.clear();
+ xFrame = m_xFrame;
+ xPluggWindow = m_xPluggWindow;
+ xContext = m_xContext;
+ }
// <- SAFE ----------------------------------
css::uno::Reference< css::awt::XWindow > xParentWindow;
@@ -350,7 +356,7 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
{
utl::MediaDescriptor lDocArgs(xModel->getArgs());
bHiddenDoc = lDocArgs.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_HIDDEN(),
+ utl::MediaDescriptor::PROP_HIDDEN,
false);
}
}
@@ -369,7 +375,7 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xParentWindow);
if ( pWindow )
{
- bool bForceFrontAndFocus(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext));
+ bool bForceFrontAndFocus(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get());
pWindow->Show(true, bForceFrontAndFocus ? ShowFlags::ForegroundTask : ShowFlags::NONE );
}
@@ -377,13 +383,15 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
void StatusIndicatorFactory::impl_createProgress()
{
+ css::uno::Reference< css::frame::XFrame > xFrame;
+ css::uno::Reference< css::awt::XWindow > xWindow;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
-
- css::uno::Reference< css::frame::XFrame > xFrame (m_xFrame.get() , css::uno::UNO_QUERY);
- css::uno::Reference< css::awt::XWindow > xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
+ {
+ std::scoped_lock aReadLock(m_mutex);
- aReadLock.clear();
+ xFrame = m_xFrame;
+ xWindow = m_xPluggWindow;
+ }
// <- SAFE ----------------------------------
css::uno::Reference< css::task::XStatusIndicator > xProgress;
@@ -391,8 +399,7 @@ void StatusIndicatorFactory::impl_createProgress()
if (xWindow.is())
{
// use vcl based progress implementation in plugged mode
- VCLStatusIndicator* pVCLProgress = new VCLStatusIndicator(xWindow);
- xProgress.set(static_cast< css::task::XStatusIndicator* >(pVCLProgress), css::uno::UNO_QUERY);
+ xProgress = new VCLStatusIndicator(xWindow);
}
else if (xFrame.is())
{
@@ -417,18 +424,19 @@ void StatusIndicatorFactory::impl_createProgress()
}
}
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
m_xProgress = xProgress;
}
void StatusIndicatorFactory::impl_showProgress()
{
+ css::uno::Reference< css::frame::XFrame > xFrame;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
-
- css::uno::Reference< css::frame::XFrame > xFrame (m_xFrame.get() , css::uno::UNO_QUERY);
+ {
+ std::scoped_lock aReadLock(m_mutex);
- aReadLock.clear();
+ xFrame = m_xFrame;
+ }
// <- SAFE ----------------------------------
css::uno::Reference< css::task::XStatusIndicator > xProgress;
@@ -457,18 +465,19 @@ void StatusIndicatorFactory::impl_showProgress()
}
}
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
m_xProgress = xProgress;
}
void StatusIndicatorFactory::impl_hideProgress()
{
+ css::uno::Reference< css::frame::XFrame > xFrame;
// SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
-
- css::uno::Reference< css::frame::XFrame > xFrame (m_xFrame.get() , css::uno::UNO_QUERY);
+ {
+ std::scoped_lock aReadLock(m_mutex);
- aReadLock.clear();
+ xFrame = m_xFrame;
+ }
// <- SAFE ----------------------------------
if (xFrame.is())
@@ -489,7 +498,7 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
{
// SAFE ->
{
- osl::MutexGuard aReadLock(m_mutex);
+ std::scoped_lock aReadLock(m_mutex);
if (m_bDisableReschedule)
return;
}
@@ -498,7 +507,7 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
bool bReschedule = bForce;
if (!bReschedule)
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
bReschedule = m_bAllowReschedule;
m_bAllowReschedule = false;
}
@@ -506,14 +515,16 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
if (!bReschedule)
return;
+ static std::mutex rescheduleLock;
// SAFE ->
- osl::ResettableMutexGuard aRescheduleGuard(RescheduleLock::get());
+ std::unique_lock aRescheduleGuard(rescheduleLock);
if (m_nInReschedule != 0)
return;
+ // coverity[missing_lock: FALSE] - coverity fails to see the aRescheduleGuard ctor as taking a lock
++m_nInReschedule;
- aRescheduleGuard.clear();
+ aRescheduleGuard.unlock();
// <- SAFE
{
@@ -522,13 +533,13 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
}
// SAFE ->
- aRescheduleGuard.reset();
+ aRescheduleGuard.lock();
--m_nInReschedule;
}
void StatusIndicatorFactory::impl_startWakeUpThread()
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
if (m_bDisableReschedule)
return;
@@ -544,7 +555,7 @@ void StatusIndicatorFactory::impl_stopWakeUpThread()
{
rtl::Reference<WakeUpThread> wakeUp;
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
std::swap(wakeUp, m_pWakeUp);
}
if (wakeUp.is())
diff --git a/framework/source/helper/tagwindowasmodified.cxx b/framework/source/helper/tagwindowasmodified.cxx
index f17594cee477..cc27a194e1fb 100644
--- a/framework/source/helper/tagwindowasmodified.cxx
+++ b/framework/source/helper/tagwindowasmodified.cxx
@@ -21,14 +21,12 @@
#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/frame/FrameAction.hpp>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
-#include <tools/wintypes.hxx>
+#include <vcl/wintypes.hxx>
namespace framework{
@@ -47,52 +45,31 @@ void SAL_CALL TagWindowAsModified::initialize(const css::uno::Sequence< css::uno
if (lArguments.hasElements())
lArguments[0] >>= xFrame;
- if ( ! xFrame.is ())
+ if (!xFrame)
return;
- {
- SolarMutexGuard g;
- m_xFrame = xFrame;
- }
-
+ m_xFrame = xFrame;
xFrame->addFrameActionListener(this);
impl_update (xFrame);
}
void SAL_CALL TagWindowAsModified::modified(const css::lang::EventObject& aEvent)
{
- css::uno::Reference< css::util::XModifiable > xModel;
- css::uno::Reference< css::awt::XWindow > xWindow;
- {
- SolarMutexGuard g;
- xModel.set(m_xModel.get (), css::uno::UNO_QUERY);
- xWindow.set(m_xWindow.get(), css::uno::UNO_QUERY);
- if (
- ( ! xModel.is () ) ||
- ( ! xWindow.is () ) ||
- (aEvent.Source != xModel)
- )
- return;
- }
+ if (!m_xModel || !m_xWindow || aEvent.Source != m_xModel)
+ return;
- bool bModified = xModel->isModified ();
+ bool bModified = m_xModel->isModified ();
// SYNCHRONIZED ->
SolarMutexGuard aSolarGuard;
- VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
- if ( ! pWindow)
- return;
-
- bool bSystemWindow = pWindow->IsSystemWindow();
- bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW);
- if (!bSystemWindow && !bWorkWindow)
+ if (m_xWindow->isDisposed())
return;
if (bModified)
- pWindow->SetExtendedStyle(WindowExtendedStyle::DocModified);
+ m_xWindow->SetExtendedStyle(WindowExtendedStyle::DocModified);
else
- pWindow->SetExtendedStyle(WindowExtendedStyle::NONE);
+ m_xWindow->SetExtendedStyle(WindowExtendedStyle::NONE);
// <- SYNCHRONIZED
}
@@ -104,40 +81,26 @@ void SAL_CALL TagWindowAsModified::frameAction(const css::frame::FrameActionEven
)
return;
- css::uno::Reference< css::frame::XFrame > xFrame;
- {
- SolarMutexGuard g;
- xFrame.set(m_xFrame.get(), css::uno::UNO_QUERY);
- if (
- ( ! xFrame.is () ) ||
- (aEvent.Source != xFrame)
- )
- return;
- }
+ if ( aEvent.Source != m_xFrame )
+ return;
- impl_update (xFrame);
+ impl_update (m_xFrame);
}
void SAL_CALL TagWindowAsModified::disposing(const css::lang::EventObject& aEvent)
{
SolarMutexGuard g;
- css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), css::uno::UNO_QUERY);
- if (
- (xFrame.is () ) &&
- (aEvent.Source == xFrame)
- )
+ if (m_xFrame && aEvent.Source == m_xFrame)
{
+ m_xFrame->removeFrameActionListener(this);
m_xFrame.clear();
return;
}
- css::uno::Reference< css::frame::XModel > xModel(m_xModel.get(), css::uno::UNO_QUERY);
- if (
- (xModel.is () ) &&
- (aEvent.Source == xModel)
- )
+ if (m_xModel && aEvent.Source == m_xModel)
{
+ m_xModel->removeModifyListener(this);
m_xModel.clear();
return;
}
@@ -145,32 +108,37 @@ void SAL_CALL TagWindowAsModified::disposing(const css::lang::EventObject& aEven
void TagWindowAsModified::impl_update (const css::uno::Reference< css::frame::XFrame >& xFrame)
{
- if ( ! xFrame.is ())
+ if (!xFrame)
return;
css::uno::Reference< css::awt::XWindow > xWindow = xFrame->getContainerWindow ();
css::uno::Reference< css::frame::XController > xController = xFrame->getController ();
- css::uno::Reference< css::frame::XModel > xModel;
+ css::uno::Reference< css::util::XModifiable > xModel;
if (xController.is ())
- xModel = xController->getModel ();
+ xModel = css::uno::Reference< css::util::XModifiable >(xController->getModel(), css::uno::UNO_QUERY);
- if (
- ( ! xWindow.is ()) ||
- ( ! xModel.is ())
- )
+ if (!xWindow || !xModel)
return;
{
SolarMutexGuard g;
+
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
+ bool bSystemWindow = pWindow->IsSystemWindow();
+ bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW);
+ if (!bSystemWindow && !bWorkWindow)
+ return;
+
+ if (m_xModel)
+ m_xModel->removeModifyListener (this);
+
// Note: frame was set as member outside ! we have to refresh connections
// regarding window and model only here.
- m_xWindow = xWindow;
+ m_xWindow = pWindow;
m_xModel = xModel;
}
- css::uno::Reference< css::util::XModifyBroadcaster > xModifiable(xModel, css::uno::UNO_QUERY);
- if (xModifiable.is ())
- xModifiable->addModifyListener (this);
+ m_xModel->addModifyListener (this);
}
} // namespace framework
diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx
index d62be2a63192..232243a83689 100644
--- a/framework/source/helper/titlebarupdate.cxx
+++ b/framework/source/helper/titlebarupdate.cxx
@@ -30,20 +30,20 @@
#include <comphelper/sequenceashashmap.hxx>
#include <unotools/configmgr.hxx>
+#include <utility>
#include <vcl/window.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace framework{
const ::sal_Int32 INVALID_ICON_ID = -1;
const ::sal_Int32 DEFAULT_ICON_ID = 0;
-TitleBarUpdate::TitleBarUpdate(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext )
- , m_xFrame ( )
+TitleBarUpdate::TitleBarUpdate(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
{
}
@@ -103,6 +103,10 @@ void SAL_CALL TitleBarUpdate::titleChanged(const css::frame::TitleChangedEvent&
void SAL_CALL TitleBarUpdate::disposing(const css::lang::EventObject&)
{
+ css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), css::uno::UNO_QUERY);
+ if (xFrame.is())
+ xFrame->removeFrameActionListener(this);
+
// nothing todo here - because we hold the frame as weak reference only
}
@@ -282,6 +286,7 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra
// <- VCL SYNCHRONIZED
}
+// static
void TitleBarUpdate::impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame)
{
// no window ... no chance to set any title -> return
diff --git a/framework/source/helper/uiconfigelementwrapperbase.cxx b/framework/source/helper/uiconfigelementwrapperbase.cxx
index 399bf8bc9d8c..05e6467a5b89 100644
--- a/framework/source/helper/uiconfigelementwrapperbase.cxx
+++ b/framework/source/helper/uiconfigelementwrapperbase.cxx
@@ -37,14 +37,14 @@ const int UIELEMENT_PROPHANDLE_TYPE = 5;
const int UIELEMENT_PROPHANDLE_XMENUBAR = 6;
const int UIELEMENT_PROPHANDLE_CONFIGLISTENER = 7;
const int UIELEMENT_PROPHANDLE_NOCLOSE = 8;
-constexpr OUStringLiteral UIELEMENT_PROPNAME_CONFIGLISTENER = u"ConfigListener";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_CONFIGSOURCE = u"ConfigurationSource";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_FRAME = u"Frame";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_PERSISTENT = u"Persistent";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_RESOURCEURL = u"ResourceURL";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_TYPE = u"Type";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_XMENUBAR = u"XMenuBar";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_NOCLOSE = u"NoClose";
+constexpr OUString UIELEMENT_PROPNAME_CONFIGLISTENER = u"ConfigListener"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_CONFIGSOURCE = u"ConfigurationSource"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_FRAME = u"Frame"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_PERSISTENT = u"Persistent"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_RESOURCEURL = u"ResourceURL"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_TYPE = u"Type"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_XMENUBAR = u"XMenuBar"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_NOCLOSE = u"NoClose"_ustr;
using namespace com::sun::star::beans;
using namespace com::sun::star::uno;
using namespace com::sun::star::frame;
@@ -174,7 +174,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
{
case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_bConfigListener),
+ css::uno::Any(m_bConfigListener),
aValue,
aOldValue,
aConvertedValue);
@@ -182,7 +182,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_xConfigSource),
+ css::uno::Any(m_xConfigSource),
aValue,
aOldValue,
aConvertedValue);
@@ -192,7 +192,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
{
Reference< XFrame > xFrame( m_xWeakFrame );
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(xFrame),
+ css::uno::Any(xFrame),
aValue,
aOldValue,
aConvertedValue);
@@ -201,7 +201,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_PERSISTENT:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_bPersistent),
+ css::uno::Any(m_bPersistent),
aValue,
aOldValue,
aConvertedValue);
@@ -209,7 +209,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_RESOURCEURL:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_aResourceURL),
+ css::uno::Any(m_aResourceURL),
aValue,
aOldValue,
aConvertedValue);
@@ -217,7 +217,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_TYPE :
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_nType),
+ css::uno::Any(m_nType),
aValue,
aOldValue,
aConvertedValue);
@@ -225,7 +225,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_XMENUBAR :
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_xMenuBar),
+ css::uno::Any(m_xMenuBar),
aValue,
aOldValue,
aConvertedValue);
@@ -233,7 +233,7 @@ sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&
case UIELEMENT_PROPHANDLE_NOCLOSE:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_bNoClose),
+ css::uno::Any(m_bNoClose),
aValue,
aOldValue,
aConvertedValue);
@@ -264,7 +264,7 @@ void SAL_CALL UIConfigElementWrapperBase::setFastPropertyValue_NoBroadcast( sa
Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
if ( xUIConfig.is() )
{
- xUIConfig->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xUIConfig->removeConfigurationListener( Reference< XUIConfigurationListener >(this) );
m_bConfigListening = false;
}
}
@@ -282,7 +282,7 @@ void SAL_CALL UIConfigElementWrapperBase::setFastPropertyValue_NoBroadcast( sa
Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
if ( xUIConfig.is() )
{
- xUIConfig->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xUIConfig->addConfigurationListener( Reference< XUIConfigurationListener >(this) );
m_bConfigListening = true;
}
}
@@ -419,7 +419,7 @@ void SAL_CALL UIConfigElementWrapperBase::setSettings( const Reference< XIndexAc
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY );
if ( xReplace.is() )
- m_xConfigData.set( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY );
+ m_xConfigData = new ConstItemContainer( xSettings );
else
m_xConfigData = xSettings;
@@ -452,7 +452,7 @@ Reference< XIndexAccess > SAL_CALL UIConfigElementWrapperBase::getSettings( sal_
SolarMutexGuard g;
if ( bWriteable )
- return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY );
+ return Reference< XIndexAccess >( new RootItemContainer( m_xConfigData ) );
return m_xConfigData;
}
diff --git a/framework/source/helper/uielementwrapperbase.cxx b/framework/source/helper/uielementwrapperbase.cxx
index 829e4f9523eb..dcf9f89e91ee 100644
--- a/framework/source/helper/uielementwrapperbase.cxx
+++ b/framework/source/helper/uielementwrapperbase.cxx
@@ -28,9 +28,9 @@
const int UIELEMENT_PROPHANDLE_RESOURCEURL = 1;
const int UIELEMENT_PROPHANDLE_TYPE = 2;
const int UIELEMENT_PROPHANDLE_FRAME = 3;
-constexpr OUStringLiteral UIELEMENT_PROPNAME_RESOURCEURL = u"ResourceURL";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_TYPE = u"Type";
-constexpr OUStringLiteral UIELEMENT_PROPNAME_FRAME = u"Frame";
+constexpr OUString UIELEMENT_PROPNAME_RESOURCEURL = u"ResourceURL"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_TYPE = u"Type"_ustr;
+constexpr OUString UIELEMENT_PROPNAME_FRAME = u"Frame"_ustr;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
diff --git a/framework/source/helper/vclstatusindicator.cxx b/framework/source/helper/vclstatusindicator.cxx
index 8173c3b48e8b..b493eacc7236 100644
--- a/framework/source/helper/vclstatusindicator.cxx
+++ b/framework/source/helper/vclstatusindicator.cxx
@@ -20,12 +20,13 @@
#include <helper/vclstatusindicator.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
namespace framework {
-VCLStatusIndicator::VCLStatusIndicator(const css::uno::Reference< css::awt::XWindow >& xParentWindow)
- : m_xParentWindow (xParentWindow )
+VCLStatusIndicator::VCLStatusIndicator(css::uno::Reference< css::awt::XWindow > xParentWindow)
+ : m_xParentWindow (std::move(xParentWindow ))
, m_pStatusBar (nullptr )
, m_nRange (0 )
, m_nValue (0 )
@@ -58,7 +59,7 @@ void SAL_CALL VCLStatusIndicator::start(const OUString& sText ,
// force repaint!
pParentWindow->Show();
pParentWindow->Invalidate(InvalidateFlags::Children);
- pParentWindow->Flush();
+ pParentWindow->GetOutDev()->Flush();
m_nRange = nRange;
m_nValue = 0;
diff --git a/framework/source/helper/wakeupthread.cxx b/framework/source/helper/wakeupthread.cxx
index 503f6707a010..40487c83b88f 100644
--- a/framework/source/helper/wakeupthread.cxx
+++ b/framework/source/helper/wakeupthread.cxx
@@ -21,17 +21,17 @@
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/util/XUpdatable.hpp>
-#include <osl/mutex.hxx>
-#include <osl/time.h>
#include <helper/wakeupthread.hxx>
+#include <chrono>
+
+using namespace std::chrono_literals;
void framework::WakeUpThread::execute() {
for (;;) {
- TimeValue t{0, 25000000}; // 25 msec
- condition_.wait(&t);
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
+ condition_.wait_for(g, 25ms, [this] { return terminate_; });
if (terminate_) {
break;
}
@@ -50,10 +50,10 @@ framework::WakeUpThread::WakeUpThread(
void framework::WakeUpThread::stop() {
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
terminate_ = true;
}
- condition_.set();
+ condition_.notify_one();
join();
}
diff --git a/framework/source/inc/accelerators/acceleratorcache.hxx b/framework/source/inc/accelerators/acceleratorcache.hxx
index 666d1eb4eb7a..adfdf8fe5aa2 100644
--- a/framework/source/inc/accelerators/acceleratorcache.hxx
+++ b/framework/source/inc/accelerators/acceleratorcache.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCACHE_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCACHE_HXX
+#pragma once
#include <stdtypes.h>
@@ -43,18 +42,18 @@ namespace framework
*/
class AcceleratorCache
{
-
- // const, types
-
public:
- /** TODO document me
+ /**
commands -> keys
*/
typedef ::std::vector< css::awt::KeyEvent > TKeyList;
+
+ private:
+
typedef std::unordered_map<OUString, TKeyList> TCommand2Keys;
- /** TODO document me
+ /**
keys -> commands
*/
typedef std::unordered_map< css::awt::KeyEvent ,
@@ -62,10 +61,6 @@ class AcceleratorCache
KeyEventHashCode ,
KeyEventEqualsFunc > TKey2Commands;
- // member
-
- private:
-
/** map commands to keys in relation 1:n.
First key is interpreted as preferred one! */
TCommand2Keys m_lCommand2Keys;
@@ -73,8 +68,6 @@ class AcceleratorCache
/** map keys to commands in relation 1:1. */
TKey2Commands m_lKey2Commands;
- // interface
-
public:
/** @short checks if the specified key exists.
@@ -87,7 +80,6 @@ class AcceleratorCache
bool hasKey(const css::awt::KeyEvent& aKey) const;
bool hasCommand(const OUString& sCommand) const;
- /** TODO document me */
TKeyList getAllKeys() const;
/** @short add a new or change an existing key-command pair
@@ -113,16 +105,11 @@ class AcceleratorCache
*/
TKeyList getKeysByCommand(const OUString& sCommand) const;
- /** TODO */
OUString getCommandByKey(const css::awt::KeyEvent& aKey) const;
-
- /** TODO */
void removeKey(const css::awt::KeyEvent& aKey);
void removeCommand(const OUString& sCommand);
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCACHE_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/accelerators/acceleratorconfiguration.hxx b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
index df7bed019ff2..050c8d950475 100644
--- a/framework/source/inc/accelerators/acceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
+#pragma once
#include <sal/config.h>
@@ -44,9 +43,9 @@
namespace framework
{
-inline constexpr OUStringLiteral CFG_ENTRY_PRIMARY = u"PrimaryKeys";
-inline constexpr OUStringLiteral CFG_ENTRY_GLOBAL = u"Global";
-inline constexpr OUStringLiteral CFG_ENTRY_MODULES = u"Modules";
+inline constexpr OUString CFG_ENTRY_PRIMARY = u"PrimaryKeys"_ustr;
+inline constexpr OUString CFG_ENTRY_GLOBAL = u"Global"_ustr;
+inline constexpr OUString CFG_ENTRY_MODULES = u"Modules"_ustr;
/**
implements a read/write access to the accelerator configuration.
@@ -150,7 +149,7 @@ class XMLBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
@return OUString
The current office locale as BCP47 string.
*/
- OUString impl_ts_getLocale() const;
+ static OUString impl_ts_getLocale();
// helper
@@ -221,7 +220,7 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
public:
- XCUBasedAcceleratorConfiguration( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ XCUBasedAcceleratorConfiguration( css::uno::Reference< css::uno::XComponentContext > xContext );
virtual ~XCUBasedAcceleratorConfiguration( ) override;
// uno interface!
@@ -291,7 +290,7 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
@return OUString
The current office locale as BCP47 string.
*/
- OUString impl_ts_getLocale() const;
+ static OUString impl_ts_getLocale();
// helper
@@ -310,6 +309,4 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper<
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/accelerators/keymapping.hxx b/framework/source/inc/accelerators/keymapping.hxx
index 3b9a8a3e46d5..b387655f3db9 100644
--- a/framework/source/inc/accelerators/keymapping.hxx
+++ b/framework/source/inc/accelerators/keymapping.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
+#pragma once
#include <rtl/ustring.hxx>
#include <unordered_map>
@@ -118,12 +117,10 @@ class KeyMapping
@return [boolean]
sal_True if conversion was successful.
*/
- bool impl_st_interpretIdentifierAsPureKeyCode(const OUString& sIdentifier,
+ static bool impl_st_interpretIdentifierAsPureKeyCode(std::u16string_view sIdentifier,
sal_uInt16& rCode );
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/accelerators/presethandler.hxx b/framework/source/inc/accelerators/presethandler.hxx
index ad0a2e1260d5..18a20a4b2016 100644
--- a/framework/source/inc/accelerators/presethandler.hxx
+++ b/framework/source/inc/accelerators/presethandler.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_PRESETHANDLER_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_PRESETHANDLER_HXX
+#pragma once
#include <sal/config.h>
@@ -123,7 +122,7 @@ class PresetHandler
points to a uno service manager, which is used internally
to create own needed uno resources.
*/
- PresetHandler(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ PresetHandler(css::uno::Reference< css::uno::XComponentContext > xContext);
/** @short copy ctor */
PresetHandler(const PresetHandler& rCopy);
@@ -208,8 +207,8 @@ class PresetHandler
if the specified resource couldn't be located.
*/
void connectToResource( EConfigType eConfigType ,
- const OUString& sResourceType ,
- const OUString& sModule ,
+ std::u16string_view sResourceType ,
+ std::u16string_view sModule ,
const css::uno::Reference< css::embed::XStorage >& xDocumentRoot ,
const LanguageTag& rLanguageTag = LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE));
@@ -300,7 +299,7 @@ class PresetHandler
@return An opened storage in case method was successful - null otherwise.
*/
- css::uno::Reference< css::embed::XStorage > impl_openPathIgnoringErrors(const OUString& sPath ,
+ static css::uno::Reference< css::embed::XStorage > impl_openPathIgnoringErrors(const OUString& sPath ,
sal_Int32 eMode ,
bool bShare);
@@ -326,7 +325,7 @@ class PresetHandler
@return An iterator, which points directly into lLocalizedValue list.
As a negative result the special iterator lLocalizedValues.end() will be returned.
*/
- ::std::vector< OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< OUString >& lLocalizedValues,
+ static ::std::vector< OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< OUString >& lLocalizedValues,
OUString& rLanguageTag ,
bool bAllowFallbacks );
@@ -357,7 +356,7 @@ class PresetHandler
@return An opened storage in case method was successful - null otherwise.
*/
- css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(OUString& sPath ,
+ static css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(OUString& sPath ,
sal_Int32 eMode ,
bool bShare ,
OUString& rLanguageTag ,
@@ -371,11 +370,9 @@ class PresetHandler
@return [vector< string >]
a list of folder names.
*/
- ::std::vector< OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder);
+ static ::std::vector< OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder);
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_PRESETHANDLER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/accelerators/storageholder.hxx b/framework/source/inc/accelerators/storageholder.hxx
index e9be85bd7cb9..355bedeaa662 100644
--- a/framework/source/inc/accelerators/storageholder.hxx
+++ b/framework/source/inc/accelerators/storageholder.hxx
@@ -17,11 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
+#pragma once
#include <com/sun/star/embed/XStorage.hpp>
+#include <mutex>
#include <unordered_map>
#include <vector>
@@ -61,7 +61,7 @@ class StorageHolder final
// member
private:
- mutable osl::Mutex m_mutex;
+ mutable std::mutex m_mutex;
/** @short TODO */
css::uno::Reference< css::embed::XStorage > m_xRoot;
@@ -174,11 +174,9 @@ class StorageHolder final
/** @short TODO
*/
- static std::vector<OUString> impl_st_parsePath(const OUString& sPath);
+ static std::vector<OUString> impl_st_parsePath(std::u16string_view sPath);
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/dispatch/dispatchdisabler.hxx b/framework/source/inc/dispatch/dispatchdisabler.hxx
index 3fe82b8e7be2..662eeb5d7c2d 100644
--- a/framework/source/inc/dispatch/dispatchdisabler.hxx
+++ b/framework/source/inc/dispatch/dispatchdisabler.hxx
@@ -6,8 +6,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
-#define INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
+#pragma once
#include <set>
@@ -32,7 +31,7 @@ namespace framework {
* of functionality included, and disabling elements remotely one
* by one performs poorly.
*/
-class DispatchDisabler : public ::cppu::WeakImplHelper<
+class DispatchDisabler final : public ::cppu::WeakImplHelper<
css::lang::XInitialization,
css::container::XNameContainer,
css::frame::XDispatchProviderInterceptor,
@@ -94,6 +93,4 @@ public:
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/dispatch/loaddispatcher.hxx b/framework/source/inc/dispatch/loaddispatcher.hxx
index e473dd53275b..195a46af82dc 100644
--- a/framework/source/inc/dispatch/loaddispatcher.hxx
+++ b/framework/source/inc/dispatch/loaddispatcher.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
+#pragma once
#include <loadenv/loadenv.hxx>
@@ -34,7 +33,7 @@ namespace framework{
non-visible components (by using the mechanism of ContentHandler)
or visible-components (by using the mechanism of FrameLoader).
*/
-class LoadDispatcher : public ::cppu::WeakImplHelper< css::frame::XNotifyingDispatch, // => XDispatch => XInterface
+class LoadDispatcher final : public ::cppu::WeakImplHelper< css::frame::XNotifyingDispatch, // => XDispatch => XInterface
css::frame::XSynchronousDispatch >
{
@@ -80,7 +79,7 @@ class LoadDispatcher : public ::cppu::WeakImplHelper< css::frame::XNotifyingDis
*/
LoadDispatcher(const css::uno::Reference< css::uno::XComponentContext >& xContext,
const css::uno::Reference< css::frame::XFrame >& xOwnerFrame ,
- const OUString& sTargetName ,
+ OUString sTargetName ,
sal_Int32 nSearchFlags);
/** @short used to free internal resources.
@@ -118,6 +117,4 @@ class LoadDispatcher : public ::cppu::WeakImplHelper< css::frame::XNotifyingDis
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/dispatch/windowcommanddispatch.hxx b/framework/source/inc/dispatch/windowcommanddispatch.hxx
index db5602fd2690..4a8a22d81c0b 100644
--- a/framework/source/inc/dispatch/windowcommanddispatch.hxx
+++ b/framework/source/inc/dispatch/windowcommanddispatch.hxx
@@ -17,14 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
+#pragma once
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <cppuhelper/weakref.hxx>
#include <tools/link.hxx>
+#include <mutex>
namespace com::sun::star::uno {
class XComponentContext;
@@ -47,7 +47,7 @@ namespace framework{
class WindowCommandDispatch final
{
private:
- osl::Mutex m_mutex;
+ std::mutex m_mutex;
/// can be used to create own needed services on demand.
css::uno::Reference< css::uno::XComponentContext > m_xContext;
@@ -74,8 +74,8 @@ class WindowCommandDispatch final
@param xFrame
used as for new detected commands.
*/
- WindowCommandDispatch(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
- const css::uno::Reference< css::frame::XFrame >& xFrame);
+ WindowCommandDispatch(css::uno::Reference< css::uno::XComponentContext > xContext ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame);
/** @short used to free internal resources.
*/
@@ -106,6 +106,4 @@ class WindowCommandDispatch final
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/loadenv/actionlockguard.hxx b/framework/source/inc/loadenv/actionlockguard.hxx
index 417d2d4ed47f..ee52fcc0dc54 100644
--- a/framework/source/inc/loadenv/actionlockguard.hxx
+++ b/framework/source/inc/loadenv/actionlockguard.hxx
@@ -17,11 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_ACTIONLOCKGUARD_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_ACTIONLOCKGUARD_HXX
+#pragma once
#include <com/sun/star/document/XActionLockable.hpp>
-#include <osl/mutex.hxx>
+#include <mutex>
namespace framework{
@@ -37,7 +36,7 @@ class ActionLockGuard final
// member
private:
- osl::Mutex m_mutex;
+ std::mutex m_mutex;
/** @short points to the object, which can be locked from outside. */
css::uno::Reference< css::document::XActionLockable > m_xActionLock;
@@ -82,7 +81,7 @@ class ActionLockGuard final
*/
bool setResource(const css::uno::Reference< css::document::XActionLockable >& xLock)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (m_bActionLocked || !xLock.is())
return false;
@@ -108,7 +107,7 @@ class ActionLockGuard final
void freeResource()
{
// SAFE -> ..........................
- osl::ClearableMutexGuard aMutexLock(m_mutex);
+ std::unique_lock aMutexLock(m_mutex);
css::uno::Reference< css::document::XActionLockable > xLock = m_xActionLock;
bool bLocked = m_bActionLocked;
@@ -116,7 +115,7 @@ class ActionLockGuard final
m_xActionLock.clear();
m_bActionLocked = false;
- aMutexLock.clear();
+ aMutexLock.unlock();
// <- SAFE ..........................
if (bLocked && xLock.is())
@@ -126,7 +125,7 @@ class ActionLockGuard final
/** @short unlock the internal wrapped resource, if it's not already done. */
void unlock()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (m_bActionLocked && m_xActionLock.is())
{
m_xActionLock->removeActionLock();
@@ -139,6 +138,4 @@ class ActionLockGuard final
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_ACTIONLOCKGUARD_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/loadenv/loadenv.hxx b/framework/source/inc/loadenv/loadenv.hxx
index 9f907e49ccfc..3fba486c8161 100644
--- a/framework/source/inc/loadenv/loadenv.hxx
+++ b/framework/source/inc/loadenv/loadenv.hxx
@@ -16,8 +16,7 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENV_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENV_HXX
+#pragma once
#include <loadenv/actionlockguard.hxx>
@@ -180,6 +179,12 @@ private:
*/
bool m_bLoaded;
+ /** @short If we already brought it to front; do not do that again
+ (the user could switch elsewhere after the first activation,
+ and we shouldn't nag them again).
+ */
+ bool m_bFocusedAndToFront = false;
+
/** @short holds an XActionLock on the internal used task member.
@seealso m_xTargetFrame
@@ -201,7 +206,7 @@ public:
@throw A RuntimeException in case any internal process indicates, that
the whole runtime can't be used any longer.
*/
- LoadEnv(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ LoadEnv(css::uno::Reference< css::uno::XComponentContext > xContext);
/** @short deinitialize an instance of this class in the right way.
*/
@@ -499,7 +504,7 @@ private:
If it's set to sal_True... both actions has to be done: setVisible(), toFront()!
This mode is needed by a)
*/
- void impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow ,
+ static void impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow ,
bool bForceToFront);
/** @short checks whether a frame is already used for another load request or not.
@@ -513,7 +518,7 @@ private:
sal_True if this frame is already used for loading,
sal_False otherwise.
*/
- bool impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame) const;
+ static bool impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame);
/** @short try to determine the used application module
of this load request and apply right position and size
@@ -534,10 +539,13 @@ private:
loading the document.
*/
bool impl_filterHasInteractiveDialog() const;
+
+ /** @short checks if this should bring to front and get focus on load,
+ according to user settings and to the load flags.
+ */
+ bool shouldFocusAndToFront() const;
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENV_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/loadenv/loadenvexception.hxx b/framework/source/inc/loadenv/loadenvexception.hxx
index e4c4eefa63da..62a17d2ac828 100644
--- a/framework/source/inc/loadenv/loadenvexception.hxx
+++ b/framework/source/inc/loadenv/loadenvexception.hxx
@@ -17,10 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENVEXCEPTION_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENVEXCEPTION_HXX
+#pragma once
#include <com/sun/star/uno/Any.hxx>
+#include <utility>
namespace framework{
@@ -76,14 +76,12 @@ class LoadEnvException
css::uno::Any m_exOriginal;
LoadEnvException(
- sal_Int32 id, OUString const & message = OUString(),
- css::uno::Any const & original = css::uno::Any()):
- m_nID(id), m_sMessage(message), m_exOriginal(original)
+ sal_Int32 id, OUString message = OUString(),
+ css::uno::Any original = css::uno::Any()):
+ m_nID(id), m_sMessage(std::move(message)), m_exOriginal(std::move(original))
{}
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_LOADENVEXCEPTION_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/loadenv/targethelper.hxx b/framework/source/inc/loadenv/targethelper.hxx
index 54f0e761e803..1f0d93d7edce 100644
--- a/framework/source/inc/loadenv/targethelper.hxx
+++ b/framework/source/inc/loadenv/targethelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_TARGETHELPER_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_TARGETHELPER_HXX
+#pragma once
#include <rtl/ustring.hxx>
@@ -83,11 +82,9 @@ class TargetHelper
@param sName
the new frame name, which should be checked.
*/
- static bool isValidNameForFrame(const OUString& sName);
+ static bool isValidNameForFrame(std::u16string_view sName);
};
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_TARGETHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/pattern/frame.hxx b/framework/source/inc/pattern/frame.hxx
index 46b86f56f891..947a03668162 100644
--- a/framework/source/inc/pattern/frame.hxx
+++ b/framework/source/inc/pattern/frame.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
+#pragma once
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
@@ -77,6 +76,4 @@ inline bool closeIt(const css::uno::Reference< css::uno::XInterface >& xResource
} // namespace framework::pattern::frame
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/pattern/window.hxx b/framework/source/inc/pattern/window.hxx
index f64d65a35e12..92134915dc37 100644
--- a/framework/source/inc/pattern/window.hxx
+++ b/framework/source/inc/pattern/window.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
+#pragma once
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/XTopWindow.hpp>
@@ -60,6 +59,4 @@ static bool isTopWindow(const css::uno::Reference< css::awt::XWindow >& xWindow)
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/interaction/quietinteraction.cxx b/framework/source/interaction/quietinteraction.cxx
index b6f3495fff09..11b8bc8b7029 100644
--- a/framework/source/interaction/quietinteraction.cxx
+++ b/framework/source/interaction/quietinteraction.cxx
@@ -28,13 +28,12 @@
#include <com/sun/star/document/LockedDocumentRequest.hpp>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
#include <vcl/svapp.hxx>
namespace framework{
QuietInteraction::QuietInteraction()
- : m_aRequest ( )
{
}
diff --git a/framework/source/jobs/helponstartup.cxx b/framework/source/jobs/helponstartup.cxx
index f022cbb73e05..2795a3f45057 100644
--- a/framework/source/jobs/helponstartup.cxx
+++ b/framework/source/jobs/helponstartup.cxx
@@ -27,6 +27,7 @@
// include others
#include <comphelper/sequenceashashmap.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/help.hxx>
@@ -56,8 +57,8 @@ css::uno::Sequence< OUString > SAL_CALL HelpOnStartup::getSupportedServiceNames(
return { SERVICENAME_JOB };
}
-HelpOnStartup::HelpOnStartup(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext)
+HelpOnStartup::HelpOnStartup(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext))
{
// create some needed uno services and cache it
m_xModuleManager = css::frame::ModuleManager::create( m_xContext );
@@ -65,10 +66,10 @@ HelpOnStartup::HelpOnStartup(const css::uno::Reference< css::uno::XComponentCont
m_xDesktop = css::frame::Desktop::create(m_xContext);
// ask for office locale
- m_sLocale = officecfg::Setup::L10N::ooLocale::get(m_xContext);
+ m_sLocale = officecfg::Setup::L10N::ooLocale::get();
// detect system
- m_sSystem = officecfg::Office::Common::Help::System::get(m_xContext);
+ m_sSystem = officecfg::Office::Common::Help::System::get();
// Start listening for disposing events of these services,
// so we can react e.g. for an office shutdown
@@ -124,7 +125,7 @@ css::uno::Any SAL_CALL HelpOnStartup::execute(const css::uno::Sequence< css::bea
// Note: The help window brings itself to front ...
Help* pHelp = Application::GetHelp();
if (pHelp)
- pHelp->Start(sModuleDependentHelpURL, static_cast<vcl::Window*>(nullptr));
+ pHelp->Start(sModuleDependentHelpURL);
}
}
@@ -133,7 +134,7 @@ css::uno::Any SAL_CALL HelpOnStartup::execute(const css::uno::Sequence< css::bea
void SAL_CALL HelpOnStartup::disposing(const css::lang::EventObject& aEvent)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (aEvent.Source == m_xModuleManager)
m_xModuleManager.clear();
else if (aEvent.Source == m_xDesktop)
@@ -174,9 +175,9 @@ OUString HelpOnStartup::its_getModuleIdFromEnv(const css::uno::Sequence< css::be
// OK - now we are sure this document is a top level document.
// Classify it.
// SAFE ->
- osl::ClearableMutexGuard aLock(m_mutex);
+ std::unique_lock aLock(m_mutex);
css::uno::Reference< css::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
- aLock.clear();
+ aLock.unlock();
// <- SAFE
OUString sModuleId;
@@ -195,9 +196,9 @@ OUString HelpOnStartup::its_getModuleIdFromEnv(const css::uno::Sequence< css::be
OUString HelpOnStartup::its_getCurrentHelpURL()
{
// SAFE ->
- osl::ClearableMutexGuard aLock(m_mutex);
+ std::unique_lock aLock(m_mutex);
css::uno::Reference< css::frame::XDesktop2 > xDesktop = m_xDesktop;
- aLock.clear();
+ aLock.unlock();
// <- SAFE
if (!xDesktop.is())
@@ -239,11 +240,11 @@ bool HelpOnStartup::its_isHelpUrlADefaultOne(std::u16string_view sHelpURL)
return false;
// SAFE ->
- osl::ClearableMutexGuard aLock(m_mutex);
+ std::unique_lock aLock(m_mutex);
css::uno::Reference< css::container::XNameAccess > xConfig = m_xConfig;
OUString sLocale = m_sLocale;
OUString sSystem = m_sSystem;
- aLock.clear();
+ aLock.unlock();
// <- SAFE
if (!xConfig.is())
@@ -282,11 +283,11 @@ bool HelpOnStartup::its_isHelpUrlADefaultOne(std::u16string_view sHelpURL)
OUString HelpOnStartup::its_checkIfHelpEnabledAndGetURL(const OUString& sModule)
{
// SAFE ->
- osl::ClearableMutexGuard aLock(m_mutex);
+ std::unique_lock aLock(m_mutex);
css::uno::Reference< css::container::XNameAccess > xConfig = m_xConfig;
OUString sLocale = m_sLocale;
OUString sSystem = m_sSystem;
- aLock.clear();
+ aLock.unlock();
// <- SAFE
OUString sHelpURL;
diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx
index 4cb9c5bb0ce1..711bd47b5823 100644
--- a/framework/source/jobs/job.cxx
+++ b/framework/source/jobs/job.cxx
@@ -31,7 +31,8 @@
#include <comphelper/sequence.hxx>
#include <sal/log.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
namespace framework{
@@ -50,10 +51,10 @@ namespace framework{
(May be null!)
*/
Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext ,
- /*IN*/ const css::uno::Reference< css::frame::XFrame >& xFrame )
+ /*IN*/ css::uno::Reference< css::frame::XFrame > xFrame )
: m_aJobCfg (xContext )
, m_xContext (xContext )
- , m_xFrame (xFrame )
+ , m_xFrame (std::move(xFrame ))
, m_bListenOnDesktop (false )
, m_bListenOnFrame (false )
, m_bListenOnModel (false )
@@ -77,10 +78,10 @@ Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xCont
(May be null!)
*/
Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext ,
- /*IN*/ const css::uno::Reference< css::frame::XModel >& xModel )
+ /*IN*/ css::uno::Reference< css::frame::XModel > xModel )
: m_aJobCfg (xContext )
, m_xContext (xContext )
- , m_xModel (xModel )
+ , m_xModel (std::move(xModel ))
, m_bListenOnDesktop (false )
, m_bListenOnFrame (false )
, m_bListenOnModel (false )
@@ -156,6 +157,18 @@ void Job::setJobData( const JobData& aData )
void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs )
{
/* SAFE { */
+ class SolarMutexAntiGuard {
+ SolarMutexResettableGuard & m_rGuard;
+ public:
+ SolarMutexAntiGuard(SolarMutexResettableGuard & rGuard) : m_rGuard(rGuard)
+ {
+ m_rGuard.clear();
+ }
+ ~SolarMutexAntiGuard()
+ {
+ m_rGuard.reset();
+ }
+ };
SolarMutexResettableGuard aWriteLock;
// reject dangerous calls
@@ -175,7 +188,7 @@ void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lD
// It's necessary to hold us self alive!
// Otherwise we might die by ref count ...
- css::uno::Reference< css::task::XJobListener > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::task::XJobListener > xThis(this);
try
{
@@ -191,23 +204,24 @@ void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lD
if (xAJob.is())
{
m_aAsyncWait.reset();
- aWriteLock.clear();
+ SolarMutexAntiGuard const ag(aWriteLock);
/* } SAFE */
xAJob->executeAsync(lJobArgs, xThis);
// wait for finishing this job - so this method
// does the same for synchronous and asynchronous jobs!
m_aAsyncWait.wait();
- aWriteLock.reset();
/* SAFE { */
// Note: Result handling was already done inside the callback!
}
// execute it synchron
else if (xSJob.is())
{
- aWriteLock.clear();
- /* } SAFE */
- css::uno::Any aResult = xSJob->execute(lJobArgs);
- aWriteLock.reset();
+ css::uno::Any aResult;
+ {
+ SolarMutexAntiGuard const ag(aWriteLock);
+ /* } SAFE */
+ aResult = xSJob->execute(lJobArgs);
+ }
/* SAFE { */
impl_reactForJobResult(aResult);
}
@@ -336,30 +350,36 @@ css::uno::Sequence< css::beans::NamedValue > Job::impl_generateJobArgs( /*IN*/ c
// Create list of environment variables. This list must be part of the
// returned structure every time... but some of its members are optional!
- css::uno::Sequence< css::beans::NamedValue > lEnvArgs(1);
- lEnvArgs[0].Name = "EnvType";
- lEnvArgs[0].Value <<= m_aJobCfg.getEnvironmentDescriptor();
+ sal_Int32 nLen = 1;
+ if (m_xFrame.is())
+ ++nLen;
+ if (m_xModel.is())
+ ++nLen;
+ if (eMode==JobData::E_EVENT)
+ ++nLen;
+ css::uno::Sequence< css::beans::NamedValue > lEnvArgs(nLen);
+ auto plEnvArgs = lEnvArgs.getArray();
+ plEnvArgs[0].Name = "EnvType";
+ plEnvArgs[0].Value <<= m_aJobCfg.getEnvironmentDescriptor();
+ sal_Int32 i = 0;
if (m_xFrame.is())
{
- sal_Int32 c = lEnvArgs.getLength();
- lEnvArgs.realloc(c+1);
- lEnvArgs[c].Name = "Frame";
- lEnvArgs[c].Value <<= m_xFrame;
+ ++i;
+ plEnvArgs[i].Name = "Frame";
+ plEnvArgs[i].Value <<= m_xFrame;
}
if (m_xModel.is())
{
- sal_Int32 c = lEnvArgs.getLength();
- lEnvArgs.realloc(c+1);
- lEnvArgs[c].Name = "Model";
- lEnvArgs[c].Value <<= m_xModel;
+ ++i;
+ plEnvArgs[i].Name = "Model";
+ plEnvArgs[i].Value <<= m_xModel;
}
if (eMode==JobData::E_EVENT)
{
- sal_Int32 c = lEnvArgs.getLength();
- lEnvArgs.realloc(c+1);
- lEnvArgs[c].Name = "EventName";
- lEnvArgs[c].Value <<= m_aJobCfg.getEvent();
+ ++i;
+ plEnvArgs[i].Name = "EventName";
+ plEnvArgs[i].Value <<= m_aJobCfg.getEvent();
}
// get the configuration data from the job data container ... if possible
@@ -381,29 +401,33 @@ css::uno::Sequence< css::beans::NamedValue > Job::impl_generateJobArgs( /*IN*/ c
{
sal_Int32 nLength = lAllArgs.getLength();
lAllArgs.realloc(nLength+1);
- lAllArgs[nLength].Name = "Config";
- lAllArgs[nLength].Value <<= lConfigArgs;
+ auto plAllArgs = lAllArgs.getArray();
+ plAllArgs[nLength].Name = "Config";
+ plAllArgs[nLength].Value <<= lConfigArgs;
}
if (!lJobConfigArgs.empty())
{
sal_Int32 nLength = lAllArgs.getLength();
lAllArgs.realloc(nLength+1);
- lAllArgs[nLength].Name = "JobConfig";
- lAllArgs[nLength].Value <<= comphelper::containerToSequence(lJobConfigArgs);
+ auto plAllArgs = lAllArgs.getArray();
+ plAllArgs[nLength].Name = "JobConfig";
+ plAllArgs[nLength].Value <<= comphelper::containerToSequence(lJobConfigArgs);
}
if (lEnvArgs.hasElements())
{
sal_Int32 nLength = lAllArgs.getLength();
lAllArgs.realloc(nLength+1);
- lAllArgs[nLength].Name = "Environment";
- lAllArgs[nLength].Value <<= lEnvArgs;
+ auto plAllArgs = lAllArgs.getArray();
+ plAllArgs[nLength].Name = "Environment";
+ plAllArgs[nLength].Value <<= lEnvArgs;
}
if (lDynamicArgs.hasElements())
{
sal_Int32 nLength = lAllArgs.getLength();
lAllArgs.realloc(nLength+1);
- lAllArgs[nLength].Name = "DynamicData";
- lAllArgs[nLength].Value <<= lDynamicArgs;
+ auto plAllArgs = lAllArgs.getArray();
+ plAllArgs[nLength].Name = "DynamicData";
+ plAllArgs[nLength].Value <<= lDynamicArgs;
}
return lAllArgs;
@@ -495,7 +519,7 @@ void Job::impl_startListening()
try
{
m_xDesktop = css::frame::Desktop::create( m_xContext );
- css::uno::Reference< css::frame::XTerminateListener > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XTerminateListener > xThis(this);
m_xDesktop->addTerminateListener(xThis);
m_bListenOnDesktop = true;
}
@@ -511,7 +535,7 @@ void Job::impl_startListening()
try
{
css::uno::Reference< css::util::XCloseBroadcaster > xCloseable(m_xFrame , css::uno::UNO_QUERY);
- css::uno::Reference< css::util::XCloseListener > xThis (static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XCloseListener > xThis(this);
if (xCloseable.is())
{
xCloseable->addCloseListener(xThis);
@@ -531,7 +555,7 @@ void Job::impl_startListening()
try
{
css::uno::Reference< css::util::XCloseBroadcaster > xCloseable(m_xModel , css::uno::UNO_QUERY);
- css::uno::Reference< css::util::XCloseListener > xThis (static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XCloseListener > xThis(this);
if (xCloseable.is())
{
xCloseable->addCloseListener(xThis);
@@ -557,7 +581,7 @@ void Job::impl_stopListening()
{
try
{
- css::uno::Reference< css::frame::XTerminateListener > xThis(static_cast< ::cppu::OWeakObject* >(this) , css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XTerminateListener > xThis(this);
m_xDesktop->removeTerminateListener(xThis);
m_xDesktop.clear();
m_bListenOnDesktop = false;
@@ -573,7 +597,7 @@ void Job::impl_stopListening()
try
{
css::uno::Reference< css::util::XCloseBroadcaster > xCloseable(m_xFrame , css::uno::UNO_QUERY);
- css::uno::Reference< css::util::XCloseListener > xThis (static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XCloseListener > xThis(this);
if (xCloseable.is())
{
xCloseable->removeCloseListener(xThis);
@@ -592,7 +616,7 @@ void Job::impl_stopListening()
try
{
css::uno::Reference< css::util::XCloseBroadcaster > xCloseable(m_xModel , css::uno::UNO_QUERY);
- css::uno::Reference< css::util::XCloseListener > xThis (static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XCloseListener > xThis(this);
if (xCloseable.is())
{
xCloseable->removeCloseListener(xThis);
diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx
index 6013812e0e7f..0ca06fcaca8a 100644
--- a/framework/source/jobs/jobdata.cxx
+++ b/framework/source/jobs/jobdata.cxx
@@ -32,6 +32,7 @@
#include <tools/wldcrd.hxx>
#include <unotools/configpaths.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
namespace framework{
@@ -45,8 +46,8 @@ namespace framework{
@param rxContext
reference to the uno service manager
*/
-JobData::JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- : m_xContext (rxContext )
+JobData::JobData( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move(xContext ))
{
// share code for member initialization with defaults!
impl_reset();
@@ -76,7 +77,6 @@ JobData::JobData( const JobData& rCopy )
*/
JobData& JobData::operator=( const JobData& rCopy )
{
- SolarMutexGuard g;
// Please don't copy the uno service manager reference.
// That can change the uno context, which isn't a good idea!
m_eMode = rCopy.m_eMode;
@@ -110,7 +110,6 @@ JobData::~JobData()
*/
void JobData::setAlias( const OUString& sAlias )
{
- SolarMutexGuard g;
// delete all old information! Otherwise we mix it with the new one ...
impl_reset();
@@ -176,7 +175,6 @@ void JobData::setAlias( const OUString& sAlias )
*/
void JobData::setService( const OUString& sService )
{
- SolarMutexGuard g;
// delete all old information! Otherwise we mix it with the new one ...
impl_reset();
// take over the new information
@@ -208,7 +206,6 @@ void JobData::setEvent( const OUString& sEvent ,
// share code to read all job properties!
setAlias(sAlias);
- SolarMutexGuard g;
// take over the new information - which differ against set one of method setAlias()!
m_sEvent = sEvent;
m_eMode = E_EVENT;
@@ -225,12 +222,10 @@ void JobData::setEvent( const OUString& sEvent ,
@param lArguments
list of arguments, which should be set for this job
*/
-void JobData::setJobConfig( const std::vector< css::beans::NamedValue >& lArguments )
+void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments )
{
- SolarMutexGuard g;
-
// update member
- m_lArguments = lArguments;
+ m_lArguments = std::move(lArguments);
// update the configuration ... if possible!
if (m_eMode!=E_ALIAS)
@@ -252,12 +247,14 @@ void JobData::setJobConfig( const std::vector< css::beans::NamedValue >& lArgume
{
sal_Int32 nCount = m_lArguments.size();
css::uno::Sequence< OUString > lNames (nCount);
+ auto lNamesRange = asNonConstRange(lNames);
css::uno::Sequence< css::uno::Any > lValues(nCount);
+ auto lValuesRange = asNonConstRange(lValues);
for (sal_Int32 i=0; i<nCount; ++i)
{
- lNames [i] = m_lArguments[i].Name;
- lValues[i] = m_lArguments[i].Value;
+ lNamesRange [i] = m_lArguments[i].Name;
+ lValuesRange[i] = m_lArguments[i].Value;
}
xArgumentList->setHierarchicalPropertyValues(lNames, lValues);
@@ -273,7 +270,6 @@ void JobData::setJobConfig( const std::vector< css::beans::NamedValue >& lArgume
*/
void JobData::setEnvironment( EEnvironment eEnvironment )
{
- SolarMutexGuard g;
m_eEnvironment = eEnvironment;
}
@@ -284,20 +280,17 @@ void JobData::setEnvironment( EEnvironment eEnvironment )
*/
JobData::EMode JobData::getMode() const
{
- SolarMutexGuard g;
return m_eMode;
}
JobData::EEnvironment JobData::getEnvironment() const
{
- SolarMutexGuard g;
return m_eEnvironment;
}
OUString JobData::getEnvironmentDescriptor() const
{
OUString sDescriptor;
- SolarMutexGuard g;
switch(m_eEnvironment)
{
case E_EXECUTION :
@@ -319,42 +312,27 @@ OUString JobData::getEnvironmentDescriptor() const
OUString JobData::getService() const
{
- SolarMutexGuard g;
return m_sService;
}
OUString JobData::getEvent() const
{
- SolarMutexGuard g;
return m_sEvent;
}
std::vector< css::beans::NamedValue > JobData::getJobConfig() const
{
- SolarMutexGuard g;
return m_lArguments;
}
css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const
{
- SolarMutexGuard g;
css::uno::Sequence< css::beans::NamedValue > lConfig;
if (m_eMode==E_ALIAS)
{
- lConfig.realloc(3);
- sal_Int32 i = 0;
-
- lConfig[i].Name = "Alias";
- lConfig[i].Value <<= m_sAlias;
- ++i;
-
- lConfig[i].Name = "Service";
- lConfig[i].Value <<= m_sService;
- ++i;
-
- lConfig[i].Name = "Context";
- lConfig[i].Value <<= m_sContext;
- ++i;
+ lConfig = { { "Alias", css::uno::Any(m_sAlias) },
+ { "Service", css::uno::Any(m_sService) },
+ { "Context", css::uno::Any(m_sContext) } };
}
return lConfig;
}
@@ -372,7 +350,6 @@ css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const
*/
bool JobData::hasConfig() const
{
- SolarMutexGuard g;
return (m_eMode==E_ALIAS || m_eMode==E_EVENT);
}
@@ -388,8 +365,6 @@ bool JobData::hasConfig() const
*/
void JobData::disableJob()
{
- SolarMutexGuard g;
-
// No configuration - not used from EXECUTOR and not triggered from an event => no chance!
if (m_eMode!=E_EVENT)
return;
@@ -456,10 +431,10 @@ void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XC
}
}
-bool JobData::hasCorrectContext(const OUString& rModuleIdent) const
+bool JobData::hasCorrectContext(std::u16string_view rModuleIdent) const
{
sal_Int32 nContextLen = m_sContext.getLength();
- sal_Int32 nModuleIdLen = rModuleIdent.getLength();
+ sal_Int32 nModuleIdLen = rModuleIdent.size();
if ( nContextLen == 0 )
return true;
@@ -468,10 +443,10 @@ bool JobData::hasCorrectContext(const OUString& rModuleIdent) const
{
sal_Int32 nIndex = m_sContext.indexOf( rModuleIdent );
if ( nIndex >= 0 && ( nIndex+nModuleIdLen <= nContextLen ))
- {
- OUString sContextModule = m_sContext.copy( nIndex, nModuleIdLen );
- return sContextModule == rModuleIdent;
- }
+ {
+ std::u16string_view sContextModule = m_sContext.subView( nIndex, nModuleIdLen );
+ return sContextModule == rModuleIdent;
+ }
}
return false;
@@ -556,7 +531,6 @@ std::vector< OUString > JobData::getEnabledJobsForEvent( const css::uno::Referen
*/
void JobData::impl_reset()
{
- SolarMutexGuard g;
m_eMode = E_UNKNOWN_MODE;
m_eEnvironment = E_UNKNOWN_ENVIRONMENT;
m_sAlias.clear();
diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx
index 964f128e9110..2352919dea09 100644
--- a/framework/source/jobs/jobdispatch.cxx
+++ b/framework/source/jobs/jobdispatch.cxx
@@ -36,6 +36,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
using namespace framework;
@@ -73,7 +74,7 @@ private:
public:
- explicit JobDispatch(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit JobDispatch(css::uno::Reference< css::uno::XComponentContext > xContext);
virtual ~JobDispatch() override;
void impl_dispatchEvent ( const OUString& sEvent ,
@@ -132,8 +133,8 @@ public:
@param xContext
reference to the uno service manager
*/
-JobDispatch::JobDispatch( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : m_xContext (xContext )
+JobDispatch::JobDispatch( /*IN*/ css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext (std::move(xContext ))
{
}
@@ -204,7 +205,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL JobDispatch::queryDispatch
JobURL aAnalyzedURL(aURL.Complete);
if (aAnalyzedURL.isValid())
- xDispatch.set( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+ xDispatch = this;
return xDispatch;
}
@@ -226,9 +227,9 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL JobD
// don't pack resulting list!
sal_Int32 nCount = lDescriptor.getLength();
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatches(nCount);
-
+ auto lDispatchesRange = asNonConstRange(lDispatches);
for (sal_Int32 i=0; i<nCount; ++i)
- lDispatches[i] = queryDispatch( lDescriptor[i].FeatureURL ,
+ lDispatchesRange[i] = queryDispatch( lDescriptor[i].FeatureURL ,
lDescriptor[i].FrameName ,
lDescriptor[i].SearchFlags );
return lDispatches;
@@ -300,11 +301,7 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString&
// get list of all enabled jobs
// The called static helper methods read it from the configuration and
// filter disabled jobs using it's time stamp values.
- /* SAFE { */
- SolarMutexResettableGuard aReadLock;
std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent);
- aReadLock.clear();
- /* } SAFE */
css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
@@ -316,9 +313,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString&
int nExecutedJobs=0;
for (const OUString & lJob : lJobs)
{
- /* SAFE { */
- aReadLock.reset();
-
JobData aCfg(m_xContext);
aCfg.setEvent(sEvent, lJob);
aCfg.setEnvironment(JobData::E_DISPATCH);
@@ -327,9 +321,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString&
rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame);
pJob->setJobData(aCfg);
- aReadLock.clear();
- /* } SAFE */
-
if (!bIsEnabled)
continue;
@@ -373,9 +364,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString&
/*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs ,
/*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
{
- /* SAFE { */
- SolarMutexClearableGuard aReadLock;
-
JobData aCfg(m_xContext);
aCfg.setService(sService);
aCfg.setEnvironment(JobData::E_DISPATCH);
@@ -388,9 +376,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString&
rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame);
pJob->setJobData(aCfg);
- aReadLock.clear();
- /* } SAFE */
-
css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
// Special mode for listener.
@@ -422,9 +407,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString&
/*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs ,
/*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
{
- /* SAFE { */
- SolarMutexClearableGuard aReadLock;
-
JobData aCfg(m_xContext);
aCfg.setAlias(sAlias);
aCfg.setEnvironment(JobData::E_DISPATCH);
@@ -432,9 +414,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString&
rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame);
pJob->setJobData(aCfg);
- aReadLock.clear();
- /* } SAFE */
-
css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
// Special mode for listener.
diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index 30b90cca6ec4..f1c450bd6530 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -31,10 +31,9 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/document/XEventListener.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/configuration.hxx>
#include <unotools/configpaths.hxx>
#include <rtl/ref.hxx>
#include <sal/log.hxx>
@@ -44,7 +43,7 @@ using namespace framework;
namespace {
-typedef cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo
, css::task::XJobExecutor
, css::container::XContainerListener // => lang.XEventListener
@@ -57,7 +56,7 @@ typedef cppu::WeakComponentImplHelper<
inside the configuration and execute it. Of course it controls the
lifetime of such jobs too.
*/
-class JobExecutor : private cppu::BaseMutex, public Base
+class JobExecutor : public Base
{
private:
@@ -73,7 +72,7 @@ private:
/** helper to allow us listen to the configuration without a cyclic dependency */
css::uno::Reference<css::container::XContainerListener> m_xConfigListener;
- virtual void SAL_CALL disposing() final override;
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) final override;
public:
@@ -121,15 +120,14 @@ public:
reference to the uno service manager
*/
JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : Base (m_aMutex)
- , m_xContext (xContext )
+ : m_xContext (xContext )
, m_aConfig (xContext, "/org.openoffice.Office.Jobs/Events")
{
}
void JobExecutor::initListeners()
{
- if (utl::ConfigManager::IsFuzzing())
+ if (comphelper::IsFuzzing())
return;
// read the list of all currently registered events inside configuration.
@@ -162,21 +160,19 @@ void JobExecutor::initListeners()
JobExecutor::~JobExecutor()
{
- disposing();
+ std::unique_lock g(m_aMutex);
+ disposing(g);
}
-void JobExecutor::disposing() {
+void JobExecutor::disposing(std::unique_lock<std::mutex>& /*rGuard*/) {
css::uno::Reference<css::container::XContainer> notifier;
css::uno::Reference<css::container::XContainerListener> listener;
- {
- osl::MutexGuard g(rBHelper.rMutex);
- if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) {
- notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY);
- listener = m_xConfigListener;
- m_aConfig.close();
- }
- m_xConfigListener.clear();
+ if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) {
+ notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY);
+ listener = m_xConfigListener;
+ m_aConfig.close();
}
+ m_xConfigListener.clear();
if (notifier.is()) {
notifier->removeContainerListener(listener);
}
@@ -195,45 +191,38 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent )
{
SAL_INFO( "fwk", "JobExecutor::trigger()");
- std::vector< OUString > lJobs;
+ /* SAFE */
+ {
+ std::unique_lock g(m_aMutex);
- /* SAFE */ {
- osl::MutexGuard g(rBHelper.rMutex);
+ // Optimization!
+ // Check if the given event name exist inside configuration and reject wrong requests.
+ // This optimization suppress using of the cfg api for getting event and job descriptions ...
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end())
+ return;
- // Optimization!
- // Check if the given event name exist inside configuration and reject wrong requests.
- // This optimization suppress using of the cfg api for getting event and job descriptions ...
- if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end())
- return;
+ } /* SAFE */
// get list of all enabled jobs
// The called static helper methods read it from the configuration and
// filter disabled jobs using it's time stamp values.
- lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent);
- } /* SAFE */
+ std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent);
// step over all enabled jobs and execute it
size_t c = lJobs.size();
for (size_t j=0; j<c; ++j)
{
- rtl::Reference<Job> pJob;
-
- /* SAFE */
- {
- SolarMutexGuard g2;
-
- JobData aCfg(m_xContext);
- aCfg.setEvent(sEvent, lJobs[j]);
- aCfg.setEnvironment(JobData::E_EXECUTION);
+ JobData aCfg(m_xContext);
+ aCfg.setEvent(sEvent, lJobs[j]);
+ aCfg.setEnvironment(JobData::E_EXECUTION);
- /*Attention!
- Jobs implements interfaces and dies by ref count!
- And freeing of such uno object is done by uno itself.
- So we have to use dynamic memory everytimes.
- */
- pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >());
- pJob->setJobData(aCfg);
- } /* SAFE */
+ /*Attention!
+ Jobs implements interfaces and dies by ref count!
+ And freeing of such uno object is done by uno itself.
+ So we have to use dynamic memory everytimes.
+ */
+ rtl::Reference<Job> pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >());
+ pJob->setJobData(aCfg);
pJob->execute(css::uno::Sequence< css::beans::NamedValue >());
}
@@ -241,15 +230,12 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent )
void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent )
{
- static constexpr OUStringLiteral EVENT_ON_DOCUMENT_OPENED(u"onDocumentOpened"); // Job UI event : OnNew or OnLoad
- static constexpr OUStringLiteral EVENT_ON_DOCUMENT_ADDED(u"onDocumentAdded"); // Job API event : OnCreate or OnLoadFinished
+ static constexpr OUString EVENT_ON_DOCUMENT_OPENED(u"onDocumentOpened"_ustr); // Job UI event : OnNew or OnLoad
+ static constexpr OUString EVENT_ON_DOCUMENT_ADDED(u"onDocumentAdded"_ustr); // Job API event : OnCreate or OnLoadFinished
OUString aModuleIdentifier;
::std::vector< JobData::TJob2DocEventBinding > lJobs;
- /* SAFE */ {
- osl::MutexGuard g(rBHelper.rMutex);
-
// Optimization!
// Check if the given event name exist inside configuration and reject wrong requests.
// This optimization suppress using of the cfg api for getting event and job descriptions.
@@ -263,29 +249,33 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
catch( const css::uno::Exception& )
{}
- // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened".
- if (
- (aEvent.EventName == "OnNew") ||
- (aEvent.EventName == "OnLoad")
- )
+ /* SAFE */
{
- if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs);
- }
+ std::unique_lock g(m_aMutex);
- // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded".
- if (
- (aEvent.EventName == "OnCreate") ||
- (aEvent.EventName == "OnLoadFinished")
- )
- {
- if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs);
- }
+ // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened".
+ if (
+ (aEvent.EventName == "OnNew") ||
+ (aEvent.EventName == "OnLoad")
+ )
+ {
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs);
+ }
- // Add all jobs for "real" notified event too .-)
- if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs);
+ // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded".
+ if (
+ (aEvent.EventName == "OnCreate") ||
+ (aEvent.EventName == "OnLoadFinished")
+ )
+ {
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs);
+ }
+
+ // Add all jobs for "real" notified event too .-)
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs);
} /* SAFE */
// step over all enabled jobs and execute it
@@ -293,9 +283,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
{
rtl::Reference<Job> pJob;
- /* SAFE */ {
- SolarMutexGuard g2;
-
const JobData::TJob2DocEventBinding& rBinding = lJob;
JobData aCfg(m_xContext);
@@ -313,7 +300,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
css::uno::Reference< css::frame::XModel > xModel(aEvent.Source, css::uno::UNO_QUERY);
pJob = new Job(m_xContext, xModel);
pJob->setJobData(aCfg);
- } /* SAFE */
pJob->execute(css::uno::Sequence< css::beans::NamedValue >());
}
@@ -371,7 +357,7 @@ void SAL_CALL JobExecutor::elementReplaced( const css::container::ContainerEvent
void SAL_CALL JobExecutor::disposing( const css::lang::EventObject& aEvent )
{
/* SAFE { */
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
css::uno::Reference< css::uno::XInterface > xCFG(m_aConfig.cfg(), css::uno::UNO_QUERY);
if (
(xCFG == aEvent.Source ) &&
@@ -383,25 +369,6 @@ void SAL_CALL JobExecutor::disposing( const css::lang::EventObject& aEvent )
/* } SAFE */
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new JobExecutor(context)))
- {
- // 2nd phase initialization needed
- static_cast<JobExecutor *>(static_cast<cppu::OWeakObject *>
- (instance.get()))->initListeners();
- }
-
- rtl::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -409,8 +376,10 @@ com_sun_star_comp_framework_JobExecutor_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ rtl::Reference<JobExecutor> xJobExec = new JobExecutor(context);
+ // 2nd phase initialization needed
+ xJobExec->initListeners();
+ return cppu::acquire(xJobExec.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/jobs/jobresult.cxx b/framework/source/jobs/jobresult.cxx
index 58cd2b59401c..183543606b59 100644
--- a/framework/source/jobs/jobresult.cxx
+++ b/framework/source/jobs/jobresult.cxx
@@ -142,7 +142,6 @@ JobResult::~JobResult()
*/
JobResult& JobResult::operator=(const JobResult& rCopy)
{
- SolarMutexGuard g;
m_eParts = rCopy.m_eParts;
m_lArguments = rCopy.m_lArguments;
m_aDispatchResult = rCopy.m_aDispatchResult;
@@ -161,11 +160,7 @@ JobResult& JobResult::operator=(const JobResult& rCopy)
@return We return true only, if any set flag of the given mask match.
*/
-bool JobResult::existPart(sal_uInt32 eParts) const
-{
- SolarMutexGuard g;
- return ((m_eParts & eParts) == eParts);
-}
+bool JobResult::existPart(sal_uInt32 eParts) const { return ((m_eParts & eParts) == eParts); }
/**
@short provides access to our internal members
@@ -175,17 +170,9 @@ bool JobResult::existPart(sal_uInt32 eParts) const
@return It returns the state of the internal member
without any checks!
*/
-std::vector<css::beans::NamedValue> JobResult::getArguments() const
-{
- SolarMutexGuard g;
- return m_lArguments;
-}
+std::vector<css::beans::NamedValue> JobResult::getArguments() const { return m_lArguments; }
-css::frame::DispatchResultEvent JobResult::getDispatchResult() const
-{
- SolarMutexGuard g;
- return m_aDispatchResult;
-}
+css::frame::DispatchResultEvent JobResult::getDispatchResult() const { return m_aDispatchResult; }
} // namespace framework
diff --git a/framework/source/jobs/joburl.cxx b/framework/source/jobs/joburl.cxx
index efff201a8401..5533014edf80 100644
--- a/framework/source/jobs/joburl.cxx
+++ b/framework/source/jobs/joburl.cxx
@@ -24,6 +24,7 @@
#include <jobs/joburl.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
namespace framework{
@@ -99,7 +100,6 @@ JobURL::JobURL( /*IN*/ const OUString& sURL )
*/
bool JobURL::isValid() const
{
- SolarMutexGuard g;
return (m_eRequest!=E_UNKNOWN);
}
@@ -121,8 +121,6 @@ bool JobURL::isValid() const
*/
bool JobURL::getEvent( /*OUT*/ OUString& sEvent ) const
{
- SolarMutexGuard g;
-
sEvent.clear();
bool bSet = ((m_eRequest & E_EVENT) == E_EVENT);
if (bSet)
@@ -149,8 +147,6 @@ bool JobURL::getEvent( /*OUT*/ OUString& sEvent ) const
*/
bool JobURL::getAlias( /*OUT*/ OUString& sAlias ) const
{
- SolarMutexGuard g;
-
sAlias.clear();
bool bSet = ((m_eRequest & E_ALIAS) == E_ALIAS);
if (bSet)
@@ -177,8 +173,6 @@ bool JobURL::getAlias( /*OUT*/ OUString& sAlias ) const
*/
bool JobURL::getService( /*OUT*/ OUString& sService ) const
{
- SolarMutexGuard g;
-
sService.clear();
bool bSet = ((m_eRequest & E_SERVICE) == E_SERVICE);
if (bSet)
@@ -212,14 +206,14 @@ bool JobURL::getService( /*OUT*/ OUString& sService ) const
@return <TRUE/> if the identifier could be found and the string was split.
<FALSE/> otherwise.
*/
-bool JobURL::implst_split( /*IN*/ const OUString& sPart ,
+bool JobURL::implst_split( /*IN*/ std::u16string_view sPart ,
/*IN*/ const char* pPartIdentifier ,
/*IN*/ sal_Int32 nPartLength ,
/*OUT*/ OUString& rPartValue ,
/*OUT*/ OUString& rPartArguments )
{
// first search for the given identifier
- bool bPartFound = sPart.matchIgnoreAsciiCaseAsciiL(pPartIdentifier,nPartLength);
+ bool bPartFound = o3tl::matchIgnoreAsciiCase(sPart, std::string_view(pPartIdentifier,nPartLength));
// If it exist - we can split the part and return sal_True.
// Otherwise we do nothing and return sal_False.
@@ -229,16 +223,16 @@ bool JobURL::implst_split( /*IN*/ const OUString& sPart ,
// Do so - we set the return value with the whole part string.
// Arguments will be set to an empty string as default.
// If we detect the right sign - we split the arguments and overwrite the default.
- OUString sValueAndArguments = sPart.copy(nPartLength);
- OUString sValue = sValueAndArguments;
+ std::u16string_view sValueAndArguments = sPart.substr(nPartLength);
+ std::u16string_view sValue = sValueAndArguments;
OUString sArguments;
- sal_Int32 nArgStart = sValueAndArguments.indexOf('?');
- if (nArgStart!=-1)
+ size_t nArgStart = sValueAndArguments.find('?');
+ if (nArgStart != std::u16string_view::npos)
{
- sValue = sValueAndArguments.copy(0,nArgStart);
+ sValue = sValueAndArguments.substr(0,nArgStart);
++nArgStart; // ignore '?'!
- sArguments = sValueAndArguments.copy(nArgStart);
+ sArguments = sValueAndArguments.substr(nArgStart);
}
rPartValue = sValue;
diff --git a/framework/source/jobs/shelljob.cxx b/framework/source/jobs/shelljob.cxx
index 292c1a701508..0c895db33f71 100644
--- a/framework/source/jobs/shelljob.cxx
+++ b/framework/source/jobs/shelljob.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/util/PathSubstitution.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
namespace framework{
@@ -55,8 +56,8 @@ css::uno::Sequence< OUString > SAL_CALL ShellJob::getSupportedServiceNames()
}
-ShellJob::ShellJob(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext)
+ShellJob::ShellJob(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext))
{
}
@@ -101,8 +102,8 @@ css::uno::Any SAL_CALL ShellJob::execute(const css::uno::Sequence< css::beans::N
css::uno::Any ShellJob::impl_generateAnswer4Deactivation()
{
- css::uno::Sequence< css::beans::NamedValue > aAnswer { { JobConst::ANSWER_DEACTIVATE_JOB, css::uno::makeAny(true) } };
- return css::uno::makeAny(aAnswer);
+ css::uno::Sequence< css::beans::NamedValue > aAnswer { { JobConst::ANSWER_DEACTIVATE_JOB, css::uno::Any(true) } };
+ return css::uno::Any(aAnswer);
}
OUString ShellJob::impl_substituteCommandVariables(const OUString& sCommand)
diff --git a/framework/source/layoutmanager/helpers.cxx b/framework/source/layoutmanager/helpers.cxx
index f5fe1fc48f44..ccce1b3e8673 100644
--- a/framework/source/layoutmanager/helpers.cxx
+++ b/framework/source/layoutmanager/helpers.cxx
@@ -29,8 +29,10 @@
#include <com/sun/star/ui/XUIElement.hpp>
#include <comphelper/lok.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <unotools/mediadescriptor.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
#include <toolkit/helper/vclunohelper.hxx>
using namespace com::sun::star;
@@ -87,7 +89,7 @@ OUString retrieveToolbarNameFromHelpURL( vcl::Window* pWindow )
ToolBox* pToolBox = dynamic_cast<ToolBox *>( pWindow );
if ( pToolBox )
{
- aToolbarName = OStringToOUString( pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8 );
+ aToolbarName = pToolBox->GetHelpId();
sal_Int32 i = aToolbarName.lastIndexOf( ':' );
if ( !aToolbarName.isEmpty() && ( i > 0 ) && (( i + 1 ) < aToolbarName.getLength() ))
aToolbarName = aToolbarName.copy( i+1 ); // Remove ".HelpId:" protocol from toolbar name
@@ -127,14 +129,6 @@ SystemWindow* getTopSystemWindow( const uno::Reference< awt::XWindow >& xWindow
return nullptr;
}
-void setZeroRectangle( ::tools::Rectangle& rRect )
-{
- rRect.setX(0);
- rRect.setY(0);
- rRect.setWidth(0);
- rRect.setHeight(0);
-}
-
// ATTENTION!
// This value is directly copied from the sfx2 project.
// You have to change BOTH values, see sfx2/inc/sfx2/sfxsids.hrc (SID_DOCKWIN_START)
@@ -160,7 +154,7 @@ bool lcl_checkUIElement(const uno::Reference< ui::XUIElement >& xUIElement, awt:
return bRet;
}
-uno::Reference< awt::XWindowPeer > createToolkitWindow( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< awt::XWindowPeer >& rParent, const char* pService )
+uno::Reference< awt::XVclWindowPeer > createToolkitWindow( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< awt::XVclWindowPeer >& rParent, const char* pService )
{
uno::Reference< awt::XToolkit2 > xToolkit = awt::Toolkit::create( rxContext );
@@ -175,8 +169,9 @@ uno::Reference< awt::XWindowPeer > createToolkitWindow( const uno::Reference< un
// create an awt window
uno::Reference< awt::XWindowPeer > xPeer = xToolkit->createWindow( aDescriptor );
-
- return xPeer;
+ uno::Reference< awt::XVclWindowPeer > xVclPeer(xPeer, uno::UNO_QUERY);
+ assert(xVclPeer || !xPeer);
+ return xVclPeer;
}
// convert alignment constant to vcl's WindowAlign type
@@ -192,26 +187,24 @@ WindowAlign ImplConvertAlignment( ui::DockingArea aAlignment )
return WindowAlign::Bottom;
}
-OUString getElementTypeFromResourceURL( const OUString& aResourceURL )
+std::u16string_view getElementTypeFromResourceURL( std::u16string_view aResourceURL )
{
- OUString aUIResourceURL( UIRESOURCE_URL );
- if ( aResourceURL.startsWith( aUIResourceURL ) )
+ if ( o3tl::starts_with(aResourceURL, UIRESOURCE_URL ) )
{
- sal_Int32 nIndex{ aUIResourceURL.getLength() };
- return aResourceURL.getToken( 1, '/', nIndex );
+ sal_Int32 nIndex{ UIRESOURCE_URL.getLength() };
+ return o3tl::getToken(aResourceURL, 1, '/', nIndex );
}
- return OUString();
+ return std::u16string_view();
}
-void parseResourceURL( const OUString& aResourceURL, OUString& aElementType, OUString& aElementName )
+void parseResourceURL( std::u16string_view aResourceURL, OUString& aElementType, OUString& aElementName )
{
- OUString aUIResourceURL( UIRESOURCE_URL );
- if ( aResourceURL.startsWith( aUIResourceURL ) )
+ if ( o3tl::starts_with(aResourceURL, UIRESOURCE_URL) )
{
- sal_Int32 nIndex{ aUIResourceURL.getLength() };
- aElementType = aResourceURL.getToken( 1, '/', nIndex );
- aElementName = aResourceURL.getToken( 0, '/', nIndex );
+ sal_Int32 nIndex{ UIRESOURCE_URL.getLength() };
+ aElementType = o3tl::getToken(aResourceURL, 1, '/', nIndex );
+ aElementName = o3tl::getToken(aResourceURL, 0, '/', nIndex );
}
}
@@ -270,7 +263,7 @@ bool implts_isPreviewModel( const uno::Reference< frame::XModel >& xModel )
if ( xModel.is() )
{
utl::MediaDescriptor aDesc( xModel->getArgs() );
- return aDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW(), false);
+ return aDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW, false);
}
else
return false;
@@ -294,9 +287,9 @@ bool implts_isFrameOrWindowTop( const uno::Reference< frame::XFrame >& xFrame )
return false;
}
-void impl_setDockingWindowVisibility( const css::uno::Reference< css::uno::XComponentContext>& rxContext, const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName, bool bVisible )
+void impl_setDockingWindowVisibility( const css::uno::Reference< css::uno::XComponentContext>& rxContext, const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName, bool bVisible )
{
- sal_Int32 nID = rDockingWindowName.toInt32();
+ sal_Int32 nID = o3tl::toInt32(rDockingWindowName);
sal_Int32 nIndex = nID - DOCKWIN_ID_BASE;
css::uno::Reference< css::frame::XDispatchProvider > xProvider(rFrame, css::uno::UNO_QUERY);
@@ -305,9 +298,8 @@ void impl_setDockingWindowVisibility( const css::uno::Reference< css::uno::XComp
OUString aDockWinArgName = "DockingWindow" + OUString::number( nIndex );
- css::uno::Sequence< css::beans::PropertyValue > aArgs(1);
- aArgs[0].Name = aDockWinArgName;
- aArgs[0].Value <<= bVisible;
+ css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
+ aDockWinArgName, bVisible) };
css::uno::Reference< css::frame::XDispatchHelper > xDispatcher = css::frame::DispatchHelper::create( rxContext );
diff --git a/framework/source/layoutmanager/helpers.hxx b/framework/source/layoutmanager/helpers.hxx
index 6d5b00705746..c58fa6665bad 100644
--- a/framework/source/layoutmanager/helpers.hxx
+++ b/framework/source/layoutmanager/helpers.hxx
@@ -17,10 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_HELPERS_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_HELPERS_HXX
+#pragma once
-#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
@@ -31,8 +30,8 @@
#include <vcl/window.hxx>
#include <vcl/toolbox.hxx>
-#define UIRESOURCE_URL "private:resource"
-#define UIRESOURCETYPE_TOOLBAR "toolbar"
+inline constexpr OUString UIRESOURCE_URL = u"private:resource"_ustr;
+inline constexpr OUString UIRESOURCETYPE_TOOLBAR = u"toolbar"_ustr;
#define UIRESOURCETYPE_MENUBAR "menubar"
namespace framework
@@ -50,22 +49,19 @@ ToolBox* getToolboxPtr( vcl::Window* pWindow );
vcl::Window* getWindowFromXUIElement( const css::uno::Reference< css::ui::XUIElement >& xUIElement );
SystemWindow* getTopSystemWindow( const css::uno::Reference< css::awt::XWindow >& xWindow );
bool equalRectangles( const css::awt::Rectangle& rRect1, const css::awt::Rectangle& rRect2 );
-void setZeroRectangle( ::tools::Rectangle& rRect );
bool lcl_checkUIElement(const css::uno::Reference< css::ui::XUIElement >& xUIElement,css::awt::Rectangle& _rPosSize, css::uno::Reference< css::awt::XWindow >& _xWindow);
-css::uno::Reference< css::awt::XWindowPeer > createToolkitWindow( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::awt::XWindowPeer >& rParent, const char* pService );
+css::uno::Reference< css::awt::XVclWindowPeer > createToolkitWindow( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::awt::XVclWindowPeer >& rParent, const char* pService );
WindowAlign ImplConvertAlignment( css::ui::DockingArea aAlignment );
-OUString getElementTypeFromResourceURL( const OUString& aResourceURL );
-void parseResourceURL( const OUString& aResourceURL, OUString& aElementType, OUString& aElementName );
+std::u16string_view getElementTypeFromResourceURL( std::u16string_view aResourceURL );
+void parseResourceURL( std::u16string_view aResourceURL, OUString& aElementType, OUString& aElementName );
::tools::Rectangle putAWTToRectangle( const css::awt::Rectangle& rRect );
css::awt::Rectangle putRectangleValueToAWT( const ::tools::Rectangle& rRect );
css::uno::Reference< css::frame::XModel > impl_getModelFromFrame( const css::uno::Reference< css::frame::XFrame >& rFrame );
bool implts_isPreviewModel( const css::uno::Reference< css::frame::XModel >& xModel );
bool implts_isFrameOrWindowTop( const css::uno::Reference< css::frame::XFrame >& xFrame );
-void impl_setDockingWindowVisibility( const css::uno::Reference< css::uno::XComponentContext>& rxContext, const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName, bool bVisible );
+void impl_setDockingWindowVisibility( const css::uno::Reference< css::uno::XComponentContext>& rxContext, const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName, bool bVisible );
void impl_addWindowListeners( const css::uno::Reference< css::uno::XInterface >& xThis, const css::uno::Reference< css::ui::XUIElement >& xUIElement );
}
-#endif // INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_HELPERS_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index e080497b066b..bd122e6f683f 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/util/URLTransformer.hpp>
#include <comphelper/lok.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/status.hxx>
#include <vcl/settings.hxx>
#include <vcl/window.hxx>
@@ -58,11 +59,11 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <comphelper/uno3.hxx>
-#include <rtl/instance.hxx>
#include <officecfg/Office/Compatibility.hxx>
#include <rtl/ref.hxx>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
#include <algorithm>
@@ -76,7 +77,7 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::frame;
-constexpr OUStringLiteral STATUS_BAR_ALIAS = u"private:resource/statusbar/statusbar";
+constexpr OUString STATUS_BAR_ALIAS = u"private:resource/statusbar/statusbar"_ustr;
namespace framework
{
@@ -84,8 +85,8 @@ namespace framework
IMPLEMENT_FORWARD_XTYPEPROVIDER2( LayoutManager, LayoutManager_Base, LayoutManager_PBase )
IMPLEMENT_FORWARD_XINTERFACE2( LayoutManager, LayoutManager_Base, LayoutManager_PBase )
-LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) : LayoutManager_Base()
- , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >(m_aMutex)
+LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
+ ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >(m_aMutex)
, LayoutManager_PBase( *static_cast< ::cppu::OBroadcastHelper* >(this) )
, m_xContext( xContext )
, m_xURLTransformer( URLTransformer::create(xContext) )
@@ -107,6 +108,7 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
, m_xModuleManager( ModuleManager::create( xContext ))
, m_xUIElementFactoryManager( ui::theUIElementFactoryManager::get(xContext) )
, m_xPersistentWindowStateSupplier( ui::theWindowStateConfiguration::get( xContext ) )
+ , m_aAsyncLayoutTimer( "framework::LayoutManager m_aAsyncLayoutTimer" )
, m_aListenerContainer( m_aMutex )
{
// Initialize statusbar member
@@ -121,7 +123,6 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
m_aAsyncLayoutTimer.SetPriority( TaskPriority::HIGH_IDLE );
m_aAsyncLayoutTimer.SetTimeout( 50 );
m_aAsyncLayoutTimer.SetInvokeHandler( LINK( this, LayoutManager, AsyncLayoutHdl ) );
- m_aAsyncLayoutTimer.SetDebugName( "framework::LayoutManager m_aAsyncLayoutTimer" );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, cppu::UnoType<decltype(m_bAutomaticToolbars)>::get() );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, cppu::UnoType<decltype(m_bHideCurrentUI)>::get() );
@@ -129,6 +130,7 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloseButton, cppu::UnoType<decltype(m_bMenuBarCloseButton)>::get() );
registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE, LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE, beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, cppu::UnoType<decltype(m_bPreserveContentSize)>::get() );
+ registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHTOOLTIP, LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP, beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
}
LayoutManager::~LayoutManager()
@@ -152,7 +154,7 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
if (m_bInplaceMenuSet || m_xMenuBar.is())
return;
- m_xMenuBar = implts_createElement( rMenuBarName );
+ m_xMenuBar.set( static_cast< MenuBarWrapper* >(implts_createElement( rMenuBarName ).get()) );
if ( !m_xMenuBar.is() )
return;
@@ -162,25 +164,21 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
Reference< awt::XMenuBar > xMenuBar;
- Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
- if ( xPropSet.is() )
+ try
+ {
+ m_xMenuBar->getPropertyValue("XMenuBar") >>= xMenuBar;
+ }
+ catch (const beans::UnknownPropertyException&)
+ {
+ }
+ catch (const lang::WrappedTargetException&)
{
- try
- {
- xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
- }
- catch (const beans::UnknownPropertyException&)
- {
- }
- catch (const lang::WrappedTargetException&)
- {
- }
}
if ( !xMenuBar.is() )
return;
- VCLXMenu* pAwtMenuBar = comphelper::getUnoTunnelImplementation<VCLXMenu>( xMenuBar );
+ VCLXMenu* pAwtMenuBar = dynamic_cast<VCLXMenu*>( xMenuBar.get() );
if ( pAwtMenuBar )
{
MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
@@ -213,12 +211,11 @@ void LayoutManager::impl_clearUpMenuBar()
{
Reference< awt::XMenuBar > xMenuBar;
- Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
- if ( xPropSet.is() )
+ if ( m_xMenuBar.is() )
{
try
{
- xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
+ m_xMenuBar->getPropertyValue("XMenuBar") >>= xMenuBar;
}
catch (const beans::UnknownPropertyException&)
{
@@ -228,7 +225,7 @@ void LayoutManager::impl_clearUpMenuBar()
}
}
- VCLXMenu* pAwtMenuBar = comphelper::getUnoTunnelImplementation<VCLXMenu>( xMenuBar );
+ VCLXMenu* pAwtMenuBar = dynamic_cast<VCLXMenu*>( xMenuBar.get() );
if ( pAwtMenuBar )
pSetMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
}
@@ -250,10 +247,11 @@ void LayoutManager::impl_clearUpMenuBar()
pMenuBar.disposeAndClear();
m_bInplaceMenuSet = false;
- Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY );
- if ( xComp.is() )
- xComp->dispose();
- m_xMenuBar.clear();
+ if ( m_xMenuBar.is() )
+ {
+ m_xMenuBar->dispose();
+ m_xMenuBar.clear();
+ }
implts_unlock();
}
@@ -312,7 +310,7 @@ void LayoutManager::implts_reset( bool bAttached )
try
{
// Remove listener to old module ui configuration manager
- xModuleCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xModuleCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -324,7 +322,7 @@ void LayoutManager::implts_reset( bool bAttached )
// Add listener to new module ui configuration manager
xModuleCfgMgr.set( xModuleCfgSupplier->getUIConfigurationManager( aModuleIdentifier ), UNO_QUERY );
if ( xModuleCfgMgr.is() )
- xModuleCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xModuleCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -355,7 +353,7 @@ void LayoutManager::implts_reset( bool bAttached )
try
{
// Remove listener to old ui configuration manager
- xDocCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xDocCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -366,7 +364,7 @@ void LayoutManager::implts_reset( bool bAttached )
{
xDocCfgMgr.set( xUIConfigurationManagerSupplier->getUIConfigurationManager(), UNO_QUERY );
if ( xDocCfgMgr.is() )
- xDocCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ xDocCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -382,7 +380,7 @@ void LayoutManager::implts_reset( bool bAttached )
try
{
xModuleCfgMgr->removeConfigurationListener(
- Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -394,7 +392,7 @@ void LayoutManager::implts_reset( bool bAttached )
try
{
xDocCfgMgr->removeConfigurationListener(
- Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -429,7 +427,7 @@ void LayoutManager::implts_reset( bool bAttached )
if ( bAttached )
{
xToolbarManager->attach( xFrame, xModCfgMgr, xDokCfgMgr, xPersistentWindowState );
- uno::Reference< awt::XWindowPeer > xParent( xContainerWindow, UNO_QUERY );
+ uno::Reference< awt::XVclWindowPeer > xParent( xContainerWindow, UNO_QUERY );
xToolbarManager->setParentWindow( xParent );
if ( bAutomaticToolbars )
xToolbarManager->createStaticToolbars();
@@ -482,7 +480,7 @@ void LayoutManager::implts_toggleFloatingUIElementsVisibility( bool bActive )
pToolbarManager->setFloatingToolbarsVisibility( bActive );
}
-uno::Reference< ui::XUIElement > LayoutManager::implts_findElement( const OUString& aName )
+uno::Reference< ui::XUIElement > LayoutManager::implts_findElement( std::u16string_view aName )
{
OUString aElementType;
OUString aElementName;
@@ -513,130 +511,130 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem
std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
const Reference< XComponentContext > &rComponentContext )
{
- if ( rPersistentWindowState.is() )
- {
- bool bGetSettingsState( false );
+ if ( !rPersistentWindowState.is() )
+ return false;
- SolarMutexClearableGuard aWriteLock;
- bool bGlobalSettings( bInGlobalSettings );
- if ( rGlobalSettings == nullptr )
- {
- rGlobalSettings.reset( new GlobalSettings( rComponentContext ) );
- bGetSettingsState = true;
- }
- GlobalSettings* pGlobalSettings = rGlobalSettings.get();
- aWriteLock.clear();
+ bool bGetSettingsState( false );
- try
+ SolarMutexClearableGuard aWriteLock;
+ bool bGlobalSettings( bInGlobalSettings );
+ if ( rGlobalSettings == nullptr )
+ {
+ rGlobalSettings.reset( new GlobalSettings( rComponentContext ) );
+ bGetSettingsState = true;
+ }
+ GlobalSettings* pGlobalSettings = rGlobalSettings.get();
+ aWriteLock.clear();
+
+ try
+ {
+ Sequence< PropertyValue > aWindowState;
+ if ( rPersistentWindowState->hasByName( aName ) && (rPersistentWindowState->getByName( aName ) >>= aWindowState) )
{
- Sequence< PropertyValue > aWindowState;
- if ( rPersistentWindowState->hasByName( aName ) && (rPersistentWindowState->getByName( aName ) >>= aWindowState) )
+ bool bValue( false );
+ for (PropertyValue const& rProp : aWindowState)
{
- bool bValue( false );
- for ( PropertyValue const & rProp : std::as_const(aWindowState) )
+ if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKED )
{
- if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKED )
- {
- if ( rProp.Value >>= bValue )
- rElementData.m_bFloating = !bValue;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_VISIBLE )
- {
- if ( rProp.Value >>= bValue )
- rElementData.m_bVisible = bValue;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA )
- {
- ui::DockingArea eDockingArea;
- if ( rProp.Value >>= eDockingArea )
- rElementData.m_aDockedData.m_nDockedArea = eDockingArea;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKPOS )
- {
- awt::Point aPoint;
- if (rProp.Value >>= aPoint)
- {
- //tdf#90256 repair these broken Docking positions
- if (aPoint.X < 0)
- aPoint.X = SAL_MAX_INT32;
- if (aPoint.Y < 0)
- aPoint.Y = SAL_MAX_INT32;
- rElementData.m_aDockedData.m_aPos = aPoint;
- }
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_POS )
- {
- awt::Point aPoint;
- if ( rProp.Value >>= aPoint )
- rElementData.m_aFloatingData.m_aPos = aPoint;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_SIZE )
- {
- awt::Size aSize;
- if ( rProp.Value >>= aSize )
- rElementData.m_aFloatingData.m_aSize = aSize;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_UINAME )
- rProp.Value >>= rElementData.m_aUIName;
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_STYLE )
- {
- sal_Int32 nStyle = 0;
- if ( rProp.Value >>= nStyle )
- rElementData.m_nStyle = static_cast<ButtonType>( nStyle );
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_LOCKED )
- {
- if ( rProp.Value >>= bValue )
- rElementData.m_aDockedData.m_bLocked = bValue;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_CONTEXT )
- {
- if ( rProp.Value >>= bValue )
- rElementData.m_bContextSensitive = bValue;
- }
- else if ( rProp.Name == WINDOWSTATE_PROPERTY_NOCLOSE )
+ if ( rProp.Value >>= bValue )
+ rElementData.m_bFloating = !bValue;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_VISIBLE )
+ {
+ if ( rProp.Value >>= bValue )
+ rElementData.m_bVisible = bValue;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA )
+ {
+ ui::DockingArea eDockingArea;
+ if ( rProp.Value >>= eDockingArea )
+ rElementData.m_aDockedData.m_nDockedArea = eDockingArea;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKPOS )
+ {
+ awt::Point aPoint;
+ if (rProp.Value >>= aPoint)
{
- if ( rProp.Value >>= bValue )
- rElementData.m_bNoClose = bValue;
+ //tdf#90256 repair these broken Docking positions
+ if (aPoint.X < 0)
+ aPoint.X = SAL_MAX_INT32;
+ if (aPoint.Y < 0)
+ aPoint.Y = SAL_MAX_INT32;
+ rElementData.m_aDockedData.m_aPos = aPoint;
}
}
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_POS )
+ {
+ awt::Point aPoint;
+ if ( rProp.Value >>= aPoint )
+ rElementData.m_aFloatingData.m_aPos = aPoint;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_SIZE )
+ {
+ awt::Size aSize;
+ if ( rProp.Value >>= aSize )
+ rElementData.m_aFloatingData.m_aSize = aSize;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_UINAME )
+ rProp.Value >>= rElementData.m_aUIName;
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_STYLE )
+ {
+ sal_Int32 nStyle = 0;
+ if ( rProp.Value >>= nStyle )
+ rElementData.m_nStyle = static_cast<ButtonType>( nStyle );
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_LOCKED )
+ {
+ if ( rProp.Value >>= bValue )
+ rElementData.m_aDockedData.m_bLocked = bValue;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_CONTEXT )
+ {
+ if ( rProp.Value >>= bValue )
+ rElementData.m_bContextSensitive = bValue;
+ }
+ else if ( rProp.Name == WINDOWSTATE_PROPERTY_NOCLOSE )
+ {
+ if ( rProp.Value >>= bValue )
+ rElementData.m_bNoClose = bValue;
+ }
}
+ }
- // oversteer values with global settings
- if (bGetSettingsState || bGlobalSettings)
+ // oversteer values with global settings
+ if (bGetSettingsState || bGlobalSettings)
+ {
+ if ( pGlobalSettings->HasToolbarStatesInfo())
{
- if ( pGlobalSettings->HasToolbarStatesInfo())
{
- {
- SolarMutexGuard aWriteLock2;
- bInGlobalSettings = true;
- }
+ SolarMutexGuard aWriteLock2;
+ bInGlobalSettings = true;
+ }
- uno::Any aValue;
- if ( pGlobalSettings->GetToolbarStateInfo(
- GlobalSettings::STATEINFO_LOCKED,
- aValue ))
- aValue >>= rElementData.m_aDockedData.m_bLocked;
- if ( pGlobalSettings->GetToolbarStateInfo(
- GlobalSettings::STATEINFO_DOCKED,
- aValue ))
- {
- bool bValue;
- if ( aValue >>= bValue )
- rElementData.m_bFloating = !bValue;
- }
+ uno::Any aValue;
+ if ( pGlobalSettings->GetToolbarStateInfo(
+ GlobalSettings::STATEINFO_LOCKED,
+ aValue ))
+ aValue >>= rElementData.m_aDockedData.m_bLocked;
+ if ( pGlobalSettings->GetToolbarStateInfo(
+ GlobalSettings::STATEINFO_DOCKED,
+ aValue ))
+ {
+ bool bValue;
+ if ( aValue >>= bValue )
+ rElementData.m_bFloating = !bValue;
}
}
+ }
- const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
- if (bDockingSupportCrippled)
- rElementData.m_bFloating = false;
+ const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
+ if (bDockingSupportCrippled)
+ rElementData.m_bFloating = false;
- return true;
- }
- catch (const NoSuchElementException&)
- {
- }
+ return true;
+ }
+ catch (const NoSuchElementException&)
+ {
}
return false;
@@ -673,38 +671,31 @@ void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UI
try
{
- Sequence< PropertyValue > aWindowState( 8 );
-
- aWindowState[0].Name = WINDOWSTATE_PROPERTY_DOCKED;
- aWindowState[0].Value <<= !rElementData.m_bFloating;
- aWindowState[1].Name = WINDOWSTATE_PROPERTY_VISIBLE;
- aWindowState[1].Value <<= rElementData.m_bVisible;
-
- aWindowState[2].Name = WINDOWSTATE_PROPERTY_DOCKINGAREA;
- aWindowState[2].Value <<= rElementData.m_aDockedData.m_nDockedArea;
-
- aWindowState[3].Name = WINDOWSTATE_PROPERTY_DOCKPOS;
- aWindowState[3].Value <<= rElementData.m_aDockedData.m_aPos;
-
- aWindowState[4].Name = WINDOWSTATE_PROPERTY_POS;
- aWindowState[4].Value <<= rElementData.m_aFloatingData.m_aPos;
-
- aWindowState[5].Name = WINDOWSTATE_PROPERTY_SIZE;
- aWindowState[5].Value <<= rElementData.m_aFloatingData.m_aSize;
- aWindowState[6].Name = WINDOWSTATE_PROPERTY_UINAME;
- aWindowState[6].Value <<= rElementData.m_aUIName;
- aWindowState[7].Name = WINDOWSTATE_PROPERTY_LOCKED;
- aWindowState[7].Value <<= rElementData.m_aDockedData.m_bLocked;
+ Sequence< PropertyValue > aWindowState{
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKED, !rElementData.m_bFloating),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_VISIBLE, rElementData.m_bVisible),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKINGAREA,
+ rElementData.m_aDockedData.m_nDockedArea),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKPOS,
+ rElementData.m_aDockedData.m_aPos),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_POS,
+ rElementData.m_aFloatingData.m_aPos),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_SIZE,
+ rElementData.m_aFloatingData.m_aSize),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_UINAME, rElementData.m_aUIName),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_LOCKED,
+ rElementData.m_aDockedData.m_bLocked)
+ };
if ( xPersistentWindowState->hasByName( aName ))
{
Reference< XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
- xReplace->replaceByName( aName, makeAny( aWindowState ));
+ xReplace->replaceByName( aName, Any( aWindowState ));
}
else
{
Reference< XNameContainer > xInsert( xPersistentWindowState, uno::UNO_QUERY );
- xInsert->insertByName( aName, makeAny( aWindowState ));
+ xInsert->insertByName( aName, Any( aWindowState ));
}
}
catch (const Exception&)
@@ -719,7 +710,7 @@ void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UI
// Retrieve output size from container Window
SolarMutexGuard aGuard;
- pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ).get();
+ pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
if ( pContainerWindow )
aContainerWinSize = pContainerWindow->GetOutputSizePixel();
@@ -731,11 +722,8 @@ Reference< XUIElement > LayoutManager::implts_createElement( const OUString& aNa
Reference< ui::XUIElement > xUIElement;
SolarMutexGuard g;
- Sequence< PropertyValue > aPropSeq( 2 );
- aPropSeq[0].Name = "Frame";
- aPropSeq[0].Value <<= m_xFrame;
- aPropSeq[1].Name = "Persistent";
- aPropSeq[1].Value <<= true;
+ Sequence< PropertyValue > aPropSeq{ comphelper::makePropertyValue("Frame", m_xFrame),
+ comphelper::makePropertyValue("Persistent", true) };
try
{
@@ -771,7 +759,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible )
implts_notifyListeners( frame::LayoutManagerEvents::INVISIBLE, a );
SolarMutexResettableGuard aWriteLock;
- Reference< XUIElement > xMenuBar = m_xMenuBar;
+ rtl::Reference< MenuBarWrapper > xMenuBar = m_xMenuBar;
Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
rtl::Reference< MenuBarManager > xInplaceMenuBar( m_xInplaceMenuBar );
aWriteLock.clear();
@@ -785,8 +773,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible )
pMenuBar = static_cast<MenuBar *>(xInplaceMenuBar->GetMenuBar());
else
{
- MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >(xMenuBar.get());
- pMenuBar = static_cast<MenuBar *>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar());
+ pMenuBar = static_cast<MenuBar *>(xMenuBar->GetMenuBarManager()->GetMenuBar());
}
SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
@@ -881,7 +868,7 @@ void LayoutManager::implts_createProgressBar()
{
Reference< XUIElement > xStatusBar;
Reference< XUIElement > xProgressBar;
- Reference< XUIElement > xProgressBarBackup;
+ rtl::Reference< ProgressBarWrapper > xProgressBarBackup;
Reference< awt::XWindow > xContainerWindow;
SolarMutexResettableGuard aWriteLock;
@@ -892,10 +879,10 @@ void LayoutManager::implts_createProgressBar()
xContainerWindow = m_xContainerWindow;
aWriteLock.clear();
- bool bRecycled = xProgressBarBackup.is();
- ProgressBarWrapper* pWrapper = nullptr;
+ bool bRecycled = xProgressBarBackup.is();
+ rtl::Reference<ProgressBarWrapper> pWrapper;
if ( bRecycled )
- pWrapper = static_cast<ProgressBarWrapper*>(xProgressBarBackup.get());
+ pWrapper = xProgressBarBackup.get();
else if ( xProgressBar.is() )
pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
else
@@ -926,7 +913,7 @@ void LayoutManager::implts_createProgressBar()
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
aWriteLock.reset();
- m_aProgressBarElement.m_xUIElement.set( static_cast< cppu::OWeakObject* >( pWrapper ), UNO_QUERY );
+ m_aProgressBarElement.m_xUIElement = pWrapper;
aWriteLock.clear();
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
@@ -944,17 +931,13 @@ void LayoutManager::implts_backupProgressBarWrapper()
// safe a backup copy of the current progress!
// This copy will be used automatically inside createProgressBar() which is called
// implicitly from implts_doLayout() .-)
- m_xProgressBarBackup = m_aProgressBarElement.m_xUIElement;
+ m_xProgressBarBackup = static_cast<ProgressBarWrapper*>(m_aProgressBarElement.m_xUIElement.get());
// remove the relation between this old progress bar and our old status bar.
// Otherwise we work on disposed items ...
// The internal used ProgressBarWrapper can handle a NULL reference.
if ( m_xProgressBarBackup.is() )
- {
- ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(m_xProgressBarBackup.get());
- if ( pWrapper )
- pWrapper->setStatusBar( Reference< awt::XWindow >() );
- }
+ m_xProgressBarBackup->setStatusBar( Reference< awt::XWindow >() );
// prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset()
m_aProgressBarElement.m_xUIElement.clear();
@@ -1141,12 +1124,8 @@ bool LayoutManager::implts_hideStatusBar( bool bStoreState )
void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset )
{
- ::tools::Rectangle aOffsetRect;
- setZeroRectangle( aOffsetRect );
- aOffsetRect.setHeight( nBottomOffset );
-
if ( m_xToolbarManager.is() )
- m_xToolbarManager->setDockingAreaOffsets( aOffsetRect );
+ m_xToolbarManager->setDockingAreaOffsets({ 0, 0, 0, nBottomOffset });
}
void LayoutManager::implts_setInplaceMenuBar( const Reference< XIndexAccess >& xMergedMenuBar )
@@ -1200,12 +1179,11 @@ void LayoutManager::implts_resetInplaceMenuBar()
if ( m_xContainerWindow.is() )
{
SolarMutexGuard aGuard;
- MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >(m_xMenuBar.get());
SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
if ( pSysWindow )
{
- if ( pMenuBarWrapper )
- pSysWindow->SetMenuBar(static_cast<MenuBar *>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar()));
+ if ( m_xMenuBar )
+ pSysWindow->SetMenuBar(static_cast<MenuBar *>(m_xMenuBar->GetMenuBarManager()->GetMenuBar()));
else
pSysWindow->SetMenuBar(nullptr);
}
@@ -1286,7 +1264,7 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
{
Reference< awt::XWindow > xWindow( m_xDockingAreaAcceptor->getContainerWindow() );
if ( xWindow.is() && ( m_xFrame->getContainerWindow() != m_xContainerWindow || !xDockingAreaAcceptor.is() ) )
- xWindow->removeWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY ));
+ xWindow->removeWindowListener( Reference< awt::XWindowListener >(this) );
m_aDockingArea = awt::Rectangle();
if ( pToolbarManager )
@@ -1303,11 +1281,11 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
m_aDockingArea = awt::Rectangle();
m_xContainerWindow = m_xDockingAreaAcceptor->getContainerWindow();
m_xContainerTopWindow.set( m_xContainerWindow, UNO_QUERY );
- m_xContainerWindow->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xContainerWindow->addWindowListener( Reference< awt::XWindowListener >(this) );
// we always must keep a connection to the window of our frame for resize events
if ( m_xContainerWindow != m_xFrame->getContainerWindow() )
- m_xFrame->getContainerWindow()->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xFrame->getContainerWindow()->addWindowListener( Reference< awt::XWindowListener >(this) );
// #i37884# set initial visibility state - in the plugin case the container window is already shown
// and we get no notification anymore
@@ -1385,7 +1363,7 @@ void LayoutManager::implts_reparentChildWindows()
aWriteLock.reset();
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
if ( pToolbarManager )
- pToolbarManager->setParentWindow( uno::Reference< awt::XWindowPeer >( xContainerWindow, uno::UNO_QUERY ));
+ pToolbarManager->setParentWindow( uno::Reference< awt::XVclWindowPeer >( xContainerWindow, uno::UNO_QUERY ));
aWriteLock.clear();
}
@@ -1494,7 +1472,7 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName )
if ( bNotify )
{
// UI element is invisible - provide information to listeners
- implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
+ implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::Any( aName ) );
}
}
@@ -1564,7 +1542,7 @@ void SAL_CALL LayoutManager::destroyElement( const OUString& aName )
doLayout();
if ( bNotify )
- implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
+ implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::Any( aName ) );
}
sal_Bool SAL_CALL LayoutManager::requestElement( const OUString& rResourceURL )
@@ -1626,8 +1604,8 @@ sal_Bool SAL_CALL LayoutManager::requestElement( const OUString& rResourceURL )
if ( pToolbarManager && bComponentAttached )
{
- bNotify = pToolbarManager->requestToolbar( rResourceURL );
- }
+ bNotify = pToolbarManager->requestToolbar( rResourceURL );
+ }
}
else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
{
@@ -1638,7 +1616,7 @@ sal_Bool SAL_CALL LayoutManager::requestElement( const OUString& rResourceURL )
}
if ( bNotify )
- implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( rResourceURL ) );
+ implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::Any( rResourceURL ) );
return bResult;
}
@@ -1662,7 +1640,7 @@ Reference< XUIElement > SAL_CALL LayoutManager::getElement( const OUString& aNam
Sequence< Reference< ui::XUIElement > > SAL_CALL LayoutManager::getElements()
{
SolarMutexClearableGuard aReadLock;
- uno::Reference< ui::XUIElement > xMenuBar( m_xMenuBar );
+ rtl::Reference< MenuBarWrapper > xMenuBar( m_xMenuBar );
uno::Reference< ui::XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement );
ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
aReadLock.clear();
@@ -1686,10 +1664,11 @@ Sequence< Reference< ui::XUIElement > > SAL_CALL LayoutManager::getElements()
}
aSeq.realloc(nSize);
+ auto pSeq = aSeq.getArray();
if ( nMenuBarIndex >= 0 )
- aSeq[nMenuBarIndex] = xMenuBar;
+ pSeq[nMenuBarIndex] = xMenuBar;
if ( nStatusBarIndex >= 0 )
- aSeq[nStatusBarIndex] = xStatusBar;
+ pSeq[nStatusBarIndex] = xStatusBar;
return aSeq;
}
@@ -1765,7 +1744,7 @@ sal_Bool SAL_CALL LayoutManager::showElement( const OUString& aName )
doLayout();
if ( bNotify )
- implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
+ implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::Any( aName ) );
return bResult;
}
@@ -1847,7 +1826,7 @@ sal_Bool SAL_CALL LayoutManager::hideElement( const OUString& aName )
doLayout();
if ( bNotify )
- implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
+ implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::Any( aName ) );
return false;
}
@@ -1893,7 +1872,7 @@ sal_Bool SAL_CALL LayoutManager::dockAllWindows( ::sal_Int16 /*nElementType*/ )
sal_Bool SAL_CALL LayoutManager::floatWindow( const OUString& aName )
{
bool bResult( false );
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -1912,7 +1891,7 @@ sal_Bool SAL_CALL LayoutManager::floatWindow( const OUString& aName )
sal_Bool SAL_CALL LayoutManager::lockWindow( const OUString& aName )
{
bool bResult( false );
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -1931,7 +1910,7 @@ sal_Bool SAL_CALL LayoutManager::lockWindow( const OUString& aName )
sal_Bool SAL_CALL LayoutManager::unlockWindow( const OUString& aName )
{
bool bResult( false );
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -1949,7 +1928,7 @@ sal_Bool SAL_CALL LayoutManager::unlockWindow( const OUString& aName )
void SAL_CALL LayoutManager::setElementSize( const OUString& aName, const awt::Size& aSize )
{
- if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( !o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
return;
SolarMutexClearableGuard aReadLock;
@@ -1966,7 +1945,7 @@ void SAL_CALL LayoutManager::setElementSize( const OUString& aName, const awt::S
void SAL_CALL LayoutManager::setElementPos( const OUString& aName, const awt::Point& aPos )
{
- if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( !o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
return;
SolarMutexClearableGuard aReadLock;
@@ -1983,7 +1962,7 @@ void SAL_CALL LayoutManager::setElementPos( const OUString& aName, const awt::Po
void SAL_CALL LayoutManager::setElementPosSize( const OUString& aName, const awt::Point& aPos, const awt::Size& aSize )
{
- if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( !o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
return;
SolarMutexClearableGuard aReadLock;
@@ -2074,7 +2053,7 @@ sal_Bool SAL_CALL LayoutManager::isElementVisible( const OUString& aName )
sal_Bool SAL_CALL LayoutManager::isElementFloating( const OUString& aName )
{
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -2089,7 +2068,7 @@ sal_Bool SAL_CALL LayoutManager::isElementFloating( const OUString& aName )
sal_Bool SAL_CALL LayoutManager::isElementDocked( const OUString& aName )
{
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -2104,7 +2083,7 @@ sal_Bool SAL_CALL LayoutManager::isElementDocked( const OUString& aName )
sal_Bool SAL_CALL LayoutManager::isElementLocked( const OUString& aName )
{
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -2119,7 +2098,7 @@ sal_Bool SAL_CALL LayoutManager::isElementLocked( const OUString& aName )
awt::Size SAL_CALL LayoutManager::getElementSize( const OUString& aName )
{
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -2134,7 +2113,7 @@ awt::Size SAL_CALL LayoutManager::getElementSize( const OUString& aName )
awt::Point SAL_CALL LayoutManager::getElementPos( const OUString& aName )
{
- if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ))
+ if ( o3tl::equalsIgnoreAsciiCase(getElementTypeFromResourceURL( aName ), UIRESOURCETYPE_TOOLBAR ))
{
SolarMutexClearableGuard aReadLock;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
@@ -2338,7 +2317,7 @@ bool LayoutManager::implts_resizeContainerWindow( const awt::Size& rContainerSiz
// calculate the maximum size we have for the container window
sal_Int32 nDisplay = xContainerTopWindow->getDisplay();
- tools::Rectangle aWorkArea = Application::GetScreenPosSizePixel( nDisplay );
+ AbsoluteScreenPixelRectangle aWorkArea = Application::GetScreenPosSizePixel( nDisplay );
if (!aWorkArea.IsEmpty())
{
@@ -2476,12 +2455,8 @@ bool LayoutManager::implts_resetMenuBar()
MenuBar* pSetMenuBar = nullptr;
if ( m_xInplaceMenuBar.is() )
pSetMenuBar = static_cast<MenuBar *>(m_xInplaceMenuBar->GetMenuBar());
- else
- {
- MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >( m_xMenuBar.get() );
- if ( pMenuBarWrapper )
- pSetMenuBar = static_cast<MenuBar*>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar());
- }
+ else if ( m_xMenuBar )
+ pSetMenuBar = static_cast<MenuBar*>(m_xMenuBar->GetMenuBarManager()->GetMenuBar());
SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
if ( pSysWindow && bMenuVisible && pSetMenuBar )
@@ -2499,9 +2474,8 @@ void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
SolarMutexGuard aWriteLock;
// Find Form menu in the original menubar
- m_xMenuBar = implts_createElement( aName );
- uno::Reference< XUIElementSettings > xMenuBarSettings(m_xMenuBar, UNO_QUERY);
- uno::Reference< container::XIndexReplace > xMenuIndex(xMenuBarSettings->getSettings(true), UNO_QUERY);
+ m_xMenuBar.set( static_cast< MenuBarWrapper* >(implts_createElement( aName ).get()) );
+ uno::Reference< container::XIndexReplace > xMenuIndex(m_xMenuBar->getSettings(true), UNO_QUERY);
sal_Int32 nFormsMenu = -1;
for (sal_Int32 nIndex = 0; nIndex < xMenuIndex->getCount(); ++nIndex)
@@ -2509,7 +2483,7 @@ void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
uno::Sequence< beans::PropertyValue > aProps;
xMenuIndex->getByIndex( nIndex ) >>= aProps;
OUString aCommand;
- for ( beans::PropertyValue const & rProp : std::as_const(aProps) )
+ for (beans::PropertyValue const& rProp : aProps)
{
if (rProp.Name == "CommandURL")
{
@@ -2535,7 +2509,7 @@ void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
assert(xFormsMenuIndex->getCount() >= 1);
uno::Sequence< beans::PropertyValue > aNewFormsMenu;
xFormsMenuIndex->getByIndex( 0 ) >>= aNewFormsMenu;
- xMenuIndex->replaceByIndex(nFormsMenu, uno::makeAny(aNewFormsMenu));
+ xMenuIndex->replaceByIndex(nFormsMenu, uno::Any(aNewFormsMenu));
setMergedMenuBar( xMenuIndex );
@@ -2580,12 +2554,12 @@ void SAL_CALL LayoutManager::removeLayoutManagerEventListener( const uno::Refere
void LayoutManager::implts_notifyListeners(short nEvent, const uno::Any& rInfoParam)
{
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>(this) );
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<frame::XLayoutManagerListener>::get());
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<frame::XLayoutManagerListener>::get());
if (pContainer==nullptr)
return;
- ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>(this) );
+ comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
while (pIterator.hasMoreElements())
{
try
@@ -2767,8 +2741,7 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
try
{
Reference<XUIConfiguration> xModuleCfgMgr(m_xModuleCfgMgr, UNO_QUERY);
- xModuleCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(
- static_cast<OWeakObject*>(this), UNO_QUERY));
+ xModuleCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(this));
}
catch (const Exception&)
{
@@ -2780,8 +2753,7 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
try
{
Reference<XUIConfiguration> xDocCfgMgr(m_xDocCfgMgr, UNO_QUERY);
- xDocCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(
- static_cast<OWeakObject*>(this), UNO_QUERY));
+ xDocCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(this));
}
catch (const Exception&)
{
@@ -2801,7 +2773,7 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
if (pToolbarManager)
{
- uno::Reference<awt::XWindowPeer> aEmptyWindowPeer;
+ uno::Reference<awt::XVclWindowPeer> aEmptyWindowPeer;
pToolbarManager->setParentWindow(aEmptyWindowPeer);
}
impl_clearUpMenuBar();
@@ -2828,7 +2800,7 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
if ( bDisposeAndClear )
{
// Send message to all listener and forget her references.
- uno::Reference< frame::XLayoutManager > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY );
+ uno::Reference< frame::XLayoutManager > xThis(this);
lang::EventObject aEvent( xThis );
m_aListenerContainer.disposeAndClear( aEvent );
}
@@ -2867,7 +2839,7 @@ void SAL_CALL LayoutManager::elementInserted( const ui::ConfigurationEvent& Even
if ( xPropSet.is() )
{
if ( Event.Source == uno::Reference< uno::XInterface >( m_xDocCfgMgr, uno::UNO_QUERY ))
- xPropSet->setPropertyValue( "ConfigurationSource", makeAny( m_xDocCfgMgr ));
+ xPropSet->setPropertyValue( "ConfigurationSource", Any( m_xDocCfgMgr ));
}
xElementSettings->updateSettings();
}
@@ -2883,7 +2855,7 @@ void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event
Reference< frame::XFrame > xFrame( m_xFrame );
rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager );
Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
- Reference< ui::XUIElement > xMenuBar( m_xMenuBar );
+ rtl::Reference< MenuBarWrapper > xMenuBar( m_xMenuBar );
Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
aReadLock.clear();
@@ -2930,7 +2902,7 @@ void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event
// document settings removed
if ( xModuleCfgMgr->hasSettings( Event.ResourceURL ))
{
- xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xModuleCfgMgr ));
+ xPropSet->setPropertyValue( aConfigSourcePropName, Any( m_xModuleCfgMgr ));
xElementSettings->updateSettings();
return;
}
@@ -2949,9 +2921,8 @@ void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event
if ( pSysWindow && !m_bInplaceMenuSet )
pSysWindow->SetMenuBar( nullptr );
- Reference< XComponent > xComp( xMenuBar, UNO_QUERY );
- if ( xComp.is() )
- xComp->dispose();
+ if ( xMenuBar.is() )
+ xMenuBar->dispose();
SolarMutexGuard g;
m_xMenuBar.clear();
@@ -3015,7 +2986,7 @@ void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Even
void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
const uno::Any& aValue )
{
- if ( nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY )
+ if ( (nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY) && (nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP) )
LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue );
switch( nHandle )
@@ -3043,6 +3014,12 @@ void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 n
case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI:
implts_setCurrentUIVisibility( !m_bHideCurrentUI );
break;
+
+ case LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP:
+ if (m_xToolbarManager.is())
+ m_xToolbarManager->updateToolbarsTips();
+ break;
+
default: break;
}
}
@@ -3066,18 +3043,11 @@ namespace detail
::cppu::OPropertyArrayHelper& getHelper() { return *m_pInfoHelper; }
};
}
-namespace
-{
- struct theInfoHelper :
- public rtl::StaticWithArg< detail::InfoHelperBuilder, LayoutManager,
- theInfoHelper >
- {
- };
-}
::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper()
{
- return theInfoHelper::get(*this).getHelper();
+ static detail::InfoHelperBuilder INFO(*this);
+ return INFO.getHelper();
}
uno::Reference< beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo()
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 154374ee0d56..46bbe90fc17d 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -33,10 +33,13 @@
#include <com/sun/star/ui/XUIElementSettings.hpp>
#include <com/sun/star/ui/XUIFunctionListener.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/queryinterface.hxx>
+#include <o3tl/string_view.hxx>
#include <unotools/cmdoptions.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/helper/convert.hxx>
+#include <utility>
#include <vcl/i18nhelp.hxx>
#include <vcl/dockingarea.hxx>
#include <vcl/settings.hxx>
@@ -51,12 +54,14 @@ namespace framework
{
ToolbarLayoutManager::ToolbarLayoutManager(
- const uno::Reference< uno::XComponentContext >& rxContext,
- const uno::Reference< ui::XUIElementFactory >& xUIElementFactory,
+ uno::Reference< uno::XComponentContext > xContext,
+ uno::Reference< ui::XUIElementFactory > xUIElementFactory,
LayoutManager* pParentLayouter ):
- m_xContext( rxContext),
- m_xUIElementFactoryManager( xUIElementFactory ),
+ m_xContext(std::move( xContext)),
+ m_xUIElementFactoryManager(std::move( xUIElementFactory )),
m_pParentLayouter( pParentLayouter ),
+ m_aDockingArea(0, 0, 0, 0),
+ m_aDockingAreaOffsets(0, 0, 0, 0),
m_eDockOperation( DOCKOP_ON_COLROW ),
m_ePreviewDetection( PREVIEWFRAME_UNKNOWN ),
m_bComponentAttached( false ),
@@ -66,9 +71,6 @@ ToolbarLayoutManager::ToolbarLayoutManager(
m_bLayoutInProgress( false ),
m_bToolbarCreation( false )
{
- // initialize rectangles to zero values
- setZeroRectangle( m_aDockingAreaOffsets );
- setZeroRectangle( m_aDockingArea );
}
ToolbarLayoutManager::~ToolbarLayoutManager()
@@ -79,12 +81,12 @@ ToolbarLayoutManager::~ToolbarLayoutManager()
// XInterface
-void SAL_CALL ToolbarLayoutManager::acquire() throw()
+void SAL_CALL ToolbarLayoutManager::acquire() noexcept
{
OWeakObject::acquire();
}
-void SAL_CALL ToolbarLayoutManager::release() throw()
+void SAL_CALL ToolbarLayoutManager::release() noexcept
{
OWeakObject::release();
}
@@ -450,11 +452,10 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
{
uno::Reference< ui::XUIElement > xUIElement;
- uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
- aPropSeq[0].Name = "Frame";
- aPropSeq[0].Value <<= xFrame;
- aPropSeq[1].Name = "Persistent";
- aPropSeq[1].Value <<= true;
+ uno::Sequence< beans::PropertyValue > aPropSeq{
+ comphelper::makePropertyValue("Frame", xFrame),
+ comphelper::makePropertyValue("Persistent", true)
+ };
uno::Reference<ui::XUIElementFactory> xUIElementFactory;
{
SolarMutexGuard aReadLock;
@@ -483,10 +484,8 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
{
try
{
- xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
- xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(this) );
+ xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(this) );
xDockWindow->enableDocking( true );
}
catch (const uno::Exception&)
@@ -544,7 +543,7 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
{
ToolBox* pToolbar = static_cast<ToolBox *>(pWindow.get());
ToolBoxMenuType nMenuType = pToolbar->GetMenuType();
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "ConfigureDialog" ))
+ if ( aCmdOptions.LookupDisabled( "ConfigureDialog" ))
pToolbar->SetMenuType( nMenuType & ~ToolBoxMenuType::Customize );
else
pToolbar->SetMenuType( nMenuType | ToolBoxMenuType::Customize );
@@ -561,14 +560,14 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
return bNotify;
}
-bool ToolbarLayoutManager::destroyToolbar( const OUString& rResourceURL )
+bool ToolbarLayoutManager::destroyToolbar( std::u16string_view rResourceURL )
{
uno::Reference< lang::XComponent > xComponent;
bool bNotify( false );
bool bMustBeSorted( false );
bool bMustLayouted( false );
- bool bMustBeDestroyed( !rResourceURL.startsWith("private:resource/toolbar/addon_") );
+ bool bMustBeDestroyed( !o3tl::starts_with(rResourceURL, u"private:resource/toolbar/addon_") );
{
SolarMutexGuard aWriteLock;
@@ -597,8 +596,7 @@ bool ToolbarLayoutManager::destroyToolbar( const OUString& rResourceURL )
try
{
if ( xWindow.is() )
- xWindow->removeWindowListener( uno::Reference< awt::XWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xWindow->removeWindowListener( uno::Reference< awt::XWindowListener >(this) );
}
catch (const uno::Exception&)
{
@@ -607,8 +605,7 @@ bool ToolbarLayoutManager::destroyToolbar( const OUString& rResourceURL )
try
{
if ( xDockWindow.is() )
- xDockWindow->removeDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xDockWindow->removeDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(this) );
}
catch (const uno::Exception&)
{
@@ -799,81 +796,81 @@ bool ToolbarLayoutManager::dockToolbar( std::u16string_view rResourceURL, ui::Do
{
UIElement aUIElement = implts_findToolbar( rResourceURL );
- if ( aUIElement.m_xUIElement.is() )
+ if ( !aUIElement.m_xUIElement.is() )
+ return false;
+
+ try
{
- try
+ uno::Reference< awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
+ uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
+ if ( xDockWindow.is() )
{
- uno::Reference< awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
- uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
- if ( xDockWindow.is() )
- {
- if ( eDockingArea != ui::DockingArea_DOCKINGAREA_DEFAULT )
- aUIElement.m_aDockedData.m_nDockedArea = eDockingArea;
+ if ( eDockingArea != ui::DockingArea_DOCKINGAREA_DEFAULT )
+ aUIElement.m_aDockedData.m_nDockedArea = eDockingArea;
- if ( !isDefaultPos( aPos ))
- aUIElement.m_aDockedData.m_aPos = aPos;
+ if ( !isDefaultPos( aPos ))
+ aUIElement.m_aDockedData.m_aPos = aPos;
- if ( !xDockWindow->isFloating() )
- {
- vcl::Window* pWindow( nullptr );
- ToolBox* pToolBox( nullptr );
+ if ( !xDockWindow->isFloating() )
+ {
+ vcl::Window* pWindow( nullptr );
+ ToolBox* pToolBox( nullptr );
+ {
+ SolarMutexGuard aGuard;
+ pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
{
- SolarMutexGuard aGuard;
- pWindow = VCLUnoHelper::GetWindow( xWindow ).get();
- if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
- {
- pToolBox = static_cast<ToolBox *>(pWindow);
+ pToolBox = static_cast<ToolBox *>(pWindow);
- // We have to set the alignment of the toolbox. It's possible that the toolbox is moved from a
- // horizontal to a vertical docking area!
- pToolBox->SetAlign( ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ));
- }
+ // We have to set the alignment of the toolbox. It's possible that the toolbox is moved from a
+ // horizontal to a vertical docking area!
+ pToolBox->SetAlign( ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ));
}
+ }
- if ( hasDefaultPosValue( aUIElement.m_aDockedData.m_aPos ))
- {
- // Docking on its default position without a preset position -
- // we have to find a good place for it.
- ::Size aSize;
-
- SolarMutexGuard aGuard;
- {
- if (pToolBox)
- aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ) );
- else if (pWindow)
- aSize = pWindow->GetSizePixel();
- }
+ if ( hasDefaultPosValue( aUIElement.m_aDockedData.m_aPos ))
+ {
+ // Docking on its default position without a preset position -
+ // we have to find a good place for it.
+ ::Size aSize;
- ::Point aPixelPos;
- awt::Point aDockPos;
- implts_findNextDockingPos(aUIElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos );
- aUIElement.m_aDockedData.m_aPos = aDockPos;
+ SolarMutexGuard aGuard;
+ {
+ if (pToolBox)
+ aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ) );
+ else if (pWindow)
+ aSize = pWindow->GetSizePixel();
}
+
+ ::Point aPixelPos;
+ awt::Point aDockPos;
+ implts_findNextDockingPos(aUIElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos );
+ aUIElement.m_aDockedData.m_aPos = aDockPos;
}
+ }
- implts_setToolbar( aUIElement );
+ implts_setToolbar( aUIElement );
- if ( xDockWindow->isFloating() )
- {
- // ATTENTION: This will call toggleFloatingMode() via notifications which
- // sets the floating member of the UIElement correctly!
- xDockWindow->setFloatingMode( false );
- }
- else
- {
- implts_writeWindowStateData( aUIElement );
- implts_sortUIElements();
+ if ( xDockWindow->isFloating() )
+ {
+ // ATTENTION: This will call toggleFloatingMode() via notifications which
+ // sets the floating member of the UIElement correctly!
+ xDockWindow->setFloatingMode( false );
+ }
+ else
+ {
+ implts_writeWindowStateData( aUIElement );
+ implts_sortUIElements();
- if ( aUIElement.m_bVisible )
- implts_setLayoutDirty();
- }
- return true;
+ if ( aUIElement.m_bVisible )
+ implts_setLayoutDirty();
}
+ return true;
}
- catch (const lang::DisposedException&)
- {
- }
+ }
+ catch (const lang::DisposedException&)
+ {
}
return false;
@@ -923,8 +920,8 @@ void ToolbarLayoutManager::childWindowEvent( VclSimpleEvent const * pEvent )
if ( pToolBox )
{
aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
- sal_uInt16 nId = pToolBox->GetCurItemId();
- if ( nId > 0 )
+ ToolBoxItemId nId = pToolBox->GetCurItemId();
+ if ( nId > ToolBoxItemId(0) )
aCommand = pToolBox->GetItemCommand( nId );
}
@@ -965,7 +962,7 @@ void ToolbarLayoutManager::childWindowEvent( VclSimpleEvent const * pEvent )
{
if ( !implts_isToolbarCreationActive() )
{
- ToolBox* pToolBox = getToolboxPtr( static_cast<VclWindowEvent const *>(pEvent)->GetWindow() );
+ ToolBox* pToolBox = getToolboxPtr( pWindowEvent->GetWindow() );
if ( pToolBox )
{
OUString aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
@@ -1005,7 +1002,7 @@ void ToolbarLayoutManager::resetDockingArea()
}
void ToolbarLayoutManager::setParentWindow(
- const uno::Reference< awt::XWindowPeer >& xParentWindow )
+ const uno::Reference< awt::XVclWindowPeer >& xParentWindow )
{
static const char DOCKINGAREASTRING[] = "dockingarea";
@@ -1026,16 +1023,16 @@ void ToolbarLayoutManager::setParentWindow(
if ( xParentWindow.is() )
{
SolarMutexGuard aGuard;
- VclPtr< ::DockingAreaWindow > pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xTopDockWindow ).get() );
+ VclPtr< ::DockingAreaWindow > pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xTopDockWindow ) );
if( pWindow )
pWindow->SetAlign( WindowAlign::Top );
- pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xBottomDockWindow ).get() );
+ pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xBottomDockWindow ) );
if( pWindow )
pWindow->SetAlign( WindowAlign::Bottom );
- pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xLeftDockWindow ).get() );
+ pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xLeftDockWindow ) );
if( pWindow )
pWindow->SetAlign( WindowAlign::Left );
- pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xRightDockWindow ).get() );
+ pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xRightDockWindow ) );
if( pWindow )
pWindow->SetAlign( WindowAlign::Right );
implts_reparentToolbars();
@@ -1054,7 +1051,8 @@ void ToolbarLayoutManager::setDockingAreaOffsets( const ::tools::Rectangle& rOff
m_bLayoutDirty = true;
}
-OUString ToolbarLayoutManager::implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber ) const
+// static
+OUString ToolbarLayoutManager::implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber )
{
OUString aAddonGenericTitle(FwkResId(STR_TOOLBAR_TITLE_ADDON));
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
@@ -1084,15 +1082,16 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
sal_uInt32 nCount = m_pAddonOptions->GetAddonsToolBarCount();
uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
- aPropSeq[0].Name = "Frame";
- aPropSeq[0].Value <<= xFrame;
- aPropSeq[1].Name = "ConfigurationData";
+ auto pPropSeq = aPropSeq.getArray();
+ pPropSeq[0].Name = "Frame";
+ pPropSeq[0].Value <<= xFrame;
+ pPropSeq[1].Name = "ConfigurationData";
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
OUString aAddonToolBarName( "private:resource/toolbar/addon_" +
m_pAddonOptions->GetAddonsToolbarResourceName(i) );
aAddonToolBarData = m_pAddonOptions->GetAddonsToolBarPart( i );
- aPropSeq[1].Value <<= aAddonToolBarData;
+ pPropSeq[1].Value <<= aAddonToolBarData;
UIElement aElement = implts_findToolbar( aAddonToolBarName );
@@ -1112,11 +1111,11 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
{
try
{
- xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >( static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(this) );
xDockWindow->enableDocking( true );
uno::Reference< awt::XWindow > xWindow( xDockWindow, uno::UNO_QUERY );
if ( xWindow.is() )
- xWindow->addWindowListener( uno::Reference< awt::XWindowListener >( static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(this) );
}
catch (const uno::Exception&)
{
@@ -1399,7 +1398,7 @@ void ToolbarLayoutManager::implts_setElementData( UIElement& rElement, const uno
{
SolarMutexGuard aGuard;
- pWindow = VCLUnoHelper::GetWindow( xWindow ).get();
+ pWindow = VCLUnoHelper::GetWindow( xWindow );
if ( pWindow )
{
OUString aText = pWindow->GetText();
@@ -1567,42 +1566,34 @@ void ToolbarLayoutManager::implts_writeWindowStateData( const UIElement& rElemen
try
{
- uno::Sequence< beans::PropertyValue > aWindowState( 9 );
-
- aWindowState[0].Name = WINDOWSTATE_PROPERTY_DOCKED;
- aWindowState[0].Value <<= !rElementData.m_bFloating;
- aWindowState[1].Name = WINDOWSTATE_PROPERTY_VISIBLE;
- aWindowState[1].Value <<= rElementData.m_bVisible;
- aWindowState[2].Name = WINDOWSTATE_PROPERTY_DOCKINGAREA;
- aWindowState[2].Value <<= rElementData.m_aDockedData.m_nDockedArea;
-
- awt::Point aPos = rElementData.m_aDockedData.m_aPos;
- aWindowState[3].Name = WINDOWSTATE_PROPERTY_DOCKPOS;
- aWindowState[3].Value <<= aPos;
-
- aPos = rElementData.m_aFloatingData.m_aPos;
- aWindowState[4].Name = WINDOWSTATE_PROPERTY_POS;
- aWindowState[4].Value <<= aPos;
-
- aWindowState[5].Name = WINDOWSTATE_PROPERTY_SIZE;
- aWindowState[5].Value <<= rElementData.m_aFloatingData.m_aSize;
- aWindowState[6].Name = WINDOWSTATE_PROPERTY_UINAME;
- aWindowState[6].Value <<= rElementData.m_aUIName;
- aWindowState[7].Name = WINDOWSTATE_PROPERTY_LOCKED;
- aWindowState[7].Value <<= rElementData.m_aDockedData.m_bLocked;
- aWindowState[8].Name = WINDOWSTATE_PROPERTY_STYLE;
- aWindowState[8].Value <<= static_cast<sal_uInt16>(rElementData.m_nStyle);
+ uno::Sequence<beans::PropertyValue> aWindowState{
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKED, !rElementData.m_bFloating),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_VISIBLE, rElementData.m_bVisible),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKINGAREA,
+ rElementData.m_aDockedData.m_nDockedArea),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_DOCKPOS,
+ rElementData.m_aDockedData.m_aPos),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_POS,
+ rElementData.m_aFloatingData.m_aPos),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_SIZE,
+ rElementData.m_aFloatingData.m_aSize),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_UINAME, rElementData.m_aUIName),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_LOCKED,
+ rElementData.m_aDockedData.m_bLocked),
+ comphelper::makePropertyValue(WINDOWSTATE_PROPERTY_STYLE,
+ static_cast<sal_uInt16>(rElementData.m_nStyle))
+ };
OUString aName = rElementData.m_aName;
if ( xPersistentWindowState->hasByName( aName ))
{
uno::Reference< container::XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
- xReplace->replaceByName( aName, uno::makeAny( aWindowState ));
+ xReplace->replaceByName( aName, uno::Any( aWindowState ));
}
else
{
uno::Reference< container::XNameContainer > xInsert( xPersistentWindowState, uno::UNO_QUERY );
- xInsert->insertByName( aName, uno::makeAny( aWindowState ));
+ xInsert->insertByName( aName, uno::Any( aWindowState ));
}
}
catch (const uno::Exception&)
@@ -1851,12 +1842,11 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfos( ui::DockingArea eD
DockingManager* pDockMgr = vcl::Window::GetDockingManager();
if (pDockMgr != nullptr)
{
- ImplDockingWindowWrapper* pWrapper
- = pDockMgr->GetDockingWindowWrapper(pWindow);
- if (pWrapper != nullptr && pWrapper->GetFloatingWindow())
+ SystemWindow* pFloatingWindow = pDockMgr->GetFloatingWindow(pWindow);
+ if (pFloatingWindow)
{
// update the position data of the floating window
- if (pWrapper->GetFloatingWindow()->UpdatePositionData())
+ if (pFloatingWindow->UpdatePositionData())
{
awt::Rectangle aTmpRect = xWindow->getPosSize();
UIElement uiElem = elem;
@@ -2166,7 +2156,7 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfoOnSingleRowCol( ui::D
awt::Rectangle aWindowRect = rRowColumnWindowData.aRowColumnWindows[i]->getPosSize();
::tools::Rectangle aRect( aWindowRect.X, aWindowRect.Y, aWindowRect.X+aWindowRect.Width, aWindowRect.Y+aWindowRect.Height );
aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
- if ( aRect.IsInside( rMousePos ))
+ if ( aRect.Contains( rMousePos ))
{
// Check if we have found the excluded element. If yes, we have to provide an empty rectangle.
// We prevent that a toolbar cannot be moved when the mouse pointer is inside its own rectangle!
@@ -2232,7 +2222,7 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfoOnSingleRowCol( ui::D
if ( nSpace > 0 )
{
- sal_Int32 nMove = std::min( nSpace, static_cast<sal_Int32>(aFrontDockingRect.getWidth()) );
+ sal_Int32 nMove = std::min( nSpace, static_cast<sal_Int32>(aFrontDockingRect.getOpenWidth()) );
if ( bHorzDockArea )
aFrontDockingRect.Move( -nMove, 0 );
else
@@ -2252,7 +2242,7 @@ void ToolbarLayoutManager::implts_findNextDockingPos( ui::DockingArea DockingAre
::Size aDockingWinSize;
// Retrieve output size from container Window
- vcl::Window* pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow ).get();
+ vcl::Window* pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow );
if ( pDockingWindow )
aDockingWinSize = pDockingWindow->GetOutputSizePixel();
aReadLock.clear();
@@ -2567,6 +2557,7 @@ void ToolbarLayoutManager::implts_setLayoutInProgress( bool bInProgress )
m_bLayoutInProgress = bInProgress;
}
+// static
::tools::Rectangle ToolbarLayoutManager::implts_calcHotZoneRect( const ::tools::Rectangle& rRect, sal_Int32 nHotZoneOffset )
{
::tools::Rectangle aRect( rRect );
@@ -2601,7 +2592,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
{
// Retrieve output size from container Window
SolarMutexGuard aGuard;
- pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ).get();
+ pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
aContainerWinSize = pContainerWindow->GetOutputSizePixel();
}
@@ -2627,7 +2618,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
{
SolarMutexGuard aGuard;
- pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get();
+ pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
VclPtr<vcl::Window> pDockWindow = VCLUnoHelper::GetWindow( xWindow );
ToolBox* pToolBox( nullptr );
if ( pDockWindow && pDockWindow->GetType() == WindowType::TOOLBOX )
@@ -2643,7 +2634,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
}
// default docking operation, dock on the given row/column
- bool bOpOutsideOfDockingArea( !aDockingAreaRect.IsInside( rMousePos ));
+ bool bOpOutsideOfDockingArea( !aDockingAreaRect.Contains( rMousePos ));
std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
@@ -2684,7 +2675,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
}
- bool bIsInsideRowCol( aRect.IsInside( rMousePos ) );
+ bool bIsInsideRowCol( aRect.Contains( rMousePos ) );
if ( bIsInsideRowCol )
{
nIndex = i;
@@ -2707,19 +2698,19 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
// Determine if the tracking rect must be located before/after the docked toolbar.
::tools::Rectangle aUIElementRect( aWindowRect );
- sal_Int32 nMiddle( bHorizontalDockArea ? ( aWindowRect.Left() + aWindowRect.getWidth() / 2 ) :
- ( aWindowRect.Top() + aWindowRect.getHeight() / 2 ));
+ sal_Int32 nMiddle( bHorizontalDockArea ? ( aWindowRect.Left() + aWindowRect.getOpenWidth() / 2 ) :
+ ( aWindowRect.Top() + aWindowRect.getOpenHeight() / 2 ));
bool bInsertBefore( bHorizontalDockArea ? ( rMousePos.X() < nMiddle ) : ( rMousePos.Y() < nMiddle ));
if ( bInsertBefore )
{
if ( bHorizontalDockArea )
{
sal_Int32 nSize = std::clamp( sal_Int32(aContainerWinSize.Width() - aWindowRect.Left()),
- sal_Int32(0), sal_Int32(aTrackingRect.getWidth()) );
+ sal_Int32(0), sal_Int32(aTrackingRect.getOpenWidth()) );
if ( nSize == 0 )
- nSize = aWindowRect.getWidth();
+ nSize = aWindowRect.getOpenWidth();
- aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
+ aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getOpenHeight() ));
aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect,rUIElement.m_aName, aUIElementRect );
// Set virtual position
@@ -2729,11 +2720,11 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
else
{
sal_Int32 nSize = std::clamp( sal_Int32(nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Top()),
- sal_Int32(0), sal_Int32(aTrackingRect.getHeight()) );
+ sal_Int32(0), sal_Int32(aTrackingRect.getOpenHeight()) );
if ( nSize == 0 )
- nSize = aWindowRect.getHeight();
+ nSize = aWindowRect.getOpenHeight();
- aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
+ aUIElementRect.SetSize( ::Size( aWindowRect.getOpenWidth(), nSize ));
aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect, rUIElement.m_aName, aUIElementRect );
// Set virtual position
@@ -2751,18 +2742,18 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
if ( bHorizontalDockArea )
{
sal_Int32 nSize = ::std::clamp( sal_Int32(aContainerWinSize.Width() - aWindowRect.Right()),
- sal_Int32(0), sal_Int32(aTrackingRect.getWidth()) );
+ sal_Int32(0), sal_Int32(aTrackingRect.getOpenWidth()) );
if ( nSize == 0 )
{
- aUIElementRect.SetPos( ::Point( aContainerWinSize.Width() - aTrackingRect.getWidth(), aWindowRect.Top() ));
- aUIElementRect.SetSize( ::Size( aTrackingRect.getWidth(), aWindowRect.getHeight() ));
+ aUIElementRect.SetPos( ::Point( aContainerWinSize.Width() - aTrackingRect.getOpenWidth(), aWindowRect.Top() ));
+ aUIElementRect.SetSize( ::Size( aTrackingRect.getOpenWidth(), aWindowRect.getOpenHeight() ));
rUIElement.m_aDockedData.m_aPos.X = aUIElementRect.Left();
}
else
{
aUIElementRect.SetPos( ::Point( aWindowRect.Right(), aWindowRect.Top() ));
- aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
+ aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getOpenHeight() ));
rUIElement.m_aDockedData.m_aPos.X = aWindowRect.Right();
}
@@ -2772,9 +2763,9 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
else
{
sal_Int32 nSize = std::clamp( sal_Int32(nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Bottom()),
- sal_Int32(0), sal_Int32(aTrackingRect.getHeight()) );
+ sal_Int32(0), sal_Int32(aTrackingRect.getOpenHeight()) );
aUIElementRect.SetPos( ::Point( aWindowRect.Left(), aWindowRect.Bottom() ));
- aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
+ aUIElementRect.SetSize( ::Size( aWindowRect.getOpenWidth(), nSize ));
// Set virtual position
sal_Int32 nPosY( 0 );
@@ -2816,9 +2807,9 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
sal_Int32 nOffsetX( 0 );
sal_Int32 nOffsetY( 0 );
if ( bHorizontalDockArea )
- nOffsetY = sal_Int32( floor( aRowColumnRect.getHeight() / 2.0 + 0.5 ));
+ nOffsetY = sal_Int32( floor( aRowColumnRect.getOpenHeight() / 2.0 + 0.5 ));
else
- nOffsetX = sal_Int32( floor( aRowColumnRect.getWidth() / 2.0 + 0.5 ));
+ nOffsetX = sal_Int32( floor( aRowColumnRect.getOpenWidth() / 2.0 + 0.5 ));
if ( rDockingOperation == DOCKOP_BEFORE_COLROW )
{
@@ -2868,24 +2859,24 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
if ( bHorizontalDockArea )
{
sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
- if (( nPosX + rTrackingRect.getWidth()) > aContainerWinSize.Width() )
+ if (( nPosX + rTrackingRect.getOpenWidth()) > aContainerWinSize.Width() )
nPosX = std::min( nPosX,
- std::max( sal_Int32( aContainerWinSize.Width() - rTrackingRect.getWidth() ),
+ std::max( sal_Int32( aContainerWinSize.Width() - rTrackingRect.getOpenWidth() ),
sal_Int32( 0 )));
- sal_Int32 nSize = std::min( aContainerWinSize.Width(), rTrackingRect.getWidth() );
- sal_Int32 nDockHeight = std::max( static_cast<sal_Int32>(aDockingAreaRect.getHeight()), sal_Int32( 0 ));
+ sal_Int32 nSize = std::min( aContainerWinSize.Width(), rTrackingRect.getOpenWidth() );
+ sal_Int32 nDockHeight = std::max( static_cast<sal_Int32>(aDockingAreaRect.getOpenHeight()), sal_Int32( 0 ));
if ( nDockHeight == 0 )
{
sal_Int32 nPosY( std::max( aDockingAreaRect.Top(), aDockingAreaRect.Bottom() ));
if ( eDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
- nPosY -= rTrackingRect.getHeight();
+ nPosY -= rTrackingRect.getOpenHeight();
rTrackingRect.SetPos( Point( nPosX, nPosY ));
rUIElement.m_aDockedData.m_aPos.Y = 0;
}
else if ( rMousePos.Y() < ( aDockingAreaRect.Top() + ( nDockHeight / 2 )))
{
- rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Top() - rTrackingRect.getHeight() ));
+ rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Top() - rTrackingRect.getOpenHeight() ));
if ( eDockedArea == ui::DockingArea_DOCKINGAREA_TOP )
rUIElement.m_aDockedData.m_aPos.Y = 0;
else
@@ -2914,24 +2905,24 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
{
sal_Int32 nMaxDockingAreaHeight = std::max<sal_Int32>( 0, nMaxLeftRightDockAreaSize );
sal_Int32 nPosY( std::max<sal_Int32>( aTrackingRect.Top(), nTopDockingAreaSize ));
- if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
+ if (( nPosY + aTrackingRect.getOpenHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
nPosY = std::min( nPosY,
- std::max<sal_Int32>( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() ),
+ std::max<sal_Int32>( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getOpenHeight() ),
nTopDockingAreaSize ));
- sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
- sal_Int32 nDockWidth = std::max( static_cast<sal_Int32>(aDockingAreaRect.getWidth()), sal_Int32( 0 ));
+ sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getOpenHeight()) );
+ sal_Int32 nDockWidth = std::max( static_cast<sal_Int32>(aDockingAreaRect.getOpenWidth()), sal_Int32( 0 ));
if ( nDockWidth == 0 )
{
sal_Int32 nPosX( std::max( aDockingAreaRect.Left(), aDockingAreaRect.Right() ));
if ( eDockedArea == ui::DockingArea_DOCKINGAREA_RIGHT )
- nPosX -= rTrackingRect.getWidth();
+ nPosX -= rTrackingRect.getOpenWidth();
rTrackingRect.SetPos( Point( nPosX, nPosY ));
rUIElement.m_aDockedData.m_aPos.X = 0;
}
else if ( rMousePos.X() < ( aDockingAreaRect.Left() + ( nDockWidth / 2 )))
{
- rTrackingRect.SetPos( Point( aDockingAreaRect.Left() - rTrackingRect.getWidth(), nPosY ));
+ rTrackingRect.SetPos( Point( aDockingAreaRect.Left() - rTrackingRect.getOpenWidth(), nPosY ));
if ( eDockedArea == ui::DockingArea_DOCKINGAREA_LEFT )
rUIElement.m_aDockedData.m_aPos.X = 0;
else
@@ -2958,6 +2949,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
}
}
+// static
framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_determineDockingOperation(
ui::DockingArea DockingArea,
const ::tools::Rectangle& rRowColRect,
@@ -2966,11 +2958,11 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
constexpr sal_Int32 nHorzVerticalRegionSize = 6;
constexpr sal_Int32 nHorzVerticalMoveRegion = 4;
- if ( rRowColRect.IsInside( rMousePos ))
+ if ( rRowColRect.Contains( rMousePos ))
{
if ( isHorizontalDockingArea( DockingArea ))
{
- sal_Int32 nRegion = rRowColRect.getHeight() / nHorzVerticalRegionSize;
+ sal_Int32 nRegion = rRowColRect.getOpenHeight() / nHorzVerticalRegionSize;
sal_Int32 nPosY = rRowColRect.Top() + nRegion;
if ( rMousePos.Y() < nPosY )
@@ -2982,7 +2974,7 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
}
else
{
- sal_Int32 nRegion = rRowColRect.getWidth() / nHorzVerticalRegionSize;
+ sal_Int32 nRegion = rRowColRect.getOpenWidth() / nHorzVerticalRegionSize;
sal_Int32 nPosX = rRowColRect.Left() + nRegion;
if ( rMousePos.X() < nPosX )
@@ -3024,16 +3016,16 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
if ( bHorizontalDockArea )
{
sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
- if (( nPosX + rTrackingRect.getWidth()) > rContainerWinSize.Width() )
+ if (( nPosX + rTrackingRect.getOpenWidth()) > rContainerWinSize.Width() )
nPosX = std::min( nPosX,
- std::max( sal_Int32( rContainerWinSize.Width() - rTrackingRect.getWidth() ),
+ std::max( sal_Int32( rContainerWinSize.Width() - rTrackingRect.getOpenWidth() ),
sal_Int32( 0 )));
- sal_Int32 nSize = std::min( rContainerWinSize.Width(), rTrackingRect.getWidth() );
+ sal_Int32 nSize = std::min( rContainerWinSize.Width(), rTrackingRect.getOpenWidth() );
aTrackingRect.SetPos( ::Point( nPosX, rRowColumnRect.Top() ));
aTrackingRect.setWidth( nSize );
- aTrackingRect.setHeight( rRowColumnRect.getHeight() );
+ aTrackingRect.setHeight( rRowColumnRect.getOpenHeight() );
// Set virtual position
rUIElement.m_aDockedData.m_aPos.X = nPosX;
@@ -3044,15 +3036,15 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
sal_Int32 nMaxDockingAreaHeight = std::max<sal_Int32>( 0, nMaxLeftRightDockAreaSize );
sal_Int32 nPosY( std::max<sal_Int32>( aTrackingRect.Top(), nTopDockingAreaSize ));
- if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
+ if (( nPosY + aTrackingRect.getOpenHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
nPosY = std::min( nPosY,
- std::max<sal_Int32>( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() ),
+ std::max<sal_Int32>( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getOpenHeight() ),
nTopDockingAreaSize ));
- sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
+ sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getOpenHeight()) );
aTrackingRect.SetPos( ::Point( rRowColumnRect.Left(), nPosY ));
- aTrackingRect.setWidth( rRowColumnRect.getWidth() );
+ aTrackingRect.setWidth( rRowColumnRect.getOpenWidth() );
aTrackingRect.setHeight( nSize );
aReadGuard.reset();
@@ -3063,7 +3055,7 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
sal_Int32 nDockPosY( 0 );
{
SolarMutexGuard aGuard;
- vcl::Window* pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get();
+ vcl::Window* pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
nDockPosY = pDockingAreaWindow->ScreenToOutputPixel( pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y();
}
@@ -3076,6 +3068,7 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d
return aTrackingRect;
}
+// static
void ToolbarLayoutManager::implts_setTrackingRect( ui::DockingArea eDockingArea, const ::Point& rMousePos, ::tools::Rectangle& rTrackingRect )
{
::Point aPoint( rTrackingRect.TopLeft());
@@ -3141,7 +3134,7 @@ void ToolbarLayoutManager::implts_renumberRowColumnData(
ui::DockingArea nDockedArea( ui::DockingArea_DOCKINGAREA_DEFAULT );
xPersistentWindowState->getByName( rWindowElementName ) >>= aPropValueSeq;
- for ( beans::PropertyValue const & rProp : std::as_const(aPropValueSeq) )
+ for (beans::PropertyValue const& rProp : aPropValueSeq)
{
if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA )
rProp.Value >>= nDockedArea;
@@ -3162,7 +3155,7 @@ void ToolbarLayoutManager::implts_renumberRowColumnData(
aDockedPos.X += 1;
uno::Reference< container::XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
- xReplace->replaceByName( rWindowElementName, makeAny( aPropValueSeq ));
+ xReplace->replaceByName( rWindowElementName, css::uno::Any( aPropValueSeq ));
}
}
catch (const uno::Exception&)
@@ -3246,7 +3239,6 @@ void SAL_CALL ToolbarLayoutManager::startDocking( const awt::DockingEvent& e )
bool bWinFound( false );
SolarMutexClearableGuard aReadGuard;
- uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
uno::Reference< awt::XWindow2 > xWindow( e.Source, uno::UNO_QUERY );
aReadGuard.clear();
@@ -3336,23 +3328,23 @@ awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent
VclPtr<vcl::Window> pContainerWindow( VCLUnoHelper::GetWindow( xContainerWindow ) );
::Point aMousePos( pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y )));
- if ( aHotZoneTopDockRect.IsInside( aMousePos ))
+ if ( aHotZoneTopDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
- else if ( aHotZoneBottomDockRect.IsInside( aMousePos ))
+ else if ( aHotZoneBottomDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_BOTTOM;
- else if ( aHotZoneLeftDockRect.IsInside( aMousePos ))
+ else if ( aHotZoneLeftDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_LEFT;
- else if ( aHotZoneRightDockRect.IsInside( aMousePos ))
+ else if ( aHotZoneRightDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_RIGHT;
// Higher priority for movements inside the real docking area
- if ( aTopDockRect.IsInside( aMousePos ))
+ if ( aTopDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
- else if ( aBottomDockRect.IsInside( aMousePos ))
+ else if ( aBottomDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_BOTTOM;
- else if ( aLeftDockRect.IsInside( aMousePos ))
+ else if ( aLeftDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_LEFT;
- else if ( aRightDockRect.IsInside( aMousePos ))
+ else if ( aRightDockRect.Contains( aMousePos ))
eDockingArea = ui::DockingArea_DOCKINGAREA_RIGHT;
// Determine if we have a toolbar and set alignment according to the docking area!
@@ -3393,7 +3385,7 @@ awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent
::Point aScreenPos = pContainerWindow->OutputToScreenPixel( aNewDockingRect.TopLeft() );
aDockingData.TrackingRectangle = awt::Rectangle( aScreenPos.X(), aScreenPos.Y(),
- aNewDockingRect.getWidth(), aNewDockingRect.getHeight() );
+ aNewDockingRect.getOpenWidth(), aNewDockingRect.getOpenHeight() );
}
else if (pToolBox)
{
@@ -3561,33 +3553,33 @@ sal_Bool SAL_CALL ToolbarLayoutManager::prepareToggleFloatingMode( const lang::E
bool bWinFound( !aUIDockingElement.m_aName.isEmpty() );
uno::Reference< awt::XWindow > xWindow( e.Source, uno::UNO_QUERY );
- if ( bWinFound && xWindow.is() )
+ if ( !bWinFound || !xWindow.is() )
+ return true;
+
+ if ( bDockingInProgress )
+ return true;
+
+ uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
+ if ( !xDockWindow->isFloating() )
+ return true;
+
{
- if ( !bDockingInProgress )
+ SolarMutexGuard aGuard;
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
{
- uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
- if ( xDockWindow->isFloating() )
- {
- {
- SolarMutexGuard aGuard;
- VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
- if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
- {
- ToolBox* pToolBox = static_cast< ToolBox *>( pWindow.get() );
- aUIDockingElement.m_aFloatingData.m_aPos = AWTPoint(pToolBox->GetPosPixel());
- aUIDockingElement.m_aFloatingData.m_aSize = AWTSize(pToolBox->GetOutputSizePixel());
- aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
- aUIDockingElement.m_aFloatingData.m_bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
- }
- }
-
- UIElement aUIElement = implts_findToolbar( aUIDockingElement.m_aName );
- if ( aUIElement.m_aName == aUIDockingElement.m_aName )
- implts_setToolbar( aUIDockingElement );
- }
+ ToolBox* pToolBox = static_cast< ToolBox *>( pWindow.get() );
+ aUIDockingElement.m_aFloatingData.m_aPos = AWTPoint(pToolBox->GetPosPixel());
+ aUIDockingElement.m_aFloatingData.m_aSize = AWTSize(pToolBox->GetOutputSizePixel());
+ aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
+ aUIDockingElement.m_aFloatingData.m_bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
}
}
+ UIElement aUIElement = implts_findToolbar( aUIDockingElement.m_aName );
+ if ( aUIElement.m_aName == aUIDockingElement.m_aName )
+ implts_setToolbar( aUIDockingElement );
+
return true;
}
@@ -3608,7 +3600,7 @@ void SAL_CALL ToolbarLayoutManager::toggleFloatingMode( const lang::EventObject&
{
SolarMutexGuard aGuard;
xWindow.set( e.Source, uno::UNO_QUERY );
- pWindow = VCLUnoHelper::GetWindow( xWindow ).get();
+ pWindow = VCLUnoHelper::GetWindow( xWindow );
if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
pToolBox = static_cast<ToolBox *>(pWindow);
@@ -3785,7 +3777,7 @@ void SAL_CALL ToolbarLayoutManager::elementInserted( const ui::ConfigurationEven
if ( xPropSet.is() )
{
if ( rEvent.Source == uno::Reference< uno::XInterface >( m_xDocCfgMgr, uno::UNO_QUERY ))
- xPropSet->setPropertyValue( "ConfigurationSource", makeAny( m_xDocCfgMgr ));
+ xPropSet->setPropertyValue( "ConfigurationSource", css::uno::Any( m_xDocCfgMgr ));
}
xElementSettings->updateSettings();
}
@@ -3869,7 +3861,7 @@ void SAL_CALL ToolbarLayoutManager::elementRemoved( const ui::ConfigurationEvent
// document settings removed
if ( xModuleCfgMgr->hasSettings( rEvent.ResourceURL ))
{
- xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( xModuleCfgMgr ));
+ xPropSet->setPropertyValue( aConfigSourcePropName, css::uno::Any( xModuleCfgMgr ));
xElementSettings->updateSettings();
return;
}
@@ -3916,6 +3908,20 @@ void SAL_CALL ToolbarLayoutManager::elementReplaced( const ui::ConfigurationEven
pParentLayouter->requestLayout();
}
+void ToolbarLayoutManager::updateToolbarsTips()
+{
+ SolarMutexGuard g;
+
+ for (auto& elem : m_aUIElements)
+ {
+ uno::Reference< ui::XUIElementSettings > xElementSettings(elem.m_xUIElement, uno::UNO_QUERY);
+ if (!xElementSettings.is())
+ continue;
+ xElementSettings->updateSettings();
+ }
+}
+
+
uno::Reference< ui::XUIElement > ToolbarLayoutManager::getToolbar( std::u16string_view aName )
{
return implts_findToolbar( aName ).m_xUIElement;
@@ -3935,7 +3941,7 @@ uno::Sequence< uno::Reference< ui::XUIElement > > ToolbarLayoutManager::getToolb
{
++nCount;
aSeq.realloc( nCount );
- aSeq[nCount-1] = elem.m_xUIElement;
+ aSeq.getArray()[nCount-1] = elem.m_xUIElement;
}
}
}
@@ -3946,26 +3952,26 @@ uno::Sequence< uno::Reference< ui::XUIElement > > ToolbarLayoutManager::getToolb
bool ToolbarLayoutManager::floatToolbar( std::u16string_view rResourceURL )
{
UIElement aUIElement = implts_findToolbar( rResourceURL );
- if ( aUIElement.m_xUIElement.is() )
+ if ( !aUIElement.m_xUIElement.is() )
+ return false;
+
+ try
{
- try
+ uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
+ if ( xDockWindow.is() && !xDockWindow->isFloating() )
{
- uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
- if ( xDockWindow.is() && !xDockWindow->isFloating() )
- {
- aUIElement.m_bFloating = true;
- implts_writeWindowStateData( aUIElement );
- xDockWindow->setFloatingMode( true );
+ aUIElement.m_bFloating = true;
+ implts_writeWindowStateData( aUIElement );
+ xDockWindow->setFloatingMode( true );
- implts_setLayoutDirty();
- implts_setToolbar( aUIElement );
- return true;
- }
- }
- catch (const lang::DisposedException&)
- {
+ implts_setLayoutDirty();
+ implts_setToolbar( aUIElement );
+ return true;
}
}
+ catch (const lang::DisposedException&)
+ {
+ }
return false;
}
@@ -3973,26 +3979,26 @@ bool ToolbarLayoutManager::floatToolbar( std::u16string_view rResourceURL )
bool ToolbarLayoutManager::lockToolbar( std::u16string_view rResourceURL )
{
UIElement aUIElement = implts_findToolbar( rResourceURL );
- if ( aUIElement.m_xUIElement.is() )
+ if ( !aUIElement.m_xUIElement.is() )
+ return false;
+
+ try
{
- try
+ uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
+ if ( xDockWindow.is() && !xDockWindow->isFloating() && !xDockWindow->isLocked() )
{
- uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
- if ( xDockWindow.is() && !xDockWindow->isFloating() && !xDockWindow->isLocked() )
- {
- aUIElement.m_aDockedData.m_bLocked = true;
- implts_writeWindowStateData( aUIElement );
- xDockWindow->lock();
+ aUIElement.m_aDockedData.m_bLocked = true;
+ implts_writeWindowStateData( aUIElement );
+ xDockWindow->lock();
- implts_setLayoutDirty();
- implts_setToolbar( aUIElement );
- return true;
- }
- }
- catch (const lang::DisposedException&)
- {
+ implts_setLayoutDirty();
+ implts_setToolbar( aUIElement );
+ return true;
}
}
+ catch (const lang::DisposedException&)
+ {
+ }
return false;
}
@@ -4000,26 +4006,26 @@ bool ToolbarLayoutManager::lockToolbar( std::u16string_view rResourceURL )
bool ToolbarLayoutManager::unlockToolbar( std::u16string_view rResourceURL )
{
UIElement aUIElement = implts_findToolbar( rResourceURL );
- if ( aUIElement.m_xUIElement.is() )
+ if ( !aUIElement.m_xUIElement.is() )
+ return false;
+
+ try
{
- try
+ uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
+ if ( xDockWindow.is() && !xDockWindow->isFloating() && xDockWindow->isLocked() )
{
- uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
- if ( xDockWindow.is() && !xDockWindow->isFloating() && xDockWindow->isLocked() )
- {
- aUIElement.m_aDockedData.m_bLocked = false;
- implts_writeWindowStateData( aUIElement );
- xDockWindow->unlock();
+ aUIElement.m_aDockedData.m_bLocked = false;
+ implts_writeWindowStateData( aUIElement );
+ xDockWindow->unlock();
- implts_setLayoutDirty();
- implts_setToolbar( aUIElement );
- return true;
- }
- }
- catch (const lang::DisposedException&)
- {
+ implts_setLayoutDirty();
+ implts_setToolbar( aUIElement );
+ return true;
}
}
+ catch (const lang::DisposedException&)
+ {
+ }
return false;
}
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
index 96edbe157742..629f50b2b4a2 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
@@ -17,12 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_TOOLBARLAYOUTMANAGER_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_TOOLBARLAYOUTMANAGER_HXX
+#pragma once
-/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
- with solaris headers ...
-*/
+#include <sal/config.h>
+
+#include <string_view>
#include <vector>
#include <uiconfiguration/globalsettings.hxx>
@@ -57,8 +56,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
PREVIEWFRAME_YES
};
- ToolbarLayoutManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
- const css::uno::Reference< css::ui::XUIElementFactory >& xUIElementFactory,
+ ToolbarLayoutManager( css::uno::Reference< css::uno::XComponentContext > xContext,
+ css::uno::Reference< css::ui::XUIElementFactory > xUIElementFactory,
LayoutManager* pParentLayouter );
virtual ~ToolbarLayoutManager() override;
@@ -68,7 +67,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
const css::uno::Reference< css::ui::XUIConfigurationManager >& xDocCfgMgr,
const css::uno::Reference< css::container::XNameAccess >& xPersistentWindowState );
- void setParentWindow( const css::uno::Reference< css::awt::XWindowPeer >& xParentWindow );
+ void setParentWindow( const css::uno::Reference< css::awt::XVclWindowPeer >& xParentWindow );
void setDockingAreaOffsets(const ::tools::Rectangle& rOffsets);
void resetDockingArea();
@@ -88,7 +87,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
bool requestToolbar( const OUString& rResourceURL );
bool createToolbar( const OUString& rResourceURL );
- bool destroyToolbar( const OUString& rResourceURL );
+ bool destroyToolbar( std::u16string_view rResourceURL );
// visibility
bool showToolbar( std::u16string_view rResourceURL );
@@ -116,13 +115,15 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
css::uno::Reference< css::ui::XUIElement > getToolbar( std::u16string_view aName );
css::uno::Sequence< css::uno::Reference< css::ui::XUIElement > > getToolbars();
+ void updateToolbarsTips();
+
// child window notifications
void childWindowEvent( VclSimpleEvent const * pEvent );
// XInterface
- virtual void SAL_CALL acquire() throw() override;
- virtual void SAL_CALL release() throw() override;
+ virtual void SAL_CALL acquire() noexcept override;
+ virtual void SAL_CALL release() noexcept override;
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
// XEventListener
@@ -183,7 +184,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
::tools::Rectangle implts_calcDockingArea();
void implts_sortUIElements();
void implts_reparentToolbars();
- OUString implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber ) const;
+ static OUString implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber );
void implts_setElementData( UIElement& rUIElement, const css::uno::Reference< css::awt::XDockableWindow >& rDockWindow );
void implts_destroyDockingAreaWindows();
@@ -213,9 +214,9 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
// internal docking methods
- ::tools::Rectangle implts_calcHotZoneRect( const ::tools::Rectangle& rRect, sal_Int32 nHotZoneOffset );
+ static ::tools::Rectangle implts_calcHotZoneRect( const ::tools::Rectangle& rRect, sal_Int32 nHotZoneOffset );
void implts_calcDockingPosSize( UIElement& aUIElement, DockingOperation& eDockOperation, ::tools::Rectangle& rTrackingRect, const Point& rMousePos );
- DockingOperation implts_determineDockingOperation( css::ui::DockingArea DockingArea, const ::tools::Rectangle& rRowColRect, const Point& rMousePos );
+ static DockingOperation implts_determineDockingOperation( css::ui::DockingArea DockingArea, const ::tools::Rectangle& rRowColRect, const Point& rMousePos );
::tools::Rectangle implts_getWindowRectFromRowColumn( css::ui::DockingArea DockingArea, const SingleRowColumnWindowData& rRowColumnWindowData, const ::Point& rMousePos, std::u16string_view rExcludeElementName );
::tools::Rectangle implts_determineFrontDockingRect( css::ui::DockingArea eDockingArea,
sal_Int32 nRowCol,
@@ -232,7 +233,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
void implts_getDockingAreaElementInfos( css::ui::DockingArea DockingArea, std::vector< SingleRowColumnWindowData >& rRowColumnsWindowData );
void implts_getDockingAreaElementInfoOnSingleRowCol( css::ui::DockingArea, sal_Int32 nRowCol, SingleRowColumnWindowData& rRowColumnWindowData );
void implts_findNextDockingPos( css::ui::DockingArea DockingArea, const ::Size& aUIElementSize, css::awt::Point& rVirtualPos, ::Point& rPixelPos );
- void implts_setTrackingRect( css::ui::DockingArea eDockingArea, const ::Point& rMousePos, ::tools::Rectangle& rTrackingRect );
+ static void implts_setTrackingRect( css::ui::DockingArea eDockingArea, const ::Point& rMousePos, ::tools::Rectangle& rTrackingRect );
// creation methods
@@ -281,6 +282,4 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
} // namespace framework
-#endif // INCLUDED_FRAMEWORK_SOURCE_LAYOUTMANAGER_TOOLBARLAYOUTMANAGER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index 159247cb2d29..5871c56619ab 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -73,6 +73,7 @@
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/XModifiable.hpp>
+#include <utility>
#include <vcl/window.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/syswin.hxx>
@@ -84,15 +85,15 @@
#include <comphelper/configurationhelper.hxx>
#include <rtl/bootstrap.hxx>
#include <sal/log.hxx>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
#include <vcl/svapp.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/profilezone.hxx>
#include <classes/taskcreator.hxx>
#include <tools/fileutil.hxx>
-constexpr OUStringLiteral PROP_TYPES = u"Types";
-constexpr OUStringLiteral PROP_NAME = u"Name";
+constexpr OUString PROP_TYPES = u"Types"_ustr;
+constexpr OUString PROP_NAME = u"Name"_ustr;
namespace framework {
@@ -104,7 +105,7 @@ class LoadEnvListener : public ::cppu::WeakImplHelper< css::frame::XLoadEventLis
css::frame::XDispatchResultListener >
{
private:
- osl::Mutex m_mutex;
+ std::mutex m_mutex;
bool m_bWaitingResult;
LoadEnv* m_pLoadEnv;
@@ -130,8 +131,8 @@ class LoadEnvListener : public ::cppu::WeakImplHelper< css::frame::XLoadEventLis
}
-LoadEnv::LoadEnv(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext(xContext)
+LoadEnv::LoadEnv(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext(std::move(xContext))
, m_nSearchFlags(0)
, m_eFeature(LoadEnvFeatures::NONE)
, m_eContentType(E_UNSUPPORTED_CONTENT)
@@ -160,9 +161,8 @@ css::uno::Reference< css::lang::XComponent > LoadEnv::loadComponentFromURL(const
LoadEnv aEnv(xContext);
LoadEnvFeatures loadEnvFeatures = LoadEnvFeatures::WorkWithUI;
- comphelper::NamedValueCollection aDescriptor( lArgs );
// tdf#118238 Only disable UI interaction when loading as hidden
- if (aDescriptor.get("Hidden") == uno::Any(true) || Application::IsHeadlessModeEnabled())
+ if (comphelper::NamedValueCollection::get(lArgs, u"Hidden") == uno::Any(true) || Application::IsHeadlessModeEnabled())
loadEnvFeatures = LoadEnvFeatures::NONE;
aEnv.startLoading(sURL,
@@ -213,14 +213,14 @@ namespace {
utl::MediaDescriptor addModelArgs(const uno::Sequence<beans::PropertyValue>& rDescriptor)
{
utl::MediaDescriptor rResult(rDescriptor);
- uno::Reference<frame::XModel> xModel(rResult.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MODEL(), uno::Reference<frame::XModel>()));
+ uno::Reference<frame::XModel> xModel(rResult.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MODEL, uno::Reference<frame::XModel>()));
if (xModel.is())
{
utl::MediaDescriptor aModelArgs(xModel->getArgs());
- utl::MediaDescriptor::iterator pIt = aModelArgs.find( utl::MediaDescriptor::PROP_MACROEXECUTIONMODE());
+ utl::MediaDescriptor::iterator pIt = aModelArgs.find( utl::MediaDescriptor::PROP_MACROEXECUTIONMODE);
if (pIt != aModelArgs.end())
- rResult[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] = pIt->second;
+ rResult[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE] = pIt->second;
}
return rResult;
@@ -251,7 +251,8 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop
m_bLoaded = false;
OUString aRealURL;
- if (!tools::IsMappedWebDAVPath(sURL, &aRealURL))
+ if (!officecfg::Office::Common::Load::DetectWebDAVRedirection::get()
+ || !tools::IsMappedWebDAVPath(sURL, &aRealURL))
aRealURL = sURL;
// try to find out, if it's really a content, which can be loaded or must be "handled"
@@ -265,7 +266,7 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop
// make URL part of the MediaDescriptor
// It doesn't matter if it is already an item of it.
// It must be the same value... so we can overwrite it :-)
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_URL()] <<= aRealURL;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_URL] <<= aRealURL;
// parse it - because some following code require that
m_aURL.Complete = aRealURL;
@@ -275,10 +276,10 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop
// BTW: Split URL and JumpMark ...
// Because such mark is an explicit value of the media descriptor!
if (!m_aURL.Mark.isEmpty())
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_JUMPMARK()] <<= m_aURL.Mark;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_JUMPMARK] <<= m_aURL.Mark;
// By the way: remove the old and deprecated value "FileName" from the descriptor!
- utl::MediaDescriptor::iterator pIt = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FILENAME());
+ utl::MediaDescriptor::iterator pIt = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FILENAME);
if (pIt != m_lMediaDescriptor.end())
m_lMediaDescriptor.erase(pIt);
@@ -291,8 +292,16 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop
// UI mode
const bool bUIMode =
(m_eFeature & LoadEnvFeatures::WorkWithUI) &&
- !m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false) &&
- !m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW(), false);
+ !m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN, false) &&
+ !m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW, false);
+
+ if( comphelper::LibreOfficeKit::isActive() &&
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_SILENT, false))
+ {
+ rtl::Reference<QuietInteraction> pQuietInteraction = new QuietInteraction();
+ uno::Reference<task::XInteractionHandler> xInteractionHandler(pQuietInteraction);
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_INTERACTIONHANDLER] <<= xInteractionHandler;
+ }
initializeUIDefaults(m_xContext, m_lMediaDescriptor, bUIMode, &m_pQuietInteraction);
@@ -313,7 +322,16 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XCompon
nUpdateMode = css::document::UpdateDocMode::ACCORDING_TO_CONFIG;
try
{
- xInteractionHandler.set( css::task::InteractionHandler::createWithParent( i_rxContext, nullptr ), css::uno::UNO_QUERY_THROW );
+ // tdf#154308 At least for the case the document is launched from the StartCenter, put that StartCenter as the
+ // parent for any dialogs that may appear during typedetection (once load starts a permanent frame will be set
+ // anyway and used as dialog parent, which will be this one if the startcenter was running)
+ css::uno::Reference<css::frame::XFramesSupplier> xSupplier = css::frame::Desktop::create(i_rxContext);
+ FrameListAnalyzer aTasksAnalyzer(xSupplier, css::uno::Reference<css::frame::XFrame>(), FrameAnalyzerFlags::BackingComponent);
+ css::uno::Reference<css::awt::XWindow> xDialogParent(aTasksAnalyzer.m_xBackingComponent ?
+ aTasksAnalyzer.m_xBackingComponent->getContainerWindow() :
+ nullptr);
+
+ xInteractionHandler.set( css::task::InteractionHandler::createWithParent(i_rxContext, xDialogParent), css::uno::UNO_QUERY_THROW );
}
catch(const css::uno::RuntimeException&) {throw;}
catch(const css::uno::Exception& ) { }
@@ -333,21 +351,21 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XCompon
if ( xInteractionHandler.is() )
{
- if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_INTERACTIONHANDLER()) == io_lMediaDescriptor.end() )
+ if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_INTERACTIONHANDLER) == io_lMediaDescriptor.end() )
{
- io_lMediaDescriptor[utl::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
+ io_lMediaDescriptor[utl::MediaDescriptor::PROP_INTERACTIONHANDLER] <<= xInteractionHandler;
}
- if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()) == io_lMediaDescriptor.end() )
+ if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER) == io_lMediaDescriptor.end() )
{
- io_lMediaDescriptor[utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= xInteractionHandler;
+ io_lMediaDescriptor[utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER] <<= xInteractionHandler;
}
}
- if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
- io_lMediaDescriptor[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] <<= nMacroMode;
+ if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_MACROEXECUTIONMODE) == io_lMediaDescriptor.end())
+ io_lMediaDescriptor[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE] <<= nMacroMode;
- if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_UPDATEDOCMODE()) == io_lMediaDescriptor.end())
- io_lMediaDescriptor[utl::MediaDescriptor::PROP_UPDATEDOCMODE()] <<= nUpdateMode;
+ if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_UPDATEDOCMODE) == io_lMediaDescriptor.end())
+ io_lMediaDescriptor[utl::MediaDescriptor::PROP_UPDATEDOCMODE] <<= nUpdateMode;
}
void LoadEnv::start()
@@ -413,7 +431,7 @@ bool LoadEnv::waitWhileLoading(sal_uInt32 nTimeout)
// in an intelligent manner :-)
sal_Int32 nTime = nTimeout;
- while(true)
+ while(!Application::IsQuit())
{
// SAFE -> ------------------------------
{
@@ -459,7 +477,7 @@ css::uno::Reference< css::lang::XComponent > LoadEnv::getTargetComponent() const
void SAL_CALL LoadEnvListener::loadFinished(const css::uno::Reference< css::frame::XFrameLoader >&)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (m_bWaitingResult)
m_pLoadEnv->impl_setResult(true);
m_bWaitingResult = false;
@@ -467,7 +485,7 @@ void SAL_CALL LoadEnvListener::loadFinished(const css::uno::Reference< css::fram
void SAL_CALL LoadEnvListener::loadCancelled(const css::uno::Reference< css::frame::XFrameLoader >&)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (m_bWaitingResult)
m_pLoadEnv->impl_setResult(false);
m_bWaitingResult = false;
@@ -475,7 +493,7 @@ void SAL_CALL LoadEnvListener::loadCancelled(const css::uno::Reference< css::fra
void SAL_CALL LoadEnvListener::dispatchFinished(const css::frame::DispatchResultEvent& aEvent)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (!m_bWaitingResult)
return;
@@ -499,7 +517,7 @@ void SAL_CALL LoadEnvListener::dispatchFinished(const css::frame::DispatchResult
void SAL_CALL LoadEnvListener::disposing(const css::lang::EventObject&)
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if (m_bWaitingResult)
m_pLoadEnv->impl_setResult(false);
m_bWaitingResult = false;
@@ -573,7 +591,7 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString&
utl::MediaDescriptor::const_iterator pIt;
if (ProtocolCheck::isProtocol(sURL,EProtocol::PrivateStream))
{
- pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_INPUTSTREAM());
+ pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_INPUTSTREAM);
css::uno::Reference< css::io::XInputStream > xStream;
if (pIt != stlMediaDescriptor.end())
pIt->second >>= xStream;
@@ -586,7 +604,7 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString&
// using of a full featured document
if (ProtocolCheck::isProtocol(sURL,EProtocol::PrivateObject))
{
- pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_MODEL());
+ pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_MODEL);
css::uno::Reference< css::frame::XModel > xModel;
if (pIt != stlMediaDescriptor.end())
pIt->second >>= xModel;
@@ -605,29 +623,26 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString&
OUString sType = xDetect->queryTypeByURL(sURL);
- css::uno::Sequence< css::beans::NamedValue > lQuery(1);
css::uno::Reference< css::frame::XLoaderFactory > xLoaderFactory;
css::uno::Reference< css::container::XEnumeration > xSet;
- css::uno::Sequence< OUString > lTypesReg(1);
// (iii) If a FrameLoader service (or at least
// a Filter) can be found, which supports
// this URL - it must be a loadable content.
// Because both items are registered for types
// it's enough to check for frame loaders only.
- // Mos of our filters are handled by our global
+ // Most of our filters are handled by our global
// default loader. But there exist some specialized
// loader, which does not work on top of filters!
// So it's not enough to search on the filter configuration.
// Further it's not enough to search for types!
// Because there exist some types, which are referenced by
- // other objects... but not by filters nor frame loaders!
-
- OUString sPROP_TYPES(PROP_TYPES);
-
- lTypesReg[0] = sType;
- lQuery[0].Name = sPROP_TYPES;
- lQuery[0].Value <<= lTypesReg;
+ // other objects... but neither by filters nor frame loaders!
+ css::uno::Sequence< OUString > lTypesReg { sType };
+ css::uno::Sequence< css::beans::NamedValue > lQuery
+ {
+ css::beans::NamedValue(PROP_TYPES, css::uno::Any(lTypesReg))
+ };
xLoaderFactory = css::frame::FrameLoaderFactory::create(xContext);
xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
@@ -639,10 +654,6 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString&
// E.g. ContentHandler.
// Such contents can be handled ... but not loaded.
- lTypesReg[0] = sType;
- lQuery[0].Name = sPROP_TYPES;
- lQuery[0].Value <<= lTypesReg;
-
xLoaderFactory = css::frame::ContentHandlerFactory::create(xContext);
xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
// at least one registered content handler is enough!
@@ -679,7 +690,7 @@ bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescrip
}
}
- if (aURL.isEmpty() || aURL.copy(0,8).equalsIgnoreAsciiCase("private:"))
+ if (aURL.isEmpty() || o3tl::equalsIgnoreAsciiCase(aURL.subView(0,8), u"private:"))
return false;
// TODO : Type must be set to be generic_Text (or any other type that
@@ -687,8 +698,7 @@ bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescrip
// hack.
// depending on the experimental mode
- uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
- if (!xContext.is() || !officecfg::Office::Common::Misc::ExperimentalMode::get(xContext))
+ if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
{
return false;
}
@@ -744,13 +754,17 @@ void LoadEnv::impl_detectTypeAndFilter()
if (queryOrcusTypeAndFilter(lDescriptor, sType, sFilter) && !sType.isEmpty() && !sFilter.isEmpty())
{
+ // SAFE ->
+ osl::MutexGuard aWriteLock(m_mutex);
+
// Orcus type detected. Skip the normal type detection process.
m_lMediaDescriptor << lDescriptor;
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType;
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] <<= sFilter;
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERPROVIDER()] <<= OUString("orcus");
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTSERVICE()] <<= OUString("com.sun.star.sheet.SpreadsheetDocument");
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_TYPENAME] <<= sType;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] <<= sFilter;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERPROVIDER] <<= OUString("orcus");
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTSERVICE] <<= OUString("com.sun.star.sheet.SpreadsheetDocument");
return;
+ // <- SAFE
}
css::uno::Reference< css::document::XTypeDetection > xDetect(
@@ -769,16 +783,16 @@ void LoadEnv::impl_detectTypeAndFilter()
// detection was successful => update the descriptor member of this class
m_lMediaDescriptor << lDescriptor;
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_TYPENAME] <<= sType;
// Is there an already detected (may be preselected) filter?
// see below ...
- sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME(), OUString());
+ sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME, OUString());
aWriteLock.clear();
// <- SAFE
// We do have potentially correct type, but the detection process was aborted.
- if (m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ABORTED(), false))
+ if (m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ABORTED, false))
throw LoadEnvException(
LoadEnvException::ID_UNSUPPORTED_CONTENT, "type detection aborted");
@@ -802,7 +816,7 @@ void LoadEnv::impl_detectTypeAndFilter()
{
// SAFE ->
aWriteLock.reset();
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] <<= sFilter;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] <<= sFilter;
aWriteLock.clear();
// <- SAFE
}
@@ -837,9 +851,9 @@ void LoadEnv::impl_detectTypeAndFilter()
// SAFE ->
aWriteLock.reset();
// Don't overwrite external decisions! See comments before ...
- utl::MediaDescriptor::const_iterator pAsTemplateItem = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_ASTEMPLATE());
+ utl::MediaDescriptor::const_iterator pAsTemplateItem = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_ASTEMPLATE);
if (pAsTemplateItem == m_lMediaDescriptor.end())
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE()] <<= true;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE] <<= true;
aWriteLock.clear();
// <- SAFE
}
@@ -851,7 +865,7 @@ bool LoadEnv::impl_handleContent()
osl::ClearableMutexGuard aReadLock(m_mutex);
// the type must exist inside the descriptor ... otherwise this class is implemented wrong :-)
- OUString sType = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME(), OUString());
+ OUString sType = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME, OUString());
if (sType.isEmpty())
throw LoadEnvException(LoadEnvException::ID_INVALID_MEDIADESCRIPTOR);
@@ -869,7 +883,7 @@ bool LoadEnv::impl_handleContent()
// query
css::uno::Sequence< OUString > lTypeReg { sType };
- css::uno::Sequence< css::beans::NamedValue > lQuery { { PROP_TYPES, css::uno::makeAny(lTypeReg) } };
+ css::uno::Sequence< css::beans::NamedValue > lQuery { { PROP_TYPES, css::uno::Any(lTypeReg) } };
css::uno::Reference< css::container::XEnumeration > xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
while(xSet->hasMoreElements())
@@ -892,11 +906,10 @@ bool LoadEnv::impl_handleContent()
// SAFE -> -----------------------------------
osl::ClearableMutexGuard aWriteLock(m_mutex);
m_xAsynchronousJob = xHandler;
- LoadEnvListener* pListener = new LoadEnvListener(this);
+ rtl::Reference<LoadEnvListener> xListener = new LoadEnvListener(this);
aWriteLock.clear();
// <- SAFE -----------------------------------
- css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pListener), css::uno::UNO_QUERY);
xHandler->dispatchWithNotification(aURL, lDescriptor, xListener);
return true;
@@ -917,7 +930,7 @@ bool LoadEnv::impl_furtherDocsAllowed()
try
{
- std::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get(xContext));
+ std::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get());
// NIL means: count of allowed documents = infinite !
// => return true
@@ -949,7 +962,7 @@ bool LoadEnv::impl_furtherDocsAllowed()
// SAFE ->
aReadLock.reset();
css::uno::Reference< css::task::XInteractionHandler > xInteraction = m_lMediaDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_INTERACTIONHANDLER(),
+ utl::MediaDescriptor::PROP_INTERACTIONHANDLER,
css::uno::Reference< css::task::XInteractionHandler >());
aReadLock.clear();
// <- SAFE
@@ -957,15 +970,13 @@ bool LoadEnv::impl_furtherDocsAllowed()
if (xInteraction.is())
{
css::uno::Any aInteraction;
- css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations(2);
- comphelper::OInteractionAbort* pAbort = new comphelper::OInteractionAbort();
- comphelper::OInteractionApprove* pApprove = new comphelper::OInteractionApprove();
+ rtl::Reference<comphelper::OInteractionAbort> pAbort = new comphelper::OInteractionAbort();
+ rtl::Reference<comphelper::OInteractionApprove> pApprove = new comphelper::OInteractionApprove();
- lContinuations[0].set( static_cast< css::task::XInteractionContinuation* >(pAbort),
- css::uno::UNO_QUERY_THROW);
- lContinuations[1].set( static_cast< css::task::XInteractionContinuation* >(pApprove),
- css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations{
+ pAbort, pApprove
+ };
css::task::ErrorCodeRequest aErrorCode;
aErrorCode.ErrCode = sal_uInt32(ERRCODE_SFX_NOMOREDOCUMENTSALLOWED);
@@ -985,11 +996,11 @@ bool LoadEnv::impl_filterHasInteractiveDialog() const
if (m_aURL.Arguments == "Interactive")
return true;
- // unless (tdf#116277) its the labels/business cards slave frame
+ // unless (tdf#116277) it's the labels/business cards slave frame
if (m_aURL.Arguments.indexOf("slot=") != -1)
return true;
- OUString sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME(), OUString());
+ OUString sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME, OUString());
if (sFilter.isEmpty())
return false;
@@ -1089,14 +1100,14 @@ bool LoadEnv::impl_loadContent()
// So we prevent our code against wrong using. Why?
// It could be, that using of this progress could make trouble. e.g. He makes window visible...
// but shouldn't do that. But if no indicator is available... nobody has a chance to do that!
- bool bHidden = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false);
- bool bMinimized = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MINIMIZED(), false);
- bool bPreview = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW(), false);
+ bool bHidden = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN, false);
+ bool bMinimized = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MINIMIZED, false);
+ bool bPreview = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW, false);
if (!bHidden && !bMinimized && !bPreview)
{
css::uno::Reference<css::task::XStatusIndicator> xProgress = m_lMediaDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_STATUSINDICATOR(), css::uno::Reference<css::task::XStatusIndicator>());
+ utl::MediaDescriptor::PROP_STATUSINDICATOR, css::uno::Reference<css::task::XStatusIndicator>());
if (!xProgress.is())
{
// Note: it's an optional interface!
@@ -1105,14 +1116,14 @@ bool LoadEnv::impl_loadContent()
{
xProgress = xProgressFactory->createStatusIndicator();
if (xProgress.is())
- m_lMediaDescriptor[utl::MediaDescriptor::PROP_STATUSINDICATOR()] <<= xProgress;
+ m_lMediaDescriptor[utl::MediaDescriptor::PROP_STATUSINDICATOR] <<= xProgress;
}
}
// Now that we have a target window into which we can load, reinit the interaction handler to have this
// window as its parent for modal dialogs and ensure the window is visible
css::uno::Reference< css::task::XInteractionHandler > xInteraction = m_lMediaDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_INTERACTIONHANDLER(),
+ utl::MediaDescriptor::PROP_INTERACTIONHANDLER,
css::uno::Reference< css::task::XInteractionHandler >());
css::uno::Reference<css::lang::XInitialization> xHandler(xInteraction, css::uno::UNO_QUERY);
if (xHandler.is())
@@ -1125,7 +1136,10 @@ bool LoadEnv::impl_loadContent()
xHandler->initialize(aArguments);
//show the frame as early as possible to make it the parent of any message dialogs
if (!impl_filterHasInteractiveDialog())
- impl_makeFrameWindowVisible(xWindow, false);
+ {
+ impl_makeFrameWindowVisible(xWindow, shouldFocusAndToFront());
+ m_bFocusedAndToFront = true; // no need to ask shouldFocusAndToFront second time
+ }
}
}
@@ -1142,11 +1156,10 @@ bool LoadEnv::impl_loadContent()
if (xAsyncLoader.is())
{
m_xAsynchronousJob = xAsyncLoader;
- LoadEnvListener* pListener = new LoadEnvListener(this);
+ rtl::Reference<LoadEnvListener> xListener = new LoadEnvListener(this);
aWriteLock.clear();
// <- SAFE -----------------------------------
- css::uno::Reference< css::frame::XLoadEventListener > xListener(static_cast< css::frame::XLoadEventListener* >(pListener), css::uno::UNO_QUERY);
xAsyncLoader->load(xTargetFrame, sURL, lDescriptor, xListener);
return true;
@@ -1158,7 +1171,7 @@ bool LoadEnv::impl_loadContent()
{
// Set the URL on the frame itself, for the duration of the load, when it has no
// controller.
- xTargetFrameProps->setPropertyValue("URL", uno::makeAny(sURL));
+ xTargetFrameProps->setPropertyValue("URL", uno::Any(sURL));
}
bool bResult = xSyncLoader->load(lDescriptor, xTargetFrame);
// react for the result here, so the outside waiting
@@ -1199,7 +1212,7 @@ css::uno::Reference< css::uno::XInterface > LoadEnv::impl_searchLoader()
// Otherwise...
// We need this type information to locate a registered frame loader
// Without such information we can't work!
- OUString sType = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME(), OUString());
+ OUString sType = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME, OUString());
if (sType.isEmpty())
throw LoadEnvException(LoadEnvException::ID_INVALID_MEDIADESCRIPTOR);
@@ -1211,7 +1224,7 @@ css::uno::Reference< css::uno::XInterface > LoadEnv::impl_searchLoader()
css::uno::Sequence< OUString > lTypesReg { sType };
- css::uno::Sequence< css::beans::NamedValue > lQuery { { PROP_TYPES, css::uno::makeAny(lTypesReg) } };
+ css::uno::Sequence< css::beans::NamedValue > lQuery { { PROP_TYPES, css::uno::Any(lTypesReg) } };
css::uno::Reference< css::container::XEnumeration > xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
while(xSet->hasMoreElements())
@@ -1274,9 +1287,9 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded()
// or better it's not allowed for some requests in general :-)
if (
( ! TargetHelper::matchSpecialTarget(m_sTarget, TargetHelper::ESpecialTarget::Default) ) ||
- m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE() , false) ||
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE , false) ||
// (m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN() , false) == sal_True) ||
- m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_OPENNEWVIEW(), false)
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_OPENNEWVIEW, false)
)
{
return css::uno::Reference< css::frame::XFrame >();
@@ -1305,7 +1318,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded()
// Note: To detect if a document was already loaded before
// we check URLs here only. But might the existing and the required
// document has different versions! Then its URLs are the same...
- sal_Int16 nNewVersion = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_VERSION(), sal_Int16(-1));
+ sal_Int16 nNewVersion = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_VERSION, sal_Int16(-1));
// will be used to save the first hidden frame referring the searched model
// Normally we are interested on visible frames... but if there is no such visible
@@ -1373,7 +1386,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded()
lOldDocDescriptor = xModel->getArgs();
if (lOldDocDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_VERSION(), sal_Int32(-1))
+ utl::MediaDescriptor::PROP_VERSION, sal_Int32(-1))
!= nNewVersion)
{
xTask.clear();
@@ -1384,7 +1397,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded()
// Hidden frames are special.
// They will be used as "last chance" if there is no visible frame pointing to the same model.
// Safe the result but continue with current loop might be looking for other visible frames.
- bool bIsHidden = lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false);
+ bool bIsHidden = lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN, false);
if ( bIsHidden && ! xHiddenTask.is() )
{
xHiddenTask = xTask;
@@ -1415,15 +1428,13 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded()
// if an optional jumpmark is given too.
if (!m_aURL.Mark.isEmpty())
impl_jumpToMark(xResult, m_aURL);
-
- // bring it to front and make sure it's visible...
- impl_makeFrameWindowVisible(xResult->getContainerWindow(), true);
}
return xResult;
}
-bool LoadEnv::impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame) const
+// static
+bool LoadEnv::impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame)
{
css::uno::Reference< css::document::XActionLockable > xLock(xFrame, css::uno::UNO_QUERY);
@@ -1446,7 +1457,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget()
// It doesn't matter if somewhere wants to create a new view
// or open a new untitled document...
// The only exception from that - hidden frames!
- if (m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false))
+ if (m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN, false))
return css::uno::Reference< css::frame::XFrame >();
css::uno::Reference< css::frame::XFramesSupplier > xSupplier = css::frame::Desktop::create( m_xContext );
@@ -1455,8 +1466,6 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget()
{
if (!impl_isFrameAlreadyUsedForLoading(aTasksAnalyzer.m_xBackingComponent))
{
- // bring it to front...
- impl_makeFrameWindowVisible(aTasksAnalyzer.m_xBackingComponent->getContainerWindow(), true);
m_bReactivateControllerOnError = true;
return aTasksAnalyzer.m_xBackingComponent;
}
@@ -1464,8 +1473,8 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget()
// These states indicates a wish for creation of a new view in general.
if (
- m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE() , false) ||
- m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_OPENNEWVIEW(), false)
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE , false) ||
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_OPENNEWVIEW, false)
)
{
return css::uno::Reference< css::frame::XFrame >();
@@ -1549,7 +1558,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget()
utl::MediaDescriptor lOldDocDescriptor(xModel->getArgs());
// replaceable document
- if (!lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REPLACEABLE(), false))
+ if (!lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REPLACEABLE, false))
return css::uno::Reference< css::frame::XFrame >();
bReactivateOldControllerOnError = xOldDoc->suspend(true);
@@ -1569,9 +1578,6 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget()
}
// <- SAFE ..................................
- // bring it to front ...
- impl_makeFrameWindowVisible(xTask->getContainerWindow(), true);
-
return xTask;
}
@@ -1588,8 +1594,8 @@ void LoadEnv::impl_reactForLoadingState()
// Note: We show new created frames here only.
// We don't hide already visible frames here ...
css::uno::Reference< css::awt::XWindow > xWindow = m_xTargetFrame->getContainerWindow();
- bool bHidden = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false);
- bool bMinimized = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MINIMIZED(), false);
+ bool bHidden = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN, false);
+ bool bMinimized = m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MINIMIZED, false);
if (bMinimized)
{
@@ -1603,13 +1609,13 @@ void LoadEnv::impl_reactForLoadingState()
{
// show frame ... if it's not still visible ...
// But do nothing if it's already visible!
- impl_makeFrameWindowVisible(xWindow, false);
+ impl_makeFrameWindowVisible(xWindow, !m_bFocusedAndToFront && shouldFocusAndToFront());
}
// Note: Only if an existing property "FrameName" is given by this media descriptor,
// it should be used. Otherwise we should do nothing. May be the outside code has already
// set a frame name on the target!
- utl::MediaDescriptor::const_iterator pFrameName = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FRAMENAME());
+ utl::MediaDescriptor::const_iterator pFrameName = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FRAMENAME);
if (pFrameName != m_lMediaDescriptor.end())
{
OUString sFrameName;
@@ -1690,33 +1696,27 @@ void LoadEnv::impl_reactForLoadingState()
// <- SAFE ----------------------------------
}
+bool LoadEnv::shouldFocusAndToFront() const
+{
+ bool const preview(
+ m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW, false));
+ return !preview
+ && officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get();
+}
+
+// static
void LoadEnv::impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow ,
bool bForceToFront)
{
- // SAFE -> ----------------------------------
- osl::ClearableMutexGuard aReadLock(m_mutex);
- css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
- aReadLock.clear();
- // <- SAFE ----------------------------------
-
SolarMutexGuard aSolarGuard;
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
if ( !pWindow )
return;
- bool const preview( m_lMediaDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_PREVIEW(), false) );
-
- bool bForceFrontAndFocus(false);
- if ( !preview )
- {
- bForceFrontAndFocus = officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext);
- }
-
- if( pWindow->IsVisible() && (bForceFrontAndFocus || bForceToFront) )
+ if (pWindow->IsVisible() && bForceToFront)
pWindow->ToTop( ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask );
else
- pWindow->Show(true, (bForceFrontAndFocus || bForceToFront) ? ShowFlags::ForegroundTask : ShowFlags::NONE );
+ pWindow->Show(true, bForceToFront ? ShowFlags::ForegroundTask : ShowFlags::NONE);
}
void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow)
@@ -1760,7 +1760,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw
// no filter -> no module -> no persistent window state
OUString sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_FILTERNAME(),
+ utl::MediaDescriptor::PROP_FILTERNAME,
OUString());
if (sFilter.isEmpty())
return;
@@ -1780,7 +1780,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw
OUString sModule = lProps.getUnpackedValueOrDefault(FILTER_PROPNAME_ASCII_DOCUMENTSERVICE, OUString());
// get access to the configuration of this office module
- css::uno::Reference< css::container::XNameAccess > xModuleCfg(officecfg::Setup::Office::Factories::get(xContext));
+ css::uno::Reference< css::container::XNameAccess > xModuleCfg(officecfg::Setup::Office::Factories::get());
// read window state from the configuration
// and apply it on the window.
@@ -1806,7 +1806,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw
return;
SystemWindow* pSystemWindow = static_cast<SystemWindow*>(pWindowCheck.get());
- pSystemWindow->SetWindowState(OUStringToOString(sWindowState,RTL_TEXTENCODING_UTF8));
+ pSystemWindow->SetWindowState(sWindowState);
// <- SOLAR SAFE
}
}
diff --git a/framework/source/loadenv/targethelper.cxx b/framework/source/loadenv/targethelper.cxx
index d531f81bc04f..7c06521da6d3 100644
--- a/framework/source/loadenv/targethelper.cxx
+++ b/framework/source/loadenv/targethelper.cxx
@@ -43,12 +43,12 @@ bool TargetHelper::matchSpecialTarget(std::u16string_view sCheckTarget ,
}
}
-bool TargetHelper::isValidNameForFrame(const OUString& sName)
+bool TargetHelper::isValidNameForFrame(std::u16string_view sName)
{
// some special targets are really special ones :-)
// E.g. the are really used to locate one frame inside the frame tree.
if (
- (sName.isEmpty() ) ||
+ (sName.empty() ) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::HelpTask)) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::Beamer) )
)
@@ -56,7 +56,7 @@ bool TargetHelper::isValidNameForFrame(const OUString& sName)
// all other names must be checked more general
// special targets starts with a "_".
- return (sName.indexOf('_') != 0);
+ return (sName.find('_') != 0);
}
} // namespace framework
diff --git a/framework/source/recording/dispatchrecorder.cxx b/framework/source/recording/dispatchrecorder.cxx
index 0a370ef3fa0b..347c23c16a9c 100644
--- a/framework/source/recording/dispatchrecorder.cxx
+++ b/framework/source/recording/dispatchrecorder.cxx
@@ -34,7 +34,7 @@ using namespace ::com::sun::star::uno;
namespace framework{
// used to mark a dispatch as comment (mostly it indicates an error) Changing of this define will impact all using of such comments...
-#define REM_AS_COMMENT "rem "
+constexpr OUString REM_AS_COMMENT = u"rem "_ustr;
// XInterface, XTypeProvider, XServiceInfo
@@ -145,14 +145,15 @@ OUString SAL_CALL DispatchRecorder::getRecordedMacro()
aScriptBuffer.ensureCapacity(10000);
m_nRecordingID = 1;
- aScriptBuffer.append("rem ----------------------------------------------------------------------\n");
- aScriptBuffer.append("rem define variables\n");
- aScriptBuffer.append("dim document as object\n");
- aScriptBuffer.append("dim dispatcher as object\n");
- aScriptBuffer.append("rem ----------------------------------------------------------------------\n");
- aScriptBuffer.append("rem get access to the document\n");
- aScriptBuffer.append("document = ThisComponent.CurrentController.Frame\n");
- aScriptBuffer.append("dispatcher = createUnoService(\"com.sun.star.frame.DispatchHelper\")\n\n");
+ aScriptBuffer.append(
+ "rem ----------------------------------------------------------------------\n"
+ "rem define variables\n"
+ "dim document as object\n"
+ "dim dispatcher as object\n"
+ "rem ----------------------------------------------------------------------\n"
+ "rem get access to the document\n"
+ "document = ThisComponent.CurrentController.Frame\n"
+ "dispatcher = createUnoService(\"com.sun.star.frame.DispatchHelper\")\n\n");
for (auto const& statement : m_aStatements)
implts_recordMacro( statement.aCommand, statement.aArgs, statement.bIsComment, aScriptBuffer );
@@ -287,7 +288,7 @@ void DispatchRecorder::AppendToBuffer( const css::uno::Any& aValue, OUStringBuff
}
}
-void DispatchRecorder::implts_recordMacro( const OUString& aURL,
+void DispatchRecorder::implts_recordMacro( std::u16string_view aURL,
const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
bool bAsComment, OUStringBuffer& aScriptBuffer )
{
@@ -320,22 +321,17 @@ void DispatchRecorder::implts_recordMacro( const OUString& aURL,
// add arg().Name
if(bAsComment)
aArgumentBuffer.append(REM_AS_COMMENT);
- aArgumentBuffer.append (sArrayName);
- aArgumentBuffer.append("(");
- aArgumentBuffer.append (nValidArgs);
- aArgumentBuffer.append(").Name = \"");
- aArgumentBuffer.append (lArguments[i].Name);
- aArgumentBuffer.append("\"\n");
+ aArgumentBuffer.append(sArrayName
+ + "(" + OUString::number(nValidArgs)
+ + ").Name = \"" + lArguments[i].Name
+ + "\"\n");
// add arg().Value
if(bAsComment)
aArgumentBuffer.append(REM_AS_COMMENT);
- aArgumentBuffer.append (sArrayName);
- aArgumentBuffer.append("(");
- aArgumentBuffer.append (nValidArgs);
- aArgumentBuffer.append(").Value = ");
- aArgumentBuffer.append (sValBuffer.makeStringAndClear());
- aArgumentBuffer.append("\n");
+ aArgumentBuffer.append(sArrayName
+ + "(" + OUString::number(nValidArgs)
+ + ").Value = " + sValBuffer + "\n");
++nValidArgs;
}
@@ -351,7 +347,7 @@ void DispatchRecorder::implts_recordMacro( const OUString& aURL,
aScriptBuffer.append("(");
aScriptBuffer.append (static_cast<sal_Int32>(nValidArgs-1)); // 0 based!
aScriptBuffer.append(") as new com.sun.star.beans.PropertyValue\n");
- aScriptBuffer.append (aArgumentBuffer.makeStringAndClear());
+ aScriptBuffer.append (aArgumentBuffer);
aScriptBuffer.append("\n");
}
@@ -392,9 +388,8 @@ sal_Int32 SAL_CALL DispatchRecorder::getCount()
css::uno::Any SAL_CALL DispatchRecorder::getByIndex(sal_Int32 idx)
{
- if (idx >= static_cast<sal_Int32>(m_aStatements.size())) {
+ if (idx >= static_cast<sal_Int32>(m_aStatements.size()))
throw css::lang::IndexOutOfBoundsException( "Dispatch recorder out of bounds" );
- }
Any element(&m_aStatements[idx],
cppu::UnoType<css::frame::DispatchStatement>::get());
@@ -411,22 +406,18 @@ void SAL_CALL DispatchRecorder::replaceByIndex(sal_Int32 idx, const css::uno::An
Reference< XInterface >(), 2 );
}
- if (idx >= static_cast<sal_Int32>(m_aStatements.size())) {
- throw css::lang::IndexOutOfBoundsException(
+ if (idx >= static_cast<sal_Int32>(m_aStatements.size()))
+ throw css::lang::IndexOutOfBoundsException(
"Dispatch recorder out of bounds" );
- }
-
auto pStatement = o3tl::doAccess<css::frame::DispatchStatement>(element);
- css::frame::DispatchStatement aStatement(
+ m_aStatements[idx] = css::frame::DispatchStatement(
pStatement->aCommand,
pStatement->aTarget,
pStatement->aArgs,
pStatement->nFlags,
pStatement->bIsComment);
-
- m_aStatements[idx] = aStatement;
}
} // namespace framework
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index fe24c2b6d770..1cf4a670cf5a 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -23,11 +23,13 @@
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <cppuhelper/basemutex.hxx>
+#include <rtl/ref.hxx>
+#include <osl/diagnose.h>
#include <algorithm>
#include <map>
@@ -38,22 +40,21 @@ using namespace css::uno;
namespace {
-typedef ::cppu::WeakComponentImplHelper <
+typedef comphelper::WeakComponentImplHelper <
css::ui::XContextChangeEventMultiplexer,
css::lang::XServiceInfo,
css::lang::XEventListener
> ContextChangeEventMultiplexerInterfaceBase;
class ContextChangeEventMultiplexer
- : private ::cppu::BaseMutex,
- public ContextChangeEventMultiplexerInterfaceBase
+ : public ContextChangeEventMultiplexerInterfaceBase
{
public:
ContextChangeEventMultiplexer();
ContextChangeEventMultiplexer(const ContextChangeEventMultiplexer&) = delete;
ContextChangeEventMultiplexer& operator=(const ContextChangeEventMultiplexer&) = delete;
- virtual void SAL_CALL disposing() override;
+ virtual void disposing(std::unique_lock<std::mutex>&) override;
// XContextChangeEventMultiplexer
virtual void SAL_CALL addContextChangeEventListener (
@@ -104,16 +105,16 @@ public:
};
ContextChangeEventMultiplexer::ContextChangeEventMultiplexer()
- : ContextChangeEventMultiplexerInterfaceBase(m_aMutex),
- maListeners()
{
}
-void SAL_CALL ContextChangeEventMultiplexer::disposing()
+void ContextChangeEventMultiplexer::disposing(std::unique_lock<std::mutex>& rGuard)
{
ListenerMap aListeners;
aListeners.swap(maListeners);
+ rGuard.unlock();
+
css::uno::Reference<css::uno::XInterface> xThis (static_cast<XWeak*>(this));
css::lang::EventObject aEvent (xThis);
for (auto const& container : aListeners)
@@ -161,23 +162,6 @@ void SAL_CALL ContextChangeEventMultiplexer::addContextChangeEventListener (
if (!(rxEventFocus.is() && pFocusDescriptor!=nullptr))
return;
- if (pFocusDescriptor->msCurrentApplicationName.isEmpty() && pFocusDescriptor->msCurrentContextName.isEmpty()
- && rxEventFocus.is())
- {
- Reference< lang::XServiceInfo > xServInfo( rxEventFocus, uno::UNO_QUERY );
- if( xServInfo.is() && xServInfo->getImplementationName() == "com.sun.star.comp.chart2.ChartController")
- {
- css::ui::ContextChangeEventObject aEvent (
- rxEventFocus,
- "com.sun.star.chart2.ChartDocument",
- "Chart");
- rxListener->notifyContextChangeEvent(aEvent);
-
- return;
- }
-
- }
-
css::ui::ContextChangeEventObject aEvent (
nullptr,
pFocusDescriptor->msCurrentApplicationName,
@@ -324,34 +308,22 @@ void SAL_CALL ContextChangeEventMultiplexer::disposing ( const css::lang::EventO
maListeners.erase(iDescriptor);
}
-struct Instance {
- explicit Instance():
- instance(static_cast<cppu::OWeakObject *>(
- new ContextChangeEventMultiplexer()))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::Static<Instance, Singleton>
-{};
-
}
namespace framework {
// right now we assume there's one matching listener
static uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith_ImplImpl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(xEventFocus.is()); // in current usage it's a bug if the XController is null here
uno::Reference<ui::XContextChangeEventListener> xRet;
- ContextChangeEventMultiplexer *const pMultiplexer(
- dynamic_cast<ContextChangeEventMultiplexer *>(Singleton::get().instance.get()));
+ rtl::Reference<ContextChangeEventMultiplexer> pMultiplexer =
+ // [-loplugin:unocast]
+ dynamic_cast<ContextChangeEventMultiplexer *>(ui::ContextChangeEventMultiplexer::get(xComponentContext).get());
assert(pMultiplexer);
ContextChangeEventMultiplexer::FocusDescriptor const*const pFocusDescriptor(
@@ -389,8 +361,7 @@ org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implement
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get().instance.get()));
+ return cppu::acquire(new ContextChangeEventMultiplexer());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 76594a4ec5f3..d1341bee4dba 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -34,7 +34,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
-#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/frame/XModel3.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/XTitle.hpp>
#include <com/sun/star/frame/XFrame.hpp>
@@ -50,11 +50,12 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-#include <com/sun/star/document/XDocumentRecovery.hpp>
+#include <com/sun/star/document/XDocumentRecovery2.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/awt/XWindow2.hpp>
#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -74,16 +75,22 @@
#include <cppuhelper/supportsservice.hxx>
#include <o3tl/safeint.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/string_view.hxx>
+#include <unotools/fcm.hxx>
#include <unotools/mediadescriptor.hxx>
+#include <comphelper/multiinterfacecontainer3.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/sequence.hxx>
+#include <utility>
#include <vcl/evntpost.hxx>
#include <vcl/svapp.hxx>
#include <vcl/timer.hxx>
#include <unotools/pathoptions.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <unotools/tempfile.hxx>
+#include <unotools/ucbhelper.hxx>
#include <ucbhelper/content.hxx>
+#include <svtools/sfxecode.hxx>
#include <vcl/weld.hxx>
#include <osl/file.hxx>
@@ -92,23 +99,57 @@
#include <unotools/configmgr.hxx>
#include <svl/documentlockfile.hxx>
#include <tools/urlobj.hxx>
+#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/Recovery.hxx>
#include <officecfg/Setup.hxx>
-#include <stdtypes.h>
-
using namespace css::uno;
using namespace css::document;
using namespace css::frame;
using namespace css::lang;
using namespace framework;
+/** After the fact documentation - hopefully it is correct.
+ *
+ * AutoRecovery handles 3 types of recovery, as well as periodic document saving
+ * 1) timed, ODF, temporary, recovery files created in the backup folder
+ * -can instead be used to actually save the documents periodically if settings request that.
+ * -temporary: deleted when the document itself is saved
+ * -handles the situation where LO immediately exits (power outage, program crash, pkill -9 soffice)
+ * -not restored immediately
+ * -no guarantee of availability of recovery file (since deleted on document save)
+ * or original document (perhaps /tmp, removeable, disconnected server).
+ * -therefore does not include unmodified files in RecoveryList (@since LO 24.2).
+ * -TODO: perhaps can be enhanced for users who always want sessions restored?
+ * 2) emergency save-and-restart immediately triggers creation of temporary, ODF, recovery files
+ * -handles the situation where LO is partially functioning (pkill -6 soffice)
+ * -restore attempted immediately, so try to restore entire session - all open files
+ * -always create recovery file for every open document in emergency situation
+ * -works without requiring AutoRecovery to be enabled
+ * 3) session save on exit desired by OS or user creates recovery files for every open document
+ * -triggered by some OS's shutdown/logout (no known way for user to initiate within LO)
+ * -same as emergency save, except maybe more time critical - OS kill timeout
+ * -not restored until much later - the user has stopped doing computer work
+ * -always create recovery file for every open document: needed for /tmp, disconnected docs
+ *
+ * All of these use the same recovery dialog - re-opening all the files listed in the RecoveryList
+ * of the user's officecfg settings.
+ *
+ * Since these 3 have very different expectations, and yet share the same code, keep all of them
+ * in mind when making code changes.
+ *
+ * Note: often, entries in m_lDocCache are copied. So realize that changes to aInfo/rInfo might not
+ * apply to async events like mark-document-as-saved-and-delete-TMP-URLs or set-modified-status,
+ * or ignoreClosing, or ListenForModify. For example, DocState::Modified should be considered only
+ * a good hint, and not as definitively accurate.
+ */
+
namespace {
/** @short hold all needed information for an asynchronous dispatch alive.
@descr Because some operations are forced to be executed asynchronously
- (e.g. requested by our CreashSave/Recovery dialog) ... we must make sure
+ (e.g. requested by our CrashSave/Recovery dialog) ... we must make sure
that this information won't be set as "normal" members of our AutoRecovery
instance. Otherwise they can disturb our normal AutoSave-timer handling.
e.g. it can be unclear then, which progress has to be used for storing documents...
@@ -321,8 +362,8 @@ public:
OUString FactoryURL;
OUString TemplateURL;
- OUString OldTempURL;
- OUString NewTempURL;
+ OUString OldTempURL; // previous recovery file (filename_0.odf) which will be removed
+ OUString NewTempURL; // new recovery file (filename_1.odf) that is being created
OUString AppModule; // e.g. com.sun.star.text.TextDocument - used to identify app module
OUString FactoryService; // the service to create a document of the module
@@ -381,11 +422,6 @@ private:
bool m_bListenForDocEvents;
bool m_bListenForConfigChanges;
- /** @short specify the time interval between two save actions.
- @descr tools::Time is measured in [min].
- */
- sal_Int32 m_nAutoSaveTimeIntervall;
-
/** @short for an asynchronous operation we must know, if there is
at least one running job (may be asynchronous!).
*/
@@ -419,7 +455,7 @@ private:
/** @short contains all status listener registered at this instance.
*/
- ListenerHash m_lListener;
+ comphelper::OMultiTypeInterfaceContainerHelperVar3<css::frame::XStatusListener, OUString> m_lListener;
/** @descr This member is used to prevent us against re-entrance problems.
A mutex can't help to prevent us from concurrent using of members
@@ -448,7 +484,7 @@ private:
public:
- explicit AutoRecovery(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit AutoRecovery(css::uno::Reference< css::uno::XComponentContext > xContext);
virtual ~AutoRecovery( ) override;
virtual OUString SAL_CALL getImplementationName() override
@@ -467,9 +503,9 @@ public:
}
// XInterface
- virtual void SAL_CALL acquire() throw () override
+ virtual void SAL_CALL acquire() noexcept override
{ OWeakObject::acquire(); }
- virtual void SAL_CALL release() throw () override
+ virtual void SAL_CALL release() noexcept override
{ OWeakObject::release(); }
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override;
@@ -574,9 +610,19 @@ private:
*/
void implts_readAutoSaveConfig();
- // TODO document me
- void implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rInfo ,
- bool bRemoveIt = false);
+ /** After the fact documentation
+ * @short adds/updates/removes entries in the RecoveryList - files to be recovered at startup
+ *
+ * @descr Deciding whether to add or remove an entry is very dependent on the context!
+ * EmergencySave and SessionSave are interested in all open documents (which may not
+ * even be available at next start - i.e. /tmp files might be lost after a reboot,
+ * or removable media / server access might not be connected).
+ * On the other hand, timer-based autorecovery should not be interested in recovering
+ * the session, but only modified documents that are recoverable
+ * (TODO: unless the user always wants to recover a session).
+ */
+ void implts_flushConfigItem(AutoRecovery::TDocumentInfo& rInfo, bool bRemoveIt = false,
+ bool bAllowAdd = true);
// TODO document me
void implts_startListening();
@@ -636,12 +682,12 @@ private:
@threadsafe
*/
- void implts_registerDocument(const css::uno::Reference< css::frame::XModel >& xDocument);
+ void implts_registerDocument(const css::uno::Reference< css::frame::XModel3 >& xDocument);
/** @short remove the specified document from our internal document list.
@param xDocument
- the new document, which should be deregistered.
+ the closing document, which should be deregistered.
@param bStopListening
sal_False: must be used in case this method is called within disposing() of the document,
@@ -679,7 +725,7 @@ private:
@return [TDocumentList::iterator]
which points to the located document.
- If document does not exists - its set to
+ If document does not exists - it's set to
rList.end()!
*/
static TDocumentList::iterator impl_searchDocument( AutoRecovery::TDocumentList& rList ,
@@ -895,7 +941,7 @@ private:
Note: This method can't fail. Flushing of config entries is an
optional feature. Errors can be ignored.
*/
- void impl_flushALLConfigChanges();
+ static void impl_flushALLConfigChanges();
// TODO document me
AutoRecovery::EFailureSafeResult implts_copyFile(const OUString& sSource ,
@@ -960,11 +1006,11 @@ private:
@param rArgs
is used to set the new created progress as parameter on these set.
*/
- void impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo ,
+ static void impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo ,
utl::MediaDescriptor& rArgs ,
const css::uno::Reference< css::frame::XFrame >& xNewFrame);
- void impl_forgetProgress(const AutoRecovery::TDocumentInfo& rInfo ,
+ static void impl_forgetProgress(const AutoRecovery::TDocumentInfo& rInfo ,
utl::MediaDescriptor& rArgs ,
const css::uno::Reference< css::frame::XFrame >& xNewFrame);
@@ -995,23 +1041,23 @@ private:
};
// recovery.xcu
-constexpr OUStringLiteral CFG_PACKAGE_RECOVERY = u"org.openoffice.Office.Recovery/";
+constexpr OUStringLiteral CFG_PACKAGE_RECOVERY = u"/org.openoffice.Office.Recovery";
const char CFG_ENTRY_AUTOSAVE_ENABLED[] = "AutoSave/Enabled";
-const char CFG_ENTRY_AUTOSAVE_TIMEINTERVALL[] = "AutoSave/TimeIntervall"; //sic!
+const char CFG_ENTRY_AUTOSAVE_USERAUTOSAVE_ENABLED[] = "AutoSave/UserAutoSaveEnabled";
constexpr OUStringLiteral CFG_ENTRY_REALDEFAULTFILTER = u"ooSetupFactoryActualFilter";
-constexpr OUStringLiteral CFG_ENTRY_PROP_TEMPURL = u"TempURL";
-constexpr OUStringLiteral CFG_ENTRY_PROP_ORIGINALURL = u"OriginalURL";
-constexpr OUStringLiteral CFG_ENTRY_PROP_TEMPLATEURL = u"TemplateURL";
+constexpr OUString CFG_ENTRY_PROP_TEMPURL = u"TempURL"_ustr;
+constexpr OUString CFG_ENTRY_PROP_ORIGINALURL = u"OriginalURL"_ustr;
+constexpr OUString CFG_ENTRY_PROP_TEMPLATEURL = u"TemplateURL"_ustr;
constexpr OUStringLiteral CFG_ENTRY_PROP_FACTORYURL = u"FactoryURL";
-constexpr OUStringLiteral CFG_ENTRY_PROP_MODULE = u"Module";
-constexpr OUStringLiteral CFG_ENTRY_PROP_DOCUMENTSTATE = u"DocumentState";
-constexpr OUStringLiteral CFG_ENTRY_PROP_FILTER = u"Filter";
-constexpr OUStringLiteral CFG_ENTRY_PROP_TITLE = u"Title";
+constexpr OUString CFG_ENTRY_PROP_MODULE = u"Module"_ustr;
+constexpr OUString CFG_ENTRY_PROP_DOCUMENTSTATE = u"DocumentState"_ustr;
+constexpr OUString CFG_ENTRY_PROP_FILTER = u"Filter"_ustr;
+constexpr OUString CFG_ENTRY_PROP_TITLE = u"Title"_ustr;
constexpr OUStringLiteral CFG_ENTRY_PROP_ID = u"ID";
-constexpr OUStringLiteral CFG_ENTRY_PROP_VIEWNAMES = u"ViewNames";
+constexpr OUString CFG_ENTRY_PROP_VIEWNAMES = u"ViewNames"_ustr;
constexpr OUStringLiteral FILTER_PROP_TYPE = u"Type";
constexpr OUStringLiteral TYPE_PROP_EXTENSIONS = u"Extensions";
@@ -1020,35 +1066,35 @@ constexpr OUStringLiteral TYPE_PROP_EXTENSIONS = u"Extensions";
constexpr OUStringLiteral CFG_ENTRY_PROP_EMPTYDOCUMENTURL = u"ooSetupFactoryEmptyDocumentURL";
constexpr OUStringLiteral CFG_ENTRY_PROP_FACTORYSERVICE = u"ooSetupFactoryDocumentService";
-const char EVENT_ON_NEW[] = "OnNew";
-const char EVENT_ON_LOAD[] = "OnLoad";
-const char EVENT_ON_UNLOAD[] = "OnUnload";
-const char EVENT_ON_MODIFYCHANGED[] = "OnModifyChanged";
-const char EVENT_ON_SAVE[] = "OnSave";
-const char EVENT_ON_SAVEAS[] = "OnSaveAs";
-const char EVENT_ON_SAVETO[] = "OnCopyTo";
-const char EVENT_ON_SAVEDONE[] = "OnSaveDone";
-const char EVENT_ON_SAVEASDONE[] = "OnSaveAsDone";
-const char EVENT_ON_SAVETODONE[] = "OnCopyToDone";
-const char EVENT_ON_SAVEFAILED[] = "OnSaveFailed";
-const char EVENT_ON_SAVEASFAILED[] = "OnSaveAsFailed";
-const char EVENT_ON_SAVETOFAILED[] = "OnCopyToFailed";
-
-constexpr OUStringLiteral RECOVERY_ITEM_BASE_IDENTIFIER = u"recovery_item_";
-
-const char CMD_PROTOCOL[] = "vnd.sun.star.autorecovery:";
-
-const char CMD_DO_AUTO_SAVE[] = "/doAutoSave"; // force AutoSave ignoring the AutoSave timer
-const char CMD_DO_PREPARE_EMERGENCY_SAVE[] = "/doPrepareEmergencySave"; // prepare the office for the following EmergencySave step (hide windows etcpp.)
-const char CMD_DO_EMERGENCY_SAVE[] = "/doEmergencySave"; // do EmergencySave on crash
-const char CMD_DO_RECOVERY[] = "/doAutoRecovery"; // recover all crashed documents
-const char CMD_DO_ENTRY_BACKUP[] = "/doEntryBackup"; // try to store a temp or original file to a user defined location
-const char CMD_DO_ENTRY_CLEANUP[] = "/doEntryCleanUp"; // remove the specified entry from the recovery cache
-const char CMD_DO_SESSION_SAVE[] = "/doSessionSave"; // save all open documents if e.g. a window manager closes an user session
-const char CMD_DO_SESSION_QUIET_QUIT[] = "/doSessionQuietQuit"; // let the current session be quietly closed ( the saving should be done using doSessionSave previously ) if e.g. a window manager closes an user session
-const char CMD_DO_SESSION_RESTORE[] = "/doSessionRestore"; // restore a saved user session from disc
-const char CMD_DO_DISABLE_RECOVERY[] = "/disableRecovery"; // disable recovery and auto save (!) temp. for this office session
-const char CMD_DO_SET_AUTOSAVE_STATE[] = "/setAutoSaveState"; // disable/enable auto save (not crash save) for this office session
+constexpr OUStringLiteral EVENT_ON_NEW = u"OnNew";
+constexpr OUStringLiteral EVENT_ON_LOAD = u"OnLoad";
+constexpr OUStringLiteral EVENT_ON_UNLOAD = u"OnUnload";
+constexpr OUStringLiteral EVENT_ON_MODIFYCHANGED = u"OnModifyChanged";
+constexpr OUStringLiteral EVENT_ON_SAVE = u"OnSave";
+constexpr OUStringLiteral EVENT_ON_SAVEAS = u"OnSaveAs";
+constexpr OUStringLiteral EVENT_ON_SAVETO = u"OnCopyTo";
+constexpr OUStringLiteral EVENT_ON_SAVEDONE = u"OnSaveDone";
+constexpr OUStringLiteral EVENT_ON_SAVEASDONE = u"OnSaveAsDone";
+constexpr OUStringLiteral EVENT_ON_SAVETODONE = u"OnCopyToDone";
+constexpr OUStringLiteral EVENT_ON_SAVEFAILED = u"OnSaveFailed";
+constexpr OUStringLiteral EVENT_ON_SAVEASFAILED = u"OnSaveAsFailed";
+constexpr OUStringLiteral EVENT_ON_SAVETOFAILED = u"OnCopyToFailed";
+
+constexpr OUString RECOVERY_ITEM_BASE_IDENTIFIER = u"recovery_item_"_ustr;
+
+constexpr OUString CMD_PROTOCOL = u"vnd.sun.star.autorecovery:"_ustr;
+
+constexpr OUString CMD_DO_AUTO_SAVE = u"/doAutoSave"_ustr; // force AutoSave ignoring the AutoSave timer
+constexpr OUString CMD_DO_PREPARE_EMERGENCY_SAVE = u"/doPrepareEmergencySave"_ustr; // prepare the office for the following EmergencySave step (hide windows etcpp.)
+constexpr OUString CMD_DO_EMERGENCY_SAVE = u"/doEmergencySave"_ustr; // do EmergencySave on crash
+constexpr OUString CMD_DO_RECOVERY = u"/doAutoRecovery"_ustr; // recover all crashed documents
+constexpr OUString CMD_DO_ENTRY_BACKUP = u"/doEntryBackup"_ustr; // try to store a temp or original file to a user defined location
+constexpr OUString CMD_DO_ENTRY_CLEANUP = u"/doEntryCleanUp"_ustr; // remove the specified entry from the recovery cache
+constexpr OUString CMD_DO_SESSION_SAVE = u"/doSessionSave"_ustr; // save all open documents if e.g. a window manager closes an user session
+constexpr OUString CMD_DO_SESSION_QUIET_QUIT = u"/doSessionQuietQuit"_ustr; // let the current session be quietly closed ( the saving should be done using doSessionSave previously ) if e.g. a window manager closes an user session
+constexpr OUString CMD_DO_SESSION_RESTORE = u"/doSessionRestore"_ustr; // restore a saved user session from disc
+constexpr OUString CMD_DO_DISABLE_RECOVERY = u"/disableRecovery"_ustr; // disable recovery and auto save (!) temp. for this office session
+constexpr OUString CMD_DO_SET_AUTOSAVE_STATE = u"/setAutoSaveState"_ustr; // disable/enable auto save (not crash save) for this office session
constexpr OUStringLiteral REFERRER_USER = u"private:user";
@@ -1058,9 +1104,9 @@ constexpr OUStringLiteral PROP_SAVEPATH = u"SavePath";
constexpr OUStringLiteral PROP_ENTRY_ID = u"EntryID";
constexpr OUStringLiteral PROP_AUTOSAVE_STATE = u"AutoSaveState";
-constexpr OUStringLiteral OPERATION_START = u"start";
-constexpr OUStringLiteral OPERATION_STOP = u"stop";
-constexpr OUStringLiteral OPERATION_UPDATE = u"update";
+constexpr OUString OPERATION_START = u"start"_ustr;
+constexpr OUString OPERATION_STOP = u"stop"_ustr;
+constexpr OUString OPERATION_UPDATE = u"update"_ustr;
const sal_Int32 MIN_DISCSPACE_DOCSAVE = 5; // [MB]
const sal_Int32 MIN_DISCSPACE_CONFIGSAVE = 1; // [MB]
@@ -1207,15 +1253,14 @@ void DispatchParams::forget()
m_xHoldRefForAsyncOpAlive.clear();
};
-AutoRecovery::AutoRecovery(const css::uno::Reference< css::uno::XComponentContext >& xContext)
+AutoRecovery::AutoRecovery(css::uno::Reference< css::uno::XComponentContext > xContext)
: AutoRecovery_BASE (m_aMutex)
, ::cppu::OPropertySetHelper(cppu::WeakComponentImplHelperBase::rBHelper)
- , m_xContext (xContext )
+ , m_xContext (std::move(xContext ))
, m_bListenForDocEvents (false )
, m_bListenForConfigChanges (false )
- , m_nAutoSaveTimeIntervall (0 )
, m_eJob (Job::NoJob)
- , m_aTimer ( "Auto save timer" )
+ , m_aTimer( "framework::AutoRecovery m_aTimer" )
, m_xAsyncDispatcher (new vcl::EventPoster( LINK( this, AutoRecovery, implts_asyncDispatch ) ))
, m_eTimerType (E_DONT_START_TIMER )
, m_nIdPool (0 )
@@ -1224,7 +1269,6 @@ AutoRecovery::AutoRecovery(const css::uno::Reference< css::uno::XComponentContex
, m_nMinSpaceDocSave (MIN_DISCSPACE_DOCSAVE )
, m_nMinSpaceConfigSave (MIN_DISCSPACE_CONFIGSAVE )
{
- m_aTimer.SetDebugName( "framework::AutoRecovery m_aTimer" );
}
void AutoRecovery::initListeners()
@@ -1537,7 +1581,7 @@ void SAL_CALL AutoRecovery::removeStatusListener(const css::uno::Reference< css:
void SAL_CALL AutoRecovery::documentEventOccured(const css::document::DocumentEvent& aEvent)
{
- css::uno::Reference< css::frame::XModel > xDocument(aEvent.Source, css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XModel3 > xDocument(aEvent.Source, css::uno::UNO_QUERY);
// new document => put it into the internal list
if (
@@ -1642,9 +1686,17 @@ void SAL_CALL AutoRecovery::changesOccurred(const css::util::ChangesEvent& aEven
}
}
}
- else
- if ( sPath == CFG_ENTRY_AUTOSAVE_TIMEINTERVALL )
- pChanges[i].Element >>= m_nAutoSaveTimeIntervall;
+ else if (sPath == CFG_ENTRY_AUTOSAVE_USERAUTOSAVE_ENABLED)
+ {
+ bool bEnabled = false;
+ if (pChanges[i].Element >>= bEnabled)
+ {
+ if (bEnabled)
+ m_eJob |= Job::UserAutoSave;
+ else
+ m_eJob &= ~Job::UserAutoSave;
+ }
+ }
}
} /* SAFE */
@@ -1726,8 +1778,8 @@ void AutoRecovery::implts_openConfig()
try
{
- nMinSpaceDocSave = officecfg::Office::Recovery::AutoSave::MinSpaceDocSave::get(m_xContext);
- nMinSpaceConfigSave = officecfg::Office::Recovery::AutoSave::MinSpaceConfigSave::get(m_xContext);
+ nMinSpaceDocSave = officecfg::Office::Recovery::AutoSave::MinSpaceDocSave::get();
+ nMinSpaceConfigSave = officecfg::Office::Recovery::AutoSave::MinSpaceConfigSave::get();
}
catch(const css::uno::Exception&)
{
@@ -1739,7 +1791,7 @@ void AutoRecovery::implts_openConfig()
/* SAFE */ {
osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
- m_xRecoveryCFG = xCFG;
+ m_xRecoveryCFG = std::move(xCFG);
m_nMinSpaceDocSave = nMinSpaceDocSave;
m_nMinSpaceConfigSave = nMinSpaceConfigSave;
} /* SAFE */
@@ -1750,13 +1802,13 @@ void AutoRecovery::implts_readAutoSaveConfig()
implts_openConfig();
// AutoSave [bool]
- bool bEnabled(officecfg::Office::Recovery::AutoSave::Enabled::get(m_xContext));
+ bool bEnabled(officecfg::Office::Recovery::AutoSave::Enabled::get());
/* SAFE */ {
osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
if (bEnabled)
{
- bool bUserEnabled(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get(m_xContext));
+ bool bUserEnabled(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get());
m_eJob |= Job::AutoSave;
m_eTimerType = AutoRecovery::E_NORMAL_AUTOSAVE_INTERVALL;
@@ -1776,14 +1828,6 @@ void AutoRecovery::implts_readAutoSaveConfig()
m_eTimerType = AutoRecovery::E_DONT_START_TIMER;
}
} /* SAFE */
-
- // AutoSaveTimeIntervall [int] in min
- sal_Int32 nTimeIntervall(officecfg::Office::Recovery::AutoSave::TimeIntervall::get(m_xContext));
-
- /* SAFE */ {
- osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
- m_nAutoSaveTimeIntervall = nTimeIntervall;
- } /* SAFE */
}
void AutoRecovery::implts_readConfig()
@@ -1804,8 +1848,7 @@ void AutoRecovery::implts_readConfig()
// <- REENTRANT --------------------------------
css::uno::Reference<css::container::XNameAccess> xRecoveryList(
- officecfg::Office::Recovery::RecoveryList::get(m_xContext));
- const OUString sRECOVERY_ITEM_BASE_IDENTIFIER(RECOVERY_ITEM_BASE_IDENTIFIER);
+ officecfg::Office::Recovery::RecoveryList::get());
const css::uno::Sequence< OUString > lItems = xRecoveryList->getElementNames();
const OUString* pItems = lItems.getConstArray();
sal_Int32 c = lItems.getLength();
@@ -1837,10 +1880,10 @@ void AutoRecovery::implts_readConfig()
implts_specifyAppModuleAndFactory(aInfo);
implts_specifyDefaultFilterAndExtension(aInfo);
- if (pItems[i].startsWith(sRECOVERY_ITEM_BASE_IDENTIFIER))
+ if (pItems[i].startsWith(RECOVERY_ITEM_BASE_IDENTIFIER))
{
- OUString sID = pItems[i].copy(sRECOVERY_ITEM_BASE_IDENTIFIER.getLength());
- aInfo.ID = sID.toInt32();
+ std::u16string_view sID = pItems[i].subView(RECOVERY_ITEM_BASE_IDENTIFIER.getLength());
+ aInfo.ID = o3tl::toInt32(sID);
/* SAFE */ {
osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
if (aInfo.ID > m_nIdPool)
@@ -1886,7 +1929,7 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume
{
implts_openConfig();
// open module config on demand and cache the update access
- xCFG.set(officecfg::Setup::Office::Factories::get(m_xContext),
+ xCFG.set(officecfg::Setup::Office::Factories::get(),
css::uno::UNO_SET_THROW);
/* SAFE */ {
@@ -1939,8 +1982,8 @@ void AutoRecovery::implts_specifyAppModuleAndFactory(AutoRecovery::TDocumentInfo
rInfo.AppModule = xManager->identify(rInfo.Document);
::comphelper::SequenceAsHashMap lModuleDescription(xManager->getByName(rInfo.AppModule));
- lModuleDescription[OUString(CFG_ENTRY_PROP_EMPTYDOCUMENTURL)] >>= rInfo.FactoryURL;
- lModuleDescription[OUString(CFG_ENTRY_PROP_FACTORYSERVICE)] >>= rInfo.FactoryService;
+ lModuleDescription[CFG_ENTRY_PROP_EMPTYDOCUMENTURL] >>= rInfo.FactoryURL;
+ lModuleDescription[CFG_ENTRY_PROP_FACTORYSERVICE] >>= rInfo.FactoryService;
}
void AutoRecovery::implts_collectActiveViewNames( AutoRecovery::TDocumentInfo& i_rInfo )
@@ -1967,17 +2010,6 @@ void AutoRecovery::implts_collectActiveViewNames( AutoRecovery::TDocumentInfo& i
aViewNames.push_back( sViewName );
}
}
- else
- {
- const Reference< XController2 > xController( xModel->getCurrentController(), UNO_QUERY );
- OUString sViewName;
- if ( xController.is() )
- sViewName = xController->getViewControllerName();
- OSL_ENSURE( !sViewName.isEmpty(), "AutoRecovery::implts_collectActiveViewNames: (no XController2 ->) no view name -> no recovery of this view!" );
-
- if ( !sViewName.isEmpty() )
- aViewNames.push_back( sViewName );
- }
i_rInfo.ViewNames.realloc( aViewNames.size() );
::std::copy( aViewNames.begin(), aViewNames.end(), i_rInfo.ViewNames.getArray() );
@@ -1995,10 +2027,11 @@ void AutoRecovery::implts_persistAllActiveViewNames()
}
}
-void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rInfo, bool bRemoveIt)
+void AutoRecovery::implts_flushConfigItem(AutoRecovery::TDocumentInfo& rInfo, bool bRemoveIt,
+ bool bAllowAdd)
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
- comphelper::ConfigurationChanges::create(m_xContext));
+ comphelper::ConfigurationChanges::create());
try
{
@@ -2020,6 +2053,11 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn
// DO IT!
try
{
+ osl::File::remove(rInfo.OldTempURL);
+ osl::File::remove(rInfo.NewTempURL);
+ rInfo.OldTempURL.clear();
+ rInfo.NewTempURL.clear();
+
xModify->removeByName(sID);
}
catch(const css::container::NoSuchElementException&)
@@ -2033,21 +2071,26 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn
css::uno::Reference< css::beans::XPropertySet > xSet;
bool bNew = !xCheck->hasByName(sID);
if (bNew)
+ {
+ if (!bAllowAdd)
+ return; // no change made, just exit
+
xSet.set(xCreate->createInstance(), css::uno::UNO_QUERY_THROW);
+ }
else
xCheck->getByName(sID) >>= xSet;
- xSet->setPropertyValue(CFG_ENTRY_PROP_ORIGINALURL, css::uno::makeAny(rInfo.OrgURL ));
- xSet->setPropertyValue(CFG_ENTRY_PROP_TEMPURL, css::uno::makeAny(rInfo.OldTempURL ));
- xSet->setPropertyValue(CFG_ENTRY_PROP_TEMPLATEURL, css::uno::makeAny(rInfo.TemplateURL ));
- xSet->setPropertyValue(CFG_ENTRY_PROP_FILTER, css::uno::makeAny(rInfo.RealFilter));
- xSet->setPropertyValue(CFG_ENTRY_PROP_DOCUMENTSTATE, css::uno::makeAny(sal_Int32(rInfo.DocumentState)));
- xSet->setPropertyValue(CFG_ENTRY_PROP_MODULE, css::uno::makeAny(rInfo.AppModule));
- xSet->setPropertyValue(CFG_ENTRY_PROP_TITLE, css::uno::makeAny(rInfo.Title));
- xSet->setPropertyValue(CFG_ENTRY_PROP_VIEWNAMES, css::uno::makeAny(rInfo.ViewNames));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_ORIGINALURL, css::uno::Any(rInfo.OrgURL ));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_TEMPURL, css::uno::Any(rInfo.OldTempURL ));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_TEMPLATEURL, css::uno::Any(rInfo.TemplateURL ));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_FILTER, css::uno::Any(rInfo.RealFilter));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_DOCUMENTSTATE, css::uno::Any(sal_Int32(rInfo.DocumentState)));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_MODULE, css::uno::Any(rInfo.AppModule));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_TITLE, css::uno::Any(rInfo.Title));
+ xSet->setPropertyValue(CFG_ENTRY_PROP_VIEWNAMES, css::uno::Any(rInfo.ViewNames));
if (bNew)
- xModify->insertByName(sID, css::uno::makeAny(xSet));
+ xModify->insertByName(sID, css::uno::Any(xSet));
}
}
catch(const css::uno::RuntimeException&)
@@ -2185,7 +2228,7 @@ void AutoRecovery::implts_startModifyListeningOnDoc(AutoRecovery::TDocumentInfo&
css::uno::Reference< css::util::XModifyBroadcaster > xBroadcaster(rInfo.Document, css::uno::UNO_QUERY);
if (xBroadcaster.is())
{
- css::uno::Reference< css::util::XModifyListener > xThis(static_cast< css::frame::XDispatch* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XModifyListener > xThis(this);
xBroadcaster->addModifyListener(xThis);
rInfo.ListenForModify = true;
}
@@ -2199,7 +2242,7 @@ void AutoRecovery::implts_stopModifyListeningOnDoc(AutoRecovery::TDocumentInfo&
css::uno::Reference< css::util::XModifyBroadcaster > xBroadcaster(rInfo.Document, css::uno::UNO_QUERY);
if (xBroadcaster.is())
{
- css::uno::Reference< css::util::XModifyListener > xThis(static_cast< css::frame::XDispatch* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::util::XModifyListener > xThis(this);
xBroadcaster->removeModifyListener(xThis);
rInfo.ListenForModify = false;
}
@@ -2209,7 +2252,7 @@ void AutoRecovery::implts_updateTimer()
{
implts_stopTimer();
- sal_Int32 nMilliSeconds = 0;
+ sal_Int64 nMilliSeconds = 0;
/* SAFE */ {
osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
@@ -2222,7 +2265,27 @@ void AutoRecovery::implts_updateTimer()
if (m_eTimerType == AutoRecovery::E_NORMAL_AUTOSAVE_INTERVALL)
{
- nMilliSeconds = (m_nAutoSaveTimeIntervall*60000); // [min] => 60.000 ms
+ const sal_Int64 nConfiguredAutoSaveInterval
+ = officecfg::Office::Recovery::AutoSave::TimeIntervall::get()
+ * sal_Int64(60000); // [min] => 60.000 ms
+ nMilliSeconds = nConfiguredAutoSaveInterval;
+
+ // Calculate how soon the nearest dirty document's autosave time is;
+ // store the shortest document autosave timeout as the next timer timeout.
+ for (const auto& docInfo : m_lDocCache)
+ {
+ if (auto xDocRecovery2 = docInfo.Document.query<XDocumentRecovery2>())
+ {
+ sal_Int64 nDirtyDuration = xDocRecovery2->getModifiedStateDuration();
+ if (nDirtyDuration < 0)
+ continue;
+ if (nDirtyDuration > nConfiguredAutoSaveInterval)
+ nDirtyDuration = nConfiguredAutoSaveInterval; // nMilliSeconds will be 0
+
+ nMilliSeconds
+ = std::min(nMilliSeconds, nConfiguredAutoSaveInterval - nDirtyDuration);
+ }
+ }
}
else if (m_eTimerType == AutoRecovery::E_POLL_FOR_USER_IDLE)
{
@@ -2310,7 +2373,9 @@ IMPL_LINK_NOARG(AutoRecovery, implts_timerExpired, Timer *, void)
// force save of all currently open documents
// The called method returns an info, if and how this
// timer must be restarted.
- AutoRecovery::ETimerType eSuggestedTimer = implts_saveDocs(true/*bAllowUserIdleLoop*/, false);
+ const bool bIsAlreadyIdle(m_eTimerType == AutoRecovery::E_POLL_FOR_USER_IDLE);
+ AutoRecovery::ETimerType eSuggestedTimer
+ = implts_saveDocs(/*AllowUserIdleLoop=*/!bIsAlreadyIdle, /*RemoveLockFiles=*/false);
// If timer is not used for "short callbacks" (means polling
// for special states) ... reset the handle state of all
@@ -2361,7 +2426,7 @@ IMPL_LINK_NOARG(AutoRecovery, implts_asyncDispatch, LinkParamNone*, void)
}
}
-void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame::XModel >& xDocument)
+void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame::XModel3 > & xDocument)
{
// ignore corrupted events, where no document is given ... Runtime Error ?!
if (!xDocument.is())
@@ -2386,11 +2451,11 @@ void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame
aCacheLock.unlock();
- utl::MediaDescriptor lDescriptor(xDocument->getArgs());
+ utl::MediaDescriptor lDescriptor(xDocument->getArgs2( { utl::MediaDescriptor::PROP_FILTERNAME, utl::MediaDescriptor::PROP_NOAUTOSAVE } ));
// check if this document must be ignored for recovery !
// Some use cases don't wish support for AutoSave/Recovery ... as e.g. OLE-Server / ActiveX Control etcpp.
- bool bNoAutoSave = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_NOAUTOSAVE(), false);
+ bool bNoAutoSave = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_NOAUTOSAVE, false);
if (bNoAutoSave)
return;
@@ -2445,7 +2510,7 @@ void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame
// and save an information about the real used filter by this document.
// We save this document with DefaultFilter ... and load it with the RealFilter.
implts_specifyDefaultFilterAndExtension(aNew);
- aNew.RealFilter = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME() , OUString());
+ aNew.RealFilter = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME, OUString());
// Further we must know, if this document base on a template.
// Then we must load it in a different way.
@@ -2479,7 +2544,8 @@ void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame
} /* SAFE */
- implts_flushConfigItem(aInfo);
+ // Even if the document is modified, we don't know if we have anything to recover, so don't add.
+ implts_flushConfigItem(aInfo, /*bRemoveIt=*/false, /*bAllowAdd=*/false);
implts_startModifyListeningOnDoc(aInfo);
aCacheLock.unlock();
@@ -2527,8 +2593,6 @@ void AutoRecovery::implts_deregisterDocument(const css::uno::Reference< css::fra
if (bStopListening)
implts_stopModifyListeningOnDoc(aInfo);
- AutoRecovery::st_impl_removeFile(aInfo.OldTempURL);
- AutoRecovery::st_impl_removeFile(aInfo.NewTempURL);
implts_flushConfigItem(aInfo, true); // sal_True => remove it from config
}
@@ -2638,16 +2702,16 @@ void AutoRecovery::implts_markDocumentAsSaved(const css::uno::Reference< css::fr
aInfo.NewTempURL.clear();
utl::MediaDescriptor lDescriptor(aInfo.Document->getArgs());
- aInfo.RealFilter = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME(), OUString());
+ aInfo.RealFilter = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME, OUString());
css::uno::Reference< css::frame::XTitle > xDocTitle(xDocument, css::uno::UNO_QUERY);
if (xDocTitle.is ())
aInfo.Title = xDocTitle->getTitle ();
else
{
- aInfo.Title = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TITLE() , OUString());
+ aInfo.Title = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TITLE, OUString());
if (aInfo.Title.isEmpty())
- aInfo.Title = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTTITLE(), OUString());
+ aInfo.Title = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTTITLE, OUString());
}
aInfo.UsedForSaving = false;
@@ -2656,7 +2720,8 @@ void AutoRecovery::implts_markDocumentAsSaved(const css::uno::Reference< css::fr
} /* SAFE */
- implts_flushConfigItem(aInfo);
+ // no need to recover a saved document until modified and new recovery file is created
+ implts_flushConfigItem(aInfo, /*bRemoveIt=*/true);
aCacheLock.unlock();
@@ -2808,7 +2873,7 @@ bool lc_checkIfSaveForbiddenByArguments(AutoRecovery::TDocumentInfo const & rInf
return true;
utl::MediaDescriptor lDescriptor(rInfo.Document->getArgs());
- bool bNoAutoSave = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_NOAUTOSAVE(), false);
+ bool bNoAutoSave = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_NOAUTOSAVE, false);
return bNoAutoSave;
}
@@ -2821,17 +2886,8 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow
if (pParams)
xExternalProgress = pParams->m_xProgress;
- css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(m_xContext);
OUString sBackupPath(SvtPathOptions().GetBackupPath());
- css::uno::Reference< css::frame::XController > xActiveController;
- css::uno::Reference< css::frame::XModel > xActiveModel;
- css::uno::Reference< css::frame::XFrame > xActiveFrame = xDesktop->getActiveFrame();
- if (xActiveFrame.is())
- xActiveController = xActiveFrame->getController();
- if (xActiveController.is())
- xActiveModel = xActiveController->getModel();
-
// Set the default timer action for our call.
// Default = NORMAL_AUTOSAVE
// We return a suggestion for an active timer only.
@@ -2845,6 +2901,10 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow
CacheLockGuard aCacheLock(this, cppu::WeakComponentImplHelperBase::rBHelper.rMutex, m_nDocCacheLock, LOCK_FOR_CACHE_USE);
+ const sal_Int64 nConfiguredAutoSaveInterval
+ = officecfg::Office::Recovery::AutoSave::TimeIntervall::get()
+ * sal_Int64(60000); // min -> ms
+
/* SAFE */ {
osl::ResettableMutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
@@ -2875,15 +2935,35 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow
if ((aInfo.DocumentState & DocState::Handled) == DocState::Handled)
continue;
+ // don't allow implts_deregisterDocument to remove from RecoveryList during shutdown jobs
+ if (m_eJob & (Job::EmergencySave | Job::SessionSave))
+ aInfo.IgnoreClosing = true;
+
// Not modified documents are not saved.
- // We safe an information about the URL only!
+ // We save information about the URL only!
Reference< XDocumentRecovery > xDocRecover( aInfo.Document, UNO_QUERY_THROW );
if ( !xDocRecover->wasModifiedSinceLastSave() )
{
aInfo.DocumentState |= DocState::Handled;
+ *pIt = aInfo;
continue;
}
+ // If the document became modified not too long ago, don't autosave it yet.
+ if (bAllowUserIdleLoop)
+ {
+ if (auto xDocRecovery2 = xDocRecover.query<XDocumentRecovery2>())
+ {
+ const sal_Int64 nDirtyDuration = xDocRecovery2->getModifiedStateDuration();
+ // Round up to second - if this document is almost ready for autosave, do it now.
+ if (nDirtyDuration + 999 < nConfiguredAutoSaveInterval)
+ {
+ aInfo.DocumentState |= DocState::Handled;
+ continue;
+ }
+ }
+ }
+
// check if this document is still used by a concurrent save operation
// e.g. if the user tried to save via UI.
// Handle it in the following way:
@@ -2924,30 +3004,22 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow
}
}
- // a) Document was not postponed - and is active now. => postpone it (restart timer, restart loop)
- // b) Document was not postponed - and is not active now. => save it
- // c) Document was postponed - and is not active now. => save it
- // d) Document was postponed - and is active now. => save it (because user idle was checked already)
- bool bActive = (xActiveModel == aInfo.Document);
- bool bWasPostponed = ((aInfo.DocumentState & DocState::Postponed) == DocState::Postponed);
-
- if (
- ! bWasPostponed &&
- bActive
- )
+ // a) Document was not postponed => wait for user idle if not urgent
+ // b) Document was postponed => save it (because user idle/call_back was checked already)
+ if (!(aInfo.DocumentState & DocState::Postponed))
{
aInfo.DocumentState |= DocState::Postponed;
*pIt = aInfo;
// postponed documents will be saved if this method is called again!
// That can be done by an outside started timer => E_POLL_FOR_USER_IDLE (if normal AutoSave is active)
// or it must be done directly without starting any timer => E_CALL_ME_BACK (if Emergency- or SessionSave is active and must be finished ASAP!)
- eTimer = AutoRecovery::E_POLL_FOR_USER_IDLE;
if (!bAllowUserIdleLoop)
eTimer = AutoRecovery::E_CALL_ME_BACK;
+ else
+ eTimer = AutoRecovery::E_POLL_FOR_USER_IDLE;
continue;
}
- // b, c, d)
// } /* SAFE */
g.clear();
// changing of aInfo and flushing it is done inside implts_saveOneDoc!
@@ -3001,59 +3073,81 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
// stored with password
utl::MediaDescriptor lNewArgs;
css::uno::Sequence< css::beans::NamedValue > aEncryptionData =
- lOldArgs.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ENCRYPTIONDATA(),
+ lOldArgs.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ENCRYPTIONDATA,
css::uno::Sequence< css::beans::NamedValue >());
if (aEncryptionData.hasElements())
- lNewArgs[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= aEncryptionData;
+ lNewArgs[utl::MediaDescriptor::PROP_ENCRYPTIONDATA] <<= aEncryptionData;
// Further it must be saved using the default file format of that application.
// Otherwise we will some data lost.
if (!rInfo.DefaultFilter.isEmpty())
- lNewArgs[utl::MediaDescriptor::PROP_FILTERNAME()] <<= rInfo.DefaultFilter;
+ lNewArgs[utl::MediaDescriptor::PROP_FILTERNAME] <<= rInfo.DefaultFilter;
// prepare frame/document/mediadescriptor in a way, that it uses OUR progress .-)
if (xExternalProgress.is())
- lNewArgs[utl::MediaDescriptor::PROP_STATUSINDICATOR()] <<= xExternalProgress;
+ lNewArgs[utl::MediaDescriptor::PROP_STATUSINDICATOR] <<= xExternalProgress;
impl_establishProgress(rInfo, lNewArgs, css::uno::Reference< css::frame::XFrame >());
// #i66598# use special handling of property "DocumentBaseURL" (it must be an empty string!)
// for make hyperlinks working
- lNewArgs[utl::MediaDescriptor::PROP_DOCUMENTBASEURL()] <<= OUString();
+ lNewArgs[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= OUString();
+
+ lNewArgs[utl::MediaDescriptor::PROP_AUTOSAVEEVENT] <<= true;
// try to save this document as a new temp file every time.
// Mark AutoSave state as "INCOMPLETE" if it failed.
// Because the last temp file is too old and does not include all changes.
Reference< XDocumentRecovery > xDocRecover(rInfo.Document, css::uno::UNO_QUERY_THROW);
- // safe the state about "trying to save"
+ // save the state about "trying to save"
// ... we need it for recovery if e.g. a crash occurs inside next line!
rInfo.DocumentState |= DocState::TrySave;
- implts_flushConfigItem(rInfo);
+ // just update existing info: don't add any recovery record until recovery file created.
+ implts_flushConfigItem(rInfo, /*bRemoveIt=*/false, /*bAllowAdd=*/false);
// If userautosave is enabled, first try to save the original file.
// Note that we must do it *before* calling storeToRecoveryFile, so in case of failure here
// we won't remain with the modified flag set to true, even though the autorecovery save succeeded.
+ const bool bEmergencySave(m_eJob & Job::EmergencySave);
+ bool bUserAutoSaved = false;
try
{
// We must check here for an empty URL to avoid a "This operation is not supported on this operating system."
// message during autosave.
- if ((m_eJob & Job::UserAutoSave) == Job::UserAutoSave && !rInfo.OrgURL.isEmpty())
+ if (!bEmergencySave && m_eJob & Job::UserAutoSave && !rInfo.OrgURL.isEmpty())
{
Reference< XStorable > xDocSave(rInfo.Document, css::uno::UNO_QUERY_THROW);
xDocSave->store();
+ bUserAutoSaved = true;
}
}
catch(const css::uno::Exception&)
{
}
+ // DocState::Modified status cannot be trusted to be accurate, but at least attempt to be so,
+ // since this rInfo will eventually get assigned to m_lDocCache as the authoritative status.
+ const Reference<css::util::XModifiable> xModify(rInfo.Document, UNO_QUERY);
+ const bool bModified = xModify.is() && xModify->isModified();
+ if (bModified)
+ rInfo.DocumentState |= DocState::Modified;
+ else if (xModify.is())
+ rInfo.DocumentState &= ~DocState::Modified;
+
+ // If it is no longer modified, it is the same as on disk, and can be removed from RecoveryList.
+ const bool bRemoveIt
+ = xModify.is() && !xModify->isModified() && bUserAutoSaved && !(m_eJob & Job::SessionSave);
+
sal_Int32 nRetry = RETRY_STORE_ON_FULL_DISC_FOREVER;
bool bError = false;
do
{
try
{
- xDocRecover->storeToRecoveryFile( rInfo.NewTempURL, lNewArgs.getAsConstPropertyValueList() );
+ // skip recovery if it will be removed anyway.
+ if (!bRemoveIt)
+ xDocRecover->storeToRecoveryFile(rInfo.NewTempURL,
+ lNewArgs.getAsConstPropertyValueList());
#ifdef TRIGGER_FULL_DISC_CHECK
throw css::uno::Exception("trigger full disk check");
@@ -3063,10 +3157,23 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
nRetry = 0;
#endif // TRIGGER_FULL_DISC_CHECK
}
- catch(const css::uno::Exception&)
+ catch(const css::uno::Exception& rException)
{
bError = true;
+ // skip saving XLSX with protected sheets, if their passwords haven't supported yet
+ if ( rException.Message.startsWith("SfxBaseModel::impl_store") )
+ {
+ const css::task::ErrorCodeIOException& pErrorCodeIOException =
+ static_cast<const css::task::ErrorCodeIOException&>(rException);
+ if ( static_cast<ErrCode>(pErrorCodeIOException.ErrCode) == ERRCODE_SFX_WRONGPASSWORD )
+ {
+ // stop and remove the bad temporary file, instead of filling the disk with them
+ bError = false;
+ break;
+ }
+ }
+
// a) FULL DISC seems to be the problem behind => show error and retry it forever (e.g. retry=300)
// b) unknown problem (may be locking problem) => reset RETRY value to more useful value(!) (e.g. retry=3)
// c) unknown problem (may be locking problem) + 1..2 repeating operations => throw the original exception to force generation of a stacktrace !
@@ -3082,7 +3189,13 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
else if (nRetry > RETRY_STORE_ON_MIGHT_FULL_DISC_USEFULL)
nRetry = RETRY_STORE_ON_MIGHT_FULL_DISC_USEFULL;
else if (nRetry <= GIVE_UP_RETRY)
+ {
+ // delete the empty file created by implts_generateNewTempURL
+ if (tools::isEmptyFileUrl(rInfo.NewTempURL))
+ osl::File::remove(rInfo.NewTempURL);
+
throw; // force stacktrace to know if there exist might other reasons, why an AutoSave can fail !!!
+ }
--nRetry;
}
@@ -3116,7 +3229,8 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
rInfo.OldTempURL = rInfo.NewTempURL;
rInfo.NewTempURL.clear();
- implts_flushConfigItem(rInfo);
+ // If it is modified, a recovery file has just been created, so add to RecoveryList.
+ implts_flushConfigItem(rInfo, bRemoveIt, /*bAllowAdd=*/bModified);
// We must know if the user modifies the document again ...
implts_startModifyListeningOnDoc(rInfo);
@@ -3162,14 +3276,14 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa
utl::MediaDescriptor lDescriptor;
// it's a UI feature - so the "USER" itself must be set as referrer
- lDescriptor[utl::MediaDescriptor::PROP_REFERRER()] <<= OUString(REFERRER_USER);
- lDescriptor[utl::MediaDescriptor::PROP_SALVAGEDFILE()] <<= OUString();
+ lDescriptor[utl::MediaDescriptor::PROP_REFERRER] <<= OUString(REFERRER_USER);
+ lDescriptor[utl::MediaDescriptor::PROP_SALVAGEDFILE] <<= OUString();
// recovered documents are loaded hidden, and shown all at once, later
- lDescriptor[utl::MediaDescriptor::PROP_HIDDEN()] <<= true;
+ lDescriptor[utl::MediaDescriptor::PROP_HIDDEN] <<= true;
if (aParams.m_xProgress.is())
- lDescriptor[utl::MediaDescriptor::PROP_STATUSINDICATOR()] <<= aParams.m_xProgress;
+ lDescriptor[utl::MediaDescriptor::PROP_STATUSINDICATOR] <<= aParams.m_xProgress;
bool bBackupWasTried = (
((info.DocumentState & DocState::TryLoadBackup ) == DocState::TryLoadBackup) || // temp. state!
@@ -3204,13 +3318,13 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa
else if (!info.TemplateURL.isEmpty())
{
sLoadOriginalURL = info.TemplateURL;
- lDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE()] <<= true;
- lDescriptor[utl::MediaDescriptor::PROP_TEMPLATENAME()] <<= info.TemplateURL;
+ lDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE] <<= true;
+ lDescriptor[utl::MediaDescriptor::PROP_TEMPLATENAME] <<= info.TemplateURL;
}
else if (!info.FactoryURL.isEmpty())
{
sLoadOriginalURL = info.FactoryURL;
- lDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE()] <<= true;
+ lDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE] <<= true;
}
// A "Salvaged" item must exists every time. The core can make something special then for recovery.
@@ -3220,7 +3334,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa
{
sURL = sLoadBackupURL;
info.DocumentState |= DocState::TryLoadBackup;
- lDescriptor[utl::MediaDescriptor::PROP_SALVAGEDFILE()] <<= sLoadOriginalURL;
+ lDescriptor[utl::MediaDescriptor::PROP_SALVAGEDFILE] <<= sLoadOriginalURL;
}
else if (!sLoadOriginalURL.isEmpty())
{
@@ -3258,7 +3372,8 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa
info.DocumentState |= DocState::Damaged;
}
- implts_flushConfigItem(info, true);
+ implts_flushConfigItem(info, /*bRemoveIt=*/true);
+
implts_informListener(eJob,
AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_UPDATE, &info));
@@ -3271,7 +3386,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa
if (!info.RealFilter.isEmpty())
{
utl::MediaDescriptor lPatchDescriptor(info.Document->getArgs());
- lPatchDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] <<= info.RealFilter;
+ lPatchDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] <<= info.RealFilter;
info.Document->attachResource(info.Document->getURL(), lPatchDescriptor.getAsConstPropertyValueList());
// do *not* use sURL here. In case this points to the recovery file, it has already been passed
// to recoverFromFile. Also, passing it here is logically wrong, as attachResource is intended
@@ -3330,9 +3445,9 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
// put the filter name into the descriptor - we're not going to involve any type detection, so
// the document might be lost without the FilterName property
if ( (rInfo.DocumentState & DocState::TryLoadOriginal) == DocState::TryLoadOriginal)
- lDescriptor[ utl::MediaDescriptor::PROP_FILTERNAME() ] <<= rInfo.RealFilter;
+ lDescriptor[ utl::MediaDescriptor::PROP_FILTERNAME ] <<= rInfo.RealFilter;
else
- lDescriptor[ utl::MediaDescriptor::PROP_FILTERNAME() ] <<= rInfo.DefaultFilter;
+ lDescriptor[ utl::MediaDescriptor::PROP_FILTERNAME ] <<= rInfo.DefaultFilter;
if ( sURL == rInfo.FactoryURL )
{
@@ -3345,10 +3460,12 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
// TODO: remove load-process specific arguments from the descriptor, e.g. the status indicator
xModel->attachResource( sURL, lDescriptor.getAsConstPropertyValueList() );
}
+ else if (!utl::UCBContentHelper::Exists(sURL))
+ throw css::uno::Exception();
else
{
OUString sFilterName;
- lDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] >>= sFilterName;
+ lDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= sFilterName;
if (!sFilterName.isEmpty()
&& ( sFilterName == "Calc MS Excel 2007 XML"
|| sFilterName == "Impress MS PowerPoint 2007 XML"
@@ -3365,12 +3482,12 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.comp.oox.FormatDetector", m_xContext),
UNO_QUERY_THROW);
- lDescriptor[utl::MediaDescriptor::PROP_URL()] <<= sURL;
+ lDescriptor[utl::MediaDescriptor::PROP_URL] <<= sURL;
Sequence< css::beans::PropertyValue > aDescriptorSeq = lDescriptor.getAsConstPropertyValueList();
OUString sType = xDetection->detect(aDescriptorSeq);
OUString sNewFilterName;
- lDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] >>= sNewFilterName;
+ lDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= sNewFilterName;
if (!sType.isEmpty() && sNewFilterName == sFilterName)
{
// Filter detection was okay, update media descriptor with one received from FilterDetect
@@ -3382,7 +3499,7 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
Reference< XDocumentRecovery > xDocRecover( xModel, UNO_QUERY_THROW );
xDocRecover->recoverFromFile(
sURL,
- lDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_SALVAGEDFILE(), OUString() ),
+ lDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_SALVAGEDFILE, OUString() ),
lDescriptor.getAsConstPropertyValueList()
);
@@ -3391,7 +3508,7 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
}
// re-create all the views
- ::std::vector< OUString > aViewsToRestore( rInfo.ViewNames.begin(), rInfo.ViewNames.end() );
+ ::std::vector< OUString > aViewsToRestore( std::cbegin(rInfo.ViewNames), std::cend(rInfo.ViewNames) );
// if we don't have views for whatever reason, then create a default-view, at least
if ( aViewsToRestore.empty() )
aViewsToRestore.emplace_back( );
@@ -3414,11 +3531,7 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL ,
}
// introduce model/view/controller to each other
- xController->attachModel( xModel.get() );
- xModel->connectController( xController.get() );
- xTargetFrame->setComponent( xController->getComponentWindow(), xController.get() );
- xController->attachFrame( xTargetFrame );
- xModel->setCurrentController( xController.get() );
+ utl::ConnectFrameControllerModel(xTargetFrame, xController, xModel);
}
rInfo.Document = xModel.get();
@@ -3475,21 +3588,16 @@ void AutoRecovery::implts_generateNewTempURL(const OUString& sBack
sUniqueName.append("untitled");
sUniqueName.append("_");
- // TODO: Must we strip some illegal signes - if we use the title?
+ // TODO: Must we strip some illegal signs - if we use the title?
- OUString sName(sUniqueName.makeStringAndClear());
- OUString sExtension(rInfo.Extension);
- OUString sPath(sBackupPath);
- ::utl::TempFile aTempFile(sName, true, &sExtension, &sPath, true);
-
- rInfo.NewTempURL = aTempFile.GetURL();
+ rInfo.NewTempURL = ::utl::CreateTempURL(sUniqueName, true, rInfo.Extension, &sBackupPath, true);
}
void AutoRecovery::implts_informListener( Job eJob ,
const css::frame::FeatureStateEvent& aEvent)
{
// Helper shares mutex with us -> threadsafe!
- ::cppu::OInterfaceContainerHelper* pListenerForURL = nullptr;
+ ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener>* pListenerForURL = nullptr;
OUString sJob = AutoRecovery::implst_getJobDescription(eJob);
// inform listener, which are registered for any URLs(!)
@@ -3497,13 +3605,12 @@ void AutoRecovery::implts_informListener( Job eJob ,
if(pListenerForURL == nullptr)
return;
- ::cppu::OInterfaceIteratorHelper pIt(*pListenerForURL);
+ ::comphelper::OInterfaceIteratorHelper3 pIt(*pListenerForURL);
while(pIt.hasMoreElements())
{
try
{
- css::uno::Reference< css::frame::XStatusListener > xListener(static_cast<css::frame::XStatusListener*>(pIt.next()), css::uno::UNO_QUERY);
- xListener->statusChanged(aEvent);
+ pIt.next()->statusChanged(aEvent);
}
catch(const css::uno::RuntimeException&)
{
@@ -3590,15 +3697,15 @@ css::frame::FeatureStateEvent AutoRecovery::implst_createFeatureStateEvent(
{
// pack rInfo for transport via UNO
::comphelper::NamedValueCollection aInfo;
- aInfo.put( OUString(CFG_ENTRY_PROP_ID), pInfo->ID );
- aInfo.put( OUString(CFG_ENTRY_PROP_ORIGINALURL), pInfo->OrgURL );
- aInfo.put( OUString(CFG_ENTRY_PROP_FACTORYURL), pInfo->FactoryURL );
- aInfo.put( OUString(CFG_ENTRY_PROP_TEMPLATEURL), pInfo->TemplateURL );
- aInfo.put( OUString(CFG_ENTRY_PROP_TEMPURL), pInfo->OldTempURL.isEmpty() ? pInfo->NewTempURL : pInfo->OldTempURL );
- aInfo.put( OUString(CFG_ENTRY_PROP_MODULE), pInfo->AppModule);
- aInfo.put( OUString(CFG_ENTRY_PROP_TITLE), pInfo->Title);
- aInfo.put( OUString(CFG_ENTRY_PROP_VIEWNAMES), pInfo->ViewNames);
- aInfo.put( OUString(CFG_ENTRY_PROP_DOCUMENTSTATE), sal_Int32(pInfo->DocumentState));
+ aInfo.put( CFG_ENTRY_PROP_ID, pInfo->ID );
+ aInfo.put( CFG_ENTRY_PROP_ORIGINALURL, pInfo->OrgURL );
+ aInfo.put( CFG_ENTRY_PROP_FACTORYURL, pInfo->FactoryURL );
+ aInfo.put( CFG_ENTRY_PROP_TEMPLATEURL, pInfo->TemplateURL );
+ aInfo.put( CFG_ENTRY_PROP_TEMPURL, pInfo->OldTempURL.isEmpty() ? pInfo->NewTempURL : pInfo->OldTempURL );
+ aInfo.put( CFG_ENTRY_PROP_MODULE, pInfo->AppModule);
+ aInfo.put( CFG_ENTRY_PROP_TITLE, pInfo->Title);
+ aInfo.put( CFG_ENTRY_PROP_VIEWNAMES, pInfo->ViewNames);
+ aInfo.put( CFG_ENTRY_PROP_DOCUMENTSTATE, sal_Int32(pInfo->DocumentState));
aEvent.State <<= aInfo.getPropertyValues();
}
@@ -3620,7 +3727,8 @@ void AutoRecovery::implts_resetHandleStates()
// } /* SAFE */
g.clear();
- implts_flushConfigItem(info);
+ // just update existing records.
+ implts_flushConfigItem(info, /*bRemoveIt=*/false, /*bAllowAdd=*/false);
g.reset();
// /* SAFE */ {
}
@@ -3643,7 +3751,7 @@ void AutoRecovery::implts_doEmergencySave(const DispatchParams& aParams)
// documents exists and was saved.
std::shared_ptr<comphelper::ConfigurationChanges> batch(
- comphelper::ConfigurationChanges::create(m_xContext));
+ comphelper::ConfigurationChanges::create());
officecfg::Office::Recovery::RecoveryInfo::Crashed::set(true, batch);
batch->commit();
@@ -3700,7 +3808,7 @@ void AutoRecovery::implts_doRecovery(const DispatchParams& aParams)
// Reset the configuration hint "we were crashed"!
std::shared_ptr<comphelper::ConfigurationChanges> batch(
- comphelper::ConfigurationChanges::create(m_xContext));
+ comphelper::ConfigurationChanges::create());
officecfg::Office::Recovery::RecoveryInfo::Crashed::set(false, batch);
batch->commit();
}
@@ -3762,7 +3870,7 @@ void AutoRecovery::implts_doSessionQuietQuit()
// Write a hint for "stored session data" into the configuration, so
// the on next startup we know what's happen last time
std::shared_ptr<comphelper::ConfigurationChanges> batch(
- comphelper::ConfigurationChanges::create(m_xContext));
+ comphelper::ConfigurationChanges::create());
officecfg::Office::Recovery::RecoveryInfo::SessionData::set(true, batch);
batch->commit();
@@ -3794,7 +3902,7 @@ void AutoRecovery::implts_doSessionRestore(const DispatchParams& aParams)
// Reset the configuration hint for "session save"!
SAL_INFO("fwk.autorecovery", "... reset config key 'SessionData'");
std::shared_ptr<comphelper::ConfigurationChanges> batch(
- comphelper::ConfigurationChanges::create(m_xContext));
+ comphelper::ConfigurationChanges::create());
officecfg::Office::Recovery::RecoveryInfo::SessionData::set(false, batch);
batch->commit();
@@ -3842,8 +3950,6 @@ void AutoRecovery::implts_cleanUpWorkingEntry(const DispatchParams& aParams)
if (pIt != m_lDocCache.end())
{
AutoRecovery::TDocumentInfo& rInfo = *pIt;
- AutoRecovery::st_impl_removeFile(rInfo.OldTempURL);
- AutoRecovery::st_impl_removeFile(rInfo.NewTempURL);
implts_flushConfigItem(rInfo, true); // sal_True => remove it from xml config!
m_lDocCache.erase(pIt);
@@ -3911,7 +4017,7 @@ void SAL_CALL AutoRecovery::getFastPropertyValue(css::uno::Any& aValue ,
{
case AUTORECOVERY_PROPHANDLE_EXISTS_RECOVERYDATA :
{
- bool bSessionData = officecfg::Office::Recovery::RecoveryInfo::SessionData::get(m_xContext);
+ bool bSessionData = officecfg::Office::Recovery::RecoveryInfo::SessionData::get();
bool bRecoveryData = !m_lDocCache.empty();
// exists session data ... => then we can't say, that these
@@ -3924,11 +4030,11 @@ void SAL_CALL AutoRecovery::getFastPropertyValue(css::uno::Any& aValue ,
break;
case AUTORECOVERY_PROPHANDLE_CRASHED :
- aValue <<= officecfg::Office::Recovery::RecoveryInfo::Crashed::get(m_xContext);
+ aValue <<= officecfg::Office::Recovery::RecoveryInfo::Crashed::get();
break;
case AUTORECOVERY_PROPHANDLE_EXISTS_SESSIONDATA :
- aValue <<= officecfg::Office::Recovery::RecoveryInfo::SessionData::get(m_xContext);
+ aValue <<= officecfg::Office::Recovery::RecoveryInfo::SessionData::get();
break;
}
}
@@ -4004,11 +4110,11 @@ void AutoRecovery::implts_verifyCacheAgainstDesktopDocumentList()
// extract the model from the frame.
// Ignore "view only" frames, which does not have a model.
css::uno::Reference< css::frame::XController > xController;
- css::uno::Reference< css::frame::XModel > xModel;
+ css::uno::Reference< css::frame::XModel3 > xModel;
xController = xFrame->getController();
if (xController.is())
- xModel = xController->getModel();
+ xModel.set( xController->getModel(), UNO_QUERY_THROW );
if (!xModel.is())
continue;
@@ -4077,6 +4183,7 @@ void AutoRecovery::impl_showFullDiscError()
xBox->run();
}
+// static
void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo ,
utl::MediaDescriptor& rArgs ,
const css::uno::Reference< css::frame::XFrame >& xNewFrame)
@@ -4101,7 +4208,7 @@ void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo&
// Only if there is no progress, we can create our own one.
css::uno::Reference< css::task::XStatusIndicator > xInternalProgress;
css::uno::Reference< css::task::XStatusIndicator > xExternalProgress = rArgs.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_STATUSINDICATOR(),
+ utl::MediaDescriptor::PROP_STATUSINDICATOR,
css::uno::Reference< css::task::XStatusIndicator >() );
// Normally a progress is set from outside (e.g. by the CrashSave/Recovery dialog, which uses our dispatch API).
@@ -4134,14 +4241,15 @@ void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo&
{
css::uno::Reference< css::beans::XPropertySet > xFrameProps(xFrame, css::uno::UNO_QUERY);
if (xFrameProps.is())
- xFrameProps->setPropertyValue(FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION, css::uno::makeAny(xExternalProgress));
+ xFrameProps->setPropertyValue(FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION, css::uno::Any(xExternalProgress));
}
// But inside the MediaDescriptor we must set our own create progress ...
// in case there is not already another progress set.
- rArgs.createItemIfMissing(utl::MediaDescriptor::PROP_STATUSINDICATOR(), xInternalProgress);
+ rArgs.createItemIfMissing(utl::MediaDescriptor::PROP_STATUSINDICATOR, xInternalProgress);
}
+// static
void AutoRecovery::impl_forgetProgress(const AutoRecovery::TDocumentInfo& rInfo ,
utl::MediaDescriptor& rArgs ,
const css::uno::Reference< css::frame::XFrame >& xNewFrame)
@@ -4165,10 +4273,10 @@ void AutoRecovery::impl_forgetProgress(const AutoRecovery::TDocumentInfo&
// stop progress interception on corresponding frame.
css::uno::Reference< css::beans::XPropertySet > xFrameProps(xFrame, css::uno::UNO_QUERY);
if (xFrameProps.is())
- xFrameProps->setPropertyValue(FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION, css::uno::makeAny(css::uno::Reference< css::task::XStatusIndicator >()));
+ xFrameProps->setPropertyValue(FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION, css::uno::Any(css::uno::Reference< css::task::XStatusIndicator >()));
// forget progress inside list of arguments.
- utl::MediaDescriptor::iterator pArg = rArgs.find(utl::MediaDescriptor::PROP_STATUSINDICATOR());
+ utl::MediaDescriptor::iterator pArg = rArgs.find(utl::MediaDescriptor::PROP_STATUSINDICATOR);
if (pArg != rArgs.end())
{
rArgs.erase(pArg);
@@ -4176,6 +4284,7 @@ void AutoRecovery::impl_forgetProgress(const AutoRecovery::TDocumentInfo&
}
}
+// static
void AutoRecovery::impl_flushALLConfigChanges()
{
try
@@ -4197,7 +4306,7 @@ void AutoRecovery::st_impl_removeFile(const OUString& sURL)
try
{
::ucbhelper::Content aContent(sURL, css::uno::Reference< css::ucb::XCommandEnvironment >(), m_xContext);
- aContent.executeCommand("delete", css::uno::makeAny(true));
+ aContent.executeCommand("delete", css::uno::Any(true));
}
catch(const css::uno::Exception&)
{
@@ -4219,25 +4328,6 @@ void AutoRecovery::st_impl_removeLockFile()
}
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new AutoRecovery(context)))
- {
- // 2nd phase initialization needed
- static_cast<AutoRecovery*>(static_cast<cppu::OWeakObject *>
- (instance.get()))->initListeners();
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -4245,8 +4335,11 @@ com_sun_star_comp_framework_AutoRecovery_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ rtl::Reference<AutoRecovery> xAutoRecovery = new AutoRecovery(context);
+ // 2nd phase initialization needed
+ xAutoRecovery->initListeners();
+
+ return cppu::acquire(xAutoRecovery.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 8f9f3f0bac85..6560af7f1eb3 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -51,13 +51,14 @@
#include <comphelper/sequence.hxx>
#include <comphelper/lok.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <rtl/instance.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <desktop/crashreport.hxx>
#include <vcl/scheduler.hxx>
#include <sal/log.hxx>
-#include <vcl/errcode.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/errcode.hxx>
+#include <vcl/threadex.hxx>
+#include <comphelper/configuration.hxx>
namespace framework{
@@ -90,26 +91,23 @@ void Desktop::constructorInit()
// We hold member as reference ... not as pointer too!
// Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
// But look on dispose() for right order of deinitialization.
- OFrames* pFramesHelper = new OFrames( this, &m_aChildTaskContainer );
- m_xFramesHelper.set( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
+ m_xFramesHelper = new OFrames( this, &m_aChildTaskContainer );
// Initialize a new dispatchhelper-object to handle dispatches.
// We use these helper as slave for our interceptor helper ... not directly!
// But he is event listener on THIS instance!
- DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this );
- css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
+ rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this );
// Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
// Set created dispatch provider as slowest slave of it.
// Hold interception helper by reference only - not by pointer!
// So it's easier to destroy it.
- InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
- m_xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
+ m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider );
OUString sUntitledPrefix = FwkResId(STR_UNTITLED_DOCUMENT) + " ";
- ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection ();
- m_xTitleNumberGenerator.set(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<::comphelper::NumberedCollection> pNumbers = new ::comphelper::NumberedCollection ();
+ m_xTitleNumberGenerator = pNumbers;
pNumbers->setOwner ( static_cast< ::cppu::OWeakObject* >(this) );
pNumbers->setUntitledPrefix ( sUntitledPrefix );
@@ -142,28 +140,17 @@ void Desktop::constructorInit()
The value must be different from NULL!
@onerror We throw an ASSERT in debug version or do nothing in release version.
*//*-*************************************************************************************************************/
-Desktop::Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext )
+Desktop::Desktop( css::uno::Reference< css::uno::XComponentContext > xContext )
: Desktop_BASE ( m_aMutex )
, cppu::OPropertySetHelper( cppu::WeakComponentImplHelperBase::rBHelper )
// Init member
, m_bIsTerminated(false)
, m_bIsShutdown(false) // see dispose() for further information!
, m_bSession ( false )
- , m_xContext ( xContext )
- , m_aChildTaskContainer ( )
+ , m_xContext (std::move( xContext ))
, m_aListenerContainer ( m_aMutex )
- , m_xFramesHelper ( )
- , m_xDispatchHelper ( )
, m_eLoadState ( E_NOTSET )
, m_bSuspendQuickstartVeto( false )
- , m_sName ( )
- , m_sTitle ( )
- , m_xDispatchRecorderSupplier( )
- , m_xPipeTerminator ( )
- , m_xQuickLauncher ( )
- , m_xSWThreadManager ( )
- , m_xSfxTerminator ( )
- , m_xTitleNumberGenerator ( )
{
}
@@ -210,8 +197,7 @@ sal_Bool SAL_CALL Desktop::terminate()
css::lang::EventObject aEvent ( static_cast< ::cppu::OWeakObject* >(this) );
bool bAskQuickStart = !m_bSuspendQuickstartVeto;
- const bool bRestartableMainLoop = Application::IsEventTestingModeEnabled() ||
- comphelper::LibreOfficeKit::isActive();
+ const bool bRestartableMainLoop = comphelper::LibreOfficeKit::isActive();
aGuard.clear();
// Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
@@ -355,9 +341,9 @@ namespace
Desktop* const m_pDesktop;
css::uno::Reference< css::frame::XTerminateListener > m_xQuickLauncher;
public:
- QuickstartSuppressor(Desktop* const pDesktop, css::uno::Reference< css::frame::XTerminateListener > const & xQuickLauncher)
+ QuickstartSuppressor(Desktop* const pDesktop, css::uno::Reference< css::frame::XTerminateListener > xQuickLauncher)
: m_pDesktop(pDesktop)
- , m_xQuickLauncher(xQuickLauncher)
+ , m_xQuickLauncher(std::move(xQuickLauncher))
{
SAL_INFO("fwk.desktop", "temporary removing Quickstarter");
if(m_xQuickLauncher.is())
@@ -457,9 +443,7 @@ void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::
}
else if (sImplementationName == "com.sun.star.comp.ComponentDLLListener")
{
- m_xComponentDllListeners.erase(
- std::remove(m_xComponentDllListeners.begin(), m_xComponentDllListeners.end(), xListener),
- m_xComponentDllListeners.end());
+ std::erase(m_xComponentDllListeners, xListener);
return;
}
}
@@ -488,9 +472,7 @@ css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getC
// We use a helper class OComponentAccess to have access on all child components.
// Create it on demand and return it as a reference.
- OComponentAccess* pAccess = new OComponentAccess( this );
- css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY );
- return xAccess;
+ return new OComponentAccess( this );
}
/*-************************************************************************************************************
@@ -588,9 +570,27 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFrom
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
SAL_INFO( "fwk.desktop", "loadComponentFromURL" );
- css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XComponentLoader > xThis(this);
- return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName, nSearchFlags, lArguments);
+ utl::MediaDescriptor aDescriptor(lArguments);
+ bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false);
+
+ if (bOnMainThread)
+ {
+ // Make sure that we own the solar mutex, otherwise later
+ // vcl::SolarThreadExecutor::execute() will release the solar mutex, even if it's owned by
+ // another thread, leading to an std::abort() at the end.
+ SolarMutexGuard g;
+
+ return vcl::solarthread::syncExecute(std::bind(&LoadEnv::loadComponentFromURL, xThis,
+ m_xContext, sURL, sTargetFrameName,
+ nSearchFlags, lArguments));
+ }
+ else
+ {
+ return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName,
+ nSearchFlags, lArguments);
+ }
}
/*-************************************************************************************************************
@@ -673,11 +673,11 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL Desktop::queryDispatch( co
if ( aURL.Protocol.equalsIgnoreAsciiCase(".uno:") )
aCommand = aURL.Path;
- if (!m_xCommandOptions && !utl::ConfigManager::IsFuzzing())
+ if (!m_xCommandOptions && !comphelper::IsFuzzing())
m_xCommandOptions.reset(new SvtCommandOptions);
// Make std::unordered_map lookup if the current URL is in the disabled list
- if (m_xCommandOptions && m_xCommandOptions->Lookup(SvtCommandOptions::CMDOPTION_DISABLED, aCommand))
+ if (m_xCommandOptions && m_xCommandOptions->LookupDisabled(aCommand))
return css::uno::Reference< css::frame::XDispatch >();
else
{
@@ -1038,8 +1038,6 @@ void SAL_CALL Desktop::disposing()
// Safe impossible cases
// It's a programming error if dispose is called before terminate!
- // But if you just ignore the assertion (which happens in unit
- // tests for instance in sc/qa/unit) nothing bad happens.
assert(m_bIsShutdown && "Desktop disposed before terminating it");
{
@@ -1333,21 +1331,21 @@ sal_Bool SAL_CALL Desktop::convertFastPropertyValue( css::uno::Any& aCon
{
case PropHandle::SuspendQuickstartVeto:
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_bSuspendQuickstartVeto),
+ css::uno::Any(m_bSuspendQuickstartVeto),
aValue,
aOldValue,
aConvertedValue);
break;
case PropHandle::DispatchRecorderSupplier :
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_xDispatchRecorderSupplier),
+ css::uno::Any(m_xDispatchRecorderSupplier),
aValue,
aOldValue,
aConvertedValue);
break;
case PropHandle::Title :
bReturn = PropHelper::willPropertyBeChanged(
- css::uno::makeAny(m_sTitle),
+ css::uno::Any(m_sTitle),
aValue,
aOldValue,
aConvertedValue);
@@ -1427,11 +1425,9 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper()
{
- struct Static:
- public rtl::StaticWithInit<cppu::OPropertyArrayHelper, Static>
- {
- cppu::OPropertyArrayHelper operator ()() {
- return {
+ static cppu::OPropertyArrayHelper HELPER =
+ [] () {
+ return cppu::OPropertyArrayHelper {
{{"ActiveFrame", PropHandle::ActiveFrame,
cppu::UnoType<css::lang::XComponent>::get(),
(css::beans::PropertyAttribute::TRANSIENT
@@ -1450,9 +1446,8 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
{"Title", PropHandle::Title, cppu::UnoType<OUString>::get(),
css::beans::PropertyAttribute::TRANSIENT}},
true};
- }
- };
- return Static::get();
+ }();
+ return HELPER;
}
/*-************************************************************************************************************
@@ -1540,13 +1535,13 @@ bool Desktop::impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList& lC
{
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
if ( ! pContainer )
return true;
css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
- ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+ comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer );
while ( aIterator.hasMoreElements() )
{
try
@@ -1598,28 +1593,26 @@ void Desktop::impl_sendTerminateToClipboard()
{
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
if ( ! pContainer )
return;
- ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+ comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer );
while ( aIterator.hasMoreElements() )
{
try
{
- css::uno::Reference< css::lang::XServiceInfo > xInfo( aIterator.next(), css::uno::UNO_QUERY );
+ css::frame::XTerminateListener* pTerminateListener =
+ static_cast< css::frame::XTerminateListener* >(aIterator.next());
+ css::uno::Reference< css::lang::XServiceInfo > xInfo( pTerminateListener, css::uno::UNO_QUERY );
if ( !xInfo.is() )
continue;
if ( xInfo->getImplementationName() != "com.sun.star.comp.svt.TransferableHelperTerminateListener" )
continue;
- css::uno::Reference< css::frame::XTerminateListener > xListener(xInfo, css::uno::UNO_QUERY);
- if ( ! xListener.is() )
- continue;
-
css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
- xListener->notifyTermination( aEvent );
+ pTerminateListener->notifyTermination( aEvent );
// don't notify twice
aIterator.remove();
@@ -1638,21 +1631,18 @@ void Desktop::impl_sendNotifyTerminationEvent()
{
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
if ( ! pContainer )
return;
css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
- ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+ comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer );
while ( aIterator.hasMoreElements() )
{
try
{
- css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY);
- if ( ! xListener.is() )
- continue;
- xListener->notifyTermination( aEvent );
+ static_cast< css::frame::XTerminateListener* >(aIterator.next())->notifyTermination( aEvent );
}
catch( const css::uno::Exception& )
{
@@ -1762,7 +1752,7 @@ rtl::Reference<framework::Desktop> createDesktop(
}
-rtl::Reference<framework::Desktop> framework::getDesktop(
+const rtl::Reference<framework::Desktop> & framework::getDesktop(
css::uno::Reference<css::uno::XComponentContext> const & context)
{
static auto const instance = createDesktop(context);
diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx
index 380eab11ec67..8f3d77d322ba 100644
--- a/framework/source/services/dispatchhelper.cxx
+++ b/framework/source/services/dispatchhelper.cxx
@@ -25,6 +25,7 @@
#include <comphelper/profilezone.hxx>
#include <unotools/mediadescriptor.hxx>
+#include <utility>
#include <vcl/threadex.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -51,8 +52,9 @@ css::uno::Sequence<OUString> SAL_CALL DispatchHelper::getSupportedServiceNames()
@param xSMGR the global uno service manager, which can be used to create own needed services.
*/
-DispatchHelper::DispatchHelper(const css::uno::Reference<css::uno::XComponentContext>& xContext)
- : m_xContext(xContext)
+DispatchHelper::DispatchHelper(css::uno::Reference<css::uno::XComponentContext> xContext)
+ : m_xContext(std::move(xContext))
+ , m_aBlockFlag(false)
{
}
@@ -91,11 +93,12 @@ css::uno::Any SAL_CALL DispatchHelper::executeDispatch(
}
// parse given URL
+ css::uno::Reference<css::util::XURLTransformer> xParser;
/* SAFE { */
- osl::ClearableMutexGuard aReadLock(m_mutex);
- css::uno::Reference<css::util::XURLTransformer> xParser
- = css::util::URLTransformer::create(m_xContext);
- aReadLock.clear();
+ {
+ std::scoped_lock aReadLock(m_mutex);
+ xParser = css::util::URLTransformer::create(m_xContext);
+ }
/* } SAFE */
css::util::URL aURL;
@@ -117,7 +120,7 @@ css::uno::Any SAL_CALL DispatchHelper::executeDispatch(
return executeDispatch(xDispatch, aURL, true, lArguments);
}
-css::uno::Any
+const css::uno::Any&
DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>& xDispatch,
const css::util::URL& aURL, bool SyncronFlag,
const css::uno::Sequence<css::beans::PropertyValue>& lArguments)
@@ -137,8 +140,9 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>
css::uno::Sequence<css::beans::PropertyValue> aArguments(lArguments);
sal_Int32 nLength = lArguments.getLength();
aArguments.realloc(nLength + 1);
- aArguments[nLength].Name = "SynchronMode";
- aArguments[nLength].Value <<= SyncronFlag;
+ auto pArguments = aArguments.getArray();
+ pArguments[nLength].Name = "SynchronMode";
+ pArguments[nLength].Value <<= SyncronFlag;
if (xNotifyDispatch.is())
{
@@ -148,16 +152,18 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>
css::uno::UNO_QUERY);
/* SAFE { */
{
- osl::MutexGuard aWriteLock(m_mutex);
+ std::scoped_lock aWriteLock(m_mutex);
m_xBroadcaster = xNotifyDispatch;
- m_aBlock.reset();
+ m_aBlockFlag = false;
}
/* } SAFE */
// dispatch it and wait for a notification
// TODO/MBA: waiting in main thread?!
xNotifyDispatch->dispatchWithNotification(aURL, aArguments, xListener);
- m_aBlock.wait(); // wait for result
+
+ std::unique_lock aWriteLock(m_mutex);
+ m_aBlock.wait(aWriteLock, [this] { return m_aBlockFlag; }); // wait for result
}
else
{
@@ -180,9 +186,10 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>
*/
void SAL_CALL DispatchHelper::dispatchFinished(const css::frame::DispatchResultEvent& aResult)
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
m_aResult <<= aResult;
- m_aBlock.set();
+ m_aBlockFlag = true;
+ m_aBlock.notify_one();
m_xBroadcaster.clear();
}
@@ -193,9 +200,10 @@ void SAL_CALL DispatchHelper::dispatchFinished(const css::frame::DispatchResultE
*/
void SAL_CALL DispatchHelper::disposing(const css::lang::EventObject&)
{
- osl::MutexGuard g(m_mutex);
+ std::scoped_lock g(m_mutex);
m_aResult.clear();
- m_aBlock.set();
+ m_aBlockFlag = true;
+ m_aBlock.notify_one();
m_xBroadcaster.clear();
}
}
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index c6930eeed96b..0cbc1ca68f9d 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -37,7 +37,6 @@
#include <pattern/window.hxx>
#include <properties.h>
-#include <stdtypes.h>
#include <targets.h>
#include <com/sun/star/awt/Toolkit.hpp>
@@ -68,9 +67,11 @@
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/compbase.hxx>
-#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/multiinterfacecontainer3.hxx>
+#include <comphelper/multicontainer2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
+#include <rtl/ref.hxx>
#include <sal/log.hxx>
#include <vcl/window.hxx>
#include <vcl/wrkwin.hxx>
@@ -78,9 +79,10 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <unotools/moduleoptions.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <unotools/cmdoptions.hxx>
#include <vcl/threadex.hxx>
+#include <mutex>
using namespace framework;
@@ -112,7 +114,7 @@ class XFrameImpl:
{
public:
- explicit XFrameImpl(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit XFrameImpl(css::uno::Reference< css::uno::XComponentContext > xContext);
/// Initialization function after having acquire()'d.
void initListeners();
@@ -352,7 +354,7 @@ private:
// non threadsafe
void impl_checkMenuCloser ( );
- void impl_setCloser ( const css::uno::Reference< css::frame::XFrame2 >& xFrame , bool bState );
+ static void impl_setCloser ( const css::uno::Reference< css::frame::XFrame2 >& xFrame , bool bState );
void disableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager2 >& xLayoutManager);
@@ -373,11 +375,11 @@ private:
/// points to an external set progress, which should be used instead of the internal one.
css::uno::WeakReference< css::task::XStatusIndicator > m_xIndicatorInterception;
/// helper for XDispatch/Provider and interception interfaces
- css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper;
+ rtl::Reference< InterceptionHelper > m_xDispatchHelper;
/// helper for XFrames, XIndexAccess and XElementAccess interfaces
css::uno::Reference< css::frame::XFrames > m_xFramesHelper;
/// container for ALL Listener
- ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer;
+ comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer;
/// parent of this frame
css::uno::Reference< css::frame::XFramesSupplier > m_xParent;
/// containerwindow of this frame for embedded components
@@ -417,8 +419,8 @@ private:
typedef std::unordered_map<OUString, css::beans::Property> TPropInfoHash;
TPropInfoHash m_lProps;
- ListenerHash m_lSimpleChangeListener;
- ListenerHash m_lVetoChangeListener;
+ comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> m_lSimpleChangeListener;
+ comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString> m_lVetoChangeListener;
// hold it weak ... otherwise this helper has to be "killed" explicitly .-)
css::uno::WeakReference< css::uno::XInterface > m_xBroadcaster;
@@ -451,26 +453,19 @@ private:
The value must be different from NULL!
@onerror ASSERT in debug version or nothing in release version.
*//*-*****************************************************************************************************/
-XFrameImpl::XFrameImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext )
+XFrameImpl::XFrameImpl( css::uno::Reference< css::uno::XComponentContext > xContext )
: PartialWeakComponentImplHelper(m_aMutex)
// init member
- , m_xContext ( xContext )
+ , m_xContext (std::move( xContext ))
, m_aListenerContainer ( m_aMutex )
- , m_xParent ()
- , m_xContainerWindow ()
- , m_xComponentWindow ()
- , m_xController ()
, m_eActiveState ( E_INACTIVE )
- , m_sName ()
, m_bIsFrameTop ( true ) // I think we are top without a parent ... and there is no parent yet!
, m_bConnected ( false ) // There exist no component inside of use => sal_False, we are not connected!
, m_nExternalLockCount ( 0 )
, m_bSelfClose ( false ) // Important!
, m_bIsHidden ( true )
- , m_xTitleHelper ()
, m_lSimpleChangeListener ( m_aMutex )
, m_lVetoChangeListener ( m_aMutex )
- , m_aChildFrameContainer ()
{
}
@@ -481,30 +476,25 @@ void XFrameImpl::initListeners()
// Initialize a new dispatchhelper-object to handle dispatches.
// We use these helper as slave for our interceptor helper ... not directly!
// But he is event listener on THIS instance!
- DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this );
- css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
+ rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this );
- DispatchInformationProvider* pInfoHelper = new DispatchInformationProvider(m_xContext, this);
- m_xDispatchInfoHelper.set( static_cast< ::cppu::OWeakObject* >(pInfoHelper), css::uno::UNO_QUERY );
+ m_xDispatchInfoHelper = new DispatchInformationProvider(m_xContext, this);
// Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
// Set created dispatch provider as slowest slave of it.
// Hold interception helper by reference only - not by pointer!
// So it's easier to destroy it.
- InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
- m_xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
+ m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider );
// Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
// We hold member as reference ... not as pointer too!
// Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
// But look on dispose() for right order of deinitialization.
- OFrames* pFramesHelper = new OFrames( this, &m_aChildFrameContainer );
- m_xFramesHelper.set( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
+ m_xFramesHelper = new OFrames( this, &m_aChildFrameContainer );
// Initialize the drop target listener.
// We hold member as reference ... not as pointer too!
- OpenFileDropTargetListener* pDropListener = new OpenFileDropTargetListener( m_xContext, this );
- m_xDropTargetListener.set( static_cast< ::cppu::OWeakObject* >(pDropListener), css::uno::UNO_QUERY );
+ m_xDropTargetListener = new OpenFileDropTargetListener( m_xContext, this );
// Safe impossible cases
// We can't work without these helpers!
@@ -585,7 +575,7 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL XFrameImpl::loadComponentF
{
checkDisposed();
- css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XComponentLoader > xThis(this);
utl::MediaDescriptor aDescriptor(lArguments);
bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false);
@@ -736,9 +726,7 @@ void lcl_enableLayoutManager(const css::uno::Reference< css::frame::XLayoutManag
xFrame->addFrameActionListener(xLayoutManager);
- DockingAreaDefaultAcceptor* pAcceptor = new DockingAreaDefaultAcceptor(xFrame);
- css::uno::Reference< css::ui::XDockingAreaAcceptor > xDockingAreaAcceptor(
- static_cast< ::cppu::OWeakObject* >(pAcceptor), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<DockingAreaDefaultAcceptor> xDockingAreaAcceptor = new DockingAreaDefaultAcceptor(xFrame);
xLayoutManager->setDockingAreaAcceptor(xDockingAreaAcceptor);
}
@@ -778,15 +766,14 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
SolarMutexResettableGuard aWriteLock;
+ // This must be the first call of this method!
+ // We should initialize our object and open it for working.
if ( m_xContainerWindow.is() )
throw css::uno::RuntimeException(
"XFrameImpl::initialized() is called more than once, which is not useful nor allowed.",
static_cast< css::frame::XFrame* >(this));
- // This must be the first call of this method!
- // We should initialize our object and open it for working.
// Set the new window.
- SAL_WARN_IF( m_xContainerWindow.is(), "fwk.frame", "XFrameImpl::initialize(): Leak detected! This state should never occur ..." );
m_xContainerWindow = xWindow;
// if window is initially visible, we will never get a windowShowing event
@@ -812,17 +799,18 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind
lcl_enableLayoutManager(xLayoutManager, this);
// create progress helper
- css::uno::Reference< css::frame::XFrame > xThis (static_cast< css::frame::XFrame* >(this),
- css::uno::UNO_QUERY_THROW);
- css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory =
- css::task::StatusIndicatorFactory::createWithFrame(m_xContext, xThis,
- false/*DisableReschedule*/, true/*AllowParentShow*/ );
+ css::uno::Reference< css::frame::XFrame > xThis (this);
+ {
+ css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory =
+ css::task::StatusIndicatorFactory::createWithFrame(m_xContext, xThis,
+ false/*DisableReschedule*/, true/*AllowParentShow*/ );
- // SAFE -> ----------------------------------
- aWriteLock.reset();
- m_xIndicatorFactoryHelper = xIndicatorFactory;
- aWriteLock.clear();
- // <- SAFE ----------------------------------
+ // SAFE -> ----------------------------------
+ aWriteLock.reset();
+ m_xIndicatorFactoryHelper = std::move(xIndicatorFactory);
+ aWriteLock.clear();
+ // <- SAFE ----------------------------------
+ }
// Start listening for events after setting it on helper class ...
// So superfluous messages are filtered to NULL :-)
@@ -831,9 +819,7 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind
m_pWindowCommandDispatch.reset(new WindowCommandDispatch(m_xContext, this));
// Initialize title functionality
- TitleHelper* pTitleHelper = new TitleHelper( m_xContext );
- m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pTitleHelper), css::uno::UNO_QUERY_THROW);
- pTitleHelper->setOwner(xThis);
+ m_xTitleHelper = new TitleHelper( m_xContext, xThis, nullptr );
}
/*-****************************************************************************************************
@@ -1249,7 +1235,7 @@ void SAL_CALL XFrameImpl::activate()
// he is threadsafe himself and live if we live.
css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive();
css::uno::Reference< css::frame::XFramesSupplier > xParent = m_xParent;
- css::uno::Reference< css::frame::XFrame > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+ css::uno::Reference< css::frame::XFrame > xThis(this);
EActiveState eState = m_eActiveState;
aWriteLock.clear();
@@ -1327,7 +1313,7 @@ void SAL_CALL XFrameImpl::deactivate()
// Copy necessary member and free the lock.
css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive();
css::uno::Reference< css::frame::XFramesSupplier > xParent = m_xParent;
- css::uno::Reference< css::frame::XFrame > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+ css::uno::Reference< css::frame::XFrame > xThis(this);
EActiveState eState = m_eActiveState;
aWriteLock.clear();
@@ -1455,7 +1441,7 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt::
css::uno::Reference< css::awt::XWindow > xOldComponentWindow = m_xComponentWindow;
css::uno::Reference< css::frame::XController > xOldController = m_xController;
VclPtr<vcl::Window> pOwnWindow = VCLUnoHelper::GetWindow( xContainerWindow );
- bool bHadFocus = pOwnWindow->HasChildPathFocus();
+ bool bHadFocus = pOwnWindow != nullptr && pOwnWindow->HasChildPathFocus();
bool bWasConnected = m_bConnected;
aReadLock.clear();
/* } SAFE */
@@ -1490,6 +1476,15 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt::
{
SolarMutexGuard aWriteLock;
m_xController = nullptr;
+
+ if (m_xDispatchHelper)
+ {
+ rtl::Reference<DispatchProvider> pDispatchProvider = m_xDispatchHelper->GetSlave();
+ if (pDispatchProvider)
+ {
+ pDispatchProvider->ClearProtocolHandlers();
+ }
+ }
}
/* } SAFE */
@@ -1678,10 +1673,10 @@ void SAL_CALL XFrameImpl::close( sal_Bool bDeliverOwnership )
// internal operations too...
// Note: container is threadsafe himself.
css::lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this));
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
if (pContainer!=nullptr)
{
- ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
+ comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
while (pIterator.hasMoreElements())
{
try
@@ -1705,17 +1700,17 @@ void SAL_CALL XFrameImpl::close( sal_Bool bDeliverOwnership )
m_bSelfClose = true;
}
- throw css::util::CloseVetoException("Frame in use for loading document ...",static_cast< ::cppu::OWeakObject*>(this));
+ throw css::util::CloseVetoException("Frame in use for loading document...",static_cast< ::cppu::OWeakObject*>(this));
}
if ( ! setComponent(nullptr,nullptr) )
- throw css::util::CloseVetoException("Component couldn't be deattached ...",static_cast< ::cppu::OWeakObject*>(this));
+ throw css::util::CloseVetoException("Component couldn't be detached...",static_cast< ::cppu::OWeakObject*>(this));
// If closing is allowed... inform all listeners and dispose this frame!
pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
if (pContainer!=nullptr)
{
- ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
+ comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
while (pIterator.hasMoreElements())
{
try
@@ -1864,9 +1859,7 @@ void SAL_CALL XFrameImpl::setLayoutManager(const css::uno::Reference<css::uno::X
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL XFrameImpl::getPropertySetInfo()
{
checkDisposed();
- css::uno::Reference< css::beans::XPropertySetInfo > xInfo(
- static_cast< css::beans::XPropertySetInfo* >(this), css::uno::UNO_QUERY_THROW);
- return xInfo;
+ return css::uno::Reference< css::beans::XPropertySetInfo >(this);
}
void SAL_CALL XFrameImpl::setPropertyValue(const OUString& sProperty,
@@ -2003,10 +1996,10 @@ css::uno::Sequence< css::beans::Property > SAL_CALL XFrameImpl::getProperties()
sal_Int32 c = static_cast<sal_Int32>(m_lProps.size());
css::uno::Sequence< css::beans::Property > lProps(c);
-
+ auto lPropsRange = asNonConstRange(lProps);
for (auto const& elem : m_lProps)
{
- lProps[--c] = elem.second;
+ lPropsRange[--c] = elem.second;
}
return lProps;
@@ -2089,7 +2082,7 @@ void SAL_CALL XFrameImpl::disposing()
// We should hold a reference to ourself ...
// because our owner dispose us and release our reference ...
// May be we will die before we could finish this method ...
- css::uno::Reference< css::frame::XFrame > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+ css::uno::Reference< css::frame::XFrame > xThis(this);
SAL_INFO("fwk.frame", "[Frame] " << m_sName << " send dispose event to listener");
@@ -2126,7 +2119,7 @@ void SAL_CALL XFrameImpl::disposing()
css::uno::Reference< css::lang::XEventListener > xDispatchHelper;
{
SolarMutexGuard g;
- xDispatchHelper.set(m_xDispatchHelper, css::uno::UNO_QUERY_THROW);
+ xDispatchHelper = m_xDispatchHelper;
}
xDispatchHelper->disposing(aEvent);
xDispatchHelper.clear();
@@ -2322,7 +2315,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL XFrameImpl::queryDispatch(
aCommand = aURL.Path;
// Make std::unordered_map lookup if the current URL is in the disabled list
- if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) )
+ if ( m_aCommandOptions.LookupDisabled( aCommand ) )
return css::uno::Reference< css::frame::XDispatch >();
else
{
@@ -2392,7 +2385,7 @@ void SAL_CALL XFrameImpl::registerDispatchProviderInterceptor(
css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper;
{
SolarMutexGuard g;
- xInterceptionHelper.set( m_xDispatchHelper, css::uno::UNO_QUERY );
+ xInterceptionHelper = m_xDispatchHelper;
}
if (xInterceptionHelper.is()) {
xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor );
@@ -2411,7 +2404,7 @@ void SAL_CALL XFrameImpl::releaseDispatchProviderInterceptor(
css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper;
{
SolarMutexGuard g;
- xInterceptionHelper.set( m_xDispatchHelper, css::uno::UNO_QUERY );
+ xInterceptionHelper = m_xDispatchHelper;
}
if (xInterceptionHelper.is()) {
xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor );
@@ -2598,7 +2591,7 @@ void SAL_CALL XFrameImpl::windowClosing( const css::lang::EventObject& )
*//*-*****************************************************************************************************/
void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& )
{
- static osl::Mutex aFirstVisibleLock;
+ static std::mutex aFirstVisibleLock;
/* SAFE { */
SolarMutexClearableGuard aReadLock;
@@ -2613,10 +2606,10 @@ void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& )
return;
static bool bFirstVisibleTask = true;
- osl::ClearableMutexGuard aGuard(aFirstVisibleLock);
+ std::unique_lock aGuard(aFirstVisibleLock);
bool bMustBeTriggered = bFirstVisibleTask;
bFirstVisibleTask = false;
- aGuard.clear();
+ aGuard.unlock();
if (bMustBeTriggered)
{
@@ -2877,19 +2870,16 @@ bool XFrameImpl::impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent)
The used helper is threadsafe and it lives for the whole lifetime of
our own object.
*/
- ::cppu::OInterfaceContainerHelper* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName);
+ ::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName);
if (! pVetoListener)
return false;
- ::cppu::OInterfaceIteratorHelper pListener(*pVetoListener);
+ ::comphelper::OInterfaceIteratorHelper3 pListener(*pVetoListener);
while (pListener.hasMoreElements())
{
try
{
- css::uno::Reference< css::beans::XVetoableChangeListener > xListener(
- static_cast<css::beans::XVetoableChangeListener*>(pListener.next()),
- css::uno::UNO_QUERY_THROW);
- xListener->vetoableChange(aEvent);
+ pListener.next()->vetoableChange(aEvent);
}
catch(const css::uno::RuntimeException&)
{ pListener.remove(); }
@@ -2906,19 +2896,16 @@ void XFrameImpl::impl_notifyChangeListener(const css::beans::PropertyChangeEvent
The used helper is threadsafe and it lives for the whole lifetime of
our own object.
*/
- ::cppu::OInterfaceContainerHelper* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName);
+ ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName);
if (! pSimpleListener)
return;
- ::cppu::OInterfaceIteratorHelper pListener(*pSimpleListener);
+ ::comphelper::OInterfaceIteratorHelper3 pListener(*pSimpleListener);
while (pListener.hasMoreElements())
{
try
{
- css::uno::Reference< css::beans::XPropertyChangeListener > xListener(
- static_cast<css::beans::XVetoableChangeListener*>(pListener.next()),
- css::uno::UNO_QUERY_THROW);
- xListener->propertyChange(aEvent);
+ pListener.next()->propertyChange(aEvent);
}
catch(const css::uno::RuntimeException&)
{ pListener.remove(); }
@@ -2954,7 +2941,7 @@ void XFrameImpl::implts_sendFrameActionEvent( const css::frame::FrameAction& aAc
// Get container for right listener.
// FOLLOW LINES ARE THREADSAFE!!!
// ( OInterfaceContainerHelper2 is synchronized with m_aListenerContainer! )
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer(
+ comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer(
cppu::UnoType<css::frame::XFrameActionListener>::get());
if( pContainer == nullptr )
@@ -2964,7 +2951,7 @@ void XFrameImpl::implts_sendFrameActionEvent( const css::frame::FrameAction& aAc
css::frame::FrameActionEvent aFrameActionEvent( static_cast< ::cppu::OWeakObject* >(this), this, aAction );
// Get iterator for access to listener.
- ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+ comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer );
// Send message to all listener.
while( aIterator.hasMoreElements() )
{
@@ -3115,12 +3102,9 @@ void XFrameImpl::implts_startWindowListening()
SolarMutexClearableGuard aReadLock;
css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > xDragDropListener = m_xDropTargetListener;
- css::uno::Reference< css::awt::XWindowListener > xWindowListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
- css::uno::Reference< css::awt::XFocusListener > xFocusListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
- css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
+ css::uno::Reference< css::awt::XWindowListener > xWindowListener(this);
+ css::uno::Reference< css::awt::XFocusListener > xFocusListener(this);
+ css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener(this);
aReadLock.clear();
/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
@@ -3154,12 +3138,9 @@ void XFrameImpl::implts_stopWindowListening()
SolarMutexClearableGuard aReadLock;
css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > xDragDropListener = m_xDropTargetListener;
- css::uno::Reference< css::awt::XWindowListener > xWindowListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
- css::uno::Reference< css::awt::XFocusListener > xFocusListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
- css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener( static_cast< ::cppu::OWeakObject* >(this),
- css::uno::UNO_QUERY );
+ css::uno::Reference< css::awt::XWindowListener > xWindowListener(this);
+ css::uno::Reference< css::awt::XFocusListener > xFocusListener(this);
+ css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener(this);
aReadLock.clear();
/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
@@ -3232,7 +3213,7 @@ void XFrameImpl::implts_checkSuicide()
@param bState
<TRUE/> enable; <FALSE/> disable this state
*/
-
+// static
void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::XFrame2 >& xFrame ,
/*IN*/ bool bState )
{
@@ -3246,7 +3227,7 @@ void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::X
css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
xFrameProps->getPropertyValue(FRAME_PROPNAME_ASCII_LAYOUTMANAGER) >>= xLayoutManager;
css::uno::Reference< css::beans::XPropertySet > xLayoutProps(xLayoutManager, css::uno::UNO_QUERY_THROW);
- xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::makeAny(bState));
+ xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::Any(bState));
}
catch(const css::uno::RuntimeException&)
{ throw; }
@@ -3347,8 +3328,8 @@ com_sun_star_comp_framework_Frame_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- XFrameImpl *inst = new XFrameImpl(context);
- css::uno::XInterface *acquired_inst = cppu::acquire(inst);
+ rtl::Reference<XFrameImpl> inst = new XFrameImpl(context);
+ css::uno::XInterface *acquired_inst = cppu::acquire(inst.get());
inst->initListeners();
diff --git a/framework/source/services/mediatypedetectionhelper.cxx b/framework/source/services/mediatypedetectionhelper.cxx
index 440a3d59a022..894f95740ad9 100644
--- a/framework/source/services/mediatypedetectionhelper.cxx
+++ b/framework/source/services/mediatypedetectionhelper.cxx
@@ -62,10 +62,11 @@ css::uno::Sequence< OUString > SAL_CALL MediaTypeDetectionHelper::getSupportedSe
sal_Bool SAL_CALL MediaTypeDetectionHelper::mapStrings(uno::Sequence< OUString >& rSeq)
{
bool bModified = false;
+ auto rSeqRange = asNonConstRange(rSeq);
for( sal_Int32 i = rSeq.getLength(); i--; )
{
- OUString& rUrl = rSeq[i];
+ OUString& rUrl = rSeqRange[i];
INetContentType eType = INetContentTypes::GetContentTypeFromURL( rUrl );
OUString aType( INetContentTypes::GetContentType( eType ) );
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx
index 5c066d034d74..f2e5758b90e1 100644
--- a/framework/source/services/modulemanager.cxx
+++ b/framework/source/services/modulemanager.cxx
@@ -36,6 +36,8 @@
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/enumhelper.hxx>
+#include <comphelper/configuration.hxx>
+#include <utility>
namespace {
@@ -60,7 +62,7 @@ private:
public:
- explicit ModuleManager(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit ModuleManager(css::uno::Reference< css::uno::XComponentContext > xContext);
ModuleManager(const ModuleManager&) = delete;
ModuleManager& operator=(const ModuleManager&) = delete;
@@ -123,13 +125,16 @@ private:
OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent);
};
-ModuleManager::ModuleManager(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext(xContext)
+ModuleManager::ModuleManager(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext(std::move(xContext))
{
- m_xCFG.set( comphelper::ConfigurationHelper::openConfig(
- m_xContext, "/org.openoffice.Setup/Office/Factories",
- comphelper::EConfigurationModes::ReadOnly ),
- css::uno::UNO_QUERY_THROW );
+ if (!comphelper::IsFuzzing())
+ {
+ m_xCFG.set( comphelper::ConfigurationHelper::openConfig(
+ m_xContext, "/org.openoffice.Setup/Office/Factories",
+ comphelper::EConfigurationModes::ReadOnly ),
+ css::uno::UNO_QUERY_THROW );
+ }
}
OUString ModuleManager::getImplementationName()
@@ -233,7 +238,7 @@ void SAL_CALL ModuleManager::replaceByName(const OUString& sName ,
{
// let "NoSuchElementException" out ! We support the same API ...
// and without a flush() at the end all changed data before will be ignored !
- xModule->replaceByName(prop.first, prop.second);
+ xModule->replaceByName(prop.first.maString, prop.second);
}
::comphelper::ConfigurationHelper::flush(xCfg);
@@ -243,7 +248,8 @@ css::uno::Any SAL_CALL ModuleManager::getByName(const OUString& sName)
{
// get access to the element
css::uno::Reference< css::container::XNameAccess > xModule;
- m_xCFG->getByName(sName) >>= xModule;
+ if (m_xCFG)
+ m_xCFG->getByName(sName) >>= xModule;
if (!xModule.is())
{
throw css::uno::RuntimeException(
@@ -261,17 +267,17 @@ css::uno::Any SAL_CALL ModuleManager::getByName(const OUString& sName)
lProps[sPropName] = xModule->getByName(sPropName);
}
- return css::uno::makeAny(lProps.getAsConstPropertyValueList());
+ return css::uno::Any(lProps.getAsConstPropertyValueList());
}
css::uno::Sequence< OUString > SAL_CALL ModuleManager::getElementNames()
{
- return m_xCFG->getElementNames();
+ return m_xCFG ? m_xCFG->getElementNames() : css::uno::Sequence<OUString>();
}
sal_Bool SAL_CALL ModuleManager::hasByName(const OUString& sName)
{
- return m_xCFG->hasByName(sName);
+ return m_xCFG && m_xCFG->hasByName(sName);
}
css::uno::Type SAL_CALL ModuleManager::getElementType()
@@ -281,7 +287,7 @@ css::uno::Type SAL_CALL ModuleManager::getElementType()
sal_Bool SAL_CALL ModuleManager::hasElements()
{
- return m_xCFG->hasElements();
+ return m_xCFG && m_xCFG->hasElements();
}
css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::createSubSetEnumerationByQuery(const OUString&)
@@ -301,17 +307,14 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::crea
{
::comphelper::SequenceAsHashMap lModuleProps = getByName(rModuleName);
if (lModuleProps.match(lSearchProps))
- lResult.push_back(css::uno::makeAny(lModuleProps.getAsConstPropertyValueList()));
+ lResult.push_back(css::uno::Any(lModuleProps.getAsConstPropertyValueList()));
}
catch(const css::uno::Exception&)
{
}
}
- ::comphelper::OAnyEnumeration* pEnum =
- new ::comphelper::OAnyEnumeration(comphelper::containerToSequence(lResult));
- css::uno::Reference< css::container::XEnumeration > xEnum(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY_THROW);
- return xEnum;
+ return new ::comphelper::OAnyEnumeration(comphelper::containerToSequence(lResult));
}
OUString ModuleManager::implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent)
@@ -339,21 +342,6 @@ OUString ModuleManager::implts_identify(const css::uno::Reference< css::uno::XIn
return OUString();
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(new ModuleManager(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -361,8 +349,7 @@ com_sun_star_comp_framework_ModuleManager_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new ModuleManager(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index c59ef728ccb5..90cbb3281e10 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -40,6 +40,7 @@
#include <tools/urlobj.hxx>
#include <rtl/ustrbuf.hxx>
+#include <rtl/ref.hxx>
#include <sal/log.hxx>
#include <cppuhelper/basemutex.hxx>
@@ -49,11 +50,12 @@
#include <comphelper/sequence.hxx>
#include <comphelper/configurationhelper.hxx>
#include <unotools/configpaths.hxx>
+#include <o3tl/string_view.hxx>
using namespace framework;
-#define CFGPROP_USERPATHS "UserPaths"
-#define CFGPROP_WRITEPATH "WritePath"
+constexpr OUString CFGPROP_USERPATHS = u"UserPaths"_ustr;
+constexpr OUString CFGPROP_WRITEPATH = u"WritePath"_ustr;
/*
0 : old style "Template" string using ";" as separator
@@ -62,9 +64,9 @@ using namespace framework;
3 : write path "Template_write" string
*/
-#define POSTFIX_INTERNAL_PATHS "_internal"
-#define POSTFIX_USER_PATHS "_user"
-#define POSTFIX_WRITE_PATH "_writable"
+constexpr OUString POSTFIX_INTERNAL_PATHS = u"_internal"_ustr;
+constexpr OUString POSTFIX_USER_PATHS = u"_user"_ustr;
+constexpr OUString POSTFIX_WRITE_PATH = u"_writable"_ustr;
namespace {
@@ -99,11 +101,7 @@ class PathSettings : private cppu::BaseMutex
public:
PathInfo()
- : sPathName ()
- , lInternalPaths()
- , lUserPaths ()
- , sWritePath ()
- , bIsSinglePath (false)
+ : bIsSinglePath (false)
, bIsReadonly (false)
{}
@@ -168,7 +166,7 @@ public:
Attention: It's necessary for right function of this class, that the order of base
classes is the right one. Because we transfer information from one base to another
during this ctor runs! */
- explicit PathSettings(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit PathSettings(css::uno::Reference< css::uno::XComponentContext > xContext);
/** free all used resources ... if it was not already done. */
virtual ~PathSettings() override;
@@ -190,9 +188,9 @@ public:
// XInterface
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override;
- virtual void SAL_CALL acquire() throw () override
+ virtual void SAL_CALL acquire() noexcept override
{ OWeakObject::acquire(); }
- virtual void SAL_CALL release() throw () override
+ virtual void SAL_CALL release() noexcept override
{ OWeakObject::release(); }
// XTypeProvider
@@ -350,8 +348,7 @@ private:
/** filter "real user defined paths" from the old configuration schema
and set it as UserPaths on the new schema.
Can be removed with new major release ... */
-
- void impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
+ static void impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
const std::vector<OUString>& lOld );
/** reload one path directly from the new configuration schema (because
@@ -363,7 +360,7 @@ private:
or check if the given path value uses paths, which can be replaced with predefined
placeholder variables ...
*/
- void impl_subst(std::vector<OUString>& lVals ,
+ static void impl_subst(std::vector<OUString>& lVals ,
const css::uno::Reference< css::util::XStringSubstitution >& xSubst ,
bool bReSubst);
@@ -371,14 +368,14 @@ private:
bool bReSubst);
/** converts our new string list schema to the old ";" separated schema ... */
- OUString impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath ) const;
- std::vector<OUString> impl_convertOldStyle2Path(const OUString& sOldStylePath) const;
+ static OUString impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath );
+ static std::vector<OUString> impl_convertOldStyle2Path(std::u16string_view sOldStylePath);
/** remove still known paths from the given lList argument.
So real user defined paths can be extracted from the list of
fix internal paths !
*/
- void impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
+ static void impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
std::vector<OUString>& lList);
/** rebuild the member m_lPropDesc using the path list m_lPaths. */
@@ -397,8 +394,8 @@ private:
const PathSettings::PathInfo* impl_getPathAccessConst(sal_Int32 nHandle) const;
/** it checks, if the given path value seems to be a valid URL or system path. */
- bool impl_isValidPath(const OUString& sPath) const;
- bool impl_isValidPath(const std::vector<OUString>& lPath) const;
+ static bool impl_isValidPath(std::u16string_view sPath);
+ static bool impl_isValidPath(const std::vector<OUString>& lPath);
void impl_storePath(const PathSettings::PathInfo& aPath);
@@ -430,10 +427,10 @@ private:
css::uno::Reference< css::container::XNameAccess > fa_getCfgNew();
};
-PathSettings::PathSettings( const css::uno::Reference< css::uno::XComponentContext >& xContext )
+PathSettings::PathSettings( css::uno::Reference< css::uno::XComponentContext > xContext )
: PathSettings_BASE(m_aMutex)
, ::cppu::OPropertySetHelper(cppu::WeakComponentImplHelperBase::rBHelper)
- , m_xContext (xContext)
+ , m_xContext (std::move(xContext))
{
}
@@ -640,13 +637,13 @@ void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath)
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
aResubstPath.sPathName,
CFGPROP_USERPATHS,
- css::uno::makeAny(comphelper::containerToSequence(aResubstPath.lUserPaths)));
+ css::uno::Any(comphelper::containerToSequence(aResubstPath.lUserPaths)));
}
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
aResubstPath.sPathName,
CFGPROP_WRITEPATH,
- css::uno::makeAny(aResubstPath.sWritePath));
+ css::uno::Any(aResubstPath.sWritePath));
::comphelper::ConfigurationHelper::flush(xCfgNew);
@@ -664,6 +661,7 @@ void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath)
}
}
+// static
void PathSettings::impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
const std::vector<OUString>& lOld )
{
@@ -807,11 +805,10 @@ css::uno::Sequence< sal_Int32 > PathSettings::impl_mapPathName2IDList(std::u16st
// follow these group IDs! But if such ID is not in the range of [0..IDGROUP_COUNT]
// the outside can't determine the right group ... and can not fire the right events .-)
- css::uno::Sequence< sal_Int32 > lIDs(IDGROUP_COUNT);
- lIDs[0] = IDGROUP_OLDSTYLE;
- lIDs[1] = IDGROUP_INTERNAL_PATHS;
- lIDs[2] = IDGROUP_USER_PATHS;
- lIDs[3] = IDGROUP_WRITE_PATH;
+ css::uno::Sequence<sal_Int32> lIDs{ IDGROUP_OLDSTYLE, IDGROUP_INTERNAL_PATHS,
+ IDGROUP_USER_PATHS, IDGROUP_WRITE_PATH };
+ assert(lIDs.getLength() == IDGROUP_COUNT);
+ auto plIDs = lIDs.getArray();
sal_Int32 c = m_lPropDesc.getLength();
sal_Int32 i = 0;
@@ -820,16 +817,16 @@ css::uno::Sequence< sal_Int32 > PathSettings::impl_mapPathName2IDList(std::u16st
const css::beans::Property& rProp = m_lPropDesc[i];
if (rProp.Name == sPath)
- lIDs[IDGROUP_OLDSTYLE] = rProp.Handle;
+ plIDs[IDGROUP_OLDSTYLE] = rProp.Handle;
else
if (rProp.Name == sInternalProp)
- lIDs[IDGROUP_INTERNAL_PATHS] = rProp.Handle;
+ plIDs[IDGROUP_INTERNAL_PATHS] = rProp.Handle;
else
if (rProp.Name == sUserProp)
- lIDs[IDGROUP_USER_PATHS] = rProp.Handle;
+ plIDs[IDGROUP_USER_PATHS] = rProp.Handle;
else
if (rProp.Name == sWriteProp)
- lIDs[IDGROUP_WRITE_PATH] = rProp.Handle;
+ plIDs[IDGROUP_WRITE_PATH] = rProp.Handle;
}
return lIDs;
@@ -840,8 +837,11 @@ void PathSettings::impl_notifyPropListener( std::u16string_view sPath,
const PathSettings::PathInfo* pPathNew)
{
css::uno::Sequence< sal_Int32 > lHandles(1);
+ auto plHandles = lHandles.getArray();
css::uno::Sequence< css::uno::Any > lOldVals(1);
+ auto plOldVals = lOldVals.getArray();
css::uno::Sequence< css::uno::Any > lNewVals(1);
+ auto plNewVals = lNewVals.getArray();
css::uno::Sequence< sal_Int32 > lIDs = impl_mapPathName2IDList(sPath);
sal_Int32 c = lIDs.getLength();
@@ -857,7 +857,7 @@ void PathSettings::impl_notifyPropListener( std::u16string_view sPath,
)
continue;
- lHandles[0] = nID;
+ plHandles[0] = nID;
switch(impl_getPropGroup(nID))
{
case IDGROUP_OLDSTYLE :
@@ -865,12 +865,12 @@ void PathSettings::impl_notifyPropListener( std::u16string_view sPath,
if (pPathOld)
{
OUString sVal = impl_convertPath2OldStyle(*pPathOld);
- lOldVals[0] <<= sVal;
+ plOldVals[0] <<= sVal;
}
if (pPathNew)
{
OUString sVal = impl_convertPath2OldStyle(*pPathNew);
- lNewVals[0] <<= sVal;
+ plNewVals[0] <<= sVal;
}
}
break;
@@ -878,39 +878,40 @@ void PathSettings::impl_notifyPropListener( std::u16string_view sPath,
case IDGROUP_INTERNAL_PATHS :
{
if (pPathOld)
- lOldVals[0] <<= comphelper::containerToSequence(pPathOld->lInternalPaths);
+ plOldVals[0] <<= comphelper::containerToSequence(pPathOld->lInternalPaths);
if (pPathNew)
- lNewVals[0] <<= comphelper::containerToSequence(pPathNew->lInternalPaths);
+ plNewVals[0] <<= comphelper::containerToSequence(pPathNew->lInternalPaths);
}
break;
case IDGROUP_USER_PATHS :
{
if (pPathOld)
- lOldVals[0] <<= comphelper::containerToSequence(pPathOld->lUserPaths);
+ plOldVals[0] <<= comphelper::containerToSequence(pPathOld->lUserPaths);
if (pPathNew)
- lNewVals[0] <<= comphelper::containerToSequence(pPathNew->lUserPaths);
+ plNewVals[0] <<= comphelper::containerToSequence(pPathNew->lUserPaths);
}
break;
case IDGROUP_WRITE_PATH :
{
if (pPathOld)
- lOldVals[0] <<= pPathOld->sWritePath;
+ plOldVals[0] <<= pPathOld->sWritePath;
if (pPathNew)
- lNewVals[0] <<= pPathNew->sWritePath;
+ plNewVals[0] <<= pPathNew->sWritePath;
}
break;
}
- fire(lHandles.getArray(),
- lNewVals.getArray(),
- lOldVals.getArray(),
+ fire(plHandles,
+ plNewVals,
+ plOldVals,
1,
false);
}
}
+// static
void PathSettings::impl_subst(std::vector<OUString>& lVals ,
const css::uno::Reference< css::util::XStringSubstitution >& xSubst ,
bool bReSubst)
@@ -940,44 +941,41 @@ void PathSettings::impl_subst(PathSettings::PathInfo& aPath ,
aPath.sWritePath = xSubst->substituteVariables(aPath.sWritePath, false);
}
-OUString PathSettings::impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath) const
+// static
+OUString PathSettings::impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath)
{
- std::vector<OUString> lTemp;
- lTemp.reserve(rPath.lInternalPaths.size() + rPath.lUserPaths.size() + 1);
+ OUStringBuffer sPathVal(256);
for (auto const& internalPath : rPath.lInternalPaths)
{
- lTemp.push_back(internalPath);
+ if (sPathVal.getLength())
+ sPathVal.append(";");
+ sPathVal.append(internalPath);
}
for (auto const& userPath : rPath.lUserPaths)
{
- lTemp.push_back(userPath);
+ if (sPathVal.getLength())
+ sPathVal.append(";");
+ sPathVal.append(userPath);
}
-
if (!rPath.sWritePath.isEmpty())
- lTemp.push_back(rPath.sWritePath);
-
- OUStringBuffer sPathVal(256);
- for ( auto pIt = lTemp.begin();
- pIt != lTemp.end();
- )
{
- sPathVal.append(*pIt);
- ++pIt;
- if (pIt != lTemp.end())
+ if (sPathVal.getLength())
sPathVal.append(";");
+ sPathVal.append(rPath.sWritePath);
}
return sPathVal.makeStringAndClear();
}
-std::vector<OUString> PathSettings::impl_convertOldStyle2Path(const OUString& sOldStylePath) const
+// static
+std::vector<OUString> PathSettings::impl_convertOldStyle2Path(std::u16string_view sOldStylePath)
{
std::vector<OUString> lList;
sal_Int32 nToken = 0;
do
{
- OUString sToken = sOldStylePath.getToken(0, ';', nToken);
+ OUString sToken( o3tl::getToken(sOldStylePath, 0, ';', nToken) );
if (!sToken.isEmpty())
lList.push_back(sToken);
}
@@ -986,6 +984,7 @@ std::vector<OUString> PathSettings::impl_convertOldStyle2Path(const OUString& sO
return lList;
}
+// static
void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
std::vector<OUString>& lList)
{
@@ -1002,11 +1001,10 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
}
// Erase items not in lList from the user path list.
- rPath.lUserPaths.erase(std::remove_if(rPath.lUserPaths.begin(), rPath.lUserPaths.end(),
+ std::erase_if(rPath.lUserPaths,
[&lList](const OUString& rItem) {
return std::find(lList.begin(), lList.end(), rItem) == lList.end();
- }),
- rPath.lUserPaths.end());
+ });
// Erase items in the user path list from lList.
for (auto const& userPath : rPath.lUserPaths)
@@ -1030,13 +1028,14 @@ void PathSettings::impl_rebuildPropertyDescriptor()
sal_Int32 c = static_cast<sal_Int32>(m_lPaths.size());
sal_Int32 i = 0;
m_lPropDesc.realloc(c*IDGROUP_COUNT);
+ auto plPropDesc = m_lPropDesc.getArray();
for (auto const& path : m_lPaths)
{
const PathSettings::PathInfo& rPath = path.second;
css::beans::Property* pProp = nullptr;
- pProp = &(m_lPropDesc[i]);
+ pProp = &(plPropDesc[i]);
pProp->Name = rPath.sPathName;
pProp->Handle = i;
pProp->Type = cppu::UnoType<OUString>::get();
@@ -1045,7 +1044,7 @@ void PathSettings::impl_rebuildPropertyDescriptor()
pProp->Attributes |= css::beans::PropertyAttribute::READONLY;
++i;
- pProp = &(m_lPropDesc[i]);
+ pProp = &(plPropDesc[i]);
pProp->Name = rPath.sPathName+POSTFIX_INTERNAL_PATHS;
pProp->Handle = i;
pProp->Type = cppu::UnoType<css::uno::Sequence< OUString >>::get();
@@ -1053,7 +1052,7 @@ void PathSettings::impl_rebuildPropertyDescriptor()
css::beans::PropertyAttribute::READONLY;
++i;
- pProp = &(m_lPropDesc[i]);
+ pProp = &(plPropDesc[i]);
pProp->Name = rPath.sPathName+POSTFIX_USER_PATHS;
pProp->Handle = i;
pProp->Type = cppu::UnoType<css::uno::Sequence< OUString >>::get();
@@ -1062,7 +1061,7 @@ void PathSettings::impl_rebuildPropertyDescriptor()
pProp->Attributes |= css::beans::PropertyAttribute::READONLY;
++i;
- pProp = &(m_lPropDesc[i]);
+ pProp = &(plPropDesc[i]);
pProp->Name = rPath.sPathName+POSTFIX_WRITE_PATH;
pProp->Handle = i;
pProp->Type = cppu::UnoType<OUString>::get();
@@ -1216,7 +1215,8 @@ void PathSettings::impl_setPathValue( sal_Int32 nID ,
*pOrgPath = std::move(aChangePath);
}
-bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath) const
+// static
+bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath)
{
for (auto const& path : lPath)
{
@@ -1227,7 +1227,8 @@ bool PathSettings::impl_isValidPath(const std::vector<OUString>& lPath) const
return true;
}
-bool PathSettings::impl_isValidPath(const OUString& sPath) const
+// static
+bool PathSettings::impl_isValidPath(std::u16string_view sPath)
{
// allow empty path to reset a path.
// idea by LLA to support empty paths
@@ -1409,25 +1410,6 @@ css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgNew()
return xCfg;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new PathSettings(context)))
- {
- // fill cache
- static_cast<PathSettings *>(static_cast<cppu::OWeakObject *>
- (instance.get()))->impl_readAll();
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -1435,8 +1417,11 @@ com_sun_star_comp_framework_PathSettings_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ rtl::Reference<PathSettings> xPathSettings = new PathSettings(context);
+ // fill cache
+ xPathSettings->impl_readAll();
+
+ return cppu::acquire(xPathSettings.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx
index e90cde5c3641..a77e7f961ebb 100644
--- a/framework/source/services/sessionlistener.cxx
+++ b/framework/source/services/sessionlistener.cxx
@@ -22,7 +22,7 @@
#include <framework/desktop.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/theAutoRecovery.hpp>
@@ -42,6 +42,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <utility>
using namespace css;
using namespace com::sun::star::uno;
@@ -101,7 +102,7 @@ private:
void QuitSessionQuietly();
public:
- explicit SessionListener(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit SessionListener(css::uno::Reference< css::uno::XComponentContext > xContext);
virtual ~SessionListener() override;
@@ -138,8 +139,8 @@ public:
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& event) override;
};
-SessionListener::SessionListener(const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- : m_xContext( rxContext )
+SessionListener::SessionListener(css::uno::Reference< css::uno::XComponentContext > rxContext )
+ : m_xContext(std::move( rxContext ))
, m_bRestored( false )
, m_bSessionStoreRequested( false )
, m_bAllowUserInteractionOnQuit( false )
@@ -179,8 +180,8 @@ void SessionListener::StoreSession( bool bAsync )
if ( bAsync )
xDispatch->addStatusListener(this, aURL);
- Sequence< PropertyValue > args(1);
- args[0] = PropertyValue("DispatchAsynchron",-1,makeAny(bAsync),PropertyState_DIRECT_VALUE);
+ Sequence< PropertyValue > args{ PropertyValue("DispatchAsynchron",-1,Any(bAsync),
+ PropertyState_DIRECT_VALUE) };
xDispatch->dispatch(aURL, args);
} catch (const css::uno::Exception&) {
TOOLS_WARN_EXCEPTION("fwk.session", "");
@@ -207,8 +208,8 @@ void SessionListener::QuitSessionQuietly()
aURL.Complete = "vnd.sun.star.autorecovery:/doSessionQuietQuit";
xURLTransformer->parseStrict(aURL);
- Sequence< PropertyValue > args(1);
- args[0] = PropertyValue("DispatchAsynchron",-1,makeAny(false),PropertyState_DIRECT_VALUE);
+ Sequence< PropertyValue > args{ PropertyValue("DispatchAsynchron",-1,Any(false),
+ PropertyState_DIRECT_VALUE) };
xDispatch->dispatch(aURL, args);
} catch (const css::uno::Exception&) {
TOOLS_WARN_EXCEPTION("fwk.session", "");
@@ -365,7 +366,8 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted
catch( const css::uno::Exception& )
{
StoreSession( true );
- m_rSessionManager->interactionDone( this );
+ if (m_rSessionManager.is())
+ m_rSessionManager->interactionDone(this);
}
if ( m_rSessionManager.is() && m_bTerminated )
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index f5f7b71ffe61..2803dfed7058 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -20,8 +20,7 @@
#include <config_folders.h>
#include <comphelper/lok.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/bootstrap.hxx>
@@ -129,15 +128,14 @@ struct ReSubstFixedVarOrder
}
};
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::util::XStringSubstitution,
css::lang::XServiceInfo > SubstitutePathVariables_BASE;
-class SubstitutePathVariables : private cppu::BaseMutex,
- public SubstitutePathVariables_BASE
+class SubstitutePathVariables : public SubstitutePathVariables_BASE
{
public:
- explicit SubstitutePathVariables(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit SubstitutePathVariables();
virtual OUString SAL_CALL getImplementationName() override
{
@@ -164,11 +162,11 @@ protected:
// Special case (transient) values can change during runtime!
// Don't store them in the pre defined struct
- OUString GetWorkPath() const;
- OUString GetWorkVariableValue() const;
- OUString GetPathVariableValue() const;
+ static OUString GetWorkPath();
+ static OUString GetWorkVariableValue();
+ static OUString GetPathVariableValue();
- OUString GetHomeVariableValue() const;
+ static OUString GetHomeVariableValue();
// XStringSubstitution implementation methods
/// @throws css::container::NoSuchElementException
@@ -187,12 +185,9 @@ private:
VarNameToIndexMap m_aPreDefVarMap; // Mapping from pre-def variable names to enum for array access
PredefinedPathVariables m_aPreDefVars; // All predefined variables
std::vector<ReSubstFixedVarOrder> m_aReSubstFixedVarOrder; // To speed up resubstitution fixed variables (order for lookup)
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
};
-SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentContext >& xContext ) :
- SubstitutePathVariables_BASE(m_aMutex),
- m_xContext( xContext )
+SubstitutePathVariables::SubstitutePathVariables()
{
SetPredefinedPathVariables();
@@ -227,26 +222,27 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
// XStringSubstitution
OUString SAL_CALL SubstitutePathVariables::substituteVariables( const OUString& aText, sal_Bool bSubstRequired )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return impl_substituteVariable( aText, bSubstRequired );
}
OUString SAL_CALL SubstitutePathVariables::reSubstituteVariables( const OUString& aText )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return impl_reSubstituteVariables( aText );
}
OUString SAL_CALL SubstitutePathVariables::getSubstituteVariableValue( const OUString& aVariable )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return impl_getSubstituteVariableValue( aVariable );
}
-OUString SubstitutePathVariables::GetWorkPath() const
+// static
+OUString SubstitutePathVariables::GetWorkPath()
{
OUString aWorkPath;
- css::uno::Reference< css::container::XHierarchicalNameAccess > xPaths(officecfg::Office::Paths::Paths::get(m_xContext), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::container::XHierarchicalNameAccess > xPaths(officecfg::Office::Paths::Paths::get(), css::uno::UNO_QUERY_THROW);
if (!(xPaths->getByHierarchicalName("['Work']/WritePath") >>= aWorkPath))
// fallback in case config layer does not return a usable work dir value.
aWorkPath = GetWorkVariableValue();
@@ -254,10 +250,11 @@ OUString SubstitutePathVariables::GetWorkPath() const
return aWorkPath;
}
-OUString SubstitutePathVariables::GetWorkVariableValue() const
+// static
+OUString SubstitutePathVariables::GetWorkVariableValue()
{
OUString aWorkPath;
- std::optional<OUString> x(officecfg::Office::Paths::Variables::Work::get(m_xContext));
+ std::optional<OUString> x(officecfg::Office::Paths::Variables::Work::get());
if (!x)
{
// fallback to $HOME in case platform dependent config layer does not return
@@ -270,7 +267,8 @@ OUString SubstitutePathVariables::GetWorkVariableValue() const
return aWorkPath;
}
-OUString SubstitutePathVariables::GetHomeVariableValue() const
+// static
+OUString SubstitutePathVariables::GetHomeVariableValue()
{
osl::Security aSecurity;
OUString aHomePath;
@@ -279,7 +277,8 @@ OUString SubstitutePathVariables::GetHomeVariableValue() const
return aHomePath;
}
-OUString SubstitutePathVariables::GetPathVariableValue() const
+// static
+OUString SubstitutePathVariables::GetPathVariableValue()
{
OUString aRetStr;
const char* pEnv = getenv( "PATH" );
@@ -639,7 +638,7 @@ void SubstitutePathVariables::SetPredefinedPathVariables()
// Set $(prog), $(progpath), $(progurl)
INetURLObject aProgObj(
m_aPreDefVars.m_FixedVar[PREDEFVAR_BRANDBASEURL] );
- if ( !aProgObj.HasError() && aProgObj.insertName( LIBO_BIN_FOLDER ) )
+ if ( !aProgObj.HasError() && aProgObj.insertName( u"" LIBO_BIN_FOLDER ) )
{
m_aPreDefVars.m_FixedVar[ PREDEFVAR_PROGPATH ] = aProgObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
m_aPreDefVars.m_FixedVar[ PREDEFVAR_PROGURL ] = m_aPreDefVars.m_FixedVar[ PREDEFVAR_PROGPATH ];
@@ -687,31 +686,14 @@ void SubstitutePathVariables::SetPredefinedPathVariables()
m_aPreDefVars.m_FixedVar[ PREDEFVAR_TEMP ] = aTmp;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new SubstitutePathVariables(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_framework_PathSubstitution_get_implementation(
- css::uno::XComponentContext *context,
+ css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new SubstitutePathVariables());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx
index 43dd64c7d573..7a60b6275a64 100644
--- a/framework/source/services/taskcreatorsrv.cxx
+++ b/framework/source/services/taskcreatorsrv.cxx
@@ -35,11 +35,11 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <comphelper/sequenceashashmap.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <svtools/colorcfg.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
@@ -47,12 +47,11 @@ using namespace framework;
namespace {
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo,
css::lang::XSingleServiceFactory> TaskCreatorService_BASE;
-class TaskCreatorService : private cppu::BaseMutex,
- public TaskCreatorService_BASE
+class TaskCreatorService : public TaskCreatorService_BASE
{
private:
@@ -63,7 +62,7 @@ private:
public:
- explicit TaskCreatorService(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ explicit TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext);
virtual OUString SAL_CALL getImplementationName() override
{
@@ -91,7 +90,7 @@ private:
const css::awt::Rectangle& aPosSize ,
bool bTopWindow );
- void implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) const;
+ static void implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow);
css::uno::Reference< css::frame::XFrame2 > implts_createFrame( const css::uno::Reference< css::frame::XFrame >& xParentFrame ,
const css::uno::Reference< css::awt::XWindow >& xContainerWindow ,
@@ -100,14 +99,13 @@ private:
void implts_establishWindowStateListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame );
void implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame2 >& xFrame );
- void implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame );
+ static void implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame );
- OUString impl_filterNames( const OUString& sName );
+ static OUString impl_filterNames( const OUString& sName );
};
-TaskCreatorService::TaskCreatorService(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : TaskCreatorService_BASE(m_aMutex)
- , m_xContext (xContext )
+TaskCreatorService::TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
{
}
@@ -130,7 +128,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
bool bSupportPersistentWindowState = lArgs.getUnpackedValueOrDefault(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE , false );
bool bEnableTitleBarUpdate = lArgs.getUnpackedValueOrDefault(ARGUMENT_ENABLE_TITLEBARUPDATE , true );
// If the frame is explicitly requested to be hidden.
- bool bHidden = lArgs.getUnpackedValueOrDefault("HiddenForConversion", false);
+ bool bHidden = lArgs.getUnpackedValueOrDefault(ARGUMENT_HIDDENFORCONVERSION, false);
// We use FrameName property to set it as API name of the new created frame later.
// But those frame names must be different from the set of special target names as e.g. _blank, _self etcpp !
@@ -178,7 +176,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
}
css::uno::Reference< css::frame::XFrame2 > xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName);
- // special freature:
+ // special feature:
// A special listener will restore pos/size states in case
// a component was loaded into the frame first time.
if (bSupportPersistentWindowState)
@@ -191,7 +189,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
if (bTopLevelDocumentWindow)
implts_establishDocModifyListener (xFrame);
- // special freature:
+ // special feature:
// A special listener will update title bar (text and icon)
// if component of frame will be changed.
if (bEnableTitleBarUpdate)
@@ -205,7 +203,8 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
return css::uno::Reference< css::uno::XInterface >(xFrame, css::uno::UNO_QUERY_THROW);
}
-void TaskCreatorService::implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) const
+// static
+void TaskCreatorService::implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow)
{
// SYNCHRONIZED ->
SolarMutexGuard aSolarGuard;
@@ -313,37 +312,33 @@ void TaskCreatorService::implts_establishWindowStateListener( const css::uno::Re
// We must create a special listener service and couple it with the new created task frame.
// He will restore or save the window state of it ...
// See used classes for further information too.
- PersistentWindowState* pPersistentStateHandler = new PersistentWindowState( m_xContext );
- css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pPersistentStateHandler), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<PersistentWindowState> pPersistentStateHandler = new PersistentWindowState( m_xContext );
- css::uno::Sequence< css::uno::Any > lInitData(1);
- lInitData[0] <<= xFrame;
- xInit->initialize(lInitData);
+ css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
+ pPersistentStateHandler->initialize(lInitData);
}
+// static
void TaskCreatorService::implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame )
{
// Special feature: It's allowed for frames using a top level window only!
// We must create a special listener service and couple it with the new created task frame.
// It will tag the window as modified if the underlying model was modified ...
- TagWindowAsModified* pTag = new TagWindowAsModified();
- css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pTag), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<TagWindowAsModified> pTag = new TagWindowAsModified();
- css::uno::Sequence< css::uno::Any > lInitData(1);
- lInitData[0] <<= xFrame;
- xInit->initialize(lInitData);
+ css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
+ pTag->initialize(lInitData);
}
void TaskCreatorService::implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame2 >& xFrame )
{
- TitleBarUpdate* pHelper = new TitleBarUpdate (m_xContext);
- css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
+ rtl::Reference<TitleBarUpdate> pHelper = new TitleBarUpdate (m_xContext);
- css::uno::Sequence< css::uno::Any > lInitData(1);
- lInitData[0] <<= xFrame;
- xInit->initialize(lInitData);
+ css::uno::Sequence< css::uno::Any > lInitData{ css::uno::Any(xFrame) };
+ pHelper->initialize(lInitData);
}
+// static
OUString TaskCreatorService::impl_filterNames( const OUString& sName )
{
OUString sFiltered;
@@ -352,22 +347,6 @@ OUString TaskCreatorService::impl_filterNames( const OUString& sName )
return sFiltered;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new TaskCreatorService(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -375,8 +354,7 @@ com_sun_star_comp_framework_TaskCreator_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new TaskCreatorService(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/services/urltransformer.cxx b/framework/source/services/urltransformer.cxx
index b5d319ef8716..84e44e422de4 100644
--- a/framework/source/services/urltransformer.cxx
+++ b/framework/source/services/urltransformer.cxx
@@ -58,7 +58,7 @@ public:
virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL, sal_Bool bWithPassword ) override;
};
-void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseIntern)
+void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL)
{
// Get all information about this URL.
_rURL.Protocol = INetURLObject::GetScheme( _rParser.GetProtocol() );
@@ -76,8 +76,8 @@ void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseI
OUStringBuffer aPath(128);
for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
{
- aPath.append( '/');
- aPath.append( _rParser.getName( nIndex, false, INetURLObject::DecodeMechanism::NONE ));
+ aPath.append( "/"
+ + _rParser.getName( nIndex, false, INetURLObject::DecodeMechanism::NONE ));
}
if ( nCount > 0 )
@@ -98,11 +98,9 @@ void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseI
// INetURLObject supports only an intelligent method of parsing URL's. So write
// back Complete to have a valid encoded URL in all cases!
_rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if ( _bUseIntern )
- _rURL.Complete = _rURL.Complete.intern();
- _rParser.SetMark ( OUString() );
- _rParser.SetParam( OUString() );
+ _rParser.SetMark( u"" );
+ _rParser.SetParam( u"" );
_rURL.Main = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
@@ -117,41 +115,41 @@ sal_Bool SAL_CALL URLTransformer::parseStrict( css::util::URL& aURL )
}
// Try to extract the protocol
sal_Int32 nURLIndex = aURL.Complete.indexOf( ':' );
- if ( nURLIndex > 1 )
+ if ( nURLIndex <= 1 )
+ return false;
+
+ std::u16string_view aProtocol = aURL.Complete.subView( 0, nURLIndex+1 );
+
+ // If INetURLObject knows this protocol let it parse
+ if ( INetURLObject::CompareProtocolScheme( aProtocol ) != INetProtocol::NotValid )
{
- OUString aProtocol = aURL.Complete.copy( 0, nURLIndex+1 );
+ // Initialize parser with given URL.
+ INetURLObject aParser( aURL.Complete );
- // If INetURLObject knows this protocol let it parse
- if ( INetURLObject::CompareProtocolScheme( aProtocol ) != INetProtocol::NotValid )
+ // Get all information about this URL.
+ INetProtocol eINetProt = aParser.GetProtocol();
+ if ( eINetProt == INetProtocol::NotValid )
{
- // Initialize parser with given URL.
- INetURLObject aParser( aURL.Complete );
-
- // Get all information about this URL.
- INetProtocol eINetProt = aParser.GetProtocol();
- if ( eINetProt == INetProtocol::NotValid )
- {
- return false;
- }
- else if ( !aParser.HasError() )
- {
- lcl_ParserHelper(aParser,aURL,false);
- // Return "URL is parsed".
- return true;
- }
+ return false;
}
- else
+ else if ( !aParser.HasError() )
{
- // Minimal support for unknown protocols. This is mandatory to support the "Protocol Handlers" implemented
- // in framework!
- aURL.Protocol = aProtocol;
- aURL.Main = aURL.Complete;
- aURL.Path = aURL.Complete.copy( nURLIndex+1 );
-
+ lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed".
return true;
}
}
+ else
+ {
+ // Minimal support for unknown protocols. This is mandatory to support the "Protocol Handlers" implemented
+ // in framework!
+ aURL.Protocol = aProtocol;
+ aURL.Main = aURL.Complete;
+ aURL.Path = aURL.Complete.copy( nURLIndex+1 );
+
+ // Return "URL is parsed".
+ return true;
+ }
return false;
}
@@ -174,7 +172,7 @@ sal_Bool SAL_CALL URLTransformer::parseSmart( css::util::URL& aURL,
bool bOk = aParser.SetSmartURL( aURL.Complete );
if ( bOk )
{
- lcl_ParserHelper(aParser,aURL,true);
+ lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed".
return true;
}
@@ -227,8 +225,7 @@ sal_Bool SAL_CALL URLTransformer::assemble( css::util::URL& aURL )
aCompletePath.append( aURL.Name );
else
{
- aCompletePath.append( '/' );
- aCompletePath.append( aURL.Name );
+ aCompletePath.append( "/" + aURL.Name );
}
}
@@ -238,7 +235,7 @@ sal_Bool SAL_CALL URLTransformer::assemble( css::util::URL& aURL )
aURL.Password ,
aURL.Server ,
aURL.Port ,
- aCompletePath.makeStringAndClear() );
+ aCompletePath);
if ( !bResult )
return false;
diff --git a/framework/source/uiconfiguration/CommandImageResolver.cxx b/framework/source/uiconfiguration/CommandImageResolver.cxx
index b57d17eb1ab5..a431ae320b35 100644
--- a/framework/source/uiconfiguration/CommandImageResolver.cxx
+++ b/framework/source/uiconfiguration/CommandImageResolver.cxx
@@ -70,7 +70,7 @@ CommandImageResolver::~CommandImageResolver()
{
}
-void CommandImageResolver::registerCommands(Sequence<OUString>& aCommandSequence)
+void CommandImageResolver::registerCommands(const Sequence<OUString>& aCommandSequence)
{
sal_Int32 nSequenceSize = aCommandSequence.getLength();
diff --git a/framework/source/uiconfiguration/CommandImageResolver.hxx b/framework/source/uiconfiguration/CommandImageResolver.hxx
index d79274304b2f..0622caf332bb 100644
--- a/framework/source/uiconfiguration/CommandImageResolver.hxx
+++ b/framework/source/uiconfiguration/CommandImageResolver.hxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef INCLUDED_VCL_COMMANDICONRESOLVER_HXX
-#define INCLUDED_VCL_COMMANDICONRESOLVER_HXX
+#pragma once
#include <vcl/image.hxx>
#include <o3tl/enumarray.hxx>
@@ -41,7 +40,7 @@ public:
CommandImageResolver();
~CommandImageResolver();
- void registerCommands(css::uno::Sequence<OUString>& aCommandSequence);
+ void registerCommands(const css::uno::Sequence<OUString>& aCommandSequence);
Image getImageFromCommandURL(ImageType nImageType, const OUString& rCommandURL);
std::vector<OUString>& getCommandNames() { return m_aImageCommandNameVector; }
@@ -51,6 +50,4 @@ public:
} // end namespace vcl
-#endif // INCLUDED_VCL_COMMANDICONRESOLVER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/ImageList.cxx b/framework/source/uiconfiguration/ImageList.cxx
index e047e6a340c7..5fb0f44f65b6 100644
--- a/framework/source/uiconfiguration/ImageList.cxx
+++ b/framework/source/uiconfiguration/ImageList.cxx
@@ -56,7 +56,7 @@ BitmapEx ImageList::GetAsHorizontalStrip() const
tools::Rectangle aDestRect( Point( nIdx * aImageSize.Width(), 0 ), aImageSize );
ImageAryData *pData = maImages[ nIdx ].get();
BitmapEx aTmp = pData->maImage.GetBitmapEx();
- aResult.CopyPixel( aDestRect, aSrcRect, &aTmp);
+ aResult.CopyPixel( aDestRect, aSrcRect, aTmp);
}
return aResult;
@@ -158,7 +158,7 @@ sal_uInt16 ImageList::GetImageId( sal_uInt16 nPos ) const
return maImages[ nPos ]->mnId;
}
-OUString ImageList::GetImageName( sal_uInt16 nPos ) const
+const OUString & ImageList::GetImageName( sal_uInt16 nPos ) const
{
return maImages[ nPos ]->maName;
}
diff --git a/framework/source/uiconfiguration/ImageList.hxx b/framework/source/uiconfiguration/ImageList.hxx
index 668b958a07c4..edd0789ed146 100644
--- a/framework/source/uiconfiguration/ImageList.hxx
+++ b/framework/source/uiconfiguration/ImageList.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef FRAMEWORK_SOURCE_UICONFIGURATION_IMAGELIST_HXX
-#define FRAMEWORK_SOURCE_UICONFIGURATION_IMAGELIST_HXX
+#pragma once
#include <vcl/image.hxx>
@@ -59,7 +58,7 @@ public:
sal_uInt16 GetImageId( sal_uInt16 nPos ) const;
- OUString GetImageName( sal_uInt16 nPos ) const;
+ const OUString & GetImageName( sal_uInt16 nPos ) const;
void GetImageNames( ::std::vector< OUString >& rNames ) const;
private:
@@ -73,6 +72,4 @@ private:
void ImplRemoveImage( sal_uInt16 nPos );
};
-#endif // INCLUDED_VCL_IMAGE_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/globalsettings.cxx b/framework/source/uiconfiguration/globalsettings.cxx
index f8a492299b95..0883cc8af197 100644
--- a/framework/source/uiconfiguration/globalsettings.cxx
+++ b/framework/source/uiconfiguration/globalsettings.cxx
@@ -25,9 +25,11 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
-#include <rtl/instance.hxx>
+#include <rtl/ref.hxx>
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/implbase.hxx>
+#include <mutex>
+#include <utility>
// Defines
@@ -47,7 +49,7 @@ class GlobalSettings_Access : public ::cppu::WeakImplHelper<
css::lang::XEventListener>
{
public:
- explicit GlobalSettings_Access( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ explicit GlobalSettings_Access( css::uno::Reference< css::uno::XComponentContext > xContext );
// XComponent
virtual void SAL_CALL dispose() override;
@@ -64,7 +66,7 @@ class GlobalSettings_Access : public ::cppu::WeakImplHelper<
private:
void impl_initConfigAccess();
- osl::Mutex m_mutex;
+ std::mutex m_mutex;
bool m_bDisposed : 1,
m_bConfigRead : 1;
OUString m_aNodeRefStates;
@@ -77,21 +79,21 @@ class GlobalSettings_Access : public ::cppu::WeakImplHelper<
}
-GlobalSettings_Access::GlobalSettings_Access( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) :
+GlobalSettings_Access::GlobalSettings_Access( css::uno::Reference< css::uno::XComponentContext > xContext ) :
m_bDisposed( false ),
m_bConfigRead( false ),
m_aNodeRefStates( "States" ),
m_aPropStatesEnabled( "StatesEnabled" ),
m_aPropLocked( "Locked" ),
m_aPropDocked( "Docked" ),
- m_xContext( rxContext )
+ m_xContext(std::move( xContext ))
{
}
// XComponent
void SAL_CALL GlobalSettings_Access::dispose()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
m_xConfigAccess.clear();
m_bDisposed = true;
}
@@ -107,14 +109,14 @@ void SAL_CALL GlobalSettings_Access::removeEventListener( const css::uno::Refere
// XEventListener
void SAL_CALL GlobalSettings_Access::disposing( const css::lang::EventObject& )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
m_xConfigAccess.clear();
}
// settings access
bool GlobalSettings_Access::HasToolbarStatesInfo()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if ( m_bDisposed )
return false;
@@ -148,7 +150,7 @@ bool GlobalSettings_Access::HasToolbarStatesInfo()
bool GlobalSettings_Access::GetToolbarStateInfo( GlobalSettings::StateInfo eStateInfo, css::uno::Any& aValue )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if ( m_bDisposed )
return false;
@@ -159,30 +161,30 @@ bool GlobalSettings_Access::GetToolbarStateInfo( GlobalSettings::StateInfo eStat
impl_initConfigAccess();
}
- if ( m_xConfigAccess.is() )
+ if ( !m_xConfigAccess.is() )
+ return false;
+
+ try
{
- try
- {
- css::uno::Any a = m_xConfigAccess->getByName( m_aNodeRefStates );
- css::uno::Reference< css::container::XNameAccess > xNameAccess;
- if ( a >>= xNameAccess )
- {
- if ( eStateInfo == GlobalSettings::STATEINFO_LOCKED )
- a = xNameAccess->getByName( m_aPropLocked );
- else if ( eStateInfo == GlobalSettings::STATEINFO_DOCKED )
- a = xNameAccess->getByName( m_aPropDocked );
-
- aValue = a;
- return true;
- }
- }
- catch ( const css::container::NoSuchElementException& )
- {
- }
- catch ( const css::uno::Exception& )
+ css::uno::Any a = m_xConfigAccess->getByName( m_aNodeRefStates );
+ css::uno::Reference< css::container::XNameAccess > xNameAccess;
+ if ( a >>= xNameAccess )
{
+ if ( eStateInfo == GlobalSettings::STATEINFO_LOCKED )
+ a = xNameAccess->getByName( m_aPropLocked );
+ else if ( eStateInfo == GlobalSettings::STATEINFO_DOCKED )
+ a = xNameAccess->getByName( m_aPropDocked );
+
+ aValue = a;
+ return true;
}
}
+ catch ( const css::container::NoSuchElementException& )
+ {
+ }
+ catch ( const css::uno::Exception& )
+ {
+ }
return false;
}
@@ -206,9 +208,7 @@ void GlobalSettings_Access::impl_initConfigAccess()
css::uno::Reference< css::lang::XComponent >(
xConfigProvider, css::uno::UNO_QUERY_THROW )->addEventListener(
- css::uno::Reference< css::lang::XEventListener >(
- static_cast< cppu::OWeakObject* >( this ),
- css::uno::UNO_QUERY ));
+ css::uno::Reference< css::lang::XEventListener >(this));
}
}
catch ( const css::lang::WrappedTargetException& )
@@ -221,24 +221,14 @@ void GlobalSettings_Access::impl_initConfigAccess()
// global class
-namespace {
-
-struct mutexGlobalSettings : public rtl::Static< osl::Mutex, mutexGlobalSettings > {};
-
-}
-
-static GlobalSettings_Access* pStaticSettings = nullptr;
-
static GlobalSettings_Access* GetGlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
{
- osl::MutexGuard aGuard(mutexGlobalSettings::get());
- if ( !pStaticSettings )
- pStaticSettings = new GlobalSettings_Access( rxContext );
- return pStaticSettings;
+ static rtl::Reference<GlobalSettings_Access> pStaticSettings = new GlobalSettings_Access( rxContext );
+ return pStaticSettings.get();
}
-GlobalSettings::GlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) :
- m_xContext( rxContext )
+GlobalSettings::GlobalSettings( css::uno::Reference< css::uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext ))
{
}
diff --git a/framework/source/uiconfiguration/graphicnameaccess.cxx b/framework/source/uiconfiguration/graphicnameaccess.cxx
index 809cc88b877c..6812f5604c26 100644
--- a/framework/source/uiconfiguration/graphicnameaccess.cxx
+++ b/framework/source/uiconfiguration/graphicnameaccess.cxx
@@ -45,7 +45,7 @@ uno::Any SAL_CALL GraphicNameAccess::getByName( const OUString& aName )
NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
if ( pIter == m_aNameToElementMap.end() )
throw container::NoSuchElementException();
- return uno::makeAny( pIter->second );
+ return uno::Any( pIter->second );
}
uno::Sequence< OUString > SAL_CALL GraphicNameAccess::getElementNames()
diff --git a/framework/source/uiconfiguration/imagemanager.cxx b/framework/source/uiconfiguration/imagemanager.cxx
index b39c77b69a37..d679deccf802 100644
--- a/framework/source/uiconfiguration/imagemanager.cxx
+++ b/framework/source/uiconfiguration/imagemanager.cxx
@@ -32,14 +32,12 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::embed;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::beans;
namespace framework
{
-ImageManager::ImageManager( const uno::Reference< uno::XComponentContext >& rxContext ) :
- m_pImpl( new ImageManagerImpl(rxContext, this, false) )
+ImageManager::ImageManager( const uno::Reference< uno::XComponentContext >& rxContext, bool bForModule ) :
+ m_pImpl( new ImageManagerImpl(rxContext, this, bForModule) )
{
}
@@ -167,7 +165,7 @@ com_sun_star_comp_framework_ImageManager_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(new framework::ImageManager(context));
+ return cppu::acquire(new framework::ImageManager(context, /*bForModule*/false));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index cfccf014f11c..a387fa011586 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -18,6 +18,7 @@
*/
#include "imagemanagerimpl.hxx"
+#include <utility>
#include <xml/imagesconfiguration.hxx>
#include <uiconfiguration/imagetype.hxx>
#include <uiconfiguration/graphicnameaccess.hxx>
@@ -39,13 +40,12 @@
#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
#include <o3tl/enumrange.hxx>
-#include <osl/mutex.hxx>
#include <comphelper/sequence.hxx>
#include <unotools/ucbstreamhelper.hxx>
-#include <vcl/pngread.hxx>
-#include <vcl/pngwrite.hxx>
-#include <rtl/instance.hxx>
+#include <vcl/filter/PngImageReader.hxx>
+#include <vcl/filter/PngImageWriter.hxx>
#include <memory>
+#include <unordered_set>
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::XInterface;
@@ -64,8 +64,8 @@ using namespace ::cppu;
const sal_Int16 MAX_IMAGETYPE_VALUE = css::ui::ImageType::SIZE_32;
-constexpr OUStringLiteral IMAGE_FOLDER = u"images";
-constexpr OUStringLiteral BITMAPS_FOLDER = u"Bitmaps";
+constexpr OUString IMAGE_FOLDER = u"images"_ustr;
+constexpr OUString BITMAPS_FOLDER = u"Bitmaps"_ustr;
const o3tl::enumarray<vcl::ImageType, const char*> IMAGELIST_XML_FILE =
{
@@ -86,20 +86,15 @@ namespace framework
static GlobalImageList* pGlobalImageList = nullptr;
-namespace
+static std::mutex& getGlobalImageListMutex()
{
- class theGlobalImageListMutex
- : public rtl::Static<osl::Mutex, theGlobalImageListMutex> {};
-}
-
-static osl::Mutex& getGlobalImageListMutex()
-{
- return theGlobalImageListMutex::get();
+ static std::mutex mutex;
+ return mutex;
}
static GlobalImageList* getGlobalImageList( const uno::Reference< uno::XComponentContext >& rxContext )
{
- osl::MutexGuard guard( getGlobalImageListMutex() );
+ std::unique_lock guard( getGlobalImageListMutex() );
if ( pGlobalImageList == nullptr )
pGlobalImageList = new GlobalImageList( rxContext );
@@ -107,10 +102,10 @@ static GlobalImageList* getGlobalImageList( const uno::Reference< uno::XComponen
return pGlobalImageList;
}
-CmdImageList::CmdImageList( const uno::Reference< uno::XComponentContext >& rxContext, const OUString& aModuleIdentifier ) :
+CmdImageList::CmdImageList( uno::Reference< uno::XComponentContext > rxContext, OUString aModuleIdentifier ) :
m_bInitialized(false),
- m_aModuleIdentifier( aModuleIdentifier ),
- m_xContext( rxContext )
+ m_aModuleIdentifier(std::move( aModuleIdentifier )),
+ m_xContext(std::move( rxContext ))
{
}
@@ -189,26 +184,26 @@ GlobalImageList::GlobalImageList( const uno::Reference< uno::XComponentContext >
GlobalImageList::~GlobalImageList()
{
- osl::MutexGuard guard( getGlobalImageListMutex() );
+ std::unique_lock guard( getGlobalImageListMutex() );
// remove global pointer as we destroy the object now
pGlobalImageList = nullptr;
}
Image GlobalImageList::getImageFromCommandURL( vcl::ImageType nImageType, const OUString& rCommandURL )
{
- osl::MutexGuard guard( getGlobalImageListMutex() );
+ std::unique_lock guard( getGlobalImageListMutex() );
return CmdImageList::getImageFromCommandURL( nImageType, rCommandURL );
}
bool GlobalImageList::hasImage( vcl::ImageType nImageType, const OUString& rCommandURL )
{
- osl::MutexGuard guard( getGlobalImageListMutex() );
+ std::unique_lock guard( getGlobalImageListMutex() );
return CmdImageList::hasImage( nImageType, rCommandURL );
}
::std::vector< OUString >& GlobalImageList::getImageCommandNames()
{
- osl::MutexGuard guard( getGlobalImageListMutex() );
+ std::unique_lock guard( getGlobalImageListMutex() );
return CmdImageList::getImageCommandNames();
}
@@ -333,8 +328,8 @@ void ImageManagerImpl::implts_loadUserImages(
BitmapEx aUserBitmap;
{
std::unique_ptr<SvStream> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream ));
- vcl::PNGReader aPngReader( *pSvStream );
- aUserBitmap = aPngReader.Read();
+ vcl::PngImageReader aPngReader( *pSvStream );
+ aUserBitmap = aPngReader.read();
}
// Delete old image list and create a new one from the read bitmap
@@ -373,89 +368,90 @@ bool ImageManagerImpl::implts_storeUserImages(
{
SolarMutexGuard g;
- if ( m_bModified )
+ if ( !m_bModified )
+ return false;
+
+ ImageList* pImageList = implts_getUserImageList( nImageType );
+ if ( pImageList->GetImageCount() > 0 )
{
- ImageList* pImageList = implts_getUserImageList( nImageType );
- if ( pImageList->GetImageCount() > 0 )
- {
- ImageItemDescriptorList aUserImageListInfo;
+ ImageItemDescriptorList aUserImageListInfo;
- for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ )
- {
- ImageItemDescriptor aItem;
- aItem.aCommandURL = pImageList->GetImageName( i );
- aUserImageListInfo.push_back( aItem );
- }
+ for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ )
+ {
+ ImageItemDescriptor aItem;
+ aItem.aCommandURL = pImageList->GetImageName( i );
+ aUserImageListInfo.push_back( aItem );
+ }
- uno::Reference< XTransactedObject > xTransaction;
- uno::Reference< XOutputStream > xOutputStream;
- uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
- ElementModes::WRITE|ElementModes::TRUNCATE );
- if ( xStream.is() )
+ uno::Reference< XTransactedObject > xTransaction;
+ uno::Reference< XOutputStream > xOutputStream;
+ uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
+ ElementModes::WRITE|ElementModes::TRUNCATE );
+ if ( xStream.is() )
+ {
+ uno::Reference< XStream > xBitmapStream =
+ xUserBitmapsStorage->openStreamElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
+ ElementModes::WRITE|ElementModes::TRUNCATE );
+ if ( xBitmapStream.is() )
{
- uno::Reference< XStream > xBitmapStream =
- xUserBitmapsStorage->openStreamElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
- ElementModes::WRITE|ElementModes::TRUNCATE );
- if ( xBitmapStream.is() )
{
- {
- std::unique_ptr<SvStream> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream ));
- vcl::PNGWriter aPngWriter( pImageList->GetAsHorizontalStrip() );
- aPngWriter.Write( *pSvStream );
- }
-
- // Commit user bitmaps storage
- xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
+ std::unique_ptr<SvStream> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream ));
+ vcl::PngImageWriter aPngWriter( *pSvStream );
+ auto rBitmap = pImageList->GetAsHorizontalStrip();
+ aPngWriter.write( rBitmap );
}
- xOutputStream = xStream->getOutputStream();
- if ( xOutputStream.is() )
- ImagesConfiguration::StoreImages( m_xContext, xOutputStream, aUserImageListInfo );
-
- // Commit user image storage
- xTransaction.set( xUserImageStorage, UNO_QUERY );
+ // Commit user bitmaps storage
+ xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
if ( xTransaction.is() )
xTransaction->commit();
}
- return true;
- }
- else
- {
- // Remove the streams from the storage, if we have no data. We have to catch
- // the NoSuchElementException as it can be possible that there is no stream at all!
- try
- {
- xUserImageStorage->removeElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ));
- }
- catch ( const css::container::NoSuchElementException& )
- {
- }
-
- try
- {
- xUserBitmapsStorage->removeElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ));
- }
- catch ( const css::container::NoSuchElementException& )
- {
- }
-
- uno::Reference< XTransactedObject > xTransaction;
+ xOutputStream = xStream->getOutputStream();
+ if ( xOutputStream.is() )
+ ImagesConfiguration::StoreImages( m_xContext, xOutputStream, aUserImageListInfo );
// Commit user image storage
xTransaction.set( xUserImageStorage, UNO_QUERY );
if ( xTransaction.is() )
xTransaction->commit();
+ }
- // Commit user bitmaps storage
- xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
+ return true;
+ }
+ else
+ {
+ // Remove the streams from the storage, if we have no data. We have to catch
+ // the NoSuchElementException as it can be possible that there is no stream at all!
+ try
+ {
+ xUserImageStorage->removeElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ));
+ }
+ catch ( const css::container::NoSuchElementException& )
+ {
+ }
- return true;
+ try
+ {
+ xUserBitmapsStorage->removeElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ));
+ }
+ catch ( const css::container::NoSuchElementException& )
+ {
}
+
+ uno::Reference< XTransactedObject > xTransaction;
+
+ // Commit user image storage
+ xTransaction.set( xUserImageStorage, UNO_QUERY );
+ if ( xTransaction.is() )
+ xTransaction->commit();
+
+ // Commit user bitmaps storage
+ xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
+ if ( xTransaction.is() )
+ xTransaction->commit();
+
+ return true;
}
return false;
@@ -480,11 +476,10 @@ CmdImageList* ImageManagerImpl::implts_getDefaultImageList()
return m_pDefaultImageList.get();
}
-ImageManagerImpl::ImageManagerImpl( const uno::Reference< uno::XComponentContext >& rxContext,::cppu::OWeakObject* pOwner,bool _bUseGlobal ) :
- m_xContext( rxContext )
+ImageManagerImpl::ImageManagerImpl( uno::Reference< uno::XComponentContext > xContext, ::cppu::OWeakObject* pOwner, bool _bUseGlobal ) :
+ m_xContext(std::move( xContext ))
, m_pOwner(pOwner)
, m_aResourceString( "private:resource/images/moduleimages" )
- , m_aListenerContainer( m_mutex )
, m_bUseGlobal(_bUseGlobal)
, m_bReadOnly( true )
, m_bInitialized( false )
@@ -507,7 +502,14 @@ void ImageManagerImpl::dispose()
{
uno::Reference< uno::XInterface > xOwner(m_pOwner);
css::lang::EventObject aEvent( xOwner );
- m_aListenerContainer.disposeAndClear( aEvent );
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.disposeAndClear( aGuard, aEvent );
+ }
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.disposeAndClear( aGuard, aEvent );
+ }
{
SolarMutexGuard g;
@@ -536,13 +538,15 @@ void ImageManagerImpl::addEventListener( const uno::Reference< XEventListener >&
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.addInterface( aGuard, xListener );
}
void ImageManagerImpl::removeEventListener( const uno::Reference< XEventListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.removeInterface( aGuard, xListener );
}
// XInitialization
@@ -624,7 +628,7 @@ Sequence< OUString > ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType
if ( m_bDisposed )
throw DisposedException();
- ImageNameMap aImageCmdNameMap;
+ std::unordered_set< OUString > aImageCmdNames;
vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
@@ -636,12 +640,12 @@ Sequence< OUString > ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType
const std::vector< OUString >& rGlobalImageNameVector = rGlobalImageList->getImageCommandNames();
const sal_uInt32 nGlobalCount = rGlobalImageNameVector.size();
for ( i = 0; i < nGlobalCount; i++ )
- aImageCmdNameMap.emplace( rGlobalImageNameVector[i], true );
+ aImageCmdNames.insert( rGlobalImageNameVector[i] );
const std::vector< OUString >& rModuleImageNameVector = implts_getDefaultImageList()->getImageCommandNames();
const sal_uInt32 nModuleCount = rModuleImageNameVector.size();
for ( i = 0; i < nModuleCount; i++ )
- aImageCmdNameMap.emplace( rModuleImageNameVector[i], true );
+ aImageCmdNames.insert( rModuleImageNameVector[i] );
}
ImageList* pImageList = implts_getUserImageList(nIndex);
@@ -649,9 +653,9 @@ Sequence< OUString > ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType
pImageList->GetImageNames( rUserImageNames );
const sal_uInt32 nUserCount = rUserImageNames.size();
for ( i = 0; i < nUserCount; i++ )
- aImageCmdNameMap.emplace( rUserImageNames[i], true );
+ aImageCmdNames.insert( rUserImageNames[i] );
- return comphelper::mapKeysToSequence( aImageCmdNameMap );
+ return comphelper::containerToSequence( aImageCmdNames );
}
bool ImageManagerImpl::hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL )
@@ -721,6 +725,7 @@ Sequence< uno::Reference< XGraphic > > ImageManagerImpl::getImages(
// 1. user image list (read/write)
// 2. module image list (read)
// 3. global image list (read)
+ auto aGraphSeqRange = asNonConstRange(aGraphSeq);
sal_Int32 n = 0;
for ( const OUString& rURL : aCommandURLSequence )
{
@@ -732,7 +737,7 @@ Sequence< uno::Reference< XGraphic > > ImageManagerImpl::getImages(
aImage = rGlobalImageList->getImageFromCommandURL( nIndex, rURL );
}
- aGraphSeq[n++] = GetXGraphic(aImage);
+ aGraphSeqRange[n++] = GetXGraphic(aImage);
}
return aGraphSeq;
@@ -743,8 +748,8 @@ void ImageManagerImpl::replaceImages(
const Sequence< OUString >& aCommandURLSequence,
const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
{
- GraphicNameAccess* pInsertedImages( nullptr );
- GraphicNameAccess* pReplacedImages( nullptr );
+ rtl::Reference<GraphicNameAccess> pInsertedImages;
+ rtl::Reference<GraphicNameAccess> pReplacedImages;
{
SolarMutexGuard g;
@@ -803,8 +808,7 @@ void ImageManagerImpl::replaceImages(
aInsertEvent.Accessor <<= xOwner;
aInsertEvent.Source = xOwner;
aInsertEvent.ResourceURL = m_aResourceString;
- aInsertEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY );
+ aInsertEvent.Element <<= uno::Reference< XNameAccess >(pInsertedImages);
implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
}
if ( pReplacedImages != nullptr )
@@ -815,16 +819,15 @@ void ImageManagerImpl::replaceImages(
aReplaceEvent.Source = xOwner;
aReplaceEvent.ResourceURL = m_aResourceString;
aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
+ aReplaceEvent.Element <<= uno::Reference< XNameAccess >(pReplacedImages);
implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
}
}
void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence )
{
- GraphicNameAccess* pRemovedImages( nullptr );
- GraphicNameAccess* pReplacedImages( nullptr );
+ rtl::Reference<GraphicNameAccess> pRemovedImages;
+ rtl::Reference<GraphicNameAccess> pReplacedImages;
{
SolarMutexGuard g;
@@ -903,8 +906,7 @@ void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUS
aRemoveEvent.Accessor <<= xOwner;
aRemoveEvent.Source = xOwner;
aRemoveEvent.ResourceURL = m_aResourceString;
- aRemoveEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY );
+ aRemoveEvent.Element <<= uno::Reference< XNameAccess >(pRemovedImages);
implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
}
if ( pReplacedImages != nullptr )
@@ -915,8 +917,7 @@ void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUS
aReplaceEvent.Source = xOwner;
aReplaceEvent.ResourceURL = m_aResourceString;
aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
+ aReplaceEvent.Element <<= uno::Reference< XNameAccess >(pReplacedImages);
implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
}
}
@@ -929,7 +930,7 @@ void ImageManagerImpl::insertImages( ::sal_Int16 nImageType, const Sequence< OUS
// XUIConfigurationPersistence
void ImageManagerImpl::reload()
{
- SolarMutexClearableGuard aGuard;
+ SolarMutexResettableGuard aGuard;
if ( m_bDisposed )
throw DisposedException();
@@ -959,9 +960,9 @@ void ImageManagerImpl::reload()
pImageList = implts_getUserImageList(i);
pImageList->GetImageNames( aNewUserCmdImageSet );
- GraphicNameAccess* pInsertedImages( nullptr );
- GraphicNameAccess* pReplacedImages( nullptr );
- GraphicNameAccess* pRemovedImages( nullptr );
+ rtl::Reference<GraphicNameAccess> pInsertedImages;
+ rtl::Reference<GraphicNameAccess> pReplacedImages;
+ rtl::Reference<GraphicNameAccess> pRemovedImages;
for (auto const& newUserCmdImage : aNewUserCmdImageSet)
{
@@ -1040,8 +1041,7 @@ void ImageManagerImpl::reload()
aInsertEvent.Accessor <<= xOwner;
aInsertEvent.Source = xOwner;
aInsertEvent.ResourceURL = m_aResourceString;
- aInsertEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY );
+ aInsertEvent.Element <<= uno::Reference< XNameAccess >( pInsertedImages );
implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
}
if ( pReplacedImages != nullptr )
@@ -1052,8 +1052,7 @@ void ImageManagerImpl::reload()
aReplaceEvent.Source = xOwner;
aReplaceEvent.ResourceURL = m_aResourceString;
aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
+ aReplaceEvent.Element <<= uno::Reference< XNameAccess >( pReplacedImages );
implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
}
if ( pRemovedImages != nullptr )
@@ -1063,12 +1062,11 @@ void ImageManagerImpl::reload()
aRemoveEvent.Accessor <<= xOwner;
aRemoveEvent.Source = xOwner;
aRemoveEvent.ResourceURL = m_aResourceString;
- aRemoveEvent.Element <<= uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY );
+ aRemoveEvent.Element <<= uno::Reference< XNameAccess >( pRemovedImages );
implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
}
- aGuard.clear();
+ aGuard.reset();
}
}
}
@@ -1157,23 +1155,22 @@ void ImageManagerImpl::addConfigurationListener( const uno::Reference< css::ui::
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.addInterface( aGuard, xListener );
}
void ImageManagerImpl::removeConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.removeInterface( aGuard, xListener );
}
void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
{
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer(
- cppu::UnoType<css::ui::XUIConfigurationListener>::get());
- if ( pContainer == nullptr )
- return;
-
- ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
+ std::unique_lock aGuard(m_mutex);
+ comphelper::OInterfaceIteratorHelper4 pIterator( aGuard, m_aConfigListeners );
+ aGuard.unlock();
while ( pIterator.hasMoreElements() )
{
try
@@ -1181,19 +1178,21 @@ void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent&
switch ( eOp )
{
case NotifyOp_Replace:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementReplaced( aEvent );
+ pIterator.next()->elementReplaced( aEvent );
break;
case NotifyOp_Insert:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementInserted( aEvent );
+ pIterator.next()->elementInserted( aEvent );
break;
case NotifyOp_Remove:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementRemoved( aEvent );
+ pIterator.next()->elementRemoved( aEvent );
break;
}
}
catch( const css::uno::RuntimeException& )
{
- pIterator.remove();
+ aGuard.lock();
+ pIterator.remove(aGuard);
+ aGuard.unlock();
}
}
}
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.hxx b/framework/source/uiconfiguration/imagemanagerimpl.hxx
index fa224e09f3c0..4d48da1c2312 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.hxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
-#define INCLUDED_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
+#pragma once
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
@@ -28,12 +27,13 @@
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <cppuhelper/weak.hxx>
-#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ref.hxx>
#include <salhelper/simplereferenceobject.hxx>
+#include <mutex>
#include <unordered_map>
#include <vector>
@@ -44,7 +44,7 @@ namespace framework
class CmdImageList
{
public:
- CmdImageList(const css::uno::Reference< css::uno::XComponentContext >& rxContext, const OUString& aModuleIdentifier);
+ CmdImageList(css::uno::Reference< css::uno::XComponentContext > xContext, OUString aModuleIdentifier);
virtual ~CmdImageList();
virtual Image getImageFromCommandURL(vcl::ImageType nImageType, const OUString& rCommandURL);
@@ -76,7 +76,7 @@ namespace framework
class ImageManagerImpl
{
public:
- ImageManagerImpl(const css::uno::Reference< css::uno::XComponentContext >& rxContext
+ ImageManagerImpl(css::uno::Reference< css::uno::XComponentContext > xContext
,::cppu::OWeakObject *pOwner
,bool _bUseGlobal);
~ImageManagerImpl();
@@ -137,9 +137,6 @@ namespace framework
void clear();
- typedef std::unordered_map< OUString,
- sal_Bool > ImageNameMap;
-
enum NotifyOp
{
NotifyOp_Remove,
@@ -147,8 +144,6 @@ namespace framework
NotifyOp_Replace
};
- typedef ::std::vector< css::ui::ConfigurationEvent > ConfigEventNotifyContainer;
-
void implts_initialize();
void implts_notifyContainerListener( const css::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
ImageList* implts_getUserImageList( vcl::ImageType nImageType );
@@ -171,8 +166,9 @@ namespace framework
std::unique_ptr<CmdImageList> m_pDefaultImageList;
OUString m_aModuleIdentifier;
OUString m_aResourceString;
- osl::Mutex m_mutex;
- ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
+ std::mutex m_mutex;
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
+ comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>> m_pUserImageList;
o3tl::enumarray<vcl::ImageType,bool> m_bUserImageListModified;
bool m_bUseGlobal;
@@ -183,6 +179,4 @@ namespace framework
};
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/moduleimagemanager.cxx b/framework/source/uiconfiguration/moduleimagemanager.cxx
deleted file mode 100644
index 05041fe0f198..000000000000
--- a/framework/source/uiconfiguration/moduleimagemanager.cxx
+++ /dev/null
@@ -1,155 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <uiconfiguration/moduleimagemanager.hxx>
-#include "imagemanagerimpl.hxx"
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-#include <sal/log.hxx>
-
-// namespaces
-
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::graphic::XGraphic;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::io;
-using namespace ::com::sun::star::embed;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::ui;
-
-namespace framework
-{
-ModuleImageManager::ModuleImageManager( const uno::Reference< uno::XComponentContext >& xContext ) :
- m_pImpl( new ImageManagerImpl(xContext,static_cast< OWeakObject* >(this),true) )
-{
-}
-
-ModuleImageManager::~ModuleImageManager()
-{
-}
-
-// XComponent
-void SAL_CALL ModuleImageManager::dispose()
-{
- m_pImpl->dispose();
-}
-
-void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener )
-{
- m_pImpl->addEventListener(xListener);
-}
-
-void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener )
-{
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_pImpl->removeEventListener(xListener);
-}
-
-// XInitialization
-void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments )
-{
- m_pImpl->initialize(aArguments);
-}
-
-// XImageManager
-void SAL_CALL ModuleImageManager::reset()
-{
- m_pImpl->reset();
-}
-
-Sequence< OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType )
-{
- return m_pImpl->getAllImageNames( nImageType );
-}
-
-sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL )
-{
- return m_pImpl->hasImage(nImageType,aCommandURL);
-}
-
-Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages(
- ::sal_Int16 nImageType,
- const Sequence< OUString >& aCommandURLSequence )
-{
- SAL_INFO( "fwk", "framework: ModuleImageManager::getImages" );
- return m_pImpl->getImages(nImageType,aCommandURLSequence);
-}
-
-void SAL_CALL ModuleImageManager::replaceImages(
- ::sal_Int16 nImageType,
- const Sequence< OUString >& aCommandURLSequence,
- const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
-{
- m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
-}
-
-void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence )
-{
- m_pImpl->removeImages(nImageType,aCommandURLSequence);
-}
-
-void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
-{
- m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
-}
-
-// XUIConfiguration
-void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
-{
- m_pImpl->addConfigurationListener(xListener);
-}
-
-void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
-{
- m_pImpl->removeConfigurationListener(xListener);
-}
-
-// XUIConfigurationPersistence
-void SAL_CALL ModuleImageManager::reload()
-{
- m_pImpl->reload();
-}
-
-void SAL_CALL ModuleImageManager::store()
-{
- m_pImpl->store();
-}
-
-void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
-{
- m_pImpl->storeToStorage(Storage);
-}
-
-sal_Bool SAL_CALL ModuleImageManager::isModified()
-{
- return m_pImpl->isModified();
-}
-
-sal_Bool SAL_CALL ModuleImageManager::isReadOnly()
-{
- return m_pImpl->isReadOnly();
-}
-
-} // namespace framework
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
index 31d61d8d0ad5..ef48cd4c17b8 100644
--- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
+++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
@@ -31,31 +31,26 @@
#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unordered_map>
using namespace com::sun::star::uno;
-using namespace com::sun::star::io;
using namespace com::sun::star::lang;
using namespace com::sun::star::container;
using namespace com::sun::star::beans;
-using namespace com::sun::star::embed;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::frame;
-using namespace framework;
namespace {
-typedef cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo,
css::ui::XModuleUIConfigurationManagerSupplier >
ModuleUIConfigurationManagerSupplier_BASE;
-class ModuleUIConfigurationManagerSupplier : private cppu::BaseMutex,
- public ModuleUIConfigurationManagerSupplier_BASE
+class ModuleUIConfigurationManagerSupplier : public ModuleUIConfigurationManagerSupplier_BASE
{
public:
explicit ModuleUIConfigurationManagerSupplier( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
@@ -80,7 +75,7 @@ public:
virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( const OUString& ModuleIdentifier ) override;
private:
- virtual void SAL_CALL disposing() final override;
+ virtual void disposing(std::unique_lock<std::mutex>&) final override;
typedef std::unordered_map< OUString, css::uno::Reference< css::ui::XModuleUIConfigurationManager2 > > ModuleToModuleCfgMgr;
@@ -92,8 +87,7 @@ private:
};
ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( const Reference< XComponentContext >& xContext ) :
- ModuleUIConfigurationManagerSupplier_BASE(m_aMutex)
- , m_xModuleMgr( ModuleManager::create( xContext ) )
+ m_xModuleMgr( ModuleManager::create( xContext ) )
, m_xContext( xContext )
{
try
@@ -111,13 +105,12 @@ ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( cons
ModuleUIConfigurationManagerSupplier::~ModuleUIConfigurationManagerSupplier()
{
- disposing();
+ std::unique_lock g(m_aMutex);
+ disposing(g);
}
-void SAL_CALL ModuleUIConfigurationManagerSupplier::disposing()
+void ModuleUIConfigurationManagerSupplier::disposing(std::unique_lock<std::mutex>&)
{
- osl::MutexGuard g(rBHelper.rMutex);
-
// dispose all our module user interface configuration managers
for (auto const& elem : m_aModuleToModuleUICfgMgrMap)
{
@@ -132,7 +125,7 @@ void SAL_CALL ModuleUIConfigurationManagerSupplier::disposing()
// XModuleUIConfigurationManagerSupplier
Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSupplier::getUIConfigurationManager( const OUString& sModuleIdentifier )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.find( sModuleIdentifier );
@@ -148,7 +141,7 @@ Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSuppli
{
Sequence< PropertyValue > lProps;
m_xModuleMgr->getByName(sModuleIdentifier) >>= lProps;
- for (PropertyValue const & rProp : std::as_const(lProps))
+ for (PropertyValue const& rProp : lProps)
{
if ( rProp.Name == "ooSetupFactoryShortName" )
{
@@ -171,22 +164,6 @@ Reference< XUIConfigurationManager > SAL_CALL ModuleUIConfigurationManagerSuppli
return pIter->second;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new ModuleUIConfigurationManagerSupplier(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -194,8 +171,7 @@ com_sun_star_comp_framework_ModuleUIConfigurationManagerSupplier_get_implementat
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new ModuleUIConfigurationManagerSupplier(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 27cb2974cf8d..4e3585c51341 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -18,7 +18,7 @@
*/
#include <accelerators/presethandler.hxx>
-#include <uiconfiguration/moduleimagemanager.hxx>
+#include <uiconfiguration/imagemanager.hxx>
#include <uielement/constitemcontainer.hxx>
#include <uielement/rootitemcontainer.hxx>
#include <uielement/uielementtypenames.hxx>
@@ -52,11 +52,16 @@
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
+#include <comphelper/interfacecontainer4.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/servicehelper.hxx>
+#include <o3tl/string_view.hxx>
#include <memory>
+#include <mutex>
#include <string_view>
using namespace css;
@@ -68,10 +73,10 @@ using namespace com::sun::star::container;
using namespace com::sun::star::beans;
using namespace framework;
-#define RESOURCETYPE_MENUBAR "menubar"
-#define RESOURCETYPE_TOOLBAR "toolbar"
-#define RESOURCETYPE_STATUSBAR "statusbar"
-#define RESOURCETYPE_POPUPMENU "popupmenu"
+constexpr OUStringLiteral RESOURCETYPE_MENUBAR = u"menubar";
+constexpr OUStringLiteral RESOURCETYPE_TOOLBAR = u"toolbar";
+constexpr OUStringLiteral RESOURCETYPE_STATUSBAR = u"statusbar";
+constexpr OUStringLiteral RESOURCETYPE_POPUPMENU = u"popupmenu";
namespace {
@@ -120,6 +125,7 @@ public:
virtual void SAL_CALL insertSettings( const OUString& NewResourceURL, const css::uno::Reference< css::container::XIndexAccess >& aNewData ) override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getImageManager() override;
virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL getShortCutManager() override;
+ virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL createShortCutManager() override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getEventsManager() override;
// XModuleUIConfigurationManager
@@ -151,8 +157,8 @@ private:
struct UIElementInfo
{
- UIElementInfo( const OUString& rResourceURL, const OUString& rUIName ) :
- aResourceURL( rResourceURL), aUIName( rUIName ) {}
+ UIElementInfo( OUString _aResourceURL, OUString _aUIName ) :
+ aResourceURL(std::move( _aResourceURL)), aUIName(std::move( _aUIName )) {}
OUString aResourceURL;
OUString aUIName;
};
@@ -210,9 +216,10 @@ private:
OUString m_aModuleIdentifier;
css::uno::Reference< css::embed::XTransactedObject > m_xUserRootCommit;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
- osl::Mutex m_mutex;
- ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
- css::uno::Reference< css::lang::XComponent > m_xModuleImageManager;
+ std::mutex m_mutex;
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
+ comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
+ rtl::Reference< ImageManager > m_xModuleImageManager;
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager;
};
@@ -230,20 +237,19 @@ std::u16string_view UIELEMENTTYPENAMES[] =
u"" UIELEMENTTYPE_TOOLPANEL_NAME
};
-const char RESOURCEURL_PREFIX[] = "private:resource/";
-const sal_Int32 RESOURCEURL_PREFIX_SIZE = strlen(RESOURCEURL_PREFIX);
+constexpr std::u16string_view RESOURCEURL_PREFIX = u"private:resource/";
-sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
+sal_Int16 RetrieveTypeFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
- sal_Int32 nIndex = aTmpStr.indexOf( '/' );
- if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex ))
+ std::u16string_view aTmpStr = aResourceURL.substr( RESOURCEURL_PREFIX.size() );
+ size_t nIndex = aTmpStr.find( '/' );
+ if (( nIndex > 0 ) && ( aTmpStr.size() > nIndex ))
{
- OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
+ std::u16string_view aTypeStr( aTmpStr.substr( 0, nIndex ));
for ( int i = 0; i < ui::UIElementType::COUNT; i++ )
{
if ( aTypeStr == UIELEMENTTYPENAMES[i] )
@@ -255,14 +261,15 @@ sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
return ui::UIElementType::UNKNOWN;
}
-OUString RetrieveNameFromResourceURL( const OUString& aResourceURL )
+OUString RetrieveNameFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
- if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
- return aResourceURL.copy( nIndex+1 );
+ size_t nIndex = aResourceURL.rfind( '/' );
+
+ if ( nIndex > 0 && nIndex != std::u16string_view::npos && (( nIndex+1 ) < aResourceURL.size()) )
+ return OUString(aResourceURL.substr( nIndex+1 ));
}
return OUString();
@@ -279,8 +286,8 @@ void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIEleme
OUString aCustomUrlPrefix( "custom_" );
for (auto const& userElement : rUserElements)
{
- sal_Int32 nIndex = userElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
- if ( nIndex > RESOURCEURL_PREFIX_SIZE )
+ sal_Int32 nIndex = userElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX.size() );
+ if ( nIndex > static_cast<sal_Int32>(RESOURCEURL_PREFIX.size()) )
{
// Performance: Retrieve user interface name only for custom user interface elements.
// It's only used by them!
@@ -315,8 +322,8 @@ void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIEleme
UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( defaultElement.second.aResourceURL );
if ( pIterInfo == aUIElementInfoCollection.end() )
{
- sal_Int32 nIndex = defaultElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
- if ( nIndex > RESOURCEURL_PREFIX_SIZE )
+ sal_Int32 nIndex = defaultElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX.size() );
+ if ( nIndex > static_cast<sal_Int32>(RESOURCEURL_PREFIX.size()) )
{
// Performance: Retrieve user interface name only for custom user interface elements.
// It's only used by them!
@@ -371,11 +378,11 @@ void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer,
sal_Int32 nIndex = rElementName.lastIndexOf( '.' );
if (( nIndex > 0 ) && ( nIndex < rElementName.getLength() ))
{
- OUString aExtension( rElementName.copy( nIndex+1 ));
- OUString aUIElementName( rElementName.copy( 0, nIndex ));
+ std::u16string_view aExtension( rElementName.subView( nIndex+1 ));
+ std::u16string_view aUIElementName( rElementName.subView( 0, nIndex ));
- if (!aUIElementName.isEmpty() &&
- ( aExtension.equalsIgnoreAsciiCase("xml")))
+ if (!aUIElementName.empty() &&
+ ( o3tl::equalsIgnoreAsciiCase(aExtension, u"xml")))
{
aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
aUIElementData.aName = rElementName;
@@ -423,11 +430,11 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
MenuConfiguration aMenuCfg( m_xContext );
Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xContainer );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xContainer.get() );
if ( pRootItemContainer )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
else
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, true ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( xContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -440,10 +447,10 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
try
{
- Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
+ Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xIndexContainer );
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -457,10 +464,10 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
try
{
- Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
+ Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xIndexContainer );
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -492,7 +499,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
}
// At least we provide an empty settings container!
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer() ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer();
}
ModuleUIConfigurationManager::UIElementData* ModuleUIConfigurationManager::impl_findUIElementData( const OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
@@ -622,7 +629,7 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData(
{
UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
Reference< XInterface > xIfac( xThis, UNO_QUERY );
sal_Int16 nType = rUserElementType.nElementType;
@@ -684,7 +691,7 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData(
{
UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
Reference< XInterface > xIfac( xThis, UNO_QUERY );
sal_Int16 nType = rUserElementType.nElementType;
@@ -827,7 +834,6 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager(
, m_aXMLPostfix( ".xml" )
, m_aPropUIName( "UIName" )
, m_xContext( xContext )
- , m_aListenerContainer( m_mutex )
{
// Make sure we have a default initialized entry for every layer and user interface element type!
// The following code depends on this!
@@ -892,10 +898,17 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager(
// XComponent
void SAL_CALL ModuleUIConfigurationManager::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
css::lang::EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.disposeAndClear( aGuard, aEvent );
+ }
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.disposeAndClear( aGuard, aEvent );
+ }
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
SolarMutexClearableGuard aGuard;
@@ -932,13 +945,15 @@ void SAL_CALL ModuleUIConfigurationManager::addEventListener( const Reference< X
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ModuleUIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.removeInterface( aGuard, xListener );
}
// XUIConfiguration
@@ -952,13 +967,15 @@ void SAL_CALL ModuleUIConfigurationManager::addConfigurationListener( const Refe
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<ui::XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ModuleUIConfigurationManager::removeConfigurationListener( const Reference< css::ui::XUIConfigurationListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<ui::XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.removeInterface( aGuard, xListener );
}
// XUIConfigurationManager
@@ -1067,18 +1084,15 @@ Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::get
else
impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
- Sequence< PropertyValue > aUIElementInfo( 2 );
- aUIElementInfo[0].Name = "ResourceURL";
- aUIElementInfo[1].Name = m_aPropUIName;
-
aElementInfoSeq.resize( aUIElementInfoCollection.size() );
sal_Int32 n = 0;
for (auto const& elem : aUIElementInfoCollection)
{
- aUIElementInfo[0].Value <<= elem.second.aResourceURL;
- aUIElementInfo[1].Value <<= elem.second.aUIName;
- aElementInfoSeq[n++] = aUIElementInfo;
+ aElementInfoSeq[n++] = Sequence<PropertyValue> {
+ comphelper::makePropertyValue("ResourceURL", elem.second.aResourceURL),
+ comphelper::makePropertyValue(m_aPropUIName, elem.second.aUIName)
+ };
}
return comphelper::containerToSequence(aElementInfoSeq);
@@ -1092,7 +1106,7 @@ Reference< XIndexContainer > SAL_CALL ModuleUIConfigurationManager::createSettin
throw DisposedException();
// Creates an empty item container which can be filled from outside
- return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
+ return Reference< XIndexContainer >( new RootItemContainer() );
}
sal_Bool SAL_CALL ModuleUIConfigurationManager::hasSettings( const OUString& ResourceURL )
@@ -1133,7 +1147,7 @@ Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getSettings( co
{
// Create a copy of our data if someone wants to change the data.
if ( bWriteable )
- return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
+ return Reference< XIndexAccess >( new RootItemContainer( pDataSettings->xSettings ) );
else
return pDataSettings->xSettings;
}
@@ -1168,7 +1182,7 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
if ( xReplace.is() )
- pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ pDataSettings->xSettings = new ConstItemContainer( aNewData );
else
pDataSettings->xSettings = aNewData;
pDataSettings->bDefault = false;
@@ -1179,14 +1193,13 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res
UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about replaced element settings
ui::ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.ReplacedElement <<= xOldSettings;
aEvent.Element <<= pDataSettings->xSettings;
@@ -1206,7 +1219,7 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
if ( xReplace.is() )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( aNewData );
else
aUIElementData.xSettings = aNewData;
aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
@@ -1227,15 +1240,14 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res
else
rElements.emplace( ResourceURL, aUIElementData );
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about replaced element settings
ui::ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.ReplacedElement <<= pDataSettings->xSettings;
aEvent.Element <<= aUIElementData.xSettings;
@@ -1289,7 +1301,7 @@ void SAL_CALL ModuleUIConfigurationManager::removeSettings( const OUString& Reso
UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Check if we have settings in the default layer which replaces the user-defined one!
@@ -1355,7 +1367,7 @@ void SAL_CALL ModuleUIConfigurationManager::insertSettings( const OUString& NewR
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
if ( xReplace.is() )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( aNewData );
else
aUIElementData.xSettings = aNewData;
aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
@@ -1369,7 +1381,7 @@ void SAL_CALL ModuleUIConfigurationManager::insertSettings( const OUString& NewR
rElements.emplace( NewResourceURL, aUIElementData );
Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about removed element settings
ui::ConfigurationEvent aEvent;
@@ -1394,9 +1406,7 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager()
if ( !m_xModuleImageManager.is() )
{
- m_xModuleImageManager.set( static_cast< cppu::OWeakObject *>( new ModuleImageManager( m_xContext )),
- UNO_QUERY );
- Reference< XInitialization > xInit( m_xModuleImageManager, UNO_QUERY );
+ m_xModuleImageManager = new ImageManager( m_xContext, /*bForModule*/true );
uno::Sequence<uno::Any> aPropSeq(comphelper::InitAnyPropertySequence(
{
@@ -1404,10 +1414,15 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager()
{"ModuleIdentifier", uno::Any(m_aModuleIdentifier)},
{"UserRootCommit", uno::Any(m_xUserRootCommit)},
}));
- xInit->initialize( aPropSeq );
+ m_xModuleImageManager->initialize( aPropSeq );
}
- return Reference< XInterface >( m_xModuleImageManager, UNO_QUERY );
+ return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xModuleImageManager.get()), UNO_QUERY );
+}
+
+Reference< ui::XAcceleratorConfiguration > SAL_CALL ModuleUIConfigurationManager::createShortCutManager()
+{
+ return ui::ModuleAcceleratorConfiguration::createWithModuleIdentifier(m_xContext, m_aModuleIdentifier);
}
Reference< ui::XAcceleratorConfiguration > SAL_CALL ModuleUIConfigurationManager::getShortCutManager()
@@ -1612,33 +1627,22 @@ sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly()
void ModuleUIConfigurationManager::implts_notifyContainerListener( const ui::ConfigurationEvent& aEvent, NotifyOp eOp )
{
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::ui::XUIConfigurationListener>::get());
- if ( pContainer == nullptr )
- return;
-
- ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
- while ( pIterator.hasMoreElements() )
+ std::unique_lock aGuard(m_mutex);
+ using ListenerMethodType = void (SAL_CALL css::ui::XUIConfigurationListener::*)(const ui::ConfigurationEvent&);
+ ListenerMethodType aListenerMethod {};
+ switch ( eOp )
{
- try
- {
- switch ( eOp )
- {
- case NotifyOp_Replace:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementReplaced( aEvent );
- break;
- case NotifyOp_Insert:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementInserted( aEvent );
- break;
- case NotifyOp_Remove:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementRemoved( aEvent );
- break;
- }
- }
- catch( const css::uno::RuntimeException& )
- {
- pIterator.remove();
- }
+ case NotifyOp_Replace:
+ aListenerMethod = &css::ui::XUIConfigurationListener::elementReplaced;
+ break;
+ case NotifyOp_Insert:
+ aListenerMethod = &css::ui::XUIConfigurationListener::elementInserted;
+ break;
+ case NotifyOp_Remove:
+ aListenerMethod = &css::ui::XUIConfigurationListener::elementRemoved;
+ break;
}
+ m_aConfigListeners.notifyEach(aGuard, aListenerMethod, aEvent);
}
}
diff --git a/framework/source/uiconfiguration/uicategorydescription.cxx b/framework/source/uiconfiguration/uicategorydescription.cxx
index 279b8b7fd192..1ff492242e6e 100644
--- a/framework/source/uiconfiguration/uicategorydescription.cxx
+++ b/framework/source/uiconfiguration/uicategorydescription.cxx
@@ -38,7 +38,6 @@
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
using namespace com::sun::star::configuration;
using namespace com::sun::star::container;
using namespace framework;
@@ -47,7 +46,7 @@ namespace {
class ConfigurationAccess_UICategory : public ::cppu::WeakImplHelper<XNameAccess,XContainerListener>
{
- osl::Mutex aMutex;
+ std::mutex aMutex;
public:
ConfigurationAccess_UICategory( std::u16string_view aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext );
virtual ~ConfigurationAccess_UICategory() override;
@@ -112,7 +111,7 @@ ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( std::u16string_v
ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory()
{
// SAFE
- osl::MutexGuard g(aMutex);
+ std::unique_lock g(aMutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
xContainer->removeContainerListener(m_xConfigListener);
@@ -121,7 +120,7 @@ ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory()
// XNameAccess
Any SAL_CALL ConfigurationAccess_UICategory::getByName( const OUString& rId )
{
- osl::MutexGuard g(aMutex);
+ std::unique_lock g(aMutex);
if ( !m_bConfigAccessInitialized )
{
initializeConfigAccess();
@@ -242,7 +241,7 @@ Any ConfigurationAccess_UICategory::getUINameFromCache( const OUString& rId )
Sequence< OUString > ConfigurationAccess_UICategory::getAllIds()
{
// SAFE
- osl::MutexGuard g(aMutex);
+ std::unique_lock g(aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -332,7 +331,7 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve
{
// SAFE
// remove our reference to the config access
- osl::MutexGuard g(aMutex);
+ std::unique_lock g(aMutex);
Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -365,38 +364,23 @@ public:
UICategoryDescription::UICategoryDescription( const Reference< XComponentContext >& rxContext ) :
UICommandDescription(rxContext,true)
{
- LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
+ SvtSysLocale aSysLocale;
+ const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
Reference< XNameAccess > xEmpty;
OUString aGenericCategories( "GenericCategories" );
- m_xGenericUICommands[aCurrentLanguage] = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, rxContext );
+ m_xGenericUICommands[rCurrentLanguage] = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, rxContext );
// insert generic categories mappings
m_aModuleToCommandFileMap.emplace( OUString("generic"), aGenericCategories );
- auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ auto& rMap = m_aUICommandsHashMap[rCurrentLanguage];
UICommandsHashMap::iterator pCatIter = rMap.find( aGenericCategories );
if ( pCatIter != rMap.end() )
- pCatIter->second = m_xGenericUICommands[aCurrentLanguage];
+ pCatIter->second = m_xGenericUICommands[rCurrentLanguage];
impl_fillElements("ooSetupFactoryCmdCategoryConfigRef");
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new UICategoryDescription(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -404,8 +388,7 @@ com_sun_star_comp_framework_UICategoryDescription_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new UICategoryDescription(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index e97cd33bb6c9..c1a24e598615 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -33,7 +33,6 @@
#include <com/sun/star/embed/StorageWrappedTargetException.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/lang/IllegalAccessException.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/io/XStream.hpp>
@@ -48,11 +47,16 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
+#include <mutex>
#include <string_view>
#include <unordered_map>
@@ -87,7 +91,7 @@ public:
return {"com.sun.star.ui.UIConfigurationManager"};
}
- explicit UIConfigurationManager( const css::uno::Reference< css::uno::XComponentContext > & rxContext );
+ explicit UIConfigurationManager( css::uno::Reference< css::uno::XComponentContext > xContext );
// XComponent
virtual void SAL_CALL dispose() override;
@@ -109,6 +113,7 @@ public:
virtual void SAL_CALL insertSettings( const OUString& NewResourceURL, const css::uno::Reference< css::container::XIndexAccess >& aNewData ) override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getImageManager() override;
virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL getShortCutManager() override;
+ virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL createShortCutManager() override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getEventsManager() override;
// XUIConfigurationPersistence
@@ -133,8 +138,8 @@ private:
struct UIElementInfo
{
- UIElementInfo( const OUString& rResourceURL, const OUString& rUIName ) :
- aResourceURL( rResourceURL), aUIName( rUIName ) {}
+ UIElementInfo( OUString _aResourceURL, OUString _aUIName ) :
+ aResourceURL(std::move( _aResourceURL)), aUIName(std::move( _aUIName )) {}
OUString aResourceURL;
OUString aUIName;
};
@@ -188,9 +193,10 @@ private:
bool m_bDisposed;
OUString m_aPropUIName;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
- osl::Mutex m_mutex;
- cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
- css::uno::Reference< css::lang::XComponent > m_xImageManager;
+ std::mutex m_mutex;
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
+ comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
+ rtl::Reference< ImageManager > m_xImageManager;
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAccConfig;
};
@@ -208,20 +214,19 @@ std::u16string_view UIELEMENTTYPENAMES[] =
u"" UIELEMENTTYPE_TOOLPANEL_NAME
};
-const char RESOURCEURL_PREFIX[] = "private:resource/";
-const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17;
+constexpr std::u16string_view RESOURCEURL_PREFIX = u"private:resource/";
-sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
+sal_Int16 RetrieveTypeFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
- sal_Int32 nIndex = aTmpStr.indexOf( '/' );
- if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex ))
+ std::u16string_view aTmpStr = aResourceURL.substr( RESOURCEURL_PREFIX.size() );
+ size_t nIndex = aTmpStr.find( '/' );
+ if (( nIndex > 0 ) && ( aTmpStr.size() > nIndex ))
{
- OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
+ std::u16string_view aTypeStr( aTmpStr.substr( 0, nIndex ));
for ( int i = 0; i < UIElementType::COUNT; i++ )
{
if ( aTypeStr == UIELEMENTTYPENAMES[i] )
@@ -233,14 +238,14 @@ sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
return UIElementType::UNKNOWN;
}
-OUString RetrieveNameFromResourceURL( const OUString& aResourceURL )
+OUString RetrieveNameFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
- if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
- return aResourceURL.copy( nIndex+1 );
+ size_t nIndex = aResourceURL.rfind( '/' );
+ if ( (nIndex > 0) && (nIndex != std::u16string_view::npos) && (( nIndex+1 ) < aResourceURL.size()) )
+ return OUString(aResourceURL.substr( nIndex+1 ));
}
return OUString();
@@ -297,11 +302,11 @@ void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementTy
sal_Int32 nIndex = rElementName.lastIndexOf( '.' );
if (( nIndex > 0 ) && ( nIndex < rElementName.getLength() ))
{
- OUString aExtension( rElementName.copy( nIndex+1 ));
- OUString aUIElementName( rElementName.copy( 0, nIndex ));
+ std::u16string_view aExtension( rElementName.subView( nIndex+1 ));
+ std::u16string_view aUIElementName( rElementName.subView( 0, nIndex ));
- if (!aUIElementName.isEmpty() &&
- ( aExtension.equalsIgnoreAsciiCase("xml")))
+ if (!aUIElementName.empty() &&
+ ( o3tl::equalsIgnoreAsciiCase(aExtension, u"xml")))
{
aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
aUIElementData.aName = rElementName;
@@ -346,11 +351,11 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
MenuConfiguration aMenuCfg( m_xContext );
Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xContainer );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xContainer.get() );
if ( pRootItemContainer )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
else
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, true ) ), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer( xContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -363,10 +368,10 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
try
{
- Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
+ Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xIndexContainer );
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -380,10 +385,10 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
try
{
- Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
+ Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getUnoTunnelImplementation<RootItemContainer>( xIndexContainer );
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, true ) ), UNO_QUERY );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
+ aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
catch ( const css::lang::WrappedTargetException& )
@@ -415,7 +420,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
}
// At least we provide an empty settings container!
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer()), UNO_QUERY );
+ aUIElementData.xSettings = new ConstItemContainer();
}
UIConfigurationManager::UIElementData* UIConfigurationManager::impl_findUIElementData( const OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
@@ -533,7 +538,7 @@ void UIConfigurationManager::impl_resetElementTypeData(
{
UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
@@ -572,7 +577,7 @@ void UIConfigurationManager::impl_reloadElementTypeData(
UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap;
Reference< XStorage > xElementStorage( rDocElementType.xStorage );
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
Reference< XInterface > xIfac( xThis, UNO_QUERY );
sal_Int16 nType = rDocElementType.nElementType;
@@ -666,13 +671,12 @@ void UIConfigurationManager::impl_Initialize()
}
}
-UIConfigurationManager::UIConfigurationManager( const css::uno::Reference< css::uno::XComponentContext > & rxContext ) :
+UIConfigurationManager::UIConfigurationManager( css::uno::Reference< css::uno::XComponentContext > xContext ) :
m_bReadOnly( true )
, m_bModified( false )
, m_bDisposed( false )
, m_aPropUIName( "UIName" )
- , m_xContext( rxContext )
- , m_aListenerContainer( m_mutex )
+ , m_xContext(std::move( xContext ))
{
// Make sure we have a default initialized entry for every layer and user interface element type!
// The following code depends on this!
@@ -682,10 +686,17 @@ UIConfigurationManager::UIConfigurationManager( const css::uno::Reference< css::
// XComponent
void SAL_CALL UIConfigurationManager::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
css::lang::EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.disposeAndClear( aGuard, aEvent );
+ }
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.disposeAndClear( aGuard, aEvent );
+ }
{
SolarMutexGuard g;
@@ -716,13 +727,15 @@ void SAL_CALL UIConfigurationManager::addEventListener( const Reference< XEventL
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.addInterface( aGuard, xListener );
}
void SAL_CALL UIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.removeInterface( aGuard, xListener );
}
// XUIConfigurationManager
@@ -736,13 +749,15 @@ void SAL_CALL UIConfigurationManager::addConfigurationListener( const Reference<
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.addInterface( aGuard, xListener );
}
void SAL_CALL UIConfigurationManager::removeConfigurationListener( const Reference< css::ui::XUIConfigurationListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.removeInterface( aGuard, xListener );
}
void SAL_CALL UIConfigurationManager::reset()
@@ -849,17 +864,15 @@ Sequence< Sequence< PropertyValue > > SAL_CALL UIConfigurationManager::getUIElem
else
impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
- Sequence< PropertyValue > aUIElementInfo( 2 );
- aUIElementInfo[0].Name = "ResourceURL";
- aUIElementInfo[1].Name = m_aPropUIName;
-
aElementInfoSeq.resize( aUIElementInfoCollection.size() );
sal_Int32 n = 0;
for (auto const& elem : aUIElementInfoCollection)
{
- aUIElementInfo[0].Value <<= elem.second.aResourceURL;
- aUIElementInfo[1].Value <<= elem.second.aUIName;
- aElementInfoSeq[n++] = aUIElementInfo;
+ aElementInfoSeq[n++] =
+ {
+ comphelper::makePropertyValue("ResourceURL", elem.second.aResourceURL),
+ comphelper::makePropertyValue(m_aPropUIName, elem.second.aUIName)
+ };
}
return comphelper::containerToSequence(aElementInfoSeq);
@@ -873,7 +886,7 @@ Reference< XIndexContainer > SAL_CALL UIConfigurationManager::createSettings()
throw DisposedException();
// Creates an empty item container which can be filled from outside
- return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer()), UNO_QUERY );
+ return Reference< XIndexContainer >( new RootItemContainer() );
}
sal_Bool SAL_CALL UIConfigurationManager::hasSettings( const OUString& ResourceURL )
@@ -908,7 +921,7 @@ Reference< XIndexAccess > SAL_CALL UIConfigurationManager::getSettings( const OU
{
// Create a copy of our data if someone wants to change the data.
if ( bWriteable )
- return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
+ return Reference< XIndexAccess >( new RootItemContainer( pDataSettings->xSettings ) );
else
return pDataSettings->xSettings;
}
@@ -941,7 +954,7 @@ void SAL_CALL UIConfigurationManager::replaceSettings( const OUString& ResourceU
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
if ( xReplace.is() )
- pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ pDataSettings->xSettings = new ConstItemContainer( aNewData );
else
pDataSettings->xSettings = aNewData;
@@ -953,15 +966,14 @@ void SAL_CALL UIConfigurationManager::replaceSettings( const OUString& ResourceU
UIElementType& rElementType = m_aUIElements[nElementType];
rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about replaced element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.ReplacedElement <<= xOldSettings;
aEvent.Element <<= pDataSettings->xSettings;
@@ -1013,15 +1025,15 @@ void SAL_CALL UIConfigurationManager::removeSettings( const OUString& ResourceUR
UIElementType& rElementType = m_aUIElements[nElementType];
rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about removed element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
+
aEvent.Element <<= xRemovedSettings;
aGuard.clear();
@@ -1067,7 +1079,7 @@ void SAL_CALL UIConfigurationManager::insertSettings( const OUString& NewResourc
// Create a copy of the data if the container is not const
Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
if ( xReplace.is() )
- pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ pDataSettings->xSettings = new ConstItemContainer( aNewData );
else
pDataSettings->xSettings = aNewData;
@@ -1086,15 +1098,14 @@ void SAL_CALL UIConfigurationManager::insertSettings( const OUString& NewResourc
}
Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis(this);
// Create event to notify listener about removed element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = NewResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.Element <<= xInsertSettings;
aGuard.clear();
@@ -1111,9 +1122,7 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager()
if ( !m_xImageManager.is() )
{
- m_xImageManager.set( static_cast< cppu::OWeakObject *>( new ImageManager( m_xContext )),
- UNO_QUERY );
- Reference< XInitialization > xInit( m_xImageManager, UNO_QUERY );
+ m_xImageManager = new ImageManager( m_xContext, /*bForModule*/false );
Sequence<Any> aPropSeq(comphelper::InitAnyPropertySequence(
{
@@ -1121,10 +1130,15 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager()
{"ModuleIdentifier", Any(OUString())},
}));
- xInit->initialize( aPropSeq );
+ m_xImageManager->initialize( aPropSeq );
}
- return Reference< XInterface >( m_xImageManager, UNO_QUERY );
+ return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xImageManager.get()), UNO_QUERY );
+}
+
+Reference< XAcceleratorConfiguration > SAL_CALL UIConfigurationManager::createShortCutManager()
+{
+ return DocumentAcceleratorConfiguration::createWithDocumentRoot(m_xContext, m_xDocConfigStorage);
}
Reference< XAcceleratorConfiguration > SAL_CALL UIConfigurationManager::getShortCutManager()
@@ -1178,12 +1192,8 @@ void SAL_CALL UIConfigurationManager::setStorage( const Reference< XStorage >& S
if ( m_xAccConfig.is() )
m_xAccConfig->setStorage( m_xDocConfigStorage );
- if ( m_xImageManager.is() )
- {
- ImageManager* pImageManager = static_cast<ImageManager*>(m_xImageManager.get());
- if ( pImageManager )
- pImageManager->setStorage( m_xDocConfigStorage );
- }
+ if ( m_xImageManager )
+ m_xImageManager->setStorage( m_xDocConfigStorage );
if ( m_xDocConfigStorage.is() )
{
@@ -1340,33 +1350,21 @@ sal_Bool SAL_CALL UIConfigurationManager::isReadOnly()
void UIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
{
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::ui::XUIConfigurationListener>::get());
- if ( pContainer == nullptr )
- return;
-
- ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
- while ( pIterator.hasMoreElements() )
- {
- try
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.forEach(aGuard, [&eOp, &aEvent](const css::uno::Reference<XUIConfigurationListener>& l) {
+ switch ( eOp )
{
- switch ( eOp )
- {
- case NotifyOp_Replace:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementReplaced( aEvent );
- break;
- case NotifyOp_Insert:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementInserted( aEvent );
- break;
- case NotifyOp_Remove:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementRemoved( aEvent );
- break;
- }
+ case NotifyOp_Replace:
+ l->elementReplaced( aEvent );
+ break;
+ case NotifyOp_Insert:
+ l->elementInserted( aEvent );
+ break;
+ case NotifyOp_Remove:
+ l->elementRemoved( aEvent );
+ break;
}
- catch( const css::uno::RuntimeException& )
- {
- pIterator.remove();
- }
- }
+ });
}
}
diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx
index 2d6d2b95e102..504ef4c97808 100644
--- a/framework/source/uiconfiguration/windowstateconfiguration.cxx
+++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx
@@ -36,14 +36,16 @@
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
+#include <comphelper/string.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/sequence.hxx>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
+#include <mutex>
#include <string_view>
#include <unordered_map>
#include <vector>
@@ -79,7 +81,7 @@ const sal_Int16 PROPERTY_DOCKPOS = 14;
const sal_Int16 PROPERTY_DOCKSIZE = 15;
// Order must be the same as WindowStateMask!!
-const char* CONFIGURATION_PROPERTIES[] =
+constexpr OUString CONFIGURATION_PROPERTIES[]
{
WINDOWSTATE_PROPERTY_LOCKED,
WINDOWSTATE_PROPERTY_DOCKED,
@@ -96,8 +98,7 @@ const char* CONFIGURATION_PROPERTIES[] =
WINDOWSTATE_PROPERTY_INTERNALSTATE,
WINDOWSTATE_PROPERTY_STYLE,
WINDOWSTATE_PROPERTY_DOCKPOS,
- WINDOWSTATE_PROPERTY_DOCKSIZE,
- nullptr
+ WINDOWSTATE_PROPERTY_DOCKSIZE
};
// Configuration access class for WindowState supplier implementation
@@ -203,7 +204,7 @@ class ConfigurationAccess_WindowState : public ::cppu::WeakImplHelper< XNameCon
typedef std::unordered_map< OUString,
WindowStateInfo > ResourceURLToInfoCache;
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
OUString m_aConfigWindowAccess;
Reference< XMultiServiceFactory > m_xConfigProvider;
Reference< XNameAccess > m_xConfigAccess;
@@ -223,18 +224,14 @@ ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( std::u16string
m_bModified( false )
{
// Initialize access array with property names.
- sal_Int32 n = 0;
- while ( CONFIGURATION_PROPERTIES[n] )
- {
- m_aPropArray.push_back( OUString::createFromAscii( CONFIGURATION_PROPERTIES[n] ));
- ++n;
- }
+ for (const OUString & s : CONFIGURATION_PROPERTIES )
+ m_aPropArray.push_back(s);
}
ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
xContainer->removeContainerListener(m_xConfigListener);
@@ -244,7 +241,7 @@ ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState()
Any SAL_CALL ConfigurationAccess_WindowState::getByName( const OUString& rResourceURL )
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
if ( pIter != m_aResourceURLToInfoCache.end() )
@@ -261,7 +258,7 @@ Any SAL_CALL ConfigurationAccess_WindowState::getByName( const OUString& rResour
Sequence< OUString > SAL_CALL ConfigurationAccess_WindowState::getElementNames()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -278,7 +275,7 @@ Sequence< OUString > SAL_CALL ConfigurationAccess_WindowState::getElementNames()
sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName( const OUString& rResourceURL )
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
if ( pIter != m_aResourceURLToInfoCache.end() )
@@ -302,7 +299,7 @@ Type SAL_CALL ConfigurationAccess_WindowState::getElementType()
sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -320,7 +317,7 @@ sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements()
void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rResourceURL )
{
// SAFE
- osl::ClearableMutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
if ( pIter != m_aResourceURLToInfoCache.end() )
@@ -338,7 +335,7 @@ void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rRe
Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
if ( xNameContainer.is() )
{
- g.clear();
+ g.unlock();
xNameContainer->removeByName( rResourceURL );
Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
@@ -354,7 +351,7 @@ void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rRe
void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rResourceURL, const css::uno::Any& aPropertySet )
{
// SAFE
- osl::ClearableMutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Sequence< PropertyValue > aPropSet;
if ( !(aPropertySet >>= aPropSet) )
@@ -387,7 +384,7 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe
return;
Reference< XSingleServiceFactory > xFactory( m_xConfigAccess, UNO_QUERY );
- g.clear();
+ g.unlock();
try
{
@@ -412,7 +409,7 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe
void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rResourceURL, const css::uno::Any& aPropertySet )
{
// SAFE
- osl::ClearableMutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Sequence< PropertyValue > aPropSet;
if ( !(aPropertySet >>= aPropSet) )
@@ -457,7 +454,7 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR
WindowStateInfo aWinStateInfo( pIter->second );
OUString aResourceURL( pIter->first );
m_bModified = false;
- g.clear();
+ g.unlock();
try
{
@@ -496,7 +493,7 @@ void SAL_CALL ConfigurationAccess_WindowState::disposing( const EventObject& aEv
{
// SAFE
// remove our reference to the config access
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -560,7 +557,7 @@ Any ConfigurationAccess_WindowState::impl_getSequenceFromStruct( const WindowSta
}
}
- return makeAny( comphelper::containerToSequence(aPropVec) );
+ return Any( comphelper::containerToSequence(aPropVec) );
}
Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OUString& rResourceURL, Reference< XNameAccess > const & xNameAccess )
@@ -641,12 +638,12 @@ Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OU
if ( a >>= aString )
{
sal_Int32 nToken( 0 );
- OUString aXStr = aString.getToken( 0, ',', nToken );
+ std::u16string_view aXStr = o3tl::getToken(aString, 0, ',', nToken );
if ( nToken > 0 )
{
css::awt::Point aPos;
- aPos.X = aXStr.toInt32();
- aPos.Y = aString.getToken( 0, ',', nToken ).toInt32();
+ aPos.X = o3tl::toInt32(aXStr);
+ aPos.Y = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken ));
if ( i == PROPERTY_POS )
{
@@ -673,12 +670,12 @@ Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OU
if ( a >>= aString )
{
sal_Int32 nToken( 0 );
- OUString aStr = aString.getToken( 0, ',', nToken );
+ std::u16string_view aStr = o3tl::getToken(aString, 0, ',', nToken );
if ( nToken > 0 )
{
css::awt::Size aSize;
- aSize.Width = aStr.toInt32();
- aSize.Height = aString.getToken( 0, ',', nToken ).toInt32();
+ aSize.Width = o3tl::toInt32(aStr);
+ aSize.Height = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken ));
if ( i == PROPERTY_SIZE )
{
aWindowStateInfo.aSize = aSize;
@@ -756,7 +753,7 @@ Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OU
aWindowStateInfo.nMask = nMask;
m_aResourceURLToInfoCache.emplace( rResourceURL, aWindowStateInfo );
- return makeAny( comphelper::containerToSequence(aPropVec) );
+ return Any( comphelper::containerToSequence(aPropVec) );
}
ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowState::impl_insertCacheAndReturnWinState( const OUString& rResourceURL, Reference< XNameAccess > const & rNameAccess )
@@ -834,12 +831,12 @@ ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowStat
if ( a >>= aString )
{
sal_Int32 nToken( 0 );
- OUString aXStr = aString.getToken( 0, ',', nToken );
+ std::u16string_view aXStr = o3tl::getToken(aString, 0, ',', nToken );
if ( nToken > 0 )
{
css::awt::Point aPos;
- aPos.X = aXStr.toInt32();
- aPos.Y = aString.getToken( 0, ',', nToken ).toInt32();
+ aPos.X = o3tl::toInt32(aXStr);
+ aPos.Y = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken ));
if ( i == PROPERTY_POS )
{
@@ -863,12 +860,12 @@ ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowStat
if ( a >>= aString )
{
sal_Int32 nToken( 0 );
- OUString aStr = aString.getToken( 0, ',', nToken );
+ std::u16string_view aStr = o3tl::getToken(aString, 0, ',', nToken );
if ( nToken > 0 )
{
css::awt::Size aSize;
- aSize.Width = aStr.toInt32();
- aSize.Height = aString.getToken( 0, ',', nToken ).toInt32();
+ aSize.Width = o3tl::toInt32(aStr);
+ aSize.Height = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken ));
if ( i == PROPERTY_SIZE )
{
aWindowStateInfo.aSize = aSize;
@@ -1132,23 +1129,23 @@ void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct( const Window
switch ( i )
{
case PROPERTY_LOCKED:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bLocked ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bLocked ) ); break;
case PROPERTY_DOCKED:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bDocked ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bDocked ) ); break;
case PROPERTY_VISIBLE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bVisible ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bVisible ) ); break;
case PROPERTY_CONTEXT:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bContext ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bContext ) ); break;
case PROPERTY_HIDEFROMMENU:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bHideFromMenu ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bHideFromMenu ) ); break;
case PROPERTY_NOCLOSE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bNoClose ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bNoClose ) ); break;
case PROPERTY_SOFTCLOSE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bSoftClose ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bSoftClose ) ); break;
case PROPERTY_CONTEXTACTIVE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bContextActive ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.bContextActive ) ); break;
case PROPERTY_DOCKINGAREA:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int16( rWinStateInfo.aDockingArea ) ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( sal_Int16( rWinStateInfo.aDockingArea ) ) ); break;
case PROPERTY_POS:
case PROPERTY_DOCKPOS:
{
@@ -1162,7 +1159,7 @@ void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct( const Window
aPosStr += OUString::number( rWinStateInfo.aPos.Y );
else
aPosStr += OUString::number( rWinStateInfo.aDockPos.Y );
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aPosStr ) );
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( aPosStr ) );
break;
}
case PROPERTY_SIZE:
@@ -1178,15 +1175,15 @@ void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct( const Window
aSizeStr += OUString::number( rWinStateInfo.aSize.Height );
else
aSizeStr += OUString::number( rWinStateInfo.aDockSize.Height );
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aSizeStr ) );
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( aSizeStr ) );
break;
}
case PROPERTY_UINAME:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.aUIName ) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( rWinStateInfo.aUIName ) ); break;
case PROPERTY_INTERNALSTATE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int32( rWinStateInfo.nInternalState )) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( sal_Int32( rWinStateInfo.nInternalState )) ); break;
case PROPERTY_STYLE:
- xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int32( rWinStateInfo.nStyle )) ); break;
+ xPropSet->setPropertyValue( m_aPropArray[i], Any( sal_Int32( rWinStateInfo.nStyle )) ); break;
default:
assert( false && "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
}
@@ -1227,11 +1224,10 @@ void ConfigurationAccess_WindowState::impl_initializeConfigAccess()
}
}
-typedef ::cppu::WeakComponentImplHelper< css::container::XNameAccess,
+typedef comphelper::WeakComponentImplHelper< css::container::XNameAccess,
css::lang::XServiceInfo> WindowStateConfiguration_BASE;
-class WindowStateConfiguration : private cppu::BaseMutex,
- public WindowStateConfiguration_BASE
+class WindowStateConfiguration : public WindowStateConfiguration_BASE
{
public:
explicit WindowStateConfiguration( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
@@ -1276,7 +1272,6 @@ private:
};
WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentContext >& rxContext ) :
- WindowStateConfiguration_BASE(m_aMutex),
m_xContext( rxContext )
{
css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
@@ -1292,12 +1287,12 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentC
}
Sequence< PropertyValue > aSeq;
- for ( OUString const & aModuleIdentifier : std::as_const(aElementNames) )
+ for (OUString const& aModuleIdentifier : aElementNames)
{
if ( xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
{
OUString aWindowStateFileStr;
- for ( PropertyValue const & rProp : std::as_const(aSeq) )
+ for (PropertyValue const& rProp : aSeq)
{
if ( rProp.Name == "ooSetupFactoryWindowStateConfigRef" )
{
@@ -1322,14 +1317,14 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentC
WindowStateConfiguration::~WindowStateConfiguration()
{
- osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
m_aModuleToFileHashMap.clear();
m_aModuleToWindowStateHashMap.clear();
}
Any SAL_CALL WindowStateConfiguration::getByName( const OUString& aModuleIdentifier )
{
- osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aModuleIdentifier );
if ( pIter != m_aModuleToFileHashMap.end() )
@@ -1344,9 +1339,7 @@ Any SAL_CALL WindowStateConfiguration::getByName( const OUString& aModuleIdentif
a <<= pModuleIter->second;
else
{
- Reference< XNameAccess > xResourceURLWindowState;
- ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext );
- xResourceURLWindowState.set( static_cast< cppu::OWeakObject* >( pModuleWindowState ),UNO_QUERY );
+ Reference< XNameAccess > xResourceURLWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext );
pModuleIter->second = xResourceURLWindowState;
a <<= xResourceURLWindowState;
}
@@ -1360,14 +1353,14 @@ Any SAL_CALL WindowStateConfiguration::getByName( const OUString& aModuleIdentif
Sequence< OUString > SAL_CALL WindowStateConfiguration::getElementNames()
{
- osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return comphelper::mapKeysToSequence( m_aModuleToFileHashMap );
}
sal_Bool SAL_CALL WindowStateConfiguration::hasByName( const OUString& aName )
{
- osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aName );
return ( pIter != m_aModuleToFileHashMap.end() );
@@ -1385,22 +1378,6 @@ sal_Bool SAL_CALL WindowStateConfiguration::hasElements()
return true;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new WindowStateConfiguration(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -1408,8 +1385,7 @@ com_sun_star_comp_framework_WindowStateConfiguration_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new WindowStateConfiguration(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uielement/FixedImageToolbarController.cxx b/framework/source/uielement/FixedImageToolbarController.cxx
index 49377db5e555..1ec52a672287 100644
--- a/framework/source/uielement/FixedImageToolbarController.cxx
+++ b/framework/source/uielement/FixedImageToolbarController.cxx
@@ -28,12 +28,8 @@
#include <framework/addonsoptions.hxx>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
namespace framework
{
@@ -57,7 +53,7 @@ FixedImageControl::FixedImageControl(vcl::Window* pParent, const OUString& rComm
m_xWidget->connect_key_press(LINK(this, FixedImageControl, KeyInputHdl));
- bool bBigImages(SvtMiscOptions().AreCurrentSymbolsLarge());
+ bool bBigImages(SvtMiscOptions::AreCurrentSymbolsLarge());
auto xImage
= Graphic(AddonsOptions().GetImageFromURL(rCommand, bBigImages, true)).GetXGraphic();
m_xWidget->set_image(xImage);
@@ -80,9 +76,9 @@ void FixedImageControl::dispose()
FixedImageToolbarController::FixedImageToolbarController(
const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame,
- ToolBox* pToolbar, sal_uInt16 nID, const OUString& rCommand)
+ ToolBox* pToolbar, ToolBoxItemId nID, const OUString& rCommand)
: ComplexToolbarController(rxContext, rFrame, pToolbar, nID, rCommand)
- , m_eSymbolSize(SvtMiscOptions().GetCurrentSymbolsSize())
+ , m_eSymbolSize(SvtMiscOptions::GetCurrentSymbolsSize())
{
m_pFixedImageControl = VclPtr<FixedImageControl>::Create(m_xToolbar, rCommand);
m_xToolbar->SetItemWindow(m_nID, m_pFixedImageControl);
@@ -106,8 +102,7 @@ void FixedImageToolbarController::CheckAndUpdateImages()
{
SolarMutexGuard aSolarMutexGuard;
- SvtMiscOptions aMiscOptions;
- const sal_Int16 eNewSymbolSize = aMiscOptions.GetCurrentSymbolsSize();
+ const sal_Int16 eNewSymbolSize = SvtMiscOptions::GetCurrentSymbolsSize();
if (m_eSymbolSize == eNewSymbolSize)
return;
diff --git a/framework/source/uielement/FixedTextToolbarController.cxx b/framework/source/uielement/FixedTextToolbarController.cxx
index 32b486379178..44cf712c72e4 100644
--- a/framework/source/uielement/FixedTextToolbarController.cxx
+++ b/framework/source/uielement/FixedTextToolbarController.cxx
@@ -19,17 +19,15 @@
#include <uielement/FixedTextToolbarController.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <vcl/svapp.hxx>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
namespace framework
{
@@ -71,7 +69,7 @@ void FixedTextControl::dispose()
FixedTextToolbarController::FixedTextToolbarController(
const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame,
- ToolBox* pToolbar, sal_uInt16 nID, const OUString& aCommand)
+ ToolBox* pToolbar, ToolBoxItemId nID, const OUString& aCommand)
: ComplexToolbarController(rxContext, rFrame, pToolbar, nID, aCommand)
{
m_pFixedTextControl = VclPtr<FixedTextControl>::Create(m_xToolbar);
@@ -89,14 +87,11 @@ void SAL_CALL FixedTextToolbarController::dispose()
Sequence<PropertyValue> FixedTextToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs(2);
const OUString aSelectedText = m_pFixedTextControl->get_label();
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Text";
- aArgs[1].Value <<= aSelectedText;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Text", aSelectedText) };
return aArgs;
}
diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx
index fb7ac0f0f5e8..740a120d63e7 100644
--- a/framework/source/uielement/addonstoolbarwrapper.cxx
+++ b/framework/source/uielement/addonstoolbarwrapper.cxx
@@ -27,6 +27,7 @@
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
+#include <vcl/wintypes.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
@@ -53,7 +54,7 @@ AddonsToolBarWrapper::~AddonsToolBarWrapper()
// XComponent
void SAL_CALL AddonsToolBarWrapper::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
css::lang::EventObject aEvent( xThis );
m_aListenerContainer.disposeAndClear( aEvent );
@@ -96,18 +97,18 @@ void SAL_CALL AddonsToolBarWrapper::initialize( const Sequence< Any >& aArgument
// Create VCL based toolbar which will be filled with settings data
VclPtr<ToolBox> pToolBar;
- ToolBarManager* pToolBarManager = nullptr;
+ rtl::Reference<ToolBarManager> pToolBarManager;
{
SolarMutexGuard aSolarMutexGuard;
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
if ( pWindow )
{
- sal_uLong nStyles = WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
+ WinBits nStyles = WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
pToolBar = VclPtr<ToolBox>::Create( pWindow, nStyles );
pToolBar->SetLineSpacing(true);
pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar );
- m_xToolBarManager.set( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY );
+ m_xToolBarManager = pToolBarManager;
}
}
@@ -134,14 +135,10 @@ Reference< XInterface > SAL_CALL AddonsToolBarWrapper::getRealInterface()
{
SolarMutexGuard g;
- if ( m_xToolBarManager.is() )
+ if ( m_xToolBarManager )
{
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( pToolBarManager )
- {
- vcl::Window* pWindow = pToolBarManager->GetToolBar();
- return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
- }
+ vcl::Window* pWindow = m_xToolBarManager->GetToolBar();
+ return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
}
return Reference< XInterface >();
@@ -155,14 +152,10 @@ void AddonsToolBarWrapper::populateImages()
if (m_bCreatedImages)
return;
- if ( m_xToolBarManager.is() )
+ if (m_xToolBarManager)
{
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if (pToolBarManager)
- {
- pToolBarManager->RequestImages();
- m_bCreatedImages = true;
- }
+ m_xToolBarManager->RequestImages();
+ m_bCreatedImages = true;
}
}
diff --git a/framework/source/uielement/buttontoolbarcontroller.cxx b/framework/source/uielement/buttontoolbarcontroller.cxx
index 6c5c3fdeb88c..d100ee17113e 100644
--- a/framework/source/uielement/buttontoolbarcontroller.cxx
+++ b/framework/source/uielement/buttontoolbarcontroller.cxx
@@ -27,6 +27,8 @@
#include <cppuhelper/queryinterface.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
@@ -42,14 +44,13 @@ namespace framework
{
ButtonToolbarController::ButtonToolbarController(
- const uno::Reference< uno::XComponentContext >& rxContext,
+ uno::Reference< uno::XComponentContext > xContext,
ToolBox* pToolBar,
- const OUString& aCommand ) :
- cppu::OWeakObject(),
+ OUString aCommand ) :
m_bInitialized( false ),
m_bDisposed( false ),
- m_aCommandURL( aCommand ),
- m_xContext( rxContext ),
+ m_aCommandURL(std::move( aCommand )),
+ m_xContext(std::move( xContext )),
m_pToolbar( pToolBar )
{
}
@@ -75,12 +76,12 @@ uno::Any SAL_CALL ButtonToolbarController::queryInterface( const uno::Type& rTyp
return cppu::OWeakObject::queryInterface( rType );
}
-void SAL_CALL ButtonToolbarController::acquire() throw ()
+void SAL_CALL ButtonToolbarController::acquire() noexcept
{
cppu::OWeakObject::acquire();
}
-void SAL_CALL ButtonToolbarController::release() throw ()
+void SAL_CALL ButtonToolbarController::release() noexcept
{
cppu::OWeakObject::release();
}
@@ -89,21 +90,14 @@ void SAL_CALL ButtonToolbarController::release() throw ()
void SAL_CALL ButtonToolbarController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
{
- bool bInitialized( true );
-
- {
- SolarMutexGuard aSolarMutexGuard;
-
- if ( m_bDisposed )
- throw DisposedException();
+ SolarMutexGuard aSolarMutexGuard;
- bInitialized = m_bInitialized;
- }
+ if ( m_bDisposed )
+ throw DisposedException();
- if ( bInitialized )
+ if ( m_bInitialized )
return;
- SolarMutexGuard aSolarMutexGuard;
m_bInitialized = true;
PropertyValue aPropValue;
@@ -132,7 +126,7 @@ void SAL_CALL ButtonToolbarController::dispose()
{
SolarMutexGuard aSolarMutexGuard;
if ( m_bDisposed )
- throw DisposedException();
+ return;
m_xContext.clear();
m_xURLTransformer.clear();
@@ -229,11 +223,8 @@ void SAL_CALL ButtonToolbarController::execute( sal_Int16 KeyModifier )
try
{
- Sequence<PropertyValue> aArgs( 1 );
-
// Provide key modifier information to dispatch function
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier) };
xDispatch->dispatch( aTargetURL, aArgs );
}
diff --git a/framework/source/uielement/comboboxtoolbarcontroller.cxx b/framework/source/uielement/comboboxtoolbarcontroller.cxx
index 745b25d2cf99..68598a2a4ef6 100644
--- a/framework/source/uielement/comboboxtoolbarcontroller.cxx
+++ b/framework/source/uielement/comboboxtoolbarcontroller.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/svapp.hxx>
@@ -29,9 +30,7 @@
using namespace ::com::sun::star;
using namespace css::uno;
using namespace css::beans;
-using namespace css::lang;
using namespace css::frame;
-using namespace css::util;
namespace framework
{
@@ -145,7 +144,7 @@ ComboboxToolbarController::ComboboxToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
sal_Int32 nWidth,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
@@ -178,14 +177,11 @@ void SAL_CALL ComboboxToolbarController::dispose()
Sequence<PropertyValue> ComboboxToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 2 );
OUString aSelectedText = m_pComboBox->get_active_text();
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Text";
- aArgs[1].Value <<= aSelectedText;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Text", aSelectedText) };
return aArgs;
}
@@ -247,11 +243,11 @@ void ComboboxToolbarController::executeControlCommand( const css::frame::Control
m_pComboBox->clear();
rArg.Value >>= aList;
- for (OUString const & rName : std::as_const(aList))
+ for (OUString const& rName : aList)
m_pComboBox->append_text(rName);
// send notification
- uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::makeAny(aList) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::Any(aList) } };
addNotifyInfo( "ListChanged",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
diff --git a/framework/source/uielement/complextoolbarcontroller.cxx b/framework/source/uielement/complextoolbarcontroller.cxx
index b62febf87663..5a8a84e55d25 100644
--- a/framework/source/uielement/complextoolbarcontroller.cxx
+++ b/framework/source/uielement/complextoolbarcontroller.cxx
@@ -28,13 +28,13 @@
#include <com/sun/star/frame/XControlNotificationListener.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/svapp.hxx>
#include <vcl/mnemonic.hxx>
#include <vcl/toolbox.hxx>
using namespace ::com::sun::star;
-using namespace css::awt;
using namespace css::uno;
using namespace css::beans;
using namespace css::lang;
@@ -49,7 +49,7 @@ ComplexToolbarController::ComplexToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
const OUString& aCommand ) :
svt::ToolboxController( rxContext, rFrame, aCommand )
, m_xToolbar( pToolbar )
@@ -72,16 +72,13 @@ void SAL_CALL ComplexToolbarController::dispose()
m_xURLTransformer.clear();
m_xToolbar.clear();
- m_nID = 0;
+ m_nID = ToolBoxItemId(0);
}
Sequence<PropertyValue> ComplexToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 1 );
-
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier) };
return aArgs;
}
@@ -177,7 +174,7 @@ void ComplexToolbarController::statusChanged( const FeatureStateEvent& Event )
{
if (aControlCommand.Command == "SetQuickHelpText")
{
- for (NamedValue const & rArg : std::as_const(aControlCommand.Arguments))
+ for (NamedValue const& rArg : aControlCommand.Arguments)
{
if (rArg.Name == "HelpText")
{
@@ -264,8 +261,9 @@ void ComplexToolbarController::addNotifyInfo(
sal_Int32 nCount = rInfo.getLength();
uno::Sequence< beans::NamedValue > aInfoSeq( rInfo );
aInfoSeq.realloc( nCount+1 );
- aInfoSeq[nCount].Name = "Source";
- aInfoSeq[nCount].Value <<= getFrameInterface();
+ auto pInfoSeq = aInfoSeq.getArray();
+ pInfoSeq[nCount].Name = "Source";
+ pInfoSeq[nCount].Value <<= getFrameInterface();
pNotifyInfo->aInfoSeq = aInfoSeq;
Application::PostUserEvent( LINK(nullptr, ComplexToolbarController, Notify_Impl), pNotifyInfo );
@@ -316,7 +314,7 @@ void ComplexToolbarController::notifyFocusLost()
void ComplexToolbarController::notifyTextChanged( const OUString& aText )
{
// send text changed notification
- uno::Sequence< beans::NamedValue > aInfo { { "Text", css::uno::makeAny(aText) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "Text", css::uno::Any(aText) } };
addNotifyInfo( "TextChanged",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index fb5362307068..abb4a5762eb5 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -26,21 +26,18 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <vcl/builder.hxx>
-#include <vcl/menu.hxx>
+#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/image.hxx>
#include <svtools/popupmenucontrollerbase.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <osl/mutex.hxx>
-#include <memory>
-#include <string_view>
#include <unordered_map>
+#include <classes/fwkresid.hxx>
#include <bitmaps.hlst>
-
-// See svx/source/form/fmshimp.cxx for other use of this .ui
+#include <strings.hrc>
static const char* aCommands[] =
{
@@ -66,35 +63,58 @@ static const char* aCommands[] =
".uno:ConvertToNavigationBar"
};
-const std::u16string_view aImgIds[] =
+static TranslateId aLabels[] =
+{
+ RID_STR_PROPTITLE_EDIT,
+ RID_STR_PROPTITLE_PUSHBUTTON,
+ RID_STR_PROPTITLE_FIXEDTEXT,
+ RID_STR_PROPTITLE_LISTBOX,
+ RID_STR_PROPTITLE_CHECKBOX,
+ RID_STR_PROPTITLE_RADIOBUTTON,
+ RID_STR_PROPTITLE_GROUPBOX,
+ RID_STR_PROPTITLE_COMBOBOX,
+ RID_STR_PROPTITLE_IMAGEBUTTON,
+ RID_STR_PROPTITLE_FILECONTROL,
+ RID_STR_PROPTITLE_DATEFIELD,
+ RID_STR_PROPTITLE_TIMEFIELD,
+ RID_STR_PROPTITLE_NUMERICFIELD,
+ RID_STR_PROPTITLE_CURRENCYFIELD,
+ RID_STR_PROPTITLE_PATTERNFIELD,
+ RID_STR_PROPTITLE_IMAGECONTROL,
+ RID_STR_PROPTITLE_FORMATTED,
+ RID_STR_PROPTITLE_SCROLLBAR,
+ RID_STR_PROPTITLE_SPINBUTTON,
+ RID_STR_PROPTITLE_NAVBAR
+};
+
+constexpr OUString aImgIds[]
{
- u"" RID_SVXBMP_EDITBOX,
- u"" RID_SVXBMP_BUTTON,
- u"" RID_SVXBMP_FIXEDTEXT,
- u"" RID_SVXBMP_LISTBOX,
- u"" RID_SVXBMP_CHECKBOX,
- u"" RID_SVXBMP_RADIOBUTTON,
- u"" RID_SVXBMP_GROUPBOX,
- u"" RID_SVXBMP_COMBOBOX,
- u"" RID_SVXBMP_IMAGEBUTTON,
- u"" RID_SVXBMP_FILECONTROL,
- u"" RID_SVXBMP_DATEFIELD,
- u"" RID_SVXBMP_TIMEFIELD,
- u"" RID_SVXBMP_NUMERICFIELD,
- u"" RID_SVXBMP_CURRENCYFIELD,
- u"" RID_SVXBMP_PATTERNFIELD,
- u"" RID_SVXBMP_IMAGECONTROL,
- u"" RID_SVXBMP_FORMATTEDFIELD,
- u"" RID_SVXBMP_SCROLLBAR,
- u"" RID_SVXBMP_SPINBUTTON,
- u"" RID_SVXBMP_NAVIGATIONBAR
+ RID_SVXBMP_EDITBOX,
+ RID_SVXBMP_BUTTON,
+ RID_SVXBMP_FIXEDTEXT,
+ RID_SVXBMP_LISTBOX,
+ RID_SVXBMP_CHECKBOX,
+ RID_SVXBMP_RADIOBUTTON,
+ RID_SVXBMP_GROUPBOX,
+ RID_SVXBMP_COMBOBOX,
+ RID_SVXBMP_IMAGEBUTTON,
+ RID_SVXBMP_FILECONTROL,
+ RID_SVXBMP_DATEFIELD,
+ RID_SVXBMP_TIMEFIELD,
+ RID_SVXBMP_NUMERICFIELD,
+ RID_SVXBMP_CURRENCYFIELD,
+ RID_SVXBMP_PATTERNFIELD,
+ RID_SVXBMP_IMAGECONTROL,
+ RID_SVXBMP_FORMATTEDFIELD,
+ RID_SVXBMP_SCROLLBAR,
+ RID_SVXBMP_SPINBUTTON,
+ RID_SVXBMP_NAVIGATIONBAR
};
using namespace css;
using namespace css::uno;
using namespace css::lang;
using namespace css::frame;
-using namespace css::beans;
namespace {
@@ -124,9 +144,6 @@ public:
// XPopupMenuController
virtual void SAL_CALL updatePopupMenu() override;
- // XInitialization
- virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) override;
-
// XStatusListener
virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) override;
@@ -137,7 +154,8 @@ public:
virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
private:
- virtual void impl_setPopupMenu() override;
+ // XInitialization
+ virtual void initializeImpl( std::unique_lock<std::mutex>& rGuard, const uno::Sequence< uno::Any >& aArguments ) override;
class UrlToDispatchMap : public std::unordered_map< OUString,
uno::Reference< frame::XDispatch > >
@@ -149,12 +167,10 @@ private:
}
};
- void updateImagesPopupMenu( PopupMenu* pPopupMenu );
- void fillPopupMenu( uno::Reference< awt::XPopupMenu > const & rPopupMenu );
+ void updateImagesPopupMenu(Reference<awt::XPopupMenu> const& rPopupMenu);
+ void fillPopupMenu(uno::Reference<awt::XPopupMenu> const& rPopupMenu);
bool m_bShowMenuImages : 1;
- std::unique_ptr<VclBuilder> m_xBuilder;
- VclPtr<PopupMenu> m_xResPopupMenu;
UrlToDispatchMap m_aURLToDispatchMap;
};
@@ -167,156 +183,107 @@ ControlMenuController::ControlMenuController(const css::uno::Reference< css::uno
}
// private function
-void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu )
+void ControlMenuController::updateImagesPopupMenu(Reference<awt::XPopupMenu> const& rPopupMenu)
{
- for (size_t i=0; i < SAL_N_ELEMENTS(aCommands); ++i)
+ if (!rPopupMenu)
+ return;
+ for (size_t i=0; i < std::size(aCommands); ++i)
{
- //ident is .uno:Command without .uno:
- OString sIdent = OString(aCommands[i]).copy(5);
- sal_uInt16 nId = pPopupMenu->GetItemId(sIdent);
+ sal_Int16 nItemId = i + 1;
if (m_bShowMenuImages)
- pPopupMenu->SetItemImage(nId, Image(StockImage::Yes, OUString(aImgIds[i])));
+ {
+ Image aImage(StockImage::Yes, aImgIds[i]);
+ Graphic aGraphic(aImage);
+ rPopupMenu->setItemImage(nItemId, aGraphic.GetXGraphic(), false);
+ }
else
- pPopupMenu->SetItemImage(nId, Image());
+ rPopupMenu->setItemImage(nItemId, nullptr, false);
}
}
// private function
void ControlMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
+ resetPopupMenu( rPopupMenu );
- SolarMutexGuard aSolarMutexGuard;
+ for (size_t i=0; i < SAL_N_ELEMENTS(aCommands); ++i)
+ {
+ sal_Int16 nItemId = i + 1;
+ OUString sCommand(OUString::createFromAscii(aCommands[i]));
+ rPopupMenu->insertItem(nItemId, FwkResId(aLabels[i]), 0, i);
+ rPopupMenu->setCommand(nItemId, sCommand);
+ rPopupMenu->enableItem(nItemId, false);
+ }
- resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
+ updateImagesPopupMenu(rPopupMenu);
+
+ rPopupMenu->hideDisabledEntries(true);
+}
- if (pVCLPopupMenu && m_xResPopupMenu)
- *pVCLPopupMenu = *m_xResPopupMenu;
}
// XEventListener
void SAL_CALL ControlMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
- m_xResPopupMenu.clear();
- m_xBuilder.reset();
}
// XStatusListener
void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
+
+ if (!m_xPopupMenu)
+ return;
- OString sIdent;
+ sal_Int16 nItemId = 0;
for (size_t i=0; i < SAL_N_ELEMENTS(aCommands); ++i)
{
if ( Event.FeatureURL.Complete.equalsAscii( aCommands[i] ))
{
- //ident is .uno:Command without .uno:
- sIdent = OString(aCommands[i]).copy(5);
+ nItemId = i + 1;
break;
}
}
- sal_uInt16 nMenuId = 0;
-
- VCLXPopupMenu* pPopupMenu = nullptr;
-
- if (!sIdent.isEmpty() && m_xResPopupMenu)
- {
- pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
- nMenuId = m_xResPopupMenu->GetItemId(sIdent);
- }
-
- if (!pPopupMenu)
+ if (!nItemId)
return;
- SolarMutexGuard aSolarMutexGuard;
-
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
-
- if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND )
- pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId ));
- else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND )
- {
- sal_Int16 nSourcePos = m_xResPopupMenu->GetItemPos(nMenuId);
- sal_Int16 nPrevInSource = nSourcePos;
- sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
- while (nPrevInSource>0)
- {
- sal_Int16 nPrevId = m_xResPopupMenu->GetItemId(--nPrevInSource);
-
- // do we have the source's predecessor in our conversion menu, too ?
- nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId );
- if ( nPrevInConversion != MENU_ITEM_NOTFOUND )
- break;
- }
-
- if ( MENU_ITEM_NOTFOUND == nPrevInConversion )
- // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
- nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
-
- pVCLPopupMenu->InsertItem(nMenuId, m_xResPopupMenu->GetItemText(nMenuId), m_xResPopupMenu->GetItemBits(nMenuId), OString(), ++nPrevInConversion);
- pVCLPopupMenu->SetItemImage(nMenuId, m_xResPopupMenu->GetItemImage(nMenuId));
- pVCLPopupMenu->SetHelpId(nMenuId, m_xResPopupMenu->GetHelpId(nMenuId));
- }
+ m_xPopupMenu->enableItem(nItemId, Event.IsEnabled);
}
// XMenuListener
void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
{
- osl::MutexGuard aLock( m_aMutex );
-
- if ( !m_xPopupMenu.is() )
- return;
+ std::unique_lock aLock( m_aMutex );
SolarMutexGuard aSolarMutexGuard;
// Check if some modes have changed so we have to update our menu images
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- bool bShowMenuImages = rSettings.GetUseImagesInMenus();
+ bool bShowMenuImages = rSettings.GetUseImagesInMenus();
if (bShowMenuImages != m_bShowMenuImages)
{
- m_bShowMenuImages = bShowMenuImages;
-
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
- if ( pPopupMenu )
- {
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if (pVCLPopupMenu)
- updateImagesPopupMenu( pVCLPopupMenu );
- }
+ m_bShowMenuImages = bShowMenuImages;
+ updateImagesPopupMenu(m_xPopupMenu);
}
}
// XPopupMenuController
-void ControlMenuController::impl_setPopupMenu()
-{
- if (!m_xResPopupMenu)
- {
- m_xBuilder.reset(new VclBuilder(nullptr, AllSettings::GetUIRootDir(), "svx/ui/convertmenu.ui", ""));
- m_xResPopupMenu = m_xBuilder->get_menu("menu");
- updateImagesPopupMenu(m_xResPopupMenu);
- }
-}
-
void SAL_CALL ControlMenuController::updatePopupMenu()
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
if ( !(m_xFrame.is() && m_xPopupMenu.is()) )
return;
@@ -334,23 +301,22 @@ void SAL_CALL ControlMenuController::updatePopupMenu()
Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
if ( xDispatch.is() )
{
+ aLock.unlock(); // the addStatusListener will call back into ::statusChanged
xDispatch->addStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
xDispatch->removeStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
+ aLock.lock();
m_aURLToDispatchMap.emplace( aTargetURL.Complete, xDispatch );
}
}
}
// XInitialization
-void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments )
+void ControlMenuController::initializeImpl( std::unique_lock<std::mutex>& rGuard, const Sequence< Any >& aArguments )
{
- osl::MutexGuard aLock( m_aMutex );
- svt::PopupMenuControllerBase::initialize(aArguments);
+ svt::PopupMenuControllerBase::initializeImpl(rGuard, aArguments);
m_aBaseURL.clear();
}
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_framework_ControlMenuController_get_implementation(
css::uno::XComponentContext *context,
diff --git a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx
index b694bca18ed6..2630ecb534d3 100644
--- a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx
+++ b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx
@@ -21,18 +21,16 @@
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
using namespace ::com::sun::star;
-using namespace css::awt;
using namespace css::uno;
using namespace css::beans;
-using namespace css::lang;
using namespace css::frame;
-using namespace css::util;
namespace framework
{
@@ -122,7 +120,7 @@ DropdownToolbarController::DropdownToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
sal_Int32 nWidth,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
@@ -155,14 +153,11 @@ void SAL_CALL DropdownToolbarController::dispose()
Sequence<PropertyValue> DropdownToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 2 );
OUString aSelectedText = m_pListBoxControl->get_active_text();
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Text";
- aArgs[1].Value <<= aSelectedText;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Text", aSelectedText) };
return aArgs;
}
@@ -194,13 +189,13 @@ void DropdownToolbarController::executeControlCommand( const css::frame::Control
m_pListBoxControl->clear();
rArg.Value >>= aList;
- for (OUString const & rName : std::as_const(aList))
+ for (OUString const& rName : aList)
m_pListBoxControl->append_text(rName);
m_pListBoxControl->set_active(0);
// send notification
- uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::makeAny(aList) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::Any(aList) } };
addNotifyInfo( "ListChanged",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
diff --git a/framework/source/uielement/edittoolbarcontroller.cxx b/framework/source/uielement/edittoolbarcontroller.cxx
index 3bbb3f9755cc..9bd65d5a0948 100644
--- a/framework/source/uielement/edittoolbarcontroller.cxx
+++ b/framework/source/uielement/edittoolbarcontroller.cxx
@@ -20,6 +20,8 @@
#include <uielement/edittoolbarcontroller.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <comphelper/propertyvalue.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/svapp.hxx>
@@ -29,9 +31,7 @@
using namespace ::com::sun::star;
using namespace css::uno;
using namespace css::beans;
-using namespace css::lang;
using namespace css::frame;
-using namespace css::util;
namespace framework
{
@@ -66,7 +66,7 @@ EditControl::EditControl(vcl::Window* pParent, EditToolbarController* pEditToolb
, m_xWidget(m_xBuilder->weld_entry("entry"))
, m_pEditToolbarController(pEditToolbarController)
{
- OString sEmpty;
+ OUString sEmpty;
m_xWidget->set_help_id(sEmpty);
m_xContainer->set_help_id(sEmpty);
@@ -127,7 +127,7 @@ EditToolbarController::EditToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
sal_Int32 nWidth,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
@@ -160,14 +160,11 @@ void SAL_CALL EditToolbarController::dispose()
Sequence<PropertyValue> EditToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 2 );
OUString aSelectedText = m_pEditControl->get_text();
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Text";
- aArgs[1].Value <<= aSelectedText;
+ Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Text", aSelectedText) };
return aArgs;
}
diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx
index 5b53720852a5..6fc2398b9850 100644
--- a/framework/source/uielement/fontmenucontroller.cxx
+++ b/framework/source/uielement/fontmenucontroller.cxx
@@ -26,27 +26,22 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/i18nhelp.hxx>
#include <tools/urlobj.hxx>
-#include <rtl/ustrbuf.hxx>
#include <vcl/mnemonic.hxx>
#include <osl/mutex.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
// Defines
using namespace css::uno;
using namespace css::lang;
using namespace css::frame;
-using namespace css::beans;
using namespace css::util;
-using namespace std;
-
static bool lcl_I18nCompareString(const OUString& rStr1, const OUString& rStr2)
{
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
@@ -85,19 +80,11 @@ FontMenuController::~FontMenuController()
// private function
void FontMenuController::fillPopupMenu( const Sequence< OUString >& rFontNameSeq, Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
-
SolarMutexGuard aSolarMutexGuard;
resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
-
- if ( !pVCLPopupMenu )
- return;
- vector<OUString> aVector;
+ std::vector<OUString> aVector;
aVector.reserve(rFontNameSeq.getLength());
for ( OUString const & s : rFontNameSeq )
{
@@ -105,7 +92,7 @@ void FontMenuController::fillPopupMenu( const Sequence< OUString >& rFontNameSeq
}
sort(aVector.begin(), aVector.end(), lcl_I18nCompareString );
- const OUString aFontNameCommandPrefix( ".uno:CharFontName?CharFontName.FamilyName:string=" );
+ static constexpr OUStringLiteral aFontNameCommandPrefix( u".uno:CharFontName?CharFontName.FamilyName:string=" );
const sal_Int16 nCount = static_cast<sal_Int16>(aVector.size());
for ( sal_Int16 i = 0; i < nCount; i++ )
{
@@ -113,26 +100,23 @@ void FontMenuController::fillPopupMenu( const Sequence< OUString >& rFontNameSeq
m_xPopupMenu->insertItem( i+1, rName, css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, i );
if ( rName == m_aFontFamilyName )
m_xPopupMenu->checkItem( i+1, true );
- // use VCL popup menu pointer to set vital information that are not part of the awt implementation
- OUStringBuffer aCommandBuffer( aFontNameCommandPrefix );
- aCommandBuffer.append( INetURLObject::encode( rName, INetURLObject::PART_HTTP_QUERY, INetURLObject::EncodeMechanism::All ));
- OUString aFontNameCommand = aCommandBuffer.makeStringAndClear();
- pVCLPopupMenu->SetItemCommand( i+1, aFontNameCommand ); // Store font name into item command.
+ OUString aFontNameCommand = aFontNameCommandPrefix + INetURLObject::encode( rName, INetURLObject::PART_HTTP_QUERY, INetURLObject::EncodeMechanism::All );
+ m_xPopupMenu->setCommand(i + 1, aFontNameCommand); // Store font name into item command.
}
}
// XEventListener
void SAL_CALL FontMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xFontListDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -144,12 +128,12 @@ void SAL_CALL FontMenuController::statusChanged( const FeatureStateEvent& Event
if ( Event.State >>= aFontDescriptor )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_aFontFamilyName = aFontDescriptor.Name;
}
else if ( Event.State >>= aFontNameSeq )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
if ( m_xPopupMenu.is() )
fillPopupMenu( aFontNameSeq, m_xPopupMenu );
}
@@ -158,7 +142,7 @@ void SAL_CALL FontMenuController::statusChanged( const FeatureStateEvent& Event
// XMenuListener
void SAL_CALL FontMenuController::itemActivated( const css::awt::MenuEvent& )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
if ( !m_xPopupMenu.is() )
return;
@@ -178,7 +162,7 @@ void SAL_CALL FontMenuController::itemActivated( const css::awt::MenuEvent& )
// TODO: must be replaced by implementation of VCL, when available
sal_Int32 nIndex = aText.indexOf( '~' );
if ( nIndex >= 0 )
- aText = aText.replaceAt( nIndex, 1, "" );
+ aText = aText.replaceAt( nIndex, 1, u"" );
// TODO: must be replaced by implementation of VCL, when available
if ( aText == m_aFontFamilyName )
@@ -208,12 +192,12 @@ void SAL_CALL FontMenuController::updatePopupMenu()
{
svt::PopupMenuControllerBase::updatePopupMenu();
- osl::ClearableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
Reference< XDispatch > xDispatch( m_xFontListDispatch );
css::util::URL aTargetURL;
aTargetURL.Complete = ".uno:FontNameList";
m_xURLTransformer->parseStrict( aTargetURL );
- aLock.clear();
+ aLock.unlock();
if ( xDispatch.is() )
{
diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx
index a217cc8ff9ed..10234d61cba1 100644
--- a/framework/source/uielement/fontsizemenucontroller.cxx
+++ b/framework/source/uielement/fontsizemenucontroller.cxx
@@ -17,22 +17,24 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
#include <uielement/fontsizemenucontroller.hxx>
#include <services.h>
+#include <com/sun/star/awt/MenuItemStyle.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/view/XPrintable.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/print.hxx>
#include <vcl/settings.hxx>
#include <svtools/ctrltool.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <osl/mutex.hxx>
#include <memory>
#include <cppuhelper/supportsservice.hxx>
@@ -112,7 +114,7 @@ void FontSizeMenuController::setCurHeight( tools::Long nHeight, Reference< css::
{
sal_uInt16 nItemId = rPopupMenu->getItemId( i );
- if ( m_pHeightArray[i] == nHeight )
+ if ( m_aHeightArray[i] == nHeight )
{
rPopupMenu->checkItem( nItemId, true );
return;
@@ -129,15 +131,7 @@ void FontSizeMenuController::setCurHeight( tools::Long nHeight, Reference< css::
// private function
void FontSizeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
-
resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
-
- if ( !pVCLPopupMenu )
- return;
std::unique_ptr<FontList> pFontList;
ScopedVclPtr<Printer> pInfoPrinter;
@@ -150,90 +144,59 @@ void FontSizeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
if ( !aPrinterName.isEmpty() )
{
pInfoPrinter.disposeAndReset(VclPtr<Printer>::Create( aPrinterName ));
- if ( pInfoPrinter && pInfoPrinter->GetDevFontCount() > 0 )
+ if ( pInfoPrinter && pInfoPrinter->GetFontFaceCollectionCount() > 0 )
pFontList.reset(new FontList( pInfoPrinter.get() ));
}
if ( !pFontList )
pFontList.reset(new FontList( Application::GetDefaultDevice() ));
- FontMetric aFontMetric = pFontList->Get( m_aFontDescriptor.Name, m_aFontDescriptor.StyleName );
-
// setup font size array
- m_pHeightArray.reset();
-
- const int* pTempAry;
- const int* pAry = pFontList->GetSizeAry( aFontMetric );
- sal_uInt16 nSizeCount = 0;
- while ( pAry[nSizeCount] )
- nSizeCount++;
+ m_aHeightArray.clear();
- sal_uInt16 nPos = 0;
- const OUString aFontHeightCommand( ".uno:FontHeight?FontHeight.Height:float=" );
+ sal_uInt16 nPos = 0; // Id is nPos+1
+ static constexpr OUString aFontHeightCommand( u".uno:FontHeight?FontHeight.Height:float="_ustr );
// first insert font size names (for simplified/traditional chinese)
- float fPoint;
FontSizeNames aFontSizeNames( Application::GetSettings().GetUILanguageTag().getLanguageType() );
- m_pHeightArray.reset(new tools::Long[nSizeCount + aFontSizeNames.Count()]);
OUString aCommand;
- if ( !aFontSizeNames.IsEmpty() )
+ if (!aFontSizeNames.IsEmpty())
{
- if ( pAry == FontList::GetStdSizeAry() )
- {
- // for scalable fonts all font size names
- sal_Int32 nCount = aFontSizeNames.Count();
- for( sal_Int32 i = 0; i < nCount; i++ )
- {
- OUString aSizeName = aFontSizeNames.GetIndexName( i );
- sal_Int32 nSize = aFontSizeNames.GetIndexSize( i );
- m_pHeightArray[nPos] = nSize;
- nPos++; // Id is nPos+1
- pVCLPopupMenu->InsertItem( nPos, aSizeName, MenuItemBits::RADIOCHECK | MenuItemBits::AUTOCHECK );
- fPoint = float( m_pHeightArray[nPos-1] ) / 10;
-
- // Create dispatchable .uno command and set it
- aCommand = aFontHeightCommand + OUString::number( fPoint );
- pVCLPopupMenu->SetItemCommand( nPos, aCommand );
- }
- }
- else
+ // for scalable fonts all font size names
+ sal_Int32 nCount = aFontSizeNames.Count();
+ for( sal_Int32 i = 0; i < nCount; i++ )
{
- // for fixed size fonts only selectable font size names
- pTempAry = pAry;
- while ( *pTempAry )
- {
- OUString aSizeName = aFontSizeNames.Size2Name( *pTempAry );
- if ( !aSizeName.isEmpty() )
- {
- m_pHeightArray[nPos] = *pTempAry;
- nPos++; // Id is nPos+1
- pVCLPopupMenu->InsertItem( nPos, aSizeName, MenuItemBits::RADIOCHECK | MenuItemBits::AUTOCHECK );
- fPoint = float( m_pHeightArray[nPos-1] ) / 10;
-
- // Create dispatchable .uno command and set it
- aCommand = aFontHeightCommand + OUString::number( fPoint );
- pVCLPopupMenu->SetItemCommand( nPos, aCommand );
- }
- pTempAry++;
- }
+ OUString aSizeName = aFontSizeNames.GetIndexName( i );
+ sal_Int32 nSize = aFontSizeNames.GetIndexSize( i );
+ m_aHeightArray.push_back(nSize);
+ rPopupMenu->insertItem(nPos + 1, aSizeName, css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
+
+ // Create dispatchable .uno command and set it
+ float fPoint = float(nSize) / 10;
+ aCommand = aFontHeightCommand + OUString::number( fPoint );
+ rPopupMenu->setCommand(nPos + 1, aCommand);
+
+ ++nPos;
}
}
// then insert numerical font size values
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
- pTempAry = pAry;
+ const int* pAry = FontList::GetStdSizeAry();
+ const int* pTempAry = pAry;
while ( *pTempAry )
{
- m_pHeightArray[nPos] = *pTempAry;
- nPos++; // Id is nPos+1
- pVCLPopupMenu->InsertItem( nPos, rI18nHelper.GetNum( *pTempAry, 1, true, false ), MenuItemBits::RADIOCHECK | MenuItemBits::AUTOCHECK );
- fPoint = float( m_pHeightArray[nPos-1] ) / 10;
+ m_aHeightArray.push_back(*pTempAry);
+ rPopupMenu->insertItem(nPos + 1, rI18nHelper.GetNum(*pTempAry, 1, true, false),
+ css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
// Create dispatchable .uno command and set it
+ float fPoint = float(*pTempAry) / 10;
aCommand = aFontHeightCommand + OUString::number( fPoint );
- pVCLPopupMenu->SetItemCommand( nPos, aCommand );
+ rPopupMenu->setCommand(nPos + 1, aCommand);
+ ++nPos;
pTempAry++;
}
@@ -243,14 +206,14 @@ void FontSizeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
// XEventListener
void SAL_CALL FontSizeMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xCurrentFontDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -262,16 +225,14 @@ void SAL_CALL FontSizeMenuController::statusChanged( const FeatureStateEvent& Ev
if ( Event.State >>= aFontDescriptor )
{
- osl::MutexGuard aLock( m_aMutex );
- m_aFontDescriptor = aFontDescriptor;
+ std::unique_lock aLock( m_aMutex );
if ( m_xPopupMenu.is() )
fillPopupMenu( m_xPopupMenu );
-
}
else if ( Event.State >>= aFontHeight )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_aFontHeight = aFontHeight;
if ( m_xPopupMenu.is() )
@@ -295,15 +256,15 @@ void FontSizeMenuController::impl_setPopupMenu()
void SAL_CALL FontSizeMenuController::updatePopupMenu()
{
- osl::ClearableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
Reference< XDispatch > xDispatch( m_xCurrentFontDispatch );
css::util::URL aTargetURL;
aTargetURL.Complete = ".uno:CharFontName";
m_xURLTransformer->parseStrict( aTargetURL );
- aLock.clear();
+ aLock.unlock();
if ( xDispatch.is() )
{
diff --git a/framework/source/uielement/footermenucontroller.cxx b/framework/source/uielement/footermenucontroller.cxx
index 9a941a825896..fdd2e17495f8 100644
--- a/framework/source/uielement/footermenucontroller.cxx
+++ b/framework/source/uielement/footermenucontroller.cxx
@@ -27,11 +27,6 @@
// Defines
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
-using namespace com::sun::star::style;
-using namespace com::sun::star::container;
namespace framework
{
diff --git a/framework/source/uielement/genericstatusbarcontroller.cxx b/framework/source/uielement/genericstatusbarcontroller.cxx
index 59515ce1422b..4ee554e43d9c 100644
--- a/framework/source/uielement/genericstatusbarcontroller.cxx
+++ b/framework/source/uielement/genericstatusbarcontroller.cxx
@@ -20,6 +20,7 @@
#include <uielement/genericstatusbarcontroller.hxx>
#include <uielement/statusbarmerger.hxx>
+#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <com/sun/star/ui/ItemStyle.hpp>
@@ -29,10 +30,8 @@
#include <com/sun/star/awt/XGraphics2.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
-using namespace ::cppu;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
namespace framework
@@ -47,7 +46,6 @@ GenericStatusbarController::GenericStatusbarController(
, m_bEnabled( false )
, m_bOwnerDraw( false )
, m_pItemData( pItemData )
- , m_xGraphic()
{
m_xStatusbarItem = rxItem;
if ( m_xStatusbarItem.is() )
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index 31c22d03bbb1..204cbc7cb4d3 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/framework/source/uielement/generictoolbarcontroller.cxx
@@ -26,10 +26,13 @@
#include <com/sun/star/frame/status/Visibility.hpp>
#include <com/sun/star/frame/ControlCommand.hpp>
+#include <comphelper/propertyvalue.hxx>
+#include <svl/imageitm.hxx>
+#include <vcl/commandinfoprovider.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/toolbox.hxx>
#include <vcl/weld.hxx>
#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <strings.hrc>
#include <classes/fwkresid.hxx>
@@ -42,7 +45,7 @@ using namespace ::com::sun::star::frame::status;
namespace framework
{
-static bool isEnumCommand( const OUString& rCommand )
+static bool isEnumCommand( std::u16string_view rCommand )
{
INetURLObject aURL( rCommand );
@@ -50,7 +53,7 @@ static bool isEnumCommand( const OUString& rCommand )
( aURL.GetURLPath().indexOf( '.' ) != -1);
}
-static OUString getEnumCommand( const OUString& rCommand )
+static OUString getEnumCommand( std::u16string_view rCommand )
{
INetURLObject aURL( rCommand );
@@ -72,7 +75,7 @@ static OUString getMasterCommand( const OUString& rCommand )
sal_Int32 nIndex = aURL.GetURLPath().indexOf( '.' );
if ( nIndex )
{
- aURL.SetURLPath( aURL.GetURLPath().copy( 0, nIndex ) );
+ aURL.SetURLPath( aURL.GetURLPath().subView( 0, nIndex ) );
aMasterCommand = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
}
@@ -82,12 +85,13 @@ static OUString getMasterCommand( const OUString& rCommand )
GenericToolbarController::GenericToolbarController( const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
const OUString& aCommand ) :
svt::ToolboxController( rxContext, rFrame, aCommand )
, m_xToolbar( pToolbar )
, m_nID( nID )
, m_bEnumCommand( isEnumCommand( aCommand ))
+ , m_bMirrored( false )
, m_bMadeInvisible( false )
, m_aEnumCommand( getEnumCommand( aCommand ))
{
@@ -104,7 +108,7 @@ GenericToolbarController::GenericToolbarController( const Reference< XComponentC
const Reference< XFrame >& rFrame,
weld::Toolbar& rToolbar,
const OUString& aCommand ) :
- GenericToolbarController( rxContext, rFrame, nullptr, 0, aCommand )
+ GenericToolbarController( rxContext, rFrame, nullptr, ToolBoxItemId(0), aCommand )
{
m_pToolbar = &rToolbar;
}
@@ -121,7 +125,7 @@ void SAL_CALL GenericToolbarController::dispose()
m_pToolbar = nullptr;
m_xToolbar.clear();
- m_nID = 0;
+ m_nID = ToolBoxItemId(0);
}
void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier )
@@ -150,13 +154,13 @@ void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier )
return;
css::util::URL aTargetURL;
- Sequence<PropertyValue> aArgs( 1 );
- // Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
+ // handle also command aliases
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(m_aCommandURL,
+ vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
+ OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties);
- aTargetURL.Complete = aCommandURL;
+ aTargetURL.Complete = sRealCommand.isEmpty() ? aCommandURL : sRealCommand;
if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aTargetURL );
@@ -164,7 +168,9 @@ void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier )
ExecuteInfo* pExecuteInfo = new ExecuteInfo;
pExecuteInfo->xDispatch = xDispatch;
pExecuteInfo->aTargetURL = aTargetURL;
- pExecuteInfo->aArgs = aArgs;
+ // Add key modifier to argument list
+ pExecuteInfo->aArgs = { comphelper::makePropertyValue("KeyModifier", KeyModifier) };
+
Application::PostUserEvent( LINK(nullptr, GenericToolbarController , ExecuteHdl_Impl), pExecuteInfo );
}
@@ -177,24 +183,30 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
if ( m_pToolbar )
{
- OString sId = m_aCommandURL.toUtf8();
-
- m_pToolbar->set_item_sensitive(sId, Event.IsEnabled);
+ m_pToolbar->set_item_sensitive(m_aCommandURL, Event.IsEnabled);
bool bValue;
OUString aStrValue;
+ SfxImageItem aImageItem;
if ( Event.State >>= bValue )
{
// Boolean, treat it as checked/unchecked
- m_pToolbar->set_item_active(sId, bValue);
+ m_pToolbar->set_item_active(m_aCommandURL, bValue);
}
else if ( Event.State >>= aStrValue )
{
- m_pToolbar->set_item_label(sId, aStrValue);
+ m_pToolbar->set_item_label(m_aCommandURL, aStrValue);
+ }
+ else if ( aImageItem.PutValue( Event.State, 0 ) && aImageItem.IsMirrored() != m_bMirrored )
+ {
+ m_pToolbar->set_item_image_mirrored(m_aCommandURL, aImageItem.IsMirrored());
+ auto xGraphic(vcl::CommandInfoProvider::GetXGraphicForCommand(m_aCommandURL, m_xFrame, m_pToolbar->get_icon_size()));
+ m_pToolbar->set_item_image(m_aCommandURL, xGraphic);
+ m_bMirrored = !m_bMirrored;
}
else
- m_pToolbar->set_item_active(sId, false);
+ m_pToolbar->set_item_active(m_aCommandURL, false);
return;
}
@@ -213,6 +225,7 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
ItemStatus aItemState;
Visibility aItemVisibility;
ControlCommand aControlCommand;
+ SfxImageItem aImageItem;
if (( Event.State >>= bValue ) && !m_bEnumCommand )
{
@@ -274,7 +287,7 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
{
if (aControlCommand.Command == "SetQuickHelpText")
{
- for ( NamedValue const & rArg : std::as_const(aControlCommand.Arguments) )
+ for (NamedValue const& rArg : aControlCommand.Arguments)
{
if (rArg.Name == "HelpText")
{
@@ -288,6 +301,15 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
if ( m_bMadeInvisible )
m_xToolbar->ShowItem( m_nID );
}
+ else if ( aImageItem.PutValue( Event.State, 0 ) && aImageItem.IsMirrored() != m_bMirrored )
+ {
+ m_xToolbar->SetItemImageMirrorMode( m_nID, aImageItem.IsMirrored() );
+ Image aImage( vcl::CommandInfoProvider::GetImageForCommand( m_aCommandURL, m_xFrame, m_xToolbar->GetImageSize() ));
+ m_xToolbar->SetItemImage( m_nID, aImage );
+ m_bMirrored = !m_bMirrored;
+ if ( m_bMadeInvisible )
+ m_xToolbar->ShowItem( m_nID );
+ }
else if ( m_bMadeInvisible )
m_xToolbar->ShowItem( m_nID );
@@ -313,6 +335,99 @@ IMPL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, void*, p, void )
delete pExecuteInfo;
}
+ImageOrientationController::ImageOrientationController(const Reference<XComponentContext>& rContext,
+ const Reference<XFrame>& rFrame,
+ const Reference<css::awt::XWindow>& rParentWindow,
+ const OUString& rModuleName)
+ : ToolboxController(rContext, rFrame, ".uno:ImageOrientation")
+ , m_nRotationAngle(0_deg10)
+ , m_bMirrored(false)
+{
+ m_sModuleName = rModuleName;
+ m_xParentWindow = rParentWindow;
+ initialize({});
+ if (!m_pToolbar)
+ VCLUnoHelper::GetWindow(getParent())->AddEventListener(LINK(this, ImageOrientationController, WindowEventListener));
+}
+
+void ImageOrientationController::dispose()
+{
+ ToolboxController::dispose();
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(getParent());
+ if (pWindow)
+ pWindow->RemoveEventListener(LINK(this, ImageOrientationController, WindowEventListener));
+}
+
+IMPL_LINK(ImageOrientationController, WindowEventListener, VclWindowEvent&, rWindowEvent, void)
+{
+ if (m_bDisposed || rWindowEvent.GetId() != VclEventId::ToolboxItemAdded)
+ return;
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(rWindowEvent.GetWindow());
+ ToolBoxItemId nItemId = pToolBox->GetItemId(reinterpret_cast<sal_IntPtr>(rWindowEvent.GetData()));
+ OUString aCommand = pToolBox->GetItemCommand(nItemId);
+
+ if (vcl::CommandInfoProvider::IsMirrored(aCommand, getModuleName()))
+ pToolBox->SetItemImageMirrorMode(nItemId, m_bMirrored);
+ if (vcl::CommandInfoProvider::IsRotated(aCommand, getModuleName()))
+ pToolBox->SetItemImageAngle(nItemId, m_nRotationAngle);
+}
+
+void ImageOrientationController::statusChanged(const css::frame::FeatureStateEvent& rEvent)
+{
+ if (m_bDisposed)
+ throw DisposedException();
+
+ SfxImageItem aItem;
+ aItem.PutValue(rEvent.State, 0);
+
+ if (m_bMirrored == aItem.IsMirrored() && m_nRotationAngle == aItem.GetRotation())
+ return;
+
+ m_bMirrored = aItem.IsMirrored();
+ m_nRotationAngle = aItem.GetRotation();
+
+ if (m_pToolbar)
+ {
+ for (int i = 0, nCount = m_pToolbar->get_n_items(); i < nCount; ++i)
+ {
+ OUString aCommand = m_pToolbar->get_item_ident(i);
+ if (vcl::CommandInfoProvider::IsMirrored(aCommand, getModuleName()))
+ {
+ m_pToolbar->set_item_image_mirrored(aCommand, m_bMirrored);
+ auto xGraphic(vcl::CommandInfoProvider::GetXGraphicForCommand(
+ aCommand, m_xFrame, m_pToolbar->get_icon_size()));
+ m_pToolbar->set_item_image(aCommand, xGraphic);
+ }
+ }
+ }
+ else
+ {
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ for (ToolBox::ImplToolItems::size_type i = 0; i < pToolBox->GetItemCount(); ++i)
+ {
+ ToolBoxItemId nItemId = pToolBox->GetItemId(i);
+ OUString aCommand = pToolBox->GetItemCommand(nItemId);
+ bool bModified = false;
+ if (vcl::CommandInfoProvider::IsMirrored(aCommand, getModuleName()))
+ {
+ pToolBox->SetItemImageMirrorMode(nItemId, m_bMirrored);
+ bModified = true;
+ }
+ if (vcl::CommandInfoProvider::IsRotated(aCommand, getModuleName()))
+ {
+ pToolBox->SetItemImageAngle(nItemId, m_nRotationAngle);
+ bModified = true;
+ }
+ if (bModified)
+ {
+ Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommand, m_xFrame, pToolBox->GetImageSize()));
+ pToolBox->SetItemImage(nItemId, aImage);
+ }
+ }
+ }
+}
+
} // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uielement/headermenucontroller.cxx b/framework/source/uielement/headermenucontroller.cxx
index 6a049994852f..1eb34720d60a 100644
--- a/framework/source/uielement/headermenucontroller.cxx
+++ b/framework/source/uielement/headermenucontroller.cxx
@@ -24,16 +24,16 @@
#include <strings.hrc>
#include <classes/fwkresid.hxx>
+#include <com/sun/star/awt/MenuItemStyle.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/mutex.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
// Defines
@@ -41,7 +41,6 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
using namespace com::sun::star::style;
using namespace com::sun::star::container;
@@ -80,17 +79,12 @@ HeaderMenuController::~HeaderMenuController()
// private function
void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >& rModel, Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
-
SolarMutexGuard aSolarMutexGuard;
resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
Reference< XStyleFamiliesSupplier > xStyleFamiliesSupplier( rModel, UNO_QUERY );
- if ( !(pVCLPopupMenu && xStyleFamiliesSupplier.is()))
+ if (!xStyleFamiliesSupplier.is())
return;
Reference< XNameAccess > xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
@@ -102,8 +96,8 @@ void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >&
aCmd = ".uno:InsertPageFooter";
aHeaderFooterIsOnStr = "FooterIsOn";
}
- const OUString aIsPhysicalStr( "IsPhysical" );
- const OUString aDisplayNameStr( "DisplayName" );
+ static constexpr OUStringLiteral aIsPhysicalStr( u"IsPhysical" );
+ static constexpr OUStringLiteral aDisplayNameStr( u"DisplayName" );
try
{
@@ -132,26 +126,24 @@ void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >&
xPropSet->getPropertyValue( aDisplayNameStr ) >>= aDisplayName;
xPropSet->getPropertyValue( aHeaderFooterIsOnStr ) >>= bHeaderIsOn;
- OUStringBuffer aStrBuf( aCmd );
- aStrBuf.append( "?PageStyle:string=");
- aStrBuf.append( aDisplayName );
- aStrBuf.append( "&On:bool=" );
+ OUStringBuffer aStrBuf( aCmd
+ + "?PageStyle:string="
+ + aDisplayName
+ + "&On:bool=" );
if ( !bHeaderIsOn )
aStrBuf.append( "true" );
else
aStrBuf.append( "false" );
OUString aCommand( aStrBuf.makeStringAndClear() );
- pVCLPopupMenu->InsertItem( nId, aDisplayName, MenuItemBits::CHECKABLE );
+ rPopupMenu->insertItem(nId, aDisplayName, css::awt::MenuItemStyle::CHECKABLE, nCount);
if ( !bFirstItemInserted )
{
bFirstItemInserted = true;
bFirstChecked = bHeaderIsOn;
}
- pVCLPopupMenu->SetItemCommand( nId, aCommand );
-
- if ( bHeaderIsOn )
- pVCLPopupMenu->CheckItem( nId );
+ rPopupMenu->setCommand(nId, aCommand);
+ rPopupMenu->checkItem(nId, bHeaderIsOn);
++nId;
// Check if all entries have the same state
@@ -166,10 +158,9 @@ void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >&
if ( bAllOneState && ( nCount > 1 ))
{
// Insert special item for all command
- pVCLPopupMenu->InsertItem( ALL_MENUITEM_ID, FwkResId(STR_MENU_HEADFOOTALL), MenuItemBits::NONE, OString(), 0 );
+ rPopupMenu->insertItem(ALL_MENUITEM_ID, FwkResId(STR_MENU_HEADFOOTALL), 0, 0);
- OUStringBuffer aStrBuf( aCmd );
- aStrBuf.append( "?On:bool=" );
+ OUStringBuffer aStrBuf( aCmd + "?On:bool=" );
// Command depends on check state of first menu item entry
if ( !bFirstChecked )
@@ -177,8 +168,8 @@ void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >&
else
aStrBuf.append( "false" );
- pVCLPopupMenu->SetItemCommand( 1, aStrBuf.makeStringAndClear() );
- pVCLPopupMenu->InsertSeparator(OString(), 1);
+ rPopupMenu->setCommand(1, aStrBuf.makeStringAndClear());
+ rPopupMenu->insertSeparator(1);
}
}
}
@@ -190,14 +181,14 @@ void HeaderMenuController::fillPopupMenu( const Reference< css::frame::XModel >&
// XEventListener
void SAL_CALL HeaderMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -208,7 +199,7 @@ void SAL_CALL HeaderMenuController::statusChanged( const FeatureStateEvent& Even
if ( Event.State >>= xModel )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xModel = xModel;
if ( m_xPopupMenu.is() )
fillPopupMenu( xModel, m_xPopupMenu );
@@ -218,17 +209,17 @@ void SAL_CALL HeaderMenuController::statusChanged( const FeatureStateEvent& Even
// XMenuListener
void SAL_CALL HeaderMenuController::updatePopupMenu()
{
- osl::ResettableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
Reference< css::frame::XModel > xModel( m_xModel );
- aLock.clear();
+ aLock.unlock();
if ( !xModel.is() )
svt::PopupMenuControllerBase::updatePopupMenu();
- aLock.reset();
+ aLock.lock();
if ( m_xPopupMenu.is() && m_xModel.is() )
fillPopupMenu( m_xModel, m_xPopupMenu );
}
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index 19107d374019..87f7407685b6 100644
--- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
@@ -34,12 +34,9 @@
#include <memory>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
const ::Size aImageSizeSmall( 16, 16 );
const ::Size aImageSizeBig( 26, 26 );
@@ -57,11 +54,11 @@ ImageButtonToolbarController::ImageButtonToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
{
- bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
+ bool bBigImages( SvtMiscOptions::AreCurrentSymbolsLarge() );
Image aImage(AddonsOptions().GetImageFromURL(aCommand, bBigImages, true));
@@ -97,14 +94,14 @@ void ImageButtonToolbarController::executeControlCommand( const css::frame::Cont
SubstituteVariables( aURL );
Image aImage;
- if ( ReadImageFromURL( SvtMiscOptions().AreCurrentSymbolsLarge(),
+ if ( ReadImageFromURL( SvtMiscOptions::AreCurrentSymbolsLarge(),
aURL,
aImage ))
{
m_xToolbar->SetItemImage( m_nID, aImage );
// send notification
- uno::Sequence< beans::NamedValue > aInfo { { "URL", css::uno::makeAny(aURL) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "URL", css::uno::Any(aURL) } };
addNotifyInfo( "ImageChanged",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
@@ -114,30 +111,31 @@ void ImageButtonToolbarController::executeControlCommand( const css::frame::Cont
}
}
+// static
bool ImageButtonToolbarController::ReadImageFromURL( bool bBigImage, const OUString& aImageURL, Image& aImage )
{
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream( aImageURL, StreamMode::STD_READ ));
- if ( pStream && ( pStream->GetErrorCode() == ERRCODE_NONE ))
- {
- // Use graphic class to also support more graphic formats (bmp,png,...)
- Graphic aGraphic;
+ if ( !pStream || ( pStream->GetErrorCode() != ERRCODE_NONE ))
+ return false;
- GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
- rGF.ImportGraphic( aGraphic, OUString(), *pStream );
+ // Use graphic class to also support more graphic formats (bmp,png,...)
+ Graphic aGraphic;
- BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
+ GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
+ rGF.ImportGraphic( aGraphic, u"", *pStream );
- const ::Size aSize = bBigImage ? aImageSizeBig : aImageSizeSmall; // Sizes used for toolbar images
+ BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
- ::Size aBmpSize = aBitmapEx.GetSizePixel();
- if ( !aBmpSize.IsEmpty() )
- {
- ::Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
- if ( aBmpSize != aNoScaleSize )
- aBitmapEx.Scale( aNoScaleSize, BmpScaleFlag::BestQuality );
- aImage = Image( aBitmapEx );
- return true;
- }
+ const ::Size aSize = bBigImage ? aImageSizeBig : aImageSizeSmall; // Sizes used for toolbar images
+
+ ::Size aBmpSize = aBitmapEx.GetSizePixel();
+ if ( !aBmpSize.IsEmpty() )
+ {
+ ::Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
+ if ( aBmpSize != aNoScaleSize )
+ aBitmapEx.Scale( aNoScaleSize, BmpScaleFlag::BestQuality );
+ aImage = Image( aBitmapEx );
+ return true;
}
return false;
diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx
index d19bf519a28e..cd1700518f3b 100644
--- a/framework/source/uielement/langselectionmenucontroller.cxx
+++ b/framework/source/uielement/langselectionmenucontroller.cxx
@@ -21,15 +21,15 @@
#include <services.h>
+#include <com/sun/star/awt/MenuItemStyle.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <svl/languageoptions.hxx>
#include <svtools/langtab.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <classes/fwkresid.hxx>
#include <strings.hrc>
@@ -47,7 +47,6 @@ using namespace ::com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
-using namespace com::sun::star::beans;
using namespace com::sun::star::util;
namespace framework
@@ -86,15 +85,15 @@ LanguageSelectionMenuController::~LanguageSelectionMenuController()
// XEventListener
void SAL_CALL LanguageSelectionMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xLanguageDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -103,7 +102,7 @@ void SAL_CALL LanguageSelectionMenuController::statusChanged( const FeatureState
{
SolarMutexGuard aSolarMutexGuard;
- if (rBHelper.bDisposed || rBHelper.bInDispose)
+ if (m_bDisposed)
return;
m_bShowMenu = true;
@@ -159,18 +158,12 @@ void LanguageSelectionMenuController::impl_setPopupMenu()
void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu , const Mode eMode )
{
- VCLXPopupMenu* pVCLPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pPopupMenu = nullptr;
-
SolarMutexGuard aSolarMutexGuard;
resetPopupMenu( rPopupMenu );
if (!m_bShowMenu)
return;
- if ( pVCLPopupMenu )
- pPopupMenu = static_cast<PopupMenu *>(pVCLPopupMenu->GetMenu());
-
OUString aCmd_Dialog;
OUString aCmd_Language;
if( eMode == MODE_SetLanguageSelectionMenu )
@@ -197,9 +190,8 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup
// now add menu entries
// the different menus purpose will be handled by the different string
// for aCmd_Dialog and aCmd_Language
-
- sal_Int16 nItemId = 1; // in this control the item id is not important for executing the command
- const OUString sAsterisk("*"); // multiple languages in current selection
+ sal_Int16 nItemId = 0; // in this control the item id is not important for executing the command
+ static constexpr OUStringLiteral sAsterisk(u"*"); // multiple languages in current selection
const OUString sNone( SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ));
for (auto const& langItem : aLangItems)
{
@@ -207,34 +199,32 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup
langItem != sAsterisk &&
!langItem.isEmpty()) // 'no language found' from language guessing
{
- pPopupMenu->InsertItem( nItemId, langItem);
- OUString aCmd = aCmd_Language + langItem;
- pPopupMenu->SetItemCommand( nItemId, aCmd );
- if (langItem == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu )
- {
- //make a sign for the current language
- pPopupMenu->CheckItem( nItemId );
- }
++nItemId;
+ rPopupMenu->insertItem(nItemId, langItem, css::awt::MenuItemStyle::CHECKABLE, nItemId - 1);
+ OUString aCmd = aCmd_Language + langItem;
+ rPopupMenu->setCommand(nItemId, aCmd);
+ bool bChecked = langItem == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu;
+ //make a sign for the current language
+ rPopupMenu->checkItem(nItemId, bChecked);
}
}
// entry for LANGUAGE_NONE
++nItemId;
- pPopupMenu->InsertItem( nItemId, FwkResId(STR_LANGSTATUS_NONE) );
+ rPopupMenu->insertItem(nItemId, FwkResId(STR_LANGSTATUS_NONE), 0, nItemId - 1);
OUString aCmd = aCmd_Language + "LANGUAGE_NONE";
- pPopupMenu->SetItemCommand( nItemId, aCmd );
+ rPopupMenu->setCommand(nItemId, aCmd);
// entry for 'Reset to default language'
++nItemId;
- pPopupMenu->InsertItem( nItemId, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE) );
+ rPopupMenu->insertItem(nItemId, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, nItemId - 1);
aCmd = aCmd_Language + "RESET_LANGUAGES";
- pPopupMenu->SetItemCommand( nItemId, aCmd );
+ rPopupMenu->setCommand(nItemId, aCmd);
// entry for opening the Format/Character dialog
++nItemId;
- pPopupMenu->InsertItem( nItemId, FwkResId(STR_LANGSTATUS_MORE));
- pPopupMenu->SetItemCommand( nItemId, aCmd_Dialog );
+ rPopupMenu->insertItem(nItemId, FwkResId(STR_LANGSTATUS_MORE), 0, nItemId - 1);
+ rPopupMenu->setCommand(nItemId, aCmd_Dialog);
}
void SAL_CALL LanguageSelectionMenuController::updatePopupMenu()
@@ -242,12 +232,12 @@ void SAL_CALL LanguageSelectionMenuController::updatePopupMenu()
svt::PopupMenuControllerBase::updatePopupMenu();
// Force status update to get information about the current languages
- osl::ClearableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
Reference< XDispatch > xDispatch( m_xLanguageDispatch );
css::util::URL aTargetURL;
aTargetURL.Complete = m_aLangStatusCommandURL;
m_xURLTransformer->parseStrict( aTargetURL );
- aLock.clear();
+ aLock.unlock();
if ( xDispatch.is() )
{
@@ -272,14 +262,12 @@ void SAL_CALL LanguageSelectionMenuController::updatePopupMenu()
}
// XInitialization
-void SAL_CALL LanguageSelectionMenuController::initialize( const Sequence< Any >& aArguments )
+void LanguageSelectionMenuController::initializeImpl( std::unique_lock<std::mutex>& rGuard, const Sequence< Any >& aArguments )
{
- osl::MutexGuard aLock( m_aMutex );
-
- bool bInitalized( m_bInitialized );
- if ( !bInitalized )
+ bool bInitialized( m_bInitialized );
+ if ( !bInitialized )
{
- svt::PopupMenuControllerBase::initialize(aArguments);
+ svt::PopupMenuControllerBase::initializeImpl(rGuard, aArguments);
if ( m_bInitialized )
{
diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx
index 2e12c12fee26..3ae0799041e8 100644
--- a/framework/source/uielement/langselectionstatusbarcontroller.cxx
+++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx
@@ -51,8 +51,6 @@ using namespace ::com::sun::star;
using namespace css::uno;
using namespace css::lang;
using namespace css::frame;
-using namespace css::i18n;
-using namespace css::document;
using namespace framework;
namespace {
@@ -120,6 +118,7 @@ void LangSelectionStatusbarController::LangMenu(
return;
const Reference<XServiceInfo> xService(m_xFrame->getController()->getModel(), UNO_QUERY);
+ bool bCalc = xService.is() && xService->supportsService("com.sun.star.sheet.SpreadsheetDocument");
bool bWriter = xService.is() && xService->supportsService("com.sun.star.text.GenericTextDocument");
//add context menu
Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) );
@@ -133,7 +132,7 @@ void LangSelectionStatusbarController::LangMenu(
// add first few entries to main menu
sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1);
- const OUString sAsterisk("*"); // multiple languages in current selection
+ static constexpr OUString sAsterisk(u"*"_ustr); // multiple languages in current selection
const OUString sNone( SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ));
std::map< sal_Int16, OUString > aLangMap;
for (auto const& langItem : aLangItems)
@@ -189,7 +188,10 @@ void LangSelectionStatusbarController::LangMenu(
}
else
{
- xPopupMenu->insertItem( MID_LANG_DEF_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_DEF_NONE );
+ if (bCalc)
+ xPopupMenu->insertItem( MID_LANG_SEL_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_SEL_NONE );
+ else
+ xPopupMenu->insertItem( MID_LANG_DEF_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_DEF_NONE );
if ( sNone == m_aCurLang )
xPopupMenu->checkItem( MID_LANG_DEF_NONE, true );
xPopupMenu->insertItem( MID_LANG_DEF_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_DEF_RESET );
@@ -211,7 +213,7 @@ void LangSelectionStatusbarController::LangMenu(
if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
{
- if (bWriter)
+ if (bWriter || bCalc)
aBuff.append( ".uno:LanguageStatus?Language:string=Current_" );
else
aBuff.append( ".uno:LanguageStatus?Language:string=Default_" );
@@ -247,8 +249,7 @@ void LangSelectionStatusbarController::LangMenu(
}
else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
{
- aBuff.append( ".uno:LanguageStatus?Language:string=Paragraph_" );
- aBuff.append( aSelectedLang );
+ aBuff.append( ".uno:LanguageStatus?Language:string=Paragraph_" + aSelectedLang );
}
else if (nId == MID_LANG_PARA_NONE)
{
@@ -315,6 +316,7 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat
if ( Event.State >>= aStrValue )
{
m_xStatusbarItem->setText( aStrValue );
+ m_xStatusbarItem->setQuickHelpText(FwkResId(STR_LANGSTATUS_HINT));
m_aCurLang = aStrValue;
}
else if ( Event.State >>= aSeq )
@@ -327,6 +329,7 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat
aStatusText = FwkResId(STR_LANGSTATUS_MULTIPLE_LANGUAGES);
}
m_xStatusbarItem->setText( aStatusText );
+ m_xStatusbarItem->setQuickHelpText(FwkResId(STR_LANGSTATUS_HINT));
// Retrieve all other values from the sequence and
// store it members!
@@ -339,6 +342,7 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat
else if ( !Event.State.hasValue() )
{
m_xStatusbarItem->setText( OUString() );
+ m_xStatusbarItem->setQuickHelpText(u""_ustr);
m_bShowMenu = false; // no language -> no menu
}
}
diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx
index 0549ff3a0299..77f077204373 100644
--- a/framework/source/uielement/macrosmenucontroller.cxx
+++ b/framework/source/uielement/macrosmenucontroller.cxx
@@ -23,18 +23,15 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <officecfg/Office/Common.hxx>
-#include <toolkit/awt/vclxmenu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <osl/mutex.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/supportsservice.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
-using namespace com::sun::star::style;
using namespace com::sun::star::container;
namespace framework
@@ -74,42 +71,35 @@ void MacrosMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > cons
if (bMacrosDisabled)
return;
- VCLXPopupMenu* pVCLPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pPopupMenu = nullptr;
-
SolarMutexGuard aSolarMutexGuard;
- resetPopupMenu( rPopupMenu );
- if ( pVCLPopupMenu )
- pPopupMenu = static_cast<PopupMenu *>(pVCLPopupMenu->GetMenu());
-
- if (!pPopupMenu)
- return;
+ resetPopupMenu(rPopupMenu);
+ assert(rPopupMenu->getItemCount() == 0);
// insert basic
OUString aCommand(".uno:MacroDialog");
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommand, m_aModuleName);
OUString aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand(aProperties);
- pPopupMenu->InsertItem( 2, aDisplayName );
- pPopupMenu->SetItemCommand( 2, aCommand );
+ rPopupMenu->insertItem(2, aDisplayName, 0, 0);
+ rPopupMenu->setCommand(2, aCommand);
// insert providers but not basic or java
- addScriptItems( pPopupMenu, 4);
+ addScriptItems(rPopupMenu, 4);
}
// XEventListener
void SAL_CALL MacrosMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xContext.clear();
if ( m_xPopupMenu.is() )
{
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
}
m_xPopupMenu.clear();
}
@@ -117,22 +107,24 @@ void SAL_CALL MacrosMenuController::disposing( const EventObject& )
// XStatusListener
void SAL_CALL MacrosMenuController::statusChanged( const FeatureStateEvent& )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
if ( m_xPopupMenu.is() )
{
fillPopupMenu( m_xPopupMenu );
}
}
-void MacrosMenuController::addScriptItems( PopupMenu* pPopupMenu, sal_uInt16 startItemId )
+void MacrosMenuController::addScriptItems(const Reference<css::awt::XPopupMenu>& rPopupMenu, sal_uInt16 startItemId)
{
- const OUString aCmdBase(".uno:ScriptOrganizer?ScriptOrganizer.Language:string=");
- const OUString ellipsis( "..." );
- const OUString providerKey("com.sun.star.script.provider.ScriptProviderFor");
+ static constexpr OUStringLiteral aCmdBase(u".uno:ScriptOrganizer?ScriptOrganizer.Language:string=");
+ static constexpr OUStringLiteral ellipsis( u"..." );
+ static constexpr OUString providerKey(u"com.sun.star.script.provider.ScriptProviderFor"_ustr);
sal_uInt16 itemId = startItemId;
Reference< XContentEnumerationAccess > xEnumAccess( m_xContext->getServiceManager(), UNO_QUERY_THROW );
Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration ( "com.sun.star.script.provider.LanguageScriptProvider" );
+ sal_Int16 nPos = rPopupMenu->getItemCount();
+
while ( xEnum->hasMoreElements() )
{
Reference< XServiceInfo > xServiceInfo;
@@ -155,8 +147,8 @@ void MacrosMenuController::addScriptItems( PopupMenu* pPopupMenu, sal_uInt16 sta
}
aCommand += aDisplayName;
aDisplayName += ellipsis;
- pPopupMenu->InsertItem( itemId, aDisplayName );
- pPopupMenu->SetItemCommand( itemId, aCommand );
+ rPopupMenu->insertItem(itemId, aDisplayName, 0, nPos++);
+ rPopupMenu->setCommand(itemId, aCommand);
itemId++;
break;
}
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index b2d1f7cbd372..95e17053d3fb 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -42,12 +42,13 @@
#include <com/sun/star/util/URLTransformer.hpp>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <officecfg/Office/Common.hxx>
-#include <svtools/menuoptions.hxx>
#include <svtools/javainteractionhandler.hxx>
#include <uno/current_context.hxx>
#include <unotools/cmdoptions.hxx>
#include <toolkit/awt/vclxmenu.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/menu.hxx>
@@ -75,10 +76,10 @@ const sal_uInt16 ITEMID_ADDONLIST = 6678; // used to be a SID in sfx
namespace framework
{
-#define aCmdHelpIndex ".uno:HelpIndex"
-#define aCmdToolsMenu ".uno:ToolsMenu"
-#define aCmdHelpMenu ".uno:HelpMenu"
-#define aSpecialWindowCommand ".uno:WindowList"
+constexpr OUString aCmdHelpIndex = u".uno:HelpIndex"_ustr;
+constexpr OUStringLiteral aCmdToolsMenu = u".uno:ToolsMenu";
+constexpr OUStringLiteral aCmdHelpMenu = u".uno:HelpMenu";
+constexpr OUStringLiteral aSpecialWindowCommand = u".uno:WindowList";
MenuBarManager::MenuBarManager(
const Reference< XComponentContext >& rxContext,
@@ -87,15 +88,14 @@ MenuBarManager::MenuBarManager(
const Reference< XDispatchProvider >& rDispatchProvider,
const OUString& rModuleIdentifier,
Menu* pMenu, bool bDelete, bool bHasMenuBar ):
- WeakComponentImplHelper( m_aMutex )
- , m_bRetrieveImages( false )
+ m_bRetrieveImages( false )
, m_bAcceleratorCfg( false )
, m_bHasMenuBar( bHasMenuBar )
, m_xContext(rxContext)
, m_xURLTransformer(_xURLTransformer)
- , m_sIconTheme( SvtMiscOptions().GetIconTheme() )
+ , m_sIconTheme( SvtMiscOptions::GetIconTheme() )
+ , m_aAsyncSettingsTimer( "framework::MenuBarManager::Deactivate m_aAsyncSettingsTimer" )
{
- m_aAsyncSettingsTimer.SetDebugName( "framework::MenuBarManager::Deactivate m_aAsyncSettingsTimer" );
m_xPopupMenuControllerFactory = frame::thePopupMenuControllerFactory::get(m_xContext);
FillMenuManager( pMenu, rFrame, rDispatchProvider, rModuleIdentifier, bDelete );
}
@@ -104,7 +104,7 @@ Any SAL_CALL MenuBarManager::getMenuHandle( const Sequence< sal_Int8 >& /*Proces
{
SolarMutexGuard aSolarGuard;
- if ( rBHelper.bDisposed || rBHelper.bInDispose )
+ if ( m_bDisposed )
throw css::lang::DisposedException();
Any a;
@@ -137,12 +137,12 @@ MenuBarManager::~MenuBarManager()
SAL_WARN_IF( OWeakObject::m_refCount != 0, "fwk.uielement", "Who wants to delete an object with refcount > 0!" );
}
-void MenuBarManager::Destroy()
+// XComponent
+void MenuBarManager::disposing(std::unique_lock<std::mutex>& )
{
- SolarMutexGuard aGuard;
+ Reference< XComponent > xThis( this );
- if ( rBHelper.bDisposed )
- return;
+ SolarMutexGuard g;
// stop asynchronous settings timer and
// release deferred item container reference
@@ -156,23 +156,13 @@ void MenuBarManager::Destroy()
{
m_pVCLMenu.disposeAndClear();
}
-}
-
-// XComponent
-void SAL_CALL MenuBarManager::disposing()
-{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
-
- SolarMutexGuard g;
- Destroy();
if ( m_xDocImageManager.is() )
{
try
{
m_xDocImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch ( const Exception& )
{
@@ -183,8 +173,7 @@ void SAL_CALL MenuBarManager::disposing()
try
{
m_xModuleImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch ( const Exception& )
{
@@ -204,7 +193,7 @@ void SAL_CALL MenuBarManager::elementInserted( const css::ui::ConfigurationEvent
SolarMutexGuard g;
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( rBHelper.bDisposed || rBHelper.bInDispose )
+ if ( m_bDisposed )
return;
sal_Int16 nImageType = sal_Int16();
@@ -227,7 +216,7 @@ void SAL_CALL MenuBarManager::frameAction( const FrameActionEvent& Action )
{
SolarMutexGuard g;
- if ( rBHelper.bDisposed || rBHelper.bInDispose )
+ if ( m_bDisposed )
throw css::lang::DisposedException();
if ( Action.Action != FrameAction_CONTEXT_CHANGED )
@@ -255,7 +244,7 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
SolarMutexGuard aSolarGuard;
{
- if ( rBHelper.bDisposed || rBHelper.bInDispose )
+ if ( m_bDisposed )
return;
// We have to check all menu entries as there can be identical entries in a popup menu.
@@ -387,10 +376,7 @@ void MenuBarManager::RequestImages()
for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
{
if ( menuItemHandler->xSubMenuManager.is() )
- {
- MenuBarManager* pMenuBarManager = static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
- pMenuBarManager->RequestImages();
- }
+ menuItemHandler->xSubMenuManager->RequestImages();
}
}
@@ -450,16 +436,14 @@ void MenuBarManager::RemoveListener()
menuItemHandler->xPopupMenu.clear();
}
- Reference< XComponent > xComponent( menuItemHandler->xSubMenuManager, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
+ if ( menuItemHandler->xSubMenuManager )
+ menuItemHandler->xSubMenuManager->dispose();
}
try
{
if ( m_xFrame.is() )
- m_xFrame->removeFrameActionListener( Reference< XFrameActionListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xFrame->removeFrameActionListener( Reference< XFrameActionListener >(this) );
}
catch ( const Exception& )
{
@@ -527,7 +511,7 @@ void SAL_CALL MenuBarManager::disposing( const EventObject& Source )
static void lcl_CheckForChildren(Menu* pMenu, sal_uInt16 nItemId)
{
if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( nItemId ))
- pMenu->EnableItem( nItemId, pThisPopup->GetItemCount() != 0 );
+ pMenu->EnableItem( nItemId, pThisPopup->GetItemCount() != 0 && pThisPopup->HasValidEntries(true));
}
// vcl handler
@@ -539,9 +523,8 @@ class QuietInteractionContext:
{
public:
explicit QuietInteractionContext(
- css::uno::Reference< css::uno::XCurrentContext >
- const & context):
- context_(context) {}
+ css::uno::Reference< css::uno::XCurrentContext > context):
+ context_(std::move(context)) {}
QuietInteractionContext(const QuietInteractionContext&) = delete;
QuietInteractionContext& operator=(const QuietInteractionContext&) = delete;
@@ -564,178 +547,212 @@ private:
IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
{
- if ( pMenu == m_pVCLMenu )
- {
- css::uno::ContextLayer layer(
- new QuietInteractionContext(
- css::uno::getCurrentContext()));
+ if ( pMenu != m_pVCLMenu )
+ return true;
- // set/unset hiding disabled menu entries
- bool bDontHide = SvtMenuOptions().IsEntryHidingEnabled();
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- bool bShowMenuImages = rSettings.GetUseImagesInMenus();
- bool bShowShortcuts = m_bHasMenuBar || rSettings.GetContextMenuShortcuts();
- bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED );
+ css::uno::ContextLayer layer(
+ new QuietInteractionContext(
+ css::uno::getCurrentContext()));
- SolarMutexGuard g;
+ // set/unset hiding disabled menu entries
+ bool bDontHide = officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get();
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ bool bShowMenuImages = rSettings.GetUseImagesInMenus();
+ bool bShowShortcuts = m_bHasMenuBar || rSettings.GetContextMenuShortcuts();
+ bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled();
- MenuFlags nFlag = pMenu->GetMenuFlags();
- if ( bDontHide )
- nFlag &= ~MenuFlags::HideDisabledEntries;
- else
- nFlag |= MenuFlags::HideDisabledEntries;
- pMenu->SetMenuFlags( nFlag );
+ SolarMutexGuard g;
- if ( m_bActive )
- return false;
+ MenuFlags nFlag = pMenu->GetMenuFlags();
+ if ( bDontHide )
+ nFlag &= ~MenuFlags::HideDisabledEntries;
+ else
+ nFlag |= MenuFlags::HideDisabledEntries;
+ pMenu->SetMenuFlags( nFlag );
- m_bActive = true;
+ if ( m_bActive )
+ return false;
- // Check if some modes have changed so we have to update our menu images
- OUString sIconTheme = SvtMiscOptions().GetIconTheme();
+ m_bActive = true;
- if ( m_bRetrieveImages ||
- bShowMenuImages != m_bShowMenuImages ||
- sIconTheme != m_sIconTheme )
- {
- m_bShowMenuImages = bShowMenuImages;
- m_bRetrieveImages = false;
- m_sIconTheme = sIconTheme;
- FillMenuImages( m_xFrame, pMenu, bShowMenuImages );
- }
+ // Check if some modes have changed so we have to update our menu images
+ OUString sIconTheme = SvtMiscOptions::GetIconTheme();
- // Try to map commands to labels
- for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ )
+ if ( m_bRetrieveImages ||
+ bShowMenuImages != m_bShowMenuImages ||
+ sIconTheme != m_sIconTheme )
+ {
+ m_bShowMenuImages = bShowMenuImages;
+ m_bRetrieveImages = false;
+ m_sIconTheme = sIconTheme;
+ FillMenuImages( m_xFrame, pMenu, bShowMenuImages );
+ }
+
+ // Try to map commands to labels
+ for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ )
+ {
+ sal_uInt16 nItemId = pMenu->GetItemId( nPos );
+ if (( pMenu->GetItemType( nPos ) != MenuItemType::SEPARATOR ) &&
+ ( pMenu->GetItemText( nItemId ).isEmpty() ))
{
- sal_uInt16 nItemId = pMenu->GetItemId( nPos );
- if (( pMenu->GetItemType( nPos ) != MenuItemType::SEPARATOR ) &&
- ( pMenu->GetItemText( nItemId ).isEmpty() ))
- {
- OUString aCommand = pMenu->GetItemCommand( nItemId );
- if ( !aCommand.isEmpty() ) {
- pMenu->SetItemText( nItemId, RetrieveLabelFromCommand( aCommand ));
- }
+ OUString aCommand = pMenu->GetItemCommand( nItemId );
+ if ( !aCommand.isEmpty() ) {
+ pMenu->SetItemText( nItemId, RetrieveLabelFromCommand( aCommand ));
}
}
+ }
- // Try to set accelerator keys
- {
- if ( bShowShortcuts )
- RetrieveShortcuts( m_aMenuItemHandlerVector );
+ // Try to set accelerator keys
+ {
+ if ( bShowShortcuts )
+ RetrieveShortcuts( m_aMenuItemHandlerVector );
- for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
+ for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
+ {
+ if ( !bShowShortcuts )
{
- if ( !bShowShortcuts )
- {
- pMenu->SetAccelKey( menuItemHandler->nItemId, vcl::KeyCode() );
- }
- else if ( menuItemHandler->aMenuItemURL == aCmdHelpIndex )
- {
- // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex
- // Only non-popup menu items can have a short-cut
- vcl::KeyCode aKeyCode( KEY_F1 );
- pMenu->SetAccelKey( menuItemHandler->nItemId, aKeyCode );
- }
- else if ( pMenu->GetPopupMenu( menuItemHandler->nItemId ) == nullptr )
- pMenu->SetAccelKey( menuItemHandler->nItemId, menuItemHandler->aKeyCode );
+ pMenu->SetAccelKey( menuItemHandler->nItemId, vcl::KeyCode() );
}
+ else if ( menuItemHandler->aMenuItemURL == aCmdHelpIndex )
+ {
+ // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex
+ // Only non-popup menu items can have a short-cut
+ vcl::KeyCode aKeyCode( KEY_F1 );
+ pMenu->SetAccelKey( menuItemHandler->nItemId, aKeyCode );
+ }
+ else if ( pMenu->GetPopupMenu( menuItemHandler->nItemId ) == nullptr )
+ pMenu->SetAccelKey( menuItemHandler->nItemId, menuItemHandler->aKeyCode );
}
+ }
- URL aTargetURL;
+ URL aTargetURL;
- // Use provided dispatch provider => fallback to frame as dispatch provider
- Reference< XDispatchProvider > xDispatchProvider;
- if ( m_xDispatchProvider.is() )
- xDispatchProvider = m_xDispatchProvider;
- else
- xDispatchProvider.set( m_xFrame, UNO_QUERY );
+ // Use provided dispatch provider => fallback to frame as dispatch provider
+ Reference< XDispatchProvider > xDispatchProvider;
+ if ( m_xDispatchProvider.is() )
+ xDispatchProvider = m_xDispatchProvider;
+ else
+ xDispatchProvider.set( m_xFrame, UNO_QUERY );
+
+ if ( !xDispatchProvider.is() )
+ return true;
- if ( xDispatchProvider.is() )
+ SvtCommandOptions aCmdOptions;
+ for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
+ {
+ if (menuItemHandler)
{
- SvtCommandOptions aCmdOptions;
- for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
+ if ( !menuItemHandler->xMenuItemDispatch.is() &&
+ !menuItemHandler->xSubMenuManager.is() )
{
- if (menuItemHandler)
- {
- if ( !menuItemHandler->xMenuItemDispatch.is() &&
- !menuItemHandler->xSubMenuManager.is() )
- {
- Reference< XDispatch > xMenuItemDispatch;
+ Reference< XDispatch > xMenuItemDispatch;
- aTargetURL.Complete = menuItemHandler->aMenuItemURL;
+ aTargetURL.Complete = menuItemHandler->aMenuItemURL;
- m_xURLTransformer->parseStrict( aTargetURL );
+ m_xURLTransformer->parseStrict( aTargetURL );
- if ( bHasDisabledEntries )
- {
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aTargetURL.Path ))
- pMenu->HideItem( menuItemHandler->nItemId );
- }
+ if ( bHasDisabledEntries )
+ {
+ if ( aCmdOptions.LookupDisabled( aTargetURL.Path ))
+ pMenu->HideItem( menuItemHandler->nItemId );
+ }
- if ( aTargetURL.Complete.startsWith( ".uno:StyleApply?" ) )
- xMenuItemDispatch = new StyleDispatcher( m_xFrame, m_xURLTransformer, aTargetURL );
- else
- xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, menuItemHandler->aTargetFrame, 0 );
+ if ( aTargetURL.Complete.startsWith( ".uno:StyleApply?" ) )
+ xMenuItemDispatch = new StyleDispatcher( m_xFrame, m_xURLTransformer, aTargetURL );
+ else
+ {
+ try
+ {
+ xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, menuItemHandler->aTargetFrame, 0 );
+ }
+ catch (uno::Exception const&)
+ {
+ TOOLS_WARN_EXCEPTION("fwk.uielement", "MenuBarManager::Activate(): exception from queryDispatch()");
+ }
+ }
- bool bPopupMenu( false );
- if ( !menuItemHandler->xPopupMenuController.is() &&
- m_xPopupMenuControllerFactory->hasController( menuItemHandler->aMenuItemURL, m_aModuleIdentifier ) )
- {
- if( xMenuItemDispatch.is() || menuItemHandler->aMenuItemURL != ".uno:RecentFileList" )
- bPopupMenu = CreatePopupMenuController(menuItemHandler.get(), m_xDispatchProvider, m_aModuleIdentifier);
- }
- else if ( menuItemHandler->xPopupMenuController.is() )
- {
- // Force update of popup menu
- menuItemHandler->xPopupMenuController->updatePopupMenu();
- bPopupMenu = true;
- if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( menuItemHandler->nItemId ))
- pMenu->EnableItem( menuItemHandler->nItemId, pThisPopup->GetItemCount() != 0 );
- }
- lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
+ bool bPopupMenu( false );
+ if ( !menuItemHandler->xPopupMenuController.is() &&
+ m_xPopupMenuControllerFactory->hasController( menuItemHandler->aMenuItemURL, m_aModuleIdentifier ) )
+ {
+ if( xMenuItemDispatch.is() || menuItemHandler->aMenuItemURL != ".uno:RecentFileList" )
+ bPopupMenu = CreatePopupMenuController(menuItemHandler.get(), m_xDispatchProvider, m_aModuleIdentifier);
- if ( xMenuItemDispatch.is() )
+ if (bPopupMenu && menuItemHandler->xPopupMenuController.is())
+ {
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu(menuItemHandler->nItemId))
{
- menuItemHandler->xMenuItemDispatch = xMenuItemDispatch;
- menuItemHandler->aParsedItemURL = aTargetURL.Complete;
-
- if ( !bPopupMenu )
- {
- xMenuItemDispatch->addStatusListener( static_cast< XStatusListener* >( this ), aTargetURL );
- // For the menubar, we have to keep status listening to support Ubuntu's HUD.
- if ( !m_bHasMenuBar )
- xMenuItemDispatch->removeStatusListener( static_cast< XStatusListener* >( this ), aTargetURL );
- }
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
}
- else if ( !bPopupMenu )
- pMenu->EnableItem( menuItemHandler->nItemId, false );
}
- else if ( menuItemHandler->xPopupMenuController.is() )
+ }
+ else if ( menuItemHandler->xPopupMenuController.is() )
+ {
+ // Force update of popup menu
+ menuItemHandler->xPopupMenuController->updatePopupMenu();
+ bPopupMenu = true;
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( menuItemHandler->nItemId ))
{
- // Force update of popup menu
- menuItemHandler->xPopupMenuController->updatePopupMenu();
- lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
}
- else if ( menuItemHandler->xMenuItemDispatch.is() )
- {
- // We need an update to reflect the current state
- try
- {
- aTargetURL.Complete = menuItemHandler->aMenuItemURL;
- m_xURLTransformer->parseStrict( aTargetURL );
+ }
+ lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
- menuItemHandler->xMenuItemDispatch->addStatusListener(
- static_cast< XStatusListener* >( this ), aTargetURL );
- menuItemHandler->xMenuItemDispatch->removeStatusListener(
- static_cast< XStatusListener* >( this ), aTargetURL );
- }
- catch ( const Exception& )
- {
- }
+ if ( xMenuItemDispatch.is() )
+ {
+ menuItemHandler->xMenuItemDispatch = xMenuItemDispatch;
+ menuItemHandler->aParsedItemURL = aTargetURL.Complete;
+
+ if ( !bPopupMenu )
+ {
+ xMenuItemDispatch->addStatusListener( static_cast< XStatusListener* >( this ), aTargetURL );
+ // For the menubar, we have to keep status listening to support Ubuntu's HUD.
+ if ( !m_bHasMenuBar )
+ xMenuItemDispatch->removeStatusListener( static_cast< XStatusListener* >( this ), aTargetURL );
}
- else if ( menuItemHandler->xSubMenuManager.is() )
- lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
}
+ else if ( !bPopupMenu )
+ pMenu->EnableItem( menuItemHandler->nItemId, false );
+ }
+ else if ( menuItemHandler->xPopupMenuController.is() )
+ {
+ // Force update of popup menu
+ menuItemHandler->xPopupMenuController->updatePopupMenu();
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu(menuItemHandler->nItemId))
+ {
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
+ }
+ lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
+ }
+ else if ( menuItemHandler->xMenuItemDispatch.is() )
+ {
+ // We need an update to reflect the current state
+ try
+ {
+ aTargetURL.Complete = menuItemHandler->aMenuItemURL;
+ m_xURLTransformer->parseStrict( aTargetURL );
+
+ menuItemHandler->xMenuItemDispatch->addStatusListener(
+ static_cast< XStatusListener* >( this ), aTargetURL );
+ menuItemHandler->xMenuItemDispatch->removeStatusListener(
+ static_cast< XStatusListener* >( this ), aTargetURL );
+ }
+ catch ( const Exception& )
+ {
+ }
+ }
+ else if (menuItemHandler->xSubMenuManager.is())
+ {
+ MenuBarManager* pMenuBarManager = menuItemHandler->xSubMenuManager.get();
+ if (pMenuBarManager)
+ {
+ pMenuBarManager->Activate(pMenuBarManager->GetMenuBar());
+ pMenuBarManager->Deactivate(pMenuBarManager->GetMenuBar());
+ }
+ lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
}
}
}
@@ -799,9 +816,7 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool )
if ( pMenu->GetUserValue( nCurItemId ) )
{
// addon menu item selected
- aArgs.realloc( 1 );
- aArgs[0].Name = "Referer";
- aArgs[0].Value <<= OUString( "private:user" );
+ aArgs = { comphelper::makePropertyValue("Referer", OUString("private:user")) };
}
xDispatch = pMenuItemHandler->xMenuItemDispatch;
@@ -827,45 +842,43 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool )
bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< XURLTransformer >& rTransformer )
{
- if ( pPopupMenu )
- {
- URL aTargetURL;
- SvtCommandOptions aCmdOptions;
+ if ( !pPopupMenu )
+ return true;
+
+ URL aTargetURL;
+ SvtCommandOptions aCmdOptions;
- sal_uInt16 nCount = pPopupMenu->GetItemCount();
- sal_uInt16 nHideCount( 0 );
+ sal_uInt16 nCount = pPopupMenu->GetItemCount();
+ sal_uInt16 nHideCount( 0 );
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ sal_uInt16 nId = pPopupMenu->GetItemId( i );
+ if ( nId > 0 )
{
- sal_uInt16 nId = pPopupMenu->GetItemId( i );
- if ( nId > 0 )
+ PopupMenu* pSubPopupMenu = pPopupMenu->GetPopupMenu( nId );
+ if ( pSubPopupMenu )
{
- PopupMenu* pSubPopupMenu = pPopupMenu->GetPopupMenu( nId );
- if ( pSubPopupMenu )
- {
- if ( MustBeHidden( pSubPopupMenu, rTransformer ))
- {
- pPopupMenu->HideItem( nId );
- ++nHideCount;
- }
- }
- else
+ if ( MustBeHidden( pSubPopupMenu, rTransformer ))
{
- aTargetURL.Complete = pPopupMenu->GetItemCommand( nId );
- rTransformer->parseStrict( aTargetURL );
-
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aTargetURL.Path ))
- ++nHideCount;
+ pPopupMenu->HideItem( nId );
+ ++nHideCount;
}
}
else
- ++nHideCount;
- }
+ {
+ aTargetURL.Complete = pPopupMenu->GetItemCommand( nId );
+ rTransformer->parseStrict( aTargetURL );
- return ( nCount == nHideCount );
+ if ( aCmdOptions.LookupDisabled( aTargetURL.Path ))
+ ++nHideCount;
+ }
+ }
+ else
+ ++nHideCount;
}
- return true;
+ return ( nCount == nHideCount );
}
OUString MenuBarManager::RetrieveLabelFromCommand(const OUString& rCmdURL)
@@ -890,10 +903,10 @@ bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHandle
return false;
auto aSeq( comphelper::InitAnyPropertySequence( {
- { "DispatchProvider", makeAny(rDispatchProvider) },
- { "ModuleIdentifier", makeAny(rModuleIdentifier) },
- { "Frame", makeAny(m_xFrame) },
- { "InToolbar", makeAny(!m_bHasMenuBar) }
+ { "DispatchProvider", Any(rDispatchProvider) },
+ { "ModuleIdentifier", Any(rModuleIdentifier) },
+ { "Frame", Any(m_xFrame) },
+ { "InToolbar", Any(!m_bHasMenuBar) }
} ) );
Reference< XPopupMenuController > xPopupMenuController(
@@ -979,7 +992,6 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
aItemCommand = aRealCommand;
Reference< XDispatch > xDispatch;
- Reference< XStatusListener > xStatusListener;
VclPtr<PopupMenu> pPopup = pMenu->GetPopupMenu( nItemId );
// overwrite the show icons on menu option?
MenuItemBits nBits = pMenu->GetItemBits( nItemId ) & ( MenuItemBits::ICON | MenuItemBits::TEXT );
@@ -1008,8 +1020,8 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
// Check if we have to create a popup menu for a uno based popup menu controller.
// We have to set an empty popup menu into our menu structure so the controller also
// works with inplace OLE.
- MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch );
- VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu(pPopup);
+ MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, nullptr, xDispatch );
+ rtl::Reference<VCLXPopupMenu> pVCLXPopupMenu = new VCLXPopupMenu(pPopup);
pItemHandler->xPopupMenu = pVCLXPopupMenu;
pItemHandler->aMenuItemURL = aItemCommand;
m_aMenuItemHandlerVector.push_back( std::unique_ptr<MenuItemHandler>(pItemHandler) );
@@ -1041,10 +1053,10 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
pSubMenu.disposeAndClear();
}
- MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer,
+ rtl::Reference<MenuBarManager> pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer,
xPopupMenuDispatchProvider, aModuleIdentifier, pPopup, false, m_bHasMenuBar );
- AddMenu(pSubMenuManager, aItemCommand, nItemId);
+ AddMenu(pSubMenuManager.get(), aItemCommand, nItemId);
}
}
else if ( pMenu->GetItemType( i ) != MenuItemType::SEPARATOR )
@@ -1052,7 +1064,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
if ( bItemShowMenuImages )
m_bRetrieveImages = true;
- std::unique_ptr<MenuItemHandler> pItemHandler(new MenuItemHandler( nItemId, xStatusListener, xDispatch ));
+ std::unique_ptr<MenuItemHandler> pItemHandler(new MenuItemHandler( nItemId, nullptr, xDispatch ));
// Retrieve possible attributes struct
MenuAttributes* pAttributes = static_cast<MenuAttributes *>(pMenu->GetUserValue( nItemId ));
if ( pAttributes )
@@ -1065,7 +1077,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
// Check if we have to create a popup menu for a uno based popup menu controller.
// We have to set an empty popup menu into our menu structure so the controller also
// works with inplace OLE.
- VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu;
+ rtl::Reference<VCLXPopupMenu> pVCLXPopupMenu = new VCLXPopupMenu;
PopupMenu* pPopupMenu = static_cast<PopupMenu *>(pVCLXPopupMenu->GetMenu());
pMenu->SetPopupMenu( pItemHandler->nItemId, pPopupMenu );
pItemHandler->xPopupMenu = pVCLXPopupMenu;
@@ -1194,10 +1206,11 @@ void MenuBarManager::RetrieveShortcuts( std::vector< std::unique_ptr<MenuItemHan
vcl::KeyCode aEmptyKeyCode;
Sequence< OUString > aSeq( aMenuShortCuts.size() );
+ auto aSeqRange = asNonConstRange(aSeq);
const sal_uInt32 nCount = aMenuShortCuts.size();
for ( sal_uInt32 i = 0; i < nCount; ++i )
{
- aSeq[i] = aMenuShortCuts[i]->aMenuItemURL;
+ aSeqRange[i] = aMenuShortCuts[i]->aMenuItemURL;
aMenuShortCuts[i]->aKeyCode = aEmptyKeyCode;
}
@@ -1226,8 +1239,7 @@ void MenuBarManager::RetrieveImageManagers()
Reference< XUIConfigurationManager > xDocUICfgMgr = xSupplier->getUIConfigurationManager();
m_xDocImageManager.set( xDocUICfgMgr->getImageManager(), UNO_QUERY );
m_xDocImageManager->addConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
}
}
@@ -1239,8 +1251,7 @@ void MenuBarManager::RetrieveImageManagers()
theModuleUIConfigurationManagerSupplier::get( m_xContext );
Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
m_xModuleImageManager.set( xUICfgMgr->getImageManager(), UNO_QUERY );
- m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
}
@@ -1259,7 +1270,7 @@ void MenuBarManager::FillMenuWithConfiguration(
AddonsOptions().GetMergeMenuInstructions(),
rModuleIdentifier );
- bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED );
+ bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled();
if ( !bHasDisabledEntries )
return;
@@ -1304,7 +1315,7 @@ void MenuBarManager::FillMenu(
bool bShow = true;
bool bEnabled = true;
- for ( beans::PropertyValue const & rProp : std::as_const(aProps) )
+ for (beans::PropertyValue const& rProp : aProps)
{
OUString aPropName = rProp.Name;
if ( aPropName == "CommandURL" )
@@ -1332,6 +1343,11 @@ void MenuBarManager::FillMenu(
{
continue;
}
+ if (aCommandURL == ".uno:SafeMode"
+ && !officecfg::Office::Common::Misc::OfferSafeMode::get())
+ {
+ continue;
+ }
if ( nType == css::ui::ItemType::DEFAULT )
{
@@ -1360,6 +1376,8 @@ void MenuBarManager::FillMenu(
{
VclPtr<PopupMenu> pNewPopupMenu = VclPtr<PopupMenu>::Create();
pMenu->SetPopupMenu( nId, pNewPopupMenu );
+ // Use the command URL as the Help ID for the sub menu
+ pNewPopupMenu->SetHelpId(aCommandURL);
if ( xDispatchProvider.is() )
{
@@ -1475,7 +1493,7 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon
FillMenuManager( m_pVCLMenu, xFrame, xDispatchProvider, m_aModuleIdentifier, false );
// add itself as frame action listener
- m_xFrame->addFrameActionListener( Reference< XFrameActionListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xFrame->addFrameActionListener( Reference< XFrameActionListener >(this) );
}
}
@@ -1511,30 +1529,28 @@ void MenuBarManager::GetPopupController( PopupControllerCache& rPopupController
rPopupController.emplace( aMainURL, aPopupControllerEntry );
}
}
- if ( menuItemHandler->xSubMenuManager.is() )
+ if ( menuItemHandler->xSubMenuManager )
{
- MenuBarManager* pMenuBarManager = static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
- if ( pMenuBarManager )
- pMenuBarManager->GetPopupController( rPopupController );
+ menuItemHandler->xSubMenuManager->GetPopupController( rPopupController );
}
}
}
void MenuBarManager::AddMenu(MenuBarManager* pSubMenuManager,const OUString& _sItemCommand,sal_uInt16 _nItemId)
{
- Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY );
+ Reference< XStatusListener > xSubMenuManager( pSubMenuManager );
m_xFrame->addFrameActionListener( Reference< XFrameActionListener >( xSubMenuManager, UNO_QUERY ));
- Reference< XDispatch > xDispatch;
std::unique_ptr<MenuItemHandler> pMenuItemHandler(new MenuItemHandler(
_nItemId,
- xSubMenuManager,
- xDispatch ));
+ pSubMenuManager,
+ Reference<XDispatch>() ));
pMenuItemHandler->aMenuItemURL = _sItemCommand;
m_aMenuItemHandlerVector.push_back( std::move(pMenuItemHandler) );
}
-sal_uInt16 MenuBarManager::FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const
+// static
+sal_uInt16 MenuBarManager::FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex)
{
sal_uInt16 nItemId = _pMenu->GetItemId( _nIndex );
diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx
index b353fc954d56..eebf61aa7383 100644
--- a/framework/source/uielement/menubarmerger.cxx
+++ b/framework/source/uielement/menubarmerger.cxx
@@ -20,6 +20,7 @@
#include <uielement/menubarmerger.hxx>
#include <framework/addonsoptions.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/string_view.hxx>
using namespace ::com::sun::star;
@@ -56,13 +57,13 @@ namespace framework
*/
bool MenuBarMerger::IsCorrectContext(
- const OUString& rContext, std::u16string_view rModuleIdentifier )
+ std::u16string_view rContext, std::u16string_view rModuleIdentifier )
{
- return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
+ return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
void MenuBarMerger::RetrieveReferencePath(
- const OUString& rReferencePathString,
+ std::u16string_view rReferencePathString,
::std::vector< OUString >& rReferencePath )
{
const char aDelimiter = '\\';
@@ -71,7 +72,7 @@ void MenuBarMerger::RetrieveReferencePath(
sal_Int32 nIndex( 0 );
do
{
- OUString aToken = rReferencePathString.getToken( 0, aDelimiter, nIndex );
+ OUString aToken( o3tl::getToken(rReferencePathString, 0, aDelimiter, nIndex ) );
if ( !aToken.isEmpty() )
rReferencePath.push_back( aToken );
}
@@ -215,11 +216,11 @@ bool MenuBarMerger::MergeMenuItems(
{
if ( rMenuItem.aURL == SEPARATOR_STRING )
{
- pMenu->InsertSeparator(OString(), nPos+nModIndex+nIndex);
+ pMenu->InsertSeparator({}, nPos + nModIndex + nIndex);
}
else
{
- pMenu->InsertItem(nItemId, rMenuItem.aTitle, MenuItemBits::NONE, OString(), nPos+nModIndex+nIndex);
+ pMenu->InsertItem(nItemId, rMenuItem.aTitle, MenuItemBits::NONE, {}, nPos + nModIndex + nIndex);
pMenu->SetItemCommand( nItemId, rMenuItem.aURL );
if ( !rMenuItem.aSubMenu.empty() )
{
@@ -256,9 +257,9 @@ bool MenuBarMerger::ReplaceMenuItem(
bool MenuBarMerger::RemoveMenuItems(
Menu* pMenu,
sal_uInt16 nPos,
- const OUString& rMergeCommandParameter )
+ std::u16string_view rMergeCommandParameter )
{
- const sal_uInt16 nParam( sal_uInt16( rMergeCommandParameter.toInt32() ));
+ const sal_uInt16 nParam( sal_uInt16( o3tl::toInt32(rMergeCommandParameter) ));
sal_uInt16 nCount = std::max( nParam, sal_uInt16(1) );
sal_uInt16 i = 0;
@@ -276,7 +277,7 @@ bool MenuBarMerger::ProcessMergeOperation(
sal_uInt16 nPos,
sal_uInt16& nItemId,
std::u16string_view rMergeCommand,
- const OUString& rMergeCommandParameter,
+ std::u16string_view rMergeCommandParameter,
const OUString& rModuleIdentifier,
const AddonMenuContainer& rAddonMenuItems )
{
diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx
index 6342f63cf637..24f4d738bf7f 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -29,6 +29,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <toolkit/awt/vclxmenu.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
using namespace com::sun::star;
@@ -44,74 +45,12 @@ using namespace ::com::sun::star::ui;
namespace framework
{
-void SAL_CALL MenuBarWrapper::acquire() throw() \
-{ \
- /* Don't use mutex in methods of XInterface! */ \
- UIConfigElementWrapperBase::acquire(); \
-} \
- \
-void SAL_CALL MenuBarWrapper::release() throw() \
-{ \
- /* Don't use mutex in methods of XInterface! */ \
- UIConfigElementWrapperBase::release(); \
-}
-
-css::uno::Any SAL_CALL MenuBarWrapper::queryInterface( const css::uno::Type& aType )
-{
- /* Attention: Don't use mutex or guard in this method!!! Is a method of XInterface. */
- /* Ask for my own supported interfaces ... */
- css::uno::Any aReturn = ::cppu::queryInterface( aType,
- static_cast< css::lang::XTypeProvider* >( this ),
- static_cast< css::ui::XUIElement* >( this ),
- static_cast< css::ui::XUIElementSettings* >( this ),
- static_cast< css::beans::XMultiPropertySet* >( this ),
- static_cast< css::beans::XFastPropertySet* >( this ),
- static_cast< css::beans::XPropertySet* >( this ),
- static_cast< css::lang::XInitialization* >( this ),
- static_cast< css::lang::XComponent* >( this ),
- static_cast< css::util::XUpdatable* >( this ),
- static_cast< css::ui::XUIConfigurationListener* >( this ),
- static_cast< css::container::XNameAccess* >( static_cast< css::container::XElementAccess* >( this ) )
- );
- /* If searched interface not supported by this class ... */
- if ( !aReturn.hasValue() )
- {
- /* ... ask baseclass for interfaces! */
- aReturn = UIConfigElementWrapperBase::queryInterface( aType );
- }
- /* Return result of this search. */
- return aReturn;
-}
-
-css::uno::Sequence< sal_Int8 > SAL_CALL MenuBarWrapper::getImplementationId()
-{
- return css::uno::Sequence<sal_Int8>();
-}
-
-css::uno::Sequence< css::uno::Type > SAL_CALL MenuBarWrapper::getTypes()
-{
- /* Attention: "TYPES" will expand to "(...)"! */
- static cppu::OTypeCollection ourTypeCollection {
- cppu::UnoType<css::lang::XTypeProvider>::get() ,
- cppu::UnoType<css::ui::XUIElement>::get() ,
- cppu::UnoType<css::ui::XUIElementSettings>::get() ,
- cppu::UnoType<css::beans::XMultiPropertySet>::get() ,
- cppu::UnoType<css::beans::XFastPropertySet>::get() ,
- cppu::UnoType<css::beans::XPropertySet>::get() ,
- cppu::UnoType<css::lang::XInitialization>::get() ,
- cppu::UnoType<css::lang::XComponent>::get() ,
- cppu::UnoType<css::util::XUpdatable>::get() ,
- cppu::UnoType<css::ui::XUIConfigurationListener>::get() ,
- cppu::UnoType<css::container::XNameAccess>::get() };
- return ourTypeCollection.getTypes();
-}
-
MenuBarWrapper::MenuBarWrapper(
- const css::uno::Reference< css::uno::XComponentContext >& rxContext
+ css::uno::Reference< css::uno::XComponentContext > xContext
)
-: UIConfigElementWrapperBase( UIElementType::MENUBAR ),
+: MenuBarWrapper_Base( UIElementType::MENUBAR ),
m_bRefreshPopupControllerCache( true ),
- m_xContext( rxContext )
+ m_xContext(std::move( xContext ))
{
}
@@ -121,7 +60,7 @@ MenuBarWrapper::~MenuBarWrapper()
void SAL_CALL MenuBarWrapper::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
css::lang::EventObject aEvent( xThis );
m_aListenerContainer.disposeAndClear( aEvent );
@@ -157,7 +96,6 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments )
// Create VCL menubar which will be filled with settings data
VclPtr<MenuBar> pVCLMenuBar;
- VCLXMenuBar* pAwtMenuBar = nullptr;
{
SolarMutexGuard aSolarMutexGuard;
pVCLMenuBar = VclPtr<MenuBar>::Create();
@@ -208,21 +146,18 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments )
// support. This feature is currently used for "Inplace editing"!
Reference< XDispatchProvider > xDispatchProvider;
- MenuBarManager* pMenuBarManager = new MenuBarManager( m_xContext,
+ m_xMenuBarManager = new MenuBarManager( m_xContext,
xFrame,
xTrans,
xDispatchProvider,
aModuleIdentifier,
pVCLMenuBar,
false );
-
- m_xMenuBarManager.set( static_cast< OWeakObject *>( pMenuBarManager ), UNO_QUERY );
}
// Initialize toolkit menu bar implementation to have awt::XMenuBar for data exchange.
// Don't use this toolkit menu bar or one of its functions. It is only used as a data container!
- pAwtMenuBar = new VCLXMenuBar( pVCLMenuBar );
- m_xMenuBar = pAwtMenuBar;
+ m_xMenuBar = new VCLXMenuBar( pVCLMenuBar );
}
// XUIElementSettings
@@ -240,11 +175,9 @@ void SAL_CALL MenuBarWrapper::updateSettings()
{
try
{
- MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() );
-
m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
if ( m_xConfigData.is() )
- pMenuBarManager->SetItemContainer( m_xConfigData );
+ m_xMenuBarManager->SetItemContainer( m_xConfigData );
}
catch ( const NoSuchElementException& )
{
@@ -258,19 +191,16 @@ void SAL_CALL MenuBarWrapper::updateSettings()
void MenuBarWrapper::impl_fillNewData()
{
// Transient menubar => Fill menubar with new data
- MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() );
-
- if ( pMenuBarManager )
- pMenuBarManager->SetItemContainer( m_xConfigData );
+ if ( m_xMenuBarManager )
+ m_xMenuBarManager->SetItemContainer( m_xConfigData );
}
void MenuBarWrapper::fillPopupControllerCache()
{
if ( m_bRefreshPopupControllerCache )
{
- MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() );
- if ( pMenuBarManager )
- pMenuBarManager->GetPopupController( m_aPopupControllerCache );
+ if ( m_xMenuBarManager )
+ m_xMenuBarManager->GetPopupController( m_aPopupControllerCache );
if ( !m_aPopupControllerCache.empty() )
m_bRefreshPopupControllerCache = false;
}
@@ -309,7 +239,7 @@ Any SAL_CALL MenuBarWrapper::getByName(
throw container::NoSuchElementException();
uno::Reference< frame::XDispatchProvider > xDispatchProvider = pIter->second.m_xDispatchProvider;
- return uno::makeAny( xDispatchProvider );
+ return uno::Any( xDispatchProvider );
}
Sequence< OUString > SAL_CALL MenuBarWrapper::getElementNames()
@@ -347,7 +277,7 @@ Reference< XInterface > SAL_CALL MenuBarWrapper::getRealInterface()
if ( m_bDisposed )
throw DisposedException();
- return Reference< XInterface >( m_xMenuBarManager, UNO_QUERY );
+ return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xMenuBarManager.get()), UNO_QUERY );
}
} // namespace framework
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 76f7bc6eb194..eba370c7a6f1 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -22,6 +22,7 @@
#include <services.h>
+#include <com/sun/star/awt/MenuItemType.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
@@ -30,6 +31,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
@@ -38,20 +40,18 @@
#include <toolkit/awt/vclxmenu.hxx>
#include <tools/urlobj.hxx>
#include <unotools/dynamicmenuoptions.hxx>
-#include <unotools/moduleoptions.hxx>
#include <osl/mutex.hxx>
#include <cppuhelper/supportsservice.hxx>
// Defines
-#define aSlotNewDocDirect ".uno:AddDirect"
-#define aSlotAutoPilot ".uno:AutoPilotMenu"
+constexpr OUString aSlotNewDocDirect = u".uno:AddDirect"_ustr;
+constexpr OUStringLiteral aSlotAutoPilot = u".uno:AutoPilotMenu";
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
-using namespace com::sun::star::container;
using namespace com::sun::star::ui;
namespace framework
@@ -105,11 +105,10 @@ void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages )
}
}
-void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode )
+void NewMenuController::determineAndSetNewDocAccel(const css::awt::KeyEvent& rKeyCode)
{
- sal_uInt16 nCount( pPopupMenu->GetItemCount() );
- sal_uInt16 nId( 0 );
- bool bFound( false );
+ sal_uInt16 nCount(m_xPopupMenu->getItemCount());
+ sal_uInt16 nId( 0 );
OUString aCommand;
if ( !m_aEmptyDocURL.isEmpty() )
@@ -118,44 +117,21 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const
for ( sal_uInt16 i = 0; i < nCount; i++ )
{
- if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR )
+ if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR)
{
- nId = pPopupMenu->GetItemId( i );
- aCommand = pPopupMenu->GetItemCommand( nId );
+ nId = m_xPopupMenu->getItemId(i);
+ aCommand = m_xPopupMenu->getCommand(nId);
if ( aCommand.startsWith( m_aEmptyDocURL ) )
{
- pPopupMenu->SetAccelKey( nId, rKeyCode );
- bFound = true;
+ m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode);
break;
}
}
}
}
-
- if ( bFound )
- return;
-
- // Search for the default module name
- OUString aDefaultModuleName( SvtModuleOptions().GetDefaultModuleName() );
- if ( aDefaultModuleName.isEmpty() )
- return;
-
- for ( sal_uInt16 i = 0; i < nCount; i++ )
- {
- if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR )
- {
- nId = pPopupMenu->GetItemId( i );
- aCommand = pPopupMenu->GetItemCommand( nId );
- if ( aCommand.indexOf( aDefaultModuleName ) >= 0 )
- {
- pPopupMenu->SetAccelKey( nId, rKeyCode );
- break;
- }
- }
- }
}
-void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
+void NewMenuController::setAccelerators()
{
if ( !m_bModuleIdentified )
return;
@@ -211,18 +187,18 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
}
vcl::KeyCode aEmptyKeyCode;
- sal_uInt16 nItemCount( pPopupMenu->GetItemCount() );
+ sal_uInt16 nItemCount(m_xPopupMenu->getItemCount());
std::vector< vcl::KeyCode > aMenuShortCuts;
std::vector< OUString > aCmds;
std::vector< sal_uInt16 > aIds;
for ( sal_uInt16 i = 0; i < nItemCount; i++ )
{
- if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR )
+ if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR)
{
- sal_uInt16 nId( pPopupMenu->GetItemId( i ));
+ sal_uInt16 nId(m_xPopupMenu->getItemId(i));
aIds.push_back( nId );
aMenuShortCuts.push_back( aEmptyKeyCode );
- aCmds.push_back( pPopupMenu->GetItemCommand( nId ));
+ aCmds.push_back(m_xPopupMenu->getCommand(nId));
}
}
@@ -232,17 +208,18 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
nSeqCount+=1;
Sequence< OUString > aSeq( nSeqCount );
+ auto aSeqRange = asNonConstRange(aSeq);
// Add a special command for our "New" menu.
if ( m_bNewMenu )
{
- aSeq[nSeqCount-1] = m_aCommandURL;
+ aSeqRange[nSeqCount-1] = m_aCommandURL;
aMenuShortCuts.push_back( aEmptyKeyCode );
}
const sal_uInt32 nCount = aCmds.size();
for ( sal_uInt32 i = 0; i < nCount; i++ )
- aSeq[i] = aCmds[i];
+ aSeqRange[i] = aCmds[i];
if ( m_xGlobalAcceleratorManager.is() )
retrieveShortcutsFromConfiguration( xGlobalAccelCfg, aSeq, aMenuShortCuts );
@@ -253,17 +230,18 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
const sal_uInt32 nCount2 = aIds.size();
for ( sal_uInt32 i = 0; i < nCount2; i++ )
- pPopupMenu->SetAccelKey( aIds[i], aMenuShortCuts[i] );
+ m_xPopupMenu->setAcceleratorKeyEvent(aIds[i], svt::AcceleratorExecute::st_VCLKey2AWTKey(aMenuShortCuts[i]));
// Special handling for "New" menu short-cut should be set at the
// document which will be opened using it.
if ( m_bNewMenu )
{
if ( aMenuShortCuts[nSeqCount-1] != aEmptyKeyCode )
- determineAndSetNewDocAccel( pPopupMenu, aMenuShortCuts[nSeqCount-1] );
+ determineAndSetNewDocAccel(svt::AcceleratorExecute::st_VCLKey2AWTKey(aMenuShortCuts[nSeqCount-1]));
}
}
+// static
void NewMenuController::retrieveShortcutsFromConfiguration(
const Reference< XAcceleratorConfiguration >& rAccelCfg,
const Sequence< OUString >& rCommands,
@@ -305,7 +283,7 @@ NewMenuController::~NewMenuController()
// private function
void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
+ VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(dynamic_cast<VCLXMenu*>( rPopupMenu.get() ));
PopupMenu* pVCLPopupMenu = nullptr;
SolarMutexGuard aSolarMutexGuard;
@@ -319,14 +297,14 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const &
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
URL aTargetURL;
- aTargetURL.Complete = OUString::createFromAscii(m_bNewMenu ? aSlotNewDocDirect : aSlotAutoPilot);
+ aTargetURL.Complete = m_bNewMenu ? aSlotNewDocDirect : OUString(aSlotAutoPilot);
m_xURLTransformer->parseStrict( aTargetURL );
Reference< XDispatch > xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
if(xMenuItemDispatch == nullptr)
return;
const std::vector< SvtDynMenuEntry > aDynamicMenuEntries =
- SvtDynamicMenuOptions().GetMenu( m_bNewMenu ? EDynamicMenuType::NewMenu : EDynamicMenuType::WizardMenu );
+ SvtDynamicMenuOptions::GetMenu( m_bNewMenu ? EDynamicMenuType::NewMenu : EDynamicMenuType::WizardMenu );
sal_uInt16 nItemId = 1;
@@ -336,14 +314,14 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const &
continue;
if ( aDynamicMenuEntry.sURL == "private:separator" )
- pVCLPopupMenu->InsertSeparator();
+ rPopupMenu->insertSeparator(-1);
else
{
- pVCLPopupMenu->InsertItem( nItemId, aDynamicMenuEntry.sTitle );
- pVCLPopupMenu->SetItemCommand( nItemId, aDynamicMenuEntry.sURL );
+ rPopupMenu->insertItem(nItemId, aDynamicMenuEntry.sTitle, 0, -1);
+ rPopupMenu->setCommand(nItemId, aDynamicMenuEntry.sURL);
void* nAttributePtr = MenuAttributes::CreateAttribute( aDynamicMenuEntry.sTargetName, aDynamicMenuEntry.sImageIdentifier );
- pVCLPopupMenu->SetUserValue( nItemId, nAttributePtr, MenuAttributes::ReleaseAttribute );
+ pPopupMenu->setUserValue(nItemId, nAttributePtr, MenuAttributes::ReleaseAttribute);
nItemId++;
}
@@ -356,21 +334,22 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const &
// XEventListener
void SAL_CALL NewMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xContext.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
// XStatusListener
-void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& )
+void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& Event )
{
+ Event.State >>= m_aEmptyDocURL;
}
// XMenuListener
@@ -380,7 +359,7 @@ void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent
Reference< XComponentContext > xContext;
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
xPopupMenu = m_xPopupMenu;
xContext = m_xContext;
}
@@ -388,7 +367,7 @@ void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent
if ( !xPopupMenu.is() )
return;
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu ));
+ VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(dynamic_cast<VCLXMenu*>( xPopupMenu.get() ));
if ( !pPopupMenu )
return;
@@ -397,17 +376,15 @@ void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent
{
SolarMutexGuard aSolarMutexGuard;
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- aURL = pVCLPopupMenu->GetItemCommand(rEvent.MenuId);
- void* nAttributePtr = pVCLPopupMenu->GetUserValue(rEvent.MenuId);
+ aURL = pPopupMenu->getCommand(rEvent.MenuId);
+ void* nAttributePtr = pPopupMenu->getUserValue(rEvent.MenuId);
MenuAttributes* pAttributes = static_cast<MenuAttributes *>(nAttributePtr);
if (pAttributes)
aTargetFrame = pAttributes->aTargetFrame;
}
- Sequence< PropertyValue > aArgsList( 1 );
- aArgsList[0].Name = "Referer";
- aArgsList[0].Value <<= OUString( "private:user" );
+ Sequence< PropertyValue > aArgsList{ comphelper::makePropertyValue("Referer",
+ OUString( "private:user" )) };
dispatchCommand( aURL, aArgsList, aTargetFrame );
}
@@ -418,15 +395,11 @@ void SAL_CALL NewMenuController::itemActivated( const css::awt::MenuEvent& )
if ( !(m_xFrame.is() && m_xPopupMenu.is()) )
return;
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
- if ( !pPopupMenu )
- return;
-
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
bool bShowImages( rSettings.GetUseImagesInMenus() );
OUString aIconTheme( rSettings.DetermineIconTheme() );
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
+ PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(m_xPopupMenu->GetMenu());
if ( m_bShowImages != bShowImages || m_aIconTheme != aIconTheme )
{
@@ -435,7 +408,7 @@ void SAL_CALL NewMenuController::itemActivated( const css::awt::MenuEvent& )
setMenuImages( pVCLPopupMenu, m_bShowImages );
}
- setAccelerators( pVCLPopupMenu );
+ setAccelerators();
}
// XPopupMenuController
@@ -451,23 +424,6 @@ void NewMenuController::impl_setPopupMenu()
{
m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
m_bModuleIdentified = true;
-
- if ( !m_aModuleIdentifier.isEmpty() )
- {
- Sequence< PropertyValue > aSeq;
-
- if ( xModuleManager->getByName( m_aModuleIdentifier ) >>= aSeq )
- {
- for ( PropertyValue const & prop : std::as_const(aSeq) )
- {
- if ( prop.Name == "ooSetupFactoryEmptyDocumentURL" )
- {
- prop.Value >>= m_aEmptyDocURL;
- break;
- }
- }
- }
- }
}
catch ( const RuntimeException& )
{
@@ -479,15 +435,13 @@ void NewMenuController::impl_setPopupMenu()
}
// XInitialization
-void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments )
+void NewMenuController::initializeImpl( std::unique_lock<std::mutex>& rGuard, const Sequence< Any >& aArguments )
{
- osl::MutexGuard aLock( m_aMutex );
-
- bool bInitalized( m_bInitialized );
- if ( bInitalized )
+ bool bInitialized( m_bInitialized );
+ if ( bInitialized )
return;
- svt::PopupMenuControllerBase::initialize( aArguments );
+ svt::PopupMenuControllerBase::initializeImpl( rGuard, aArguments );
if ( m_bInitialized )
{
diff --git a/framework/source/uielement/objectmenucontroller.cxx b/framework/source/uielement/objectmenucontroller.cxx
index 80215acb8d06..d61036753434 100644
--- a/framework/source/uielement/objectmenucontroller.cxx
+++ b/framework/source/uielement/objectmenucontroller.cxx
@@ -23,19 +23,15 @@
#include <com/sun/star/embed/VerbDescriptor.hpp>
#include <svtools/popupmenucontrollerbase.hxx>
-#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
-#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
-using namespace framework;
namespace {
@@ -81,29 +77,20 @@ ObjectMenuController::ObjectMenuController( const css::uno::Reference< css::uno:
void ObjectMenuController::fillPopupMenu( const Sequence< css::embed::VerbDescriptor >& rVerbCommandSeq, Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
const css::embed::VerbDescriptor* pVerbCommandArray = rVerbCommandSeq.getConstArray();
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
SolarMutexGuard aSolarMutexGuard;
resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if ( !pVCLPopupMenu )
- return;
-
- const OUString aVerbCommand( ".uno:ObjectMenue?VerbID:short=" );
+ static constexpr OUStringLiteral aVerbCommand( u".uno:ObjectMenue?VerbID:short=" );
for ( sal_Int32 i = 0; i < rVerbCommandSeq.getLength(); i++ )
{
const css::embed::VerbDescriptor& rVerb = pVerbCommandArray[i];
if ( rVerb.VerbAttributes & css::embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU )
{
m_xPopupMenu->insertItem( i+1, rVerb.VerbName, 0, i );
- // use VCL popup menu pointer to set vital information that are not part of the awt implementation
-
OUString aCommand = aVerbCommand + OUString::number( rVerb.VerbID );
- pVCLPopupMenu->SetItemCommand( i+1, aCommand ); // Store verb command
+ m_xPopupMenu->setCommand( i+1, aCommand ); // Store verb command
}
}
}
@@ -111,14 +98,14 @@ void ObjectMenuController::fillPopupMenu( const Sequence< css::embed::VerbDescri
// XEventListener
void SAL_CALL ObjectMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -128,7 +115,7 @@ void SAL_CALL ObjectMenuController::statusChanged( const FeatureStateEvent& Even
Sequence < css::embed::VerbDescriptor > aVerbCommandSeq;
if ( Event.State >>= aVerbCommandSeq )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
if ( m_xPopupMenu.is() )
fillPopupMenu( aVerbCommandSeq, m_xPopupMenu );
}
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index 36ad65f19cc2..b17e8a6bfc60 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -27,8 +27,9 @@
#include <svtools/toolboxcontroller.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <toolkit/helper/vclunohelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
+#include <utility>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
@@ -70,7 +71,7 @@ public:
protected:
PopupMenuToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
- const OUString &rPopupCommand = OUString() );
+ OUString aPopupCommand = OUString() );
virtual void functionExecuted( const OUString &rCommand );
virtual ToolBoxItemBits getDropDownStyle() const;
void createPopupMenuController();
@@ -78,7 +79,7 @@ protected:
bool m_bHasController;
bool m_bResourceURL;
OUString m_aPopupCommand;
- css::uno::Reference< css::awt::XPopupMenu > m_xPopupMenu;
+ rtl::Reference< VCLXPopupMenu > m_xPopupMenu;
private:
css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuFactory;
@@ -87,11 +88,11 @@ private:
PopupMenuToolbarController::PopupMenuToolbarController(
const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const OUString &rPopupCommand )
+ OUString aPopupCommand )
: ToolBarBase( xContext, css::uno::Reference< css::frame::XFrame >(), /*aCommandURL*/OUString() )
, m_bHasController( false )
, m_bResourceURL( false )
- , m_aPopupCommand( rPopupCommand )
+ , m_aPopupCommand(std::move( aPopupCommand ))
{
}
@@ -150,7 +151,7 @@ void SAL_CALL PopupMenuToolbarController::initialize(
SolarMutexGuard aSolarLock;
ToolBox* pToolBox = nullptr;
- sal_uInt16 nItemId = 0;
+ ToolBoxItemId nItemId;
if ( getToolboxId( nItemId, &pToolBox ) )
{
ToolBoxItemBits nCurStyle( pToolBox->GetItemBits( nItemId ) );
@@ -169,7 +170,7 @@ void SAL_CALL PopupMenuToolbarController::statusChanged( const css::frame::Featu
return;
ToolBox* pToolBox = nullptr;
- sal_uInt16 nItemId = 0;
+ ToolBoxItemId nItemId;
if ( getToolboxId( nItemId, &pToolBox ) )
{
SolarMutexGuard aSolarLock;
@@ -192,7 +193,7 @@ PopupMenuToolbarController::createPopupWindow()
createPopupMenuController();
SolarMutexGuard aSolarLock;
- VclPtr< ToolBox > pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
+ VclPtr< ToolBox > pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
if ( !pToolBox )
return xRet;
@@ -239,23 +240,20 @@ void PopupMenuToolbarController::createPopupMenuController()
else
{
css::uno::Sequence<css::uno::Any> aArgs {
- css::uno::makeAny(comphelper::makePropertyValue("Frame", m_xFrame)),
- css::uno::makeAny(comphelper::makePropertyValue("ModuleIdentifier", m_sModuleName)),
- css::uno::makeAny(comphelper::makePropertyValue("InToolbar", true))
+ css::uno::Any(comphelper::makePropertyValue("Frame", m_xFrame)),
+ css::uno::Any(comphelper::makePropertyValue("ModuleIdentifier", m_sModuleName)),
+ css::uno::Any(comphelper::makePropertyValue("InToolbar", true))
};
try
{
- m_xPopupMenu.set(
- m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.awt.PopupMenu", m_xContext ),
- css::uno::UNO_QUERY_THROW );
+ m_xPopupMenu = new VCLXPopupMenu();
if (m_bResourceURL)
{
sal_Int32 nAppendIndex = aArgs.getLength();
aArgs.realloc(nAppendIndex + 1);
- aArgs[nAppendIndex] <<= comphelper::makePropertyValue("ResourceURL", m_aPopupCommand);
+ aArgs.getArray()[nAppendIndex] <<= comphelper::makePropertyValue("ResourceURL", m_aPopupCommand);
m_xPopupMenuController.set( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.framework.ResourceMenuController", aArgs, m_xContext), css::uno::UNO_QUERY_THROW );
@@ -352,22 +350,21 @@ void GenericPopupToolbarController::statusChanged( const css::frame::FeatureStat
if ( m_bReplaceWithLast && !rEvent.IsEnabled && m_xPopupMenu.is() )
{
- Menu* pVclMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu )->GetMenu();
-
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( getToolboxId( nId, &pToolBox ) && pToolBox->IsItemEnabled( nId ) )
{
+ Menu* pVclMenu = m_xPopupMenu->GetMenu();
pVclMenu->Activate();
pVclMenu->Deactivate();
}
- for ( sal_uInt16 i = 0; i < pVclMenu->GetItemCount(); ++i )
+ for (sal_uInt16 i = 0, nCount = m_xPopupMenu->getItemCount(); i < nCount; ++i )
{
- sal_uInt16 nItemId = pVclMenu->GetItemId( i );
- if ( nItemId && pVclMenu->IsItemEnabled( nItemId ) && !pVclMenu->GetPopupMenu( nItemId ) )
+ sal_uInt16 nItemId = m_xPopupMenu->getItemId(i);
+ if (nItemId && m_xPopupMenu->isItemEnabled(nItemId) && !m_xPopupMenu->getPopupMenu(nItemId).is())
{
- functionExecuted( pVclMenu->GetItemCommand( nItemId ) );
+ functionExecuted(m_xPopupMenu->getCommand(nItemId));
return;
}
}
@@ -389,7 +386,7 @@ void GenericPopupToolbarController::functionExecuted( const OUString& rCommand )
addStatusListener( m_aCommandURL );
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( getToolboxId( nId, &pToolBox ) )
{
pToolBox->SetItemCommand( nId, rCommand );
@@ -461,7 +458,7 @@ void SaveToolbarController::initialize( const css::uno::Sequence< css::uno::Any
PopupMenuToolbarController::initialize( aArguments );
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( !getToolboxId( nId, &pToolBox ) )
return;
@@ -504,7 +501,7 @@ void SaveToolbarController::updateImage()
{
SolarMutexGuard aGuard;
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( !getToolboxId( nId, &pToolBox ) )
return;
@@ -536,7 +533,7 @@ void SaveToolbarController::updateImage()
void SaveToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent )
{
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( !getToolboxId( nId, &pToolBox ) )
return;
@@ -693,12 +690,11 @@ void SAL_CALL NewToolbarController::execute( sal_Int16 /*KeyModifier*/ )
OUString aURL, aTarget;
if ( m_xPopupMenu.is() && m_nMenuId )
{
- // TODO investigate how to wrap Get/SetUserValue in css::awt::XMenu
SolarMutexGuard aSolarMutexGuard;
- Menu* pVclMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu )->GetMenu();
- aURL = pVclMenu->GetItemCommand( m_nMenuId );
+ aURL = m_xPopupMenu->getCommand(m_nMenuId);
- MenuAttributes* pMenuAttributes( static_cast<MenuAttributes*>( pVclMenu->GetUserValue( m_nMenuId ) ) );
+ // TODO investigate how to wrap Get/SetUserValue in css::awt::XMenu
+ MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(m_xPopupMenu->getUserValue(m_nMenuId)));
if ( pMenuAttributes )
aTarget = pMenuAttributes->aTargetFrame;
else
@@ -707,9 +703,8 @@ void SAL_CALL NewToolbarController::execute( sal_Int16 /*KeyModifier*/ )
else
aURL = m_aCommandURL;
- css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
- aArgs[0].Name = "Referer";
- aArgs[0].Value <<= OUString( "private:user" );
+ css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
+ "Referer", OUString( "private:user" )) };
dispatchCommand( aURL, aArgs, aTarget );
}
@@ -724,12 +719,11 @@ sal_uInt16 NewToolbarController::getMenuIdForCommand( std::u16string_view rComma
{
if ( m_xPopupMenu.is() && !rCommand.empty() )
{
- Menu* pVclMenu( comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu )->GetMenu() );
- sal_uInt16 nCount = pVclMenu->GetItemCount();
+ sal_uInt16 nCount = m_xPopupMenu->getItemCount();
for ( sal_uInt16 n = 0; n < nCount; ++n )
{
- sal_uInt16 nId = pVclMenu->GetItemId( n );
- OUString aCmd( pVclMenu->GetItemCommand( nId ) );
+ sal_uInt16 nId = m_xPopupMenu->getItemId(n);
+ OUString aCmd(m_xPopupMenu->getCommand(nId));
// match even if the menu command is more detailed
// (maybe an additional query) #i28667#
@@ -744,17 +738,15 @@ sal_uInt16 NewToolbarController::getMenuIdForCommand( std::u16string_view rComma
void SAL_CALL NewToolbarController::updateImage()
{
SolarMutexGuard aSolarLock;
- VclPtr< ToolBox> pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
+ VclPtr< ToolBox> pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
if ( !pToolBox )
return;
OUString aURL, aImageId;
if ( m_xPopupMenu.is() && m_nMenuId )
{
- Menu* pVclMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu )->GetMenu();
- aURL = pVclMenu->GetItemCommand( m_nMenuId );
-
- MenuAttributes* pMenuAttributes( static_cast<MenuAttributes*>( pVclMenu->GetUserValue( m_nMenuId ) ) );
+ aURL = m_xPopupMenu->getCommand(m_nMenuId);
+ MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(m_xPopupMenu->getUserValue(m_nMenuId)));
if ( pMenuAttributes )
aImageId = pMenuAttributes->aImageId;
}
diff --git a/framework/source/uielement/progressbarwrapper.cxx b/framework/source/uielement/progressbarwrapper.cxx
index 68e0220fb1bb..ad147111ff50 100644
--- a/framework/source/uielement/progressbarwrapper.cxx
+++ b/framework/source/uielement/progressbarwrapper.cxx
@@ -251,9 +251,7 @@ void SAL_CALL ProgressBarWrapper::update()
// XComponent
void SAL_CALL ProgressBarWrapper::dispose()
{
- uno::Reference< lang::XComponent > xThis(
- static_cast< cppu::OWeakObject* >(this),
- uno::UNO_QUERY );
+ uno::Reference< lang::XComponent > xThis(this);
{
SolarMutexGuard g;
@@ -296,12 +294,9 @@ uno::Reference< uno::XInterface > SAL_CALL ProgressBarWrapper::getRealInterface(
uno::Reference< uno::XInterface > xComp( m_xProgressBarIfacWrapper );
if ( !xComp.is() )
{
- StatusIndicatorInterfaceWrapper* pWrapper =
- new StatusIndicatorInterfaceWrapper(
- uno::Reference< lang::XComponent >(
- static_cast< cppu::OWeakObject* >( this ),
- uno::UNO_QUERY ));
- xComp.set(static_cast< cppu::OWeakObject* >( pWrapper ),
+ rtl::Reference<StatusIndicatorInterfaceWrapper> pWrapper =
+ new StatusIndicatorInterfaceWrapper( uno::Reference< lang::XComponent >(this) );
+ xComp.set(static_cast< cppu::OWeakObject* >( pWrapper.get() ),
uno::UNO_QUERY );
m_xProgressBarIfacWrapper = xComp;
}
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index 9e1d9d84bfdb..4355069c683d 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -20,14 +20,23 @@
#include <strings.hrc>
#include <classes/fwkresid.hxx>
+#include <comphelper/mimeconfighelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
+#include <svtools/imagemgr.hxx>
#include <svtools/popupmenucontrollerbase.hxx>
#include <tools/urlobj.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <unotools/historyoptions.hxx>
-#include <vcl/menu.hxx>
+#include <vcl/commandinfoprovider.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
+
+#include <officecfg/Office/Common.hxx>
using namespace css;
using namespace com::sun::star::uno;
@@ -37,12 +46,13 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::util;
#define MAX_MENU_ITEMS 99
+#define MAX_MENU_ITEMS_PER_MODULE 5
namespace {
-constexpr OUStringLiteral CMD_CLEAR_LIST = u".uno:ClearRecentFileList";
-constexpr OUStringLiteral CMD_OPEN_AS_TEMPLATE = u".uno:OpenTemplate";
-constexpr OUStringLiteral CMD_OPEN_REMOTE = u".uno:OpenRemote";
+constexpr OUString CMD_CLEAR_LIST = u".uno:ClearRecentFileList"_ustr;
+constexpr OUString CMD_OPEN_AS_TEMPLATE = u".uno:OpenTemplate"_ustr;
+constexpr OUString CMD_OPEN_REMOTE = u".uno:OpenRemote"_ustr;
class RecentFilesMenuController : public svt::PopupMenuControllerBase
{
@@ -89,7 +99,7 @@ private:
void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu );
void executeEntry( sal_Int32 nIndex );
- std::vector< OUString > m_aRecentFilesItems;
+ std::vector<std::pair<OUString, bool>> m_aRecentFilesItems;
bool m_bDisabled : 1;
bool m_bShowToolbarEntries;
};
@@ -112,48 +122,113 @@ RecentFilesMenuController::RecentFilesMenuController( const uno::Reference< uno:
}
}
+void InsertItem(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu,
+ const OUString& rCommand,
+ const css::uno::Reference<css::frame::XFrame>& rFrame)
+{
+ sal_uInt16 nItemId = rPopupMenu->getItemCount() + 1;
+
+ if (rFrame.is())
+ {
+ OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame));
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rCommand, aModuleName);
+ OUString aLabel(vcl::CommandInfoProvider::GetPopupLabelForCommand(aProperties));
+ OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(rCommand, aProperties, rFrame));
+ css::uno::Reference<css::graphic::XGraphic> xGraphic(vcl::CommandInfoProvider::GetXGraphicForCommand(rCommand, rFrame));
+
+ rPopupMenu->insertItem(nItemId, aLabel, 0, -1);
+ rPopupMenu->setItemImage(nItemId, xGraphic, false);
+ rPopupMenu->setHelpText(nItemId, aTooltip);
+ }
+ else
+ rPopupMenu->insertItem(nItemId, OUString(), 0, -1);
+
+ rPopupMenu->setCommand(nItemId, rCommand);
+}
+
+
// private function
void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- PopupMenu* pVCLPopupMenu = nullptr;
-
SolarMutexGuard aSolarMutexGuard;
resetPopupMenu( rPopupMenu );
- if ( pPopupMenu )
- pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if ( !pVCLPopupMenu )
- return;
+ std::vector< SvtHistoryOptions::HistoryItem > aHistoryList = SvtHistoryOptions::GetList( EHistoryType::PickList );
- Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( EHistoryType::PickList );
-
- int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.getLength(), MAX_MENU_ITEMS );
+ int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.size(), MAX_MENU_ITEMS );
m_aRecentFilesItems.clear();
+
+ // tdf#56696 - retrieve expert configuration option if the recent document
+ // list should show only files that can be handled by the current module
+ const bool bShowCurrentModuleOnly
+ = officecfg::Office::Common::History::ShowCurrentModuleOnly::get();
+
+ size_t nItemPosModule = 0;
+ size_t nItemPosPinned = 0;
if (( nPickListMenuItems > 0 ) && !m_bDisabled )
{
- for ( int i = 0; i < nPickListMenuItems; i++ )
+ size_t nItemPos = 0;
+
+ // tdf#155699 - create a lambda to insert a recent document item at a specified position
+ auto insertHistoryItemAtPos =
+ [&](const SvtHistoryOptions::HistoryItem& rPickListEntry, const size_t aInsertPosition)
+ {
+ m_aRecentFilesItems.insert(m_aRecentFilesItems.begin() + aInsertPosition,
+ { rPickListEntry.sURL, rPickListEntry.isReadOnly });
+ nItemPos++;
+ };
+
+ if (m_aModuleName != "com.sun.star.frame.StartModule")
{
- const Sequence< PropertyValue >& rPickListEntry = aHistoryList[i];
- OUString aURL;
+ ::comphelper::MimeConfigurationHelper aConfigHelper(
+ comphelper::getProcessComponentContext());
- for ( PropertyValue const & prop : rPickListEntry )
+ // Show the first MAX_MENU_ITEMS_PER_MODULE items of the current module
+ // on top of the recent document list.
+ for (int i = 0; i < nPickListMenuItems; i++)
{
- if ( prop.Name == HISTORY_PROPERTYNAME_URL )
+ const SvtHistoryOptions::HistoryItem& rPickListEntry = aHistoryList[i];
+
+ // tdf#155699 - insert pinned document at the beginning of the list
+ if (rPickListEntry.isPinned)
+ {
+ insertHistoryItemAtPos(rPickListEntry, nItemPosPinned);
+ nItemPosPinned++;
+ nItemPosModule++;
+ }
+ // tdf#56696 - insert documents of the current module
+ else if ((bShowCurrentModuleOnly
+ || (nItemPosModule - nItemPosPinned) < MAX_MENU_ITEMS_PER_MODULE)
+ && aConfigHelper.GetDocServiceNameFromFilter(rPickListEntry.sFilter)
+ == m_aModuleName)
{
- prop.Value >>= aURL;
- break;
+ insertHistoryItemAtPos(rPickListEntry, nItemPosModule);
+ nItemPosModule++;
}
+ // Insert all other documents at the end of the list if the expert option is not set
+ else if (!bShowCurrentModuleOnly)
+ insertHistoryItemAtPos(rPickListEntry, nItemPos);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < nPickListMenuItems; i++)
+ {
+ const SvtHistoryOptions::HistoryItem& rPickListEntry = aHistoryList[i];
+ // tdf#155699 - insert pinned document at the beginning of the list
+ insertHistoryItemAtPos(rPickListEntry,
+ rPickListEntry.isPinned ? nItemPosModule++ : nItemPos);
}
-
- m_aRecentFilesItems.push_back( aURL );
}
}
if ( !m_aRecentFilesItems.empty() )
{
const sal_uInt32 nCount = m_aRecentFilesItems.size();
+ StyleSettings aIconSettings;
+ bool bIsIconsAllowed = aIconSettings.GetUseImagesInMenus();
+
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
@@ -170,15 +245,14 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
}
else
{
- aMenuShortCut.append( sal_Int32( i + 1 ) );
- aMenuShortCut.append( ". " );
+ aMenuShortCut.append( OUString::number(sal_Int32( i + 1 ) ) + ". " );
}
OUString aURLString = "vnd.sun.star.popup:RecentFileList?entry=" + OUString::number(i);
// Abbreviate URL
OUString aMenuTitle;
- INetURLObject aURL( m_aRecentFilesItems[i] );
+ INetURLObject const aURL(m_aRecentFilesItems[i].first);
OUString aTipHelpText( aURL.getFSysPath( FSysStyle::Detect ) );
if ( aURL.GetProtocol() == INetProtocol::File )
@@ -194,42 +268,57 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
aMenuShortCut.append( aMenuTitle );
- pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aMenuShortCut.makeStringAndClear() );
- pVCLPopupMenu->SetTipHelpText( sal_uInt16( i+1 ), aTipHelpText );
- pVCLPopupMenu->SetItemCommand( sal_uInt16( i+1 ), aURLString );
+ rPopupMenu->insertItem(sal_uInt16( i+1 ), aMenuShortCut.makeStringAndClear(), 0, -1);
+
+ if ( bIsIconsAllowed ) {
+ // tdf#146219: don't use SvFileInformationManager::GetImageId,
+ // which needs to access the URL to detect if it's a directory
+ BitmapEx aThumbnail(SvFileInformationManager::GetFileImageId(aURL));
+ rPopupMenu->setItemImage(sal_uInt16(i + 1), Graphic(aThumbnail).GetXGraphic(), false);
+ }
+
+ rPopupMenu->setTipHelpText(sal_uInt16(i + 1), aTipHelpText);
+ rPopupMenu->setCommand(sal_uInt16(i + 1), aURLString);
+
+ // tdf#155699 - show a separator after the pinned recent document items
+ if (nItemPosPinned > 0 && i == nItemPosPinned - 1)
+ rPopupMenu->insertSeparator(-1);
+
+ // Show a separator after the MAX_MENU_ITEMS_PER_MODULE recent document items
+ if (nItemPosModule > 0 && i == nItemPosModule - 1)
+ rPopupMenu->insertSeparator(-1);
}
- pVCLPopupMenu->InsertSeparator();
+ rPopupMenu->insertSeparator(-1);
// Clear List menu entry
- pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 1 ),
- FwkResId(STR_CLEAR_RECENT_FILES) );
- pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 1 ),
- CMD_CLEAR_LIST );
- pVCLPopupMenu->SetHelpText( sal_uInt16( nCount + 1 ),
- FwkResId(STR_CLEAR_RECENT_FILES_HELP) );
+ rPopupMenu->insertItem(sal_uInt16(nCount + 1), FwkResId(STR_CLEAR_RECENT_FILES), 0, -1);
+ rPopupMenu->setCommand(sal_uInt16(nCount + 1), CMD_CLEAR_LIST);
+ rPopupMenu->setHelpText(sal_uInt16(nCount + 1), FwkResId(STR_CLEAR_RECENT_FILES_HELP));
// Open remote menu entry
if ( m_bShowToolbarEntries )
{
- pVCLPopupMenu->InsertSeparator();
- pVCLPopupMenu->InsertItem( CMD_OPEN_AS_TEMPLATE, m_xFrame );
- pVCLPopupMenu->InsertItem( CMD_OPEN_REMOTE, m_xFrame );
+ rPopupMenu->insertSeparator(-1);
+ InsertItem(rPopupMenu, CMD_OPEN_AS_TEMPLATE, m_xFrame);
+ InsertItem(rPopupMenu, CMD_OPEN_REMOTE, m_xFrame);
}
}
else
{
if ( m_bShowToolbarEntries )
{
- pVCLPopupMenu->InsertItem( CMD_OPEN_AS_TEMPLATE, m_xFrame );
- pVCLPopupMenu->InsertItem( CMD_OPEN_REMOTE, m_xFrame );
+ InsertItem(rPopupMenu, CMD_OPEN_AS_TEMPLATE, m_xFrame);
+ InsertItem(rPopupMenu, CMD_OPEN_REMOTE, m_xFrame);
}
else
{
- // No recent documents => insert "no document" string
- pVCLPopupMenu->InsertItem( 1, FwkResId(STR_NODOCUMENT) );
+ // Add InsertSeparator(), otherwise it will display
+ // the first item icon of recent files instead of displaying no icon.
+ rPopupMenu->insertSeparator(-1);
+ // No recent documents => insert "no documents" string
// Do not disable it, otherwise the Toolbar controller and MenuButton
// will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT
- pVCLPopupMenu->SetItemBits( 1, pVCLPopupMenu->GetItemBits( 1 ) | MenuItemBits::NOSELECT );
+ rPopupMenu->insertItem(1, FwkResId(STR_NODOCUMENT), static_cast<sal_Int16>(MenuItemBits::NOSELECT), -1);
}
}
}
@@ -240,39 +329,41 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
( nIndex >= sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() )))
return;
- Sequence< PropertyValue > aArgsList(3);
- aArgsList[0].Name = "Referer";
- aArgsList[0].Value <<= OUString( "private:user" );
-
- // documents in the picklist will never be opened as templates
- aArgsList[1].Name = "AsTemplate";
- aArgsList[1].Value <<= false;
+ Sequence< PropertyValue > aArgsList{
+ comphelper::makePropertyValue("Referer", OUString( "private:user" )),
- // Type detection needs to know which app we are opening it from.
- aArgsList[2].Name = "DocumentService";
- aArgsList[2].Value <<= m_aModuleName;
+ // documents in the picklist will never be opened as templates
+ comphelper::makePropertyValue("AsTemplate", false),
- dispatchCommand( m_aRecentFilesItems[ nIndex ], aArgsList, "_default" );
+ // Type detection needs to know which app we are opening it from.
+ comphelper::makePropertyValue("DocumentService", m_aModuleName)
+ };
+ if (m_aRecentFilesItems[nIndex].second) // tdf#149170 only add if true
+ {
+ aArgsList.realloc(aArgsList.size()+1);
+ aArgsList.getArray()[aArgsList.size()-1] = comphelper::makePropertyValue("ReadOnly", true);
+ }
+ dispatchCommand(m_aRecentFilesItems[nIndex].first, aArgsList, "_default");
}
// XEventListener
void SAL_CALL RecentFilesMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
// XStatusListener
void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent& Event )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_bDisabled = !Event.IsEnabled;
}
@@ -281,7 +372,7 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent
Reference< css::awt::XPopupMenu > xPopupMenu;
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
xPopupMenu = m_xPopupMenu;
}
@@ -292,7 +383,7 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent
if ( aCommand == CMD_CLEAR_LIST )
{
- SvtHistoryOptions().Clear( EHistoryType::PickList );
+ SvtHistoryOptions::Clear( EHistoryType::PickList, false );
dispatchCommand(
"vnd.org.libreoffice.recentdocs:ClearRecentFileList",
css::uno::Sequence< css::beans::PropertyValue >() );
@@ -313,7 +404,7 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent
void SAL_CALL RecentFilesMenuController::itemActivated( const css::awt::MenuEvent& )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
impl_setPopupMenu();
}
@@ -330,12 +421,12 @@ Reference< XDispatch > SAL_CALL RecentFilesMenuController::queryDispatch(
const OUString& /*sTarget*/,
sal_Int32 /*nFlags*/ )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
if ( aURL.Complete.startsWith( m_aBaseURL ) )
- return Reference< XDispatch >( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ return Reference< XDispatch >( this );
else
return Reference< XDispatch >();
}
@@ -345,9 +436,9 @@ void SAL_CALL RecentFilesMenuController::dispatch(
const URL& aURL,
const Sequence< PropertyValue >& /*seqProperties*/ )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
if ( !aURL.Complete.startsWith( m_aBaseURL ) )
return;
@@ -357,21 +448,21 @@ void SAL_CALL RecentFilesMenuController::dispatch(
if ( nQueryPart <= 0 )
return;
- const OUString aEntryArgStr( "entry=" );
+ static constexpr OUString aEntryArgStr( u"entry="_ustr );
sal_Int32 nEntryArg = aURL.Complete.indexOf( aEntryArgStr, nQueryPart );
sal_Int32 nEntryPos = nEntryArg + aEntryArgStr.getLength();
if (( nEntryArg <= 0 ) || ( nEntryPos >= aURL.Complete.getLength() ))
return;
sal_Int32 nAddArgs = aURL.Complete.indexOf( '&', nEntryPos );
- OUString aEntryArg;
+ std::u16string_view aEntryArg;
if ( nAddArgs < 0 )
- aEntryArg = aURL.Complete.copy( nEntryPos );
+ aEntryArg = aURL.Complete.subView( nEntryPos );
else
- aEntryArg = aURL.Complete.copy( nEntryPos, nAddArgs-nEntryPos );
+ aEntryArg = aURL.Complete.subView( nEntryPos, nAddArgs-nEntryPos );
- sal_Int32 nEntry = aEntryArg.toInt32();
+ sal_Int32 nEntry = o3tl::toInt32(aEntryArg);
executeEntry( nEntry );
}
diff --git a/framework/source/uielement/resourcemenucontroller.cxx b/framework/source/uielement/resourcemenucontroller.cxx
index 1094874bbcce..065a97c63a47 100644
--- a/framework/source/uielement/resourcemenucontroller.cxx
+++ b/framework/source/uielement/resourcemenucontroller.cxx
@@ -77,7 +77,7 @@ private:
css::uno::Reference< css::container::XIndexAccess > m_xMenuContainer;
css::uno::Reference< css::ui::XUIConfigurationManager > m_xConfigManager, m_xModuleConfigManager;
void addVerbs( const css::uno::Sequence< css::embed::VerbDescriptor >& rVerbs );
- virtual void SAL_CALL disposing() override;
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
protected:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
@@ -225,21 +225,21 @@ void ResourceMenuController::updatePopupMenu()
m_nNewMenuId = 1;
// Now fill the menu with the configuration data.
- framework::MenuBarManager::FillMenu( m_nNewMenuId, comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu )->GetMenu(), m_aModuleName, m_xMenuContainer, m_xDispatchProvider );
+ framework::MenuBarManager::FillMenu( m_nNewMenuId, m_xPopupMenu->GetMenu(), m_aModuleName, m_xMenuContainer, m_xDispatchProvider );
// For context menus, add object verbs.
- if ( m_bContextMenu )
+ if ( !m_bContextMenu )
+ return;
+
+ css::util::URL aObjectMenuURL;
+ aObjectMenuURL.Complete = ".uno:ObjectMenue";
+ m_xURLTransformer->parseStrict( aObjectMenuURL );
+ css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY );
+ css::uno::Reference< css::frame::XDispatch > xDispatch( xDispatchProvider->queryDispatch( aObjectMenuURL, OUString(), 0 ) );
+ if ( xDispatch.is() )
{
- css::util::URL aObjectMenuURL;
- aObjectMenuURL.Complete = ".uno:ObjectMenue";
- m_xURLTransformer->parseStrict( aObjectMenuURL );
- css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY );
- css::uno::Reference< css::frame::XDispatch > xDispatch( xDispatchProvider->queryDispatch( aObjectMenuURL, OUString(), 0 ) );
- if ( xDispatch.is() )
- {
- xDispatch->addStatusListener( this, aObjectMenuURL );
- xDispatch->removeStatusListener( this, aObjectMenuURL );
- }
+ xDispatch->addStatusListener( this, aObjectMenuURL );
+ xDispatch->removeStatusListener( this, aObjectMenuURL );
}
}
@@ -259,8 +259,7 @@ void ResourceMenuController::addVerbs( const css::uno::Sequence< css::embed::Ver
xStorable.set( xController->getModel(), css::uno::UNO_QUERY );
bool bReadOnly = xStorable.is() && xStorable->isReadonly();
- VCLXMenu* pAwtMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu );
- Menu* pVCLMenu = pAwtMenu->GetMenu();
+ Menu* pVCLMenu = m_xPopupMenu->GetMenu();
for ( const auto& rVerb : rVerbs )
{
@@ -279,10 +278,9 @@ void ResourceMenuController::itemActivated( const css::awt::MenuEvent& /*rEvent*
// Must initialize MenuBarManager here, because we want to let the app do context menu interception before.
if ( !m_xMenuBarManager.is() )
{
- VCLXMenu* pAwtMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu );
m_xMenuBarManager.set( new framework::MenuBarManager(
- m_xContext, m_xFrame, m_xURLTransformer, m_xDispatchProvider, m_aModuleName, pAwtMenu->GetMenu(), false, !m_bContextMenu && !m_bInToolbar ) );
- m_xFrame->addFrameActionListener( m_xMenuBarManager.get() );
+ m_xContext, m_xFrame, m_xURLTransformer, m_xDispatchProvider, m_aModuleName, m_xPopupMenu->GetMenu(), false, !m_bContextMenu && !m_bInToolbar ) );
+ m_xFrame->addFrameActionListener( m_xMenuBarManager );
}
}
@@ -317,6 +315,9 @@ void ResourceMenuController::disposing( const css::lang::EventObject& rEvent )
{
if ( m_xMenuBarManager.is() )
{
+ if (m_xFrame.is())
+ m_xFrame->removeFrameActionListener( m_xMenuBarManager );
+
m_xMenuBarManager->dispose();
m_xMenuBarManager.clear();
}
@@ -324,7 +325,7 @@ void ResourceMenuController::disposing( const css::lang::EventObject& rEvent )
}
}
-void ResourceMenuController::disposing()
+void ResourceMenuController::disposing(std::unique_lock<std::mutex>& rGuard)
{
css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY );
if ( xConfig.is() )
@@ -340,11 +341,14 @@ void ResourceMenuController::disposing()
m_xDispatchProvider.clear();
if ( m_xMenuBarManager.is() )
{
+ if (m_xFrame.is())
+ m_xFrame->removeFrameActionListener( m_xMenuBarManager );
+
m_xMenuBarManager->dispose();
m_xMenuBarManager.clear();
}
- svt::PopupMenuControllerBase::disposing();
+ svt::PopupMenuControllerBase::disposing(rGuard);
}
OUString ResourceMenuController::getImplementationName()
@@ -379,24 +383,24 @@ SaveAsMenuController::SaveAsMenuController( const css::uno::Reference< css::uno:
{
}
-void SaveAsMenuController::impl_setPopupMenu()
+void InsertItem(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu,
+ const OUString& rCommand)
{
- VCLXMenu* pPopupMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu );
- Menu* pVCLPopupMenu = nullptr;
+ sal_uInt16 nItemId = rPopupMenu->getItemCount() + 1;
+ rPopupMenu->insertItem(nItemId, OUString(), 0, -1);
+ rPopupMenu->setCommand(nItemId, rCommand);
+}
+void SaveAsMenuController::impl_setPopupMenu()
+{
SolarMutexGuard aGuard;
- if ( pPopupMenu )
- pVCLPopupMenu = pPopupMenu->GetMenu();
-
- if ( !pVCLPopupMenu )
- return;
-
- pVCLPopupMenu->InsertItem( ".uno:SaveAs", nullptr );
- pVCLPopupMenu->InsertItem( ".uno:ExportTo", nullptr );
- pVCLPopupMenu->InsertItem( ".uno:SaveAsTemplate", nullptr );
- pVCLPopupMenu->InsertSeparator();
- pVCLPopupMenu->InsertItem( ".uno:SaveAsRemote", nullptr );
+ InsertItem(m_xPopupMenu, ".uno:SaveAs");
+ InsertItem(m_xPopupMenu, ".uno:ExportTo");
+ InsertItem(m_xPopupMenu, ".uno:SaveACopy");
+ InsertItem(m_xPopupMenu, ".uno:SaveAsTemplate");
+ m_xPopupMenu->insertSeparator(-1);
+ InsertItem(m_xPopupMenu, ".uno:SaveAsRemote");
}
OUString SaveAsMenuController::getImplementationName()
@@ -469,8 +473,7 @@ void WindowListMenuController::itemActivated( const css::awt::MenuEvent& rEvent
{
SolarMutexGuard g;
- VCLXMenu* pAwtMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu );
- Menu* pVCLMenu = pAwtMenu->GetMenu();
+ Menu* pVCLMenu = m_xPopupMenu->GetMenu();
int nItemCount = pVCLMenu->GetItemCount();
if ( nItemCount > 0 )
@@ -503,29 +506,28 @@ void WindowListMenuController::itemActivated( const css::awt::MenuEvent& rEvent
void WindowListMenuController::itemSelected( const css::awt::MenuEvent& rEvent )
{
- if ( rEvent.MenuId >= START_ITEMID_WINDOWLIST &&
- rEvent.MenuId <= END_ITEMID_WINDOWLIST )
- {
- // window list menu item selected
- css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create( m_xContext );
+ if ( rEvent.MenuId < START_ITEMID_WINDOWLIST || rEvent.MenuId > END_ITEMID_WINDOWLIST )
+ return;
- sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST;
- css::uno::Reference< css::container::XIndexAccess > xList = xDesktop->getFrames();
- sal_Int32 nCount = xList->getCount();
- for ( sal_Int32 i=0; i<nCount; ++i )
- {
- css::uno::Reference< css::frame::XFrame > xFrame;
- xList->getByIndex(i) >>= xFrame;
- if ( xFrame.is() && nTaskId == rEvent.MenuId )
- {
- VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
- pWin->GrabFocus();
- pWin->ToTop( ToTopFlags::RestoreWhenMin );
- break;
- }
+ // window list menu item selected
+ css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create( m_xContext );
- nTaskId++;
+ sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST;
+ css::uno::Reference< css::container::XIndexAccess > xList = xDesktop->getFrames();
+ sal_Int32 nCount = xList->getCount();
+ for ( sal_Int32 i=0; i<nCount; ++i )
+ {
+ css::uno::Reference< css::frame::XFrame > xFrame;
+ xList->getByIndex(i) >>= xFrame;
+ if ( xFrame.is() && nTaskId == rEvent.MenuId )
+ {
+ VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
+ pWin->GrabFocus();
+ pWin->ToTop( ToTopFlags::RestoreWhenMin );
+ break;
}
+
+ nTaskId++;
}
}
diff --git a/framework/source/uielement/spinfieldtoolbarcontroller.cxx b/framework/source/uielement/spinfieldtoolbarcontroller.cxx
index d76db7516c88..8e72b81e3422 100644
--- a/framework/source/uielement/spinfieldtoolbarcontroller.cxx
+++ b/framework/source/uielement/spinfieldtoolbarcontroller.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <vcl/event.hxx>
@@ -36,9 +37,7 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
namespace framework
{
@@ -168,7 +167,7 @@ SpinfieldToolbarController::SpinfieldToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
sal_Int32 nWidth,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
@@ -206,18 +205,14 @@ void SAL_CALL SpinfieldToolbarController::dispose()
Sequence<PropertyValue> SpinfieldToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 2 );
OUString aSpinfieldText = m_pSpinfieldControl->get_entry_text();
// Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Value";
- if ( m_bFloat )
- aArgs[1].Value <<= aSpinfieldText.toDouble();
- else
- aArgs[1].Value <<= aSpinfieldText.toInt32();
- return aArgs;
+ return {
+ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Value", m_bFloat ? Any(aSpinfieldText.toDouble())
+ : Any(aSpinfieldText.toInt32()))
+ };
}
void SpinfieldToolbarController::Modify()
@@ -260,7 +255,7 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
double fValue;
bool bFloat( false );
if ( impl_getValue( arg.Value, nValue, fValue, bFloat ))
- aStep = bFloat ? OUString( OUString::number( fValue )) :
+ aStep = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
break;
}
@@ -278,7 +273,7 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
if ( impl_getValue( arg.Value, nValue, fValue, bFloat ))
{
- aValue = bFloat ? OUString( OUString::number( fValue )) :
+ aValue = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
bFloatValue = bFloat;
}
@@ -299,18 +294,18 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
{
if ( aName == "Value" )
{
- aValue = bFloat ? OUString( OUString::number( fValue )) :
+ aValue = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
bFloatValue = bFloat;
}
else if ( aName == "Step" )
- aStep = bFloat ? OUString( OUString::number( fValue )) :
+ aStep = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
else if ( aName == "LowerLimit" )
- aMin = bFloat ? OUString( OUString::number( fValue )) :
+ aMin = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
else if ( aName == "UpperLimit" )
- aMax = bFloat ? OUString( OUString::number( fValue )) :
+ aMax = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
}
else if ( aName == "OutputFormat" )
@@ -327,7 +322,7 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
double fValue;
bool bFloat( false );
if ( impl_getValue( arg.Value, nValue, fValue, bFloat ))
- aMin = bFloat ? OUString( OUString::number( fValue )) :
+ aMin = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
break;
}
@@ -343,7 +338,7 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
double fValue;
bool bFloat( false );
if ( impl_getValue( arg.Value, nValue, fValue, bFloat ))
- aMax = bFloat ? OUString( OUString::number( fValue )) :
+ aMax = bFloat ? OUString::number( fValue ) :
OUString( OUString::number( nValue ));
break;
}
@@ -389,6 +384,7 @@ void SpinfieldToolbarController::executeControlCommand( const css::frame::Contro
}
}
+// static
bool SpinfieldToolbarController::impl_getValue(
const Any& rAny, sal_Int32& nValue, double& fValue, bool& bFloat )
{
@@ -445,7 +441,7 @@ OUString SpinfieldToolbarController::FormatOutputString( double fValue )
snprintf( aBuffer, 128, aFormat.getStr(), static_cast<tools::Long>( fValue ));
sal_Int32 nSize = strlen( aBuffer );
- OString aTmp( aBuffer, nSize );
+ std::string_view aTmp( aBuffer, nSize );
return OStringToOUString( aTmp, osl_getThreadTextEncoding() );
#endif
}
diff --git a/framework/source/uielement/statusbaritem.cxx b/framework/source/uielement/statusbaritem.cxx
index a453f0079fc0..d9c4b2ccfd21 100644
--- a/framework/source/uielement/statusbaritem.cxx
+++ b/framework/source/uielement/statusbaritem.cxx
@@ -18,6 +18,7 @@
*/
#include <uielement/statusbaritem.hxx>
+#include <utility>
#include <vcl/status.hxx>
#include <vcl/svapp.hxx>
@@ -61,12 +62,11 @@ sal_uInt16 impl_convertItemBitsToItemStyle( StatusBarItemBits nItemBits )
StatusbarItem::StatusbarItem(
StatusBar *pStatusBar,
sal_uInt16 nId,
- const OUString& aCommand )
- : StatusbarItem_Base( m_aMutex )
- , m_pStatusBar( pStatusBar )
+ OUString aCommand )
+ : m_pStatusBar( pStatusBar )
, m_nId( nId )
, m_nStyle( 0 )
- , m_aCommand( aCommand )
+ , m_aCommand(std::move( aCommand ))
{
if ( m_pStatusBar )
m_nStyle = impl_convertItemBitsToItemStyle(
@@ -77,21 +77,18 @@ StatusbarItem::~StatusbarItem()
{
}
-void SAL_CALL StatusbarItem::disposing()
+void StatusbarItem::disposing(std::unique_lock<std::mutex>&)
{
- osl::MutexGuard aGuard( m_aMutex );
m_pStatusBar = nullptr;
}
OUString SAL_CALL StatusbarItem::getCommand()
{
- osl::MutexGuard aGuard( m_aMutex );
return m_aCommand;
}
::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
{
- osl::MutexGuard aGuard( m_aMutex );
return m_nId;
}
@@ -106,7 +103,7 @@ OUString SAL_CALL StatusbarItem::getCommand()
::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
return m_nStyle;
}
diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx
index 6c417903b807..be6840a1cc33 100644
--- a/framework/source/uielement/statusbarmanager.cxx
+++ b/framework/source/uielement/statusbarmanager.cxx
@@ -34,11 +34,13 @@
#include <com/sun/star/awt/Command.hpp>
#include <com/sun/star/ui/XStatusbarItem.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/statusbarcontroller.hxx>
#include <tools/debug.hxx>
+#include <utility>
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/status.hxx>
@@ -120,16 +122,15 @@ StatusBarItemBits impl_convertItemStyleToItemBits( sal_Int16 nStyle )
}
StatusBarManager::StatusBarManager(
- const uno::Reference< uno::XComponentContext >& rxContext,
- const uno::Reference< frame::XFrame >& rFrame,
+ uno::Reference< uno::XComponentContext > xContext,
+ uno::Reference< frame::XFrame > rFrame,
StatusBar* pStatusBar ) :
m_bDisposed( false ),
m_bFrameActionRegistered( false ),
m_bUpdateControllers( false ),
m_pStatusBar( pStatusBar ),
- m_xFrame( rFrame ),
- m_aListenerContainer( m_mutex ),
- m_xContext( rxContext )
+ m_xFrame(std::move( rFrame )),
+ m_xContext(std::move( xContext ))
{
m_xStatusbarControllerFactory = frame::theStatusbarControllerFactory::get(
@@ -175,13 +176,14 @@ void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source )
// XComponent
void SAL_CALL StatusBarManager::dispose()
{
- uno::Reference< lang::XComponent > xThis(
- static_cast< OWeakObject* >(this), uno::UNO_QUERY );
-
- lang::EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
+ uno::Reference< lang::XComponent > xThis(this );
{
+ lang::EventObject aEvent( xThis );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.disposeAndClear( aGuard, aEvent );
+ }
+ {
SolarMutexGuard g;
if ( m_bDisposed )
return;
@@ -202,9 +204,7 @@ void SAL_CALL StatusBarManager::dispose()
{
try
{
- m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(
- static_cast< ::cppu::OWeakObject *>( this ),
- uno::UNO_QUERY ));
+ m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(this) );
}
catch ( const uno::Exception& )
{
@@ -226,12 +226,14 @@ void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XE
if ( m_bDisposed )
throw lang::DisposedException();
- m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.addInterface( aGuard, xListener );
}
void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.removeInterface( aGuard, xListener );
}
// XUIConfigurationListener
@@ -296,42 +298,21 @@ void StatusBarManager::CreateControllers()
bool bInit( true );
uno::Reference< frame::XStatusbarController > xController;
AddonStatusbarItemData *pItemData = static_cast< AddonStatusbarItemData *>( m_pStatusBar->GetItemData( nId ) );
- uno::Reference< ui::XStatusbarItem > xStatusbarItem(
- static_cast< cppu::OWeakObject *>( new StatusbarItem( m_pStatusBar, nId, aCommandURL ) ),
- uno::UNO_QUERY );
-
- beans::PropertyValue aPropValue;
- std::vector< uno::Any > aPropVector;
-
- aPropValue.Name = "CommandURL";
- aPropValue.Value <<= aCommandURL;
- aPropVector.push_back( uno::makeAny( aPropValue ) );
+ uno::Reference< ui::XStatusbarItem > xStatusbarItem = new StatusbarItem( m_pStatusBar, nId, aCommandURL );
- aPropValue.Name = "ModuleIdentifier";
- aPropValue.Value <<= OUString();
- aPropVector.push_back( uno::makeAny( aPropValue ) );
-
- aPropValue.Name = "Frame";
- aPropValue.Value <<= m_xFrame;
- aPropVector.push_back( uno::makeAny( aPropValue ) );
-
- // TODO remove this
- aPropValue.Name = "ServiceManager";
- aPropValue.Value <<= uno::Reference<lang::XMultiServiceFactory>(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
- aPropVector.push_back( uno::makeAny( aPropValue ) );
-
- aPropValue.Name = "ParentWindow";
- aPropValue.Value <<= xStatusbarWindow;
- aPropVector.push_back( uno::makeAny( aPropValue ) );
+ std::vector< uno::Any > aPropVector
+ {
+ uno::Any(comphelper::makePropertyValue("CommandURL", aCommandURL)),
+ uno::Any(comphelper::makePropertyValue("ModuleIdentifier", u""_ustr)),
+ uno::Any(comphelper::makePropertyValue("Frame", m_xFrame)),
- // TODO still needing with the css::ui::XStatusbarItem?
- aPropValue.Name = "Identifier";
- aPropValue.Value <<= nId;
- aPropVector.push_back( uno::makeAny( aPropValue ) );
+ // TODO remove this
+ uno::Any(comphelper::makePropertyValue("ServiceManager", uno::Reference<lang::XMultiServiceFactory>(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW))),
- aPropValue.Name = "StatusbarItem";
- aPropValue.Value <<= xStatusbarItem;
- aPropVector.push_back( uno::makeAny( aPropValue ) );
+ uno::Any(comphelper::makePropertyValue("ParentWindow", xStatusbarWindow)),
+ uno::Any(comphelper::makePropertyValue("Identifier", nId)),
+ uno::Any(comphelper::makePropertyValue("StatusbarItem", xStatusbarItem))
+ };
uno::Sequence< uno::Any > aArgs( comphelper::containerToSequence( aPropVector ) );
@@ -348,13 +329,13 @@ void StatusBarManager::CreateControllers()
if ( !xController.is() )
{
// 2) Old SFX2 Statusbar controllers
- svt::StatusbarController* pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
- if ( !pController )
+ xController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
+ if ( !xController )
{
// 3) Is Add-on? Generic statusbar controller
if ( pItemData )
{
- pController = new GenericStatusbarController( m_xContext,
+ xController = new GenericStatusbarController( m_xContext,
m_xFrame,
xStatusbarItem,
pItemData );
@@ -362,11 +343,9 @@ void StatusBarManager::CreateControllers()
else
{
// 4) Default Statusbar controller
- pController = new svt::StatusbarController( m_xContext, m_xFrame, aCommandURL, nId );
+ xController = new svt::StatusbarController( m_xContext, m_xFrame, aCommandURL, nId );
}
}
-
- xController = pController;
}
m_aControllerMap[nId] = xController;
@@ -380,8 +359,7 @@ void StatusBarManager::CreateControllers()
if ( !m_bFrameActionRegistered && m_xFrame.is() )
{
m_bFrameActionRegistered = true;
- m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(
- static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY ));
+ m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(this) );
}
}
@@ -413,7 +391,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc
{
if ( rItemContainer->getByIndex( n ) >>= aProps )
{
- for ( beans::PropertyValue const & prop : std::as_const(aProps) )
+ for (beans::PropertyValue const& prop : aProps)
{
if ( prop.Name == "CommandURL" )
{
diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx
index 38e266009aca..c8e6633be9f0 100644
--- a/framework/source/uielement/statusbarmerger.cxx
+++ b/framework/source/uielement/statusbarmerger.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <uielement/statusbarmerger.hxx>
+#include <o3tl/string_view.hxx>
using com::sun::star::beans::PropertyValue;
using com::sun::star::uno::Sequence;
@@ -135,9 +136,9 @@ bool lcl_ReplaceItem( StatusBar* pStatusbar,
bool lcl_RemoveItems( StatusBar* pStatusbar,
sal_uInt16 nPos,
- const OUString& rMergeCommandParameter )
+ std::u16string_view rMergeCommandParameter )
{
- sal_Int32 nCount = rMergeCommandParameter.toInt32();
+ sal_Int32 nCount = o3tl::toInt32(rMergeCommandParameter);
if ( nCount > 0 )
{
for ( sal_Int32 i = 0; i < nCount; i++ )
@@ -190,7 +191,7 @@ bool StatusbarMerger::ProcessMergeOperation(
sal_uInt16 nPos,
sal_uInt16& rItemId,
std::u16string_view rMergeCommand,
- const OUString& rMergeCommandParameter,
+ std::u16string_view rMergeCommandParameter,
const AddonStatusbarItemContainer& rItems )
{
if ( rMergeCommand == MERGECOMMAND_ADDAFTER )
diff --git a/framework/source/uielement/statusbarwrapper.cxx b/framework/source/uielement/statusbarwrapper.cxx
index f22736f796a4..e8c6dc9d1bf0 100644
--- a/framework/source/uielement/statusbarwrapper.cxx
+++ b/framework/source/uielement/statusbarwrapper.cxx
@@ -26,10 +26,11 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/solar.h>
+#include <utility>
#include <vcl/svapp.hxx>
+#include <vcl/wintypes.hxx>
using namespace com::sun::star::uno;
-using namespace com::sun::star::beans;
using namespace com::sun::star::frame;
using namespace com::sun::star::lang;
using namespace com::sun::star::container;
@@ -40,10 +41,10 @@ namespace framework
{
StatusBarWrapper::StatusBarWrapper(
- const css::uno::Reference< css::uno::XComponentContext >& rxContext
+ css::uno::Reference< css::uno::XComponentContext > xContext
)
: UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
- m_xContext( rxContext )
+ m_xContext(std::move( xContext ))
{
}
@@ -53,14 +54,14 @@ StatusBarWrapper::~StatusBarWrapper()
void SAL_CALL StatusBarWrapper::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
css::lang::EventObject aEvent( xThis );
m_aListenerContainer.disposeAndClear( aEvent );
SolarMutexGuard g;
if ( m_bDisposed )
- throw DisposedException();
+ return;
if ( m_xStatusBarManager.is() )
m_xStatusBarManager->dispose();
@@ -92,18 +93,18 @@ void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments )
// Create VCL based toolbar which will be filled with settings data
StatusBar* pStatusBar( nullptr );
- StatusBarManager* pStatusBarManager( nullptr );
+ rtl::Reference<StatusBarManager> pStatusBarManager;
{
SolarMutexGuard aSolarMutexGuard;
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
if ( pWindow )
{
- sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
+ WinBits nStyles = WinBits( WB_LEFT | WB_3DLOOK );
pStatusBar = VclPtr<FrameworkStatusBar>::Create( pWindow, nStyles );
pStatusBarManager = new StatusBarManager( m_xContext, xFrame, pStatusBar );
- static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager );
- m_xStatusBarManager.set( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
+ static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager.get() );
+ m_xStatusBarManager = pStatusBarManager;
}
}
@@ -136,11 +137,9 @@ void SAL_CALL StatusBarWrapper::updateSettings()
try
{
- StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
-
m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
if ( m_xConfigData.is() )
- pStatusBarManager->FillStatusBar( m_xConfigData );
+ m_xStatusBarManager->FillStatusBar( m_xConfigData );
}
catch ( const NoSuchElementException& )
{
@@ -151,15 +150,11 @@ Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface()
{
SolarMutexGuard g;
- if ( m_xStatusBarManager.is() )
+ if ( m_xStatusBarManager )
{
- StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
- if ( pStatusBarManager )
- {
- vcl::Window* pWindow = pStatusBarManager->GetStatusBar();
- if ( pWindow )
- return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
- }
+ vcl::Window* pWindow = m_xStatusBarManager->GetStatusBar();
+ if ( pWindow )
+ return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
}
return Reference< XInterface >();
diff --git a/framework/source/uielement/statusindicatorinterfacewrapper.cxx b/framework/source/uielement/statusindicatorinterfacewrapper.cxx
index ba796036b0dd..6082f2aa5c3f 100644
--- a/framework/source/uielement/statusindicatorinterfacewrapper.cxx
+++ b/framework/source/uielement/statusindicatorinterfacewrapper.cxx
@@ -23,7 +23,6 @@
using namespace cppu;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
namespace framework
{
diff --git a/framework/source/uielement/styletoolbarcontroller.cxx b/framework/source/uielement/styletoolbarcontroller.cxx
index a5c2715095ec..3ff1e777eb6d 100644
--- a/framework/source/uielement/styletoolbarcontroller.cxx
+++ b/framework/source/uielement/styletoolbarcontroller.cxx
@@ -10,9 +10,11 @@
#include <uielement/styletoolbarcontroller.hxx>
#include <tools/urlobj.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/status/Template.hpp>
@@ -32,7 +34,8 @@ OUString MapFamilyToCommand( std::u16string_view rFamily )
return ".uno:CharStyle";
else if ( rFamily == u"PageStyles" )
return ".uno:PageStyle";
- else if ( rFamily == u"FrameStyles" )
+ else if ( rFamily == u"FrameStyles" ||
+ rFamily == u"GraphicStyles" ) // In sc
return ".uno:FrameStyle";
else if ( rFamily == u"NumberingStyles" )
return ".uno:ListStyle";
@@ -79,10 +82,10 @@ OUString GetDisplayFromInternalName( const css::uno::Reference< css::frame::XFra
namespace framework {
StyleDispatcher::StyleDispatcher( const css::uno::Reference< css::frame::XFrame >& rFrame,
- const css::uno::Reference< css::util::XURLTransformer >& rUrlTransformer,
+ css::uno::Reference< css::util::XURLTransformer > xUrlTransformer,
const css::util::URL& rURL )
: m_aCommand( rURL.Complete )
- , m_xUrlTransformer( rUrlTransformer )
+ , m_xUrlTransformer(std::move( xUrlTransformer ))
, m_xFrame( rFrame, css::uno::UNO_QUERY )
{
SAL_WARN_IF( !m_aCommand.startsWith( ".uno:StyleApply?" ), "fwk.uielement", "Wrong dispatcher!" );
@@ -92,21 +95,21 @@ StyleDispatcher::StyleDispatcher( const css::uno::Reference< css::frame::XFrame
sal_Int32 nIndex = 0;
do
{
- OUString aParam = aParams.getToken( 0, '&', nIndex );
+ std::u16string_view aParam = o3tl::getToken(aParams, 0, '&', nIndex );
sal_Int32 nParamIndex = 0;
- OUString aParamName = aParam.getToken( 0, '=', nParamIndex );
+ std::u16string_view aParamName = o3tl::getToken(aParam, 0, '=', nParamIndex );
if ( nParamIndex < 0 )
break;
- if ( aParamName == "Style:string" )
+ if ( aParamName == u"Style:string" )
{
- OUString aValue = aParam.getToken( 0, '=', nParamIndex );
+ std::u16string_view aValue = o3tl::getToken(aParam, 0, '=', nParamIndex );
aStyleName = INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset );
}
- else if ( aParamName == "FamilyName:string" )
+ else if ( aParamName == u"FamilyName:string" )
{
- aFamilyName = aParam.getToken( 0, '=', nParamIndex );
+ aFamilyName = o3tl::getToken(aParam, 0, '=', nParamIndex );
}
} while ( nIndex >= 0 );
@@ -220,7 +223,7 @@ void StyleToolbarController::statusChanged( const css::frame::FeatureStateEvent&
throw css::lang::DisposedException();
ToolBox* pToolBox = nullptr;
- sal_uInt16 nItemId = 0;
+ ToolBoxItemId nItemId;
if ( getToolboxId( nItemId, &pToolBox ) )
{
bool bChecked = false;
diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx
index 6dcd8b67404a..b04b9609e709 100644
--- a/framework/source/uielement/subtoolbarcontroller.cxx
+++ b/framework/source/uielement/subtoolbarcontroller.cxx
@@ -21,12 +21,14 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weakref.hxx>
-#include <svtools/toolboxcontroller.hxx>
+#include <svtools/popupwindowcontroller.hxx>
+#include <svtools/toolbarmenu.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/gen.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/commandinfoprovider.hxx>
+#include <vcl/weldutils.hxx>
#include <com/sun/star/awt/XDockableWindow.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
@@ -36,10 +38,9 @@
#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
-typedef cppu::ImplInheritanceHelper< svt::ToolboxController,
+typedef cppu::ImplInheritanceHelper< svt::PopupWindowController,
css::frame::XSubToolbarController,
- css::awt::XDockableWindowListener,
- css::lang::XServiceInfo > ToolBarBase;
+ css::awt::XDockableWindowListener> ToolBarBase;
namespace {
@@ -50,9 +51,12 @@ class SubToolBarController : public ToolBarBase
css::uno::Reference< css::ui::XUIElement > m_xUIElement;
void disposeUIElement();
public:
- explicit SubToolBarController( const css::uno::Sequence< css::uno::Any >& rxArgs );
+ explicit SubToolBarController( const rtl::Reference< com::sun::star::uno::XComponentContext >& rxContext,
+ const css::uno::Sequence< css::uno::Any >& rxArgs );
virtual ~SubToolBarController() override;
+ void PopoverDestroyed();
+
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rxArgs ) override;
@@ -61,7 +65,10 @@ public:
// XToolbarController
virtual void SAL_CALL execute( sal_Int16 nKeyModifier ) override;
- virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override;
+
+ // PopupWindowController
+ virtual VclPtr<vcl::Window> createVclPopupWindow(vcl::Window* pParent) override;
+ virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
// XSubToolbarController
virtual sal_Bool SAL_CALL opensSubToolbar() override;
@@ -92,7 +99,14 @@ public:
}
-SubToolBarController::SubToolBarController( const css::uno::Sequence< css::uno::Any >& rxArgs )
+SubToolBarController::SubToolBarController(
+ const rtl::Reference< com::sun::star::uno::XComponentContext >& rxContext,
+ const css::uno::Sequence< css::uno::Any >& rxArgs
+) : ToolBarBase(
+ rxContext,
+ rtl::Reference< css::frame::XFrame >(),
+ ""
+ )
{
for ( css::uno::Any const & arg : rxArgs )
{
@@ -104,6 +118,7 @@ SubToolBarController::SubToolBarController( const css::uno::Sequence< css::uno::
OUString aValue;
aPropValue.Value >>= aValue;
m_aSubTbName = aValue.getToken(0, ';', nIdx);
+ m_aCommandURL = m_aSubTbName;
m_aLastCommand = aValue.getToken(0, ';', nIdx);
break;
}
@@ -135,7 +150,7 @@ void SubToolBarController::statusChanged( const css::frame::FeatureStateEvent& E
return;
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( !getToolboxId( nId, &pToolBox ) )
return;
@@ -153,7 +168,7 @@ void SubToolBarController::statusChanged( const css::frame::FeatureStateEvent& E
{
// Enum command, such as the current custom shape,
// toggle checked state.
- if ( m_aLastCommand == ( m_aCommandURL + "." + aStrValue ) )
+ if ( m_aLastCommand == Concat2View( m_aCommandURL + "." + aStrValue ) )
{
eTri = TRISTATE_TRUE;
nItemBits |= ToolBoxItemBits::CHECKABLE;
@@ -185,18 +200,91 @@ void SubToolBarController::execute( sal_Int16 nKeyModifier )
if ( !m_aLastCommand.isEmpty() )
{
auto aArgs( comphelper::InitPropertySequence( {
- { "KeyModifier", css::uno::makeAny( nKeyModifier ) }
+ { "KeyModifier", css::uno::Any( nKeyModifier ) }
} ) );
dispatchCommand( m_aLastCommand, aArgs );
}
}
-css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow()
+namespace {
+class SubToolbarControl final : public WeldToolbarPopup
+{
+public:
+ explicit SubToolbarControl(SubToolBarController& rController, weld::Widget* pParent);
+ virtual ~SubToolbarControl() override;
+
+ virtual void GrabFocus() override;
+
+ weld::Container* GetContainer() { return m_xTargetContainer.get(); }
+
+private:
+ SubToolBarController& m_rController;
+ std::unique_ptr<weld::Container> m_xTargetContainer;
+};
+}
+
+SubToolbarControl::SubToolbarControl(SubToolBarController& rController,
+ weld::Widget* pParent)
+ : WeldToolbarPopup(rController.getFrameInterface(), pParent, "svt/ui/subtoolbar.ui", "subtoolbar")
+ , m_rController(rController)
+ , m_xTargetContainer(m_xBuilder->weld_container("container"))
+{
+}
+
+void SubToolbarControl::GrabFocus()
+{
+ // TODO
+}
+
+SubToolbarControl::~SubToolbarControl()
+{
+ m_rController.PopoverDestroyed();
+}
+
+std::unique_ptr<WeldToolbarPopup> SubToolBarController::weldPopupWindow()
+{
+ SolarMutexGuard aGuard;
+
+ auto pPopup = std::make_unique<SubToolbarControl>(*this, m_pToolbar);
+
+ css::uno::Reference< css::frame::XFrame > xFrame ( getFrameInterface() );
+
+ // create element with factory
+ static css::uno::WeakReference< css::ui::XUIElementFactoryManager > xWeakUIElementFactory;
+ css::uno::Reference< css::ui::XUIElementFactoryManager > xUIElementFactory = xWeakUIElementFactory;
+ if ( !xUIElementFactory.is() )
+ {
+ xUIElementFactory = css::ui::theUIElementFactoryManager::get( m_xContext );
+ xWeakUIElementFactory = xUIElementFactory;
+ }
+
+ css::uno::Reference< css::awt::XWindow > xParent = new weld::TransportAsXWindow(pPopup->GetContainer());
+
+ auto aPropSeq( comphelper::InitPropertySequence( {
+ { "Frame", css::uno::Any( xFrame ) },
+ { "ParentWindow", css::uno::Any( xParent ) },
+ { "Persistent", css::uno::Any( false ) },
+ { "PopupMode", css::uno::Any( true ) }
+ } ) );
+
+ try
+ {
+ m_xUIElement = xUIElementFactory->createUIElement( "private:resource/toolbar/" + m_aSubTbName, aPropSeq );
+ }
+ catch ( css::container::NoSuchElementException& )
+ {}
+ catch ( css::lang::IllegalArgumentException& )
+ {}
+
+ return pPopup;
+}
+
+VclPtr<vcl::Window> SubToolBarController::createVclPopupWindow(vcl::Window* /*pParent*/)
{
SolarMutexGuard aGuard;
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( getToolboxId( nId, &pToolBox ) )
{
css::uno::Reference< css::frame::XFrame > xFrame ( getFrameInterface() );
@@ -212,10 +300,10 @@ css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow
}
auto aPropSeq( comphelper::InitPropertySequence( {
- { "Frame", css::uno::makeAny( xFrame ) },
- { "ParentWindow", css::uno::makeAny( m_xParentWindow ) },
- { "Persistent", css::uno::makeAny( false ) },
- { "PopupMode", css::uno::makeAny( true ) }
+ { "Frame", css::uno::Any( xFrame ) },
+ { "ParentWindow", css::uno::Any( m_xParentWindow ) },
+ { "Persistent", css::uno::Any( false ) },
+ { "PopupMode", css::uno::Any( true ) }
} ) );
try
@@ -233,8 +321,7 @@ css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow
if ( xSubToolBar.is() )
{
css::uno::Reference< css::awt::XDockableWindow > xDockWindow( xSubToolBar, css::uno::UNO_QUERY );
- xDockWindow->addDockableWindowListener( css::uno::Reference< css::awt::XDockableWindowListener >(
- static_cast< OWeakObject * >( this ), css::uno::UNO_QUERY ) );
+ xDockWindow->addDockableWindowListener( css::uno::Reference< css::awt::XDockableWindowListener >(this) );
xDockWindow->enableDocking( true );
// keep reference to UIElement to avoid its destruction
@@ -254,7 +341,7 @@ css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow
}
}
}
- return css::uno::Reference< css::awt::XWindow >();
+ return nullptr;
}
sal_Bool SubToolBarController::opensSubToolbar()
@@ -284,7 +371,7 @@ void SubToolBarController::updateImage()
if ( !m_aLastCommand.isEmpty() )
{
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( getToolboxId( nId, &pToolBox ) )
{
vcl::ImageType eImageType = pToolBox->GetImageSize();
@@ -371,7 +458,7 @@ void SubToolBarController::endPopupMode( const css::awt::EndPopupModeEvent& e )
{
OUString aPersistentString( "Persistent" );
css::uno::Any a = xProp->getPropertyValue( aPersistentString );
- xProp->setPropertyValue( aPersistentString, css::uno::makeAny( false ) );
+ xProp->setPropertyValue( aPersistentString, css::uno::Any( false ) );
xLayoutManager->hideElement( aSubToolBarResName );
xLayoutManager->floatWindow( aSubToolBarResName );
@@ -397,10 +484,10 @@ void SubToolBarController::disposing( const css::lang::EventObject& e )
void SubToolBarController::initialize( const css::uno::Sequence< css::uno::Any >& rxArgs )
{
- svt::ToolboxController::initialize( rxArgs );
+ svt::PopupWindowController::initialize( rxArgs );
ToolBox* pToolBox = nullptr;
- sal_uInt16 nId = 0;
+ ToolBoxItemId nId;
if ( getToolboxId( nId, &pToolBox ) )
{
if ( m_aLastCommand.isEmpty() )
@@ -408,15 +495,28 @@ void SubToolBarController::initialize( const css::uno::Sequence< css::uno::Any >
else
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWN );
}
+
+ if (m_pToolbar)
+ {
+ mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
+ m_pToolbar->set_item_popover(m_aCommandURL, mxPopoverContainer->getTopLevel());
+ }
+
updateImage();
}
+void SubToolBarController::PopoverDestroyed()
+{
+ disposeUIElement();
+ m_xUIElement = nullptr;
+}
+
void SubToolBarController::dispose()
{
if ( m_bDisposed )
return;
- svt::ToolboxController::dispose();
+ svt::PopupWindowController::dispose();
disposeUIElement();
m_xUIElement = nullptr;
}
@@ -438,10 +538,10 @@ css::uno::Sequence< OUString > SubToolBarController::getSupportedServiceNames()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_framework_SubToolBarController_get_implementation(
- css::uno::XComponentContext*,
+ css::uno::XComponentContext* rxContext,
css::uno::Sequence<css::uno::Any> const & rxArgs )
{
- return cppu::acquire( new SubToolBarController( rxArgs ) );
+ return cppu::acquire( new SubToolBarController( rxContext, rxArgs ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uielement/thesaurusmenucontroller.cxx b/framework/source/uielement/thesaurusmenucontroller.cxx
index 492da8593ac2..6a834757c3fa 100644
--- a/framework/source/uielement/thesaurusmenucontroller.cxx
+++ b/framework/source/uielement/thesaurusmenucontroller.cxx
@@ -17,16 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <sal/log.hxx>
#include <svl/lngmisc.hxx>
#include <svtools/popupmenucontrollerbase.hxx>
-#include <unotools/lingucfg.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <toolkit/awt/vclxmenu.hxx>
+#include <unotools/lingucfg.hxx>
#include <vcl/commandinfoprovider.hxx>
-#include <vcl/image.hxx>
-#include <vcl/menu.hxx>
-#include <sal/log.hxx>
+#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
namespace {
@@ -81,36 +83,46 @@ void ThesaurusMenuController::fillPopupMenu()
css::lang::Locale aLocale = LanguageTag::convertToLocale( aIsoLang );
getMeanings( aSynonyms, aText, aLocale, 7 /*max number of synonyms to retrieve*/ );
- VCLXMenu* pAwtMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu );
- Menu* pVCLMenu = pAwtMenu->GetMenu();
- pVCLMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics );
+ m_xPopupMenu->enableAutoMnemonics(false);
if ( aSynonyms.empty() )
return;
SvtLinguConfig aCfg;
- Image aImage;
+ css::uno::Reference<css::graphic::XGraphic> xGraphic;
OUString aThesImplName( getThesImplName( aLocale ) );
OUString aSynonymsImageUrl( aCfg.GetSynonymsContextImage( aThesImplName ) );
- if ( !aThesImplName.isEmpty() && !aSynonymsImageUrl.isEmpty() )
- aImage = Image( aSynonymsImageUrl );
+ if (!aThesImplName.isEmpty() && !aSynonymsImageUrl.isEmpty())
+ {
+ try
+ {
+ css::uno::Reference<css::uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
+ css::uno::Reference<css::graphic::XGraphicProvider> xProvider(css::graphic::GraphicProvider::create(xContext));
+ xGraphic = xProvider->queryGraphic({ comphelper::makePropertyValue("URL", aSynonymsImageUrl) });
+ }
+ catch (const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("fwk");
+ }
+ }
sal_uInt16 nId = 1;
for ( const auto& aSynonym : aSynonyms )
{
OUString aItemText( linguistic::GetThesaurusReplaceText( aSynonym ) );
- pVCLMenu->InsertItem( nId, aItemText );
- pVCLMenu->SetItemCommand( nId, ".uno:ThesaurusFromContext?WordReplace:string=" + aItemText );
+ m_xPopupMenu->insertItem(nId, aItemText, 0, -1);
+ m_xPopupMenu->setCommand(nId, ".uno:ThesaurusFromContext?WordReplace:string=" + aItemText);
+
+ if (xGraphic.is())
+ m_xPopupMenu->setItemImage(nId, xGraphic, false);
- if ( !aSynonymsImageUrl.isEmpty() )
- pVCLMenu->SetItemImage( nId, aImage );
nId++;
}
- pVCLMenu->InsertSeparator();
+ m_xPopupMenu->insertSeparator(-1);
OUString aThesaurusDialogCmd( ".uno:ThesaurusDialog" );
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aThesaurusDialogCmd, m_aModuleName);
- pVCLMenu->InsertItem( nId, vcl::CommandInfoProvider::GetPopupLabelForCommand(aProperties) );
- pVCLMenu->SetItemCommand( nId, aThesaurusDialogCmd );
+ m_xPopupMenu->insertItem(nId, vcl::CommandInfoProvider::GetPopupLabelForCommand(aProperties), 0, -1);
+ m_xPopupMenu->setCommand(nId, aThesaurusDialogCmd);
}
void ThesaurusMenuController::getMeanings( std::vector< OUString >& rSynonyms, const OUString& rWord,
diff --git a/framework/source/uielement/togglebuttontoolbarcontroller.cxx b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
index ee2cb30e9910..7beabd2f8f01 100644
--- a/framework/source/uielement/togglebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
@@ -19,6 +19,7 @@
#include <uielement/togglebuttontoolbarcontroller.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/menu.hxx>
@@ -27,9 +28,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
namespace framework
{
@@ -38,7 +37,7 @@ ToggleButtonToolbarController::ToggleButtonToolbarController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbar,
- sal_uInt16 nID,
+ ToolBoxItemId nID,
Style eStyle,
const OUString& aCommand ) :
ComplexToolbarController( rxContext, rFrame, pToolbar, nID, aCommand )
@@ -61,13 +60,9 @@ void SAL_CALL ToggleButtonToolbarController::dispose()
Sequence<PropertyValue> ToggleButtonToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
{
- Sequence<PropertyValue> aArgs( 2 );
-
- // Add key modifier to argument list
- aArgs[0].Name = "KeyModifier";
- aArgs[0].Value <<= KeyModifier;
- aArgs[1].Name = "Text";
- aArgs[1].Value <<= m_aCurrentSelection;
+ Sequence<PropertyValue> aArgs{ // Add key modifier to argument list
+ comphelper::makePropertyValue("KeyModifier", KeyModifier),
+ comphelper::makePropertyValue("Text", m_aCurrentSelection) };
return aArgs;
}
@@ -116,14 +111,14 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
m_aCurrentSelection.clear();
arg.Value >>= aList;
- for ( OUString const & label : std::as_const(aList) )
+ for (OUString const& label : aList)
{
m_aDropdownMenuList.push_back( DropdownMenuItem() );
m_aDropdownMenuList.back().mLabel = label;
}
// send notification
- uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::makeAny(aList) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::Any(aList) } };
addNotifyInfo( "ListChanged",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
@@ -148,7 +143,7 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
m_aCurrentSelection = m_aDropdownMenuList[nPos].mLabel;
// send notification
- uno::Sequence< beans::NamedValue > aInfo { { "ItemChecked", css::uno::makeAny(nPos) } };
+ uno::Sequence< beans::NamedValue > aInfo { { "ItemChecked", css::uno::Any(nPos) } };
addNotifyInfo( "Pos",
getDispatchFromCommand( m_aCommandURL ),
aInfo );
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 82b7e82607c8..fb6e02918027 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -31,7 +31,6 @@
#include <classes/fwkresid.hxx>
#include <classes/resource.hxx>
#include <strings.hrc>
-#include <framework/addonsoptions.hxx>
#include <uielement/toolbarmerger.hxx>
#include <com/sun/star/ui/ItemType.hpp>
@@ -59,10 +58,13 @@
#include <unotools/cmdoptions.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <unotools/mediadescriptor.hxx>
-#include <comphelper/sequence.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/propertysequence.hxx>
#include <svtools/miscopt.hxx>
#include <svtools/imgdef.hxx>
+#include <utility>
#include <vcl/event.hxx>
+#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
#include <vcl/menu.hxx>
#include <vcl/syswin.hxx>
@@ -70,10 +72,9 @@
#include <vcl/toolbox.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
+#include <vcl/weldutils.hxx>
#include <tools/debug.hxx>
-#include <svtools/menuoptions.hxx>
-
// namespaces
using namespace ::com::sun::star::awt;
@@ -123,83 +124,490 @@ namespace
sal_Int16 getCurrentImageType()
{
- SvtMiscOptions aMiscOptions;
sal_Int16 nImageType = css::ui::ImageType::SIZE_DEFAULT;
- if (aMiscOptions.GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
+ sal_Int16 nCurrentSymbolSize = SvtMiscOptions::GetCurrentSymbolsSize();
+ if (nCurrentSymbolSize == SFX_SYMBOLS_SIZE_LARGE)
nImageType |= css::ui::ImageType::SIZE_LARGE;
- else if (aMiscOptions.GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32)
+ else if (nCurrentSymbolSize == SFX_SYMBOLS_SIZE_32)
nImageType |= css::ui::ImageType::SIZE_32;
return nImageType;
}
+class VclToolBarManager : public ToolBarManagerImpl
+{
+ DECL_LINK(Click, ToolBox*, void);
+
+public:
+ VclToolBarManager(VclPtr<ToolBox> pToolbar)
+ : m_pToolBar(std::move(pToolbar))
+ , m_bAddedToTaskPaneList(true)
+ , m_pManager(nullptr)
+ {}
+
+ ~VclToolBarManager()
+ {
+ OSL_ASSERT( !m_bAddedToTaskPaneList );
+ }
+
+ virtual void Init() override
+ {
+ vcl::Window* pWindow = m_pToolBar;
+ while ( pWindow && !pWindow->IsSystemWindow() )
+ pWindow = pWindow->GetParent();
+
+ if ( pWindow )
+ static_cast<SystemWindow *>(pWindow)->GetTaskPaneList()->AddWindow( m_pToolBar );
+ }
+
+ virtual void Destroy() override
+ {
+ OSL_ASSERT( m_pToolBar != nullptr );
+ SolarMutexGuard g;
+ if ( m_bAddedToTaskPaneList )
+ {
+ vcl::Window* pWindow = m_pToolBar;
+ while ( pWindow && !pWindow->IsSystemWindow() )
+ pWindow = pWindow->GetParent();
+
+ if ( pWindow )
+ static_cast<SystemWindow *>(pWindow)->GetTaskPaneList()->RemoveWindow( m_pToolBar );
+ m_bAddedToTaskPaneList = false;
+ }
+
+ // Delete the additional add-ons data
+ for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
+ {
+ ToolBoxItemId nItemId = m_pToolBar->GetItemId( i );
+ if ( nItemId > ToolBoxItemId(0) )
+ delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId ));
+ }
+
+ // #i93173# note we can still be in one of the toolbar's handlers
+ m_pToolBar->SetSelectHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetActivateHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetDeactivateHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetClickHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetDropdownClickHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetDoubleClickHdl( Link<ToolBox *, void>() );
+ m_pToolBar->SetStateChangedHdl( Link<StateChangedType const *, void>() );
+ m_pToolBar->SetDataChangedHdl( Link<DataChangedEvent const *, void>() );
+
+ m_pToolBar.disposeAndClear();
+ }
+
+ virtual css::uno::Reference<css::awt::XWindow> GetInterface() override
+ {
+ return VCLUnoHelper::GetInterface(m_pToolBar);
+ }
+
+ virtual void ConnectCallbacks(ToolBarManager* pManager) override
+ {
+ m_pManager = pManager;
+ m_pToolBar->SetSelectHdl( LINK( pManager, ToolBarManager, Select) );
+ m_pToolBar->SetClickHdl( LINK( this, VclToolBarManager, Click ) );
+ m_pToolBar->SetDropdownClickHdl( LINK( pManager, ToolBarManager, DropdownClick ) );
+ m_pToolBar->SetDoubleClickHdl( LINK( pManager, ToolBarManager, DoubleClick ) );
+ m_pToolBar->SetStateChangedHdl( LINK( pManager, ToolBarManager, StateChanged ) );
+ m_pToolBar->SetDataChangedHdl( LINK( pManager, ToolBarManager, DataChanged ) );
+
+ m_pToolBar->SetMenuButtonHdl( LINK( pManager, ToolBarManager, MenuButton ) );
+ m_pToolBar->SetMenuExecuteHdl( LINK( pManager, ToolBarManager, MenuPreExecute ) );
+ m_pToolBar->GetMenu()->SetSelectHdl( LINK( pManager, ToolBarManager, MenuSelect ) );
+ }
+
+ virtual void InsertItem(ToolBoxItemId nId,
+ const OUString& rCommandURL,
+ const OUString& rTooltip,
+ const OUString& rLabel,
+ ToolBoxItemBits nItemBits) override
+ {
+ m_pToolBar->InsertItem( nId, rLabel, rCommandURL, nItemBits );
+ m_pToolBar->SetQuickHelpText(nId, rTooltip);
+ m_pToolBar->EnableItem( nId );
+ m_pToolBar->SetItemState( nId, TRISTATE_FALSE );
+ }
+
+ virtual void InsertSeparator() override
+ {
+ m_pToolBar->InsertSeparator();
+ }
+
+ virtual void InsertSpace() override
+ {
+ m_pToolBar->InsertSpace();
+ }
+
+ virtual void InsertBreak() override
+ {
+ m_pToolBar->InsertBreak();
+ }
+
+ virtual ToolBoxItemId GetItemId(sal_uInt16 nPos) override
+ {
+ return m_pToolBar->GetItemId(nPos);
+ }
+
+ virtual ToolBoxItemId GetCurItemId() override
+ {
+ return m_pToolBar->GetCurItemId();
+ }
+
+ virtual OUString GetItemCommand(ToolBoxItemId nId) override
+ {
+ return m_pToolBar->GetItemCommand(nId);
+ }
+
+ virtual sal_uInt16 GetItemCount() override
+ {
+ return m_pToolBar->GetItemCount();
+ }
+
+ virtual void SetItemCheckable(ToolBoxItemId nId) override
+ {
+ m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE );
+ }
+
+ virtual void HideItem(ToolBoxItemId nId, const OUString& /*rCommandURL*/) override
+ {
+ m_pToolBar->HideItem( nId );
+ }
+
+ virtual bool IsItemVisible(ToolBoxItemId nId, const OUString& /*rCommandURL*/) override
+ {
+ return m_pToolBar->IsItemVisible(nId);
+ }
+
+ virtual void Clear() override
+ {
+ m_pToolBar->Clear();
+ }
+
+ virtual void SetName(const OUString& rName) override
+ {
+ m_pToolBar->SetText( rName );
+ }
+
+ virtual void SetHelpId(const OUString& rHelpId) override
+ {
+ m_pToolBar->SetHelpId( rHelpId );
+ }
+
+ virtual bool WillUsePopupMode() override
+ {
+ return m_pToolBar->WillUsePopupMode();
+ }
+
+ virtual bool IsReallyVisible() override
+ {
+ return m_pToolBar->IsReallyVisible();
+ }
+
+ virtual void SetIconSize(ToolBoxButtonSize eSize) override
+ {
+ m_pToolBar->SetToolboxButtonSize(eSize);
+ }
+
+ virtual vcl::ImageType GetImageSize() override
+ {
+ return m_pToolBar->GetImageSize();
+ }
+
+ virtual void SetMenuType(ToolBoxMenuType eType) override
+ {
+ m_pToolBar->SetMenuType( eType );
+ }
+
+ virtual void MergeToolbar(ToolBoxItemId & rItemId, sal_uInt16 nFirstItem,
+ const OUString& rModuleIdentifier,
+ CommandToInfoMap& rCommandMap,
+ MergeToolbarInstruction& rInstruction) override
+ {
+ ReferenceToolbarPathInfo aRefPoint = ToolBarMerger::FindReferencePoint( m_pToolBar, nFirstItem, rInstruction.aMergePoint );
+
+ // convert the sequence< sequence< propertyvalue > > structure to
+ // something we can better handle. A vector with item data
+ AddonToolbarItemContainer aItems;
+ ToolBarMerger::ConvertSeqSeqToVector( rInstruction.aMergeToolbarItems, aItems );
+
+ if ( aRefPoint.bResult )
+ {
+ ToolBarMerger::ProcessMergeOperation( m_pToolBar,
+ aRefPoint.nPos,
+ rItemId,
+ rCommandMap,
+ rModuleIdentifier,
+ rInstruction.aMergeCommand,
+ rInstruction.aMergeCommandParameter,
+ aItems );
+ }
+ else
+ {
+ ToolBarMerger::ProcessMergeFallback( m_pToolBar,
+ rItemId,
+ rCommandMap,
+ rModuleIdentifier,
+ rInstruction.aMergeCommand,
+ rInstruction.aMergeFallback,
+ aItems );
+ }
+ }
+
+ virtual void SetItemImage(ToolBoxItemId nId,
+ const OUString& /*rCommandURL*/,
+ const Image& rImage) override
+ {
+ m_pToolBar->SetItemImage(nId, rImage);
+ }
+
+ virtual void UpdateSize() override
+ {
+ ::Size aSize = m_pToolBar->CalcWindowSizePixel();
+ m_pToolBar->SetOutputSizePixel( aSize );
+ }
+
+ virtual void SetItemWindow(ToolBoxItemId nItemId, vcl::Window* pNewWindow) override
+ {
+ m_pToolBar->SetItemWindow( nItemId, pNewWindow );
+ }
+
+private:
+ VclPtr<ToolBox> m_pToolBar;
+ bool m_bAddedToTaskPaneList;
+ ToolBarManager* m_pManager;
+};
+
+IMPL_LINK_NOARG(VclToolBarManager, Click, ToolBox*, void)
+{
+ m_pManager->OnClick();
+}
+
+class WeldToolBarManager : public ToolBarManagerImpl
+{
+ DECL_LINK(Click, const OUString&, void);
+ DECL_LINK(ToggleMenuHdl, const OUString&, void);
+
+public:
+ WeldToolBarManager(weld::Toolbar* pToolbar,
+ weld::Builder* pBuilder)
+ : m_pWeldedToolBar(pToolbar)
+ , m_pBuilder(pBuilder)
+ , m_pManager(nullptr)
+ , m_nCurrentId(0)
+ {}
+
+ virtual void Init() override {}
+
+ virtual void Destroy() override {}
+
+ virtual css::uno::Reference<css::awt::XWindow> GetInterface() override
+ {
+ return new weld::TransportAsXWindow(m_pWeldedToolBar, m_pBuilder);
+ }
+
+ virtual void ConnectCallbacks(ToolBarManager* pManager) override
+ {
+ m_pManager = pManager;
+ m_pWeldedToolBar->connect_clicked(LINK(this, WeldToolBarManager, Click));
+ m_pWeldedToolBar->connect_menu_toggled(LINK(this, WeldToolBarManager, ToggleMenuHdl));
+ }
+
+ virtual void InsertItem(ToolBoxItemId nId,
+ const OUString& rCommandURL,
+ const OUString& rTooltip,
+ const OUString& rLabel,
+ ToolBoxItemBits /*nItemBits*/) override
+ {
+ m_aCommandToId[rCommandURL] = nId;
+ m_aIdToCommand[nId] = rCommandURL;
+ m_aCommandOrder.push_back(rCommandURL);
+
+ m_pWeldedToolBar->insert_item(m_aCommandOrder.size(), rCommandURL);
+ m_pWeldedToolBar->set_item_tooltip_text(rCommandURL, rTooltip);
+ m_pWeldedToolBar->set_item_label(rCommandURL, rLabel);
+ m_pWeldedToolBar->set_item_sensitive(rCommandURL, true);
+ m_pWeldedToolBar->set_item_active(rCommandURL, false);
+ }
+
+ virtual void InsertSeparator() override
+ {
+ m_pWeldedToolBar->append_separator("");
+ }
+
+ virtual void InsertSpace() override {}
+
+ virtual void InsertBreak() override {}
+
+ virtual ToolBoxItemId GetItemId(sal_uInt16 nPos) override
+ {
+ return m_aCommandToId[m_aCommandOrder[nPos]];
+ }
+
+ virtual ToolBoxItemId GetCurItemId() override
+ {
+ return m_nCurrentId;
+ }
+
+ virtual OUString GetItemCommand(ToolBoxItemId nId) override
+ {
+ return m_aIdToCommand[nId];
+ }
+
+ virtual sal_uInt16 GetItemCount() override
+ {
+ return m_aCommandOrder.size();
+ }
+
+ virtual void SetItemCheckable(ToolBoxItemId /*nId*/) override {}
+
+ virtual void HideItem(ToolBoxItemId /*nId*/, const OUString& rCommandURL) override
+ {
+ m_pWeldedToolBar->set_item_visible(rCommandURL, false);
+ }
+
+ virtual bool IsItemVisible(ToolBoxItemId /*nId*/, const OUString& rCommandURL) override
+ {
+ return m_pWeldedToolBar->get_item_visible(rCommandURL);
+ }
+
+ virtual void Clear() override {}
+
+ virtual void SetName(const OUString& /*rName*/) override {}
+
+ virtual void SetHelpId(const OUString& /*rHelpId*/) override {}
+
+ virtual bool WillUsePopupMode() override { return true; }
+
+ virtual bool IsReallyVisible() override { return true; }
+
+ virtual void SetIconSize(ToolBoxButtonSize /*eSize*/) override {}
+
+ virtual vcl::ImageType GetImageSize() override
+ {
+ return vcl::ImageType::Size32;
+ }
+
+ virtual void SetMenuType(ToolBoxMenuType /*eType*/) override {}
+
+ virtual void MergeToolbar(ToolBoxItemId & /*rItemId*/,
+ sal_uInt16 /*nFirstItem*/,
+ const OUString& /*rModuleIdentifier*/,
+ CommandToInfoMap& /*rCommandMap*/,
+ MergeToolbarInstruction& /*rInstruction*/) override {}
+
+ virtual void SetItemImage(ToolBoxItemId /*nId*/,
+ const OUString& rCommandURL,
+ const Image& rImage) override
+ {
+ m_pWeldedToolBar->set_item_image(rCommandURL, Graphic(rImage).GetXGraphic());
+ }
+
+ virtual void UpdateSize() override {}
+
+ virtual void SetItemWindow(ToolBoxItemId /*nItemId*/, vcl::Window* /*pNewWindow*/) override {}
+
+private:
+ weld::Toolbar* m_pWeldedToolBar;
+ weld::Builder* m_pBuilder;
+ ToolBarManager* m_pManager;
+ ToolBoxItemId m_nCurrentId;
+ std::map<const OUString, ToolBoxItemId> m_aCommandToId;
+ std::map<ToolBoxItemId, OUString> m_aIdToCommand;
+ std::vector<OUString> m_aCommandOrder;
+};
+
+IMPL_LINK(WeldToolBarManager, Click, const OUString&, rCommand, void)
+{
+ m_nCurrentId = m_aCommandToId[rCommand];
+ m_pManager->OnClick(true);
+}
+
+IMPL_LINK(WeldToolBarManager, ToggleMenuHdl, const OUString&, rCommand, void)
+{
+ m_nCurrentId = m_aCommandToId[rCommand];
+ m_pManager->OnDropdownClick(false);
+}
+
} // end anonymous namespace
// XInterface, XTypeProvider, XServiceInfo
ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
- const OUString& rResourceName,
+ OUString aResourceName,
ToolBox* pToolBar ) :
m_bDisposed( false ),
- m_bAddedToTaskPaneList( true ),
m_bFrameActionRegistered( false ),
m_bUpdateControllers( false ),
- m_eSymbolSize(SvtMiscOptions().GetCurrentSymbolsSize()),
+ m_eSymbolSize(SvtMiscOptions::GetCurrentSymbolsSize()),
+ m_nContextMinPos(0),
+ m_pImpl( new VclToolBarManager( pToolBar ) ),
m_pToolBar( pToolBar ),
- m_aResourceName( rResourceName ),
+ m_pWeldedToolBar( nullptr ),
+ m_aResourceName(std::move( aResourceName )),
m_xFrame( rFrame ),
- m_aListenerContainer( m_mutex ),
m_xContext( rxContext ),
- m_sIconTheme( SvtMiscOptions().GetIconTheme() )
+ m_aAsyncUpdateControllersTimer( "framework::ToolBarManager m_aAsyncUpdateControllersTimer" ),
+ m_sIconTheme( SvtMiscOptions::GetIconTheme() )
{
- OSL_ASSERT( m_xContext.is() );
+ Init();
+}
- vcl::Window* pWindow = m_pToolBar;
- while ( pWindow && !pWindow->IsSystemWindow() )
- pWindow = pWindow->GetParent();
+ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
+ const Reference< XFrame >& rFrame,
+ OUString aResourceName,
+ weld::Toolbar* pToolBar,
+ weld::Builder* pBuilder ) :
+ m_bDisposed( false ),
+ m_bFrameActionRegistered( false ),
+ m_bUpdateControllers( false ),
+ m_eSymbolSize( SvtMiscOptions::GetCurrentSymbolsSize() ),
+ m_nContextMinPos(0),
+ m_pImpl( new WeldToolBarManager( pToolBar, pBuilder ) ),
+ m_pWeldedToolBar( pToolBar ),
+ m_aResourceName(std::move( aResourceName )),
+ m_xFrame( rFrame ),
+ m_xContext( rxContext ),
+ m_aAsyncUpdateControllersTimer( "framework::ToolBarManager m_aAsyncUpdateControllersTimer" ),
+ m_sIconTheme( SvtMiscOptions::GetIconTheme() )
+{
+ Init();
+}
+
+void ToolBarManager::Init()
+{
+ OSL_ASSERT( m_xContext.is() );
- if ( pWindow )
- static_cast<SystemWindow *>(pWindow)->GetTaskPaneList()->AddWindow( m_pToolBar );
+ m_pImpl->Init();
m_xToolbarControllerFactory = frame::theToolbarControllerFactory::get( m_xContext );
m_xURLTransformer = URLTransformer::create( m_xContext );
- m_pToolBar->SetSelectHdl( LINK( this, ToolBarManager, Select) );
- m_pToolBar->SetClickHdl( LINK( this, ToolBarManager, Click ) );
- m_pToolBar->SetDropdownClickHdl( LINK( this, ToolBarManager, DropdownClick ) );
- m_pToolBar->SetDoubleClickHdl( LINK( this, ToolBarManager, DoubleClick ) );
- m_pToolBar->SetStateChangedHdl( LINK( this, ToolBarManager, StateChanged ) );
- m_pToolBar->SetDataChangedHdl( LINK( this, ToolBarManager, DataChanged ) );
+ m_pImpl->ConnectCallbacks(this);
if (m_eSymbolSize == SFX_SYMBOLS_SIZE_LARGE)
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Large);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Large);
else if (m_eSymbolSize == SFX_SYMBOLS_SIZE_32)
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Size32);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Size32);
else
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Small);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Small);
// enables a menu for clipped items and customization
SvtCommandOptions aCmdOptions;
ToolBoxMenuType nMenuType = ToolBoxMenuType::ClippedItems;
- if ( !aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "CreateDialog"))
+ if ( !aCmdOptions.LookupDisabled( "CreateDialog"))
nMenuType |= ToolBoxMenuType::Customize;
- m_pToolBar->SetMenuType( nMenuType );
- m_pToolBar->SetMenuButtonHdl( LINK( this, ToolBarManager, MenuButton ) );
- m_pToolBar->SetMenuExecuteHdl( LINK( this, ToolBarManager, MenuPreExecute ) );
- m_pToolBar->GetMenu()->SetSelectHdl( LINK( this, ToolBarManager, MenuSelect ) );
+ m_pImpl->SetMenuType( nMenuType );
// set name for testtool, the useful part is after the last '/'
- sal_Int32 idx = rResourceName.lastIndexOf('/');
+ sal_Int32 idx = m_aResourceName.lastIndexOf('/');
idx++; // will become 0 if '/' not found: use full string
- OString aHelpIdAsString( ".HelpId:" );
- OUString aToolbarName = rResourceName.copy( idx );
- aHelpIdAsString += OUStringToOString( aToolbarName, RTL_TEXTENCODING_UTF8 );
- m_pToolBar->SetHelpId( aHelpIdAsString );
+ std::u16string_view aToolbarName = m_aResourceName.subView( idx );
+ OUString aHelpIdAsString = ".HelpId:" + OUString::Concat(aToolbarName);
+ m_pImpl->SetHelpId( aHelpIdAsString );
m_aAsyncUpdateControllersTimer.SetTimeout( 50 );
m_aAsyncUpdateControllersTimer.SetInvokeHandler( LINK( this, ToolBarManager, AsyncUpdateControllersHdl ) );
- m_aAsyncUpdateControllersTimer.SetDebugName( "framework::ToolBarManager m_aAsyncUpdateControllersTimer" );
SvtMiscOptions().AddListenerLink( LINK( this, ToolBarManager, MiscOptionsChanged ) );
}
@@ -208,46 +616,11 @@ ToolBarManager::~ToolBarManager()
{
assert(!m_aAsyncUpdateControllersTimer.IsActive());
assert(!m_pToolBar); // must be disposed by ToolbarLayoutManager
- OSL_ASSERT( !m_bAddedToTaskPaneList );
}
void ToolBarManager::Destroy()
{
- OSL_ASSERT( m_pToolBar != nullptr );
- SolarMutexGuard g;
- if ( m_bAddedToTaskPaneList )
- {
- vcl::Window* pWindow = m_pToolBar;
- while ( pWindow && !pWindow->IsSystemWindow() )
- pWindow = pWindow->GetParent();
-
- if ( pWindow )
- static_cast<SystemWindow *>(pWindow)->GetTaskPaneList()->RemoveWindow( m_pToolBar );
- m_bAddedToTaskPaneList = false;
- }
-
- // Delete the additional add-ons data
- for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
- {
- sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
- if ( nItemId > 0 )
- delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId ));
- }
-
- // tdf#119390 this will reparent the toolbar, so focus is restored from a
- // floating toolbar to the last focused control of the application window.
- m_pToolBar->SetParentToDefaultWindow();
- // #i93173# note we can still be in one of the toolbar's handlers
- m_pToolBar->SetSelectHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetActivateHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetDeactivateHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetClickHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetDropdownClickHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetDoubleClickHdl( Link<ToolBox *, void>() );
- m_pToolBar->SetStateChangedHdl( Link<StateChangedType const *, void>() );
- m_pToolBar->SetDataChangedHdl( Link<DataChangedEvent const *, void>() );
-
- m_pToolBar.disposeAndClear();
+ m_pImpl->Destroy();
SvtMiscOptions().RemoveListenerLink( LINK( this, ToolBarManager, MiscOptionsChanged ) );
}
@@ -263,8 +636,7 @@ void ToolBarManager::CheckAndUpdateImages()
SolarMutexGuard g;
bool bRefreshImages = false;
- SvtMiscOptions aMiscOptions;
- sal_Int16 eNewSymbolSize = aMiscOptions.GetCurrentSymbolsSize();
+ sal_Int16 eNewSymbolSize = SvtMiscOptions::GetCurrentSymbolsSize();
if (m_eSymbolSize != eNewSymbolSize )
{
@@ -272,7 +644,7 @@ void ToolBarManager::CheckAndUpdateImages()
m_eSymbolSize = eNewSymbolSize;
}
- const OUString& sCurrentIconTheme = aMiscOptions.GetIconTheme();
+ const OUString& sCurrentIconTheme = SvtMiscOptions::GetIconTheme();
if ( m_sIconTheme != sCurrentIconTheme )
{
bRefreshImages = true;
@@ -289,11 +661,11 @@ void ToolBarManager::RefreshImages()
SolarMutexGuard g;
if (m_eSymbolSize == SFX_SYMBOLS_SIZE_LARGE)
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Large);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Large);
else if (m_eSymbolSize == SFX_SYMBOLS_SIZE_32)
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Size32);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Size32);
else
- m_pToolBar->SetToolboxButtonSize(ToolBoxButtonSize::Small);
+ m_pImpl->SetIconSize(ToolBoxButtonSize::Small);
for ( auto const& it : m_aControllerMap )
{
@@ -306,26 +678,25 @@ void ToolBarManager::RefreshImages()
}
else
{
- OUString aCommandURL = m_pToolBar->GetItemCommand( it.first );
- vcl::ImageType eImageType = m_pToolBar->GetImageSize();
+ OUString aCommandURL = m_pImpl->GetItemCommand( it.first );
+ vcl::ImageType eImageType = m_pImpl->GetImageSize();
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, m_xFrame, eImageType);
// Try also to query for add-on images before giving up and use an
// empty image.
bool bBigImages = eImageType != vcl::ImageType::Size16;
if ( !aImage )
aImage = Image(framework::AddonsOptions().GetImageFromURL(aCommandURL, bBigImages));
- m_pToolBar->SetItemImage( it.first, aImage );
+ m_pImpl->SetItemImage( it.first, aCommandURL, aImage );
}
}
- ::Size aSize = m_pToolBar->CalcWindowSizePixel();
- m_pToolBar->SetOutputSizePixel( aSize );
+ m_pImpl->UpdateSize();
}
void ToolBarManager::UpdateControllers()
{
- if( SvtMiscOptions().DisableUICustomization() )
+ if( officecfg::Office::Common::Misc::DisableUICustomization::get() )
{
Any a;
Reference< XLayoutManager > xLayoutManager;
@@ -333,7 +704,7 @@ void ToolBarManager::UpdateControllers()
if ( xFramePropSet.is() )
a = xFramePropSet->getPropertyValue("LayoutManager");
a >>= xLayoutManager;
- Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
+ Reference< XDockableWindow > xDockable( m_pImpl->GetInterface(), UNO_QUERY );
if ( xLayoutManager.is() && xDockable.is() )
{
css::awt::Point aPoint;
@@ -390,6 +761,8 @@ void ToolBarManager::frameAction( const FrameActionEvent& Action )
SolarMutexGuard g;
if ( Action.Action == FrameAction_CONTEXT_CHANGED && !m_bDisposed )
{
+ if (m_aImageController)
+ m_aImageController->update();
m_aAsyncUpdateControllersTimer.Start();
}
}
@@ -408,8 +781,7 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source )
try
{
m_xDocImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -421,8 +793,7 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source )
try
{
m_xModuleImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -441,12 +812,14 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source )
// XComponent
void SAL_CALL ToolBarManager::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
-
- EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
+ Reference< XComponent > xThis(this);
{
+ EventObject aEvent( xThis );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.disposeAndClear( aGuard, aEvent );
+ }
+ {
SolarMutexGuard g;
if (m_bDisposed)
@@ -461,8 +834,7 @@ void SAL_CALL ToolBarManager::dispose()
try
{
m_xDocImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -474,8 +846,7 @@ void SAL_CALL ToolBarManager::dispose()
try
{
m_xModuleImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
catch (const Exception&)
{
@@ -497,8 +868,7 @@ void SAL_CALL ToolBarManager::dispose()
{
try
{
- m_xFrame->removeFrameActionListener( Reference< XFrameActionListener >(
- static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ));
+ m_xFrame->removeFrameActionListener( Reference< XFrameActionListener >(this) );
}
catch (const Exception&)
{
@@ -524,12 +894,14 @@ void SAL_CALL ToolBarManager::addEventListener( const Reference< XEventListener
if ( m_bDisposed )
throw DisposedException();
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.addInterface( aGuard, xListener );
}
void SAL_CALL ToolBarManager::removeEventListener( const Reference< XEventListener >& xListener )
{
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aListenerContainer.removeInterface( aGuard, xListener );
}
// XUIConfigurationListener
@@ -579,9 +951,8 @@ void ToolBarManager::impl_elementChanged(bool const isRemove,
// Special case: An image from the document image manager has been removed.
// It is possible that we have an image at our module image manager. Before
// we can remove our image we have to ask our module image manager.
- Sequence< OUString > aCmdURLSeq( 1 );
+ Sequence< OUString > aCmdURLSeq{ pIter->first };
Sequence< Reference< XGraphic > > aGraphicSeq;
- aCmdURLSeq[0] = pIter->first;
aGraphicSeq = m_xModuleImageManager->getImages( nImageType, aCmdURLSeq );
aImage = Image( aGraphicSeq[0] );
}
@@ -604,11 +975,11 @@ void ToolBarManager::impl_elementChanged(bool const isRemove,
void ToolBarManager::setToolBarImage(const Image& rImage,
const CommandToInfoMap::const_iterator& rIter)
{
- const ::std::vector<sal_uInt16>& rIDs = rIter->second.aIds;
- m_pToolBar->SetItemImage( rIter->second.nId, rImage );
+ const ::std::vector<ToolBoxItemId>& rIDs = rIter->second.aIds;
+ m_pImpl->SetItemImage( rIter->second.nId, rIter->first, rImage );
for (auto const& it : rIDs)
{
- m_pToolBar->SetItemImage(it, rImage);
+ m_pImpl->SetItemImage(it, rIter->first, rImage);
}
}
@@ -624,15 +995,19 @@ void ToolBarManager::RemoveControllers()
m_aSubToolBarControllerMap.clear();
+ if (m_aImageController)
+ m_aImageController->dispose();
+ m_aImageController.clear();
+
// i90033
// Remove item window pointers from the toolbar. They were
// destroyed by the dispose() at the XComponent. This is needed
// as VCL code later tries to access the item window data in certain
// dtors where the item window is already invalid!
- for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
+ for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pImpl->GetItemCount(); i++ )
{
- sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
- if ( nItemId > 0 )
+ ToolBoxItemId nItemId = m_pImpl->GetItemId( i );
+ if ( nItemId > ToolBoxItemId(0) )
{
Reference< XComponent > xComponent( m_aControllerMap[ nItemId ], UNO_QUERY );
if ( xComponent.is() )
@@ -645,7 +1020,7 @@ void ToolBarManager::RemoveControllers()
{
}
}
- m_pToolBar->SetItemWindow(nItemId, nullptr);
+ m_pImpl->SetItemWindow(nItemId, nullptr);
}
}
m_aControllerMap.clear();
@@ -653,25 +1028,23 @@ void ToolBarManager::RemoveControllers()
void ToolBarManager::CreateControllers()
{
- Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar );
+ Reference< XWindow > xToolbarWindow = m_pImpl->GetInterface();
css::util::URL aURL;
- bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED );
+ bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled();
SvtCommandOptions aCmdOptions;
- for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
+ for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pImpl->GetItemCount(); i++ )
{
- sal_uInt16 nId = m_pToolBar->GetItemId( i );
- if ( nId == 0 )
+ ToolBoxItemId nId = m_pImpl->GetItemId( i );
+ if ( nId == ToolBoxItemId(0) )
continue;
bool bInit( true );
bool bCreate( true );
Reference< XStatusListener > xController;
- svt::ToolboxController* pController( nullptr );
-
- OUString aCommandURL( m_pToolBar->GetItemCommand( nId ) );
+ OUString aCommandURL( m_pImpl->GetItemCommand( nId ) );
// Command can be just an alias to another command.
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommandURL, m_aModuleIdentifier);
OUString aRealCommandURL( vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties) );
@@ -682,10 +1055,10 @@ void ToolBarManager::CreateControllers()
{
aURL.Complete = aCommandURL;
m_xURLTransformer->parseStrict( aURL );
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aURL.Path ))
+ if ( aCmdOptions.LookupDisabled( aURL.Path ))
{
m_aControllerMap[ nId ] = xController;
- m_pToolBar->HideItem( nId );
+ m_pImpl->HideItem( nId, aCommandURL );
continue;
}
}
@@ -693,85 +1066,69 @@ void ToolBarManager::CreateControllers()
if ( m_xToolbarControllerFactory.is() &&
m_xToolbarControllerFactory->hasController( aCommandURL, m_aModuleIdentifier ))
{
- PropertyValue aPropValue;
- std::vector< Any > aPropertyVector;
-
- aPropValue.Name = "ModuleIdentifier";
- aPropValue.Value <<= m_aModuleIdentifier;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "Frame";
- aPropValue.Value <<= m_xFrame;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "ServiceManager";
Reference<XMultiServiceFactory> xMSF(m_xContext->getServiceManager(), UNO_QUERY_THROW);
- aPropValue.Value <<= xMSF;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "ParentWindow";
- aPropValue.Value <<= xToolbarWindow;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "Identifier";
- aPropValue.Value <<= nId;
- aPropertyVector.push_back( uno::makeAny( aPropValue ) );
-
- Sequence< Any > aArgs( comphelper::containerToSequence( aPropertyVector ));
+ Sequence< Any > aArgs( comphelper::InitAnyPropertySequence( {
+ { "ModuleIdentifier", Any(m_aModuleIdentifier) },
+ { "Frame", Any(m_xFrame) },
+ { "ServiceManager", Any(xMSF) },
+ { "ParentWindow", Any(xToolbarWindow) },
+ { "Identifier", Any(sal_uInt16(nId)) },
+ } ));
xController.set( m_xToolbarControllerFactory->createInstanceWithArgumentsAndContext( aCommandURL, aArgs, m_xContext ),
UNO_QUERY );
bInit = false; // Initialization is done through the factory service
}
- if (( aCommandURL == ".uno:OpenUrl" ) && ( !m_pToolBar->IsItemVisible(nId)))
+ if (( aCommandURL == ".uno:OpenUrl" ) && ( !m_pImpl->IsItemVisible(nId, aCommandURL)))
bCreate = false;
if ( !xController.is() && bCreate )
{
- pController = CreateToolBoxController( m_xFrame, m_pToolBar, nId, aCommandURL );
- if ( !pController )
+ if ( m_pToolBar )
+ xController = CreateToolBoxController( m_xFrame, m_pToolBar, nId, aCommandURL );
+ if ( !xController )
{
-
if ( aCommandURL.startsWith( ".uno:StyleApply?" ) )
{
xController.set( new StyleToolbarController( m_xContext, m_xFrame, aCommandURL ));
- m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE );
+ m_pImpl->SetItemCheckable( nId );
}
else if ( aCommandURL.startsWith( "private:resource/" ) )
{
xController.set( m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.comp.framework.GenericPopupToolbarController", m_xContext ), UNO_QUERY );
}
- else if ( m_pToolBar->GetItemData( nId ) != nullptr )
+ else if ( m_pToolBar && m_pToolBar->GetItemData( nId ) != nullptr )
{
// retrieve additional parameters
OUString aControlType = static_cast< AddonsParams* >( m_pToolBar->GetItemData( nId ))->aControlType;
sal_uInt16 nWidth = static_cast< AddonsParams* >( m_pToolBar->GetItemData( nId ))->nWidth;
- Reference< XStatusListener > xStatusListener(
+ xController.set(
ToolBarMerger::CreateController( m_xContext,
m_xFrame,
m_pToolBar,
aCommandURL,
nId,
nWidth,
- aControlType ), UNO_QUERY );
+ aControlType ).get(), UNO_QUERY );
- xController = xStatusListener;
}
else
{
- xController.set(
- new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL ));
-
- // Accessibility support: Set toggle button role for specific commands
- sal_Int32 nProps = vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, m_aModuleIdentifier);
- if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON )
- m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE );
+ if ( m_pToolBar )
+ xController.set( new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL ));
+ else
+ xController.set( new GenericToolbarController( m_xContext, m_xFrame, *m_pWeldedToolBar, aCommandURL ));
}
}
- else if ( pController )
- {
- xController.set( static_cast< ::cppu::OWeakObject *>( pController ), UNO_QUERY );
- }
}
+ // Accessibility support: Set toggle button role for specific commands
+ const sal_Int32 nProps = vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, m_aModuleIdentifier);
+ if (nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON)
+ m_pImpl->SetItemCheckable(nId);
+
// Associate ID and controller to be able to retrieve
// the controller from the ID later.
m_aControllerMap[ nId ] = xController;
@@ -802,37 +1159,17 @@ void ToolBarManager::CreateControllers()
{
if ( bInit )
{
- PropertyValue aPropValue;
- std::vector< Any > aPropertyVector;
-
- aPropValue.Name = "Frame";
- aPropValue.Value <<= m_xFrame;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "CommandURL";
- aPropValue.Value <<= aCommandURL;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "ServiceManager";
Reference<XMultiServiceFactory> xMSF(m_xContext->getServiceManager(), UNO_QUERY_THROW);
- aPropValue.Value <<= xMSF;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "ParentWindow";
- aPropValue.Value <<= xToolbarWindow;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "ModuleIdentifier";
- aPropValue.Value <<= m_aModuleIdentifier;
- aPropertyVector.push_back( makeAny( aPropValue ));
- aPropValue.Name = "Identifier";
- aPropValue.Value <<= nId;
- aPropertyVector.push_back( uno::makeAny( aPropValue ) );
-
- Sequence< Any > aArgs( comphelper::containerToSequence( aPropertyVector ));
- xInit->initialize( aArgs );
+ Sequence< Any > aArgs( comphelper::InitAnyPropertySequence( {
+ { "Frame", Any(m_xFrame) },
+ { "CommandURL", Any(aCommandURL) },
+ { "ServiceManager", Any(xMSF) },
+ { "ParentWindow", Any(xToolbarWindow) },
+ { "ModuleIdentifier", Any(m_aModuleIdentifier) },
+ { "Identifier", Any(sal_uInt16(nId)) },
+ } ));
- if (pController)
- {
- if (aCommandURL == ".uno:SwitchXFormsDesignMode" || aCommandURL == ".uno:ViewDataSourceBrowser")
- pController->setFastPropertyValue_NoBroadcast(1, makeAny(true));
- }
+ xInit->initialize( aArgs );
}
// Request an item window from the toolbar controller and set it at the VCL toolbar
@@ -846,9 +1183,9 @@ void ToolBarManager::CreateControllers()
if ( pItemWin )
{
WindowType nType = pItemWin->GetType();
- if ( nType == WindowType::LISTBOX || nType == WindowType::MULTILISTBOX || nType == WindowType::COMBOBOX )
+ if ( m_pToolBar && (nType == WindowType::LISTBOX || nType == WindowType::MULTILISTBOX || nType == WindowType::COMBOBOX) )
pItemWin->SetAccessibleName( m_pToolBar->GetItemText( nId ) );
- m_pToolBar->SetItemWindow( nId, pItemWin );
+ m_pImpl->SetItemWindow( nId, pItemWin );
}
}
}
@@ -887,11 +1224,11 @@ void ToolBarManager::AddFrameActionListener()
if ( !m_bFrameActionRegistered && m_xFrame.is() )
{
m_bFrameActionRegistered = true;
- m_xFrame->addFrameActionListener( Reference< XFrameActionListener >(
- static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ));
+ m_xFrame->addFrameActionListener( Reference< XFrameActionListener >(this) );
}
}
+// static
ToolBoxItemBits ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle )
{
ToolBoxItemBits nItemBits( ToolBoxItemBits::NONE );
@@ -929,8 +1266,7 @@ void ToolBarManager::InitImageManager()
Reference< XUIConfigurationManager > xDocUICfgMgr = xSupplier->getUIConfigurationManager();
m_xDocImageManager.set( xDocUICfgMgr->getImageManager(), UNO_QUERY );
m_xDocImageManager->addConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ Reference< XUIConfigurationListener >(this) );
}
}
}
@@ -949,12 +1285,13 @@ void ToolBarManager::InitImageManager()
theModuleUIConfigurationManagerSupplier::get( m_xContext );
Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
m_xModuleImageManager.set( xUICfgMgr->getImageManager(), UNO_QUERY );
- m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(this) );
}
}
-void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContainer )
+void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContainer,
+ const Reference< XIndexAccess >& rContextData,
+ const OUString& rContextToolbarName )
{
OString aTbxName = OUStringToOString( m_aResourceName, RTL_TEXTENCODING_ASCII_US );
SAL_INFO( "fwk.uielement", "framework (cd100003) ::ToolBarManager::FillToolbar " << aTbxName );
@@ -969,11 +1306,58 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
RemoveControllers();
// reset and fill command map
- m_pToolBar->Clear();
+ m_pImpl->Clear();
m_aControllerMap.clear();
m_aCommandMap.clear();
- sal_uInt16 nId( 1 );
+ ToolBoxItemId nId(1), nAddonId(1000);
+ FillToolbarFromContainer( rItemContainer, m_aResourceName, nId, nAddonId );
+ m_aContextResourceName = rContextToolbarName;
+ if ( rContextData.is() )
+ {
+ m_pImpl->InsertSeparator();
+ FillToolbarFromContainer( rContextData, m_aContextResourceName, nId, nAddonId );
+ }
+
+ // Request images for all toolbar items. Must be done before CreateControllers as
+ // some controllers need access to the image.
+ RequestImages();
+
+ // Create controllers after we set the images. There are controllers which needs
+ // an image at the toolbar at creation time!
+ CreateControllers();
+
+ // Notify controllers that they are now correctly initialized and can start listening
+ // toolbars that will open in popup mode will be updated immediately to avoid flickering
+ if( m_pImpl->WillUsePopupMode() )
+ UpdateControllers();
+ else if ( m_pImpl->IsReallyVisible() )
+ {
+ m_aAsyncUpdateControllersTimer.Start();
+ }
+
+ // Try to retrieve UIName from the container property set and set it as the title
+ // if it is not empty.
+ Reference< XPropertySet > xPropSet( rItemContainer, UNO_QUERY );
+ if ( !xPropSet.is() )
+ return;
+
+ try
+ {
+ OUString aUIName;
+ xPropSet->getPropertyValue("UIName") >>= aUIName;
+ if ( !aUIName.isEmpty() )
+ m_pImpl->SetName( aUIName );
+ }
+ catch (const Exception&)
+ {
+ }
+}
+
+void ToolBarManager::FillToolbarFromContainer( const Reference< XIndexAccess >& rItemContainer,
+ const OUString& rResourceName, ToolBoxItemId& nId, ToolBoxItemId& nAddonId )
+{
+ m_nContextMinPos = m_pImpl->GetItemCount();
CommandInfo aCmdInfo;
for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
{
@@ -989,7 +1373,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if ( rItemContainer->getByIndex( n ) >>= aProps )
{
bool bIsVisible( true );
- for ( PropertyValue const & prop : std::as_const(aProps) )
+ for (PropertyValue const& prop : aProps)
{
if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL )
prop.Value >>= aCommandURL;
@@ -1014,26 +1398,18 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
{
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommandURL, m_aModuleIdentifier);
- OUString aString(vcl::CommandInfoProvider::GetLabelForCommand(aProperties));
+ if (!aProperties.hasElements()) // E.g., user-provided macro command?
+ aProperties = aProps; // Use existing info, including user-provided Label
ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle );
- m_pToolBar->InsertItem( nId, aString, nItemBits );
- m_pToolBar->SetItemCommand( nId, aCommandURL );
- if ( !aTooltip.isEmpty() )
- m_pToolBar->SetQuickHelpText(nId, aTooltip);
- else
- m_pToolBar->SetQuickHelpText(nId, vcl::CommandInfoProvider::GetTooltipForCommand(aCommandURL, aProperties, m_xFrame));
- if ( !aLabel.isEmpty() )
- {
- m_pToolBar->SetItemText( nId, aLabel );
- }
- else
- {
- m_pToolBar->SetItemText( nId, aString );
- }
- m_pToolBar->EnableItem( nId );
- m_pToolBar->SetItemState( nId, TRISTATE_FALSE );
+ if ( aTooltip.isEmpty() )
+ aTooltip = vcl::CommandInfoProvider::GetTooltipForCommand(aCommandURL, aProperties, m_xFrame);
+
+ if ( aLabel.isEmpty() )
+ aLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
+
+ m_pImpl->InsertItem(nId, aCommandURL, aTooltip, aLabel, nItemBits);
// Fill command map. It stores all our commands and from what
// image manager we got our image. So we can decide if we have to use an
@@ -1050,21 +1426,21 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
}
if ( !bIsVisible )
- m_pToolBar->HideItem( nId );
+ m_pImpl->HideItem( nId, aCommandURL );
++nId;
}
else if ( nType == css::ui::ItemType::SEPARATOR_LINE )
{
- m_pToolBar->InsertSeparator();
+ m_pImpl->InsertSeparator();
}
else if ( nType == css::ui::ItemType::SEPARATOR_SPACE )
{
- m_pToolBar->InsertSpace();
+ m_pImpl->InsertSpace();
}
else if ( nType == css::ui::ItemType::SEPARATOR_LINEBREAK )
{
- m_pToolBar->InsertBreak();
+ m_pImpl->InsertBreak();
}
}
}
@@ -1076,12 +1452,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
// Support add-on toolbar merging here. Working directly on the toolbar object is much
// simpler and faster.
- constexpr sal_uInt16 TOOLBAR_ITEM_STARTID = 1000;
-
MergeToolbarInstructionContainer aMergeInstructionContainer;
// Retrieve the toolbar name from the resource name
- OUString aToolbarName( m_aResourceName );
+ OUString aToolbarName( rResourceName );
sal_Int32 nIndex = aToolbarName.lastIndexOf( '/' );
if (( nIndex > 0 ) && ( nIndex < aToolbarName.getLength() ))
aToolbarName = aToolbarName.copy( nIndex+1 );
@@ -1090,82 +1464,23 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if ( !aMergeInstructionContainer.empty() )
{
- sal_uInt16 nItemId( TOOLBAR_ITEM_STARTID );
const sal_uInt32 nCount = aMergeInstructionContainer.size();
for ( sal_uInt32 i=0; i < nCount; i++ )
{
MergeToolbarInstruction& rInstruction = aMergeInstructionContainer[i];
if ( ToolBarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier ))
{
- ReferenceToolbarPathInfo aRefPoint = ToolBarMerger::FindReferencePoint( m_pToolBar, rInstruction.aMergePoint );
-
- // convert the sequence< sequence< propertyvalue > > structure to
- // something we can better handle. A vector with item data
- AddonToolbarItemContainer aItems;
- ToolBarMerger::ConvertSeqSeqToVector( rInstruction.aMergeToolbarItems, aItems );
-
- if ( aRefPoint.bResult )
- {
- ToolBarMerger::ProcessMergeOperation( m_pToolBar,
- aRefPoint.nPos,
- nItemId,
- m_aCommandMap,
- m_aModuleIdentifier,
- rInstruction.aMergeCommand,
- rInstruction.aMergeCommandParameter,
- aItems );
- }
- else
- {
- ToolBarMerger::ProcessMergeFallback( m_pToolBar,
- nItemId,
- m_aCommandMap,
- m_aModuleIdentifier,
- rInstruction.aMergeCommand,
- rInstruction.aMergeFallback,
- aItems );
- }
+ m_pImpl->MergeToolbar(nAddonId, m_nContextMinPos, m_aModuleIdentifier, m_aCommandMap, rInstruction);
}
}
}
-
- // Request images for all toolbar items. Must be done before CreateControllers as
- // some controllers need access to the image.
- RequestImages();
-
- // Create controllers after we set the images. There are controllers which needs
- // an image at the toolbar at creation time!
- CreateControllers();
-
- // Notify controllers that they are now correctly initialized and can start listening
- // toolbars that will open in popup mode will be updated immediately to avoid flickering
- if( m_pToolBar->WillUsePopupMode() )
- UpdateControllers();
- else if ( m_pToolBar->IsReallyVisible() )
- {
- m_aAsyncUpdateControllersTimer.Start();
- }
-
- // Try to retrieve UIName from the container property set and set it as the title
- // if it is not empty.
- Reference< XPropertySet > xPropSet( rItemContainer, UNO_QUERY );
- if ( !xPropSet.is() )
- return;
-
- try
- {
- OUString aUIName;
- xPropSet->getPropertyValue("UIName") >>= aUIName;
- if ( !aUIName.isEmpty() )
- m_pToolBar->SetText( aUIName );
- }
- catch (const Exception&)
- {
- }
}
void ToolBarManager::FillAddonToolbar( const Sequence< Sequence< PropertyValue > >& rAddonToolbar )
{
+ if (!m_pToolBar)
+ return;
+
SolarMutexGuard g;
if ( m_bDisposed )
@@ -1180,7 +1495,7 @@ void ToolBarManager::FillAddonToolbar( const Sequence< Sequence< PropertyValue >
m_aControllerMap.clear();
m_aCommandMap.clear();
- sal_uInt16 nId( 1 );
+ ToolBoxItemId nId( 1 );
CommandInfo aCmdInfo;
for ( const Sequence< PropertyValue >& rSeq : rAddonToolbar )
{
@@ -1203,7 +1518,7 @@ void ToolBarManager::FillAddonToolbar( const Sequence< Sequence< PropertyValue >
}
else
{
- m_pToolBar->InsertItem( nId, aTitle );
+ m_pToolBar->InsertItem( nId, aTitle, aURL );
OUString aShortcut(vcl::CommandInfoProvider::GetCommandShortcut(aURL, m_xFrame));
if (!aShortcut.isEmpty())
@@ -1214,7 +1529,6 @@ void ToolBarManager::FillAddonToolbar( const Sequence< Sequence< PropertyValue >
pRuntimeItemData->aControlType = aControlType;
pRuntimeItemData->nWidth = nWidth;
m_pToolBar->SetItemData( nId, pRuntimeItemData );
- m_pToolBar->SetItemCommand( nId, aURL );
// Fill command map. It stores all our commands and from what
// image manager we got our image. So we can decide if we have to use an
@@ -1244,11 +1558,14 @@ void ToolBarManager::FillAddonToolbar( const Sequence< Sequence< PropertyValue >
void ToolBarManager::FillOverflowToolbar( ToolBox const * pParent )
{
+ if (!m_pToolBar)
+ return;
+
CommandInfo aCmdInfo;
bool bInsertSeparator = false;
for ( ToolBox::ImplToolItems::size_type i = 0; i < pParent->GetItemCount(); ++i )
{
- sal_uInt16 nId = pParent->GetItemId( i );
+ ToolBoxItemId nId = pParent->GetItemId( i );
if ( pParent->IsItemClipped( nId ) )
{
if ( bInsertSeparator )
@@ -1258,8 +1575,7 @@ void ToolBarManager::FillOverflowToolbar( ToolBox const * pParent )
}
const OUString aCommandURL( pParent->GetItemCommand( nId ) );
- m_pToolBar->InsertItem( nId, pParent->GetItemText( nId ) );
- m_pToolBar->SetItemCommand( nId, aCommandURL );
+ m_pToolBar->InsertItem( nId, pParent->GetItemText( nId ), aCommandURL );
m_pToolBar->SetQuickHelpText( nId, pParent->GetQuickHelpText( nId ) );
// Handle possible add-on controls.
@@ -1313,8 +1629,6 @@ void ToolBarManager::RequestImages()
Sequence< Reference< XGraphic > > aDocGraphicSeq;
Sequence< Reference< XGraphic > > aModGraphicSeq;
- SvtMiscOptions aMiscOptions;
-
sal_Int16 nImageType = getCurrentImageType();
if ( m_xDocImageManager.is() )
@@ -1335,7 +1649,7 @@ void ToolBarManager::RequestImages()
// Try also to query for add-on images before giving up and use an
// empty image.
if ( !aImage )
- aImage = Image(framework::AddonsOptions().GetImageFromURL(aCmdURLSeq[i], aMiscOptions.AreCurrentSymbolsLarge()));
+ aImage = Image(framework::AddonsOptions().GetImageFromURL(aCmdURLSeq[i], SvtMiscOptions::AreCurrentSymbolsLarge()));
pIter->second.nImageInfo = 1; // mark image as module based
}
@@ -1347,6 +1661,10 @@ void ToolBarManager::RequestImages()
++pIter;
++i;
}
+
+ assert(!m_aImageController); // an existing one isn't disposed here
+ m_aImageController = new ImageOrientationController(m_xContext, m_xFrame, m_pImpl->GetInterface(), m_aModuleIdentifier);
+ m_aImageController->update();
}
void ToolBarManager::notifyRegisteredControllers( const OUString& aUIElementName, const OUString& aCommand )
@@ -1387,54 +1705,84 @@ void ToolBarManager::notifyRegisteredControllers( const OUString& aUIElementName
}
}
-void ToolBarManager::HandleClick(void ( SAL_CALL XToolbarController::*_pClick )())
+void ToolBarManager::HandleClick(ClickAction eClickAction)
{
SolarMutexGuard g;
if ( m_bDisposed )
return;
- sal_uInt16 nId( m_pToolBar->GetCurItemId() );
+ ToolBoxItemId nId( m_pImpl->GetCurItemId() );
ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
- if ( pIter != m_aControllerMap.end() )
+ if ( pIter == m_aControllerMap.end() )
+ return;
+
+ Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
+
+ if ( xController.is() )
{
- Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
+ switch (eClickAction)
+ {
+ case ClickAction::Click:
+ xController->click();
+ break;
- if ( xController.is() )
- (xController.get()->*_pClick)( );
+ case ClickAction::DblClick:
+ xController->doubleClick();
+ break;
+
+ case ClickAction::Execute:
+ xController->execute(0);
+ break;
+ }
}
}
-IMPL_LINK_NOARG(ToolBarManager, Click, ToolBox *, void)
+void ToolBarManager::OnClick(bool bUseExecute)
{
- HandleClick(&XToolbarController::click);
+ if (bUseExecute)
+ HandleClick(ClickAction::Execute);
+ else
+ HandleClick(ClickAction::Click);
}
IMPL_LINK_NOARG(ToolBarManager, DropdownClick, ToolBox *, void)
{
+ OnDropdownClick(true);
+}
+
+void ToolBarManager::OnDropdownClick(bool bCreatePopupWindow)
+{
SolarMutexGuard g;
if ( m_bDisposed )
return;
- sal_uInt16 nId( m_pToolBar->GetCurItemId() );
+ ToolBoxItemId nId( m_pImpl->GetCurItemId() );
ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
- if ( pIter != m_aControllerMap.end() )
- {
- Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
+ if ( pIter == m_aControllerMap.end() )
+ return;
- if ( xController.is() )
+ Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
+
+ if ( xController.is() )
+ {
+ if (bCreatePopupWindow)
{
Reference< XWindow > xWin = xController->createPopupWindow();
if ( xWin.is() )
xWin->setFocus();
}
+ else
+ {
+ xController->click();
+ }
}
}
IMPL_LINK_NOARG(ToolBarManager, DoubleClick, ToolBox *, void)
{
- HandleClick(&XToolbarController::doubleClick);
+ HandleClick(ClickAction::DblClick);
}
Reference< XModel > ToolBarManager::GetModelFromFrame() const
@@ -1458,7 +1806,7 @@ bool ToolBarManager::IsPluginMode() const
{
Sequence< PropertyValue > aSeq = xModel->getArgs();
utl::MediaDescriptor aMediaDescriptor( aSeq );
- bPluginMode = aMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_VIEWONLY(), false );
+ bPluginMode = aMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_VIEWONLY, false );
}
}
@@ -1467,6 +1815,9 @@ bool ToolBarManager::IsPluginMode() const
void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
{
+ if (!m_pToolBar)
+ return;
+
// No config menu entries if command ".uno:ConfigureDialog" is not enabled
Reference< XDispatch > xDisp;
css::util::URL aURL;
@@ -1483,7 +1834,7 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
}
// popup menu for quick customization
- bool bHideDisabledEntries = !SvtMenuOptions().IsEntryHidingEnabled();
+ bool bHideDisabledEntries = !officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get();
::PopupMenu *pMenu = pToolBar->GetMenu();
@@ -1538,15 +1889,12 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
pMenu->EnableItem(MENUITEM_TOOLBAR_DOCKALLTOOLBAR, false);
Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
if( xDockable.is() )
- {
pMenu->CheckItem(MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, xDockable->isLocked());
- pMenu->EnableItem(MENUITEM_TOOLBAR_UNDOCKTOOLBAR, !xDockable->isLocked());
- }
}
else
pMenu->EnableItem(MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, false);
- if (SvtMiscOptions().DisableUICustomization())
+ if (officecfg::Office::Common::Misc::DisableUICustomization::get())
{
pMenu->EnableItem(MENUITEM_TOOLBAR_VISIBLEBUTTON, false);
pMenu->EnableItem(MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR, false);
@@ -1569,7 +1917,7 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
{
if ( m_pToolBar->GetItemType(nPos) == ToolBoxItemType::BUTTON )
{
- sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
+ ToolBoxItemId nId = m_pToolBar->GetItemId(nPos);
OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
xVisibleItemsPopupMenu->InsertItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->GetItemText( nId ), MenuItemBits::CHECKABLE );
xVisibleItemsPopupMenu->CheckItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->IsItemVisible( nId ) );
@@ -1611,6 +1959,66 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
pMenu->RemoveDisabledEntries();
}
+void ToolBarManager::ToggleButton( const OUString& rResourceName, std::u16string_view rCommand )
+{
+ Reference< XLayoutManager > xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
+ if ( !xLayoutManager.is() )
+ return;
+
+ Reference< XUIElementSettings > xUIElementSettings( xLayoutManager->getElement( rResourceName ), UNO_QUERY );
+ if ( !xUIElementSettings.is() )
+ return;
+
+ Reference< XIndexContainer > xItemContainer( xUIElementSettings->getSettings( true ), UNO_QUERY );
+ sal_Int32 nCount = xItemContainer->getCount();
+ for ( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ Sequence< PropertyValue > aProp;
+ sal_Int32 nVisibleIndex( -1 );
+ OUString aCommandURL;
+ bool bVisible( false );
+
+ if ( xItemContainer->getByIndex( i ) >>= aProp )
+ {
+ for ( sal_Int32 j = 0; j < aProp.getLength(); j++ )
+ {
+ if ( aProp[j].Name == ITEM_DESCRIPTOR_COMMANDURL )
+ {
+ aProp[j].Value >>= aCommandURL;
+ }
+ else if ( aProp[j].Name == ITEM_DESCRIPTOR_VISIBLE )
+ {
+ aProp[j].Value >>= bVisible;
+ nVisibleIndex = j;
+ }
+ }
+
+ if (( aCommandURL == rCommand ) && ( nVisibleIndex >= 0 ))
+ {
+ // We have found the requested item, toggle the visible flag
+ // and write back the configuration settings to the toolbar
+ aProp.getArray()[nVisibleIndex].Value <<= !bVisible;
+ try
+ {
+ xItemContainer->replaceByIndex( i, Any( aProp ));
+ xUIElementSettings->setSettings( xItemContainer );
+ Reference< XPropertySet > xPropSet( xUIElementSettings, UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ Reference< XUIConfigurationPersistence > xUICfgMgr;
+ if (( xPropSet->getPropertyValue("ConfigurationSource") >>= xUICfgMgr ) && ( xUICfgMgr.is() ))
+ xUICfgMgr->store();
+ }
+ }
+ catch (const Exception&)
+ {
+ }
+ break;
+ }
+ }
+ }
+}
+
IMPL_LINK( ToolBarManager, MenuButton, ToolBox*, pToolBar, void )
{
SolarMutexGuard g;
@@ -1698,10 +2106,8 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu, bool )
if ( xDisp.is() )
{
- Sequence< PropertyValue > aPropSeq( 1 );
-
- aPropSeq[ 0 ].Name = "ResourceURL";
- aPropSeq[ 0 ].Value <<= m_aResourceName;
+ Sequence< PropertyValue > aPropSeq{ comphelper::makePropertyValue(
+ "ResourceURL", m_aResourceName) };
xDisp->dispatch( aURL, aPropSeq );
}
@@ -1780,64 +2186,11 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu, bool )
{
// toggle toolbar button visibility
OUString aCommand = pMenu->GetItemCommand( nId );
-
- Reference< XLayoutManager > xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
- if ( xLayoutManager.is() )
- {
- Reference< XUIElementSettings > xUIElementSettings( xLayoutManager->getElement( m_aResourceName ), UNO_QUERY );
- if ( xUIElementSettings.is() )
- {
- Reference< XIndexContainer > xItemContainer( xUIElementSettings->getSettings( true ), UNO_QUERY );
- sal_Int32 nCount = xItemContainer->getCount();
- for ( sal_Int32 i = 0; i < nCount; i++ )
- {
- Sequence< PropertyValue > aProp;
- sal_Int32 nVisibleIndex( -1 );
- OUString aCommandURL;
- bool bVisible( false );
-
- if ( xItemContainer->getByIndex( i ) >>= aProp )
- {
- for ( sal_Int32 j = 0; j < aProp.getLength(); j++ )
- {
- if ( aProp[j].Name == ITEM_DESCRIPTOR_COMMANDURL )
- {
- aProp[j].Value >>= aCommandURL;
- }
- else if ( aProp[j].Name == ITEM_DESCRIPTOR_VISIBLE )
- {
- aProp[j].Value >>= bVisible;
- nVisibleIndex = j;
- }
- }
-
- if (( aCommandURL == aCommand ) && ( nVisibleIndex >= 0 ))
- {
- // We have found the requested item, toggle the visible flag
- // and write back the configuration settings to the toolbar
- aProp[nVisibleIndex].Value <<= !bVisible;
- try
- {
- xItemContainer->replaceByIndex( i, makeAny( aProp ));
- xUIElementSettings->setSettings( xItemContainer );
- Reference< XPropertySet > xPropSet( xUIElementSettings, UNO_QUERY );
- if ( xPropSet.is() )
- {
- Reference< XUIConfigurationPersistence > xUICfgMgr;
- if (( xPropSet->getPropertyValue("ConfigurationSource") >>= xUICfgMgr ) && ( xUICfgMgr.is() ))
- xUICfgMgr->store();
- }
- }
- catch (const Exception&)
- {
- }
-
- break;
- }
- }
- }
- }
- }
+ if (m_aContextResourceName.isEmpty() ||
+ nId - STARTID_CUSTOMIZE_POPUPMENU < m_nContextMinPos)
+ ToggleButton(m_aResourceName, aCommand);
+ else
+ ToggleButton(m_aContextResourceName, aCommand);
}
break;
}
@@ -1853,7 +2206,7 @@ IMPL_LINK_NOARG(ToolBarManager, Select, ToolBox *, void)
return;
sal_Int16 nKeyModifier( static_cast<sal_Int16>(m_pToolBar->GetModifier()) );
- sal_uInt16 nId( m_pToolBar->GetCurItemId() );
+ ToolBoxItemId nId( m_pToolBar->GetCurItemId() );
ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
if ( pIter != m_aControllerMap.end() )
@@ -1898,7 +2251,7 @@ IMPL_LINK( ToolBarManager, DataChanged, DataChangedEvent const *, pDataChangedEv
for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
{
- const sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
+ const ToolBoxItemId nId = m_pToolBar->GetItemId(nPos);
vcl::Window* pWindow = m_pToolBar->GetItemWindow( nId );
if ( pWindow )
{
@@ -1926,7 +2279,7 @@ IMPL_LINK_NOARG(ToolBarManager, AsyncUpdateControllersHdl, Timer *, void)
{
// The guard must be in its own context as the we can get destroyed when our
// own xInterface reference get destroyed!
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
SolarMutexGuard g;
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 294e34cbc30f..5588ff0522d3 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -33,6 +33,7 @@
#include <uielement/togglebuttontoolbarcontroller.hxx>
#include <uielement/FixedTextToolbarController.hxx>
#include <uielement/FixedImageToolbarController.hxx>
+#include <o3tl/string_view.hxx>
namespace framework
{
@@ -92,10 +93,10 @@ using namespace ::com::sun::star;
*/
bool ToolBarMerger::IsCorrectContext(
- const OUString& rContext,
+ std::u16string_view rContext,
std::u16string_view rModuleIdentifier )
{
- return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
+ return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
/**
@@ -215,6 +216,10 @@ void ToolBarMerger::ConvertSequenceToValues(
Must be a valid pointer to a toolbar with items which
should be searched.
+@param
+ nFirstItem
+
+ First toolbar item to search from.
@param
rReferencePoint
@@ -227,7 +232,7 @@ void ToolBarMerger::ConvertSequenceToValues(
position of the reference point and the toolbar used.
*/
ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
- const ToolBox* pToolbar,
+ const ToolBox* pToolbar, sal_uInt16 nFirstItem,
std::u16string_view rReferencePoint )
{
ReferenceToolbarPathInfo aResult;
@@ -236,10 +241,10 @@ ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
const ToolBox::ImplToolItems::size_type nSize( pToolbar->GetItemCount() );
- for ( ToolBox::ImplToolItems::size_type i = 0; i < nSize; i++ )
+ for ( ToolBox::ImplToolItems::size_type i = nFirstItem; i < nSize; i++ )
{
- const sal_uInt16 nItemId = pToolbar->GetItemId( i );
- if ( nItemId > 0 )
+ const ToolBoxItemId nItemId = pToolbar->GetItemId( i );
+ if ( nItemId > ToolBoxItemId(0) )
{
const OUString rCmd = pToolbar->GetItemCommand( nItemId );
if ( rCmd == rReferencePoint )
@@ -303,11 +308,11 @@ ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
bool ToolBarMerger::ProcessMergeOperation(
ToolBox* pToolbar,
ToolBox::ImplToolItems::size_type nPos,
- sal_uInt16& rItemId,
+ ToolBoxItemId& rItemId,
CommandToInfoMap& rCommandMap,
std::u16string_view rModuleIdentifier,
std::u16string_view rMergeCommand,
- const OUString& rMergeCommandParameter,
+ std::u16string_view rMergeCommandParameter,
const AddonToolbarItemContainer& rItems )
{
if ( rMergeCommand == MERGECOMMAND_ADDAFTER )
@@ -366,7 +371,7 @@ bool ToolBarMerger::ProcessMergeOperation(
*/
bool ToolBarMerger::ProcessMergeFallback(
ToolBox* pToolbar,
- sal_uInt16& rItemId,
+ ToolBoxItemId& rItemId,
CommandToInfoMap& rCommandMap,
std::u16string_view rModuleIdentifier,
std::u16string_view rMergeCommand,
@@ -430,7 +435,7 @@ void ToolBarMerger::MergeItems(
ToolBox* pToolbar,
ToolBox::ImplToolItems::size_type nPos,
sal_uInt16 nModIndex,
- sal_uInt16& rItemId,
+ ToolBoxItemId& rItemId,
CommandToInfoMap& rCommandMap,
std::u16string_view rModuleIdentifier,
const AddonToolbarItemContainer& rAddonToolbarItems )
@@ -511,7 +516,7 @@ void ToolBarMerger::MergeItems(
void ToolBarMerger::ReplaceItem(
ToolBox* pToolbar,
ToolBox::ImplToolItems::size_type nPos,
- sal_uInt16& rItemId,
+ ToolBoxItemId& rItemId,
CommandToInfoMap& rCommandMap,
std::u16string_view rModuleIdentifier,
const AddonToolbarItemContainer& rAddonToolbarItems )
@@ -544,9 +549,9 @@ void ToolBarMerger::ReplaceItem(
void ToolBarMerger::RemoveItems(
ToolBox* pToolbar,
ToolBox::ImplToolItems::size_type nPos,
- const OUString& rMergeCommandParameter )
+ std::u16string_view rMergeCommandParameter )
{
- sal_Int32 nCount = rMergeCommandParameter.toInt32();
+ sal_Int32 nCount = o3tl::toInt32(rMergeCommandParameter);
if ( nCount > 0 )
{
for ( sal_Int32 i = 0; i < nCount; i++ )
@@ -582,16 +587,16 @@ void ToolBarMerger::RemoveItems(
Returns true for a successful operation otherwise
false.
*/
-::cppu::OWeakObject* ToolBarMerger::CreateController(
+rtl::Reference<::cppu::OWeakObject> ToolBarMerger::CreateController(
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< frame::XFrame > & xFrame,
ToolBox* pToolbar,
const OUString& rCommandURL,
- sal_uInt16 nId,
+ ToolBoxItemId nId,
sal_uInt16 nWidth,
std::u16string_view rControlType )
{
- ::cppu::OWeakObject* pResult( nullptr );
+ rtl::Reference<::cppu::OWeakObject> pResult;
if ( rControlType == TOOLBARCONTROLLER_BUTTON )
pResult = new ButtonToolbarController( rxContext, pToolbar, rCommandURL );
@@ -621,10 +626,11 @@ void ToolBarMerger::RemoveItems(
return pResult;
}
-void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, ToolBox::ImplToolItems::size_type nPos, sal_uInt16 nItemId, const AddonToolbarItem& rItem )
+void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, ToolBox::ImplToolItems::size_type nPos, ToolBoxItemId nItemId, const AddonToolbarItem& rItem )
{
- pToolbar->InsertItem( nItemId, rItem.aLabel, ToolBoxItemBits::NONE, nPos );
- pToolbar->SetItemCommand( nItemId, rItem.aCommandURL );
+ assert(pToolbar->GetItemData(nItemId) == nullptr); // that future would contain a double free
+
+ pToolbar->InsertItem( nItemId, rItem.aLabel, rItem.aCommandURL, ToolBoxItemBits::NONE, nPos );
pToolbar->SetQuickHelpText( nItemId, rItem.aLabel );
pToolbar->SetItemText( nItemId, rItem.aLabel );
pToolbar->EnableItem( nItemId );
diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx
index cd6f2716a23a..2901eef0ac76 100644
--- a/framework/source/uielement/toolbarmodemenucontroller.cxx
+++ b/framework/source/uielement/toolbarmodemenucontroller.cxx
@@ -26,17 +26,14 @@
#include <com/sun/star/frame/ModuleManager.hpp>
-#include <officecfg/Office/Common.hxx>
#include <toolkit/awt/vclxmenu.hxx>
-#include <vcl/menu.hxx>
+#include <officecfg/Office/Common.hxx>
#include <vcl/svapp.hxx>
#include <vcl/EnumContext.hxx>
#include <rtl/ustrbuf.hxx>
-#include <sal/log.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/types.hxx>
-#include <svtools/miscopt.hxx>
#include <unotools/confignode.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -46,10 +43,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::util;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::ui;
namespace framework
{
@@ -84,7 +78,7 @@ ToolbarModeMenuController::~ToolbarModeMenuController()
void ToolbarModeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- if ( SvtMiscOptions().DisableUICustomization() )
+ if ( officecfg::Office::Common::Misc::DisableUICustomization::get() )
return;
SolarMutexGuard aSolarMutexGuard;
@@ -158,14 +152,14 @@ void ToolbarModeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
// XEventListener
void SAL_CALL ToolbarModeMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -175,47 +169,41 @@ void SAL_CALL ToolbarModeMenuController::statusChanged( const FeatureStateEvent&
OUString aFeatureURL( Event.FeatureURL.Complete );
// All other status events will be processed here
- osl::ClearableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu );
- aLock.clear();
+ aLock.unlock();
if ( !xPopupMenu.is() )
return;
SolarMutexGuard aGuard;
- VCLXPopupMenu* pXPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu ));
- PopupMenu* pVCLPopupMenu = pXPopupMenu ? static_cast<PopupMenu *>(pXPopupMenu->GetMenu()) : nullptr;
-
- SAL_WARN_IF(!pVCLPopupMenu, "fwk.uielement", "worrying lack of popup menu");
- if (!pVCLPopupMenu)
- return;
bool bSetCheckmark = false;
bool bCheckmark = false;
- for ( sal_uInt16 i = 0; i < pVCLPopupMenu->GetItemCount(); i++ )
+ for (sal_Int16 i = 0, nCount = xPopupMenu->getItemCount(); i < nCount; ++i)
{
- sal_uInt16 nId = pVCLPopupMenu->GetItemId( i );
+ sal_Int16 nId = xPopupMenu->getItemId(i);
if ( nId == 0 )
continue;
- OUString aCmd = pVCLPopupMenu->GetItemCommand( nId );
+ OUString aCmd = xPopupMenu->getCommand(nId);
if ( aCmd == aFeatureURL )
{
// Enable/disable item
- pVCLPopupMenu->EnableItem( nId, Event.IsEnabled );
+ xPopupMenu->enableItem(nId, Event.IsEnabled);
// Checkmark
if ( Event.State >>= bCheckmark )
bSetCheckmark = true;
if ( bSetCheckmark )
- pVCLPopupMenu->CheckItem( nId, bCheckmark );
+ xPopupMenu->checkItem(nId, bCheckmark);
else
{
OUString aItemText;
if ( Event.State >>= aItemText )
- pVCLPopupMenu->SetItemText( nId, aItemText );
+ xPopupMenu->setItemText(nId, aItemText);
}
}
}
@@ -224,7 +212,7 @@ void SAL_CALL ToolbarModeMenuController::statusChanged( const FeatureStateEvent&
// XMenuListener
void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent& rEvent )
{
- auto aArgs(comphelper::InitPropertySequence({{"Mode", makeAny(m_xPopupMenu->getCommand(rEvent.MenuId))}}));
+ auto aArgs(comphelper::InitPropertySequence({{"Mode", Any(m_xPopupMenu->getCommand(rEvent.MenuId))}}));
dispatchCommand(m_aCommandURL, aArgs);
}
@@ -277,17 +265,18 @@ void SAL_CALL ToolbarModeMenuController::itemActivated( const css::awt::MenuEven
// XPopupMenuController
void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
if ( m_xFrame.is() && !m_xPopupMenu.is() )
{
// Create popup menu on demand
SolarMutexGuard aSolarMutexGuard;
- m_xPopupMenu = xPopupMenu;
- m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( static_cast<OWeakObject*>(this), UNO_QUERY ));
+ m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get());
+ assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu");
+ m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) );
fillPopupMenu( m_xPopupMenu );
}
}
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index 8f08976528cf..9bd0d72faa06 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -41,18 +41,16 @@
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/ui/theWindowStateConfiguration.hpp>
-#include <vcl/menu.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <officecfg/Office/Common.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/image.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <rtl/ustrbuf.hxx>
-#include <sal/log.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx>
#include <unotools/cmdoptions.hxx>
-#include <svtools/miscopt.hxx>
#include <unotools/collatorwrapper.hxx>
#include <unotools/syslocale.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -68,9 +66,10 @@ using namespace ::com::sun::star::util;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::ui;
-constexpr OUStringLiteral CMD_RESTOREVISIBILITY = u".cmd:RestoreVisibility";
+constexpr OUString CMD_RESTOREVISIBILITY = u".cmd:RestoreVisibility"_ustr;
+constexpr OUStringLiteral CMD_LOCKTOOLBARS = u".uno:ToolbarLock";
-constexpr OUStringLiteral STATIC_CMD_PART = u".uno:AvailableToolbars?Toolbar:string=";
+constexpr OUString STATIC_CMD_PART = u".uno:AvailableToolbars?Toolbar:string="_ustr;
const char STATIC_INTERNAL_CMD_PART[] = ".cmd:";
namespace framework
@@ -85,7 +84,6 @@ struct ToolBarEntry
OUString aUIName;
OUString aCommand;
bool bVisible;
- bool bContextSensitive;
const CollatorWrapper* pCollatorWrapper;
};
@@ -141,8 +139,8 @@ css::uno::Sequence< OUString > SAL_CALL ToolbarsMenuController::getSupportedServ
return { SERVICENAME_POPUPMENUCONTROLLER };
}
-constexpr OUStringLiteral g_aPropUIName( u"UIName" );
-constexpr OUStringLiteral g_aPropResourceURL( u"ResourceURL" );
+constexpr OUString g_aPropUIName( u"UIName"_ustr );
+constexpr OUString g_aPropResourceURL( u"ResourceURL"_ustr );
ToolbarsMenuController::ToolbarsMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ) :
svt::PopupMenuControllerBase( xContext ),
@@ -182,19 +180,14 @@ void ToolbarsMenuController::addCommand(
SolarMutexGuard aSolarMutexGuard;
- Image aImage;
+ css::uno::Reference<css::graphic::XGraphic> xGraphic;
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetUseImagesInMenus() )
- aImage = vcl::CommandInfoProvider::GetImageForCommand(rCommandURL, m_xFrame);
+ xGraphic = vcl::CommandInfoProvider::GetXGraphicForCommand(rCommandURL, m_xFrame);
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( rPopupMenu ));
- if ( pPopupMenu )
- {
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if ( !!aImage )
- pVCLPopupMenu->SetItemImage( nItemId, aImage );
- }
+ if (xGraphic.is())
+ rPopupMenu->setItemImage(nItemId, xGraphic, false);
m_aCommandVector.push_back( rCommandURL );
}
@@ -242,6 +235,7 @@ static void fillHashMap( const Sequence< Sequence< css::beans::PropertyValue > >
}
// private function
+// static
Sequence< Sequence< css::beans::PropertyValue > > ToolbarsMenuController::getLayoutManagerToolbars( const Reference< css::frame::XLayoutManager >& rLayoutManager )
{
std::vector< ToolBarInfo > aToolBarArray;
@@ -280,17 +274,16 @@ Sequence< Sequence< css::beans::PropertyValue > > ToolbarsMenuController::getLay
}
}
- Sequence< css::beans::PropertyValue > aTbSeq( 2 );
- aTbSeq[0].Name = g_aPropUIName;
- aTbSeq[1].Name = g_aPropResourceURL;
-
Sequence< Sequence< css::beans::PropertyValue > > aSeq( aToolBarArray.size() );
+ auto pSeq = aSeq.getArray();
const sal_uInt32 nCount = aToolBarArray.size();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
- aTbSeq[0].Value <<= aToolBarArray[i].aToolBarUIName;
- aTbSeq[1].Value <<= aToolBarArray[i].aToolBarResName;
- aSeq[i] = aTbSeq;
+ Sequence< css::beans::PropertyValue > aTbSeq{
+ comphelper::makePropertyValue(g_aPropUIName, aToolBarArray[i].aToolBarUIName),
+ comphelper::makePropertyValue(g_aPropResourceURL, aToolBarArray[i].aToolBarResName)
+ };
+ pSeq[i] = aTbSeq;
}
return aSeq;
@@ -299,7 +292,7 @@ Sequence< Sequence< css::beans::PropertyValue > > ToolbarsMenuController::getLay
void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
- if( SvtMiscOptions().DisableUICustomization() )
+ if( officecfg::Office::Common::Misc::DisableUICustomization::get() )
return;
SolarMutexGuard aSolarMutexGuard;
@@ -353,7 +346,7 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
if ( a >>= aWindowState )
{
- for ( PropertyValue const & prop : std::as_const(aWindowState) )
+ for (PropertyValue const& prop : aWindowState)
{
if ( prop.Name == WINDOWSTATE_PROPERTY_UINAME )
prop.Value >>= aUIName;
@@ -382,7 +375,6 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
aTbEntry.aUIName = aUIName;
aTbEntry.aCommand = toolbar.first;
aTbEntry.bVisible = xLayoutManager->isElementVisible( toolbar.first );
- aTbEntry.bContextSensitive = bContextSensitive;
aTbEntry.pCollatorWrapper = m_aIntlWrapper.getCaseCollator();
aSortedTbs.push_back( aTbEntry );
}
@@ -400,21 +392,11 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
if ( aSortedTbs[i].bVisible )
m_xPopupMenu->checkItem( nIndex, true );
- {
- SolarMutexGuard aGuard;
- VCLXPopupMenu* pXPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
- PopupMenu* pVCLPopupMenu = pXPopupMenu ? static_cast<PopupMenu *>(pXPopupMenu->GetMenu()) : nullptr;
- assert(pVCLPopupMenu);
- if (pVCLPopupMenu)
- pVCLPopupMenu->SetUserValue( nIndex, reinterpret_cast<void*>( aSortedTbs[i].bContextSensitive ? 1 : 0 ));
- }
-
- // use VCL popup menu pointer to set vital information that are not part of the awt implementation
OUStringBuffer aStrBuf( aStaticCmdPart );
sal_Int32 n = aSortedTbs[i].aCommand.lastIndexOf( '/' );
if (( n > 0 ) && (( n+1 ) < aSortedTbs[i].aCommand.getLength() ))
- aStrBuf.append( std::u16string_view(aSortedTbs[i].aCommand).substr(n+1) );
+ aStrBuf.append( aSortedTbs[i].aCommand.subView(n+1) );
OUString aCmd( aStrBuf.makeStringAndClear() );
@@ -429,12 +411,8 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
bool bAddCommand( true );
SvtCommandOptions aCmdOptions;
- if ( aCmdOptions.HasEntries( SvtCommandOptions::CMDOPTION_DISABLED ))
- {
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,
- "ConfigureDialog"))
- bAddCommand = false;
- }
+ if ( aCmdOptions.HasEntriesDisabled() && aCmdOptions.LookupDisabled("ConfigureDialog"))
+ bAddCommand = false;
if ( bAddCommand )
{
@@ -461,14 +439,16 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > co
OUString aLabelStr(FwkResId(STR_RESTORE_TOOLBARS));
addCommand( m_xPopupMenu, CMD_RESTOREVISIBILITY, aLabelStr );
+ aLabelStr = FwkResId(STR_LOCK_TOOLBARS);
+ addCommand( m_xPopupMenu, CMD_LOCKTOOLBARS, aLabelStr );
}
// XEventListener
void SAL_CALL ToolbarsMenuController::disposing( const EventObject& )
{
- Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY );
+ Reference< css::awt::XMenuListener > xHolder(this);
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xDocCfgMgr.clear();
@@ -476,7 +456,7 @@ void SAL_CALL ToolbarsMenuController::disposing( const EventObject& )
m_xContext.clear();
if ( m_xPopupMenu.is() )
- m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast<OWeakObject *>(this), UNO_QUERY ));
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(this) );
m_xPopupMenu.clear();
}
@@ -486,47 +466,41 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev
OUString aFeatureURL( Event.FeatureURL.Complete );
// All other status events will be processed here
- osl::ClearableMutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu );
- aLock.clear();
+ aLock.unlock();
if ( !xPopupMenu.is() )
return;
SolarMutexGuard aGuard;
- VCLXPopupMenu* pXPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu ));
- PopupMenu* pVCLPopupMenu = pXPopupMenu ? static_cast<PopupMenu *>(pXPopupMenu->GetMenu()) : nullptr;
-
- SAL_WARN_IF(!pVCLPopupMenu, "fwk.uielement", "worrying lack of popup menu");
- if (!pVCLPopupMenu)
- return;
bool bSetCheckmark = false;
bool bCheckmark = false;
- for ( sal_uInt16 i = 0; i < pVCLPopupMenu->GetItemCount(); i++ )
+ for (sal_Int16 i = 0, nCount = xPopupMenu->getItemCount(); i < nCount; ++i)
{
- sal_uInt16 nId = pVCLPopupMenu->GetItemId( i );
+ sal_Int16 nId = xPopupMenu->getItemId(i);
if ( nId == 0 )
continue;
- OUString aCmd = pVCLPopupMenu->GetItemCommand( nId );
+ OUString aCmd = xPopupMenu->getCommand(nId);
if ( aCmd == aFeatureURL )
{
// Enable/disable item
- pVCLPopupMenu->EnableItem( nId, Event.IsEnabled );
+ xPopupMenu->enableItem(nId, Event.IsEnabled);
// Checkmark
if ( Event.State >>= bCheckmark )
bSetCheckmark = true;
if ( bSetCheckmark )
- pVCLPopupMenu->CheckItem( nId, bCheckmark );
+ xPopupMenu->checkItem(nId, bCheckmark);
else
{
OUString aItemText;
if ( Event.State >>= aItemText )
- pVCLPopupMenu->SetItemText( nId, aItemText );
+ xPopupMenu->setItemText(nId, aItemText);
}
}
}
@@ -542,7 +516,7 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
Reference< XNameAccess > xPersistentWindowState;
{
- osl::MutexGuard aLock(m_aMutex);
+ std::unique_lock aLock(m_aMutex);
xPopupMenu = m_xPopupMenu;
xContext = m_xContext;
xURLTransformer = m_xURLTransformer;
@@ -553,14 +527,9 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
if ( !xPopupMenu.is() )
return;
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu ));
- if ( !pPopupMenu )
- return;
-
SolarMutexGuard aSolarMutexGuard;
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId ));
+ OUString aCmd(xPopupMenu->getCommand(rEvent.MenuId));
if ( aCmd.startsWith( STATIC_INTERNAL_CMD_PART ) )
{
// Command to restore the visibility of all context sensitive toolbars
@@ -599,8 +568,8 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
if ( !bVisible && bContextSensitive && nVisibleIndex >= 0 )
{
// Default is: Every context sensitive toolbar is visible
- aWindowState[nVisibleIndex].Value <<= true;
- xNameReplace->replaceByName( aElementName, makeAny( aWindowState ));
+ aWindowState.getArray()[nVisibleIndex].Value <<= true;
+ xNameReplace->replaceByName( aElementName, Any( aWindowState ));
bRefreshToolbars = true;
}
}
@@ -620,7 +589,7 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
{
try
{
- xPropSet->setPropertyValue("RefreshContextToolbarVisibility", makeAny( true ));
+ xPropSet->setPropertyValue("RefreshContextToolbarVisibility", Any( true ));
}
catch ( const RuntimeException& )
{
@@ -645,20 +614,15 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
else if ( aCmd.indexOf( STATIC_CMD_PART ) < 0 )
{
URL aTargetURL;
- Sequence<PropertyValue> aArgs;
aTargetURL.Complete = aCmd;
xURLTransformer->parseStrict( aTargetURL );
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
if ( xDispatchProvider.is() )
{
- Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(
- aTargetURL, OUString(), 0 );
-
ExecuteInfo* pExecuteInfo = new ExecuteInfo;
- pExecuteInfo->xDispatch = xDispatch;
- pExecuteInfo->aTargetURL = aTargetURL;
- pExecuteInfo->aArgs = aArgs;
+ pExecuteInfo->xDispatch = xDispatchProvider->queryDispatch(aTargetURL, OUString(), 0);
+ pExecuteInfo->aTargetURL = aTargetURL;
Application::PostUserEvent( LINK(nullptr, ToolbarsMenuController, ExecuteHdl_Impl), pExecuteInfo );
}
}
@@ -671,11 +635,9 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r
sal_Int32 nIndex = aCmd.indexOf( '=' );
if (( nIndex > 0 ) && (( nIndex+1 ) < aCmd.getLength() ))
{
- OUStringBuffer aBuf( "private:resource/toolbar/" );
- aBuf.append( std::u16string_view(aCmd).substr(nIndex+1) );
+ OUString aToolBarResName = OUString::Concat("private:resource/toolbar/") + aCmd.subView(nIndex+1);
- bool bShow( !pVCLPopupMenu->IsItemChecked( rEvent.MenuId ));
- OUString aToolBarResName( aBuf.makeStringAndClear() );
+ const bool bShow(!xPopupMenu->isItemChecked(rEvent.MenuId));
if ( bShow )
{
xLayoutManager->createElement( aToolBarResName );
@@ -699,7 +661,7 @@ void SAL_CALL ToolbarsMenuController::itemActivated( const css::awt::MenuEvent&
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
Reference< XURLTransformer > xURLTransformer( m_xURLTransformer );
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
fillPopupMenu( m_xPopupMenu );
aCmdVector = m_aCommandVector;
}
@@ -736,30 +698,30 @@ void SAL_CALL ToolbarsMenuController::itemActivated( const css::awt::MenuEvent&
// XPopupMenuController
void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu )
{
- osl::MutexGuard aLock( m_aMutex );
+ std::unique_lock aLock( m_aMutex );
- throwIfDisposed();
+ throwIfDisposed(aLock);
if ( m_xFrame.is() && !m_xPopupMenu.is() )
{
// Create popup menu on demand
SolarMutexGuard aSolarMutexGuard;
- m_xPopupMenu = xPopupMenu;
- m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( static_cast<OWeakObject*>(this), UNO_QUERY ));
+ m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get());
+ assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu");
+ m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) );
fillPopupMenu( m_xPopupMenu );
}
}
// XInitialization
-void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArguments )
+void ToolbarsMenuController::initializeImpl( std::unique_lock<std::mutex>& rGuard, const Sequence< Any >& aArguments )
{
- osl::MutexGuard aLock( m_aMutex );
- bool bInitalized( m_bInitialized );
- if ( bInitalized )
+ bool bInitialized( m_bInitialized );
+ if ( bInitialized )
return;
- svt::PopupMenuControllerBase::initialize(aArguments);
+ svt::PopupMenuControllerBase::initializeImpl(rGuard, aArguments);
if ( !m_bInitialized )
return;
@@ -803,7 +765,7 @@ IMPL_STATIC_LINK( ToolbarsMenuController, ExecuteHdl_Impl, void*, p, void )
// elements if a component gets detached from its frame!
if ( pExecuteInfo->xDispatch.is() )
{
- pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
+ pExecuteInfo->xDispatch->dispatch(pExecuteInfo->aTargetURL, Sequence<PropertyValue>());
}
}
catch ( const Exception& )
diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx
index b74aa19136f3..30d0e84e2b1a 100644
--- a/framework/source/uielement/toolbarwrapper.cxx
+++ b/framework/source/uielement/toolbarwrapper.cxx
@@ -20,14 +20,16 @@
#include <uielement/toolbarwrapper.hxx>
#include <uielement/toolbarmanager.hxx>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <toolkit/helper/vclunohelper.hxx>
-#include <cppuhelper/queryinterface.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
+#include <vcl/weldutils.hxx>
+#include <vcl/wintypes.hxx>
using namespace com::sun::star;
using namespace com::sun::star::uno;
@@ -42,42 +44,22 @@ namespace framework
{
ToolBarWrapper::ToolBarWrapper( const Reference< XComponentContext >& rxContext ) :
- UIConfigElementWrapperBase( UIElementType::TOOLBAR ),
+ ImplInheritanceHelper( UIElementType::TOOLBAR ),
m_xContext( rxContext )
{
}
ToolBarWrapper::~ToolBarWrapper()
{
-}
-
-// XInterface
-void SAL_CALL ToolBarWrapper::acquire() throw()
-{
- UIConfigElementWrapperBase::acquire();
-}
-
-void SAL_CALL ToolBarWrapper::release() throw()
-{
- UIConfigElementWrapperBase::release();
-}
-
-uno::Any SAL_CALL ToolBarWrapper::queryInterface( const uno::Type & rType )
-{
- Any a = ::cppu::queryInterface(
- rType ,
- static_cast< css::ui::XUIFunctionListener* >(this) );
-
- if( a.hasValue() )
- return a;
-
- return UIConfigElementWrapperBase::queryInterface( rType );
+ m_xWeldedToolbar.reset(nullptr);
+ m_xTopLevel.reset(nullptr);
+ m_xBuilder.reset(nullptr);
}
// XComponent
void SAL_CALL ToolBarWrapper::dispose()
{
- Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
+ Reference< XComponent > xThis(this);
{
SolarMutexGuard g;
@@ -90,6 +72,14 @@ void SAL_CALL ToolBarWrapper::dispose()
SolarMutexGuard g;
+ auto xMultiplexer( ContextChangeEventMultiplexer::get( m_xContext ) );
+ xMultiplexer->removeAllContextChangeEventListeners( this );
+
+ Reference< XComponent > xComponent( m_xSubElement, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->removeEventListener( Reference< XUIConfigurationListener >( this ));
+ m_xSubElement.clear();
+
if ( m_xToolBarManager.is() )
m_xToolBarManager->dispose();
m_xToolBarManager.clear();
@@ -130,9 +120,25 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments )
if ( !(xFrame.is() && m_xConfigSource.is()) )
return;
+ OUString aContextPart;
+ if ( m_aResourceURL.startsWith( "private:resource/toolbar/singlemode", &aContextPart ) && aContextPart.isEmpty() )
+ {
+ auto xMultiplexer( ContextChangeEventMultiplexer::get( m_xContext ) );
+ try
+ {
+ xMultiplexer->addContextChangeEventListener( this, xFrame->getController() );
+ }
+ catch( const Exception& )
+ {
+ }
+ // Avoid flickering on context change
+ bPopupMode = true;
+ }
+
// Create VCL based toolbar which will be filled with settings data
VclPtr<ToolBox> pToolBar;
- ToolBarManager* pToolBarManager = nullptr;
+ rtl::Reference<ToolBarManager> pToolBarManager;
+ if ( aContextPart.isEmpty() )
{
SolarMutexGuard aSolarMutexGuard;
if ( !xParentWindow.is() )
@@ -140,28 +146,42 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments )
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xParentWindow );
if ( pWindow )
{
- sal_uLong nStyles = WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
+ WinBits nStyles = WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
pToolBar = VclPtr<ToolBox>::Create( pWindow, nStyles );
pToolBar->SetLineSpacing(true);
pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar );
- m_xToolBarManager.set( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY );
+ m_xToolBarManager = pToolBarManager;
pToolBar->WillUsePopupMode( bPopupMode );
}
+ else if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ {
+ m_xBuilder = Application::CreateBuilder(pTunnel->getWidget(), "svt/ui/managedtoolbar.ui");
+ m_xTopLevel = m_xBuilder->weld_container("toolbarcontainer");
+ m_xWeldedToolbar = m_xBuilder->weld_toolbar("managedtoolbar");
+ if ( m_xWeldedToolbar )
+ {
+ pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, m_xWeldedToolbar.get(), m_xBuilder.get() );
+ m_xToolBarManager = pToolBarManager;
+ }
+ }
}
try
{
m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
- if ( m_xConfigData.is() && pToolBar && pToolBarManager )
+ if ( m_xConfigData.is() && (pToolBar || m_xWeldedToolbar) && pToolBarManager )
{
// Fill toolbar with container contents
- pToolBarManager->FillToolbar( m_xConfigData );
- pToolBar->EnableCustomize();
- ::Size aActSize( pToolBar->GetSizePixel() );
- ::Size aSize( pToolBar->CalcWindowSizePixel() );
- aSize.setWidth( aActSize.Width() );
- pToolBar->SetOutputSizePixel( aSize );
+ impl_fillNewData();
+ if (pToolBar)
+ {
+ pToolBar->EnableCustomize();
+ ::Size aActSize( pToolBar->GetSizePixel() );
+ ::Size aSize( pToolBar->CalcWindowSizePixel() );
+ aSize.setWidth( aActSize.Width() );
+ pToolBar->SetOutputSizePixel( aSize );
+ }
}
}
catch ( const NoSuchElementException& )
@@ -181,9 +201,10 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments )
}
// XEventListener
-void SAL_CALL ToolBarWrapper::disposing( const css::lang::EventObject& )
+void SAL_CALL ToolBarWrapper::disposing( const css::lang::EventObject& aEvent )
{
- // nothing todo
+ if ( aEvent.Source == m_xSubElement )
+ m_xSubElement.clear();
}
// XUpdatable
@@ -194,9 +215,8 @@ void SAL_CALL ToolBarWrapper::update()
if ( m_bDisposed )
throw DisposedException();
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( pToolBarManager )
- pToolBarManager->CheckAndUpdateImages();
+ if ( m_xToolBarManager )
+ m_xToolBarManager->CheckAndUpdateImages();
}
// XUIElementSettings
@@ -207,22 +227,21 @@ void SAL_CALL ToolBarWrapper::updateSettings()
if ( m_bDisposed )
throw DisposedException();
- if ( !m_xToolBarManager.is() )
- return;
-
if ( m_xConfigSource.is() && m_bPersistent )
{
try
{
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
-
m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
if ( m_xConfigData.is() )
- pToolBarManager->FillToolbar( m_xConfigData );
+ impl_fillNewData();
}
catch ( const NoSuchElementException& )
{
}
+
+ auto pContainer( m_aListenerContainer.getContainer( cppu::UnoType< XEventListener >::get() ) );
+ if ( pContainer )
+ pContainer->forEach< XUIElementSettings >([]( const Reference<XUIElementSettings>& xListener ){ xListener->updateSettings(); });
}
else if ( !m_bPersistent )
{
@@ -232,10 +251,54 @@ void SAL_CALL ToolBarWrapper::updateSettings()
void ToolBarWrapper::impl_fillNewData()
{
- // Transient toolbar => Fill toolbar with new data
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( pToolBarManager )
- pToolBarManager->FillToolbar( m_xConfigData );
+ if ( m_xToolBarManager )
+ {
+ Reference< XUIElementSettings > xUIElementSettings( m_xSubElement, UNO_QUERY );
+ Reference< XIndexAccess > xContextData = xUIElementSettings.is() ? xUIElementSettings->getSettings( false ) : nullptr;
+ OUString aContextToolbar = xContextData.is() ? m_xSubElement->getResourceURL() : OUString();
+ m_xToolBarManager->FillToolbar( m_xConfigData, xContextData, aContextToolbar );
+ }
+}
+
+//XContextChangeEventListener
+void SAL_CALL ToolBarWrapper::notifyContextChangeEvent( const ContextChangeEventObject& aEvent )
+{
+ SolarMutexGuard g;
+
+ if ( m_bDisposed )
+ throw DisposedException();
+
+ if ( aEvent.ContextName.isEmpty() || aEvent.ContextName == "default" )
+ return;
+
+ const OUString aContextToolbar( m_aResourceURL + "-" + aEvent.ContextName.toAsciiLowerCase() );
+ if ( m_xSubElement.is() && m_xSubElement->getResourceURL() == aContextToolbar )
+ return;
+
+ Reference< XComponent > xComponent( m_xSubElement, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->removeEventListener( Reference< XUIConfigurationListener >( this ));
+ m_xSubElement.clear();
+
+ Reference< XLayoutManager > xLayoutManager;
+ Reference< XPropertySet > xPropSet( m_xWeakFrame.get(), UNO_QUERY );
+ if ( xPropSet.is() )
+ xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
+ if ( !xLayoutManager.is() )
+ return;
+
+ xLayoutManager->createElement( aContextToolbar );
+ m_xSubElement.set( xLayoutManager->getElement( aContextToolbar ) );
+ xComponent.set( m_xSubElement, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->addEventListener( Reference< XUIConfigurationListener >( this ));
+
+ if ( m_xConfigData.is() )
+ {
+ xLayoutManager->lock();
+ impl_fillNewData();
+ xLayoutManager->unlock();
+ }
}
// XUIElement interface
@@ -243,14 +306,10 @@ Reference< XInterface > SAL_CALL ToolBarWrapper::getRealInterface( )
{
SolarMutexGuard g;
- if ( m_xToolBarManager.is() )
+ if ( m_xToolBarManager )
{
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( pToolBarManager )
- {
- vcl::Window* pWindow = pToolBarManager->GetToolBar();
- return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
- }
+ vcl::Window* pWindow = m_xToolBarManager->GetToolBar();
+ return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
}
return Reference< XInterface >();
@@ -263,12 +322,8 @@ void SAL_CALL ToolBarWrapper::functionExecute(
{
SolarMutexGuard g;
- if ( m_xToolBarManager.is() )
- {
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( pToolBarManager )
- pToolBarManager->notifyRegisteredControllers( aUIElementName, aCommand );
- }
+ if ( m_xToolBarManager )
+ m_xToolBarManager->notifyRegisteredControllers( aUIElementName, aCommand );
}
void SAL_CALL ToolBarWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& aValue )
@@ -285,11 +340,10 @@ void SAL_CALL ToolBarWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandl
if ( !(m_xToolBarManager.is() && !m_bDisposed && ( bNewNoClose != bNoClose )))
return;
- ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() );
- if ( !pToolBarManager )
+ if ( !m_xToolBarManager )
return;
- ToolBox* pToolBox = pToolBarManager->GetToolBar();
+ ToolBox* pToolBox = m_xToolBarManager->GetToolBar();
if ( !pToolBox )
return;
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 7fdef0eaf06d..0b8bad8ccdfa 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -39,6 +39,7 @@
#include <vcl/mnemonic.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/string.hxx>
@@ -54,7 +55,7 @@ using namespace ::com::sun::star::frame;
const char CONFIGURATION_ROOT_ACCESS[] = "/org.openoffice.Office.UI.";
// Special resource URLs to retrieve additional information
-constexpr OUStringLiteral PRIVATE_RESOURCE_URL = u"private:";
+constexpr OUString PRIVATE_RESOURCE_URL = u"private:"_ustr;
const sal_Int32 COMMAND_PROPERTY_IMAGE = 1;
const sal_Int32 COMMAND_PROPERTY_ROTATE = 2;
@@ -70,7 +71,7 @@ namespace {
class ConfigurationAccess_UICommand : // Order is necessary for right initialization!
public ::cppu::WeakImplHelper<XNameAccess,XContainerListener>
{
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
public:
ConfigurationAccess_UICommand( std::u16string_view aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext );
virtual ~ConfigurationAccess_UICommand() override;
@@ -119,7 +120,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
Any getSequenceFromCache( const OUString& aCommandURL );
Any getInfoFromCommand( const OUString& rCommandURL );
- void fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel );
+ static void fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel );
Sequence< OUString > getAllCommands();
void fillCache();
void addGenericInfoToCache();
@@ -175,7 +176,7 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( std::u16string_vie
ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
xContainer->removeContainerListener(m_xConfigListener);
@@ -187,7 +188,7 @@ ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
// XNameAccess
Any ConfigurationAccess_UICommand::getByNameImpl( const OUString& rCommandURL )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
initializeConfigAccess();
@@ -202,11 +203,11 @@ Any ConfigurationAccess_UICommand::getByNameImpl( const OUString& rCommandURL )
addGenericInfoToCache();
if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST ))
- return makeAny( m_aCommandImageList );
+ return Any( m_aCommandImageList );
else if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST ))
- return makeAny( m_aCommandRotateImageList );
+ return Any( m_aCommandRotateImageList );
else if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ))
- return makeAny( m_aCommandMirrorImageList );
+ return Any( m_aCommandMirrorImageList );
else
return Any();
}
@@ -248,6 +249,7 @@ sal_Bool SAL_CALL ConfigurationAccess_UICommand::hasElements()
return true;
}
+// static
void ConfigurationAccess_UICommand::fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel )
{
OUString aStr(aLabel.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()));
@@ -265,25 +267,26 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman
if ( !pIter->second.bCommandNameCreated )
fillInfoFromResult( pIter->second, pIter->second.aLabel );
- Sequence< PropertyValue > aPropSeq( 8 );
- aPropSeq[0].Name = "Label";
- aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ?
- makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel );
- aPropSeq[1].Name = "Name";
- aPropSeq[1].Value <<= pIter->second.aCommandName;
- aPropSeq[2].Name = "Popup";
- aPropSeq[2].Value <<= pIter->second.bPopup;
- aPropSeq[3].Name = m_aPropProperties;
- aPropSeq[3].Value <<= pIter->second.nProperties;
- aPropSeq[4].Name = "PopupLabel";
- aPropSeq[4].Value <<= pIter->second.aPopupLabel;
- aPropSeq[5].Name = "TooltipLabel";
- aPropSeq[5].Value <<= pIter->second.aTooltipLabel;
- aPropSeq[6].Name = "TargetURL";
- aPropSeq[6].Value <<= pIter->second.aTargetURL;
- aPropSeq[7].Name = "IsExperimental";
- aPropSeq[7].Value <<= pIter->second.bIsExperimental;
- return makeAny( aPropSeq );
+ static constexpr OUString sLabel = u"Label"_ustr;
+ static constexpr OUString sName = u"Name"_ustr;
+ static constexpr OUString sPopup = u"Popup"_ustr;
+ static constexpr OUString sPopupLabel = u"PopupLabel"_ustr;
+ static constexpr OUString sTooltipLabel = u"TooltipLabel"_ustr;
+ static constexpr OUString sTargetURL = u"TargetURL"_ustr;
+ static constexpr OUString sIsExperimental = u"IsExperimental"_ustr;
+ Sequence< PropertyValue > aPropSeq{
+ comphelper::makePropertyValue(sLabel, !pIter->second.aContextLabel.isEmpty()
+ ? Any(pIter->second.aContextLabel)
+ : Any(pIter->second.aLabel)),
+ comphelper::makePropertyValue(sName, pIter->second.aCommandName),
+ comphelper::makePropertyValue(sPopup, pIter->second.bPopup),
+ comphelper::makePropertyValue(m_aPropProperties, pIter->second.nProperties),
+ comphelper::makePropertyValue(sPopupLabel, pIter->second.aPopupLabel),
+ comphelper::makePropertyValue(sTooltipLabel, pIter->second.aTooltipLabel),
+ comphelper::makePropertyValue(sTargetURL, pIter->second.aTargetURL),
+ comphelper::makePropertyValue(sIsExperimental, pIter->second.bIsExperimental)
+ };
+ return Any( aPropSeq );
}
return Any();
@@ -430,7 +433,7 @@ Any ConfigurationAccess_UICommand::getInfoFromCommand( const OUString& rCommandU
Sequence< OUString > ConfigurationAccess_UICommand::getAllCommands()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -521,21 +524,21 @@ void ConfigurationAccess_UICommand::initializeConfigAccess()
// container.XContainerListener
void SAL_CALL ConfigurationAccess_UICommand::elementInserted( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
void SAL_CALL ConfigurationAccess_UICommand::elementRemoved( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
void SAL_CALL ConfigurationAccess_UICommand::elementReplaced( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
@@ -545,7 +548,7 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven
{
// SAFE
// remove our reference to the config access
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -570,32 +573,31 @@ void UICommandDescription::ensureGenericUICommandsForLanguage(const LanguageTag&
}
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext)
- : UICommandDescription_BASE(m_aMutex)
- , m_aPrivateResourceURL(PRIVATE_RESOURCE_URL)
+ : m_aPrivateResourceURL(PRIVATE_RESOURCE_URL)
, m_xContext(rxContext)
{
- LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
+ SvtSysLocale aSysLocale;
+ const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
- ensureGenericUICommandsForLanguage(aCurrentLanguage);
+ ensureGenericUICommandsForLanguage(rCurrentLanguage);
impl_fillElements("ooSetupFactoryCommandConfigRef");
// insert generic commands
- auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ auto& rMap = m_aUICommandsHashMap[rCurrentLanguage];
UICommandsHashMap::iterator pIter = rMap.find( "GenericCommands" );
if ( pIter != rMap.end() )
- pIter->second = m_xGenericUICommands[aCurrentLanguage];
+ pIter->second = m_xGenericUICommands[rCurrentLanguage];
}
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext, bool)
- : UICommandDescription_BASE(m_aMutex)
- , m_xContext(rxContext)
+ : m_xContext(rxContext)
{
}
UICommandDescription::~UICommandDescription()
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
m_aModuleToCommandFileMap.clear();
m_aUICommandsHashMap.clear();
m_xGenericUICommands.clear();
@@ -605,13 +607,15 @@ void UICommandDescription::impl_fillElements(const char* _pName)
m_xModuleManager.set( ModuleManager::create( m_xContext ) );
const Sequence< OUString > aElementNames = m_xModuleManager->getElementNames();
+ SvtSysLocale aSysLocale;
+
for ( OUString const & aModuleIdentifier : aElementNames )
{
Sequence< PropertyValue > aSeq;
if ( m_xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
{
OUString aCommandStr;
- for ( PropertyValue const & prop : std::as_const(aSeq) )
+ for (PropertyValue const& prop : aSeq)
{
if ( prop.Name.equalsAscii(_pName) )
{
@@ -624,8 +628,8 @@ void UICommandDescription::impl_fillElements(const char* _pName)
m_aModuleToCommandFileMap.emplace( aModuleIdentifier, aCommandStr );
// Create second mapping Command File ==> commands instance
- LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
- auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
+ auto& rMap = m_aUICommandsHashMap[rCurrentLanguage];
UICommandsHashMap::iterator pIter = rMap.find( aCommandStr );
if ( pIter == rMap.end() )
rMap.emplace( aCommandStr, Reference< XNameAccess >() );
@@ -635,20 +639,21 @@ void UICommandDescription::impl_fillElements(const char* _pName)
Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
{
- LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
+ SvtSysLocale aSysLocale;
+ const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
Any a;
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToCommandFileMap::const_iterator pM2CIter = m_aModuleToCommandFileMap.find( aName );
if ( pM2CIter != m_aModuleToCommandFileMap.end() )
{
OUString aCommandFile( pM2CIter->second );
- auto pMapIter = m_aUICommandsHashMap.find( aCurrentLanguage );
+ auto pMapIter = m_aUICommandsHashMap.find( rCurrentLanguage );
if ( pMapIter == m_aUICommandsHashMap.end() )
impl_fillElements("ooSetupFactoryCommandConfigRef");
- auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ auto& rMap = m_aUICommandsHashMap[rCurrentLanguage];
UICommandsHashMap::iterator pIter = rMap.find( aCommandFile );
if ( pIter != rMap.end() )
{
@@ -656,13 +661,11 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
a <<= pIter->second;
else
{
- ensureGenericUICommandsForLanguage(aCurrentLanguage);
+ ensureGenericUICommandsForLanguage(rCurrentLanguage);
- Reference< XNameAccess > xUICommands;
- ConfigurationAccess_UICommand* pUICommands = new ConfigurationAccess_UICommand( aCommandFile,
- m_xGenericUICommands[aCurrentLanguage],
- m_xContext );
- xUICommands.set( static_cast< cppu::OWeakObject* >( pUICommands ),UNO_QUERY );
+ Reference< XNameAccess > xUICommands = new ConfigurationAccess_UICommand( aCommandFile,
+ m_xGenericUICommands[rCurrentLanguage],
+ m_xContext );
pIter->second = xUICommands;
a <<= xUICommands;
}
@@ -670,10 +673,10 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
}
else if ( !m_aPrivateResourceURL.isEmpty() && aName.startsWith( m_aPrivateResourceURL ) )
{
- ensureGenericUICommandsForLanguage(aCurrentLanguage);
+ ensureGenericUICommandsForLanguage(rCurrentLanguage);
// special keys to retrieve information about a set of commands
- return m_xGenericUICommands[aCurrentLanguage]->getByName( aName );
+ return m_xGenericUICommands[rCurrentLanguage]->getByName( aName );
}
else
{
@@ -685,14 +688,14 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
Sequence< OUString > SAL_CALL UICommandDescription::getElementNames()
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return comphelper::mapKeysToSequence( m_aModuleToCommandFileMap );
}
sal_Bool SAL_CALL UICommandDescription::hasByName( const OUString& aName )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToCommandFileMap::const_iterator pIter = m_aModuleToCommandFileMap.find( aName );
return ( pIter != m_aModuleToCommandFileMap.end() );
@@ -712,33 +715,12 @@ sal_Bool SAL_CALL UICommandDescription::hasElements()
} // namespace framework
-namespace {
-
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new framework::UICommandDescription(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_framework_UICommandDescription_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new framework::UICommandDescription(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/addonstoolbarfactory.cxx b/framework/source/uifactory/addonstoolbarfactory.cxx
index 63742c89249c..10e91380a871 100644
--- a/framework/source/uifactory/addonstoolbarfactory.cxx
+++ b/framework/source/uifactory/addonstoolbarfactory.cxx
@@ -26,10 +26,10 @@
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
@@ -38,7 +38,6 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
using namespace framework;
@@ -83,15 +82,14 @@ AddonsToolBarFactory::AddonsToolBarFactory(
{
}
-bool IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& aContextList )
+bool IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view aContextList )
{
- if ( aContextList.isEmpty() )
+ if ( aContextList.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
- sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );
- return ( nIndex >= 0 );
+ return aContextList.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
@@ -180,23 +178,15 @@ Reference< XUIElement > SAL_CALL AddonsToolBarFactory::createUIElement(
aConfigData.hasElements() &&
hasButtonsInContext( aConfigData, xFrame ))
{
- PropertyValue aPropValue;
- Sequence< Any > aPropSeq( 3 );
- aPropValue.Name = "Frame";
- aPropValue.Value <<= xFrame;
- aPropSeq[0] <<= aPropValue;
- aPropValue.Name = "ConfigurationData";
- aPropValue.Value <<= aConfigData;
- aPropSeq[1] <<= aPropValue;
- aPropValue.Name = "ResourceURL";
- aPropValue.Value <<= aResourceURL;
- aPropSeq[2] <<= aPropValue;
+ Sequence< Any > aPropSeq{ Any(comphelper::makePropertyValue("Frame", xFrame)),
+ Any(comphelper::makePropertyValue("ConfigurationData",
+ aConfigData)),
+ Any(comphelper::makePropertyValue("ResourceURL", aResourceURL)) };
SolarMutexGuard aGuard;
- AddonsToolBarWrapper* pToolBarWrapper = new AddonsToolBarWrapper( m_xContext );
- xToolBar.set( static_cast<OWeakObject *>(pToolBarWrapper), UNO_QUERY );
- Reference< XInitialization > xInit( xToolBar, UNO_QUERY );
- xInit->initialize( aPropSeq );
+ rtl::Reference<AddonsToolBarWrapper> pToolBarWrapper = new AddonsToolBarWrapper( m_xContext );
+ xToolBar = pToolBarWrapper;
+ pToolBarWrapper->initialize( aPropSeq );
}
return xToolBar;
diff --git a/framework/source/uifactory/factoryconfiguration.cxx b/framework/source/uifactory/factoryconfiguration.cxx
index c0c75db7bba8..047a6b6edb68 100644
--- a/framework/source/uifactory/factoryconfiguration.cxx
+++ b/framework/source/uifactory/factoryconfiguration.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/container/XContainer.hpp>
#include <comphelper/propertysequence.hxx>
+#include <utility>
// Defines
@@ -53,12 +54,12 @@ static OUString getHashKeyFromStrings(
// XInterface, XTypeProvider
-ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory( const Reference< XComponentContext >& rxContext, const OUString& _sRoot ) :
+ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory( const Reference< XComponentContext >& rxContext, OUString _sRoot ) :
m_aPropCommand( "Command" ),
m_aPropModule( "Module" ),
m_aPropController( "Controller" ),
m_aPropValue( "Value" ),
- m_sRoot(_sRoot),
+ m_sRoot(std::move(_sRoot)),
m_bConfigAccessInitialized( false )
{
m_xConfigProvider = configuration::theDefaultProvider::get( rxContext );
@@ -66,7 +67,7 @@ ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory( co
ConfigurationAccess_ControllerFactory::~ConfigurationAccess_ControllerFactory()
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
@@ -75,7 +76,7 @@ ConfigurationAccess_ControllerFactory::~ConfigurationAccess_ControllerFactory()
OUString ConfigurationAccess_ControllerFactory::getServiceFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
MenuControllerMap::const_iterator pIter = m_aMenuControllerMap.find( getHashKeyFromStrings( rCommandURL, rModule ));
if ( pIter != m_aMenuControllerMap.end() )
@@ -94,7 +95,7 @@ OUString ConfigurationAccess_ControllerFactory::getServiceFromCommandModule( std
}
OUString ConfigurationAccess_ControllerFactory::getValueFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
MenuControllerMap::const_iterator pIter = m_aMenuControllerMap.find( getHashKeyFromStrings( rCommandURL, rModule ));
@@ -118,7 +119,7 @@ void ConfigurationAccess_ControllerFactory::addServiceToCommandModule(
std::u16string_view rModule,
const OUString& rServiceSpecifier )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
OUString aHashKey = getHashKeyFromStrings( rCommandURL, rModule );
m_aMenuControllerMap.emplace( aHashKey,ControllerInfo(rServiceSpecifier,OUString()) );
@@ -128,7 +129,7 @@ void ConfigurationAccess_ControllerFactory::removeServiceFromCommandModule(
std::u16string_view rCommandURL,
std::u16string_view rModule )
{
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
OUString aHashKey = getHashKeyFromStrings( rCommandURL, rModule );
m_aMenuControllerMap.erase( aHashKey );
@@ -142,7 +143,7 @@ void SAL_CALL ConfigurationAccess_ControllerFactory::elementInserted( const Cont
OUString aService;
OUString aValue;
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if ( impl_getElementProps( aEvent.Element, aCommand, aModule, aService, aValue ))
{
@@ -162,7 +163,7 @@ void SAL_CALL ConfigurationAccess_ControllerFactory::elementRemoved ( const Cont
OUString aService;
OUString aValue;
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
if ( impl_getElementProps( aEvent.Element, aCommand, aModule, aService, aValue ))
{
@@ -182,14 +183,14 @@ void SAL_CALL ConfigurationAccess_ControllerFactory::elementReplaced( const Cont
void SAL_CALL ConfigurationAccess_ControllerFactory::disposing( const EventObject& )
{
// remove our reference to the config access
- osl::MutexGuard g(m_mutex);
+ std::unique_lock g(m_mutex);
m_xConfigAccess.clear();
}
void ConfigurationAccess_ControllerFactory::readConfigurationData()
{
// SAFE
- osl::ClearableMutexGuard aLock( m_mutex );
+ std::unique_lock aLock( m_mutex );
if ( !m_bConfigAccessInitialized )
{
@@ -212,11 +213,11 @@ void ConfigurationAccess_ControllerFactory::readConfigurationData()
return;
// Read and update configuration data
- updateConfigurationData();
+ updateConfigurationDataImpl();
uno::Reference< container::XContainer > xContainer( m_xConfigAccess, uno::UNO_QUERY );
// UNSAFE
- aLock.clear();
+ aLock.unlock();
if ( xContainer.is() )
{
@@ -225,12 +226,8 @@ void ConfigurationAccess_ControllerFactory::readConfigurationData()
}
}
-void ConfigurationAccess_ControllerFactory::updateConfigurationData()
+void ConfigurationAccess_ControllerFactory::updateConfigurationDataImpl()
{
- osl::MutexGuard g(m_mutex);
- if ( !m_xConfigAccess.is() )
- return;
-
const Sequence< OUString > aPopupMenuControllers = m_xConfigAccess->getElementNames();
OUString aCommand;
@@ -266,23 +263,23 @@ bool ConfigurationAccess_ControllerFactory::impl_getElementProps( const Any& aEl
Reference< XPropertySet > xPropertySet;
aElement >>= xPropertySet;
- if ( xPropertySet.is() )
+ if ( !xPropertySet.is() )
+ return true;
+
+ try
{
- try
- {
- xPropertySet->getPropertyValue( m_aPropCommand ) >>= aCommand;
- xPropertySet->getPropertyValue( m_aPropModule ) >>= aModule;
- xPropertySet->getPropertyValue( m_aPropController ) >>= aServiceSpecifier;
- xPropertySet->getPropertyValue( m_aPropValue ) >>= aValue;
- }
- catch ( const css::beans::UnknownPropertyException& )
- {
- return false;
- }
- catch ( const css::lang::WrappedTargetException& )
- {
- return false;
- }
+ xPropertySet->getPropertyValue( m_aPropCommand ) >>= aCommand;
+ xPropertySet->getPropertyValue( m_aPropModule ) >>= aModule;
+ xPropertySet->getPropertyValue( m_aPropController ) >>= aServiceSpecifier;
+ xPropertySet->getPropertyValue( m_aPropValue ) >>= aValue;
+ }
+ catch ( const css::beans::UnknownPropertyException& )
+ {
+ return false;
+ }
+ catch ( const css::lang::WrappedTargetException& )
+ {
+ return false;
}
return true;
diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx
index 5c6e60425400..a4b6c4686c9a 100644
--- a/framework/source/uifactory/menubarfactory.cxx
+++ b/framework/source/uifactory/menubarfactory.cxx
@@ -29,20 +29,20 @@
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <utility>
#include <vcl/svapp.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
namespace framework
{
-MenuBarFactory::MenuBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : m_xContext( xContext )
+MenuBarFactory::MenuBarFactory( css::uno::Reference< css::uno::XComponentContext > xContext )
+ : m_xContext(std::move( xContext ))
{
}
@@ -55,8 +55,7 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement(
const OUString& ResourceURL,
const Sequence< PropertyValue >& Args )
{
- Reference< css::ui::XUIElement > xMenuBar(
- static_cast<OWeakObject *>(new MenuBarWrapper(m_xContext)), UNO_QUERY);
+ Reference< css::ui::XUIElement > xMenuBar = new MenuBarWrapper(m_xContext);
CreateUIElement(ResourceURL, Args, u"private:resource/menubar/", xMenuBar, m_xContext);
return xMenuBar;
}
@@ -134,6 +133,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
nURLPropertyIndex++;
Sequence< Any > aPropSeq( nSeqLength );
+ auto aPropSeqRange = asNonConstRange(aPropSeq);
for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
{
PropertyValue aPropValue;
@@ -150,7 +150,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
else
aPropValue = Args[n];
- aPropSeq[n] <<= aPropValue;
+ aPropSeqRange[n] <<= aPropValue;
}
SolarMutexGuard aGuard;
diff --git a/framework/source/uifactory/statusbarfactory.cxx b/framework/source/uifactory/statusbarfactory.cxx
index 0c59adea073b..addb6cb11d86 100644
--- a/framework/source/uifactory/statusbarfactory.cxx
+++ b/framework/source/uifactory/statusbarfactory.cxx
@@ -23,9 +23,7 @@
#include <cppuhelper/supportsservice.hxx>
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
using namespace framework;
@@ -66,8 +64,7 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement(
const OUString& ResourceURL,
const Sequence< PropertyValue >& Args )
{
- Reference< css::ui::XUIElement > xStatusBar(
- static_cast<OWeakObject *>(new StatusBarWrapper(m_xContext)), UNO_QUERY);
+ Reference< css::ui::XUIElement > xStatusBar = new StatusBarWrapper(m_xContext);
MenuBarFactory::CreateUIElement(ResourceURL, Args, u"private:resource/statusbar/", xStatusBar, m_xContext);
return xStatusBar;
}
diff --git a/framework/source/uifactory/toolbarfactory.cxx b/framework/source/uifactory/toolbarfactory.cxx
index 8af020cde45b..d597f3e178cc 100644
--- a/framework/source/uifactory/toolbarfactory.cxx
+++ b/framework/source/uifactory/toolbarfactory.cxx
@@ -25,7 +25,6 @@
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
using namespace framework;
@@ -66,8 +65,7 @@ Reference< XUIElement > SAL_CALL ToolBarFactory::createUIElement(
const OUString& ResourceURL,
const Sequence< PropertyValue >& Args )
{
- Reference< css::ui::XUIElement > xToolBar(
- static_cast<OWeakObject *>(new ToolBarWrapper(m_xContext)), UNO_QUERY);
+ Reference< css::ui::XUIElement > xToolBar = new ToolBarWrapper(m_xContext);
CreateUIElement(ResourceURL, Args, u"private:resource/toolbar/", xToolBar, m_xContext);
return xToolBar;
}
diff --git a/framework/source/uifactory/uicontrollerfactory.cxx b/framework/source/uifactory/uicontrollerfactory.cxx
index 619b66d7c420..314b277995e1 100644
--- a/framework/source/uifactory/uicontrollerfactory.cxx
+++ b/framework/source/uifactory/uicontrollerfactory.cxx
@@ -28,25 +28,22 @@
#include <com/sun/star/frame/XUIControllerFactory.hpp>
#include <rtl/ref.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
using namespace css::uno;
using namespace css::lang;
using namespace css::beans;
-using namespace css::container;
using namespace css::frame;
using namespace framework;
namespace {
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo,
css::frame::XUIControllerFactory > UIControllerFactory_BASE;
-class UIControllerFactory : private cppu::BaseMutex,
- public UIControllerFactory_BASE
+class UIControllerFactory : public UIControllerFactory_BASE
{
public:
virtual ~UIControllerFactory() override;
@@ -68,16 +65,14 @@ protected:
rtl::Reference<ConfigurationAccess_ControllerFactory> m_pConfigAccess;
private:
- virtual void SAL_CALL disposing() final override;
+ virtual void disposing(std::unique_lock<std::mutex>&) final override;
};
UIControllerFactory::UIControllerFactory(
const Reference< XComponentContext >& xContext,
std::u16string_view rConfigurationNode )
- : UIControllerFactory_BASE(m_aMutex)
- , m_bConfigRead( false )
+ : m_bConfigRead( false )
, m_xContext( xContext )
- , m_pConfigAccess()
{
m_pConfigAccess = new ConfigurationAccess_ControllerFactory(m_xContext,
OUString::Concat("/org.openoffice.Office.UI.Controller/Registered/")
@@ -86,12 +81,12 @@ UIControllerFactory::UIControllerFactory(
UIControllerFactory::~UIControllerFactory()
{
- disposing();
+ std::unique_lock g(m_aMutex);
+ disposing(g);
}
-void SAL_CALL UIControllerFactory::disposing()
+void UIControllerFactory::disposing(std::unique_lock<std::mutex>&)
{
- osl::MutexGuard g(rBHelper.rMutex);
m_pConfigAccess.clear();
}
@@ -101,7 +96,7 @@ Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithContext(
const Reference< XComponentContext >& )
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigRead )
{
@@ -122,7 +117,7 @@ Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithArgument
const Sequence< Any >& Arguments,
const Reference< XComponentContext >& )
{
- const OUString aPropModuleName( "ModuleIdentifier" );
+ static constexpr OUStringLiteral aPropModuleName( u"ModuleIdentifier" );
OUString aPropName;
PropertyValue aPropValue;
@@ -143,24 +138,25 @@ Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithArgument
sal_Int32 nAppendIndex = aNewArgs.getLength();
aNewArgs.realloc( aNewArgs.getLength() + 2 );
+ auto pNewArgs = aNewArgs.getArray();
// Append the command URL to the Arguments sequence so that one controller can be
// used for more than one command URL.
aPropValue.Name = "CommandURL";
aPropValue.Value <<= ServiceSpecifier;
- aNewArgs[nAppendIndex] <<= aPropValue;
+ pNewArgs[nAppendIndex] <<= aPropValue;
// Append the optional value argument. It's an empty string if no additional info
// is provided to the controller.
OUString aValue = m_pConfigAccess->getValueFromCommandModule( ServiceSpecifier, aPropName );
aPropValue.Name = "Value";
aPropValue.Value <<= aValue;
- aNewArgs[nAppendIndex+1] <<= aPropValue;
+ pNewArgs[nAppendIndex+1] <<= aPropValue;
{
OUString aServiceName;
{ // SAFE
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigRead )
{
@@ -188,7 +184,7 @@ sal_Bool SAL_CALL UIControllerFactory::hasController(
const OUString& aCommandURL,
const OUString& aModuleName )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigRead )
{
@@ -205,7 +201,7 @@ void SAL_CALL UIControllerFactory::registerController(
const OUString& aControllerImplementationName )
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigRead )
{
@@ -222,7 +218,7 @@ void SAL_CALL UIControllerFactory::deregisterController(
const OUString& aModuleName )
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigRead )
{
@@ -261,24 +257,6 @@ PopupMenuControllerFactory::PopupMenuControllerFactory( const Reference< XCompon
{
}
-struct PopupMenuControllerFactoryInstance {
- explicit PopupMenuControllerFactoryInstance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new PopupMenuControllerFactory(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct PopupMenuControllerFactorySingleton:
- public rtl::StaticWithArg<
- PopupMenuControllerFactoryInstance,
- css::uno::Reference<css::uno::XComponentContext>,
- PopupMenuControllerFactorySingleton>
-{};
-
class ToolbarControllerFactory : public UIControllerFactory
{
public:
@@ -306,24 +284,6 @@ ToolbarControllerFactory::ToolbarControllerFactory( const Reference< XComponentC
{
}
-struct ToolbarControllerFactoryInstance {
- explicit ToolbarControllerFactoryInstance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new ToolbarControllerFactory(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct ToolbarControllerFactorySingleton:
- public rtl::StaticWithArg<
- ToolbarControllerFactoryInstance,
- css::uno::Reference<css::uno::XComponentContext>,
- ToolbarControllerFactorySingleton>
-{};
-
class StatusbarControllerFactory : public UIControllerFactory
{
public:
@@ -351,24 +311,6 @@ StatusbarControllerFactory::StatusbarControllerFactory( const Reference< XCompon
{
}
-struct StatusbarControllerFactoryInstance {
- explicit StatusbarControllerFactoryInstance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new StatusbarControllerFactory(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct StatusbarControllerFactorySingleton:
- public rtl::StaticWithArg<
- StatusbarControllerFactoryInstance,
- css::uno::Reference<css::uno::XComponentContext>,
- StatusbarControllerFactorySingleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -376,8 +318,7 @@ com_sun_star_comp_framework_PopupMenuControllerFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- PopupMenuControllerFactorySingleton::get(context).instance.get()));
+ return cppu::acquire(new PopupMenuControllerFactory(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -385,8 +326,7 @@ com_sun_star_comp_framework_ToolBarControllerFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- ToolbarControllerFactorySingleton::get(context).instance.get()));
+ return cppu::acquire(new ToolbarControllerFactory(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -394,8 +334,7 @@ com_sun_star_comp_framework_StatusBarControllerFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- StatusbarControllerFactorySingleton::get(context).instance.get()));
+ return cppu::acquire(new StatusbarControllerFactory(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx
index 02d5435bab80..b8a8ea46ed9b 100644
--- a/framework/source/uifactory/uielementfactorymanager.cxx
+++ b/framework/source/uifactory/uielementfactorymanager.cxx
@@ -41,9 +41,10 @@
#include <rtl/ref.hxx>
#include <sal/log.hxx>
#include <comphelper/propertysequence.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <utility>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -63,12 +64,12 @@ static OUString getHashKeyFromStrings( std::u16string_view aType, std::u16string
return OUString::Concat(aType) + "^" + aName + "^" + aModuleName;
}
-ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const OUString& _sRoot ) :
+ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, OUString _sRoot ) :
m_aPropType( "Type" ),
m_aPropName( "Name" ),
m_aPropModule( "Module" ),
m_aPropFactory( "FactoryImplementation" ),
- m_sRoot(_sRoot),
+ m_sRoot(std::move(_sRoot)),
m_bConfigAccessInitialized( false )
{
m_xConfigProvider = theDefaultProvider::get( rxContext );
@@ -77,17 +78,17 @@ ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Re
ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
xContainer->removeContainerListener(m_xConfigListener);
}
-OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( std::u16string_view rType, const OUString& rName, std::u16string_view rModule ) const
+OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view rModule ) const
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
FactoryManagerMap::const_iterator pIter =
m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rModule ));
@@ -102,10 +103,10 @@ OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModu
else
{
// Support factories which uses a defined prefix before the ui name.
- sal_Int32 nIndex = rName.indexOf( '_' );
- if ( nIndex > 0 )
+ size_t nIndex = rName.find( '_' );
+ if ( nIndex > 0 && nIndex != std::u16string_view::npos)
{
- OUString aName = rName.copy( 0, nIndex+1 );
+ std::u16string_view aName = rName.substr( 0, nIndex+1 );
pIter = m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, aName, std::u16string_view() ));
if ( pIter != m_aFactoryManagerMap.end() )
return pIter->second;
@@ -123,7 +124,7 @@ OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModu
void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view rModule, const OUString& rServiceSpecifier )
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
@@ -137,7 +138,7 @@ void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( st
void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view rModule )
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
@@ -151,7 +152,7 @@ void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModul
Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFactoriesDescription() const
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Sequence< Sequence< PropertyValue > > aSeqSeq;
@@ -162,25 +163,26 @@ Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFac
if ( !aFactory.isEmpty() )
{
sal_Int32 nToken = 0;
- Sequence< PropertyValue > aSeq( 1 );
aSeqSeq.realloc( aSeqSeq.getLength() + 1 );
- aSeq[0].Name = m_aPropType;
- aSeq[0].Value <<= aFactory.getToken( 0, '^', nToken );
+ Sequence< PropertyValue > aSeq{ comphelper::makePropertyValue(
+ m_aPropType, aFactory.getToken( 0, '^', nToken )) };
if ( nToken > 0 )
{
aSeq.realloc( 2 );
- aSeq[1].Name = m_aPropName;
- aSeq[1].Value <<= aFactory.getToken( 0, '^', nToken );
+ aSeq.getArray()[1]
+ = comphelper::makePropertyValue(m_aPropName,
+ aFactory.getToken( 0, '^', nToken ));
if ( nToken > 0 )
{
aSeq.realloc( 3 );
- aSeq[2].Name = m_aPropModule;
- aSeq[2].Value <<= aFactory.getToken( 0, '^', nToken );
+ aSeq.getArray()[2]
+ = comphelper::makePropertyValue(m_aPropModule,
+ aFactory.getToken( 0, '^', nToken ));
}
}
- aSeqSeq[nIndex++] = aSeq;
+ aSeqSeq.getArray()[nIndex++] = aSeq;
}
}
@@ -196,7 +198,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementInserted( const Contain
OUString aService;
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
{
@@ -215,7 +217,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementRemoved ( const Contain
OUString aService;
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
{
@@ -234,7 +236,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementReplaced( const Contain
OUString aService;
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
{
@@ -251,14 +253,14 @@ void SAL_CALL ConfigurationAccess_FactoryManager::disposing( const EventObject&
{
// SAFE
// remove our reference to the config access
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_xConfigAccess.clear();
}
void ConfigurationAccess_FactoryManager::readConfigurationData()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -313,23 +315,23 @@ bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aEleme
Reference< XPropertySet > xPropertySet;
aElement >>= xPropertySet;
- if ( xPropertySet.is() )
+ if ( !xPropertySet.is() )
+ return true;
+
+ try
{
- try
- {
- xPropertySet->getPropertyValue( m_aPropType ) >>= rType;
- xPropertySet->getPropertyValue( m_aPropName ) >>= rName;
- xPropertySet->getPropertyValue( m_aPropModule ) >>= rModule;
- xPropertySet->getPropertyValue( m_aPropFactory ) >>= rServiceSpecifier;
- }
- catch ( const css::beans::UnknownPropertyException& )
- {
- return false;
- }
- catch ( const css::lang::WrappedTargetException& )
- {
- return false;
- }
+ xPropertySet->getPropertyValue( m_aPropType ) >>= rType;
+ xPropertySet->getPropertyValue( m_aPropName ) >>= rName;
+ xPropertySet->getPropertyValue( m_aPropModule ) >>= rModule;
+ xPropertySet->getPropertyValue( m_aPropFactory ) >>= rServiceSpecifier;
+ }
+ catch ( const css::beans::UnknownPropertyException& )
+ {
+ return false;
+ }
+ catch ( const css::lang::WrappedTargetException& )
+ {
+ return false;
}
return true;
@@ -339,14 +341,13 @@ bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aEleme
namespace {
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo,
css::ui::XUIElementFactoryManager> UIElementFactoryManager_BASE;
-class UIElementFactoryManager : private cppu::BaseMutex,
- public UIElementFactoryManager_BASE
+class UIElementFactoryManager : public UIElementFactoryManager_BASE
{
- virtual void SAL_CALL disposing() override;
+ virtual void disposing(std::unique_lock<std::mutex>&) override;
public:
explicit UIElementFactoryManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
@@ -381,7 +382,6 @@ private:
};
UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) :
- UIElementFactoryManager_BASE(m_aMutex),
m_bConfigRead( false ),
m_xContext(rxContext),
m_pConfigAccess(
@@ -390,7 +390,7 @@ UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentCon
"/org.openoffice.Office.UI.Factories/Registered/UIElementFactories"))
{}
-void SAL_CALL UIElementFactoryManager::disposing()
+void UIElementFactoryManager::disposing(std::unique_lock<std::mutex>&)
{
m_pConfigAccess.clear();
}
@@ -403,28 +403,28 @@ Reference< XUIElement > SAL_CALL UIElementFactoryManager::createUIElement(
Reference< XFrame > xFrame;
OUString aModuleId;
{ // SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
- throw css::lang::DisposedException(
- "disposed", static_cast<OWeakObject *>(this));
- }
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
+ throw css::lang::DisposedException(
+ "disposed", static_cast<OWeakObject *>(this));
+ }
- if ( !m_bConfigRead )
- {
- m_bConfigRead = true;
- m_pConfigAccess->readConfigurationData();
- }
+ if ( !m_bConfigRead )
+ {
+ m_bConfigRead = true;
+ m_pConfigAccess->readConfigurationData();
+ }
- // Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
- // to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
- // retrieve from it.
- for ( auto const & arg : Args )
- {
- if ( arg.Name == "Frame")
- arg.Value >>= xFrame;
- if (arg.Name == "Module")
- arg.Value >>= aModuleId;
- }
+ // Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
+ // to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
+ // retrieve from it.
+ for ( auto const & arg : Args )
+ {
+ if ( arg.Name == "Frame")
+ arg.Value >>= xFrame;
+ if (arg.Name == "Module")
+ arg.Value >>= aModuleId;
+ }
} // SAFE
Reference< XModuleManager2 > xManager = ModuleManager::create( m_xContext );
@@ -450,8 +450,8 @@ Reference< XUIElement > SAL_CALL UIElementFactoryManager::createUIElement(
Sequence< Sequence< PropertyValue > > SAL_CALL UIElementFactoryManager::getRegisteredFactories()
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
throw css::lang::DisposedException(
"disposed", static_cast<OWeakObject *>(this));
}
@@ -469,24 +469,22 @@ Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( con
{
OUString aServiceSpecifier;
{ // SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
- throw css::lang::DisposedException(
- "disposed", static_cast<OWeakObject *>(this));
- }
-
- if ( !m_bConfigRead )
- {
- m_bConfigRead = true;
- m_pConfigAccess->readConfigurationData();
- }
-
- OUString aType;
- OUString aName;
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
+ throw css::lang::DisposedException(
+ "disposed", static_cast<OWeakObject *>(this));
+ }
- RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
+ if ( !m_bConfigRead )
+ {
+ m_bConfigRead = true;
+ m_pConfigAccess->readConfigurationData();
+ }
- aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
+ OUString aType;
+ OUString aName;
+ RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
+ aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
} // SAFE
if ( !aServiceSpecifier.isEmpty() ) try
@@ -507,8 +505,8 @@ Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( con
void SAL_CALL UIElementFactoryManager::registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleId, const OUString& aFactoryImplementationName )
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
throw css::lang::DisposedException(
"disposed", static_cast<OWeakObject *>(this));
}
@@ -526,8 +524,8 @@ void SAL_CALL UIElementFactoryManager::registerFactory( const OUString& aType, c
void SAL_CALL UIElementFactoryManager::deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleId )
{
// SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
throw css::lang::DisposedException(
"disposed", static_cast<OWeakObject *>(this));
}
@@ -542,22 +540,6 @@ void SAL_CALL UIElementFactoryManager::deregisterFactory( const OUString& aType,
// SAFE
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new UIElementFactoryManager(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -565,8 +547,7 @@ com_sun_star_comp_framework_UIElementFactoryManager_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new UIElementFactoryManager(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx
index 996fae5f41a1..1918ae6fdd54 100644
--- a/framework/source/uifactory/windowcontentfactorymanager.cxx
+++ b/framework/source/uifactory/windowcontentfactorymanager.cxx
@@ -31,26 +31,25 @@
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ref.hxx>
-#include <tools/diagnose_ex.h>
+#include <utility>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace framework;
namespace {
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo,
css::lang::XSingleComponentFactory > WindowContentFactoryManager_BASE;
-class WindowContentFactoryManager : private cppu::BaseMutex,
- public WindowContentFactoryManager_BASE
+class WindowContentFactoryManager : public WindowContentFactoryManager_BASE
{
public:
- explicit WindowContentFactoryManager( const css::uno::Reference< css::uno::XComponentContext>& rxContext );
+ explicit WindowContentFactoryManager( css::uno::Reference< css::uno::XComponentContext> xContext );
virtual OUString SAL_CALL getImplementationName() override
{
@@ -72,16 +71,15 @@ public:
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& Context ) override;
private:
- virtual void SAL_CALL disposing() override;
+ virtual void disposing(std::unique_lock<std::mutex>&) override;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
bool m_bConfigRead;
rtl::Reference<ConfigurationAccess_FactoryManager> m_pConfigAccess;
};
-WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference< uno::XComponentContext >& rxContext ) :
- WindowContentFactoryManager_BASE(m_aMutex),
- m_xContext( rxContext ),
+WindowContentFactoryManager::WindowContentFactoryManager( uno::Reference< uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext )),
m_bConfigRead( false ),
m_pConfigAccess(
new ConfigurationAccess_FactoryManager(
@@ -89,7 +87,7 @@ WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference<
"/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories"))
{}
-void SAL_CALL WindowContentFactoryManager::disposing()
+void WindowContentFactoryManager::disposing(std::unique_lock<std::mutex>&)
{
m_pConfigAccess.clear();
}
@@ -147,17 +145,17 @@ uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createIn
// Determine the implementation name of the window content factory dependent on the
// module identifier, user interface element type and name
{ // SAFE
- osl::MutexGuard g(rBHelper.rMutex);
- if (rBHelper.bDisposed) {
- throw css::lang::DisposedException(
- "disposed", static_cast<OWeakObject *>(this));
- }
- if ( !m_bConfigRead )
- {
- m_bConfigRead = true;
- m_pConfigAccess->readConfigurationData();
- }
- aImplementationName = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
+ std::unique_lock g(m_aMutex);
+ if (m_bDisposed) {
+ throw css::lang::DisposedException(
+ "disposed", static_cast<OWeakObject *>(this));
+ }
+ if ( !m_bConfigRead )
+ {
+ m_bConfigRead = true;
+ m_pConfigAccess->readConfigurationData();
+ }
+ aImplementationName = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
} // SAFE
if ( !aImplementationName.isEmpty() )
@@ -193,22 +191,6 @@ uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createIn
return xWindow;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new WindowContentFactoryManager(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -216,8 +198,7 @@ com_sun_star_comp_framework_WindowContentFactoryManager_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new WindowContentFactoryManager(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/xml/acceleratorconfigurationreader.cxx b/framework/source/xml/acceleratorconfigurationreader.cxx
index 1b36119f2fd6..7cbb81de9bcd 100644
--- a/framework/source/xml/acceleratorconfigurationreader.cxx
+++ b/framework/source/xml/acceleratorconfigurationreader.cxx
@@ -27,8 +27,6 @@
#include <com/sun/star/awt/KeyModifier.hpp>
#include <com/sun/star/awt/KeyEvent.hpp>
-#include <rtl/ustrbuf.hxx>
-
namespace framework{
/* Throws a SaxException in case a wrong formatted XML
@@ -103,7 +101,7 @@ void SAL_CALL AcceleratorConfigurationReader::startElement(const OUString&
switch(eAttribute)
{
case E_ATTRIBUTE_URL :
- sCommand = sValue.intern();
+ sCommand = sValue;
break;
case E_ATTRIBUTE_KEYCODE :
@@ -248,13 +246,11 @@ OUString AcceleratorConfigurationReader::implts_getErrorLineString()
if (!m_xLocator.is())
return "Error during parsing XML. (No further info available ...)";
- OUStringBuffer sMsg(256);
- sMsg.append("Error during parsing XML in\nline = ");
- sMsg.append (m_xLocator->getLineNumber() );
- sMsg.append("\ncolumn = " );
- sMsg.append (m_xLocator->getColumnNumber() );
- sMsg.append("." );
- return sMsg.makeStringAndClear();
+ return "Error during parsing XML in\nline = " +
+ OUString::number(m_xLocator->getLineNumber()) +
+ "\ncolumn = " +
+ OUString::number(m_xLocator->getColumnNumber()) +
+ ".";
}
} // namespace framework
diff --git a/framework/source/xml/acceleratorconfigurationwriter.cxx b/framework/source/xml/acceleratorconfigurationwriter.cxx
index c94501ad12dc..6ef30fe4fe66 100644
--- a/framework/source/xml/acceleratorconfigurationwriter.cxx
+++ b/framework/source/xml/acceleratorconfigurationwriter.cxx
@@ -20,21 +20,22 @@
#include <sal/config.h>
#include <accelerators/keymapping.hxx>
+#include <utility>
#include <xml/acceleratorconfigurationwriter.hxx>
#include <acceleratorconst.h>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/awt/KeyModifier.hpp>
#include <comphelper/attributelist.hxx>
+#include <rtl/ref.hxx>
namespace framework{
AcceleratorConfigurationWriter::AcceleratorConfigurationWriter(const AcceleratorCache& rContainer,
- const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig )
- : m_xConfig (xConfig )
+ css::uno::Reference< css::xml::sax::XDocumentHandler > xConfig )
+ : m_xConfig (std::move(xConfig ))
, m_rContainer (rContainer )
{
}
@@ -48,14 +49,13 @@ void AcceleratorConfigurationWriter::flush()
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > xExtendedCFG(m_xConfig, css::uno::UNO_QUERY_THROW);
// prepare attribute list
- ::comphelper::AttributeList* pAttribs = new ::comphelper::AttributeList;
- css::uno::Reference< css::xml::sax::XAttributeList > xAttribs(static_cast< css::xml::sax::XAttributeList* >(pAttribs), css::uno::UNO_QUERY);
+ rtl::Reference<::comphelper::AttributeList> pAttribs = new ::comphelper::AttributeList;
pAttribs->AddAttribute(
- "xmlns:accel", ATTRIBUTE_TYPE_CDATA,
+ "xmlns:accel",
"http://openoffice.org/2001/accel");
pAttribs->AddAttribute(
- "xmlns:xlink", ATTRIBUTE_TYPE_CDATA, "http://www.w3.org/1999/xlink");
+ "xmlns:xlink", "http://www.w3.org/1999/xlink");
// generate xml
xExtendedCFG->startDocument();
@@ -65,7 +65,7 @@ void AcceleratorConfigurationWriter::flush()
" OfficeDocument 1.0//EN\" \"accelerator.dtd\">");
xExtendedCFG->ignorableWhitespace(OUString());
- xExtendedCFG->startElement(AL_ELEMENT_ACCELERATORLIST, xAttribs);
+ xExtendedCFG->startElement(AL_ELEMENT_ACCELERATORLIST, pAttribs);
xExtendedCFG->ignorableWhitespace(OUString());
// TODO think about threadsafe using of cache
@@ -87,33 +87,33 @@ void AcceleratorConfigurationWriter::flush()
xExtendedCFG->endDocument();
}
+// static
void AcceleratorConfigurationWriter::impl_ts_writeKeyCommandPair(const css::awt::KeyEvent& aKey ,
const OUString& sCommand,
const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig )
{
- ::comphelper::AttributeList* pAttribs = new ::comphelper::AttributeList;
- css::uno::Reference< css::xml::sax::XAttributeList > xAttribs (static_cast< css::xml::sax::XAttributeList* >(pAttribs) , css::uno::UNO_QUERY_THROW);
+ rtl::Reference<::comphelper::AttributeList> pAttribs = new ::comphelper::AttributeList;
OUString sKey = KeyMapping::get().mapCodeToIdentifier(aKey.KeyCode);
// TODO check if key is empty!
- pAttribs->AddAttribute("accel:code", ATTRIBUTE_TYPE_CDATA, sKey );
- pAttribs->AddAttribute("xlink:href", ATTRIBUTE_TYPE_CDATA, sCommand);
+ pAttribs->AddAttribute("accel:code", sKey );
+ pAttribs->AddAttribute("xlink:href", sCommand);
if ((aKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT)
- pAttribs->AddAttribute("accel:shift", ATTRIBUTE_TYPE_CDATA, "true");
+ pAttribs->AddAttribute("accel:shift", "true");
if ((aKey.Modifiers & css::awt::KeyModifier::MOD1) == css::awt::KeyModifier::MOD1)
- pAttribs->AddAttribute("accel:mod1", ATTRIBUTE_TYPE_CDATA, "true");
+ pAttribs->AddAttribute("accel:mod1", "true");
if ((aKey.Modifiers & css::awt::KeyModifier::MOD2) == css::awt::KeyModifier::MOD2)
- pAttribs->AddAttribute("accel:mod2", ATTRIBUTE_TYPE_CDATA, "true");
+ pAttribs->AddAttribute("accel:mod2", "true");
if ((aKey.Modifiers & css::awt::KeyModifier::MOD3) == css::awt::KeyModifier::MOD3)
- pAttribs->AddAttribute("accel:mod3", ATTRIBUTE_TYPE_CDATA, "true");
+ pAttribs->AddAttribute("accel:mod3", "true");
xConfig->ignorableWhitespace(OUString());
- xConfig->startElement(AL_ELEMENT_ITEM, xAttribs);
+ xConfig->startElement(AL_ELEMENT_ITEM, pAttribs);
xConfig->ignorableWhitespace(OUString());
xConfig->endElement(AL_ELEMENT_ITEM);
xConfig->ignorableWhitespace(OUString());
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx
index 51352b0296d4..ff5799f5c775 100644
--- a/framework/source/xml/imagesdocumenthandler.cxx
+++ b/framework/source/xml/imagesdocumenthandler.cxx
@@ -22,7 +22,7 @@
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
#include <com/sun/star/xml/sax/SAXException.hpp>
-#include <vcl/svapp.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/attributelist.hxx>
@@ -36,9 +36,9 @@ using namespace ::com::sun::star::xml::sax;
#define ELEMENT_EXTERNALIMAGES "externalimages"
#define ELEMENT_EXTERNALENTRY "externalentry"
-#define ELEMENT_NS_IMAGESCONTAINER "image:imagescontainer"
-#define ELEMENT_NS_IMAGES "image:images"
-#define ELEMENT_NS_ENTRY "image:entry"
+constexpr OUString ELEMENT_NS_IMAGESCONTAINER = u"image:imagescontainer"_ustr;
+constexpr OUString ELEMENT_NS_IMAGES = u"image:images"_ustr;
+constexpr OUString ELEMENT_NS_ENTRY = u"image:entry"_ustr;
#define ATTRIBUTE_HREF "href"
#define ATTRIBUTE_MASKCOLOR "maskcolor"
@@ -48,21 +48,20 @@ using namespace ::com::sun::star::xml::sax;
#define ATTRIBUTE_MASKMODE "maskmode"
#define ATTRIBUTE_HIGHCONTRASTURL "highcontrasturl"
#define ATTRIBUTE_HIGHCONTRASTMASKURL "highcontrastmaskurl"
-#define ATTRIBUTE_TYPE_CDATA "CDATA"
-#define ATTRIBUTE_XMLNS_IMAGE "xmlns:image"
-#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink"
+constexpr OUStringLiteral ATTRIBUTE_XMLNS_IMAGE = u"xmlns:image";
+constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK = u"xmlns:xlink";
-#define ATTRIBUTE_XLINK_TYPE "xlink:type"
-#define ATTRIBUTE_XLINK_TYPE_VALUE "simple"
+constexpr OUStringLiteral ATTRIBUTE_XLINK_TYPE = u"xlink:type";
+constexpr OUStringLiteral ATTRIBUTE_XLINK_TYPE_VALUE = u"simple";
-#define XMLNS_IMAGE "http://openoffice.org/2001/image"
-#define XMLNS_XLINK "http://www.w3.org/1999/xlink"
-#define XMLNS_IMAGE_PREFIX "image:"
+constexpr OUString XMLNS_IMAGE = u"http://openoffice.org/2001/image"_ustr;
+constexpr OUString XMLNS_XLINK = u"http://www.w3.org/1999/xlink"_ustr;
+constexpr OUStringLiteral XMLNS_IMAGE_PREFIX = u"image:";
-#define XMLNS_FILTER_SEPARATOR "^"
+constexpr OUStringLiteral XMLNS_FILTER_SEPARATOR = u"^";
-#define IMAGES_DOCTYPE "<!DOCTYPE image:imagecontainer PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"image.dtd\">"
+constexpr OUStringLiteral IMAGES_DOCTYPE = u"<!DOCTYPE image:imagecontainer PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"image.dtd\">";
namespace framework
{
@@ -98,7 +97,7 @@ OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageItemDescriptorList&
m_rImageList( rItems )
{
// create hash map to speed up lookup
- for ( int i = 0; i < int(IMG_XML_ENTRY_COUNT); i++ )
+ for ( int i = 0; i < IMG_XML_ENTRY_COUNT; i++ )
{
OUStringBuffer temp( 20 );
@@ -129,8 +128,6 @@ void SAL_CALL OReadImagesDocumentHandler::startDocument()
void SAL_CALL OReadImagesDocumentHandler::endDocument()
{
- SolarMutexGuard g;
-
if (m_bImageContainerStartFound != m_bImageContainerEndFound)
{
OUString aErrorMessage = getErrorLineString() + "No matching start or end element 'image:imagecontainer' found!";
@@ -141,8 +138,6 @@ void SAL_CALL OReadImagesDocumentHandler::endDocument()
void SAL_CALL OReadImagesDocumentHandler::startElement(
const OUString& aName, const Reference< XAttributeList > &xAttribs )
{
- SolarMutexGuard g;
-
ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName );
if ( pImageEntry == m_aImageMap.end() )
return;
@@ -230,8 +225,6 @@ void SAL_CALL OReadImagesDocumentHandler::startElement(
void SAL_CALL OReadImagesDocumentHandler::endElement(const OUString& aName)
{
- SolarMutexGuard g;
-
ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName );
if ( pImageEntry == m_aImageMap.end() )
return;
@@ -270,19 +263,16 @@ void SAL_CALL OReadImagesDocumentHandler::processingInstruction(
void SAL_CALL OReadImagesDocumentHandler::setDocumentLocator(
const Reference< XLocator > &xLocator)
{
- SolarMutexGuard g;
m_xLocator = xLocator;
}
OUString OReadImagesDocumentHandler::getErrorLineString()
{
- SolarMutexGuard g;
if ( m_xLocator.is() )
{
- OUStringBuffer buffer("Line: ");
- buffer.append(m_xLocator->getLineNumber());
- buffer.append(" - ");
- return buffer.makeStringAndClear();
+ return "Line: " +
+ OUString::number(m_xLocator->getLineNumber()) +
+ " - ";
}
else
return OUString();
@@ -296,9 +286,7 @@ OWriteImagesDocumentHandler::OWriteImagesDocumentHandler(
m_rImageItemList( rItems ),
m_xWriteDocumentHandler( rWriteDocumentHandler )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY );
- m_aAttributeType = ATTRIBUTE_TYPE_CDATA;
+ m_xEmptyList = new ::comphelper::AttributeList;
m_aXMLImageNS = XMLNS_IMAGE_PREFIX;
m_aAttributeXlinkType = ATTRIBUTE_XLINK_TYPE;
m_aAttributeValueSimple = ATTRIBUTE_XLINK_TYPE_VALUE;
@@ -310,8 +298,6 @@ OWriteImagesDocumentHandler::~OWriteImagesDocumentHandler()
void OWriteImagesDocumentHandler::WriteImagesDocument()
{
- SolarMutexGuard g;
-
m_xWriteDocumentHandler->startDocument();
// write DOCTYPE line!
@@ -325,14 +311,12 @@ void OWriteImagesDocumentHandler::WriteImagesDocument()
rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( ATTRIBUTE_XMLNS_IMAGE,
- m_aAttributeType,
XMLNS_IMAGE );
pList->AddAttribute( ATTRIBUTE_XMLNS_XLINK,
- m_aAttributeType,
XMLNS_XLINK );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGESCONTAINER, pList.get() );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGESCONTAINER, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
WriteImageList( &m_rImageItemList );
@@ -347,15 +331,13 @@ void OWriteImagesDocumentHandler::WriteImagesDocument()
void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList* pImageList )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
// save required attributes
pList->AddAttribute( m_aAttributeXlinkType,
- m_aAttributeType,
m_aAttributeValueSimple );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, xList );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
for (const ImageItemDescriptor & i : *pImageList)
@@ -367,14 +349,12 @@ void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList*
void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage )
{
- ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
- Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY );
+ rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_COMMAND,
- m_aAttributeType,
pImage->aCommandURL );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_ENTRY, xList );
+ m_xWriteDocumentHandler->startElement( ELEMENT_NS_ENTRY, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->endElement( ELEMENT_NS_ENTRY );