[Libreoffice-commits] core.git: 10 commits - chart2/source offapi/com
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Oct 9 13:35:56 PDT 2014
chart2/source/view/axes/Tickmarks.cxx | 20 +--
chart2/source/view/axes/Tickmarks.hxx | 6 -
chart2/source/view/axes/VAxisBase.cxx | 6 -
chart2/source/view/axes/VAxisBase.hxx | 2
chart2/source/view/axes/VAxisProperties.cxx | 15 --
chart2/source/view/axes/VAxisProperties.hxx | 17 +--
chart2/source/view/axes/VCartesianAxis.cxx | 138 +++++++++++----------------
chart2/source/view/axes/VCartesianAxis.hxx | 35 +++++-
chart2/source/view/axes/VPolarRadiusAxis.cxx | 2
chart2/source/view/diagram/VDiagram.cxx | 2
chart2/source/view/inc/PlotterBase.hxx | 2
chart2/source/view/inc/VDiagram.hxx | 5
offapi/com/sun/star/chart2/XScaling.idl | 29 +++--
13 files changed, 144 insertions(+), 135 deletions(-)
New commits:
commit c5cb66b537327247ebaf303951d718583de63710
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Oct 9 16:30:12 2014 -0400
B2DVector supports operator!=. Let's use it.
Change-Id: Iecf58e0f24909ec2fd2780a5f4b219105c7c4b47
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 48d5e89..5f5a35d 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -1258,19 +1258,15 @@ TickFactory2D* VCartesianAxis::createTickFactory2D()
void lcl_hideIdenticalScreenValues( TickIter& rTickIter )
{
- TickInfo* pPreviousTickInfo = rTickIter.firstInfo();
- if(!pPreviousTickInfo)
+ TickInfo* pPrevTickInfo = rTickIter.firstInfo();
+ if (!pPrevTickInfo)
return;
- pPreviousTickInfo->bPaintIt = true;
+
+ pPrevTickInfo->bPaintIt = true;
for( TickInfo* pTickInfo = rTickIter.nextInfo(); pTickInfo; pTickInfo = rTickIter.nextInfo())
{
- pTickInfo->bPaintIt =
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
- ||
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
- pPreviousTickInfo = pTickInfo;
+ pTickInfo->bPaintIt = (pTickInfo->aTickScreenPosition != pPrevTickInfo->aTickScreenPosition);
+ pPrevTickInfo = pTickInfo;
}
}
commit bd485290c77ce9b0a3a557513bf84817b48a5772
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Oct 9 12:33:15 2014 -0400
Make it clear which bounding rectangle it returns & const.
Change-Id: I9c8080225cfbe0f38133ce2503bd2d0c1d0f5e13
diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index 30913e2..bdbc3dd 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -675,7 +675,7 @@ void VDiagram::createShapes_3d()
adjustPosAndSize_3d( m_aAvailablePosIncludingAxes, m_aAvailableSizeIncludingAxes );
}
-::basegfx::B2IRectangle VDiagram::getCurrentRectangle()
+basegfx::B2IRectangle VDiagram::getCurrentRectangle() const
{
return BaseGFXHelper::makeRectangle(m_aCurrentPosWithoutAxes,m_aCurrentSizeWithoutAxes);
}
diff --git a/chart2/source/view/inc/VDiagram.hxx b/chart2/source/view/inc/VDiagram.hxx
index ecf6cf2..a57cc14 100644
--- a/chart2/source/view/inc/VDiagram.hxx
+++ b/chart2/source/view/inc/VDiagram.hxx
@@ -54,7 +54,10 @@ public: //methods
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
getCoordinateRegion() { return css::uno::Reference<css::drawing::XShapes>( m_xCoordinateRegionShape, css::uno::UNO_QUERY );}
- ::basegfx::B2IRectangle getCurrentRectangle();
+ /**
+ * Get current bounding rectangle for the diagram without axes.
+ */
+ basegfx::B2IRectangle getCurrentRectangle() const;
void reduceToMimimumSize();
commit 7df90ca4ddc3edd2df10a7d74772f0bea28d35c0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Oct 9 10:27:26 2014 -0400
Improve method descriptions.
Change-Id: I25074578607dedaec9689dff9a6bb9c2fa7be56b
diff --git a/offapi/com/sun/star/chart2/XScaling.idl b/offapi/com/sun/star/chart2/XScaling.idl
index 7d65c84..0daf41b 100644
--- a/offapi/com/sun/star/chart2/XScaling.idl
+++ b/offapi/com/sun/star/chart2/XScaling.idl
@@ -28,16 +28,27 @@ module com { module sun { module star { module chart2 {
interface XScaling : ::com::sun::star::uno::XInterface
{
- /** needs to keep relative ordering
- */
- double doScaling([in] double value);
+ /**
+ * Given a numeric value, return the scaled value that conforms
+ * to a predefined scaling rule. For instance, for linear
+ * scaling, given a x value, the method may return a y value as
+ * defined by y = Ax + B for predefined values of A and B.
+ *
+ * @param value input value from which to calculate the scaled
+ * value.
+ *
+ * @return scaled value based on a predefined scaling rule.
+ */
+ double doScaling( [in] double value );
+
+ /**
+ * Get an interface object that conforms to a scaling rule that
+ * is the reverse of the original scaling rule.
+ *
+ * @return internface object that represents the reversed
+ * scaling rule.
+ */
com::sun::star::chart2::XScaling getInverseScaling();
-
- //maybe provide correction for Min/Max
- //double getMinimum(); ?adjust <-> min/max may not exist
- //double getMaximum();
-
- //... or better/additionally?: provide default values for Min&Max
};
commit 877b66a00b1d6fe4f8ed2fc61774a240e653b49e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Oct 8 17:12:18 2014 -0400
xInverseScaling is set but not used. Remove it.
Change-Id: I1d185df4b14e152f4da9dfdbc2e71504c2cb1f3b
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 6867ab1..48d5e89 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -608,10 +608,6 @@ bool VCartesianAxis::createTextShapes(
, TickFactory2D* pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks )
{
- uno::Reference<chart2::XScaling> xInverseScaling(NULL);
- if( m_aScale.Scaling.is() )
- xInverseScaling = m_aScale.Scaling->getInverseScaling();
-
FixedNumberFormatter aFixedNumberFormatter(
m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey );
commit f602c74facc4c01daa068431dd1b0e973ac9047f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Oct 8 17:09:23 2014 -0400
Re-organize method / class descriptions.
Change-Id: Ib7fe33581c3aec2f58f8a16a07215b69080e0a51
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 0da7b5e..6867ab1 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -367,9 +367,13 @@ bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape )
return false;
}
+/**
+ * Iterate through only the first 2 and last 2 tick info items, and the tick
+ * that has the longest text (in terms of character length) in case it's not
+ * in the first or last 2 items.
+ */
class MaxLabelTickIter : public TickIter
{
- //iterate over first two and last two labels and the longest label
public:
MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector
, sal_Int32 nLongestLabelIndex );
@@ -604,10 +608,6 @@ bool VCartesianAxis::createTextShapes(
, TickFactory2D* pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks )
{
- //returns true if the text shapes have been created successfully
- //otherwise false - in this case the AxisLabelProperties have changed
- //and contain new instructions for the next try for text shape creation
-
uno::Reference<chart2::XScaling> xInverseScaling(NULL);
if( m_aScale.Scaling.is() )
xInverseScaling = m_aScale.Scaling->getInverseScaling();
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index 41d23b6..22a52e9 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -99,6 +99,12 @@ public:
};
protected: //methods
+ /**
+ * @return true if the text shapes have been successfully created,
+ * otherwise false. Returning false means the AxisLabelProperties
+ * have changed during the call, and the caller needs to call this
+ * method once again to get the text shapes created.
+ */
bool createTextShapes( const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShapes >& xTarget
, TickIter& rTickIter
commit 70ac6e7997a93631ee02a11b689529da21f3a6ab
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 7 22:27:53 2014 -0400
Make this data member const, as it never gets modified once constructed.
Change-Id: Ic01fd0591bbb524b4a6a0ec1dfe448e33f4d6b18
diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx
index 4cc8b6c..4395c78 100644
--- a/chart2/source/view/inc/PlotterBase.hxx
+++ b/chart2/source/view/inc/PlotterBase.hxx
@@ -82,7 +82,7 @@ protected: //member
AbstractShapeFactory* m_pShapeFactory;
OUString m_aCID;
- sal_Int32 m_nDimension;
+ const sal_Int32 m_nDimension;
// needs to be created and deleted by the derived class
PlottingPositionHelper* m_pPosHelper;
};
commit fd9151e1fe24c0f3ade2cf7a13e169f2601e65da
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 7 22:24:46 2014 -0400
TickFactory_2D -> TickFactory2D.
For consistent naming.
Change-Id: Ic94681d4d18c0330ea5a8393c1b3d863c81e1ea8
diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx
index 7dad991..0ab95cb 100644
--- a/chart2/source/view/axes/Tickmarks.cxx
+++ b/chart2/source/view/axes/Tickmarks.cxx
@@ -135,7 +135,7 @@ void TickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >
}
// ___TickFactory_2D___
-TickFactory_2D::TickFactory_2D(
+TickFactory2D::TickFactory2D(
const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement
//, double fStrech_SceneToScreen, double fOffset_SceneToScreen )
, const B2DVector& rStartScreenPos, const B2DVector& rEndScreenPos
@@ -164,21 +164,21 @@ TickFactory_2D::TickFactory_2D(
}
}
-TickFactory_2D::~TickFactory_2D()
+TickFactory2D::~TickFactory2D()
{
}
-bool TickFactory_2D::isHorizontalAxis() const
+bool TickFactory2D::isHorizontalAxis() const
{
return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() );
}
-bool TickFactory_2D::isVerticalAxis() const
+bool TickFactory2D::isVerticalAxis() const
{
return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() );
}
//static
-sal_Int32 TickFactory_2D::getTickScreenDistance( TickIter& rIter )
+sal_Int32 TickFactory2D::getTickScreenDistance( TickIter& rIter )
{
//return the positive distance between the two first tickmarks in screen values
//if there are less than two tickmarks -1 is returned
@@ -191,7 +191,7 @@ sal_Int32 TickFactory_2D::getTickScreenDistance( TickIter& rIter )
return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo );
}
-B2DVector TickFactory_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const
+B2DVector TickFactory2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const
{
B2DVector aRet(m_aAxisStartScreenPosition2D);
aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D)
@@ -199,7 +199,7 @@ B2DVector TickFactory_2D::getTickScreenPosition2D( double fScaledLogicTickValue
return aRet;
}
-void TickFactory_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints
+void TickFactory2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints
, sal_Int32 nSequenceIndex
, double fScaledLogicTickValue, double fInnerDirectionSign
, const TickmarkProperties& rTickmarkProperties
@@ -228,7 +228,7 @@ void TickFactory_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence
rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY());
}
-B2DVector TickFactory_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const
+B2DVector TickFactory2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const
{
bool bFarAwayLabels = false;
if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos
@@ -281,7 +281,7 @@ B2DVector TickFactory_2D::getDistanceAxisTickToText( const AxisProperties& rAxis
return aLabelDirection;
}
-void TickFactory_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const
+void TickFactory2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const
{
rPoints[0].realloc(2);
rPoints[0][0].X = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getX());
@@ -290,7 +290,7 @@ void TickFactory_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceS
rPoints[0][1].Y = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getY());
}
-void TickFactory_2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
+void TickFactory2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
{
//get the transformed screen values for all tickmarks in rAllTickInfos
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
diff --git a/chart2/source/view/axes/Tickmarks.hxx b/chart2/source/view/axes/Tickmarks.hxx
index 4952e64..411b80f 100644
--- a/chart2/source/view/axes/Tickmarks.hxx
+++ b/chart2/source/view/axes/Tickmarks.hxx
@@ -103,16 +103,16 @@ protected: //member
double m_fScaledVisibleMax;
};
-class TickFactory_2D : public TickFactory
+class TickFactory2D : public TickFactory
{
public:
- TickFactory_2D(
+ TickFactory2D(
const ExplicitScaleData& rScale
, const ExplicitIncrementData& rIncrement
, const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos
, const ::basegfx::B2DVector& rAxisLineToLabelLineShift );
//, double fStrech_SceneToScreen, double fOffset_SceneToScreen );
- virtual ~TickFactory_2D();
+ virtual ~TickFactory2D();
static sal_Int32 getTickScreenDistance( TickIter& rIter );
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index c9c35ad..0da7b5e 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -601,7 +601,7 @@ bool VCartesianAxis::createTextShapes(
const Reference< drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickFactory_2D* pTickFactory
+ , TickFactory2D* pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks )
{
//returns true if the text shapes have been created successfully
@@ -1249,7 +1249,7 @@ TickFactory* VCartesianAxis::createTickFactory()
return createTickFactory2D();
}
-TickFactory_2D* VCartesianAxis::createTickFactory2D()
+TickFactory2D* VCartesianAxis::createTickFactory2D()
{
B2DVector aStart, aEnd;
get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
@@ -1257,7 +1257,7 @@ TickFactory_2D* VCartesianAxis::createTickFactory2D()
B2DVector aLabelLineStart, aLabelLineEnd;
get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, getLabelLineIntersectionValue() );
- return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
+ return new TickFactory2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
void lcl_hideIdenticalScreenValues( TickIter& rTickIter )
@@ -1327,7 +1327,7 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
return nRet;
}
-void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickFactory_2D* pTickFactory2D )
+void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickFactory2D* pTickFactory2D )
{
if( !pTickFactory2D )
return;
@@ -1376,8 +1376,8 @@ void VCartesianAxis::createLabels()
if (!m_aAxisProperties.m_bDisplayLabels)
return;
- boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
- TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
+ boost::scoped_ptr< TickFactory2D > apTickFactory2D( this->createTickFactory2D() );
+ TickFactory2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
@@ -1398,7 +1398,7 @@ void VCartesianAxis::createLabels()
{
if(nTextLevel==0)
{
- nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() );
+ nScreenDistanceBetweenTicks = TickFactory2D::getTickScreenDistance( *apTickIter.get() );
if( nTextLevelCount>1 )
nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
}
@@ -1430,8 +1430,8 @@ void VCartesianAxis::createMaximumLabels()
if (!m_aAxisProperties.m_bDisplayLabels)
return;
- boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
- TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
+ boost::scoped_ptr< TickFactory2D > apTickFactory2D( this->createTickFactory2D() );
+ TickFactory2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
@@ -1467,8 +1467,8 @@ void VCartesianAxis::updatePositions()
if (!m_aAxisProperties.m_bDisplayLabels)
return;
- boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
- TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
+ boost::scoped_ptr< TickFactory2D > apTickFactory2D( this->createTickFactory2D() );
+ TickFactory2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
@@ -1532,7 +1532,7 @@ void VCartesianAxis::updatePositions()
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
}
-void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels )
+void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory2D& rTickFactory2D, bool bOnlyAtLabels )
{
sal_Int32 nPointCount = rTickInfos.size();
drawing::PointSequenceSequence aPoints(2*nPointCount);
@@ -1568,8 +1568,8 @@ void VCartesianAxis::createShapes()
if( !prepareShapeCreation() )
return;
- boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
- TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
+ boost::scoped_ptr< TickFactory2D > apTickFactory2D( this->createTickFactory2D() );
+ TickFactory2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index 2f320f3..41d23b6 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -103,16 +103,16 @@ protected: //methods
::com::sun::star::drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickFactory_2D* pTickFactory
+ , TickFactory2D* pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks );
- void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels );
+ void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory2D& rTickFactory2D, bool bOnlyAtLabels );
- TickFactory_2D* createTickFactory2D();
+ TickFactory2D* createTickFactory2D();
void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const;
void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties
- , TickFactory_2D* pTickFactory2D );
+ , TickFactory2D* pTickFactory2D );
bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
, bool bIsHorizontalAxis, bool bIsVerticalAxis );
bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis );
commit a66ab02f04e2541e457f72cb0580b1c226ebd79d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 7 22:22:54 2014 -0400
Make thie method consistent with the others.
Change-Id: I028f0dd833cb2307e842805636458f51c71dbd66
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index c5f0bc9..c9c35ad 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -847,17 +847,22 @@ double VCartesianAxis::getLabelLineIntersectionValue() const
return getAxisIntersectionValue();
}
-bool VCartesianAxis::getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis ) const
+double VCartesianAxis::getExtraLineIntersectionValue() const
{
+ double fNan;
+ rtl::math::setNan(&fNan);
+
if( !m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
- return false;
+ return fNan;
+
double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
+
if( *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin
|| *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax )
- return false;
- fCrossesOtherAxis = *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis;
- return true;
+ return fNan;
+
+ return *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis;
}
B2DVector VCartesianAxis::getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const
@@ -1640,8 +1645,8 @@ void VCartesianAxis::createShapes()
//create an additional line at NULL
if( !AxisHelper::isAxisPositioningEnabled() )
{
- double fExtraLineCrossesOtherAxis;
- if( getLogicValueWhereExtraLineCrossesOtherAxis(fExtraLineCrossesOtherAxis) )
+ double fExtraLineCrossesOtherAxis = getExtraLineIntersectionValue();
+ if (!rtl::math::isNan(fExtraLineCrossesOtherAxis))
{
B2DVector aStart, aEnd;
this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis );
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index 757fd1a..2f320f3 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -63,7 +63,14 @@ public:
*/
double getLabelLineIntersectionValue() const;
- bool getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis) const;
+ /**
+ * Get the value at which extra line crosses the other axis.
+ *
+ * @return a NaN if the line doesn't cross the other axis, a non-NaN value
+ * otherwise.
+ */
+ double getExtraLineIntersectionValue() const;
+
void get2DAxisMainLine( ::basegfx::B2DVector& rStart, ::basegfx::B2DVector& rEnd, double fCrossesOtherAxis );
//Layout interface for cartesian axes:
commit 4dfd8ba4ab9e5375edb3ce9a8de30bc0240f31ff
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 7 22:13:48 2014 -0400
Simplify AxisProperties and its surrounding code.
Change-Id: Ie47421d778c2beb8eb8e132532220054f183a5f1
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index 860aa6a..6ad35c5 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -86,15 +86,15 @@ struct AxisLabelProperties
struct AxisProperties
{
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > m_xAxisModel;
+ css::uno::Reference<css::chart2::XAxis> m_xAxisModel;
sal_Int32 m_nDimensionIndex;
bool m_bIsMainAxis;//not secondary axis
bool m_bSwapXAndY;
- ::com::sun::star::chart::ChartAxisPosition m_eCrossoverType;
- ::com::sun::star::chart::ChartAxisLabelPosition m_eLabelPos;
- ::com::sun::star::chart::ChartAxisMarkPosition m_eTickmarkPos;
+ css::chart::ChartAxisPosition m_eCrossoverType;
+ css::chart::ChartAxisLabelPosition m_eLabelPos;
+ css::chart::ChartAxisMarkPosition m_eTickmarkPos;
boost::optional<double> m_pfMainLinePositionAtOtherAxis;
boost::optional<double> m_pfExrtaLinePositionAtOtherAxis;
@@ -125,9 +125,7 @@ struct AxisProperties
sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
bool m_bComplexCategories;
ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence >
- m_xAxisTextProvider; //for categories or series names
+ css::uno::Reference<css::chart2::data::XTextualDataSequence> m_xAxisTextProvider; //for categories or series names
//<- category axes
//methods:
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index dfd87f2..c5f0bc9 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -49,16 +49,14 @@
#include <basegfx/polygon/b2dpolygonclipper.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
-namespace chart
-{
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
-using namespace ::rtl::math;
-using ::basegfx::B2DVector;
using ::com::sun::star::uno::Reference;
+using ::basegfx::B2DVector;
using ::basegfx::B2DPolygon;
using ::basegfx::B2DPolyPolygon;
+namespace chart {
+
VCartesianAxis::VCartesianAxis( const AxisProperties& rAxisProperties
, const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
, sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
@@ -610,7 +608,7 @@ bool VCartesianAxis::createTextShapes(
//otherwise false - in this case the AxisLabelProperties have changed
//and contain new instructions for the next try for text shape creation
- Reference< XScaling > xInverseScaling( NULL );
+ uno::Reference<chart2::XScaling> xInverseScaling(NULL);
if( m_aScale.Scaling.is() )
xInverseScaling = m_aScale.Scaling->getInverseScaling();
@@ -827,37 +825,26 @@ drawing::PointSequenceSequence lcl_makePointSequence( B2DVector& rStart, B2DVect
return aPoints;
}
-double VCartesianAxis::getLogicValueWhereMainLineCrossesOtherAxis() const
+double VCartesianAxis::getAxisIntersectionValue() const
{
+ if (m_aAxisProperties.m_pfMainLinePositionAtOtherAxis)
+ return *m_aAxisProperties.m_pfMainLinePositionAtOtherAxis;
+
double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
- double fCrossesOtherAxis;
- if(m_aAxisProperties.m_pfMainLinePositionAtOtherAxis)
- fCrossesOtherAxis = *m_aAxisProperties.m_pfMainLinePositionAtOtherAxis;
- else
- {
- if( ::com::sun::star::chart::ChartAxisPosition_END == m_aAxisProperties.m_eCrossoverType )
- fCrossesOtherAxis = fMax;
- else
- fCrossesOtherAxis = fMin;
- }
- return fCrossesOtherAxis;
+ return (css::chart::ChartAxisPosition_END == m_aAxisProperties.m_eCrossoverType) ? fMax : fMin;
}
-double VCartesianAxis::getLogicValueWhereLabelLineCrossesOtherAxis() const
+double VCartesianAxis::getLabelLineIntersectionValue() const
{
- double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
- double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
+ if (css::chart::ChartAxisLabelPosition_OUTSIDE_START == m_aAxisProperties.m_eLabelPos)
+ return (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
- double fCrossesOtherAxis;
- if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == m_aAxisProperties.m_eLabelPos )
- fCrossesOtherAxis = fMin;
- else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == m_aAxisProperties.m_eLabelPos )
- fCrossesOtherAxis = fMax;
- else
- fCrossesOtherAxis = getLogicValueWhereMainLineCrossesOtherAxis();
- return fCrossesOtherAxis;
+ if (css::chart::ChartAxisLabelPosition_OUTSIDE_END == m_aAxisProperties.m_eLabelPos)
+ return (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
+
+ return getAxisIntersectionValue();
}
bool VCartesianAxis::getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis ) const
@@ -1207,8 +1194,8 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
- if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
- ( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
+ if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
+ ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
@@ -1225,8 +1212,8 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
- if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
- ( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
+ if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
+ ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
@@ -1243,8 +1230,8 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
- if( ( fDeltaX>0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
- ( fDeltaX<0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
+ if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
+ ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_TOP ) ?
LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
@@ -1260,10 +1247,10 @@ TickFactory* VCartesianAxis::createTickFactory()
TickFactory_2D* VCartesianAxis::createTickFactory2D()
{
B2DVector aStart, aEnd;
- this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() );
+ get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
B2DVector aLabelLineStart, aLabelLineEnd;
- this->get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, this->getLogicValueWhereLabelLineCrossesOtherAxis() );
+ get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, getLabelLineIntersectionValue() );
return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
@@ -1313,7 +1300,7 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
return nRet;
B2DVector aStart, aEnd;
- this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() );
+ this->get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
sal_Int32 nMaxHeight = static_cast<sal_Int32>(fabs(aEnd.getY()-aStart.getY()));
sal_Int32 nMaxWidth = static_cast<sal_Int32>(fabs(aEnd.getX()-aStart.getX()));
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index b5122d9..757fd1a 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -53,8 +53,16 @@ public:
virtual TickFactory* createTickFactory() SAL_OVERRIDE;
- double getLogicValueWhereMainLineCrossesOtherAxis() const;
- double getLogicValueWhereLabelLineCrossesOtherAxis() const;
+ /**
+ * Get the value at which the other axis crosses.
+ */
+ double getAxisIntersectionValue() const;
+
+ /**
+ * Get the value at which label line crosses the other axis.
+ */
+ double getLabelLineIntersectionValue() const;
+
bool getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis) const;
void get2DAxisMainLine( ::basegfx::B2DVector& rStart, ::basegfx::B2DVector& rEnd, double fCrossesOtherAxis );
commit d7e477c4518bb3f638af59fa48cae04eba8c76cc
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 7 20:38:56 2014 -0400
Use boost::optional for these members.
Change-Id: I60c52bf99d0e63e27f7c576e2582c26e19809c8c
diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx
index 15f75ca..94f3799 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -111,11 +111,9 @@ sal_Int32 VAxisBase::estimateMaximumAutoMainIncrementCount()
return 10;
}
-void VAxisBase::setExrtaLinePositionAtOtherAxis( const double& fCrossingAt )
+void VAxisBase::setExrtaLinePositionAtOtherAxis( double fCrossingAt )
{
- if( m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
- delete m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis;
- m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = new double(fCrossingAt);
+ m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis.reset(fCrossingAt);
}
sal_Int32 VAxisBase::getDimensionCount() const
diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx
index cc2ef58..b27c604 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -62,7 +62,7 @@ public:
virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
- void setExrtaLinePositionAtOtherAxis( const double& fCrossingAt );
+ void setExrtaLinePositionAtOtherAxis( double fCrossingAt );
protected: //methods
sal_Int32 getIndexOfLongestLabel( const ::com::sun::star::uno::Sequence< OUString >& rLabels );
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index e6fb154..ec63826 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -156,8 +156,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
, m_eCrossoverType( ::com::sun::star::chart::ChartAxisPosition_ZERO )
, m_eLabelPos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS )
, m_eTickmarkPos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
- , m_pfMainLinePositionAtOtherAxis(NULL)
- , m_pfExrtaLinePositionAtOtherAxis(NULL)
, m_bCrossingAxisHasReverseDirection(false)
, m_bCrossingAxisIsCategoryAxes(false)
, m_fLabelDirectionSign(1.0)
@@ -184,9 +182,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_bSwapXAndY( rAxisProperties.m_bSwapXAndY )
, m_eCrossoverType( rAxisProperties.m_eCrossoverType )
, m_eLabelPos( rAxisProperties.m_eLabelPos )
- , m_eTickmarkPos( rAxisProperties.m_eTickmarkPos )
- , m_pfMainLinePositionAtOtherAxis( NULL )
- , m_pfExrtaLinePositionAtOtherAxis( NULL )
, m_bCrossingAxisHasReverseDirection( rAxisProperties.m_bCrossingAxisHasReverseDirection )
, m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes )
, m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign )
@@ -205,15 +200,13 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_xAxisTextProvider( rAxisProperties.m_xAxisTextProvider )
{
if( rAxisProperties.m_pfMainLinePositionAtOtherAxis )
- m_pfMainLinePositionAtOtherAxis = new double(*rAxisProperties.m_pfMainLinePositionAtOtherAxis);
+ m_pfMainLinePositionAtOtherAxis.reset(*rAxisProperties.m_pfMainLinePositionAtOtherAxis);
if( rAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
- m_pfExrtaLinePositionAtOtherAxis = new double (*rAxisProperties.m_pfExrtaLinePositionAtOtherAxis);
+ m_pfExrtaLinePositionAtOtherAxis.reset(*rAxisProperties.m_pfExrtaLinePositionAtOtherAxis);
}
AxisProperties::~AxisProperties()
{
- delete m_pfMainLinePositionAtOtherAxis;
- delete m_pfExrtaLinePositionAtOtherAxis;
}
LabelAlignment lcl_getLabelAlignmentForZAxis( const AxisProperties& rAxisProperties )
@@ -256,10 +249,10 @@ void AxisProperties::initAxisPositioning( const uno::Reference< beans::XProperty
if( m_bCrossingAxisIsCategoryAxes )
fValue = ::rtl::math::round(fValue);
- m_pfMainLinePositionAtOtherAxis = new double(fValue);
+ m_pfMainLinePositionAtOtherAxis.reset(fValue);
}
else if( ::com::sun::star::chart::ChartAxisPosition_ZERO == m_eCrossoverType )
- m_pfMainLinePositionAtOtherAxis = new double(0.0);
+ m_pfMainLinePositionAtOtherAxis.reset(0.0);
xAxisProp->getPropertyValue("LabelPosition") >>= m_eLabelPos;
xAxisProp->getPropertyValue("MarkPosition") >>= m_eTickmarkPos;
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index bf4a508..860aa6a 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -37,6 +37,7 @@
#include <com/sun/star/lang/Locale.hpp>
#include <vector>
+#include <boost/optional.hpp>
namespace chart
{
@@ -95,8 +96,8 @@ struct AxisProperties
::com::sun::star::chart::ChartAxisLabelPosition m_eLabelPos;
::com::sun::star::chart::ChartAxisMarkPosition m_eTickmarkPos;
- double* m_pfMainLinePositionAtOtherAxis;
- double* m_pfExrtaLinePositionAtOtherAxis;
+ boost::optional<double> m_pfMainLinePositionAtOtherAxis;
+ boost::optional<double> m_pfExrtaLinePositionAtOtherAxis;
bool m_bCrossingAxisHasReverseDirection;
bool m_bCrossingAxisIsCategoryAxes;
diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx
index 4b6d8e2..4d89d26 100644
--- a/chart2/source/view/axes/VPolarRadiusAxis.cxx
+++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx
@@ -152,7 +152,7 @@ void VPolarRadiusAxis::createShapes()
}
//xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
- aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() );
+ aAxisProperties.m_pfMainLinePositionAtOtherAxis.reset(pTickInfo->getUnscaledTickValue());
aAxisProperties.m_bDisplayLabels=false;
VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier
More information about the Libreoffice-commits
mailing list