30#include <com/sun/star/container/XNameContainer.hpp>
31#include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
32#include <com/sun/star/xml/sax/Parser.hpp>
53 BackendImpl * getMyBackend()
const;
58 void initPackageHandler();
61 virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
62 ::osl::ResettableMutexGuard & guard,
64 Reference<XCommandEnvironment>
const & xCmdEnv )
override;
65 virtual void processPackage_(
66 ::osl::ResettableMutexGuard & guard,
70 Reference<XCommandEnvironment>
const & xCmdEnv )
override;
75 OUString
const & url, OUString libType,
bool bRemoved,
76 OUString
const & identifier);
78 virtual OUString SAL_CALL getDescription()
override;
79 virtual OUString SAL_CALL getLicenseText()
override;
81 friend class PackageImpl;
84 virtual Reference<deployment::XPackage> bindPackage_(
85 OUString
const & url, OUString
const & mediaType,
86 bool bRemoved, OUString
const & identifier,
87 Reference<XCommandEnvironment>
const & xCmdEnv )
override;
94 Sequence<Any>
const & args,
95 Reference<XComponentContext>
const & xComponentContext );
103 virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL
104 getSupportedPackageTypes()
override;
105 virtual void SAL_CALL packageRemoved(OUString
const & url, OUString
const & mediaType)
override;
110BackendImpl * BackendImpl::PackageImpl::getMyBackend()
const
112 BackendImpl * pBackend =
static_cast<BackendImpl *
>(m_myBackend.get());
113 if (
nullptr == pBackend)
119 static_cast<OWeakObject*
>(
const_cast<PackageImpl *
>(
this)));
124OUString BackendImpl::PackageImpl::getDescription()
132OUString BackendImpl::PackageImpl::getLicenseText()
137BackendImpl::PackageImpl::PackageImpl(
139 OUString
const & url, OUString libType,
bool bRemoved,
140 OUString
const & identifier)
141 :
Package( myBackend, url, OUString(), OUString(),
145 initPackageHandler();
147 sal_Int32 segmEnd = url.getLength();
148 if ( url.endsWith(
"/") )
150 sal_Int32 segmStart = url.lastIndexOf(
'/', segmEnd ) + 1;
154 m_displayName = ::rtl::Uri::decode(
155 url.copy( segmStart, segmEnd - segmStart ),
156 rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
163BackendImpl::BackendImpl(
164 Sequence<Any>
const & args,
165 Reference<XComponentContext>
const & xComponentContext )
166 : PackageRegistryBackend(
args, xComponentContext ),
168 "application/vnd.sun.star.framework-script",
170 "Scripting Framework Script Library"
177OUString BackendImpl::getImplementationName()
179 return "com.sun.star.comp.deployment.sfwk.PackageRegistryBackend";
182sal_Bool BackendImpl::supportsService(
const OUString& ServiceName )
187css::uno::Sequence< OUString > BackendImpl::getSupportedServiceNames()
194Sequence< Reference<deployment::XPackageTypeInfo> >
195BackendImpl::getSupportedPackageTypes()
197 return Sequence< Reference<deployment::XPackageTypeInfo> >(&
m_xTypeInfo, 1);
200void BackendImpl::packageRemoved(OUString
const & , OUString
const & )
206Reference<deployment::XPackage> BackendImpl::bindPackage_(
207 OUString
const & url, OUString
const & mediaType_,
bool bRemoved,
208 OUString
const & identifier, Reference<XCommandEnvironment>
const & xCmdEnv )
210 OUString mediaType( mediaType_ );
211 if (mediaType.isEmpty())
220 nullptr,
makeURL( url,
"parcel-descriptor.xml" ),
223 mediaType =
"application/vnd.sun.star.framework-script";
226 if (mediaType.isEmpty())
227 throw lang::IllegalArgumentException(
228 StrCannotDetectMediaType() + url,
229 static_cast<OWeakObject *
>(
this),
static_cast<sal_Int16
>(-1) );
232 OUString
type, subType;
236 if (
type.equalsIgnoreAsciiCase(
"application"))
238 if (subType.equalsIgnoreAsciiCase(
"vnd.sun.star.framework-script"))
240 OUString
lang =
"Script";
241 OUString sParcelDescURL =
makeURL(
242 url,
"parcel-descriptor.xml" );
250 new ParcelDescDocHandler();
252 Reference<XComponentContext>
257 xParser->setDocumentHandler( pHandler );
258 xml::sax::InputSource source;
259 source.aInputStream = ucb_content.
openStream();
260 source.sSystemId = ucb_content.
getURL();
261 xParser->parseStream( source );
263 if ( pHandler->isParsed() )
265 lang = pHandler->getParcelLanguage();
269 OUString sfwkLibType =
DpResId( RID_STR_SFWK_LIB );
271 OUString MACRONAME(
"%MACROLANG" );
272 sal_Int32 startOfReplace = sfwkLibType.indexOf( MACRONAME );
273 sal_Int32 charsToReplace = MACRONAME.getLength();
274 sfwkLibType = sfwkLibType.replaceAt( startOfReplace, charsToReplace,
lang );
279 return new PackageImpl(
this, url, sfwkLibType, bRemoved, identifier);
283 throw lang::IllegalArgumentException(
284 StrUnsupportedMediaType() + mediaType,
285 static_cast<OWeakObject *
>(
this),
286 static_cast<sal_Int16
>(-1) );
290void BackendImpl::PackageImpl:: initPackageHandler()
295 BackendImpl * that = getMyBackend();
298 if ( that->m_eContext == Context::User )
300 aContext <<= OUString(
"user");
302 else if ( that->m_eContext == Context::Shared )
304 aContext <<= OUString(
"share");
306 else if ( that->m_eContext == Context::Bundled )
308 aContext <<= OUString(
"bundled");
316 Reference< provider::XScriptProviderFactory > xFac =
317 provider::theMasterScriptProviderFactory::get( that->getComponentContext() );
329beans::Optional< beans::Ambiguous<sal_Bool> >
330BackendImpl::PackageImpl::isRegistered_(
331 ::osl::ResettableMutexGuard &,
333 Reference<XCommandEnvironment>
const & )
335 return beans::Optional< beans::Ambiguous<sal_Bool> >(
337 beans::Ambiguous<sal_Bool>(
344void BackendImpl::PackageImpl::processPackage_(
345 ::osl::ResettableMutexGuard &,
346 bool doRegisterPackage,
349 Reference<XCommandEnvironment>
const & )
357 if (doRegisterPackage)
371extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
373 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& args)
375 return cppu::acquire(
new dp_registry::backend::sfwk::BackendImpl(
args, context));
static bool parse(OUString const &rMediaType, OUString &rType, OUString &rSubType, INetContentTypeParameterList *pParameters=nullptr)
virtual OUString SAL_CALL getDescription() override
const OUString & getURL() const
css::uno::Reference< css::io::XInputStream > openStream()
OUString DpResId(TranslateId aId)
const Reference< deployment::XPackageTypeInfo > m_xTypeInfo
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_deployment_sfwk_PackageRegistryBackend_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
Reference< container::XNameContainer > m_xNameCntrPkgHandler
std::unordered_map< OString, INetContentTypeParameter > INetContentTypeParameterList
static uno::Reference< css::uno::XComponentContext > xContext
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString makeURL(std::u16string_view baseURL, OUString const &relPath_)
appends a relative path to a url.
void TRACE(OUString const &sText)
print the text to the console in a debug build.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_ucb_content(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
constexpr OUStringLiteral BACKEND_SERVICE_NAME
::boost::spirit::classic::rule< ScannerT > identifier