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_sw.hxx" 26 #ifdef SW_DLLIMPLEMENTATION 27 #undef SW_DLLIMPLEMENTATION 28 #endif 29 30 #include "optcomp.hxx" 31 32 #include "docsh.hxx" 33 #include "swmodule.hxx" 34 #include "swtypes.hxx" 35 #include "uiitems.hxx" 36 #include "view.hxx" 37 #include "wrtsh.hxx" 38 39 #include "optcomp.hrc" 40 #include "globals.hrc" 41 #include <tools/urlobj.hxx> 42 #ifndef _UTL__HXX_ 43 #include <unotools/configmgr.hxx> 44 #endif 45 #include <vcl/msgbox.hxx> 46 #include <sfx2/docfile.hxx> 47 #include <sfx2/docfilt.hxx> 48 #include <sfx2/fcontnr.hxx> 49 #include <IDocumentSettingAccess.hxx> 50 51 using namespace ::com::sun::star::beans; 52 using namespace ::com::sun::star::document; 53 using namespace ::com::sun::star::uno; 54 using ::rtl::OUString; 55 using namespace ::std; 56 57 #define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM( s ) ) 58 #define DEFAULT_ENTRY COMPATIBILITY_DEFAULT_NAME 59 #define USER_ENTRY ASCII_STR( "_user" ) 60 #define BUTTON_BORDER 2 61 62 // struct CompatibilityItem ---------------------------------------------- 63 64 struct CompatibilityItem 65 { 66 String m_sName; 67 String m_sModule; 68 bool m_bUsePrtMetrics; 69 bool m_bAddSpacing; 70 bool m_bAddSpacingAtPages; 71 bool m_bUseOurTabStops; 72 bool m_bNoExtLeading; 73 bool m_bUseLineSpacing; 74 bool m_bAddTableSpacing; 75 bool m_bUseObjPos; 76 bool m_bUseOurTextWrapping; 77 bool m_bConsiderWrappingStyle; 78 bool m_bExpandWordSpace; 79 bool m_bIsDefault; 80 bool m_bIsUser; 81 82 CompatibilityItem( const String& _rName, const String& _rModule, 83 bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages, 84 bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing, 85 bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping, 86 bool _bConsiderWrappingStyle, bool _bExpandWordSpace, 87 bool _bIsDefault, bool _bIsUser ) : 88 89 m_sName ( _rName ), 90 m_sModule ( _rModule ), 91 m_bUsePrtMetrics ( _bUsePrtMetrics ), 92 m_bAddSpacing ( _bAddSpacing ), 93 m_bAddSpacingAtPages ( _bAddSpacingAtPages ), 94 m_bUseOurTabStops ( _bUseOurTabStops ), 95 m_bNoExtLeading ( _bNoExtLeading ), 96 m_bUseLineSpacing ( _bUseLineSpacing ), 97 m_bAddTableSpacing ( _bAddTableSpacing ), 98 m_bUseObjPos ( _bUseObjPos ), 99 m_bUseOurTextWrapping ( _bUseOurTextWrapping ), 100 m_bConsiderWrappingStyle( _bConsiderWrappingStyle ), 101 m_bExpandWordSpace ( _bExpandWordSpace ), 102 m_bIsDefault ( _bIsDefault ), 103 m_bIsUser ( _bIsUser ) {} 104 }; 105 106 #include <vector> 107 108 struct SwCompatibilityOptPage_Impl 109 { 110 typedef vector< CompatibilityItem > SwCompatibilityItemList; 111 112 SwCompatibilityItemList m_aList; 113 }; 114 115 // class SwCompatibilityOptPage ------------------------------------------ 116 117 SwCompatibilityOptPage::SwCompatibilityOptPage( Window* pParent, const SfxItemSet& rSet ) : 118 119 SfxTabPage( pParent, SW_RES( TP_OPTCOMPATIBILITY_PAGE ), rSet ), 120 121 m_aMainFL ( this, SW_RES( FL_MAIN ) ), 122 m_aFormattingFT ( this, SW_RES( FT_FORMATTING ) ), 123 m_aFormattingLB ( this, SW_RES( LB_FORMATTING ) ), 124 m_aOptionsFT ( this, SW_RES( FT_OPTIONS ) ), 125 m_aOptionsLB ( this, SW_RES( LB_OPTIONS ) ), 126 m_aResetPB ( this, SW_RES( PB_RESET ) ), 127 m_aDefaultPB ( this, SW_RES( PB_DEFAULT ) ), 128 m_sUserEntry ( SW_RES( STR_USERENTRY ) ), 129 m_sUseAsDefaultQuery( SW_RES( STR_QRYBOX_USEASDEFAULT ) ), 130 m_pWrtShell ( NULL ), 131 m_pImpl ( new SwCompatibilityOptPage_Impl ), 132 m_nSavedOptions ( 0 ) 133 134 { 135 // init options strings with local resource ids -> so do it before FreeResource() 136 for ( sal_uInt16 nResId = STR_COMP_OPTIONS_START; nResId < STR_COMP_OPTIONS_END; ++nResId ) 137 { 138 String sEntry = String( SW_RES( nResId ) ); 139 if ( STR_TAB_ALIGNMENT == nResId || 140 STR_LINE_SPACING == nResId || 141 STR_USE_OBJPOSITIONING == nResId || 142 STR_USE_OURTEXTWRAPPING == nResId ) 143 ReplaceFormatName( sEntry ); 144 SvLBoxEntry* pEntry = m_aOptionsLB.SvTreeListBox::InsertEntry( sEntry ); 145 if ( pEntry ) 146 { 147 m_aOptionsLB.SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED ); 148 pEntry->SetUserData( (void*)(sal_uLong)nResId ); 149 } 150 } 151 m_aOptionsLB.SetStyle( m_aOptionsLB.GetStyle() | WB_HSCROLL | WB_HIDESELECTION ); 152 m_aOptionsLB.SetHighlightRange(); 153 154 FreeResource(); 155 156 InitControls( rSet ); 157 158 // set handler 159 m_aFormattingLB.SetSelectHdl( LINK( this, SwCompatibilityOptPage, SelectHdl ) ); 160 m_aDefaultPB.SetClickHdl( LINK( this, SwCompatibilityOptPage, UseAsDefaultHdl ) ); 161 162 // hide some controls, will be implemented later!!! 163 m_aFormattingFT.Hide(); 164 m_aFormattingLB.Hide(); 165 m_aResetPB.Hide(); 166 // so move and resize the other controls 167 Point aMovePnt = m_aFormattingFT.GetPosPixel(); 168 Point aNewPnt = m_aOptionsFT.GetPosPixel(); 169 aNewPnt.Y() = aMovePnt.Y(); 170 m_aOptionsFT.SetPosPixel( aNewPnt ); 171 aMovePnt = m_aFormattingLB.GetPosPixel(); 172 aNewPnt = m_aOptionsLB.GetPosPixel(); 173 long nDelta = aNewPnt.Y() - aMovePnt.Y(); 174 aNewPnt.Y() = aMovePnt.Y(); 175 m_aOptionsLB.SetPosPixel( aNewPnt ); 176 Size aNewSz = m_aOptionsLB.GetSizePixel(); 177 aNewSz.Height() += nDelta; 178 m_aOptionsLB.SetSizePixel( aNewSz ); 179 } 180 181 // ----------------------------------------------------------------------- 182 183 SwCompatibilityOptPage::~SwCompatibilityOptPage() 184 { 185 delete m_pImpl; 186 } 187 188 // ----------------------------------------------------------------------- 189 190 void SwCompatibilityOptPage::ReplaceFormatName( String& rEntry ) 191 { 192 static const String sOpenOfficeName = String::CreateFromAscii("OpenOffice.org"); 193 static const String sAsianName = String::CreateFromAscii("StarSuite"); 194 195 Any aAny = ::utl::ConfigManager:: 196 GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ); 197 rtl::OUString sTmp; 198 if ( aAny >>= sTmp ) 199 { 200 String sFormatName = sTmp; 201 String sFormatVersion; 202 bool bOpenOffice = ( sOpenOfficeName == sFormatName ); 203 if ( bOpenOffice ) 204 sFormatVersion = String::CreateFromAscii("1.1"); 205 else 206 sFormatVersion = String::CreateFromAscii("6.0/7"); 207 if ( !bOpenOffice && ( sAsianName != sFormatName ) ) 208 sFormatName = String::CreateFromAscii("StarOffice"); 209 210 rEntry.SearchAndReplace( String::CreateFromAscii("%FORMATNAME"), sFormatName ); 211 rEntry.SearchAndReplace( String::CreateFromAscii("%FORMATVERSION"), sFormatVersion ); 212 } 213 } 214 215 // ----------------------------------------------------------------------- 216 217 sal_uLong convertBools2Ulong_Impl 218 ( 219 bool _bUsePrtMetrics, 220 bool _bAddSpacing, 221 bool _bAddSpacingAtPages, 222 bool _bUseOurTabStops, 223 bool _bNoExtLeading, 224 bool _bUseLineSpacing, 225 bool _bAddTableSpacing, 226 bool _bUseObjPos, 227 bool _bUseOurTextWrapping, 228 bool _bConsiderWrappingStyle, 229 bool _bExpandWordSpace 230 ) 231 { 232 sal_uLong nRet = 0; 233 sal_uLong nSetBit = 1; 234 235 if ( _bUsePrtMetrics ) 236 nRet |= nSetBit; 237 nSetBit = nSetBit << 1; 238 if ( _bAddSpacing ) 239 nRet |= nSetBit; 240 nSetBit = nSetBit << 1; 241 if ( _bAddSpacingAtPages ) 242 nRet |= nSetBit; 243 nSetBit = nSetBit << 1; 244 if ( _bUseOurTabStops ) 245 nRet |= nSetBit; 246 nSetBit = nSetBit << 1; 247 if ( _bNoExtLeading ) 248 nRet |= nSetBit; 249 nSetBit = nSetBit << 1; 250 if ( _bUseLineSpacing ) 251 nRet |= nSetBit; 252 nSetBit = nSetBit << 1; 253 if ( _bAddTableSpacing ) 254 nRet |= nSetBit; 255 nSetBit = nSetBit << 1; 256 if ( _bUseObjPos ) 257 nRet |= nSetBit; 258 nSetBit = nSetBit << 1; 259 if ( _bUseOurTextWrapping ) 260 nRet |= nSetBit; 261 nSetBit = nSetBit << 1; 262 if ( _bConsiderWrappingStyle ) 263 nRet |= nSetBit; 264 nSetBit = nSetBit << 1; 265 if ( _bExpandWordSpace ) 266 nRet |= nSetBit; 267 268 return nRet; 269 } 270 271 // ----------------------------------------------------------------------- 272 273 void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet ) 274 { 275 // init objectshell and detect document name 276 String sDocTitle; 277 const SfxPoolItem* pItem = NULL; 278 SfxObjectShell* pObjShell = NULL; 279 if ( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_WRTSHELL, sal_False, &pItem ) ) 280 m_pWrtShell = (SwWrtShell*)( (const SwPtrItem*)pItem )->GetValue(); 281 if ( m_pWrtShell ) 282 { 283 pObjShell = m_pWrtShell->GetView().GetDocShell(); 284 if ( pObjShell ) 285 sDocTitle = pObjShell->GetTitle( SFX_TITLE_TITLE ); 286 } 287 else 288 { 289 m_aMainFL.Disable(); 290 m_aFormattingFT.Disable(); 291 m_aFormattingLB.Disable(); 292 m_aOptionsFT.Disable(); 293 m_aOptionsLB.Disable(); 294 m_aResetPB.Disable(); 295 m_aDefaultPB.Disable(); 296 } 297 String sText = m_aMainFL.GetText(); 298 sText.SearchAndReplace( String::CreateFromAscii("%DOCNAME"), sDocTitle ); 299 m_aMainFL.SetText( sText ); 300 301 // loading file formats 302 Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList(); 303 OUString sName; 304 OUString sModule; 305 bool bUsePrtMetrics = false; 306 bool bAddSpacing = false; 307 bool bAddSpacingAtPages = false; 308 bool bUseOurTabStops = false; 309 bool bNoExtLeading = false; 310 bool bUseLineSpacing = false; 311 bool bAddTableSpacing = false; 312 bool bUseObjPos = false; 313 bool bUseOurTextWrapping = false; 314 bool bConsiderWrappingStyle = false; 315 bool bExpandWordSpace = false; 316 int i, j, nCount = aList.getLength(); 317 for ( i = 0; i < nCount; ++i ) 318 { 319 String sNewEntry; 320 const Sequence< PropertyValue >& rEntry = aList[i]; 321 for ( j = 0; j < rEntry.getLength(); j++ ) 322 { 323 PropertyValue aValue = rEntry[j]; 324 if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NAME ) 325 aValue.Value >>= sName; 326 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MODULE ) 327 aValue.Value >>= sModule; 328 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS ) 329 aValue.Value >>= bUsePrtMetrics; 330 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACING ) 331 aValue.Value >>= bAddSpacing; 332 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES ) 333 aValue.Value >>= bAddSpacingAtPages; 334 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS ) 335 aValue.Value >>= bUseOurTabStops; 336 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING ) 337 aValue.Value >>= bNoExtLeading; 338 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USELINESPACING ) 339 aValue.Value >>= bUseLineSpacing; 340 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING ) 341 aValue.Value >>= bAddTableSpacing; 342 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING ) 343 aValue.Value >>= bUseObjPos; 344 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING ) 345 aValue.Value >>= bUseOurTextWrapping; 346 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE ) 347 aValue.Value >>= bConsiderWrappingStyle; 348 else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE ) 349 aValue.Value >>= bExpandWordSpace; 350 } 351 352 CompatibilityItem aItem( 353 sName, sModule, bUsePrtMetrics, bAddSpacing, 354 bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading, 355 bUseLineSpacing, bAddTableSpacing, bUseObjPos, 356 bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, 357 ( sName.equals( DEFAULT_ENTRY ) != sal_False ), 358 ( sName.equals( USER_ENTRY ) != sal_False ) ); 359 m_pImpl->m_aList.push_back( aItem ); 360 361 if ( aItem.m_bIsDefault ) 362 continue; 363 364 if ( sName.equals( USER_ENTRY ) ) 365 sNewEntry = m_sUserEntry; 366 else if ( pObjShell && sName.getLength() > 0 ) 367 { 368 SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer(); 369 const SfxFilter* pFilter = pFacCont->GetFilter4FilterName( sName ); 370 if ( pFilter ) 371 sNewEntry = pFilter->GetUIName(); 372 } 373 374 if ( sNewEntry.Len() == 0 ) 375 sNewEntry = sName; 376 377 sal_uInt16 nPos = m_aFormattingLB.InsertEntry( sNewEntry ); 378 sal_uLong nOptions = convertBools2Ulong_Impl( 379 bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages, 380 bUseOurTabStops, bNoExtLeading, bUseLineSpacing, 381 bAddTableSpacing, bUseObjPos, bUseOurTextWrapping, 382 bConsiderWrappingStyle, bExpandWordSpace ); 383 m_aFormattingLB.SetEntryData( nPos, (void*)(long)nOptions ); 384 } 385 386 m_aFormattingLB.SetDropDownLineCount( m_aFormattingLB.GetEntryCount() ); 387 388 // check if the default button text is not too wide otherwise we have to stretch the button 389 // and move its position and the position of the reset button 390 long nTxtWidth = m_aDefaultPB.GetTextWidth( m_aDefaultPB.GetText() ); 391 Size aBtnSz = m_aDefaultPB.GetSizePixel(); 392 if ( nTxtWidth > aBtnSz.Width() ) 393 { 394 long nDelta = nTxtWidth - aBtnSz.Width() + 2 * BUTTON_BORDER; 395 aBtnSz.Width() += nDelta; 396 Point aBtnPnt = m_aDefaultPB.GetPosPixel(); 397 aBtnPnt.X() -= nDelta; 398 m_aDefaultPB.SetPosSizePixel( aBtnPnt, aBtnSz ); 399 aBtnPnt = m_aResetPB.GetPosPixel(); 400 aBtnPnt.X() -= 2 * nDelta; 401 m_aResetPB.SetPosSizePixel( aBtnPnt, aBtnSz ); 402 } 403 } 404 405 // ----------------------------------------------------------------------- 406 407 IMPL_LINK( SwCompatibilityOptPage, SelectHdl, ListBox*, EMPTYARG ) 408 { 409 sal_uInt16 nPos = m_aFormattingLB.GetSelectEntryPos(); 410 sal_uLong nOptions = (sal_uLong)(void*)m_aFormattingLB.GetEntryData( nPos ); 411 SetCurrentOptions( nOptions ); 412 413 return 0; 414 } 415 416 // ----------------------------------------------------------------------- 417 418 IMPL_LINK( SwCompatibilityOptPage, UseAsDefaultHdl, PushButton*, EMPTYARG ) 419 { 420 QueryBox aBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), m_sUseAsDefaultQuery ); 421 if ( aBox.Execute() == RET_YES ) 422 { 423 for ( vector< CompatibilityItem >::iterator pItem = m_pImpl->m_aList.begin(); 424 pItem != m_pImpl->m_aList.end(); ++pItem ) 425 { 426 if ( pItem->m_bIsDefault ) 427 { 428 sal_uInt16 nCount = static_cast< sal_uInt16 >( m_aOptionsLB.GetEntryCount() ); 429 for ( sal_uInt16 i = 0; i < nCount; ++i ) 430 { 431 bool bChecked = ( m_aOptionsLB.IsChecked(i) != sal_False ); 432 CompatibilityOptions eOption = static_cast< CompatibilityOptions >(i); 433 switch ( eOption ) 434 { 435 case COPT_USE_PRINTERDEVICE : pItem->m_bUsePrtMetrics = bChecked; break; 436 case COPT_ADD_SPACING : pItem->m_bAddSpacing = bChecked; break; 437 case COPT_ADD_SPACING_AT_PAGES : pItem->m_bAddSpacingAtPages = bChecked; break; 438 case COPT_USE_OUR_TABSTOPS : pItem->m_bUseOurTabStops = bChecked; break; 439 case COPT_NO_EXTLEADING : pItem->m_bNoExtLeading = bChecked; break; 440 case COPT_USE_LINESPACING : pItem->m_bUseLineSpacing = bChecked; break; 441 case COPT_ADD_TABLESPACING : pItem->m_bAddTableSpacing = bChecked; break; 442 case COPT_USE_OBJECTPOSITIONING: pItem->m_bUseObjPos = bChecked; break; 443 case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break; 444 case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break; 445 case COPT_EXPAND_WORDSPACE: pItem->m_bExpandWordSpace = bChecked; break; 446 default: 447 { 448 DBG_ERRORFILE( "SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" ); 449 } 450 } 451 } 452 break; 453 } 454 } 455 456 WriteOptions(); 457 } 458 459 return 0; 460 } 461 462 // ----------------------------------------------------------------------- 463 464 void SwCompatibilityOptPage::SetCurrentOptions( sal_uLong nOptions ) 465 { 466 sal_uLong nCount = m_aOptionsLB.GetEntryCount(); 467 DBG_ASSERT( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" ); 468 for ( sal_uInt16 i = 0; i < nCount; ++i ) 469 { 470 sal_Bool bChecked = ( ( nOptions & 0x00000001 ) == 0x00000001 ); 471 m_aOptionsLB.CheckEntryPos( i, bChecked ); 472 nOptions = nOptions >> 1; 473 } 474 } 475 476 // ----------------------------------------------------------------------- 477 478 sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const 479 { 480 sal_uLong nRet = 0; 481 if ( m_pWrtShell ) 482 { 483 const IDocumentSettingAccess& rIDocumentSettingAccess = *m_pWrtShell->getIDocumentSettingAccess(); 484 nRet = convertBools2Ulong_Impl( 485 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) == sal_False, 486 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX) != sal_False, 487 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) != sal_False, 488 rIDocumentSettingAccess.get(IDocumentSettingAccess::TAB_COMPAT) == sal_False, 489 rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_EXT_LEADING) == sal_False, 490 rIDocumentSettingAccess.get(IDocumentSettingAccess::OLD_LINE_SPACING) != sal_False, 491 rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) != sal_False, 492 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) != sal_False, 493 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) != sal_False, 494 rIDocumentSettingAccess.get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) != sal_False, 495 rIDocumentSettingAccess.get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != sal_True ); 496 } 497 return nRet; 498 } 499 500 // ----------------------------------------------------------------------- 501 502 void SwCompatibilityOptPage::WriteOptions() 503 { 504 m_aConfigItem.Clear(); 505 for ( vector< CompatibilityItem >::const_iterator pItem = m_pImpl->m_aList.begin(); 506 pItem != m_pImpl->m_aList.end(); ++pItem ) 507 m_aConfigItem.AppendItem( 508 pItem->m_sName, pItem->m_sModule, pItem->m_bUsePrtMetrics, pItem->m_bAddSpacing, 509 pItem->m_bAddSpacingAtPages, pItem->m_bUseOurTabStops, 510 pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing, 511 pItem->m_bAddTableSpacing, pItem->m_bUseObjPos, 512 pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle, 513 pItem->m_bExpandWordSpace ); 514 } 515 516 // ----------------------------------------------------------------------- 517 518 SfxTabPage* SwCompatibilityOptPage::Create( Window* pParent, const SfxItemSet& rAttrSet ) 519 { 520 return new SwCompatibilityOptPage( pParent, rAttrSet ); 521 } 522 523 // ----------------------------------------------------------------------- 524 525 sal_Bool SwCompatibilityOptPage::FillItemSet( SfxItemSet& ) 526 { 527 sal_Bool bModified = sal_False; 528 if ( m_pWrtShell ) 529 { 530 sal_uLong nSavedOptions = m_nSavedOptions; 531 sal_uLong nCount = m_aOptionsLB.GetEntryCount(); 532 DBG_ASSERT( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" ); 533 534 bool bSetParaSpaceMax = false; 535 536 for ( sal_uInt16 i = 0; i < nCount; ++i ) 537 { 538 CompatibilityOptions nOption = static_cast< CompatibilityOptions >(i); 539 sal_Bool bChecked = m_aOptionsLB.IsChecked(i); 540 sal_Bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 0x00000001 ); 541 if ( bChecked != bSavedChecked ) 542 { 543 if ( COPT_USE_PRINTERDEVICE == nOption ) 544 { 545 m_pWrtShell->SetUseVirDev( !bChecked ); 546 bModified = sal_True; 547 } 548 else if ( ( COPT_ADD_SPACING == nOption || COPT_ADD_SPACING_AT_PAGES == nOption ) && !bSetParaSpaceMax ) 549 bSetParaSpaceMax = true; 550 else if ( COPT_USE_OUR_TABSTOPS == nOption ) 551 { 552 m_pWrtShell->SetTabCompat( !bChecked ); 553 bModified = sal_True; 554 } 555 else if ( COPT_NO_EXTLEADING == nOption ) 556 { 557 m_pWrtShell->SetAddExtLeading( !bChecked ); 558 bModified = sal_True; 559 } 560 else if ( COPT_USE_LINESPACING == nOption ) 561 { 562 m_pWrtShell->SetUseFormerLineSpacing( bChecked ); 563 bModified = sal_True; 564 } 565 else if ( COPT_ADD_TABLESPACING == nOption ) 566 { 567 m_pWrtShell->SetAddParaSpacingToTableCells( bChecked ); 568 bModified = sal_True; 569 } 570 else if ( COPT_ADD_TABLESPACING == nOption ) 571 { 572 m_pWrtShell->SetAddParaSpacingToTableCells( bChecked ); 573 bModified = sal_True; 574 } 575 else if ( COPT_USE_OBJECTPOSITIONING == nOption ) 576 { 577 m_pWrtShell->SetUseFormerObjectPositioning( bChecked ); 578 bModified = sal_True; 579 } 580 else if ( COPT_USE_OUR_TEXTWRAPPING == nOption ) 581 { 582 m_pWrtShell->SetUseFormerTextWrapping( bChecked ); 583 bModified = sal_True; 584 } 585 else if ( COPT_CONSIDER_WRAPPINGSTYLE == nOption ) 586 { 587 m_pWrtShell->SetConsiderWrapOnObjPos( bChecked ); 588 bModified = sal_True; 589 } 590 else if ( COPT_EXPAND_WORDSPACE == nOption ) 591 { 592 m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked ); 593 bModified = sal_True; 594 } 595 } 596 597 nSavedOptions = nSavedOptions >> 1; 598 } 599 600 if ( bSetParaSpaceMax ) 601 { 602 m_pWrtShell->SetParaSpaceMax( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING ) ); 603 m_pWrtShell->SetParaSpaceMaxAtPages( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING_AT_PAGES ) ); 604 bModified = sal_True; 605 } 606 } 607 608 if ( bModified ) 609 WriteOptions(); 610 611 return bModified; 612 } 613 614 // ----------------------------------------------------------------------- 615 616 void SwCompatibilityOptPage::Reset( const SfxItemSet& ) 617 { 618 m_aOptionsLB.SelectEntryPos( 0 ); 619 620 sal_uLong nOptions = GetDocumentOptions(); 621 SetCurrentOptions( nOptions ); 622 m_nSavedOptions = nOptions; 623 } 624 625