[Libreoffice-commits] core.git: 6 commits - dbaccess/source editeng/source include/xmloff linguistic/source reportdesign/source sc/source starmath/source svx/source sw/inc sw/source xmloff/inc xmloff/source

Michael Stahl mstahl at redhat.com
Thu Nov 30 21:39:04 UTC 2017


 dbaccess/source/filter/xml/xmlEnums.hxx            |   12 -
 dbaccess/source/filter/xml/xmlfilter.cxx           |  186 ++++++++++++++++--
 dbaccess/source/filter/xml/xmlfilter.hxx           |    5 
 editeng/source/xml/xmltxtimp.cxx                   |    6 
 include/xmloff/xmlimp.hxx                          |    4 
 linguistic/source/convdicxml.cxx                   |    2 
 linguistic/source/convdicxml.hxx                   |    2 
 reportdesign/source/filter/xml/xmlEnums.hxx        |   16 +
 reportdesign/source/filter/xml/xmlHelper.cxx       |    1 
 reportdesign/source/filter/xml/xmlSubDocument.cxx  |    6 
 reportdesign/source/filter/xml/xmlfilter.cxx       |  213 ++++++++++++++++-----
 reportdesign/source/filter/xml/xmlfilter.hxx       |   21 +-
 sc/source/filter/xml/xmlimprt.cxx                  |    4 
 sc/source/filter/xml/xmlimprt.hxx                  |    4 
 starmath/source/mathmlimport.cxx                   |    2 
 starmath/source/mathmlimport.hxx                   |    2 
 svx/source/inc/xmlxtimp.hxx                        |    2 
 svx/source/xml/xmlxtimp.cxx                        |    4 
 sw/inc/SwXMLSectionList.hxx                        |   25 --
 sw/inc/shellio.hxx                                 |    2 
 sw/source/core/swg/SwXMLSectionList.cxx            |   97 ++++++---
 sw/source/filter/basflt/shellio.cxx                |    2 
 sw/source/filter/inc/fltini.hxx                    |    2 
 sw/source/filter/xml/swxml.cxx                     |    2 
 sw/source/filter/xml/xmlimp.cxx                    |    4 
 sw/source/filter/xml/xmlimp.hxx                    |    4 
 sw/source/ui/dialog/uiregionsw.cxx                 |   10 
 sw/source/uibase/config/StoredChapterNumbering.cxx |    4 
 xmloff/inc/SchXMLImport.hxx                        |    2 
 xmloff/inc/xmlversion.hxx                          |    4 
 xmloff/source/chart/SchXMLImport.cxx               |    7 
 xmloff/source/core/xmlictxt.cxx                    |    6 
 xmloff/source/core/xmlimp.cxx                      |    4 
 xmloff/source/draw/animationimport.cxx             |    8 
 xmloff/source/draw/sdxmlimp.cxx                    |    4 
 xmloff/source/draw/sdxmlimp_impl.hxx               |    5 
 xmloff/source/meta/MetaImportComponent.cxx         |    6 
 xmloff/source/meta/xmlversion.cxx                  |    4 
 xmloff/source/text/XMLAutoTextEventImport.cxx      |    4 
 xmloff/source/text/XMLAutoTextEventImport.hxx      |    2 
 40 files changed, 515 insertions(+), 185 deletions(-)

New commits:
commit f7a5335ef50f4a9775703a038006dfb983a50a15
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Nov 30 18:29:37 2017 +0100

    xmloff: turn SvXMLImportContext into a no-op base class
    
    Fix the non-obvious and potentially dangerous recursion that is
    implicit in xmloff's context code.
    
    SvXMLImportContext::CreateChildContext() now always creates a
    SvXMLImportContext, does not delegate to SvXMLImport.
    
    Rename CreateContext to CreateDocumentContext, to make its purpose of
    creating only the top-level context more obvious.
    
    With the previous changes to CreateContext overrides in sw,
    reportdesign and dbaccess, this hopefully shouldn't break anything.
    
    Change-Id: I9e147bf6297bbac9e8470454881da73f6e39db0a

diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index e6db6b055d41..553b536e8ec9 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -514,7 +514,7 @@ public:
     }
 };
 
-SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
+SvXMLImportContext* ODBFilter::CreateDocumentContext(sal_uInt16 const nPrefix,
                                       const OUString& rLocalName,
                                       const uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
 {
@@ -538,7 +538,7 @@ SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
     }
 
     if ( !pContext )
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext( nPrefix, rLocalName, xAttrList );
 
     return pContext;
 }
diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx
index abe106cb60b1..9c8188ebb21b 100644
--- a/dbaccess/source/filter/xml/xmlfilter.hxx
+++ b/dbaccess/source/filter/xml/xmlfilter.hxx
@@ -99,7 +99,7 @@ public:
 
 protected:
     // SvXMLImport
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
                                       const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
 
diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx
index 91c61b1f5a8c..7fad6fa1419d 100644
--- a/editeng/source/xml/xmltxtimp.cxx
+++ b/editeng/source/xml/xmltxtimp.cxx
@@ -104,14 +104,16 @@ public:
         const css::uno::Reference< css::uno::XComponentContext >& rContext,
         const uno::Reference< XText > & rText );
 
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
         const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList >& xAttrList )  override;
 
 private:
     const uno::Reference< XText > mxText;
 };
 
-SvXMLImportContext *SvxXMLXTextImportComponent::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+SvXMLImportContext *SvxXMLXTextImportComponent::CreateDocumentContext(
+        sal_uInt16 const nPrefix, const OUString& rLocalName,
+        const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/)
 {
     SvXMLImportContext* pContext = nullptr;
 
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index b6552a297843..483a1a36b660 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -240,9 +240,11 @@ protected:
     bool                        mbIsTableShapeSupported;
     bool                        mbIsGraphicLoadOnDemandSupported;
 
+    // Create top-level element context.
     // This method is called after the namespace map has been updated, but
     // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    // This base class implementation returns a context that ignores everything.
+    virtual SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
                                                const OUString& rLocalName,
                                                const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
     virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
diff --git a/linguistic/source/convdicxml.cxx b/linguistic/source/convdicxml.cxx
index 964a51edc396..97a1d6a56268 100644
--- a/linguistic/source/convdicxml.cxx
+++ b/linguistic/source/convdicxml.cxx
@@ -370,7 +370,7 @@ void SAL_CALL ConvDicXMLImport::startDocument()
     SvXMLImport::startDocument();
 }
 
-SvXMLImportContext * ConvDicXMLImport::CreateContext(
+SvXMLImportContext * ConvDicXMLImport::CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString &rLocalName,
         const uno::Reference < xml::sax::XAttributeList > & /*rxAttrList*/ )
diff --git a/linguistic/source/convdicxml.hxx b/linguistic/source/convdicxml.hxx
index 5339a85e2dae..9a2b3c776c37 100644
--- a/linguistic/source/convdicxml.hxx
+++ b/linguistic/source/convdicxml.hxx
@@ -87,7 +87,7 @@ public:
 
     virtual void SAL_CALL startDocument() override;
 
-    virtual SvXMLImportContext * CreateContext(
+    virtual SvXMLImportContext * CreateDocumentContext(
         sal_uInt16 nPrefix, const OUString &rLocalName,
         const css::uno::Reference < css::xml::sax::XAttributeList > &rxAttrList ) override;
 
diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx
index 7d23913ff5e2..b7223bd0ef0d 100644
--- a/reportdesign/source/filter/xml/xmlfilter.cxx
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -725,7 +725,7 @@ public:
     }
 };
 
-SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix,
+SvXMLImportContext* ORptFilter::CreateDocumentContext( sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
                                       const uno::Reference< xml::sax::XAttributeList >& xAttrList )
 {
@@ -753,7 +753,7 @@ SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix,
     }
 
     if ( !pContext )
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext( nPrefix, rLocalName, xAttrList );
 
     return pContext;
 }
diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx b/reportdesign/source/filter/xml/xmlfilter.hxx
index c858e66f53de..1f6531a9b795 100644
--- a/reportdesign/source/filter/xml/xmlfilter.hxx
+++ b/reportdesign/source/filter/xml/xmlfilter.hxx
@@ -104,7 +104,7 @@ public:
             const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
 protected:
     // SvXMLImport
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
             const OUString& rLocalName,
             const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
 
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index e0795f56808d..b3f464b1def2 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -658,7 +658,7 @@ sc::PivotTableSources& ScXMLImport::GetPivotTableSources()
     return *mpPivotSources;
 }
 
-SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix,
+SvXMLImportContext *ScXMLImport::CreateDocumentContext( sal_uInt16 nPrefix,
                                                const OUString& rLocalName,
                                                const uno::Reference<xml::sax::XAttributeList>& xAttrList )
 {
@@ -676,7 +676,7 @@ SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix,
                 xDPS->getDocumentProperties());
     }
     else
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext( nPrefix, rLocalName, xAttrList );
 
     return pContext;
 }
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 6cf664bdcf8d..c0cfeae34cee 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -373,9 +373,7 @@ class ScXMLImport: public SvXMLImport
 
 protected:
 
-    // This method is called after the namespace map has been updated, but
-    // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
                                       const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
 
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 500ecff58425..2147001061de 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2789,7 +2789,7 @@ void SmXMLActionContext_Impl::EndElement()
     rNodeStack.push_front(std::move(pSelected));
 }
 
-SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
+SvXMLImportContext *SmXMLImport::CreateDocumentContext(sal_uInt16 nPrefix,
     const OUString &rLocalName,
     const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
 {
diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx
index 4db626df4d0a..3d017c1a25a7 100644
--- a/starmath/source/mathmlimport.hxx
+++ b/starmath/source/mathmlimport.hxx
@@ -94,7 +94,7 @@ public:
 
     void SAL_CALL endDocument() override;
 
-    SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
+    SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
         const OUString &rLocalName,
         const css::uno::Reference <
         css::xml::sax::XAttributeList> &xAttrList) override;
diff --git a/svx/source/inc/xmlxtimp.hxx b/svx/source/inc/xmlxtimp.hxx
index c7ca90c03859..ba4563efa21b 100644
--- a/svx/source/inc/xmlxtimp.hxx
+++ b/svx/source/inc/xmlxtimp.hxx
@@ -45,7 +45,7 @@ public:
                       const css::uno::Reference< css::container::XNameContainer >& xTable,
                       bool *bOptLoadedFromStorage ) throw();
 protected:
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
                                       const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
 
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index ade13897ecf2..207912fca311 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -417,7 +417,9 @@ bool SvxXMLXTableImport::load( const OUString &rPath, const OUString &rReferer,
     return bRet;
 }
 
-SvXMLImportContext *SvxXMLXTableImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& /*xAttrList*/ )
+SvXMLImportContext *SvxXMLXTableImport::CreateDocumentContext(
+        sal_uInt16 const nPrefix, const OUString& rLocalName,
+        const uno::Reference< XAttributeList >& /*xAttrList*/)
 {
     if( XML_NAMESPACE_OOO == nPrefix ||
         XML_NAMESPACE_OFFICE == nPrefix )
diff --git a/sw/inc/SwXMLSectionList.hxx b/sw/inc/SwXMLSectionList.hxx
index 45fd8bc8c2c7..82c8f66340dd 100644
--- a/sw/inc/SwXMLSectionList.hxx
+++ b/sw/inc/SwXMLSectionList.hxx
@@ -24,9 +24,7 @@
 class SwXMLSectionList : public SvXMLImport
 {
 protected:
-    // This method is called after the namespace map has been updated, but
-    // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
                   const OUString& rLocalName,
                   const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
 
diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 2e90f05a518a..cad35a9958bd 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -103,7 +103,7 @@ SwXMLSectionList::~SwXMLSectionList()
 {
 }
 
-SvXMLImportContext *SwXMLSectionList::CreateContext(
+SvXMLImportContext *SwXMLSectionList::CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const uno::Reference<xml::sax::XAttributeList> & )
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index d892d7768775..e2118d87ca34 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -353,7 +353,7 @@ const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap()
     return *m_pDocElemTokenMap;
 }
 
-SvXMLImportContext *SwXMLImport::CreateContext(
+SvXMLImportContext *SwXMLImport::CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const Reference< xml::sax::XAttributeList > & xAttrList )
@@ -385,7 +385,7 @@ SvXMLImportContext *SwXMLImport::CreateContext(
                         xDocProps);
     }
     else
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
 
     return pContext;
 }
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index 444186992c34..aa7ad833e356 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -103,9 +103,7 @@ class SwXMLImport: public SvXMLImport
 
 protected:
 
-    // This method is called after the namespace map has been updated, but
-    // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
                   const OUString& rLocalName,
                   const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
 
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
index c575863f00e7..531e5b424bbc 100644
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
@@ -386,7 +386,7 @@ public:
     {
     }
 
-    virtual SvXMLImportContext * CreateContext(
+    virtual SvXMLImportContext * CreateDocumentContext(
         sal_uInt16 const nPrefix, OUString const& rLocalName,
         uno::Reference<xml::sax::XAttributeList> const& xAttrList) override
     {
@@ -395,7 +395,7 @@ public:
             return new StoredChapterNumberingRootContext(m_rNumRules,
                     *this, nPrefix, rLocalName);
         }
-        return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
+        return SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 };
 
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 4119496c5894..3248d4ceadbd 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -154,7 +154,7 @@ private:
     rtl::Reference<SchXMLImportHelper> maImportHelper;
 
 protected:
-    virtual SvXMLImportContext *CreateContext(
+    virtual SvXMLImportContext *CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
diff --git a/xmloff/inc/xmlversion.hxx b/xmloff/inc/xmlversion.hxx
index e709efb6f5a4..e39cfdda5521 100644
--- a/xmloff/inc/xmlversion.hxx
+++ b/xmloff/inc/xmlversion.hxx
@@ -56,9 +56,7 @@ private:
 
 protected:
 
-    // This method is called after the namespace map has been updated, but
-    // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+    virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix,
                     const OUString& rLocalName,
                     const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
 
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index d3c40c78887d..b7dc42566ec3 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -510,7 +510,8 @@ SchXMLImport::~SchXMLImport() throw ()
 
 // create the main context (subcontexts are created
 // by the one created here)
-SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName,
+SvXMLImportContext *SchXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
     const Reference< xml::sax::XAttributeList >& xAttrList )
 {
     SvXMLImportContext* pContext = nullptr;
@@ -540,12 +541,12 @@ SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUStr
                             xDPS->getDocumentProperties());
         } else {
             pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
-                ? SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList )
+                ? SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList)
                 : new SchXMLDocContext( *maImportHelper.get(), *this,
                                         nPrefix, rLocalName );
         }
     } else {
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 
     return pContext;
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index e1805057dcdd..a00539afce6b 100644
--- a/xmloff/source/core/xmlictxt.cxx
+++ b/xmloff/source/core/xmlictxt.cxx
@@ -48,10 +48,10 @@ SvXMLImportContext::~SvXMLImportContext()
 }
 
 SvXMLImportContextRef SvXMLImportContext::CreateChildContext( sal_uInt16 nPrefix,
-                                            const OUString& rLocalName,
-                                            const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList>& )
 {
-    return mrImport.CreateContext( nPrefix, rLocalName, xAttrList );
+    return new SvXMLImportContext(mrImport, nPrefix, rLocalName);
 }
 
 void SvXMLImportContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& )
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index f96940aeb575..676d6be7d071 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -308,7 +308,7 @@ public:
     ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
 };
 
-SvXMLImportContext *SvXMLImport::CreateContext( sal_uInt16 nPrefix,
+SvXMLImportContext *SvXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix,
                                          const OUString& rLocalName,
                                          const uno::Reference< xml::sax::XAttributeList >& )
 {
@@ -719,7 +719,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName,
     }
     else
     {
-        xContext.set(CreateContext( nPrefix, aLocalName, xAttrList ));
+        xContext.set(CreateDocumentContext(nPrefix, aLocalName, xAttrList));
         if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 &&
             dynamic_cast< const SvXMLImportContext*>(xContext.get()) !=  nullptr )
         {
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index 8134fd671499..75553fa8a1cd 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -1243,7 +1243,7 @@ class AnimationsImport: public SvXMLImport, public XAnimationNodeSupplier
 public:
     explicit AnimationsImport( const Reference< XComponentContext > & rxContext );
 
-    SvXMLImportContext* CreateContext(sal_uInt16 nPrefix, const OUString& rLocalName,   const Reference<XAttributeList>& xAttrList) override;
+    SvXMLImportContext* CreateDocumentContext(sal_uInt16 nPrefix, const OUString& rLocalName,   const Reference<XAttributeList>& xAttrList) override;
 
     // XInterface
     virtual Any SAL_CALL queryInterface( const Type& aType ) override;
@@ -1305,7 +1305,9 @@ void SAL_CALL AnimationsImport::release() throw ()
     SvXMLImport::release();
 }
 
-SvXMLImportContext *AnimationsImport::CreateContext(sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& xAttrList)
+SvXMLImportContext *AnimationsImport::CreateDocumentContext(
+        sal_uInt16 const nPrefix, const OUString& rLocalName,
+        const Reference<XAttributeList>& xAttrList)
 {
     SvXMLImportContext* pContext = nullptr;
 
@@ -1315,7 +1317,7 @@ SvXMLImportContext *AnimationsImport::CreateContext(sal_uInt16 nPrefix, const OU
     }
     else
     {
-        pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
+        pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 
     return pContext;
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index bb02d346bf24..ed2848036239 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -584,7 +584,7 @@ const SvXMLTokenMap& SdXMLImport::GetPresentationPlaceholderAttrTokenMap()
     return *mpPresentationPlaceholderAttrTokenMap;
 }
 
-SvXMLImportContext *SdXMLImport::CreateContext(sal_uInt16 nPrefix,
+SvXMLImportContext *SdXMLImport::CreateDocumentContext(sal_uInt16 nPrefix,
     const OUString& rLocalName,
     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
 {
@@ -607,7 +607,7 @@ SvXMLImportContext *SdXMLImport::CreateContext(sal_uInt16 nPrefix,
         pContext = new SdXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
                         xAttrList, xDPS->getDocumentProperties());
     } else {
-        pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
+        pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 
     return pContext;
diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx
index 9dcf7715a76a..3900aa02aaf4 100644
--- a/xmloff/source/draw/sdxmlimp_impl.hxx
+++ b/xmloff/source/draw/sdxmlimp_impl.hxx
@@ -175,9 +175,8 @@ class SdXMLImport: public SvXMLImport
     DateTimeDeclMap             maDateTimeDeclsMap;
 
 protected:
-    // This method is called after the namespace map has been updated, but
-    // before a context for the current element has been pushed.
-    virtual SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
+
+    virtual SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
       const OUString& rLocalName,
       const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList) override;
 
diff --git a/xmloff/source/meta/MetaImportComponent.cxx b/xmloff/source/meta/MetaImportComponent.cxx
index 2ba733d1abc0..2159916ad9cc 100644
--- a/xmloff/source/meta/MetaImportComponent.cxx
+++ b/xmloff/source/meta/MetaImportComponent.cxx
@@ -43,7 +43,7 @@ public:
 
 protected:
 
-    virtual SvXMLImportContext* CreateContext(
+    virtual SvXMLImportContext* CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
@@ -68,7 +68,7 @@ XMLMetaImportComponent::XMLMetaImportComponent(
 {
 }
 
-SvXMLImportContext* XMLMetaImportComponent::CreateContext(
+SvXMLImportContext* XMLMetaImportComponent::CreateDocumentContext(
     sal_uInt16 nPrefix,
     const OUString& rLocalName,
     const uno::Reference<xml::sax::XAttributeList > & xAttrList )
@@ -86,7 +86,7 @@ SvXMLImportContext* XMLMetaImportComponent::CreateContext(
     }
     else
     {
-        return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
+        return SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 }
 
diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx
index 080a954536aa..48104f58ff34 100644
--- a/xmloff/source/meta/xmlversion.cxx
+++ b/xmloff/source/meta/xmlversion.cxx
@@ -112,7 +112,7 @@ XMLVersionListImport::XMLVersionListImport(
 XMLVersionListImport::~XMLVersionListImport() throw()
 {}
 
-SvXMLImportContext *XMLVersionListImport::CreateContext(
+SvXMLImportContext *XMLVersionListImport::CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const Reference< XAttributeList > & xAttrList )
@@ -126,7 +126,7 @@ SvXMLImportContext *XMLVersionListImport::CreateContext(
     }
     else
     {
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+        pContext = SvXMLImport::CreateDocumentContext( nPrefix, rLocalName, xAttrList );
     }
 
     return pContext;
diff --git a/xmloff/source/text/XMLAutoTextEventImport.cxx b/xmloff/source/text/XMLAutoTextEventImport.cxx
index dcb7d93554b3..285a8ca1d13b 100644
--- a/xmloff/source/text/XMLAutoTextEventImport.cxx
+++ b/xmloff/source/text/XMLAutoTextEventImport.cxx
@@ -85,7 +85,7 @@ void XMLAutoTextEventImport::initialize(
 }
 
 
-SvXMLImportContext* XMLAutoTextEventImport::CreateContext(
+SvXMLImportContext* XMLAutoTextEventImport::CreateDocumentContext(
     sal_uInt16 nPrefix,
     const OUString& rLocalName,
     const Reference<XAttributeList > & xAttrList )
@@ -98,7 +98,7 @@ SvXMLImportContext* XMLAutoTextEventImport::CreateContext(
     }
     else
     {
-        return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
+        return SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
     }
 }
 
diff --git a/xmloff/source/text/XMLAutoTextEventImport.hxx b/xmloff/source/text/XMLAutoTextEventImport.hxx
index 0d7b4d4787fb..6413033dee4a 100644
--- a/xmloff/source/text/XMLAutoTextEventImport.hxx
+++ b/xmloff/source/text/XMLAutoTextEventImport.hxx
@@ -52,7 +52,7 @@ public:
 
 protected:
 
-    virtual SvXMLImportContext* CreateContext(
+    virtual SvXMLImportContext* CreateDocumentContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
commit ebb34571c19c5ac939fbf5aed2ab66ee18e298dc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Nov 30 18:00:53 2017 +0100

    dbaccess: split up ODBFilter::CreateContext()
    
    This was handling XML elements at 3 different levels; add some more
    context classes to handle the nesting better.
    
    Change-Id: I05d7b2b7dc2d797acd4e97eacb54fa07e32d88e2

diff --git a/dbaccess/source/filter/xml/xmlEnums.hxx b/dbaccess/source/filter/xml/xmlEnums.hxx
index de87caa26b48..397e9bc592a4 100644
--- a/dbaccess/source/filter/xml/xmlEnums.hxx
+++ b/dbaccess/source/filter/xml/xmlEnums.hxx
@@ -25,11 +25,17 @@ namespace dbaxml
 {
     enum XMLDocTokens
     {
-        XML_TOK_DOC_AUTOSTYLES,
         XML_TOK_DOC_SETTINGS,
-        XML_TOK_DOC_DATABASE,
         XML_TOK_DOC_STYLES,
-        XML_TOK_DOC_SCRIPT
+        XML_TOK_DOC_CONTENT,
+        XML_TOK_DOC_META
+    };
+    enum XMLDocContentTokens
+    {
+        XML_TOK_CONTENT_AUTOSTYLES,
+        XML_TOK_CONTENT_STYLES,
+        XML_TOK_CONTENT_SCRIPTS,
+        XML_TOK_CONTENT_BODY,
     };
     enum XMLDatabaseToken
     {
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index f386206bec66..e6db6b055d41 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -382,6 +382,137 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
     return bRet;
 }
 
+class DBXMLDocumentSettingsContext : public SvXMLImportContext
+{
+public:
+    DBXMLDocumentSettingsContext(SvXMLImport & rImport,
+           sal_uInt16 const nPrefix,
+           const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        if (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken(rLocalName, XML_SETTINGS))
+        {
+            return new XMLDocumentSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList);
+        }
+        else
+        {
+            return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+        }
+    }
+};
+
+class DBXMLDocumentStylesContext : public SvXMLImportContext
+{
+public:
+    DBXMLDocumentStylesContext(SvXMLImport & rImport,
+            sal_uInt16 const nPrefix,
+            const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        SvXMLImportContext *pContext = nullptr;
+
+        ODBFilter & rImport(static_cast<ODBFilter&>(GetImport()));
+        const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap();
+        switch (rTokenMap.Get(nPrefix, rLocalName))
+        {
+            case XML_TOK_CONTENT_STYLES:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, false);
+                break;
+            case XML_TOK_CONTENT_AUTOSTYLES:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, true);
+                break;
+            default:
+                break;
+        }
+
+        if (!pContext)
+            pContext = new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+
+        return pContext;
+    }
+};
+
+class DBXMLDocumentBodyContext : public SvXMLImportContext
+{
+public:
+    DBXMLDocumentBodyContext(SvXMLImport & rImport,
+           sal_uInt16 const nPrefix,
+           const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> &) override
+    {
+        if ((XML_NAMESPACE_OFFICE == nPrefix || XML_NAMESPACE_OOO == nPrefix)
+            && IsXMLToken(rLocalName, XML_DATABASE))
+        {
+            ODBFilter & rImport(static_cast<ODBFilter&>(GetImport()));
+            rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+            return new OXMLDatabase(rImport, nPrefix, rLocalName );
+        }
+        else
+        {
+            return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+        }
+    }
+};
+
+class DBXMLDocumentContentContext : public SvXMLImportContext
+{
+public:
+    DBXMLDocumentContentContext(SvXMLImport & rImport,
+            sal_uInt16 const nPrefix,
+            const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        SvXMLImportContext *pContext = nullptr;
+
+        ODBFilter & rImport(static_cast<ODBFilter&>(GetImport()));
+        const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap();
+        switch (rTokenMap.Get(nPrefix, rLocalName))
+        {
+            case XML_TOK_CONTENT_AUTOSTYLES:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, true);
+                break;
+            case XML_TOK_CONTENT_SCRIPTS:
+                pContext = new XMLScriptContext(GetImport(), rLocalName, rImport.GetModel());
+                break;
+            case XML_TOK_CONTENT_BODY:
+                pContext = new DBXMLDocumentBodyContext(rImport, nPrefix, rLocalName);
+            default:
+                break;
+        }
+
+        if (!pContext)
+            pContext = new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+
+        return pContext;
+    }
+};
 
 SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
@@ -394,22 +525,15 @@ SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
     {
         case XML_TOK_DOC_SETTINGS:
             GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList );
-            break;
-        case XML_TOK_DOC_DATABASE:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = new OXMLDatabase( *this, nPrefix, rLocalName );
+            pContext = new DBXMLDocumentSettingsContext(*this, nPrefix, rLocalName);
             break;
         case XML_TOK_DOC_STYLES:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, false);
+            pContext = new DBXMLDocumentStylesContext(*this, nPrefix, rLocalName);
             break;
-        case XML_TOK_DOC_AUTOSTYLES:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, true);
+        case XML_TOK_DOC_CONTENT:
+            pContext = new DBXMLDocumentContentContext(*this, nPrefix, rLocalName);
             break;
-        case XML_TOK_DOC_SCRIPT:
-            pContext = new XMLScriptContext( *this, rLocalName, GetModel() );
+        default:
             break;
     }
 
@@ -478,15 +602,12 @@ const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const
     {
         static const SvXMLTokenMapEntry aElemTokenMap[]=
         {
-            { XML_NAMESPACE_OFFICE, XML_SETTINGS,           XML_TOK_DOC_SETTINGS    },
-            { XML_NAMESPACE_OOO,    XML_SETTINGS,           XML_TOK_DOC_SETTINGS    },
-            { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_DOC_STYLES      },
-            { XML_NAMESPACE_OOO,    XML_STYLES,             XML_TOK_DOC_STYLES      },
-            { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_DOC_AUTOSTYLES  },
-            { XML_NAMESPACE_OOO,    XML_AUTOMATIC_STYLES,   XML_TOK_DOC_AUTOSTYLES  },
-            { XML_NAMESPACE_OFFICE, XML_DATABASE,           XML_TOK_DOC_DATABASE    },
-            { XML_NAMESPACE_OOO,    XML_DATABASE,           XML_TOK_DOC_DATABASE    },
-            { XML_NAMESPACE_OFFICE, XML_SCRIPTS,            XML_TOK_DOC_SCRIPT      },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_SETTINGS,  XML_TOK_DOC_SETTINGS    },
+            { XML_NAMESPACE_OOO,    XML_DOCUMENT_SETTINGS,  XML_TOK_DOC_SETTINGS    },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_STYLES,    XML_TOK_DOC_STYLES      },
+            { XML_NAMESPACE_OOO,    XML_DOCUMENT_STYLES,    XML_TOK_DOC_STYLES      },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_CONTENT,   XML_TOK_DOC_CONTENT     },
+            { XML_NAMESPACE_OOO,    XML_DOCUMENT_CONTENT,   XML_TOK_DOC_CONTENT     },
             XML_TOKEN_MAP_END
         };
         m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
@@ -494,6 +615,25 @@ const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const
     return *m_pDocElemTokenMap;
 }
 
+const SvXMLTokenMap& ODBFilter::GetDocContentElemTokenMap() const
+{
+    if (!m_pDocContentElemTokenMap.get())
+    {
+        static const SvXMLTokenMapEntry aElemTokenMap[]=
+        {
+            { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_CONTENT_STYLES      },
+            { XML_NAMESPACE_OOO,    XML_STYLES,             XML_TOK_CONTENT_STYLES      },
+            { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_CONTENT_AUTOSTYLES  },
+            { XML_NAMESPACE_OOO,    XML_AUTOMATIC_STYLES,   XML_TOK_CONTENT_AUTOSTYLES  },
+            { XML_NAMESPACE_OFFICE, XML_SCRIPTS,            XML_TOK_CONTENT_SCRIPTS     },
+            { XML_NAMESPACE_OFFICE, XML_BODY,               XML_TOK_CONTENT_BODY        },
+            XML_TOKEN_MAP_END
+        };
+        m_pDocContentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+    }
+    return *m_pDocContentElemTokenMap;
+}
+
 
 const SvXMLTokenMap& ODBFilter::GetDatabaseElemTokenMap() const
 {
diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx
index d2372d849d08..abe106cb60b1 100644
--- a/dbaccess/source/filter/xml/xmlfilter.hxx
+++ b/dbaccess/source/filter/xml/xmlfilter.hxx
@@ -65,6 +65,7 @@ private:
     TInfoSequence                                   m_aInfoSequence;
 
     mutable std::unique_ptr<SvXMLTokenMap>          m_pDocElemTokenMap;
+    mutable std::unique_ptr<SvXMLTokenMap>          m_pDocContentElemTokenMap;
     mutable std::unique_ptr<SvXMLTokenMap>          m_pDatabaseElemTokenMap;
     mutable std::unique_ptr<SvXMLTokenMap>          m_pDataSourceElemTokenMap;
     mutable std::unique_ptr<SvXMLTokenMap>          m_pLoginElemTokenMap;
@@ -92,6 +93,7 @@ private:
     */
     static void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap);
 
+public:
     SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const OUString& rLocalName,
                                      const Reference< XAttributeList>& xAttrList, bool bIsAutoStyle );
 
@@ -128,6 +130,7 @@ public:
     const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;}
 
     const SvXMLTokenMap& GetDocElemTokenMap() const;
+    const SvXMLTokenMap& GetDocContentElemTokenMap() const;
     const SvXMLTokenMap& GetDatabaseElemTokenMap() const;
     const SvXMLTokenMap& GetDataSourceElemTokenMap() const;
     const SvXMLTokenMap& GetLoginElemTokenMap() const;
commit 2bda2100d8abbf66285551379215579108a4ebf0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Nov 30 14:43:58 2017 +0100

    reportdesign: split up ORptFilter::CreateContext()
    
    This was handling XML elements at 3 different levels; add some more
    context classes to handle the nesting better.
    
    There was one tricky case: the ORptExport::exportContainer()
    can export a office:report element inside office:body
    inside report:sub-document, but i don't know how to
    create a report like that.
    
    This was previously handled on import via the fallback to
    SvXMLImportContext (created for office:body) calling
    ORptFilter::CreateContext(), but now it needs explicit handling
    in OXMLSubDocument::CreateChildContext_().
    
    Change-Id: I839986599b2b936f57bb65da355ac1be811fe999

diff --git a/reportdesign/source/filter/xml/xmlEnums.hxx b/reportdesign/source/filter/xml/xmlEnums.hxx
index 91214fea3171..2a98c7103c22 100644
--- a/reportdesign/source/filter/xml/xmlEnums.hxx
+++ b/reportdesign/source/filter/xml/xmlEnums.hxx
@@ -25,14 +25,19 @@ namespace rptxml
 {
     enum XMLDocTokens
     {
-        XML_TOK_DOC_AUTOSTYLES,
         XML_TOK_DOC_SETTINGS,
-        XML_TOK_DOC_REPORT,
         XML_TOK_DOC_STYLES,
-        XML_TOK_DOC_FONTDECLS,
-        XML_TOK_DOC_MASTERSTYLES,
+        XML_TOK_DOC_CONTENT,
         XML_TOK_DOC_META
     };
+    enum XMLDocContentTokens
+    {
+        XML_TOK_CONTENT_AUTOSTYLES,
+        XML_TOK_CONTENT_STYLES,
+        XML_TOK_CONTENT_FONTDECLS,
+        XML_TOK_CONTENT_MASTERSTYLES,
+        XML_TOK_CONTENT_BODY,
+    };
     enum XMLReportToken
     {
         XML_TOK_REPORT_HEADER,
@@ -53,7 +58,8 @@ namespace rptxml
         XML_TOK_REPORT_MIMETYPE         ,
         XML_TOK_REPORT_NAME             ,
         XML_TOK_MASTER_DETAIL_FIELDS    ,
-        XML_TOK_SUB_FRAME
+        XML_TOK_SUB_FRAME               ,
+        XML_TOK_SUB_BODY                ,
     };
     enum XMLGroup
     {
diff --git a/reportdesign/source/filter/xml/xmlHelper.cxx b/reportdesign/source/filter/xml/xmlHelper.cxx
index cf6167001ebd..c9b2002dbd3b 100644
--- a/reportdesign/source/filter/xml/xmlHelper.cxx
+++ b/reportdesign/source/filter/xml/xmlHelper.cxx
@@ -352,6 +352,7 @@ SvXMLTokenMap* OXMLHelper::GetReportElemTokenMap()
         { XML_NAMESPACE_DRAW,   XML_NAME,                       XML_TOK_REPORT_NAME             },
         { XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS,       XML_TOK_MASTER_DETAIL_FIELDS    },
         { XML_NAMESPACE_DRAW,   XML_FRAME,                      XML_TOK_SUB_FRAME               },
+        { XML_NAMESPACE_OFFICE, XML_BODY,                       XML_TOK_SUB_BODY },
         XML_TOKEN_MAP_END
     };
     return new SvXMLTokenMap( aElemTokenMap );
diff --git a/reportdesign/source/filter/xml/xmlSubDocument.cxx b/reportdesign/source/filter/xml/xmlSubDocument.cxx
index 4c84af1e728f..c8c01a6c85b8 100644
--- a/reportdesign/source/filter/xml/xmlSubDocument.cxx
+++ b/reportdesign/source/filter/xml/xmlSubDocument.cxx
@@ -87,6 +87,12 @@ SvXMLImportContextRef OXMLSubDocument::CreateChildContext_(
                 }
             }
             break;
+        // FIXME: is it *intentional* that this is supported?
+        // ORptExport::exportContainer() can export this but the import
+        // used to be rather accidental previously
+        case XML_TOK_SUB_BODY:
+            xContext = new RptXMLDocumentBodyContext(GetImport(), _nPrefix, _rLocalName);
+            break;
         default:
             break;
     }
diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx
index cb16957ea836..7d23913ff5e2 100644
--- a/reportdesign/source/filter/xml/xmlfilter.cxx
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -582,6 +582,149 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
     return bRet;
 }
 
+class RptXMLDocumentSettingsContext : public SvXMLImportContext
+{
+public:
+    RptXMLDocumentSettingsContext(SvXMLImport & rImport,
+           sal_uInt16 const nPrefix,
+           const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        if (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken(rLocalName, XML_SETTINGS))
+        {
+            return new XMLDocumentSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList);
+        }
+        else
+        {
+            return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+        }
+    }
+};
+
+class RptXMLDocumentStylesContext : public SvXMLImportContext
+{
+public:
+    RptXMLDocumentStylesContext(SvXMLImport & rImport,
+            sal_uInt16 const nPrefix,
+            const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        SvXMLImportContext *pContext = nullptr;
+
+        ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
+        const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap();
+        switch (rTokenMap.Get(nPrefix, rLocalName))
+        {
+            case XML_TOK_CONTENT_STYLES:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateStylesContext(rLocalName, xAttrList, false);
+                break;
+            case XML_TOK_CONTENT_AUTOSTYLES:
+                // don't use the autostyles from the styles-document for the progress
+                pContext = rImport.CreateStylesContext(rLocalName, xAttrList, true);
+                break;
+            case XML_TOK_CONTENT_FONTDECLS:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateFontDeclsContext(rLocalName, xAttrList);
+                break;
+            case XML_TOK_CONTENT_MASTERSTYLES:
+                {
+                    SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(rImport, nPrefix, rLocalName, xAttrList);//CreateMasterStylesContext( rLocalName,xAttrList );
+                    pContext = pStyleContext;
+                    rImport.SetMasterStyles(pStyleContext);
+                }
+                break;
+            default:
+                break;
+        }
+
+        if (!pContext)
+            pContext = new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+
+        return pContext;
+    }
+};
+
+SvXMLImportContextRef RptXMLDocumentBodyContext::CreateChildContext(
+        sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList> & xAttrList)
+{
+    ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
+    if ((XML_NAMESPACE_OFFICE == nPrefix || XML_NAMESPACE_OOO == nPrefix)
+        && IsXMLToken(rLocalName, XML_REPORT))
+    {
+        rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+        const SvXMLStylesContext* pAutoStyles = rImport.GetAutoStyles();
+        if (pAutoStyles)
+        {
+            XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast<const XMLPropStyleContext *>(pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_PAGE_MASTER, "pm1")));
+            if (pAutoStyle)
+            {
+                pAutoStyle->FillPropertySet(rImport.getReportDefinition().get());
+            }
+        }
+        return new OXMLReport(rImport, nPrefix, rLocalName, xAttrList, rImport.getReportDefinition());
+    }
+    else
+    {
+        return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+    }
+}
+
+class RptXMLDocumentContentContext : public SvXMLImportContext
+{
+public:
+    RptXMLDocumentContentContext(SvXMLImport & rImport,
+            sal_uInt16 const nPrefix,
+            const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+        const OUString& rLocalName,
+        const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        SvXMLImportContext *pContext = nullptr;
+
+        ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
+        const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap();
+        switch (rTokenMap.Get(nPrefix, rLocalName))
+        {
+            case XML_TOK_CONTENT_AUTOSTYLES:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateStylesContext(rLocalName, xAttrList, true);
+                break;
+            case XML_TOK_CONTENT_FONTDECLS:
+                rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+                pContext = rImport.CreateFontDeclsContext(rLocalName, xAttrList);
+                break;
+            case XML_TOK_CONTENT_BODY:
+                pContext = new RptXMLDocumentBodyContext(rImport, nPrefix, rLocalName);
+            default:
+                break;
+        }
+
+        if (!pContext)
+            pContext = new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+
+        return pContext;
+    }
+};
+
 SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix,
                                       const OUString& rLocalName,
                                       const uno::Reference< xml::sax::XAttributeList >& xAttrList )
@@ -593,43 +736,13 @@ SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix,
     {
         case XML_TOK_DOC_SETTINGS:
             GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList );
-            break;
-        case XML_TOK_DOC_REPORT:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            {
-                const SvXMLStylesContext* pAutoStyles = GetAutoStyles();
-                if ( pAutoStyles )
-                {
-                    XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext *>(pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_PAGE_MASTER,"pm1")));
-                    if ( pAutoStyle )
-                    {
-                        pAutoStyle->FillPropertySet(getReportDefinition().get());
-                    }
-                }
-                pContext = new OXMLReport( *this, nPrefix, rLocalName,xAttrList,getReportDefinition() );
-            }
+            pContext = new RptXMLDocumentSettingsContext(*this, nPrefix, rLocalName);
             break;
         case XML_TOK_DOC_STYLES:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = CreateStylesContext( rLocalName, xAttrList, false);
+            pContext = new RptXMLDocumentStylesContext(*this, nPrefix, rLocalName);
             break;
-        case XML_TOK_DOC_AUTOSTYLES:
-            // don't use the autostyles from the styles-document for the progress
-            if ( ! IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
-                GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = CreateStylesContext( rLocalName, xAttrList, true);
-            break;
-        case XML_TOK_DOC_FONTDECLS:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = CreateFontDeclsContext( rLocalName,xAttrList );
-            break;
-        case XML_TOK_DOC_MASTERSTYLES:
-            {
-                SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(*this, nPrefix, rLocalName,xAttrList);//CreateMasterStylesContext( rLocalName,xAttrList );
-                pContext = pStyleContext;
-                SetMasterStyles( pStyleContext );
-            }
+        case XML_TOK_DOC_CONTENT:
+            pContext = new RptXMLDocumentContentContext(*this, nPrefix, rLocalName);
             break;
         case XML_TOK_DOC_META:
             GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
@@ -651,13 +764,9 @@ const SvXMLTokenMap& ORptFilter::GetDocElemTokenMap() const
     {
         static const SvXMLTokenMapEntry aElemTokenMap[]=
         {
-            { XML_NAMESPACE_OFFICE, XML_SETTINGS,           XML_TOK_DOC_SETTINGS    },
-            { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_DOC_STYLES      },
-            { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_DOC_AUTOSTYLES  },
-            { XML_NAMESPACE_OFFICE, XML_REPORT,             XML_TOK_DOC_REPORT      },
-            { XML_NAMESPACE_OOO,    XML_REPORT,             XML_TOK_DOC_REPORT      },
-            { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS,    XML_TOK_DOC_FONTDECLS   },
-            { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,      XML_TOK_DOC_MASTERSTYLES    },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_SETTINGS,  XML_TOK_DOC_SETTINGS    },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_CONTENT,   XML_TOK_DOC_CONTENT     },
+            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_STYLES,    XML_TOK_DOC_STYLES      },
             { XML_NAMESPACE_OFFICE, XML_DOCUMENT_META,      XML_TOK_DOC_META        },
             XML_TOKEN_MAP_END
         };
@@ -666,6 +775,24 @@ const SvXMLTokenMap& ORptFilter::GetDocElemTokenMap() const
     return *m_pDocElemTokenMap;
 }
 
+const SvXMLTokenMap& ORptFilter::GetDocContentElemTokenMap() const
+{
+    if (!m_pDocContentElemTokenMap.get())
+    {
+        static const SvXMLTokenMapEntry aElemTokenMap[]=
+        {
+            { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_CONTENT_STYLES      },
+            { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_CONTENT_AUTOSTYLES  },
+            { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS,    XML_TOK_CONTENT_FONTDECLS   },
+            { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,      XML_TOK_CONTENT_MASTERSTYLES},
+            { XML_NAMESPACE_OFFICE, XML_BODY,               XML_TOK_CONTENT_BODY        },
+            XML_TOKEN_MAP_END
+        };
+        m_pDocContentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
+    }
+    return *m_pDocContentElemTokenMap;
+}
+
 const SvXMLTokenMap& ORptFilter::GetReportElemTokenMap() const
 {
     if ( !m_pReportElemTokenMap.get() )
diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx b/reportdesign/source/filter/xml/xmlfilter.hxx
index 6969c56859ac..c858e66f53de 100644
--- a/reportdesign/source/filter/xml/xmlfilter.hxx
+++ b/reportdesign/source/filter/xml/xmlfilter.hxx
@@ -70,6 +70,7 @@ private:
     TGroupFunctionMap                               m_aFunctions;
 
     mutable ::std::unique_ptr<SvXMLTokenMap>        m_pDocElemTokenMap;
+    mutable ::std::unique_ptr<SvXMLTokenMap>        m_pDocContentElemTokenMap;
     mutable ::std::unique_ptr<SvXMLTokenMap>        m_pReportElemTokenMap;
     mutable ::std::unique_ptr<SvXMLTokenMap>        m_pGroupElemTokenMap;
     mutable ::std::unique_ptr<SvXMLTokenMap>        m_pSectionElemTokenMap;
@@ -94,6 +95,8 @@ private:
     /// @throws RuntimeException
     bool                            implImport( const Sequence< PropertyValue >& rDescriptor );
 
+public:
+    using SvXMLImport::SetMasterStyles;
     SvXMLImportContext* CreateStylesContext(const OUString& rLocalName,
                                             const Reference< XAttributeList>& xAttrList, bool bIsAutoStyle );
     SvXMLImportContext* CreateMetaContext(const OUString& rLocalName);
@@ -131,6 +134,7 @@ public:
     virtual void SAL_CALL endDocument() override;
 
     const SvXMLTokenMap& GetDocElemTokenMap() const;
+    const SvXMLTokenMap& GetDocContentElemTokenMap() const;
     const SvXMLTokenMap& GetReportElemTokenMap() const;
     const SvXMLTokenMap& GetGroupElemTokenMap() const;
     const SvXMLTokenMap& GetSectionElemTokenMap() const;
@@ -228,6 +232,21 @@ public:
 };
 
 
+class RptXMLDocumentBodyContext : public SvXMLImportContext
+{
+public:
+    RptXMLDocumentBodyContext(SvXMLImport & rImport,
+           sal_uInt16 const nPrefix,
+           const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
+           const OUString& rLocalName,
+           const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
+};
+
 } // rptxml
 
 #endif // INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLFILTER_HXX
commit dfe635d4f523224b7a6991b524dc2635311a5956
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 29 23:24:35 2017 +0100

    sw: std::vector<OUString*> considered silly
    
    Change-Id: Ie5141a01b1a63c083d5fce1842a35a9a4b0d36e3

diff --git a/sw/inc/SwXMLSectionList.hxx b/sw/inc/SwXMLSectionList.hxx
index f157f17fa76f..45fd8bc8c2c7 100644
--- a/sw/inc/SwXMLSectionList.hxx
+++ b/sw/inc/SwXMLSectionList.hxx
@@ -29,12 +29,13 @@ protected:
     virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
                   const OUString& rLocalName,
                   const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+
 public:
-    std::vector<OUString*> &rSectionList;
+    std::vector<OUString> & m_rSectionList;
 
     SwXMLSectionList(
         const css::uno::Reference< css::uno::XComponentContext >& rContext,
-        std::vector<OUString*> &rNewSectionList );
+        std::vector<OUString> & rNewSectionList);
 
     virtual ~SwXMLSectionList ( )
         throw() override;
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 2b2be71c06b5..3509685638f7 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -251,7 +251,7 @@ public:
     // Read the sections of the document, which is equal to the medium.
     // Returns the count of it
     virtual size_t GetSectionList( SfxMedium& rMedium,
-                                   std::vector<OUString*>& rStrings ) const;
+                                   std::vector<OUString>& rStrings) const;
 
     const tools::SvRef<SotStorage>& getSotStorageRef() { return pStg; };
     void setSotStorageRef(const tools::SvRef<SotStorage>& pStgRef) { pStg = pStgRef; };
diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index a0f484098201..2e90f05a518a 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -84,9 +84,9 @@ public:
 
 SwXMLSectionList::SwXMLSectionList(
     const uno::Reference< uno::XComponentContext >& rContext,
-    std::vector<OUString*> &rNewSectionList)
-:   SvXMLImport( rContext, "" ),
-    rSectionList ( rNewSectionList )
+    std::vector<OUString> &rNewSectionList)
+: SvXMLImport(rContext, "")
+, m_rSectionList(rNewSectionList)
 {
     // TODO: verify if these should match the same-name constants
     //       in xmloff/source/core/xmlimp.cxx ("_office" and "_office")
@@ -143,7 +143,7 @@ SvXMLImportContextRef SvXMLSectionListContext::CreateChildContext(
                 sName = xAttrList->getValueByIndex( i );
         }
         if ( !sName.isEmpty() )
-            m_rImport.rSectionList.push_back( new OUString(sName) );
+            m_rImport.m_rSectionList.push_back(sName);
     }
 
     pContext = new SvXMLSectionListContext(m_rImport, nPrefix, rLocalName, xAttrList);
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 8b66489885dd..037c12b4a993 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -632,7 +632,7 @@ void Reader::ResetFrameFormats( SwDoc& rDoc )
 
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
-size_t Reader::GetSectionList( SfxMedium&, std::vector<OUString*>& ) const
+size_t Reader::GetSectionList(SfxMedium&, std::vector<OUString>&) const
 {
     return 0;
 }
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 4dd40872e77a..2a6b55fc0724 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -50,7 +50,7 @@ public:
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
     virtual size_t GetSectionList( SfxMedium& rMedium,
-                                   std::vector<OUString*>& rStrings ) const override;
+                                   std::vector<OUString>& rStrings) const override;
 };
 
 // the special writers
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 652e84ef5ab8..7387986bb892 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -957,7 +957,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
 size_t XMLReader::GetSectionList( SfxMedium& rMedium,
-                                  std::vector<OUString*>& rStrings ) const
+                                  std::vector<OUString>& rStrings) const
 {
     uno::Reference< uno::XComponentContext > xContext =
             comphelper::getProcessComponentContext();
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 78bf7c681bd5..404b2a0f59bc 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -1379,22 +1379,22 @@ IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent&, rEvent, void )
     }
 }
 
-// helper function - read region names from medium
+// helper function - read section names from medium
 static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
 {
     rBox.Clear();
     uno::Reference < embed::XStorage > xStg;
     if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
     {
-        std::vector<OUString*> aArr;
+        std::vector<OUString> aArr;
         SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStg );
         if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
             nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
             SwGetReaderXML()->GetSectionList( rMedium, aArr );
 
-        for(std::vector<OUString*>::const_iterator it(aArr.begin()); it != aArr.end(); ++it) {
-            rBox.InsertEntry( **it );
-            delete *it;
+        for (auto const& it : aArr)
+        {
+            rBox.InsertEntry(it);
         }
     }
 }
commit 2c081e66cd63df812c2d248c7d2b5bb384b21156
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 29 23:11:31 2017 +0100

    sw: move generic code out of SwXMLSectionList::CreateContext
    
    ... into a new class that recursively creates itself
    instead of relying on the import class.
    
    Change-Id: I9bb445ba6a5c490293983d4566bab7b066fb8f24

diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 7ac9c6c9bb7d..a0f484098201 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -42,6 +42,45 @@ public:
     virtual ~SvXMLSectionListContext() override;
 };
 
+class SwXMLParentContext : public SvXMLImportContext
+{
+private:
+    SwXMLSectionList & m_rImport;
+
+public:
+    SwXMLParentContext(SwXMLSectionList& rImport,
+           sal_uInt16 nPrefix,
+           const OUString& rLocalName)
+        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+        , m_rImport(rImport)
+    {
+    }
+
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
+    {
+        if ((nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken(rLocalName, XML_BODY)) ||
+            (nPrefix == XML_NAMESPACE_TEXT &&
+                (   IsXMLToken(rLocalName, XML_P)
+                 || IsXMLToken(rLocalName, XML_H)
+                 || IsXMLToken(rLocalName, XML_A)
+                 || IsXMLToken(rLocalName, XML_SPAN)
+                 || IsXMLToken(rLocalName, XML_SECTION)
+                 || IsXMLToken(rLocalName, XML_INDEX_BODY)
+                 || IsXMLToken(rLocalName, XML_INDEX_TITLE)
+                 || IsXMLToken(rLocalName, XML_INSERTION)
+                 || IsXMLToken(rLocalName, XML_DELETION))))
+        {
+            return new SvXMLSectionListContext(m_rImport, nPrefix, rLocalName, xAttrList);
+        }
+        else
+        {
+            return new SwXMLParentContext(m_rImport, nPrefix, rLocalName);
+        }
+    }
+};
+
 
 SwXMLSectionList::SwXMLSectionList(
     const uno::Reference< uno::XComponentContext >& rContext,
@@ -67,29 +106,9 @@ SwXMLSectionList::~SwXMLSectionList()
 SvXMLImportContext *SwXMLSectionList::CreateContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
-        const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+        const uno::Reference<xml::sax::XAttributeList> & )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if(( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken ( rLocalName, XML_BODY )) ||
-        ( nPrefix == XML_NAMESPACE_TEXT &&
-            (IsXMLToken ( rLocalName, XML_P ) ||
-            IsXMLToken ( rLocalName, XML_H ) ||
-            IsXMLToken ( rLocalName, XML_A ) ||
-            IsXMLToken ( rLocalName, XML_SPAN ) ||
-            IsXMLToken ( rLocalName, XML_SECTION ) ||
-            IsXMLToken ( rLocalName, XML_INDEX_BODY ) ||
-            IsXMLToken ( rLocalName, XML_INDEX_TITLE )||
-            IsXMLToken ( rLocalName, XML_INSERTION ) ||
-            IsXMLToken ( rLocalName, XML_DELETION ) )
-        )
-      )
-    {
-        pContext = new SvXMLSectionListContext (*this, nPrefix, rLocalName, xAttrList);
-    }
-    else
-        pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
-    return pContext;
+    return new SwXMLParentContext(*this, nPrefix, rLocalName);
 }
 
 SvXMLSectionListContext::SvXMLSectionListContext(
commit 346abc6785117ad0a3353eec2bc2f4d1b8db9fb7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 29 22:59:16 2017 +0100

    sw: move SvXMLSectionListContext out of header file
    
    Change-Id: I18417484a35d67bde3ec2690d834589c3751005f

diff --git a/sw/inc/SwXMLSectionList.hxx b/sw/inc/SwXMLSectionList.hxx
index ab254c0da2bf..f157f17fa76f 100644
--- a/sw/inc/SwXMLSectionList.hxx
+++ b/sw/inc/SwXMLSectionList.hxx
@@ -19,7 +19,6 @@
 #ifndef INCLUDED_SW_INC_SWXMLSECTIONLIST_HXX
 #define INCLUDED_SW_INC_SWXMLSECTIONLIST_HXX
 
-#include <xmloff/xmlictxt.hxx>
 #include <xmloff/xmlimp.hxx>
 
 class SwXMLSectionList : public SvXMLImport
@@ -41,21 +40,6 @@ public:
         throw() override;
 };
 
-class SvXMLSectionListContext : public SvXMLImportContext
-{
-private:
-    SwXMLSectionList & rLocalRef;
-public:
-    SvXMLSectionListContext ( SwXMLSectionList& rImport,
-                           sal_uInt16 nPrefix,
-                           const OUString& rLocalName,
-                           const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
-    virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
-                           const OUString& rLocalName,
-                           const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
-    virtual ~SvXMLSectionListContext() override;
-};
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 01a08f9abcf5..7ac9c6c9bb7d 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <SwXMLSectionList.hxx>
+#include <xmloff/xmlictxt.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include <vector>
@@ -25,6 +26,23 @@
 using namespace ::com::sun::star;
 using namespace ::xmloff::token;
 
+class SvXMLSectionListContext : public SvXMLImportContext
+{
+private:
+    SwXMLSectionList & m_rImport;
+
+public:
+    SvXMLSectionListContext(SwXMLSectionList& rImport,
+           sal_uInt16 nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> & xAttrList);
+    virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix,
+           const OUString& rLocalName,
+           const uno::Reference<xml::sax::XAttributeList> & xAttrList) override;
+    virtual ~SvXMLSectionListContext() override;
+};
+
+
 SwXMLSectionList::SwXMLSectionList(
     const uno::Reference< uno::XComponentContext >& rContext,
     std::vector<OUString*> &rNewSectionList)
@@ -80,7 +98,7 @@ SvXMLSectionListContext::SvXMLSectionListContext(
    const OUString& rLocalName,
    const uno::Reference<   xml::sax::XAttributeList > & ) :
    SvXMLImportContext ( rImport, nPrefix, rLocalName ),
-   rLocalRef(rImport)
+   m_rImport(rImport)
 {
 }
 
@@ -101,15 +119,15 @@ SvXMLImportContextRef SvXMLSectionListContext::CreateChildContext(
         {
             const OUString& rAttrName = xAttrList->getNameByIndex( i );
             OUString aLocalName;
-            sal_uInt16 nPrefx = rLocalRef.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
+            sal_uInt16 nPrefx = m_rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
             if (XML_NAMESPACE_TEXT == nPrefx && IsXMLToken ( aLocalName, XML_NAME ) )
                 sName = xAttrList->getValueByIndex( i );
         }
         if ( !sName.isEmpty() )
-            rLocalRef.rSectionList.push_back( new OUString(sName) );
+            m_rImport.rSectionList.push_back( new OUString(sName) );
     }
 
-    pContext = new SvXMLSectionListContext (rLocalRef, nPrefix, rLocalName, xAttrList);
+    pContext = new SvXMLSectionListContext(m_rImport, nPrefix, rLocalName, xAttrList);
     return pContext;
 }
 SvXMLSectionListContext::~SvXMLSectionListContext()


More information about the Libreoffice-commits mailing list