From cdb708291b59ac89b43c24154f0edc77f237eadd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 Aug 2016 15:37:10 +0100 Subject: Resolves: tdf#101359 getBookmarksCount includes more than aTableBookmarks aTableBookmarks is just "BOOKMARK"s while getBookmarksCount() includes two extra types. So cache the result of getBookmarksCount when filling aTableBookmarks to compare if the count from the time of filling aTableBookmarks is unchanged. Change-Id: I69fedab613f23e4e2b30498e4620a370d92272e0 --- sw/source/ui/misc/bookmark.cxx | 12 +++++++----- sw/source/uibase/inc/bookmark.hxx | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 56734dc38fab..5aeb4621c853 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -246,7 +246,7 @@ bool SwInsertBookmarkDlg::ValidateBookmarks() bool SwInsertBookmarkDlg::HaveBookmarksChanged() { IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); - if (pMarkAccess->getBookmarksCount() != static_cast(aTableBookmarks.size())) + if (pMarkAccess->getBookmarksCount() != m_nLastBookmarksCount) return true; IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); @@ -277,16 +277,18 @@ void SwInsertBookmarkDlg::PopulateTable() aTableBookmarks.push_back(std::make_pair(ppBookmark->get(), ppBookmark->get()->GetName())); } } + m_nLastBookmarksCount = pMarkAccess->getBookmarksCount(); } void SwInsertBookmarkDlg::Apply() { } -SwInsertBookmarkDlg::SwInsertBookmarkDlg(vcl::Window* pParent, SwWrtShell& rS, SfxRequest& rRequest) : - SvxStandardDialog(pParent, "InsertBookmarkDialog", "modules/swriter/ui/insertbookmark.ui"), - rSh(rS), - rReq(rRequest) +SwInsertBookmarkDlg::SwInsertBookmarkDlg(vcl::Window* pParent, SwWrtShell& rS, SfxRequest& rRequest) + : SvxStandardDialog(pParent, "InsertBookmarkDialog", "modules/swriter/ui/insertbookmark.ui") + , rSh(rS) + , rReq(rRequest) + , m_nLastBookmarksCount(0) { get(m_pBookmarksContainer, "bookmarks"); get(m_pEditBox, "name"); diff --git a/sw/source/uibase/inc/bookmark.hxx b/sw/source/uibase/inc/bookmark.hxx index 0754f6988bac..472cedb2bb64 100644 --- a/sw/source/uibase/inc/bookmark.hxx +++ b/sw/source/uibase/inc/bookmark.hxx @@ -61,6 +61,7 @@ class SwInsertBookmarkDlg: public SvxStandardDialog SwWrtShell& rSh; SfxRequest& rReq; std::vector> aTableBookmarks; + sal_Int32 m_nLastBookmarksCount; DECL_LINK_TYPED(ModifyHdl, Edit&, void); DECL_LINK_TYPED(InsertHdl, Button*, void); -- cgit