[Libreoffice-commits] core.git: chart2/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Jun 2 07:32:21 UTC 2016


 chart2/source/controller/dialogs/DataBrowser.cxx    |   37 +++++++++-----------
 chart2/source/controller/main/ChartTransferable.cxx |    6 +--
 chart2/source/tools/RangeHighlighter.cxx            |   14 +++----
 chart2/source/view/charttypes/Splines.cxx           |    6 +--
 chart2/source/view/inc/GL3DRenderer.hxx             |   12 +++---
 chart2/source/view/main/GL3DRenderer.cxx            |    8 ++--
 6 files changed, 38 insertions(+), 45 deletions(-)

New commits:
commit 4ca9e855389176bd913c60840b516cb122273b81
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Jun 1 10:57:28 2016 +0200

    replace simple macros in chart2
    
    with static constantants or a named value (enum)
    
    Change-Id: I8ef21bc3b9797ed9319e790fc12241d59f07b88c
    Reviewed-on: https://gerrit.libreoffice.org/25760
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 2767d01..e1b8e94 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -52,25 +52,6 @@
 #include <algorithm>
 #include <functional>
 
-/*  BrowserMode::COLUMNSELECTION :  single cells may be selected rather than only
-                               entire rows
-    BROWSER_(H|V)LINES :       show horizontal or vertical grid-lines
-
-    BROWSER_AUTO_(H|V)SCROLL : scroll automated horizontally or vertically when
-                               cursor is moved beyond the edge of the dialog
-    BrowserMode::HIDESELECT     :   Do not mark the current row with selection color
-                               (usually blue)
-
- */
-#define BROWSER_STANDARD_FLAGS  \
-    BrowserMode::COLUMNSELECTION | \
-    BrowserMode::HLINES | BrowserMode::VLINES | \
-    BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL | \
-    BrowserMode::HIDESELECT
-
-// BrowserMode::HIDECURSOR would prevent flickering in edit fields, but navigating
-// with shift up/down, and entering non-editable cells would be problematic,
-// e.g.  the first cell, or when being in read-only mode
 
 using namespace ::com::sun::star;
 using ::com::sun::star::uno::Reference;
@@ -79,6 +60,22 @@ using namespace ::svt;
 
 namespace
 {
+/*  BrowserMode::COLUMNSELECTION : single cells may be selected rather than only
+                                   entire rows
+    BrowserMode::(H|V)LINES : show horizontal or vertical grid-lines
+    BrowserMode::AUTO_(H|V)SCROLL : scroll automated horizontally or vertically when
+                                    cursor is moved beyond the edge of the dialog
+    BrowserMode::HIDESELECT : Do not mark the current row with selection color
+                              (usually blue)
+  ! BrowserMode::HIDECURSOR would prevent flickering in edit fields, but navigating
+        with shift up/down, and entering non-editable cells would be problematic,
+        e.g.  the first cell, or when being in read-only mode
+*/
+const BrowserMode BrowserStdFlags = BrowserMode::COLUMNSELECTION |
+                                    BrowserMode::HLINES | BrowserMode::VLINES |
+                                    BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL |
+                                    BrowserMode::HIDESELECT;
+
 sal_Int32 lcl_getRowInData( long nRow )
 {
     return static_cast< sal_Int32 >( nRow );
@@ -440,7 +437,7 @@ sal_Int32 lcl_getColumnInDataOrHeader(
 } // anonymous namespace
 
 DataBrowser::DataBrowser( vcl::Window* pParent, WinBits nStyle, bool bLiveUpdate ) :
-    ::svt::EditBrowseBox( pParent, EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::HANDLE_COLUMN_TEXT, nStyle, BROWSER_STANDARD_FLAGS ),
+    ::svt::EditBrowseBox( pParent, EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::HANDLE_COLUMN_TEXT, nStyle, BrowserStdFlags ),
     m_nSeekRow( 0 ),
     m_bIsReadOnly( false ),
     m_bIsDirty( false ),
diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx
index 5888620..206b7ad 100644
--- a/chart2/source/controller/main/ChartTransferable.cxx
+++ b/chart2/source/controller/main/ChartTransferable.cxx
@@ -32,8 +32,6 @@
 #include <svx/unomodel.hxx>
 #include <svx/svdview.hxx>
 
-#define CHARTTRANSFER_OBJECTTYPE_DRAWMODEL      SotClipboardFormatId::STRING
-
 using namespace ::com::sun::star;
 
 using ::com::sun::star::uno::Reference;
@@ -83,7 +81,7 @@ bool ChartTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, c
     {
         if ( nFormat == SotClipboardFormatId::DRAWING )
         {
-            bResult = SetObject( m_pMarkedObjModel, CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
+            bResult = SetObject( m_pMarkedObjModel, SotClipboardFormatId::STRING, rFlavor );
         }
         else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
         {
@@ -108,7 +106,7 @@ bool ChartTransferable::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, voi
     bool bRet = false;
     switch ( nUserObjectId )
     {
-        case CHARTTRANSFER_OBJECTTYPE_DRAWMODEL:
+        case SotClipboardFormatId::STRING:
             {
                 SdrModel* pMarkedObjModel = static_cast< SdrModel* >( pUserObject );
                 if ( pMarkedObjModel )
diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx
index 31ca9da..55b90e1 100644
--- a/chart2/source/tools/RangeHighlighter.cxx
+++ b/chart2/source/tools/RangeHighlighter.cxx
@@ -31,8 +31,6 @@
 #include <com/sun/star/drawing/XShape.hpp>
 #include <comphelper/sequence.hxx>
 
-#define PREFERED_DEFAULT_COLOR 0x0000ff
-
 using namespace ::com::sun::star;
 
 using ::com::sun::star::uno::Reference;
@@ -41,10 +39,12 @@ using ::com::sun::star::uno::Sequence;
 namespace
 {
 
+const auto defaultPreferredColor = COL_LIGHTBLUE;
+
 void lcl_fillRanges(
     Sequence< chart2::data::HighlightedRange > & rOutRanges,
     const Sequence< OUString >& aRangeStrings,
-    sal_Int32 nPreferredColor = PREFERED_DEFAULT_COLOR,
+    sal_Int32 nPreferredColor = defaultPreferredColor,
     sal_Int32 nIndex = -1 )
 {
     rOutRanges.realloc( aRangeStrings.getLength());
@@ -199,7 +199,7 @@ void RangeHighlighter::fillRangesForDiagram( const Reference< chart2::XDiagram >
     {
         m_aSelectedRanges[i].RangeRepresentation = aSelectedRanges[i];
         m_aSelectedRanges[i].Index = -1;
-        m_aSelectedRanges[i].PreferredColor = PREFERED_DEFAULT_COLOR;
+        m_aSelectedRanges[i].PreferredColor = defaultPreferredColor;
         m_aSelectedRanges[i].AllowMerginigWithOtherRanges = true;
     }
 }
@@ -209,7 +209,7 @@ void RangeHighlighter::fillRangesForDataSeries( const uno::Reference< chart2::XD
     Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
     if( xSource.is())
     {
-        sal_Int32 nPreferredColor = PREFERED_DEFAULT_COLOR;
+        sal_Int32 nPreferredColor = defaultPreferredColor;
         lcl_fillRanges( m_aSelectedRanges,
                         ::chart::DataSourceHelper::getRangesFromDataSource( xSource ),
                         nPreferredColor );
@@ -240,7 +240,7 @@ void RangeHighlighter::fillRangesForErrorBars(
         Reference< chart2::data::XDataSource > xSource( xErrorBar, uno::UNO_QUERY );
         if( xSource.is())
         {
-            sal_Int32 nPreferredColor = PREFERED_DEFAULT_COLOR;
+            sal_Int32 nPreferredColor = defaultPreferredColor;
             lcl_fillRanges( m_aSelectedRanges,
                             ::chart::DataSourceHelper::getRangesFromDataSource( xSource ),
                             nPreferredColor );
@@ -268,7 +268,7 @@ void RangeHighlighter::fillRangesForDataPoint( const Reference< uno::XInterface
         Reference< chart2::data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY );
         if( xSource.is() )
         {
-            sal_Int32 nPreferredColor = PREFERED_DEFAULT_COLOR;
+            sal_Int32 nPreferredColor = defaultPreferredColor;
             ::std::vector< chart2::data::HighlightedRange > aHilightedRanges;
             Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences());
             for( sal_Int32 i=0; i<aLSeqSeq.getLength(); ++i )
diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index 3c20ed0..9720362 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -26,8 +26,6 @@
 #include <functional>
 #include <memory>
 
-#define MAX_BSPLINE_DEGREE 15
-
 namespace chart
 {
 using namespace ::com::sun::star;
@@ -676,8 +674,8 @@ void SplineCalculater::CalculateBSplines(
     OSL_ASSERT( nResolution > 1 );
     OSL_ASSERT( nDegree >= 1 );
 
-    // limit the b-spline degree to prevent insanely large sets of points
-    sal_uInt32 p = std::min<sal_uInt32>(nDegree, MAX_BSPLINE_DEGREE);
+    // limit the b-spline degree at 15 to prevent insanely large sets of points
+    sal_uInt32 p = std::min<sal_uInt32>(nDegree, 15);
 
     rResult.SequenceX.realloc(0);
     rResult.SequenceY.realloc(0);
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 9966a98..ee3403b 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -25,12 +25,12 @@
 #include <list>
 #include <map>
 
-#define MAX_LIGHT_NUM 8
-
 namespace chart {
 
 namespace opengl3D {
 
+const auto maxLights = 8;
+
 struct PosVecf3
 {
     float x;
@@ -65,7 +65,7 @@ struct GlobalLights
 {
     int lightNum;
     glm::vec4 ambient;
-    LightSource light[MAX_LIGHT_NUM];
+    LightSource light[maxLights];
 };
 
 struct Polygon3DInfo
@@ -464,9 +464,9 @@ private:
     //for 3.0 version
     int m_iLightNum;
     glm::vec4 m_Ambient;
-    glm::vec4 m_LightColor[MAX_LIGHT_NUM];
-    glm::vec4 m_PositionWorldspace[MAX_LIGHT_NUM];
-    float m_fLightPower[MAX_LIGHT_NUM];
+    glm::vec4 m_LightColor[maxLights];
+    glm::vec4 m_PositionWorldspace[maxLights];
+    float m_fLightPower[maxLights];
     //for 3.0 end
     std::vector<GLuint> m_Texturelist;
     std::vector<GLuint> m_ScreenTexturelist;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 61916f9..b21f970 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1115,7 +1115,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
     {
         if (maResources.m_b330Support)
         {
-            if (m_LightsInfo.lightNum >= MAX_LIGHT_NUM)
+            if (m_LightsInfo.lightNum >= maxLights)
             {
                 return;
             }
@@ -1126,7 +1126,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
         }
         else
         {
-            if (m_iLightNum >= MAX_LIGHT_NUM)
+            if (m_iLightNum >= maxLights)
             {
                 return;
             }
@@ -1358,7 +1358,7 @@ void OpenGL3DRenderer::UpdateBatch3DUniformBlock()
     glBufferSubData(GL_UNIFORM_BUFFER, 16, sizeof(glm::vec4), &m_LightsInfo.ambient[0]);
     CHECK_GL_ERROR();
     //current std140 alignment: 16
-    glBufferSubData(GL_UNIFORM_BUFFER, 32, sizeof(LightSource) * MAX_LIGHT_NUM, &m_LightsInfo.light);
+    glBufferSubData(GL_UNIFORM_BUFFER, 32, sizeof(LightSource) * maxLights, &m_LightsInfo.light);
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
 }
@@ -1377,7 +1377,7 @@ void OpenGL3DRenderer::Update3DUniformBlock()
     glBufferSubData(GL_UNIFORM_BUFFER, 16, sizeof(glm::vec4), &m_LightsInfo.ambient[0]);
     CHECK_GL_ERROR();
     //current std140 alignment: 16
-    glBufferSubData(GL_UNIFORM_BUFFER, 32, sizeof(LightSource) * MAX_LIGHT_NUM, &m_LightsInfo.light);
+    glBufferSubData(GL_UNIFORM_BUFFER, 32, sizeof(LightSource) * maxLights, &m_LightsInfo.light);
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
 }


More information about the Libreoffice-commits mailing list