LibreOffice Module dbaccess (master) 1
dlgsize.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 <dlgsize.hxx>
21
22namespace dbaui
23{
24
25#define DEF_ROW_HEIGHT 45
26#define DEF_COL_WIDTH 227
27
28DlgSize::DlgSize(weld::Window* pParent, sal_Int32 nVal, bool bRow, sal_Int32 _nAlternativeStandard )
29 : GenericDialogController(pParent, bRow ? OUString("dbaccess/ui/rowheightdialog.ui") : OUString("dbaccess/ui/colwidthdialog.ui"),
30 bRow ? OUString("RowHeightDialog") : OUString("ColWidthDialog"))
31 , m_nPrevValue(nVal)
32 , m_xMF_VALUE(m_xBuilder->weld_metric_spin_button("value", FieldUnit::CM))
33 , m_xCB_STANDARD(m_xBuilder->weld_check_button("automatic"))
34{
35 sal_Int32 nStandard(bRow ? DEF_ROW_HEIGHT : DEF_COL_WIDTH);
36 if ( _nAlternativeStandard > 0 )
37 nStandard = _nAlternativeStandard;
38 m_xCB_STANDARD->connect_toggled(LINK(this,DlgSize,CbClickHdl));
39
40 bool bDefault = -1 == nVal;
41 m_xCB_STANDARD->set_active(bDefault);
42 if (bDefault)
43 {
44 SetValue(nStandard);
45 m_nPrevValue = nStandard;
46 }
47 CbClickHdl(*m_xCB_STANDARD);
48}
49
51{
52}
53
54void DlgSize::SetValue( sal_Int32 nVal )
55{
56 m_xMF_VALUE->set_value(nVal, FieldUnit::CM );
57}
58
59sal_Int32 DlgSize::GetValue() const
60{
61 if (m_xCB_STANDARD->get_active())
62 return -1;
63 return static_cast<sal_Int32>(m_xMF_VALUE->get_value( FieldUnit::CM ));
64}
65
67{
68 m_xMF_VALUE->set_sensitive(!m_xCB_STANDARD->get_active());
69 if (m_xCB_STANDARD->get_active())
70 {
71 // don't use getValue as this will use m_xCB_STANDARD->to determine if we're standard
72 m_nPrevValue = static_cast<sal_Int32>(m_xMF_VALUE->get_value(FieldUnit::CM));
73 m_xMF_VALUE->set_text("");
74 }
75 else
76 {
77 SetValue(m_nPrevValue);
78 }
79}
80
81} // namespace dbaui
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DlgSize(weld::Window *pParent, sal_Int32 nVal, bool bRow, sal_Int32 _nAlternativeStandard=-1)
Definition: dlgsize.cxx:28
virtual ~DlgSize() override
Definition: dlgsize.cxx:50
sal_Int32 GetValue() const
Definition: dlgsize.cxx:59
std::unique_ptr< weld::CheckButton > m_xCB_STANDARD
Definition: dlgsize.hxx:35
sal_Int32 m_nPrevValue
Definition: dlgsize.hxx:29
void SetValue(sal_Int32 nVal)
Definition: dlgsize.cxx:54
std::unique_ptr< weld::MetricSpinButton > m_xMF_VALUE
Definition: dlgsize.hxx:34
virtual void SetValue(tools::Long nNew) override
#define DEF_COL_WIDTH
Definition: dlgsize.cxx:26
#define DEF_ROW_HEIGHT
Definition: dlgsize.cxx:25
FieldUnit
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)