From a4d35e9ed6b26d329d05bc4f39e21aac34510e0a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 10 May 2018 16:42:15 +0100 Subject: weld SdVectorizeDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I15469be36807bcfca9882d04dd5d55933692abf7 Reviewed-on: https://gerrit.libreoffice.org/54092 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svx/graphctl.hxx | 53 ++++++++++---- include/vcl/weld.hxx | 8 +++ sd/inc/sdabstdlg.hxx | 2 +- sd/qa/unit/dialogs-test.cxx | 3 +- sd/source/ui/dlg/sddlgfact.cxx | 13 ++-- sd/source/ui/dlg/sddlgfact.hxx | 11 ++- sd/source/ui/dlg/vectdlg.cxx | 146 +++++++++++++++++--------------------- sd/source/ui/func/fuvect.cxx | 2 +- sd/source/ui/inc/vectdlg.hxx | 54 ++++++-------- sd/uiconfig/sdraw/ui/vectorize.ui | 100 ++++++++++++++++++-------- svx/source/dialog/graphctl.cxx | 72 +++++++++++++++++++ vcl/source/app/salvtables.cxx | 25 +++++++ vcl/unx/gtk3/gtk3gtkinst.cxx | 27 +++++++ 13 files changed, 350 insertions(+), 166 deletions(-) diff --git a/include/svx/graphctl.hxx b/include/svx/graphctl.hxx index f32454a56ae4..13d323c48a93 100644 --- a/include/svx/graphctl.hxx +++ b/include/svx/graphctl.hxx @@ -21,12 +21,27 @@ #include #include +#include #include #include #include -class GraphCtrlUserCall; +class GraphCtrl; + +class GraphCtrlUserCall : public SdrObjUserCall +{ + GraphCtrl& rWin; + +public: + + GraphCtrlUserCall(GraphCtrl& rGraphWin) + : rWin(rGraphWin) + {} + + virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override; +}; + class SvxGraphCtrlAccessibleContext; class SVX_DLLPUBLIC GraphCtrl : public Control @@ -71,7 +86,7 @@ protected: virtual void SdrObjChanged( const SdrObject& rObj ); virtual void MarkListHasChanged(); - inline SdrObjUserCall* GetSdrUserCall(); + SdrObjUserCall* GetSdrUserCall() { return pUserCall; } public: @@ -109,24 +124,34 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; }; - -class GraphCtrlUserCall : public SdrObjUserCall +class SVX_DLLPUBLIC SvxGraphCtrl { - GraphCtrl& rWin; + MapMode aMap100; + Graphic aGraphic; + Size aGraphSize; + Size maSize; + + std::unique_ptr mxDrawingArea; + + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoResize, const Size& rSize, void); public: - GraphCtrlUserCall(GraphCtrl& rGraphWin) - : rWin(rGraphWin) - {} + SvxGraphCtrl(weld::Builder& rBuilder, const OString& rDrawingId); + virtual ~SvxGraphCtrl(); - virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override; -}; + void SetGraphic( const Graphic& rGraphic ); + const Graphic& GetGraphic() const { return aGraphic; } + const Size& GetGraphicSize() const { return aGraphSize; } -SdrObjUserCall* GraphCtrl::GetSdrUserCall() -{ - return pUserCall; -} + const Size& GetSize() const { return maSize; } + + void set_size_request(int nWidth, int nHeight) + { + mxDrawingArea->set_size_request(nWidth, nHeight); + } +}; class GraphCtrlView : public SdrView { diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index b7f53ab0e057..306dc4fedebf 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -444,6 +444,13 @@ public: void connect_value_changed(const Link& rLink) { m_aValueChangedHdl = rLink; } }; +class VCL_DLLPUBLIC ProgressBar : virtual public Widget +{ +public: + //0-100 + virtual void set_percentage(int value) = 0; +}; + class VCL_DLLPUBLIC Entry : virtual public Widget { private: @@ -868,6 +875,7 @@ public: virtual Expander* weld_expander(const OString& id, bool bTakeOwnership = false) = 0; virtual Entry* weld_entry(const OString& id, bool bTakeOwnership = false) = 0; virtual Scale* weld_scale(const OString& id, bool bTakeOwnership = false) = 0; + virtual ProgressBar* weld_progress_bar(const OString& id, bool bTakeOwnership = false) = 0; virtual DrawingArea* weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr, bool bTakeOwnership = false) diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx index 1cd4f51d11e7..8595a6044252 100644 --- a/sd/inc/sdabstdlg.hxx +++ b/sd/inc/sdabstdlg.hxx @@ -197,7 +197,7 @@ public: virtual VclPtr CreateSdPresLayoutDlg( ::sd::DrawDocShell* pDocShell, const SfxItemSet& rInAttrs) = 0; virtual VclPtr CreateSdTabTemplateDlg(vcl::Window* pParent, const SfxObjectShell* pDocShell, SfxStyleSheetBase& rStyleBase, SdrModel* pModel, SdrView* pView) = 0; virtual VclPtr CreatSdActionDialog(vcl::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView) = 0; - virtual VclPtr CreateSdVectorizeDlg( vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell ) = 0; + virtual VclPtr CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) = 0; virtual VclPtr CreateSdPublishingDlg( vcl::Window* pWindow, DocumentType eDocType) = 0; virtual VclPtr CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) = 0; diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx index a4a0a049bd7a..a4c9c067aa86 100644 --- a/sd/qa/unit/dialogs-test.cxx +++ b/sd/qa/unit/dialogs-test.cxx @@ -545,8 +545,9 @@ VclPtr SdDialogsTest::createDialogByID(sal_uInt32 nID) // CreateSdVectorizeDlg(vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override; // works well with empty Bitmap, but my be nicer with setting one Bitmap aEmptyBitmap; + auto const parent = Application::GetDefDialogParent(); pRetval = getSdAbstractDialogFactory()->CreateSdVectorizeDlg( - Application::GetDefDialogParent(), + parent == nullptr ? nullptr : parent->GetFrameWeld(), aEmptyBitmap, getDocShell()); break; diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index 180d63d95441..c0b8d950d158 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -82,7 +82,12 @@ short AbstractSdStartPresDlg_Impl::Execute() IMPL_ABSTDLG_BASE(AbstractSdPresLayoutDlg_Impl); IMPL_ABSTDLG_BASE(SdAbstractSfxDialog_Impl); -IMPL_ABSTDLG_BASE(AbstractSdVectorizeDlg_Impl); + +short AbstractSdVectorizeDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + IMPL_ABSTDLG_BASE(AbstractSdPublishingDlg_Impl); IMPL_ABSTDLG_BASE(AbstractHeaderFooterDialog_Impl); IMPL_ABSTDLG_BASE(AbstractBulletDialog_Impl); @@ -300,7 +305,7 @@ void SdAbstractSfxDialog_Impl::SetText( const OUString& rStr ) const GDIMetaFile& AbstractSdVectorizeDlg_Impl::GetGDIMetaFile() const { - return pDlg->GetGDIMetaFile(); + return m_xDlg->GetGDIMetaFile(); } void AbstractSdPublishingDlg_Impl::GetParameterSequence( css::uno::Sequence< css::beans::PropertyValue >& rParams ) @@ -408,9 +413,9 @@ VclPtr SdAbstractDialogFactory_Impl::CreatSdActionDialog(vcl: return VclPtr::Create( VclPtr::Create( pParent, pAttr, pView ) ); } -VclPtr SdAbstractDialogFactory_Impl::CreateSdVectorizeDlg( vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell ) +VclPtr SdAbstractDialogFactory_Impl::CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) { - return VclPtr::Create( VclPtr::Create( pParent, rBmp, pDocShell ) ); + return VclPtr::Create(new SdVectorizeDlg(pParent, rBmp, pDocShell)); } VclPtr SdAbstractDialogFactory_Impl::CreateSdPublishingDlg( vcl::Window* pParent, DocumentType eDocType) diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index 8008f4c7b5d2..55765fb23861 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -237,7 +237,14 @@ class SdAbstractSfxDialog_Impl : public SfxAbstractDialog class SdVectorizeDlg; class AbstractSdVectorizeDlg_Impl :public AbstractSdVectorizeDlg { - DECL_ABSTDLG_BASE(AbstractSdVectorizeDlg_Impl,SdVectorizeDlg) +private: + std::unique_ptr m_xDlg; +public: + AbstractSdVectorizeDlg_Impl(SdVectorizeDlg* pDlg) + : m_xDlg(pDlg) + { + } + virtual short Execute() override; virtual const GDIMetaFile& GetGDIMetaFile() const override ; }; @@ -279,7 +286,7 @@ public: virtual VclPtr CreateSdPresLayoutDlg( ::sd::DrawDocShell* pDocShell, const SfxItemSet& rInAttrs) override; virtual VclPtr CreateSdTabTemplateDlg(vcl::Window* pParent, const SfxObjectShell* pDocShell, SfxStyleSheetBase& rStyleBase, SdrModel* pModel, SdrView* pView ) override; virtual VclPtr CreatSdActionDialog(vcl::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView) override; - virtual VclPtr CreateSdVectorizeDlg(vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override; + virtual VclPtr CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override; virtual VclPtr CreateSdPublishingDlg(vcl::Window* pWindow, DocumentType eDocType) override; virtual VclPtr CreateSdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pDoc) override; diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index 44ed925dc767..145bc94fd3f5 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -30,39 +30,32 @@ #define VECTORIZE_MAX_EXTENT 512 -SdVectorizeDlg::SdVectorizeDlg(vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) - : ModalDialog(pParent, "VectorizeDialog", "modules/sdraw/ui/vectorize.ui") - , mpDocSh(pDocShell) +SdVectorizeDlg::SdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) + : GenericDialogController(pParent, "modules/sdraw/ui/vectorize.ui", "VectorizeDialog") + , m_pDocSh(pDocShell) , aBmp(rBmp) + , m_xNmLayers(m_xBuilder->weld_spin_button("colors")) + , m_xMtReduce(m_xBuilder->weld_metric_spin_button("points", FUNIT_PIXEL)) + , m_xFtFillHoles(m_xBuilder->weld_label("tilesft")) + , m_xMtFillHoles(m_xBuilder->weld_metric_spin_button("tiles", FUNIT_PIXEL)) + , m_xCbFillHoles(m_xBuilder->weld_check_button("fillholes")) + , m_xBmpWin(new SvxGraphCtrl(*m_xBuilder, "source")) + , m_xMtfWin(new SvxGraphCtrl(*m_xBuilder, "vectorized")) + , m_xPrgs(m_xBuilder->weld_progress_bar("progressbar")) + , m_xBtnOK(m_xBuilder->weld_button("ok")) + , m_xBtnPreview(m_xBuilder->weld_button("preview")) { - get(m_pNmLayers, "colors"); - get(m_pMtReduce, "points"); - get(m_pCbFillHoles, "fillholes"); - get(m_pFtFillHoles, "tilesft"); - get(m_pMtFillHoles, "tiles"); - get(m_pBmpWin, "source"); - get(m_pMtfWin, "vectorized"); - - Size aSize(LogicToPixel(Size(92, 100), MapMode(MapUnit::MapAppFont))); - m_pBmpWin->set_width_request(aSize.Width()); - m_pMtfWin->set_width_request(aSize.Width()); - m_pBmpWin->set_height_request(aSize.Height()); - m_pMtfWin->set_height_request(aSize.Height()); - - get(m_pPrgs, "progressbar"); - get(m_pBtnPreview, "preview"); - get(m_pBtnOK, "ok"); - - m_pBtnPreview->SetClickHdl( LINK( this, SdVectorizeDlg, ClickPreviewHdl ) ); - m_pBtnOK->SetClickHdl( LINK( this, SdVectorizeDlg, ClickOKHdl ) ); - m_pNmLayers->SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) ); - m_pMtReduce->SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) ); - m_pMtFillHoles->SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) ); - m_pCbFillHoles->SetToggleHdl( LINK( this, SdVectorizeDlg, ToggleHdl ) ); - - // disable 3D border - m_pBmpWin->SetBorderStyle(WindowBorderStyle::MONO); - m_pMtfWin->SetBorderStyle(WindowBorderStyle::MONO); + const int nWidth = m_xFtFillHoles->get_approximate_digit_width() * 32; + const int nHeight = m_xFtFillHoles->get_text_height() * 16; + m_xBmpWin->set_size_request(nWidth, nHeight); + m_xMtfWin->set_size_request(nWidth, nHeight); + + m_xBtnPreview->connect_clicked( LINK( this, SdVectorizeDlg, ClickPreviewHdl ) ); + m_xBtnOK->connect_clicked( LINK( this, SdVectorizeDlg, ClickOKHdl ) ); + m_xNmLayers->connect_value_changed( LINK( this, SdVectorizeDlg, ModifyHdl ) ); + m_xMtReduce->connect_value_changed( LINK( this, SdVectorizeDlg, MetricModifyHdl ) ); + m_xMtFillHoles->connect_value_changed( LINK( this, SdVectorizeDlg, MetricModifyHdl ) ); + m_xCbFillHoles->connect_toggled( LINK( this, SdVectorizeDlg, ToggleHdl ) ); LoadSettings(); InitPreviewBmp(); @@ -70,22 +63,6 @@ SdVectorizeDlg::SdVectorizeDlg(vcl::Window* pParent, const Bitmap& rBmp, ::sd::D SdVectorizeDlg::~SdVectorizeDlg() { - disposeOnce(); -} - -void SdVectorizeDlg::dispose() -{ - m_pNmLayers.clear(); - m_pMtReduce.clear(); - m_pFtFillHoles.clear(); - m_pMtFillHoles.clear(); - m_pCbFillHoles.clear(); - m_pBmpWin.clear(); - m_pMtfWin.clear(); - m_pPrgs.clear(); - m_pBtnOK.clear(); - m_pBtnPreview.clear(); - ModalDialog::dispose(); } ::tools::Rectangle SdVectorizeDlg::GetRect( const Size& rDispSize, const Size& rBmpSize ) @@ -120,11 +97,11 @@ void SdVectorizeDlg::dispose() void SdVectorizeDlg::InitPreviewBmp() { - const ::tools::Rectangle aRect( GetRect( m_pBmpWin->GetSizePixel(), aBmp.GetSizePixel() ) ); + const ::tools::Rectangle aRect( GetRect( m_xBmpWin->GetSize(), aBmp.GetSizePixel() ) ); aPreviewBmp = aBmp; aPreviewBmp.Scale( aRect.GetSize() ); - m_pBmpWin->SetGraphic( aPreviewBmp ); + m_xBmpWin->SetGraphic( aPreviewBmp ); } Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale ) @@ -142,7 +119,7 @@ Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale rScale = Fraction( 1, 1 ); BitmapEx aNewBmpEx(aNew); - BitmapFilter::Filter(aNewBmpEx, BitmapSimpleColorQuantizationFilter(static_cast(m_pNmLayers->GetValue()))); + BitmapFilter::Filter(aNewBmpEx, BitmapSimpleColorQuantizationFilter(m_xNmLayers->get_value())); aNew = aNewBmpEx.GetBitmap(); return aNew; @@ -150,8 +127,8 @@ Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) { - mpDocSh->SetWaitCursor( true ); - m_pPrgs->SetValue( 0 ); + m_pDocSh->SetWaitCursor( true ); + m_xPrgs->set_percentage(0); Fraction aScale; Bitmap aTmp( GetPreparedBitmap( rBmp, aScale ) ); @@ -159,9 +136,9 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) if( !!aTmp ) { const Link aPrgsHdl( LINK( this, SdVectorizeDlg, ProgressHdl ) ); - aTmp.Vectorize( rMtf, static_cast(m_pMtReduce->GetValue()), &aPrgsHdl ); + aTmp.Vectorize( rMtf, static_cast(m_xMtReduce->get_value(FUNIT_NONE)), &aPrgsHdl ); - if( m_pCbFillHoles->IsChecked() ) + if (m_xCbFillHoles->get_active()) { GDIMetaFile aNewMtf; Bitmap::ScopedReadAccess pRAcc(aTmp); @@ -170,8 +147,8 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) { const long nWidth = pRAcc->Width(); const long nHeight = pRAcc->Height(); - const long nTileX = static_cast(m_pMtFillHoles->GetValue()); - const long nTileY = static_cast(m_pMtFillHoles->GetValue()); + const long nTileX = m_xMtFillHoles->get_value(FUNIT_NONE); + const long nTileY = m_xMtFillHoles->get_value(FUNIT_NONE); assert(nTileX && "div-by-zero"); const long nCountX = nWidth / nTileX; assert(nTileY && "div-by-zero"); @@ -218,8 +195,8 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) } } - m_pPrgs->SetValue( 0 ); - mpDocSh->SetWaitCursor( false ); + m_xPrgs->set_percentage(0); + m_pDocSh->SetWaitCursor( false ); } void SdVectorizeDlg::AddTile( BitmapReadAccess const * pRAcc, GDIMetaFile& rMtf, @@ -249,7 +226,7 @@ void SdVectorizeDlg::AddTile( BitmapReadAccess const * pRAcc, GDIMetaFile& rMtf, ::tools::Rectangle aRect( Point( nPosX, nPosY ), Size( nWidth + 1, nHeight + 1 ) ); const Size& rMaxSize = rMtf.GetPrefSize(); - aRect = PixelToLogic( aRect, rMtf.GetPrefMapMode() ); + aRect = Application::GetDefaultDevice()->PixelToLogic(aRect, rMtf.GetPrefMapMode()); if( aRect.Right() > ( rMaxSize.Width() - 1 ) ) aRect.SetRight( rMaxSize.Width() - 1 ); @@ -264,44 +241,49 @@ void SdVectorizeDlg::AddTile( BitmapReadAccess const * pRAcc, GDIMetaFile& rMtf, IMPL_LINK( SdVectorizeDlg, ProgressHdl, long, nData, void ) { - m_pPrgs->SetValue( static_cast(nData) ); + m_xPrgs->set_percentage(nData); } -IMPL_LINK_NOARG(SdVectorizeDlg, ClickPreviewHdl, Button*, void) +IMPL_LINK_NOARG(SdVectorizeDlg, ClickPreviewHdl, weld::Button&, void) { Calculate( aBmp, aMtf ); - m_pMtfWin->SetGraphic( aMtf ); - m_pBtnPreview->Disable(); + m_xMtfWin->SetGraphic( aMtf ); + m_xBtnPreview->set_sensitive(false); } -IMPL_LINK_NOARG(SdVectorizeDlg, ClickOKHdl, Button*, void) +IMPL_LINK_NOARG(SdVectorizeDlg, ClickOKHdl, weld::Button&, void) { - if( m_pBtnPreview->IsEnabled() ) + if (m_xBtnPreview->get_sensitive()) Calculate( aBmp, aMtf ); SaveSettings(); - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } -IMPL_LINK( SdVectorizeDlg, ToggleHdl, CheckBox&, rCb, void ) +IMPL_LINK( SdVectorizeDlg, ToggleHdl, weld::ToggleButton&, rCb, void ) { - if( rCb.IsChecked() ) + if (rCb.get_active()) { - m_pFtFillHoles->Enable(); - m_pMtFillHoles->Enable(); + m_xFtFillHoles->set_sensitive(true); + m_xMtFillHoles->set_sensitive(true); } else { - m_pFtFillHoles->Disable(); - m_pMtFillHoles->Disable(); + m_xFtFillHoles->set_sensitive(false); + m_xMtFillHoles->set_sensitive(false); } - m_pBtnPreview->Enable(); + m_xBtnPreview->set_sensitive(true); +} + +IMPL_LINK_NOARG(SdVectorizeDlg, ModifyHdl, weld::SpinButton&, void) +{ + m_xBtnPreview->set_sensitive(true); } -IMPL_LINK_NOARG(SdVectorizeDlg, ModifyHdl, Edit&, void) +IMPL_LINK_NOARG(SdVectorizeDlg, MetricModifyHdl, weld::MetricSpinButton&, void) { - m_pBtnPreview->Enable(); + m_xBtnPreview->set_sensitive(true); } void SdVectorizeDlg::LoadSettings() @@ -327,12 +309,12 @@ void SdVectorizeDlg::LoadSettings() bFillHoles = false; } - m_pNmLayers->SetValue( nLayers ); - m_pMtReduce->SetValue( nReduce ); - m_pMtFillHoles->SetValue( nFillHoles ); - m_pCbFillHoles->Check( bFillHoles ); + m_xNmLayers->set_value(nLayers); + m_xMtReduce->set_value(nReduce, FUNIT_NONE); + m_xMtFillHoles->set_value(nFillHoles, FUNIT_NONE); + m_xCbFillHoles->set_active(bFillHoles); - ToggleHdl(*m_pCbFillHoles); + ToggleHdl(*m_xCbFillHoles); } void SdVectorizeDlg::SaveSettings() const @@ -344,8 +326,8 @@ void SdVectorizeDlg::SaveSettings() const if( xOStm.is() ) { SdIOCompat aCompat( *xOStm, StreamMode::WRITE, 1 ); - xOStm->WriteUInt16( m_pNmLayers->GetValue() ).WriteUInt16( m_pMtReduce->GetValue() ); - xOStm->WriteUInt16( m_pMtFillHoles->GetValue() ).WriteBool( m_pCbFillHoles->IsChecked() ); + xOStm->WriteUInt16( m_xNmLayers->get_value() ).WriteUInt16(m_xMtReduce->get_value(FUNIT_NONE)); + xOStm->WriteUInt16( m_xMtFillHoles->get_value(FUNIT_NONE) ).WriteBool(m_xCbFillHoles->get_active()); } } diff --git a/sd/source/ui/func/fuvect.cxx b/sd/source/ui/func/fuvect.cxx index 8a547243d6d8..7d51a805be5e 100644 --- a/sd/source/ui/func/fuvect.cxx +++ b/sd/source/ui/func/fuvect.cxx @@ -62,7 +62,7 @@ void FuVectorize::DoExecute( SfxRequest& ) if( pObj && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr ) { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact ? pFact->CreateSdVectorizeDlg( mpWindow, static_cast( pObj )->GetGraphic().GetBitmap(), mpDocSh ) : nullptr); + ScopedVclPtr pDlg(pFact ? pFact->CreateSdVectorizeDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, static_cast( pObj )->GetGraphic().GetBitmap(), mpDocSh ) : nullptr); if( pDlg && pDlg->Execute() == RET_OK ) { const GDIMetaFile& rMtf = pDlg->GetGDIMetaFile(); diff --git a/sd/source/ui/inc/vectdlg.hxx b/sd/source/ui/inc/vectdlg.hxx index 9a6ddd2304b3..370508f90852 100644 --- a/sd/source/ui/inc/vectdlg.hxx +++ b/sd/source/ui/inc/vectdlg.hxx @@ -20,13 +20,7 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_VECTDLG_HXX #define INCLUDED_SD_SOURCE_UI_INC_VECTDLG_HXX -#include -#include -#include -#include -#include -#include -#include +#include #include namespace sd { @@ -39,28 +33,24 @@ class DrawDocShell; |* \******************************************************************************/ -class SdVectorizeDlg : public ModalDialog +class SdVectorizeDlg : public weld::GenericDialogController { - ::sd::DrawDocShell * mpDocSh; - VclPtr m_pNmLayers; - VclPtr m_pMtReduce; - VclPtr m_pFtFillHoles; - VclPtr m_pMtFillHoles; - VclPtr m_pCbFillHoles; - - VclPtr m_pBmpWin; - - VclPtr m_pMtfWin; - - VclPtr m_pPrgs; - - VclPtr m_pBtnOK; - VclPtr m_pBtnPreview; - + ::sd::DrawDocShell* m_pDocSh; Bitmap aBmp; Bitmap aPreviewBmp; GDIMetaFile aMtf; + std::unique_ptr m_xNmLayers; + std::unique_ptr m_xMtReduce; + std::unique_ptr m_xFtFillHoles; + std::unique_ptr m_xMtFillHoles; + std::unique_ptr m_xCbFillHoles; + std::unique_ptr m_xBmpWin; + std::unique_ptr m_xMtfWin; + std::unique_ptr m_xPrgs; + std::unique_ptr m_xBtnOK; + std::unique_ptr m_xBtnPreview; + void LoadSettings(); void SaveSettings() const; void InitPreviewBmp(); @@ -71,17 +61,17 @@ class SdVectorizeDlg : public ModalDialog void AddTile( BitmapReadAccess const * pRAcc, GDIMetaFile& rMtf, long nPosX, long nPosY, long nWidth, long nHeight ); - DECL_LINK( ProgressHdl, long, void ); - DECL_LINK( ClickPreviewHdl, Button*, void ); - DECL_LINK( ClickOKHdl, Button*, void ); - DECL_LINK( ToggleHdl, CheckBox&, void ); - DECL_LINK( ModifyHdl, Edit&, void ); + DECL_LINK( ProgressHdl, long, void ); + DECL_LINK( ClickPreviewHdl, weld::Button&, void ); + DECL_LINK( ClickOKHdl, weld::Button&, void ); + DECL_LINK( ToggleHdl, weld::ToggleButton&, void ); + DECL_LINK( ModifyHdl, weld::SpinButton&, void ); + DECL_LINK( MetricModifyHdl, weld::MetricSpinButton&, void ); public: - SdVectorizeDlg( vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell ); - virtual ~SdVectorizeDlg() override; - virtual void dispose() override; + SdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell); + virtual ~SdVectorizeDlg() override; const GDIMetaFile& GetGDIMetaFile() const { return aMtf; } }; diff --git a/sd/uiconfig/sdraw/ui/vectorize.ui b/sd/uiconfig/sdraw/ui/vectorize.ui index 0d7ccad1f96c..4bc9fecd61a9 100644 --- a/sd/uiconfig/sdraw/ui/vectorize.ui +++ b/sd/uiconfig/sdraw/ui/vectorize.ui @@ -1,5 +1,5 @@ - + @@ -26,7 +26,10 @@ 6 Convert to Polygon False + True mouse + 0 + 0 dialog @@ -38,14 +41,12 @@ False end - - gtk-ok + + Preview True True - True - True True - True + True False @@ -54,10 +55,12 @@ - - gtk-cancel + + gtk-ok True True + True + True True True @@ -68,12 +71,12 @@ - - Preview + + gtk-cancel True True True - True + True False @@ -114,10 +117,10 @@ True False - 0 Number of colors: True colors + 0 0 @@ -128,6 +131,7 @@ True True + True adjustment1 @@ -139,10 +143,10 @@ True False - 0 Point reduction: True - points:0px + points + 0 0 @@ -150,9 +154,10 @@ - + True True + True adjustment2 @@ -165,11 +170,11 @@ True False 12 - 0 12 Tile size: True - tiles:0px + tiles + 0 0 @@ -177,9 +182,10 @@ - + True True + True adjustment3 @@ -222,10 +228,10 @@ True False - 0 Source image: True - tiles:0px + source + 0 0 @@ -236,10 +242,10 @@ True False - 0 Vectorized image: True - tiles:0px + vectorized + 0 1 @@ -247,11 +253,28 @@ - + True False - True - True + never + never + in + + + True + False + True + True + + + True + False + True + True + + + + 0 @@ -259,11 +282,28 @@ - + True False - True - True + never + never + in + + + True + False + True + True + + + True + False + True + True + + + + 1 @@ -294,8 +334,10 @@ ok cancel - preview help + + + diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx index 568827f303f5..5f959499f97b 100644 --- a/svx/source/dialog/graphctl.cxx +++ b/svx/source/dialog/graphctl.cxx @@ -771,4 +771,76 @@ css::uno::Reference< css::accessibility::XAccessible > GraphCtrl::CreateAccessib return mpAccContext.get(); } +SvxGraphCtrl::SvxGraphCtrl(weld::Builder& rBuilder, const OString& rDrawingId) + : aMap100(MapUnit::Map100thMM) + , mxDrawingArea(rBuilder.weld_drawing_area(rDrawingId)) +{ + mxDrawingArea->connect_size_allocate(LINK(this, SvxGraphCtrl, DoResize)); + mxDrawingArea->connect_draw(LINK(this, SvxGraphCtrl, DoPaint)); +} + +IMPL_LINK(SvxGraphCtrl, DoResize, const Size&, rSize, void) +{ + maSize = rSize; + mxDrawingArea->queue_draw(); +} + +IMPL_LINK(SvxGraphCtrl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +{ + vcl::RenderContext& rRenderContext = aPayload.first; + const bool bGraphicValid(GraphicType::NONE != aGraphic.GetType()); + // #i73381# in non-SdrMode, paint to local directly + if (bGraphicValid && aGraphSize.Width() && aGraphSize.Height()) + { + MapMode aDisplayMap( aMap100 ); + Point aNewPos; + Size aNewSize; + const Size aWinSize = Application::GetDefaultDevice()->PixelToLogic( maSize, aMap100 ); + const long nWidth = aWinSize.Width(); + const long nHeight = aWinSize.Height(); + double fGrfWH = static_cast(aGraphSize.Width()) / aGraphSize.Height(); + double fWinWH = static_cast(nWidth) / nHeight; + + // Adapt Bitmap to Thumb size + if ( fGrfWH < fWinWH) + { + aNewSize.setWidth( static_cast( static_cast(nHeight) * fGrfWH ) ); + aNewSize.setHeight( nHeight ); + } + else + { + aNewSize.setWidth( nWidth ); + aNewSize.setHeight( static_cast( static_cast(nWidth) / fGrfWH ) ); + } + + aNewPos.setX( ( nWidth - aNewSize.Width() ) >> 1 ); + aNewPos.setY( ( nHeight - aNewSize.Height() ) >> 1 ); + + // Implementing MapMode for Engine + aDisplayMap.SetScaleX( Fraction( aNewSize.Width(), aGraphSize.Width() ) ); + aDisplayMap.SetScaleY( Fraction( aNewSize.Height(), aGraphSize.Height() ) ); + + aDisplayMap.SetOrigin(OutputDevice::LogicToLogic(aNewPos, aMap100, aDisplayMap)); + rRenderContext.SetMapMode(aDisplayMap); + + aGraphic.Draw(&rRenderContext, Point(), aGraphSize); + } +} + +SvxGraphCtrl::~SvxGraphCtrl() +{ +} + +void SvxGraphCtrl::SetGraphic(const Graphic& rGraphic) +{ + aGraphic = rGraphic; + + if ( aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel ) + aGraphSize = Application::GetDefaultDevice()->PixelToLogic( aGraphic.GetPrefSize(), aMap100 ); + else + aGraphSize = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 ); + + mxDrawingArea->queue_draw(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d5d613b892f1..4f5c0850418c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1140,6 +1141,24 @@ IMPL_LINK_NOARG(SalInstanceScale, SlideHdl, Slider*, void) signal_value_changed(); } +class SalInstanceProgressBar : public SalInstanceWidget, public virtual weld::ProgressBar +{ +private: + VclPtr<::ProgressBar> m_xProgressBar; + +public: + SalInstanceProgressBar(::ProgressBar* pProgressBar, bool bTakeOwnership) + : SalInstanceWidget(pProgressBar, bTakeOwnership) + , m_xProgressBar(pProgressBar) + { + } + + virtual void set_percentage(int value) override + { + m_xProgressBar->SetValue(value); + } +}; + class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry { private: @@ -2175,6 +2194,12 @@ public: return pSlider ? new SalInstanceScale(pSlider, bTakeOwnership) : nullptr; } + virtual weld::ProgressBar* weld_progress_bar(const OString &id, bool bTakeOwnership) override + { + ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id); + return pProgress ? new SalInstanceProgressBar(pProgress, bTakeOwnership) : nullptr; + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { Edit* pEntry = m_xBuilder->get(id); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 7b972cebea00..8ffa151cd4b7 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2747,6 +2747,24 @@ public: } }; +class GtkInstanceProgressBar : public GtkInstanceWidget, public virtual weld::ProgressBar +{ +private: + GtkProgressBar* m_pProgressBar; + +public: + GtkInstanceProgressBar(GtkProgressBar* pProgressBar, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pProgressBar), bTakeOwnership) + , m_pProgressBar(pProgressBar) + { + } + + virtual void set_percentage(int value) override + { + gtk_progress_bar_set_fraction(m_pProgressBar, value / 100.0); + } +}; + class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry { private: @@ -4598,6 +4616,15 @@ public: return new GtkInstanceScale(pScale, bTakeOwnership); } + virtual weld::ProgressBar* weld_progress_bar(const OString &id, bool bTakeOwnership) override + { + GtkProgressBar* pProgressBar = GTK_PROGRESS_BAR(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pProgressBar) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pProgressBar)); + return new GtkInstanceProgressBar(pProgressBar, bTakeOwnership); + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { GtkEntry* pEntry = GTK_ENTRY(gtk_builder_get_object(m_pBuilder, id.getStr())); -- cgit