summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx36
-rw-r--r--sc/source/ui/view/tabview.cxx26
2 files changed, 19 insertions, 43 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2ba6866f3db3..a0bf1f8a1bd8 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -192,16 +192,16 @@ gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
{
cairo_set_source_rgb(pCairo, 0, 0, 0);
- int nTotal = 0;
+ int nPrevious = 0;
for (const Header& rHeader : m_aHeaders)
{
GdkRectangle aRectangle;
if (m_eType == ROW)
{
aRectangle.x = 0;
- aRectangle.y = nTotal - 1;
+ aRectangle.y = nPrevious - 1;
aRectangle.width = ROW_HEADER_WIDTH - 1;
- aRectangle.height = rHeader.m_nSize;
+ aRectangle.height = rHeader.m_nSize - nPrevious;
// Left line.
cairo_rectangle(pCairo, aRectangle.x, aRectangle.y, 1, aRectangle.height);
cairo_fill(pCairo);
@@ -214,9 +214,9 @@ gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
}
else
{
- aRectangle.x = nTotal - 1;
+ aRectangle.x = nPrevious - 1;
aRectangle.y = 0;
- aRectangle.width = rHeader.m_nSize;
+ aRectangle.width = rHeader.m_nSize - nPrevious;
aRectangle.height = COLUMN_HEADER_HEIGHT - 1;
// Top line.
cairo_rectangle(pCairo, aRectangle.x, aRectangle.y, aRectangle.width, 1);
@@ -229,8 +229,8 @@ gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
cairo_fill(pCairo);
}
drawText(pCairo, aRectangle, rHeader.m_aText);
- nTotal += rHeader.m_nSize;
- if (nTotal > m_nSizePixel)
+ nPrevious = rHeader.m_nSize;
+ if (rHeader.m_nSize > m_nSizePixel)
break;
}
@@ -275,39 +275,29 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
gtk_widget_show(rWindow.m_pCornerButton->m_pDrawingArea);
rWindow.m_pRowBar->m_aHeaders.clear();
- int nTotal = 0;
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
{
- int nSize = lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str()));
- int nScrolledSize = nSize;
- if (nTotal + nSize >= rWindow.m_pRowBar->m_nPositionPixel)
+ int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
+ if (nSize >= rWindow.m_pRowBar->m_nPositionPixel)
{
- if (nTotal < rWindow.m_pRowBar->m_nPositionPixel)
- // First visible row: reduce height because the row is only partially visible.
- nScrolledSize = nTotal + nSize - rWindow.m_pRowBar->m_nPositionPixel;
+ int nScrolledSize = nSize - rWindow.m_pRowBar->m_nPositionPixel;
Header aHeader(nScrolledSize, rValue.second.get<std::string>("text"));
rWindow.m_pRowBar->m_aHeaders.push_back(aHeader);
}
- nTotal += nSize;
}
gtk_widget_show(rWindow.m_pRowBar->m_pDrawingArea);
gtk_widget_queue_draw(rWindow.m_pRowBar->m_pDrawingArea);
rWindow.m_pColumnBar->m_aHeaders.clear();
- nTotal = 0;
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
{
- int nSize = lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str()));
- int nScrolledSize = nSize;
- if (nTotal + nSize >= rWindow.m_pColumnBar->m_nPositionPixel)
+ int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
+ if (nSize >= rWindow.m_pColumnBar->m_nPositionPixel)
{
- if (nTotal < rWindow.m_pColumnBar->m_nPositionPixel)
- // First visible column: reduce width because the column is only partially visible.
- nScrolledSize = nTotal + nSize - rWindow.m_pColumnBar->m_nPositionPixel;
+ int nScrolledSize = nSize - rWindow.m_pColumnBar->m_nPositionPixel;
Header aHeader(nScrolledSize, rValue.second.get<std::string>("text"));
rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader);
}
- nTotal += nSize;
}
gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index d197750f68c2..b4703d993dee 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2295,6 +2295,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;
@@ -2308,22 +2309,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;
@@ -2332,6 +2324,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;
@@ -2345,20 +2338,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;