summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/postithelper.hxx5
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx10
-rw-r--r--sw/source/core/fields/postithelper.cxx8
-rw-r--r--sw/source/core/layout/wsfrm.cxx7
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx18
5 files changed, 40 insertions, 8 deletions
diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx
index cdbbc7b27580..e0f934dfe025 100644
--- a/sw/inc/postithelper.hxx
+++ b/sw/inc/postithelper.hxx
@@ -31,6 +31,7 @@ class SwRootFrame;
class SwPostItMgr;
class SwEditWin;
class SwFrame;
+class IDocumentRedlineAccess;
namespace sw { namespace annotation {
class SwAnnotationWin;
} }
@@ -115,7 +116,7 @@ public:
SwSidebarItem & operator =(SwSidebarItem &&) = default;
virtual SwPosition GetAnchorPosition() const = 0;
- virtual bool UseElement() = 0;
+ virtual bool UseElement(SwRootFrame const&, IDocumentRedlineAccess const&) = 0;
virtual const SwFormatField& GetFormatField() const = 0;
virtual const SfxBroadcaster* GetBroadCaster() const = 0;
virtual VclPtr<sw::annotation::SwAnnotationWin> GetSidebarWindow( SwEditWin& rEditWin,
@@ -134,7 +135,7 @@ public:
}
virtual SwPosition GetAnchorPosition() const override;
- virtual bool UseElement() override;
+ virtual bool UseElement(SwRootFrame const&, IDocumentRedlineAccess const&) override;
virtual const SwFormatField& GetFormatField() const override
{
return mrFormatField;
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 5da8c16f1877..71816cc7c20c 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -21,6 +21,8 @@
#include <rootfrm.hxx>
#include <txtfrm.hxx>
#include <doc.hxx>
+#include <docsh.hxx>
+#include <fmtfld.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentFieldsAccess.hxx>
#include <IDocumentState.hxx>
@@ -166,6 +168,10 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam)
}
// fields last - SwGetRefField::UpdateField requires up-to-date frames
UpdateFieldsForRedline(rDoc.getIDocumentFieldsAccess()); // after footnotes
+
+ // update SwPostItMgr / notes in the margin
+ rDoc.GetDocShell()->Broadcast(
+ SwFormatFieldHint(nullptr, SwFormatFieldHintWhich::REMOVED) );
}
void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam)
@@ -225,6 +231,10 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam)
}
// fields last - SwGetRefField::UpdateField requires up-to-date frames
UpdateFieldsForRedline(rDoc.getIDocumentFieldsAccess()); // after footnotes
+
+ // update SwPostItMgr / notes in the margin
+ rDoc.GetDocShell()->Broadcast(
+ SwFormatFieldHint(nullptr, SwFormatFieldHintWhich::INSERTED) );
}
} // namespace sw
diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx
index d02bbec26c6a..8b276678a3d7 100644
--- a/sw/source/core/fields/postithelper.cxx
+++ b/sw/source/core/fields/postithelper.cxx
@@ -31,6 +31,7 @@
#include <txtfrm.hxx>
#include <tabfrm.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <redline.hxx>
#include <scriptinfo.hxx>
#include <editeng/charhiddenitem.hxx>
@@ -142,9 +143,12 @@ SwPosition SwAnnotationItem::GetAnchorPosition() const
return aPos;
}
-bool SwAnnotationItem::UseElement()
+bool SwAnnotationItem::UseElement(SwRootFrame const& rLayout,
+ IDocumentRedlineAccess const& rIDRA)
{
- return mrFormatField.IsFieldInDoc();
+ return mrFormatField.IsFieldInDoc()
+ && (!rLayout.IsHideRedlines()
+ || !sw::IsFieldDeletedInModel(rIDRA, *mrFormatField.GetTextField()));
}
VclPtr<sw::annotation::SwAnnotationWin> SwAnnotationItem::GetSidebarWindow(
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 914df003d2b1..aa2cd56249f6 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4518,6 +4518,13 @@ void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
rIDFA.UpdateExpFields(nullptr, false);
rIDFA.UpdateRefFields();
+ // update SwPostItMgr / notes in the margin
+ // note: as long as all shells share layout, broadcast to all shells!
+ rDoc.GetDocShell()->Broadcast( SwFormatFieldHint(nullptr, bHideRedlines
+ ? SwFormatFieldHintWhich::REMOVED
+ : SwFormatFieldHintWhich::INSERTED) );
+
+
// InvalidateAllContent(SwInvalidateFlags::Size); // ??? TODO what to invalidate? this is the big hammer
}
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 2355151e851c..b702fd4bccbe 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -52,6 +52,7 @@
#include <ndtxt.hxx>
#include <redline.hxx>
#include <docary.hxx>
+#include <rootfrm.hxx>
#include <SwRewriter.hxx>
#include <tools/color.hxx>
#include <unotools/datetime.hxx>
@@ -240,13 +241,15 @@ SwPostItMgr::~SwPostItMgr()
void SwPostItMgr::CheckForRemovedPostIts()
{
+ IDocumentRedlineAccess const& rIDRA(mpWrtShell->getIDocumentRedlineAccess());
bool bRemoved = false;
auto currentIt = mvPostItFields.begin();
while(currentIt != mvPostItFields.end())
{
auto it = currentIt++;
- if ( !(*it)->UseElement() )
+ if (!(*it)->UseElement(*mpWrtShell->GetLayout(), rIDRA))
{
+ EndListening(const_cast<SfxBroadcaster&>(*(*it)->GetBroadCaster()));
SwSidebarItem* p = (*it);
currentIt = mvPostItFields.erase(std::remove(mvPostItFields.begin(), mvPostItFields.end(), *it), mvPostItFields.end());
if (GetActiveSidebarWin() == p->pPostIt)
@@ -531,9 +534,10 @@ bool SwPostItMgr::CalcRects()
PreparePageContainer();
if ( !mvPostItFields.empty() )
{
+ IDocumentRedlineAccess const& rIDRA(mpWrtShell->getIDocumentRedlineAccess());
for (auto const& pItem : mvPostItFields)
{
- if ( !pItem->UseElement() )
+ if (!pItem->UseElement(*mpWrtShell->GetLayout(), rIDRA))
{
OSL_FAIL("PostIt is not in doc or other wrong use");
bRepair = true;
@@ -887,10 +891,11 @@ void SwPostItMgr::LayoutPostIts()
if (!ShowNotes())
{ // we do not want to see the notes anymore -> Options-Writer-View-Notes
+ IDocumentRedlineAccess const& rIDRA(mpWrtShell->getIDocumentRedlineAccess());
bool bRepair = false;
for (auto const& postItField : mvPostItFields)
{
- if ( !postItField->UseElement() )
+ if (!postItField->UseElement(*mpWrtShell->GetLayout(), rIDRA))
{
OSL_FAIL("PostIt is not in doc!");
bRepair = true;
@@ -1298,8 +1303,13 @@ void SwPostItMgr::AddPostIts(bool bCheckExistence, bool bFocus)
{
if ( pSwFormatField->GetTextField())
{
- if ( pSwFormatField->IsFieldInDoc() )
+ IDocumentRedlineAccess const& rIDRA(mpWrtShell->getIDocumentRedlineAccess());
+ if (pSwFormatField->IsFieldInDoc()
+ && (!mpWrtShell->GetLayout()->IsHideRedlines()
+ || !sw::IsFieldDeletedInModel(rIDRA, *pSwFormatField->GetTextField())))
+ {
InsertItem(pSwFormatField,bCheckExistence,bFocus);
+ }
}
pSwFormatField = aIter.Next();
}