LCOV - code coverage report
Current view: top level - libreoffice/writerfilter/source/dmapper - SettingsTable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 82 90 91.1 %
Date: 2012-12-17 Functions: 20 20 100.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             : #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         438 : 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             :     bool                m_bUsePrinterMetrics;
      72             :     bool                embedTrueTypeFonts;
      73             :     bool                embedSystemFonts;
      74             :     bool                m_bDoNotUseHTMLParagraphAutoSpacing;
      75             :     bool                m_bSplitPgBreakAndParaMark;
      76             : 
      77         438 :     SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
      78             :     m_rDMapper( rDMapper )
      79             :     , m_xTextFactory( xTextFactory )
      80             :     , m_nDefaultTabStop( 720 ) //default is 1/2 in
      81             :     , m_nHyphenationZone(0)
      82             :     , m_bNoPunctuationKerning(false)
      83             :     , m_doNotIncludeSubdocsInStats(false)
      84             :     , m_bRecordChanges(false)
      85             :     , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none)
      86             :     , m_bFormatting(false)
      87             :     , m_bEnforcement(false)
      88             :     , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES)
      89             :     , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash)
      90             :     , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny)
      91             :     , m_nCryptSpinCount(0)
      92             :     , m_bLinkStyles(false)
      93             :     , m_nZoomFactor(0)
      94             :     , m_bEvenAndOddHeaders(false)
      95             :     , m_bUsePrinterMetrics(false)
      96             :     , embedTrueTypeFonts(false)
      97             :     , embedSystemFonts(false)
      98             :     , m_bDoNotUseHTMLParagraphAutoSpacing(false)
      99         438 :     , m_bSplitPgBreakAndParaMark(false)
     100         438 :     {}
     101             : 
     102             : };
     103             : 
     104         438 : SettingsTable::SettingsTable(DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory)
     105             : : LoggedProperties(dmapper_logger, "SettingsTable")
     106             : , LoggedTable(dmapper_logger, "SettingsTable")
     107         438 : , m_pImpl( new SettingsTable_Impl(rDMapper, xTextFactory) )
     108             : {
     109             : 
     110         438 : }
     111             : 
     112        1314 : SettingsTable::~SettingsTable()
     113             : {
     114         438 :     delete m_pImpl;
     115         876 : }
     116             : 
     117         470 : void SettingsTable::lcl_attribute(Id nName, Value & val)
     118             : {
     119         470 :     int nIntValue = val.getInt();
     120             : 
     121         470 :     switch(nName)
     122             :     {
     123             :     case NS_ooxml::LN_CT_Zoom_percent:
     124         228 :         m_pImpl->m_nZoomFactor = nIntValue;
     125         228 :     break;
     126             :     default:
     127             :     {
     128             : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     129             :         dmapper_logger->element("unhandled");
     130             : #endif
     131             :     }
     132             :     }
     133         470 : }
     134             : 
     135        1642 : void SettingsTable::lcl_sprm(Sprm& rSprm)
     136             : {
     137        1642 :     sal_uInt32 nSprmId = rSprm.getId();
     138             : 
     139        1642 :     Value::Pointer_t pValue = rSprm.getValue();
     140        1642 :     sal_Int32 nIntValue = pValue->getInt();
     141             :     (void)nIntValue;
     142        1642 :     OUString sStringValue = pValue->getString();
     143             : 
     144        1642 :     switch(nSprmId)
     145             :     {
     146             :     case NS_ooxml::LN_CT_Settings_zoom: //  92469;
     147             :     case NS_ooxml::LN_CT_Settings_proofState: //  92489;
     148             :     case NS_ooxml::LN_CT_Settings_attachedTemplate: //  92491;
     149             :     case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: //  92544;
     150             :     case NS_ooxml::LN_CT_Settings_footnotePr: //  92545;
     151             :     case NS_ooxml::LN_CT_Settings_endnotePr: //  92546;
     152             :     case NS_ooxml::LN_CT_Settings_compat: //  92547;
     153             :     case NS_ooxml::LN_CT_Settings_themeFontLang: //  92552;
     154             :     case NS_ooxml::LN_CT_Settings_shapeDefaults: //  92560;
     155             : 
     156             :     //PropertySetValues - need to be resolved
     157             :     {
     158         568 :         writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     159         568 :         if( pProperties.get())
     160         568 :         pProperties->resolve(*this);
     161             :     }
     162         568 :     break;
     163             :     case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
     164           4 :     break;
     165             :     case NS_ooxml::LN_CT_Settings_defaultTabStop: //  92505;
     166         188 :     m_pImpl->m_nDefaultTabStop = nIntValue;
     167         188 :     break;
     168             :     case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
     169           2 :     m_pImpl->m_bLinkStyles = nIntValue;
     170           2 :     break;
     171             :     case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
     172           4 :     m_pImpl->m_bEvenAndOddHeaders = nIntValue;
     173           4 :     break;
     174             :     case NS_ooxml::LN_CT_Settings_noPunctuationKerning: //  92526;
     175           2 :     m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
     176           2 :     break;
     177             :     case NS_ooxml::LN_CT_Settings_characterSpacingControl: //  92527;
     178          96 :     m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
     179          96 :     break;
     180             :     case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: //  92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
     181          10 :     m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
     182          10 :     break;
     183             :     case NS_ooxml::LN_CT_Settings_decimalSymbol: //  92562;
     184          96 :     m_pImpl->m_sDecimalSymbol = sStringValue;
     185          96 :     break;
     186             :     case NS_ooxml::LN_CT_Settings_listSeparator: //  92563;
     187          96 :     m_pImpl->m_sListSeparatorForFields = sStringValue;
     188          96 :     break;
     189             :     case NS_ooxml::LN_CT_Settings_rsids: //  92549; revision save Ids - probably not necessary
     190          96 :     break;
     191             :     case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
     192          14 :     m_pImpl->m_nHyphenationZone = nIntValue;
     193          14 :     break;
     194             :     case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
     195             :     // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
     196          16 :     break;
     197             :     case NS_ooxml::LN_CT_Settings_trackRevisions:
     198             :     {
     199           0 :         m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
     200             :     }
     201           0 :     break;
     202             :     case NS_ooxml::LN_CT_Settings_documentProtection:
     203             :         {
     204           0 :             resolveSprmProps(*this, rSprm);
     205             :         }
     206           0 :         break;
     207             :     case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
     208           0 :         m_pImpl->m_bUsePrinterMetrics = nIntValue;
     209           0 :         break;
     210             :     case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
     211           0 :         m_pImpl->embedTrueTypeFonts = nIntValue != 0;
     212           0 :         break;
     213             :     case NS_ooxml::LN_CT_Settings_embedSystemFonts:
     214          12 :         m_pImpl->embedSystemFonts = nIntValue != 0;
     215          12 :         break;
     216             :     case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
     217           4 :         m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
     218           4 :         break;
     219             :     case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
     220          10 :         m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
     221          10 :         break;
     222             :     default:
     223             :     {
     224             : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     225             :         dmapper_logger->element("unhandled");
     226             : #endif
     227             :     }
     228        1642 :     }
     229        1642 : }
     230             : 
     231         416 : void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
     232             : {
     233         416 :     ref->resolve(*this);
     234         416 : }
     235             : //returns default TabStop in 1/100th mm
     236             : 
     237             : 
     238             : 
     239         400 : int SettingsTable::GetDefaultTabStop() const
     240             : {
     241         400 :     return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
     242             : }
     243             : 
     244         400 : bool SettingsTable::GetLinkStyles() const
     245             : {
     246         400 :     return m_pImpl->m_bLinkStyles;
     247             : }
     248             : 
     249         630 : sal_Int16 SettingsTable::GetZoomFactor() const
     250             : {
     251         630 :     return m_pImpl->m_nZoomFactor;
     252             : }
     253             : 
     254         400 : bool SettingsTable::GetUsePrinterMetrics() const
     255             : {
     256         400 :     return m_pImpl->m_bUsePrinterMetrics;
     257             : }
     258             : 
     259          10 : bool SettingsTable::GetEvenAndOddHeaders() const
     260             : {
     261          10 :     return m_pImpl->m_bEvenAndOddHeaders;
     262             : }
     263             : 
     264         400 : bool SettingsTable::GetEmbedTrueTypeFonts() const
     265             : {
     266         400 :     return m_pImpl->embedTrueTypeFonts;
     267             : }
     268             : 
     269         400 : bool SettingsTable::GetEmbedSystemFonts() const
     270             : {
     271         400 :     return m_pImpl->embedSystemFonts;
     272             : }
     273             : 
     274         412 : bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
     275             : {
     276         412 :     return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
     277             : }
     278             : 
     279         986 : bool SettingsTable::GetSplitPgBreakAndParaMark() const
     280             : {
     281         986 :     return m_pImpl->m_bSplitPgBreakAndParaMark;
     282             : }
     283             : 
     284         438 : void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
     285             : {
     286         438 :     uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
     287             : 
     288             :     // Record changes value
     289         438 :     if (xDocProps.is())
     290         416 :         xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
     291         438 : }
     292             : 
     293             : 
     294             : }//namespace dmapper
     295          30 : } //namespace writerfilter
     296             : 
     297             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10