diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-07-01 20:30:43 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-07-08 09:27:32 +0200 |
commit | 3340ce30562832b584dd0576d9e0733aa03d867f (patch) | |
tree | da2b1d859fefca6bd0d93480d11855ff2de0486d | |
parent | 7b4f4f15971047664fa278fff96b959d53b272b3 (diff) |
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@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/inc/unoframe.hxx | 2 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx | bin | 0 -> 28843 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap1.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/OLEHandler.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/OLEHandler.hxx | 2 |
10 files changed, 42 insertions, 4 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 0c5726536511..91078196f67b 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -585,6 +585,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 4bf9e3aa0647..44e27f6434b6 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 24cc71cb8740..c78f08bf5577 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -813,6 +813,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 Binary files differnew file mode 100644 index 000000000000..2e5429ce71b9 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf108545_embeddedDocxIcon.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 817c065f4e95..0ff3f1cdc71a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1382,6 +1382,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 f463bf3f95fd..f43b6bace8e3 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1197,6 +1197,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); @@ -1984,6 +1985,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(); @@ -2913,8 +2924,8 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::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 ); @@ -2951,8 +2962,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } SwFlyFrameFormat* pFormat2 = nullptr; - // TODO/LATER: Is it the only possible aspect here? - ::svt::EmbeddedObjectRef xObjRef( xIPObj, embed::Aspects::MSOLE_CONTENT ); + ::svt::EmbeddedObjectRef xObjRef( xIPObj, m_nDrawAspect); pFormat2 = pDoc->getIDocumentContentOperations().InsertEmbObject( 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 3d277d3b97c2..9ed3faa7d1bc 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -864,6 +864,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 }, // 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 bc15fc347fcf..e7cd1f8c51f7 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1447,6 +1447,10 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const OLEHandler else xOLEProperties->setPropertyValue("CLSID", uno::makeAny(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 1f01c77e3fd4..68067648c1ef 100644 --- a/writerfilter/source/dmapper/OLEHandler.cxx +++ b/writerfilter/source/dmapper/OLEHandler.cxx @@ -239,6 +239,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 84818dfb17df..6053851fb9b5 100644 --- a/writerfilter/source/dmapper/OLEHandler.hxx +++ b/writerfilter/source/dmapper/OLEHandler.hxx @@ -90,6 +90,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; } |