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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Oct 5 07:52:25 PDT 2011


 sw/inc/swundo.hxx                   |    3 +-
 sw/source/core/undo/undo.hrc        |    3 +-
 sw/source/core/undo/undo.src        |    4 +++
 sw/source/ui/docvw/PageBreakWin.cxx |   41 +++++++++++++++++++++++++++++++++++-
 4 files changed, 48 insertions(+), 3 deletions(-)

New commits:
commit 9767483eea7800aadd18b4489069ad633ce7a79c
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Oct 4 15:35:41 2011 +0200

    Page Break: basic implementation of the popup menu actions
    
    Open the paragraph properties dialog on Text Flow tab when clicking on
    the Edit item. Remove the page break (and add it to the undo stack) when
    clicking on the Delete item.

diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 4a91cff..9e07154 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -177,7 +177,8 @@ enum SwUndoId
     UNDO_UI_INSERT_URLBTN,
     UNDO_UI_INSERT_URLTXT,
     UNDO_UI_DELETE_INVISIBLECNTNT,
-    UNDO_UI_REPLACE_STYLE
+    UNDO_UI_REPLACE_STYLE,
+    UNDO_UI_DELETE_PAGE_BREAK
 };
 
 
diff --git a/sw/source/core/undo/undo.hrc b/sw/source/core/undo/undo.hrc
index 8edccd3..eee3e3c 100644
--- a/sw/source/core/undo/undo.hrc
+++ b/sw/source/core/undo/undo.hrc
@@ -172,7 +172,8 @@
 #define STR_INSERT_URLTXT               (UI_UNDO_BEGIN + 11)
 #define STR_DELETE_INVISIBLECNTNT       (UI_UNDO_BEGIN + 12)
 #define STR_REPLACE_STYLE               (UI_UNDO_BEGIN + 13)
-#define UI_UNDO_END                     STR_REPLACE_STYLE
+#define STR_DELETE_PAGE_BREAK           (UI_UNDO_BEGIN + 14)
+#define UI_UNDO_END                     STR_DELETE_PAGE_BREAK
 
 #define UNDO_MORE_STRINGS_BEGIN         (UI_UNDO_END + 1)
 #define STR_OCCURRENCES_OF              (UNDO_MORE_STRINGS_BEGIN)
diff --git a/sw/source/core/undo/undo.src b/sw/source/core/undo/undo.src
index fefa5ef..d1222fe 100644
--- a/sw/source/core/undo/undo.src
+++ b/sw/source/core/undo/undo.src
@@ -189,6 +189,10 @@ String STR_REPLACE_STYLE
 {
     Text [ en-US ] = "Replace style: $1 $2 $3" ;
 };
+String STR_DELETE_PAGE_BREAK
+{
+    Text [ en-US ] = "Delete page break" ;
+};
 String STR_OUTLINE_LR
 {
     Text [ en-US ] = "Promote/demote outline" ;
diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index b9ca0a3..2b70887 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -25,13 +25,19 @@
  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
  * instead of those above.
  */
+#include <globals.hrc>
 #include <popup.hrc>
 #include <utlui.hrc>
 
+#include <cmdid.h>
+#include <cntfrm.hxx>
 #include <DashedLine.hxx>
+#include <doc.hxx>
 #include <edtwin.hxx>
+#include <IDocumentUndoRedo.hxx>
 #include <PageBreakWin.hxx>
 #include <pagefrm.hxx>
+#include <view.hxx>
 #include <viewopt.hxx>
 
 #include <basegfx/color/bcolortools.hxx>
@@ -40,6 +46,8 @@
 #include <basegfx/range/b2drectangle.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <editeng/brkitem.hxx>
+#include <sfx2/dispatch.hxx>
 #include <svx/sdr/contact/objectcontacttools.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/svapp.hxx>
@@ -232,7 +240,38 @@ void SwPageBreakWin::Paint( const Rectangle& )
 
 void SwPageBreakWin::Select( )
 {
-    // TODO Menu item selected...
+    switch( GetCurItemId( ) )
+    {
+        case FN_PAGEBREAK_EDIT:
+            {
+                // TODO Handle the break on a table case
+                SfxUInt16Item aItem( GetEditWin()->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), TP_PARA_EXT );
+                GetEditWin()->GetView().GetViewFrame()->GetDispatcher()->Execute(
+                        SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL );
+            }
+            break;
+        case FN_PAGEBREAK_DELETE:
+            {
+                const SwLayoutFrm* pBodyFrm = static_cast< const SwLayoutFrm* >( GetPageFrame()->Lower() );
+                while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+                    pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() );
+
+                if ( pBodyFrm )
+                {
+                    // TODO Handle the break before a table case
+                    SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+                    sal_uInt16 nWhich = pCnt->GetAttrSet()->GetPool()->GetWhich( SID_ATTR_PARA_PAGEBREAK );
+                    SwCntntNode* pNd = pCnt->GetNode();
+
+                    pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
+                    SvxFmtBreakItem aNoBreakItem( SVX_BREAK_NONE, nWhich );
+                    SwPaM aPaM( *pNd );
+                    pNd->GetDoc()->InsertPoolItem( aPaM, aNoBreakItem, nsSetAttrMode::SETATTR_DEFAULT );
+                    pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
+                }
+            }
+            break;
+    }
 }
 
 void SwPageBreakWin::UpdatePosition( )


More information about the Libreoffice-commits mailing list