LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - prntopts.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 171 0.0 %
Date: 2015-06-13 12:38:46 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             : #include "sdattr.hxx"
      21             : #include "optsitem.hxx"
      22             : #include "sdresid.hxx"
      23             : #include "prntopts.hxx"
      24             : #include "app.hrc"
      25             : #include <svl/intitem.hxx>
      26             : #include <sfx2/request.hxx>
      27             : 
      28             : /**
      29             :  *  dialog to adjust print options
      30             :  */
      31           0 : SdPrintOptions::SdPrintOptions( vcl::Window* pParent, const SfxItemSet& rInAttrs ) :
      32             :     SfxTabPage          ( pParent, "prntopts" , "modules/simpress/ui/prntopts.ui" , &rInAttrs ),
      33           0 :     rOutAttrs           ( rInAttrs )
      34             : {
      35           0 :     get( m_pFrmContent , "contentframe" );
      36           0 :     get( m_pCbxDraw , "drawingcb" );
      37           0 :     get( m_pCbxNotes , "notecb" );
      38           0 :     get( m_pCbxHandout , "handoutcb" );
      39           0 :     get( m_pCbxOutline , "outlinecb");
      40           0 :     get( m_pRbtColor , "defaultrb" );
      41           0 :     get( m_pRbtGrayscale , "grayscalerb" );
      42           0 :     get( m_pRbtBlackWhite , "blackwhiterb" );
      43           0 :     get( m_pCbxPagename , "pagenmcb" );
      44           0 :     get( m_pCbxDate , "datecb" );
      45           0 :     get( m_pCbxTime , "timecb" );
      46           0 :     get( m_pCbxHiddenPages , "hiddenpgcb" );
      47           0 :     get( m_pRbtDefault , "pagedefaultrb" );
      48           0 :     get( m_pRbtPagesize , "fittopgrb" );
      49           0 :     get( m_pRbtPagetile , "tilepgrb" );
      50           0 :     get( m_pRbtBooklet , "brouchrb" );
      51           0 :     get( m_pCbxFront , "frontcb" );
      52           0 :     get( m_pCbxBack , "backcb" );
      53           0 :     get( m_pCbxPaperbin , "papertryfrmprntrcb" );
      54             : 
      55           0 :     Link<> aLink = LINK( this, SdPrintOptions, ClickBookletHdl );
      56           0 :     m_pRbtDefault->SetClickHdl( aLink );
      57           0 :     m_pRbtPagesize->SetClickHdl( aLink );
      58           0 :     m_pRbtPagetile->SetClickHdl( aLink );
      59           0 :     m_pRbtBooklet->SetClickHdl( aLink );
      60             : 
      61           0 :     aLink = LINK( this, SdPrintOptions, ClickCheckboxHdl );
      62           0 :     m_pCbxDraw->SetClickHdl( aLink );
      63           0 :     m_pCbxNotes->SetClickHdl( aLink );
      64           0 :     m_pCbxHandout->SetClickHdl( aLink );
      65           0 :     m_pCbxOutline->SetClickHdl( aLink );
      66             : 
      67             : #ifndef MACOSX
      68           0 :     SetDrawMode();
      69             : #endif
      70             : 
      71           0 :     m_pCbxFront->SetAccessibleRelationLabeledBy( m_pRbtBooklet );
      72           0 :     m_pCbxBack->SetAccessibleRelationLabeledBy( m_pRbtBooklet );
      73           0 : }
      74             : 
      75           0 : SdPrintOptions::~SdPrintOptions()
      76             : {
      77           0 :     disposeOnce();
      78           0 : }
      79             : 
      80           0 : void SdPrintOptions::dispose()
      81             : {
      82           0 :     m_pFrmContent.clear();
      83           0 :     m_pCbxDraw.clear();
      84           0 :     m_pCbxNotes.clear();
      85           0 :     m_pCbxHandout.clear();
      86           0 :     m_pCbxOutline.clear();
      87           0 :     m_pRbtColor.clear();
      88           0 :     m_pRbtGrayscale.clear();
      89           0 :     m_pRbtBlackWhite.clear();
      90           0 :     m_pCbxPagename.clear();
      91           0 :     m_pCbxDate.clear();
      92           0 :     m_pCbxTime.clear();
      93           0 :     m_pCbxHiddenPages.clear();
      94           0 :     m_pRbtDefault.clear();
      95           0 :     m_pRbtPagesize.clear();
      96           0 :     m_pRbtPagetile.clear();
      97           0 :     m_pRbtBooklet.clear();
      98           0 :     m_pCbxFront.clear();
      99           0 :     m_pCbxBack.clear();
     100           0 :     m_pCbxPaperbin.clear();
     101           0 :     SfxTabPage::dispose();
     102           0 : }
     103             : 
     104           0 : bool SdPrintOptions::FillItemSet( SfxItemSet* rAttrs )
     105             : {
     106           0 :     if( m_pCbxDraw->IsValueChangedFromSaved() ||
     107           0 :         m_pCbxNotes->IsValueChangedFromSaved() ||
     108           0 :         m_pCbxHandout->IsValueChangedFromSaved() ||
     109           0 :         m_pCbxOutline->IsValueChangedFromSaved() ||
     110           0 :         m_pCbxDate->IsValueChangedFromSaved() ||
     111           0 :         m_pCbxTime->IsValueChangedFromSaved() ||
     112           0 :         m_pCbxPagename->IsValueChangedFromSaved() ||
     113           0 :         m_pCbxHiddenPages->IsValueChangedFromSaved() ||
     114           0 :         m_pRbtPagesize->IsValueChangedFromSaved() ||
     115           0 :         m_pRbtPagetile->IsValueChangedFromSaved() ||
     116           0 :         m_pRbtBooklet->IsValueChangedFromSaved() ||
     117           0 :         m_pCbxFront->IsValueChangedFromSaved() ||
     118           0 :         m_pCbxBack->IsValueChangedFromSaved() ||
     119           0 :         m_pCbxPaperbin->IsValueChangedFromSaved() ||
     120           0 :         m_pRbtColor->IsValueChangedFromSaved() ||
     121           0 :         m_pRbtGrayscale->IsValueChangedFromSaved()||
     122           0 :         m_pRbtBlackWhite->IsValueChangedFromSaved())
     123             :     {
     124           0 :         SdOptionsPrintItem aOptions( ATTR_OPTIONS_PRINT );
     125             : 
     126           0 :         aOptions.GetOptionsPrint().SetDraw( m_pCbxDraw->IsChecked() );
     127           0 :         aOptions.GetOptionsPrint().SetNotes( m_pCbxNotes->IsChecked() );
     128           0 :         aOptions.GetOptionsPrint().SetHandout( m_pCbxHandout->IsChecked() );
     129           0 :         aOptions.GetOptionsPrint().SetOutline( m_pCbxOutline->IsChecked() );
     130           0 :         aOptions.GetOptionsPrint().SetDate( m_pCbxDate->IsChecked() );
     131           0 :         aOptions.GetOptionsPrint().SetTime( m_pCbxTime->IsChecked() );
     132           0 :         aOptions.GetOptionsPrint().SetPagename( m_pCbxPagename->IsChecked() );
     133           0 :         aOptions.GetOptionsPrint().SetHiddenPages( m_pCbxHiddenPages->IsChecked() );
     134           0 :         aOptions.GetOptionsPrint().SetPagesize( m_pRbtPagesize->IsChecked() );
     135           0 :         aOptions.GetOptionsPrint().SetPagetile( m_pRbtPagetile->IsChecked() );
     136           0 :         aOptions.GetOptionsPrint().SetBooklet( m_pRbtBooklet->IsChecked() );
     137           0 :         aOptions.GetOptionsPrint().SetFrontPage( m_pCbxFront->IsChecked() );
     138           0 :         aOptions.GetOptionsPrint().SetBackPage( m_pCbxBack->IsChecked() );
     139           0 :         aOptions.GetOptionsPrint().SetPaperbin( m_pCbxPaperbin->IsChecked() );
     140             : 
     141           0 :         sal_uInt16 nQuality = 0; // Standard, also Color
     142           0 :         if( m_pRbtGrayscale->IsChecked() )
     143           0 :             nQuality = 1;
     144           0 :         if( m_pRbtBlackWhite->IsChecked() )
     145           0 :             nQuality = 2;
     146           0 :         aOptions.GetOptionsPrint().SetOutputQuality( nQuality );
     147             : 
     148           0 :         rAttrs->Put( aOptions );
     149             : 
     150           0 :         return true;
     151             :     }
     152           0 :     return false;
     153             : }
     154             : 
     155           0 : void SdPrintOptions::Reset( const SfxItemSet* rAttrs )
     156             : {
     157           0 :     const SdOptionsPrintItem* pPrintOpts = NULL;
     158           0 :     if( SfxItemState::SET == rAttrs->GetItemState( ATTR_OPTIONS_PRINT, false,
     159           0 :                             reinterpret_cast<const SfxPoolItem**>(&pPrintOpts) ) )
     160             :     {
     161           0 :         m_pCbxDraw->Check(              pPrintOpts->GetOptionsPrint().IsDraw() );
     162           0 :         m_pCbxNotes->Check(             pPrintOpts->GetOptionsPrint().IsNotes() );
     163           0 :         m_pCbxHandout->Check(           pPrintOpts->GetOptionsPrint().IsHandout() );
     164           0 :         m_pCbxOutline->Check(           pPrintOpts->GetOptionsPrint().IsOutline() );
     165           0 :         m_pCbxDate->Check(              pPrintOpts->GetOptionsPrint().IsDate() );
     166           0 :         m_pCbxTime->Check(              pPrintOpts->GetOptionsPrint().IsTime() );
     167           0 :         m_pCbxPagename->Check(          pPrintOpts->GetOptionsPrint().IsPagename() );
     168           0 :         m_pCbxHiddenPages->Check(       pPrintOpts->GetOptionsPrint().IsHiddenPages() );
     169           0 :         m_pRbtPagesize->Check(          pPrintOpts->GetOptionsPrint().IsPagesize() );
     170           0 :         m_pRbtPagetile->Check(          pPrintOpts->GetOptionsPrint().IsPagetile() );
     171           0 :         m_pRbtBooklet->Check(           pPrintOpts->GetOptionsPrint().IsBooklet() );
     172           0 :         m_pCbxFront->Check(             pPrintOpts->GetOptionsPrint().IsFrontPage() );
     173           0 :         m_pCbxBack->Check(              pPrintOpts->GetOptionsPrint().IsBackPage() );
     174           0 :         m_pCbxPaperbin->Check(          pPrintOpts->GetOptionsPrint().IsPaperbin() );
     175             : 
     176           0 :         if( !m_pRbtPagesize->IsChecked() &&
     177           0 :             !m_pRbtPagetile->IsChecked() &&
     178           0 :             !m_pRbtBooklet->IsChecked() )
     179             :         {
     180           0 :             m_pRbtDefault->Check();
     181             :         }
     182             : 
     183           0 :         sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality();
     184           0 :         if( nQuality == 0 )
     185           0 :             m_pRbtColor->Check();
     186           0 :         else if( nQuality == 1 )
     187           0 :             m_pRbtGrayscale->Check();
     188             :         else
     189           0 :             m_pRbtBlackWhite->Check();
     190             :     }
     191           0 :     m_pCbxDraw->SaveValue();
     192           0 :     m_pCbxNotes->SaveValue();
     193           0 :     m_pCbxHandout->SaveValue();
     194           0 :     m_pCbxOutline->SaveValue();
     195           0 :     m_pCbxDate->SaveValue();
     196           0 :     m_pCbxTime->SaveValue();
     197           0 :     m_pCbxPagename->SaveValue();
     198           0 :     m_pCbxHiddenPages->SaveValue();
     199           0 :     m_pRbtPagesize->SaveValue();
     200           0 :     m_pRbtPagetile->SaveValue();
     201           0 :     m_pRbtBooklet->SaveValue();
     202           0 :     m_pCbxPaperbin->SaveValue();
     203           0 :     m_pRbtColor->SaveValue();
     204           0 :     m_pRbtGrayscale->SaveValue();
     205           0 :     m_pRbtBlackWhite->SaveValue();
     206             : 
     207           0 :     ClickBookletHdl( NULL );
     208           0 : }
     209             : 
     210           0 : VclPtr<SfxTabPage> SdPrintOptions::Create( vcl::Window* pWindow,
     211             :                                            const SfxItemSet* rOutAttrs )
     212             : {
     213           0 :     return VclPtr<SdPrintOptions>::Create( pWindow, *rOutAttrs );
     214             : }
     215             : 
     216           0 : IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, CheckBox *, pCbx )
     217             : {
     218             :     // there must be at least one of them checked
     219           0 :     if( !m_pCbxDraw->IsChecked() && !m_pCbxNotes->IsChecked() && !m_pCbxOutline->IsChecked() && !m_pCbxHandout->IsChecked() )
     220           0 :         pCbx->Check();
     221             : 
     222           0 :     updateControls();
     223           0 :     return 0;
     224             : }
     225             : 
     226           0 : IMPL_LINK_NOARG(SdPrintOptions, ClickBookletHdl)
     227             : {
     228           0 :     updateControls();
     229           0 :     return 0;
     230             : }
     231             : 
     232           0 : void SdPrintOptions::updateControls()
     233             : {
     234           0 :     m_pCbxFront->Enable(m_pRbtBooklet->IsChecked());
     235           0 :     m_pCbxBack->Enable(m_pRbtBooklet->IsChecked());
     236             : 
     237           0 :     m_pCbxDate->Enable( !m_pRbtBooklet->IsChecked() );
     238           0 :     m_pCbxTime->Enable( !m_pRbtBooklet->IsChecked() );
     239             : 
     240           0 :     m_pCbxPagename->Enable( !m_pRbtBooklet->IsChecked() && (m_pCbxDraw->IsChecked() || m_pCbxNotes->IsChecked() || m_pCbxOutline->IsChecked()) );
     241           0 : }
     242             : 
     243           0 : void    SdPrintOptions::SetDrawMode()
     244             : {
     245           0 :     if(m_pCbxNotes->IsVisible())
     246             :     {
     247           0 :         m_pFrmContent->Hide();
     248             :     }
     249           0 : }
     250             : 
     251           0 : void SdPrintOptions::PageCreated (const SfxAllItemSet&
     252             : #ifdef MACOSX
     253             :                                   aSet
     254             : #endif
     255             :                                   )
     256             : {
     257             : #ifdef MACOSX
     258             :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,false);
     259             :     if (pFlagItem)
     260             :     {
     261             :         sal_uInt32 nFlags=pFlagItem->GetValue();
     262             :         if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
     263             :             SetDrawMode();
     264             :     }
     265             : #else
     266           0 :     SetDrawMode();
     267             : #endif
     268           0 : }
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11