summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-06-15 13:11:29 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-06-15 15:58:59 +0200
commit2d89b9929e85bede4c72684a12e7508751875f0e (patch)
treefcfa0397afabff393ed3c4c09fd4c5119c289cbe /sw/source
parent786d0b9abf76b2f84d333e18c902a374ab3b3090 (diff)
tdf#133957 sw: SelectAll should select fly in empty section
Ctrl+A should select everything in the section; if the section is empty, there's no text to select, and then the shell will cancel the selection because SwCursorShell::HasSelection() returns false - so check if there are flys anchored there, which fixes the Copy. To fix Delete, a few more checks for empty selection need to be changed. Change-Id: If54160bdca976ad5f153b89cf8492f4da1e774b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96324 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/crsrsh.cxx6
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx5
-rw-r--r--sw/source/core/edit/eddel.cxx7
-rw-r--r--sw/source/core/undo/undel.cxx23
-rw-r--r--sw/source/core/undo/undobj.cxx29
5 files changed, 46 insertions, 24 deletions
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 9407dd9d6629..042097a7e507 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -71,6 +71,7 @@
#include <vcl/uitest/eventdescription.hxx>
#include <tabcol.hxx>
#include <wrtsh.hxx>
+#include <undobj.hxx>
#include <boost/property_tree/json_parser.hpp>
using namespace com::sun::star;
@@ -2501,7 +2502,10 @@ void SwCursorShell::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
bool SwCursorShell::HasSelection() const
{
const SwPaM* pCursor = getShellCursor( true );
- return IsTableMode() || ( pCursor->HasMark() && *pCursor->GetPoint() != *pCursor->GetMark() );
+ return IsTableMode()
+ || (pCursor->HasMark() &&
+ (*pCursor->GetPoint() != *pCursor->GetMark()
+ || IsFlySelectedByCursor(*GetDoc(), *pCursor->Start(), *pCursor->End())));
}
void SwCursorShell::CallChgLnk()
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 12350ceb49d9..ebb7c988f04a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4062,8 +4062,11 @@ bool DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam)
{
SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
- if( !rPam.HasMark() || *pStt >= *pEnd )
+ if (!rPam.HasMark()
+ || (*pStt == *pEnd && !IsFlySelectedByCursor(m_rDoc, *pStt, *pEnd)))
+ {
return false;
+ }
if( m_rDoc.GetAutoCorrExceptWord() )
{
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index af9a8e4d5674..b32f72c5fa6d 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -24,6 +24,7 @@
#include <editsh.hxx>
#include <pam.hxx>
#include <swundo.hxx>
+#include <undobj.hxx>
#include <SwRewriter.hxx>
#include <osl/diagnose.h>
@@ -34,8 +35,12 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
{
bool bSelectAll = StartsWithTable() && ExtendedSelectedAll();
// only for selections
- if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark())
+ if (!rPam.HasMark()
+ || (*rPam.GetPoint() == *rPam.GetMark()
+ && !IsFlySelectedByCursor(*GetDoc(), *rPam.Start(), *rPam.End())))
+ {
return;
+ }
// Is the selection in a table? Then delete only the content of the selected boxes.
// Here, there are two cases:
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index ba625d577f57..f285e8852f5b 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -561,28 +561,9 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam )
// tdf#132725 - if at-char/at-para flys would be deleted, don't group!
// DelContentIndex() would be called at the wrong time here, the indexes
// in the stored SwHistoryTextFlyCnt would be wrong when Undo is invoked
- for (SwFrameFormat const*const pFly : *pDoc->GetSpzFrameFormats())
+ if (IsFlySelectedByCursor(*pDoc, *pStt, *pEnd))
{
- SwFormatAnchor const& rAnchor(pFly->GetAnchor());
- switch (rAnchor.GetAnchorId())
- {
- case RndStdIds::FLY_AT_CHAR:
- case RndStdIds::FLY_AT_PARA:
- {
- SwPosition const*const pAnchorPos(rAnchor.GetContentAnchor());
- // can this really be null?
- if (pAnchorPos != nullptr
- && ((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
- ? IsDestroyFrameAnchoredAtChar(*pAnchorPos, *pStt, *pEnd)
- : IsSelectFrameAnchoredAtPara(*pAnchorPos, *pStt, *pEnd)))
- {
- return false;
- }
- }
- break;
- default: // other types not relevant
- break;
- }
+ return false;
}
{
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 2b081f723368..aca9012898c9 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1645,4 +1645,33 @@ bool IsSelectFrameAnchoredAtPara(SwPosition const & rAnchorPos,
|| (IsAtEndOfSection(rAnchorPos) && IsAtStartOfSection2(rStart)))));
}
+bool IsFlySelectedByCursor(SwDoc const & rDoc,
+ SwPosition const & rStart, SwPosition const & rEnd)
+{
+ for (SwFrameFormat const*const pFly : *rDoc.GetSpzFrameFormats())
+ {
+ SwFormatAnchor const& rAnchor(pFly->GetAnchor());
+ switch (rAnchor.GetAnchorId())
+ {
+ case RndStdIds::FLY_AT_CHAR:
+ case RndStdIds::FLY_AT_PARA:
+ {
+ SwPosition const*const pAnchorPos(rAnchor.GetContentAnchor());
+ // can this really be null?
+ if (pAnchorPos != nullptr
+ && ((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
+ ? IsDestroyFrameAnchoredAtChar(*pAnchorPos, rStart, rEnd)
+ : IsSelectFrameAnchoredAtPara(*pAnchorPos, rStart, rEnd)))
+ {
+ return true;
+ }
+ }
+ break;
+ default: // other types not relevant
+ break;
+ }
+ }
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */