summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/grfsh.cxx
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 /sw/source/uibase/shells/grfsh.cxx
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 'sw/source/uibase/shells/grfsh.cxx')
-rw-r--r--sw/source/uibase/shells/grfsh.cxx38
1 files changed, 35 insertions, 3 deletions
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index b0f44cf62fbe..583a234443fe 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -131,13 +131,45 @@ void SwGrfShell::Execute(SfxRequest &rReq)
case SID_SAVE_GRAPHIC:
{
- const Graphic *pGraphic;
- if(nullptr != (pGraphic = rSh.GetGraphic()))
+ GraphicAttr aGraphicAttr;
+ const GraphicObject* pGraphicObj = rSh.GetGraphicObj();
+ if (pGraphicObj)
{
+ rSh.GetGraphicAttr(aGraphicAttr);
+ }
+
+ short nState = RET_CANCEL;
+ if (aGraphicAttr != GraphicAttr()) // the image has been modified
+ {
+ vcl::Window* pWin = GetView().GetWindow();
+ if (pWin)
+ {
+ nState = GraphicHelper::HasToSaveTransformedImage(pWin);
+ }
+ }
+ else
+ {
+ nState = RET_NO;
+ }
+
+ if (nState == RET_YES)
+ {
+ Graphic aGraphic = pGraphicObj->GetTransformedGraphic(pGraphicObj->GetPrefSize(), pGraphicObj->GetPrefMapMode(), aGraphicAttr);
OUString sGrfNm;
OUString sFilterNm;
rSh.GetGrfNms( &sGrfNm, &sFilterNm );
- GraphicHelper::ExportGraphic( *pGraphic, sGrfNm );
+ GraphicHelper::ExportGraphic( aGraphic, sGrfNm );
+ }
+ else if (nState == RET_NO)
+ {
+ const Graphic *pGraphic;
+ if(nullptr != (pGraphic = rSh.GetGraphic()))
+ {
+ OUString sGrfNm;
+ OUString sFilterNm;
+ rSh.GetGrfNms( &sGrfNm, &sFilterNm );
+ GraphicHelper::ExportGraphic( *pGraphic, sGrfNm );
+ }
}
}
break;