From 434465cee3c5e21881d3466f115d968e8fbf731c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 6 Dec 2013 16:53:36 +0100 Subject: More Expert Config Page fixes Change-Id: Iaa2b7df4246ab3fa31737126f27e4a9da3814048 --- cui/source/options/optaboutconfig.cxx | 209 +++++++++++++++++++++------------- cui/source/options/optaboutconfig.hxx | 2 +- 2 files changed, 131 insertions(+), 80 deletions(-) (limited to 'cui') diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index ad145de90b7c..56b945afeee6 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -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() ); + 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() ); + break; + + case ::com::sun::star::uno::TypeClass_DOUBLE: + sValue = OUString::number( aNode.get() ); + break; + + case ::com::sun::star::uno::TypeClass_STRING: + sValue = aNode.get(); + 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 seq = aNode.get< uno::Sequence >(); + 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 seq = aNode.get< uno::Sequence >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { - sal_Bool bVal = sal_False; - if(aNode >>= bVal ) + OUString s = OUString::number( + static_cast(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 > seq = aNode.get< uno::Sequence< uno::Sequence > >(); + 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 seqLong; - if( aNode >>= seqLong ) + OUString s = OUString::number( + static_cast(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 seq = aNode.get< uno::Sequence >(); + 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 seq = aNode.get< uno::Sequence >(); + 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 seq = aNode.get< uno::Sequence >(); + 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 seq = aNode.get< uno::Sequence >(); + for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + { + if( j != 0 ) + { + sValue += ","; + } + sValue += OUString::number( seq[j] ); + } + } + else if( sType == "[]string" ) + { + uno::Sequence seq = aNode.get< uno::Sequence >(); + 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 9ad78a6d2cf8..7d6017da630b 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& xNameAccess, const OUString& sPath); + void FillItems(const com::sun::star::uno::Reference& xNameAccess); com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess( OUString sNodePath, sal_Bool bUpdate ); virtual sal_Bool FillItemSet( /* SfxItemSet& rSet*/ ); -- cgit