Line data Source code
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>
21 : #include <cppuhelper/supportsservice.hxx>
22 :
23 : namespace rptxml
24 : {
25 :
26 : using namespace ::ucbhelper;
27 : using namespace ::com::sun::star::task;
28 : using namespace ::com::sun::star::uno;
29 : using namespace ::com::sun::star::ucb;
30 : using namespace ::com::sun::star::io;
31 : using namespace ::com::sun::star::util;
32 : using namespace ::com::sun::star::frame;
33 : using namespace ::com::sun::star::beans;
34 : using namespace ::com::sun::star::container;
35 : using namespace ::com::sun::star::lang;
36 : using namespace ::com::sun::star::document;
37 : using namespace ::com::sun::star::registry;
38 : using namespace ::com::sun::star::embed;
39 : using namespace ::com::sun::star::ui::dialogs;
40 : using ::com::sun::star::awt::XWindow;
41 :
42 :
43 0 : ORptTypeDetection::ORptTypeDetection(Reference< XComponentContext > const & xContext)
44 0 : : m_xContext(xContext)
45 : {
46 0 : }
47 :
48 0 : OUString SAL_CALL ORptTypeDetection::detect( Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (RuntimeException, std::exception)
49 : {
50 :
51 0 : ::comphelper::SequenceAsHashMap aTemp(Descriptor);
52 0 : OUString sTemp = aTemp.getUnpackedValueOrDefault("URL",OUString());
53 :
54 0 : if ( !sTemp.isEmpty() )
55 : {
56 0 : INetURLObject aURL(sTemp);
57 0 : if ( aURL.GetExtension().equalsIgnoreAsciiCase("orp") )
58 0 : return OUString("StarBaseReport");
59 : else
60 : {
61 : try
62 : {
63 0 : Reference<XPropertySet> xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ, m_xContext),UNO_QUERY);
64 0 : if ( xProp.is() )
65 : {
66 0 : OUString sMediaType;
67 0 : xProp->getPropertyValue("MediaType") >>= sMediaType;
68 0 : if ( sMediaType == MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII )
69 0 : return OUString("StarBaseReport");
70 0 : ::comphelper::disposeComponent(xProp);
71 0 : }
72 : }
73 0 : catch(Exception&)
74 : {
75 : }
76 0 : }
77 : }
78 0 : return OUString();
79 : }
80 :
81 : Reference< XInterface > SAL_CALL
82 0 : ORptTypeDetection::create(Reference< XComponentContext > const & xContext)
83 : {
84 0 : return *(new ORptTypeDetection(xContext));
85 : }
86 :
87 : // XServiceInfo
88 0 : OUString SAL_CALL ORptTypeDetection::getImplementationName() throw(std::exception )
89 : {
90 0 : return getImplementationName_Static();
91 : }
92 :
93 :
94 : // XServiceInfo
95 0 : sal_Bool SAL_CALL ORptTypeDetection::supportsService(const OUString& ServiceName) throw(std::exception )
96 : {
97 0 : return cppu::supportsService(this, ServiceName);
98 : }
99 :
100 : // XServiceInfo
101 0 : Sequence< OUString > SAL_CALL ORptTypeDetection::getSupportedServiceNames(void) throw(std::exception )
102 : {
103 0 : return getSupportedServiceNames_Static();
104 : }
105 :
106 : // ORegistryServiceManager_Static
107 0 : Sequence< OUString > ORptTypeDetection::getSupportedServiceNames_Static(void) throw( RuntimeException )
108 : {
109 0 : Sequence< OUString > aSNS( 1 );
110 0 : aSNS[0] = "com.sun.star.document.ExtendedTypeDetection";
111 0 : return aSNS;
112 : }
113 :
114 :
115 0 : }//rptxml
116 :
117 :
118 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|