This is an automated email from the ASF dual-hosted git repository.
ardovm pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO41X by this push:
new 3e3ee956bf svx, avmedia: put the media question when the URL is set,
not while painting
3e3ee956bf is described below
commit 3e3ee956bf18f5160ce425680b071f84dfd485a4
Author: Peter <[email protected]>
AuthorDate: Wed Sep 30 22:28:23 2026 +0200
svx, avmedia: put the media question when the URL is set, not while painting
Avoid multiple popups.
Keep the checks where they are, but have the question put earlier, in a
place that does not paint: when a media object gets its URL -- on insertion,
while the document loads, through the API -- ask the document that holds the
object. Its LinkManager keeps the answer, and the checks made later while a
view paints get it without a question. A copy takes the URL without asking
again.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
main/avmedia/source/viewer/mediawindow.cxx | 16 ++++-----
main/svx/source/svdraw/svdomedia.cxx | 53 +++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/main/avmedia/source/viewer/mediawindow.cxx
b/main/avmedia/source/viewer/mediawindow.cxx
index 4b1a5c4f62..7f99f64230 100644
--- a/main/avmedia/source/viewer/mediawindow.cxx
+++ b/main/avmedia/source/viewer/mediawindow.cxx
@@ -33,7 +33,6 @@
#include <sfx2/filedlghelper.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <svtools/linkpolicy.hxx>
#include <com/sun/star/media/XManager.hpp>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
@@ -527,18 +526,15 @@ uno::Reference< graphic::XGraphic >
MediaWindow::grabFrame( const ::rtl::OUStrin
bool
bAllowToCreateReplacementGraphic,
double fMediaTime )
{
- uno::Reference< media::XPlayer > xPlayer;
+ // createPlayer() applies the shared policy (mayLoadDocumentReference): a
+ // relative reference or a local file is grabbed without asking. This runs
+ // while a view paints, so it must not put a question to the user for the
+ // ordinary case; anything else has been put to the document already, when
+ // the media object got its URL (see SdrMediaObj).
+ uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL ) );
uno::Reference< graphic::XGraphic > xRet;
::std::auto_ptr< Graphic > apGraphic;
- // Stricter than mayLoadDocumentReference: a grabbed frame is drawn into
the
- // document and exported with it, so any reference that carries a scheme is
- // put to the document, a local file included. A relative reference is the
- // document's own content and is grabbed as before.
- if( !::svt::linkpolicy::isAbsoluteUrl( rURL )
- || ::svt::linkpolicy::mayFollowDocumentLink( rURL ) )
- xPlayer = createPlayer( rURL );
-
if( xPlayer.is() )
{
uno::Reference< media::XFrameGrabber > xGrabber(
xPlayer->createFrameGrabber() );
diff --git a/main/svx/source/svdraw/svdomedia.cxx
b/main/svx/source/svdraw/svdomedia.cxx
index 8548c9d49a..0dbc63a711 100644
--- a/main/svx/source/svdraw/svdomedia.cxx
+++ b/main/svx/source/svdraw/svdomedia.cxx
@@ -30,7 +30,48 @@
#include "svx/svdglob.hxx"
#include "svx/svdstr.hrc"
#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+#include <svx/svdmodel.hxx>
#include <avmedia/mediawindow.hxx>
+#include <svtools/linkpolicy.hxx>
+
+#include <com/sun/star/document/XLinkAuthorizer.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+using namespace ::com::sun::star;
+
+namespace {
+
+// Asks the document that holds the media object whether rURL may be loaded.
+// The document's LinkManager keeps the answer, so the checks that avmedia
makes
+// later -- some of them while a view paints -- get it without a question.
+// A reference mayLoadDocumentReference() accepts without asking (relative, or
+// a local file) needs nothing; nor does a model without a document behind it.
+void lcl_authorizeURL( SdrModel* pModel, const ::rtl::OUString& rURL )
+{
+ if( !pModel || !pModel->GetPersist() || rURL.getLength() == 0 )
+ return;
+
+ if( !::svt::linkpolicy::isAbsoluteUrl( rURL ) )
+ {
+ if( !rURL.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM( "\\\\" ) )
+ && !rURL.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM( "//" ) ) )
+ return;
+ }
+ else if( ::svt::linkpolicy::isLocalFileUrl( rURL ) )
+ return;
+
+ try
+ {
+ const uno::Reference< document::XLinkAuthorizer > xAuthorizer(
pModel->getUnoModel(), uno::UNO_QUERY );
+ if( xAuthorizer.is() )
+ xAuthorizer->authorizeLinks( rURL );
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+}
+
+}
// ---------------
// - SdrMediaObj -
@@ -137,7 +178,11 @@ void SdrMediaObj::operator=(const SdrObject& rObj)
if( rObj.ISA( SdrMediaObj ) )
{
const SdrMediaObj& rMediaObj = static_cast< const SdrMediaObj& >( rObj
);
-
+
+ // A copy is not a new reference from document content: take the URL
+ // first, so mediaPropertiesChanged() sees no change and asks nobody
+ // (a copy to the clipboard would otherwise put the question again).
+ maMediaProperties.setURL( rMediaObj.getURL() );
setMediaProperties( rMediaObj.getMediaProperties() );
setGraphic( rMediaObj.mapGraphic.get() );
}
@@ -265,6 +310,12 @@ void SdrMediaObj::mediaPropertiesChanged( const
::avmedia::MediaItem& rNewProper
{
setGraphic();
maMediaProperties.setURL( rNewProperties.getURL() );
+
+ // The URL is set on insertion, while a document loads, and
through
+ // the API -- never while painting. Put the question now, so
that the
+ // checks made later while a view paints (the player and the
frame
+ // grab in avmedia) find the document's answer already given.
+ lcl_authorizeURL( GetModel(), getURL() );
}
if( AVMEDIA_SETMASK_LOOP & nMaskSet )