xref: /aoo41x/main/svx/source/dialog/_bmpmask.cxx (revision 9b8096d0)
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_svx.hxx"
26 #include <vcl/wrkwin.hxx>
27 #include <tools/shl.hxx>
28 #include <vcl/metaact.hxx>
29 #include <svtools/valueset.hxx>
30 #include <svl/eitem.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <svtools/colrdlg.hxx>
33 
34 #define BMPMASK_PRIVATE
35 
36 #include <svx/dialmgr.hxx>
37 #include <svx/bmpmask.hxx>
38 #include <svx/dialogs.hrc>
39 #include <bmpmask.hrc>
40 #include <svx/svxids.hrc>
41 
42 //-------------------------------------------------------------------------
43 
44 #define BMP_RESID(nId)  ResId(nId, DIALOG_MGR())
45 #define TRANSP_STRING	"Transparent"
46 #define TRANSP_COL		(Color( 252, 252, 252 ))
47 #define OWN_CALLMODE	SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD
48 
49 //-------------------------------------------------------------------------
50 
51 #define TEST_COLS()													\
52 {																	\
53 	nR = aCol.GetRed(); nG = aCol.GetGreen(); nB = aCol.GetBlue();	\
54 	for( i = 0; i < nCount; i++ )									\
55 	{																\
56 		if ( ( pMinR[i] <= nR ) && ( pMaxR[i] >= nR ) &&			\
57 			 ( pMinG[i] <= nG ) && ( pMaxG[i] >= nG ) &&			\
58 			 ( pMinB[i] <= nB ) && ( pMaxB[i] >= nB ) )				\
59 		{															\
60 			aCol = pDstCols[i];	bReplace = sal_True; break;				\
61 		}															\
62 	}																\
63 }
64 
65 // -------------------------------------------------------------------------
66 
67 SFX_IMPL_DOCKINGWINDOW( SvxBmpMaskChildWindow, SID_BMPMASK )
68 
69 // -------------------------------------------------------------------------
70 
71 class ColorWindow : public Control
72 {
73 	Color       aColor;
74 
75 
76 public:
77 
78 				ColorWindow( Window* pParent, WinBits nWinStyle ) :
79 					Control( pParent, nWinStyle ),
80 					aColor( COL_WHITE ) {};
81 
82 				ColorWindow( Window* pParent, const ResId& rId ) :
83 					Control( pParent, rId ),
84 					aColor( COL_WHITE ) {};
85 
86 	void        SetColor( const Color& rColor )
87 				{
88 					aColor = rColor;
89 					Invalidate();
90 				}
91 
92 	virtual void Paint( const Rectangle& rRect );
93 };
94 
95 //-------------------------------------------------------------------------
96 
97 class MaskSet : public ValueSet
98 {
99 	SvxBmpMask*     pSvxBmpMask;
100 
101 
102 public:
103 					MaskSet( SvxBmpMask* pParent, WinBits nWinStyle );
104 					MaskSet( SvxBmpMask* pParent, const ResId& rId );
105 
106 	virtual void    Select();
107 	virtual void KeyInput( const KeyEvent& rKEvt );
108 	virtual void GetFocus();
109 
110 	void onEditColor();
111 };
112 
113 //-------------------------------------------------------------------------
114 
115 MaskSet::MaskSet( SvxBmpMask* pParent, WinBits nWinStyle ) :
116 			ValueSet        ( pParent, nWinStyle ),
117 			pSvxBmpMask     ( pParent )
118 {
119 }
120 
121 //-------------------------------------------------------------------------
122 
123 MaskSet::MaskSet( SvxBmpMask* pParent, const ResId& rId ) :
124 			ValueSet        ( pParent, rId ),
125 			pSvxBmpMask     ( pParent )
126 {
127 }
128 
129 //-------------------------------------------------------------------------
130 
131 void MaskSet::Select()
132 {
133 	ValueSet::Select();
134 
135 	pSvxBmpMask->onSelect( this );
136 }
137 
138 void MaskSet::GetFocus()
139 {
140 	//IAccessibility2 Implementation 2009-----
141 	ValueSet::GetFocus();
142 	//-----IAccessibility2 Implementation 2009
143 	SelectItem( 1 );
144 	pSvxBmpMask->onSelect( this );
145 }
146 
147 void MaskSet::KeyInput( const KeyEvent& rKEvt )
148 {
149     KeyCode aCode = rKEvt.GetKeyCode();
150 
151 	// if the key has a modifier we don't care
152     if( aCode.GetModifier() )
153     {
154         ValueSet::KeyInput( rKEvt );
155     }
156 	else
157 	{
158 		// check for keys that interests us
159 		switch ( aCode.GetCode() )
160 		{
161 			case KEY_SPACE:
162 				onEditColor();
163 				break;
164 			default:
165 		        ValueSet::KeyInput( rKEvt );
166 		}
167 
168 	}
169 }
170 
171 void MaskSet::onEditColor()
172 {
173 	SvColorDialog* pColorDlg = new SvColorDialog( GetParent() );
174 
175 	pColorDlg->SetColor(GetItemColor(1));
176 
177 	if( pColorDlg->Execute() )
178 		SetItemColor( 1, pColorDlg->GetColor() );
179 
180 	delete pColorDlg;
181 }
182 
183 //-------------------------------------------------------------------------
184 
185 class MaskData
186 {
187 	SvxBmpMask*		pMask;
188 	sal_Bool			bIsReady;
189 	sal_Bool			bExecState;
190 	SfxBindings&	rBindings;
191 
192 public:
193 				MaskData( SvxBmpMask* pBmpMask, SfxBindings& rBind );
194 
195 	sal_Bool		IsCbxReady() const { return bIsReady; }
196 	void		SetExecState( sal_Bool bState ) { bExecState = bState; }
197 	sal_Bool		IsExecReady() const { return bExecState; }
198 
199 				DECL_LINK( PipetteHdl, ToolBox* pTbx );
200 				DECL_LINK( CbxHdl, CheckBox* pCbx );
201 				DECL_LINK( CbxTransHdl, CheckBox* pCbx );
202 				DECL_LINK( FocusLbHdl, ColorLB* pLb );
203 				DECL_LINK( ExecHdl, PushButton* pBtn );
204 };
205 
206 //-------------------------------------------------------------------------
207 
208 MaskData::MaskData( SvxBmpMask* pBmpMask, SfxBindings& rBind ) :
209 
210 	pMask       ( pBmpMask ),
211 	bIsReady    ( sal_False ),
212 	bExecState  ( sal_False ),
213 	rBindings	( rBind )
214 
215 {
216 }
217 
218 //-------------------------------------------------------------------------
219 
220 IMPL_LINK( MaskData, PipetteHdl, ToolBox*, pTbx )
221 {
222 	SfxBoolItem aBItem( SID_BMPMASK_PIPETTE,
223 						pTbx->IsItemChecked( TBI_PIPETTE ) );
224 
225 	rBindings.GetDispatcher()->Execute( SID_BMPMASK_PIPETTE, OWN_CALLMODE, &aBItem, 0L );
226 
227 	return 0;
228 }
229 
230 //-------------------------------------------------------------------------
231 
232 IMPL_LINK( MaskData, CbxHdl, CheckBox*, pCbx )
233 {
234 	bIsReady =  pMask->aCbx1.IsChecked() || pMask->aCbx2.IsChecked() ||
235 				pMask->aCbx3.IsChecked() || pMask->aCbx4.IsChecked();
236 
237 	if ( bIsReady && IsExecReady() )
238 		pMask->aBtnExec.Enable();
239 	else
240 		pMask->aBtnExec.Disable();
241 
242 	// Wenn eine Checkbox gecheckt wurde, wird die Pipette enabled
243 	if ( pCbx->IsChecked() )
244 	{
245 		MaskSet* pSet = NULL;
246 
247 		if ( pCbx == &( pMask->aCbx1 ) )
248 			pSet = pMask->pQSet1;
249 		else if ( pCbx == &( pMask->aCbx2 ) )
250 			pSet = pMask->pQSet2;
251 		else if ( pCbx == &( pMask->aCbx3 ) )
252 			pSet = pMask->pQSet3;
253 		else // if ( pCbx == &( pMask->aCbx4 ) )
254 			pSet = pMask->pQSet4;
255 
256 		pSet->SelectItem( 1 );
257 		pSet->Select();
258 
259 		pMask->aTbxPipette.CheckItem( TBI_PIPETTE, sal_True );
260 		PipetteHdl( &( pMask->aTbxPipette ) );
261 	}
262 
263 	return 0;
264 }
265 
266 //-------------------------------------------------------------------------
267 
268 IMPL_LINK( MaskData, CbxTransHdl, CheckBox*, pCbx )
269 {
270     bIsReady = pCbx->IsChecked();
271 	if ( bIsReady )
272 	{
273 		pMask->pQSet1->Disable();
274 		pMask->pQSet2->Disable();
275 		pMask->pQSet3->Disable();
276 		pMask->pQSet4->Disable();
277 		pMask->pCtlPipette->Disable();
278 		pMask->aCbx1.Disable();
279 		pMask->aSp1.Disable();
280 		pMask->aCbx2.Disable();
281 		pMask->aSp2.Disable();
282 		pMask->aCbx3.Disable();
283 		pMask->aSp3.Disable();
284 		pMask->aCbx4.Disable();
285 		pMask->aSp4.Disable();
286 		pMask->aTbxPipette.Disable();
287 
288 		pMask->aLbColor1.Disable();
289 		pMask->aLbColor2.Disable();
290 		pMask->aLbColor3.Disable();
291 		pMask->aLbColor4.Disable();
292 		pMask->aLbColorTrans.Enable();
293 	}
294 	else
295 	{
296 		pMask->pQSet1->Enable();
297 		pMask->pQSet2->Enable();
298 		pMask->pQSet3->Enable();
299 		pMask->pQSet4->Enable();
300 		pMask->pCtlPipette->Enable();
301 		pMask->aCbx1.Enable();
302 		pMask->aSp1.Enable();
303 		pMask->aCbx2.Enable();
304 		pMask->aSp2.Enable();
305 		pMask->aCbx3.Enable();
306 		pMask->aSp3.Enable();
307 		pMask->aCbx4.Enable();
308 		pMask->aSp4.Enable();
309 		pMask->aTbxPipette.Enable();
310 
311 		pMask->aLbColor1.Enable();
312 		pMask->aLbColor2.Enable();
313 		pMask->aLbColor3.Enable();
314 		pMask->aLbColor4.Enable();
315 		pMask->aLbColorTrans.Disable();
316 
317 		bIsReady = pMask->aCbx1.IsChecked() || pMask->aCbx2.IsChecked() ||
318 				   pMask->aCbx3.IsChecked() || pMask->aCbx4.IsChecked();
319 	}
320 
321 	if ( bIsReady && IsExecReady() )
322 		pMask->aBtnExec.Enable();
323 	else
324 		pMask->aBtnExec.Disable();
325 
326 	return 0L;
327 }
328 
329 //-------------------------------------------------------------------------
330 
331 IMPL_LINK( MaskData, FocusLbHdl, ColorLB*, pLb )
332 {
333 	//IAccessibility2 Implementation 2009-----
334 	// MT: bFireFox as API parameter is ugly, find better solution????
335 	pMask->pQSet1->SelectItem( pLb == &( pMask->aLbColor1 ) ? 1 : 0 /* , false */ );
336 	pMask->pQSet2->SelectItem( pLb == &( pMask->aLbColor2 ) ? 1 : 0 /* , false */ );
337 	pMask->pQSet3->SelectItem( pLb == &( pMask->aLbColor3 ) ? 1 : 0 /* , false */ );
338 	pMask->pQSet4->SelectItem( pLb == &( pMask->aLbColor4 ) ? 1 : 0 /* , false */ );
339 	//-----IAccessibility2 Implementation 2009
340 
341 	return 0;
342 }
343 
344 //-------------------------------------------------------------------------
345 
346 IMPL_LINK( MaskData, ExecHdl, PushButton*, EMPTYARG )
347 {
348 	SfxBoolItem aBItem( SID_BMPMASK_EXEC, sal_True );
349 	rBindings.GetDispatcher()->Execute( SID_BMPMASK_EXEC, OWN_CALLMODE, &aBItem, 0L );
350 
351 	return 0L;
352 }
353 
354 //-------------------------------------------------------------------------
355 
356 void ColorWindow::Paint( const Rectangle &/*Rect*/ )
357 {
358 	const Color& rOldLineColor = GetLineColor();
359 	const Color& rOldFillColor = GetFillColor();
360 
361 	SetLineColor( aColor );
362 	SetFillColor( aColor );
363 
364 	DrawRect( Rectangle( Point(), GetSizePixel() ) );
365 
366 	SetLineColor( rOldLineColor );
367 	SetFillColor( rOldFillColor );
368 }
369 
370 //-------------------------------------------------------------------------
371 
372 SvxBmpMaskSelectItem::SvxBmpMaskSelectItem( sal_uInt16 nId_, SvxBmpMask& rMask,
373 											SfxBindings& rBindings ) :
374 			SfxControllerItem   ( nId_, rBindings ),
375 			rBmpMask            ( rMask)
376 {
377 }
378 
379 //-------------------------------------------------------------------------
380 
381 void SvxBmpMaskSelectItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
382 										 const SfxPoolItem* pItem )
383 {
384 	if ( ( nSID == SID_BMPMASK_EXEC ) && pItem )
385 	{
386 		const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
387 
388 		DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
389 
390 		rBmpMask.SetExecState( pStateItem->GetValue() );
391 	}
392 }
393 
394 //-------------------------------------------------------------------------
395 
396 SvxBmpMaskChildWindow::SvxBmpMaskChildWindow( Window* pParent_, sal_uInt16 nId,
397 											  SfxBindings* pBindings,
398 											  SfxChildWinInfo* pInfo ) :
399 		SfxChildWindow( pParent_, nId )
400 {
401 	pWindow = new SvxBmpMask( pBindings, this, pParent_,
402 							  BMP_RESID( RID_SVXDLG_BMPMASK ) );
403 	SvxBmpMask* pDlg = (SvxBmpMask*) pWindow;
404 
405 	eChildAlignment = SFX_ALIGN_NOALIGNMENT;
406 
407 	pDlg->Initialize( pInfo );
408 }
409 
410 //-------------------------------------------------------------------------
411 
412 SvxBmpMask::SvxBmpMask( SfxBindings *pBindinx,
413 						SfxChildWindow *pCW,
414 						Window* pParent,
415 						const ResId& rResId ) :
416 		SfxDockingWindow	( pBindinx, pCW, pParent, rResId ),
417 		aTbxPipette			( this, BMP_RESID( TBX_PIPETTE ) ),
418 		pCtlPipette			( new ColorWindow( this, BMP_RESID( WND_PIPETTE ) ) ),
419 		aBtnExec			( this, BMP_RESID( BTN_EXEC ) ),
420 		aGrpQ				( this, BMP_RESID( GRP_Q ) ),
421 
422 		aFt1				( this, BMP_RESID ( FT_1 ) ),
423 		aFt2				( this, BMP_RESID ( FT_2 ) ),
424 		aFt3				( this, BMP_RESID ( FT_3 ) ),
425 
426         aCbx1				( this, BMP_RESID( CBX_1 ) ),
427 		pQSet1				( new MaskSet( this, BMP_RESID( QCOL_1 ) ) ),
428 		aSp1				( this, BMP_RESID( SP_1 ) ),
429 		aLbColor1			( this, BMP_RESID ( LB_1 ) ),
430 
431 		aCbx2				( this, BMP_RESID( CBX_2 ) ),
432 		pQSet2				( new MaskSet( this, BMP_RESID( QCOL_2 ) ) ),
433 		aSp2				( this, BMP_RESID( SP_2 ) ),
434 		aLbColor2			( this, BMP_RESID ( LB_2 ) ),
435 
436 		aCbx3				( this, BMP_RESID( CBX_3 ) ),
437 		pQSet3				( new MaskSet( this, BMP_RESID( QCOL_3 ) ) ),
438 		aSp3				( this, BMP_RESID( SP_3 ) ),
439 		aLbColor3			( this, BMP_RESID ( LB_3 ) ),
440 
441 		aCbx4				( this, BMP_RESID( CBX_4 ) ),
442 		pQSet4				( new MaskSet( this, BMP_RESID( QCOL_4 ) ) ),
443 		aSp4				( this, BMP_RESID( SP_4 ) ),
444 		aLbColor4			( this, BMP_RESID ( LB_4 ) ),
445 
446 		pData				( new MaskData( this, *pBindinx ) ),
447 		aCbxTrans			( this, BMP_RESID( CBX_TRANS ) ),
448 		aLbColorTrans		( this, BMP_RESID ( LB_TRANS ) ),
449 		pColTab				( NULL ),
450 		aPipetteColor		( COL_WHITE ),
451 		aSelItem			( SID_BMPMASK_EXEC, *this, *pBindinx ),
452 		maImgPipette		( BMP_RESID ( IMG_PIPETTE ) ),
453 		maImgPipetteH		( BMP_RESID ( IMG_PIPETTE_H ) )
454 {
455 	FreeResource();
456 
457 	ApplyStyle();
458 
459 	aTbxPipette.SetSizePixel( aTbxPipette.CalcWindowSizePixel() );
460 	aTbxPipette.SetSelectHdl( LINK( pData, MaskData, PipetteHdl ) );
461 	aBtnExec.SetClickHdl( LINK( pData, MaskData, ExecHdl ) );
462 
463 	aCbx1.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
464 	aCbx2.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
465 	aCbx3.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
466 	aCbx4.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
467 	aCbxTrans.SetClickHdl( LINK( pData, MaskData, CbxTransHdl ) );
468 
469     SetAccessibleNames ();
470 
471 	aLbColor1.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
472 	aLbColor2.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
473 	aLbColor3.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
474 	aLbColor4.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
475     aLbColorTrans.Disable();
476 
477 	aSp1.SetValue( 10 );
478 	aSp2.SetValue( 10 );
479 	aSp3.SetValue( 10 );
480 	aSp4.SetValue( 10 );
481 
482 	pQSet1->SetStyle( pQSet1->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
483 	pQSet1->SetColCount( 1 );
484 	pQSet1->SetLineCount( 1 );
485 //	pQSet1->SetExtraSpacing( 1 );
486 	//-----IAccessibility2 Implementation 2009
487 	String sColorPalette (BMP_RESID( RID_SVXDLG_BMPMASK_STR_PALETTE));
488     String sColorPaletteN;
489     sColorPaletteN = sColorPalette;
490     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
491 	//pQSet1->InsertItem( 1, aPipetteColor );
492 	pQSet1->InsertItem( 1, aPipetteColor, sColorPaletteN);
493 	//IAccessibility2 Implementation 2009-----
494 	pQSet1->SelectItem( 1 );
495 
496 	pQSet2->SetStyle( pQSet2->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
497 	pQSet2->SetColCount( 1 );
498 	pQSet2->SetLineCount( 1 );
499 //	pQSet2->SetExtraSpacing( 1 );
500 	//IAccessibility2 Implementation 2009-----
501 	sColorPaletteN = sColorPalette;
502     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
503 	//pQSet2->InsertItem( 1, aPipetteColor );
504 	pQSet2->InsertItem( 1, aPipetteColor, sColorPaletteN);
505 	//-----IAccessibility2 Implementation 2009
506 	pQSet2->SelectItem( 0 );
507 
508 	pQSet3->SetStyle( pQSet3->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
509 	pQSet3->SetColCount( 1 );
510 	pQSet3->SetLineCount( 1 );
511 //	pQSet3->SetExtraSpacing( 1 );
512 	//IAccessibility2 Implementation 2009-----
513 	sColorPaletteN = sColorPalette;
514  	sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
515 	pQSet3->InsertItem( 1, aPipetteColor, sColorPaletteN);
516 	//pQSet3->InsertItem( 1, aPipetteColor );
517 	//-----IAccessibility2 Implementation 2009
518 	pQSet3->SelectItem( 0 );
519 
520 	pQSet4->SetStyle( pQSet4->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
521 	pQSet4->SetColCount( 1 );
522 	pQSet4->SetLineCount( 1 );
523 //	pQSet4->SetExtraSpacing( 1 );
524 	//IAccessibility2 Implementation 2009-----
525 	sColorPaletteN = sColorPalette;
526     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
527 	pQSet4->InsertItem( 1, aPipetteColor, sColorPaletteN);
528 	//pQSet4->InsertItem( 1, aPipetteColor );
529 	//-----IAccessibility2 Implementation 2009
530 	pQSet4->SelectItem( 0 );
531 
532 	pQSet1->Show();
533 	pQSet2->Show();
534 	pQSet3->Show();
535 	pQSet4->Show();
536 	//IAccessibility2 Implementation 2009-----
537 	aCbx1.SetAccessibleRelationMemberOf( &aGrpQ );
538 	pQSet1->SetAccessibleRelationMemberOf( &aGrpQ );
539 	aSp1.SetAccessibleRelationMemberOf( &aGrpQ );
540 	aLbColor1.SetAccessibleRelationMemberOf( &aGrpQ );
541 	aCbx1.SetAccessibleRelationLabeledBy( &aFt1 );
542 	pQSet1->SetAccessibleRelationLabeledBy( &aFt1 );
543 	aSp1.SetAccessibleRelationLabeledBy( &aFt2 );
544 	aLbColor1.SetAccessibleRelationLabeledBy( &aFt3 );
545 	aCbx2.SetAccessibleRelationMemberOf( &aGrpQ );
546 	pQSet2->SetAccessibleRelationMemberOf( &aGrpQ );
547 	aSp2.SetAccessibleRelationMemberOf( &aGrpQ );
548 	aLbColor2.SetAccessibleRelationMemberOf( &aGrpQ );
549 	aCbx2.SetAccessibleRelationLabeledBy( &aFt1 );
550 	pQSet2->SetAccessibleRelationLabeledBy( &aFt1 );
551 	aSp2.SetAccessibleRelationLabeledBy( &aFt2 );
552 	aLbColor2.SetAccessibleRelationLabeledBy( &aFt3 );
553 	aCbx3.SetAccessibleRelationMemberOf( &aGrpQ );
554 	pQSet3->SetAccessibleRelationMemberOf( &aGrpQ );
555 	aSp3.SetAccessibleRelationMemberOf( &aGrpQ );
556 	aLbColor3.SetAccessibleRelationMemberOf( &aGrpQ );
557 	aCbx3.SetAccessibleRelationLabeledBy( &aFt1 );
558 	pQSet3->SetAccessibleRelationLabeledBy( &aFt1 );
559 	aSp3.SetAccessibleRelationLabeledBy( &aFt2 );
560 	aLbColor3.SetAccessibleRelationLabeledBy( &aFt3 );
561 	aCbx4.SetAccessibleRelationMemberOf( &aGrpQ );
562 	pQSet4->SetAccessibleRelationMemberOf( &aGrpQ );
563 	aSp4.SetAccessibleRelationMemberOf( &aGrpQ );
564 	aLbColor4.SetAccessibleRelationMemberOf( &aGrpQ );
565 	aCbx4.SetAccessibleRelationLabeledBy( &aFt1 );
566 	pQSet4->SetAccessibleRelationLabeledBy( &aFt1 );
567 	aSp4.SetAccessibleRelationLabeledBy( &aFt2 );
568 	aLbColor4.SetAccessibleRelationLabeledBy( &aFt3 );
569 	aLbColorTrans.SetAccessibleRelationLabeledBy( &aCbxTrans );
570 	aLbColorTrans.SetAccessibleRelationMemberOf( &aGrpQ );
571 	aCbxTrans.SetAccessibleRelationMemberOf( &aGrpQ );
572 	//-----IAccessibility2 Implementation 2009
573 }
574 
575 //-------------------------------------------------------------------------
576 
577 SvxBmpMask::~SvxBmpMask()
578 {
579 	delete pQSet1;
580 	delete pQSet2;
581 	delete pQSet3;
582 	delete pQSet4;
583 	delete pCtlPipette;
584 	delete pData;
585 }
586 
587 //-------------------------------------------------------------------------
588 
589 /** is called by a MaskSet when it is selected */
590 void SvxBmpMask::onSelect( MaskSet* pSet )
591 {
592 	// automaticaly set focus to the corresponding listbox
593 /*
594 	if( pSet == pQSet1 )
595 		aLbColor1.GrabFocus();
596 	else if( pSet == pQSet2 )
597 		aLbColor2.GrabFocus();
598 	else if( pSet == pQSet2 )
599 		aLbColor3.GrabFocus();
600 	else if( pSet == pQSet2 )
601 		aLbColor4.GrabFocus();
602 */
603 
604 	// now deselect all other value sets
605 	if( pSet != pQSet1 )
606 		pQSet1->SelectItem( 0 );
607 
608 	if( pSet != pQSet2 )
609 		pQSet2->SelectItem( 0 );
610 
611 	if( pSet != pQSet3 )
612 		pQSet3->SelectItem( 0 );
613 
614 	if( pSet != pQSet4 )
615 		pQSet4->SelectItem( 0 );
616 }
617 
618 //-------------------------------------------------------------------------
619 
620 sal_Bool SvxBmpMask::Close()
621 {
622 	SfxBoolItem aItem2( SID_BMPMASK_PIPETTE, sal_False );
623 	GetBindings().GetDispatcher()->Execute( SID_BMPMASK_PIPETTE, OWN_CALLMODE, &aItem2, 0L );
624 
625 	return SfxDockingWindow::Close();
626 }
627 
628 //-------------------------------------------------------------------------
629 
630 sal_Bool SvxBmpMask::NeedsColorTable() const
631 {
632 	return ( aLbColor1.GetEntryCount() == 0 );
633 }
634 
635 //-------------------------------------------------------------------------
636 
637 void SvxBmpMask::SetColorTable( const XColorTable* pTable )
638 {
639 	if ( pTable && ( pTable != pColTab ) )
640 	{
641 		const String aTransp( BMP_RESID( RID_SVXDLG_BMPMASK_STR_TRANSP ) );
642 
643 		pColTab = pTable;
644 
645 		aLbColorTrans.Fill( pColTab );
646 		aLbColorTrans.SelectEntryPos( 0 );
647 
648 		aLbColor1.Fill( pColTab );
649 		aLbColor1.InsertEntry( TRANSP_COL, aTransp, 0 );
650 		aLbColor1.SelectEntryPos( 0 );
651 
652 		aLbColor2.Fill( pColTab );
653 		aLbColor2.InsertEntry( TRANSP_COL, aTransp, 0 );
654 		aLbColor2.SelectEntryPos( 0 );
655 
656 		aLbColor3.Fill( pColTab );
657 		aLbColor3.InsertEntry( TRANSP_COL, aTransp, 0 );
658 		aLbColor3.SelectEntryPos( 0 );
659 
660 		aLbColor4.Fill( pColTab );
661 		aLbColor4.InsertEntry( TRANSP_COL, aTransp, 0 );
662 		aLbColor4.SelectEntryPos( 0 );
663 	}
664 }
665 
666 //-------------------------------------------------------------------------
667 
668 void SvxBmpMask::SetColor( const Color& rColor )
669 {
670 	aPipetteColor = rColor;
671 	pCtlPipette->SetColor( aPipetteColor );
672 }
673 
674 //-------------------------------------------------------------------------
675 
676 void SvxBmpMask::PipetteClicked()
677 {
678 	if( pQSet1->GetSelectItemId() == 1 )
679 	{
680 		aCbx1.Check( sal_True );
681 		pData->CbxHdl( &aCbx1 );
682 		pQSet1->SetItemColor( 1, aPipetteColor );
683 	}
684 	else if( pQSet2->GetSelectItemId() == 1 )
685 	{
686 		aCbx2.Check( sal_True );
687 		pData->CbxHdl( &aCbx2 );
688 		pQSet2->SetItemColor( 1, aPipetteColor );
689 	}
690 	else if( pQSet3->GetSelectItemId() == 1 )
691 	{
692 		aCbx3.Check( sal_True );
693 		pData->CbxHdl( &aCbx3 );
694 		pQSet3->SetItemColor( 1, aPipetteColor );
695 	}
696 	else if( pQSet4->GetSelectItemId() == 1 )
697 	{
698 		aCbx4.Check( sal_True );
699 		pData->CbxHdl( &aCbx4 );
700 		pQSet4->SetItemColor( 1, aPipetteColor );
701 	}
702 
703 	aTbxPipette.CheckItem( TBI_PIPETTE, sal_False );
704 	pData->PipetteHdl( &aTbxPipette );
705 }
706 
707 //-------------------------------------------------------------------------
708 
709 void SvxBmpMask::SetExecState( sal_Bool bEnable )
710 {
711 	pData->SetExecState( bEnable );
712 
713 	if ( pData->IsExecReady() && pData->IsCbxReady() )
714 		aBtnExec.Enable();
715 	else
716 		aBtnExec.Disable();
717 }
718 
719 //-------------------------------------------------------------------------
720 
721 sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uIntPtr* pTols )
722 {
723 	sal_uInt16  nCount = 0;
724 
725 	if ( aCbx1.IsChecked() )
726 	{
727 		pSrcCols[nCount] = pQSet1->GetItemColor( 1 );
728 		pDstCols[nCount] = aLbColor1.GetSelectEntryColor();
729 		pTols[nCount++] = static_cast<sal_uIntPtr>(aSp1.GetValue());
730 	}
731 
732 	if ( aCbx2.IsChecked() )
733 	{
734 		pSrcCols[nCount] = pQSet2->GetItemColor( 1 );
735 		pDstCols[nCount] = aLbColor2.GetSelectEntryColor();
736 		pTols[nCount++] = static_cast<sal_uIntPtr>(aSp2.GetValue());
737 	}
738 
739 	if ( aCbx3.IsChecked() )
740 	{
741 		pSrcCols[nCount] = pQSet3->GetItemColor( 1 );
742 		pDstCols[nCount] = aLbColor3.GetSelectEntryColor();
743 		pTols[nCount++] = static_cast<sal_uIntPtr>(aSp3.GetValue());
744 	}
745 
746 	if ( aCbx4.IsChecked() )
747 	{
748 		pSrcCols[nCount] = pQSet4->GetItemColor( 1 );
749 		pDstCols[nCount] = aLbColor4.GetSelectEntryColor();
750 		pTols[nCount++] = static_cast<sal_uIntPtr>(aSp4.GetValue());
751 	}
752 
753 	return nCount;
754 }
755 
756 //-------------------------------------------------------------------------
757 
758 Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap )
759 {
760 	Bitmap			aBitmap( rBitmap );
761 	Color			pSrcCols[4];
762 	Color			pDstCols[4];
763 	sal_uIntPtr			pTols[4];
764 	const sal_uInt16	nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
765 
766 	EnterWait();
767 	aBitmap.Replace( pSrcCols, pDstCols, nCount, pTols );
768 	LeaveWait();
769 
770 	return aBitmap;
771 }
772 
773 //-------------------------------------------------------------------------
774 
775 BitmapEx SvxBmpMask::ImpMask( const BitmapEx& rBitmapEx )
776 {
777 	return BitmapEx( ImpMask( rBitmapEx.GetBitmap() ), rBitmapEx.GetMask() );
778 }
779 
780 //-------------------------------------------------------------------------
781 
782 BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol )
783 {
784 	EnterWait();
785 
786 	BitmapEx	aBmpEx;
787 	Bitmap		aMask( rBitmapEx.GetBitmap().CreateMask( rColor, nTol ) );
788 
789 	if( rBitmapEx.IsTransparent() )
790 		aMask.CombineSimple( rBitmapEx.GetMask(), BMP_COMBINE_OR );
791 
792 	aBmpEx = BitmapEx( rBitmapEx.GetBitmap(), aMask );
793 	LeaveWait();
794 
795 	return aBmpEx;
796 }
797 
798 //-------------------------------------------------------------------------
799 
800 Animation SvxBmpMask::ImpMask( const Animation& rAnimation )
801 {
802 	Animation	aAnimation( rAnimation );
803 	Color		pSrcCols[4];
804 	Color		pDstCols[4];
805 	sal_uIntPtr		pTols[4];
806 	InitColorArrays( pSrcCols, pDstCols, pTols );
807 	sal_uInt16		nAnimationCount = aAnimation.Count();
808 
809 	for( sal_uInt16 i = 0; i < nAnimationCount; i++ )
810 	{
811 		AnimationBitmap aAnimBmp( aAnimation.Get( i ) );
812 		aAnimBmp.aBmpEx = Mask( aAnimBmp.aBmpEx ).GetBitmapEx();
813 		aAnimation.Replace( aAnimBmp, i );
814 	}
815 
816 	return aAnimation;
817 }
818 
819 //-------------------------------------------------------------------------
820 
821 GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf )
822 {
823 	GDIMetaFile aMtf;
824 	Color		pSrcCols[4];
825 	Color		pDstCols[4];
826 	sal_uIntPtr		pTols[4];
827 	sal_uInt16      nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
828 	sal_Bool		pTrans[4];
829 
830 	// Falls keine Farben ausgewaehlt, kopieren wir nur das Mtf
831 	if( !nCount )
832 		aMtf = rMtf;
833 	else
834 	{
835 		Color       aCol;
836 		long        nVal;
837 		long        nTol;
838 		long        nR;
839 		long        nG;
840 		long        nB;
841 		long*       pMinR = new long[nCount];
842 		long*       pMaxR = new long[nCount];
843 		long*       pMinG = new long[nCount];
844 		long*       pMaxG = new long[nCount];
845 		long*       pMinB = new long[nCount];
846 		long*       pMaxB = new long[nCount];
847 		sal_uInt16      i;
848 		sal_Bool        bReplace;
849 
850 		aMtf.SetPrefSize( rMtf.GetPrefSize() );
851 		aMtf.SetPrefMapMode( rMtf.GetPrefMapMode() );
852 
853 		// Farbvergleichsarrays vorbereiten
854 		for( i = 0; i < nCount; i++ )
855 		{
856 			nTol = ( pTols[i] * 255L ) / 100L;
857 
858 			nVal = ( (long) pSrcCols[i].GetRed() );
859 			pMinR[i] = Max( nVal - nTol, 0L );
860 			pMaxR[i] = Min( nVal + nTol, 255L );
861 
862 			nVal = ( (long) pSrcCols[i].GetGreen() );
863 			pMinG[i] = Max( nVal - nTol, 0L );
864 			pMaxG[i] = Min( nVal + nTol, 255L );
865 
866 			nVal = ( (long) pSrcCols[i].GetBlue() );
867 			pMinB[i] = Max( nVal - nTol, 0L );
868 			pMaxB[i] = Min( nVal + nTol, 255L );
869 
870 			pTrans[ i ] = ( pDstCols[ i ] == TRANSP_COL );
871 		}
872 
873 		// Actions untersuchen und Farben ggf. ersetzen
874 		for( sal_uIntPtr nAct = 0UL, nActCount = rMtf.GetActionCount(); nAct < nActCount; nAct++ )
875 		{
876 			MetaAction* pAction = rMtf.GetAction( nAct );
877 
878 			bReplace = sal_False;
879 
880 			switch( pAction->GetType() )
881 			{
882 				case( META_PIXEL_ACTION ):
883 				{
884 					MetaPixelAction* pAct = (MetaPixelAction*) pAction;
885 
886 					aCol = pAct->GetColor();
887 					TEST_COLS();
888 
889 					if( bReplace )
890 						pAct = new MetaPixelAction( pAct->GetPoint(), aCol );
891 					else
892 						pAct->Duplicate();
893 
894 					aMtf.AddAction( pAct );
895 				}
896 				break;
897 
898 				case( META_LINECOLOR_ACTION ):
899 				{
900 					MetaLineColorAction* pAct = (MetaLineColorAction*) pAction;
901 
902 					aCol = pAct->GetColor();
903 					TEST_COLS();
904 
905 					if( bReplace )
906 						pAct = new MetaLineColorAction( aCol, !pTrans[ i ] );
907 					else
908 						pAct->Duplicate();
909 
910 					aMtf.AddAction( pAct );
911 				}
912 				break;
913 
914 				case( META_FILLCOLOR_ACTION ):
915 				{
916 					MetaFillColorAction* pAct = (MetaFillColorAction*) pAction;
917 
918 					aCol = pAct->GetColor();
919 					TEST_COLS();
920 
921 					if( bReplace )
922 						pAct = new MetaFillColorAction( aCol, !pTrans[ i ] );
923 					else
924 						pAct->Duplicate();
925 
926 					aMtf.AddAction( pAct );
927 				}
928 				break;
929 
930 				case( META_TEXTCOLOR_ACTION ):
931 				{
932 					MetaTextColorAction* pAct = (MetaTextColorAction*) pAction;
933 
934 					aCol = pAct->GetColor();
935 					TEST_COLS();
936 
937 					if( bReplace )
938 						pAct = new MetaTextColorAction( aCol );
939 					else
940 						pAct->Duplicate();
941 
942 					aMtf.AddAction( pAct );
943 				}
944 				break;
945 
946 				case( META_TEXTFILLCOLOR_ACTION ):
947 				{
948 					MetaTextFillColorAction* pAct = (MetaTextFillColorAction*) pAction;
949 
950 					aCol = pAct->GetColor();
951 					TEST_COLS();
952 
953 					if( bReplace )
954 						pAct = new MetaTextFillColorAction( aCol, !pTrans[ i ] );
955 					else
956 						pAct->Duplicate();
957 
958 					aMtf.AddAction( pAct );
959 				}
960 				break;
961 
962 				case( META_FONT_ACTION ):
963 				{
964 					MetaFontAction* pAct = (MetaFontAction*) pAction;
965 					Font			aFont( pAct->GetFont() );
966 
967 					aCol = aFont.GetColor();
968 					TEST_COLS();
969 
970 					if( bReplace )
971 					{
972 						aFont.SetColor( aCol );
973 						pAct = new MetaFontAction( aFont );
974 					}
975 					else
976 						pAct->Duplicate();
977 
978 					aMtf.AddAction( pAct );
979 				}
980 				break;
981 
982 				case( META_WALLPAPER_ACTION ):
983 				{
984 					MetaWallpaperAction*	pAct = (MetaWallpaperAction*) pAction;
985 					Wallpaper				aWall( pAct->GetWallpaper() );
986 
987 					aCol = aWall.GetColor();
988 					TEST_COLS();
989 
990 					if( bReplace )
991 					{
992 						aWall.SetColor( aCol );
993 						pAct = new MetaWallpaperAction( pAct->GetRect(), aWall );
994 					}
995 					else
996 						pAct->Duplicate();
997 
998 					aMtf.AddAction( pAct );
999 				}
1000 				break;
1001 
1002 				case( META_BMP_ACTION ):
1003 				{
1004 					MetaBmpAction*	pAct = (MetaBmpAction*) pAction;
1005 					const Bitmap	aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
1006 
1007 					pAct = new MetaBmpAction( pAct->GetPoint(), aBmp );
1008 					aMtf.AddAction( pAct );
1009 				}
1010 				break;
1011 
1012 				case( META_BMPSCALE_ACTION ):
1013 				{
1014 					MetaBmpScaleAction* pAct = (MetaBmpScaleAction*) pAction;
1015 					const Bitmap		aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
1016 
1017 					pAct = new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(), aBmp );
1018 					aMtf.AddAction( pAct );
1019 				}
1020 				break;
1021 
1022 				case( META_BMPSCALEPART_ACTION ):
1023 				{
1024 					MetaBmpScalePartAction* pAct = (MetaBmpScalePartAction*) pAction;
1025 					const Bitmap			aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
1026 
1027 					pAct = new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1028 													   pAct->GetSrcPoint(), pAct->GetSrcSize(), aBmp );
1029 					aMtf.AddAction( pAct );
1030 				}
1031 				break;
1032 
1033 				case( META_BMPEX_ACTION ):
1034 				{
1035 					MetaBmpExAction*	pAct = (MetaBmpExAction*) pAction;
1036 					const BitmapEx		aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
1037 
1038 					pAct = new MetaBmpExAction( pAct->GetPoint(), aBmpEx );
1039 					aMtf.AddAction( pAct );
1040 				}
1041 				break;
1042 
1043 				case( META_BMPEXSCALE_ACTION ):
1044 				{
1045 					MetaBmpExScaleAction*	pAct = (MetaBmpExScaleAction*) pAction;
1046 					const BitmapEx			aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
1047 
1048 					pAct = new MetaBmpExScaleAction( pAct->GetPoint(), pAct->GetSize(), aBmpEx );
1049 					aMtf.AddAction( pAct );
1050 				}
1051 				break;
1052 
1053 				case( META_BMPEXSCALEPART_ACTION ):
1054 				{
1055 					MetaBmpExScalePartAction*	pAct = (MetaBmpExScalePartAction*) pAction;
1056 					const BitmapEx				aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
1057 
1058 					pAct = new MetaBmpExScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1059 														 pAct->GetSrcPoint(), pAct->GetSrcSize(), aBmpEx );
1060 					aMtf.AddAction( pAct );
1061 				}
1062 				break;
1063 
1064 				default:
1065 				{
1066 					pAction->Duplicate();
1067 					aMtf.AddAction( pAction );
1068 				}
1069 				break;
1070 			}
1071 		}
1072 
1073 		delete[] pMinR;
1074 		delete[] pMaxR;
1075 		delete[] pMinG;
1076 		delete[] pMaxG;
1077 		delete[] pMinB;
1078 		delete[] pMaxB;
1079 	}
1080 
1081 	LeaveWait();
1082 
1083 	return aMtf;
1084 }
1085 
1086 //-------------------------------------------------------------------------
1087 
1088 BitmapEx SvxBmpMask::ImpReplaceTransparency( const BitmapEx& rBmpEx, const Color& rColor )
1089 {
1090 	if( rBmpEx.IsTransparent() )
1091 	{
1092 		Bitmap aBmp( rBmpEx.GetBitmap() );
1093 		aBmp.Replace( rBmpEx.GetMask(), rColor );
1094 		return aBmp;
1095 	}
1096 	else
1097 		return rBmpEx;
1098 }
1099 
1100 //-------------------------------------------------------------------------
1101 
1102 Animation SvxBmpMask::ImpReplaceTransparency( const Animation& rAnim, const Color& rColor )
1103 {
1104 	Animation	aAnimation( rAnim );
1105 	sal_uInt16		nAnimationCount = aAnimation.Count();
1106 
1107 	for( sal_uInt16 i = 0; i < nAnimationCount; i++ )
1108 	{
1109 		AnimationBitmap aAnimBmp( aAnimation.Get( i ) );
1110 		aAnimBmp.aBmpEx = ImpReplaceTransparency( aAnimBmp.aBmpEx, rColor );
1111 		aAnimation.Replace( aAnimBmp, i );
1112 	}
1113 
1114 	return aAnimation;
1115 }
1116 
1117 //-------------------------------------------------------------------------
1118 
1119 GDIMetaFile SvxBmpMask::ImpReplaceTransparency( const GDIMetaFile& rMtf, const Color& rColor )
1120 {
1121 	VirtualDevice	aVDev;
1122 	GDIMetaFile		aMtf;
1123 	const MapMode&	rPrefMap = rMtf.GetPrefMapMode();
1124 	const Size&		rPrefSize = rMtf.GetPrefSize();
1125 	const sal_uIntPtr		nActionCount = rMtf.GetActionCount();
1126 
1127 	aVDev.EnableOutput( sal_False );
1128 	aMtf.Record( &aVDev );
1129 	aMtf.SetPrefSize( rPrefSize );
1130 	aMtf.SetPrefMapMode( rPrefMap );
1131 	aVDev.SetLineColor( rColor );
1132 	aVDev.SetFillColor( rColor );
1133 
1134 	// Actions nacheinander abspielen; zuerst
1135 	// den gesamten Bereich auf die Ersatzfarbe setzen
1136 	aVDev.DrawRect( Rectangle( rPrefMap.GetOrigin(), rPrefSize ) );
1137 	for ( sal_uIntPtr i = 0; i < nActionCount; i++ )
1138 	{
1139 		MetaAction* pAct = rMtf.GetAction( i );
1140 
1141 		pAct->Duplicate();
1142 		aMtf.AddAction( pAct );
1143 	}
1144 
1145 	aMtf.Stop();
1146 	aMtf.WindStart();
1147 
1148 	return aMtf;
1149 }
1150 
1151 //-------------------------------------------------------------------------
1152 
1153 Graphic SvxBmpMask::Mask( const Graphic& rGraphic )
1154 {
1155 	Graphic		aGraphic( rGraphic );
1156 	const Color	aReplColor( aLbColorTrans.GetSelectEntryColor() );
1157 
1158 	switch( rGraphic.GetType() )
1159 	{
1160 		case( GRAPHIC_BITMAP ):
1161 		{
1162 			if( rGraphic.IsAnimated() )
1163 			{
1164 				// Transparenz ersetzen?
1165 				if ( aCbxTrans.IsChecked() )
1166 					aGraphic = ImpReplaceTransparency( rGraphic.GetAnimation(), aReplColor );
1167 				else
1168 					aGraphic = ImpMask( rGraphic.GetAnimation() );
1169 			}
1170 			else
1171 			{
1172 				// Transparenz ersetzen?
1173 				if( aCbxTrans.IsChecked() )
1174 				{
1175 					if( aGraphic.IsTransparent() )
1176 					{
1177 						BitmapEx	aBmpEx( ImpReplaceTransparency( aGraphic.GetBitmapEx(), aReplColor ) );
1178 						const Size	aSize( aBmpEx.GetSizePixel() );
1179 
1180 						if( aSize.Width() && aSize.Height() )
1181 							aGraphic = aBmpEx;
1182 					}
1183 				}
1184 				else
1185 				{
1186 					Color	pSrcCols[4];
1187 					Color	pDstCols[4];
1188 					sal_uIntPtr	pTols[4];
1189 					sal_uInt16	nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
1190 
1191 					if( nCount )
1192 					{
1193 						// erstmal alle Transparent-Farben setzen
1194 						for( sal_uInt16 i = 0; i < nCount; i++ )
1195 						{
1196 							// Haben wir eine Transparenzfarbe?
1197 							if( pDstCols[i] == TRANSP_COL )
1198 							{
1199 								BitmapEx	aBmpEx( ImpMaskTransparent( aGraphic.GetBitmapEx(),
1200 																		pSrcCols[ i ], pTols[ i ] ) );
1201 								const Size	aSize( aBmpEx.GetSizePixel() );
1202 
1203 								if( aSize.Width() && aSize.Height() )
1204 									aGraphic = aBmpEx;
1205 							}
1206 						}
1207 
1208 						// jetzt noch einmal mit den normalen Farben ersetzen
1209 						Bitmap	aBitmap( ImpMask( aGraphic.GetBitmap() ) );
1210 						Size	aSize( aBitmap.GetSizePixel() );
1211 
1212 						if ( aSize.Width() && aSize.Height() )
1213 						{
1214 							if ( aGraphic.IsTransparent() )
1215 								aGraphic = Graphic( BitmapEx( aBitmap, aGraphic.GetBitmapEx().GetMask() ) );
1216 							else
1217 								aGraphic = aBitmap;
1218 						}
1219 					}
1220 				}
1221 			}
1222 		}
1223 		break;
1224 
1225 		case( GRAPHIC_GDIMETAFILE ):
1226 		{
1227 			GDIMetaFile	aMtf( aGraphic.GetGDIMetaFile() );
1228 
1229 			// Transparenz ersetzen?
1230 			if( aCbxTrans.IsChecked() )
1231 				aMtf = ImpReplaceTransparency( aMtf, aReplColor );
1232 			else
1233 				aMtf = ImpMask( aMtf );
1234 
1235 			Size aSize( aMtf.GetPrefSize() );
1236 			if ( aSize.Width() && aSize.Height() )
1237 				aGraphic = Graphic( aMtf );
1238 			else
1239 				aGraphic = rGraphic;
1240 		}
1241 		break;
1242 
1243 		default:
1244 			aGraphic = rGraphic;
1245 		break;
1246 	}
1247 
1248 	if( aGraphic != rGraphic )
1249 	{
1250 		aGraphic.SetPrefSize( rGraphic.GetPrefSize() );
1251 		aGraphic.SetPrefMapMode( rGraphic.GetPrefMapMode() );
1252 	}
1253 
1254 	return aGraphic;
1255 }
1256 
1257 //-------------------------------------------------------------------------
1258 
1259 sal_Bool SvxBmpMask::IsEyedropping() const
1260 {
1261 	return aTbxPipette.IsItemChecked( TBI_PIPETTE );
1262 }
1263 
1264 void SvxBmpMask::DataChanged( const DataChangedEvent& rDCEvt )
1265 {
1266     SfxDockingWindow::DataChanged( rDCEvt );
1267 
1268 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1269             ApplyStyle();
1270 }
1271 
1272 void SvxBmpMask::ApplyStyle()
1273 {
1274 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1275 
1276 	aTbxPipette.SetItemImage( TBI_PIPETTE, bHighContrast ? maImgPipetteH : maImgPipette );
1277 }
1278 
1279 
1280 /** Set an accessible name for the source color check boxes.  Without this
1281     the lengthy description is read.
1282 */
1283 void SvxBmpMask::SetAccessibleNames (void)
1284 {
1285     String sSourceColor (BMP_RESID( RID_SVXDLG_BMPMASK_STR_SOURCECOLOR));
1286     String sSourceColorN;
1287 
1288     sSourceColorN = sSourceColor;
1289     sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
1290     aCbx1.SetAccessibleName (sSourceColorN);
1291 
1292     sSourceColorN = sSourceColor;
1293     sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
1294     aCbx2.SetAccessibleName (sSourceColorN);
1295 
1296     sSourceColorN = sSourceColor;
1297     sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
1298     aCbx3.SetAccessibleName (sSourceColorN);
1299 
1300     sSourceColorN = sSourceColor;
1301     sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
1302     aCbx4.SetAccessibleName (sSourceColorN);
1303 	//IAccessibility2 Implementation 2009-----
1304 	// set the accessible name for valueset
1305 	String sColorPalette (BMP_RESID( RID_SVXDLG_BMPMASK_STR_PALETTE));
1306     String sColorPaletteN;
1307     sColorPaletteN = sColorPalette;
1308     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
1309     pQSet1->SetText (sColorPaletteN);
1310     sColorPaletteN = sColorPalette;
1311     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
1312     pQSet2->SetText (sColorPaletteN);
1313     sColorPaletteN = sColorPalette;
1314     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
1315     pQSet3->SetText (sColorPaletteN);
1316     sColorPaletteN = sColorPalette;
1317     sColorPaletteN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
1318     pQSet4->SetText (sColorPaletteN);
1319     // set the accessible for replace with spin boxes.
1320 	String sTolerance(BMP_RESID( RID_SVXDLG_BMPMASK_STR_TOLERANCE));
1321     String sToleranceN;
1322     sToleranceN = sTolerance;
1323     sToleranceN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
1324     aSp1.SetAccessibleName (sToleranceN);
1325     sToleranceN = sTolerance;
1326     sToleranceN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
1327     aSp2.SetAccessibleName (sToleranceN);
1328     sToleranceN = sTolerance;
1329     sToleranceN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
1330     aSp3.SetAccessibleName (sToleranceN);
1331     sToleranceN = sTolerance;
1332     sToleranceN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
1333     aSp4.SetAccessibleName (sToleranceN);
1334     // set the accessible for replace with combo boxes.
1335    	String sReplaceWith(BMP_RESID( RID_SVXDLG_BMPMASK_STR_REPLACEWITH));
1336     String sReplaceWithN;
1337     sReplaceWithN = sReplaceWith;
1338     sReplaceWithN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
1339     aLbColor1.SetAccessibleName (sReplaceWithN);
1340     sReplaceWithN = sReplaceWith;
1341     sReplaceWithN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
1342     aLbColor2.SetAccessibleName (sReplaceWithN);
1343     sReplaceWithN = sReplaceWith;
1344     sReplaceWithN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
1345     aLbColor3.SetAccessibleName (sReplaceWithN);
1346     sReplaceWithN = sReplaceWith;
1347     sReplaceWithN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
1348     aLbColor4.SetAccessibleName (sReplaceWithN);
1349 	//-----IAccessibility2 Implementation 2009
1350 }
1351