LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - SettingsTable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 64 70 91.4 %
Date: 2012-08-25 Functions: 15 15 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 47 88 53.4 %

           Branch data     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 <stdio.h>
      21                 :            : #include <rtl/ustring.hxx>
      22                 :            : #include <resourcemodel/ResourceModelHelper.hxx>
      23                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      24                 :            : #include <SettingsTable.hxx>
      25                 :            : #include <doctok/resourceids.hxx>
      26                 :            : #include <ooxml/resourceids.hxx>
      27                 :            : #include <ConversionHelper.hxx>
      28                 :            : 
      29                 :            : #include "dmapperLoggers.hxx"
      30                 :            : 
      31                 :            : namespace writerfilter {
      32                 :            : 
      33                 :            : using resourcemodel::resolveSprmProps;
      34                 :            : 
      35                 :            : namespace dmapper
      36                 :            : {
      37                 :            : 
      38                 :        506 : struct SettingsTable_Impl
      39                 :            : {
      40                 :            :     DomainMapper&       m_rDMapper;
      41                 :            :     const uno::Reference< lang::XMultiServiceFactory > m_xTextFactory;
      42                 :            : 
      43                 :            :     OUString     m_sCharacterSpacing;
      44                 :            :     OUString     m_sDecimalSymbol;
      45                 :            :     OUString     m_sListSeparatorForFields; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
      46                 :            : 
      47                 :            :     int                 m_nDefaultTabStop;
      48                 :            :     int                 m_nHyphenationZone;
      49                 :            : 
      50                 :            :     bool                m_bNoPunctuationKerning;
      51                 :            :     bool                m_doNotIncludeSubdocsInStats; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
      52                 :            :     bool                m_bRecordChanges;
      53                 :            :     int                 m_nEdit;
      54                 :            :     bool                m_bFormatting;
      55                 :            :     bool                m_bEnforcement;
      56                 :            :     int                 m_nCryptProviderType;
      57                 :            :     int                 m_nCryptAlgorithmClass;
      58                 :            :     int                 m_nCryptAlgorithmType;
      59                 :            :     OUString     m_sCryptAlgorithmSid;
      60                 :            :     int                 m_nCryptSpinCount;
      61                 :            :     OUString     m_sCryptProvider;
      62                 :            :     OUString     m_sAlgIdExt;
      63                 :            :     OUString     m_sAlgIdExtSource;
      64                 :            :     OUString     m_sCryptProviderTypeExt;
      65                 :            :     OUString     m_sCryptProviderTypeExtSource;
      66                 :            :     OUString     m_sHash;
      67                 :            :     OUString     m_sSalt;
      68                 :            :     bool                m_bLinkStyles;
      69                 :            :     sal_Int16           m_nZoomFactor;
      70                 :            :     bool                m_bEvenAndOddHeaders;
      71                 :            : 
      72                 :        506 :     SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
      73                 :            :     m_rDMapper( rDMapper )
      74                 :            :     , m_xTextFactory( xTextFactory )
      75                 :            :     , m_nDefaultTabStop( 720 ) //default is 1/2 in
      76                 :            :     , m_nHyphenationZone(0)
      77                 :            :     , m_bNoPunctuationKerning(false)
      78                 :            :     , m_doNotIncludeSubdocsInStats(false)
      79                 :            :     , m_bRecordChanges(false)
      80                 :            :     , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none)
      81                 :            :     , m_bFormatting(false)
      82                 :            :     , m_bEnforcement(false)
      83                 :            :     , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES)
      84                 :            :     , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash)
      85                 :            :     , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny)
      86                 :            :     , m_nCryptSpinCount(0)
      87                 :            :     , m_bLinkStyles(false)
      88                 :            :     , m_nZoomFactor(0)
      89                 :        506 :     , m_bEvenAndOddHeaders(false)
      90                 :        506 :     {}
      91                 :            : 
      92                 :            : };
      93                 :            : 
      94                 :        506 : SettingsTable::SettingsTable(DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory)
      95                 :            : : LoggedProperties(dmapper_logger, "SettingsTable")
      96                 :            : , LoggedTable(dmapper_logger, "SettingsTable")
      97 [ +  - ][ +  - ]:        506 : , m_pImpl( new SettingsTable_Impl(rDMapper, xTextFactory) )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      98                 :            : {
      99                 :            : 
     100                 :        506 : }
     101                 :            : 
     102         [ +  - ]:        506 : SettingsTable::~SettingsTable()
     103                 :            : {
     104 [ +  - ][ +  - ]:        506 :     delete m_pImpl;
     105         [ -  + ]:       1012 : }
     106                 :            : 
     107                 :        467 : void SettingsTable::lcl_attribute(Id nName, Value & val)
     108                 :            : {
     109                 :        467 :     int nIntValue = val.getInt();
     110                 :            : 
     111         [ +  + ]:        467 :     switch(nName)
     112                 :            :     {
     113                 :            :     case NS_ooxml::LN_CT_Zoom_percent:
     114                 :        248 :         m_pImpl->m_nZoomFactor = nIntValue;
     115                 :        248 :     break;
     116                 :            :     default:
     117                 :            :     {
     118                 :            : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     119                 :            :         dmapper_logger->element("unhandled");
     120                 :            : #endif
     121                 :            :     }
     122                 :            :     }
     123                 :        467 : }
     124                 :            : 
     125                 :       1402 : void SettingsTable::lcl_sprm(Sprm& rSprm)
     126                 :            : {
     127         [ +  - ]:       1402 :     sal_uInt32 nSprmId = rSprm.getId();
     128                 :            : 
     129 [ +  - ][ +  - ]:       1402 :     Value::Pointer_t pValue = rSprm.getValue();
     130         [ +  - ]:       1402 :     sal_Int32 nIntValue = pValue->getInt();
     131                 :            :     (void)nIntValue;
     132         [ +  - ]:       1402 :     OUString sStringValue = pValue->getString();
     133                 :            : 
     134   [ +  +  +  +  :       1402 :     switch(nSprmId)
          +  -  +  +  +  
          +  +  +  +  -  
                   -  + ]
     135                 :            :     {
     136                 :            :     case NS_ooxml::LN_CT_Settings_zoom: //  92469;
     137                 :            :     case NS_ooxml::LN_CT_Settings_proofState: //  92489;
     138                 :            :     case NS_ooxml::LN_CT_Settings_attachedTemplate: //  92491;
     139                 :            :     case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: //  92544;
     140                 :            :     case NS_ooxml::LN_CT_Settings_footnotePr: //  92545;
     141                 :            :     case NS_ooxml::LN_CT_Settings_endnotePr: //  92546;
     142                 :            :     case NS_ooxml::LN_CT_Settings_compat: //  92547;
     143                 :            :     case NS_ooxml::LN_CT_Settings_themeFontLang: //  92552;
     144                 :            :     case NS_ooxml::LN_CT_Settings_shapeDefaults: //  92560;
     145                 :            : 
     146                 :            :     //PropertySetValues - need to be resolved
     147                 :            :     {
     148         [ +  - ]:        496 :         writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     149         [ +  - ]:        496 :         if( pProperties.get())
     150 [ +  - ][ +  - ]:        496 :         pProperties->resolve(*this);
     151                 :            :     }
     152                 :        496 :     break;
     153                 :            :     case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
     154                 :         11 :     break;
     155                 :            :     case NS_ooxml::LN_CT_Settings_defaultTabStop: //  92505;
     156                 :        191 :     m_pImpl->m_nDefaultTabStop = nIntValue;
     157                 :        191 :     break;
     158                 :            :     case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
     159                 :          3 :     m_pImpl->m_bLinkStyles = nIntValue;
     160                 :          3 :     break;
     161                 :            :     case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
     162                 :          6 :     m_pImpl->m_bEvenAndOddHeaders = nIntValue;
     163                 :          6 :     break;
     164                 :            :     case NS_ooxml::LN_CT_Settings_noPunctuationKerning: //  92526;
     165                 :          0 :     m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
     166                 :          0 :     break;
     167                 :            :     case NS_ooxml::LN_CT_Settings_characterSpacingControl: //  92527;
     168                 :         83 :     m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
     169                 :         83 :     break;
     170                 :            :     case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: //  92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
     171                 :         14 :     m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
     172                 :         14 :     break;
     173                 :            :     case NS_ooxml::LN_CT_Settings_decimalSymbol: //  92562;
     174                 :         83 :     m_pImpl->m_sDecimalSymbol = sStringValue;
     175                 :         83 :     break;
     176                 :            :     case NS_ooxml::LN_CT_Settings_listSeparator: //  92563;
     177                 :         83 :     m_pImpl->m_sListSeparatorForFields = sStringValue;
     178                 :         83 :     break;
     179                 :            :     case NS_ooxml::LN_CT_Settings_rsids: //  92549; revision save Ids - probably not necessary
     180                 :         83 :     break;
     181                 :            :     case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
     182                 :         12 :     m_pImpl->m_nHyphenationZone = nIntValue;
     183                 :         12 :     break;
     184                 :            :     case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
     185                 :            :     // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
     186                 :         23 :     break;
     187                 :            :     case NS_ooxml::LN_CT_Settings_trackRevisions:
     188                 :            :     {
     189 [ #  # ][ #  # ]:          0 :         m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
                 [ #  # ]
     190                 :            :     }
     191                 :          0 :     break;
     192                 :            :     case NS_ooxml::LN_CT_Settings_documentProtection:
     193                 :            :         {
     194         [ #  # ]:          0 :             resolveSprmProps(*this, rSprm);
     195                 :            :         }
     196                 :          0 :         break;
     197                 :            :     default:
     198                 :            :     {
     199                 :            : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     200                 :            :         dmapper_logger->element("unhandled");
     201                 :            : #endif
     202                 :            :     }
     203         [ +  - ]:       1402 :     }
     204                 :       1402 : }
     205                 :            : 
     206                 :        479 : void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
     207                 :            : {
     208                 :        479 :     ref->resolve(*this);
     209                 :        479 : }
     210                 :            : //returns default TabStop in 1/100th mm
     211                 :            : 
     212                 :            : 
     213                 :            : 
     214                 :        455 : int SettingsTable::GetDefaultTabStop() const
     215                 :            : {
     216                 :        455 :     return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
     217                 :            : }
     218                 :            : 
     219                 :        455 : bool SettingsTable::GetLinkStyles() const
     220                 :            : {
     221                 :        455 :     return m_pImpl->m_bLinkStyles;
     222                 :            : }
     223                 :            : 
     224                 :        703 : sal_Int16 SettingsTable::GetZoomFactor() const
     225                 :            : {
     226                 :        703 :     return m_pImpl->m_nZoomFactor;
     227                 :            : }
     228                 :            : 
     229                 :          6 : bool SettingsTable::GetEvenAndOddHeaders() const
     230                 :            : {
     231                 :          6 :     return m_pImpl->m_bEvenAndOddHeaders;
     232                 :            : }
     233                 :            : 
     234                 :        506 : void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
     235                 :            : {
     236         [ +  - ]:        506 :     uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
     237                 :            : 
     238                 :            :     // Record changes value
     239         [ +  + ]:        506 :     if (xDocProps.is())
     240 [ +  - ][ +  - ]:        506 :         xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
                 [ +  - ]
     241                 :        506 : }
     242                 :            : 
     243                 :            : 
     244                 :            : }//namespace dmapper
     245 [ +  - ][ +  - ]:         60 : } //namespace writerfilter
     246                 :            : 
     247                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10