summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-10 16:37:11 +0000
committerXisco Fauli <xiscofauli@libreoffice.org>2021-02-11 15:31:43 +0100
commit75d8743ba840307d409ad0df67347e3ae5e60425 (patch)
tree15f92bda1b8a9a641a3a2fe9f2f2256eb16b1015 /sw/source/uibase/shells
parent430ab72c2cf785cd99e3275d9b76349aa9d5352c (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/+/110681 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/source/uibase/shells')
-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
3 files changed, 18 insertions, 6 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index e0af002ba981..359dea043183 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -3039,4 +3039,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 b7d3d60f2d97..a41c9e9d3d9c 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1079,8 +1079,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.
@@ -1110,7 +1110,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();
});