Kaydet (Commit) 28bf1a3a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst f281d2d2
......@@ -37,7 +37,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/util/XUpdatable2.hpp>
#include <com/sun/star/qa/XDumper.hpp>
#include <vector>
......@@ -96,7 +96,7 @@ class ChartView : public ::cppu::WeakImplHelper10<
,::com::sun::star::lang::XUnoTunnel
,::com::sun::star::util::XModifyListener
,::com::sun::star::util::XModeChangeBroadcaster
,::com::sun::star::util::XUpdatable
,::com::sun::star::util::XUpdatable2
,::com::sun::star::beans::XPropertySet
,::com::sun::star::lang::XMultiServiceFactory
,::com::sun::star::qa::XDumper
......@@ -169,6 +169,10 @@ public:
// ::com::sun::star::util::XUpdatable
virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// util::XUpdatable2
virtual void SAL_CALL updateSoft() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL updateHard() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// ::com::sun::star::beans::XPropertySet
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
......@@ -217,7 +221,7 @@ private: //methods
void impl_refreshAddIn();
bool impl_AddInDrawsAllByItself();
void impl_updateView();
void impl_updateView( bool bCheckLockedCtrler = true );
void render();
......
......@@ -2627,7 +2627,7 @@ void SAL_CALL ChartView::disposing( const lang::EventObject& /* rSource */ )
{
}
void ChartView::impl_updateView()
void ChartView::impl_updateView( bool bCheckLockedCtrler )
{
if( !m_pDrawModelWrapper )
return;
......@@ -2638,7 +2638,7 @@ void ChartView::impl_updateView()
return;
}
if (mrChartModel.hasControllersLocked())
if (bCheckLockedCtrler && mrChartModel.hasControllersLocked())
return;
if( m_bViewDirty && !m_bInViewUpdate )
......@@ -2822,7 +2822,7 @@ void SAL_CALL ChartView::removeModeChangeApproveListener( const uno::Reference<
// ____ XUpdatable ____
void SAL_CALL ChartView::update() throw (uno::RuntimeException, std::exception)
{
impl_updateView();
impl_updateView(true);
//#i100778# migrate all imported or old documents to a plot area sizing exclusive axes (in case the save settings allow for this):
//Although in general it is a bad idea to change the model from within the view this is exceptionally the best place to do this special conversion.
......@@ -2833,6 +2833,16 @@ void SAL_CALL ChartView::update() throw (uno::RuntimeException, std::exception)
impl_updateView();
}
void SAL_CALL ChartView::updateSoft() throw (uno::RuntimeException, std::exception)
{
update();
}
void SAL_CALL ChartView::updateHard() throw (uno::RuntimeException, std::exception)
{
impl_updateView(false);
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL ChartView::getPropertySetInfo()
throw (uno::RuntimeException, std::exception)
......
......@@ -35,7 +35,7 @@ public:
static bool isGL3DDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram);
/// Use chart's XUpdatable::update() to update values.
static void updateChart(const css::uno::Reference< css::frame::XModel >& rXModel);
static void updateChart( const css::uno::Reference< css::frame::XModel >& rXModel, bool bHardUpdate );
// try to access rXModel in case of a chart to to get the chart content
// as sequence of primitives. Return range of primitives (chart size) in rRange;
......
......@@ -152,6 +152,8 @@ namespace sdr
// for 3D scenes
virtual drawinglayer::primitive2d::Primitive2DSequence embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const;
virtual basegfx::B2DRange getRange( const drawinglayer::geometry::ViewInformation2D& rViewInfo2D ) const;
// delete all existing VOCs including DrawHierarchy which will invalidate all
// visualisations, too. Used mostly at object removal from DrawHierarchy to
// delete all existing VOCs by purpose, but can also be used for other purposes.
......
......@@ -4138,6 +4138,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\
XURLTransformer \
XUniqueIDFactory \
XUpdatable \
XUpdatable2 \
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/view,\
DocumentZoomType \
......
/* -*- 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/.
*/
#ifndef __com_sun_star_util_XUpdatable2_idl__
#define __com_sun_star_util_XUpdatable2_idl__
#include <com/sun/star/util/XUpdatable.idl>
module com { module sun { module star { module util {
/**
* This interface extends XUpdatable in order to provide more fine-tuned
* update modes. When performing a <i>soft</i> update, the implementor may
* decide not to update in certain cases, such as when the controller is
* locked. When performing a <i>hard</i> update, on the other hand, the
* implementor should perform update more aggressively even when the
* controller is locked.
*/
interface XUpdatable2: com::sun::star::util::XUpdatable
{
/**
* Perform update, but update may not always be performed especially when
* the controller is locked.
*/
void updateSoft();
/**
* Perform update, even when the controller is locked.
*/
void updateHard();
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment