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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon Oct 10 03:53:55 PDT 2011


 sw/source/ui/docvw/PageBreakWin.cxx |  121 ++++++++++++++++++++++++++++--------
 sw/source/ui/inc/PageBreakWin.hxx   |    3 
 2 files changed, 100 insertions(+), 24 deletions(-)

New commits:
commit 4c03a2497c97568c244cd14767e840d200fbc440
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Mon Oct 10 12:50:02 2011 +0200

    Page Break: Fix page break deletion when changing page style

diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 8a185d6..31fe8a3 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -34,6 +34,7 @@
 #include <DashedLine.hxx>
 #include <doc.hxx>
 #include <edtwin.hxx>
+#include <fmtpdsc.hxx>
 #include <IDocumentUndoRedo.hxx>
 #include <PageBreakWin.hxx>
 #include <pagefrm.hxx>
@@ -308,13 +309,21 @@ void SwPageBreakWin::Select( )
                 if ( pBodyFrm )
                 {
                     SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
-                    sal_uInt16 nWhich = pCnt->GetAttrSet()->GetPool()->GetWhich( SID_ATTR_PARA_PAGEBREAK );
+                    //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 );
+
+                    SfxItemSet aSet( GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
+                            RES_PAGEDESC, RES_PAGEDESC,
+                            RES_BREAK, RES_BREAK,
+                            NULL );
+                    aSet.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
+                    aSet.Put( SwFmtPageDesc( NULL ) );
+
                     SwPaM aPaM( *pNd );
-                    pNd->GetDoc()->InsertPoolItem( aPaM, aNoBreakItem, nsSetAttrMode::SETATTR_DEFAULT );
+                    pNd->GetDoc()->InsertItemSet( aPaM, aSet, nsSetAttrMode::SETATTR_DEFAULT );
+
                     pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
                 }
             }
commit 61ae8caa020c76f3095ec91801c460a018872fae
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Mon Oct 10 10:50:01 2011 +0200

    Page Break: show the button on the right for book mode view

diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 2caa8cc..8a185d6 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -44,6 +44,7 @@
 #include <wrtsh.hxx>
 
 #include <basegfx/color/bcolortools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/range/b2drectangle.hxx>
@@ -65,7 +66,7 @@ using namespace drawinglayer::primitive2d;
 
 namespace
 {
-    B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds )
+    B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bShowOnRight )
     {
         B2DPolygon aRetval;
         const double nRadius = 1;
@@ -140,6 +141,14 @@ namespace
         }
 
         aRetval.setClosed( true );
+
+        if ( bShowOnRight )
+        {
+            B2DHomMatrix bRotMatrix = createRotateAroundPoint(
+                    aBounds.getCenterX(), aBounds.getCenterY(), M_PI );
+            aRetval.transform( bRotMatrix );
+        }
+
         return aRetval;
     }
 }
@@ -190,10 +199,12 @@ void SwPageBreakWin::Paint( const Rectangle& )
         aOtherColor = rSettings.GetDialogColor( ).getBColor();
     }
 
+    bool bShowOnRight = ShowOnRight( );
+
     Primitive2DSequence aSeq( 2 );
     B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
            double( aRect.Right() ), double( aRect.Bottom( ) ) );
-    B2DPolygon aPolygon = lcl_CreatePolygon( aBRect );
+    B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bShowOnRight );
 
     // Create the polygon primitives
     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
@@ -213,7 +224,9 @@ void SwPageBreakWin::Paint( const Rectangle& )
         double nTop = double( aRect.getHeight() ) / 2.0;
         double nBottom = nTop + 4.0;
         double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
-        double nRight = aRect.getWidth( ) - ARROW_WIDTH + 2.0;
+        if ( bShowOnRight )
+            nLeft = ARROW_WIDTH - 2.0;
+        double nRight = nLeft + 8.0;
 
         B2DPolygon aTriangle;
         aTriangle.append( B2DPoint( nLeft, nTop ) );
@@ -234,7 +247,10 @@ void SwPageBreakWin::Paint( const Rectangle& )
 
     // Paint the picture
     Image aImg( SW_RES( IMG_PAGE_BREAK ) );
-    DrawImage( Point( 3, 1 ), aImg );
+    long nImgOfstX = 3;
+    if ( bShowOnRight )
+        nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3;
+    DrawImage( Point( nImgOfstX, 1 ), aImg );
 }
 
 void SwPageBreakWin::Select( )
@@ -306,33 +322,81 @@ void SwPageBreakWin::Select( )
     }
 }
 
-void SwPageBreakWin::UpdatePosition( )
+bool SwPageBreakWin::ShowOnRight( )
 {
-    const SwPageFrm* pPrevPage = static_cast< const SwPageFrm* >( GetPageFrame()->GetPrev() );
-    Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
-    Rectangle aBoundRect = GetEditWin()->LogicToPixel( GetPageFrame()->GetBoundRect().SVRect() );
-    Rectangle aFrmRect = GetEditWin()->LogicToPixel( GetPageFrame()->Frm().SVRect() );
+    bool bOnRight = false;
 
-    long nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2;
-    if ( aFrmRect.Top() == aPrevFrmRect.Top() )
-        nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2;
+    // Handle the book mode / columns view case
+    const SwViewOption* pViewOpt = GetEditWin()->GetView().GetWrtShell().GetViewOptions();
+    bool bBookMode = pViewOpt->IsViewLayoutBookMode();
 
-    Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() );
+    if ( bBookMode )
+        bOnRight = GetPageFrame()->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT;
 
-    Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT );
-    long nLeft = std::max( aFrmRect.Left() - aBtnSize.Width(), aVisArea.Left() );
-    Point aBtnPos( nLeft + ARROW_WIDTH / 2,
-            nYLineOffset - aBtnSize.Height() / 2 );
+    // TODO Handle the RTL case
 
-    SetPosSizePixel( aBtnPos, aBtnSize );
+    return bOnRight;
+}
+
+void SwPageBreakWin::UpdatePosition( )
+{
+    const SwPageFrm* pPageFrm = GetPageFrame();
+    const SwFrm* pPrevPage = pPageFrm->GetPrev();
+    while ( pPrevPage && ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) ) )
+        pPrevPage = pPrevPage->GetPrev();
+
+    Rectangle aBoundRect = GetEditWin()->LogicToPixel( pPageFrm->GetBoundRect().SVRect() );
+    Rectangle aFrmRect = GetEditWin()->LogicToPixel( pPageFrm->Frm().SVRect() );
+
+    long nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2;
+    if ( pPrevPage )
+    {
+        Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
+        nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2;
+    }
+
+    // Get the page + sidebar coords
+    long nPgLeft = aFrmRect.Left();
+    long nPgRight = aFrmRect.Right();
 
-    // Update the line position
-    Point aLinePos( nLeft + ARROW_WIDTH / 2, nYLineOffset );
     unsigned long nSidebarWidth = 0;
     const SwPostItMgr* pPostItMngr = GetEditWin()->GetView().GetWrtShell().GetPostItMgr();
     if ( pPostItMngr && pPostItMngr->HasNotes() && pPostItMngr->ShowNotes() )
         nSidebarWidth = pPostItMngr->GetSidebarBorderWidth( true ) + pPostItMngr->GetSidebarWidth( true );
-    Size aLineSize( aFrmRect.Right() + nSidebarWidth - nLeft, 1 );
+
+    if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_LEFT )
+        nPgLeft -= nSidebarWidth;
+    else if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT )
+        nPgRight += nSidebarWidth;
+
+    Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT );
+
+    // Place the button on the left or right?
+    Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() );
+
+    long nLineLeft = nPgLeft;
+    long nLineRight = nPgRight;
+    long nBtnLeft = nPgLeft;
+
+    if ( ShowOnRight( ) )
+    {
+        long nRight = std::min( nPgRight + aBtnSize.getWidth() - ARROW_WIDTH / 2, aVisArea.Right() );
+        nBtnLeft = nRight - aBtnSize.getWidth();
+        nLineRight = nBtnLeft - ARROW_WIDTH / 2;
+    }
+    else
+    {
+        nBtnLeft = std::max( nPgLeft - aBtnSize.Width() + ARROW_WIDTH / 2, aVisArea.Left() );
+        nLineLeft = nBtnLeft + aBtnSize.Width( ) + ARROW_WIDTH / 2;
+    }
+
+    // Set the button position
+    Point aBtnPos( nBtnLeft, nYLineOffset - aBtnSize.Height() / 2 );
+    SetPosSizePixel( aBtnPos, aBtnSize );
+
+    // Set the line position
+    Point aLinePos( nLineLeft, nYLineOffset );
+    Size aLineSize( nLineRight - nLineLeft, 1 );
     m_pLine->SetPosSizePixel( aLinePos, aLineSize );
 }
 
diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx
index 117dc9c..a595ed6 100644
--- a/sw/source/ui/inc/PageBreakWin.hxx
+++ b/sw/source/ui/inc/PageBreakWin.hxx
@@ -58,6 +58,9 @@ public:
     const SwPageFrm* GetPageFrame( );
 
     void SetReadonly( bool bReadonly );
+
+private:
+    bool ShowOnRight();
 };
 
 #endif


More information about the Libreoffice-commits mailing list