1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unotools/compatibility.hxx>
21 #include <unotools/configmgr.hxx>
22 #include <unotools/configitem.hxx>
23 #include <unotools/syslocale.hxx>
24 #include <tools/debug.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
30 #include <itemholder1.hxx>
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 using namespace ::std
;
39 using namespace ::utl
;
40 using namespace ::rtl
;
41 using namespace ::osl
;
42 using namespace ::com::sun::star::uno
;
43 using namespace ::com::sun::star::beans
;
45 #define ROOTNODE_OPTIONS OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Compatibility/" ) )
46 #define PATHDELIMITER OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) )
47 #define SETNODE_ALLFILEFORMATS OUString( RTL_CONSTASCII_USTRINGPARAM( "AllFileFormats" ) )
49 #define PROPERTYNAME_NAME COMPATIBILITY_PROPERTYNAME_NAME
50 #define PROPERTYNAME_MODULE COMPATIBILITY_PROPERTYNAME_MODULE
51 #define PROPERTYNAME_USEPRTMETRICS COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
52 #define PROPERTYNAME_ADDSPACING COMPATIBILITY_PROPERTYNAME_ADDSPACING
53 #define PROPERTYNAME_ADDSPACINGATPAGES COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
54 #define PROPERTYNAME_USEOURTABSTOPS COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
55 #define PROPERTYNAME_NOEXTLEADING COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
56 #define PROPERTYNAME_USELINESPACING COMPATIBILITY_PROPERTYNAME_USELINESPACING
57 #define PROPERTYNAME_ADDTABLESPACING COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
58 #define PROPERTYNAME_USEOBJPOS COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
59 #define PROPERTYNAME_USEOURTEXTWRAP COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
60 #define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
61 #define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
63 #define PROPERTYCOUNT 13
66 #define OFFSET_MODULE 1
67 #define OFFSET_USEPRTMETRICS 2
68 #define OFFSET_ADDSPACING 3
69 #define OFFSET_ADDSPACINGATPAGES 4
70 #define OFFSET_USEOURTABSTOPS 5
71 #define OFFSET_NOEXTLEADING 6
72 #define OFFSET_USELINESPACING 7
73 #define OFFSET_ADDTABLESPACING 8
74 #define OFFSET_USEOBJPOS 9
75 #define OFFSET_USEOURTEXTWRAPPING 10
76 #define OFFSET_CONSIDERWRAPPINGSTYLE 11
77 #define OFFSET_EXPANDWORDSPACE 12
79 //_________________________________________________________________________________________________________________
80 // private declarations!
81 //_________________________________________________________________________________________________________________
83 /*-****************************************************************************************************************
84 @descr struct to hold information about one compatibility entry
85 ****************************************************************************************************************-*/
86 struct SvtCompatibilityEntry
89 SvtCompatibilityEntry() :
90 bUsePrtMetrics( false ), bAddSpacing( false ),
91 bAddSpacingAtPages( false ), bUseOurTabStops( false ),
92 bNoExtLeading( false ), bUseLineSpacing( false ),
93 bAddTableSpacing( false ), bUseObjPos( false ),
94 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
95 bExpandWordSpace( true ) {}
96 SvtCompatibilityEntry(
97 const OUString
& _rName
, const OUString
& _rNewModule
) :
98 sName( _rName
), sModule( _rNewModule
),
99 bUsePrtMetrics( false ), bAddSpacing( false ),
100 bAddSpacingAtPages( false ), bUseOurTabStops( false ),
101 bNoExtLeading( false ), bUseLineSpacing( false ),
102 bAddTableSpacing( false ), bUseObjPos( false ),
103 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
104 bExpandWordSpace( true ) {}
106 inline void SetUsePrtMetrics( bool _bSet
) { bUsePrtMetrics
= _bSet
; }
107 inline void SetAddSpacing( bool _bSet
) { bAddSpacing
= _bSet
; }
108 inline void SetAddSpacingAtPages( bool _bSet
) { bAddSpacingAtPages
= _bSet
; }
109 inline void SetUseOurTabStops( bool _bSet
) { bUseOurTabStops
= _bSet
; }
110 inline void SetNoExtLeading( bool _bSet
) { bNoExtLeading
= _bSet
; }
111 inline void SetUseLineSpacing( bool _bSet
) { bUseLineSpacing
= _bSet
; }
112 inline void SetAddTableSpacing( bool _bSet
) { bAddTableSpacing
= _bSet
; }
113 inline void SetUseObjPos( bool _bSet
) { bUseObjPos
= _bSet
; }
114 inline void SetUseOurTextWrapping( bool _bSet
) { bUseOurTextWrapping
= _bSet
; }
115 inline void SetConsiderWrappingStyle( bool _bSet
) { bConsiderWrappingStyle
= _bSet
; }
116 inline void SetExpandWordSpace( bool _bSet
) { bExpandWordSpace
= _bSet
; }
123 bool bAddSpacingAtPages
;
124 bool bUseOurTabStops
;
126 bool bUseLineSpacing
;
127 bool bAddTableSpacing
;
129 bool bUseOurTextWrapping
;
130 bool bConsiderWrappingStyle
;
131 bool bExpandWordSpace
;
134 /*-****************************************************************************************************************
135 @descr support simple menu structures and operations on it
136 ****************************************************************************************************************-*/
137 class SvtCompatibility
140 //---------------------------------------------------------------------------------------------------------
142 void AppendEntry( const SvtCompatibilityEntry
& rEntry
)
144 lEntries
.push_back( rEntry
);
147 //---------------------------------------------------------------------------------------------------------
148 // the only way to free memory!
154 //---------------------------------------------------------------------------------------------------------
155 // convert internal list to external format
156 Sequence
< Sequence
< PropertyValue
> > GetList() const
158 sal_Int32 nCount
= (sal_Int32
)lEntries
.size();
160 Sequence
< PropertyValue
> lProperties( PROPERTYCOUNT
);
161 Sequence
< Sequence
< PropertyValue
> > lResult( nCount
);
162 const vector
< SvtCompatibilityEntry
>* pList
= &lEntries
;
164 lProperties
[ OFFSET_NAME
].Name
= PROPERTYNAME_NAME
;
165 lProperties
[ OFFSET_MODULE
].Name
= PROPERTYNAME_MODULE
;
166 lProperties
[ OFFSET_USEPRTMETRICS
].Name
= PROPERTYNAME_USEPRTMETRICS
;
167 lProperties
[ OFFSET_ADDSPACING
].Name
= PROPERTYNAME_ADDSPACING
;
168 lProperties
[ OFFSET_ADDSPACINGATPAGES
].Name
= PROPERTYNAME_ADDSPACINGATPAGES
;
169 lProperties
[ OFFSET_USEOURTABSTOPS
].Name
= PROPERTYNAME_USEOURTABSTOPS
;
170 lProperties
[ OFFSET_NOEXTLEADING
].Name
= PROPERTYNAME_NOEXTLEADING
;
171 lProperties
[ OFFSET_USELINESPACING
].Name
= PROPERTYNAME_USELINESPACING
;
172 lProperties
[ OFFSET_ADDTABLESPACING
].Name
= PROPERTYNAME_ADDTABLESPACING
;
173 lProperties
[ OFFSET_USEOBJPOS
].Name
= PROPERTYNAME_USEOBJPOS
;
174 lProperties
[ OFFSET_USEOURTEXTWRAPPING
].Name
= PROPERTYNAME_USEOURTEXTWRAP
;
175 lProperties
[ OFFSET_CONSIDERWRAPPINGSTYLE
].Name
= PROPERTYNAME_CONSIDERWRAPSTYLE
;
176 lProperties
[ OFFSET_EXPANDWORDSPACE
].Name
= PROPERTYNAME_EXPANDWORDSPACE
;
178 for ( vector
< SvtCompatibilityEntry
>::const_iterator pItem
= pList
->begin();
179 pItem
!= pList
->end(); ++pItem
)
181 lProperties
[ OFFSET_NAME
].Value
<<= pItem
->sName
;
182 lProperties
[ OFFSET_MODULE
].Value
<<= pItem
->sModule
;
183 lProperties
[ OFFSET_USEPRTMETRICS
].Value
<<= pItem
->bUsePrtMetrics
;
184 lProperties
[ OFFSET_ADDSPACING
].Value
<<= pItem
->bAddSpacing
;
185 lProperties
[ OFFSET_ADDSPACINGATPAGES
].Value
<<= pItem
->bAddSpacingAtPages
;
186 lProperties
[ OFFSET_USEOURTABSTOPS
].Value
<<= pItem
->bUseOurTabStops
;
187 lProperties
[ OFFSET_NOEXTLEADING
].Value
<<= pItem
->bNoExtLeading
;
188 lProperties
[ OFFSET_USELINESPACING
].Value
<<= pItem
->bUseLineSpacing
;
189 lProperties
[ OFFSET_ADDTABLESPACING
].Value
<<= pItem
->bAddTableSpacing
;
190 lProperties
[ OFFSET_USEOBJPOS
].Value
<<= pItem
->bUseObjPos
;
191 lProperties
[ OFFSET_USEOURTEXTWRAPPING
].Value
<<= pItem
->bUseOurTextWrapping
;
192 lProperties
[ OFFSET_CONSIDERWRAPPINGSTYLE
].Value
<<= pItem
->bConsiderWrappingStyle
;
193 lProperties
[ OFFSET_EXPANDWORDSPACE
].Value
<<= pItem
->bExpandWordSpace
;
194 lResult
[ nStep
] = lProperties
;
203 return lEntries
.size();
206 const SvtCompatibilityEntry
& operator[]( int i
) const
212 vector
< SvtCompatibilityEntry
> lEntries
;
215 class SvtCompatibilityOptions_Impl
: public ConfigItem
217 //-------------------------------------------------------------------------------------------------------------
219 //-------------------------------------------------------------------------------------------------------------
223 //---------------------------------------------------------------------------------------------------------
224 // constructor / destructor
225 //---------------------------------------------------------------------------------------------------------
227 SvtCompatibilityOptions_Impl();
228 ~SvtCompatibilityOptions_Impl();
230 void SetDefault( OUString sName
, bool bValue
);
232 //---------------------------------------------------------------------------------------------------------
233 // overloaded methods of baseclass
234 //---------------------------------------------------------------------------------------------------------
236 /*-****************************************************************************************************//**
237 @short called for notify of configmanager
238 @descr These method is called from the ConfigManager before application ends or from the
239 PropertyChangeListener if the sub tree broadcasts changes. You must update your
242 @seealso baseclass ConfigItem
244 @param "lPropertyNames" is the list of properties which should be updated.
248 *//*-*****************************************************************************************************/
250 virtual void Notify( const Sequence
< OUString
>& lPropertyNames
);
252 /*-****************************************************************************************************//**
253 @short write changes to configuration
254 @descr These method writes the changed values into the sub tree
255 and should always called in our destructor to guarantee consistency of config data.
257 @seealso baseclass ConfigItem
263 *//*-*****************************************************************************************************/
265 virtual void Commit();
267 //---------------------------------------------------------------------------------------------------------
269 //---------------------------------------------------------------------------------------------------------
271 /*-****************************************************************************************************//**
272 @short base implementation of public interface for "SvtCompatibilityOptions"!
273 @descr These class is used as static member of "SvtCompatibilityOptions" ...
274 => The code exist only for one time and isn't duplicated for every instance!
282 *//*-*****************************************************************************************************/
285 Sequence
< Sequence
< PropertyValue
> > GetList() const;
286 void AppendItem( const ::rtl::OUString
& _sName
,
287 const ::rtl::OUString
& _sModule
,
288 bool _bUsePrtMetrics
,
290 bool _bAddSpacingAtPages
,
291 bool _bUseOurTabStops
,
293 bool _bUseLineSpacing
,
294 bool _bAddTableSpacing
,
296 bool _bUseOurTextWrapping
,
297 bool _bConsiderWrappingStyle
,
298 bool _bExpandWordSpace
);
300 inline bool IsUsePrtDevice() const { return m_aDefOptions
.bUsePrtMetrics
; }
301 inline bool IsAddSpacing() const { return m_aDefOptions
.bAddSpacing
; }
302 inline bool IsAddSpacingAtPages() const { return m_aDefOptions
.bAddSpacingAtPages
; }
303 inline bool IsUseOurTabStops() const { return m_aDefOptions
.bUseOurTabStops
; }
304 inline bool IsNoExtLeading() const { return m_aDefOptions
.bNoExtLeading
; }
305 inline bool IsUseLineSpacing() const { return m_aDefOptions
.bUseLineSpacing
; }
306 inline bool IsAddTableSpacing() const { return m_aDefOptions
.bAddTableSpacing
; }
307 inline bool IsUseObjPos() const { return m_aDefOptions
.bUseObjPos
; }
308 inline bool IsUseOurTextWrapping() const { return m_aDefOptions
.bUseOurTextWrapping
; }
309 inline bool IsConsiderWrappingStyle() const { return m_aDefOptions
.bConsiderWrappingStyle
; }
310 inline bool IsExpandWordSpace() const { return m_aDefOptions
.bExpandWordSpace
; }
312 //-------------------------------------------------------------------------------------------------------------
314 //-------------------------------------------------------------------------------------------------------------
318 /*-****************************************************************************************************//**
319 @short return list of key names of our configuration management which represent one module tree
320 @descr These methods return the current list of key names! We need it to get needed values from our
321 configuration management and support dynamical menu item lists!
326 @return A list of configuration key names is returned.
329 *//*-*****************************************************************************************************/
331 Sequence
< OUString
> impl_GetPropertyNames( Sequence
< OUString
>& rItems
);
333 /*-****************************************************************************************************//**
334 @short expand the list for all well known properties to destination
338 @seealso method impl_GetPropertyNames()
340 @param "lSource" , original list
341 @param "lDestination" , destination of operation
342 @return A list of configuration key names is returned.
345 *//*-*****************************************************************************************************/
347 void impl_ExpandPropertyNames( const Sequence
< OUString
>& lSource
,
348 Sequence
< OUString
>& lDestination
);
350 //-------------------------------------------------------------------------------------------------------------
352 //-------------------------------------------------------------------------------------------------------------
356 SvtCompatibility m_aOptions
;
357 SvtCompatibilityEntry m_aDefOptions
;
360 //*****************************************************************************************************************
362 //*****************************************************************************************************************
363 SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
364 // Init baseclasses first
365 : ConfigItem( ROOTNODE_OPTIONS
)
366 // Init member then...
368 // Get names and values of all accessable menu entries and fill internal structures.
369 // See impl_GetPropertyNames() for further informations.
370 Sequence
< OUString
> lNodes
;
371 Sequence
< OUString
> lNames
= impl_GetPropertyNames( lNodes
);
372 sal_uInt32 nCount
= lNodes
.getLength();
373 Sequence
< Any
> lValues
= GetProperties( lNames
);
375 // Safe impossible cases.
376 // We need values from ALL configuration keys.
377 // Follow assignment use order of values in relation to our list of key names!
378 DBG_ASSERT( !( lNames
.getLength()!=lValues
.getLength() ), "SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()\nI miss some values of configuration keys!\n" );
380 SvtCompatibilityEntry aItem
;
381 sal_uInt32 nItem
= 0;
382 sal_uInt32 nPosition
= 0;
384 // Get names/values for new menu.
385 // 4 subkeys for every item!
386 bool bDefaultFound
= false;
387 for( nItem
= 0; nItem
< nCount
; ++nItem
)
389 aItem
.sName
= lNodes
[ nItem
];
390 lValues
[ nPosition
++ ] >>= aItem
.sModule
;
391 lValues
[ nPosition
++ ] >>= aItem
.bUsePrtMetrics
;
392 lValues
[ nPosition
++ ] >>= aItem
.bAddSpacing
;
393 lValues
[ nPosition
++ ] >>= aItem
.bAddSpacingAtPages
;
394 lValues
[ nPosition
++ ] >>= aItem
.bUseOurTabStops
;
395 lValues
[ nPosition
++ ] >>= aItem
.bNoExtLeading
;
396 lValues
[ nPosition
++ ] >>= aItem
.bUseLineSpacing
;
397 lValues
[ nPosition
++ ] >>= aItem
.bAddTableSpacing
;
398 lValues
[ nPosition
++ ] >>= aItem
.bUseObjPos
;
399 lValues
[ nPosition
++ ] >>= aItem
.bUseOurTextWrapping
;
400 lValues
[ nPosition
++ ] >>= aItem
.bConsiderWrappingStyle
;
401 lValues
[ nPosition
++ ] >>= aItem
.bExpandWordSpace
;
402 m_aOptions
.AppendEntry( aItem
);
404 if ( !bDefaultFound
&& aItem
.sName
.equals( COMPATIBILITY_DEFAULT_NAME
) != sal_False
)
406 SvtSysLocale aSysLocale
;
407 com::sun::star::lang::Locale aLocale
= aSysLocale
.GetLanguageTag().getLocale();
408 if ( aLocale
.Language
== "zh" || aLocale
.Language
== "ja" || aLocale
.Language
== "ko" )
409 aItem
.bExpandWordSpace
= false;
411 m_aDefOptions
= aItem
;
412 bDefaultFound
= true;
417 //*****************************************************************************************************************
419 //*****************************************************************************************************************
420 SvtCompatibilityOptions_Impl::~SvtCompatibilityOptions_Impl()
422 // We must save our current values .. if user forget it!
423 if( IsModified() == sal_True
)
429 void SvtCompatibilityOptions_Impl::SetDefault( OUString sName
, bool bValue
)
431 if ( COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
.equals( sName
) )
432 m_aDefOptions
.SetUsePrtMetrics( bValue
);
433 else if ( COMPATIBILITY_PROPERTYNAME_ADDSPACING
.equals( sName
) )
434 m_aDefOptions
.SetAddSpacing( bValue
);
435 else if ( COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
.equals( sName
) )
436 m_aDefOptions
.SetAddSpacingAtPages( bValue
);
437 else if ( COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
.equals( sName
) )
438 m_aDefOptions
.SetUseOurTabStops( bValue
);
439 else if ( COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
.equals( sName
) )
440 m_aDefOptions
.SetNoExtLeading( bValue
);
441 else if ( COMPATIBILITY_PROPERTYNAME_USELINESPACING
.equals( sName
) )
442 m_aDefOptions
.SetUseLineSpacing( bValue
);
443 else if ( COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
.equals( sName
) )
444 m_aDefOptions
.SetAddTableSpacing( bValue
);
445 else if ( COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
.equals( sName
) )
446 m_aDefOptions
.SetUseObjPos( bValue
);
447 else if ( COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
.equals( sName
) )
448 m_aDefOptions
.SetUseOurTextWrapping( bValue
);
449 else if ( COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
.equals( sName
) )
450 m_aDefOptions
.SetConsiderWrappingStyle( bValue
);
451 else if ( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
.equals( sName
) )
452 m_aDefOptions
.SetExpandWordSpace( bValue
);
455 //*****************************************************************************************************************
457 //*****************************************************************************************************************
458 void SvtCompatibilityOptions_Impl::Notify( const Sequence
< OUString
>& )
460 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" );
463 //*****************************************************************************************************************
465 //*****************************************************************************************************************
466 void SvtCompatibilityOptions_Impl::Commit()
468 // Write all properties!
469 // Delete complete set first.
470 ClearNodeSet( SETNODE_ALLFILEFORMATS
);
472 SvtCompatibilityEntry aItem
;
474 Sequence
< PropertyValue
> lPropertyValues( PROPERTYCOUNT
- 1 );
475 sal_uInt32 nItem
= 0;
476 sal_uInt32 nNewCount
= m_aOptions
.size();
477 for( nItem
= 0; nItem
< nNewCount
; ++nItem
)
479 aItem
= m_aOptions
[ nItem
];
480 sNode
= SETNODE_ALLFILEFORMATS
+ PATHDELIMITER
+ aItem
.sName
+ PATHDELIMITER
;
482 lPropertyValues
[ OFFSET_MODULE
- 1 ].Name
= sNode
+ PROPERTYNAME_MODULE
;
483 lPropertyValues
[ OFFSET_USEPRTMETRICS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEPRTMETRICS
;
484 lPropertyValues
[ OFFSET_ADDSPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDSPACING
;
485 lPropertyValues
[ OFFSET_ADDSPACINGATPAGES
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDSPACINGATPAGES
;
486 lPropertyValues
[ OFFSET_USEOURTABSTOPS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOURTABSTOPS
;
487 lPropertyValues
[ OFFSET_NOEXTLEADING
- 1 ].Name
= sNode
+ PROPERTYNAME_NOEXTLEADING
;
488 lPropertyValues
[ OFFSET_USELINESPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_USELINESPACING
;
489 lPropertyValues
[ OFFSET_ADDTABLESPACING
- 1 ].Name
= sNode
+ PROPERTYNAME_ADDTABLESPACING
;
490 lPropertyValues
[ OFFSET_USEOBJPOS
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOBJPOS
;
491 lPropertyValues
[ OFFSET_USEOURTEXTWRAPPING
- 1 ].Name
= sNode
+ PROPERTYNAME_USEOURTEXTWRAP
;
492 lPropertyValues
[ OFFSET_CONSIDERWRAPPINGSTYLE
- 1 ].Name
= sNode
+ PROPERTYNAME_CONSIDERWRAPSTYLE
;
493 lPropertyValues
[ OFFSET_EXPANDWORDSPACE
- 1 ].Name
= sNode
+ PROPERTYNAME_EXPANDWORDSPACE
;
495 lPropertyValues
[ OFFSET_MODULE
- 1 ].Value
<<= aItem
.sModule
;
496 lPropertyValues
[ OFFSET_USEPRTMETRICS
- 1 ].Value
<<= aItem
.bUsePrtMetrics
;
497 lPropertyValues
[ OFFSET_ADDSPACING
- 1 ].Value
<<= aItem
.bAddSpacing
;
498 lPropertyValues
[ OFFSET_ADDSPACINGATPAGES
- 1 ].Value
<<= aItem
.bAddSpacingAtPages
;
499 lPropertyValues
[ OFFSET_USEOURTABSTOPS
- 1 ].Value
<<= aItem
.bUseOurTabStops
;
500 lPropertyValues
[ OFFSET_NOEXTLEADING
- 1 ].Value
<<= aItem
.bNoExtLeading
;
501 lPropertyValues
[ OFFSET_USELINESPACING
- 1 ].Value
<<= aItem
.bUseLineSpacing
;
502 lPropertyValues
[ OFFSET_ADDTABLESPACING
- 1 ].Value
<<= aItem
.bAddTableSpacing
;
503 lPropertyValues
[ OFFSET_USEOBJPOS
- 1 ].Value
<<= aItem
.bUseObjPos
;
504 lPropertyValues
[ OFFSET_USEOURTEXTWRAPPING
- 1 ].Value
<<= aItem
.bUseOurTextWrapping
;
505 lPropertyValues
[ OFFSET_CONSIDERWRAPPINGSTYLE
- 1 ].Value
<<= aItem
.bConsiderWrappingStyle
;
506 lPropertyValues
[ OFFSET_EXPANDWORDSPACE
- 1 ].Value
<<= aItem
.bExpandWordSpace
;
508 SetSetProperties( SETNODE_ALLFILEFORMATS
, lPropertyValues
);
512 //*****************************************************************************************************************
514 //*****************************************************************************************************************
515 void SvtCompatibilityOptions_Impl::Clear()
521 //*****************************************************************************************************************
523 //*****************************************************************************************************************
524 Sequence
< Sequence
< PropertyValue
> > SvtCompatibilityOptions_Impl::GetList() const
526 Sequence
< Sequence
< PropertyValue
> > lReturn
;
527 lReturn
= m_aOptions
.GetList();
531 //*****************************************************************************************************************
533 //*****************************************************************************************************************
535 void SvtCompatibilityOptions_Impl::AppendItem( const ::rtl::OUString
& _sName
,
536 const ::rtl::OUString
& _sModule
,
537 bool _bUsePrtMetrics
,
539 bool _bAddSpacingAtPages
,
540 bool _bUseOurTabStops
,
542 bool _bUseLineSpacing
,
543 bool _bAddTableSpacing
,
545 bool _bUseOurTextWrapping
,
546 bool _bConsiderWrappingStyle
,
547 bool _bExpandWordSpace
)
549 SvtCompatibilityEntry
aItem( _sName
, _sModule
);
550 aItem
.SetUsePrtMetrics( _bUsePrtMetrics
);
551 aItem
.SetAddSpacing( _bAddSpacing
);
552 aItem
.SetAddSpacingAtPages( _bAddSpacingAtPages
);
553 aItem
.SetUseOurTabStops( _bUseOurTabStops
);
554 aItem
.SetNoExtLeading( _bNoExtLeading
);
555 aItem
.SetUseLineSpacing( _bUseLineSpacing
);
556 aItem
.SetAddTableSpacing( _bAddTableSpacing
);
557 aItem
.SetUseObjPos( _bUseObjPos
);
558 aItem
.SetUseOurTextWrapping( _bUseOurTextWrapping
);
559 aItem
.SetConsiderWrappingStyle( _bConsiderWrappingStyle
);
560 aItem
.SetExpandWordSpace( _bExpandWordSpace
);
561 m_aOptions
.AppendEntry( aItem
);
563 // default item reset?
564 if ( _sName
.equals( COMPATIBILITY_DEFAULT_NAME
) != sal_False
)
565 m_aDefOptions
= aItem
;
570 //*****************************************************************************************************************
572 //*****************************************************************************************************************
573 Sequence
< OUString
> SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequence
< OUString
>& rItems
)
575 // First get ALL names of current existing list items in configuration!
576 rItems
= GetNodeNames( SETNODE_ALLFILEFORMATS
);
577 // expand list to result list ...
578 Sequence
< OUString
> lProperties( rItems
.getLength() * ( PROPERTYCOUNT
- 1 ) );
579 impl_ExpandPropertyNames( rItems
, lProperties
);
584 //*****************************************************************************************************************
586 //*****************************************************************************************************************
587 void SvtCompatibilityOptions_Impl::impl_ExpandPropertyNames(
588 const Sequence
< OUString
>& lSource
, Sequence
< OUString
>& lDestination
)
591 sal_Int32 nDestStep
= 0;
592 sal_Int32 nSourceCount
= lSource
.getLength();
593 // Copy entries to destination and expand every item with 2 supported sub properties.
594 for( sal_Int32 nSourceStep
= 0; nSourceStep
< nSourceCount
; ++nSourceStep
)
596 sFixPath
= SETNODE_ALLFILEFORMATS
;
597 sFixPath
+= PATHDELIMITER
;
598 sFixPath
+= lSource
[ nSourceStep
];
599 sFixPath
+= PATHDELIMITER
;
601 lDestination
[nDestStep
] = sFixPath
;
602 lDestination
[nDestStep
] += PROPERTYNAME_MODULE
;
604 lDestination
[nDestStep
] = sFixPath
;
605 lDestination
[nDestStep
] += PROPERTYNAME_USEPRTMETRICS
;
607 lDestination
[nDestStep
] = sFixPath
;
608 lDestination
[nDestStep
] += PROPERTYNAME_ADDSPACING
;
610 lDestination
[nDestStep
] = sFixPath
;
611 lDestination
[nDestStep
] += PROPERTYNAME_ADDSPACINGATPAGES
;
613 lDestination
[nDestStep
] = sFixPath
;
614 lDestination
[nDestStep
] += PROPERTYNAME_USEOURTABSTOPS
;
616 lDestination
[nDestStep
] = sFixPath
;
617 lDestination
[nDestStep
] += PROPERTYNAME_NOEXTLEADING
;
619 lDestination
[nDestStep
] = sFixPath
;
620 lDestination
[nDestStep
] += PROPERTYNAME_USELINESPACING
;
622 lDestination
[nDestStep
] = sFixPath
;
623 lDestination
[nDestStep
] += PROPERTYNAME_ADDTABLESPACING
;
625 lDestination
[nDestStep
] = sFixPath
;
626 lDestination
[nDestStep
] += PROPERTYNAME_USEOBJPOS
;
628 lDestination
[nDestStep
] = sFixPath
;
629 lDestination
[nDestStep
] += PROPERTYNAME_USEOURTEXTWRAP
;
631 lDestination
[nDestStep
] = sFixPath
;
632 lDestination
[nDestStep
] += PROPERTYNAME_CONSIDERWRAPSTYLE
;
634 lDestination
[nDestStep
] = sFixPath
;
635 lDestination
[nDestStep
] += PROPERTYNAME_EXPANDWORDSPACE
;
640 //*****************************************************************************************************************
641 // initialize static member
642 // DON'T DO IT IN YOUR HEADER!
643 // see definition for further informations
644 //*****************************************************************************************************************
645 SvtCompatibilityOptions_Impl
* SvtCompatibilityOptions::m_pDataContainer
= NULL
;
646 sal_Int32
SvtCompatibilityOptions::m_nRefCount
= 0;
648 //*****************************************************************************************************************
650 //*****************************************************************************************************************
651 SvtCompatibilityOptions::SvtCompatibilityOptions()
653 // Global access, must be guarded (multithreading!).
654 MutexGuard
aGuard( GetOwnStaticMutex() );
655 // Increase ouer refcount ...
657 // ... and initialize ouer data container only if it not already exist!
658 if( m_pDataContainer
== NULL
)
660 m_pDataContainer
= new SvtCompatibilityOptions_Impl
;
661 ItemHolder1::holdConfigItem(E_COMPATIBILITY
);
665 //*****************************************************************************************************************
667 //*****************************************************************************************************************
668 SvtCompatibilityOptions::~SvtCompatibilityOptions()
670 // Global access, must be guarded (multithreading!)
671 MutexGuard
aGuard( GetOwnStaticMutex() );
672 // Decrease ouer refcount.
674 // If last instance was deleted ...
675 // we must destroy ouer static data container!
676 if( m_nRefCount
<= 0 )
678 delete m_pDataContainer
;
679 m_pDataContainer
= NULL
;
683 //*****************************************************************************************************************
685 //*****************************************************************************************************************
686 void SvtCompatibilityOptions::Clear()
688 MutexGuard
aGuard( GetOwnStaticMutex() );
689 m_pDataContainer
->Clear();
692 void SvtCompatibilityOptions::SetDefault( ::rtl::OUString sName
, bool bValue
)
694 m_pDataContainer
->SetDefault( sName
, bValue
);
697 //*****************************************************************************************************************
699 //*****************************************************************************************************************
700 void SvtCompatibilityOptions::AppendItem( const ::rtl::OUString
& sName
,
701 const ::rtl::OUString
& sModule
,
704 bool bAddSpacingAtPages
,
705 bool bUseOurTabStops
,
707 bool bUseLineSpacing
,
708 bool bAddTableSpacing
,
710 bool bUseOurTextWrapping
,
711 bool bConsiderWrappingStyle
,
712 bool bExpandWordSpace
)
714 MutexGuard
aGuard( GetOwnStaticMutex() );
715 m_pDataContainer
->AppendItem(
716 sName
, sModule
, bUsePrtMetrics
, bAddSpacing
,
717 bAddSpacingAtPages
, bUseOurTabStops
, bNoExtLeading
,
718 bUseLineSpacing
, bAddTableSpacing
, bUseObjPos
,
719 bUseOurTextWrapping
, bConsiderWrappingStyle
, bExpandWordSpace
);
722 bool SvtCompatibilityOptions::IsUsePrtDevice() const
724 MutexGuard
aGuard( GetOwnStaticMutex() );
725 return m_pDataContainer
->IsUsePrtDevice();
728 bool SvtCompatibilityOptions::IsAddSpacing() const
730 MutexGuard
aGuard( GetOwnStaticMutex() );
731 return m_pDataContainer
->IsAddSpacing();
734 bool SvtCompatibilityOptions::IsAddSpacingAtPages() const
736 MutexGuard
aGuard( GetOwnStaticMutex() );
737 return m_pDataContainer
->IsAddSpacingAtPages();
740 bool SvtCompatibilityOptions::IsUseOurTabStops() const
742 MutexGuard
aGuard( GetOwnStaticMutex() );
743 return m_pDataContainer
->IsUseOurTabStops();
746 bool SvtCompatibilityOptions::IsNoExtLeading() const
748 MutexGuard
aGuard( GetOwnStaticMutex() );
749 return m_pDataContainer
->IsNoExtLeading();
752 bool SvtCompatibilityOptions::IsUseLineSpacing() const
754 MutexGuard
aGuard( GetOwnStaticMutex() );
755 return m_pDataContainer
->IsUseLineSpacing();
758 bool SvtCompatibilityOptions::IsAddTableSpacing() const
760 MutexGuard
aGuard( GetOwnStaticMutex() );
761 return m_pDataContainer
->IsAddTableSpacing();
764 bool SvtCompatibilityOptions::IsUseObjectPositioning() const
766 MutexGuard
aGuard( GetOwnStaticMutex() );
767 return m_pDataContainer
->IsUseObjPos();
770 bool SvtCompatibilityOptions::IsUseOurTextWrapping() const
772 MutexGuard
aGuard( GetOwnStaticMutex() );
773 return m_pDataContainer
->IsUseOurTextWrapping();
776 bool SvtCompatibilityOptions::IsConsiderWrappingStyle() const
778 MutexGuard
aGuard( GetOwnStaticMutex() );
779 return m_pDataContainer
->IsConsiderWrappingStyle();
782 bool SvtCompatibilityOptions::IsExpandWordSpace() const
784 MutexGuard
aGuard( GetOwnStaticMutex() );
785 return m_pDataContainer
->IsExpandWordSpace();
788 Sequence
< Sequence
< PropertyValue
> > SvtCompatibilityOptions::GetList() const
790 MutexGuard
aGuard( GetOwnStaticMutex() );
791 return m_pDataContainer
->GetList();
796 class theCompatibilityOptionsMutex
: public rtl::Static
<osl::Mutex
, theCompatibilityOptionsMutex
>{};
799 //*****************************************************************************************************************
801 //*****************************************************************************************************************
802 Mutex
& SvtCompatibilityOptions::GetOwnStaticMutex()
804 return theCompatibilityOptionsMutex::get();
807 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */