summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2022-02-14 08:23:45 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-02-20 22:17:57 +0100
commit90546b02d70cb9a9c3ee88428d99635a2f7eb22a (patch)
treeb9bafa9802f7fa93ddd32856f31418481969f6d9 /svx
parent0d402556af53790adb06380b4b04ea421d14d09e (diff)
Resolves tdf#146929 - Remember user input for the compress dialog
Change-Id: I23a0cd10b6936de920a294901f860620fc2af0a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129894 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/compressgraphicdialog.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index 1eb6a32501f2..7c9a8a44be33 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -39,6 +39,23 @@
#include <tools/stream.hxx>
#include <unotools/localedatawrapper.hxx>
+// tdf#146929 - remember user settings within the currect session
+// memp is filled in dtor and restored after initialization
+namespace
+{
+ struct memParam {
+ bool ReduceResolutionCB = false;
+ int MFNewWidth = 1;
+ int MFNewHeight = 1;
+ bool LosslessRB = true;
+ bool JpegCompRB = false;
+ int CompressionMF = 6;
+ int QualityMF = 80;
+ int InterpolationCombo = 3;
+ };
+ memParam memp;
+}
+
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
@@ -66,12 +83,31 @@ CompressGraphicsDialog::CompressGraphicsDialog( weld::Window* pParent, Graphic c
m_dResolution ( 300 )
{
Initialize();
+ recallParameter();
}
CompressGraphicsDialog::~CompressGraphicsDialog()
{
}
+void CompressGraphicsDialog::recallParameter()
+{
+ m_xReduceResolutionCB->set_active( memp.ReduceResolutionCB );
+ if (memp.ReduceResolutionCB && (memp.MFNewWidth > 1))
+ m_xMFNewWidth->set_value( memp.MFNewWidth );
+ if (memp.ReduceResolutionCB && (memp.MFNewHeight > 1))
+ m_xMFNewHeight->set_value( memp.MFNewHeight );
+
+ m_xLosslessRB->set_active( memp.LosslessRB );
+ m_xJpegCompRB->set_active( memp.JpegCompRB );
+ m_xCompressionMF->set_value( memp.CompressionMF );
+ m_xCompressionSlider->set_value( memp.CompressionMF );
+ m_xQualityMF->set_value( memp.QualityMF );
+ m_xQualitySlider->set_value( memp.QualityMF );
+
+ m_xInterpolationCombo->set_active( memp.InterpolationCombo );
+}
+
void CompressGraphicsDialog::Initialize()
{
m_xLabelGraphicType = m_xBuilder->weld_label("label-graphic-type");
@@ -91,6 +127,7 @@ void CompressGraphicsDialog::Initialize()
m_xResolutionLB = m_xBuilder->weld_combo_box("combo-resolution");
m_xBtnCalculate = m_xBuilder->weld_button("calculate");
m_xInterpolationCombo = m_xBuilder->weld_combo_box("interpolation-method-combo");
+ m_xBtnOkay = m_xBuilder->weld_button("ok");
m_xInterpolationCombo->set_active_text("Lanczos");
@@ -115,6 +152,7 @@ void CompressGraphicsDialog::Initialize()
m_xJpegCompRB->set_active(true);
m_xReduceResolutionCB->set_active(true);
+ m_xBtnOkay->connect_clicked( LINK( this, CompressGraphicsDialog, OkayClickHdl ) );
UpdateNewWidthMF();
UpdateNewHeightMF();
UpdateResolutionLB();
@@ -235,6 +273,19 @@ void CompressGraphicsDialog::Compress(SvStream& aStream)
rFilter.ExportGraphic( aScaledGraphic, "none", aStream, nFilterFormat, &aFilterData );
}
+IMPL_LINK_NOARG( CompressGraphicsDialog, OkayClickHdl, weld::Button&, void )
+{
+ memp.ReduceResolutionCB = m_xReduceResolutionCB->get_active();
+ memp.MFNewWidth = m_xMFNewWidth->get_value();
+ memp.MFNewHeight = m_xMFNewHeight->get_value();
+ memp.LosslessRB = m_xLosslessRB->get_active();
+ memp.JpegCompRB = m_xJpegCompRB->get_active();
+ memp.CompressionMF = m_xCompressionMF->get_value();
+ memp.QualityMF = m_xQualityMF->get_value();
+ memp.InterpolationCombo = m_xInterpolationCombo->get_active();
+ CompressGraphicsDialog::response(RET_OK);
+}
+
IMPL_LINK_NOARG( CompressGraphicsDialog, NewWidthModifiedHdl, weld::Entry&, void )
{
m_dResolution = m_xMFNewWidth->get_value() / GetViewWidthInch();