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

Generated by: LCOV version 1.10