[Libreoffice-commits] core.git: 4 commits - sc/inc sc/source

Pranav Kant pranavk at collabora.co.uk
Thu Feb 16 04:36:11 UTC 2017


 sc/inc/docuno.hxx                 |    3 +
 sc/inc/viewdata.hxx               |    1 
 sc/source/ui/docshell/docfunc.cxx |    5 ++
 sc/source/ui/unoobj/docuno.cxx    |   71 +++++++++++++++++++++++++++++++++++---
 4 files changed, 74 insertions(+), 6 deletions(-)

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

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 671b400..dde0818 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>
@@ -1214,7 +1215,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 c7b84ac9ea14e6c96165e3281c4bea422918c83f
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

diff --git a/sc/inc/viewdata.hxx b/sc/inc/viewdata.hxx
index 1d9dcda..6a8eb4c 100644
--- a/sc/inc/viewdata.hxx
+++ b/sc/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 beb3bd6..f506fa5 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1052,6 +1052,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 31b32d156ab69f347f21de29c8ba6cd07cc4dc95
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

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index d496958..e7195e5 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -356,6 +356,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 2c43888..beb3bd6 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>
@@ -975,6 +977,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 16f8e1c398870870ed4ea4f90cd521f1885a1345
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

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 41b7c48..2c43888 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -4092,11 +4092,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;
 }


More information about the Libreoffice-commits mailing list