LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - prntopts.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 148 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 "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 : }
      78             : 
      79           0 : bool SdPrintOptions::FillItemSet( SfxItemSet* rAttrs )
      80             : {
      81           0 :     if( m_pCbxDraw->IsValueChangedFromSaved() ||
      82           0 :         m_pCbxNotes->IsValueChangedFromSaved() ||
      83           0 :         m_pCbxHandout->IsValueChangedFromSaved() ||
      84           0 :         m_pCbxOutline->IsValueChangedFromSaved() ||
      85           0 :         m_pCbxDate->IsValueChangedFromSaved() ||
      86           0 :         m_pCbxTime->IsValueChangedFromSaved() ||
      87           0 :         m_pCbxPagename->IsValueChangedFromSaved() ||
      88           0 :         m_pCbxHiddenPages->IsValueChangedFromSaved() ||
      89           0 :         m_pRbtPagesize->IsValueChangedFromSaved() ||
      90           0 :         m_pRbtPagetile->IsValueChangedFromSaved() ||
      91           0 :         m_pRbtBooklet->IsValueChangedFromSaved() ||
      92           0 :         m_pCbxFront->IsValueChangedFromSaved() ||
      93           0 :         m_pCbxBack->IsValueChangedFromSaved() ||
      94           0 :         m_pCbxPaperbin->IsValueChangedFromSaved() ||
      95           0 :         m_pRbtColor->IsValueChangedFromSaved() ||
      96           0 :         m_pRbtGrayscale->IsValueChangedFromSaved()||
      97           0 :         m_pRbtBlackWhite->IsValueChangedFromSaved())
      98             :     {
      99           0 :         SdOptionsPrintItem aOptions( ATTR_OPTIONS_PRINT );
     100             : 
     101           0 :         aOptions.GetOptionsPrint().SetDraw( m_pCbxDraw->IsChecked() );
     102           0 :         aOptions.GetOptionsPrint().SetNotes( m_pCbxNotes->IsChecked() );
     103           0 :         aOptions.GetOptionsPrint().SetHandout( m_pCbxHandout->IsChecked() );
     104           0 :         aOptions.GetOptionsPrint().SetOutline( m_pCbxOutline->IsChecked() );
     105           0 :         aOptions.GetOptionsPrint().SetDate( m_pCbxDate->IsChecked() );
     106           0 :         aOptions.GetOptionsPrint().SetTime( m_pCbxTime->IsChecked() );
     107           0 :         aOptions.GetOptionsPrint().SetPagename( m_pCbxPagename->IsChecked() );
     108           0 :         aOptions.GetOptionsPrint().SetHiddenPages( m_pCbxHiddenPages->IsChecked() );
     109           0 :         aOptions.GetOptionsPrint().SetPagesize( m_pRbtPagesize->IsChecked() );
     110           0 :         aOptions.GetOptionsPrint().SetPagetile( m_pRbtPagetile->IsChecked() );
     111           0 :         aOptions.GetOptionsPrint().SetBooklet( m_pRbtBooklet->IsChecked() );
     112           0 :         aOptions.GetOptionsPrint().SetFrontPage( m_pCbxFront->IsChecked() );
     113           0 :         aOptions.GetOptionsPrint().SetBackPage( m_pCbxBack->IsChecked() );
     114           0 :         aOptions.GetOptionsPrint().SetPaperbin( m_pCbxPaperbin->IsChecked() );
     115             : 
     116           0 :         sal_uInt16 nQuality = 0; // Standard, also Color
     117           0 :         if( m_pRbtGrayscale->IsChecked() )
     118           0 :             nQuality = 1;
     119           0 :         if( m_pRbtBlackWhite->IsChecked() )
     120           0 :             nQuality = 2;
     121           0 :         aOptions.GetOptionsPrint().SetOutputQuality( nQuality );
     122             : 
     123           0 :         rAttrs->Put( aOptions );
     124             : 
     125           0 :         return true;
     126             :     }
     127           0 :     return false;
     128             : }
     129             : 
     130           0 : void SdPrintOptions::Reset( const SfxItemSet* rAttrs )
     131             : {
     132           0 :     const SdOptionsPrintItem* pPrintOpts = NULL;
     133           0 :     if( SfxItemState::SET == rAttrs->GetItemState( ATTR_OPTIONS_PRINT, false,
     134           0 :                             (const SfxPoolItem**) &pPrintOpts ) )
     135             :     {
     136           0 :         m_pCbxDraw->Check(              pPrintOpts->GetOptionsPrint().IsDraw() );
     137           0 :         m_pCbxNotes->Check(             pPrintOpts->GetOptionsPrint().IsNotes() );
     138           0 :         m_pCbxHandout->Check(           pPrintOpts->GetOptionsPrint().IsHandout() );
     139           0 :         m_pCbxOutline->Check(           pPrintOpts->GetOptionsPrint().IsOutline() );
     140           0 :         m_pCbxDate->Check(              pPrintOpts->GetOptionsPrint().IsDate() );
     141           0 :         m_pCbxTime->Check(              pPrintOpts->GetOptionsPrint().IsTime() );
     142           0 :         m_pCbxPagename->Check(          pPrintOpts->GetOptionsPrint().IsPagename() );
     143           0 :         m_pCbxHiddenPages->Check(       pPrintOpts->GetOptionsPrint().IsHiddenPages() );
     144           0 :         m_pRbtPagesize->Check(          pPrintOpts->GetOptionsPrint().IsPagesize() );
     145           0 :         m_pRbtPagetile->Check(          pPrintOpts->GetOptionsPrint().IsPagetile() );
     146           0 :         m_pRbtBooklet->Check(           pPrintOpts->GetOptionsPrint().IsBooklet() );
     147           0 :         m_pCbxFront->Check(             pPrintOpts->GetOptionsPrint().IsFrontPage() );
     148           0 :         m_pCbxBack->Check(              pPrintOpts->GetOptionsPrint().IsBackPage() );
     149           0 :         m_pCbxPaperbin->Check(          pPrintOpts->GetOptionsPrint().IsPaperbin() );
     150             : 
     151           0 :         if( !m_pRbtPagesize->IsChecked() &&
     152           0 :             !m_pRbtPagetile->IsChecked() &&
     153           0 :             !m_pRbtBooklet->IsChecked() )
     154             :         {
     155           0 :             m_pRbtDefault->Check();
     156             :         }
     157             : 
     158           0 :         sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality();
     159           0 :         if( nQuality == 0 )
     160           0 :             m_pRbtColor->Check();
     161           0 :         else if( nQuality == 1 )
     162           0 :             m_pRbtGrayscale->Check();
     163             :         else
     164           0 :             m_pRbtBlackWhite->Check();
     165             :     }
     166           0 :     m_pCbxDraw->SaveValue();
     167           0 :     m_pCbxNotes->SaveValue();
     168           0 :     m_pCbxHandout->SaveValue();
     169           0 :     m_pCbxOutline->SaveValue();
     170           0 :     m_pCbxDate->SaveValue();
     171           0 :     m_pCbxTime->SaveValue();
     172           0 :     m_pCbxPagename->SaveValue();
     173           0 :     m_pCbxHiddenPages->SaveValue();
     174           0 :     m_pRbtPagesize->SaveValue();
     175           0 :     m_pRbtPagetile->SaveValue();
     176           0 :     m_pRbtBooklet->SaveValue();
     177           0 :     m_pCbxPaperbin->SaveValue();
     178           0 :     m_pRbtColor->SaveValue();
     179           0 :     m_pRbtGrayscale->SaveValue();
     180           0 :     m_pRbtBlackWhite->SaveValue();
     181             : 
     182           0 :     ClickBookletHdl( NULL );
     183           0 : }
     184             : 
     185           0 : SfxTabPage* SdPrintOptions::Create( vcl::Window* pWindow,
     186             :                 const SfxItemSet* rOutAttrs )
     187             : {
     188           0 :     return( new SdPrintOptions( pWindow, *rOutAttrs ) );
     189             : }
     190             : 
     191           0 : IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, CheckBox *, pCbx )
     192             : {
     193             :     // there must be at least one of them checked
     194           0 :     if( !m_pCbxDraw->IsChecked() && !m_pCbxNotes->IsChecked() && !m_pCbxOutline->IsChecked() && !m_pCbxHandout->IsChecked() )
     195           0 :         pCbx->Check();
     196             : 
     197           0 :     updateControls();
     198           0 :     return 0;
     199             : }
     200             : 
     201           0 : IMPL_LINK_NOARG(SdPrintOptions, ClickBookletHdl)
     202             : {
     203           0 :     updateControls();
     204           0 :     return 0;
     205             : }
     206             : 
     207           0 : void SdPrintOptions::updateControls()
     208             : {
     209           0 :     m_pCbxFront->Enable(m_pRbtBooklet->IsChecked());
     210           0 :     m_pCbxBack->Enable(m_pRbtBooklet->IsChecked());
     211             : 
     212           0 :     m_pCbxDate->Enable( !m_pRbtBooklet->IsChecked() );
     213           0 :     m_pCbxTime->Enable( !m_pRbtBooklet->IsChecked() );
     214             : 
     215           0 :     m_pCbxPagename->Enable( !m_pRbtBooklet->IsChecked() && (m_pCbxDraw->IsChecked() || m_pCbxNotes->IsChecked() || m_pCbxOutline->IsChecked()) );
     216           0 : }
     217             : 
     218           0 : void    SdPrintOptions::SetDrawMode()
     219             : {
     220           0 :     if(m_pCbxNotes->IsVisible())
     221             :     {
     222           0 :         m_pFrmContent->Hide();
     223             :     }
     224           0 : }
     225             : 
     226           0 : void SdPrintOptions::PageCreated (const SfxAllItemSet&
     227             : #ifdef MACOSX
     228             :                                   aSet
     229             : #endif
     230             :                                   )
     231             : {
     232             : #ifdef MACOSX
     233             :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,false);
     234             :     if (pFlagItem)
     235             :     {
     236             :         sal_uInt32 nFlags=pFlagItem->GetValue();
     237             :         if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
     238             :             SetDrawMode();
     239             :     }
     240             : #else
     241           0 :     SetDrawMode();
     242             : #endif
     243           0 : }
     244             : 
     245             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10