summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-07 14:38:02 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-07 18:16:32 +0100
commitb9086ccff6325bdfaf0cf03715fd8be7e2628169 (patch)
treef326a6a71a82755a103ffe3f2c22c44ff75f95d2 /sw
parentc67d285a8b213816395948c2082faaf6bb6eab43 (diff)
sw XHTML import: handle alt text of OLE objects
That ended up in the body text instead previously, which is unexpected. Change-Id: Ia40d83b3243c313462dce2617404a0670a7debb2 Reviewed-on: https://gerrit.libreoffice.org/50897 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml2
-rw-r--r--sw/qa/extras/htmlimport/htmlimport.cxx3
-rw-r--r--sw/source/filter/html/swhtml.cxx20
3 files changed, 24 insertions, 1 deletions
diff --git a/sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml b/sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml
index 05abc7721d24..b552783068ae 100644
--- a/sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml
+++ b/sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml
@@ -1,6 +1,6 @@
<reqif-xhtml:div><reqif-xhtml:br/>
<reqif-xhtml:object data="reqif-ole-data.ole" type="text/rtf">
- <reqif-xhtml:object data="reqif-ole-img.png" type="image/png"/>
+ <reqif-xhtml:object data="reqif-ole-img.png" type="image/png">OLE Object</reqif-xhtml:object>
</reqif-xhtml:object>
</reqif-xhtml:div>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 23017e40a79b..079cc803b569 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -338,6 +338,9 @@ DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
= xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
// This was empty.
CPPUNIT_ASSERT_EQUAL(OUString("text/rtf"), getProperty<OUString>(xStream, "MediaType"));
+
+ // Check alternate text (it was empty).
+ CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), getProperty<OUString>(xObject, "Title").trim());
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index af3e3c65c003..d196c718921e 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -114,10 +114,13 @@
#include <swdll.hxx>
#include <sfx2/viewfrm.hxx>
+#include <svx/svdobj.hxx>
#include <strings.hrc>
#include <swerror.h>
#include <hints.hxx>
+#include <ndole.hxx>
+#include <unoframe.hxx>
#include "css1atr.hxx"
#define FONTSIZE_MASK 7
@@ -1513,6 +1516,23 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
{
if( !m_bDocInitalized )
DocumentDetected();
+
+ if (!m_aEmbeds.empty())
+ {
+ // The text token is inside an OLE object, which means
+ // alternate text.
+ SwOLENode* pOLENode = m_aEmbeds.top();
+ if (SwFlyFrameFormat* pFormat
+ = dynamic_cast<SwFlyFrameFormat*>(pOLENode->GetFlyFormat()))
+ {
+ if (SdrObject* pObject = SwXFrame::GetOrCreateSdrObject(*pFormat))
+ {
+ pObject->SetTitle(pObject->GetTitle() + aToken);
+ break;
+ }
+ }
+ }
+
m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, aToken );
// if there are temporary paragraph attributes and the