Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svtools/prnsetup.hxx>
30 : : #include <unotools/cmdoptions.hxx>
31 : : #include <vcl/print.hxx>
32 : : #include <wrtsh.hxx>
33 : : #include <label.hxx>
34 : : #include <labprt.hxx>
35 : : #include <labimg.hxx>
36 : : #include "swuilabimp.hxx"
37 : :
38 : : #include <cmdid.h>
39 : : #include <labprt.hrc>
40 : :
41 : 0 : SwLabPrtPage::SwLabPrtPage(Window* pParent, const SfxItemSet& rSet) :
42 : :
43 : : SfxTabPage(pParent, SW_RES(TP_LAB_PRT), rSet),
44 : :
45 : : pPrinter( 0 ),
46 : : aFLDontKnow (this, SW_RES(FL_DONTKNOW)),
47 : : aPageButton (this, SW_RES(BTN_PAGE )),
48 : : aSingleButton (this, SW_RES(BTN_SINGLE )),
49 : : aColText (this, SW_RES(TXT_COL )),
50 : : aColField (this, SW_RES(FLD_COL )),
51 : : aRowText (this, SW_RES(TXT_ROW )),
52 : : aRowField (this, SW_RES(FLD_ROW )),
53 : : aSynchronCB (this, SW_RES(CB_SYNCHRON)),
54 : : aFLPrinter (this, SW_RES(FL_PRINTER )),
55 : : aPrinterInfo (this, SW_RES(INF_PRINTER)),
56 : 0 : aPrtSetup (this, SW_RES(BTN_PRTSETUP))
57 : :
58 : : {
59 : 0 : FreeResource();
60 : 0 : SetExchangeSupport();
61 : :
62 : : // Install handlers
63 : 0 : Link aLk = LINK(this, SwLabPrtPage, CountHdl);
64 : 0 : aPageButton .SetClickHdl( aLk );
65 : 0 : aSingleButton.SetClickHdl( aLk );
66 : :
67 : 0 : aPrtSetup.SetClickHdl( aLk );
68 : :
69 : 0 : SvtCommandOptions aCmdOpts;
70 : 0 : if ( aCmdOpts.Lookup(
71 : : SvtCommandOptions::CMDOPTION_DISABLED,
72 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) ) )
73 : : {
74 : 0 : aPrinterInfo.Hide();
75 : 0 : aPrtSetup.Hide();
76 : 0 : aFLPrinter.Hide();
77 : 0 : }
78 : 0 : }
79 : :
80 : 0 : SwLabPrtPage::~SwLabPrtPage()
81 : : {
82 : 0 : delete pPrinter;
83 : 0 : }
84 : :
85 : 0 : IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton )
86 : : {
87 : 0 : if (pButton == &aPrtSetup)
88 : : {
89 : : // Call printer setup
90 : 0 : if (!pPrinter)
91 : 0 : pPrinter = new Printer;
92 : :
93 : 0 : PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
94 : 0 : pDlg->SetPrinter(pPrinter);
95 : 0 : pDlg->Execute();
96 : 0 : delete pDlg;
97 : 0 : GrabFocus();
98 : 0 : aPrinterInfo.SetText(pPrinter->GetName());
99 : 0 : return 0;
100 : : }
101 : 0 : const sal_Bool bEnable = pButton == &aSingleButton;
102 : 0 : aColText .Enable(bEnable);
103 : 0 : aColField.Enable(bEnable);
104 : 0 : aRowText .Enable(bEnable);
105 : 0 : aRowField.Enable(bEnable);
106 : 0 : aSynchronCB.Enable(!bEnable);
107 : :
108 : : OSL_ENSURE(!bEnable || pButton == &aPageButton, "NewButton?" );
109 : 0 : if ( bEnable )
110 : : {
111 : 0 : aColField.GrabFocus();
112 : : }
113 : 0 : return 0;
114 : : }
115 : :
116 : 0 : SfxTabPage* SwLabPrtPage::Create(Window* pParent, const SfxItemSet& rSet)
117 : : {
118 : 0 : return new SwLabPrtPage( pParent, rSet );
119 : : }
120 : :
121 : 0 : void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
122 : : {
123 : 0 : Reset(rSet);
124 : 0 : }
125 : :
126 : 0 : int SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
127 : : {
128 : 0 : if ( _pSet )
129 : 0 : FillItemSet(*_pSet);
130 : :
131 : 0 : return sal_True;
132 : : }
133 : :
134 : 0 : void SwLabPrtPage::FillItem(SwLabItem& rItem)
135 : : {
136 : 0 : rItem.bPage = aPageButton.IsChecked();
137 : 0 : rItem.nCol = (sal_uInt16) aColField.GetValue();
138 : 0 : rItem.nRow = (sal_uInt16) aRowField.GetValue();
139 : 0 : rItem.bSynchron = aSynchronCB.IsChecked() && aSynchronCB.IsEnabled();
140 : 0 : }
141 : :
142 : 0 : sal_Bool SwLabPrtPage::FillItemSet(SfxItemSet& rSet)
143 : : {
144 : 0 : SwLabItem aItem;
145 : 0 : GetParent()->GetLabItem(aItem);
146 : 0 : FillItem(aItem);
147 : 0 : rSet.Put(aItem);
148 : :
149 : 0 : return sal_True;
150 : : }
151 : :
152 : 0 : void SwLabPrtPage::Reset(const SfxItemSet& )
153 : : {
154 : 0 : SwLabItem aItem;
155 : 0 : GetParent()->GetLabItem(aItem);
156 : :
157 : 0 : aColField.SetValue (aItem.nCol);
158 : 0 : aRowField.SetValue (aItem.nRow);
159 : :
160 : 0 : if (aItem.bPage)
161 : : {
162 : 0 : aPageButton.Check();
163 : 0 : aPageButton.GetClickHdl().Call(&aPageButton);
164 : : }
165 : : else
166 : : {
167 : 0 : aSingleButton.GetClickHdl().Call(&aSingleButton);
168 : 0 : aSingleButton.Check();
169 : : }
170 : :
171 : 0 : if (pPrinter)
172 : : {
173 : : // show printer
174 : 0 : aPrinterInfo.SetText(pPrinter->GetName());
175 : : }
176 : : else
177 : 0 : aPrinterInfo.SetText(Printer::GetDefaultPrinterName());
178 : :
179 : 0 : aColField.SetMax(aItem.nCols);
180 : 0 : aRowField.SetMax(aItem.nRows);
181 : :
182 : 0 : aColField.SetLast(aColField.GetMax());
183 : 0 : aRowField.SetLast(aRowField.GetMax());
184 : :
185 : 0 : aSynchronCB.Check(aItem.bSynchron);
186 : 0 : }
187 : :
188 : :
189 : :
190 : :
191 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|