LibreOffice Module sw (master) 1
labprt.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/prnsetup.hxx>
22#include <vcl/print.hxx>
23#include <label.hxx>
24#include "labprt.hxx"
25#include <labimg.hxx>
26
28 : SfxTabPage(pPage, pController, "modules/swriter/ui/labeloptionspage.ui", "LabelOptionsPage", &rSet)
29 , pPrinter(nullptr)
30 , m_xPageButton(m_xBuilder->weld_radio_button("entirepage"))
31 , m_xSingleButton(m_xBuilder->weld_radio_button("singlelabel"))
32 , m_xSingleGrid(m_xBuilder->weld_widget("singlegrid"))
33 , m_xPrinterFrame(m_xBuilder->weld_widget("printerframe"))
34 , m_xColField(m_xBuilder->weld_spin_button("cols"))
35 , m_xRowField(m_xBuilder->weld_spin_button("rows"))
36 , m_xSynchronCB(m_xBuilder->weld_check_button("synchronize"))
37 , m_xPrinterInfo(m_xBuilder->weld_label("printername"))
38 , m_xPrtSetup(m_xBuilder->weld_button("setup"))
39{
41
42 // Install handlers
43 Link<weld::Toggleable&,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
44 m_xPageButton->connect_toggled(aLk);
45 m_xSingleButton->connect_toggled(aLk);
46 m_xPrtSetup->connect_clicked(LINK(this, SwLabPrtPage, PrtSetupHdl));
47
48 SvtCommandOptions aCmdOpts;
49 if (aCmdOpts.Lookup(SvtCommandOptions::CMDOPTION_DISABLED, "Print"))
50 {
51 m_xPrinterFrame->hide();
52 }
53}
54
56{
58}
59
60IMPL_LINK( SwLabPrtPage, PrtSetupHdl, weld::Button&, rButton, void )
61{
62 // Call printer setup
63 if (!pPrinter)
64 pPrinter = VclPtr<Printer>::Create();
65
67 aDlg.SetPrinter(pPrinter);
68 aDlg.run();
69 rButton.grab_focus();
70 m_xPrinterInfo->set_label(pPrinter->GetName());
71}
72
73IMPL_LINK(SwLabPrtPage, CountHdl, weld::Toggleable&, rButton, void)
74{
75 if (!rButton.get_active())
76 return;
77
78 const bool bEnable = m_xSingleButton->get_active();
79 m_xSingleGrid->set_sensitive(bEnable);
80 m_xSynchronCB->set_sensitive(!bEnable);
81
82 if (bEnable)
83 m_xColField->grab_focus();
84}
85
86std::unique_ptr<SfxTabPage> SwLabPrtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
87{
88 return std::make_unique<SwLabPrtPage>(pPage, pController, *rSet );
89}
90
92{
93 Reset(&rSet);
94}
95
97{
98 if ( _pSet )
99 FillItemSet(_pSet);
100
101 return DeactivateRC::LeavePage;
102}
103
105{
106 rItem.m_bPage = m_xPageButton->get_active();
107 rItem.m_nCol = m_xColField->get_value();
108 rItem.m_nRow = m_xRowField->get_value();
109 rItem.m_bSynchron = m_xSynchronCB->get_active() && m_xSynchronCB->get_sensitive();
110}
111
113{
114 SwLabItem aItem;
116 FillItem(aItem);
117 rSet->Put(aItem);
118
119 return true;
120}
121
123{
124 SwLabItem aItem;
126
127 m_xColField->set_value(aItem.m_nCol);
128 m_xRowField->set_value(aItem.m_nRow);
129
130 if (aItem.m_bPage)
131 {
132 m_xPageButton->set_active(true);
133 CountHdl(*m_xPageButton);
134 }
135 else
136 {
137 CountHdl(*m_xSingleButton);
138 m_xSingleButton->set_active(true);
139 }
140
141 if (pPrinter)
142 {
143 // show printer
144 m_xPrinterInfo->set_label(pPrinter->GetName());
145 }
146 else
148
149 m_xColField->set_max(aItem.m_nCols);
150 m_xRowField->set_max(aItem.m_nRows);
151
152 m_xSynchronCB->set_active(aItem.m_bSynchron);
153}
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual short run() override
void SetPrinter(Printer *pNewPrinter)
static OUString GetDefaultPrinterName()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetExchangeSupport()
bool Lookup(CmdOption eOption, const OUString &aCommandURL) const
void GetLabItem(SwLabItem &rItem)
Definition: label1.cxx:158
sal_Int32 m_nRows
Definition: labimg.hxx:57
bool m_bPage
Definition: labimg.hxx:64
sal_Int32 m_nCol
Definition: labimg.hxx:58
sal_Int32 m_nCols
Definition: labimg.hxx:56
sal_Int32 m_nRow
Definition: labimg.hxx:59
bool m_bSynchron
Definition: labimg.hxx:65
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: labprt.cxx:96
std::unique_ptr< weld::SpinButton > m_xRowField
Definition: labprt.hxx:38
std::unique_ptr< weld::SpinButton > m_xColField
Definition: labprt.hxx:37
VclPtr< Printer > pPrinter
Definition: labprt.hxx:31
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: labprt.cxx:91
std::unique_ptr< weld::Button > m_xPrtSetup
Definition: labprt.hxx:41
std::unique_ptr< weld::Label > m_xPrinterInfo
Definition: labprt.hxx:40
virtual void Reset(const SfxItemSet *rSet) override
Definition: labprt.cxx:122
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: labprt.cxx:86
std::unique_ptr< weld::RadioButton > m_xSingleButton
Definition: labprt.hxx:34
void FillItem(SwLabItem &rItem)
Definition: labprt.cxx:104
std::unique_ptr< weld::Widget > m_xPrinterFrame
Definition: labprt.hxx:36
SwLabPrtPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: labprt.cxx:27
SwLabDlg * GetParentSwLabDlg()
Definition: labprt.hxx:46
virtual ~SwLabPrtPage() override
Definition: labprt.cxx:55
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: labprt.cxx:112
std::unique_ptr< weld::RadioButton > m_xPageButton
Definition: labprt.hxx:33
std::unique_ptr< weld::CheckButton > m_xSynchronCB
Definition: labprt.hxx:39
void disposeAndClear()
static VclPtr< reference_type > Create(Arg &&... arg)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
IMPL_LINK(SwLabPrtPage, PrtSetupHdl, weld::Button &, rButton, void)
Definition: labprt.cxx:60
static SfxItemSet & rSet
DeactivateRC