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)));
35
37 if(eFrameSize != aSz.GetHeightSizeType())
38 {
39 aSz.SetHeightSizeType(eFrameSize);
40 }
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: */
void SetRowHeight(const SwFormatFrameSize &rSz)
Definition: fetab.cxx:898
std::unique_ptr< SwFormatFrameSize > GetRowHeight() const
Pointer must be destroyed by caller != 0.
Definition: fetab.cxx:906
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
SwWrtShell & m_rSh
Definition: rowht.hxx:28
SwTableHeightDlg(weld::Window *pParent, SwWrtShell &rS)
Definition: rowht.cxx:44
std::unique_ptr< weld::MetricSpinButton > m_xHeightEdit
Definition: rowht.hxx:30
virtual short run() override
Definition: rowht.cxx:64
std::unique_ptr< weld::CheckButton > m_xAutoHeightCB
Definition: rowht.hxx:31
void Apply()
Definition: rowht.cxx:31
SwDocShell * GetDocShell()
Definition: view.cxx:1193
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
const SwView & GetView() const
Definition: wrtsh.hxx:443
FieldUnit
SwFrameSize
Definition: fmtfsize.hxx:36
@ Fixed
Frame cannot be moved in Var-direction.
@ Minimum
Value in Var-direction gives minimum (can be exceeded but not be less).
#define SW_MOD()
Definition: swmodule.hxx:254
#define MINLAY
Definition: swtypes.hxx:62
tools::Long SwTwips
Definition: swtypes.hxx:51
RET_OK