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