Kaydet (Commit) 9d9eb01e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

simplify gathering XML conf. data in sidebar ResourceManager

Change-Id: I218698079d205690b596f3d36ff7dedea08c92fa
üst 9a2fc944
...@@ -37,6 +37,24 @@ using namespace css::uno; ...@@ -37,6 +37,24 @@ using namespace css::uno;
namespace sfx2 { namespace sidebar { namespace sfx2 { namespace sidebar {
namespace
{
OUString getString(utl::OConfigurationNode aNode, const char* pNodeName)
{
return comphelper::getString(aNode.getNodeValue(pNodeName));
}
sal_Int32 getInt32(utl::OConfigurationNode aNode, const char* pNodeName)
{
return comphelper::getINT32(aNode.getNodeValue(pNodeName));
}
bool getBool(utl::OConfigurationNode aNode, const char* pNodeName)
{
return comphelper::getBOOL(aNode.getNodeValue(pNodeName));
}
} //end anonymous namespace
ResourceManager& ResourceManager::Instance() ResourceManager& ResourceManager::Instance()
{ {
static ResourceManager maInstance; static ResourceManager maInstance;
...@@ -194,26 +212,17 @@ void ResourceManager::ReadDeckList() ...@@ -194,26 +212,17 @@ void ResourceManager::ReadDeckList()
DeckDescriptor& rDeckDescriptor (maDecks[nWriteIndex++]); DeckDescriptor& rDeckDescriptor (maDecks[nWriteIndex++]);
rDeckDescriptor.msTitle = ::comphelper::getString( rDeckDescriptor.msTitle = getString(aDeckNode, "Title");
aDeckNode.getNodeValue("Title")); rDeckDescriptor.msId = getString(aDeckNode, "Id");
rDeckDescriptor.msId = ::comphelper::getString( rDeckDescriptor.msIconURL = getString(aDeckNode, "IconURL");
aDeckNode.getNodeValue("Id")); rDeckDescriptor.msHighContrastIconURL = getString(aDeckNode, "HighContrastIconURL");
rDeckDescriptor.msIconURL = ::comphelper::getString( rDeckDescriptor.msTitleBarIconURL = getString(aDeckNode, "TitleBarIconURL");
aDeckNode.getNodeValue("IconURL")); rDeckDescriptor.msHighContrastTitleBarIconURL = getString(aDeckNode, "HighContrastTitleBarIconURL");
rDeckDescriptor.msHighContrastIconURL = ::comphelper::getString( rDeckDescriptor.msHelpURL = getString(aDeckNode, "HelpURL");
aDeckNode.getNodeValue("HighContrastIconURL"));
rDeckDescriptor.msTitleBarIconURL = ::comphelper::getString(
aDeckNode.getNodeValue("TitleBarIconURL"));
rDeckDescriptor.msHighContrastTitleBarIconURL = ::comphelper::getString(
aDeckNode.getNodeValue("HighContrastTitleBarIconURL"));
rDeckDescriptor.msHelpURL = ::comphelper::getString(
aDeckNode.getNodeValue("HelpURL"));
rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle; rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
rDeckDescriptor.mbIsEnabled = true; rDeckDescriptor.mbIsEnabled = true;
rDeckDescriptor.mnOrderIndex = ::comphelper::getINT32( rDeckDescriptor.mnOrderIndex = getInt32(aDeckNode, "OrderIndex");
aDeckNode.getNodeValue("OrderIndex")); rDeckDescriptor.mbExperimental = getBool(aDeckNode, "IsExperimental");
rDeckDescriptor.mbExperimental = ::comphelper::getBOOL(
aDeckNode.getNodeValue("IsExperimental"));
ReadContextList( ReadContextList(
aDeckNode, aDeckNode,
...@@ -248,32 +257,19 @@ void ResourceManager::ReadPanelList() ...@@ -248,32 +257,19 @@ void ResourceManager::ReadPanelList()
PanelDescriptor& rPanelDescriptor (maPanels[nWriteIndex++]); PanelDescriptor& rPanelDescriptor (maPanels[nWriteIndex++]);
rPanelDescriptor.msTitle = ::comphelper::getString( rPanelDescriptor.msTitle = getString(aPanelNode, "Title");
aPanelNode.getNodeValue("Title")); rPanelDescriptor.mbIsTitleBarOptional = getBool(aPanelNode, "TitleBarIsOptional");
rPanelDescriptor.mbIsTitleBarOptional = ::comphelper::getBOOL( rPanelDescriptor.msId = getString(aPanelNode, "Id");
aPanelNode.getNodeValue("TitleBarIsOptional")); rPanelDescriptor.msDeckId = getString(aPanelNode, "DeckId");
rPanelDescriptor.msId = ::comphelper::getString( rPanelDescriptor.msTitleBarIconURL = getString(aPanelNode, "TitleBarIconURL");
aPanelNode.getNodeValue("Id")); rPanelDescriptor.msHighContrastTitleBarIconURL = getString(aPanelNode, "HighContrastTitleBarIconURL");
rPanelDescriptor.msDeckId = ::comphelper::getString( rPanelDescriptor.msHelpURL = getString(aPanelNode, "HelpURL");
aPanelNode.getNodeValue("DeckId")); rPanelDescriptor.msImplementationURL = getString(aPanelNode, "ImplementationURL");
rPanelDescriptor.msTitleBarIconURL = ::comphelper::getString( rPanelDescriptor.mnOrderIndex = getInt32(aPanelNode, "OrderIndex");
aPanelNode.getNodeValue("TitleBarIconURL")); rPanelDescriptor.mbShowForReadOnlyDocuments = getBool(aPanelNode, "ShowForReadOnlyDocument");
rPanelDescriptor.msHighContrastTitleBarIconURL = ::comphelper::getString( rPanelDescriptor.mbWantsCanvas = getBool(aPanelNode, "WantsCanvas");
aPanelNode.getNodeValue("HighContrastTitleBarIconURL")); rPanelDescriptor.mbExperimental = getBool(aPanelNode, "IsExperimental");
rPanelDescriptor.msHelpURL = ::comphelper::getString( const OUString sDefaultMenuCommand(getString(aPanelNode, "DefaultMenuCommand"));
aPanelNode.getNodeValue("HelpURL"));
rPanelDescriptor.msImplementationURL = ::comphelper::getString(
aPanelNode.getNodeValue("ImplementationURL"));
rPanelDescriptor.mnOrderIndex = ::comphelper::getINT32(
aPanelNode.getNodeValue("OrderIndex"));
rPanelDescriptor.mbShowForReadOnlyDocuments = ::comphelper::getBOOL(
aPanelNode.getNodeValue("ShowForReadOnlyDocument"));
rPanelDescriptor.mbWantsCanvas = ::comphelper::getBOOL(
aPanelNode.getNodeValue("WantsCanvas"));
rPanelDescriptor.mbExperimental = ::comphelper::getBOOL(
aPanelNode.getNodeValue("IsExperimental"));
const OUString sDefaultMenuCommand (::comphelper::getString(
aPanelNode.getNodeValue("DefaultMenuCommand")));
ReadContextList(aPanelNode, rPanelDescriptor.maContextList, sDefaultMenuCommand); ReadContextList(aPanelNode, rPanelDescriptor.maContextList, sDefaultMenuCommand);
} }
...@@ -474,26 +470,26 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame) ...@@ -474,26 +470,26 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame)
continue; continue;
DeckDescriptor& rDeckDescriptor (maDecks[nDeckWriteIndex++]); DeckDescriptor& rDeckDescriptor (maDecks[nDeckWriteIndex++]);
rDeckDescriptor.msTitle = ::comphelper::getString(aChildNode.getNodeValue("UIName")); rDeckDescriptor.msTitle = getString(aChildNode, "UIName");
rDeckDescriptor.msId = rsNodeName; rDeckDescriptor.msId = rsNodeName;
rDeckDescriptor.msIconURL = ::comphelper::getString(aChildNode.getNodeValue("ImageURL")); rDeckDescriptor.msIconURL = getString(aChildNode, "ImageURL");
rDeckDescriptor.msHighContrastIconURL = rDeckDescriptor.msIconURL; rDeckDescriptor.msHighContrastIconURL = rDeckDescriptor.msIconURL;
rDeckDescriptor.msTitleBarIconURL.clear(); rDeckDescriptor.msTitleBarIconURL.clear();
rDeckDescriptor.msHighContrastTitleBarIconURL.clear(); rDeckDescriptor.msHighContrastTitleBarIconURL.clear();
rDeckDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL")); rDeckDescriptor.msHelpURL = getString(aChildNode, "HelpURL");
rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle; rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
rDeckDescriptor.mbIsEnabled = true; rDeckDescriptor.mbIsEnabled = true;
rDeckDescriptor.mnOrderIndex = 100000 + nReadIndex; rDeckDescriptor.mnOrderIndex = 100000 + nReadIndex;
rDeckDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString()); rDeckDescriptor.maContextList.AddContextDescription(Context(sModuleName, OUString("any")), true, OUString());
PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]); PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]);
rPanelDescriptor.msTitle = ::comphelper::getString(aChildNode.getNodeValue("UIName")); rPanelDescriptor.msTitle = getString(aChildNode, "UIName");
rPanelDescriptor.mbIsTitleBarOptional = true; rPanelDescriptor.mbIsTitleBarOptional = true;
rPanelDescriptor.msId = rsNodeName; rPanelDescriptor.msId = rsNodeName;
rPanelDescriptor.msDeckId = rsNodeName; rPanelDescriptor.msDeckId = rsNodeName;
rPanelDescriptor.msTitleBarIconURL.clear(); rPanelDescriptor.msTitleBarIconURL.clear();
rPanelDescriptor.msHighContrastTitleBarIconURL.clear(); rPanelDescriptor.msHighContrastTitleBarIconURL.clear();
rPanelDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL")); rPanelDescriptor.msHelpURL = getString(aChildNode, "HelpURL");
rPanelDescriptor.msImplementationURL = rsNodeName; rPanelDescriptor.msImplementationURL = rsNodeName;
rPanelDescriptor.mnOrderIndex = 100000 + nReadIndex; rPanelDescriptor.mnOrderIndex = 100000 + nReadIndex;
rPanelDescriptor.mbShowForReadOnlyDocuments = false; rPanelDescriptor.mbShowForReadOnlyDocuments = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment