[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/inc sw/qa sw/source writerfilter/source
Szymon Kłos
szymon.klos at collabora.com
Tue Jul 11 18:19:56 UTC 2017
sw/inc/cmdid.h | 1
sw/inc/unoframe.hxx | 2 +
sw/inc/unoprnms.hxx | 1
sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 ++++++
sw/source/core/unocore/unoframe.cxx | 19 +++++++---
sw/source/core/unocore/unomap1.cxx | 1
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 ++
writerfilter/source/dmapper/OLEHandler.cxx | 5 ++
writerfilter/source/dmapper/OLEHandler.hxx | 2 +
10 files changed, 42 insertions(+), 5 deletions(-)
New commits:
commit 91ca088171d58339715358b8a47f7adc491ba7fa
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Sat Jul 1 20:30:43 2017 +0200
tdf#108545 show an icon (DOCX inside DOCX)
If DrawAspect is equal "Icon", show an icon not document preview
Document is opened in the separate window, not in-place.
Change-Id: I3a8d81e7340b29d247f8ac440c06b0420bb65644
Reviewed-on: https://gerrit.libreoffice.org/39440
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/39716
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index cf15543a13c2..476b2decca02 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -588,6 +588,7 @@
#define FN_MATH_BASELINE_ALIGNMENT (FN_EXTRA2 + 115)
#define FN_EMBEDDED_OBJECT (FN_EXTRA2 + 116)
+#define FN_UNO_DRAW_ASPECT (FN_EXTRA2 + 117)
#define FN_UNO_HEADER_FIRST (FN_EXTRA2 + 118)
#define FN_UNO_FOOTER_FIRST (FN_EXTRA2 + 119)
#define FN_UNO_TABLE_BORDER2 (FN_EXTRA2 + 120)
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx
index c6bbd1f24ebb..ce6b1857b89b 100644
--- a/sw/inc/unoframe.hxx
+++ b/sw/inc/unoframe.hxx
@@ -71,6 +71,8 @@ private:
SwPaM* m_pCopySource;
+ sal_Int64 m_nDrawAspect;
+
protected:
css::uno::Reference< css::beans::XPropertySet > mxStyleData;
css::uno::Reference< css::container::XNameAccess > mxStyleFamily;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index c4020c53acf8..f7585451e854 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -807,6 +807,7 @@
#define UNO_NAME_EMBEDDED_OBJECT "EmbeddedObject"
#define UNO_NAME_RSID "Rsid"
#define UNO_NAME_PARRSID "ParRsid"
+#define UNO_NAME_DRAW_ASPECT "DrawAspect"
#define UNO_NAME_LINE_STYLE "LineStyle"
#define UNO_NAME_LINE_WIDTH "LineWidth"
diff --git a/sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx b/sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx
new file mode 100644
index 000000000000..2e5429ce71b9
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a46a09d32bf3..0f7c5d0101d6 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1476,6 +1476,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
paragraph->getString());
}
+#if defined(_WIN32)
+DECLARE_OOXMLIMPORT_TEST(testTdf108545_embeddedDocxIcon, "tdf108545_embeddedDocxIcon.docx")
+{
+ // Check if document shows an icon for embedded docx document
+ // Due to different fonts used for icon labels on each OS, current checksum is for Windows only
+ uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(getShape(1), uno::UNO_QUERY);
+ uno::Reference<graphic::XGraphic> xGraphic = xSupplier->getReplacementGraphic();
+ Graphic aGraphic(xGraphic);
+ CPPUNIT_ASSERT_EQUAL(BitmapChecksum(SAL_CONST_UINT64(733876873106730813)), aGraphic.GetChecksum());
+}
+#endif
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 43ff3cec26bd..76d59e1a1d05 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1201,6 +1201,7 @@ SwXFrame::SwXFrame(FlyCntType eSet, const ::SfxItemPropertySet* pSet, SwDoc *pDo
, eType(eSet)
, bIsDescriptor(true)
, m_pCopySource(nullptr)
+ , m_nDrawAspect(embed::Aspects::MSOLE_CONTENT)
{
// Register ourselves as a listener to the document (via the page descriptor)
pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
@@ -1994,6 +1995,16 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
{
}
}
+ else if (FN_UNO_DRAW_ASPECT == pEntry->nWID)
+ {
+ OUString sAspect = "";
+ aValue >>= sAspect;
+
+ if (sAspect == "Icon")
+ m_nDrawAspect = embed::Aspects::MSOLE_ICON;
+ else if (sAspect == "Content")
+ m_nDrawAspect = embed::Aspects::MSOLE_CONTENT;
+ }
}
else
throw uno::RuntimeException();
@@ -2938,8 +2949,8 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, nullptr);
if(!bSizeFound)
{
- //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode?
- sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
+ //TODO/LATER: how do I transport it to the OLENode?
+ sal_Int64 nAspect = m_nDrawAspect;
// TODO/LEAN: VisualArea still needs running state
svt::EmbeddedObjectRef::TryRunningState( xIPObj );
@@ -2976,9 +2987,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
}
SwFlyFrameFormat* pFormat2 = nullptr;
- // TODO/LATER: Is it the only possible aspect here?
- sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
- ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect );
+ ::svt::EmbeddedObjectRef xObjRef( xIPObj, m_nDrawAspect );
pFormat2 = pDoc->getIDocumentContentOperations().Insert(aPam, xObjRef, &aFrameSet );
assert(pFormat2 && "Doc->Insert(notxt) failed.");
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index c93effc95184..a89aadebf843 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -865,6 +865,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetEmbeddedPropertyMap
{ OUString(UNO_NAME_GRAPHIC), FN_UNO_REPLACEMENT_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), PropertyAttribute::MAYBEVOID, 0 },
{ OUString(UNO_NAME_COMPONENT),FN_UNO_COMPONENT, cppu::UnoType<css::lang::XComponent>::get(), PropertyAttribute::READONLY, 0},
{ OUString(UNO_NAME_EMBEDDED_OBJECT),FN_EMBEDDED_OBJECT, cppu::UnoType<css::embed::XEmbeddedObject>::get(), PROPERTY_NONE, 0},
+ { OUString(UNO_NAME_DRAW_ASPECT),FN_UNO_DRAW_ASPECT, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
//UUUU added FillProperties for SW, same as FILL_PROPERTIES in svx
// but need own defines in Writer due to later association of strings
// and uno types (see loop at end of this method and definition of SW_PROP_NMID)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4cb55513eacb..1e646350cfcd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1418,6 +1418,10 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const OLEHandler
else
xOLEProperties->setPropertyValue("CLSID", uno::makeAny(OUString(aCLSID)));
+ OUString aDrawAspect = pOLEHandler->GetDrawAspect();
+ if(!aDrawAspect.isEmpty())
+ xOLEProperties->setPropertyValue("DrawAspect", uno::makeAny(aDrawAspect));
+
awt::Size aSize = pOLEHandler->getSize();
if( !aSize.Width )
aSize.Width = 1000;
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index 317fe5c80239..6dbe0aae2f87 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -251,6 +251,11 @@ OUString OLEHandler::getCLSID(const uno::Reference<uno::XComponentContext>& xCom
return aRet;
}
+OUString OLEHandler::GetDrawAspect() const
+{
+ return m_sDrawAspect;
+}
+
OUString OLEHandler::copyOLEOStream(
uno::Reference<text::XTextDocument> const& xTextDocument)
{
diff --git a/writerfilter/source/dmapper/OLEHandler.hxx b/writerfilter/source/dmapper/OLEHandler.hxx
index 2f99de501e5f..b71f51adcc88 100644
--- a/writerfilter/source/dmapper/OLEHandler.hxx
+++ b/writerfilter/source/dmapper/OLEHandler.hxx
@@ -92,6 +92,8 @@ public:
/// Get the CLSID of the OLE object, in case we can find one based on m_sProgId.
OUString getCLSID(const css::uno::Reference<css::uno::XComponentContext>& xComponentContext) const;
+ OUString GetDrawAspect() const;
+
OUString copyOLEOStream(css::uno::Reference<css::text::XTextDocument> const& xTextDocument);
const css::awt::Size& getSize() const { return m_aShapeSize; }
More information about the Libreoffice-commits
mailing list