[Libreoffice-commits] core.git: include/vcl vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Wed Mar 19 03:40:18 PDT 2014


 include/vcl/outdev.hxx     |    3 ++
 include/vcl/print.hxx      |   23 +++++++++++++---------
 vcl/source/gdi/outdev4.cxx |   46 ++++++++++++++++++++++++++++-----------------
 vcl/source/gdi/print.cxx   |    7 ++++++
 4 files changed, 53 insertions(+), 26 deletions(-)

New commits:
commit c16186f1b96ecf0933a16f4c9fb196c5be18d7d9
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Fri Mar 14 21:31:59 2014 +1100

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index da696af..e3986ac 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 bc53bd6..f72781c 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 8df71b8..c3873b6 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 92a7d3d..8e97d4b 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()
 {


More information about the Libreoffice-commits mailing list