This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch AOO50X in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit eb76c9b3bfb7ce7d890ac889324e415ea72ee970 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]> (cherry picked from commit fb122de935def4d7d318cbb25ee0b9de0a4547ae) --- main/avmedia/source/viewer/mediawindow.cxx | 15 ++++----- main/svx/source/svdraw/svdomedia.cxx | 51 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/main/avmedia/source/viewer/mediawindow.cxx b/main/avmedia/source/viewer/mediawindow.cxx index 182b68ae88..f0ecd05f1f 100644 --- a/main/avmedia/source/viewer/mediawindow.cxx +++ b/main/avmedia/source/viewer/mediawindow.cxx @@ -526,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 617e092941..5b2dc39f23 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 - @@ -138,6 +179,10 @@ void SdrMediaObj::operator=(const SdrObject& rObj) { 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 )
