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_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <unotools/pathoptions.hxx> 33 #include <svl/intitem.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <tools/urlobj.hxx> 36 #include <sfx2/objsh.hxx> 37 #include <sfx2/docfile.hxx> 38 #include <svtools/wallitem.hxx> 39 #include <svl/cntwall.hxx> 40 #include <sfx2/cntids.hrc> 41 #include <svx/dialogs.hrc> 42 43 #define _SVX_BACKGRND_CXX 44 45 #include <cuires.hrc> 46 #include "backgrnd.hrc" 47 #include <svx/dialmgr.hxx> 48 #include <editeng/memberids.hrc> 49 #include <editeng/editrids.hrc> 50 #include <editeng/eerdll.hxx> 51 52 // Tabellenhintergrund 53 #define TBL_DEST_CELL 0 54 #define TBL_DEST_ROW 1 55 #define TBL_DEST_TBL 2 56 57 #include <editeng/brshitem.hxx> 58 #include "backgrnd.hxx" 59 60 #include <svx/xtable.hxx> 61 #include <sfx2/opengrf.hxx> 62 #include <svx/svxerr.hxx> 63 #include <svx/drawitem.hxx> 64 #include <dialmgr.hxx> 65 #include <svx/htmlmode.hxx> 66 #include <svtools/controldims.hrc> 67 #include <svx/flagsdef.hxx> //CHINA001 68 #include <svl/intitem.hxx> //CHINA001 69 #include <sfx2/request.hxx> //CHINA001 70 using namespace ::com::sun::star; 71 // static ---------------------------------------------------------------- 72 73 static sal_uInt16 pRanges[] = 74 { 75 SID_VIEW_FLD_PIC, SID_VIEW_FLD_PIC, 76 SID_ATTR_BRUSH, SID_ATTR_BRUSH, 77 SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR, 78 0 79 }; 80 81 struct SvxBackgroundTable_Impl 82 { 83 SvxBrushItem* pCellBrush; 84 SvxBrushItem* pRowBrush; 85 SvxBrushItem* pTableBrush; 86 sal_uInt16 nCellWhich; 87 sal_uInt16 nRowWhich; 88 sal_uInt16 nTableWhich; 89 sal_uInt16 nActPos; 90 91 SvxBackgroundTable_Impl() : 92 pCellBrush(NULL), pRowBrush(NULL), pTableBrush(NULL), 93 nCellWhich(0), nRowWhich(0), nTableWhich(0) {} 94 }; 95 96 struct SvxBackgroundPara_Impl 97 { 98 SvxBrushItem* pParaBrush; 99 SvxBrushItem* pCharBrush; 100 101 sal_uInt16 nActPos; 102 103 SvxBackgroundPara_Impl() : 104 pParaBrush(NULL), pCharBrush(NULL) {} 105 }; 106 107 struct SvxBackgroundPage_Impl 108 { 109 Timer* pLoadTimer; 110 sal_Bool bIsImportDlgInExecute; 111 112 SvxBackgroundPage_Impl() : 113 pLoadTimer(NULL), bIsImportDlgInExecute(sal_False) {} 114 }; 115 /* -----------------------------15.08.2002 12:21------------------------------ 116 117 ---------------------------------------------------------------------------*/ 118 inline sal_uInt8 lcl_PercentToTransparency(long nPercent) 119 { 120 //0xff must not be returned! 121 return sal_uInt8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0); 122 } 123 inline sal_uInt8 lcl_TransparencyToPercent(sal_uInt8 nTrans) 124 { 125 return (nTrans * 100 + 127) / 254; 126 } 127 void lcl_SetTransparency(SvxBrushItem& rBrush, long nTransparency) 128 { 129 uno::Any aTransparency; 130 aTransparency <<= (sal_Int8)nTransparency; 131 rBrush.PutValue(aTransparency, MID_GRAPHIC_TRANSPARENCY); 132 } 133 //------------------------------------------------------------------------- 134 135 /* [Beschreibung] 136 137 */ 138 139 sal_uInt16 GetItemId_Impl( ValueSet& rValueSet, const Color& rCol ) 140 { 141 sal_Bool bFound = sal_False; 142 sal_uInt16 nCount = rValueSet.GetItemCount(); 143 sal_uInt16 n = 1; 144 145 while ( !bFound && n <= nCount ) 146 { 147 Color aValCol = rValueSet.GetItemColor(n); 148 149 bFound = ( aValCol.GetRed() == rCol.GetRed() 150 && aValCol.GetGreen() == rCol.GetGreen() 151 && aValCol.GetBlue() == rCol.GetBlue() ); 152 153 if ( !bFound ) 154 n++; 155 } 156 return bFound ? n : 0; 157 } 158 159 // class BackgroundPreview ----------------------------------------------- 160 161 /* [Beschreibung] 162 163 Vorschaufenster f"ur Brush oder Bitmap 164 */ 165 166 class BackgroundPreviewImpl : public Window 167 { 168 public: 169 BackgroundPreviewImpl( Window* pParent, 170 const ResId& rResId, sal_Bool bIsBmpPreview ); 171 ~BackgroundPreviewImpl(); 172 173 void NotifyChange( const Color& rColor ); 174 void NotifyChange( const Bitmap* pBitmap ); 175 176 protected: 177 virtual void Paint( const Rectangle& rRect ); 178 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 179 180 private: 181 const sal_Bool bIsBmp; 182 Bitmap* pBitmap; 183 Point aDrawPos; 184 Size aDrawSize; 185 Rectangle aDrawRect; 186 sal_uInt8 nTransparency; 187 }; 188 189 //----------------------------------------------------------------------- 190 191 BackgroundPreviewImpl::BackgroundPreviewImpl 192 ( 193 Window* pParent, 194 const ResId& rResId, 195 sal_Bool bIsBmpPreview 196 ) : 197 198 /* [Beschreibung] 199 200 */ 201 202 Window( pParent, rResId ), 203 204 bIsBmp ( bIsBmpPreview ), 205 pBitmap ( NULL ), 206 aDrawRect( Point(0,0), GetOutputSizePixel() ), 207 nTransparency(0) 208 209 { 210 SetBorderStyle(WINDOW_BORDER_MONO); 211 Paint( aDrawRect ); 212 } 213 214 //----------------------------------------------------------------------- 215 216 BackgroundPreviewImpl::~BackgroundPreviewImpl() 217 218 /* [Beschreibung] 219 220 */ 221 222 { 223 delete pBitmap; 224 } 225 226 //----------------------------------------------------------------------- 227 void BackgroundPreviewImpl::NotifyChange( const Color& rColor ) 228 { 229 if ( !bIsBmp ) 230 { 231 const static Color aTranspCol( COL_TRANSPARENT ); 232 233 nTransparency = lcl_TransparencyToPercent( rColor.GetTransparency() ); 234 235 SetFillColor( rColor == aTranspCol ? GetSettings().GetStyleSettings().GetFieldColor() : (Color) rColor.GetRGBColor() ); 236 Paint( aDrawRect ); 237 } 238 } 239 240 //----------------------------------------------------------------------- 241 242 void BackgroundPreviewImpl::NotifyChange( const Bitmap* pNewBitmap ) 243 /* [Beschreibung] 244 245 */ 246 247 { 248 if ( bIsBmp && (pNewBitmap || pBitmap) ) 249 { 250 if ( pNewBitmap && pBitmap ) 251 *pBitmap = *pNewBitmap; 252 else if ( pNewBitmap && !pBitmap ) 253 pBitmap = new Bitmap( *pNewBitmap ); 254 else if ( !pNewBitmap ) 255 DELETEZ( pBitmap ); 256 257 if ( pBitmap ) 258 { 259 Size aSize = GetOutputSizePixel(); 260 // InnerSize == Size without one pixel border 261 Size aInnerSize = aSize; 262 aInnerSize.Width() -= 2; 263 aInnerSize.Height() -= 2; 264 aDrawSize = pBitmap->GetSizePixel(); 265 266 // bitmap bigger than preview window? 267 if ( aDrawSize.Width() > aInnerSize.Width() ) 268 { 269 aDrawSize.Height() = aDrawSize.Height() * aInnerSize.Width() / aDrawSize.Width(); 270 if ( aDrawSize.Height() > aInnerSize.Height() ) 271 { 272 aDrawSize.Width() = aDrawSize.Height(); 273 aDrawSize.Height() = aInnerSize.Height(); 274 } 275 else 276 aDrawSize.Width() = aInnerSize.Width(); 277 } 278 else if ( aDrawSize.Height() > aInnerSize.Height() ) 279 { 280 aDrawSize.Width() = aDrawSize.Width() * aInnerSize.Height() / aDrawSize.Height(); 281 if ( aDrawSize.Width() > aInnerSize.Width() ) 282 { 283 aDrawSize.Height() = aDrawSize.Width(); 284 aDrawSize.Width() = aInnerSize.Width(); 285 } 286 else 287 aDrawSize.Height() = aInnerSize.Height(); 288 } 289 290 aDrawPos.X() = (aSize.Width() - aDrawSize.Width()) / 2; 291 aDrawPos.Y() = (aSize.Height() - aDrawSize.Height()) / 2; 292 } 293 Invalidate( aDrawRect ); 294 Update(); 295 } 296 } 297 298 //----------------------------------------------------------------------- 299 300 void BackgroundPreviewImpl::Paint( const Rectangle& ) 301 { 302 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 303 SetBackground(Wallpaper(rStyleSettings.GetWindowColor())); 304 SetLineColor(); 305 if(bIsBmp) 306 SetFillColor( Color(COL_TRANSPARENT) ); 307 DrawRect( aDrawRect ); 308 if ( bIsBmp ) 309 { 310 if ( pBitmap ) 311 DrawBitmap( aDrawPos, aDrawSize, *pBitmap ); 312 else 313 { 314 Size aSize = GetOutputSizePixel(); 315 DrawLine( Point(0,0), Point(aSize.Width(),aSize.Height()) ); 316 DrawLine( Point(0,aSize.Height()), Point(aSize.Width(),0) ); 317 } 318 } 319 } 320 /* -----------------------------27.02.2002 11:07------------------------------ 321 322 ---------------------------------------------------------------------------*/ 323 void BackgroundPreviewImpl::DataChanged( const DataChangedEvent& rDCEvt ) 324 { 325 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 326 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 327 { 328 Invalidate(); 329 } 330 Window::DataChanged( rDCEvt ); 331 } 332 333 // class SvxBackgroundTabPage -------------------------------------------- 334 335 #define HDL(hdl) LINK(this,SvxBackgroundTabPage,hdl) 336 337 SvxBackgroundTabPage::SvxBackgroundTabPage( Window* pParent, 338 const SfxItemSet& rCoreSet ) : 339 340 /* [Beschreibung] 341 342 */ 343 344 SvxTabPage( pParent, CUI_RES( RID_SVXPAGE_BACKGROUND ), rCoreSet ), 345 346 aSelectTxt ( this, CUI_RES( FT_SELECTOR ) ), 347 aLbSelect ( this, CUI_RES( LB_SELECTOR ) ), 348 aStrBrowse ( CUI_RES( STR_BROWSE ) ), 349 aStrUnlinked ( CUI_RES( STR_UNLINKED ) ), 350 aTblDesc ( this, CUI_RES( FT_TBL_DESC ) ), 351 aTblLBox ( this, CUI_RES( LB_TBL_BOX ) ), 352 aParaLBox ( this, CUI_RES( LB_PARA_BOX ) ), 353 354 aBorderWin ( this, CUI_RES(CT_BORDER) ), 355 aBackgroundColorSet ( &aBorderWin, CUI_RES( SET_BGDCOLOR ) ), 356 aBackgroundColorBox ( this, CUI_RES( GB_BGDCOLOR ) ), 357 pPreviewWin1 ( new BackgroundPreviewImpl( this, CUI_RES( WIN_PREVIEW1 ), sal_False ) ), 358 359 aColTransFT ( this, CUI_RES( FT_COL_TRANS ) ), 360 aColTransMF ( this, CUI_RES( MF_COL_TRANS ) ), 361 aBtnPreview ( this, CUI_RES( BTN_PREVIEW ) ), 362 aGbFile ( this, CUI_RES( GB_FILE ) ), 363 aBtnBrowse ( this, CUI_RES( BTN_BROWSE ) ), 364 aBtnLink ( this, CUI_RES( BTN_LINK ) ), 365 aGbPosition ( this, CUI_RES( GB_POSITION ) ), 366 aBtnPosition ( this, CUI_RES( BTN_POSITION ) ), 367 aBtnArea ( this, CUI_RES( BTN_AREA ) ), 368 aBtnTile ( this, CUI_RES( BTN_TILE ) ), 369 aWndPosition ( this, CUI_RES( WND_POSITION ), RP_MM ), 370 aFtFile ( this, CUI_RES( FT_FILE ) ), 371 aGraphTransFL ( this, CUI_RES( FL_GRAPH_TRANS ) ), 372 aGraphTransMF ( this, CUI_RES( MF_GRAPH_TRANS ) ), 373 pPreviewWin2 ( new BackgroundPreviewImpl( 374 this, CUI_RES( WIN_PREVIEW2 ), sal_True ) ), 375 376 nHtmlMode ( 0 ), 377 bAllowShowSelector ( sal_True ), 378 bIsGraphicValid ( sal_False ), 379 bLinkOnly ( sal_False ), 380 bResized ( sal_False ), 381 bColTransparency ( sal_False ), 382 bGraphTransparency ( sal_False ), 383 384 pPageImpl ( new SvxBackgroundPage_Impl ), 385 pImportDlg ( NULL ), 386 pTableBck_Impl ( NULL ), 387 pParaBck_Impl ( NULL ) 388 389 { 390 // diese Page braucht ExchangeSupport 391 SetExchangeSupport(); 392 393 const SfxPoolItem* pItem; 394 SfxObjectShell* pShell; 395 396 if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_HTML_MODE, sal_False, &pItem ) 397 || ( 0 != ( pShell = SfxObjectShell::Current()) && 398 0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) 399 { 400 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue(); 401 } 402 403 FillColorValueSets_Impl(); 404 405 aBackgroundColorSet.SetSelectHdl( HDL(BackgroundColorHdl_Impl) ); 406 FreeResource(); 407 408 aBtnBrowse.SetAccessibleRelationMemberOf(&aGbFile); 409 aWndPosition.SetAccessibleRelationMemberOf(&aGbPosition); 410 aWndPosition.SetAccessibleRelationLabeledBy(&aBtnPosition); 411 aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorBox); 412 } 413 414 //------------------------------------------------------------------------ 415 416 SvxBackgroundTabPage::~SvxBackgroundTabPage() 417 418 /* [Beschreibung] 419 420 */ 421 422 { 423 delete pPreviewWin1; 424 delete pPreviewWin2; 425 delete pPageImpl->pLoadTimer; 426 delete pPageImpl; 427 delete pImportDlg; 428 429 if( pTableBck_Impl) 430 { 431 delete pTableBck_Impl->pCellBrush; 432 delete pTableBck_Impl->pRowBrush; 433 delete pTableBck_Impl->pTableBrush; 434 delete pTableBck_Impl; 435 } 436 437 if(pParaBck_Impl) 438 { 439 delete pParaBck_Impl->pParaBrush; 440 delete pParaBck_Impl->pCharBrush; 441 delete pParaBck_Impl; 442 } 443 } 444 445 //------------------------------------------------------------------------ 446 447 sal_uInt16* SvxBackgroundTabPage::GetRanges() 448 449 /* [Beschreibung] 450 451 gibt den Bereich der Which-Werte zur"uck 452 */ 453 454 { 455 return pRanges; 456 } 457 458 //------------------------------------------------------------------------ 459 460 SfxTabPage* SvxBackgroundTabPage::Create( Window* pParent, 461 const SfxItemSet& rAttrSet ) 462 463 /* [Beschreibung] 464 465 Create-Methode f"ur den TabDialog 466 */ 467 468 { 469 return ( new SvxBackgroundTabPage( pParent, rAttrSet ) ); 470 } 471 472 //------------------------------------------------------------------------ 473 474 void SvxBackgroundTabPage::Reset( const SfxItemSet& rSet ) 475 476 /* [Beschreibung] 477 478 */ 479 480 { 481 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden, 482 // es muss aber im rSet vorhanden sein! 483 // const SfxPoolItem* pX = GetOldItem( rSet, SID_VIEW_FLD_PIC ); 484 // if( pX && pX->ISA(SfxWallpaperItem)) 485 if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False)) 486 { 487 ResetFromWallpaperItem( rSet ); 488 return; 489 } 490 491 // Zustand des Vorschau-Buttons durch UserData persistent 492 String aUserData = GetUserData(); 493 aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) ); 494 495 // nach Reset kein ShowSelector() mehr aufrufen d"urfen 496 bAllowShowSelector = sal_False; 497 498 499 // Input-BrushItem besorgen und auswerten 500 const SvxBrushItem* pBgdAttr = NULL; 501 sal_uInt16 nSlot = SID_ATTR_BRUSH; 502 const SfxPoolItem* pItem; 503 sal_uInt16 nDestValue = USHRT_MAX; 504 505 if ( SFX_ITEM_SET == rSet.GetItemState( SID_BACKGRND_DESTINATION, 506 sal_False, &pItem ) ) 507 { 508 nDestValue = ((const SfxUInt16Item*)pItem)->GetValue(); 509 aTblLBox.SelectEntryPos(nDestValue); 510 511 switch ( nDestValue ) 512 { 513 case TBL_DEST_CELL: 514 nSlot = SID_ATTR_BRUSH; 515 break; 516 case TBL_DEST_ROW: 517 nSlot = SID_ATTR_BRUSH_ROW; 518 break; 519 case TBL_DEST_TBL: 520 nSlot = SID_ATTR_BRUSH_TABLE; 521 break; 522 } 523 } 524 else if( SFX_ITEM_SET == rSet.GetItemState( 525 SID_PARA_BACKGRND_DESTINATION, sal_False, &pItem ) ) 526 { 527 nDestValue = ((const SfxUInt16Item*)pItem)->GetValue(); 528 // ist gerade Zeichen aktiviert? 529 sal_uInt16 nParaSel = aParaLBox.GetSelectEntryPos(); 530 if(1 == nParaSel) 531 { 532 // dann war das ein "Standard" - Aufruf 533 nDestValue = nParaSel; 534 } 535 aParaLBox.SelectEntryPos(nDestValue); 536 537 switch ( nDestValue ) 538 { 539 case PARA_DEST_PARA: 540 nSlot = SID_ATTR_BRUSH; 541 break; 542 case PARA_DEST_CHAR: 543 nSlot = SID_ATTR_BRUSH_CHAR; 544 break; 545 } 546 } 547 //#111173# the destination item is missing when the parent style has been changed 548 if(USHRT_MAX == nDestValue && (aParaLBox.IsVisible()||aTblLBox.IsVisible())) 549 nDestValue = 0; 550 sal_uInt16 nWhich = GetWhich( nSlot ); 551 552 if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE ) 553 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) ); 554 555 aBtnTile.Check(); 556 557 if ( pBgdAttr ) 558 { 559 FillControls_Impl(*pBgdAttr, aUserData); 560 aBgdColor = ( (SvxBrushItem*)pBgdAttr )->GetColor(); 561 } 562 else 563 { 564 aSelectTxt.Hide(); 565 aLbSelect.Hide(); 566 aLbSelect.SelectEntryPos( 0 ); 567 ShowColorUI_Impl(); 568 569 const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_BRUSH ); 570 571 if ( pOld ) 572 aBgdColor = ( (SvxBrushItem*)pOld )->GetColor(); 573 } 574 575 if ( nDestValue != USHRT_MAX ) 576 { 577 if(aTblLBox.IsVisible()) 578 { 579 sal_uInt16 nValue = aTblLBox.GetSelectEntryPos(); 580 581 if ( pTableBck_Impl ) 582 { 583 DELETEZ( pTableBck_Impl->pCellBrush); 584 DELETEZ( pTableBck_Impl->pRowBrush); 585 DELETEZ( pTableBck_Impl->pTableBrush); 586 } 587 else 588 pTableBck_Impl = new SvxBackgroundTable_Impl(); 589 590 pTableBck_Impl->nActPos = nValue; 591 592 nWhich = GetWhich( SID_ATTR_BRUSH ); 593 if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE ) 594 { 595 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) ); 596 pTableBck_Impl->pCellBrush = new SvxBrushItem(*pBgdAttr); 597 } 598 pTableBck_Impl->nCellWhich = nWhich; 599 600 if ( rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False ) >= SFX_ITEM_AVAILABLE ) 601 { 602 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_ROW ) ); 603 pTableBck_Impl->pRowBrush = new SvxBrushItem(*pBgdAttr); 604 } 605 pTableBck_Impl->nRowWhich = SID_ATTR_BRUSH_ROW; 606 607 if ( rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False ) >= SFX_ITEM_AVAILABLE ) 608 { 609 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_TABLE ) ); 610 pTableBck_Impl->pTableBrush = new SvxBrushItem(*pBgdAttr); 611 } 612 pTableBck_Impl->nTableWhich = SID_ATTR_BRUSH_TABLE; 613 614 TblDestinationHdl_Impl(&aTblLBox); 615 aTblLBox.SaveValue(); 616 } 617 else 618 { 619 sal_uInt16 nValue = aParaLBox.GetSelectEntryPos(); 620 621 if ( pParaBck_Impl ) 622 { 623 delete pParaBck_Impl->pParaBrush; 624 delete pParaBck_Impl->pCharBrush; 625 } 626 else 627 pParaBck_Impl = new SvxBackgroundPara_Impl(); 628 629 pParaBck_Impl->nActPos = nValue; 630 631 nWhich = GetWhich( SID_ATTR_BRUSH ); 632 if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE ) 633 { 634 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) ); 635 pParaBck_Impl->pParaBrush = new SvxBrushItem(*pBgdAttr); 636 } 637 638 nWhich = GetWhich( SID_ATTR_BRUSH_CHAR ); 639 SfxItemState eState = rSet.GetItemState( nWhich, sal_True ); 640 eState = rSet.GetItemState( nWhich, sal_False ); 641 if ( rSet.GetItemState( nWhich, sal_True ) > SFX_ITEM_AVAILABLE ) 642 { 643 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) ); 644 pParaBck_Impl->pCharBrush = new SvxBrushItem(*pBgdAttr); 645 } 646 else 647 pParaBck_Impl->pCharBrush = new SvxBrushItem(SID_ATTR_BRUSH_CHAR); 648 649 ParaDestinationHdl_Impl(&aParaLBox); 650 aParaLBox.SaveValue(); 651 } 652 } 653 if(!bResized) 654 { 655 if(!aLbSelect.IsVisible() && !aTblLBox.IsVisible() && !aParaLBox.IsVisible()) 656 { 657 long nY(LogicToPixel(Point(11,14), MAP_APPFONT).X()); 658 long nX(LogicToPixel(Point(11,14), MAP_APPFONT).Y()); 659 Point aPos(aBorderWin.GetPosPixel()); 660 aPos.X() = nX; 661 aPos.Y() = nY; 662 aBorderWin.SetPosPixel(aPos); 663 aPos = pPreviewWin1->GetPosPixel(); 664 aPos.Y() = nY; 665 pPreviewWin1->SetPosPixel(aPos); 666 aBackgroundColorBox.Hide(); 667 aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorSet); 668 } 669 } 670 } 671 672 void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet& rSet ) 673 { 674 ShowSelector(); 675 676 // Zustand des Vorschau-Buttons durch UserData persistent 677 String aUserData = GetUserData(); 678 aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) ); 679 680 // Input-BrushItem besorgen und auswerten 681 const SvxBrushItem* pBgdAttr = NULL; 682 sal_uInt16 nSlot = SID_VIEW_FLD_PIC; 683 sal_uInt16 nWhich = GetWhich( nSlot ); 684 SvxBrushItem* pTemp = 0; 685 const CntWallpaperItem* pItem = 0; 686 687 if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE ) 688 { 689 pItem = (const CntWallpaperItem*)&rSet.Get( nWhich ); 690 pTemp = new SvxBrushItem( *pItem, nWhich ); 691 pBgdAttr = pTemp; 692 } 693 694 aBtnTile.Check(); 695 696 if ( pBgdAttr ) 697 { 698 FillControls_Impl(*pBgdAttr, aUserData); 699 // Auch bei Anzeige der Grafik, soll die Brush erhalten bleiben 700 if( aBgdColor != pBgdAttr->GetColor() ) 701 { 702 aBgdColor = pBgdAttr->GetColor(); 703 sal_uInt16 nCol = GetItemId_Impl( aBackgroundColorSet, aBgdColor ); 704 aBackgroundColorSet.SelectItem( nCol ); 705 pPreviewWin1->NotifyChange( aBgdColor ); 706 } 707 } 708 else 709 { 710 aLbSelect.SelectEntryPos( 0 ); 711 ShowColorUI_Impl(); 712 713 const SfxPoolItem* pOld = GetOldItem( rSet, SID_VIEW_FLD_PIC ); 714 if ( pOld ) 715 aBgdColor = Color( ((CntWallpaperItem*)pOld)->GetColor() ); 716 } 717 718 // We now have always a link to the background 719 bLinkOnly = sal_True; 720 aBtnLink.Check( sal_True ); 721 aBtnLink.Show( sal_False ); 722 // if( !pItem || !pItem->GetWallpaper(sal_False).IsBitmap() ) 723 // aBtnLink.Check(); 724 725 delete pTemp; 726 } 727 728 729 730 //------------------------------------------------------------------------ 731 732 void SvxBackgroundTabPage::FillUserData() 733 734 /* [Beschreibung] 735 736 Beim Destruieren einer SfxTabPage wird diese virtuelle Methode gerufen, 737 damit die TabPage interne Informationen sichern kann. 738 739 In diesem Fall wird der Zustand des Vorschau-Buttons gesichert. 740 */ 741 742 { 743 SetUserData( String( aBtnPreview.IsChecked() ? sal_Unicode('1') : sal_Unicode('0') ) ); 744 } 745 746 //------------------------------------------------------------------------ 747 748 sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet ) 749 750 /* [Beschreibung] 751 752 */ 753 754 { 755 if ( pPageImpl->pLoadTimer && pPageImpl->pLoadTimer->IsActive() ) 756 { 757 pPageImpl->pLoadTimer->Stop(); 758 LoadTimerHdl_Impl( pPageImpl->pLoadTimer ); 759 } 760 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden, 761 // es muss aber im rSet vorhanden sein! 762 763 // const SfxPoolItem* pX = GetOldItem( rCoreSet, SID_VIEW_FLD_PIC ); 764 // if( pX && pX->ISA(SfxWallpaperItem)) 765 if(SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False)) 766 return FillItemSetWithWallpaperItem( rCoreSet, SID_VIEW_FLD_PIC ); 767 768 sal_Bool bModified = sal_False; 769 sal_uInt16 nSlot = SID_ATTR_BRUSH; 770 771 if ( aTblLBox.IsVisible() ) 772 { 773 switch( aTblLBox.GetSelectEntryPos() ) 774 { 775 case TBL_DEST_CELL: 776 nSlot = SID_ATTR_BRUSH; 777 break; 778 case TBL_DEST_ROW: 779 nSlot = SID_ATTR_BRUSH_ROW; 780 break; 781 case TBL_DEST_TBL: 782 nSlot = SID_ATTR_BRUSH_TABLE; 783 break; 784 } 785 } 786 else if(aParaLBox.GetData() == &aParaLBox) 787 { 788 switch(aParaLBox.GetSelectEntryPos()) 789 { 790 case PARA_DEST_PARA: 791 nSlot = SID_ATTR_BRUSH; 792 break; 793 case PARA_DEST_CHAR: 794 nSlot = SID_ATTR_BRUSH_CHAR; 795 break; 796 } 797 } 798 sal_uInt16 nWhich = GetWhich( nSlot ); 799 800 const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot ); 801 SfxItemState eOldItemState = rCoreSet.GetItemState(nSlot, sal_False); 802 const SfxItemSet& rOldSet = GetItemSet(); 803 804 sal_Bool bGraphTransparencyChanged = bGraphTransparency && (aGraphTransMF.GetText() != aGraphTransMF.GetSavedValue()); 805 if ( pOld ) 806 { 807 const SvxBrushItem& rOldItem = (const SvxBrushItem&)*pOld; 808 SvxGraphicPosition eOldPos = rOldItem.GetGraphicPos(); 809 const sal_Bool bIsBrush = ( 0 == aLbSelect.GetSelectEntryPos() ); 810 811 // transparency has to be set if enabled, the color not already set to "No fill" and 812 if( bColTransparency && 813 aBgdColor.GetTransparency() < 0xff) 814 { 815 aBgdColor.SetTransparency(lcl_PercentToTransparency(static_cast<long>(aColTransMF.GetValue()))); 816 } 817 if ( ( (GPOS_NONE == eOldPos) && bIsBrush ) 818 || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt? 819 { 820 // Hintergrund-Art wurde nicht gewechselt: 821 822 if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() ) 823 { 824 // Brush-Behandlung: 825 if ( rOldItem.GetColor() != aBgdColor || 826 (SFX_ITEM_AVAILABLE >= eOldItemState && !aBackgroundColorSet.IsNoSelection())) 827 { 828 bModified = sal_True; 829 rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) ); 830 } 831 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 832 rCoreSet.ClearItem( nWhich ); 833 } 834 else 835 { 836 // Bitmap-Behandlung: 837 838 SvxGraphicPosition eNewPos = GetGraphicPosition_Impl(); 839 const sal_Bool bIsLink = aBtnLink.IsChecked(); 840 const sal_Bool bWasLink = (NULL != rOldItem.GetGraphicLink() ); 841 842 843 if ( !bIsLink && !bIsGraphicValid ) 844 bIsGraphicValid = LoadLinkedGraphic_Impl(); 845 846 if ( bGraphTransparencyChanged || 847 eNewPos != eOldPos 848 || bIsLink != bWasLink 849 || ( bWasLink && *rOldItem.GetGraphicLink() 850 != aBgdGraphicPath ) 851 || ( !bWasLink && rOldItem.GetGraphic()->GetBitmap() 852 != aBgdGraphic.GetBitmap() ) 853 ) 854 { 855 bModified = sal_True; 856 857 SvxBrushItem aTmpBrush(nWhich); 858 if ( bIsLink ) 859 { 860 aTmpBrush = SvxBrushItem( aBgdGraphicPath, 861 aBgdGraphicFilter, 862 eNewPos, 863 nWhich ); 864 } 865 else 866 aTmpBrush = SvxBrushItem( aBgdGraphic, 867 eNewPos, 868 nWhich ); 869 lcl_SetTransparency(aTmpBrush, static_cast<long>(aGraphTransMF.GetValue())); 870 871 rCoreSet.Put(aTmpBrush); 872 } 873 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 874 rCoreSet.ClearItem( nWhich ); 875 } 876 } 877 else // Brush <-> Bitmap gewechselt! 878 { 879 if ( bIsBrush ) 880 rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) ); 881 else 882 { 883 SvxBrushItem* pTmpBrush = 0; 884 if ( aBtnLink.IsChecked() ) 885 { 886 pTmpBrush = new SvxBrushItem( aBgdGraphicPath, 887 aBgdGraphicFilter, 888 GetGraphicPosition_Impl(), 889 nWhich ); 890 } 891 else 892 { 893 if ( !bIsGraphicValid ) 894 bIsGraphicValid = LoadLinkedGraphic_Impl(); 895 896 if ( bIsGraphicValid ) 897 pTmpBrush = new SvxBrushItem( aBgdGraphic, 898 GetGraphicPosition_Impl(), 899 nWhich ); 900 } 901 if(pTmpBrush) 902 { 903 lcl_SetTransparency(*pTmpBrush, static_cast<long>(aGraphTransMF.GetValue())); 904 rCoreSet.Put(*pTmpBrush); 905 delete pTmpBrush; 906 } 907 } 908 bModified = ( bIsBrush || aBtnLink.IsChecked() || bIsGraphicValid ); 909 } 910 } 911 else if ( SID_ATTR_BRUSH_CHAR == nSlot && aBgdColor != Color( COL_WHITE ) ) 912 { 913 rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) ); 914 bModified = sal_True; 915 } 916 917 if( aTblLBox.IsVisible() ) 918 { 919 // Der aktuelle Zustand wurde bereits geputtet 920 if( nSlot != SID_ATTR_BRUSH && pTableBck_Impl->pCellBrush) 921 { 922 const SfxPoolItem* pOldCell = 923 GetOldItem( rCoreSet, SID_ATTR_BRUSH ); 924 925 if ( *pTableBck_Impl->pCellBrush != *pOldCell ) 926 { 927 rCoreSet.Put( *pTableBck_Impl->pCellBrush ); 928 bModified |= sal_True; 929 } 930 } 931 932 if( nSlot != SID_ATTR_BRUSH_ROW && pTableBck_Impl->pRowBrush) 933 { 934 const SfxPoolItem* pOldRow = 935 GetOldItem( rCoreSet, SID_ATTR_BRUSH_ROW ); 936 937 if ( *pTableBck_Impl->pRowBrush != *pOldRow ) 938 { 939 rCoreSet.Put( *pTableBck_Impl->pRowBrush ); 940 bModified |= sal_True; 941 } 942 } 943 944 if( nSlot != SID_ATTR_BRUSH_TABLE && pTableBck_Impl->pTableBrush) 945 { 946 const SfxPoolItem* pOldTable = 947 GetOldItem( rCoreSet, SID_ATTR_BRUSH_TABLE ); 948 949 if ( *pTableBck_Impl->pTableBrush != *pOldTable ) 950 { 951 rCoreSet.Put( *pTableBck_Impl->pTableBrush ); 952 bModified |= sal_True; 953 } 954 } 955 956 if( aTblLBox.GetSavedValue() != aTblLBox.GetSelectEntryPos() ) 957 { 958 rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION, 959 aTblLBox.GetSelectEntryPos() ) ); 960 bModified |= sal_True; 961 } 962 } 963 else if(aParaLBox.GetData() == &aParaLBox) 964 { 965 // Der aktuelle Zustand wurde bereits geputtet 966 if( nSlot != SID_ATTR_BRUSH && aParaLBox.IsVisible()) // nicht im Suchen-Format-Dialog 967 { 968 const SfxPoolItem* pOldPara = 969 GetOldItem( rCoreSet, SID_ATTR_BRUSH ); 970 971 if ( *pParaBck_Impl->pParaBrush != *pOldPara ) 972 { 973 rCoreSet.Put( *pParaBck_Impl->pParaBrush ); 974 bModified |= sal_True; 975 } 976 } 977 978 if( nSlot != SID_ATTR_BRUSH_CHAR ) 979 { 980 const SfxPoolItem* pOldChar = 981 GetOldItem( rCoreSet, SID_ATTR_BRUSH_CHAR ); 982 DBG_ASSERT(pParaBck_Impl, "pParaBck_Impl == NULL ?"); 983 if ( pOldChar && 984 //#111173# crash report shows that pParaBck_Impl can be NULL, the cause is unknown 985 pParaBck_Impl && 986 (*pParaBck_Impl->pCharBrush != *pOldChar || 987 *pParaBck_Impl->pCharBrush != SvxBrushItem(SID_ATTR_BRUSH_CHAR))) 988 { 989 rCoreSet.Put( *pParaBck_Impl->pCharBrush ); 990 bModified |= sal_True; 991 } 992 } 993 994 if( aParaLBox.GetSavedValue() != aParaLBox.GetSelectEntryPos() ) 995 { 996 rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION, 997 aParaLBox.GetSelectEntryPos() ) ); 998 bModified |= sal_True; 999 } 1000 } 1001 return bModified; 1002 } 1003 1004 sal_Bool SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet& rCoreSet, sal_uInt16 nSlot) 1005 { 1006 sal_uInt16 nWhich = GetWhich( nSlot ); 1007 const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot ); 1008 const SfxItemSet& rOldSet = GetItemSet(); 1009 DBG_ASSERT(pOld,"FillItemSetWithWallpaperItem: Item not found"); 1010 1011 SvxBrushItem rOldItem( (const CntWallpaperItem&)*pOld, nWhich ); 1012 SvxGraphicPosition eOldPos = rOldItem.GetGraphicPos(); 1013 const sal_Bool bIsBrush = ( 0 == aLbSelect.GetSelectEntryPos() ); 1014 sal_Bool bModified = sal_False; 1015 1016 if ( ( (GPOS_NONE == eOldPos) && bIsBrush ) 1017 || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt? 1018 { 1019 // Hintergrund-Art wurde nicht gewechselt: 1020 1021 if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() ) 1022 { 1023 // Brush-Behandlung: 1024 if ( rOldItem.GetColor() != aBgdColor ) 1025 { 1026 bModified = sal_True; 1027 CntWallpaperItem aItem( nWhich ); 1028 aItem.SetColor( aBgdColor ); 1029 rCoreSet.Put( aItem ); 1030 } 1031 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1032 rCoreSet.ClearItem( nWhich ); 1033 } 1034 else 1035 { 1036 // Bitmap-Behandlung: 1037 SvxGraphicPosition eNewPos = GetGraphicPosition_Impl(); 1038 1039 int bBitmapChanged = ( ( eNewPos != eOldPos ) || 1040 ( *rOldItem.GetGraphicLink() != aBgdGraphicPath ) ); 1041 int bBrushChanged = ( rOldItem.GetColor() != aBgdColor ); 1042 if( bBitmapChanged || bBrushChanged ) 1043 { 1044 bModified = sal_True; 1045 1046 CntWallpaperItem aItem( nWhich ); 1047 WallpaperStyle eWallStyle = SvxBrushItem::GraphicPos2WallpaperStyle(eNewPos); 1048 aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) ); 1049 aItem.SetColor( aBgdColor ); 1050 aItem.SetBitmapURL( aBgdGraphicPath ); 1051 rCoreSet.Put( aItem ); 1052 } 1053 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1054 rCoreSet.ClearItem( nWhich ); 1055 } 1056 } 1057 else // Brush <-> Bitmap gewechselt! 1058 { 1059 CntWallpaperItem aItem( nWhich ); 1060 if ( bIsBrush ) 1061 { 1062 aItem.SetColor( aBgdColor ); 1063 rCoreSet.Put( aItem ); 1064 } 1065 else 1066 { 1067 WallpaperStyle eWallStyle = 1068 SvxBrushItem::GraphicPos2WallpaperStyle( GetGraphicPosition_Impl() ); 1069 aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) ); 1070 aItem.SetColor( aBgdColor ); 1071 aItem.SetBitmapURL( aBgdGraphicPath ); 1072 rCoreSet.Put( aItem ); 1073 } 1074 1075 bModified = sal_True; 1076 } 1077 return bModified; 1078 } 1079 1080 //----------------------------------------------------------------------- 1081 1082 int SvxBackgroundTabPage::DeactivatePage( SfxItemSet* _pSet ) 1083 1084 /* [Beschreibung] 1085 1086 virtuelle Methode, wird beim Deaktivieren gerufen 1087 */ 1088 1089 { 1090 if ( pPageImpl->bIsImportDlgInExecute ) 1091 return KEEP_PAGE; 1092 1093 if ( _pSet ) 1094 FillItemSet( *_pSet ); 1095 1096 return LEAVE_PAGE; 1097 } 1098 1099 //----------------------------------------------------------------------- 1100 1101 void SvxBackgroundTabPage::PointChanged( Window* , RECT_POINT ) 1102 1103 /* [Beschreibung] 1104 1105 */ 1106 1107 { 1108 // muss implementiert werden, damit Position-Control funktioniert 1109 } 1110 1111 //----------------------------------------------------------------------- 1112 1113 void SvxBackgroundTabPage::ShowSelector() 1114 1115 /* [Beschreibung] 1116 1117 */ 1118 1119 { 1120 if( bAllowShowSelector) 1121 { 1122 aSelectTxt.Show(); 1123 aLbSelect.Show(); 1124 aLbSelect.SetSelectHdl( HDL(SelectHdl_Impl) ); 1125 aBtnLink.SetClickHdl( HDL(FileClickHdl_Impl) ); 1126 aBtnPreview.SetClickHdl( HDL(FileClickHdl_Impl) ); 1127 aBtnBrowse.SetClickHdl( HDL(BrowseHdl_Impl) ); 1128 aBtnArea.SetClickHdl( HDL(RadioClickHdl_Impl) ); 1129 aBtnTile.SetClickHdl( HDL(RadioClickHdl_Impl) ); 1130 aBtnPosition.SetClickHdl( HDL(RadioClickHdl_Impl) ); 1131 1132 // Verz"ogertes Laden "uber Timer (wg. UI-Update) 1133 pPageImpl->pLoadTimer = new Timer; 1134 pPageImpl->pLoadTimer->SetTimeout( 500 ); // 500ms verz"ogern 1135 pPageImpl->pLoadTimer->SetTimeoutHdl( 1136 LINK( this, SvxBackgroundTabPage, LoadTimerHdl_Impl ) ); 1137 1138 bAllowShowSelector = sal_False; 1139 1140 if(nHtmlMode & HTMLMODE_ON) 1141 { 1142 if(!(nHtmlMode & HTMLMODE_GRAPH_POS)) 1143 aBtnPosition.Enable(sal_False); 1144 aBtnArea.Enable(sal_False); 1145 } 1146 } 1147 } 1148 1149 //------------------------------------------------------------------------ 1150 1151 1152 void SvxBackgroundTabPage::RaiseLoadError_Impl() 1153 1154 /* [Beschreibung] 1155 1156 */ 1157 1158 { 1159 SfxErrorContext aContext( ERRCTX_SVX_BACKGROUND, 1160 String(), 1161 this, 1162 RID_SVXERRCTX, 1163 &CUI_MGR() ); 1164 1165 ErrorHandler::HandleError( 1166 *new StringErrorInfo( ERRCODE_SVX_GRAPHIC_NOTREADABLE, 1167 aBgdGraphicPath ) ); 1168 } 1169 1170 //------------------------------------------------------------------------ 1171 1172 sal_Bool SvxBackgroundTabPage::LoadLinkedGraphic_Impl() 1173 1174 /* [Beschreibung] 1175 1176 */ 1177 1178 { 1179 sal_Bool bResult = ( aBgdGraphicPath.Len() > 0 ) && 1180 ( GRFILTER_OK == GraphicFilter::LoadGraphic( aBgdGraphicPath, 1181 aBgdGraphicFilter, 1182 aBgdGraphic ) ); 1183 return bResult; 1184 } 1185 1186 //------------------------------------------------------------------------ 1187 1188 1189 void SvxBackgroundTabPage::FillColorValueSets_Impl() 1190 1191 /* [Beschreibung] 1192 1193 F"ullen des Farb-Sets 1194 */ 1195 1196 { 1197 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 1198 const SfxPoolItem* pItem = NULL; 1199 XColorTable* pColorTable = NULL; 1200 const Size aSize15x15 = Size( 15, 15 ); 1201 FASTBOOL bOwn = sal_False; 1202 1203 if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) ) 1204 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); 1205 1206 if ( !pColorTable ) 1207 { 1208 bOwn = sal_True; 1209 pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() ); 1210 } 1211 1212 if ( pColorTable ) 1213 { 1214 short i = 0; 1215 long nCount = pColorTable->Count(); 1216 XColorEntry* pEntry = NULL; 1217 Color aColWhite( COL_WHITE ); 1218 String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) ); 1219 WinBits nBits = ( aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD ); 1220 aBackgroundColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) ); 1221 aBackgroundColorSet.SetStyle( nBits ); 1222 aBackgroundColorSet.SetAccessibleName(aBackgroundColorBox.GetText()); 1223 for ( i = 0; i < nCount; i++ ) 1224 { 1225 pEntry = pColorTable->GetColor(i); 1226 aBackgroundColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() ); 1227 } 1228 1229 while ( i < 80 ) 1230 { 1231 aBackgroundColorSet.InsertItem( i + 1, aColWhite, aStrWhite ); 1232 i++; 1233 } 1234 1235 if ( nCount > 80 ) 1236 { 1237 aBackgroundColorSet.SetStyle( nBits | WB_VSCROLL ); 1238 } 1239 } 1240 1241 if ( bOwn ) 1242 delete pColorTable; 1243 1244 aBackgroundColorSet.SetColCount( 10 ); 1245 aBackgroundColorSet.SetLineCount( 10 ); 1246 aBackgroundColorSet.CalcWindowSizePixel( aSize15x15 ); 1247 1248 } 1249 1250 //------------------------------------------------------------------------ 1251 1252 1253 1254 //------------------------------------------------------------------------ 1255 1256 void SvxBackgroundTabPage::ShowColorUI_Impl() 1257 1258 /* [Beschreibung] 1259 1260 Die Controls f"ur das Einstellen der Grafik ausblenden und die 1261 Controls f"ur die Farbeinstellung einblenden. 1262 */ 1263 1264 { 1265 if( !aBackgroundColorSet.IsVisible() ) 1266 { 1267 aBackgroundColorSet.Show(); 1268 aBackgroundColorBox.Show(); 1269 aBorderWin.Show(); 1270 pPreviewWin1->Show(); 1271 aBtnBrowse.Hide(); 1272 aFtFile.Hide(); 1273 aBtnLink.Hide(); 1274 aBtnPreview.Hide(); 1275 aGbFile.Hide(); 1276 aBtnPosition.Hide(); 1277 aBtnArea.Hide(); 1278 aBtnTile.Hide(); 1279 aWndPosition.Hide(); 1280 aGbPosition.Hide(); 1281 pPreviewWin2->Hide(); 1282 aGraphTransFL.Show(sal_False); 1283 aGraphTransMF.Show(sal_False); 1284 if(bColTransparency) 1285 { 1286 aColTransFT.Show(); 1287 aColTransMF.Show(); 1288 } 1289 } 1290 } 1291 1292 //------------------------------------------------------------------------ 1293 1294 void SvxBackgroundTabPage::ShowBitmapUI_Impl() 1295 1296 /* [Beschreibung] 1297 1298 Die Controls f"ur die Farbeinstellung ausblenden und die 1299 Controls f"ur das Einstellen der Grafik einblenden. 1300 */ 1301 1302 { 1303 if ( aLbSelect.IsVisible() && 1304 ( 1305 aBackgroundColorSet.IsVisible() 1306 || !aBtnBrowse.IsVisible() ) ) 1307 { 1308 aBackgroundColorSet.Hide(); 1309 aBackgroundColorBox.Hide(); 1310 aBorderWin.Hide(); 1311 pPreviewWin1->Hide(); 1312 aBtnBrowse.Show(); 1313 aFtFile.Show(); 1314 1315 if ( !bLinkOnly && ! nHtmlMode & HTMLMODE_ON ) 1316 aBtnLink.Show(); 1317 aBtnPreview.Show(); 1318 aGbFile.Show(); 1319 aBtnPosition.Show(); 1320 aBtnArea.Show(); 1321 aBtnTile.Show(); 1322 aWndPosition.Show(); 1323 aGbPosition.Show(); 1324 pPreviewWin2->Show(); 1325 if(bGraphTransparency) 1326 { 1327 aGraphTransFL.Show(); 1328 aGraphTransMF.Show(); 1329 } 1330 aColTransFT.Show(sal_False); 1331 aColTransMF.Show(sal_False); 1332 } 1333 } 1334 1335 //------------------------------------------------------------------------ 1336 1337 void SvxBackgroundTabPage::SetGraphicPosition_Impl( SvxGraphicPosition ePos ) 1338 1339 /* [Beschreibung] 1340 1341 Die Controls f"ur die Grafikposition einstellen. 1342 */ 1343 1344 { 1345 switch ( ePos ) 1346 { 1347 case GPOS_AREA: 1348 { 1349 aBtnArea.Check(); 1350 aWndPosition.Disable(); 1351 } 1352 break; 1353 1354 case GPOS_TILED: 1355 { 1356 aBtnTile.Check(); 1357 aWndPosition.Disable(); 1358 } 1359 break; 1360 1361 default: 1362 { 1363 aBtnPosition.Check(); 1364 aWndPosition.Enable(); 1365 RECT_POINT eNewPos = RP_MM; 1366 1367 switch ( ePos ) 1368 { 1369 case GPOS_MM: break; 1370 case GPOS_LT: eNewPos = RP_LT; break; 1371 case GPOS_MT: eNewPos = RP_MT; break; 1372 case GPOS_RT: eNewPos = RP_RT; break; 1373 case GPOS_LM: eNewPos = RP_LM; break; 1374 case GPOS_RM: eNewPos = RP_RM; break; 1375 case GPOS_LB: eNewPos = RP_LB; break; 1376 case GPOS_MB: eNewPos = RP_MB; break; 1377 case GPOS_RB: eNewPos = RP_RB; break; 1378 default: ;//prevent warning 1379 } 1380 aWndPosition.SetActualRP( eNewPos ); 1381 } 1382 break; 1383 } 1384 aWndPosition.Invalidate(); 1385 } 1386 1387 //------------------------------------------------------------------------ 1388 1389 SvxGraphicPosition SvxBackgroundTabPage::GetGraphicPosition_Impl() 1390 1391 /* [Beschreibung] 1392 1393 Die Position der Grafik zur"uckgeben. 1394 */ 1395 1396 { 1397 if ( aBtnTile.IsChecked() ) 1398 return GPOS_TILED; 1399 else if ( aBtnArea.IsChecked() ) 1400 return GPOS_AREA; 1401 else 1402 { 1403 switch ( aWndPosition.GetActualRP() ) 1404 { 1405 case RP_LT: return GPOS_LT; 1406 case RP_MT: return GPOS_MT; 1407 case RP_RT: return GPOS_RT; 1408 case RP_LM: return GPOS_LM; 1409 case RP_MM: return GPOS_MM; 1410 case RP_RM: return GPOS_RM; 1411 case RP_LB: return GPOS_LB; 1412 case RP_MB: return GPOS_MB; 1413 case RP_RB: return GPOS_RB; 1414 } 1415 } 1416 return GPOS_MM; 1417 } 1418 1419 //----------------------------------------------------------------------- 1420 // Handler 1421 //----------------------------------------------------------------------- 1422 1423 IMPL_LINK( SvxBackgroundTabPage, BackgroundColorHdl_Impl, ValueSet*, EMPTYARG ) 1424 /* 1425 Handler, called when color selection is changed 1426 */ 1427 { 1428 sal_uInt16 nItemId = aBackgroundColorSet.GetSelectItemId(); 1429 Color aColor = nItemId ? ( aBackgroundColorSet.GetItemColor( nItemId ) ) : Color( COL_TRANSPARENT ); 1430 aBgdColor = aColor; 1431 pPreviewWin1->NotifyChange( aBgdColor ); 1432 sal_Bool bEnableTransp = aBgdColor.GetTransparency() < 0xff; 1433 aColTransFT.Enable(bEnableTransp); 1434 aColTransMF.Enable(bEnableTransp); 1435 return 0; 1436 } 1437 1438 //------------------------------------------------------------------------ 1439 1440 IMPL_LINK( SvxBackgroundTabPage, SelectHdl_Impl, ListBox*, EMPTYARG ) 1441 1442 /* [Beschreibung] 1443 1444 */ 1445 1446 { 1447 if ( 0 == aLbSelect.GetSelectEntryPos() ) 1448 { 1449 ShowColorUI_Impl(); 1450 aParaLBox.Enable(); // Zeichenhintergrund kann keine Bitmap sein 1451 } 1452 else 1453 { 1454 ShowBitmapUI_Impl(); 1455 aParaLBox.Enable(sal_False);// Zeichenhintergrund kann keine Bitmap sein 1456 } 1457 return 0; 1458 } 1459 1460 //------------------------------------------------------------------------ 1461 1462 IMPL_LINK( SvxBackgroundTabPage, FileClickHdl_Impl, CheckBox*, pBox ) 1463 1464 /* [Beschreibung] 1465 1466 */ 1467 1468 { 1469 if ( &aBtnLink == pBox ) 1470 { 1471 if ( aBtnLink.IsChecked() ) 1472 { 1473 INetURLObject aObj( aBgdGraphicPath ); 1474 String aFilePath; 1475 if ( aObj.GetProtocol() == INET_PROT_FILE ) 1476 aFilePath = aObj.getFSysPath( INetURLObject::FSYS_DETECT ); 1477 else 1478 aFilePath = aBgdGraphicPath; 1479 aFtFile.SetText( aFilePath ); 1480 } 1481 else 1482 aFtFile.SetText( aStrUnlinked ); 1483 } 1484 else if ( &aBtnPreview == pBox ) 1485 { 1486 if ( aBtnPreview.IsChecked() ) 1487 { 1488 if ( !bIsGraphicValid ) 1489 bIsGraphicValid = LoadLinkedGraphic_Impl(); 1490 1491 if ( bIsGraphicValid ) 1492 { 1493 Bitmap aBmp = aBgdGraphic.GetBitmap(); 1494 pPreviewWin2->NotifyChange( &aBmp ); 1495 } 1496 else 1497 { 1498 if ( aBgdGraphicPath.Len() > 0 ) // nur bei gelinkter Grafik 1499 RaiseLoadError_Impl(); // ein Fehler 1500 pPreviewWin2->NotifyChange( NULL ); 1501 } 1502 } 1503 else 1504 pPreviewWin2->NotifyChange( NULL ); 1505 } 1506 return 0; 1507 } 1508 1509 //------------------------------------------------------------------------ 1510 1511 IMPL_LINK( SvxBackgroundTabPage, RadioClickHdl_Impl, RadioButton*, pBtn ) 1512 1513 /* [Beschreibung] 1514 1515 */ 1516 1517 { 1518 if ( pBtn == &aBtnPosition ) 1519 { 1520 if ( !aWndPosition.IsEnabled() ) 1521 { 1522 aWndPosition.Enable(); 1523 aWndPosition.Invalidate(); 1524 } 1525 } 1526 else if ( aWndPosition.IsEnabled() ) 1527 { 1528 aWndPosition.Disable(); 1529 aWndPosition.Invalidate(); 1530 } 1531 return 0; 1532 } 1533 1534 //------------------------------------------------------------------------ 1535 1536 IMPL_LINK( SvxBackgroundTabPage, BrowseHdl_Impl, PushButton* , EMPTYARG ) 1537 1538 /* [Beschreibung] 1539 1540 Handler, gerufen durch das Dr"ucken des Durchsuchen-Buttons. 1541 Grafik/Einf"ugen-Dialog erzeugen, Pfad setzen und starten. 1542 */ 1543 1544 { 1545 if ( pPageImpl->pLoadTimer->IsActive() ) 1546 return 0; 1547 sal_Bool bHtml = 0 != ( nHtmlMode & HTMLMODE_ON ); 1548 1549 pImportDlg = new SvxOpenGraphicDialog( aStrBrowse ); 1550 if ( bHtml || bLinkOnly ) 1551 pImportDlg->EnableLink(sal_False); 1552 pImportDlg->SetPath( aBgdGraphicPath, aBtnLink.IsChecked() ); 1553 1554 pPageImpl->bIsImportDlgInExecute = sal_True; 1555 short nErr = pImportDlg->Execute(); 1556 pPageImpl->bIsImportDlgInExecute = sal_False; 1557 1558 if( !nErr ) 1559 { 1560 if ( bHtml ) 1561 aBtnLink.Check(); 1562 // wenn Verkn"upfen nicht gecheckt ist und die Vorschau auch nicht, 1563 // dann die Vorschau aktivieren, damit der Anwender sieht, 1564 // welche Grafik er ausgew"ahlt hat 1565 if ( !aBtnLink.IsChecked() && !aBtnPreview.IsChecked() ) 1566 aBtnPreview.Check( sal_True ); 1567 // timer-verz"ogertes Laden der Grafik 1568 pPageImpl->pLoadTimer->Start(); 1569 } 1570 else 1571 DELETEZ( pImportDlg ); 1572 return 0; 1573 } 1574 1575 //----------------------------------------------------------------------- 1576 1577 IMPL_LINK( SvxBackgroundTabPage, LoadTimerHdl_Impl, Timer* , pTimer ) 1578 1579 /* [Beschreibung] 1580 1581 Verz"ogertes Laden der Grafik. 1582 Grafik wird nur dann geladen, wenn sie unterschiedlich zur 1583 aktuellen Grafik ist. 1584 */ 1585 1586 { 1587 if ( pTimer == pPageImpl->pLoadTimer ) 1588 { 1589 pPageImpl->pLoadTimer->Stop(); 1590 1591 if ( pImportDlg ) 1592 { 1593 INetURLObject aOld( aBgdGraphicPath ); 1594 INetURLObject aNew( pImportDlg->GetPath() ); 1595 if ( !aBgdGraphicPath.Len() || aNew != aOld ) 1596 { 1597 // neue Datei gew"ahlt 1598 aBgdGraphicPath = pImportDlg->GetPath(); 1599 aBgdGraphicFilter = pImportDlg->GetCurrentFilter(); 1600 sal_Bool bLink = ( nHtmlMode & HTMLMODE_ON ) || bLinkOnly ? sal_True : pImportDlg->IsAsLink(); 1601 aBtnLink.Check( bLink ); 1602 aBtnLink.Enable(); 1603 1604 if ( aBtnPreview.IsChecked() ) 1605 { 1606 if( !pImportDlg->GetGraphic(aBgdGraphic) ) 1607 { 1608 bIsGraphicValid = sal_True; 1609 } 1610 else 1611 { 1612 aBgdGraphicFilter.Erase(); 1613 aBgdGraphicPath.Erase(); 1614 bIsGraphicValid = sal_False; 1615 } 1616 } 1617 else 1618 bIsGraphicValid = sal_False; // Grafik erst beim Preview-Click laden 1619 1620 if ( aBtnPreview.IsChecked() && bIsGraphicValid ) 1621 { 1622 Bitmap aBmp = aBgdGraphic.GetBitmap(); 1623 pPreviewWin2->NotifyChange( &aBmp ); 1624 } 1625 else 1626 pPreviewWin2->NotifyChange( NULL ); 1627 } 1628 1629 FileClickHdl_Impl( &aBtnLink ); 1630 DELETEZ( pImportDlg ); 1631 } 1632 } 1633 return 0; 1634 } 1635 1636 //----------------------------------------------------------------------- 1637 1638 void SvxBackgroundTabPage::ShowTblControl() 1639 1640 /* [Beschreibung] 1641 1642 */ 1643 1644 { 1645 aTblLBox .SetSelectHdl( HDL(TblDestinationHdl_Impl) ); 1646 aTblLBox .SelectEntryPos(0); 1647 aTblDesc.Show(); 1648 aTblLBox.Show(); 1649 } 1650 1651 //----------------------------------------------------------------------- 1652 1653 void SvxBackgroundTabPage::ShowParaControl(sal_Bool bCharOnly) 1654 { 1655 aParaLBox.SetSelectHdl(HDL(ParaDestinationHdl_Impl)); 1656 aParaLBox.SelectEntryPos(0); 1657 if(!bCharOnly) 1658 { 1659 aTblDesc.Show(); 1660 aParaLBox.Show(); 1661 } 1662 aParaLBox.SetData(&aParaLBox); // hier erkennt man, dass dieser Mode eingeschaltet ist 1663 } 1664 //----------------------------------------------------------------------- 1665 1666 IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox ) 1667 1668 /* [Beschreibung] 1669 1670 */ 1671 1672 { 1673 sal_uInt16 nSelPos = pBox->GetSelectEntryPos(); 1674 if( pTableBck_Impl && pTableBck_Impl->nActPos != nSelPos) 1675 { 1676 SvxBrushItem** pActItem = new (SvxBrushItem*); 1677 sal_uInt16 nWhich = 0; 1678 switch(pTableBck_Impl->nActPos) 1679 { 1680 case TBL_DEST_CELL: 1681 *pActItem = pTableBck_Impl->pCellBrush; 1682 nWhich = pTableBck_Impl->nCellWhich; 1683 break; 1684 case TBL_DEST_ROW: 1685 *pActItem = pTableBck_Impl->pRowBrush; 1686 nWhich = pTableBck_Impl->nRowWhich; 1687 break; 1688 case TBL_DEST_TBL: 1689 *pActItem = pTableBck_Impl->pTableBrush; 1690 nWhich = pTableBck_Impl->nTableWhich; 1691 break; 1692 } 1693 pTableBck_Impl->nActPos = nSelPos; 1694 if(!*pActItem) 1695 *pActItem = new SvxBrushItem(nWhich); 1696 if(0 == aLbSelect.GetSelectEntryPos()) // Brush ausgewaehlt 1697 { 1698 **pActItem = SvxBrushItem( aBgdColor, nWhich ); 1699 } 1700 else 1701 { 1702 SvxGraphicPosition eNewPos = GetGraphicPosition_Impl(); 1703 const sal_Bool bIsLink = aBtnLink.IsChecked(); 1704 1705 if ( !bIsLink && !bIsGraphicValid ) 1706 bIsGraphicValid = LoadLinkedGraphic_Impl(); 1707 1708 if ( bIsLink ) 1709 **pActItem = SvxBrushItem( aBgdGraphicPath, 1710 aBgdGraphicFilter, 1711 eNewPos, 1712 (*pActItem)->Which() ); 1713 else 1714 **pActItem = SvxBrushItem( aBgdGraphic, 1715 eNewPos, 1716 (*pActItem)->Which() ); 1717 } 1718 switch(nSelPos) 1719 { 1720 case TBL_DEST_CELL: 1721 *pActItem = pTableBck_Impl->pCellBrush; 1722 aLbSelect.Enable(); 1723 nWhich = pTableBck_Impl->nCellWhich; 1724 break; 1725 case TBL_DEST_ROW: 1726 { 1727 if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_SOME_STYLES)) 1728 aLbSelect.Disable(); 1729 *pActItem = pTableBck_Impl->pRowBrush; 1730 nWhich = pTableBck_Impl->nRowWhich; 1731 } 1732 break; 1733 case TBL_DEST_TBL: 1734 *pActItem = pTableBck_Impl->pTableBrush; 1735 aLbSelect.Enable(); 1736 nWhich = pTableBck_Impl->nTableWhich; 1737 break; 1738 } 1739 String aUserData = GetUserData(); 1740 if(!*pActItem) 1741 *pActItem = new SvxBrushItem(nWhich); 1742 FillControls_Impl(**pActItem, aUserData); 1743 delete pActItem; 1744 } 1745 return 0; 1746 } 1747 1748 //----------------------------------------------------------------------- 1749 1750 IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox ) 1751 { 1752 sal_uInt16 nSelPos = pBox->GetSelectEntryPos(); 1753 if( pParaBck_Impl && pParaBck_Impl->nActPos != nSelPos) 1754 { 1755 SvxBrushItem** pActItem = new (SvxBrushItem*); 1756 switch(pParaBck_Impl->nActPos) 1757 { 1758 case PARA_DEST_PARA: 1759 *pActItem = pParaBck_Impl->pParaBrush; 1760 break; 1761 case PARA_DEST_CHAR: 1762 *pActItem = pParaBck_Impl->pCharBrush; 1763 break; 1764 } 1765 pParaBck_Impl->nActPos = nSelPos; 1766 if(0 == aLbSelect.GetSelectEntryPos()) // Brush ausgewaehlt 1767 { 1768 sal_uInt16 nWhich = (*pActItem)->Which(); 1769 **pActItem = SvxBrushItem( aBgdColor, nWhich ); 1770 } 1771 else 1772 { 1773 SvxGraphicPosition eNewPos = GetGraphicPosition_Impl(); 1774 const sal_Bool bIsLink = aBtnLink.IsChecked(); 1775 1776 if ( !bIsLink && !bIsGraphicValid ) 1777 bIsGraphicValid = LoadLinkedGraphic_Impl(); 1778 1779 if ( bIsLink ) 1780 **pActItem = SvxBrushItem( aBgdGraphicPath, 1781 aBgdGraphicFilter, 1782 eNewPos, 1783 (*pActItem)->Which() ); 1784 else 1785 **pActItem = SvxBrushItem( aBgdGraphic, 1786 eNewPos, 1787 (*pActItem)->Which() ); 1788 } 1789 switch(nSelPos) 1790 { 1791 case PARA_DEST_PARA: 1792 *pActItem = pParaBck_Impl->pParaBrush; 1793 aLbSelect.Enable(); 1794 break; 1795 case PARA_DEST_CHAR: 1796 { 1797 *pActItem = pParaBck_Impl->pCharBrush; 1798 aLbSelect.Enable(sal_False); 1799 } 1800 break; 1801 } 1802 String aUserData = GetUserData(); 1803 FillControls_Impl(**pActItem, aUserData); 1804 delete pActItem; 1805 } 1806 return 0; 1807 } 1808 1809 //----------------------------------------------------------------------- 1810 1811 void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr, 1812 const String& rUserData ) 1813 1814 /* [Beschreibung] 1815 1816 */ 1817 1818 { 1819 SvxGraphicPosition ePos = rBgdAttr.GetGraphicPos(); 1820 const Color& rColor = rBgdAttr.GetColor(); 1821 if(bColTransparency) 1822 { 1823 aColTransMF.SetValue(lcl_TransparencyToPercent(rColor.GetTransparency())); 1824 aColTransMF.SaveValue(); 1825 sal_Bool bEnableTransp = rColor.GetTransparency() < 0xff; 1826 aColTransFT.Enable(bEnableTransp); 1827 aColTransMF.Enable(bEnableTransp); 1828 //the default setting should be "no transparency" 1829 if(!bEnableTransp) 1830 aColTransMF.SetValue(0); 1831 } 1832 1833 if ( GPOS_NONE == ePos || !aLbSelect.IsVisible() ) 1834 { 1835 aLbSelect.SelectEntryPos( 0 ); 1836 ShowColorUI_Impl(); 1837 Color aTrColor( COL_TRANSPARENT ); 1838 aBgdColor = rColor; 1839 1840 sal_uInt16 nCol = ( aTrColor != aBgdColor ) ? 1841 GetItemId_Impl( aBackgroundColorSet, aBgdColor ) : 0; 1842 1843 if( aTrColor != aBgdColor && nCol == 0) 1844 { 1845 aBackgroundColorSet.SetNoSelection(); 1846 } 1847 else 1848 { 1849 aBackgroundColorSet.SelectItem( nCol ); 1850 } 1851 1852 pPreviewWin1->NotifyChange( aBgdColor ); 1853 if ( aLbSelect.IsVisible() ) // Grafikteil initialisieren 1854 { 1855 aBgdGraphicFilter.Erase(); 1856 aBgdGraphicPath.Erase(); 1857 1858 if ( !rUserData.Len() ) 1859 aBtnPreview.Check( sal_False ); 1860 aBtnLink.Check( sal_False ); 1861 aBtnLink.Disable(); 1862 pPreviewWin2->NotifyChange( NULL ); 1863 SetGraphicPosition_Impl( GPOS_TILED ); // Kacheln als Default 1864 } 1865 } 1866 else 1867 { 1868 const String* pStrLink = rBgdAttr.GetGraphicLink(); 1869 const String* pStrFilter = rBgdAttr.GetGraphicFilter(); 1870 1871 aLbSelect.SelectEntryPos( 1 ); 1872 ShowBitmapUI_Impl(); 1873 1874 if ( pStrLink ) 1875 { 1876 #ifdef DBG_UTIL 1877 INetURLObject aObj( *pStrLink ); 1878 DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); 1879 #endif 1880 aBgdGraphicPath = *pStrLink; 1881 aBtnLink.Check( sal_True ); 1882 aBtnLink.Enable(); 1883 } 1884 else 1885 { 1886 aBgdGraphicPath.Erase(); 1887 aBtnLink.Check( sal_False ); 1888 aBtnLink.Disable(); 1889 } 1890 1891 if(bGraphTransparency) 1892 { 1893 const GraphicObject* pObject = rBgdAttr.GetGraphicObject(); 1894 if(pObject) 1895 aGraphTransMF.SetValue(lcl_TransparencyToPercent(pObject->GetAttr().GetTransparency())); 1896 else 1897 aGraphTransMF.SetValue(0); 1898 aGraphTransMF.SaveValue(); 1899 } 1900 1901 FileClickHdl_Impl( &aBtnLink ); 1902 1903 if ( pStrFilter ) 1904 aBgdGraphicFilter = *pStrFilter; 1905 else 1906 aBgdGraphicFilter.Erase(); 1907 1908 if ( !pStrLink || aBtnPreview.IsChecked() ) 1909 { 1910 // Grafik ist im Item vorhanden und muss nicht 1911 // geladen werden: 1912 1913 const Graphic* pGraphic = rBgdAttr.GetGraphic(); 1914 1915 if ( !pGraphic && aBtnPreview.IsChecked() ) 1916 bIsGraphicValid = LoadLinkedGraphic_Impl(); 1917 else if ( pGraphic ) 1918 { 1919 aBgdGraphic = *pGraphic; 1920 bIsGraphicValid = sal_True; 1921 1922 if ( !rUserData.Len() ) 1923 aBtnPreview.Check(); 1924 } 1925 else 1926 { 1927 RaiseLoadError_Impl(); 1928 bIsGraphicValid = sal_False; 1929 1930 if ( !rUserData.Len() ) 1931 aBtnPreview.Check( sal_False ); 1932 } 1933 } 1934 1935 if ( aBtnPreview.IsChecked() && bIsGraphicValid ) 1936 { 1937 Bitmap aBmp = aBgdGraphic.GetBitmap(); 1938 pPreviewWin2->NotifyChange( &aBmp ); 1939 } 1940 else 1941 pPreviewWin2->NotifyChange( NULL ); 1942 1943 SetGraphicPosition_Impl( ePos ); 1944 } 1945 } 1946 /* -----------------------------09.08.2002 14:04------------------------------ 1947 1948 ---------------------------------------------------------------------------*/ 1949 void SvxBackgroundTabPage::EnableTransparency(sal_Bool bColor, sal_Bool bGraphic) 1950 { 1951 bColTransparency = bColor; 1952 bGraphTransparency = bGraphic; 1953 if(bColor) 1954 { 1955 aColTransFT.Show(); 1956 aColTransMF.Show(); 1957 } 1958 if(bGraphic) 1959 { 1960 Size aRectSize(aWndPosition.GetSizePixel()); 1961 Point aRectPos(aWndPosition.GetPosPixel()); 1962 Point aFLPos(aGraphTransFL.GetPosPixel()); 1963 Size aTmp(LogicToPixel(Size(RSC_SP_FLGR_SPACE_Y, RSC_SP_FLGR_SPACE_Y), MAP_APPFONT)); 1964 long nRectHeight = aFLPos.Y() - aRectPos.Y() - aTmp.Height(); 1965 aRectSize.Height() = nRectHeight; 1966 aWndPosition.SetSizePixel(aRectSize); 1967 aWndPosition.Invalidate(); 1968 } 1969 } 1970 1971 void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001 1972 { 1973 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False); 1974 if (pFlagItem) 1975 { 1976 sal_uInt32 nFlags=pFlagItem->GetValue(); 1977 if ( ( nFlags & SVX_SHOW_TBLCTL ) == SVX_SHOW_TBLCTL ) 1978 ShowTblControl(); 1979 if ( ( nFlags & SVX_SHOW_PARACTL ) == SVX_SHOW_PARACTL ) 1980 ShowParaControl(); 1981 if ( ( nFlags & SVX_SHOW_SELECTOR ) == SVX_SHOW_SELECTOR ) 1982 ShowSelector(); 1983 if ( ( nFlags & SVX_ENABLE_TRANSPARENCY ) == SVX_ENABLE_TRANSPARENCY ) 1984 EnableTransparency(sal_True, sal_True); 1985 } 1986 } 1987