diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-27 16:02:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-27 16:21:22 +0200 |
commit | 8760b2b05c23e5fdf8ad7ad3f447a7489c2ddeac (patch) | |
tree | 678a305c276e928b33e87cbfb3f5678280b6dda0 /sw | |
parent | 8d670c9452e930460be600212d73e22acd61cc0f (diff) |
sw HTML export: avoid invalid output for embedded documents
When an sw document is embedded inside an sw one, then the inner sw HTML export
should just write what's inside the <body>. Add a filter option for that in sw,
similar to the one already existing in sc.
Change-Id: Id2cef966c1022ba45a3540bff234029c1d396778
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx | bin | 0 -> 21379 bytes | |||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 2 |
4 files changed, 32 insertions, 3 deletions
diff --git a/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx b/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx Binary files differnew file mode 100644 index 000000000000..f48935ad4490 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index fd800ab2096f..9cfde5d082d7 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -149,6 +149,19 @@ DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc") assertXPath(pDoc, "//span/table", 1); } +DECLARE_HTMLEXPORT_TEST(testSkipImageEmbeddedDocument, "skipimage-embedded-document.docx") +{ + // Similar to testSkipImageEmbedded, but with an embedded Writer object, + // not a Calc one, and this time OOXML, not WW8. + htmlDocPtr pDoc = parseHtml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + // This was 2, the HTML header was in the document two times. + assertXPath(pDoc, "//meta[@name='generator']", 1); + // Text of embedded document was missing. + assertXPathContent(pDoc, "/html/body/p/span/p/span", "Inner."); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 1a34ff663a1f..0ab79bd2c3b3 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -152,6 +152,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL ) , bPreserveForm( false ) , bCfgNetscape4( false ) , mbSkipImages(false) + , mbSkipHeaderFooter(false) { SetBaseURL(rBaseURL); } @@ -177,6 +178,10 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium) { mbSkipImages = true; } + else if (sFilterOptions == "SkipHeaderFooter") + { + mbSkipHeaderFooter = true; + } } sal_uLong SwHTMLWriter::WriteStream() @@ -418,9 +423,12 @@ sal_uLong SwHTMLWriter::WriteStream() if( bLFPossible ) OutNewLine(); - HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_body, false ); - OutNewLine(); - HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html, false ); + if (!mbSkipHeaderFooter) + { + HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_body, false ); + OutNewLine(); + HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html, false ); + } // loesche die Tabelle mit den freifliegenden Rahmen sal_uInt16 i; @@ -930,6 +938,8 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs() const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) { OStringBuffer sOut; + if (!mbSkipHeaderFooter) + { sOut.append(OString(OOO_STRING_SVTOOLS_HTML_doctype) + " " + OString(OOO_STRING_SVTOOLS_HTML_doctype40)); HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() ); @@ -963,6 +973,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) rHeaderAttrs = OutHeaderAttrs(); OutFootEndNoteInfo(); + } const SwPageDesc *pPageDesc = 0; @@ -992,6 +1003,8 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) if( !pPageDesc ) pPageDesc = &pDoc->GetPageDesc( 0 ); + if (!mbSkipHeaderFooter) + { // und nun ... das Style-Sheet!!! if( bCfgOutStyles ) { @@ -1043,6 +1056,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) OutBasicBodyEvents(); Strm().WriteChar( '>' ); + } return pPageDesc; } diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 9953307c8296..a62cae36a41b 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -399,6 +399,8 @@ public: bool bCfgNetscape4 : 1; // Netscape4 Hacks bool mbSkipImages : 1; + /// If HTML header and footer should be written as well, or just the content itself. + bool mbSkipHeaderFooter : 1; // 23 |