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