1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svtools/prnsetup.hxx>
#include <unotools/cmdoptions.hxx>
#include <vcl/print.hxx>
#include <label.hxx>
#include "labprt.hxx"
#include <labimg.hxx>
SwLabPrtPage::SwLabPrtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
: SfxTabPage(pPage, pController, "modules/swriter/ui/labeloptionspage.ui", "LabelOptionsPage", &rSet)
, m_pPrinter(nullptr)
, m_xPageButton(m_xBuilder->weld_radio_button("entirepage"))
, m_xSingleButton(m_xBuilder->weld_radio_button("singlelabel"))
, m_xSingleGrid(m_xBuilder->weld_widget("singlegrid"))
, m_xPrinterFrame(m_xBuilder->weld_widget("printerframe"))
, m_xColField(m_xBuilder->weld_spin_button("cols"))
, m_xRowField(m_xBuilder->weld_spin_button("rows"))
, m_xSynchronCB(m_xBuilder->weld_check_button("synchronize"))
, m_xPrinterInfo(m_xBuilder->weld_label("printername"))
, m_xPrtSetup(m_xBuilder->weld_button("setup"))
{
SetExchangeSupport();
// Install handlers
Link<weld::Toggleable&,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
m_xPageButton->connect_toggled(aLk);
m_xSingleButton->connect_toggled(aLk);
m_xPrtSetup->connect_clicked(LINK(this, SwLabPrtPage, PrtSetupHdl));
SvtCommandOptions aCmdOpts;
if (aCmdOpts.LookupDisabled("Print"))
{
m_xPrinterFrame->hide();
}
}
SwLabPrtPage::~SwLabPrtPage()
{
m_pPrinter.disposeAndClear();
}
IMPL_LINK( SwLabPrtPage, PrtSetupHdl, weld::Button&, rButton, void )
{
// Call printer setup
if (!m_pPrinter)
m_pPrinter = VclPtr<Printer>::Create();
PrinterSetupDialog aDlg(GetFrameWeld());
aDlg.SetPrinter(m_pPrinter);
aDlg.run();
rButton.grab_focus();
m_xPrinterInfo->set_label(m_pPrinter->GetName());
}
IMPL_LINK(SwLabPrtPage, CountHdl, weld::Toggleable&, rButton, void)
{
if (!rButton.get_active())
return;
const bool bEnable = m_xSingleButton->get_active();
m_xSingleGrid->set_sensitive(bEnable);
m_xSynchronCB->set_sensitive(!bEnable);
if (bEnable)
m_xColField->grab_focus();
}
std::unique_ptr<SfxTabPage> SwLabPrtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
{
return std::make_unique<SwLabPrtPage>(pPage, pController, *rSet );
}
void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
{
Reset(&rSet);
}
DeactivateRC SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
{
if ( _pSet )
FillItemSet(_pSet);
return DeactivateRC::LeavePage;
}
void SwLabPrtPage::FillItem(SwLabItem& rItem)
{
rItem.m_bPage = m_xPageButton->get_active();
rItem.m_nCol = m_xColField->get_value();
rItem.m_nRow = m_xRowField->get_value();
rItem.m_bSynchron = m_xSynchronCB->get_active() && m_xSynchronCB->get_sensitive();
}
bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet)
{
SwLabItem aItem;
GetParentSwLabDlg()->GetLabItem(aItem);
FillItem(aItem);
rSet->Put(aItem);
return true;
}
void SwLabPrtPage::Reset(const SfxItemSet* )
{
SwLabItem aItem;
GetParentSwLabDlg()->GetLabItem(aItem);
m_xColField->set_value(aItem.m_nCol);
m_xRowField->set_value(aItem.m_nRow);
if (aItem.m_bPage)
{
m_xPageButton->set_active(true);
CountHdl(*m_xPageButton);
}
else
{
CountHdl(*m_xSingleButton);
m_xSingleButton->set_active(true);
}
if (m_pPrinter)
{
// show printer
m_xPrinterInfo->set_label(m_pPrinter->GetName());
}
else
m_xPrinterInfo->set_label(Printer::GetDefaultPrinterName());
m_xColField->set_max(aItem.m_nCols);
m_xRowField->set_max(aItem.m_nRows);
m_xSynchronCB->set_active(aItem.m_bSynchron);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|