diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-01-27 15:10:34 +0530 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2017-01-27 11:52:22 +0000 |
commit | 4b8e711ead69aaa129637aad484c63877fa10890 (patch) | |
tree | 3136319d7f13ce0c1eb51d19a16220b8a9abcbd9 /sw/source/uibase | |
parent | 5f5073a84518e4a8660e0153c2e218fb75a85ec4 (diff) |
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 <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 8d9bff9a2a51..d8cca6fad7bd 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 43b1b55b7db0..0e9a01e31e5f 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 a43658300749..549b150198f0 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())); |