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

Generated by: LCOV version 1.10