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 0 : IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl)
35 : {
36 0 : sal_uInt16 nId = (sal_uInt16)m_pColNF->GetValue()-1;
37 0 : const SwTwips lWidth = rFnc.GetColWidth(nId);
38 0 : m_pWidthMF->SetMax(m_pWidthMF->Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
39 0 : m_pWidthMF->SetValue(m_pWidthMF->Normalize(lWidth), FUNIT_TWIP);
40 0 : return 0;
41 : }
42 :
43 0 : SwTableWidthDlg::SwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rTableFnc )
44 : : SvxStandardDialog( pParent, "ColumnWidthDialog", "modules/swriter/ui/columnwidth.ui" )
45 0 : , rFnc(rTableFnc)
46 : {
47 0 : get(m_pColNF, "column");
48 0 : get(m_pWidthMF, "width");
49 :
50 0 : bool bIsWeb = rTableFnc.GetShell()
51 0 : && (0 != PTR_CAST( SwWebDocShell,
52 0 : rTableFnc.GetShell()->GetView().GetDocShell()) );
53 0 : FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
54 0 : ::SetFieldUnit(*m_pWidthMF, eFieldUnit);
55 :
56 0 : m_pColNF->SetValue( rFnc.GetCurColNum() +1 );
57 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(MINLAY), FUNIT_TWIP);
58 0 : if(!m_pWidthMF->GetMin())
59 0 : m_pWidthMF->SetMin(1);
60 :
61 0 : if(rFnc.GetColCount() == 0)
62 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
63 0 : m_pColNF->SetMax(rFnc.GetColCount() +1 );
64 0 : m_pColNF->SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
65 0 : LoseFocusHdl();
66 0 : }
67 :
68 0 : SwTableWidthDlg::~SwTableWidthDlg()
69 : {
70 0 : disposeOnce();
71 0 : }
72 :
73 0 : void SwTableWidthDlg::dispose()
74 : {
75 0 : m_pColNF.clear();
76 0 : m_pWidthMF.clear();
77 0 : SvxStandardDialog::dispose();
78 0 : }
79 :
80 0 : void SwTableWidthDlg::Apply()
81 : {
82 0 : rFnc.InitTabCols();
83 : rFnc.SetColWidth(
84 0 : static_cast< sal_uInt16 >(m_pColNF->GetValue() - 1),
85 0 : static_cast< sal_uInt16 >(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))));
86 0 : }
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|