From e0d0614db9ad3e41430426159296d331ff3d0012 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 4 Nov 2015 10:32:23 +0100 Subject: sc lok: return absolute positions for row/column headers This simplifies both LOK API implementation and client code, and also clients are no longer required to floor() the twip -> pixel conversion result. (cherry picked from commit 84dedf4ff8e7267efa95674e6545c80c9b995cb2) Conflicts: libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx Change-Id: I63dbc05f53e8f7582b964c43d5da3aad51ede10d --- sc/source/ui/view/tabview.cxx | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 2c4a696884d5..2c4b7213fa85 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -2325,6 +2325,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle) for (SCROW nRow = 0; nRow <= nEndRow; ++nRow) { sal_uInt16 nSize = pDoc->GetOriginalHeight(nRow, aViewData.GetTabNo()); + long nSizePixels = ScViewData::ToPixel(nSize, aViewData.GetPPTY()); OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow); bool bSkip = false; @@ -2338,22 +2339,13 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle) } if (!bSkip) { - if (aRows.empty() && nTotal > 0) - { - // The sizes are relative sizes, so include the total skipped size before the real items. - boost::property_tree::ptree aRow; - // Client is required to floor(), rather than round() the sizes in general, so add 0.5 here to have rounding. - aRow.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTY())).getStr()); - aRow.put("text", ""); - aRows.push_back(std::make_pair("", aRow)); - } boost::property_tree::ptree aRow; - aRow.put("size", OString::number(nSize).getStr()); + aRow.put("size", OString::number((nTotalPixels + nSizePixels) / aViewData.GetPPTY()).getStr()); aRow.put("text", aText.toUtf8().getStr()); aRows.push_back(std::make_pair("", aRow)); } nTotal += nSize; - nTotalPixels += long(nSize * aViewData.GetPPTY()); + nTotalPixels += nSizePixels; } boost::property_tree::ptree aCols; @@ -2362,6 +2354,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle) for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol) { sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo()); + long nSizePixels = ScViewData::ToPixel(nSize, aViewData.GetPPTX()); OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol); bool bSkip = false; @@ -2375,20 +2368,13 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle) } if (!bSkip) { - if (aCols.empty() && nTotal > 0) - { - boost::property_tree::ptree aCol; - aCol.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTX())).getStr()); - aCol.put("text", ""); - aCols.push_back(std::make_pair("", aCol)); - } boost::property_tree::ptree aCol; - aCol.put("size", OString::number(nSize).getStr()); + aCol.put("size", OString::number((nTotalPixels + nSizePixels) / aViewData.GetPPTX()).getStr()); aCol.put("text", aText.toUtf8().getStr()); aCols.push_back(std::make_pair("", aCol)); } nTotal += nSize; - nTotalPixels += long(nSize * aViewData.GetPPTX()); + nTotalPixels += nSizePixels; } boost::property_tree::ptree aTree; -- cgit v1.2.3