Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/shl.hxx>
30 : : #include <vcl/svapp.hxx>
31 : :
32 : : #include <svx/xtable.hxx>
33 : : #include <svx/xpool.hxx>
34 : :
35 : : #include <svx/dialogs.hrc>
36 : : #include "accessibility.hrc"
37 : : #include <svx/dlgctrl.hxx>
38 : : #include <svx/dialmgr.hxx>
39 : : #include <tools/poly.hxx>
40 : : #include <vcl/region.hxx>
41 : : #include <vcl/gradient.hxx>
42 : : #include <vcl/hatch.hxx>
43 : : #include <svtools/colorcfg.hxx>
44 : :
45 : : #include "svxrectctaccessiblecontext.hxx"
46 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
47 : : #include <basegfx/point/b2dpoint.hxx>
48 : : #include <basegfx/polygon/b2dpolygon.hxx>
49 : : #include <svx/svdorect.hxx>
50 : :
51 : : #include <svx/svdmodel.hxx>
52 : : #include <svx/svdopath.hxx>
53 : : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
54 : : #include <svx/sdr/contact/displayinfo.hxx>
55 : : #include "linectrl.hrc"
56 : :
57 : : #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
58 : : #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
59 : :
60 : : using namespace ::com::sun::star::uno;
61 : : using namespace ::com::sun::star::lang;
62 : : using namespace ::com::sun::star::accessibility;
63 : :
64 : : // Control for display and selection of the corner points and
65 : : // mid point of an object
66 : :
67 : 0 : Bitmap& SvxRectCtl::GetRectBitmap( void )
68 : : {
69 [ # # ]: 0 : if( !pBitmap )
70 : 0 : InitRectBitmap();
71 : :
72 : 0 : return *pBitmap;
73 : : }
74 : :
75 : 0 : SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
76 : : sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
77 : :
78 : : Control( pParent, rResId ),
79 : :
80 : : pAccContext ( NULL ),
81 : : nBorderWidth( nBorder ),
82 : : nRadius ( nCircle),
83 : : eDefRP ( eRpt ),
84 : : eCS ( eStyle ),
85 : : pBitmap ( NULL ),
86 : : m_nState ( 0 ),
87 : 0 : mbCompleteDisable(sal_False)
88 : : {
89 [ # # ][ # # ]: 0 : SetMapMode( MAP_100TH_MM );
[ # # ]
90 [ # # ]: 0 : Resize_Impl();
91 : 0 : }
92 : :
93 : : // -----------------------------------------------------------------------
94 : :
95 : 0 : SvxRectCtl::~SvxRectCtl()
96 : : {
97 [ # # ][ # # ]: 0 : delete pBitmap;
98 : :
99 [ # # ]: 0 : if( pAccContext )
100 : 0 : pAccContext->release();
101 [ # # ]: 0 : }
102 : :
103 : : // -----------------------------------------------------------------------
104 : 0 : void SvxRectCtl::Resize()
105 : : {
106 : 0 : Resize_Impl();
107 : 0 : Control::Resize();
108 : 0 : }
109 : :
110 : : // -----------------------------------------------------------------------
111 : :
112 : 0 : void SvxRectCtl::Resize_Impl()
113 : : {
114 : 0 : aSize = GetOutputSize();
115 : :
116 [ # # # ]: 0 : switch( eCS )
117 : : {
118 : : case CS_RECT:
119 : : case CS_ANGLE:
120 : : case CS_SHADOW:
121 : 0 : aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
122 : 0 : aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
123 : 0 : aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
124 : :
125 : 0 : aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 );
126 : 0 : aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
127 : 0 : aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
128 : :
129 : 0 : aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth );
130 : 0 : aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
131 : 0 : aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
132 : 0 : break;
133 : :
134 : : case CS_LINE:
135 : 0 : aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth );
136 : 0 : aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
137 : 0 : aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
138 : :
139 : 0 : aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 );
140 : 0 : aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
141 : 0 : aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
142 : :
143 : 0 : aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth );
144 : 0 : aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
145 : 0 : aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
146 : 0 : break;
147 : : }
148 : 0 : Reset();
149 : 0 : InitSettings( sal_True, sal_True );
150 : 0 : }
151 : : // -----------------------------------------------------------------------
152 : :
153 : 0 : void SvxRectCtl::InitRectBitmap( void )
154 : : {
155 [ # # ]: 0 : if( pBitmap )
156 [ # # ][ # # ]: 0 : delete pBitmap;
157 : :
158 [ # # ]: 0 : const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
159 [ # # ]: 0 : svtools::ColorConfig aColorConfig;
160 : :
161 [ # # ][ # # ]: 0 : pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
[ # # ]
162 : :
163 : : // set bitmap-colors
164 [ # # ]: 0 : Color aColorAry1[7];
165 [ # # ]: 0 : Color aColorAry2[7];
166 : 0 : aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
167 : 0 : aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
168 : 0 : aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
169 : 0 : aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
170 : 0 : aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
171 : 0 : aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
172 : 0 : aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
173 : 0 : aColorAry2[0] = rStyles.GetDialogColor(); // background
174 : 0 : aColorAry2[1] = rStyles.GetWindowColor();
175 : 0 : aColorAry2[2] = rStyles.GetLightColor();
176 : 0 : aColorAry2[3] = rStyles.GetShadowColor();
177 : 0 : aColorAry2[4] = rStyles.GetDarkShadowColor();
178 [ # # ]: 0 : aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
179 : 0 : aColorAry2[6] = rStyles.GetDialogColor();
180 : :
181 : : #ifdef DBG_UTIL
182 : : static sal_Bool bModify = sal_False;
183 : : sal_Bool& rModify = bModify;
184 : : if( rModify )
185 : : {
186 : : static int n = 0;
187 : : static sal_uInt8 r = 0xFF;
188 : : static sal_uInt8 g = 0x00;
189 : : static sal_uInt8 b = 0xFF;
190 : : int& rn = n;
191 : : sal_uInt8& rr = r;
192 : : sal_uInt8& rg = g;
193 : : sal_uInt8& rb = b;
194 : : aColorAry2[ rn ] = Color( rr, rg, rb );
195 : : }
196 : : #endif
197 : :
198 [ # # ][ # # ]: 0 : pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
199 : 0 : }
200 : :
201 : : // -----------------------------------------------------------------------
202 : :
203 : 0 : void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
204 : : {
205 : 0 : const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
206 : :
207 [ # # ]: 0 : if( bForeground )
208 : : {
209 [ # # ]: 0 : svtools::ColorConfig aColorConfig;
210 [ # # ]: 0 : Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
211 : :
212 [ # # ][ # # ]: 0 : if ( IsControlForeground() )
213 [ # # ]: 0 : aTextColor = GetControlForeground();
214 [ # # ][ # # ]: 0 : SetTextColor( aTextColor );
215 : : }
216 : :
217 [ # # ]: 0 : if( bBackground )
218 : : {
219 [ # # ]: 0 : if ( IsControlBackground() )
220 [ # # ][ # # ]: 0 : SetBackground( GetControlBackground() );
[ # # ]
221 : : else
222 [ # # ]: 0 : SetBackground( rStyleSettings.GetWindowColor() );
223 : : }
224 : :
225 [ # # ]: 0 : delete pBitmap;
226 : 0 : pBitmap = NULL; // forces new creating of bitmap
227 : :
228 : 0 : Invalidate();
229 : 0 : }
230 : :
231 : : // The clicked rectangle (3 x 3) is determined and the parent (dialog)
232 : : // is notified that the item was changed
233 : 0 : void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
234 : : {
235 : : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
236 [ # # ]: 0 : if(!IsCompletelyDisabled())
237 : : {
238 : 0 : Point aPtLast = aPtNew;
239 : :
240 [ # # ]: 0 : aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
241 : :
242 [ # # ][ # # ]: 0 : if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
[ # # ][ # # ]
243 : : {
244 : 0 : aPtNew = aPtLast;
245 : : }
246 : : else
247 : : {
248 : 0 : Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
249 [ # # ][ # # ]: 0 : aPtLast + Point( nRadius, nRadius ) ) );
250 : 0 : Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
251 [ # # ][ # # ]: 0 : aPtNew + Point( nRadius, nRadius ) ) );
252 [ # # ]: 0 : eRP = GetRPFromPoint( aPtNew );
253 : :
254 [ # # ]: 0 : SetActualRP( eRP );
255 : :
256 [ # # ][ # # ]: 0 : if( WINDOW_TABPAGE == GetParent()->GetType() )
[ # # ]
257 [ # # ][ # # ]: 0 : ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
258 : : }
259 : : }
260 : 0 : }
261 : :
262 : : // -----------------------------------------------------------------------
263 : :
264 : 0 : void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
265 : : {
266 : : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
267 [ # # ]: 0 : if(!IsCompletelyDisabled())
268 : : {
269 : 0 : RECT_POINT eNewRP = eRP;
270 [ # # ][ # # ]: 0 : sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
271 : :
272 [ # # # # : 0 : switch( rKeyEvt.GetKeyCode().GetCode() )
# ]
273 : : {
274 : : case KEY_DOWN:
275 : : {
276 [ # # ]: 0 : if( !(m_nState & CS_NOVERT) )
277 [ # # # # : 0 : switch( eNewRP )
# # # ]
278 : : {
279 : 0 : case RP_LT: eNewRP = RP_LM; break;
280 [ # # ]: 0 : case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
281 : 0 : case RP_RT: eNewRP = RP_RM; break;
282 : 0 : case RP_LM: eNewRP = RP_LB; break;
283 : 0 : case RP_MM: eNewRP = RP_MB; break;
284 : 0 : case RP_RM: eNewRP = RP_RB; break;
285 : : default: ; //prevent warning
286 : : }
287 : : }
288 : 0 : break;
289 : : case KEY_UP:
290 : : {
291 [ # # ]: 0 : if( !(m_nState & CS_NOVERT) )
292 [ # # # # : 0 : switch( eNewRP )
# # # ]
293 : : {
294 : 0 : case RP_LM: eNewRP = RP_LT; break;
295 : 0 : case RP_MM: eNewRP = RP_MT; break;
296 : 0 : case RP_RM: eNewRP = RP_RT; break;
297 : 0 : case RP_LB: eNewRP = RP_LM; break;
298 [ # # ]: 0 : case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
299 : 0 : case RP_RB: eNewRP = RP_RM; break;
300 : : default: ; //prevent warning
301 : : }
302 : : }
303 : 0 : break;
304 : : case KEY_LEFT:
305 : : {
306 [ # # ]: 0 : if( !(m_nState & CS_NOHORZ) )
307 [ # # # # : 0 : switch( eNewRP )
# # # ]
308 : : {
309 : 0 : case RP_MT: eNewRP = RP_LT; break;
310 : 0 : case RP_RT: eNewRP = RP_MT; break;
311 : 0 : case RP_MM: eNewRP = RP_LM; break;
312 [ # # ]: 0 : case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
313 : 0 : case RP_MB: eNewRP = RP_LB; break;
314 : 0 : case RP_RB: eNewRP = RP_MB; break;
315 : : default: ; //prevent warning
316 : : }
317 : : }
318 : 0 : break;
319 : : case KEY_RIGHT:
320 : : {
321 [ # # ]: 0 : if( !(m_nState & CS_NOHORZ) )
322 [ # # # # : 0 : switch( eNewRP )
# # # ]
323 : : {
324 : 0 : case RP_LT: eNewRP = RP_MT; break;
325 : 0 : case RP_MT: eNewRP = RP_RT; break;
326 [ # # ]: 0 : case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
327 : 0 : case RP_MM: eNewRP = RP_RM; break;
328 : 0 : case RP_LB: eNewRP = RP_MB; break;
329 : 0 : case RP_MB: eNewRP = RP_RB; break;
330 : : default: ; //prevent warning
331 : : }
332 : : }
333 : 0 : break;
334 : : default:
335 : 0 : Control::KeyInput( rKeyEvt );
336 : 0 : return;
337 : : }
338 [ # # ]: 0 : if( eNewRP != eRP )
339 : : {
340 : 0 : SetActualRP( eNewRP );
341 : :
342 [ # # ]: 0 : if( WINDOW_TABPAGE == GetParent()->GetType() )
343 : 0 : ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
344 : :
345 : 0 : SetFocusRect();
346 : : }
347 : : }
348 : : }
349 : :
350 : : // -----------------------------------------------------------------------
351 : :
352 : 0 : void SvxRectCtl::StateChanged( StateChangedType nType )
353 : : {
354 [ # # ]: 0 : if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
355 : 0 : InitSettings( sal_True, sal_False );
356 [ # # ]: 0 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
357 : 0 : InitSettings( sal_False, sal_True );
358 : :
359 : 0 : Window::StateChanged( nType );
360 : 0 : }
361 : :
362 : : // -----------------------------------------------------------------------
363 : :
364 : 0 : void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
365 : : {
366 [ # # ][ # # ]: 0 : if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
[ # # ]
367 : 0 : InitSettings( sal_True, sal_True );
368 : : else
369 : 0 : Window::DataChanged( rDCEvt );
370 : 0 : }
371 : :
372 : : // the control (rectangle with 9 circles)
373 : :
374 : 0 : void SvxRectCtl::Paint( const Rectangle& )
375 : : {
376 [ # # ]: 0 : Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
377 : :
378 [ # # ]: 0 : const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
379 : :
380 [ # # ]: 0 : SetLineColor( rStyles.GetDialogColor() );
381 [ # # ]: 0 : SetFillColor( rStyles.GetDialogColor() );
382 [ # # ][ # # ]: 0 : DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
[ # # ]
383 : :
384 [ # # ][ # # ]: 0 : if( IsEnabled() )
385 [ # # ]: 0 : SetLineColor( rStyles.GetLabelTextColor() );
386 : : else
387 [ # # ]: 0 : SetLineColor( rStyles.GetShadowColor() );
388 : :
389 [ # # ]: 0 : SetFillColor();
390 : :
391 [ # # # # ]: 0 : switch( eCS )
392 : : {
393 : :
394 : : case CS_RECT:
395 : : case CS_SHADOW:
396 [ # # ][ # # ]: 0 : if( !IsEnabled() )
397 : : {
398 : 0 : Color aOldCol = GetLineColor();
399 [ # # ]: 0 : SetLineColor( rStyles.GetLightColor() );
400 [ # # ][ # # ]: 0 : DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
401 [ # # ]: 0 : SetLineColor( aOldCol );
402 : : }
403 [ # # ][ # # ]: 0 : DrawRect( Rectangle( aPtLT, aPtRB ) );
404 : 0 : break;
405 : :
406 : : case CS_LINE:
407 [ # # ][ # # ]: 0 : if( !IsEnabled() )
408 : : {
409 : 0 : Color aOldCol = GetLineColor();
410 [ # # ]: 0 : SetLineColor( rStyles.GetLightColor() );
411 : 0 : DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
412 [ # # ]: 0 : aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
413 [ # # ]: 0 : SetLineColor( aOldCol );
414 : : }
415 : 0 : DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
416 [ # # ]: 0 : aPtRM + Point( 2 * nBorderWidth, 0 ) );
417 : 0 : break;
418 : :
419 : : case CS_ANGLE:
420 [ # # ][ # # ]: 0 : if( !IsEnabled() )
421 : : {
422 : 0 : Color aOldCol = GetLineColor();
423 [ # # ]: 0 : SetLineColor( rStyles.GetLightColor() );
424 [ # # ]: 0 : DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
425 [ # # ]: 0 : DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
426 [ # # ]: 0 : DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
427 [ # # ]: 0 : DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
428 [ # # ]: 0 : SetLineColor( aOldCol );
429 : : }
430 [ # # ]: 0 : DrawLine( aPtLT, aPtRB );
431 [ # # ]: 0 : DrawLine( aPtLB, aPtRT );
432 [ # # ]: 0 : DrawLine( aPtLM, aPtRM );
433 [ # # ]: 0 : DrawLine( aPtMT, aPtMB );
434 : 0 : break;
435 : :
436 : : default:
437 : 0 : break;
438 : : }
439 [ # # ][ # # ]: 0 : SetFillColor( GetBackground().GetColor() );
440 : :
441 : 0 : Size aBtnSize( 11, 11 );
442 [ # # ]: 0 : Size aDstBtnSize( PixelToLogic( aBtnSize ) );
443 : 0 : Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
444 [ # # ][ # # ]: 0 : Point aBtnPnt1( IsEnabled()?0:22,0 );
445 : 0 : Point aBtnPnt2( 11,0 );
446 : 0 : Point aBtnPnt3( 22,0 );
447 : :
448 : 0 : sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
449 : 0 : sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0;
450 : :
451 [ # # ]: 0 : Bitmap& rBitmap = GetRectBitmap();
452 : :
453 : : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
454 [ # # ]: 0 : if(IsCompletelyDisabled())
455 : : {
456 [ # # ]: 0 : DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
457 [ # # ]: 0 : DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
458 [ # # ]: 0 : DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
459 [ # # ]: 0 : DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
460 [ # # ][ # # ]: 0 : if( eCS == CS_RECT || eCS == CS_LINE )
461 [ # # ]: 0 : DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
462 [ # # ]: 0 : DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
463 [ # # ]: 0 : DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
464 [ # # ]: 0 : DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
465 [ # # ]: 0 : DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
466 : : }
467 : : else
468 : : {
469 [ # # ][ # # ]: 0 : DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
470 [ # # ][ # # ]: 0 : DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
471 [ # # ][ # # ]: 0 : DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
472 : :
473 [ # # ][ # # ]: 0 : DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
474 : :
475 : : // Center for rectangle and line
476 [ # # ][ # # ]: 0 : if( eCS == CS_RECT || eCS == CS_LINE )
477 [ # # ]: 0 : DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
478 : :
479 [ # # ][ # # ]: 0 : DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
480 : :
481 [ # # ][ # # ]: 0 : DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
482 [ # # ][ # # ]: 0 : DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
483 [ # # ][ # # ]: 0 : DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
484 : : }
485 : :
486 : : // draw active button, avoid center pos for angle
487 : : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
488 [ # # ]: 0 : if(!IsCompletelyDisabled())
489 : : {
490 [ # # ][ # # ]: 0 : if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
[ # # ][ # # ]
[ # # ]
491 : : {
492 : 0 : Point aCenterPt( aPtNew );
493 : 0 : aCenterPt -= aToCenter;
494 : :
495 [ # # ]: 0 : DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
496 : : }
497 : : }
498 : 0 : }
499 : :
500 : : // Convert RECT_POINT Point
501 : :
502 : 0 : Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
503 : : {
504 [ # # # # : 0 : switch( _eRP )
# # # # #
# ]
505 : : {
506 : 0 : case RP_LT: return aPtLT;
507 : 0 : case RP_MT: return aPtMT;
508 : 0 : case RP_RT: return aPtRT;
509 : 0 : case RP_LM: return aPtLM;
510 : 0 : case RP_MM: return aPtMM;
511 : 0 : case RP_RM: return aPtRM;
512 : 0 : case RP_LB: return aPtLB;
513 : 0 : case RP_MB: return aPtMB;
514 : 0 : case RP_RB: return aPtRB;
515 : : }
516 : 0 : return( aPtMM ); // default
517 : : }
518 : :
519 : :
520 : 0 : void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
521 : : {
522 : 0 : HideFocus();
523 : :
524 [ # # ]: 0 : if( pRect )
525 : 0 : ShowFocus( *pRect );
526 : : else
527 [ # # ]: 0 : ShowFocus( CalculateFocusRectangle() );
528 : 0 : }
529 : :
530 : 0 : Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
531 : : {
532 : 0 : Point aPtLast = aPtNew;
533 : 0 : aPtNew = GetPointFromRP( eNewRP );
534 : :
535 [ # # ]: 0 : if( (m_nState & CS_NOHORZ) != 0 )
536 : 0 : aPtNew.X() = aPtMM.X();
537 : :
538 [ # # ]: 0 : if( (m_nState & CS_NOVERT) != 0 )
539 : 0 : aPtNew.Y() = aPtMM.Y();
540 : :
541 : 0 : eNewRP = GetRPFromPoint( aPtNew );
542 : :
543 : 0 : eDefRP = eNewRP;
544 : 0 : eRP = eNewRP;
545 : :
546 : 0 : return aPtLast;
547 : : }
548 : :
549 : 0 : void SvxRectCtl::GetFocus()
550 : : {
551 : 0 : SetFocusRect();
552 : 0 : }
553 : :
554 : :
555 : 0 : void SvxRectCtl::LoseFocus()
556 : : {
557 : 0 : HideFocus();
558 : 0 : }
559 : :
560 : :
561 : 0 : Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
562 : : {
563 [ # # ]: 0 : Point aPt = PixelToLogic( rPt );
564 : : long x;
565 : : long y;
566 : :
567 [ # # ]: 0 : if( ( m_nState & CS_NOHORZ ) == 0 )
568 : : {
569 [ # # ]: 0 : if( aPt.X() < aSize.Width() / 3 )
570 : 0 : x = aPtLT.X();
571 [ # # ]: 0 : else if( aPt.X() < aSize.Width() * 2 / 3 )
572 : 0 : x = aPtMM.X();
573 : : else
574 : 0 : x = aPtRB.X();
575 : : }
576 : : else
577 : 0 : x = aPtMM.X();
578 : :
579 [ # # ]: 0 : if( ( m_nState & CS_NOVERT ) == 0 )
580 : : {
581 [ # # ]: 0 : if( aPt.Y() < aSize.Height() / 3 )
582 : 0 : y = aPtLT.Y();
583 [ # # ]: 0 : else if( aPt.Y() < aSize.Height() * 2 / 3 )
584 : 0 : y = aPtMM.Y();
585 : : else
586 : 0 : y = aPtRB.Y();
587 : : }
588 : : else
589 : 0 : y = aPtMM.Y();
590 : :
591 : 0 : return Point( x, y );
592 : : }
593 : :
594 : :
595 : : // Converts Point in RECT_POINT
596 : :
597 : 0 : RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
598 : : {
599 [ # # ]: 0 : if ( aPt == aPtLT) return RP_LT;
600 [ # # ]: 0 : else if( aPt == aPtMT) return RP_MT;
601 [ # # ]: 0 : else if( aPt == aPtRT) return RP_RT;
602 [ # # ]: 0 : else if( aPt == aPtLM) return RP_LM;
603 [ # # ]: 0 : else if( aPt == aPtRM) return RP_RM;
604 [ # # ]: 0 : else if( aPt == aPtLB) return RP_LB;
605 [ # # ]: 0 : else if( aPt == aPtMB) return RP_MB;
606 [ # # ]: 0 : else if( aPt == aPtRB) return RP_RB;
607 : :
608 : : else
609 : 0 : return RP_MM; // default
610 : : }
611 : :
612 : : // Resets to the original state of the control
613 : :
614 : 0 : void SvxRectCtl::Reset()
615 : : {
616 : 0 : aPtNew = GetPointFromRP( eDefRP );
617 : 0 : eRP = eDefRP;
618 : 0 : Invalidate();
619 : 0 : }
620 : :
621 : : // Returns the currently selected RECT_POINT
622 : :
623 : 0 : RECT_POINT SvxRectCtl::GetActualRP() const
624 : : {
625 : 0 : return( eRP );
626 : : }
627 : :
628 : 0 : void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
629 : : {
630 [ # # ]: 0 : Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
631 : :
632 [ # # ][ # # ]: 0 : Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
633 [ # # ][ # # ]: 0 : Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
634 : :
635 : : // notify accessibility object about change
636 [ # # ]: 0 : if( pAccContext )
637 [ # # ]: 0 : pAccContext->selectChild( eNewRP );
638 : 0 : }
639 : :
640 : 0 : void SvxRectCtl::SetState( CTL_STATE nState )
641 : : {
642 : 0 : m_nState = nState;
643 : :
644 [ # # ]: 0 : Point aPtLast( GetPointFromRP( eRP ) );
645 : 0 : Point _aPtNew( aPtLast );
646 : :
647 [ # # ]: 0 : if( (m_nState & CS_NOHORZ) != 0 )
648 : 0 : _aPtNew.X() = aPtMM.X();
649 : :
650 [ # # ]: 0 : if( (m_nState & CS_NOVERT) != 0 )
651 : 0 : _aPtNew.Y() = aPtMM.Y();
652 : :
653 [ # # ]: 0 : eRP = GetRPFromPoint( _aPtNew );
654 [ # # ]: 0 : Invalidate();
655 : :
656 [ # # ][ # # ]: 0 : if( WINDOW_TABPAGE == GetParent()->GetType() )
[ # # ]
657 [ # # ][ # # ]: 0 : ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
658 : 0 : }
659 : :
660 : 0 : sal_uInt8 SvxRectCtl::GetNumOfChildren( void ) const
661 : : {
662 [ # # ]: 0 : return ( eCS == CS_ANGLE )? 8 : 9;
663 : : }
664 : :
665 : 0 : Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
666 : : {
667 [ # # ]: 0 : Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
668 [ # # ]: 0 : return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
669 : : }
670 : :
671 : 0 : Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
672 : : {
673 : 0 : Rectangle aRet;
674 : 0 : RECT_POINT eOldRectPoint = GetActualRP();
675 : :
676 [ # # ]: 0 : if( eOldRectPoint == eRectPoint )
677 : 0 : aRet = CalculateFocusRectangle();
678 : : else
679 : : {
680 : 0 : SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
681 : :
682 : 0 : pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
683 : 0 : aRet = CalculateFocusRectangle();
684 : :
685 : 0 : pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
686 : : }
687 : :
688 : 0 : return aRet;
689 : : }
690 : :
691 : 0 : Reference< XAccessible > SvxRectCtl::CreateAccessible()
692 : : {
693 [ # # ]: 0 : Window* pParent = GetAccessibleParentWindow();
694 : :
695 : : DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
696 : :
697 [ # # ]: 0 : Reference< XAccessible > xAccParent = pParent->GetAccessible();
698 [ # # ]: 0 : if( xAccParent.is() )
699 : : {
700 [ # # ]: 0 : pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
701 : 0 : pAccContext->acquire();
702 : :
703 [ # # ][ # # ]: 0 : SetActualRP( GetActualRP() );
704 : :
705 [ # # ][ # # ]: 0 : return pAccContext;
706 : : }
707 : : else
708 : 0 : return Reference< XAccessible >();
709 : : }
710 : :
711 : 0 : RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
712 : : {
713 [ # # ][ # # ]: 0 : return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
714 : : }
715 : :
716 : : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
717 : 0 : void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
718 : : {
719 : 0 : mbCompleteDisable = bNew;
720 : 0 : Invalidate();
721 : 0 : }
722 : :
723 : : // Control for editing bitmaps
724 : :
725 : 0 : SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
726 : : Control ( pParent, rResId ),
727 : : nLines ( nNumber ),
728 : 0 : bPaintable ( sal_True )
729 : : {
730 [ # # ]: 0 : aRectSize = GetOutputSize();
731 : :
732 : 0 : SetPixelColor( Color( COL_BLACK ) );
733 : 0 : SetBackgroundColor( Color( COL_WHITE ) );
734 [ # # ]: 0 : SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
735 : :
736 : 0 : nSquares = nLines * nLines;
737 [ # # ]: 0 : pPixel = new sal_uInt16[ nSquares ];
738 [ # # ]: 0 : rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
739 : 0 : }
740 : :
741 : : // Destructor dealocating the dynamic array
742 : :
743 : 0 : SvxPixelCtl::~SvxPixelCtl( )
744 : : {
745 [ # # ]: 0 : delete []pPixel;
746 [ # # ]: 0 : }
747 : :
748 : : // Changes the foreground or Background color
749 : :
750 : 0 : void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
751 : : {
752 [ # # ]: 0 : if( *( pPixel + nPixel) == 0 )
753 : 0 : *( pPixel + nPixel) = 1; // could be extended to more colors
754 : : else
755 : 0 : *( pPixel + nPixel) = 0;
756 : 0 : }
757 : :
758 : : // The clicked rectangle is identified, to change its color
759 : :
760 : 0 : void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
761 : : {
762 [ # # ]: 0 : Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
763 : 0 : Point aPtTl, aPtBr;
764 : : sal_uInt16 nX, nY;
765 : :
766 : 0 : nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
767 : 0 : nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
768 : :
769 [ # # ]: 0 : ChangePixel( nX + nY * nLines );
770 : :
771 : 0 : aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
772 : 0 : aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
773 : 0 : aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
774 : 0 : aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
775 : :
776 [ # # ][ # # ]: 0 : Invalidate( Rectangle( aPtTl, aPtBr ) );
777 : :
778 [ # # ][ # # ]: 0 : if( WINDOW_TABPAGE == GetParent()->GetType() )
[ # # ]
779 [ # # ][ # # ]: 0 : ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint is a dummy
780 : 0 : }
781 : :
782 : : // Draws the Control (Rectangle with nine circles)
783 : :
784 : 0 : void SvxPixelCtl::Paint( const Rectangle& )
785 : : {
786 : : sal_uInt16 i, j, nTmp;
787 : 0 : Point aPtTl, aPtBr;
788 : :
789 [ # # ]: 0 : if( bPaintable )
790 : : {
791 : : // Draw lines
792 [ # # ]: 0 : Control::SetLineColor( aLineColor );
793 [ # # ]: 0 : for( i = 1; i < nLines; i++)
794 : : {
795 : : // horizontal
796 : 0 : nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
797 [ # # ]: 0 : DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
798 : : // vertically
799 : 0 : nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
800 [ # # ]: 0 : DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
801 : : }
802 : :
803 : : //Draw Rectangles (squares)
804 [ # # ]: 0 : Control::SetLineColor();
805 : 0 : sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
806 : :
807 [ # # ]: 0 : for( i = 0; i < nLines; i++)
808 : : {
809 : 0 : aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
810 : 0 : aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
811 : :
812 [ # # ]: 0 : for( j = 0; j < nLines; j++)
813 : : {
814 : 0 : aPtTl.X() = aRectSize.Width() * j / nLines + 1;
815 : 0 : aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
816 : :
817 [ # # ]: 0 : if ( *( pPixel + i * nLines + j ) != nLastPixel )
818 : : {
819 : 0 : nLastPixel = *( pPixel + i * nLines + j );
820 : : // Change color: 0 -> Background color
821 [ # # ][ # # ]: 0 : SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
822 : : }
823 [ # # ][ # # ]: 0 : DrawRect( Rectangle( aPtTl, aPtBr ) );
824 : : }
825 : : }
826 : : } // bPaintable
827 : : else
828 : : {
829 [ # # ][ # # ]: 0 : SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
[ # # ]
830 [ # # ]: 0 : Control::SetLineColor( Color( COL_LIGHTRED ) );
831 [ # # ]: 0 : DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
832 [ # # ]: 0 : DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
833 : : }
834 : 0 : }
835 : :
836 : 0 : void SvxPixelCtl::SetXBitmap( const XOBitmap& rXBmp )
837 : : {
838 [ # # ]: 0 : if( rXBmp.GetBitmapType() == XBITMAP_8X8 )
839 : : {
840 : 0 : aPixelColor = rXBmp.GetPixelColor();
841 : 0 : aBackgroundColor = rXBmp.GetBackgroundColor();
842 : :
843 : 0 : sal_uInt16* pArray = rXBmp.GetPixelArray();
844 : :
845 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nSquares; i++ )
846 : 0 : *( pPixel + i ) = *( pArray + i );
847 : : }
848 : 0 : }
849 : :
850 : : // Resets to the original state of the control
851 : :
852 : 0 : void SvxPixelCtl::Reset()
853 : : {
854 : : // clear pixel area
855 : 0 : rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
856 : 0 : Invalidate();
857 : 0 : }
858 : :
859 : : // Constructor: BitmapCtl for SvxPixelCtl
860 : :
861 : 0 : SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
862 : : {
863 : 0 : aSize = rSize;
864 : 0 : }
865 : :
866 : 0 : SvxBitmapCtl::~SvxBitmapCtl()
867 : : {
868 : 0 : }
869 : :
870 : : // BitmapCtl: Returns the Bitmap
871 : :
872 : 0 : XOBitmap SvxBitmapCtl::GetXBitmap()
873 : : {
874 [ # # ]: 0 : XOBitmap aXOBitmap( pBmpArray, aPixelColor, aBackgroundColor );
875 : :
876 : 0 : return( aXOBitmap );
877 : : }
878 : :
879 : : // Fills the Listbox with color and strings
880 : :
881 : 129 : void ColorLB::Fill( const XColorListRef &pColorTab )
882 : : {
883 : 129 : long nCount = pColorTab->Count();
884 : : XColorEntry* pEntry;
885 : 129 : SetUpdateMode( sal_False );
886 : :
887 [ + + ]: 13029 : for( long i = 0; i < nCount; i++ )
888 : : {
889 : 12900 : pEntry = pColorTab->GetColor( i );
890 : 12900 : InsertEntry( pEntry->GetColor(), pEntry->GetName() );
891 : : }
892 : 129 : SetUpdateMode( sal_True );
893 : 129 : }
894 : :
895 : : /************************************************************************/
896 : :
897 : 0 : void ColorLB::Append( XColorEntry* pEntry, Bitmap* )
898 : : {
899 : 0 : InsertEntry( pEntry->GetColor(), pEntry->GetName() );
900 : 0 : }
901 : :
902 : : /************************************************************************/
903 : :
904 : 0 : void ColorLB::Modify( XColorEntry* pEntry, sal_uInt16 nPos, Bitmap* )
905 : : {
906 : 0 : RemoveEntry( nPos );
907 : 0 : InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos );
908 : 0 : }
909 : :
910 : : // Fills the Listbox with color and strings
911 : :
912 : 119 : void FillAttrLB::Fill( const XColorListRef &pColorTab )
913 : : {
914 : 119 : long nCount = pColorTab->Count();
915 : : XColorEntry* pEntry;
916 : 119 : SetUpdateMode( sal_False );
917 : :
918 [ + + ]: 12019 : for( long i = 0; i < nCount; i++ )
919 : : {
920 : 11900 : pEntry = pColorTab->GetColor( i );
921 : 11900 : InsertEntry( pEntry->GetColor(), pEntry->GetName() );
922 : : }
923 : 119 : SetUpdateMode( sal_True );
924 : 119 : }
925 : :
926 : : // Fills the listbox (provisional) with strings
927 : :
928 : 0 : HatchingLB::HatchingLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ )
929 : : : ListBox( pParent, Id ),
930 : : mpList ( NULL ),
931 : 0 : mbUserDraw( bUserDraw )
932 : : {
933 [ # # ]: 0 : EnableUserDraw( mbUserDraw );
934 : 0 : }
935 : :
936 : 0 : void HatchingLB::Fill( const XHatchListRef &pList )
937 : : {
938 : 0 : mpList = pList;
939 : : XHatchEntry* pEntry;
940 : 0 : long nCount = pList->Count();
941 : :
942 : 0 : SetUpdateMode( sal_False );
943 : :
944 [ # # ]: 0 : if( mbUserDraw )
945 : : {
946 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
947 : 0 : InsertEntry( pList->GetHatch( i )->GetName() );
948 : : }
949 : : else
950 : : {
951 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
952 : : {
953 : 0 : pEntry = pList->GetHatch( i );
954 : 0 : Bitmap* pBitmap = pList->GetBitmap( i );
955 [ # # ]: 0 : if( pBitmap )
956 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBitmap );
957 : : else
958 : 0 : InsertEntry( pEntry->GetName() );
959 : : }
960 : : }
961 : :
962 : 0 : SetUpdateMode( sal_True );
963 : 0 : }
964 : :
965 : 0 : void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt )
966 : : {
967 [ # # ]: 0 : if( mpList != NULL )
968 : : {
969 : : // Draw gradient with borderrectangle
970 : 0 : const Rectangle& rDrawRect = rUDEvt.GetRect();
971 [ # # ]: 0 : Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
972 : :
973 : 0 : sal_Int32 nId = rUDEvt.GetItemId();
974 [ # # ][ # # ]: 0 : if( nId >= 0 && nId <= mpList->Count() )
[ # # ][ # # ]
975 : : {
976 : 0 : OutputDevice* pDevice = rUDEvt.GetDevice();
977 : :
978 : 0 : sal_uIntPtr nOldDrawMode = pDevice->GetDrawMode();
979 [ # # ][ # # ]: 0 : pDevice->SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
980 : :
981 [ # # ]: 0 : XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch();
982 [ # # ]: 0 : MapMode aMode( MAP_100TH_MM );
983 : 0 : Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(),
984 : : rXHatch.GetColor(),
985 [ # # ]: 0 : rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(),
986 [ # # ]: 0 : (sal_uInt16)rXHatch.GetAngle() );
987 [ # # ]: 0 : const Polygon aPolygon( aRect );
988 [ # # ]: 0 : const PolyPolygon aPolypoly( aPolygon );
989 [ # # ]: 0 : pDevice->DrawHatch( aPolypoly, aHatch );
990 : :
991 [ # # ]: 0 : pDevice->SetLineColor( COL_BLACK );
992 [ # # ]: 0 : pDevice->SetFillColor();
993 [ # # ]: 0 : pDevice->DrawRect( aRect );
994 : :
995 [ # # ]: 0 : pDevice->SetDrawMode( nOldDrawMode );
996 : :
997 : : // Draw name
998 [ # # ][ # # ]: 0 : pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() );
[ # # ][ # # ]
[ # # ][ # # ]
999 : : }
1000 : : }
1001 : 0 : }
1002 : :
1003 : : /************************************************************************/
1004 : :
1005 : 0 : void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp )
1006 : : {
1007 [ # # ]: 0 : if( pBmp )
1008 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp );
1009 : : else
1010 : 0 : InsertEntry( pEntry->GetName() );
1011 : 0 : }
1012 : :
1013 : : /************************************************************************/
1014 : :
1015 : 0 : void HatchingLB::Modify( XHatchEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1016 : : {
1017 : 0 : RemoveEntry( nPos );
1018 : :
1019 [ # # ]: 0 : if( pBmp )
1020 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp, nPos );
1021 : : else
1022 : 0 : InsertEntry( pEntry->GetName(), nPos );
1023 : 0 : }
1024 : :
1025 : : // Fills the listbox (provisional) with strings
1026 : :
1027 : 0 : void FillAttrLB::Fill( const XHatchListRef &pList )
1028 : : {
1029 : 0 : long nCount = pList->Count();
1030 : : XHatchEntry* pEntry;
1031 : 0 : ListBox::SetUpdateMode( sal_False );
1032 : :
1033 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1034 : : {
1035 : 0 : pEntry = pList->GetHatch( i );
1036 : 0 : Bitmap* pBitmap = pList->GetBitmap( i );
1037 [ # # ]: 0 : if( pBitmap )
1038 [ # # ]: 0 : ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1039 : : else
1040 : 0 : InsertEntry( pEntry->GetName() );
1041 : : }
1042 : 0 : ListBox::SetUpdateMode( sal_True );
1043 : 0 : }
1044 : :
1045 : : // Fills the listbox (provisional) with strings
1046 : :
1047 : 0 : GradientLB::GradientLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ )
1048 : : : ListBox( pParent, Id ),
1049 : : mpList(NULL),
1050 : 0 : mbUserDraw( bUserDraw )
1051 : : {
1052 [ # # ]: 0 : EnableUserDraw( mbUserDraw);
1053 : 0 : }
1054 : :
1055 : 0 : void GradientLB::Fill( const XGradientListRef &pList )
1056 : : {
1057 : 0 : mpList = pList;
1058 : : XGradientEntry* pEntry;
1059 : 0 : long nCount = pList->Count();
1060 : :
1061 : 0 : SetUpdateMode( sal_False );
1062 : :
1063 [ # # ]: 0 : if( mbUserDraw )
1064 : : {
1065 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1066 : 0 : InsertEntry( pList->GetGradient( i )->GetName() );
1067 : : }
1068 : : else
1069 : : {
1070 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1071 : : {
1072 : 0 : pEntry = pList->GetGradient( i );
1073 : 0 : Bitmap* pBitmap = pList->GetBitmap( i );
1074 [ # # ]: 0 : if( pBitmap )
1075 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBitmap );
1076 : : else
1077 : 0 : InsertEntry( pEntry->GetName() );
1078 : : }
1079 : : }
1080 : :
1081 : 0 : SetUpdateMode( sal_True );
1082 : 0 : }
1083 : :
1084 : 0 : void GradientLB::UserDraw( const UserDrawEvent& rUDEvt )
1085 : : {
1086 [ # # ]: 0 : if( mpList != NULL )
1087 : : {
1088 : : // Draw gradient with borderrectangle
1089 : 0 : const Rectangle& rDrawRect = rUDEvt.GetRect();
1090 [ # # ]: 0 : Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1091 : :
1092 : 0 : sal_Int32 nId = rUDEvt.GetItemId();
1093 [ # # ][ # # ]: 0 : if( nId >= 0 && nId <= mpList->Count() )
[ # # ][ # # ]
1094 : : {
1095 : 0 : OutputDevice* pDevice = rUDEvt.GetDevice();
1096 : :
1097 [ # # ]: 0 : XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient();
1098 [ # # ]: 0 : Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() );
1099 [ # # ]: 0 : aGradient.SetAngle( (sal_uInt16)rXGrad.GetAngle() );
1100 [ # # ]: 0 : aGradient.SetBorder( rXGrad.GetBorder() );
1101 [ # # ]: 0 : aGradient.SetOfsX( rXGrad.GetXOffset() );
1102 [ # # ]: 0 : aGradient.SetOfsY( rXGrad.GetYOffset() );
1103 [ # # ]: 0 : aGradient.SetStartIntensity( rXGrad.GetStartIntens() );
1104 [ # # ]: 0 : aGradient.SetEndIntensity( rXGrad.GetEndIntens() );
1105 [ # # ]: 0 : aGradient.SetSteps( 255 );
1106 : :
1107 : : // #i76307# always paint the preview in LTR, because this is what the document does
1108 [ # # ]: 0 : Window* pWin = dynamic_cast<Window*>(pDevice);
1109 [ # # ][ # # ]: 0 : if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL())
[ # # ][ # # ]
[ # # ][ # # ]
1110 : : {
1111 [ # # ]: 0 : long nWidth = pDevice->GetOutputSize().Width();
1112 : :
1113 [ # # ]: 0 : pWin->EnableRTL( sal_False );
1114 : :
1115 [ # # ]: 0 : Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ),
1116 [ # # ][ # # ]: 0 : aRect.GetSize() );
1117 : :
1118 [ # # ]: 0 : pDevice->DrawGradient( aMirrorRect, aGradient );
1119 : :
1120 [ # # ]: 0 : pWin->EnableRTL( sal_True );
1121 : : }
1122 : : else
1123 [ # # ]: 0 : pDevice->DrawGradient( aRect, aGradient );
1124 : :
1125 [ # # ]: 0 : pDevice->SetLineColor( COL_BLACK );
1126 [ # # ]: 0 : pDevice->SetFillColor();
1127 [ # # ]: 0 : pDevice->DrawRect( aRect );
1128 : :
1129 : : // Draw name
1130 [ # # ][ # # ]: 0 : pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() );
[ # # ]
1131 : : }
1132 : : }
1133 : 0 : }
1134 : :
1135 : : /************************************************************************/
1136 : :
1137 : 0 : void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp )
1138 : : {
1139 [ # # ]: 0 : if( pBmp )
1140 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp );
1141 : : else
1142 : 0 : InsertEntry( pEntry->GetName() );
1143 : 0 : }
1144 : :
1145 : : /************************************************************************/
1146 : :
1147 : 0 : void GradientLB::Modify( XGradientEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1148 : : {
1149 : 0 : RemoveEntry( nPos );
1150 : :
1151 [ # # ]: 0 : if( pBmp )
1152 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp, nPos );
1153 : : else
1154 : 0 : InsertEntry( pEntry->GetName(), nPos );
1155 : 0 : }
1156 : :
1157 : : /************************************************************************/
1158 : :
1159 : 0 : void GradientLB::SelectEntryByList( const XGradientListRef &pList, const String& rStr,
1160 : : const XGradient& rGradient, sal_uInt16 nDist )
1161 : : {
1162 [ # # ]: 0 : long nCount = pList->Count();
1163 : : XGradientEntry* pEntry;
1164 : 0 : sal_Bool bFound = sal_False;
1165 [ # # ]: 0 : String aStr;
1166 : :
1167 : : long i;
1168 [ # # ][ # # ]: 0 : for( i = 0; i < nCount && !bFound; i++ )
[ # # ]
1169 : : {
1170 [ # # ]: 0 : pEntry = pList->GetGradient( i );
1171 : :
1172 [ # # ]: 0 : aStr = pEntry->GetName();
1173 : :
1174 [ # # ][ # # ]: 0 : if( rStr == aStr && rGradient == pEntry->GetGradient() )
[ # # ][ # # ]
[ # # ]
1175 : 0 : bFound = sal_True;
1176 : : }
1177 [ # # ]: 0 : if( bFound )
1178 [ # # ][ # # ]: 0 : SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1179 : 0 : }
1180 : :
1181 : : // Fills the listbox (provisional) with strings
1182 : :
1183 : 0 : void FillAttrLB::Fill( const XGradientListRef &pList )
1184 : : {
1185 : 0 : long nCount = pList->Count();
1186 : : XGradientEntry* pEntry;
1187 : 0 : ListBox::SetUpdateMode( sal_False );
1188 : :
1189 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1190 : : {
1191 : 0 : pEntry = pList->GetGradient( i );
1192 : 0 : Bitmap* pBitmap = pList->GetBitmap( i );
1193 [ # # ]: 0 : if( pBitmap )
1194 [ # # ]: 0 : ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1195 : : else
1196 : 0 : InsertEntry( pEntry->GetName() );
1197 : : }
1198 : 0 : ListBox::SetUpdateMode( sal_True );
1199 : 0 : }
1200 : :
1201 : : // BitmapLB Constructor
1202 : :
1203 : 0 : BitmapLB::BitmapLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ )
1204 : : : ListBox( pParent, Id ),
1205 : : mpList( NULL ),
1206 [ # # ][ # # ]: 0 : mbUserDraw( bUserDraw )
1207 : : {
1208 [ # # ]: 0 : aVD.SetOutputSizePixel( Size( 32, 16 ) );
1209 [ # # ]: 0 : EnableUserDraw( mbUserDraw );
1210 : 0 : }
1211 : :
1212 : : /************************************************************************/
1213 : :
1214 : 0 : void BitmapLB::SetVirtualDevice()
1215 : : {
1216 [ # # ]: 0 : if( aBitmap.GetSizePixel().Width() > 8 ||
[ # # # # ]
[ # # ]
[ # # # # ]
1217 [ # # ][ # # ]: 0 : aBitmap.GetSizePixel().Height() > 8 )
[ # # ]
1218 : : {
1219 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
1220 : : }
1221 : : else
1222 : : {
1223 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
1224 [ # # ]: 0 : aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
1225 [ # # ]: 0 : aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
1226 [ # # ]: 0 : aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
1227 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
1228 [ # # ]: 0 : aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
1229 [ # # ]: 0 : aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
1230 [ # # ]: 0 : aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
1231 : : }
1232 : 0 : }
1233 : :
1234 : : /************************************************************************/
1235 : :
1236 : 0 : void BitmapLB::Fill( const XBitmapListRef &pList )
1237 : : {
1238 : 0 : mpList = pList;
1239 : : XBitmapEntry* pEntry;
1240 : 0 : long nCount = pList->Count();
1241 : :
1242 : 0 : SetUpdateMode( sal_False );
1243 : :
1244 [ # # ]: 0 : if( mbUserDraw )
1245 : : {
1246 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1247 : 0 : InsertEntry( pList->GetBitmap( i )->GetName() );
1248 : : }
1249 : : else
1250 : : {
1251 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1252 : : {
1253 : 0 : pEntry = pList->GetBitmap( i );
1254 [ # # ]: 0 : aBitmap = pEntry->GetXBitmap().GetBitmap();
1255 : :
1256 : 0 : SetVirtualDevice();
1257 : :
1258 [ # # ][ # # ]: 0 : InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
[ # # ][ # # ]
[ # # ]
1259 : : }
1260 : : }
1261 : :
1262 : 0 : SetUpdateMode( sal_True );
1263 : 0 : }
1264 : :
1265 : 0 : void BitmapLB::UserDraw( const UserDrawEvent& rUDEvt )
1266 : : {
1267 [ # # ]: 0 : if( mpList != NULL )
1268 : : {
1269 : : // Draw bitmap
1270 : 0 : const Rectangle& rDrawRect = rUDEvt.GetRect();
1271 [ # # ]: 0 : Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1272 : :
1273 : 0 : sal_Int32 nId = rUDEvt.GetItemId();
1274 [ # # ][ # # ]: 0 : if( nId >= 0 && nId <= mpList->Count() )
[ # # ][ # # ]
1275 : : {
1276 [ # # ]: 0 : Rectangle aClipRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nRight-1, rDrawRect.nBottom-1 );
1277 : :
1278 : 0 : OutputDevice* pDevice = rUDEvt.GetDevice();
1279 [ # # ][ # # ]: 0 : pDevice->SetClipRegion( Region( aClipRect ) );
[ # # ]
1280 : :
1281 [ # # ][ # # ]: 0 : aBitmap = mpList->GetBitmap( nId )->GetXBitmap().GetBitmap();
[ # # ][ # # ]
1282 : :
1283 : 0 : long nPosBaseX = aRect.nLeft;
1284 : 0 : long nPosBaseY = aRect.nTop;
1285 : :
1286 [ # # ]: 0 : if( aBitmap.GetSizePixel().Width() > 8 ||
[ # # # # ]
[ # # ]
[ # # # # ]
1287 [ # # ][ # # ]: 0 : aBitmap.GetSizePixel().Height() > 8 )
[ # # ]
1288 : : {
1289 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX, nPosBaseY ), Size( 32, 16 ), aBitmap );
1290 : : }
1291 : : else
1292 : : {
1293 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+0 ), aBitmap );
1294 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+0 ), aBitmap );
1295 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+0 ), aBitmap );
1296 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+0 ), aBitmap );
1297 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+8 ), aBitmap );
1298 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+8 ), aBitmap );
1299 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+8 ), aBitmap );
1300 [ # # ]: 0 : pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+8 ), aBitmap );
1301 : : }
1302 : :
1303 [ # # ]: 0 : pDevice->SetClipRegion();
1304 : :
1305 : : // Draw name
1306 [ # # ][ # # ]: 0 : pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetBitmap( nId )->GetName() );
1307 : : }
1308 : : }
1309 : 0 : }
1310 : :
1311 : : /************************************************************************/
1312 : :
1313 : 0 : void BitmapLB::Append( XBitmapEntry* pEntry, Bitmap* pBmp )
1314 : : {
1315 [ # # ]: 0 : if( pBmp )
1316 : : {
1317 [ # # ]: 0 : aBitmap = pEntry->GetXBitmap().GetBitmap();
1318 : 0 : SetVirtualDevice();
1319 [ # # ][ # # ]: 0 : InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
[ # # ][ # # ]
[ # # ]
1320 : : }
1321 : : else
1322 : 0 : InsertEntry( pEntry->GetName() );
1323 : 0 : }
1324 : :
1325 : : /************************************************************************/
1326 : :
1327 : 0 : void BitmapLB::Modify( XBitmapEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1328 : : {
1329 : 0 : RemoveEntry( nPos );
1330 : :
1331 [ # # ]: 0 : if( pBmp )
1332 : : {
1333 [ # # ]: 0 : aBitmap = pEntry->GetXBitmap().GetBitmap();
1334 : 0 : SetVirtualDevice();
1335 : :
1336 [ # # ][ # # ]: 0 : InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ), nPos );
[ # # ][ # # ]
[ # # ]
1337 : : }
1338 : : else
1339 : 0 : InsertEntry( pEntry->GetName() );
1340 : 0 : }
1341 : :
1342 : : // FillAttrLB Constructor
1343 : :
1344 : 129 : FillAttrLB::FillAttrLB( Window* pParent, WinBits aWB ) :
1345 [ + - ][ + - ]: 129 : ColorListBox( pParent, aWB )
1346 : : {
1347 [ + - ]: 129 : aVD.SetOutputSizePixel( Size( 32, 16 ) );
1348 : 129 : }
1349 : :
1350 : : /************************************************************************/
1351 : :
1352 : 0 : void FillAttrLB::SetVirtualDevice()
1353 : : {
1354 [ # # ]: 0 : if( aBitmap.GetSizePixel().Width() > 8 ||
[ # # # # ]
[ # # ]
[ # # # # ]
1355 [ # # ][ # # ]: 0 : aBitmap.GetSizePixel().Height() > 8 )
[ # # ]
1356 : : {
1357 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
1358 : : }
1359 : : else
1360 : : {
1361 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
1362 [ # # ]: 0 : aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
1363 [ # # ]: 0 : aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
1364 [ # # ]: 0 : aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
1365 [ # # ]: 0 : aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
1366 [ # # ]: 0 : aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
1367 [ # # ]: 0 : aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
1368 [ # # ]: 0 : aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
1369 : : }
1370 : 0 : }
1371 : :
1372 : : /************************************************************************/
1373 : :
1374 : 0 : void FillAttrLB::Fill( const XBitmapListRef &pList )
1375 : : {
1376 : 0 : long nCount = pList->Count();
1377 : : XBitmapEntry* pEntry;
1378 : 0 : ListBox::SetUpdateMode( sal_False );
1379 : :
1380 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1381 : : {
1382 : 0 : pEntry = pList->GetBitmap( i );
1383 [ # # ]: 0 : aBitmap = pEntry->GetXBitmap().GetBitmap();
1384 : :
1385 : 0 : SetVirtualDevice();
1386 : :
1387 [ # # ][ # # ]: 0 : ListBox::InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
[ # # ][ # # ]
[ # # ]
1388 : : }
1389 : 0 : ListBox::SetUpdateMode( sal_True );
1390 : 0 : }
1391 : :
1392 : : // Fills the listbox (provisional) with strings
1393 : :
1394 : 129 : void FillTypeLB::Fill()
1395 : : {
1396 : 129 : SetUpdateMode( sal_False );
1397 [ + - ][ + - ]: 129 : InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
[ + - ]
1398 [ + - ][ + - ]: 129 : InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
[ + - ]
1399 [ + - ][ + - ]: 129 : InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
[ + - ]
1400 [ + - ][ + - ]: 129 : InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
[ + - ]
1401 [ + - ][ + - ]: 129 : InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
[ + - ]
1402 : 129 : SetUpdateMode( sal_True );
1403 : 129 : }
1404 : :
1405 : : // Fills the listbox (provisional) with strings
1406 : :
1407 : 126 : void LineLB::Fill( const XDashListRef &pList )
1408 : : {
1409 : 126 : long nCount = pList->Count();
1410 : : XDashEntry* pEntry;
1411 : 126 : SetUpdateMode( sal_False );
1412 : :
1413 [ + + ]: 1512 : for( long i = 0; i < nCount; i++ )
1414 : : {
1415 : 1386 : pEntry = pList->GetDash( i );
1416 : 1386 : Bitmap* pBitmap = pList->CreateBitmapForUI( i );
1417 [ + - ]: 1386 : if( pBitmap )
1418 : : {
1419 [ + - ]: 1386 : InsertEntry( pEntry->GetName(), *pBitmap );
1420 [ + - ]: 1386 : delete pBitmap;
1421 : : }
1422 : : else
1423 : 0 : InsertEntry( pEntry->GetName() );
1424 : : }
1425 : 126 : SetUpdateMode( sal_True );
1426 : 126 : }
1427 : :
1428 : 126 : void LineLB::FillStyles()
1429 : : {
1430 [ + - ]: 126 : ResMgr& rMgr = DIALOG_MGR();
1431 : :
1432 : : // Line Styles
1433 [ + - ]: 126 : Clear();
1434 [ + - ][ + - ]: 126 : InsertEntry( String( ResId( RID_SVXSTR_INVISIBLE, rMgr ) ) );
[ + - ]
1435 : :
1436 [ + - ]: 126 : const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
1437 [ + - ][ + - ]: 126 : Bitmap aBitmap ( SVX_RES ( RID_SVXCTRL_LINECTRL ) );
1438 [ + + ]: 378 : Color aSourceColors[2];
1439 [ + + ]: 378 : Color aDestColors[2];
1440 : :
1441 : 126 : aSourceColors[0] = Color( COL_WHITE );
1442 : 126 : aSourceColors[1] = Color( COL_BLACK );
1443 : :
1444 : 126 : aDestColors[0] = rStyles.GetFieldColor();
1445 : 126 : aDestColors[1] = rStyles.GetFieldTextColor();
1446 : :
1447 [ + - ]: 126 : aBitmap.Replace ( aSourceColors, aDestColors, 2 );
1448 [ + - ]: 126 : Image aSolidLine ( aBitmap );
1449 [ + - ][ + - ]: 126 : InsertEntry( String( ResId( RID_SVXSTR_SOLID, rMgr ) ), aSolidLine );
[ + - ][ + - ]
[ + - ]
1450 : 126 : }
1451 : :
1452 : : /************************************************************************/
1453 : :
1454 : 0 : void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp )
1455 : : {
1456 [ # # ]: 0 : if( pBmp )
1457 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp );
1458 : : else
1459 : 0 : InsertEntry( pEntry->GetName() );
1460 : 0 : }
1461 : :
1462 : : /************************************************************************/
1463 : :
1464 : 0 : void LineLB::Modify( XDashEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp )
1465 : : {
1466 : 0 : RemoveEntry( nPos );
1467 : :
1468 [ # # ]: 0 : if( pBmp )
1469 [ # # ]: 0 : InsertEntry( pEntry->GetName(), *pBmp, nPos );
1470 : : else
1471 : 0 : InsertEntry( pEntry->GetName(), nPos );
1472 : 0 : }
1473 : :
1474 : : // Fills the listbox (provisional) with strings
1475 : :
1476 : 0 : void LineEndLB::Fill( const XLineEndListRef &pList, sal_Bool bStart )
1477 : : {
1478 [ # # ]: 0 : long nCount = pList->Count();
1479 : : XLineEndEntry* pEntry;
1480 [ # # ]: 0 : VirtualDevice aVD;
1481 [ # # ]: 0 : SetUpdateMode( sal_False );
1482 : :
1483 [ # # ]: 0 : for( long i = 0; i < nCount; i++ )
1484 : : {
1485 [ # # ]: 0 : pEntry = pList->GetLineEnd( i );
1486 [ # # ]: 0 : Bitmap* pBitmap = pList->CreateBitmapForUI( i );
1487 [ # # ]: 0 : if( pBitmap )
1488 : : {
1489 [ # # ]: 0 : Size aBmpSize( pBitmap->GetSizePixel() );
1490 [ # # ]: 0 : aVD.SetOutputSizePixel( aBmpSize, sal_False );
1491 [ # # ]: 0 : aVD.DrawBitmap( Point(), *pBitmap );
1492 : 0 : InsertEntry( pEntry->GetName(),
1493 : 0 : aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1494 [ # # ][ # # ]: 0 : Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
[ # # # # ]
[ # # ][ # # ]
1495 : :
1496 [ # # ][ # # ]: 0 : delete pBitmap;
1497 : : }
1498 : : else
1499 [ # # ]: 0 : InsertEntry( pEntry->GetName() );
1500 : : }
1501 [ # # ][ # # ]: 0 : SetUpdateMode( sal_True );
1502 : 0 : }
1503 : :
1504 : : /************************************************************************/
1505 : :
1506 : 0 : void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp,
1507 : : sal_Bool bStart )
1508 : : {
1509 [ # # ]: 0 : if( pBmp )
1510 : : {
1511 [ # # ]: 0 : VirtualDevice aVD;
1512 [ # # ]: 0 : Size aBmpSize( pBmp->GetSizePixel() );
1513 : :
1514 [ # # ]: 0 : aVD.SetOutputSizePixel( aBmpSize, sal_False );
1515 [ # # ]: 0 : aVD.DrawBitmap( Point(), *pBmp );
1516 : 0 : InsertEntry( pEntry->GetName(),
1517 : 0 : aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1518 [ # # ][ # # ]: 0 : Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
[ # # # # ]
[ # # ][ # # ]
[ # # ]
1519 : : }
1520 : : else
1521 : 0 : InsertEntry( pEntry->GetName() );
1522 : 0 : }
1523 : :
1524 : : /************************************************************************/
1525 : :
1526 : 0 : void LineEndLB::Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp,
1527 : : sal_Bool bStart )
1528 : : {
1529 : 0 : RemoveEntry( nPos );
1530 : :
1531 [ # # ]: 0 : if( pBmp )
1532 : : {
1533 [ # # ]: 0 : VirtualDevice aVD;
1534 [ # # ]: 0 : Size aBmpSize( pBmp->GetSizePixel() );
1535 : :
1536 [ # # ]: 0 : aVD.SetOutputSizePixel( aBmpSize, sal_False );
1537 [ # # ]: 0 : aVD.DrawBitmap( Point(), *pBmp );
1538 : 0 : InsertEntry( pEntry->GetName(),
1539 : 0 : aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1540 [ # # ][ # # ]: 0 : Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
[ # # # # ]
[ # # ][ # # ]
[ # # ]
1541 : : }
1542 : : else
1543 : 0 : InsertEntry( pEntry->GetName(), nPos );
1544 : 0 : }
1545 : :
1546 : : //////////////////////////////////////////////////////////////////////////////
1547 : :
1548 : 0 : void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
1549 : : {
1550 : 0 : const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1551 : :
1552 [ # # ]: 0 : if(bForeground)
1553 : : {
1554 [ # # ]: 0 : svtools::ColorConfig aColorConfig;
1555 [ # # ]: 0 : Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
1556 : :
1557 [ # # ][ # # ]: 0 : if(IsControlForeground())
1558 : : {
1559 [ # # ]: 0 : aTextColor = GetControlForeground();
1560 : : }
1561 : :
1562 [ # # ][ # # ]: 0 : getBufferDevice().SetTextColor(aTextColor);
1563 : : }
1564 : :
1565 [ # # ]: 0 : if(bBackground)
1566 : : {
1567 [ # # ]: 0 : if(IsControlBackground())
1568 : : {
1569 [ # # ][ # # ]: 0 : getBufferDevice().SetBackground(GetControlBackground());
[ # # ]
1570 : : }
1571 : : else
1572 : : {
1573 [ # # ]: 0 : getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
1574 : : }
1575 : : }
1576 : :
1577 : : // do not paint background self, it gets painted buffered
1578 : 0 : SetControlBackground();
1579 : 0 : SetBackground();
1580 : :
1581 : 0 : Invalidate();
1582 : 0 : }
1583 : :
1584 : 0 : SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
1585 : : : Control( pParent, rResId ),
1586 : 0 : mpModel( new SdrModel() ),
1587 [ # # ][ # # ]: 0 : mpBufferDevice( new VirtualDevice(*this) )
[ # # ][ # # ]
1588 : : {
1589 : : // Draw the control's border as a flat thin black line.
1590 [ # # ]: 0 : SetBorderStyle(WINDOW_BORDER_MONO);
1591 [ # # ][ # # ]: 0 : SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
1592 [ # # ][ # # ]: 0 : SetMapMode(MAP_100TH_MM);
[ # # ]
1593 : :
1594 : : // init model
1595 [ # # ]: 0 : mpModel->GetItemPool().FreezeIdRanges();
1596 : 0 : }
1597 : :
1598 : 0 : SvxPreviewBase::~SvxPreviewBase()
1599 : : {
1600 [ # # ][ # # ]: 0 : delete mpModel;
1601 [ # # ][ # # ]: 0 : delete mpBufferDevice;
1602 [ # # ]: 0 : }
1603 : :
1604 : 0 : void SvxPreviewBase::LocalPrePaint()
1605 : : {
1606 : : // init BufferDevice
1607 [ # # ]: 0 : if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
1608 : : {
1609 : 0 : mpBufferDevice->SetDrawMode(GetDrawMode());
1610 : 0 : mpBufferDevice->SetSettings(GetSettings());
1611 : 0 : mpBufferDevice->SetAntialiasing(GetAntialiasing());
1612 [ # # ]: 0 : mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
1613 : 0 : mpBufferDevice->SetMapMode(GetMapMode());
1614 : : }
1615 : :
1616 : 0 : mpBufferDevice->Erase();
1617 : 0 : }
1618 : :
1619 : 0 : void SvxPreviewBase::LocalPostPaint()
1620 : : {
1621 : : // copy to front (in pixel mode)
1622 : 0 : const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
1623 : 0 : const bool bWasEnabledDst(IsMapModeEnabled());
1624 : 0 : const Point aEmptyPoint;
1625 : :
1626 [ # # ]: 0 : mpBufferDevice->EnableMapMode(false);
1627 [ # # ]: 0 : EnableMapMode(false);
1628 : :
1629 : : DrawOutDev(
1630 : 0 : aEmptyPoint, GetOutputSizePixel(),
1631 : 0 : aEmptyPoint, GetOutputSizePixel(),
1632 [ # # ]: 0 : *mpBufferDevice);
1633 : :
1634 [ # # ]: 0 : mpBufferDevice->EnableMapMode(bWasEnabledSrc);
1635 [ # # ]: 0 : EnableMapMode(bWasEnabledDst);
1636 : 0 : }
1637 : :
1638 : 0 : void SvxPreviewBase::StateChanged(StateChangedType nType)
1639 : : {
1640 : 0 : Control::StateChanged(nType);
1641 : :
1642 [ # # ]: 0 : if(STATE_CHANGE_CONTROLFOREGROUND == nType)
1643 : : {
1644 : 0 : InitSettings(true, false);
1645 : : }
1646 [ # # ]: 0 : else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
1647 : : {
1648 : 0 : InitSettings(false, true);
1649 : : }
1650 : 0 : }
1651 : :
1652 : 0 : void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
1653 : : {
1654 [ # # ]: 0 : SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
1655 : :
1656 [ # # ][ # # ]: 0 : if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
[ # # ]
1657 : : {
1658 : 0 : InitSettings(true, true);
1659 : : }
1660 : : else
1661 : : {
1662 : 0 : Control::DataChanged(rDCEvt);
1663 : : }
1664 : 0 : }
1665 : :
1666 : 0 : SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
1667 : : : SvxPreviewBase( pParent, rResId ),
1668 : : mpLineObjA( 0L ),
1669 : : mpLineObjB( 0L ),
1670 : : mpLineObjC( 0L ),
1671 : : mpGraphic( 0L ),
1672 : 0 : mbWithSymbol( sal_False )
1673 : : {
1674 [ # # ]: 0 : const Size aOutputSize(GetOutputSize());
1675 [ # # ]: 0 : InitSettings( sal_True, sal_True );
1676 : :
1677 : 0 : const sal_Int32 nDistance(500L);
1678 : 0 : const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
1679 : :
1680 : : // create DrawObectA
1681 : 0 : const sal_Int32 aYPosA(aOutputSize.Height() / 2);
1682 : 0 : const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
1683 : 0 : const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
1684 [ # # ]: 0 : basegfx::B2DPolygon aPolygonA;
1685 [ # # ]: 0 : aPolygonA.append(aPointA1);
1686 [ # # ]: 0 : aPolygonA.append(aPointA2);
1687 [ # # ][ # # ]: 0 : mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
[ # # ][ # # ]
1688 [ # # ]: 0 : mpLineObjA->SetModel(&getModel());
1689 : :
1690 : : // create DrawObectB
1691 : 0 : const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
1692 : 0 : const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
1693 : 0 : const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
1694 : 0 : const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
1695 : 0 : const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
1696 [ # # ]: 0 : basegfx::B2DPolygon aPolygonB;
1697 [ # # ]: 0 : aPolygonB.append(aPointB1);
1698 [ # # ]: 0 : aPolygonB.append(aPointB2);
1699 [ # # ]: 0 : aPolygonB.append(aPointB3);
1700 [ # # ][ # # ]: 0 : mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
[ # # ][ # # ]
1701 [ # # ]: 0 : mpLineObjB->SetModel(&getModel());
1702 : :
1703 : : // create DrawObectC
1704 : 0 : const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
1705 : 0 : const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
1706 : 0 : const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
1707 [ # # ]: 0 : basegfx::B2DPolygon aPolygonC;
1708 [ # # ]: 0 : aPolygonC.append(aPointC1);
1709 [ # # ]: 0 : aPolygonC.append(aPointC2);
1710 [ # # ]: 0 : aPolygonC.append(aPointC3);
1711 [ # # ][ # # ]: 0 : mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
[ # # ][ # # ]
1712 [ # # ][ # # ]: 0 : mpLineObjC->SetModel(&getModel());
[ # # ][ # # ]
1713 : 0 : }
1714 : :
1715 : 0 : SvxXLinePreview::~SvxXLinePreview()
1716 : : {
1717 [ # # ]: 0 : SdrObject::Free( mpLineObjA );
1718 [ # # ]: 0 : SdrObject::Free( mpLineObjB );
1719 [ # # ]: 0 : SdrObject::Free( mpLineObjC );
1720 [ # # ]: 0 : }
1721 : :
1722 : : // -----------------------------------------------------------------------
1723 : :
1724 : 0 : void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
1725 : : {
1726 : 0 : mpGraphic = p;
1727 : 0 : maSymbolSize = s;
1728 : 0 : }
1729 : :
1730 : : // -----------------------------------------------------------------------
1731 : :
1732 : 0 : void SvxXLinePreview::ResizeSymbol(const Size& s)
1733 : : {
1734 [ # # ]: 0 : if ( s != maSymbolSize )
1735 : : {
1736 : 0 : maSymbolSize = s;
1737 : 0 : Invalidate();
1738 : : }
1739 : 0 : }
1740 : :
1741 : : // -----------------------------------------------------------------------
1742 : :
1743 : 0 : void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
1744 : : {
1745 : : // Set ItemSet at objects
1746 [ # # ]: 0 : mpLineObjA->SetMergedItemSet(rItemSet);
1747 : :
1748 : : // At line joints, do not use arrows
1749 [ # # ]: 0 : SfxItemSet aTempSet(rItemSet);
1750 [ # # ]: 0 : aTempSet.ClearItem(XATTR_LINESTART);
1751 [ # # ]: 0 : aTempSet.ClearItem(XATTR_LINEEND);
1752 : :
1753 [ # # ]: 0 : mpLineObjB->SetMergedItemSet(aTempSet);
1754 [ # # ][ # # ]: 0 : mpLineObjC->SetMergedItemSet(aTempSet);
1755 : 0 : }
1756 : :
1757 : : // -----------------------------------------------------------------------
1758 : :
1759 : 0 : void SvxXLinePreview::Paint( const Rectangle& )
1760 : : {
1761 [ # # ]: 0 : LocalPrePaint();
1762 : :
1763 : : // paint objects to buffer device
1764 [ # # ]: 0 : sdr::contact::SdrObjectVector aObjectVector;
1765 [ # # ]: 0 : aObjectVector.push_back(mpLineObjA);
1766 [ # # ]: 0 : aObjectVector.push_back(mpLineObjB);
1767 [ # # ]: 0 : aObjectVector.push_back(mpLineObjC);
1768 : :
1769 [ # # ]: 0 : sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
1770 [ # # ]: 0 : sdr::contact::DisplayInfo aDisplayInfo;
1771 : :
1772 : : // do processing
1773 [ # # ]: 0 : aPainter.ProcessDisplay(aDisplayInfo);
1774 : :
1775 [ # # ][ # # ]: 0 : if ( mbWithSymbol && mpGraphic )
1776 : : {
1777 [ # # ]: 0 : const Size aOutputSize(GetOutputSize());
1778 : 0 : Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
1779 : 0 : aPos.X() -= maSymbolSize.Width() / 2;
1780 : 0 : aPos.Y() -= maSymbolSize.Height() / 2;
1781 [ # # ]: 0 : mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
1782 : : }
1783 : :
1784 [ # # ][ # # ]: 0 : LocalPostPaint();
[ # # ]
1785 : 0 : }
1786 : :
1787 : 0 : SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
1788 : : : SvxPreviewBase( pParent, rResId ),
1789 : 0 : mpRectangleObject(0)
1790 : : {
1791 [ # # ]: 0 : InitSettings(true, true);
1792 : :
1793 : : // create RectangleObject
1794 [ # # ][ # # ]: 0 : const Rectangle aObjectSize(Point(), GetOutputSize());
1795 [ # # ][ # # ]: 0 : mpRectangleObject = new SdrRectObj(aObjectSize);
1796 [ # # ]: 0 : mpRectangleObject->SetModel(&getModel());
1797 : 0 : }
1798 : :
1799 : 0 : SvxXRectPreview::~SvxXRectPreview()
1800 : : {
1801 [ # # ]: 0 : SdrObject::Free(mpRectangleObject);
1802 [ # # ]: 0 : }
1803 : :
1804 : 0 : void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
1805 : : {
1806 : 0 : mpRectangleObject->SetMergedItemSet(rItemSet, true);
1807 [ # # ]: 0 : mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
1808 : 0 : }
1809 : :
1810 : 0 : void SvxXRectPreview::Paint( const Rectangle& )
1811 : : {
1812 [ # # ]: 0 : LocalPrePaint();
1813 : :
1814 [ # # ]: 0 : sdr::contact::SdrObjectVector aObjectVector;
1815 : :
1816 [ # # ]: 0 : aObjectVector.push_back(mpRectangleObject);
1817 : :
1818 [ # # ]: 0 : sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
1819 [ # # ]: 0 : sdr::contact::DisplayInfo aDisplayInfo;
1820 : :
1821 [ # # ]: 0 : aPainter.ProcessDisplay(aDisplayInfo);
1822 : :
1823 [ # # ][ # # ]: 0 : LocalPostPaint();
[ # # ]
1824 : 0 : }
1825 : :
1826 : 0 : SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
1827 : : : SvxPreviewBase( pParent, rResId ),
1828 : : mpRectangleObject(0),
1829 : 0 : mpRectangleShadow(0)
1830 : : {
1831 [ # # ]: 0 : InitSettings(true, true);
1832 : :
1833 : : // prepare size
1834 [ # # ]: 0 : Size aSize = GetOutputSize();
1835 : 0 : aSize.Width() = aSize.Width() / 3;
1836 : 0 : aSize.Height() = aSize.Height() / 3;
1837 : :
1838 : : // create RectangleObject
1839 [ # # ]: 0 : const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
1840 [ # # ][ # # ]: 0 : mpRectangleObject = new SdrRectObj(aObjectSize);
1841 [ # # ]: 0 : mpRectangleObject->SetModel(&getModel());
1842 : :
1843 : : // create ShadowObject
1844 [ # # ]: 0 : const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
1845 [ # # ][ # # ]: 0 : mpRectangleShadow = new SdrRectObj(aShadowSize);
1846 [ # # ]: 0 : mpRectangleShadow->SetModel(&getModel());
1847 : 0 : }
1848 : :
1849 : 0 : SvxXShadowPreview::~SvxXShadowPreview()
1850 : : {
1851 [ # # ]: 0 : SdrObject::Free(mpRectangleObject);
1852 [ # # ]: 0 : SdrObject::Free(mpRectangleShadow);
1853 [ # # ]: 0 : }
1854 : :
1855 : 0 : void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
1856 : : {
1857 : 0 : mpRectangleObject->SetMergedItemSet(rItemSet, true);
1858 [ # # ]: 0 : mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
1859 : 0 : }
1860 : :
1861 : 0 : void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
1862 : : {
1863 : 0 : mpRectangleShadow->SetMergedItemSet(rItemSet, true);
1864 [ # # ]: 0 : mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
1865 : 0 : }
1866 : :
1867 : 0 : void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
1868 : : {
1869 [ # # ]: 0 : Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
1870 [ # # ]: 0 : aObjectPosition.Move(rPos.X(), rPos.Y());
1871 [ # # ]: 0 : mpRectangleShadow->SetSnapRect(aObjectPosition);
1872 : 0 : }
1873 : :
1874 : 0 : void SvxXShadowPreview::Paint( const Rectangle& )
1875 : : {
1876 [ # # ]: 0 : LocalPrePaint();
1877 : :
1878 [ # # ]: 0 : sdr::contact::SdrObjectVector aObjectVector;
1879 : :
1880 [ # # ]: 0 : aObjectVector.push_back(mpRectangleShadow);
1881 [ # # ]: 0 : aObjectVector.push_back(mpRectangleObject);
1882 : :
1883 [ # # ]: 0 : sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
1884 [ # # ]: 0 : sdr::contact::DisplayInfo aDisplayInfo;
1885 : :
1886 [ # # ]: 0 : aPainter.ProcessDisplay(aDisplayInfo);
1887 : :
1888 [ # # ][ # # ]: 0 : LocalPostPaint();
[ # # ]
1889 : 0 : }
1890 : :
1891 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|