File: | stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx |
Location: | line 111, column 9 |
Description: | Called C++ object pointer is null |
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 | |
20 | |
21 | #include "stocservices.hxx" |
22 | |
23 | #include "supportsService.hxx" |
24 | |
25 | #include "com/sun/star/lang/XServiceInfo.hpp" |
26 | #include "com/sun/star/uno/Exception.hpp" |
27 | #include "com/sun/star/uno/Reference.hxx" |
28 | #include "com/sun/star/uno/RuntimeException.hpp" |
29 | #include "com/sun/star/uno/Sequence.hxx" |
30 | #include "com/sun/star/uno/XComponentContext.hpp" |
31 | #include "com/sun/star/uno/XInterface.hpp" |
32 | #include "com/sun/star/uri/UriReferenceFactory.hpp" |
33 | #include "com/sun/star/uri/XUriReference.hpp" |
34 | #include "com/sun/star/uri/XUriReferenceFactory.hpp" |
35 | #include "com/sun/star/uri/XVndSunStarPkgUrlReferenceFactory.hpp" |
36 | #include "cppuhelper/implbase2.hxx" |
37 | #include "cppuhelper/weak.hxx" |
38 | #include "rtl/string.h" |
39 | #include "rtl/textenc.h" |
40 | #include "rtl/uri.h" |
41 | #include "rtl/uri.hxx" |
42 | #include "rtl/ustrbuf.hxx" |
43 | #include "rtl/ustring.hxx" |
44 | #include "sal/types.h" |
45 | |
46 | #include <new> |
47 | |
48 | namespace css = com::sun::star; |
49 | |
50 | namespace { |
51 | |
52 | class Factory: public cppu::WeakImplHelper2< |
53 | css::lang::XServiceInfo, css::uri::XVndSunStarPkgUrlReferenceFactory > |
54 | { |
55 | public: |
56 | explicit Factory( |
57 | css::uno::Reference< css::uno::XComponentContext > const & context): |
58 | m_context(context) {} |
59 | |
60 | virtual rtl::OUString SAL_CALL getImplementationName() |
61 | throw (css::uno::RuntimeException); |
62 | |
63 | virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName) |
64 | throw (css::uno::RuntimeException); |
65 | |
66 | virtual css::uno::Sequence< rtl::OUString > SAL_CALL |
67 | getSupportedServiceNames() throw (css::uno::RuntimeException); |
68 | |
69 | virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL |
70 | createVndSunStarPkgUrlReference( |
71 | css::uno::Reference< css::uri::XUriReference > const & authority) |
72 | throw (css::uno::RuntimeException); |
73 | |
74 | private: |
75 | Factory(Factory &); // not implemented |
76 | void operator =(Factory); // not implemented |
77 | |
78 | virtual ~Factory() {} |
79 | |
80 | css::uno::Reference< css::uno::XComponentContext > m_context; |
81 | }; |
82 | |
83 | rtl::OUString Factory::getImplementationName() |
84 | throw (css::uno::RuntimeException) |
85 | { |
86 | return |
87 | stoc_services::VndSunStarPkgUrlReferenceFactory:: |
88 | getImplementationName(); |
89 | } |
90 | |
91 | sal_Bool Factory::supportsService(rtl::OUString const & serviceName) |
92 | throw (css::uno::RuntimeException) |
93 | { |
94 | return stoc::uriproc::supportsService( |
95 | getSupportedServiceNames(), serviceName); |
96 | } |
97 | |
98 | css::uno::Sequence< rtl::OUString > Factory::getSupportedServiceNames() |
99 | throw (css::uno::RuntimeException) |
100 | { |
101 | return stoc_services::VndSunStarPkgUrlReferenceFactory:: |
102 | getSupportedServiceNames(); |
103 | } |
104 | |
105 | css::uno::Reference< css::uri::XUriReference > |
106 | Factory::createVndSunStarPkgUrlReference( |
107 | css::uno::Reference< css::uri::XUriReference > const & authority) |
108 | throw (css::uno::RuntimeException) |
109 | { |
110 | OSL_ASSERT(authority.is())do { if (true && (!(authority.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx" ":" "110" ": "), "OSL_ASSERT: %s", "authority.is()"); } } while (false); |
111 | if (authority->isAbsolute() && !authority->hasFragment()) { |
Called C++ object pointer is null | |
112 | rtl::OUStringBuffer buf; |
113 | buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg://")(&("vnd.sun.star.pkg://")[0]), ((sal_Int32)(sizeof ("vnd.sun.star.pkg://" ) / sizeof (("vnd.sun.star.pkg://")[0]))-1)); |
114 | buf.append( |
115 | rtl::Uri::encode( |
116 | authority->getUriReference(), rtl_UriCharClassRegName, |
117 | rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
118 | css::uno::Reference< css::uri::XUriReference > uriRef( |
119 | css::uri::UriReferenceFactory::create(m_context)->parse( |
120 | buf.makeStringAndClear())); |
121 | OSL_ASSERT(uriRef.is())do { if (true && (!(uriRef.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx" ":" "121" ": "), "OSL_ASSERT: %s", "uriRef.is()"); } } while (false); |
122 | return uriRef; |
123 | } else { |
124 | return css::uno::Reference< css::uri::XUriReference >(); |
125 | } |
126 | } |
127 | |
128 | } |
129 | |
130 | namespace stoc_services { namespace VndSunStarPkgUrlReferenceFactory |
131 | { |
132 | |
133 | css::uno::Reference< css::uno::XInterface > create( |
134 | css::uno::Reference< css::uno::XComponentContext > const & context) |
135 | SAL_THROW((css::uno::Exception)) |
136 | { |
137 | try { |
138 | return static_cast< cppu::OWeakObject * >(new Factory(context)); |
139 | } catch (std::bad_alloc &) { |
140 | throw css::uno::RuntimeException( |
141 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")(&("std::bad_alloc")[0]), ((sal_Int32)((sizeof ("std::bad_alloc" ) / sizeof (("std::bad_alloc")[0]))-1)), (((rtl_TextEncoding) 11))), 0); |
142 | } |
143 | } |
144 | |
145 | rtl::OUString getImplementationName() { |
146 | return rtl::OUString( |
147 | RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory")(&("com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory" ) / sizeof (("com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory" )[0]))-1)), (((rtl_TextEncoding) 11))); |
148 | } |
149 | |
150 | css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { |
151 | css::uno::Sequence< rtl::OUString > s(1); |
152 | s[0] = rtl::OUString( |
153 | RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.VndSunStarPkgUrlReferenceFactory")(&("com.sun.star.uri.VndSunStarPkgUrlReferenceFactory")[0 ]), ((sal_Int32)((sizeof ("com.sun.star.uri.VndSunStarPkgUrlReferenceFactory" ) / sizeof (("com.sun.star.uri.VndSunStarPkgUrlReferenceFactory" )[0]))-1)), (((rtl_TextEncoding) 11))); |
154 | return s; |
155 | } |
156 | |
157 | } } |
158 | |
159 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |