1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svtools/prnsetup.hxx>
21 #include <unotools/cmdoptions.hxx>
22 #include <vcl/print.hxx>
27 #include "swuilabimp.hxx"
32 SwLabPrtPage::SwLabPrtPage(Window
* pParent
, const SfxItemSet
& rSet
) :
34 SfxTabPage(pParent
, SW_RES(TP_LAB_PRT
), rSet
),
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 aPrtSetup (this, SW_RES(BTN_PRTSETUP
))
54 Link aLk
= LINK(this, SwLabPrtPage
, CountHdl
);
55 aPageButton
.SetClickHdl( aLk
);
56 aSingleButton
.SetClickHdl( aLk
);
58 aPrtSetup
.SetClickHdl( aLk
);
60 SvtCommandOptions aCmdOpts
;
62 SvtCommandOptions::CMDOPTION_DISABLED
,
63 OUString( "Print" ) ) )
71 SwLabPrtPage::~SwLabPrtPage()
76 IMPL_LINK( SwLabPrtPage
, CountHdl
, Button
*, pButton
)
78 if (pButton
== &aPrtSetup
)
82 pPrinter
= new Printer
;
84 PrinterSetupDialog
* pDlg
= new PrinterSetupDialog(this );
85 pDlg
->SetPrinter(pPrinter
);
89 aPrinterInfo
.SetText(pPrinter
->GetName());
92 const sal_Bool bEnable
= pButton
== &aSingleButton
;
93 aColText
.Enable(bEnable
);
94 aColField
.Enable(bEnable
);
95 aRowText
.Enable(bEnable
);
96 aRowField
.Enable(bEnable
);
97 aSynchronCB
.Enable(!bEnable
);
99 OSL_ENSURE(!bEnable
|| pButton
== &aPageButton
, "NewButton?" );
102 aColField
.GrabFocus();
107 SfxTabPage
* SwLabPrtPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
109 return new SwLabPrtPage( pParent
, rSet
);
112 void SwLabPrtPage::ActivatePage( const SfxItemSet
& rSet
)
117 int SwLabPrtPage::DeactivatePage(SfxItemSet
* _pSet
)
125 void SwLabPrtPage::FillItem(SwLabItem
& rItem
)
127 rItem
.bPage
= aPageButton
.IsChecked();
128 rItem
.nCol
= (sal_uInt16
) aColField
.GetValue();
129 rItem
.nRow
= (sal_uInt16
) aRowField
.GetValue();
130 rItem
.bSynchron
= aSynchronCB
.IsChecked() && aSynchronCB
.IsEnabled();
133 sal_Bool
SwLabPrtPage::FillItemSet(SfxItemSet
& rSet
)
136 GetParentSwLabDlg()->GetLabItem(aItem
);
143 void SwLabPrtPage::Reset(const SfxItemSet
& )
146 GetParentSwLabDlg()->GetLabItem(aItem
);
148 aColField
.SetValue (aItem
.nCol
);
149 aRowField
.SetValue (aItem
.nRow
);
154 aPageButton
.GetClickHdl().Call(&aPageButton
);
158 aSingleButton
.GetClickHdl().Call(&aSingleButton
);
159 aSingleButton
.Check();
165 aPrinterInfo
.SetText(pPrinter
->GetName());
168 aPrinterInfo
.SetText(Printer::GetDefaultPrinterName());
170 aColField
.SetMax(aItem
.nCols
);
171 aRowField
.SetMax(aItem
.nRows
);
173 aColField
.SetLast(aColField
.GetMax());
174 aRowField
.SetLast(aRowField
.GetMax());
176 aSynchronCB
.Check(aItem
.bSynchron
);
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */