[Libreoffice-commits] core.git: sw/CppunitTest_sw_indexingexport.mk sw/qa sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 17 13:03:53 UTC 2021


 sw/CppunitTest_sw_indexingexport.mk          |    2 
 sw/qa/extras/htmlexport/IndexingExport.cxx   |   44 ---------------------
 sw/qa/extras/indexing/IndexingExportTest.cxx |   55 +++++++++++++++++++++++++++
 sw/source/filter/html/wrthtml.cxx            |   31 ---------------
 sw/source/filter/html/wrthtml.hxx            |    5 --
 5 files changed, 59 insertions(+), 78 deletions(-)

New commits:
commit 1da7d73eeaaff43e4f3e8a61ad77fcec3c7aaed8
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Jun 10 16:34:41 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Jun 17 15:03:03 2021 +0200

    indexing: remove indexing changes from html export
    
    Turns out that reusing HTML export wasn't the best way to generate
    output XML that can be used for indexing, so reverting those
    changes.
    
    The IndexingExportTest and the test file has been moved out of
    html to its own folder, so it can be reused.
    
    Change-Id: Ie2b34285775133322c16c05eee9c0e9712c86c3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117354
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sw/CppunitTest_sw_indexingexport.mk b/sw/CppunitTest_sw_indexingexport.mk
index 814e8d849dec..06b2b448f32a 100644
--- a/sw/CppunitTest_sw_indexingexport.mk
+++ b/sw/CppunitTest_sw_indexingexport.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sw_indexingexport))
 $(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_indexingexport))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sw_indexingexport, \
-    sw/qa/extras/htmlexport/IndexingExport \
+    sw/qa/extras/indexing/IndexingExportTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,sw_indexingexport, \
diff --git a/sw/qa/extras/htmlexport/IndexingExport.cxx b/sw/qa/extras/htmlexport/IndexingExport.cxx
deleted file mode 100644
index f10c6ec08470..000000000000
--- a/sw/qa/extras/htmlexport/IndexingExport.cxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <memory>
-#include <swmodeltestbase.hxx>
-
-#include <test/htmltesttools.hxx>
-
-class IndexingExportTest : public SwModelTestBase
-{
-public:
-    IndexingExportTest()
-        : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)")
-    {
-    }
-
-private:
-    virtual std::unique_ptr<Resetter> preTest(const char*) override
-    {
-        setFilterOptions("IndexingOutput");
-        return nullptr;
-    }
-};
-
-#define DECLARE_INDEXINGEXPORT_TEST(TestName, filename)                                            \
-    DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, IndexingExportTest)
-
-DECLARE_INDEXINGEXPORT_TEST(testIndexingSimpleParagraph, "IndexingExport_VariousParagraphs.odt")
-{
-    xmlDocUniquePtr pDoc = parseXml(maTempFile);
-    CPPUNIT_ASSERT(pDoc);
-
-    assertXPath(pDoc, "/indexing", 1);
-}
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/indexing/IndexingExportTest.cxx b/sw/qa/extras/indexing/IndexingExportTest.cxx
new file mode 100644
index 000000000000..eed303c3e97b
--- /dev/null
+++ b/sw/qa/extras/indexing/IndexingExportTest.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <memory>
+#include <string_view>
+#include <swmodeltestbase.hxx>
+#include <docsh.hxx>
+#include <unotxdoc.hxx>
+
+namespace
+{
+constexpr OUStringLiteral DATA_DIRECTORY = u"sw/qa/extras/indexing/data/";
+}
+
+class IndexingExportTest : public SwModelTestBase
+{
+private:
+    SwDoc* createDoc(const char* pName = nullptr);
+
+public:
+    void testIndexingExport();
+
+    CPPUNIT_TEST_SUITE(IndexingExportTest);
+    CPPUNIT_TEST(testIndexingExport);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+SwDoc* IndexingExportTest::createDoc(const char* pName)
+{
+    if (!pName)
+        loadURL("private:factory/swriter", nullptr);
+    else
+        load(DATA_DIRECTORY, pName);
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    return pTextDoc->GetDocShell()->GetDoc();
+}
+
+void IndexingExportTest::testIndexingExport()
+{
+    SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt");
+    CPPUNIT_ASSERT(pDoc);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(IndexingExportTest);
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt b/sw/qa/extras/indexing/data/IndexingExport_VariousParagraphs.odt
similarity index 100%
rename from sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt
rename to sw/qa/extras/indexing/data/IndexingExport_VariousParagraphs.odt
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index d6880d407842..ebe0918750a9 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -79,7 +79,6 @@
 #include <xmloff/odffields.hxx>
 #include <tools/urlobj.hxx>
 #include <osl/file.hxx>
-#include <tools/stream.hxx>
 #include <comphelper/scopeguard.hxx>
 #include <unotools/tempfile.hxx>
 #include <comphelper/sequenceashashmap.hxx>
@@ -151,7 +150,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
     , mbSkipImages(false)
     , mbSkipHeaderFooter(false)
     , mbEmbedImages(false)
-    , mbIndexingOutput(false)
     , m_bCfgPrintLayout( false )
     , m_bParaDotLeaders( false )
 {
@@ -232,13 +230,6 @@ void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
     {
         mbEmbedImages = true;
     }
-    else if (rFilterOptions == "IndexingOutput")
-    {
-        mbIndexingOutput = true;
-        mbSkipHeaderFooter = true;
-        mbSkipImages = true;
-        mbXHTML = true;
-    }
 
     const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(rFilterOptions);
     static const OUStringLiteral aXhtmlNsKey(u"xhtmlns=");
@@ -282,8 +273,6 @@ ErrCode SwHTMLWriter::WriteStream()
     }
     comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
 
-    HtmlWriter aHtmlWriter(Strm(), GetNamespace());
-
     SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
 
     // font heights 1-7
@@ -468,7 +457,7 @@ ErrCode SwHTMLWriter::WriteStream()
     CollectLinkTargets();
 
     sal_uInt16 nHeaderAttrs = 0;
-    m_pCurrPageDesc = MakeHeader(aHtmlWriter, nHeaderAttrs);
+    m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
 
     m_bLFPossible = true;
 
@@ -520,14 +509,8 @@ ErrCode SwHTMLWriter::WriteStream()
         HTMLOutFuncs::Out_AsciiTag( Strm(), OString(GetNamespace() + OOO_STRING_SVTOOLS_HTML_html), false );
     }
     else if (mbReqIF)
-    {
         // ReqIF: end xhtml.BlkStruct.class.
         HTMLOutFuncs::Out_AsciiTag(Strm(), OString(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false);
-    }
-    else if (mbIndexingOutput)
-    {
-        aHtmlWriter.end("indexing");
-    }
 
     // delete the table with floating frames
     OSL_ENSURE( !m_pHTMLPosFlyFrames, "Were not all frames output?" );
@@ -1008,7 +991,7 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
     return nAttrs;
 }
 
-const SwPageDesc* SwHTMLWriter::MakeHeader(HtmlWriter & rHtmlWriter, sal_uInt16 &rHeaderAttrs )
+const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
 {
     OStringBuffer sOut;
     if (!mbSkipHeaderFooter)
@@ -1024,7 +1007,6 @@ const SwPageDesc* SwHTMLWriter::MakeHeader(HtmlWriter & rHtmlWriter, sal_uInt16
         HTMLOutFuncs::Out_AsciiTag( Strm(), OString(GetNamespace() + OOO_STRING_SVTOOLS_HTML_html) );
 
         OutNewLine();
-
         HTMLOutFuncs::Out_AsciiTag( Strm(), OString(GetNamespace() + OOO_STRING_SVTOOLS_HTML_head) );
 
         IncIndentLevel();   // indent content of <HEAD>
@@ -1051,14 +1033,6 @@ const SwPageDesc* SwHTMLWriter::MakeHeader(HtmlWriter & rHtmlWriter, sal_uInt16
 
         OutFootEndNoteInfo();
     }
-    else if (mbIndexingOutput)
-    {
-        Strm().WriteCharPtr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-        Strm().WriteCharPtr(SAL_NEWLINE_STRING);
-        rHtmlWriter.start("indexing");
-        rHtmlWriter.characters("");
-        Strm().WriteCharPtr(SAL_NEWLINE_STRING);
-    }
 
     const SwPageDesc *pPageDesc = nullptr;
 
@@ -1102,7 +1076,6 @@ const SwPageDesc* SwHTMLWriter::MakeHeader(HtmlWriter & rHtmlWriter, sal_uInt16
 
         DecIndentLevel();   // indent content of <HEAD>
         OutNewLine();
-
         HTMLOutFuncs::Out_AsciiTag( Strm(), OString(GetNamespace() + OOO_STRING_SVTOOLS_HTML_head), false );
 
         // the body won't be indented, because then everything would be indented!
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 340c1a0a81dc..12f693a72872 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -33,7 +33,6 @@
 #include <o3tl/typed_flags_set.hxx>
 #include <rtl/ref.hxx>
 #include <svtools/htmlout.hxx>
-#include <svtools/HtmlWriter.hxx>
 #include <tools/fldunit.hxx>
 
 #include <shellio.hxx>
@@ -265,7 +264,7 @@ class SW_DLLPUBLIC SwHTMLWriter : public Writer
     FieldUnit m_eCSS1Unit;
 
     sal_uInt16 OutHeaderAttrs();
-    const SwPageDesc* MakeHeader(HtmlWriter & rXmlWriter, sal_uInt16& rHeaderAtrs);
+    const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
     void GetControls();
 
     void AddLinkTarget( const OUString& rURL );
@@ -398,8 +397,6 @@ public:
     OString maNamespace;
     /// If the ReqIF subset of XHTML should be written.
     bool mbReqIF = false;
-    /// Indexing output.
-    bool mbIndexingOutput : 1;
 
 #define sCSS2_P_CLASS_leaders "leaders"
     bool m_bCfgPrintLayout : 1;       // PrintLayout option for TOC dot leaders


More information about the Libreoffice-commits mailing list