xref: /aoo42x/main/sw/source/ui/table/rowht.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_sw.hxx"
30 
31 #ifdef SW_DLLIMPLEMENTATION
32 #undef SW_DLLIMPLEMENTATION
33 #endif
34 
35 
36 #include <svl/intitem.hxx>
37 #include <svl/eitem.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <svx/dlgutil.hxx>
40 
41 
42 #include <fmtfsize.hxx>
43 #include <swtypes.hxx>
44 #include <rowht.hxx>
45 #include <wrtsh.hxx>
46 #include <frmatr.hxx>
47 #ifndef _WDOCSH_HXX
48 #include <wdocsh.hxx>
49 #endif
50 #ifndef _VIEW_HXX
51 #include <view.hxx>
52 #endif
53 #include <swmodule.hxx>
54 #include <usrpref.hxx>
55 
56 #ifndef _CMDID_H
57 #include <cmdid.h>
58 #endif
59 #ifndef _ROWHT_HRC
60 #include <rowht.hrc>
61 #endif
62 #ifndef _TABLE_HRC
63 #include <table.hrc>
64 #endif
65 
66 
67 
68 
69 void SwTableHeightDlg::Apply()
70 {
71     SwTwips nHeight = static_cast< SwTwips >(aHeightEdit.Denormalize(aHeightEdit.GetValue(FUNIT_TWIP)));
72 	SwFmtFrmSize aSz(ATT_FIX_SIZE, 0, nHeight);
73 
74 	SwFrmSize eFrmSize = (SwFrmSize) aAutoHeightCB.IsChecked() ?
75 		ATT_MIN_SIZE : ATT_FIX_SIZE;
76     if(eFrmSize != aSz.GetHeightSizeType())
77 	{
78         aSz.SetHeightSizeType(eFrmSize);
79 	}
80 	rSh.SetRowHeight( aSz );
81 }
82 
83 // CTOR / DTOR -----------------------------------------------------------
84 
85 
86 SwTableHeightDlg::SwTableHeightDlg( Window *pParent, SwWrtShell &rS ) :
87 
88 	SvxStandardDialog(pParent, SW_RES(DLG_ROW_HEIGHT)),
89     aHeightFL(this, SW_RES(FL_HEIGHT)),
90 
91 	aHeightEdit(this, SW_RES(ED_HEIGHT)),
92 	aAutoHeightCB(this, SW_RES(CB_AUTOHEIGHT)),
93 	aOKBtn(this, SW_RES(BT_OK)),
94 	aCancelBtn(this, SW_RES(BT_CANCEL)),
95 	aHelpBtn( this, SW_RES( BT_HELP ) ),
96 	rSh( rS )
97 {
98 	FreeResource();
99 
100 	FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( 0 != PTR_CAST( SwWebDocShell,
101 								rSh.GetView().GetDocShell() ) )->GetMetric();
102 	::SetFieldUnit( aHeightEdit, eFieldUnit );
103 
104 	aHeightEdit.SetMin(MINLAY, FUNIT_TWIP);
105 	if(!aHeightEdit.GetMin())
106 		aHeightEdit.SetMin(1);
107 	SwFmtFrmSize *pSz;
108 	rSh.GetRowHeight( pSz );
109 	if ( pSz )
110 	{
111 		long nHeight = pSz->GetHeight();
112         aAutoHeightCB.Check(pSz->GetHeightSizeType() != ATT_FIX_SIZE);
113 		aHeightEdit.SetValue(aHeightEdit.Normalize(nHeight), FUNIT_TWIP);
114 
115 		delete pSz;
116 	}
117 }
118 
119 
120 
121