1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <svtools/prnsetup.hxx>
33cdf0e10cSrcweir #include <unotools/cmdoptions.hxx>
34cdf0e10cSrcweir #include <vcl/print.hxx>
35cdf0e10cSrcweir #include <wrtsh.hxx>
36cdf0e10cSrcweir #include <label.hxx>
37cdf0e10cSrcweir #include <labprt.hxx>
38cdf0e10cSrcweir #include <labimg.hxx>
39cdf0e10cSrcweir #ifndef _LABIMP_HXX
40cdf0e10cSrcweir #include "swuilabimp.hxx"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir
43cdf0e10cSrcweir #ifndef _CMDID_H
44cdf0e10cSrcweir #include <cmdid.h>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #ifndef _LABPRT_HRC
47cdf0e10cSrcweir #include <labprt.hrc>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir
50cdf0e10cSrcweir
51cdf0e10cSrcweir // --------------------------------------------------------------------------
52cdf0e10cSrcweir
53cdf0e10cSrcweir
54cdf0e10cSrcweir
SwLabPrtPage(Window * pParent,const SfxItemSet & rSet)55cdf0e10cSrcweir SwLabPrtPage::SwLabPrtPage(Window* pParent, const SfxItemSet& rSet) :
56cdf0e10cSrcweir
57cdf0e10cSrcweir SfxTabPage(pParent, SW_RES(TP_LAB_PRT), rSet),
58cdf0e10cSrcweir
59cdf0e10cSrcweir pPrinter( 0 ),
60cdf0e10cSrcweir aFLDontKnow (this, SW_RES(FL_DONTKNOW)),
61cdf0e10cSrcweir aPageButton (this, SW_RES(BTN_PAGE )),
62cdf0e10cSrcweir aSingleButton (this, SW_RES(BTN_SINGLE )),
63cdf0e10cSrcweir aColText (this, SW_RES(TXT_COL )),
64cdf0e10cSrcweir aColField (this, SW_RES(FLD_COL )),
65cdf0e10cSrcweir aRowText (this, SW_RES(TXT_ROW )),
66cdf0e10cSrcweir aRowField (this, SW_RES(FLD_ROW )),
67cdf0e10cSrcweir aSynchronCB (this, SW_RES(CB_SYNCHRON)),
68cdf0e10cSrcweir aFLPrinter (this, SW_RES(FL_PRINTER )),
69cdf0e10cSrcweir aPrinterInfo (this, SW_RES(INF_PRINTER)),
70cdf0e10cSrcweir aPrtSetup (this, SW_RES(BTN_PRTSETUP))
71cdf0e10cSrcweir
72cdf0e10cSrcweir {
73cdf0e10cSrcweir FreeResource();
74cdf0e10cSrcweir SetExchangeSupport();
75cdf0e10cSrcweir
76cdf0e10cSrcweir // Handler installieren
77cdf0e10cSrcweir Link aLk = LINK(this, SwLabPrtPage, CountHdl);
78cdf0e10cSrcweir aPageButton .SetClickHdl( aLk );
79cdf0e10cSrcweir aSingleButton.SetClickHdl( aLk );
80cdf0e10cSrcweir
81cdf0e10cSrcweir aPrtSetup.SetClickHdl( aLk );
82cdf0e10cSrcweir
83cdf0e10cSrcweir SvtCommandOptions aCmdOpts;
84cdf0e10cSrcweir if ( aCmdOpts.Lookup(
85cdf0e10cSrcweir SvtCommandOptions::CMDOPTION_DISABLED,
86cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) ) )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir aPrinterInfo.Hide();
89cdf0e10cSrcweir aPrtSetup.Hide();
90cdf0e10cSrcweir aFLPrinter.Hide();
91cdf0e10cSrcweir }
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir // --------------------------------------------------------------------------
95cdf0e10cSrcweir
96cdf0e10cSrcweir
97cdf0e10cSrcweir
~SwLabPrtPage()98cdf0e10cSrcweir SwLabPrtPage::~SwLabPrtPage()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir if (pPrinter)
101cdf0e10cSrcweir delete pPrinter;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir // --------------------------------------------------------------------------
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir
IMPL_LINK(SwLabPrtPage,CountHdl,Button *,pButton)108cdf0e10cSrcweir IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if (pButton == &aPrtSetup)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir // Druck-Setup aufrufen
113cdf0e10cSrcweir if (!pPrinter)
114cdf0e10cSrcweir pPrinter = new Printer;
115cdf0e10cSrcweir
116cdf0e10cSrcweir PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
117cdf0e10cSrcweir pDlg->SetPrinter(pPrinter);
118cdf0e10cSrcweir pDlg->Execute();
119cdf0e10cSrcweir delete pDlg;
120cdf0e10cSrcweir GrabFocus();
121cdf0e10cSrcweir aPrinterInfo.SetText(pPrinter->GetName());
122cdf0e10cSrcweir return 0;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir const sal_Bool bEnable = pButton == &aSingleButton;
125cdf0e10cSrcweir aColText .Enable(bEnable);
126cdf0e10cSrcweir aColField.Enable(bEnable);
127cdf0e10cSrcweir aRowText .Enable(bEnable);
128cdf0e10cSrcweir aRowField.Enable(bEnable);
129cdf0e10cSrcweir aSynchronCB.Enable(!bEnable);
130cdf0e10cSrcweir
131cdf0e10cSrcweir if ( bEnable )
132cdf0e10cSrcweir aColField.GrabFocus();
133cdf0e10cSrcweir #ifdef DBG_UTIL
134cdf0e10cSrcweir else
135cdf0e10cSrcweir ASSERT( pButton == &aPageButton, "NewButton?" );
136cdf0e10cSrcweir #endif
137cdf0e10cSrcweir return 0;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir // --------------------------------------------------------------------------
141cdf0e10cSrcweir
142cdf0e10cSrcweir
143cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rSet)144cdf0e10cSrcweir SfxTabPage* SwLabPrtPage::Create(Window* pParent, const SfxItemSet& rSet)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir return new SwLabPrtPage( pParent, rSet );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir // --------------------------------------------------------------------------
150cdf0e10cSrcweir
151cdf0e10cSrcweir
152cdf0e10cSrcweir
ActivatePage(const SfxItemSet & rSet)153cdf0e10cSrcweir void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir Reset(rSet);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir // --------------------------------------------------------------------------
159cdf0e10cSrcweir
160cdf0e10cSrcweir
161cdf0e10cSrcweir
DeactivatePage(SfxItemSet * _pSet)162cdf0e10cSrcweir int SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir if ( _pSet )
165cdf0e10cSrcweir FillItemSet(*_pSet);
166cdf0e10cSrcweir
167cdf0e10cSrcweir return sal_True;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir // --------------------------------------------------------------------------
171cdf0e10cSrcweir
172cdf0e10cSrcweir
173cdf0e10cSrcweir
FillItem(SwLabItem & rItem)174cdf0e10cSrcweir void SwLabPrtPage::FillItem(SwLabItem& rItem)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir rItem.bPage = aPageButton.IsChecked();
177cdf0e10cSrcweir rItem.nCol = (sal_uInt16) aColField.GetValue();
178cdf0e10cSrcweir rItem.nRow = (sal_uInt16) aRowField.GetValue();
179cdf0e10cSrcweir rItem.bSynchron = aSynchronCB.IsChecked() && aSynchronCB.IsEnabled();
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir // --------------------------------------------------------------------------
183cdf0e10cSrcweir
184cdf0e10cSrcweir
185cdf0e10cSrcweir
FillItemSet(SfxItemSet & rSet)186cdf0e10cSrcweir sal_Bool SwLabPrtPage::FillItemSet(SfxItemSet& rSet)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir SwLabItem aItem;
189cdf0e10cSrcweir GetParent()->GetLabItem(aItem);
190cdf0e10cSrcweir FillItem(aItem);
191cdf0e10cSrcweir rSet.Put(aItem);
192cdf0e10cSrcweir
193cdf0e10cSrcweir return sal_True;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir // --------------------------------------------------------------------------
197cdf0e10cSrcweir
198cdf0e10cSrcweir
199cdf0e10cSrcweir
Reset(const SfxItemSet &)200cdf0e10cSrcweir void SwLabPrtPage::Reset(const SfxItemSet& )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir SwLabItem aItem;
203cdf0e10cSrcweir GetParent()->GetLabItem(aItem);
204cdf0e10cSrcweir
205cdf0e10cSrcweir aColField.SetValue (aItem.nCol);
206cdf0e10cSrcweir aRowField.SetValue (aItem.nRow);
207cdf0e10cSrcweir
208cdf0e10cSrcweir if (aItem.bPage)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir aPageButton.Check();
211cdf0e10cSrcweir aPageButton.GetClickHdl().Call(&aPageButton);
212cdf0e10cSrcweir }
213cdf0e10cSrcweir else
214cdf0e10cSrcweir {
215cdf0e10cSrcweir aSingleButton.GetClickHdl().Call(&aSingleButton);
216cdf0e10cSrcweir aSingleButton.Check();
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
219cdf0e10cSrcweir if (pPrinter)
220cdf0e10cSrcweir {
221cdf0e10cSrcweir // Drucker anzeigen
222cdf0e10cSrcweir aPrinterInfo.SetText(pPrinter->GetName());
223cdf0e10cSrcweir }
224cdf0e10cSrcweir else
225cdf0e10cSrcweir aPrinterInfo.SetText(Printer::GetDefaultPrinterName());
226cdf0e10cSrcweir
227cdf0e10cSrcweir aColField.SetMax(aItem.nCols);
228cdf0e10cSrcweir aRowField.SetMax(aItem.nRows);
229cdf0e10cSrcweir
230cdf0e10cSrcweir aColField.SetLast(aColField.GetMax());
231cdf0e10cSrcweir aRowField.SetLast(aRowField.GetMax());
232cdf0e10cSrcweir
233cdf0e10cSrcweir aSynchronCB.Check(aItem.bSynchron);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir
237cdf0e10cSrcweir
238cdf0e10cSrcweir
239