LibreOffice Module sw (master)  1
rowht.cxx
Go to the documentation of this file.
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 <svtools/unitconv.hxx>
21 
22 #include <fmtfsize.hxx>
23 #include <swtypes.hxx>
24 #include <rowht.hxx>
25 #include <wrtsh.hxx>
26 #include <wdocsh.hxx>
27 #include <view.hxx>
28 #include <swmodule.hxx>
29 #include <usrpref.hxx>
30 
32 {
33  SwTwips nHeight = static_cast< SwTwips >(m_xHeightEdit->denormalize(m_xHeightEdit->get_value(FieldUnit::TWIP)));
34  SwFormatFrameSize aSz(SwFrameSize::Fixed, 0, nHeight);
35 
37  if(eFrameSize != aSz.GetHeightSizeType())
38  {
39  aSz.SetHeightSizeType(eFrameSize);
40  }
41  m_rSh.SetRowHeight(aSz);
42 }
43 
45  : GenericDialogController(pParent, "modules/swriter/ui/rowheight.ui", "RowHeightDialog")
46  , m_rSh(rS)
47  , m_xHeightEdit(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM))
48  , m_xAutoHeightCB(m_xBuilder->weld_check_button("fit"))
49 {
50  FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( dynamic_cast< const SwWebDocShell*>(
51  m_rSh.GetView().GetDocShell() ) != nullptr )->GetMetric();
52  ::SetFieldUnit(*m_xHeightEdit, eFieldUnit);
53 
54  m_xHeightEdit->set_min(MINLAY, FieldUnit::TWIP);
55  std::unique_ptr<SwFormatFrameSize> pSz = m_rSh.GetRowHeight();
56  if (pSz)
57  {
58  auto nHeight = pSz->GetHeight();
59  m_xAutoHeightCB->set_active(pSz->GetHeightSizeType() != SwFrameSize::Fixed);
60  m_xHeightEdit->set_value(m_xHeightEdit->normalize(nHeight), FieldUnit::TWIP);
61  }
62 }
63 
65 {
66  short nRet = GenericDialogController::run();
67  if (nRet == RET_OK)
68  Apply();
69  return nRet;
70 }
71 
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FieldUnit
virtual short run() override
Definition: rowht.cxx:64
#define MINLAY
Definition: swtypes.hxx:66
long SwTwips
Definition: swtypes.hxx:49
std::unique_ptr< SwFormatFrameSize > GetRowHeight() const
Pointer must be destroyed by caller != 0.
Definition: fetab.cxx:724
Value in Var-direction gives minimum (can be exceeded but not be less).
SwWrtShell & m_rSh
Definition: rowht.hxx:28
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
const SwView & GetView() const
Definition: wrtsh.hxx:428
void Apply()
Definition: rowht.cxx:31
std::unique_ptr< weld::MetricSpinButton > m_xHeightEdit
Definition: rowht.hxx:30
#define SW_MOD()
Definition: swmodule.hxx:256
void SetRowHeight(const SwFormatFrameSize &rSz)
Definition: fetab.cxx:716
SwTableHeightDlg(weld::Window *pParent, SwWrtShell &rS)
Definition: rowht.cxx:44
SwFrameSize
Definition: fmtfsize.hxx:35
Frame cannot be moved in Var-direction.
SwDocShell * GetDocShell()
Definition: view.cxx:1107
RET_OK
std::unique_ptr< weld::CheckButton > m_xAutoHeightCB
Definition: rowht.hxx:31
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80