diff options
-rw-r--r-- | include/svx/compressgraphicdialog.hxx | 84 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 15 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/graphsh.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 6 | ||||
-rw-r--r-- | svx/source/dialog/compressgraphicdialog.cxx | 209 | ||||
-rw-r--r-- | svx/uiconfig/ui/compressgraphicdialog.ui | 53 | ||||
-rw-r--r-- | sw/source/uibase/shells/grfsh.cxx | 8 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 42 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 58 |
9 files changed, 278 insertions, 204 deletions
diff --git a/include/svx/compressgraphicdialog.hxx b/include/svx/compressgraphicdialog.hxx index 03128ee74fba..ca907aefcede 100644 --- a/include/svx/compressgraphicdialog.hxx +++ b/include/svx/compressgraphicdialog.hxx @@ -24,49 +24,36 @@ #include <tools/gen.hxx> #include <tools/link.hxx> #include <vcl/bitmap.hxx> -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> #include <vcl/graph.hxx> -#include <vcl/vclptr.hxx> - -namespace vcl { class Window; } - -class Button; -class CheckBox; -class ComboBox; -class Edit; -class FixedText; -class ListBox; -class NumericField; -class PushButton; -class RadioButton; + class SdrGrafObj; class SfxBindings; -class Slider; class SvStream; -class SAL_WARN_UNUSED SVX_DLLPUBLIC CompressGraphicsDialog : public ModalDialog +class SAL_WARN_UNUSED SVX_DLLPUBLIC CompressGraphicsDialog : public weld::GenericDialogController { private: - VclPtr<FixedText> m_pLabelGraphicType; - VclPtr<FixedText> m_pFixedText2; - VclPtr<FixedText> m_pFixedText3; - VclPtr<FixedText> m_pFixedText5; - VclPtr<FixedText> m_pFixedText6; - - VclPtr<CheckBox> m_pReduceResolutionCB; - VclPtr<NumericField> m_pMFNewWidth; - VclPtr<NumericField> m_pMFNewHeight; - VclPtr<ComboBox> m_pResolutionLB; - VclPtr<RadioButton> m_pLosslessRB; - VclPtr<RadioButton> m_pJpegCompRB; - VclPtr<NumericField> m_pCompressionMF; - VclPtr<Slider> m_pCompressionSlider; - VclPtr<NumericField> m_pQualityMF; - VclPtr<Slider> m_pQualitySlider; - VclPtr<PushButton> m_pBtnCalculate; - VclPtr<ListBox> m_pInterpolationCombo; - - SdrGrafObj* m_pGraphicObj; + std::unique_ptr<weld::Label> m_xLabelGraphicType; + std::unique_ptr<weld::Label> m_xFixedText2; + std::unique_ptr<weld::Label> m_xFixedText3; + std::unique_ptr<weld::Label> m_xFixedText5; + std::unique_ptr<weld::Label> m_xFixedText6; + + std::unique_ptr<weld::CheckButton> m_xReduceResolutionCB; + std::unique_ptr<weld::SpinButton> m_xMFNewWidth; + std::unique_ptr<weld::SpinButton> m_xMFNewHeight; + std::unique_ptr<weld::ComboBoxText> m_xResolutionLB; + std::unique_ptr<weld::RadioButton> m_xLosslessRB; + std::unique_ptr<weld::RadioButton> m_xJpegCompRB; + std::unique_ptr<weld::SpinButton> m_xCompressionMF; + std::unique_ptr<weld::Scale> m_xCompressionSlider; + std::unique_ptr<weld::SpinButton> m_xQualityMF; + std::unique_ptr<weld::Scale> m_xQualitySlider; + std::unique_ptr<weld::Button> m_xBtnCalculate; + std::unique_ptr<weld::ComboBoxText> m_xInterpolationCombo; + + SdrGrafObj* m_xGraphicObj; Graphic m_aGraphic; Size m_aViewSize100mm; tools::Rectangle m_aCropRectangle; @@ -76,17 +63,17 @@ private: void Initialize(); - DECL_LINK( EndSlideHdl, Slider*, void ); - DECL_LINK( NewInterpolationModifiedHdl, ListBox&, void ); - DECL_LINK( NewQualityModifiedHdl, Edit&, void ); - DECL_LINK( NewCompressionModifiedHdl, Edit&, void ); - DECL_LINK( NewWidthModifiedHdl, Edit&, void ); - DECL_LINK( NewHeightModifiedHdl, Edit&, void ); - DECL_LINK( ResolutionModifiedHdl, Edit&, void ); - DECL_LINK( ToggleCompressionRB, RadioButton&, void ); - DECL_LINK( ToggleReduceResolutionRB, CheckBox&, void ); + DECL_LINK( SlideHdl, weld::Scale&, void ); + DECL_LINK( NewInterpolationModifiedHdl, weld::ComboBoxText&, void ); + DECL_LINK( NewQualityModifiedHdl, weld::Entry&, void ); + DECL_LINK( NewCompressionModifiedHdl, weld::Entry&, void ); + DECL_LINK( NewWidthModifiedHdl, weld::Entry&, void ); + DECL_LINK( NewHeightModifiedHdl, weld::Entry&, void ); + DECL_LINK( ResolutionModifiedHdl, weld::ComboBoxText&, void ); + DECL_LINK( ToggleCompressionRB, weld::ToggleButton&, void ); + DECL_LINK( ToggleReduceResolutionRB, weld::ToggleButton&, void ); - DECL_LINK( CalculateClickHdl, Button*, void ); + DECL_LINK( CalculateClickHdl, weld::Button&, void ); void Update(); void UpdateNewWidthMF(); @@ -101,10 +88,9 @@ private: BmpScaleFlag GetSelectedInterpolationType(); public: - CompressGraphicsDialog( vcl::Window* pParent, SdrGrafObj* pGraphicObj, SfxBindings& rBindings ); - CompressGraphicsDialog( vcl::Window* pParent, Graphic const & rGraphic, Size rViewSize100mm, tools::Rectangle const & rCropRectangle, SfxBindings& rBindings ); + CompressGraphicsDialog( weld::Window* pParent, SdrGrafObj* pGraphicObj, SfxBindings& rBindings ); + CompressGraphicsDialog( weld::Window* pParent, Graphic const & rGraphic, Size rViewSize100mm, tools::Rectangle const & rCropRectangle, SfxBindings& rBindings ); virtual ~CompressGraphicsDialog() override; - virtual void dispose() override; SdrGrafObj* GetCompressedSdrGrafObj(); Graphic GetCompressedGraphic(); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 4e0d91ac9b0f..116e7c182f07 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -389,6 +389,20 @@ class VCL_DLLPUBLIC RadioButton : virtual public ToggleButton { }; +class VCL_DLLPUBLIC Scale : virtual public Widget +{ +protected: + Link<Scale&, void> m_aValueChangedHdl; + Link<Scale&, void> m_aOutputHdl; + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + +public: + virtual void set_value(int value) = 0; + virtual int get_value() const = 0; + void connect_value_changed(const Link<Scale&, void>& rLink) { m_aValueChangedHdl = rLink; } +}; + class VCL_DLLPUBLIC Entry : virtual public Widget { private: @@ -724,6 +738,7 @@ public: virtual TextView* weld_text_view(const OString& id, bool bTakeOwnership = false) = 0; 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 DrawingArea* weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr, bool bTakeOwnership = false) diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx index 9855beee0125..63475198c329 100644 --- a/sc/source/ui/drawfunc/graphsh.cxx +++ b/sc/source/ui/drawfunc/graphsh.cxx @@ -202,10 +202,11 @@ void ScGraphicShell::ExecuteCompressGraphic( SAL_UNUSED_PARAMETER SfxRequest& ) if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) { SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj); - ScopedVclPtrInstance< CompressGraphicsDialog > dialog( GetViewData()->GetDialogParent(), pGraphicObj, GetViewData()->GetBindings() ); - if ( dialog->Execute() == RET_OK ) + vcl::Window* pWin = GetViewData()->GetDialogParent(); + CompressGraphicsDialog dialog(pWin ? pWin->GetFrameWeld() : nullptr, pGraphicObj, GetViewData()->GetBindings()); + if (dialog.run() == RET_OK) { - SdrGrafObj* pNewObject = dialog->GetCompressedSdrGrafObj(); + SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); SdrPageView* pPageView = pView->GetSdrPageView(); OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Compress"; pView->BegUndo( aUndoString ); diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index bbfd4e0d3d23..48d0bc806589 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1351,10 +1351,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( pObj && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) { SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj); - ScopedVclPtrInstance< CompressGraphicsDialog > dialog( GetParentWindow(), pGraphicObj, GetViewFrame()->GetBindings() ); - if ( dialog->Execute() == RET_OK ) + CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() ); + if (dialog.run() == RET_OK) { - SdrGrafObj* pNewObject = dialog->GetCompressedSdrGrafObj(); + SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); SdrPageView* pPageView = mpDrawView->GetSdrPageView(); OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects(); aUndoString += " Compress"; diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx index 92edf6e78d48..72ee8732f924 100644 --- a/svx/source/dialog/compressgraphicdialog.cxx +++ b/svx/source/dialog/compressgraphicdialog.cxx @@ -39,23 +39,23 @@ using namespace com::sun::star::uno; using namespace com::sun::star::beans; -CompressGraphicsDialog::CompressGraphicsDialog( vcl::Window* pParent, SdrGrafObj* pGraphicObj, SfxBindings& rBindings ) : - ModalDialog ( pParent, "CompressGraphicDialog", "svx/ui/compressgraphicdialog.ui" ), - m_pGraphicObj ( pGraphicObj ), +CompressGraphicsDialog::CompressGraphicsDialog( weld::Window* pParent, SdrGrafObj* pGraphicObj, SfxBindings& rBindings ) : + GenericDialogController( pParent, "svx/ui/compressgraphicdialog.ui", "CompressGraphicDialog" ), + m_xGraphicObj ( pGraphicObj ), m_aGraphic ( pGraphicObj->GetGraphicObject().GetGraphic() ), m_aViewSize100mm ( pGraphicObj->GetLogicRect().GetSize() ), m_rBindings ( rBindings ), m_dResolution ( 96.0 ) { - const SdrGrafCropItem& rCrop = m_pGraphicObj->GetMergedItem(SDRATTR_GRAFCROP); + const SdrGrafCropItem& rCrop = m_xGraphicObj->GetMergedItem(SDRATTR_GRAFCROP); m_aCropRectangle = tools::Rectangle(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom()); Initialize(); } -CompressGraphicsDialog::CompressGraphicsDialog( vcl::Window* pParent, Graphic const & rGraphic, Size rViewSize100mm, tools::Rectangle const & rCropRectangle, SfxBindings& rBindings ) : - ModalDialog ( pParent, "CompressGraphicDialog", "svx/ui/compressgraphicdialog.ui" ), - m_pGraphicObj ( nullptr ), +CompressGraphicsDialog::CompressGraphicsDialog( weld::Window* pParent, Graphic const & rGraphic, Size rViewSize100mm, tools::Rectangle const & rCropRectangle, SfxBindings& rBindings ) : + GenericDialogController( pParent, "svx/ui/compressgraphicdialog.ui", "CompressGraphicDialog" ), + m_xGraphicObj ( nullptr ), m_aGraphic ( rGraphic ), m_aViewSize100mm ( rViewSize100mm ), m_aCropRectangle ( rCropRectangle ), @@ -67,75 +67,50 @@ CompressGraphicsDialog::CompressGraphicsDialog( vcl::Window* pParent, Graphic co CompressGraphicsDialog::~CompressGraphicsDialog() { - disposeOnce(); -} - -void CompressGraphicsDialog::dispose() -{ - m_pLabelGraphicType.clear(); - m_pFixedText2.clear(); - m_pFixedText3.clear(); - m_pFixedText5.clear(); - m_pFixedText6.clear(); - m_pReduceResolutionCB.clear(); - m_pMFNewWidth.clear(); - m_pMFNewHeight.clear(); - m_pResolutionLB.clear(); - m_pLosslessRB.clear(); - m_pJpegCompRB.clear(); - m_pCompressionMF.clear(); - m_pQualityMF.clear(); - m_pBtnCalculate.clear(); - m_pInterpolationCombo.clear(); - m_pCompressionSlider.clear(); - m_pQualitySlider.clear(); - ModalDialog::dispose(); } void CompressGraphicsDialog::Initialize() { - get(m_pLabelGraphicType, "label-graphic-type"); - get(m_pFixedText2, "label-original-size"); - get(m_pFixedText3, "label-view-size"); - get(m_pFixedText5, "label-image-capacity"); - get(m_pFixedText6, "label-new-capacity"); - get(m_pJpegCompRB, "radio-jpeg"); - get(m_pCompressionMF, "spin-compression"); - get(m_pCompressionSlider, "scale-compression"); - get(m_pLosslessRB, "radio-lossless"); - get(m_pQualityMF, "spin-quality"); - get(m_pQualitySlider, "scale-quality"); - get(m_pReduceResolutionCB, "checkbox-reduce-resolution"); - get(m_pMFNewWidth, "spin-new-width"); - get(m_pMFNewHeight, "spin-new-height"); - get(m_pResolutionLB, "combo-resolution"); - get(m_pBtnCalculate, "calculate"); - get(m_pInterpolationCombo, "interpolation-method-combo"); - - m_pInterpolationCombo->SelectEntry( "Lanczos" ); - - m_pInterpolationCombo->SetSelectHdl( LINK( this, CompressGraphicsDialog, NewInterpolationModifiedHdl )); - - m_pMFNewWidth->SetModifyHdl( LINK( this, CompressGraphicsDialog, NewWidthModifiedHdl )); - m_pMFNewHeight->SetModifyHdl( LINK( this, CompressGraphicsDialog, NewHeightModifiedHdl )); - - m_pResolutionLB->SetModifyHdl( LINK( this, CompressGraphicsDialog, ResolutionModifiedHdl )); - m_pBtnCalculate->SetClickHdl( LINK( this, CompressGraphicsDialog, CalculateClickHdl ) ); - - m_pLosslessRB->SetToggleHdl( LINK( this, CompressGraphicsDialog, ToggleCompressionRB ) ); - m_pJpegCompRB->SetToggleHdl( LINK( this, CompressGraphicsDialog, ToggleCompressionRB ) ); - - m_pReduceResolutionCB->SetToggleHdl( LINK( this, CompressGraphicsDialog, ToggleReduceResolutionRB ) ); - - m_pQualitySlider->SetLinkedField(m_pQualityMF); - m_pQualitySlider->SetEndSlideHdl( LINK( this, CompressGraphicsDialog, EndSlideHdl )); - m_pCompressionSlider->SetLinkedField(m_pCompressionMF); - m_pCompressionSlider->SetEndSlideHdl( LINK( this, CompressGraphicsDialog, EndSlideHdl )); - m_pQualityMF->SetModifyHdl( LINK( this, CompressGraphicsDialog, NewQualityModifiedHdl )); - m_pCompressionMF->SetModifyHdl( LINK( this, CompressGraphicsDialog, NewCompressionModifiedHdl )); - - m_pJpegCompRB->Check(); - m_pReduceResolutionCB->Check(); + m_xLabelGraphicType.reset(m_xBuilder->weld_label("label-graphic-type")); + m_xFixedText2.reset(m_xBuilder->weld_label("label-original-size")); + m_xFixedText3.reset(m_xBuilder->weld_label("label-view-size")); + m_xFixedText5.reset(m_xBuilder->weld_label("label-image-capacity")); + m_xFixedText6.reset(m_xBuilder->weld_label("label-new-capacity")); + m_xJpegCompRB.reset(m_xBuilder->weld_radio_button("radio-jpeg")); + m_xCompressionMF.reset(m_xBuilder->weld_spin_button("spin-compression")); + m_xCompressionSlider.reset(m_xBuilder->weld_scale("scale-compression")); + m_xLosslessRB.reset(m_xBuilder->weld_radio_button("radio-lossless")); + m_xQualityMF.reset(m_xBuilder->weld_spin_button("spin-quality")); + m_xQualitySlider.reset(m_xBuilder->weld_scale("scale-quality")); + m_xReduceResolutionCB.reset(m_xBuilder->weld_check_button("checkbox-reduce-resolution")); + m_xMFNewWidth.reset(m_xBuilder->weld_spin_button("spin-new-width")); + m_xMFNewHeight.reset(m_xBuilder->weld_spin_button("spin-new-height")); + m_xResolutionLB.reset(m_xBuilder->weld_combo_box_text("combo-resolution")); + m_xBtnCalculate.reset(m_xBuilder->weld_button("calculate")); + m_xInterpolationCombo.reset(m_xBuilder->weld_combo_box_text("interpolation-method-combo")); + + m_xInterpolationCombo->set_active("Lanczos"); + + m_xInterpolationCombo->connect_changed(LINK(this, CompressGraphicsDialog, NewInterpolationModifiedHdl)); + + m_xMFNewWidth->connect_changed( LINK( this, CompressGraphicsDialog, NewWidthModifiedHdl )); + m_xMFNewHeight->connect_changed( LINK( this, CompressGraphicsDialog, NewHeightModifiedHdl )); + + m_xResolutionLB->connect_changed( LINK( this, CompressGraphicsDialog, ResolutionModifiedHdl )); + m_xBtnCalculate->connect_clicked( LINK( this, CompressGraphicsDialog, CalculateClickHdl ) ); + + m_xLosslessRB->connect_toggled( LINK( this, CompressGraphicsDialog, ToggleCompressionRB ) ); + m_xJpegCompRB->connect_toggled( LINK( this, CompressGraphicsDialog, ToggleCompressionRB ) ); + + m_xReduceResolutionCB->connect_toggled( LINK( this, CompressGraphicsDialog, ToggleReduceResolutionRB ) ); + + m_xQualitySlider->connect_value_changed( LINK( this, CompressGraphicsDialog, SlideHdl )); + m_xCompressionSlider->connect_value_changed( LINK( this, CompressGraphicsDialog, SlideHdl )); + m_xQualityMF->connect_changed( LINK( this, CompressGraphicsDialog, NewQualityModifiedHdl )); + m_xCompressionMF->connect_changed( LINK( this, CompressGraphicsDialog, NewCompressionModifiedHdl )); + + m_xJpegCompRB->set_active(true); + m_xReduceResolutionCB->set_active(true); UpdateNewWidthMF(); UpdateNewHeightMF(); @@ -180,7 +155,7 @@ void CompressGraphicsDialog::Update() aGraphicTypeString = SvxResId(STR_IMAGE_UNKNOWN); break; } - m_pLabelGraphicType->SetText(aGraphicTypeString); + m_xLabelGraphicType->set_label(aGraphicTypeString); const FieldUnit eFieldUnit = m_rBindings.GetDispatcher()->GetModule()->GetFieldUnit(); const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); @@ -200,7 +175,7 @@ void CompressGraphicsDialog::Update() aBitmapSizeString = aBitmapSizeString.replaceAll("$(HEIGHT)", aHeightString); aBitmapSizeString = aBitmapSizeString.replaceAll("$(WIDTH_IN_PX)", OUString::number(aPixelSize.Width())); aBitmapSizeString = aBitmapSizeString.replaceAll("$(HEIGHT_IN_PX)", OUString::number(aPixelSize.Height())); - m_pFixedText2->SetText(aBitmapSizeString); + m_xFixedText2->set_label(aBitmapSizeString); int aValX = static_cast<int>(aPixelSize.Width() / GetViewWidthInch()); @@ -211,7 +186,7 @@ void CompressGraphicsDialog::Update() aViewSizeString = aViewSizeString.replaceAll("$(WIDTH)", aWidthString); aViewSizeString = aViewSizeString.replaceAll("$(HEIGHT)", aHeightString); aViewSizeString = aViewSizeString.replaceAll("$(DPI)", OUString::number(aValX)); - m_pFixedText3->SetText(aViewSizeString); + m_xFixedText3->set_label(aViewSizeString); SvMemoryStream aMemStream; aMemStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT ); @@ -221,26 +196,26 @@ void CompressGraphicsDialog::Update() OUString aNativeSizeString = SvxResId(STR_IMAGE_CAPACITY); aNativeSizeString = aNativeSizeString.replaceAll("$(CAPACITY)", OUString::number(aNativeSize / 1024)); - m_pFixedText5->SetText(aNativeSizeString); + m_xFixedText5->set_label(aNativeSizeString); - m_pFixedText6->SetText("??"); + m_xFixedText6->set_label("??"); } void CompressGraphicsDialog::UpdateNewWidthMF() { int nPixelX = static_cast<sal_Int32>( GetViewWidthInch() * m_dResolution ); - m_pMFNewWidth->SetText( OUString::number( nPixelX )); + m_xMFNewWidth->set_value(nPixelX); } void CompressGraphicsDialog::UpdateNewHeightMF() { int nPixelY = static_cast<sal_Int32>( GetViewHeightInch() * m_dResolution ); - m_pMFNewHeight->SetText( OUString::number( nPixelY )); + m_xMFNewHeight->set_value(nPixelY); } void CompressGraphicsDialog::UpdateResolutionLB() { - m_pResolutionLB->SetText( OUString::number( static_cast<sal_Int32>(m_dResolution) ) ); + m_xResolutionLB->set_entry_text( OUString::number( static_cast<sal_Int32>(m_dResolution) ) ); } double CompressGraphicsDialog::GetViewWidthInch() @@ -255,7 +230,7 @@ double CompressGraphicsDialog::GetViewHeightInch() BmpScaleFlag CompressGraphicsDialog::GetSelectedInterpolationType() { - OUString aSelectionText = m_pInterpolationCombo->GetSelectedEntry(); + OUString aSelectionText = m_xInterpolationCombo->get_active_text(); if( aSelectionText == "Lanczos" ) { return BmpScaleFlag::Lanczos; @@ -272,7 +247,7 @@ BmpScaleFlag CompressGraphicsDialog::GetSelectedInterpolationType() void CompressGraphicsDialog::Compress(SvStream& aStream) { BitmapEx aBitmap = m_aGraphic.GetBitmapEx(); - if ( m_pReduceResolutionCB->IsChecked() ) + if ( m_xReduceResolutionCB->get_active() ) { long nPixelX = static_cast<long>( GetViewWidthInch() * m_dResolution ); long nPixelY = static_cast<long>( GetViewHeightInch() * m_dResolution ); @@ -286,88 +261,90 @@ void CompressGraphicsDialog::Compress(SvStream& aStream) aFilterData[ 0 ].Name = "Interlaced"; aFilterData[ 0 ].Value <<= sal_Int32(0); aFilterData[ 1 ].Name = "Compression"; - aFilterData[ 1 ].Value <<= static_cast<sal_Int32>(m_pCompressionMF->GetValue()); + aFilterData[ 1 ].Value <<= static_cast<sal_Int32>(m_xCompressionMF->get_value()); aFilterData[ 2 ].Name = "Quality"; - aFilterData[ 2 ].Value <<= static_cast<sal_Int32>(m_pQualityMF->GetValue()); + aFilterData[ 2 ].Value <<= static_cast<sal_Int32>(m_xQualityMF->get_value()); - OUString aGraphicFormatName = m_pLosslessRB->IsChecked() ? OUString( "png" ) : OUString( "jpg" ); + OUString aGraphicFormatName = m_xLosslessRB->get_active() ? OUString( "png" ) : OUString( "jpg" ); sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( aGraphicFormatName ); rFilter.ExportGraphic( aScaledGraphic, "none", aStream, nFilterFormat, &aFilterData ); } -IMPL_LINK_NOARG( CompressGraphicsDialog, NewWidthModifiedHdl, Edit&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, NewWidthModifiedHdl, weld::Entry&, void ) { - fprintf(stderr, "NewWidthModifiedHdl\n"); - - m_dResolution = m_pMFNewWidth->GetValue() / GetViewWidthInch(); + m_dResolution = m_xMFNewWidth->get_value() / GetViewWidthInch(); UpdateNewHeightMF(); UpdateResolutionLB(); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, EndSlideHdl, Slider*, void ) +IMPL_LINK( CompressGraphicsDialog, SlideHdl, weld::Scale&, rScale, void ) { + if (&rScale == m_xQualitySlider.get()) + m_xQualityMF->set_value(m_xQualitySlider->get_value()); + else + m_xCompressionMF->set_value(m_xCompressionSlider->get_value()); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, NewInterpolationModifiedHdl, ListBox&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, NewInterpolationModifiedHdl, weld::ComboBoxText&, void ) { Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, NewQualityModifiedHdl, Edit&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, NewQualityModifiedHdl, weld::Entry&, void ) { - m_pQualitySlider->SetThumbPos(m_pQualityMF->GetValue()); + m_xQualitySlider->set_value(m_xQualityMF->get_value()); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, NewCompressionModifiedHdl, Edit&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, NewCompressionModifiedHdl, weld::Entry&, void ) { - m_pCompressionSlider->SetThumbPos(m_pCompressionMF->GetValue()); + m_xCompressionSlider->set_value(m_xCompressionMF->get_value()); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, NewHeightModifiedHdl, Edit&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, NewHeightModifiedHdl, weld::Entry&, void ) { - m_dResolution = m_pMFNewHeight->GetValue() / GetViewHeightInch(); + m_dResolution = m_xMFNewHeight->get_value() / GetViewHeightInch(); UpdateNewWidthMF(); UpdateResolutionLB(); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, ResolutionModifiedHdl, Edit&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, ResolutionModifiedHdl, weld::ComboBoxText&, void ) { - m_dResolution = static_cast<double>(m_pResolutionLB->GetText().toInt32()); + m_dResolution = static_cast<double>(m_xResolutionLB->get_active_text().toInt32()); UpdateNewWidthMF(); UpdateNewHeightMF(); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, ToggleCompressionRB, RadioButton&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, ToggleCompressionRB, weld::ToggleButton&, void ) { - bool choice = m_pLosslessRB->IsChecked(); - m_pCompressionMF->Enable(choice); - m_pCompressionSlider->Enable(choice); - m_pQualityMF->Enable(!choice); - m_pQualitySlider->Enable(!choice); + bool choice = m_xLosslessRB->get_active(); + m_xCompressionMF->set_sensitive(choice); + m_xCompressionSlider->set_sensitive(choice); + m_xQualityMF->set_sensitive(!choice); + m_xQualitySlider->set_sensitive(!choice); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, ToggleReduceResolutionRB, CheckBox&, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, ToggleReduceResolutionRB, weld::ToggleButton&, void ) { - bool choice = m_pReduceResolutionCB->IsChecked(); - m_pMFNewWidth->Enable(choice); - m_pMFNewHeight->Enable(choice); - m_pResolutionLB->Enable(choice); - m_pInterpolationCombo->Enable(choice); + bool choice = m_xReduceResolutionCB->get_active(); + m_xMFNewWidth->set_sensitive(choice); + m_xMFNewHeight->set_sensitive(choice); + m_xResolutionLB->set_sensitive(choice); + m_xInterpolationCombo->set_sensitive(choice); Update(); } -IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl, Button*, void ) +IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl, weld::Button&, void ) { sal_Int32 aSize = 0; @@ -386,13 +363,13 @@ IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl, Button*, void ) OUString aNewSizeString = SvxResId(STR_IMAGE_CAPACITY); aNewSizeString = aNewSizeString.replaceAll("$(CAPACITY)", aSizeAsString); - m_pFixedText6->SetText(aNewSizeString); + m_xFixedText6->set_label(aNewSizeString); } } tools::Rectangle CompressGraphicsDialog::GetScaledCropRectangle() { - if ( m_pReduceResolutionCB->IsChecked() ) + if ( m_xReduceResolutionCB->get_active() ) { long nPixelX = static_cast<long>( GetViewWidthInch() * m_dResolution ); long nPixelY = static_cast<long>( GetViewHeightInch() * m_dResolution ); @@ -433,9 +410,9 @@ SdrGrafObj* CompressGraphicsDialog::GetCompressedSdrGrafObj() { if ( m_dResolution > 0.0 ) { - SdrGrafObj* pNewObject = m_pGraphicObj->Clone(); + SdrGrafObj* pNewObject = m_xGraphicObj->Clone(); - if ( m_pReduceResolutionCB->IsChecked() ) + if ( m_xReduceResolutionCB->get_active() ) { tools::Rectangle aScaledCropedRectangle = GetScaledCropRectangle(); SdrGrafCropItem aNewCrop( diff --git a/svx/uiconfig/ui/compressgraphicdialog.ui b/svx/uiconfig/ui/compressgraphicdialog.ui index 0f4a81af5190..14dd0a1c7bb5 100644 --- a/svx/uiconfig/ui/compressgraphicdialog.ui +++ b/svx/uiconfig/ui/compressgraphicdialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.20.4 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> <object class="GtkAdjustment" id="compression-adjustment"> @@ -16,26 +16,6 @@ <property name="step_increment">100</property> <property name="page_increment">100</property> </object> - <object class="GtkListStore" id="interpolation-method-store"> - <columns> - <!-- column-name scale-method-name --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes" context="compressgraphicdialog|interpolation-method-store">None</col> - </row> - <row> - <col id="0" translatable="yes" context="compressgraphicdialog|interpolation-method-store">Bilinear</col> - </row> - <row> - <col id="0" translatable="yes" context="compressgraphicdialog|interpolation-method-store">Bicubic</col> - </row> - <row> - <col id="0" translatable="yes" context="compressgraphicdialog|interpolation-method-store">Lanczos</col> - </row> - </data> - </object> <object class="GtkAdjustment" id="quality-adjustment"> <property name="lower">1</property> <property name="upper">99</property> @@ -56,6 +36,8 @@ <property name="title" translatable="yes" context="compressgraphicdialog|CompressGraphicDialog">Compress Image</property> <property name="resizable">False</property> <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">9</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -151,8 +133,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="use_underline">True</property> <property name="tooltip_text" translatable="yes" context="compressgraphicdialog|radio-jpeg|tooltip_text">Lossy compression</property> + <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> <property name="group">radio-lossless</property> @@ -168,8 +150,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="use_underline">True</property> <property name="tooltip_text" translatable="yes" context="compressgraphicdialog|radio-lossless|tooltip_text">Lossless compression</property> + <property name="use_underline">True</property> <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> @@ -209,7 +191,8 @@ <object class="GtkSpinButton" id="spin-quality"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="no">90</property> + <property name="activates_default">True</property> + <property name="text">90</property> <property name="adjustment">quality-adjustment</property> <property name="numeric">True</property> <property name="value">90</property> @@ -256,7 +239,8 @@ <object class="GtkSpinButton" id="spin-compression"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="no">9</property> + <property name="activates_default">True</property> + <property name="text">9</property> <property name="adjustment">compression-adjustment</property> <property name="numeric">True</property> <property name="value">9</property> @@ -393,7 +377,8 @@ <object class="GtkSpinButton" id="spin-new-width"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="no">1</property> + <property name="activates_default">True</property> + <property name="text">1</property> <property name="adjustment">width-adjustment</property> <property name="numeric">True</property> <property name="value">1</property> @@ -407,7 +392,8 @@ <object class="GtkSpinButton" id="spin-new-height"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="no">1</property> + <property name="activates_default">True</property> + <property name="text">1</property> <property name="adjustment">height-adjustment</property> <property name="numeric">True</property> <property name="value">1</property> @@ -434,6 +420,7 @@ <child internal-child="entry"> <object class="GtkEntry"> <property name="can_focus">True</property> + <property name="activates_default">True</property> </object> </child> </object> @@ -443,10 +430,15 @@ </packing> </child> <child> - <object class="GtkComboBox" id="interpolation-method-combo"> + <object class="GtkComboBoxText" id="interpolation-method-combo"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="model">interpolation-method-store</property> + <items> + <item translatable="yes" context="compressgraphicdialog|interpolation-method-store">None</item> + <item translatable="yes" context="compressgraphicdialog|interpolation-method-store">Bilinear</item> + <item translatable="yes" context="compressgraphicdialog|interpolation-method-store">Bicubic</item> + <item translatable="yes" context="compressgraphicdialog|interpolation-method-store">Lanczos</item> + </items> </object> <packing> <property name="left_attach">1</property> @@ -693,5 +685,8 @@ <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index 683c8a7344bf..cc31d9d3ea05 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -215,19 +215,19 @@ void SwGrfShell::Execute(SfxRequest &rReq) Graphic aGraphic = Graphic( *pGraphic ); - ScopedVclPtrInstance< CompressGraphicsDialog > aDialog( GetView().GetWindow(), aGraphic, aSize, aCropRectangle, GetView().GetViewFrame()->GetBindings() ); - if( aDialog->Execute() == RET_OK ) + CompressGraphicsDialog aDialog(GetView().GetFrameWeld(), aGraphic, aSize, aCropRectangle, GetView().GetViewFrame()->GetBindings()); + if (aDialog.run() == RET_OK) { rSh.StartAllAction(); rSh.StartUndo(SwUndoId::START); - tools::Rectangle aScaledCropedRectangle = aDialog->GetScaledCropRectangle(); + tools::Rectangle aScaledCropedRectangle = aDialog.GetScaledCropRectangle(); aCrop.SetLeft( convertMm100ToTwip( aScaledCropedRectangle.Left() )); aCrop.SetTop( convertMm100ToTwip( aScaledCropedRectangle.Top() )); aCrop.SetRight( convertMm100ToTwip( aScaledCropedRectangle.Right() )); aCrop.SetBottom( convertMm100ToTwip( aScaledCropedRectangle.Bottom() )); - Graphic aCompressedGraphic( aDialog->GetCompressedGraphic() ); + Graphic aCompressedGraphic( aDialog.GetCompressedGraphic() ); rSh.ReRead(OUString(), OUString(), const_cast<const Graphic*>(&aCompressedGraphic)); rSh.SetAttrItem(aCrop); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 159fd97a4d2e..fcfcdd90618c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -36,6 +36,7 @@ #include <vcl/dialog.hxx> #include <vcl/layout.hxx> #include <vcl/menubtn.hxx> +#include <vcl/slider.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabpage.hxx> #include <vcl/unowrap.hxx> @@ -994,6 +995,41 @@ IMPL_LINK_NOARG(SalInstanceCheckButton, ToggleHdl, CheckBox&, void) signal_toggled(); } +class SalInstanceScale : public SalInstanceWidget, public virtual weld::Scale +{ +private: + VclPtr<Slider> m_xScale; + + DECL_LINK(SlideHdl, Slider*, void); +public: + SalInstanceScale(Slider* pScale, bool bTakeOwnership) + : SalInstanceWidget(pScale, bTakeOwnership) + , m_xScale(pScale) + { + m_xScale->SetSlideHdl(LINK(this, SalInstanceScale, SlideHdl)); + } + + virtual void set_value(int value) override + { + m_xScale->SetThumbPos(value); + } + + virtual int get_value() const override + { + return m_xScale->GetThumbPos(); + } + + virtual ~SalInstanceScale() override + { + m_xScale->SetSlideHdl(Link<Slider*, void>()); + } +}; + +IMPL_LINK_NOARG(SalInstanceScale, SlideHdl, Slider*, void) +{ + signal_value_changed(); +} + class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry { private: @@ -1926,6 +1962,12 @@ public: return pCheckButton ? new SalInstanceCheckButton(pCheckButton, bTakeOwnership) : nullptr; } + virtual weld::Scale* weld_scale(const OString &id, bool bTakeOwnership) override + { + Slider* pSlider = m_xBuilder->get<Slider>(id); + return pSlider ? new SalInstanceScale(pSlider, bTakeOwnership) : nullptr; + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { Edit* pEntry = m_xBuilder->get<Edit>(id); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 14e8af024d01..20f94158612e 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2629,6 +2629,55 @@ public: } }; +class GtkInstanceScale : public GtkInstanceWidget, public virtual weld::Scale +{ +private: + GtkScale* m_pScale; + gulong m_nValueChangedSignalId; + + static void signalValueChanged(GtkScale*, gpointer widget) + { + GtkInstanceScale* pThis = static_cast<GtkInstanceScale*>(widget); + SolarMutexGuard aGuard; + pThis->signal_value_changed(); + } + +public: + GtkInstanceScale(GtkScale* pScale, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pScale), bTakeOwnership) + , m_pScale(pScale) + , m_nValueChangedSignalId(g_signal_connect(m_pScale, "value-changed", G_CALLBACK(signalValueChanged), this)) + { + } + + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pScale, m_nValueChangedSignalId); + GtkInstanceWidget::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceWidget::enable_notify_events(); + g_signal_handler_unblock(m_pScale, m_nValueChangedSignalId); + } + + virtual void set_value(int value) override + { + gtk_range_set_value(GTK_RANGE(m_pScale), value); + } + + virtual int get_value() const override + { + return gtk_range_get_value(GTK_RANGE(m_pScale)); + } + + virtual ~GtkInstanceScale() override + { + g_signal_handler_disconnect(m_pScale, m_nValueChangedSignalId); + } +}; + class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry { private: @@ -4365,6 +4414,15 @@ public: return new GtkInstanceCheckButton(pCheckButton, bTakeOwnership); } + virtual weld::Scale* weld_scale(const OString &id, bool bTakeOwnership) override + { + GtkScale* pScale = GTK_SCALE(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pScale) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pScale)); + return new GtkInstanceScale(pScale, bTakeOwnership); + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { GtkEntry* pEntry = GTK_ENTRY(gtk_builder_get_object(m_pBuilder, id.getStr())); |