29#include <svx/svxids.hrc>
50 if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
83 bool bContourEdgeDetect =
false;
85 if ( rGraphic.
GetType() == GraphicType::Bitmap )
95 if ( pVDev->SetOutputSizePixel( rSizePix ) )
107 pVDev->SetMapMode( aTransMap );
112 pVDev->SetMapMode( aTransMap );
113 aBmp = pVDev->GetBitmap(
Point(), rSizePix );
114 aBmp.
Convert( BmpConversion::N1BitThreshold );
122 bContourEdgeDetect =
true;
125 else if( rGraphic.
GetType() != GraphicType::NONE )
133 double fWH =
static_cast<double>(aSizePix.
Width()) / aSizePix.
Height();
147 if( pVDev->SetOutputSizePixel( aSizePix ) )
150 aTmpGrf.
Draw(*pVDev, aPt, aSizePix);
151 aBmp = pVDev->GetBitmap( aPt, aSizePix );
154 bContourEdgeDetect =
true;
173 return m_xImpl->IsGraphicChanged();
178 return m_xImpl->GetPolyPolygon();
183 return m_xImpl->GetEditingObject();
189 m_xImpl->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
194 : aUpdateIdle(
"SvxSuperContourDlg UpdateIdle" )
195 , aCreateIdle(
"SvxSuperContourDlg CreateIdle" )
196 , mpBindings(pBindings)
197 , pUpdateEditingObject( nullptr )
198 , pCheckObj( nullptr )
199 , aContourItem( *this, *pBindings )
201 , bExecState( false )
202 , bUpdateGraphicLinked( false )
203 , bGraphicLinked( false )
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))
244 if (m_xTbx1->get_item_sensitive(
"TBI_APPLY"))
247 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog(
"QuerySaveContourChangesDialog"));
248 const short nRet = xQBox->run();
254 SID_CONTOUR_EXEC, SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
285 const MapMode aMap100( MapUnit::Map100thMM );
288 bool bPixelMap = aGrfMap.
GetMapUnit() == MapUnit::MapPixel;
290 for ( sal_uInt16 j = 0, nPolyCount = aPolyPoly.
Count(); j < nPolyCount; j++ )
313 const MapMode aMap100( MapUnit::Map100thMM );
316 bool bPixelMap = aGrfMap.
GetMapUnit() == MapUnit::MapPixel;
318 for ( sal_uInt16 j = 0, nPolyCount = aRetPolyPoly.
Count(); j < nPolyCount; j++ )
355 if (rId ==
"TBI_APPLY")
359 SID_CONTOUR_EXEC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
362 else if (rId ==
"TBI_WORKPLACE")
364 if (m_xTbx1->get_item_active(
"TBI_WORKPLACE"))
367 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog(
"QueryDeleteContourDialog"));
369 if (!m_xContourWnd->IsContourChanged() || (xQBox->run() ==
RET_YES))
370 m_xContourWnd->SetWorkplaceMode(
true );
372 m_xTbx1->set_item_active(
"TBI_WORKPLACE",
false);
375 m_xContourWnd->SetWorkplaceMode(
false );
377 else if (rId ==
"TBI_SELECT")
380 m_xContourWnd->SetEditMode(
true );
382 else if (rId ==
"TBI_RECT")
387 else if (rId ==
"TBI_CIRCLE")
392 else if (rId ==
"TBI_POLY")
397 else if (rId ==
"TBI_POLYEDIT")
399 m_xContourWnd->SetPolyEditMode(m_xTbx1->get_item_active(
"TBI_POLYEDIT") ? SID_BEZIER_MOVE : 0);
401 else if (rId ==
"TBI_POLYMOVE")
404 m_xContourWnd->SetPolyEditMode( SID_BEZIER_MOVE );
406 else if (rId ==
"TBI_POLYINSERT")
409 m_xContourWnd->SetPolyEditMode( SID_BEZIER_INSERT );
411 else if (rId ==
"TBI_POLYDELETE")
413 m_xContourWnd->GetSdrView()->DeleteMarkedPoints();
415 else if (rId ==
"TBI_UNDO")
417 mnGrfChanged = mnGrfChanged ? mnGrfChanged - 1 : 0;
418 aRedoGraphic = aGraphic;
419 aGraphic = aUndoGraphic;
421 m_xContourWnd->SetGraphic( aGraphic,
false );
423 else if (rId ==
"TBI_REDO")
426 aUndoGraphic = aGraphic;
427 aGraphic = aRedoGraphic;
429 m_xContourWnd->SetGraphic( aGraphic,
false );
431 else if (rId ==
"TBI_AUTOCONTOUR")
435 else if (rId ==
"TBI_PIPETTE")
437 bool bPipette = m_xTbx1->get_item_active(
"TBI_PIPETTE");
440 m_xStbStatusColor->Invalidate();
441 else if ( bGraphicLinked )
444 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog(
"QueryUnlinkGraphicsDialog"));
449 m_xTbx1->set_item_active(
"TBI_PIPETTE", bPipette);
450 m_xStbStatusColor->Invalidate();
454 m_xContourWnd->SetPipetteMode( bPipette );
456 m_xContourWnd->QueueIdleUpdate();
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");
469 m_xTbx1->set_item_active(
"TBI_POLYMOVE", rId ==
u"TBI_POLYMOVE");
470 m_xTbx1->set_item_active(
"TBI_POLYINSERT", rId ==
u"TBI_POLYINSERT");
477 const Point& rMousePos = pWnd->GetMousePos();
485 m_xStbStatus2->set_label(
aStr );
492 const Size& rSize = pWnd->GetGraphicSize();
500 m_xStbStatus3->set_label(
aStr );
507 if ( pUpdateEditingObject != pCheckObj )
509 if( !GetEditingObject() )
510 m_xContourWnd->GrabFocus();
512 SetGraphic( aUpdateGraphic );
513 SetPolyPolygon( aUpdatePolyPoly );
514 pCheckObj = pUpdateEditingObject;
515 bGraphicLinked = bUpdateGraphicLinked;
519 bUpdateGraphicLinked =
false;
521 m_xContourWnd->GetSdrModel()->SetChanged(
false );
525 m_xContourWnd->QueueIdleUpdate();
532 const tools::Rectangle aWorkRect = m_xContourWnd->GetDrawingArea()->get_ref_device().LogicToPixel(
533 m_xContourWnd->GetWorkRect(),
MapMode( MapUnit::Map100thMM));
535 const Graphic& rGraphic = m_xContourWnd->GetGraphic();
536 const bool bValid = aWorkRect.
Left() != aWorkRect.
Right() && aWorkRect.
Top() != aWorkRect.
Bottom();
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;
553 m_xTbx1->set_item_sensitive(
"TBI_APPLY", bDontHide && bExecState && pWnd->IsChanged());
555 m_xTbx1->set_item_sensitive(
"TBI_WORKPLACE", !bPipette && bDrawEnabled);
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);
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);
567 m_xTbx1->set_item_sensitive(
"TBI_AUTOCONTOUR", bDontHide && bDrawEnabled);
568 m_xTbx1->set_item_sensitive(
"TBI_PIPETTE", !bWorkplace && bDrawEnabled && bBitmap);
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);
575 switch( pWnd->GetPolyEditMode() )
577 case SID_BEZIER_MOVE:
578 SetActivePoly(
u"TBI_POLYMOVE");
580 case SID_BEZIER_INSERT:
581 SetActivePoly(
u"TBI_POLYINSERT");
589 m_xTbx1->set_item_active(
"TBI_POLYEDIT",
false);
590 SetActivePoly(
u"TBI_POLYMOVE");
591 pWnd->SetPolyEditMode( 0 );
597 m_xStbStatusColor->Invalidate();
624 if ( rWnd.IsClickValid() )
626 const Color& rColor = rWnd.GetPipetteColor();
630 if( aGraphic.GetType() == GraphicType::Bitmap )
632 const tools::Long nTol =
static_cast<tools::Long>(m_xMtfTolerance->get_value(FieldUnit::PERCENT) * 255 / 100);
634 Bitmap aMask = aGraphic.GetBitmapEx().GetBitmap().
CreateMask( rColor, nTol );
636 if( aGraphic.IsTransparent() )
637 aMask.
CombineOr( aGraphic.GetBitmapEx().GetAlphaMask() );
642 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog(
"QueryNewContourDialog"));
647 aUndoGraphic = aGraphic;
648 Bitmap aBmp = aGraphic.GetBitmapEx().GetBitmap();
652 bNewContour = (xQBox->run() ==
RET_YES);
653 rWnd.SetGraphic( aGraphic, bNewContour );
661 m_xTbx1->set_item_active(
"TBI_PIPETTE",
false);
662 rWnd.SetPipetteMode(
false );
663 m_xStbStatusColor->Invalidate();
668 m_xTbx1->set_item_active(
"TBI_WORKPLACE",
false);
669 m_xTbx1->set_item_active(
"TBI_SELECT",
true);
670 rWnd.SetWorkplaceMode(
false );
672 m_xContourWnd->QueueIdleUpdate();
IMPL_LINK_NOARG(SvxSuperContourDlg, CancelHdl, weld::Button &, void)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxContourDlgChildWindow, SID_CONTOUR_DLG)
IMPL_LINK(SvxSuperContourDlg, Tbx1ClickHdl, const OUString &, rId, void)
Reference< XExecutableDialog > m_xDialog
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)
void SetPrefSize(const Size &rSize)
const Color & GetPipetteColor() const
Animation GetAnimation() const
const GDIMetaFile & GetGDIMetaFile() const
GraphicType GetType() 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)
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
bool IsDeleteMarkedPointsPossible() const override
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
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
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
SvxContourDlgChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo const *)
SvxContourDlgItem(SvxSuperContourDlg &rDlg, SfxBindings &rBindings)
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
SvxSuperContourDlg & rDlg
void Update(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
bool IsGraphicChanged() const
SvxContourDlg(SfxBindings *pBindings, SfxChildWindow *pCW, weld::Window *pParent)
const void * GetEditingObject() const
const Graphic & GetGraphic() const
std::unique_ptr< SvxSuperContourDlg > m_xImpl
virtual ~SvxContourDlg() override
tools::PolyPolygon GetPolyPolygon()
static tools::PolyPolygon CreateAutoContour(const Graphic &rGraphic, const tools::Rectangle *pRect=nullptr)
SvxSuperContourDlg(weld::Builder &rBuilder, weld::Dialog &rDialog, SfxBindings *pBindings)
void SetExecState(bool bEnable)
std::unique_ptr< ContourWindow > m_xContourWnd
void SetActivePoly(std::u16string_view rId)
std::unique_ptr< weld::Toolbar > m_xTbx1
tools::PolyPolygon GetPolyPolygon()
void UpdateGraphic(const Graphic &rGraphic, bool bGraphicLinked, const tools::PolyPolygon *pPolyPoly, void *pEditingObj)
void * pUpdateEditingObject
void SetGraphic(const Graphic &rGraphic)
std::unique_ptr< weld::Button > m_xCancelBtn
void SetActiveTool(std::u16string_view rId)
void SetPolyPolygon(const tools::PolyPolygon &rPolyPoly)
tools::PolyPolygon aUpdatePolyPoly
bool bUpdateGraphicLinked
std::unique_ptr< weld::MetricSpinButton > m_xMtfTolerance
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
weld::Window * GetFrameWeld() const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
virtual SfxBindings & GetBindings() override
OUString GetUnitString(tools::Long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
tools::Long FRound(double fVal)
#define LINK(Instance, Class, Member)
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
@ CircleOrEllipse
rectangle (round corners optional)
constexpr OUStringLiteral PERCENT(u"Percent")