diff options
author | Vladislav Tarakanov <vladislav.tarakanov@bk.ru> | 2024-07-28 14:26:21 +0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-07-28 17:05:53 +0200 |
commit | c658efe24f7a7eb4234c1c64668ea115788272e7 (patch) | |
tree | 646d4d4fce0114b70cff69ead1d92fd1bcb46efb /slideshow/source | |
parent | 78090581d246cd391d99575680b5b8f8d9de7840 (diff) |
tdf#158510 Don't change the initial URL when using fallback
The current aURL conversions in the file "unoshap4.cxx"
result in the URL obtained when importing the file being replaced with a
new one formed from the presentation directory and file name.
As a result, the model changes and saving is requested
even if no changes were made to the presentation.
To fix this problem, we added saving the
presentation directory URL into the context for
transfer from SlideImpl to ViewMediaShape.
Regression after: fe897b36aef28dfe175461c43614e22588fcfd84
Change-Id: Ifda8610d0a4874ffa17e759fd45ddbbd2f934c0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170528
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'slideshow/source')
-rw-r--r-- | slideshow/source/engine/shapes/mediashape.cxx | 7 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/viewmediashape.cxx | 17 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/viewmediashape.hxx | 4 | ||||
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 9 | ||||
-rw-r--r-- | slideshow/source/inc/slideshowcontext.hxx | 1 |
5 files changed, 33 insertions, 5 deletions
diff --git a/slideshow/source/engine/shapes/mediashape.cxx b/slideshow/source/engine/shapes/mediashape.cxx index c81fc87072c0..d45dc7ec7b03 100644 --- a/slideshow/source/engine/shapes/mediashape.cxx +++ b/slideshow/source/engine/shapes/mediashape.cxx @@ -88,6 +88,7 @@ namespace slideshow::internal typedef ::std::vector< ViewMediaShapeSharedPtr > ViewMediaShapeVector; ViewMediaShapeVector maViewMediaShapes; bool mbIsPlaying; + OUString maFallbackDir; }; } @@ -97,7 +98,8 @@ namespace slideshow::internal const SlideShowContext& rContext ) : ExternalShapeBase( xShape, nPrio, rContext ), maViewMediaShapes(), - mbIsPlaying(false) + mbIsPlaying(false), + maFallbackDir(rContext.maFallbackDir) { } @@ -127,7 +129,8 @@ namespace slideshow::internal maViewMediaShapes.push_back( std::make_shared<ViewMediaShape>( rNewLayer, getXShape(), - mxComponentContext )); + mxComponentContext, + maFallbackDir )); // push new size to view shape maViewMediaShapes.back()->resize( getBounds() ); diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx index 83acbd7e5207..b31d392d8550 100644 --- a/slideshow/source/engine/shapes/viewmediashape.cxx +++ b/slideshow/source/engine/shapes/viewmediashape.cxx @@ -35,6 +35,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/range/b2irange.hxx> #include <canvas/canvastools.hxx> +#include <comphelper/DirectoryHelper.hxx> #include <cppcanvas/canvas.hxx> #include <avmedia/mediawindow.hxx> #include <svx/svdobj.hxx> @@ -59,7 +60,8 @@ namespace slideshow::internal { ViewMediaShape::ViewMediaShape( const ViewLayerSharedPtr& rViewLayer, uno::Reference< drawing::XShape > xShape, - uno::Reference< uno::XComponentContext > xContext ) : + uno::Reference< uno::XComponentContext > xContext, + const OUString& aFallbackDir ) : mpViewLayer( rViewLayer ), maWindowOffset( 0, 0 ), maBounds(), @@ -67,7 +69,8 @@ namespace slideshow::internal mxPlayer(), mxPlayerWindow(), mxComponentContext(std::move( xContext )), - mbIsSoundEnabled(true) + mbIsSoundEnabled(true), + maFallbackDir(aFallbackDir) { ENSURE_OR_THROW( mxShape.is(), "ViewMediaShape::ViewMediaShape(): Invalid Shape" ); ENSURE_OR_THROW( mpViewLayer, "ViewMediaShape::ViewMediaShape(): Invalid View" ); @@ -294,6 +297,16 @@ namespace slideshow::internal } else if (xPropSet->getPropertyValue(u"MediaURL"_ustr) >>= aURL) { + if ( maFallbackDir.getLength() && + aURL.startsWith("file:///") && + !comphelper::DirectoryHelper::fileExists(aURL) ) + { + auto fileNameStartIdx = aURL.lastIndexOf("/"); + if (fileNameStartIdx != -1) + { + aURL = OUString::Concat(maFallbackDir) + aURL.subView(fileNameStartIdx + 1); + } + } implInitializeMediaPlayer( aURL, sMimeType ); } } diff --git a/slideshow/source/engine/shapes/viewmediashape.hxx b/slideshow/source/engine/shapes/viewmediashape.hxx index fc37a3add8ce..34be8536b73b 100644 --- a/slideshow/source/engine/shapes/viewmediashape.hxx +++ b/slideshow/source/engine/shapes/viewmediashape.hxx @@ -65,7 +65,8 @@ namespace slideshow::internal */ ViewMediaShape( const ViewLayerSharedPtr& rViewLayer, css::uno::Reference< css::drawing::XShape > xShape, - css::uno::Reference< css::uno::XComponentContext > xContext ); + css::uno::Reference< css::uno::XComponentContext > xContext, + const OUString& aFallbackDir ); /** destroy the object */ @@ -157,6 +158,7 @@ namespace slideshow::internal css::uno::Reference< css::media::XPlayerWindow > mxPlayerWindow; css::uno::Reference< css::uno::XComponentContext> mxComponentContext; bool mbIsSoundEnabled; + OUString maFallbackDir; }; typedef ::std::shared_ptr< ViewMediaShape > ViewMediaShapeSharedPtr; diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 1468b24bff5a..a4ff70043b05 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/awt/SystemPointer.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/presentation/ParagraphTarget.hpp> #include <com/sun/star/presentation/EffectNodeType.hpp> @@ -1039,6 +1040,14 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra mbPaintOverlayActive( false ), mbFinalStateApplied( false ) { + if (uno::Reference<frame::XModel> xModel{ mxDrawPagesSupplier, uno::UNO_QUERY }) + { + OUString presentationURL = xModel->getURL(); + auto fileDirectoryEndIdx = presentationURL.lastIndexOf("/"); + if (presentationURL.startsWith("file:///") && fileDirectoryEndIdx != -1) + maContext.maFallbackDir = OUString::Concat(presentationURL.subView(0, fileDirectoryEndIdx + 1)); + } + // clone already existing views for slide bitmaps for( const auto& rView : rViewContainer ) viewAdded( rView ); diff --git a/slideshow/source/inc/slideshowcontext.hxx b/slideshow/source/inc/slideshowcontext.hxx index f745c30f25da..d0f8bbf432ea 100644 --- a/slideshow/source/inc/slideshowcontext.hxx +++ b/slideshow/source/inc/slideshowcontext.hxx @@ -108,6 +108,7 @@ namespace slideshow::internal const UnoViewContainer& mrViewContainer; css::uno::Reference< css::uno::XComponentContext> mxComponentContext; box2d::utils::Box2DWorldSharedPtr& mpBox2DWorld; + OUString maFallbackDir; }; } |