xref: /aoo42x/main/svx/source/dialog/dlgctrl.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 
27 // include ---------------------------------------------------------------
28 #include <tools/shl.hxx>
29 #include <vcl/svapp.hxx>
30 #include <svx/xtable.hxx>
31 #include <svx/xpool.hxx>
32 #include <svx/dialogs.hrc>
33 #include <accessibility.hrc>
34 #include <svx/dlgctrl.hxx>
35 #include <svx/dialmgr.hxx>
36 #include <tools/poly.hxx>
37 #include <vcl/region.hxx>
38 #include <vcl/gradient.hxx>
39 #include <vcl/hatch.hxx>
40 // IAccessibility2 implementation 2009. ------
41 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_
42 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
45 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
48 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
49 #endif
50 #include "svxpixelctlaccessiblecontext.hxx"
51 // ------ IAccessibility2 implementation 2009.
52 #include <svtools/colorcfg.hxx>
53 #include <svxrectctaccessiblecontext.hxx>
54 #include <com/sun/star/lang/XUnoTunnel.hpp>
55 #include <basegfx/point/b2dpoint.hxx>
56 #include <basegfx/polygon/b2dpolygon.hxx>
57 #include <svx/svdorect.hxx>
58 #include <svx/svdmodel.hxx>
59 #include <svx/svdopath.hxx>
60 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
61 #include <svx/sdr/contact/displayinfo.hxx>
62 #include <linectrl.hrc>
63 #include <vcl/bmpacc.hxx>
64 #include <svx/xbtmpit.hxx>
65 
66 #define OUTPUT_DRAWMODE_COLOR		(DRAWMODE_DEFAULT)
67 #define OUTPUT_DRAWMODE_CONTRAST	(DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
68 
69 using namespace ::com::sun::star::uno;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star::accessibility;
72 
73 
74 /*************************************************************************
75 |*
76 |*	Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
77 |*	eines Objekts
78 |*
79 \************************************************************************/
80 
81 Bitmap& SvxRectCtl::GetRectBitmap( void )
82 {
83 	if( !pBitmap )
84 		InitRectBitmap();
85 
86 	return *pBitmap;
87 }
88 
89 SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
90 						sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
91 
92 	Control( pParent, rResId ),
93 
94 	pAccContext	( NULL ),
95     nBorderWidth( nBorder ),
96     nRadius     ( nCircle),
97     eDefRP      ( eRpt ),
98     eCS         ( eStyle ),
99 	pBitmap		( NULL ),
100     m_nState    ( 0 ),
101     mbCompleteDisable(sal_False)
102 {
103 	SetMapMode( MAP_100TH_MM );
104     Resize_Impl();
105 }
106 
107 // -----------------------------------------------------------------------
108 
109 SvxRectCtl::~SvxRectCtl()
110 {
111 	delete pBitmap;
112 
113 	if( pAccContext )
114 		pAccContext->release();
115 }
116 
117 // -----------------------------------------------------------------------
118 void SvxRectCtl::Resize()
119 {
120     Resize_Impl();
121     Control::Resize();
122 }
123 
124 // -----------------------------------------------------------------------
125 
126 void SvxRectCtl::Resize_Impl()
127 {
128     aSize = GetOutputSize();
129 
130 	switch( eCS )
131 	{
132 		case CS_RECT:
133 		case CS_ANGLE:
134 		case CS_SHADOW:
135 			aPtLT = Point( 0 + nBorderWidth,  0 + nBorderWidth );
136 			aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
137 			aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
138 
139 			aPtLM = Point( 0 + nBorderWidth,  aSize.Height() / 2 );
140 			aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
141 			aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
142 
143 			aPtLB = Point( 0 + nBorderWidth,	aSize.Height() - nBorderWidth );
144 			aPtMB = Point( aSize.Width() / 2,	aSize.Height() - nBorderWidth );
145 			aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
146 		break;
147 
148 		case CS_LINE:
149 			aPtLT = Point( 0 + 3 * nBorderWidth,  0 + nBorderWidth );
150 			aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
151 			aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
152 
153 			aPtLM = Point( 0 + 3 * nBorderWidth,  aSize.Height() / 2 );
154 			aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
155 			aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
156 
157 			aPtLB = Point( 0 + 3 * nBorderWidth,	aSize.Height() - nBorderWidth );
158 			aPtMB = Point( aSize.Width() / 2,	aSize.Height() - nBorderWidth );
159 			aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
160 		break;
161 	}
162 	Reset();
163 	InitSettings( sal_True, sal_True );
164 }
165 // -----------------------------------------------------------------------
166 
167 void SvxRectCtl::InitRectBitmap( void )
168 {
169 	if( pBitmap )
170 		delete pBitmap;
171 
172 	const StyleSettings&	rStyles = Application::GetSettings().GetStyleSettings();
173 	svtools::ColorConfig aColorConfig;
174 
175 	pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
176 
177 	// set bitmap-colors
178 	Color	aColorAry1[7];
179 	Color	aColorAry2[7];
180 	aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );	// light-gray
181 	aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );	// yellow
182 	aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );	// white
183 	aColorAry1[3] = Color( 0x80, 0x80, 0x80 );	// dark-gray
184 	aColorAry1[4] = Color( 0x00, 0x00, 0x00 );  // black
185 	aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );	// green
186 	aColorAry1[6] = Color( 0x00, 0x00, 0xFF );	// blue
187 	aColorAry2[0] = rStyles.GetDialogColor();		// background
188 	aColorAry2[1] = rStyles.GetWindowColor();
189 	aColorAry2[2] = rStyles.GetLightColor();
190 	aColorAry2[3] = rStyles.GetShadowColor();
191 	aColorAry2[4] = rStyles.GetDarkShadowColor();
192 	aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
193 	aColorAry2[6] = rStyles.GetDialogColor();
194 
195 #ifdef DBG_UTIL
196 	static sal_Bool		bModify = sal_False;
197 	sal_Bool&			rModify = bModify;
198 	if( rModify )
199 	{
200 		static int		n = 0;
201 		static sal_uInt8	r = 0xFF;
202 		static sal_uInt8	g = 0x00;
203 		static sal_uInt8	b = 0xFF;
204 		int&			rn = n;
205 		sal_uInt8&			rr = r;
206 		sal_uInt8&			rg = g;
207 		sal_uInt8&			rb = b;
208 		aColorAry2[ rn ] = Color( rr, rg, rb );
209 	}
210 #endif
211 
212 	pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
213 }
214 
215 // -----------------------------------------------------------------------
216 
217 void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
218 {
219 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
220 
221 	if( bForeground )
222 	{
223 		svtools::ColorConfig aColorConfig;
224 		Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
225 
226 		if ( IsControlForeground() )
227 			aTextColor = GetControlForeground();
228 		SetTextColor( aTextColor );
229 	}
230 
231 	if( bBackground )
232 	{
233 		if ( IsControlBackground() )
234 			SetBackground( GetControlBackground() );
235 		else
236 			SetBackground( rStyleSettings.GetWindowColor() );
237 	}
238 
239 	delete pBitmap;
240 	pBitmap = NULL;		// forces new creating of bitmap
241 
242 	Invalidate();
243 }
244 
245 /*************************************************************************
246 |*
247 |*	Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
248 |*	wird benachrichtigt, dass der Punkt geaendert wurde
249 |*
250 \************************************************************************/
251 
252 void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
253 {
254 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
255 	if(!IsCompletelyDisabled())
256 	{
257 		Point aPtLast = aPtNew;
258 
259 		aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
260 
261 		if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
262 		{
263 			aPtNew = aPtLast;
264 		}
265 		else
266 		{
267 			Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
268 								   aPtLast + Point( nRadius, nRadius ) ) );
269 			Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
270 								   aPtNew + Point( nRadius, nRadius ) ) );
271 			eRP = GetRPFromPoint( aPtNew );
272 
273 			SetActualRP( eRP );
274 
275 			if( WINDOW_TABPAGE == GetParent()->GetType() )
276 				( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
277 		}
278 	}
279 }
280 
281 // -----------------------------------------------------------------------
282 
283 void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
284 {
285 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
286 	if(!IsCompletelyDisabled())
287 	{
288 		RECT_POINT eNewRP = eRP;
289 		sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
290 
291 		switch( rKeyEvt.GetKeyCode().GetCode() )
292 		{
293 			case KEY_DOWN:
294 			{
295 				if( !(m_nState & CS_NOVERT) )
296 					switch( eNewRP )
297 					{
298 						case RP_LT: eNewRP = RP_LM; break;
299 						case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
300 						case RP_RT: eNewRP = RP_RM; break;
301 						case RP_LM: eNewRP = RP_LB; break;
302 						case RP_MM: eNewRP = RP_MB; break;
303 						case RP_RM: eNewRP = RP_RB; break;
304                         default: ; //prevent warning
305                     }
306 			}
307 			break;
308 			case KEY_UP:
309 			{
310 				if( !(m_nState & CS_NOVERT) )
311 					switch( eNewRP )
312 					{
313 						case RP_LM: eNewRP = RP_LT; break;
314 						case RP_MM: eNewRP = RP_MT; break;
315 						case RP_RM: eNewRP = RP_RT; break;
316 						case RP_LB: eNewRP = RP_LM; break;
317 						case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
318 						case RP_RB: eNewRP = RP_RM; break;
319                         default: ; //prevent warning
320                     }
321 			}
322 			break;
323 			case KEY_LEFT:
324 			{
325 				if( !(m_nState & CS_NOHORZ) )
326 					switch( eNewRP )
327 					{
328 						case RP_MT: eNewRP = RP_LT; break;
329 						case RP_RT: eNewRP = RP_MT; break;
330 						case RP_MM: eNewRP = RP_LM; break;
331 						case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
332 						case RP_MB: eNewRP = RP_LB; break;
333 						case RP_RB: eNewRP = RP_MB; break;
334                         default: ; //prevent warning
335                     }
336 			}
337 			break;
338 			case KEY_RIGHT:
339 			{
340 				if( !(m_nState & CS_NOHORZ) )
341 					switch( eNewRP )
342 					{
343 						case RP_LT: eNewRP = RP_MT; break;
344 						case RP_MT: eNewRP = RP_RT; break;
345 						case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
346 						case RP_MM: eNewRP = RP_RM; break;
347 						case RP_LB: eNewRP = RP_MB; break;
348 						case RP_MB: eNewRP = RP_RB; break;
349                         default: ; //prevent warning
350                     }
351 			}
352 			break;
353 			default:
354 				Control::KeyInput( rKeyEvt );
355 				return;
356 		}
357 		if( eNewRP != eRP )
358 		{
359 			SetActualRP( eNewRP );
360 
361 			if( WINDOW_TABPAGE == GetParent()->GetType() )
362 				( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
363 
364 			SetFocusRect();
365 		}
366 	}
367 }
368 
369 // -----------------------------------------------------------------------
370 
371 void SvxRectCtl::StateChanged( StateChangedType nType )
372 {
373 	if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
374 		InitSettings( sal_True, sal_False );
375 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
376 		InitSettings( sal_False, sal_True );
377 
378 	Window::StateChanged( nType );
379 }
380 
381 // -----------------------------------------------------------------------
382 
383 void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
384 {
385 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
386 		InitSettings( sal_True, sal_True );
387 	else
388 		Window::DataChanged( rDCEvt );
389 }
390 
391 /*************************************************************************
392 |*
393 |*	Zeichnet das Control (Rechteck mit 9 Kreisen)
394 |*
395 \************************************************************************/
396 
397 void SvxRectCtl::Paint( const Rectangle& )
398 {
399 	Point	aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
400 
401 	const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
402 
403 	SetLineColor( rStyles.GetDialogColor() );
404 	SetFillColor( rStyles.GetDialogColor() );
405 	DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
406 
407 	if( IsEnabled() )
408 		SetLineColor( rStyles.GetLabelTextColor() );
409 	else
410 		SetLineColor( rStyles.GetShadowColor() );
411 
412 	SetFillColor();
413 
414 	switch( eCS )
415 	{
416 
417 		case CS_RECT:
418 		case CS_SHADOW:
419 			if( !IsEnabled() )
420 			{
421 				Color aOldCol = GetLineColor();
422 				SetLineColor( rStyles.GetLightColor() );
423 				DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
424 				SetLineColor( aOldCol );
425 			}
426 			DrawRect( Rectangle( aPtLT, aPtRB ) );
427 		break;
428 
429 		case CS_LINE:
430 			if( !IsEnabled() )
431 			{
432 				Color aOldCol = GetLineColor();
433 				SetLineColor( rStyles.GetLightColor() );
434 				DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
435 						  aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
436 				SetLineColor( aOldCol );
437 			}
438 			DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
439 					  aPtRM + Point( 2 * nBorderWidth, 0 ) );
440 		break;
441 
442 		case CS_ANGLE:
443 			if( !IsEnabled() )
444 			{
445 				Color aOldCol = GetLineColor();
446 				SetLineColor( rStyles.GetLightColor() );
447 				DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
448 				DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
449 				DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
450 				DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
451 				SetLineColor( aOldCol );
452 			}
453 			DrawLine( aPtLT, aPtRB );
454 			DrawLine( aPtLB, aPtRT );
455 			DrawLine( aPtLM, aPtRM );
456 			DrawLine( aPtMT, aPtMB );
457 		break;
458 
459 		default:
460 			break;
461 	}
462 	SetFillColor( GetBackground().GetColor() );
463 
464 	Size aBtnSize( 11, 11 );
465 	Size aDstBtnSize(  PixelToLogic( aBtnSize ) );
466 	Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
467 	Point aBtnPnt1( IsEnabled()?0:22,0 );
468 	Point aBtnPnt2( 11,0 );
469 	Point aBtnPnt3( 22,0 );
470 
471 	sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
472 	sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0;
473 
474 	Bitmap&			rBitmap = GetRectBitmap();
475 
476 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
477 	if(IsCompletelyDisabled())
478 	{
479 		DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
480 		DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
481 		DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
482 		DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
483 		if( eCS == CS_RECT || eCS == CS_LINE )
484 			DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
485 		DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
486 		DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
487 		DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
488 		DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
489 	}
490 	else
491 	{
492 		DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
493 		DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
494 		DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
495 
496 		DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
497 
498 		// Mittelpunkt bei Rechteck und Linie
499 		if( eCS == CS_RECT || eCS == CS_LINE )
500 			DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
501 
502 		DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
503 
504 		DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
505 		DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
506 		DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
507 	}
508 
509 	// draw active button, avoid center pos for angle
510 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
511 	if(!IsCompletelyDisabled())
512 	{
513 		if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
514 		{
515 			Point		aCenterPt( aPtNew );
516 			aCenterPt -= aToCenter;
517 
518 			DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
519 		}
520 	}
521 }
522 
523 /*************************************************************************
524 |*
525 |*	Konvertiert RECT_POINT in Point
526 |*
527 \************************************************************************/
528 
529 Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
530 {
531     switch( _eRP )
532 	{
533 		case RP_LT: return aPtLT;
534 		case RP_MT: return aPtMT;
535 		case RP_RT: return aPtRT;
536 		case RP_LM: return aPtLM;
537 		case RP_MM: return aPtMM;
538 		case RP_RM: return aPtRM;
539 		case RP_LB: return aPtLB;
540 		case RP_MB: return aPtMB;
541 		case RP_RB: return aPtRB;
542 	}
543 	return( aPtMM ); // default
544 }
545 
546 
547 void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
548 {
549 	HideFocus();
550 
551 	if( pRect )
552 		ShowFocus( *pRect );
553 	else
554 		ShowFocus( CalculateFocusRectangle() );
555 }
556 
557 Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
558 {
559 	Point aPtLast = aPtNew;
560 	aPtNew = GetPointFromRP( eNewRP );
561 
562 	if( (m_nState & CS_NOHORZ) != 0 )
563 		aPtNew.X() = aPtMM.X();
564 
565 	if( (m_nState & CS_NOVERT) != 0 )
566 		aPtNew.Y() = aPtMM.Y();
567 
568 	eNewRP = GetRPFromPoint( aPtNew );
569 
570 	eDefRP = eNewRP;
571 	eRP = eNewRP;
572 
573 	return aPtLast;
574 }
575 
576 void SvxRectCtl::GetFocus()
577 {
578 	SetFocusRect();
579 	// IAccessibility2 implementation 2009. ------
580 	//Solution: Send the accessible focused event
581 	Control::GetFocus();
582 	// Send accessibility event.
583 	if(pAccContext)
584 	{
585 		pAccContext->FireChildFocus(GetActualRP());
586 	}
587 	// ------ IAccessibility2 implementation 2009.
588 }
589 
590 
591 void SvxRectCtl::LoseFocus()
592 {
593 	HideFocus();
594 }
595 
596 
597 Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
598 {
599 	Point	aPt = PixelToLogic( rPt );
600 	long	x;
601 	long	y;
602 
603 	if( ( m_nState & CS_NOHORZ ) == 0 )
604 	{
605 		if( aPt.X() < aSize.Width() / 3 )
606 			x = aPtLT.X();
607 		else if( aPt.X() < aSize.Width() * 2 / 3 )
608 			x = aPtMM.X();
609 		else
610 			x = aPtRB.X();
611 	}
612 	else
613 		x = aPtMM.X();
614 
615 	if( ( m_nState & CS_NOVERT ) == 0 )
616 	{
617 		if( aPt.Y() < aSize.Height() / 3 )
618 			y = aPtLT.Y();
619 		else if( aPt.Y() < aSize.Height() * 2 / 3 )
620 			y = aPtMM.Y();
621 		else
622 			y = aPtRB.Y();
623 	}
624 	else
625 			y = aPtMM.Y();
626 
627 	return Point( x, y );
628 }
629 
630 
631 /*************************************************************************
632 |*
633 |*	Konvertiert Point in RECT_POINT
634 |*
635 \************************************************************************/
636 
637 RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
638 {
639 	if	   ( aPt == aPtLT) return RP_LT;
640 	else if( aPt == aPtMT) return RP_MT;
641 	else if( aPt == aPtRT) return RP_RT;
642 	else if( aPt == aPtLM) return RP_LM;
643 	else if( aPt == aPtRM) return RP_RM;
644 	else if( aPt == aPtLB) return RP_LB;
645 	else if( aPt == aPtMB) return RP_MB;
646 	else if( aPt == aPtRB) return RP_RB;
647 
648 	else
649 		return RP_MM; // default
650 }
651 
652 /*************************************************************************
653 |*
654 |*	Bewirkt den Ursprungszustand des Controls
655 |*
656 \************************************************************************/
657 
658 void SvxRectCtl::Reset()
659 {
660 	aPtNew = GetPointFromRP( eDefRP );
661 	eRP = eDefRP;
662 	Invalidate();
663 }
664 
665 /*************************************************************************
666 |*
667 |*	Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
668 |*
669 \************************************************************************/
670 
671 RECT_POINT SvxRectCtl::GetActualRP() const
672 {
673 	return( eRP );
674 }
675 
676 /*************************************************************************
677 |*
678 |*	Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
679 |*
680 \************************************************************************/
681 // IAccessibility2 implementation 2009. ------
682 void SvxRectCtl::SetActualRP( RECT_POINT eNewRP /* MT: , sal_Bool bFireFocus */ )
683 {
684 	// MT: bFireFox as API parameter is ugly...
685 	Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
686 
687 	Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
688 	Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
689 
690 	// notify accessibility object about change
691 	if( pAccContext )
692 		pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
693 }
694 // ------ IAccessibility2 implementation 2009.
695 void SvxRectCtl::SetState( CTL_STATE nState )
696 {
697 	m_nState = nState;
698 
699 	Point aPtLast( GetPointFromRP( eRP ) );
700     Point _aPtNew( aPtLast );
701 
702 	if( (m_nState & CS_NOHORZ) != 0 )
703         _aPtNew.X() = aPtMM.X();
704 
705 	if( (m_nState & CS_NOVERT) != 0 )
706         _aPtNew.Y() = aPtMM.Y();
707 
708     eRP = GetRPFromPoint( _aPtNew );
709 	Invalidate();
710 
711 	if( WINDOW_TABPAGE == GetParent()->GetType() )
712 		( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
713 }
714 
715 sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const
716 {
717 	return ( eCS == CS_ANGLE )? 8 : 9;
718 }
719 
720 Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
721 {
722 	Size		aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
723 	return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
724 }
725 
726 Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
727 {
728 	Rectangle	aRet;
729 	RECT_POINT	eOldRectPoint = GetActualRP();
730 
731 	if( eOldRectPoint == eRectPoint )
732 		aRet = CalculateFocusRectangle();
733 	else
734 	{
735 		SvxRectCtl*	pThis = const_cast< SvxRectCtl* >( this );
736 
737 		pThis->SetActualRPWithoutInvalidate( eRectPoint );		// no invalidation because it's only temporary!
738 		aRet = CalculateFocusRectangle();
739 
740 		pThis->SetActualRPWithoutInvalidate( eOldRectPoint );	// no invalidation because nothing has changed!
741 	}
742 
743 	return aRet;
744 }
745 
746 Reference< XAccessible > SvxRectCtl::CreateAccessible()
747 {
748 	Window*						pParent = GetAccessibleParentWindow();
749 
750 	DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
751 
752 	Reference< XAccessible >	xAccParent  = pParent->GetAccessible();
753 	if( xAccParent.is() )
754 	{
755 		pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
756 		pAccContext->acquire();
757 
758         SetActualRP( GetActualRP() );
759 
760 		return pAccContext;
761 	}
762 	else
763 		return Reference< XAccessible >();
764 }
765 
766 RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
767 {
768 	return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
769 }
770 
771 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
772 void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
773 {
774 	mbCompleteDisable = bNew;
775 	Invalidate();
776 }
777 
778 /*************************************************************************
779 |*
780 |* Konstruktor ohne Size-Parameter
781 |*
782 \************************************************************************/
783 
784 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
785 
786 	SvxRectCtl( pParent, rResId ),
787 
788 	aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
789 {
790 	aFontSize = Size( 250, 400 );
791 	Initialize();
792 }
793 
794 /*************************************************************************
795 |*
796 |* Konstruktor mit Size-Parameter
797 |*
798 \************************************************************************/
799 
800 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
801 
802 	SvxRectCtl( pParent, rResId ),
803 
804 	aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
805 {
806     aFontSize = _aSize;
807 	Initialize();
808 }
809 
810 /*************************************************************************
811 |*
812 |* Initialisierung
813 |*
814 \************************************************************************/
815 
816 void SvxAngleCtl::Initialize()
817 {
818 	bPositive = sal_True;
819 
820 	// aFont.SetName( "Helvetica" );
821 	aFont.SetSize( aFontSize );
822 	aFont.SetWeight( WEIGHT_NORMAL );
823 	aFont.SetTransparent( sal_False );
824 
825 	SetFont( aFont );
826 }
827 
828 /*************************************************************************
829 |*
830 |*	Zeichnet das (Mini-)Koordinatensystem
831 |*
832 \************************************************************************/
833 
834 void SvxAngleCtl::Paint( const Rectangle& )
835 {
836 	SetLineColor( Color( COL_BLACK ) ); 	// PEN_DOT ???
837 	DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
838 	DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
839 
840 	SetLineColor( Color( COL_BLACK ) );
841 	DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
842 	DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
843 
844 	Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
845 
846 	DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
847 		                     RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
848 	DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
849 		                     RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
850 
851 	if ( bPositive )
852 		DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
853 		                         RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
854 	else
855 		DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
856 		                         RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
857 
858 	aDiff.X() = aFontSize.Width();
859 	DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
860 		                     RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
861 	DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
862 		                     RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
863 	aDiff.X() = aDiff .X() * 3 / 2;
864 
865 	if ( bPositive )
866 		DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
867 		                         RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
868 	else
869 		DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
870 		                         RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
871 
872 	DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
873 		                                     RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
874 	aDiff.X() = aFontSize.Width() * 2;
875 
876 	if ( bPositive )
877 		DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
878 		                         RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
879 	else
880 		DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
881 		                         RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
882 }
883 
884 /*************************************************************************
885 |*
886 |*	Control zum Editieren von Bitmaps
887 |*
888 \************************************************************************/
889 // IAccessibility2 implementation 2009. ------
890 
891 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
892 {
893     if(!m_xAccess.is())
894 	{
895 		m_xAccess = m_pAccess =  new SvxPixelCtlAccessible(*this);
896 	}
897     return m_xAccess;
898 }
899 
900 //Logic Pixel
901 long SvxPixelCtl::PointToIndex(const Point &aPt) const
902 {
903 	sal_uInt16	nX, nY;
904 
905 	nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
906 	nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
907 
908 	return nX + nY * nLines ;
909 }
910 Point SvxPixelCtl::IndexToPoint(long nIndex) const
911 {
912 	DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
913 
914 	sal_uInt16 nXIndex = nIndex % nLines ;
915 	sal_uInt16 nYIndex = sal_uInt16(nIndex / nLines) ;
916 
917 	Point aPtTl;
918 	aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1;
919 	aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1;
920 
921 	return aPtTl;
922 }
923 long SvxPixelCtl::GetFoucsPosIndex() const
924 {
925 	return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
926 }
927 long SvxPixelCtl::ShowPosition( const Point &pt)
928 {
929 	Point aPt = PixelToLogic( pt );
930 
931 	sal_uInt16	nX, nY;
932 	nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
933 	nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
934 
935 	ChangePixel( nX + nY * nLines );
936 
937 	//Solution:Set new focus position and repaint
938 	//Invalidate( Rectangle( aPtTl, aPtBr ) );
939 	aFocusPosition.setX(nX);
940 	aFocusPosition.setY(nY);
941 	Invalidate(Rectangle(Point(0,0),aRectSize));
942 
943 	if( WINDOW_TABPAGE == GetParent()->GetType() )
944 		( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
945 
946 	return GetFoucsPosIndex();
947 
948 }
949 // ------ IAccessibility2 implementation 2009.
950 SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
951 						Control		( pParent, rResId ),
952 						nLines		( nNumber ),
953 						bPaintable	( sal_True )
954 						// IAccessibility2 implementation 2009. ------
955 						//Solution:Initialize it's value to Point(0,0)
956 						,aFocusPosition(0,0)
957 {
958 	// SetMapMode( MAP_100TH_MM );
959 	aRectSize = GetOutputSize();
960 
961 	SetPixelColor( Color( COL_BLACK ) );
962 	SetBackgroundColor( Color( COL_WHITE ) );
963 	SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
964 
965 	nSquares = nLines * nLines;
966 	pPixel = new sal_uInt16[ nSquares ];
967 	rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
968 	// IAccessibility2 implementation 2009. ------
969 	m_pAccess=NULL;
970 }
971 
972 /*************************************************************************
973 |*
974 |*	Destruktor dealociert dyn. Array
975 |*
976 \************************************************************************/
977 
978 SvxPixelCtl::~SvxPixelCtl( )
979 {
980 	delete []pPixel;
981 }
982 
983 /*************************************************************************
984 |*
985 |*	Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
986 |*
987 \************************************************************************/
988 
989 void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
990 {
991 	if( *( pPixel + nPixel) == 0 )
992 		*( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
993 	else
994 		*( pPixel + nPixel) = 0;
995 }
996 
997 /*************************************************************************
998 |*
999 |*	Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
1000 |*
1001 \************************************************************************/
1002 
1003 void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
1004 {
1005 	// IAccessibility2 implementation 2009. ------
1006 	//Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
1007 	//Point aPtTl, aPtBr;
1008 	//sal_uInt16	nX, nY;
1009 
1010 	//nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
1011 	//nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
1012 
1013 	//ChangePixel( nX + nY * nLines );
1014 
1015 	//aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
1016 	//aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
1017 	//aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
1018 	//aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
1019 
1020 	//Invalidate( Rectangle( aPtTl, aPtBr ) );
1021 
1022 	//if( WINDOW_TABPAGE == GetParent()->GetType() )
1023 	//	( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
1024 	//Solution:Grab focus when click in window
1025 	if( !HasFocus() )
1026 	{
1027 		GrabFocus();
1028 	}
1029 	long nIndex = ShowPosition(rMEvt.GetPosPixel());
1030 
1031 	if(m_pAccess)
1032 	{
1033 		m_pAccess->NotifyChild(nIndex,sal_True,sal_True);
1034 	}
1035 	// ------ IAccessibility2 implementation 2009.
1036 }
1037 
1038 /*************************************************************************
1039 |*
1040 |*	Zeichnet das Control (Rechteck mit 9 Kreisen)
1041 |*
1042 \************************************************************************/
1043 
1044 void SvxPixelCtl::Paint( const Rectangle& )
1045 {
1046 	sal_uInt16	i, j, nTmp;
1047 	Point	aPtTl, aPtBr;
1048 
1049 	if( bPaintable )
1050 	{
1051 		// Linien Zeichnen
1052 		Control::SetLineColor( aLineColor );
1053 		for( i = 1; i < nLines; i++)
1054 		{
1055 			// horizontal
1056 			nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
1057 			DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
1058 			// vertikal
1059 			nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
1060 			DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
1061 		}
1062 
1063 		// Rechtecke (Quadrate) zeichnen
1064 		Control::SetLineColor();
1065 		sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
1066 
1067 		for( i = 0; i < nLines; i++)
1068 		{
1069 			aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
1070 			aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
1071 
1072 			for( j = 0; j < nLines; j++)
1073 			{
1074 				aPtTl.X() = aRectSize.Width() * j / nLines + 1;
1075 				aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
1076 
1077 				if ( *( pPixel + i * nLines + j ) != nLastPixel )
1078 				{
1079 					nLastPixel = *( pPixel + i * nLines + j );
1080 					// Farbe wechseln: 0 -> Hintergrundfarbe
1081 					SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
1082 				}
1083 				DrawRect( Rectangle( aPtTl, aPtBr ) );
1084 			}
1085 		}
1086 		// IAccessibility2 implementation 2009. ------
1087 		//Solution:Draw visual focus when has focus
1088 		if( HasFocus() )
1089 		{
1090 			ShowFocus(implCalFocusRect(aFocusPosition));
1091 		}
1092 		// ------ IAccessibility2 implementation 2009.
1093 	} // bPaintable
1094 	else
1095 	{
1096 		SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
1097 		Control::SetLineColor( Color( COL_LIGHTRED ) );
1098 		DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
1099 		DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
1100 	}
1101 }
1102 // IAccessibility2 implementation 2009. ------
1103 //Solution:Caculate visual focus rectangle via focus position
1104 Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition )
1105 {
1106 	long nLeft,nTop,nRight,nBottom;
1107 	long i,j;
1108 	i = aPosition.Y();
1109 	j = aPosition.X();
1110 	nLeft = aRectSize.Width() * j / nLines + 1;
1111 	nRight = aRectSize.Width() * (j + 1) / nLines - 1;
1112 	nTop = aRectSize.Height() * i / nLines + 1;
1113 	nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
1114 	return Rectangle(nLeft,nTop,nRight,nBottom);
1115 }
1116 
1117 //Solution:Keyboard fucntion
1118 void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
1119 {
1120 	KeyCode aKeyCode = rKEvt.GetKeyCode();
1121 	sal_uInt16 nCode = aKeyCode.GetCode();
1122 	sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
1123 
1124 	if( !bIsMod )
1125 	{
1126 		Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
1127 		                     aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
1128 		                    );
1129 		Size  mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
1130 		Rectangle mRepaintRect( pRepaintPoint, mRepaintSize );
1131 		sal_Bool bFocusPosChanged=sal_False;
1132 		switch(nCode)
1133 		{
1134 			case KEY_LEFT:
1135 				if((aFocusPosition.getX() >= 1))
1136 				{
1137 					aFocusPosition.setX( aFocusPosition.getX() - 1 );
1138 					Invalidate(mRepaintRect);
1139 					bFocusPosChanged=sal_True;
1140 				}
1141 				break;
1142 			case KEY_RIGHT:
1143 				if( aFocusPosition.getX() < (nLines - 1) )
1144 				{
1145 					aFocusPosition.setX( aFocusPosition.getX() + 1 );
1146 					Invalidate(mRepaintRect);
1147 					bFocusPosChanged=sal_True;
1148 				}
1149 				break;
1150 			case KEY_UP:
1151 				if((aFocusPosition.getY() >= 1))
1152 				{
1153 					aFocusPosition.setY( aFocusPosition.getY() - 1 );
1154 					Invalidate(mRepaintRect);
1155 					bFocusPosChanged=sal_True;
1156 				}
1157 				break;
1158 			case KEY_DOWN:
1159 				if( aFocusPosition.getY() < ( nLines - 1 ) )
1160 				{
1161 					aFocusPosition.setY( aFocusPosition.getY() + 1 );
1162 					Invalidate(mRepaintRect);
1163 					bFocusPosChanged=sal_True;
1164 				}
1165 				break;
1166 			case KEY_SPACE:
1167 				ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
1168 				Invalidate( implCalFocusRect(aFocusPosition) );
1169 				break;
1170 			default:
1171 				Control::KeyInput( rKEvt );
1172 				return;
1173 		}
1174 		if(m_xAccess.is())
1175 		{
1176 			long nIndex = GetFoucsPosIndex();
1177 			switch(nCode)
1178 			{
1179 			case KEY_LEFT:
1180 			case KEY_RIGHT:
1181 			case KEY_UP:
1182 			case KEY_DOWN:
1183 				if (bFocusPosChanged)
1184 				{
1185 					m_pAccess->NotifyChild(nIndex,sal_False,sal_False);
1186 				}
1187 				break;
1188 			case KEY_SPACE:
1189 				m_pAccess->NotifyChild(nIndex,sal_False,sal_True);
1190 				break;
1191 			default:
1192 				break;
1193 			}
1194 		}
1195 	}
1196 	else
1197 	{
1198 		Control::KeyInput( rKEvt );
1199 	}
1200 }
1201 
1202 //Draw focus when get focus
1203 void SvxPixelCtl::GetFocus()
1204 {
1205 	Invalidate(implCalFocusRect(aFocusPosition));
1206 
1207 	if(m_pAccess)
1208 	{
1209 		m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False);
1210 	}
1211 
1212 	Control::GetFocus();
1213 }
1214 
1215 //Hide focus when lose focus
1216 void SvxPixelCtl::LoseFocus()
1217 {
1218 	HideFocus();
1219 	if (m_pAccess)
1220 	{
1221 		m_pAccess->LoseFocus();
1222 	}
1223 	Control::LoseFocus();
1224 }
1225 // ------ IAccessibility2 implementation 2009.
1226 
1227 /*************************************************************************
1228 |*
1229 |*
1230 |*
1231 \************************************************************************/
1232 
1233 void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
1234 {
1235     BitmapColor aBack;
1236     BitmapColor aFront;
1237 
1238     if(isHistorical8x8(rBitmapEx, aBack, aFront))
1239     {
1240         Bitmap aBitmap(rBitmapEx.GetBitmap());
1241         BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
1242 
1243         aBackgroundColor = aBack;
1244         aPixelColor = aFront;
1245 
1246         for(sal_uInt16 i(0); i < nSquares; i++)
1247         {
1248             const BitmapColor aColor(pRead->GetColor(i/8, i%8));
1249 
1250             if(aColor == aBack)
1251             {
1252                 *( pPixel + i ) = 0;
1253             }
1254             else
1255             {
1256                 *( pPixel + i ) = 1;
1257             }
1258         }
1259 
1260         aBitmap.ReleaseAccess(pRead);
1261     }
1262 }
1263 
1264 /*************************************************************************
1265 |*
1266 |*	Gibt ein bestimmtes Pixel zurueck
1267 |*
1268 \************************************************************************/
1269 
1270 sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel )
1271 {
1272 	return( *( pPixel + nPixel ) );
1273 }
1274 
1275 /*************************************************************************
1276 |*
1277 |*	Bewirkt den Ursprungszustand des Controls
1278 |*
1279 \************************************************************************/
1280 
1281 void SvxPixelCtl::Reset()
1282 {
1283 	// clear pixel area
1284 	rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
1285 	Invalidate();
1286 }
1287 
1288 /*************************************************************************
1289 |*
1290 |*	Ctor: BitmapCtl fuer SvxPixelCtl
1291 |*
1292 \************************************************************************/
1293 
1294 SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
1295 {
1296 	aSize = rSize;
1297 	// aVD.SetOutputSizePixel( aSize );
1298 }
1299 
1300 /*************************************************************************
1301 |*
1302 |*	Dtor
1303 |*
1304 \************************************************************************/
1305 
1306 SvxBitmapCtl::~SvxBitmapCtl()
1307 {
1308 }
1309 
1310 /*************************************************************************
1311 |*
1312 |*	BitmapCtl:	Gibt die Bitmap zurueck
1313 |*
1314 \************************************************************************/
1315 
1316 BitmapEx SvxBitmapCtl::GetBitmapEx()
1317 {
1318     const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
1319 
1320 	return BitmapEx(aRetval);
1321 }
1322 
1323 /*************************************************************************
1324 |*
1325 |*	Fuellt die Listbox mit Farben und Strings
1326 |*
1327 \************************************************************************/
1328 
1329 void ColorLB::Fill( const XColorTable* pColorTab )
1330 {
1331 	long nCount = pColorTab->Count();
1332 	XColorEntry* pEntry;
1333 	SetUpdateMode( sal_False );
1334 
1335 	for( long i = 0; i < nCount; i++ )
1336 	{
1337         pEntry = pColorTab->GetColor( i );
1338 		InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1339 	}
1340 	SetUpdateMode( sal_True );
1341 }
1342 
1343 /************************************************************************/
1344 
1345 void ColorLB::Append( XColorEntry* pEntry, Bitmap* )
1346 {
1347 	InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1348 }
1349 
1350 /************************************************************************/
1351 
1352 void ColorLB::Modify( XColorEntry* pEntry, sal_uInt16 nPos, Bitmap*  )
1353 {
1354 	RemoveEntry( nPos );
1355 	InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos );
1356 }
1357 
1358 /*************************************************************************
1359 |*
1360 |*	Fuellt die Listbox mit Farben und Strings
1361 |*
1362 \************************************************************************/
1363 
1364 void FillAttrLB::Fill( const XColorTable* pColorTab )
1365 {
1366 	long nCount = pColorTab->Count();
1367 	XColorEntry* pEntry;
1368 	SetUpdateMode( sal_False );
1369 
1370 	for( long i = 0; i < nCount; i++ )
1371 	{
1372         pEntry = pColorTab->GetColor( i );
1373 		InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1374 	}
1375 	SetUpdateMode( sal_True );
1376 }
1377 
1378 /*************************************************************************
1379 |*
1380 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1381 |*
1382 \************************************************************************/
1383 
1384 HatchingLB::HatchingLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ )
1385 : ListBox( pParent, Id ),
1386   mpList ( NULL ),
1387   mbUserDraw( bUserDraw )
1388 {
1389 	EnableUserDraw( mbUserDraw );
1390 }
1391 
1392 HatchingLB::HatchingLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ )
1393 : ListBox( pParent, aWB ),
1394   mpList ( NULL ),
1395   mbUserDraw( bUserDraw )
1396 {
1397 	EnableUserDraw( mbUserDraw );
1398 }
1399 
1400 void HatchingLB::Fill( const XHatchList* pList )
1401 {
1402 	mpList = (XHatchList*)pList;
1403 	XHatchEntry* pEntry;
1404 	long nCount = pList->Count();
1405 
1406 	SetUpdateMode( sal_False );
1407 
1408 	if( mbUserDraw )
1409 	{
1410 		for( long i = 0; i < nCount; i++ )
1411             InsertEntry( pList->GetHatch( i )->GetName() );
1412 	}
1413 	else
1414 	{
1415 		for( long i = 0; i < nCount; i++ )
1416 		{
1417             pEntry = pList->GetHatch( i );
1418 			Bitmap* pBitmap = pList->GetBitmap( i );
1419 			if( pBitmap )
1420 				InsertEntry( pEntry->GetName(), *pBitmap );
1421 			else
1422 				InsertEntry( pEntry->GetName() );
1423 		}
1424 	}
1425 
1426 	SetUpdateMode( sal_True );
1427 }
1428 
1429 void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt )
1430 {
1431 	if( mpList != NULL )
1432 	{
1433 		// Draw gradient with borderrectangle
1434 		const Rectangle& rDrawRect = rUDEvt.GetRect();
1435 		Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1436 
1437         sal_Int32 nId = rUDEvt.GetItemId();
1438 		if( nId >= 0 && nId <= mpList->Count() )
1439 		{
1440 			OutputDevice* pDevice = rUDEvt.GetDevice();
1441 
1442 			sal_uIntPtr nOldDrawMode = pDevice->GetDrawMode();
1443 		    pDevice->SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
1444 
1445             XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch();
1446 			MapMode aMode( MAP_100TH_MM );
1447 			Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(),
1448 						  rXHatch.GetColor(),
1449 						  rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(),
1450 						  (sal_uInt16)rXHatch.GetAngle() );
1451 			const Polygon aPolygon( aRect );
1452 			const PolyPolygon aPolypoly( aPolygon );
1453 			pDevice->DrawHatch( aPolypoly, aHatch );
1454 
1455 			pDevice->SetLineColor( COL_BLACK );
1456 			pDevice->SetFillColor();
1457 			pDevice->DrawRect( aRect );
1458 
1459 			pDevice->SetDrawMode( nOldDrawMode );
1460 
1461 			// Draw name
1462             pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() );
1463 		}
1464 	}
1465 }
1466 
1467 /************************************************************************/
1468 
1469 void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp )
1470 {
1471 	if( pBmp )
1472 		InsertEntry( pEntry->GetName(), *pBmp );
1473 	else
1474 		InsertEntry( pEntry->GetName() );
1475 }
1476 
1477 /************************************************************************/
1478 
1479 void HatchingLB::Modify( XHatchEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1480 {
1481 	RemoveEntry( nPos );
1482 
1483 	if( pBmp )
1484 		InsertEntry( pEntry->GetName(), *pBmp, nPos );
1485 	else
1486 		InsertEntry( pEntry->GetName(), nPos );
1487 }
1488 
1489 /************************************************************************/
1490 
1491 void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr,
1492 									const XHatch& rHatch, sal_uInt16 nDist )
1493 {
1494 	long nCount = pList->Count();
1495 	XHatchEntry* pEntry;
1496 	sal_Bool bFound = sal_False;
1497 	String aStr;
1498 
1499 	long i;
1500 	for( i = 0; i < nCount && !bFound; i++ )
1501 	{
1502         pEntry = pList->GetHatch( i );
1503 
1504 		aStr = pEntry->GetName();
1505 
1506 		if( rStr == aStr && rHatch == pEntry->GetHatch() )
1507 			bFound = sal_True;
1508 	}
1509 	if( bFound )
1510 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1511 }
1512 
1513 /*************************************************************************
1514 |*
1515 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1516 |*
1517 \************************************************************************/
1518 
1519 void FillAttrLB::Fill( const XHatchList* pList )
1520 {
1521 	long nCount = pList->Count();
1522 	XHatchEntry* pEntry;
1523 	ListBox::SetUpdateMode( sal_False );
1524 
1525 	for( long i = 0; i < nCount; i++ )
1526 	{
1527         pEntry = pList->GetHatch( i );
1528 		Bitmap* pBitmap = pList->GetBitmap( i );
1529 		if( pBitmap )
1530 			ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1531 		else
1532 			InsertEntry( pEntry->GetName() );
1533 	}
1534 	ListBox::SetUpdateMode( sal_True );
1535 }
1536 
1537 /*************************************************************************
1538 |*
1539 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1540 |*
1541 \************************************************************************/
1542 
1543 GradientLB::GradientLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ )
1544 : ListBox( pParent, Id ),
1545   mpList(NULL),
1546   mbUserDraw( bUserDraw )
1547 {
1548 	EnableUserDraw( mbUserDraw);
1549 }
1550 
1551 GradientLB::GradientLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ )
1552 : ListBox( pParent, aWB ),
1553   mpList(NULL),
1554   mbUserDraw( bUserDraw )
1555 {
1556 	EnableUserDraw( mbUserDraw );
1557 }
1558 
1559 void GradientLB::Fill( const XGradientList* pList )
1560 {
1561 	mpList = (XGradientList*)pList;
1562 	XGradientEntry* pEntry;
1563 	long nCount = pList->Count();
1564 
1565 	SetUpdateMode( sal_False );
1566 
1567 	if( mbUserDraw )
1568 	{
1569 		for( long i = 0; i < nCount; i++ )
1570             InsertEntry( pList->GetGradient( i )->GetName() );
1571 	}
1572 	else
1573 	{
1574 		for( long i = 0; i < nCount; i++ )
1575 		{
1576             pEntry = pList->GetGradient( i );
1577 			Bitmap* pBitmap = pList->GetBitmap( i );
1578 			if( pBitmap )
1579 				InsertEntry( pEntry->GetName(), *pBitmap );
1580 			else
1581 				InsertEntry( pEntry->GetName() );
1582 		}
1583 	}
1584 
1585 	SetUpdateMode( sal_True );
1586 }
1587 
1588 void GradientLB::UserDraw( const UserDrawEvent& rUDEvt )
1589 {
1590 	if( mpList != NULL )
1591 	{
1592 		// Draw gradient with borderrectangle
1593 		const Rectangle& rDrawRect = rUDEvt.GetRect();
1594 		Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1595 
1596         sal_Int32 nId = rUDEvt.GetItemId();
1597 		if( nId >= 0 && nId <= mpList->Count() )
1598 		{
1599 			OutputDevice* pDevice = rUDEvt.GetDevice();
1600 
1601             XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient();
1602 			Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() );
1603 			aGradient.SetAngle( (sal_uInt16)rXGrad.GetAngle() );
1604 			aGradient.SetBorder( rXGrad.GetBorder() );
1605 			aGradient.SetOfsX( rXGrad.GetXOffset() );
1606 			aGradient.SetOfsY( rXGrad.GetYOffset() );
1607 			aGradient.SetStartIntensity( rXGrad.GetStartIntens() );
1608 			aGradient.SetEndIntensity( rXGrad.GetEndIntens() );
1609 			aGradient.SetSteps( 255 );
1610 
1611             // #i76307# always paint the preview in LTR, because this is what the document does
1612             Window* pWin = dynamic_cast<Window*>(pDevice);
1613             if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL())
1614             {
1615                 long nWidth = pDevice->GetOutputSize().Width();
1616 
1617                 pWin->EnableRTL( sal_False );
1618 
1619                 Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ),
1620                                        aRect.GetSize() );
1621 
1622                 pDevice->DrawGradient( aMirrorRect, aGradient );
1623 
1624                 pWin->EnableRTL( sal_True );
1625             }
1626             else
1627                 pDevice->DrawGradient( aRect, aGradient );
1628 
1629 			pDevice->SetLineColor( COL_BLACK );
1630 			pDevice->SetFillColor();
1631 			pDevice->DrawRect( aRect );
1632 
1633 			// Draw name
1634             pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() );
1635 		}
1636 	}
1637 }
1638 
1639 /************************************************************************/
1640 
1641 void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp )
1642 {
1643 	if( pBmp )
1644 		InsertEntry( pEntry->GetName(), *pBmp );
1645 	else
1646 		InsertEntry( pEntry->GetName() );
1647 }
1648 
1649 /************************************************************************/
1650 
1651 void GradientLB::Modify( XGradientEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1652 {
1653 	RemoveEntry( nPos );
1654 
1655 	if( pBmp )
1656 		InsertEntry( pEntry->GetName(), *pBmp, nPos );
1657 	else
1658 		InsertEntry( pEntry->GetName(), nPos );
1659 }
1660 
1661 /************************************************************************/
1662 
1663 void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr,
1664 								const XGradient& rGradient, sal_uInt16 nDist )
1665 {
1666 	long nCount = pList->Count();
1667 	XGradientEntry* pEntry;
1668 	sal_Bool bFound = sal_False;
1669 	String aStr;
1670 
1671 	long i;
1672 	for( i = 0; i < nCount && !bFound; i++ )
1673 	{
1674         pEntry = pList->GetGradient( i );
1675 
1676 		aStr = pEntry->GetName();
1677 
1678 		if( rStr == aStr && rGradient == pEntry->GetGradient() )
1679 			bFound = sal_True;
1680 	}
1681 	if( bFound )
1682 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1683 }
1684 
1685 /*************************************************************************
1686 |*
1687 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1688 |*
1689 \************************************************************************/
1690 
1691 void FillAttrLB::Fill( const XGradientList* pList )
1692 {
1693 	long nCount = pList->Count();
1694 	XGradientEntry* pEntry;
1695 	ListBox::SetUpdateMode( sal_False );
1696 
1697 	for( long i = 0; i < nCount; i++ )
1698 	{
1699         pEntry = pList->GetGradient( i );
1700 		Bitmap* pBitmap = pList->GetBitmap( i );
1701 		if( pBitmap )
1702 			ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1703 		else
1704 			InsertEntry( pEntry->GetName() );
1705 	}
1706 	ListBox::SetUpdateMode( sal_True );
1707 }
1708 
1709 /*************************************************************************
1710 |*
1711 |*	Konstruktor von BitmapLB
1712 |*
1713 \************************************************************************/
1714 
1715 BitmapLB::BitmapLB(Window* pParent, ResId Id, bool bUserDraw /*= false*/ )
1716 :   ListBox(pParent, Id),
1717     maVD(),
1718     maBitmapEx(),
1719     mpList(NULL),
1720     mbUserDraw(bUserDraw)
1721 {
1722 	maVD.SetOutputSizePixel(Size(32, 16));
1723 	EnableUserDraw(mbUserDraw);
1724 }
1725 
1726 /************************************************************************/
1727 
1728 void BitmapLB::SetVirtualDevice()
1729 {
1730 	if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8)
1731 	{
1732 		maVD.DrawBitmapEx(Point(0, 0), Size(32, 16), maBitmapEx);
1733 	}
1734 	else
1735 	{
1736 		maVD.DrawBitmapEx(Point(0,  0), maBitmapEx);
1737 		maVD.DrawBitmapEx(Point(8,  0), maBitmapEx);
1738 		maVD.DrawBitmapEx(Point(16, 0), maBitmapEx);
1739 		maVD.DrawBitmapEx(Point(24, 0), maBitmapEx);
1740 		maVD.DrawBitmapEx(Point(0,  8), maBitmapEx);
1741 		maVD.DrawBitmapEx(Point(8,  8), maBitmapEx);
1742 		maVD.DrawBitmapEx(Point(16, 8), maBitmapEx);
1743 		maVD.DrawBitmapEx(Point(24, 8), maBitmapEx);
1744 	}
1745 }
1746 
1747 /************************************************************************/
1748 
1749 void BitmapLB::Fill(const XBitmapList* pList)
1750 {
1751 	mpList = (XBitmapList*)pList;
1752 	XBitmapEntry* pEntry;
1753 	const long nCount(pList->Count());
1754 
1755 	SetUpdateMode(false);
1756 
1757 	if(mbUserDraw)
1758 	{
1759 		for(long i(0); i < nCount; i++)
1760         {
1761             InsertEntry(pList->GetBitmap(i)->GetName());
1762         }
1763 	}
1764 	else
1765 	{
1766 		for(long i(0); i < nCount; i++)
1767 		{
1768             pEntry = pList->GetBitmap(i);
1769 			maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1770 			SetVirtualDevice();
1771 			InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12)));
1772 		}
1773 	}
1774 
1775 	SetUpdateMode(true);
1776 }
1777 
1778 void BitmapLB::UserDraw(const UserDrawEvent& rUDEvt)
1779 {
1780 	if(mpList)
1781 	{
1782 		// Draw bitmap
1783 		const Rectangle& rDrawRect = rUDEvt.GetRect();
1784 		const Rectangle aRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nLeft + 33, rDrawRect.nBottom - 1);
1785         const sal_Int32 nId(rUDEvt.GetItemId());
1786 
1787         if(nId >= 0 && nId <= mpList->Count())
1788 		{
1789 			const Rectangle aClipRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nRight - 1, rDrawRect.nBottom - 1);
1790 			OutputDevice* pDevice = rUDEvt.GetDevice();
1791 			pDevice->SetClipRegion(Region(aClipRect));
1792             maBitmapEx = mpList->GetBitmap(nId)->GetGraphicObject().GetGraphic().GetBitmapEx();
1793 			long nPosBaseX = aRect.nLeft;
1794 			long nPosBaseY = aRect.nTop;
1795 
1796 			if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8)
1797 			{
1798 				pDevice->DrawBitmapEx(Point(nPosBaseX, nPosBaseY), Size(32, 16), maBitmapEx);
1799 			}
1800 			else
1801 			{
1802 				pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+0 ), maBitmapEx);
1803 				pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+0 ), maBitmapEx);
1804 				pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+0 ), maBitmapEx);
1805 				pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+0 ), maBitmapEx);
1806 				pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+8 ), maBitmapEx);
1807 				pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+8 ), maBitmapEx);
1808 				pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+8 ), maBitmapEx);
1809 				pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+8 ), maBitmapEx);
1810 			}
1811 
1812 			pDevice->SetClipRegion();
1813 
1814 			// Draw name
1815             pDevice->DrawText(Point(aRect.nRight + 7, aRect.nTop - 1), mpList->GetBitmap(nId)->GetName());
1816 		}
1817 	}
1818 }
1819 
1820 /************************************************************************/
1821 
1822 void BitmapLB::Append(XBitmapEntry* pEntry, BitmapEx* pBmpEx)
1823 {
1824 	if(pBmpEx)
1825 	{
1826 		maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1827 		SetVirtualDevice();
1828 		InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12)));
1829 	}
1830 	else
1831     {
1832 		InsertEntry(pEntry->GetName());
1833     }
1834 }
1835 
1836 /************************************************************************/
1837 
1838 void BitmapLB::Modify(XBitmapEntry* pEntry, sal_uInt16 nPos, BitmapEx* pBmpEx)
1839 {
1840 	RemoveEntry(nPos);
1841 
1842 	if(pBmpEx)
1843 	{
1844 		maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1845 		SetVirtualDevice();
1846 		InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12)), nPos);
1847 	}
1848 	else
1849     {
1850 		InsertEntry(pEntry->GetName());
1851     }
1852 }
1853 
1854 /************************************************************************/
1855 
1856 void BitmapLB::SelectEntryByList(const XBitmapList* pList, const String& rStr)
1857 {
1858 	const long nCount(pList->Count());
1859 	XBitmapEntry* pEntry;
1860 	bool bFound(false);
1861     long i(0);
1862 
1863 	for(i = 0; i < nCount && !bFound; i++)
1864 	{
1865         pEntry = pList->GetBitmap(i);
1866 		const String aStr(pEntry->GetName());
1867 
1868 		if(rStr == aStr)
1869 		{
1870 			bFound = true;
1871 		}
1872 	}
1873 
1874     if(bFound)
1875     {
1876 		SelectEntryPos((sal_uInt16)(i - 1));
1877     }
1878 }
1879 
1880 /*************************************************************************
1881 |*
1882 |*	Konstruktor von FillAttrLB
1883 |*
1884 \************************************************************************/
1885 
1886 FillAttrLB::FillAttrLB( Window* pParent, ResId Id )
1887 :   ColorListBox(pParent, Id),
1888     maVD(),
1889     maBitmapEx()
1890 {
1891 	maVD.SetOutputSizePixel(Size(32, 16));
1892 }
1893 
1894 /************************************************************************/
1895 
1896 FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
1897 :   ColorListBox(pParent, aWB)
1898 {
1899 	maVD.SetOutputSizePixel(Size(32, 16));
1900 }
1901 
1902 /************************************************************************/
1903 
1904 void FillAttrLB::SetVirtualDevice()
1905 {
1906     maVD.Erase();
1907 
1908     if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8)
1909 	{
1910 		maVD.DrawBitmapEx(Point(0, 0), Size(32, 16), maBitmapEx);
1911 	}
1912 	else
1913 	{
1914 		maVD.DrawBitmapEx(Point(0,  0), maBitmapEx);
1915 		maVD.DrawBitmapEx(Point(8,  0), maBitmapEx);
1916 		maVD.DrawBitmapEx(Point(16, 0), maBitmapEx);
1917 		maVD.DrawBitmapEx(Point(24, 0), maBitmapEx);
1918 		maVD.DrawBitmapEx(Point(0,  8), maBitmapEx);
1919 		maVD.DrawBitmapEx(Point(8,  8), maBitmapEx);
1920 		maVD.DrawBitmapEx(Point(16, 8), maBitmapEx);
1921 		maVD.DrawBitmapEx(Point(24, 8), maBitmapEx);
1922 	}
1923 }
1924 
1925 /************************************************************************/
1926 
1927 void FillAttrLB::Fill(const XBitmapList* pList)
1928 {
1929 	const long nCount(pList->Count());
1930 	XBitmapEntry* pEntry;
1931 
1932     ListBox::SetUpdateMode(false);
1933 
1934 	for(long i(0); i < nCount; i++)
1935 	{
1936         pEntry = pList->GetBitmap( i );
1937 		maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1938 		SetVirtualDevice();
1939 		ListBox::InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12)));
1940 	}
1941 
1942     ListBox::SetUpdateMode(true);
1943 }
1944 
1945 /************************************************************************/
1946 
1947 void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr)
1948 {
1949 	const long nCount(pList->Count());
1950 	XBitmapEntry* pEntry;
1951 	bool bFound(false);
1952 	long i(0);
1953 
1954     for(i = 0; i < nCount && !bFound; i++)
1955 	{
1956         pEntry = pList->GetBitmap(i);
1957 		const String aStr(pEntry->GetName());
1958 
1959 		if(rStr == aStr)
1960 		{
1961 			bFound = true;
1962 		}
1963 	}
1964 
1965     if(bFound)
1966     {
1967 		SelectEntryPos((sal_uInt16)(i - 1));
1968     }
1969 }
1970 
1971 /*************************************************************************
1972 |*
1973 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1974 |*
1975 \************************************************************************/
1976 
1977 void FillTypeLB::Fill()
1978 {
1979 	SetUpdateMode( sal_False );
1980 	InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
1981 	InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
1982 	InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
1983 	InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
1984 	InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
1985 	SetUpdateMode( sal_True );
1986 }
1987 
1988 /*************************************************************************
1989 |*
1990 |*	Fuellt die Listbox (vorlaeufig) mit Strings
1991 |*
1992 \************************************************************************/
1993 
1994 void LineLB::Fill( const XDashList* pList )
1995 {
1996 	long nCount = pList->Count();
1997 	XDashEntry* pEntry;
1998 	SetUpdateMode( sal_False );
1999 
2000 	for( long i = 0; i < nCount; i++ )
2001 	{
2002         pEntry = pList->GetDash( i );
2003 		Bitmap* pBitmap = const_cast<XDashList*>(pList)->CreateBitmapForUI( i );
2004 		if( pBitmap )
2005 		{
2006 			InsertEntry( pEntry->GetName(), *pBitmap );
2007 			delete pBitmap;
2008 		}
2009 		else
2010 			InsertEntry( pEntry->GetName() );
2011 	}
2012 	SetUpdateMode( sal_True );
2013 }
2014 
2015 void LineLB::FillStyles()
2016 {
2017 	ResMgr& rMgr = DIALOG_MGR();
2018 
2019 	// Linienstile
2020 	Clear();
2021 	InsertEntry( String( ResId( RID_SVXSTR_INVISIBLE, rMgr ) ) );
2022 
2023 	const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
2024 	Bitmap aBitmap ( SVX_RES ( RID_SVXCTRL_LINECTRL ) );
2025 	Color aSourceColors[2];
2026 	Color aDestColors[2];
2027 
2028 	aSourceColors[0] = Color( COL_WHITE );
2029 	aSourceColors[1] = Color( COL_BLACK );
2030 
2031 	aDestColors[0] = rStyles.GetFieldColor();
2032 	aDestColors[1] = rStyles.GetFieldTextColor();
2033 
2034 	aBitmap.Replace ( aSourceColors, aDestColors, 2 );
2035 	Image aSolidLine ( aBitmap );
2036 	InsertEntry( String( ResId( RID_SVXSTR_SOLID, rMgr ) ), aSolidLine );
2037 }
2038 
2039 /************************************************************************/
2040 
2041 void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp )
2042 {
2043 	if( pBmp )
2044 		InsertEntry( pEntry->GetName(), *pBmp );
2045 	else
2046 		InsertEntry( pEntry->GetName() );
2047 }
2048 
2049 /************************************************************************/
2050 
2051 void LineLB::Modify( XDashEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
2052 {
2053 	RemoveEntry( nPos );
2054 
2055 	if( pBmp )
2056 		InsertEntry( pEntry->GetName(), *pBmp, nPos );
2057 	else
2058 		InsertEntry( pEntry->GetName(), nPos );
2059 }
2060 
2061 /************************************************************************/
2062 
2063 void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr,
2064 								const XDash& rDash, sal_uInt16 nDist )
2065 {
2066 	long nCount = pList->Count();
2067 	XDashEntry* pEntry;
2068 	sal_Bool bFound = sal_False;
2069 	String aStr;
2070 	XDash aDash;
2071 
2072 	long i;
2073 	for( i = 0; i < nCount && !bFound; i++ )
2074 	{
2075         pEntry = pList->GetDash( i );
2076 
2077 		aStr = pEntry->GetName();
2078 		aDash = pEntry->GetDash();
2079 
2080 		if( rStr == aStr && rDash == aDash )
2081 			bFound = sal_True;
2082 	}
2083 	if( bFound )
2084 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
2085 }
2086 
2087 /*************************************************************************
2088 |*
2089 |*	Fuellt die Listbox (vorlaeufig) mit Strings
2090 |*
2091 \************************************************************************/
2092 
2093 void LineEndLB::Fill( const XLineEndList* pList, sal_Bool bStart )
2094 {
2095 	long nCount = pList->Count();
2096 	XLineEndEntry* pEntry;
2097 	VirtualDevice aVD;
2098 	SetUpdateMode( sal_False );
2099 
2100 	for( long i = 0; i < nCount; i++ )
2101 	{
2102         pEntry = pList->GetLineEnd( i );
2103 		Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i );
2104 		if( pBitmap )
2105 		{
2106 			Size aBmpSize( pBitmap->GetSizePixel() );
2107 			aVD.SetOutputSizePixel( aBmpSize, sal_False );
2108 			aVD.DrawBitmap( Point(), *pBitmap );
2109 			InsertEntry( pEntry->GetName(),
2110 				aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
2111 					Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
2112 
2113 			delete pBitmap;
2114 		}
2115 		else
2116 			InsertEntry( pEntry->GetName() );
2117 	}
2118 	SetUpdateMode( sal_True );
2119 }
2120 
2121 /************************************************************************/
2122 
2123 void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp,
2124 						sal_Bool bStart )
2125 {
2126 	if( pBmp )
2127 	{
2128 		VirtualDevice aVD;
2129 		Size aBmpSize( pBmp->GetSizePixel() );
2130 
2131 		aVD.SetOutputSizePixel( aBmpSize, sal_False );
2132 		aVD.DrawBitmap( Point(), *pBmp );
2133 		InsertEntry( pEntry->GetName(),
2134 			aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
2135 				Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
2136 	}
2137 	else
2138 		InsertEntry( pEntry->GetName() );
2139 }
2140 
2141 /************************************************************************/
2142 
2143 void LineEndLB::Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp,
2144 						sal_Bool bStart )
2145 {
2146 	RemoveEntry( nPos );
2147 
2148 	if( pBmp )
2149 	{
2150 		VirtualDevice aVD;
2151 		Size aBmpSize( pBmp->GetSizePixel() );
2152 
2153 		aVD.SetOutputSizePixel( aBmpSize, sal_False );
2154 		aVD.DrawBitmap( Point(), *pBmp );
2155 		InsertEntry( pEntry->GetName(),
2156 			aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
2157 				Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
2158 	}
2159 	else
2160 		InsertEntry( pEntry->GetName(), nPos );
2161 }
2162 
2163 //////////////////////////////////////////////////////////////////////////////
2164 
2165 void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
2166 {
2167 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2168 
2169 	if(bForeground)
2170 	{
2171 		svtools::ColorConfig aColorConfig;
2172 		Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
2173 
2174 		if(IsControlForeground())
2175         {
2176 			aTextColor = GetControlForeground();
2177         }
2178 
2179 		getBufferDevice().SetTextColor(aTextColor);
2180 	}
2181 
2182 	if(bBackground)
2183 	{
2184 		if(IsControlBackground())
2185         {
2186 			getBufferDevice().SetBackground(GetControlBackground());
2187         }
2188 		else
2189         {
2190 			getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
2191         }
2192 	}
2193 
2194     // do not paint background self, it gets painted buffered
2195 	SetControlBackground();
2196     SetBackground();
2197 
2198     Invalidate();
2199 }
2200 
2201 SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
2202 :	Control( pParent, rResId ),
2203 	mpModel( new SdrModel() ),
2204     mpBufferDevice( new VirtualDevice(*this) )
2205 {
2206 	//	Draw the control's border as a flat thin black line.
2207     SetBorderStyle(WINDOW_BORDER_MONO);
2208     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
2209     SetMapMode(MAP_100TH_MM);
2210 
2211     // init model
2212 	mpModel->GetItemPool().FreezeIdRanges();
2213 }
2214 
2215 SvxPreviewBase::~SvxPreviewBase()
2216 {
2217 	delete mpModel;
2218     delete mpBufferDevice;
2219 }
2220 
2221 void SvxPreviewBase::LocalPrePaint()
2222 {
2223     // init BufferDevice
2224     if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
2225     {
2226         mpBufferDevice->SetDrawMode(GetDrawMode());
2227         mpBufferDevice->SetSettings(GetSettings());
2228         mpBufferDevice->SetAntialiasing(GetAntialiasing());
2229         mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
2230 	    mpBufferDevice->SetMapMode(GetMapMode());
2231     }
2232 
2233     mpBufferDevice->Erase();
2234 }
2235 
2236 void SvxPreviewBase::LocalPostPaint()
2237 {
2238     // copy to front (in pixel mode)
2239 	const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
2240 	const bool bWasEnabledDst(IsMapModeEnabled());
2241 	const Point aEmptyPoint;
2242 
2243     mpBufferDevice->EnableMapMode(false);
2244     EnableMapMode(false);
2245 
2246     DrawOutDev(
2247         aEmptyPoint, GetOutputSizePixel(),
2248         aEmptyPoint, GetOutputSizePixel(),
2249         *mpBufferDevice);
2250 
2251     mpBufferDevice->EnableMapMode(bWasEnabledSrc);
2252     EnableMapMode(bWasEnabledDst);
2253 }
2254 
2255 void SvxPreviewBase::StateChanged(StateChangedType nType)
2256 {
2257 	Control::StateChanged(nType);
2258 
2259     if(STATE_CHANGE_CONTROLFOREGROUND == nType)
2260     {
2261 		InitSettings(true, false);
2262     }
2263 	else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
2264     {
2265 		InitSettings(false, true);
2266     }
2267 }
2268 
2269 void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
2270 {
2271     SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
2272 
2273     if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
2274     {
2275 		InitSettings(true, true);
2276     }
2277 	else
2278     {
2279 		Control::DataChanged(rDCEvt);
2280     }
2281 }
2282 
2283 /*************************************************************************
2284 |*
2285 |*    SvxXLinePreview::SvxXLinePreview()
2286 |*
2287 *************************************************************************/
2288 
2289 SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
2290 :	SvxPreviewBase( pParent, rResId ),
2291 	mpLineObjA( 0L ),
2292 	mpLineObjB( 0L ),
2293 	mpLineObjC( 0L ),
2294 	mpGraphic( 0L ),
2295 	mbWithSymbol( sal_False )
2296 {
2297 	const Size aOutputSize(GetOutputSize());
2298 	InitSettings( sal_True, sal_True );
2299 
2300 	const sal_Int32 nDistance(500L);
2301 	const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
2302 
2303 	// create DrawObectA
2304 	const sal_Int32 aYPosA(aOutputSize.Height() / 2);
2305 	const basegfx::B2DPoint aPointA1( nDistance,  aYPosA);
2306 	const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
2307 	basegfx::B2DPolygon aPolygonA;
2308 	aPolygonA.append(aPointA1);
2309 	aPolygonA.append(aPointA2);
2310 	mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
2311 	mpLineObjA->SetModel(&getModel());
2312 
2313 	// create DrawObectB
2314 	const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
2315 	const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
2316 	const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance,  aYPosB1);
2317 	const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
2318 	const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
2319 	basegfx::B2DPolygon aPolygonB;
2320 	aPolygonB.append(aPointB1);
2321 	aPolygonB.append(aPointB2);
2322 	aPolygonB.append(aPointB3);
2323 	mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
2324 	mpLineObjB->SetModel(&getModel());
2325 
2326 	// create DrawObectC
2327 	const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance,  aYPosB1);
2328 	const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
2329 	const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
2330 	basegfx::B2DPolygon aPolygonC;
2331 	aPolygonC.append(aPointC1);
2332 	aPolygonC.append(aPointC2);
2333 	aPolygonC.append(aPointC3);
2334 	mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
2335 	mpLineObjC->SetModel(&getModel());
2336 }
2337 
2338 SvxXLinePreview::~SvxXLinePreview()
2339 {
2340     SdrObject::Free( mpLineObjA );
2341     SdrObject::Free( mpLineObjB );
2342     SdrObject::Free( mpLineObjC );
2343 }
2344 
2345 // -----------------------------------------------------------------------
2346 
2347 void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
2348 {
2349 	mpGraphic = p;
2350 	maSymbolSize = s;
2351 }
2352 
2353 // -----------------------------------------------------------------------
2354 
2355 void SvxXLinePreview::ResizeSymbol(const Size& s)
2356 {
2357 	if ( s != maSymbolSize )
2358 	{
2359 		maSymbolSize = s;
2360 		Invalidate();
2361 	}
2362 }
2363 
2364 // -----------------------------------------------------------------------
2365 
2366 void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
2367 {
2368 	// Set ItemSet at objects
2369 	mpLineObjA->SetMergedItemSet(rItemSet);
2370 
2371 	// At line joints, do not use arrows
2372 	SfxItemSet aTempSet(rItemSet);
2373 	aTempSet.ClearItem(XATTR_LINESTART);
2374 	aTempSet.ClearItem(XATTR_LINEEND);
2375 
2376 	mpLineObjB->SetMergedItemSet(aTempSet);
2377 	mpLineObjC->SetMergedItemSet(aTempSet);
2378 }
2379 
2380 // -----------------------------------------------------------------------
2381 
2382 void SvxXLinePreview::Paint( const Rectangle& )
2383 {
2384 	LocalPrePaint();
2385 
2386 	// paint objects to buffer device
2387 	sdr::contact::SdrObjectVector aObjectVector;
2388 	aObjectVector.push_back(mpLineObjA);
2389 	aObjectVector.push_back(mpLineObjB);
2390 	aObjectVector.push_back(mpLineObjC);
2391 
2392 	sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2393 	sdr::contact::DisplayInfo aDisplayInfo;
2394 
2395 	// do processing
2396 	aPainter.ProcessDisplay(aDisplayInfo);
2397 
2398 	if ( mbWithSymbol && mpGraphic )
2399 	{
2400     	const Size aOutputSize(GetOutputSize());
2401 		Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
2402 		aPos.X() -= maSymbolSize.Width() / 2;
2403 		aPos.Y() -= maSymbolSize.Height() / 2;
2404 		mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
2405 	}
2406 
2407 	LocalPostPaint();
2408 }
2409 
2410 /*************************************************************************
2411 |*
2412 |*    SvxXRectPreview::SvxXRectPreview()
2413 |*
2414 *************************************************************************/
2415 
2416 SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
2417 :	SvxPreviewBase( pParent, rResId ),
2418 	mpRectangleObject(0)
2419 {
2420 	InitSettings(true, true);
2421 
2422 	// create RectangleObject
2423     const Rectangle aObjectSize(Point(), GetOutputSize());
2424 	mpRectangleObject = new SdrRectObj(aObjectSize);
2425 	mpRectangleObject->SetModel(&getModel());
2426 }
2427 
2428 SvxXRectPreview::~SvxXRectPreview()
2429 {
2430     SdrObject::Free(mpRectangleObject);
2431 }
2432 
2433 void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
2434 {
2435 	mpRectangleObject->SetMergedItemSet(rItemSet, true);
2436 	mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2437 }
2438 
2439 void SvxXRectPreview::Paint( const Rectangle& )
2440 {
2441 	LocalPrePaint();
2442 
2443     sdr::contact::SdrObjectVector aObjectVector;
2444 
2445     aObjectVector.push_back(mpRectangleObject);
2446 
2447     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2448 	sdr::contact::DisplayInfo aDisplayInfo;
2449 
2450 	aPainter.ProcessDisplay(aDisplayInfo);
2451 
2452     LocalPostPaint();
2453 }
2454 
2455 /*************************************************************************
2456 |*
2457 |*    SvxXShadowPreview::SvxXShadowPreview()
2458 |*
2459 *************************************************************************/
2460 
2461 SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
2462 :	SvxPreviewBase( pParent, rResId ),
2463 	mpRectangleObject(0),
2464     mpRectangleShadow(0)
2465 {
2466 	InitSettings(true, true);
2467 
2468     // prepare size
2469 	Size aSize = GetOutputSize();
2470 	aSize.Width() = aSize.Width() / 3;
2471 	aSize.Height() = aSize.Height() / 3;
2472 
2473     // create RectangleObject
2474     const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
2475 	mpRectangleObject = new SdrRectObj(aObjectSize);
2476 	mpRectangleObject->SetModel(&getModel());
2477 
2478     // create ShadowObject
2479     const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
2480 	mpRectangleShadow = new SdrRectObj(aShadowSize);
2481 	mpRectangleShadow->SetModel(&getModel());
2482 }
2483 
2484 SvxXShadowPreview::~SvxXShadowPreview()
2485 {
2486     SdrObject::Free(mpRectangleObject);
2487     SdrObject::Free(mpRectangleShadow);
2488 }
2489 
2490 void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
2491 {
2492 	mpRectangleObject->SetMergedItemSet(rItemSet, true);
2493 	mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2494 }
2495 
2496 void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
2497 {
2498 	mpRectangleShadow->SetMergedItemSet(rItemSet, true);
2499 	mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
2500 }
2501 
2502 void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
2503 {
2504     Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
2505     aObjectPosition.Move(rPos.X(), rPos.Y());
2506     mpRectangleShadow->SetSnapRect(aObjectPosition);
2507 }
2508 
2509 void SvxXShadowPreview::Paint( const Rectangle& )
2510 {
2511 	LocalPrePaint();
2512 
2513     sdr::contact::SdrObjectVector aObjectVector;
2514 
2515     aObjectVector.push_back(mpRectangleShadow);
2516 	aObjectVector.push_back(mpRectangleObject);
2517 
2518     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2519 	sdr::contact::DisplayInfo aDisplayInfo;
2520 
2521 	aPainter.ProcessDisplay(aDisplayInfo);
2522 
2523     LocalPostPaint();
2524 }
2525 
2526 // -----------------------------------------------------------------------
2527 // eof
2528