Kaydet (Commit) 8760b2b0 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 8d670c94
...@@ -149,6 +149,19 @@ DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc") ...@@ -149,6 +149,19 @@ DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc")
assertXPath(pDoc, "//span/table", 1); 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 #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -152,6 +152,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL ) ...@@ -152,6 +152,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
, bPreserveForm( false ) , bPreserveForm( false )
, bCfgNetscape4( false ) , bCfgNetscape4( false )
, mbSkipImages(false) , mbSkipImages(false)
, mbSkipHeaderFooter(false)
{ {
SetBaseURL(rBaseURL); SetBaseURL(rBaseURL);
} }
...@@ -177,6 +178,10 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium) ...@@ -177,6 +178,10 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
{ {
mbSkipImages = true; mbSkipImages = true;
} }
else if (sFilterOptions == "SkipHeaderFooter")
{
mbSkipHeaderFooter = true;
}
} }
sal_uLong SwHTMLWriter::WriteStream() sal_uLong SwHTMLWriter::WriteStream()
...@@ -418,9 +423,12 @@ sal_uLong SwHTMLWriter::WriteStream() ...@@ -418,9 +423,12 @@ sal_uLong SwHTMLWriter::WriteStream()
if( bLFPossible ) if( bLFPossible )
OutNewLine(); OutNewLine();
HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_body, false ); if (!mbSkipHeaderFooter)
OutNewLine(); {
HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html, false ); 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 // loesche die Tabelle mit den freifliegenden Rahmen
sal_uInt16 i; sal_uInt16 i;
...@@ -930,6 +938,8 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs() ...@@ -930,6 +938,8 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
{ {
OStringBuffer sOut; OStringBuffer sOut;
if (!mbSkipHeaderFooter)
{
sOut.append(OString(OOO_STRING_SVTOOLS_HTML_doctype) + " " + OString(OOO_STRING_SVTOOLS_HTML_doctype40)); sOut.append(OString(OOO_STRING_SVTOOLS_HTML_doctype) + " " + OString(OOO_STRING_SVTOOLS_HTML_doctype40));
HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() ); HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() );
...@@ -963,6 +973,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) ...@@ -963,6 +973,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
rHeaderAttrs = OutHeaderAttrs(); rHeaderAttrs = OutHeaderAttrs();
OutFootEndNoteInfo(); OutFootEndNoteInfo();
}
const SwPageDesc *pPageDesc = 0; const SwPageDesc *pPageDesc = 0;
...@@ -992,6 +1003,8 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) ...@@ -992,6 +1003,8 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
if( !pPageDesc ) if( !pPageDesc )
pPageDesc = &pDoc->GetPageDesc( 0 ); pPageDesc = &pDoc->GetPageDesc( 0 );
if (!mbSkipHeaderFooter)
{
// und nun ... das Style-Sheet!!! // und nun ... das Style-Sheet!!!
if( bCfgOutStyles ) if( bCfgOutStyles )
{ {
...@@ -1043,6 +1056,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) ...@@ -1043,6 +1056,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
OutBasicBodyEvents(); OutBasicBodyEvents();
Strm().WriteChar( '>' ); Strm().WriteChar( '>' );
}
return pPageDesc; return pPageDesc;
} }
......
...@@ -399,6 +399,8 @@ public: ...@@ -399,6 +399,8 @@ public:
bool bCfgNetscape4 : 1; // Netscape4 Hacks bool bCfgNetscape4 : 1; // Netscape4 Hacks
bool mbSkipImages : 1; bool mbSkipImages : 1;
/// If HTML header and footer should be written as well, or just the content itself.
bool mbSkipHeaderFooter : 1;
// 23 // 23
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment