[Libreoffice-commits] core.git: Branch 'feature/perfwork4' - 2 commits - chart2/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Oct 17 14:34:08 PDT 2014
chart2/source/view/axes/Tickmarks.cxx | 29 ++++
chart2/source/view/axes/Tickmarks.hxx | 8 +
chart2/source/view/axes/VAxisBase.cxx | 25 +++
chart2/source/view/axes/VAxisBase.hxx | 9 +
chart2/source/view/axes/VCartesianAxis.cxx | 110 +++++++++++++----
chart2/source/view/axes/VCartesianAxis.hxx | 4
chart2/source/view/axes/VCartesianCoordinateSystem.cxx | 13 +-
chart2/source/view/axes/VCoordinateSystem.cxx | 7 -
8 files changed, 176 insertions(+), 29 deletions(-)
New commits:
commit 859cb431f1208142529af8f7166347d84e4f4e75
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 17 17:01:09 2014 -0400
Adjust text properties after adding a cached text object...
But it still doesn't work, and I have a feeling that this strategy will
not work without a huge amount of effort. I'll probably abandon it and
try something else.
Change-Id: Ic09b6e65abdd5595810b29c6ba7858cb5e7b31b5
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 968770d..6914ee0 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -103,6 +103,39 @@ Reference< drawing::XShape > createSingleLabel(
return xShape2DText;
}
+void adjustSingleLabel(
+ const Reference<drawing::XShape>& xShape, const awt::Point& rAnchorPos,
+ const AxisLabelProperties& rAxisLabelProps, const AxisProperties& rAxisProps,
+ const tNameSequence& rPropNames, const tAnySequence& rPropValues )
+{
+ if (!xShape.is())
+ return;
+
+ uno::Reference<beans::XPropertySet> xProp(xShape, uno::UNO_QUERY);
+ if (xProp.is())
+ {
+ //set properties
+ PropertyMapper::setMultiProperties(rPropNames, rPropValues, xProp);
+
+ //set position matrix
+ //the matrix needs to be set at the end behind autogrow and such position influencing properties
+ double fRotationAnglePi = rAxisLabelProps.fRotationAngleDegree * (F_PI / -180.0);
+ uno::Any aATransformation = AbstractShapeFactory::makeTransformation(rAnchorPos, fRotationAnglePi);
+ try
+ {
+ xProp->setPropertyValue("Transformation", aATransformation);
+ }
+ catch( const uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+
+ LabelPositionHelper::correctPositionForRotation(
+ xShape, rAxisProps.maLabelAlignment.meAlignment,
+ rAxisLabelProps.fRotationAngleDegree, rAxisProps.m_bComplexCategories);
+}
+
bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape
, double fRotationAngleDegree
, const basegfx::B2DVector& rTickScreenPosition
@@ -763,8 +796,12 @@ bool VCartesianAxis::createTextShapes(
uno::Reference<drawing::XShape> xCached = rTickIter.getTextShape();
if (xCached.is())
{
- xTarget->add(xCached);
pTickInfo->xTextShape = xCached;
+ xTarget->add(xCached);
+ adjustSingleLabel(
+ pTickInfo->xTextShape, aAnchorScreenPosition2D,
+ rAxisLabelProperties, m_aAxisProperties,
+ aPropNames, aPropValues);
}
else
{
commit b83a034b6977bd83057e14f06eb044659f9ca82e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 17 15:15:51 2014 -0400
More on caching axis label text shapes. Still disabled.
Lots of stuff is still not working....
Change-Id: Ib2548e912da75aa55bd215bf79a845331a6bad5f
diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx
index a8cd9a5..78fe7be 100644
--- a/chart2/source/view/axes/Tickmarks.cxx
+++ b/chart2/source/view/axes/Tickmarks.cxx
@@ -58,11 +58,18 @@ sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo
return nRet;
}
-PureTickIter::PureTickIter( TickInfoArrayType& rTickInfoVector )
- : m_rTickVector(rTickInfoVector)
- , m_aTickIter(m_rTickVector.begin())
+uno::Reference<drawing::XShape> TickIter::getTextShape()
{
+ return uno::Reference<drawing::XShape>();
}
+
+PureTickIter::PureTickIter( TickInfoArrayType& rTickInfoVector, const TickLabelArrayType* pLabels ) :
+ m_rTickVector(rTickInfoVector),
+ mpLabels(pLabels),
+ m_aTickIter(m_rTickVector.begin())
+{
+}
+
PureTickIter::~PureTickIter()
{
}
@@ -84,6 +91,22 @@ TickInfo* PureTickIter::nextInfo()
return 0;
}
+uno::Reference<drawing::XShape> PureTickIter::getTextShape()
+{
+ uno::Reference<drawing::XShape> xShape;
+ if (!mpLabels)
+ return xShape;
+
+ if (m_aTickIter == m_rTickVector.end())
+ return xShape;
+
+ size_t nPos = std::distance(m_rTickVector.begin(), m_aTickIter);
+ if (nPos >= mpLabels->size())
+ return xShape;
+
+ return (*mpLabels)[nPos];
+}
+
TickFactory::TickFactory(
const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement )
: m_rScale( rScale )
diff --git a/chart2/source/view/axes/Tickmarks.hxx b/chart2/source/view/axes/Tickmarks.hxx
index 15e83eb..352ef2a 100644
--- a/chart2/source/view/axes/Tickmarks.hxx
+++ b/chart2/source/view/axes/Tickmarks.hxx
@@ -56,24 +56,30 @@ private:
typedef std::vector<TickInfo> TickInfoArrayType;
typedef std::vector<TickInfoArrayType> TickInfoArraysType;
+typedef std::vector<css::uno::Reference<css::drawing::XShape> > TickLabelArrayType;
+typedef std::vector<TickLabelArrayType> TickLabelArraysType;
+
class TickIter
{
public:
virtual ~TickIter() {}
virtual TickInfo* firstInfo() = 0;
virtual TickInfo* nextInfo() = 0;
+ virtual css::uno::Reference<css::drawing::XShape> getTextShape();
};
class PureTickIter : public TickIter
{
public:
- PureTickIter( TickInfoArrayType& rTickInfoVector );
+ PureTickIter( TickInfoArrayType& rTickInfoVector, const TickLabelArrayType* pLabels );
virtual ~PureTickIter();
virtual TickInfo* firstInfo() SAL_OVERRIDE;
virtual TickInfo* nextInfo() SAL_OVERRIDE;
+ virtual css::uno::Reference<css::drawing::XShape> getTextShape() SAL_OVERRIDE;
private:
TickInfoArrayType& m_rTickVector;
+ const TickLabelArrayType* mpLabels;
TickInfoArrayType::iterator m_aTickIter;
};
diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx
index c391382..1524e77 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -49,6 +49,31 @@ VAxisBase::~VAxisBase()
{
}
+#if ENABLE_AXIS_SHAPE_CACHE
+void VAxisBase::reset()
+{
+}
+
+void VAxisBase::copyShapes( const VAxisBase& r )
+{
+ TickLabelArraysType aNewTickLabels;
+ TickInfoArraysType::const_iterator it = r.m_aAllTickInfos.begin(), itEnd = r.m_aAllTickInfos.end();
+ for (; it != itEnd; ++it)
+ {
+ aNewTickLabels.push_back(TickLabelArrayType());
+ TickLabelArrayType& rLabelArray = aNewTickLabels.back();
+ TickInfoArrayType::const_iterator it2 = it->begin(), it2End = it->end();
+ for (; it2 != it2End; ++it2)
+ {
+ const TickInfo& rOldTick = *it2;
+ rLabelArray.push_back(rOldTick.xTextShape);
+ }
+ }
+
+ m_aAllTickLabels.swap(aNewTickLabels);
+}
+#endif
+
void VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize
, const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels )
{
diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx
index d43ef58..980c170 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -22,6 +22,8 @@
#include "VAxisOrGridBase.hxx"
#include "VAxisProperties.hxx"
#include "Tickmarks.hxx"
+#include <macros.hxx>
+
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
namespace chart
@@ -39,6 +41,11 @@ public:
::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
virtual ~VAxisBase();
+#if ENABLE_AXIS_SHAPE_CACHE
+ void reset();
+ void copyShapes( const VAxisBase& r );
+#endif
+
/**
* Return the number of dimensions the diagram has. 2 for x and y, and 3
* for x, y, and z.
@@ -97,6 +104,8 @@ protected: //member
* which has multi-level axis labels.
*/
TickInfoArraysType m_aAllTickInfos;
+ TickLabelArraysType m_aAllTickLabels;
+
bool m_bReCreateAllTickInfos;
bool m_bRecordMaximumTextSize;
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index be13e64..968770d 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -218,7 +218,7 @@ private: //member
LabelIterator::LabelIterator( TickInfoArrayType& rTickInfoVector
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine )
- : m_aPureTickIter( rTickInfoVector )
+ : m_aPureTickIter(rTickInfoVector, NULL)
, m_eAxisLabelStaggering(eAxisLabelStaggering)
, m_bInnerLine(bInnerLine)
{
@@ -375,23 +375,25 @@ bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape )
class MaxLabelTickIter : public TickIter
{
public:
- MaxLabelTickIter( TickInfoArrayType& rTickInfoVector
- , sal_Int32 nLongestLabelIndex );
+ MaxLabelTickIter( TickInfoArrayType& rTickInfoVector, sal_Int32 nLongestLabelIndex, const TickLabelArrayType* pLabels );
virtual ~MaxLabelTickIter();
virtual TickInfo* firstInfo() SAL_OVERRIDE;
virtual TickInfo* nextInfo() SAL_OVERRIDE;
+ virtual uno::Reference<drawing::XShape> getTextShape() SAL_OVERRIDE;
private:
TickInfoArrayType& m_rTickInfoVector;
+ const TickLabelArrayType* mpTickLabels;
::std::vector< sal_Int32 > m_aValidIndices;
- sal_Int32 m_nCurrentIndex;
+ size_t m_nCurrentIndex;
};
-MaxLabelTickIter::MaxLabelTickIter( TickInfoArrayType& rTickInfoVector
- , sal_Int32 nLongestLabelIndex )
- : m_rTickInfoVector(rTickInfoVector)
- , m_nCurrentIndex(0)
+MaxLabelTickIter::MaxLabelTickIter(
+ TickInfoArrayType& rTickInfoVector, sal_Int32 nLongestLabelIndex, const TickLabelArrayType* pLabels ) :
+ m_rTickInfoVector(rTickInfoVector),
+ mpTickLabels(pLabels),
+ m_nCurrentIndex(0)
{
sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1;
if( nLongestLabelIndex<0 || nLongestLabelIndex>=nMaxIndex-1 )
@@ -415,7 +417,7 @@ MaxLabelTickIter::~MaxLabelTickIter()
TickInfo* MaxLabelTickIter::firstInfo()
{
m_nCurrentIndex = 0;
- if( m_nCurrentIndex < static_cast<sal_Int32>(m_aValidIndices.size()) )
+ if (m_nCurrentIndex < m_aValidIndices.size())
return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]];
return 0;
}
@@ -423,11 +425,23 @@ TickInfo* MaxLabelTickIter::firstInfo()
TickInfo* MaxLabelTickIter::nextInfo()
{
m_nCurrentIndex++;
- if( m_nCurrentIndex>=0 && m_nCurrentIndex<static_cast<sal_Int32>(m_aValidIndices.size()) )
+ if (m_nCurrentIndex < m_aValidIndices.size())
return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]];
return 0;
}
+uno::Reference<drawing::XShape> MaxLabelTickIter::getTextShape()
+{
+ uno::Reference<drawing::XShape> xShape;
+ if (!mpTickLabels)
+ return xShape;
+
+ if (m_nCurrentIndex >= mpTickLabels->size())
+ return xShape;
+
+ return (*mpTickLabels)[m_nCurrentIndex];
+}
+
bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
, bool bIsHorizontalAxis )
{
@@ -566,14 +580,19 @@ void VCartesianAxis::createAllTickInfos( TickInfoArraysType& rAllTickInfos )
VAxisBase::createAllTickInfos(rAllTickInfos);
}
-TickIter* VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel )
+TickIter* VCartesianAxis::createLabelTickIterator( size_t nTextLevel )
{
- if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) )
- return new PureTickIter( m_aAllTickInfos[nTextLevel] );
- return NULL;
+ if (nTextLevel >= m_aAllTickInfos.size())
+ return NULL;
+
+ const TickLabelArrayType* pLabels = NULL;
+ if (nTextLevel < m_aAllTickLabels.size())
+ pLabels = &m_aAllTickLabels[nTextLevel];
+
+ return new PureTickIter(m_aAllTickInfos[nTextLevel], pLabels);
}
-TickIter* VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel )
+TickIter* VCartesianAxis::createMaximumLabelTickIterator( size_t nTextLevel )
{
if( isComplexCategoryAxis() || isDateAxis() )
{
@@ -586,7 +605,8 @@ TickIter* VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel )
if( !m_aAllTickInfos.empty() )
{
sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
- return new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex );
+ const TickLabelArrayType* pLabels = m_aAllTickLabels.empty() ? NULL : &m_aAllTickLabels[0];
+ return new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex, pLabels );
}
}
}
@@ -739,10 +759,21 @@ bool VCartesianAxis::createTextShapes(
//create single label
if(!pTickInfo->xTextShape.is())
- pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget
- , aAnchorScreenPosition2D, aLabel
- , rAxisLabelProperties, m_aAxisProperties
- , aPropNames, aPropValues );
+ {
+ uno::Reference<drawing::XShape> xCached = rTickIter.getTextShape();
+ if (xCached.is())
+ {
+ xTarget->add(xCached);
+ pTickInfo->xTextShape = xCached;
+ }
+ else
+ {
+ pTickInfo->xTextShape = createSingleLabel(
+ m_xShapeFactory, xTarget, aAnchorScreenPosition2D, aLabel,
+ rAxisLabelProperties, m_aAxisProperties, aPropNames, aPropValues);
+ }
+ }
+
if(!pTickInfo->xTextShape.is())
continue;
@@ -1281,7 +1312,7 @@ void VCartesianAxis::hideIdenticalScreenValues( TickInfoArraysType& rTickInfos )
sal_Int32 nCount = rTickInfos.size();
for( sal_Int32 nN=0; nN<nCount; nN++ )
{
- PureTickIter aTickIter( rTickInfos[nN] );
+ PureTickIter aTickIter(rTickInfos[nN], NULL);
lcl_hideIdenticalScreenValues( aTickIter );
}
}
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index e3f26a8..ad94f76 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -47,8 +47,8 @@ public:
virtual void createAllTickInfos( TickInfoArraysType& rAllTickInfos ) SAL_OVERRIDE;
void createAllTickInfosFromComplexCategories( TickInfoArraysType& rAllTickInfos, bool bShiftedPosition );
- TickIter* createLabelTickIterator( sal_Int32 nTextLevel );
- TickIter* createMaximumLabelTickIterator( sal_Int32 nTextLevel );
+ TickIter* createLabelTickIterator( size_t nTextLevel );
+ TickIter* createMaximumLabelTickIterator( size_t nTextLevel );
sal_Int32 getTextLevelCount() const;
virtual TickFactory* createTickFactory() SAL_OVERRIDE;
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 79005bf..15730a7 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -99,7 +99,8 @@ void VCartesianCoordinateSystem::createVAxisList(
, const awt::Rectangle& rMaximumSpaceForLabels
)
{
- m_aAxisMap.clear();
+ tVAxisMap aOldAxisMap;
+ aOldAxisMap.swap(m_aAxisMap);
sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
bool bSwapXAndY = this->getPropertySwapXAndYAxis();
@@ -148,6 +149,16 @@ void VCartesianCoordinateSystem::createVAxisList(
::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
+
+#if ENABLE_AXIS_SHAPE_CACHE
+ tVAxisMap::iterator it = aOldAxisMap.find(aFullAxisIndex);
+ if (it != aOldAxisMap.end())
+ {
+ // Copy the text objects over.
+ apVAxis->copyShapes(*it->second);
+ }
+#endif
+
m_aAxisMap[aFullAxisIndex] = apVAxis;
apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos );
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 25b7149..690dde3 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -119,7 +119,12 @@ void VCoordinateSystem::reset()
m_apExplicitCategoriesProvider.reset();
- m_aAxisMap.clear(); // TODO : switch to reset() later.
+ tVAxisMap::iterator it = m_aAxisMap.begin(), itEnd = m_aAxisMap.end();
+ for (; it != itEnd; ++it)
+ {
+ VAxisBase& rAxis = *it->second;
+ rAxis.reset();
+ }
}
#endif
More information about the Libreoffice-commits
mailing list