[Libreoffice-commits] core.git: sw/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 7 14:08:47 UTC 2021
sw/source/uibase/utlui/content.cxx | 61 +++++++++++++++++++------------------
1 file changed, 32 insertions(+), 29 deletions(-)
New commits:
commit 69c9237f0345c5b92792f6350771618f5c9cb8c2
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Wed Oct 6 19:19:40 2021 -0800
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Thu Oct 7 16:08:12 2021 +0200
SwNavigator: Fix crash on image select
Fixes crash that occurs in update tracking test for bookmark when image
is selected by testing that selection type is text before testing for
bookmark.
Change-Id: I53c64a71d3aff0f159bff31b98e2f453d7c2225a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123202
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj at gmail.com>
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index fb7aab99847d..5e89303edf3b 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3568,39 +3568,42 @@ void SwContentTree::UpdateTracking()
return;
}
// bookmarks - track first bookmark at cursor
- SwDoc* pDoc = m_pActiveShell->GetDoc();
- uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(pDoc->GetDocShell()->GetBaseModel(),
- uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xBookmarks(xBookmarksSupplier->getBookmarks(),
- uno::UNO_QUERY);
- sal_Int32 nBookmarkCount = xBookmarks->getCount();
- if (nBookmarkCount && !(m_bIsRoot && m_nRootType != ContentTypeId::BOOKMARK))
+ if (m_pActiveShell->GetSelectionType() & SelectionType::Text)
{
- SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
- uno::Reference<text::XTextRange> xRange(
- SwXTextRange::CreateXTextRange(*pDoc, *pCursor->GetPoint(), nullptr));
- for (sal_Int32 i = 0; i < nBookmarkCount; ++i)
+ SwDoc* pDoc = m_pActiveShell->GetDoc();
+ uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(pDoc->GetDocShell()->GetBaseModel(),
+ uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xBookmarks(xBookmarksSupplier->getBookmarks(),
+ uno::UNO_QUERY);
+ sal_Int32 nBookmarkCount = xBookmarks->getCount();
+ if (nBookmarkCount && !(m_bIsRoot && m_nRootType != ContentTypeId::BOOKMARK))
{
- uno::Reference<text::XTextContent> bookmark;
- xBookmarks->getByIndex(i) >>= bookmark;
- try
- {
- uno::Reference<text::XTextRange> bookmarkRange = bookmark->getAnchor();
- uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xRange->getText(),
- uno::UNO_QUERY);
- if (xTextRangeCompare.is()
- && xTextRangeCompare->compareRegionStarts(bookmarkRange, xRange) != -1
- && xTextRangeCompare->compareRegionEnds(xRange, bookmarkRange) != -1)
+ SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+ uno::Reference<text::XTextRange> xRange(
+ SwXTextRange::CreateXTextRange(*pDoc, *pCursor->GetPoint(), nullptr));
+ for (sal_Int32 i = 0; i < nBookmarkCount; ++i)
+ {
+ uno::Reference<text::XTextContent> bookmark;
+ xBookmarks->getByIndex(i) >>= bookmark;
+ try
+ {
+ uno::Reference<text::XTextRange> bookmarkRange = bookmark->getAnchor();
+ uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xRange->getText(),
+ uno::UNO_QUERY);
+ if (xTextRangeCompare.is()
+ && xTextRangeCompare->compareRegionStarts(bookmarkRange, xRange) != -1
+ && xTextRangeCompare->compareRegionEnds(xRange, bookmarkRange) != -1)
+ {
+ uno::Reference<container::XNamed> xBookmark(bookmark, uno::UNO_QUERY);
+ lcl_SelectByContentTypeAndName(this, *m_xTreeView,
+ SwResId(STR_CONTENT_TYPE_BOOKMARK),
+ xBookmark->getName());
+ return;
+ }
+ }
+ catch (const lang::IllegalArgumentException&)
{
- uno::Reference<container::XNamed> xBookmark(bookmark, uno::UNO_QUERY);
- lcl_SelectByContentTypeAndName(this, *m_xTreeView,
- SwResId(STR_CONTENT_TYPE_BOOKMARK),
- xBookmark->getName());
- return;
}
- }
- catch (const lang::IllegalArgumentException&)
- {
}
}
}
More information about the Libreoffice-commits
mailing list