summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-09-16 12:12:42 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-16 12:47:31 +0200
commit3b11e66ab89c201591d8be8f1ab1af1aba11a821 (patch)
tree9d0f0e4d085772fc6a99c359480a6db37b6a8db6
parentaf450651f759600d15027adf1eb58054a8364444 (diff)
fdo#37606 SwWrtShell::SelAll(): initial support for doc starting with table
SwWrtShell::SelAll() can now detect if the body text starts with a table, and if so, it explicitly selects the whole document, not just the first cell of the starting table. Also, SwCrsrShell::EndAction() now checks for this "select all and doc starts with table" situation, and if that's the case, it activates a special select all mode, so layout can act accordingly. Change-Id: I8d634fc76b656a7513f067d1ce70f1930bb62dd4
-rw-r--r--sw/inc/crsrsh.hxx4
-rw-r--r--sw/inc/viewsh.hxx2
-rw-r--r--sw/source/core/crsr/crsrsh.cxx30
-rw-r--r--sw/source/core/layout/trvlfrm.cxx5
-rw-r--r--sw/source/core/view/vnew.cxx2
-rw-r--r--sw/source/ui/wrtsh/select.cxx4
6 files changed, 46 insertions, 1 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index df120f9825c5..9166edce6a11 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -327,6 +327,10 @@ public:
// if ExtendedSelect() is called afterwards, the whole nodes array is selected
// only for usage in special cases allowed!
void ExtendedSelectAll();
+ /// If ExtendedSelectAll() was called and selection didn't change since then.
+ bool ExtendedSelectedAll();
+ /// If document body starts with a table.
+ bool StartsWithTable();
SwPaM* GetCrsr( sal_Bool bMakeTblCrsr = sal_True ) const;
inline SwCursor* GetSwCrsr( sal_Bool bMakeTblCrsr = sal_True ) const;
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 92c5f0e5bdcc..7fcd7d135ba0 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -193,6 +193,7 @@ protected:
sal_uInt16 mnStartAction; ///< != 0 if at least one ::com::sun::star::chaos::Action is active.
sal_uInt16 mnLockPaint; ///< != 0 if Paint is locked.
+ bool mbSelectAll; ///< Special select all mode: whole document selected, even if doc starts with table.
public:
TYPEINFO();
@@ -564,6 +565,7 @@ public:
bool IsHeaderFooterEdit() const { return mbHeaderFooterEdit; }
bool IsShowHeaderFooterSeparator( FrameControlType eControl ) { return (eControl == Header)? mbShowHeaderSeparator: mbShowFooterSeparator; }
virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) { if ( eControl == Header ) mbShowHeaderSeparator = bShow; else mbShowFooterSeparator = bShow; }
+ bool IsSelectAll() { return mbSelectAll; }
};
//---- class CurrShell manages global ShellPointer -------------------
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index f9aa315cc7e8..89698a99d762 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -57,6 +57,7 @@
#include <vcl/svapp.hxx>
#include <numrule.hxx>
#include <IGrammarContact.hxx>
+#include <comphelper/flagguard.hxx>
#include <globals.hrc>
#include <comcore.hrc>
@@ -226,6 +227,7 @@ void SwCrsrShell::StartAction()
void SwCrsrShell::EndAction( const sal_Bool bIdleEnd )
{
+ comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
sal_Bool bVis = m_bSVCrsrVis;
// Idle-formatting?
@@ -530,6 +532,32 @@ void SwCrsrShell::ExtendedSelectAll()
pPos->nContent.Assign( pCNd, pCNd ? pCNd->Len() : 0 );
}
+bool SwCrsrShell::ExtendedSelectedAll()
+{
+ SwNodes& rNodes = GetDoc()->GetNodes();
+ SwNodeIndex nNode = rNodes.GetEndOfPostIts();
+ SwCntntNode* pStart = rNodes.GoNext(&nNode);
+
+ nNode = rNodes.GetEndOfContent();
+ SwCntntNode* pEnd = rNodes.GoPrevious(&nNode);
+
+ if (!pStart || !pEnd)
+ return false;
+
+ SwPosition aStart(*pStart, 0);
+ SwPosition aEnd(*pEnd, pEnd->Len());
+ SwShellCrsr* pShellCrsr = getShellCrsr(false);
+ return aStart == *pShellCrsr->Start() && aEnd == *pShellCrsr->End();
+}
+
+bool SwCrsrShell::StartsWithTable()
+{
+ SwNodes& rNodes = GetDoc()->GetNodes();
+ SwNodeIndex nNode(rNodes.GetEndOfExtras());
+ SwCntntNode* pCntntNode = rNodes.GoNext(&nNode);
+ return pCntntNode->FindTableNode();
+}
+
sal_Bool SwCrsrShell::MovePage( SwWhichPage fnWhichPage, SwPosPage fnPosPage )
{
sal_Bool bRet = sal_False;
@@ -1306,7 +1334,7 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd )
mpDoc->IsIdxInTbl( pTstCrsr->GetPoint()->nNode ) &&
( m_pTblCrsr ||
pTstCrsr->GetNode( sal_True )->StartOfSectionNode() !=
- pTstCrsr->GetNode( sal_False )->StartOfSectionNode() ) )
+ pTstCrsr->GetNode( sal_False )->StartOfSectionNode() ) && !mbSelectAll)
{
SwShellCrsr* pITmpCrsr = getShellCrsr( true );
Point aTmpPt( pITmpCrsr->GetPtPos() );
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 2b5ca6ecc787..438b0018a2ba 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -2483,6 +2483,9 @@ void SwRootFrm::CalcFrmRects( SwShellCrsr &rCrsr, sal_Bool bIsTblMode )
bool const bBody = pStartFrm->IsInDocBody();
const SwTableBox* pCellBox = pStartFrm->GetUpper()->IsCellFrm() ?
((SwCellFrm*)pStartFrm->GetUpper())->GetTabBox() : 0;
+ if (pSh->IsSelectAll())
+ pCellBox = 0;
+
const SwCntntFrm *pCntnt = pStartFrm->GetNextCntntFrm();
SwRect aPrvRect;
@@ -2501,6 +2504,8 @@ void SwRootFrm::CalcFrmRects( SwShellCrsr &rCrsr, sal_Bool bIsTblMode )
// same cell frame (or its follow cell)
const SwTableBox* pTmpCellBox = pCntnt->GetUpper()->IsCellFrm() ?
((SwCellFrm*)pCntnt->GetUpper())->GetTabBox() : 0;
+ if (pSh->IsSelectAll())
+ pTmpCellBox = 0;
if ( bBody == pCntnt->IsInDocBody() &&
( !pCellBox || pCellBox == pTmpCellBox ) )
{
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index c6668d4aef50..19a589f2a16d 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -162,6 +162,7 @@ ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow,
mpDoc( &rDocument ),
mnStartAction( 0 ),
mnLockPaint( 0 ),
+ mbSelectAll(false),
mpPrePostOutDev(0), // #i72754#
maPrePostMapMode()
{
@@ -236,6 +237,7 @@ ViewShell::ViewShell( ViewShell& rShell, Window *pWindow,
mpDoc( rShell.GetDoc() ),
mnStartAction( 0 ),
mnLockPaint( 0 ),
+ mbSelectAll(false),
mpPrePostOutDev(0), // #i72754#
maPrePostMapMode()
{
diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx
index 370b4492f613..4ad3f6a6e6c8 100644
--- a/sw/source/ui/wrtsh/select.cxx
+++ b/sw/source/ui/wrtsh/select.cxx
@@ -159,6 +159,10 @@ long SwWrtShell::SelAll()
}
SttSelect();
GoEnd(sal_True, &bMoveTable);
+
+ if (StartsWithTable())
+ ExtendedSelectAll();
+
if( pStartPos )
{
pTmpCrsr = getShellCrsr( false );