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
48void SvxContourDlgItem::StateChangedAtToolBoxControl( 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 AnimationFrame& 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().GetAlphaMask();
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
186void 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
229
230 aCreateIdle.SetPriority( TaskPriority::RESIZE );
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 );
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
336void 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
349}
350
351// Click handler for ToolBox
352
353IMPL_LINK(SvxSuperContourDlg, Tbx1ClickHdl, const OUString&, rId, void)
354{
355 if (rId == "TBI_APPLY")
356 {
357 SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, true );
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( SdrObjKind::Rectangle );
386 }
387 else if (rId == "TBI_CIRCLE")
388 {
389 SetActiveTool(rId);
390 m_xContourWnd->SetObjKind( SdrObjKind::CircleOrEllipse );
391 }
392 else if (rId == "TBI_POLY")
393 {
394 SetActiveTool(rId);
395 m_xContourWnd->SetObjKind( SdrObjKind::Polygon );
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
459void SvxSuperContourDlg::SetActiveTool(std::u16string_view rId)
460{
461 m_xTbx1->set_item_active("TBI_SELECT", rId == u"TBI_SELECT");
462 m_xTbx1->set_item_active("TBI_RECT", rId == u"TBI_RECT");
463 m_xTbx1->set_item_active("TBI_CIRCLE", rId == u"TBI_CIRCLE");
464 m_xTbx1->set_item_active("TBI_POLY", rId == u"TBI_POLY");
465}
466
467void SvxSuperContourDlg::SetActivePoly(std::u16string_view rId)
468{
469 m_xTbx1->set_item_active("TBI_POLYMOVE", rId == u"TBI_POLYMOVE");
470 m_xTbx1->set_item_active("TBI_POLYINSERT", rId == u"TBI_POLYINSERT");
471}
472
473IMPL_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
488IMPL_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
542IMPL_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(u"TBI_POLYMOVE");
579 break;
580 case SID_BEZIER_INSERT:
581 SetActivePoly(u"TBI_POLYINSERT");
582 break;
583 default:
584 break;
585 }
586 }
587 else
588 {
589 m_xTbx1->set_item_active("TBI_POLYEDIT", false);
590 SetActivePoly(u"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
622IMPL_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.CombineOr( aGraphic.GetBitmapEx().GetAlphaMask() );
638
639 if( !aMask.IsEmpty() )
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
666IMPL_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: */
IMPL_LINK_NOARG(SvxSuperContourDlg, CancelHdl, weld::Button &, void)
Definition: _contdlg.cxx:240
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxContourDlgChildWindow, SID_CONTOUR_DLG)
IMPL_LINK(SvxSuperContourDlg, Tbx1ClickHdl, const OUString &, rId, void)
Definition: _contdlg.cxx:353
Reference< XExecutableDialog > m_xDialog
size_t Count() const
const Size & GetDisplaySizePixel() const
const AnimationFrame & Get(sal_uInt16 nAnimation) const
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
bool CombineOr(const Bitmap &rMask)
void SetPrefMapMode(const MapMode &rMapMode)
Bitmap CreateMask(const Color &rTransColor) const
bool Convert(BmpConversion eConversion)
bool IsEmpty() const
void SetPrefSize(const Size &rSize)
const Color & GetPipetteColor() const
Definition: contwnd.hxx:54
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
Size GetPrefSize() const
Animation GetAnimation() const
const GDIMetaFile & GetGDIMetaFile() const
GraphicType GetType() const
bool IsAnimated() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
MapMode GetPrefMapMode() const
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
bool IsTransparent() const
virtual void Start(bool bStartTimer=true) override
const OUString & getNumDecimalSep() const
void SetOrigin(const Point &rOrigin)
MapUnit GetMapUnit() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetFillColor()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const Color & GetLineColor() const
const Color & GetFillColor() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
Abstract DrawObject.
Definition: svdobj.hxx:260
bool IsDeleteMarkedPointsPossible() const override
Definition: svdpoev.cxx:281
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
bool GetValue() const
void SetController(std::shared_ptr< SfxDialogController > controller)
std::shared_ptr< SfxDialogController > & GetController()
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxModule * GetModule() const
void Initialize(SfxChildWinInfo const *pInfo)
FieldUnit GetFieldUnit() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
ContourWindow & m_rWnd
Definition: contimp.hxx:46
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: _contdlg.cxx:600
SvxContourDlgChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo const *)
Definition: _contdlg.cxx:59
SvxContourDlgItem(SvxSuperContourDlg &rDlg, SfxBindings &rBindings)
Definition: _contdlg.cxx:42
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: _contdlg.cxx:48
SvxSuperContourDlg & rDlg
Definition: contimp.hxx:30
void Update(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
Definition: _contdlg.cxx:186
bool IsGraphicChanged() const
Definition: _contdlg.cxx:171
SvxContourDlg(SfxBindings *pBindings, SfxChildWindow *pCW, weld::Window *pParent)
Definition: _contdlg.cxx:68
const void * GetEditingObject() const
Definition: _contdlg.cxx:181
const Graphic & GetGraphic() const
Definition: _contdlg.cxx:166
std::unique_ptr< SvxSuperContourDlg > m_xImpl
Definition: contdlg.hxx:53
virtual ~SvxContourDlg() override
Definition: _contdlg.cxx:75
tools::PolyPolygon GetPolyPolygon()
Definition: _contdlg.cxx:176
static tools::PolyPolygon CreateAutoContour(const Graphic &rGraphic, const tools::Rectangle *pRect=nullptr)
Definition: _contdlg.cxx:79
SvxSuperContourDlg(weld::Builder &rBuilder, weld::Dialog &rDialog, SfxBindings *pBindings)
Definition: _contdlg.cxx:192
void SetExecState(bool bEnable)
Definition: _contdlg.cxx:267
std::unique_ptr< ContourWindow > m_xContourWnd
Definition: contimp.hxx:82
Graphic aGraphic
Definition: contimp.hxx:65
void SetActivePoly(std::u16string_view rId)
Definition: _contdlg.cxx:467
std::unique_ptr< weld::Toolbar > m_xTbx1
Definition: contimp.hxx:84
tools::PolyPolygon GetPolyPolygon()
Definition: _contdlg.cxx:309
Graphic aUpdateGraphic
Definition: contimp.hxx:68
Graphic aRedoGraphic
Definition: contimp.hxx:67
void UpdateGraphic(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
Definition: _contdlg.cxx:336
void * pUpdateEditingObject
Definition: contimp.hxx:73
void SetGraphic(const Graphic &rGraphic)
Definition: _contdlg.cxx:272
std::unique_ptr< weld::Button > m_xCancelBtn
Definition: contimp.hxx:88
void SetActiveTool(std::u16string_view rId)
Definition: _contdlg.cxx:459
void SetPolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: _contdlg.cxx:280
Graphic aUndoGraphic
Definition: contimp.hxx:66
tools::PolyPolygon aUpdatePolyPoly
Definition: contimp.hxx:69
bool bUpdateGraphicLinked
Definition: contimp.hxx:78
sal_Int32 mnGrfChanged
Definition: contimp.hxx:76
std::unique_ptr< weld::MetricSpinButton > m_xMtfTolerance
Definition: contimp.hxx:85
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
sal_uInt16 Count() const
sal_uInt16 GetSize() const
constexpr tools::Long Top() const
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
weld::Window * GetFrameWeld() const
Size const & GetOutputSizePixel() const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
int nCount
#define DBG_ASSERT(sCon, aError)
virtual SfxBindings & GetBindings() override
OUString GetUnitString(tools::Long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
Definition: dlgunit.hxx:27
float u
FieldUnit
tools::Long FRound(double fVal)
aStr
int i
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
long Long
sal_Int16 nId
SfxItemState
Point maPositionPixel
BitmapEx maBitmapEx
@ Polygon
circle cut
@ CircleOrEllipse
rectangle (round corners optional)
@ Rectangle
line
sal_uInt16 sal_Unicode
constexpr OUStringLiteral PERCENT(u"Percent")
RET_CANCEL
RET_YES