LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - envprt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 85 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/print.hxx>
      30                 :            : #include <svtools/prnsetup.hxx>
      31                 :            : 
      32                 :            : #include "swtypes.hxx"
      33                 :            : #include "cmdid.h"
      34                 :            : #include "envprt.hxx"
      35                 :            : #include "envlop.hxx"
      36                 :            : #include "uitool.hxx"
      37                 :            : 
      38                 :            : #include "envprt.hrc"
      39                 :            : 
      40                 :          0 : SwEnvPrtPage::SwEnvPrtPage(Window* pParent, const SfxItemSet& rSet) :
      41                 :            : 
      42                 :            :     SfxTabPage(pParent, SW_RES(TP_ENV_PRT), rSet),
      43                 :            : 
      44                 :            :     aAlignBox    (this, SW_RES(BOX_ALIGN  )),
      45                 :            :     aTopButton   (this, SW_RES(BTN_TOP    )),
      46                 :            :     aBottomButton(this, SW_RES(BTN_BOTTOM )),
      47                 :            :     aRightText   (this, SW_RES(TXT_RIGHT  )),
      48                 :            :     aRightField  (this, SW_RES(FLD_RIGHT  )),
      49                 :            :     aDownText    (this, SW_RES(TXT_DOWN   )),
      50                 :            :     aDownField   (this, SW_RES(FLD_DOWN   )),
      51                 :            :     aPrinterInfo (this, SW_RES(TXT_PRINTER)),
      52                 :            :     aNoNameFL    (this, SW_RES(FL_NONAME )),
      53                 :            :     aPrinterFL   (this, SW_RES(FL_PRINTER )),
      54                 :          0 :     aPrtSetup    (this, SW_RES(BTN_PRTSETUP))
      55                 :            : 
      56                 :            : {
      57                 :          0 :     FreeResource();
      58                 :          0 :     SetExchangeSupport();
      59                 :            : 
      60                 :            :     // Metrics
      61                 :          0 :     FieldUnit eUnit = ::GetDfltMetric(sal_False);
      62                 :          0 :     SetMetric(aRightField, eUnit);
      63                 :          0 :     SetMetric(aDownField , eUnit);
      64                 :            : 
      65                 :            :     // Install handlers
      66                 :          0 :     aTopButton   .SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
      67                 :          0 :     aBottomButton.SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
      68                 :            : 
      69                 :          0 :     aPrtSetup    .SetClickHdl(LINK(this, SwEnvPrtPage, ButtonHdl));
      70                 :            : 
      71                 :            :     // Bitmaps
      72                 :          0 :     aBottomButton.GetClickHdl().Call(&aBottomButton);
      73                 :            : 
      74                 :            :     // ToolBox
      75                 :          0 :     Size aSz = aAlignBox.CalcWindowSizePixel();
      76                 :          0 :     aAlignBox.SetSizePixel(aSz);
      77                 :          0 :     aAlignBox.SetClickHdl(LINK(this, SwEnvPrtPage, AlignHdl));
      78                 :          0 : }
      79                 :            : 
      80                 :          0 : SwEnvPrtPage::~SwEnvPrtPage()
      81                 :            : {
      82                 :          0 : }
      83                 :            : 
      84                 :          0 : IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl)
      85                 :            : {
      86                 :          0 :     if (aBottomButton.IsChecked())
      87                 :            :     {
      88                 :            :         // Envelope from botton
      89                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_LEFT, Bitmap(SW_RES(BMP_HOR_LEFT_LOWER)));
      90                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_CNTR, Bitmap(SW_RES(BMP_HOR_CNTR_LOWER)));
      91                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_RGHT, Bitmap(SW_RES(BMP_HOR_RGHT_LOWER)));
      92                 :          0 :         aAlignBox.SetItemImage(ITM_VER_LEFT, Bitmap(SW_RES(BMP_VER_LEFT_LOWER)));
      93                 :          0 :         aAlignBox.SetItemImage(ITM_VER_CNTR, Bitmap(SW_RES(BMP_VER_CNTR_LOWER)));
      94                 :          0 :         aAlignBox.SetItemImage(ITM_VER_RGHT, Bitmap(SW_RES(BMP_VER_RGHT_LOWER)));
      95                 :            :     }
      96                 :            :     else
      97                 :            :     {
      98                 :            :         // Envelope from top
      99                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_LEFT, Bitmap(SW_RES(BMP_HOR_LEFT_UPPER)));
     100                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_CNTR, Bitmap(SW_RES(BMP_HOR_CNTR_UPPER)));
     101                 :          0 :         aAlignBox.SetItemImage(ITM_HOR_RGHT, Bitmap(SW_RES(BMP_HOR_RGHT_UPPER)));
     102                 :          0 :         aAlignBox.SetItemImage(ITM_VER_LEFT, Bitmap(SW_RES(BMP_VER_LEFT_UPPER)));
     103                 :          0 :         aAlignBox.SetItemImage(ITM_VER_CNTR, Bitmap(SW_RES(BMP_VER_CNTR_UPPER)));
     104                 :          0 :         aAlignBox.SetItemImage(ITM_VER_RGHT, Bitmap(SW_RES(BMP_VER_RGHT_UPPER)));
     105                 :            :     }
     106                 :          0 :     return 0;
     107                 :            : }
     108                 :            : 
     109                 :          0 : IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn )
     110                 :            : {
     111                 :          0 :     if (pBtn == &aPrtSetup)
     112                 :            :     {
     113                 :            :         // Call printer setup
     114                 :          0 :         if (pPrt)
     115                 :            :         {
     116                 :          0 :             PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
     117                 :          0 :             pDlg->SetPrinter(pPrt);
     118                 :          0 :             pDlg->Execute();
     119                 :          0 :             delete pDlg;
     120                 :          0 :             GrabFocus();
     121                 :          0 :             aPrinterInfo.SetText(pPrt->GetName());
     122                 :            :         }
     123                 :            :     }
     124                 :          0 :     return 0;
     125                 :            : }
     126                 :            : 
     127                 :          0 : IMPL_LINK_NOARG(SwEnvPrtPage, AlignHdl)
     128                 :            : {
     129                 :          0 :     if (aAlignBox.GetCurItemId())
     130                 :            :     {
     131                 :          0 :         for (sal_uInt16 i = ITM_HOR_LEFT; i <= ITM_VER_RGHT; i++)
     132                 :          0 :             aAlignBox.CheckItem(i, sal_False);
     133                 :          0 :         aAlignBox.CheckItem(aAlignBox.GetCurItemId(), sal_True);
     134                 :            :     }
     135                 :            :     else
     136                 :            :     {
     137                 :            :         // GetCurItemId() == 0 is possible!
     138                 :          0 :         const SwEnvItem& rItem = (const SwEnvItem&) GetItemSet().Get(FN_ENVELOP);
     139                 :          0 :         aAlignBox.CheckItem((sal_uInt16) rItem.eAlign + ITM_HOR_LEFT, sal_True);
     140                 :            :     }
     141                 :          0 :     return 0;
     142                 :            : }
     143                 :            : 
     144                 :          0 : SfxTabPage* SwEnvPrtPage::Create(Window* pParent, const SfxItemSet& rSet)
     145                 :            : {
     146                 :          0 :     return new SwEnvPrtPage(pParent, rSet);
     147                 :            : }
     148                 :            : 
     149                 :          0 : void SwEnvPrtPage::ActivatePage(const SfxItemSet&)
     150                 :            : {
     151                 :          0 :     if (pPrt)
     152                 :          0 :         aPrinterInfo.SetText(pPrt->GetName());
     153                 :          0 : }
     154                 :            : 
     155                 :          0 : int SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
     156                 :            : {
     157                 :          0 :     if( _pSet )
     158                 :          0 :         FillItemSet(*_pSet);
     159                 :          0 :     return SfxTabPage::LEAVE_PAGE;
     160                 :            : }
     161                 :            : 
     162                 :          0 : void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
     163                 :            : {
     164                 :          0 :     sal_uInt16 nID = 0;
     165                 :          0 :     for (sal_uInt16 i = ITM_HOR_LEFT; i <= ITM_VER_RGHT && !nID; i++)
     166                 :          0 :         if (aAlignBox.IsItemChecked(i))
     167                 :          0 :             nID = i;
     168                 :            : 
     169                 :          0 :     rItem.eAlign          = (SwEnvAlign) (nID - ITM_HOR_LEFT);
     170                 :          0 :     rItem.bPrintFromAbove = aTopButton.IsChecked();
     171                 :          0 :     rItem.lShiftRight     = static_cast< sal_Int32 >(GetFldVal(aRightField));
     172                 :          0 :     rItem.lShiftDown      = static_cast< sal_Int32 >(GetFldVal(aDownField ));
     173                 :          0 : }
     174                 :            : 
     175                 :          0 : sal_Bool SwEnvPrtPage::FillItemSet(SfxItemSet& rSet)
     176                 :            : {
     177                 :          0 :     FillItem(GetParent()->aEnvItem);
     178                 :          0 :     rSet.Put(GetParent()->aEnvItem);
     179                 :          0 :     return sal_True;
     180                 :            : }
     181                 :            : 
     182                 :          0 : void SwEnvPrtPage::Reset(const SfxItemSet& rSet)
     183                 :            : {
     184                 :            :     // Read item
     185                 :          0 :     const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP);
     186                 :          0 :     aAlignBox.CheckItem((sal_uInt16) rItem.eAlign + ITM_HOR_LEFT);
     187                 :            : 
     188                 :          0 :     if (rItem.bPrintFromAbove)
     189                 :          0 :         aTopButton   .Check();
     190                 :            :     else
     191                 :          0 :         aBottomButton.Check();
     192                 :            : 
     193                 :          0 :     SetFldVal(aRightField, rItem.lShiftRight);
     194                 :          0 :     SetFldVal(aDownField , rItem.lShiftDown );
     195                 :            : 
     196                 :          0 :     ActivatePage(rSet);
     197                 :          0 :     ClickHdl(&aTopButton);
     198                 :          0 : }
     199                 :            : 
     200                 :            : 
     201                 :            : 
     202                 :            : 
     203                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10