summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Korepanov <gkorepanov.gk@gmail.com>2017-01-06 15:39:27 +0500
committerjan iversen <jani@documentfoundation.org>2017-01-09 07:20:35 +0000
commitc695869fd83c516d63330f352d63c9b601999f20 (patch)
tree6874b85c44fc5b34f183f3eaea7d68bc97a8d72e
parentcb8b05eb486d1def2d6332bcad221c7de333d67d (diff)
tdf#87933: made pagebreak lines dashed
Change-Id: I0067ef7bc672e159b739d6fd588f1427827e91a8 Reviewed-on: https://gerrit.libreoffice.org/32779 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
-rw-r--r--sc/source/ui/inc/gridmerg.hxx4
-rw-r--r--sc/source/ui/view/gridmerg.cxx56
-rw-r--r--sc/source/ui/view/output.cxx39
3 files changed, 84 insertions, 15 deletions
diff --git a/sc/source/ui/inc/gridmerg.hxx b/sc/source/ui/inc/gridmerg.hxx
index 89be9ffa03eb..a6c484afa7f3 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 c7cf899953f9..abb6493a3d84 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 78d351ba3a51..519bdbdb9c21 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);
}
}
}