1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: compatibility.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <svtools/compatibility.hxx>
39 #include <unotools/configmgr.hxx>
40 #include <unotools/configitem.hxx>
41 #include <tools/debug.hxx>
42 #include <com/sun/star/uno/Any.hxx>
43 #include <com/sun/star/uno/Sequence.hxx>
45 #ifndef __SGI_STL_VECTOR
49 #include <itemholder1.hxx>
53 //_________________________________________________________________________________________________________________
55 //_________________________________________________________________________________________________________________
57 using namespace ::std
;
58 using namespace ::utl
;
59 using namespace ::rtl
;
60 using namespace ::osl
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
68 #define ROOTNODE_OPTIONS OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Compatibility/" ) )
69 #define PATHDELIMITER OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) )
70 #define SETNODE_ALLFILEFORMATS OUString( RTL_CONSTASCII_USTRINGPARAM( "AllFileFormats" ) )
72 #define PROPERTYNAME_NAME COMPATIBILITY_PROPERTYNAME_NAME
73 #define PROPERTYNAME_MODULE COMPATIBILITY_PROPERTYNAME_MODULE
74 #define PROPERTYNAME_USEPRTMETRICS COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
75 #define PROPERTYNAME_ADDSPACING COMPATIBILITY_PROPERTYNAME_ADDSPACING
76 #define PROPERTYNAME_ADDSPACINGATPAGES COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
77 #define PROPERTYNAME_USEOURTABSTOPS COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
78 #define PROPERTYNAME_NOEXTLEADING COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
79 #define PROPERTYNAME_USELINESPACING COMPATIBILITY_PROPERTYNAME_USELINESPACING
80 #define PROPERTYNAME_ADDTABLESPACING COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
81 #define PROPERTYNAME_USEOBJPOS COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
82 #define PROPERTYNAME_USEOURTEXTWRAP COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
83 #define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
84 #define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
86 #define PROPERTYCOUNT 13
89 #define OFFSET_MODULE 1
90 #define OFFSET_USEPRTMETRICS 2
91 #define OFFSET_ADDSPACING 3
92 #define OFFSET_ADDSPACINGATPAGES 4
93 #define OFFSET_USEOURTABSTOPS 5
94 #define OFFSET_NOEXTLEADING 6
95 #define OFFSET_USELINESPACING 7
96 #define OFFSET_ADDTABLESPACING 8
97 #define OFFSET_USEOBJPOS 9
98 #define OFFSET_USEOURTEXTWRAPPING 10
99 #define OFFSET_CONSIDERWRAPPINGSTYLE 11
100 #define OFFSET_EXPANDWORDSPACE 12
102 //_________________________________________________________________________________________________________________
103 // private declarations!
104 //_________________________________________________________________________________________________________________
106 /*-****************************************************************************************************************
107 @descr struct to hold information about one compatibility entry
108 ****************************************************************************************************************-*/
109 struct SvtCompatibilityEntry
112 SvtCompatibilityEntry() :
113 bUsePrtMetrics( false ), bAddSpacing( false ),
114 bAddSpacingAtPages( false ), bUseOurTabStops( false ),
115 bNoExtLeading( false ), bUseLineSpacing( false ),
116 bAddTableSpacing( false ), bUseObjPos( false ),
117 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
118 bExpandWordSpace( true ) {}
119 SvtCompatibilityEntry(
120 const OUString
& _rName
, const OUString
& _rNewModule
) :
121 sName( _rName
), sModule( _rNewModule
),
122 bUsePrtMetrics( false ), bAddSpacing( false ),
123 bAddSpacingAtPages( false ), bUseOurTabStops( false ),
124 bNoExtLeading( false ), bUseLineSpacing( false ),
125 bAddTableSpacing( false ), bUseObjPos( false ),
126 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
127 bExpandWordSpace( true ) {}
129 inline void SetUsePrtMetrics( bool _bSet
) { bUsePrtMetrics
= _bSet
; }
130 inline void SetAddSpacing( bool _bSet
) { bAddSpacing
= _bSet
; }
131 inline void SetAddSpacingAtPages( bool _bSet
) { bAddSpacingAtPages
= _bSet
; }
132 inline void SetUseOurTabStops( bool _bSet
) { bUseOurTabStops
= _bSet
; }
133 inline void SetNoExtLeading( bool _bSet
) { bNoExtLeading
= _bSet
; }
134 inline void SetUseLineSpacing( bool _bSet
) { bUseLineSpacing
= _bSet
; }
135 inline void SetAddTableSpacing( bool _bSet
) { bAddTableSpacing
= _bSet
; }
136 inline void SetUseObjPos( bool _bSet
) { bUseObjPos
= _bSet
; }
137 inline void SetUseOurTextWrapping( bool _bSet
) { bUseOurTextWrapping
= _bSet
; }
138 inline void SetConsiderWrappingStyle( bool _bSet
) { bConsiderWrappingStyle
= _bSet
; }
139 inline void SetExpandWordSpace( bool _bSet
) { bExpandWordSpace
= _bSet
; }
146 bool bAddSpacingAtPages
;
147 bool bUseOurTabStops
;
149 bool bUseLineSpacing
;
150 bool bAddTableSpacing
;
152 bool bUseOurTextWrapping
;
153 bool bConsiderWrappingStyle
;
154 bool bExpandWordSpace
;
157 /*-****************************************************************************************************************
158 @descr support simple menu structures and operations on it
159 ****************************************************************************************************************-*/
160 class SvtCompatibility
163 //---------------------------------------------------------------------------------------------------------
165 void AppendEntry( const SvtCompatibilityEntry
& rEntry
)
167 lEntries
.push_back( rEntry
);
170 //---------------------------------------------------------------------------------------------------------
171 // the only way to free memory!
177 //---------------------------------------------------------------------------------------------------------
178 // convert internal list to external format
179 Sequence
< Sequence
< PropertyValue
> > GetList() const
181 sal_Int32 nCount
= (sal_Int32
)lEntries
.size();
183 Sequence
< PropertyValue
> lProperties( PROPERTYCOUNT
);
184 Sequence
< Sequence
< PropertyValue
> > lResult( nCount
);
185 const vector
< SvtCompatibilityEntry
>* pList
= &lEntries
;
187 lProperties
[ OFFSET_NAME
].Name
= PROPERTYNAME_NAME
;
188 lProperties
[ OFFSET_MODULE
].Name
= PROPERTYNAME_MODULE
;
189 lProperties
[ OFFSET_USEPRTMETRICS
].Name
= PROPERTYNAME_USEPRTMETRICS
;
190 lProperties
[ OFFSET_ADDSPACING
].Name
= PROPERTYNAME_ADDSPACING
;
191 lProperties
[ OFFSET_ADDSPACINGATPAGES
].Name
= PROPERTYNAME_ADDSPACINGATPAGES
;
192 lProperties
[ OFFSET_USEOURTABSTOPS
].Name
= PROPERTYNAME_USEOURTABSTOPS
;
193 lProperties
[ OFFSET_NOEXTLEADING
].Name
= PROPERTYNAME_NOEXTLEADING
;
194 lProperties
[ OFFSET_USELINESPACING
].Name
= PROPERTYNAME_USELINESPACING
;
195 lProperties
[ OFFSET_ADDTABLESPACING
].Name
= PROPERTYNAME_ADDTABLESPACING
;
196 lProperties
[ OFFSET_USEOBJPOS
].Name
= PROPERTYNAME_USEOBJPOS
;
197 lProperties
[ OFFSET_USEOURTEXTWRAPPING
].Name
= PROPERTYNAME_USEOURTEXTWRAP
;
198 lProperties
[ OFFSET_CONSIDERWRAPPINGSTYLE
].Name
= PROPERTYNAME_CONSIDERWRAPSTYLE
;
199 lProperties
[ OFFSET_EXPANDWORDSPACE
].Name
= PROPERTYNAME_EXPANDWORDSPACE
;
201 for ( vector
< SvtCompatibilityEntry
>::const_iterator pItem
= pList
->begin();
202 pItem
!= pList
->end(); ++pItem
)
204 lProperties
[ OFFSET_NAME
].Value
<<= pItem
->sName
;
205 lProperties
[ OFFSET_MODULE
].Value
<<= pItem
->sModule
;
206 lProperties
[ OFFSET_USEPRTMETRICS
].Value
<<= pItem
->bUsePrtMetrics
;
207 lProperties
[ OFFSET_ADDSPACING
].Value
<<= pItem
->bAddSpacing
;
208 lProperties
[ OFFSET_ADDSPACINGATPAGES
].Value
<<= pItem
->bAddSpacingAtPages
;
209 lProperties
[ OFFSET_USEOURTABSTOPS
].Value
<<= pItem
->bUseOurTabStops
;
210 lProperties
[ OFFSET_NOEXTLEADING
].Value
<<= pItem
->bNoExtLeading
;
211 lProperties
[ OFFSET_USELINESPACING
].Value
<<= pItem
->bUseLineSpacing
;
212 lProperties
[ OFFSET_ADDTABLESPACING
].Value
<<= pItem
->bAddTableSpacing
;
213 lProperties
[ OFFSET_USEOBJPOS
].Value
<<= pItem
->bUseObjPos
;
214 lProperties
[ OFFSET_USEOURTEXTWRAPPING
].Value
<<= pItem
->bUseOurTextWrapping
;
215 lProperties
[ OFFSET_CONSIDERWRAPPINGSTYLE
].Value
<<= pItem
->bConsiderWrappingStyle
;
216 lProperties
[ OFFSET_EXPANDWORDSPACE
].Value
<<= pItem
->bExpandWordSpace
;
217 lResult
[ nStep
] = lProperties
;
226 return lEntries
.size();
229 const SvtCompatibilityEntry
& operator[]( int i
)
235 vector
< SvtCompatibilityEntry
> lEntries
;
238 class SvtCompatibilityOptions_Impl
: public ConfigItem
240 //-------------------------------------------------------------------------------------------------------------
242 //-------------------------------------------------------------------------------------------------------------
246 //---------------------------------------------------------------------------------------------------------
247 // constructor / destructor
248 //---------------------------------------------------------------------------------------------------------
250 SvtCompatibilityOptions_Impl();
251 ~SvtCompatibilityOptions_Impl();
253 //---------------------------------------------------------------------------------------------------------
254 // overloaded methods of baseclass
255 //---------------------------------------------------------------------------------------------------------
257 /*-****************************************************************************************************//**
258 @short called for notify of configmanager
259 @descr These method is called from the ConfigManager before application ends or from the
260 PropertyChangeListener if the sub tree broadcasts changes. You must update your
263 @seealso baseclass ConfigItem
265 @param "lPropertyNames" is the list of properties which should be updated.
269 *//*-*****************************************************************************************************/
271 virtual void Notify( const Sequence
< OUString
>& lPropertyNames
);
273 /*-****************************************************************************************************//**
274 @short write changes to configuration
275 @descr These method writes the changed values into the sub tree
276 and should always called in our destructor to guarantee consistency of config data.
278 @seealso baseclass ConfigItem
284 *//*-*****************************************************************************************************/
286 virtual void Commit();
288 //---------------------------------------------------------------------------------------------------------
290 //---------------------------------------------------------------------------------------------------------
292 /*-****************************************************************************************************//**
293 @short base implementation of public interface for "SvtCompatibilityOptions"!
294 @descr These class is used as static member of "SvtCompatibilityOptions" ...
295 => The code exist only for one time and isn't duplicated for every instance!
303 *//*-*****************************************************************************************************/
306 Sequence
< Sequence
< PropertyValue
> > GetList() const;
307 void AppendItem( const ::rtl::OUString
& _sName
,
308 const ::rtl::OUString
& _sModule
,
309 bool _bUsePrtMetrics
,
311 bool _bAddSpacingAtPages
,
312 bool _bUseOurTabStops
,
314 bool _bUseLineSpacing
,
315 bool _bAddTableSpacing
,
317 bool _bUseOurTextWrapping
,
318 bool _bConsiderWrappingStyle
,
319 bool _bExpandWordSpace
);
321 inline bool IsUsePrtDevice() const { return m_aDefOptions
.bUsePrtMetrics
; }
322 inline bool IsAddSpacing() const { return m_aDefOptions
.bAddSpacing
; }
323 inline bool IsAddSpacingAtPages() const { return m_aDefOptions
.bAddSpacingAtPages
; }
324 inline bool IsUseOurTabStops() const { return m_aDefOptions
.bUseOurTabStops
; }
325 inline bool IsNoExtLeading() const { return m_aDefOptions
.bNoExtLeading
; }
326 inline bool IsUseLineSpacing() const { return m_aDefOptions
.bUseLineSpacing
; }
327 inline bool IsAddTableSpacing() const { return m_aDefOptions
.bAddTableSpacing
; }
328 inline bool IsUseObjPos() const { return m_aDefOptions
.bUseObjPos
; }
329 inline bool IsUseOurTextWrapping() const { return m_aDefOptions
.bUseOurTextWrapping
; }
330 inline bool IsConsiderWrappingStyle() const { return m_aDefOptions
.bConsiderWrappingStyle
; }
331 inline bool IsExpandWordSpace() const { return m_aDefOptions
.bExpandWordSpace
; }
333 //-------------------------------------------------------------------------------------------------------------
335 //-------------------------------------------------------------------------------------------------------------
339 /*-****************************************************************************************************//**
340 @short return list of key names of our configuration management which represent one module tree
341 @descr These methods return the current list of key names! We need it to get needed values from our
342 configuration management and support dynamical menu item lists!
347 @return A list of configuration key names is returned.
350 *//*-*****************************************************************************************************/
352 Sequence
< OUString
> impl_GetPropertyNames( Sequence
< OUString
>& rItems
);
354 /*-****************************************************************************************************//**
355 @short expand the list for all well known properties to destination
359 @seealso method impl_GetPropertyNames()
361 @param "lSource" , original list
362 @param "lDestination" , destination of operation
363 @return A list of configuration key names is returned.
366 *//*-*****************************************************************************************************/
368 void impl_ExpandPropertyNames( const Sequence
< OUString
>& lSource
,
369 Sequence
< OUString
>& lDestination
);
371 //-------------------------------------------------------------------------------------------------------------
373 //-------------------------------------------------------------------------------------------------------------
377 SvtCompatibility m_aOptions
;
378 SvtCompatibilityEntry m_aDefOptions
;
381 //_________________________________________________________________________________________________________________
383 //_________________________________________________________________________________________________________________
385 //*****************************************************************************************************************
387 //*****************************************************************************************************************
388 SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
389 // Init baseclasses first
390 : ConfigItem( ROOTNODE_OPTIONS
)
391 // Init member then...
393 // Get names and values of all accessable menu entries and fill internal structures.
394 // See impl_GetPropertyNames() for further informations.
395 Sequence
< OUString
> lNodes
;
396 Sequence
< OUString
> lNames
= impl_GetPropertyNames( lNodes
);
397 sal_uInt32 nCount
= lNodes
.getLength();
398 Sequence
< Any
> lValues
= GetProperties( lNames
);
400 // Safe impossible cases.
401 // We need values from ALL configuration keys.
402 // Follow assignment use order of values in relation to our list of key names!
403 DBG_ASSERT( !( lNames
.getLength()!=lValues
.getLength() ), "SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()\nI miss some values of configuration keys!\n" );
405 SvtCompatibilityEntry aItem
;
406 sal_uInt32 nItem
= 0;
407 sal_uInt32 nPosition
= 0;
409 // Get names/values for new menu.
410 // 4 subkeys for every item!
411 bool bDefaultFound
= false;
412 for( nItem
= 0; nItem
< nCount
; ++nItem
)
414 aItem
.sName
= lNodes
[ nItem
];
415 lValues
[ nPosition
++ ] >>= aItem
.sModule
;
416 lValues
[ nPosition
++ ] >>= aItem
.bUsePrtMetrics
;
417 lValues
[ nPosition
++ ] >>= aItem
.bAddSpacing
;
418 lValues
[ nPosition
++ ] >>= aItem
.bAddSpacingAtPages
;
419 lValues
[ nPosition
++ ] >>= aItem
.bUseOurTabStops
;
420 lValues
[ nPosition
++ ] >>= aItem
.bNoExtLeading
;
421 lValues
[ nPosition
++ ] >>= aItem
.bUseLineSpacing
;
422 lValues
[ nPosition
++ ] >>= aItem
.bAddTableSpacing
;
423 lValues
[ nPosition
++ ] >>= aItem
.bUseObjPos
;
424 lValues
[ nPosition
++ ] >>= aItem
.bUseOurTextWrapping
;
425 lValues
[ nPosition
++ ] >>= aItem
.bConsiderWrappingStyle
;
426 lValues
[ nPosition
++ ] >>= aItem
.bExpandWordSpace
;
427 m_aOptions
.AppendEntry( aItem
);
429 if ( !bDefaultFound
&& aItem
.sName
.equals( COMPATIBILITY_DEFAULT_NAME
) != sal_False
)
431 m_aDefOptions
= aItem
;
432 bDefaultFound
= true;
437 //*****************************************************************************************************************
439 //*****************************************************************************************************************
440 SvtCompatibilityOptions_Impl::~SvtCompatibilityOptions_Impl()
442 // We must save our current values .. if user forget it!
443 if( IsModified() == sal_True
)
449 //*****************************************************************************************************************
451 //*****************************************************************************************************************
452 void SvtCompatibilityOptions_Impl::Notify( const Sequence
< OUString
>& )
454 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" );
457 //*****************************************************************************************************************
459 //*****************************************************************************************************************
460 void SvtCompatibilityOptions_Impl::Commit()
462 // Write all properties!
463 // Delete complete set first.
464 ClearNodeSet( SETNODE_ALLFILEFORMATS
);
466 SvtCompatibilityEntry aItem
;
468 Sequence
< PropertyValue
> lPropertyValues( PROPERTYCOUNT
- 1 );
469 sal_uInt32 nItem
= 0;
470 sal_uInt32 nNewCount
= m_aOptions
.size();
471 for( nItem
= 0; nItem
< nNewCount
; ++nItem
)
473 aItem
= m_aOptions
[ nItem
];
474 sNode
= SETNODE_ALLFILEFORMATS
+ PATHDELIMITER
+ aItem
.sName
+ PATHDELIMITER
;
476 lPropertyValues
[ OFFSET_MODULE
- 1 ].Name
= sNode
+ PROPERTYNAME_MODULE
;
477 lPropertyValues
[ OFFSET_USEPRTMETRICS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEPRTMETRICS
;
478 lPropertyValues
[ OFFSET_ADDSPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDSPACING
;
479 lPropertyValues
[ OFFSET_ADDSPACINGATPAGES
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDSPACINGATPAGES
;
480 lPropertyValues
[ OFFSET_USEOURTABSTOPS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOURTABSTOPS
;
481 lPropertyValues
[ OFFSET_NOEXTLEADING
- 1 ].Name
= sNode
+ PROPERTYNAME_NOEXTLEADING
;
482 lPropertyValues
[ OFFSET_USELINESPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_USELINESPACING
;
483 lPropertyValues
[ OFFSET_ADDTABLESPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDTABLESPACING
;
484 lPropertyValues
[ OFFSET_USEOBJPOS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOBJPOS
;
485 lPropertyValues
[ OFFSET_USEOURTEXTWRAPPING
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOURTEXTWRAP
;
486 lPropertyValues
[ OFFSET_CONSIDERWRAPPINGSTYLE
- 1 ].Name
= sNode
+ PROPERTYNAME_CONSIDERWRAPSTYLE
;
487 lPropertyValues
[ OFFSET_EXPANDWORDSPACE
- 1 ].Name
= sNode
+ PROPERTYNAME_EXPANDWORDSPACE
;
489 lPropertyValues
[ OFFSET_MODULE
- 1 ].Value
<<= aItem
.sModule
;
490 lPropertyValues
[ OFFSET_USEPRTMETRICS
- 1 ].Value
<<= aItem
.bUsePrtMetrics
;
491 lPropertyValues
[ OFFSET_ADDSPACING
- 1 ].Value
<<= aItem
.bAddSpacing
;
492 lPropertyValues
[ OFFSET_ADDSPACINGATPAGES
- 1 ].Value
<<= aItem
.bAddSpacingAtPages
;
493 lPropertyValues
[ OFFSET_USEOURTABSTOPS
- 1 ].Value
<<= aItem
.bUseOurTabStops
;
494 lPropertyValues
[ OFFSET_NOEXTLEADING
- 1 ].Value
<<= aItem
.bNoExtLeading
;
495 lPropertyValues
[ OFFSET_USELINESPACING
- 1 ].Value
<<= aItem
.bUseLineSpacing
;
496 lPropertyValues
[ OFFSET_ADDTABLESPACING
- 1 ].Value
<<= aItem
.bAddTableSpacing
;
497 lPropertyValues
[ OFFSET_USEOBJPOS
- 1 ].Value
<<= aItem
.bUseObjPos
;
498 lPropertyValues
[ OFFSET_USEOURTEXTWRAPPING
- 1 ].Value
<<= aItem
.bUseOurTextWrapping
;
499 lPropertyValues
[ OFFSET_CONSIDERWRAPPINGSTYLE
- 1 ].Value
<<= aItem
.bConsiderWrappingStyle
;
500 lPropertyValues
[ OFFSET_EXPANDWORDSPACE
- 1 ].Value
<<= aItem
.bExpandWordSpace
;
502 SetSetProperties( SETNODE_ALLFILEFORMATS
, lPropertyValues
);
506 //*****************************************************************************************************************
508 //*****************************************************************************************************************
509 void SvtCompatibilityOptions_Impl::Clear()
515 //*****************************************************************************************************************
517 //*****************************************************************************************************************
518 Sequence
< Sequence
< PropertyValue
> > SvtCompatibilityOptions_Impl::GetList() const
520 Sequence
< Sequence
< PropertyValue
> > lReturn
;
521 lReturn
= m_aOptions
.GetList();
525 //*****************************************************************************************************************
527 //*****************************************************************************************************************
529 void SvtCompatibilityOptions_Impl::AppendItem( const ::rtl::OUString
& _sName
,
530 const ::rtl::OUString
& _sModule
,
531 bool _bUsePrtMetrics
,
533 bool _bAddSpacingAtPages
,
534 bool _bUseOurTabStops
,
536 bool _bUseLineSpacing
,
537 bool _bAddTableSpacing
,
539 bool _bUseOurTextWrapping
,
540 bool _bConsiderWrappingStyle
,
541 bool _bExpandWordSpace
)
543 SvtCompatibilityEntry
aItem( _sName
, _sModule
);
544 aItem
.SetUsePrtMetrics( _bUsePrtMetrics
);
545 aItem
.SetAddSpacing( _bAddSpacing
);
546 aItem
.SetAddSpacingAtPages( _bAddSpacingAtPages
);
547 aItem
.SetUseOurTabStops( _bUseOurTabStops
);
548 aItem
.SetNoExtLeading( _bNoExtLeading
);
549 aItem
.SetUseLineSpacing( _bUseLineSpacing
);
550 aItem
.SetAddTableSpacing( _bAddTableSpacing
);
551 aItem
.SetUseObjPos( _bUseObjPos
);
552 aItem
.SetUseOurTextWrapping( _bUseOurTextWrapping
);
553 aItem
.SetConsiderWrappingStyle( _bConsiderWrappingStyle
);
554 aItem
.SetExpandWordSpace( _bExpandWordSpace
);
555 m_aOptions
.AppendEntry( aItem
);
557 // default item reset?
558 if ( _sName
.equals( COMPATIBILITY_DEFAULT_NAME
) != sal_False
)
559 m_aDefOptions
= aItem
;
564 //*****************************************************************************************************************
566 //*****************************************************************************************************************
567 Sequence
< OUString
> SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequence
< OUString
>& rItems
)
569 // First get ALL names of current existing list items in configuration!
570 rItems
= GetNodeNames( SETNODE_ALLFILEFORMATS
);
571 // expand list to result list ...
572 Sequence
< OUString
> lProperties( rItems
.getLength() * ( PROPERTYCOUNT
- 1 ) );
573 impl_ExpandPropertyNames( rItems
, lProperties
);
578 //*****************************************************************************************************************
580 //*****************************************************************************************************************
581 void SvtCompatibilityOptions_Impl::impl_ExpandPropertyNames(
582 const Sequence
< OUString
>& lSource
, Sequence
< OUString
>& lDestination
)
585 sal_Int32 nDestStep
= 0;
586 sal_Int32 nSourceCount
= lSource
.getLength();
587 // Copy entries to destination and expand every item with 2 supported sub properties.
588 for( sal_Int32 nSourceStep
= 0; nSourceStep
< nSourceCount
; ++nSourceStep
)
590 sFixPath
= SETNODE_ALLFILEFORMATS
;
591 sFixPath
+= PATHDELIMITER
;
592 sFixPath
+= lSource
[ nSourceStep
];
593 sFixPath
+= PATHDELIMITER
;
595 lDestination
[nDestStep
] = sFixPath
;
596 lDestination
[nDestStep
] += PROPERTYNAME_MODULE
;
598 lDestination
[nDestStep
] = sFixPath
;
599 lDestination
[nDestStep
] += PROPERTYNAME_USEPRTMETRICS
;
601 lDestination
[nDestStep
] = sFixPath
;
602 lDestination
[nDestStep
] += PROPERTYNAME_ADDSPACING
;
604 lDestination
[nDestStep
] = sFixPath
;
605 lDestination
[nDestStep
] += PROPERTYNAME_ADDSPACINGATPAGES
;
607 lDestination
[nDestStep
] = sFixPath
;
608 lDestination
[nDestStep
] += PROPERTYNAME_USEOURTABSTOPS
;
610 lDestination
[nDestStep
] = sFixPath
;
611 lDestination
[nDestStep
] += PROPERTYNAME_NOEXTLEADING
;
613 lDestination
[nDestStep
] = sFixPath
;
614 lDestination
[nDestStep
] += PROPERTYNAME_USELINESPACING
;
616 lDestination
[nDestStep
] = sFixPath
;
617 lDestination
[nDestStep
] += PROPERTYNAME_ADDTABLESPACING
;
619 lDestination
[nDestStep
] = sFixPath
;
620 lDestination
[nDestStep
] += PROPERTYNAME_USEOBJPOS
;
622 lDestination
[nDestStep
] = sFixPath
;
623 lDestination
[nDestStep
] += PROPERTYNAME_USEOURTEXTWRAP
;
625 lDestination
[nDestStep
] = sFixPath
;
626 lDestination
[nDestStep
] += PROPERTYNAME_CONSIDERWRAPSTYLE
;
628 lDestination
[nDestStep
] = sFixPath
;
629 lDestination
[nDestStep
] += PROPERTYNAME_EXPANDWORDSPACE
;
634 //*****************************************************************************************************************
635 // initialize static member
636 // DON'T DO IT IN YOUR HEADER!
637 // see definition for further informations
638 //*****************************************************************************************************************
639 SvtCompatibilityOptions_Impl
* SvtCompatibilityOptions::m_pDataContainer
= NULL
;
640 sal_Int32
SvtCompatibilityOptions::m_nRefCount
= 0;
642 //*****************************************************************************************************************
644 //*****************************************************************************************************************
645 SvtCompatibilityOptions::SvtCompatibilityOptions()
647 // Global access, must be guarded (multithreading!).
648 MutexGuard
aGuard( GetOwnStaticMutex() );
649 // Increase ouer refcount ...
651 // ... and initialize ouer data container only if it not already exist!
652 if( m_pDataContainer
== NULL
)
654 m_pDataContainer
= new SvtCompatibilityOptions_Impl
;
655 ItemHolder1::holdConfigItem(E_COMPATIBILITY
);
659 //*****************************************************************************************************************
661 //*****************************************************************************************************************
662 SvtCompatibilityOptions::~SvtCompatibilityOptions()
664 // Global access, must be guarded (multithreading!)
665 MutexGuard
aGuard( GetOwnStaticMutex() );
666 // Decrease ouer refcount.
668 // If last instance was deleted ...
669 // we must destroy ouer static data container!
670 if( m_nRefCount
<= 0 )
672 delete m_pDataContainer
;
673 m_pDataContainer
= NULL
;
677 //*****************************************************************************************************************
679 //*****************************************************************************************************************
680 void SvtCompatibilityOptions::Clear()
682 MutexGuard
aGuard( GetOwnStaticMutex() );
683 m_pDataContainer
->Clear();
686 //*****************************************************************************************************************
688 //*****************************************************************************************************************
689 void SvtCompatibilityOptions::AppendItem( const ::rtl::OUString
& sName
,
690 const ::rtl::OUString
& sModule
,
693 bool bAddSpacingAtPages
,
694 bool bUseOurTabStops
,
696 bool bUseLineSpacing
,
697 bool bAddTableSpacing
,
699 bool bUseOurTextWrapping
,
700 bool bConsiderWrappingStyle
,
701 bool bExpandWordSpace
)
703 MutexGuard
aGuard( GetOwnStaticMutex() );
704 m_pDataContainer
->AppendItem(
705 sName
, sModule
, bUsePrtMetrics
, bAddSpacing
,
706 bAddSpacingAtPages
, bUseOurTabStops
, bNoExtLeading
,
707 bUseLineSpacing
, bAddTableSpacing
, bUseObjPos
,
708 bUseOurTextWrapping
, bConsiderWrappingStyle
, bExpandWordSpace
);
711 bool SvtCompatibilityOptions::IsUsePrtDevice() const
713 MutexGuard
aGuard( GetOwnStaticMutex() );
714 return m_pDataContainer
->IsUsePrtDevice();
717 bool SvtCompatibilityOptions::IsAddSpacing() const
719 MutexGuard
aGuard( GetOwnStaticMutex() );
720 return m_pDataContainer
->IsAddSpacing();
723 bool SvtCompatibilityOptions::IsAddSpacingAtPages() const
725 MutexGuard
aGuard( GetOwnStaticMutex() );
726 return m_pDataContainer
->IsAddSpacingAtPages();
729 bool SvtCompatibilityOptions::IsUseOurTabStops() const
731 MutexGuard
aGuard( GetOwnStaticMutex() );
732 return m_pDataContainer
->IsUseOurTabStops();
735 bool SvtCompatibilityOptions::IsNoExtLeading() const
737 MutexGuard
aGuard( GetOwnStaticMutex() );
738 return m_pDataContainer
->IsNoExtLeading();
741 bool SvtCompatibilityOptions::IsUseLineSpacing() const
743 MutexGuard
aGuard( GetOwnStaticMutex() );
744 return m_pDataContainer
->IsUseLineSpacing();
747 bool SvtCompatibilityOptions::IsAddTableSpacing() const
749 MutexGuard
aGuard( GetOwnStaticMutex() );
750 return m_pDataContainer
->IsAddTableSpacing();
753 bool SvtCompatibilityOptions::IsUseObjectPositioning() const
755 MutexGuard
aGuard( GetOwnStaticMutex() );
756 return m_pDataContainer
->IsUseObjPos();
759 bool SvtCompatibilityOptions::IsUseOurTextWrapping() const
761 MutexGuard
aGuard( GetOwnStaticMutex() );
762 return m_pDataContainer
->IsUseOurTextWrapping();
765 bool SvtCompatibilityOptions::IsConsiderWrappingStyle() const
767 MutexGuard
aGuard( GetOwnStaticMutex() );
768 return m_pDataContainer
->IsConsiderWrappingStyle();
771 bool SvtCompatibilityOptions::IsExpandWordSpace() const
773 MutexGuard
aGuard( GetOwnStaticMutex() );
774 return m_pDataContainer
->IsExpandWordSpace();
777 Sequence
< Sequence
< PropertyValue
> > SvtCompatibilityOptions::GetList() const
779 MutexGuard
aGuard( GetOwnStaticMutex() );
780 return m_pDataContainer
->GetList();
783 //*****************************************************************************************************************
785 //*****************************************************************************************************************
786 Mutex
& SvtCompatibilityOptions::GetOwnStaticMutex()
788 // Initialize static mutex only for one time!
789 static Mutex
* pMutex
= NULL
;
790 // If these method first called (Mutex not already exist!) ...
793 // ... we must create a new one. Protect follow code with the global mutex -
794 // It must be - we create a static variable!
795 MutexGuard
aGuard( Mutex::getGlobalMutex() );
796 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
799 // Create the new mutex and set it for return on static variable.
804 // Return new created or already existing mutex object.