summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-14 14:19:07 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-14 14:19:07 +0100
commit161c3f179f71eda2a32dabaf68ff6fb3ba487062 (patch)
tree2920a3b4fc55e65512b198aec0c5fbdac1a13619 /cui
parent00717e8550ac41069a01c7ef7c11fbe40d75e91d (diff)
Some more comphelper/configurationhelper clean up
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/treeopt.hxx9
-rw-r--r--cui/source/options/optpath.cxx15
-rw-r--r--cui/source/options/treeopt.cxx318
3 files changed, 159 insertions, 183 deletions
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx
index a107750bbc30..90777c870558 100644
--- a/cui/source/inc/treeopt.hxx
+++ b/cui/source/inc/treeopt.hxx
@@ -138,7 +138,6 @@ struct LastPageSaver
// class OfaTreeOptionsDialog --------------------------------------------
namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
-namespace com { namespace sun { namespace star { namespace container { class XNameAccess; } } } }
namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } }
namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } }
@@ -192,12 +191,8 @@ private:
com::sun::star::lang::XMultiServiceFactory >& xMFac,
const com::sun::star::uno::Reference<
com::sun::star::frame::XFrame >& xFrame );
- Module* LoadModule( const rtl::OUString& rModuleIdentifier,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameAccess >& xRoot );
- void LoadNodes( const com::sun::star::uno::Reference<
- com::sun::star::container::XNameAccess >& xRoot,
- Module* pModule,
+ Module* LoadModule( const rtl::OUString& rModuleIdentifier );
+ void LoadNodes( Module* pModule,
const rtl::OUString& rExtensionId,
VectorOfNodes& rOutNodeList );
void InsertNodes( const VectorOfNodes& rNodeList );
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index cdecf06e351f..4d8f8a94eddd 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -50,7 +50,7 @@
#include "optpath.hrc"
#include <cuires.hrc>
#include "helpid.hrc"
-#include <comphelper/configurationhelper.hxx>
+#include <comphelper/configuration.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/uno/Exception.hpp>
@@ -59,6 +59,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
+#include <officecfg/Office/Common.hxx>
#include "optHeaderTabListbox.hxx"
#include <readonlyimage.hxx>
#include <vcl/help.hxx>
@@ -532,13 +533,11 @@ void SvxPathTabPage::ChangeCurrentEntry( const String& _rFolder )
// Set configuration flag to notify file picker that it's necessary
// to take over the path provided.
- Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
- ::comphelper::ConfigurationHelper::writeDirectKey(xFactory,
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/")),
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Path/Info")),
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WorkPathChanged")),
- ::com::sun::star::uno::makeAny(true),
- ::comphelper::ConfigurationHelper::E_STANDARD);
+ boost::shared_ptr< comphelper::ConfigurationChanges > batch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Path::Info::WorkPathChanged::set(
+ true, batch);
+ batch->commit();
}
}
}
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 51a8066aa3c1..96a5999ca491 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -67,11 +67,11 @@
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
-#include <comphelper/configurationhelper.hxx>
#include <comphelper/processfactory.hxx>
#include <editeng/optitems.hxx>
#include <editeng/unolingu.hxx>
#include <linguistic/misc.hxx>
+#include <officecfg/Office/OptionsDialog.hxx>
#include <osl/module.hxx>
#include <osl/process.h>
#include <rtl/bootstrap.hxx>
@@ -2008,18 +2008,12 @@ void OfaTreeOptionsDialog::LoadExtensionOptions( const rtl::OUString& rExtension
{
Module* pModule = NULL;
Reference< XMultiServiceFactory > xMSFac = comphelper::getProcessServiceFactory();
- // open optionsdialog.xcu
- Reference< XNameAccess > xRoot(
- ::comphelper::ConfigurationHelper::openConfig(
- xMSFac, C2U("org.openoffice.Office.OptionsDialog"),
- ::comphelper::ConfigurationHelper::E_READONLY ), UNO_QUERY );
- DBG_ASSERT( xRoot.is(), "OfaTreeOptionsDialog::LoadExtensionOptions(): no config" );
// when called by Tools - Options then load nodes of active module
if ( rExtensionId.isEmpty() )
- pModule = LoadModule( GetModuleIdentifier( xMSFac, Reference< XFrame >() ), xRoot );
+ pModule = LoadModule( GetModuleIdentifier( xMSFac, Reference< XFrame >() ) );
VectorOfNodes aNodeList;
- LoadNodes( xRoot, pModule, rExtensionId, aNodeList );
+ LoadNodes( pModule, rExtensionId, aNodeList );
InsertNodes( aNodeList );
}
@@ -2058,64 +2052,58 @@ rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier(
}
Module* OfaTreeOptionsDialog::LoadModule(
- const rtl::OUString& rModuleIdentifier, const Reference< XNameAccess >& xRoot )
+ const rtl::OUString& rModuleIdentifier )
{
Module* pModule = NULL;
- Reference< XNameAccess > xSet;
+ Reference< XNameAccess > xSet(
+ officecfg::Office::OptionsDialog::Modules::get());
- if ( xRoot->hasByName( C2U("Modules") ) )
+ Sequence< rtl::OUString > seqNames = xSet->getElementNames();
+ for ( int i = 0; i < seqNames.getLength(); ++i )
{
- xRoot->getByName( C2U("Modules") ) >>= xSet;
- if ( xSet.is() )
+ rtl::OUString sModule( seqNames[i] );
+ if ( rModuleIdentifier == sModule )
{
- Sequence< rtl::OUString > seqNames = xSet->getElementNames();
- for ( int i = 0; i < seqNames.getLength(); ++i )
+ // current active module found
+ pModule = new Module( sModule );
+ pModule->m_bActive = true;
+
+ Reference< XNameAccess > xModAccess;
+ xSet->getByName( seqNames[i] ) >>= xModAccess;
+ if ( xModAccess.is() )
{
- rtl::OUString sModule( seqNames[i] );
- if ( rModuleIdentifier == sModule )
+ // load the nodes of this module
+ Reference< XNameAccess > xNodeAccess;
+ xModAccess->getByName( C2U("Nodes") ) >>= xNodeAccess;
+ if ( xNodeAccess.is() )
{
- // current active module found
- pModule = new Module( sModule );
- pModule->m_bActive = true;
-
- Reference< XNameAccess > xModAccess;
- xSet->getByName( seqNames[i] ) >>= xModAccess;
- if ( xModAccess.is() )
+ Sequence< rtl::OUString > xTemp = xNodeAccess->getElementNames();
+ Reference< XNameAccess > xAccess;
+ sal_Int32 nIndex = -1;
+ for ( int x = 0; x < xTemp.getLength(); ++x )
{
- // load the nodes of this module
- Reference< XNameAccess > xNodeAccess;
- xModAccess->getByName( C2U("Nodes") ) >>= xNodeAccess;
- if ( xNodeAccess.is() )
+ xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
+ if ( xAccess.is() )
{
- Sequence< rtl::OUString > xTemp = xNodeAccess->getElementNames();
- Reference< XNameAccess > xAccess;
- sal_Int32 nIndex = -1;
- for ( int x = 0; x < xTemp.getLength(); ++x )
+ xAccess->getByName( C2U("Index") ) >>= nIndex;
+ if ( nIndex < 0 )
+ // append nodes with index < 0
+ pModule->m_aNodeList.push_back(
+ new OrderedEntry( nIndex, xTemp[x] ) );
+ else
{
- xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
- if ( xAccess.is() )
+ // search position of the node
+ sal_uInt32 y = 0;
+ for ( ; y < pModule->m_aNodeList.size(); ++y )
{
- xAccess->getByName( C2U("Index") ) >>= nIndex;
- if ( nIndex < 0 )
- // append nodes with index < 0
- pModule->m_aNodeList.push_back(
- new OrderedEntry( nIndex, xTemp[x] ) );
- else
- {
- // search position of the node
- sal_uInt32 y = 0;
- for ( ; y < pModule->m_aNodeList.size(); ++y )
- {
- sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
- if ( nNodeIdx < 0 || nNodeIdx > nIndex )
- break;
- }
- // and insert the node on this position
- pModule->m_aNodeList.insert(
- pModule->m_aNodeList.begin() + y,
- new OrderedEntry( nIndex, xTemp[x] ) );
- }
+ sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
+ if ( nNodeIdx < 0 || nNodeIdx > nIndex )
+ break;
}
+ // and insert the node on this position
+ pModule->m_aNodeList.insert(
+ pModule->m_aNodeList.begin() + y,
+ new OrderedEntry( nIndex, xTemp[x] ) );
}
}
}
@@ -2127,151 +2115,145 @@ Module* OfaTreeOptionsDialog::LoadModule(
}
void OfaTreeOptionsDialog::LoadNodes(
- const Reference< XNameAccess >& xRoot, Module* pModule,
- const rtl::OUString& rExtensionId, VectorOfNodes& rOutNodeList )
+ Module* pModule, const rtl::OUString& rExtensionId,
+ VectorOfNodes& rOutNodeList )
{
- Reference< XNameAccess > xSet;
- if ( xRoot->hasByName( C2U("Nodes") ) )
+ Reference< XNameAccess > xSet(
+ officecfg::Office::OptionsDialog::Nodes::get());
+ VectorOfNodes aNodeList;
+ Sequence< rtl::OUString > seqNames = xSet->getElementNames();
+
+ for ( int i = 0; i < seqNames.getLength(); ++i )
{
- xRoot->getByName( C2U("Nodes") ) >>= xSet;
- if ( xSet.is() )
+ String sGroupName( seqNames[i] );
+ Reference< XNameAccess > xNodeAccess;
+ xSet->getByName( seqNames[i] ) >>= xNodeAccess;
+
+ if ( xNodeAccess.is() )
{
- VectorOfNodes aNodeList;
- Sequence< rtl::OUString > seqNames = xSet->getElementNames();
+ rtl::OUString sNodeId, sLabel, sPageURL, sGroupId;
+ bool bAllModules = false;
+ sal_Int32 nGroupIndex = 0;
+
+ sNodeId = seqNames[i];
+ xNodeAccess->getByName( C2U("Label") ) >>= sLabel;
+ xNodeAccess->getByName( C2U("OptionsPage") ) >>= sPageURL;
+ xNodeAccess->getByName( C2U("AllModules") ) >>= bAllModules;
+ xNodeAccess->getByName( C2U("GroupId") ) >>= sGroupId;
+ xNodeAccess->getByName( C2U("GroupIndex") ) >>= nGroupIndex;
- for ( int i = 0; i < seqNames.getLength(); ++i )
+ if ( sLabel.isEmpty() )
+ sLabel = sGroupName;
+ String sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
+ if ( sTemp.Len() > 0 )
+ sLabel = sTemp;
+ OptionsNode* pNode =
+ new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
+
+ if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
{
- String sGroupName( seqNames[i] );
- Reference< XNameAccess > xNodeAccess;
- xSet->getByName( seqNames[i] ) >>= xNodeAccess;
+ delete pNode;
+ continue;
+ }
- if ( xNodeAccess.is() )
+ Reference< XNameAccess > xLeavesSet;
+ xNodeAccess->getByName( C2U( "Leaves" ) ) >>= xLeavesSet;
+ if ( xLeavesSet.is() )
+ {
+ Sequence< rtl::OUString > seqLeaves = xLeavesSet->getElementNames();
+ for ( int j = 0; j < seqLeaves.getLength(); ++j )
{
- rtl::OUString sNodeId, sLabel, sPageURL, sGroupId;
- bool bAllModules = false;
- sal_Int32 nGroupIndex = 0;
-
- sNodeId = seqNames[i];
- xNodeAccess->getByName( C2U("Label") ) >>= sLabel;
- xNodeAccess->getByName( C2U("OptionsPage") ) >>= sPageURL;
- xNodeAccess->getByName( C2U("AllModules") ) >>= bAllModules;
- xNodeAccess->getByName( C2U("GroupId") ) >>= sGroupId;
- xNodeAccess->getByName( C2U("GroupIndex") ) >>= nGroupIndex;
-
- if ( sLabel.isEmpty() )
- sLabel = sGroupName;
- String sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
- if ( sTemp.Len() > 0 )
- sLabel = sTemp;
- OptionsNode* pNode =
- new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
-
- if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
- {
- delete pNode;
- continue;
- }
+ Reference< XNameAccess > xLeaveAccess;
+ xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
- Reference< XNameAccess > xLeavesSet;
- xNodeAccess->getByName( C2U( "Leaves" ) ) >>= xLeavesSet;
- if ( xLeavesSet.is() )
+ if ( xLeaveAccess.is() )
{
- Sequence< rtl::OUString > seqLeaves = xLeavesSet->getElementNames();
- for ( int j = 0; j < seqLeaves.getLength(); ++j )
- {
- Reference< XNameAccess > xLeaveAccess;
- xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
+ rtl::OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
+ sal_Int32 nLeafGrpIdx = 0;
- if ( xLeaveAccess.is() )
- {
- rtl::OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
- sal_Int32 nLeafGrpIdx = 0;
+ xLeaveAccess->getByName( C2U("Id") ) >>= sId;
+ xLeaveAccess->getByName( C2U("Label") ) >>= sLeafLabel;
+ xLeaveAccess->getByName( C2U("OptionsPage") ) >>= sLeafURL;
+ xLeaveAccess->getByName( C2U("EventHandlerService") ) >>= sEventHdl;
+ xLeaveAccess->getByName( C2U("GroupId") ) >>= sLeafGrpId;
+ xLeaveAccess->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx;
- xLeaveAccess->getByName( C2U("Id") ) >>= sId;
- xLeaveAccess->getByName( C2U("Label") ) >>= sLeafLabel;
- xLeaveAccess->getByName( C2U("OptionsPage") ) >>= sLeafURL;
- xLeaveAccess->getByName( C2U("EventHandlerService") ) >>= sEventHdl;
- xLeaveAccess->getByName( C2U("GroupId") ) >>= sLeafGrpId;
- xLeaveAccess->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx;
+ if ( rExtensionId.isEmpty() || sId == rExtensionId )
+ {
+ OptionsLeaf* pLeaf = new OptionsLeaf(
+ sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
- if ( rExtensionId.isEmpty() || sId == rExtensionId )
+ if ( !sLeafGrpId.isEmpty() )
+ {
+ bool bAlreadyOpened = false;
+ if ( pNode->m_aGroupedLeaves.size() > 0 )
{
- OptionsLeaf* pLeaf = new OptionsLeaf(
- sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
-
- if ( !sLeafGrpId.isEmpty() )
+ for ( sal_uInt32 k = 0;
+ k < pNode->m_aGroupedLeaves.size(); ++k )
{
- bool bAlreadyOpened = false;
- if ( pNode->m_aGroupedLeaves.size() > 0 )
+ if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
+ pNode->m_aGroupedLeaves[k][0]->m_sGroupId
+ == sLeafGrpId )
{
- for ( sal_uInt32 k = 0;
- k < pNode->m_aGroupedLeaves.size(); ++k )
+ sal_uInt32 l = 0;
+ for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
{
- if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
- pNode->m_aGroupedLeaves[k][0]->m_sGroupId
- == sLeafGrpId )
- {
- sal_uInt32 l = 0;
- for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
- {
- if ( pNode->m_aGroupedLeaves[k][l]->
- m_nGroupIndex >= nLeafGrpIdx )
- break;
- }
- pNode->m_aGroupedLeaves[k].insert(
- pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
- bAlreadyOpened = true;
+ if ( pNode->m_aGroupedLeaves[k][l]->
+ m_nGroupIndex >= nLeafGrpIdx )
break;
- }
}
- }
- if ( !bAlreadyOpened )
- {
- VectorOfLeaves aGroupedLeaves;
- aGroupedLeaves.push_back( pLeaf );
- pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
+ pNode->m_aGroupedLeaves[k].insert(
+ pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
+ bAlreadyOpened = true;
+ break;
}
}
- else
- pNode->m_aLeaves.push_back(
- new OptionsLeaf(
- sId, sLeafLabel, sLeafURL,
- sEventHdl, sLeafGrpId, nLeafGrpIdx ) );
+ }
+ if ( !bAlreadyOpened )
+ {
+ VectorOfLeaves aGroupedLeaves;
+ aGroupedLeaves.push_back( pLeaf );
+ pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
}
}
+ else
+ pNode->m_aLeaves.push_back(
+ new OptionsLeaf(
+ sId, sLeafLabel, sLeafURL,
+ sEventHdl, sLeafGrpId, nLeafGrpIdx ) );
}
}
-
- // do not insert nodes without leaves
- if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
- {
- pModule ? aNodeList.push_back( pNode ) : rOutNodeList.push_back( pNode );
- }
}
}
- if ( pModule && aNodeList.size() > 0 )
+ // do not insert nodes without leaves
+ if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
{
- sal_uInt32 i = 0, j = 0;
- for ( ; i < pModule->m_aNodeList.size(); ++i )
+ pModule ? aNodeList.push_back( pNode ) : rOutNodeList.push_back( pNode );
+ }
+ }
+ }
+
+ if ( pModule && aNodeList.size() > 0 )
+ {
+ sal_uInt32 i = 0, j = 0;
+ for ( ; i < pModule->m_aNodeList.size(); ++i )
+ {
+ rtl::OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
+ for ( j = 0; j < aNodeList.size(); ++j )
+ {
+ OptionsNode* pNode = aNodeList[j];
+ if ( pNode->m_sId == sNodeId )
{
- rtl::OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
- for ( j = 0; j < aNodeList.size(); ++j )
- {
- OptionsNode* pNode = aNodeList[j];
- if ( pNode->m_sId == sNodeId )
- {
- rOutNodeList.push_back( pNode );
- aNodeList.erase( aNodeList.begin() + j );
- break;
- }
- }
+ rOutNodeList.push_back( pNode );
+ aNodeList.erase( aNodeList.begin() + j );
+ break;
}
-
- for ( i = 0; i < aNodeList.size(); ++i )
- rOutNodeList.push_back( aNodeList[i] );
}
}
+
+ for ( i = 0; i < aNodeList.size(); ++i )
+ rOutNodeList.push_back( aNodeList[i] );
}
}