sw/source/uibase/uno/loktxdoc.cxx | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
New commits: commit 5dd9775d775275271de3e2cd6362c73f16032a73 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jun 25 01:28:03 2025 +0500 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jun 25 08:58:16 2025 +0200 Drop some one-time-use constants; use the strings inline. Helps to see some detalis, that may not be obvious with constants: e.g., the order of ".uno:TextFormFields" and ".uno:TextFormField", of ".uno:Bookmarks" and ".uno:Bookmark" is important, because the check is not equality, but starts_with. Change-Id: Ia67bf182f19305ca393421111e4f2e9bdeaeaa5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186919 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 84baaf58ce1d04a48e600bccd08d78470b475f61) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186922 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/uibase/uno/loktxdoc.cxx b/sw/source/uibase/uno/loktxdoc.cxx index d9a782495e48..8891709d442d 100644 --- a/sw/source/uibase/uno/loktxdoc.cxx +++ b/sw/source/uibase/uno/loktxdoc.cxx @@ -967,57 +967,47 @@ bool SwXTextDocument::supportsCommand(std::u16string_view rCommand) void SwXTextDocument::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) { - static constexpr OStringLiteral aTextFormFields(".uno:TextFormFields"); - static constexpr OStringLiteral aTextFormField(".uno:TextFormField"); - static constexpr OStringLiteral aSetDocumentProperties(".uno:SetDocumentProperties"); - static constexpr OStringLiteral aBookmarks(".uno:Bookmarks"); - static constexpr OStringLiteral aFields(".uno:Fields"); - static constexpr OStringLiteral aSections(".uno:Sections"); - static constexpr OStringLiteral aBookmark(".uno:Bookmark"); - static constexpr OStringLiteral aField(".uno:Field"); - static constexpr OStringLiteral aExtractDocStructure(".uno:ExtractDocumentStructure"); - static constexpr OStringLiteral aLayout(".uno:Layout"); - + using namespace std::string_view_literals; std::map<OUString, OUString> aMap = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand)); - if (o3tl::starts_with(rCommand, aTextFormFields)) + if (o3tl::starts_with(rCommand, ".uno:TextFormFields"sv)) { GetTextFormFields(rJsonWriter, m_pDocShell, aMap); } - if (o3tl::starts_with(rCommand, aTextFormField)) + if (o3tl::starts_with(rCommand, ".uno:TextFormField"sv)) { GetTextFormField(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aSetDocumentProperties)) + else if (o3tl::starts_with(rCommand, ".uno:SetDocumentProperties"sv)) { GetDocumentProperties(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aBookmarks)) + else if (o3tl::starts_with(rCommand, ".uno:Bookmarks"sv)) { GetBookmarks(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aFields)) + else if (o3tl::starts_with(rCommand, ".uno:Fields"sv)) { GetFields(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aSections)) + else if (o3tl::starts_with(rCommand, ".uno:Sections"sv)) { GetSections(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aBookmark)) + else if (o3tl::starts_with(rCommand, ".uno:Bookmark"sv)) { GetBookmark(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aField)) + else if (o3tl::starts_with(rCommand, ".uno:Field"sv)) { GetField(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aExtractDocStructure)) + else if (o3tl::starts_with(rCommand, ".uno:ExtractDocumentStructure"sv)) { GetDocStructure(rJsonWriter, m_pDocShell, aMap); } - else if (o3tl::starts_with(rCommand, aLayout)) + else if (o3tl::starts_with(rCommand, ".uno:Layout"sv)) { GetLayout(rJsonWriter, m_pDocShell); }