summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-01-21 13:15:50 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-01-30 14:18:46 +0100
commitef8427d12a63127a2eb867637699343d630545dd (patch)
treeb3312295b36246c8bad99e417639445cfe23670e
parent3a248dfe57318af57fc5df89652cb64dfa923e46 (diff)
tdf#45589 sw: invalidate on bookmark insertion/deletion
Invalidate the text frames when a bookmark is inserted or deleted; also when MarkManager::repositionMark() changes the positions. The other calls of SetMarkPos()/SetOtherMarkPos() look like they're all from code that corrects positions after text insertions or deletions so no additional invalidate should be necessary there. It turns out that one WW8 document in sw_filters_test wants to insert a bookmark on a SwGrfNode; check for that in makeMark(). Change-Id: I293e6da9042bea5992cb27091b9cff77e5c7961d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87157 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/source/core/crsr/bookmrk.cxx42
-rw-r--r--sw/source/core/doc/docbm.cxx14
-rw-r--r--sw/source/core/inc/bookmrk.hxx10
3 files changed, 62 insertions, 4 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 6643e77f03e9..f299436eeb61 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -238,6 +238,12 @@ namespace
io_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::UI_REPLACE, nullptr);
};
+
+ auto InvalidatePosition(SwPosition const& rPos) -> void
+ {
+ SwUpdateAttr const hint(rPos.nContent.GetIndex(), rPos.nContent.GetIndex(), 0);
+ rPos.nNode.GetNode().GetTextNode()->NotifyClients(nullptr, &hint);
+ }
}
namespace sw::mark
@@ -336,6 +342,10 @@ namespace sw::mark
}
}
+ auto MarkBase::InvalidateFrames() -> void
+ {
+ }
+
NavigatorReminder::NavigatorReminder(const SwPaM& rPaM)
: MarkBase(rPaM, MarkBase::GenerateNewName("__NavigatorReminder__"))
{ }
@@ -392,6 +402,7 @@ namespace sw::mark
std::make_unique<SwUndoInsBookmark>(*this));
}
io_pDoc->getIDocumentState().SetModified();
+ InvalidateFrames();
}
void Bookmark::DeregisterFromDoc(SwDoc* const io_pDoc)
@@ -404,6 +415,35 @@ namespace sw::mark
std::make_unique<SwUndoDeleteBookmark>(*this));
}
io_pDoc->getIDocumentState().SetModified();
+ InvalidateFrames();
+ }
+
+ // invalidate text frames in case it's hidden or Formatting Marks enabled
+ auto Bookmark::InvalidateFrames() -> void
+ {
+ InvalidatePosition(GetMarkPos());
+ if (IsExpanded())
+ {
+ InvalidatePosition(GetOtherMarkPos());
+ }
+ }
+
+ void Bookmark::Hide(bool const isHide)
+ {
+ if (isHide != m_bHidden)
+ {
+ m_bHidden = isHide;
+ InvalidateFrames();
+ }
+ }
+
+ void Bookmark::SetHideCondition(OUString const& rHideCondition)
+ {
+ if (m_sHideCondition != rHideCondition)
+ {
+ m_sHideCondition = rHideCondition;
+ InvalidateFrames();
+ }
}
::sfx2::IXmlIdRegistry& Bookmark::GetRegistry()
@@ -512,6 +552,8 @@ namespace sw::mark
if (eMode == sw::mark::InsertMode::New)
{
lcl_SetFieldMarks(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, pSepPos);
+ // no need to invalidate text frames here, the insertion of the
+ // CH_TXT_ATR already invalidates
}
else
{
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 4144ad47a567..bff33b553eb9 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -561,6 +561,16 @@ namespace sw::mark
pPos2->nContent.GetIndex());
}
#endif
+ if ( (!rPaM.GetPoint()->nNode.GetNode().IsTextNode()
+ // huh, SwXTextRange puts one on table node?
+ && !rPaM.GetPoint()->nNode.GetNode().IsTableNode())
+ || (!rPaM.GetMark()->nNode.GetNode().IsTextNode()
+ && !rPaM.GetMark()->nNode.GetNode().IsTableNode()))
+ {
+ SAL_WARN("sw.core", "MarkManager::makeMark(..)"
+ " - refusing to create mark on non-textnode");
+ return nullptr;
+ }
// There should only be one CrossRefBookmark per Textnode per Type
if ((eType == MarkType::CROSSREF_NUMITEM_BOOKMARK || eType == MarkType::CROSSREF_HEADING_BOOKMARK)
&& (lcl_FindMarkAtPos(m_vBookmarks, *rPaM.Start(), eType) != m_vBookmarks.end()))
@@ -809,6 +819,8 @@ namespace sw::mark
if (!pMarkBase)
return;
+ pMarkBase->InvalidateFrames();
+
pMarkBase->SetMarkPos(*(rPaM.GetPoint()));
if(rPaM.HasMark())
pMarkBase->SetOtherMarkPos(*(rPaM.GetMark()));
@@ -818,6 +830,8 @@ namespace sw::mark
if(pMarkBase->GetMarkPos() != pMarkBase->GetMarkStart())
pMarkBase->Swap();
+ pMarkBase->InvalidateFrames();
+
sortMarks();
}
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 3960ca4b3d8b..fe5bff942568 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -90,6 +90,8 @@ namespace sw {
virtual void ClearOtherMarkPos()
{ m_pPos2.reset(); }
+ virtual auto InvalidateFrames() -> void;
+
virtual OUString ToString( ) const override;
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
@@ -170,6 +172,8 @@ namespace sw {
virtual void DeregisterFromDoc(SwDoc* const io_pDoc) override;
+ virtual auto InvalidateFrames() -> void override;
+
virtual const OUString& GetShortName() const override
{ return m_sShortName; }
virtual const vcl::KeyCode& GetKeyCode() const override
@@ -182,10 +186,8 @@ namespace sw {
{ return m_bHidden; }
virtual const OUString& GetHideCondition() const override
{ return m_sHideCondition; }
- virtual void Hide(bool rHide) override
- { m_bHidden = rHide; }
- virtual void SetHideCondition(const OUString& rHideCondition) override
- { m_sHideCondition = rHideCondition; }
+ virtual void Hide(bool rHide) override;
+ virtual void SetHideCondition(const OUString& rHideCondition) override;
// ::sfx2::Metadatable
virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;