LibreOffice Module svx (master)  1
_contdlg.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 <sal/config.h>
21 
22 #include <tools/helpers.hxx>
23 #include <svl/eitem.hxx>
24 #include <sfx2/ctrlitem.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/module.hxx>
28 
29 #include <svx/svxids.hrc>
30 #include <svx/contdlg.hxx>
31 #include "contimp.hxx"
32 #include "contwnd.hxx"
33 #include <svx/svdopath.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/settings.hxx>
36 #include <vcl/virdev.hxx>
37 #include "dlgunit.hxx"
38 #include <vcl/weld.hxx>
39 
41 
43  SfxControllerItem ( SID_CONTOUR_EXEC, rBindings ),
44  rDlg ( rContourDlg )
45 {
46 }
47 
48 void SvxContourDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, const SfxPoolItem* pItem )
49 {
50  if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
51  {
52  const SfxBoolItem* pStateItem = dynamic_cast<const SfxBoolItem*>( pItem );
53  assert(pStateItem); //SfxBoolItem expected
54  if (pStateItem)
55  rDlg.SetExecState(!pStateItem->GetValue());
56  }
57 }
58 
60  SfxBindings* pBindings, SfxChildWinInfo const * pInfo)
61  : SfxChildWindow( _pParent, nId )
62 {
63  SetController(std::make_shared<SvxContourDlg>(pBindings, this, _pParent->GetFrameWeld()));
64  SvxContourDlg* pDlg = static_cast<SvxContourDlg*>(GetController().get());
65  pDlg->Initialize( pInfo );
66 }
67 
69  weld::Window* _pParent)
70  : SfxModelessDialogController(_pBindings, pCW, _pParent, "svx/ui/floatingcontour.ui", "FloatingContour")
71  , m_xImpl(std::make_unique<SvxSuperContourDlg>(*m_xBuilder, *m_xDialog, _pBindings))
72 {
73 }
74 
76 {
77 }
78 
80  const tools::Rectangle* pRect )
81 {
82  Bitmap aBmp;
83  bool bContourEdgeDetect = false;
84 
85  if ( rGraphic.GetType() == GraphicType::Bitmap )
86  {
87  if( rGraphic.IsAnimated() )
88  {
90  MapMode aTransMap;
91  const Animation aAnim( rGraphic.GetAnimation() );
92  const Size& rSizePix = aAnim.GetDisplaySizePixel();
93  const sal_uInt16 nCount = aAnim.Count();
94 
95  if ( pVDev->SetOutputSizePixel( rSizePix ) )
96  {
97  pVDev->SetLineColor( COL_BLACK );
98  pVDev->SetFillColor( COL_BLACK );
99 
100  for( sal_uInt16 i = 0; i < nCount; i++ )
101  {
102  const AnimationBitmap& rStepBmp = aAnim.Get( i );
103 
104  // Push Polygon output to the right place; this is the
105  // offset of the sub-image within the total animation
106  aTransMap.SetOrigin( Point( rStepBmp.maPositionPixel.X(), rStepBmp.maPositionPixel.Y() ) );
107  pVDev->SetMapMode( aTransMap );
108  pVDev->DrawPolyPolygon( CreateAutoContour( rStepBmp.maBitmapEx, pRect ) );
109  }
110 
111  aTransMap.SetOrigin( Point() );
112  pVDev->SetMapMode( aTransMap );
113  aBmp = pVDev->GetBitmap( Point(), rSizePix );
114  aBmp.Convert( BmpConversion::N1BitThreshold );
115  }
116  }
117  else if( rGraphic.IsTransparent() )
118  aBmp = rGraphic.GetBitmapEx().GetMask();
119  else
120  {
121  aBmp = rGraphic.GetBitmapEx().GetBitmap();
122  bContourEdgeDetect = true;
123  }
124  }
125  else if( rGraphic.GetType() != GraphicType::NONE )
126  {
127  const Graphic aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( COL_BLACK ) );
129  Size aSizePix( pVDev->LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
130 
131  if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
132  {
133  double fWH = static_cast<double>(aSizePix.Width()) / aSizePix.Height();
134 
135  if( fWH <= 1.0 )
136  {
137  aSizePix.setHeight(512);
138  aSizePix.setWidth( FRound( ( aSizePix.Height() ) * fWH ) );
139  }
140  else
141  {
142  aSizePix.setWidth(512);
143  aSizePix.setHeight( FRound( ( aSizePix.Width() ) / fWH ) );
144  }
145  }
146 
147  if( pVDev->SetOutputSizePixel( aSizePix ) )
148  {
149  const Point aPt;
150  aTmpGrf.Draw( pVDev, aPt, aSizePix );
151  aBmp = pVDev->GetBitmap( aPt, aSizePix );
152  }
153 
154  bContourEdgeDetect = true;
155  }
156 
157  aBmp.SetPrefSize( rGraphic.GetPrefSize() );
158  aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() );
159 
160  return tools::PolyPolygon( BitmapEx(aBmp).GetContour( bContourEdgeDetect, pRect ) );
161 }
162 
163 // Loop through to super class, no virtual Methods to not become incompatible
164 // due to IF changes
165 
167 {
168  return m_xImpl->GetGraphic();
169 }
170 
172 {
173  return m_xImpl->IsGraphicChanged();
174 }
175 
177 {
178  return m_xImpl->GetPolyPolygon();
179 }
180 
182 {
183  return m_xImpl->GetEditingObject();
184 }
185 
186 void SvxContourDlg::Update( const Graphic& rGraphic, bool bGraphicLinked,
187  const tools::PolyPolygon* pPolyPoly, void* pEditingObj )
188 {
189  m_xImpl->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
190 }
191 
193  weld::Dialog& rDialog, SfxBindings* pBindings)
194  : aUpdateIdle( "SvxSuperContourDlg UpdateIdle" )
195  , aCreateIdle( "SvxSuperContourDlg CreateIdle" )
196  , mpBindings(pBindings)
197  , pUpdateEditingObject( nullptr )
198  , pCheckObj( nullptr )
199  , aContourItem( *this, *pBindings )
200  , mnGrfChanged( 0 )
201  , bExecState( false )
202  , bUpdateGraphicLinked( false )
203  , bGraphicLinked( false )
204  , m_rDialog(rDialog)
205  , m_xContourWnd(new ContourWindow(&rDialog))
206  , m_xStbStatusColor(new StatusColor(*m_xContourWnd))
207  , m_xTbx1(rBuilder.weld_toolbar("toolbar"))
208  , m_xMtfTolerance(rBuilder.weld_metric_spin_button("spinbutton", FieldUnit::PERCENT))
209  , m_xStbStatus2(rBuilder.weld_label("statuspos"))
210  , m_xStbStatus3(rBuilder.weld_label("statussize"))
211  , m_xCancelBtn(rBuilder.weld_button("cancel"))
212  , m_xStbStatusColorWeld(new weld::CustomWeld(rBuilder, "statuscolor", *m_xStbStatusColor))
213  , m_xContourWndWeld(new weld::CustomWeld(rBuilder, "container", *m_xContourWnd))
214 {
215  m_xCancelBtn->connect_clicked(LINK(this, SvxSuperContourDlg, CancelHdl));
216 
217  m_xContourWnd->SetMousePosLink( LINK( this, SvxSuperContourDlg, MousePosHdl ) );
218  m_xContourWnd->SetGraphSizeLink( LINK( this, SvxSuperContourDlg, GraphSizeHdl ) );
219  m_xContourWnd->SetUpdateLink( LINK( this, SvxSuperContourDlg, StateHdl ) );
220  m_xContourWnd->SetPipetteHdl( LINK( this, SvxSuperContourDlg, PipetteHdl ) );
221  m_xContourWnd->SetPipetteClickHdl( LINK( this, SvxSuperContourDlg, PipetteClickHdl ) );
222  m_xContourWnd->SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg, WorkplaceClickHdl ) );
223 
224  m_xTbx1->connect_clicked( LINK( this, SvxSuperContourDlg, Tbx1ClickHdl ) );
225 
226  m_xMtfTolerance->set_value(10, FieldUnit::PERCENT);
227 
228  aUpdateIdle.SetInvokeHandler( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
229 
230  aCreateIdle.SetPriority( TaskPriority::RESIZE );
231  aCreateIdle.SetInvokeHandler( LINK( this, SvxSuperContourDlg, CreateHdl ) );
232 }
233 
235 {
236  m_xContourWnd->SetUpdateLink( Link<GraphCtrl*,void>() );
237  m_xContourWnd.reset();
238 }
239 
241 {
242  bool bRet = true;
243 
244  if (m_xTbx1->get_item_sensitive("TBI_APPLY"))
245  {
246  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&m_rDialog, "svx/ui/querysavecontchangesdialog.ui"));
247  std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QuerySaveContourChangesDialog"));
248  const short nRet = xQBox->run();
249 
250  if ( nRet == RET_YES )
251  {
252  SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, true );
253  GetBindings().GetDispatcher()->ExecuteList(
254  SID_CONTOUR_EXEC, SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
255  { &aBoolItem });
256  }
257  else if ( nRet == RET_CANCEL )
258  bRet = false;
259  }
260 
261  if (bRet)
262  m_rDialog.response(RET_CANCEL);
263 }
264 
265 // Enabled or disabled all Controls
266 
268 {
269  bExecState = bEnable;
270 }
271 
273 {
275  aGraphic = rGraphic;
276  mnGrfChanged = 0;
277  m_xContourWnd->SetGraphic( aGraphic );
278 }
279 
281 {
282  DBG_ASSERT( m_xContourWnd->GetGraphic().GetType() != GraphicType::NONE, "Graphic must've been set first!" );
283 
284  tools::PolyPolygon aPolyPoly( rPolyPoly );
285  const MapMode aMap100( MapUnit::Map100thMM );
286  const MapMode aGrfMap( aGraphic.GetPrefMapMode() );
288  bool bPixelMap = aGrfMap.GetMapUnit() == MapUnit::MapPixel;
289 
290  for ( sal_uInt16 j = 0, nPolyCount = aPolyPoly.Count(); j < nPolyCount; j++ )
291  {
292  tools::Polygon& rPoly = aPolyPoly[ j ];
293 
294  for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
295  {
296  Point& rPt = rPoly[ i ];
297 
298  if ( !bPixelMap )
299  rPt = pOutDev->LogicToPixel( rPt, aGrfMap );
300 
301  rPt = pOutDev->PixelToLogic( rPt, aMap100 );
302  }
303  }
304 
305  m_xContourWnd->SetPolyPolygon( aPolyPoly );
306  m_xContourWnd->GetSdrModel()->SetChanged();
307 }
308 
310 {
311  tools::PolyPolygon aRetPolyPoly( m_xContourWnd->GetPolyPolygon() );
312 
313  const MapMode aMap100( MapUnit::Map100thMM );
314  const MapMode aGrfMap( aGraphic.GetPrefMapMode() );
316  bool bPixelMap = aGrfMap.GetMapUnit() == MapUnit::MapPixel;
317 
318  for ( sal_uInt16 j = 0, nPolyCount = aRetPolyPoly.Count(); j < nPolyCount; j++ )
319  {
320  tools::Polygon& rPoly = aRetPolyPoly[ j ];
321 
322  for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
323  {
324  Point& rPt = rPoly[ i ];
325 
326  rPt = pOutDev->LogicToPixel( rPt, aMap100 );
327 
328  if ( !bPixelMap )
329  rPt = pOutDev->PixelToLogic( rPt, aGrfMap );
330  }
331  }
332 
333  return aRetPolyPoly;
334 }
335 
336 void SvxSuperContourDlg::UpdateGraphic( const Graphic& rGraphic, bool _bGraphicLinked,
337  const tools::PolyPolygon* pPolyPoly, void* pEditingObj )
338 {
339  aUpdateGraphic = rGraphic;
340  bUpdateGraphicLinked = _bGraphicLinked;
341  pUpdateEditingObject = pEditingObj;
342 
343  if ( pPolyPoly )
344  aUpdatePolyPoly = *pPolyPoly;
345  else
347 
348  aUpdateIdle.Start();
349 }
350 
351 // Click handler for ToolBox
352 
353 IMPL_LINK(SvxSuperContourDlg, Tbx1ClickHdl, const OString&, rId, void)
354 {
355  if (rId == "TBI_APPLY")
356  {
357  SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, true );
358  GetBindings().GetDispatcher()->ExecuteList(
359  SID_CONTOUR_EXEC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
360  { &aBoolItem });
361  }
362  else if (rId == "TBI_WORKPLACE")
363  {
364  if (m_xTbx1->get_item_active("TBI_WORKPLACE"))
365  {
366  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&m_rDialog, "svx/ui/querydeletecontourdialog.ui"));
367  std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QueryDeleteContourDialog"));
368 
369  if (!m_xContourWnd->IsContourChanged() || (xQBox->run() == RET_YES))
370  m_xContourWnd->SetWorkplaceMode( true );
371  else
372  m_xTbx1->set_item_active("TBI_WORKPLACE", false);
373  }
374  else
375  m_xContourWnd->SetWorkplaceMode( false );
376  }
377  else if (rId == "TBI_SELECT")
378  {
379  SetActiveTool(rId);
380  m_xContourWnd->SetEditMode( true );
381  }
382  else if (rId == "TBI_RECT")
383  {
384  SetActiveTool(rId);
385  m_xContourWnd->SetObjKind( OBJ_RECT );
386  }
387  else if (rId == "TBI_CIRCLE")
388  {
389  SetActiveTool(rId);
390  m_xContourWnd->SetObjKind( OBJ_CIRC );
391  }
392  else if (rId == "TBI_POLY")
393  {
394  SetActiveTool(rId);
395  m_xContourWnd->SetObjKind( OBJ_POLY );
396  }
397  else if (rId == "TBI_POLYEDIT")
398  {
399  m_xContourWnd->SetPolyEditMode(m_xTbx1->get_item_active("TBI_POLYEDIT") ? SID_BEZIER_MOVE : 0);
400  }
401  else if (rId == "TBI_POLYMOVE")
402  {
403  SetActivePoly(rId);
404  m_xContourWnd->SetPolyEditMode( SID_BEZIER_MOVE );
405  }
406  else if (rId == "TBI_POLYINSERT")
407  {
408  SetActivePoly(rId);
409  m_xContourWnd->SetPolyEditMode( SID_BEZIER_INSERT );
410  }
411  else if (rId == "TBI_POLYDELETE")
412  {
413  m_xContourWnd->GetSdrView()->DeleteMarkedPoints();
414  }
415  else if (rId == "TBI_UNDO")
416  {
417  mnGrfChanged = mnGrfChanged ? mnGrfChanged - 1 : 0;
418  aRedoGraphic = aGraphic;
419  aGraphic = aUndoGraphic;
420  aUndoGraphic = Graphic();
421  m_xContourWnd->SetGraphic( aGraphic, false );
422  }
423  else if (rId == "TBI_REDO")
424  {
425  mnGrfChanged++;
426  aUndoGraphic = aGraphic;
427  aGraphic = aRedoGraphic;
428  aRedoGraphic = Graphic();
429  m_xContourWnd->SetGraphic( aGraphic, false );
430  }
431  else if (rId == "TBI_AUTOCONTOUR")
432  {
433  aCreateIdle.Start();
434  }
435  else if (rId == "TBI_PIPETTE")
436  {
437  bool bPipette = m_xTbx1->get_item_active("TBI_PIPETTE");
438 
439  if ( !bPipette )
440  m_xStbStatusColor->Invalidate();
441  else if ( bGraphicLinked )
442  {
443  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&m_rDialog, "svx/ui/queryunlinkgraphicsdialog.ui"));
444  std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QueryUnlinkGraphicsDialog"));
445 
446  if (xQBox->run() != RET_YES)
447  {
448  bPipette = false;
449  m_xTbx1->set_item_active("TBI_PIPETTE", bPipette);
450  m_xStbStatusColor->Invalidate();
451  }
452  }
453 
454  m_xContourWnd->SetPipetteMode( bPipette );
455  }
456  m_xContourWnd->QueueIdleUpdate();
457 }
458 
459 void SvxSuperContourDlg::SetActiveTool(const OString& rId)
460 {
461  m_xTbx1->set_item_active("TBI_SELECT", rId == "TBI_SELECT");
462  m_xTbx1->set_item_active("TBI_RECT", rId == "TBI_RECT");
463  m_xTbx1->set_item_active("TBI_CIRCLE", rId == "TBI_CIRCLE");
464  m_xTbx1->set_item_active("TBI_POLY", rId == "TBI_POLY");
465 }
466 
467 void SvxSuperContourDlg::SetActivePoly(const OString& rId)
468 {
469  m_xTbx1->set_item_active("TBI_POLYMOVE", rId == "TBI_POLYMOVE");
470  m_xTbx1->set_item_active("TBI_POLYINSERT", rId == "TBI_POLYINSERT");
471 }
472 
473 IMPL_LINK( SvxSuperContourDlg, MousePosHdl, GraphCtrl*, pWnd, void )
474 {
475  OUString aStr;
476  const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
477  const Point& rMousePos = pWnd->GetMousePos();
479  const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
480 
481  aStr = GetUnitString( rMousePos.X(), eFieldUnit, cSep )
482  + " / "
483  + GetUnitString( rMousePos.Y(), eFieldUnit, cSep );
484 
485  m_xStbStatus2->set_label( aStr );
486 }
487 
488 IMPL_LINK( SvxSuperContourDlg, GraphSizeHdl, GraphCtrl*, pWnd, void )
489 {
490  OUString aStr;
491  const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
492  const Size& rSize = pWnd->GetGraphicSize();
494  const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
495 
496  aStr = GetUnitString( rSize.Width(), eFieldUnit, cSep )
497  + " x "
498  + GetUnitString( rSize.Height(), eFieldUnit, cSep );
499 
500  m_xStbStatus3->set_label( aStr );
501 }
502 
504 {
505  aUpdateIdle.Stop();
506 
507  if ( pUpdateEditingObject != pCheckObj )
508  {
509  if( !GetEditingObject() )
510  m_xContourWnd->GrabFocus();
511 
512  SetGraphic( aUpdateGraphic );
513  SetPolyPolygon( aUpdatePolyPoly );
514  pCheckObj = pUpdateEditingObject;
515  bGraphicLinked = bUpdateGraphicLinked;
516 
517  aUpdateGraphic = Graphic();
518  aUpdatePolyPoly = tools::PolyPolygon();
519  bUpdateGraphicLinked = false;
520 
521  m_xContourWnd->GetSdrModel()->SetChanged( false );
522  }
523 
524  GetBindings().Invalidate( SID_CONTOUR_EXEC );
525  m_xContourWnd->QueueIdleUpdate();
526 }
527 
529 {
530  aCreateIdle.Stop();
531 
532  const tools::Rectangle aWorkRect = m_xContourWnd->GetDrawingArea()->get_ref_device().LogicToPixel(
533  m_xContourWnd->GetWorkRect(), MapMode( MapUnit::Map100thMM));
534 
535  const Graphic& rGraphic = m_xContourWnd->GetGraphic();
536  const bool bValid = aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom();
537 
538  weld::WaitObject aWaitObj(&m_rDialog);
539  SetPolyPolygon( SvxContourDlg::CreateAutoContour( rGraphic, bValid ? &aWorkRect : nullptr ) );
540 }
541 
542 IMPL_LINK( SvxSuperContourDlg, StateHdl, GraphCtrl*, pWnd, void )
543 {
544  const SdrObject* pObj = pWnd->GetSelectedSdrObject();
545  const SdrView* pView = pWnd->GetSdrView();
546  const bool bPolyEdit = ( pObj != nullptr ) && dynamic_cast<const SdrPathObj*>( pObj) != nullptr;
547  const bool bDrawEnabled = !(bPolyEdit && m_xTbx1->get_item_active("TBI_POLYEDIT"));
548  const bool bPipette = m_xTbx1->get_item_active("TBI_PIPETTE");
549  const bool bWorkplace = m_xTbx1->get_item_active("TBI_WORKPLACE");
550  const bool bDontHide = !( bPipette || bWorkplace );
551  const bool bBitmap = pWnd->GetGraphic().GetType() == GraphicType::Bitmap;
552 
553  m_xTbx1->set_item_sensitive("TBI_APPLY", bDontHide && bExecState && pWnd->IsChanged());
554 
555  m_xTbx1->set_item_sensitive("TBI_WORKPLACE", !bPipette && bDrawEnabled);
556 
557  m_xTbx1->set_item_sensitive("TBI_SELECT", bDontHide && bDrawEnabled);
558  m_xTbx1->set_item_sensitive("TBI_RECT", bDontHide && bDrawEnabled);
559  m_xTbx1->set_item_sensitive("TBI_CIRCLE", bDontHide && bDrawEnabled);
560  m_xTbx1->set_item_sensitive("TBI_POLY", bDontHide && bDrawEnabled);
561 
562  m_xTbx1->set_item_sensitive("TBI_POLYEDIT", bDontHide && bPolyEdit);
563  m_xTbx1->set_item_sensitive("TBI_POLYMOVE", bDontHide && !bDrawEnabled);
564  m_xTbx1->set_item_sensitive("TBI_POLYINSERT", bDontHide && !bDrawEnabled);
565  m_xTbx1->set_item_sensitive("TBI_POLYDELETE", bDontHide && !bDrawEnabled && pView->IsDeleteMarkedPointsPossible());
566 
567  m_xTbx1->set_item_sensitive("TBI_AUTOCONTOUR", bDontHide && bDrawEnabled);
568  m_xTbx1->set_item_sensitive("TBI_PIPETTE", !bWorkplace && bDrawEnabled && bBitmap);
569 
570  m_xTbx1->set_item_sensitive("TBI_UNDO", bDontHide && aUndoGraphic.GetType() != GraphicType::NONE);
571  m_xTbx1->set_item_sensitive("TBI_REDO", bDontHide && aRedoGraphic.GetType() != GraphicType::NONE);
572 
573  if ( bPolyEdit )
574  {
575  switch( pWnd->GetPolyEditMode() )
576  {
577  case SID_BEZIER_MOVE:
578  SetActivePoly("TBI_POLYMOVE");
579  break;
580  case SID_BEZIER_INSERT:
581  SetActivePoly("TBI_POLYINSERT");
582  break;
583  default:
584  break;
585  }
586  }
587  else
588  {
589  m_xTbx1->set_item_active("TBI_POLYEDIT", false);
590  SetActivePoly("TBI_POLYMOVE");
591  pWnd->SetPolyEditMode( 0 );
592  }
593 }
594 
596 {
597  m_xStbStatusColor->Invalidate();
598 }
599 
601 {
602  const Color& rOldLineColor = rDevice.GetLineColor();
603  const Color& rOldFillColor = rDevice.GetFillColor();
604 
606  const Color& rColor = m_rWnd.GetPipetteColor();
607 
608  rDevice.SetLineColor(rColor);
609  rDevice.SetFillColor(rColor);
610 
611  aRect.AdjustLeft(4 );
612  aRect.AdjustTop(4 );
613  aRect.AdjustRight( -4 );
614  aRect.AdjustBottom( -4 );
615 
616  rDevice.DrawRect( aRect );
617 
618  rDevice.SetLineColor(rOldLineColor);
619  rDevice.SetFillColor(rOldFillColor);
620 }
621 
622 IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow&, rWnd, void )
623 {
624  if ( rWnd.IsClickValid() )
625  {
626  const Color& rColor = rWnd.GetPipetteColor();
627 
628  weld::WaitObject aWaitObj(&m_rDialog);
629 
630  if( aGraphic.GetType() == GraphicType::Bitmap )
631  {
632  const tools::Long nTol = static_cast<tools::Long>(m_xMtfTolerance->get_value(FieldUnit::PERCENT) * 255 / 100);
633 
634  Bitmap aMask = aGraphic.GetBitmapEx().GetBitmap().CreateMask( rColor, nTol );
635 
636  if( aGraphic.IsTransparent() )
637  aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BmpCombine::Or );
638 
639  if( !!aMask )
640  {
641  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&m_rDialog, "svx/ui/querynewcontourdialog.ui"));
642  std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QueryNewContourDialog"));
643 
644  bool bNewContour;
645 
646  aRedoGraphic = Graphic();
647  aUndoGraphic = aGraphic;
648  Bitmap aBmp = aGraphic.GetBitmapEx().GetBitmap();
649  aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
650  mnGrfChanged++;
651 
652  bNewContour = (xQBox->run() == RET_YES);
653  rWnd.SetGraphic( aGraphic, bNewContour );
654 
655  if( bNewContour )
656  aCreateIdle.Start();
657  }
658  }
659  }
660 
661  m_xTbx1->set_item_active("TBI_PIPETTE", false);
662  rWnd.SetPipetteMode( false );
663  m_xStbStatusColor->Invalidate();
664 }
665 
666 IMPL_LINK( SvxSuperContourDlg, WorkplaceClickHdl, ContourWindow&, rWnd, void )
667 {
668  m_xTbx1->set_item_active("TBI_WORKPLACE", false);
669  m_xTbx1->set_item_active("TBI_SELECT", true);
670  rWnd.SetWorkplaceMode( false );
671 
672  m_xContourWnd->QueueIdleUpdate();
673 }
674 
675 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< SfxDialogController > & GetController()
bool GetValue() const
Bitmap GetMask() const
FieldUnit
line
Definition: svdobjkind.hxx:29
void Initialize(SfxChildWinInfo const *pInfo)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
void setWidth(tools::Long nWidth)
rectangle (round corners optional)
Definition: svdobjkind.hxx:30
const Color & GetPipetteColor() const
Definition: contwnd.hxx:54
bool bUpdateGraphicLinked
Definition: contimp.hxx:78
long Long
Graphic aUndoGraphic
Definition: contimp.hxx:66
static const AllSettings & GetSettings()
SvxContourDlgChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo const *)
Definition: _contdlg.cxx:59
constexpr OUStringLiteral PERCENT(u"Percent")
circle cut
Definition: svdobjkind.hxx:34
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
bool IsTransparent() const
BitmapEx maBitmapEx
RET_CANCEL
std::unique_ptr< weld::Toolbar > m_xTbx1
Definition: contimp.hxx:84
Size const & GetOutputSizePixel() const
SvxContourDlgItem(SvxSuperContourDlg &rDlg, SfxBindings &rBindings)
Definition: _contdlg.cxx:42
static OutputDevice * GetDefaultDevice()
weld::Window * GetFrameWeld() const
void SetExecState(bool bEnable)
Definition: _contdlg.cxx:267
sal_uInt16 sal_Unicode
bool CombineSimple(const Bitmap &rMask, BmpCombine eCombine)
const Graphic & GetGraphic() const
Definition: _contdlg.cxx:166
RET_YES
tools::Long Left() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static tools::PolyPolygon CreateAutoContour(const Graphic &rGraphic, const tools::Rectangle *pRect=nullptr)
Definition: _contdlg.cxx:79
int nCount
tools::Long Bottom() const
Graphic aRedoGraphic
Definition: contimp.hxx:67
virtual void Start() override
std::unique_ptr< weld::Button > m_xCancelBtn
Definition: contimp.hxx:88
const GDIMetaFile & GetGDIMetaFile() const
Graphic aGraphic
Definition: contimp.hxx:65
tools::PolyPolygon GetPolyPolygon()
Definition: _contdlg.cxx:176
bool IsGraphicChanged() const
Definition: _contdlg.cxx:171
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::PolyPolygon aUpdatePolyPoly
Definition: contimp.hxx:69
bool IsDeleteMarkedPointsPossible() const override
Definition: svdpoev.cxx:281
bool IsAnimated() const
void DrawRect(const tools::Rectangle &rRect)
const void * GetEditingObject() const
Definition: _contdlg.cxx:181
void UpdateGraphic(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
Definition: _contdlg.cxx:336
virtual ~SvxContourDlg() override
Definition: _contdlg.cxx:75
Animation GetAnimation() const
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxContourDlgChildWindow, SID_CONTOUR_DLG)
const OUString & getNumDecimalSep() const
void SetPrefMapMode(const MapMode &rMapMode)
void SetLineColor()
OUString GetUnitString(tools::Long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
Definition: dlgunit.hxx:27
#define DBG_ASSERT(sCon, aError)
Graphic aUpdateGraphic
Definition: contimp.hxx:68
int i
GraphicType GetType() const
tools::Long FRound(double fVal)
IMPL_LINK_NOARG(SvxSuperContourDlg, CancelHdl, weld::Button &, void)
Definition: _contdlg.cxx:240
std::unique_ptr< weld::MetricSpinButton > m_xMtfTolerance
Definition: contimp.hxx:85
tools::PolyPolygon GetPolyPolygon()
Definition: _contdlg.cxx:309
void SetActiveTool(const OString &rId)
Definition: _contdlg.cxx:459
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: _contdlg.cxx:48
void SetOrigin(const Point &rOrigin)
void SetFillColor()
tools::Long Width() const
const Color & GetLineColor() const
void SetPrefSize(const Size &rSize)
SvxSuperContourDlg & rDlg
Definition: contimp.hxx:30
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
sal_uInt16 GetSize() const
IMPL_LINK(SvxSuperContourDlg, Tbx1ClickHdl, const OString &, rId, void)
Definition: _contdlg.cxx:353
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
tools::Long Top() const
Abstract DrawObject.
Definition: svdobj.hxx:260
void SetPolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: _contdlg.cxx:280
void * pUpdateEditingObject
Definition: contimp.hxx:73
tools::Long AdjustTop(tools::Long nVertMoveDelta)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Size GetPrefSize() const
std::unique_ptr< ContourWindow > m_xContourWnd
Definition: contimp.hxx:82
SfxItemState
MapMode GetPrefMapMode() const
bool Convert(BmpConversion eConversion)
void SetController(std::shared_ptr< SfxDialogController > controller)
Reference< XExecutableDialog > m_xDialog
tools::Long Height() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void SetGraphic(const Graphic &rGraphic)
Definition: _contdlg.cxx:272
void setHeight(tools::Long nHeight)
SvxSuperContourDlg(weld::Builder &rBuilder, weld::Dialog &rDialog, SfxBindings *pBindings)
Definition: _contdlg.cxx:192
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
void Update(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
Definition: _contdlg.cxx:186
void SetPriority(TaskPriority ePriority)
sal_Int32 mnGrfChanged
Definition: contimp.hxx:76
ContourWindow & m_rWnd
Definition: contimp.hxx:46
std::unique_ptr< SvxSuperContourDlg > m_xImpl
Definition: contdlg.hxx:54
Bitmap CreateMask(const Color &rTransColor, sal_uInt8 nTol=0) const
aStr
tools::Long Right() const
const Color & GetFillColor() const
SvxContourDlg(SfxBindings *pBindings, SfxChildWindow *pCW, weld::Window *pParent)
Definition: _contdlg.cxx:68
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: _contdlg.cxx:600
void SetActivePoly(const OString &rId)
Definition: _contdlg.cxx:467