sw/source/uibase/uiview/view2.cxx |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

New commits:
commit a6c9519b5f92eab604a8884aa6db4e8f1ac616b3
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 17 11:17:33 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jan 17 12:16:36 2025 +0100

    tdf#137848 Speed up inserting rotated image
    
    Since writer supports displaying rotation now, we don't need to convert
    and rotate the image data itself
    
    Change-Id: I547d8da98125f8956badeb0c113f2d6ab332ee86
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180380
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index 74b2b9f738ab..a566915a7e16 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -157,6 +157,7 @@
 #include <basegfx/utils/zoomtools.hxx>
 
 #include <ndtxt.hxx>
+#include <grfatr.hxx>
 
 #include <svx/srchdlg.hxx>
 #include <o3tl/string_view.hxx>
@@ -330,19 +331,13 @@ ErrCode SwView::InsertGraphic( const OUString &rPath, 
const OUString &rFilter,
 
     if( ERRCODE_NONE == aResult )
     {
+        Degree10 aRotation;
         GraphicNativeMetadata aMetadata;
         if ( aMetadata.read(aGraphic) )
-        {
-            const Degree10 aRotation = aMetadata.getRotation();
-            if (aRotation)
-            {
-                GraphicNativeTransform aTransform( aGraphic );
-                aTransform.rotate( aRotation );
-            }
-        }
+            aRotation = aMetadata.getRotation();
 
-        SwFlyFrameAttrMgr aFrameManager( true, GetWrtShellPtr(), 
Frmmgr_Type::GRF, nullptr );
         SwWrtShell& rShell = GetWrtShell();
+        SwFlyFrameAttrMgr aFrameManager( true, &rShell, Frmmgr_Type::GRF, 
nullptr );
 
         // #i123922# determine if we really want to insert or replace the 
graphic at a selected object
         const bool bReplaceMode(rShell.HasSelection() && SelectionType::Frame 
== rShell.GetSelectionType());
@@ -376,6 +371,14 @@ ErrCode SwView::InsertGraphic( const OUString &rPath, 
const OUString &rFilter,
                 rShell.InsertGraphic( OUString(), OUString(), aGraphic, 
&aFrameManager );
             }
 
+            if (aRotation)
+            {
+                SfxItemSetFixed<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION> 
aSet( rShell.GetAttrPool() );
+                rShell.GetCurAttr( aSet );
+                const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION);
+                aFrameManager.SetRotation(rRotation.GetValue(), aRotation, 
rRotation.GetUnrotatedSize());
+            }
+
             // it is too late after "EndAction" because the Shell can already 
be destroyed.
             rShell.EndAction();
         }

Reply via email to