Blame SOURCES/0267-sc-lok-allow-requesting-column-headers-only-for-a-lo.patch

135360
From fb9903c682fdabcc425caea737d81eda1a33f902 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Tue, 3 Nov 2015 15:37:31 +0100
135360
Subject: [PATCH 267/398] sc lok: allow requesting column headers only for a
135360
 logic area
135360
135360
Change-Id: Iacd8f11917e929c6a1579c6a1553eb7840df5fba
135360
(cherry picked from commit 0fe622f66ee04f25b05c2069f573010e6f517915)
135360
---
135360
 sc/source/ui/view/tabview.cxx | 32 ++++++++++++++++++++++++++++----
135360
 1 file changed, 28 insertions(+), 4 deletions(-)
135360
135360
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
135360
index 1cb869cbd432..ab77b47bed0c 100644
135360
--- a/sc/source/ui/view/tabview.cxx
135360
+++ b/sc/source/ui/view/tabview.cxx
135360
@@ -2351,14 +2351,38 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
135360
     }
135360
 
135360
     boost::property_tree::ptree aCols;
135360
+    nTotal = 0;
135360
+    nTotalPixels = 0;
135360
     for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
135360
     {
135360
-        boost::property_tree::ptree aCol;
135360
         sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
135360
-        aCol.put("size", OString::number(nSize).getStr());
135360
         OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
135360
-        aCol.put("text", aText.toUtf8().getStr());
135360
-        aCols.push_back(std::make_pair("", aCol));
135360
+
135360
+        bool bSkip = false;
135360
+        if (!rRectangle.IsEmpty())
135360
+        {
135360
+            long nLeft = std::max(rRectangle.Left(), nTotal);
135360
+            long nRight = std::min(rRectangle.Right(), nTotal + nSize);
135360
+            if (nRight < nLeft)
135360
+                // They do not intersect.
135360
+                bSkip = true;
135360
+        }
135360
+        if (!bSkip)
135360
+        {
135360
+            if (aCols.empty())
135360
+            {
135360
+                boost::property_tree::ptree aCol;
135360
+                aCol.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTX())).getStr());
135360
+                aCol.put("text", "");
135360
+                aCols.push_back(std::make_pair("", aCol));
135360
+            }
135360
+            boost::property_tree::ptree aCol;
135360
+            aCol.put("size", OString::number(nSize).getStr());
135360
+            aCol.put("text", aText.toUtf8().getStr());
135360
+            aCols.push_back(std::make_pair("", aCol));
135360
+        }
135360
+        nTotal += nSize;
135360
+        nTotalPixels += long(nSize * aViewData.GetPPTX());
135360
     }
135360
 
135360
     boost::property_tree::ptree aTree;
135360
-- 
135360
2.12.0
135360