Kaydet (Commit) 708d1c5a authored tarafından Miklos Vajna's avatar Miklos Vajna

sc lok: emit RowColumnHeader info in twips

As that's the unit we use everywhere else in the LOK API. Also, make the
ScGlobal::nScreenPPTX/Y calculation more precise, otherwise rounding
errors occur during the pixel -> twip conversion.

Example with the old precision: col height is 103 px, nScreenPPTY is
0.067, twips is 1537.3134328358208, convering it back is 102.487562189
px.

Example with the new precision: col height is 103 px, nScreenPPTY is
0.0667, twips is 1544.2278860569716, convering it back is 102.948525737
px.

Change-Id: I19f5285508ef0c751614d07969b3a7a037e7d1ec
üst f570f837
...@@ -250,7 +250,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi ...@@ -250,7 +250,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
rWindow.m_pRowBar->m_aHeaders.clear(); rWindow.m_pRowBar->m_aHeaders.clear();
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows")) for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
{ {
Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text")); int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
Header aHeader(nSize, rValue.second.get<std::string>("text"));
rWindow.m_pRowBar->m_aHeaders.push_back(aHeader); rWindow.m_pRowBar->m_aHeaders.push_back(aHeader);
} }
gtk_widget_show(rWindow.m_pRowBar->m_pDrawingArea); gtk_widget_show(rWindow.m_pRowBar->m_pDrawingArea);
...@@ -259,7 +260,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi ...@@ -259,7 +260,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
rWindow.m_pColumnBar->m_aHeaders.clear(); rWindow.m_pColumnBar->m_aHeaders.clear();
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns")) for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
{ {
Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text")); int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
Header aHeader(nSize, rValue.second.get<std::string>("text"));
rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader); rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader);
} }
gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea); gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
......
...@@ -545,9 +545,9 @@ void ScGlobal::UpdatePPT( OutputDevice* pDev ) ...@@ -545,9 +545,9 @@ void ScGlobal::UpdatePPT( OutputDevice* pDev )
if ( !pDev ) if ( !pDev )
pDev = Application::GetDefaultDevice(); pDev = Application::GetDefaultDevice();
Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); Point aPix1000 = pDev->LogicToPixel( Point(10000,10000), MAP_TWIP );
nScreenPPTX = aPix1000.X() / 1000.0; nScreenPPTX = aPix1000.X() / 10000.0;
nScreenPPTY = aPix1000.Y() / 1000.0; nScreenPPTY = aPix1000.Y() / 10000.0;
nPPTZoom = nCurrentZoom; nPPTZoom = nCurrentZoom;
} }
} }
......
...@@ -2289,12 +2289,15 @@ OUString ScTabView::getRowColumnHeaders() ...@@ -2289,12 +2289,15 @@ OUString ScTabView::getRowColumnHeaders()
SCROW nEndRow = 0; SCROW nEndRow = 0;
pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow); pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
double nPPTX = aViewData.GetPPTX();
double nPPTY = aViewData.GetPPTY();
boost::property_tree::ptree aRows; boost::property_tree::ptree aRows;
for (SCROW nRow = 0; nRow <= nEndRow; ++nRow) for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
{ {
boost::property_tree::ptree aRow; boost::property_tree::ptree aRow;
sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow); sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
aRow.put("size", OString::number(nSize).getStr()); aRow.put("size", OString::number(nSize / nPPTY).getStr());
OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow); OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
aRow.put("text", aText.toUtf8().getStr()); aRow.put("text", aText.toUtf8().getStr());
aRows.push_back(std::make_pair("", aRow)); aRows.push_back(std::make_pair("", aRow));
...@@ -2305,7 +2308,7 @@ OUString ScTabView::getRowColumnHeaders() ...@@ -2305,7 +2308,7 @@ OUString ScTabView::getRowColumnHeaders()
{ {
boost::property_tree::ptree aCol; boost::property_tree::ptree aCol;
sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol); sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
aCol.put("size", OString::number(nSize).getStr()); aCol.put("size", OString::number(nSize / nPPTX).getStr());
OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol); OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
aCol.put("text", aText.toUtf8().getStr()); aCol.put("text", aText.toUtf8().getStr());
aCols.push_back(std::make_pair("", aCol)); aCols.push_back(std::make_pair("", aCol));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment