LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/config - prtopt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 45 75 60.0 %
Date: 2012-12-27 Functions: 3 6 50.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             : #include <unotools/configmgr.hxx>
      22             : #include <prtopt.hxx>
      23             : #include <osl/diagnose.h>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : 
      27             : #include <unomid.h>
      28             : 
      29             : 
      30             : using namespace utl;
      31             : using rtl::OUString;
      32             : using namespace com::sun::star::uno;
      33             : 
      34             : /*--------------------------------------------------------------------
      35             :      Description: Ctor
      36             :  --------------------------------------------------------------------*/
      37             : 
      38          26 : Sequence<OUString> SwPrintOptions::GetPropertyNames()
      39             : {
      40             :     static const char* aPropNames[] =
      41             :     {
      42             :         "Content/Graphic",              //  0
      43             :         "Content/Table",                //  1
      44             :         "Content/Control",              //  2
      45             :         "Content/Background",           //  3
      46             :         "Content/PrintBlack",           //  4
      47             :         "Content/Note",                 //  5
      48             :         "Page/Reversed",                //  6
      49             :         "Page/Brochure",                //  7
      50             :         "Page/BrochureRightToLeft",     //  8
      51             :         "Output/SinglePrintJob",        //  9
      52             :         "Output/Fax",                   // 10
      53             :         "Papertray/FromPrinterSetup",   // 11
      54             :         "Content/Drawing",              // 12 not in SW/Web
      55             :         "Page/LeftPage",                // 13 not in SW/Web
      56             :         "Page/RightPage",               // 14 not in SW/Web
      57             :         "EmptyPages",                   // 15 not in SW/Web
      58             :         "Content/PrintPlaceholders",    // 16 not in Sw/Web
      59             :         "Content/PrintHiddenText"       // 17 not in Sw/Web
      60             :     };
      61          26 :     const int nCount = bIsWeb ? 12 : 18;
      62          26 :     Sequence<OUString> aNames(nCount);
      63          26 :     OUString* pNames = aNames.getArray();
      64         494 :     for(int i = 0; i < nCount; i++)
      65             :     {
      66         468 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
      67             :     }
      68          26 :     return aNames;
      69             : }
      70             : 
      71          26 : SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
      72             :     ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"),
      73             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
      74          26 :     bIsWeb(bWeb)
      75             : {
      76          26 :     bPrintPageBackground = !bWeb;
      77          26 :     bPrintBlackFont = bWeb;
      78          26 :     bPrintTextPlaceholder = bPrintHiddenText = sal_False;
      79          26 :     if (bWeb)
      80           0 :         bPrintEmptyPages = sal_False;
      81             : 
      82          26 :     Sequence<OUString> aNames = GetPropertyNames();
      83          26 :     Sequence<Any> aValues = GetProperties(aNames);
      84          26 :     const Any* pValues = aValues.getConstArray();
      85             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
      86          26 :     if(aValues.getLength() == aNames.getLength())
      87             :     {
      88         494 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
      89             :         {
      90         468 :             if(pValues[nProp].hasValue())
      91             :             {
      92         468 :                 switch(nProp)
      93             :                 {
      94          26 :                     case  0: bPrintGraphic      = *(sal_Bool*)pValues[nProp].getValue(); break;
      95          26 :                     case  1: bPrintTable            = *(sal_Bool*)pValues[nProp].getValue();  break;
      96          26 :                     case  2: bPrintControl      = *(sal_Bool*)pValues[nProp].getValue() ;  break;
      97          26 :                     case  3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue();  break;
      98          26 :                     case  4: bPrintBlackFont        = *(sal_Bool*)pValues[nProp].getValue();  break;
      99             :                     case  5:
     100             :                     {
     101          26 :                         sal_Int32 nTmp = 0;
     102          26 :                         pValues[nProp] >>=  nTmp;
     103          26 :                         nPrintPostIts = (sal_Int16)nTmp;
     104             :                     }
     105          26 :                     break;
     106          26 :                     case  6: bPrintReverse      = *(sal_Bool*)pValues[nProp].getValue();  break;
     107          26 :                     case  7: bPrintProspect      = *(sal_Bool*)pValues[nProp].getValue();  break;
     108          26 :                     case  8: bPrintProspectRTL  = *(sal_Bool*)pValues[nProp].getValue();  break;
     109          26 :                     case  9: bPrintSingleJobs   = *(sal_Bool*)pValues[nProp].getValue();  break;
     110          26 :                     case 10: pValues[nProp] >>= sFaxName;  break;
     111          26 :                     case 11: bPaperFromSetup    = *(sal_Bool*)pValues[nProp].getValue();  break;
     112          26 :                     case 12: bPrintDraw         = *(sal_Bool*)pValues[nProp].getValue() ;  break;
     113          26 :                     case 13: bPrintLeftPages    = *(sal_Bool*)pValues[nProp].getValue();  break;
     114          26 :                     case 14: bPrintRightPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
     115          26 :                     case 15: bPrintEmptyPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
     116          26 :                     case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue();  break;
     117          26 :                     case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue();  break;
     118             :                 }
     119             :             }
     120             :         }
     121             :     }
     122             : 
     123             :     // currently there is just one checkbox for print drawings and print graphics
     124             :     // In the UI. (File/Print dialog and Tools/Options/.../Print)
     125             :     // And since print graphics is the only available in Writer and WrtierWeb ...
     126             : 
     127          26 :     bPrintDraw = bPrintGraphic;
     128          26 : }
     129             : 
     130          18 : SwPrintOptions::~SwPrintOptions()
     131             : {
     132          18 : }
     133             : 
     134             : 
     135           0 : void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
     136             : 
     137           0 : void    SwPrintOptions::Commit()
     138             : {
     139           0 :     Sequence<OUString> aNames = GetPropertyNames();
     140             : 
     141           0 :     Sequence<Any> aValues(aNames.getLength());
     142           0 :     Any* pValues = aValues.getArray();
     143             : 
     144           0 :     const Type& rType = ::getBooleanCppuType();
     145             :     sal_Bool bVal;
     146           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     147             :     {
     148           0 :         switch(nProp)
     149             :         {
     150           0 :             case  0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
     151           0 :             case  1: bVal = bPrintTable         ;pValues[nProp].setValue(&bVal, rType);  break;
     152           0 :             case  2: bVal = bPrintControl        ; pValues[nProp].setValue(&bVal, rType);  break;
     153           0 :             case  3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType);  break;
     154           0 :             case  4: bVal = bPrintBlackFont     ; pValues[nProp].setValue(&bVal, rType);  break;
     155           0 :             case  5: pValues[nProp] <<=  (sal_Int32)nPrintPostIts       ; break;
     156           0 :             case  6: bVal = bPrintReverse       ; pValues[nProp].setValue(&bVal, rType);  break;
     157           0 :             case  7: bVal = bPrintProspect      ; pValues[nProp].setValue(&bVal, rType);  break;
     158           0 :             case  8: bVal = bPrintProspectRTL      ; pValues[nProp].setValue(&bVal, rType);  break;
     159           0 :             case  9: bVal = bPrintSingleJobs     ; pValues[nProp].setValue(&bVal, rType);  break;
     160           0 :             case 10: pValues[nProp] <<= sFaxName;  break;
     161           0 :             case 11: bVal = bPaperFromSetup     ; pValues[nProp].setValue(&bVal, rType);  break;
     162           0 :             case 12: bVal = bPrintDraw           ; pValues[nProp].setValue(&bVal, rType);  break;
     163           0 :             case 13: bVal = bPrintLeftPages      ; pValues[nProp].setValue(&bVal, rType);  break;
     164           0 :             case 14: bVal = bPrintRightPages    ; pValues[nProp].setValue(&bVal, rType);  break;
     165           0 :             case 15: bVal = bPrintEmptyPages    ; pValues[nProp].setValue(&bVal, rType);  break;
     166           0 :             case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType);  break;
     167           0 :             case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType);  break;
     168             :         }
     169             :     }
     170             : 
     171             :     // currently there is just one checkbox for print drawings and print graphics
     172             :     // In the UI. (File/Print dialog and Tools/Options/.../Print)
     173             :     // And since print graphics is the only available in Writer and WrtierWeb ...
     174           0 :     bPrintDraw = bPrintGraphic;
     175             : 
     176           0 :     PutProperties(aNames, aValues);
     177           0 : }
     178             : 
     179             : 
     180             : 
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10