From 0a4ad544daaec4f773480e6301238c7f6958a9ab Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 6 Nov 2017 13:30:01 +0900 Subject: TSCP: put more duplicated methods to common MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic49e0dad1351684db3372214604d12b48d0be907 Reviewed-on: https://gerrit.libreoffice.org/44337 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- sd/source/ui/view/drviews2.cxx | 59 ++++++------------------------------------ 1 file changed, 8 insertions(+), 51 deletions(-) (limited to 'sd') diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 8a0c20a41889..2095738f62f6 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -192,49 +192,6 @@ namespace sd { namespace { -void lcl_removeAllProperties(uno::Reference const & rxPropertyContainer) -{ - uno::Reference xPropertySet(rxPropertyContainer, uno::UNO_QUERY); - uno::Sequence aProperties = xPropertySet->getPropertySetInfo()->getProperties(); - - for (const beans::Property& rProperty : aProperties) - { - rxPropertyContainer->removeProperty(rProperty.Name); - } -} - -bool lcl_containsProperty(const uno::Sequence & rProperties, const OUString& rName) -{ - return std::find_if(rProperties.begin(), rProperties.end(), [&](const beans::Property& rProperty) - { - return rProperty.Name == rName; - }) != rProperties.end(); -} - -OUString lcl_getProperty(uno::Reference const & rxPropertyContainer, const OUString& rName) -{ - uno::Reference xPropertySet(rxPropertyContainer, uno::UNO_QUERY); - return xPropertySet->getPropertyValue(rName).get(); -} - -bool addOrInsertDocumentProperty(uno::Reference const & rxPropertyContainer, OUString const & rsKey, OUString const & rsValue) -{ - uno::Reference xPropertySet(rxPropertyContainer, uno::UNO_QUERY); - - try - { - if (lcl_containsProperty(xPropertySet->getPropertySetInfo()->getProperties(), rsKey)) - xPropertySet->setPropertyValue(rsKey, uno::makeAny(rsValue)); - else - rxPropertyContainer->addProperty(rsKey, beans::PropertyAttribute::REMOVABLE, uno::makeAny(rsValue)); - } - catch (const uno::Exception& /*rException*/) - { - return false; - } - return true; -} - const SvxFieldItem* findField(editeng::Section const & rSection) { for (SfxPoolItem const * pPool: rSection.maAttributes) @@ -321,22 +278,22 @@ private: OUString aKey = pCustomPropertyField->GetName(); if (aKeyCreator.isMarkingTextKey(aKey)) { - OUString aValue = lcl_getProperty(xPropertyContainer, aKey); + OUString aValue = svx::classification::getProperty(xPropertyContainer, aKey); m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); } else if (aKeyCreator.isCategoryNameKey(aKey) || aKeyCreator.isCategoryIdentifierKey(aKey)) { - OUString aValue = lcl_getProperty(xPropertyContainer, aKey); + OUString aValue = svx::classification::getProperty(xPropertyContainer, aKey); m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank }); } else if (aKeyCreator.isMarkingKey(aKey)) { - OUString aValue = lcl_getProperty(xPropertyContainer, aKey); + OUString aValue = svx::classification::getProperty(xPropertyContainer, aKey); m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank }); } else if (aKeyCreator.isIntellectualPropertyPartKey(aKey)) { - OUString aValue = lcl_getProperty(xPropertyContainer, aKey); + OUString aValue = svx::classification::getProperty(xPropertyContainer, aKey); m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank }); } } @@ -463,7 +420,7 @@ public: uno::Reference xPropertyContainer = xDocumentProperties->getUserDefinedProperties(); // Clear properties - lcl_removeAllProperties(xPropertyContainer); + svx::classification::removeAllProperties(xPropertyContainer); SfxClassificationHelper aHelper(xDocumentProperties); @@ -497,7 +454,7 @@ public: case svx::ClassificationType::TEXT: { OUString sKey = aKeyCreator.makeNumberedMarkingTextKey(); - addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); + svx::classification::addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); } break; @@ -512,7 +469,7 @@ public: case svx::ClassificationType::MARKING: { OUString sKey = aKeyCreator.makeMarkingKey(); - addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); + svx::classification::addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); } break; @@ -520,7 +477,7 @@ public: case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART: { OUString sKey = aKeyCreator.makeIntellectualPropertyPartKey(); - addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); + svx::classification::addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName); pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); } break; -- cgit