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