tdf#50613 buffer OLE primitives for charts

If OLE is a chart, buffer the primitives used for presentation as
info at the SwOLEObj, after getting them the first time using the
ChartHelper.

Change-Id: I6d7486185f6eac450de9328d37ea800f424f351b
This commit is contained in:
Armin Le Grand
2016-07-01 14:20:00 +02:00
committed by Thorsten Behrens
parent 30fdc46969
commit 64e1113916
3 changed files with 61 additions and 23 deletions

View File

@@ -41,6 +41,10 @@ class SW_DLLPUBLIC SwOLEObj
svt::EmbeddedObjectRef xOLERef; svt::EmbeddedObjectRef xOLERef;
OUString aName; OUString aName;
// eventually buffered data if it is a chart OLE
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence;
basegfx::B2DRange m_aRange;
SwOLEObj( const SwOLEObj& rObj ) = delete; SwOLEObj( const SwOLEObj& rObj ) = delete;
void SetNode( SwOLENode* pNode ); void SetNode( SwOLENode* pNode );
@@ -62,6 +66,11 @@ public:
const OUString& GetCurrentPersistName() const { return aName; } const OUString& GetCurrentPersistName() const { return aName; }
OUString GetStyleString(); OUString GetStyleString();
bool IsOleRef() const; ///< To avoid unnecessary loading of object. bool IsOleRef() const; ///< To avoid unnecessary loading of object.
// try to get OLE visualization in form of a Primitive2DSequence
// and the corresponding B2DRange. This data may be locally buffered
drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange& rRange);
void resetBufferedData();
}; };
// SwOLENode // SwOLENode

View File

@@ -69,7 +69,6 @@
#include <com/sun/star/embed/EmbedMisc.hpp> #include <com/sun/star/embed/EmbedMisc.hpp>
#include <com/sun/star/embed/EmbedStates.hpp> #include <com/sun/star/embed/EmbedStates.hpp>
#include <svtools/embedhlp.hxx> #include <svtools/embedhlp.hxx>
#include <svx/charthelper.hxx>
#include <dview.hxx> #include <dview.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx>
@@ -998,16 +997,10 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfAr
bool bDone(false); bool bDone(false);
if(bIsChart) if(bIsChart)
{
const uno::Reference< frame::XModel > aXModel(pOLENd->GetOLEObj().GetOleRef()->getComponent(), uno::UNO_QUERY);
if(aXModel.is())
{ {
basegfx::B2DRange aSourceRange; basegfx::B2DRange aSourceRange;
const drawinglayer::primitive2d::Primitive2DContainer aSequence( const drawinglayer::primitive2d::Primitive2DContainer aSequence(
ChartHelper::tryToGetChartContentAsPrimitive2DSequence( pOLENd->GetOLEObj().tryToGetChartContentAsPrimitive2DSequence(
aXModel,
aSourceRange)); aSourceRange));
if(!aSequence.empty() && !aSourceRange.isEmpty()) if(!aSequence.empty() && !aSourceRange.isEmpty())
@@ -1023,7 +1016,6 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfAr
aTargetRange); aTargetRange);
} }
} }
}
if(!bDone && pOLENd) if(!bDone && pOLENd)
{ {

View File

@@ -56,6 +56,7 @@
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include <comcore.hrc> #include <comcore.hrc>
#include <svx/charthelper.hxx>
#include <deque> #include <deque>
@@ -124,6 +125,10 @@ void SAL_CALL SwOLEListener_Impl::stateChanged( const lang::EventObject&, ::sal_
if (g_pOLELRU_Cache) if (g_pOLELRU_Cache)
g_pOLELRU_Cache->RemoveObj( *mpObj ); g_pOLELRU_Cache->RemoveObj( *mpObj );
} }
else if(mpObj && nNewState == embed::EmbedStates::RUNNING)
{
mpObj->resetBufferedData();
}
} }
void SwOLEListener_Impl::Release() void SwOLEListener_Impl::Release()
@@ -640,7 +645,9 @@ bool SwOLENode::IsChart() const
SwOLEObj::SwOLEObj( const svt::EmbeddedObjectRef& xObj ) : SwOLEObj::SwOLEObj( const svt::EmbeddedObjectRef& xObj ) :
pOLENd( nullptr ), pOLENd( nullptr ),
pListener( nullptr ), pListener( nullptr ),
xOLERef( xObj ) xOLERef( xObj ),
m_aPrimitive2DSequence(),
m_aRange()
{ {
xOLERef.Lock(); xOLERef.Lock();
if ( xObj.is() ) if ( xObj.is() )
@@ -654,7 +661,9 @@ SwOLEObj::SwOLEObj( const svt::EmbeddedObjectRef& xObj ) :
SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) : SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
pOLENd( nullptr ), pOLENd( nullptr ),
pListener( nullptr ), pListener( nullptr ),
aName( rString ) aName( rString ),
m_aPrimitive2DSequence(),
m_aRange()
{ {
xOLERef.Lock(); xOLERef.Lock();
xOLERef.SetViewAspect( nAspect ); xOLERef.SetViewAspect( nAspect );
@@ -899,6 +908,34 @@ OUString SwOLEObj::GetDescription()
return SW_RESSTR(STR_OLE); return SW_RESSTR(STR_OLE);
} }
drawinglayer::primitive2d::Primitive2DContainer SwOLEObj::tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange& rRange)
{
if(m_aPrimitive2DSequence.empty() && m_aRange.isEmpty() && xOLERef.is() && xOLERef.IsChart())
{
const uno::Reference< frame::XModel > aXModel(xOLERef->getComponent(), uno::UNO_QUERY);
if(aXModel.is())
{
m_aPrimitive2DSequence = ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
aXModel,
m_aRange);
}
}
if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
{
rRange = m_aRange;
}
return m_aPrimitive2DSequence;
}
void SwOLEObj::resetBufferedData()
{
m_aPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer();
m_aRange.reset();
}
SwOLELRUCache::SwOLELRUCache() SwOLELRUCache::SwOLELRUCache()
: utl::ConfigItem(OUString("Office.Common/Cache")) : utl::ConfigItem(OUString("Office.Common/Cache"))
, m_nLRU_InitSize( 20 ) , m_nLRU_InitSize( 20 )