LCOV - code coverage report
Current view: top level - unotools/source/config - compatibility.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 157 319 49.2 %
Date: 2014-11-03 Functions: 38 64 59.4 %
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/compatibility.hxx>
      21             : #include <unotools/configmgr.hxx>
      22             : #include <unotools/configitem.hxx>
      23             : #include <unotools/syslocale.hxx>
      24             : #include <tools/debug.hxx>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : #include <com/sun/star/uno/Sequence.hxx>
      27             : 
      28             : #include <vector>
      29             : 
      30             : #include "itemholder1.hxx"
      31             : 
      32             : #include <algorithm>
      33             : 
      34             : //  namespaces
      35             : 
      36             : using namespace ::std;
      37             : using namespace ::utl;
      38             : using namespace ::osl;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::beans;
      41             : 
      42             : #define ROOTNODE_OPTIONS        OUString( "Office.Compatibility/" )
      43             : #define PATHDELIMITER           OUString( "/" )
      44             : #define SETNODE_ALLFILEFORMATS  OUString( "AllFileFormats" )
      45             : 
      46             : #define PROPERTYNAME_NAME               COMPATIBILITY_PROPERTYNAME_NAME
      47             : #define PROPERTYNAME_MODULE             COMPATIBILITY_PROPERTYNAME_MODULE
      48             : #define PROPERTYNAME_USEPRTMETRICS      COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
      49             : #define PROPERTYNAME_ADDSPACING         COMPATIBILITY_PROPERTYNAME_ADDSPACING
      50             : #define PROPERTYNAME_ADDSPACINGATPAGES  COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
      51             : #define PROPERTYNAME_USEOURTABSTOPS     COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
      52             : #define PROPERTYNAME_NOEXTLEADING       COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
      53             : #define PROPERTYNAME_USELINESPACING     COMPATIBILITY_PROPERTYNAME_USELINESPACING
      54             : #define PROPERTYNAME_ADDTABLESPACING    COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
      55             : #define PROPERTYNAME_USEOBJPOS          COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
      56             : #define PROPERTYNAME_USEOURTEXTWRAP     COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
      57             : #define PROPERTYNAME_CONSIDERWRAPSTYLE  COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
      58             : #define PROPERTYNAME_EXPANDWORDSPACE    COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
      59             : 
      60             : #define PROPERTYCOUNT                   13
      61             : 
      62             : #define OFFSET_NAME                     0
      63             : #define OFFSET_MODULE                   1
      64             : #define OFFSET_USEPRTMETRICS            2
      65             : #define OFFSET_ADDSPACING               3
      66             : #define OFFSET_ADDSPACINGATPAGES        4
      67             : #define OFFSET_USEOURTABSTOPS           5
      68             : #define OFFSET_NOEXTLEADING             6
      69             : #define OFFSET_USELINESPACING           7
      70             : #define OFFSET_ADDTABLESPACING          8
      71             : #define OFFSET_USEOBJPOS                9
      72             : #define OFFSET_USEOURTEXTWRAPPING       10
      73             : #define OFFSET_CONSIDERWRAPPINGSTYLE    11
      74             : #define OFFSET_EXPANDWORDSPACE          12
      75             : 
      76             : //  private declarations!
      77             : 
      78             : /*-****************************************************************************************************************
      79             :     @descr  struct to hold information about one compatibility entry
      80             : ****************************************************************************************************************-*/
      81         768 : struct SvtCompatibilityEntry
      82             : {
      83             :     public:
      84         172 :         SvtCompatibilityEntry() :
      85             :             bUsePrtMetrics( false ), bAddSpacing( false ),
      86             :             bAddSpacingAtPages( false ), bUseOurTabStops( false ),
      87             :             bNoExtLeading( false ), bUseLineSpacing( false ),
      88             :             bAddTableSpacing( false ), bUseObjPos( false ),
      89             :             bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
      90         172 :             bExpandWordSpace( true ) {}
      91           0 :         SvtCompatibilityEntry(
      92             :             const OUString& _rName, const OUString& _rNewModule ) :
      93             :                 sName( _rName ), sModule( _rNewModule ),
      94             :                 bUsePrtMetrics( false ), bAddSpacing( false ),
      95             :                 bAddSpacingAtPages( false ), bUseOurTabStops( false ),
      96             :                 bNoExtLeading( false ), bUseLineSpacing( false ),
      97             :                 bAddTableSpacing( false ), bUseObjPos( false ),
      98             :                 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
      99           0 :                 bExpandWordSpace( true ) {}
     100             : 
     101           0 :         inline void     SetUsePrtMetrics( bool _bSet ) { bUsePrtMetrics = _bSet; }
     102           0 :         inline void     SetAddSpacing( bool _bSet ) { bAddSpacing = _bSet; }
     103           0 :         inline void     SetAddSpacingAtPages( bool _bSet ) { bAddSpacingAtPages = _bSet; }
     104           0 :         inline void     SetUseOurTabStops( bool _bSet ) { bUseOurTabStops = _bSet; }
     105           0 :         inline void     SetNoExtLeading( bool _bSet ) { bNoExtLeading = _bSet; }
     106           0 :         inline void     SetUseLineSpacing( bool _bSet ) { bUseLineSpacing = _bSet; }
     107           0 :         inline void     SetAddTableSpacing( bool _bSet ) { bAddTableSpacing = _bSet; }
     108           0 :         inline void     SetUseObjPos( bool _bSet ) { bUseObjPos = _bSet; }
     109           0 :         inline void     SetUseOurTextWrapping( bool _bSet ) { bUseOurTextWrapping = _bSet; }
     110           0 :         inline void     SetConsiderWrappingStyle( bool _bSet ) { bConsiderWrappingStyle = _bSet; }
     111           0 :         inline void     SetExpandWordSpace( bool _bSet ) { bExpandWordSpace = _bSet; }
     112             : 
     113             :     public:
     114             :         OUString    sName;
     115             :         OUString    sModule;
     116             :         bool        bUsePrtMetrics;
     117             :         bool        bAddSpacing;
     118             :         bool        bAddSpacingAtPages;
     119             :         bool        bUseOurTabStops;
     120             :         bool        bNoExtLeading;
     121             :         bool        bUseLineSpacing;
     122             :         bool        bAddTableSpacing;
     123             :         bool        bUseObjPos;
     124             :         bool        bUseOurTextWrapping;
     125             :         bool        bConsiderWrappingStyle;
     126             :         bool        bExpandWordSpace;
     127             : };
     128             : 
     129             : /*-****************************************************************************************************************
     130             :     @descr  support simple menu structures and operations on it
     131             : ****************************************************************************************************************-*/
     132         170 : class SvtCompatibility
     133             : {
     134             :     public:
     135             : 
     136             :         // append one entry
     137         172 :         void AppendEntry( const SvtCompatibilityEntry& rEntry )
     138             :         {
     139         172 :             lEntries.push_back( rEntry );
     140         172 :         }
     141             : 
     142             :         // the only way to free memory!
     143           0 :         void Clear()
     144             :         {
     145           0 :             lEntries.clear();
     146           0 :         }
     147             : 
     148             :         // convert internal list to external format
     149           0 :         Sequence< Sequence< PropertyValue > > GetList() const
     150             :         {
     151           0 :             sal_Int32 nCount = (sal_Int32)lEntries.size();
     152           0 :             sal_Int32 nStep = 0;
     153           0 :             Sequence< PropertyValue > lProperties( PROPERTYCOUNT );
     154           0 :             Sequence< Sequence< PropertyValue > > lResult( nCount );
     155           0 :             const vector< SvtCompatibilityEntry >* pList = &lEntries;
     156             : 
     157           0 :             lProperties[ OFFSET_NAME ].Name = PROPERTYNAME_NAME;
     158           0 :             lProperties[ OFFSET_MODULE ].Name = PROPERTYNAME_MODULE;
     159           0 :             lProperties[ OFFSET_USEPRTMETRICS ].Name = PROPERTYNAME_USEPRTMETRICS;
     160           0 :             lProperties[ OFFSET_ADDSPACING ].Name = PROPERTYNAME_ADDSPACING;
     161           0 :             lProperties[ OFFSET_ADDSPACINGATPAGES ].Name = PROPERTYNAME_ADDSPACINGATPAGES;
     162           0 :             lProperties[ OFFSET_USEOURTABSTOPS ].Name = PROPERTYNAME_USEOURTABSTOPS;
     163           0 :             lProperties[ OFFSET_NOEXTLEADING ].Name = PROPERTYNAME_NOEXTLEADING;
     164           0 :             lProperties[ OFFSET_USELINESPACING ].Name = PROPERTYNAME_USELINESPACING;
     165           0 :             lProperties[ OFFSET_ADDTABLESPACING ].Name = PROPERTYNAME_ADDTABLESPACING;
     166           0 :             lProperties[ OFFSET_USEOBJPOS ].Name = PROPERTYNAME_USEOBJPOS;
     167           0 :             lProperties[ OFFSET_USEOURTEXTWRAPPING ].Name = PROPERTYNAME_USEOURTEXTWRAP;
     168           0 :             lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Name = PROPERTYNAME_CONSIDERWRAPSTYLE;
     169           0 :             lProperties[ OFFSET_EXPANDWORDSPACE ].Name = PROPERTYNAME_EXPANDWORDSPACE;
     170             : 
     171           0 :             for ( vector< SvtCompatibilityEntry >::const_iterator pItem = pList->begin();
     172           0 :                   pItem != pList->end(); ++pItem )
     173             :             {
     174           0 :                 lProperties[ OFFSET_NAME ].Value <<= pItem->sName;
     175           0 :                 lProperties[ OFFSET_MODULE ].Value <<= pItem->sModule;
     176           0 :                 lProperties[ OFFSET_USEPRTMETRICS ].Value <<= pItem->bUsePrtMetrics;
     177           0 :                 lProperties[ OFFSET_ADDSPACING ].Value <<= pItem->bAddSpacing;
     178           0 :                 lProperties[ OFFSET_ADDSPACINGATPAGES ].Value <<= pItem->bAddSpacingAtPages;
     179           0 :                 lProperties[ OFFSET_USEOURTABSTOPS ].Value <<= pItem->bUseOurTabStops;
     180           0 :                 lProperties[ OFFSET_NOEXTLEADING ].Value <<= pItem->bNoExtLeading;
     181           0 :                 lProperties[ OFFSET_USELINESPACING ].Value <<= pItem->bUseLineSpacing;
     182           0 :                 lProperties[ OFFSET_ADDTABLESPACING ].Value <<= pItem->bAddTableSpacing;
     183           0 :                 lProperties[ OFFSET_USEOBJPOS ].Value <<= pItem->bUseObjPos;
     184           0 :                 lProperties[ OFFSET_USEOURTEXTWRAPPING ].Value <<= pItem->bUseOurTextWrapping;
     185           0 :                 lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Value <<= pItem->bConsiderWrappingStyle;
     186           0 :                 lProperties[ OFFSET_EXPANDWORDSPACE ].Value <<= pItem->bExpandWordSpace;
     187           0 :                 lResult[ nStep ] = lProperties;
     188           0 :                 ++nStep;
     189             :             }
     190             : 
     191           0 :             return lResult;
     192             :         }
     193             : 
     194           0 :         int size() const
     195             :         {
     196           0 :             return lEntries.size();
     197             :         }
     198             : 
     199           0 :         const SvtCompatibilityEntry& operator[]( int i ) const
     200             :         {
     201           0 :             return lEntries[i];
     202             :         }
     203             : 
     204             :     private:
     205             :         vector< SvtCompatibilityEntry > lEntries;
     206             : };
     207             : 
     208             : class SvtCompatibilityOptions_Impl : public ConfigItem
     209             : {
     210             : 
     211             :     //  public methods
     212             : 
     213             :     public:
     214             : 
     215             :         //  constructor / destructor
     216             : 
     217             :          SvtCompatibilityOptions_Impl();
     218             :         virtual ~SvtCompatibilityOptions_Impl();
     219             : 
     220             :         void SetDefault( const OUString & sName, bool bValue );
     221             : 
     222             :         //  overloaded methods of baseclass
     223             : 
     224             :         /*-****************************************************************************************************
     225             :             @short      called for notify of configmanager
     226             :             @descr      These method is called from the ConfigManager before application ends or from the
     227             :                          PropertyChangeListener if the sub tree broadcasts changes. You must update your
     228             :                         internal values.
     229             : 
     230             :             @seealso    baseclass ConfigItem
     231             : 
     232             :             @param      "lPropertyNames" is the list of properties which should be updated.
     233             :         *//*-*****************************************************************************************************/
     234             : 
     235             :         virtual void Notify( const Sequence< OUString >& lPropertyNames ) SAL_OVERRIDE;
     236             : 
     237             :         /*-****************************************************************************************************
     238             :             @short      write changes to configuration
     239             :             @descr      These method writes the changed values into the sub tree
     240             :                         and should always called in our destructor to guarantee consistency of config data.
     241             : 
     242             :             @seealso    baseclass ConfigItem
     243             :         *//*-*****************************************************************************************************/
     244             : 
     245             :         virtual void Commit() SAL_OVERRIDE;
     246             : 
     247             :         //  public interface
     248             : 
     249             :         /*-****************************************************************************************************
     250             :             @short      base implementation of public interface for "SvtCompatibilityOptions"!
     251             :             @descr      These class is used as static member of "SvtCompatibilityOptions" ...
     252             :                         => The code exist only for one time and isn't duplicated for every instance!
     253             :         *//*-*****************************************************************************************************/
     254             : 
     255             :         void                                    Clear();
     256             :         Sequence< Sequence< PropertyValue > >   GetList() const;
     257             :         void                                    AppendItem( const OUString& _sName,
     258             :                                                             const OUString& _sModule,
     259             :                                                             bool _bUsePrtMetrics,
     260             :                                                             bool _bAddSpacing,
     261             :                                                             bool _bAddSpacingAtPages,
     262             :                                                             bool _bUseOurTabStops,
     263             :                                                             bool _bNoExtLeading,
     264             :                                                             bool _bUseLineSpacing,
     265             :                                                             bool _bAddTableSpacing,
     266             :                                                             bool _bUseObjPos,
     267             :                                                             bool _bUseOurTextWrapping,
     268             :                                                             bool _bConsiderWrappingStyle,
     269             :                                                             bool _bExpandWordSpace );
     270             : 
     271        5052 :         inline bool IsUsePrtDevice() const { return m_aDefOptions.bUsePrtMetrics; }
     272        5052 :         inline bool IsAddSpacing() const { return m_aDefOptions.bAddSpacing; }
     273        5052 :         inline bool IsAddSpacingAtPages() const { return m_aDefOptions.bAddSpacingAtPages; }
     274        5052 :         inline bool IsUseOurTabStops() const { return m_aDefOptions.bUseOurTabStops; }
     275        5052 :         inline bool IsNoExtLeading() const { return m_aDefOptions.bNoExtLeading; }
     276        5052 :         inline bool IsUseLineSpacing() const { return m_aDefOptions.bUseLineSpacing; }
     277        5052 :         inline bool IsAddTableSpacing() const { return m_aDefOptions.bAddTableSpacing; }
     278        5052 :         inline bool IsUseObjPos() const { return m_aDefOptions.bUseObjPos; }
     279        5052 :         inline bool IsUseOurTextWrapping() const { return m_aDefOptions.bUseOurTextWrapping; }
     280        5052 :         inline bool IsConsiderWrappingStyle() const { return m_aDefOptions.bConsiderWrappingStyle; }
     281        5052 :         inline bool IsExpandWordSpace() const { return m_aDefOptions.bExpandWordSpace; }
     282             : 
     283             :     //  private methods
     284             : 
     285             :     private:
     286             : 
     287             :         /*-****************************************************************************************************
     288             :             @short      return list of key names of our configuration management which represent one module tree
     289             :             @descr      These methods return the current list of key names! We need it to get needed values from our
     290             :                         configuration management and support dynamical menu item lists!
     291             :             @return     A list of configuration key names is returned.
     292             :         *//*-*****************************************************************************************************/
     293             : 
     294             :         Sequence< OUString > impl_GetPropertyNames( Sequence< OUString >& rItems );
     295             : 
     296             :         /*-****************************************************************************************************
     297             :             @short      expand the list for all well known properties to destination
     298             :             @seealso    method impl_GetPropertyNames()
     299             : 
     300             :             @param      "lSource"      ,   original list
     301             :             @param      "lDestination" ,   destination of operation
     302             :             @return     A list of configuration key names is returned.
     303             :         *//*-*****************************************************************************************************/
     304             : 
     305             :         void impl_ExpandPropertyNames( const Sequence< OUString >& lSource,
     306             :                                              Sequence< OUString >& lDestination );
     307             : 
     308             :     //  private member
     309             : 
     310             :     private:
     311             : 
     312             :         SvtCompatibility        m_aOptions;
     313             :         SvtCompatibilityEntry   m_aDefOptions;
     314             : };
     315             : 
     316             : //  constructor
     317             : 
     318          86 : SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
     319             :     // Init baseclasses first
     320          86 :     :   ConfigItem( ROOTNODE_OPTIONS )
     321             :     // Init member then...
     322             : {
     323             :     // Get names and values of all accessible menu entries and fill internal structures.
     324             :     // See impl_GetPropertyNames() for further information.
     325          86 :     Sequence< OUString > lNodes;
     326         172 :     Sequence< OUString > lNames = impl_GetPropertyNames( lNodes );
     327          86 :     sal_uInt32 nCount = lNodes.getLength();
     328         172 :     Sequence< Any > lValues = GetProperties( lNames );
     329             : 
     330             :     // Safe impossible cases.
     331             :     // We need values from ALL configuration keys.
     332             :     // Follow assignment use order of values in relation to our list of key names!
     333             :     DBG_ASSERT( !( lNames.getLength()!=lValues.getLength() ), "SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()\nI miss some values of configuration keys!\n" );
     334             : 
     335         172 :     SvtCompatibilityEntry aItem;
     336          86 :     sal_uInt32 nItem = 0;
     337          86 :     sal_uInt32 nPosition = 0;
     338             : 
     339             :     // Get names/values for new menu.
     340             :     // 4 subkeys for every item!
     341          86 :     bool bDefaultFound = false;
     342         258 :     for( nItem = 0; nItem < nCount; ++nItem )
     343             :     {
     344         172 :         aItem.sName = lNodes[ nItem ];
     345         172 :         lValues[ nPosition++ ] >>= aItem.sModule;
     346         172 :         lValues[ nPosition++ ] >>= aItem.bUsePrtMetrics;
     347         172 :         lValues[ nPosition++ ] >>= aItem.bAddSpacing;
     348         172 :         lValues[ nPosition++ ] >>= aItem.bAddSpacingAtPages;
     349         172 :         lValues[ nPosition++ ] >>= aItem.bUseOurTabStops;
     350         172 :         lValues[ nPosition++ ] >>= aItem.bNoExtLeading;
     351         172 :         lValues[ nPosition++ ] >>= aItem.bUseLineSpacing;
     352         172 :         lValues[ nPosition++ ] >>= aItem.bAddTableSpacing;
     353         172 :         lValues[ nPosition++ ] >>= aItem.bUseObjPos;
     354         172 :         lValues[ nPosition++ ] >>= aItem.bUseOurTextWrapping;
     355         172 :         lValues[ nPosition++ ] >>= aItem.bConsiderWrappingStyle;
     356         172 :         lValues[ nPosition++ ] >>= aItem.bExpandWordSpace;
     357         172 :         m_aOptions.AppendEntry( aItem );
     358             : 
     359         172 :         if ( !bDefaultFound && aItem.sName.equals( COMPATIBILITY_DEFAULT_NAME ) )
     360             :         {
     361          86 :             SvtSysLocale aSysLocale;
     362         172 :             com::sun::star::lang::Locale aLocale = aSysLocale.GetLanguageTag().getLocale();
     363          86 :             if ( aLocale.Language == "zh" || aLocale.Language == "ja" || aLocale.Language == "ko" )
     364           0 :                 aItem.bExpandWordSpace = false;
     365             : 
     366          86 :             m_aDefOptions = aItem;
     367         172 :             bDefaultFound = true;
     368             :         }
     369          86 :     }
     370          86 : }
     371             : 
     372             : //  destructor
     373             : 
     374         252 : SvtCompatibilityOptions_Impl::~SvtCompatibilityOptions_Impl()
     375             : {
     376             :     // We must save our current values .. if user forget it!
     377          84 :     if( IsModified() )
     378             :     {
     379           0 :         Commit();
     380             :     }
     381         168 : }
     382             : 
     383           0 : void SvtCompatibilityOptions_Impl::SetDefault( const OUString & sName, bool bValue )
     384             : {
     385           0 :     if ( COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS.equals( sName ) )
     386           0 :         m_aDefOptions.SetUsePrtMetrics( bValue );
     387           0 :     else if ( COMPATIBILITY_PROPERTYNAME_ADDSPACING.equals( sName ) )
     388           0 :         m_aDefOptions.SetAddSpacing( bValue );
     389           0 :     else if ( COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES.equals( sName ) )
     390           0 :         m_aDefOptions.SetAddSpacingAtPages( bValue );
     391           0 :     else if ( COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS.equals( sName ) )
     392           0 :         m_aDefOptions.SetUseOurTabStops( bValue );
     393           0 :     else if ( COMPATIBILITY_PROPERTYNAME_NOEXTLEADING.equals( sName ) )
     394           0 :         m_aDefOptions.SetNoExtLeading( bValue );
     395           0 :     else if ( COMPATIBILITY_PROPERTYNAME_USELINESPACING.equals( sName ) )
     396           0 :         m_aDefOptions.SetUseLineSpacing( bValue );
     397           0 :     else if ( COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING.equals( sName ) )
     398           0 :         m_aDefOptions.SetAddTableSpacing( bValue );
     399           0 :     else if ( COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING.equals( sName ) )
     400           0 :         m_aDefOptions.SetUseObjPos( bValue );
     401           0 :     else if ( COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING.equals( sName ) )
     402           0 :         m_aDefOptions.SetUseOurTextWrapping( bValue );
     403           0 :     else if ( COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE.equals( sName ) )
     404           0 :         m_aDefOptions.SetConsiderWrappingStyle( bValue );
     405           0 :     else if ( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE.equals( sName ) )
     406           0 :         m_aDefOptions.SetExpandWordSpace( bValue );
     407           0 : }
     408             : 
     409             : //  public method
     410             : 
     411           0 : void SvtCompatibilityOptions_Impl::Notify( const Sequence< OUString >& )
     412             : {
     413             :     DBG_ASSERT( false, "SvtCompatibilityOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
     414           0 : }
     415             : 
     416             : //  public method
     417             : 
     418           0 : void SvtCompatibilityOptions_Impl::Commit()
     419             : {
     420             :     // Write all properties!
     421             :     // Delete complete set first.
     422           0 :     ClearNodeSet( SETNODE_ALLFILEFORMATS );
     423             : 
     424           0 :     SvtCompatibilityEntry aItem;
     425           0 :     OUString sNode;
     426           0 :     Sequence< PropertyValue > lPropertyValues( PROPERTYCOUNT - 1 );
     427           0 :     sal_uInt32 nItem = 0;
     428           0 :     sal_uInt32 nNewCount = m_aOptions.size();
     429           0 :     for( nItem = 0; nItem < nNewCount; ++nItem )
     430             :     {
     431           0 :         aItem = m_aOptions[ nItem ];
     432           0 :         sNode = SETNODE_ALLFILEFORMATS + PATHDELIMITER + aItem.sName + PATHDELIMITER;
     433             : 
     434           0 :         lPropertyValues[ OFFSET_MODULE - 1                  ].Name = sNode + PROPERTYNAME_MODULE;
     435           0 :         lPropertyValues[ OFFSET_USEPRTMETRICS - 1           ].Name = sNode + PROPERTYNAME_USEPRTMETRICS;
     436           0 :         lPropertyValues[ OFFSET_ADDSPACING - 1              ].Name = sNode + PROPERTYNAME_ADDSPACING;
     437           0 :         lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1       ].Name = sNode + PROPERTYNAME_ADDSPACINGATPAGES;
     438           0 :         lPropertyValues[ OFFSET_USEOURTABSTOPS - 1          ].Name = sNode + PROPERTYNAME_USEOURTABSTOPS;
     439           0 :         lPropertyValues[ OFFSET_NOEXTLEADING - 1            ].Name = sNode + PROPERTYNAME_NOEXTLEADING;
     440           0 :         lPropertyValues[ OFFSET_USELINESPACING - 1          ].Name = sNode + PROPERTYNAME_USELINESPACING;
     441           0 :         lPropertyValues[ OFFSET_ADDTABLESPACING - 1         ].Name = sNode + PROPERTYNAME_ADDTABLESPACING;
     442           0 :         lPropertyValues[ OFFSET_USEOBJPOS - 1               ].Name = sNode + PROPERTYNAME_USEOBJPOS;
     443           0 :         lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1      ].Name = sNode + PROPERTYNAME_USEOURTEXTWRAP;
     444           0 :         lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1   ].Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE;
     445           0 :         lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1         ].Name = sNode + PROPERTYNAME_EXPANDWORDSPACE;
     446             : 
     447           0 :         lPropertyValues[ OFFSET_MODULE - 1                  ].Value <<= aItem.sModule;
     448           0 :         lPropertyValues[ OFFSET_USEPRTMETRICS - 1           ].Value <<= aItem.bUsePrtMetrics;
     449           0 :         lPropertyValues[ OFFSET_ADDSPACING - 1              ].Value <<= aItem.bAddSpacing;
     450           0 :         lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1       ].Value <<= aItem.bAddSpacingAtPages;
     451           0 :         lPropertyValues[ OFFSET_USEOURTABSTOPS - 1          ].Value <<= aItem.bUseOurTabStops;
     452           0 :         lPropertyValues[ OFFSET_NOEXTLEADING - 1            ].Value <<= aItem.bNoExtLeading;
     453           0 :         lPropertyValues[ OFFSET_USELINESPACING - 1          ].Value <<= aItem.bUseLineSpacing;
     454           0 :         lPropertyValues[ OFFSET_ADDTABLESPACING - 1         ].Value <<= aItem.bAddTableSpacing;
     455           0 :         lPropertyValues[ OFFSET_USEOBJPOS - 1               ].Value <<= aItem.bUseObjPos;
     456           0 :         lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1      ].Value <<= aItem.bUseOurTextWrapping;
     457           0 :         lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1   ].Value <<= aItem.bConsiderWrappingStyle;
     458           0 :         lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1         ].Value <<= aItem.bExpandWordSpace;
     459             : 
     460           0 :         SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
     461           0 :     }
     462           0 : }
     463             : 
     464             : //  public method
     465             : 
     466           0 : void SvtCompatibilityOptions_Impl::Clear()
     467             : {
     468           0 :     m_aOptions.Clear();
     469           0 :     SetModified();
     470           0 : }
     471             : 
     472             : //  public method
     473             : 
     474           0 : Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions_Impl::GetList() const
     475             : {
     476           0 :     Sequence< Sequence< PropertyValue > > lReturn;
     477           0 :     lReturn = m_aOptions.GetList();
     478           0 :     return lReturn;
     479             : }
     480             : 
     481             : //  public method
     482             : 
     483           0 : void SvtCompatibilityOptions_Impl::AppendItem(  const OUString& _sName,
     484             :                                                 const OUString& _sModule,
     485             :                                                 bool _bUsePrtMetrics,
     486             :                                                 bool _bAddSpacing,
     487             :                                                 bool _bAddSpacingAtPages,
     488             :                                                 bool _bUseOurTabStops,
     489             :                                                 bool _bNoExtLeading,
     490             :                                                 bool _bUseLineSpacing,
     491             :                                                 bool _bAddTableSpacing,
     492             :                                                 bool _bUseObjPos,
     493             :                                                 bool _bUseOurTextWrapping,
     494             :                                                 bool _bConsiderWrappingStyle,
     495             :                                                 bool _bExpandWordSpace )
     496             : {
     497           0 :     SvtCompatibilityEntry aItem( _sName, _sModule );
     498           0 :     aItem.SetUsePrtMetrics( _bUsePrtMetrics );
     499           0 :     aItem.SetAddSpacing( _bAddSpacing );
     500           0 :     aItem.SetAddSpacingAtPages( _bAddSpacingAtPages );
     501           0 :     aItem.SetUseOurTabStops( _bUseOurTabStops );
     502           0 :     aItem.SetNoExtLeading( _bNoExtLeading );
     503           0 :     aItem.SetUseLineSpacing( _bUseLineSpacing );
     504           0 :     aItem.SetAddTableSpacing( _bAddTableSpacing );
     505           0 :     aItem.SetUseObjPos( _bUseObjPos );
     506           0 :     aItem.SetUseOurTextWrapping( _bUseOurTextWrapping );
     507           0 :     aItem.SetConsiderWrappingStyle( _bConsiderWrappingStyle );
     508           0 :     aItem.SetExpandWordSpace( _bExpandWordSpace );
     509           0 :     m_aOptions.AppendEntry( aItem );
     510             : 
     511             :     // default item reset?
     512           0 :     if ( _sName.equals( COMPATIBILITY_DEFAULT_NAME ) )
     513           0 :         m_aDefOptions = aItem;
     514             : 
     515           0 :     SetModified();
     516           0 : }
     517             : 
     518             : //  private method
     519             : 
     520          86 : Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequence< OUString >& rItems )
     521             : {
     522             :     // First get ALL names of current existing list items in configuration!
     523          86 :     rItems = GetNodeNames( SETNODE_ALLFILEFORMATS );
     524             :     // expand list to result list ...
     525          86 :     Sequence< OUString > lProperties( rItems.getLength() * ( PROPERTYCOUNT - 1 ) );
     526          86 :     impl_ExpandPropertyNames( rItems, lProperties );
     527             :     // Return result.
     528          86 :     return lProperties;
     529             : }
     530             : 
     531             : //  private method
     532             : 
     533          86 : void SvtCompatibilityOptions_Impl::impl_ExpandPropertyNames(
     534             :     const Sequence< OUString >& lSource, Sequence< OUString >& lDestination )
     535             : {
     536          86 :     OUString sFixPath;
     537          86 :     sal_Int32 nDestStep = 0;
     538          86 :     sal_Int32 nSourceCount = lSource.getLength();
     539             :     // Copy entries to destination and expand every item with 2 supported sub properties.
     540         258 :     for( sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep )
     541             :     {
     542         172 :         sFixPath = SETNODE_ALLFILEFORMATS;
     543         172 :         sFixPath += PATHDELIMITER;
     544         172 :         sFixPath += lSource[ nSourceStep ];
     545         172 :         sFixPath += PATHDELIMITER;
     546             : 
     547         172 :         lDestination[nDestStep] = sFixPath;
     548         172 :         lDestination[nDestStep] += PROPERTYNAME_MODULE;
     549         172 :         ++nDestStep;
     550         172 :         lDestination[nDestStep] = sFixPath;
     551         172 :         lDestination[nDestStep] += PROPERTYNAME_USEPRTMETRICS;
     552         172 :         ++nDestStep;
     553         172 :         lDestination[nDestStep] = sFixPath;
     554         172 :         lDestination[nDestStep] += PROPERTYNAME_ADDSPACING;
     555         172 :         ++nDestStep;
     556         172 :         lDestination[nDestStep] = sFixPath;
     557         172 :         lDestination[nDestStep] += PROPERTYNAME_ADDSPACINGATPAGES;
     558         172 :         ++nDestStep;
     559         172 :         lDestination[nDestStep] = sFixPath;
     560         172 :         lDestination[nDestStep] += PROPERTYNAME_USEOURTABSTOPS;
     561         172 :         ++nDestStep;
     562         172 :         lDestination[nDestStep] = sFixPath;
     563         172 :         lDestination[nDestStep] += PROPERTYNAME_NOEXTLEADING;
     564         172 :         ++nDestStep;
     565         172 :         lDestination[nDestStep] = sFixPath;
     566         172 :         lDestination[nDestStep] += PROPERTYNAME_USELINESPACING;
     567         172 :         ++nDestStep;
     568         172 :         lDestination[nDestStep] = sFixPath;
     569         172 :         lDestination[nDestStep] += PROPERTYNAME_ADDTABLESPACING;
     570         172 :         ++nDestStep;
     571         172 :         lDestination[nDestStep] = sFixPath;
     572         172 :         lDestination[nDestStep] += PROPERTYNAME_USEOBJPOS;
     573         172 :         ++nDestStep;
     574         172 :         lDestination[nDestStep] = sFixPath;
     575         172 :         lDestination[nDestStep] += PROPERTYNAME_USEOURTEXTWRAP;
     576         172 :         ++nDestStep;
     577         172 :         lDestination[nDestStep] = sFixPath;
     578         172 :         lDestination[nDestStep] += PROPERTYNAME_CONSIDERWRAPSTYLE;
     579         172 :         ++nDestStep;
     580         172 :         lDestination[nDestStep] = sFixPath;
     581         172 :         lDestination[nDestStep] += PROPERTYNAME_EXPANDWORDSPACE;
     582         172 :         ++nDestStep;
     583          86 :     }
     584          86 : }
     585             : 
     586             : //  initialize static member
     587             : //  DON'T DO IT IN YOUR HEADER!
     588             : //  see definition for further information
     589             : 
     590             : SvtCompatibilityOptions_Impl*   SvtCompatibilityOptions::m_pDataContainer = NULL;
     591             : sal_Int32                       SvtCompatibilityOptions::m_nRefCount = 0;
     592             : 
     593             : //  constructor
     594             : 
     595        5138 : SvtCompatibilityOptions::SvtCompatibilityOptions()
     596             : {
     597             :     // Global access, must be guarded (multithreading!).
     598        5138 :     MutexGuard aGuard( GetOwnStaticMutex() );
     599             :     // Increase our refcount ...
     600        5138 :     ++m_nRefCount;
     601             :     // ... and initialize our data container only if it not already exist!
     602        5138 :     if( m_pDataContainer == NULL )
     603             :     {
     604          86 :         m_pDataContainer = new SvtCompatibilityOptions_Impl;
     605          86 :         ItemHolder1::holdConfigItem(E_COMPATIBILITY);
     606        5138 :     }
     607        5138 : }
     608             : 
     609             : //  destructor
     610             : 
     611       10356 : SvtCompatibilityOptions::~SvtCompatibilityOptions()
     612             : {
     613             :     // Global access, must be guarded (multithreading!)
     614        5136 :     MutexGuard aGuard( GetOwnStaticMutex() );
     615             :     // Decrease our refcount.
     616        5136 :     --m_nRefCount;
     617             :     // If last instance was deleted ...
     618             :     // we must destroy our static data container!
     619        5136 :     if( m_nRefCount <= 0 )
     620             :     {
     621          84 :         delete m_pDataContainer;
     622          84 :         m_pDataContainer = NULL;
     623        5136 :     }
     624        5220 : }
     625             : 
     626             : //  public method
     627             : 
     628           0 : void SvtCompatibilityOptions::Clear()
     629             : {
     630           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     631           0 :     m_pDataContainer->Clear();
     632           0 : }
     633             : 
     634           0 : void SvtCompatibilityOptions::SetDefault( const OUString & sName, bool bValue )
     635             : {
     636           0 :     m_pDataContainer->SetDefault( sName, bValue );
     637           0 : }
     638             : 
     639             : //  public method
     640             : 
     641           0 : void SvtCompatibilityOptions::AppendItem( const OUString& sName,
     642             :                                           const OUString& sModule,
     643             :                                           bool bUsePrtMetrics,
     644             :                                           bool bAddSpacing,
     645             :                                           bool bAddSpacingAtPages,
     646             :                                           bool bUseOurTabStops,
     647             :                                           bool bNoExtLeading,
     648             :                                           bool bUseLineSpacing,
     649             :                                           bool bAddTableSpacing,
     650             :                                           bool bUseObjPos,
     651             :                                           bool bUseOurTextWrapping,
     652             :                                           bool bConsiderWrappingStyle,
     653             :                                           bool bExpandWordSpace )
     654             : {
     655           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     656             :     m_pDataContainer->AppendItem(
     657             :         sName, sModule, bUsePrtMetrics, bAddSpacing,
     658             :         bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
     659             :         bUseLineSpacing, bAddTableSpacing, bUseObjPos,
     660           0 :         bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace );
     661           0 : }
     662             : 
     663        5052 : bool SvtCompatibilityOptions::IsUsePrtDevice() const
     664             : {
     665        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     666        5052 :     return m_pDataContainer->IsUsePrtDevice();
     667             : }
     668             : 
     669        5052 : bool SvtCompatibilityOptions::IsAddSpacing() const
     670             : {
     671        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     672        5052 :     return m_pDataContainer->IsAddSpacing();
     673             : }
     674             : 
     675        5052 : bool SvtCompatibilityOptions::IsAddSpacingAtPages() const
     676             : {
     677        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     678        5052 :     return m_pDataContainer->IsAddSpacingAtPages();
     679             : }
     680             : 
     681        5052 : bool SvtCompatibilityOptions::IsUseOurTabStops() const
     682             : {
     683        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     684        5052 :     return m_pDataContainer->IsUseOurTabStops();
     685             : }
     686             : 
     687        5052 : bool SvtCompatibilityOptions::IsNoExtLeading() const
     688             : {
     689        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     690        5052 :     return m_pDataContainer->IsNoExtLeading();
     691             : }
     692             : 
     693        5052 : bool SvtCompatibilityOptions::IsUseLineSpacing() const
     694             : {
     695        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     696        5052 :     return m_pDataContainer->IsUseLineSpacing();
     697             : }
     698             : 
     699        5052 : bool SvtCompatibilityOptions::IsAddTableSpacing() const
     700             : {
     701        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     702        5052 :     return m_pDataContainer->IsAddTableSpacing();
     703             : }
     704             : 
     705        5052 : bool SvtCompatibilityOptions::IsUseObjectPositioning() const
     706             : {
     707        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     708        5052 :     return m_pDataContainer->IsUseObjPos();
     709             : }
     710             : 
     711        5052 : bool SvtCompatibilityOptions::IsUseOurTextWrapping() const
     712             : {
     713        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     714        5052 :     return m_pDataContainer->IsUseOurTextWrapping();
     715             : }
     716             : 
     717        5052 : bool SvtCompatibilityOptions::IsConsiderWrappingStyle() const
     718             : {
     719        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     720        5052 :     return m_pDataContainer->IsConsiderWrappingStyle();
     721             : }
     722             : 
     723        5052 : bool SvtCompatibilityOptions::IsExpandWordSpace() const
     724             : {
     725        5052 :     MutexGuard aGuard( GetOwnStaticMutex() );
     726        5052 :     return m_pDataContainer->IsExpandWordSpace();
     727             : }
     728             : 
     729           0 : Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions::GetList() const
     730             : {
     731           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     732           0 :     return m_pDataContainer->GetList();
     733             : }
     734             : 
     735             : namespace
     736             : {
     737             :     class theCompatibilityOptionsMutex : public rtl::Static<osl::Mutex, theCompatibilityOptionsMutex>{};
     738             : }
     739             : 
     740             : //  private method
     741             : 
     742       65846 : Mutex& SvtCompatibilityOptions::GetOwnStaticMutex()
     743             : {
     744       65846 :     return theCompatibilityOptionsMutex::get();
     745             : }
     746             : 
     747             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10