1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir //------------------------------------------------------------------ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #define _TPHF_CXX 38*cdf0e10cSrcweir #include "scitems.hxx" 39*cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 40*cdf0e10cSrcweir #include <svl/style.hxx> 41*cdf0e10cSrcweir #include <vcl/svapp.hxx> 42*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "tphf.hxx" 45*cdf0e10cSrcweir #include "sc.hrc" 46*cdf0e10cSrcweir #include "globstr.hrc" 47*cdf0e10cSrcweir #include "tabvwsh.hxx" 48*cdf0e10cSrcweir #include "viewdata.hxx" 49*cdf0e10cSrcweir #include "document.hxx" 50*cdf0e10cSrcweir //CHINA001 #include "tphfedit.hxx" 51*cdf0e10cSrcweir #include "hfedtdlg.hxx" 52*cdf0e10cSrcweir #include "styledlg.hxx" 53*cdf0e10cSrcweir #include "scresid.hxx" 54*cdf0e10cSrcweir #include "scuitphfedit.hxx" //CHINA001 55*cdf0e10cSrcweir #undef _TPHF_CXX 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //================================================================== 60*cdf0e10cSrcweir // class ScHFPage 61*cdf0e10cSrcweir //================================================================== 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir ScHFPage::ScHFPage( Window* pParent, sal_uInt16 nResId, 64*cdf0e10cSrcweir const SfxItemSet& rSet, sal_uInt16 nSetId ) 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir : SvxHFPage ( pParent, nResId, rSet, nSetId ), 67*cdf0e10cSrcweir aBtnEdit ( this, ScResId( RID_SCBTN_HFEDIT ) ), 68*cdf0e10cSrcweir aDataSet ( *rSet.GetPool(), 69*cdf0e10cSrcweir ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT, 70*cdf0e10cSrcweir ATTR_PAGE, ATTR_PAGE, 0 ), 71*cdf0e10cSrcweir nPageUsage ( (sal_uInt16)SVX_PAGE_ALL ), 72*cdf0e10cSrcweir pStyleDlg ( NULL ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir SetExchangeSupport(); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SfxViewShell* pSh = SfxViewShell::Current(); 77*cdf0e10cSrcweir ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pSh); 78*cdf0e10cSrcweir Point aPos( aBackgroundBtn.GetPosPixel() ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // aBackgroundBtn position not changed anymore 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir aPos.X() += aBackgroundBtn.GetSizePixel().Width(); 83*cdf0e10cSrcweir aPos.X() += LogicToPixel( Size(3,0), MAP_APPFONT ).Width(); 84*cdf0e10cSrcweir aBtnEdit.SetPosPixel( aPos ); 85*cdf0e10cSrcweir aBtnEdit.Show(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir aDataSet.Put( rSet ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir if ( pViewSh ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir ScViewData* pViewData = pViewSh->GetViewData(); 92*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir aStrPageStyle = pDoc->GetPageStyle( pViewData->GetTabNo() ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir aBtnEdit.SetClickHdl ( LINK( this, ScHFPage, BtnHdl ) ); 98*cdf0e10cSrcweir aTurnOnBox.SetClickHdl ( LINK( this, ScHFPage, TurnOnHdl ) ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if ( nId == SID_ATTR_PAGE_HEADERSET ) 101*cdf0e10cSrcweir aBtnEdit.SetHelpId( HID_SC_HEADER_EDIT ); 102*cdf0e10cSrcweir else 103*cdf0e10cSrcweir aBtnEdit.SetHelpId( HID_SC_FOOTER_EDIT ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir aBtnEdit.SetAccessibleRelationMemberOf(&aFrm); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir //------------------------------------------------------------------ 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir __EXPORT ScHFPage::~ScHFPage() 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir //------------------------------------------------------------------ 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir void __EXPORT ScHFPage::Reset( const SfxItemSet& rSet ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir SvxHFPage::Reset( rSet ); 119*cdf0e10cSrcweir TurnOnHdl( 0 ); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //------------------------------------------------------------------ 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir sal_Bool __EXPORT ScHFPage::FillItemSet( SfxItemSet& rOutSet ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir sal_Bool bResult = SvxHFPage::FillItemSet( rOutSet ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if ( nId == SID_ATTR_PAGE_HEADERSET ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERLEFT ) ); 131*cdf0e10cSrcweir rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERRIGHT ) ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir else 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERLEFT ) ); 136*cdf0e10cSrcweir rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERRIGHT ) ); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir return bResult; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir //------------------------------------------------------------------ 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void __EXPORT ScHFPage::ActivatePage( const SfxItemSet& rSet ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir sal_uInt16 nPageWhich = GetWhich( SID_ATTR_PAGE ); 147*cdf0e10cSrcweir const SvxPageItem& rPageItem = (const SvxPageItem&) 148*cdf0e10cSrcweir rSet.Get(nPageWhich); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir nPageUsage = rPageItem.GetPageUsage(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir if ( pStyleDlg ) 153*cdf0e10cSrcweir aStrPageStyle = pStyleDlg->GetStyleSheet().GetName(); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir aDataSet.Put( rSet.Get(ATTR_PAGE) ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir SvxHFPage::ActivatePage( rSet ); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir //------------------------------------------------------------------ 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir int __EXPORT ScHFPage::DeactivatePage( SfxItemSet* pSetP ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir if ( LEAVE_PAGE == SvxHFPage::DeactivatePage( pSetP ) ) 165*cdf0e10cSrcweir if ( pSetP ) 166*cdf0e10cSrcweir FillItemSet( *pSetP ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir return LEAVE_PAGE; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //------------------------------------------------------------------ 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir void ScHFPage::ActivatePage() 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir void ScHFPage::DeactivatePage() 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir //------------------------------------------------------------------ 182*cdf0e10cSrcweir // Handler: 183*cdf0e10cSrcweir //------------------------------------------------------------------ 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir IMPL_LINK( ScHFPage, TurnOnHdl, CheckBox*, EMPTYARG ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir SvxHFPage::TurnOnHdl( &aTurnOnBox ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir if ( aTurnOnBox.IsChecked() ) 190*cdf0e10cSrcweir aBtnEdit.Enable(); 191*cdf0e10cSrcweir else 192*cdf0e10cSrcweir aBtnEdit.Disable(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir return 0; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir //------------------------------------------------------------------ 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir IMPL_LINK( ScHFPage, BtnHdl, PushButton*, EMPTYARG ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir // Wenn der Bearbeiten-Dialog direkt aus dem Click-Handler des Buttons 203*cdf0e10cSrcweir // aufgerufen wird, funktioniert im Bearbeiten-Dialog unter OS/2 das 204*cdf0e10cSrcweir // GrabFocus nicht (Bug #41805#). 205*cdf0e10cSrcweir // Mit dem neuen StarView sollte dieser Workaround wieder raus koennen! 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir Application::PostUserEvent( LINK( this, ScHFPage, HFEditHdl ) ); 208*cdf0e10cSrcweir return 0; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir IMPL_LINK( ScHFPage, HFEditHdl, void*, EMPTYARG ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir SfxViewShell* pViewSh = SfxViewShell::Current(); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir if ( !pViewSh ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir DBG_ERROR( "Current ViewShell not found." ); 218*cdf0e10cSrcweir return 0; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if ( aCntSharedBox.IsEnabled() 222*cdf0e10cSrcweir && !aCntSharedBox.IsChecked() ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir sal_uInt16 nResId = ( nId == SID_ATTR_PAGE_HEADERSET ) 225*cdf0e10cSrcweir ? RID_SCDLG_HFED_HEADER 226*cdf0e10cSrcweir : RID_SCDLG_HFED_FOOTER; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir ScHFEditDlg* pDlg 229*cdf0e10cSrcweir = new ScHFEditDlg( pViewSh->GetViewFrame(), this, 230*cdf0e10cSrcweir aDataSet, aStrPageStyle, nResId ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir aDataSet.Put( *pDlg->GetOutputItemSet() ); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir delete pDlg; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir else 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir String aText; 242*cdf0e10cSrcweir SfxSingleTabDialog* pDlg = new SfxSingleTabDialog( this, aDataSet, 42 ); 243*cdf0e10cSrcweir sal_Bool bRightPage = aCntSharedBox.IsChecked() 244*cdf0e10cSrcweir || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if ( nId == SID_ATTR_PAGE_HEADERSET ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir aText = ScGlobal::GetRscString( STR_PAGEHEADER ); 249*cdf0e10cSrcweir if ( bRightPage ) 250*cdf0e10cSrcweir pDlg->SetTabPage( ScRightHeaderEditPage::Create( pDlg, aDataSet ) ); 251*cdf0e10cSrcweir else 252*cdf0e10cSrcweir pDlg->SetTabPage( ScLeftHeaderEditPage::Create( pDlg, aDataSet ) ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir else 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir aText = ScGlobal::GetRscString( STR_PAGEFOOTER ); 257*cdf0e10cSrcweir if ( bRightPage ) 258*cdf0e10cSrcweir pDlg->SetTabPage( ScRightFooterEditPage::Create( pDlg, aDataSet ) ); 259*cdf0e10cSrcweir else 260*cdf0e10cSrcweir pDlg->SetTabPage( ScLeftFooterEditPage::Create( pDlg, aDataSet ) ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir SvxNumType eNumType = ((const SvxPageItem&)aDataSet.Get(ATTR_PAGE)).GetNumType(); 264*cdf0e10cSrcweir ((ScHFEditPage*)pDlg->GetTabPage())->SetNumType(eNumType); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" )); 267*cdf0e10cSrcweir aText += ScGlobal::GetRscString( STR_PAGESTYLE ); 268*cdf0e10cSrcweir aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " )); 269*cdf0e10cSrcweir aText += aStrPageStyle; 270*cdf0e10cSrcweir aText += ')'; 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir pDlg->SetText( aText ); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir aDataSet.Put( *pDlg->GetOutputItemSet() ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir delete pDlg; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir return 0; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir //================================================================== 286*cdf0e10cSrcweir // class ScHeaderPage 287*cdf0e10cSrcweir //================================================================== 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir ScHeaderPage::ScHeaderPage( Window* pParent, const SfxItemSet& rSet ) 290*cdf0e10cSrcweir : ScHFPage( pParent, RID_SVXPAGE_HEADER, rSet, SID_ATTR_PAGE_HEADERSET ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir //------------------------------------------------------------------ 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir SfxTabPage* __EXPORT ScHeaderPage::Create( Window* pParent, const SfxItemSet& rCoreSet ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir return ( new ScHeaderPage( pParent, rCoreSet ) ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir //------------------------------------------------------------------ 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir sal_uInt16* __EXPORT ScHeaderPage::GetRanges() 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir return SvxHeaderPage::GetRanges(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir //================================================================== 309*cdf0e10cSrcweir // class ScFooterPage 310*cdf0e10cSrcweir //================================================================== 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir ScFooterPage::ScFooterPage( Window* pParent, const SfxItemSet& rSet ) 313*cdf0e10cSrcweir : ScHFPage( pParent, RID_SVXPAGE_FOOTER, rSet, SID_ATTR_PAGE_FOOTERSET ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //------------------------------------------------------------------ 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir SfxTabPage* __EXPORT ScFooterPage::Create( Window* pParent, const SfxItemSet& rCoreSet ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir return ( new ScFooterPage( pParent, rCoreSet ) ); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir //------------------------------------------------------------------ 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir sal_uInt16* __EXPORT ScFooterPage::GetRanges() 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir return SvxHeaderPage::GetRanges(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir 334