summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-07-20 11:01:38 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-07-20 11:01:38 +0100
commit19ca75ec8e27a6651e36f2578bfa77de587899a5 (patch)
tree97c5ac1bce6f35b7e1469fcd975c1a724e1f7aca
parentc4e89a07964f2f9d5286d5df8a7adca82c467742 (diff)
LOK: Enable embedding images in text/html format output
Change-Id: Ibd8bed796678ee26de2ceb6e434dce24da4eab05
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx28
-rw-r--r--sw/source/filter/html/wrthtml.hxx6
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx6
4 files changed, 25 insertions, 17 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 43ec7036c3a9..2d78696ca533 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2676,7 +2676,7 @@ void DesktopLOKTest::testComplexSelection()
pText = pDocument->pClass->getTextSelection(pDocument, "text/html", nullptr);
CPPUNIT_ASSERT(pText != nullptr);
CPPUNIT_ASSERT(std::string(pText).find(aText.getStr()) != std::string::npos); // Must have the text.
- // CPPUNIT_ASSERT(std::string(pText).find("<img") != std::string::npos); // Must have the image as well.
+ CPPUNIT_ASSERT(std::string(pText).find("<img") != std::string::npos); // Must have the image as well.
free(pText);
// We expect this to be complex.
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 54afa80ba7c9..4351a329c895 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -91,7 +91,7 @@ using namespace css;
static sal_Char sIndentTabs[MAX_INDENT_LEVEL+2] =
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
-SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
+SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions )
: m_pNumRuleInfo(new SwHTMLNumRuleInfo)
, m_nHTMLMode(0)
, m_eCSS1Unit(FieldUnit::NONE)
@@ -163,6 +163,8 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
mpTempBaseURL->EnableKillingFile();
SetBaseURL(mpTempBaseURL->GetURL());
}
+
+ SetupFilterOptions(rFilterOptions);
}
SwHTMLWriter::~SwHTMLWriter()
@@ -185,16 +187,21 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
return;
- OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
- if (sFilterOptions == "SkipImages")
+ const OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ SetupFilterOptions(sFilterOptions);
+}
+
+void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
+{
+ if (rFilterOptions == "SkipImages")
{
mbSkipImages = true;
}
- else if (sFilterOptions == "SkipHeaderFooter")
+ else if (rFilterOptions == "SkipHeaderFooter")
{
mbSkipHeaderFooter = true;
}
- else if (sFilterOptions == "EmbedImages" )
+ else if (rFilterOptions == "EmbedImages")
{
mbEmbedImages = true;
}
@@ -823,13 +830,6 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
OutHTML_Section( *this, *rNd.GetSectionNode() );
m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
}
- else if( rNd.IsGrfNode() )
- {
- SwGrfNode* pGrfNd = rNd.GetGrfNode();
- assert(pGrfNd && !"FIXME: Implement Graphic copy as HTML.");
- // if (pGrfNd)
- // OutHTML_SwGrfNode( *this, *pGrfNd );
- }
else if( &rNd == &m_pDoc->GetNodes().GetEndOfContent() )
break;
@@ -1555,9 +1555,9 @@ HTMLSaveData::~HTMLSaveData()
}
}
-void GetHTMLWriter( const OUString&, const OUString& rBaseURL, WriterRef& xRet )
+void GetHTMLWriter( const OUString& rFilterOptions, const OUString& rBaseURL, WriterRef& xRet )
{
- xRet = new SwHTMLWriter( rBaseURL );
+ xRet = new SwHTMLWriter( rBaseURL, rFilterOptions );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 47893227f98f..98c9005fe095 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -269,6 +269,8 @@ class SW_DLLPUBLIC SwHTMLWriter : public Writer
void AddLinkTarget( const OUString& rURL );
void CollectLinkTargets();
+ void SetupFilterOptions(const OUString& rFilterOptions);
+
protected:
ErrCode WriteStream() override;
void SetupFilterOptions(SfxMedium& rMedium) override;
@@ -403,7 +405,9 @@ public:
/// Tracks which text portion attributes are currently open: a which id -> open count map.
std::map<sal_uInt16, int> maStartedAttributes;
- explicit SwHTMLWriter( const OUString& rBaseURL );
+ /// Construct an instance of SwHTMLWriter and optionally give it
+ /// the filter options directly, which can also be set via SetupFilterOptions().
+ explicit SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions = "" );
virtual ~SwHTMLWriter() override;
void Out_SwDoc( SwPaM* ); // write the marked range
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 95b8d8b0e4d0..3cc08cbfe741 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -773,8 +773,12 @@ bool SwTransferable::WriteObject( tools::SvRef<SotStorageStream>& xStream,
break;
case SWTRANSFER_OBJECTTYPE_HTML:
- GetHTMLWriter(OUString(), OUString(), xWrt);
+ {
+ // LOK is interested in getting images embedded for copy/paste support.
+ const OUString aFilterOptions("EmbedImages");
+ GetHTMLWriter( comphelper::LibreOfficeKit::isActive() ? aFilterOptions : aEmptyOUStr, OUString(), xWrt );
break;
+ }
case SWTRANSFER_OBJECTTYPE_RTF:
case SWTRANSFER_OBJECTTYPE_RICHTEXT: