merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / table / rowht.cxx
blobedf6938c05d779426badcfbbc5135d1616e00e58
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rowht.cxx,v $
10 * $Revision: 1.12 $
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
36 #endif
39 #include <svtools/intitem.hxx>
40 #include <svtools/eitem.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <svx/dlgutil.hxx>
45 #include <fmtfsize.hxx>
46 #include <swtypes.hxx>
47 #include <rowht.hxx>
48 #include <wrtsh.hxx>
49 #include <frmatr.hxx>
50 #ifndef _WDOCSH_HXX
51 #include <wdocsh.hxx>
52 #endif
53 #ifndef _VIEW_HXX
54 #include <view.hxx>
55 #endif
56 #include <swmodule.hxx>
57 #include <usrpref.hxx>
59 #ifndef _CMDID_H
60 #include <cmdid.h>
61 #endif
62 #ifndef _ROWHT_HRC
63 #include <rowht.hrc>
64 #endif
65 #ifndef _TABLE_HRC
66 #include <table.hrc>
67 #endif
72 void SwTableHeightDlg::Apply()
74 SwTwips nHeight = static_cast< SwTwips >(aHeightEdit.Denormalize(aHeightEdit.GetValue(FUNIT_TWIP)));
75 SwFmtFrmSize aSz(ATT_FIX_SIZE, 0, nHeight);
77 SwFrmSize eFrmSize = (SwFrmSize) aAutoHeightCB.IsChecked() ?
78 ATT_MIN_SIZE : ATT_FIX_SIZE;
79 if(eFrmSize != aSz.GetHeightSizeType())
81 aSz.SetHeightSizeType(eFrmSize);
83 rSh.SetRowHeight( aSz );
86 // CTOR / DTOR -----------------------------------------------------------
89 SwTableHeightDlg::SwTableHeightDlg( Window *pParent, SwWrtShell &rS ) :
91 SvxStandardDialog(pParent, SW_RES(DLG_ROW_HEIGHT)),
93 aHeightEdit(this, SW_RES(ED_HEIGHT)),
94 aAutoHeightCB(this, SW_RES(CB_AUTOHEIGHT)),
95 aHeightFL(this, SW_RES(FL_HEIGHT)),
96 aOKBtn(this, SW_RES(BT_OK)),
97 aCancelBtn(this, SW_RES(BT_CANCEL)),
98 aHelpBtn( this, SW_RES( BT_HELP ) ),
99 rSh( rS )
101 FreeResource();
103 FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( 0 != PTR_CAST( SwWebDocShell,
104 rSh.GetView().GetDocShell() ) )->GetMetric();
105 ::SetFieldUnit( aHeightEdit, eFieldUnit );
107 aHeightEdit.SetMin(MINLAY, FUNIT_TWIP);
108 if(!aHeightEdit.GetMin())
109 aHeightEdit.SetMin(1);
110 SwFmtFrmSize *pSz;
111 rSh.GetRowHeight( pSz );
112 if ( pSz )
114 long nHeight = pSz->GetHeight();
115 aAutoHeightCB.Check(pSz->GetHeightSizeType() != ATT_FIX_SIZE);
116 aHeightEdit.SetValue(aHeightEdit.Normalize(nHeight), FUNIT_TWIP);
118 delete pSz;