LCOV - code coverage report
Current view: top level - libreoffice/sc/source/core/tool - printopt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 Functions: 0 24 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 <com/sun/star/uno/Any.hxx>
      21             : #include <com/sun/star/uno/Sequence.hxx>
      22             : 
      23             : #include "printopt.hxx"
      24             : #include "miscuno.hxx"
      25             : 
      26             : using namespace utl;
      27             : using namespace com::sun::star::uno;
      28             : 
      29             : using ::rtl::OUString;
      30             : 
      31             : // -----------------------------------------------------------------------
      32             : 
      33           0 : TYPEINIT1(ScTpPrintItem, SfxPoolItem);
      34             : 
      35             : // -----------------------------------------------------------------------
      36             : 
      37           0 : ScPrintOptions::ScPrintOptions()
      38             : {
      39           0 :     SetDefaults();
      40           0 : }
      41             : 
      42           0 : ScPrintOptions::ScPrintOptions( const ScPrintOptions& rCpy ) :
      43             :     bSkipEmpty( rCpy.bSkipEmpty ),
      44           0 :     bAllSheets( rCpy.bAllSheets )
      45             : {
      46           0 : }
      47             : 
      48           0 : ScPrintOptions::~ScPrintOptions()
      49             : {
      50           0 : }
      51             : 
      52           0 : void ScPrintOptions::SetDefaults()
      53             : {
      54           0 :     bSkipEmpty = sal_True;
      55           0 :     bAllSheets = false;
      56           0 : }
      57             : 
      58           0 : const ScPrintOptions& ScPrintOptions::operator=( const ScPrintOptions& rCpy )
      59             : {
      60           0 :     bSkipEmpty = rCpy.bSkipEmpty;
      61           0 :     bAllSheets = rCpy.bAllSheets;
      62           0 :     return *this;
      63             : }
      64             : 
      65           0 : bool ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const
      66             : {
      67             :     return bSkipEmpty == rOpt.bSkipEmpty
      68           0 :         && bAllSheets == rOpt.bAllSheets;
      69             : }
      70             : 
      71           0 : bool ScPrintOptions::operator!=( const ScPrintOptions& rOpt ) const
      72             : {
      73           0 :     return !(operator==(rOpt));
      74             : }
      75             : 
      76             : // -----------------------------------------------------------------------
      77             : 
      78             : 
      79           0 : ScTpPrintItem::ScTpPrintItem( sal_uInt16 nWhichP, const ScPrintOptions& rOpt ) :
      80             :     SfxPoolItem ( nWhichP ),
      81           0 :     theOptions  ( rOpt )
      82             : {
      83           0 : }
      84             : 
      85           0 : ScTpPrintItem::ScTpPrintItem( const ScTpPrintItem& rItem ) :
      86             :     SfxPoolItem ( rItem ),
      87           0 :     theOptions  ( rItem.theOptions )
      88             : {
      89           0 : }
      90             : 
      91           0 : ScTpPrintItem::~ScTpPrintItem()
      92             : {
      93           0 : }
      94             : 
      95           0 : String ScTpPrintItem::GetValueText() const
      96             : {
      97           0 :     return rtl::OUString("ScTpPrintItem");
      98             : }
      99             : 
     100           0 : int ScTpPrintItem::operator==( const SfxPoolItem& rItem ) const
     101             : {
     102             :     OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
     103             : 
     104           0 :     const ScTpPrintItem& rPItem = (const ScTpPrintItem&)rItem;
     105           0 :     return ( theOptions == rPItem.theOptions );
     106             : }
     107             : 
     108           0 : SfxPoolItem* ScTpPrintItem::Clone( SfxItemPool * ) const
     109             : {
     110           0 :     return new ScTpPrintItem( *this );
     111             : }
     112             : 
     113             : // -----------------------------------------------------------------------
     114             : 
     115             : #define CFGPATH_PRINT           "Office.Calc/Print"
     116             : 
     117             : #define SCPRINTOPT_EMPTYPAGES       0
     118             : #define SCPRINTOPT_ALLSHEETS        1
     119             : #define SCPRINTOPT_COUNT            2
     120             : 
     121           0 : Sequence<OUString> ScPrintCfg::GetPropertyNames()
     122             : {
     123             :     static const char* aPropNames[] =
     124             :     {
     125             :         "Page/EmptyPages",          // SCPRINTOPT_EMPTYPAGES
     126             :         "Other/AllSheets"           // SCPRINTOPT_ALLSHEETS
     127             :     };
     128           0 :     Sequence<OUString> aNames(SCPRINTOPT_COUNT);
     129           0 :     OUString* pNames = aNames.getArray();
     130           0 :     for(int i = 0; i < SCPRINTOPT_COUNT; i++)
     131           0 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     132             : 
     133           0 :     return aNames;
     134             : }
     135             : 
     136           0 : ScPrintCfg::ScPrintCfg() :
     137           0 :     ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_PRINT )) )
     138             : {
     139           0 :     Sequence<OUString> aNames = GetPropertyNames();
     140           0 :     Sequence<Any> aValues = GetProperties(aNames);
     141           0 :     const Any* pValues = aValues.getConstArray();
     142             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     143           0 :     if(aValues.getLength() == aNames.getLength())
     144             :     {
     145           0 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     146             :         {
     147             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     148           0 :             if(pValues[nProp].hasValue())
     149             :             {
     150           0 :                 switch(nProp)
     151             :                 {
     152             :                     case SCPRINTOPT_EMPTYPAGES:
     153             :                         // reversed
     154           0 :                         SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     155           0 :                         break;
     156             :                     case SCPRINTOPT_ALLSHEETS:
     157           0 :                         SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     158           0 :                         break;
     159             :                 }
     160             :             }
     161             :         }
     162           0 :     }
     163           0 : }
     164             : 
     165             : 
     166           0 : void ScPrintCfg::Commit()
     167             : {
     168           0 :     Sequence<OUString> aNames = GetPropertyNames();
     169           0 :     Sequence<Any> aValues(aNames.getLength());
     170           0 :     Any* pValues = aValues.getArray();
     171             : 
     172           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     173             :     {
     174           0 :         switch(nProp)
     175             :         {
     176             :             case SCPRINTOPT_EMPTYPAGES:
     177             :                 // reversed
     178           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], !GetSkipEmpty() );
     179           0 :                 break;
     180             :             case SCPRINTOPT_ALLSHEETS:
     181           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAllSheets() );
     182           0 :                 break;
     183             :         }
     184             :     }
     185           0 :     PutProperties(aNames, aValues);
     186           0 : }
     187             : 
     188           0 : void ScPrintCfg::SetOptions( const ScPrintOptions& rNew )
     189             : {
     190           0 :     *(ScPrintOptions*)this = rNew;
     191           0 :     SetModified();
     192           0 : }
     193             : 
     194           0 : void ScPrintCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10