LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - SettingsTable.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 126 130 96.9 %
Date: 2014-04-11 Functions: 22 22 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 <ooxml/resourceids.hxx>
      26             : #include <ConversionHelper.hxx>
      27             : 
      28             : #include "dmapperLoggers.hxx"
      29             : 
      30             : namespace writerfilter {
      31             : 
      32             : using resourcemodel::resolveSprmProps;
      33             : 
      34             : namespace dmapper
      35             : {
      36             : 
      37        1191 : struct SettingsTable_Impl
      38             : {
      39             :     DomainMapper&       m_rDMapper;
      40             :     const uno::Reference< lang::XMultiServiceFactory > m_xTextFactory;
      41             : 
      42             :     OUString     m_sCharacterSpacing;
      43             :     OUString     m_sDecimalSymbol;
      44             :     OUString     m_sListSeparatorForFields; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
      45             : 
      46             :     int                 m_nDefaultTabStop;
      47             :     int                 m_nHyphenationZone;
      48             : 
      49             :     bool                m_bNoPunctuationKerning;
      50             :     bool                m_doNotIncludeSubdocsInStats; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
      51             :     bool                m_bRecordChanges;
      52             :     int                 m_nEdit;
      53             :     bool                m_bFormatting;
      54             :     bool                m_bEnforcement;
      55             :     int                 m_nCryptProviderType;
      56             :     int                 m_nCryptAlgorithmClass;
      57             :     int                 m_nCryptAlgorithmType;
      58             :     OUString     m_sCryptAlgorithmSid;
      59             :     int                 m_nCryptSpinCount;
      60             :     OUString     m_sCryptProvider;
      61             :     OUString     m_sAlgIdExt;
      62             :     OUString     m_sAlgIdExtSource;
      63             :     OUString     m_sCryptProviderTypeExt;
      64             :     OUString     m_sCryptProviderTypeExtSource;
      65             :     OUString     m_sHash;
      66             :     OUString     m_sSalt;
      67             :     bool                m_bLinkStyles;
      68             :     sal_Int16           m_nZoomFactor;
      69             :     Id                  m_nView;
      70             :     bool                m_bEvenAndOddHeaders;
      71             :     bool                m_bUsePrinterMetrics;
      72             :     bool                embedTrueTypeFonts;
      73             :     bool                embedSystemFonts;
      74             :     bool                m_bDoNotUseHTMLParagraphAutoSpacing;
      75             :     bool                m_bSplitPgBreakAndParaMark;
      76             :     bool                m_bMirrorMargin;
      77             :     uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
      78             : 
      79             :     uno::Sequence<beans::PropertyValue> m_pCompatSettings;
      80             :     uno::Sequence<beans::PropertyValue> m_pCurrentCompatSetting;
      81             : 
      82        1191 :     SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
      83             :     m_rDMapper( rDMapper )
      84             :     , m_xTextFactory( xTextFactory )
      85             :     , m_nDefaultTabStop( 720 ) //default is 1/2 in
      86             :     , m_nHyphenationZone(0)
      87             :     , m_bNoPunctuationKerning(false)
      88             :     , m_doNotIncludeSubdocsInStats(false)
      89             :     , m_bRecordChanges(false)
      90             :     , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none)
      91             :     , m_bFormatting(false)
      92             :     , m_bEnforcement(false)
      93             :     , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES)
      94             :     , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash)
      95             :     , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny)
      96             :     , m_nCryptSpinCount(0)
      97             :     , m_bLinkStyles(false)
      98             :     , m_nZoomFactor(0)
      99             :     , m_nView(0)
     100             :     , m_bEvenAndOddHeaders(false)
     101             :     , m_bUsePrinterMetrics(false)
     102             :     , embedTrueTypeFonts(false)
     103             :     , embedSystemFonts(false)
     104             :     , m_bDoNotUseHTMLParagraphAutoSpacing(false)
     105             :     , m_bSplitPgBreakAndParaMark(false)
     106             :     , m_bMirrorMargin(false)
     107             :     , m_pThemeFontLangProps(3)
     108             :     , m_pCompatSettings(0)
     109        1191 :     , m_pCurrentCompatSetting(3)
     110        1191 :     {}
     111             : 
     112             : };
     113             : 
     114        1191 : SettingsTable::SettingsTable(DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory)
     115             : : LoggedProperties(dmapper_logger, "SettingsTable")
     116             : , LoggedTable(dmapper_logger, "SettingsTable")
     117        1191 : , m_pImpl( new SettingsTable_Impl(rDMapper, xTextFactory) )
     118             : {
     119             : 
     120        1191 : }
     121             : 
     122        3573 : SettingsTable::~SettingsTable()
     123             : {
     124        1191 :     delete m_pImpl;
     125        2382 : }
     126             : 
     127       10396 : void SettingsTable::lcl_attribute(Id nName, Value & val)
     128             : {
     129       10396 :     int nIntValue = val.getInt();
     130       10396 :     OUString sStringValue = val.getString();
     131             : 
     132       10396 :     switch(nName)
     133             :     {
     134             :     case NS_ooxml::LN_CT_Zoom_percent:
     135         941 :         m_pImpl->m_nZoomFactor = nIntValue;
     136         941 :     break;
     137             :     case NS_ooxml::LN_CT_Language_val:
     138         823 :         m_pImpl->m_pThemeFontLangProps[0].Name = "val";
     139         823 :         m_pImpl->m_pThemeFontLangProps[0].Value <<= sStringValue;
     140         823 :         break;
     141             :     case NS_ooxml::LN_CT_Language_eastAsia:
     142         444 :         m_pImpl->m_pThemeFontLangProps[1].Name = "eastAsia";
     143         444 :         m_pImpl->m_pThemeFontLangProps[1].Value <<= sStringValue;
     144         444 :         break;
     145             :     case NS_ooxml::LN_CT_Language_bidi:
     146         487 :         m_pImpl->m_pThemeFontLangProps[2].Name = "bidi";
     147         487 :         m_pImpl->m_pThemeFontLangProps[2].Value <<= sStringValue;
     148         487 :         break;
     149             :     case NS_ooxml::LN_CT_View_val:
     150           7 :         m_pImpl->m_nView = nIntValue;
     151           7 :         break;
     152             :     case NS_ooxml::LN_CT_CompatSetting_name:
     153        2276 :         m_pImpl->m_pCurrentCompatSetting[0].Name = "name";
     154        2276 :         m_pImpl->m_pCurrentCompatSetting[0].Value <<= sStringValue;
     155        2276 :         break;
     156             :     case NS_ooxml::LN_CT_CompatSetting_uri:
     157        2276 :         m_pImpl->m_pCurrentCompatSetting[1].Name = "uri";
     158        2276 :         m_pImpl->m_pCurrentCompatSetting[1].Value <<= sStringValue;
     159        2276 :         break;
     160             :     case NS_ooxml::LN_CT_CompatSetting_val:
     161        2276 :         m_pImpl->m_pCurrentCompatSetting[2].Name = "val";
     162        2276 :         m_pImpl->m_pCurrentCompatSetting[2].Value <<= sStringValue;
     163        2276 :         break;
     164             :     default:
     165             :     {
     166             : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     167             :         dmapper_logger->element("unhandled");
     168             : #endif
     169             :     }
     170       10396 :     }
     171       10396 : }
     172             : 
     173       11952 : void SettingsTable::lcl_sprm(Sprm& rSprm)
     174             : {
     175       11952 :     sal_uInt32 nSprmId = rSprm.getId();
     176             : 
     177       11952 :     Value::Pointer_t pValue = rSprm.getValue();
     178       11952 :     sal_Int32 nIntValue = pValue->getInt();
     179             :     (void)nIntValue;
     180       23904 :     OUString sStringValue = pValue->getString();
     181             : 
     182       11952 :     switch(nSprmId)
     183             :     {
     184             :     case NS_ooxml::LN_CT_Settings_zoom: //  92469;
     185             :     case NS_ooxml::LN_CT_Settings_proofState: //  92489;
     186             :     case NS_ooxml::LN_CT_Settings_attachedTemplate: //  92491;
     187             :     case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: //  92544;
     188             :     case NS_ooxml::LN_CT_Settings_footnotePr: //  92545;
     189             :     case NS_ooxml::LN_CT_Settings_endnotePr: //  92546;
     190             :     case NS_ooxml::LN_CT_Settings_compat: //  92547;
     191             :     case NS_ooxml::LN_CT_Settings_themeFontLang: //  92552;
     192             :     case NS_ooxml::LN_CT_Settings_shapeDefaults: //  92560;
     193             :     case NS_ooxml::LN_CT_Settings_view:
     194             :     //PropertySetValues - need to be resolved
     195             :     {
     196        4037 :         writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     197        4037 :         if( pProperties.get())
     198        4037 :             pProperties->resolve(*this);
     199             :     }
     200        4037 :     break;
     201             :     case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
     202          54 :     break;
     203             :     case NS_ooxml::LN_CT_Settings_defaultTabStop: //  92505;
     204         938 :     m_pImpl->m_nDefaultTabStop = nIntValue;
     205         938 :     break;
     206             :     case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
     207           3 :     m_pImpl->m_bLinkStyles = nIntValue;
     208           3 :     break;
     209             :     case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
     210          21 :     m_pImpl->m_bEvenAndOddHeaders = nIntValue;
     211          21 :     break;
     212             :     case NS_ooxml::LN_CT_Settings_noPunctuationKerning: //  92526;
     213          48 :     m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
     214          48 :     break;
     215             :     case NS_ooxml::LN_CT_Settings_characterSpacingControl: //  92527;
     216         557 :     m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
     217         557 :     break;
     218             :     case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: //  92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
     219          62 :     m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
     220          62 :     break;
     221             :     case NS_ooxml::LN_CT_Settings_decimalSymbol: //  92562;
     222         557 :     m_pImpl->m_sDecimalSymbol = sStringValue;
     223         557 :     break;
     224             :     case NS_ooxml::LN_CT_Settings_listSeparator: //  92563;
     225         557 :     m_pImpl->m_sListSeparatorForFields = sStringValue;
     226         557 :     break;
     227             :     case NS_ooxml::LN_CT_Settings_rsids: //  92549; revision save Ids - probably not necessary
     228         554 :     break;
     229             :     case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
     230          94 :     m_pImpl->m_nHyphenationZone = nIntValue;
     231          94 :     break;
     232             :     case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
     233             :     // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
     234         115 :     break;
     235             :     case NS_ooxml::LN_CT_Settings_trackRevisions:
     236             :     {
     237          30 :         m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
     238             :     }
     239          30 :     break;
     240             :     case NS_ooxml::LN_CT_Settings_documentProtection:
     241             :         {
     242           1 :             resolveSprmProps(*this, rSprm);
     243             :         }
     244           1 :         break;
     245             :     case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
     246           0 :         m_pImpl->m_bUsePrinterMetrics = nIntValue;
     247           0 :         break;
     248             :     case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
     249           0 :         m_pImpl->embedTrueTypeFonts = nIntValue != 0;
     250           0 :         break;
     251             :     case NS_ooxml::LN_CT_Settings_embedSystemFonts:
     252          68 :         m_pImpl->embedSystemFonts = nIntValue != 0;
     253          68 :         break;
     254             :     case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
     255           7 :         m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
     256           7 :         break;
     257             :     case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
     258          14 :         m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
     259          14 :         break;
     260             :     case NS_ooxml::LN_CT_Settings_mirrorMargins:
     261           7 :         m_pImpl->m_bMirrorMargin = nIntValue;
     262           7 :         break;
     263             :     case NS_ooxml::LN_CT_Compat_compatSetting:
     264             :     {
     265        2276 :         writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     266        2276 :         if (pProperties.get())
     267             :         {
     268        2276 :             pProperties->resolve(*this);
     269             : 
     270        2276 :             sal_Int32 nLength = m_pImpl->m_pCompatSettings.getLength();
     271        2276 :             m_pImpl->m_pCompatSettings.realloc(nLength + 1);
     272        2276 :             m_pImpl->m_pCompatSettings[nLength].Name = "compatSetting";
     273        2276 :             m_pImpl->m_pCompatSettings[nLength].Value = uno::makeAny(m_pImpl->m_pCurrentCompatSetting);
     274        2276 :         }
     275             :     }
     276        2276 :     break;
     277             :     default:
     278             :     {
     279             : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
     280             :         dmapper_logger->element("unhandled");
     281             : #endif
     282             :     }
     283       11952 :     }
     284       11952 : }
     285             : 
     286        1177 : void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
     287             : {
     288        1177 :     ref->resolve(*this);
     289        1177 : }
     290             : //returns default TabStop in 1/100th mm
     291             : 
     292             : 
     293             : 
     294        1165 : int SettingsTable::GetDefaultTabStop() const
     295             : {
     296        1165 :     return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
     297             : }
     298             : 
     299        1165 : bool SettingsTable::GetLinkStyles() const
     300             : {
     301        1165 :     return m_pImpl->m_bLinkStyles;
     302             : }
     303             : 
     304        2113 : sal_Int16 SettingsTable::GetZoomFactor() const
     305             : {
     306        2113 :     return m_pImpl->m_nZoomFactor;
     307             : }
     308             : 
     309         932 : Id SettingsTable::GetView() const
     310             : {
     311         932 :     return m_pImpl->m_nView;
     312             : }
     313             : 
     314        1165 : bool SettingsTable::GetUsePrinterMetrics() const
     315             : {
     316        1165 :     return m_pImpl->m_bUsePrinterMetrics;
     317             : }
     318             : 
     319        1473 : bool SettingsTable::GetEvenAndOddHeaders() const
     320             : {
     321        1473 :     return m_pImpl->m_bEvenAndOddHeaders;
     322             : }
     323             : 
     324        1165 : bool SettingsTable::GetEmbedTrueTypeFonts() const
     325             : {
     326        1165 :     return m_pImpl->embedTrueTypeFonts;
     327             : }
     328             : 
     329        1165 : bool SettingsTable::GetEmbedSystemFonts() const
     330             : {
     331        1165 :     return m_pImpl->embedSystemFonts;
     332             : }
     333             : 
     334        2112 : bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
     335             : {
     336        2112 :     return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
     337             : }
     338             : 
     339       21101 : bool SettingsTable::GetSplitPgBreakAndParaMark() const
     340             : {
     341       21101 :     return m_pImpl->m_bSplitPgBreakAndParaMark;
     342             : }
     343             : 
     344        1272 : bool SettingsTable::GetMirrorMarginSettings() const
     345             : {
     346        1272 :     return m_pImpl->m_bMirrorMargin;
     347             : }
     348             : 
     349        1712 : uno::Sequence<beans::PropertyValue> SettingsTable::GetThemeFontLangProperties() const
     350             : {
     351        1712 :     return m_pImpl->m_pThemeFontLangProps;
     352             : }
     353             : 
     354         904 : uno::Sequence<beans::PropertyValue> SettingsTable::GetCompatSettings() const
     355             : {
     356         904 :     return m_pImpl->m_pCompatSettings;
     357             : }
     358             : 
     359        1191 : void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
     360             : {
     361        1191 :     uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
     362             : 
     363             :     // Record changes value
     364        1191 :     if (xDocProps.is())
     365        1175 :         xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
     366        1191 : }
     367             : 
     368             : 
     369             : }//namespace dmapper
     370             : } //namespace writerfilter
     371             : 
     372             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10