chart2/source/controller/main/ChartFrameloader.cxx | 5 chart2/source/model/filter/XMLFilter.cxx | 3 comphelper/source/container/embeddedobjectcontainer.cxx | 27 + filter/source/msfilter/msdffimp.cxx | 18 - filter/source/msfilter/svdfppt.cxx | 2 include/comphelper/embeddedobjectcontainer.hxx | 6 include/filter/msfilter/msdffimp.hxx | 6 include/sfx2/objsh.hxx | 2 reportdesign/inc/ReportDefinition.hxx | 1 reportdesign/source/core/api/ReportDefinition.cxx | 5 sc/inc/autoform.hxx | 8 sc/inc/callform.hxx | 8 sc/source/core/data/funcdesc.cxx | 2 sc/source/core/tool/autoform.cxx | 48 +-- sc/source/core/tool/callform.cxx | 35 +- sc/source/filter/excel/xiescher.cxx | 2 sc/source/ui/miscdlgs/scuiautofmt.cxx | 2 sc/source/ui/unoobj/afmtuno.cxx | 4 sfx2/source/dialog/dockwin.cxx | 3 sfx2/source/doc/objstor.cxx | 6 svtools/source/misc/embedhlp.cxx | 12 svx/source/unodraw/unoshap4.cxx | 7 svx/source/xml/xmleohlp.cxx | 3 sw/qa/extras/inc/swmodeltestbase.hxx | 1 sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 24 + sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 30 +- sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 101 ++++++- sw/source/core/ole/ndole.cxx | 4 sw/source/filter/ww8/docxattributeoutput.cxx | 95 ------ sw/source/filter/ww8/docxexport.cxx | 229 +++++++++++++++- sw/source/filter/ww8/docxexport.hxx | 2 sw/source/filter/ww8/wrtww8gr.cxx | 2 sw/source/filter/ww8/ww8par.cxx | 3 sw/source/filter/ww8/ww8par4.cxx | 2 writerfilter/inc/ooxml/OOXMLDocument.hxx | 2 writerfilter/source/filter/WriterFilter.cxx | 3 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 13 writerfilter/source/ooxml/OOXMLDocumentImpl.hxx | 5 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 6 39 files changed, 541 insertions(+), 196 deletions(-)
New commits: commit 07004a7e9cd8b44f8cb4ff8f30180b06d9c325c3 Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 17:23:45 2015 +0100 chart2: add DocumentBaseURL in ChartFrameLoader::load() ... as seen in JunitTest_chart2_unoapi Change-Id: Ibe0cd210b8f2ddf730483705292e9027654b6fd4 diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx index adf74ee..fb12dfe 100644 --- a/chart2/source/controller/main/ChartFrameloader.cxx +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -165,6 +165,11 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa } else { + // use the URL as BaseURL, similar to what SfxBaseModel effectively does + if (!aURL.isEmpty()) + { + aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL()] <<= aURL; + } aMediaDescriptor.addInputStream(); uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; aMediaDescriptor >> aCompleteMediaDescriptor; commit e4a06fc983fd6a94a6138503c3fc94b567bc3a68 Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 16:39:14 2015 +0100 sw: set a BaseURL when copying embedded objects Turns out that SfxObjectShell::CreateShellID() will produce the SfxMedium's base URL if it exists, so EmbeddedObjectContainer::CopyAndGetEmbeddedObject() already has parameters, sw just needs to set them. Change-Id: I36cedfde4e7c2e25c43c66a30d8ca572f099ad69 diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index 21a2f9d..b813b96 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -696,7 +696,8 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CopyAndGetEmb // objects without persistence are not really stored by the method if (xObj.is() && StoreEmbeddedObject(xObj, rName, true, rSrcShellID, rDestShellID)) { - xResult = Get_Impl( rName, xObj); + assert(!rDestShellID.isEmpty() && !rDestShellID.startsWith("0x")); // assume that every shell has a base URL + xResult = Get_Impl(rName, xObj, &rDestShellID); if ( !xResult.is() ) { // this is a case when object has no real persistence diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 8facbee..6089e69 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -439,8 +439,8 @@ SwContentNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const pSrc->GetEmbeddedObjectContainer(), pSrc->GetEmbeddedObjectContainer().GetEmbeddedObject( aOLEObj.aName ), aNewName, - OUString(), - OUString()); + SfxObjectShell::CreateShellID(pSrc), + SfxObjectShell::CreateShellID(pPersistShell)); SwOLENode* pOLENd = pDoc->GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(), pDoc->GetDfltGrfFormatColl(), commit 8338e2783f223aec176a3f06f78abd7a60ea2e0a Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 16:18:24 2015 +0100 writerfilter: set a BaseURL on embedded math objects Change-Id: I9a500e079c892e281bdfee9627641f118261e0f8 diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx index 7bf884f..5ef9247 100644 --- a/writerfilter/inc/ooxml/OOXMLDocument.hxx +++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx @@ -254,7 +254,7 @@ public: static OOXMLDocument * createDocument(OOXMLStream::Pointer_t pStream, const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator, - bool bSkipImage); + bool bSkipImage, OUString const& rBaseURL); }; diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index 2a96884..de6199f 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -154,6 +154,7 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc utl::MediaDescriptor aMediaDesc(aDescriptor); bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault("RepairPackage", false); bool bSkipImages = aMediaDesc.getUnpackedValueOrDefault("FilterOptions", OUString("")) == "SkipImages"; + OUString const baseURI = aMediaDesc.getUnpackedValueOrDefault("DocumentBaseURL", OUString("")); uno::Reference< io::XInputStream > xInputStream; try @@ -174,7 +175,7 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc //create the tokenizer and domain mapper writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream, bRepairStorage); uno::Reference<task::XStatusIndicator> xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STATUSINDICATOR(), uno::Reference<task::XStatusIndicator>()); - writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream, xStatusIndicator, bSkipImages)); + writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream, xStatusIndicator, bSkipImages, baseURI)); uno::Reference<frame::XModel> xModel(m_xDstDoc, uno::UNO_QUERY_THROW); pDocument->setModel(xModel); diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index 5844c75..210384a 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -49,7 +49,7 @@ namespace writerfilter { namespace ooxml { -OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool bSkipImages) +OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, OUString const& rBaseURL) : mpStream(pStream) , mxStatusIndicator(xStatusIndicator) , mnXNoteId(0) @@ -61,6 +61,7 @@ OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno:: , mnProgressLastPos(0) , mnProgressCurrentPos(0) , mnProgressEndPos(0) + , m_rBaseURL(rBaseURL) { } @@ -265,7 +266,7 @@ OOXMLDocumentImpl::getSubStream(const OUString & rId) OOXMLDocumentImpl * pTemp; // Do not pass status indicator to sub-streams: they are typically marginal in size, so we just track the main document for now. - writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages )); + writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, m_rBaseURL)); pTemp->setModel(mxModel); pTemp->setDrawPage(mxDrawPage); pTemp->setIsSubstream( true ); @@ -279,7 +280,7 @@ OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rT OOXMLStream::Pointer_t pStream = (OOXMLDocumentFactory::createStream(mpStream, nType)); // See above, no status indicator for the note stream, either. - OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages); + OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, m_rBaseURL); pDocument->setXNoteId(nId); pDocument->setXNoteType(rType); pDocument->setModel(getModel()); @@ -927,9 +928,11 @@ uno::Sequence<beans::PropertyValue > OOXMLDocumentImpl::getEmbeddingsList( ) OOXMLDocument * OOXMLDocumentFactory::createDocument -(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool mbSkipImages) +(OOXMLStream::Pointer_t pStream, + const uno::Reference<task::XStatusIndicator>& xStatusIndicator, + bool mbSkipImages, OUString const& rBaseURL) { - return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages); + return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages, rBaseURL); } }} diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index c0c8d33..82a57de 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -63,6 +63,8 @@ class OOXMLDocumentImpl : public OOXMLDocument sal_Int32 mnProgressCurrentPos; /// End position, i.e. the estimated number of paragraphs. sal_Int32 mnProgressEndPos; + /// DocumentBaseURL + OUString const m_rBaseURL; protected: void resolveFastSubStream(Stream & rStream, @@ -90,7 +92,7 @@ protected: void resolveGlossaryStream(Stream & rStream); void resolveEmbeddingsStream(OOXMLStream::Pointer_t pStream); public: - OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator, bool bSkipImages); + OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, OUString const& rBaseURL); virtual ~OOXMLDocumentImpl(); virtual void resolve(Stream & rStream) override; @@ -138,6 +140,7 @@ public: void incrementProgress(); bool IsSkipImages() { return mbSkipImages; }; + OUString const& GetDocumentBaseURL() { return m_rBaseURL; }; }; }} #endif // OOXML_DOCUMENT_IMPL_HXX diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 3f5e404..1f09843 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -2009,7 +2009,11 @@ void OOXMLFastContextHandlerMath::process() SvGlobalName name( SO3_SM_CLASSID ); comphelper::EmbeddedObjectContainer container; OUString aName; - uno::Reference< embed::XEmbeddedObject > ref = container.CreateEmbeddedObject( name.GetByteSequence(), aName ); + uno::Sequence<beans::PropertyValue> objArgs(1); + objArgs[0].Name = "DefaultParentBaseURL"; + objArgs[0].Value <<= getDocument()->GetDocumentBaseURL(); + uno::Reference<embed::XEmbeddedObject> ref = + container.CreateEmbeddedObject(name.GetByteSequence(), objArgs, aName); assert(ref.is()); if (!ref.is()) return; commit 75a200f371d12ddaf5b82af10c8d4675babcdb5e Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 15:06:20 2015 +0100 svx: set BaseURL from SvxOle2Shape::createObject() This is used from oox chart import code, cf. oox::drawingml::Shape::finalizeXShape(). Change-Id: I7b2097f8d5740a590a6473797ab9436453fbf580 diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 58c668a..03c85d4 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -410,8 +410,13 @@ bool SvxOle2Shape::createObject( const SvGlobalName &aClassName ) if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME ) >>= aTmpStr ) aPersistName = aTmpStr; + uno::Sequence<beans::PropertyValue> objArgs(1); + objArgs[0].Name = "DefaultParentBaseURL"; + objArgs[0].Value <<= pPersist->getDocumentBaseURL(); //TODO/LATER: how to cope with creation failure?! - uno::Reference < embed::XEmbeddedObject > xObj( pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ) ); + uno::Reference<embed::XEmbeddedObject> xObj( + pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( + aClassName.GetByteSequence(), objArgs, aPersistName)); if( xObj.is() ) { Rectangle aRect = pOle2Obj->GetLogicRect(); commit 36a0abed4ab27abd77b502070d4e17e70e6afe7b Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 14:18:06 2015 +0100 filter: add BaseURL parameter to SvxMSDffManager::ImportOLE() ... mainly for the (unlikely) case of ODF embedded objects in MSO binary files, which can be created by toggling the Tools->Options->Load/Save->Microsoft Office export settings. Change-Id: I270f1516b70b20ec0b60cfbd17c2c327c3d9efd0 diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 4afc1cb..f29cf4f 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6517,7 +6517,7 @@ SdrObject* SvxMSDffManager::ImportOLE( long nOLEId, if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg )) pRet = CreateSdrOLEFromStorage( sStorageName, xSrcStg, xDstStg, rGrf, rBoundRect, rVisArea, pStData, nError, - nSvxMSDffOLEConvFlags, nAspect ); + nSvxMSDffOLEConvFlags, nAspect, maBaseURL); return pRet; } @@ -6831,7 +6831,7 @@ OUString GetFilterNameFromClassID_Impl( const SvGlobalName& aGlobName ) css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForConvertToSOObj( sal_uInt32 nConvertFlags, SotStorage& rSrcStg, const uno::Reference < embed::XStorage >& rDestStorage, const Graphic& rGrf, - const Rectangle& rVisArea ) + const Rectangle& rVisArea, OUString const& rBaseURL) { uno::Reference < embed::XEmbeddedObject > xObj; SvGlobalName aStgNm = rSrcStg.GetClassName(); @@ -6930,17 +6930,19 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo else aFilterName = GetFilterNameFromClassID_Impl( aStgNm ); - uno::Sequence < beans::PropertyValue > aMedium( aFilterName.isEmpty() ? 2 : 3); + uno::Sequence<beans::PropertyValue> aMedium(aFilterName.isEmpty() ? 3 : 4); aMedium[0].Name = "InputStream"; uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( *xMemStream ); aMedium[0].Value <<= xStream; aMedium[1].Name = "URL"; aMedium[1].Value <<= OUString( "private:stream" ); + aMedium[2].Name = "DocumentBaseURL"; + aMedium[2].Value <<= OUString(rBaseURL); if ( !aFilterName.isEmpty() ) { - aMedium[2].Name = "FilterName"; - aMedium[2].Value <<= aFilterName; + aMedium[3].Name = "FilterName"; + aMedium[3].Value <<= aFilterName; } OUString aName( aDstStgName ); @@ -7015,7 +7017,8 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage( SvStream* pDataStrm, ErrCode& rError, sal_uInt32 nConvertFlags, - sal_Int64 nRecommendedAspect ) + sal_Int64 nRecommendedAspect, + OUString const& rBaseURL) { sal_Int64 nAspect = nRecommendedAspect; SdrOle2Obj* pRet = nullptr; @@ -7069,7 +7072,8 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage( } uno::Reference < embed::XEmbeddedObject > xObj( CheckForConvertToSOObj( - nConvertFlags, *xObjStg, xDestStorage, rGrf, rVisArea )); + nConvertFlags, *xObjStg, xDestStorage, rGrf, + rVisArea, rBaseURL)); if ( xObj.is() ) { svt::EmbeddedObjectRef aObj( xObj, nAspect ); diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 8f066e8..f9d14e8 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1868,7 +1868,7 @@ SdrObject* SdrPowerPointImport::ImportOLE( long nOLEId, { uno::Reference < embed::XStorage > xDestStorage( pOe->pShell->GetStorage() ); uno::Reference < embed::XEmbeddedObject > xObj = - CheckForConvertToSOObj( nSvxMSDffOLEConvFlags, *xObjStor, xDestStorage, rGraf, rVisArea ); + CheckForConvertToSOObj(nSvxMSDffOLEConvFlags, *xObjStor, xDestStorage, rGraf, rVisArea, maBaseURL); if( xObj.is() ) { pOe->pShell->getEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aNm ); diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx index 28b7b27..28ae918 100644 --- a/include/filter/msfilter/msdffimp.hxx +++ b/include/filter/msfilter/msdffimp.hxx @@ -466,7 +466,8 @@ protected: sal_uInt32 nConvertFlags, SotStorage& rSrcStg, const css::uno::Reference < css::embed::XStorage >& xDestStg, const Graphic& rGrf, - const Rectangle& rVisArea ); + const Rectangle& rVisArea, + OUString const& rBaseURL); // the following methods need to be overridden for Excel imports static bool ProcessClientAnchor( SvStream& rStData, @@ -687,7 +688,8 @@ public: SvStream* pDataStrrm, ErrCode& rError, sal_uInt32 nConvertFlags, - sal_Int64 nAspect ); + sal_Int64 nAspect, + OUString const& rBaseURL); /** Create connections between shapes. This method should be called after a page is imported. diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 9a72643..d592213 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -3454,7 +3454,7 @@ SdrObjectPtr XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicOb sal_Int64 nAspects = rPicObj.IsSymbol() ? cssea::MSOLE_ICON : cssea::MSOLE_CONTENT; xSdrObj.reset( CreateSdrOLEFromStorage( aStrgName, xSrcStrg, pDocShell->GetStorage(), aGraphic, - rAnchorRect, aVisArea, nullptr, nError, mnOleImpFlags, nAspects ) ); + rAnchorRect, aVisArea, nullptr, nError, mnOleImpFlags, nAspects, GetRoot().GetMedium().GetBaseURL()) ); } } } diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 476ab4f..54d1306 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -141,7 +141,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, if ( pOLENd ) nAspect = pOLENd->GetAspect(); SdrOle2Obj *pRet = SvxMSDffManager::CreateSdrOLEFromStorage( - rStorageName,xObjStg,m_pDoc->GetDocStorage(),aGraph,aRect,aVisArea,nullptr,nErr,0,nAspect); + rStorageName,xObjStg,m_pDoc->GetDocStorage(),aGraph,aRect,aVisArea,nullptr,nErr,0,nAspect, m_pWriter->GetBaseURL()); if (pRet) { diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 56a819b..04203c3 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -591,7 +591,8 @@ SdrObject* SwMSDffManager::ImportOLE( long nOLEId, { ErrCode nError = ERRCODE_NONE; pRet = CreateSdrOLEFromStorage( sStorageName, xSrcStg, xDstStg, - rGrf, rBoundRect, rVisArea, pStData, nError, nSvxMSDffOLEConvFlags, nAspect ); + rGrf, rBoundRect, rVisArea, pStData, nError, + nSvxMSDffOLEConvFlags, nAspect, rReader.GetBaseURL()); } } return pRet; diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index ff437e3..56a0b76 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -437,7 +437,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph, ErrCode nError = ERRCODE_NONE; pRet = SvxMSDffManager::CreateSdrOLEFromStorage( aSrcStgName, xSrc0, m_pDocShell->GetStorage(), rGraph, aRect, aVisArea, pTmpData, nError, - SwMSDffManager::GetFilterFlags(), nAspect ); + SwMSDffManager::GetFilterFlags(), nAspect, GetBaseURL()); m_pDataStream->Seek( nOldPos ); } } commit 45300b43fe44bb01494fecbaa290d846d476cdb0 Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 14:15:39 2015 +0100 chart2: fix obvious mis-use of wrong member in XMLFilter::impl_Import() ... so we get a BaseURI set. Change-Id: I01176a8a0b0a1f4386f4d58bdf36bd5cb29cf3e5 diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index ba2746d..2ffe00d 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -364,7 +364,8 @@ sal_Int32 XMLFilter::impl_Import( // Set base URI and Hierarchical Name OUString aHierarchName, aBaseUri; - uno::Reference< frame::XModel > xModel( m_xSourceDoc, uno::UNO_QUERY ); + // why retrieve this from the model when it's availabe as rMediaDescriptor? + uno::Reference<frame::XModel> const xModel(m_xTargetDoc, uno::UNO_QUERY); if( xModel.is() ) { uno::Sequence< beans::PropertyValue > aModProps = xModel->getArgs(); commit b0fc09daf1086423a9bd457d9a2c043e7ff41451 Author: Michael Stahl <mst...@redhat.com> Date: Mon Dec 14 13:41:57 2015 +0100 fix missing BaseURL when loading embedded objects When the object is edited in the UI, the m_xClient is set to a SfxInPlaceClient and the DocumentBaseURL is retrieved from it. But if the object is not edited, it will be loaded during export via the API and without a m_xClient; in this case the DocumentBaseURL must have been set previously to be available during import. There appears to be no way to get the URL of the document via the API while it is being imported; SfxBaseModel's m_sURL is unfortunately only initialized from SfxObjectShell::FinishedLoading(). During ODF import, the SvXMLEmbeddedObjectHelper creates the embedded object, so let's make it pass in the parent's BaseURL. The "DefaultParentBaseURL" parameter already exists but was unused previously. Change-Id: I3d1ed29b3a2c0e77ec606a1d09f7bc07e7860733 diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index af4bc5c..21a2f9d 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -280,7 +280,9 @@ OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const css::uno::Referen return OUString(); } -uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::GetEmbeddedObject( const OUString& rName ) +uno::Reference< embed::XEmbeddedObject> +EmbeddedObjectContainer::GetEmbeddedObject( + const OUString& rName, OUString const*const pBaseURL) { SAL_WARN_IF( rName.isEmpty(), "comphelper.container", "Empty object name!"); @@ -303,12 +305,15 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::GetEmbeddedOb if ( aIt != pImpl->maObjectContainer.end() ) xObj = (*aIt).second; else - xObj = Get_Impl( rName, uno::Reference < embed::XEmbeddedObject >() ); + xObj = Get_Impl(rName, uno::Reference<embed::XEmbeddedObject>(), pBaseURL); return xObj; } -uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::Get_Impl( const OUString& rName, const uno::Reference < embed::XEmbeddedObject >& xCopy ) +uno::Reference<embed::XEmbeddedObject> EmbeddedObjectContainer::Get_Impl( + const OUString& rName, + const uno::Reference<embed::XEmbeddedObject>& xCopy, + rtl::OUString const*const pBaseURL) { uno::Reference < embed::XEmbeddedObject > xObj; try @@ -328,13 +333,20 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::Get_Impl( con // object was not added until now - should happen only by calling this method from "inside" //TODO/LATER: it would be good to detect an error when an object should be created already, but isn't (not an "inside" call) uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() ); - uno::Sequence< beans::PropertyValue > aObjDescr( xCopy.is() ? 2 : 1 ); + uno::Sequence< beans::PropertyValue > aObjDescr(1 + (xCopy.is() ? 1 : 0) + (pBaseURL ? 1 : 0)); aObjDescr[0].Name = "Parent"; aObjDescr[0].Value <<= pImpl->m_xModel.get(); + sal_Int32 i = 1; + if (pBaseURL) + { + aObjDescr[i].Name = "DefaultParentBaseURL"; + aObjDescr[i].Value <<= *pBaseURL; + ++i; + } if ( xCopy.is() ) { - aObjDescr[1].Name = "CloneFrom"; - aObjDescr[1].Value <<= xCopy; + aObjDescr[i].Name = "CloneFrom"; + aObjDescr[i].Value <<= xCopy; } uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx index f2b108d..24153c2 100644 --- a/include/comphelper/embeddedobjectcontainer.hxx +++ b/include/comphelper/embeddedobjectcontainer.hxx @@ -43,6 +43,7 @@ namespace comphelper virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0; virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const = 0; virtual bool isEnableSetModified() const = 0; + virtual OUString getDocumentBaseURL() const = 0; protected: ~IEmbeddedHelper() {} @@ -54,7 +55,8 @@ class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer EmbedImpl* pImpl; css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&, - const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy); + const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy, + OUString const* pBaseURL = nullptr); public: // add an embedded object to the container storage @@ -92,7 +94,7 @@ public: OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ); // retrieve an embedded object by name that either has been added already or is available in the container storage - css::uno::Reference < css::embed::XEmbeddedObject > GetEmbeddedObject( const OUString& ); + css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr); // create an object from a ClassId css::uno::Reference < css::embed::XEmbeddedObject > diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 5b32ae8..90e2f57 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -583,6 +583,8 @@ public: { return IsEnableSetModified(); } + virtual OUString getDocumentBaseURL() const override; + comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const; void ClearEmbeddedObjects(); diff --git a/reportdesign/inc/ReportDefinition.hxx b/reportdesign/inc/ReportDefinition.hxx index 36d325f..9e582ea 100644 --- a/reportdesign/inc/ReportDefinition.hxx +++ b/reportdesign/inc/ReportDefinition.hxx @@ -392,6 +392,7 @@ namespace reportdesign virtual ::comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override; virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override; virtual bool isEnableSetModified() const override; + virtual OUString getDocumentBaseURL() const override; css::uno::Reference< css::ui::XUIConfigurationManager2 > getUIConfigurationManager2( ) throw (css::uno::RuntimeException); }; diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 3355055..c5d3f9c 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -2512,6 +2512,11 @@ bool OReportDefinition::isEnableSetModified() const return true; } +OUString OReportDefinition::getDocumentBaseURL() const +{ + return const_cast<OReportDefinition*>(this)->getURL(); +} + uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw() { SolarMutexGuard aSolarGuard; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index ea768f7..722630f 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -3618,6 +3618,7 @@ bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< ta return true; } +// comphelper::IEmbeddedHelper uno::Reference< task::XInteractionHandler > SfxObjectShell::getInteractionHandler() const { uno::Reference< task::XInteractionHandler > xRet; @@ -3626,4 +3627,9 @@ uno::Reference< task::XInteractionHandler > SfxObjectShell::getInteractionHandle return xRet; } +OUString SfxObjectShell::getDocumentBaseURL() const +{ + return GetMedium()->GetBaseURL(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx index ec40121..f75376a 100644 --- a/svx/source/xml/xmleohlp.cxx +++ b/svx/source/xml/xmleohlp.cxx @@ -445,7 +445,8 @@ bool SvXMLEmbeddedObjectHelper::ImplReadObject( // server that was used to create the object. pClassId could be used to specify the server that should // be used for the next opening, but this information seems to be out of the file format responsibility // area. - rContainer.GetEmbeddedObject( aName ); + OUString const baseURL(mpDocPersist->getDocumentBaseURL()); + rContainer.GetEmbeddedObject(aName, &baseURL); return true; } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index f4fad50..a850c81 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -475,10 +475,32 @@ DECLARE_OOXMLEXPORT_TEST(testTableBorders, "table-borders.docx") DECLARE_OOXMLEXPORT_TEST(testFdo51550, "fdo51550.odt") { - // The problem was that we lacked the fallback to export the replacement graphic for OLE objects. - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); + // The problem was that we lacked the fallback to export the replacement + // graphic for OLE objects. But we can actually export the OLE itself now, + // so check that instead. + uno::Reference<text::XTextEmbeddedObjectsSupplier> xTextEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount()); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + + if (!pXmlDocCT) + return; // initial import + + assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocContent = parseExport("word/document.xml"); + assertXPath(pXmlDocContent, + "/w:document/w:body/w:p/w:r/w:object/o:OLEObject", + "ProgID", + "Excel.Sheet.12"); } /* diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 041e54b..a4503a3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -828,13 +828,13 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); // check the rels too - xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart2.xml.rels"); assertXPath(pXmlDocRels, "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); // check the content too - xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart2.xml"); assertXPath(pXmlDocChart1, "/c:chartSpace/c:externalData", "id", commit 7dfa45a62b3b942823af5ccd59897364788589c8 Author: Michael Stahl <mst...@redhat.com> Date: Mon Dec 14 12:38:52 2015 +0100 svtools: print some exception messages with SAL_WARN Change-Id: I2d51b6093e13fd5ea2a93c5a4f38e4078587808d diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 9d50a68..62fa448 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -351,9 +351,9 @@ void EmbeddedObjectRef::Clear() { // there's still someone who needs the object! } - catch (const uno::Exception&) + catch (const uno::Exception& e) { - OSL_FAIL( "Error on switching of the object to loaded state and closing!\n" ); + SAL_WARN("svtools.misc", "Error on switching of the object to loaded state and closing: \"" << e.Message << "\""); } } } @@ -492,18 +492,18 @@ Size EmbeddedObjectRef::GetSize( MapMode* pTargetMapMode ) const catch(const embed::NoVisualAreaSizeException&) { } - catch(const uno::Exception&) + catch (const uno::Exception& e) { - OSL_FAIL( "Something went wrong on getting of the size of the object!" ); + SAL_WARN("svtools.misc", "Something went wrong on getting of the size of the object: \"" << e.Message << "\""); } try { aSourceMapMode = VCLUnoHelper::UnoEmbed2VCLMapUnit(mpImpl->mxObj->getMapUnit(mpImpl->nViewAspect)); } - catch(const uno::Exception&) + catch (const uno::Exception& e) { - OSL_FAIL( "Can not get the map mode!" ); + SAL_WARN("svtools.misc", "Can not get the map mode: \"" << e.Message << "\""); } } commit 1af4dbd827b615a10e4686486fa9034e7adf1289 Author: Michael Stahl <mst...@redhat.com> Date: Fri Dec 11 16:55:55 2015 +0100 sw: extend various OOXML export test to check embedded objects Change-Id: I272afd26addfde5065939db4a04c2f0f01aa28c8 diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 8a51f82..273bdfc 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -693,6 +693,7 @@ protected: xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"), BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), BAD_CAST("urn:schemas-microsoft-com:office:office")); // odt xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index fa2d847..239cfe8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -305,6 +305,30 @@ DECLARE_OOXMLEXPORT_TEST(testChartDupe, "chart-dupe.docx") uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY); // This was 2, on second import we got a duplicated chart copy. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount()); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + + if (!pXmlDocCT) + return; // initial import + + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']", + "ContentType", + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"); + assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Worksheet1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Worksheet1.xlsx']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + assertXPath(pXmlDocChart1, + "/c:chartSpace/c:externalData", + "id", + "rId1"); } DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation, "position-and-rotation.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 9857fe6..041e54b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -390,6 +390,27 @@ DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx") // Check footer1.xml.rels contains in doc after roundtrip. // Check Id = rId1 in footer1.xml.rels assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1"); + assertXPath(pXmlDoc, + "/rels:Relationships/rels:Relationship[@Id='rId1']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']", + "ContentType", + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"); + + // check the content too + xmlDocPtr pXmlDocFooter1 = parseExport("word/footer1.xml"); + assertXPath(pXmlDocFooter1, + "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData", + "uri", + "http://schemas.openxmlformats.org/drawingml/2006/chart"); + assertXPath(pXmlDocFooter1, + "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart", + "id", + "rId1"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); if (xDrawPageSupplier.is()) @@ -516,7 +537,26 @@ DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx") if (!pXmlDoc) return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); + assertXPath(pXmlDoc, + "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject", + "DrawAspect", + "Content"); + // TODO: ProgID="Package" - what is this? Zip with 10k extra header? + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.bin']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"); + // check the media type too + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']", + "ContentType", + "application/vnd.openxmlformats-officedocument.oleObject"); + } DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") @@ -678,6 +718,26 @@ DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx") return; assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + + // check the media type too + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']", + "ContentType", + "application/vnd.openxmlformats-officedocument.oleObject"); + + // check the content too + xmlDocPtr pXmlDocHeader1 = parseExport("word/header1.xml"); + assertXPath(pXmlDocHeader1, + "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject", + "ProgID", + "Word.Picture.8"); + xmlDocPtr pXmlDocHeader2 = parseExport("word/header2.xml"); + assertXPath(pXmlDocHeader2, + "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject", + "ProgID", + "Word.Picture.8"); } DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx") @@ -766,6 +826,19 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") return; assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + assertXPath(pXmlDocChart1, + "/c:chartSpace/c:externalData", + "id", + "rId1"); } DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx") @@ -822,6 +895,20 @@ DECLARE_OOXMLEXPORT_TEST(testEmbeddedExcelChart, "EmbeddedExcelChart.docx") "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xls']", "ContentType", "application/vnd.ms-excel"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xls']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"); + + // check the content too + xmlDocPtr pXmlDocContent = parseExport("word/document.xml"); + assertXPath(pXmlDocContent, + "/w:document/w:body/w:p/w:r/w:object/o:OLEObject", + "ProgID", + "Excel.Chart.8"); } DECLARE_OOXMLEXPORT_TEST(testTdf83227, "tdf83227.docx") diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 50c49f6..43a57ab 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1458,6 +1458,7 @@ void DocxExport::WriteEmbeddings() embeddingsList[j].Value >>= embeddingsStream; OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + // FIXME: this .xlsm hack is silly - if anything the mime-type for an existing embedded object shoud be read from [Content_Types].xml if (embeddingPath.endsWith(".xlsm")) contentType = "application/vnd.ms-excel.sheet.macroEnabled.12"; else if (embeddingPath.endsWith(".bin")) commit 2a9f1dd27a5df97013f73e61eecf53b2348d055a Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 18:21:46 2015 +0100 sw: DOCX export: convert ODF embedded objects to OOXML If the user edits an embedded object it is converted to ODF, so we really need to be able to store such objects. Ensure that the proper MediaType is set in [Content_Types].xml, the package relationship type in document.xml.rels and the proper ProgID attribute in document.xml. Change-Id: I3c78c5ab5b4d534213af5e773fe0c6c2c92d9104 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 238cbde..9857fe6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -744,6 +744,18 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeDOCX, "fdo80410.docx") "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']", "ContentType", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.docx']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocContent = parseExport("word/document.xml"); + assertXPath(pXmlDocContent, + "/w:document/w:body/w:p[6]/w:r/w:object/o:OLEObject", + "ProgID", + "Word.Document.12"); } DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index edc3280..50c49f6 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -25,8 +25,10 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/embed/EmbedStates.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/sax/XSAXSerializable.hpp> #include <com/sun/star/xml/sax/Writer.hpp> @@ -70,6 +72,7 @@ #include "ww8par.hxx" #include "ww8scan.hxx" #include <oox/token/properties.hxx> +#include <comphelper/classids.hxx> #include <comphelper/embeddedobjectcontainer.hxx> #include <comphelper/string.hxx> #include <rtl/ustrbuf.hxx> @@ -462,7 +465,87 @@ static void lcl_ConvertProgID(OUString const& rProgID, } } -OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID) +static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML( + uno::Reference<uno::XComponentContext> const& xContext, + uno::Reference<embed::XEmbeddedObject> const& xObj, + char const*& o_rpProgID, + OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rSuffix) +{ + static struct { + struct { + sal_uInt32 n1; + sal_uInt16 n2, n3; + sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15; + } const ClassId; + char const*const pFilterName; + char const*const pMediaType; + char const*const pProgID; + char const*const pSuffix; + } s_Mapping[] = { + { {SO3_SW_CLASSID_60}, "MS Word 2007 XML", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word.Document.12", "docx" }, + { {SO3_SC_CLASSID_60}, "Calc MS Excel 2007 XML", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel.Sheet.12", "xlsx" }, + { {SO3_SIMPRESS_CLASSID_60}, "Impress MS PowerPoint 2007 XML", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint.Show.12", "pptx" }, + // FIXME: Draw does not appear to have a MSO format export filter? +// { {SO3_SDRAW_CLASSID}, "", "", "", "" }, + { {SO3_SCH_CLASSID_60}, "unused", "", "", "" }, + { {SO3_SM_CLASSID_60}, "unused", "", "", "" }, + }; + + const char * pFilterName(nullptr); + SvGlobalName const classId(xObj->getClassID()); + for (size_t i = 0; i < SAL_N_ELEMENTS(s_Mapping); ++i) + { + auto const& rId(s_Mapping[i].ClassId); + SvGlobalName const temp(rId.n1, rId.n2, rId.n3, rId.b8, rId.b9, rId.b10, rId.b11, rId.b12, rId.b13, rId.b14, rId.b15); + if (temp == classId) + { + assert(SvGlobalName(SO3_SCH_CLASSID_60) != classId); // chart should be written elsewhere! + assert(SvGlobalName(SO3_SM_CLASSID_60) != classId); // formula should be written elsewhere! + pFilterName = s_Mapping[i].pFilterName; + o_rMediaType = OUString::createFromAscii(s_Mapping[i].pMediaType); + o_rpProgID = s_Mapping[i].pProgID; + o_rSuffix = OUString::createFromAscii(s_Mapping[i].pSuffix); + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + break; + } + } + + if (!pFilterName) + { + SAL_WARN("sw.ww8", "DocxExport::WriteOLEObject: unknown ClassId " << classId.GetHexName()); + return nullptr; + } + + if (embed::EmbedStates::LOADED == xObj->getCurrentState()) + { + xObj->changeState(embed::EmbedStates::RUNNING); + } + // use a temp stream - while it would work to store directly to a + // fragment stream, an error during export means we'd have to delete it + uno::Reference<io::XStream> const xTempStream( + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.comp.MemoryStream", xContext), + uno::UNO_QUERY_THROW); + uno::Sequence<beans::PropertyValue> args(2); + args[0].Name = "OutputStream"; + args[0].Value <<= xTempStream->getOutputStream(); + args[1].Name = "FilterName"; + args[1].Value <<= OUString::createFromAscii(pFilterName); + uno::Reference<frame::XStorable> xStorable(xObj->getComponent(), uno::UNO_QUERY); + try + { + xStorable->storeToURL("private:stream", args); + } + catch (uno::Exception const& e) + { + SAL_WARN("sw.ww8", "DocxExport::WriteOLEObject: exception: \"" << e.Message << "\""); + return nullptr; + } + xTempStream->getOutputStream()->closeOutput(); + return xTempStream->getInputStream(); +} + +OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID) { uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() ); comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer(); @@ -470,17 +553,46 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID) OUString sMediaType; OUString sRelationType; - OUString sFileExtension; - lcl_ConvertProgID(rProgID, sMediaType, sRelationType, sFileExtension); + OUString sSuffix; + const char * pProgID(nullptr); + + if (xInStream.is()) + { + lcl_ConvertProgID(io_rProgID, sMediaType, sRelationType, sSuffix); + } + else // the object is ODF - either the whole document is + { // ODF, or the OLE was edited so it was converted to ODF + uno::Reference<uno::XComponentContext> const xContext( + GetFilter().getComponentContext()); + xInStream = lcl_StoreOwnAsOOXML(xContext, xObj, + pProgID, sMediaType, sRelationType, sSuffix); + } + + if (!xInStream.is()) + { + return OString(); + } - OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension; + assert(!sMediaType.isEmpty()); + assert(!sRelationType.isEmpty()); + assert(!sSuffix.isEmpty()); + OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sSuffix; uno::Reference<io::XOutputStream> const xOutStream = GetFilter().openFragmentStream("word/" + sFileName, sMediaType); - OUString sId; - if( lcl_CopyStream( xInStream, xOutStream ) ) + assert(xOutStream.is()); // no reason why that could fail + bool const isExported = lcl_CopyStream(xInStream, xOutStream); + + OUString sId; + if (isExported) + { sId = m_pFilter->addRelation( GetFS()->getOutputStream(), sRelationType, sFileName ); + if (pProgID) + { + io_rProgID = OUString::createFromAscii(pProgID); + } + } return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 169759d..cc1854d 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -170,7 +170,7 @@ public: /// Returns the relationd id OString OutputChart( css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer ); - OString WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID); + OString WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID); static bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut ); /// Writes the shape using drawingML syntax. commit ea50cb70efed40d1ed2ca6806c626ed5fdb71351 Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 17:06:18 2015 +0100 sw: replace OUStringBuffer Change-Id: Iebb4ac4a7307bb8482ca735096503da03448fee7 diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 3e77d9a..edc3280 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -474,11 +474,8 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID) lcl_ConvertProgID(rProgID, sMediaType, sRelationType, sFileExtension); OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension; - uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer() - .append( "word/" ) - .append( sFileName ) - .makeStringAndClear(), - sMediaType ); + uno::Reference<io::XOutputStream> const xOutStream = + GetFilter().openFragmentStream("word/" + sFileName, sMediaType); OUString sId; if( lcl_CopyStream( xInStream, xOutStream ) ) commit a7762b56c0f0605d090ed95069db16c6641f769e Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 17:01:19 2015 +0100 sw: move ProgId parsing to DocxExport::WriteOLEObject Change-Id: Ieb308d717aa661fa51bd1b9dd3d0a12ca61337c1 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index d9b45e8..d65d9db 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4752,7 +4752,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj ); // set some attributes according to the type of the embedded object - OUString sProgID, sMediaType, sRelationType, sFileExtension, sDrawAspect="Content"; + OUString sProgID, sDrawAspect = "Content"; for( sal_Int32 i=0; i < aObjectsInteropList.getLength(); ++i ) if ( aObjectsInteropList[i].Name == sObjectName ) { @@ -4772,99 +4772,8 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S } } - if( sProgID == "Excel.Sheet.12" ) - { - sMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "xlsx"; - } - else if(sProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") ) - { - sMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "xlsb"; - } - else if( sProgID.startsWith("Excel.SheetMacroEnabled.12") ) - { - sMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "xlsm"; - } - else if( sProgID.startsWith("Excel.Sheet") ) - { - sMediaType = "application/vnd.ms-excel"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "xls"; - } - else if( sProgID == "PowerPoint.Show.12" ) - { - sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "pptx"; - } - else if(sProgID == "PowerPoint.ShowMacroEnabled.12") - { - sMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "pptm"; - } - else if( sProgID.startsWith("PowerPoint.Show") ) - { - sMediaType = "application/vnd.ms-powerpoint"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "ppt"; - } - else if (sProgID.startsWith("PowerPoint.Slide.12")) - { - sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "sldx"; - } - else if( sProgID == "PowerPoint.SlideMacroEnabled.12" ) - { - sMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "sldm"; - } - else if( sProgID == "Word.DocumentMacroEnabled.12" ) - { - sMediaType = "application/vnd.ms-word.document.macroEnabled.12"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "docm"; - } - else if (sProgID == "Word.Document.12") - { - sMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; - sFileExtension = "docx"; - } - else if( sProgID == "Word.Document.8" ) - { - sMediaType = "application/msword"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "doc"; - } - else if( sProgID == "Excel.Chart.8" ) - { - sMediaType = "application/vnd.ms-excel"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "xls"; - } - else if (sProgID == "AcroExch.Document.11") - { - sMediaType = "application/pdf"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "pdf"; - } - else - { - sMediaType = "application/vnd.openxmlformats-officedocument.oleObject"; - sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; - sFileExtension = "bin"; - } - // write embedded file - OString sId = m_rExport.WriteOLEObject( aObject, sMediaType, sRelationType, sFileExtension ); + OString sId = m_rExport.WriteOLEObject(aObject, sProgID); if( sId.isEmpty() ) { diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 109b36d..3e77d9a 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -366,12 +366,113 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } -OString DocxExport::WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension ) + +static void lcl_ConvertProgID(OUString const& rProgID, + OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rFileExtension) +{ + if (rProgID == "Excel.Sheet.12") + { + o_rMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "xlsx"; + } + else if (rProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") ) + { + o_rMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "xlsb"; + } + else if (rProgID.startsWith("Excel.SheetMacroEnabled.12")) + { + o_rMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "xlsm"; + } + else if (rProgID.startsWith("Excel.Sheet")) + { + o_rMediaType = "application/vnd.ms-excel"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "xls"; + } + else if (rProgID == "PowerPoint.Show.12") + { + o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "pptx"; + } + else if (rProgID == "PowerPoint.ShowMacroEnabled.12") + { + o_rMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "pptm"; + } + else if (rProgID.startsWith("PowerPoint.Show")) + { + o_rMediaType = "application/vnd.ms-powerpoint"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "ppt"; + } + else if (rProgID.startsWith("PowerPoint.Slide.12")) + { + o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "sldx"; + } + else if (rProgID == "PowerPoint.SlideMacroEnabled.12") + { + o_rMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "sldm"; + } + else if (rProgID == "Word.DocumentMacroEnabled.12") + { + o_rMediaType = "application/vnd.ms-word.document.macroEnabled.12"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "docm"; + } + else if (rProgID == "Word.Document.12") + { + o_rMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + o_rFileExtension = "docx"; + } + else if (rProgID == "Word.Document.8") + { + o_rMediaType = "application/msword"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "doc"; + } + else if (rProgID == "Excel.Chart.8") + { + o_rMediaType = "application/vnd.ms-excel"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "xls"; + } + else if (rProgID == "AcroExch.Document.11") + { + o_rMediaType = "application/pdf"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "pdf"; + } + else + { + o_rMediaType = "application/vnd.openxmlformats-officedocument.oleObject"; + o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + o_rFileExtension = "bin"; + } +} + +OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID) { uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() ); comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer(); uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj ); + OUString sMediaType; + OUString sRelationType; + OUString sFileExtension; + lcl_ConvertProgID(rProgID, sMediaType, sRelationType, sFileExtension); + OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension; uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer() .append( "word/" ) diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index a4315d7..169759d 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -170,7 +170,7 @@ public: /// Returns the relationd id OString OutputChart( css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer ); - OString WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension ); + OString WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID); static bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut ); /// Writes the shape using drawingML syntax. commit 8831281942b0ffe3dbdcea6febcda97a2ab665b3 Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 15 12:35:47 2015 +0100 sfx2: fix valgrind warning ==7727== Conditional jump or move depends on uninitialised value(s) ==7727== at 0x9121E24: SfxDockingWindow::Resize() (dockwin.cxx:451) ==7727== by 0x3CADFAC3: SmElementsDockingWindow::Resize() (ElementsDockingWindow.cxx:753) Change-Id: Ie6e8a61f6c295373e5ccad409e2557e7c2dd6c1a diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index e4d71dd..99ab523 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -857,6 +857,7 @@ SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW, pImp->nLine = pImp->nDockLine = 0; pImp->nPos = pImp->nDockPos = 0; pImp->bNewLine = false; + pImp->SetDockAlignment(SfxChildAlignment::NOALIGNMENT); pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT); pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE); pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl)); @@ -902,6 +903,7 @@ SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW, pImp->nLine = pImp->nDockLine = 0; pImp->nPos = pImp->nDockPos = 0; pImp->bNewLine = false; + pImp->SetDockAlignment(SfxChildAlignment::NOALIGNMENT); pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT); pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE); pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl)); @@ -947,6 +949,7 @@ SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW, pImp->nLine = pImp->nDockLine = 0; pImp->nPos = pImp->nDockPos = 0; pImp->bNewLine = false; + pImp->SetDockAlignment(SfxChildAlignment::NOALIGNMENT); pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT); pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE); pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl)); commit 8522c20c704cdf8345dc0b8f69a8fdf2a75583e2 Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 14:02:21 2015 +0100 sc: replace boost::ptr_map with std::map<std::unique_ptr> Change-Id: Idabd8facd21efb2da3e46185272d76bce2d0b44c diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx index af3cc33..d3de9e6 100644 --- a/sc/source/core/tool/callform.cxx +++ b/sc/source/core/tool/callform.cxx @@ -26,7 +26,6 @@ #include <osl/file.hxx> #include <unotools/transliterationwrapper.hxx> #include <o3tl/make_unique.hxx> -#include <boost/ptr_container/ptr_map.hpp> #include <memory> #include "callform.hxx" @@ -125,8 +124,8 @@ namespace { class ModuleCollection { - typedef boost::ptr_map<OUString, ModuleData> MapType; - MapType maData; + typedef std::map<OUString, std::unique_ptr<ModuleData>> MapType; + MapType m_Data; public: ModuleCollection() {} @@ -137,8 +136,8 @@ public: const ModuleData* ModuleCollection::findByName(const OUString& rName) const { - MapType::const_iterator it = maData.find(rName); - return it == maData.end() ? nullptr : it->second; + MapType::const_iterator it = m_Data.find(rName); + return it == m_Data.end() ? nullptr : it->second.get(); } void ModuleCollection::insert(ModuleData* pNew) @@ -147,12 +146,12 @@ void ModuleCollection::insert(ModuleData* pNew) return; OUString aName = pNew->GetName(); - maData.insert(aName, pNew); + m_Data.insert(std::make_pair(aName, std::unique_ptr<ModuleData>(pNew))); } void ModuleCollection::clear() { - maData.clear(); + m_Data.clear(); } ModuleCollection aModuleCollection; commit 7086ed59512f359bc62963202a08d41e2e5ceccb Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 14:00:31 2015 +0100 sc: replace boost::ptr_map with std::map<std::unique_ptr> Change-Id: I800f8d4facaa6dc8eb04b2544ce0e9035af66442 diff --git a/sc/inc/callform.hxx b/sc/inc/callform.hxx index a883ec5..584c1d1 100644 --- a/sc/inc/callform.hxx +++ b/sc/inc/callform.hxx @@ -22,7 +22,8 @@ #include <rtl/ustring.hxx> -#include <boost/ptr_container/ptr_map.hpp> +#include <memory> +#include <map> #define MAXFUNCPARAM 16 #define MAXARRSIZE 0xfffe @@ -86,8 +87,9 @@ public: class LegacyFuncCollection { - typedef boost::ptr_map<OUString, LegacyFuncData> MapType; - MapType maData; + typedef std::map<OUString, std::unique_ptr<LegacyFuncData>> MapType; + MapType m_Data; + public: typedef MapType::const_iterator const_iterator; diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index ff72cdc..b9c6e30 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -451,7 +451,7 @@ ScFunctionList::ScFunctionList() : LegacyFuncCollection::const_iterator it = rLegacyFuncColl.begin(), itEnd = rLegacyFuncColl.end(); for (; it != itEnd; ++it) { - const LegacyFuncData* pLegacyFuncData = it->second; + const LegacyFuncData *const pLegacyFuncData = it->second.get(); pDesc = new ScFuncDesc; sal_uInt16 nArgs = pLegacyFuncData->GetParamCount() - 1; pLegacyFuncData->getParamDesc( aArgName, aArgDesc, 0 ); diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx index 3334715..af3cc33 100644 --- a/sc/source/core/tool/callform.cxx +++ b/sc/source/core/tool/callform.cxx @@ -25,6 +25,8 @@ #include <osl/module.hxx> #include <osl/file.hxx> #include <unotools/transliterationwrapper.hxx> +#include <o3tl/make_unique.hxx> +#include <boost/ptr_container/ptr_map.hpp> #include <memory> #include "callform.hxx" @@ -398,34 +400,40 @@ bool LegacyFuncData::getParamDesc( OUString& aName, OUString& aDesc, sal_uInt16 } LegacyFuncCollection::LegacyFuncCollection() {} -LegacyFuncCollection::LegacyFuncCollection(const LegacyFuncCollection& r) : maData(r.maData) {} +LegacyFuncCollection::LegacyFuncCollection(const LegacyFuncCollection& r) +{ + for (auto const& it : r.m_Data) + { + m_Data.insert(std::make_pair(it.first, o3tl::make_unique<LegacyFuncData>(*it.second))); + } +} const LegacyFuncData* LegacyFuncCollection::findByName(const OUString& rName) const { - MapType::const_iterator it = maData.find(rName); - return it == maData.end() ? nullptr : it->second; + MapType::const_iterator it = m_Data.find(rName); + return it == m_Data.end() ? nullptr : it->second.get(); } LegacyFuncData* LegacyFuncCollection::findByName(const OUString& rName) { - MapType::iterator it = maData.find(rName); - return it == maData.end() ? nullptr : it->second; + MapType::iterator it = m_Data.find(rName); + return it == m_Data.end() ? nullptr : it->second.get(); } void LegacyFuncCollection::insert(LegacyFuncData* pNew) { OUString aName = pNew->GetInternalName(); - maData.insert(aName, pNew); + m_Data.insert(std::make_pair(aName, std::unique_ptr<LegacyFuncData>(pNew))); } LegacyFuncCollection::const_iterator LegacyFuncCollection::begin() const { - return maData.begin(); + return m_Data.begin(); } LegacyFuncCollection::const_iterator LegacyFuncCollection::end() const { - return maData.end(); + return m_Data.end(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 14a0115b9580d541971440c085220328c5aed92e Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 9 13:43:27 2015 +0100 sc: replace boost::ptr_map with std::map<std::unique_ptr> Change-Id: I311d3a3e35ae4321e92e1fe2e0651b3b4899c0bd diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx index a290aca..9a03d91 100644 --- a/sc/inc/autoform.hxx +++ b/sc/inc/autoform.hxx @@ -59,7 +59,9 @@ #include "zforauto.hxx" #include <boost/noncopyable.hpp> -#include <boost/ptr_container/ptr_map.hpp> + +#include <memory> +#include <map> /** A binary blob of writer-specific data. This data typically consists of types that are @@ -313,8 +315,8 @@ struct DefaultFirstEntry { class SC_DLLPUBLIC ScAutoFormat { - typedef boost::ptr_map<OUString, ScAutoFormatData, DefaultFirstEntry> MapType; - MapType maData; + typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType; + MapType m_Data; bool mbSaveLater; ScAfVersions m_aVersions; diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx index 2207f6b..3e6cc33 100644 --- a/sc/source/core/tool/autoform.cxx +++ b/sc/source/core/tool/autoform.cxx @@ -31,6 +31,7 @@ #include <tools/urlobj.hxx> #include <unotools/transliterationwrapper.hxx> #include <tools/tenccvt.hxx> +#include <o3tl/make_unique.hxx> #include "globstr.hrc" #include "document.hxx" @@ -906,9 +907,14 @@ bool DefaultFirstEntry::operator() (const OUString& left, const OUString& right) return ScGlobal::GetCollator()->compareString( left, right) < 0; } -ScAutoFormat::ScAutoFormat(const ScAutoFormat& r) : - maData(r.maData), - mbSaveLater(false) {} +ScAutoFormat::ScAutoFormat(const ScAutoFormat& r) + : mbSaveLater(false) +{ + for (auto const& it : r.m_Data) + { + m_Data.insert(std::make_pair(it.first, o3tl::make_unique<ScAutoFormatData>(*it.second))); + } +} ScAutoFormat::~ScAutoFormat() { @@ -926,30 +932,30 @@ void ScAutoFormat::SetSaveLater( bool bSet ) const ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) const { - if (nIndex >= maData.size()) + if (nIndex >= m_Data.size()) return nullptr; - MapType::const_iterator it = maData.begin(); + MapType::const_iterator it = m_Data.begin(); std::advance(it, nIndex); - return it->second; + return it->second.get(); } ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) { - if (nIndex >= maData.size()) + if (nIndex >= m_Data.size()) return nullptr; - MapType::iterator it = maData.begin(); + MapType::iterator it = m_Data.begin(); std::advance(it, nIndex); - return it->second; + return it->second.get(); } ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData) { - MapType::iterator it = maData.begin(), itEnd = maData.end(); + MapType::iterator it = m_Data.begin(), itEnd = m_Data.end(); for (; it != itEnd; ++it) { - if (it->second == pData) + if (it->second.get() == pData) return it; } return itEnd; @@ -957,43 +963,43 @@ ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData) ScAutoFormat::iterator ScAutoFormat::find(const OUString& rName) { - return maData.find(rName); + return m_Data.find(rName); } bool ScAutoFormat::insert(ScAutoFormatData* pNew) { OUString aName = pNew->GetName(); - return maData.insert(aName, pNew).second; + return m_Data.insert(std::make_pair(aName, std::unique_ptr<ScAutoFormatData>(pNew))).second; } void ScAutoFormat::erase(const iterator& it) { - maData.erase(it); + m_Data.erase(it); } size_t ScAutoFormat::size() const { - return maData.size(); + return m_Data.size(); } ScAutoFormat::const_iterator ScAutoFormat::begin() const { - return maData.begin(); + return m_Data.begin(); } ScAutoFormat::const_iterator ScAutoFormat::end() const { - return maData.end(); + return m_Data.end(); } ScAutoFormat::iterator ScAutoFormat::begin() { - return maData.begin(); + return m_Data.begin(); } ScAutoFormat::iterator ScAutoFormat::end() { - return maData.end(); + return m_Data.end(); } bool ScAutoFormat::Load() @@ -1084,9 +1090,9 @@ bool ScAutoFormat::Save() bRet &= (rStream.GetError() == 0); - rStream.WriteUInt16( maData.size() - 1 ); + rStream.WriteUInt16( m_Data.size() - 1 ); bRet &= (rStream.GetError() == 0); - MapType::iterator it = maData.begin(), itEnd = maData.end(); + MapType::iterator it = m_Data.begin(), itEnd = m_Data.end(); if (it != itEnd) { for (++it; bRet && it != itEnd; ++it) // Skip the first item. diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index e8190e4..ace4398 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -84,7 +84,7 @@ ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, Init(); ScAutoFormat::iterator it = pFormat->begin(); - m_pWndPreview->NotifyChange(it->second); + m_pWndPreview->NotifyChange(it->second.get()); } ScAutoFormatDlg::~ScAutoFormatDlg() diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx index c623071..0bd1abe 100644 --- a/sc/source/ui/unoobj/afmtuno.cxx +++ b/sc/source/ui/unoobj/afmtuno.cxx @@ -149,7 +149,7 @@ static bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, const OUStrin ScAutoFormat::const_iterator itBeg = rFormats.begin(), itEnd = rFormats.end(); for (ScAutoFormat::const_iterator it = itBeg; it != itEnd; ++it) { - const ScAutoFormatData* pEntry = it->second; + const ScAutoFormatData *const pEntry = it->second.get(); const OUString& aEntryName = pEntry->GetName(); if ( aEntryName.equals(rName) ) { @@ -513,7 +513,7 @@ void SAL_CALL ScAutoFormatObj::setName( const OUString& aNewName ) { ScAutoFormat::iterator it = pFormats->begin(); std::advance(it, nFormatIndex); - ScAutoFormatData* pData = it->second; + ScAutoFormatData *const pData = it->second.get(); OSL_ENSURE(pData,"AutoFormat Daten nicht da"); ScAutoFormatData* pNew = new ScAutoFormatData(*pData); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits