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