[Libreoffice-commits] .: 3 commits - sw/inc sw/source
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Fri Sep 9 12:34:47 PDT 2011
sw/inc/viewsh.hxx | 2
sw/source/core/layout/paintfrm.cxx | 127 +++++++++++++++++----------------
sw/source/ui/app/mn.src | 4 -
sw/source/ui/docvw/HeaderFooterWin.cxx | 31 +++++++-
sw/source/ui/docvw/docvw.hrc | 2
sw/source/ui/docvw/docvw.src | 10 ++
sw/source/ui/docvw/edtwin.cxx | 10 ++
sw/source/ui/inc/HeaderFooterWin.hxx | 2
sw/source/ui/inc/edtwin.hxx | 1
sw/source/ui/inc/wrtsh.hxx | 1
sw/source/ui/wrtsh/wrtsh1.cxx | 6 +
11 files changed, 130 insertions(+), 66 deletions(-)
New commits:
commit 7607e0db191db41e35f24755a4f684c3fc8f90e6
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date: Fri Sep 9 21:26:46 2011 +0200
Writer Page Breaks: don't print the marker, not for PDF export or printing
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 23c523e..e868cba 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3315,70 +3315,75 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
void SwPageFrm::PaintBreak( ) const
{
- const SwFrm* pBodyFrm = Lower();
- while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
- pBodyFrm = pBodyFrm->GetNext();
-
- if ( pBodyFrm )
+ if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
+ !pGlobalShell->GetViewOptions()->IsPDFExport() &&
+ !pGlobalShell->IsPreView() )
{
- const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt();
- if ( pCnt && pCnt->IsPageBreak( sal_True ))
+ const SwFrm* pBodyFrm = Lower();
+ while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+ pBodyFrm = pBodyFrm->GetNext();
+
+ if ( pBodyFrm )
{
- // Paint the break only if:
- // * Not in header footer edition, to avoid conflicts with the
- // header/footer marker
- // * Non-printing characters are shown, as this is more consistent
- // with other formatting marks
- if ( !pGlobalShell->IsHeaderFooterEdit() &&
- pGlobalShell->GetViewOptions()->IsShowHiddenChar( ) )
+ const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt();
+ if ( pCnt && pCnt->IsPageBreak( sal_True ))
{
- SwRect aRect( pCnt->Prt() );
- aRect.Pos() += pCnt->Frm().Pos();
-
- // Draw the line
- basegfx::B2DPolygon aLine;
- aLine.append( basegfx::B2DPoint( double( aRect.Left() ), double( aRect.Top() ) ) );
- aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
-
- basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
-
- drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
- new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
- aLine, aLineColor );
-
- drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
- aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
-
- // Add the text above
- rtl::OUString aBreakText = ResId::toString( SW_RES( STR_PAGE_BREAK ) );
-
- basegfx::B2DVector aFontSize;
- OutputDevice* pOut = pGlobalShell->GetOut();
- Font aFont = pOut->GetSettings().GetStyleSettings().GetToolFont();
- aFont.SetHeight( 8 * 20 );
- pOut->SetFont( aFont );
- drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
- aFontSize, aFont, false, false );
-
- Rectangle aTextRect;
- pOut->GetTextBoundRect( aTextRect, String( aBreakText ) );
- long nTextXOff = ( aRect.Width() - aTextRect.GetWidth() ) / 2;
-
- basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
- aFontSize.getX(), aFontSize.getY(),
- aRect.Left() + nTextXOff, aRect.Top() ) );
-
- drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
- new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
- aTextMatrix,
- aBreakText, 0, aBreakText.getLength(),
- std::vector< double >(),
- aFontAttr,
- lang::Locale(),
- aLineColor );
- aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
-
- ProcessPrimitives( aSeq );
+ // Paint the break only if:
+ // * Not in header footer edition, to avoid conflicts with the
+ // header/footer marker
+ // * Non-printing characters are shown, as this is more consistent
+ // with other formatting marks
+ if ( !pGlobalShell->IsHeaderFooterEdit() &&
+ pGlobalShell->GetViewOptions()->IsShowHiddenChar( ) )
+ {
+ SwRect aRect( pCnt->Prt() );
+ aRect.Pos() += pCnt->Frm().Pos();
+
+ // Draw the line
+ basegfx::B2DPolygon aLine;
+ aLine.append( basegfx::B2DPoint( double( aRect.Left() ), double( aRect.Top() ) ) );
+ aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
+
+ basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
+
+ drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+ aLine, aLineColor );
+
+ drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
+ aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+
+ // Add the text above
+ rtl::OUString aBreakText = ResId::toString( SW_RES( STR_PAGE_BREAK ) );
+
+ basegfx::B2DVector aFontSize;
+ OutputDevice* pOut = pGlobalShell->GetOut();
+ Font aFont = pOut->GetSettings().GetStyleSettings().GetToolFont();
+ aFont.SetHeight( 8 * 20 );
+ pOut->SetFont( aFont );
+ drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
+ aFontSize, aFont, false, false );
+
+ Rectangle aTextRect;
+ pOut->GetTextBoundRect( aTextRect, String( aBreakText ) );
+ long nTextXOff = ( aRect.Width() - aTextRect.GetWidth() ) / 2;
+
+ basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aFontSize.getX(), aFontSize.getY(),
+ aRect.Left() + nTextXOff, aRect.Top() ) );
+
+ drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
+ new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aTextMatrix,
+ aBreakText, 0, aBreakText.getLength(),
+ std::vector< double >(),
+ aFontAttr,
+ lang::Locale(),
+ aLineColor );
+ aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+
+ ProcessPrimitives( aSeq );
+ }
}
}
}
commit 7bdee3289aac2c2f96204d06f30dee80657bc21b
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date: Fri Sep 9 21:23:11 2011 +0200
Header/Footer: adjusted popup menu texts
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index e7a59f5..c63d6d0 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1442,13 +1442,13 @@ Menu MN_HEADERFOOTER_BUTTON
{
Identifier = FN_HEADERFOOTER_EDIT ;
HelpID = CMD_FN_HEADERFOOTER_EDIT ;
- Text [ en-US ] = "Edit" ;
+ Text [ en-US ] = "Format $1..." ;
};
MenuItem
{
Identifier = FN_HEADERFOOTER_DELETE ;
HelpID = CMD_FN_HEADERFOOTER_DELETE ;
- Text [ en-US ] = "Remove" ;
+ Text [ en-US ] = "Delete $1" ;
};
};
};
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 1a33706..2f9a99c 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -38,6 +38,7 @@
#include <fmthdft.hxx>
#include <HeaderFooterWin.hxx>
#include <pagefrm.hxx>
+#include <SwRewriter.hxx>
#include <view.hxx>
#include <viewopt.hxx>
#include <wrtsh.hxx>
@@ -293,7 +294,20 @@ SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
{
// Create and set the PopupMenu
m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
- // TODO Potentially rewrite the menu entries' text
+
+ // Rewrite the menu entries' text
+ String sType = SW_RESSTR( STR_FOOTER );
+ if ( m_pWindow->IsHeader() )
+ sType = SW_RESSTR( STR_HEADER );
+ SwRewriter aRewriter;
+ aRewriter.AddRule( String::CreateFromAscii( "$1" ), sType );
+
+ String aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_EDIT );
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, aRewriter.Apply( aText ) );
+
+ aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_DELETE );
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, aRewriter.Apply( aText ) );
+
SetPopupMenu( m_pPopupMenu );
}
diff --git a/sw/source/ui/docvw/docvw.hrc b/sw/source/ui/docvw/docvw.hrc
index 136bbc1..7e318ab 100644
--- a/sw/source/ui/docvw/docvw.hrc
+++ b/sw/source/ui/docvw/docvw.hrc
@@ -83,6 +83,8 @@
#define STR_HEADER_TITLE (RC_DOCVW_BEGIN + 22)
#define STR_FOOTER_TITLE (RC_DOCVW_BEGIN + 23)
+#define STR_HEADER (RC_DOCVW_BEGIN + 24)
+#define STR_FOOTER (RC_DOCVW_BEGIN + 25)
#define MSG_READONLY_CONTENT (RC_DOCVW_BEGIN + 1)
diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src
index ec01a8f..a843c08 100644
--- a/sw/source/ui/docvw/docvw.src
+++ b/sw/source/ui/docvw/docvw.src
@@ -301,3 +301,13 @@ String STR_FOOTER_TITLE
Text [ en-US ] = "Footer (%1)" ;
};
+String STR_HEADER
+{
+ Text [ en-US ] = "Header" ;
+};
+
+String STR_FOOTER
+{
+ Text [ en-US ] = "Footer" ;
+};
+
commit 16400db4629133ad59ce8cbc8746a63b33202fd3
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date: Fri Sep 9 09:13:10 2011 +0200
Header/Footer: don't show the separator action in readonly mode
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 472739e..3f95de7 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -423,7 +423,7 @@ public:
inline const SwViewOption *GetViewOptions() const { return pOpt; }
virtual void ApplyViewOptions( const SwViewOption &rOpt );
void SetUIOptions( const SwViewOption &rOpt );
- void SetReadonlyOption(sal_Bool bSet); // Set readonly-bit of ViewOptions.
+ virtual void SetReadonlyOption(sal_Bool bSet); // Set readonly-bit of ViewOptions.
void SetPDFExportOption(sal_Bool bSet); // Set/reset PDF export mode.
void SetPrtFormatOption(sal_Bool bSet); // Set PrtFormat-Bit of ViewOptions.
void SetReadonlySelectionOption(sal_Bool bSet); // Change the selection mode in readonly docs.
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index e926d54..1a33706 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -150,9 +150,13 @@ SwHeaderFooterWin::~SwHeaderFooterWin( )
MenuButton* SwHeaderFooterWin::GetMenuButton()
{
if ( !m_pButton )
+ {
m_pButton = new SwHeaderFooterButton( this );
- m_pButton->Show();
+ // Don't blindly show it: check for readonly document
+ const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
+ m_pButton->Show( !pViewOpt->IsReadonly() );
+ }
return m_pButton;
}
@@ -274,6 +278,15 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
}
}
+void SwHeaderFooterWin::SetReadonly( bool bReadonly )
+{
+ if ( bReadonly )
+ m_pButton->Hide();
+ else
+ m_pButton->Show();
+ Update();
+}
+
SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
MenuButton( pWindow ),
m_pWindow( pWindow )
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 6b800f8..034b063 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5736,4 +5736,14 @@ void SwEditWin::HideHeaderFooterControls( )
}
}
+void SwEditWin::SetReadonlyHeaderFooterControls( bool bReadonly )
+{
+ std::vector< boost::shared_ptr< SwHeaderFooterWin > >::iterator pIt = aHeadFootControls.begin();
+ while ( pIt != aHeadFootControls.end() )
+ {
+ ( *pIt )->SetReadonly( bReadonly );
+ pIt++;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index c3c21d5..e7d4d65 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -63,6 +63,8 @@ public:
void ChangeHeaderOrFooter( bool bAdd );
void ExecuteCommand(sal_uInt16 nSlot);
+ void SetReadonly( bool bReadonly );
+
private:
MenuButton* GetMenuButton( );
};
diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx
index 142514c..6468f51 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -315,6 +315,7 @@ public:
void SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset );
void RemoveHeaderFooterControls( const SwPageFrm* pPageFrm );
void HideHeaderFooterControls( );
+ void SetReadonlyHeaderFooterControls( bool bReadonly );
SwEditWin(Window *pParent, SwView &);
virtual ~SwEditWin();
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index ef7337d..e98afbd 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -450,6 +450,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
virtual void NewCoreSelection();
virtual void ApplyViewOptions( const SwViewOption &rOpt );
+ virtual void SetReadonlyOption( sal_Bool bSet );
// automatic update of styles
void AutoUpdateFrame(SwFrmFmt* pFmt, const SfxItemSet& rStyleSet);
diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx
index 9a3a7d9..94460f9 100644
--- a/sw/source/ui/wrtsh/wrtsh1.cxx
+++ b/sw/source/ui/wrtsh/wrtsh1.cxx
@@ -1808,4 +1808,10 @@ void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt )
}
+void SwWrtShell::SetReadonlyOption(sal_Bool bSet)
+{
+ GetView().GetEditWin().SetReadonlyHeaderFooterControls( bSet );
+ ViewShell::SetReadonlyOption( bSet );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list