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