[Libreoffice-commits] core.git: sw/source

Armin Le Grand alg at apache.org
Tue Feb 11 01:25:18 PST 2014


 sw/source/core/graphic/ndgrf.cxx |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

New commits:
commit 38ea39b517b218573b8d1430d7b06280bcfef0fb
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Feb 10 22:24:18 2014 +0000

    Resolves: #i15508# keep the original file and format AFAP...
    
    when breaking links to graphic contents in Writer
    
    (cherry picked from commit a9325263271883fb147351d287c817ea7984fbe9)
    
    Conflicts:
    	sw/source/core/graphic/ndgrf.cxx
    
    Change-Id: I86e2b80b95f4e26a734f56d060f97e6430ae56b8

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 8d2cb3e..d25123f 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -724,15 +724,53 @@ void SwGrfNode::ReleaseLink()
 {
     if( refLink.Is() )
     {
+        // #i15508# remember some stuff from the linked graphic
+        const OUString aFileName(maGrfObj.GetLink());
+        const Graphic aLocalGraphic(maGrfObj.GetGraphic());
+        const bool bHasOriginalData(aLocalGraphic.IsLink());
+
         {
             bInSwapIn = sal_True;
             SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
             pLink->SwapIn( sal_True, sal_True );
             bInSwapIn = sal_False;
         }
+
         getIDocumentLinksAdministration()->GetLinkManager().Remove( refLink );
         refLink.Clear();
         maGrfObj.SetLink();
+
+        // #i15508# added extra processing after getting rid of the link. Use whatever is
+        // known from the formally linked graphic to get to a state as close to a directly
+        // unlinked insterted graphic as possible. Goal is to have a valid GfxLink at the
+        // ImplGraphic (see there) that holds temporary data to the original data and type
+        // information about the original data. Only when this is given will
+        // SvXMLGraphicHelper::ImplInsertGraphicURL which is used at export use that type
+        // and use the original graphic at export for the ODF, without evtl. recoding
+        // of trhe bitmap graphic data to something without loss (e.g. PNG) but bigger
+        if(bHasOriginalData)
+        {
+            // #i15508# if we have the original data at the Graphic, let it survive
+            // by using that Graphic again, this time at a GraphicObject without link.
+            // This happens e.g. when inserting a linked graphic and breaking the link
+            maGrfObj.SetGraphic(aLocalGraphic);
+        }
+        else if(!aFileName.isEmpty())
+        {
+            // #i15508# we have no original data, but a file name. This happens e.g.
+            // when inserting a linked graphic and save, reload document. Try to access
+            // that data from the original file; if this works, use it. Else use the
+            // data we have (but without knowing the original format)
+            int nRes = GRFILTER_OK;
+            GraphicFilter& rFlt = GraphicFilter::GetGraphicFilter();
+            Graphic aNew;
+            nRes = GraphicFilter::LoadGraphic( aFileName, OUString(), aNew, &rFlt);
+
+            if(GRFILTER_OK == nRes)
+            {
+                maGrfObj.SetGraphic(aNew);
+            }
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list