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