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: colwd.cxx,v $
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/dispatch.hxx>
40 #include <svx/dlgutil.hxx>
42 #include <tablemgr.hxx>
50 #include <swmodule.hxx>
54 #include <usrpref.hxx>
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
);
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
)),
95 BOOL bIsWeb
= rTableFnc
.GetShell()
96 ? static_cast< BOOL
>(0 != PTR_CAST( SwWebDocShell
,
97 rTableFnc
.GetShell()->GetView().GetDocShell()) )
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
));
116 void SwTableWidthDlg::Apply()
120 static_cast< USHORT
>(aColEdit
.GetValue() - 1),
121 static_cast< USHORT
>(aWidthEdit
.Denormalize(aWidthEdit
.GetValue(FUNIT_TWIP
))));