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 <svl/intitem.hxx>
21 #include <svl/eitem.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <svx/dlgutil.hxx>
24 #include <svtools/unitconv.hxx>
25 
26 #include <fmtfsize.hxx>
27 #include <swtypes.hxx>
28 #include <rowht.hxx>
29 #include <wrtsh.hxx>
30 #include <frmatr.hxx>
31 #include <wdocsh.hxx>
32 #include <view.hxx>
33 #include <swmodule.hxx>
34 #include <usrpref.hxx>
35 
36 #include <cmdid.h>
37 
39 {
40  SwTwips nHeight = static_cast< SwTwips >(m_xHeightEdit->denormalize(m_xHeightEdit->get_value(FieldUnit::TWIP)));
41  SwFormatFrameSize aSz(ATT_FIX_SIZE, 0, nHeight);
42 
43  SwFrameSize eFrameSize = m_xAutoHeightCB->get_active() ? ATT_MIN_SIZE : ATT_FIX_SIZE;
44  if(eFrameSize != aSz.GetHeightSizeType())
45  {
46  aSz.SetHeightSizeType(eFrameSize);
47  }
48  m_rSh.SetRowHeight(aSz);
49 }
50 
52  : GenericDialogController(pParent, "modules/swriter/ui/rowheight.ui", "RowHeightDialog")
53  , m_rSh(rS)
54  , m_xHeightEdit(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM))
55  , m_xAutoHeightCB(m_xBuilder->weld_check_button("fit"))
56 {
57  FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( dynamic_cast< const SwWebDocShell*>(
58  m_rSh.GetView().GetDocShell() ) != nullptr )->GetMetric();
59  ::SetFieldUnit(*m_xHeightEdit, eFieldUnit);
60 
61  m_xHeightEdit->set_min(MINLAY, FieldUnit::TWIP);
62  std::unique_ptr<SwFormatFrameSize> pSz = m_rSh.GetRowHeight();
63  if (pSz)
64  {
65  auto nHeight = pSz->GetHeight();
66  m_xAutoHeightCB->set_active(pSz->GetHeightSizeType() != ATT_FIX_SIZE);
67  m_xHeightEdit->set_value(m_xHeightEdit->normalize(nHeight), FieldUnit::TWIP);
68  }
69 }
70 
72 {
73  short nRet = GenericDialogController::run();
74  if (nRet == RET_OK)
75  Apply();
76  return nRet;
77 }
78 
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FieldUnit
virtual short run() override
Definition: rowht.cxx:71
#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:726
Frame cannot be moved in Var-direction.
Definition: fmtfsize.hxx:38
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
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
void Apply()
Definition: rowht.cxx:38
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:718
SwTableHeightDlg(weld::Window *pParent, SwWrtShell &rS)
Definition: rowht.cxx:51
SwFrameSize
Definition: fmtfsize.hxx:35
SwDocShell * GetDocShell()
Definition: view.cxx:1127
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