diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-01-03 08:10:47 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-01-03 09:18:51 +0100 |
commit | a586ce188086ff27b08b8a4de4672c07ddf8ed7c (patch) | |
tree | 799a9b4e8ecb58ab78b3ebbefeebdc1004da8a2d /sw | |
parent | 41452912e8ec11ecfead11588e7c70ad08903fd9 (diff) |
tdf#158532 sw: fix toolbar buttons remain disabled after pasting an image
Pasting an image and then quickly switching to text selection resulted
in e.g. the 'Insert Special Characters' toolbar button to remain
disabled, which is incorrect.
What happened is that the check in SwView::SelectShell() was poor, the
intent in commit 31cb5b5538b9fd91dafb067ce961f2540555ad2b (sw: fix
missing cache invalidation when switching between images, 2022-08-23)
was to handle the case when we switch between images, but it also
triggered for the case when we were switching from text to image.
Once the condition is fixed, an additional problem was that while
switching from text to image, m_nSelectionType is not yet updated, so
use IsSelFrameMode() instead, this way both the old and the new
use-cases work.
A testcase that covers this would look something like this:
createSwDoc();
SwDocShell* pDocShell = getSwDocShell();
SwView* pView = pDocShell->GetView();
pView->InsertGraphic(createFileURL(u"test.jpg"), OUString(), /*bAsLink=*/false,
&GraphicFilter::GetGraphicFilter());
dispatchCommand(mxComponent, ".uno:Escape", {});
std::unique_ptr<SfxPoolItem> pItem;
SfxItemState eState = pView->GetViewFrame().GetBindings().QueryState(SID_INSERT_DIAGRAM, pItem);
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState);
but for some reason that also passes without the fix, so probably this
change is hard to test from cppunit with reasonable amount of effort.
Change-Id: I16749455e093cecf17fa067d7ddf86cd007fd2d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161579
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index c7cf01d4d8df..ac1c15e95e26 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -284,12 +284,13 @@ void SwView::SelectShell() // Determine if a different fly frame was selected. bool bUpdateFly = false; const SwFrameFormat* pCurFlyFormat = nullptr; - if (m_nSelectionType & SelectionType::Ole || m_nSelectionType & SelectionType::Graphic) + if (m_pWrtShell->IsSelFrameMode()) { pCurFlyFormat = m_pWrtShell->GetFlyFrameFormat(); } - if (pCurFlyFormat && pCurFlyFormat != m_pLastFlyFormat) + if (pCurFlyFormat && m_pLastFlyFormat && pCurFlyFormat != m_pLastFlyFormat) { + // Only do an explicit update when switching between flys. bUpdateFly = true; } m_pLastFlyFormat = pCurFlyFormat; |