summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdograf.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-04-01 14:47:13 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-04-10 08:34:13 +0200
commite4eb416c3ef81d098ed61caabd2077cbbb2418bc (patch)
tree5aa13b196431f02a1b4fc0d1049f7ba2eb0ba74c /svx/source/svdraw/svdograf.cxx
parentea3d755ac949c1b6dada5c341e018f8c23f5d395 (diff)
remove swapping and link from GraphicObject and Graphic
Change-Id: If81127e0589b504909801bcbf392d2dec3a3efc1 Reviewed-on: https://gerrit.libreoffice.org/52244 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source/svdraw/svdograf.cxx')
-rw-r--r--svx/source/svdraw/svdograf.cxx177
1 files changed, 6 insertions, 171 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index e61a09da8e2b..0acc622e08e0 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -62,6 +62,7 @@
#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
#include <memory>
+#include <vcl/GraphicLoader.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -282,7 +283,7 @@ sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
void SdrGrafObj::onGraphicChanged()
{
- if (!mpGraphicObject || mpGraphicObject->IsSwappedOut()) // don't force swap-in for this
+ if (!mpGraphicObject) // don't force swap-in for this
return;
const VectorGraphicDataPtr& rVectorGraphicDataPtr = mpGraphicObject->GetGraphic().getVectorGraphicData();
@@ -334,7 +335,6 @@ SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel)
,mbIsSignatureLineShowSignDate(true)
,mbIsSignatureLineCanAddComment(false)
{
- mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -363,7 +363,6 @@ SdrGrafObj::SdrGrafObj(
,mbIsSignatureLineShowSignDate(true)
,mbIsSignatureLineCanAddComment(false)
{
- mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -391,7 +390,6 @@ SdrGrafObj::SdrGrafObj(
,mbIsSignatureLineShowSignDate(true)
,mbIsSignatureLineCanAddComment(false)
{
- mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -417,7 +415,6 @@ void SdrGrafObj::SetGraphicObject(const GraphicObject& rGraphicObject)
{
mpGraphicObject.reset(new GraphicObject(rGraphicObject));
mpReplacementGraphicObject.reset();
- mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
mpGraphicObject->SetUserData();
mbIsPreview = false;
SetChanged();
@@ -449,11 +446,6 @@ const GraphicObject* SdrGrafObj::GetReplacementGraphicObject() const
// Replacement graphic for PDF and metafiles is just the bitmap.
const_cast<SdrGrafObj*>(this)->mpReplacementGraphicObject.reset(new GraphicObject(mpGraphicObject->GetGraphic().GetBitmapEx()));
}
- if (mpReplacementGraphicObject)
- {
- mpReplacementGraphicObject->SetSwapStreamHdl(
- LINK(const_cast<SdrGrafObj*>(this), SdrGrafObj, ReplacementSwapHdl));
- }
}
return mpReplacementGraphicObject.get();
@@ -477,7 +469,6 @@ void SdrGrafObj::SetGraphic( const Graphic& rGrf )
const Graphic& SdrGrafObj::GetGraphic() const
{
- ForceSwapIn();
return mpGraphicObject->GetGraphic();
}
@@ -547,9 +538,10 @@ bool SdrGrafObj::IsEPS() const
return mpGraphicObject->IsEPS();
}
+// TODO Remove
bool SdrGrafObj::IsSwappedOut() const
{
- return mbIsPreview || mpGraphicObject->IsSwappedOut();
+ return false;
}
const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
@@ -605,32 +597,9 @@ Size SdrGrafObj::getOriginalSize() const
return aSize;
}
+// TODO Remove
void SdrGrafObj::ForceSwapIn() const
{
- if( mbIsPreview && mpGraphicObject->HasUserData() )
- {
- // removing preview graphic
- const OUString aUserData( mpGraphicObject->GetUserData() );
-
- Graphic aEmpty;
- mpGraphicObject->SetGraphic( aEmpty );
- mpGraphicObject->SetUserData( aUserData );
-
- const_cast< SdrGrafObj* >( this )->mbIsPreview = false;
- }
- if ( pGraphicLink && mpGraphicObject->IsSwappedOut() )
- ImpUpdateGraphicLink( false );
- else
- mpGraphicObject->FireSwapInRequest();
-
- if( mpGraphicObject->IsSwappedOut() ||
- ( mpGraphicObject->GetType() == GraphicType::NONE ) ||
- ( mpGraphicObject->GetType() == GraphicType::Default ) )
- {
- Graphic aDefaultGraphic;
- aDefaultGraphic.SetDefaultType();
- mpGraphicObject->SetGraphic( aDefaultGraphic );
- }
}
void SdrGrafObj::ImpRegisterLink()
@@ -669,7 +638,7 @@ void SdrGrafObj::SetGraphicLink(const OUString& rFileName, const OUString& rRefe
aFilterName = rFilterName;
ImpRegisterLink();
mpGraphicObject->SetUserData();
- mpGraphicObject->SetSwapState();
+ SetGraphic(vcl::graphic::loadFromURL(aFileName));
}
void SdrGrafObj::ReleaseGraphicLink()
@@ -893,7 +862,6 @@ SdrObject* SdrGrafObj::getFullDragClone() const
// temporary interaction object and load graphic
if(pRetval && IsLinkedGraphic())
{
- pRetval->ForceSwapIn();
pRetval->ReleaseGraphicLink();
}
@@ -1318,139 +1286,6 @@ void SdrGrafObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrink
}
}
-IMPL_LINK(SdrGrafObj, ReplacementSwapHdl, const GraphicObject*, pO, SvStream*)
-{
- // replacement image is always swapped
- if (pO->IsInSwapOut())
- {
- SdrSwapGraphicsMode const nSwapMode(getSdrModelFromSdrObject().GetSwapGraphicsMode());
- if (nSwapMode & SdrSwapGraphicsMode::TEMP)
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- }
- else if (pO->IsInSwapIn())
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- assert(!"why is swap handler being called?");
- }
-
- return GRFMGR_AUTOSWAPSTREAM_NONE;
-}
-
-IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
-{
- SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
-
- if( pO->IsInSwapOut() )
- {
- if( !mbIsPreview && getSdrModelFromSdrObject().IsSwapGraphics() && mpGraphicObject->GetSizeBytes() > 20480 )
- {
- // test if this object is visualized from someone
- // ## test only if there are VOCs other than the preview renderer
- if(!GetViewContact().HasViewObjectContacts())
- {
- const SdrSwapGraphicsMode nSwapMode = getSdrModelFromSdrObject().GetSwapGraphicsMode();
-
- if( ( pGraphicLink ) &&
- ( nSwapMode & SdrSwapGraphicsMode::PURGE ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
- }
- else if( nSwapMode & SdrSwapGraphicsMode::TEMP )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- mpGraphicObject->SetUserData();
- }
-
- // #i102380#
- sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact());
-
- if(pVC)
- {
- pVC->flushGraphicObjects();
- }
- }
- }
- }
- else if( pO->IsInSwapIn() )
- {
- // can be loaded from the original document stream later
- if(mpGraphicObject->HasUserData())
- {
- ::comphelper::LifecycleProxy proxy;
- OUString aUserData = mpGraphicObject->GetUserData();
- uno::Reference<io::XInputStream> const xStream(
- getSdrModelFromSdrObject().GetDocumentStream(aUserData, proxy));
-
- std::unique_ptr<SvStream> const pStream( (xStream.is())
- ? ::utl::UcbStreamHelper::CreateStream(xStream)
- : nullptr );
-
- if( pStream != nullptr )
- {
- Graphic aGraphic;
-
- std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
-
- if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
- {
- pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
-
- const css::awt::Size aPreviewSizeHint( 64, 64 );
- const bool bAllowPartialStreamRead = 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 bool bCreateNativeLink = true;
- (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
- (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
- (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
- (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
- (*pFilterData)[ 2 ].Name = "CreateNativeLink";
- (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
-
- mbIsPreview = true;
- }
-
- if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
- aGraphic, aUserData, *pStream,
- GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
- {
- const OUString aNewUserData( mpGraphicObject->GetUserData() );
- mpGraphicObject->SetGraphic( aGraphic );
- if( mbIsPreview )
- {
- mpGraphicObject->SetUserData(aNewUserData);
- }
- else
- {
- mpGraphicObject->SetUserData();
- }
-
- // Graphic successfully swapped in.
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
- }
- pFilterData.reset();
-
- pStream->ResetError();
- }
- }
- else if( !ImpUpdateGraphicLink( false ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
- }
- }
-
- return pRet;
-}
-
void SdrGrafObj::SetGrafAnimationAllowed(bool bNew)
{
if(mbGrafAnimationAllowed != bNew)