[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2012-03-23 Thread Kohei Yoshida
 chart2/source/view/charttypes/Splines.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 62cd23f0cf538dccc30f1a38578d4c5925703029
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Fri Mar 23 22:54:12 2012 +0100

use fabs for double values, not abs, fdo#47632

Signed-off-by: Kohei Yoshida kohei.yosh...@gmail.com

diff --git a/chart2/source/view/charttypes/Splines.cxx 
b/chart2/source/view/charttypes/Splines.cxx
index 2005c1c..6c0c877 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -465,7 +465,7 @@ bool createParameterT(const tPointVecType aUniquePoints, 
double* t)
 {
 dx = aUniquePoints[i].first - aUniquePoints[i-1].first;
 dy = aUniquePoints[i].second - aUniquePoints[i-1].second;
-fDiffMax = (abs(dx)abs(dy)) ? abs(dx) : abs(dy);
+fDiffMax = (fabs(dx)fabs(dy)) ? fabs(dx) : fabs(dy);
 // same as above, so should not be zero
 dx /= fDiffMax;
 dy /= fDiffMax;
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2012-03-16 Thread Thorsten Behrens
 chart2/source/view/main/VLegendSymbolFactory.cxx |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 4ce99d42806e87378614207c8d5adf38d43c756c
Author: Katarina Machalkova bu...@bubli.org
Date:   Mon Feb 20 22:20:12 2012 +0100

fdo#31551: Show actual line width in the legend

however, limit the line width from above by legend entry height
(which +- matches the font height)

Signed-off-by: Thorsten Behrens tbehr...@suse.com

diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx 
b/chart2/source/view/main/VLegendSymbolFactory.cxx
index 31b2cbc..79db3c1 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -44,7 +44,8 @@ namespace
 void lcl_setPropetiesToShape(
 const Reference beans::XPropertySet   xProp,
 const Reference drawing::XShape   xShape,
-::chart::VLegendSymbolFactory::tPropertyType ePropertyType )
+::chart::VLegendSymbolFactory::tPropertyType ePropertyType,
+const awt::Size aMaxSymbolExtent = awt::Size(0,0))
 {
 const ::chart::tPropertyNameMap  aFilledSeriesNameMap( 
::chart::PropertyMapper::getPropertyNameMapForFilledSeriesProperties());
 const ::chart::tPropertyNameMap  aLineSeriesNameMap( 
::chart::PropertyMapper::getPropertyNameMapForLineSeriesProperties());
@@ -83,7 +84,8 @@ void lcl_setPropetiesToShape(
 sal_Int32 nLineWidth = 0;
 if( pLineWidthAny  (*pLineWidthAny=nLineWidth) )
 {
-const sal_Int32 nMaxLineWidthForLegend = 50;/*1/100 mm*///todo: 
make this dependent from legend entry height
+// use legend entry height as upper limit for line width
+sal_Int32 nMaxLineWidthForLegend = aMaxSymbolExtent.Height;
 if( nLineWidthnMaxLineWidthForLegend )
 *pLineWidthAny = uno::makeAny( nMaxLineWidthForLegend );
 }
@@ -134,7 +136,7 @@ Reference drawing::XShape  
VLegendSymbolFactory::createSymbol(
 xLine-setSize(  awt::Size( rEntryKeyAspectRatio.Width, 0 ));
 xLine-setPosition( awt::Point( 0, 
rEntryKeyAspectRatio.Height/2 ));
 
-lcl_setPropetiesToShape( xLegendEntryProperties, xLine, 
ePropertyType );
+lcl_setPropetiesToShape( xLegendEntryProperties, xLine, 
ePropertyType, rEntryKeyAspectRatio );
 }
 
 Reference drawing::XShape  xSymbol;
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2012-01-09 Thread Kohei Yoshida
 chart2/source/view/charttypes/VSeriesPlotter.cxx |  206 +--
 1 file changed, 161 insertions(+), 45 deletions(-)

New commits:
commit cbb7814247ad99eac2de0fac207774755bdfc2bd
Author: Kohei Yoshida kohei.yosh...@suse.com
Date:   Mon Jan 9 17:06:56 2012 -0500

fdo#44546: Hopefully correct automatic calculation of y-axis scale.

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index cd188b7..b3f2c5a 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -79,11 +79,12 @@
 #include svx/unoshape.hxx
 
 #include functional
+#include map
+
+#include boost/ptr_container/ptr_map.hpp
+
+namespace chart {
 
-//.
-namespace chart
-{
-//.
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::chart2;
 using ::com::sun::star::uno::Reference;
@@ -1500,6 +1501,142 @@ void VDataSeriesGroup::getMinimumAndMaximiumX( double 
rfMinimum, double rfMaxi
 ::rtl::math::setNan(rfMaximum);
 }
 
+namespace {
+
+/**
+ * Keep track of minimum and maximum Y values for one or more data series.
+ * When multiple data series exist, that indicates that the data series are
+ * stacked.
+ *
+ * pFor each X value, we calculate separate Y value ranges for each data
+ * series in the first pass.  In the second pass, we calculate the minimum Y
+ * value by taking the absolute minimum value of all data series, whereas
+ * the maxium Y value is the sum of all the series maximum Y values./p
+ *
+ * pOnce that's done for all X values, the final min / max Y values get
+ * calculated by taking the absolute min / max Y values across all the X
+ * values./p
+ */
+class PerXMinMaxCalculator
+{
+typedef std::pairdouble, double MinMaxType;
+typedef std::mapsize_t, MinMaxType SeriesMinMaxType;
+typedef boost::ptr_mapdouble, SeriesMinMaxType GroupMinMaxType;
+typedef boost::unordered_mapdouble, MinMaxType TotalStoreType;
+GroupMinMaxType maSeriesGroup;
+size_t mnCurSeries;
+
+public:
+PerXMinMaxCalculator() : mnCurSeries(0) {}
+
+void nextSeries() { ++mnCurSeries; }
+
+void setValue(double fX, double fY)
+{
+SeriesMinMaxType* pStore = getByXValue(fX); // get storage for given X 
value.
+if (!pStore)
+// This shouldn't happen!
+return;
+
+SeriesMinMaxType::iterator it = pStore-lower_bound(mnCurSeries);
+if (it != pStore-end()  !pStore-key_comp()(mnCurSeries, it-first))
+{
+MinMaxType r = it-second;
+// A min-max pair already exists for this series.  Update it.
+if (fY  r.first)
+r.first = fY;
+if (r.second  fY)
+r.second = fY;
+}
+else
+{
+// No existing pair. Insert a new one.
+pStore-insert(
+it, SeriesMinMaxType::value_type(
+mnCurSeries, MinMaxType(fY,fY)));
+}
+}
+
+void getTotalRange(double rfMin, double rfMax) const
+{
+rtl::math::setNan(rfMin);
+rtl::math::setNan(rfMax);
+
+TotalStoreType aStore;
+getTotalStore(aStore);
+
+if (aStore.empty())
+return;
+
+TotalStoreType::const_iterator it = aStore.begin(), itEnd = 
aStore.end();
+rfMin = it-second.first;
+rfMax = it-second.second;
+for (++it; it != itEnd; ++it)
+{
+if (rfMin  it-second.first)
+rfMin = it-second.first;
+if (rfMax  it-second.second)
+rfMax = it-second.second;
+}
+}
+
+private:
+/**
+ * Parse all data and reduce them into a set of global Y value ranges per
+ * X value.
+ */
+void getTotalStore(TotalStoreType rStore) const
+{
+TotalStoreType aStore;
+GroupMinMaxType::const_iterator it = maSeriesGroup.begin(), itEnd = 
maSeriesGroup.end();
+for (; it != itEnd; ++it)
+{
+double fX = it-first;
+
+const SeriesMinMaxType rSeries = *it-second;
+SeriesMinMaxType::const_iterator itSeries = rSeries.begin(), 
itSeriesEnd = rSeries.end();
+for (; itSeries != itSeriesEnd; ++itSeries)
+{
+double fYMin = itSeries-second.first, fYMax = 
itSeries-second.second;
+TotalStoreType::iterator itr = aStore.find(fX);
+if (itr == aStore.end())
+// New min-max pair for give X value.
+aStore.insert(
+TotalStoreType::value_type(fX, 
std::pairdouble,double(fYMin,fYMax)));
+else
+{
+MinMaxType r = itr-second;
+if (fYMin  r.first)
+r.first = 

[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2011-12-13 Thread Kohei Yoshida
 chart2/source/view/charttypes/VSeriesPlotter.cxx |   57 ---
 1 file changed, 42 insertions(+), 15 deletions(-)

New commits:
commit 37bcc2a18d598eb1c6218b10f64a49957d08c7c1
Author: Kohei Yoshida kohei.yosh...@suse.com
Date:   Tue Dec 13 19:46:31 2011 -0500

fdo#43681: Set correct auto scaling for stacked data series.

With this change, the automatic y-axis scaling should be more accurate
for stacked charts (i.e. stacked line, area, bar charts) with dates on
the x-axis.  The previous algorithm only calculated the max and min
y-values of the individual data, without taking into account the stacking
type when the x-axis type was date.

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index c7d4d9e..cd188b7 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1378,7 +1378,7 @@ void 
VSeriesPlotter::getMinimumAndMaximiumYInContinuousXRange( double rfMinY, d
 
 ::std::vector ::std::vector VDataSeriesGroup  ::const_iterator   
aZSlotIter = m_aZSlots.begin();
 const ::std::vector ::std::vector VDataSeriesGroup  ::const_iterator  
aZSlotEnd = m_aZSlots.end();
-for( ; aZSlotIter != aZSlotEnd; aZSlotIter++ )
+for( ; aZSlotIter != aZSlotEnd; ++aZSlotIter )
 {
 ::std::vector VDataSeriesGroup ::const_iterator  aXSlotIter = 
aZSlotIter-begin();
 const ::std::vector VDataSeriesGroup ::const_iterator aXSlotEnd = 
aZSlotIter-end();
@@ -1499,16 +1499,24 @@ void VDataSeriesGroup::getMinimumAndMaximiumX( double 
rfMinimum, double rfMaxi
 if(::rtl::math::isInf(rfMaximum))
 ::rtl::math::setNan(rfMaximum);
 }
-void VDataSeriesGroup::getMinimumAndMaximiumYInContinuousXRange( double 
rfMinY, double rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const
+
+void VDataSeriesGroup::getMinimumAndMaximiumYInContinuousXRange(
+double rfMinY, double rfMaxY, double fMinX, double fMaxX, sal_Int32 
nAxisIndex ) const
 {
-const ::std::vector VDataSeries* * pSeriesList = this-m_aSeriesVector;
+::rtl::math::setNan(rfMinY);
+::rtl::math::setNan(rfMaxY);
 
-::std::vector VDataSeries* ::const_iterator   aSeriesIter = 
pSeriesList-begin();
-const ::std::vector VDataSeries* ::const_iterator aSeriesEnd  = 
pSeriesList-end();
+if (m_aSeriesVector.empty())
+// No data series.  Bail out.
+return;
 
-::rtl::math::setInf(rfMinY, false);
-::rtl::math::setInf(rfMaxY, true);
+// Collect minimum y-value and accumulative maximum y-value for each
+// x-value first, in case of stacked data series.
+typedef boost::unordered_mapdouble, std::pairdouble,double  
MinMaxPerXType;
+MinMaxPerXType aStore;
 
+std::vectorVDataSeries*::const_iterator   aSeriesIter = 
m_aSeriesVector.begin();
+const std::vectorVDataSeries*::const_iterator aSeriesEnd  = 
m_aSeriesVector.end();
 for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
 {
 sal_Int32 nPointCount = (*aSeriesIter)-getTotalPointCount();
@@ -1525,16 +1533,35 @@ void 
VDataSeriesGroup::getMinimumAndMaximiumYInContinuousXRange( double rfMinY,
 double fY = (*aSeriesIter)-getYValue( nN );
 if( ::rtl::math::isNan(fY) )
 continue;
-if(rfMaxYfY)
-rfMaxY=fY;
-if(rfMinYfY)
-rfMinY=fY;
+
+MinMaxPerXType::iterator itr = aStore.find(fX);
+if (itr == aStore.end())
+aStore.insert(MinMaxPerXType::value_type(fX, 
std::pairdouble,double(fY, fY)));
+else
+{
+std::pairdouble,double r = itr-second;
+if (fY  r.first)
+r.first = fY; // min y-value
+
+r.second += fY; // accumulative max y-value.
+}
 }
 }
-if(::rtl::math::isInf(rfMinY))
-::rtl::math::setNan(rfMinY);
-if(::rtl::math::isInf(rfMaxY))
-::rtl::math::setNan(rfMaxY);
+
+if (aStore.empty())
+// No data within the specified x range.
+return;
+
+MinMaxPerXType::const_iterator itr = aStore.begin(), itrEnd = aStore.end();
+rfMinY = itr-second.first;
+rfMaxY = itr-second.second;
+for (++itr; itr != itrEnd; ++itr)
+{
+if (rfMinY  itr-second.first)
+rfMinY = itr-second.first;
+if (rfMaxY  itr-second.second)
+rfMaxY = itr-second.second;
+}
 }
 
 void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2011-12-12 Thread Markus Mohrhard
 chart2/source/view/axes/ScaleAutomatism.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 8216e8551dad8a3bbedb4b8e663b2d96570270a0
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Dec 12 23:51:48 2011 +0100

don't try to use Inf for axes calculation fdo#43703

diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx 
b/chart2/source/view/axes/ScaleAutomatism.cxx
index 2ac44fc..ba10366 100644
--- a/chart2/source/view/axes/ScaleAutomatism.cxx
+++ b/chart2/source/view/axes/ScaleAutomatism.cxx
@@ -909,6 +909,12 @@ void 
ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear(
 fDistanceNormalized = 1.0;
 fDistanceMagnitude = 1.0e-307;
 }
+else if ( !rtl::math::isFinite(fDistance) )
+{
+// fdo#43703: Handle values bigger than limits correctly
+fDistanceNormalized = 1.0;
+fDistanceMagnitude = std::numeric_limitsdouble::max();
+}
 else
 {
 // distance magnitude (a power of 10)
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-5' - chart2/source

2011-12-12 Thread Lionel Elie Mamane
 chart2/source/view/axes/ScaleAutomatism.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 893552129e0eb82c0bfbcac750a068258720adaf
Author: Lionel Elie Mamane lio...@mamane.lu
Date:   Tue Dec 13 04:15:27 2011 +0100

missing #include

diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx 
b/chart2/source/view/axes/ScaleAutomatism.cxx
index ba10366..896caf9 100644
--- a/chart2/source/view/axes/ScaleAutomatism.cxx
+++ b/chart2/source/view/axes/ScaleAutomatism.cxx
@@ -36,6 +36,7 @@
 
 #include rtl/math.hxx
 #include tools/debug.hxx
+#include limits
 
 //.
 namespace chart
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits