summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx19
-rw-r--r--include/vcl/ITiledRenderable.hxx7
-rw-r--r--sw/inc/AnnotationWin.hxx2
-rw-r--r--sw/inc/SidebarWin.hxx4
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/source/uibase/docvw/SidebarWin.cxx93
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx44
7 files changed, 127 insertions, 45 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4d2dc02a6a0a..2403ff6c8f27 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1867,6 +1867,20 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get());
}
+/// Returns the JSON representation of all the comments in the document
+static char* getPostIts(LibreOfficeKitDocument* pThis)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return nullptr;
+ }
+ OUString aComments = pDoc->getPostIts();
+ return strdup(aComments.toUtf8().getStr());
+}
+
+
static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode)
{
SolarMutexGuard aGuard;
@@ -2416,6 +2430,7 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis)
return pJson;
}
+
/// Returns the JSON representation of the redline author table.
static char* getTrackedChangeAuthors(LibreOfficeKitDocument* pThis)
{
@@ -2462,6 +2477,10 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
{
return getTrackedChangeAuthors(pThis);
}
+ else if (aCommand == ".uno:ViewAnnotations")
+ {
+ return getPostIts(pThis);
+ }
else if (aCommand.startsWith(aViewRowColumnHeaders))
{
ITiledRenderable* pDoc = getTiledRenderable(pThis);
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index a6cb988226b0..abe4979058c8 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -219,6 +219,13 @@ public:
{
return OUString();
}
+
+ /// Implementation for
+ /// lok::Document::getCommandValues(".uno:ViewAnnotations");
+ virtual OUString getPostIts()
+ {
+ return OUString();
+ }
};
} // namespace vcl
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 8d41b587871c..07dde376b880 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_SW_INC_ANNOTATIONWIN_HXX
#define INCLUDED_SW_INC_ANNOTATIONWIN_HXX
+#include <docufld.hxx>
#include <SidebarWin.hxx>
class PopupMenu;
@@ -43,6 +44,7 @@ class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin
virtual void SetPostItText() override;
virtual void Delete() override;
virtual void GotoPos() override;
+ inline const SwPostItField* GetPostItField() { return mpField; }
virtual OUString GetAuthor() override;
virtual Date GetDate() override;
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index adfb47c16118..742e2f29c5b3 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -30,6 +30,7 @@
#include <vcl/lineinfo.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/range/b2drange.hxx>
#include <editeng/editstat.hxx>
class SwPostItMgr;
@@ -80,6 +81,7 @@ class SwSidebarWin : public vcl::Window
void CheckMetaText();
inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
+ inline const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() { return maAnnotationTextRanges; }
SwEditWin& EditWin();
inline OutlinerView* GetOutlinerView() { return mpOutlinerView;}
@@ -240,6 +242,8 @@ class SwSidebarWin : public vcl::Window
SwRect mAnchorRect;
long mPageBorder;
+ std::vector<basegfx::B2DRange> maAnnotationTextRanges;
+
bool mbMouseOver;
SwPostItHelper::SwLayoutStatus mLayoutStatus;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e358cbd0f19f..aeb55619e716 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -419,7 +419,8 @@ public:
virtual Pointer getPointer() override;
/// @see vcl::ITiledRenderable::getTrackedChangeAuthors().
OUString getTrackedChangeAuthors() override;
-
+ /// @see vcl::ITiledRenderable::getPostIts().
+ OUString getPostIts() override;
// css::tiledrendering::XTiledRenderable
virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 6f739ccd4157..f71b6b614f1b 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -24,7 +24,8 @@
#include <SidebarWin.hxx>
#include <SidebarWinAcc.hxx>
#include <PostItMgr.hxx>
-
+#include <basegfx/range/b2drange.hxx>
+#include <comphelper/string.hxx>
#include <SidebarTxtControl.hxx>
#include <SidebarScrollBar.hxx>
#include <AnchorOverlayObject.hxx>
@@ -356,6 +357,7 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence());
if (mpTextRangeOverlay)
pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence());
+
rRenderContext.Push(PushFlags::NONE);
pProcessor.reset();
rRenderContext.Push(PushFlags::NONE);
@@ -868,62 +870,65 @@ void SwSidebarWin::SetPosAndSize()
}
}
+
// text range overlay
- if ( mrMgr.ShowNotes()
- && mrSidebarItem.maLayoutInfo.mnStartNodeIdx != 0
+ maAnnotationTextRanges.clear();
+ if ( mrSidebarItem.maLayoutInfo.mnStartNodeIdx != 0
&& mrSidebarItem.maLayoutInfo.mnStartContent != -1 )
{
- std::vector< basegfx::B2DRange > aAnnotationTextRanges;
+ const SwTextAnnotationField* pTextAnnotationField =
+ dynamic_cast< const SwTextAnnotationField* >( mrSidebarItem.GetFormatField().GetTextField() );
+ SwTextNode* pTextNode = pTextAnnotationField ? pTextAnnotationField->GetpTextNode() : nullptr;
+ SwContentNode* pContentNd = nullptr;
+ if (pTextNode)
+ {
+ SwNodes& rNds = pTextNode->GetDoc()->GetNodes();
+ pContentNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetContentNode();
+ }
+ if (pContentNd)
{
- const SwTextAnnotationField* pTextAnnotationField =
- dynamic_cast< const SwTextAnnotationField* >( mrSidebarItem.GetFormatField().GetTextField() );
- SwTextNode* pTextNode = pTextAnnotationField ? pTextAnnotationField->GetpTextNode() : nullptr;
- SwContentNode* pContentNd = nullptr;
- if (pTextNode)
+ SwPosition aStartPos( *pContentNd, mrSidebarItem.maLayoutInfo.mnStartContent );
+ SwShellCursor* pTmpCursor = nullptr;
+ const bool bTableCursorNeeded = pTextNode->FindTableBoxStartNode() != pContentNd->FindTableBoxStartNode();
+ if ( bTableCursorNeeded )
{
- SwNodes& rNds = pTextNode->GetDoc()->GetNodes();
- pContentNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetContentNode();
+ SwShellTableCursor* pTableCursor = new SwShellTableCursor( DocView().GetWrtShell(), aStartPos );
+ pTableCursor->SetMark();
+ pTableCursor->GetMark()->nNode = *pTextNode;
+ pTableCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 );
+ pTableCursor->NewTableSelection();
+ pTmpCursor = pTableCursor;
}
- if (pContentNd)
+ else
{
- SwPosition aStartPos( *pContentNd, mrSidebarItem.maLayoutInfo.mnStartContent );
- SwShellCursor* pTmpCursor = nullptr;
- const bool bTableCursorNeeded = pTextNode->FindTableBoxStartNode() != pContentNd->FindTableBoxStartNode();
- if ( bTableCursorNeeded )
- {
- SwShellTableCursor* pTableCursor = new SwShellTableCursor( DocView().GetWrtShell(), aStartPos );
- pTableCursor->SetMark();
- pTableCursor->GetMark()->nNode = *pTextNode;
- pTableCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 );
- pTableCursor->NewTableSelection();
- pTmpCursor = pTableCursor;
- }
- else
- {
- SwShellCursor* pCursor = new SwShellCursor( DocView().GetWrtShell(), aStartPos );
- pCursor->SetMark();
- pCursor->GetMark()->nNode = *pTextNode;
- pCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 );
- pTmpCursor = pCursor;
- }
- std::unique_ptr<SwShellCursor> pTmpCursorForAnnotationTextRange( pTmpCursor );
+ SwShellCursor* pCursor = new SwShellCursor( DocView().GetWrtShell(), aStartPos );
+ pCursor->SetMark();
+ pCursor->GetMark()->nNode = *pTextNode;
+ pCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 );
+ pTmpCursor = pCursor;
+ }
+ std::unique_ptr<SwShellCursor> pTmpCursorForAnnotationTextRange( pTmpCursor );
- pTmpCursorForAnnotationTextRange->FillRects();
- SwRects* pRects(pTmpCursorForAnnotationTextRange.get());
- for(SwRect & rNextRect : *pRects)
- {
- const Rectangle aPntRect(rNextRect.SVRect());
+ pTmpCursorForAnnotationTextRange->FillRects();
+ SwRects* pRects(pTmpCursorForAnnotationTextRange.get());
+ std::vector<OString> aRects;
+ for(SwRect & rNextRect : *pRects)
+ {
+ aRects.push_back(rNextRect.SVRect().toString());
+ const Rectangle aPntRect(rNextRect.SVRect());
- aAnnotationTextRanges.push_back(basegfx::B2DRange(
- aPntRect.Left(), aPntRect.Top(),
- aPntRect.Right() + 1, aPntRect.Bottom() + 1));
- }
+ maAnnotationTextRanges.push_back(basegfx::B2DRange(
+ aPntRect.Left(), aPntRect.Top(),
+ aPntRect.Right() + 1, aPntRect.Bottom() + 1));
}
}
+ }
+ if (mrMgr.ShowNotes() && !maAnnotationTextRanges.empty())
+ {
if ( mpTextRangeOverlay != nullptr )
{
- mpTextRangeOverlay->setRanges( aAnnotationTextRanges );
+ mpTextRangeOverlay->setRanges( maAnnotationTextRanges );
if ( mpAnchor != nullptr && mpAnchor->getLineSolid() )
{
mpTextRangeOverlay->ShowSolidBorder();
@@ -940,7 +945,7 @@ void SwSidebarWin::SetPosAndSize()
sw::overlay::OverlayRanges::CreateOverlayRange(
DocView(),
mColorAnchor,
- aAnnotationTextRanges,
+ maAnnotationTextRanges,
mpAnchor && mpAnchor->getLineSolid() );
}
}
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 81519d940c3c..a43658300749 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -17,8 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <boost/property_tree/json_parser.hpp>
+
#include <sal/config.h>
+#include <comphelper/string.hxx>
+#include <AnnotationWin.hxx>
#include <o3tl/any.hxx>
#include <osl/mutex.hxx>
#include <vcl/image.hxx>
@@ -64,6 +68,7 @@
#include <unodraw.hxx>
#include <svl/eitem.hxx>
#include <pagedesc.hxx>
+#include <unotools/datetime.hxx>
#include <unotools/textsearch.hxx>
#include <unocrsr.hxx>
#include <unofieldcoll.hxx>
@@ -3179,6 +3184,45 @@ OUString SwXTextDocument::getTrackedChangeAuthors()
return SW_MOD()->GetRedlineAuthorInfo();
}
+OUString SwXTextDocument::getPostIts()
+{
+ SolarMutexGuard aGuard;
+ boost::property_tree::ptree aAnnotations;
+ for (std::list<SwSidebarItem*>::const_iterator i = pDocShell->GetView()->GetPostItMgr()->begin();
+ i != pDocShell->GetView()->GetPostItMgr()->end(); i++ )
+ {
+ sw::annotation::SwAnnotationWin* pWin = static_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt.get());
+
+ const SwPostItField* pField = pWin->GetPostItField();
+ const std::string aAnchorPos = std::to_string(pWin->GetAnchorPos().X()) + ", " + std::to_string(pWin->GetAnchorPos().Y());
+ std::vector<OString> aRects;
+ for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
+ {
+ const SwRect rect(aRange.getMinX(), aRange.getMinY(), aRange.getWidth(), aRange.getHeight());
+ aRects.push_back(rect.SVRect().toString());
+ }
+ const OString sRects = comphelper::string::join("; ", aRects);
+
+ boost::property_tree::ptree aAnnotation;
+ aAnnotation.put("id", pField->GetPostItId());
+ aAnnotation.put("reply", pWin->IsFollow());
+ 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.c_str());
+ aAnnotation.put("textRange", sRects.getStr());
+
+ 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());
+}
+
int SwXTextDocument::getPart()
{
SolarMutexGuard aGuard;