diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2017-07-03 16:33:36 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-07-05 09:48:19 +0200 |
commit | 970a2517d27336deb8b140f31371f37ea1c890f6 (patch) | |
tree | 2598ca7da9d0727b60b95c1e25875bc8aa0393c9 /svx | |
parent | 89d56ad70a5b43509d647d89d0cd12e481642954 (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 rotation, 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/39487
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/core/graphichelper.cxx | 9 | ||||
-rw-r--r-- | svx/source/core/graphichelper.src | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 35 |
3 files changed, 36 insertions, 13 deletions
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx index 5be57e8a8c2a..0e2497fa072a 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(SVX_RESSTR(RID_SVXSTR_SAVE_MODIFIED_IMAGE)); + ScopedVclPtrInstance< MessageDialog > aBox(pWin, aMsg, VclMessageType::Question, VCL_BUTTONS_YES_NO); + 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 7234d08e8f8d..60104fe90d50 100644 --- a/svx/source/core/graphichelper.src +++ b/svx/source/core/graphichelper.src @@ -24,4 +24,9 @@ String RID_SVXSTR_EXPORT_GRAPHIC_TITLE Text [ en-US ] = "Image Export" ; }; + +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 002ac8f77db2..cc14814fc7dc 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -479,20 +479,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; @@ -510,13 +525,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 |