[Libreoffice-commits] core.git: sc/source sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Aug 25 08:46:44 PDT 2014
sc/source/filter/html/htmlexp.cxx | 19 ++++++++++++++++---
sc/source/filter/inc/htmlexp.hxx | 2 ++
sw/qa/extras/htmlexport/htmlexport.cxx | 2 ++
sw/source/filter/html/htmlplug.cxx | 1 +
4 files changed, 21 insertions(+), 3 deletions(-)
New commits:
commit 1ee98159f7749b2c1ad47de60a9b3057b9e9720e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Aug 25 16:12:33 2014 +0200
HTML export: avoid invalid output for embedded spreadsheets
When the sc document is embedded inside an sw one, then the sc HTML
export should just write what's inside the <body>. Add a filter option
for that in sc and use it from sw.
Change-Id: I3a9605bd62f0628b78cd782c11661f12bc2c3ae4
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 7104f60..f9facfc 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -210,7 +210,8 @@ ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const OUString& rBaseURL, ScDocume
bCalcAsShown( pDocP->GetDocOptions().IsCalcAsShown() ),
bTableDataWidth( true ),
bTableDataHeight( true ),
- mbSkipImages ( false )
+ mbSkipImages ( false ),
+ mbSkipHeaderFooter( false )
{
strcpy( sIndent, sIndentSource );
sIndent[0] = 0;
@@ -224,6 +225,10 @@ ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const OUString& rBaseURL, ScDocume
{
mbSkipImages = true;
}
+ else if (rFilterOptions == "SkipHeaderFooter")
+ {
+ mbSkipHeaderFooter = true;
+ }
for ( sal_uInt16 j=0; j < SC_HTML_FONTSIZES; j++ )
{
@@ -306,14 +311,18 @@ Size ScHTMLExport::MMToPixel( const Size& rSize )
sal_uLong ScHTMLExport::Write()
{
+ if (!mbSkipHeaderFooter)
+ {
rStrm.WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype ).WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype40 ).WriteChar( '>' )
.WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( SAL_NEWLINE_STRING );
TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
WriteHeader();
OUT_LF();
+ }
WriteBody();
OUT_LF();
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
+ if (!mbSkipHeaderFooter)
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
return rStrm.GetError();
}
@@ -544,6 +553,8 @@ void ScHTMLExport::WriteBody()
const SvxBrushItem* pBrushItem = (const SvxBrushItem*)&rSet.Get( ATTR_BACKGROUND );
// default text color black
+ if (!mbSkipHeaderFooter)
+ {
rStrm.WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body );
if (!mbSkipImages)
@@ -608,13 +619,15 @@ void ScHTMLExport::WriteBody()
}
rStrm.WriteChar( '>' ); OUT_LF();
+ }
if ( bAll )
WriteOverview();
WriteTables();
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
+ if (!mbSkipHeaderFooter)
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
}
void ScHTMLExport::WriteTables()
diff --git a/sc/source/filter/inc/htmlexp.hxx b/sc/source/filter/inc/htmlexp.hxx
index 8f70b0d..6120906 100644
--- a/sc/source/filter/inc/htmlexp.hxx
+++ b/sc/source/filter/inc/htmlexp.hxx
@@ -125,6 +125,8 @@ class ScHTMLExport : public ScExportBase
bool bTableDataWidth;
bool bTableDataHeight;
bool mbSkipImages;
+ /// If HTML header and footer should be written as well, or just the content itself.
+ bool mbSkipHeaderFooter;
const SfxItemSet& PageDefaults( SCTAB nTab );
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 6903522..82d6cd4 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -143,6 +143,8 @@ DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc")
// This was 0.
assertXPath(pDoc, "//table", 1);
+ // This was 2, the HTML header was in the document two times.
+ assertXPath(pDoc, "//meta[@name='generator']", 1);
}
#endif
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 3155db1..3705a07 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -1281,6 +1281,7 @@ Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt,
uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= aFilter;
+ aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter");
aMediaDescriptor["OutputStream"] <<= xOutputStream;
xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList());
OString aData(reinterpret_cast<const char*>(aStream.GetData()), aStream.GetSize());
More information about the Libreoffice-commits
mailing list