Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/dispatch.hxx>
30 : : #include <svx/dlgutil.hxx>
31 : : #include <colwd.hxx>
32 : : #include <tablemgr.hxx>
33 : : #include <wrtsh.hxx>
34 : : #include <wdocsh.hxx>
35 : : #include <view.hxx>
36 : : #include <swmodule.hxx>
37 : : #include <modcfg.hxx>
38 : : #include <usrpref.hxx>
39 : :
40 : : #include <cmdid.h>
41 : : #include <colwd.hrc>
42 : : #include <table.hrc>
43 : :
44 : :
45 : 0 : IMPL_LINK_NOARG_INLINE_START(SwTableWidthDlg, LoseFocusHdl)
46 : : {
47 : 0 : sal_uInt16 nId = (sal_uInt16)aColEdit.GetValue()-1;
48 : 0 : const SwTwips lWidth = rFnc.GetColWidth(nId);
49 : 0 : aWidthEdit.SetValue(aWidthEdit.Normalize(lWidth), FUNIT_TWIP);
50 : 0 : aWidthEdit.SetMax(aWidthEdit.Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
51 : 0 : return 0;
52 : : }
53 : 0 : IMPL_LINK_NOARG_INLINE_END(SwTableWidthDlg, LoseFocusHdl)
54 : :
55 : :
56 : :
57 : 0 : SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc ) :
58 : :
59 : : SvxStandardDialog( pParent, SW_RES(DLG_COL_WIDTH) ),
60 : : aWidthFL(this, SW_RES(FL_WIDTH)),
61 : :
62 : : aColFT(this, SW_RES(FT_COL)),
63 : : aColEdit(this, SW_RES(ED_COL)),
64 : : aWidthFT(this, SW_RES(FT_WIDTH)),
65 : : aWidthEdit(this, SW_RES(ED_WIDTH)),
66 : : aOKBtn(this, SW_RES(BT_OK)),
67 : : aCancelBtn(this, SW_RES(BT_CANCEL)),
68 : : aHelpBtn(this, SW_RES(BT_HELP)),
69 : 0 : rFnc(rTableFnc)
70 : : {
71 : 0 : FreeResource();
72 : :
73 : 0 : sal_Bool bIsWeb = rTableFnc.GetShell()
74 : 0 : ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
75 : : rTableFnc.GetShell()->GetView().GetDocShell()) )
76 : 0 : : sal_False;
77 : 0 : FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
78 : 0 : ::SetFieldUnit(aWidthEdit, eFieldUnit );
79 : :
80 : 0 : aColEdit.SetValue( rFnc.GetCurColNum() +1 );
81 : 0 : aWidthEdit.SetMin(aWidthEdit.Normalize(MINLAY), FUNIT_TWIP);
82 : 0 : if(!aWidthEdit.GetMin())
83 : 0 : aWidthEdit.SetMin(1);
84 : :
85 : 0 : if(rFnc.GetColCount() == 0)
86 : 0 : aWidthEdit.SetMin(aWidthEdit.Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
87 : 0 : aColEdit.SetMax(rFnc.GetColCount() +1 );
88 : 0 : aColEdit.SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
89 : 0 : LoseFocusHdl();
90 : 0 : }
91 : :
92 : :
93 : :
94 : 0 : void SwTableWidthDlg::Apply()
95 : : {
96 : 0 : rFnc.InitTabCols();
97 : : rFnc.SetColWidth(
98 : 0 : static_cast< sal_uInt16 >(aColEdit.GetValue() - 1),
99 : 0 : static_cast< sal_uInt16 >(aWidthEdit.Denormalize(aWidthEdit.GetValue(FUNIT_TWIP))));
100 : 0 : }
101 : :
102 : :
103 : :
104 : :
105 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|