[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 54 commits - basctl/source chart2/source compilerplugins/clang cui/source dbaccess/source desktop/qa desktop/source drawinglayer/source extensions/source filter/source forms/source framework/source include/svx include/vcl libreofficekit/qa libreofficekit/source reportdesign/source sc/inc sc/source sd/qa sd/source sfx2/source solenv/CompilerTest_compilerplugins_clang.mk svtools/source svx/sdi svx/source sw/inc sw/sdi sw/source toolkit/source unusedcode.README vcl/source

Jan Holesovsky kendy at collabora.com
Sat Feb 18 08:38:49 UTC 2017


 basctl/source/accessibility/accessibledialogcontrolshape.cxx               |    2 
 basctl/source/basicide/basidesh.cxx                                        |   13 
 basctl/source/basicide/bastypes.cxx                                        |    2 
 chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx                |    2 
 chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx               |    2 
 chart2/source/controller/main/ChartController.cxx                          |    2 
 compilerplugins/clang/test/vclwidgets.cxx                                  |   86 +
 compilerplugins/clang/vclwidgets.cxx                                       |   84 +
 cui/source/customize/cfg.cxx                                               |    2 
 cui/source/dialogs/hangulhanjadlg.cxx                                      |    4 
 cui/source/dialogs/passwdomdlg.cxx                                         |    4 
 cui/source/tabpages/chardlg.cxx                                            |    2 
 cui/source/tabpages/swpossizetabpage.cxx                                   |    4 
 dbaccess/source/ui/app/AppDetailPageHelper.cxx                             |    4 
 dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx                       |    2 
 dbaccess/source/ui/querydesign/JoinTableView.cxx                           |   18 
 dbaccess/source/ui/relationdesign/RelationTableView.cxx                    |    5 
 dbaccess/source/ui/uno/ColumnControl.cxx                                   |    2 
 desktop/qa/data/comments.odt                                               |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx                                |  233 ++++-
 desktop/source/lib/init.cxx                                                |   25 
 drawinglayer/source/processor2d/vclhelperbufferdevice.cxx                  |    6 
 extensions/source/dbpilots/gridwizard.cxx                                  |    2 
 extensions/source/propctrlr/defaulthelpprovider.cxx                        |    2 
 extensions/source/propctrlr/formlinkdialog.cxx                             |    4 
 extensions/source/propctrlr/handlerhelper.cxx                              |    2 
 filter/source/msfilter/msdffimp.cxx                                        |   38 
 forms/source/richtext/richtextcontrol.cxx                                  |    2 
 forms/source/solar/component/navbarcontrol.cxx                             |    2 
 framework/source/layoutmanager/layoutmanager.cxx                           |    2 
 framework/source/layoutmanager/toolbarlayoutmanager.cxx                    |   18 
 framework/source/uielement/addonstoolbarwrapper.cxx                        |    2 
 framework/source/uielement/toolbarwrapper.cxx                              |    2 
 include/svx/postattr.hxx                                                   |   26 
 include/svx/svxids.hrc                                                     |    1 
 include/vcl/menu.hxx                                                       |    2 
 include/vcl/outdev.hxx                                                     |    1 
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx                        |  437 ++++++++--
 libreofficekit/source/gtk/lokdocview.cxx                                   |   63 +
 reportdesign/source/ui/dlg/CondFormat.cxx                                  |    2 
 reportdesign/source/ui/report/ViewsWindow.cxx                              |   34 
 sc/inc/address.hxx                                                         |    2 
 sc/inc/docuno.hxx                                                          |    3 
 sc/source/core/data/column2.cxx                                            |   43 
 sc/source/core/data/global.cxx                                             |    6 
 sc/source/ui/dbgui/filtdlg.cxx                                             |    6 
 sc/source/ui/dbgui/pfiltdlg.cxx                                            |    4 
 sc/source/ui/dbgui/pvfundlg.cxx                                            |    2 
 sc/source/ui/docshell/docfunc.cxx                                          |   16 
 sc/source/ui/docshell/docsh4.cxx                                           |   56 +
 sc/source/ui/inc/docsh.hxx                                                 |    3 
 sc/source/ui/inc/viewdata.hxx                                              |    1 
 sc/source/ui/miscdlgs/anyrefdg.cxx                                         |    3 
 sc/source/ui/unoobj/docuno.cxx                                             |   68 +
 sc/source/ui/view/cellsh1.cxx                                              |   18 
 sc/source/ui/view/gridwin.cxx                                              |   16 
 sc/source/ui/view/tabview.cxx                                              |  298 +++++-
 sc/source/ui/view/tabview3.cxx                                             |   24 
 sc/source/ui/view/tabview4.cxx                                             |    4 
 sd/qa/unit/data/ppt/FillPatterns.ppt                                       |binary
 sd/qa/unit/import-tests.cxx                                                |  339 +++++++
 sd/source/ui/framework/factories/BasicViewFactory.cxx                      |    2 
 sd/source/ui/inc/DrawViewShell.hxx                                         |    4 
 sd/source/ui/inc/PresentationViewShell.hxx                                 |    4 
 sd/source/ui/inc/ViewShell.hxx                                             |    4 
 sd/source/ui/slidesorter/controller/SlideSorterController.cxx              |   10 
 sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx              |    2 
 sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx                |    6 
 sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx               |    2 
 sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx              |    4 
 sd/source/ui/slidesorter/shell/SlideSorter.cxx                             |    6 
 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx                    |    2 
 sd/source/ui/slidesorter/view/SlideSorterView.cxx                          |   18 
 sd/source/ui/slidesorter/view/SlsToolTip.cxx                               |    6 
 sd/source/ui/unoidl/UnoDocumentSettings.cxx                                |    2 
 sd/source/ui/view/drviews1.cxx                                             |    8 
 sd/source/ui/view/presvish.cxx                                             |    7 
 sd/source/ui/view/viewshe2.cxx                                             |    4 
 sfx2/source/appl/workwin.cxx                                               |    8 
 sfx2/source/dialog/backingwindow.cxx                                       |    6 
 sfx2/source/doc/guisaveas.cxx                                              |    2 
 sfx2/source/doc/objmisc.cxx                                                |    2 
 sfx2/source/doc/printhelper.cxx                                            |    4 
 sfx2/source/doc/printhelper.hxx                                            |    2 
 sfx2/source/doc/sfxbasemodel.cxx                                           |    2 
 sfx2/source/sidebar/ResourceManager.cxx                                    |    2 
 sfx2/source/sidebar/UnoPanel.cxx                                           |    2 
 sfx2/source/view/lokhelper.cxx                                             |   14 
 solenv/CompilerTest_compilerplugins_clang.mk                               |    1 
 svtools/source/control/ctrltool.cxx                                        |    9 
 svtools/source/hatchwindow/hatchwindow.cxx                                 |    2 
 svtools/source/uno/genericunodialog.cxx                                    |    2 
 svx/sdi/svx.sdi                                                            |    2 
 svx/sdi/svxitems.sdi                                                       |    1 
 svx/source/dialog/srchdlg.cxx                                              |    2 
 svx/source/fmcomp/fmgridif.cxx                                             |    2 
 svx/source/form/datanavi.cxx                                               |    2 
 svx/source/form/fmtextcontrolshell.cxx                                     |    2 
 svx/source/form/formcontroller.cxx                                         |    2 
 svx/source/items/postattr.cxx                                              |   17 
 svx/source/svdraw/sdrpaintwindow.cxx                                       |    2 
 svx/source/tbxctrls/layctrl.cxx                                            |    2 
 svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx |    2 
 sw/inc/AnnotationWin.hxx                                                   |    4 
 sw/inc/PostItMgr.hxx                                                       |    5 
 sw/inc/SidebarWin.hxx                                                      |    7 
 sw/inc/postithelper.hxx                                                    |    2 
 sw/sdi/_textsh.sdi                                                         |   10 
 sw/sdi/swriter.sdi                                                         |    4 
 sw/source/core/edit/acorrect.cxx                                           |    2 
 sw/source/ui/dbui/createaddresslistdialog.cxx                              |    2 
 sw/source/ui/dbui/mmaddressblockpage.cxx                                   |    2 
 sw/source/ui/dbui/mmgreetingspage.cxx                                      |    2 
 sw/source/ui/frmdlg/frmpage.cxx                                            |    4 
 sw/source/ui/index/cnttab.cxx                                              |   42 
 sw/source/uibase/app/docsh2.cxx                                            |    2 
 sw/source/uibase/docvw/AnnotationWin.cxx                                   |   24 
 sw/source/uibase/docvw/PostItMgr.cxx                                       |  112 ++
 sw/source/uibase/docvw/SidebarWin.cxx                                      |   17 
 sw/source/uibase/shells/annotsh.cxx                                        |   13 
 sw/source/uibase/shells/textfld.cxx                                        |   69 +
 sw/source/uibase/uno/unotxdoc.cxx                                          |   10 
 toolkit/source/awt/stylesettings.cxx                                       |   10 
 toolkit/source/awt/vclxtoolkit.cxx                                         |   34 
 toolkit/source/awt/vclxwindow.cxx                                          |    8 
 toolkit/source/helper/vclunohelper.cxx                                     |    2 
 unusedcode.README                                                          |   20 
 vcl/source/app/help.cxx                                                    |    2 
 vcl/source/control/button.cxx                                              |    6 
 vcl/source/outdev/font.cxx                                                 |    5 
 vcl/source/window/accessibility.cxx                                        |    7 
 vcl/source/window/builder.cxx                                              |    7 
 vcl/source/window/menu.cxx                                                 |    4 
 vcl/source/window/syswin.cxx                                               |    2 
 vcl/source/window/taskpanelist.cxx                                         |    6 
 vcl/source/window/toolbox.cxx                                              |    4 
 vcl/source/window/window2.cxx                                              |    3 
 137 files changed, 2166 insertions(+), 530 deletions(-)

New commits:
commit 02a2cb8f3b0a0c1a85248a2fa6dd16f801b5957f
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Feb 2 19:53:16 2017 +0100

    sc tiled rendering: We keep increasing the precision here...
    
    ... so let's finally do it right, and count in double precision directly.
    
    Change-Id: Ic49cc42d9e61a1b9fa9853bfe93d2681a6be88b2
    (cherry picked from commit 27ca6387b7188d1805dda8906d809025a2d3fb95)

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 68d1d83..b16a656 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -529,9 +529,9 @@ void ScGlobal::Init()
 void ScGlobal::InitPPT()
 {
     OutputDevice* pDev = Application::GetDefaultDevice();
-    Point aPix1000 = pDev->LogicToPixel( Point(100000,100000), MapUnit::MapTwip );
-    nScreenPPTX = aPix1000.X() / 100000.0;
-    nScreenPPTY = aPix1000.Y() / 100000.0;
+
+    nScreenPPTX = double(pDev->GetDPIX()) / double(TWIPS_PER_INCH);
+    nScreenPPTY = double(pDev->GetDPIY()) / double(TWIPS_PER_INCH);
 }
 
 const OUString& ScGlobal::GetClipDocName()
commit 1951d7b2961fc8b48c17a9a30d7c2489857e4dc7
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 31 17:33:49 2017 +0100

    Replace a terribly expensive json parsing with a peek for the value.
    
    We should reduce the amount of callbacks from the core in the first place, so
    that we don't have to deduplicate this much here, but this already helps a
    lot.
    
    Change-Id: Idf4a3681ac0f47536e00c1d97152f3f8bb99894b
    (cherry picked from commit 20910ea89efb01406e35e9d942613123f78b637f)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 83c872c..a62b777 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -446,10 +446,26 @@ bool lcl_isViewCallbackType(const int type)
 
 int lcl_getViewId(const std::string& payload)
 {
-    boost::property_tree::ptree aTree;
-    std::stringstream aStream(payload);
-    boost::property_tree::read_json(aStream, aTree);
-    return aTree.get<int>("viewId");
+    // this is a cheap way how to get the viewId from a JSON message; proper
+    // parsing is terribly expensive, and we just need the viewId here
+    size_t viewIdPos = payload.find("viewId");
+    if (viewIdPos == std::string::npos)
+        return 0;
+
+    size_t numberPos = payload.find(":", viewIdPos + 6);
+    if (numberPos == std::string::npos)
+        return 0;
+
+    for (++numberPos; numberPos < payload.length(); ++numberPos)
+    {
+        if (payload[numberPos] == ',' || payload[numberPos] == '}' || (payload[numberPos] >= '0' && payload[numberPos] <= '9'))
+            break;
+    }
+
+    if (numberPos < payload.length() && payload[numberPos] >= '0' && payload[numberPos] <= '9')
+        return std::stoi(payload.substr(numberPos));
+
+    return 0;
 }
 
 }  // end anonymous namespace
commit 8f13d1ebe42dfea233df3b802202b91cfa82a11c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 31 16:47:54 2017 +0100

    Build the json message a much less expensive way.
    
    Change-Id: I10911deb52f6a0c65262f9d6af459cf6ddd2fae9
    (cherry picked from commit 230f04e92d3a3c492e12e0ef2392fc45c73dd762)

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 4aa35af..bfcd000 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -9,8 +9,6 @@
 
 #include <sfx2/lokhelper.hxx>
 
-#include <boost/property_tree/json_parser.hpp>
-
 #include <com/sun/star/frame/Desktop.hpp>
 
 #include <comphelper/processfactory.hxx>
@@ -112,14 +110,10 @@ bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
 
 void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell* pOtherView, int nType, const OString& rKey, const OString& rPayload)
 {
-    boost::property_tree::ptree aTree;
-    aTree.put("viewId", SfxLokHelper::getView(pThisView));
-    aTree.put(rKey.getStr(), rPayload.getStr());
-    aTree.put("part", pThisView->getPart());
-    aTree.put(rKey.getStr(), rPayload.getStr());
-    std::stringstream aStream;
-    boost::property_tree::write_json(aStream, aTree);
-    OString aPayload = aStream.str().c_str();
+    OString aPayload = OString("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView(pThisView)) +
+        "\", \"part\": \"" + OString::number(pThisView->getPart()) +
+        "\", \"" + rKey + "\": \"" + rPayload + "\" }";
+
     pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr());
 }
 
commit db15f1c9415908b10801b7bdfb0879ef834a1220
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Wed Nov 30 14:13:15 2016 +0100

    LOK - Calc: Increase the row limit to 10.000 rows.
    
    Change-Id: Ie91e4caf33d3b31df4c3de8dc6e78e223dc1e4b3
    Reviewed-on: https://gerrit.libreoffice.org/34216
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    (cherry picked from commit eb399d69aa5ad0c04affb830a522c5c1f130813f)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d193c4a..99ae560 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -598,46 +598,79 @@ void DesktopLOKTest::testRowColumnHeaders()
 
     pDocument->pClass->initializeForRendering(pDocument, nullptr);
 
+    long nWidth = 0;
+    long nHeight = 0;
+    pDocument->m_pDocumentClass->getDocumentSize(pDocument, &nWidth, &nHeight);
+    long nX = rtl::math::round(nWidth / 4.0);
+    long nY = rtl::math::round(nHeight / 4.0);
+    nWidth = rtl::math::round(nWidth / 2.0);
+    nHeight = rtl::math::round(nHeight / 2.0);
+
+    std::stringstream aPayload;
+    aPayload << ".uno:ViewRowColumnHeaders?x=" << nX << "&y=" << nY << "&width=" << nWidth << "&height=" << nHeight;
+
     boost::property_tree::ptree aTree;
-    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
+    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, aPayload.str().c_str());
     std::stringstream aStream(pJSON);
     free(pJSON);
+
     CPPUNIT_ASSERT(!aStream.str().empty());
 
     boost::property_tree::read_json(aStream, aTree);
     sal_Int32 nPrevious = 0;
+    bool bFirstHeader = true;
+    bool bNotEnoughHeaders = true;
     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());
-        if (!nPrevious)
-            // This failed, as the first item did not contain the text of the first row.
-            CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
+
+        if (bFirstHeader)
+        {
+            CPPUNIT_ASSERT(nSize <= nY);
+            CPPUNIT_ASSERT_EQUAL(OString("11"), aText);
+            bFirstHeader = false;
+        }
         else
         {
-            // Make sure that size is absolute: the first two items have the same relative size.
+            CPPUNIT_ASSERT(nSize > 0);
             CPPUNIT_ASSERT(nPrevious < nSize);
-            break;
+            if (nSize > nY + nHeight)
+            {
+                bNotEnoughHeaders = false;
+                break;
+            }
         }
         nPrevious = nSize;
     }
+    CPPUNIT_ASSERT(!bNotEnoughHeaders);
 
     nPrevious = 0;
+    bFirstHeader = true;
+    bNotEnoughHeaders = true;
     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());
-        if (!nPrevious)
-            CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
+        if (bFirstHeader)
+        {
+            CPPUNIT_ASSERT(nSize <= nX);
+            CPPUNIT_ASSERT_EQUAL(OString("4"), aText);
+            bFirstHeader = false;
+        }
         else
         {
+            CPPUNIT_ASSERT(nSize > 0);
             CPPUNIT_ASSERT(nPrevious < nSize);
-            break;
+            if (nSize > nX + nWidth)
+            {
+                bNotEnoughHeaders = false;
+                break;
+            }
         }
         nPrevious = nSize;
     }
+    CPPUNIT_ASSERT(!bNotEnoughHeaders);
 }
 
 void DesktopLOKTest::testHiddenRowHeaders()
@@ -646,29 +679,34 @@ void DesktopLOKTest::testHiddenRowHeaders()
 
     pDocument->pClass->initializeForRendering(pDocument, nullptr);
 
+    long nX = 0;
+    long nY = 0;
+    long nWidth = 0;
+    long nHeight = 0;
+    pDocument->m_pDocumentClass->getDocumentSize(pDocument, &nWidth, &nHeight);
+
+    std::stringstream aPayload;
+    aPayload << ".uno:ViewRowColumnHeaders?x=" << nX << "&y=" << nY << "&width=" << nWidth << "&height=" << nHeight;
+
     boost::property_tree::ptree aTree;
-    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
+    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, aPayload.str().c_str());
     std::stringstream aStream(pJSON);
     free(pJSON);
     CPPUNIT_ASSERT(!aStream.str().empty());
 
     boost::property_tree::read_json(aStream, aTree);
     sal_Int32 nPrevious = 0;
-    bool bFirst = true;
+    sal_Int32 nIndex = 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);
 
-        if (bFirst)
-            bFirst = false;
-        else
+        if (nIndex++ == 2)
         {
-            // nSize was 509, nPrevious was 254, i.e. hidden row wasn't reported as 0 height.
+            // nSize was 510, nPrevious was 255, i.e. hidden row wasn't reported as 0 height.
             CPPUNIT_ASSERT_EQUAL(nPrevious, nSize);
             break;
         }
-
         nPrevious = nSize;
     }
 }
commit caa9f9e35837f13608ae4b89b9214bb3b07468be
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Wed Nov 30 14:13:15 2016 +0100

    LOK - Calc: Increase the row limit to 10.000 rows.
    
    Change-Id: I2702b1e654dff816c8d66e82464ea578473dba60
    (cherry picked from commit e530c7c4bcaaeb99cecd6f3c2c303db2a114b555)

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 2c17dfd..aa5d4f1 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -71,7 +71,7 @@ const SCCOL       MAXCOL         = MAXCOLCOUNT - 1;
 const SCTAB       MAXTAB         = MAXTABCOUNT - 1;
 const SCCOLROW    MAXCOLROW      = MAXROW;
 // Maximun tiled rendering values
-const SCROW       MAXTILEDROW    = 1000;
+const SCROW       MAXTILEDROW    = 10000;
 // Limit the initial tab count to prevent users to set the count too high,
 // which could cause the memory usage of blank documents to exceed the
 // available system memory.
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index c05d098..080d12b 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -44,6 +44,9 @@
 #include "AccessibilityHints.hxx"
 #include "appoptio.hxx"
 #include "attrib.hxx"
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <sfx2/lokhelper.hxx>
 
 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
 
@@ -2307,82 +2310,273 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
     if (!pDoc)
         return OUString();
 
-    SCCOL nEndCol = 0;
+    if (rRectangle.IsEmpty())
+        return OUString();
+
+    rtl::OUStringBuffer aBuffer(256);
+    aBuffer.append("{ \"commandName\": \".uno:ViewRowColumnHeaders\",\n");
+
+    SCROW nStartRow = 0;
     SCROW nEndRow = 0;
-    pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
+    SCCOL nStartCol = 0;
+    SCCOL nEndCol = 0;
 
-    rtl::OUStringBuffer aBuffer(256 + (50 * nEndRow) + (50 * nEndCol));
+    /// *** start collecting ROWS ***
 
-    aBuffer.append("{ \"commandName\": \".uno:ViewRowColumnHeaders\",\n");
-    aBuffer.append("\"rows\": [\n");
+    /// 1) compute start and end rows
 
-    long nTotal = 0;
     long nTotalPixels = 0;
+    if (rRectangle.Top() < rRectangle.Bottom())
+    {
+        long nUpperBoundPx = rRectangle.Top() / TWIPS_PER_PIXEL;
+        long nLowerBoundPx = rRectangle.Bottom() / TWIPS_PER_PIXEL;
+        nEndRow = MAXTILEDROW;
+        for (SCROW nRow = 0; nRow <= MAXTILEDROW; ++nRow)
+        {
+            if (nTotalPixels > nLowerBoundPx)
+            {
+                nEndRow = nRow; // first row below the rectangle
+                break;
+            }
+
+            const sal_uInt16 nSize = pDoc->GetRowHeight(nRow, aViewData.GetTabNo());
+            const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+
+            nTotalPixels += nSizePx;
+
+            if (nTotalPixels < nUpperBoundPx)
+            {
+                nStartRow = nRow; // last row above the rectangle
+                continue;
+            }
+        }
+
+        nStartRow -= 1;
+        nEndRow += 2;
+
+        if (nStartRow < 0) nStartRow = 0;
+        if (nEndRow > MAXTILEDROW) nEndRow = MAXTILEDROW;
+    }
+
+    aBuffer.ensureCapacity( aBuffer.getCapacity() + (50 * (nEndRow - nStartRow + 1)) );
+
+
+    long nVisibleRows = nEndRow - nStartRow;
+    if (nVisibleRows < 25)
+        nVisibleRows = 25;
+
+
+    /// 2) if we are approaching current max tiled row, signal a size changed event
+    ///    and invalidate the involved area
+
+    if (nEndRow > aViewData.GetMaxTiledRow() - nVisibleRows)
+    {
+        ScDocShell* pDocSh = aViewData.GetDocShell();
+        ScModelObj* pModelObj = pDocSh ? ScModelObj::getImplementation( pDocSh->GetModel() ) : nullptr;
+        Size aOldSize(0, 0);
+        if (pModelObj)
+            aOldSize = pModelObj->getDocumentSize();
+
+        aViewData.SetMaxTiledRow(std::min(std::max(nEndRow, aViewData.GetMaxTiledRow()) + nVisibleRows, (long)(MAXTILEDROW)));
+
+        Size aNewSize(0, 0);
+        if (pModelObj)
+            aNewSize = pModelObj->getDocumentSize();
+
+        if (pDocSh)
+        {
+            // Provide size in the payload, so clients don't have to
+            // call lok::Document::getDocumentSize().
+            std::stringstream ss;
+            ss << aNewSize.Width() << ", " << aNewSize.Height();
+            OString sSize = ss.str().c_str();
+            aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+
+            // New area extended to the bottom of the sheet after last row
+            // excluding overlapping area with aNewColArea
+            Rectangle aNewRowArea(0, aOldSize.getHeight(), aOldSize.getWidth(), aNewSize.getHeight());
+
+            // Only invalidate if spreadsheet extended to the bottom
+            if (aNewRowArea.getHeight())
+            {
+                SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewRowArea.toString());
+            }
+        }
+    }
+
+
+    /// 3) create string data for rows
+
+    aBuffer.append("\"rows\": [\n");
+
     bool bFirstRow = true;
-    for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
+    if (nStartRow  == 0 && nStartRow != nEndRow)
+    {
+        aBuffer.append("{ \"text\": \"").append("0").append("\", ");
+        aBuffer.append("\"size\": \"").append(OUString::number(0)).append("\" }");
+        bFirstRow = false;
+    }
+
+    nTotalPixels = 0;
+    for (SCROW nRow = 0; nRow < nEndRow; ++nRow)
     {
         // nSize will be 0 for hidden rows.
         const sal_uInt16 nSize = pDoc->GetRowHeight(nRow, aViewData.GetTabNo());
-        const long nSizePixels = ScViewData::ToPixel(nSize, aViewData.GetPPTY());
-        const OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
+        const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+        nTotalPixels += nSizePx;
+
+        if (nRow < nStartRow)
+            continue;
 
-        bool bSkip = false;
-        if (!rRectangle.IsEmpty())
+        OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
+
+        if (!bFirstRow)
+        {
+            aBuffer.append(", ");
+        }
+        else
         {
-            long nTop = std::max(rRectangle.Top(), nTotal);
-            long nBottom = std::min(rRectangle.Bottom(), nTotal + nSize);
-            if (nBottom < nTop)
-                // They do not intersect.
-                bSkip = true;
+            aText = OUString::number(nStartRow + 1);
         }
-        if (!bSkip)
+
+        aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
+        aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\" }");
+        bFirstRow = false;
+    }
+
+    aBuffer.append("]");
+    ///  end collecting ROWS
+
+
+    aBuffer.append(",\n");
+
+    /// *** start collecting COLS ***
+
+    /// 1) compute start and end columns
+
+    nTotalPixels = 0;
+    if (rRectangle.Left() < rRectangle.Right())
+    {
+        long nLeftBoundPx = rRectangle.Left() / TWIPS_PER_PIXEL;
+        long nRightBoundPx = rRectangle.Right() / TWIPS_PER_PIXEL;
+        nEndCol = MAXCOL;
+        for (SCCOL nCol = 0; nCol <= MAXCOL; ++nCol)
         {
-            if (!bFirstRow)
-                aBuffer.append(", ");
+            if (nTotalPixels > nRightBoundPx)
+            {
+                nEndCol = nCol;
+                break;
+            }
+
+            const sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
+            const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+            nTotalPixels += nSizePx;
+            if (nTotalPixels < nLeftBoundPx)
+            {
+                nStartCol = nCol;
+                continue;
+            }
+        }
+
+        nStartCol -= 1;
+        nEndCol += 2;
+
+        if (nStartCol < 0) nStartCol = 0;
+        if (nEndCol > MAXCOL) nEndCol = MAXCOL;
+    }
 
-            aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-            aBuffer.append("\"size\": \"").append(OUString::number((nTotalPixels + nSizePixels) / aViewData.GetPPTY())).append("\" }");
-            bFirstRow = false;
+    aBuffer.ensureCapacity( aBuffer.getCapacity() + (50 * (nEndCol - nStartCol + 1)) );
+
+    long nVisibleCols = nEndCol - nStartCol;
+    if (nVisibleCols < 10)
+        nVisibleCols = 10;
+
+
+    /// 2) if we are approaching current max tiled column, signal a size changed event
+    ///    and invalidate the involved area
+
+    if (nEndCol > aViewData.GetMaxTiledCol() - nVisibleCols)
+    {
+        ScDocShell* pDocSh = aViewData.GetDocShell();
+        ScModelObj* pModelObj = pDocSh ? ScModelObj::getImplementation( pDocSh->GetModel() ) : nullptr;
+        Size aOldSize(0, 0);
+        if (pModelObj)
+            aOldSize = pModelObj->getDocumentSize();
+
+        aViewData.SetMaxTiledCol(std::min(std::max(nEndCol, aViewData.GetMaxTiledCol()) + nVisibleCols, (long)(MAXCOL)));
+
+        Size aNewSize(0, 0);
+        if (pModelObj)
+            aNewSize = pModelObj->getDocumentSize();
+
+        if (pDocSh)
+        {
+            // Provide size in the payload, so clients don't have to
+            // call lok::Document::getDocumentSize().
+            std::stringstream ss;
+            ss << aNewSize.Width() << ", " << aNewSize.Height();
+            OString sSize = ss.str().c_str();
+            aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+
+            // New area extended to the right of the sheet after last column
+            // including overlapping area with aNewRowArea
+            Rectangle aNewColArea(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight());
+
+            // Only invalidate if spreadsheet extended to the bottom
+            if (aNewColArea.getWidth())
+            {
+                SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewColArea.toString());
+            }
         }
-        nTotal += nSize;
-        nTotalPixels += nSizePixels;
     }
 
-    aBuffer.append("],\n\"columns\":\n[");
 
-    nTotal = 0;
+    /// 3) create string data for columns
+
+    aBuffer.append("\"columns\": [\n");
+
+    bool bFirstCol = true;
+    if (nStartCol  == 0 && nStartCol != nEndCol )
+    {
+        aBuffer.append("{ \"text\": \"").append("0").append("\", ");
+        aBuffer.append("\"size\": \"").append(OUString::number(0)).append("\" }");
+        bFirstCol = false;
+    }
+
     nTotalPixels = 0;
-    bFirstRow = true;
-    for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
+    for (SCCOL nCol = 0; nCol < nEndCol; ++nCol)
     {
+        // nSize will be 0 for hidden columns.
         const sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
-        const long nSizePixels = ScViewData::ToPixel(nSize, aViewData.GetPPTX());
-        const OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
+        const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+        nTotalPixels += nSizePx;
+
+        if (nCol < nStartCol)
+            continue;
 
-        bool bSkip = false;
-        if (!rRectangle.IsEmpty())
+        OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
+
+        if (!bFirstCol)
         {
-            long nLeft = std::max(rRectangle.Left(), nTotal);
-            long nRight = std::min(rRectangle.Right(), nTotal + nSize);
-            if (nRight < nLeft)
-                // They do not intersect.
-                bSkip = true;
+            aBuffer.append(", ");
         }
-        if (!bSkip)
+        else
         {
-            if (!bFirstRow)
-                aBuffer.append(", ");
-
-            aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-            aBuffer.append("\"size\": \"").append(OUString::number((nTotalPixels + nSizePixels) / aViewData.GetPPTX())).append("\" }");
-            bFirstRow = false;
+            aText = OUString::number(nStartCol + 1);
         }
-        nTotal += nSize;
-        nTotalPixels += nSizePixels;
+
+        aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
+        aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\" }");
+        bFirstCol = false;
     }
 
-    aBuffer.append("]\n}");
-    return aBuffer.makeStringAndClear();
+    aBuffer.append("]");
+    ///  end collecting COLs
+
+    aBuffer.append("\n}");
+    OUString sRet = aBuffer.makeStringAndClear();
+
+    return sRet;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5a55e78fee52864a253fbd318f4b623b1d9e1a9d
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Jun 1 14:24:12 2016 -0400

    sc lok: Limit number of row with LOK to 1000 rows.
    
    Change-Id: Ic7fe2dec012efb8ba180feb4d3df6f4bfbf6c38a
    (cherry picked from commit f5e330abbf3d8cd9625b29fcc228a742b35aa657)

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index d801d05..2c17dfd 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -70,6 +70,8 @@ const SCROW       MAXROW         = MAXROWCOUNT - 1;
 const SCCOL       MAXCOL         = MAXCOLCOUNT - 1;
 const SCTAB       MAXTAB         = MAXTABCOUNT - 1;
 const SCCOLROW    MAXCOLROW      = MAXROW;
+// Maximun tiled rendering values
+const SCROW       MAXTILEDROW    = 1000;
 // Limit the initial tab count to prevent users to set the count too high,
 // which could cause the memory usage of blank documents to exceed the
 // available system memory.
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 5f8b97f..f6c3282 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -141,6 +141,7 @@
 #include <sfx2/lokhelper.hxx>
 
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
 
 #include <memory>
 #include <vector>
@@ -1838,6 +1839,16 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
     pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
     SCTAB nTab = pViewData->GetTabNo();
 
+    // FIXME: this is to limit the number of rows handled in the Online
+    // to 1000; this will be removed again when the performance
+    // bottlenecks are sorted out
+    if ( comphelper::LibreOfficeKit::isActive() && nPosY > MAXTILEDROW - 1 )
+    {
+        nButtonDown = 0;
+        nMouseStatus = SC_GM_NONE;
+        return;
+    }
+
     // Auto filter / pivot table / data select popup.  This shouldn't activate the part.
 
     if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() )
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index fb3d6b4..d6c3546 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -333,6 +333,12 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
 
     //  DeactivateIP only for MarkListHasChanged
 
+    // FIXME: this is to limit the number of rows handled in the Online
+    // to 1000; this will be removed again when the performance
+    // bottlenecks are sorted out
+    if (comphelper::LibreOfficeKit::isActive())
+        nPosY = std::min(nPosY, MAXTILEDROW);
+
     if ( nPosX != nOldX || nPosY != nOldY || bNew )
     {
         ScTabViewShell* pViewShell = aViewData.GetViewShell();
@@ -362,10 +368,10 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
                     aOldSize = pModelObj->getDocumentSize();
 
                 if (nPosX > aViewData.GetMaxTiledCol() - 10)
-                    aViewData.SetMaxTiledCol(std::max(nPosX, aViewData.GetMaxTiledCol()) + 10);
+                    aViewData.SetMaxTiledCol(std::min<SCCOL>(std::max(nPosX, aViewData.GetMaxTiledCol()) + 10, MAXCOL));
 
                 if (nPosY > aViewData.GetMaxTiledRow() - 25)
-                    aViewData.SetMaxTiledRow(std::max(nPosY, aViewData.GetMaxTiledRow()) + 25);
+                    aViewData.SetMaxTiledRow(std::min<SCROW>(std::max(nPosY, aViewData.GetMaxTiledRow()) + 25,  MAXTILEDROW));
 
                 Size aNewSize(0, 0);
                 if (pModelObj)
@@ -1121,6 +1127,12 @@ void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
     if (nCurX > MAXCOL) nCurX = MAXCOL;
     if (nCurY > MAXROW) nCurY = MAXROW;
 
+    // FIXME: this is to limit the number of rows handled in the Online
+    // to 1000; this will be removed again when the performance
+    // bottlenecks are sorted out
+    if (comphelper::LibreOfficeKit::isActive())
+        nCurY = std::min(nCurY, MAXTILEDROW);
+
     HideAllCursors();
 
     // switch of active now in AlignToCursor
commit 56cc151f8803fc57a6ac2b282483aef24d54f1b4
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Feb 2 20:07:55 2017 +0100

    sc rowlimit: Make the cursor better fit the rendering.
    
    Change-Id: If4d02161bd8a37100d7403c05ea0840a3d2d0cf8
    (cherry picked from commit 9ba5eb228d714d1e5454049cac987a673bfce1e1)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2372dbd..d193c4a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -688,7 +688,7 @@ void DesktopLOKTest::testCellCursor()
     boost::property_tree::read_json(aStream, aTree);
 
     OString aRectangle(aTree.get<std::string>("commandValues").c_str());
-    CPPUNIT_ASSERT_EQUAL(aRectangle, OString("0, 0, 1278, 254"));
+    CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255"), aRectangle);
 }
 
 void DesktopLOKTest::testCommandResult()
commit 13fb8096d144d025b2c3042d955ec94dbaea9d09
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Feb 2 20:07:55 2017 +0100

    sc rowlimit: Make the cursor better fit the rendering.
    
    Change-Id: If4d02161bd8a37100d7403c05ea0840a3d2d0cf8
    (cherry picked from commit f7962f59ea0b2a8f7c2d6c015e1c02855e1008fe)

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index aea4f53..5f8b97f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5728,8 +5728,9 @@ OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoo
 
     double fPPTX = pViewData->GetPPTX();
     double fPPTY = pViewData->GetPPTY();
-    Rectangle aRect(Point(aScrPos.getX() / fPPTX, aScrPos.getY() / fPPTY),
-                    Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
+
+    Rectangle aRect(Point(rtl::math::round(aScrPos.getX() / fPPTX), rtl::math::round(aScrPos.getY() / fPPTY)),
+                    Size(rtl::math::round(nSizeXPix / fPPTX), rtl::math::round(nSizeYPix / fPPTY)));
 
     pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
 
commit c79c6da522be853b2c4befa97a90c5a264acdb3b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Feb 16 00:58:09 2017 +0530

    sc: author, date not mandatory now for .uno:InsertAnnotation
    
    These can be autostamped always when missing
    
    Change-Id: I9cf8d03d7294cb70c17ccb2635f81936abcad1c0
    Reviewed-on: https://gerrit.libreoffice.org/34328
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 5986bafea98228fc2552a5d71777ae199d223a2a)

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 2b64d03..9c17a86 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2198,20 +2198,17 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         case SID_INSERT_POSTIT:
         case SID_EDIT_POSTIT:
             {
-                const SfxPoolItem* pAuthor;
-                const SfxPoolItem* pDate;
                 const SfxPoolItem* pText;
-
-                if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_AUTHOR, &pAuthor ) &&
-                                 pReqArgs->HasItem( SID_ATTR_POSTIT_DATE, &pDate) &&
-                                 pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
+                if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
                 {
-                    const SvxPostItAuthorItem*  pAuthorItem = static_cast<const SvxPostItAuthorItem*>( pAuthor );
-                    const SvxPostItDateItem*    pDateItem   = static_cast<const SvxPostItDateItem*>( pDate );
                     const SvxPostItTextItem*    pTextItem   = static_cast<const SvxPostItTextItem*>( pText );
+                    const SvxPostItAuthorItem*  pAuthorItem = static_cast<const SvxPostItAuthorItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR) );
+                    const SvxPostItDateItem*    pDateItem   = static_cast<const SvxPostItDateItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_DATE ) );
 
                     ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
-                    pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(), &pAuthorItem->GetValue(), &pDateItem->GetValue() );
+                    pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
+                                                pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
+                                                pDateItem ? &pDateItem->GetValue() : nullptr );
                 }
                 else if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
                 {
commit 2de31d18e80270e2d4fea3363855d1b878659903
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Feb 16 00:54:48 2017 +0530

    gtktiledviewer: Different UNO command for calc
    
    Change-Id: I229451bac7cf4c223efd3fa18c177d650d3f9954
    Reviewed-on: https://gerrit.libreoffice.org/34327
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 748361ada42ffef774a7cb68f704de0e9edb5639)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 4876302..17caee8 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -346,7 +346,7 @@ static void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata)
     boost::property_tree::write_json(aStream, aTree);
     std::string aArguments = aStream.str();
 
-    lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:DeleteComment", aArguments.c_str(), false);
+    lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), rWindow.m_aToolItemCommandNames[rWindow.m_pDeleteComment].c_str(), aArguments.c_str(), false);
 }
 
 GtkWidget* CommentsSidebar::createCommentBox(const boost::property_tree::ptree& aComment)
commit 5feb8be8e3a7f42b7a1482f90fe8ff5d35706767
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 23:55:38 2017 +0530

    sc lok: implement comment callbacks
    
    Change-Id: I1253138aa530ecb2b63bf6cda658d480ac62ada5
    Reviewed-on: https://gerrit.libreoffice.org/34326
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 57056e5d6032ff1ce0a91c078ebaa1deeaa9dc6f)

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index b11a297..1fda6e2 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "column.hxx"
+#include "docsh.hxx"
 #include "scitems.hxx"
 #include "formulacell.hxx"
 #include "document.hxx"
@@ -1875,26 +1876,38 @@ void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote)
 }
 
 namespace {
-class ForgetCellNoteCaptionsHandler
-{
+    class CellNoteHandler
+    {
+        const ScDocument* m_pDocument;
+        const ScAddress m_aAddress; // 'incomplete' address consisting of tab, column
+        const bool m_bForgetCaptionOwnership;
 
-public:
-    ForgetCellNoteCaptionsHandler() {}
+    public:
+        CellNoteHandler(const ScDocument* pDocument, const ScAddress& rPos, bool bForgetCaptionOwnership) :
+            m_pDocument(pDocument),
+            m_aAddress(rPos),
+            m_bForgetCaptionOwnership(bForgetCaptionOwnership) {}
 
-    void operator() ( size_t /*nRow*/, ScPostIt* p )
-    {
-        p->ForgetCaption();
-    }
-};
-}
+        void operator() ( size_t nRow, ScPostIt* p )
+        {
+            if (m_bForgetCaptionOwnership)
+                p->ForgetCaption();
+
+            // Create a 'complete' address object
+            ScAddress aAddr(m_aAddress);
+            aAddr.SetRow(nRow);
+            // Notify our LOK clients
+            ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Remove, m_pDocument, aAddr, p);
+        }
+    };
+} // anonymous namespace
 
 void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership )
 {
-    if (bForgetCaptionOwnership)
-    {
-        ForgetCellNoteCaptionsHandler aFunc;
-        sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
-    }
+    ScAddress aAddr(nCol, 0, nTab);
+    CellNoteHandler aFunc(pDocument, aAddr, bForgetCaptionOwnership);
+    sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
+
     rBlockPos.miCellNotePos =
         maCellNotes.set_empty(rBlockPos.miCellNotePos, nRow1, nRow2);
 }
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 47fa09f..2ecad69 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1287,10 +1287,12 @@ void ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
 
         // create new note (creates drawing undo action for the new caption object)
         ScNoteData aNewData;
-        if( ScPostIt* pNewNote = ScNoteUtil::CreateNoteFromString( rDoc, rPos, rNoteText, false, true ) )
+        ScPostIt* pNewNote = nullptr;
+        if( (pNewNote = ScNoteUtil::CreateNoteFromString( rDoc, rPos, rNoteText, false, true )) )
         {
             if( pAuthor ) pNewNote->SetAuthor( *pAuthor );
             if( pDate ) pNewNote->SetDate( *pDate );
+
             // rescue note data for undo
             aNewData = pNewNote->GetNoteData();
         }
@@ -1306,6 +1308,13 @@ void ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
             rDoc.SetStreamValid(rPos.Tab(), false);
 
         aModificator.SetDocumentModified();
+
+        // Let our LOK clients know about the new/modified note
+        if (pNewNote)
+        {
+            ScDocShell::LOKCommentNotify(pOldNote ? LOKCommentNotificationType::Modify : LOKCommentNotificationType::Add,
+                                         &rDoc, rPos, pNewNote);
+        }
     }
     else if (!bApi)
     {
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 63a2db5..fa6db5a 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -19,6 +19,8 @@
 
 #include <config_features.h>
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
@@ -51,7 +53,9 @@ using namespace ::com::sun::star;
 #include <svl/documentlockfile.hxx>
 #include <svl/sharecontrolfile.hxx>
 #include <unotools/securityoptions.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
+#include <comphelper/lok.hxx>
 #include <comphelper/processfactory.hxx>
 #include "docuno.hxx"
 
@@ -2238,6 +2242,58 @@ bool ScDocShell::DdeSetData( const OUString& rItem,
     return pObj;
 }
 
+void ScDocShell::LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument* pDocument, const ScAddress& rPos, const ScPostIt* pNote)
+{
+    if ( !pDocument->IsDocVisible() || // don't want callbacks until document load
+         !comphelper::LibreOfficeKit::isActive() ||
+         comphelper::LibreOfficeKit::isTiledAnnotations() )
+        return;
+
+    boost::property_tree::ptree aAnnotation;
+    aAnnotation.put("action", (nType == LOKCommentNotificationType::Add ? "Add" :
+                               (nType == LOKCommentNotificationType::Remove ? "Remove" :
+                                (nType == LOKCommentNotificationType::Modify ? "Modify" : "???"))));
+    OUString aCellId = rPos.Format(ScRefFlags::VALID | ScRefFlags::TAB_3D, pDocument,
+                                   ScAddress::Details(formula::FormulaGrammar::AddressConvention::CONV_ODF, rPos));
+    aAnnotation.put("id", aCellId.toUtf8().getStr());
+    if (nType != LOKCommentNotificationType::Remove && pNote)
+    {
+        aAnnotation.put("author", pNote->GetAuthor());
+        aAnnotation.put("dateTime", pNote->GetDate());
+        aAnnotation.put("text", pNote->GetText());
+
+        // Calculating the cell cursor position
+        ScViewData* pViewData = GetViewData();
+        if (pViewData && pViewData->GetActiveWin())
+        {
+            Point aScrPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), pViewData->GetActivePart(), true);
+            long nSizeXPix;
+            long nSizeYPix;
+            pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeXPix, nSizeYPix);
+
+            const double fPPTX = pViewData->GetPPTX();
+            const double fPPTY = pViewData->GetPPTY();
+            Rectangle aRect(Point(aScrPos.getX() / fPPTX, aScrPos.getY() / fPPTY),
+                            Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
+
+            aAnnotation.put("cellPos", aRect.toString());
+        }
+    }
+
+    boost::property_tree::ptree aTree;
+    aTree.add_child("comment", aAnnotation);
+    std::stringstream aStream;
+    boost::property_tree::write_json(aStream, aTree);
+    std::string aPayload = aStream.str();
+
+    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+    while (pViewShell)
+    {
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
+        pViewShell = SfxViewShell::GetNext(*pViewShell);
+    }
+}
+
 ScViewData* ScDocShell::GetViewData()
 {
     SfxViewShell* pCur = SfxViewShell::Current();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 0abc289..e87ebcc 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -75,6 +75,8 @@ typedef std::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap;
 
 //enum ScDBFormat { SC_FORMAT_SDF, SC_FORMAT_DBF };
 
+enum class LOKCommentNotificationType { Add, Modify, Remove };
+
                                     // Extra flags for Repaint
 #define SC_PF_LINES         1
 #define SC_PF_TESTMERGE     2
@@ -398,6 +400,7 @@ public:
     static OUString   GetDBaseFilterName();
     static OUString   GetDifFilterName();
     static bool       HasAutomaticTableName( const OUString& rFilter );
+    static void       LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument* pDocument, const ScAddress& rPos, const ScPostIt* pNote);
 
     DECL_LINK( RefreshDBDataHdl, Timer*, void );
 
commit f64995d49740622c744a82be9906ab594416d01e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 17:00:05 2017 +0530

    gtktiledviewer: This is a better place to change doc-specific controls
    
    Change-Id: Id8fbebe2f6e339120741ed3744b18f50941c995e
    (cherry picked from commit a6c4552e792f6ab20fae83d354b369defd3bb345)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 90a6bf5..4876302 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -586,11 +586,6 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
         gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
         gtk_widget_show(rWindow.m_pFormulabarEntry);
 
-        // Change cell alignment uno commands for spreadsheet
-        lcl_registerToolItem(rWindow, rWindow.m_pLeftpara, ".uno:AlignLeft");
-        lcl_registerToolItem(rWindow, rWindow.m_pCenterpara, ".uno:AlignHorizontalCenter");
-        lcl_registerToolItem(rWindow, rWindow.m_pRightpara, ".uno:AlignRight");
-        gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
     }
 
     return TRUE;
@@ -1121,6 +1116,14 @@ static void initWindow(TiledWindow& rWindow)
         // used.
         gtk_widget_set_halign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
         gtk_widget_set_valign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+
+        // Change cell alignment uno commands for spreadsheet
+        lcl_registerToolItem(rWindow, rWindow.m_pLeftpara, ".uno:AlignLeft");
+        lcl_registerToolItem(rWindow, rWindow.m_pCenterpara, ".uno:AlignHorizontalCenter");
+        lcl_registerToolItem(rWindow, rWindow.m_pRightpara, ".uno:AlignRight");
+        gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
+
+        lcl_registerToolItem(rWindow, rWindow.m_pDeleteComment, ".uno:DeleteNote");
     }
 
     // Fill our comments sidebar
commit 7b4ea9d94e76bfbfc226d5751c056ad6c769ca2b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 16:42:49 2017 +0530

    gtktiledviewer: Kill CommentsSidebar's docConfigure
    
    Move this code to initWindow too
    
    (cherry picked from commit 2d6ec9761df5fcd36dd0ce7964d1ae6876ec9943)
    
    Change-Id: I057d9b8f60b9da2c20b28901ab958f9fc2095df3

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 6219a41..90a6bf5 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -57,8 +57,6 @@ public:
     static GtkWidget* createCommentBox(const boost::property_tree::ptree& aComment);
     /// Click even handler for m_pViewAnnotationsButton
     static void unoViewAnnotations(GtkWidget* pWidget, gpointer userdata);
-    /// Configure event handler for window
-    static gboolean docConfigureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
 };
 
 
@@ -432,41 +430,6 @@ void CommentsSidebar::unoViewAnnotations(GtkWidget* pWidget, gpointer /*userdata
     }
 }
 
-gboolean CommentsSidebar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigure* /*pEvent*/, gpointer /*userdata*/)
-{
-    TiledWindow& rWindow = lcl_getTiledWindow(pDocView);
-    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
-
-    // whether tield rendering is turned on
-    gboolean bTiledAnnotations;
-    g_object_get(G_OBJECT(pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
-
-    if (!bTiledAnnotations && pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT)
-    {
-        if (!rWindow.m_pCommentsSidebar)
-        {
-            rWindow.m_pCommentsSidebar.reset(new CommentsSidebar());
-            rWindow.m_pCommentsSidebar->m_pMainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-            gtk_container_add(GTK_CONTAINER(rWindow.m_pMainHBox), rWindow.m_pCommentsSidebar->m_pMainVBox);
-
-            rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton = gtk_button_new_with_label(".uno:ViewAnnotations");
-#if GTK_CHECK_VERSION(3,12,0)
-            // Hack to make sidebar grid wide enough to not need any horizontal scrollbar
-            gtk_widget_set_margin_start(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
-            gtk_widget_set_margin_end(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
-#endif
-            gtk_container_add(GTK_CONTAINER(rWindow.m_pCommentsSidebar->m_pMainVBox), rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton);
-            g_signal_connect(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, "clicked", G_CALLBACK(CommentsSidebar::unoViewAnnotations), nullptr);
-
-            gtk_widget_show_all(rWindow.m_pCommentsSidebar->m_pMainVBox);
-
-            gtk_button_clicked(GTK_BUTTON(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton));
-        }
-    }
-
-    return TRUE;
-}
-
 TiledRowColumnBar::TiledRowColumnBar(TiledBarType eType)
     : m_pDrawingArea(gtk_drawing_area_new()),
     m_nSizePixel(0),
@@ -630,7 +593,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
         gtk_widget_hide(GTK_WIDGET(rWindow.m_pJustifypara));
     }
 
-    return FALSE;
+    return TRUE;
 }
 
 TiledCornerButton::TiledCornerButton()
@@ -1149,6 +1112,46 @@ static void initWindow(TiledWindow& rWindow)
     gtk_widget_hide(rWindow.m_pProgressBar);
 
     gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(rWindow.m_pEnableEditing), TRUE);
+
+    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(rWindow.m_pDocView));
+    if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
+    {
+        // Align to top left corner, so the tiles are in sync with the
+        // row/column bar, even when zooming out enough that not all space is
+        // used.
+        gtk_widget_set_halign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+        gtk_widget_set_valign(GTK_WIDGET(rWindow.m_pDocView), GTK_ALIGN_START);
+    }
+
+    // Fill our comments sidebar
+    gboolean bTiledAnnotations;
+    g_object_get(G_OBJECT(rWindow.m_pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
+
+    // comments api implemented only for writer, calc as of now
+    if (!bTiledAnnotations && pDocument &&
+        (pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT ||
+         pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET))
+    {
+        if (!rWindow.m_pCommentsSidebar)
+        {
+            rWindow.m_pCommentsSidebar.reset(new CommentsSidebar());
+            rWindow.m_pCommentsSidebar->m_pMainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+            gtk_container_add(GTK_CONTAINER(rWindow.m_pMainHBox), rWindow.m_pCommentsSidebar->m_pMainVBox);
+
+            rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton = gtk_button_new_with_label(".uno:ViewAnnotations");
+#if GTK_CHECK_VERSION(3,12,0)
+            // Hack to make sidebar grid wide enough to not need any horizontal scrollbar
+            gtk_widget_set_margin_start(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
+            gtk_widget_set_margin_end(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, 20);
+#endif
+            gtk_container_add(GTK_CONTAINER(rWindow.m_pCommentsSidebar->m_pMainVBox), rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton);
+            g_signal_connect(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton, "clicked", G_CALLBACK(CommentsSidebar::unoViewAnnotations), nullptr);
+
+            gtk_widget_show_all(rWindow.m_pCommentsSidebar->m_pMainVBox);
+
+            gtk_button_clicked(GTK_BUTTON(rWindow.m_pCommentsSidebar->m_pViewAnnotationsButton));
+        }
+    }
 }
 
 /// Creates a new view, i.e. no LOK init or document load.
@@ -1790,16 +1793,6 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
         return;
     }
 
-    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pDocView);
-    if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
-    {
-        // Align to top left corner, so the tiles are in sync with the
-        // row/column bar, even when zooming out enough that not all space is
-        // used.
-        gtk_widget_set_halign(GTK_WIDGET(pDocView), GTK_ALIGN_START);
-        gtk_widget_set_valign(GTK_WIDGET(pDocView), GTK_ALIGN_START);
-    }
-
     initWindow(rWindow);
 }
 
@@ -2181,7 +2174,6 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     g_aWindows[pWindow] = rWindow;
 
     g_signal_connect(rWindow.m_pDocView, "configure-event", G_CALLBACK(TiledRowColumnBar::docConfigureEvent), 0);
-    g_signal_connect(rWindow.m_pDocView, "configure-event", G_CALLBACK(CommentsSidebar::docConfigureEvent), 0);
     return pWindow;
 }
 
commit d88c2e3c8910a278361eefeb09748ce1b4c01012
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 16:13:11 2017 +0530

    gtktiledviewer: Kill signalSize; move its code to initWindow
    
    Change-Id: I8aa0a00768e074b016ea20680c67884f19fe26df
    (cherry picked from commit abef7dfae3d87f52464d1f0879927ffdcfd41656)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 1867a54..6219a41 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -214,8 +214,6 @@ static std::map<GtkWidget*, TiledWindow> g_aWindows;
 static void setupDocView(GtkWidget* pDocView);
 static GtkWidget* createWindow(TiledWindow& rWindow);
 static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpointer userdata);
-/// Called when the document size is changed.
-static void signalSize(LOKDocView* pLOKDocView, gpointer pData);
 /// Handler for m_pPartModeComboBox.
 static void changePartMode( GtkWidget* pSelector, gpointer /*pItem*/);
 /// Handler for m_pPartSelector.
@@ -1134,10 +1132,15 @@ static void registerSelectorHandlers(TiledWindow& rWindow)
 /// document load)
 static void initWindow(TiledWindow& rWindow)
 {
+    rWindow.m_bPartSelectorBroadcast = false;
     populatePartSelector(LOK_DOC_VIEW(rWindow.m_pDocView));
+    rWindow.m_bPartSelectorBroadcast = true;
+
     populatePartModeSelector( GTK_COMBO_BOX_TEXT(rWindow.m_pPartModeComboBox) );
     registerSelectorHandlers(rWindow);
 
+    registerSelectorHandlers(rWindow);
+
     GList *focusChain = nullptr;
     focusChain = g_list_append( focusChain, rWindow.m_pDocView );
     gtk_container_set_focus_chain ( GTK_CONTAINER (rWindow.m_pVBox), focusChain );
@@ -1169,9 +1172,6 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
     // Hide the unused progress bar.
     gtk_widget_show_all(rNewWindow.m_pStatusBar);
     gtk_widget_hide(rNewWindow.m_pProgressBar);
-    // Trigger a 'document size changed' event to populate the part selectors.
-    signalSize(LOK_DOC_VIEW(pDocView), nullptr);
-    registerSelectorHandlers(rNewWindow);
 }
 
 /// Creates a new model, i.e. LOK init and document load, one view implicitly.
@@ -1726,14 +1726,6 @@ static void populatePartSelector(LOKDocView* pLOKDocView)
     gtk_combo_box_set_active(GTK_COMBO_BOX(rWindow.m_pPartSelector), lok_doc_view_get_part(pLOKDocView));
 }
 
-static void signalSize(LOKDocView* pLOKDocView, gpointer /*pData*/)
-{
-    TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
-    rWindow.m_bPartSelectorBroadcast = false;
-    populatePartSelector(pLOKDocView);
-    rWindow.m_bPartSelectorBroadcast = true;
-}
-
 static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
 {
     int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
@@ -2205,7 +2197,6 @@ static void setupDocView(GtkWidget* pDocView)
     g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), nullptr);
     g_signal_connect(pDocView, "search-result-count", G_CALLBACK(signalSearchResultCount), nullptr);
     g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), nullptr);
-    g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), nullptr);
     g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), nullptr);
     g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), nullptr);
     g_signal_connect(pDocView, "formula-changed", G_CALLBACK(formulaChanged), nullptr);
commit 22847581b0b84def9ee3ca5020c08c9faf1643dc
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 15:49:41 2017 +0530

    gtktiledviewer: Factor out per view code to separate function
    
    This code (populating part selector, part mode selector etc.) is something
    that needs to be executed for each view, not just the view that makes
    open_document call. Put all such code in initWindow function from now.
    
    Change-Id: Ibf9b12adb156258aa3cfdf959fffb541a88da529
    (cherry picked from commit 786107e674877478b8c7fdc4e6b545c44ac6b6ac)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index e24a63a..1867a54 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -220,6 +220,10 @@ static void signalSize(LOKDocView* pLOKDocView, gpointer pData);
 static void changePartMode( GtkWidget* pSelector, gpointer /*pItem*/);
 /// Handler for m_pPartSelector.
 static void changePart( GtkWidget* pSelector, gpointer /*pItem*/ );
+/// Part selector populator
+static void populatePartSelector(LOKDocView* pLOKDocView);
+/// Part mode selector populator
+static void populatePartModeSelector( GtkComboBoxText* pSelector );
 
 static TiledWindow& lcl_getTiledWindow(GtkWidget* pWidget)
 {
@@ -1126,6 +1130,24 @@ static void registerSelectorHandlers(TiledWindow& rWindow)
     g_signal_connect(G_OBJECT(rWindow.m_pPartSelector), "changed", G_CALLBACK(changePart), 0);
 }
 
+/// Helper function to do some tasks after widget is fully loaded (including
+/// document load)
+static void initWindow(TiledWindow& rWindow)
+{
+    populatePartSelector(LOK_DOC_VIEW(rWindow.m_pDocView));
+    populatePartModeSelector( GTK_COMBO_BOX_TEXT(rWindow.m_pPartModeComboBox) );
+    registerSelectorHandlers(rWindow);
+
+    GList *focusChain = nullptr;
+    focusChain = g_list_append( focusChain, rWindow.m_pDocView );
+    gtk_container_set_focus_chain ( GTK_CONTAINER (rWindow.m_pVBox), focusChain );
+
+    gtk_widget_show_all(rWindow.m_pStatusBar);
+    gtk_widget_hide(rWindow.m_pProgressBar);
+
+    gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(rWindow.m_pEnableEditing), TRUE);
+}
+
 /// Creates a new view, i.e. no LOK init or document load.
 static void createView(GtkWidget* pButton, gpointer /*pItem*/)
 {
@@ -1143,6 +1165,7 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
     gboolean bTiledAnnotations;
     g_object_get(G_OBJECT(rWindow.m_pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
     TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView, bTiledAnnotations);
+    initWindow(rNewWindow);
     // Hide the unused progress bar.
     gtk_widget_show_all(rNewWindow.m_pStatusBar);
     gtk_widget_hide(rNewWindow.m_pProgressBar);
@@ -1756,7 +1779,6 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
     LOKDocView* pDocView = LOK_DOC_VIEW (source_object);
     TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pDocView));
     GError* error = nullptr;
-    GList *focusChain = nullptr;
 
     if (!lok_doc_view_open_document_finish(pDocView, res, &error))
     {
@@ -1786,17 +1808,7 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
         gtk_widget_set_valign(GTK_WIDGET(pDocView), GTK_ALIGN_START);
     }
 
-    populatePartSelector(pDocView);
-    populatePartModeSelector( GTK_COMBO_BOX_TEXT(rWindow.m_pPartModeComboBox) );
-    registerSelectorHandlers(rWindow);
-
-    focusChain = g_list_append( focusChain, pDocView );
-    gtk_container_set_focus_chain ( GTK_CONTAINER (rWindow.m_pVBox), focusChain );
-
-    gtk_widget_show_all(rWindow.m_pStatusBar);
-    gtk_widget_hide(rWindow.m_pProgressBar);
-
-    gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(rWindow.m_pEnableEditing), TRUE);
+    initWindow(rWindow);
 }
 
 /**
commit 21c545a23f1dc33f4e18a6dc6b9d8a5d86cc6e4f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 15:12:25 2017 +0530

    gtktiledviewer: Store author name of each view
    
    Change-Id: I9a5be9050f3bedd14b6b5602b51bf40da0a11175
    (cherry picked from commit 2c622c188757143ecf2131210f34b1ca1b0c33e2)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 9255ff0..e24a63a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -165,6 +165,8 @@ public:
     std::shared_ptr<CommentsSidebar> m_pCommentsSidebar;
     /// Rendering arguments, which are the same for all views.
     boost::property_tree::ptree m_aRenderingArguments;
+    /// Author of this window
+    std::string m_aAuthor;
 
     TiledWindow()
         : m_pDocView(nullptr),
@@ -1130,9 +1132,9 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
     TiledWindow& rWindow = lcl_getTiledWindow(pButton);
 
     boost::property_tree::ptree aTree = rWindow.m_aRenderingArguments;
-    std::string aAuthor = getNextAuthor();
+    rWindow.m_aAuthor = getNextAuthor();
     aTree.put(boost::property_tree::ptree::path_type(".uno:Author/type", '/'), "string");
-    aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), aAuthor);
+    aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), rWindow.m_aAuthor);
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
     std::string aArguments = aStream.str();
@@ -1194,9 +1196,9 @@ static void createModelAndView(const char* pLOPath, const char* pDocPath, const
 
     // Save rendering arguments for views which are created later.
     rWindow.m_aRenderingArguments = aTree;
-
+    rWindow.m_aAuthor = getNextAuthor();
     aTree.put(boost::property_tree::ptree::path_type(".uno:Author/type", '/'), "string");
-    aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), getNextAuthor());
+    aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), rWindow.m_aAuthor);
 
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
commit 2b62934862d020f3475b8fc95b8acee1572a54c5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 14:55:49 2017 +0530

    sc lok: No need to set tiled rendering zoom here
    
    If we make sure that this code is executed after initializeForRendering
    is called, which is how it should be ideally, we will get the correct
    positions anyway.
    
    Change-Id: I1eb8f32823cb0b02539f077882372a73b6df5851
    (cherry picked from commit 4d800a54bfa94421712c7dccc5437f50b8bfab9c)

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7429a55..f5149af 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1005,13 +1005,6 @@ OUString ScModelObj::getPostIts()
         ScGridWindow* pGridWindow = pViewData->GetActiveWin();
         if (pGridWindow)
         {
-            Fraction zoomX = Fraction(long(mnTilePixelWidth * TWIPS_PER_PIXEL), mnTileTwipWidth);
-            Fraction zoomY = Fraction(long(mnTilePixelHeight * TWIPS_PER_PIXEL), mnTileTwipHeight);
-
-            Fraction defaultZoomX = pViewData->GetZoomX();
-            Fraction defaultZoomY = pViewData->GetZoomY();
-            pViewData->SetZoom(zoomX, zoomY, true);
-
             SCCOL nX = aNote.maPos.Col();
             SCROW nY = aNote.maPos.Row();
             Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(), true);
@@ -1024,8 +1017,6 @@ OUString ScModelObj::getPostIts()
             Rectangle aRect(Point(aScrPos.getX() / fPPTX, aScrPos.getY() / fPPTY),
                             Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
 
-            pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
-
             aAnnotation.put("cellPos", aRect.toString());
         }
 
commit ffa25ed80d759e2ae283356a722cad9c6f3ee2df
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 14:54:50 2017 +0530

    sc lok: comments: Use tab.rowcolumn string as postit id
    
    Change-Id: I5eaa7c82239ab65a567a893d76c68468cf116469
    (cherry picked from commit 7d04c367158039f18f04b0b9e1157829e5e6e082)

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5c24ede..7429a55 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -983,7 +983,7 @@ OUString ScModelObj::getPostIts()
     if (!pDocShell)
         return OUString();
 
-    const ScDocument& rDoc = pDocShell->GetDocument();
+    ScDocument& rDoc = pDocShell->GetDocument();
     std::vector<sc::NoteEntry> aNotes;
     rDoc.GetAllNoteEntries(aNotes);
 
@@ -991,7 +991,11 @@ OUString ScModelObj::getPostIts()
     for (const sc::NoteEntry& aNote : aNotes)
     {
         boost::property_tree::ptree aAnnotation;
-        aAnnotation.put("id", aNote.maPos.hash());
+        OStringBuffer aBuf;
+        aNote.maPos.Format(aBuf, ScRefFlags::VALID | ScRefFlags::TAB_3D, &rDoc,
+                           ScAddress::Details(formula::FormulaGrammar::AddressConvention::CONV_ODF, aNote.maPos));
+
+        aAnnotation.put("id", aBuf.toString());
         aAnnotation.put("author", aNote.mpNote->GetAuthor());
         aAnnotation.put("dateTime", aNote.mpNote->GetDate());
         aAnnotation.put("text", aNote.mpNote->GetText());
commit 48aa777b9f802a8ed399be3a5309d12a40728732
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 14:27:59 2017 +0530

    sc lok: Prevent editing note in case tiled annotations off
    
    Change-Id: Ie98a2cc3a5366bde912f4eeef9bb63a32342cdd6
    (cherry picked from commit 4a22a8f16d144681d8a802a407f9aec43ca4a190)

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index f17de35..2b64d03 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -25,6 +25,7 @@
 #include "scitems.hxx"
 #include <sfx2/viewfrm.hxx>
 
+#include <comphelper/lok.hxx>
 #include <svl/stritem.hxx>
 #include <svl/whiter.hxx>
 #include <svl/zforlist.hxx>
@@ -2212,7 +2213,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
                     pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(), &pAuthorItem->GetValue(), &pDateItem->GetValue() );
                 }
-                else
+                else if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
                 {
                     pTabViewShell->EditNote();                  // note object to edit
                 }
commit cffc6378acb2eb0c1c365e8fee159b9e5eb7268f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 10 19:18:24 2017 +0530

    gtktiledviewer: comment id can be a string too now
    
    Change-Id: Ia94041884b7fde5f6c104a41c77c6a3aa96b7be1
    (cherry picked from commit f5f3103187545952babf7b7efbdebc7d969f0974)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 502ccf7..9255ff0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -290,11 +290,11 @@ static void editButtonClicked(GtkWidget* pWidget, gpointer userdata)
 
     userPromptDialog(rWindow.m_pDocView, "Edit comment", aEntries);
 
-    int *commentId = static_cast<int*>(g_object_get_data(G_OBJECT(userdata), "id"));
+    gchar *commentId = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id"));
 
     boost::property_tree::ptree aTree;
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "long");
-    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::to_string(*commentId));
+    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentId));
 
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string");
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]);
@@ -314,11 +314,11 @@ static void replyButtonClicked(GtkWidget* pWidget, gpointer userdata)
 
     userPromptDialog(rWindow.m_pDocView, "Reply comment", aEntries);
 
-    int *commentId = static_cast<int*>(g_object_get_data(G_OBJECT(userdata), "id"));
+    gchar *commentId = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id"));
 
     boost::property_tree::ptree aTree;
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "long");
-    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::to_string(*commentId));
+    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentId));
 
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string");
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]);
@@ -334,11 +334,11 @@ static void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata)
 {
     TiledWindow& rWindow = lcl_getTiledWindow(pWidget);
 
-    int *commentid = static_cast<int*>(g_object_get_data(G_OBJECT(userdata), "id"));
+    gchar *commentid = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id"));
 
     boost::property_tree::ptree aTree;
     aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "long");
-    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::to_string(*commentid));
+    aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentid));
 
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
@@ -350,12 +350,11 @@ static void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata)
 GtkWidget* CommentsSidebar::createCommentBox(const boost::property_tree::ptree& aComment)
 {
     GtkWidget* pCommentVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
-    int *id = g_new(int, 1);
-    *id =  aComment.get<int>("id");
+    gchar *id = g_strndup(aComment.get<std::string>("id").c_str(), 20);
     g_object_set_data_full(G_OBJECT(pCommentVBox), "id", id, g_free);
 
-    // Set left-margin if its a reply comment
-    if (aComment.get<int>("parent") > 0)
+    // Set background if its a reply comment
+    if (aComment.get("parent", -1) > 0)
     {
         GtkStyleContext* pStyleContext = gtk_widget_get_style_context(pCommentVBox);
         GtkCssProvider* pCssProvider = gtk_css_provider_get_default();
@@ -1602,13 +1601,13 @@ static void commentCallback(LOKDocView* pLOKDocView, gchar* pComment, gpointer /
     GtkWidget* pParent = nullptr;
     for (GList* l = pChildren; l != nullptr; l = l->next)
     {
-        int *id = static_cast<int*>(g_object_get_data(G_OBJECT(l->data), "id"));
+        gchar *id = static_cast<gchar*>(g_object_get_data(G_OBJECT(l->data), "id"));
 
-        if (*id == aComment.get<int>("id"))
+        if (g_strcmp0(id, aComment.get<std::string>("id").c_str()) == 0)
             pSelf = GTK_WIDGET(l->data);
 
         // There is no 'parent' in Remove callbacks
-        if (*id == aComment.get("parent", -1))
+        if (g_strcmp0(id, aComment.get("parent", std::string("0")).c_str()) == 0)
             pParent = GTK_WIDGET(l->data);
     }
 
commit c09422cef0247b4dfcb7933df7d5feffb39f8bc5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 15 14:27:08 2017 +0530

    SvxPostItIdItem is now string type
    
    Change-Id: Id44bf5dd623749b6e9a46f121f035aa5ce617557
    (cherry picked from commit ce96c5957c38384f8911d6307605c502eca0c644)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index c8ebbae..2372dbd 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1929,7 +1929,7 @@ void DesktopLOKTest::testCommentsCallbacks()
     int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id");
 
     // Reply to a comment just added
-    aCommandArgs = "{ \"Id\": { \"type\": \"long\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment\" } }";
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment\" } }";
     pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false);
     Scheduler::ProcessEventsToIdle();
 
@@ -1943,7 +1943,7 @@ void DesktopLOKTest::testCommentsCallbacks()
     int nCommentId2 = aView1.m_aCommentCallbackResult.get<int>("id");
 
     // Edit the previously added comment
-    aCommandArgs = "{ \"Id\": { \"type\": \"long\", \"value\": \"" + OString::number(nCommentId2) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Edited comment\" } }";
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId2) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Edited comment\" } }";
     pDocument->pClass->postUnoCommand(pDocument, ".uno:EditAnnotation", aCommandArgs.getStr(), false);
     Scheduler::ProcessEventsToIdle();
 
@@ -1957,7 +1957,7 @@ void DesktopLOKTest::testCommentsCallbacks()
     CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
 
     // Delete the reply comment just added
-    aCommandArgs = "{ \"Id\": { \"type\": \"long\", \"value\":  \"" + OString::number(nCommentId2) + "\" } }";
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\":  \"" + OString::number(nCommentId2) + "\" } }";
     pDocument->pClass->postUnoCommand(pDocument, ".uno:DeleteComment", aCommandArgs.getStr(), false);
     Scheduler::ProcessEventsToIdle();
 
@@ -1968,7 +1968,7 @@ void DesktopLOKTest::testCommentsCallbacks()
     CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id"));
 
     // Reply to nCommentId1 again
-    aCommandArgs = "{ \"Id\": { \"type\": \"long\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }";
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }";
     pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false);
     Scheduler::ProcessEventsToIdle();
 
diff --git a/include/svx/postattr.hxx b/include/svx/postattr.hxx
index dbe378f..19477ac 100644
--- a/include/svx/postattr.hxx
+++ b/include/svx/postattr.hxx
@@ -120,14 +120,14 @@ public:
 The internal id of a note
 */
 
-class SVX_DLLPUBLIC SvxPostItIdItem: public SfxUInt32Item
+class SVX_DLLPUBLIC SvxPostItIdItem: public SfxStringItem
 {
 public:
     static SfxPoolItem* CreateDefault();
 
     SvxPostItIdItem( sal_uInt16 nWhich  );
 
-    SvxPostItIdItem( sal_uInt32 rId, sal_uInt16 nWhich  );
+    SvxPostItIdItem( const OUString& rId, sal_uInt16 nWhich  );
 
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = nullptr ) const override;
 
diff --git a/svx/source/items/postattr.cxx b/svx/source/items/postattr.cxx
index 1426a1b..52d98a3 100644
--- a/svx/source/items/postattr.cxx
+++ b/svx/source/items/postattr.cxx
@@ -151,8 +151,8 @@ SvxPostItIdItem::SvxPostItIdItem( sal_uInt16 _nWhich )
     SetWhich( _nWhich );
 }
 
-SvxPostItIdItem::SvxPostItIdItem( sal_uInt32 rId, sal_uInt16 _nWhich ) :
-    SfxUInt32Item( _nWhich, rId )
+SvxPostItIdItem::SvxPostItIdItem( const OUString& rId, sal_uInt16 _nWhich ) :
+    SfxStringItem( _nWhich, rId )
 {
 }
 
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 8b5b8e3..b4c296b 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -332,9 +332,9 @@ void SwTextShell::ExecField(SfxRequest &rReq)
             case FN_DELETE_COMMENT:
             {
                 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
-                if (pIdItem && pIdItem->GetValue() && GetView().GetPostItMgr())
+                if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr())
                 {
-                    GetView().GetPostItMgr()->Delete(pIdItem->GetValue());
+                    GetView().GetPostItMgr()->Delete(pIdItem->GetValue().toUInt32());
                 }
                 else if ( GetView().GetPostItMgr() &&
                           GetView().GetPostItMgr()->HasActiveSidebarWin() )
@@ -382,16 +382,16 @@ void SwTextShell::ExecField(SfxRequest &rReq)
             case FN_REPLY:
             {
                 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
-                if (pIdItem && pIdItem->GetValue())
+                if (pIdItem && !pIdItem->GetValue().isEmpty())
                 {
                     SwFieldType* pType = rSh.GetDoc()->getIDocumentFieldsAccess().GetFieldType(RES_POSTITFLD, OUString(), false);
                     SwIterator<SwFormatField,SwFieldType> aIter( *pType );
                     SwFormatField* pSwFormatField = aIter.First();
                     while( pSwFormatField )
                     {
-                        if ( static_cast<SwPostItField*>(pSwFormatField->GetField())->GetPostItId() == pIdItem->GetValue())
+                        if ( static_cast<SwPostItField*>(pSwFormatField->GetField())->GetPostItId() == pIdItem->GetValue().toUInt32() )
                         {
-                            sw::annotation::SwAnnotationWin* pWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue());
+                            sw::annotation::SwAnnotationWin* pWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue().toUInt32());
                             if (pWin)
                             {
                                 const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
@@ -481,14 +481,14 @@ void SwTextShell::ExecField(SfxRequest &rReq)
             case SID_EDIT_POSTIT:
             {
                 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
-                if (pIdItem && pIdItem->GetValue())
+                if (pIdItem && !pIdItem->GetValue().isEmpty())
                 {
                     const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
                     OUString sText;
                     if ( pTextItem )
                         sText = pTextItem->GetValue();
 
-                    sw::annotation::SwAnnotationWin* pAnnotationWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue());
+                    sw::annotation::SwAnnotationWin* pAnnotationWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue().toUInt32());
                     if (pAnnotationWin)
                         pAnnotationWin->UpdateText(sText);
                 }
commit c0845978774045f6e14d39ea39a7e1740fd99669
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 8 20:42:17 2017 +0530

    sc lok: Prevent showing comments if tiled annotations are off
    
    Change-Id: I594b61e102c0ecacb169ee6064ba96d70c16ab42
    (cherry picked from commit a29b0d68011f9e2be8eee466f3f9ccad283f274c)

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index fb7fd67..47fa09f 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -19,6 +19,7 @@
 
 #include "scitems.hxx"
 
+#include <comphelper/lok.hxx>
 #include <sfx2/app.hxx>
 #include <editeng/editobj.hxx>
 #include <sfx2/linkmgr.hxx>
@@ -1211,7 +1212,9 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
 {
     ScDocument& rDoc = rDocShell.GetDocument();
     ScPostIt* pNote = rDoc.GetNote( rPos );
-    if( !pNote || (bShow == pNote->IsCaptionShown()) ) return false;
+    if( !pNote || (bShow == pNote->IsCaptionShown()) ||
+        (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations()) )
+        return false;
 
     // move the caption to internal or hidden layer and create undo action
     pNote->ShowCaption( rPos, bShow );
commit 21ed2e32bd99f49fa2565ccf8db3c44eadc2445f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 8 20:40:57 2017 +0530

    sc lok: Set appropriate ScViewOptions when annotations are off
    
    Change-Id: I65b3fea9a33396419dff70b134729594c0dda4db
    (cherry picked from commit c7b84ac9ea14e6c96165e3281c4bea422918c83f)

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 1a62a90..42b0cbe 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -431,6 +431,7 @@ public:
     void    SetHScrollMode  ( bool bNewMode )   { pOptions->SetOption( VOPT_HSCROLL, bNewMode ); }
     bool    IsOutlineMode   () const            { return pOptions->GetOption( VOPT_OUTLINER ); }
     void    SetOutlineMode  ( bool bNewMode )   { pOptions->SetOption( VOPT_OUTLINER, bNewMode ); }
+    void    SetNotesMode    ( bool bNewMode )   { pOptions->SetOption( VOPT_NOTES, bNewMode ); }
 
     /// Force page size for PgUp/PgDown to overwrite the computation based on m_aVisArea.
     void ForcePageUpDownOffset(long nTwips) { m_nLOKPageUpDownOffset = nTwips; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7ad4381..5c24ede 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1053,6 +1053,10 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans
     // format
     SvtSaveOptions().SetWarnAlienFormat(false);
 
+    // If annotations are turned off in tiled rendering case
+    if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
+        ScDocShell::GetViewData()->SetNotesMode(false);
+
     // default tile size in pixels
     mnTilePixelWidth = 256;
     mnTilePixelHeight = 256;
commit 489fca3be68e8c13b5c753d0e2edada9de01dd19
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Feb 9 19:19:38 2017 +0530

    sc lok: implement commandvalues command, ViewAnnotations
    
    ... to list all notes in calc.
    
    Change-Id: I6c636ebd47ee238c32e3c0b7d10254d237396a51
    (cherry picked from commit 31b32d156ab69f347f21de29c8ba6cd07cc4dc95)

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 55957f3..9dac6c4 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -426,6 +426,9 @@ public:
 
     /// @see vcl::ITiledRenderable::setClientVisibleArea().
     virtual void setClientVisibleArea(const Rectangle& rRectangle) override;
+
+    /// @see vcl::ITiledRenderable::getPostIts().
+    OUString getPostIts() override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index fa9b4ab..7ad4381 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -19,6 +19,8 @@
 
 #include <config_features.h>
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include "scitems.hxx"
 #include <editeng/editview.hxx>
 #include <editeng/outliner.hxx>
@@ -976,6 +978,63 @@ void ScModelObj::setClientVisibleArea(const Rectangle& rRectangle)
     pViewData->ForcePageUpDownOffset(rRectangle.GetHeight());
 }
 
+OUString ScModelObj::getPostIts()
+{
+    if (!pDocShell)
+        return OUString();
+
+    const ScDocument& rDoc = pDocShell->GetDocument();
+    std::vector<sc::NoteEntry> aNotes;
+    rDoc.GetAllNoteEntries(aNotes);
+
+    boost::property_tree::ptree aAnnotations;
+    for (const sc::NoteEntry& aNote : aNotes)
+    {
+        boost::property_tree::ptree aAnnotation;
+        aAnnotation.put("id", aNote.maPos.hash());
+        aAnnotation.put("author", aNote.mpNote->GetAuthor());
+        aAnnotation.put("dateTime", aNote.mpNote->GetDate());
+        aAnnotation.put("text", aNote.mpNote->GetText());
+
+        // Calculating the cell cursor position
+        ScViewData* pViewData = ScDocShell::GetViewData();
+        ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+        if (pGridWindow)
+        {
+            Fraction zoomX = Fraction(long(mnTilePixelWidth * TWIPS_PER_PIXEL), mnTileTwipWidth);
+            Fraction zoomY = Fraction(long(mnTilePixelHeight * TWIPS_PER_PIXEL), mnTileTwipHeight);
+
+            Fraction defaultZoomX = pViewData->GetZoomX();
+            Fraction defaultZoomY = pViewData->GetZoomY();
+            pViewData->SetZoom(zoomX, zoomY, true);
+
+            SCCOL nX = aNote.maPos.Col();
+            SCROW nY = aNote.maPos.Row();
+            Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(), true);
+            long nSizeXPix;
+            long nSizeYPix;
+            pViewData->GetMergeSizePixel(nX, nY, nSizeXPix, nSizeYPix);
+
+            double fPPTX = pViewData->GetPPTX();
+            double fPPTY = pViewData->GetPPTY();
+            Rectangle aRect(Point(aScrPos.getX() / fPPTX, aScrPos.getY() / fPPTY),
+                            Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
+
+            pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
+
+            aAnnotation.put("cellPos", aRect.toString());
+        }
+
+        aAnnotations.push_back(std::make_pair("", aAnnotation));
+    }
+
+    boost::property_tree::ptree aTree;
+    aTree.add_child("comments", aAnnotations);
+    std::stringstream aStream;
+    boost::property_tree::write_json(aStream, aTree);
+
+    return OUString::createFromAscii(aStream.str().c_str());
+}
 
 void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/)
 {
commit c7bb5db91980ddc5e9df9cbea393cf2315c1d253
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 8 15:43:42 2017 +0530

    sc: Use less expensive alternative to count total notes
    
    No need to fill the vector unnecessarily when we are just concerned
    about the total count.
    
    Change-Id: I94d7cd6dd86e612edc078f7b70c051d67b787a5a
    (cherry picked from commit 16f8e1c398870870ed4ea4f90cd521f1885a1345)

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7b61def..fa9b4ab 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -4194,11 +4194,9 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount()
     sal_Int32 nCount = 0;
     if (pDocShell)
     {
-        ScDocument& rDoc = pDocShell->GetDocument();
-        const ScRangeList aRangeList( ScRange( 0, 0, nTab, MAXCOL, MAXROW, nTab) );
-        std::vector<sc::NoteEntry> rNotes;
-        rDoc.GetNotesInRange(aRangeList, rNotes);
-        nCount = rNotes.size();
+        const ScDocument& rDoc = pDocShell->GetDocument();
+        for (SCCOL nCol = 0; nCol <= MAXCOL; ++nCol)
+            nCount += rDoc.GetNoteCount(nTab, nCol);
     }
     return nCount;
 }
commit a835bcb91b3e41ac4441e0cc0f74ac8f02be22f4
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 3 16:16:02 2017 +0530

    lok: Disable map mode when calculating annotation rectangles
    
    Change-Id: I4803ca9b52ce76ff9f7461253ec78bfcbc26690c
    Reviewed-on: https://gerrit.libreoffice.org/33879
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 5bafdc99a15fa9b4b5e1b06f0f76d52addf09873)

diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index beae532..85fc5e5 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -912,7 +912,17 @@ void SwSidebarWin::SetPosAndSize()
             }
             std::unique_ptr<SwShellCursor> pTmpCursorForAnnotationTextRange( pTmpCursor );
 
+            // For annotation text range rectangles to be calculated correctly,
+            // we need the map mode disabled
+            bool bDisableMapMode = comphelper::LibreOfficeKit::isActive() && EditWin().IsMapModeEnabled();
+            if (bDisableMapMode)
+                EditWin().EnableMapMode(false);
+
             pTmpCursorForAnnotationTextRange->FillRects();
+
+            if (bDisableMapMode)
+                EditWin().EnableMapMode();
+
             SwRects* pRects(pTmpCursorForAnnotationTextRange.get());
             std::vector<OString> aRects;
             for(SwRect & rNextRect : *pRects)
commit 66e1a0d65adc373c148f57d386500602a8d25bc4
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 3 17:02:26 2017 +0530

    lok: Emit modify comment callback when anchor changes
    
    Change-Id: Ibe4a66b93768eb446a04cab8cfdd4bdebee13d1f
    Reviewed-on: https://gerrit.libreoffice.org/33878
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit a51faf9ead8ab3797e9a70bf2e487f26643ce9d0)

diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index de109fb..af4e5a4 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -82,6 +82,8 @@ class SwSidebarWin : public vcl::Window
 
         inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
         inline const SwRect& GetAnchorRect() { return mAnchorRect; }
+        inline bool IsAnchorRectChanged() { return mbAnchorRectChanged; }
+        inline void ResetAnchorRectChanged() { mbAnchorRectChanged = false; }
         inline const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() { return maAnnotationTextRanges; }
         SwEditWin& EditWin();
         inline SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
@@ -243,6 +245,7 @@ class SwSidebarWin : public vcl::Window
         Rectangle       mPosSize;
         SwRect          mAnchorRect;
         long            mPageBorder;
+        bool            mbAnchorRectChanged;
 
         std::vector<basegfx::B2DRange> maAnnotationTextRanges;
 
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 3c87288..61a4d0e 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -874,6 +874,11 @@ void SwPostItMgr::LayoutPostIts()
                     {
                         if ((*i)->GetSidebarItem().bPendingLayout)
                             lcl_CommentNotification(mpView, CommentNotificationType::Add, &(*i)->GetSidebarItem(), 0);
+                        else if ((*i)->IsAnchorRectChanged())
+                        {
+                            lcl_CommentNotification(mpView, CommentNotificationType::Modify, &(*i)->GetSidebarItem(), 0);
+                            (*i)->ResetAnchorRectChanged();
+                        }
                     }
 
                     // Layout for this post it finished now
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index e4eb830..beae532 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -183,6 +183,7 @@ SwSidebarWin::SwSidebarWin(SwEditWin& rEditWin,
     , mPosSize()
     , mAnchorRect()
     , mPageBorder(0)
+    , mbAnchorRectChanged(false)
     , mbMouseOver(false)
     , mLayoutStatus(SwPostItHelper::INVISIBLE)
     , mbReadonly(false)
@@ -509,6 +510,8 @@ void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeig
                                        const SwRect& aAnchorRect, const long aPageBorder)
 {
     mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
+    if (!mAnchorRect.IsEmpty() && mAnchorRect != aAnchorRect)
+        mbAnchorRectChanged = true;
     mAnchorRect = aAnchorRect;
     mPageBorder = aPageBorder;
 }
commit cff06958fbd04f546d2448b2b6f54c6f66e6f06a
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 3 17:00:51 2017 +0530

    lok: comments: emit add callback after layout finishes
    
    Change-Id: Ie6eba244dd5eb78813185f8c7aceed841d05d48b
    Reviewed-on: https://gerrit.libreoffice.org/33877
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 5596b3f86f753b7ae0a262ccea84c6a61bdc9ca2)

diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index 4d114b8..de109fb 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -84,6 +84,7 @@ class SwSidebarWin : public vcl::Window
         inline const SwRect& GetAnchorRect() { return mAnchorRect; }
         inline const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() { return maAnnotationTextRanges; }
         SwEditWin& EditWin();
+        inline SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
 
         inline OutlinerView* GetOutlinerView() { return mpOutlinerView;}
         bool HasScrollbar() const;
diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx
index 0c9fe92..73d3cfe 100644
--- a/sw/inc/postithelper.hxx
+++ b/sw/inc/postithelper.hxx
@@ -92,6 +92,7 @@ public:
     VclPtr<sw::sidebarwindows::SwSidebarWin> pPostIt;
     bool bShow;
     bool bFocus;
+    bool bPendingLayout;
 
     SwPostItHelper::SwLayoutStatus mLayoutStatus;
     SwLayoutInfo maLayoutInfo;
@@ -100,6 +101,7 @@ public:
         : pPostIt(nullptr)
         , bShow(true)
         , bFocus(aFocus)
+        , bPendingLayout(false)
         , mLayoutStatus( SwPostItHelper::INVISIBLE )
         , maLayoutInfo()
     {
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 80332ab..3c87288 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -357,17 +357,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     if (bEmpty && !mvPostItFields.empty())
                         PrepareView(true);
 
-                    // If LOK has disabled tiled annotations, emit annotation callbacks
-                    if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
-                    {
-                        CalcRects();
-                        Show();
-
-                        if (pItem && pItem->pPostIt)
-                        {
-                            lcl_CommentNotification(mpView, CommentNotificationType::Add, pItem, 0);
-                        }
-                    }
+                    // True until the layout of this post it finishes
+                    if (pItem)
+                        pItem->bPendingLayout = true;
                 }
                 else
                 {
@@ -875,6 +867,19 @@ void SwPostItMgr::LayoutPostIts()
                     pPage->bScrollbar = false;
                     bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate;
                 }
+
+                for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+                {
+                    if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
+                    {
+                        if ((*i)->GetSidebarItem().bPendingLayout)
+                            lcl_CommentNotification(mpView, CommentNotificationType::Add, &(*i)->GetSidebarItem(), 0);
+                    }
+
+                    // Layout for this post it finished now
+                    (*i)->GetSidebarItem().bPendingLayout = false;
+                }
+
                 aVisiblePostItList.clear();
             }
             else
commit 3ce4cb99c71849c0e1366f655077b25d820baaf3
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 3 13:43:01 2017 +0530

    Indentation
    
    Change-Id: I723438eb4258f12413a16b5b727f5c8f6eb3083c
    Reviewed-on: https://gerrit.libreoffice.org/33876
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 900556a89278f6d98fcce1405c9954318e52e671)

diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 65a896c..80332ab 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -867,11 +867,13 @@ void SwPostItMgr::LayoutPostIts()
                 else
                 {
                     for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
-                                                            (*i)->SetPosAndSize();
+                    {
+                        (*i)->SetPosAndSize();
+                    }
 
-                                                    bool bOldScrollbar = pPage->bScrollbar;
-                                                    pPage->bScrollbar = false;
-                                                    bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate;
+                    bool bOldScrollbar = pPage->bScrollbar;
+                    pPage->bScrollbar = false;
+                    bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate;
                 }
                 aVisiblePostItList.clear();
             }
commit ac13fba5d0e6dfa434c17009cf4b560d4b0ff7d5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Jan 31 00:57:29 2017 +0530

    lok: Send complete anchor rectangle
    
    ... instead of just sending the X, Y coordinates
    
    Change-Id: Ie87b252ebfd64e806e1e5f66cfc27e77282cbaab
    Reviewed-on: https://gerrit.libreoffice.org/33875
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 6d243a10724da6836b7f3e623d2815cc7b0a13c5)

diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index bb6dab5..4d114b8 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -81,6 +81,7 @@ class SwSidebarWin : public vcl::Window
         void CheckMetaText();
 
         inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
+        inline const SwRect& GetAnchorRect() { return mAnchorRect; }
         inline const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() { return maAnnotationTextRanges; }
         SwEditWin& EditWin();
 
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 1edd672..65a896c 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -152,7 +152,11 @@ namespace {
             sw::annotation::SwAnnotationWin* pWin = static_cast<sw::annotation::SwAnnotationWin*>((pItem)->pPostIt.get());
 
             const SwPostItField* pField = pWin->GetPostItField();
-            const OString aAnchorPos = OString::number(pWin->GetAnchorPos().X()) + ", " + OString::number(pWin->GetAnchorPos().Y());
+            const SwRect& aRect = pWin->GetAnchorRect();
+            const Rectangle aSVRect(aRect.Pos().getX(),
+                                    aRect.Pos().getY(),
+                                    aRect.Pos().getX() + aRect.SSize().Width(),
+                                    aRect.Pos().getY() + aRect.SSize().Height());
             std::vector<OString> aRects;
             for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
             {
@@ -166,7 +170,7 @@ namespace {
             aAnnotation.put("author", pField->GetPar1().toUtf8().getStr());
             aAnnotation.put("text", pField->GetPar2().toUtf8().getStr());
             aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
-            aAnnotation.put("anchorPos", aAnchorPos.getStr());
+            aAnnotation.put("anchorPos", aSVRect.toString());
             aAnnotation.put("textRange", sRects.getStr());
         }
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 047000e..84c286c 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3247,7 +3247,11 @@ OUString SwXTextDocument::getPostIts()
         sw::annotation::SwAnnotationWin* pWin = static_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt.get());
 
         const SwPostItField* pField = pWin->GetPostItField();
-        const OString aAnchorPos = OString::number(pWin->GetAnchorPos().X()) + ", " + OString::number(pWin->GetAnchorPos().Y());
+        const SwRect& aRect = pWin->GetAnchorRect();
+        const Rectangle aSVRect(aRect.Pos().getX(),
+                                aRect.Pos().getY(),
+                                aRect.Pos().getX() + aRect.SSize().Width(),
+                                aRect.Pos().getY() + aRect.SSize().Height());
         std::vector<OString> aRects;
         for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
         {
@@ -3262,7 +3266,7 @@ OUString SwXTextDocument::getPostIts()
         aAnnotation.put("author", pField->GetPar1().toUtf8().getStr());
         aAnnotation.put("text", pField->GetPar2().toUtf8().getStr());
         aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
-        aAnnotation.put("anchorPos", aAnchorPos.getStr());
+        aAnnotation.put("anchorPos", aSVRect.toString());
         aAnnotation.put("textRange", sRects.getStr());
 
         aAnnotations.push_back(std::make_pair("", aAnnotation));
commit 55ec2440eba11b034c6617ac06e24003e8feae5c
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Jan 31 19:35:49 2017 +0530

    gtktiledviewer: gtk version checks
    
    There is no major harm in excluding these lines of code on
    platforms with older gtk.
    
    Change-Id: Ica3f1e2b4f60f0bab55254632663ace7b4c61d4d
    (cherry picked from commit 96f597acf70ce52f2bdb59c85dd052be54b8d629)

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index e5f56a9..502ccf7 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list