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