From f271ec5cd98ae32fd643df33174136d0a91a1941 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 13 Nov 2023 14:22:09 +0100 Subject: Format optaboutconfig with clang-format Change-Id: Ia696e096f972fe722920238c3710d20a3f03b221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159374 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- cui/source/options/optaboutconfig.cxx | 364 +++++++++++++++++----------------- cui/source/options/optaboutconfig.hxx | 34 ++-- 2 files changed, 202 insertions(+), 196 deletions(-) (limited to 'cui') diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 11806faa8477..362af44cfd7d 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -7,37 +7,37 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "optaboutconfig.hxx" #include #include -#include "optaboutconfig.hxx" -#include -#include -#include -#include #include #include #include #include #include #include +#include +#include #include #include -#include +#include #include #include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include #include +#include #include #include #include -#include -#include #include #include @@ -52,15 +52,16 @@ using namespace com::sun::star::container; struct Prop_Impl { - OUString Name; - OUString Property; - Any Value; - - Prop_Impl( OUString sName, OUString sProperty, Any aValue ) - : Name(std::move( sName )) - , Property(std::move( sProperty )) - , Value(std::move( aValue )) - {} + OUString Name; + OUString Property; + Any Value; + + Prop_Impl(OUString sName, OUString sProperty, Any aValue) + : Name(std::move(sName)) + , Property(std::move(sProperty)) + , Value(std::move(aValue)) + { + } }; struct UserData @@ -72,20 +73,22 @@ struct UserData int aLineage; Reference aXNameAccess; - explicit UserData( OUString aPropertyPath, OUString aTooltip, bool isReadOnly ) - : bIsPropertyPath( true ) - , bIsReadOnly( isReadOnly ) + explicit UserData(OUString aPropertyPath, OUString aTooltip, bool isReadOnly) + : bIsPropertyPath(true) + , bIsReadOnly(isReadOnly) , sPropertyPath(std::move(aPropertyPath)) , sTooltip(std::move(aTooltip)) , aLineage(0) - {} + { + } - explicit UserData( Reference const & rXNameAccess, int rIndex ) - : bIsPropertyPath( false ) - , bIsReadOnly( false ) + explicit UserData(Reference const& rXNameAccess, int rIndex) + : bIsPropertyPath(false) + , bIsReadOnly(false) , aLineage(rIndex) - , aXNameAccess( rXNameAccess ) - {} + , aXNameAccess(rXNameAccess) + { + } }; CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent) @@ -103,24 +106,20 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent) m_xPrefBox->get_height_rows(23)); m_xPrefBox->connect_column_clicked(LINK(this, CuiAboutConfigTabPage, HeaderBarClick)); - m_xEditBtn->connect_clicked(LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl)); - m_xResetBtn->connect_clicked(LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl)); + m_xEditBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl)); + m_xResetBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, ResetBtnHdl_Impl)); m_xPrefBox->connect_row_activated(LINK(this, CuiAboutConfigTabPage, DoubleClickHdl_Impl)); m_xPrefBox->connect_expanding(LINK(this, CuiAboutConfigTabPage, ExpandingHdl_Impl)); m_xSearchBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, SearchHdl_Impl)); m_options.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE; m_options.transliterateFlags |= TransliterationFlags::IGNORE_CASE; - m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE | - util::SearchFlags::REG_NOT_ENDOFLINE); + m_options.searchFlag + |= (util::SearchFlags::REG_NOT_BEGINOFLINE | util::SearchFlags::REG_NOT_ENDOFLINE); float fWidth = m_xPrefBox->get_approximate_digit_width(); - std::vector aWidths - { - o3tl::narrowing(fWidth * 65), - o3tl::narrowing(fWidth * 20), - o3tl::narrowing(fWidth * 8) - }; + std::vector aWidths{ o3tl::narrowing(fWidth * 65), o3tl::narrowing(fWidth * 20), + o3tl::narrowing(fWidth * 8) }; m_xPrefBox->set_column_fixed_widths(aWidths); m_xPrefBox->connect_query_tooltip(LINK(this, CuiAboutConfigTabPage, QueryTooltip)); @@ -128,7 +127,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent) IMPL_LINK(CuiAboutConfigTabPage, QueryTooltip, const weld::TreeIter&, rIter, OUString) { - UserData *pUserData = weld::fromId(m_xPrefBox->get_id(rIter)); + UserData* pUserData = weld::fromId(m_xPrefBox->get_id(rIter)); OUStringBuffer ret; if (pUserData && pUserData->bIsReadOnly) { @@ -181,20 +180,20 @@ IMPL_STATIC_LINK_NOARG(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, bool return true; } -CuiAboutConfigTabPage::~CuiAboutConfigTabPage() -{ -} +CuiAboutConfigTabPage::~CuiAboutConfigTabPage() {} -void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUString& rProp, const OUString& rStatus, - const OUString& rType, const OUString& rValue, const OUString& rTooltip, - const weld::TreeIter* pParentEntry, - bool bInsertToPrefBox, bool bIsReadOnly) +void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUString& rProp, + const OUString& rStatus, const OUString& rType, + const OUString& rValue, const OUString& rTooltip, + const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, + bool bIsReadOnly) { m_vectorUserData.push_back(std::make_unique(rPropertyPath, rTooltip, bIsReadOnly)); if (bInsertToPrefBox) { OUString sId(weld::toId(m_vectorUserData.back().get())); - m_xPrefBox->insert(pParentEntry, -1, &rProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + m_xPrefBox->insert(pParentEntry, -1, &rProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rType, 2); m_xPrefBox->set_text(*m_xScratchIter, rValue, 3); @@ -202,7 +201,8 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUS } else { - m_prefBoxEntries.push_back({rProp, rStatus, rType, rValue, m_vectorUserData.back().get()}); + m_prefBoxEntries.push_back( + { rProp, rStatus, rType, rValue, m_vectorUserData.back().get() }); } } @@ -222,42 +222,43 @@ void CuiAboutConfigTabPage::Reset() m_modifiedPrefBoxEntries.clear(); m_xPrefBox->freeze(); - Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", false ); + Reference xConfigAccess = getConfigAccess("/", false); //Load all XNameAccess to m_prefBoxEntries - FillItems( xConfigAccess, nullptr, 0, true ); + FillItems(xConfigAccess, nullptr, 0, true); //Load xConfigAccess' children to m_prefBox - FillItems( xConfigAccess ); + FillItems(xConfigAccess); m_xPrefBox->thaw(); } void CuiAboutConfigTabPage::FillItemSet() { - std::vector< std::shared_ptr< Prop_Impl > >::iterator pIter; - for( pIter = m_vectorOfModified.begin() ; pIter != m_vectorOfModified.end(); ++pIter ) + std::vector>::iterator pIter; + for (pIter = m_vectorOfModified.begin(); pIter != m_vectorOfModified.end(); ++pIter) { - Reference< XNameAccess > xUpdateAccess = getConfigAccess( (*pIter)->Name , true ); - Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW ); + Reference xUpdateAccess = getConfigAccess((*pIter)->Name, true); + Reference xNameReplace(xUpdateAccess, UNO_QUERY_THROW); - xNameReplace->replaceByName( (*pIter)->Property, (*pIter)->Value ); + xNameReplace->replaceByName((*pIter)->Property, (*pIter)->Value); - Reference< util::XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY_THROW ); + Reference xChangesBatch(xUpdateAccess, UNO_QUERY_THROW); xChangesBatch->commitChanges(); } } -void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, const weld::TreeIter* pParentEntry, - int lineage, bool bLoadAll) +void CuiAboutConfigTabPage::FillItems(const Reference& xNameAccess, + const weld::TreeIter* pParentEntry, int lineage, + bool bLoadAll) { - OUString sPath = Reference< XHierarchicalName >( - xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName(); - const uno::Sequence< OUString > seqItems = xNameAccess->getElementNames(); - for( const OUString& item : seqItems ) + OUString sPath + = Reference(xNameAccess, uno::UNO_QUERY_THROW)->getHierarchicalName(); + const uno::Sequence seqItems = xNameAccess->getElementNames(); + for (const OUString& item : seqItems) { - Any aNode = xNameAccess->getByName( item ); + Any aNode = xNameAccess->getByName(item); bool bNotLeaf = false; - Reference< XNameAccess > xNextNameAccess; + Reference xNextNameAccess; try { xNextNameAccess.set(aNode, uno::UNO_QUERY); @@ -265,20 +266,22 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } catch (const RuntimeException&) { - TOOLS_WARN_EXCEPTION( "cui.options", "CuiAboutConfigTabPage"); + TOOLS_WARN_EXCEPTION("cui.options", "CuiAboutConfigTabPage"); } if (bNotLeaf) { - if(bLoadAll) + if (bLoadAll) FillItems(xNextNameAccess, nullptr, lineage + 1, true); else { // not leaf node - m_vectorUserData.push_back(std::make_unique(xNextNameAccess, lineage + 1)); + m_vectorUserData.push_back( + std::make_unique(xNextNameAccess, lineage + 1)); OUString sId(weld::toId(m_vectorUserData.back().get())); - m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, true, m_xScratchIter.get()); + m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, true, + m_xScratchIter.get()); // Necessary, without this the selection line will be truncated. m_xPrefBox->set_text(*m_xScratchIter, "", 1); m_xPrefBox->set_text(*m_xScratchIter, "", 2); @@ -291,12 +294,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces // leaf node OUString sPropertyName = item; auto it = std::find_if(m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), - [&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == sPath - && rEntry.sStatus == sPropertyName; - } - ); + [&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == sPath + && rEntry.sStatus == sPropertyName; + }); css::uno::Reference m_xReadWriteAccess; m_xReadWriteAccess = css::configuration::ReadWriteAccess::create( @@ -307,7 +308,8 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces try { aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(sFullPath); - bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; } + bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + } catch (css::beans::UnknownPropertyException) { SAL_WARN("cui.options", "unknown property: " << sFullPath); @@ -318,8 +320,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces OUString sDynamicType = aNode.getValueTypeName(); try { - Reference xDocumentation(xNameAccess, UNO_QUERY_THROW); - sTooltip = xDocumentation->getDescriptionByHierarchicalName(sPath + "/" + sPropertyName); + Reference xDocumentation(xNameAccess, + UNO_QUERY_THROW); + sTooltip + = xDocumentation->getDescriptionByHierarchicalName(sPath + "/" + sPropertyName); sType = xDocumentation->getTypeByHierarchicalName(sFullPath); } catch (css::container::NoSuchElementException) @@ -379,7 +383,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces sValue = OUString::number(aNode.get()); sType = "short"; } - else if (sType == "xs:int" ) + else if (sType == "xs:int") { sValue = OUString::number(aNode.get()); sType = "int"; @@ -389,7 +393,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces sValue = OUString::number(aNode.get()); sType = "long"; } - else if (sType == "xs:double" ) + else if (sType == "xs:double") { sValue = OUString::number(aNode.get()); sType = "double"; @@ -413,7 +417,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } sType = "hexBinary"; } - else if (sType == "oor:boolean-list" ) + else if (sType == "oor:boolean-list") { uno::Sequence seq = aNode.get>(); for (sal_Int32 j = 0; j != seq.getLength(); ++j) @@ -426,7 +430,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } sType = "boolean-list"; } - else if (sType == "oor:short-list" ) + else if (sType == "oor:short-list") { uno::Sequence seq = aNode.get>(); for (sal_Int32 j = 0; j != seq.getLength(); ++j) @@ -491,7 +495,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } sType = "string-list"; } - else if (sType == "oor:hexBinary-list" ) + else if (sType == "oor:hexBinary-list") { const uno::Sequence> seq = aNode.get>>(); @@ -522,50 +526,50 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces //Short name int index = 0; - for(int j = 1; j < lineage; ++j) + for (int j = 1; j < lineage; ++j) index = sPath.indexOf("/", index + 1); - InsertEntry(sPath, sPath.copy(index + 1), item, sType, sValue.makeStringAndClear(), sTooltip, - pParentEntry, !bLoadAll, bReadOnly); + InsertEntry(sPath, sPath.copy(index + 1), item, sType, sValue.makeStringAndClear(), + sTooltip, pParentEntry, !bLoadAll, bReadOnly); } } } -Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, bool bUpdate ) +Reference CuiAboutConfigTabPage::getConfigAccess(const OUString& sNodePath, + bool bUpdate) { - uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference xContext(::comphelper::getProcessComponentContext()); - uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - css::configuration::theDefaultProvider::get( xContext ) ); + uno::Reference xConfigProvider( + css::configuration::theDefaultProvider::get(xContext)); beans::NamedValue aProperty; aProperty.Name = "nodepath"; aProperty.Value <<= sNodePath; - uno::Sequence< uno::Any > aArgumentList{ uno::Any(aProperty) }; + uno::Sequence aArgumentList{ uno::Any(aProperty) }; OUString sAccessString; - if( bUpdate ) + if (bUpdate) sAccessString = "com.sun.star.configuration.ConfigurationUpdateAccess"; else sAccessString = "com.sun.star.configuration.ConfigurationAccess"; - uno::Reference< container::XNameAccess > xNameAccess( - xConfigProvider->createInstanceWithArguments( - sAccessString, aArgumentList ), - uno::UNO_QUERY_THROW ); + uno::Reference xNameAccess( + xConfigProvider->createInstanceWithArguments(sAccessString, aArgumentList), + uno::UNO_QUERY_THROW); return xNameAccess; } -void CuiAboutConfigTabPage::AddToModifiedVector( const std::shared_ptr< Prop_Impl >& rProp ) +void CuiAboutConfigTabPage::AddToModifiedVector(const std::shared_ptr& rProp) { bool isModifiedBefore = false; //Check if value modified before - for(std::shared_ptr & nInd : m_vectorOfModified) + for (std::shared_ptr& nInd : m_vectorOfModified) { - if( rProp->Name == nInd->Name && rProp->Property == nInd->Property ) + if (rProp->Name == nInd->Name && rProp->Property == nInd->Property) { //property modified before. Assign reference to the modified value //do your changes on this object. They will be saved later. @@ -575,30 +579,28 @@ void CuiAboutConfigTabPage::AddToModifiedVector( const std::shared_ptr< Prop_Imp } } - if( !isModifiedBefore ) - m_vectorOfModified.push_back( rProp ); + if (!isModifiedBefore) + m_vectorOfModified.push_back(rProp); //property is not modified before } -std::vector< OUString > CuiAboutConfigTabPage::commaStringToSequence( std::u16string_view rCommaSepString ) +std::vector +CuiAboutConfigTabPage::commaStringToSequence(std::u16string_view rCommaSepString) { std::vector tempVector; sal_Int32 index = 0; do { - OUString word( o3tl::getToken(rCommaSepString, 0, u',', index) ); + OUString word(o3tl::getToken(rCommaSepString, 0, u',', index)); word = word.trim(); - if( !word.isEmpty()) + if (!word.isEmpty()) tempVector.push_back(word); - }while( index >= 0 ); + } while (index >= 0); return tempVector; } -IMPL_LINK_NOARG( CuiAboutConfigTabPage, ResetBtnHdl_Impl, weld::Button&, void ) -{ - Reset(); -} +IMPL_LINK_NOARG(CuiAboutConfigTabPage, ResetBtnHdl_Impl, weld::Button&, void) { Reset(); } IMPL_LINK_NOARG(CuiAboutConfigTabPage, DoubleClickHdl_Impl, weld::TreeView&, bool) { @@ -606,12 +608,12 @@ IMPL_LINK_NOARG(CuiAboutConfigTabPage, DoubleClickHdl_Impl, weld::TreeView&, boo return true; } -IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) +IMPL_LINK_NOARG(CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void) { if (!m_xPrefBox->get_selected(m_xScratchIter.get())) return; - UserData *pUserData = weld::fromId(m_xPrefBox->get_id(*m_xScratchIter)); + UserData* pUserData = weld::fromId(m_xPrefBox->get_id(*m_xScratchIter)); if (!pUserData || !pUserData->bIsPropertyPath || pUserData->bIsReadOnly) return; @@ -620,16 +622,17 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) OUString sPropertyType = m_xPrefBox->get_text(*m_xScratchIter, 2); OUString sPropertyValue = m_xPrefBox->get_text(*m_xScratchIter, 3); - auto pProperty = std::make_shared( pUserData->sPropertyPath, sPropertyName, Any( sPropertyValue ) ); + auto pProperty + = std::make_shared(pUserData->sPropertyPath, sPropertyName, Any(sPropertyValue)); bool bSaveChanges = false; bool bOpenDialog = true; OUString sDialogValue; - if( sPropertyType == "boolean" ) + if (sPropertyType == "boolean") { bool bValue; - if( sPropertyValue == "true" ) + if (sPropertyValue == "true") { sDialogValue = "false"; bValue = false; @@ -652,7 +655,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) try { - if( bOpenDialog ) + if (bOpenDialog) { if (sPropertyType == "short" || sPropertyType == "int" || sPropertyType == "long") { @@ -683,9 +686,10 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) sDialogValue = OUString::number(nNewValue); } } - else if( sPropertyType == "double") + else if (sPropertyType == "double") { - SvxDecimalNumberDialog aNumberDialog(m_pParent, sPropertyName, sDialogValue.toDouble()); + SvxDecimalNumberDialog aNumberDialog(m_pParent, sPropertyName, + sDialogValue.toDouble()); if (aNumberDialog.run() == RET_OK) { double fNewValue = aNumberDialog.GetNumber(); @@ -694,93 +698,93 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) sDialogValue = OUString::number(fNewValue); } } - else if( sPropertyType == "string" ) + else if (sPropertyType == "string") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); pProperty->Value <<= sDialogValue; bSaveChanges = true; } } - else if( sPropertyType == "short-list" ) + else if (sPropertyType == "short-list") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); //create string sequence from comma separated string //uno::Sequence< OUString > seqStr; - std::vector< OUString > seqStr = commaStringToSequence( sDialogValue ); + std::vector seqStr = commaStringToSequence(sDialogValue); //create appropriate sequence with same size as string sequence - uno::Sequence< sal_Int16 > seqShort( seqStr.size() ); + uno::Sequence seqShort(seqStr.size()); //convert all strings to appropriate type - std::transform(seqStr.begin(), seqStr.end(), seqShort.getArray(), - [](const auto& str) - { return static_cast(str.toInt32()); }); + std::transform( + seqStr.begin(), seqStr.end(), seqShort.getArray(), + [](const auto& str) { return static_cast(str.toInt32()); }); pProperty->Value <<= seqShort; bSaveChanges = true; } - } - else if( sPropertyType == "int-list" ) + else if (sPropertyType == "int-list") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); - std::vector< OUString > seqStrLong = commaStringToSequence( sDialogValue ); + std::vector seqStrLong = commaStringToSequence(sDialogValue); - uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() ); + uno::Sequence seqLong(seqStrLong.size()); std::transform(seqStrLong.begin(), seqStrLong.end(), seqLong.getArray(), - [](const auto& str) { return str.toInt32(); }); + [](const auto& str) { return str.toInt32(); }); pProperty->Value <<= seqLong; bSaveChanges = true; } } - else if( sPropertyType == "long-list" ) + else if (sPropertyType == "long-list") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); - std::vector< OUString > seqStrHyper = commaStringToSequence( sDialogValue ); - uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() ); + std::vector seqStrHyper = commaStringToSequence(sDialogValue); + uno::Sequence seqHyper(seqStrHyper.size()); std::transform(seqStrHyper.begin(), seqStrHyper.end(), seqHyper.getArray(), - [](const auto& str) { return str.toInt64(); }); + [](const auto& str) { return str.toInt64(); }); pProperty->Value <<= seqHyper; bSaveChanges = true; } } - else if( sPropertyType == "double-list" ) + else if (sPropertyType == "double-list") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); - std::vector< OUString > seqStrDoub = commaStringToSequence( sDialogValue ); - uno::Sequence< double > seqDoub( seqStrDoub.size() ); + std::vector seqStrDoub = commaStringToSequence(sDialogValue); + uno::Sequence seqDoub(seqStrDoub.size()); std::transform(seqStrDoub.begin(), seqStrDoub.end(), seqDoub.getArray(), - [](const auto& str) { return str.toDouble(); }); + [](const auto& str) { return str.toDouble(); }); pProperty->Value <<= seqDoub; bSaveChanges = true; } } - else if( sPropertyType == "string-list" ) + else if (sPropertyType == "string-list") { SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName); - aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, ValidNameHdl ) ); - if (aNameDialog.run() == RET_OK ) + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { sDialogValue = aNameDialog.GetName(); - pProperty->Value <<= comphelper::containerToSequence( commaStringToSequence( sDialogValue )); + pProperty->Value + <<= comphelper::containerToSequence(commaStringToSequence(sDialogValue)); bSaveChanges = true; } } @@ -788,33 +792,30 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) throw uno::Exception("unknown property type " + sPropertyType, nullptr); } - if(bSaveChanges) + if (bSaveChanges) { - AddToModifiedVector( pProperty ); + AddToModifiedVector(pProperty); //update listbox value. m_xPrefBox->set_text(*m_xScratchIter, sPropertyType, 2); m_xPrefBox->set_text(*m_xScratchIter, sDialogValue, 3); //update m_prefBoxEntries - auto it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); + auto it = std::find_if( + m_prefBoxEntries.begin(), m_prefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + }); if (it != m_prefBoxEntries.end()) { it->sValue = sDialogValue; auto modifiedIt = std::find_if( - m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); + m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + }); if (modifiedIt != m_modifiedPrefBoxEntries.end()) { @@ -827,12 +828,12 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) } } } - catch( uno::Exception& ) + catch (uno::Exception&) { } } -IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void) +IMPL_LINK_NOARG(CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void) { weld::WaitObject aWait(m_xDialog.get()); @@ -846,18 +847,18 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void) if (m_xSearchEdit->get_text().isEmpty()) { m_xPrefBox->clear(); - Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", false ); - FillItems( xConfigAccess ); + Reference xConfigAccess = getConfigAccess("/", false); + FillItems(xConfigAccess); } else { m_options.searchString = m_xSearchEdit->get_text(); - utl::TextSearch textSearch( m_options ); + utl::TextSearch textSearch(m_options); for (auto const& it : m_prefBoxEntries) { sal_Int32 endPos, startPos = 0; - for(size_t i = 0; i < 5; ++i) + for (size_t i = 0; i < 5; ++i) { OUString scrTxt; @@ -905,19 +906,20 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) do { int prevIndex = index; - index = sPath.indexOf("/", index+1); + index = sPath.indexOf("/", index + 1); // deal with no parent case (tdf#107811) if (index < 0) { OUString sId(weld::toId(rEntry.pUserData)); - m_xPrefBox->insert(nullptr, -1, &rEntry.sProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + m_xPrefBox->insert(nullptr, -1, &rEntry.sProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3); m_xPrefBox->set_sensitive(*m_xScratchIter, !rEntry.pUserData->bIsReadOnly); return; } - OUString sParentName = sPath.copy(prevIndex+1, index - prevIndex - 1); + OUString sParentName = sPath.copy(prevIndex + 1, index - prevIndex - 1); bool hasEntry = false; bool bStartOk; @@ -944,7 +946,8 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) if (!hasEntry) { - m_xPrefBox->insert(xGrandParentEntry.get(), -1, &sParentName, nullptr, nullptr, nullptr, false, xParentEntry.get()); + m_xPrefBox->insert(xGrandParentEntry.get(), -1, &sParentName, nullptr, nullptr, nullptr, + false, xParentEntry.get()); //It is needed, without this the selection line will be truncated. m_xPrefBox->set_text(*xParentEntry, "", 1); m_xPrefBox->set_text(*xParentEntry, "", 2); @@ -953,10 +956,11 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) } xGrandParentEntry = m_xPrefBox->make_iterator(xParentEntry.get()); - } while(index < sPath.getLength() - 1); + } while (index < sPath.getLength() - 1); OUString sId(weld::toId(rEntry.pUserData)); - m_xPrefBox->insert(xParentEntry.get(), -1, &rEntry.sProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + m_xPrefBox->insert(xParentEntry.get(), -1, &rEntry.sProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3); @@ -967,7 +971,7 @@ IMPL_LINK(CuiAboutConfigTabPage, ExpandingHdl_Impl, const weld::TreeIter&, rEntr { if (m_xPrefBox->iter_has_child(rEntry)) return true; - UserData *pUserData = weld::fromId(m_xPrefBox->get_id(rEntry)); + UserData* pUserData = weld::fromId(m_xPrefBox->get_id(rEntry)); if (pUserData && !pUserData->bIsPropertyPath) { assert(pUserData->aXNameAccess.is()); diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 136ed0b11e8b..0175ee1301ca 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -11,8 +11,8 @@ #include -#include #include +#include #include #include @@ -41,20 +41,20 @@ private: std::unique_ptr m_xPrefBox; std::unique_ptr m_xScratchIter; - std::vector < std::unique_ptr > m_vectorUserData; + std::vector> m_vectorUserData; std::vector m_modifiedPrefBoxEntries; - std::vector< std::shared_ptr< Prop_Impl > > m_vectorOfModified; + std::vector> m_vectorOfModified; - //for search + //for search i18nutil::SearchOptions2 m_options; std::vector m_prefBoxEntries; bool m_bSorted; weld::Window* m_pParent; - void AddToModifiedVector( const std::shared_ptr< Prop_Impl >& rProp ); - static std::vector< OUString > commaStringToSequence( std::u16string_view rCommaSepString ); + void AddToModifiedVector(const std::shared_ptr& rProp); + static std::vector commaStringToSequence(std::u16string_view rCommaSepString); void InsertEntry(const prefBoxEntry& rEntry); DECL_LINK(QueryTooltip, const weld::TreeIter& rIter, OUString); @@ -67,16 +67,18 @@ private: DECL_STATIC_LINK(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, bool); public: - explicit CuiAboutConfigTabPage(weld::Window* pParent); - virtual ~CuiAboutConfigTabPage() override; - void InsertEntry(const OUString &rPropertyPath, const OUString& rProp, const OUString& rStatus, - const OUString& rType, const OUString& rValue, const OUString& rTooltip, - const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, bool bIsReadOnly); - void Reset(); - void FillItems(const css::uno::Reference& xNameAccess, - const weld::TreeIter* pParentEntry = nullptr, int lineage = 0, bool bLoadAll = false); - static css::uno::Reference< css::container::XNameAccess > getConfigAccess( const OUString& sNodePath, bool bUpdate ); - void FillItemSet(); + explicit CuiAboutConfigTabPage(weld::Window* pParent); + virtual ~CuiAboutConfigTabPage() override; + void InsertEntry(const OUString& rPropertyPath, const OUString& rProp, const OUString& rStatus, + const OUString& rType, const OUString& rValue, const OUString& rTooltip, + const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, bool bIsReadOnly); + void Reset(); + void FillItems(const css::uno::Reference& xNameAccess, + const weld::TreeIter* pParentEntry = nullptr, int lineage = 0, + bool bLoadAll = false); + static css::uno::Reference + getConfigAccess(const OUString& sNodePath, bool bUpdate); + void FillItemSet(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit