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 /sw | |
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 'sw')
-rw-r--r-- | sw/inc/editsh.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/edit/editsh.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/shells/grfsh.cxx | 38 |
3 files changed, 44 insertions, 3 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index e031303b6aae..888ee55c26ce 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -78,6 +78,7 @@ class SwCharFormat; class SwExtTextInput; class Graphic; class GraphicObject; +class GraphicAttr; class SwFormatINetFormat; class SwTable; class SwTextBlocks; @@ -609,6 +610,7 @@ public: const Graphic* GetGraphic( bool bWait = true ) const; const GraphicObject* GetGraphicObj() const; + const GraphicAttr* GetGraphicAttr( GraphicAttr& rGA ) const; bool IsLinkedGrfSwapOut() const; GraphicType GetGraphicType() const; diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0a0057a17dc5..ddabe6bc4fa7 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -258,6 +258,13 @@ const GraphicObject* SwEditShell::GetGraphicObj() const return pGrfNode ? &(pGrfNode->GetGrfObj()) : nullptr; } +const GraphicAttr* SwEditShell::GetGraphicAttr( GraphicAttr& rGA ) const +{ + SwGrfNode* pGrfNode = GetGrfNode_(); + const SwFrame* pFrame = GetCurrFrame(false); + return pGrfNode ? &(pGrfNode->GetGraphicAttr( rGA, pFrame )) : nullptr; +} + GraphicType SwEditShell::GetGraphicType() const { SwGrfNode *pGrfNode = GetGrfNode_(); diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index 8553c3ed8f38..c269f75ba66a 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -132,13 +132,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; |