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