Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "dbloader2.hxx"
29 : : #include <tools/urlobj.hxx>
30 : : #include <comphelper/sequence.hxx>
31 : : // -------------------------------------------------------------------------
32 : : namespace rptxml
33 : : {
34 : :
35 : : using namespace ::ucbhelper;
36 : : using namespace ::com::sun::star::task;
37 : : using namespace ::com::sun::star::uno;
38 : : using namespace ::com::sun::star::ucb;
39 : : using namespace ::com::sun::star::io;
40 : : using namespace ::com::sun::star::util;
41 : : using namespace ::com::sun::star::frame;
42 : : using namespace ::com::sun::star::beans;
43 : : using namespace ::com::sun::star::container;
44 : : using namespace ::com::sun::star::lang;
45 : : using namespace ::com::sun::star::document;
46 : : using namespace ::com::sun::star::registry;
47 : : using namespace ::com::sun::star::embed;
48 : : using namespace ::com::sun::star::ui::dialogs;
49 : : using ::com::sun::star::awt::XWindow;
50 : :
51 : : // -------------------------------------------------------------------------
52 : 10 : ORptTypeDetection::ORptTypeDetection(Reference< XComponentContext > const & xContext)
53 : 10 : : m_xContext(xContext)
54 : : {
55 : 10 : }
56 : : // -------------------------------------------------------------------------
57 : 10 : ::rtl::OUString SAL_CALL ORptTypeDetection::detect( Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (RuntimeException)
58 : : {
59 : :
60 [ + - ]: 10 : ::comphelper::SequenceAsHashMap aTemp(Descriptor);
61 [ + - ][ + - ]: 10 : ::rtl::OUString sTemp = aTemp.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")),::rtl::OUString());
62 : :
63 [ + - ]: 10 : if ( !sTemp.isEmpty() )
64 : : {
65 [ + - ]: 10 : INetURLObject aURL(sTemp);
66 [ + - ][ - + ]: 10 : if ( aURL.GetExtension().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("orp")) )
67 [ # # ]: 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBaseReport"));
68 : : else
69 : : {
70 : : try
71 : : {
72 [ + - ][ + - ]: 10 : Reference<XPropertySet> xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ,Reference< XMultiServiceFactory >(m_xContext->getServiceManager(),UNO_QUERY)),UNO_QUERY);
[ + - ][ + - ]
[ + - ]
73 [ + - ]: 10 : if ( xProp.is() )
74 : : {
75 : 10 : ::rtl::OUString sMediaType;
76 [ + - ][ + - ]: 10 : xProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")) ) >>= sMediaType;
[ + - ]
77 [ - + ]: 10 : if ( sMediaType == MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII )
78 [ # # ]: 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBaseReport"));
79 [ + - ][ + - ]: 10 : ::comphelper::disposeComponent(xProp);
80 [ + - ][ # # ]: 10 : }
81 : : }
82 [ # # ]: 0 : catch(Exception&)
83 : : {
84 : : }
85 [ + - ][ + - ]: 10 : }
86 : : }
87 [ + - ]: 10 : return ::rtl::OUString();
88 : : }
89 : : // -------------------------------------------------------------------------
90 : : Reference< XInterface > SAL_CALL
91 : 10 : ORptTypeDetection::create(Reference< XComponentContext > const & xContext)
92 : : {
93 [ + - ]: 10 : return *(new ORptTypeDetection(xContext));
94 : : }
95 : : // -------------------------------------------------------------------------
96 : : // XServiceInfo
97 : 0 : ::rtl::OUString SAL_CALL ORptTypeDetection::getImplementationName() throw( )
98 : : {
99 : 0 : return getImplementationName_Static();
100 : : }
101 : : // -------------------------------------------------------------------------
102 : :
103 : : // XServiceInfo
104 : 0 : sal_Bool SAL_CALL ORptTypeDetection::supportsService(const ::rtl::OUString& ServiceName) throw( )
105 : : {
106 [ # # ]: 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
107 : : }
108 : : // -------------------------------------------------------------------------
109 : : // XServiceInfo
110 : 0 : Sequence< ::rtl::OUString > SAL_CALL ORptTypeDetection::getSupportedServiceNames(void) throw( )
111 : : {
112 : 0 : return getSupportedServiceNames_Static();
113 : : }
114 : : // -------------------------------------------------------------------------
115 : : // ORegistryServiceManager_Static
116 : 6 : Sequence< ::rtl::OUString > ORptTypeDetection::getSupportedServiceNames_Static(void) throw( RuntimeException )
117 : : {
118 : 6 : Sequence< ::rtl::OUString > aSNS( 1 );
119 [ + - ][ + - ]: 6 : aSNS.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExtendedTypeDetection"));
120 : 6 : return aSNS;
121 : : }
122 : : // -----------------------------------------------------------------------------
123 : : // -----------------------------------------------------------------------------
124 : : }//rptxml
125 : : // -----------------------------------------------------------------------------
126 : :
127 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|