Update ooo320-m1
[ooovba.git] / sw / source / ui / table / colwd.cxx
blob325881453746ccdf8d6ecc43d11bbc1d41ef0643
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: colwd.cxx,v $
10 * $Revision: 1.11 $
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 <sfx2/dispatch.hxx>
40 #include <svx/dlgutil.hxx>
41 #include <colwd.hxx>
42 #include <tablemgr.hxx>
43 #include <wrtsh.hxx>
44 #ifndef _WDOCSH_HXX
45 #include <wdocsh.hxx>
46 #endif
47 #ifndef _VIEW_HXX
48 #include <view.hxx>
49 #endif
50 #include <swmodule.hxx>
51 #ifndef _MODCFG_HXX
52 #include <modcfg.hxx>
53 #endif
54 #include <usrpref.hxx>
56 #ifndef _CMDID_H
57 #include <cmdid.h>
58 #endif
59 #ifndef _COLWD_HRC
60 #include <colwd.hrc>
61 #endif
62 #ifndef _TABLE_HRC
63 #include <table.hrc>
64 #endif
67 IMPL_LINK_INLINE_START( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
69 USHORT nId = (USHORT)aColEdit.GetValue()-1;
70 const SwTwips lWidth = rFnc.GetColWidth(nId);
71 aWidthEdit.SetValue(aWidthEdit.Normalize(lWidth), FUNIT_TWIP);
72 aWidthEdit.SetMax(aWidthEdit.Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
73 return 0;
75 IMPL_LINK_INLINE_END( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
79 SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc ) :
81 SvxStandardDialog( pParent, SW_RES(DLG_COL_WIDTH) ),
83 aColFT(this, SW_RES(FT_COL)),
84 aColEdit(this, SW_RES(ED_COL)),
85 aWidthFT(this, SW_RES(FT_WIDTH)),
86 aWidthEdit(this, SW_RES(ED_WIDTH)),
87 aWidthFL(this, SW_RES(FL_WIDTH)),
88 aOKBtn(this, SW_RES(BT_OK)),
89 aCancelBtn(this, SW_RES(BT_CANCEL)),
90 aHelpBtn(this, SW_RES(BT_HELP)),
91 rFnc(rTableFnc)
93 FreeResource();
95 BOOL bIsWeb = rTableFnc.GetShell()
96 ? static_cast< BOOL >(0 != PTR_CAST( SwWebDocShell,
97 rTableFnc.GetShell()->GetView().GetDocShell()) )
98 : FALSE;
99 FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
100 ::SetFieldUnit(aWidthEdit, eFieldUnit );
102 aColEdit.SetValue( rFnc.GetCurColNum() +1 );
103 aWidthEdit.SetMin(aWidthEdit.Normalize(MINLAY), FUNIT_TWIP);
104 if(!aWidthEdit.GetMin())
105 aWidthEdit.SetMin(1);
107 if(rFnc.GetColCount() == 0)
108 aWidthEdit.SetMin(aWidthEdit.Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
109 aColEdit.SetMax(rFnc.GetColCount() +1 );
110 aColEdit.SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
111 LoseFocusHdl();
116 void SwTableWidthDlg::Apply()
118 rFnc.InitTabCols();
119 rFnc.SetColWidth(
120 static_cast< USHORT >(aColEdit.GetValue() - 1),
121 static_cast< USHORT >(aWidthEdit.Denormalize(aWidthEdit.GetValue(FUNIT_TWIP))));