[Libreoffice-commits] core.git: Branch 'private/kohei/new-chart-type-skeleton' - 2 commits - chart2/Library_chartcore.mk chart2/source sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Mar 24 14:49:18 PDT 2014


 chart2/Library_chartcore.mk                               |    1 
 chart2/source/chartcore.component                         |    4 +
 chart2/source/model/template/GL3DBarChartType.cxx         |   12 ++-
 chart2/source/model/template/GL3DBarChartType.hxx         |    2 
 chart2/source/model/template/GL3DBarChartTypeTemplate.cxx |   25 +++++++
 chart2/source/model/template/GL3DBarChartTypeTemplate.hxx |    2 
 chart2/source/view/charttypes/AreaChart.cxx               |    2 
 chart2/source/view/charttypes/GL3DBarChart.cxx            |   29 +++++++++
 chart2/source/view/charttypes/GL3DBarChart.hxx            |   30 +++++++++
 chart2/source/view/charttypes/VSeriesPlotter.cxx          |   15 ++++
 chart2/source/view/main/PlotterBase.cxx                   |    6 +
 sc/source/ui/view/output2.cxx                             |   44 --------------
 12 files changed, 121 insertions(+), 51 deletions(-)

New commits:
commit 6818fa42eb96aba5d9f34f1b15d7c3804ca78e6e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Mar 24 17:47:01 2014 -0400

    Add a new skeleton plotter for the GL3D bar chart.
    
    It plots absolutely nothing. It's just a place holder for now.
    
    Change-Id: I6eb9cc23481391b83f6946a8b49a6176c5b29cd7

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 63171f4..6dafd71 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/view/charttypes/BubbleChart \
     chart2/source/view/charttypes/CandleStickChart \
     chart2/source/view/charttypes/CategoryPositionHelper \
+    chart2/source/view/charttypes/GL3DBarChart \
     chart2/source/view/charttypes/NetChart \
     chart2/source/view/charttypes/PieChart \
     chart2/source/view/charttypes/Splines \
diff --git a/chart2/source/chartcore.component b/chart2/source/chartcore.component
index 5df1a18..4029670 100644
--- a/chart2/source/chartcore.component
+++ b/chart2/source/chartcore.component
@@ -101,6 +101,10 @@
     <service name="com.sun.star.chart2.BubbleChartType"/>
     <service name="com.sun.star.chart2.ChartType"/>
   </implementation>
+  <implementation name="com.sun.star.comp.chart.GL3DBarChartType">
+    <service name="com.sun.star.chart2.GL3DBarChartType"/>
+    <service name="com.sun.star.chart2.ChartType"/>
+  </implementation>
   <implementation name="com.sun.star.comp.chart.CandleStickChartType">
     <service name="com.sun.star.beans.PropertySet"/>
     <service name="com.sun.star.chart2.CandleStickChartType"/>
diff --git a/chart2/source/model/template/GL3DBarChartType.cxx b/chart2/source/model/template/GL3DBarChartType.cxx
index 1dd889d..033c38c 100644
--- a/chart2/source/model/template/GL3DBarChartType.cxx
+++ b/chart2/source/model/template/GL3DBarChartType.cxx
@@ -15,7 +15,14 @@ using namespace com::sun::star;
 namespace chart {
 
 GL3DBarChartType::GL3DBarChartType( const uno::Reference<uno::XComponentContext>& xContext ) :
-    ChartType(xContext) {}
+    ChartType(xContext)
+{
+}
+
+GL3DBarChartType::GL3DBarChartType( const GL3DBarChartType& rOther ) :
+    ChartType(rOther)
+{
+}
 
 GL3DBarChartType::~GL3DBarChartType() {}
 
@@ -30,9 +37,6 @@ uno::Sequence<OUString> GL3DBarChartType::getSupportedServiceNames_Static()
     return aServices;
 }
 
-GL3DBarChartType::GL3DBarChartType( const GL3DBarChartType& rOther ) :
-    ChartType(rOther) {}
-
 OUString SAL_CALL GL3DBarChartType::getChartType()
         throw (::com::sun::star::uno::RuntimeException, std::exception)
 {
diff --git a/chart2/source/model/template/GL3DBarChartType.hxx b/chart2/source/model/template/GL3DBarChartType.hxx
index 4951050..ee9d0ab 100644
--- a/chart2/source/model/template/GL3DBarChartType.hxx
+++ b/chart2/source/model/template/GL3DBarChartType.hxx
@@ -22,7 +22,7 @@ namespace chart {
 class GL3DBarChartType : public ChartType
 {
 public:
-    GL3DBarChartType( const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext );
+    GL3DBarChartType( const css::uno::Reference<css::uno::XComponentContext>& xContext );
     virtual ~GL3DBarChartType();
 
     APPHELPER_XSERVICEINFO_DECL()
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
index 262828c..e65c8f5 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
@@ -8,6 +8,8 @@
  */
 
 #include "GL3DBarChartTypeTemplate.hxx"
+#include "GL3DBarChartType.hxx"
+
 #include <servicenames_charttypes.hxx>
 #include <macros.hxx>
 
@@ -15,6 +17,12 @@ using namespace com::sun::star;
 
 namespace chart {
 
+namespace {
+
+const OUString aServiceName("com.sun.star.chart2.BubbleChartTypeTemplate");
+
+}
+
 GL3DBarChartTypeTemplate::GL3DBarChartTypeTemplate(
     const uno::Reference<uno::XComponentContext>& xContext, const OUString& rServiceName ) :
     ChartTypeTemplate(xContext, rServiceName) {}
@@ -51,8 +59,13 @@ GL3DBarChartTypeTemplate::getChartTypeForNewSeries(
         uno::Reference<lang::XMultiServiceFactory> xFact(
             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
 
+#if 1
+        // I gave up trying to use UNO just to instantiate this little thing...
+        xResult.set(new GL3DBarChartType(GetComponentContext()));
+#else
+        // This never works for me.
         xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
-
+#endif
         ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem(xOldChartTypes, xResult);
     }
     catch (const uno::Exception & ex)
@@ -68,6 +81,16 @@ sal_Bool GL3DBarChartTypeTemplate::supportsCategories()
     return false;
 }
 
+uno::Sequence<OUString> GL3DBarChartTypeTemplate::getSupportedServiceNames_Static()
+{
+    uno::Sequence<OUString> aServices(2);
+    aServices[0] = aServiceName;
+    aServices[1] = "com.sun.star.chart2.ChartTypeTemplate";
+    return aServices;
+}
+
+APPHELPER_XSERVICEINFO_IMPL(GL3DBarChartTypeTemplate, aServiceName);
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
index 47a7b06..56aa220 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.hxx
@@ -20,6 +20,8 @@ namespace chart {
 class GL3DBarChartTypeTemplate : public ChartTypeTemplate
 {
 public:
+    APPHELPER_XSERVICEINFO_DECL()
+
     GL3DBarChartTypeTemplate(
         const css::uno::Reference<
             css::uno::XComponentContext>& xContext,
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 2443e20..2cc53b6 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -136,7 +136,7 @@ drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const
     drawing::Direction3D aRet(1,-1,1);
     if( m_nDimension == 2 )
         aRet = drawing::Direction3D(-1,-1,-1);
-    else
+    else if (m_pPosHelper)
     {
         drawing::Direction3D aScale( m_pPosHelper->getScaledLogicWidth() );
         aRet.DirectionZ = aScale.DirectionZ*0.2;
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
new file mode 100644
index 0000000..bd0250b
--- /dev/null
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "GL3DBarChart.hxx"
+
+namespace chart {
+
+GL3DBarChart::GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartTypeModel ) :
+    VSeriesPlotter(xChartTypeModel, 3, false)
+{
+}
+
+GL3DBarChart::~GL3DBarChart()
+{
+}
+
+void GL3DBarChart::createShapes()
+{
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/charttypes/GL3DBarChart.hxx b/chart2/source/view/charttypes/GL3DBarChart.hxx
new file mode 100644
index 0000000..d5ecf77
--- /dev/null
+++ b/chart2/source/view/charttypes/GL3DBarChart.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef CHART2_GL3DBARCHART_HXX
+#define CHART2_GL3DBARCHART_HXX
+
+#include <VSeriesPlotter.hxx>
+
+namespace chart {
+
+class GL3DBarChart : public VSeriesPlotter
+{
+public:
+    GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartTypeModel );
+    virtual ~GL3DBarChart();
+
+    virtual void createShapes();
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 5202cc1..79e1e28 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -51,7 +51,7 @@
 #include "CandleStickChart.hxx"
 #include "BubbleChart.hxx"
 #include "NetChart.hxx"
-
+#include "GL3DBarChart.hxx"
 
 #include <com/sun/star/chart/ErrorBarStyle.hpp>
 #include <com/sun/star/chart/TimeUnit.hpp>
@@ -250,6 +250,9 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32
 drawing::Direction3D VSeriesPlotter::getPreferredDiagramAspectRatio() const
 {
     drawing::Direction3D aRet(1.0,1.0,1.0);
+    if (!m_pPosHelper)
+        return aRet;
+
     drawing::Direction3D aScale( m_pPosHelper->getScaledLogicWidth() );
     aRet.DirectionZ = aScale.DirectionZ*0.2;
     if(aRet.DirectionZ>1.0)
@@ -803,6 +806,9 @@ void VSeriesPlotter::createErrorBar(
         if(nErrorBarStyle==::com::sun::star::chart::ErrorBarStyle::NONE)
             return;
 
+        if (!m_pPosHelper)
+            return;
+
         drawing::Position3D aUnscaledLogicPosition(rUnscaledLogicPosition);
         if(nErrorBarStyle==::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION)
         {
@@ -967,6 +973,9 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
     if(!xContainer.is())
         return;
 
+    if (!m_pPosHelper)
+        return;
+
     uno::Sequence< uno::Reference< XRegressionCurve > > aCurveList = xContainer->getRegressionCurves();
 
     for(sal_Int32 nN=0; nN<aCurveList.getLength(); nN++)
@@ -1882,7 +1891,7 @@ PlottingPositionHelper& VSeriesPlotter::getPlottingPositionHelper( sal_Int32 nAx
         {
             pRet = aPosIt->second;
         }
-        else
+        else if (m_pPosHelper)
         {
             tSecondaryValueScales::const_iterator aScaleIt = m_aSecondaryValueScales.find( nAxisIndex );
             if( aScaleIt != m_aSecondaryValueScales.end() )
@@ -2434,6 +2443,8 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
         pRet = new AreaChart(xChartTypeModel,nDimensionCount,false,true);
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
         pRet = new BubbleChart(xChartTypeModel,nDimensionCount);
+    else if (aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR))
+        pRet = new GL3DBarChart(xChartTypeModel);
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
         pRet = new PieChart(xChartTypeModel,nDimensionCount, bExcludingPositioning );
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx
index f38b570..c273899 100644
--- a/chart2/source/view/main/PlotterBase.cxx
+++ b/chart2/source/view/main/PlotterBase.cxx
@@ -60,12 +60,18 @@ PlotterBase::~PlotterBase()
 
 void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
 {
+    if (!m_pPosHelper)
+        return;
+
     OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
     m_pPosHelper->setScales( rScales, bSwapXAndYAxis );
 }
 
 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
 {
+    if (!m_pPosHelper)
+        return;
+
     OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
     if(m_nDimension!=2)
         return;
commit a133e6a5af480e749ebcb3279844bec948e00e8a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Mar 24 17:06:30 2014 -0400

    coverity#735476: bRepeat is always false.
    
    Therefore act accordingly.
    
    Change-Id: Ie737c053a935d3cc0e0c03ab30da2cf3fde0e401

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 54f977c..eb46c4a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -4160,8 +4160,7 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
     Size aRefOne = mpRefDevice->PixelToLogic(Size(1,1));
 
     bool bHidden = false;
-    bool bRepeat = false;
-    bool bShrink = !rParam.mbBreak && !bRepeat && lcl_GetBoolValue(*rParam.mpPattern, ATTR_SHRINKTOFIT, rParam.mpCondSet);
+    bool bShrink = !rParam.mbBreak && lcl_GetBoolValue(*rParam.mpPattern, ATTR_SHRINKTOFIT, rParam.mpCondSet);
     long nAttrRotate = lcl_GetValue<SfxInt32Item, long>(*rParam.mpPattern, ATTR_ROTATE_VALUE, rParam.mpCondSet);
 
     if (nAttrRotate)
@@ -4276,7 +4275,7 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
     // for break, the first GetOutputArea call is sufficient
     GetOutputArea( nXForPos, nArrYForPos, rParam.mnPosX, rParam.mnPosY, rParam.mnCellX, rParam.mnCellY, nNeededPixel,
                    *rParam.mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
-                   rParam.mbCellIsValue || bRepeat || bShrink, false, false, aAreaParam );
+                   rParam.mbCellIsValue || bShrink, false, false, aAreaParam );
 
     if ( bShrink )
     {
@@ -4286,45 +4285,6 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
             nEngineWidth, nEngineHeight, nNeededPixel,
             aAreaParam.mbLeftClip, aAreaParam.mbRightClip );
     }
-    if ( bRepeat && !aAreaParam.mbLeftClip && !aAreaParam.mbRightClip && rParam.mpEngine->GetParagraphCount() == 1 )
-    {
-        // First check if twice the space for the formatted text is available
-        // (otherwise just keep it unchanged).
-
-        long nFormatted = nNeededPixel - nLeftM - nRightM;      // without margin
-        long nAvailable = aAreaParam.maAlignRect.GetWidth() - nLeftM - nRightM;
-        if ( nAvailable >= 2 * nFormatted )
-        {
-            // "repeat" is handled with unformatted text (for performance reasons)
-            OUString aCellStr = rParam.mpEngine->GetText();
-            rParam.mpEngine->SetText( aCellStr );
-
-            long nRepeatSize = (long) rParam.mpEngine->CalcTextWidth();
-            if (rParam.mbPixelToLogic)
-                nRepeatSize = mpRefDevice->LogicToPixel(Size(nRepeatSize,0)).Width();
-            if ( pFmtDevice != mpRefDevice )
-                ++nRepeatSize;
-            if ( nRepeatSize > 0 )
-            {
-                long nRepeatCount = nAvailable / nRepeatSize;
-                if ( nRepeatCount > 1 )
-                {
-                    OUString aRepeated = aCellStr;
-                    for ( long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
-                        aRepeated += aCellStr;
-                    rParam.mpEngine->SetText( aRepeated );
-
-                    nEngineHeight = rParam.mpEngine->GetTextHeight();
-                    nEngineWidth = (long) rParam.mpEngine->CalcTextWidth();
-                    if (rParam.mbPixelToLogic)
-                        nNeededPixel = mpRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width();
-                    else
-                        nNeededPixel = nEngineWidth;
-                    nNeededPixel += nLeftM + nRightM;
-                }
-            }
-        }
-    }
 
     if ( rParam.mbCellIsValue && ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) )
     {


More information about the Libreoffice-commits mailing list