summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2025-09-09 15:09:59 +0200
committerAndras Timar <andras.timar@collabora.com>2025-09-10 10:23:44 +0200
commit0200a718af66ec1e8d2e41e937aaebcd337a147e (patch)
tree5b335a2e590afae5e173dd74545e669113ac1cbf
parentc5f4ff057e78ab69c14423c269e2040a7ec15f78 (diff)
tdf#137833 Always respect EXIF Orientation tag when importing a JPEG
Previously EXIF Orientation tag was read only via the Insert -> Image route. Now it is respected even via File -> Open or drag&drop. Change-Id: I16a79940823f4a62e8df5fa5d7c2e28a755e3460 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190717 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190733 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Jenkins
-rw-r--r--sc/source/ui/drawfunc/fuins1.cxx12
-rw-r--r--sd/qa/uitest/impress_tests2/tdf146019.py4
-rw-r--r--sd/source/ui/func/fuinsert.cxx13
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx22
-rw-r--r--vcl/source/filter/graphicfilter.cxx14
5 files changed, 16 insertions, 49 deletions
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 38e6684c0dec..d9a1d83568c3 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -37,8 +37,6 @@
#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>
@@ -114,16 +112,6 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
ScAnchorType aAnchorType = SCA_CELL )
{
Graphic& rGraphic1 = const_cast<Graphic &>(rGraphic);
- GraphicNativeMetadata aMetadata;
- if ( aMetadata.read(rGraphic1) )
- {
- const Degree10 aRotation = aMetadata.getRotation();
- if (aRotation)
- {
- GraphicNativeTransform aTransform( rGraphic1 );
- aTransform.rotate( aRotation );
- }
- }
ScDrawView* pDrawView = rViewSh.GetScDrawView();
// #i123922# check if an existing object is selected; if yes, evtl. replace
diff --git a/sd/qa/uitest/impress_tests2/tdf146019.py b/sd/qa/uitest/impress_tests2/tdf146019.py
index 86b8ed48180f..dc568b5151c2 100644
--- a/sd/qa/uitest/impress_tests2/tdf146019.py
+++ b/sd/qa/uitest/impress_tests2/tdf146019.py
@@ -29,7 +29,7 @@ class tdf146019(UITestCase):
# Check the shape is rotated, height > width
shape = document.getDrawPages()[0][2]
- self.assertEqual(8996, shape.getSize().Width)
- self.assertEqual(11745, shape.getSize().Height)
+ self.assertEqual(8995, shape.getSize().Width)
+ self.assertEqual(11746, shape.getSize().Height)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 041a4465172a..1b88fc4ff891 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -80,9 +80,6 @@
#include <vcl/errinf.hxx>
#include <vcl/graphicfilter.hxx>
-#include <vcl/GraphicNativeTransform.hxx>
-#include <vcl/GraphicNativeMetadata.hxx>
-
#include <comphelper/lok.hxx>
using namespace com::sun::star;
@@ -156,16 +153,6 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
if( nError == ERRCODE_NONE )
{
- GraphicNativeMetadata aMetadata;
- if ( aMetadata.read(aGraphic) )
- {
- const Degree10 aRotation = aMetadata.getRotation();
- if (aRotation)
- {
- GraphicNativeTransform aTransform( aGraphic );
- aTransform.rotate( aRotation );
- }
- }
if( dynamic_cast< DrawViewShell *>( &mrViewShell ) )
{
sal_Int8 nAction = DND_ACTION_COPY;
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index bbd0fe4ac382..610bc9d3b7f5 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -136,8 +136,6 @@
#include <vcl/uitest/eventdescription.hxx>
#include <svx/GenericDropDownFieldDialog.hxx>
-#include <vcl/GraphicNativeTransform.hxx>
-#include <vcl/GraphicNativeMetadata.hxx>
#include <vcl/TypeSerializer.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/classificationhelper.hxx>
@@ -427,20 +425,6 @@ namespace
rDest.GetMetaFieldManager().copyDocumentProperties(rSrc);
}
-
- void lclCheckAndPerformRotation(Graphic& aGraphic)
- {
- GraphicNativeMetadata aMetadata;
- if ( !aMetadata.read(aGraphic) )
- return;
-
- Degree10 aRotation = aMetadata.getRotation();
- if (aRotation)
- {
- GraphicNativeTransform aTransform( aGraphic );
- aTransform.rotate( aRotation );
- }
- }
}
sal_Bool SAL_CALL SwTransferable::isComplex()
@@ -2631,9 +2615,6 @@ bool SwTransferable::PasteTargetURL( const TransferableDataHelper& rData,
if( bRet )
{
- //Check and Perform rotation if needed
- lclCheckAndPerformRotation(aGraphic);
-
switch( nAction )
{
case SwPasteSdr::Insert:
@@ -3040,9 +3021,6 @@ bool SwTransferable::PasteGrf( const TransferableDataHelper& rData, SwWrtShell&
if( bRet )
{
- //Check and Perform rotation if needed
- lclCheckAndPerformRotation(aGraphic);
-
OUString sURL;
if( dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) != nullptr
// #i123922# if link action is noted, also take URL
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index d9a2802c25b7..49b385628de6 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -88,6 +88,8 @@
#include <o3tl/string_view.hxx>
#include <o3tl/test_info.hxx>
#include <vcl/TypeSerializer.hxx>
+#include <vcl/GraphicNativeMetadata.hxx>
+#include <vcl/GraphicNativeTransform.hxx>
#include "FilterConfigCache.hxx"
@@ -977,6 +979,18 @@ ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkT
}
}
+ // Get Orientation from EXIF data
+ GraphicNativeMetadata aMetadata;
+ if (aMetadata.read(rStream))
+ {
+ Degree10 aRotation = aMetadata.getRotation();
+ if (aRotation)
+ {
+ GraphicNativeTransform aTransform(rGraphic);
+ aTransform.rotate(aRotation);
+ }
+ }
+
return aReturnCode;
}