Mark some visible strings in ui files as translatable
[LibreOffice.git] / sw / source / ui / table / colwd.cxx
blob67a6bd7bfbfc087b9f7535463107d4385ab3b3ce
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 <svtools/unitconv.hxx>
21 #include <colwd.hxx>
22 #include <tablemgr.hxx>
23 #include <wrtsh.hxx>
24 #include <wdocsh.hxx>
25 #include <view.hxx>
26 #include <swmodule.hxx>
27 #include <usrpref.hxx>
29 IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl, weld::SpinButton&, void)
31 sal_uInt16 nId = o3tl::narrowing<sal_uInt16>(m_xColNF->get_value()) - 1;
32 const SwTwips lWidth = m_xFnc->GetColWidth(nId);
33 m_xWidthMF->set_max(m_xWidthMF->normalize(m_xFnc->GetMaxColWidth(nId)), FieldUnit::TWIP);
34 m_xWidthMF->set_value(m_xWidthMF->normalize(lWidth), FieldUnit::TWIP);
37 SwTableWidthDlg::SwTableWidthDlg(weld::Window *pParent, SwWrtShell *pShell)
38 : GenericDialogController(pParent, u"modules/swriter/ui/columnwidth.ui"_ustr, u"ColumnWidthDialog"_ustr)
39 , m_xFnc(new SwTableFUNC(pShell))
40 , m_xColNF(m_xBuilder->weld_spin_button(u"column"_ustr))
41 , m_xWidthMF(m_xBuilder->weld_metric_spin_button(u"width"_ustr, FieldUnit::CM))
43 m_xFnc->InitTabCols();
44 bool bIsWeb = m_xFnc->GetShell()
45 && (dynamic_cast< const SwWebDocShell* >(
46 m_xFnc->GetShell()->GetView().GetDocShell()) != nullptr );
47 FieldUnit eFieldUnit = SwModule::get()->GetUsrPref(bIsWeb)->GetMetric();
48 ::SetFieldUnit(*m_xWidthMF, eFieldUnit);
50 m_xColNF->set_max(m_xFnc->GetColCount() + 1);
51 m_xColNF->set_value(m_xFnc->GetCurColNum() + 1);
53 if (m_xFnc->GetColCount() == 0)
54 m_xWidthMF->set_min(m_xWidthMF->normalize(m_xFnc->GetColWidth(0)), FieldUnit::TWIP);
55 else
56 m_xWidthMF->set_min(m_xWidthMF->normalize(MINLAY), FieldUnit::TWIP);
57 m_xColNF->connect_value_changed(LINK(this, SwTableWidthDlg, LoseFocusHdl));
58 LoseFocusHdl(*m_xColNF);
61 SwTableWidthDlg::~SwTableWidthDlg() {}
63 void SwTableWidthDlg::Apply()
65 m_xFnc->InitTabCols();
66 m_xFnc->SetColWidth(o3tl::narrowing<sal_uInt16>(m_xColNF->get_value() - 1),
67 o3tl::narrowing<sal_uInt16>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))));
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */