Kaydet (Commit) f76b2b3b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

calc mapmode: Convert ScOutputData::DrawGrid to draw in logic units.

Change-Id: Ie641c31e9023accf9d6bc510f8ca0b25ced3031b
üst 6a55792c
......@@ -42,8 +42,8 @@ public:
ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY );
~ScGridMerger();
void AddHorLine( long nX1, long nX2, long nY );
void AddVerLine( long nX, long nY1, long nY2 );
void AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY);
void AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2);
void Flush();
};
......
......@@ -297,7 +297,7 @@ public:
void SetSnapPixel( bool bSet = true );
void DrawGrid( bool bGrid, bool bPage );
void DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool bPage);
void DrawStrings( bool bPixelToLogic = false );
/// Draw all strings, or provide Rectangle where the text (defined by rAddress) would be drawn.
......
......@@ -86,8 +86,16 @@ void ScGridMerger::AddLine( long nStart, long nEnd, long nPos )
}
}
void ScGridMerger::AddHorLine( long nX1, long nX2, long nY )
void ScGridMerger::AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY)
{
if (bWorksInPixels)
{
Point aPoint(pDev->PixelToLogic(Point(nX1, nY)));
nX1 = aPoint.X();
nY = aPoint.Y();
nX2 = pDev->PixelToLogic(Point(nX2, 0)).X();
}
if ( bOptimize )
{
if ( bVertical )
......@@ -101,8 +109,16 @@ void ScGridMerger::AddHorLine( long nX1, long nX2, long nY )
pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
}
void ScGridMerger::AddVerLine( long nX, long nY1, long nY2 )
void ScGridMerger::AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2)
{
if (bWorksInPixels)
{
Point aPoint(pDev->PixelToLogic(Point(nX, nY1)));
nX = aPoint.X();
nY1 = aPoint.Y();
nY2 = pDev->PixelToLogic(Point(0, nY2)).Y();
}
if ( bOptimize )
{
if ( !bVertical )
......
......@@ -720,15 +720,20 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
aOutputData.DrawDocumentBackground();
pContentDev->SetMapMode(MAP_PIXEL);
if ( bGridFirst && ( bGrid || bPage ) )
aOutputData.DrawGrid( bGrid, bPage );
aOutputData.DrawGrid(*pContentDev, bGrid, bPage);
MapMode aPrevMapMode = pContentDev->GetMapMode();
pContentDev->SetMapMode(MAP_PIXEL);
aOutputData.DrawBackground();
pContentDev->SetMapMode(aPrevMapMode);
if ( !bGridFirst && ( bGrid || bPage ) )
aOutputData.DrawGrid( bGrid, bPage );
aOutputData.DrawGrid(*pContentDev, bGrid, bPage);
pContentDev->SetMapMode(MAP_PIXEL);
if ( bPageMode )
{
......
......@@ -498,9 +498,9 @@ void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const Recta
if ( nPass == ( bNextToMark ? SC_HDRPAINT_SEL_BOTTOM : SC_HDRPAINT_BOTTOM ) )
{
if (bVertical)
aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aEndPos.Y() );
aGrid.AddHorLine(/* here we work in pixels */ true, aScrPos.X(), aEndPos.X(), aEndPos.Y());
else
aGrid.AddVerLine( aEndPos.X(), aScrPos.Y(), aEndPos.Y() );
aGrid.AddVerLine(/* here we work in pixels */ true, aEndPos.X(), aScrPos.Y(), aEndPos.Y());
// thick bottom for hidden rows
// (drawn directly, without aGrid)
......
......@@ -307,7 +307,7 @@ void ScOutputData::SetSyntaxMode( bool bNewMode )
}
}
void ScOutputData::DrawGrid( bool bGrid, bool bPage )
void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool bPage)
{
SCCOL nX;
SCROW nY;
......@@ -324,20 +324,16 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
if (bPagebreakMode)
bPage = false; // no "normal" breaks over the whole width/height
//! um den einen Pixel sieht das Metafile (oder die Druck-Ausgabe) anders aus
//! als die Bildschirmdarstellung, aber wenigstens passen Druck und Metafile zusammen
Size aOnePixel = mpDev->PixelToLogic(Size(1,1));
long nOneX = aOnePixel.Width();
long nOneY = aOnePixel.Height();
if (bMetaFile)
nOneX = nOneY = 1;
long nLayoutSign = bLayoutRTL ? -1 : 1;
long nSignedOneX = nOneX * nLayoutSign;
// It is a big mess to distinguish when we are using pixels and when logic
// units for drawing. Ultimately we want to work only in the logic units,
// but until that happens, we need to special-case:
// * metafile
// * drawing to the screen - everything is internally counted in pixels there
bool bWorksInPixels = bMetaFile;
if ( eType == OUTTYPE_WINDOW )
{
bWorksInPixels = true;
const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
aPageColor.SetColor( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor );
aManualColor.SetColor( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor );
......@@ -348,8 +344,20 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
aManualColor = aGridColor;
}
mpDev->SetLineColor( aGridColor );
ScGridMerger aGrid( mpDev, nOneX, nOneY );
long nOneX = 1;
long nOneY = 1;
if (!bWorksInPixels)
{
Size aOnePixel = rRenderContext.PixelToLogic(Size(1,1));
nOneX = aOnePixel.Width();
nOneY = aOnePixel.Height();
}
long nLayoutSign = bLayoutRTL ? -1 : 1;
long nSignedOneX = nOneX * nLayoutSign;
rRenderContext.SetLineColor(aGridColor);
ScGridMerger aGrid(&rRenderContext, nOneX, nOneY);
// vertical lines
......@@ -383,7 +391,7 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
if (nBreak != nBreakOld)
{
aGrid.Flush();
mpDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
rRenderContext.SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
nBreak ? aPageColor : aGridColor );
nBreakOld = nBreak;
}
......@@ -441,14 +449,14 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
if (pThisRowInfo->bChanged && !bHOver)
{
aGrid.AddVerLine( nPosX-nSignedOneX, nPosY, nNextY-nOneY );
aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nPosY, nNextY-nOneY);
}
nPosY = nNextY;
}
}
else
{
aGrid.AddVerLine( nPosX-nSignedOneX, nScrY, nScrY+nScrH-nOneY );
aGrid.AddVerLine(bWorksInPixels, nPosX-nSignedOneX, nScrY, nScrY+nScrH-nOneY);
}
}
}
......@@ -489,7 +497,7 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
if (nBreakOld != nBreak)
{
aGrid.Flush();
mpDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
rRenderContext.SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
(nBreak) ? aPageColor : aGridColor );
nBreakOld = nBreak;
}
......@@ -535,7 +543,7 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
}
if (!bVOver)
{
aGrid.AddHorLine( nPosX, nNextX-nSignedOneX, nPosY-nOneY );
aGrid.AddHorLine(bWorksInPixels, nPosX, nNextX-nSignedOneX, nPosY-nOneY);
}
}
nPosX = nNextX;
......@@ -543,7 +551,7 @@ void ScOutputData::DrawGrid( bool bGrid, bool bPage )
}
else
{
aGrid.AddHorLine( nScrX, nScrX+nScrW-nOneX, nPosY-nOneY );
aGrid.AddHorLine(bWorksInPixels, nScrX, nScrX+nScrW-nOneX, nPosY-nOneY);
}
}
}
......
......@@ -563,7 +563,7 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr
if (!bMetaFile && pViewData)
pDev->SetMapMode(aMode);
aOutputData.DrawGrid( true, false ); // no page breaks
aOutputData.DrawGrid(*pDev, true, false); // no page breaks
pDev->SetLineColor( COL_BLACK );
......@@ -1619,7 +1619,7 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
}
if (aTableParam.bGrid)
aOutputData.DrawGrid( true, false ); // no page breaks
aOutputData.DrawGrid(*pDev, true, false); // no page breaks
aOutputData.AddPDFNotes(); // has no effect if not rendering PDF with notes enabled
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment