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