[Libreoffice-commits] core.git: 3 commits - desktop/source include/vcl libreofficekit/qa sc/inc sc/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 3 06:40:49 PST 2015


 desktop/source/lib/init.cxx                         |   45 ++++++++++++-
 include/vcl/ITiledRenderable.hxx                    |    5 +
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   12 ++-
 sc/inc/docuno.hxx                                   |    2 
 sc/source/core/data/global.cxx                      |    6 -
 sc/source/ui/inc/tabview.hxx                        |    2 
 sc/source/ui/unoobj/docuno.cxx                      |    4 -
 sc/source/ui/view/tabview.cxx                       |   68 +++++++++++++++++---
 8 files changed, 123 insertions(+), 21 deletions(-)

New commits:
commit 0fe622f66ee04f25b05c2069f573010e6f517915
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

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index e2e25f9..615f0d9 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2327,14 +2327,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 75303695eb4bfe6c8fdea2cad0d3ed3f912f95c9
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.
    
    Change-Id: I64a155582acdee7b2acc741d77a2c462409b91a8

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8d09c39..ca06d50 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1205,6 +1205,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);
@@ -1213,7 +1216,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)
@@ -1222,7 +1225,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 48a13ff..efa9bc2 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/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index e67db9f..fb05477 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -256,8 +256,16 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
     if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
     {
-        g_info("lok::Document::getCommandValues(.uno:ViewRowColumnHeaders)");
-        char* pValues = pDocument->pClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
+        std::stringstream aCommand;
+        aCommand << ".uno:ViewRowColumnHeaders";
+        aCommand << "?x=" << int(lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), rWindow.m_pColumnBar->m_nPositionPixel));
+        aCommand << "&width=" << int(lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), rWindow.m_pColumnBar->m_nSizePixel));
+        aCommand << "&y=" << int(lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), rWindow.m_pRowBar->m_nPositionPixel));
+        aCommand << "&height=" << int(lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), rWindow.m_pRowBar->m_nSizePixel));
+        std::stringstream ss;
+        ss << "lok::Document::getCommandValues(" << aCommand.str() << ")";
+        g_info(ss.str().c_str());
+        char* pValues = pDocument->pClass->getCommandValues(pDocument, aCommand.str().c_str());
         std::stringstream aStream(pValues);
         free(pValues);
         assert(!aStream.str().empty());
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index e2a2dbc..96511886 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -406,7 +406,7 @@ public:
     virtual bool isMimeTypeSupported() override;
 
     /// @see vcl::ITiledRenderable::getRowColumnHeaders().
-    virtual OUString getRowColumnHeaders() override;
+    virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 51cb7c1..820aecd 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -518,7 +518,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 2e4bb66..45e5db9 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -872,7 +872,7 @@ bool ScModelObj::isMimeTypeSupported()
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
 }
 
-OUString ScModelObj::getRowColumnHeaders()
+OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
 {
     ScViewData* pViewData = ScDocShell::GetViewData();
     if (!pViewData)
@@ -882,7 +882,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 d11133b..e2e25f9 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2279,7 +2279,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)
@@ -2290,14 +2290,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 cce7d78baa91ab348e85407ada8387c9c89176cb
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

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index c97c026..1cd32b3 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -545,9 +545,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;
     }
 }


More information about the Libreoffice-commits mailing list