[libreoffice/f20] Resolves: rhbz#1084822 graphics missing after save and reload

Caolán McNamara caolanm at fedoraproject.org
Fri May 23 21:00:19 UTC 2014


commit e67911f0a39dab19cb4196b18a6f24bd0c1dc9d0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 23 21:55:26 2014 +0100

    Resolves: rhbz#1084822 graphics missing after save and reload

 ...tuations-where-graphic-go-missing-on-save.patch |  284 ++++++++++++++++++++
 libreoffice.spec                                   |    6 +-
 2 files changed, 289 insertions(+), 1 deletions(-)
---
diff --git a/0001-various-situations-where-graphic-go-missing-on-save.patch b/0001-various-situations-where-graphic-go-missing-on-save.patch
new file mode 100644
index 0000000..320893f
--- /dev/null
+++ b/0001-various-situations-where-graphic-go-missing-on-save.patch
@@ -0,0 +1,284 @@
+From cd971608e456f04bd6f315dfd96ffade79abfc20 Mon Sep 17 00:00:00 2001
+From: Oliver-Rainer Wittmann <orw at apache.org>
+Date: Mon, 19 May 2014 11:37:11 +0000
+Subject: [PATCH] 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
+
+(cherry picked from commit 192abfb36b8a4859879fcb49326d59ed62083c8d)
+
+Conflicts:
+	sw/inc/ndgrf.hxx
+
+Change-Id: I9d4a02af2561467fe1a66f036b55d6dcf2429986
+
+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
+
+(cherry picked from commit 05e07167e422caf58d23ff883edda30acc3ba88d)
+
+Conflicts:
+	sw/inc/ndgrf.hxx
+	sw/source/core/graphic/ndgrf.cxx
+
+Change-Id: Ia9771932ae5b380ccae9b0a3cbb79d41f5d9bdb8
+
+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
+
+(cherry picked from commit 597ae8dd9c28ee370874b219d594fa1c105f2c72)
+
+Conflicts:
+	svx/source/svdraw/svdograf.cxx
+
+Change-Id: Ifecb07b4d5d33d593502fccd6f21644893027d2d
+---
+ svx/source/svdraw/svdograf.cxx      |  8 +++++---
+ sw/inc/ndgrf.hxx                    |  9 ++++++---
+ sw/source/core/graphic/ndgrf.cxx    | 18 +++++++++---------
+ sw/source/core/unocore/unoframe.cxx |  1 -
+ sw/source/filter/xml/xmltexte.cxx   | 10 ++++++++++
+ xmloff/source/draw/shapeexport.cxx  | 11 +++++++----
+ 6 files changed, 37 insertions(+), 20 deletions(-)
+
+diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
+index 30e51f0..0a672d3 100644
+--- a/svx/source/svdraw/svdograf.cxx
++++ b/svx/source/svdraw/svdograf.cxx
+@@ -1389,9 +1389,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 );
+-                        sal_Bool bAllowPartialStreamRead = true;
+-                        sal_Bool bCreateNativeLink = false;
++                        const com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
++                        const sal_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 sal_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 a2687d6..599b6d4 100644
+--- a/sw/inc/ndgrf.hxx
++++ b/sw/inc/ndgrf.hxx
+@@ -74,7 +74,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
+ 
+     void InsertLink( const OUString& rGrfName, const OUString& rFltName );
+     sal_Bool ImportGraphic( SvStream& rStrm );
+-    sal_Bool HasStreamName() const { return maGrfObj.HasUserData(); }
+     /** adjust return type and rename method to
+        indicate that its an private one. */
+ 
+@@ -172,8 +171,12 @@ public:
+     short SwapIn( sal_Bool bWaitForData = sal_False );
+     /// Remove graphic in order to free memory.
+     short 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?
+     sal_Bool IsSelected() const;
+ 
+diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
+index 725296f..c6d3c54 100644
+--- a/sw/source/core/graphic/ndgrf.cxx
++++ b/sw/source/core/graphic/ndgrf.cxx
+@@ -233,7 +233,7 @@ sal_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 @@ sal_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 @@ sal_Bool SwGrfNode::ReRead(
+         return sal_True;
+     else
+     {
+-        if( HasStreamName() )
++        if( HasEmbeddedStreamName() )
+             DelStreamName();
+ 
+         // create new link for the graphic object
+@@ -561,7 +561,7 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
+     else if( maGrfObj.IsSwappedOut() )
+     {
+         // graphic is in storage or in a temp file
+-        if( !HasStreamName() )
++        if( !HasEmbeddedStreamName() )
+             nRet = (short)maGrfObj.SwapIn();
+         else
+         {
+@@ -614,7 +614,7 @@ short 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 0;
+         }
+@@ -666,7 +666,7 @@ sal_Bool SwGrfNode::SavePersistentData()
+     }
+ 
+     // swap in first if already in storage
+-    if( HasStreamName() && !SwapIn() )
++    if( HasEmbeddedStreamName() && !SwapIn() )
+         return sal_False;
+ 
+     // #i44367#
+@@ -820,7 +820,7 @@ void SwGrfNode::ScaleImageMap()
+ 
+ void SwGrfNode::DelStreamName()
+ {
+-    if( HasStreamName() )
++    if( HasEmbeddedStreamName() )
+     {
+         // then remove graphic from storage
+         uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
+@@ -929,7 +929,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
+         {
+@@ -1008,7 +1008,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 035340e..43520a7 100644
+--- a/sw/source/core/unocore/unoframe.cxx
++++ b/sw/source/core/unocore/unoframe.cxx
+@@ -1544,7 +1544,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 6e4223f..c3575ba 100644
+--- a/sw/source/filter/xml/xmltexte.cxx
++++ b/sw/source/filter/xml/xmltexte.cxx
+@@ -205,6 +205,16 @@ void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
+     SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
+     if( !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/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
+index da5057c..bddf0ac 100644
+--- a/xmloff/source/draw/shapeexport.cxx
++++ b/xmloff/source/draw/shapeexport.cxx
+@@ -2257,7 +2257,6 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
+             if( !bIsEmptyPresObj )
+             {
+                 OUString aStreamURL;
+-                OUString aStr;
+ 
+                 xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL;
+                 xPropSet->getPropertyValue("GraphicURL") >>= sImageURL;
+@@ -2265,7 +2264,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() ) );
+@@ -2282,16 +2281,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;
+-- 
+1.9.0
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 7473492..c44a09f 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -36,7 +36,7 @@ Summary:        Free Software Productivity Suite
 Name:           libreoffice
 Epoch:          1
 Version:        %{libo_version}.2
-Release:        8%{?libo_prerelease}%{?dist}
+Release:        9%{?libo_prerelease}%{?dist}
 License:        (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic and MPLv2.0
 Group:          Applications/Productivity
 URL:            http://www.libreoffice.org/
@@ -304,6 +304,7 @@ Patch44: 0001-Related-fdo-50697-reset-the-cache-timeout-on-GetGrap.patch
 Patch45: 0001-resolve-fdo-77509-memory-corruption-crash-in-Consoli.patch
 Patch46: 0001-rhbz-1071604-don-t-crash-if-slide-layout-configs-are.patch
 Patch47: 0001-Related-rhbz-1071604-don-t-paint-anim.-effect-icon.patch
+Patch48: 0001-various-situations-where-graphic-go-missing-on-save.patch
 
 %define instdir %{_libdir}
 %define baseinstdir %{instdir}/libreoffice
@@ -2267,6 +2268,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
 %endif
 
 %changelog
+* Fri May 23 2014 Caolán McNamara <caolanm at redhat.com> - 1:4.2.4.2-9
+- Resolves: rhbz#1084822 graphics missing after save and reload
+
 * Fri May 09 2014 David Tardon <dtardon at redhat.com> - 1:4.2.4.2-8
 - Resolves: rhbz#1071604 Draw depends on files from libreoffice-impress, crashes
   without them


More information about the scm-commits mailing list