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_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <sfx2/request.hxx> 37*cdf0e10cSrcweir #include <svl/stritem.hxx> 38*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 39*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #ifndef _CMDID_H 43*cdf0e10cSrcweir #include <cmdid.h> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #include <uitool.hxx> 46*cdf0e10cSrcweir #include <swtypes.hxx> 47*cdf0e10cSrcweir #include <wrtsh.hxx> 48*cdf0e10cSrcweir #ifndef _BASESH_HXX 49*cdf0e10cSrcweir #include <basesh.hxx> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _VIEW_HXX 52*cdf0e10cSrcweir #include <view.hxx> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #include <viewopt.hxx> 55*cdf0e10cSrcweir #include <break.hxx> 56*cdf0e10cSrcweir #include <pagedesc.hxx> 57*cdf0e10cSrcweir #include <poolfmt.hxx> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #ifndef _BREAK_HRC 60*cdf0e10cSrcweir #include <break.hrc> 61*cdf0e10cSrcweir #endif 62*cdf0e10cSrcweir #ifndef _CHRDLG_HRC 63*cdf0e10cSrcweir #include <chrdlg.hrc> 64*cdf0e10cSrcweir #endif 65*cdf0e10cSrcweir #include <SwStyleNameMapper.hxx> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir void SwBreakDlg::Apply() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir nKind = 0; 70*cdf0e10cSrcweir if(aLineBtn.IsChecked()) 71*cdf0e10cSrcweir nKind = 1; 72*cdf0e10cSrcweir else if(aColumnBtn.IsChecked()) 73*cdf0e10cSrcweir nKind = 2; 74*cdf0e10cSrcweir else if(aPageBtn.IsChecked()) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir nKind = 3; 77*cdf0e10cSrcweir const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos(); 78*cdf0e10cSrcweir if(0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir aTemplate = aPageCollBox.GetSelectEntry(); 81*cdf0e10cSrcweir nPgNum = aPageNumBox.IsChecked() ? (sal_uInt16)aPageNumEdit.GetValue() : 0; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwBreakDlg, ClickHdl, void *, EMPTYARG ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir CheckEnable(); 90*cdf0e10cSrcweir return 0; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwBreakDlg, ClickHdl, void *, EMPTYARG ) 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir /*------------------------------------------------------------------------ 95*cdf0e10cSrcweir Beschreibung: Handler fuer Aendern Seitenummer 96*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwBreakDlg, PageNumHdl, CheckBox *, pBox ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if(pBox->IsChecked()) aPageNumEdit.SetValue(1); 101*cdf0e10cSrcweir else aPageNumEdit.SetText(aEmptyStr); 102*cdf0e10cSrcweir return 0; 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwBreakDlg, PageNumHdl, CheckBox *, pBox ) 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /*------------------------------------------------------------------------ 107*cdf0e10cSrcweir Beschreibung: Durch Aendern der Seitennummer wird die Checkbox gecheckt. 108*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwBreakDlg, PageNumModifyHdl, Edit *, EMPTYARG ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir aPageNumBox.Check(); 113*cdf0e10cSrcweir return 0; 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwBreakDlg, PageNumModifyHdl, Edit *, EMPTYARG ) 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /*------------------------------------------------------------------------ 118*cdf0e10cSrcweir Beschreibung: Ok-Handler; 119*cdf0e10cSrcweir prueft, ob die Seitenummer nPage eine legale Seitennummer 120*cdf0e10cSrcweir ist (linke Seiten mit geraden Nummern etc. bei einer Seitenvorlage 121*cdf0e10cSrcweir mit wechselnden Seiten) 122*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir IMPL_LINK( SwBreakDlg, OkHdl, Button *, EMPTYARG ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir if(aPageNumBox.IsChecked()) { 127*cdf0e10cSrcweir // wenn unterschiedliche Seitenvorlagen, testen auf Gueltigkeit 128*cdf0e10cSrcweir const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos(); 129*cdf0e10cSrcweir // auf Position 0 steht 'Ohne'. 130*cdf0e10cSrcweir const SwPageDesc *pPageDesc; 131*cdf0e10cSrcweir if ( 0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos ) 132*cdf0e10cSrcweir pPageDesc = rSh.FindPageDescByName( aPageCollBox.GetSelectEntry(), 133*cdf0e10cSrcweir sal_True ); 134*cdf0e10cSrcweir else 135*cdf0e10cSrcweir pPageDesc = &rSh.GetPageDesc(rSh.GetCurPageDesc()); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ASSERT(pPageDesc, Seitenvorlage nicht gefunden.); 138*cdf0e10cSrcweir const sal_uInt16 nUserPage = sal_uInt16(aPageNumEdit.GetValue()); 139*cdf0e10cSrcweir sal_Bool bOk = sal_True; 140*cdf0e10cSrcweir switch(pPageDesc->GetUseOn()) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir case nsUseOnPage::PD_MIRROR: 143*cdf0e10cSrcweir case nsUseOnPage::PD_ALL: break; 144*cdf0e10cSrcweir case nsUseOnPage::PD_LEFT: bOk = 0 == nUserPage % 2; break; 145*cdf0e10cSrcweir case nsUseOnPage::PD_RIGHT: bOk = static_cast< sal_Bool >(nUserPage % 2); break; 146*cdf0e10cSrcweir default:; //prevent warning 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir if(!bOk) { 149*cdf0e10cSrcweir InfoBox(this, SW_RES(MSG_ILLEGAL_PAGENUM)).Execute(); 150*cdf0e10cSrcweir aPageNumEdit.GrabFocus(); 151*cdf0e10cSrcweir return 0; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir EndDialog(RET_OK); 155*cdf0e10cSrcweir return 0; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir SwBreakDlg::SwBreakDlg( Window *pParent, SwWrtShell &rS ) : 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir SvxStandardDialog( pParent,SW_RES(DLG_BREAK) ), 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir rSh(rS), 163*cdf0e10cSrcweir aBreakFL(this,SW_RES(FL_BREAK)), 164*cdf0e10cSrcweir aLineBtn(this,SW_RES(RB_LINE)), 165*cdf0e10cSrcweir aColumnBtn(this,SW_RES(RB_COL)), 166*cdf0e10cSrcweir aPageBtn(this,SW_RES(RB_PAGE)), 167*cdf0e10cSrcweir aPageCollText(this, SW_RES(FT_COLL)), 168*cdf0e10cSrcweir aPageCollBox(this, SW_RES(LB_COLL)), 169*cdf0e10cSrcweir aPageNumBox(this, SW_RES(CB_PAGENUM)), 170*cdf0e10cSrcweir aPageNumEdit(this, SW_RES(ED_PAGENUM)), 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir aOkBtn(this,SW_RES(BT_OK)), 173*cdf0e10cSrcweir aCancelBtn(this,SW_RES(BT_CANCEL)), 174*cdf0e10cSrcweir aHelpBtn(this,SW_RES(BT_HELP)), 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir nKind(0), 177*cdf0e10cSrcweir nPgNum(0), 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir bHtmlMode(0 != ::GetHtmlMode(rS.GetView().GetDocShell())) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir aPageNumEdit.SetAccessibleRelationLabeledBy(&aPageNumBox); 182*cdf0e10cSrcweir aPageNumEdit.SetAccessibleName(aPageNumBox.GetText()); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir Link aLk = LINK(this,SwBreakDlg,ClickHdl); 185*cdf0e10cSrcweir aPageBtn.SetClickHdl( aLk ); 186*cdf0e10cSrcweir aLineBtn.SetClickHdl( aLk ); 187*cdf0e10cSrcweir aColumnBtn.SetClickHdl( aLk ); 188*cdf0e10cSrcweir aPageCollBox.SetSelectHdl( aLk ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir aOkBtn.SetClickHdl(LINK(this,SwBreakDlg,OkHdl)); 191*cdf0e10cSrcweir aPageNumBox.SetClickHdl(LINK(this,SwBreakDlg,PageNumHdl)); 192*cdf0e10cSrcweir aPageNumEdit.SetModifyHdl(LINK(this,SwBreakDlg,PageNumModifyHdl)); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // Einfuegen der vorhandenen Seitenvorlagen in die Listbox 196*cdf0e10cSrcweir const sal_uInt16 nCount = rSh.GetPageDescCnt(); 197*cdf0e10cSrcweir sal_uInt16 i; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir for( i = 0; i < nCount; ++i) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir const SwPageDesc &rPageDesc = rSh.GetPageDesc(i); 202*cdf0e10cSrcweir ::InsertStringSorted(rPageDesc.GetName(), aPageCollBox, 1 ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir String aFmtName; 206*cdf0e10cSrcweir for(i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i) 207*cdf0e10cSrcweir if(LISTBOX_ENTRY_NOTFOUND == aPageCollBox.GetEntryPos( aFmtName = 208*cdf0e10cSrcweir SwStyleNameMapper::GetUIName( i, aFmtName ))) 209*cdf0e10cSrcweir ::InsertStringSorted(aFmtName, aPageCollBox, 1 ); 210*cdf0e10cSrcweir //add landscape page 211*cdf0e10cSrcweir if(LISTBOX_ENTRY_NOTFOUND == aPageCollBox.GetEntryPos( aFmtName = 212*cdf0e10cSrcweir SwStyleNameMapper::GetUIName( RES_POOLPAGE_LANDSCAPE, aFmtName ))) 213*cdf0e10cSrcweir ::InsertStringSorted(aFmtName, aPageCollBox, 1 ); 214*cdf0e10cSrcweir CheckEnable(); 215*cdf0e10cSrcweir aPageNumEdit.SetText( aEmptyStr ); 216*cdf0e10cSrcweir FreeResource(); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir void SwBreakDlg::CheckEnable() 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir sal_Bool bEnable = sal_True; 223*cdf0e10cSrcweir if ( bHtmlMode ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir aColumnBtn .Enable(sal_False); 226*cdf0e10cSrcweir aPageCollBox.Enable(sal_False); 227*cdf0e10cSrcweir bEnable = sal_False; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir else if(rSh.GetFrmType(0,sal_True) 230*cdf0e10cSrcweir & (FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE)) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir aPageBtn.Enable(sal_False); 233*cdf0e10cSrcweir if(aPageBtn.IsChecked()) 234*cdf0e10cSrcweir aLineBtn.Check(sal_True); 235*cdf0e10cSrcweir bEnable = sal_False; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir const sal_Bool bPage = aPageBtn.IsChecked(); 238*cdf0e10cSrcweir aPageCollText.Enable( bPage ); 239*cdf0e10cSrcweir aPageCollBox.Enable ( bPage ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir bEnable &= bPage; 242*cdf0e10cSrcweir if ( bEnable ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir // auf Position 0 steht 'Ohne' Seitenvorlage. 245*cdf0e10cSrcweir const sal_uInt16 nPos = aPageCollBox.GetSelectEntryPos(); 246*cdf0e10cSrcweir if ( 0 == nPos || LISTBOX_ENTRY_NOTFOUND == nPos ) 247*cdf0e10cSrcweir bEnable = sal_False; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir aPageNumBox .Enable(bEnable); 250*cdf0e10cSrcweir aPageNumEdit.Enable(bEnable); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir SwBreakDlg::~SwBreakDlg() 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir } 256