diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-12-18 14:32:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-12-18 18:18:57 +0100 |
commit | d05a74234d5ab6b029618281908552066fe04fa4 (patch) | |
tree | f4d3074d2d1ba9d53f9f0310bec7c2a32a20b3cd /xmloff | |
parent | 164fb25f7b2db7d833d6d0f28e49c5cac68426b3 (diff) |
unique_ptr->optional in XMLTextFieldExport
Change-Id: I161fd82784dfbb19ff42f83cacc24bf4b347206c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160911
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtflde.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 24 |
2 files changed, 15 insertions, 14 deletions
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index f98fb7c5c421..f21b85eb1b2a 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -32,6 +32,7 @@ #include <map> #include <set> #include <memory> +#include <optional> #include <string_view> #include "txtfld.hxx" @@ -154,10 +155,10 @@ class XMLTextFieldExport final SvXMLExport& rExport; /// store used text field master names (NULL means: don't collect) - std::unique_ptr< ::std::map< + std::optional< ::std::map< css::uno::Reference< css::text::XText >, ::std::set< OUString > > > - pUsedMasters; + moUsedMasters; public: diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 2c054d57e3f6..0beab8dd8994 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -760,7 +760,7 @@ void XMLTextFieldExport::ExportFieldAutoStyle( Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY); // add field master to list of used field masters (if desired) - if (nullptr != pUsedMasters) + if (moUsedMasters) { Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY); if (xDepField.is()) @@ -770,14 +770,14 @@ void XMLTextFieldExport::ExportFieldAutoStyle( Reference<XText> xOurText = GetToplevelText(rTextField->getAnchor()->getText()); std::map<Reference<XText>, std::set<OUString> >::iterator aMapIter = - pUsedMasters->find(xOurText); + moUsedMasters->find(xOurText); // insert a list for our XText (if necessary) - if (aMapIter == pUsedMasters->end()) + if (aMapIter == moUsedMasters->end()) { std::set<OUString> aSet; - (*pUsedMasters)[xOurText] = aSet; - aMapIter = pUsedMasters->find(xOurText); + (*moUsedMasters)[xOurText] = aSet; + aMapIter = moUsedMasters->find(xOurText); } // insert this text field master @@ -1973,18 +1973,18 @@ void XMLTextFieldExport::ExportFieldDeclarations( if (rText.is()) { // export only used masters - DBG_ASSERT(nullptr != pUsedMasters, + DBG_ASSERT(moUsedMasters.has_value(), "field masters must be recorded in order to be " "written out separately" ); - if (nullptr != pUsedMasters) + if (moUsedMasters) { std::map<Reference<XText>, std::set<OUString> > ::iterator aMapIter = - pUsedMasters->find(rText); - if (aMapIter != pUsedMasters->end()) + moUsedMasters->find(rText); + if (aMapIter != moUsedMasters->end()) { // found the set of used field masters aFieldMasters = comphelper::containerToSequence(aMapIter->second); - pUsedMasters->erase(rText); + moUsedMasters->erase(rText); } // else: XText not found -> ignore } @@ -2244,11 +2244,11 @@ void XMLTextFieldExport::ExportFieldDeclarations( void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations( bool bExportOnlyUsed) { - pUsedMasters.reset(); + moUsedMasters.reset(); // create used masters set (if none is used) if (bExportOnlyUsed) - pUsedMasters.reset( new std::map<Reference<XText>, std::set<OUString> > ); + moUsedMasters.emplace(); } void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName, |