configmgr/source/access.cxx | 7 cui/source/options/optaboutconfig.cxx | 249 +++++++++++++++++++--------------- cui/source/options/optaboutconfig.hxx | 4 3 files changed, 146 insertions(+), 114 deletions(-)
New commits: commit 6ac384a1ccd4f52e16b9c2393441096f6d9e7bc1 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Dec 6 16:53:36 2013 +0100 More Expert Config Page fixes Change-Id: Iaa2b7df4246ab3fa31737126f27e4a9da3814048 (cherry picked from commit 434465cee3c5e21881d3466f115d968e8fbf731c) diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index ad145de..56b945a 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/beans/XProperty.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameReplace.hpp> +#include <com/sun/star/container/XHierarchicalName.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/util/XChangesBatch.hpp> @@ -175,27 +176,25 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& r void CuiAboutConfigTabPage::Reset(/* const SfxItemSet&*/ ) { - OUString sRootNodePath = ""; m_pPrefBox->Clear(); m_vectorOfModified.clear(); m_pPrefBox->GetModel()->SetSortMode( SortNone ); m_pPrefBox->SetUpdateMode(sal_False); - Reference< XNameAccess > xConfigAccess = getConfigAccess( sRootNodePath, sal_False ); - FillItems( xConfigAccess, sRootNodePath ); + Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", sal_False ); + FillItems( xConfigAccess ); m_pPrefBox->SetUpdateMode(sal_True); } sal_Bool CuiAboutConfigTabPage::FillItemSet(/* SfxItemSet&*/ ) { sal_Bool bModified = sal_False; - Reference< XNameAccess > xUpdateAccess = getConfigAccess( "/", sal_True ); std::vector< boost::shared_ptr< Prop_Impl > >::iterator pIter; for( pIter = m_vectorOfModified.begin() ; pIter != m_vectorOfModified.end(); ++pIter ) { - xUpdateAccess = getConfigAccess( (*pIter)->Name , sal_True ); + Reference< XNameAccess > xUpdateAccess = getConfigAccess( (*pIter)->Name , sal_True ); Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW ); xNameReplace->replaceByName( (*pIter)->Property, (*pIter)->Value ); @@ -208,10 +207,12 @@ sal_Bool CuiAboutConfigTabPage::FillItemSet(/* SfxItemSet&*/ ) return bModified; } -void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, const OUString& sPath) +void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess) { + OUString sPath = Reference< XHierarchicalName >( + xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName(); uno::Sequence< OUString > seqItems = xNameAccess->getElementNames(); - for( sal_Int16 i = 0; i < seqItems.getLength(); ++i ) + for( sal_Int32 i = 0; i < seqItems.getLength(); ++i ) { Any aNode = xNameAccess->getByName( seqItems[i] ); @@ -219,7 +220,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces if( xNextNameAccess.is() ) { // not leaf node - FillItems( xNextNameAccess, sPath + "/" + seqItems[i] ); + FillItems( xNextNameAccess ); } else { @@ -227,100 +228,152 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces OUString sType = aNode.getValueTypeName(); OUString sValue; - if( aNode.hasValue() ) + switch( aNode.getValueType().getTypeClass() ) { - switch( aNode.getValueType().getTypeClass() ) + case ::com::sun::star::uno::TypeClass_VOID: + break; + + case ::com::sun::star::uno::TypeClass_BOOLEAN: + sValue = OUString::boolean( aNode.get<bool>() ); + break; + + case ::com::sun::star::uno::TypeClass_SHORT: + case ::com::sun::star::uno::TypeClass_LONG: + case ::com::sun::star::uno::TypeClass_HYPER: + sValue = OUString::number( aNode.get<sal_Int64>() ); + break; + + case ::com::sun::star::uno::TypeClass_DOUBLE: + sValue = OUString::number( aNode.get<double>() ); + break; + + case ::com::sun::star::uno::TypeClass_STRING: + sValue = aNode.get<OUString>(); + break; + + case ::com::sun::star::uno::TypeClass_SEQUENCE: + if( sType == "[]boolean" ) { - case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT : - case ::com::sun::star::uno::TypeClass_SHORT : - case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG : - case ::com::sun::star::uno::TypeClass_LONG : - //case ::com::sun::star::uno::TypeClass_INT : + uno::Sequence<sal_Bool> seq = aNode.get< uno::Sequence<sal_Bool> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { - sal_Int32 nVal = 0; - if(aNode >>= nVal) + if( j != 0 ) { - sValue = OUString::number( nVal ); + sValue += ","; } + sValue += OUString::boolean( seq[j] ); } - break; - - case ::com::sun::star::uno::TypeClass_BOOLEAN : + } + else if( sType == "[]byte" ) + { + uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { - sal_Bool bVal = sal_False; - if(aNode >>= bVal ) + OUString s = OUString::number( + static_cast<sal_uInt8>(seq[j]), 16 ); + if( s.getLength() == 1 ) { - sValue = OUString::boolean( bVal ); + sValue += "0"; } + sValue += s.toAsciiUpperCase(); } - break; - - case ::com::sun::star::uno::TypeClass_STRING : + } + else if( sType == "[][]byte" ) + { + uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { - OUString sString; - if(aNode >>= sString) + if( j != 0 ) { - sValue = sString; + sValue += ","; } - - } - break; - - case ::com::sun::star::uno::TypeClass_SEQUENCE : - //case ::com::sun::star::uno::TypeClass_ARRAY : - { - sValue = ""; - if( "[]long" == sType || "[]short"== sType ) + for( sal_Int32 k = 0; k != seq[j].getLength(); ++k ) { - uno::Sequence<sal_Int32> seqLong; - if( aNode >>= seqLong ) + OUString s = OUString::number( + static_cast<sal_uInt8>(seq[j][k]), 16 ); + if( s.getLength() == 1 ) { - for(int nInd=0; nInd < seqLong.getLength(); ++nInd) - { - sValue += OUString::number(seqLong[nInd]) + ","; - } + sValue += "0"; } + sValue += s.toAsciiUpperCase(); } - - if( "[]string" == sType ) + } + } + else if( sType == "[]short" ) + { + uno::Sequence<sal_Int16> seq = aNode.get< uno::Sequence<sal_Int16> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + { + if( j != 0 ) { - uno::Sequence< OUString > seqOUString; - if( aNode >>= seqOUString ) - { - for( sal_Int16 nInd=0; nInd < seqOUString.getLength(); ++nInd ) - { - sValue += seqOUString[nInd] + ","; - } - } + sValue += ","; } - - if( "[]hyper" == sType ) + sValue += OUString::number( seq[j] ); + } + } + else if( sType == "[]long" ) + { + uno::Sequence<sal_Int32> seq = aNode.get< uno::Sequence<sal_Int32> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + { + if( j != 0 ) { - uno::Sequence< sal_Int64 > seqHyp; - if( aNode >>= seqHyp ) - { - for(int nInd = 0; nInd < seqHyp.getLength(); ++nInd) - { - sValue += OUString::number( seqHyp[nInd] ) + ","; - } - } + sValue += ","; } + sValue += OUString::number( seq[j] ); } - break; - - default: + } + else if( sType == "[]hyper" ) + { + uno::Sequence<sal_Int64> seq = aNode.get< uno::Sequence<sal_Int64> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { - if( "hyper" == sType ) + if( j != 0 ) { - sal_Int64 nHyp = 0; - if(aNode >>= nHyp) - { - sValue = OUString::number( nHyp ); - } - }else - sValue = ""; + sValue += ","; + } + sValue += OUString::number( seq[j] ); } } + else if( sType == "[]double" ) + { + uno::Sequence<double> seq = aNode.get< uno::Sequence<double> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + { + if( j != 0 ) + { + sValue += ","; + } + sValue += OUString::number( seq[j] ); + } + } + else if( sType == "[]string" ) + { + uno::Sequence<OUString> seq = aNode.get< uno::Sequence<OUString> >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + { + if( j != 0 ) + { + sValue += ","; + } + sValue += seq[j]; + } + } + else + { + SAL_WARN( + "cui.options", + "path \"" << sPath << "\" member " << seqItems[i] + << " of unsupported type " << sType); + } + break; + + default: + SAL_WARN( + "cui.options", + "path \"" << sPath << "\" member " << seqItems[i] + << " of unsupported type " << sType); + break; } InsertEntry( sPath, seqItems[i], sType, sValue); @@ -335,8 +388,6 @@ Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( OUString sNodeP uno::Reference< lang::XMultiServiceFactory > xConfigProvider( com::sun::star::configuration::theDefaultProvider::get( xContext ) ); - if( sNodePath == "" ) - sNodePath = "/"; beans::NamedValue aProperty; aProperty.Name = "nodepath"; aProperty.Value = uno::makeAny( sNodePath ); @@ -365,7 +416,7 @@ void CuiAboutConfigTabPage::AddToModifiedVector( const boost::shared_ptr< Prop_I //Check if value modified before for( size_t nInd = 0; nInd < m_vectorOfModified.size() ; ++nInd ) { - if( rProp->Name == m_vectorOfModified[nInd]->Name && rProp->Value == m_vectorOfModified[nInd]->Value ) + if( rProp->Name == m_vectorOfModified[nInd]->Name && rProp->Property == m_vectorOfModified[nInd]->Property ) { //property modified before. assing reference to the modified value //do your changes on this object. They will be saved later. diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 9ad78a6..7d6017d 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -62,7 +62,7 @@ public: CuiAboutConfigTabPage( Window* pParent/*, const SfxItemSet& rItemSet*/ ); void InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue); void Reset(/* const SfxItemSet&*/ ); - void FillItems(const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess>& xNameAccess, const OUString& sPath); + void FillItems(const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess>& xNameAccess); com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess( OUString sNodePath, sal_Bool bUpdate ); virtual sal_Bool FillItemSet( /* SfxItemSet& rSet*/ ); commit 50d9e9e59fdd38ec8e24ac0f844015080bbcd36f Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Dec 6 16:52:27 2013 +0100 Do not create paths starting "//" when root is just "/" Change-Id: If0b413a4fdd93465074548c7ea5451288c1d12aa (cherry picked from commit bd8b3be0c7535e74ca8b63969be5c2bece0d3a3b) diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 280f053..a6a8035 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -543,13 +543,14 @@ OUString Access::getHierarchicalName() throw (css::uno::RuntimeException) { checkLocalizedPropertyAccess(); // For backwards compatibility, return an absolute path representation where // available: - OUStringBuffer path; + OUString rootPath; rtl::Reference< RootAccess > root(getRootAccess()); if (root.is()) { - path.append(root->getAbsolutePathRepresentation()); + rootPath = root->getAbsolutePathRepresentation(); } OUString rel(getRelativePathRepresentation()); - if (!path.isEmpty() && !rel.isEmpty()) { + OUStringBuffer path(rootPath); + if (!rootPath.isEmpty() && rootPath != "/" && !rel.isEmpty()) { path.append('/'); } path.append(rel); commit a176f564883b3bfd16fbf1750d46521d4a491dc2 Author: Noel Grandin <n...@peralex.com> Date: Fri Dec 6 10:39:34 2013 +0200 fdo#72125 - Expert config dialog takes too much time to come up This is not a full fix, this just trims some of the fat in CuiAboutConfigTabPage::FillItems. Specifically - improve string handling - don't use catch/throw unnecessarily Change-Id: I5b4987407bd007fbbb18f76fcf26f4a33282c0c0 Signed-off-by: Stephan Bergmann <sberg...@redhat.com>: reintroduced lost "/" into path of recursive FillItems calls (cherry picked from commit 7468f9b773d5a9a4cb3af57cf123c2a0e7e937fd) diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 6f8a757..ad145de 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -26,6 +26,7 @@ #include <vector> #include <boost/shared_ptr.hpp> +#include <iostream> using namespace svx; using namespace ::com::sun::star; @@ -209,37 +210,26 @@ sal_Bool CuiAboutConfigTabPage::FillItemSet(/* SfxItemSet&*/ ) void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, const OUString& sPath) { - sal_Bool bIsLeafNode; - - Reference< XHierarchicalNameAccess > xHierarchicalNameAccess( xNameAccess, uno::UNO_QUERY_THROW ); - uno::Sequence< OUString > seqItems = xNameAccess->getElementNames(); for( sal_Int16 i = 0; i < seqItems.getLength(); ++i ) { - Any aNode = xHierarchicalNameAccess->getByHierarchicalName( seqItems[i] ); - - bIsLeafNode = sal_True; - - try - { - Reference< XHierarchicalNameAccess >xNextHierarchicalNameAccess( aNode, uno::UNO_QUERY_THROW ); - Reference< XNameAccess > xNextNameAccess( xNextHierarchicalNameAccess, uno::UNO_QUERY_THROW ); - FillItems( xNextNameAccess, sPath + OUString("/") + seqItems[i] ); - bIsLeafNode = sal_False; + Any aNode = xNameAccess->getByName( seqItems[i] ); - } - catch( uno::Exception& ) + Reference< XNameAccess > xNextNameAccess( aNode, uno::UNO_QUERY ); + if( xNextNameAccess.is() ) { + // not leaf node + FillItems( xNextNameAccess, sPath + "/" + seqItems[i] ); } - - if( bIsLeafNode ) + else { - Any aProp = xHierarchicalNameAccess->getByHierarchicalName(seqItems[i]); + // leaf node + OUString sType = aNode.getValueTypeName(); OUString sValue; - if( aProp.hasValue() ) + if( aNode.hasValue() ) { - switch( aProp.getValueType().getTypeClass() ) + switch( aNode.getValueType().getTypeClass() ) { case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT : case ::com::sun::star::uno::TypeClass_SHORT : @@ -248,10 +238,9 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces //case ::com::sun::star::uno::TypeClass_INT : { sal_Int32 nVal = 0; - if(aProp >>= nVal) + if(aNode >>= nVal) { - OUString aNumber( OUString::number( nVal ) ); - sValue = aNumber; + sValue = OUString::number( nVal ); } } break; @@ -259,10 +248,9 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces case ::com::sun::star::uno::TypeClass_BOOLEAN : { sal_Bool bVal = sal_False; - if(aProp >>= bVal ) + if(aNode >>= bVal ) { - OUString sBoolean( OUString::boolean( bVal ) ); - sValue = sBoolean; + sValue = OUString::boolean( bVal ); } } break; @@ -270,7 +258,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces case ::com::sun::star::uno::TypeClass_STRING : { OUString sString; - if(aProp >>= sString) + if(aNode >>= sString) { sValue = sString; } @@ -282,43 +270,38 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces //case ::com::sun::star::uno::TypeClass_ARRAY : { sValue = ""; - if( OUString("[]long") ==aProp.getValueTypeName() || - OUString("[]short")==aProp.getValueTypeName() ) + if( "[]long" == sType || "[]short"== sType ) { uno::Sequence<sal_Int32> seqLong; - if( aProp >>= seqLong ) + if( aNode >>= seqLong ) { for(int nInd=0; nInd < seqLong.getLength(); ++nInd) { - OUString sNumber( OUString::number(seqLong[nInd]) ); - sValue += sNumber; - sValue += ","; + sValue += OUString::number(seqLong[nInd]) + ","; } } } - if( OUString("[]string") == aProp.getValueTypeName() ) + if( "[]string" == sType ) { uno::Sequence< OUString > seqOUString; - if( aProp >>= seqOUString ) + if( aNode >>= seqOUString ) { for( sal_Int16 nInd=0; nInd < seqOUString.getLength(); ++nInd ) { - sValue += seqOUString[nInd] + OUString(","); + sValue += seqOUString[nInd] + ","; } } } - if( OUString("[]hyper") == aProp.getValueTypeName() ) + if( "[]hyper" == sType ) { uno::Sequence< sal_Int64 > seqHyp; - if( aProp >>= seqHyp ) + if( aNode >>= seqHyp ) { for(int nInd = 0; nInd < seqHyp.getLength(); ++nInd) { - OUString sHyper( OUString::number( seqHyp[nInd] ) ); - sValue += sHyper; - sValue += ","; + sValue += OUString::number( seqHyp[nInd] ) + ","; } } } @@ -327,13 +310,12 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces default: { - if( OUString("hyper") == aProp.getValueTypeName() ) + if( "hyper" == sType ) { sal_Int64 nHyp = 0; - if(aProp >>= nHyp) + if(aNode >>= nHyp) { - OUString aHyp( OUString::number( nHyp ) ); - sValue = aHyp; + sValue = OUString::number( nHyp ); } }else sValue = ""; @@ -341,8 +323,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } } - OUString sType = aProp.getValueTypeName(); - InsertEntry( sPath, seqItems [ i ], sType, sValue); + InsertEntry( sPath, seqItems[i], sType, sValue); } } } commit 71226058d7cbf3582c5fe9d453ed503d6b97f3c4 Author: Jan Holesovsky <ke...@collabora.com> Date: Thu Dec 5 19:26:56 2013 +0100 A bit of constness. Change-Id: If7681341c7d5d88286f36f943708f99b3c5700e0 (cherry picked from commit 0b5e5783d8b15b0415c9fd5043932882904aece8) diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 742b649..6f8a757 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -159,7 +159,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( Window* pParent/*, const SfxItemSe m_pPrefBox->SetTabs(aTabs, MAP_PIXEL); } -void CuiAboutConfigTabPage::InsertEntry( OUString& rProp, OUString& rStatus, OUString& rType, OUString& rValue) +void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue) { SvTreeListEntry* pEntry = new SvTreeListEntry; @@ -207,13 +207,12 @@ sal_Bool CuiAboutConfigTabPage::FillItemSet(/* SfxItemSet&*/ ) return bModified; } -void CuiAboutConfigTabPage::FillItems( Reference< XNameAccess >xNameAccess, OUString sPath) +void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, const OUString& sPath) { sal_Bool bIsLeafNode; Reference< XHierarchicalNameAccess > xHierarchicalNameAccess( xNameAccess, uno::UNO_QUERY_THROW ); - uno::Sequence< OUString > seqItems = xNameAccess->getElementNames(); for( sal_Int16 i = 0; i < seqItems.getLength(); ++i ) { diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 55ba3e2..9ad78a6 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -60,9 +60,9 @@ private: public: //static ModalDialog* Create( Window* pParent, const SfxItemSet& rItemset ); CuiAboutConfigTabPage( Window* pParent/*, const SfxItemSet& rItemSet*/ ); - void InsertEntry(OUString& rProp, OUString& rStatus, OUString& rType, OUString& rValue); + void InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue); void Reset(/* const SfxItemSet&*/ ); - void FillItems( com::sun::star::uno::Reference < com::sun::star::container::XNameAccess > xNameAccess, OUString sPath); + void FillItems(const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess>& xNameAccess, const OUString& sPath); com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess( OUString sNodePath, sal_Bool bUpdate ); virtual sal_Bool FillItemSet( /* SfxItemSet& rSet*/ ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits