tdf#167833 sw: if an anchored object is pasted, don't select it
Instead, leave the cursor in the text at the paste location, like (reportedly) some version of Word does. This can be configured with the new Office::Writer::Cursor::Option::SelectPastedAnchoredObject Change-Id: Id1ddeb0e17c5cd568100d5a8169d929487d16749 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189001 Reviewed-by: Michael Stahl <michael.stahl@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -2175,6 +2175,13 @@
|
||||
</info>
|
||||
<value>false</value>
|
||||
</prop>
|
||||
<prop oor:name="SelectPastedAnchoredObject" oor:type="xs:boolean" oor:nillable="false">
|
||||
<info>
|
||||
<desc>Specifies if pasted anchored objects will be selected; otherwise, the text cursor will remain at the location of the paste.</desc>
|
||||
<label>Select pasted anchored objects</label>
|
||||
</info>
|
||||
<value>false</value>
|
||||
</prop>
|
||||
</group>
|
||||
</group>
|
||||
<group oor:name="FmtAidsAutocomplete">
|
||||
|
||||
@@ -65,6 +65,10 @@ $(eval $(call gb_CppunitTest_use_vcl,sw_unowriter))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_rdb,sw_unowriter,services))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_custom_headers,sw_unowriter,\
|
||||
officecfg/registry \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_configuration,sw_unowriter))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_uiconfigs,sw_unowriter, \
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
#include <com/sun/star/text/XTextTable.hpp>
|
||||
#include <com/sun/star/text/XPageCursor.hpp>
|
||||
|
||||
#include <officecfg/Office/Writer.hxx>
|
||||
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <comphelper/scopeguard.hxx>
|
||||
#include <tools/UnitConversion.hxx>
|
||||
#include <toolkit/helper/vclunohelper.hxx>
|
||||
#include <vcl/graphicfilter.hxx>
|
||||
@@ -971,6 +974,17 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testRenderablePagePosition)
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwUnoWriter, testPasteListener)
|
||||
{
|
||||
comphelper::ScopeGuard g([]() {
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
|
||||
comphelper::ConfigurationChanges::create());
|
||||
officecfg::Office::Writer::Cursor::Option::SelectPastedAnchoredObject::set(false, pBatch);
|
||||
return pBatch->commit();
|
||||
});
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
|
||||
comphelper::ConfigurationChanges::create());
|
||||
officecfg::Office::Writer::Cursor::Option::SelectPastedAnchoredObject::set(true, pBatch);
|
||||
pBatch->commit();
|
||||
|
||||
createSwDoc();
|
||||
|
||||
// Insert initial string.
|
||||
|
||||
@@ -116,7 +116,8 @@ class Test(UITestCase):
|
||||
self.assertTrue(to_char_enabled)
|
||||
|
||||
def test_floattable_in_shape_text(self):
|
||||
with self.ui_test.load_file(get_url_for_data_file("floattable-in-shape-text.docx")) as xComponent:
|
||||
with self.ui_test.set_config('/org.openoffice.Office.Writer/Cursor/Option/SelectPastedAnchoredObject', True):
|
||||
with self.ui_test.load_file(get_url_for_data_file("floattable-in-shape-text.docx")) as xComponent:
|
||||
# Given a table in a frame, anchored in shape text (TextBox case):
|
||||
self.xUITest.executeCommand(".uno:SelectAll")
|
||||
# Insert frame around the selected table:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <memory>
|
||||
#include <hintids.hxx>
|
||||
|
||||
#include <officecfg/Office/Writer.hxx>
|
||||
#include <vcl/graph.hxx>
|
||||
#include <sot/formats.hxx>
|
||||
#include <svx/xfillit0.hxx>
|
||||
@@ -801,7 +802,8 @@ namespace {
|
||||
return pNew;
|
||||
}
|
||||
|
||||
void lcl_SelectFlyFormat(SwFrameFormat *const pNew, SwFEShell& rSh)
|
||||
void lcl_InitSelectFlyOrDrawFormat(SwFrameFormat *const pNew,
|
||||
SwFEShell & rSh, bool const isSelect)
|
||||
{
|
||||
if(!pNew)
|
||||
return;
|
||||
@@ -810,21 +812,27 @@ namespace {
|
||||
case RES_FLYFRMFMT:
|
||||
{
|
||||
assert(dynamic_cast<SwFlyFrameFormat*>(pNew));
|
||||
const Point aPt(rSh.GetCursorDocPos());
|
||||
SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pNew)->GetFrame(&aPt);
|
||||
if(pFlyFrame)
|
||||
rSh.SelectFlyFrame(*pFlyFrame);
|
||||
if (isSelect)
|
||||
{
|
||||
const Point aPt(rSh.GetCursorDocPos());
|
||||
SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pNew)->GetFrame(&aPt);
|
||||
if (pFlyFrame)
|
||||
rSh.SelectFlyFrame(*pFlyFrame);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RES_DRAWFRMFMT:
|
||||
{
|
||||
auto& rDrawView = *rSh.Imp()->GetDrawView();
|
||||
assert(dynamic_cast<SwDrawFrameFormat*>(pNew));
|
||||
SwDrawFrameFormat* pDrawFormat = static_cast<SwDrawFrameFormat*>(pNew);
|
||||
// #i52780# - drawing object has to be made visible on paste.
|
||||
pDrawFormat->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::PREPPASTING));
|
||||
SdrObject* pObj = pDrawFormat->FindSdrObject();
|
||||
rDrawView.MarkObj(pObj, rDrawView.GetSdrPageView());
|
||||
if (isSelect)
|
||||
{
|
||||
auto& rDrawView = *rSh.Imp()->GetDrawView();
|
||||
SdrObject* pObj = pDrawFormat->FindSdrObject();
|
||||
rDrawView.MarkObj(pObj, rDrawView.GetSdrPageView());
|
||||
}
|
||||
// #i47455# - notify draw frame format
|
||||
// that position attributes are already set.
|
||||
pDrawFormat->PosAttrSet();
|
||||
@@ -1063,9 +1071,10 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
|
||||
lcl_PasteFlyOrDrawFormat(rPaM, pFlyFormat, *this));
|
||||
}
|
||||
}
|
||||
bool const isSelect{officecfg::Office::Writer::Cursor::Option::SelectPastedAnchoredObject::get()};
|
||||
for (auto const pFlyFormat : inserted)
|
||||
{
|
||||
lcl_SelectFlyFormat(pFlyFormat, *this);
|
||||
lcl_InitSelectFlyOrDrawFormat(pFlyFormat, *this, isSelect);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user