[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Mar 7 17:16:56 UTC 2018
sw/qa/extras/htmlimport/data/reqif-ole-img.xhtml | 2 +-
sw/qa/extras/htmlimport/htmlimport.cxx | 3 +++
sw/source/filter/html/swhtml.cxx | 20 ++++++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
New commits:
commit b9086ccff6325bdfaf0cf03715fd8be7e2628169
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Mar 7 14:38:02 2018 +0100
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 at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
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
More information about the Libreoffice-commits
mailing list