/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
mxLink->SetLinkSourceName( sCmd );
} else// no name anymore, so remove link
{
GetDoc().getIDocumentLinksAdministration().GetLinkManager().Remove( mxLink.get() );
mxLink.clear();
}
if( pGraphic )
{
maGrfObj.SetGraphic( *pGraphic );
onGraphicChanged();
bReadGrf = true;
} else
{ // reset data of the old graphic so that the correct placeholder is // shown in case the new link could not be loaded
Graphic aGrf; aGrf.SetDefaultType();
maGrfObj.SetGraphic( aGrf );
if( GetNodes().IsDocNodes() )
{ if( pGraphic )
{
maGrfObj.SetGraphic( *pGraphic );
onGraphicChanged();
bReadGrf = true; // create connection without update, as we have the graphic
mxLink->Connect();
} else
{
Graphic aGrf;
aGrf.SetDefaultType();
maGrfObj.SetGraphic( aGrf );
onGraphicChanged(); if ( bNewGrf )
{
mxLink->SwapIn();
}
}
}
}
// Bug 39281: Do not delete Size immediately - Events on ImageMaps should have // something to work with when swapping if( bSetTwipSize )
SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), nullptr ) );
// create an updates for the frames if( bReadGrf && bNewGrf )
{ const SwUpdateAttr aHint(0,0,0);
CallSwClientNotify(sw::UpdateAttrHint(&aHint, &aHint));
}
SwDoc& rDoc = GetDoc(); if( mxLink.is() )
{
OSL_ENSURE( !mbInSwapIn, "DTOR: I am still in SwapIn" );
rDoc.getIDocumentLinksAdministration().GetLinkManager().Remove( mxLink.get() );
mxLink->Disconnect();
} else
{ // #i40014# - A graphic node, which is in a linked // section, whose link is another section in 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 // one problem with shared graphic files - there are also problems, // a certain graphic file is referenced by two independent graphic nodes, // brush item or drawing objects, the stream isn't no longer removed here. // To do this stuff correctly, a reference counting on shared streams // inside one document has to be implemented.
} //#39289# delete frames already here since the Frames' dtor needs the graphic for its StopAnimation if( HasWriterListeners() )
DelFrames(nullptr);
ResetAttr(RES_PAGEDESC);
}
/// allow reaction on change of content of GraphicObject void SwGrfNode::onGraphicChanged()
{ // try to access SwFlyFrameFormat; 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.
SwFlyFrameFormat* pFlyFormat = dynamic_cast< SwFlyFrameFormat* >(GetFlyFormat());
if (rVectorGraphicDataPtr)
{ const_cast< SwGrfNode* >(this)->mpReplacementGraphic.reset( new GraphicObject(rVectorGraphicDataPtr->getReplacement()) );
} elseif (GetGrfObj().GetGraphic().GetType() == GraphicType::GdiMetafile)
{ // Replacement graphic for PDF and metafiles is just the bitmap. const_cast<SwGrfNode*>(this)->mpReplacementGraphic.reset( new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx()) );
}
}
/** * @return true if ReRead or reading successful, * false if not loaded
*/ bool SwGrfNode::SwapIn(bool bWaitForData)
{ if(mbInSwapIn) // not recursively! returntrue;
/** Make a graphic object ready for UNDO. * * If it is already in storage, it needs to be loaded.
*/ bool SwGrfNode::SavePersistentData()
{ if( mxLink.is() )
{
OSL_ENSURE( !mbInSwapIn, "SavePersistentData: I am still in SwapIn" );
GetDoc().getIDocumentLinksAdministration().GetLinkManager().Remove( mxLink.get() ); returntrue;
}
// swap in first if in storage if( HasEmbeddedStreamName() && !SwapIn() ) returnfalse;
// #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 // one problem with shared graphic files - there are also problems, if // a certain graphic file is referenced by two independent graphic nodes, // brush item or drawing objects, the stream isn't no longer removed here. // To do this stuff correct, a reference counting on shared streams // inside one document has to be implemented. // Important note: see also fix for #i40014#
// #i15508# added extra processing after getting rid of the link. Use whatever is // known from the formerly linked graphic to get to a state as close to a directly // unlinked inserted graphic as possible. Goal is to have a valid GfxLink at the // ImplGraphic (see there) that holds temporary data to the original data and type // information about the original data. Only when this is given will // SvXMLGraphicHelper::ImplInsertGraphicURL which is used at export use that type // and use the original graphic at export for the ODF, without evtl. recoding // of the bitmap graphic data to something without loss (e.g. PNG) but bigger if(bHasOriginalData)
{ // #i15508# 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);
}
}
void SwGrfNode::SetTwipSize( const Size& rSz )
{
mnGrfSize = rSz; if( IsScaleImageMap() && mnGrfSize.Width() && mnGrfSize.Height() )
{ // resize Image-Map to size of the graphic
ScaleImageMap();
// do not re-scale Image-Map
SetScaleImageMap( false );
}
}
// take mirroring of crop values into consideration // while cropping a flipped image. otherwise, // cropping will crop the opposite side of the image. if (rGA.GetMirrorFlags() & BmpMirrorFlags::Vertical)
{
nCropTop = rCrop.GetBottom();
nCropBottom = rCrop.GetTop();
}
void SwGrfNode::TriggerAsyncRetrieveInputStream()
{ if ( !IsLinkedFile() )
{
OSL_FAIL( " - Method is misused. Method call is only valid for graphic nodes, which refer a linked graphic file" ); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.