2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-07-11 09:51:50 +01:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2003-10-15 09:07:51 +00:00
2009-10-06 07:38:24 +02:00
# include <unotools/compatibility.hxx>
2003-10-15 09:07:51 +00:00
# include <unotools/configmgr.hxx>
# include <unotools/configitem.hxx>
2010-09-14 17:21:03 +02:00
# include <unotools/syslocale.hxx>
2003-10-15 09:07:51 +00:00
# include <tools/debug.hxx>
# include <com/sun/star/uno/Any.hxx>
# include <com/sun/star/uno/Sequence.hxx>
# include <vector>
2014-05-10 18:12:32 +02:00
# include "itemholder1.hxx"
2005-11-11 07:47:18 +00:00
2003-10-15 09:07:51 +00:00
# include <algorithm>
// namespaces
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
using namespace : : std ;
using namespace : : utl ;
using namespace : : osl ;
using namespace : : com : : sun : : star : : uno ;
using namespace : : com : : sun : : star : : beans ;
2013-03-10 20:44:01 +01:00
# define ROOTNODE_OPTIONS OUString( "Office.Compatibility / " )
2014-12-18 13:38:27 +01:00
# define PATHDELIMITER " / "
# define SETNODE_ALLFILEFORMATS "AllFileFormats"
2003-10-15 09:07:51 +00:00
2004-02-26 16:06:12 +00:00
# define PROPERTYNAME_NAME COMPATIBILITY_PROPERTYNAME_NAME
# define PROPERTYNAME_MODULE COMPATIBILITY_PROPERTYNAME_MODULE
# define PROPERTYNAME_USEPRTMETRICS COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
# define PROPERTYNAME_ADDSPACING COMPATIBILITY_PROPERTYNAME_ADDSPACING
# define PROPERTYNAME_ADDSPACINGATPAGES COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
# define PROPERTYNAME_USEOURTABSTOPS COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
# define PROPERTYNAME_NOEXTLEADING COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
# define PROPERTYNAME_USELINESPACING COMPATIBILITY_PROPERTYNAME_USELINESPACING
2004-03-23 10:31:47 +00:00
# define PROPERTYNAME_ADDTABLESPACING COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
2004-03-31 14:14:37 +00:00
# define PROPERTYNAME_USEOBJPOS COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
2004-05-11 10:31:21 +00:00
# define PROPERTYNAME_USEOURTEXTWRAP COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
2004-08-02 12:54:02 +00:00
# define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
2007-07-10 14:15:59 +00:00
# define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
# define PROPERTYCOUNT 13
# define OFFSET_NAME 0
# define OFFSET_MODULE 1
# define OFFSET_USEPRTMETRICS 2
# define OFFSET_ADDSPACING 3
# define OFFSET_ADDSPACINGATPAGES 4
# define OFFSET_USEOURTABSTOPS 5
# define OFFSET_NOEXTLEADING 6
# define OFFSET_USELINESPACING 7
# define OFFSET_ADDTABLESPACING 8
# define OFFSET_USEOBJPOS 9
# define OFFSET_USEOURTEXTWRAPPING 10
# define OFFSET_CONSIDERWRAPPINGSTYLE 11
# define OFFSET_EXPANDWORDSPACE 12
2003-10-15 09:07:51 +00:00
// private declarations!
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
/*-****************************************************************************************************************
@ descr struct to hold information about one compatibility entry
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - */
struct SvtCompatibilityEntry
{
public :
2004-02-26 16:06:12 +00:00
SvtCompatibilityEntry ( ) :
bUsePrtMetrics ( false ) , bAddSpacing ( false ) ,
bAddSpacingAtPages ( false ) , bUseOurTabStops ( false ) ,
2004-03-31 14:14:37 +00:00
bNoExtLeading ( false ) , bUseLineSpacing ( false ) ,
2004-08-02 12:54:02 +00:00
bAddTableSpacing ( false ) , bUseObjPos ( false ) ,
2007-07-10 14:15:59 +00:00
bUseOurTextWrapping ( false ) , bConsiderWrappingStyle ( false ) ,
bExpandWordSpace ( true ) { }
2003-10-15 09:07:51 +00:00
SvtCompatibilityEntry (
2004-02-26 16:06:12 +00:00
const OUString & _rName , const OUString & _rNewModule ) :
sName ( _rName ) , sModule ( _rNewModule ) ,
bUsePrtMetrics ( false ) , bAddSpacing ( false ) ,
bAddSpacingAtPages ( false ) , bUseOurTabStops ( false ) ,
2004-03-31 14:14:37 +00:00
bNoExtLeading ( false ) , bUseLineSpacing ( false ) ,
2004-08-02 12:54:02 +00:00
bAddTableSpacing ( false ) , bUseObjPos ( false ) ,
2007-07-10 14:15:59 +00:00
bUseOurTextWrapping ( false ) , bConsiderWrappingStyle ( false ) ,
bExpandWordSpace ( true ) { }
2004-02-26 16:06:12 +00:00
inline void SetUsePrtMetrics ( bool _bSet ) { bUsePrtMetrics = _bSet ; }
inline void SetAddSpacing ( bool _bSet ) { bAddSpacing = _bSet ; }
inline void SetAddSpacingAtPages ( bool _bSet ) { bAddSpacingAtPages = _bSet ; }
inline void SetUseOurTabStops ( bool _bSet ) { bUseOurTabStops = _bSet ; }
inline void SetNoExtLeading ( bool _bSet ) { bNoExtLeading = _bSet ; }
inline void SetUseLineSpacing ( bool _bSet ) { bUseLineSpacing = _bSet ; }
2004-03-23 10:31:47 +00:00
inline void SetAddTableSpacing ( bool _bSet ) { bAddTableSpacing = _bSet ; }
2004-03-31 14:14:37 +00:00
inline void SetUseObjPos ( bool _bSet ) { bUseObjPos = _bSet ; }
2004-05-11 10:31:21 +00:00
inline void SetUseOurTextWrapping ( bool _bSet ) { bUseOurTextWrapping = _bSet ; }
2004-08-02 12:54:02 +00:00
inline void SetConsiderWrappingStyle ( bool _bSet ) { bConsiderWrappingStyle = _bSet ; }
2007-07-10 14:15:59 +00:00
inline void SetExpandWordSpace ( bool _bSet ) { bExpandWordSpace = _bSet ; }
2006-08-11 14:49:24 +00:00
2003-10-15 09:07:51 +00:00
public :
OUString sName ;
OUString sModule ;
2004-02-26 16:06:12 +00:00
bool bUsePrtMetrics ;
bool bAddSpacing ;
bool bAddSpacingAtPages ;
bool bUseOurTabStops ;
bool bNoExtLeading ;
bool bUseLineSpacing ;
2004-03-23 10:31:47 +00:00
bool bAddTableSpacing ;
2004-03-31 14:14:37 +00:00
bool bUseObjPos ;
2004-05-11 10:31:21 +00:00
bool bUseOurTextWrapping ;
2004-08-02 12:54:02 +00:00
bool bConsiderWrappingStyle ;
2007-07-10 14:15:59 +00:00
bool bExpandWordSpace ;
2003-10-15 09:07:51 +00:00
} ;
/*-****************************************************************************************************************
@ descr support simple menu structures and operations on it
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - */
class SvtCompatibility
{
public :
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
// append one entry
void AppendEntry ( const SvtCompatibilityEntry & rEntry )
{
lEntries . push_back ( rEntry ) ;
}
// the only way to free memory!
void Clear ( )
{
lEntries . clear ( ) ;
}
// convert internal list to external format
Sequence < Sequence < PropertyValue > > GetList ( ) const
{
sal_Int32 nCount = ( sal_Int32 ) lEntries . size ( ) ;
sal_Int32 nStep = 0 ;
Sequence < PropertyValue > lProperties ( PROPERTYCOUNT ) ;
Sequence < Sequence < PropertyValue > > lResult ( nCount ) ;
const vector < SvtCompatibilityEntry > * pList = & lEntries ;
lProperties [ OFFSET_NAME ] . Name = PROPERTYNAME_NAME ;
lProperties [ OFFSET_MODULE ] . Name = PROPERTYNAME_MODULE ;
2004-02-26 16:06:12 +00:00
lProperties [ OFFSET_USEPRTMETRICS ] . Name = PROPERTYNAME_USEPRTMETRICS ;
lProperties [ OFFSET_ADDSPACING ] . Name = PROPERTYNAME_ADDSPACING ;
lProperties [ OFFSET_ADDSPACINGATPAGES ] . Name = PROPERTYNAME_ADDSPACINGATPAGES ;
lProperties [ OFFSET_USEOURTABSTOPS ] . Name = PROPERTYNAME_USEOURTABSTOPS ;
lProperties [ OFFSET_NOEXTLEADING ] . Name = PROPERTYNAME_NOEXTLEADING ;
lProperties [ OFFSET_USELINESPACING ] . Name = PROPERTYNAME_USELINESPACING ;
2004-03-23 10:31:47 +00:00
lProperties [ OFFSET_ADDTABLESPACING ] . Name = PROPERTYNAME_ADDTABLESPACING ;
2004-03-31 14:14:37 +00:00
lProperties [ OFFSET_USEOBJPOS ] . Name = PROPERTYNAME_USEOBJPOS ;
2004-05-11 10:31:21 +00:00
lProperties [ OFFSET_USEOURTEXTWRAPPING ] . Name = PROPERTYNAME_USEOURTEXTWRAP ;
2004-08-02 12:54:02 +00:00
lProperties [ OFFSET_CONSIDERWRAPPINGSTYLE ] . Name = PROPERTYNAME_CONSIDERWRAPSTYLE ;
2007-07-10 14:15:59 +00:00
lProperties [ OFFSET_EXPANDWORDSPACE ] . Name = PROPERTYNAME_EXPANDWORDSPACE ;
2003-10-15 09:07:51 +00:00
for ( vector < SvtCompatibilityEntry > : : const_iterator pItem = pList - > begin ( ) ;
pItem ! = pList - > end ( ) ; + + pItem )
{
lProperties [ OFFSET_NAME ] . Value < < = pItem - > sName ;
lProperties [ OFFSET_MODULE ] . Value < < = pItem - > sModule ;
2004-02-26 16:06:12 +00:00
lProperties [ OFFSET_USEPRTMETRICS ] . Value < < = pItem - > bUsePrtMetrics ;
lProperties [ OFFSET_ADDSPACING ] . Value < < = pItem - > bAddSpacing ;
lProperties [ OFFSET_ADDSPACINGATPAGES ] . Value < < = pItem - > bAddSpacingAtPages ;
lProperties [ OFFSET_USEOURTABSTOPS ] . Value < < = pItem - > bUseOurTabStops ;
lProperties [ OFFSET_NOEXTLEADING ] . Value < < = pItem - > bNoExtLeading ;
lProperties [ OFFSET_USELINESPACING ] . Value < < = pItem - > bUseLineSpacing ;
2004-03-23 10:31:47 +00:00
lProperties [ OFFSET_ADDTABLESPACING ] . Value < < = pItem - > bAddTableSpacing ;
2004-03-31 14:14:37 +00:00
lProperties [ OFFSET_USEOBJPOS ] . Value < < = pItem - > bUseObjPos ;
2004-05-11 10:31:21 +00:00
lProperties [ OFFSET_USEOURTEXTWRAPPING ] . Value < < = pItem - > bUseOurTextWrapping ;
2004-08-02 12:54:02 +00:00
lProperties [ OFFSET_CONSIDERWRAPPINGSTYLE ] . Value < < = pItem - > bConsiderWrappingStyle ;
2007-07-10 14:15:59 +00:00
lProperties [ OFFSET_EXPANDWORDSPACE ] . Value < < = pItem - > bExpandWordSpace ;
2003-10-15 09:07:51 +00:00
lResult [ nStep ] = lProperties ;
+ + nStep ;
}
return lResult ;
}
int size ( ) const
{
return lEntries . size ( ) ;
}
2010-11-25 11:36:25 +00:00
const SvtCompatibilityEntry & operator [ ] ( int i ) const
2003-10-15 09:07:51 +00:00
{
return lEntries [ i ] ;
}
private :
vector < SvtCompatibilityEntry > lEntries ;
} ;
class SvtCompatibilityOptions_Impl : public ConfigItem
{
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
// public methods
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
public :
// constructor / destructor
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions_Impl ( ) ;
2014-04-01 19:18:35 +02:00
virtual ~ SvtCompatibilityOptions_Impl ( ) ;
2003-10-15 09:07:51 +00:00
2014-03-14 15:14:28 +02:00
void SetDefault ( const OUString & sName , bool bValue ) ;
2010-09-14 17:21:03 +02:00
2015-01-08 23:08:34 +01:00
// override methods of baseclass
2014-02-22 21:20:15 +01:00
2014-02-25 22:46:10 +01:00
/*-****************************************************************************************************
2003-10-15 09:07:51 +00:00
@ short called for notify of configmanager
@ descr These method is called from the ConfigManager before application ends or from the
PropertyChangeListener if the sub tree broadcasts changes . You must update your
internal values .
@ seealso baseclass ConfigItem
@ param " lPropertyNames " is the list of properties which should be updated .
*/ /*-*****************************************************************************************************/
2014-03-26 16:37:00 +01:00
virtual void Notify ( const Sequence < OUString > & lPropertyNames ) SAL_OVERRIDE ;
2003-10-15 09:07:51 +00:00
// public interface
2014-02-22 21:20:15 +01:00
2014-02-25 22:46:10 +01:00
/*-****************************************************************************************************
2003-10-15 09:07:51 +00:00
@ short base implementation of public interface for " SvtCompatibilityOptions " !
@ descr These class is used as static member of " SvtCompatibilityOptions " . . .
= > The code exist only for one time and isn ' t duplicated for every instance !
*/ /*-*****************************************************************************************************/
void Clear ( ) ;
Sequence < Sequence < PropertyValue > > GetList ( ) const ;
2013-04-07 12:06:47 +02:00
void AppendItem ( const OUString & _sName ,
const OUString & _sModule ,
2004-02-26 16:06:12 +00:00
bool _bUsePrtMetrics ,
bool _bAddSpacing ,
bool _bAddSpacingAtPages ,
bool _bUseOurTabStops ,
bool _bNoExtLeading ,
2004-03-23 10:31:47 +00:00
bool _bUseLineSpacing ,
2004-03-31 14:14:37 +00:00
bool _bAddTableSpacing ,
2004-05-11 10:31:21 +00:00
bool _bUseObjPos ,
2004-08-02 12:54:02 +00:00
bool _bUseOurTextWrapping ,
2007-07-10 14:15:59 +00:00
bool _bConsiderWrappingStyle ,
bool _bExpandWordSpace ) ;
inline bool IsUsePrtDevice ( ) const { return m_aDefOptions . bUsePrtMetrics ; }
inline bool IsAddSpacing ( ) const { return m_aDefOptions . bAddSpacing ; }
inline bool IsAddSpacingAtPages ( ) const { return m_aDefOptions . bAddSpacingAtPages ; }
inline bool IsUseOurTabStops ( ) const { return m_aDefOptions . bUseOurTabStops ; }
inline bool IsNoExtLeading ( ) const { return m_aDefOptions . bNoExtLeading ; }
inline bool IsUseLineSpacing ( ) const { return m_aDefOptions . bUseLineSpacing ; }
inline bool IsAddTableSpacing ( ) const { return m_aDefOptions . bAddTableSpacing ; }
inline bool IsUseObjPos ( ) const { return m_aDefOptions . bUseObjPos ; }
inline bool IsUseOurTextWrapping ( ) const { return m_aDefOptions . bUseOurTextWrapping ; }
inline bool IsConsiderWrappingStyle ( ) const { return m_aDefOptions . bConsiderWrappingStyle ; }
inline bool IsExpandWordSpace ( ) const { return m_aDefOptions . bExpandWordSpace ; }
2003-10-15 09:07:51 +00:00
// private methods
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
private :
2015-03-11 16:14:47 +01:00
virtual void ImplCommit ( ) SAL_OVERRIDE ;
2014-02-25 22:46:10 +01:00
/*-****************************************************************************************************
2003-10-15 09:07:51 +00:00
@ short return list of key names of our configuration management which represent one module tree
@ descr These methods return the current list of key names ! We need it to get needed values from our
configuration management and support dynamical menu item lists !
@ return A list of configuration key names is returned .
*/ /*-*****************************************************************************************************/
Sequence < OUString > impl_GetPropertyNames ( Sequence < OUString > & rItems ) ;
2014-02-25 22:46:10 +01:00
/*-****************************************************************************************************
2003-10-15 09:07:51 +00:00
@ short expand the list for all well known properties to destination
@ seealso method impl_GetPropertyNames ( )
@ param " lSource " , original list
@ param " lDestination " , destination of operation
@ return A list of configuration key names is returned .
*/ /*-*****************************************************************************************************/
2015-04-01 14:24:26 +02:00
static void impl_ExpandPropertyNames ( const Sequence < OUString > & lSource ,
Sequence < OUString > & lDestination ) ;
2003-10-15 09:07:51 +00:00
// private member
2014-02-22 21:20:15 +01:00
2003-10-15 09:07:51 +00:00
private :
2004-02-26 16:06:12 +00:00
SvtCompatibility m_aOptions ;
SvtCompatibilityEntry m_aDefOptions ;
2003-10-15 09:07:51 +00:00
} ;
// constructor
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions_Impl : : SvtCompatibilityOptions_Impl ( )
// Init baseclasses first
: ConfigItem ( ROOTNODE_OPTIONS )
// Init member then...
{
2013-02-23 17:29:22 +01:00
// Get names and values of all accessible menu entries and fill internal structures.
2013-04-15 04:49:39 +02:00
// See impl_GetPropertyNames() for further information.
2003-10-15 09:07:51 +00:00
Sequence < OUString > lNodes ;
Sequence < OUString > lNames = impl_GetPropertyNames ( lNodes ) ;
sal_uInt32 nCount = lNodes . getLength ( ) ;
Sequence < Any > lValues = GetProperties ( lNames ) ;
// Safe impossible cases.
// We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names!
DBG_ASSERT ( ! ( lNames . getLength ( ) ! = lValues . getLength ( ) ) , " SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() \n I miss some values of configuration keys! \n " ) ;
SvtCompatibilityEntry aItem ;
sal_uInt32 nItem = 0 ;
sal_uInt32 nPosition = 0 ;
// Get names/values for new menu.
// 4 subkeys for every item!
bool bDefaultFound = false ;
for ( nItem = 0 ; nItem < nCount ; + + nItem )
{
aItem . sName = lNodes [ nItem ] ;
lValues [ nPosition + + ] > > = aItem . sModule ;
2004-02-26 16:06:12 +00:00
lValues [ nPosition + + ] > > = aItem . bUsePrtMetrics ;
lValues [ nPosition + + ] > > = aItem . bAddSpacing ;
lValues [ nPosition + + ] > > = aItem . bAddSpacingAtPages ;
lValues [ nPosition + + ] > > = aItem . bUseOurTabStops ;
lValues [ nPosition + + ] > > = aItem . bNoExtLeading ;
lValues [ nPosition + + ] > > = aItem . bUseLineSpacing ;
2004-03-23 10:31:47 +00:00
lValues [ nPosition + + ] > > = aItem . bAddTableSpacing ;
2004-03-31 14:14:37 +00:00
lValues [ nPosition + + ] > > = aItem . bUseObjPos ;
2004-05-11 10:31:21 +00:00
lValues [ nPosition + + ] > > = aItem . bUseOurTextWrapping ;
2004-08-02 12:54:02 +00:00
lValues [ nPosition + + ] > > = aItem . bConsiderWrappingStyle ;
2007-07-10 14:15:59 +00:00
lValues [ nPosition + + ] > > = aItem . bExpandWordSpace ;
2003-10-15 09:07:51 +00:00
m_aOptions . AppendEntry ( aItem ) ;
2014-12-18 13:38:27 +01:00
if ( ! bDefaultFound & & aItem . sName = = COMPATIBILITY_DEFAULT_NAME )
2003-10-15 09:07:51 +00:00
{
2010-09-14 17:21:03 +02:00
SvtSysLocale aSysLocale ;
2012-11-21 18:34:53 +01:00
com : : sun : : star : : lang : : Locale aLocale = aSysLocale . GetLanguageTag ( ) . getLocale ( ) ;
2012-04-06 19:49:53 +02:00
if ( aLocale . Language = = " zh " | | aLocale . Language = = " ja " | | aLocale . Language = = " ko " )
2010-09-14 17:21:03 +02:00
aItem . bExpandWordSpace = false ;
2004-02-26 16:06:12 +00:00
m_aDefOptions = aItem ;
2003-10-15 09:07:51 +00:00
bDefaultFound = true ;
}
}
}
// destructor
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions_Impl : : ~ SvtCompatibilityOptions_Impl ( )
{
2015-03-11 16:39:24 +01:00
assert ( ! IsModified ( ) ) ; // should have been committed
2003-10-15 09:07:51 +00:00
}
2014-03-14 15:14:28 +02:00
void SvtCompatibilityOptions_Impl : : SetDefault ( const OUString & sName , bool bValue )
2010-09-14 17:21:03 +02:00
{
2014-12-18 13:38:27 +01:00
if ( sName = = COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetUsePrtMetrics ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_ADDSPACING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetAddSpacing ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetAddSpacingAtPages ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetUseOurTabStops ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetNoExtLeading ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_USELINESPACING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetUseLineSpacing ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetAddTableSpacing ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetUseObjPos ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetUseOurTextWrapping ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetConsiderWrappingStyle ( bValue ) ;
2014-12-18 13:38:27 +01:00
else if ( sName = = COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
2010-09-14 17:21:03 +02:00
m_aDefOptions . SetExpandWordSpace ( bValue ) ;
}
2003-10-15 09:07:51 +00:00
// public method
2014-02-25 22:46:10 +01:00
2006-06-19 19:42:23 +00:00
void SvtCompatibilityOptions_Impl : : Notify ( const Sequence < OUString > & )
2003-10-15 09:07:51 +00:00
{
2014-01-28 19:58:32 +01:00
DBG_ASSERT ( false , " SvtCompatibilityOptions_Impl::Notify() \n Not implemented yet! I don't know how I can handle a dynamical list of unknown properties ... \n " ) ;
2003-10-15 09:07:51 +00:00
}
// public method
2014-02-25 22:46:10 +01:00
2015-03-11 16:14:47 +01:00
void SvtCompatibilityOptions_Impl : : ImplCommit ( )
2003-10-15 09:07:51 +00:00
{
// Write all properties!
// Delete complete set first.
ClearNodeSet ( SETNODE_ALLFILEFORMATS ) ;
SvtCompatibilityEntry aItem ;
OUString sNode ;
Sequence < PropertyValue > lPropertyValues ( PROPERTYCOUNT - 1 ) ;
sal_uInt32 nItem = 0 ;
sal_uInt32 nNewCount = m_aOptions . size ( ) ;
for ( nItem = 0 ; nItem < nNewCount ; + + nItem )
{
aItem = m_aOptions [ nItem ] ;
2014-12-18 13:38:27 +01:00
sNode = SETNODE_ALLFILEFORMATS PATHDELIMITER + aItem . sName + PATHDELIMITER ;
2003-10-15 09:07:51 +00:00
2004-08-02 12:54:02 +00:00
lPropertyValues [ OFFSET_MODULE - 1 ] . Name = sNode + PROPERTYNAME_MODULE ;
lPropertyValues [ OFFSET_USEPRTMETRICS - 1 ] . Name = sNode + PROPERTYNAME_USEPRTMETRICS ;
lPropertyValues [ OFFSET_ADDSPACING - 1 ] . Name = sNode + PROPERTYNAME_ADDSPACING ;
lPropertyValues [ OFFSET_ADDSPACINGATPAGES - 1 ] . Name = sNode + PROPERTYNAME_ADDSPACINGATPAGES ;
lPropertyValues [ OFFSET_USEOURTABSTOPS - 1 ] . Name = sNode + PROPERTYNAME_USEOURTABSTOPS ;
lPropertyValues [ OFFSET_NOEXTLEADING - 1 ] . Name = sNode + PROPERTYNAME_NOEXTLEADING ;
lPropertyValues [ OFFSET_USELINESPACING - 1 ] . Name = sNode + PROPERTYNAME_USELINESPACING ;
lPropertyValues [ OFFSET_ADDTABLESPACING - 1 ] . Name = sNode + PROPERTYNAME_ADDTABLESPACING ;
lPropertyValues [ OFFSET_USEOBJPOS - 1 ] . Name = sNode + PROPERTYNAME_USEOBJPOS ;
lPropertyValues [ OFFSET_USEOURTEXTWRAPPING - 1 ] . Name = sNode + PROPERTYNAME_USEOURTEXTWRAP ;
lPropertyValues [ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ] . Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE ;
2007-07-10 14:15:59 +00:00
lPropertyValues [ OFFSET_EXPANDWORDSPACE - 1 ] . Name = sNode + PROPERTYNAME_EXPANDWORDSPACE ;
2004-08-02 12:54:02 +00:00
lPropertyValues [ OFFSET_MODULE - 1 ] . Value < < = aItem . sModule ;
lPropertyValues [ OFFSET_USEPRTMETRICS - 1 ] . Value < < = aItem . bUsePrtMetrics ;
lPropertyValues [ OFFSET_ADDSPACING - 1 ] . Value < < = aItem . bAddSpacing ;
lPropertyValues [ OFFSET_ADDSPACINGATPAGES - 1 ] . Value < < = aItem . bAddSpacingAtPages ;
lPropertyValues [ OFFSET_USEOURTABSTOPS - 1 ] . Value < < = aItem . bUseOurTabStops ;
lPropertyValues [ OFFSET_NOEXTLEADING - 1 ] . Value < < = aItem . bNoExtLeading ;
lPropertyValues [ OFFSET_USELINESPACING - 1 ] . Value < < = aItem . bUseLineSpacing ;
lPropertyValues [ OFFSET_ADDTABLESPACING - 1 ] . Value < < = aItem . bAddTableSpacing ;
lPropertyValues [ OFFSET_USEOBJPOS - 1 ] . Value < < = aItem . bUseObjPos ;
lPropertyValues [ OFFSET_USEOURTEXTWRAPPING - 1 ] . Value < < = aItem . bUseOurTextWrapping ;
lPropertyValues [ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ] . Value < < = aItem . bConsiderWrappingStyle ;
2007-07-10 14:15:59 +00:00
lPropertyValues [ OFFSET_EXPANDWORDSPACE - 1 ] . Value < < = aItem . bExpandWordSpace ;
2003-10-15 09:07:51 +00:00
SetSetProperties ( SETNODE_ALLFILEFORMATS , lPropertyValues ) ;
}
}
// public method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
void SvtCompatibilityOptions_Impl : : Clear ( )
{
m_aOptions . Clear ( ) ;
SetModified ( ) ;
}
// public method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
Sequence < Sequence < PropertyValue > > SvtCompatibilityOptions_Impl : : GetList ( ) const
{
Sequence < Sequence < PropertyValue > > lReturn ;
lReturn = m_aOptions . GetList ( ) ;
return lReturn ;
}
// public method
2014-02-25 22:46:10 +01:00
2013-04-07 12:06:47 +02:00
void SvtCompatibilityOptions_Impl : : AppendItem ( const OUString & _sName ,
const OUString & _sModule ,
2004-02-26 16:06:12 +00:00
bool _bUsePrtMetrics ,
bool _bAddSpacing ,
bool _bAddSpacingAtPages ,
bool _bUseOurTabStops ,
bool _bNoExtLeading ,
2004-03-23 10:31:47 +00:00
bool _bUseLineSpacing ,
2004-03-31 14:14:37 +00:00
bool _bAddTableSpacing ,
2004-05-11 10:31:21 +00:00
bool _bUseObjPos ,
2004-08-02 12:54:02 +00:00
bool _bUseOurTextWrapping ,
2007-07-10 14:15:59 +00:00
bool _bConsiderWrappingStyle ,
bool _bExpandWordSpace )
2003-10-15 09:07:51 +00:00
{
2004-02-26 16:06:12 +00:00
SvtCompatibilityEntry aItem ( _sName , _sModule ) ;
aItem . SetUsePrtMetrics ( _bUsePrtMetrics ) ;
aItem . SetAddSpacing ( _bAddSpacing ) ;
aItem . SetAddSpacingAtPages ( _bAddSpacingAtPages ) ;
aItem . SetUseOurTabStops ( _bUseOurTabStops ) ;
aItem . SetNoExtLeading ( _bNoExtLeading ) ;
aItem . SetUseLineSpacing ( _bUseLineSpacing ) ;
2004-03-23 10:31:47 +00:00
aItem . SetAddTableSpacing ( _bAddTableSpacing ) ;
2004-03-31 14:14:37 +00:00
aItem . SetUseObjPos ( _bUseObjPos ) ;
2004-05-11 10:31:21 +00:00
aItem . SetUseOurTextWrapping ( _bUseOurTextWrapping ) ;
2004-08-02 12:54:02 +00:00
aItem . SetConsiderWrappingStyle ( _bConsiderWrappingStyle ) ;
2007-07-10 14:15:59 +00:00
aItem . SetExpandWordSpace ( _bExpandWordSpace ) ;
2003-10-15 09:07:51 +00:00
m_aOptions . AppendEntry ( aItem ) ;
2007-07-10 14:15:59 +00:00
// default item reset?
2014-12-18 13:38:27 +01:00
if ( _sName = = COMPATIBILITY_DEFAULT_NAME )
2007-07-10 14:15:59 +00:00
m_aDefOptions = aItem ;
2003-10-15 09:07:51 +00:00
SetModified ( ) ;
}
// private method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
Sequence < OUString > SvtCompatibilityOptions_Impl : : impl_GetPropertyNames ( Sequence < OUString > & rItems )
{
// First get ALL names of current existing list items in configuration!
rItems = GetNodeNames ( SETNODE_ALLFILEFORMATS ) ;
// expand list to result list ...
Sequence < OUString > lProperties ( rItems . getLength ( ) * ( PROPERTYCOUNT - 1 ) ) ;
impl_ExpandPropertyNames ( rItems , lProperties ) ;
// Return result.
return lProperties ;
}
// private method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
void SvtCompatibilityOptions_Impl : : impl_ExpandPropertyNames (
const Sequence < OUString > & lSource , Sequence < OUString > & lDestination )
{
OUString sFixPath ;
sal_Int32 nDestStep = 0 ;
sal_Int32 nSourceCount = lSource . getLength ( ) ;
// Copy entries to destination and expand every item with 2 supported sub properties.
for ( sal_Int32 nSourceStep = 0 ; nSourceStep < nSourceCount ; + + nSourceStep )
{
sFixPath = SETNODE_ALLFILEFORMATS ;
sFixPath + = PATHDELIMITER ;
sFixPath + = lSource [ nSourceStep ] ;
sFixPath + = PATHDELIMITER ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_MODULE ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
2004-02-26 16:06:12 +00:00
lDestination [ nDestStep ] + = PROPERTYNAME_USEPRTMETRICS ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_ADDSPACING ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_ADDSPACINGATPAGES ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_USEOURTABSTOPS ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_NOEXTLEADING ;
+ + nDestStep ;
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_USELINESPACING ;
2003-10-15 09:07:51 +00:00
+ + nDestStep ;
2004-03-23 10:31:47 +00:00
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_ADDTABLESPACING ;
+ + nDestStep ;
2004-03-31 14:14:37 +00:00
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_USEOBJPOS ;
+ + nDestStep ;
2004-05-11 10:31:21 +00:00
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_USEOURTEXTWRAP ;
+ + nDestStep ;
2004-08-02 12:54:02 +00:00
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_CONSIDERWRAPSTYLE ;
+ + nDestStep ;
2007-07-10 14:15:59 +00:00
lDestination [ nDestStep ] = sFixPath ;
lDestination [ nDestStep ] + = PROPERTYNAME_EXPANDWORDSPACE ;
+ + nDestStep ;
2003-10-15 09:07:51 +00:00
}
}
// initialize static member
// DON'T DO IT IN YOUR HEADER!
2013-04-15 04:49:39 +02:00
// see definition for further information
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions_Impl * SvtCompatibilityOptions : : m_pDataContainer = NULL ;
sal_Int32 SvtCompatibilityOptions : : m_nRefCount = 0 ;
// constructor
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions : : SvtCompatibilityOptions ( )
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2014-04-06 20:25:20 +03:00
// Increase our refcount ...
2003-10-15 09:07:51 +00:00
+ + m_nRefCount ;
2014-04-06 20:25:20 +03:00
// ... and initialize our data container only if it not already exist!
2003-10-15 09:07:51 +00:00
if ( m_pDataContainer = = NULL )
{
m_pDataContainer = new SvtCompatibilityOptions_Impl ;
2005-11-11 07:47:18 +00:00
ItemHolder1 : : holdConfigItem ( E_COMPATIBILITY ) ;
2003-10-15 09:07:51 +00:00
}
}
// destructor
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
SvtCompatibilityOptions : : ~ SvtCompatibilityOptions ( )
{
// Global access, must be guarded (multithreading!)
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2014-04-06 20:25:20 +03:00
// Decrease our refcount.
2003-10-15 09:07:51 +00:00
- - m_nRefCount ;
// If last instance was deleted ...
2014-04-06 20:25:20 +03:00
// we must destroy our static data container!
2003-10-15 09:07:51 +00:00
if ( m_nRefCount < = 0 )
{
delete m_pDataContainer ;
m_pDataContainer = NULL ;
}
}
// public method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
void SvtCompatibilityOptions : : Clear ( )
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
m_pDataContainer - > Clear ( ) ;
}
2014-03-14 15:14:28 +02:00
void SvtCompatibilityOptions : : SetDefault ( const OUString & sName , bool bValue )
2010-09-14 17:21:03 +02:00
{
m_pDataContainer - > SetDefault ( sName , bValue ) ;
}
2003-10-15 09:07:51 +00:00
// public method
2014-02-25 22:46:10 +01:00
2013-04-07 12:06:47 +02:00
void SvtCompatibilityOptions : : AppendItem ( const OUString & sName ,
const OUString & sModule ,
2004-02-26 16:06:12 +00:00
bool bUsePrtMetrics ,
bool bAddSpacing ,
bool bAddSpacingAtPages ,
bool bUseOurTabStops ,
bool bNoExtLeading ,
2004-03-23 10:31:47 +00:00
bool bUseLineSpacing ,
2004-03-31 14:14:37 +00:00
bool bAddTableSpacing ,
2004-05-11 10:31:21 +00:00
bool bUseObjPos ,
2004-08-02 12:54:02 +00:00
bool bUseOurTextWrapping ,
2007-07-10 14:15:59 +00:00
bool bConsiderWrappingStyle ,
bool bExpandWordSpace )
2004-02-26 16:06:12 +00:00
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
m_pDataContainer - > AppendItem (
2004-03-31 14:14:37 +00:00
sName , sModule , bUsePrtMetrics , bAddSpacing ,
bAddSpacingAtPages , bUseOurTabStops , bNoExtLeading ,
2007-07-10 14:15:59 +00:00
bUseLineSpacing , bAddTableSpacing , bUseObjPos ,
bUseOurTextWrapping , bConsiderWrappingStyle , bExpandWordSpace ) ;
2004-02-26 16:06:12 +00:00
}
bool SvtCompatibilityOptions : : IsUsePrtDevice ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsUsePrtDevice ( ) ;
}
bool SvtCompatibilityOptions : : IsAddSpacing ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsAddSpacing ( ) ;
}
bool SvtCompatibilityOptions : : IsAddSpacingAtPages ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsAddSpacingAtPages ( ) ;
}
bool SvtCompatibilityOptions : : IsUseOurTabStops ( ) const
2003-10-15 09:07:51 +00:00
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2004-02-26 16:06:12 +00:00
return m_pDataContainer - > IsUseOurTabStops ( ) ;
}
bool SvtCompatibilityOptions : : IsNoExtLeading ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsNoExtLeading ( ) ;
}
bool SvtCompatibilityOptions : : IsUseLineSpacing ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsUseLineSpacing ( ) ;
2003-10-15 09:07:51 +00:00
}
2004-03-23 10:31:47 +00:00
bool SvtCompatibilityOptions : : IsAddTableSpacing ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsAddTableSpacing ( ) ;
}
2004-03-31 14:14:37 +00:00
bool SvtCompatibilityOptions : : IsUseObjectPositioning ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsUseObjPos ( ) ;
}
2004-05-11 10:31:21 +00:00
bool SvtCompatibilityOptions : : IsUseOurTextWrapping ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsUseOurTextWrapping ( ) ;
}
2004-08-02 12:54:02 +00:00
bool SvtCompatibilityOptions : : IsConsiderWrappingStyle ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsConsiderWrappingStyle ( ) ;
}
2007-07-10 14:15:59 +00:00
bool SvtCompatibilityOptions : : IsExpandWordSpace ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsExpandWordSpace ( ) ;
}
2003-10-15 09:07:51 +00:00
Sequence < Sequence < PropertyValue > > SvtCompatibilityOptions : : GetList ( ) const
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetList ( ) ;
}
2011-04-03 21:34:16 +01:00
namespace
{
class theCompatibilityOptionsMutex : public rtl : : Static < osl : : Mutex , theCompatibilityOptionsMutex > { } ;
}
2003-10-15 09:07:51 +00:00
// private method
2014-02-25 22:46:10 +01:00
2003-10-15 09:07:51 +00:00
Mutex & SvtCompatibilityOptions : : GetOwnStaticMutex ( )
{
2011-04-03 21:34:16 +01:00
return theCompatibilityOptionsMutex : : get ( ) ;
2003-10-15 09:07:51 +00:00
}
2010-10-14 08:27:31 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */