LibreOffice Module reportdesign (master) 1
dbloader2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#include "dbloader2.hxx"
20#include <tools/urlobj.hxx>
24#include <comphelper/types.hxx>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/embed/XStorage.hpp>
28
29namespace rptxml
30{
31
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::io;
34using namespace ::com::sun::star::util;
35using namespace ::com::sun::star::beans;
36using namespace ::com::sun::star::lang;
37using namespace ::com::sun::star::document;
38using namespace ::com::sun::star::embed;
39using namespace ::com::sun::star::ui::dialogs;
40
41
42ORptTypeDetection::ORptTypeDetection(Reference< XComponentContext > const & xContext)
43: m_xContext(xContext)
44{
45}
46
47OUString SAL_CALL ORptTypeDetection::detect( Sequence< css::beans::PropertyValue >& Descriptor )
48{
49
50 ::comphelper::SequenceAsHashMap aTemp(Descriptor);
51 OUString sTemp = aTemp.getUnpackedValueOrDefault("URL",OUString());
52
53 if ( !sTemp.isEmpty() )
54 {
55 INetURLObject aURL(sTemp);
56 if ( aURL.GetFileExtension().equalsIgnoreAsciiCase("orp") )
57 return "StarBaseReport";
58 else
59 {
60 try
61 {
62 Reference<XPropertySet> xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ, m_xContext),UNO_QUERY);
63 if ( xProp.is() )
64 {
65 OUString sMediaType;
66 xProp->getPropertyValue("MediaType") >>= sMediaType;
68 return "StarBaseReport";
69 ::comphelper::disposeComponent(xProp);
70 }
71 }
72 catch(Exception&)
73 {
74 }
75 }
76 }
77 return OUString();
78}
79
80// XServiceInfo
82{
83 return "com.sun.star.comp.report.ORptTypeDetection";
84}
85
86
87// XServiceInfo
88sal_Bool SAL_CALL ORptTypeDetection::supportsService(const OUString& ServiceName)
89{
91}
92
93// XServiceInfo
94Sequence< OUString > SAL_CALL ORptTypeDetection::getSupportedServiceNames()
95{
96 return { "com.sun.star.document.ExtendedTypeDetection" };
97}
98
99
100}//rptxml
101
102extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
104 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
105{
106 return cppu::acquire(new rptxml::ORptTypeDetection(context));
107}
108
109
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
constexpr OUStringLiteral sMediaType
static css::uno::Reference< css::embed::XStorage > GetStorageFromURL(const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) override
Definition: dbloader2.cxx:47
ORptTypeDetection(css::uno::Reference< css::uno::XComponentContext > const &xContext)
Definition: dbloader2.cxx:42
OUString SAL_CALL getImplementationName() override
Definition: dbloader2.cxx:81
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: dbloader2.hxx:34
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: dbloader2.cxx:88
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: dbloader2.cxx:94
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_ORptTypeDetection_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: dbloader2.cxx:103
URL aURL
constexpr OUStringLiteral MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
@ Exception
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool