[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 16 03:49:11 PDT 2013


 sw/inc/crsrsh.hxx                 |    4 ++++
 sw/inc/viewsh.hxx                 |    2 ++
 sw/source/core/crsr/crsrsh.cxx    |   30 +++++++++++++++++++++++++++++-
 sw/source/core/layout/trvlfrm.cxx |    5 +++++
 sw/source/core/view/vnew.cxx      |    2 ++
 sw/source/ui/wrtsh/select.cxx     |    4 ++++
 6 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 3b11e66ab89c201591d8be8f1ab1af1aba11a821
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 16 12:12:42 2013 +0200

    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

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index df120f9..9166edc 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 92c5f0e..7fcd7d1 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 f9aa315..89698a9 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 2b5ca6e..438b001 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 c6668d4..19a589f 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 370b449..4ad3f6a 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 );


More information about the Libreoffice-commits mailing list