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