diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2014-05-19 11:37:11 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-27 03:09:56 -0500 |
commit | 51bc76f170c8fc71bc37c058c5e6cd1f14b773fb (patch) | |
tree | 63cba8f08b3de8b425f770195fceb17d124729c0 | |
parent | 05086b3449eeb8354fe287989122ead626268fff (diff) |
various situations where graphic go missing on save
Resolves: #i114361# provide and accept changed URL...
of embedded graphic file during save (ODF export)
(cherry picked from commit a90c007908eb3f66e28a9ea525729065db652b6f)
Conflicts:
sw/inc/ndgrf.hxx
sw/source/core/graphic/ndgrf.cxx
sw/source/core/unocore/unoframe.cxx
sw/source/filter/xml/xmltexte.cxx
xmloff/source/draw/shapeexport2.cxx
Change-Id: I9d4a02af2561467fe1a66f036b55d6dcf2429986
(cherry picked from commit 192abfb36b8a4859879fcb49326d59ed62083c8d)
Resolves: #i124717# do not mark *.svm graphic files as *.bmp graphic files
(cherry picked from commit a5cfb91f3dc4b38055fb920f65101cc45d52f8de)
Conflicts:
svtools/source/filter/filter.cxx
Change-Id: I43f62a453bfa17254cebc07bde95f07f16a329c2
(cherry picked from commit 12dd68e3d20ad36ebe7cb40a600215f6d2b7b6ec)
Resolves: #i124946# only apply new embedded stream name...
for a graphic, if is already has one.
- needed correction for the fix made for issue #i114361#
(cherry picked from commit 23a4bd91ceb89e5e0a2413f80fc987db106a0bc9)
Conflicts:
sw/inc/ndgrf.hxx
sw/source/core/graphic/ndgrf.cxx
sw/source/filter/xml/xmltexte.cxx
Change-Id: Ia9771932ae5b380ccae9b0a3cbb79d41f5d9bdb8
(cherry picked from commit 05e07167e422caf58d23ff883edda30acc3ba88d)
Resolves: #i124966# keep picture format information
- <GfxLink> instance - also for the reading of preview picture data
in order to avoid trouble on save in case that the preview data equals the
picture data
(cherry picked from commit d6af1b601bb8fe2569d17e01505f67e1becc9366)
Conflicts:
svx/source/svdraw/svdograf.cxx
Change-Id: Ifecb07b4d5d33d593502fccd6f21644893027d2d
(cherry picked from commit 597ae8dd9c28ee370874b219d594fa1c105f2c72)
Reviewed-on: https://gerrit.libreoffice.org/9455
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 8 | ||||
-rw-r--r-- | sw/inc/ndgrf.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltexte.cxx | 10 | ||||
-rw-r--r-- | vcl/source/filter/graphicfilter.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 11 |
7 files changed, 38 insertions, 21 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index df6189d5d3de..5a9496f8e541 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -1352,9 +1352,11 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) { pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 ); - com::sun::star::awt::Size aPreviewSizeHint( 64, 64 ); - bool bAllowPartialStreamRead = true; - bool bCreateNativeLink = false; + const com::sun::star::awt::Size aPreviewSizeHint( 64, 64 ); + const bool bAllowPartialStreamRead = true; + // create <GfxLink> instance also for previews in order to avoid that its corresponding + // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data + const bool bCreateNativeLink = true; (*pFilterData)[ 0 ].Name = "PreviewSizeHint"; (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint; (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead"; diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx index d5e3ddd7a307..4d97b6a9feae 100644 --- a/sw/inc/ndgrf.hxx +++ b/sw/inc/ndgrf.hxx @@ -72,7 +72,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode void InsertLink( const OUString& rGrfName, const OUString& rFltName ); bool ImportGraphic( SvStream& rStrm ); - bool HasStreamName() const { return maGrfObj.HasUserData(); } /** adjust return type and rename method to indicate that its an private one. */ @@ -174,8 +173,12 @@ public: bool SwapIn( bool bWaitForData = false ); /// Remove graphic in order to free memory. bool SwapOut(); - /// Access to storage stream-name. - void SetStreamName( const OUString& r ) { maGrfObj.SetUserData( r ); } + bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); } + /// applying new stream name for embedded graphic - needed as saving the document might change this stream name + void ApplyNewEmbeddedStreamName(const OUString& r) + { + maGrfObj.SetUserData(r); + } /// Is this node selected by any shell? bool IsSelected() const; diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index c868c56a1fb5..00e383d5f6b0 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -233,7 +233,7 @@ bool SwGrfNode::ReRead( else if( pGraphic && rGrfName.isEmpty() ) { // Old stream must be deleted before the new one is set. - if( HasStreamName() ) + if( HasEmbeddedStreamName() ) DelStreamName(); maGrfObj.SetGraphic( *pGraphic ); @@ -243,7 +243,7 @@ bool SwGrfNode::ReRead( else if( pGrfObj && rGrfName.isEmpty() ) { // Old stream must be deleted before the new one is set. - if( HasStreamName() ) + if( HasEmbeddedStreamName() ) DelStreamName(); maGrfObj = *pGrfObj; @@ -257,7 +257,7 @@ bool SwGrfNode::ReRead( return true; else { - if( HasStreamName() ) + if( HasEmbeddedStreamName() ) DelStreamName(); // create new link for the graphic object @@ -563,7 +563,7 @@ bool SwGrfNode::SwapIn( bool bWaitForData ) else if( maGrfObj.IsSwappedOut() ) { // graphic is in storage or in a temp file - if( !HasStreamName() ) + if( !HasEmbeddedStreamName() ) { bRet = maGrfObj.SwapIn(); } @@ -617,7 +617,7 @@ bool SwGrfNode::SwapOut() // Swapping is only needed for embedded pictures. // The graphic will be written into a temp file if it is new, i.e. // if there is no stream name in the storage yet - if( !HasStreamName() ) + if( !HasEmbeddedStreamName() ) if( !maGrfObj.SwapOut() ) return false; } @@ -669,7 +669,7 @@ bool SwGrfNode::SavePersistentData() } // swap in first if already in storage - if( HasStreamName() && !SwapIn() ) + if( HasEmbeddedStreamName() && !SwapIn() ) return false; // #i44367# @@ -860,7 +860,7 @@ void SwGrfNode::ScaleImageMap() void SwGrfNode::DelStreamName() { - if( HasStreamName() ) + if( HasEmbeddedStreamName() ) { // then remove graphic from storage uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage(); @@ -969,7 +969,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const Graphic aTmpGrf; SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink; - if( !pLink && HasStreamName() ) + if( !pLink && HasEmbeddedStreamName() ) { try { @@ -1048,7 +1048,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj ) { pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; - if( HasStreamName() ) + if( HasEmbeddedStreamName() ) { try { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index a89540756805..6a15f4e7a2d5 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2010,7 +2010,6 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) if(pIdx) { SwNodeIndex aIdx(*pIdx, 1); -// SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); if(!pGrfNode) throw uno::RuntimeException(); diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 6cbb329be4cf..9b184afd8220 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -197,6 +197,16 @@ void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL( SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode(); if (pGrfNd && !pGrfNd->IsGrfLink()) { + // Apply new embedded stream name, only if graphic node already has one. + // - The saving of recovery information triggers this method, but for a newly created + // document the new embedded stream name shall not be applied. + // - The saving of a newly created document to own format (ODF) triggers this method, + // but the embedded stream name is not needed as its original inserted data is still in use. + if (pGrfNd->HasEmbeddedStreamName()) + { + pGrfNd->ApplyNewEmbeddedStreamName("vnd.sun.star.Package:" + rURL); + } + // #i15411# save-as will swap all graphics in; we need to swap // them out again, to prevent excessive memory use pGrfNd->SwapOut(); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 2485d442aa99..1f132f364139 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1592,7 +1592,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat { nStatus = GRFILTER_FORMATERROR; } - else + else if (aFilterName.equalsIgnoreAsciiCase(IMP_BMP)) { // #i15508# added BMP type (checked, works) eLinkType = GFX_LINK_TYPE_NATIVE_BMP; diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 9a1723bc183a..66577bac9594 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -2247,7 +2247,6 @@ void XMLShapeExport::ImpExportGraphicObjectShape( if( !bIsEmptyPresObj ) { OUString aStreamURL; - OUString aStr; xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL; xPropSet->getPropertyValue("GraphicURL") >>= sImageURL; @@ -2255,7 +2254,7 @@ void XMLShapeExport::ImpExportGraphicObjectShape( OUString aResolveURL( sImageURL ); const OUString sPackageURL( "vnd.sun.star.Package:" ); - // sj: trying to preserve the filename + // trying to preserve the filename if ( aStreamURL.match( sPackageURL, 0 ) ) { OUString sRequestedName( aStreamURL.copy( sPackageURL.getLength(), aStreamURL.getLength() - sPackageURL.getLength() ) ); @@ -2272,16 +2271,20 @@ void XMLShapeExport::ImpExportGraphicObjectShape( } } - aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL ); + const OUString aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL ); mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr ); if( !aStr.isEmpty() ) { + aStreamURL = sPackageURL; if( aStr[ 0 ] == '#' ) { - aStreamURL = sPackageURL; aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) ); } + else + { + aStreamURL = aStreamURL.concat( aStr ); + } // update stream URL for load on demand uno::Any aAny; |