summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-21 14:29:30 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-21 17:44:51 +0200
commit1ca08ac546c24f12644e387418d88dba7c1c4236 (patch)
tree1ab9a833bff58576da5e09aceda589570ee0bd93
parentaaa34f74a639b8cf54d27d52b292f4d0ed0f1231 (diff)
Header/Footer: Extracted a few common things to a SwFrameControl class
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx26
-rw-r--r--sw/source/ui/docvw/edtwin.cxx2
-rw-r--r--sw/source/ui/inc/FrameControl.hxx55
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx7
4 files changed, 73 insertions, 17 deletions
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index f1eb77a430d4..f3bb00ac3f90 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -139,18 +139,13 @@ namespace
SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
MenuButton( pEditWin, WB_DIALOGCONTROL ),
- m_pEditWin( pEditWin ),
+ SwFrameControl( pEditWin, pPageFrm ),
m_sLabel( ),
- m_pPageFrm( pPageFrm ),
m_bIsHeader( bHeader ),
m_bReadonly( false ),
m_pPopupMenu( NULL ),
m_pLine( NULL )
{
- // Define the readonly member
- const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
- m_bReadonly = pViewOpt->IsReadonly();
-
// Get the font and configure it
Font aFont = GetSettings().GetStyleSettings().GetToolFont();
SetZoomedPointFont( aFont );
@@ -163,11 +158,11 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
if ( !m_bIsHeader )
m_sLabel = ResId::toString( SW_RES( STR_FOOTER_TITLE ) );
sal_Int32 nPos = m_sLabel.lastIndexOf( rtl::OUString::createFromAscii( "%1" ) );
- m_sLabel = m_sLabel.replaceAt( nPos, 2, m_pPageFrm->GetPageDesc()->GetName() );
+ m_sLabel = m_sLabel.replaceAt( nPos, 2, GetPageFrame()->GetPageDesc()->GetName() );
// Create the line control
basegfx::BColor aColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
- m_pLine = new SwDashedLine( m_pEditWin, aColor );
+ m_pLine = new SwDashedLine( GetEditWin(), aColor );
// Create and set the PopupMenu
m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
@@ -193,6 +188,11 @@ SwHeaderFooterWin::~SwHeaderFooterWin( )
delete m_pLine;
}
+const SwPageFrm* SwHeaderFooterWin::GetPageFrame( )
+{
+ return static_cast< const SwPageFrm * >( GetFrame( ) );
+}
+
void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd )
{
// Compute the text size and get the box position & size from it
@@ -278,10 +278,10 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
bool bResult = true;
// Actually check it
- const SwPageDesc* pDesc = m_pPageFrm->GetPageDesc();
+ const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
const SwFrmFmt* pFmt = pDesc->GetLeftFmt();
- if ( m_pPageFrm->OnRightPage() )
+ if ( GetPageFrame()->OnRightPage() )
pFmt = pDesc->GetRightFmt();
if ( pFmt )
@@ -297,7 +297,7 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
{
- SwView& rView = m_pEditWin->GetView();
+ SwView& rView = GetEditWin()->GetView();
SwWrtShell& rSh = rView.GetWrtShell();
const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
@@ -316,7 +316,7 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
break;
case FN_HEADERFOOTER_BORDERBACK:
{
- const SwPageDesc* pDesc = m_pPageFrm->GetPageDesc();
+ const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
const SwFrmFmt& rMaster = pDesc->GetMaster();
SwFrmFmt* pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetFooter().GetFooterFmt() );
if ( m_bIsHeader )
@@ -380,7 +380,7 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( IsEmptyHeaderFooter( ) )
{
- SwView& rView = m_pEditWin->GetView();
+ SwView& rView = GetEditWin()->GetView();
SwWrtShell& rSh = rView.GetWrtShell();
const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 3c29c27ea370..e985981e2c88 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5774,6 +5774,8 @@ void SwEditWin::SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader,
if ( !pControl.get() )
{
boost::shared_ptr< SwHeaderFooterWin > pNewControl( new SwHeaderFooterWin( this, pPageFrm, bHeader ) );
+ const SwViewOption* pViewOpt = GetView().GetWrtShell().GetViewOptions();
+ pNewControl->SetReadonly( pViewOpt->IsReadonly() );
pControl.swap( pNewControl );
aHeadFootControls.push_back( pControl );
}
diff --git a/sw/source/ui/inc/FrameControl.hxx b/sw/source/ui/inc/FrameControl.hxx
new file mode 100644
index 000000000000..01bbb6b84510
--- /dev/null
+++ b/sw/source/ui/inc/FrameControl.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _FRAMECONTROL_HXX
+#define _FRAMECONTROL_HXX
+
+#include <edtwin.hxx>
+#include <frame.hxx>
+
+/** Class representing a control linked to a SwFrm.
+ */
+class SwFrameControl
+{
+ SwEditWin* m_pEditWin;
+ const SwFrm* m_pFrm;
+
+public:
+ SwFrameControl( SwEditWin* pEditWin, const SwFrm* pFrm ) :
+ m_pEditWin( pEditWin ), m_pFrm( pFrm ) {};
+ ~SwFrameControl( ) {};
+
+ const SwFrm* GetFrame( ) { return m_pFrm; }
+ SwEditWin* GetEditWin( ) { return m_pEditWin; }
+
+ virtual void SetReadonly( bool bReadonly ) = 0;
+ virtual void ShowAll( bool bShow ) = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index c59211da6558..bbb93b209172 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -28,6 +28,7 @@
#ifndef _HEADERFOOTERWINDOW_HXX
#define _HEADERFOOTERWINDOW_HXX
+#include <FrameControl.hxx>
#include <pagedesc.hxx>
#include <vcl/menubtn.hxx>
@@ -37,11 +38,9 @@
This control is showing the header / footer style name and provides
a few useful actions to the user.
*/
-class SwHeaderFooterWin : public MenuButton
+class SwHeaderFooterWin : public MenuButton, public SwFrameControl
{
- SwEditWin* m_pEditWin;
rtl::OUString m_sLabel;
- const SwPageFrm* m_pPageFrm;
bool m_bIsHeader;
bool m_bReadonly;
PopupMenu* m_pPopupMenu;
@@ -61,7 +60,7 @@ public:
bool IsHeader() { return m_bIsHeader; };
bool IsEmptyHeaderFooter( );
- const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
+ const SwPageFrm* GetPageFrame( );
void ExecuteCommand(sal_uInt16 nSlot);