[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - desktop/qa sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Nov 4 02:49:30 PST 2015
desktop/qa/desktop_lib/test_desktop_lib.cxx | 54 +++++++++++++++++++++++++---
sc/source/ui/view/tabview.cxx | 26 +++----------
2 files changed, 55 insertions(+), 25 deletions(-)
New commits:
commit 77004e1af2e5348cf7d566ada5bc859b311f161d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 4 10:59:08 2015 +0100
CppunitTest_desktop_lib: test absolute positions for row/column headers
Change-Id: If2526647221fef2c6b18b21b589192239d8a89ad
(cherry picked from commit 2bed1867531fc91d1bd20da226d3fa012356125d)
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d40344e..5170785 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -369,6 +369,35 @@ void DesktopLOKTest::testPasteWriter()
void DesktopLOKTest::testRowColumnHeaders()
{
+ /*
+ * Payload example:
+ *
+ * {
+ * "rows": [
+ * {
+ * "size": "254.987250637468",
+ * "text": "1"
+ * },
+ * {
+ * "size": "509.974501274936",
+ * "text": "2"
+ * }
+ * ],
+ * "columns": [
+ * {
+ * "size": "1274.93625318734",
+ * "text": "A"
+ * },
+ * {
+ * "size": "2549.87250637468",
+ * "text": "B"
+ * }
+ * ]
+ * }
+ *
+ * "size" defines the bottom/right boundary of a row/column in twips (size between 0 and boundary)
+ * "text" has the header label in UTF-8
+ */
LibLODocument_Impl* pDocument = loadDoc("search.ods");
boost::property_tree::ptree aTree;
char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
@@ -377,23 +406,38 @@ void DesktopLOKTest::testRowColumnHeaders()
CPPUNIT_ASSERT(!aStream.str().empty());
boost::property_tree::read_json(aStream, aTree);
+ sal_Int32 nPrevious = 0;
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
{
sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
CPPUNIT_ASSERT(nSize > 0);
OString aText(rValue.second.get<std::string>("text").c_str());
- // This failed, as the first item did not contain the text of the first row.
- CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
- break;
+ if (!nPrevious)
+ // This failed, as the first item did not contain the text of the first row.
+ CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
+ else
+ {
+ // Make sure that size is absolute: the first two items have the same relative size.
+ CPPUNIT_ASSERT(nPrevious < nSize);
+ break;
+ }
+ nPrevious = nSize;
}
+ nPrevious = 0;
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
{
sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
CPPUNIT_ASSERT(nSize > 0);
OString aText(rValue.second.get<std::string>("text").c_str());
- CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
- break;
+ if (!nPrevious)
+ CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
+ else
+ {
+ CPPUNIT_ASSERT(nPrevious < nSize);
+ break;
+ }
+ nPrevious = nSize;
}
}
commit e0d0614db9ad3e41430426159296d331ff3d0012
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 4 10:32:23 2015 +0100
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
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 2c4a696..2c4b721 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;
More information about the Libreoffice-commits
mailing list