LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - envprt.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 94 0.0 %
Date: 2014-11-03 Functions: 0 15 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 : IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl)
      71             : {
      72           0 :     if (m_pBottomButton->IsChecked())
      73             :     {
      74             :         // Envelope from botton
      75           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(Bitmap(SW_RES(BMP_HOR_LEFT_LOWER))));
      76           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(Bitmap(SW_RES(BMP_HOR_CNTR_LOWER))));
      77           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(Bitmap(SW_RES(BMP_HOR_RGHT_LOWER))));
      78           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(Bitmap(SW_RES(BMP_VER_LEFT_LOWER))));
      79           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(Bitmap(SW_RES(BMP_VER_CNTR_LOWER))));
      80           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(Bitmap(SW_RES(BMP_VER_RGHT_LOWER))));
      81             :     }
      82             :     else
      83             :     {
      84             :         // Envelope from top
      85           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(Bitmap(SW_RES(BMP_HOR_LEFT_UPPER))));
      86           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(Bitmap(SW_RES(BMP_HOR_CNTR_UPPER))));
      87           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(Bitmap(SW_RES(BMP_HOR_RGHT_UPPER))));
      88           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(Bitmap(SW_RES(BMP_VER_LEFT_UPPER))));
      89           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(Bitmap(SW_RES(BMP_VER_CNTR_UPPER))));
      90           0 :         m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(Bitmap(SW_RES(BMP_VER_RGHT_UPPER))));
      91             :     }
      92           0 :     return 0;
      93             : }
      94             : 
      95           0 : IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn )
      96             : {
      97           0 :     if (pBtn == m_pPrtSetup)
      98             :     {
      99             :         // Call printer setup
     100           0 :         if (pPrt)
     101             :         {
     102           0 :             boost::scoped_ptr<PrinterSetupDialog> pDlg(new PrinterSetupDialog(this));
     103           0 :             pDlg->SetPrinter(pPrt);
     104           0 :             pDlg->Execute();
     105           0 :             pDlg.reset();
     106           0 :             GrabFocus();
     107           0 :             m_pPrinterInfo->SetText(pPrt->GetName());
     108             :         }
     109             :     }
     110           0 :     return 0;
     111             : }
     112             : 
     113           0 : IMPL_LINK_NOARG(SwEnvPrtPage, AlignHdl)
     114             : {
     115           0 :     if (m_pAlignBox->GetCurItemId())
     116             :     {
     117           0 :         for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
     118           0 :             m_pAlignBox->CheckItem(m_aIds[i], false);
     119           0 :         m_pAlignBox->CheckItem(m_pAlignBox->GetCurItemId(), true);
     120             :     }
     121             :     else
     122             :     {
     123             :         // GetCurItemId() == 0 is possible!
     124           0 :         const SwEnvItem& rItem = (const SwEnvItem&) GetItemSet().Get(FN_ENVELOP);
     125           0 :         m_pAlignBox->CheckItem(m_aIds[rItem.eAlign], true);
     126             :     }
     127           0 :     return 0;
     128             : }
     129             : 
     130           0 : SfxTabPage* SwEnvPrtPage::Create(vcl::Window* pParent, const SfxItemSet* rSet)
     131             : {
     132           0 :     return new SwEnvPrtPage(pParent, *rSet);
     133             : }
     134             : 
     135           0 : void SwEnvPrtPage::ActivatePage(const SfxItemSet&)
     136             : {
     137           0 :     if (pPrt)
     138           0 :         m_pPrinterInfo->SetText(pPrt->GetName());
     139           0 : }
     140             : 
     141           0 : int SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
     142             : {
     143           0 :     if( _pSet )
     144           0 :         FillItemSet(_pSet);
     145           0 :     return SfxTabPage::LEAVE_PAGE;
     146             : }
     147             : 
     148           0 : void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
     149             : {
     150           0 :     int nOrient = 0;
     151           0 :     for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
     152             :     {
     153           0 :         if (m_pAlignBox->IsItemChecked(m_aIds[i]))
     154             :         {
     155           0 :             nOrient = i;
     156           0 :             break;
     157             :         }
     158             :     }
     159             : 
     160           0 :     rItem.eAlign          = (SwEnvAlign) (nOrient);
     161           0 :     rItem.bPrintFromAbove = m_pTopButton->IsChecked();
     162           0 :     rItem.lShiftRight     = static_cast< sal_Int32 >(GetFldVal(*m_pRightField));
     163           0 :     rItem.lShiftDown      = static_cast< sal_Int32 >(GetFldVal(*m_pDownField ));
     164           0 : }
     165             : 
     166           0 : bool SwEnvPrtPage::FillItemSet(SfxItemSet* rSet)
     167             : {
     168           0 :     FillItem(GetParentSwEnvDlg()->aEnvItem);
     169           0 :     rSet->Put(GetParentSwEnvDlg()->aEnvItem);
     170           0 :     return true;
     171             : }
     172             : 
     173           0 : void SwEnvPrtPage::Reset(const SfxItemSet* rSet)
     174             : {
     175             :     // Read item
     176           0 :     const SwEnvItem& rItem = (const SwEnvItem&) rSet->Get(FN_ENVELOP);
     177           0 :     m_pAlignBox->CheckItem(m_aIds[rItem.eAlign]);
     178             : 
     179           0 :     if (rItem.bPrintFromAbove)
     180           0 :         m_pTopButton->Check();
     181             :     else
     182           0 :         m_pBottomButton->Check();
     183             : 
     184           0 :     SetFldVal(*m_pRightField, rItem.lShiftRight);
     185           0 :     SetFldVal(*m_pDownField , rItem.lShiftDown );
     186             : 
     187           0 :     ActivatePage(*rSet);
     188           0 :     ClickHdl(m_pTopButton);
     189           0 : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10