diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-04-01 14:47:13 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-04-10 08:34:13 +0200 |
commit | e4eb416c3ef81d098ed61caabd2077cbbb2418bc (patch) | |
tree | 5aa13b196431f02a1b4fc0d1049f7ba2eb0ba74c | |
parent | ea3d755ac949c1b6dada5c341e018f8c23f5d395 (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>
-rw-r--r-- | include/vcl/GraphicObject.hxx | 36 | ||||
-rw-r--r-- | include/vcl/graph.hxx | 7 | ||||
-rw-r--r-- | sc/qa/extras/anchor.cxx | 1 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 1 | ||||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 2 | ||||
-rw-r--r-- | svtools/qa/unit/GraphicObjectTest.cxx | 124 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofgraphic.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 177 | ||||
-rw-r--r-- | sw/qa/extras/globalfilter/globalfilter.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 38 | ||||
-rw-r--r-- | sw/source/core/docnode/swbaslnk.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/edit/editsh.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 227 | ||||
-rw-r--r-- | vcl/source/gdi/graph.cxx | 35 | ||||
-rw-r--r-- | vcl/source/graphic/GraphicObject.cxx | 343 |
15 files changed, 46 insertions, 957 deletions
diff --git a/include/vcl/GraphicObject.hxx b/include/vcl/GraphicObject.hxx index 64f912e4876d..057f232ea4ef 100644 --- a/include/vcl/GraphicObject.hxx +++ b/include/vcl/GraphicObject.hxx @@ -178,26 +178,15 @@ private: MapMode maPrefMapMode; sal_uLong mnSizeBytes; GraphicType meType; - OUString maLink; - Link<const GraphicObject*, SvStream*> maSwapStreamHdl; OUString maUserData; - std::unique_ptr<Timer> mxSwapOutTimer; std::unique_ptr<GrfSimpleCacheObj> mxSimpleCache; sal_uInt32 mnAnimationLoopCount; - // a unique increasing ID to be able to say which data change is older - sal_uLong mnDataChangeTimeStamp; - - bool mbAutoSwapped : 1; bool mbTransparent : 1; bool mbAnimated : 1; bool mbEPS : 1; - bool mbIsInSwapIn : 1; - bool mbIsInSwapOut : 1; void VCL_DLLPRIVATE ImplAssignGraphicData(); - static void VCL_DLLPRIVATE ImplEnsureGraphicManager(); - void VCL_DLLPRIVATE ImplAutoSwapIn(); bool VCL_DLLPRIVATE ImplGetCropParams( OutputDevice const * pOut, Point& rPt, @@ -299,12 +288,6 @@ private: bool bEnlarge ) const; - DECL_LINK( ImplAutoSwapOutHdl, Timer*, void ); -protected: - - SvStream* GetSwapStream() const; - void SetSwapState(); - public: GraphicObject(); GraphicObject( const Graphic& rGraphic ); @@ -315,12 +298,6 @@ public: bool operator==( const GraphicObject& rCacheObj ) const; bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); } - bool HasSwapStreamHdl() const { return maSwapStreamHdl.IsSet(); } - void SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl); - - void FireSwapInRequest(); - void FireSwapOutRequest(); - const Graphic& GetGraphic() const; void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = nullptr); void SetGraphic( const Graphic& rGraphic, const OUString& rLink ); @@ -360,11 +337,6 @@ public: void SetAttr( const GraphicAttr& rAttr ); const GraphicAttr& GetAttr() const { return maAttr; } - bool HasLink() const { return !maLink.isEmpty(); } - void SetLink(); - void SetLink( const OUString& rLink ); - const OUString& GetLink() const { return maLink; } - bool HasUserData() const { return !maUserData.isEmpty(); } void SetUserData(); void SetUserData( const OUString& rUserData ); @@ -380,14 +352,6 @@ public: bool IsAnimated() const { return mbAnimated; } bool IsEPS() const { return mbEPS; } - bool SwapOut(); - bool SwapOut( SvStream* pOStm ); - bool SwapIn(); - - bool IsInSwapIn() const { return mbIsInSwapIn; } - bool IsInSwapOut() const { return mbIsInSwapOut; } - bool IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); } - bool Draw( OutputDevice* pOut, const Point& rPt, diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 9be22958b446..be62d12bc1e7 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -212,13 +212,6 @@ public: private: friend class GraphicObject; - bool SwapOut(); - void SwapOutAsLink(); - bool SwapOut( SvStream* pOStm ); - bool SwapIn(); - bool SwapIn( SvStream* pIStm ); - bool IsSwapOut() const; - public: void SetLink( const GfxLink& ); GfxLink GetLink() const; diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx index baa609a154a6..1407b784fa9e 100644 --- a/sc/qa/extras/anchor.cxx +++ b/sc/qa/extras/anchor.cxx @@ -86,7 +86,6 @@ void ScAnchorTest::testUndoAnchor() CPPUNIT_ASSERT(pObject->IsLinkedGraphic()); const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT(!rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes()); diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index e011eeddbf1d..f6582cd8e7d0 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -3253,7 +3253,6 @@ void ScExportTest::testLinkedGraphicRT() CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject->IsLinkedGraphic() ); const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes()); diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 20addcee2bc0..4752a84d3529 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -590,7 +590,6 @@ void SdExportTest::testLinkedGraphicRT() CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic() ); const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), !rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes()); } @@ -616,7 +615,6 @@ void SdExportTest::testLinkedGraphicRT() CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject->IsLinkedGraphic() ); const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes()); } diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx index 6d748b8d180d..3f6c69b7e051 100644 --- a/svtools/qa/unit/GraphicObjectTest.cxx +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -37,10 +37,7 @@ class GraphicObjectTest: public test::BootstrapFixture, public unotest::MacrosTe { public: - void testSwap(); void testTdf88836(); - void testPdf(); - virtual void setUp() override { @@ -50,98 +47,11 @@ public: } private: - DECL_LINK(getLinkStream, const GraphicObject*, SvStream*); - -private: CPPUNIT_TEST_SUITE(GraphicObjectTest); - CPPUNIT_TEST(testSwap); CPPUNIT_TEST(testTdf88836); - CPPUNIT_TEST(testPdf); CPPUNIT_TEST_SUITE_END(); }; -static const char aGraphicFile[] = "/svtools/qa/unit/data/graphic.png"; -static const sal_uLong nGraphicSizeBytes = 4800; - -const Graphic lcl_loadGraphic(const rtl::OUString &rUrl) -{ - const Image aImage(rUrl); - return Graphic(aImage.GetBitmapEx()); -} - -IMPL_LINK_NOARG(GraphicObjectTest, getLinkStream, const GraphicObject*, SvStream*) -{ - return GRFMGR_AUTOSWAPSTREAM_LINK; -} - -void GraphicObjectTest::testSwap() -{ - // simple non-linked case - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - CPPUNIT_ASSERT(!aGraphObj.HasSwapStreamHdl()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - } - - // linked case - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - aGraphObj.SetSwapStreamHdl(LINK(this, GraphicObjectTest, getLinkStream)); - - CPPUNIT_ASSERT(aGraphObj.HasSwapStreamHdl()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - } - - // combination of two GraphicObjects - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - - GraphicObject aGraphObj2(aGraphObj); - aGraphObj2.SetSwapStreamHdl(LINK(this, GraphicObjectTest, getLinkStream)); - - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj2.GetGraphic().GetSizeBytes()); - - // GraphicObjects never share the same Graphic. A new one is created as one step during - // registration of the GraphicObject at GraphicManager. - - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj2.SwapOut()); - CPPUNIT_ASSERT(aGraphObj2.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj2.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj2.GetGraphic().GetSizeBytes()); - } -} void GraphicObjectTest::testTdf88836() { @@ -152,40 +62,6 @@ void GraphicObjectTest::testTdf88836() CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); } -void GraphicObjectTest::testPdf() -{ -#if HAVE_FEATURE_PDFIUM - uno::Reference<lang::XComponent> xComponent = loadFromDesktop(m_directories.getURLFromSrc("svtools/qa/unit/data/pdf.odt"), "com.sun.star.text.TextDocument"); - SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument*>(xComponent.get()); - CPPUNIT_ASSERT(pTxtDoc); - SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc(); - CPPUNIT_ASSERT(pDoc); - SwNodes& aNodes = pDoc->GetNodes(); - - // Find images - GraphicObject* pGraphicObject = nullptr; - for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex) - { - if( aNodes[nIndex]->IsGrfNode() ) - { - SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode(); - CPPUNIT_ASSERT(pGrfNode); - pGraphicObject = const_cast<GraphicObject*>(&pGrfNode->GetGrfObj()); - break; - } - } - CPPUNIT_ASSERT_MESSAGE("Missing image", pGraphicObject); - - CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); - CPPUNIT_ASSERT(pGraphicObject->SwapOut()); - CPPUNIT_ASSERT(pGraphicObject->SwapIn()); - // This failed, swap out + swap in lost the PDF data. - CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); - - xComponent->dispose(); -#endif -} - CPPUNIT_TEST_SUITE_REGISTRATION(GraphicObjectTest); } diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index 3c0622bad264..b379757408ba 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -418,10 +418,6 @@ namespace sdr // draft when swapped out const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(); - static bool bAllowReplacements(true); - - if(rGraphicObject.IsSwappedOut() && bAllowReplacements) - return true; // draft when no graphic if(GraphicType::NONE == rGraphicObject.GetType() || GraphicType::Default == rGraphicObject.GetType()) 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) diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 1c4bc6f5e793..66b0d72d31b3 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -184,7 +184,6 @@ void Test::testLinkedGraphicRT() CPPUNIT_ASSERT(pGrfNode); const GraphicObject& rGraphicObj = pGrfNode->GetGrfObj(true); - CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetType())); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), static_cast<sal_uLong>(864900), rGraphicObj.GetSizeBytes()); bImageFound = true; diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 6d503dce45fa..4c6c8ffc80e9 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -941,44 +941,6 @@ void paintGraphicUsingPrimitivesHelper( drawinglayer::primitive2d::Primitive2DContainer aContent(1); bool bDone(false); - // #i125171# The mechanism to get lossless jpegs into pdf is based on having the original - // file data (not the bitmap data) at the Graphic in the GfxLink (which has *nothing* to - // do with the graphic being linked). This works well for DrawingLayer GraphicObjects (linked - // and unlinked) but fails for linked Writer GraphicObjects. These have the URL in the - // GraphicObject, but no GfxLink with the original file data when it's a linked graphic. - // Since this blows up PDF size by a factor of 10 (the graphics get embedded as pixel maps - // then) it is okay to add this workarund: In the needed case, load the graphic in a way to - // get the GfxLink in the needed form and use that Graphic temporarily. Do this only when - // - we have PDF export - // - the GraphicObject is linked - // - the Graphic has no GfxLink - // - LosslessCompression is activated - // - it's indeed a jpeg graphic (could be checked by the url ending, but is more reliable to check later) - // In all other cases (normal repaint, print, etc...) use the available Graphic with the - // already loaded pixel graphic as before this change. - if (rOutputDevice.GetExtOutDevData() && rGrfObj.HasLink() && !rGrfObj.GetGraphic().IsLink()) - { - const vcl::PDFExtOutDevData* pPDFExt = dynamic_cast< const vcl::PDFExtOutDevData* >(rOutputDevice.GetExtOutDevData()); - - if (pPDFExt && pPDFExt->GetIsLosslessCompression()) - { - Graphic aTempGraphic; - INetURLObject aURL(rGrfObj.GetLink()); - - if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aTempGraphic, aURL)) - { - if(aTempGraphic.IsLink() && GfxLinkType::NativeJpg == aTempGraphic.GetLink().GetType()) - { - aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( - rGraphicTransform, - aTempGraphic, - rGraphicAttr); - bDone = true; - } - } - } - } - if(!bDone) { aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index cc3bff0306d4..4f30f7b4d67e 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -164,7 +164,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) bGraphicPieceArrived = false; } - pSwGrfNode->SetGraphic(aGrf, rGrfObj.GetLink()); + pSwGrfNode->SetGraphic(aGrf, ""); bUpdate = true; // In order for the Node to have the right transparency status diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 9ac89cd6f01b..7d3dd51265b7 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -246,9 +246,8 @@ bool SwEditShell::IsLinkedGrfSwapOut() const { SwGrfNode *pGrfNode = GetGrfNode_(); return pGrfNode && - ( pGrfNode->IsLinkedFile() && - ( GraphicType::Default == pGrfNode->GetGrfObj().GetType() || - pGrfNode->GetGrfObj().IsSwappedOut())); + pGrfNode->IsLinkedFile() && + GraphicType::Default == pGrfNode->GetGrfObj().GetType(); } const GraphicObject* SwEditShell::GetGraphicObj() const diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 31fab60ce388..97660f6cbbde 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -73,7 +73,6 @@ SwGrfNode::SwGrfNode( mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( false ) { - maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) ); bInSwapIn = bChgTwipSize = bFrameInPaint = bScaleImageMap = false; @@ -92,7 +91,6 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( false ) { - maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) ); bInSwapIn = bChgTwipSize = bFrameInPaint = bScaleImageMap = false; bGraphicArrived = true; @@ -116,8 +114,6 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( false ) { - maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) ); - Graphic aGrf; aGrf.SetDefaultType(); maGrfObj.SetGraphic( aGrf, rGrfName ); @@ -195,7 +191,6 @@ bool SwGrfNode::ReRead( else if( pGrfObj ) { maGrfObj = *pGrfObj; - maGrfObj.SetLink( rGrfName ); onGraphicChanged(); bReadGrf = true; } @@ -256,7 +251,6 @@ bool SwGrfNode::ReRead( else if( pGrfObj ) { maGrfObj = *pGrfObj; - maGrfObj.SetLink( rGrfName ); onGraphicChanged(); bReadGrf = true; // create connection without update, as we have the graphic @@ -410,11 +404,6 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const // Replacement graphic for PDF and metafiles is just the bitmap. const_cast<SwGrfNode*>(this)->mpReplacementGraphic = new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx()); } - if (mpReplacementGraphic) - { - mpReplacementGraphic->SetSwapStreamHdl( - LINK(const_cast<SwGrfNode*>(this), SwGrfNode, SwapReplacement)); - } } return mpReplacementGraphic; @@ -479,157 +468,17 @@ bool SwGrfNode::ImportGraphic( SvStream& rStrm ) return false; } -namespace -{ - -struct StreamAndStorageNames -{ - OUString sStream; - OUString sStorage; -}; - -StreamAndStorageNames lcl_GetStreamStorageNames( const OUString& sUserData ) -{ - StreamAndStorageNames aNames; - if( sUserData.isEmpty() ) - return aNames; - - const OUString aProt( "vnd.sun.star.Package:" ); - if (sUserData.startsWithIgnoreAsciiCase(aProt)) - { - // 6.0 (XML) Package - const sal_Int32 nPos = sUserData.indexOf('/'); - if (nPos<0) - { - aNames.sStream = sUserData.copy(aProt.getLength()); - } - else - { - const sal_Int32 nPathStart = aProt.getLength(); - aNames.sStorage = sUserData.copy( nPathStart, nPos-nPathStart ); - aNames.sStream = sUserData.copy( nPos+1 ); - } - } - else - { - OSL_FAIL( "<lcl_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." ); - } - OSL_ENSURE( aNames.sStream.indexOf('/')<0, "invalid graphic stream name" ); - return aNames; -} - -} - /** * @return true if ReRead or reading successful, * false if not loaded */ -bool SwGrfNode::SwapIn( bool bWaitForData ) +bool SwGrfNode::SwapIn( bool /*bWaitForData*/ ) { - if( bInSwapIn ) // not recursively! - return !maGrfObj.IsSwappedOut(); - - bool bRet = false; - bInSwapIn = true; - SwBaseLink* pLink = static_cast<SwBaseLink*>( refLink.get() ); - - if( pLink ) - { - if( GraphicType::NONE == maGrfObj.GetType() || - GraphicType::Default == maGrfObj.GetType() ) - { - // link was not loaded yet - if( pLink->SwapIn( bWaitForData ) ) - { - bRet = true; - } - else if( GraphicType::Default == maGrfObj.GetType() ) - { - // no default bitmap anymore, thus re-paint - delete mpReplacementGraphic; - mpReplacementGraphic = nullptr; - - maGrfObj.SetGraphic( Graphic() ); - onGraphicChanged(); - SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED ); - ModifyNotification( &aMsgHint, &aMsgHint ); - } - } - else if( maGrfObj.IsSwappedOut() ) - { - // link to download - bRet = pLink->SwapIn( bWaitForData ); - } - else - bRet = true; - } - else if( maGrfObj.IsSwappedOut() ) - { - // graphic is in storage or in a temp file - if( !HasEmbeddedStreamName() ) - { - bRet = maGrfObj.SwapIn(); - } - else - { - try - { - const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() ); - uno::Reference < embed::XStorage > refPics = GetDocSubstorageOrRoot( aNames.sStorage ); - SvStream* pStrm = GetStreamForEmbedGrf( refPics, aNames.sStream ); - if ( pStrm ) - { - bRet = ImportGraphic( *pStrm ); - delete pStrm; - if( bRet ) - { - maGrfObj.SetUserData(); - } - } - } - catch (const uno::Exception&) - { - // #i48434# - OSL_FAIL( "<SwGrfNode::SwapIn(..)> - unhandled exception!" ); - } - } - - if( bRet ) - { - SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN ); - ModifyNotification( &aMsg, &aMsg ); - } - } - else - bRet = true; - OSL_ENSURE( bRet, "Cannot swap in graphic" ); - - if( bRet ) - { - if( !nGrfSize.Width() && !nGrfSize.Height() ) - SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), nullptr ) ); - } - bInSwapIn = false; - return bRet; + return true; } bool SwGrfNode::SwapOut() { - if( maGrfObj.GetType() != GraphicType::Default && - maGrfObj.GetType() != GraphicType::NONE && - !maGrfObj.IsSwappedOut() && !bInSwapIn ) - { - if( refLink.is() ) - { - // written graphics and links are removed here - return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK ); - } - else - { - return maGrfObj.SwapOut(); - } - - } return true; } @@ -735,14 +584,12 @@ void SwGrfNode::InsertLink( const OUString& rGrfName, const OUString& rFltName ) (!bSync && !rFltName.isEmpty() ? &rFltName : nullptr) ); } } - maGrfObj.SetLink( rGrfName ); } void SwGrfNode::ReleaseLink() { if( refLink.is() ) { - const OUString aFileName(maGrfObj.GetLink()); const Graphic aLocalGraphic(maGrfObj.GetGraphic()); const bool bHasOriginalData(aLocalGraphic.IsLink()); @@ -755,7 +602,6 @@ void SwGrfNode::ReleaseLink() getIDocumentLinksAdministration().GetLinkManager().Remove( refLink.get() ); refLink.clear(); - maGrfObj.SetLink(); // #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 @@ -772,21 +618,6 @@ void SwGrfNode::ReleaseLink() // This happens e.g. when inserting a linked graphic and breaking the link maGrfObj.SetGraphic(aLocalGraphic); } - else if(!aFileName.isEmpty()) - { - // #i15508# 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 - // that data from the original file; if this works, use it. Else use the - // data we have (but without knowing the original format) - GraphicFilter& rFlt = GraphicFilter::GetGraphicFilter(); - Graphic aNew; - ErrCode nRes = GraphicFilter::LoadGraphic( aFileName, OUString(), aNew, &rFlt); - - if(ERRCODE_NONE == nRes) - { - maGrfObj.SetGraphic(aNew); - } - } } } @@ -964,60 +795,6 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const return pGrfNd; } -IMPL_STATIC_LINK(SwGrfNode, SwapReplacement, const GraphicObject*, pGrfObj, SvStream*) -{ - // replacement image is always swapped - if (pGrfObj->IsInSwapOut()) - { - return GRFMGR_AUTOSWAPSTREAM_TEMP; - } - else if (pGrfObj->IsInSwapIn()) - { - return GRFMGR_AUTOSWAPSTREAM_TEMP; - } - else - { - assert(!"why is swap handler being called?"); - } - - return GRFMGR_AUTOSWAPSTREAM_NONE; -} - -IMPL_LINK( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj, SvStream* ) -{ - SvStream* pRet; - - // 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) ) - pRet = GRFMGR_AUTOSWAPSTREAM_NONE; - else if( refLink.is() ) - { - if( pGrfObj->IsInSwapIn() ) - { - // then make it by your self - if( !bInSwapIn ) - { - const bool bIsModifyLocked = IsModifyLocked(); - LockModify(); - SwapIn(); - if( !bIsModifyLocked ) - UnlockModify(); - } - pRet = GRFMGR_AUTOSWAPSTREAM_NONE; - } - else - pRet = GRFMGR_AUTOSWAPSTREAM_LINK; - } - else - { - pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; - } - - return pRet; -} - /// returns the Graphic-Attr-Structure filled with our graphic attributes GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA, const SwFrame* pFrame ) const diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 150bc049d722..a424b4ebdb0e 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -507,41 +507,6 @@ bool Graphic::IsDummyContext() return mxImpGraphic->ImplIsDummyContext(); } -bool Graphic::SwapOut() -{ - ImplTestRefCount(); - return mxImpGraphic->ImplSwapOut(); -} - -void Graphic::SwapOutAsLink() -{ - ImplTestRefCount(); - mxImpGraphic->ImplSwapOutAsLink(); -} - -bool Graphic::SwapOut( SvStream* pOStream ) -{ - ImplTestRefCount(); - return mxImpGraphic->ImplSwapOut( pOStream ); -} - -bool Graphic::SwapIn() -{ - ImplTestRefCount(); - return mxImpGraphic->ImplSwapIn(); -} - -bool Graphic::SwapIn( SvStream* pStrm ) -{ - ImplTestRefCount(); - return mxImpGraphic->ImplSwapIn( pStrm ); -} - -bool Graphic::IsSwapOut() const -{ - return mxImpGraphic->ImplIsSwapOut(); -} - void Graphic::SetLink( const GfxLink& rGfxLink ) { ImplTestRefCount(); diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx index b609608d1f67..3cb54a70c6c6 100644 --- a/vcl/source/graphic/GraphicObject.cxx +++ b/vcl/source/graphic/GraphicObject.cxx @@ -302,21 +302,13 @@ struct GrfSimpleCacheObj }; GraphicObject::GraphicObject() - : mbAutoSwapped(false) - , mbIsInSwapIn(false) - , mbIsInSwapOut(false) { - ImplEnsureGraphicManager(); ImplAssignGraphicData(); } GraphicObject::GraphicObject(const Graphic& rGraphic) : maGraphic(rGraphic) - , mbAutoSwapped(false) - , mbIsInSwapIn(false) - , mbIsInSwapOut(false) { - ImplEnsureGraphicManager(); ImplAssignGraphicData(); } @@ -324,15 +316,9 @@ GraphicObject::GraphicObject(const GraphicObject& rGraphicObj) : maGraphic(rGraphicObj.GetGraphic()) , maAttr(rGraphicObj.maAttr) , maPrefMapMode(rGraphicObj.maPrefMapMode) - , maLink(rGraphicObj.maLink) , maUserData(rGraphicObj.maUserData) - , mbAutoSwapped(false) - , mbIsInSwapIn(false) - , mbIsInSwapOut(false) { ImplAssignGraphicData(); - if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() ) - SetSwapState(); } GraphicObject::~GraphicObject() @@ -351,66 +337,6 @@ void GraphicObject::ImplAssignGraphicData() mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 ); } -void GraphicObject::ImplEnsureGraphicManager() -{ -} - -void GraphicObject::ImplAutoSwapIn() -{ - if( !IsSwappedOut() ) - return; - - { - mbIsInSwapIn = true; - - if( maGraphic.SwapIn() ) - mbAutoSwapped = false; - else - { - SvStream* pStream = GetSwapStream(); - - if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream ) - { - if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream ) - { - if( HasLink() ) - { - OUString aURLStr; - - if( osl::FileBase::getFileURLFromSystemPath( GetLink(), aURLStr ) == osl::FileBase::E_None ) - { - std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURLStr, StreamMode::READ )); - - if( pIStm ) - { - ReadGraphic( *pIStm, maGraphic ); - mbAutoSwapped = ( maGraphic.GetType() != GraphicType::NONE ); - } - } - } - } - else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream ) - mbAutoSwapped = !maGraphic.SwapIn(); - else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream ) - mbAutoSwapped = maGraphic.IsSwapOut(); - else - { - mbAutoSwapped = !maGraphic.SwapIn( pStream ); - delete pStream; - } - } - else - { - DBG_ASSERT( ( GraphicType::NONE == meType ) || ( GraphicType::Default == meType ), - "GraphicObject::ImplAutoSwapIn: could not get stream to swap in graphic! (=>KA)" ); - } - } - - mbIsInSwapIn = false; - } - ImplAssignGraphicData(); -} - bool GraphicObject::ImplGetCropParams( OutputDevice const * pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr, tools::PolyPolygon& rClipPolyPoly, bool& bRectClipRegion ) const { @@ -484,17 +410,11 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj ) { if( &rGraphicObj != this ) { - maSwapStreamHdl = Link<const GraphicObject*, SvStream*>(); mxSimpleCache.reset(); - maGraphic = rGraphicObj.GetGraphic(); maAttr = rGraphicObj.maAttr; - maLink = rGraphicObj.maLink; maUserData = rGraphicObj.maUserData; ImplAssignGraphicData(); - mbAutoSwapped = false; - if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() ) - SetSwapState(); } return *this; @@ -502,27 +422,15 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj ) bool GraphicObject::operator==( const GraphicObject& rGraphicObj ) const { - return( ( rGraphicObj.maGraphic == maGraphic ) && - ( rGraphicObj.maAttr == maAttr ) && - ( rGraphicObj.GetLink() == GetLink() ) ); + return rGraphicObj.maGraphic == maGraphic + && rGraphicObj.maAttr == maAttr; } OString GraphicObject::GetUniqueID() const { - if ( !IsInSwapIn() && IsEPS() ) - const_cast<GraphicObject*>(this)->FireSwapInRequest(); - return GetGraphic().getUniqueID(); } -SvStream* GraphicObject::GetSwapStream() const -{ - if( HasSwapStreamHdl() ) - return maSwapStreamHdl.Call( this ); - else - return GRFMGR_AUTOSWAPSTREAM_NONE; -} - void GraphicObject::SetAttr( const GraphicAttr& rAttr ) { maAttr = rAttr; @@ -531,16 +439,6 @@ void GraphicObject::SetAttr( const GraphicAttr& rAttr ) mxSimpleCache.reset(); } -void GraphicObject::SetLink() -{ - maLink.clear(); -} - -void GraphicObject::SetLink( const OUString& rLink ) -{ - maLink = rLink; -} - void GraphicObject::SetUserData() { maUserData.clear(); @@ -549,52 +447,6 @@ void GraphicObject::SetUserData() void GraphicObject::SetUserData( const OUString& rUserData ) { maUserData = rUserData; - if( !rUserData.isEmpty() ) - SetSwapState(); -} - -static sal_uInt32 GetCacheTimeInMs() -{ - if (utl::ConfigManager::IsFuzzing()) - return 20000; - - const sal_uInt32 nSeconds = - officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get( - comphelper::getProcessComponentContext()); - - return nSeconds * 1000; -} - -void GraphicObject::SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl) -{ - maSwapStreamHdl = rHdl; - - sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs()); - if (nSwapOutTimeout) - { - if (!mxSwapOutTimer) - { - mxSwapOutTimer.reset(new Timer("svtools::GraphicObject mpSwapOutTimer")); - mxSwapOutTimer->SetInvokeHandler( LINK( this, GraphicObject, ImplAutoSwapOutHdl ) ); - } - - mxSwapOutTimer->SetTimeout( nSwapOutTimeout ); - mxSwapOutTimer->Start(); - } - else - { - mxSwapOutTimer.reset(); - } -} - -void GraphicObject::FireSwapInRequest() -{ - ImplAutoSwapIn(); -} - -void GraphicObject::FireSwapOutRequest() -{ - ImplAutoSwapOutHdl( nullptr ); } bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz, @@ -693,49 +545,47 @@ bool GraphicObject::StartAnimation( OutputDevice* pOut, const Point& rPt, const GetGraphic(); - if( !IsSwappedOut() ) - { - const GraphicAttr aAttr( GetAttr() ); - if( mbAnimated ) - { - Point aPt( rPt ); - Size aSz( rSz ); - bool bCropped = aAttr.IsCropped(); + const GraphicAttr aAttr( GetAttr() ); - if( bCropped ) - { - tools::PolyPolygon aClipPolyPoly; - bool bRectClip; - const bool bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip ); + if( mbAnimated ) + { + Point aPt( rPt ); + Size aSz( rSz ); + bool bCropped = aAttr.IsCropped(); - pOut->Push( PushFlags::CLIPREGION ); + if( bCropped ) + { + tools::PolyPolygon aClipPolyPoly; + bool bRectClip; + const bool bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip ); - if( bCrop ) - { - if( bRectClip ) - pOut->IntersectClipRegion( aClipPolyPoly.GetBoundRect() ); - else - pOut->IntersectClipRegion(vcl::Region(aClipPolyPoly)); - } - } + pOut->Push( PushFlags::CLIPREGION ); - if (!mxSimpleCache || (mxSimpleCache->maAttr != aAttr) || pFirstFrameOutDev) + if( bCrop ) { - mxSimpleCache.reset(new GrfSimpleCacheObj(GetTransformedGraphic(&aAttr), aAttr)); - mxSimpleCache->maGraphic.SetAnimationNotifyHdl(GetGraphic().GetAnimationNotifyHdl()); + if( bRectClip ) + pOut->IntersectClipRegion( aClipPolyPoly.GetBoundRect() ); + else + pOut->IntersectClipRegion(vcl::Region(aClipPolyPoly)); } + } - mxSimpleCache->maGraphic.StartAnimation(pOut, aPt, aSz, nExtraData, pFirstFrameOutDev); + if (!mxSimpleCache || (mxSimpleCache->maAttr != aAttr) || pFirstFrameOutDev) + { + mxSimpleCache.reset(new GrfSimpleCacheObj(GetTransformedGraphic(&aAttr), aAttr)); + mxSimpleCache->maGraphic.SetAnimationNotifyHdl(GetGraphic().GetAnimationNotifyHdl()); + } - if( bCropped ) - pOut->Pop(); + mxSimpleCache->maGraphic.StartAnimation(pOut, aPt, aSz, nExtraData, pFirstFrameOutDev); - bRet = true; - } - else - bRet = Draw( pOut, rPt, rSz, &aAttr ); + if( bCropped ) + pOut->Pop(); + + bRet = true; } + else + bRet = Draw( pOut, rPt, rSz, &aAttr ); return bRet; } @@ -748,44 +598,18 @@ void GraphicObject::StopAnimation( OutputDevice* pOut, long nExtraData ) const Graphic& GraphicObject::GetGraphic() const { - GraphicObject *pThis = const_cast<GraphicObject*>(this); - (void)pThis->SwapIn(); - - //fdo#50697 If we've been asked to provide the graphic, then reset - //the cache timeout to start from now and not remain at the - //time of creation - // restart SwapOut timer; this is like touching in a cache to reset to the full timeout value - if (pThis->mxSwapOutTimer && pThis->mxSwapOutTimer->IsActive()) - { - pThis->mxSwapOutTimer->Stop(); - pThis->mxSwapOutTimer->Start(); - } - return maGraphic; } -void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* /*pCopyObj*/ ) +void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* /*pCopyObj*/) { - if (mxSwapOutTimer) - mxSwapOutTimer->Stop(); - maGraphic = rGraphic; - mbAutoSwapped = false; ImplAssignGraphicData(); - maLink.clear(); - mxSimpleCache.reset(); - - if (mxSwapOutTimer) - mxSwapOutTimer->Start(); } -void GraphicObject::SetGraphic( const Graphic& rGraphic, const OUString& rLink ) +void GraphicObject::SetGraphic( const Graphic& rGraphic, const OUString& /*rLink*/ ) { - // in case we are called from a situation where rLink and maLink are the same thing, - // we need a copy because SetGraphic clears maLink - OUString sLinkCopy = rLink; SetGraphic( rGraphic ); - maLink = sLinkCopy; } Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const @@ -1022,7 +846,7 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const Graphic aGraphic; GraphicAttr aAttr( pAttr ? *pAttr : GetAttr() ); - if( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() ) + if (maGraphic.IsSupportedGraphic()) { if( aAttr.IsSpecialDrawMode() || aAttr.IsAdjusted() || aAttr.IsMirrored() || aAttr.IsRotated() || aAttr.IsTransparent() ) { @@ -1065,103 +889,6 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const return aGraphic; } -bool GraphicObject::SwapOut() -{ - const bool bRet = !mbAutoSwapped && maGraphic.SwapOut(); - - return bRet; -} - -bool GraphicObject::SwapOut( SvStream* pOStm ) -{ - bool bRet = false; - try - { - bRet = !mbAutoSwapped; - // swap out as a link - if( pOStm == GRFMGR_AUTOSWAPSTREAM_LINK ) - { - maGraphic.SwapOutAsLink(); - } - else - { - bRet = bRet && maGraphic.SwapOut( pOStm ); - } - } - catch(...) - { - SAL_WARN( "svtools", "GraphicObject::SwapIn exception"); - } - return bRet; -} - -bool GraphicObject::SwapIn() -{ - bool bRet = false; - try - { - if( mbAutoSwapped ) - { - ImplAutoSwapIn(); - bRet = true; - } - else - { - bRet = maGraphic.SwapIn(); - } - - if( bRet ) - { - ImplAssignGraphicData(); - } - } - catch (...) - { - SAL_WARN( "svtools", "GraphicObject::SwapIn exception"); - } - - return bRet; -} - -void GraphicObject::SetSwapState() -{ - if( !IsSwappedOut() ) - { - mbAutoSwapped = true; - } -} - -IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl, Timer *, void) -{ - if( !IsSwappedOut() ) - { - mbIsInSwapOut = true; - - SvStream* pStream = GetSwapStream(); - - if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream ) - { - if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream ) - mbAutoSwapped = SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK ); - else - { - if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream ) - mbAutoSwapped = SwapOut(); - else - { - mbAutoSwapped = SwapOut( pStream ); - delete pStream; - } - } - } - - mbIsInSwapOut = false; - } - - if (mxSwapOutTimer) - mxSwapOutTimer->Start(); -} - bool GraphicObject::isGraphicObjectUniqueIdURL(OUString const & rURL) { const OUString aPrefix("vnd.sun.star.GraphicObject:"); |