bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / table / colwd.cxx
blob134cab20871f1a61356b2b96bb4f9baadcd33365
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
31 #include <cmdid.h>
32 #include <table.hrc>
35 IMPL_LINK_NOARG_INLINE_START(SwTableWidthDlg, LoseFocusHdl)
37 sal_uInt16 nId = (sal_uInt16)m_pColNF->GetValue()-1;
38 const SwTwips lWidth = rFnc.GetColWidth(nId);
39 m_pWidthMF->SetMax(m_pWidthMF->Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP);
40 m_pWidthMF->SetValue(m_pWidthMF->Normalize(lWidth), FUNIT_TWIP);
41 return 0;
43 IMPL_LINK_NOARG_INLINE_END(SwTableWidthDlg, LoseFocusHdl)
47 SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc )
48 : SvxStandardDialog( pParent, "ColumnWidthDialog", "modules/swriter/ui/columnwidth.ui" )
49 , rFnc(rTableFnc)
51 get(m_pColNF, "column");
52 get(m_pWidthMF, "width");
54 sal_Bool bIsWeb = rTableFnc.GetShell()
55 ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell,
56 rTableFnc.GetShell()->GetView().GetDocShell()) )
57 : sal_False;
58 FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
59 ::SetFieldUnit(*m_pWidthMF, eFieldUnit);
61 m_pColNF->SetValue( rFnc.GetCurColNum() +1 );
62 m_pWidthMF->SetMin(m_pWidthMF->Normalize(MINLAY), FUNIT_TWIP);
63 if(!m_pWidthMF->GetMin())
64 m_pWidthMF->SetMin(1);
66 if(rFnc.GetColCount() == 0)
67 m_pWidthMF->SetMin(m_pWidthMF->Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP);
68 m_pColNF->SetMax(rFnc.GetColCount() +1 );
69 m_pColNF->SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl));
70 LoseFocusHdl();
75 void SwTableWidthDlg::Apply()
77 rFnc.InitTabCols();
78 rFnc.SetColWidth(
79 static_cast< sal_uInt16 >(m_pColNF->GetValue() - 1),
80 static_cast< sal_uInt16 >(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))));
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */