LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - prntopts.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 149 0.0 %
Date: 2012-12-27 Functions: 0 16 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             : 
      21             : #ifdef SD_DLLIMPLEMENTATION
      22             : #undef SD_DLLIMPLEMENTATION
      23             : #endif
      24             : 
      25             : 
      26             : #include "sdattr.hxx"
      27             : #include "optsitem.hxx"
      28             : #include "prntopts.hrc"
      29             : #include "sdresid.hxx"
      30             : #include "prntopts.hxx"
      31             : #include "app.hrc"
      32             : #include <svl/intitem.hxx>
      33             : #include <sfx2/request.hxx>
      34             : 
      35             : /*************************************************************************
      36             : |*
      37             : |*  Dialog zum Aendern der Print-Optionen
      38             : |*
      39             : \************************************************************************/
      40             : 
      41           0 : SdPrintOptions::SdPrintOptions( Window* pParent, const SfxItemSet& rInAttrs ) :
      42             :         SfxTabPage          ( pParent, SdResId( TP_PRINT_OPTIONS ), rInAttrs ),
      43             : 
      44             :         aGrpPrint               ( this, SdResId( GRP_PRINT ) ),
      45             :         aCbxDraw                ( this, SdResId( CBX_DRAW ) ),
      46             :         aCbxNotes               ( this, SdResId( CBX_NOTES ) ),
      47             :         aCbxHandout             ( this, SdResId( CBX_HANDOUTS ) ),
      48             :         aCbxOutline             ( this, SdResId( CBX_OUTLINE ) ),
      49             : 
      50             :         aSeparator1FL            ( this, SdResId( FL_SEPARATOR1 ) ),
      51             :         aGrpOutput              ( this, SdResId( GRP_OUTPUT ) ),
      52             :         aRbtColor               ( this, SdResId( RBT_COLOR ) ),
      53             :         aRbtGrayscale           ( this, SdResId( RBT_GRAYSCALE ) ),
      54             :         aRbtBlackWhite          ( this, SdResId( RBT_BLACKWHITE ) ),
      55             : 
      56             :         aGrpPrintExt            ( this, SdResId( GRP_PRINT_EXT ) ),
      57             :         aCbxPagename            ( this, SdResId( CBX_PAGENAME ) ),
      58             :         aCbxDate                ( this, SdResId( CBX_DATE ) ),
      59             :         aCbxTime                ( this, SdResId( CBX_TIME ) ),
      60             :         aCbxHiddenPages         ( this, SdResId( CBX_HIDDEN_PAGES ) ),
      61             : 
      62             :         aSeparator2FL            ( this, SdResId( FL_SEPARATOR2 ) ),
      63             :         aGrpPageoptions         ( this, SdResId( GRP_PAGE ) ),
      64             :         aRbtDefault             ( this, SdResId( RBT_DEFAULT ) ),
      65             :         aRbtPagesize            ( this, SdResId( RBT_PAGESIZE ) ),
      66             :         aRbtPagetile            ( this, SdResId( RBT_PAGETILE ) ),
      67             :         aRbtBooklet             ( this, SdResId( RBT_BOOKLET ) ),
      68             :         aCbxFront               ( this, SdResId( CBX_FRONT ) ),
      69             :         aCbxBack                ( this, SdResId( CBX_BACK ) ),
      70             : 
      71             :         aCbxPaperbin            ( this, SdResId( CBX_PAPERBIN ) ),
      72             : 
      73           0 :         rOutAttrs               ( rInAttrs )
      74             : {
      75           0 :     FreeResource();
      76             : 
      77           0 :     Link aLink = LINK( this, SdPrintOptions, ClickBookletHdl );
      78           0 :     aRbtDefault.SetClickHdl( aLink );
      79           0 :     aRbtPagesize.SetClickHdl( aLink );
      80           0 :     aRbtPagetile.SetClickHdl( aLink );
      81           0 :     aRbtBooklet.SetClickHdl( aLink );
      82             : 
      83           0 :     aLink = LINK( this, SdPrintOptions, ClickCheckboxHdl );
      84           0 :     aCbxDraw.SetClickHdl( aLink );
      85           0 :     aCbxNotes.SetClickHdl( aLink );
      86           0 :     aCbxHandout.SetClickHdl( aLink );
      87           0 :     aCbxOutline.SetClickHdl( aLink );
      88             : 
      89             : #ifndef QUARTZ
      90           0 :     SetDrawMode();
      91             : #endif
      92             : 
      93           0 :     aCbxFront.SetAccessibleRelationLabeledBy( &aRbtBooklet );
      94           0 :     aCbxBack.SetAccessibleRelationLabeledBy( &aRbtBooklet );
      95           0 : }
      96             : 
      97             : // -----------------------------------------------------------------------
      98             : 
      99           0 : SdPrintOptions::~SdPrintOptions()
     100             : {
     101           0 : }
     102             : 
     103             : // -----------------------------------------------------------------------
     104             : 
     105           0 : sal_Bool SdPrintOptions::FillItemSet( SfxItemSet& rAttrs )
     106             : {
     107           0 :     if( aCbxDraw.GetSavedValue() != aCbxDraw.IsChecked() ||
     108           0 :         aCbxNotes.GetSavedValue() != aCbxNotes.IsChecked() ||
     109           0 :         aCbxHandout.GetSavedValue() != aCbxHandout.IsChecked() ||
     110           0 :         aCbxOutline.GetSavedValue() != aCbxOutline.IsChecked() ||
     111           0 :         aCbxDate.GetSavedValue() != aCbxDate.IsChecked() ||
     112           0 :         aCbxTime.GetSavedValue() != aCbxTime.IsChecked() ||
     113           0 :         aCbxPagename.GetSavedValue() != aCbxPagename.IsChecked() ||
     114           0 :         aCbxHiddenPages.GetSavedValue() != aCbxHiddenPages.IsChecked() ||
     115           0 :         aRbtPagesize.GetSavedValue() != aRbtPagesize.IsChecked() ||
     116           0 :         aRbtPagetile.GetSavedValue() != aRbtPagetile.IsChecked() ||
     117           0 :         aRbtBooklet.GetSavedValue() != aRbtBooklet.IsChecked() ||
     118           0 :         aCbxFront.GetSavedValue() != aCbxFront.IsChecked() ||
     119           0 :         aCbxBack.GetSavedValue() != aCbxBack.IsChecked() ||
     120           0 :         aCbxPaperbin.GetSavedValue() != aCbxPaperbin.IsChecked() ||
     121           0 :         aRbtColor.GetSavedValue() != aRbtColor.IsChecked() ||
     122           0 :         aRbtGrayscale.GetSavedValue() != aRbtGrayscale.IsChecked() ||
     123           0 :         aRbtBlackWhite.GetSavedValue() != aRbtBlackWhite.IsChecked() )
     124             :     {
     125           0 :         SdOptionsPrintItem aOptions( ATTR_OPTIONS_PRINT );
     126             : 
     127           0 :         aOptions.GetOptionsPrint().SetDraw( aCbxDraw.IsChecked() );
     128           0 :         aOptions.GetOptionsPrint().SetNotes( aCbxNotes.IsChecked() );
     129           0 :         aOptions.GetOptionsPrint().SetHandout( aCbxHandout.IsChecked() );
     130           0 :         aOptions.GetOptionsPrint().SetOutline( aCbxOutline.IsChecked() );
     131           0 :         aOptions.GetOptionsPrint().SetDate( aCbxDate.IsChecked() );
     132           0 :         aOptions.GetOptionsPrint().SetTime( aCbxTime.IsChecked() );
     133           0 :         aOptions.GetOptionsPrint().SetPagename( aCbxPagename.IsChecked() );
     134           0 :         aOptions.GetOptionsPrint().SetHiddenPages( aCbxHiddenPages.IsChecked() );
     135           0 :         aOptions.GetOptionsPrint().SetPagesize( aRbtPagesize.IsChecked() );
     136           0 :         aOptions.GetOptionsPrint().SetPagetile( aRbtPagetile.IsChecked() );
     137           0 :         aOptions.GetOptionsPrint().SetBooklet( aRbtBooklet.IsChecked() );
     138           0 :         aOptions.GetOptionsPrint().SetFrontPage( aCbxFront.IsChecked() );
     139           0 :         aOptions.GetOptionsPrint().SetBackPage( aCbxBack.IsChecked() );
     140           0 :         aOptions.GetOptionsPrint().SetPaperbin( aCbxPaperbin.IsChecked() );
     141             : 
     142           0 :         sal_uInt16 nQuality = 0; // Standard, also Color
     143           0 :         if( aRbtGrayscale.IsChecked() )
     144           0 :             nQuality = 1;
     145           0 :         if( aRbtBlackWhite.IsChecked() )
     146           0 :             nQuality = 2;
     147           0 :         aOptions.GetOptionsPrint().SetOutputQuality( nQuality );
     148             : 
     149           0 :         rAttrs.Put( aOptions );
     150             : 
     151           0 :         return( sal_True );
     152             :     }
     153           0 :     return( sal_False );
     154             : }
     155             : 
     156             : // -----------------------------------------------------------------------
     157             : 
     158           0 : void SdPrintOptions::Reset( const SfxItemSet& rAttrs )
     159             : {
     160           0 :     const SdOptionsPrintItem* pPrintOpts = NULL;
     161           0 :     if( SFX_ITEM_SET == rAttrs.GetItemState( ATTR_OPTIONS_PRINT, sal_False,
     162           0 :                             (const SfxPoolItem**) &pPrintOpts ) )
     163             :     {
     164           0 :         aCbxDraw.Check(              pPrintOpts->GetOptionsPrint().IsDraw() );
     165           0 :         aCbxNotes.Check(             pPrintOpts->GetOptionsPrint().IsNotes() );
     166           0 :         aCbxHandout.Check(           pPrintOpts->GetOptionsPrint().IsHandout() );
     167           0 :         aCbxOutline.Check(           pPrintOpts->GetOptionsPrint().IsOutline() );
     168           0 :         aCbxDate.Check(              pPrintOpts->GetOptionsPrint().IsDate() );
     169           0 :         aCbxTime.Check(              pPrintOpts->GetOptionsPrint().IsTime() );
     170           0 :         aCbxPagename.Check(          pPrintOpts->GetOptionsPrint().IsPagename() );
     171           0 :         aCbxHiddenPages.Check(       pPrintOpts->GetOptionsPrint().IsHiddenPages() );
     172           0 :         aRbtPagesize.Check(          pPrintOpts->GetOptionsPrint().IsPagesize() );
     173           0 :         aRbtPagetile.Check(          pPrintOpts->GetOptionsPrint().IsPagetile() );
     174           0 :         aRbtBooklet.Check(           pPrintOpts->GetOptionsPrint().IsBooklet() );
     175           0 :         aCbxFront.Check(             pPrintOpts->GetOptionsPrint().IsFrontPage() );
     176           0 :         aCbxBack.Check(              pPrintOpts->GetOptionsPrint().IsBackPage() );
     177           0 :         aCbxPaperbin.Check(          pPrintOpts->GetOptionsPrint().IsPaperbin() );
     178             : 
     179           0 :         if( !aRbtPagesize.IsChecked() &&
     180           0 :             !aRbtPagetile.IsChecked() &&
     181           0 :             !aRbtBooklet.IsChecked() )
     182             :         {
     183           0 :             aRbtDefault.Check();
     184             :         }
     185             : 
     186           0 :         sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality();
     187           0 :         if( nQuality == 0 )
     188           0 :             aRbtColor.Check();
     189           0 :         else if( nQuality == 1 )
     190           0 :             aRbtGrayscale.Check();
     191             :         else
     192           0 :             aRbtBlackWhite.Check();
     193             :     }
     194           0 :     aCbxDraw.SaveValue();
     195           0 :     aCbxNotes.SaveValue();
     196           0 :     aCbxHandout.SaveValue();
     197           0 :     aCbxOutline.SaveValue();
     198           0 :     aCbxDate.SaveValue();
     199           0 :     aCbxTime.SaveValue();
     200           0 :     aCbxPagename.SaveValue();
     201           0 :     aCbxHiddenPages.SaveValue();
     202           0 :     aRbtPagesize.SaveValue();
     203           0 :     aRbtPagetile.SaveValue();
     204           0 :     aRbtBooklet.SaveValue();
     205           0 :     aCbxPaperbin.SaveValue();
     206           0 :     aRbtColor.SaveValue();
     207           0 :     aRbtGrayscale.SaveValue();
     208           0 :     aRbtBlackWhite.SaveValue();
     209             : 
     210           0 :     ClickBookletHdl( NULL );
     211           0 : }
     212             : 
     213             : // -----------------------------------------------------------------------
     214             : 
     215           0 : SfxTabPage* SdPrintOptions::Create( Window* pWindow,
     216             :                 const SfxItemSet& rOutAttrs )
     217             : {
     218           0 :     return( new SdPrintOptions( pWindow, rOutAttrs ) );
     219             : }
     220             : 
     221             : //-----------------------------------------------------------------------
     222             : 
     223           0 : IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, CheckBox *, pCbx )
     224             : {
     225             :     // there must be at least one of them checked
     226           0 :     if( !aCbxDraw.IsChecked() && !aCbxNotes.IsChecked() && !aCbxOutline.IsChecked() && !aCbxHandout.IsChecked() )
     227           0 :         pCbx->Check();
     228             : 
     229           0 :     updateControls();
     230           0 :     return 0;
     231             : }
     232             : 
     233             : //-----------------------------------------------------------------------
     234             : 
     235           0 : IMPL_LINK_NOARG(SdPrintOptions, ClickBookletHdl)
     236             : {
     237           0 :     updateControls();
     238           0 :     return 0;
     239             : }
     240             : 
     241           0 : void SdPrintOptions::updateControls()
     242             : {
     243           0 :     aCbxFront.Enable(aRbtBooklet.IsChecked());
     244           0 :     aCbxBack.Enable(aRbtBooklet.IsChecked());
     245             : 
     246           0 :     aCbxDate.Enable( !aRbtBooklet.IsChecked() );
     247           0 :     aCbxTime.Enable( !aRbtBooklet.IsChecked() );
     248             : 
     249           0 :     aCbxPagename.Enable( !aRbtBooklet.IsChecked() && (aCbxDraw.IsChecked() || aCbxNotes.IsChecked() || aCbxOutline.IsChecked()) );
     250           0 : }
     251             : 
     252           0 : static void lcl_MoveRB_Impl(Window& rBtn, long nXDiff)
     253             : {
     254           0 :     Point aPos(rBtn.GetPosPixel());
     255           0 :     aPos.X() -= nXDiff;
     256           0 :     rBtn.SetPosPixel(aPos);
     257           0 : }
     258             : 
     259           0 : void    SdPrintOptions::SetDrawMode()
     260             : {
     261           0 :     if(aCbxNotes.IsVisible())
     262             :     {
     263           0 :         aCbxNotes.Hide();
     264           0 :         aCbxHandout.Hide();
     265           0 :         aCbxOutline.Hide();
     266           0 :         aCbxDraw.Hide();
     267           0 :         aGrpPrint.Hide();
     268             : 
     269           0 :         aSeparator1FL.Hide();
     270           0 :         long nXDiff = aGrpOutput.GetPosPixel().X() - aGrpPrint.GetPosPixel().X();
     271           0 :         lcl_MoveRB_Impl(aRbtColor, nXDiff);
     272           0 :         lcl_MoveRB_Impl(aRbtGrayscale, nXDiff);
     273           0 :         lcl_MoveRB_Impl(aRbtBlackWhite, nXDiff);
     274           0 :         lcl_MoveRB_Impl(aGrpOutput, nXDiff);
     275             : 
     276           0 :         long nWidth =  aGrpOutput.GetSizePixel().Width() + nXDiff;
     277           0 :         Size aSize(aGrpOutput.GetSizePixel());
     278           0 :         aSize.Width() = nWidth;
     279           0 :         aGrpOutput.SetSizePixel(aSize);
     280             :     }
     281           0 : }
     282             : 
     283           0 : void SdPrintOptions::PageCreated (SfxAllItemSet
     284             : #ifdef QUARTZ
     285             :                                   aSet
     286             : #endif
     287             :                                   )
     288             : {
     289             : #ifdef QUARTZ
     290             :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
     291             :     if (pFlagItem)
     292             :     {
     293             :         sal_uInt32 nFlags=pFlagItem->GetValue();
     294             :         if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
     295             :             SetDrawMode();
     296             :     }
     297             : #else
     298           0 :     SetDrawMode();
     299             : #endif
     300           0 : }
     301             : 
     302             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10