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_INLINE_START(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 0 : IMPL_LINK_NOARG_INLINE_END(SwTableWidthDlg, LoseFocusHdl)
43 :
44 0 : SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc )
45 : : SvxStandardDialog( pParent, "ColumnWidthDialog", "modules/swriter/ui/columnwidth.ui" )
46 0 : , rFnc(rTableFnc)
47 : {
48 0 : get(m_pColNF, "column");
49 0 : get(m_pWidthMF, "width");
50 :
51 0 : sal_Bool bIsWeb = rTableFnc.GetShell()
52 0 : ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
53 : rTableFnc.GetShell()->GetView().GetDocShell()) )
54 0 : : sal_False;
55 0 : FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
56 0 : ::SetFieldUnit(*m_pWidthMF, eFieldUnit);
57 :
58 0 : m_pColNF->SetValue( rFnc.GetCurColNum() +1 );
59 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(MINLAY), FUNIT_TWIP);
60 0 : if(!m_pWidthMF->GetMin())
61 0 : m_pWidthMF->SetMin(1);
62 :
63 0 : if(rFnc.GetColCount() == 0)
64 0 : m_pWidthMF->SetMin(m_pWidthMF->Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
65 0 : m_pColNF->SetMax(rFnc.GetColCount() +1 );
66 0 : m_pColNF->SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
67 0 : LoseFocusHdl();
68 0 : }
69 :
70 0 : void SwTableWidthDlg::Apply()
71 : {
72 0 : rFnc.InitTabCols();
73 : rFnc.SetColWidth(
74 0 : static_cast< sal_uInt16 >(m_pColNF->GetValue() - 1),
75 0 : static_cast< sal_uInt16 >(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))));
76 0 : }
77 :
78 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|