summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-03-14 21:31:59 +1100
committerCaolán McNamara <caolanm@redhat.com>2014-03-19 10:39:51 +0000
commitc16186f1b96ecf0933a16f4c9fb196c5be18d7d9 (patch)
tree8734af9f01b0fbfa2a836fdcd3a41e41d01e9b0b
parent3fa4b0a00f78e940b32d546bac410890719502fd (diff)
fdo#74702 Move gradient steps logic into OutputDevice or Printer classes
Currently we work out the number of gradient steps based on the type of class that is being used. We calculate the number differntly for printers. However, we should let the Printers class work this out. Also, the function is very long - I have moved most of the calculation logic to it's own function. Made some very small formatting changes to outdev.hxx. Change-Id: I91b8787d885c1c8d2aa2205f25e5c7f82607c0ea Reviewed-on: https://gerrit.libreoffice.org/8586 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/vcl/outdev.hxx3
-rw-r--r--include/vcl/print.hxx23
-rw-r--r--vcl/source/gdi/outdev4.cxx46
-rw-r--r--vcl/source/gdi/print.cxx7
4 files changed, 53 insertions, 26 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index da696aff81cf..e3986acd783f 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -798,6 +798,8 @@ public:
protected:
OutputDevice();
+ virtual long ImplGetGradientStepCount( long nMinRect );
+
private:
typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
@@ -807,6 +809,7 @@ private:
SAL_DLLPRIVATE void ImplClearFontData( bool bNewFontLists );
SAL_DLLPRIVATE void ImplRefreshFontData( bool bNewFontLists );
SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
+ SAL_DLLPRIVATE long ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf );
public:
virtual ~OutputDevice();
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index bc53bd6e87d7..f72781c908f8 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -223,18 +223,18 @@ private:
Printer* mpNext;
VirtualDevice* mpDisplayDev;
PrinterOptions* mpPrinterOptions;
- OUString maPrinterName;
- OUString maDriver;
- OUString maPrintFile;
- OUString maJobName;
+ OUString maPrinterName;
+ OUString maDriver;
+ OUString maPrintFile;
+ OUString maJobName;
JobSetup maJobSetup;
Point maPageOffset;
Size maPaperSize;
- sal_uLong mnError;
- sal_uInt16 mnCurPage;
- sal_uInt16 mnCurPrintPage;
- sal_uInt16 mnPageQueueSize;
- sal_uInt16 mnCopyCount;
+ sal_uLong mnError;
+ sal_uInt16 mnCurPage;
+ sal_uInt16 mnCurPrintPage;
+ sal_uInt16 mnPageQueueSize;
+ sal_uInt16 mnCopyCount;
bool mbDefPrinter;
bool mbPrinting;
bool mbJobActive;
@@ -265,9 +265,14 @@ private:
SAL_DLLPRIVATE bool EndJob();
SAL_DLLPRIVATE Printer( const Printer& rPrinter );
SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter );
+
public:
SAL_DLLPRIVATE void ImplStartPage();
SAL_DLLPRIVATE void ImplEndPage();
+
+protected:
+ long ImplGetGradientStepCount( long nMinRect );
+
public:
void DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient );
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx
index 8df71b8e3ed9..c3873b6adcb4 100644
--- a/vcl/source/gdi/outdev4.cxx
+++ b/vcl/source/gdi/outdev4.cxx
@@ -140,6 +140,34 @@ inline sal_uInt8 ImplGetGradientColorValue( long nValue )
return (sal_uInt8)nValue;
}
+long OutputDevice::ImplGetGradientStepCount( long nMinRect )
+{
+ long nInc = (nMinRect < 50) ? 2 : 4;
+
+ return nInc;
+}
+
+long OutputDevice::ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf )
+{
+ // calculate step count
+ long nStepCount = rGradient.GetSteps();
+
+ // generate nStepCount, if not passed
+ long nMinRect = rRect.GetHeight();
+
+ if ( !nStepCount )
+ {
+ long nInc;
+
+ nInc = ImplGetGradientStepCount (nMinRect);
+ if ( !nInc || bMtf )
+ nInc = 1;
+ nStepCount = nMinRect / nInc;
+ }
+
+ return nStepCount;
+}
+
void OutputDevice::ImplDrawLinearGradient( const Rectangle& rRect,
const Gradient& rGradient,
bool bMtf, const PolyPolygon* pClipPolyPoly )
@@ -243,23 +271,7 @@ void OutputDevice::ImplDrawLinearGradient( const Rectangle& rRect,
}
// calculate step count
- long nStepCount = rGradient.GetSteps();
- // generate nStepCount, if not passed
- long nMinRect = aRect.GetHeight();
- if ( !nStepCount )
- {
- long nInc = 1;
- if ( meOutDevType != OUTDEV_PRINTER && !bMtf )
- {
- nInc = (nMinRect < 50) ? 2 : 4;
- }
- else
- {
- // Use display-equivalent step size calculation
- nInc = (nMinRect < 800) ? 10 : 20;
- }
- nStepCount = nMinRect / nInc;
- }
+ long nStepCount = ImplGetGradientSteps( rGradient, aRect, bMtf );
// minimal three steps and maximal as max color steps
long nAbsRedSteps = std::abs( nEndRed - nStartRed );
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 92a7d3d7f486..8e97d4bc62c2 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -663,6 +663,13 @@ void Printer::ImplUpdateFontList()
ImplUpdateFontData( true );
}
+long Printer::ImplGetGradientStepCount( long nMinRect )
+{
+ // use display-equivalent step size calculation
+ long nInc = (nMinRect < 800) ? 10 : 20;
+
+ return nInc;
+}
Printer::Printer()
{