1*ff12d537SAndre Fischer /************************************************************** 2*ff12d537SAndre Fischer * 3*ff12d537SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*ff12d537SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*ff12d537SAndre Fischer * distributed with this work for additional information 6*ff12d537SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*ff12d537SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*ff12d537SAndre Fischer * "License"); you may not use this file except in compliance 9*ff12d537SAndre Fischer * with the License. You may obtain a copy of the License at 10*ff12d537SAndre Fischer * 11*ff12d537SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*ff12d537SAndre Fischer * 13*ff12d537SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*ff12d537SAndre Fischer * software distributed under the License is distributed on an 15*ff12d537SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ff12d537SAndre Fischer * KIND, either express or implied. See the License for the 17*ff12d537SAndre Fischer * specific language governing permissions and limitations 18*ff12d537SAndre Fischer * under the License. 19*ff12d537SAndre Fischer * 20*ff12d537SAndre Fischer *************************************************************/ 21*ff12d537SAndre Fischer 22*ff12d537SAndre Fischer #include "precompiled_sfx2.hxx" 23*ff12d537SAndre Fischer 24*ff12d537SAndre Fischer #include "ResourceManager.hxx" 25*ff12d537SAndre Fischer #include <unotools/confignode.hxx> 26*ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 27*ff12d537SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 28*ff12d537SAndre Fischer #include <tools/diagnose_ex.h> 29*ff12d537SAndre Fischer 30*ff12d537SAndre Fischer 31*ff12d537SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 32*ff12d537SAndre Fischer 33*ff12d537SAndre Fischer using ::rtl::OUString; 34*ff12d537SAndre Fischer using namespace css; 35*ff12d537SAndre Fischer using namespace cssu; 36*ff12d537SAndre Fischer 37*ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 38*ff12d537SAndre Fischer 39*ff12d537SAndre Fischer #define gsPrivateResourceToolpanelPrefix "private:resource/toolpanel/" 40*ff12d537SAndre Fischer 41*ff12d537SAndre Fischer 42*ff12d537SAndre Fischer 43*ff12d537SAndre Fischer class ResourceManager::Deleter 44*ff12d537SAndre Fischer { 45*ff12d537SAndre Fischer public: 46*ff12d537SAndre Fischer void operator() (ResourceManager* pObject) 47*ff12d537SAndre Fischer { 48*ff12d537SAndre Fischer delete pObject; 49*ff12d537SAndre Fischer } 50*ff12d537SAndre Fischer }; 51*ff12d537SAndre Fischer 52*ff12d537SAndre Fischer 53*ff12d537SAndre Fischer ResourceManager& ResourceManager::Instance (void) 54*ff12d537SAndre Fischer { 55*ff12d537SAndre Fischer static ResourceManager maInstance; 56*ff12d537SAndre Fischer return maInstance; 57*ff12d537SAndre Fischer } 58*ff12d537SAndre Fischer 59*ff12d537SAndre Fischer 60*ff12d537SAndre Fischer 61*ff12d537SAndre Fischer 62*ff12d537SAndre Fischer ResourceManager::ResourceManager (void) 63*ff12d537SAndre Fischer : maDecks(), 64*ff12d537SAndre Fischer maPanels(), 65*ff12d537SAndre Fischer maProcessedApplications() 66*ff12d537SAndre Fischer { 67*ff12d537SAndre Fischer ReadDeckList(); 68*ff12d537SAndre Fischer ReadPanelList(); 69*ff12d537SAndre Fischer } 70*ff12d537SAndre Fischer 71*ff12d537SAndre Fischer 72*ff12d537SAndre Fischer 73*ff12d537SAndre Fischer 74*ff12d537SAndre Fischer ResourceManager::~ResourceManager (void) 75*ff12d537SAndre Fischer { 76*ff12d537SAndre Fischer maPanels.clear(); 77*ff12d537SAndre Fischer maDecks.clear(); 78*ff12d537SAndre Fischer } 79*ff12d537SAndre Fischer 80*ff12d537SAndre Fischer 81*ff12d537SAndre Fischer 82*ff12d537SAndre Fischer 83*ff12d537SAndre Fischer const DeckDescriptor* ResourceManager::GetBestMatchingDeck ( 84*ff12d537SAndre Fischer const Context& rContext, 85*ff12d537SAndre Fischer const Reference<frame::XFrame>& rxFrame) 86*ff12d537SAndre Fischer { 87*ff12d537SAndre Fischer ReadLegacyAddons(rxFrame); 88*ff12d537SAndre Fischer 89*ff12d537SAndre Fischer sal_Int32 nBestMatch (Context::NoMatch); 90*ff12d537SAndre Fischer const DeckContainer::const_iterator iEnd (maDecks.end()); 91*ff12d537SAndre Fischer DeckContainer::const_iterator iBestDeck (iEnd); 92*ff12d537SAndre Fischer 93*ff12d537SAndre Fischer for (DeckContainer::const_iterator iDeck(maDecks.begin()); 94*ff12d537SAndre Fischer iDeck!=iEnd; 95*ff12d537SAndre Fischer ++iDeck) 96*ff12d537SAndre Fischer { 97*ff12d537SAndre Fischer const sal_Int32 nMatch (rContext.EvaluateMatch(iDeck->maContexts)); 98*ff12d537SAndre Fischer if (nMatch < nBestMatch) 99*ff12d537SAndre Fischer { 100*ff12d537SAndre Fischer // Found a better matching decks. 101*ff12d537SAndre Fischer nBestMatch = nMatch; 102*ff12d537SAndre Fischer iBestDeck = iDeck; 103*ff12d537SAndre Fischer if (nBestMatch == Context::OptimalMatch) 104*ff12d537SAndre Fischer { 105*ff12d537SAndre Fischer // We will not find a better match. 106*ff12d537SAndre Fischer break; 107*ff12d537SAndre Fischer } 108*ff12d537SAndre Fischer } 109*ff12d537SAndre Fischer } 110*ff12d537SAndre Fischer if (iBestDeck != iEnd) 111*ff12d537SAndre Fischer return &*iBestDeck; 112*ff12d537SAndre Fischer else 113*ff12d537SAndre Fischer return NULL; 114*ff12d537SAndre Fischer } 115*ff12d537SAndre Fischer 116*ff12d537SAndre Fischer 117*ff12d537SAndre Fischer 118*ff12d537SAndre Fischer 119*ff12d537SAndre Fischer const ResourceManager::DeckContainer& ResourceManager::GetMatchingDecks ( 120*ff12d537SAndre Fischer DeckContainer& rDeckDescriptors, 121*ff12d537SAndre Fischer const Context& rContext, 122*ff12d537SAndre Fischer const Reference<frame::XFrame>& rxFrame) 123*ff12d537SAndre Fischer { 124*ff12d537SAndre Fischer ReadLegacyAddons(rxFrame); 125*ff12d537SAndre Fischer 126*ff12d537SAndre Fischer for (DeckContainer::const_iterator 127*ff12d537SAndre Fischer iDeck(maDecks.begin()), 128*ff12d537SAndre Fischer iEnd (maDecks.end()); 129*ff12d537SAndre Fischer iDeck!=iEnd; 130*ff12d537SAndre Fischer ++iDeck) 131*ff12d537SAndre Fischer { 132*ff12d537SAndre Fischer if (rContext.EvaluateMatch(iDeck->maContexts) != Context::NoMatch) 133*ff12d537SAndre Fischer rDeckDescriptors.push_back(*iDeck); 134*ff12d537SAndre Fischer } 135*ff12d537SAndre Fischer 136*ff12d537SAndre Fischer return rDeckDescriptors; 137*ff12d537SAndre Fischer } 138*ff12d537SAndre Fischer 139*ff12d537SAndre Fischer 140*ff12d537SAndre Fischer 141*ff12d537SAndre Fischer 142*ff12d537SAndre Fischer const ResourceManager::PanelContainer& ResourceManager::GetMatchingPanels ( 143*ff12d537SAndre Fischer PanelContainer& rPanelDescriptors, 144*ff12d537SAndre Fischer const Context& rContext, 145*ff12d537SAndre Fischer const ::rtl::OUString& rsDeckId, 146*ff12d537SAndre Fischer const Reference<frame::XFrame>& rxFrame) 147*ff12d537SAndre Fischer { 148*ff12d537SAndre Fischer ReadLegacyAddons(rxFrame); 149*ff12d537SAndre Fischer 150*ff12d537SAndre Fischer for (PanelContainer::const_iterator 151*ff12d537SAndre Fischer iPanel(maPanels.begin()), 152*ff12d537SAndre Fischer iEnd(maPanels.end()); 153*ff12d537SAndre Fischer iPanel!=iEnd; 154*ff12d537SAndre Fischer ++iPanel) 155*ff12d537SAndre Fischer { 156*ff12d537SAndre Fischer const PanelDescriptor& rPanelDescriptor (*iPanel); 157*ff12d537SAndre Fischer if (rPanelDescriptor.msDeckId.equals(rsDeckId)) 158*ff12d537SAndre Fischer if (rContext.EvaluateMatch(rPanelDescriptor.maContexts) != Context::NoMatch) 159*ff12d537SAndre Fischer rPanelDescriptors.push_back(*iPanel); 160*ff12d537SAndre Fischer } 161*ff12d537SAndre Fischer 162*ff12d537SAndre Fischer return rPanelDescriptors; 163*ff12d537SAndre Fischer } 164*ff12d537SAndre Fischer 165*ff12d537SAndre Fischer 166*ff12d537SAndre Fischer 167*ff12d537SAndre Fischer 168*ff12d537SAndre Fischer void ResourceManager::ReadDeckList (void) 169*ff12d537SAndre Fischer { 170*ff12d537SAndre Fischer const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory()); 171*ff12d537SAndre Fischer const ::utl::OConfigurationTreeRoot aDeckRootNode ( 172*ff12d537SAndre Fischer aContext, 173*ff12d537SAndre Fischer A2S("org.openoffice.Office.UI.Sidebar/Content/DeckList"), 174*ff12d537SAndre Fischer false); 175*ff12d537SAndre Fischer if ( ! aDeckRootNode.isValid() ) 176*ff12d537SAndre Fischer return; 177*ff12d537SAndre Fischer 178*ff12d537SAndre Fischer const Sequence<OUString> aDeckNodeNames (aDeckRootNode.getNodeNames()); 179*ff12d537SAndre Fischer const sal_Int32 nCount (aDeckNodeNames.getLength()); 180*ff12d537SAndre Fischer maDecks.resize(nCount); 181*ff12d537SAndre Fischer sal_Int32 nWriteIndex(0); 182*ff12d537SAndre Fischer for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) 183*ff12d537SAndre Fischer { 184*ff12d537SAndre Fischer const ::utl::OConfigurationNode aDeckNode (aDeckRootNode.openNode(aDeckNodeNames[nReadIndex])); 185*ff12d537SAndre Fischer if ( ! aDeckNode.isValid()) 186*ff12d537SAndre Fischer continue; 187*ff12d537SAndre Fischer 188*ff12d537SAndre Fischer DeckDescriptor& rDeckDescriptor (maDecks[nWriteIndex++]); 189*ff12d537SAndre Fischer 190*ff12d537SAndre Fischer rDeckDescriptor.msTitle = ::comphelper::getString(aDeckNode.getNodeValue("Title")); 191*ff12d537SAndre Fischer rDeckDescriptor.msId = ::comphelper::getString(aDeckNode.getNodeValue("Id")); 192*ff12d537SAndre Fischer rDeckDescriptor.msIconURL = ::comphelper::getString(aDeckNode.getNodeValue("IconURL")); 193*ff12d537SAndre Fischer rDeckDescriptor.msHighContrastIconURL = ::comphelper::getString(aDeckNode.getNodeValue("HighContrastIconURL")); 194*ff12d537SAndre Fischer rDeckDescriptor.msHelpURL = ::comphelper::getString(aDeckNode.getNodeValue("HelpURL")); 195*ff12d537SAndre Fischer rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle; 196*ff12d537SAndre Fischer ReadContextList(aDeckNode.openNode("ContextList"), rDeckDescriptor.maContexts); 197*ff12d537SAndre Fischer } 198*ff12d537SAndre Fischer 199*ff12d537SAndre Fischer // When there where invalid nodes then we have to adapt the size 200*ff12d537SAndre Fischer // of the deck vector. 201*ff12d537SAndre Fischer if (nWriteIndex<nCount) 202*ff12d537SAndre Fischer maDecks.resize(nWriteIndex); 203*ff12d537SAndre Fischer } 204*ff12d537SAndre Fischer 205*ff12d537SAndre Fischer 206*ff12d537SAndre Fischer 207*ff12d537SAndre Fischer 208*ff12d537SAndre Fischer void ResourceManager::ReadPanelList (void) 209*ff12d537SAndre Fischer { 210*ff12d537SAndre Fischer const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory()); 211*ff12d537SAndre Fischer const ::utl::OConfigurationTreeRoot aPanelRootNode ( 212*ff12d537SAndre Fischer aContext, 213*ff12d537SAndre Fischer A2S("org.openoffice.Office.UI.Sidebar/Content/PanelList"), 214*ff12d537SAndre Fischer false); 215*ff12d537SAndre Fischer if ( ! aPanelRootNode.isValid() ) 216*ff12d537SAndre Fischer return; 217*ff12d537SAndre Fischer 218*ff12d537SAndre Fischer const Sequence<OUString> aPanelNodeNames (aPanelRootNode.getNodeNames()); 219*ff12d537SAndre Fischer const sal_Int32 nCount (aPanelNodeNames.getLength()); 220*ff12d537SAndre Fischer maPanels.resize(nCount); 221*ff12d537SAndre Fischer sal_Int32 nWriteIndex (0); 222*ff12d537SAndre Fischer for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) 223*ff12d537SAndre Fischer { 224*ff12d537SAndre Fischer const ::utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(aPanelNodeNames[nReadIndex])); 225*ff12d537SAndre Fischer if ( ! aPanelNode.isValid()) 226*ff12d537SAndre Fischer continue; 227*ff12d537SAndre Fischer 228*ff12d537SAndre Fischer PanelDescriptor& rPanelDescriptor (maPanels[nWriteIndex++]); 229*ff12d537SAndre Fischer 230*ff12d537SAndre Fischer rPanelDescriptor.msTitle = ::comphelper::getString( 231*ff12d537SAndre Fischer aPanelNode.getNodeValue("Title")); 232*ff12d537SAndre Fischer rPanelDescriptor.mbIsTitleBarOptional = ::comphelper::getBOOL( 233*ff12d537SAndre Fischer aPanelNode.getNodeValue("TitleBarIsOptional")); 234*ff12d537SAndre Fischer rPanelDescriptor.msId = ::comphelper::getString( 235*ff12d537SAndre Fischer aPanelNode.getNodeValue("Id")); 236*ff12d537SAndre Fischer rPanelDescriptor.msDeckId = ::comphelper::getString( 237*ff12d537SAndre Fischer aPanelNode.getNodeValue("DeckId")); 238*ff12d537SAndre Fischer rPanelDescriptor.msHelpURL = ::comphelper::getString( 239*ff12d537SAndre Fischer aPanelNode.getNodeValue("HelpURL")); 240*ff12d537SAndre Fischer rPanelDescriptor.msLayout = ::comphelper::getString( 241*ff12d537SAndre Fischer aPanelNode.getNodeValue("Layout")); 242*ff12d537SAndre Fischer rPanelDescriptor.msImplementationURL = ::comphelper::getString( 243*ff12d537SAndre Fischer aPanelNode.getNodeValue("ImplementationURL")); 244*ff12d537SAndre Fischer ReadContextList(aPanelNode.openNode("ContextList"), rPanelDescriptor.maContexts); 245*ff12d537SAndre Fischer } 246*ff12d537SAndre Fischer 247*ff12d537SAndre Fischer // When there where invalid nodes then we have to adapt the size 248*ff12d537SAndre Fischer // of the deck vector. 249*ff12d537SAndre Fischer if (nWriteIndex<nCount) 250*ff12d537SAndre Fischer maPanels.resize(nWriteIndex); 251*ff12d537SAndre Fischer } 252*ff12d537SAndre Fischer 253*ff12d537SAndre Fischer 254*ff12d537SAndre Fischer 255*ff12d537SAndre Fischer 256*ff12d537SAndre Fischer void ResourceManager::ReadContextList ( 257*ff12d537SAndre Fischer const ::utl::OConfigurationNode& rNode, 258*ff12d537SAndre Fischer ::std::vector<Context>& rContextContainer) const 259*ff12d537SAndre Fischer { 260*ff12d537SAndre Fischer const Sequence<OUString> aChildNodeNames (rNode.getNodeNames()); 261*ff12d537SAndre Fischer const sal_Int32 nCount (aChildNodeNames.getLength()); 262*ff12d537SAndre Fischer rContextContainer.resize(nCount); 263*ff12d537SAndre Fischer for (sal_Int32 nIndex(0); nIndex<nCount; ++nIndex) 264*ff12d537SAndre Fischer { 265*ff12d537SAndre Fischer const ::utl::OConfigurationNode aChildNode (rNode.openNode(aChildNodeNames[nIndex])); 266*ff12d537SAndre Fischer Context& rContext (rContextContainer[nIndex]); 267*ff12d537SAndre Fischer 268*ff12d537SAndre Fischer rContext.msApplication = ::comphelper::getString(aChildNode.getNodeValue("Application")); 269*ff12d537SAndre Fischer rContext.msContext = ::comphelper::getString(aChildNode.getNodeValue("ApplicationContext")); 270*ff12d537SAndre Fischer } 271*ff12d537SAndre Fischer } 272*ff12d537SAndre Fischer 273*ff12d537SAndre Fischer 274*ff12d537SAndre Fischer 275*ff12d537SAndre Fischer 276*ff12d537SAndre Fischer void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame) 277*ff12d537SAndre Fischer { 278*ff12d537SAndre Fischer // Get module name for given frame. 279*ff12d537SAndre Fischer ::rtl::OUString sModuleName (GetModuleName(rxFrame)); 280*ff12d537SAndre Fischer if (sModuleName.getLength() == 0) 281*ff12d537SAndre Fischer return; 282*ff12d537SAndre Fischer if (maProcessedApplications.find(sModuleName) != maProcessedApplications.end()) 283*ff12d537SAndre Fischer { 284*ff12d537SAndre Fischer // Addons for this application have already been read. 285*ff12d537SAndre Fischer // There is nothing more to do. 286*ff12d537SAndre Fischer return; 287*ff12d537SAndre Fischer } 288*ff12d537SAndre Fischer 289*ff12d537SAndre Fischer // Mark module as processed. Even when there is an error that 290*ff12d537SAndre Fischer // prevents the configuration data from being read, this error 291*ff12d537SAndre Fischer // will not be triggered a second time. 292*ff12d537SAndre Fischer maProcessedApplications.insert(sModuleName); 293*ff12d537SAndre Fischer 294*ff12d537SAndre Fischer // Get access to the configuration root node for the application. 295*ff12d537SAndre Fischer ::utl::OConfigurationTreeRoot aLegacyRootNode (GetLegacyAddonRootNode(sModuleName)); 296*ff12d537SAndre Fischer if ( ! aLegacyRootNode.isValid()) 297*ff12d537SAndre Fischer return; 298*ff12d537SAndre Fischer 299*ff12d537SAndre Fischer // Process child nodes. 300*ff12d537SAndre Fischer ::std::vector<OUString> aMatchingNodeNames; 301*ff12d537SAndre Fischer GetToolPanelNodeNames(aMatchingNodeNames, aLegacyRootNode); 302*ff12d537SAndre Fischer const sal_Int32 nCount (aMatchingNodeNames.size()); 303*ff12d537SAndre Fischer sal_Int32 nDeckWriteIndex (maDecks.size()); 304*ff12d537SAndre Fischer sal_Int32 nPanelWriteIndex (maPanels.size()); 305*ff12d537SAndre Fischer maDecks.resize(maDecks.size() + nCount); 306*ff12d537SAndre Fischer maPanels.resize(maPanels.size() + nCount); 307*ff12d537SAndre Fischer for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) 308*ff12d537SAndre Fischer { 309*ff12d537SAndre Fischer const OUString& rsNodeName (aMatchingNodeNames[nReadIndex]); 310*ff12d537SAndre Fischer const ::utl::OConfigurationNode aChildNode (aLegacyRootNode.openNode(rsNodeName)); 311*ff12d537SAndre Fischer if ( ! aChildNode.isValid()) 312*ff12d537SAndre Fischer continue; 313*ff12d537SAndre Fischer 314*ff12d537SAndre Fischer DeckDescriptor& rDeckDescriptor (maDecks[nDeckWriteIndex++]); 315*ff12d537SAndre Fischer rDeckDescriptor.msTitle = ::comphelper::getString(aChildNode.getNodeValue("UIName")); 316*ff12d537SAndre Fischer rDeckDescriptor.msId = rsNodeName; 317*ff12d537SAndre Fischer rDeckDescriptor.msIconURL = ::comphelper::getString(aChildNode.getNodeValue("ImageURL")); 318*ff12d537SAndre Fischer rDeckDescriptor.msHighContrastIconURL = rDeckDescriptor.msIconURL; 319*ff12d537SAndre Fischer rDeckDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL")); 320*ff12d537SAndre Fischer rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle; 321*ff12d537SAndre Fischer rDeckDescriptor.maContexts.resize(1); 322*ff12d537SAndre Fischer rDeckDescriptor.maContexts.front() = Context(A2S("any"), A2S("any")); 323*ff12d537SAndre Fischer 324*ff12d537SAndre Fischer PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]); 325*ff12d537SAndre Fischer rPanelDescriptor.msTitle = ::comphelper::getString(aChildNode.getNodeValue("UIName")); 326*ff12d537SAndre Fischer rPanelDescriptor.mbIsTitleBarOptional = false; 327*ff12d537SAndre Fischer rPanelDescriptor.msId = rsNodeName; 328*ff12d537SAndre Fischer rPanelDescriptor.msDeckId = rsNodeName; 329*ff12d537SAndre Fischer rPanelDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL")); 330*ff12d537SAndre Fischer rPanelDescriptor.maContexts.resize(1); 331*ff12d537SAndre Fischer rPanelDescriptor.maContexts.front() = Context(A2S("any"), A2S("any")); 332*ff12d537SAndre Fischer rPanelDescriptor.msLayout = A2S("full"); 333*ff12d537SAndre Fischer rPanelDescriptor.msImplementationURL = rsNodeName; 334*ff12d537SAndre Fischer } 335*ff12d537SAndre Fischer 336*ff12d537SAndre Fischer // When there where invalid nodes then we have to adapt the size 337*ff12d537SAndre Fischer // of the deck and panel vectors. 338*ff12d537SAndre Fischer if (nDeckWriteIndex < maDecks.size()) 339*ff12d537SAndre Fischer maDecks.resize(nDeckWriteIndex); 340*ff12d537SAndre Fischer if (nPanelWriteIndex < maPanels.size()) 341*ff12d537SAndre Fischer maPanels.resize(nPanelWriteIndex); 342*ff12d537SAndre Fischer } 343*ff12d537SAndre Fischer 344*ff12d537SAndre Fischer 345*ff12d537SAndre Fischer 346*ff12d537SAndre Fischer 347*ff12d537SAndre Fischer ::rtl::OUString ResourceManager::GetModuleName ( 348*ff12d537SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) const 349*ff12d537SAndre Fischer { 350*ff12d537SAndre Fischer try 351*ff12d537SAndre Fischer { 352*ff12d537SAndre Fischer const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory()); 353*ff12d537SAndre Fischer const Reference<frame::XModuleManager> xModuleManager ( 354*ff12d537SAndre Fischer aContext.createComponent("com.sun.star.frame.ModuleManager" ), 355*ff12d537SAndre Fischer UNO_QUERY_THROW ); 356*ff12d537SAndre Fischer return xModuleManager->identify(rxFrame); 357*ff12d537SAndre Fischer } 358*ff12d537SAndre Fischer catch (const Exception&) 359*ff12d537SAndre Fischer { 360*ff12d537SAndre Fischer DBG_UNHANDLED_EXCEPTION(); 361*ff12d537SAndre Fischer } 362*ff12d537SAndre Fischer return OUString(); 363*ff12d537SAndre Fischer } 364*ff12d537SAndre Fischer 365*ff12d537SAndre Fischer 366*ff12d537SAndre Fischer 367*ff12d537SAndre Fischer 368*ff12d537SAndre Fischer ::utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode ( 369*ff12d537SAndre Fischer const ::rtl::OUString& rsModuleName) const 370*ff12d537SAndre Fischer { 371*ff12d537SAndre Fischer try 372*ff12d537SAndre Fischer { 373*ff12d537SAndre Fischer const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory()); 374*ff12d537SAndre Fischer const Reference<container::XNameAccess> xModuleAccess ( 375*ff12d537SAndre Fischer aContext.createComponent("com.sun.star.frame.ModuleManager"), 376*ff12d537SAndre Fischer UNO_QUERY_THROW); 377*ff12d537SAndre Fischer const ::comphelper::NamedValueCollection aModuleProperties (xModuleAccess->getByName(rsModuleName)); 378*ff12d537SAndre Fischer const ::rtl::OUString sWindowStateRef (aModuleProperties.getOrDefault( 379*ff12d537SAndre Fischer "ooSetupFactoryWindowStateConfigRef", 380*ff12d537SAndre Fischer ::rtl::OUString())); 381*ff12d537SAndre Fischer 382*ff12d537SAndre Fischer ::rtl::OUStringBuffer aPathComposer; 383*ff12d537SAndre Fischer aPathComposer.appendAscii("org.openoffice.Office.UI."); 384*ff12d537SAndre Fischer aPathComposer.append(sWindowStateRef); 385*ff12d537SAndre Fischer aPathComposer.appendAscii("/UIElements/States"); 386*ff12d537SAndre Fischer 387*ff12d537SAndre Fischer return ::utl::OConfigurationTreeRoot(aContext, aPathComposer.makeStringAndClear(), false); 388*ff12d537SAndre Fischer } 389*ff12d537SAndre Fischer catch( const Exception& ) 390*ff12d537SAndre Fischer { 391*ff12d537SAndre Fischer DBG_UNHANDLED_EXCEPTION(); 392*ff12d537SAndre Fischer } 393*ff12d537SAndre Fischer 394*ff12d537SAndre Fischer return ::utl::OConfigurationTreeRoot(); 395*ff12d537SAndre Fischer } 396*ff12d537SAndre Fischer 397*ff12d537SAndre Fischer 398*ff12d537SAndre Fischer 399*ff12d537SAndre Fischer 400*ff12d537SAndre Fischer void ResourceManager::GetToolPanelNodeNames ( 401*ff12d537SAndre Fischer ::std::vector<OUString>& rMatchingNames, 402*ff12d537SAndre Fischer const ::utl::OConfigurationTreeRoot aRoot) const 403*ff12d537SAndre Fischer { 404*ff12d537SAndre Fischer Sequence<OUString> aChildNodeNames (aRoot.getNodeNames()); 405*ff12d537SAndre Fischer const sal_Int32 nCount (aChildNodeNames.getLength()); 406*ff12d537SAndre Fischer for (sal_Int32 nIndex(0); nIndex<nCount; ++nIndex) 407*ff12d537SAndre Fischer { 408*ff12d537SAndre Fischer if (aChildNodeNames[nIndex].matchAsciiL( 409*ff12d537SAndre Fischer RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/"))) 410*ff12d537SAndre Fischer rMatchingNames.push_back(aChildNodeNames[nIndex]); 411*ff12d537SAndre Fischer } 412*ff12d537SAndre Fischer } 413*ff12d537SAndre Fischer 414*ff12d537SAndre Fischer 415*ff12d537SAndre Fischer 416*ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 417