summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-01-21 13:15:50 +0100
committerVasily Melenchuk <vasily.melenchuk@cib.de>2020-12-06 10:42:07 +0300
commit011f7c8a461ff6e0b3e83bf2c90b1d4502406df1 (patch)
tree6da629a7726d31b04176459a0a7bb48dcd28bec8 /sw
parent4c3f554b44d417bf5ba48d40a8925ef46cc6eaf1 (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(). Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87157 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit ef8427d12a63127a2eb867637699343d630545dd) Change-Id: I293e6da9042bea5992cb27091b9cff77e5c7961d
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/crsr/bookmrk.cxx26
-rw-r--r--sw/source/core/doc/docbm.cxx19
-rw-r--r--sw/source/core/inc/bookmrk.hxx4
3 files changed, 49 insertions, 0 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index a16713dc295d..1c4d4941463a 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -25,6 +25,7 @@
#include <doc.hxx>
#include <ndtxt.hxx>
#include <pam.hxx>
+#include <hints.hxx>
#include <swserv.hxx>
#include <sfx2/linkmgr.hxx>
#include <UndoBookmark.hxx>
@@ -238,6 +239,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 { namespace mark
@@ -337,6 +344,11 @@ namespace sw { namespace mark
}
// TODO: everything else uses MarkBase::GenerateNewName ?
+
+ auto MarkBase::InvalidateFrames() -> void
+ {
+ }
+
NavigatorReminder::NavigatorReminder(const SwPaM& rPaM)
: MarkBase(rPaM, "__NavigatorReminder__")
{ }
@@ -393,6 +405,7 @@ namespace sw { namespace mark
std::make_unique<SwUndoInsBookmark>(*this));
}
io_pDoc->getIDocumentState().SetModified();
+ InvalidateFrames();
}
void Bookmark::DeregisterFromDoc(SwDoc* const io_pDoc)
@@ -405,6 +418,17 @@ namespace sw { namespace 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());
+ }
}
::sfx2::IXmlIdRegistry& Bookmark::GetRegistry()
@@ -513,6 +537,8 @@ namespace sw { namespace 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 6e15efc78b24..30110bbb75b8 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -561,6 +561,21 @@ namespace sw { namespace mark
pPos2->nContent.GetIndex());
}
#endif
+ // see for example _SaveContentIdx, Shells
+ OSL_PRECOND(m_vAllMarks.size() < USHRT_MAX,
+ "MarkManager::makeMark(..)"
+ " - more than USHRT_MAX marks are not supported correctly");
+
+ 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 +824,8 @@ namespace sw { namespace mark
if (!pMarkBase)
return;
+ pMarkBase->InvalidateFrames();
+
pMarkBase->SetMarkPos(*(rPaM.GetPoint()));
if(rPaM.HasMark())
pMarkBase->SetOtherMarkPos(*(rPaM.GetMark()));
@@ -818,6 +835,8 @@ namespace sw { namespace 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..45be76199073 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