diff options
author | himajin100000 <himajin100000@gmail.com> | 2018-03-17 07:00:02 +0900 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-03-27 15:06:09 +0200 |
commit | e97ab52a83d2440ca42c85229ef794549208cb7d (patch) | |
tree | ae53c67d057fe0ee1a4d7c3cf89565a280f1a10d | |
parent | 6d05579c7fceb0f3ce83abe25bdfe62b26c29671 (diff) |
tdf#116438:Apps should ask if rotation should be applied
For Calc,Draw,Impress. Writer already does this.
Change-Id: I92512719673fb39a973b8a68378e93f30d82c327
Reviewed-on: https://gerrit.libreoffice.org/51447
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | sc/inc/pch/precompiled_scui.hxx | 3 | ||||
-rw-r--r-- | sc/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fuins1.cxx | 23 | ||||
-rw-r--r-- | sd/inc/pch/precompiled_sd.hxx | 3 | ||||
-rw-r--r-- | sd/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 19 |
6 files changed, 46 insertions, 4 deletions
diff --git a/sc/inc/pch/precompiled_scui.hxx b/sc/inc/pch/precompiled_scui.hxx index 08321aeca6f3..244b05d121cb 100644 --- a/sc/inc/pch/precompiled_scui.hxx +++ b/sc/inc/pch/precompiled_scui.hxx @@ -45,6 +45,9 @@ #include <vcl/svapp.hxx> #include <vcl/waitobj.hxx> #include <vcl/window.hxx> +#include <vcl/weld.hxx> +#include <vcl/GraphicNativeTransform.hxx> +#include <vcl/GraphicNativeMetadata.hxx> #include <appoptio.hxx> #include <attrib.hxx> #include <autoform.hxx> diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index 02596e6bccdd..29ee57ae53f8 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -47,6 +47,7 @@ #define SCSTR_NO_TAB_BG_COLOR NC_("SCSTR_NO_TAB_BG_COLOR", "Default") #define SCSTR_RENAMEOBJECT NC_("SCSTR_RENAMEOBJECT", "Name Object") #define STR_INSERTGRAPHIC NC_("STR_INSERTGRAPHIC", "Insert Image") +#define STR_QUERYROTATION NC_("STR_QUERYROTATION", "This image is rotated. Would you like to rotate it into standard orientation?") #define SCSTR_TOTAL NC_("SCSTR_TOTAL", "%1 results found") #define SCSTR_SKIPPED NC_("SCSTR_SKIPPED", "(only %1 are listed)") // Attribute diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index 72c243bbe882..b7c4ed8d5e8b 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -31,7 +31,9 @@ #include <svtools/miscopt.hxx> #include <avmedia/mediawindow.hxx> #include <vcl/svapp.hxx> - +#include <vcl/weld.hxx> +#include <vcl/GraphicNativeTransform.hxx> +#include <vcl/GraphicNativeMetadata.hxx> #include <fuinsert.hxx> #include <tabvwsh.hxx> #include <drwlayer.hxx> @@ -100,6 +102,21 @@ static void lcl_InsertGraphic( const Graphic& rGraphic, ScTabViewShell* pViewSh, const vcl::Window* pWindow, SdrView* pView, ScAnchorType aAnchorType = SCA_CELL ) { + Graphic& rGraphic1 = const_cast<Graphic &>(rGraphic); + GraphicNativeMetadata aMetadata; + if ( aMetadata.read(rGraphic1) ) + { + const sal_uInt16 aRotation = aMetadata.getRotation(); + if (aRotation != 0) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, VclMessageType::Question,VclButtonsType::YesNo,ScResId(STR_QUERYROTATION))); + if (xQueryBox->run() == RET_YES) + { + GraphicNativeTransform aTransform( rGraphic1 ); + aTransform.rotate( aRotation ); + } + } + } ScDrawView* pDrawView = pViewSh->GetScDrawView(); // #i123922# check if an existing object is selected; if yes, evtl. replace @@ -117,7 +134,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic, SdrObject* pResult = pDrawView->ApplyGraphicToObject( *pPickObj, - rGraphic, + rGraphic1, aBeginUndo, bAsLink ? rFileName : OUString(), bAsLink ? rFilterName : OUString()); @@ -160,7 +177,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic, tools::Rectangle aRect ( aInsertPos, aLogicSize ); - SdrGrafObj* pObj = new SdrGrafObj( rGraphic, aRect ); + SdrGrafObj* pObj = new SdrGrafObj( rGraphic1, aRect ); // calling SetGraphicLink here doesn't work diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx index e02b65cbae48..0f42d8defb23 100644 --- a/sd/inc/pch/precompiled_sd.hxx +++ b/sd/inc/pch/precompiled_sd.hxx @@ -138,7 +138,10 @@ #include <vcl/waitobj.hxx> #include <vcl/window.hxx> #include <vcl/wrkwin.hxx> +#include <vcl/weld.hxx> #include <Annotation.hxx> +#include <vcl/GraphicNativeTransform.hxx> +#include <vcl/GraphicNativeMetadata.hxx> #include <CustomAnimationEffect.hxx> #include <CustomAnimationPreset.hxx> #include <EffectMigration.hxx> diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc index 52b5d6796cdd..1a5a829044ec 100644 --- a/sd/inc/strings.hrc +++ b/sd/inc/strings.hrc @@ -31,6 +31,7 @@ #define STR_UNDO_REPLACE NC_("STR_UNDO_REPLACE", "Replace") #define STR_UNDO_DRAGDROP NC_("STR_UNDO_DRAGDROP", "Drag and Drop") #define STR_INSERTGRAPHIC NC_("STR_INSERTGRAPHIC", "Insert Image") +#define STR_QUERYROTATION NC_("STR_QUERYROTATION", "This image is rotated. Would you like to rotate it into standard orientation?") #define STR_UNDO_BEZCLOSE NC_("STR_UNDO_BEZCLOSE", "Close Polygon") #define STR_SLIDE_SORTER_MODE NC_("STR_SLIDE_SORTER_MODE", "Slide Sorter") #define STR_NORMAL_MODE NC_("STR_NORMAL_MODE", "Normal") diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index fa6cbcc8f0f3..4cb2845d13fe 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -20,7 +20,6 @@ #include <config_features.h> #include <fuinsert.hxx> - #include <comphelper/storagehelper.hxx> #include <comphelper/processfactory.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -84,6 +83,10 @@ #include <vcl/svapp.hxx> #include <undo/undoobjects.hxx> #include <memory> +#include <vcl/weld.hxx> + +#include <vcl/GraphicNativeTransform.hxx> +#include <vcl/GraphicNativeMetadata.hxx> using namespace com::sun::star; @@ -150,6 +153,20 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq ) if( nError == ERRCODE_NONE ) { + GraphicNativeMetadata aMetadata; + if ( aMetadata.read(aGraphic) ) + { + const sal_uInt16 aRotation = aMetadata.getRotation(); + if (aRotation != 0) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, VclMessageType::Question,VclButtonsType::YesNo,SdResId(STR_QUERYROTATION))); + if (xQueryBox->run() == RET_YES) + { + GraphicNativeTransform aTransform( aGraphic ); + aTransform.rotate( aRotation ); + } + } + } if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr) { sal_Int8 nAction = DND_ACTION_COPY; |