summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_indexingexport.mk64
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/extras/htmlexport/IndexingExport.cxx44
-rw-r--r--sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odtbin0 -> 11111 bytes
-rw-r--r--sw/source/filter/html/wrthtml.cxx31
-rw-r--r--sw/source/filter/html/wrthtml.hxx5
6 files changed, 142 insertions, 3 deletions
diff --git a/sw/CppunitTest_sw_indexingexport.mk b/sw/CppunitTest_sw_indexingexport.mk
new file mode 100644
index 000000000000..814e8d849dec
--- /dev/null
+++ b/sw/CppunitTest_sw_indexingexport.mk
@@ -0,0 +1,64 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(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 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_indexingexport, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ i18nlangtag \
+ msfilter \
+ sal \
+ sfx \
+ sot \
+ sw \
+ swqahelper \
+ svl \
+ svt \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_indexingexport,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_indexingexport,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_indexingexport,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_indexingexport))
+$(eval $(call gb_CppunitTest_use_vcl,sw_indexingexport))
+$(eval $(call gb_CppunitTest_use_rdb,sw_indexingexport,services))
+$(eval $(call gb_CppunitTest_use_configuration,sw_indexingexport))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index a9356124762a..d0ebbea8df45 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -70,6 +70,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_htmlexport \
CppunitTest_sw_xhtmlexport \
CppunitTest_sw_htmlimport \
+ CppunitTest_sw_indexingexport \
CppunitTest_sw_macros_test \
CppunitTest_sw_ooxmlexport \
CppunitTest_sw_ooxmlexport2 \
diff --git a/sw/qa/extras/htmlexport/IndexingExport.cxx b/sw/qa/extras/htmlexport/IndexingExport.cxx
new file mode 100644
index 000000000000..f10c6ec08470
--- /dev/null
+++ b/sw/qa/extras/htmlexport/IndexingExport.cxx
@@ -0,0 +1,44 @@
+/* -*- 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/htmlexport/data/IndexingExport_VariousParagraphs.odt b/sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt
new file mode 100644
index 000000000000..eb8904720f29
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/IndexingExport_VariousParagraphs.odt
Binary files differ
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 63857cf65c73..dfd03a5360f2 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -79,6 +79,7 @@
#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>
@@ -150,6 +151,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
, mbSkipImages(false)
, mbSkipHeaderFooter(false)
, mbEmbedImages(false)
+ , mbIndexingOutput(false)
, m_bCfgPrintLayout( false )
, m_bParaDotLeaders( false )
{
@@ -222,6 +224,13 @@ 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=");
@@ -265,6 +274,8 @@ ErrCode SwHTMLWriter::WriteStream()
}
comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
+ HtmlWriter aHtmlWriter(Strm(), GetNamespace());
+
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
// font heights 1-7
@@ -449,7 +460,7 @@ ErrCode SwHTMLWriter::WriteStream()
CollectLinkTargets();
sal_uInt16 nHeaderAttrs = 0;
- m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
+ m_pCurrPageDesc = MakeHeader(aHtmlWriter, nHeaderAttrs);
m_bLFPossible = true;
@@ -501,8 +512,14 @@ 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?" );
@@ -983,7 +1000,7 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
return nAttrs;
}
-const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
+const SwPageDesc* SwHTMLWriter::MakeHeader(HtmlWriter & rHtmlWriter, sal_uInt16 &rHeaderAttrs )
{
OStringBuffer sOut;
if (!mbSkipHeaderFooter)
@@ -999,6 +1016,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
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>
@@ -1025,6 +1043,14 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
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;
@@ -1068,6 +1094,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
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 8d6d1751e5a3..cc84b39f1e65 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -33,6 +33,7 @@
#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 +265,7 @@ class SW_DLLPUBLIC SwHTMLWriter : public Writer
FieldUnit m_eCSS1Unit;
sal_uInt16 OutHeaderAttrs();
- const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
+ const SwPageDesc* MakeHeader(HtmlWriter & rXmlWriter, sal_uInt16& rHeaderAtrs);
void GetControls();
void AddLinkTarget( const OUString& rURL );
@@ -397,6 +398,8 @@ 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