sw/inc/AnnotationWin.hxx | 3 ++- sw/inc/SidebarWin.hxx | 2 +- sw/source/uibase/docvw/AnnotationWin.cxx | 12 +++++++++--- sw/source/uibase/docvw/PostItMgr.cxx | 6 +++--- sw/source/uibase/uno/unotxdoc.cxx | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-)
New commits: commit 4b8e711ead69aaa129637aad484c63877fa10890 Author: Pranav Kant <pran...@collabora.co.uk> Date: Fri Jan 27 15:10:34 2017 +0530 lok: Calculate and return parent comment id ... instead of just checking if its a root comment or reply one. Change-Id: I2539e6893ee69bfe12911807504df49edf422be2 Reviewed-on: https://gerrit.libreoffice.org/33470 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 07dde37..0062f96 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -52,7 +52,8 @@ class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin virtual sal_uInt32 MoveCaret() override; - virtual bool CalcFollow() override; + /// Calculate parent postit id of currrent annotation window + virtual sal_uInt32 CalcParent() override; void InitAnswer(OutlinerParaObject* pText); virtual bool IsProtected() override; diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index 742e2f2..bb6dab5 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -146,7 +146,7 @@ class SwSidebarWin : public vcl::Window bool IsFollow() { return mbIsFollow; } void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; }; - virtual bool CalcFollow() = 0; + virtual sal_uInt32 CalcParent() = 0; sal_Int32 GetMetaHeight(); sal_Int32 GetMinimumSizeWithMeta(); diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 8d9bff9..d8cca6f 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -177,8 +177,8 @@ sal_uInt32 SwAnnotationWin::MoveCaret() : 1 + CountFollowing(); } -//returns true, if there is another note right before this note -bool SwAnnotationWin::CalcFollow() +// returns a non-zero postit parent id, if exists, otherwise 0 for root comments +sal_uInt32 SwAnnotationWin::CalcParent() { SwTextField* pTextField = mpFormatField->GetTextField(); SwPosition aPosition( pTextField->GetTextNode() ); @@ -188,7 +188,13 @@ bool SwAnnotationWin::CalcFollow() aPosition.nContent.GetIndex() - 1, RES_TXTATR_ANNOTATION ); const SwField* pField = pTextAttr ? pTextAttr->GetFormatField().GetField() : nullptr; - return pField && (pField->Which()== RES_POSTITFLD); + sal_uInt32 nParentId = 0; + if (pField && pField->Which() == RES_POSTITFLD) + { + const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField); + nParentId = pPostItField->GetPostItId(); + } + return nParentId; } // counts how many SwPostItField we have right after the current one diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 43b1b55..0e9a01e 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -161,7 +161,7 @@ namespace { const OString sRects = comphelper::string::join("; ", aRects); aAnnotation.put("id", pField->GetPostItId()); - aAnnotation.put("reply", pWin->IsFollow()); + aAnnotation.put("parent", pWin->CalcParent()); aAnnotation.put("author", pField->GetPar1().toUtf8().getStr()); aAnnotation.put("text", pField->GetPar2().toUtf8().getStr()); aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime())); @@ -743,7 +743,7 @@ void SwPostItMgr::LayoutPostIts() pItem->pPostIt = pPostIt; if (mpAnswer) { - if (pPostIt->CalcFollow()) //do we really have another note in front of this one + if (static_cast<bool>(pPostIt->CalcParent())) //do we really have another note in front of this one static_cast<sw::annotation::SwAnnotationWin*>(pPostIt.get())->InitAnswer(mpAnswer); delete mpAnswer; mpAnswer = nullptr; @@ -754,7 +754,7 @@ void SwPostItMgr::LayoutPostIts() pItem->mLayoutStatus, GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor)); pPostIt->SetSidebarPosition(pPage->eSidebarPosition); - pPostIt->SetFollow(pPostIt->CalcFollow()); + pPostIt->SetFollow(static_cast<bool>(pPostIt->CalcParent())); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() ? pPostIt->GetMinimumSizeWithoutMeta() : pPostIt->GetPostItTextHeight() ) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index a436583..549b150 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3205,7 +3205,7 @@ OUString SwXTextDocument::getPostIts() boost::property_tree::ptree aAnnotation; aAnnotation.put("id", pField->GetPostItId()); - aAnnotation.put("reply", pWin->IsFollow()); + aAnnotation.put("parent", pWin->CalcParent()); aAnnotation.put("author", pField->GetPar1().toUtf8().getStr()); aAnnotation.put("text", pField->GetPar2().toUtf8().getStr()); aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime())); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits