LibreOffice Module sw (master) 1
envprt.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 <vcl/print.hxx>
21#include <svtools/prnsetup.hxx>
22#include <svtools/unitconv.hxx>
23
24#include <cmdid.h>
25#include "envprt.hxx"
26#include <envlop.hxx>
27#include <uitool.hxx>
28
30 : SfxTabPage(pPage, pController, "modules/swriter/ui/envprinterpage.ui", "EnvPrinterPage", &rSet)
31 , m_xUpper(m_xBuilder->weld_widget("upper"))
32 , m_xLower(m_xBuilder->weld_widget("lower"))
33 , m_xTopButton(m_xBuilder->weld_radio_button("top"))
34 , m_xBottomButton(m_xBuilder->weld_radio_button("bottom"))
35 , m_xRightField(m_xBuilder->weld_metric_spin_button("right", FieldUnit::CM))
36 , m_xDownField(m_xBuilder->weld_metric_spin_button("down", FieldUnit::CM))
37 , m_xPrinterInfo(m_xBuilder->weld_label("printername"))
38 , m_xPrtSetup(m_xBuilder->weld_button("setup"))
39 , m_aIdsL { m_xBuilder->weld_radio_button("horileftl"),
40 m_xBuilder->weld_radio_button("horicenterl"),
41 m_xBuilder->weld_radio_button("horirightl"),
42 m_xBuilder->weld_radio_button("vertleftl"),
43 m_xBuilder->weld_radio_button("vertcenterl"),
44 m_xBuilder->weld_radio_button("vertrightl") }
45 , m_aIdsU { m_xBuilder->weld_radio_button("horileftu"),
46 m_xBuilder->weld_radio_button("horicenteru"),
47 m_xBuilder->weld_radio_button("horirightu"),
48 m_xBuilder->weld_radio_button("vertleftu"),
49 m_xBuilder->weld_radio_button("vertcenteru"),
50 m_xBuilder->weld_radio_button("vertrightu") }
51{
53
54 // Metrics
55 FieldUnit eUnit = ::GetDfltMetric(false);
56 ::SetFieldUnit(*m_xRightField, eUnit);
57 ::SetFieldUnit(*m_xDownField, eUnit);
58
59 // Install handlers
60 m_xTopButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl));
61 m_xBottomButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl));
62
63 m_xPrtSetup->connect_clicked(LINK(this, SwEnvPrtPage, ButtonHdl));
64
65 for (auto& a : m_aIdsL)
66 a->connect_toggled(LINK(this, SwEnvPrtPage, LowerHdl));
67 for (auto& a : m_aIdsU)
68 a->connect_toggled(LINK(this, SwEnvPrtPage, UpperHdl));
69
70 // Bitmaps
71 ClickHdl(*m_xBottomButton);
72}
73
75{
76 m_xPrt.clear();
77}
78
80{
81 // Envelope from bottom, otherwise Envelope from top
82 const bool bLowerActive = m_xBottomButton->get_active();
83 m_xUpper->set_visible(!bLowerActive);
84 m_xLower->set_visible(bLowerActive);
85}
86
87IMPL_LINK(SwEnvPrtPage, LowerHdl, weld::Toggleable&, rButton, void)
88{
89 for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
90 {
91 if (&rButton == m_aIdsL[i].get())
92 {
93 m_aIdsU[i]->set_active(m_aIdsL[i]->get_active());
94 break;
95 }
96 }
97}
98
99IMPL_LINK(SwEnvPrtPage, UpperHdl, weld::Toggleable&, rButton, void)
100{
101 for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
102 {
103 if (&rButton == m_aIdsU[i].get())
104 {
105 m_aIdsL[i]->set_active(m_aIdsU[i]->get_active());
106 break;
107 }
108 }
109}
110
111IMPL_LINK(SwEnvPrtPage, ButtonHdl, weld::Button&, rBtn, void)
112{
113 if (&rBtn == m_xPrtSetup.get())
114 {
115 // Call printer setup
116 if (m_xPrt)
117 {
119 aDlg.SetPrinter(m_xPrt);
120 aDlg.run();
121 rBtn.grab_focus();
122 m_xPrinterInfo->set_label(m_xPrt->GetName());
123 }
124 }
125}
126
127std::unique_ptr<SfxTabPage> SwEnvPrtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
128{
129 return std::make_unique<SwEnvPrtPage>(pPage, pController, *rSet);
130}
131
133{
134 if (m_xPrt)
135 m_xPrinterInfo->set_label(m_xPrt->GetName());
136}
137
139{
140 if( _pSet )
141 FillItemSet(_pSet);
142 return DeactivateRC::LeavePage;
143}
144
146{
147 int nOrient = 0;
148 for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
149 {
150 assert(m_aIdsL[i]->get_active() == m_aIdsU[i]->get_active());
151 if (m_aIdsL[i]->get_active())
152 {
153 nOrient = i;
154 break;
155 }
156 }
157
158 rItem.m_eAlign = static_cast<SwEnvAlign>(nOrient);
159 rItem.m_bPrintFromAbove = m_xTopButton->get_active();
162}
163
165{
166 FillItem(GetParentSwEnvDlg()->m_aEnvItem);
167 rSet->Put(GetParentSwEnvDlg()->m_aEnvItem);
168 return true;
169}
170
172{
173 // Read item
174 const SwEnvItem& rItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP) );
175 m_aIdsL[rItem.m_eAlign]->set_active(true);
176 m_aIdsU[rItem.m_eAlign]->set_active(true);
177
178 if (rItem.m_bPrintFromAbove)
179 m_xTopButton->set_active(true);
180 else
181 m_xBottomButton->set_active(true);
182
185
187 ClickHdl(*m_xTopButton);
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual short run() override
void SetPrinter(Printer *pNewPrinter)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetExchangeSupport()
sal_Int32 m_nShiftDown
Definition: envimg.hxx:54
sal_Int32 m_nShiftRight
Definition: envimg.hxx:53
bool m_bPrintFromAbove
Definition: envimg.hxx:52
SwEnvAlign m_eAlign
Definition: envimg.hxx:51
std::unique_ptr< weld::RadioButton > m_aIdsL[ENV_VER_RGHT - ENV_HOR_LEFT+1]
Definition: envprt.hxx:42
void FillItem(SwEnvItem &rItem)
Definition: envprt.cxx:145
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: envprt.cxx:164
std::unique_ptr< weld::MetricSpinButton > m_xRightField
Definition: envprt.hxx:37
std::unique_ptr< weld::Label > m_xPrinterInfo
Definition: envprt.hxx:39
SwEnvDlg * GetParentSwEnvDlg()
Definition: envprt.hxx:52
std::unique_ptr< weld::RadioButton > m_xTopButton
Definition: envprt.hxx:35
std::unique_ptr< weld::Button > m_xPrtSetup
Definition: envprt.hxx:40
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: envprt.cxx:138
std::unique_ptr< weld::RadioButton > m_xBottomButton
Definition: envprt.hxx:36
std::unique_ptr< weld::RadioButton > m_aIdsU[ENV_VER_RGHT - ENV_HOR_LEFT+1]
Definition: envprt.hxx:43
virtual void Reset(const SfxItemSet *rSet) override
Definition: envprt.cxx:171
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: envprt.cxx:127
SwEnvPrtPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: envprt.cxx:29
std::unique_ptr< weld::MetricSpinButton > m_xDownField
Definition: envprt.hxx:38
virtual ~SwEnvPrtPage() override
Definition: envprt.cxx:74
VclPtr< Printer > m_xPrt
Definition: envprt.hxx:45
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: envprt.cxx:132
void clear()
#define FN_ENVELOP
Definition: cmdid.h:784
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwEnvAlign
Definition: envimg.hxx:29
@ ENV_VER_RGHT
Definition: envimg.hxx:35
@ ENV_HOR_LEFT
Definition: envimg.hxx:30
int getfieldval(const weld::MetricSpinButton &rField)
Definition: envlop.hxx:30
void setfieldval(weld::MetricSpinButton &rField, int lValue)
Definition: envlop.hxx:35
IMPL_LINK(SwEnvPrtPage, LowerHdl, weld::Toggleable &, rButton, void)
Definition: envprt.cxx:87
IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl, weld::Toggleable &, void)
Definition: envprt.cxx:79
FieldUnit
uno_Any a
int i
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static SfxItemSet & rSet
DeactivateRC
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:756