LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - envprt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 107 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 18 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 <vcl/print.hxx>
      21             : #include <svtools/prnsetup.hxx>
      22             : 
      23             : #include "swtypes.hxx"
      24             : #include "cmdid.h"
      25             : #include "envprt.hxx"
      26             : #include "envlop.hxx"
      27             : #include "uitool.hxx"
      28             : 
      29             : #include "envprt.hrc"
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32           0 : SwEnvPrtPage::SwEnvPrtPage(vcl::Window* pParent, const SfxItemSet& rSet)
      33             :     : SfxTabPage(pParent, "EnvPrinterPage",
      34             :         "modules/swriter/ui/envprinterpage.ui", &rSet)
      35           0 :     , pPrt(NULL)
      36             : {
      37           0 :     get(m_pAlignBox, "alignbox");
      38           0 :     get(m_pTopButton, "top");
      39           0 :     get(m_pBottomButton, "bottom");
      40           0 :     get(m_pRightField, "right");
      41           0 :     get(m_pDownField, "down");
      42           0 :     get(m_pPrinterInfo, "printername");
      43           0 :     get(m_pPrtSetup, "setup");
      44           0 :     SetExchangeSupport();
      45             : 
      46             :     // Metrics
      47           0 :     FieldUnit eUnit = ::GetDfltMetric(false);
      48           0 :     SetMetric(*m_pRightField, eUnit);
      49           0 :     SetMetric(*m_pDownField, eUnit);
      50             : 
      51             :     // Install handlers
      52           0 :     m_pTopButton->SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
      53           0 :     m_pBottomButton->SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
      54             : 
      55           0 :     m_pPrtSetup->SetClickHdl(LINK(this, SwEnvPrtPage, ButtonHdl));
      56             : 
      57             :     // Bitmaps
      58           0 :     m_pBottomButton->GetClickHdl().Call(m_pBottomButton);
      59             : 
      60             :     // ToolBox
      61           0 :     m_pAlignBox->SetClickHdl(LINK(this, SwEnvPrtPage, AlignHdl));
      62           0 :     m_aIds[ENV_HOR_LEFT] = m_pAlignBox->GetItemId("horileft");
      63           0 :     m_aIds[ENV_HOR_CNTR] = m_pAlignBox->GetItemId("horicenter");
      64           0 :     m_aIds[ENV_HOR_RGHT] = m_pAlignBox->GetItemId("horiright");
      65           0 :     m_aIds[ENV_VER_LEFT] = m_pAlignBox->GetItemId("vertleft");
      66           0 :     m_aIds[ENV_VER_CNTR] = m_pAlignBox->GetItemId("vertcenter");
      67           0 :     m_aIds[ENV_VER_RGHT] = m_pAlignBox->GetItemId("vertright");
      68           0 : }
      69             : 
      70           0 : SwEnvPrtPage::~SwEnvPrtPage()
      71             : {
      72           0 :     disposeOnce();
      73           0 : }
      74             : 
      75           0 : void SwEnvPrtPage::dispose()
      76             : {
      77           0 :     m_pAlignBox.clear();
      78           0 :     m_pTopButton.clear();
      79           0 :     m_pBottomButton.clear();
      80           0 :     m_pRightField.clear();
      81           0 :     m_pDownField.clear();
      82           0 :     m_pPrinterInfo.clear();
      83           0 :     m_pPrtSetup.clear();
      84           0 :     SfxTabPage::dispose();
      85           0 : }
      86             : 
      87           0 : IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl)
      88             : {
      89           0 :     if (m_pBottomButton->IsChecked())
      90             :     {
      91             :         // Envelope from botton
      92           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(Bitmap(SW_RES(BMP_HOR_LEFT_LOWER))));
      93           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(Bitmap(SW_RES(BMP_HOR_CNTR_LOWER))));
      94           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(Bitmap(SW_RES(BMP_HOR_RGHT_LOWER))));
      95           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(Bitmap(SW_RES(BMP_VER_LEFT_LOWER))));
      96           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(Bitmap(SW_RES(BMP_VER_CNTR_LOWER))));
      97           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(Bitmap(SW_RES(BMP_VER_RGHT_LOWER))));
      98             :     }
      99             :     else
     100             :     {
     101             :         // Envelope from top
     102           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(Bitmap(SW_RES(BMP_HOR_LEFT_UPPER))));
     103           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(Bitmap(SW_RES(BMP_HOR_CNTR_UPPER))));
     104           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(Bitmap(SW_RES(BMP_HOR_RGHT_UPPER))));
     105           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(Bitmap(SW_RES(BMP_VER_LEFT_UPPER))));
     106           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(Bitmap(SW_RES(BMP_VER_CNTR_UPPER))));
     107           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(Bitmap(SW_RES(BMP_VER_RGHT_UPPER))));
     108             :     }
     109           0 :     return 0;
     110             : }
     111             : 
     112           0 : IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn )
     113             : {
     114           0 :     if (pBtn == m_pPrtSetup)
     115             :     {
     116             :         // Call printer setup
     117           0 :         if (pPrt)
     118             :         {
     119           0 :             VclPtrInstance< PrinterSetupDialog > pDlg(this);
     120           0 :             pDlg->SetPrinter(pPrt);
     121           0 :             pDlg->Execute();
     122           0 :             pDlg.reset();
     123           0 :             GrabFocus();
     124           0 :             m_pPrinterInfo->SetText(pPrt->GetName());
     125             :         }
     126             :     }
     127           0 :     return 0;
     128             : }
     129             : 
     130           0 : IMPL_LINK_NOARG_TYPED(SwEnvPrtPage, AlignHdl, ToolBox *, void)
     131             : {
     132           0 :     if (m_pAlignBox->GetCurItemId())
     133             :     {
     134           0 :         for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
     135           0 :             m_pAlignBox->CheckItem(m_aIds[i], false);
     136           0 :         m_pAlignBox->CheckItem(m_pAlignBox->GetCurItemId(), true);
     137             :     }
     138             :     else
     139             :     {
     140             :         // GetCurItemId() == 0 is possible!
     141           0 :         const SwEnvItem& rItem = static_cast<const SwEnvItem&>( GetItemSet().Get(FN_ENVELOP) );
     142           0 :         m_pAlignBox->CheckItem(m_aIds[rItem.eAlign], true);
     143             :     }
     144           0 : }
     145             : 
     146           0 : VclPtr<SfxTabPage> SwEnvPrtPage::Create(vcl::Window* pParent, const SfxItemSet* rSet)
     147             : {
     148           0 :     return VclPtr<SwEnvPrtPage>::Create(pParent, *rSet);
     149             : }
     150             : 
     151           0 : void SwEnvPrtPage::ActivatePage(const SfxItemSet&)
     152             : {
     153           0 :     if (pPrt)
     154           0 :         m_pPrinterInfo->SetText(pPrt->GetName());
     155           0 : }
     156             : 
     157           0 : SfxTabPage::sfxpg SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
     158             : {
     159           0 :     if( _pSet )
     160           0 :         FillItemSet(_pSet);
     161           0 :     return SfxTabPage::LEAVE_PAGE;
     162             : }
     163             : 
     164           0 : void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
     165             : {
     166           0 :     int nOrient = 0;
     167           0 :     for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
     168             :     {
     169           0 :         if (m_pAlignBox->IsItemChecked(m_aIds[i]))
     170             :         {
     171           0 :             nOrient = i;
     172           0 :             break;
     173             :         }
     174             :     }
     175             : 
     176           0 :     rItem.eAlign          = (SwEnvAlign) (nOrient);
     177           0 :     rItem.bPrintFromAbove = m_pTopButton->IsChecked();
     178           0 :     rItem.lShiftRight     = static_cast< sal_Int32 >(GetFieldVal(*m_pRightField));
     179           0 :     rItem.lShiftDown      = static_cast< sal_Int32 >(GetFieldVal(*m_pDownField ));
     180           0 : }
     181             : 
     182           0 : bool SwEnvPrtPage::FillItemSet(SfxItemSet* rSet)
     183             : {
     184           0 :     FillItem(GetParentSwEnvDlg()->aEnvItem);
     185           0 :     rSet->Put(GetParentSwEnvDlg()->aEnvItem);
     186           0 :     return true;
     187             : }
     188             : 
     189           0 : void SwEnvPrtPage::Reset(const SfxItemSet* rSet)
     190             : {
     191             :     // Read item
     192           0 :     const SwEnvItem& rItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP) );
     193           0 :     m_pAlignBox->CheckItem(m_aIds[rItem.eAlign]);
     194             : 
     195           0 :     if (rItem.bPrintFromAbove)
     196           0 :         m_pTopButton->Check();
     197             :     else
     198           0 :         m_pBottomButton->Check();
     199             : 
     200           0 :     SetFieldVal(*m_pRightField, rItem.lShiftRight);
     201           0 :     SetFieldVal(*m_pDownField , rItem.lShiftDown );
     202             : 
     203           0 :     ActivatePage(*rSet);
     204           0 :     ClickHdl(m_pTopButton);
     205           0 : }
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11