sc/source/ui/drawfunc/fuins1.cxx         |   12 ++++++++++++
 sd/qa/uitest/impress_tests2/tdf146019.py |    4 ++--
 sd/source/ui/func/fuinsert.cxx           |   13 +++++++++++++
 sw/source/uibase/dochdl/swdtflvr.cxx     |   22 ++++++++++++++++++++++
 vcl/source/filter/graphicfilter.cxx      |   11 -----------
 5 files changed, 49 insertions(+), 13 deletions(-)

New commits:
commit 97e5975b4f39bdce902131a3a3c06edd05730b82
Author:     Xisco Fauli <[email protected]>
AuthorDate: Fri Jan 16 15:55:45 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Jan 19 17:22:12 2026 +0100

    tdf169376: Revert "tdf#137833 Always respect EXIF Orientation...
    
    ...tag when importing a JPEG"
    
    This reverts commit 0200a718af66ec1e8d2e41e937aaebcd337a147e.
    
    Revert it before the LibreOffice 26.2 final release until
    a better solution is found. tdf#137833 can be reproduced
    back to OpenOffice 3.0 so it's better to have an old known
    bug than introducing a new one which might affect many
    existing documents
    
    Change-Id: I8c4dae60c9116514fc8b2405aae6ec1df9df6430
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197458
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 5193ccbd44cc..d11d86ebc83c 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -37,6 +37,8 @@
 #include <avmedia/mediawindow.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld/weld.hxx>
+#include <vcl/GraphicNativeTransform.hxx>
+#include <vcl/GraphicNativeMetadata.hxx>
 #include <fuinsert.hxx>
 #include <tabvwsh.hxx>
 #include <drwlayer.hxx>
@@ -112,6 +114,16 @@ 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 dc568b5151c2..86b8ed48180f 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(8995, shape.getSize().Width)
-            self.assertEqual(11746, shape.getSize().Height)
+            self.assertEqual(8996, shape.getSize().Width)
+            self.assertEqual(11745, 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 8239d746c010..45cd2b2ceafa 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -80,6 +80,9 @@
 #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;
@@ -153,6 +156,16 @@ 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 3d46261971d4..cc6187d995a6 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -131,6 +131,8 @@
 #include <vcl/uitest/logger.hxx>
 #include <vcl/uitest/eventdescription.hxx>
 
+#include <vcl/GraphicNativeTransform.hxx>
+#include <vcl/GraphicNativeMetadata.hxx>
 #include <vcl/TypeSerializer.hxx>
 #include <comphelper/lok.hxx>
 #include <sfx2/classificationhelper.hxx>
@@ -420,6 +422,20 @@ 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()
@@ -2588,6 +2604,9 @@ bool SwTransferable::PasteTargetURL( const 
TransferableDataHelper& rData,
 
             if( bRet )
             {
+                //Check and Perform rotation if needed
+                lclCheckAndPerformRotation(aGraphic);
+
                 switch( nAction )
                 {
                 case SwPasteSdr::Insert:
@@ -2996,6 +3015,9 @@ 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 b3d30f0c4a10..88f892e20b23 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -88,8 +88,6 @@
 #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"
 
@@ -952,15 +950,6 @@ ErrCode GraphicFilter::readJPEG(SvStream & rStream, 
Graphic & rGraphic, GfxLinkT
     rGraphic = Graphic(*aImportOutput.moBitmap);
     rLinkType = GfxLinkType::NativeJpg;
 
-    // Get Orientation from EXIF data
-    if (GraphicNativeMetadata aMetadata; aMetadata.read(rStream))
-    {
-        if (Degree10 aRotation = aMetadata.getRotation())
-        {
-            GraphicNativeTransform(rGraphic).rotate(aRotation);
-        }
-    }
-
     return ERRCODE_NONE;
 }
 

Reply via email to