[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 3 commits - sw/inc sw/source vcl/win

Oliver-Rainer Wittmann orw at apache.org
Fri Jun 6 07:07:51 PDT 2014


 sw/inc/ndgrf.hxx                   |    8 
 sw/source/core/doc/doc.cxx         |   50 +-
 sw/source/core/docnode/ndnotxt.cxx |    1 
 sw/source/core/graphic/ndgrf.cxx   |  629 ++++++++++++++++++-------------------
 sw/source/filter/rtf/rtffly.cxx    |    2 
 vcl/win/source/gdi/salbmp.cxx      |   38 +-
 6 files changed, 360 insertions(+), 368 deletions(-)

New commits:
commit 7dcef20c6ec732ad36a88d89a4cc1a7606939d9d
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri Jun 6 13:31:32 2014 +0000

    124999: As Writer graphics are no longer painted via the graphic manager - see <SwNoTxtFrm::PaintPicture(..)> - it is needed to swap out the Writer graphics automatically after a certain amount of time. --> 5000ms

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 342ae0b..bf789f1 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -62,6 +62,11 @@
 using namespace com::sun::star;
 
 
+// As Writer graphics are no longer painted via the graphic manager - see <SwNoTxtFrm::PaintPicture(..)> -
+// it is needed to swap out the Writer graphics automatically after a certain amount of time.
+// --> 5000ms
+#define TIMETOSWAPOUTGRAPHICAUTOMATICALLY 5000
+
 // --------------------
 // SwGrfNode
 // --------------------
@@ -78,7 +83,7 @@ SwGrfNode::SwGrfNode(
           mbLinkedInputStreamReady( false ),
           mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY );
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False;
 
     bGrafikArrived = sal_True;
@@ -97,7 +102,7 @@ SwGrfNode::SwGrfNode(
           mbIsStreamReadOnly( sal_False )
 {
     maGrfObj = rGrfObj;
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY );
     if ( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() )
         maGrfObj.SetSwapState();
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False;
@@ -120,7 +125,7 @@ SwGrfNode::SwGrfNode(
           mbLinkedInputStreamReady( false ),
           mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY );
 
     Graphic aGrf;
     aGrf.SetDefaultType();
commit 4dbdc0ce931d7686583a49e68f8df09827357beb
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri Jun 6 12:14:07 2014 +0000

    124999: - call <SwGrfNode::onGraphicChanged()> only when <Graphic> instance has been set, too
    
    - <SwGrfNode::onGraphicChanged()> - assure that graphic is swapped out in case its swap in has been triggered by this method.

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index c40eb15..b191cf3 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -121,6 +121,10 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
                                                 const String& aStgName ) const;
 
+    /// allow reaction on change of content of GraphicObject, so always call
+    /// when GraphicObject content changes
+    void onGraphicChanged();
+
 public:
     virtual ~SwGrfNode();
     const Graphic&          GetGrf() const      { return maGrfObj.GetGraphic(); }
@@ -136,10 +140,6 @@ public:
     void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); }
     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
 
-    /// allow reaction on change of content of GraphicObject, so always call
-    /// when GraphicObject content changes
-    void onGraphicChanged();
-
     virtual Size GetTwipSize() const;
 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     void SetTwipSize( const Size& rSz );
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index a41a6d0..af9a28f 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -952,38 +952,42 @@ SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
     return pFmt;
 }
 
-SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg,
-                            const String& rGrfName,
-                            const String& rFltName,
-                            const Graphic* pGraphic,
-                            const SfxItemSet* pFlyAttrSet,
-                            const SfxItemSet* pGrfAttrSet,
-                            SwFrmFmt* pFrmFmt )
+
+SwFlyFrmFmt* SwDoc::Insert(
+    const SwPaM &rRg,
+    const String& rGrfName,
+    const String& rFltName,
+    const Graphic* pGraphic,
+    const SfxItemSet* pFlyAttrSet,
+    const SfxItemSet* pGrfAttrSet,
+    SwFrmFmt* pFrmFmt )
 {
-    if( !pFrmFmt )
+    if ( !pFrmFmt )
         pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
     SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
-                            SwNodeIndex( GetNodes().GetEndOfAutotext() ),
-                            rGrfName, rFltName, pGraphic,
-                            pDfltGrfFmtColl );
-    SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
-                            pFlyAttrSet, pGrfAttrSet, pFrmFmt );
-    pSwGrfNode->onGraphicChanged();
+        SwNodeIndex( GetNodes().GetEndOfAutotext() ),
+        rGrfName, rFltName, pGraphic,
+        pDfltGrfFmtColl );
+    SwFlyFrmFmt* pSwFlyFrmFmt =
+        _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode, pFlyAttrSet, pGrfAttrSet, pFrmFmt );
     return pSwFlyFrmFmt;
 }
-SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj,
-                            const SfxItemSet* pFlyAttrSet,
-                            const SfxItemSet* pGrfAttrSet,
-                            SwFrmFmt* pFrmFmt )
+
+
+SwFlyFrmFmt* SwDoc::Insert(
+    const SwPaM &rRg,
+    const GraphicObject& rGrfObj,
+    const SfxItemSet* pFlyAttrSet,
+    const SfxItemSet* pGrfAttrSet,
+    SwFrmFmt* pFrmFmt )
 {
-    if( !pFrmFmt )
+    if ( !pFrmFmt )
         pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
     SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
-                            SwNodeIndex( GetNodes().GetEndOfAutotext() ),
-                            rGrfObj, pDfltGrfFmtColl );
+        SwNodeIndex( GetNodes().GetEndOfAutotext() ),
+        rGrfObj, pDfltGrfFmtColl );
     SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
-                            pFlyAttrSet, pGrfAttrSet, pFrmFmt );
-    pSwGrfNode->onGraphicChanged();
+        pFlyAttrSet, pGrfAttrSet, pFrmFmt );
     return pSwFlyFrmFmt;
 }
 
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index aaf3785..424d3aa 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -282,7 +282,6 @@ Graphic SwNoTxtNode::GetGraphic() const
     return aRet;
 }
 
-// --> OD 2009-07-14 #i73249#
 void SwNoTxtNode::SetTitle( const String& rTitle, bool bBroadcast )
 {
     // Title attribute of <SdrObject> replaces own AlternateText attribute
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 6c42713..342ae0b 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -19,8 +19,6 @@
  *
  *************************************************************/
 
-
-
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sw.hxx"
 #include <hintids.hxx>
@@ -61,9 +59,9 @@
 #include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
 
-
 using namespace com::sun::star;
 
+
 // --------------------
 // SwGrfNode
 // --------------------
@@ -109,44 +107,47 @@ SwGrfNode::SwGrfNode(
 // Konstruktor fuer den SW/G-Reader. Dieser ctor wird verwendet,
 // wenn eine gelinkte Grafik gelesen wird. Sie liest diese NICHT ein.
 
-
-SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
-                      const String& rGrfName, const String& rFltName,
-                      SwGrfFmtColl *pGrfColl,
-                      SwAttrSet* pAutoAttr ) :
-    SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
-    maGrfObj(),
-    mpReplacementGraphic(0),
-    // --> OD 2007-01-23 #i73788#
-    mbLinkedInputStreamReady( false ),
-    mbIsStreamReadOnly( sal_False )
-    // <--
+SwGrfNode::SwGrfNode(
+    const SwNodeIndex & rWhere,
+    const String& rGrfName,
+    const String& rFltName,
+    SwGrfFmtColl *pGrfColl,
+    SwAttrSet* pAutoAttr )
+        :
+          SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
+          maGrfObj(),
+          mpReplacementGraphic( 0 ),
+          mbLinkedInputStreamReady( false ),
+          mbIsStreamReadOnly( sal_False )
 {
     maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
 
-    Graphic aGrf; aGrf.SetDefaultType();
+    Graphic aGrf;
+    aGrf.SetDefaultType();
     maGrfObj.SetGraphic( aGrf, rGrfName );
 
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf =
-        bFrameInPaint = bScaleImageMap = sal_False;
+            bFrameInPaint = bScaleImageMap = sal_False;
     bGrafikArrived = sal_True;
 
     InsertLink( rGrfName, rFltName );
-    if( IsLinkedFile() )
+    if ( IsLinkedFile() )
     {
         INetURLObject aUrl( rGrfName );
-        if( INET_PROT_FILE == aUrl.GetProtocol() &&
-            FStatHelper::IsDocument( aUrl.GetMainURL( INetURLObject::NO_DECODE ) ))
+        if ( INET_PROT_FILE == aUrl.GetProtocol() &&
+             FStatHelper::IsDocument( aUrl.GetMainURL( INetURLObject::NO_DECODE ) ) )
         {
             // File vorhanden, Verbindung herstellen ohne ein Update
-            ((SwBaseLink*)&refLink)->Connect();
+            ( (SwBaseLink*) &refLink )->Connect();
         }
     }
 }
 
 sal_Bool SwGrfNode::ReRead(
-    const String& rGrfName, const String& rFltName,
-    const Graphic* pGraphic, const GraphicObject* pGrfObj,
+    const String& rGrfName,
+    const String& rFltName,
+    const Graphic* pGraphic,
+    const GraphicObject* pGrfObj,
     sal_Bool bNewGrf )
 {
     sal_Bool bReadGrf = sal_False, bSetTwipSize = sal_True;
@@ -154,22 +155,22 @@ sal_Bool SwGrfNode::ReRead(
     mpReplacementGraphic = 0;
 
     ASSERT( pGraphic || pGrfObj || rGrfName.Len(),
-            "GraphicNode without a name, Graphic or GraphicObject" );
+        "GraphicNode without a name, Graphic or GraphicObject" );
 
     // ReadRead mit Namen
-    if( refLink.Is() )
+    if ( refLink.Is() )
     {
         ASSERT( !bInSwapIn, "ReRead: stehe noch im SwapIn" );
 
-        if( rGrfName.Len() )
+        if ( rGrfName.Len() )
         {
             // Besonderheit: steht im FltNamen DDE, handelt es sich um eine
             //                  DDE-gelinkte Grafik
             String sCmd( rGrfName );
-            if( rFltName.Len() )
+            if ( rFltName.Len() )
             {
                 sal_uInt16 nNewType;
-                if( rFltName.EqualsAscii( "DDE" ))
+                if ( rFltName.EqualsAscii( "DDE" ) )
                     nNewType = OBJECT_CLIENT_DDE;
                 else
                 {
@@ -177,10 +178,10 @@ sal_Bool SwGrfNode::ReRead(
                     nNewType = OBJECT_CLIENT_GRF;
                 }
 
-                if( nNewType != refLink->GetObjType() )
+                if ( nNewType != refLink->GetObjType() )
                 {
                     refLink->Disconnect();
-                    ((SwBaseLink*)&refLink)->SetObjType( nNewType );
+                    ( (SwBaseLink*) &refLink )->SetObjType( nNewType );
                 }
             }
 
@@ -192,16 +193,16 @@ sal_Bool SwGrfNode::ReRead(
             refLink.Clear();
         }
 
-        if( pGraphic )
+        if ( pGraphic )
         {
             maGrfObj.SetGraphic( *pGraphic, rGrfName );
             onGraphicChanged();
             bReadGrf = sal_True;
         }
-        else if( pGrfObj )
+        else if ( pGrfObj )
         {
             maGrfObj = *pGrfObj;
-            if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
+            if ( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
                 maGrfObj.SetSwapState();
             maGrfObj.SetLink( rGrfName );
             onGraphicChanged();
@@ -212,112 +213,100 @@ sal_Bool SwGrfNode::ReRead(
             // MIB 25.02.97: Daten der alten Grafik zuruecksetzen, damit
             // die korrekte Ersatz-Darstellung erscheint, wenn die
             // der neue Link nicht geladen werden konnte.
-            Graphic aGrf; aGrf.SetDefaultType();
+            Graphic aGrf;
+            aGrf.SetDefaultType();
             maGrfObj.SetGraphic( aGrf, rGrfName );
 
-            if( refLink.Is() )
+            if ( refLink.Is() )
             {
-                if( getLayoutFrm( GetDoc()->GetCurrentLayout() ) )
+                if ( getLayoutFrm( GetDoc()->GetCurrentLayout() ) )
                 {
                     SwMsgPoolItem aMsgHint( RES_GRF_REREAD_AND_INCACHE );
                     ModifyNotification( &aMsgHint, &aMsgHint );
                 }
-                // --> OD 2006-11-03 #i59688#
-                // do not load linked graphic, if it isn't a new linked graphic.
-//                else {
                 else if ( bNewGrf )
-                // <--
                 {
                     //TODO refLink->setInputStream(getInputStream());
-                    ((SwBaseLink*)&refLink)->SwapIn();
+                    ( (SwBaseLink*) &refLink )->SwapIn();
                 }
             }
             onGraphicChanged();
             bSetTwipSize = sal_False;
         }
     }
-    else if( pGraphic && !rGrfName.Len() )
+    else if ( pGraphic && !rGrfName.Len() )
     {
         // MIB 27.02.2001: Old stream must be deleted before the new one is set.
-        if( HasEmbeddedStreamName() )
+        if ( HasEmbeddedStreamName() )
             DelStreamName();
 
         maGrfObj.SetGraphic( *pGraphic );
         onGraphicChanged();
         bReadGrf = sal_True;
     }
-    else if( pGrfObj && !rGrfName.Len() )
+    else if ( pGrfObj && !rGrfName.Len() )
     {
         // MIB 27.02.2001: Old stream must be deleted before the new one is set.
-        if( HasEmbeddedStreamName() )
+        if ( HasEmbeddedStreamName() )
             DelStreamName();
 
         maGrfObj = *pGrfObj;
         onGraphicChanged();
-        if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
+        if ( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
             maGrfObj.SetSwapState();
         bReadGrf = sal_True;
     }
-        // Import einer Grafik:
-        // Ist die Grafik bereits geladen?
-    else if( !bNewGrf && GRAPHIC_NONE != maGrfObj.GetType() )
+    else if ( !bNewGrf && GRAPHIC_NONE != maGrfObj.GetType() )
         return sal_True;
 
     else
     {
-        if( HasEmbeddedStreamName() )
+        if ( HasEmbeddedStreamName() )
             DelStreamName();
 
         // einen neuen Grafik-Link anlegen
         InsertLink( rGrfName, rFltName );
 
-        if( GetNodes().IsDocNodes() )
+        if ( GetNodes().IsDocNodes() )
         {
-            if( pGraphic )
+            if ( pGraphic )
             {
                 maGrfObj.SetGraphic( *pGraphic, rGrfName );
                 onGraphicChanged();
                 bReadGrf = sal_True;
                 // Verbindung herstellen ohne ein Update; Grafik haben wir!
-                ((SwBaseLink*)&refLink)->Connect();
+                ( (SwBaseLink*) &refLink )->Connect();
             }
-            else if( pGrfObj )
+            else if ( pGrfObj )
             {
                 maGrfObj = *pGrfObj;
                 maGrfObj.SetLink( rGrfName );
                 onGraphicChanged();
                 bReadGrf = sal_True;
                 // Verbindung herstellen ohne ein Update; Grafik haben wir!
-                ((SwBaseLink*)&refLink)->Connect();
+                ( (SwBaseLink*) &refLink )->Connect();
             }
             else
             {
-                // MIB 25.02.97: Daten der alten Grafik zuruecksetzen, damit
-                // die korrekte Ersatz-Darstellung erscheint, wenn die
-                // der neue Kink nicht geladen werden konnte.
-                Graphic aGrf; aGrf.SetDefaultType();
+                Graphic aGrf;
+                aGrf.SetDefaultType();
                 maGrfObj.SetGraphic( aGrf, rGrfName );
                 onGraphicChanged();
-                // --> OD 2006-11-03 #i59688#
-                // do not load linked graphic, if it isn't a new linked graphic.
-//                //TODO refLink->setInputStream(getInputStream());
-//                ((SwBaseLink*)&refLink)->SwapIn();
                 if ( bNewGrf )
                 {
-                    ((SwBaseLink*)&refLink)->SwapIn();
+                    ( (SwBaseLink*) &refLink )->SwapIn();
                 }
-                // <--
             }
         }
     }
 
     // Bug 39281: Size nicht sofort loeschen - Events auf ImageMaps
     //            sollten nicht beim Austauschen nicht ins "leere greifen"
-    if( bSetTwipSize )
+    if ( bSetTwipSize )
         SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
 
     // erzeuge noch einen Update auf die Frames
-    if( bReadGrf && bNewGrf )
+    if ( bReadGrf && bNewGrf )
     {
         SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
         ModifyNotification( &aMsgHint, &aMsgHint );
@@ -326,18 +315,15 @@ sal_Bool SwGrfNode::ReRead(
     return bReadGrf;
 }
 
-
 SwGrfNode::~SwGrfNode()
 {
     delete mpReplacementGraphic;
     mpReplacementGraphic = 0;
 
-    // --> OD 2007-03-30 #i73788#
     mpThreadConsumer.reset();
-    // <--
 
     SwDoc* pDoc = GetDoc();
-    if( refLink.Is() )
+    if ( refLink.Is() )
     {
         ASSERT( !bInSwapIn, "DTOR: stehe noch im SwapIn" );
         pDoc->GetLinkManager().Remove( refLink );
@@ -345,7 +331,7 @@ SwGrfNode::~SwGrfNode()
     }
     else
     {
-        // --> OD 2005-01-19 #i40014# - A graphic node, which are in linked
+        // #i40014# - A graphic node, which are in linked
         // section, whose link is another section is the document, doesn't
         // have to remove the stream from the storage.
         // Because it's hard to detect this case here and it would only fix
@@ -356,11 +342,10 @@ SwGrfNode::~SwGrfNode()
         // inside one document have to be implemented.
 //        if( !pDoc->IsInDtor() && HasStreamName() )
 //          DelStreamName();
-        // <--
     }
     //#39289# Die Frames muessen hier bereits geloescht weil der DTor der
     //Frms die Grafik noch fuer StopAnimation braucht.
-    if( GetDepends() )
+    if ( GetDepends() )
         DelFrms();
 }
 
@@ -370,29 +355,31 @@ void SwGrfNode::onGraphicChanged()
     // try to access SwFlyFrmFmt; since title/desc/name are set there, there is no
     // use to continue if it is not yet set. If not yet set, call onGraphicChanged()
     // when it is set.
-    SwFlyFrmFmt* pFlyFmt = dynamic_cast< SwFlyFrmFmt* >(GetFlyFmt());
+    SwFlyFrmFmt* pFlyFmt = dynamic_cast< SwFlyFrmFmt* >( GetFlyFmt() );
 
-    if(pFlyFmt)
+    if ( pFlyFmt != NULL )
     {
+        const bool bWasSwappedOut = ( GetGrfObj().IsSwappedOut() == sal_True );
+
         String aName;
         String aTitle;
         String aDesc;
         const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
 
-        if(rSvgDataPtr.get())
+        if ( rSvgDataPtr.get() )
         {
-            const drawinglayer::primitive2d::Primitive2DSequence aSequence(rSvgDataPtr->getPrimitive2DSequence());
+            const drawinglayer::primitive2d::Primitive2DSequence aSequence( rSvgDataPtr->getPrimitive2DSequence() );
 
-            if(aSequence.hasElements())
+            if ( aSequence.hasElements() )
             {
                 drawinglayer::geometry::ViewInformation2D aViewInformation2D;
-                drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D);
+                drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor( aViewInformation2D );
 
-                aProcessor.process(aSequence);
+                aProcessor.process( aSequence );
 
                 const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
 
-                if(pResult)
+                if ( pResult )
                 {
                     aName = pResult->getName();
                     aTitle = pResult->getTitle();
@@ -401,95 +388,99 @@ void SwGrfNode::onGraphicChanged()
             }
         }
 
-        // do not use this currently; it seems that this name has to be unique in
-        // the writer model and is already set to some default
-        //if(aName.Len() && pFlyFmt)
-        //{
-        //    pFlyFmt->SetName(aName);
-        //}
+        if ( aTitle.Len() > 0 )
+        {
+            SetTitle( aTitle );
+        }
+        else if ( aName.Len() > 0 )
+        {
+            SetTitle( aName );
+        }
 
-        if(aTitle.Len())
+        if ( aDesc.Len() > 0 )
         {
-            SetTitle(aTitle);
+            SetDescription( aDesc );
         }
 
-        if(aDesc.Len())
+        if ( bWasSwappedOut )
         {
-            SetDescription(aDesc);
+            SwapOut();
         }
     }
 }
 
-void SwGrfNode::SetGraphic(const Graphic& rGraphic, const String& rLink)
+void SwGrfNode::SetGraphic(
+    const Graphic& rGraphic,
+    const String& rLink )
 {
-    maGrfObj.SetGraphic(rGraphic, rLink);
+    maGrfObj.SetGraphic( rGraphic, rLink );
     onGraphicChanged();
 }
 
 const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
 {
-    if(!mpReplacementGraphic)
+    if ( !mpReplacementGraphic )
     {
         const SvgDataPtr& rSvgDataPtr = GetGrfObj().GetGraphic().getSvgData();
 
-        if(rSvgDataPtr.get())
+        if ( rSvgDataPtr.get() )
         {
-            const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement());
+            const_cast< SwGrfNode* >( this )->mpReplacementGraphic = new GraphicObject( rSvgDataPtr->getReplacement() );
         }
     }
 
     return mpReplacementGraphic;
 }
 
-SwCntntNode *SwGrfNode::SplitCntntNode( const SwPosition & )
+SwCntntNode *SwGrfNode::SplitCntntNode(
+    const SwPosition & )
 {
     return this;
 }
 
-
-SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere,
-                                const String& rGrfName,
-                                const String& rFltName,
-                                const Graphic* pGraphic,
-                                SwGrfFmtColl* pGrfColl,
-                                SwAttrSet* pAutoAttr,
-                                sal_Bool bDelayed )
+SwGrfNode * SwNodes::MakeGrfNode(
+    const SwNodeIndex & rWhere,
+    const String& rGrfName,
+    const String& rFltName,
+    const Graphic* pGraphic,
+    SwGrfFmtColl* pGrfColl,
+    SwAttrSet* pAutoAttr,
+    sal_Bool bDelayed )
 {
     ASSERT( pGrfColl, "MakeGrfNode: Formatpointer ist 0." );
     SwGrfNode *pNode;
     // Delayed erzeugen nur aus dem SW/G-Reader
-    if( bDelayed )
+    if ( bDelayed )
         pNode = new SwGrfNode( rWhere, rGrfName,
-                                rFltName, pGrfColl, pAutoAttr );
+            rFltName, pGrfColl, pAutoAttr );
     else
         pNode = new SwGrfNode( rWhere, rGrfName,
-                                rFltName, pGraphic, pGrfColl, pAutoAttr );
+            rFltName, pGraphic, pGrfColl, pAutoAttr );
     return pNode;
 }
 
-SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere,
-                                const GraphicObject& rGrfObj,
-                                SwGrfFmtColl* pGrfColl,
-                                SwAttrSet* pAutoAttr )
+SwGrfNode * SwNodes::MakeGrfNode(
+    const SwNodeIndex & rWhere,
+    const GraphicObject& rGrfObj,
+    SwGrfFmtColl* pGrfColl,
+    SwAttrSet* pAutoAttr )
 {
     ASSERT( pGrfColl, "MakeGrfNode: Formatpointer ist 0." );
     return new SwGrfNode( rWhere, rGrfObj, pGrfColl, pAutoAttr );
 }
 
-
 Size SwGrfNode::GetTwipSize() const
 {
     return nGrfSize;
 }
 
-
-
-sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
+sal_Bool SwGrfNode::ImportGraphic(
+    SvStream& rStrm )
 {
     Graphic aGraphic;
-    const String aURL(maGrfObj.GetUserData());
+    const String aURL( maGrfObj.GetUserData() );
 
-    if(!GraphicFilter::GetGraphicFilter()->ImportGraphic(aGraphic, aURL, rStrm))
+    if ( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, aURL, rStrm ) )
     {
         delete mpReplacementGraphic;
         mpReplacementGraphic = 0;
@@ -508,25 +499,26 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
 //  0 : nicht geladen
 //  1 : Einlesen erfolgreich
 
-short SwGrfNode::SwapIn( sal_Bool bWaitForData )
+short SwGrfNode::SwapIn(
+    sal_Bool bWaitForData )
 {
-    if( bInSwapIn )                 // nicht rekuriv!!
+    if ( bInSwapIn )                    // nicht rekuriv!!
         return !maGrfObj.IsSwappedOut();
 
     short nRet = 0;
     bInSwapIn = sal_True;
-    SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
+    SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
 
-    if( pLink )
+    if ( pLink )
     {
-        if( GRAPHIC_NONE == maGrfObj.GetType() ||
-            GRAPHIC_DEFAULT == maGrfObj.GetType() )
+        if ( GRAPHIC_NONE == maGrfObj.GetType() ||
+             GRAPHIC_DEFAULT == maGrfObj.GetType() )
         {
             // noch nicht geladener Link
             //TODO pLink->setInputStream(getInputStream());
-            if( pLink->SwapIn( bWaitForData ) )
+            if ( pLink->SwapIn( bWaitForData ) )
                 nRet = -1;
-            else if( GRAPHIC_DEFAULT == maGrfObj.GetType() )
+            else if ( GRAPHIC_DEFAULT == maGrfObj.GetType() )
             {
                 // keine default Bitmap mehr, also neu Painten!
                 delete mpReplacementGraphic;
@@ -538,7 +530,8 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
                 ModifyNotification( &aMsgHint, &aMsgHint );
             }
         }
-        else if( maGrfObj.IsSwappedOut() ) {
+        else if ( maGrfObj.IsSwappedOut() )
+        {
             // nachzuladender Link
             //TODO pLink->setInputStream(getInputStream());
             nRet = pLink->SwapIn( bWaitForData ) ? 1 : 0;
@@ -558,7 +551,7 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
             {
                 String aStrmName, aPicStgName;
                 _GetStreamStorageNames( aStrmName, aPicStgName );
-                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
+                uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
                 SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
                 if ( pStrm )
                 {
@@ -592,21 +585,21 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
     return nRet;
 }
 
-
 short SwGrfNode::SwapOut()
 {
-    if( maGrfObj.GetType() != GRAPHIC_DEFAULT &&
-        maGrfObj.GetType() != GRAPHIC_NONE &&
-        !maGrfObj.IsSwappedOut() && !bInSwapIn )
+    if ( maGrfObj.GetType() != GRAPHIC_DEFAULT
+         && maGrfObj.GetType() != GRAPHIC_NONE
+         && !maGrfObj.IsSwappedOut()
+         && !bInSwapIn )
     {
-        if( !refLink.Is() )
+        if ( !refLink.Is() )
         {
             // Das Swapping brauchen wir nur fuer Embedded Pictures
             // Die Grafik wird in eine TempFile geschrieben, wenn
             // sie frisch eingefuegt war, d.h. wenn es noch keinen
             // Streamnamen im Storage gibt.
-            if( !HasEmbeddedStreamName() )
-                if( !maGrfObj.SwapOut() )
+            if ( !HasEmbeddedStreamName() )
+                if ( !maGrfObj.SwapOut() )
                     return 0;
         }
         // Geschriebene Grafiken oder Links werden jetzt weggeschmissen
@@ -615,26 +608,27 @@ short SwGrfNode::SwapOut()
     return 1;
 }
 
-
-sal_Bool SwGrfNode::GetFileFilterNms( String* pFileNm, String* pFilterNm ) const
-{
+sal_Bool SwGrfNode::GetFileFilterNms(
+    String* pFileNm,
+    String* pFilterNm ) const
+    {
     sal_Bool bRet = sal_False;
-    if( refLink.Is() && refLink->GetLinkManager() )
+    if ( refLink.Is() && refLink->GetLinkManager() )
     {
         sal_uInt16 nType = refLink->GetObjType();
-        if( OBJECT_CLIENT_GRF == nType )
+        if ( OBJECT_CLIENT_GRF == nType )
             bRet = refLink->GetLinkManager()->GetDisplayNames(
-                    refLink, 0, pFileNm, 0, pFilterNm );
-        else if( OBJECT_CLIENT_DDE == nType && pFileNm && pFilterNm )
+                refLink, 0, pFileNm, 0, pFilterNm );
+        else if ( OBJECT_CLIENT_DDE == nType && pFileNm && pFilterNm )
         {
             String sApp, sTopic, sItem;
-            if( refLink->GetLinkManager()->GetDisplayNames(
-                    refLink, &sApp, &sTopic, &sItem ) )
+            if ( refLink->GetLinkManager()->GetDisplayNames(
+                refLink, &sApp, &sTopic, &sItem ) )
             {
                 ( *pFileNm = sApp ) += sfx2::cTokenSeperator;
                 ( *pFileNm += sTopic ) += sfx2::cTokenSeperator;
                 *pFileNm += sItem;
-                pFilterNm->AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ));
+                pFilterNm->AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ) );
                 bRet = sal_True;
             }
         }
@@ -642,13 +636,12 @@ sal_Bool SwGrfNode::GetFileFilterNms( String* pFileNm, String* pFilterNm ) const
     return bRet;
 }
 
-
 // Eine Grafik Undo-faehig machen. Falls sie sich bereits in
 // einem Storage befindet, muss sie geladen werden.
 
 sal_Bool SwGrfNode::SavePersistentData()
 {
-    if( refLink.Is() )
+    if ( refLink.Is() )
     {
         ASSERT( !bInSwapIn, "SavePersistentData: stehe noch im SwapIn" );
         GetDoc()->GetLinkManager().Remove( refLink );
@@ -656,10 +649,10 @@ sal_Bool SwGrfNode::SavePersistentData()
     }
 
     // Erst mal reinswappen, falls sie im Storage ist
-    if( HasEmbeddedStreamName() && !SwapIn() )
+    if ( HasEmbeddedStreamName() && !SwapIn() )
         return sal_False;
 
-    // --> OD 2005-04-19 #i44367#
+    // #i44367#
     // Do not delete graphic file in storage, because the graphic file could
     // be referenced by other graphic nodes.
     // Because it's hard to detect this case here and it would only fix
@@ -671,36 +664,35 @@ sal_Bool SwGrfNode::SavePersistentData()
     // Important note: see also fix for #i40014#
 //    if( HasStreamName() )
 //        DelStreamName();
-    // <--
 
     // Und in TempFile rausswappen
     return (sal_Bool) SwapOut();
 }
 
-
 sal_Bool SwGrfNode::RestorePersistentData()
 {
-    if( refLink.Is() )
+    if ( refLink.Is() )
     {
         IDocumentLinksAdministration* pIDLA = getIDocumentLinksAdministration();
         refLink->SetVisible( pIDLA->IsVisibleLinks() );
         pIDLA->GetLinkManager().InsertDDELink( refLink );
-        if( getIDocumentLayoutAccess()->GetCurrentLayout() )    //swmod 080218
+        if ( getIDocumentLayoutAccess()->GetCurrentLayout() )
             refLink->Update();
     }
     return sal_True;
 }
 
-
-void SwGrfNode::InsertLink( const String& rGrfName, const String& rFltName )
+void SwGrfNode::InsertLink(
+    const String& rGrfName,
+    const String& rFltName )
 {
     refLink = new SwBaseLink( sfx2::LINKUPDATE_ONCALL, FORMAT_GDIMETAFILE, this );
 
     IDocumentLinksAdministration* pIDLA = getIDocumentLinksAdministration();
-    if( GetNodes().IsDocNodes() )
+    if ( GetNodes().IsDocNodes() )
     {
         refLink->SetVisible( pIDLA->IsVisibleLinks() );
-        if( rFltName.EqualsAscii( "DDE" ))
+        if ( rFltName.EqualsAscii( "DDE" ) )
         {
             sal_uInt16 nTmp = 0;
             String sApp, sTopic, sItem;
@@ -708,7 +700,7 @@ void SwGrfNode::InsertLink( const String& rGrfName, const String& rFltName )
             sTopic = rGrfName.GetToken( 0, sfx2::cTokenSeperator, nTmp );
             sItem = rGrfName.Copy( nTmp );
             pIDLA->GetLinkManager().InsertDDELink( refLink,
-                                            sApp, sTopic, sItem );
+                sApp, sTopic, sItem );
         }
         else
         {
@@ -717,26 +709,24 @@ void SwGrfNode::InsertLink( const String& rGrfName, const String& rFltName )
             refLink->SetContentType( SOT_FORMATSTR_ID_SVXB );
 
             pIDLA->GetLinkManager().InsertFileLink( *refLink,
-                                            OBJECT_CLIENT_GRF, rGrfName,
-                                (!bSync && rFltName.Len() ? &rFltName : 0) );
+            OBJECT_CLIENT_GRF, rGrfName,
+                ( !bSync && rFltName.Len() ? &rFltName : 0 ) );
         }
     }
     maGrfObj.SetLink( rGrfName );
 }
 
-
 void SwGrfNode::ReleaseLink()
 {
-    if( refLink.Is() )
+    if ( refLink.Is() )
     {
-        // #15508# remember some stuff from the linked graphic
-        const String aFileName(maGrfObj.GetLink());
-        const Graphic aLocalGraphic(maGrfObj.GetGraphic());
-        const bool bHasOriginalData(aLocalGraphic.IsLink());
+        const String aFileName( maGrfObj.GetLink() );
+        const Graphic aLocalGraphic( maGrfObj.GetGraphic() );
+        const bool bHasOriginalData( aLocalGraphic.IsLink() );
 
         {
             bInSwapIn = sal_True;
-            SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
+            SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
             //TODO pLink->setInputStream(getInputStream());
             pLink->SwapIn( sal_True, sal_True );
             bInSwapIn = sal_False;
@@ -754,14 +744,14 @@ void SwGrfNode::ReleaseLink()
         // 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)
+        if ( bHasOriginalData )
         {
             // #15508# 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);
+            maGrfObj.SetGraphic( aLocalGraphic );
         }
-        else if(aFileName.Len())
+        else if ( aFileName.Len() )
         {
             // #15508# 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
@@ -770,21 +760,21 @@ void SwGrfNode::ReleaseLink()
             int nRes = GRFILTER_OK;
             GraphicFilter* pFlt = GraphicFilter::GetGraphicFilter();
             Graphic aNew;
-            nRes = GraphicFilter::LoadGraphic( aFileName, String(), aNew, pFlt);
+            nRes = GraphicFilter::LoadGraphic( aFileName, String(), aNew, pFlt );
 
-            if(GRFILTER_OK == nRes)
+            if ( GRFILTER_OK == nRes )
             {
-                maGrfObj.SetGraphic(aNew);
+                maGrfObj.SetGraphic( aNew );
             }
         }
     }
 }
 
-
-void SwGrfNode::SetTwipSize( const Size& rSz )
+void SwGrfNode::SetTwipSize(
+    const Size& rSz )
 {
     nGrfSize = rSz;
-    if( IsScaleImageMap() && nGrfSize.Width() && nGrfSize.Height() )
+    if ( IsScaleImageMap() && nGrfSize.Width() && nGrfSize.Height() )
     {
         // Image-Map an Grafik-Groesse anpassen
         ScaleImageMap();
@@ -796,13 +786,13 @@ void SwGrfNode::SetTwipSize( const Size& rSz )
 
 void SwGrfNode::ScaleImageMap()
 {
-    if( !nGrfSize.Width() || !nGrfSize.Height() )
+    if ( !nGrfSize.Width() || !nGrfSize.Height() )
         return;
 
     // dann die Image-Map skalieren
     SwFrmFmt* pFmt = GetFlyFmt();
 
-    if( !pFmt )
+    if ( !pFmt )
         return;
 
     SwFmtURL aURL( pFmt->GetURL() );
@@ -816,62 +806,61 @@ void SwGrfNode::ScaleImageMap()
     const SwFmtFrmSize& rFrmSize = pFmt->GetFrmSize();
     const SvxBoxItem& rBox = pFmt->GetBox();
 
-    if( !rFrmSize.GetWidthPercent() )
+    if ( !rFrmSize.GetWidthPercent() )
     {
         SwTwips nWidth = rFrmSize.GetWidth();
 
-        nWidth -= rBox.CalcLineSpace(BOX_LINE_LEFT) +
-                  rBox.CalcLineSpace(BOX_LINE_RIGHT);
+        nWidth -= rBox.CalcLineSpace( BOX_LINE_LEFT ) +
+                  rBox.CalcLineSpace( BOX_LINE_RIGHT );
 
         ASSERT( nWidth>0, "Gibt es 0 twip breite Grafiken!?" );
 
-        if( nGrfSize.Width() != nWidth )
+        if ( nGrfSize.Width() != nWidth )
         {
             aScaleX = Fraction( nGrfSize.Width(), nWidth );
             bScale = sal_True;
         }
     }
-    if( !rFrmSize.GetHeightPercent() )
+    if ( !rFrmSize.GetHeightPercent() )
     {
         SwTwips nHeight = rFrmSize.GetHeight();
 
-        nHeight -= rBox.CalcLineSpace(BOX_LINE_TOP) +
-                   rBox.CalcLineSpace(BOX_LINE_BOTTOM);
+        nHeight -= rBox.CalcLineSpace( BOX_LINE_TOP ) +
+                   rBox.CalcLineSpace( BOX_LINE_BOTTOM );
 
         ASSERT( nHeight>0, "Gibt es 0 twip hohe Grafiken!?" );
 
-        if( nGrfSize.Height() != nHeight )
+        if ( nGrfSize.Height() != nHeight )
         {
             aScaleY = Fraction( nGrfSize.Height(), nHeight );
             bScale = sal_True;
         }
     }
 
-    if( bScale )
+    if ( bScale )
     {
         aURL.GetMap()->Scale( aScaleX, aScaleY );
         pFmt->SetFmtAttr( aURL );
     }
 }
 
-
 void SwGrfNode::DelStreamName()
 {
-    if( HasEmbeddedStreamName() )
+    if ( HasEmbeddedStreamName() )
     {
         // Dann die Grafik im Storage loeschen
-        uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
-        if( xDocStg.is() )
+        uno::Reference< embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
+        if ( xDocStg.is() )
         {
             try
             {
                 String aPicStgName, aStrmName;
                 _GetStreamStorageNames( aStrmName, aPicStgName );
-                uno::Reference < embed::XStorage > refPics = xDocStg;
+                uno::Reference< embed::XStorage > refPics = xDocStg;
                 if ( aPicStgName.Len() )
                     refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE );
                 refPics->removeElement( aStrmName );
-                uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
+                uno::Reference< embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
                 if ( xTrans.is() )
                     xTrans->commit();
             }
@@ -889,19 +878,20 @@ void SwGrfNode::DelStreamName()
 
 /** helper method to get a substorage of the document storage for readonly access.
 
-    OD, MAV 2005-08-17 #i53025#
-    A substorage with the specified name will be opened readonly. If the provided
-    name is empty the root storage will be returned.
-*/
-uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot( const String& aStgName ) const
-{
-    uno::Reference < embed::XStorage > refStor =
-        const_cast<SwGrfNode*>(this)->GetDoc()->GetDocStorage();
+ #i53025#
+ A substorage with the specified name will be opened readonly. If the provided
+ name is empty the root storage will be returned.
+ */
+uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot(
+    const String& aStgName ) const
+    {
+    uno::Reference< embed::XStorage > refStor =
+            const_cast< SwGrfNode* >( this )->GetDoc()->GetDocStorage();
     ASSERT( refStor.is(), "Kein Storage am Doc" );
 
     if ( aStgName.Len() )
     {
-        if( refStor.is() )
+        if ( refStor.is() )
             return refStor->openStorageElement( aStgName, embed::ElementModes::READ );
     }
 
@@ -910,29 +900,29 @@ uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot( const Stri
 
 /** helper method to determine stream for the embedded graphic.
 
-    OD 2005-05-04 #i48434#
-    Important note: caller of this method has to handle the thrown exceptions
-    OD, MAV 2005-08-17 #i53025#
-    Storage, which should contain the stream of the embedded graphic, is
-    provided via parameter. Otherwise the returned stream will be closed
-    after the the method returns, because its parent stream is closed and deleted.
-    Proposed name of embedded graphic stream is also provided by parameter.
+ #i48434#
+ Important note: caller of this method has to handle the thrown exceptions
+ #i53025#
+ Storage, which should contain the stream of the embedded graphic, is
+ provided via parameter. Otherwise the returned stream will be closed
+ after the the method returns, because its parent stream is closed and deleted.
+ Proposed name of embedded graphic stream is also provided by parameter.
 
-    @author OD
-*/
+ @author OD
+ */
 SvStream* SwGrfNode::_GetStreamForEmbedGrf(
-            const uno::Reference< embed::XStorage >& _refPics,
-            String& _aStrmName ) const
-{
+    const uno::Reference< embed::XStorage >& _refPics,
+    String& _aStrmName ) const
+    {
     SvStream* pStrm( 0L );
 
-    if( _refPics.is() && _aStrmName.Len() )
+    if ( _refPics.is() && _aStrmName.Len() )
     {
         // If stream doesn't exist in the storage, try access the graphic file by
         // re-generating its name.
         // A save action can have changed the filename of the embedded graphic,
         // because a changed unique ID of the graphic is calculated.
-        // --> OD 2006-01-30 #b6364738#
+        // #b6364738#
         // recursive calls of <GetUniqueID()> have to be avoided.
         // Thus, use local static boolean to assure this.
         static bool bInRegenerateStrmName( false );
@@ -951,13 +941,12 @@ SvStream* SwGrfNode::_GetStreamForEmbedGrf(
             }
             bInRegenerateStrmName = false;
         }
-        // <--
 
         // assure that graphic file exist in the storage.
         if ( _refPics->hasByName( _aStrmName ) &&
              _refPics->isStreamElement( _aStrmName ) )
         {
-            uno::Reference < io::XStream > refStrm = _refPics->openStreamElement( _aStrmName, embed::ElementModes::READ );
+            uno::Reference< io::XStream > refStrm = _refPics->openStreamElement( _aStrmName, embed::ElementModes::READ );
             pStrm = utl::UcbStreamHelper::CreateStream( refStrm );
         }
         else
@@ -970,104 +959,96 @@ SvStream* SwGrfNode::_GetStreamForEmbedGrf(
 }
 
 
-// --> OD 2005-08-17 #i53025# - stream couldn't be in a 3.1 - 5.2 storage any more.
-// Thus, removing corresponding code.
-void SwGrfNode::_GetStreamStorageNames( String& rStrmName,
-                                        String& rStorName ) const
-{
+void SwGrfNode::_GetStreamStorageNames(
+    String& rStrmName,
+    String& rStorName ) const
+    {
     rStorName.Erase();
     rStrmName.Erase();
 
     String aUserData( maGrfObj.GetUserData() );
-    if( !aUserData.Len() )
+    if ( !aUserData.Len() )
         return;
 
     String aProt( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.Package:" ) );
-    if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
+    if ( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
     {
         // 6.0 (XML) Package
         xub_StrLen nPos = aUserData.Search( '/' );
-        if( STRING_NOTFOUND == nPos )
+        if ( STRING_NOTFOUND == nPos )
         {
             rStrmName = aUserData.Copy( aProt.Len() );
         }
         else
         {
             xub_StrLen nPathStart = aProt.Len();
-            if( 0 == aUserData.CompareToAscii( "./", 2 ) )
+            if ( 0 == aUserData.CompareToAscii( "./", 2 ) )
                 nPathStart += 2;
-            rStorName = aUserData.Copy( nPathStart, nPos-nPathStart );
-            rStrmName = aUserData.Copy( nPos+1 );
+            rStorName = aUserData.Copy( nPathStart, nPos - nPathStart );
+            rStrmName = aUserData.Copy( nPos + 1 );
         }
     }
     else
     {
         ASSERT( false,
-                "<SwGrfNode::_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
+            "<SwGrfNode::_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
     }
     ASSERT( STRING_NOTFOUND == rStrmName.Search( '/' ),
-            "invalid graphic stream name" );
+        "invalid graphic stream name" );
 }
-// <--
 
-SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
-{
+
+SwCntntNode* SwGrfNode::MakeCopy(
+    SwDoc* pDoc,
+    const SwNodeIndex& rIdx ) const
+    {
     // kopiere die Formate in das andere Dokument:
     SwGrfFmtColl* pColl = pDoc->CopyGrfColl( *GetGrfColl() );
 
     Graphic aTmpGrf;
-    SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
-    if( !pLink && HasEmbeddedStreamName() )
+    SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
+    if ( !pLink && HasEmbeddedStreamName() )
     {
-        // --> 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 );
+            uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
             SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
             if ( pStrm )
             {
-                const String aURL(maGrfObj.GetUserData());
-                GraphicFilter::GetGraphicFilter()->ImportGraphic(aTmpGrf, aURL, *pStrm);
+                const String aURL( maGrfObj.GetUserData() );
+                GraphicFilter::GetGraphicFilter()->ImportGraphic( aTmpGrf, aURL, *pStrm );
                 delete pStrm;
             }
-            // <--
         }
         catch ( uno::Exception& )
         {
-            // --> OD 2005-04-25 #i48434#
             ASSERT( false, "<SwGrfNode::MakeCopy(..)> - unhandled exception!" );
-            // <--
         }
-        // <--
     }
     else
     {
-        if( maGrfObj.IsSwappedOut() )
-            const_cast<SwGrfNode*>(this)->SwapIn();
+        if ( maGrfObj.IsSwappedOut() )
+            const_cast< SwGrfNode* >( this )->SwapIn();
         aTmpGrf = maGrfObj.GetGraphic();
     }
 
     const sfx2::LinkManager& rMgr = getIDocumentLinksAdministration()->GetLinkManager();
     String sFile, sFilter;
-    if( IsLinkedFile() )
+    if ( IsLinkedFile() )
         rMgr.GetDisplayNames( refLink, 0, &sFile, 0, &sFilter );
-    else if( IsLinkedDDE() )
+    else if ( IsLinkedDDE() )
     {
         String sTmp1, sTmp2;
         rMgr.GetDisplayNames( refLink, &sTmp1, &sTmp2, &sFilter );
         sfx2::MakeLnkName( sFile, &sTmp1, sTmp2, sFilter );
-        sFilter.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ));
+        sFilter.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ) );
     }
 
     SwGrfNode* pGrfNd = pDoc->GetNodes().MakeGrfNode( rIdx, sFile, sFilter,
-                                                    &aTmpGrf, pColl,
-                                            (SwAttrSet*)GetpSwAttrSet() );
+        &aTmpGrf, pColl,
+        (SwAttrSet*) GetpSwAttrSet() );
     pGrfNd->SetTitle( GetTitle() );
     pGrfNd->SetDescription( GetDescription() );
     pGrfNd->SetContour( HasContour(), HasAutomaticContour() );
@@ -1081,19 +1062,19 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
     // #101174#: Keep graphic while in swap in. That's at least important
     // when breaking links, because in this situation a reschedule call and
     // a DataChanged call lead to a paint of the graphic.
-    if( pGrfObj->IsInSwapOut() && (IsSelected() || bInSwapIn) )
+    if ( pGrfObj->IsInSwapOut() && ( IsSelected() || bInSwapIn ) )
         pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
-    else if( refLink.Is() )
+    else if ( refLink.Is() )
     {
-        if( pGrfObj->IsInSwapIn() )
+        if ( pGrfObj->IsInSwapIn() )
         {
             // then make it by your self
-            if( !bInSwapIn )
+            if ( !bInSwapIn )
             {
                 sal_Bool bIsModifyLocked = IsModifyLocked();
                 LockModify();
                 SwapIn( sal_False );
-                if( !bIsModifyLocked )
+                if ( !bIsModifyLocked )
                     UnlockModify();
             }
             pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
@@ -1105,22 +1086,17 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
     {
         pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
 
-        if( HasEmbeddedStreamName() )
+        if ( HasEmbeddedStreamName() )
         {
-            // --> 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 );
+                uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
                 SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
                 if ( pStrm )
                 {
-                    if( pGrfObj->IsInSwapOut() )
+                    if ( pGrfObj->IsInSwapOut() )
                     {
                         pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
                     }
@@ -1131,39 +1107,35 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
                     }
                     delete pStrm;
                 }
-                // <--
             }
             catch ( uno::Exception& )
             {
-                // --> OD 2005-04-25 #i48434#
                 ASSERT( false, "<SwapGraphic> - unhandled exception!" );
-                // <--
             }
-            // <--
         }
     }
 
-    return (long)pRet;
+    return (long) pRet;
 }
 
-
 // alle QuickDraw-Bitmaps eines speziellen Docs loeschen
-void DelAllGrfCacheEntries( SwDoc* pDoc )
+void DelAllGrfCacheEntries(
+    SwDoc* pDoc )
 {
-    if( pDoc )
+    if ( pDoc )
     {
         // alle Graphic-Links mit dem Namen aus dem Cache loeschen
         const sfx2::LinkManager& rLnkMgr = pDoc->GetLinkManager();
         const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks();
         SwGrfNode* pGrfNd;
         String sFileNm;
-        for( sal_uInt16 n = rLnks.Count(); n; )
+        for ( sal_uInt16 n = rLnks.Count(); n; )
         {
-            ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
-            if( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType() &&
-                rLnkMgr.GetDisplayNames( pLnk, 0, &sFileNm ) &&
-                pLnk->ISA( SwBaseLink ) && 0 != ( pGrfNd =
-                ((SwBaseLink*)pLnk)->GetCntntNode()->GetGrfNode()) )
+            ::sfx2::SvBaseLink* pLnk = &( *rLnks[--n] );
+            if ( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType()
+                 && rLnkMgr.GetDisplayNames( pLnk, 0, &sFileNm )
+                 && pLnk->ISA( SwBaseLink )
+                 && 0 != ( pGrfNd = ( (SwBaseLink*) pLnk )->GetCntntNode()->GetGrfNode() ) )
             {
                 pGrfNd->ReleaseGraphicFromCache();
             }
@@ -1172,42 +1144,55 @@ void DelAllGrfCacheEntries( SwDoc* pDoc )
 }
 
 // returns the with our graphic attributes filled Graphic-Attr-Structure
-GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
-                                        const SwFrm* pFrm ) const
-{
+GraphicAttr& SwGrfNode::GetGraphicAttr(
+    GraphicAttr& rGA,
+    const SwFrm* pFrm ) const
+    {
     const SwAttrSet& rSet = GetSwAttrSet();
 
-    rGA.SetDrawMode( (GraphicDrawMode)rSet.GetDrawModeGrf().GetValue() );
+    rGA.SetDrawMode( (GraphicDrawMode) rSet.GetDrawModeGrf().GetValue() );
 
     const SwMirrorGrf & rMirror = rSet.GetMirrorGrf();
     sal_uLong nMirror = BMP_MIRROR_NONE;
-    if( rMirror.IsGrfToggle() && pFrm && !pFrm->FindPageFrm()->OnRightPage() )
+    if ( rMirror.IsGrfToggle() && pFrm && !pFrm->FindPageFrm()->OnRightPage() )
     {
-        switch( rMirror.GetValue() )
+        switch (rMirror.GetValue())
         {
-        case RES_MIRROR_GRAPH_DONT:     nMirror = BMP_MIRROR_HORZ; break;
-        case RES_MIRROR_GRAPH_VERT:     nMirror = BMP_MIRROR_NONE; break;
-        case RES_MIRROR_GRAPH_HOR:  nMirror = BMP_MIRROR_HORZ|BMP_MIRROR_VERT;
-                                    break;
-        default:                    nMirror = BMP_MIRROR_VERT; break;
+        case RES_MIRROR_GRAPH_DONT:
+            nMirror = BMP_MIRROR_HORZ;
+            break;
+        case RES_MIRROR_GRAPH_VERT:
+            nMirror = BMP_MIRROR_NONE;
+            break;
+        case RES_MIRROR_GRAPH_HOR:
+            nMirror = BMP_MIRROR_HORZ | BMP_MIRROR_VERT;
+            break;
+        default:
+            nMirror = BMP_MIRROR_VERT;
+            break;
         }
     }
     else
-        switch( rMirror.GetValue() )
+        switch (rMirror.GetValue())
         {
-        case RES_MIRROR_GRAPH_BOTH:     nMirror = BMP_MIRROR_HORZ|BMP_MIRROR_VERT;
-                                    break;
-        case RES_MIRROR_GRAPH_VERT: nMirror = BMP_MIRROR_HORZ; break;
-        case RES_MIRROR_GRAPH_HOR:  nMirror = BMP_MIRROR_VERT; break;
+        case RES_MIRROR_GRAPH_BOTH:
+            nMirror = BMP_MIRROR_HORZ | BMP_MIRROR_VERT;
+            break;
+        case RES_MIRROR_GRAPH_VERT:
+            nMirror = BMP_MIRROR_HORZ;
+            break;
+        case RES_MIRROR_GRAPH_HOR:
+            nMirror = BMP_MIRROR_VERT;
+            break;
         }
 
     rGA.SetMirrorFlags( nMirror );
 
     const SwCropGrf& rCrop = rSet.GetCropGrf();
     rGA.SetCrop( TWIP_TO_MM100( rCrop.GetLeft() ),
-                 TWIP_TO_MM100( rCrop.GetTop() ),
-                 TWIP_TO_MM100( rCrop.GetRight() ),
-                 TWIP_TO_MM100( rCrop.GetBottom() ));
+        TWIP_TO_MM100( rCrop.GetTop() ),
+        TWIP_TO_MM100( rCrop.GetRight() ),
+        TWIP_TO_MM100( rCrop.GetBottom() ) );
 
     const SwRotationGrf& rRotation = rSet.GetRotationGrf();
     rGA.SetRotation( rRotation.GetValue() );
@@ -1222,7 +1207,7 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
 
     const sal_uInt16 nTrans = rSet.GetTransparencyGrf().GetValue();
     rGA.SetTransparency( (sal_uInt8) FRound(
-                                Min( nTrans, (sal_uInt16) 100 )  * 2.55 ) );
+        Min( nTrans, (sal_uInt16) 100 ) * 2.55 ) );
 
     return rGA;
 }
@@ -1230,35 +1215,34 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
 sal_Bool SwGrfNode::IsTransparent() const
 {
     sal_Bool bRet = maGrfObj.IsTransparent();
-    if( !bRet ) // ask the attribut
+    if ( !bRet )    // ask the attribut
         bRet = 0 != GetSwAttrSet().GetTransparencyGrf().GetValue();
 
     return bRet;
 }
 
-
 sal_Bool SwGrfNode::IsSelected() const
 {
     sal_Bool bRet = sal_False;
     const SwEditShell* pESh = GetDoc()->GetEditShell();
-    if( pESh )
+    if ( pESh )
     {
         const SwNode* pN = this;
         const ViewShell* pV = pESh;
-        do {
-            if( pV->ISA( SwEditShell ) && pN == &((SwCrsrShell*)pV)
-                                ->GetCrsr()->GetPoint()->nNode.GetNode() )
+        do
+        {
+            if ( pV->ISA( SwEditShell ) && pN == &( (SwCrsrShell*) pV )
+                                                   ->GetCrsr()->GetPoint()->nNode.GetNode() )
             {
                 bRet = sal_True;
                 break;
             }
         }
-        while( pESh != ( pV = (ViewShell*)pV->GetNext() ));
+        while (pESh != ( pV = (ViewShell*) pV->GetNext() ));
     }
     return bRet;
 }
 
-// --> OD 2006-12-22 #i73788#
 boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > SwGrfNode::GetThreadConsumer()
 {
     return mpThreadConsumer;
@@ -1269,7 +1253,7 @@ void SwGrfNode::TriggerAsyncRetrieveInputStream()
     if ( !IsLinkedFile() )
     {
         ASSERT( false,
-                "<SwGrfNode::TriggerAsyncLoad()> - Method is misused. Method call is only valid for graphic nodes, which refer a linked graphic file" );
+            "<SwGrfNode::TriggerAsyncLoad()> - Method is misused. Method call is only valid for graphic nodes, which refer a linked graphic file" );
         return;
     }
 
@@ -1290,7 +1274,7 @@ bool SwGrfNode::IsLinkedInputStreamReady() const
 }
 
 void SwGrfNode::ApplyInputStream(
-    com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
+    com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream,
     const sal_Bool bIsStreamReadOnly )
 {
     if ( IsLinkedFile() )
@@ -1308,27 +1292,22 @@ void SwGrfNode::ApplyInputStream(
 
 void SwGrfNode::UpdateLinkWithInputStream()
 {
-    // --> OD #i85105#
     // do not work on link, if a <SwapIn> has been triggered.
     if ( !bInSwapIn && IsLinkedFile() )
-    // <--
     {
         GetLink()->setStreamToLoadFrom( mxInputStream, mbIsStreamReadOnly );
         GetLink()->Update();
         SwMsgPoolItem aMsgHint( RES_GRAPHIC_ARRIVED );
         ModifyNotification( &aMsgHint, &aMsgHint );
 
-        // --> OD 2008-06-18 #i88291#
         mxInputStream.clear();
         GetLink()->clearStreamToLoadFrom();
-        // <--
         mbLinkedInputStreamReady = false;
         mpThreadConsumer.reset();
     }
 }
-// <--
 
-// --> OD 2008-07-21 #i90395#
+
 bool SwGrfNode::IsAsyncRetrieveInputStreamPossible() const
 {
     bool bRet = false;
@@ -1346,4 +1325,3 @@ bool SwGrfNode::IsAsyncRetrieveInputStreamPossible() const
 
     return bRet;
 }
-// <--
diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx
index dba3787..2208e4d 100644
--- a/sw/source/filter/rtf/rtffly.cxx
+++ b/sw/source/filter/rtf/rtffly.cxx
@@ -1269,8 +1269,6 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf,
                 if( pFlySave->nEndNd == rIdx )
                     pFlySave->nEndNd = rIdx.GetIndex() - 1;
             }
-
-            pGrfNd->onGraphicChanged();
         }
     }
     else
commit b127235917610b9c68e19df29bb39af496906569
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri Jun 6 12:07:49 2014 +0000

    125000: <WinSalBitmap::ImplCreateGdiPlusBitmap()> - check last status of newly created <Gdiplus::Bitmap> instance before using it.

diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index 005f822..0173b8e 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -310,24 +310,32 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
 
         if(pRetval)
         {
-            sal_uInt8* pSrcRGB(pRGB->mpBits);
-            const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
-            const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
-            const Gdiplus::Rect aAllRect(0, 0, nW, nH);
-            Gdiplus::BitmapData aGdiPlusBitmapData;
-            pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
-
-            // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
-            for(sal_uInt32 y(0); y < nH; y++)
+            if ( pRetval->GetLastStatus() == Gdiplus::Ok )
             {
-                const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
-                sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
+                sal_uInt8* pSrcRGB(pRGB->mpBits);
+                const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
+                const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
+                const Gdiplus::Rect aAllRect(0, 0, nW, nH);
+                Gdiplus::BitmapData aGdiPlusBitmapData;
+                pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
+
+                // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
+                for(sal_uInt32 y(0); y < nH; y++)
+                {
+                    const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
+                    sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
 
-                memcpy(targetPixels, pSrcRGB, nW * 3);
-                pSrcRGB += nW * 3 + nExtraRGB;
-            }
+                    memcpy(targetPixels, pSrcRGB, nW * 3);
+                    pSrcRGB += nW * 3 + nExtraRGB;
+                }
 
-            pRetval->UnlockBits(&aGdiPlusBitmapData);
+                pRetval->UnlockBits(&aGdiPlusBitmapData);
+            }
+            else
+            {
+                delete pRetval;
+                pRetval = NULL;
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list