29#include <com/sun/star/ucb/ContentCreationException.hpp>
30#include <com/sun/star/ucb/XContent.hpp>
31#include <com/sun/star/task/XInteractionHandler.hpp>
32#include <com/sun/star/io/XStream.hpp>
33#include <com/sun/star/io/XActiveDataSink.hpp>
34#include <com/sun/star/io/XSeekable.hpp>
35#include <com/sun/star/lang/IllegalArgumentException.hpp>
36#include <com/sun/star/uri/UriReferenceFactory.hpp>
37#include <com/sun/star/uri/XUriReference.hpp>
38#include <com/sun/star/ucb/PostCommandArgument2.hpp>
39#include <officecfg/Office/Common.hxx>
45#include <osl/diagnose.h>
52OUString removeFragment(OUString
const & uri) {
53 css::uno::Reference< css::uri::XUriReference > ref(
54 css::uri::UriReferenceFactory::create(
59 return ref->getUriReference();
61 SAL_WARN(
"unotools.misc",
"cannot parse <" << uri <<
">");
73 : SequenceAsHashMap(lSource)
108 css::uno::Reference< css::ucb::XContentIdentifier > xId = xContent->getIdentifier();
111 aScheme = xId->getContentProviderScheme();
113 if (aScheme.equalsIgnoreAsciiCase(
"file"))
124 catch(
const css::uno::RuntimeException& )
126 catch(
const css::uno::Exception&)
135 if( aPropertyIter !=
end() )
137 return css::uno::Any();
142 if( rValue.hasValue() )
147 bool bHasNamedValues = !rCompDataAny.hasValue() || rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
148 bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
149 OSL_ENSURE( bHasNamedValues || bHasPropValues,
"MediaDescriptor::setComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
150 if( bHasNamedValues || bHasPropValues )
154 aCompDataMap[ rName ] = rValue;
169 if( aPropertyIter ==
end() )
172 css::uno::Any& rCompDataAny = aPropertyIter->second;
173 bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
174 bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
175 OSL_ENSURE( bHasNamedValues || bHasPropValues,
"MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
176 if( bHasNamedValues || bHasPropValues )
180 aCompDataMap.
erase( rName );
182 if( aCompDataMap.
empty() )
183 erase( aPropertyIter );
192 const ::std::vector< OUString >* pDefaultPasswords )
203 bool bIsDefaultPassword =
false;
205 rVerifier, aMediaEncData, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
212 if( aEncryptionData.hasElements() )
215 return aEncryptionData;
246 const css::uno::Any& rPostData = pIt->second;
247 css::uno::Reference< css::io::XInputStream > xPostData;
248 rPostData >>= xPostData;
256 throw css::uno::Exception(
"Found no URL.",
257 css::uno::Reference< css::uno::XInterface >());
261 catch(
const css::uno::Exception&)
270 if ( !_rxPostData.is() )
271 throw css::lang::IllegalArgumentException(
"Found invalid PostData.",
272 css::uno::Reference< css::uno::XInterface >(), 1);
280 css::uno::Reference< css::task::XInteractionHandler >());
281 css::uno::Reference< css::ucb::XProgressHandler > xProgress;
288 sMediaType =
"application/x-www-form-urlencoded";
295 css::uno::Reference< css::io::XInputStream > xResultStream;
299 css::uno::Reference< css::io::XSeekable > xSeek( _rxPostData, css::uno::UNO_QUERY );
307 css::ucb::PostCommandArgument2 aPostArgument;
308 aPostArgument.Source = _rxPostData;
309 css::uno::Reference< css::io::XActiveDataSink >
xSink(
new ucbhelper::ActiveDataSink );
310 aPostArgument.Sink =
xSink;
314 aContent.
executeCommand(
"post", css::uno::Any( aPostArgument ) );
317 xResultStream =
xSink->getInputStream();
319 catch(
const css::uno::Exception& )
324 if ( !xResultStream.is() )
326 OSL_FAIL(
"no valid reply to the HTTP-Post" );
345 css::uno::Reference< css::task::XInteractionHandler >());
349 css::uno::Reference< css::task::XInteractionHandler >());
353 css::uno::Reference< css::ucb::XProgressHandler > xProgress;
359 css::uno::Reference< css::ucb::XContent > xContent;
363 xContent = aContent.
get();
365 catch(
const css::uno::RuntimeException&)
367 catch(
const css::ucb::ContentCreationException&)
372 catch(
const css::uno::Exception&)
382 css::uno::Reference< css::io::XStream >
xStream;
383 css::uno::Reference< css::io::XInputStream > xInputStream;
386 bool bModeRequestedExplicitly =
false;
391 bModeRequestedExplicitly =
true;
401 xInputStream =
xStream->getInputStream();
403 catch(
const css::uno::RuntimeException&)
405 catch(
const css::uno::Exception&)
413 if (!xInteraction->wasWriteError() || bModeRequestedExplicitly)
423 xInputStream.clear();
429 if (!xInputStream.is())
435 css::uno::Reference< css::ucb::XContentIdentifier > xContId(
436 aContent.
get().is() ? aContent.
get()->getIdentifier() :
nullptr );
439 aScheme = xContId->getContentProviderScheme();
444 if( bLockFile && aScheme.equalsIgnoreAsciiCase(
"file") )
450 if (
bReadOnly && !bRequestReadOnly && bModeRequestedExplicitly )
454 catch(
const css::uno::RuntimeException&)
456 catch(
const css::uno::Exception&)
462 xInteraction->resetInterceptions();
463 xInteraction->resetErrorStates();
467 if ( bLockFile || !aScheme.equalsIgnoreAsciiCase(
"file") )
472 catch(
const css::uno::RuntimeException&)
476 catch(
const css::uno::Exception&)
488 if (xInputStream.is())
492 return xInputStream.is();
constexpr OUStringLiteral sMediaType
static css::uno::Sequence< css::beans::NamedValue > requestAndVerifyDocPassword(IDocPasswordVerifier &rVerifier, const css::uno::Sequence< css::beans::NamedValue > &rMediaEncData, const OUString &rMediaPassword, const css::uno::Reference< css::task::XInteractionHandler > &rxInteractHandler, const OUString &rDocumentUrl, DocPasswordRequestType eRequestType, const ::std::vector< OUString > *pDefaultPasswords=nullptr, bool *pbIsDefaultPassword=nullptr)
const css::uno::Any & get(const OUString &_rValueName) const
css::uno::Any getAsConstAny(bool bAsPropertyValue) const
iterator erase(iterator it)
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
iterator find(const OUString &rKey)
SequenceAsHashMapBase::iterator iterator
css::uno::Any & operator[](const OUString &rKey)
SequenceAsHashMapBase::const_iterator const_iterator
css::uno::Any getPropertyValue(const OUString &rPropertyName)
css::uno::Reference< css::io::XStream > openWriteableStream()
css::uno::Reference< css::io::XInputStream > openStreamNoLock()
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
css::uno::Reference< css::ucb::XContent > get() const
css::uno::Reference< css::io::XInputStream > openStream()
OString exceptionToString(const css::uno::Any &caught)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
tools::SvRef< SvBaseLink > xSink
#define SAL_WARN(area, stream)
bool isUntrustedReferer(OUString const &referer)
Check whether the given referer URI is untrusted, and links originating from it should not be accesse...
OUString get(TranslateId sContextAndId, const std::locale &loc)
Reference< XComponentContext > getProcessComponentContext()
Any SAL_CALL getCaughtException()
bool parse(OUString const &uri, SourceProviderScannerData *data)
UNOTOOLS_DLLPUBLIC css::uno::Reference< css::ucb::XCommandEnvironment > getDefaultCommandEnvironment()
Returns a default XCommandEnvironment to be used when creating a ucbhelper::Content.