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