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