[Libreoffice-commits] core.git: 2 commits - xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 6 08:15:58 UTC 2020


 xmloff/source/core/ProgressBarHelper.cxx                        |   80 -
 xmloff/source/core/XMLEmbeddedObjectImportContext.cxx           |   64 -
 xmloff/source/core/xmlexp.cxx                                   |  478 +++++-----
 xmloff/source/core/xmlimp.cxx                                   |  157 +--
 xmloff/source/core/xmluconv.cxx                                 |  110 +-
 xmloff/source/forms/elementexport.cxx                           |   64 -
 xmloff/source/forms/elementimport.cxx                           |  115 +-
 xmloff/source/forms/layerexport.cxx                             |   42 
 xmloff/source/forms/layerimport.cxx                             |   58 -
 xmloff/source/meta/xmlmetae.cxx                                 |   70 -
 xmloff/source/meta/xmlmetai.cxx                                 |    5 
 xmloff/source/meta/xmlversion.cxx                               |   62 -
 xmloff/source/script/XMLEventExport.cxx                         |   56 -
 xmloff/source/script/XMLEventImportHelper.cxx                   |   28 
 xmloff/source/table/XMLTableExport.cxx                          |   26 
 xmloff/source/table/XMLTableImport.cxx                          |   40 
 xmloff/source/text/XMLChangedRegionImportContext.cxx            |   30 
 xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx    |   30 
 xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx |   60 -
 xmloff/source/text/XMLIndexTOCStylesContext.cxx                 |   34 
 xmloff/source/text/XMLIndexTemplateContext.cxx                  |   76 -
 xmloff/source/text/XMLLineNumberingExport.cxx                   |  239 ++---
 xmloff/source/text/XMLLineNumberingImportContext.cxx            |   72 -
 xmloff/source/text/XMLPropertyBackpatcher.cxx                   |   28 
 xmloff/source/text/XMLRedlineExport.cxx                         |  224 ++--
 xmloff/source/text/XMLSectionExport.cxx                         |  464 ++++-----
 xmloff/source/text/XMLSectionFootnoteConfigExport.cxx           |   84 -
 xmloff/source/text/XMLSectionImportContext.cxx                  |  166 +--
 xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx       |   36 
 xmloff/source/text/XMLTextFrameContext.cxx                      |  219 ++--
 xmloff/source/text/XMLTextHeaderFooterContext.cxx               |   62 -
 xmloff/source/text/XMLTextListBlockContext.cxx                  |  142 +-
 xmloff/source/text/XMLTextMarkImportContext.cxx                 |  388 ++++----
 xmloff/source/text/XMLTextMasterPageContext.cxx                 |  130 +-
 xmloff/source/text/txtexppr.cxx                                 |  122 +-
 xmloff/source/text/txtflde.cxx                                  |  118 +-
 xmloff/source/text/txtfldi.cxx                                  |  300 +++---
 xmloff/source/text/txtftne.cxx                                  |   46 
 xmloff/source/text/txtimppr.cxx                                 |   66 -
 xmloff/source/text/txtlists.cxx                                 |   26 
 xmloff/source/text/txtparae.cxx                                 |  360 +++----
 xmloff/source/text/txtparai.cxx                                 |   88 -
 xmloff/source/text/txtstyli.cxx                                 |   32 
 xmloff/source/text/txtvfldi.cxx                                 |  155 +--
 xmloff/source/xforms/xformsexport.cxx                           |   22 
 45 files changed, 2640 insertions(+), 2634 deletions(-)

New commits:
commit 04336ca32ea08f0c0c78125ea3b07689ee51acf2
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 6 09:16:48 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 6 10:15:29 2020 +0200

    loplugin:flatten in xmloff/text
    
    Change-Id: Iffadbe50a3b1e8263725b8f22395c5eaac11534d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100199
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx
index 44f68d98d2de..2d2050976b69 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.cxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx
@@ -160,24 +160,24 @@ void XMLChangedRegionImportContext::SetChangeInfo(
 void XMLChangedRegionImportContext::UseRedlineText()
 {
     // if we haven't already installed the redline cursor, do it now
-    if (! xOldCursor.is())
-    {
-        // get TextImportHelper and old Cursor
-        rtl::Reference<XMLTextImportHelper> rHelper(GetImport().GetTextImport());
-        Reference<XTextCursor> xCursor( rHelper->GetCursor() );
+    if ( xOldCursor.is())
+        return;
 
-        // create Redline and new Cursor
-        Reference<XTextCursor> xNewCursor =
-            rHelper->RedlineCreateText(xCursor, sID);
+    // get TextImportHelper and old Cursor
+    rtl::Reference<XMLTextImportHelper> rHelper(GetImport().GetTextImport());
+    Reference<XTextCursor> xCursor( rHelper->GetCursor() );
 
-        if (xNewCursor.is())
-        {
-            // save old cursor and install new one
-            xOldCursor = xCursor;
-            rHelper->SetCursor( xNewCursor );
-        }
-        // else: leave as is
+    // create Redline and new Cursor
+    Reference<XTextCursor> xNewCursor =
+        rHelper->RedlineCreateText(xCursor, sID);
+
+    if (xNewCursor.is())
+    {
+        // save old cursor and install new one
+        xOldCursor = xCursor;
+        rHelper->SetCursor( xNewCursor );
     }
+    // else: leave as is
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
index 05764ebd0fb9..7245750f9edd 100644
--- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
+++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx
@@ -320,25 +320,25 @@ SvXMLImportContextRef XMLFootnoteConfigurationImportContext::CreateChildContext(
 void XMLFootnoteConfigurationImportContext::Finish( bool bOverwrite )
 {
 
-    if (bOverwrite)
+    if (!bOverwrite)
+        return;
+
+    if (bIsEndnote)
     {
-        if (bIsEndnote)
+        Reference<XEndnotesSupplier> xSupplier(
+            GetImport().GetModel(), UNO_QUERY);
+        if (xSupplier.is())
         {
-            Reference<XEndnotesSupplier> xSupplier(
-                GetImport().GetModel(), UNO_QUERY);
-            if (xSupplier.is())
-            {
-                ProcessSettings(xSupplier->getEndnoteSettings());
-            }
+            ProcessSettings(xSupplier->getEndnoteSettings());
         }
-        else
+    }
+    else
+    {
+        Reference<XFootnotesSupplier> xSupplier(
+            GetImport().GetModel(), UNO_QUERY);
+        if (xSupplier.is())
         {
-            Reference<XFootnotesSupplier> xSupplier(
-                GetImport().GetModel(), UNO_QUERY);
-            if (xSupplier.is())
-            {
-                ProcessSettings(xSupplier->getFootnoteSettings());
-            }
+            ProcessSettings(xSupplier->getFootnoteSettings());
         }
     }
     // else: ignore (there's only one configuration, so we can only overwrite)
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 80a1369a7152..24d1912b8939 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -204,41 +204,41 @@ void XMLIndexBibliographyConfigurationContext::CreateAndInsert(bool)
     // first: get field master
     // (we'll create one, and get the only master for this type)
     Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY);
-    if( xFactory.is() )
-    {
-        Sequence<OUString> aServices = xFactory->getAvailableServiceNames();
-        // here we should use a method which compares in reverse order if available
-        if (comphelper::findValue(aServices, gsFieldMaster_Bibliography) != -1)
-        {
-            Reference<XInterface> xIfc =
-                xFactory->createInstance(gsFieldMaster_Bibliography);
-            if( xIfc.is() )
-            {
-                Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY );
-                Any aAny;
+    if( !xFactory.is() )
+        return;
 
-                xPropSet->setPropertyValue(gsBracketAfter, Any(sSuffix));
-                xPropSet->setPropertyValue(gsBracketBefore, Any(sPrefix));
-                xPropSet->setPropertyValue(gsIsNumberEntries, Any(bNumberedEntries));
-                xPropSet->setPropertyValue(gsIsSortByPosition, Any(bSortByPosition));
+    Sequence<OUString> aServices = xFactory->getAvailableServiceNames();
+    // here we should use a method which compares in reverse order if available
+    if (comphelper::findValue(aServices, gsFieldMaster_Bibliography) == -1)
+        return;
 
-                if( !maLanguageTagODF.isEmpty() )
-                {
-                    aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
-                    xPropSet->setPropertyValue(gsLocale, aAny);
-                }
+    Reference<XInterface> xIfc =
+        xFactory->createInstance(gsFieldMaster_Bibliography);
+    if( !xIfc.is() )
+        return;
 
-                if( !sAlgorithm.isEmpty() )
-                {
-                    xPropSet->setPropertyValue(gsSortAlgorithm, Any(sAlgorithm));
-                }
+    Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY );
+    Any aAny;
 
-                Sequence<Sequence<PropertyValue> > aKeysSeq = comphelper::containerToSequence(aSortKeys);
-                xPropSet->setPropertyValue(gsSortKeys, Any(aKeysSeq));
-            }
-            // else: can't get FieldMaster -> ignore
-        }
+    xPropSet->setPropertyValue(gsBracketAfter, Any(sSuffix));
+    xPropSet->setPropertyValue(gsBracketBefore, Any(sPrefix));
+    xPropSet->setPropertyValue(gsIsNumberEntries, Any(bNumberedEntries));
+    xPropSet->setPropertyValue(gsIsSortByPosition, Any(bSortByPosition));
+
+    if( !maLanguageTagODF.isEmpty() )
+    {
+        aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
+        xPropSet->setPropertyValue(gsLocale, aAny);
     }
+
+    if( !sAlgorithm.isEmpty() )
+    {
+        xPropSet->setPropertyValue(gsSortAlgorithm, Any(sAlgorithm));
+    }
+
+    Sequence<Sequence<PropertyValue> > aKeysSeq = comphelper::containerToSequence(aSortKeys);
+    xPropSet->setPropertyValue(gsSortKeys, Any(aKeysSeq));
+    // else: can't get FieldMaster -> ignore
     // else: can't even get Factory -> ignore
 }
 
diff --git a/xmloff/source/text/XMLIndexTOCStylesContext.cxx b/xmloff/source/text/XMLIndexTOCStylesContext.cxx
index f310776dfee0..ed0b77f41cd5 100644
--- a/xmloff/source/text/XMLIndexTOCStylesContext.cxx
+++ b/xmloff/source/text/XMLIndexTOCStylesContext.cxx
@@ -85,26 +85,26 @@ void XMLIndexTOCStylesContext::StartElement(
 void XMLIndexTOCStylesContext::EndElement()
 {
     // if valid...
-    if (nOutlineLevel >= 0)
+    if (nOutlineLevel < 0)
+        return;
+
+    // copy vector into sequence
+    const sal_Int32 nCount = aStyleNames.size();
+    Sequence<OUString> aStyleNamesSequence(nCount);
+    for(sal_Int32 i = 0; i < nCount; i++)
     {
-        // copy vector into sequence
-        const sal_Int32 nCount = aStyleNames.size();
-        Sequence<OUString> aStyleNamesSequence(nCount);
-        for(sal_Int32 i = 0; i < nCount; i++)
-        {
-            aStyleNamesSequence[i] = GetImport().GetStyleDisplayName(
-                            XmlStyleFamily::TEXT_PARAGRAPH,
-                               aStyleNames[i] );
-        }
+        aStyleNamesSequence[i] = GetImport().GetStyleDisplayName(
+                        XmlStyleFamily::TEXT_PARAGRAPH,
+                           aStyleNames[i] );
+    }
 
-        // get index replace
-        Any aAny = rTOCPropertySet->getPropertyValue("LevelParagraphStyles");
-        Reference<XIndexReplace> xIndexReplace;
-        aAny >>= xIndexReplace;
+    // get index replace
+    Any aAny = rTOCPropertySet->getPropertyValue("LevelParagraphStyles");
+    Reference<XIndexReplace> xIndexReplace;
+    aAny >>= xIndexReplace;
 
-        // set style names
-        xIndexReplace->replaceByIndex(nOutlineLevel, Any(aStyleNamesSequence));
-    }
+    // set style names
+    xIndexReplace->replaceByIndex(nOutlineLevel, Any(aStyleNamesSequence));
 }
 
 SvXMLImportContextRef XMLIndexTOCStylesContext::CreateChildContext(
diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx
index 5d3ec9b12d4f..f0aac4bb3563 100644
--- a/xmloff/source/text/XMLIndexTemplateContext.cxx
+++ b/xmloff/source/text/XMLIndexTemplateContext.cxx
@@ -142,46 +142,46 @@ void XMLIndexTemplateContext::StartElement(
 
 void XMLIndexTemplateContext::EndElement()
 {
-    if (bOutlineLevelOK)
-    {
-        const sal_Int32 nCount = aValueVector.size();
-        Sequence<PropertyValues> aValueSequence(nCount);
-        for(sal_Int32 i = 0; i<nCount; i++)
-        {
-            aValueSequence[i] = aValueVector[i];
-        }
-
-        // get LevelFormat IndexReplace ...
-        Any aAny = rPropertySet->getPropertyValue("LevelFormat");
-        Reference<XIndexReplace> xIndexReplace;
-        aAny >>= xIndexReplace;
+    if (!bOutlineLevelOK)
+        return;
 
-        // ... and insert
-        xIndexReplace->replaceByIndex(nOutlineLevel, Any(aValueSequence));
-
-        if (bStyleNameOK)
-        {
-            const char* pStyleProperty =
-                pOutlineLevelStylePropMap[nOutlineLevel];
+    const sal_Int32 nCount = aValueVector.size();
+    Sequence<PropertyValues> aValueSequence(nCount);
+    for(sal_Int32 i = 0; i<nCount; i++)
+    {
+        aValueSequence[i] = aValueVector[i];
+    }
 
-            DBG_ASSERT(nullptr != pStyleProperty, "need property name");
-            if (nullptr != pStyleProperty)
-            {
-                OUString sDisplayStyleName =
-                        GetImport().GetStyleDisplayName(
-                        XmlStyleFamily::TEXT_PARAGRAPH,
-                        sStyleName );
-                // #i50288#: Check if style exists
-                const Reference < css::container::XNameContainer > & rStyles =
-                    GetImport().GetTextImport()->GetParaStyles();
-                if( rStyles.is() &&
-                    rStyles->hasByName( sDisplayStyleName ) )
-                {
-                    rPropertySet->setPropertyValue(
-                        OUString::createFromAscii(pStyleProperty), css::uno::Any(sDisplayStyleName));
-                }
-            }
-        }
+    // get LevelFormat IndexReplace ...
+    Any aAny = rPropertySet->getPropertyValue("LevelFormat");
+    Reference<XIndexReplace> xIndexReplace;
+    aAny >>= xIndexReplace;
+
+    // ... and insert
+    xIndexReplace->replaceByIndex(nOutlineLevel, Any(aValueSequence));
+
+    if (!bStyleNameOK)
+        return;
+
+    const char* pStyleProperty =
+        pOutlineLevelStylePropMap[nOutlineLevel];
+
+    DBG_ASSERT(nullptr != pStyleProperty, "need property name");
+    if (nullptr == pStyleProperty)
+        return;
+
+    OUString sDisplayStyleName =
+            GetImport().GetStyleDisplayName(
+            XmlStyleFamily::TEXT_PARAGRAPH,
+            sStyleName );
+    // #i50288#: Check if style exists
+    const Reference < css::container::XNameContainer > & rStyles =
+        GetImport().GetTextImport()->GetParaStyles();
+    if( rStyles.is() &&
+        rStyles->hasByName( sDisplayStyleName ) )
+    {
+        rPropertySet->setPropertyValue(
+            OUString::createFromAscii(pStyleProperty), css::uno::Any(sDisplayStyleName));
     }
 }
 
diff --git a/xmloff/source/text/XMLLineNumberingExport.cxx b/xmloff/source/text/XMLLineNumberingExport.cxx
index 1b39593bb0ab..c531f657ebe3 100644
--- a/xmloff/source/text/XMLLineNumberingExport.cxx
+++ b/xmloff/source/text/XMLLineNumberingExport.cxx
@@ -58,128 +58,127 @@ void XMLLineNumberingExport::Export()
     // export element if we have line numbering info
     Reference<XLineNumberingProperties> xSupplier(rExport.GetModel(),
                                                   UNO_QUERY);
-    if (xSupplier.is())
+    if (!xSupplier.is())
+        return;
+
+    Reference<XPropertySet> xLineNumbering =
+        xSupplier->getLineNumberingProperties();
+
+    if (!xLineNumbering.is())
+        return;
+
+    // char style
+    Any aAny = xLineNumbering->getPropertyValue("CharStyleName");
+    OUString sTmp;
+    aAny >>= sTmp;
+    if (!sTmp.isEmpty())
     {
-        Reference<XPropertySet> xLineNumbering =
-            xSupplier->getLineNumberingProperties();
-
-        if (xLineNumbering.is())
-        {
-            // char style
-            Any aAny = xLineNumbering->getPropertyValue("CharStyleName");
-            OUString sTmp;
-            aAny >>= sTmp;
-            if (!sTmp.isEmpty())
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
-                                     rExport.EncodeStyleName( sTmp ));
-            }
-
-            // enable
-            aAny = xLineNumbering->getPropertyValue("IsOn");
-            if (! *o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_NUMBER_LINES, XML_FALSE);
-            }
-
-            // count empty lines
-            aAny = xLineNumbering->getPropertyValue("CountEmptyLines");
-            if (! *o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_COUNT_EMPTY_LINES, XML_FALSE);
-            }
-
-            // count in frames
-            aAny = xLineNumbering->getPropertyValue("CountLinesInFrames");
-            if (*o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_COUNT_IN_TEXT_BOXES, XML_TRUE);
-            }
-
-            // restart numbering
-            aAny = xLineNumbering->getPropertyValue("RestartAtEachPage");
-            if (*o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_RESTART_ON_PAGE, XML_TRUE);
-            }
-
-            // Distance
-            aAny = xLineNumbering->getPropertyValue("Distance");
-            sal_Int32 nLength = 0;
-            aAny >>= nLength;
-            if (nLength != 0)
-            {
-                OUStringBuffer sBuf;
-                rExport.GetMM100UnitConverter().convertMeasureToXML(
-                        sBuf, nLength);
-                rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET,
-                                     sBuf.makeStringAndClear());
-            }
-
-            // NumberingType
-            OUStringBuffer sNumPosBuf;
-            aAny = xLineNumbering->getPropertyValue("NumberingType");
-            sal_Int16 nFormat = 0;
-            aAny >>= nFormat;
-            rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat );
-            rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
-                                 sNumPosBuf.makeStringAndClear());
-            SvXMLUnitConverter::convertNumLetterSync( sNumPosBuf, nFormat );
-            if( !sNumPosBuf.isEmpty() )
-            {
-                rExport.AddAttribute(XML_NAMESPACE_STYLE,
-                                     XML_NUM_LETTER_SYNC,
-                                     sNumPosBuf.makeStringAndClear() );
-            }
-
-            // number position
-            aAny = xLineNumbering->getPropertyValue("NumberPosition");
-            sal_uInt16 nPosition = 0;
-            aAny >>= nPosition;
-            if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition,
-                                                aLineNumberPositionMap))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION,
-                                     sNumPosBuf.makeStringAndClear());
-            }
-
-            // sInterval
-            aAny = xLineNumbering->getPropertyValue("Interval");
-            sal_Int16 nLineInterval = 0;
-            aAny >>= nLineInterval;
-            rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
-                                 OUString::number(nLineInterval));
-
-            SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT,
-                                           XML_LINENUMBERING_CONFIGURATION,
-                                           true, true);
-
-            // line separator
-            aAny = xLineNumbering->getPropertyValue("SeparatorText");
-            OUString sSeparator;
-            aAny >>= sSeparator;
-            if (!sSeparator.isEmpty())
-            {
-
-                // SeparatorInterval
-                aAny = xLineNumbering->getPropertyValue("SeparatorInterval");
-                sal_Int16 nLineDistance = 0;
-                aAny >>= nLineDistance;
-                rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
-                                     OUString::number(nLineDistance));
-
-                SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT,
-                                                  XML_LINENUMBERING_SEPARATOR,
-                                                  true, false);
-                rExport.Characters(sSeparator);
-            }
-        }
-        // else: no configuration: don't save -> default
+        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
+                             rExport.EncodeStyleName( sTmp ));
     }
+
+    // enable
+    aAny = xLineNumbering->getPropertyValue("IsOn");
+    if (! *o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_NUMBER_LINES, XML_FALSE);
+    }
+
+    // count empty lines
+    aAny = xLineNumbering->getPropertyValue("CountEmptyLines");
+    if (! *o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_COUNT_EMPTY_LINES, XML_FALSE);
+    }
+
+    // count in frames
+    aAny = xLineNumbering->getPropertyValue("CountLinesInFrames");
+    if (*o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_COUNT_IN_TEXT_BOXES, XML_TRUE);
+    }
+
+    // restart numbering
+    aAny = xLineNumbering->getPropertyValue("RestartAtEachPage");
+    if (*o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_RESTART_ON_PAGE, XML_TRUE);
+    }
+
+    // Distance
+    aAny = xLineNumbering->getPropertyValue("Distance");
+    sal_Int32 nLength = 0;
+    aAny >>= nLength;
+    if (nLength != 0)
+    {
+        OUStringBuffer sBuf;
+        rExport.GetMM100UnitConverter().convertMeasureToXML(
+                sBuf, nLength);
+        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET,
+                             sBuf.makeStringAndClear());
+    }
+
+    // NumberingType
+    OUStringBuffer sNumPosBuf;
+    aAny = xLineNumbering->getPropertyValue("NumberingType");
+    sal_Int16 nFormat = 0;
+    aAny >>= nFormat;
+    rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat );
+    rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
+                         sNumPosBuf.makeStringAndClear());
+    SvXMLUnitConverter::convertNumLetterSync( sNumPosBuf, nFormat );
+    if( !sNumPosBuf.isEmpty() )
+    {
+        rExport.AddAttribute(XML_NAMESPACE_STYLE,
+                             XML_NUM_LETTER_SYNC,
+                             sNumPosBuf.makeStringAndClear() );
+    }
+
+    // number position
+    aAny = xLineNumbering->getPropertyValue("NumberPosition");
+    sal_uInt16 nPosition = 0;
+    aAny >>= nPosition;
+    if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition,
+                                        aLineNumberPositionMap))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION,
+                             sNumPosBuf.makeStringAndClear());
+    }
+
+    // sInterval
+    aAny = xLineNumbering->getPropertyValue("Interval");
+    sal_Int16 nLineInterval = 0;
+    aAny >>= nLineInterval;
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
+                         OUString::number(nLineInterval));
+
+    SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT,
+                                   XML_LINENUMBERING_CONFIGURATION,
+                                   true, true);
+
+    // line separator
+    aAny = xLineNumbering->getPropertyValue("SeparatorText");
+    OUString sSeparator;
+    aAny >>= sSeparator;
+    if (sSeparator.isEmpty())
+        return;
+
+    // SeparatorInterval
+    aAny = xLineNumbering->getPropertyValue("SeparatorInterval");
+    sal_Int16 nLineDistance = 0;
+    aAny >>= nLineDistance;
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
+                         OUString::number(nLineDistance));
+
+    SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT,
+                                      XML_LINENUMBERING_SEPARATOR,
+                                      true, false);
+    rExport.Characters(sSeparator);
+    // else: no configuration: don't save -> default
     // can't even get supplier: don't save -> default
 }
 
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index 3e56ab088182..7370d60dc628 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -198,50 +198,50 @@ void XMLLineNumberingImportContext::CreateAndInsert(bool)
     // we'll try to get the LineNumberingProperties
     Reference<XLineNumberingProperties> xSupplier(GetImport().GetModel(),
                                                   UNO_QUERY);
-    if (xSupplier.is())
-    {
-        Reference<XPropertySet> xLineNumbering =
-            xSupplier->getLineNumberingProperties();
+    if (!xSupplier.is())
+        return;
 
-        if (xLineNumbering.is())
-        {
-            Any aAny;
+    Reference<XPropertySet> xLineNumbering =
+        xSupplier->getLineNumberingProperties();
 
-            // set style name (if it exists)
-            if ( GetImport().GetStyles()->FindStyleChildContext(
-                            XmlStyleFamily::TEXT_TEXT, sStyleName ) != nullptr )
-            {
-                aAny <<= GetImport().GetStyleDisplayName(
-                            XmlStyleFamily::TEXT_TEXT, sStyleName );
-                xLineNumbering->setPropertyValue(gsCharStyleName, aAny);
-            }
+    if (!xLineNumbering.is())
+        return;
 
-            xLineNumbering->setPropertyValue(gsSeparatorText, Any(sSeparator));
-            xLineNumbering->setPropertyValue(gsDistance, Any(nOffset));
-            xLineNumbering->setPropertyValue(gsNumberPosition, Any(nNumberPosition));
+    Any aAny;
 
-            if (nIncrement >= 0)
-            {
-                xLineNumbering->setPropertyValue(gsInterval, Any(nIncrement));
-            }
+    // set style name (if it exists)
+    if ( GetImport().GetStyles()->FindStyleChildContext(
+                    XmlStyleFamily::TEXT_TEXT, sStyleName ) != nullptr )
+    {
+        aAny <<= GetImport().GetStyleDisplayName(
+                    XmlStyleFamily::TEXT_TEXT, sStyleName );
+        xLineNumbering->setPropertyValue(gsCharStyleName, aAny);
+    }
 
-            if (nSeparatorIncrement >= 0)
-            {
-                xLineNumbering->setPropertyValue(gsSeparatorInterval, Any(nSeparatorIncrement));
-            }
+    xLineNumbering->setPropertyValue(gsSeparatorText, Any(sSeparator));
+    xLineNumbering->setPropertyValue(gsDistance, Any(nOffset));
+    xLineNumbering->setPropertyValue(gsNumberPosition, Any(nNumberPosition));
 
-            xLineNumbering->setPropertyValue(gsIsOn, Any(bNumberLines));
-            xLineNumbering->setPropertyValue(gsCountEmptyLines, Any(bCountEmptyLines));
-            xLineNumbering->setPropertyValue(gsCountLinesInFrames, Any(bCountInFloatingFrames));
-            xLineNumbering->setPropertyValue(gsRestartAtEachPage, Any(bRestartNumbering));
+    if (nIncrement >= 0)
+    {
+        xLineNumbering->setPropertyValue(gsInterval, Any(nIncrement));
+    }
 
-            sal_Int16 nNumType = NumberingType::ARABIC;
-            GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
-                                                    sNumFormat,
-                                                    sNumLetterSync );
-            xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType));
-        }
+    if (nSeparatorIncrement >= 0)
+    {
+        xLineNumbering->setPropertyValue(gsSeparatorInterval, Any(nSeparatorIncrement));
     }
+
+    xLineNumbering->setPropertyValue(gsIsOn, Any(bNumberLines));
+    xLineNumbering->setPropertyValue(gsCountEmptyLines, Any(bCountEmptyLines));
+    xLineNumbering->setPropertyValue(gsCountLinesInFrames, Any(bCountInFloatingFrames));
+    xLineNumbering->setPropertyValue(gsRestartAtEachPage, Any(bRestartNumbering));
+
+    sal_Int16 nNumType = NumberingType::ARABIC;
+    GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
+                                            sNumFormat,
+                                            sNumLetterSync );
+    xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType));
 }
 
 SvXMLImportContextRef XMLLineNumberingImportContext::CreateChildContext(
diff --git a/xmloff/source/text/XMLPropertyBackpatcher.cxx b/xmloff/source/text/XMLPropertyBackpatcher.cxx
index ea4db1d5024b..a2e4ac3a6fc0 100644
--- a/xmloff/source/text/XMLPropertyBackpatcher.cxx
+++ b/xmloff/source/text/XMLPropertyBackpatcher.cxx
@@ -55,22 +55,22 @@ void XMLPropertyBackpatcher<A>::ResolveId(
 
     // backpatch old references, if backpatch list exists
     auto it = aBackpatchListMap.find(sName);
-    if (it != aBackpatchListMap.end())
-    {
-        // aah, we have a backpatch list!
-        std::unique_ptr<BackpatchListType> pList = std::move(it->second);
+    if (it == aBackpatchListMap.end())
+        return;
 
-        // a) remove list from list map
-        aBackpatchListMap.erase(it);
+    // aah, we have a backpatch list!
+    std::unique_ptr<BackpatchListType> pList = std::move(it->second);
 
-        // b) for every item, set SequenceNumber
-        //    (and preserve Property, if appropriate)
-        Any aAny;
-        aAny <<= aValue;
-        for(const auto& rBackpatch : *pList)
-        {
-            rBackpatch->setPropertyValue(sPropertyName, aAny);
-        }
+    // a) remove list from list map
+    aBackpatchListMap.erase(it);
+
+    // b) for every item, set SequenceNumber
+    //    (and preserve Property, if appropriate)
+    Any aAny;
+    aAny <<= aValue;
+    for(const auto& rBackpatch : *pList)
+    {
+        rBackpatch->setPropertyValue(sPropertyName, aAny);
     }
     // else: no backpatch list -> then we're finished
 }
diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx
index a17d10423c3b..f03bc1a98149 100644
--- a/xmloff/source/text/XMLRedlineExport.cxx
+++ b/xmloff/source/text/XMLRedlineExport.cxx
@@ -123,26 +123,26 @@ void XMLRedlineExport::ExportChangesList(
 
     // look for changes list for this XText
     ChangesMapType::iterator aFind = aChangeMap.find(rText);
-    if (aFind != aChangeMap.end())
-    {
-        ChangesVectorType* pChangesList = aFind->second.get();
+    if (aFind == aChangeMap.end())
+        return;
 
-        // export only if changes are found
-        if (!pChangesList->empty())
-        {
-            // changes container element
-            SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
-                                        XML_TRACKED_CHANGES,
-                                        true, true);
+    ChangesVectorType* pChangesList = aFind->second.get();
 
-            // iterate over changes list
-            for (auto const& change : *pChangesList)
-            {
-                ExportChangedRegion(change);
-            }
-        }
-        // else: changes list empty -> ignore
+    // export only if changes are found
+    if (pChangesList->empty())
+        return;
+
+    // changes container element
+    SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
+                                XML_TRACKED_CHANGES,
+                                true, true);
+
+    // iterate over changes list
+    for (auto const& change : *pChangesList)
+    {
+        ExportChangedRegion(change);
     }
+    // else: changes list empty -> ignore
     // else: no changes list found -> empty
 }
 
@@ -179,60 +179,60 @@ void XMLRedlineExport::ExportChangesListElements()
 {
     // get redlines (aka tracked changes) from the model
     Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY);
-    if (xSupplier.is())
-    {
-        Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
+    if (!xSupplier.is())
+        return;
 
-        // redline protection key
-        Reference<XPropertySet> aDocPropertySet( rExport.GetModel(),
-                                                 uno::UNO_QUERY );
-        // redlining enabled?
-        bool bEnabled = *o3tl::doAccess<bool>(aDocPropertySet->getPropertyValue(
-                                                "RecordChanges" ));
+    Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
 
-        // only export if we have redlines or attributes
-        if ( aEnumAccess->hasElements() || bEnabled )
-        {
+    // redline protection key
+    Reference<XPropertySet> aDocPropertySet( rExport.GetModel(),
+                                             uno::UNO_QUERY );
+    // redlining enabled?
+    bool bEnabled = *o3tl::doAccess<bool>(aDocPropertySet->getPropertyValue(
+                                            "RecordChanges" ));
 
-            // export only if we have changes, but tracking is not enabled
-            if ( !bEnabled != !aEnumAccess->hasElements() )
-            {
-                rExport.AddAttribute(
-                    XML_NAMESPACE_TEXT, XML_TRACK_CHANGES,
-                    bEnabled ? XML_TRUE : XML_FALSE );
-            }
+    // only export if we have redlines or attributes
+    if ( !(aEnumAccess->hasElements() || bEnabled) )
+        return;
+
+
+    // export only if we have changes, but tracking is not enabled
+    if ( !bEnabled != !aEnumAccess->hasElements() )
+    {
+        rExport.AddAttribute(
+            XML_NAMESPACE_TEXT, XML_TRACK_CHANGES,
+            bEnabled ? XML_TRUE : XML_FALSE );
+    }
 
-            // changes container element
-            SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
-                                        XML_TRACKED_CHANGES,
-                                        true, true);
+    // changes container element
+    SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT,
+                                XML_TRACKED_CHANGES,
+                                true, true);
 
-            // get enumeration and iterate over elements
-            Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
-            while (aEnum->hasMoreElements())
+    // get enumeration and iterate over elements
+    Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
+    while (aEnum->hasMoreElements())
+    {
+        Any aAny = aEnum->nextElement();
+        Reference<XPropertySet> xPropSet;
+        aAny >>= xPropSet;
+
+        DBG_ASSERT(xPropSet.is(),
+                   "can't get XPropertySet; skipping Redline");
+        if (xPropSet.is())
+        {
+            // export only if not in header or footer
+            // (those must be exported with their XText)
+            aAny = xPropSet->getPropertyValue("IsInHeaderFooter");
+            if (! *o3tl::doAccess<bool>(aAny))
             {
-                Any aAny = aEnum->nextElement();
-                Reference<XPropertySet> xPropSet;
-                aAny >>= xPropSet;
-
-                DBG_ASSERT(xPropSet.is(),
-                           "can't get XPropertySet; skipping Redline");
-                if (xPropSet.is())
-                {
-                    // export only if not in header or footer
-                    // (those must be exported with their XText)
-                    aAny = xPropSet->getPropertyValue("IsInHeaderFooter");
-                    if (! *o3tl::doAccess<bool>(aAny))
-                    {
-                        // and finally, export change
-                        ExportChangedRegion(xPropSet);
-                    }
-                }
-                // else: no XPropertySet -> no export
+                // and finally, export change
+                ExportChangedRegion(xPropSet);
             }
         }
-        // else: no redlines -> no export
+        // else: no XPropertySet -> no export
     }
+    // else: no redlines -> no export
     // else: no XRedlineSupplier -> no export
 }
 
@@ -266,34 +266,34 @@ void XMLRedlineExport::ExportChangesListAutoStyles()
 {
     // get redlines (aka tracked changes) from the model
     Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY);
-    if (xSupplier.is())
+    if (!xSupplier.is())
+        return;
+
+    Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
+
+    // only export if we actually have redlines
+    if (!aEnumAccess->hasElements())
+        return;
+
+    // get enumeration and iterate over elements
+    Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
+    while (aEnum->hasMoreElements())
     {
-        Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines();
+        Any aAny = aEnum->nextElement();
+        Reference<XPropertySet> xPropSet;
+        aAny >>= xPropSet;
 
-        // only export if we actually have redlines
-        if (aEnumAccess->hasElements())
+        DBG_ASSERT(xPropSet.is(),
+                   "can't get XPropertySet; skipping Redline");
+        if (xPropSet.is())
         {
-            // get enumeration and iterate over elements
-            Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration();
-            while (aEnum->hasMoreElements())
+
+            // export only if not in header or footer
+            // (those must be exported with their XText)
+            aAny = xPropSet->getPropertyValue("IsInHeaderFooter");
+            if (! *o3tl::doAccess<bool>(aAny))
             {
-                Any aAny = aEnum->nextElement();
-                Reference<XPropertySet> xPropSet;
-                aAny >>= xPropSet;
-
-                DBG_ASSERT(xPropSet.is(),
-                           "can't get XPropertySet; skipping Redline");
-                if (xPropSet.is())
-                {
-
-                    // export only if not in header or footer
-                    // (those must be exported with their XText)
-                    aAny = xPropSet->getPropertyValue("IsInHeaderFooter");
-                    if (! *o3tl::doAccess<bool>(aAny))
-                    {
-                        ExportChangeAutoStyle(xPropSet);
-                    }
-                }
+                ExportChangeAutoStyle(xPropSet);
             }
         }
     }
@@ -557,22 +557,22 @@ void XMLRedlineExport::ExportStartOrEndRedline(
         }
     }
 
-    if( bIdOK )
-    {
-        SAL_WARN_IF( sId.isEmpty(), "xmloff", "Redlines must have IDs" );
+    if( !bIdOK )
+        return;
 
-        // TODO: use GetRedlineID or eliminate that function
-        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID,
-                             "ct" + sId);
-
-        // export the element
-        // (whitespace because we're not inside paragraphs)
-        SvXMLElementExport aChangeElem(
-            rExport, XML_NAMESPACE_TEXT,
-            bIsCollapsed ? XML_CHANGE :
-                ( bIsStart ? XML_CHANGE_START : XML_CHANGE_END ),
-            true, true);
-    }
+    SAL_WARN_IF( sId.isEmpty(), "xmloff", "Redlines must have IDs" );
+
+    // TODO: use GetRedlineID or eliminate that function
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID,
+                         "ct" + sId);
+
+    // export the element
+    // (whitespace because we're not inside paragraphs)
+    SvXMLElementExport aChangeElem(
+        rExport, XML_NAMESPACE_TEXT,
+        bIsCollapsed ? XML_CHANGE :
+            ( bIsStart ? XML_CHANGE_START : XML_CHANGE_END ),
+        true, true);
 }
 
 void XMLRedlineExport::ExportStartOrEndRedline(
@@ -607,18 +607,18 @@ void XMLRedlineExport::ExportStartOrEndRedline(
 
 void XMLRedlineExport::WriteComment(const OUString& rComment)
 {
-    if (!rComment.isEmpty())
+    if (rComment.isEmpty())
+        return;
+
+    // iterate over all string-pieces separated by return (0x0a) and
+    // put each inside a paragraph element.
+    SvXMLTokenEnumerator aEnumerator(rComment, char(0x0a));
+    OUString aSubString;
+    while (aEnumerator.getNextToken(aSubString))
     {
-        // iterate over all string-pieces separated by return (0x0a) and
-        // put each inside a paragraph element.
-        SvXMLTokenEnumerator aEnumerator(rComment, char(0x0a));
-        OUString aSubString;
-        while (aEnumerator.getNextToken(aSubString))
-        {
-            SvXMLElementExport aParagraph(
-                rExport, XML_NAMESPACE_TEXT, XML_P, true, false);
-            rExport.Characters(aSubString);
-        }
+        SvXMLElementExport aParagraph(
+            rExport, XML_NAMESPACE_TEXT, XML_P, true, false);
+        rExport.Characters(aSubString);
     }
 }
 
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index 3703c927105b..04fc58e4cfa4 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -182,80 +182,80 @@ void XMLSectionExport::ExportSectionEnd(
     bool bAutoStyles)
 {
     // no end section for styles
-    if (!bAutoStyles)
-    {
-        enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
+    if (bAutoStyles)
+        return;
 
-        // export index or regular section end
-        Reference<XDocumentIndex> xIndex;
-        if (GetIndex(rSection, xIndex))
+    enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
+
+    // export index or regular section end
+    Reference<XDocumentIndex> xIndex;
+    if (GetIndex(rSection, xIndex))
+    {
+        if (xIndex.is())
         {
-            if (xIndex.is())
-            {
-                // index end: close index body element
-                GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY,
-                                        true );
-                GetExport().IgnorableWhitespace();
+            // index end: close index body element
+            GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY,
+                                    true );
+            GetExport().IgnorableWhitespace();
 
-                switch (MapSectionType(xIndex->getServiceName()))
-                {
-                    case TEXT_SECTION_TYPE_TOC:
-                        eElement = XML_TABLE_OF_CONTENT;
-                        break;
+            switch (MapSectionType(xIndex->getServiceName()))
+            {
+                case TEXT_SECTION_TYPE_TOC:
+                    eElement = XML_TABLE_OF_CONTENT;
+                    break;
 
-                    case TEXT_SECTION_TYPE_ILLUSTRATION:
-                        eElement = XML_ILLUSTRATION_INDEX;
-                        break;
+                case TEXT_SECTION_TYPE_ILLUSTRATION:
+                    eElement = XML_ILLUSTRATION_INDEX;
+                    break;
 
-                    case TEXT_SECTION_TYPE_ALPHABETICAL:
-                        eElement = XML_ALPHABETICAL_INDEX;
-                        break;
+                case TEXT_SECTION_TYPE_ALPHABETICAL:
+                    eElement = XML_ALPHABETICAL_INDEX;
+                    break;
 
-                    case TEXT_SECTION_TYPE_TABLE:
-                        eElement = XML_TABLE_INDEX;
-                        break;
+                case TEXT_SECTION_TYPE_TABLE:
+                    eElement = XML_TABLE_INDEX;
+                    break;
 
-                    case TEXT_SECTION_TYPE_OBJECT:
-                        eElement = XML_OBJECT_INDEX;
-                        break;
+                case TEXT_SECTION_TYPE_OBJECT:
+                    eElement = XML_OBJECT_INDEX;
+                    break;
 
-                    case TEXT_SECTION_TYPE_USER:
-                        eElement = XML_USER_INDEX;
-                        break;
+                case TEXT_SECTION_TYPE_USER:
+                    eElement = XML_USER_INDEX;
+                    break;
 
-                    case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
-                        eElement = XML_BIBLIOGRAPHY;
-                        break;
+                case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
+                    eElement = XML_BIBLIOGRAPHY;
+                    break;
 
-                    default:
-                        OSL_FAIL("unknown index type");
-                        // default: skip index!
-                        break;
-                }
-            }
-            else
-            {
-                eElement = XML_INDEX_TITLE;
+                default:
+                    OSL_FAIL("unknown index type");
+                    // default: skip index!
+                    break;
             }
         }
         else
         {
-            eElement = XML_SECTION;
+            eElement = XML_INDEX_TITLE;
         }
+    }
+    else
+    {
+        eElement = XML_SECTION;
+    }
 
-        if (XML_TOKEN_INVALID != eElement)
-        {
-            // any old attributes?
-            GetExport().CheckAttrList();
+    if (XML_TOKEN_INVALID != eElement)
+    {
+        // any old attributes?
+        GetExport().CheckAttrList();
 
-            // element surrounded by whitespace
-            GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, true);
-            GetExport().IgnorableWhitespace();
-        }
-        else
-        {
-            OSL_FAIL("Need element name!");
-        }
+        // element surrounded by whitespace
+        GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, true);
+        GetExport().IgnorableWhitespace();
+    }
+    else
+    {
+        OSL_FAIL("Need element name!");
     }
     // else: autostyles -> ignore
 }
@@ -1385,117 +1385,117 @@ void XMLSectionExport::ExportIndexTemplateElement(
     }
 
     // ... and write Element
-    if (eElement != XML_TOKEN_INVALID)
+    if (eElement == XML_TOKEN_INVALID)
+        return;
+
+    // character style (for most templates)
+    if (bCharStyleOK)
     {
-        // character style (for most templates)
-        if (bCharStyleOK)
+        switch (nTokenType)
         {
-            switch (nTokenType)
-            {
-                case TOK_TTYPE_ENTRY_TEXT:
-                case TOK_TTYPE_TEXT:
-                case TOK_TTYPE_PAGE_NUMBER:
-                case TOK_TTYPE_ENTRY_NUMBER:
-                case TOK_TTYPE_HYPERLINK_START:
-                case TOK_TTYPE_HYPERLINK_END:
-                case TOK_TTYPE_BIBLIOGRAPHY:
-                case TOK_TTYPE_CHAPTER_INFO:
-                case TOK_TTYPE_TAB_STOP:
-                    GetExport().AddAttribute(XML_NAMESPACE_TEXT,
-                                             XML_STYLE_NAME,
-                                 GetExport().EncodeStyleName( sCharStyle) );
-                    break;
-                default:
-                    ; // nothing: no character style
-                    break;
-            }
+            case TOK_TTYPE_ENTRY_TEXT:
+            case TOK_TTYPE_TEXT:
+            case TOK_TTYPE_PAGE_NUMBER:
+            case TOK_TTYPE_ENTRY_NUMBER:
+            case TOK_TTYPE_HYPERLINK_START:
+            case TOK_TTYPE_HYPERLINK_END:
+            case TOK_TTYPE_BIBLIOGRAPHY:
+            case TOK_TTYPE_CHAPTER_INFO:
+            case TOK_TTYPE_TAB_STOP:
+                GetExport().AddAttribute(XML_NAMESPACE_TEXT,
+                                         XML_STYLE_NAME,
+                             GetExport().EncodeStyleName( sCharStyle) );
+                break;
+            default:
+                ; // nothing: no character style
+                break;
         }
+    }
 
-        // tab properties
-        if (TOK_TTYPE_TAB_STOP == nTokenType)
-        {
-            // tab type
-            GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE,
-                                     bRightAligned ? XML_RIGHT : XML_LEFT);
-
-            if (bTabPositionOK && (! bRightAligned))
-            {
-                // position for left tabs (convert to measure)
-                OUStringBuffer sBuf;
-                GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf,
-                                                                 nTabPosition);
-                GetExport().AddAttribute(XML_NAMESPACE_STYLE,
-                                         XML_POSITION,
-                                         sBuf.makeStringAndClear());
-            }
-
-            // fill char ("leader char")
-            if (bFillCharOK && !sFillChar.isEmpty())
-            {
-                GetExport().AddAttribute(XML_NAMESPACE_STYLE,
-                                         XML_LEADER_CHAR, sFillChar);
-            }
-
-            // #i21237#
-            if (bWithTabStopOK && ! bWithTabStop)
-            {
-                   GetExport().AddAttribute(XML_NAMESPACE_STYLE,
-                                         XML_WITH_TAB,
-                                         XML_FALSE);
-            }
-        }
+    // tab properties
+    if (TOK_TTYPE_TAB_STOP == nTokenType)
+    {
+        // tab type
+        GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE,
+                                 bRightAligned ? XML_RIGHT : XML_LEFT);
 
-        // bibliography data
-        if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType)
+        if (bTabPositionOK && (! bRightAligned))
         {
-            OSL_ENSURE(bBibliographyDataOK, "need bibl data");
+            // position for left tabs (convert to measure)
             OUStringBuffer sBuf;
-            if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData,
-                                                 aBibliographyDataFieldMap ) )
-            {
-                GetExport().AddAttribute(XML_NAMESPACE_TEXT,
-                                         XML_BIBLIOGRAPHY_DATA_FIELD,
-                                         sBuf.makeStringAndClear());
-            }
+            GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf,
+                                                             nTabPosition);
+            GetExport().AddAttribute(XML_NAMESPACE_STYLE,
+                                     XML_POSITION,
+                                     sBuf.makeStringAndClear());
         }
 
-        // chapter info
-        if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
+        // fill char ("leader char")
+        if (bFillCharOK && !sFillChar.isEmpty())
         {
-            OSL_ENSURE(bChapterFormatOK, "need chapter info");
-            GetExport().AddAttribute(
-                XML_NAMESPACE_TEXT, XML_DISPLAY,
-                XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
-//---> i53420
-            if (bLevelOK)
-                GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
-                                     OUString::number(nLevel));
+            GetExport().AddAttribute(XML_NAMESPACE_STYLE,
+                                     XML_LEADER_CHAR, sFillChar);
         }
 
-//--->i53420
-        if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
+        // #i21237#
+        if (bWithTabStopOK && ! bWithTabStop)
         {
-            if (bChapterFormatOK)
-                GetExport().AddAttribute(
-                    XML_NAMESPACE_TEXT, XML_DISPLAY,
-                    XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
-
-            if (bLevelOK)
-                GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
-                                     OUString::number(nLevel));
+               GetExport().AddAttribute(XML_NAMESPACE_STYLE,
+                                     XML_WITH_TAB,
+                                     XML_FALSE);
         }
-        // export template
-        SvXMLElementExport aTemplateElement(GetExport(), nNamespace,
-                                            GetXMLToken(eElement),
-                                            true, false)
-            ;
-
-        // entry text or span element: write text
-        if (TOK_TTYPE_TEXT == nTokenType)
+    }
+
+    // bibliography data
+    if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType)
+    {
+        OSL_ENSURE(bBibliographyDataOK, "need bibl data");
+        OUStringBuffer sBuf;
+        if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData,
+                                             aBibliographyDataFieldMap ) )
         {
-            GetExport().Characters(sText);
+            GetExport().AddAttribute(XML_NAMESPACE_TEXT,
+                                     XML_BIBLIOGRAPHY_DATA_FIELD,
+                                     sBuf.makeStringAndClear());
         }
     }
+
+    // chapter info
+    if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
+    {
+        OSL_ENSURE(bChapterFormatOK, "need chapter info");
+        GetExport().AddAttribute(
+            XML_NAMESPACE_TEXT, XML_DISPLAY,
+            XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
+//---> i53420
+        if (bLevelOK)
+            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
+                                 OUString::number(nLevel));
+    }
+
+//--->i53420
+    if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
+    {
+        if (bChapterFormatOK)
+            GetExport().AddAttribute(
+                XML_NAMESPACE_TEXT, XML_DISPLAY,
+                XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
+
+        if (bLevelOK)
+            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
+                                 OUString::number(nLevel));
+    }
+    // export template
+    SvXMLElementExport aTemplateElement(GetExport(), nNamespace,
+                                        GetXMLToken(eElement),
+                                        true, false)
+        ;
+
+    // entry text or span element: write text
+    if (TOK_TTYPE_TEXT == nTokenType)
+    {
+        GetExport().Characters(sText);
+    }
 }
 
 void XMLSectionExport::ExportLevelParagraphStyles(
@@ -1570,101 +1570,101 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
     // first: get field master (via text field supplier)
     Reference<XTextFieldsSupplier> xTextFieldsSupp( rExport.GetModel(),
                                                     UNO_QUERY );
-    if ( xTextFieldsSupp.is() )
-    {
-        const OUString sFieldMaster_Bibliography("com.sun.star.text.FieldMaster.Bibliography");
+    if ( !xTextFieldsSupp.is() )
+        return;
 
-        // get bibliography field master
-        Reference<XNameAccess> xMasters =
-            xTextFieldsSupp->getTextFieldMasters();
-        if ( xMasters->hasByName(sFieldMaster_Bibliography) )
-        {
-            Any aAny =
-                xMasters->getByName(sFieldMaster_Bibliography);
-            Reference<XPropertySet> xPropSet;
-            aAny >>= xPropSet;
+    const OUString sFieldMaster_Bibliography("com.sun.star.text.FieldMaster.Bibliography");
 
-            OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" );
+    // get bibliography field master
+    Reference<XNameAccess> xMasters =
+        xTextFieldsSupp->getTextFieldMasters();
+    if ( !xMasters->hasByName(sFieldMaster_Bibliography) )
+        return;
 
-            OUString sTmp;
+    Any aAny =
+        xMasters->getByName(sFieldMaster_Bibliography);
+    Reference<XPropertySet> xPropSet;
+    aAny >>= xPropSet;
 
-            aAny = xPropSet->getPropertyValue("BracketBefore");
-            aAny >>= sTmp;
-            rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp);
+    OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" );
 
-            aAny = xPropSet->getPropertyValue("BracketAfter");
-            aAny >>= sTmp;
-            rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp);
+    OUString sTmp;
 
-            aAny = xPropSet->getPropertyValue("IsNumberEntries");
-            if (*o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_NUMBERED_ENTRIES, XML_TRUE);
-            }
+    aAny = xPropSet->getPropertyValue("BracketBefore");
+    aAny >>= sTmp;
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp);
 
-            aAny = xPropSet->getPropertyValue("IsSortByPosition");
-            if (! *o3tl::doAccess<bool>(aAny))
-            {
-                rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                     XML_SORT_BY_POSITION, XML_FALSE);
-            }
+    aAny = xPropSet->getPropertyValue("BracketAfter");
+    aAny >>= sTmp;
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp);
 
-            // sort algorithm
-            aAny = xPropSet->getPropertyValue("SortAlgorithm");
-            OUString sAlgorithm;
-            aAny >>= sAlgorithm;
-            if( !sAlgorithm.isEmpty() )
-            {
-                rExport.AddAttribute( XML_NAMESPACE_TEXT,
-                                      XML_SORT_ALGORITHM, sAlgorithm );
-            }
+    aAny = xPropSet->getPropertyValue("IsNumberEntries");
+    if (*o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_NUMBERED_ENTRIES, XML_TRUE);
+    }
+
+    aAny = xPropSet->getPropertyValue("IsSortByPosition");
+    if (! *o3tl::doAccess<bool>(aAny))
+    {
+        rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                             XML_SORT_BY_POSITION, XML_FALSE);
+    }
+
+    // sort algorithm
+    aAny = xPropSet->getPropertyValue("SortAlgorithm");
+    OUString sAlgorithm;
+    aAny >>= sAlgorithm;
+    if( !sAlgorithm.isEmpty() )
+    {
+        rExport.AddAttribute( XML_NAMESPACE_TEXT,
+                              XML_SORT_ALGORITHM, sAlgorithm );
+    }
 
-            // locale
-            aAny = xPropSet->getPropertyValue("Locale");
-            Locale aLocale;
-            aAny >>= aLocale;
-            rExport.AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true);
-
-            // configuration element
-            SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT,
-                                        XML_BIBLIOGRAPHY_CONFIGURATION,
-                                        true, true);
-
-            // sort keys
-            aAny = xPropSet->getPropertyValue("SortKeys");
-            Sequence<Sequence<PropertyValue> > aKeys;
-            aAny >>= aKeys;
-            for(const Sequence<PropertyValue> & rKey : std::as_const(aKeys))
+    // locale
+    aAny = xPropSet->getPropertyValue("Locale");
+    Locale aLocale;
+    aAny >>= aLocale;
+    rExport.AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true);
+
+    // configuration element
+    SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT,
+                                XML_BIBLIOGRAPHY_CONFIGURATION,
+                                true, true);
+
+    // sort keys
+    aAny = xPropSet->getPropertyValue("SortKeys");
+    Sequence<Sequence<PropertyValue> > aKeys;
+    aAny >>= aKeys;
+    for(const Sequence<PropertyValue> & rKey : std::as_const(aKeys))
+    {
+        for(const PropertyValue& rValue : rKey)
+        {
+            if (rValue.Name == "SortKey")
             {
-                for(const PropertyValue& rValue : rKey)
+                sal_Int16 nKey = 0;
+                rValue.Value >>= nKey;
+                OUStringBuffer sBuf;
+                if (SvXMLUnitConverter::convertEnum( sBuf, nKey,
+                                         aBibliographyDataFieldMap ) )
                 {
-                    if (rValue.Name == "SortKey")
-                    {
-                        sal_Int16 nKey = 0;
-                        rValue.Value >>= nKey;
-                        OUStringBuffer sBuf;
-                        if (SvXMLUnitConverter::convertEnum( sBuf, nKey,
-                                                 aBibliographyDataFieldMap ) )
-                        {
-                            rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY,
-                                                 sBuf.makeStringAndClear());
-                        }
-                    }
-                    else if (rValue.Name == "IsSortAscending")
-                    {
-                        bool bTmp = *o3tl::doAccess<bool>(rValue.Value);
-                        rExport.AddAttribute(XML_NAMESPACE_TEXT,
-                                             XML_SORT_ASCENDING,
-                                             bTmp ? XML_TRUE : XML_FALSE);
-                    }
+                    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY,
+                                         sBuf.makeStringAndClear());
                 }
-
-                SvXMLElementExport aKeyElem(rExport,
-                                            XML_NAMESPACE_TEXT, XML_SORT_KEY,
-                                            true, true);
+            }
+            else if (rValue.Name == "IsSortAscending")
+            {
+                bool bTmp = *o3tl::doAccess<bool>(rValue.Value);
+                rExport.AddAttribute(XML_NAMESPACE_TEXT,
+                                     XML_SORT_ASCENDING,
+                                     bTmp ? XML_TRUE : XML_FALSE);
             }
         }
+
+        SvXMLElementExport aKeyElem(rExport,
+                                    XML_NAMESPACE_TEXT, XML_SORT_KEY,
+                                    true, true);
     }
 }
 
diff --git a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
index 7f59169a0e8d..1f78bc5be790 100644
--- a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
+++ b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
@@ -124,56 +124,56 @@ void XMLSectionFootnoteConfigExport::exportXML(
     }
 
     // we only make an element if we have an own footnote/endnote numbering
-    if (bEnd)
+    if (!bEnd)
+        return;
+
+    rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
+                             GetXMLToken( bEndnote ? XML_ENDNOTE
+                                                     : XML_FOOTNOTE ) );
+    // start numbering
+    OUStringBuffer sBuf;
+    if (bNumRestart)
     {
-        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
-                                 GetXMLToken( bEndnote ? XML_ENDNOTE
-                                                         : XML_FOOTNOTE ) );
-        // start numbering
-        OUStringBuffer sBuf;
-        if (bNumRestart)
+        // restart number is stored as 0.., but interpreted as 1..
+        rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE,
+                             OUString::number(nNumRestartAt+1));
+    }
+
+    if (bNumOwn)
+    {
+        // prefix and suffix
+        if (!sNumPrefix.isEmpty())
         {
-            // restart number is stored as 0.., but interpreted as 1..
-            rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE,
-                                 OUString::number(nNumRestartAt+1));
+                rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
+                                     sNumPrefix);
         }
-
-        if (bNumOwn)
+        if (!sNumSuffix.isEmpty())
         {
-            // prefix and suffix
-            if (!sNumPrefix.isEmpty())
-            {
-                    rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
-                                         sNumPrefix);
-            }
-            if (!sNumSuffix.isEmpty())
-            {
-                rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
-                                     sNumSuffix);
-            }
+            rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
+                                 sNumSuffix);
+        }
 
-            // number type: num format
-            rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
-                                                              nNumberingType );
-            rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
-                                 sBuf.makeStringAndClear());
+        // number type: num format
+        rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
+                                                          nNumberingType );
+        rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
+                             sBuf.makeStringAndClear());
 
-            // and letter sync, if applicable
-            SvXMLUnitConverter::convertNumLetterSync(
-                sBuf, nNumberingType );
-            if (!sBuf.isEmpty())
-            {
-                rExport.AddAttribute(XML_NAMESPACE_STYLE,
-                                     XML_NUM_LETTER_SYNC,
-                                     sBuf.makeStringAndClear());
-            }
+        // and letter sync, if applicable
+        SvXMLUnitConverter::convertNumLetterSync(
+            sBuf, nNumberingType );
+        if (!sBuf.isEmpty())
+        {
+            rExport.AddAttribute(XML_NAMESPACE_STYLE,
+                                 XML_NUM_LETTER_SYNC,
+                                 sBuf.makeStringAndClear());
         }
-
-        // and finally, the element
-        SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
-                                 XML_NOTES_CONFIGURATION,
-                                 true, true);
     }
+
+    // and finally, the element
+    SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
+                             XML_NOTES_CONFIGURATION,
+                             true, true);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx
index a5c75a40e814..ee7d94426b16 100644
--- a/xmloff/source/text/XMLSectionImportContext.cxx
+++ b/xmloff/source/text/XMLSectionImportContext.cxx
@@ -121,108 +121,108 @@ void XMLSectionImportContext::StartElement(
     rtl::Reference<XMLTextImportHelper> rHelper = GetImport().GetTextImport();
 
     // valid?
-    if (bValid)
-    {
-        // create text section (as XPropertySet)
-        Reference<XMultiServiceFactory> xFactory(
-            GetImport().GetModel(),UNO_QUERY);
-        if (xFactory.is())
-        {
-            Reference<XInterface> xIfc =
-                xFactory->createInstance( bIsIndexHeader ? OUString("com.sun.star.text.IndexHeaderSection")
-                                                         : OUString("com.sun.star.text.TextSection") );
-            if (xIfc.is())
-            {
-                Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY);
+    if (!bValid)
+        return;
 
-                // save PropertySet (for CreateChildContext)
-                xSectionPropertySet = xPropSet;
+    // create text section (as XPropertySet)
+    Reference<XMultiServiceFactory> xFactory(
+        GetImport().GetModel(),UNO_QUERY);
+    if (!xFactory.is())
+        return;
 
-                // name
-                Reference<XNamed> xNamed(xPropSet, UNO_QUERY);
-                xNamed->setName(sName);
+    Reference<XInterface> xIfc =
+        xFactory->createInstance( bIsIndexHeader ? OUString("com.sun.star.text.IndexHeaderSection")
+                                                 : OUString("com.sun.star.text.TextSection") );
+    if (!xIfc.is())
+        return;
 
-                // stylename?
-                if (!sStyleName.isEmpty())
-                {
-                    XMLPropStyleContext* pStyle = rHelper->
-                        FindSectionStyle(sStyleName);
+    Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY);
 
-                    if (pStyle != nullptr)
-                    {
-                        pStyle->FillPropertySet( xPropSet );
-                    }
-                }
+    // save PropertySet (for CreateChildContext)
+    xSectionPropertySet = xPropSet;
 
-                // IsVisible and condition (not for index headers)
-                if (! bIsIndexHeader)
-                {
-                    xPropSet->setPropertyValue( "IsVisible", Any(bIsVisible) );
+    // name
+    Reference<XNamed> xNamed(xPropSet, UNO_QUERY);
+    xNamed->setName(sName);
 
-                    // #97450# hidden sections must be hidden on reload
-                    // For backwards compatibility, set flag only if it is
-                    // present
-                    if( bIsCurrentlyVisibleOK )
-                    {
-                        xPropSet->setPropertyValue( "IsCurrentlyVisible", Any(bIsCurrentlyVisible));
-                    }
+    // stylename?
+    if (!sStyleName.isEmpty())
+    {
+        XMLPropStyleContext* pStyle = rHelper->
+            FindSectionStyle(sStyleName);
 
-                    if (bCondOK)
-                    {
-                        xPropSet->setPropertyValue( "Condition", Any(sCond) );
-                    }
-                }
+        if (pStyle != nullptr)
+        {
+            pStyle->FillPropertySet( xPropSet );
+        }
+    }
 
-                // password (only for regular sections)
-                if ( bSequenceOK &&
-                     IsXMLToken(GetLocalName(), XML_SECTION) )
-                {
-                    xPropSet->setPropertyValue("ProtectionKey", Any(aSequence));
-                }
+    // IsVisible and condition (not for index headers)
+    if (! bIsIndexHeader)
+    {
+        xPropSet->setPropertyValue( "IsVisible", Any(bIsVisible) );
 
-                // protection
-                xPropSet->setPropertyValue( "IsProtected", Any(bProtect) );
+        // #97450# hidden sections must be hidden on reload
+        // For backwards compatibility, set flag only if it is
+        // present
+        if( bIsCurrentlyVisibleOK )
+        {
+            xPropSet->setPropertyValue( "IsCurrentlyVisible", Any(bIsCurrentlyVisible));
+        }
+
+        if (bCondOK)
+        {
+            xPropSet->setPropertyValue( "Condition", Any(sCond) );
+        }
+    }
 
-                // insert marker, <paragraph>, marker; then insert
-                // section over the first marker character, and delete the
-                // last paragraph (and marker) when closing a section.
-                Reference<XTextRange> xStart =
-                    rHelper->GetCursor()->getStart();
+    // password (only for regular sections)
+    if ( bSequenceOK &&
+         IsXMLToken(GetLocalName(), XML_SECTION) )
+    {
+        xPropSet->setPropertyValue("ProtectionKey", Any(aSequence));
+    }
+
+    // protection
+    xPropSet->setPropertyValue( "IsProtected", Any(bProtect) );
+
+    // insert marker, <paragraph>, marker; then insert
+    // section over the first marker character, and delete the
+    // last paragraph (and marker) when closing a section.
+    Reference<XTextRange> xStart =
+        rHelper->GetCursor()->getStart();
 #ifndef DBG_UTIL
-                OUString sMarkerString(" ");
+    OUString sMarkerString(" ");
 #else
-                OUString sMarkerString("X");
+    OUString sMarkerString("X");
 #endif
-                rHelper->InsertString(sMarkerString);
-                rHelper->InsertControlCharacter(
-                    ControlCharacter::APPEND_PARAGRAPH );
-                rHelper->InsertString(sMarkerString);
+    rHelper->InsertString(sMarkerString);
+    rHelper->InsertControlCharacter(
+        ControlCharacter::APPEND_PARAGRAPH );
+    rHelper->InsertString(sMarkerString);
 
-                // select first marker
-                rHelper->GetCursor()->gotoRange(xStart, false);
-                rHelper->GetCursor()->goRight(1, true);
+    // select first marker
+    rHelper->GetCursor()->gotoRange(xStart, false);
+    rHelper->GetCursor()->goRight(1, true);
 
-                // convert section to XTextContent
-                Reference<XTextContent> xTextContent(xSectionPropertySet,
-                                                     UNO_QUERY);
+    // convert section to XTextContent
+    Reference<XTextContent> xTextContent(xSectionPropertySet,
+                                         UNO_QUERY);
 
-                // and insert (over marker)
-                rHelper->GetText()->insertTextContent(
-                    rHelper->GetCursorAsRange(), xTextContent, true );
+    // and insert (over marker)
+    rHelper->GetText()->insertTextContent(
+        rHelper->GetCursorAsRange(), xTextContent, true );
 
-                // and delete first marker (in section)
-                rHelper->GetText()->insertString(
-                    rHelper->GetCursorAsRange(), "", true);
+    // and delete first marker (in section)
+    rHelper->GetText()->insertString(
+        rHelper->GetCursorAsRange(), "", true);
 
-                // finally, check for redlines that should start at
-                // the section start node
-                rHelper->RedlineAdjustStartNodeCursor(); // start ???
+    // finally, check for redlines that should start at
+    // the section start node
+    rHelper->RedlineAdjustStartNodeCursor(); // start ???
 
-                // xml:id for RDF metadata
-                GetImport().SetXmlId(xIfc, sXmlId);
-            }
-        }
-    }
+    // xml:id for RDF metadata
+    GetImport().SetXmlId(xIfc, sXmlId);
 }
 
 void XMLSectionImportContext::ProcessAttributes(
diff --git a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
index db928cde972c..070e402fb34a 100644
--- a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
+++ b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
@@ -39,26 +39,26 @@ XMLTextCharStyleNamesElementExport::XMLTextCharStyleNamesElementExport(
     rExport( rExp ),
     nCount( 0 )
 {
-    if( bDoSth )
+    if( !bDoSth )
+        return;
+
+    Any aAny = rPropSet->getPropertyValue( rPropName );
+    Sequence < OUString > aNames;
+    if( !(aAny >>= aNames) )
+        return;
+
+    nCount = aNames.getLength();
+    OSL_ENSURE( nCount > 0, "no char style found" );
+    if ( bAllStyles ) ++nCount;
+    if( nCount > 1 )
     {
-        Any aAny = rPropSet->getPropertyValue( rPropName );
-        Sequence < OUString > aNames;
-        if( aAny >>= aNames )
+        aName = rExport.GetNamespaceMap().GetQNameByKey(
+                        XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) );
+        for( sal_Int32 i = 1; i < nCount; ++i )
         {
-            nCount = aNames.getLength();
-            OSL_ENSURE( nCount > 0, "no char style found" );
-            if ( bAllStyles ) ++nCount;
-            if( nCount > 1 )
-            {
-                aName = rExport.GetNamespaceMap().GetQNameByKey(
-                                XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) );
-                for( sal_Int32 i = 1; i < nCount; ++i )
-                {
-                    rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
-                                          rExport.EncodeStyleName( aNames[i - 1] ) );
-                    rExport.StartElement( aName, false );
-                }
-            }
+            rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
+                                  rExport.EncodeStyleName( aNames[i - 1] ) );
+            rExport.StartElement( aName, false );
         }
     }
 }
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index 408a28bbcf95..ea3deca2b963 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -280,60 +280,62 @@ XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
     OUString sContourPolyPolygon("ContourPolyPolygon");
     Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
 
-    if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength())
+    if(!xPropSetInfo->hasPropertyByName(sContourPolyPolygon) ||
+        nWidth <= 0 || nHeight <= 0 || bPixelWidth != bPixelHeight ||
+        !(bPath ? sD : sPoints).getLength())
+        return;
+
+    const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
+    basegfx::B2DPolyPolygon aPolyPolygon;
+
+    if( bPath )
     {
-        const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
-        basegfx::B2DPolyPolygon aPolyPolygon;
+        basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr);
+    }
+    else
+    {
+        basegfx::B2DPolygon aPolygon;
 
-        if( bPath )
+        if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints))
         {
-            basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr);
-        }
-        else
-        {
-            basegfx::B2DPolygon aPolygon;
-
-            if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints))
-            {
-                aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
-            }
+            aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
         }
+    }
 
-        if(aPolyPolygon.count())
+    if(aPolyPolygon.count())
+    {
+        const basegfx::B2DRange aSourceRange(
+            aViewBox.GetX(), aViewBox.GetY(),
+            aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
+        const basegfx::B2DRange aTargetRange(
+            0.0, 0.0,
+            nWidth, nHeight);
+
+        if(!aSourceRange.equal(aTargetRange))
         {
-            const basegfx::B2DRange aSourceRange(
-                aViewBox.GetX(), aViewBox.GetY(),
-                aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
-            const basegfx::B2DRange aTargetRange(
-                0.0, 0.0,
-                nWidth, nHeight);
-
-            if(!aSourceRange.equal(aTargetRange))
-            {
-                aPolyPolygon.transform(
-                    basegfx::utils::createSourceRangeTargetRangeTransform(
-                        aSourceRange,
-                        aTargetRange));
-            }
-
-            css::drawing::PointSequenceSequence aPointSequenceSequence;
-            basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence);
-            xPropSet->setPropertyValue( sContourPolyPolygon, Any(aPointSequenceSequence) );
+            aPolyPolygon.transform(
+                basegfx::utils::createSourceRangeTargetRangeTransform(
+                    aSourceRange,
+                    aTargetRange));
         }
 
-        const OUString sIsPixelContour("IsPixelContour");
+        css::drawing::PointSequenceSequence aPointSequenceSequence;
+        basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence);
+        xPropSet->setPropertyValue( sContourPolyPolygon, Any(aPointSequenceSequence) );
+    }
 
-        if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
-        {
-            xPropSet->setPropertyValue( sIsPixelContour, Any(bPixelWidth) );
-        }
+    const OUString sIsPixelContour("IsPixelContour");
+
+    if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
+    {
+        xPropSet->setPropertyValue( sIsPixelContour, Any(bPixelWidth) );
+    }
 
-        const OUString sIsAutomaticContour("IsAutomaticContour");
+    const OUString sIsAutomaticContour("IsAutomaticContour");
 
-        if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
-        {
-            xPropSet->setPropertyValue( sIsAutomaticContour, Any(bAuto) );
-        }
+    if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
+    {
+        xPropSet->setPropertyValue( sIsAutomaticContour, Any(bAuto) );
     }
 }
 
@@ -731,47 +733,47 @@ void XMLTextFrameContext_Impl::Create()
         GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
     }
 
-    if( XML_TEXT_FRAME_TEXTBOX == nType )
-    {
-        xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
-        Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
-        Reference < XText > xTxt = xTxtFrame->getText();
-        xOldTextCursor = xTextImportHelper->GetCursor();
-        xTextImportHelper->SetCursor( xTxt->createTextCursor() );
-
-        // remember old list item and block (#89892#) and reset them
-        // for the text frame
-        xTextImportHelper->PushListContext();
-        mbListContextPushed = true;
-    }
+    if( XML_TEXT_FRAME_TEXTBOX != nType )
+        return;
+
+    xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
+    Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
+    Reference < XText > xTxt = xTxtFrame->getText();
+    xOldTextCursor = xTextImportHelper->GetCursor();
+    xTextImportHelper->SetCursor( xTxt->createTextCursor() );
+
+    // remember old list item and block (#89892#) and reset them
+    // for the text frame
+    xTextImportHelper->PushListContext();
+    mbListContextPushed = true;
 }
 
 void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext)
 {
     const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
 
-    if(pXMLTextFrameContext_Impl)
+    if(!pXMLTextFrameContext_Impl)
+        return;
+
+    try
     {
-        try
-        {
-            // just dispose to delete
-            uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
+        // just dispose to delete
+        uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
 
-            // Inform shape importer about the removal so it can adjust
-            // z-indexes.
-            uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY);
-            GetImport().GetShapeImport()->shapeRemoved(xShape);
+        // Inform shape importer about the removal so it can adjust
+        // z-indexes.
+        uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY);
+        GetImport().GetShapeImport()->shapeRemoved(xShape);
 
-            if(xComp.is())
-            {
-                xComp->dispose();
-            }
-        }
-        catch( uno::Exception& )
+        if(xComp.is())
         {
-            OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
+            xComp->dispose();
         }
     }
+    catch( uno::Exception& )
+    {
+        OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
+    }
 }
 
 OUString XMLTextFrameContext::getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const
@@ -1295,20 +1297,20 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
 void XMLTextFrameContext_Impl::SetName()
 {
     Reference<XNamed> xNamed(xPropSet, UNO_QUERY);
-    if (!m_sOrigName.isEmpty() && xNamed.is())
+    if (!(!m_sOrigName.isEmpty() && xNamed.is()))
+        return;
+
+    OUString const name(xNamed->getName());
+    if (name != m_sOrigName)
     {
-        OUString const name(xNamed->getName());
-        if (name != m_sOrigName)
+        try
         {
-            try
-            {
-                xNamed->setName(m_sOrigName);
-            }
-            catch (uno::Exception const&)
-            {   // fdo#71698 document contains 2 frames with same draw:name
-                TOOLS_INFO_EXCEPTION("xmloff.text", "SetName(): exception setting \""
-                        << m_sOrigName << "\"");
-            }
+            xNamed->setName(m_sOrigName);
+        }
+        catch (uno::Exception const&)
+        {   // fdo#71698 document contains 2 frames with same draw:name
+            TOOLS_INFO_EXCEPTION("xmloff.text", "SetName(): exception setting \""
+                    << m_sOrigName << "\"");
         }
     }
 }
@@ -1414,36 +1416,35 @@ void XMLTextFrameContext::EndElement()
         (pMultiContext.is()) ? pMultiContext.get() : m_xImplContext.get();
     XMLTextFrameContext_Impl *pImpl = const_cast<XMLTextFrameContext_Impl*>(dynamic_cast< const XMLTextFrameContext_Impl*>( pContext ));
     assert(!pMultiContext.is() || pImpl);
-    if( pImpl )
-    {
-        pImpl->CreateIfNotThere();
-
-        // fdo#68839: in case the surviving image was not the first one,
-        // it will have a counter added to its name - set the original name
-        if (pMultiContext.is()) // do this only when necessary; esp. not for text
-        {                  // frames that may have entries in GetRenameMap()!
-            pImpl->SetName();
-        }
+    if( !pImpl )
+        return;
 
-        if( !m_sTitle.isEmpty() )
-        {
-            pImpl->SetTitle( m_sTitle );
-        }
-        if( !m_sDesc.isEmpty() )
-        {
-            pImpl->SetDesc( m_sDesc );
-        }
+    pImpl->CreateIfNotThere();
 
-        if( m_pHyperlink )
-        {
-            pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
-                          m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
-            m_pHyperlink.reset();
-        }
+    // fdo#68839: in case the surviving image was not the first one,
+    // it will have a counter added to its name - set the original name
+    if (pMultiContext.is()) // do this only when necessary; esp. not for text
+    {                  // frames that may have entries in GetRenameMap()!
+        pImpl->SetName();
+    }
 
-        GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName());
+    if( !m_sTitle.isEmpty() )
+    {
+        pImpl->SetTitle( m_sTitle );
+    }
+    if( !m_sDesc.isEmpty() )
+    {
+        pImpl->SetDesc( m_sDesc );
+    }
 
+    if( m_pHyperlink )
+    {
+        pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
+                      m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
+        m_pHyperlink.reset();
     }
+
+    GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName());
 }
 
 SvXMLImportContextRef XMLTextFrameContext::CreateChildContext(
diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
index 50414bd78b65..38dc32dd1e46 100644
--- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx
+++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
@@ -51,45 +51,45 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa
 {
     const OUString sShareContentFirst( "FirstIsShared" );
     // NOTE: if this ever handles XML_DISPLAY attr then beware of fdo#72850 !
-    if( bLeft || bFirst )
-    {
-        Any aAny = xPropSet->getPropertyValue( sOn );
-        bool bOn = *o3tl::doAccess<bool>(aAny);
+    if( !(bLeft || bFirst) )
+        return;
+
+    Any aAny = xPropSet->getPropertyValue( sOn );
+    bool bOn = *o3tl::doAccess<bool>(aAny);
 
-        if( bOn )
+    if( bOn )
+    {
+        if (bLeft)
         {
-            if (bLeft)
-            {
-                aAny = xPropSet->getPropertyValue( sShareContent );
-                bool bShared = bool();
-                if (!(aAny >>= bShared))
-                    assert(false); // should return a value!
-                if( bShared )
-                {
-                    // Don't share headers any longer
-                    xPropSet->setPropertyValue( sShareContent, Any(false) );
-                }
-            }
-            if (bFirst)
+            aAny = xPropSet->getPropertyValue( sShareContent );
+            bool bShared = bool();
+            if (!(aAny >>= bShared))
+                assert(false); // should return a value!
+            if( bShared )
             {
-                aAny = xPropSet->getPropertyValue( sShareContentFirst );
-                bool bSharedFirst = bool();
-                if (!(aAny >>= bSharedFirst))
-                    assert(false); // should return a value!
-                if( bSharedFirst )
-                {
-                    // Don't share first/right headers any longer
-                    xPropSet->setPropertyValue( sShareContentFirst, Any(false) );
-                }
+                // Don't share headers any longer
+                xPropSet->setPropertyValue( sShareContent, Any(false) );
             }
         }
-        else
+        if (bFirst)
         {
-            // If headers or footers are switched off, no content must be
-            // inserted.
-            bInsertContent = false;
+            aAny = xPropSet->getPropertyValue( sShareContentFirst );
+            bool bSharedFirst = bool();
+            if (!(aAny >>= bSharedFirst))
+                assert(false); // should return a value!
+            if( bSharedFirst )
+            {
+                // Don't share first/right headers any longer
+                xPropSet->setPropertyValue( sShareContentFirst, Any(false) );
+            }
         }
     }
+    else
+    {
+        // If headers or footers are switched off, no content must be
+        // inserted.
+        bInsertContent = false;
+    }
 }
 
 XMLTextHeaderFooterContext::~XMLTextHeaderFooterContext()
diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx
index 6265bcf48a9f..a3b02b5b5c71 100644
--- a/xmloff/source/text/XMLTextListBlockContext.cxx
+++ b/xmloff/source/text/XMLTextListBlockContext.cxx
@@ -130,98 +130,98 @@ XMLTextListBlockContext::XMLTextListBlockContext(
     if( !mxNumRules.is() )
         return;
 
-    if ( mnLevel == 0 ) // root <list> element
+    if ( mnLevel != 0 ) // root <list> element
+        return;
+
+    XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() );
+    // Inconsistent behavior regarding lists (#i92811#)
+    OUString sListStyleDefaultListId;
     {
-        XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() );
-        // Inconsistent behavior regarding lists (#i92811#)
-        OUString sListStyleDefaultListId;
+        uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY );
+        if ( xNumRuleProps.is() )
         {
-            uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY );
-            if ( xNumRuleProps.is() )
+            uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo(
+                                        xNumRuleProps->getPropertySetInfo());
+            if (xNumRulePropSetInfo.is() &&
+                xNumRulePropSetInfo->hasPropertyByName(
+                     s_PropNameDefaultListId))
             {
-                uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo(
-                                            xNumRuleProps->getPropertySetInfo());
-                if (xNumRulePropSetInfo.is() &&
-                    xNumRulePropSetInfo->hasPropertyByName(
-                         s_PropNameDefaultListId))
-                {
-                    xNumRuleProps->getPropertyValue(s_PropNameDefaultListId)
-                        >>= sListStyleDefaultListId;
-                    SAL_WARN_IF( sListStyleDefaultListId.isEmpty(), "xmloff",
-                                "no default list id found at numbering rules instance. Serious defect." );
-                }
+                xNumRuleProps->getPropertyValue(s_PropNameDefaultListId)
+                    >>= sListStyleDefaultListId;
+                SAL_WARN_IF( sListStyleDefaultListId.isEmpty(), "xmloff",
+                            "no default list id found at numbering rules instance. Serious defect." );
             }
         }
-        if ( msListId.isEmpty() )  // no text:id property found
+    }
+    if ( msListId.isEmpty() )  // no text:id property found
+    {
+        sal_Int32 nUPD( 0 );
+        sal_Int32 nBuild( 0 );
+        const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
+        if ( rImport.IsTextDocInOOoFileFormat() ||
+             ( bBuildIdFound && nUPD == 680 ) )
         {
-            sal_Int32 nUPD( 0 );
-            sal_Int32 nBuild( 0 );
-            const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
-            if ( rImport.IsTextDocInOOoFileFormat() ||
-                 ( bBuildIdFound && nUPD == 680 ) )
+            /* handling former documents written by OpenOffice.org:
+               use default list id of numbering rules instance, if existing
+               (#i92811#)
+            */
+            if ( !sListStyleDefaultListId.isEmpty() )
             {
-                /* handling former documents written by OpenOffice.org:
-                   use default list id of numbering rules instance, if existing
-                   (#i92811#)
-                */
-                if ( !sListStyleDefaultListId.isEmpty() )
+                msListId = sListStyleDefaultListId;
+                if ( !bIsContinueNumberingAttributePresent &&
+                     !mbRestartNumbering &&
+                     rTextListsHelper.IsListProcessed( msListId ) )
                 {
-                    msListId = sListStyleDefaultListId;
-                    if ( !bIsContinueNumberingAttributePresent &&
-                         !mbRestartNumbering &&
-                         rTextListsHelper.IsListProcessed( msListId ) )
-                    {
-                        mbRestartNumbering = true;
-                    }
+                    mbRestartNumbering = true;
                 }
             }
-            if ( msListId.isEmpty() )
-            {
-                // generate a new list id for the list
-                msListId = rTextListsHelper.GenerateNewListId();
-            }
         }
+        if ( msListId.isEmpty() )
+        {
+            // generate a new list id for the list
+            msListId = rTextListsHelper.GenerateNewListId();
+        }
+    }
 
-        if ( bIsContinueNumberingAttributePresent && !mbRestartNumbering &&
-             msContinueListId.isEmpty() )
+    if ( bIsContinueNumberingAttributePresent && !mbRestartNumbering &&
+         msContinueListId.isEmpty() )
+    {
+        const OUString& Last( rTextListsHelper.GetLastProcessedListId() );
+        if ( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName
+             && Last != msListId )
         {
-            const OUString& Last( rTextListsHelper.GetLastProcessedListId() );
-            if ( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName
-                 && Last != msListId )
-            {
-                msContinueListId = Last;
-            }
+            msContinueListId = Last;
         }
+    }
 
-        if ( !msContinueListId.isEmpty() )
+    if ( !msContinueListId.isEmpty() )
+    {
+        if ( !rTextListsHelper.IsListProcessed( msContinueListId ) )
         {
-            if ( !rTextListsHelper.IsListProcessed( msContinueListId ) )
-            {
-                msContinueListId.clear();
-            }
-            else
+            msContinueListId.clear();
+        }
+        else
+        {
+            // search continue list chain for master list and
+            // continue the master list.
+            OUString sTmpStr =
+                rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId );
+            while ( !sTmpStr.isEmpty() )
             {
-                // search continue list chain for master list and
-                // continue the master list.
-                OUString sTmpStr =
-                    rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId );
-                while ( !sTmpStr.isEmpty() )
-                {
-                    msContinueListId = sTmpStr;
+                msContinueListId = sTmpStr;
 
-                    sTmpStr =
-                        rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId );
-                }
+                sTmpStr =
+                    rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId );
             }
         }
+    }
 
-        if ( !rTextListsHelper.IsListProcessed( msListId ) )
-        {
-            // Inconsistent behavior regarding lists (#i92811#)
-            rTextListsHelper.KeepListAsProcessed(
-                msListId, msListStyleName, msContinueListId,
-                sListStyleDefaultListId );
-        }
+    if ( !rTextListsHelper.IsListProcessed( msListId ) )
+    {
+        // Inconsistent behavior regarding lists (#i92811#)
+        rTextListsHelper.KeepListAsProcessed(
+            msListId, msListStyleName, msContinueListId,
+            sListStyleDefaultListId );
     }
 }
 
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index a947f81cc376..9ffb3e5c30fd 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -200,23 +200,23 @@ static auto InsertFieldmark(SvXMLImport & rImport,
             rImport, "com.sun.star.text.Fieldmark",
             rName, rHelper.GetCursorAsRange());
 
-    if (xContent.is())
-    {
-        // setup fieldmark...
-        Reference<text::XFormField> const xFormField(xContent, UNO_QUERY);
-        assert(xFormField.is());
-        xFormField->setFieldType(fieldmarkTypeName);
-        rHelper.setCurrentFieldParamsTo(xFormField);
-        // move cursor after setFieldType as that may delete/re-insert
-        rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false);
-        rHelper.GetCursor()->goLeft(1, false); // move before CH_TXT_ATR_FIELDEND
-        // tdf#129520: AppendTextNode() ignores the content index!
-        // plan B: insert a spurious paragraph break now and join
-        //         it in PopFieldmark()!
-        rHelper.GetText()->insertControlCharacter(rHelper.GetCursor(),
-                text::ControlCharacter::PARAGRAPH_BREAK, false);
-        rHelper.GetCursor()->goLeft(1, false); // back to previous paragraph
-    }
+    if (!xContent.is())
+        return;
+
+    // setup fieldmark...
+    Reference<text::XFormField> const xFormField(xContent, UNO_QUERY);
+    assert(xFormField.is());
+    xFormField->setFieldType(fieldmarkTypeName);
+    rHelper.setCurrentFieldParamsTo(xFormField);
+    // move cursor after setFieldType as that may delete/re-insert
+    rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false);
+    rHelper.GetCursor()->goLeft(1, false); // move before CH_TXT_ATR_FIELDEND
+    // tdf#129520: AppendTextNode() ignores the content index!
+    // plan B: insert a spurious paragraph break now and join
+    //         it in PopFieldmark()!
+    rHelper.GetText()->insertControlCharacter(rHelper.GetCursor(),
+            text::ControlCharacter::PARAGRAPH_BREAK, false);
+    rHelper.GetCursor()->goLeft(1, false); // back to previous paragraph
 }
 
 static auto PopFieldmark(XMLTextImportHelper & rHelper) -> void
@@ -224,28 +224,28 @@ static auto PopFieldmark(XMLTextImportHelper & rHelper) -> void
     // can't verify name because it's not written as an attribute...
     uno::Reference<text::XTextContent> const xField(rHelper.popFieldCtx(),
             uno::UNO_QUERY);
-    if (xField.is())
+    if (!xField.is())
+        return;
+
+    if (rHelper.GetText() == xField->getAnchor()->getText())
     {
-        if (rHelper.GetText() == xField->getAnchor()->getText())
-        {
-            try
-            {   // skip CH_TXT_ATR_FIELDEND
-                rHelper.GetCursor()->goRight(1, true);
-                rHelper.GetCursor()->setString(OUString()); // undo AppendTextNode from InsertFieldmark
-                rHelper.GetCursor()->gotoRange(xField->getAnchor()->getEnd(), false);
-            }
-            catch (uno::Exception const&)
-            {
-                assert(false); // must succeed
-            }
+        try
+        {   // skip CH_TXT_ATR_FIELDEND
+            rHelper.GetCursor()->goRight(1, true);
+            rHelper.GetCursor()->setString(OUString()); // undo AppendTextNode from InsertFieldmark
+            rHelper.GetCursor()->gotoRange(xField->getAnchor()->getEnd(), false);
         }
-        else
+        catch (uno::Exception const&)
         {
-            SAL_INFO("xmloff.text", "fieldmark has invalid positions");
-            // could either dispose it or leave it to end at the end of the document?
-            xField->dispose();
+            assert(false); // must succeed
         }
     }
+    else
+    {
+        SAL_INFO("xmloff.text", "fieldmark has invalid positions");
+        // could either dispose it or leave it to end at the end of the document?
+        xField->dispose();
+    }
 }
 
 void XMLTextMarkImportContext::EndElement()
@@ -255,183 +255,183 @@ void XMLTextMarkImportContext::EndElement()
     static const char sAPI_bookmark[] = "com.sun.star.text.Bookmark";
 
     lcl_MarkType nTmp{};
-    if (SvXMLUnitConverter::convertEnum(nTmp, GetLocalName(), lcl_aMarkTypeMap))
+    if (!SvXMLUnitConverter::convertEnum(nTmp, GetLocalName(), lcl_aMarkTypeMap))
+        return;
+
+    if (m_sBookmarkName.isEmpty() && TypeFieldmarkEnd != nTmp)
+        return;
+
+    switch (nTmp)
     {
-        if (!m_sBookmarkName.isEmpty() || TypeFieldmarkEnd == nTmp)
-        {
-            switch (nTmp)
+        case TypeReference:
+            // export point reference mark
+            CreateAndInsertMark(GetImport(),
+                "com.sun.star.text.ReferenceMark",
+                m_sBookmarkName,
+                m_rHelper.GetCursorAsRange()->getStart());
+            break;
+
+        case TypeBookmark:
             {
-                case TypeReference:
-                    // export point reference mark
+                // tdf#94804: detect duplicate heading cross reference bookmarks
+                if (m_sBookmarkName.startsWith("__RefHeading__"))
+                {
+                    if (m_rxCrossRefHeadingBookmark.is())
+                    {
+                        uno::Reference<container::XNamed> const xNamed(
+                            m_rxCrossRefHeadingBookmark, uno::UNO_QUERY);
+                        m_rHelper.AddCrossRefHeadingMapping(
+                            m_sBookmarkName, xNamed->getName());
+                        break; // don't insert
+                    }
+                }
+            }
+            [[fallthrough]];

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list