[Libreoffice-commits] core.git: 5 commits - libreofficekit/qa sd/source

Pranav Kant pranavk at collabora.co.uk
Mon Feb 20 08:10:13 UTC 2017


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    4 -
 sd/source/ui/annotations/annotationmanager.cxx      |   16 +++++-
 sd/source/ui/inc/View.hxx                           |    3 +
 sd/source/ui/inc/unomodel.hxx                       |    2 
 sd/source/ui/unoidl/unomodel.cxx                    |   48 ++++++++++++++++++++
 5 files changed, 66 insertions(+), 7 deletions(-)

New commits:
commit c3b26856cc4d69bc206dc56e0b6a47d9cf4afb6c
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Feb 19 18:32:11 2017 +0530

    sd lok: Implement ViewAnnotations command
    
    Change-Id: I87dde393adc82dc59c08ec96d1fd79145de6f3c6

diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 9132662..0e34762 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -264,6 +264,8 @@ public:
     virtual bool isMimeTypeSupported() override;
     /// @see vcl::ITiledRenderable::getPointer().
     virtual Pointer getPointer() override;
+    /// @see vcl::ITiledRenderable::getPostIts().
+    virtual OUString getPostIts() override;
 
     // XComponent
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index d687550..3fcc45b 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <com/sun/star/presentation/XPresentation2.hpp>
 
 #include <com/sun/star/lang/DisposedException.hpp>
@@ -66,6 +68,7 @@
 #include <svx/unoshape.hxx>
 #include <editeng/unonrule.hxx>
 #include <editeng/eeitem.hxx>
+#include <unotools/datetime.hxx>
 #include <unotools/saveopt.hxx>
 
 // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
@@ -2361,6 +2364,40 @@ Size SdXImpressDocument::getDocumentSize()
     return Size(convertMm100ToTwip(aSize.getWidth()), convertMm100ToTwip(aSize.getHeight()));
 }
 
+OUString SdXImpressDocument::getPostIts()
+{
+    boost::property_tree::ptree aAnnotations;
+    // Return annotations on master pages too ?
+    const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
+    SdPage* pPage;
+    for (sal_uInt16 nPage = 0; nPage < nMaxPages; ++nPage)
+    {
+        pPage = static_cast<SdPage*>(mpDoc->GetPage(nPage));
+        const sd::AnnotationVector& aPageAnnotations = pPage->getAnnotations();
+
+        for (const auto& aPageAnnotation : aPageAnnotations)
+        {
+            uno::Reference<office::XAnnotation> xAnnotation(aPageAnnotation);
+
+            boost::property_tree::ptree aAnnotation;
+
+            aAnnotation.put("author", xAnnotation->getAuthor());
+            aAnnotation.put("dateTime", utl::toISO8601(xAnnotation->getDateTime()));
+            uno::Reference<text::XText> xText(xAnnotation->getTextRange());
+            aAnnotation.put("text", xText->getString());
+
+            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 SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
 {
     SolarMutexGuard aGuard;
commit 6b4103984f31b42c791800925328dda00f17f122
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Feb 19 18:31:20 2017 +0530

    gtktiledviewer: enable comment sidebar for all doctypes
    
    Impress was the only doctype remaining which didn't have comments api
    yet, but now it does
    
    Change-Id: I4e287301e879dff1c29c26880305505466ceaba4

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 3115fd4..1996368f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -1132,9 +1132,7 @@ static void initWindow(TiledWindow& rWindow)
     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 (!bTiledAnnotations && pDocument)
     {
         if (!rWindow.m_pCommentsSidebar)
         {
commit fbb171357048dc5ef52faec118327e68d423fa91
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Feb 19 15:28:25 2017 +0530

    sd lok: Disable comments if required
    
    Change-Id: Ic321bb9d35f5db3d2fbeb9f183aaa48da23002f3

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 6692e46..d687550 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/embed/Aspects.hpp>
 
 #include <osl/mutex.hxx>
+#include <comphelper/lok.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/servicehelper.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -88,12 +89,15 @@
 #include <stlpool.hxx>
 #include <unopback.hxx>
 #include <unokywds.hxx>
+
 #include "FrameView.hxx"
 #include "ClientView.hxx"
 #include "DrawViewShell.hxx"
 #include "ViewShell.hxx"
 #include "Window.hxx"
 #include "app.hrc"
+#include "optsitem.hxx"
+
 #include <vcl/pdfextoutdevdata.hxx>
 #include <com/sun/star/presentation/AnimationEffect.hpp>
 #include <com/sun/star/presentation/AnimationSpeed.hpp>
@@ -2376,6 +2380,11 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
             else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
                 pDrawView->SetAuthor(rValue.Value.get<OUString>());
         }
+
+        // Disable comments if requested
+        SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType());
+        pOptions->SetShowComments(comphelper::LibreOfficeKit::isTiledAnnotations());
+
         // Disable map mode, so that it's possible to send mouse event coordinates
         // in logic units.
         if (sd::Window* pWindow = pViewShell->GetActiveWindow())
commit 5556b6e9ad791fc31ef4428ec7dd342c5e0e5482
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Feb 19 15:16:56 2017 +0530

    sd lok: use stored per view author name
    
    Change-Id: I8b56a7d6aeb9d98d42cb1c07cd347d1171762b08

diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 2c75dff..4f895c53 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/geometry/RealPoint2D.hpp>
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <comphelper/lok.hxx>
 #include <comphelper/string.hxx>
 #include <svx/svxids.hrc>
 
@@ -394,11 +395,18 @@ void AnnotationManagerImpl::InsertAnnotation()
         Reference< XAnnotation > xAnnotation;
         pPage->createAnnotation( xAnnotation );
 
-        // set current author to new annotation
-        SvtUserOptions aUserOptions;
-        xAnnotation->setAuthor( aUserOptions.GetFullName() );
-        xAnnotation->setInitials( aUserOptions.GetID() );
+        OUString sAuthor;
+        if (comphelper::LibreOfficeKit::isActive())
+            sAuthor = mrBase.GetMainViewShell()->GetView()->GetAuthor();
+        else
+        {
+            SvtUserOptions aUserOptions;
+            sAuthor = aUserOptions.GetFullName();
+            xAnnotation->setInitials( aUserOptions.GetID() );
+        }
 
+        // set current author to new annotation
+        xAnnotation->setAuthor( sAuthor );
         // set current time to new annotation
         xAnnotation->setDateTime( getCurrentDateTime() );
 
commit b46f3cd56fc5bcd419d79d1f615c3e1921ec5bb0
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Feb 19 15:05:32 2017 +0530

    sd: Per view author names
    
    Change-Id: Ie7146ec289263eb3240a4b9270c4a88837ebd2ad

diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index e19b7b3..f6f84c0 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -227,6 +227,8 @@ public:
     SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
     SdPage* GetPage();
     SdrObject* GetSelectedSingleObject(SdPage* pPage);
+    void SetAuthor(const OUString& rAuthor) { m_sAuthor = rAuthor; }
+    const OUString& GetAuthor() { return m_sAuthor; }
 
 protected:
     DECL_LINK( OnParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, void );
@@ -261,6 +263,7 @@ protected:
 private:
     ::std::unique_ptr<ViewClipboard> mpClipboard;
     OutlinerMasterViewFilter maMasterViewFilter;
+    OUString m_sAuthor;
 };
 
 SdDrawDocument& View::GetDoc() const
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index d529736..6692e46 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2373,6 +2373,8 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
             const beans::PropertyValue& rValue = rArguments[i];
             if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
                 pDrawView->SetPageShadowVisible(rValue.Value.get<bool>());
+            else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
+                pDrawView->SetAuthor(rValue.Value.get<OUString>());
         }
         // Disable map mode, so that it's possible to send mouse event coordinates
         // in logic units.


More information about the Libreoffice-commits mailing list