LCOV - code coverage report
Current view: top level - sw/source/uibase/config - prtopt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 74 75 98.7 %
Date: 2015-06-13 12:38:46 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             : // Ctor
      32         341 : 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         341 :     const int nCount = bIsWeb ? 12 : 18;
      56         341 :     Sequence<OUString> aNames(nCount);
      57         341 :     OUString* pNames = aNames.getArray();
      58        6473 :     for(int i = 0; i < nCount; i++)
      59             :     {
      60        6132 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
      61             :     }
      62         341 :     return aNames;
      63             : }
      64             : 
      65         340 : SwPrintOptions::SwPrintOptions(bool bWeb) :
      66             :     ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"),
      67         680 :         ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
      68        1020 :     bIsWeb(bWeb)
      69             : {
      70         340 :     bPrintPageBackground = !bWeb;
      71         340 :     bPrintBlackFont = bWeb;
      72         340 :     bPrintTextPlaceholder = bPrintHiddenText = false;
      73         340 :     if (bWeb)
      74           1 :         bPrintEmptyPages = false;
      75             : 
      76         340 :     Sequence<OUString> aNames = GetPropertyNames();
      77         680 :     Sequence<Any> aValues = GetProperties(aNames);
      78         340 :     const Any* pValues = aValues.getConstArray();
      79             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
      80         340 :     if(aValues.getLength() == aNames.getLength())
      81             :     {
      82        6454 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
      83             :         {
      84        6114 :             if(pValues[nProp].hasValue())
      85             :             {
      86        6114 :                 switch(nProp)
      87             :                 {
      88         340 :                     case  0: bPrintGraphic      = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;
      89         340 :                     case  1: bPrintTable            = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
      90         340 :                     case  2: bPrintControl      = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
      91         340 :                     case  3: bPrintPageBackground= *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
      92         340 :                     case  4: bPrintBlackFont        = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
      93             :                     case  5:
      94             :                     {
      95         340 :                         sal_Int32 nTmp = 0;
      96         340 :                         pValues[nProp] >>=  nTmp;
      97         340 :                         nPrintPostIts = (sal_Int16)nTmp;
      98             :                     }
      99         340 :                     break;
     100         340 :                     case  6: bPrintReverse      = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     101         340 :                     case  7: bPrintProspect      = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     102         340 :                     case  8: bPrintProspectRTL  = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     103         340 :                     case  9: bPrintSingleJobs   = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     104         340 :                     case 10: pValues[nProp] >>= sFaxName;  break;
     105         340 :                     case 11: bPaperFromSetup    = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     106         339 :                     case 12: bPrintDraw         = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     107         339 :                     case 13: bPrintLeftPages    = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     108         339 :                     case 14: bPrintRightPages       = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     109         339 :                     case 15: bPrintEmptyPages       = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     110         339 :                     case 16: bPrintTextPlaceholder = *static_cast<sal_Bool const *>(pValues[nProp].getValue());  break;
     111         339 :                     case 17: bPrintHiddenText = *static_cast<sal_Bool const *>(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         680 :     bPrintDraw = bPrintGraphic;
     122         340 : }
     123             : 
     124         334 : SwPrintOptions::~SwPrintOptions()
     125             : {
     126         334 : }
     127             : 
     128           0 : void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     129             : 
     130           1 : void SwPrintOptions::ImplCommit()
     131             : {
     132           1 :     Sequence<OUString> aNames = GetPropertyNames();
     133             : 
     134           2 :     Sequence<Any> aValues(aNames.getLength());
     135           1 :     Any* pValues = aValues.getArray();
     136             : 
     137          19 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     138             :     {
     139          18 :         switch(nProp)
     140             :         {
     141           1 :             case  0: pValues[nProp] <<= bPrintGraphic; break;
     142           1 :             case  1: pValues[nProp] <<= bPrintTable; break;
     143           1 :             case  2: pValues[nProp] <<= bPrintControl; break;
     144           1 :             case  3: pValues[nProp] <<= bPrintPageBackground; break;
     145           1 :             case  4: pValues[nProp] <<= bPrintBlackFont; break;
     146           1 :             case  5: pValues[nProp] <<=  (sal_Int32)nPrintPostIts       ; break;
     147           1 :             case  6: pValues[nProp] <<= bPrintReverse; break;
     148           1 :             case  7: pValues[nProp] <<= bPrintProspect; break;
     149           1 :             case  8: pValues[nProp] <<= bPrintProspectRTL; break;
     150           1 :             case  9: pValues[nProp] <<= bPrintSingleJobs; break;
     151           1 :             case 10: pValues[nProp] <<= sFaxName;  break;
     152           1 :             case 11: pValues[nProp] <<= bPaperFromSetup; break;
     153           1 :             case 12: pValues[nProp] <<= bPrintDraw; break;
     154           1 :             case 13: pValues[nProp] <<= bPrintLeftPages; break;
     155           1 :             case 14: pValues[nProp] <<= bPrintRightPages; break;
     156           1 :             case 15: pValues[nProp] <<= bPrintEmptyPages; break;
     157           1 :             case 16: pValues[nProp] <<= bPrintTextPlaceholder; break;
     158           1 :             case 17: pValues[nProp] <<= bPrintHiddenText; break;
     159             :         }
     160             :     }
     161             : 
     162             :     // currently there is just one checkbox for print drawings and print graphics
     163             :     // In the UI. (File/Print dialog and Tools/Options/.../Print)
     164             :     // And since print graphics is the only available in Writer and WrtierWeb ...
     165           1 :     bPrintDraw = bPrintGraphic;
     166             : 
     167           2 :     PutProperties(aNames, aValues);
     168           1 : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11