summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAbhilash <abhilash300singh@gmail.com>2016-07-29 00:19:27 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-09-07 18:02:22 +0000
commit511acc66f543b0200ebe70cf072e5a8db8677809 (patch)
tree8486aa1aa6eb4885b45f9f5f4b79829d87ae19ae /sd
parent6323e6628668849438e6e19ba7ad2c6598263261 (diff)
tdf#64575 Photo Album: Better Image Layout
Change-Id: I021c5fa921eb80edd996e0224e69e3b3d54b76d3 Reviewed-on: https://gerrit.libreoffice.org/27654 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.cxx49
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.hxx2
-rw-r--r--sd/uiconfig/simpress/ui/photoalbum.ui16
3 files changed, 63 insertions, 4 deletions
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 9622b8c1acde..c1de735bb19e 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 dfdefb071938..cf8854a58fb8 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 66948ee038d8..9b2e5ef1a24f 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>