[Libreoffice-commits] core.git: sc/source

tagezi lera.goncharuk at gmail.com
Wed Nov 22 10:32:35 UTC 2017


 sc/source/ui/inc/output.hxx   |    2 
 sc/source/ui/view/output2.cxx |  178 +++++++++---------------------------------
 2 files changed, 41 insertions(+), 139 deletions(-)

New commits:
commit 2f34bec2a7b939e24c3c5e884fdfe2057b732248
Author: tagezi <lera.goncharuk at gmail.com>
Date:   Wed Nov 22 01:01:43 2017 +0200

    tdf#39593 deduplicate code in ScOutputData
    
    Change-Id: Ie7efcdf23e65b2047af7972756c2ba11cc178672
    Reviewed-on: https://gerrit.libreoffice.org/45064
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 1e84d2920504..7abff2e541e2 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -250,6 +250,8 @@ private:
     bool Clip( DrawEditParam& rParam, const Size& aCellSize, OutputAreaParam& aAreaParam,
                long nEngineHeight, bool bWrapFields);
 
+    bool AdjustAreaParamClipRect(OutputAreaParam& aAreaParam);
+
 public:
     /**
      * @param nNewScrX: X-Offset in the output device for the table
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index a257c8f1a576..a3a0348a3dd5 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1847,30 +1847,9 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
                     long nOutHeight = aAreaParam.maAlignRect.GetHeight();
 
                     bool bOutside = ( aAreaParam.maClipRect.Right() < nScrX || aAreaParam.maClipRect.Left() >= nScrX + nScrW );
-                    if ( aAreaParam.maClipRect.Left() < nScrX )
-                    {
-                        aAreaParam.maClipRect.Left() = nScrX;
-                        aAreaParam.mbLeftClip = true;
-                    }
-                    if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
-                    {
-                        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
-                        aAreaParam.mbRightClip = true;
-                    }
-
+                    // Take adjusted values of aAreaParam.mbLeftClip and aAreaParam.mbRightClip
+                    bool bVClip = AdjustAreaParamClipRect(aAreaParam);
                     bool bHClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
-                    bool bVClip = false;
-
-                    if ( aAreaParam.maClipRect.Top() < nScrY )
-                    {
-                        aAreaParam.maClipRect.Top() = nScrY;
-                        bVClip = true;
-                    }
-                    if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
-                    {
-                        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;         //! minus one?
-                        bVClip = true;
-                    }
 
                     // check horizontal space
 
@@ -2740,6 +2719,35 @@ void ScOutputData::DrawEditParam::adjustForHyperlinkInPDF(Point aURLStart, const
     lcl_DoHyperlinkResult(pDev, aURLRect, maCell);
 }
 
+// Returns true if the rect is clipped vertically
+bool ScOutputData::AdjustAreaParamClipRect(OutputAreaParam& aAreaParam)
+{
+    if( aAreaParam.maClipRect.Left() < nScrX )
+    {
+        aAreaParam.maClipRect.Left() = nScrX;
+        aAreaParam.mbLeftClip = true;
+    }
+    if( aAreaParam.maClipRect.Right() > nScrX + nScrW )
+    {
+        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
+        aAreaParam.mbRightClip = true;
+    }
+
+    bool bVClip = false;
+
+    if( aAreaParam.maClipRect.Top() < nScrY )
+    {
+        aAreaParam.maClipRect.Top() = nScrY;
+        bVClip = true;
+    }
+    if( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
+    {
+        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;     //! minus one?
+        bVClip = true;
+    }
+    return bVClip;
+}
+
 void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
 {
     OSL_ASSERT(rParam.meOrient == SvxCellOrientation::Standard);
@@ -2970,37 +2978,10 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
     if (bOutside)
         return;
 
-    if ( aAreaParam.maClipRect.Left() < nScrX )
-    {
-        aAreaParam.maClipRect.Left() = nScrX;
-        aAreaParam.mbLeftClip = true;
-    }
-    if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
-    {
-        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
-        aAreaParam.mbRightClip = true;
-    }
-
-    bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+    // Also take fields in a cell with automatic breaks into account: clip to cell width
+    bool bClip = AdjustAreaParamClipRect(aAreaParam) || aAreaParam.mbLeftClip || aAreaParam.mbRightClip || bWrapFields;
     bool bSimClip = false;
 
-    if ( bWrapFields )
-    {
-        //  Fields in a cell with automatic breaks: clip to cell width
-        bClip = true;
-    }
-
-    if ( aAreaParam.maClipRect.Top() < nScrY )
-    {
-        aAreaParam.maClipRect.Top() = nScrY;
-        bClip = true;
-    }
-    if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
-    {
-        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;     //! minus one?
-        bClip = true;
-    }
-
     Size aCellSize;         // output area, excluding margins, in logical units
     if (rParam.mbPixelToLogic)
         aCellSize = mpRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) );
@@ -3187,37 +3168,10 @@ bool ScOutputData::Clip( DrawEditParam& rParam, const Size& aCellSize,
                          OutputAreaParam& aAreaParam, long nEngineHeight,
                          bool bWrapFields)
 {
-    if ( aAreaParam.maClipRect.Left() < nScrX )
-    {
-        aAreaParam.maClipRect.Left() = nScrX;
-        aAreaParam.mbLeftClip = true;
-    }
-    if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
-    {
-        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
-        aAreaParam.mbRightClip = true;
-    }
-
-    bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+    // Also take fields in a cell with automatic breaks into account: clip to cell width
+    bool bClip = AdjustAreaParamClipRect(aAreaParam) || aAreaParam.mbLeftClip || aAreaParam.mbRightClip || bWrapFields;
     bool bSimClip = false;
 
-    if ( bWrapFields )
-    {
-        //  Fields in a cell with automatic breaks: clip to cell width
-        bClip = true;
-    }
-
-    if ( aAreaParam.maClipRect.Top() < nScrY )
-    {
-        aAreaParam.maClipRect.Top() = nScrY;
-        bClip = true;
-    }
-    if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
-    {
-        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;     //! minus one?
-        bClip = true;
-    }
-
     const Size& aRefOne = mpRefDevice->PixelToLogic(Size(1,1));
     if ( nEngineHeight >= aCellSize.Height() + aRefOne.Height() )
     {
@@ -3945,37 +3899,10 @@ void ScOutputData::DrawEditStacked(DrawEditParam& rParam)
     if (bOutside)
         return;
 
-    if ( aAreaParam.maClipRect.Left() < nScrX )
-    {
-        aAreaParam.maClipRect.Left() = nScrX;
-        aAreaParam.mbLeftClip = true;
-    }
-    if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
-    {
-        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
-        aAreaParam.mbRightClip = true;
-    }
-
-    bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+    // Also take fields in a cell with automatic breaks into account: clip to cell width
+    bool bClip = AdjustAreaParamClipRect(aAreaParam) || aAreaParam.mbLeftClip || aAreaParam.mbRightClip || bWrapFields;
     bool bSimClip = false;
 
-    if ( bWrapFields )
-    {
-        //  Fields in a cell with automatic breaks: clip to cell width
-        bClip = true;
-    }
-
-    if ( aAreaParam.maClipRect.Top() < nScrY )
-    {
-        aAreaParam.maClipRect.Top() = nScrY;
-        bClip = true;
-    }
-    if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
-    {
-        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;     //! minus one?
-        bClip = true;
-    }
-
     Size aCellSize;         // output area, excluding margins, in logical units
     if (rParam.mbPixelToLogic)
         aCellSize = mpRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) );
@@ -4291,37 +4218,10 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
     if (bOutside)
         return;
 
-    if ( aAreaParam.maClipRect.Left() < nScrX )
-    {
-        aAreaParam.maClipRect.Left() = nScrX;
-        aAreaParam.mbLeftClip = true;
-    }
-    if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
-    {
-        aAreaParam.maClipRect.Right() = nScrX + nScrW;          //! minus one?
-        aAreaParam.mbRightClip = true;
-    }
-
-    bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+    // Also take fields in a cell with automatic breaks into account: clip to cell width
+    bool bClip = AdjustAreaParamClipRect(aAreaParam) || aAreaParam.mbLeftClip || aAreaParam.mbRightClip || bWrapFields;
     bool bSimClip = false;
 
-    if ( bWrapFields )
-    {
-        //  Fields in a cell with automatic breaks: clip to cell width
-        bClip = true;
-    }
-
-    if ( aAreaParam.maClipRect.Top() < nScrY )
-    {
-        aAreaParam.maClipRect.Top() = nScrY;
-        bClip = true;
-    }
-    if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
-    {
-        aAreaParam.maClipRect.Bottom() = nScrY + nScrH;     //! minus one?
-        bClip = true;
-    }
-
     Size aCellSize;         // output area, excluding margins, in logical units
     if (rParam.mbPixelToLogic)
         aCellSize = mpRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) );


More information about the Libreoffice-commits mailing list