sw/inc/shellio.hxx                              |    4 ++--
 sw/qa/extras/htmlimport/data/outline-level.html |    5 +++++
 sw/qa/extras/htmlimport/htmlimport.cxx          |    8 ++++++++
 sw/source/filter/basflt/shellio.cxx             |   10 +++++-----
 sw/source/filter/html/swhtml.cxx                |    6 +++++-
 sw/source/filter/html/wrthtml.cxx               |    2 +-
 sw/source/filter/inc/fltini.hxx                 |    2 +-
 7 files changed, 27 insertions(+), 10 deletions(-)

New commits:
commit 303f8e5160ddb39914ba7f669698d5dbe958878a
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed Feb 7 17:54:49 2018 +0100

    sw HTML import: avoid loading the Writer/Web template for the Writer filter
    
    The share/template/common/internal/html.stw template we have is for
    Writer/Web, loading that into Writer is questionable at best. Also it
    means that the outline numbering of the heading styles is not set, which
    is a problem, as the sw HTML import only sets the style, not the
    outline numbering.
    
    Change-Id: I86d11d8a5744c3c2ca71b03fd41a24d3f88ea333
    Reviewed-on: https://gerrit.libreoffice.org/49381
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>

diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index ac1cd9e50d48..5cbd0f502639 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -211,7 +211,7 @@ protected:
     bool bIgnoreHTMLComments : 1;
     bool bSkipImages : 1;
 
-    virtual OUString GetTemplateName() const;
+    virtual OUString GetTemplateName(SwDoc& rDoc) const;
 
 public:
     Reader();
@@ -230,7 +230,7 @@ public:
     static void ResetFrameFormats( SwDoc& rDoc );
 
     // Load filter template, set it and release it again.
-    SwDoc* GetTemplateDoc();
+    SwDoc* GetTemplateDoc(SwDoc& rDoc);
     bool SetTemplate( SwDoc& rDoc );
     void ClearTemplate();
     void SetTemplateName( const OUString& rDir );
diff --git a/sw/qa/extras/htmlimport/data/outline-level.html 
b/sw/qa/extras/htmlimport/data/outline-level.html
new file mode 100644
index 000000000000..cd36fc3c1b60
--- /dev/null
+++ b/sw/qa/extras/htmlimport/data/outline-level.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<h1>heading</h1>
+</body>
+</html>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx 
b/sw/qa/extras/htmlimport/htmlimport.cxx
index 9b20423ea945..bfe1f436e03c 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -271,6 +271,14 @@ DECLARE_HTMLIMPORT_TEST(testTableBorder1px, 
"table_border_1px.html")
     CPPUNIT_ASSERT_MESSAGE("Missing cell right border", aBorder.InnerLineWidth 
> 0);
 }
 
+DECLARE_HTMLIMPORT_TEST(testOutlineLevel, "outline-level.html")
+{
+    // This was 0, HTML imported into Writer lost the outline numbering for
+    // Heading 1 styles.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1),
+                         getProperty<sal_Int32>(getParagraph(1), 
"OutlineLevel"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/basflt/shellio.cxx 
b/sw/source/filter/basflt/shellio.cxx
index 037c12b4a993..3e98da244e51 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -442,17 +442,17 @@ Reader::~Reader()
 {
 }
 
-OUString Reader::GetTemplateName() const
+OUString Reader::GetTemplateName(SwDoc& /*rDoc*/) const
 {
     return OUString();
 }
 
 // load the Filter template, set and release
-SwDoc* Reader::GetTemplateDoc()
+SwDoc* Reader::GetTemplateDoc(SwDoc& rDoc)
 {
     if( !bHasAskTemplateName )
     {
-        SetTemplateName( GetTemplateName() );
+        SetTemplateName( GetTemplateName(rDoc) );
         bHasAskTemplateName = true;
     }
 
@@ -529,7 +529,7 @@ bool Reader::SetTemplate( SwDoc& rDoc )
 {
     bool bRet = false;
 
-    GetTemplateDoc();
+    GetTemplateDoc(rDoc);
     if( mxTemplate.is() )
     {
         rDoc.RemoveAllFormatLanguageDependencies();
@@ -901,7 +901,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const 
OUString* pRealFileNa
 bool SetHTMLTemplate( SwDoc & rDoc )
 {
     // get template name of the Sfx-HTML-Filter !!!
-    if( !ReadHTML->GetTemplateDoc() )
+    if( !ReadHTML->GetTemplateDoc(rDoc) )
         ReadHTML->MakeHTMLDummyTemplateDoc();
 
     bool bRet = ReadHTML->SetTemplate( rDoc );
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index c21a373315ed..4586686e1693 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -158,8 +158,12 @@ HTMLReader::HTMLReader()
     bTmplBrowseMode = true;
 }
 
-OUString HTMLReader::GetTemplateName() const
+OUString HTMLReader::GetTemplateName(SwDoc& rDoc) const
 {
+    if (!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE))
+        // HTML import into Writer, avoid loading the Writer/Web template.
+        return OUString();
+
     const OUString sTemplateWithoutExt("internal/html");
     SvtPathOptions aPathOpt;
 
diff --git a/sw/source/filter/html/wrthtml.cxx 
b/sw/source/filter/html/wrthtml.cxx
index 4fd3cd91be9d..dd6a2dd3f0ad 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -265,7 +265,7 @@ ErrCode SwHTMLWriter::WriteStream()
     SwCharFormats::size_type nOldCharFormatCnt = 0;
 
     OSL_ENSURE( !m_xTemplate.is(), "Where is the HTML template coming from?" );
-    m_xTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc();
+    m_xTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc(*pDoc);
     if( m_xTemplate.is() )
     {
         bOldHTMLMode = 
m_xTemplate->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE);
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 2a6b55fc0724..c20859fa5250 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -34,7 +34,7 @@ class HTMLReader: public Reader
     // we don't want to have the streams/storages open
     virtual bool SetStrmStgPtr() override;
     virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const 
OUString &) override;
-    virtual OUString GetTemplateName() const override;
+    virtual OUString GetTemplateName(SwDoc& rDoc) const override;
 public:
     HTMLReader();
 };
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to