Resolves: #i124946# only apply new embedded stream name...
for a graphic, if is already has one.
- needed correction for the fix made for issue #i114361#
(cherry picked from commit 23a4bd91ceb89e5e0a2413f80fc987db106a0bc9)
Conflicts:
sw/inc/ndgrf.hxx
sw/source/core/graphic/ndgrf.cxx
sw/source/filter/xml/xmltexte.cxx
Change-Id: Ia9771932ae5b380ccae9b0a3cbb79d41f5d9bdb8
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 5292561..4d97b6a 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -72,7 +72,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
void InsertLink( const OUString& rGrfName, const OUString& rFltName );
bool ImportGraphic( SvStream& rStrm );
bool HasStreamName() const { return maGrfObj.HasUserData(); }
/** adjust return type and rename method to
indicate that its an private one. */
@@ -174,6 +173,7 @@ public:
bool SwapIn( bool bWaitForData = false );
/// Remove graphic in order to free memory.
bool SwapOut();
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 OUString& r)
{
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index c868c56..00e383d 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -233,7 +233,7 @@ bool SwGrfNode::ReRead(
else if( pGraphic && rGrfName.isEmpty() )
{
// Old stream must be deleted before the new one is set.
if( HasStreamName() )
if( HasEmbeddedStreamName() )
DelStreamName();
maGrfObj.SetGraphic( *pGraphic );
@@ -243,7 +243,7 @@ bool SwGrfNode::ReRead(
else if( pGrfObj && rGrfName.isEmpty() )
{
// Old stream must be deleted before the new one is set.
if( HasStreamName() )
if( HasEmbeddedStreamName() )
DelStreamName();
maGrfObj = *pGrfObj;
@@ -257,7 +257,7 @@ bool SwGrfNode::ReRead(
return true;
else
{
if( HasStreamName() )
if( HasEmbeddedStreamName() )
DelStreamName();
// create new link for the graphic object
@@ -563,7 +563,7 @@ bool SwGrfNode::SwapIn( bool bWaitForData )
else if( maGrfObj.IsSwappedOut() )
{
// graphic is in storage or in a temp file
if( !HasStreamName() )
if( !HasEmbeddedStreamName() )
{
bRet = maGrfObj.SwapIn();
}
@@ -617,7 +617,7 @@ bool SwGrfNode::SwapOut()
// Swapping is only needed for embedded pictures.
// The graphic will be written into a temp file if it is new, i.e.
// if there is no stream name in the storage yet
if( !HasStreamName() )
if( !HasEmbeddedStreamName() )
if( !maGrfObj.SwapOut() )
return false;
}
@@ -669,7 +669,7 @@ bool SwGrfNode::SavePersistentData()
}
// swap in first if already in storage
if( HasStreamName() && !SwapIn() )
if( HasEmbeddedStreamName() && !SwapIn() )
return false;
// #i44367#
@@ -860,7 +860,7 @@ void SwGrfNode::ScaleImageMap()
void SwGrfNode::DelStreamName()
{
if( HasStreamName() )
if( HasEmbeddedStreamName() )
{
// then remove graphic from storage
uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
@@ -969,7 +969,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
Graphic aTmpGrf;
SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
if( !pLink && HasStreamName() )
if( !pLink && HasEmbeddedStreamName() )
{
try
{
@@ -1048,7 +1048,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
{
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
if( HasStreamName() )
if( HasEmbeddedStreamName() )
{
try
{
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index c5d21ba..9b184af 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -197,7 +197,16 @@ void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
if (pGrfNd && !pGrfNd->IsGrfLink())
{
pGrfNd->ApplyNewEmbeddedStreamName("vnd.sun.star.Package:" + rURL);
// 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())
{
pGrfNd->ApplyNewEmbeddedStreamName("vnd.sun.star.Package:" + rURL);
}
// #i15411# save-as will swap all graphics in; we need to swap
// them out again, to prevent excessive memory use
pGrfNd->SwapOut();