summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-10 16:37:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-10 18:39:25 +0100
commite08b446e46f56e15af58fdd4396afba1a316f9e5 (patch)
treea40a5f76c9ba331e3e0002669a8a850af3e88af6 /sw
parent951d9fe0b5470085ae817c3af04014e6dd95b498 (diff)
tdf#140257 duplicate entire PaM ring when making copy
tdf#134439, tdf#135636 are the motivation behind copying the PaM, but multiselections require multiple PaMs Change-Id: I9f95eb6c62ac0e61053298d4e4dbe386f5686275 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110717 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/inc/basesh.hxx8
-rw-r--r--sw/source/uibase/shells/basesh.cxx12
-rw-r--r--sw/source/uibase/shells/tabsh.cxx6
-rw-r--r--sw/source/uibase/shells/textsh1.cxx6
4 files changed, 25 insertions, 7 deletions
diff --git a/sw/source/uibase/inc/basesh.hxx b/sw/source/uibase/inc/basesh.hxx
index b4426137fe9d..6e924a62cde1 100644
--- a/sw/source/uibase/inc/basesh.hxx
+++ b/sw/source/uibase/inc/basesh.hxx
@@ -24,10 +24,12 @@
#include <tools/link.hxx>
#include <sfx2/module.hxx>
#include <sfx2/shell.hxx>
-
#include <mdiexp.hxx>
+#include <memory>
#include <set>
+#include <vector>
+class SwPaM;
class SwWrtShell;
class SwView;
class SfxItemSet;
@@ -110,6 +112,10 @@ public:
static void SetFrameMode( FlyMode eMode, SwWrtShell *pShell ); // with update!
static void SetFrameMode_( FlyMode eMode ) { eFrameMode = eMode; }
static FlyMode GetFrameMode() { return eFrameMode; }
+
+ // duplicate rOrig and rOrig's multi-selection Ring so the first element of the returned
+ // vector can be used equivalently to rOrig to affect the same selections
+ static std::shared_ptr<std::vector<std::unique_ptr<SwPaM>>> CopyPaMRing(SwPaM& rOrig);
};
#endif
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 71f93a40d421..ac2c245a3d61 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -3052,4 +3052,16 @@ void SwBaseShell::ExecField( SfxRequest const & rReq )
}
}
+std::shared_ptr<std::vector<std::unique_ptr<SwPaM>>> SwBaseShell::CopyPaMRing(SwPaM& rOrig)
+{
+ auto vCursors = std::make_shared<std::vector<std::unique_ptr<SwPaM>>>();
+ vCursors->emplace_back(std::make_unique<SwPaM>(rOrig, nullptr));
+ for (auto& rCursor : rOrig.GetRingContainer())
+ {
+ if (&rCursor != &rOrig)
+ vCursors->emplace_back(std::make_unique<SwPaM>(rCursor, vCursors->front().get()));
+ }
+ return vCursors;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 247d5b4955d6..34d98f61edd9 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -596,11 +596,11 @@ void SwTableShell::Execute(SfxRequest &rReq)
auto pRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
- auto xPaM(std::make_shared<SwPaM>(*rSh.GetCursor(), nullptr)); // tdf#135636 make a copy to use at later apply
- pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, xPaM](sal_Int32 nResult){
+ auto vCursors = CopyPaMRing(*rSh.GetCursor()); // tdf#135636 make a copy to use at later apply
+ pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, vCursors](sal_Int32 nResult){
if (RET_OK == nResult)
{
- rSh.SetSelection(*xPaM); // tdf#135636 set the table selected at dialog launch as current selection
+ rSh.SetSelection(*vCursors->front()); // tdf#135636 set the table selected at dialog launch as current selection
const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 1aae087262d0..a65d7ccebf42 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1072,8 +1072,8 @@ void SwTextShell::Execute(SfxRequest &rReq)
auto pRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
- auto xPaM(std::make_shared<SwPaM>(*pPaM, nullptr)); // tdf#134439 make a copy to use at later apply
- pDlg->StartExecuteAsync([pDlg, &rWrtSh, pRequest, nDefDist, xPaM](sal_Int32 nResult){
+ auto vCursors = CopyPaMRing(*pPaM); // tdf#134439 make a copy to use at later apply
+ pDlg->StartExecuteAsync([pDlg, &rWrtSh, pRequest, nDefDist, vCursors](sal_Int32 nResult){
if (nResult == RET_OK)
{
// Apply defaults if necessary.
@@ -1103,7 +1103,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
}
- sw_ParagraphDialogResult(pSet, rWrtSh, *pRequest, xPaM.get());
+ sw_ParagraphDialogResult(pSet, rWrtSh, *pRequest, vCursors->front().get());
}
pDlg->disposeOnce();
});