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