[Libreoffice-commits] core.git: include/svx svx/source

Daniel (via logerrit) logerrit at kemper.freedesktop.org
Sat Oct 10 12:27:15 UTC 2020


 include/svx/compressgraphicdialog.hxx       |    1 +
 include/svx/strings.hrc                     |    1 +
 svx/source/dialog/compressgraphicdialog.cxx |    9 ++++++---
 3 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 46772b2dbbc269c2e83f00af2cd864fb64ccf425
Author:     Daniel <d22148483 at gmail.com>
AuthorDate: Sat Oct 10 10:38:51 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Oct 10 14:26:36 2020 +0200

    tdf#87963: Add percentage value to new calculated compressed image size
    
    Change-Id: I8e9029c2fee2a42501e580737a453ad3f90eac1c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104138
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/compressgraphicdialog.hxx b/include/svx/compressgraphicdialog.hxx
index a29225263efb..9c11b8dc765f 100644
--- a/include/svx/compressgraphicdialog.hxx
+++ b/include/svx/compressgraphicdialog.hxx
@@ -59,6 +59,7 @@ private:
     SfxBindings&    m_rBindings;
 
     double          m_dResolution;
+    sal_Int32       m_aNativeSize;
 
     void Initialize();
 
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index 4b4ca6797e99..1e8b33826120 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -1368,6 +1368,7 @@
 #define STR_IMAGE_ORIGINAL_SIZE                             NC_("STR_IMAGE_ORIGINAL_SIZE", "$(WIDTH) x $(HEIGHT) ($(WIDTH_IN_PX) x $(HEIGHT_IN_PX) px)")
 #define STR_IMAGE_VIEW_SIZE                                 NC_("STR_IMAGE_VIEW_SIZE", "$(WIDTH) x $(HEIGHT) at $(DPI) DPI")
 #define STR_IMAGE_CAPACITY                                  NC_("STR_IMAGE_CAPACITY", "$(CAPACITY) kiB")
+#define STR_IMAGE_CAPACITY_WITH_REDUCTION                   NC_("STR_IMAGE_CAPACITY_WITH_REDUCTION", "$(CAPACITY) kiB ($(REDUCTION) % Reduction)")
 #define STR_IMAGE_GIF                                       NC_("STR_IMAGE_GIF", "Gif image")
 #define STR_IMAGE_JPEG                                      NC_("STR_IMAGE_JPEG", "Jpeg image")
 #define STR_IMAGE_PNG                                       NC_("STR_IMAGE_PNG", "PNG image")
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index 14b4c809f04a..d16202cd5c1c 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -192,10 +192,10 @@ void CompressGraphicsDialog::Update()
     SvMemoryStream aMemStream;
     aMemStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
     m_aGraphic.ExportNative(aMemStream);
-    sal_Int32 aNativeSize = aMemStream.TellEnd();
+    m_aNativeSize = aMemStream.TellEnd();
 
     OUString aNativeSizeString = SvxResId(STR_IMAGE_CAPACITY);
-    aNativeSizeString = aNativeSizeString.replaceAll("$(CAPACITY)",  OUString::number(aNativeSize / 1024));
+    aNativeSizeString = aNativeSizeString.replaceAll("$(CAPACITY)",  OUString::number( m_aNativeSize  / 1024 ));
     m_xFixedText5->set_label(aNativeSizeString);
 
     m_xFixedText6->set_label("??");
@@ -360,8 +360,11 @@ IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl, weld::Button&, void
     {
         OUString aSizeAsString = OUString::number(aSize / 1024);
 
-        OUString aNewSizeString = SvxResId(STR_IMAGE_CAPACITY);
+        OUString aReductionSizeAsString = OUString::number( m_aNativeSize > 0 ? (m_aNativeSize - aSize) * 100 / m_aNativeSize : 0 );
+
+        OUString aNewSizeString = SvxResId(STR_IMAGE_CAPACITY_WITH_REDUCTION);
         aNewSizeString = aNewSizeString.replaceAll("$(CAPACITY)", aSizeAsString);
+        aNewSizeString = aNewSizeString.replaceAll("$(REDUCTION)", aReductionSizeAsString);
         m_xFixedText6->set_label(aNewSizeString);
     }
 }


More information about the Libreoffice-commits mailing list