xref: /AOO42X/main/sw/source/ui/table/colwd.cxx (revision bf1b25cd889b02ff0f0810153811f35fe632c3fe)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #ifdef SW_DLLIMPLEMENTATION
26 #undef SW_DLLIMPLEMENTATION
27 #endif
28 
29 #include <sfx2/dispatch.hxx>
30 #include <svx/dlgutil.hxx>
31 #include <colwd.hxx>
32 #include <tablemgr.hxx>
33 #include <wrtsh.hxx>
34 #ifndef _WDOCSH_HXX
35 #include <wdocsh.hxx>
36 #endif
37 #ifndef _VIEW_HXX
38 #include <view.hxx>
39 #endif
40 #include <swmodule.hxx>
41 #ifndef _MODCFG_HXX
42 #include <modcfg.hxx>
43 #endif
44 #include <usrpref.hxx>
45 
46 #ifndef _CMDID_H
47 #include <cmdid.h>
48 #endif
49 #ifndef _COLWD_HRC
50 #include <colwd.hrc>
51 #endif
52 #ifndef _TABLE_HRC
53 #include <table.hrc>
54 #endif
55 
IMPL_LINK_INLINE_START(SwTableWidthDlg,LoseFocusHdl,Edit *,EMPTYARG)56 IMPL_LINK_INLINE_START( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
57 {
58     sal_uInt16 nId = (sal_uInt16)aColEdit.GetValue()-1;
59     const SwTwips lWidth = rFnc.GetColWidth(nId);
60     aWidthEdit.SetValue(aWidthEdit.Normalize(lWidth), FUNIT_TWIP);
61     aWidthEdit.SetMax(aWidthEdit.Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
62     return 0;
63 }
IMPL_LINK_INLINE_END(SwTableWidthDlg,LoseFocusHdl,Edit *,EMPTYARG)64 IMPL_LINK_INLINE_END( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG )
65 
66 
67 SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc ) :
68 
69     SvxStandardDialog( pParent, SW_RES(DLG_COL_WIDTH) ),
70     aWidthFL(this,      SW_RES(FL_WIDTH)),
71 
72     aColFT(this,        SW_RES(FT_COL)),
73     aColEdit(this,      SW_RES(ED_COL)),
74     aWidthFT(this,      SW_RES(FT_WIDTH)),
75     aWidthEdit(this,    SW_RES(ED_WIDTH)),
76     aOKBtn(this,        SW_RES(BT_OK)),
77     aCancelBtn(this,    SW_RES(BT_CANCEL)),
78     aHelpBtn(this,      SW_RES(BT_HELP)),
79     rFnc(rTableFnc)
80 {
81     FreeResource();
82 
83     sal_Bool bIsWeb = rTableFnc.GetShell()
84                     ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
85                             rTableFnc.GetShell()->GetView().GetDocShell()) )
86                     : sal_False;
87     FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
88     ::SetFieldUnit(aWidthEdit, eFieldUnit );
89 
90     aColEdit.SetValue( rFnc.GetCurColNum() +1 );
91     aWidthEdit.SetMin(aWidthEdit.Normalize(MINLAY), FUNIT_TWIP);
92     if(!aWidthEdit.GetMin())
93         aWidthEdit.SetMin(1);
94 
95     if(rFnc.GetColCount() == 0)
96         aWidthEdit.SetMin(aWidthEdit.Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
97     aColEdit.SetMax(rFnc.GetColCount() +1 );
98     aColEdit.SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
99     LoseFocusHdl();
100 }
101 
102 
Apply()103 void SwTableWidthDlg::Apply()
104 {
105     rFnc.InitTabCols();
106     rFnc.SetColWidth(
107             static_cast< sal_uInt16 >(aColEdit.GetValue() - 1),
108             static_cast< sal_uInt16 >(aWidthEdit.Denormalize(aWidthEdit.GetValue(FUNIT_TWIP))));
109 }
110 
111 /* vim: set noet sw=4 ts=4: */
112