diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2014-05-23 14:28:40 +0000 |
---|---|---|
committer | Oliver-Rainer Wittmann <orw@apache.org> | 2014-05-23 14:28:40 +0000 |
commit | 23a4bd91ceb89e5e0a2413f80fc987db106a0bc9 (patch) | |
tree | 30b4ff39a5c27a4dc0dc6316bae0e4dca7b384a1 /sw | |
parent | a79b8bb279357f9a81fd8bb11a6b2c2be07f5d7a (diff) |
124946: only apply new embedded stream name for a graphic, if is already has one.
- needed correction for the fix made for issue 114361
Notes
Notes:
merged as: 05e07167e422caf58d23ff883edda30acc3ba88d
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/ndgrf.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 37 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltexte.cxx | 32 |
3 files changed, 32 insertions, 39 deletions
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx index 6d5946622c07..c40eb15b025f 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 e9c634823233..6c42713c3980 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 5bf90e5f0441..edc81d7383e4 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 ) |