summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-07-03 16:33:36 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2017-07-04 10:28:35 +0200
commitdd74a659c60c1f0e7733d4244e808865377c6316 (patch)
tree402e767710ede69c40de175d26b3e2e8d3f57ac1 /svx
parentabc440a691efb872afac385ce5ed28cd5db56c8c (diff)
support for saving a modified image instead of original version
Normally when you save an image through the "Save..." entry in the context menu for an image, the saved image is the original one more eventually applied filters (which are not removeable). Further applied transformations like rotations, cropping, color effects are not included in the saved image. This patch offers the user to choose if saving the original image (with filters) or the modified version through a pop-up dialog. The new feature is available in Writer, Draw and Calc. Change-Id: I4f983e3a5e8a6839fa5789a96c4d8c44477c1fd7 Reviewed-on: https://gerrit.libreoffice.org/39480 Reviewed-by: Marco Cecchetti <mrcekets@gmail.com> Tested-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/core/graphichelper.cxx9
-rw-r--r--svx/source/core/graphichelper.src5
-rw-r--r--svx/source/svdraw/svdograf.cxx35
3 files changed, 36 insertions, 13 deletions
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx
index 86b1025e18f7..3a6df2b9e7f5 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -26,6 +26,8 @@
#include <svx/graphichelper.hxx>
#include <svx/dialogs.hrc>
+#include <vcl/layout.hxx>
+
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/anytostring.hxx>
#include <comphelper/processfactory.hxx>
@@ -284,4 +286,11 @@ void GraphicHelper::SaveShapeAsGraphic( const Reference< drawing::XShape >& xSha
}
}
+short GraphicHelper::HasToSaveTransformedImage(vcl::Window* pWin)
+{
+ OUString aMsg(SvxResId(RID_SVXSTR_SAVE_MODIFIED_IMAGE));
+ ScopedVclPtrInstance< MessageDialog > aBox(pWin, aMsg, VclMessageType::Question, VclButtonsType::YesNo);
+ return aBox->Execute();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/core/graphichelper.src b/svx/source/core/graphichelper.src
index 3432778c9cd9..c866076bed4d 100644
--- a/svx/source/core/graphichelper.src
+++ b/svx/source/core/graphichelper.src
@@ -28,4 +28,9 @@ String RID_SVXSTR_SAVEAS_IMAGE
{
Text [ en-US ] = "Save as Image" ;
};
+
+String RID_SVXSTR_SAVE_MODIFIED_IMAGE
+{
+ Text [ en-US ] = "The image has been modified. By default the original image will be saved.\nDo you want to save the modified version instead ?" ;
+};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 8c8d584e9abe..59c5a57e9125 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -474,20 +474,35 @@ Graphic SdrGrafObj::GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformF
// Refactored most of the code to GraphicObject, where
// everybody can use e.g. the cropping functionality
- GraphicType eType = GetGraphicType();
MapMode aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
const Size aDestSize( GetLogicRect().GetSize() );
- const bool bMirror = bool( nTransformFlags & SdrGrafObjTransformsAttrs::MIRROR );
- const bool bRotate = bool( nTransformFlags & SdrGrafObjTransformsAttrs::ROTATE ) &&
- ( aGeo.nRotationAngle && aGeo.nRotationAngle != 18000 ) && ( GraphicType::NONE != eType );
- // Need cropping info earlier
- const_cast<SdrGrafObj*>(this)->ImpSetAttrToGrafInfo();
+ GraphicAttr aActAttr = GetGraphicAttr(nTransformFlags);
+
+ // Delegate to moved code in GraphicObject
+ return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr );
+}
+
+GraphicType SdrGrafObj::GetGraphicType() const
+{
+ return pGraphic->GetType();
+}
+
+GraphicAttr SdrGrafObj::GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags ) const
+{
GraphicAttr aActAttr;
+ GraphicType eType = GetGraphicType();
if( SdrGrafObjTransformsAttrs::NONE != nTransformFlags &&
GraphicType::NONE != eType )
{
+ const bool bMirror = bool( nTransformFlags & SdrGrafObjTransformsAttrs::MIRROR );
+ const bool bRotate = bool( nTransformFlags & SdrGrafObjTransformsAttrs::ROTATE ) &&
+ ( aGeo.nRotationAngle && aGeo.nRotationAngle != 18000 ) && ( GraphicType::NONE != eType );
+
+ // Need cropping info earlier
+ const_cast<SdrGrafObj*>(this)->ImpSetAttrToGrafInfo();
+
// Actually transform the graphic only in this case.
// Cropping always happens, though.
aActAttr = aGrafInfo;
@@ -505,13 +520,7 @@ Graphic SdrGrafObj::GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformF
aActAttr.SetRotation( sal_uInt16(aGeo.nRotationAngle / 10) );
}
- // Delegate to moved code in GraphicObject
- return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr );
-}
-
-GraphicType SdrGrafObj::GetGraphicType() const
-{
- return pGraphic->GetType();
+ return aActAttr;
}
bool SdrGrafObj::IsAnimated() const