[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 11 commits - desktop/qa desktop/source include/vcl sc/inc sc/source sd/source sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 3 08:10:11 PST 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   32 +++++++++
 desktop/source/lib/init.cxx                 |   68 ++++++++++++++++++--
 desktop/source/lib/lokandroid.cxx           |    2 
 include/vcl/ITiledRenderable.hxx            |   15 ++++
 sc/inc/docuno.hxx                           |    7 +-
 sc/source/core/data/global.cxx              |    6 -
 sc/source/ui/inc/tabview.hxx                |    2 
 sc/source/ui/unoobj/docuno.cxx              |   19 ++++-
 sc/source/ui/view/tabview.cxx               |   91 ++++++++++++++++++++++++++++
 sd/source/ui/inc/unomodel.hxx               |    4 -
 sd/source/ui/unoidl/unomodel.cxx            |    6 -
 sw/inc/unotxdoc.hxx                         |    4 -
 sw/source/uibase/uno/unotxdoc.cxx           |    4 -
 13 files changed, 231 insertions(+), 29 deletions(-)

New commits:
commit c36c16c346b411f8862904f0d5f9c5c597363e90
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 16:26:46 2015 +0100

    sc lok: avoid placeholder row when providing all headers
    
    In case the logic visible area is known, info is provided only about the
    visible headers. Given that only relative sizes (no absolute positions)
    are provided, a placeholder row/col is added to the result that contains
    the total size of the skipped items.
    
    These placeholder items are not needed when providing all headers, so
    don't emit them.
    
    Change-Id: I48ccb73554313f4d2bb420e4402995719b0f9f7d
    (cherry picked from commit 788cec0a60dcfce6d86c820e9d0f7a1eb634f7bf)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 38664c5..5313f14 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -72,6 +72,7 @@ public:
     void testSaveAs();
     void testSaveAsCalc();
     void testPasteWriter();
+    void testRowColumnHeaders();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(testGetStyles);
@@ -84,6 +85,7 @@ public:
     CPPUNIT_TEST(testSaveAs);
     CPPUNIT_TEST(testSaveAsCalc);
     CPPUNIT_TEST(testPasteWriter);
+    CPPUNIT_TEST(testRowColumnHeaders);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -352,6 +354,36 @@ void DesktopLOKTest::testPasteWriter()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testRowColumnHeaders()
+{
+    LibLODocument_Impl* pDocument = loadDoc("search.ods");
+    boost::property_tree::ptree aTree;
+    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
+    std::stringstream aStream(pJSON);
+    free(pJSON);
+    CPPUNIT_ASSERT(!aStream.str().empty());
+
+    boost::property_tree::read_json(aStream, aTree);
+    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;
+    }
+
+    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;
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index ab77b47..8edec1b 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2332,7 +2332,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
         }
         if (!bSkip)
         {
-            if (aRows.empty())
+            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;
@@ -2369,7 +2369,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
         }
         if (!bSkip)
         {
-            if (aCols.empty())
+            if (aCols.empty() && nTotal > 0)
             {
                 boost::property_tree::ptree aCol;
                 aCol.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTX())).getStr());
commit 326b9f5e19b0ad2f7fb5dcc078e55c7ed9b3b265
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 15:37:31 2015 +0100

    sc lok: allow requesting column headers only for a logic area
    
    Change-Id: Iacd8f11917e929c6a1579c6a1553eb7840df5fba
    (cherry picked from commit 0fe622f66ee04f25b05c2069f573010e6f517915)

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 1cb869c..ab77b47 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2351,14 +2351,38 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
     }
 
     boost::property_tree::ptree aCols;
+    nTotal = 0;
+    nTotalPixels = 0;
     for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
     {
-        boost::property_tree::ptree aCol;
         sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
-        aCol.put("size", OString::number(nSize).getStr());
         OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
-        aCol.put("text", aText.toUtf8().getStr());
-        aCols.push_back(std::make_pair("", aCol));
+
+        bool bSkip = false;
+        if (!rRectangle.IsEmpty())
+        {
+            long nLeft = std::max(rRectangle.Left(), nTotal);
+            long nRight = std::min(rRectangle.Right(), nTotal + nSize);
+            if (nRight < nLeft)
+                // They do not intersect.
+                bSkip = true;
+        }
+        if (!bSkip)
+        {
+            if (aCols.empty())
+            {
+                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("text", aText.toUtf8().getStr());
+            aCols.push_back(std::make_pair("", aCol));
+        }
+        nTotal += nSize;
+        nTotalPixels += long(nSize * aViewData.GetPPTX());
     }
 
     boost::property_tree::ptree aTree;
commit 8a284e678e50c875c68f7d3e155fe92cc43393c9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 15:05:37 2015 +0100

    sc lok: allow requesting row headers only for a logic area
    
    So that for large documents it's not needed to query all of them on
    load, but (similar to tiled rendering itself) it's possible to query the
    data that affects the visible area.
    
    One catch is that the row sizes are relative, so there is a placeholder
    row in case the visible area is not the top left corner, and
    constructing its size needs special care. Normally the handed out twip
    values have to be floored after twip->px conversion, but this one is
    already rounded (as the total is a sum of px values, again becase of the
    previous floor rule), so need to play the +0.5 trick to allow clients
    always just flooring the logic conversion result they get.
    
    (cherry picked from commit 75303695eb4bfe6c8fdea2cad0d3ed3f912f95c9)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    	sc/inc/docuno.hxx
    
    Change-Id: I64a155582acdee7b2acc741d77a2c462409b91a8

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3c813c7..72a2176 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1213,6 +1213,9 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
 
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand)
 {
+    OString aCommand(pCommand);
+    static const OString aViewRowColumnHeaders(".uno:ViewRowColumnHeaders");
+
     if (!strcmp(pCommand, ".uno:CharFontName"))
     {
         return getFonts(pCommand);
@@ -1221,7 +1224,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     {
         return getStyles(pThis, pCommand);
     }
-    else if (OString(pCommand) == ".uno:ViewRowColumnHeaders")
+    else if (aCommand.startsWith(aViewRowColumnHeaders))
     {
         ITiledRenderable* pDoc = getTiledRenderable(pThis);
         if (!pDoc)
@@ -1230,7 +1233,45 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
             return 0;
         }
 
-        OUString aHeaders = pDoc->getRowColumnHeaders();
+        Rectangle aRectangle;
+        if (aCommand.getLength() > aViewRowColumnHeaders.getLength())
+        {
+            // Command has parameters.
+            int nX = 0;
+            int nY = 0;
+            int nWidth = 0;
+            int nHeight = 0;
+            OString aArguments = aCommand.copy(aViewRowColumnHeaders.getLength() + 1);
+            sal_Int32 nParamIndex = 0;
+            do
+            {
+                OString aParamToken = aArguments.getToken(0, '&', nParamIndex);
+                sal_Int32 nIndex = 0;
+                OString aKey;
+                OString aValue;
+                do
+                {
+                    OString aToken = aParamToken.getToken(0, '=', nIndex);
+                    if (!aKey.getLength())
+                        aKey = aToken;
+                    else
+                        aValue = aToken;
+                }
+                while (nIndex >= 0);
+                if (aKey == "x")
+                    nX = aValue.toInt32();
+                else if (aKey == "y")
+                    nY = aValue.toInt32();
+                else if (aKey == "width")
+                    nWidth = aValue.toInt32();
+                else if (aKey == "height")
+                    nHeight = aValue.toInt32();
+            }
+            while (nParamIndex >= 0);
+            aRectangle = Rectangle(nX, nY, nX + nWidth, nY + nHeight);
+        }
+
+        OUString aHeaders = pDoc->getRowColumnHeaders(aRectangle);
         OString aString = OUStringToOString(aHeaders, RTL_TEXTENCODING_UTF8);
         char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
         strcpy(pMemory, aString.getStr());
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 369758d..c24370a 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -150,8 +150,11 @@ public:
 
     /**
      * Get position and content of row/column headers of Calc documents.
+     *
+     * @param rRectangle - if not empty, then limit the output only to the area of this rectangle
+     * @return a JSON describing position/content of rows/columns
      */
-    virtual OUString getRowColumnHeaders()
+    virtual OUString getRowColumnHeaders(const Rectangle& /*rRectangle*/)
     {
         return OUString();
     }
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 8daa699..58363d6 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -423,7 +423,7 @@ public:
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
 
     /// @see vcl::ITiledRenderable::getRowColumnHeaders().
-    virtual OUString getRowColumnHeaders() SAL_OVERRIDE;
+    virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) SAL_OVERRIDE;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 5b08520..548742c 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -521,7 +521,7 @@ public:
     void ResetAutoSpell();
     void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
     /// @see ScModelObj::getRowColumnHeaders().
-    OUString getRowColumnHeaders();
+    OUString getRowColumnHeaders(const Rectangle& rRectangle);
 };
 
 #endif
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9049b5d..c84b13c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -855,7 +855,7 @@ bool ScModelObj::isMimeTypeSupported()
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
 }
 
-OUString ScModelObj::getRowColumnHeaders()
+OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
 {
     ScViewData* pViewData = ScDocShell::GetViewData();
     if (!pViewData)
@@ -865,7 +865,7 @@ OUString ScModelObj::getRowColumnHeaders()
     if (!pTabView)
         return OUString();
 
-    return pTabView->getRowColumnHeaders();
+    return pTabView->getRowColumnHeaders(rRectangle);
 }
 
 void ScModelObj::initializeForTiledRendering()
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 2d886bc..1cb869c 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2303,7 +2303,7 @@ void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<ed
     }
 }
 
-OUString ScTabView::getRowColumnHeaders()
+OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
 {
     ScDocument* pDoc = aViewData.GetDocument();
     if (!pDoc)
@@ -2314,14 +2314,40 @@ OUString ScTabView::getRowColumnHeaders()
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
 
     boost::property_tree::ptree aRows;
+    long nTotal = 0;
+    long nTotalPixels = 0;
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
     {
-        boost::property_tree::ptree aRow;
         sal_uInt16 nSize = pDoc->GetOriginalHeight(nRow, aViewData.GetTabNo());
-        aRow.put("size", OString::number(nSize).getStr());
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
-        aRow.put("text", aText.toUtf8().getStr());
-        aRows.push_back(std::make_pair("", aRow));
+
+        bool bSkip = false;
+        if (!rRectangle.IsEmpty())
+        {
+            long nTop = std::max(rRectangle.Top(), nTotal);
+            long nBottom = std::min(rRectangle.Bottom(), nTotal + nSize);
+            if (nBottom < nTop)
+                // They do not intersect.
+                bSkip = true;
+        }
+        if (!bSkip)
+        {
+            if (aRows.empty())
+            {
+                // 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("text", aText.toUtf8().getStr());
+            aRows.push_back(std::make_pair("", aRow));
+        }
+        nTotal += nSize;
+        nTotalPixels += long(nSize * aViewData.GetPPTY());
     }
 
     boost::property_tree::ptree aCols;
commit 30d04756881ec60f80173387a836ae74874f7b54
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 14:34:58 2015 +0100

    ScGlobal::UpdatePPT: make conversion more precise
    
    Old situation was (96 DPI, 100% zoom): 0.06669 factor, 1088 pixels,
    result is 16311 twips (1087.4 pixels).
    
    New situation is: 0.066669 factor, 1088 pixels, result is 16319 twips
    (1087.93 pixels).
    
    Change-Id: I0ff11520fd719aefd2b351a6d4ef949d66b66282
    (cherry picked from commit cce7d78baa91ab348e85407ada8387c9c89176cb)

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 8303770..4846857 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -544,9 +544,9 @@ void ScGlobal::UpdatePPT( OutputDevice* pDev )
 
         if ( !pDev )
             pDev = Application::GetDefaultDevice();
-        Point aPix1000 = pDev->LogicToPixel( Point(10000,10000), MAP_TWIP );
-        nScreenPPTX = aPix1000.X() / 10000.0;
-        nScreenPPTY = aPix1000.Y() / 10000.0;
+        Point aPix1000 = pDev->LogicToPixel( Point(100000,100000), MAP_TWIP );
+        nScreenPPTX = aPix1000.X() / 100000.0;
+        nScreenPPTY = aPix1000.Y() / 100000.0;
         nPPTZoom = nCurrentZoom;
     }
 }
commit 99d697c526742082352312652cd31d6b192a0ac7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 14:13:38 2015 +0100

    desktop: minimal Android build fix
    
    Change-Id: Icb9a40c5ded676ff3f8f7db198a90bb94540bdf4
    (cherry picked from commit a2141e39dbaecfdbf7a9b25abba25ad175746183)

diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 9d7ce6e..017ab8a 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -301,7 +301,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postUno
     if (arguments != NULL)
         pArguments = pEnv->GetStringUTFChars(arguments, NULL);
 
-    pDocument->pClass->postUnoCommand(pDocument, pCommand, pArguments);
+    pDocument->pClass->postUnoCommand(pDocument, pCommand, pArguments, false);
 
     pEnv->ReleaseStringUTFChars(command, pCommand);
     if (arguments != NULL)
commit a900c9c8ee048c052f5e637a67c9f18a91d575f5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 2 15:18:09 2015 +0100

    sc lok: fix rounding errors with non-100% zoom
    
    There were two problems here:
    
    1) ScTabView::getRowColumnHeaders() did not expose twip values directly,
    but used ScRow/ColBar::GetEntrySize(), which does a twip -> pixel
    conversion, and then converted it back to twip. Avoid this unnecessary
    roundtrip.
    
    2) ScViewData::ToPixel() trunaces the resulting float to an integer, so
    if the result is e.g. 67.7 pixels, then Calc handled that as 67, but
    gtktiledviewer rounded that up to 68, resulting in non-matching headers
    for the rendered tiles.
    
    (cherry picked from commit 861b28b88909ec39fc83fccc0ab23d288128aa0e)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: Ie6ed1ea923a423d1526eeb235b7b87106fd2f20b

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index f2f6179..2d886bc 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2313,15 +2313,12 @@ OUString ScTabView::getRowColumnHeaders()
     SCROW nEndRow = 0;
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
 
-    double nPPTX = aViewData.GetPPTX();
-    double nPPTY = aViewData.GetPPTY();
-
     boost::property_tree::ptree aRows;
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
     {
         boost::property_tree::ptree aRow;
-        sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
-        aRow.put("size", OString::number(nSize / nPPTY).getStr());
+        sal_uInt16 nSize = pDoc->GetOriginalHeight(nRow, aViewData.GetTabNo());
+        aRow.put("size", OString::number(nSize).getStr());
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
         aRow.put("text", aText.toUtf8().getStr());
         aRows.push_back(std::make_pair("", aRow));
@@ -2331,8 +2328,8 @@ OUString ScTabView::getRowColumnHeaders()
     for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
     {
         boost::property_tree::ptree aCol;
-        sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
-        aCol.put("size", OString::number(nSize / nPPTX).getStr());
+        sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
+        aCol.put("size", OString::number(nSize).getStr());
         OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
         aCol.put("text", aText.toUtf8().getStr());
         aCols.push_back(std::make_pair("", aCol));
commit 99e1227e96f61c8ab82f7ff67ccb486b0386577e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 2 10:56:43 2015 +0100

    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.
    
    (cherry picked from commit 708d1c5ab242b545ced598879233fc662d7e6cc0)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I19f5285508ef0c751614d07969b3a7a037e7d1ec

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 12b7cbb..8303770 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -544,9 +544,9 @@ void ScGlobal::UpdatePPT( OutputDevice* pDev )
 
         if ( !pDev )
             pDev = Application::GetDefaultDevice();
-        Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
-        nScreenPPTX = aPix1000.X() / 1000.0;
-        nScreenPPTY = aPix1000.Y() / 1000.0;
+        Point aPix1000 = pDev->LogicToPixel( Point(10000,10000), MAP_TWIP );
+        nScreenPPTX = aPix1000.X() / 10000.0;
+        nScreenPPTY = aPix1000.Y() / 10000.0;
         nPPTZoom = nCurrentZoom;
     }
 }
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index a3718f6..f2f6179 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2313,12 +2313,15 @@ OUString ScTabView::getRowColumnHeaders()
     SCROW nEndRow = 0;
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
 
+    double nPPTX = aViewData.GetPPTX();
+    double nPPTY = aViewData.GetPPTY();
+
     boost::property_tree::ptree aRows;
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
     {
         boost::property_tree::ptree aRow;
         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);
         aRow.put("text", aText.toUtf8().getStr());
         aRows.push_back(std::make_pair("", aRow));
@@ -2329,7 +2332,7 @@ OUString ScTabView::getRowColumnHeaders()
     {
         boost::property_tree::ptree aCol;
         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);
         aCol.put("text", aText.toUtf8().getStr());
         aCols.push_back(std::make_pair("", aCol));
commit 69de44eb55f522d961dee53d7778e0e86adfc990
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 30 16:00:03 2015 +0100

    ScTabView::getRowColumnHeaders: emit info about last formatted row/col
    
    Change-Id: I6b4f6eacde84433fa3865e62c692a3f97895b887
    (cherry picked from commit 3bdce53c557a1279e7e40d215e34405626bbc628)

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 4dccc9b..a3718f6 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2314,7 +2314,7 @@ OUString ScTabView::getRowColumnHeaders()
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
 
     boost::property_tree::ptree aRows;
-    for (SCROW nRow = 0; nRow < nEndRow; ++nRow)
+    for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
     {
         boost::property_tree::ptree aRow;
         sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
@@ -2325,7 +2325,7 @@ OUString ScTabView::getRowColumnHeaders()
     }
 
     boost::property_tree::ptree aCols;
-    for (SCCOL nCol = 0; nCol < nEndCol; ++nCol)
+    for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
     {
         boost::property_tree::ptree aCol;
         sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
commit a4225957dfcdfed525297683e988f8fa1948220d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 30 13:57:28 2015 +0100

    ScTabView::getRowColumnHeaders: include info about columns, too
    
    Change-Id: Id7db9fa9b451dcf2423142b38c2c12b369e16fae
    (cherry picked from commit ac47e5758e56ac30d98c1d6386dfad24ac59b1f6)

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index f177bbe..4dccc9b 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2324,8 +2324,20 @@ OUString ScTabView::getRowColumnHeaders()
         aRows.push_back(std::make_pair("", aRow));
     }
 
+    boost::property_tree::ptree aCols;
+    for (SCCOL nCol = 0; nCol < nEndCol; ++nCol)
+    {
+        boost::property_tree::ptree aCol;
+        sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
+        aCol.put("size", OString::number(nSize).getStr());
+        OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
+        aCol.put("text", aText.toUtf8().getStr());
+        aCols.push_back(std::make_pair("", aCol));
+    }
+
     boost::property_tree::ptree aTree;
     aTree.add_child("rows", aRows);
+    aTree.add_child("columns", aCols);
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
     return OUString::fromUtf8(aStream.str().c_str());
commit dc1656a71acca3a20ba99c162ae5169f15b362fc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 30 11:18:19 2015 +0100

    LOK: initial Document::getCommandValues() for RowColumnHeaders
    
    Only the row info and for the entire tiled rendering area as a start.
    
    (cherry picked from commit a7ce5f83343f8f6ba8a59b05820b3a2066c0ce9a)
    
    Conflicts:
    	sc/inc/docuno.hxx
    
    Change-Id: Idbccd805b355e8d151ab7025ac1cf0c686cb237b

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a3c4872..3c813c7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1221,7 +1221,23 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     {
         return getStyles(pThis, pCommand);
     }
-    else {
+    else if (OString(pCommand) == ".uno:ViewRowColumnHeaders")
+    {
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
+        if (!pDoc)
+        {
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+            return 0;
+        }
+
+        OUString aHeaders = pDoc->getRowColumnHeaders();
+        OString aString = OUStringToOString(aHeaders, RTL_TEXTENCODING_UTF8);
+        char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
+        strcpy(pMemory, aString.getStr());
+        return pMemory;
+    }
+    else
+    {
         gImpl->maLastExceptionMsg = "Unknown command, no values returned";
         return NULL;
     }
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 1bf14d8..369758d 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -148,6 +148,14 @@ public:
         return OUString();
     }
 
+    /**
+     * Get position and content of row/column headers of Calc documents.
+     */
+    virtual OUString getRowColumnHeaders()
+    {
+        return OUString();
+    }
+
     /// Sets the clipboard of the component.
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
 
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 8123a0e..8daa699 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -421,6 +421,9 @@ public:
 
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
+
+    /// @see vcl::ITiledRenderable::getRowColumnHeaders().
+    virtual OUString getRowColumnHeaders() SAL_OVERRIDE;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index d7e2a2d..5b08520 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -520,6 +520,8 @@ public:
     void EnableAutoSpell( bool bEnable );
     void ResetAutoSpell();
     void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
+    /// @see ScModelObj::getRowColumnHeaders().
+    OUString getRowColumnHeaders();
 };
 
 #endif
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 66ac7ec..9049b5d 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -855,6 +855,19 @@ bool ScModelObj::isMimeTypeSupported()
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
 }
 
+OUString ScModelObj::getRowColumnHeaders()
+{
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return OUString();
+
+    ScTabView* pTabView = pViewData->GetView();
+    if (!pTabView)
+        return OUString();
+
+    return pTabView->getRowColumnHeaders();
+}
+
 void ScModelObj::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index b5d308b..f177bbe 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -50,6 +50,7 @@
 
 #include <string>
 #include <algorithm>
+#include <boost/property_tree/json_parser.hpp>
 
 #include <basegfx/tools/zoomtools.hxx>
 
@@ -2302,4 +2303,32 @@ void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<ed
     }
 }
 
+OUString ScTabView::getRowColumnHeaders()
+{
+    ScDocument* pDoc = aViewData.GetDocument();
+    if (!pDoc)
+        return OUString();
+
+    SCCOL nEndCol = 0;
+    SCROW nEndRow = 0;
+    pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
+
+    boost::property_tree::ptree aRows;
+    for (SCROW nRow = 0; nRow < nEndRow; ++nRow)
+    {
+        boost::property_tree::ptree aRow;
+        sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
+        aRow.put("size", OString::number(nSize).getStr());
+        OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
+        aRow.put("text", aText.toUtf8().getStr());
+        aRows.push_back(std::make_pair("", aRow));
+    }
+
+    boost::property_tree::ptree aTree;
+    aTree.add_child("rows", aRows);
+    std::stringstream aStream;
+    boost::property_tree::write_json(aStream, aTree);
+    return OUString::fromUtf8(aStream.str().c_str());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 155044c76e5baa2c6d5193a0a8bb5165daae8095
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 28 09:44:37 2015 +0100

    vcl: getWindow() -> setClipboard() in ITiledRenderable
    
    It's cleaner to let the apps do this themselves than exposing their
    underlying vcl::Window.
    
    (cherry picked from commit bfd79be417358822023691cf7b7b2946906100ca)
    
    Conflicts:
    	sc/inc/docuno.hxx
    	sd/source/ui/inc/unomodel.hxx
    	sw/inc/unotxdoc.hxx
    
    Change-Id: Iff2442dd325fa65a0cf3ad4aa7f918542dab1e4c

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7eb7f52..a3c4872 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1097,14 +1097,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
     uno::Reference<datatransfer::XTransferable> xTransferable(new LOKTransferable(pMimeType, pData, nSize));
     uno::Reference<datatransfer::clipboard::XClipboard> xClipboard(new LOKClipboard());
     xClipboard->setContents(xTransferable, uno::Reference<datatransfer::clipboard::XClipboardOwner>());
-    vcl::Window* pWindow = pDoc->getWindow();
-    if (!pWindow)
-    {
-        gImpl->maLastExceptionMsg = "Document did not provide a window";
-        return false;
-    }
-
-    pWindow->SetClipboard(xClipboard);
+    pDoc->setClipboard(xClipboard);
     if (!pDoc->isMimeTypeSupported())
     {
         if (gImpl)
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 2a42f19..1bf14d8 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -148,8 +148,8 @@ public:
         return OUString();
     }
 
-    /// Returns the current vcl::Window of the component.
-    virtual vcl::Window* getWindow() = 0;
+    /// Sets the clipboard of the component.
+    virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
 
     /// If the current contents of the clipboard is something we can paste.
     virtual bool isMimeTypeSupported() = 0;
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 56fc762..8123a0e 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -416,8 +416,8 @@ public:
     /// @see lok::Document::resetSelection().
     virtual void resetSelection() SAL_OVERRIDE;
 
-    /// @see vcl::ITiledRenderable::getWindow().
-    virtual vcl::Window* getWindow() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::setClipboard().
+    virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
 
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9489a07..66ac7ec 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -831,15 +831,15 @@ void ScModelObj::resetSelection()
     pDocShell->GetDocument().GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
 }
 
-vcl::Window* ScModelObj::getWindow()
+void ScModelObj::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
 {
     SolarMutexGuard aGuard;
 
     ScViewData* pViewData = ScDocShell::GetViewData();
     if (!pViewData)
-        return 0;
+        return;
 
-    return pViewData->GetActiveWin();
+    pViewData->GetActiveWin()->SetClipboard(xClipboard);
 }
 
 bool ScModelObj::isMimeTypeSupported()
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 107069e..14162e3 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -258,8 +258,8 @@ public:
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see lok::Document::resetSelection().
     virtual void resetSelection() SAL_OVERRIDE;
-    /// @see vcl::ITiledRenderable::getWindow().
-    virtual vcl::Window* getWindow() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::setClipboard().
+    virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 31954b6..d2c6b5e 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2539,15 +2539,15 @@ void SdXImpressDocument::resetSelection()
     pSdrView->UnmarkAll();
 }
 
-vcl::Window* SdXImpressDocument::getWindow()
+void SdXImpressDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
 {
     SolarMutexGuard aGuard;
 
     DrawViewShell* pViewShell = GetViewShell();
     if (!pViewShell)
-        return 0;
+        return;
 
-    return pViewShell->GetActiveWindow();
+    pViewShell->GetActiveWindow()->SetClipboard(xClipboard);
 }
 
 bool SdXImpressDocument::isMimeTypeSupported()
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e590e2d..4a3307b 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -434,8 +434,8 @@ public:
     virtual void resetSelection() SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::getPartPageRectangles().
     virtual OUString getPartPageRectangles() SAL_OVERRIDE;
-    /// @see vcl::ITiledRenderable::getWindow().
-    virtual vcl::Window* getWindow() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::setClipboard().
+    virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 2a3c894..58a61e8 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3188,11 +3188,11 @@ OUString SwXTextDocument::getPartPageRectangles()
     return pWrtShell->getPageRectangles();
 }
 
-vcl::Window* SwXTextDocument::getWindow()
+void SwXTextDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
 {
     SolarMutexGuard aGuard;
 
-    return &pDocShell->GetView()->GetEditWin();
+    pDocShell->GetView()->GetEditWin().SetClipboard(xClipboard);
 }
 
 bool SwXTextDocument::isMimeTypeSupported()


More information about the Libreoffice-commits mailing list