Author: orw
Date: Thu Jun 19 08:42:48 2014
New Revision: 1603757

URL: http://svn.apache.org/r1603757
Log:
124946: only apply new embedded stream name for a graphic, if is already has 
one.
        - needed correction for the fix made for issue 114361

        cherry-picked from trunk


Modified:
    openoffice/branches/AOO410/   (props changed)
    openoffice/branches/AOO410/main/   (props changed)
    openoffice/branches/AOO410/main/sw/inc/ndgrf.hxx
    openoffice/branches/AOO410/main/sw/source/core/graphic/ndgrf.cxx
    openoffice/branches/AOO410/main/sw/source/filter/xml/xmltexte.cxx

Propchange: openoffice/branches/AOO410/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1597102

Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1597102

Modified: openoffice/branches/AOO410/main/sw/inc/ndgrf.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/inc/ndgrf.hxx?rev=1603757&r1=1603756&r2=1603757&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/inc/ndgrf.hxx (original)
+++ openoffice/branches/AOO410/main/sw/inc/ndgrf.hxx Thu Jun 19 08:42:48 2014
@@ -75,7 +75,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwN
 
        void InsertLink( const String& rGrfName, const String& rFltName );
        sal_Bool ImportGraphic( SvStream& rStrm );
-       sal_Bool HasStreamName() const { return maGrfObj.HasUserData(); }
     void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
        void DelStreamName();
        DECL_LINK( SwapGraphic, GraphicObject* );
@@ -177,6 +176,7 @@ public:
     // Entfernen der Grafik, um Speicher freizugeben
     short SwapOut();
 
+    sal_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 String& r )
     {

Modified: openoffice/branches/AOO410/main/sw/source/core/graphic/ndgrf.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/graphic/ndgrf.cxx?rev=1603757&r1=1603756&r2=1603757&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/graphic/ndgrf.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/graphic/ndgrf.cxx Thu Jun 19 
08:42:48 2014
@@ -239,7 +239,7 @@ sal_Bool SwGrfNode::ReRead(
        else if( pGraphic && !rGrfName.Len() )
        {
                // MIB 27.02.2001: Old stream must be deleted before the new 
one is set.
-               if( HasStreamName() )
+               if( HasEmbeddedStreamName() )
                        DelStreamName();
 
                maGrfObj.SetGraphic( *pGraphic );
@@ -249,7 +249,7 @@ sal_Bool SwGrfNode::ReRead(
        else if( pGrfObj && !rGrfName.Len() )
        {
                // MIB 27.02.2001: Old stream must be deleted before the new 
one is set.
-               if( HasStreamName() )
+               if( HasEmbeddedStreamName() )
                        DelStreamName();
 
                maGrfObj = *pGrfObj;
@@ -265,7 +265,7 @@ sal_Bool SwGrfNode::ReRead(
 
        else
        {
-               if( HasStreamName() )
+               if( HasEmbeddedStreamName() )
                        DelStreamName();
 
                // einen neuen Grafik-Link anlegen
@@ -546,21 +546,16 @@ short SwGrfNode::SwapIn( sal_Bool bWaitF
                else
                        nRet = 1;
        }
-       else if( maGrfObj.IsSwappedOut() )
-       {
-               // Die Grafik ist im Storage oder im TempFile drin
-               if( !HasStreamName() )
-                       nRet = (short)maGrfObj.SwapIn();
-               else
-               {
+    else if ( maGrfObj.IsSwappedOut() )
+    {
+        // Die Grafik ist im Storage oder im TempFile drin
+        if ( !HasEmbeddedStreamName() )
+            nRet = (short) maGrfObj.SwapIn();
+        else
+        {
 
-            // --> OD 2005-05-04 #i48434# - usage of new method 
<_GetStreamForEmbedGrf(..)>
             try
             {
-                // --> OD, MAV 2005-08-17 #i53025# - needed correction of new
-                // method <_GetStreamForEmbedGrf(..)>
-//                bool bGraphic(false);
-//                SvStream* pStrm = _GetStreamForEmbedGrf( bGraphic );
                 String aStrmName, aPicStgName;
                 _GetStreamStorageNames( aStrmName, aPicStgName );
                 uno::Reference < embed::XStorage > refPics = 
_GetDocSubstorageOrRoot( aPicStgName );
@@ -571,34 +566,30 @@ short SwGrfNode::SwapIn( sal_Bool bWaitF
                         nRet = 1;
                     delete pStrm;
                 }
-                // <--
             }
             catch ( uno::Exception& )
             {
-                // --> OD 2005-04-25 #i48434#
                 ASSERT( false, "<SwGrfNode::SwapIn(..)> - unhandled 
exception!" );
-                // <--
             }
-            // <--
-               }
+        }
 
-               if( 1 == nRet )
-               {
-                       SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
+        if ( 1 == nRet )
+        {
+            SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
             ModifyNotification( &aMsg, &aMsg );
-               }
-       }
-       else
-               nRet = 1;
-       DBG_ASSERTWARNING( nRet, "Grafik kann nicht eingeswapt werden" );
+        }
+    }
+    else
+        nRet = 1;
+    DBG_ASSERTWARNING( nRet, "Grafik kann nicht eingeswapt werden" );
 
-       if( nRet )
-       {
-               if( !nGrfSize.Width() && !nGrfSize.Height() )
-                       SetTwipSize( ::GetGraphicSizeTwip( 
maGrfObj.GetGraphic(), 0 ) );
-       }
-       bInSwapIn = sal_False;
-       return nRet;
+    if ( nRet )
+    {
+        if ( !nGrfSize.Width() && !nGrfSize.Height() )
+            SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
+    }
+    bInSwapIn = sal_False;
+    return nRet;
 }
 
 
@@ -614,7 +605,7 @@ short SwGrfNode::SwapOut()
                        // Die Grafik wird in eine TempFile geschrieben, wenn
                        // sie frisch eingefuegt war, d.h. wenn es noch keinen
                        // Streamnamen im Storage gibt.
-                       if( !HasStreamName() )
+                       if( !HasEmbeddedStreamName() )
                                if( !maGrfObj.SwapOut() )
                                        return 0;
                }
@@ -665,7 +656,7 @@ sal_Bool SwGrfNode::SavePersistentData()
        }
 
        // Erst mal reinswappen, falls sie im Storage ist
-       if( HasStreamName() && !SwapIn() )
+       if( HasEmbeddedStreamName() && !SwapIn() )
                return sal_False;
 
     // --> OD 2005-04-19 #i44367#
@@ -866,7 +857,7 @@ void SwGrfNode::ScaleImageMap()
 
 void SwGrfNode::DelStreamName()
 {
-       if( HasStreamName() )
+       if( HasEmbeddedStreamName() )
        {
                // Dann die Grafik im Storage loeschen
         uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
@@ -1026,7 +1017,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc*
 
        Graphic aTmpGrf;
     SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
-       if( !pLink && HasStreamName() )
+       if( !pLink && HasEmbeddedStreamName() )
        {
         // --> OD 2005-05-04 #i48434# - usage of new method 
<_GetStreamForEmbedGrf(..)>
         try
@@ -1114,7 +1105,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, Graph
        {
                pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
 
-               if( HasStreamName() )
+               if( HasEmbeddedStreamName() )
                {
             // --> OD 2005-05-04 #i48434# - usage of new method 
<_GetStreamForEmbedGrf(..)>
             try

Modified: openoffice/branches/AOO410/main/sw/source/filter/xml/xmltexte.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/xml/xmltexte.cxx?rev=1603757&r1=1603756&r2=1603757&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/xml/xmltexte.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/xml/xmltexte.cxx Thu Jun 
19 08:42:48 2014
@@ -211,31 +211,33 @@ SwXMLTextParagraphExport::~SwXMLTextPara
 }
 
 void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
-       const Reference < XPropertySet >& rPropSet,
-       OUString& rURL) const
-{
-       if( !rURL.getLength() )
-               return;
+    const Reference< XPropertySet >& rPropSet,
+    OUString& rURL ) const
+    {
+    if ( !rURL.getLength() )
+        return;
 
-       SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
-       if( !pGrfNd->IsGrfLink() )
-       {
-               String aNewURL( 
RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.Package:") );
-               aNewURL += String(rURL);
-               pGrfNd->ApplyNewEmbeddedStreamName( aNewURL );
+    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() )
+        {
+            String aNewURL( RTL_CONSTASCII_STRINGPARAM( 
"vnd.sun.star.Package:" ) );
+            aNewURL += String( rURL );
+            pGrfNd->ApplyNewEmbeddedStreamName( aNewURL );
+        }
 
         // #i15411# save-as will swap all graphics in; we need to swap
         // them out again, to prevent excessive memory use
         pGrfNd->SwapOut();
-       }
+    }
 }
-/*
-static void lcl_addParam ( SvXMLExport &rExport, const SvCommand &rCommand )
-{
-    rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rCommand.GetCommand() 
);
-    rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, 
rCommand.GetArgument() );
-    SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_PARAM, 
sal_False, sal_True );
-}*/
+
 
 static void lcl_addURL ( SvXMLExport &rExport, const String &rURL,
                                                 sal_Bool bToRel = sal_True )


Reply via email to