1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: labprt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
39 #include <svtools/prnsetup.hxx>
40 #include <svtools/cmdoptions.hxx>
41 #include <vcl/print.hxx>
47 #include "swuilabimp.hxx"
58 // --------------------------------------------------------------------------
62 SwLabPrtPage::SwLabPrtPage(Window
* pParent
, const SfxItemSet
& rSet
) :
64 SfxTabPage(pParent
, SW_RES(TP_LAB_PRT
), rSet
),
67 aPageButton (this, SW_RES(BTN_PAGE
)),
68 aSingleButton (this, SW_RES(BTN_SINGLE
)),
69 aColText (this, SW_RES(TXT_COL
)),
70 aColField (this, SW_RES(FLD_COL
)),
71 aRowText (this, SW_RES(TXT_ROW
)),
72 aRowField (this, SW_RES(FLD_ROW
)),
73 aSynchronCB (this, SW_RES(CB_SYNCHRON
)),
74 aFLDontKnow (this, SW_RES(FL_DONTKNOW
)),
75 aPrinterInfo (this, SW_RES(INF_PRINTER
)),
76 aPrtSetup (this, SW_RES(BTN_PRTSETUP
)),
77 aFLPrinter (this, SW_RES(FL_PRINTER
))
83 // Handler installieren
84 Link aLk
= LINK(this, SwLabPrtPage
, CountHdl
);
85 aPageButton
.SetClickHdl( aLk
);
86 aSingleButton
.SetClickHdl( aLk
);
88 aPrtSetup
.SetClickHdl( aLk
);
90 SvtCommandOptions aCmdOpts
;
92 SvtCommandOptions::CMDOPTION_DISABLED
,
93 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) ) )
101 // --------------------------------------------------------------------------
105 SwLabPrtPage::~SwLabPrtPage()
111 // --------------------------------------------------------------------------
115 IMPL_LINK( SwLabPrtPage
, CountHdl
, Button
*, pButton
)
117 if (pButton
== &aPrtSetup
)
119 // Druck-Setup aufrufen
121 pPrinter
= new Printer
;
123 PrinterSetupDialog
* pDlg
= new PrinterSetupDialog(this );
124 pDlg
->SetPrinter(pPrinter
);
128 aPrinterInfo
.SetText(pPrinter
->GetName());
131 const BOOL bEnable
= pButton
== &aSingleButton
;
132 aColText
.Enable(bEnable
);
133 aColField
.Enable(bEnable
);
134 aRowText
.Enable(bEnable
);
135 aRowField
.Enable(bEnable
);
136 aSynchronCB
.Enable(!bEnable
);
139 aColField
.GrabFocus();
142 ASSERT( pButton
== &aPageButton
, "NewButton?" );
147 // --------------------------------------------------------------------------
151 SfxTabPage
* SwLabPrtPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
153 return new SwLabPrtPage( pParent
, rSet
);
156 // --------------------------------------------------------------------------
160 void SwLabPrtPage::ActivatePage( const SfxItemSet
& rSet
)
165 // --------------------------------------------------------------------------
169 int SwLabPrtPage::DeactivatePage(SfxItemSet
* _pSet
)
177 // --------------------------------------------------------------------------
181 void SwLabPrtPage::FillItem(SwLabItem
& rItem
)
183 rItem
.bPage
= aPageButton
.IsChecked();
184 rItem
.nCol
= (USHORT
) aColField
.GetValue();
185 rItem
.nRow
= (USHORT
) aRowField
.GetValue();
186 rItem
.bSynchron
= aSynchronCB
.IsChecked() && aSynchronCB
.IsEnabled();
189 // --------------------------------------------------------------------------
193 BOOL
SwLabPrtPage::FillItemSet(SfxItemSet
& rSet
)
196 GetParent()->GetLabItem(aItem
);
203 // --------------------------------------------------------------------------
207 void SwLabPrtPage::Reset(const SfxItemSet
& )
210 GetParent()->GetLabItem(aItem
);
212 aColField
.SetValue (aItem
.nCol
);
213 aRowField
.SetValue (aItem
.nRow
);
218 aPageButton
.GetClickHdl().Call(&aPageButton
);
222 aSingleButton
.GetClickHdl().Call(&aSingleButton
);
223 aSingleButton
.Check();
229 aPrinterInfo
.SetText(pPrinter
->GetName());
232 aPrinterInfo
.SetText(Printer::GetDefaultPrinterName());
234 aColField
.SetMax(aItem
.nCols
);
235 aRowField
.SetMax(aItem
.nRows
);
237 aColField
.SetLast(aColField
.GetMax());
238 aRowField
.SetLast(aRowField
.GetMax());
240 aSynchronCB
.Check(aItem
.bSynchron
);