xref: /trunk/main/cui/source/dialogs/splitcelldlg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 
31 #include <sfx2/dispatch.hxx>
32 #include <svl/intitem.hxx>
33 #include <svl/eitem.hxx>
34 #include "dialmgr.hxx"
35 #include "splitcelldlg.hxx"
36 #include "cuires.hrc"
37 #include "splitcelldlg.hrc"
38 
39 SvxSplitTableDlg::SvxSplitTableDlg( Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal )
40 : SvxStandardDialog(pParent, CUI_RES(RID_SVX_SPLITCELLDLG))
41 , maCountFL(this, CUI_RES(FL_COUNT))
42 , maCountLbl(this, CUI_RES(FT_COUNT))
43 , maCountEdit(this, CUI_RES(ED_COUNT))
44 , maDirFL(this, CUI_RES(FL_DIR))
45 , maHorzBox(this, CUI_RES(RB_HORZ))
46 , maVertBox(this, CUI_RES(RB_VERT))
47 , maPropCB(this, CUI_RES(CB_PROP))
48 , maOKBtn(this, CUI_RES(BT_OK))
49 , maCancelBtn(this, CUI_RES(BT_CANCEL))
50 , maHelpBtn( this, CUI_RES( BT_HELP ) )
51 , mnMaxVertical( nMaxVertical )
52 , mnMaxHorizontal( nMaxHorizontal )
53 {
54     maVertBox.SetModeRadioImage(Image(CUI_RES(BMP_SPLIT_VERT)), BMP_COLOR_HIGHCONTRAST);
55     maHorzBox.SetModeRadioImage(Image(CUI_RES(BMP_SPLIT_HORZ)), BMP_COLOR_HIGHCONTRAST);
56     FreeResource();
57     maHorzBox.SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
58     maPropCB.SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
59     maVertBox.SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
60 
61 	if( mnMaxVertical < 2 )
62 		maVertBox.Enable(sal_False);
63 
64     //exchange the meaning of horizontal and vertical for vertical text
65 	if(bIsTableVertical)
66     {
67         Image aTmpImg(maHorzBox.GetModeRadioImage());
68         String sTmp(maHorzBox.GetText());
69         maHorzBox.SetText(maVertBox.GetText());
70         maHorzBox.SetModeRadioImage(maVertBox.GetModeRadioImage());
71         maVertBox.SetText(sTmp);
72         maVertBox.SetModeRadioImage(aTmpImg);
73     }
74 }
75 
76 SvxSplitTableDlg::~SvxSplitTableDlg()
77 {
78 }
79 
80 IMPL_LINK( SvxSplitTableDlg, ClickHdl, Button *, pButton )
81 {
82 	const bool bIsVert =  pButton == &maVertBox ;
83 	long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal;
84     maPropCB.Enable(!bIsVert);
85     maCountEdit.SetMax( nMax );
86 	return 0;
87 }
88 
89 bool SvxSplitTableDlg::IsHorizontal() const
90 {
91 	return maHorzBox.IsChecked();
92 }
93 
94 bool SvxSplitTableDlg::IsProportional() const
95 {
96 	return maPropCB.IsChecked() && maHorzBox.IsChecked();
97 }
98 
99 long SvxSplitTableDlg::GetCount() const
100 {
101 	return sal::static_int_cast<long>( maCountEdit.GetValue() );
102 }
103 
104 short SvxSplitTableDlg::Execute()
105 {
106 	return SvxStandardDialog::Execute();
107 }
108 
109 void SvxSplitTableDlg::Apply()
110 {
111 }
112