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

Generated by: LCOV version 1.10