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

George Korepanov gkorepanov.gk at gmail.com
Mon Jan 9 07:21:05 UTC 2017


 sc/source/ui/inc/gridmerg.hxx  |    4 +-
 sc/source/ui/view/gridmerg.cxx |   56 +++++++++++++++++++++++++++++++++++++----
 sc/source/ui/view/output.cxx   |   39 ++++++++++++++++++++++------
 3 files changed, 84 insertions(+), 15 deletions(-)

New commits:
commit c695869fd83c516d63330f352d63c9b601999f20
Author: George Korepanov <gkorepanov.gk at gmail.com>
Date:   Fri Jan 6 15:39:27 2017 +0500

    tdf#87933: made pagebreak lines dashed
    
    Change-Id: I0067ef7bc672e159b739d6fd588f1427827e91a8
    Reviewed-on: https://gerrit.libreoffice.org/32779
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/sc/source/ui/inc/gridmerg.hxx b/sc/source/ui/inc/gridmerg.hxx
index 89be9ff..a6c484a 100644
--- a/sc/source/ui/inc/gridmerg.hxx
+++ b/sc/source/ui/inc/gridmerg.hxx
@@ -42,8 +42,8 @@ public:
                 ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY );
                 ~ScGridMerger();
 
-    void        AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY);
-    void        AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2);
+    void        AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY, bool bDashed = false);
+    void        AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2, bool bDashed = false);
     void        Flush();
 };
 
diff --git a/sc/source/ui/view/gridmerg.cxx b/sc/source/ui/view/gridmerg.cxx
index c7cf899..abb6493 100644
--- a/sc/source/ui/view/gridmerg.cxx
+++ b/sc/source/ui/view/gridmerg.cxx
@@ -21,6 +21,10 @@
 
 #include "gridmerg.hxx"
 
+#define PAGEBREAK_LINE_DISTANCE_PIXEL 5
+#define PAGEBREAK_LINE_DASH_LEN_PIXEL 5
+#define PAGEBREAK_LINE_DASH_COUNT 1
+
 ScGridMerger::ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY )
     : pDev(pOutDev)
     , nOneX(nOnePixelX)
@@ -86,9 +90,9 @@ void ScGridMerger::AddLine( long nStart, long nEnd, long nPos )
     }
 }
 
-void ScGridMerger::AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY)
+void ScGridMerger::AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY, bool bDashed)
 {
-    if (bWorksInPixels)
+    if ( bWorksInPixels )
     {
         Point aPoint(pDev->PixelToLogic(Point(nX1, nY)));
         nX1 = aPoint.X();
@@ -96,7 +100,28 @@ void ScGridMerger::AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY)
         nX2 = pDev->PixelToLogic(Point(nX2, 0)).X();
     }
 
-    if ( bOptimize )
+    if ( bDashed )
+    {
+        // If there are some unflushed lines they must be flushed since
+        // new line is of different style
+        if (bOptimize) {
+            Flush();
+            bVertical = false;
+        }
+
+        LineInfo aLineInfo(LineStyle::Dash, 1);
+        aLineInfo.SetDashCount( PAGEBREAK_LINE_DASH_COUNT );
+
+        // Calculating logic values of DashLen and Distance from fixed pixel values
+        Size aDashDistanceLen( pDev->PixelToLogic( Size( PAGEBREAK_LINE_DISTANCE_PIXEL,
+                                                         PAGEBREAK_LINE_DASH_LEN_PIXEL )));
+
+        aLineInfo.SetDistance( aDashDistanceLen.Width() );
+        aLineInfo.SetDashLen( aDashDistanceLen.Height() );
+
+        pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ), aLineInfo );
+    }
+    else if ( bOptimize )
     {
         if ( bVertical )
         {
@@ -109,7 +134,7 @@ void ScGridMerger::AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY)
         pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
 }
 
-void ScGridMerger::AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2)
+void ScGridMerger::AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2, bool bDashed)
 {
     if (bWorksInPixels)
     {
@@ -119,7 +144,28 @@ void ScGridMerger::AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2)
         nY2 = pDev->PixelToLogic(Point(0, nY2)).Y();
     }
 
-    if ( bOptimize )
+    if ( bDashed )
+    {
+        // If there are some unflushed lines they must be flushed since
+        // new line is of different style
+        if (bOptimize) {
+            Flush();
+            bVertical = false;
+        }
+
+        LineInfo aLineInfo(LineStyle::Dash, 1);
+        aLineInfo.SetDashCount( PAGEBREAK_LINE_DASH_COUNT );
+
+        // Calculating logic values of DashLen and Distance from fixed pixel values
+        Size aDashDistanceLen( pDev->PixelToLogic( Size( PAGEBREAK_LINE_DISTANCE_PIXEL,
+                                                         PAGEBREAK_LINE_DASH_LEN_PIXEL )));
+
+        aLineInfo.SetDistance( aDashDistanceLen.Width() );
+        aLineInfo.SetDashLen( aDashDistanceLen.Height() );
+
+        pDev->DrawLine( Point( nX, nY1 ), Point( nX, nY2 ), aLineInfo);
+    }
+    else if ( bOptimize )
     {
         if ( !bVertical )
         {
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 78d351b..519bdbd 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -318,6 +318,7 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
     ScBreakType nBreakOld = ScBreakType::NONE;
 
     bool bSingle;
+    bool bDashed = false;
     Color aPageColor;
     Color aManualColor;
 
@@ -404,8 +405,19 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                 if (nBreak != nBreakOld)
                 {
                     aGrid.Flush();
-                    rRenderContext.SetLineColor( (nBreak & ScBreakType::Manual) ? aManualColor :
-                                        nBreak != ScBreakType::NONE ? aPageColor : aGridColor );
+
+                    if (static_cast<int>(nBreak))
+                    {
+                        rRenderContext.SetLineColor( (nBreak & ScBreakType::Manual) ? aManualColor :
+                                                        aPageColor );
+                        bDashed = true;
+                    }
+                    else
+                    {
+                        rRenderContext.SetLineColor( aGridColor );
+                        bDashed = false;
+                    }
+
                     nBreakOld = nBreak;
                 }
             }
@@ -462,14 +474,14 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
 
                         if (pThisRowInfo->bChanged && !bHOver)
                         {
-                            aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nPosY, nNextY-nOneY);
+                            aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nPosY, nNextY-nOneY, bDashed);
                         }
                         nPosY = nNextY;
                     }
                 }
                 else
                 {
-                    aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nScrY, nScrY+nScrH-nOneY);
+                    aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nScrY, nScrY+nScrH-nOneY, bDashed);
                 }
             }
         }
@@ -510,8 +522,19 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                 if (nBreakOld != nBreak)
                 {
                     aGrid.Flush();
-                    rRenderContext.SetLineColor( (nBreak & ScBreakType::Manual) ? aManualColor :
-                                        (nBreak != ScBreakType::NONE) ? aPageColor : aGridColor );
+
+                    if (static_cast<int>(nBreak))
+                    {
+                        rRenderContext.SetLineColor( (nBreak & ScBreakType::Manual) ? aManualColor :
+                                                        aPageColor );
+                        bDashed = true;
+                    }
+                    else
+                    {
+                        rRenderContext.SetLineColor( aGridColor );
+                        bDashed = false;
+                    }
+
                     nBreakOld = nBreak;
                 }
             }
@@ -556,7 +579,7 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                             }
                             if (!bVOver)
                             {
-                                aGrid.AddHorLine(bWorksInPixels, nPosX, nNextX-nSignedOneX, nPosY-nOneY);
+                                aGrid.AddHorLine(bWorksInPixels, nPosX, nNextX-nSignedOneX, nPosY-nOneY, bDashed);
                             }
                         }
                         nPosX = nNextX;
@@ -564,7 +587,7 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                 }
                 else
                 {
-                    aGrid.AddHorLine(bWorksInPixels, nScrX, nScrX+nScrW-nOneX, nPosY-nOneY);
+                    aGrid.AddHorLine(bWorksInPixels, nScrX, nScrX+nScrW-nOneX, nPosY-nOneY, bDashed);
                 }
             }
         }


More information about the Libreoffice-commits mailing list