[Libreoffice-commits] core.git: sd/source sd/uiconfig
Abhilash
abhilash300singh at gmail.com
Wed Sep 7 18:02:44 UTC 2016
sd/source/ui/dlg/PhotoAlbumDialog.cxx | 49 +++++++++++++++++++++++++++++++---
sd/source/ui/dlg/PhotoAlbumDialog.hxx | 2 +
sd/uiconfig/simpress/ui/photoalbum.ui | 16 +++++++++++
3 files changed, 63 insertions(+), 4 deletions(-)
New commits:
commit 511acc66f543b0200ebe70cf072e5a8db8677809
Author: Abhilash <abhilash300singh at gmail.com>
Date: Fri Jul 29 00:19:27 2016 +0530
tdf#64575 Photo Album: Better Image Layout
Change-Id: I021c5fa921eb80edd996e0224e69e3b3d54b76d3
Reviewed-on: https://gerrit.libreoffice.org/27654
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 9622b8c..c1de735 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -55,6 +55,7 @@ SdPhotoAlbumDialog::SdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pAc
get(pInsTypeCombo, "opt_combo");
get(pASRCheck, "asr_check");
+ get(pASRCheckCrop, "asr_check_crop");
get(pCapCheck, "cap_check");
get(pInsertAsLinkCheck, "insert_as_link_check");
@@ -93,6 +94,7 @@ void SdPhotoAlbumDialog::dispose()
pImg.clear();
pInsTypeCombo.clear();
pASRCheck.clear();
+ pASRCheckCrop.clear();
pCapCheck.clear();
pInsertAsLinkCheck.clear();
ModalDialog::dispose();
@@ -163,15 +165,14 @@ IMPL_LINK_NOARG_TYPED(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if(pASRCheck->IsChecked() && !pASRCheckCrop->IsChecked())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, aPageSize);
}
- else
+ else if(pASRCheckCrop->IsChecked())
{
- aPicSize.Width = aPageSize.Width;
- aPicSize.Height = aPageSize.Height;
+ aPicSize = createASRSizeCrop(aPicSize, aPageSize);
}
xShape->setSize(aPicSize);
@@ -698,6 +699,46 @@ awt::Size SdPhotoAlbumDialog::createASRSize(const awt::Size& aPicSize, const awt
return awt::Size(resizeWidth, resizeHeight);
}
+awt::Size SdPhotoAlbumDialog::createASRSizeCrop(const awt::Size& aPicSize, const awt::Size& aMaxSize)
+{
+ double resizeWidth = aPicSize.Width;
+ double resizeHeight = aPicSize.Height;
+ double imgAspect = resizeWidth / resizeHeight;
+ double windowAspectRatio = static_cast<double>(aMaxSize.Width) / aMaxSize.Height ;
+
+
+ //When both sides of an image are bigger than canvas size, image would be downscaled.
+ if( resizeWidth > aMaxSize.Width && resizeHeight > aMaxSize.Height )
+ {
+ if( imgAspect > windowAspectRatio )
+ {
+ resizeHeight = aMaxSize.Height;
+ resizeWidth = aMaxSize.Height * imgAspect;
+ }
+ else
+ {
+ resizeHeight = aMaxSize.Width / imgAspect;
+ resizeWidth = aMaxSize.Width;
+ }
+
+ }
+ //In all other cases image is upscaled
+ else
+ {
+ if( imgAspect > windowAspectRatio )
+ {
+ resizeHeight = aMaxSize.Height;
+ resizeWidth = aMaxSize.Height * imgAspect;
+ }
+ else
+ {
+ resizeWidth = aMaxSize.Width;
+ resizeHeight = aMaxSize.Width / imgAspect;
+ }
+ }
+ return awt::Size(resizeWidth, resizeHeight);
+}
+
void SdPhotoAlbumDialog::createCaption(const awt::Size& aPageSize )
{
Point CapPos;
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
index dfdefb0..cf8854a 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
@@ -65,6 +65,7 @@ private:
VclPtr<ListBox> pInsTypeCombo;
VclPtr<CheckBox> pASRCheck;
+ VclPtr<CheckBox> pASRCheckCrop;
VclPtr<CheckBox> pCapCheck;
VclPtr<CheckBox> pInsertAsLinkCheck;
@@ -85,6 +86,7 @@ private:
const Reference< drawing::XDrawPages >& xDrawPages);
static awt::Size createASRSize(const awt::Size& aPicSize, const awt::Size& aMaxSize);
+ static awt::Size createASRSizeCrop(const awt::Size& aPicSize, const awt::Size& aMaxSize);
void createCaption(const awt::Size& aPageSize);
static Reference< graphic::XGraphic> createXGraphicFromUrl(const OUString& sUrl,
const Reference< graphic::XGraphicProvider>& xProvider);
diff --git a/sd/uiconfig/simpress/ui/photoalbum.ui b/sd/uiconfig/simpress/ui/photoalbum.ui
index 66948ee..9b2e5ef 100644
--- a/sd/uiconfig/simpress/ui/photoalbum.ui
+++ b/sd/uiconfig/simpress/ui/photoalbum.ui
@@ -374,6 +374,22 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="asr_check_crop">
+ <property name="label" translatable="yes">Fill Screen</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="active">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
<child>
<object class="GtkCheckButton" id="insert_as_link_check">
<property name="label" translatable="yes">Link images</property>
More information about the Libreoffice-commits
mailing list