xref: /aoo41x/main/sw/source/ui/table/colwd.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33cdf0e10cSrcweir #include <svx/dlgutil.hxx>
34cdf0e10cSrcweir #include <colwd.hxx>
35cdf0e10cSrcweir #include <tablemgr.hxx>
36cdf0e10cSrcweir #include <wrtsh.hxx>
37cdf0e10cSrcweir #ifndef _WDOCSH_HXX
38cdf0e10cSrcweir #include <wdocsh.hxx>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #ifndef _VIEW_HXX
41cdf0e10cSrcweir #include <view.hxx>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #include <swmodule.hxx>
44cdf0e10cSrcweir #ifndef _MODCFG_HXX
45cdf0e10cSrcweir #include <modcfg.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #include <usrpref.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #ifndef _CMDID_H
50cdf0e10cSrcweir #include <cmdid.h>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #ifndef _COLWD_HRC
53cdf0e10cSrcweir #include <colwd.hrc>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _TABLE_HRC
56cdf0e10cSrcweir #include <table.hrc>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(SwTableWidthDlg,LoseFocusHdl,Edit *,EMPTYARG)60cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	sal_uInt16 nId = (sal_uInt16)aColEdit.GetValue()-1;
63cdf0e10cSrcweir 	const SwTwips lWidth = rFnc.GetColWidth(nId);
64cdf0e10cSrcweir 	aWidthEdit.SetValue(aWidthEdit.Normalize(lWidth), FUNIT_TWIP);
65cdf0e10cSrcweir 	aWidthEdit.SetMax(aWidthEdit.Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
66cdf0e10cSrcweir 	return 0;
67cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwTableWidthDlg,LoseFocusHdl,Edit *,EMPTYARG)68cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc ) :
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	SvxStandardDialog( pParent, SW_RES(DLG_COL_WIDTH) ),
75cdf0e10cSrcweir     aWidthFL(this,     SW_RES(FL_WIDTH)),
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	aColFT(this, 		SW_RES(FT_COL)),
78cdf0e10cSrcweir 	aColEdit(this, 		SW_RES(ED_COL)),
79cdf0e10cSrcweir     aWidthFT(this, 		SW_RES(FT_WIDTH)),
80cdf0e10cSrcweir 	aWidthEdit(this, 	SW_RES(ED_WIDTH)),
81cdf0e10cSrcweir 	aOKBtn(this, 		SW_RES(BT_OK)),
82cdf0e10cSrcweir 	aCancelBtn(this, 	SW_RES(BT_CANCEL)),
83cdf0e10cSrcweir 	aHelpBtn(this, 		SW_RES(BT_HELP)),
84cdf0e10cSrcweir 	rFnc(rTableFnc)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	FreeResource();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	sal_Bool bIsWeb = rTableFnc.GetShell()
89cdf0e10cSrcweir                     ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
90cdf0e10cSrcweir                             rTableFnc.GetShell()->GetView().GetDocShell()) )
91cdf0e10cSrcweir 					: sal_False;
92cdf0e10cSrcweir 	FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
93cdf0e10cSrcweir 	::SetFieldUnit(aWidthEdit, eFieldUnit );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	aColEdit.SetValue( rFnc.GetCurColNum() +1 );
96cdf0e10cSrcweir 	aWidthEdit.SetMin(aWidthEdit.Normalize(MINLAY), FUNIT_TWIP);
97cdf0e10cSrcweir 	if(!aWidthEdit.GetMin())
98cdf0e10cSrcweir 		aWidthEdit.SetMin(1);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	if(rFnc.GetColCount() == 0)
101cdf0e10cSrcweir 		aWidthEdit.SetMin(aWidthEdit.Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
102cdf0e10cSrcweir 	aColEdit.SetMax(rFnc.GetColCount() +1 );
103cdf0e10cSrcweir 	aColEdit.SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
104cdf0e10cSrcweir 	LoseFocusHdl();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
Apply()109cdf0e10cSrcweir void SwTableWidthDlg::Apply()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	rFnc.InitTabCols();
112cdf0e10cSrcweir     rFnc.SetColWidth(
113cdf0e10cSrcweir             static_cast< sal_uInt16 >(aColEdit.GetValue() - 1),
114cdf0e10cSrcweir             static_cast< sal_uInt16 >(aWidthEdit.Denormalize(aWidthEdit.GetValue(FUNIT_TWIP))));
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120