sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx |binary sw/qa/extras/htmlexport/htmlexport.cxx | 13 ++++++ sw/source/filter/html/htmlplug.cxx | 9 +++- sw/source/filter/html/wrthtml.cxx | 20 ++++++++-- sw/source/filter/html/wrthtml.hxx | 2 + 5 files changed, 39 insertions(+), 5 deletions(-)
New commits: commit 8760b2b05c23e5fdf8ad7ad3f447a7489c2ddeac Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Aug 27 16:02:10 2014 +0200 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 diff --git a/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx b/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx new file mode 100644 index 0000000..f48935a Binary files /dev/null and b/sw/qa/extras/htmlexport/data/skipimage-embedded-document.docx differ diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index fd800ab..9cfde5d 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 1a34ff6..0ab79bd 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 9953307..a62cae3 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 commit 8d670c9452e930460be600212d73e22acd61cc0f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Aug 27 15:41:29 2014 +0200 sw HTML export: handle embedded text documents Change-Id: Ib7e55e3c82b1a1115335b68c317f5fcb084f6d28 diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 8fdc499..e4cf7d9 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1273,8 +1273,13 @@ Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt, // Figure out what is the filter name of the embedded object. uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY); OUString aFilter; - if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) - aFilter = "HTML (StarCalc)"; + if (xServiceInfo.is()) + { + if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) + aFilter = "HTML (StarCalc)"; + else if (xServiceInfo->supportsService("com.sun.star.text.TextDocument")) + aFilter = "HTML (StarWriter)"; + } if (xStorable.is() && !aFilter.isEmpty()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits