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