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

Generated by: LCOV version 1.10