Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <sfx2/dispatch.hxx>
21 : #include <svx/dlgutil.hxx>
22 : #include <colwd.hxx>
23 : #include <tablemgr.hxx>
24 : #include <wrtsh.hxx>
25 : #include <wdocsh.hxx>
26 : #include <view.hxx>
27 : #include <swmodule.hxx>
28 : #include <modcfg.hxx>
29 : #include <usrpref.hxx>
30 :
31 : #include <cmdid.h>
32 : #include <table.hrc>
33 :
34 :
35 0 : IMPL_LINK_NOARG_INLINE_START(SwTableWidthDlg, LoseFocusHdl)
36 : {
37 0 : sal_uInt16 nId = (sal_uInt16)m_pColNF->GetValue()-1;
38 0 : const SwTwips lWidth = rFnc.GetColWidth(nId);
39 0 : m_pWidthMF->SetMax(m_pWidthMF->Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
40 0 : m_pWidthMF->SetValue(m_pWidthMF->Normalize(lWidth), FUNIT_TWIP);
41 0 : return 0;
42 : }
43 0 : IMPL_LINK_NOARG_INLINE_END(SwTableWidthDlg, LoseFocusHdl)
44 :
45 :
46 :
47 0 : SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc )
48 : : SvxStandardDialog( pParent, "ColumnWidthDialog", "modules/swriter/ui/columnwidth.ui" )
49 0 : , rFnc(rTableFnc)
50 : {
51 0 : get(m_pColNF, "column");
52 0 : get(m_pWidthMF, "width");
53 :
54 0 : sal_Bool bIsWeb = rTableFnc.GetShell()
55 0 : ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
56 : rTableFnc.GetShell()->GetView().GetDocShell()) )
57 0 : : sal_False;
58 0 : FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
59 0 : ::SetFieldUnit(*m_pWidthMF, eFieldUnit);
60 :
61 0 : m_pColNF->SetValue( rFnc.GetCurColNum() +1 );
62 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(MINLAY), FUNIT_TWIP);
63 0 : if(!m_pWidthMF->GetMin())
64 0 : m_pWidthMF->SetMin(1);
65 :
66 0 : if(rFnc.GetColCount() == 0)
67 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
68 0 : m_pColNF->SetMax(rFnc.GetColCount() +1 );
69 0 : m_pColNF->SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
70 0 : LoseFocusHdl();
71 0 : }
72 :
73 :
74 :
75 0 : void SwTableWidthDlg::Apply()
76 : {
77 0 : rFnc.InitTabCols();
78 : rFnc.SetColWidth(
79 0 : static_cast< sal_uInt16 >(m_pColNF->GetValue() - 1),
80 0 : static_cast< sal_uInt16 >(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))));
81 0 : }
82 :
83 :
84 :
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|