From 3d7e9a7faec98b92c61eac8bd10e2db4772b235f Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Sun, 19 Feb 2017 18:32:11 +0530 Subject: sd lok: Implement ViewAnnotations command Change-Id: I87dde393adc82dc59c08ec96d1fd79145de6f3c6 (cherry picked from commit c3b26856cc4d69bc206dc56e0b6a47d9cf4afb6c) --- sd/source/ui/inc/unomodel.hxx | 2 ++ sd/source/ui/unoidl/unomodel.cxx | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'sd') diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 0aff34745a0b..087fa521ca9e 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -265,6 +265,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 04578f87c1af..61a02779e5c3 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 + #include #include @@ -65,6 +67,7 @@ #include #include #include +#include #include // Support creation of GraphicObjectResolver and EmbeddedObjectResolver @@ -2376,6 +2379,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(mpDoc->GetPage(nPage)); + const sd::AnnotationVector& aPageAnnotations = pPage->getAnnotations(); + + for (const auto& aPageAnnotation : aPageAnnotations) + { + uno::Reference xAnnotation(aPageAnnotation); + + boost::property_tree::ptree aAnnotation; + + aAnnotation.put("author", xAnnotation->getAuthor()); + aAnnotation.put("dateTime", utl::toISO8601(xAnnotation->getDateTime())); + uno::Reference 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& rArguments) { SolarMutexGuard aGuard; -- cgit v1.2.3