LibreOffice Module svx (master)  1
dlgctrl.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <vcl/svapp.hxx>
21 #include <vcl/settings.hxx>
22 #include <vcl/virdev.hxx>
23 #include <vcl/event.hxx>
24 #include <sfx2/dialoghelper.hxx>
25 #include <svx/xlineit0.hxx>
26 #include <svx/xtable.hxx>
27 #include <svx/xpool.hxx>
28 #include <svx/strings.hrc>
29 #include <bitmaps.hlst>
30 #include <svx/dlgctrl.hxx>
31 #include <svx/dialmgr.hxx>
32 #include <tools/debug.hxx>
33 #include <tools/poly.hxx>
34 #include <vcl/region.hxx>
35 #include <vcl/gradient.hxx>
36 #include <vcl/hatch.hxx>
37 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
38 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41 #include <svtools/colorcfg.hxx>
43 #include <com/sun/star/lang/XUnoTunnel.hpp>
46 #include <svx/svdorect.hxx>
47 #include <svx/svdmodel.hxx>
48 #include <svx/svdopath.hxx>
51 #include <vcl/bitmapaccess.hxx>
52 #include <vcl/BitmapTools.hxx>
53 #include <svx/xbtmpit.hxx>
54 
55 #define OUTPUT_DRAWMODE_COLOR (DrawModeFlags::Default)
56 #define OUTPUT_DRAWMODE_CONTRAST (DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient)
57 
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star::accessibility;
62 
63 // Control for display and selection of the corner points and
64 // mid point of an object
65 
67 {
68  if( !pBitmap )
70 
71  return *pBitmap;
72 }
73 
74 SvxRectCtl::SvxRectCtl(SvxTabPage* pPage, RectPoint eRpt, sal_uInt16 nBorder)
75  : m_pPage(pPage)
76  , nBorderWidth(Application::GetDefaultDevice()->LogicToPixel(Size(nBorder, 0), MapMode(MapUnit::Map100thMM)).Width())
77  , eRP(eRpt)
78  , eDefRP(eRpt)
79  , m_nState(CTL_STATE::NONE)
80  , mbCompleteDisable(false)
81 {
82 }
83 
85 {
86  CustomWidgetController::SetDrawingArea(pDrawingArea);
87  Size aSize(pDrawingArea->get_approximate_digit_width() * 25,
88  pDrawingArea->get_text_height() * 5);
89  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
90  Resize_Impl(aSize);
91 }
92 
93 void SvxRectCtl::SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder)
94 {
95  nBorderWidth = Application::GetDefaultDevice()->LogicToPixel(Size(nBorder, 0), MapMode(MapUnit::Map100thMM)).Width();
96  eDefRP = eRpt;
97  Resize();
98 }
99 
101 {
102  pBitmap.reset();
103  pAccContext.clear();
104 }
105 
107 {
109 }
110 
111 void SvxRectCtl::Resize_Impl(const Size &rSize)
112 {
113  aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
114  aPtMT = Point( rSize.Width() / 2, 0 + nBorderWidth );
115  aPtRT = Point( rSize.Width() - nBorderWidth, 0 + nBorderWidth );
116 
117  aPtLM = Point( 0 + nBorderWidth, rSize.Height() / 2 );
118  aPtMM = Point( rSize.Width() / 2, rSize.Height() / 2 );
119  aPtRM = Point( rSize.Width() - nBorderWidth, rSize.Height() / 2 );
120 
121  aPtLB = Point( 0 + nBorderWidth, rSize.Height() - nBorderWidth );
122  aPtMB = Point( rSize.Width() / 2, rSize.Height() - nBorderWidth );
123  aPtRB = Point( rSize.Width() - nBorderWidth, rSize.Height() - nBorderWidth );
124 
125  Reset();
126  StyleUpdated();
127 }
128 
130 {
131  pBitmap.reset();
132 
134  svtools::ColorConfig aColorConfig;
135 
136  pBitmap.reset(new BitmapEx(RID_SVXCTRL_RECTBTNS));
137 
138  // set bitmap-colors
139  Color aColorAry1[7];
140  Color aColorAry2[7];
141  aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
142  aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
143  aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
144  aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
145  aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
146  aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
147  aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
148  aColorAry2[0] = rStyles.GetDialogColor(); // background
149  aColorAry2[1] = rStyles.GetWindowColor();
150  aColorAry2[2] = rStyles.GetLightColor();
151  aColorAry2[3] = rStyles.GetShadowColor();
152  aColorAry2[4] = rStyles.GetDarkShadowColor();
153  aColorAry2[5] = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
154  aColorAry2[6] = rStyles.GetDialogColor();
155 
156 #ifdef DBG_UTIL
157  static bool bModify = false;
158  bool& rModify = bModify;
159  if( rModify )
160  {
161  static int n = 0;
162  static sal_uInt8 r = 0xFF;
163  static sal_uInt8 g = 0x00;
164  static sal_uInt8 b = 0xFF;
165  int& rn = n;
166  sal_uInt8& rr = r;
167  sal_uInt8& rg = g;
168  sal_uInt8& rb = b;
169  aColorAry2[ rn ] = Color( rr, rg, rb );
170  }
171 #endif
172 
173  pBitmap->Replace( aColorAry1, aColorAry2, 7 );
174 }
175 
177 {
178  pBitmap.reset(); // forces new creating of bitmap
179  CustomWidgetController::StyleUpdated();
180 }
181 
183 {
184  svtools::ColorConfig aColorConfig;
185  Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
186  rRenderContext.SetTextColor(aTextColor);
187  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
188  rRenderContext.SetBackground(rStyleSettings.GetWindowColor());
189 }
190 
191 // The clicked rectangle (3 x 3) is determined and the parent (dialog)
192 // is notified that the item was changed
194 {
195  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
196  if(!IsCompletelyDisabled())
197  {
200  SetActualRP( eRP );
201 
202  if (m_pPage)
204  }
205  return true;
206 }
207 
208 bool SvxRectCtl::KeyInput(const KeyEvent& rKeyEvt)
209 {
210  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
211  if (IsCompletelyDisabled())
212  return false;
213 
214  RectPoint eNewRP = eRP;
215 
216  switch( rKeyEvt.GetKeyCode().GetCode() )
217  {
218  case KEY_DOWN:
219  {
220  if( !(m_nState & CTL_STATE::NOVERT) )
221  switch( eNewRP )
222  {
223  case RectPoint::LT: eNewRP = RectPoint::LM; break;
224  case RectPoint::MT: eNewRP = RectPoint::MM; break;
225  case RectPoint::RT: eNewRP = RectPoint::RM; break;
226  case RectPoint::LM: eNewRP = RectPoint::LB; break;
227  case RectPoint::MM: eNewRP = RectPoint::MB; break;
228  case RectPoint::RM: eNewRP = RectPoint::RB; break;
229  default: ; //prevent warning
230  }
231  }
232  break;
233  case KEY_UP:
234  {
235  if( !(m_nState & CTL_STATE::NOVERT) )
236  switch( eNewRP )
237  {
238  case RectPoint::LM: eNewRP = RectPoint::LT; break;
239  case RectPoint::MM: eNewRP = RectPoint::MT; break;
240  case RectPoint::RM: eNewRP = RectPoint::RT; break;
241  case RectPoint::LB: eNewRP = RectPoint::LM; break;
242  case RectPoint::MB: eNewRP = RectPoint::MM; break;
243  case RectPoint::RB: eNewRP = RectPoint::RM; break;
244  default: ; //prevent warning
245  }
246  }
247  break;
248  case KEY_LEFT:
249  {
250  if( !(m_nState & CTL_STATE::NOHORZ) )
251  switch( eNewRP )
252  {
253  case RectPoint::MT: eNewRP = RectPoint::LT; break;
254  case RectPoint::RT: eNewRP = RectPoint::MT; break;
255  case RectPoint::MM: eNewRP = RectPoint::LM; break;
256  case RectPoint::RM: eNewRP = RectPoint::MM; break;
257  case RectPoint::MB: eNewRP = RectPoint::LB; break;
258  case RectPoint::RB: eNewRP = RectPoint::MB; break;
259  default: ; //prevent warning
260  }
261  }
262  break;
263  case KEY_RIGHT:
264  {
265  if( !(m_nState & CTL_STATE::NOHORZ) )
266  switch( eNewRP )
267  {
268  case RectPoint::LT: eNewRP = RectPoint::MT; break;
269  case RectPoint::MT: eNewRP = RectPoint::RT; break;
270  case RectPoint::LM: eNewRP = RectPoint::MM; break;
271  case RectPoint::MM: eNewRP = RectPoint::RM; break;
272  case RectPoint::LB: eNewRP = RectPoint::MB; break;
273  case RectPoint::MB: eNewRP = RectPoint::RB; break;
274  default: ; //prevent warning
275  }
276  }
277  break;
278  default:
279  return false;
280  }
281  if( eNewRP != eRP )
282  {
283  SetActualRP( eNewRP );
284 
285  if (m_pPage)
287  }
288  return true;
289 }
290 
291 // the control (rectangle with 9 circles)
293 {
294  InitSettings(rRenderContext);
295 
296  Point aPtDiff(1, 1);
297 
299 
300  rRenderContext.SetLineColor(rStyles.GetDialogColor());
301  rRenderContext.SetFillColor(rStyles.GetDialogColor());
302  rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize()));
303 
304  if (IsEnabled())
305  rRenderContext.SetLineColor(rStyles.GetLabelTextColor());
306  else
307  rRenderContext.SetLineColor(rStyles.GetShadowColor());
308 
309  rRenderContext.SetFillColor();
310 
311  if (!IsEnabled())
312  {
313  Color aOldCol = rRenderContext.GetLineColor();
314  rRenderContext.SetLineColor(rStyles.GetLightColor());
315  rRenderContext.DrawRect(tools::Rectangle(aPtLT + aPtDiff, aPtRB + aPtDiff));
316  rRenderContext.SetLineColor(aOldCol);
317  }
318  rRenderContext.DrawRect(tools::Rectangle(aPtLT, aPtRB));
319 
320  rRenderContext.SetFillColor(rRenderContext.GetBackground().GetColor());
321 
322  Size aBtnSize(11, 11);
323  Size aDstBtnSize(aBtnSize);
324  Point aToCenter(aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
325  Point aBtnPnt1(IsEnabled() ? 0 : 22, 0);
326  Point aBtnPnt2(11, 0);
327  Point aBtnPnt3(22, 0);
328 
329  bool bNoHorz = bool(m_nState & CTL_STATE::NOHORZ);
330  bool bNoVert = bool(m_nState & CTL_STATE::NOVERT);
331 
332  BitmapEx& rBitmap = GetRectBitmap();
333 
334  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
335  if (IsCompletelyDisabled())
336  {
337  rRenderContext.DrawBitmapEx(aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
338  rRenderContext.DrawBitmapEx(aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
339  rRenderContext.DrawBitmapEx(aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
340  rRenderContext.DrawBitmapEx(aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
341  rRenderContext.DrawBitmapEx(aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
342  rRenderContext.DrawBitmapEx(aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
343  rRenderContext.DrawBitmapEx(aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
344  rRenderContext.DrawBitmapEx(aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
345  rRenderContext.DrawBitmapEx(aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
346  }
347  else
348  {
349  rRenderContext.DrawBitmapEx(aPtLT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
350  rRenderContext.DrawBitmapEx(aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
351  rRenderContext.DrawBitmapEx(aPtRT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
352  rRenderContext.DrawBitmapEx(aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
353 
354  // Center for rectangle and line
355  rRenderContext.DrawBitmapEx(aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap);
356 
357  rRenderContext.DrawBitmapEx(aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
358  rRenderContext.DrawBitmapEx(aPtLB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
359  rRenderContext.DrawBitmapEx(aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
360  rRenderContext.DrawBitmapEx(aPtRB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
361  }
362 
363  // draw active button, avoid center pos for angle
364  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
365  if (!IsCompletelyDisabled())
366  {
367  if (IsEnabled())
368  {
369  Point aCenterPt(aPtNew);
370  aCenterPt -= aToCenter;
371 
372  rRenderContext.DrawBitmapEx(aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap);
373  }
374  }
375 }
376 
378 {
379  tools::Rectangle aRet;
380  if (HasFocus())
381  aRet = CalculateFocusRectangle();
382  return aRet;
383 }
384 
385 // Convert RectPoint Point
386 
388 {
389  switch( _eRP )
390  {
391  case RectPoint::LT: return aPtLT;
392  case RectPoint::MT: return aPtMT;
393  case RectPoint::RT: return aPtRT;
394  case RectPoint::LM: return aPtLM;
395  case RectPoint::MM: return aPtMM;
396  case RectPoint::RM: return aPtRM;
397  case RectPoint::LB: return aPtLB;
398  case RectPoint::MB: return aPtMB;
399  case RectPoint::RB: return aPtRB;
400  }
401  return aPtMM; // default
402 }
403 
405 {
406  Point aPtLast = aPtNew;
407  aPtNew = GetPointFromRP( eNewRP );
408 
410  aPtNew.setX( aPtMM.X() );
411 
413  aPtNew.setY( aPtMM.Y() );
414 
415  // fdo#74751 this fix reverse base point on RTL UI.
416  bool bRTL = AllSettings::GetLayoutRTL();
417  eNewRP = GetRPFromPoint( aPtNew, bRTL );
418 
419  eDefRP = eNewRP;
420  eRP = eNewRP;
421 
422  return aPtLast;
423 }
424 
426 {
427  Invalidate();
428 
429  // Send accessibility event.
430  if (pAccContext.is())
431  {
432  pAccContext->FireChildFocus(GetActualRP());
433  }
434 }
435 
437 {
438  Invalidate();
439 }
440 
442 {
443  Point aPt = rPt;
444  long x;
445  long y;
446 
447  Size aSize(GetOutputSizePixel());
448 
449  if( !( m_nState & CTL_STATE::NOHORZ ) )
450  {
451  if( aPt.X() < aSize.Width() / 3 )
452  x = aPtLT.X();
453  else if( aPt.X() < aSize.Width() * 2 / 3 )
454  x = aPtMM.X();
455  else
456  x = aPtRB.X();
457  }
458  else
459  x = aPtMM.X();
460 
461  if( !( m_nState & CTL_STATE::NOVERT ) )
462  {
463  if( aPt.Y() < aSize.Height() / 3 )
464  y = aPtLT.Y();
465  else if( aPt.Y() < aSize.Height() * 2 / 3 )
466  y = aPtMM.Y();
467  else
468  y = aPtRB.Y();
469  }
470  else
471  y = aPtMM.Y();
472 
473  return Point( x, y );
474 }
475 
476 
477 // Converts Point in RectPoint
478 
480 {
481  RectPoint rPoint = RectPoint::MM; // default
482 
483  if (aPt == aPtLT) rPoint = bRTL ? RectPoint::RT : RectPoint::LT;
484  else if( aPt == aPtMT) rPoint = RectPoint::MT;
485  else if( aPt == aPtRT) rPoint = bRTL ? RectPoint::LT : RectPoint::RT;
486  else if( aPt == aPtLM) rPoint = bRTL ? RectPoint::RM : RectPoint::LM;
487  else if( aPt == aPtRM) rPoint = bRTL ? RectPoint::LM : RectPoint::RM;
488  else if( aPt == aPtLB) rPoint = bRTL ? RectPoint::RB : RectPoint::LB;
489  else if( aPt == aPtMB) rPoint = RectPoint::MB;
490  else if( aPt == aPtRB) rPoint = bRTL ? RectPoint::LB : RectPoint::RB;
491 
492  return rPoint;
493 }
494 
495 // Resets to the original state of the control
496 
498 {
500  eRP = eDefRP;
501  Invalidate();
502 }
503 
504 // Returns the currently selected RectPoint
505 
506 
508 {
510 
511  Invalidate();
512 
513  // notify accessibility object about change
514  if (pAccContext.is())
515  pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
516 }
517 
519 {
520  m_nState = nState;
521 
522  Point aPtLast( GetPointFromRP( eRP ) );
523  Point _aPtNew( aPtLast );
524 
526  _aPtNew.setX( aPtMM.X() );
527 
529  _aPtNew.setY( aPtMM.Y() );
530 
531  eRP = GetRPFromPoint( _aPtNew );
532  Invalidate();
533 
534  if (m_pPage)
536 }
537 
539 {
540  Size aDstBtnSize(15, 15);
541  return tools::Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
542 }
543 
545 {
546  tools::Rectangle aRet;
547  RectPoint eOldRectPoint = GetActualRP();
548 
549  if( eOldRectPoint == eRectPoint )
550  aRet = CalculateFocusRectangle();
551  else
552  {
553  SvxRectCtl* pThis = const_cast<SvxRectCtl*>(this);
554 
555  pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
556  aRet = CalculateFocusRectangle();
557 
558  pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
559  }
560 
561  return aRet;
562 }
563 
564 Reference< XAccessible > SvxRectCtl::CreateAccessible()
565 {
567  return pAccContext.get();
568 }
569 
570 RectPoint SvxRectCtl::GetApproxRPFromPixPt( const css::awt::Point& r ) const
571 {
572  return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
573 }
574 
575 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
577 {
578  mbCompleteDisable = bNew;
579  Invalidate();
580 }
581 
582 // Control for editing bitmaps
583 
584 css::uno::Reference< css::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
585 {
586  if (!m_xAccess.is())
587  m_xAccess = new SvxPixelCtlAccessible(this);
588  return m_xAccess.get();
589 }
590 
591 long SvxPixelCtl::PointToIndex(const Point &aPt) const
592 {
593  long nX = aPt.X() * nLines / aRectSize.Width();
594  long nY = aPt.Y() * nLines / aRectSize.Height();
595 
596  return nX + nY * nLines ;
597 }
598 
600 {
601  DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
602 
603  sal_Int32 nXIndex = nIndex % nLines;
604  sal_Int32 nYIndex = nIndex / nLines;
605 
606  Point aPtTl;
607  aPtTl.setY( aRectSize.Height() * nYIndex / nLines + 1 );
608  aPtTl.setX( aRectSize.Width() * nXIndex / nLines + 1 );
609 
610  return aPtTl;
611 }
612 
614 {
615  return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
616 }
617 
619 {
620  sal_Int32 nX = rPt.X() * nLines / aRectSize.Width();
621  sal_Int32 nY = rPt.Y() * nLines / aRectSize.Height();
622 
623  ChangePixel( nX + nY * nLines );
624 
625  //Solution:Set new focus position and repaint
626  aFocusPosition.setX(nX);
627  aFocusPosition.setY(nY);
629 
630  if (m_pPage)
631  m_pPage->PointChanged(GetDrawingArea(), RectPoint::MM ); // RectPoint is dummy
632 
633  return GetFocusPosIndex();
634 
635 }
636 
638  : m_pPage(pPage)
639  , bPaintable(true)
640  , aFocusPosition(0,0)
641 {
642  maPixelData.fill(0);
643 }
644 
646 {
647  CustomWidgetController::Resize();
649 }
650 
652 {
653  CustomWidgetController::SetDrawingArea(pDrawingArea);
654  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 25,
655  pDrawingArea->get_text_height() * 10);
656 }
657 
659 {
660 }
661 
662 // Changes the foreground or Background color
663 
664 void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
665 {
666  if( maPixelData[nPixel] == 0 )
667  maPixelData[nPixel] = 1; // could be extended to more colors
668  else
669  maPixelData[nPixel] = 0;
670 }
671 
672 // The clicked rectangle is identified, to change its color
673 
675 {
676  if (!aRectSize.Width() || !aRectSize.Height())
677  return true;
678 
679  //Grab focus when click in window
680  if (!HasFocus())
681  {
682  GrabFocus();
683  }
684 
685  long nIndex = ShowPosition(rMEvt.GetPosPixel());
686 
687  if(m_xAccess.is())
688  {
689  m_xAccess->NotifyChild(nIndex,true, true);
690  }
691 
692  return true;
693 }
694 
696 {
697  tools::Rectangle aRet;
698  //Draw visual focus when has focus
699  if (HasFocus())
701  return aRet;
702 }
703 
704 // Draws the Control (Rectangle with nine circles)
706 {
707  if (!aRectSize.Width() || !aRectSize.Height())
708  return;
709 
710  sal_uInt16 i, j, nTmp;
711  Point aPtTl, aPtBr;
712 
713  if (bPaintable)
714  {
715  // Draw lines
716  rRenderContext.SetLineColor(Color());
717  for (i = 1; i < nLines; i++)
718  {
719  // horizontal
720  nTmp = static_cast<sal_uInt16>(aRectSize.Height() * i / nLines);
721  rRenderContext.DrawLine(Point(0, nTmp), Point(aRectSize.Width(), nTmp));
722  // vertically
723  nTmp = static_cast<sal_uInt16>( aRectSize.Width() * i / nLines );
724  rRenderContext.DrawLine(Point(nTmp, 0), Point(nTmp, aRectSize.Height()));
725  }
726 
727  //Draw Rectangles (squares)
728  rRenderContext.SetLineColor();
729  sal_uInt16 nLastPixel = maPixelData[0] ? 0 : 1;
730 
731  for (i = 0; i < nLines; i++)
732  {
733  aPtTl.setY( aRectSize.Height() * i / nLines + 1 );
734  aPtBr.setY( aRectSize.Height() * (i + 1) / nLines - 1 );
735 
736  for (j = 0; j < nLines; j++)
737  {
738  aPtTl.setX( aRectSize.Width() * j / nLines + 1 );
739  aPtBr.setX( aRectSize.Width() * (j + 1) / nLines - 1 );
740 
741  if (maPixelData[i * nLines + j] != nLastPixel)
742  {
743  nLastPixel = maPixelData[i * nLines + j];
744  // Change color: 0 -> Background color
745  rRenderContext.SetFillColor(nLastPixel ? aPixelColor : aBackgroundColor);
746  }
747  rRenderContext.DrawRect(tools::Rectangle(aPtTl, aPtBr));
748  }
749  }
750  }
751  else
752  {
753  rRenderContext.SetBackground(Wallpaper(COL_LIGHTGRAY));
754  rRenderContext.SetLineColor(COL_LIGHTRED);
755  rRenderContext.DrawLine(Point(0, 0), Point(aRectSize.Width(), aRectSize.Height()));
756  rRenderContext.DrawLine(Point(0, aRectSize.Height()), Point(aRectSize.Width(), 0));
757  }
758 }
759 
760 //Calculate visual focus rectangle via focus position
762 {
763  long nLeft,nTop,nRight,nBottom;
764  long i,j;
765  i = aPosition.Y();
766  j = aPosition.X();
767  nLeft = aRectSize.Width() * j / nLines + 1;
768  nRight = aRectSize.Width() * (j + 1) / nLines - 1;
769  nTop = aRectSize.Height() * i / nLines + 1;
770  nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
771  return tools::Rectangle(nLeft,nTop,nRight,nBottom);
772 }
773 
774 //Solution:Keyboard function
775 bool SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
776 {
777  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
778  sal_uInt16 nCode = aKeyCode.GetCode();
779  bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
780 
781  if( !bIsMod )
782  {
783  Point aRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
784  aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
785  );
786  Size aRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
787  tools::Rectangle aRepaintRect( aRepaintPoint, aRepaintSize );
788  bool bFocusPosChanged=false;
789  switch(nCode)
790  {
791  case KEY_LEFT:
792  if(aFocusPosition.getX() >= 1)
793  {
795  Invalidate(aRepaintRect);
796  bFocusPosChanged=true;
797  }
798  break;
799  case KEY_RIGHT:
800  if( aFocusPosition.getX() < (nLines - 1) )
801  {
803  Invalidate(aRepaintRect);
804  bFocusPosChanged=true;
805  }
806  break;
807  case KEY_UP:
808  if(aFocusPosition.getY() >= 1)
809  {
811  Invalidate(aRepaintRect);
812  bFocusPosChanged=true;
813  }
814  break;
815  case KEY_DOWN:
816  if( aFocusPosition.getY() < ( nLines - 1 ) )
817  {
819  Invalidate(aRepaintRect);
820  bFocusPosChanged=true;
821  }
822  break;
823  case KEY_SPACE:
824  ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
826  break;
827  default:
828  return CustomWidgetController::KeyInput( rKEvt );
829  }
830  if(m_xAccess.is())
831  {
832  long nIndex = GetFocusPosIndex();
833  switch(nCode)
834  {
835  case KEY_LEFT:
836  case KEY_RIGHT:
837  case KEY_UP:
838  case KEY_DOWN:
839  if (bFocusPosChanged)
840  {
841  m_xAccess->NotifyChild(nIndex,false,false);
842  }
843  break;
844  case KEY_SPACE:
845  m_xAccess->NotifyChild(nIndex,false,true);
846  break;
847  default:
848  break;
849  }
850  }
851  return true;
852  }
853  else
854  {
855  return CustomWidgetController::KeyInput( rKEvt );
856  }
857 }
858 
859 //Draw focus when get focus
861 {
863 
864  if (m_xAccess.is())
865  {
866  m_xAccess->NotifyChild(GetFocusPosIndex(),true,false);
867  }
868 }
869 
871 {
872  Invalidate();
873 }
874 
875 void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx)
876 {
878  {
879  for (sal_uInt16 i = 0; i < nSquares; i++)
880  {
881  Color aColor = rBitmapEx.GetPixelColor(i%8, i/8);
882  maPixelData[i] = (aColor == aBackgroundColor) ? 0 : 1;
883  }
884  }
885 }
886 
887 // Returns a specific pixel
888 
889 sal_uInt8 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) const
890 {
891  return maPixelData[nPixel];
892 }
893 
894 // Resets to the original state of the control
895 
897 {
898  // clear pixel area
899  maPixelData.fill(0);
900  Invalidate();
901 }
902 
904 {
905  SetUpdateMode( false );
906 
907  InsertEntry( SvxResId(RID_SVXSTR_INVISIBLE) );
908  InsertEntry( SvxResId(RID_SVXSTR_COLOR) );
909  InsertEntry( SvxResId(RID_SVXSTR_GRADIENT) );
910  InsertEntry( SvxResId(RID_SVXSTR_HATCH) );
911  InsertEntry( SvxResId(RID_SVXSTR_BITMAP) );
912  InsertEntry( SvxResId(RID_SVXSTR_PATTERN) );
913 
915  SetUpdateMode( true );
916 }
917 
918 SvxLineLB::SvxLineLB(std::unique_ptr<weld::ComboBox> pControl)
919  : m_xControl(std::move(pControl))
920  , mbAddStandardFields(true)
921 {
922 }
923 
925 {
926  if(getAddStandardFields() != bNew)
927  {
928  mbAddStandardFields = bNew;
929  }
930 }
931 
932 // Fills the listbox (provisional) with strings
933 
934 void SvxLineLB::Fill( const XDashListRef &pList )
935 {
936  m_xControl->clear();
937 
938  if( !pList.is() )
939  return;
940 
942 
944  {
945  // entry for 'none'
946  m_xControl->append_text(pList->GetStringForUiNoLine());
947 
948  // entry for solid line
949  const BitmapEx aBitmap = pList->GetBitmapForUISolidLine();
950  const Size aBmpSize(aBitmap.GetSizePixel());
951  pVD->SetOutputSizePixel(aBmpSize, false);
952  pVD->DrawBitmapEx(Point(), aBitmap);
953  m_xControl->append("", pList->GetStringForUiSolidLine(), *pVD);
954  }
955 
956  // entries for dashed lines
957 
958  long nCount = pList->Count();
959  m_xControl->freeze();
960 
961  for( long i = 0; i < nCount; i++ )
962  {
963  const XDashEntry* pEntry = pList->GetDash(i);
964  const BitmapEx aBitmap = pList->GetUiBitmap( i );
965  if( !aBitmap.IsEmpty() )
966  {
967  const Size aBmpSize(aBitmap.GetSizePixel());
968  pVD->SetOutputSizePixel(aBmpSize, false);
969  pVD->DrawBitmapEx(Point(), aBitmap);
970  m_xControl->append("", pEntry->GetName(), *pVD);
971  }
972  else
973  {
974  m_xControl->append_text(pEntry->GetName());
975  }
976  }
977 
978  m_xControl->thaw();
979 }
980 
981 void SvxLineLB::Append( const XDashEntry& rEntry, const BitmapEx& rBitmap )
982 {
983  if (!rBitmap.IsEmpty())
984  {
986 
987  const Size aBmpSize(rBitmap.GetSizePixel());
988  pVD->SetOutputSizePixel(aBmpSize, false);
989  pVD->DrawBitmapEx(Point(), rBitmap);
990  m_xControl->append("", rEntry.GetName(), *pVD);
991  }
992  else
993  {
994  m_xControl->append_text(rEntry.GetName());
995  }
996 }
997 
998 void SvxLineLB::Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap)
999 {
1000  m_xControl->remove(nPos);
1001 
1002  if (!rBitmap.IsEmpty())
1003  {
1005 
1006  const Size aBmpSize(rBitmap.GetSizePixel());
1007  pVD->SetOutputSizePixel(aBmpSize, false);
1008  pVD->DrawBitmapEx(Point(), rBitmap);
1009  m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
1010  }
1011  else
1012  {
1013  m_xControl->insert_text(nPos, rEntry.GetName());
1014  }
1015 }
1016 
1017 SvxLineEndLB::SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl)
1018  : m_xControl(std::move(pControl))
1019 {
1020 }
1021 
1022 void SvxLineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
1023 {
1024  if( !pList.is() )
1025  return;
1026 
1027  long nCount = pList->Count();
1029  m_xControl->freeze();
1030 
1031  for( long i = 0; i < nCount; i++ )
1032  {
1033  const XLineEndEntry* pEntry = pList->GetLineEnd(i);
1034  const BitmapEx aBitmap = pList->GetUiBitmap( i );
1035  if( !aBitmap.IsEmpty() )
1036  {
1037  const Size aBmpSize(aBitmap.GetSizePixel());
1038  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1039  pVD->DrawBitmapEx(bStart ? Point() : Point(-aBmpSize.Width() / 2, 0), aBitmap);
1040  m_xControl->append("", pEntry->GetName(), *pVD);
1041  }
1042  else
1043  m_xControl->append_text(pEntry->GetName());
1044  }
1045 
1046  m_xControl->thaw();
1047 }
1048 
1049 void SvxLineEndLB::Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap )
1050 {
1051  if(!rBitmap.IsEmpty())
1052  {
1054 
1055  const Size aBmpSize(rBitmap.GetSizePixel());
1056  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1057  pVD->DrawBitmapEx(Point(-aBmpSize.Width() / 2, 0), rBitmap);
1058  m_xControl->append("", rEntry.GetName(), *pVD);
1059  }
1060  else
1061  {
1062  m_xControl->append_text(rEntry.GetName());
1063  }
1064 }
1065 
1066 void SvxLineEndLB::Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap )
1067 {
1068  m_xControl->remove(nPos);
1069 
1070  if(!rBitmap.IsEmpty())
1071  {
1073 
1074  const Size aBmpSize(rBitmap.GetSizePixel());
1075  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1076  pVD->DrawBitmapEx(Point(-aBmpSize.Width() / 2, 0), rBitmap);
1077  m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
1078  }
1079  else
1080  {
1081  m_xControl->insert_text(nPos, rEntry.GetName());
1082  }
1083 }
1084 
1086 {
1088 
1089  const Size aOutputSize(GetOutputSize());
1090  const sal_Int32 nDistance(500);
1091  const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
1092 
1093  // create DrawObectA
1094  const sal_Int32 aYPosA(aOutputSize.Height() / 2);
1095  const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
1096  const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
1097  basegfx::B2DPolygon aPolygonA;
1098  aPolygonA.append(aPointA1);
1099  aPolygonA.append(aPointA2);
1101 
1102  // create DrawObectB
1103  const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
1104  const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
1105  const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
1106  const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
1107  const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
1108  basegfx::B2DPolygon aPolygonB;
1109  aPolygonB.append(aPointB1);
1110  aPolygonB.append(aPointB2);
1111  aPolygonB.append(aPointB3);
1113 
1114  // create DrawObectC
1115  basegfx::B2DPolygon aPolygonC;
1116  const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
1117  const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
1118  const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
1119  aPolygonC.append(aPointC1);
1120  aPolygonC.append(aPointC2);
1121  aPolygonC.append(aPointC3);
1123 }
1124 
1126  : mpLineObjA(nullptr)
1127  , mpLineObjB(nullptr)
1128  , mpLineObjC(nullptr)
1129  , mpGraphic(nullptr)
1130  , mbWithSymbol(false)
1131 {
1132 }
1133 
1135 {
1136  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1137 
1141 
1142  Resize();
1143  Invalidate();
1144 }
1145 
1147 {
1148  SdrObject *pFoo = mpLineObjA;
1149  SdrObject::Free( pFoo );
1150  pFoo = mpLineObjB;
1151  SdrObject::Free( pFoo );
1152  pFoo = mpLineObjC;
1153  SdrObject::Free( pFoo );
1154 }
1155 
1157 {
1158  mpGraphic = p;
1159  maSymbolSize = s;
1160 }
1161 
1163 {
1164  if ( s != maSymbolSize )
1165  {
1166  maSymbolSize = s;
1167  Invalidate();
1168  }
1169 }
1170 
1172 {
1173  // Set ItemSet at objects
1174  mpLineObjA->SetMergedItemSet(rItemSet);
1175 
1176  // At line joints, do not use arrows
1177  SfxItemSet aTempSet(rItemSet);
1178  aTempSet.ClearItem(XATTR_LINESTART);
1179  aTempSet.ClearItem(XATTR_LINEEND);
1180 
1181  mpLineObjB->SetMergedItemSet(aTempSet);
1182  mpLineObjC->SetMergedItemSet(aTempSet);
1183 }
1184 
1186 {
1187  LocalPrePaint(rRenderContext);
1188 
1189  // paint objects to buffer device
1190  sdr::contact::SdrObjectVector aObjectVector;
1191  aObjectVector.push_back(mpLineObjA);
1192  aObjectVector.push_back(mpLineObjB);
1193  aObjectVector.push_back(mpLineObjC);
1194 
1195  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1196  sdr::contact::DisplayInfo aDisplayInfo;
1197 
1198  // do processing
1199  aPainter.ProcessDisplay(aDisplayInfo);
1200 
1201  if ( mbWithSymbol && mpGraphic )
1202  {
1203  const Size aOutputSize(GetOutputSize());
1204  Point aPos( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
1205  aPos.AdjustX( -(maSymbolSize.Width() / 2) );
1206  aPos.AdjustY( -(maSymbolSize.Height() / 2) );
1208  }
1209 
1210  LocalPostPaint(rRenderContext);
1211 }
1212 
1214  : mpRectangleObject(nullptr)
1215  , mpRectangleShadow(nullptr)
1216 {
1217 }
1218 
1220 {
1221  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1222  InitSettings();
1223 
1224  // prepare size
1225  Size aSize = GetPreviewSize().GetSize();
1226  aSize.setWidth( aSize.Width() / 3 );
1227  aSize.setHeight( aSize.Height() / 3 );
1228 
1229  // create RectangleObject
1230  const tools::Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
1232  getModel(),
1233  aObjectSize);
1234 
1235  // create ShadowObject
1236  const tools::Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
1238  getModel(),
1239  aShadowSize);
1240 }
1241 
1243 {
1246 }
1247 
1249 {
1250  mpRectangleObject->SetMergedItemSet(rItemSet, true);
1251  mpRectangleObject->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1252 }
1253 
1255 {
1256  mpRectangleShadow->SetMergedItemSet(rItemSet, true);
1257  mpRectangleShadow->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1258 }
1259 
1261 {
1262  maShadowOffset = rPos;
1263 }
1264 
1266 {
1267  rRenderContext.Push(PushFlags::MAPMODE);
1268  rRenderContext.SetMapMode(MapMode(MapUnit::Map100thMM));
1269 
1270  LocalPrePaint(rRenderContext);
1271 
1272  // prepare size
1273  Size aSize = rRenderContext.GetOutputSize();
1274  aSize.setWidth( aSize.Width() / 3 );
1275  aSize.setHeight( aSize.Height() / 3 );
1276 
1277  tools::Rectangle aObjectRect(Point(aSize.Width(), aSize.Height()), aSize);
1278  mpRectangleObject->SetSnapRect(aObjectRect);
1279  aObjectRect.Move(maShadowOffset.X(), maShadowOffset.Y());
1280  mpRectangleShadow->SetSnapRect(aObjectRect);
1281 
1282  sdr::contact::SdrObjectVector aObjectVector;
1283 
1284  aObjectVector.push_back(mpRectangleShadow);
1285  aObjectVector.push_back(mpRectangleObject);
1286 
1287  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1288  sdr::contact::DisplayInfo aDisplayInfo;
1289 
1290  aPainter.ProcessDisplay(aDisplayInfo);
1291 
1292  LocalPostPaint(rRenderContext);
1293 
1294  rRenderContext.Pop();
1295 }
1296 
1298 {
1299  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1300 
1301  svtools::ColorConfig aColorConfig;
1302  Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
1303  getBufferDevice().SetTextColor(aTextColor);
1304 
1305  getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
1306 
1308 
1309  Invalidate();
1310 }
1311 
1313  : mpModel(new SdrModel(nullptr, nullptr, true))
1314 {
1315  // init model
1316  mpModel->GetItemPool().FreezeIdRanges();
1317 }
1318 
1320 {
1321  CustomWidgetController::SetDrawingArea(pDrawingArea);
1322  Size aSize(getPreviewStripSize(pDrawingArea->get_ref_device()));
1323  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
1324  SetOutputSizePixel(aSize);
1325 
1327  mpBufferDevice->SetMapMode(MapMode(MapUnit::Map100thMM));
1328 }
1329 
1331 {
1332  mpModel.reset();
1334 }
1335 
1337 {
1338  // init BufferDevice
1341  mpBufferDevice->SetAntialiasing(rRenderContext.GetAntialiasing());
1342 
1343  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1344 
1345  if (rStyleSettings.GetPreviewUsesCheckeredBackground())
1346  {
1347  const Point aNull(0, 0);
1348  static const sal_uInt32 nLen(8);
1349  static const Color aW(COL_WHITE);
1350  static const Color aG(0xef, 0xef, 0xef);
1351  const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
1352 
1353  mpBufferDevice->EnableMapMode(false);
1355  mpBufferDevice->EnableMapMode(bWasEnabled);
1356  }
1357  else
1358  {
1359  mpBufferDevice->Erase();
1360  }
1361 }
1362 
1364 {
1365  // copy to front (in pixel mode)
1366  const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
1367  const bool bWasEnabledDst(rRenderContext.IsMapModeEnabled());
1368  const Point aEmptyPoint;
1369 
1370  mpBufferDevice->EnableMapMode(false);
1371  rRenderContext.EnableMapMode(false);
1372 
1373  rRenderContext.DrawOutDev(aEmptyPoint, GetOutputSizePixel(),
1374  aEmptyPoint, GetOutputSizePixel(),
1375  *mpBufferDevice);
1376 
1377  mpBufferDevice->EnableMapMode(bWasEnabledSrc);
1378  rRenderContext.EnableMapMode(bWasEnabledDst);
1379 }
1380 
1382 {
1383  InitSettings();
1384  CustomWidgetController::StyleUpdated();
1385 }
1386 
1388  : mpRectangleObject(nullptr)
1389 {
1390 }
1391 
1393 {
1394  tools::Rectangle aObjectSize(Point(), getBufferDevice().PixelToLogic(GetOutputSizePixel()));
1395  return aObjectSize;
1396 }
1397 
1399 {
1400  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1401  InitSettings();
1402 
1403  // create RectangleObject
1405 }
1406 
1408 {
1409  SdrObject *pOrigObject = mpRectangleObject;
1410  if (pOrigObject)
1411  {
1413  SetAttributes(pOrigObject->GetMergedItemSet());
1414  SdrObject::Free(pOrigObject);
1415  }
1417 }
1418 
1420 {
1422 }
1423 
1425 {
1426  mpRectangleObject->SetMergedItemSet(rItemSet, true);
1427  mpRectangleObject->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1428 }
1429 
1431 {
1432  rRenderContext.Push(PushFlags::MAPMODE);
1433  rRenderContext.SetMapMode(MapMode(MapUnit::Map100thMM));
1434  LocalPrePaint(rRenderContext);
1435 
1436  sdr::contact::SdrObjectVector aObjectVector;
1437 
1438  aObjectVector.push_back(mpRectangleObject);
1439 
1440  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1441  sdr::contact::DisplayInfo aDisplayInfo;
1442 
1443  aPainter.ProcessDisplay(aDisplayInfo);
1444 
1445  LocalPostPaint(rRenderContext);
1446  rRenderContext.Pop();
1447 }
1448 
1449 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CTL_STATE m_nState
Definition: dlgctrl.hxx:96
long Width() const
const Color & GetShadowColor() const
void setAddStandardFields(bool bNew)
Definition: dlgctrl.cxx:924
#define OUTPUT_DRAWMODE_CONTRAST
Definition: dlgctrl.cxx:56
virtual ~SvxPixelCtl() override
Definition: dlgctrl.cxx:658
const Wallpaper & GetBackground() const
void Modify(const XLineEndEntry &rEntry, sal_Int32 nPos, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:1066
void SetActualRP(RectPoint eNewRP)
Definition: dlgctrl.cxx:507
OutputDevice & getBufferDevice() const
Definition: dlgctrl.hxx:334
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:151
sal_Int32 nIndex
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
const Color & GetDialogColor() const
void SetAntialiasing(AntialiasingFlags nMode)
Color aPixelColor
Definition: dlgctrl.hxx:153
virtual void Resize() override
Definition: dlgctrl.cxx:1085
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:651
#define KEY_SPACE
SdrPathObj * mpLineObjB
Definition: dlgctrl.hxx:351
long AdjustX(long nHorzMove)
tools::Rectangle implCalFocusRect(const Point &aPosition)
Definition: dlgctrl.cxx:761
void SetXBitmap(const BitmapEx &rBitmapEx)
Definition: dlgctrl.cxx:875
Point aPtLT
Definition: dlgctrl.hxx:90
bool bPaintable
Definition: dlgctrl.hxx:157
Point aPtLM
Definition: dlgctrl.hxx:91
Reference< XControl > m_xControl
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1430
long Height() const
Size GetOutputSize() const
Definition: dlgctrl.hxx:324
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder)
Definition: dlgctrl.cxx:93
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1398
virtual void GetFocus() override
Definition: dlgctrl.cxx:860
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:705
void Reset()
Definition: dlgctrl.cxx:497
void DoCompletelyDisable(bool bNew)
Definition: dlgctrl.cxx:576
SVX_DLLPRIVATE BitmapEx & GetRectBitmap()
Definition: dlgctrl.cxx:66
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:84
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
SdrPathObj * mpLineObjA
Definition: dlgctrl.hxx:350
bool IsMapModeEnabled() const
sal_Int64 n
Point aPtRT
Definition: dlgctrl.hxx:90
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1219
virtual ~SvxXRectPreview() override
Definition: dlgctrl.cxx:1419
sal_uInt16 GetCode() const
bool GetPreviewUsesCheckeredBackground() const
RectPoint GetActualRP() const
Definition: dlgctrl.hxx:121
RectPoint eRP
Definition: dlgctrl.hxx:94
long ShowPosition(const Point &pt)
Definition: dlgctrl.cxx:618
SdrModel & getModel() const
Definition: dlgctrl.hxx:330
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:77
constexpr::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
Color aBackgroundColor
Definition: dlgctrl.hxx:154
const Color & GetLabelTextColor() const
Point maShadowOffset
Definition: dlgctrl.hxx:398
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
void EnableMapMode(bool bEnable=true)
#define OUTPUT_DRAWMODE_COLOR
Definition: dlgctrl.cxx:55
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:423
void SetLineAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1171
SVX_DLLPRIVATE void InitRectBitmap()
Definition: dlgctrl.cxx:129
virtual bool KeyInput(const KeyEvent &) override
Definition: dlgctrl.cxx:208
float x
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1134
void SetRectangleAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1248
#define KEY_LEFT
void SetMapMode()
AntialiasingFlags GetAntialiasing() const
virtual void LoseFocus() override
Definition: dlgctrl.cxx:870
polygon, PolyPolygon
Definition: svdobj.hxx:126
long GetFocusPosIndex() const
Definition: dlgctrl.cxx:613
Size const & GetOutputSizePixel() const
Point IndexToPoint(long nIndex) const
Definition: dlgctrl.cxx:599
Point aFocusPosition
Definition: dlgctrl.hxx:159
SdrObject * mpRectangleShadow
Definition: dlgctrl.hxx:401
NONE
void Move(long nHorzMoveDelta, long nVertMoveDelta)
void SetDrawMode(DrawModeFlags nDrawMode)
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
static OutputDevice * GetDefaultDevice()
::std::vector< SdrObject * > SdrObjectVector
void SetShadowAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1254
SdrPathObj * mpLineObjC
Definition: dlgctrl.hxx:352
virtual tools::Rectangle GetFocusRect() override
Definition: dlgctrl.cxx:695
void SetBackground()
SvxRectCtl(const SvxRectCtl &)=delete
bool mbAddStandardFields
defines if standard fields (none, solid) are added, default is true
Definition: dlgctrl.hxx:233
virtual void GetFocus() override
Definition: dlgctrl.cxx:425
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
virtual void PointChanged(weld::DrawingArea *pArea, RectPoint eRP)=0
void setX(long nX)
Size aRectSize
Definition: dlgctrl.hxx:155
int nCount
bool getAddStandardFields() const
Definition: dlgctrl.hxx:239
Size getPreviewStripSize(const OutputDevice &rReference)
const Color & GetLightColor() const
bool GetHighContrastMode() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: svdobj.cxx:1936
std::unique_ptr< SdrModel > mpModel
Definition: dlgctrl.hxx:297
virtual OutputDevice & get_ref_device()=0
void setY(long nY)
std::array< sal_uInt8, nSquares > maPixelData
Definition: dlgctrl.hxx:156
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1185
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetState(CTL_STATE nState)
Definition: dlgctrl.cxx:518
sal_uInt16 nCode
void Append(const XLineEndEntry &rEntry, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:1049
void DrawRect(const tools::Rectangle &rRect)
virtual void LoseFocus() override
Definition: dlgctrl.cxx:436
float y
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
long getY() const
const OUString & GetName() const
long getX() const
const Color & GetDarkShadowColor() const
bool IsEmpty() const
RectPoint
Definition: rectenum.hxx:22
void SetLineColor()
virtual void Resize() override
Definition: dlgctrl.cxx:1407
object group
Definition: svdobj.hxx:119
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: dlgctrl.cxx:584
Point aPtMB
Definition: dlgctrl.hxx:92
void Fill()
Definition: dlgctrl.cxx:903
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
#define DBG_ASSERT(sCon, aError)
static sal_uInt16 constexpr nSquares
Definition: dlgctrl.hxx:149
void SetPathPoly(const basegfx::B2DPolyPolygon &rPathPoly)
Definition: svdopath.cxx:2746
sal_uInt16 nBorderWidth
Definition: dlgctrl.hxx:89
sal_uInt8 GetBitmapPixel(const sal_uInt16 nPixelNumber) const
Definition: dlgctrl.cxx:889
RectPoint eDefRP
Definition: dlgctrl.hxx:94
VclPtr< VirtualDevice > mpBufferDevice
Definition: dlgctrl.hxx:298
Point aPtRB
Definition: dlgctrl.hxx:92
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
int i
const Color & GetColor() const
void SetUpdateMode(bool bUpdate)
Size GetOutputSize() const
bool IsCompletelyDisabled() const
Definition: dlgctrl.hxx:137
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:265
void SetFillColor()
const Color & GetLineColor() const
Point aPtNew
Definition: dlgctrl.hxx:93
void SetTextColor(const Color &rColor)
static bool GetLayoutRTL()
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:376
bool isHistorical8x8(const BitmapEx &rBitmapEx, Color &o_rBack, Color &o_rFront)
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
void LocalPrePaint(vcl::RenderContext const &rRenderContext)
Definition: dlgctrl.cxx:1336
rtl::Reference< SvxRectCtlAccessibleContext > pAccContext
Definition: dlgctrl.hxx:88
void SetAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1424
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:230
void SetMergedItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1921
::Color GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: dlgctrl.cxx:674
Size GetOutputSizePixel() const
static SVX_DLLPRIVATE void InitSettings(vcl::RenderContext &rRenderContext)
Definition: dlgctrl.cxx:182
std::unique_ptr< BitmapEx > pBitmap
Definition: dlgctrl.hxx:95
SVX_DLLPRIVATE void Resize_Impl(const Size &rSize)
Definition: dlgctrl.cxx:111
virtual ~SvxPreviewBase() override
Definition: dlgctrl.cxx:1330
Point aPtLB
Definition: dlgctrl.hxx:92
Abstract DrawObject.
Definition: svdobj.hxx:312
RectPoint GetApproxRPFromPixPt(const css::awt::Point &rPixelPoint) const
Definition: dlgctrl.cxx:570
tools::Rectangle GetPreviewSize() const
Definition: dlgctrl.cxx:1392
Point SetActualRPWithoutInvalidate(RectPoint eNewRP)
Definition: dlgctrl.cxx:404
void SetOutputSizePixel(const Size &rSize)
long X() const
void Append(const XDashEntry &rEntry, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:981
Size GetSize() const
void SetShadowPosition(const Point &rPos)
Definition: dlgctrl.cxx:1260
Point LogicToPixel(const Point &rLogicPt) const
void LocalPostPaint(vcl::RenderContext &rRenderContext)
Definition: dlgctrl.cxx:1363
static sal_uInt16 constexpr nLines
Definition: dlgctrl.hxx:148
const vcl::KeyCode & GetKeyCode() const
virtual void StyleUpdated() override
Definition: dlgctrl.cxx:1381
virtual ~SvxXLinePreview() override
Definition: dlgctrl.cxx:1146
Point GetApproxLogPtFromPixPt(const Point &rRoughPixelPoint) const
Definition: dlgctrl.cxx:441
bool mbCompleteDisable
Definition: dlgctrl.hxx:98
bool IsShift() const
weld::DrawingArea * GetDrawingArea() const
#define KEY_DOWN
Graphic * mpGraphic
Definition: dlgctrl.hxx:354
void SetSymbol(Graphic *p, const Size &s)
Definition: dlgctrl.cxx:1156
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
virtual void Resize() override
Definition: dlgctrl.cxx:645
unsigned char sal_uInt8
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: dlgctrl.cxx:775
void Fill(const XDashListRef &pList)
Definition: dlgctrl.cxx:934
void Reset()
Definition: dlgctrl.cxx:896
tools::Rectangle CalculateFocusRectangle() const
Definition: dlgctrl.cxx:538
#define XATTR_LINEEND
Definition: xdef.hxx:95
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1911
virtual int get_text_height() const =0
bool IsMod1() const
static VclPtr< reference_type > Create(Arg &&...arg)
virtual bool MouseButtonDown(const MouseEvent &) override
Definition: dlgctrl.cxx:193
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: dlgctrl.cxx:564
virtual void SetDrawingArea(weld::DrawingArea *) override
Definition: dlgctrl.cxx:1319
const Color & GetWindowColor() const
const Point & GetPosPixel() const
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: dlgctrl.cxx:292
rtl::Reference< SvxPixelCtlAccessible > m_xAccess
Definition: dlgctrl.hxx:160
void DrawCheckered(const Point &rPos, const Size &rSize, sal_uInt32 nLen=8, Color aStart=COL_WHITE, Color aEnd=COL_BLACK)
void Modify(const XDashEntry &rEntry, sal_Int32 nPos, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:998
virtual ~SvxXShadowPreview() override
Definition: dlgctrl.cxx:1242
virtual void Resize() override
Definition: dlgctrl.cxx:106
RectPoint GetRPFromPoint(Point, bool bRTL=false) const
Definition: dlgctrl.cxx:479
virtual void SetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1649
void Fill(const XLineEndListRef &pList, bool bStart=true)
Definition: dlgctrl.cxx:1022
MapUnit
virtual tools::Rectangle GetFocusRect() override
Definition: dlgctrl.cxx:377
void ChangePixel(sal_uInt16 nPixel)
Definition: dlgctrl.cxx:664
void AdaptDropDownLineCountToMaximum()
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:400
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1265
long PointToIndex(const Point &pt) const
Definition: dlgctrl.cxx:591
void ResizeSymbol(const Size &s)
Definition: dlgctrl.cxx:1162
const Size & GetSizePixel() const
const Point & GetPointFromRP(RectPoint) const
Definition: dlgctrl.cxx:387
virtual void StyleUpdated() override
Definition: dlgctrl.cxx:176
virtual void set_size_request(int nWidth, int nHeight)=0
SvxPixelCtl(SvxPixelCtl const &)=delete
void Push(PushFlags nFlags=PushFlags::ALL)
void setWidth(long nWidth)
virtual ~SvxRectCtl() override
Definition: dlgctrl.cxx:100
Point aPtRM
Definition: dlgctrl.hxx:91
SvxLineEndLB(std::unique_ptr< weld::ComboBox > pControl)
Definition: dlgctrl.cxx:1017
#define KEY_RIGHT
virtual float get_approximate_digit_width() const =0
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
long Y() const
#define XATTR_LINESTART
Definition: xdef.hxx:94
SvxLineLB(std::unique_ptr< weld::ComboBox > pControl)
Definition: dlgctrl.cxx:918
Point aPtMT
Definition: dlgctrl.hxx:90
CTL_STATE
Definition: dlgctrl.hxx:60
#define KEY_UP
void InitSettings()
Definition: dlgctrl.cxx:1297
bool IsMod2() const
Point aPtMM
Definition: dlgctrl.hxx:91
void setHeight(long nHeight)