1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: break.cxx,v $
10 * $Revision: 1.16.224.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
39 #include <sfx2/request.hxx>
40 #include <svtools/stritem.hxx>
41 #ifndef _MSGBOX_HXX //autogen
42 #include <vcl/msgbox.hxx>
49 #include <swtypes.hxx>
57 #include <viewopt.hxx>
59 #include <pagedesc.hxx>
60 #include <poolfmt.hxx>
68 #include <SwStyleNameMapper.hxx>
70 void SwBreakDlg::Apply()
73 if(aLineBtn
.IsChecked())
75 else if(aColumnBtn
.IsChecked())
77 else if(aPageBtn
.IsChecked())
80 const USHORT nPos
= aPageCollBox
.GetSelectEntryPos();
81 if(0 != nPos
&& LISTBOX_ENTRY_NOTFOUND
!= nPos
)
83 aTemplate
= aPageCollBox
.GetSelectEntry();
84 nPgNum
= aPageNumBox
.IsChecked() ? (USHORT
)aPageNumEdit
.GetValue() : 0;
90 IMPL_LINK_INLINE_START( SwBreakDlg
, ClickHdl
, void *, EMPTYARG
)
95 IMPL_LINK_INLINE_END( SwBreakDlg
, ClickHdl
, void *, EMPTYARG
)
97 /*------------------------------------------------------------------------
98 Beschreibung: Handler fuer Aendern Seitenummer
99 ------------------------------------------------------------------------*/
101 IMPL_LINK_INLINE_START( SwBreakDlg
, PageNumHdl
, CheckBox
*, pBox
)
103 if(pBox
->IsChecked()) aPageNumEdit
.SetValue(1);
104 else aPageNumEdit
.SetText(aEmptyStr
);
107 IMPL_LINK_INLINE_END( SwBreakDlg
, PageNumHdl
, CheckBox
*, pBox
)
109 /*------------------------------------------------------------------------
110 Beschreibung: Durch Aendern der Seitennummer wird die Checkbox gecheckt.
111 ------------------------------------------------------------------------*/
113 IMPL_LINK_INLINE_START( SwBreakDlg
, PageNumModifyHdl
, Edit
*, EMPTYARG
)
118 IMPL_LINK_INLINE_END( SwBreakDlg
, PageNumModifyHdl
, Edit
*, EMPTYARG
)
120 /*------------------------------------------------------------------------
121 Beschreibung: Ok-Handler;
122 prueft, ob die Seitenummer nPage eine legale Seitennummer
123 ist (linke Seiten mit geraden Nummern etc. bei einer Seitenvorlage
124 mit wechselnden Seiten)
125 ------------------------------------------------------------------------*/
127 IMPL_LINK( SwBreakDlg
, OkHdl
, Button
*, EMPTYARG
)
129 if(aPageNumBox
.IsChecked()) {
130 // wenn unterschiedliche Seitenvorlagen, testen auf Gueltigkeit
131 const USHORT nPos
= aPageCollBox
.GetSelectEntryPos();
132 // auf Position 0 steht 'Ohne'.
133 const SwPageDesc
*pPageDesc
;
134 if ( 0 != nPos
&& LISTBOX_ENTRY_NOTFOUND
!= nPos
)
135 pPageDesc
= rSh
.FindPageDescByName( aPageCollBox
.GetSelectEntry(),
138 pPageDesc
= &rSh
.GetPageDesc(rSh
.GetCurPageDesc());
140 ASSERT(pPageDesc
, Seitenvorlage nicht gefunden
.);
141 const USHORT nUserPage
= USHORT(aPageNumEdit
.GetValue());
143 switch(pPageDesc
->GetUseOn())
145 case nsUseOnPage::PD_MIRROR
:
146 case nsUseOnPage::PD_ALL
: break;
147 case nsUseOnPage::PD_LEFT
: bOk
= 0 == nUserPage
% 2; break;
148 case nsUseOnPage::PD_RIGHT
: bOk
= static_cast< sal_Bool
>(nUserPage
% 2); break;
149 default:; //prevent warning
152 InfoBox(this, SW_RES(MSG_ILLEGAL_PAGENUM
)).Execute();
153 aPageNumEdit
.GrabFocus();
161 SwBreakDlg::SwBreakDlg( Window
*pParent
, SwWrtShell
&rS
) :
163 SvxStandardDialog( pParent
,SW_RES(DLG_BREAK
) ),
166 aLineBtn(this,SW_RES(RB_LINE
)),
167 aColumnBtn(this,SW_RES(RB_COL
)),
168 aPageBtn(this,SW_RES(RB_PAGE
)),
169 aPageCollText(this, SW_RES(FT_COLL
)),
170 aPageCollBox(this, SW_RES(LB_COLL
)),
171 aPageNumBox(this, SW_RES(CB_PAGENUM
)),
172 aPageNumEdit(this, SW_RES(ED_PAGENUM
)),
173 aBreakFL(this,SW_RES(FL_BREAK
)),
175 aOkBtn(this,SW_RES(BT_OK
)),
176 aCancelBtn(this,SW_RES(BT_CANCEL
)),
177 aHelpBtn(this,SW_RES(BT_HELP
)),
182 bHtmlMode(0 != ::GetHtmlMode(rS
.GetView().GetDocShell()))
184 Link aLk
= LINK(this,SwBreakDlg
,ClickHdl
);
185 aPageBtn
.SetClickHdl( aLk
);
186 aLineBtn
.SetClickHdl( aLk
);
187 aColumnBtn
.SetClickHdl( aLk
);
188 aPageCollBox
.SetSelectHdl( aLk
);
190 aOkBtn
.SetClickHdl(LINK(this,SwBreakDlg
,OkHdl
));
191 aPageNumBox
.SetClickHdl(LINK(this,SwBreakDlg
,PageNumHdl
));
192 aPageNumEdit
.SetModifyHdl(LINK(this,SwBreakDlg
,PageNumModifyHdl
));
195 // Einfuegen der vorhandenen Seitenvorlagen in die Listbox
196 const USHORT nCount
= rSh
.GetPageDescCnt();
199 for( i
= 0; i
< nCount
; ++i
)
201 const SwPageDesc
&rPageDesc
= rSh
.GetPageDesc(i
);
202 ::InsertStringSorted(rPageDesc
.GetName(), aPageCollBox
, 1 );
206 for(i
= RES_POOLPAGE_BEGIN
; i
<= RES_POOLPAGE_REGISTER
; ++i
)
207 if(LISTBOX_ENTRY_NOTFOUND
== aPageCollBox
.GetEntryPos( aFmtName
=
208 SwStyleNameMapper::GetUIName( i
, aFmtName
)))
209 ::InsertStringSorted(aFmtName
, aPageCollBox
, 1 );
211 if(LISTBOX_ENTRY_NOTFOUND
== aPageCollBox
.GetEntryPos( aFmtName
=
212 SwStyleNameMapper::GetUIName( RES_POOLPAGE_LANDSCAPE
, aFmtName
)))
213 ::InsertStringSorted(aFmtName
, aPageCollBox
, 1 );
215 aPageNumEdit
.SetText( aEmptyStr
);
220 void SwBreakDlg::CheckEnable()
225 aColumnBtn
.Enable(FALSE
);
226 aPageCollBox
.Enable(FALSE
);
229 else if(rSh
.GetFrmType(0,TRUE
)
230 & (FRMTYPE_FLY_ANY
| FRMTYPE_HEADER
| FRMTYPE_FOOTER
| FRMTYPE_FOOTNOTE
))
232 aPageBtn
.Enable(FALSE
);
233 if(aPageBtn
.IsChecked())
234 aLineBtn
.Check(TRUE
);
237 const BOOL bPage
= aPageBtn
.IsChecked();
238 aPageCollText
.Enable( bPage
);
239 aPageCollBox
.Enable ( bPage
);
244 // auf Position 0 steht 'Ohne' Seitenvorlage.
245 const USHORT nPos
= aPageCollBox
.GetSelectEntryPos();
246 if ( 0 == nPos
|| LISTBOX_ENTRY_NOTFOUND
== nPos
)
249 aPageNumBox
.Enable(bEnable
);
250 aPageNumEdit
.Enable(bEnable
);
253 SwBreakDlg::~SwBreakDlg()