summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-06-10 16:34:41 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-08-30 09:18:59 +0200
commit81d10bf3ef0046941d5e6f7717f582e5286e0ab2 (patch)
tree94e36329dcc1ed86d8f1b1ad9a77719e64a4d0af /sw
parent4a04be1c48be3d253ccbed374a622f87f6bd9629 (diff)
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@gmail.com> (cherry picked from commit 1da7d73eeaaff43e4f3e8a61ad77fcec3c7aaed8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121097 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_indexingexport.mk2
-rw-r--r--sw/qa/extras/htmlexport/IndexingExport.cxx44
-rw-r--r--sw/qa/extras/indexing/IndexingExportTest.cxx55
-rw-r--r--sw/qa/extras/indexing/data/IndexingExport_VariousParagraphs.odt (renamed from sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt)bin11111 -> 11111 bytes
-rw-r--r--sw/source/filter/html/wrthtml.cxx27
-rw-r--r--sw/source/filter/html/wrthtml.hxx5
6 files changed, 59 insertions, 74 deletions
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
index eb8904720f29..eb8904720f29 100644
--- a/sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt
+++ b/sw/qa/extras/indexing/data/IndexingExport_VariousParagraphs.odt
Binary files differ
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 1bffc2030e44..4e4dfe722670 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 )
{
@@ -220,13 +218,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);
const OUString aXhtmlNsKey("xhtmlns=");
@@ -268,8 +259,6 @@ ErrCode SwHTMLWriter::WriteStream()
}
comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
- HtmlWriter aHtmlWriter(Strm(), GetNamespace());
-
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
// font heights 1-7
@@ -454,7 +443,7 @@ ErrCode SwHTMLWriter::WriteStream()
CollectLinkTargets();
sal_uInt16 nHeaderAttrs = 0;
- m_pCurrPageDesc = MakeHeader(aHtmlWriter, nHeaderAttrs);
+ m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
m_bLFPossible = true;
@@ -510,10 +499,6 @@ ErrCode SwHTMLWriter::WriteStream()
// ReqIF: end xhtml.BlkStruct.class.
HTMLOutFuncs::Out_AsciiTag(Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false);
}
- else if (mbIndexingOutput)
- {
- aHtmlWriter.end();
- }
// delete the table with floating frames
OSL_ENSURE( !m_pHTMLPosFlyFrames, "Were not all frames output?" );
@@ -995,7 +980,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)
@@ -1037,14 +1022,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;
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index abe6968e8488..f82325ee50ae 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -32,7 +32,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>
@@ -264,7 +263,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 );
@@ -397,8 +396,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