diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-02 14:35:31 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-04 12:30:41 -0500 |
commit | 28bf1a3a1408df042d7e767c3760e47faf2d077e (patch) | |
tree | c4e3534682b14ae33f6e24a3cadd8f9c58fc4644 /svx | |
parent | f281d2d24c2a368c58d32b1b50acf83e0f056d90 (diff) |
Avoid re-constructing chart shapes when it's not in visible range.
The re-construction will be deferred until it becomes visible again.
Change-Id: I364ea8d38d48078dfd803b0e5bb20bfc8a2913ba
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/sdr/contact/viewcontactofsdrole2obj.hxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontact.cxx | 6 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrole2obj.cxx | 32 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontact.cxx | 29 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx | 12 | ||||
-rw-r--r-- | svx/source/svdraw/charthelper.cxx | 15 |
6 files changed, 79 insertions, 17 deletions
diff --git a/svx/inc/sdr/contact/viewcontactofsdrole2obj.hxx b/svx/inc/sdr/contact/viewcontactofsdrole2obj.hxx index fba70b22523e..29fc2dfa8092 100644 --- a/svx/inc/sdr/contact/viewcontactofsdrole2obj.hxx +++ b/svx/inc/sdr/contact/viewcontactofsdrole2obj.hxx @@ -69,6 +69,8 @@ namespace sdr // #i123539# get rid of buffered chart content (if there) on change virtual void ActionChanged() SAL_OVERRIDE; + virtual basegfx::B2DRange getRange( const drawinglayer::geometry::ViewInformation2D& rViewInfo2D ) const SAL_OVERRIDE; + protected: // This method is responsible for creating the graphical visualisation data // ONLY based on model data, just wraps to call createPrimitive2DSequenceWithParameters(false) diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 292bfba3c2bb..b4c4020d5387 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -308,6 +308,12 @@ namespace sdr return rSource; } + basegfx::B2DRange ViewContact::getRange( const drawinglayer::geometry::ViewInformation2D& /*rViewInfo2D*/ ) const + { + // Return empty range. + return basegfx::B2DRange(); + } + void ViewContact::flushViewObjectContacts(bool bWithHierarchy) { if(bWithHierarchy) diff --git a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx index f8fb29353c95..1704fdda6e1d 100644 --- a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx @@ -91,12 +91,11 @@ namespace sdr const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet(); // this may be refined more granular; if no content, attributes may get simpler - const bool bHasContent(true); const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( rItemSet, GetOle2Obj().getText(0), - bHasContent)); + true)); drawinglayer::primitive2d::Primitive2DReference xContent; if(GetOle2Obj().IsChart()) @@ -170,6 +169,35 @@ namespace sdr return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); } + basegfx::B2DRange ViewContactOfSdrOle2Obj::getRange( const drawinglayer::geometry::ViewInformation2D& rViewInfo2D ) const + { + // this may be refined more granular; if no content, attributes may get simpler + const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute = + drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( + GetOle2Obj().GetMergedItemSet(), + GetOle2Obj().getText(0), + true); + + basegfx::B2DHomMatrix aObjectMatrix = createObjectTransform(); + + drawinglayer::primitive2d::Primitive2DReference xContent = + new drawinglayer::primitive2d::SdrOleContentPrimitive2D( + GetOle2Obj(), + aObjectMatrix, + GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion()); + + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::SdrOle2Primitive2D( + drawinglayer::primitive2d::Primitive2DSequence(&xContent, 1), + aObjectMatrix, + aAttribute)); + + drawinglayer::primitive2d::Primitive2DSequence xSeq = + drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); + + return drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSeq, rViewInfo2D); + } + void ViewContactOfSdrOle2Obj::ActionChanged() { // call parent diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx index 140c5c8ba6fe..664f5b1fbded 100644 --- a/svx/source/sdr/contact/viewobjectcontact.cxx +++ b/svx/source/sdr/contact/viewobjectcontact.cxx @@ -206,15 +206,23 @@ const basegfx::B2DRange& ViewObjectContact::getObjectRange() const { if(maObjectRange.isEmpty()) { - // if range is not computed (new or LazyInvalidate objects), force it - const DisplayInfo aDisplayInfo; - const drawinglayer::primitive2d::Primitive2DSequence xSequence(getPrimitive2DSequence(aDisplayInfo)); - - if(xSequence.hasElements()) + const drawinglayer::geometry::ViewInformation2D& rViewInfo2D = GetObjectContact().getViewInformation2D(); + basegfx::B2DRange aTempRange = GetViewContact().getRange(rViewInfo2D); + if (!aTempRange.isEmpty()) { - const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); - const_cast< ViewObjectContact* >(this)->maObjectRange = - drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSequence, rViewInformation2D); + const_cast< ViewObjectContact* >(this)->maObjectRange = aTempRange; + } + else + { + // if range is not computed (new or LazyInvalidate objects), force it + const DisplayInfo aDisplayInfo; + const drawinglayer::primitive2d::Primitive2DSequence xSequence(getPrimitive2DSequence(aDisplayInfo)); + + if(xSequence.hasElements()) + { + const_cast< ViewObjectContact* >(this)->maObjectRange = + drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSequence, rViewInfo2D); + } } } @@ -257,7 +265,7 @@ void ViewObjectContact::triggerLazyInvalidate() // drawn by the drawinglayer ViewContactOfSdrOle2Obj* pViewContact = dynamic_cast<ViewContactOfSdrOle2Obj*>(&GetViewContact()); if (pViewContact && pViewContact->GetOle2Obj().IsReal3DChart()) - ChartHelper::updateChart(pViewContact->GetOle2Obj().getXModel()); + ChartHelper::updateChart(pViewContact->GetOle2Obj().getXModel(), false); #endif // force ObjectRange @@ -415,7 +423,8 @@ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2D const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport()); // check geometrical visibility - if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange)) + bool bVisible = aViewRange.isEmpty() || aViewRange.overlaps(aObjectRange); + if(!bVisible) { // not visible, release xRetval.realloc(0); diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx index 2273f4b434e2..0c9afc62db49 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx @@ -23,6 +23,7 @@ #include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <sdr/contact/objectcontactofpageview.hxx> +#include <sdr/contact/viewcontactofsdrole2obj.hxx> #include <svx/sdrpagewindow.hxx> #include <svx/sdrpaintwindow.hxx> #include <svx/svdobj.hxx> @@ -138,6 +139,17 @@ bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayIn } } + // Check if this object is in the visible range. + const drawinglayer::geometry::ViewInformation2D& rViewInfo = GetObjectContact().getViewInformation2D(); + basegfx::B2DRange aObjRange = GetViewContact().getRange(rViewInfo); + if (!aObjRange.isEmpty()) + { + const basegfx::B2DRange& rViewRange = rViewInfo.getViewport(); + bool bVisible = rViewRange.isEmpty() || rViewRange.overlaps(aObjRange); + if (!bVisible) + return false; + } + return true; } diff --git a/svx/source/svdraw/charthelper.cxx b/svx/source/svdraw/charthelper.cxx index 4965e073d53e..643a2be5cf1e 100644 --- a/svx/source/svdraw/charthelper.cxx +++ b/svx/source/svdraw/charthelper.cxx @@ -24,7 +24,7 @@ #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/util/XUpdatable2.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> @@ -67,7 +67,7 @@ bool ChartHelper::isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram return false; } -void ChartHelper::updateChart(const uno::Reference< ::frame::XModel >& rXModel) +void ChartHelper::updateChart( const uno::Reference< ::frame::XModel >& rXModel, bool bHardUpdate ) { if (!rXModel.is()) return; @@ -76,10 +76,15 @@ void ChartHelper::updateChart(const uno::Reference< ::frame::XModel >& rXModel) { const uno::Reference< lang::XMultiServiceFactory > xChartFact(rXModel, uno::UNO_QUERY_THROW); const uno::Reference< lang::XUnoTunnel > xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), uno::UNO_QUERY_THROW); - const uno::Reference< util::XUpdatable > xUpdatable(xChartView, uno::UNO_QUERY_THROW); + const uno::Reference<util::XUpdatable2> xUpdatable(xChartView, uno::UNO_QUERY_THROW); if (xUpdatable.is()) - xUpdatable->update(); + { + if (bHardUpdate) + xUpdatable->updateHard(); + else + xUpdatable->updateSoft(); + } } catch(uno::Exception&) { @@ -96,7 +101,7 @@ drawinglayer::primitive2d::Primitive2DSequence ChartHelper::tryToGetChartContent if (!rXModel.is()) return aRetval; - updateChart(rXModel); + updateChart(rXModel, true); try { |