LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - ResourceManager.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 229 298 76.8 %
Date: 2015-06-13 12:38:46 Functions: 17 19 89.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "ResourceManager.hxx"
      21             : #include <sfx2/sidebar/Tools.hxx>
      22             : 
      23             : #include <unotools/confignode.hxx>
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <comphelper/namedvaluecollection.hxx>
      26             : #include <comphelper/types.hxx>
      27             : 
      28             : #include <rtl/ustrbuf.hxx>
      29             : #include <tools/diagnose_ex.h>
      30             : 
      31             : #include <com/sun/star/frame/ModuleManager.hpp>
      32             : 
      33             : #include <map>
      34             : 
      35             : using namespace css;
      36             : using namespace css::uno;
      37             : 
      38             : namespace sfx2 { namespace sidebar {
      39             : 
      40             : namespace
      41             : {
      42             : 
      43       28518 : OUString getString(utl::OConfigurationNode const & aNode, const char* pNodeName)
      44             : {
      45       28518 :     return comphelper::getString(aNode.getNodeValue(pNodeName));
      46             : }
      47        3686 : sal_Int32 getInt32(utl::OConfigurationNode const & aNode, const char* pNodeName)
      48             : {
      49        3686 :     return comphelper::getINT32(aNode.getNodeValue(pNodeName));
      50             : }
      51       11834 : bool getBool(utl::OConfigurationNode const & aNode, const char* pNodeName)
      52             : {
      53       11834 :     return comphelper::getBOOL(aNode.getNodeValue(pNodeName));
      54             : }
      55             : 
      56             : } //end anonymous namespace
      57             : 
      58       26094 : ResourceManager& ResourceManager::Instance()
      59             : {
      60       26094 :     static ResourceManager maInstance;
      61       26094 :     return maInstance;
      62             : }
      63             : 
      64          97 : ResourceManager::ResourceManager()
      65             :     : maDecks(),
      66             :       maPanels(),
      67             :       maProcessedApplications(),
      68          97 :       maMiscOptions()
      69             : {
      70          97 :     ReadDeckList();
      71          97 :     ReadPanelList();
      72          97 : }
      73             : 
      74          97 : ResourceManager::~ResourceManager()
      75             : {
      76          97 : }
      77             : 
      78       13573 : const DeckDescriptor* ResourceManager::GetDeckDescriptor(const OUString& rsDeckId) const
      79             : {
      80       13573 :     DeckContainer::const_iterator iDeck;
      81       49225 :     for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck)
      82             :     {
      83       49225 :         if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode())
      84       13573 :             continue;
      85       35652 :         if (iDeck->msId.equals(rsDeckId))
      86       13573 :             return &*iDeck;
      87             :     }
      88           0 :     return NULL;
      89             : }
      90             : 
      91        9300 : const PanelDescriptor* ResourceManager::GetPanelDescriptor(const OUString& rsPanelId) const
      92             : {
      93        9300 :     PanelContainer::const_iterator iPanel;
      94      121867 :     for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel)
      95             :     {
      96      121867 :         if (iPanel->msId.equals(rsPanelId))
      97        9300 :             return &*iPanel;
      98             :     }
      99           0 :     return NULL;
     100             : }
     101             : 
     102           0 : void ResourceManager::SetIsDeckEnabled(const OUString& rsDeckId, const bool bIsEnabled)
     103             : {
     104           0 :     DeckContainer::iterator iDeck;
     105           0 :     for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck)
     106             :     {
     107           0 :         if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode())
     108           0 :             continue;
     109           0 :         if (iDeck->msId.equals(rsDeckId))
     110             :         {
     111           0 :             iDeck->mbIsEnabled = bIsEnabled;
     112           0 :             return;
     113             :         }
     114             :     }
     115             : }
     116             : 
     117         610 : const ResourceManager::DeckContextDescriptorContainer& ResourceManager::GetMatchingDecks (
     118             :                                                             DeckContextDescriptorContainer& rDecks,
     119             :                                                             const Context& rContext,
     120             :                                                             const bool bIsDocumentReadOnly,
     121             :                                                             const Reference<frame::XFrame>& rxFrame)
     122             : {
     123         610 :     ReadLegacyAddons(rxFrame);
     124             : 
     125         610 :     std::multimap<sal_Int32,DeckContextDescriptor> aOrderedIds;
     126         610 :     DeckContainer::const_iterator iDeck;
     127        6710 :     for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck)
     128             :     {
     129        6100 :         if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode())
     130        3690 :             continue;
     131        5490 :         const DeckDescriptor& rDeckDescriptor (*iDeck);
     132        5490 :         if (rDeckDescriptor.maContextList.GetMatch(rContext) == NULL)
     133        2470 :             continue;
     134        3020 :         DeckContextDescriptor aDeckContextDescriptor;
     135        3020 :         aDeckContextDescriptor.msId = rDeckDescriptor.msId;
     136             :         aDeckContextDescriptor.mbIsEnabled =
     137        3020 :             ! bIsDocumentReadOnly
     138        3020 :             || IsDeckEnabled(rDeckDescriptor.msId, rContext, rxFrame);
     139             :         aOrderedIds.insert(::std::multimap<sal_Int32,DeckContextDescriptor>::value_type(
     140             :                 rDeckDescriptor.mnOrderIndex,
     141        3020 :                 aDeckContextDescriptor));
     142        3020 :     }
     143             : 
     144         610 :     std::multimap<sal_Int32,DeckContextDescriptor>::const_iterator iId;
     145        3630 :     for (iId = aOrderedIds.begin(); iId != aOrderedIds.end(); ++iId)
     146             :     {
     147        3020 :         rDecks.push_back(iId->second);
     148             :     }
     149             : 
     150         610 :     return rDecks;
     151             : }
     152             : 
     153        6984 : const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatchingPanels (
     154             :                                                             PanelContextDescriptorContainer& rPanelIds,
     155             :                                                             const Context& rContext,
     156             :                                                             const OUString& rsDeckId,
     157             :                                                             const Reference<frame::XFrame>& rxFrame)
     158             : {
     159        6984 :     ReadLegacyAddons(rxFrame);
     160             : 
     161        6984 :     std::multimap<sal_Int32, PanelContextDescriptor> aOrderedIds;
     162        6984 :     PanelContainer::const_iterator iPanel;
     163      202536 :     for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel)
     164             :     {
     165      195552 :         const PanelDescriptor& rPanelDescriptor (*iPanel);
     166      195552 :         if (rPanelDescriptor.mbExperimental && !maMiscOptions.IsExperimentalMode())
     167      204446 :             continue;
     168      181584 :         if ( ! rPanelDescriptor.msDeckId.equals(rsDeckId))
     169       83991 :             continue;
     170             : 
     171       97593 :         const ContextList::Entry* pEntry = rPanelDescriptor.maContextList.GetMatch(rContext);
     172       97593 :         if (pEntry == NULL)
     173       92519 :             continue;
     174             : 
     175        5074 :         PanelContextDescriptor aPanelContextDescriptor;
     176        5074 :         aPanelContextDescriptor.msId = rPanelDescriptor.msId;
     177        5074 :         aPanelContextDescriptor.msMenuCommand = pEntry->msMenuCommand;
     178        5074 :         aPanelContextDescriptor.mbIsInitiallyVisible = pEntry->mbIsInitiallyVisible;
     179        5074 :         aPanelContextDescriptor.mbShowForReadOnlyDocuments = rPanelDescriptor.mbShowForReadOnlyDocuments;
     180             :         aOrderedIds.insert(std::multimap<sal_Int32, PanelContextDescriptor>::value_type(
     181             :                                                     rPanelDescriptor.mnOrderIndex,
     182        5074 :                                                     aPanelContextDescriptor));
     183        5074 :     }
     184             : 
     185        6984 :     std::multimap<sal_Int32,PanelContextDescriptor>::const_iterator iId;
     186       12058 :     for (iId = aOrderedIds.begin(); iId != aOrderedIds.end(); ++iId)
     187             :     {
     188        5074 :         rPanelIds.push_back(iId->second);
     189             :     }
     190             : 
     191        6984 :     return rPanelIds;
     192             : }
     193             : 
     194          97 : void ResourceManager::ReadDeckList()
     195             : {
     196             :     const utl::OConfigurationTreeRoot aDeckRootNode(
     197             :                                         comphelper::getProcessComponentContext(),
     198             :                                         OUString("org.openoffice.Office.UI.Sidebar/Content/DeckList"),
     199          97 :                                         false);
     200          97 :     if (!aDeckRootNode.isValid())
     201          97 :         return;
     202             : 
     203         194 :     const Sequence<OUString> aDeckNodeNames (aDeckRootNode.getNodeNames());
     204          97 :     const sal_Int32 nCount(aDeckNodeNames.getLength());
     205          97 :     maDecks.resize(nCount);
     206          97 :     sal_Int32 nWriteIndex(0);
     207        1067 :     for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex)
     208             :     {
     209         970 :         const utl::OConfigurationNode aDeckNode(aDeckRootNode.openNode(aDeckNodeNames[nReadIndex]));
     210         970 :         if (!aDeckNode.isValid())
     211           0 :             continue;
     212             : 
     213         970 :         DeckDescriptor& rDeckDescriptor (maDecks[nWriteIndex++]);
     214             : 
     215         970 :         rDeckDescriptor.msTitle = getString(aDeckNode, "Title");
     216         970 :         rDeckDescriptor.msId = getString(aDeckNode, "Id");
     217         970 :         rDeckDescriptor.msIconURL = getString(aDeckNode, "IconURL");
     218         970 :         rDeckDescriptor.msHighContrastIconURL = getString(aDeckNode, "HighContrastIconURL");
     219         970 :         rDeckDescriptor.msTitleBarIconURL = getString(aDeckNode, "TitleBarIconURL");
     220         970 :         rDeckDescriptor.msHighContrastTitleBarIconURL = getString(aDeckNode, "HighContrastTitleBarIconURL");
     221         970 :         rDeckDescriptor.msHelpURL = getString(aDeckNode, "HelpURL");
     222         970 :         rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
     223         970 :         rDeckDescriptor.mbIsEnabled = true;
     224         970 :         rDeckDescriptor.mnOrderIndex = getInt32(aDeckNode, "OrderIndex");
     225         970 :         rDeckDescriptor.mbExperimental = getBool(aDeckNode, "IsExperimental");
     226             : 
     227             :         ReadContextList(
     228             :             aDeckNode,
     229             :             rDeckDescriptor.maContextList,
     230         970 :             OUString());
     231         970 :     }
     232             : 
     233             :     // When there where invalid nodes then we have to adapt the size
     234             :     // of the deck vector.
     235          97 :     if (nWriteIndex<nCount)
     236          97 :         maDecks.resize(nWriteIndex);
     237             : }
     238             : 
     239          97 : void ResourceManager::ReadPanelList()
     240             : {
     241             :     const utl::OConfigurationTreeRoot aPanelRootNode(
     242             :                                         comphelper::getProcessComponentContext(),
     243             :                                         OUString("org.openoffice.Office.UI.Sidebar/Content/PanelList"),
     244          97 :                                         false);
     245          97 :     if (!aPanelRootNode.isValid())
     246          97 :         return;
     247             : 
     248         194 :     const Sequence<OUString> aPanelNodeNames (aPanelRootNode.getNodeNames());
     249          97 :     const sal_Int32 nCount (aPanelNodeNames.getLength());
     250          97 :     maPanels.resize(nCount);
     251          97 :     sal_Int32 nWriteIndex (0);
     252        2813 :     for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex)
     253             :     {
     254        2716 :         const utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(aPanelNodeNames[nReadIndex]));
     255        2716 :         if (!aPanelNode.isValid())
     256           0 :             continue;
     257             : 
     258        2716 :         PanelDescriptor& rPanelDescriptor (maPanels[nWriteIndex++]);
     259             : 
     260        2716 :         rPanelDescriptor.msTitle = getString(aPanelNode, "Title");
     261        2716 :         rPanelDescriptor.mbIsTitleBarOptional = getBool(aPanelNode, "TitleBarIsOptional");
     262        2716 :         rPanelDescriptor.msId = getString(aPanelNode, "Id");
     263        2716 :         rPanelDescriptor.msDeckId = getString(aPanelNode, "DeckId");
     264        2716 :         rPanelDescriptor.msTitleBarIconURL = getString(aPanelNode, "TitleBarIconURL");
     265        2716 :         rPanelDescriptor.msHighContrastTitleBarIconURL = getString(aPanelNode, "HighContrastTitleBarIconURL");
     266        2716 :         rPanelDescriptor.msHelpURL = getString(aPanelNode, "HelpURL");
     267        2716 :         rPanelDescriptor.msImplementationURL = getString(aPanelNode, "ImplementationURL");
     268        2716 :         rPanelDescriptor.mnOrderIndex = getInt32(aPanelNode, "OrderIndex");
     269        2716 :         rPanelDescriptor.mbShowForReadOnlyDocuments = getBool(aPanelNode, "ShowForReadOnlyDocument");
     270        2716 :         rPanelDescriptor.mbWantsCanvas = getBool(aPanelNode, "WantsCanvas");
     271        2716 :         rPanelDescriptor.mbExperimental = getBool(aPanelNode, "IsExperimental");
     272        5432 :         const OUString sDefaultMenuCommand(getString(aPanelNode, "DefaultMenuCommand"));
     273             : 
     274        2716 :         ReadContextList(aPanelNode, rPanelDescriptor.maContextList, sDefaultMenuCommand);
     275        2716 :     }
     276             : 
     277             :     // When there where invalid nodes then we have to adapt the size
     278             :     // of the deck vector.
     279          97 :     if (nWriteIndex<nCount)
     280          97 :         maPanels.resize(nWriteIndex);
     281             : }
     282             : 
     283        3686 : void ResourceManager::ReadContextList (
     284             :                         const utl::OConfigurationNode& rParentNode,
     285             :                         ContextList& rContextList,
     286             :                         const OUString& rsDefaultMenuCommand)
     287             : {
     288        3686 :     const Any aValue = rParentNode.getNodeValue("ContextList");
     289        7372 :     Sequence<OUString> aValues;
     290             :     sal_Int32 nCount;
     291        3686 :     if (aValue >>= aValues)
     292        3686 :         nCount = aValues.getLength();
     293             :     else
     294           0 :         nCount = 0;
     295             : 
     296       16199 :     for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
     297             :     {
     298       16199 :         const OUString sValue (aValues[nIndex]);
     299       16199 :         sal_Int32 nCharacterIndex (0);
     300       28712 :         const OUString sApplicationName (sValue.getToken(0, ',', nCharacterIndex).trim());
     301       16199 :         if (nCharacterIndex < 0)
     302             :         {
     303        3686 :             if (sApplicationName.getLength() == 0)
     304             :             {
     305             :                 // This is a valid case: in the XML file the separator
     306             :                 // was used as terminator.  Using it in the last line
     307             :                 // creates an additional but empty entry.
     308        3686 :                 break;
     309             :             }
     310             :             else
     311             :             {
     312             :                 OSL_FAIL("expecting three or four values per ContextList entry, separated by comma");
     313           0 :                 continue;
     314             :             }
     315             :         }
     316             : 
     317       25026 :         const OUString sContextName(sValue.getToken(0, ',', nCharacterIndex).trim());
     318       12513 :         if (nCharacterIndex < 0)
     319             :         {
     320             :             OSL_FAIL("expecting three or four values per ContextList entry, separated by comma");
     321           0 :             continue;
     322             :         }
     323             : 
     324       25026 :         const OUString sInitialState(sValue.getToken(0, ',', nCharacterIndex).trim());
     325             : 
     326             :         // The fourth argument is optional.
     327             :         const OUString sMenuCommandOverride(
     328       12513 :             nCharacterIndex < 0
     329             :                 ? OUString()
     330       25026 :                 : sValue.getToken(0, ',', nCharacterIndex).trim());
     331             : 
     332             :         const OUString sMenuCommand(
     333       12513 :             sMenuCommandOverride.getLength() > 0
     334         582 :                 ? (sMenuCommandOverride == "none"
     335             :                     ? OUString()
     336             :                     : sMenuCommandOverride)
     337       25608 :                 : rsDefaultMenuCommand);
     338             : 
     339             :         // Setup a list of application enums.  Note that the
     340             :         // application name may result in more than one value (eg
     341             :         // DrawImpress will result in two enums, one for Draw and one
     342             :         // for Impress).
     343       25026 :         std::vector<EnumContext::Application> aApplications;
     344       12513 :         EnumContext::Application eApplication (EnumContext::GetApplicationEnum(sApplicationName));
     345       25026 :         if (eApplication == EnumContext::Application_None
     346       12513 :             && !sApplicationName.equals(EnumContext::GetApplicationName(EnumContext::Application_None)))
     347             :         {
     348             :             // Handle some special names: abbreviations that make
     349             :             // context descriptions more readable.
     350       11834 :             if (sApplicationName == "Writer")
     351         873 :                 aApplications.push_back(EnumContext::Application_Writer);
     352       10961 :             else if (sApplicationName == "Calc")
     353        3686 :                 aApplications.push_back(EnumContext::Application_Calc);
     354        7275 :             else if (sApplicationName == "Draw")
     355           0 :                 aApplications.push_back(EnumContext::Application_Draw);
     356        7275 :             else if (sApplicationName == "Impress")
     357        1358 :                 aApplications.push_back(EnumContext::Application_Impress);
     358        5917 :             else if (sApplicationName == "DrawImpress")
     359             :             {
     360             :                 // A special case among the special names:  it is
     361             :                 // common to use the same context descriptions for
     362             :                 // both Draw and Impress.  This special case helps to
     363             :                 // avoid duplication in the .xcu file.
     364        3201 :                 aApplications.push_back(EnumContext::Application_Draw);
     365        3201 :                 aApplications.push_back(EnumContext::Application_Impress);
     366             :             }
     367        2716 :             else if (sApplicationName == "WriterVariants")
     368             :             {
     369             :                 // Another special case for all Writer variants.
     370        2716 :                 aApplications.push_back(EnumContext::Application_Writer);
     371        2716 :                 aApplications.push_back(EnumContext::Application_WriterGlobal);
     372        2716 :                 aApplications.push_back(EnumContext::Application_WriterWeb);
     373        2716 :                 aApplications.push_back(EnumContext::Application_WriterXML);
     374        2716 :                 aApplications.push_back(EnumContext::Application_WriterForm);
     375        2716 :                 aApplications.push_back(EnumContext::Application_WriterReport);
     376             :             }
     377             :             else
     378             :             {
     379             :                 SAL_WARN("sfx2.sidebar", "application name " << sApplicationName << " not recognized");
     380           0 :                 continue;
     381             :             }
     382             :         }
     383             :         else
     384             :         {
     385             :             // No conversion of the application name necessary.
     386         679 :             aApplications.push_back(eApplication);
     387             :         }
     388             : 
     389             :         // Setup the actual context enum.
     390       12513 :         const EnumContext::Context eContext (EnumContext::GetContextEnum(sContextName));
     391       12513 :         if (eContext == EnumContext::Context_Unknown)
     392             :         {
     393             :             OSL_FAIL("context name not recognized");
     394           0 :             continue;
     395             :         }
     396             : 
     397             :         // Setup the flag that controls whether a deck/pane is
     398             :         // initially visible/expanded.
     399             :         bool bIsInitiallyVisible;
     400       12513 :         if (sInitialState == "visible")
     401       10185 :             bIsInitiallyVisible = true;
     402        2328 :         else if (sInitialState == "hidden")
     403        2328 :             bIsInitiallyVisible = false;
     404             :         else
     405             :         {
     406             :             OSL_FAIL("unrecognized state");
     407           0 :             continue;
     408             :         }
     409             : 
     410             :         // Add context descriptors.
     411       12513 :         std::vector<EnumContext::Application>::const_iterator iApplication;
     412       41807 :         for (iApplication = aApplications.begin(); iApplication != aApplications.end(); ++iApplication)
     413             :         {
     414       29294 :             if (*iApplication != EnumContext::Application_None)
     415             :             {
     416             :                 rContextList.AddContextDescription(
     417             :                     Context(
     418       29294 :                         EnumContext::GetApplicationName(*iApplication),
     419       29294 :                         EnumContext::GetContextName(eContext)),
     420             :                     bIsInitiallyVisible,
     421       58588 :                     sMenuCommand);
     422             :             }
     423             :         }
     424       16199 :     }
     425        3686 : }
     426             : 
     427        7594 : void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame)
     428             : {
     429             :     // Get module name for given frame.
     430        7594 :     OUString sModuleName (Tools::GetModuleName(rxFrame));
     431        7594 :     if (sModuleName.getLength() == 0)
     432           0 :         return;
     433        7594 :     if (maProcessedApplications.find(sModuleName) != maProcessedApplications.end())
     434             :     {
     435             :         // Addons for this application have already been read.
     436             :         // There is nothing more to do.
     437        7483 :         return;
     438             :     }
     439             : 
     440             :     // Mark module as processed.  Even when there is an error that
     441             :     // prevents the configuration data from being read, this error
     442             :     // will not be triggered a second time.
     443         111 :     maProcessedApplications.insert(sModuleName);
     444             : 
     445             :     // Get access to the configuration root node for the application.
     446         222 :     utl::OConfigurationTreeRoot aLegacyRootNode (GetLegacyAddonRootNode(sModuleName));
     447         111 :     if (!aLegacyRootNode.isValid())
     448           0 :         return;
     449             : 
     450             :     // Process child nodes.
     451         222 :     std::vector<OUString> aMatchingNodeNames;
     452         111 :     GetToolPanelNodeNames(aMatchingNodeNames, aLegacyRootNode);
     453         111 :     const sal_Int32 nCount (aMatchingNodeNames.size());
     454         111 :     size_t nDeckWriteIndex (maDecks.size());
     455         111 :     size_t nPanelWriteIndex (maPanels.size());
     456         111 :     maDecks.resize(maDecks.size() + nCount);
     457         111 :     maPanels.resize(maPanels.size() + nCount);
     458         111 :     for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex)
     459             :     {
     460           0 :         const OUString& rsNodeName (aMatchingNodeNames[nReadIndex]);
     461           0 :         const utl::OConfigurationNode aChildNode (aLegacyRootNode.openNode(rsNodeName));
     462           0 :         if (!aChildNode.isValid())
     463           0 :             continue;
     464             : 
     465           0 :         if ( rsNodeName == "private:resource/toolpanel/DrawingFramework/CustomAnimations" ||
     466           0 :              rsNodeName == "private:resource/toolpanel/DrawingFramework/Layouts" ||
     467           0 :              rsNodeName == "private:resource/toolpanel/DrawingFramework/MasterPages" ||
     468           0 :              rsNodeName == "private:resource/toolpanel/DrawingFramework/SlideTransitions" ||
     469           0 :              rsNodeName == "private:resource/toolpanel/DrawingFramework/TableDesign" )
     470           0 :           continue;
     471             : 
     472           0 :         DeckDescriptor& rDeckDescriptor (maDecks[nDeckWriteIndex++]);
     473           0 :         rDeckDescriptor.msTitle = getString(aChildNode, "UIName");
     474           0 :         rDeckDescriptor.msId = rsNodeName;
     475           0 :         rDeckDescriptor.msIconURL = getString(aChildNode, "ImageURL");
     476           0 :         rDeckDescriptor.msHighContrastIconURL = rDeckDescriptor.msIconURL;
     477           0 :         rDeckDescriptor.msTitleBarIconURL.clear();
     478           0 :         rDeckDescriptor.msHighContrastTitleBarIconURL.clear();
     479           0 :         rDeckDescriptor.msHelpURL = getString(aChildNode, "HelpURL");
     480           0 :         rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
     481           0 :         rDeckDescriptor.mbIsEnabled = true;
     482           0 :         rDeckDescriptor.mnOrderIndex = 100000 + nReadIndex;
     483           0 :         rDeckDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString());
     484             : 
     485           0 :         PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]);
     486           0 :         rPanelDescriptor.msTitle = getString(aChildNode, "UIName");
     487           0 :         rPanelDescriptor.mbIsTitleBarOptional = true;
     488           0 :         rPanelDescriptor.msId = rsNodeName;
     489           0 :         rPanelDescriptor.msDeckId = rsNodeName;
     490           0 :         rPanelDescriptor.msTitleBarIconURL.clear();
     491           0 :         rPanelDescriptor.msHighContrastTitleBarIconURL.clear();
     492           0 :         rPanelDescriptor.msHelpURL = getString(aChildNode, "HelpURL");
     493           0 :         rPanelDescriptor.msImplementationURL = rsNodeName;
     494           0 :         rPanelDescriptor.mnOrderIndex = 100000 + nReadIndex;
     495           0 :         rPanelDescriptor.mbShowForReadOnlyDocuments = false;
     496           0 :         rPanelDescriptor.mbWantsCanvas = false;
     497           0 :         rPanelDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString());
     498           0 :     }
     499             : 
     500             :     // When there where invalid nodes then we have to adapt the size
     501             :     // of the deck and panel vectors.
     502         111 :     if (nDeckWriteIndex < maDecks.size())
     503           0 :         maDecks.resize(nDeckWriteIndex);
     504         111 :     if (nPanelWriteIndex < maPanels.size())
     505         111 :         maPanels.resize(nPanelWriteIndex);
     506             : }
     507             : 
     508           0 : void ResourceManager::StorePanelExpansionState (
     509             :                         const OUString& rsPanelId,
     510             :                         const bool bExpansionState,
     511             :                         const Context& rContext)
     512             : {
     513           0 :     PanelContainer::iterator iPanel;
     514           0 :     for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel)
     515             :     {
     516           0 :         if (iPanel->msId.equals(rsPanelId))
     517             :         {
     518           0 :             ContextList::Entry* pEntry(iPanel->maContextList.GetMatch(rContext));
     519           0 :             if (pEntry != NULL)
     520           0 :                 pEntry->mbIsInitiallyVisible = bExpansionState;
     521             :         }
     522             :     }
     523           0 : }
     524             : 
     525         111 : utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode (const OUString& rsModuleName)
     526             : {
     527             :     try
     528             :     {
     529         111 :         const Reference<XComponentContext> xContext(comphelper::getProcessComponentContext());
     530         222 :         const Reference<frame::XModuleManager2> xModuleAccess = frame::ModuleManager::create(xContext);
     531         222 :         const comphelper::NamedValueCollection aModuleProperties(xModuleAccess->getByName(rsModuleName));
     532             :         const OUString sWindowStateRef(aModuleProperties.getOrDefault(
     533             :                                        "ooSetupFactoryWindowStateConfigRef",
     534         222 :                                        OUString()));
     535             : 
     536         222 :         OUStringBuffer aPathComposer;
     537         111 :         aPathComposer.appendAscii("org.openoffice.Office.UI.");
     538         111 :         aPathComposer.append(sWindowStateRef);
     539         111 :         aPathComposer.appendAscii("/UIElements/States");
     540             : 
     541         222 :         return utl::OConfigurationTreeRoot(xContext, aPathComposer.makeStringAndClear(), false);
     542             :     }
     543           0 :     catch (const Exception&)
     544             :     {
     545             :         DBG_UNHANDLED_EXCEPTION();
     546             :     }
     547             : 
     548           0 :     return utl::OConfigurationTreeRoot();
     549             : }
     550             : 
     551         111 : void ResourceManager::GetToolPanelNodeNames (
     552             :                         std::vector<OUString>& rMatchingNames,
     553             :                         const utl::OConfigurationTreeRoot& aRoot)
     554             : {
     555         111 :     Sequence<OUString> aChildNodeNames (aRoot.getNodeNames());
     556         111 :     const sal_Int32 nCount (aChildNodeNames.getLength());
     557        4377 :     for (sal_Int32 nIndex(0); nIndex<nCount; ++nIndex)
     558             :     {
     559        4266 :         if (aChildNodeNames[nIndex].startsWith( "private:resource/toolpanel/" ))
     560           0 :             rMatchingNames.push_back(aChildNodeNames[nIndex]);
     561         111 :     }
     562         111 : }
     563             : 
     564          15 : bool ResourceManager::IsDeckEnabled (
     565             :                         const OUString& rsDeckId,
     566             :                         const Context& rContext,
     567             :                         const Reference<frame::XFrame>& rxFrame)
     568             : {
     569             :     // Check if any panel that matches the current context can be
     570             :     // displayed.
     571          15 :     ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
     572          15 :     ResourceManager::Instance().GetMatchingPanels(aPanelContextDescriptors,
     573          15 :                                                   rContext, rsDeckId, rxFrame);
     574             : 
     575          15 :     ResourceManager::PanelContextDescriptorContainer::const_iterator iPanel;
     576          33 :     for (iPanel = aPanelContextDescriptors.begin(); iPanel != aPanelContextDescriptors.end(); ++iPanel)
     577             :     {
     578          21 :         if (iPanel->mbShowForReadOnlyDocuments)
     579           3 :             return true;
     580             :     }
     581             : 
     582          12 :     return false;
     583             : }
     584             : 
     585             : } } // end of namespace sfx2::sidebar
     586             : 
     587             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11