[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - svx/source sw/inc sw/source

Oliver-Rainer Wittmann orw at apache.org
Fri May 23 09:07:34 PDT 2014


 svx/source/svdraw/svdograf.cxx    |    8 +++++---
 sw/inc/ndgrf.hxx                  |    2 +-
 sw/source/core/graphic/ndgrf.cxx  |   37 ++++++++++++++-----------------------
 sw/source/filter/xml/xmltexte.cxx |   32 +++++++++++++++++---------------
 4 files changed, 37 insertions(+), 42 deletions(-)

New commits:
commit d6af1b601bb8fe2569d17e01505f67e1becc9366
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri May 23 14:50:23 2014 +0000

    124966: 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

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index fc08d4b..b70f12f 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1537,9 +1537,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 = sal_True;
-                        sal_Bool bCreateNativeLink = sal_False;
+                        const com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
+                        const sal_Bool bAllowPartialStreamRead = sal_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 = sal_True;
                         (*pFilterData)[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "PreviewSizeHint" ) );
                         (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
                         (*pFilterData)[ 1 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "AllowPartialStreamRead" ) );
commit 23a4bd91ceb89e5e0a2413f80fc987db106a0bc9
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri May 23 14:28:40 2014 +0000

    124946: only apply new embedded stream name for a graphic, if is already has one.
    
    - needed correction for the fix made for issue 114361

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 6d59466..c40eb15 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -75,7 +75,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
 
     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 )
     {
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index e9c6348..6c42713 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -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 bWaitForData )
         else
             nRet = 1;
     }
-    else if( maGrfObj.IsSwappedOut() )
+    else if ( maGrfObj.IsSwappedOut() )
     {
         // Die Grafik ist im Storage oder im TempFile drin
-        if( !HasStreamName() )
-            nRet = (short)maGrfObj.SwapIn();
+        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,18 +566,14 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
                         nRet = 1;
                     delete pStrm;
                 }
-                // <--
             }
             catch ( uno::Exception& )
             {
-                // --> OD 2005-04-25 #i48434#
                 ASSERT( false, "<SwGrfNode::SwapIn(..)> - unhandled exception!" );
-                // <--
             }
-            // <--
         }
 
-        if( 1 == nRet )
+        if ( 1 == nRet )
         {
             SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
             ModifyNotification( &aMsg, &aMsg );
@@ -592,9 +583,9 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
         nRet = 1;
     DBG_ASSERTWARNING( nRet, "Grafik kann nicht eingeswapt werden" );
 
-    if( nRet )
+    if ( nRet )
     {
-        if( !nGrfSize.Width() && !nGrfSize.Height() )
+        if ( !nGrfSize.Width() && !nGrfSize.Height() )
             SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
     }
     bInSwapIn = sal_False;
@@ -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* pDoc, const SwNodeIndex& rIdx ) const
 
     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, GraphicObject*, pGrfObj )
     {
         pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
 
-        if( HasStreamName() )
+        if( HasEmbeddedStreamName() )
         {
             // --> OD 2005-05-04 #i48434# - usage of new method <_GetStreamForEmbedGrf(..)>
             try
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index 5bf90e5..edc81d7 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -211,31 +211,33 @@ SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
 }
 
 void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
-    const Reference < XPropertySet >& rPropSet,
-    OUString& rURL) const
-{
-    if( !rURL.getLength() )
+    const Reference< XPropertySet >& rPropSet,
+    OUString& rURL ) const
+    {
+    if ( !rURL.getLength() )
         return;
 
     SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
-    if( !pGrfNd->IsGrfLink() )
+    if ( !pGrfNd->IsGrfLink() )
     {
-        String aNewURL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.Package:") );
-        aNewURL += String(rURL);
-        pGrfNd->ApplyNewEmbeddedStreamName( aNewURL );
+        // 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 )


More information about the Libreoffice-commits mailing list