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