xref: /aoo41x/main/cui/source/tabpages/backgrnd.cxx (revision ca6f8f21)
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     aBackgroundColorSet.SetStyle(aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
405 	aBackgroundColorSet.SetText(SVX_RESSTR(RID_SVXSTR_TRANSPARENT));
406 	aBackgroundColorSet.SetAccessibleName(aBackgroundColorBox.GetText());
407 	FreeResource();
408 
409 	aBtnBrowse.SetAccessibleRelationMemberOf(&aGbFile);
410 	aWndPosition.SetAccessibleRelationMemberOf(&aGbPosition);
411 	aWndPosition.SetAccessibleRelationLabeledBy(&aBtnPosition);
412     aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorBox);
413 }
414 
415 //------------------------------------------------------------------------
416 
417 SvxBackgroundTabPage::~SvxBackgroundTabPage()
418 
419 /*	[Beschreibung]
420 
421 */
422 
423 {
424 	delete pPreviewWin1;
425 	delete pPreviewWin2;
426 	delete pPageImpl->pLoadTimer;
427 	delete pPageImpl;
428 	delete pImportDlg;
429 
430 	if( pTableBck_Impl)
431 	{
432 		delete pTableBck_Impl->pCellBrush;
433 		delete pTableBck_Impl->pRowBrush;
434 		delete pTableBck_Impl->pTableBrush;
435 		delete pTableBck_Impl;
436 	}
437 
438 	if(pParaBck_Impl)
439 	{
440 		delete pParaBck_Impl->pParaBrush;
441 		delete pParaBck_Impl->pCharBrush;
442 		delete pParaBck_Impl;
443 	}
444 }
445 
446 //------------------------------------------------------------------------
447 
448 sal_uInt16* SvxBackgroundTabPage::GetRanges()
449 
450 /*	[Beschreibung]
451 
452 	gibt den Bereich der Which-Werte zur"uck
453 */
454 
455 {
456 	return pRanges;
457 }
458 
459 //------------------------------------------------------------------------
460 
461 SfxTabPage* SvxBackgroundTabPage::Create( Window* pParent,
462 										  const SfxItemSet& rAttrSet )
463 
464 /*	[Beschreibung]
465 
466 	Create-Methode f"ur den TabDialog
467 */
468 
469 {
470 	return ( new SvxBackgroundTabPage( pParent, rAttrSet ) );
471 }
472 
473 //------------------------------------------------------------------------
474 
475 void SvxBackgroundTabPage::Reset( const SfxItemSet& rSet )
476 
477 /*	[Beschreibung]
478 
479 */
480 
481 {
482 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
483 //		es muss aber im rSet vorhanden sein!
484 //	const SfxPoolItem* pX = GetOldItem( rSet, SID_VIEW_FLD_PIC );
485 // 	if( pX && pX->ISA(SfxWallpaperItem))
486 	if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False))
487 	{
488 		ResetFromWallpaperItem( rSet );
489 		return;
490 	}
491 
492 	// Zustand des Vorschau-Buttons durch UserData persistent
493 	String aUserData = GetUserData();
494 	aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) );
495 
496 	// nach Reset kein ShowSelector() mehr aufrufen d"urfen
497 	bAllowShowSelector = sal_False;
498 
499 
500 	// Input-BrushItem besorgen und auswerten
501 	const SvxBrushItem* pBgdAttr = NULL;
502 	sal_uInt16 nSlot = SID_ATTR_BRUSH;
503 	const SfxPoolItem* pItem;
504 	sal_uInt16 nDestValue = USHRT_MAX;
505 
506 	if ( SFX_ITEM_SET == rSet.GetItemState(	SID_BACKGRND_DESTINATION,
507 											sal_False, &pItem ) )
508 	{
509 		nDestValue = ((const SfxUInt16Item*)pItem)->GetValue();
510 		aTblLBox.SelectEntryPos(nDestValue);
511 
512 		switch ( nDestValue )
513 		{
514 			case TBL_DEST_CELL:
515 				nSlot = SID_ATTR_BRUSH;
516 			break;
517 			case TBL_DEST_ROW:
518 				nSlot = SID_ATTR_BRUSH_ROW;
519 			break;
520 			case TBL_DEST_TBL:
521 				nSlot = SID_ATTR_BRUSH_TABLE;
522 			break;
523 		}
524 	}
525 	else if( SFX_ITEM_SET == rSet.GetItemState(
526 				SID_PARA_BACKGRND_DESTINATION, sal_False, &pItem ) )
527 	{
528 		nDestValue = ((const SfxUInt16Item*)pItem)->GetValue();
529 		// ist gerade Zeichen aktiviert?
530 		sal_uInt16 nParaSel  = aParaLBox.GetSelectEntryPos();
531 		if(1 == nParaSel)
532 		{
533 			// dann war das ein "Standard" - Aufruf
534 			nDestValue = nParaSel;
535 		}
536 		aParaLBox.SelectEntryPos(nDestValue);
537 
538 		switch ( nDestValue )
539 		{
540 			case PARA_DEST_PARA:
541 				nSlot = SID_ATTR_BRUSH;
542 			break;
543 			case PARA_DEST_CHAR:
544 				nSlot = SID_ATTR_BRUSH_CHAR;
545 			break;
546 		}
547 	}
548     //#111173# the destination item is missing when the parent style has been changed
549     if(USHRT_MAX == nDestValue && (aParaLBox.IsVisible()||aTblLBox.IsVisible()))
550         nDestValue = 0;
551 	sal_uInt16 nWhich = GetWhich( nSlot );
552 
553 	if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
554 		pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
555 
556 	aBtnTile.Check();
557 
558 	if ( pBgdAttr )
559 	{
560 		FillControls_Impl(*pBgdAttr, aUserData);
561 		aBgdColor = ( (SvxBrushItem*)pBgdAttr )->GetColor();
562 	}
563 	else
564 	{
565 		aSelectTxt.Hide();
566 		aLbSelect.Hide();
567 		aLbSelect.SelectEntryPos( 0 );
568 		ShowColorUI_Impl();
569 
570 		const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_BRUSH );
571 
572 		if ( pOld )
573 			aBgdColor = ( (SvxBrushItem*)pOld )->GetColor();
574 	}
575 
576 	if ( nDestValue != USHRT_MAX )
577 	{
578 		if(aTblLBox.IsVisible())
579 		{
580 			sal_uInt16 nValue = aTblLBox.GetSelectEntryPos();
581 
582 			if ( pTableBck_Impl )
583 			{
584                 DELETEZ( pTableBck_Impl->pCellBrush);
585                 DELETEZ( pTableBck_Impl->pRowBrush);
586                 DELETEZ( pTableBck_Impl->pTableBrush);
587 			}
588 			else
589 				pTableBck_Impl = new SvxBackgroundTable_Impl();
590 
591 			pTableBck_Impl->nActPos = nValue;
592 
593 			nWhich = GetWhich( SID_ATTR_BRUSH );
594 			if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
595             {
596 				pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
597                 pTableBck_Impl->pCellBrush = new SvxBrushItem(*pBgdAttr);
598             }
599             pTableBck_Impl->nCellWhich = nWhich;
600 
601 			if ( rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False ) >= SFX_ITEM_AVAILABLE )
602             {
603 				pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_ROW ) );
604                 pTableBck_Impl->pRowBrush = new SvxBrushItem(*pBgdAttr);
605             }
606             pTableBck_Impl->nRowWhich = SID_ATTR_BRUSH_ROW;
607 
608 			if ( rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False ) >= SFX_ITEM_AVAILABLE )
609             {
610 				pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_TABLE ) );
611                 pTableBck_Impl->pTableBrush = new SvxBrushItem(*pBgdAttr);
612             }
613             pTableBck_Impl->nTableWhich = SID_ATTR_BRUSH_TABLE;
614 
615 			TblDestinationHdl_Impl(&aTblLBox);
616 			aTblLBox.SaveValue();
617 		}
618 		else
619 		{
620 			sal_uInt16 nValue = aParaLBox.GetSelectEntryPos();
621 
622 			if ( pParaBck_Impl )
623 			{
624 				delete pParaBck_Impl->pParaBrush;
625 				delete pParaBck_Impl->pCharBrush;
626 			}
627 			else
628 				pParaBck_Impl = new SvxBackgroundPara_Impl();
629 
630 			pParaBck_Impl->nActPos = nValue;
631 
632 			nWhich = GetWhich( SID_ATTR_BRUSH );
633 			if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
634             {
635 				pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
636 			    pParaBck_Impl->pParaBrush = new SvxBrushItem(*pBgdAttr);
637             }
638 
639 			nWhich = GetWhich( SID_ATTR_BRUSH_CHAR );
640 			SfxItemState eState = rSet.GetItemState( nWhich, sal_True );
641 			eState = rSet.GetItemState( nWhich, sal_False );
642 			if ( rSet.GetItemState( nWhich, sal_True ) > SFX_ITEM_AVAILABLE )
643 			{
644 				pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
645 				pParaBck_Impl->pCharBrush = new SvxBrushItem(*pBgdAttr);
646 			}
647 			else
648 				pParaBck_Impl->pCharBrush = new SvxBrushItem(SID_ATTR_BRUSH_CHAR);
649 
650 			ParaDestinationHdl_Impl(&aParaLBox);
651 			aParaLBox.SaveValue();
652 		}
653 	}
654     if(!bResized)
655     {
656         if(!aLbSelect.IsVisible() && !aTblLBox.IsVisible() && !aParaLBox.IsVisible())
657         {
658 			long nY(LogicToPixel(Point(11,14), MAP_APPFONT).X());
659 			long nX(LogicToPixel(Point(11,14), MAP_APPFONT).Y());
660             Point aPos(aBorderWin.GetPosPixel());
661 			aPos.X() = nX;
662             aPos.Y() = nY;
663             aBorderWin.SetPosPixel(aPos);
664             aPos = pPreviewWin1->GetPosPixel();
665             aPos.Y()  = nY;
666             pPreviewWin1->SetPosPixel(aPos);
667             aBackgroundColorBox.Hide();
668             aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorSet);
669         }
670     }
671 }
672 
673 void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet& rSet )
674 {
675 	ShowSelector();
676 
677 	// Zustand des Vorschau-Buttons durch UserData persistent
678 	String aUserData = GetUserData();
679 	aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) );
680 
681 	// Input-BrushItem besorgen und auswerten
682 	const SvxBrushItem* pBgdAttr = NULL;
683 	sal_uInt16 nSlot = SID_VIEW_FLD_PIC;
684 	sal_uInt16 nWhich = GetWhich( nSlot );
685 	SvxBrushItem* pTemp = 0;
686 	const CntWallpaperItem* pItem = 0;
687 
688 	if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
689 	{
690 		pItem = (const CntWallpaperItem*)&rSet.Get( nWhich );
691 		pTemp = new SvxBrushItem( *pItem, nWhich );
692 		pBgdAttr = pTemp;
693 	}
694 
695 	aBtnTile.Check();
696 
697 	if ( pBgdAttr )
698 	{
699 		FillControls_Impl(*pBgdAttr, aUserData);
700 		// Auch bei Anzeige der Grafik, soll die Brush erhalten bleiben
701 		if( aBgdColor != pBgdAttr->GetColor() )
702 		{
703 			aBgdColor = pBgdAttr->GetColor();
704 			sal_uInt16 nCol = GetItemId_Impl( aBackgroundColorSet, aBgdColor );
705 			aBackgroundColorSet.SelectItem( nCol );
706 			pPreviewWin1->NotifyChange( aBgdColor );
707 		}
708 	}
709 	else
710 	{
711 		aLbSelect.SelectEntryPos( 0 );
712 		ShowColorUI_Impl();
713 
714 		const SfxPoolItem* pOld = GetOldItem( rSet, SID_VIEW_FLD_PIC );
715 		if ( pOld )
716 			aBgdColor = Color( ((CntWallpaperItem*)pOld)->GetColor() );
717 	}
718 
719 	// We now have always a link to the background
720 	bLinkOnly = sal_True;
721 	aBtnLink.Check( sal_True );
722 	aBtnLink.Show( sal_False );
723 //	if( !pItem || !pItem->GetWallpaper(sal_False).IsBitmap() )
724 //		aBtnLink.Check();
725 
726 	delete pTemp;
727 }
728 
729 
730 
731 //------------------------------------------------------------------------
732 
733 void SvxBackgroundTabPage::FillUserData()
734 
735 /*	[Beschreibung]
736 
737 	Beim Destruieren einer SfxTabPage wird diese virtuelle Methode gerufen,
738 	damit die TabPage interne Informationen sichern kann.
739 
740 	In diesem Fall wird der Zustand des Vorschau-Buttons gesichert.
741 */
742 
743 {
744 	SetUserData( String( aBtnPreview.IsChecked() ? sal_Unicode('1') : sal_Unicode('0') ) );
745 }
746 
747 //------------------------------------------------------------------------
748 
749 sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet )
750 
751 /*	[Beschreibung]
752 
753 */
754 
755 {
756 	if ( pPageImpl->pLoadTimer && pPageImpl->pLoadTimer->IsActive() )
757 	{
758 		pPageImpl->pLoadTimer->Stop();
759 		LoadTimerHdl_Impl( pPageImpl->pLoadTimer );
760 	}
761 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
762 //		es muss aber im rSet vorhanden sein!
763 
764 //	const SfxPoolItem* pX = GetOldItem( rCoreSet, SID_VIEW_FLD_PIC );
765 //	if( pX && pX->ISA(SfxWallpaperItem))
766 	if(SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False))
767 		return FillItemSetWithWallpaperItem( rCoreSet, SID_VIEW_FLD_PIC );
768 
769 	sal_Bool bModified = sal_False;
770 	sal_uInt16 nSlot = SID_ATTR_BRUSH;
771 
772 	if ( aTblLBox.IsVisible() )
773 	{
774 		switch( aTblLBox.GetSelectEntryPos() )
775 		{
776 			case TBL_DEST_CELL:
777 				nSlot = SID_ATTR_BRUSH;
778 			break;
779 			case TBL_DEST_ROW:
780 				nSlot = SID_ATTR_BRUSH_ROW;
781 			break;
782 			case TBL_DEST_TBL:
783 				nSlot = SID_ATTR_BRUSH_TABLE;
784 			break;
785 		}
786 	}
787 	else if(aParaLBox.GetData() == &aParaLBox)
788 	{
789 		switch(aParaLBox.GetSelectEntryPos())
790 		{
791 			case PARA_DEST_PARA:
792 				nSlot = SID_ATTR_BRUSH;
793 			break;
794 			case PARA_DEST_CHAR:
795 				nSlot = SID_ATTR_BRUSH_CHAR;
796 			break;
797 		}
798 	}
799 	sal_uInt16 nWhich = GetWhich( nSlot );
800 
801 	const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot );
802 	SfxItemState eOldItemState = rCoreSet.GetItemState(nSlot, sal_False);
803 	const SfxItemSet& rOldSet = GetItemSet();
804 
805     sal_Bool bGraphTransparencyChanged = bGraphTransparency && (aGraphTransMF.GetText() != aGraphTransMF.GetSavedValue());
806     if ( pOld )
807 	{
808 		const SvxBrushItem& rOldItem	= (const SvxBrushItem&)*pOld;
809 		SvxGraphicPosition	eOldPos		= rOldItem.GetGraphicPos();
810 		const sal_Bool 			bIsBrush	= ( 0 == aLbSelect.GetSelectEntryPos() );
811 
812         // transparency has to be set if enabled, the color not already set to "No fill" and
813         if( bColTransparency &&
814             aBgdColor.GetTransparency() < 0xff)
815         {
816             aBgdColor.SetTransparency(lcl_PercentToTransparency(static_cast<long>(aColTransMF.GetValue())));
817         }
818         if (   ( (GPOS_NONE == eOldPos) && bIsBrush  )
819 			|| ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt?
820 		{
821 			// Hintergrund-Art wurde nicht gewechselt:
822 
823 			if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() )
824 			{
825 				// Brush-Behandlung:
826 				if ( rOldItem.GetColor() != aBgdColor ||
827 						(SFX_ITEM_AVAILABLE >= eOldItemState && !aBackgroundColorSet.IsNoSelection()))
828 				{
829 					bModified = sal_True;
830 					rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
831 				}
832 				else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
833 					rCoreSet.ClearItem( nWhich );
834 			}
835 			else
836 			{
837 				// Bitmap-Behandlung:
838 
839 				SvxGraphicPosition	eNewPos  = GetGraphicPosition_Impl();
840 				const sal_Bool			bIsLink  = aBtnLink.IsChecked();
841 				const sal_Bool			bWasLink = (NULL != rOldItem.GetGraphicLink() );
842 
843 
844 				if ( !bIsLink && !bIsGraphicValid )
845 					bIsGraphicValid = LoadLinkedGraphic_Impl();
846 
847                 if (    bGraphTransparencyChanged ||
848                         eNewPos != eOldPos
849 					|| bIsLink != bWasLink
850 					|| ( bWasLink  &&    *rOldItem.GetGraphicLink()
851 									  != aBgdGraphicPath )
852 					|| ( !bWasLink &&    rOldItem.GetGraphic()->GetBitmap()
853 									  != aBgdGraphic.GetBitmap() )
854 				   )
855 				{
856 					bModified = sal_True;
857 
858                     SvxBrushItem aTmpBrush(nWhich);
859                     if ( bIsLink )
860 					{
861                         aTmpBrush = SvxBrushItem( aBgdGraphicPath,
862                                                 aBgdGraphicFilter,
863                                                 eNewPos,
864                                                 nWhich );
865 					}
866 					else
867                         aTmpBrush = SvxBrushItem( aBgdGraphic,
868                                         eNewPos,
869                                         nWhich );
870                     lcl_SetTransparency(aTmpBrush, static_cast<long>(aGraphTransMF.GetValue()));
871 
872                     rCoreSet.Put(aTmpBrush);
873 				}
874 				else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
875 					rCoreSet.ClearItem( nWhich );
876 			}
877 		}
878 		else // Brush <-> Bitmap gewechselt!
879 		{
880 			if ( bIsBrush )
881 				rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
882 			else
883 			{
884                 SvxBrushItem* pTmpBrush = 0;
885                 if ( aBtnLink.IsChecked() )
886 				{
887                     pTmpBrush = new SvxBrushItem( aBgdGraphicPath,
888 												aBgdGraphicFilter,
889 												GetGraphicPosition_Impl(),
890                                                 nWhich );
891 				}
892 				else
893 				{
894 					if ( !bIsGraphicValid )
895 						bIsGraphicValid = LoadLinkedGraphic_Impl();
896 
897 					if ( bIsGraphicValid )
898                         pTmpBrush = new SvxBrushItem( aBgdGraphic,
899 													GetGraphicPosition_Impl(),
900                                                     nWhich );
901 				}
902                 if(pTmpBrush)
903                 {
904                     lcl_SetTransparency(*pTmpBrush, static_cast<long>(aGraphTransMF.GetValue()));
905                     rCoreSet.Put(*pTmpBrush);
906                     delete pTmpBrush;
907                 }
908 			}
909 			bModified = ( bIsBrush || aBtnLink.IsChecked() || bIsGraphicValid );
910 		}
911 	}
912 	else if ( SID_ATTR_BRUSH_CHAR == nSlot && aBgdColor != Color( COL_WHITE ) )
913 	{
914 		rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
915 		bModified = sal_True;
916 	}
917 
918 	if( aTblLBox.IsVisible() )
919 	{
920 		// Der aktuelle Zustand wurde bereits geputtet
921         if( nSlot != SID_ATTR_BRUSH && pTableBck_Impl->pCellBrush)
922 		{
923 			const SfxPoolItem* pOldCell =
924 				GetOldItem( rCoreSet, SID_ATTR_BRUSH );
925 
926             if ( *pTableBck_Impl->pCellBrush != *pOldCell )
927 			{
928 				rCoreSet.Put( *pTableBck_Impl->pCellBrush );
929 				bModified |= sal_True;
930 			}
931 		}
932 
933         if( nSlot != SID_ATTR_BRUSH_ROW && pTableBck_Impl->pRowBrush)
934 		{
935 			const SfxPoolItem* pOldRow =
936 				GetOldItem( rCoreSet, SID_ATTR_BRUSH_ROW );
937 
938             if ( *pTableBck_Impl->pRowBrush != *pOldRow )
939 			{
940 				rCoreSet.Put( *pTableBck_Impl->pRowBrush );
941 				bModified |= sal_True;
942 			}
943 		}
944 
945         if( nSlot != SID_ATTR_BRUSH_TABLE && pTableBck_Impl->pTableBrush)
946 		{
947 			const SfxPoolItem* pOldTable =
948 				GetOldItem( rCoreSet, SID_ATTR_BRUSH_TABLE );
949 
950 			if ( *pTableBck_Impl->pTableBrush != *pOldTable )
951 			{
952 				rCoreSet.Put( *pTableBck_Impl->pTableBrush );
953 				bModified |= sal_True;
954 			}
955 		}
956 
957 		if( aTblLBox.GetSavedValue() != aTblLBox.GetSelectEntryPos() )
958 		{
959 			rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
960 										 aTblLBox.GetSelectEntryPos() ) );
961 			bModified |= sal_True;
962 		}
963 	}
964 	else if(aParaLBox.GetData() == &aParaLBox)
965 	{
966 		// Der aktuelle Zustand wurde bereits geputtet
967 		if( nSlot != SID_ATTR_BRUSH && aParaLBox.IsVisible()) // nicht im Suchen-Format-Dialog
968 		{
969 			const SfxPoolItem* pOldPara =
970 				GetOldItem( rCoreSet, SID_ATTR_BRUSH );
971 
972 			if ( *pParaBck_Impl->pParaBrush != *pOldPara )
973 			{
974 				rCoreSet.Put( *pParaBck_Impl->pParaBrush );
975 				bModified |= sal_True;
976 			}
977 		}
978 
979 		if( nSlot != SID_ATTR_BRUSH_CHAR )
980 		{
981 			const SfxPoolItem* pOldChar =
982 				GetOldItem( rCoreSet, SID_ATTR_BRUSH_CHAR );
983             DBG_ASSERT(pParaBck_Impl, "pParaBck_Impl == NULL ?");
984             if ( pOldChar &&
985                     //#111173#  crash report shows that pParaBck_Impl can be NULL, the cause is unknown
986                     pParaBck_Impl &&
987                         (*pParaBck_Impl->pCharBrush != *pOldChar ||
988                 *pParaBck_Impl->pCharBrush != SvxBrushItem(SID_ATTR_BRUSH_CHAR)))
989 			{
990 				rCoreSet.Put( *pParaBck_Impl->pCharBrush );
991 				bModified |= sal_True;
992 			}
993 		}
994 
995 		if( aParaLBox.GetSavedValue() != aParaLBox.GetSelectEntryPos() )
996 		{
997 			rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
998 										 aParaLBox.GetSelectEntryPos() ) );
999 			bModified |= sal_True;
1000 		}
1001 	}
1002 	return bModified;
1003 }
1004 
1005 sal_Bool SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet& rCoreSet, sal_uInt16 nSlot)
1006 {
1007 	sal_uInt16 nWhich = GetWhich( nSlot );
1008 	const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot );
1009 	const SfxItemSet& rOldSet = GetItemSet();
1010 	DBG_ASSERT(pOld,"FillItemSetWithWallpaperItem: Item not found");
1011 
1012 	SvxBrushItem 		rOldItem( (const CntWallpaperItem&)*pOld, nWhich );
1013 	SvxGraphicPosition	eOldPos		= rOldItem.GetGraphicPos();
1014 	const sal_Bool 			bIsBrush	= ( 0 == aLbSelect.GetSelectEntryPos() );
1015 	sal_Bool				bModified = sal_False;
1016 
1017 	if (   ( (GPOS_NONE == eOldPos) && bIsBrush  )
1018 		|| ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt?
1019 	{
1020 		// Hintergrund-Art wurde nicht gewechselt:
1021 
1022 		if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() )
1023 		{
1024 			// Brush-Behandlung:
1025 			if ( rOldItem.GetColor() != aBgdColor )
1026 			{
1027 				bModified = sal_True;
1028 				CntWallpaperItem aItem( nWhich );
1029 				aItem.SetColor( aBgdColor );
1030 				rCoreSet.Put( aItem );
1031 			}
1032 			else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1033 				rCoreSet.ClearItem( nWhich );
1034 		}
1035 		else
1036 		{
1037 			// Bitmap-Behandlung:
1038 			SvxGraphicPosition	eNewPos  = GetGraphicPosition_Impl();
1039 
1040 			int bBitmapChanged = ( ( eNewPos != eOldPos ) ||
1041 								   ( *rOldItem.GetGraphicLink() != aBgdGraphicPath ) );
1042 			int bBrushChanged = ( rOldItem.GetColor() != aBgdColor );
1043 			if( bBitmapChanged || bBrushChanged )
1044 			{
1045 				bModified = sal_True;
1046 
1047 				CntWallpaperItem aItem( nWhich );
1048 				WallpaperStyle eWallStyle = SvxBrushItem::GraphicPos2WallpaperStyle(eNewPos);
1049 				aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1050 				aItem.SetColor( aBgdColor );
1051                 aItem.SetBitmapURL( aBgdGraphicPath );
1052 				rCoreSet.Put( aItem );
1053 			}
1054 			else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1055 				rCoreSet.ClearItem( nWhich );
1056 		}
1057 	}
1058 	else // Brush <-> Bitmap gewechselt!
1059 	{
1060 		CntWallpaperItem aItem( nWhich );
1061 		if ( bIsBrush )
1062 		{
1063 			aItem.SetColor( aBgdColor );
1064 			rCoreSet.Put( aItem );
1065 		}
1066 		else
1067 		{
1068 			WallpaperStyle eWallStyle =
1069 				SvxBrushItem::GraphicPos2WallpaperStyle( GetGraphicPosition_Impl() );
1070 			aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1071 			aItem.SetColor( aBgdColor );
1072             aItem.SetBitmapURL( aBgdGraphicPath );
1073 			rCoreSet.Put( aItem );
1074 		}
1075 
1076 		bModified = sal_True;
1077 	}
1078 	return bModified;
1079 }
1080 
1081 //-----------------------------------------------------------------------
1082 
1083 int SvxBackgroundTabPage::DeactivatePage( SfxItemSet* _pSet )
1084 
1085 /*	[Beschreibung]
1086 
1087 	virtuelle Methode, wird beim Deaktivieren gerufen
1088 */
1089 
1090 {
1091 	if ( pPageImpl->bIsImportDlgInExecute )
1092 		return KEEP_PAGE;
1093 
1094     if ( _pSet )
1095         FillItemSet( *_pSet );
1096 
1097     return LEAVE_PAGE;
1098 }
1099 
1100 //-----------------------------------------------------------------------
1101 
1102 void SvxBackgroundTabPage::PointChanged( Window* , RECT_POINT  )
1103 
1104 /*	[Beschreibung]
1105 
1106 */
1107 
1108 {
1109 	// muss implementiert werden, damit Position-Control funktioniert
1110 }
1111 
1112 //-----------------------------------------------------------------------
1113 
1114 void SvxBackgroundTabPage::ShowSelector()
1115 
1116 /*	[Beschreibung]
1117 
1118 */
1119 
1120 {
1121 	if( bAllowShowSelector)
1122 	{
1123 		aSelectTxt.Show();
1124 		aLbSelect.Show();
1125 		aLbSelect.SetSelectHdl( HDL(SelectHdl_Impl) );
1126 		aBtnLink.SetClickHdl( HDL(FileClickHdl_Impl) );
1127 		aBtnPreview.SetClickHdl( HDL(FileClickHdl_Impl) );
1128 		aBtnBrowse.SetClickHdl( HDL(BrowseHdl_Impl) );
1129 		aBtnArea.SetClickHdl( HDL(RadioClickHdl_Impl) );
1130 		aBtnTile.SetClickHdl( HDL(RadioClickHdl_Impl) );
1131 		aBtnPosition.SetClickHdl( HDL(RadioClickHdl_Impl) );
1132 
1133 		// Verz"ogertes Laden "uber Timer (wg. UI-Update)
1134 		pPageImpl->pLoadTimer = new Timer;
1135 		pPageImpl->pLoadTimer->SetTimeout( 500 ); // 500ms verz"ogern
1136 		pPageImpl->pLoadTimer->SetTimeoutHdl(
1137 			LINK( this, SvxBackgroundTabPage, LoadTimerHdl_Impl ) );
1138 
1139 		bAllowShowSelector = sal_False;
1140 
1141 		if(nHtmlMode & HTMLMODE_ON)
1142 		{
1143 			if(!(nHtmlMode & HTMLMODE_GRAPH_POS))
1144 				aBtnPosition.Enable(sal_False);
1145 			aBtnArea.Enable(sal_False);
1146 		}
1147 	}
1148 }
1149 
1150 //------------------------------------------------------------------------
1151 
1152 
1153 void SvxBackgroundTabPage::RaiseLoadError_Impl()
1154 
1155 /*	[Beschreibung]
1156 
1157 */
1158 
1159 {
1160 	SfxErrorContext aContext( ERRCTX_SVX_BACKGROUND,
1161 							  String(),
1162 							  this,
1163 							  RID_SVXERRCTX,
1164 							  &CUI_MGR() );
1165 
1166 	ErrorHandler::HandleError(
1167 		*new StringErrorInfo( ERRCODE_SVX_GRAPHIC_NOTREADABLE,
1168 							  aBgdGraphicPath ) );
1169 }
1170 
1171 //------------------------------------------------------------------------
1172 
1173 sal_Bool SvxBackgroundTabPage::LoadLinkedGraphic_Impl()
1174 
1175 /*	[Beschreibung]
1176 
1177 */
1178 
1179 {
1180 	sal_Bool bResult = ( aBgdGraphicPath.Len() > 0 ) &&
1181 				   ( GRFILTER_OK == GraphicFilter::LoadGraphic( aBgdGraphicPath,
1182 												 aBgdGraphicFilter,
1183 												 aBgdGraphic ) );
1184 	return bResult;
1185 }
1186 
1187 //------------------------------------------------------------------------
1188 
1189 
1190 void SvxBackgroundTabPage::FillColorValueSets_Impl()
1191 
1192 /*	[Beschreibung]
1193 
1194 	F"ullen des Farb-Sets
1195 */
1196 
1197 {
1198 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
1199 	const SfxPoolItem* pItem = NULL;
1200 	XColorList* pColorTable = NULL;
1201 	bool bOwn(false);
1202     long nColorCount(0);
1203 
1204 	if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
1205     {
1206 		pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
1207     }
1208 
1209 	if ( !pColorTable )
1210 	{
1211 		bOwn = true;
1212 		pColorTable = new XColorList( SvtPathOptions().GetPalettePath() );
1213 	}
1214 
1215 	if ( pColorTable )
1216 	{
1217         nColorCount = pColorTable->Count();
1218         aBackgroundColorSet.Clear();
1219         aBackgroundColorSet.addEntriesForXColorList(*pColorTable);
1220 
1221         if(bOwn)
1222         {
1223 		    delete pColorTable;
1224         }
1225     }
1226 
1227 	const WinBits nBits(aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
1228 	aBackgroundColorSet.SetStyle(nBits);
1229     aBackgroundColorSet.SetColCount(aBackgroundColorSet.getColumnCount());
1230 
1231     // here we have enough space to the left, so layout with fixed column size
1232     // and fixed height, adapt width. Apply the adapted width by moving the left
1233     // edge of the control to the left, keeping the right edge aligned
1234     // with the original position
1235     const Point aCurrentPosContainer(aBorderWin.GetPosPixel());
1236     const Size aCurrentSizeContainer(aBorderWin.GetOutputSizePixel());
1237     const Size aCurrentSizeContent(aBackgroundColorSet.GetOutputSizePixel());
1238     const Size aNewSizeContent(aBackgroundColorSet.layoutToGivenHeight(aCurrentSizeContent.Height() - 4, nColorCount));
1239     static sal_Int32 nAdd = 4;
1240     const Size aNewSizeContainer(aNewSizeContent.Width() + nAdd, aNewSizeContent.Height() + nAdd);
1241     const Point aNewPos((aCurrentPosContainer.X() + aCurrentSizeContainer.Width()) - aNewSizeContainer.Width(), aCurrentPosContainer.Y());
1242 
1243     aBorderWin.SetOutputSizePixel(aNewSizeContainer);
1244     aBackgroundColorSet.SetOutputSizePixel(aNewSizeContent);
1245     aBackgroundColorSet.SetPosSizePixel(Point(nAdd/2, nAdd/2), aNewSizeContent);
1246     aBorderWin.SetPosSizePixel(aNewPos, aNewSizeContainer);
1247 }
1248 
1249 //------------------------------------------------------------------------
1250 
1251 
1252 
1253 //------------------------------------------------------------------------
1254 
1255 void SvxBackgroundTabPage::ShowColorUI_Impl()
1256 
1257 /*	[Beschreibung]
1258 
1259 	Die Controls f"ur das Einstellen der Grafik ausblenden und die
1260 	Controls f"ur die Farbeinstellung einblenden.
1261 */
1262 
1263 {
1264 	if( !aBackgroundColorSet.IsVisible() )
1265 	{
1266 		aBackgroundColorSet.Show();
1267 		aBackgroundColorBox.Show();
1268 		aBorderWin.Show();
1269 		pPreviewWin1->Show();
1270 		aBtnBrowse.Hide();
1271 		aFtFile.Hide();
1272 		aBtnLink.Hide();
1273 		aBtnPreview.Hide();
1274 		aGbFile.Hide();
1275 		aBtnPosition.Hide();
1276 		aBtnArea.Hide();
1277 		aBtnTile.Hide();
1278 		aWndPosition.Hide();
1279 		aGbPosition.Hide();
1280 		pPreviewWin2->Hide();
1281         aGraphTransFL.Show(sal_False);
1282         aGraphTransMF.Show(sal_False);
1283         if(bColTransparency)
1284 		{
1285 			aColTransFT.Show();
1286 			aColTransMF.Show();
1287 		}
1288     }
1289 }
1290 
1291 //------------------------------------------------------------------------
1292 
1293 void SvxBackgroundTabPage::ShowBitmapUI_Impl()
1294 
1295 /*	[Beschreibung]
1296 
1297 	Die Controls f"ur die Farbeinstellung ausblenden und die
1298 	Controls f"ur das Einstellen der Grafik einblenden.
1299 */
1300 
1301 {
1302 	if ( aLbSelect.IsVisible() &&
1303 		 (
1304 		aBackgroundColorSet.IsVisible()
1305 		 || !aBtnBrowse.IsVisible() ) )
1306 	{
1307 		aBackgroundColorSet.Hide();
1308 		aBackgroundColorBox.Hide();
1309 		aBorderWin.Hide();
1310 		pPreviewWin1->Hide();
1311 		aBtnBrowse.Show();
1312 		aFtFile.Show();
1313 
1314 		if ( !bLinkOnly && ! nHtmlMode & HTMLMODE_ON )
1315 			aBtnLink.Show();
1316 		aBtnPreview.Show();
1317 		aGbFile.Show();
1318 		aBtnPosition.Show();
1319 		aBtnArea.Show();
1320 		aBtnTile.Show();
1321 		aWndPosition.Show();
1322 		aGbPosition.Show();
1323 		pPreviewWin2->Show();
1324         if(bGraphTransparency)
1325 		{
1326 			aGraphTransFL.Show();
1327 			aGraphTransMF.Show();
1328 		}
1329         aColTransFT.Show(sal_False);
1330         aColTransMF.Show(sal_False);
1331     }
1332 }
1333 
1334 //------------------------------------------------------------------------
1335 
1336 void SvxBackgroundTabPage::SetGraphicPosition_Impl( SvxGraphicPosition ePos )
1337 
1338 /*	[Beschreibung]
1339 
1340 	Die Controls f"ur die Grafikposition einstellen.
1341 */
1342 
1343 {
1344 	switch ( ePos )
1345 	{
1346 		case GPOS_AREA:
1347 		{
1348 			aBtnArea.Check();
1349 			aWndPosition.Disable();
1350 		}
1351 		break;
1352 
1353 		case GPOS_TILED:
1354 		{
1355 			aBtnTile.Check();
1356 			aWndPosition.Disable();
1357 		}
1358 		break;
1359 
1360 		default:
1361 		{
1362 			aBtnPosition.Check();
1363 			aWndPosition.Enable();
1364 			RECT_POINT eNewPos = RP_MM;
1365 
1366 			switch ( ePos )
1367 			{
1368 				case GPOS_MM:	break;
1369 				case GPOS_LT:	eNewPos = RP_LT; break;
1370 				case GPOS_MT:	eNewPos = RP_MT; break;
1371 				case GPOS_RT:	eNewPos = RP_RT; break;
1372 				case GPOS_LM:	eNewPos = RP_LM; break;
1373 				case GPOS_RM:	eNewPos = RP_RM; break;
1374 				case GPOS_LB:	eNewPos = RP_LB; break;
1375 				case GPOS_MB:	eNewPos = RP_MB; break;
1376 				case GPOS_RB:	eNewPos = RP_RB; break;
1377                 default: ;//prevent warning
1378 			}
1379 			aWndPosition.SetActualRP( eNewPos );
1380 		}
1381 		break;
1382 	}
1383 	aWndPosition.Invalidate();
1384 }
1385 
1386 //------------------------------------------------------------------------
1387 
1388 SvxGraphicPosition SvxBackgroundTabPage::GetGraphicPosition_Impl()
1389 
1390 /*	[Beschreibung]
1391 
1392 	Die Position der Grafik zur"uckgeben.
1393 */
1394 
1395 {
1396 	if ( aBtnTile.IsChecked() )
1397 		return GPOS_TILED;
1398 	else if ( aBtnArea.IsChecked() )
1399 		return GPOS_AREA;
1400 	else
1401 	{
1402 		switch ( aWndPosition.GetActualRP() )
1403 		{
1404 			case RP_LT:	return GPOS_LT;
1405 			case RP_MT:	return GPOS_MT;
1406 			case RP_RT:	return GPOS_RT;
1407 			case RP_LM:	return GPOS_LM;
1408 			case RP_MM:	return GPOS_MM;
1409 			case RP_RM:	return GPOS_RM;
1410 			case RP_LB:	return GPOS_LB;
1411 			case RP_MB:	return GPOS_MB;
1412 			case RP_RB:	return GPOS_RB;
1413 		}
1414 	}
1415 	return GPOS_MM;
1416 }
1417 
1418 //-----------------------------------------------------------------------
1419 // Handler
1420 //-----------------------------------------------------------------------
1421 
1422 IMPL_LINK( SvxBackgroundTabPage, BackgroundColorHdl_Impl, ValueSet*, EMPTYARG )
1423 /*
1424     Handler, called when color selection is changed
1425 */
1426 {
1427 	sal_uInt16 nItemId = aBackgroundColorSet.GetSelectItemId();
1428 	Color aColor = nItemId ? ( aBackgroundColorSet.GetItemColor( nItemId ) ) : Color( COL_TRANSPARENT );
1429 	aBgdColor = aColor;
1430 	pPreviewWin1->NotifyChange( aBgdColor );
1431     sal_Bool bEnableTransp = aBgdColor.GetTransparency() < 0xff;
1432     aColTransFT.Enable(bEnableTransp);
1433     aColTransMF.Enable(bEnableTransp);
1434     return 0;
1435 }
1436 
1437 //------------------------------------------------------------------------
1438 
1439 IMPL_LINK( SvxBackgroundTabPage, SelectHdl_Impl, ListBox*, EMPTYARG )
1440 
1441 /*	[Beschreibung]
1442 
1443 */
1444 
1445 {
1446 	if ( 0 == aLbSelect.GetSelectEntryPos() )
1447 	{
1448 		ShowColorUI_Impl();
1449 		aParaLBox.Enable(); // Zeichenhintergrund kann keine Bitmap sein
1450 	}
1451 	else
1452 	{
1453 		ShowBitmapUI_Impl();
1454 		aParaLBox.Enable(sal_False);// Zeichenhintergrund kann keine Bitmap sein
1455 	}
1456 	return 0;
1457 }
1458 
1459 //------------------------------------------------------------------------
1460 
1461 IMPL_LINK( SvxBackgroundTabPage, FileClickHdl_Impl, CheckBox*, pBox )
1462 
1463 /*	[Beschreibung]
1464 
1465 */
1466 
1467 {
1468 	if ( &aBtnLink == pBox )
1469 	{
1470 		if ( aBtnLink.IsChecked() )
1471 		{
1472             INetURLObject aObj( aBgdGraphicPath );
1473 			String aFilePath;
1474 			if ( aObj.GetProtocol() == INET_PROT_FILE )
1475 				aFilePath = aObj.getFSysPath( INetURLObject::FSYS_DETECT );
1476 			else
1477 				aFilePath = aBgdGraphicPath;
1478 			aFtFile.SetText( aFilePath );
1479 		}
1480 		else
1481 			aFtFile.SetText( aStrUnlinked );
1482 	}
1483 	else if ( &aBtnPreview == pBox )
1484 	{
1485 		if ( aBtnPreview.IsChecked() )
1486 		{
1487 			if ( !bIsGraphicValid )
1488 				bIsGraphicValid = LoadLinkedGraphic_Impl();
1489 
1490 			if ( bIsGraphicValid )
1491 			{
1492 				Bitmap aBmp = aBgdGraphic.GetBitmap();
1493 				pPreviewWin2->NotifyChange( &aBmp );
1494 			}
1495 			else
1496 			{
1497 				if ( aBgdGraphicPath.Len() > 0 ) // nur bei gelinkter Grafik
1498 					RaiseLoadError_Impl();		 // ein Fehler
1499 				pPreviewWin2->NotifyChange( NULL );
1500 			}
1501 		}
1502 		else
1503 			pPreviewWin2->NotifyChange( NULL );
1504 	}
1505 	return 0;
1506 }
1507 
1508 //------------------------------------------------------------------------
1509 
1510 IMPL_LINK( SvxBackgroundTabPage, RadioClickHdl_Impl, RadioButton*, pBtn )
1511 
1512 /*	[Beschreibung]
1513 
1514 */
1515 
1516 {
1517 	if ( pBtn == &aBtnPosition )
1518 	{
1519 		if ( !aWndPosition.IsEnabled() )
1520 		{
1521 			aWndPosition.Enable();
1522 			aWndPosition.Invalidate();
1523 		}
1524 	}
1525 	else if ( aWndPosition.IsEnabled() )
1526 	{
1527 		aWndPosition.Disable();
1528 		aWndPosition.Invalidate();
1529 	}
1530 	return 0;
1531 }
1532 
1533 //------------------------------------------------------------------------
1534 
1535 IMPL_LINK( SvxBackgroundTabPage, BrowseHdl_Impl, PushButton* , EMPTYARG )
1536 
1537 /*	[Beschreibung]
1538 
1539 	Handler, gerufen durch das Dr"ucken des Durchsuchen-Buttons.
1540 	Grafik/Einf"ugen-Dialog erzeugen, Pfad setzen und starten.
1541 */
1542 
1543 {
1544 	if ( pPageImpl->pLoadTimer->IsActive() )
1545 		return 0;
1546 	sal_Bool bHtml = 0 != ( nHtmlMode & HTMLMODE_ON );
1547 
1548 	pImportDlg = new SvxOpenGraphicDialog( aStrBrowse );
1549 	if ( bHtml || bLinkOnly )
1550 		pImportDlg->EnableLink(sal_False);
1551 	pImportDlg->SetPath( aBgdGraphicPath, aBtnLink.IsChecked() );
1552 
1553 	pPageImpl->bIsImportDlgInExecute = sal_True;
1554 	short nErr = pImportDlg->Execute();
1555 	pPageImpl->bIsImportDlgInExecute = sal_False;
1556 
1557 	if( !nErr )
1558 	{
1559 		if ( bHtml )
1560 			aBtnLink.Check();
1561 		// wenn Verkn"upfen nicht gecheckt ist und die Vorschau auch nicht,
1562 		// dann die Vorschau aktivieren, damit der Anwender sieht,
1563 		// welche Grafik er ausgew"ahlt hat
1564 		if ( !aBtnLink.IsChecked() && !aBtnPreview.IsChecked() )
1565 			aBtnPreview.Check( sal_True );
1566 		// timer-verz"ogertes Laden der Grafik
1567 		pPageImpl->pLoadTimer->Start();
1568 	}
1569 	else
1570 		DELETEZ( pImportDlg );
1571 	return 0;
1572 }
1573 
1574 //-----------------------------------------------------------------------
1575 
1576 IMPL_LINK( SvxBackgroundTabPage, LoadTimerHdl_Impl, Timer* , pTimer )
1577 
1578 /*	[Beschreibung]
1579 
1580 	Verz"ogertes Laden der Grafik.
1581 	Grafik wird nur dann geladen, wenn sie unterschiedlich zur
1582 	aktuellen Grafik ist.
1583 */
1584 
1585 {
1586 	if ( pTimer == pPageImpl->pLoadTimer )
1587 	{
1588 		pPageImpl->pLoadTimer->Stop();
1589 
1590 		if ( pImportDlg )
1591 		{
1592             INetURLObject aOld( aBgdGraphicPath );
1593 			INetURLObject aNew( pImportDlg->GetPath() );
1594 			if ( !aBgdGraphicPath.Len() || aNew != aOld )
1595 			{
1596 				// neue Datei gew"ahlt
1597 				aBgdGraphicPath   = pImportDlg->GetPath();
1598 				aBgdGraphicFilter =	pImportDlg->GetCurrentFilter();
1599 				sal_Bool bLink = ( nHtmlMode & HTMLMODE_ON ) || bLinkOnly ? sal_True : pImportDlg->IsAsLink();
1600 				aBtnLink.Check( bLink );
1601 				aBtnLink.Enable();
1602 
1603 				if ( aBtnPreview.IsChecked() )
1604 				{
1605 					if( !pImportDlg->GetGraphic(aBgdGraphic) )
1606 					{
1607 						bIsGraphicValid = sal_True;
1608 					}
1609 					else
1610 					{
1611 						aBgdGraphicFilter.Erase();
1612 						aBgdGraphicPath.Erase();
1613 						bIsGraphicValid = sal_False;
1614 					}
1615 				}
1616 				else
1617 					bIsGraphicValid = sal_False; // Grafik erst beim Preview-Click laden
1618 
1619 				if ( aBtnPreview.IsChecked() && bIsGraphicValid )
1620 				{
1621 					Bitmap aBmp = aBgdGraphic.GetBitmap();
1622 					pPreviewWin2->NotifyChange( &aBmp );
1623 				}
1624 				else
1625 					pPreviewWin2->NotifyChange( NULL );
1626 			}
1627 
1628 			FileClickHdl_Impl( &aBtnLink );
1629 			DELETEZ( pImportDlg );
1630 		}
1631 	}
1632 	return 0;
1633 }
1634 
1635 //-----------------------------------------------------------------------
1636 
1637 void SvxBackgroundTabPage::ShowTblControl()
1638 
1639 /*	[Beschreibung]
1640 
1641 */
1642 
1643 {
1644 	aTblLBox			.SetSelectHdl( HDL(TblDestinationHdl_Impl) );
1645 	aTblLBox			.SelectEntryPos(0);
1646 	aTblDesc.Show();
1647 	aTblLBox.Show();
1648 }
1649 
1650 //-----------------------------------------------------------------------
1651 
1652 void SvxBackgroundTabPage::ShowParaControl(sal_Bool bCharOnly)
1653 {
1654 	aParaLBox.SetSelectHdl(HDL(ParaDestinationHdl_Impl));
1655 	aParaLBox.SelectEntryPos(0);
1656 	if(!bCharOnly)
1657 	{
1658 		aTblDesc.Show();
1659 		aParaLBox.Show();
1660 	}
1661 	aParaLBox.SetData(&aParaLBox); // hier erkennt man, dass dieser Mode eingeschaltet ist
1662 }
1663 //-----------------------------------------------------------------------
1664 
1665 IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox )
1666 
1667 /*	[Beschreibung]
1668 
1669 */
1670 
1671 {
1672 	sal_uInt16 nSelPos = pBox->GetSelectEntryPos();
1673 	if( pTableBck_Impl && pTableBck_Impl->nActPos != nSelPos)
1674 	{
1675 		SvxBrushItem** pActItem = new (SvxBrushItem*);
1676         sal_uInt16 nWhich = 0;
1677         switch(pTableBck_Impl->nActPos)
1678 		{
1679 			case TBL_DEST_CELL:
1680                 *pActItem = pTableBck_Impl->pCellBrush;
1681                 nWhich = pTableBck_Impl->nCellWhich;
1682 			break;
1683 			case TBL_DEST_ROW:
1684                 *pActItem = pTableBck_Impl->pRowBrush;
1685                 nWhich = pTableBck_Impl->nRowWhich;
1686 			break;
1687 			case TBL_DEST_TBL:
1688                 *pActItem = pTableBck_Impl->pTableBrush;
1689                 nWhich = pTableBck_Impl->nTableWhich;
1690 			break;
1691 		}
1692 		pTableBck_Impl->nActPos = nSelPos;
1693         if(!*pActItem)
1694             *pActItem = new SvxBrushItem(nWhich);
1695         if(0 == aLbSelect.GetSelectEntryPos())  // Brush ausgewaehlt
1696 		{
1697             **pActItem = SvxBrushItem( aBgdColor, nWhich );
1698 		}
1699 		else
1700 		{
1701 				SvxGraphicPosition	eNewPos  = GetGraphicPosition_Impl();
1702 				const sal_Bool			bIsLink  = aBtnLink.IsChecked();
1703 
1704 				if ( !bIsLink && !bIsGraphicValid )
1705 					bIsGraphicValid = LoadLinkedGraphic_Impl();
1706 
1707 				if ( bIsLink )
1708 					**pActItem = SvxBrushItem( aBgdGraphicPath,
1709 												aBgdGraphicFilter,
1710 												eNewPos,
1711 												(*pActItem)->Which() );
1712 				else
1713 					**pActItem = SvxBrushItem( aBgdGraphic,
1714 												eNewPos,
1715 												(*pActItem)->Which() );
1716 		}
1717 		switch(nSelPos)
1718 		{
1719 			case TBL_DEST_CELL:
1720 				*pActItem = pTableBck_Impl->pCellBrush;
1721 				aLbSelect.Enable();
1722                 nWhich = pTableBck_Impl->nCellWhich;
1723             break;
1724 			case TBL_DEST_ROW:
1725 			{
1726 				if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_SOME_STYLES))
1727 					aLbSelect.Disable();
1728 				*pActItem = pTableBck_Impl->pRowBrush;
1729                 nWhich = pTableBck_Impl->nRowWhich;
1730             }
1731 			break;
1732 			case TBL_DEST_TBL:
1733 				*pActItem = pTableBck_Impl->pTableBrush;
1734 				aLbSelect.Enable();
1735                 nWhich = pTableBck_Impl->nTableWhich;
1736             break;
1737 		}
1738 		String aUserData = GetUserData();
1739         if(!*pActItem)
1740             *pActItem = new SvxBrushItem(nWhich);
1741         FillControls_Impl(**pActItem, aUserData);
1742 		delete pActItem;
1743 	}
1744 	return 0;
1745 }
1746 
1747 //-----------------------------------------------------------------------
1748 
1749 IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox )
1750 {
1751 	sal_uInt16 nSelPos = pBox->GetSelectEntryPos();
1752 	if( pParaBck_Impl && pParaBck_Impl->nActPos != nSelPos)
1753 	{
1754 		SvxBrushItem** pActItem = new (SvxBrushItem*);
1755 		switch(pParaBck_Impl->nActPos)
1756 		{
1757 			case PARA_DEST_PARA:
1758 				*pActItem = pParaBck_Impl->pParaBrush;
1759 			break;
1760 			case PARA_DEST_CHAR:
1761 				*pActItem = pParaBck_Impl->pCharBrush;
1762 			break;
1763 		}
1764 		pParaBck_Impl->nActPos = nSelPos;
1765 		if(0 == aLbSelect.GetSelectEntryPos())  // Brush ausgewaehlt
1766 		{
1767 			sal_uInt16 nWhich = (*pActItem)->Which();
1768             **pActItem = SvxBrushItem( aBgdColor, nWhich );
1769 		}
1770 		else
1771 		{
1772 				SvxGraphicPosition	eNewPos  = GetGraphicPosition_Impl();
1773 				const sal_Bool			bIsLink  = aBtnLink.IsChecked();
1774 
1775 				if ( !bIsLink && !bIsGraphicValid )
1776 					bIsGraphicValid = LoadLinkedGraphic_Impl();
1777 
1778 				if ( bIsLink )
1779 					**pActItem = SvxBrushItem( aBgdGraphicPath,
1780 												aBgdGraphicFilter,
1781 												eNewPos,
1782 												(*pActItem)->Which() );
1783 				else
1784 					**pActItem = SvxBrushItem( aBgdGraphic,
1785 												eNewPos,
1786 												(*pActItem)->Which() );
1787 		}
1788 		switch(nSelPos)
1789 		{
1790 			case PARA_DEST_PARA:
1791 				*pActItem = pParaBck_Impl->pParaBrush;
1792 				aLbSelect.Enable();
1793 			break;
1794 			case PARA_DEST_CHAR:
1795 			{
1796 				*pActItem = pParaBck_Impl->pCharBrush;
1797 				aLbSelect.Enable(sal_False);
1798 			}
1799 			break;
1800 		}
1801 		String aUserData = GetUserData();
1802 		FillControls_Impl(**pActItem, aUserData);
1803 		delete pActItem;
1804 	}
1805 	return 0;
1806 }
1807 
1808 //-----------------------------------------------------------------------
1809 
1810 void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
1811 											  const String& rUserData )
1812 
1813 /*	[Beschreibung]
1814 
1815 */
1816 
1817 {
1818 	SvxGraphicPosition	ePos = rBgdAttr.GetGraphicPos();
1819 	const Color& rColor = rBgdAttr.GetColor();
1820     if(bColTransparency)
1821     {
1822         aColTransMF.SetValue(lcl_TransparencyToPercent(rColor.GetTransparency()));
1823         aColTransMF.SaveValue();
1824 		sal_Bool bEnableTransp = rColor.GetTransparency() < 0xff;
1825 		aColTransFT.Enable(bEnableTransp);
1826 		aColTransMF.Enable(bEnableTransp);
1827 		//the default setting should be "no transparency"
1828 		if(!bEnableTransp)
1829 			aColTransMF.SetValue(0);
1830     }
1831 
1832     if ( GPOS_NONE == ePos || !aLbSelect.IsVisible() )
1833 	{
1834 		aLbSelect.SelectEntryPos( 0 );
1835 		ShowColorUI_Impl();
1836 		Color aTrColor( COL_TRANSPARENT );
1837 		aBgdColor = rColor;
1838 
1839 		sal_uInt16 nCol = ( aTrColor != aBgdColor ) ?
1840 			GetItemId_Impl( aBackgroundColorSet, aBgdColor ) : 0;
1841 
1842 		if( aTrColor != aBgdColor && nCol == 0)
1843 		{
1844 			aBackgroundColorSet.SetNoSelection();
1845 		}
1846 		else
1847 		{
1848 			aBackgroundColorSet.SelectItem( nCol );
1849 		}
1850 
1851 		pPreviewWin1->NotifyChange( aBgdColor );
1852 		if ( aLbSelect.IsVisible() ) // Grafikteil initialisieren
1853 		{
1854 			aBgdGraphicFilter.Erase();
1855 			aBgdGraphicPath.Erase();
1856 
1857 			if ( !rUserData.Len() )
1858 				aBtnPreview.Check( sal_False );
1859 			aBtnLink.Check( sal_False );
1860 			aBtnLink.Disable();
1861 			pPreviewWin2->NotifyChange( NULL );
1862 			SetGraphicPosition_Impl( GPOS_TILED );	// Kacheln als Default
1863 		}
1864 	}
1865 	else
1866 	{
1867 		const String*	pStrLink   = rBgdAttr.GetGraphicLink();
1868 		const String*	pStrFilter = rBgdAttr.GetGraphicFilter();
1869 
1870 		aLbSelect.SelectEntryPos( 1 );
1871 		ShowBitmapUI_Impl();
1872 
1873 		if ( pStrLink )
1874 		{
1875 #ifdef DBG_UTIL
1876             INetURLObject aObj( *pStrLink );
1877             DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
1878 #endif
1879 			aBgdGraphicPath = *pStrLink;
1880 			aBtnLink.Check( sal_True );
1881 			aBtnLink.Enable();
1882 		}
1883 		else
1884 		{
1885 			aBgdGraphicPath.Erase();
1886 			aBtnLink.Check( sal_False );
1887 			aBtnLink.Disable();
1888 		}
1889 
1890         if(bGraphTransparency)
1891         {
1892             const GraphicObject* pObject = rBgdAttr.GetGraphicObject();
1893             if(pObject)
1894                 aGraphTransMF.SetValue(lcl_TransparencyToPercent(pObject->GetAttr().GetTransparency()));
1895             else
1896                 aGraphTransMF.SetValue(0);
1897             aGraphTransMF.SaveValue();
1898         }
1899 
1900         FileClickHdl_Impl( &aBtnLink );
1901 
1902 		if ( pStrFilter )
1903 			aBgdGraphicFilter = *pStrFilter;
1904 		else
1905 			aBgdGraphicFilter.Erase();
1906 
1907 		if ( !pStrLink || aBtnPreview.IsChecked() )
1908 		{
1909 			// Grafik ist im Item vorhanden und muss nicht
1910 			// geladen werden:
1911 
1912 			const Graphic* pGraphic = rBgdAttr.GetGraphic();
1913 
1914 			if ( !pGraphic && aBtnPreview.IsChecked() )
1915 				bIsGraphicValid = LoadLinkedGraphic_Impl();
1916 			else if ( pGraphic )
1917 			{
1918 				aBgdGraphic = *pGraphic;
1919 				bIsGraphicValid = sal_True;
1920 
1921 				if ( !rUserData.Len() )
1922 					aBtnPreview.Check();
1923 			}
1924 			else
1925 			{
1926 				RaiseLoadError_Impl();
1927 				bIsGraphicValid = sal_False;
1928 
1929 				if ( !rUserData.Len() )
1930 					aBtnPreview.Check( sal_False );
1931 			}
1932 		}
1933 
1934 		if ( aBtnPreview.IsChecked() && bIsGraphicValid )
1935 		{
1936 			Bitmap aBmp = aBgdGraphic.GetBitmap();
1937 			pPreviewWin2->NotifyChange( &aBmp );
1938 		}
1939 		else
1940 			pPreviewWin2->NotifyChange( NULL );
1941 
1942 		SetGraphicPosition_Impl( ePos );
1943 	}
1944 }
1945 /* -----------------------------09.08.2002 14:04------------------------------
1946 
1947  ---------------------------------------------------------------------------*/
1948 void SvxBackgroundTabPage::EnableTransparency(sal_Bool bColor, sal_Bool bGraphic)
1949 {
1950     bColTransparency  = bColor;
1951     bGraphTransparency = bGraphic;
1952     if(bColor)
1953     {
1954         aColTransFT.Show();
1955         aColTransMF.Show();
1956     }
1957     if(bGraphic)
1958     {
1959         Size aRectSize(aWndPosition.GetSizePixel());
1960         Point aRectPos(aWndPosition.GetPosPixel());
1961         Point aFLPos(aGraphTransFL.GetPosPixel());
1962         Size aTmp(LogicToPixel(Size(RSC_SP_FLGR_SPACE_Y, RSC_SP_FLGR_SPACE_Y), MAP_APPFONT));
1963         long nRectHeight = aFLPos.Y() - aRectPos.Y() - aTmp.Height();
1964         aRectSize.Height() = nRectHeight;
1965         aWndPosition.SetSizePixel(aRectSize);
1966         aWndPosition.Invalidate();
1967     }
1968 }
1969 
1970 void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1971 {
1972 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
1973 	if (pFlagItem)
1974 	{
1975 		sal_uInt32 nFlags=pFlagItem->GetValue();
1976 		if ( ( nFlags & SVX_SHOW_TBLCTL ) == SVX_SHOW_TBLCTL )
1977 			ShowTblControl();
1978 		if ( ( nFlags & SVX_SHOW_PARACTL ) == SVX_SHOW_PARACTL )
1979 			ShowParaControl();
1980 		if ( ( nFlags & SVX_SHOW_SELECTOR ) == SVX_SHOW_SELECTOR )
1981 			ShowSelector();
1982 		if ( ( nFlags & SVX_ENABLE_TRANSPARENCY ) == SVX_ENABLE_TRANSPARENCY )
1983 			EnableTransparency(sal_True, sal_True);
1984 	}
1985 }
1986