summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-01 14:20:00 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-07 16:45:51 +0200
commite98353c56efd45762a95d93e968685c10ec313a6 (patch)
treee9f185b01940e1f2f97d04857e10e2e9329580d6
parent0223781c3fa4f73985cf7aec58924f91c8963a75 (diff)
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
-rw-r--r--sw/inc/ndole.hxx9
-rw-r--r--sw/source/core/doc/notxtfrm.cxx37
-rw-r--r--sw/source/core/ole/ndole.cxx37
3 files changed, 61 insertions, 22 deletions
diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx
index b2787a393f78..7b98a33f0da4 100644
--- a/sw/inc/ndole.hxx
+++ b/sw/inc/ndole.hxx
@@ -41,6 +41,10 @@ class SW_DLLPUBLIC SwOLEObj
svt::EmbeddedObjectRef xOLERef;
OUString aName;
+ // eventually buffered data if it is a chart OLE
+ drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence;
+ basegfx::B2DRange m_aRange;
+
SwOLEObj( const SwOLEObj& rObj ) SAL_DELETED_FUNCTION;
void SetNode( SwOLENode* pNode );
@@ -62,6 +66,11 @@ public:
OUString GetCurrentPersistName() const { return aName; }
OUString GetStyleString();
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
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index d943e6dffeca..6d6f3940cdd3 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -69,7 +69,6 @@
#include <com/sun/star/embed/EmbedMisc.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
#include <svtools/embedhlp.hxx>
-#include <svx/charthelper.hxx>
#include <dview.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
@@ -999,29 +998,23 @@ void SwNoTextFrm::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfArea
if(bIsChart)
{
- const uno::Reference< frame::XModel > aXModel(pOLENd->GetOLEObj().GetOleRef()->getComponent(), uno::UNO_QUERY);
+ basegfx::B2DRange aSourceRange;
+ const drawinglayer::primitive2d::Primitive2DContainer aSequence(
+ pOLENd->GetOLEObj().tryToGetChartContentAsPrimitive2DSequence(
+ aSourceRange,
+ bPrn));
- if(aXModel.is())
+ if(!aSequence.empty() && !aSourceRange.isEmpty())
{
- basegfx::B2DRange aSourceRange;
-
- const drawinglayer::primitive2d::Primitive2DSequence aSequence(
- ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
- aXModel,
- aSourceRange));
-
- if(aSequence.hasElements() && !aSourceRange.isEmpty())
- {
- const basegfx::B2DRange aTargetRange(
- aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
- aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
-
- bDone = paintUsingPrimitivesHelper(
- *pOut,
- aSequence,
- aSourceRange,
- aTargetRange);
- }
+ const basegfx::B2DRange aTargetRange(
+ aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
+ aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+
+ bDone = paintUsingPrimitivesHelper(
+ *pOut,
+ aSequence,
+ aSourceRange,
+ aTargetRange);
}
}
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index c2bccbda314d..d7173d725f33 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -55,6 +55,7 @@
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/graphicfilter.hxx>
#include <comcore.hrc>
+#include <svx/charthelper.hxx>
#include <deque>
@@ -123,6 +124,10 @@ void SAL_CALL SwOLEListener_Impl::stateChanged( const lang::EventObject&, ::sal_
if (g_pOLELRU_Cache)
g_pOLELRU_Cache->RemoveObj( *mpObj );
}
+ else if(mpObj && nNewState == embed::EmbedStates::RUNNING)
+ {
+ mpObj->resetBufferedData();
+ }
}
void SwOLEListener_Impl::Release()
@@ -640,6 +645,8 @@ SwOLEObj::SwOLEObj( const svt::EmbeddedObjectRef& xObj ) :
pOLENd( 0 ),
pListener( 0 ),
xOLERef( xObj )
+ m_aPrimitive2DSequence(),
+ m_aRange()
{
xOLERef.Lock( true );
if ( xObj.is() )
@@ -654,6 +661,8 @@ SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
pOLENd( 0 ),
pListener( 0 ),
aName( rString )
+ m_aPrimitive2DSequence(),
+ m_aRange()
{
xOLERef.Lock( true );
xOLERef.SetViewAspect( nAspect );
@@ -900,6 +909,34 @@ OUString SwOLEObj::GetDescription()
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()
: utl::ConfigItem(OUString("Office.Common/Cache"))
, m_nLRU_InitSize( 20 )