Line data Source code
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>
21 : #include <unotools/cmdoptions.hxx>
22 : #include <vcl/print.hxx>
23 : #include <wrtsh.hxx>
24 : #include <label.hxx>
25 : #include <labprt.hxx>
26 : #include <labimg.hxx>
27 : #include "swuilabimp.hxx"
28 :
29 : #include <cmdid.h>
30 : #include <labprt.hrc>
31 :
32 0 : SwLabPrtPage::SwLabPrtPage(Window* pParent, const SfxItemSet& rSet) :
33 :
34 : SfxTabPage(pParent, SW_RES(TP_LAB_PRT), rSet),
35 :
36 : pPrinter( 0 ),
37 : aFLDontKnow (this, SW_RES(FL_DONTKNOW)),
38 : aPageButton (this, SW_RES(BTN_PAGE )),
39 : aSingleButton (this, SW_RES(BTN_SINGLE )),
40 : aColText (this, SW_RES(TXT_COL )),
41 : aColField (this, SW_RES(FLD_COL )),
42 : aRowText (this, SW_RES(TXT_ROW )),
43 : aRowField (this, SW_RES(FLD_ROW )),
44 : aSynchronCB (this, SW_RES(CB_SYNCHRON)),
45 : aFLPrinter (this, SW_RES(FL_PRINTER )),
46 : aPrinterInfo (this, SW_RES(INF_PRINTER)),
47 0 : aPrtSetup (this, SW_RES(BTN_PRTSETUP))
48 :
49 : {
50 0 : FreeResource();
51 0 : SetExchangeSupport();
52 :
53 : // Install handlers
54 0 : Link aLk = LINK(this, SwLabPrtPage, CountHdl);
55 0 : aPageButton .SetClickHdl( aLk );
56 0 : aSingleButton.SetClickHdl( aLk );
57 :
58 0 : aPrtSetup.SetClickHdl( aLk );
59 :
60 0 : SvtCommandOptions aCmdOpts;
61 0 : if ( aCmdOpts.Lookup(
62 : SvtCommandOptions::CMDOPTION_DISABLED,
63 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) ) )
64 : {
65 0 : aPrinterInfo.Hide();
66 0 : aPrtSetup.Hide();
67 0 : aFLPrinter.Hide();
68 0 : }
69 0 : }
70 :
71 0 : SwLabPrtPage::~SwLabPrtPage()
72 : {
73 0 : delete pPrinter;
74 0 : }
75 :
76 0 : IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton )
77 : {
78 0 : if (pButton == &aPrtSetup)
79 : {
80 : // Call printer setup
81 0 : if (!pPrinter)
82 0 : pPrinter = new Printer;
83 :
84 0 : PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
85 0 : pDlg->SetPrinter(pPrinter);
86 0 : pDlg->Execute();
87 0 : delete pDlg;
88 0 : GrabFocus();
89 0 : aPrinterInfo.SetText(pPrinter->GetName());
90 0 : return 0;
91 : }
92 0 : const sal_Bool bEnable = pButton == &aSingleButton;
93 0 : aColText .Enable(bEnable);
94 0 : aColField.Enable(bEnable);
95 0 : aRowText .Enable(bEnable);
96 0 : aRowField.Enable(bEnable);
97 0 : aSynchronCB.Enable(!bEnable);
98 :
99 : OSL_ENSURE(!bEnable || pButton == &aPageButton, "NewButton?" );
100 0 : if ( bEnable )
101 : {
102 0 : aColField.GrabFocus();
103 : }
104 0 : return 0;
105 : }
106 :
107 0 : SfxTabPage* SwLabPrtPage::Create(Window* pParent, const SfxItemSet& rSet)
108 : {
109 0 : return new SwLabPrtPage( pParent, rSet );
110 : }
111 :
112 0 : void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
113 : {
114 0 : Reset(rSet);
115 0 : }
116 :
117 0 : int SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
118 : {
119 0 : if ( _pSet )
120 0 : FillItemSet(*_pSet);
121 :
122 0 : return sal_True;
123 : }
124 :
125 0 : void SwLabPrtPage::FillItem(SwLabItem& rItem)
126 : {
127 0 : rItem.bPage = aPageButton.IsChecked();
128 0 : rItem.nCol = (sal_uInt16) aColField.GetValue();
129 0 : rItem.nRow = (sal_uInt16) aRowField.GetValue();
130 0 : rItem.bSynchron = aSynchronCB.IsChecked() && aSynchronCB.IsEnabled();
131 0 : }
132 :
133 0 : sal_Bool SwLabPrtPage::FillItemSet(SfxItemSet& rSet)
134 : {
135 0 : SwLabItem aItem;
136 0 : GetParentSwLabDlg()->GetLabItem(aItem);
137 0 : FillItem(aItem);
138 0 : rSet.Put(aItem);
139 :
140 0 : return sal_True;
141 : }
142 :
143 0 : void SwLabPrtPage::Reset(const SfxItemSet& )
144 : {
145 0 : SwLabItem aItem;
146 0 : GetParentSwLabDlg()->GetLabItem(aItem);
147 :
148 0 : aColField.SetValue (aItem.nCol);
149 0 : aRowField.SetValue (aItem.nRow);
150 :
151 0 : if (aItem.bPage)
152 : {
153 0 : aPageButton.Check();
154 0 : aPageButton.GetClickHdl().Call(&aPageButton);
155 : }
156 : else
157 : {
158 0 : aSingleButton.GetClickHdl().Call(&aSingleButton);
159 0 : aSingleButton.Check();
160 : }
161 :
162 0 : if (pPrinter)
163 : {
164 : // show printer
165 0 : aPrinterInfo.SetText(pPrinter->GetName());
166 : }
167 : else
168 0 : aPrinterInfo.SetText(Printer::GetDefaultPrinterName());
169 :
170 0 : aColField.SetMax(aItem.nCols);
171 0 : aRowField.SetMax(aItem.nRows);
172 :
173 0 : aColField.SetLast(aColField.GetMax());
174 0 : aRowField.SetLast(aRowField.GetMax());
175 :
176 0 : aSynchronCB.Check(aItem.bSynchron);
177 0 : }
178 :
179 :
180 :
181 :
182 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|