LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - labprt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 95 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          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             : 
      28             : #include <cmdid.h>
      29             : #include <boost/scoped_ptr.hpp>
      30             : 
      31           0 : SwLabPrtPage::SwLabPrtPage(vcl::Window* pParent, const SfxItemSet& rSet)
      32             :     : SfxTabPage(pParent, "LabelOptionsPage",
      33             :         "modules/swriter/ui/labeloptionspage.ui", &rSet)
      34           0 :     , pPrinter(0)
      35             : {
      36           0 :     get(m_pPageButton, "entirepage");
      37           0 :     get(m_pSingleButton, "singlelabel");
      38           0 :     get(m_pSingleGrid, "singlegrid");
      39           0 :     get(m_pColField, "cols");
      40           0 :     get(m_pRowField, "rows");
      41           0 :     get(m_pSynchronCB, "synchronize");
      42           0 :     get(m_pPrinterFrame, "printerframe");
      43           0 :     get(m_pPrinterInfo, "printername");
      44           0 :     get(m_pPrtSetup, "setup");
      45           0 :     SetExchangeSupport();
      46             : 
      47             :     // Install handlers
      48           0 :     Link<> aLk = LINK(this, SwLabPrtPage, CountHdl);
      49           0 :     m_pPageButton->SetClickHdl( aLk );
      50           0 :     m_pSingleButton->SetClickHdl( aLk );
      51             : 
      52           0 :     m_pPrtSetup->SetClickHdl( aLk );
      53             : 
      54           0 :     SvtCommandOptions aCmdOpts;
      55           0 :     if ( aCmdOpts.Lookup(
      56             :              SvtCommandOptions::CMDOPTION_DISABLED,
      57           0 :              OUString( "Print"  ) ) )
      58             :     {
      59           0 :         m_pPrinterFrame->Hide();
      60           0 :     }
      61           0 : }
      62             : 
      63           0 : SwLabPrtPage::~SwLabPrtPage()
      64             : {
      65           0 :     disposeOnce();
      66           0 : }
      67             : 
      68           0 : void SwLabPrtPage::dispose()
      69             : {
      70           0 :     pPrinter.disposeAndClear();
      71           0 :     m_pPageButton.clear();
      72           0 :     m_pSingleButton.clear();
      73           0 :     m_pSingleGrid.clear();
      74           0 :     m_pPrinterFrame.clear();
      75           0 :     m_pColField.clear();
      76           0 :     m_pRowField.clear();
      77           0 :     m_pSynchronCB.clear();
      78           0 :     m_pPrinterInfo.clear();
      79           0 :     m_pPrtSetup.clear();
      80           0 :     SfxTabPage::dispose();
      81           0 : }
      82             : 
      83           0 : IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton )
      84             : {
      85           0 :     if (pButton == m_pPrtSetup)
      86             :     {
      87             :         // Call printer setup
      88           0 :         if (!pPrinter)
      89           0 :             pPrinter = VclPtr<Printer>::Create();
      90             : 
      91           0 :         VclPtrInstance< PrinterSetupDialog > pDlg(this);
      92           0 :         pDlg->SetPrinter(pPrinter);
      93           0 :         pDlg->Execute();
      94           0 :         pDlg.reset();
      95           0 :         GrabFocus();
      96           0 :         m_pPrinterInfo->SetText(pPrinter->GetName());
      97           0 :         return 0;
      98             :     }
      99           0 :     const bool bEnable = pButton == m_pSingleButton;
     100           0 :     m_pSingleGrid->Enable(bEnable);
     101           0 :     m_pSynchronCB->Enable(!bEnable);
     102             : 
     103             :     OSL_ENSURE(!bEnable || pButton == m_pPageButton, "NewButton?" );
     104           0 :     if ( bEnable )
     105             :     {
     106           0 :         m_pColField->GrabFocus();
     107             :     }
     108           0 :     return 0;
     109             : }
     110             : 
     111           0 : VclPtr<SfxTabPage> SwLabPrtPage::Create(vcl::Window* pParent, const SfxItemSet* rSet)
     112             : {
     113           0 :     return VclPtr<SwLabPrtPage>::Create( pParent, *rSet );
     114             : }
     115             : 
     116           0 : void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
     117             : {
     118           0 :     Reset(&rSet);
     119           0 : }
     120             : 
     121           0 : SfxTabPage::sfxpg SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
     122             : {
     123           0 :     if ( _pSet )
     124           0 :         FillItemSet(_pSet);
     125             : 
     126           0 :     return LEAVE_PAGE;
     127             : }
     128             : 
     129           0 : void SwLabPrtPage::FillItem(SwLabItem& rItem)
     130             : {
     131           0 :     rItem.bPage = m_pPageButton->IsChecked();
     132           0 :     rItem.nCol = static_cast<sal_Int32>(m_pColField->GetValue());
     133           0 :     rItem.nRow = static_cast<sal_Int32>(m_pRowField->GetValue());
     134           0 :     rItem.bSynchron = m_pSynchronCB->IsChecked() && m_pSynchronCB->IsEnabled();
     135           0 : }
     136             : 
     137           0 : bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet)
     138             : {
     139           0 :     SwLabItem aItem;
     140           0 :     GetParentSwLabDlg()->GetLabItem(aItem);
     141           0 :     FillItem(aItem);
     142           0 :     rSet->Put(aItem);
     143             : 
     144           0 :     return true;
     145             : }
     146             : 
     147           0 : void SwLabPrtPage::Reset(const SfxItemSet* )
     148             : {
     149           0 :     SwLabItem aItem;
     150           0 :     GetParentSwLabDlg()->GetLabItem(aItem);
     151             : 
     152           0 :     m_pColField->SetValue   (aItem.nCol);
     153           0 :     m_pRowField->SetValue   (aItem.nRow);
     154             : 
     155           0 :     if (aItem.bPage)
     156             :     {
     157           0 :         m_pPageButton->Check();
     158           0 :         m_pPageButton->GetClickHdl().Call(m_pPageButton);
     159             :     }
     160             :     else
     161             :     {
     162           0 :         m_pSingleButton->GetClickHdl().Call(m_pSingleButton);
     163           0 :         m_pSingleButton->Check();
     164             :     }
     165             : 
     166           0 :     if (pPrinter)
     167             :     {
     168             :         // show printer
     169           0 :         m_pPrinterInfo->SetText(pPrinter->GetName());
     170             :     }
     171             :     else
     172           0 :         m_pPrinterInfo->SetText(Printer::GetDefaultPrinterName());
     173             : 
     174           0 :     m_pColField->SetMax(aItem.nCols);
     175           0 :     m_pRowField->SetMax(aItem.nRows);
     176             : 
     177           0 :     m_pColField->SetLast(m_pColField->GetMax());
     178           0 :     m_pRowField->SetLast(m_pRowField->GetMax());
     179             : 
     180           0 :     m_pSynchronCB->Check(aItem.bSynchron);
     181           0 : }
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11