2008-12-17 14:42:56 +0100 tbo r265602 : #i97269# changed hid.lst and etab.win 2008-12-15 15:36:04 +0100 mav r265508 : #i95809# remove the stream as well 2008-12-12 13:20:09 +0100 mav r265411 : #i95809# small fixes 2008-12-12 13:12:07 +0100 mav r265410 : #i95809# fix streams handling 2008-12-12 10:45:29 +0100 mav r265397 : #i95809# close the stream if there is no storage 2008-12-12 10:24:38 +0100 mav r265396 : #i95809# close the stream if there is no temporary file 2008-12-12 00:56:13 +0100 mav r265383 : #i95809# adopt for linux 2008-12-12 00:51:25 +0100 mav r265382 : #i95809# adopt for linux 2008-12-12 00:38:31 +0100 mav r265381 : #i95809# check timestamp only if fs locking not active 2008-12-12 00:35:32 +0100 mav r265380 : #i95809# small fixes 2008-12-12 00:29:33 +0100 mav r265379 : #i95809# small fixes 2008-12-11 22:30:15 +0100 mav r265374 : #i97092# allow to use default master password 2008-12-11 22:20:56 +0100 mav r265372 : #i95809# avoid storage closing 2008-12-11 21:11:37 +0100 mav r265368 : #i97092# do not publish for now 2008-12-11 21:08:22 +0100 mav r265366 : #i95809# fix typo 2008-12-11 21:06:49 +0100 mav r265364 : #i95809# small fixes 2008-12-11 21:05:13 +0100 mav r265363 : #i95809# small fixes 2008-12-11 20:40:05 +0100 mav r265360 : #i95809# show warning if the document was touched 2008-12-11 20:39:44 +0100 mav r265359 : #i95809# show warning if the document was touched 2008-12-11 19:54:45 +0100 mav r265355 : #i95809# small fixes 2008-12-11 19:42:52 +0100 mav r265353 : #i95809# small fixes 2008-12-11 19:30:30 +0100 mav r265351 : #i95809# small fixes 2008-12-11 19:16:40 +0100 mav r265349 : #i95809# small fixes 2008-12-11 19:05:56 +0100 mav r265348 : #i95809# small fixes 2008-12-11 18:26:03 +0100 mav r265346 : #i95809# ignore the exception 2008-12-11 18:19:28 +0100 mav r265345 : #i95809# pure imput stream in case of local file URL means opening of document readonly 2008-12-11 17:41:56 +0100 mav r265341 : #i95809# unfortunately SfxMedium can not take the decision 2008-12-11 17:37:07 +0100 mav r265340 : #i95809# fix typo 2008-12-11 17:33:47 +0100 mav r265339 : #i95809# pure imput stream in case of local file URL means opening of document readonly 2008-12-11 16:12:26 +0100 mav r265330 : #i95809# let dialogs look better 2008-12-11 15:50:43 +0100 mav r265322 : #i97092# allow to use default master password 2008-12-11 13:35:39 +0100 mav r265295 : #i97092# allow to use default master password 2008-12-11 13:04:28 +0100 mav r265290 : #i97092# allow to use default master password 2008-12-11 12:34:52 +0100 mav r265284 : #i97092# allow to use default master password 2008-12-11 11:21:33 +0100 mav r265267 : #i95809# adopt for linux 2008-12-11 10:25:22 +0100 mav r265255 : #i97092# allow to use default master password 2008-12-11 10:24:35 +0100 mav r265254 : #i97092# allow to use default master password 2008-12-10 17:02:32 +0100 pb r265207 : fix: #i97092# more info text 2008-12-10 16:40:53 +0100 mav r265205 : #i95809# integrate new file locking UI in sfx workflow 2008-12-10 16:38:55 +0100 mav r265204 : #i95809# allow to ignore own lock on saving 2008-12-10 14:52:12 +0100 pb r265192 : fix: #i97092# new master password behavior 2008-12-10 14:51:22 +0100 pb r265191 : fix: #i97092# new master password bahavior 2008-12-10 14:49:46 +0100 pb r265189 : fix: #i97092# new master password bahavior 2008-12-10 10:55:19 +0100 mav r265155 : #i95809# allow to ignore own lock on saving 2008-12-09 17:47:51 +0100 mav r265124 : #i95809# allow to ignore own lock on saving 2008-12-07 11:24:57 +0100 mav r264949 : #i95809# let the request be derived from IOException 2008-12-05 18:31:35 +0100 mav r264915 : #i95809# use the locking related dialogs from InteractionHandler 2008-12-04 18:33:36 +0100 mav r264867 : #i95809# the requests for the new locking UI 2008-12-04 10:26:52 +0100 pb r264822 : fix: #i95809# new message boxes for locking 2008-12-04 10:23:51 +0100 pb r264821 : fix: #i95809# STR_OPENLOCKED_UNKNOWNUSER replaced by STR_UNKNOWNUSER 2008-12-04 10:18:23 +0100 pb r264820 : fix: #i95809# new message boxes for locking 2008-12-04 10:15:56 +0100 pb r264819 : fix: #i95809# new message boxes for locking 2008-12-03 16:06:46 +0100 mav r264796 : #i95809# system file locking support 2008-12-02 16:19:30 +0100 mav r264717 : #i95809# system file locking support 2008-12-02 16:07:10 +0100 mav r264716 : #i95809# system file locking support 2008-12-02 15:58:53 +0100 mav r264714 : #i95809# change the name 2008-12-02 15:58:06 +0100 mav r264713 : #i95809# do not allow to change ReadOnly flag in TypeDetection 2008-12-02 15:56:00 +0100 mav r264712 : #i95809# system file locking support 2008-12-02 15:43:20 +0100 mav r264708 : #i95809# change the name 2008-12-02 15:38:08 +0100 mav r264706 : #i95809# an options to control system file locking usage
943 lines
32 KiB
C++
943 lines
32 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: mediadescriptor.cxx,v $
|
|
* $Revision: 1.20.22.1 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_comphelper.hxx"
|
|
#include <comphelper/mediadescriptor.hxx>
|
|
|
|
//_______________________________________________
|
|
// includes
|
|
|
|
#ifndef __COM_SUN_STAR_UCB_XCONTENT_HPP__
|
|
#include <com/sun/star/ucb/XContent.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP__
|
|
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP__
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_IO_XSTREAM_HPP__
|
|
#include <com/sun/star/io/XStream.hpp>
|
|
#endif
|
|
#include <com/sun/star/io/XActiveDataSink.hpp>
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
|
|
|
#ifndef __COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP__
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
#endif
|
|
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
|
|
|
#ifndef __COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP__
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP__
|
|
#include <com/sun/star/ucb/InteractiveIOException.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP__
|
|
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_UCB_COMMANDFAILEDEXCEPTION_HPP__
|
|
#include <com/sun/star/ucb/CommandFailedException.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP__
|
|
#include <com/sun/star/task/XInteractionAbort.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_URI_XURIREFERENCEFACTORY_HPP__
|
|
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
|
|
#endif
|
|
|
|
#ifndef __COM_SUN_STAR_URI_XURIREFERENCE_HPP__
|
|
#include <com/sun/star/uri/XUriReference.hpp>
|
|
#endif
|
|
#include <com/sun/star/ucb/PostCommandArgument2.hpp>
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <ucbhelper/interceptedinteraction.hxx>
|
|
#include <ucbhelper/content.hxx>
|
|
#include <ucbhelper/commandenvironment.hxx>
|
|
#include <ucbhelper/activedatasink.hxx>
|
|
#include <comphelper/processfactory.hxx>
|
|
#include <comphelper/configurationhelper.hxx>
|
|
|
|
#if OSL_DEBUG_LEVEL>0
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
#include <rtl/ustrbuf.hxx>
|
|
#endif
|
|
#endif
|
|
|
|
//_______________________________________________
|
|
// namespace
|
|
|
|
namespace comphelper{
|
|
|
|
namespace css = ::com::sun::star;
|
|
|
|
//_______________________________________________
|
|
// definitions
|
|
|
|
/*-----------------------------------------------
|
|
10.03.2004 07:35
|
|
-----------------------------------------------*/
|
|
const ::rtl::OUString& MediaDescriptor::PROP_ASTEMPLATE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_CHARACTERSET()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("CharacterSet"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_DEEPDETECTION()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DeepDetection"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_DETECTSERVICE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DetectService"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTSERVICE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DocumentService"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_EXTENSION()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Extension"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_FILENAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("FileName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_FILTERNAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("FilterName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_FILTEROPTIONS()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("FilterOptions"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_FORMAT()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Format"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_FRAMENAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("FrameName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_HIDDEN()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Hidden"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_INPUTSTREAM()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_INTERACTIONHANDLER()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_JUMPMARK()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("JumpMark"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_MACROEXECUTIONMODE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_MEDIATYPE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("MediaType"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_MINIMIZED()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Minimized"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_NOAUTOSAVE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("NoAutoSave"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_OPENNEWVIEW()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("OpenNewView"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_OUTPUTSTREAM()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("OutputStream"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_PATTERN()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Pattern"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_POSSIZE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("PosSize"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_POSTDATA()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("PostData"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_POSTSTRING()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("PostString"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_PREVIEW()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Preview"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_READONLY()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_REFERRER()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Referer"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_SILENT()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Silent"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_STATUSINDICATOR()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_STREAM()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Stream"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_STREAMFOROUTPUT()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("StreamForOutput"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_TEMPLATENAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("TemplateName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_TEMPLATEREGIONNAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("TemplateRegionName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_TYPENAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("TypeName"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_UCBCONTENT()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("UCBContent"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_UPDATEDOCMODE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("UpdateDocMode"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_URL()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("URL"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_VERSION()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Version"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_VIEWID()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ViewId"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_REPAIRPACKAGE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("RepairPackage"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTTITLE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_MODEL()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Model"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_PASSWORD()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Password"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_TITLE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Title"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_SALVAGEDFILE()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("SalvagedFile"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_VIEWONLY()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ViewOnly"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTBASEURL()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DocumentBaseURL"));
|
|
return sProp;
|
|
}
|
|
|
|
const ::rtl::OUString& MediaDescriptor::PROP_VIEWCONTROLLERNAME()
|
|
{
|
|
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ViewControllerName"));
|
|
return sProp;
|
|
}
|
|
/*-----------------------------------------------
|
|
10.03.2004 08:09
|
|
-----------------------------------------------*/
|
|
MediaDescriptor::MediaDescriptor()
|
|
: SequenceAsHashMap()
|
|
{
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
10.03.2004 08:09
|
|
-----------------------------------------------*/
|
|
MediaDescriptor::MediaDescriptor(const css::uno::Any& aSource)
|
|
: SequenceAsHashMap(aSource)
|
|
{
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
10.03.2004 08:09
|
|
-----------------------------------------------*/
|
|
MediaDescriptor::MediaDescriptor(const css::uno::Sequence< css::beans::PropertyValue >& lSource)
|
|
: SequenceAsHashMap(lSource)
|
|
{
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
10.03.2004 08:09
|
|
-----------------------------------------------*/
|
|
MediaDescriptor::MediaDescriptor(const css::uno::Sequence< css::beans::NamedValue >& lSource)
|
|
: SequenceAsHashMap(lSource)
|
|
{
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
18.11.2004 13:37
|
|
-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::isStreamReadOnly() const
|
|
{
|
|
static ::rtl::OUString CONTENTSCHEME_FILE = ::rtl::OUString::createFromAscii("file");
|
|
static ::rtl::OUString CONTENTPROP_ISREADONLY = ::rtl::OUString::createFromAscii("IsReadOnly");
|
|
static sal_Bool READONLY_FALLBACK = sal_False;
|
|
|
|
sal_Bool bReadOnly = READONLY_FALLBACK;
|
|
|
|
// check for explicit readonly state
|
|
const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
|
|
if (pIt != end())
|
|
{
|
|
pIt->second >>= bReadOnly;
|
|
return bReadOnly;
|
|
}
|
|
|
|
// streams based on post data are readonly by definition
|
|
pIt = find(MediaDescriptor::PROP_POSTDATA());
|
|
if (pIt != end())
|
|
return sal_True;
|
|
|
|
// A XStream capsulate XInputStream and XOutputStream ...
|
|
// If it exists - the file must be open in read/write mode!
|
|
pIt = find(MediaDescriptor::PROP_STREAM());
|
|
if (pIt != end())
|
|
return sal_False;
|
|
|
|
// Only file system content provider is able to provide XStream
|
|
// so for this content impossibility to create XStream triggers
|
|
// switch to readonly mode.
|
|
try
|
|
{
|
|
css::uno::Reference< css::ucb::XContent > xContent = getUnpackedValueOrDefault(MediaDescriptor::PROP_UCBCONTENT(), css::uno::Reference< css::ucb::XContent >());
|
|
if (xContent.is())
|
|
{
|
|
css::uno::Reference< css::ucb::XContentIdentifier > xId(xContent->getIdentifier(), css::uno::UNO_QUERY);
|
|
::rtl::OUString aScheme;
|
|
if (xId.is())
|
|
aScheme = xId->getContentProviderScheme();
|
|
|
|
if (aScheme.equalsIgnoreAsciiCase(CONTENTSCHEME_FILE))
|
|
bReadOnly = sal_True;
|
|
else
|
|
{
|
|
::ucbhelper::Content aContent(xContent, css::uno::Reference< css::ucb::XCommandEnvironment >());
|
|
aContent.getPropertyValue(CONTENTPROP_ISREADONLY) >>= bReadOnly;
|
|
}
|
|
}
|
|
}
|
|
catch(const css::uno::RuntimeException& exRun)
|
|
{ throw exRun; }
|
|
catch(const css::uno::Exception&)
|
|
{}
|
|
|
|
return bReadOnly;
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
10.03.2004 09:02
|
|
-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::addInputStream()
|
|
{
|
|
return impl_addInputStream( sal_True );
|
|
}
|
|
|
|
/*-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::addInputStreamOwnLock()
|
|
{
|
|
// Own lock file implementation
|
|
|
|
sal_Bool bUseLock = sal_True; // the system file locking is used per default
|
|
try
|
|
{
|
|
|
|
css::uno::Reference< css::uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
|
|
::comphelper::getProcessServiceFactory(),
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
|
|
::comphelper::ConfigurationHelper::E_STANDARD );
|
|
if ( !xCommonConfig.is() )
|
|
throw css::uno::RuntimeException();
|
|
|
|
::comphelper::ConfigurationHelper::readRelativeKey(
|
|
xCommonConfig,
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseDocumentSystemFileLocking" ) ) ) >>= bUseLock;
|
|
}
|
|
catch( const css::uno::Exception& )
|
|
{
|
|
}
|
|
|
|
return impl_addInputStream( bUseLock );
|
|
}
|
|
|
|
/*-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile )
|
|
{
|
|
// check for an already existing stream item first
|
|
const_iterator pIt = find(MediaDescriptor::PROP_INPUTSTREAM());
|
|
if (pIt != end())
|
|
return sal_True;
|
|
|
|
try
|
|
{
|
|
// No stream available - create a new one
|
|
// a) data comes as PostData ...
|
|
pIt = find(MediaDescriptor::PROP_POSTDATA());
|
|
if (pIt != end())
|
|
{
|
|
const css::uno::Any& rPostData = pIt->second;
|
|
css::uno::Reference< css::io::XInputStream > xPostData;
|
|
rPostData >>= xPostData;
|
|
|
|
return impl_openStreamWithPostData( xPostData );
|
|
}
|
|
|
|
// b) ... or we must get it from the given URL
|
|
::rtl::OUString sURL = getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), ::rtl::OUString());
|
|
if (!sURL.getLength())
|
|
throw css::uno::Exception(
|
|
::rtl::OUString::createFromAscii("Found no URL."),
|
|
css::uno::Reference< css::uno::XInterface >());
|
|
|
|
// Parse URL! Only the main part has to be used further. E.g. a jumpmark can make trouble
|
|
::rtl::OUString sNormalizedURL = impl_normalizeURL( sURL );
|
|
return impl_openStreamWithURL( sNormalizedURL, bLockFile );
|
|
}
|
|
#if OSL_DEBUG_LEVEL>0
|
|
catch(const css::uno::Exception& ex)
|
|
{
|
|
::rtl::OUStringBuffer sMsg(256);
|
|
sMsg.appendAscii("Invalid MediaDescriptor detected:\n");
|
|
sMsg.append (ex.Message );
|
|
OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr());
|
|
}
|
|
#else
|
|
catch(const css::uno::Exception&)
|
|
{}
|
|
#endif
|
|
|
|
return sal_False;
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
25.03.2004 12:38
|
|
-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::impl_openStreamWithPostData( const css::uno::Reference< css::io::XInputStream >& _rxPostData )
|
|
throw(::com::sun::star::uno::RuntimeException)
|
|
{
|
|
if ( !_rxPostData.is() )
|
|
throw css::lang::IllegalArgumentException(
|
|
::rtl::OUString::createFromAscii("Found invalid PostData."),
|
|
css::uno::Reference< css::uno::XInterface >(), 1);
|
|
|
|
// PostData can't be used in read/write mode!
|
|
(*this)[MediaDescriptor::PROP_READONLY()] <<= sal_True;
|
|
|
|
// prepare the environment
|
|
css::uno::Reference< css::task::XInteractionHandler > xInteraction = getUnpackedValueOrDefault(
|
|
MediaDescriptor::PROP_INTERACTIONHANDLER(),
|
|
css::uno::Reference< css::task::XInteractionHandler >());
|
|
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
|
|
::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
|
|
css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv(static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY);
|
|
|
|
// media type
|
|
::rtl::OUString sMediaType = getUnpackedValueOrDefault(MediaDescriptor::PROP_MEDIATYPE(), ::rtl::OUString());
|
|
if (!sMediaType.getLength())
|
|
{
|
|
sMediaType = ::rtl::OUString::createFromAscii("application/x-www-form-urlencoded");
|
|
(*this)[MediaDescriptor::PROP_MEDIATYPE()] <<= sMediaType;
|
|
}
|
|
|
|
// url
|
|
::rtl::OUString sURL( getUnpackedValueOrDefault( PROP_URL(), ::rtl::OUString() ) );
|
|
|
|
css::uno::Reference< css::io::XInputStream > xResultStream;
|
|
try
|
|
{
|
|
// seek PostData stream to the beginning
|
|
css::uno::Reference< css::io::XSeekable > xSeek( _rxPostData, css::uno::UNO_QUERY );
|
|
if ( xSeek.is() )
|
|
xSeek->seek( 0 );
|
|
|
|
// a content for the URL
|
|
::ucbhelper::Content aContent( sURL, xCommandEnv );
|
|
|
|
// use post command
|
|
css::ucb::PostCommandArgument2 aPostArgument;
|
|
aPostArgument.Source = _rxPostData;
|
|
css::uno::Reference< css::io::XActiveDataSink > xSink( new ucbhelper::ActiveDataSink );
|
|
aPostArgument.Sink = xSink;
|
|
aPostArgument.MediaType = sMediaType;
|
|
aPostArgument.Referer = getUnpackedValueOrDefault( PROP_REFERRER(), ::rtl::OUString() );
|
|
|
|
::rtl::OUString sCommandName( RTL_CONSTASCII_USTRINGPARAM( "post" ) );
|
|
aContent.executeCommand( sCommandName, css::uno::makeAny( aPostArgument ) );
|
|
|
|
// get result
|
|
xResultStream = xSink->getInputStream();
|
|
}
|
|
catch( const css::uno::Exception& )
|
|
{
|
|
}
|
|
|
|
// success?
|
|
if ( !xResultStream.is() )
|
|
{
|
|
OSL_ENSURE( false, "no valid reply to the HTTP-Post" );
|
|
return sal_False;
|
|
}
|
|
|
|
(*this)[MediaDescriptor::PROP_INPUTSTREAM()] <<= xResultStream;
|
|
return sal_True;
|
|
}
|
|
|
|
/*-----------------------------------------------*/
|
|
class StillReadWriteInteraction : public ::ucbhelper::InterceptedInteraction
|
|
{
|
|
private:
|
|
static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION = 0;
|
|
static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
|
|
|
|
sal_Bool m_bUsed;
|
|
sal_Bool m_bHandledByMySelf;
|
|
sal_Bool m_bHandledByInternalHandler;
|
|
|
|
public:
|
|
StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
|
|
: m_bUsed (sal_False)
|
|
, m_bHandledByMySelf (sal_False)
|
|
, m_bHandledByInternalHandler(sal_False)
|
|
{
|
|
::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
|
|
::ucbhelper::InterceptedInteraction::InterceptedRequest aInterceptedRequest;
|
|
|
|
aInterceptedRequest.Handle = HANDLE_INTERACTIVEIOEXCEPTION;
|
|
aInterceptedRequest.Request <<= css::ucb::InteractiveIOException();
|
|
aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
|
|
aInterceptedRequest.MatchExact = sal_False;
|
|
lInterceptions.push_back(aInterceptedRequest);
|
|
|
|
aInterceptedRequest.Handle = HANDLE_UNSUPPORTEDDATASINKEXCEPTION;
|
|
aInterceptedRequest.Request <<= css::ucb::UnsupportedDataSinkException();
|
|
aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
|
|
aInterceptedRequest.MatchExact = sal_False;
|
|
lInterceptions.push_back(aInterceptedRequest);
|
|
|
|
setInterceptedHandler(xHandler);
|
|
setInterceptions(lInterceptions);
|
|
}
|
|
|
|
void resetInterceptions()
|
|
{
|
|
setInterceptions(::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest >());
|
|
}
|
|
|
|
void resetErrorStates()
|
|
{
|
|
m_bUsed = sal_False;
|
|
m_bHandledByMySelf = sal_False;
|
|
m_bHandledByInternalHandler = sal_False;
|
|
}
|
|
|
|
sal_Bool wasWriteError()
|
|
{
|
|
return (m_bUsed && m_bHandledByMySelf);
|
|
}
|
|
|
|
private:
|
|
virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest& aRequest,
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest)
|
|
{
|
|
// we are used!
|
|
m_bUsed = sal_True;
|
|
|
|
// check if its a real interception - might some parameters are not the right ones ...
|
|
sal_Bool bAbort = sal_False;
|
|
switch(aRequest.Handle)
|
|
{
|
|
case HANDLE_INTERACTIVEIOEXCEPTION:
|
|
{
|
|
css::ucb::InteractiveIOException exIO;
|
|
xRequest->getRequest() >>= exIO;
|
|
bAbort = (
|
|
(exIO.Code == css::ucb::IOErrorCode_ACCESS_DENIED ) ||
|
|
(exIO.Code == css::ucb::IOErrorCode_LOCKING_VIOLATION )
|
|
);
|
|
}
|
|
break;
|
|
|
|
case HANDLE_UNSUPPORTEDDATASINKEXCEPTION:
|
|
{
|
|
bAbort = sal_True;
|
|
}
|
|
break;
|
|
}
|
|
|
|
// handle interaction by ourself
|
|
if (bAbort)
|
|
{
|
|
m_bHandledByMySelf = sal_True;
|
|
css::uno::Reference< css::task::XInteractionContinuation > xAbort = ::ucbhelper::InterceptedInteraction::extractContinuation(
|
|
xRequest->getContinuations(),
|
|
::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0)));
|
|
if (!xAbort.is())
|
|
return ::ucbhelper::InterceptedInteraction::E_NO_CONTINUATION_FOUND;
|
|
xAbort->select();
|
|
return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
|
|
}
|
|
|
|
// Otherwhise use internal handler.
|
|
if (m_xInterceptedHandler.is())
|
|
{
|
|
m_bHandledByInternalHandler = sal_True;
|
|
m_xInterceptedHandler->handle(xRequest);
|
|
}
|
|
return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
|
|
}
|
|
};
|
|
|
|
/*-----------------------------------------------
|
|
25.03.2004 12:29
|
|
-----------------------------------------------*/
|
|
sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, sal_Bool bLockFile )
|
|
throw(::com::sun::star::uno::RuntimeException)
|
|
{
|
|
// prepare the environment
|
|
css::uno::Reference< css::task::XInteractionHandler > xOrgInteraction = getUnpackedValueOrDefault(
|
|
MediaDescriptor::PROP_INTERACTIONHANDLER(),
|
|
css::uno::Reference< css::task::XInteractionHandler >());
|
|
|
|
StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction);
|
|
css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
|
|
|
|
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
|
|
::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
|
|
css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv(static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY);
|
|
|
|
// try to create the content
|
|
// no content -> no stream => return immediatly with FALSE
|
|
::ucbhelper::Content aContent;
|
|
css::uno::Reference< css::ucb::XContent > xContent;
|
|
try
|
|
{
|
|
aContent = ::ucbhelper::Content(sURL, xCommandEnv);
|
|
xContent = aContent.get();
|
|
}
|
|
catch(const css::uno::RuntimeException&)
|
|
{ throw; }
|
|
catch(const css::ucb::ContentCreationException&)
|
|
{ return sal_False; } // TODO error handling
|
|
catch(const css::uno::Exception&)
|
|
{ return sal_False; } // TODO error handling
|
|
|
|
// try to open the file in read/write mode
|
|
// (if its allowed to do so).
|
|
// But handle errors in a "hidden mode". Because
|
|
// we try it readonly later - if read/write isnt an option.
|
|
css::uno::Reference< css::io::XStream > xStream ;
|
|
css::uno::Reference< css::io::XInputStream > xInputStream;
|
|
|
|
sal_Bool bReadOnly = sal_False;
|
|
sal_Bool bModeRequestedExplicitly = sal_False;
|
|
const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
|
|
if (pIt != end())
|
|
{
|
|
pIt->second >>= bReadOnly;
|
|
bModeRequestedExplicitly = sal_True;
|
|
}
|
|
|
|
if ( !bReadOnly && bLockFile )
|
|
{
|
|
try
|
|
{
|
|
// TODO: use "special" still interaction to supress error messages
|
|
xStream = aContent.openWriteableStream();
|
|
if (xStream.is())
|
|
xInputStream = xStream->getInputStream();
|
|
}
|
|
catch(const css::uno::RuntimeException&)
|
|
{ throw; }
|
|
catch(const css::uno::Exception&)
|
|
{
|
|
// ignore exception, if reason was problem reasoned on
|
|
// open it in WRITEABLE mode! Then we try it READONLY
|
|
// later a second time.
|
|
// All other errors must be handled as real error an
|
|
// break this method.
|
|
if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
|
|
return sal_False;
|
|
xStream.clear();
|
|
xInputStream.clear();
|
|
}
|
|
}
|
|
|
|
// If opening of the stream in read/write mode wasnt allowed
|
|
// or failed by an error - we must try it in readonly mode.
|
|
if (!xInputStream.is())
|
|
{
|
|
rtl::OUString aScheme;
|
|
|
|
try
|
|
{
|
|
css::uno::Reference< css::ucb::XContentIdentifier > xContId(
|
|
aContent.get().is() ? aContent.get()->getIdentifier() : 0 );
|
|
|
|
if ( xContId.is() )
|
|
aScheme = xContId->getContentProviderScheme();
|
|
|
|
// Only file system content provider is able to provide XStream
|
|
// so for this content impossibility to create XStream triggers
|
|
// switch to readonly mode in case of opening with locking on
|
|
if( bLockFile && aScheme.equalsIgnoreAsciiCaseAscii( "file" ) )
|
|
bReadOnly = sal_True;
|
|
else
|
|
{
|
|
sal_Bool bRequestReadOnly = bReadOnly;
|
|
aContent.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ) ) >>= bReadOnly;
|
|
if ( bReadOnly && !bRequestReadOnly && bModeRequestedExplicitly )
|
|
return sal_False; // the document is explicitly requested with WRITEABLE mode
|
|
}
|
|
}
|
|
catch(const css::uno::RuntimeException&)
|
|
{ throw; }
|
|
catch(const css::uno::Exception&)
|
|
{ /* no error handling if IsReadOnly property does not exist for UCP */ }
|
|
|
|
if ( bReadOnly )
|
|
(*this)[MediaDescriptor::PROP_READONLY()] <<= bReadOnly;
|
|
|
|
pInteraction->resetInterceptions();
|
|
pInteraction->resetErrorStates();
|
|
try
|
|
{
|
|
// all the contents except file-URLs should be opened as usual
|
|
if ( bLockFile || !aScheme.equalsIgnoreAsciiCaseAscii( "file" ) )
|
|
xInputStream = aContent.openStream();
|
|
else
|
|
xInputStream = aContent.openStreamNoLock();
|
|
}
|
|
catch(const css::uno::RuntimeException&)
|
|
{ throw; }
|
|
catch(const css::uno::Exception&)
|
|
{ return sal_False; }
|
|
}
|
|
|
|
// add streams to the descriptor
|
|
if (xContent.is())
|
|
(*this)[MediaDescriptor::PROP_UCBCONTENT()] <<= xContent;
|
|
if (xStream.is())
|
|
(*this)[MediaDescriptor::PROP_STREAM()] <<= xStream;
|
|
if (xInputStream.is())
|
|
(*this)[MediaDescriptor::PROP_INPUTSTREAM()] <<= xInputStream;
|
|
|
|
// At least we need an input stream. The r/w stream is optional ...
|
|
return xInputStream.is();
|
|
}
|
|
|
|
/*-----------------------------------------------
|
|
10.09.2004 10:51
|
|
-----------------------------------------------*/
|
|
::rtl::OUString MediaDescriptor::impl_normalizeURL(const ::rtl::OUString& sURL)
|
|
{
|
|
/* Remove Jumpmarks (fragments) of an URL only here.
|
|
They are not part of any URL and as a result may be
|
|
no ucb content can be created then.
|
|
On the other side arguments must exists ... because
|
|
they are part of an URL.
|
|
|
|
Do not use the URLTransformer service here. Because
|
|
it parses the URL in another way. It's main part isnt enough
|
|
and it's complete part contains the jumpmark (fragment) parameter ...
|
|
*/
|
|
static ::rtl::OUString SERVICENAME_URIREFERENCEFACTORY = ::rtl::OUString::createFromAscii("com.sun.star.uri.UriReferenceFactory");
|
|
|
|
try
|
|
{
|
|
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
|
|
css::uno::Reference< css::uri::XUriReferenceFactory > xUriFactory(xSMGR->createInstance(SERVICENAME_URIREFERENCEFACTORY), css::uno::UNO_QUERY_THROW);
|
|
css::uno::Reference< css::uri::XUriReference > xUriRef = xUriFactory->parse(sURL);
|
|
if (xUriRef.is())
|
|
{
|
|
xUriRef->clearFragment();
|
|
return xUriRef->getUriReference();
|
|
}
|
|
}
|
|
catch(const css::uno::RuntimeException& exRun)
|
|
{ throw exRun; }
|
|
catch(const css::uno::Exception&)
|
|
{}
|
|
|
|
// If an error ocurred ... return the original URL.
|
|
// It's a try .-)
|
|
return sURL;
|
|
}
|
|
|
|
} // namespace comphelper
|
|
|