clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name vclxcontainer.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D TOOLKIT_DLLIMPLEMENTATION -D SVT_DLL_NAME="libsvtlo.so" -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/epoxy/include -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/toolkit/inc -I /home/maarten/src/libreoffice/core/toolkit/source -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/toolkit/source/awt/vclxcontainer.cxx
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | #include <toolkit/awt/vclxcontainer.hxx> |
21 | #include <toolkit/helper/macros.hxx> |
22 | #include <toolkit/helper/vclunohelper.hxx> |
23 | #include <cppuhelper/typeprovider.hxx> |
24 | #include <cppuhelper/queryinterface.hxx> |
25 | #include <comphelper/interfacecontainer2.hxx> |
26 | |
27 | #include <vcl/svapp.hxx> |
28 | #include <vcl/window.hxx> |
29 | #include <tools/debug.hxx> |
30 | #include <helper/scrollabledialog.hxx> |
31 | #include <toolkit/helper/property.hxx> |
32 | |
33 | |
34 | |
35 | |
36 | void VCLXContainer::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) |
37 | { |
38 | VCLXWindow::ImplGetPropertyIds( rIds ); |
39 | } |
40 | |
41 | VCLXContainer::VCLXContainer() |
42 | { |
43 | } |
44 | |
45 | VCLXContainer::~VCLXContainer() |
46 | { |
47 | } |
48 | |
49 | |
50 | css::uno::Any VCLXContainer::queryInterface( const css::uno::Type & rType ) |
51 | { |
52 | css::uno::Any aRet = ::cppu::queryInterface( rType, |
53 | static_cast< css::awt::XVclContainer* >(this), |
54 | static_cast< css::awt::XVclContainerPeer* >(this) ); |
55 | return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); |
56 | } |
57 | |
58 | IMPL_IMPLEMENTATION_ID( VCLXContainer ) |
59 | |
60 | |
61 | css::uno::Sequence< css::uno::Type > VCLXContainer::getTypes() |
62 | { |
63 | static const ::cppu::OTypeCollection aTypeList( |
64 | cppu::UnoType<css::lang::XTypeProvider>::get(), |
65 | cppu::UnoType<css::awt::XVclContainer>::get(), |
66 | cppu::UnoType<css::awt::XVclContainerPeer>::get(), |
67 | VCLXWindow::getTypes() |
68 | ); |
69 | return aTypeList.getTypes(); |
70 | } |
71 | |
72 | |
73 | |
74 | void VCLXContainer::addVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener ) |
75 | { |
76 | SolarMutexGuard aGuard; |
77 | |
78 | GetContainerListeners().addInterface( rxListener ); |
79 | } |
80 | |
81 | void VCLXContainer::removeVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener ) |
82 | { |
83 | SolarMutexGuard aGuard; |
84 | |
85 | GetContainerListeners().removeInterface( rxListener ); |
86 | } |
87 | |
88 | css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > VCLXContainer::getWindows( ) |
89 | { |
90 | SolarMutexGuard aGuard; |
91 | |
92 | |
93 | css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > aSeq; |
94 | VclPtr<vcl::Window> pWindow = GetWindow(); |
95 | if ( pWindow ) |
96 | { |
97 | sal_uInt16 nChildren = pWindow->GetChildCount(); |
98 | if ( nChildren ) |
99 | { |
100 | aSeq = css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >( nChildren ); |
101 | css::uno::Reference< css::awt::XWindow > * pChildRefs = aSeq.getArray(); |
102 | for ( sal_uInt16 n = 0; n < nChildren; n++ ) |
103 | { |
104 | vcl::Window* pChild = pWindow->GetChild( n ); |
105 | css::uno::Reference< css::awt::XWindowPeer > xWP = pChild->GetComponentInterface(); |
106 | css::uno::Reference< css::awt::XWindow > xW( xWP, css::uno::UNO_QUERY ); |
107 | pChildRefs[n] = xW; |
108 | } |
109 | } |
110 | } |
111 | return aSeq; |
112 | } |
113 | |
114 | |
115 | |
116 | void VCLXContainer::enableDialogControl( sal_Bool bEnable ) |
117 | { |
118 | SolarMutexGuard aGuard; |
119 | |
120 | VclPtr<vcl::Window> pWindow = GetWindow(); |
121 | if ( pWindow ) |
122 | { |
123 | WinBits nStyle = pWindow->GetStyle(); |
124 | if ( bEnable ) |
125 | nStyle |= WB_DIALOGCONTROL; |
126 | else |
127 | nStyle &= (~WB_DIALOGCONTROL); |
128 | pWindow->SetStyle( nStyle ); |
129 | } |
130 | } |
131 | |
132 | void VCLXContainer::setTabOrder( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components, const css::uno::Sequence< css::uno::Any >& Tabs, sal_Bool bGroupControl ) |
133 | { |
134 | SolarMutexGuard aGuard; |
135 | |
136 | sal_uInt32 nCount = Components.getLength(); |
137 | DBG_ASSERT( nCount == static_cast<sal_uInt32>(Tabs.getLength()), "setTabOrder: TabCount != ComponentCount" ); |
138 | const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray(); |
139 | const css::uno::Any* pTabs = Tabs.getConstArray(); |
140 | |
141 | vcl::Window* pPrevWin = nullptr; |
142 | for ( sal_uInt32 n = 0; n < nCount; n++ ) |
143 | { |
144 | |
145 | VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( pComps[n] ); |
146 | |
147 | if ( pWin ) |
148 | { |
149 | |
150 | |
151 | if ( pPrevWin ) |
152 | pWin->SetZOrder( pPrevWin, ZOrderFlags::Behind ); |
153 | |
154 | WinBits nStyle = pWin->GetStyle(); |
155 | nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP); |
156 | if ( pTabs[n].getValueType().getTypeClass() == css::uno::TypeClass_BOOLEAN ) |
157 | { |
158 | bool bTab = false; |
159 | pTabs[n] >>= bTab; |
160 | nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP ); |
161 | } |
162 | pWin->SetStyle( nStyle ); |
163 | |
164 | if ( bGroupControl ) |
165 | { |
166 | if ( n == 0 ) |
167 | pWin->SetDialogControlStart( true ); |
168 | else |
169 | pWin->SetDialogControlStart( false ); |
170 | } |
171 | |
172 | pPrevWin = pWin; |
173 | } |
174 | } |
175 | } |
176 | |
177 | void VCLXContainer::setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components ) |
178 | { |
179 | SolarMutexGuard aGuard; |
180 | |
181 | sal_uInt32 nCount = Components.getLength(); |
182 | const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray(); |
183 | |
184 | vcl::Window* pPrevWin = nullptr; |
185 | vcl::Window* pPrevRadio = nullptr; |
186 | for ( sal_uInt32 n = 0; n < nCount; n++ ) |
| 1 | Assuming 'n' is < 'nCount' | |
|
| 2 | | Loop condition is true. Entering loop body | |
|
| 21 | | Loop condition is true. Entering loop body | |
|
187 | { |
188 | VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( pComps[n] ); |
189 | if ( pWin ) |
| |
| |
190 | { |
191 | vcl::Window* pSortBehind = pPrevWin; |
192 | |
193 | bool bNewPrevWin = true; |
194 | if ( pWin->GetType() == WindowType::RADIOBUTTON ) |
| 4 | | Assuming the condition is false | |
|
| |
| 23 | | Assuming the condition is false | |
|
| |
195 | { |
196 | if ( pPrevRadio ) |
197 | { |
198 | |
199 | bNewPrevWin = ( pPrevWin == pPrevRadio ); |
200 | pSortBehind = pPrevRadio; |
201 | } |
202 | pPrevRadio = pWin; |
203 | } |
204 | |
205 | |
206 | if ( pSortBehind ) |
| |
| |
207 | pWin->SetZOrder( pSortBehind, ZOrderFlags::Behind ); |
| 26 | | Use of memory after it is freed |
|
208 | |
209 | WinBits nStyle = pWin->GetStyle(); |
210 | if ( n == 0 ) |
| |
211 | nStyle |= WB_GROUP; |
212 | else |
213 | nStyle &= (~WB_GROUP); |
214 | pWin->SetStyle( nStyle ); |
215 | |
216 | |
217 | if ( n == ( nCount - 1 ) ) |
| 8 | | Assuming the condition is false | |
|
| |
218 | { |
219 | vcl::Window* pBehindLast = pWin->GetWindow( GetWindowType::Next ); |
220 | if ( pBehindLast ) |
221 | { |
222 | WinBits nLastStyle = pBehindLast->GetStyle(); |
223 | nLastStyle |= WB_GROUP; |
224 | pBehindLast->SetStyle( nLastStyle ); |
225 | } |
226 | } |
227 | |
228 | if ( bNewPrevWin ) |
| |
229 | pPrevWin = pWin; |
230 | } |
231 | } |
| 11 | | Calling implicit destructor for 'VclPtr<vcl::Window>' | |
|
| |
| 19 | | Returning from '~Reference' | |
|
| 20 | | Returning from destructor for 'VclPtr<vcl::Window>' | |
|
232 | } |
233 | |
234 | void SAL_CALL VCLXContainer::setProperty( |
235 | const OUString& PropertyName, |
236 | const css::uno::Any& Value ) |
237 | { |
238 | SolarMutexGuard aGuard; |
239 | |
240 | sal_uInt16 nPropType = GetPropertyId( PropertyName ); |
241 | switch ( nPropType ) |
242 | { |
243 | case BASEPROPERTY_SCROLLHEIGHT: |
244 | case BASEPROPERTY_SCROLLWIDTH: |
245 | case BASEPROPERTY_SCROLLTOP: |
246 | case BASEPROPERTY_SCROLLLEFT: |
247 | { |
248 | sal_Int32 nVal =0; |
249 | Value >>= nVal; |
250 | Size aSize( nVal, nVal ); |
251 | VclPtr<vcl::Window> pWindow = GetWindow(); |
252 | MapMode aMode( MapUnit::MapAppFont ); |
253 | toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() ); |
254 | if ( pWindow && pScrollable ) |
255 | { |
256 | OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); |
257 | if ( !pDev ) |
258 | pDev = pWindow->GetParent(); |
259 | |
260 | |
261 | if ( !pDev ) |
262 | break; |
263 | |
264 | aSize = pDev->LogicToPixel( aSize, aMode ); |
265 | switch ( nPropType ) |
266 | { |
267 | case BASEPROPERTY_SCROLLHEIGHT: |
268 | pScrollable->SetScrollHeight( aSize.Height() ); |
269 | break; |
270 | case BASEPROPERTY_SCROLLWIDTH: |
271 | pScrollable->SetScrollWidth( aSize.Width() ); |
272 | break; |
273 | case BASEPROPERTY_SCROLLTOP: |
274 | pScrollable->SetScrollTop( aSize.Height() ); |
275 | break; |
276 | case BASEPROPERTY_SCROLLLEFT: |
277 | pScrollable->SetScrollLeft( aSize.Width() ); |
278 | break; |
279 | default: |
280 | break; |
281 | } |
282 | break; |
283 | } |
284 | break; |
285 | } |
286 | |
287 | default: |
288 | { |
289 | VCLXWindow::setProperty( PropertyName, Value ); |
290 | } |
291 | } |
292 | } |
293 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | #ifndef INCLUDED_RTL_REF_HXX |
21 | #define INCLUDED_RTL_REF_HXX |
22 | |
23 | #include "sal/config.h" |
24 | |
25 | #include <cassert> |
26 | #include <cstddef> |
27 | #include <functional> |
28 | #ifdef LIBO_INTERNAL_ONLY |
29 | #include <type_traits> |
30 | #endif |
31 | |
32 | #include "sal/types.h" |
33 | |
34 | namespace rtl |
35 | { |
36 | |
37 | |
38 | |
39 | template <class reference_type> |
40 | class Reference |
41 | { |
42 | |
43 | |
44 | reference_type * m_pBody; |
45 | |
46 | |
47 | public: |
48 | |
49 | |
50 | Reference() |
51 | : m_pBody (NULL) |
52 | {} |
53 | |
54 | |
55 | |
56 | |
57 | Reference (reference_type * pBody, __sal_NoAcquire) |
58 | : m_pBody (pBody) |
59 | { |
60 | } |
61 | |
62 | |
63 | |
64 | Reference (reference_type * pBody) |
65 | : m_pBody (pBody) |
66 | { |
67 | if (m_pBody) |
68 | m_pBody->acquire(); |
69 | } |
70 | |
71 | |
72 | |
73 | Reference (const Reference<reference_type> & handle) |
74 | : m_pBody (handle.m_pBody) |
75 | { |
76 | if (m_pBody) |
77 | m_pBody->acquire(); |
78 | } |
79 | |
80 | #ifdef LIBO_INTERNAL_ONLY |
81 | |
82 | |
83 | Reference (Reference<reference_type> && handle) noexcept |
84 | : m_pBody (handle.m_pBody) |
85 | { |
86 | handle.m_pBody = nullptr; |
87 | } |
88 | #endif |
89 | |
90 | #if defined LIBO_INTERNAL_ONLY |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | template< class derived_type > |
98 | inline Reference( |
99 | const Reference< derived_type > & rRef, |
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) |
101 | : m_pBody (rRef.get()) |
102 | { |
103 | if (m_pBody) |
104 | m_pBody->acquire(); |
105 | } |
106 | #endif |
107 | |
108 | |
109 | |
110 | ~Reference() COVERITY_NOEXCEPT_FALSE |
111 | { |
112 | if (m_pBody) |
| |
113 | m_pBody->release(); |
| 14 | | Calling 'VclReferenceBase::release' | |
|
| 18 | | Returning; memory was released | |
|
114 | } |
115 | |
116 | |
117 | |
118 | |
119 | Reference<reference_type> & |
120 | SAL_CALL set (reference_type * pBody) |
121 | { |
122 | if (pBody) |
123 | pBody->acquire(); |
124 | reference_type * const pOld = m_pBody; |
125 | m_pBody = pBody; |
126 | if (pOld) |
127 | pOld->release(); |
128 | return *this; |
129 | } |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | Reference<reference_type> & |
136 | SAL_CALL operator= (const Reference<reference_type> & handle) |
137 | { |
138 | return set( handle.m_pBody ); |
139 | } |
140 | |
141 | #ifdef LIBO_INTERNAL_ONLY |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | Reference<reference_type> & |
148 | operator= (Reference<reference_type> && handle) |
149 | { |
150 | |
151 | if (m_pBody) |
152 | m_pBody->release(); |
153 | m_pBody = handle.m_pBody; |
154 | handle.m_pBody = nullptr; |
155 | return *this; |
156 | } |
157 | #endif |
158 | |
159 | |
160 | |
161 | Reference<reference_type> & |
162 | SAL_CALL operator= (reference_type * pBody) |
163 | { |
164 | return set( pBody ); |
165 | } |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | |
172 | |
173 | |
174 | Reference<reference_type> & SAL_CALL clear() |
175 | { |
176 | if (m_pBody) |
177 | { |
178 | reference_type * const pOld = m_pBody; |
179 | m_pBody = NULL; |
180 | pOld->release(); |
181 | } |
182 | return *this; |
183 | } |
184 | |
185 | |
186 | |
187 | |
188 | |
189 | |
190 | reference_type * SAL_CALL get() const |
191 | { |
192 | return m_pBody; |
193 | } |
194 | |
195 | |
196 | |
197 | |
198 | reference_type * SAL_CALL operator->() const |
199 | { |
200 | assert(m_pBody != NULL); |
201 | return m_pBody; |
202 | } |
203 | |
204 | |
205 | |
206 | |
207 | reference_type & SAL_CALL operator*() const |
208 | { |
209 | assert(m_pBody != NULL); |
210 | return *m_pBody; |
211 | } |
212 | |
213 | |
214 | |
215 | |
216 | bool SAL_CALL is() const |
217 | { |
218 | return (m_pBody != NULL); |
219 | } |
220 | |
221 | #if defined LIBO_INTERNAL_ONLY |
222 | |
223 | |
224 | explicit operator bool() const |
225 | { |
226 | return is(); |
227 | } |
228 | #endif |
229 | |
230 | |
231 | |
232 | bool SAL_CALL operator== (const reference_type * pBody) const |
233 | { |
234 | return (m_pBody == pBody); |
235 | } |
236 | |
237 | |
238 | |
239 | |
240 | bool |
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const |
242 | { |
243 | return (m_pBody == handle.m_pBody); |
244 | } |
245 | |
246 | |
247 | |
248 | |
249 | bool |
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const |
251 | { |
252 | return (m_pBody != handle.m_pBody); |
253 | } |
254 | |
255 | |
256 | |
257 | |
258 | bool |
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const |
260 | { |
261 | return (m_pBody < handle.m_pBody); |
262 | } |
263 | |
264 | |
265 | |
266 | |
267 | bool |
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const |
269 | { |
270 | return (m_pBody > handle.m_pBody); |
271 | } |
272 | }; |
273 | |
274 | } |
275 | |
276 | #if defined LIBO_INTERNAL_ONLY |
277 | namespace std |
278 | { |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | template<typename T> |
287 | struct hash<::rtl::Reference<T>> |
288 | { |
289 | std::size_t operator()(::rtl::Reference<T> const & s) const |
290 | { return std::size_t(s.get()); } |
291 | }; |
292 | |
293 | |
294 | } |
295 | |
296 | #endif |
297 | |
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ |
299 | |
300 | |