sw: fix the LOK text selection callback for multi-selections
Fails with commit 53d2155bce08506c8d4f3faa052cee5ff1f689cf (Writer: Fix empty selection callback., 2026-03-04) reverted. Change-Id: Id966eff07b5461ab1f681349f1ed2d33129d8153 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201891 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -15,11 +15,14 @@
|
||||
#include <com/sun/star/text/XTextRange.hpp>
|
||||
#include <com/sun/star/text/XTextDocument.hpp>
|
||||
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
#include <comphelper/lok.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <sal/types.h>
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <editeng/fontitem.hxx>
|
||||
#include <editeng/lrspitem.hxx>
|
||||
#include <sfx2/lokhelper.hxx>
|
||||
|
||||
#include <swmodeltestbase.hxx>
|
||||
#include <doc.hxx>
|
||||
@@ -27,6 +30,7 @@
|
||||
#include <formatlinebreak.hxx>
|
||||
#include <ndtxt.hxx>
|
||||
#include <textcontentcontrol.hxx>
|
||||
#include <unotxdoc.hxx>
|
||||
#include <fmtanchr.hxx>
|
||||
#include <view.hxx>
|
||||
#include <itabenum.hxx>
|
||||
@@ -656,6 +660,38 @@ CPPUNIT_TEST_FIXTURE(Test, testCutFontworkObject)
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testMultiSelectionTextSelectionCallback)
|
||||
{
|
||||
// Given a document with "ABC" and LOK active:
|
||||
comphelper::LibreOfficeKit::setActive(true);
|
||||
createSwDoc();
|
||||
SwXTextDocument* pTextDocument = getSwTextDoc();
|
||||
pTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
|
||||
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
|
||||
int nViewId = SfxLokHelper::getView(*pWrtShell->GetSfxViewShell());
|
||||
pWrtShell->Insert(u"ABC"_ustr);
|
||||
pWrtShell->SttEndDoc(/*bStt=*/true);
|
||||
|
||||
// When having a multi-selection: "A" is selected and also the cursor is after "B":
|
||||
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false);
|
||||
// Move past "B" without selecting (ctrl+click equivalent):
|
||||
pWrtShell->EnterAddMode();
|
||||
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
|
||||
|
||||
// Then the LOK text selection payload should not be empty:
|
||||
std::optional<OString> aPayload
|
||||
= pWrtShell->getLOKPayload(LOK_CALLBACK_TEXT_SELECTION, nViewId);
|
||||
CPPUNIT_ASSERT(aPayload.has_value());
|
||||
// Without the fix in place, this test would have failed, only the non-range "after B" selection
|
||||
// was part of the payload.
|
||||
CPPUNIT_ASSERT(!aPayload->isEmpty());
|
||||
|
||||
// Tear down LOK:
|
||||
mxComponent->dispose();
|
||||
mxComponent.clear();
|
||||
comphelper::LibreOfficeKit::setActive(false);
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
void ToggleExtMode();
|
||||
bool IsExtMode() const { return m_bExtMode; }
|
||||
|
||||
void EnterAddMode();
|
||||
SW_DLLPUBLIC void EnterAddMode();
|
||||
void LeaveAddMode();
|
||||
void ToggleAddMode();
|
||||
bool IsAddMode() const { return m_bAddMode; }
|
||||
@@ -537,7 +537,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
|
||||
void SetEnteringStdMode(bool bEnteringStdMode) { m_bEnteringStdMode = bEnteringStdMode; }
|
||||
bool IsEnteringStdMode() const { return m_bEnteringStdMode; }
|
||||
|
||||
std::optional<OString> getLOKPayload(int nType, int nViewId) const;
|
||||
SW_DLLPUBLIC std::optional<OString> getLOKPayload(int nType, int nViewId) const;
|
||||
|
||||
void SortChapters(const SwOutlineNodes::size_type nOutlineNodePos = SwOutlineNodes::npos);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user