sw/inc/SwStyleNameMapper.hxx | 23 ++-- sw/inc/istyleaccess.hxx | 3 sw/inc/names.hxx | 35 ++++++ sw/inc/unocrsrhelper.hxx | 3 sw/inc/unosett.hxx | 5 sw/source/core/doc/DocumentStylePoolManager.cxx | 3 sw/source/core/doc/SwStyleNameMapper.cxx | 73 ++++++++----- sw/source/core/doc/swstylemanager.cxx | 7 - sw/source/core/doc/tblafmt.cxx | 5 sw/source/core/docnode/ndnotxt.cxx | 5 sw/source/core/docnode/node.cxx | 13 +- sw/source/core/edit/edfcol.cxx | 5 sw/source/core/fields/expfld.cxx | 5 sw/source/core/fields/reffld.cxx | 11 +- sw/source/core/fields/textapi.cxx | 5 sw/source/core/inc/unofield.hxx | 3 sw/source/core/layout/atrfrm.cxx | 5 sw/source/core/para/paratr.cxx | 11 +- sw/source/core/text/EnhancedPDFExportHelper.cxx | 29 ++--- sw/source/core/text/inftxt.cxx | 3 sw/source/core/txtnode/fmtatr2.cxx | 25 ++-- sw/source/core/txtnode/ndtxt.cxx | 7 - sw/source/core/unocore/SwXTextDefaults.cxx | 3 sw/source/core/unocore/unocrsrhelper.cxx | 15 +- sw/source/core/unocore/unofield.cxx | 19 +-- sw/source/core/unocore/unoframe.cxx | 23 ++-- sw/source/core/unocore/unoidx.cxx | 61 +++++------ sw/source/core/unocore/unoobj.cxx | 11 +- sw/source/core/unocore/unoparagraph.cxx | 3 sw/source/core/unocore/unosett.cxx | 81 ++++++++------- sw/source/core/unocore/unostyle.cxx | 110 ++++++++++----------- sw/source/core/unocore/unotbl.cxx | 36 +++--- sw/source/filter/html/htmltab.cxx | 3 sw/source/filter/ww8/ww8par5.cxx | 5 sw/source/filter/xml/swxml.cxx | 7 - sw/source/filter/xml/xmlfmt.cxx | 14 +- sw/source/filter/xml/xmlfmte.cxx | 5 sw/source/filter/xml/xmltble.cxx | 5 sw/source/filter/xml/xmltbli.cxx | 3 sw/source/ui/chrdlg/break.cxx | 5 sw/source/ui/frmdlg/cption.cxx | 3 sw/source/ui/index/cntex.cxx | 5 sw/source/ui/index/cnttab.cxx | 7 - sw/source/ui/misc/docfnote.cxx | 3 sw/source/ui/misc/outline.cxx | 8 - sw/source/ui/table/tabledlg.cxx | 3 sw/source/uibase/app/docst.cxx | 5 sw/source/uibase/app/docstyle.cxx | 15 +- sw/source/uibase/config/StoredChapterNumbering.cxx | 3 sw/source/uibase/docvw/edtwin2.cxx | 5 sw/source/uibase/uno/unotxvw.cxx | 7 - 51 files changed, 440 insertions(+), 317 deletions(-)
New commits: commit 79d6de8f878fd4fce27557739cbc37431c465e2a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 17 13:42:30 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 20 12:08:36 2025 +0100 Make Programmatic Names typesafe by creating a wrapper class, to make it obvious in the code what kind of name we are dealing with. The new class is in sw/inc/names.hxx Change-Id: Ifb3e598d497f098cf1fce71b87c5e0da9f8a7151 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180406 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/inc/SwStyleNameMapper.hxx b/sw/inc/SwStyleNameMapper.hxx index f2403a30e1aa..dbd1ca166243 100644 --- a/sw/inc/SwStyleNameMapper.hxx +++ b/sw/inc/SwStyleNameMapper.hxx @@ -26,6 +26,8 @@ #include <unordered_map> #include <vector> +class ProgName; + /** This class holds all data about the names of styles used in the user * interface (UI names...these are localised into different languages). * These UI names are loaded from the resource files on demand. @@ -77,6 +79,7 @@ class SwStyleNameMapper final friend void InitCore(); friend void FinitCore(); + static void fillProgNameFromId(sal_uInt16 nId, ProgName &rName); static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName); static const OUString& getNameFromId(sal_uInt16 nId, const OUString &rName, bool bProgName); @@ -88,27 +91,27 @@ class SwStyleNameMapper final public: // This gets the UI Name from the programmatic name SAL_WARN_UNUSED_RESULT - static const OUString& GetUIName(const OUString& rName, SwGetPoolIdFromName); - static void FillUIName(const OUString& rName, OUString& rFillName, + static const OUString& GetUIName(const ProgName& rName, SwGetPoolIdFromName); + static void FillUIName(const ProgName& rName, OUString& rFillName, SwGetPoolIdFromName); // Get the programmatic Name from the UI name SAL_WARN_UNUSED_RESULT - static const OUString& GetProgName(const OUString& rName, + static ProgName GetProgName(const OUString& rName, SwGetPoolIdFromName); - static void FillProgName(const OUString& rName, OUString& rFillName, + static void FillProgName(const OUString& rName, ProgName& rFillName, SwGetPoolIdFromName); // This gets the UI Name from the Pool ID SW_DLLPUBLIC static void FillUIName(sal_uInt16 nId, OUString& rFillName); SAL_WARN_UNUSED_RESULT SW_DLLPUBLIC static const OUString& GetUIName(sal_uInt16 nId, - const OUString& rName); + const ProgName& rName); // This gets the programmatic Name from the Pool ID - static void FillProgName(sal_uInt16 nId, OUString& rFillName); + static void FillProgName(sal_uInt16 nId, ProgName& rFillName); SAL_WARN_UNUSED_RESULT - SW_DLLPUBLIC static const OUString& GetProgName(sal_uInt16 nId, + SW_DLLPUBLIC static ProgName GetProgName(sal_uInt16 nId, const OUString& rName); // This gets the PoolId from the UI Name @@ -118,7 +121,7 @@ public: // Get the Pool ID from the programmatic name SAL_WARN_UNUSED_RESULT - SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromProgName(const OUString& rName, + SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromProgName(const ProgName& rName, SwGetPoolIdFromName); // used to convert the 4 special ExtraProg/UINames for @@ -127,10 +130,10 @@ public: // forth and back. // Non-matching names remain unchanged. SAL_WARN_UNUSED_RESULT - SW_DLLPUBLIC static const OUString & GetSpecialExtraProgName( + SW_DLLPUBLIC static ProgName GetSpecialExtraProgName( const OUString& rExtraUIName); SAL_WARN_UNUSED_RESULT - static const OUString & GetSpecialExtraUIName(const OUString& rExtraProgName); + static const OUString & GetSpecialExtraUIName(const ProgName& rExtraProgName); static const std::vector<OUString>& GetTextUINameArray(); static const std::vector<OUString>& GetListsUINameArray(); diff --git a/sw/inc/istyleaccess.hxx b/sw/inc/istyleaccess.hxx index 755f10bf15d8..cc995e01dc3f 100644 --- a/sw/inc/istyleaccess.hxx +++ b/sw/inc/istyleaccess.hxx @@ -24,6 +24,7 @@ #include <vector> class SwAttrSet; +class ProgName; // Management of (automatic) styles class IStyleAccess @@ -44,7 +45,7 @@ public: const OUString* pParentName = nullptr ) = 0; virtual std::shared_ptr<SwAttrSet> getAutomaticStyle( const SwAttrSet& rSet, SwAutoStyleFamily eFamily, - const OUString* pParentName = nullptr ) = 0; + const ProgName* pParentName = nullptr ) = 0; virtual void getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rStyles, SwAutoStyleFamily eFamily ) = 0; /** It's slow to iterate through a stylepool looking for a special name, but if diff --git a/sw/inc/names.hxx b/sw/inc/names.hxx new file mode 100644 index 000000000000..fe15221d2c7a --- /dev/null +++ b/sw/inc/names.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include <rtl/ustring.hxx> +#include <functional> + +/// Thin wrapper around OUString to make visible in code when we are dealing with a UIName vs a Programmatic Name +class ProgName +{ +public: + ProgName() {} + constexpr explicit ProgName(const OUString& s) + : m_s(s) + { + } + const OUString& toString() const { return m_s; } + bool isEmpty() const { return m_s.isEmpty(); } + bool operator==(const ProgName& s) const = default; + bool operator==(const OUString& s) const { return m_s == s; } + bool operator==(std::u16string_view s) const { return m_s == s; } + bool operator<(const ProgName& s) const { return m_s < s.m_s; } + bool operator>(const ProgName& s) const { return m_s > s.m_s; } + +private: + OUString m_s; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index a510216641f8..e9fea3d32c9c 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -39,6 +39,7 @@ class SwFormatColl; struct SwSortOptions; class SwDoc; class SwRootFrame; +class ProgName; namespace sw::mark { class MarkBase; } @@ -84,7 +85,7 @@ namespace SwUnoCursorHelper , css::beans::PropertyState& eState , const SwTextNode* pNode = nullptr ); - void GetCurPageStyle(SwPaM const & rPaM, OUString &rString); + void GetCurPageStyle(SwPaM const & rPaM, ProgName &rString); inline bool IsStartOfPara(SwPaM& rUnoCursor) { return rUnoCursor.GetPoint()->GetContentIndex() == 0;} diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx index f280e78c5a6d..1f25fb666282 100644 --- a/sw/inc/unosett.hxx +++ b/sw/inc/unosett.hxx @@ -38,6 +38,7 @@ class SwDocShell; class SwNumRule; class SwNumFormat; class SfxItemPropertySet; +class ProgName; namespace com::sun::star::beans { struct PropertyValue; } class SwXFootnoteProperties final : public cppu::WeakImplHelper @@ -206,7 +207,7 @@ public: static css::uno::Sequence<css::beans::PropertyValue> GetPropertiesForNumFormat( const SwNumFormat& rFormat, OUString const& rCharFormatName, - OUString const* pHeadingStyleName, OUString const & referer); + ProgName const* pHeadingStyleName, OUString const & referer); static void SetPropertiesToNumFormat( SwNumFormat & aFormat, OUString & rCharStyleName, @@ -221,7 +222,7 @@ private: css::uno::Any GetNumberingRuleByIndex(const SwNumRule& rNumRule, sal_Int32 nIndex, const OUString& rPropName) const; static css::uno::Any GetPropertyForNumFormat( const SwNumFormat& rFormat, OUString const& rCharFormatName, - OUString const* pHeadingStyleName, OUString const & referer, OUString const & rPropName); + ProgName const* pHeadingStyleName, OUString const & referer, OUString const & rPropName); }; class SwXChapterNumbering final : public SwXNumberingRules diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 0830799e3c1e..e6d73b90db65 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -71,6 +71,7 @@ #include <unotools/syslocale.hxx> #include <i18nlangtag/languagetag.hxx> #include <comphelper/lok.hxx> +#include <names.hxx> using namespace ::editeng; using namespace ::com::sun::star; @@ -604,7 +605,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, // in online we can have multiple languages, use translated name if (comphelper::LibreOfficeKit::isActive()) { - OUString aName = SwStyleNameMapper::GetUIName(nId, OUString()); + OUString aName = SwStyleNameMapper::GetUIName(nId, ProgName()); if (!aName.isEmpty()) pNewColl->SetFormatName(aName); } diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx b/sw/source/core/doc/SwStyleNameMapper.cxx index b89dec6d6e6f..def6c49c552d 100644 --- a/sw/source/core/doc/SwStyleNameMapper.cxx +++ b/sw/source/core/doc/SwStyleNameMapper.cxx @@ -25,6 +25,7 @@ #include <i18nlangtag/languagetag.hxx> #include <o3tl/string_view.hxx> #include <map> +#include <names.hxx> #ifdef _NEED_TO_DEBUG_MAPPING #include <stdlib.h> @@ -76,6 +77,14 @@ void lcl_CheckSuffixAndDelete(OUString & rString) } } +void lcl_CheckSuffixAndDelete(ProgName & rString) +{ + if (lcl_SuffixIsUser(rString.toString())) + { + rString = ProgName(rString.toString().copy(0, rString.toString().getLength() - 7)); + } +} + NameToIdHash HashFromRange(sal_uInt16 nAcc) { return NameToIdHash(nAcc); } template <typename... Rest> NameToIdHash HashFromRange(sal_uInt16 nAcc, sal_uInt16 nBegin, sal_uInt16 nEnd, @@ -234,33 +243,33 @@ const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlag } // This gets the UI name from the programmatic name -const OUString& SwStyleNameMapper::GetUIName(const OUString& rName, +const OUString& SwStyleNameMapper::GetUIName(const ProgName& rName, SwGetPoolIdFromName const eFlags) { sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags ); - return nId != USHRT_MAX ? GetUIName( nId, rName ) : rName; + return nId != USHRT_MAX ? GetUIName( nId, rName ) : rName.toString(); } // Get the programmatic name from the UI name -const OUString& SwStyleNameMapper::GetProgName( +ProgName SwStyleNameMapper::GetProgName( const OUString& rName, SwGetPoolIdFromName const eFlags) { sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags ); - return nId != USHRT_MAX ? GetProgName( nId, rName ) : rName; + return nId != USHRT_MAX ? GetProgName( nId, rName ) : ProgName(rName); } // Get the programmatic name from the UI name in rName and put it into rFillName void SwStyleNameMapper::FillProgName( - const OUString& rName, OUString& rFillName, + const OUString& rName, ProgName& rFillName, SwGetPoolIdFromName const eFlags) { sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags ); if ( nId == USHRT_MAX ) { // rName isn't in our UI name table...check if it's in the programmatic one - nId = GetPoolIdFromProgName ( rName, eFlags ); + nId = GetPoolIdFromProgName ( ProgName(rName), eFlags ); - rFillName = rName; + rFillName = ProgName(rName); if (nId == USHRT_MAX ) { if (eFlags != SwGetPoolIdFromName::TabStyle) @@ -272,42 +281,42 @@ void SwStyleNameMapper::FillProgName( { // It isn't ...make sure the suffix isn't already " (user)"...if it is, // we need to add another one - if (lcl_SuffixIsUser(rFillName)) - rFillName += " (user)"; + if (lcl_SuffixIsUser(rFillName.toString())) + rFillName = ProgName(rFillName.toString() + " (user)"); } } else { // It's in the programmatic name table...append suffix - rFillName += " (user)"; + rFillName = ProgName(rFillName.toString() + " (user)"); } } else { // If we aren't trying to disambiguate, then just do a normal fill - fillNameFromId(nId, rFillName, true); + fillProgNameFromId(nId, rFillName); } if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == SwResId(STR_POOLCHR_STANDARD)) - rFillName = "Standard"; + rFillName = ProgName("Standard"); } // Get the UI name from the programmatic name in rName and put it into rFillName void SwStyleNameMapper::FillUIName( - const OUString& rName, OUString& rFillName, + const ProgName& rName, OUString& rFillName, SwGetPoolIdFromName const eFlags) { - OUString aName = rName; + ProgName aName = rName; if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == "Standard") - aName = SwResId(STR_POOLCHR_STANDARD); + aName = ProgName(SwResId(STR_POOLCHR_STANDARD)); sal_uInt16 nId = GetPoolIdFromProgName ( aName, eFlags ); if ( nId == USHRT_MAX ) { - rFillName = aName; + rFillName = aName.toString(); // TabStyle: unfortunately ODF documents with UIName table styles exist if (eFlags == SwGetPoolIdFromName::TabStyle || // see testTdf129568ui - GetPoolIdFromUIName(aName, eFlags) == USHRT_MAX) + GetPoolIdFromUIName(aName.toString(), eFlags) == USHRT_MAX) { // aName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it lcl_CheckSuffixAndDelete(rFillName); @@ -424,6 +433,12 @@ void SwStyleNameMapper::fillNameFromId( rFillName = getNameFromId(nId, rFillName, bProgName); } +void SwStyleNameMapper::fillProgNameFromId( + sal_uInt16 const nId, ProgName& rFillName) +{ + rFillName = ProgName(getNameFromId(nId, rFillName.toString(), /*bProgName*/true)); +} + // Get the UI name from the pool ID void SwStyleNameMapper::FillUIName(sal_uInt16 const nId, OUString& rFillName) { @@ -432,22 +447,22 @@ void SwStyleNameMapper::FillUIName(sal_uInt16 const nId, OUString& rFillName) // Get the UI name from the pool ID const OUString& SwStyleNameMapper::GetUIName( - sal_uInt16 const nId, const OUString& rName) + sal_uInt16 const nId, const ProgName& rName) { - return getNameFromId(nId, rName, false); + return getNameFromId(nId, rName.toString(), false); } // Get the programmatic name from the pool ID -void SwStyleNameMapper::FillProgName(sal_uInt16 nId, OUString& rFillName) +void SwStyleNameMapper::FillProgName(sal_uInt16 nId, ProgName& rFillName) { - fillNameFromId(nId, rFillName, true); + fillProgNameFromId(nId, rFillName); } // Get the programmatic name from the pool ID -const OUString& +ProgName SwStyleNameMapper::GetProgName(sal_uInt16 const nId, const OUString& rName) { - return getNameFromId(nId, rName, true); + return ProgName(getNameFromId(nId, rName, true)); } // This gets the PoolId from the UI Name @@ -461,10 +476,10 @@ sal_uInt16 SwStyleNameMapper::GetPoolIdFromUIName( // Get the Pool ID from the programmatic name sal_uInt16 SwStyleNameMapper::GetPoolIdFromProgName( - const OUString& rName, SwGetPoolIdFromName const eFlags) + const ProgName& rName, SwGetPoolIdFromName const eFlags) { const NameToIdHash & rHashMap = getHashTable ( eFlags, true ); - NameToIdHash::const_iterator aIter = rHashMap.find(rName); + NameToIdHash::const_iterator aIter = rHashMap.find(rName.toString()); return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX; } @@ -781,16 +796,16 @@ const std::vector<OUString>& SwStyleNameMapper::GetCellStyleProgNameArray() return s_aCellStyleProgNameArray; } -const OUString & +ProgName SwStyleNameMapper::GetSpecialExtraProgName(const OUString& rExtraUIName) { - return lcl_GetSpecialExtraName( rExtraUIName, true ); + return ProgName(lcl_GetSpecialExtraName( rExtraUIName, true )); } const OUString & -SwStyleNameMapper::GetSpecialExtraUIName(const OUString& rExtraProgName) +SwStyleNameMapper::GetSpecialExtraUIName(const ProgName& rExtraProgName) { - return lcl_GetSpecialExtraName( rExtraProgName, false ); + return lcl_GetSpecialExtraName( rExtraProgName.toString(), false ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/swstylemanager.cxx b/sw/source/core/doc/swstylemanager.cxx index 0deaeec3e78d..cdca3dc34147 100644 --- a/sw/source/core/doc/swstylemanager.cxx +++ b/sw/source/core/doc/swstylemanager.cxx @@ -23,6 +23,7 @@ #include <swatrset.hxx> #include <unordered_map> #include <osl/diagnose.h> +#include <names.hxx> typedef std::unordered_map< OUString, std::shared_ptr<SfxItemSet> > SwStyleNameCache; @@ -67,7 +68,7 @@ public: const OUString* pParentName = nullptr ) override; virtual std::shared_ptr<SwAttrSet> getAutomaticStyle( const SwAttrSet& rSet, IStyleAccess::SwAutoStyleFamily eFamily, - const OUString* pParentName = nullptr ) override; + const ProgName* pParentName = nullptr ) override; virtual std::shared_ptr<SfxItemSet> getByName( const OUString& rName, IStyleAccess::SwAutoStyleFamily eFamily ) override; virtual void getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rStyles, @@ -102,11 +103,11 @@ std::shared_ptr<SfxItemSet> SwStyleManager::getAutomaticStyle( const SfxItemSet& std::shared_ptr<SwAttrSet> SwStyleManager::getAutomaticStyle( const SwAttrSet& rSet, IStyleAccess::SwAutoStyleFamily eFamily, - const OUString* pParentName ) + const ProgName* pParentName ) { StylePool& rAutoPool = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? m_aAutoCharPool : m_aAutoParaPool; - std::shared_ptr<SfxItemSet> pItemSet = rAutoPool.insertItemSet( rSet, pParentName ); + std::shared_ptr<SfxItemSet> pItemSet = rAutoPool.insertItemSet( rSet, pParentName ? &pParentName->toString() : nullptr ); std::shared_ptr<SwAttrSet> pAttrSet = std::dynamic_pointer_cast<SwAttrSet>(pItemSet); assert(bool(pItemSet) == bool(pAttrSet) && "types do not match"); return pAttrSet; diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index b73e195a6bbc..3e0e68d25940 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -63,6 +63,7 @@ #include <svx/rotmodit.hxx> #include <legacyitem.hxx> #include <unostyle.hxx> +#include <names.hxx> #include <memory> #include <utility> @@ -774,7 +775,7 @@ bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions ) // start from 3d because default is added via constructor if( m_nStrResId < RES_POOLTABLESTYLE_END - RES_POOLTABLESTYLE_3D ) { - m_aName = SwStyleNameMapper::GetUIName(RES_POOLTABLESTYLE_3D + m_nStrResId, m_aName); + m_aName = SwStyleNameMapper::GetUIName(RES_POOLTABLESTYLE_3D + m_nStrResId, ProgName(m_aName)); } else m_nStrResId = USHRT_MAX; @@ -1027,7 +1028,7 @@ SwTableAutoFormatTable::SwTableAutoFormatTable() : m_pImpl(new Impl) { std::unique_ptr<SwTableAutoFormat> pNew(new SwTableAutoFormat( - SwStyleNameMapper::GetUIName(RES_POOLTABLESTYLE_DEFAULT, OUString()))); + SwStyleNameMapper::GetUIName(RES_POOLTABLESTYLE_DEFAULT, ProgName()))); sal_uInt8 i; diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx index 0fdb56751023..1ca38f198b0c 100644 --- a/sw/source/core/docnode/ndnotxt.cxx +++ b/sw/source/core/docnode/ndnotxt.cxx @@ -33,6 +33,7 @@ #include <SwStyleNameMapper.hxx> #include <frmfmt.hxx> +#include <names.hxx> SwNoTextNode::SwNoTextNode( SwNode& rWhere, const SwNodeType nNdType, @@ -61,9 +62,9 @@ void SwNoTextNode::NewAttrSet( SwAttrPool& rPool ) // put names of parent style and conditional style: const SwFormatColl* pFormatColl = GetFormatColl(); - OUString sVal; + ProgName sVal; SwStyleNameMapper::FillProgName( pFormatColl->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); - SfxStringItem aFormatColl( RES_FRMATR_STYLE_NAME, sVal ); + SfxStringItem aFormatColl( RES_FRMATR_STYLE_NAME, sVal.toString() ); aNewAttrSet.Put( aFormatColl ); aNewAttrSet.SetParent( &GetFormatColl()->GetAttrSet() ); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 9d7c57b15659..4926f33fb4e3 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -73,6 +73,7 @@ #ifdef DBG_UTIL #include <sal/backtrace.hxx> #endif +#include <names.hxx> using namespace ::com::sun::star::i18n; @@ -130,15 +131,19 @@ static void SetParent( std::shared_ptr<const SwAttrSet>& rpAttrSet, if ( pParentFormat ) { - OUString sVal; + ProgName sVal; SwStyleNameMapper::FillProgName( pParentFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); - const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal ); + const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal.toString() ); aNewSet.Put( aAnyFormatColl ); if ( pConditionalFormat != pParentFormat ) - SwStyleNameMapper::FillProgName( pConditionalFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); + { + ProgName sTmp; + SwStyleNameMapper::FillProgName( pConditionalFormat->GetName(), sTmp, SwGetPoolIdFromName::TxtColl ); + sVal = sTmp; + } - const SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal ); + const SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal.toString() ); aNewSet.Put( aFormatColl ); } diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 165ef5eec354..848d9508a418 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -101,6 +101,7 @@ #include <comphelper/diagnose_ex.hxx> #include <IDocumentRedlineAccess.hxx> +#include <names.hxx> constexpr OUString WATERMARK_NAME = u"PowerPlusWaterMarkObject"_ustr; #define WATERMARK_AUTO_SIZE sal_uInt32(1) @@ -133,9 +134,9 @@ std::vector<OUString> lcl_getUsedPageStyles(SwViewShell const * pShell) SwPageFrame* pPage = static_cast<SwPageFrame*>(pFrame); if (const SwPageDesc *pDesc = pPage->FindPageDesc()) { - OUString sStyleName; + ProgName sStyleName; SwStyleNameMapper::FillProgName(pDesc->GetName(), sStyleName, SwGetPoolIdFromName::PageDesc); - aReturn.push_back(sStyleName); + aReturn.push_back(sStyleName.toString()); } } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 2f6820154e1e..a3bf0d522e37 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -58,6 +58,7 @@ #include <SwStyleNameMapper.hxx> #include <unofldmid.h> #include <numrule.hxx> +#include <names.hxx> #include <utility> using namespace ::com::sun::star; @@ -1075,7 +1076,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { OUString sTmp; rAny >>= sTmp; - SetPar1( SwStyleNameMapper::GetUIName( sTmp, SwGetPoolIdFromName::TxtColl ) ); + SetPar1( SwStyleNameMapper::GetUIName( ProgName(sTmp), SwGetPoolIdFromName::TxtColl ) ); } break; case FIELD_PROP_PAR2: @@ -1169,7 +1170,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= static_cast<sal_Int16>(mnSeqNo); break; case FIELD_PROP_PAR1: - rAny <<= SwStyleNameMapper::GetProgName(GetPar1(), SwGetPoolIdFromName::TxtColl ); + rAny <<= SwStyleNameMapper::GetProgName(GetPar1(), SwGetPoolIdFromName::TxtColl ).toString(); break; case FIELD_PROP_PAR2: { diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 3961aebf9594..35480504f17f 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -58,6 +58,7 @@ #include <numrule.hxx> #include <SwNodeNum.hxx> #include <calbck.hxx> +#include <names.hxx> #include <cstddef> #include <memory> @@ -953,7 +954,11 @@ bool SwGetRefField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const case RES_POOLCOLL_LABEL_FRAME: case RES_POOLCOLL_LABEL_DRAWING: case RES_POOLCOLL_LABEL_FIGURE: - SwStyleNameMapper::FillProgName(nPoolId, sTmp) ; + { + ProgName sTmp2(sTmp); + SwStyleNameMapper::FillProgName(nPoolId, sTmp2) ; + sTmp = sTmp2.toString(); + } break; } } @@ -1074,7 +1079,7 @@ void SwGetRefField::ConvertProgrammaticToUIName() if (rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rPar1, false)) return; - sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromProgName( rPar1, SwGetPoolIdFromName::TxtColl ); + sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromProgName( ProgName(rPar1), SwGetPoolIdFromName::TxtColl ); TranslateId pResId; switch( nPoolId ) { @@ -1501,7 +1506,7 @@ SwTextNode* SwGetRefFieldType::FindAnchorRefStyle(SwDoc* pDoc, const OUString& r // undocumented Word feature: 1 = "Heading 1" etc. OUString const styleName( (rRefMark.getLength() == 1 && '1' <= rRefMark[0] && rRefMark[0] <= '9') - ? SwStyleNameMapper::GetProgName(RES_POOLCOLL_HEADLINE1 + rRefMark[0] - '1', rRefMark) + ? SwStyleNameMapper::GetProgName(RES_POOLCOLL_HEADLINE1 + rRefMark[0] - '1', rRefMark).toString() : rRefMark); switch (elementType) diff --git a/sw/source/core/fields/textapi.cxx b/sw/source/core/fields/textapi.cxx index 187785a0b340..59c6c5ab95fa 100644 --- a/sw/source/core/fields/textapi.cxx +++ b/sw/source/core/fields/textapi.cxx @@ -32,6 +32,7 @@ #include <editeng/unoprnms.hxx> #include <editeng/unoforou.hxx> #include <editeng/unoipset.hxx> +#include <names.hxx> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -93,12 +94,12 @@ public: using SvxOutlinerForwarder::SvxOutlinerForwarder; OUString GetStyleSheet(sal_Int32 nPara) const override { - return SwStyleNameMapper::GetProgName(SvxOutlinerForwarder::GetStyleSheet(nPara), SwGetPoolIdFromName::TxtColl); + return SwStyleNameMapper::GetProgName(SvxOutlinerForwarder::GetStyleSheet(nPara), SwGetPoolIdFromName::TxtColl).toString(); } void SetStyleSheet(sal_Int32 nPara, const OUString& rStyleName) override { - SvxOutlinerForwarder::SetStyleSheet(nPara, SwStyleNameMapper::GetUIName(rStyleName, SwGetPoolIdFromName::TxtColl)); + SvxOutlinerForwarder::SetStyleSheet(nPara, SwStyleNameMapper::GetUIName(ProgName(rStyleName), SwGetPoolIdFromName::TxtColl)); } }; diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx index 747b41e6decc..dabf724138cf 100644 --- a/sw/source/core/inc/unofield.hxx +++ b/sw/source/core/inc/unofield.hxx @@ -34,6 +34,7 @@ class SwDoc; class SwFormatField; class SwSetExpField; +class ProgName; typedef ::cppu::WeakImplHelper < css::beans::XPropertySet @@ -62,7 +63,7 @@ public: CreateXFieldMaster(SwDoc * pDoc, SwFieldType * pType, SwFieldIds nResId = SwFieldIds::Unknown); - static OUString GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc); + static ProgName GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc); static OUString LocalizeFormula(const SwSetExpField& rField, const OUString& rFormula, bool bQuery); SwFieldType* GetFieldType(bool bDontCreate = false) const; diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 788fd13a2419..bd5d65a9e9b1 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -100,6 +100,7 @@ #include <wrtsh.hxx> #include <txtfld.hxx> #include <cellatr.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -798,9 +799,9 @@ bool SwFormatPageDesc::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const const SwPageDesc* pDesc = GetPageDesc(); if( pDesc ) { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, SwGetPoolIdFromName::PageDesc); - rVal <<= aString; + rVal <<= aString.toString(); } else rVal.clear(); diff --git a/sw/source/core/para/paratr.cxx b/sw/source/core/para/paratr.cxx index 52763819a844..e98aaec7c323 100644 --- a/sw/source/core/para/paratr.cxx +++ b/sw/source/core/para/paratr.cxx @@ -28,6 +28,7 @@ #include <osl/diagnose.h> #include <tools/UnitConversion.hxx> #include <o3tl/hash_combine.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -128,11 +129,11 @@ bool SwFormatDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; case MID_DROPCAP_CHAR_STYLE_NAME : { - OUString sName; + ProgName sName; if(GetCharFormat()) sName = SwStyleNameMapper::GetProgName( GetCharFormat()->GetName(), SwGetPoolIdFromName::ChrFmt ); - rVal <<= sName; + rVal <<= sName.toString(); } break; } @@ -209,8 +210,8 @@ bool SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const bool SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const { - OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), SwGetPoolIdFromName::NumRule ); - rVal <<= sRet; + ProgName sRet = SwStyleNameMapper::GetProgName(GetValue(), SwGetPoolIdFromName::NumRule ); + rVal <<= sRet.toString(); return true; } @@ -218,7 +219,7 @@ bool SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 ) { OUString uName; rVal >>= uName; - SetValue(SwStyleNameMapper::GetUIName(uName, SwGetPoolIdFromName::NumRule)); + SetValue(SwStyleNameMapper::GetUIName(ProgName(uName), SwGetPoolIdFromName::NumRule)); return true; } diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 4c7e4e43e36b..20ccb7bac875 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -89,6 +89,7 @@ #include <dcontact.hxx> #include <PostItMgr.hxx> #include <AnnotationWin.hxx> +#include <names.hxx> #include <tools/globname.hxx> #include <svx/svdobj.hxx> @@ -232,9 +233,9 @@ bool lcl_IsHeadlineCell( const SwCellFrame& rCellFrame ) SwTextNode const*const pTextNode = static_cast<const SwTextFrame*>(pCnt)->GetTextNodeForParaProps(); const SwFormat* pTextFormat = pTextNode->GetFormatColl(); - OUString sStyleName; + ProgName sStyleName; SwStyleNameMapper::FillProgName( pTextFormat->GetName(), sStyleName, SwGetPoolIdFromName::TxtColl ); - bRet = sStyleName == aTableHeadingName; + bRet = sStyleName.toString() == aTableHeadingName; } // tdf#153935 wild guessing for 1st row based on table autoformat @@ -1445,8 +1446,8 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() const SwFormat* pTextFormat = pTextNd->GetFormatColl(); const SwFormat* pParentTextFormat = pTextFormat ? pTextFormat->DerivedFrom() : nullptr; - OUString sStyleName; - OUString sParentStyleName; + ProgName sStyleName; + ProgName sParentStyleName; if ( pTextFormat) SwStyleNameMapper::FillProgName( pTextFormat->GetName(), sStyleName, SwGetPoolIdFromName::TxtColl ); @@ -1457,7 +1458,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() // any of the standard pdf tags, we write a user defined tag // <stylename> with role = P nPDFType = sal_uInt16(vcl::pdf::StructElement::Paragraph); - aPDFType = sStyleName; + aPDFType = sStyleName.toString(); // Title @@ -1488,7 +1489,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() else if (sParentStyleName == aCaption) { nPDFType = sal_uInt16(vcl::pdf::StructElement::Caption); - aPDFType = sStyleName + aCaptionString; + aPDFType = sStyleName.toString() + aCaptionString; } // Heading: H @@ -1858,7 +1859,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() SwTextAttr const*const pInetFormatAttr = pos.first->GetTextAttrAt(pos.second, RES_TXTATR_INETFMT); - OUString sStyleName; + ProgName sStyleName; if (!pInetFormatAttr) { std::vector<SwTextAttr *> const charAttrs( @@ -1871,7 +1872,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() } // note: ILSE may be nested, so only end the span if needed to start new one - bool const isContinueSpan(CheckContinueSpan(rInf, sStyleName, pInetFormatAttr)); + bool const isContinueSpan(CheckContinueSpan(rInf, sStyleName.toString(), pInetFormatAttr)); sal_uInt16 nPDFType = USHRT_MAX; OUString aPDFType; @@ -1930,7 +1931,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() { nPDFType = sal_uInt16(vcl::pdf::StructElement::Emphasis); aPDFType = constEmphasisStyleName; - CreateCurrentSpan(rInf, sStyleName); + CreateCurrentSpan(rInf, sStyleName.toString()); } } // Strong @@ -1940,7 +1941,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() { nPDFType = sal_uInt16(vcl::pdf::StructElement::Strong); aPDFType = constStrongEmphasisStyleName; - CreateCurrentSpan(rInf, sStyleName); + CreateCurrentSpan(rInf, sStyleName.toString()); } } // Check for Quote/Code character style: @@ -1950,7 +1951,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() { nPDFType = sal_uInt16(vcl::pdf::StructElement::Quote); aPDFType = aQuoteString; - CreateCurrentSpan(rInf, sStyleName); + CreateCurrentSpan(rInf, sStyleName.toString()); } } else if (sStyleName == aSourceText) @@ -1959,7 +1960,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() { nPDFType = sal_uInt16(vcl::pdf::StructElement::Code); aPDFType = aCodeString; - CreateCurrentSpan(rInf, sStyleName); + CreateCurrentSpan(rInf, sStyleName.toString()); } } else if (!isContinueSpan) @@ -1979,10 +1980,10 @@ void SwTaggedPDFHelper::BeginInlineStructureElements() { nPDFType = sal_uInt16(vcl::pdf::StructElement::Span); if (!sStyleName.isEmpty()) - aPDFType = sStyleName; + aPDFType = sStyleName.toString(); else aPDFType = aSpanString; - CreateCurrentSpan(rInf, sStyleName); + CreateCurrentSpan(rInf, sStyleName.toString()); } } } diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 08a653311071..74588b341474 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -81,6 +81,7 @@ #include <unoprnms.hxx> #include <editeng/unoprnms.hxx> #include <unomap.hxx> +#include <names.hxx> #include <com/sun/star/awt/FontSlant.hpp> using namespace ::com::sun::star; @@ -1360,7 +1361,7 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const if (!rCharStylesColorMap.empty()) { OUString sCharStyleDisplayName; - sCharStyleDisplayName = SwStyleNameMapper::GetUIName(sCurrentCharStyle, + sCharStyleDisplayName = SwStyleNameMapper::GetUIName(ProgName(sCurrentCharStyle), SwGetPoolIdFromName::ChrFmt); if (!sCharStyleDisplayName.isEmpty()) { diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 8159e0c5e812..780ecb23cc92 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -49,6 +49,7 @@ #include <unometa.hxx> #include <unotext.hxx> #include <docsh.hxx> +#include <names.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -124,10 +125,10 @@ void SwFormatCharFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) bool SwFormatCharFormat::QueryValue( uno::Any& rVal, sal_uInt8 ) const { - OUString sCharFormatName; + ProgName sCharFormatName; if(GetCharFormat()) SwStyleNameMapper::FillProgName(GetCharFormat()->GetName(), sCharFormatName, SwGetPoolIdFromName::ChrFmt ); - rVal <<= sCharFormatName; + rVal <<= sCharFormatName.toString(); return true; } bool SwFormatCharFormat::PutValue( const uno::Any& , sal_uInt8 ) @@ -321,10 +322,11 @@ bool SwFormatINetFormat::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const OUString sVal = msVisitedFormatName; if (sVal.isEmpty() && mnVisitedFormatId != 0) SwStyleNameMapper::FillUIName(mnVisitedFormatId, sVal); + ProgName aRet; if (!sVal.isEmpty()) - SwStyleNameMapper::FillProgName(sVal, sVal, + SwStyleNameMapper::FillProgName(sVal, aRet, SwGetPoolIdFromName::ChrFmt); - rVal <<= sVal; + rVal <<= aRet.toString(); } break; case MID_URL_UNVISITED_FMT: @@ -332,10 +334,11 @@ bool SwFormatINetFormat::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const OUString sVal = msINetFormatName; if (sVal.isEmpty() && mnINetFormatId != 0) SwStyleNameMapper::FillUIName(mnINetFormatId, sVal); + ProgName aRet; if (!sVal.isEmpty()) - SwStyleNameMapper::FillProgName(sVal, sVal, + SwStyleNameMapper::FillProgName(sVal, aRet, SwGetPoolIdFromName::ChrFmt); - rVal <<= sVal; + rVal <<= aRet.toString(); } break; case MID_URL_HYPERLINKEVENTS: @@ -403,7 +406,7 @@ bool SwFormatINetFormat::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) OUString sVal; rVal >>= sVal; OUString aString; - SwStyleNameMapper::FillUIName( sVal, aString, SwGetPoolIdFromName::ChrFmt ); + SwStyleNameMapper::FillUIName( ProgName(sVal), aString, SwGetPoolIdFromName::ChrFmt ); msVisitedFormatName = aString; mnVisitedFormatId = SwStyleNameMapper::GetPoolIdFromUIName( msVisitedFormatName, SwGetPoolIdFromName::ChrFmt ); @@ -414,7 +417,7 @@ bool SwFormatINetFormat::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) OUString sVal; rVal >>= sVal; OUString aString; - SwStyleNameMapper::FillUIName( sVal, aString, SwGetPoolIdFromName::ChrFmt ); + SwStyleNameMapper::FillUIName( ProgName(sVal), aString, SwGetPoolIdFromName::ChrFmt ); msINetFormatName = aString; mnINetFormatId = SwStyleNameMapper::GetPoolIdFromUIName( msINetFormatName, SwGetPoolIdFromName::ChrFmt ); } @@ -507,9 +510,9 @@ bool SwFormatRuby::QueryValue( uno::Any& rVal, case MID_RUBY_ADJUST: rVal <<= static_cast<sal_Int16>(m_eAdjustment); break; case MID_RUBY_CHARSTYLE: { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(m_sCharFormatName, aString, SwGetPoolIdFromName::ChrFmt ); - rVal <<= aString; + rVal <<= aString.toString(); } break; case MID_RUBY_ABOVE: @@ -572,7 +575,7 @@ bool SwFormatRuby::PutValue( const uno::Any& rVal, OUString sTmp; bRet = rVal >>= sTmp; if(bRet) - m_sCharFormatName = SwStyleNameMapper::GetUIName(sTmp, SwGetPoolIdFromName::ChrFmt ); + m_sCharFormatName = SwStyleNameMapper::GetUIName(ProgName(sTmp), SwGetPoolIdFromName::ChrFmt ); } break; default: diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 105357a165dc..033e65bf5de7 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -88,6 +88,7 @@ #include <formatflysplit.hxx> #include <fmtcntnt.hxx> #include <poolfmt.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -1234,12 +1235,12 @@ void SwTextNode::NewAttrSet( SwAttrPool& rPool ) // put names of parent style and conditional style: const SwFormatColl* pAnyFormatColl = &GetAnyFormatColl(); const SwFormatColl* pFormatColl = GetFormatColl(); - OUString sVal; + ProgName sVal; SwStyleNameMapper::FillProgName( pAnyFormatColl->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); - SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal ); + SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal.toString() ); if ( pFormatColl != pAnyFormatColl ) SwStyleNameMapper::FillProgName( pFormatColl->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); - SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal ); + SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal.toString() ); aNewAttrSet.Put( aAnyFormatColl ); aNewAttrSet.Put( aFormatColl ); diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index 66ea89e3d3f0..de5e71265786 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -37,6 +37,7 @@ #include <unocrsrhelper.hxx> #include <hintids.hxx> #include <fmtpdsc.hxx> +#include <names.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -86,7 +87,7 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName, throw lang::IllegalArgumentException(); OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, SwGetPoolIdFromName::ChrFmt ); + SwStyleNameMapper::FillUIName(ProgName(uStyle), sStyle, SwGetPoolIdFromName::ChrFmt ); SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)); std::unique_ptr<SwFormatDrop> pDrop; diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 7a019bf98bd3..10d391b5ee99 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -93,6 +93,7 @@ #include <poolfmt.hxx> #include <paratr.hxx> #include <sal/log.hxx> +#include <names.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -395,9 +396,9 @@ bool getCursorPropertyValue(const SfxItemPropertyMapEntry& rEntry { if( pAny ) { - OUString sVal; + ProgName sVal; SwStyleNameMapper::FillProgName(pFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); - *pAny <<= sVal; + *pAny <<= sVal.toString(); } } else @@ -406,10 +407,10 @@ bool getCursorPropertyValue(const SfxItemPropertyMapEntry& rEntry break; case FN_UNO_PAGE_STYLE : { - OUString sVal; + ProgName sVal; GetCurPageStyle(rPam, sVal); if( pAny ) - *pAny <<= sVal; + *pAny <<= sVal.toString(); if(sVal.isEmpty()) eNewState = PropertyState_AMBIGUOUS_VALUE; } @@ -780,7 +781,7 @@ bool getCursorPropertyValue(const SfxItemPropertyMapEntry& rEntry OSL_ENSURE(pAttr->GetCharFormat().GetCharFormat(), "no character format set"); aCharStyles.getArray()[aCharStyles.getLength() - 1] = SwStyleNameMapper::GetProgName( - pAttr->GetCharFormat().GetCharFormat()->GetName(), SwGetPoolIdFromName::ChrFmt); + pAttr->GetCharFormat().GetCharFormat()->GetName(), SwGetPoolIdFromName::ChrFmt).toString(); } } @@ -964,7 +965,7 @@ void getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny ) eState = PropertyState_DEFAULT_VALUE; } -void GetCurPageStyle(SwPaM const & rPaM, OUString &rString) +void GetCurPageStyle(SwPaM const & rPaM, ProgName &rString) { if (!rPaM.GetPointContentNode()) return; // TODO: is there an easy way to get it for tables/sections? @@ -1390,7 +1391,7 @@ void makeRedline( SwPaM const & rPaM, nStylePoolId = RES_POOLCOLL_STANDARD; // tdf#149747 Get UI style name from programmatic style name - SwStyleNameMapper::FillUIName(sParaStyleName, sUIStyle, + SwStyleNameMapper::FillUIName(ProgName(sParaStyleName), sUIStyle, SwGetPoolIdFromName::TxtColl); xRedlineExtraData.reset(new SwRedlineExtraData_FormatColl( sUIStyle.isEmpty() ? sParaStyleName : sUIStyle, nStylePoolId, &aItemSet)); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index afbaf1e48867..235f96d792c2 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -86,6 +86,7 @@ #include <textapi.hxx> #include <fmtmeta.hxx> #include <annotationmark.hxx> +#include <names.hxx> #include <vector> using namespace ::com::sun::star; @@ -804,7 +805,7 @@ SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) { if(rPropertyName == UNO_NAME_NAME) { - aRet <<= SwXFieldMaster::GetProgrammaticName(*pType, *m_pImpl->m_pDoc); + aRet <<= SwXFieldMaster::GetProgrammaticName(*pType, *m_pImpl->m_pDoc).toString(); } else if(rPropertyName == UNO_NAME_DEPENDENT_TEXT_FIELDS) { @@ -986,7 +987,7 @@ void SwXFieldMaster::Impl::Notify(const SfxHint& rHint) } } -OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc) +ProgName SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc) { const OUString sName(rType.GetName()); if(SwFieldIds::SetExp == rType.Which()) @@ -1000,7 +1001,7 @@ OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rD } } } - return sName; + return ProgName(sName); } OUString SwXFieldMaster::LocalizeFormula( @@ -1009,12 +1010,12 @@ OUString SwXFieldMaster::LocalizeFormula( bool bQuery) { const OUString sTypeName(rField.GetTyp()->GetName()); - const OUString sProgName( + const ProgName sProgName( SwStyleNameMapper::GetProgName(sTypeName, SwGetPoolIdFromName::TxtColl )); - if(sProgName != sTypeName) + if(sProgName.toString() != sTypeName) { - const OUString sSource = bQuery ? sTypeName : sProgName; - const OUString sDest = bQuery ? sProgName : sTypeName; + const OUString sSource = bQuery ? sTypeName : sProgName.toString(); + const OUString sDest = bQuery ? sProgName.toString() : sTypeName; if(rFormula.startsWith(sSource)) { return sDest + rFormula.subView(sSource.getLength()); @@ -2715,7 +2716,7 @@ static SwFieldIds lcl_GetIdByName( OUString& rName, OUString& rTypeName ) nResId = SwFieldIds::SetExp; const OUString sFieldTypName( rName.getToken( 0, '.', nIdx )); - const OUString sUIName( SwStyleNameMapper::GetSpecialExtraUIName( sFieldTypName ) ); + const OUString sUIName( SwStyleNameMapper::GetSpecialExtraUIName( ProgName(sFieldTypName) ) ); if( sUIName != sFieldTypName ) rName = comphelper::string::setToken(rName, 1, '.', sUIName); @@ -2779,7 +2780,7 @@ bool SwXTextFieldMasters::getInstanceName( break; case SwFieldIds::SetExp: - sField = "SetExpression." + SwStyleNameMapper::GetSpecialExtraProgName( rFieldType.GetName() ); + sField = "SetExpression." + SwStyleNameMapper::GetSpecialExtraProgName( rFieldType.GetName() ).toString(); break; case SwFieldIds::Database: diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 979c7fce353c..12c5829224b0 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -137,6 +137,7 @@ #include <fefly.hxx> #include <formatflysplit.hxx> #include <formatwraptextatflystart.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -949,12 +950,13 @@ bool SwFrameProperties_Impl::AnyToItemSet(SwDoc *pDoc, SfxItemSet& rSet, SfxItem if (const uno::Any* pStyleName = GetProperty(FN_UNO_FRAME_STYLE_NAME, 0)) { - OUString sStyle; - *pStyleName >>= sStyle; - SwStyleNameMapper::FillUIName(sStyle, sStyle, SwGetPoolIdFromName::FrmFmt); + OUString sStyleProgName; + *pStyleName >>= sStyleProgName; + OUString sStyleUIName; + SwStyleNameMapper::FillUIName(ProgName(sStyleProgName), sStyleUIName, SwGetPoolIdFromName::FrmFmt); if (SwDocShell* pShell = pDoc->GetDocShell()) { - pStyle = static_cast<SwDocStyleSheet*>(pShell->GetStyleSheetPool()->Find(sStyle, + pStyle = static_cast<SwDocStyleSheet*>(pShell->GetStyleSheetPool()->Find(sStyleUIName, SfxStyleFamily::Frame)); } } @@ -1031,12 +1033,13 @@ bool SwGraphicProperties_Impl::AnyToItemSet( if (const uno::Any* pStyleName = GetProperty(FN_UNO_FRAME_STYLE_NAME, 0)) { - OUString sStyle; - *pStyleName >>= sStyle; - SwStyleNameMapper::FillUIName(sStyle, sStyle, SwGetPoolIdFromName::FrmFmt); + OUString sStyleProgName; + *pStyleName >>= sStyleProgName; + OUString sStyleUIName; + SwStyleNameMapper::FillUIName(ProgName(sStyleProgName), sStyleUIName, SwGetPoolIdFromName::FrmFmt); if (SwDocShell* pShell = pDoc->GetDocShell()) { - pStyle = static_cast<SwDocStyleSheet*>(pShell->GetStyleSheetPool()->Find(sStyle, + pStyle = static_cast<SwDocStyleSheet*>(pShell->GetStyleSheetPool()->Find(sStyleUIName, SfxStyleFamily::Frame)); } } @@ -1322,7 +1325,7 @@ static SwFrameFormat *lcl_GetFrameFormat( const ::uno::Any& rValue, SwDoc *pDoc OUString uTemp; rValue >>= uTemp; OUString sStyle; - SwStyleNameMapper::FillUIName(uTemp, sStyle, + SwStyleNameMapper::FillUIName(ProgName(uTemp), sStyle, SwGetPoolIdFromName::FrmFmt); SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>(pDocSh->GetStyleSheetPool()->Find(sStyle, @@ -2095,7 +2098,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) } else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) { - aAny <<= SwStyleNameMapper::GetProgName(pFormat->DerivedFrom()->GetName(), SwGetPoolIdFromName::FrmFmt ); + aAny <<= SwStyleNameMapper::GetProgName(pFormat->DerivedFrom()->GetName(), SwGetPoolIdFromName::FrmFmt ).toString(); } // #i73249# else if( FN_UNO_TITLE == pEntry->nWID ) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 3cba56977729..aa4f2d171c93 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -62,6 +62,7 @@ #include <svl/listener.hxx> #include <mutex> #include <unotxdoc.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -689,7 +690,7 @@ SwXDocumentIndex::setPropertyValue( // convert file-format/API/external programmatic english name // to internal UI name before usage rTOXBase.SetSequenceName( SwStyleNameMapper::GetSpecialExtraUIName( - lcl_AnyToType<OUString>(rValue) ) ); + ProgName(lcl_AnyToType<OUString>(rValue)) ) ); } break; case WID_LABEL_DISPLAY_TYPE: @@ -719,7 +720,7 @@ SwXDocumentIndex::setPropertyValue( case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: { OUString aString; - SwStyleNameMapper::FillUIName(lcl_AnyToType<OUString>(rValue), + SwStyleNameMapper::FillUIName(ProgName(lcl_AnyToType<OUString>(rValue)), aString, SwGetPoolIdFromName::ChrFmt); rTOXBase.SetMainEntryCharStyle( aString ); } @@ -755,7 +756,7 @@ SwXDocumentIndex::setPropertyValue( case WID_PARA_HEAD: { OUString aString; - SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue), + SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)), aString, SwGetPoolIdFromName::TxtColl); bForm = true; // Header is on Pos 0 @@ -770,7 +771,7 @@ SwXDocumentIndex::setPropertyValue( { OUString aString; bForm = true; - SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue), + SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)), aString, SwGetPoolIdFromName::TxtColl); aForm.SetTemplate( 1, aString ); } @@ -789,7 +790,7 @@ SwXDocumentIndex::setPropertyValue( } lcl_AnyToBitMask(uno::Any(true), nCreate, SwTOXElement::Template); OUString uiStyle; - SwStyleNameMapper::FillUIName(style, uiStyle, SwGetPoolIdFromName::TxtColl); + SwStyleNameMapper::FillUIName(ProgName(style), uiStyle, SwGetPoolIdFromName::TxtColl); rTOXBase.SetStyleNames(uiStyle, 0); } else if (!rValue.hasValue()) @@ -818,7 +819,7 @@ SwXDocumentIndex::setPropertyValue( // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1; OUString aString; - SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue), + SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)), aString, SwGetPoolIdFromName::TxtColl); aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); } @@ -1019,7 +1020,7 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) // file-format/API/external programmatic english name // before usage aRet <<= SwStyleNameMapper::GetSpecialExtraProgName( - pTOXBase->GetSequenceName() ); + pTOXBase->GetSequenceName() ).toString(); } break; case WID_LABEL_DISPLAY_TYPE: @@ -1072,12 +1073,12 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) break; case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName( pTOXBase->GetMainEntryCharStyle(), aString, SwGetPoolIdFromName::ChrFmt); - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_CREATE_FROM_TABLES: @@ -1119,10 +1120,10 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) if (!rStyle.isEmpty()) { assert(rStyle.indexOf(TOX_STYLE_DELIMITER) == -1); - OUString ret; + ProgName ret; SwStyleNameMapper::FillProgName(rStyle, ret, SwGetPoolIdFromName::TxtColl); - aRet <<= ret; + aRet <<= ret.toString(); } } } @@ -1131,20 +1132,20 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) case WID_PARA_HEAD: { //Header is at position 0 - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString, SwGetPoolIdFromName::TxtColl ); - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_PARA_SEP: { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName( rForm.GetTemplate( 1 ), aString, SwGetPoolIdFromName::TxtColl); - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_PARA_LEV1: @@ -1160,12 +1161,12 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) { // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 const sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName( rForm.GetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1), aString, SwGetPoolIdFromName::TxtColl); - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_IS_RELATIVE_TABSTOPS: @@ -2529,7 +2530,7 @@ SwXDocumentIndex::StyleAccess_Impl::replaceByIndex( { sSetStyles.append(TOX_STYLE_DELIMITER); } - SwStyleNameMapper::FillUIName(pStyles[i], aString, + SwStyleNameMapper::FillUIName(ProgName(pStyles[i]), aString, SwGetPoolIdFromName::TxtColl); sSetStyles.append(aString); } @@ -2559,7 +2560,7 @@ SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) const sal_Int32 nStyles = comphelper::string::getTokenCount(rStyles, TOX_STYLE_DELIMITER); uno::Sequence<OUString> aStyles(nStyles); OUString* pStyles = aStyles.getArray(); - OUString aString; + ProgName aString; sal_Int32 nPos = 0; for(sal_Int32 i = 0; i < nStyles; ++i) { @@ -2567,7 +2568,7 @@ SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos), aString, SwGetPoolIdFromName::TxtColl); - pStyles[i] = aString; + pStyles[i] = aString.toString(); } uno::Any aRet(&aStyles, cppu::UnoType<uno::Sequence<OUString>>::get()); return aRet; @@ -2682,7 +2683,7 @@ SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( { OUString sCharStyleName; SwStyleNameMapper::FillUIName( - lcl_AnyToType<OUString>(pProperties[j].Value), + ProgName(lcl_AnyToType<OUString>(pProperties[j].Value)), sCharStyleName, SwGetPoolIdFromName::ChrFmt); aToken.sCharStyleName = sCharStyleName; @@ -2846,7 +2847,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int32 nTokenCount = 0; uno::Sequence< beans::PropertyValues > aRetSeq; - OUString aProgCharStyle; + ProgName aProgCharStyle; for(const SwFormToken& aToken : aPattern) // #i21237# { nTokenCount++; @@ -2887,7 +2888,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) u"TokenEntryNumber"_ustr; pArr[nCurrentElement].Name = "CharacterStyleName"; - pArr[nCurrentElement++].Value <<= aProgCharStyle; + pArr[nCurrentElement++].Value <<= aProgCharStyle.toString(); if( aToken.nChapterFormat != CF_NUMBER ) { pArr[nCurrentElement].Name = "ChapterFormat"; @@ -2926,7 +2927,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Value <<= u"TokenEntryText"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); } break; case TOKEN_TAB_STOP: @@ -2953,7 +2954,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[2].Name = "TabStopFillCharacter"; pArr[2].Value <<= OUString(aToken.cTabFillChar); pArr[3].Name = "CharacterStyleName"; - pArr[3].Value <<= aProgCharStyle; + pArr[3].Value <<= aProgCharStyle.toString(); // #i21237# pArr[4].Name = "WithTab"; pArr[4].Value <<= aToken.bWithTab; @@ -2968,7 +2969,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Value <<= u"TokenText"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); pArr[2].Name = "Text"; pArr[2].Value <<= aToken.sText; @@ -2983,7 +2984,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Value <<= u"TokenPageNumber"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); } break; case TOKEN_CHAPTER_INFO: @@ -2995,7 +2996,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Value <<= u"TokenChapterInfo"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); pArr[2].Name = "ChapterFormat"; sal_Int16 nVal = text::ChapterFormat::NUMBER; @@ -3032,7 +3033,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Value <<= u"TokenHyperlinkStart"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); } break; case TOKEN_LINK_END: @@ -3055,7 +3056,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) u"TokenBibliographyDataField"_ustr; pArr[1].Name = "CharacterStyleName"; - pArr[1].Value <<= aProgCharStyle; + pArr[1].Value <<= aProgCharStyle.toString(); pArr[2].Name = "BibliographyDataField"; pArr[2].Value <<= sal_Int16(aToken.nAuthorityField); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index a790cefa80c5..ba1efe36124b 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -79,6 +79,7 @@ #include <comphelper/profilezone.hxx> #include <comphelper/flagguard.hxx> #include <swmodule.hxx> +#include <names.hxx> using namespace ::com::sun::star; @@ -203,7 +204,7 @@ lcl_setCharStyle(SwDoc& rDoc, const uno::Any & rValue, SfxItemSet & rSet) throw lang::IllegalArgumentException(); } OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, + SwStyleNameMapper::FillUIName(ProgName(uStyle), sStyle, SwGetPoolIdFromName::ChrFmt); SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>( pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)); @@ -250,7 +251,7 @@ SwUnoCursorHelper::SetTextFormatColl(const uno::Any & rAny, SwPaM & rPaM) OUString uStyle; rAny >>= uStyle; OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, + SwStyleNameMapper::FillUIName(ProgName(uStyle), sStyle, SwGetPoolIdFromName::TxtColl ); SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>( pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Para)); @@ -289,7 +290,7 @@ SwUnoCursorHelper::SetPageDesc( pNewDesc.reset(new SwFormatPageDesc()); } OUString sDescName; - SwStyleNameMapper::FillUIName(uDescName, sDescName, + SwStyleNameMapper::FillUIName(ProgName(uDescName), sDescName, SwGetPoolIdFromName::PageDesc); if (!pNewDesc->GetPageDesc() || (pNewDesc->GetPageDesc()->GetName() != sDescName)) @@ -384,7 +385,7 @@ lcl_setDropcapCharStyle(SwPaM const & rPam, SfxItemSet & rItemSet, throw lang::IllegalArgumentException(); } OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, + SwStyleNameMapper::FillUIName(ProgName(uStyle), sStyle, SwGetPoolIdFromName::ChrFmt); SwDoc& rDoc = rPam.GetDoc(); //default character style must not be set as default format @@ -428,7 +429,7 @@ lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue) pRuby.reset(new SwFormatRuby(OUString())); } OUString sStyle; - SwStyleNameMapper::FillUIName(sTmp, sStyle, + SwStyleNameMapper::FillUIName(ProgName(sTmp), sStyle, SwGetPoolIdFromName::ChrFmt); pRuby->SetCharFormatName(sStyle); pRuby->SetCharFormatId(0); diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index c6085b368871..9924a169785c 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -42,6 +42,7 @@ #include <vcl/svapp.hxx> #include <docsh.hxx> #include <swunohelper.hxx> +#include <names.hxx> #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> @@ -909,7 +910,7 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState( } case FN_UNO_PAGE_STYLE: { - OUString sVal; + ProgName sVal; SwUnoCursorHelper::GetCurPageStyle( aPam, sVal ); eRet = !sVal.isEmpty() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 3784c55284d7..c52d95b3cba9 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -70,6 +70,7 @@ #include <svl/listener.hxx> #include <paratr.hxx> #include <sal/log.hxx> +#include <names.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -189,7 +190,7 @@ static SwCharFormat* lcl_getCharFormat(SwDoc* pDoc, const uno::Any& aValue) OUString uTmp; aValue >>= uTmp; OUString sCharFormat; - SwStyleNameMapper::FillUIName(uTmp, sCharFormat, SwGetPoolIdFromName::ChrFmt); + SwStyleNameMapper::FillUIName(ProgName(uTmp), sCharFormat, SwGetPoolIdFromName::ChrFmt); if (sCharFormat != SwResId(STR_POOLCHR_STANDARD)) { pRet = pDoc->FindCharFormatByName( sCharFormat ); @@ -208,7 +209,7 @@ static SwTextFormatColl* lcl_GetParaStyle(SwDoc* pDoc, const uno::Any& aValue) OUString uTmp; aValue >>= uTmp; OUString sParaStyle; - SwStyleNameMapper::FillUIName(uTmp, sParaStyle, SwGetPoolIdFromName::TxtColl ); + SwStyleNameMapper::FillUIName(ProgName(uTmp), sParaStyle, SwGetPoolIdFromName::TxtColl ); SwTextFormatColl* pRet = pDoc->FindTextFormatCollByName( sParaStyle ); if( !pRet ) { @@ -224,7 +225,7 @@ static SwPageDesc* lcl_GetPageDesc(SwDoc* pDoc, const uno::Any& aValue) OUString uTmp; aValue >>= uTmp; OUString sPageDesc; - SwStyleNameMapper::FillUIName(uTmp, sPageDesc, SwGetPoolIdFromName::PageDesc ); + SwStyleNameMapper::FillUIName(ProgName(uTmp), sPageDesc, SwGetPoolIdFromName::PageDesc ); SwPageDesc* pRet = pDoc->FindPageDesc( sPageDesc ); if(!pRet) { @@ -455,13 +456,14 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) OUString aString; if(pColl) aString = pColl->GetName(); - SwStyleNameMapper::FillProgName(aString, aString, SwGetPoolIdFromName::TxtColl); - aRet <<= aString; + ProgName aRetName; + SwStyleNameMapper::FillProgName(aString, aRetName, SwGetPoolIdFromName::TxtColl); + aRet <<= aRetName.toString(); } break; case WID_PAGE_STYLE : { - OUString aString; + ProgName aString; if( rFootnoteInfo.KnowsPageDesc() ) { SwStyleNameMapper::FillProgName( @@ -469,13 +471,13 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) aString, SwGetPoolIdFromName::PageDesc); } - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_ANCHOR_CHARACTER_STYLE: case WID_CHARACTER_STYLE: { - OUString aString; + ProgName aString; const SwCharFormat* pCharFormat = rFootnoteInfo.GetCurrentCharFormat(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE); if( pCharFormat ) { @@ -484,7 +486,7 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) aString, SwGetPoolIdFromName::ChrFmt); } - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_POSITION_END_OF_DOC: @@ -660,20 +662,21 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) case WID_PARAGRAPH_STYLE : { SwTextFormatColl* pColl = rEndInfo.GetFootnoteTextColl(); - OUString aString; + OUString aName; if(pColl) - aString = pColl->GetName(); + aName = pColl->GetName(); + ProgName aString; SwStyleNameMapper::FillProgName( - aString, + aName, aString, SwGetPoolIdFromName::TxtColl); - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_PAGE_STYLE : { - OUString aString; + ProgName aString; if( rEndInfo.KnowsPageDesc() ) { SwStyleNameMapper::FillProgName( @@ -681,13 +684,13 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) aString, SwGetPoolIdFromName::PageDesc); } - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_ANCHOR_CHARACTER_STYLE: case WID_CHARACTER_STYLE: { - OUString aString; + ProgName aString; const SwCharFormat* pCharFormat = rEndInfo.GetCurrentCharFormat( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE ); if( pCharFormat ) { @@ -696,7 +699,7 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) aString, SwGetPoolIdFromName::ChrFmt); } - aRet <<= aString; + aRet <<= aString.toString(); } break; } @@ -893,7 +896,7 @@ Any SwXLineNumberingProperties::getPropertyValue(const OUString& rPropertyName) break; case WID_CHARACTER_STYLE : { - OUString aString; + ProgName aString; // return empty string if no char format is set // otherwise it would be created here if(rInfo.HasCharFormat()) @@ -903,7 +906,7 @@ Any SwXLineNumberingProperties::getPropertyValue(const OUString& rPropertyName) aString, SwGetPoolIdFromName::ChrFmt); } - aRet <<= aString; + aRet <<= aString.toString(); } break; case WID_NUMBERING_TYPE : @@ -1239,7 +1242,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex( CharStyleName = m_sNewCharStyleNames[nIndex]; } - OUString aUString; + ProgName aUString; if (m_pDocShell) // -> Chapter Numbering { // template name @@ -1302,7 +1305,7 @@ uno::Any SwXNumberingRules::GetNumberingRuleByIndex( CharStyleName = m_sNewCharStyleNames[nIndex]; } - OUString aUString; + ProgName aUString; if (m_pDocShell) // -> Chapter Numbering { // template name @@ -1347,7 +1350,7 @@ uno::Any SwXNumberingRules::GetNumberingRuleByIndex( uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat( const SwNumFormat& rFormat, OUString const& rCharFormatName, - OUString const*const pHeadingStyleName, OUString const & referer) + ProgName const*const pHeadingStyleName, OUString const & referer) { bool bChapterNum = pHeadingStyleName != nullptr; @@ -1382,9 +1385,9 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_LEVEL_IS_LEGAL, true)); //char style name - aUString.clear(); - SwStyleNameMapper::FillProgName( rCharFormatName, aUString, SwGetPoolIdFromName::ChrFmt); - aPropertyValues.push_back(comphelper::makePropertyValue(u"CharStyleName"_ustr, aUString)); + ProgName aCharStyleProgName; + SwStyleNameMapper::FillProgName( rCharFormatName, aCharStyleProgName, SwGetPoolIdFromName::ChrFmt); + aPropertyValues.push_back(comphelper::makePropertyValue(u"CharStyleName"_ustr, aCharStyleProgName.toString())); //startvalue nINT16 = rFormat.GetStart(); @@ -1505,7 +1508,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat } else { - aUString = *pHeadingStyleName; + aUString = pHeadingStyleName->toString(); aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_HEADING_STYLE_NAME, aUString)); } @@ -1514,7 +1517,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat uno::Any SwXNumberingRules::GetPropertyForNumFormat( const SwNumFormat& rFormat, OUString const& rCharFormatName, - OUString const*const pHeadingStyleName, OUString const & referer, OUString const & rPropName) + ProgName const*const pHeadingStyleName, OUString const & referer, OUString const & rPropName) { bool bChapterNum = pHeadingStyleName != nullptr; @@ -1542,9 +1545,9 @@ uno::Any SwXNumberingRules::GetPropertyForNumFormat( return uno::Any(rFormat.GetIsLegal()); if (rPropName == u"CharStyleName"_ustr) { - OUString aUString; + ProgName aUString; SwStyleNameMapper::FillProgName( rCharFormatName, aUString, SwGetPoolIdFromName::ChrFmt); - return uno::Any(aUString); + return uno::Any(aUString.toString()); } if (rPropName == u"StartWith"_ustr) return uno::Any(sal_Int16(rFormat.GetStart())); @@ -1681,7 +1684,7 @@ uno::Any SwXNumberingRules::GetPropertyForNumFormat( else { if (rPropName == UNO_NAME_HEADING_STYLE_NAME) - return uno::Any(*pHeadingStyleName); + return uno::Any(pHeadingStyleName->toString()); } throw UnknownPropertyException(rPropName); @@ -1806,7 +1809,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( OUString uTmp; rProp.Value >>= uTmp; OUString sCharFormatName; - SwStyleNameMapper::FillUIName( uTmp, sCharFormatName, SwGetPoolIdFromName::ChrFmt ); + SwStyleNameMapper::FillUIName( ProgName(uTmp), sCharFormatName, SwGetPoolIdFromName::ChrFmt ); SwDoc *const pLocalDoc = pDocShell ? pDocShell->GetDoc() : pDoc; if (sCharFormatName.isEmpty()) { @@ -1956,7 +1959,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( OUString uTmp; rProp.Value >>= uTmp; OUString sStyleName; - SwStyleNameMapper::FillUIName(uTmp, sStyleName, SwGetPoolIdFromName::TxtColl ); + SwStyleNameMapper::FillUIName(ProgName(uTmp), sStyleName, SwGetPoolIdFromName::TxtColl ); *pParagraphStyleName = sStyleName; } } @@ -2093,7 +2096,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( OUString uTmp; rProp.Value >>= uTmp; OUString sStyleName; - SwStyleNameMapper::FillUIName(uTmp, sStyleName, SwGetPoolIdFromName::TxtColl ); + SwStyleNameMapper::FillUIName(ProgName(uTmp), sStyleName, SwGetPoolIdFromName::TxtColl ); *pHeadingStyleName = sStyleName; } } @@ -2173,9 +2176,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat( && !aFormat.GetCharFormat() && !SwXNumberingRules::isInvalidStyle(rCharStyleName)) { - OUString tmp; + ProgName tmp; SwStyleNameMapper::FillProgName(RES_POOLCHR_BULLET_LEVEL, tmp); - rCharStyleName = tmp; + rCharStyleName = tmp.toString(); } if(bWrongArg) @@ -2320,17 +2323,17 @@ OUString SwXNumberingRules::getName() { if(m_pNumRule) { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(m_pNumRule->GetName(), aString, SwGetPoolIdFromName::NumRule ); - return aString; + return aString.toString(); } // consider chapter numbering <SwXNumberingRules> if ( m_pDocShell ) { - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName( m_pDocShell->GetDoc()->GetOutlineNumRule()->GetName(), aString, SwGetPoolIdFromName::NumRule ); - return aString; + return aString.toString(); } return m_sCreatedNumRuleName; } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 1209470951bb..791b5ef41050 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -128,6 +128,7 @@ #include <string_view> #include <limits> #include <unotxdoc.hxx> +#include <names.hxx> using namespace css; using namespace css::io; @@ -362,8 +363,9 @@ sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Cell>(const SwDoc& rD const sal_Int32 nAutoFormat = nIndex / rTableTemplateMap.size(); const sal_Int32 nBoxFormat = rTableTemplateMap[nIndex % rTableTemplateMap.size()]; const SwTableAutoFormat& rTableFormat = rAutoFormats[nAutoFormat]; - SwStyleNameMapper::FillProgName(rTableFormat.GetName(), *pString, SwGetPoolIdFromName::TabStyle); - *pString += rTableFormat.GetTableTemplateCellSubName(rTableFormat.GetBoxFormat(nBoxFormat)); + ProgName aProgName; + SwStyleNameMapper::FillProgName(rTableFormat.GetName(), aProgName, SwGetPoolIdFromName::TabStyle); + *pString = aProgName.toString() + rTableFormat.GetTableTemplateCellSubName(rTableFormat.GetBoxFormat(nBoxFormat)); } else *pString = rDoc.GetCellStyles()[nIndex-nUsedCellStylesCount].GetName(); @@ -913,13 +915,13 @@ uno::Any SwXStyleFamily::getByIndex(sal_Int32 nIndex) if(!m_pBasePool) throw uno::RuntimeException(); - OUString sStyleProgName; + ProgName sStyleProgName; try { SwStyleNameMapper::FillProgName(m_rEntry.translateIndex(nIndex), sStyleProgName); } catch(...) {} if (!sStyleProgName.isEmpty()) - return getByName(sStyleProgName); + return getByName(sStyleProgName.toString()); OUString sStyleUIName; GetCountOrName(&sStyleUIName, nIndex); @@ -965,7 +967,7 @@ rtl::Reference<SwXBaseStyle> SwXStyleFamily::getStyleByName(const OUString& rPro if(!m_pBasePool) throw uno::RuntimeException(); OUString sStyleName; - SwStyleNameMapper::FillUIName(rProgName, sStyleName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sStyleName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.family()); if(!pBase) throw container::NoSuchElementException(rProgName); @@ -1010,9 +1012,9 @@ uno::Sequence<OUString> SwXStyleFamily::getElementNames() std::unique_ptr<SfxStyleSheetIterator> pIt = m_pBasePool->CreateIterator(m_rEntry.family()); for (SfxStyleSheetBase* pStyle = pIt->First(); pStyle; pStyle = pIt->Next()) { - OUString sName; + ProgName sName; SwStyleNameMapper::FillProgName(pStyle->GetName(), sName, m_rEntry.poolId()); - vRet.push_back(sName); + vRet.push_back(sName.toString()); } return comphelper::containerToSequence(vRet); } @@ -1023,7 +1025,7 @@ sal_Bool SwXStyleFamily::hasByName(const OUString& rProgName) if(!m_pBasePool) throw uno::RuntimeException(); OUString sStyleName; - SwStyleNameMapper::FillUIName(rProgName, sStyleName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sStyleName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.family()); return nullptr != pBase; } @@ -1034,7 +1036,7 @@ void SwXStyleFamily::insertStyleByName(const OUString& rProgName, const rtl::Ref if(!m_pBasePool) throw uno::RuntimeException(); OUString sStyleName; - SwStyleNameMapper::FillUIName(rProgName, sStyleName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sStyleName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.family()); if (pBase) throw container::ElementExistException(); @@ -1047,7 +1049,7 @@ void SwXStyleFamily::insertByName(const OUString& rProgName, const uno::Any& rEl if(!m_pBasePool) throw uno::RuntimeException(); OUString sStyleName; - SwStyleNameMapper::FillUIName(rProgName, sStyleName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sStyleName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.family()); if (pBase) throw container::ElementExistException(); @@ -1110,7 +1112,7 @@ void SwXStyleFamily::replaceByName(const OUString& rProgName, const uno::Any& rE if(!m_pBasePool) throw uno::RuntimeException(); OUString sStyleName; - SwStyleNameMapper::FillUIName(rProgName, sStyleName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sStyleName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.family()); // replacements only for userdefined styles if(!pBase) @@ -1171,7 +1173,7 @@ void SwXStyleFamily::removeByName(const OUString& rProgName) if(!m_pBasePool) throw uno::RuntimeException(); OUString sName; - SwStyleNameMapper::FillUIName(rProgName, sName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sName, m_rEntry.poolId()); SfxStyleSheetBase* pBase = m_pBasePool->Find(sName, m_rEntry.family()); if(!pBase) throw container::NoSuchElementException(); @@ -1391,17 +1393,17 @@ OUString SwXStyle::getName() SolarMutexGuard aGuard; if(!m_pBasePool) { - OUString ret; + ProgName ret; SwStyleNameMapper::FillProgName(m_sStyleUIName, ret, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); - return ret; + return ret.toString(); } SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleUIName, m_rEntry.family()); SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); if(!pBase) throw uno::RuntimeException(); - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.family())); - return aString; + return aString.toString(); } void SwXStyle::setName(const OUString& rProgName) @@ -1411,7 +1413,7 @@ void SwXStyle::setName(const OUString& rProgName) { // it looks like a descriptor style with a built-in name cannot be // inserted into the document anyway - just convert name for consistency - SwStyleNameMapper::FillUIName(rProgName, m_sStyleUIName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), m_sStyleUIName, m_rEntry.poolId()); return; } SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleUIName, m_rEntry.family()); @@ -1420,7 +1422,7 @@ void SwXStyle::setName(const OUString& rProgName) throw uno::RuntimeException(); OUString sUIName; // conversion should actually be irrelevant due to IsUserDefined() check - SwStyleNameMapper::FillUIName(rProgName, sUIName, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sUIName, m_rEntry.poolId()); rtl::Reference<SwDocStyleSheet> xTmp(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); if (!xTmp->SetName(sUIName)) throw uno::RuntimeException(); @@ -1449,27 +1451,27 @@ sal_Bool SwXStyle::isInUse() OUString SwXStyle::getParentStyle() { SolarMutexGuard aGuard; + ProgName ret; if(!m_pBasePool) { if(!m_bIsDescriptor) throw uno::RuntimeException(); - OUString ret; SwStyleNameMapper::FillProgName(m_sParentStyleUIName, ret, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); - return ret; + return ret.toString(); } SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleUIName, m_rEntry.family()); OUString aString; if(pBase) aString = pBase->GetParent(); - SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); - return aString; + SwStyleNameMapper::FillProgName(aString, ret, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); + return ret.toString(); } void SwXStyle::setParentStyle(const OUString& rParentStyleProgName) { SolarMutexGuard aGuard; OUString sParentStyle; - SwStyleNameMapper::FillUIName(rParentStyleProgName, sParentStyle, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); + SwStyleNameMapper::FillUIName(ProgName(rParentStyleProgName), sParentStyle, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); if(!m_pBasePool) { if(!m_bIsDescriptor) @@ -1782,7 +1784,7 @@ void SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>(const SfxItemPropertyMapEnt return; const auto sValue(rValue.get<OUString>()); OUString aString; - SwStyleNameMapper::FillUIName(sValue, aString, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(sValue), aString, m_rEntry.poolId()); o_rStyleBase.getNewBase()->SetFollow(aString); } @@ -1796,7 +1798,7 @@ void SwXStyle::SetPropertyValue<FN_UNO_LINK_STYLE>(const SfxItemPropertyMapEntry return; const auto sValue(rValue.get<OUString>()); OUString aString; - SwStyleNameMapper::FillUIName(sValue, aString, m_rEntry.poolId()); + SwStyleNameMapper::FillUIName(ProgName(sValue), aString, m_rEntry.poolId()); o_rStyleBase.getNewBase()->SetLink(aString); } @@ -1819,7 +1821,7 @@ void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAGEDESC)>(const SfxItemPropertyM pNewDesc.reset(new SwFormatPageDesc); const auto sValue(rValue.get<OUString>()); OUString sDescName; - SwStyleNameMapper::FillUIName(sValue, sDescName, SwGetPoolIdFromName::PageDesc); + SwStyleNameMapper::FillUIName(ProgName(sValue), sDescName, SwGetPoolIdFromName::PageDesc); if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName) return; if(sDescName.isEmpty()) @@ -1878,7 +1880,7 @@ void SwXStyle::SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>(const SfxItemPrope const OUString sValue(rNamedValue.Value.get<OUString>()); // get UI style name from programmatic style name OUString aStyleName; - SwStyleNameMapper::FillUIName(sValue, aStyleName, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); + SwStyleNameMapper::FillUIName(ProgName(sValue), aStyleName, lcl_GetSwEnumFromSfxEnum(m_rEntry.family())); // check for correct context and style name const auto nIdx(GetCommandContextIndex(rNamedValue.Name)); @@ -1922,7 +1924,7 @@ void SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>(const SfxItemProperty aReg.SetWhich(SID_SWREGISTER_MODE); o_rStyleBase.GetItemSet().Put(aReg); OUString aString; - SwStyleNameMapper::FillUIName(sName, aString, SwGetPoolIdFromName::TxtColl); + SwStyleNameMapper::FillUIName(ProgName(sName), aString, SwGetPoolIdFromName::TxtColl); o_rStyleBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) ); } template<> @@ -1940,7 +1942,7 @@ void SwXStyle::SetPropertyValue<sal_uInt16(RES_TXTATR_CJK_RUBY)>(const SfxItemPr else pRuby.reset(new SwFormatRuby(OUString())); OUString sStyle; - SwStyleNameMapper::FillUIName(sValue, sStyle, SwGetPoolIdFromName::ChrFmt); + SwStyleNameMapper::FillUIName(ProgName(sValue), sStyle, SwGetPoolIdFromName::ChrFmt); pRuby->SetCharFormatName(sStyle); pRuby->SetCharFormatId(0); if(!sValue.isEmpty()) @@ -1969,7 +1971,7 @@ void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_DROP)>(const SfxItemProper pDrop.reset(new SwFormatDrop); const auto sValue(rValue.get<OUString>()); OUString sStyle; - SwStyleNameMapper::FillUIName(sValue, sStyle, SwGetPoolIdFromName::ChrFmt); + SwStyleNameMapper::FillUIName(ProgName(sValue), sStyle, SwGetPoolIdFromName::ChrFmt); SwDocStyleSheet* pStyle = nullptr; if (SwDocShell* pShell = m_pDoc->GetDocShell()) pStyle = static_cast<SwDocStyleSheet*>(pShell->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)); @@ -2190,9 +2192,9 @@ template<> uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) { PrepareStyleBase(rBase); - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum(GetFamily())); - return uno::Any(aString); + return uno::Any(aString.toString()); } template <> @@ -2201,10 +2203,10 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_LINK_STYLE>(const SfxItemPropertyMapE SwStyleBase_Impl& rBase) { PrepareStyleBase(rBase); - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetLink(), aString, lcl_GetSwEnumFromSfxEnum(GetFamily())); - return uno::Any(aString); + return uno::Any(aString.toString()); } template<> @@ -2221,9 +2223,9 @@ uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAGEDESC)>(const SfxItemPrope const SwPageDesc* pDesc = pItem->GetPageDesc(); if(!pDesc) return uno::Any(); - OUString aString; + ProgName aString; SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, SwGetPoolIdFromName::PageDesc); - return uno::Any(aString); + return uno::Any(aString.toString()); } template<> uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_AUTO_UPDATE>(const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) @@ -2265,9 +2267,10 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(const SfxItemP if(!pCond || !pCond->GetTextFormatColl()) continue; // get programmatic style name from UI style name - OUString aStyleName = pCond->GetTextFormatColl()->GetName(); - SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum(GetFamily())); - pSeq[n].Value <<= aStyleName; + OUString aStyleUIName = pCond->GetTextFormatColl()->GetName(); + ProgName aStyleProgName; + SwStyleNameMapper::FillProgName(aStyleUIName, aStyleProgName, lcl_GetSwEnumFromSfxEnum(GetFamily())); + pSeq[n].Value <<= aStyleProgName.toString(); } } return uno::Any(aSeq); @@ -2298,9 +2301,9 @@ uno::Any SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>(const SfxItemProp const SwTextFormatColl* pCol = pPageDesc->GetRegisterFormatColl(); if(!pCol) return uno::Any(OUString()); - OUString aName; + ProgName aName; SwStyleNameMapper::FillProgName(pCol->GetName(), aName, SwGetPoolIdFromName::TxtColl); - return uno::Any(aName); + return uno::Any(aName.toString()); } template<> uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>(const SfxItemPropertyMapEntry& rEntry, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) @@ -4592,16 +4595,16 @@ void SAL_CALL SwXTextTableStyle::setParentStyle(const OUString& /*aParentStyle*/ OUString SAL_CALL SwXTextTableStyle::getName() { SolarMutexGuard aGuard; - OUString sProgName; + ProgName sProgName; SwStyleNameMapper::FillProgName(m_pTableAutoFormat->GetName(), sProgName, SwGetPoolIdFromName::TabStyle); - return sProgName; + return sProgName.toString(); } void SAL_CALL SwXTextTableStyle::setName(const OUString& rProgName) { SolarMutexGuard aGuard; OUString sUIName; - SwStyleNameMapper::FillUIName(rProgName, sUIName, SwGetPoolIdFromName::TabStyle); + SwStyleNameMapper::FillUIName(ProgName(rProgName), sUIName, SwGetPoolIdFromName::TabStyle); m_pTableAutoFormat->SetName(sUIName); } @@ -4815,14 +4818,14 @@ SwBoxAutoFormat* SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, std:: if (!pBoxAutoFormat) { sal_Int32 nTemplateIndex; - OUString sParentName; + OUString sParentProgName; std::u16string_view sCellSubName; size_t nSeparatorIndex = sName.rfind('.'); if (nSeparatorIndex == std::u16string_view::npos) return nullptr; - sParentName = sName.substr(0, nSeparatorIndex); + sParentProgName = sName.substr(0, nSeparatorIndex); sCellSubName = sName.substr(nSeparatorIndex+1); nTemplateIndex = o3tl::toInt32(sCellSubName)-1; // -1 because cell styles names start from 1, but internally are indexed from 0 if (0 > nTemplateIndex) @@ -4832,13 +4835,14 @@ SwBoxAutoFormat* SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, std:: if (rTableTemplateMap.size() <= o3tl::make_unsigned(nTemplateIndex)) return nullptr; - SwStyleNameMapper::FillUIName(sParentName, sParentName, SwGetPoolIdFromName::TabStyle); - SwTableAutoFormat* pTableAutoFormat = pDocShell->GetDoc()->GetTableStyles().FindAutoFormat(sParentName); + OUString sParentUIName; + SwStyleNameMapper::FillUIName(ProgName(sParentProgName), sParentUIName, SwGetPoolIdFromName::TabStyle); + SwTableAutoFormat* pTableAutoFormat = pDocShell->GetDoc()->GetTableStyles().FindAutoFormat(sParentUIName); if (!pTableAutoFormat) return nullptr; if (pParentName) - *pParentName = sParentName; + *pParentName = sParentUIName; sal_uInt32 nBoxIndex = rTableTemplateMap[nTemplateIndex]; pBoxAutoFormat = &pTableAutoFormat->GetBoxFormat(nBoxIndex); } @@ -4903,10 +4907,10 @@ sal_Bool SAL_CALL SwXTextCellStyle::isInUse() if (!xTableStyles.is()) return false; - OUString sParentStyle; -e ... etc. - the rest is truncated