summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-07-20 15:11:30 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-07-28 17:51:56 +0200
commite32c12a444e5bd0c6735db8e8008340c29a7e25e (patch)
tree50262efd53047ee92f5f39f9a1fd6c9e00917fc7 /sc/source/ui
parent1118e5b986e4df8a417edcd4ee23a40fb64a0a38 (diff)
borderline: adaptions to primitives
Handling and paint of borderlines greatly adapted to primitive usage. Solved the double paint mechanisn to no longer use the sc-local special cases. The svx tooling for borderline paint is now the only one and was extended to also handle diagonal lines. Big cleanups/removals of old paint to OutputDevice and sc-specific rendering. All other app-usages of borderline also adapted. Preparations for careful line-start/end adaption prepared and possible due to unified coordinate-system usages and basegfx class-usage Change-Id: If9e4efcfc0fe25e14d4052907038ca5cf222a432
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/output.hxx3
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx17
-rw-r--r--sc/source/ui/view/gridwin4.cxx4
-rw-r--r--sc/source/ui/view/output.cxx249
-rw-r--r--sc/source/ui/view/output2.cxx4
5 files changed, 77 insertions, 200 deletions
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 8aeee70791e1..5345b69141bb 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -196,7 +196,6 @@ private:
bool bSnapPixel;
- bool bAnyRotated; // internal
bool bAnyClipped; // internal
bool bTabProtected;
bool bLayoutRTL;
@@ -302,7 +301,7 @@ public:
// with logic MapMode set!
void DrawEdit(bool bPixelToLogic);
- void FindRotated();
+ void SetCellRotations();
void DrawRotated(bool bPixelToLogic); // logical
void DrawClear();
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
index 0a7f9de81a50..8fd590944c79 100644
--- a/sc/source/ui/miscdlgs/autofmt.cxx
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -36,6 +36,7 @@
#include <vcl/builderfactory.hxx>
#include <sfx2/viewfrm.hxx>
#include <comphelper/processfactory.hxx>
+#include <drawinglayer/processor2d/processor2dtools.hxx>
#include "strings.hrc"
#include "scmod.hxx"
@@ -393,7 +394,19 @@ void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
// 3) border
if (pCurData->GetIncludeFrame())
- maArray.DrawArray(rRenderContext);
+ {
+ const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
+ std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
+ drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+ rRenderContext,
+ aNewViewInformation2D));
+
+ if (pProcessor2D)
+ {
+ maArray.DrawArray(*pProcessor2D.get());
+ pProcessor2D.reset();
+ }
+ }
}
}
@@ -401,7 +414,7 @@ void ScAutoFmtPreview::Init()
{
SetBorderStyle( WindowBorderStyle::MONO );
maArray.Initialize( 5, 5 );
- maArray.SetUseDiagDoubleClipping( false );
+// maArray.SetUseDiagDoubleClipping( false );
mnLabelColWidth = 0;
mnDataColWidth1 = 0;
mnDataColWidth2 = 0;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 68a1ec5fb461..a0ea195f3e14 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -699,6 +699,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
pContentDev->SetMapMode(aCurrentMapMode);
}
+ // check for and set cell rotations at OutputData to have it available
+ // in the svx tooling to render the borders
+ aOutputData.SetCellRotations();
+
if ( rDoc.HasBackgroundDraw( nTab, aDrawingRectLogic ) )
{
pContentDev->SetMapMode(MapUnit::MapPixel);
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index b6d73631aca6..f4db5fec5b09 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -183,7 +183,6 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
bShowSpellErrors( false ),
bMarkClipped( false ), // sal_False for printer/metafile etc.
bSnapPixel( false ),
- bAnyRotated( false ),
bAnyClipped( false ),
mpTargetPaintWindow(nullptr), // #i74769# use SdrPaintWindow direct
mpSpellCheckCxt(nullptr)
@@ -618,7 +617,7 @@ void ScOutputData::SetPagebreakMode( ScPageBreakData* pPageData )
}
}
-void ScOutputData::FindRotated()
+void ScOutputData::SetCellRotations()
{
//! save nRotMax
SCCOL nRotMax = nX2;
@@ -652,8 +651,16 @@ void ScOutputData::FindRotated()
ScRotateDir nDir = pPattern->GetRotateDir( pCondSet );
if (nDir != ScRotateDir::NONE)
{
+ // Needed for CellInfo internal decisions (bg fill, ...)
pInfo->nRotateDir = nDir;
- bAnyRotated = true;
+
+ // add rotation info to Array information
+ const long nAttrRotate(pPattern->GetRotateVal(pCondSet));
+ const SvxRotateMode eRotMode((SvxRotateMode)static_cast<const SvxRotateModeItem&>(pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue());
+ const double fOrient((bLayoutRTL ? -1.0 : 1.0) * nAttrRotate * F_PI18000); // 1/100th degrees -> [0..2PI]
+ svx::frame::Array& rArray = mrTabInfo.maArray;
+
+ rArray.SetCellRotation(nY+1, nX+1, eRotMode, fOrient);
}
}
}
@@ -985,8 +992,6 @@ void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const Sv
void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext)
{
- FindRotated(); //! from the outside?
-
Size aOnePixel = rRenderContext.PixelToLogic(Size(1,1));
long nOneXLogic = aOnePixel.Width();
long nOneYLogic = aOnePixel.Height();
@@ -1380,8 +1385,10 @@ void ScOutputData::DrawFrame(vcl::RenderContext& rRenderContext)
const Color* pForceColor = bUseSingleColor ? &aSingleColor : nullptr;
- if (bAnyRotated)
+ if (mrTabInfo.maArray.HasCellRotation())
+ {
DrawRotatedFrame(rRenderContext, pForceColor); // removes the lines that must not be painted here
+ }
long nInitPosX = nScrX;
if ( bLayoutRTL )
@@ -1617,16 +1624,16 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext, const Co
SvxRotateMode eRotMode = (SvxRotateMode)static_cast<const SvxRotateModeItem&>(
pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
- if ( nAttrRotate )
+ if (nAttrRotate)
{
- if (nX<nX1) // compute negative position
+ if (nX < nX1) // compute negative position
{
nPosX = nInitPosX;
SCCOL nCol = nX1;
while (nCol > nX)
{
--nCol;
- nPosX -= nLayoutSign * (long) pRowInfo[0].pCellInfo[nCol+1].nWidth;
+ nPosX -= nLayoutSign * (long)pRowInfo[0].pCellInfo[nCol + 1].nWidth;
}
}
@@ -1636,248 +1643,100 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext, const Co
long nTop = nPosY - 1;
long nBottom = nPosY + nRowHeight - 1;
long nTopLeft = nPosX - nLayoutSign;
- long nTopRight = nPosX + ( nColWidth - 1 ) * nLayoutSign;
+ long nTopRight = nPosX + (nColWidth - 1) * nLayoutSign;
long nBotLeft = nTopLeft;
long nBotRight = nTopRight;
// inclusion of the sign here hasn't been decided yet
// (if not, the extension of the non-rotated background must also be changed)
double nRealOrient = nLayoutSign * nAttrRotate * F_PI18000; // 1/100th degrees
- double nCos = cos( nRealOrient );
- double nSin = sin( nRealOrient );
+ double nCos = cos(nRealOrient);
+ double nSin = sin(nRealOrient);
//! restrict !!!
- long nSkew = (long) ( nRowHeight * nCos / nSin );
+ long nSkew = (long)(nRowHeight * nCos / nSin);
switch (eRotMode)
{
- case SVX_ROTATE_MODE_BOTTOM:
- nTopLeft += nSkew;
- nTopRight += nSkew;
- break;
- case SVX_ROTATE_MODE_CENTER:
- nSkew /= 2;
- nTopLeft += nSkew;
- nTopRight += nSkew;
- nBotLeft -= nSkew;
- nBotRight -= nSkew;
- break;
- case SVX_ROTATE_MODE_TOP:
- nBotLeft -= nSkew;
- nBotRight -= nSkew;
- break;
- default:
- {
- // added to avoid warnings
- }
+ case SVX_ROTATE_MODE_BOTTOM:
+ nTopLeft += nSkew;
+ nTopRight += nSkew;
+ break;
+ case SVX_ROTATE_MODE_CENTER:
+ nSkew /= 2;
+ nTopLeft += nSkew;
+ nTopRight += nSkew;
+ nBotLeft -= nSkew;
+ nBotRight -= nSkew;
+ break;
+ case SVX_ROTATE_MODE_TOP:
+ nBotLeft -= nSkew;
+ nBotRight -= nSkew;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
}
Point aPoints[4];
- aPoints[0] = Point( nTopLeft, nTop );
- aPoints[1] = Point( nTopRight, nTop );
- aPoints[2] = Point( nBotRight, nBottom );
- aPoints[3] = Point( nBotLeft, nBottom );
+ aPoints[0] = Point(nTopLeft, nTop);
+ aPoints[1] = Point(nTopRight, nTop);
+ aPoints[2] = Point(nBotRight, nBottom);
+ aPoints[3] = Point(nBotLeft, nBottom);
const SvxBrushItem* pBackground = pInfo->pBackground;
if (!pBackground)
- pBackground = static_cast<const SvxBrushItem*>( &pPattern->GetItem(
- ATTR_BACKGROUND, pCondSet ));
+ pBackground = static_cast<const SvxBrushItem*>(&pPattern->GetItem(
+ ATTR_BACKGROUND, pCondSet));
if (bCellContrast)
{
// high contrast for cell borders and backgrounds -> empty background
pBackground = ScGlobal::GetEmptyBrushItem();
}
- if(!pInfo->pColorScale)
+ if (!pInfo->pColorScale)
{
const Color& rColor = pBackground->GetColor();
- if ( rColor.GetTransparency() != 255 )
+ if (rColor.GetTransparency() != 255)
{
// draw background only for the changed row itself
// (background doesn't extend into other cells).
// For the borders (rotated and normal), clipping should be
// set if the row isn't changed, but at least the borders
// don't cover the cell contents.
- if ( rThisRowInfo.bChanged )
+ if (rThisRowInfo.bChanged)
{
- tools::Polygon aPoly( 4, aPoints );
+ tools::Polygon aPoly(4, aPoints);
// for DrawPolygon, whitout Pen one pixel is left out
// to the right and below...
- if ( rColor.GetTransparency() == 0 )
+ if (rColor.GetTransparency() == 0)
rRenderContext.SetLineColor(rColor);
else
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(rColor);
- rRenderContext.DrawPolygon( aPoly );
+ rRenderContext.DrawPolygon(aPoly);
}
}
}
else
{
- tools::Polygon aPoly( 4, aPoints );
+ tools::Polygon aPoly(4, aPoints);
const Color* pColor = pInfo->pColorScale.get();
// for DrawPolygon, whitout Pen one pixel is left out
// to the right and below...
- if ( pColor->GetTransparency() == 0 )
+ if (pColor->GetTransparency() == 0)
rRenderContext.SetLineColor(*pColor);
else
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(*pColor);
- rRenderContext.DrawPolygon( aPoly );
+ rRenderContext.DrawPolygon(aPoly);
}
-
- svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine;
-
- if ( nX < nX1 || nX > nX2 ) // Attributes in FillInfo not set
- {
- //! consider page borders for printing !!!!!
- const ::editeng::SvxBorderLine* pLeftLine;
- const ::editeng::SvxBorderLine* pTopLine;
- const ::editeng::SvxBorderLine* pRightLine;
- const ::editeng::SvxBorderLine* pBottomLine;
- mpDoc->GetBorderLines( nX, nY, nTab,
- &pLeftLine, &pTopLine, &pRightLine, &pBottomLine );
- aTopLine.Set( pTopLine, mnPPTY );
- aBottomLine.Set( pBottomLine, mnPPTY );
- aLeftLine.Set( pLeftLine, mnPPTX );
- aRightLine.Set( pRightLine, mnPPTX );
- }
- else
- {
- size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
- aTopLine = rArray.GetCellStyleTop( nCol, nRow );
- aBottomLine = rArray.GetCellStyleBottom( nCol, nRow );
- aLeftLine = rArray.GetCellStyleLeft( nCol, nRow );
- aRightLine = rArray.GetCellStyleRight( nCol, nRow );
- // in RTL mode the array is already mirrored -> swap back left/right borders
- if( bLayoutRTL )
- std::swap( aLeftLine, aRightLine );
- }
-
- // Horizontal lines
- if (aTopLine.Prim() || aTopLine.Secn())
- {
- long nUpperRotate = lcl_getRotate( mpDoc, nTab, nX, nY - 1 );
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
- svx::frame::CreateBorderPrimitives(
- aSequence,
- aPoints[bLayoutRTL?1:0], aPoints[bLayoutRTL?0:1], aTopLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aLeftLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aRightLine,
- pForceColor, nUpperRotate, nAttrRotate );
- pProcessor->process(aSequence);
- }
-
- if (aBottomLine.Prim() || aBottomLine.Secn())
- {
- long nLowerRotate = lcl_getRotate( mpDoc, nTab, nX, nY + 1 );
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
- svx::frame::CreateBorderPrimitives(
- aSequence,
- aPoints[bLayoutRTL?2:3], aPoints[bLayoutRTL?3:2], aBottomLine,
- aLeftLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aRightLine,
- svx::frame::Style(),
- svx::frame::Style(),
- pForceColor, 18000 - nAttrRotate, 18000 - nLowerRotate );
- pProcessor->process(aSequence);
- }
-
- // Vertical slanted lines
- if (aLeftLine.Prim() || aLeftLine.Secn())
- {
- long nLeftRotate = lcl_getRotate( mpDoc, nTab, nX - 1, nY );
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
- svx::frame::CreateBorderPrimitives(
- aSequence,
- aPoints[0], aPoints[3], aLeftLine,
- aTopLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aBottomLine,
- svx::frame::Style(),
- svx::frame::Style(),
- pForceColor, nAttrRotate, nLeftRotate );
- pProcessor->process(aSequence);
- }
-
- if (aRightLine.Prim() || aRightLine.Secn())
- {
- long nRightRotate = lcl_getRotate( mpDoc, nTab, nX + 1, nY );
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
- svx::frame::CreateBorderPrimitives(
- aSequence,
- aPoints[1], aPoints[2], aRightLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aTopLine,
- svx::frame::Style(),
- svx::frame::Style(),
- aBottomLine,
- pForceColor, 18000 - nRightRotate, 18000 - nAttrRotate );
- pProcessor->process(aSequence);
- }
}
}
nPosX += nColWidth * nLayoutSign;
}
-
- // delete the lines for normal output only afterwards in the second step
-
- nX = nX1 > 0 ? (nX1-1) : static_cast<SCCOL>(0);
- for (; nX<=nX2+1; nX++) // visible part +- 1
- {
- sal_uInt16 nArrX = nX + 1;
- CellInfo& rInfo = rThisRowInfo.pCellInfo[nArrX];
- if ( rInfo.nRotateDir > ScRotateDir::Standard &&
- !rInfo.bHOverlapped && !rInfo.bVOverlapped )
- {
- size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
-
- // horizontal: extend adjacent line
- // (only when the rotated cell has a border)
- ScRotateDir nDir = rInfo.nRotateDir;
- if ( rArray.GetCellStyleTop( nCol, nRow ).Prim() )
- {
- svx::frame::Style aStyle( lcl_FindHorLine( mpDoc, nX, nY, nTab, nDir, true ), mnPPTY );
- rArray.SetCellStyleTop( nCol, nRow, aStyle );
- if( nRow > 0 )
- rArray.SetCellStyleBottom( nCol, nRow - 1, aStyle );
- }
- if ( rArray.GetCellStyleBottom( nCol, nRow ).Prim() )
- {
- svx::frame::Style aStyle( lcl_FindHorLine( mpDoc, nX, nY, nTab, nDir, false ), mnPPTY );
- rArray.SetCellStyleBottom( nCol, nRow, aStyle );
- if( nRow + 1 < rArray.GetRowCount() )
- rArray.SetCellStyleTop( nCol, nRow + 1, aStyle );
- }
-
- // always remove vertical borders
- if( !rArray.IsMergedOverlappedLeft( nCol, nRow ) )
- {
- rArray.SetCellStyleLeft( nCol, nRow, svx::frame::Style() );
- if( nCol > 0 )
- rArray.SetCellStyleRight( nCol - 1, nRow, svx::frame::Style() );
- }
- if( !rArray.IsMergedOverlappedRight( nCol, nRow ) )
- {
- rArray.SetCellStyleRight( nCol, nRow, svx::frame::Style() );
- if( nCol + 1 < rArray.GetColCount() )
- rArray.SetCellStyleLeft( nCol + 1, nRow, svx::frame::Style() );
- }
-
- // remove diagonal borders
- rArray.SetCellStyleTLBR( nCol, nRow, svx::frame::Style() );
- rArray.SetCellStyleBLTR( nCol, nRow, svx::frame::Style() );
- }
- }
}
nPosY += nRowHeight;
}
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 7191d2875910..7658a3765fe1 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -4632,8 +4632,10 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
pEngine.reset();
- if (bAnyRotated)
+ if (mrTabInfo.maArray.HasCellRotation())
+ {
DrawRotated(bPixelToLogic); //! call from outside ?
+ }
}
void ScOutputData::DrawRotated(bool bPixelToLogic)