File: | home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx |
Warning: | line 424, column 24 The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 <ooo/vba/office/MsoZOrderCmd.hpp> | |||
20 | #include <ooo/vba/office/MsoScaleFrom.hpp> | |||
21 | #include <com/sun/star/container/XChild.hpp> | |||
22 | #include <com/sun/star/container/XNamed.hpp> | |||
23 | #include <com/sun/star/drawing/ConnectorType.hpp> | |||
24 | #include <com/sun/star/drawing/XDrawPage.hpp> | |||
25 | #include <com/sun/star/drawing/XShapes.hpp> | |||
26 | #include <com/sun/star/view/XSelectionSupplier.hpp> | |||
27 | #include <com/sun/star/lang/XServiceInfo.hpp> | |||
28 | #include <com/sun/star/text/RelOrientation.hpp> | |||
29 | #include <com/sun/star/uno/XComponentContext.hpp> | |||
30 | #include <com/sun/star/frame/XModel.hpp> | |||
31 | #include <ooo/vba/office/MsoShapeType.hpp> | |||
32 | #include <ooo/vba/office/MsoAutoShapeType.hpp> | |||
33 | #include <ooo/vba/word/WdRelativeHorizontalPosition.hpp> | |||
34 | #include <ooo/vba/word/WdRelativeVerticalPosition.hpp> | |||
35 | ||||
36 | #include <basic/sberrors.hxx> | |||
37 | #include <comphelper/processfactory.hxx> | |||
38 | #include <vcl/svapp.hxx> | |||
39 | #include <sal/log.hxx> | |||
40 | ||||
41 | #include <vbahelper/vbashape.hxx> | |||
42 | #include <vbahelper/vbatextframe.hxx> | |||
43 | #include "vbalineformat.hxx" | |||
44 | #include "vbafillformat.hxx" | |||
45 | #include "vbapictureformat.hxx" | |||
46 | #include <vbahelper/vbashaperange.hxx> | |||
47 | ||||
48 | using namespace ::ooo::vba; | |||
49 | using namespace ::com::sun::star; | |||
50 | ||||
51 | ScVbaShape::ScVbaShape( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel, sal_Int32 nType ) | |||
52 | : ScVbaShape_BASE( xParent, xContext ), m_xShape( xShape ), m_xShapes( xShapes ), m_nType( nType ), m_xModel( xModel ) | |||
53 | { | |||
54 | m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW ); | |||
55 | m_pShapeHelper.reset( new ShapeHelper( m_xShape ) ); | |||
56 | addListeners(); | |||
57 | } | |||
58 | ||||
59 | ScVbaShape::~ScVbaShape() | |||
60 | { | |||
61 | } | |||
62 | ||||
63 | void SAL_CALL | |||
64 | ScVbaShape::disposing( const lang::EventObject& rEventObject ) | |||
65 | { | |||
66 | try | |||
67 | { | |||
68 | uno::Reference< drawing::XShapes > xShapes( rEventObject.Source, uno::UNO_QUERY ); | |||
69 | uno::Reference< drawing::XShape > xShape( rEventObject.Source, uno::UNO_QUERY ); | |||
70 | if ( xShapes.is() ) | |||
71 | removeShapesListener(); | |||
72 | if ( xShape.is() ) | |||
73 | removeShapeListener(); | |||
74 | } | |||
75 | catch( uno::Exception& ) | |||
76 | { | |||
77 | } | |||
78 | } | |||
79 | ||||
80 | ||||
81 | void ScVbaShape::addListeners() | |||
82 | { | |||
83 | uno::Reference< lang::XComponent > xComponent( m_xShape, uno::UNO_QUERY ); | |||
84 | if ( xComponent.is() ) | |||
85 | xComponent->addEventListener( this ); | |||
86 | ||||
87 | xComponent.set( m_xShapes, uno::UNO_QUERY ); | |||
88 | if ( xComponent.is() ) | |||
89 | xComponent->addEventListener( this ); | |||
90 | } | |||
91 | ||||
92 | void | |||
93 | ScVbaShape::removeShapeListener() | |||
94 | { | |||
95 | if( m_xShape.is() ) | |||
96 | { | |||
97 | uno::Reference< lang::XComponent > xComponent( m_xShape, uno::UNO_QUERY_THROW ); | |||
98 | xComponent->removeEventListener( this ); | |||
99 | } | |||
100 | m_xShape = nullptr; | |||
101 | m_xPropertySet = nullptr; | |||
102 | } | |||
103 | ||||
104 | void | |||
105 | ScVbaShape::removeShapesListener() | |||
106 | { | |||
107 | if( m_xShapes.is() ) | |||
108 | { | |||
109 | uno::Reference< lang::XComponent > xComponent( m_xShapes, uno::UNO_QUERY_THROW ); | |||
110 | xComponent->removeEventListener( this ); | |||
111 | } | |||
112 | m_xShapes = nullptr; | |||
113 | } | |||
114 | ||||
115 | sal_Int32 | |||
116 | ScVbaShape::getType( const css::uno::Reference< drawing::XShape >& xShape ) | |||
117 | { | |||
118 | OUString sShapeType; | |||
119 | uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor( xShape, uno::UNO_QUERY_THROW ); | |||
120 | sShapeType = xShapeDescriptor->getShapeType(); | |||
121 | SAL_INFO("vbahelper", "ScVbaShape::getType: " << sShapeType)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vbahelper")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "ScVbaShape::getType: " << sShapeType) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "121" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getType: " << sShapeType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ScVbaShape::getType: " << sShapeType; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "121" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "ScVbaShape::getType: " << sShapeType) == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "121" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getType: " << sShapeType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ScVbaShape::getType: " << sShapeType; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "121" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
122 | // office::MsoShapeType::msoDiagram to "com.sun.star.drawing.GroupShape" | |||
123 | if( sShapeType == "com.sun.star.drawing.GroupShape" ) | |||
124 | return office::MsoShapeType::msoGroup; | |||
125 | else if( sShapeType == "com.sun.star.drawing.GraphicObjectShape" ) | |||
126 | return office::MsoShapeType::msoPicture; | |||
127 | else if( sShapeType == "com.sun.star.drawing.ControlShape" || sShapeType == "FrameShape" ) | |||
128 | return office::MsoShapeType::msoOLEControlObject; | |||
129 | // OOo don't support office::MsoShapeType::msoComment as a Shape. | |||
130 | else if( sShapeType == "com.sun.star.drawing.OLE2Shape" ) | |||
131 | return office::MsoShapeType::msoChart; | |||
132 | // Art characters office::MsoShapeType::msoTextEffect, in OOo corresponding to "com.sun.star.drawing.CustomShape" | |||
133 | else if( sShapeType == "com.sun.star.drawing.ConnectorShape" ) | |||
134 | { | |||
135 | drawing::ConnectorType connectorType; | |||
136 | uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY_THROW ); | |||
137 | xPropertySet->getPropertyValue( "EdgeKind" ) >>= connectorType; | |||
138 | if( connectorType == drawing::ConnectorType_CURVE ) | |||
139 | return office::MsoShapeType::msoFreeform; | |||
140 | else if( connectorType == drawing::ConnectorType_LINE ) | |||
141 | return office::MsoShapeType::msoLine; | |||
142 | else | |||
143 | return office::MsoShapeType::msoAutoShape; | |||
144 | } | |||
145 | else if( sShapeType == "com.sun.star.drawing.LineShape" ) | |||
146 | return office::MsoShapeType::msoLine; | |||
147 | else if( sShapeType == "com.sun.star.drawing.CustomShape" | |||
148 | || sShapeType == "com.sun.star.drawing.RectangleShape" | |||
149 | || sShapeType == "com.sun.star.drawing.EllipseShape" ) | |||
150 | return office::MsoShapeType::msoAutoShape; | |||
151 | else if( sShapeType == "com.sun.star.drawing.TextShape" ) | |||
152 | return office::MsoShapeType::msoTextBox; | |||
153 | else | |||
154 | throw uno::RuntimeException("the shape type do not be supported: " + sShapeType ); | |||
155 | } | |||
156 | ||||
157 | sal_Int32 ScVbaShape::getAutoShapeType(const css::uno::Reference< drawing::XShape >& xShape) | |||
158 | { | |||
159 | assert( ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape )(static_cast <bool> (ScVbaShape::getType( xShape ) == office ::MsoShapeType::msoAutoShape) ? void (0) : __assert_fail ("ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape" , "/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" , 159, __extension__ __PRETTY_FUNCTION__)); | |||
160 | ||||
161 | OUString sShapeType; | |||
162 | uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor( xShape, uno::UNO_QUERY_THROW ); | |||
163 | sShapeType = xShapeDescriptor->getShapeType(); | |||
164 | SAL_INFO("vbahelper", "ScVbaShape::getAutoShapeType: " << sShapeType)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vbahelper")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "ScVbaShape::getAutoShapeType: " << sShapeType) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "164" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getAutoShapeType: " << sShapeType), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "ScVbaShape::getAutoShapeType: " << sShapeType; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "164" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "ScVbaShape::getAutoShapeType: " << sShapeType ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "164" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getAutoShapeType: " << sShapeType), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "ScVbaShape::getAutoShapeType: " << sShapeType; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vbahelper"), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "164" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
165 | ||||
166 | if( sShapeType == "com.sun.star.drawing.EllipseShape" ) | |||
167 | return office::MsoAutoShapeType::msoShapeOval; | |||
168 | else if ( sShapeType == "com.sun.star.drawing.RectangleShape" ) | |||
169 | return office::MsoAutoShapeType::msoShapeRectangle; | |||
170 | else if ( sShapeType == "com.sun.star.drawing.CustomShape" ) | |||
171 | { | |||
172 | uno::Reference< beans::XPropertySet > aXPropSet( xShape, uno::UNO_QUERY ); | |||
173 | uno::Any aGeoPropSet = aXPropSet->getPropertyValue( "CustomShapeGeometry" ); | |||
174 | uno::Sequence< beans::PropertyValue > aGeoPropSeq; | |||
175 | if ( aGeoPropSet >>= aGeoPropSeq ) | |||
176 | { | |||
177 | for( const auto& rProp : std::as_const(aGeoPropSeq) ) | |||
178 | { | |||
179 | if( rProp.Name == "Type" ) | |||
180 | { | |||
181 | OUString sType; | |||
182 | if( rProp.Value >>= sType ) | |||
183 | { | |||
184 | if( sType.endsWith( "ellipse" ) ) | |||
185 | return office::MsoAutoShapeType::msoShapeOval; | |||
186 | // TODO other custom shapes here | |||
187 | } | |||
188 | } | |||
189 | } | |||
190 | } | |||
191 | } | |||
192 | ||||
193 | SAL_WARN( "vbahelper", "ScVbaShape::getAutoShapeType: unknown auto type" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vbahelper")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "ScVbaShape::getAutoShapeType: unknown auto type" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "193" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getAutoShapeType: unknown auto type" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ScVbaShape::getAutoShapeType: unknown auto type"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "193" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "ScVbaShape::getAutoShapeType: unknown auto type" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "193" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "ScVbaShape::getAutoShapeType: unknown auto type" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "ScVbaShape::getAutoShapeType: unknown auto type"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vbahelper" ), ("/home/maarten/src/libreoffice/core/vbahelper/source/vbahelper/vbashape.cxx" ":" "193" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
194 | return -1; // could not decide | |||
195 | ||||
196 | } | |||
197 | ||||
198 | // Attributes | |||
199 | OUString SAL_CALL | |||
200 | ScVbaShape::getName() | |||
201 | { | |||
202 | OUString sName; | |||
203 | uno::Reference< container::XNamed > xNamed( m_xShape, uno::UNO_QUERY_THROW ); | |||
204 | sName = xNamed->getName(); | |||
205 | return sName; | |||
206 | } | |||
207 | ||||
208 | void SAL_CALL | |||
209 | ScVbaShape::setName( const OUString& _name ) | |||
210 | { | |||
211 | uno::Reference< container::XNamed > xNamed( m_xShape, uno::UNO_QUERY_THROW ); | |||
212 | xNamed->setName( _name ); | |||
213 | } | |||
214 | ||||
215 | OUString SAL_CALL | |||
216 | ScVbaShape::getAlternativeText() | |||
217 | { | |||
218 | OUString sAltText; | |||
219 | uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW ); | |||
220 | xProps->getPropertyValue("Title") >>= sAltText; | |||
221 | return sAltText; | |||
222 | } | |||
223 | ||||
224 | void SAL_CALL | |||
225 | ScVbaShape::setAlternativeText( const OUString& sAltText ) | |||
226 | { | |||
227 | uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW ); | |||
228 | xProps->setPropertyValue("Title", uno::Any( sAltText ) ); | |||
229 | } | |||
230 | ||||
231 | double SAL_CALL | |||
232 | ScVbaShape::getHeight() | |||
233 | { | |||
234 | return m_pShapeHelper->getHeight(); | |||
235 | } | |||
236 | ||||
237 | void SAL_CALL | |||
238 | ScVbaShape::setHeight(double _height) | |||
239 | { | |||
240 | m_pShapeHelper->setHeight( _height ); | |||
241 | } | |||
242 | ||||
243 | double SAL_CALL | |||
244 | ScVbaShape::getWidth() | |||
245 | { | |||
246 | return m_pShapeHelper->getWidth(); | |||
247 | } | |||
248 | ||||
249 | void SAL_CALL | |||
250 | ScVbaShape::setWidth(double _width) | |||
251 | { | |||
252 | m_pShapeHelper->setWidth( _width ); | |||
253 | } | |||
254 | ||||
255 | double SAL_CALL | |||
256 | ScVbaShape::getLeft() | |||
257 | { | |||
258 | double left = 0; | |||
259 | try | |||
260 | { | |||
261 | left = m_pShapeHelper->getLeft(); | |||
262 | } | |||
263 | catch( uno::Exception& ) | |||
264 | { | |||
265 | // fail to get position by using XShape::getPosition() | |||
266 | sal_Int32 nLeft = 0; | |||
267 | m_xPropertySet->getPropertyValue( "HoriOrientPosition" ) >>= nLeft; | |||
268 | left = Millimeter::getInPoints( nLeft ); | |||
269 | } | |||
270 | return left; | |||
271 | } | |||
272 | ||||
273 | void SAL_CALL | |||
274 | ScVbaShape::setLeft( double _left ) | |||
275 | { | |||
276 | try | |||
277 | { | |||
278 | m_pShapeHelper->setLeft( _left ); | |||
279 | } | |||
280 | catch( uno::Exception& ) | |||
281 | { | |||
282 | sal_Int32 nLeft = Millimeter::getInHundredthsOfOneMillimeter( _left ); | |||
283 | m_xPropertySet->setPropertyValue( "HoriOrientPosition" , uno::makeAny( nLeft ) ); | |||
284 | } | |||
285 | } | |||
286 | ||||
287 | double SAL_CALL | |||
288 | ScVbaShape::getTop() | |||
289 | { | |||
290 | double top = 0; | |||
291 | try | |||
292 | { | |||
293 | top = m_pShapeHelper->getTop(); | |||
294 | } | |||
295 | catch( uno::Exception& ) | |||
296 | { | |||
297 | sal_Int32 nTop = 0; | |||
298 | m_xPropertySet->getPropertyValue( "VertOrientPosition" ) >>= nTop; | |||
299 | top = Millimeter::getInPoints( nTop ); | |||
300 | } | |||
301 | return top; | |||
302 | } | |||
303 | ||||
304 | void SAL_CALL | |||
305 | ScVbaShape::setTop( double _top ) | |||
306 | { | |||
307 | try | |||
308 | { | |||
309 | m_pShapeHelper->setTop( _top ); | |||
310 | } | |||
311 | catch( uno::Exception& ) | |||
312 | { | |||
313 | sal_Int32 nTop = Millimeter::getInHundredthsOfOneMillimeter( _top ); | |||
314 | m_xPropertySet->setPropertyValue( "VertOrientPosition" , uno::makeAny( nTop ) ); | |||
315 | } | |||
316 | } | |||
317 | ||||
318 | sal_Bool SAL_CALL | |||
319 | ScVbaShape::getVisible() | |||
320 | { | |||
321 | // #STUB | |||
322 | //UNO Shapes are always visible | |||
323 | return true; | |||
324 | } | |||
325 | ||||
326 | void SAL_CALL | |||
327 | ScVbaShape::setVisible( sal_Bool /*_visible*/ ) | |||
328 | { | |||
329 | // #STUB | |||
330 | //UNO Shapes are always visible | |||
331 | } | |||
332 | ||||
333 | sal_Int32 SAL_CALL | |||
334 | ScVbaShape::getZOrderPosition() | |||
335 | { | |||
336 | sal_Int32 nZOrderPosition = 0; | |||
337 | uno::Any aZOrderPosition = m_xPropertySet->getPropertyValue( "ZOrder" ); | |||
338 | aZOrderPosition >>= nZOrderPosition; | |||
339 | return nZOrderPosition + 1; | |||
340 | } | |||
341 | ||||
342 | sal_Int32 SAL_CALL | |||
343 | ScVbaShape::getType() | |||
344 | { | |||
345 | return m_nType; | |||
346 | } | |||
347 | ||||
348 | double SAL_CALL | |||
349 | ScVbaShape::getRotation() | |||
350 | { | |||
351 | double dRotation = 0; | |||
352 | sal_Int32 nRotation = 0; | |||
353 | m_xPropertySet->getPropertyValue( "RotateAngle" ) >>= nRotation; | |||
354 | dRotation = static_cast< double >( nRotation /100 ); | |||
355 | return dRotation; | |||
356 | } | |||
357 | ||||
358 | void SAL_CALL | |||
359 | ScVbaShape::setRotation( double _rotation ) | |||
360 | { | |||
361 | sal_Int32 nRotation = static_cast < sal_Int32 > ( _rotation * 100 ); | |||
362 | m_xPropertySet->setPropertyValue( "RotateAngle" , uno::makeAny( nRotation ) ); | |||
363 | } | |||
364 | ||||
365 | uno::Reference< msforms::XLineFormat > SAL_CALL | |||
366 | ScVbaShape::getLine() | |||
367 | { | |||
368 | // TODO should only return line | |||
369 | return uno::Reference< msforms::XLineFormat >( new ScVbaLineFormat( this, mxContext, m_xShape ) ); | |||
370 | } | |||
371 | ||||
372 | uno::Reference< msforms::XFillFormat > SAL_CALL | |||
373 | ScVbaShape::getFill() | |||
374 | { | |||
375 | return uno::Reference< msforms::XFillFormat >( new ScVbaFillFormat( this, mxContext, m_xShape ) ); | |||
376 | } | |||
377 | ||||
378 | uno::Reference< msforms::XPictureFormat > SAL_CALL | |||
379 | ScVbaShape::getPictureFormat() | |||
380 | { | |||
381 | return uno::Reference< msforms::XPictureFormat >( new ScVbaPictureFormat( this, mxContext, m_xShape ) ); | |||
382 | } | |||
383 | ||||
384 | // Methods | |||
385 | uno::Any SAL_CALL | |||
386 | ScVbaShape::TextFrame() | |||
387 | { | |||
388 | uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW ); | |||
389 | if( xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) ) | |||
390 | { | |||
391 | uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); | |||
392 | uno::Sequence< uno::Any > aArgs(2); | |||
393 | aArgs[0] <<= getParent(); | |||
394 | aArgs[1] <<= m_xShape; | |||
395 | uno::Reference< uno::XInterface > xTextFrame = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "ooo.vba.excel.TextFrame" , aArgs, xContext ); | |||
396 | return uno::makeAny( xTextFrame ); | |||
397 | } | |||
398 | ||||
399 | return uno::makeAny( uno::Reference< msforms::XTextFrame >( new VbaTextFrame( this, mxContext, m_xShape ) ) ); | |||
400 | } | |||
401 | ||||
402 | void SAL_CALL | |||
403 | ScVbaShape::Delete() | |||
404 | { | |||
405 | SolarMutexGuard aGuard; | |||
406 | m_xShapes->remove( m_xShape ); | |||
407 | } | |||
408 | ||||
409 | void SAL_CALL | |||
410 | ScVbaShape::ZOrder( sal_Int32 ZOrderCmd ) | |||
411 | { | |||
412 | sal_Int32 nOrderPosition; | |||
| ||||
413 | uno::Any aOrderPosition = m_xPropertySet->getPropertyValue( "ZOrder" ); | |||
414 | aOrderPosition >>= nOrderPosition; | |||
415 | switch( ZOrderCmd ) | |||
416 | { | |||
417 | case office::MsoZOrderCmd::msoBringToFront: | |||
418 | m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) ) ); | |||
419 | break; | |||
420 | case office::MsoZOrderCmd::msoSendToBack: | |||
421 | m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( sal_Int32(0) ) ); | |||
422 | break; | |||
423 | case office::MsoZOrderCmd::msoBringForward: | |||
424 | nOrderPosition += 1; | |||
| ||||
425 | m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( nOrderPosition ) ); | |||
426 | break; | |||
427 | case office::MsoZOrderCmd::msoSendBackward: | |||
428 | if( nOrderPosition > 0 ) | |||
429 | { | |||
430 | nOrderPosition -= 1; | |||
431 | m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( nOrderPosition ) ); | |||
432 | } | |||
433 | break; | |||
434 | // below two commands use with Writer for text and image object. | |||
435 | case office::MsoZOrderCmd::msoBringInFrontOfText: | |||
436 | case office::MsoZOrderCmd::msoSendBehindText: | |||
437 | throw uno::RuntimeException( "This ZOrderCmd is not implemented, it is use with writer." ); | |||
438 | default: | |||
439 | throw uno::RuntimeException( "Invalid Parameter." ); | |||
440 | } | |||
441 | } | |||
442 | ||||
443 | void SAL_CALL | |||
444 | ScVbaShape::IncrementRotation( double Increment ) | |||
445 | { | |||
446 | double nCurrentRotation = getRotation(); | |||
447 | nCurrentRotation += Increment; | |||
448 | setRotation(nCurrentRotation); | |||
449 | } | |||
450 | ||||
451 | void SAL_CALL | |||
452 | ScVbaShape::IncrementLeft( double Increment ) | |||
453 | { | |||
454 | double nCurrentLeft = getLeft(); | |||
455 | nCurrentLeft += Increment; | |||
456 | setLeft(nCurrentLeft); | |||
457 | } | |||
458 | ||||
459 | void SAL_CALL | |||
460 | ScVbaShape::IncrementTop( double Increment ) | |||
461 | { | |||
462 | double nCurrentTop = getTop(); | |||
463 | nCurrentTop += Increment; | |||
464 | setTop(nCurrentTop); | |||
465 | } | |||
466 | ||||
467 | void SAL_CALL | |||
468 | ScVbaShape::ScaleHeight( double Factor, sal_Bool /*RelativeToOriginalSize*/, sal_Int32 Scale ) | |||
469 | { | |||
470 | double nHeight = getHeight(); | |||
471 | double nNewHeight = nHeight * Factor; | |||
472 | if( Scale == office::MsoScaleFrom::msoScaleFromTopLeft ) | |||
473 | { | |||
474 | setHeight(nNewHeight); | |||
475 | } | |||
476 | else if( Scale == office::MsoScaleFrom::msoScaleFromBottomRight ) | |||
477 | { | |||
478 | double nDeltaHeight = nNewHeight - nHeight; | |||
479 | double nNewTop = getTop() - nDeltaHeight; | |||
480 | setTop(nNewTop); | |||
481 | setHeight(nNewHeight); | |||
482 | } | |||
483 | else if( Scale == office::MsoScaleFrom::msoScaleFromMiddle ) | |||
484 | { | |||
485 | double nDeltaHeight = (nNewHeight - nHeight) / 2; | |||
486 | double nNewTop = getTop() - nDeltaHeight; | |||
487 | setTop(nNewTop); | |||
488 | setHeight(nNewHeight); | |||
489 | } | |||
490 | else | |||
491 | { | |||
492 | throw uno::RuntimeException( "ScaleHeight.Scale wrong value is given." ); | |||
493 | } | |||
494 | } | |||
495 | ||||
496 | void SAL_CALL | |||
497 | ScVbaShape::ScaleWidth( double Factor, sal_Bool /*RelativeToOriginalSize*/, sal_Int32 Scale ) | |||
498 | { | |||
499 | double nWidth = getWidth(); | |||
500 | double nNewWidth = nWidth * Factor; | |||
501 | if( Scale == office::MsoScaleFrom::msoScaleFromTopLeft ) | |||
502 | { | |||
503 | setWidth(nNewWidth); | |||
504 | } | |||
505 | else if( Scale == office::MsoScaleFrom::msoScaleFromBottomRight ) | |||
506 | { | |||
507 | double nDeltaWidth = nNewWidth - nWidth; | |||
508 | double nNewLeft = getLeft() - nDeltaWidth; | |||
509 | setLeft(nNewLeft); | |||
510 | setWidth(nNewWidth); | |||
511 | } | |||
512 | else if( Scale == office::MsoScaleFrom::msoScaleFromMiddle ) | |||
513 | { | |||
514 | double nDeltaWidth = (nNewWidth - nWidth) / 2; | |||
515 | double nNewLeft = getLeft() - nDeltaWidth; | |||
516 | setLeft(nNewLeft); | |||
517 | setWidth(nNewWidth); | |||
518 | } | |||
519 | else | |||
520 | { | |||
521 | throw uno::RuntimeException( "ScaleHeight.Scale wrong value is given." ); | |||
522 | } | |||
523 | } | |||
524 | ||||
525 | void SAL_CALL | |||
526 | ScVbaShape::Select( const uno::Any& /*Replace*/ ) | |||
527 | { | |||
528 | uno::Reference< view::XSelectionSupplier > xSelectSupp( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); | |||
529 | xSelectSupp->select( uno::makeAny( m_xShape ) ); | |||
530 | } | |||
531 | ||||
532 | // This method should not be part of Shape, what we really need to do is... | |||
533 | // dynamically create the appropriate objects e.g. TextBox, Oval, Picture etc. | |||
534 | // ( e.g. the ones that really do have ShapeRange as an attribute ) | |||
535 | uno::Any SAL_CALL | |||
536 | ScVbaShape::ShapeRange( const uno::Any& index ) | |||
537 | { | |||
538 | // perhaps we should store a reference to the Shapes Collection | |||
539 | // in this class | |||
540 | // but anyway this method should not even be in this class | |||
541 | // #TODO not sure what the parent of the Shapes collection should be | |||
542 | ||||
543 | XNamedObjectCollectionHelper< drawing::XShape >::XNamedVec aVec; | |||
544 | aVec.push_back( m_xShape ); | |||
545 | uno::Reference< container::XIndexAccess > xIndexAccess( new XNamedObjectCollectionHelper< drawing::XShape >( aVec ) ); | |||
546 | uno::Reference< container::XChild > xChild( m_xShape, uno::UNO_QUERY_THROW ); | |||
547 | // #FIXME for want of a better parent, setting this | |||
548 | uno::Reference< msforms::XShapeRange > xShapeRange( new ScVbaShapeRange( mxParent, mxContext, xIndexAccess, uno::Reference< drawing::XDrawPage >( xChild->getParent(), uno::UNO_QUERY_THROW ), m_xModel ) ); | |||
549 | if ( index.hasValue() ) | |||
550 | return xShapeRange->Item( index, uno::Any() ); | |||
551 | return uno::makeAny( xShapeRange ); | |||
552 | } | |||
553 | ||||
554 | sal_Bool SAL_CALL | |||
555 | ScVbaShape::getLockAspectRatio() | |||
556 | { | |||
557 | // #STUB | |||
558 | return false; | |||
559 | } | |||
560 | ||||
561 | void SAL_CALL | |||
562 | ScVbaShape::setLockAspectRatio( sal_Bool /*_lockaspectratio*/ ) | |||
563 | { | |||
564 | // #STUB | |||
565 | } | |||
566 | ||||
567 | sal_Bool SAL_CALL | |||
568 | ScVbaShape::getLockAnchor() | |||
569 | { | |||
570 | // #STUB | |||
571 | return true; | |||
572 | } | |||
573 | ||||
574 | void SAL_CALL | |||
575 | ScVbaShape::setLockAnchor( sal_Bool /*_lockanchor*/ ) | |||
576 | { | |||
577 | // #STUB | |||
578 | } | |||
579 | ||||
580 | sal_Int32 SAL_CALL | |||
581 | ScVbaShape::getRelativeHorizontalPosition() | |||
582 | { | |||
583 | sal_Int32 nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin; | |||
584 | sal_Int16 nType = text::RelOrientation::PAGE_LEFT; | |||
585 | m_xPropertySet->getPropertyValue( "HoriOrientRelation" ) >>= nType; | |||
586 | ||||
587 | switch( nType ) | |||
588 | { | |||
589 | case text::RelOrientation::FRAME: | |||
590 | { | |||
591 | nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn; | |||
592 | break; | |||
593 | } | |||
594 | case text::RelOrientation::PAGE_FRAME: | |||
595 | { | |||
596 | nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage; | |||
597 | break; | |||
598 | } | |||
599 | case text::RelOrientation::CHAR: | |||
600 | { | |||
601 | nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter; | |||
602 | break; | |||
603 | } | |||
604 | case text::RelOrientation::PAGE_PRINT_AREA: | |||
605 | { | |||
606 | nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin; | |||
607 | break; | |||
608 | } | |||
609 | default: | |||
610 | { | |||
611 | throw uno::RuntimeException( "Shape::RelativeHorizontalPosition: not implemented" ); | |||
612 | } | |||
613 | } | |||
614 | return nRelativeHorizontalPosition; | |||
615 | } | |||
616 | ||||
617 | void SAL_CALL | |||
618 | ScVbaShape::setRelativeHorizontalPosition(::sal_Int32 _relativehorizontalposition) | |||
619 | { | |||
620 | sal_Int16 nType = text::RelOrientation::PAGE_FRAME; | |||
621 | switch( _relativehorizontalposition ) | |||
622 | { | |||
623 | case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter: | |||
624 | { | |||
625 | nType = text::RelOrientation::CHAR; | |||
626 | break; | |||
627 | } | |||
628 | case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn: | |||
629 | { | |||
630 | nType = text::RelOrientation::PAGE_FRAME; | |||
631 | break; | |||
632 | } | |||
633 | case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin: | |||
634 | { | |||
635 | nType = text::RelOrientation::PAGE_PRINT_AREA; | |||
636 | break; | |||
637 | } | |||
638 | case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage: | |||
639 | { | |||
640 | nType = text::RelOrientation::PAGE_FRAME; | |||
641 | break; | |||
642 | } | |||
643 | default: | |||
644 | { | |||
645 | DebugHelper::runtimeexception(ERRCODE_BASIC_BAD_ARGUMENTErrCode( ErrCodeArea::Sbx, ErrCodeClass::NotSupported, 2)); | |||
646 | } | |||
647 | } | |||
648 | m_xPropertySet->setPropertyValue( "HoriOrientRelation" , uno::makeAny( nType ) ); | |||
649 | } | |||
650 | ||||
651 | sal_Int32 SAL_CALL | |||
652 | ScVbaShape::getRelativeVerticalPosition() | |||
653 | { | |||
654 | sal_Int32 nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin; | |||
655 | sal_Int16 nType = text::RelOrientation::PAGE_FRAME; | |||
656 | m_xPropertySet->getPropertyValue( "VertOrientRelation" ) >>= nType; | |||
657 | ||||
658 | switch( nType ) | |||
659 | { | |||
660 | case text::RelOrientation::FRAME: | |||
661 | { | |||
662 | nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph; | |||
663 | break; | |||
664 | } | |||
665 | case text::RelOrientation::PAGE_FRAME: | |||
666 | { | |||
667 | nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage; | |||
668 | break; | |||
669 | } | |||
670 | case text::RelOrientation::TEXT_LINE: | |||
671 | { | |||
672 | nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine; | |||
673 | break; | |||
674 | } | |||
675 | case text::RelOrientation::PAGE_PRINT_AREA: | |||
676 | { | |||
677 | nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin; | |||
678 | break; | |||
679 | } | |||
680 | default: | |||
681 | { | |||
682 | throw uno::RuntimeException( "Shape::RelativeVerticalPosition: not implemented" ); | |||
683 | } | |||
684 | } | |||
685 | return nRelativeVerticalPosition; | |||
686 | } | |||
687 | ||||
688 | void SAL_CALL | |||
689 | ScVbaShape::setRelativeVerticalPosition(::sal_Int32 _relativeverticalposition) | |||
690 | { | |||
691 | sal_Int16 nType = text::RelOrientation::PAGE_FRAME; | |||
692 | switch( _relativeverticalposition ) | |||
693 | { | |||
694 | case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine: | |||
695 | { | |||
696 | nType = text::RelOrientation::TEXT_LINE; | |||
697 | break; | |||
698 | } | |||
699 | case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph: | |||
700 | { | |||
701 | nType = text::RelOrientation::FRAME; | |||
702 | break; | |||
703 | } | |||
704 | case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin: | |||
705 | { | |||
706 | nType = text::RelOrientation::PAGE_PRINT_AREA; | |||
707 | break; | |||
708 | } | |||
709 | case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage: | |||
710 | { | |||
711 | nType = text::RelOrientation::PAGE_FRAME; | |||
712 | break; | |||
713 | } | |||
714 | default: | |||
715 | { | |||
716 | DebugHelper::runtimeexception(ERRCODE_BASIC_BAD_ARGUMENTErrCode( ErrCodeArea::Sbx, ErrCodeClass::NotSupported, 2)); | |||
717 | } | |||
718 | } | |||
719 | m_xPropertySet->setPropertyValue( "VertOrientRelation" , uno::makeAny( nType ) ); | |||
720 | } | |||
721 | ||||
722 | uno::Any SAL_CALL | |||
723 | ScVbaShape::WrapFormat() | |||
724 | { | |||
725 | uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW ); | |||
726 | if( xServiceInfo->supportsService( "com.sun.star.text.TextDocument" )) | |||
727 | { | |||
728 | uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); | |||
729 | uno::Sequence< uno::Any > aArgs(2); | |||
730 | aArgs[0] <<= getParent(); | |||
731 | aArgs[1] <<= m_xShape; | |||
732 | uno::Reference< uno::XInterface > xWrapFormat = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "ooo.vba.word.WrapFormat" , aArgs, xContext ); | |||
733 | return uno::makeAny( xWrapFormat ); | |||
734 | } | |||
735 | throw uno::RuntimeException( "Not implemented" ); | |||
736 | } | |||
737 | ||||
738 | OUString | |||
739 | ScVbaShape::getServiceImplName() | |||
740 | { | |||
741 | return "ScVbaShape"; | |||
742 | } | |||
743 | ||||
744 | uno::Sequence< OUString > | |||
745 | ScVbaShape::getServiceNames() | |||
746 | { | |||
747 | static uno::Sequence< OUString > const aServiceNames | |||
748 | { | |||
749 | "ooo.vba.msform.Shape" | |||
750 | }; | |||
751 | return aServiceNames; | |||
752 | } | |||
753 | ||||
754 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX |
20 | #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX |
21 | |
22 | #include "sal/config.h" |
23 | |
24 | #include <algorithm> |
25 | #include <cassert> |
26 | #include <cstddef> |
27 | #include <iomanip> |
28 | #include <ostream> |
29 | #include <utility> |
30 | |
31 | #include "com/sun/star/uno/Any.h" |
32 | #include "uno/data.h" |
33 | #include "uno/sequence2.h" |
34 | #include "com/sun/star/uno/Type.hxx" |
35 | #include "com/sun/star/uno/Reference.h" |
36 | #include "com/sun/star/uno/genfunc.hxx" |
37 | #include "com/sun/star/uno/RuntimeException.hpp" |
38 | #include "cppu/cppudllapi.h" |
39 | #include "cppu/unotype.hxx" |
40 | |
41 | extern "C" CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg( |
42 | uno_Any const * pAny, typelib_TypeDescriptionReference * pType ) |
43 | SAL_THROW_EXTERN_C()throw (); |
44 | |
45 | namespace com |
46 | { |
47 | namespace sun |
48 | { |
49 | namespace star |
50 | { |
51 | namespace uno |
52 | { |
53 | |
54 | |
55 | inline Any::Any() |
56 | { |
57 | ::uno_any_construct( this, NULL__null, NULL__null, cpp_acquire ); |
58 | } |
59 | |
60 | |
61 | template <typename T> |
62 | inline Any::Any( T const & value ) |
63 | { |
64 | ::uno_type_any_construct( |
65 | this, const_cast<T *>(&value), |
66 | ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(), |
67 | cpp_acquire ); |
68 | } |
69 | |
70 | inline Any::Any( bool value ) |
71 | { |
72 | sal_Bool b = value; |
73 | ::uno_type_any_construct( |
74 | this, &b, cppu::UnoType<bool>::get().getTypeLibType(), |
75 | cpp_acquire ); |
76 | } |
77 | |
78 | #if defined LIBO_INTERNAL_ONLY1 |
79 | template<typename T1, typename T2> |
80 | Any::Any(rtl::OUStringConcat<T1, T2> && value): |
81 | Any(rtl::OUString(std::move(value))) |
82 | {} |
83 | #endif |
84 | |
85 | inline Any::Any( const Any & rAny ) |
86 | { |
87 | ::uno_type_any_construct( this, rAny.pData, rAny.pType, cpp_acquire ); |
88 | } |
89 | |
90 | inline Any::Any( const void * pData_, const Type & rType ) |
91 | { |
92 | ::uno_type_any_construct( |
93 | this, const_cast< void * >( pData_ ), rType.getTypeLibType(), |
94 | cpp_acquire ); |
95 | } |
96 | |
97 | inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) |
98 | { |
99 | ::uno_any_construct( |
100 | this, const_cast< void * >( pData_ ), pTypeDescr, cpp_acquire ); |
101 | } |
102 | |
103 | inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) |
104 | { |
105 | ::uno_type_any_construct( |
106 | this, const_cast< void * >( pData_ ), pType_, cpp_acquire ); |
107 | } |
108 | |
109 | inline Any::~Any() |
110 | { |
111 | ::uno_any_destruct( |
112 | this, cpp_release ); |
113 | } |
114 | |
115 | inline Any & Any::operator = ( const Any & rAny ) |
116 | { |
117 | if (this != &rAny) |
118 | { |
119 | ::uno_type_any_assign( |
120 | this, rAny.pData, rAny.pType, |
121 | cpp_acquire, cpp_release ); |
122 | } |
123 | return *this; |
124 | } |
125 | |
126 | #if defined LIBO_INTERNAL_ONLY1 |
127 | |
128 | namespace detail { |
129 | |
130 | inline void moveAnyInternals(Any & from, Any & to) noexcept { |
131 | uno_any_construct(&to, nullptr, nullptr, &cpp_acquire); |
132 | std::swap(from.pType, to.pType); |
133 | std::swap(from.pData, to.pData); |
134 | std::swap(from.pReserved, to.pReserved); |
135 | if (to.pData == &from.pReserved) { |
136 | to.pData = &to.pReserved; |
137 | } |
138 | // This leaves from.pData (where "from" is now VOID) dangling to somewhere (cf. |
139 | // CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is |
140 | // only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData -> |
141 | // _assignData takes a null pSource to mean "construct a default value"). |
142 | } |
143 | |
144 | } |
145 | |
146 | Any::Any(Any && other) noexcept { |
147 | detail::moveAnyInternals(other, *this); |
148 | } |
149 | |
150 | Any & Any::operator =(Any && other) noexcept { |
151 | uno_any_destruct(this, &cpp_release); |
152 | detail::moveAnyInternals(other, *this); |
153 | return *this; |
154 | } |
155 | |
156 | #endif |
157 | |
158 | inline ::rtl::OUString Any::getValueTypeName() const |
159 | { |
160 | return ::rtl::OUString( pType->pTypeName ); |
161 | } |
162 | |
163 | inline void Any::setValue( const void * pData_, const Type & rType ) |
164 | { |
165 | ::uno_type_any_assign( |
166 | this, const_cast< void * >( pData_ ), rType.getTypeLibType(), |
167 | cpp_acquire, cpp_release ); |
168 | } |
169 | |
170 | inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) |
171 | { |
172 | ::uno_type_any_assign( |
173 | this, const_cast< void * >( pData_ ), pType_, |
174 | cpp_acquire, cpp_release ); |
175 | } |
176 | |
177 | inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) |
178 | { |
179 | ::uno_any_assign( |
180 | this, const_cast< void * >( pData_ ), pTypeDescr, |
181 | cpp_acquire, cpp_release ); |
182 | } |
183 | |
184 | inline void Any::clear() |
185 | { |
186 | ::uno_any_clear( |
187 | this, cpp_release ); |
188 | } |
189 | |
190 | inline bool Any::isExtractableTo( const Type & rType ) const |
191 | { |
192 | return ::uno_type_isAssignableFromData( |
193 | rType.getTypeLibType(), pData, pType, |
194 | cpp_queryInterface, cpp_release ); |
195 | } |
196 | |
197 | |
198 | template <typename T> |
199 | inline bool Any::has() const |
200 | { |
201 | Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0)); |
202 | return ::uno_type_isAssignableFromData( |
203 | rType.getTypeLibType(), pData, pType, |
204 | cpp_queryInterface, |
205 | cpp_release ); |
206 | } |
207 | |
208 | #if defined LIBO_INTERNAL_ONLY1 |
209 | template<> bool Any::has<Any>() const = delete; |
210 | #endif |
211 | |
212 | inline bool Any::operator == ( const Any & rAny ) const |
213 | { |
214 | return ::uno_type_equalData( |
215 | pData, pType, rAny.pData, rAny.pType, |
216 | cpp_queryInterface, cpp_release ); |
217 | } |
218 | |
219 | inline bool Any::operator != ( const Any & rAny ) const |
220 | { |
221 | return (! ::uno_type_equalData( |
222 | pData, pType, rAny.pData, rAny.pType, |
223 | cpp_queryInterface, cpp_release )); |
224 | } |
225 | |
226 | |
227 | template< class C > |
228 | inline Any SAL_CALL makeAny( const C & value ) |
229 | { |
230 | return Any(value); |
231 | } |
232 | |
233 | #if !defined LIBO_INTERNAL_ONLY1 |
234 | template<> Any makeAny(sal_uInt16 const & value) |
235 | { return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); } |
236 | #endif |
237 | |
238 | template<typename T> Any toAny(T const & value) { return makeAny(value); } |
239 | |
240 | template<> Any toAny(Any const & value) { return value; } |
241 | |
242 | #if defined LIBO_INTERNAL_ONLY1 |
243 | |
244 | template<typename T1, typename T2> |
245 | Any makeAny(rtl::OUStringConcat<T1, T2> && value) |
246 | { return Any(std::move(value)); } |
247 | |
248 | template<typename T1, typename T2> |
249 | Any toAny(rtl::OUStringConcat<T1, T2> && value) |
250 | { return makeAny(std::move(value)); } |
251 | |
252 | template<typename T> |
253 | Any makeAny(rtl::OUStringNumber<T> && value) |
254 | { return Any(OUString(std::move(value))); } |
255 | |
256 | template<typename T> |
257 | Any toAny(rtl::OUStringNumber<T> && value) |
258 | { return makeAny(std::move(value)); } |
259 | |
260 | template<typename T> bool fromAny(Any const & any, T * value) { |
261 | assert(value != nullptr)(static_cast <bool> (value != nullptr) ? void (0) : __assert_fail ("value != nullptr", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx" , 261, __extension__ __PRETTY_FUNCTION__)); |
262 | return any >>= *value; |
263 | } |
264 | |
265 | template<> bool fromAny(Any const & any, Any * value) { |
266 | assert(value != nullptr)(static_cast <bool> (value != nullptr) ? void (0) : __assert_fail ("value != nullptr", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx" , 266, __extension__ __PRETTY_FUNCTION__)); |
267 | *value = any; |
268 | return true; |
269 | } |
270 | |
271 | #endif |
272 | |
273 | template< class C > |
274 | inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) |
275 | { |
276 | const Type & rType = ::cppu::getTypeFavourUnsigned(&value); |
277 | ::uno_type_any_assign( |
278 | &rAny, const_cast< C * >( &value ), rType.getTypeLibType(), |
279 | cpp_acquire, cpp_release ); |
280 | } |
281 | |
282 | // additionally for C++ bool: |
283 | |
284 | template<> |
285 | inline void SAL_CALL operator <<= ( Any & rAny, bool const & value ) |
286 | { |
287 | sal_Bool b = value; |
288 | ::uno_type_any_assign( |
289 | &rAny, &b, cppu::UnoType<bool>::get().getTypeLibType(), |
290 | cpp_acquire, cpp_release ); |
291 | } |
292 | |
293 | |
294 | #ifdef LIBO_INTERNAL_ONLY1 // "RTL_FAST_STRING" |
295 | template< class C1, class C2 > |
296 | inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value ) |
297 | { |
298 | const rtl::OUString str( std::move(value) ); |
299 | const Type & rType = ::cppu::getTypeFavourUnsigned(&str); |
300 | ::uno_type_any_assign( |
301 | &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(), |
302 | cpp_acquire, cpp_release ); |
303 | } |
304 | template<typename T1, typename T2> |
305 | void operator <<=(Any &, rtl::OUStringConcat<T1, T2> const &) = delete; |
306 | template< class C > |
307 | inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value ) |
308 | { |
309 | const rtl::OUString str( std::move(value) ); |
310 | const Type & rType = ::cppu::getTypeFavourUnsigned(&str); |
311 | ::uno_type_any_assign( |
312 | &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(), |
313 | cpp_acquire, cpp_release ); |
314 | } |
315 | template<typename T> |
316 | void operator <<=(Any &, rtl::OUStringNumber<T> const &) = delete; |
317 | #endif |
318 | |
319 | #if defined LIBO_INTERNAL_ONLY1 |
320 | template<> void SAL_CALL operator <<=(Any &, Any const &) = delete; |
321 | #endif |
322 | |
323 | template< class C > |
324 | inline bool SAL_CALL operator >>= ( const Any & rAny, C & value ) |
325 | { |
326 | const Type & rType = ::cppu::getTypeFavourUnsigned(&value); |
327 | return ::uno_type_assignData( |
328 | &value, rType.getTypeLibType(), |
329 | rAny.pData, rAny.pType, |
330 | cpp_queryInterface, |
331 | cpp_acquire, cpp_release ); |
332 | } |
333 | |
334 | // bool |
335 | |
336 | template<> |
337 | inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) |
338 | { |
339 | if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass) |
340 | { |
341 | value = bool(* static_cast< const sal_Bool * >( rAny.pData )); |
342 | return true; |
343 | } |
344 | return false; |
345 | } |
346 | |
347 | template<> |
348 | inline bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) |
349 | { |
350 | return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass && |
351 | bool(value) == bool(* static_cast< const sal_Bool * >( rAny.pData ))); |
352 | } |
353 | |
354 | |
355 | template<> |
356 | inline bool SAL_CALL operator >>= ( Any const & rAny, bool & value ) |
357 | { |
358 | if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN) |
359 | { |
360 | value = *static_cast< sal_Bool const * >( rAny.pData ); |
361 | return true; |
362 | } |
363 | return false; |
364 | } |
365 | |
366 | |
367 | template<> |
368 | inline bool SAL_CALL operator == ( Any const & rAny, bool const & value ) |
369 | { |
370 | return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN && |
371 | (value == |
372 | bool(*static_cast< sal_Bool const * >( rAny.pData )))); |
373 | } |
374 | |
375 | // byte |
376 | |
377 | template<> |
378 | inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) |
379 | { |
380 | if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass) |
381 | { |
382 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
383 | return true; |
384 | } |
385 | return false; |
386 | } |
387 | // short |
388 | |
389 | template<> |
390 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) |
391 | { |
392 | switch (rAny.pType->eTypeClass) |
393 | { |
394 | case typelib_TypeClass_BYTE: |
395 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
396 | return true; |
397 | case typelib_TypeClass_SHORT: |
398 | case typelib_TypeClass_UNSIGNED_SHORT: |
399 | value = * static_cast< const sal_Int16 * >( rAny.pData ); |
400 | return true; |
401 | default: |
402 | return false; |
403 | } |
404 | } |
405 | |
406 | template<> |
407 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) |
408 | { |
409 | switch (rAny.pType->eTypeClass) |
410 | { |
411 | case typelib_TypeClass_BYTE: |
412 | value = static_cast<sal_uInt16>( * static_cast< const sal_Int8 * >( rAny.pData ) ); |
413 | return true; |
414 | case typelib_TypeClass_SHORT: |
415 | case typelib_TypeClass_UNSIGNED_SHORT: |
416 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
417 | return true; |
418 | default: |
419 | return false; |
420 | } |
421 | } |
422 | // long |
423 | |
424 | template<> |
425 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) |
426 | { |
427 | switch (rAny.pType->eTypeClass) |
428 | { |
429 | case typelib_TypeClass_BYTE: |
430 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
431 | return true; |
432 | case typelib_TypeClass_SHORT: |
433 | value = * static_cast< const sal_Int16 * >( rAny.pData ); |
434 | return true; |
435 | case typelib_TypeClass_UNSIGNED_SHORT: |
436 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
437 | return true; |
438 | case typelib_TypeClass_LONG: |
439 | case typelib_TypeClass_UNSIGNED_LONG: |
440 | value = * static_cast< const sal_Int32 * >( rAny.pData ); |
441 | return true; |
442 | default: |
443 | return false; |
444 | } |
445 | } |
446 | |
447 | template<> |
448 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) |
449 | { |
450 | switch (rAny.pType->eTypeClass) |
451 | { |
452 | case typelib_TypeClass_BYTE: |
453 | value = static_cast<sal_uInt32>( * static_cast< const sal_Int8 * >( rAny.pData ) ); |
454 | return true; |
455 | case typelib_TypeClass_SHORT: |
456 | value = static_cast<sal_uInt32>( * static_cast< const sal_Int16 * >( rAny.pData ) ); |
457 | return true; |
458 | case typelib_TypeClass_UNSIGNED_SHORT: |
459 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
460 | return true; |
461 | case typelib_TypeClass_LONG: |
462 | case typelib_TypeClass_UNSIGNED_LONG: |
463 | value = * static_cast< const sal_uInt32 * >( rAny.pData ); |
464 | return true; |
465 | default: |
466 | return false; |
467 | } |
468 | } |
469 | // hyper |
470 | |
471 | template<> |
472 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) |
473 | { |
474 | switch (rAny.pType->eTypeClass) |
475 | { |
476 | case typelib_TypeClass_BYTE: |
477 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
478 | return true; |
479 | case typelib_TypeClass_SHORT: |
480 | value = * static_cast< const sal_Int16 * >( rAny.pData ); |
481 | return true; |
482 | case typelib_TypeClass_UNSIGNED_SHORT: |
483 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
484 | return true; |
485 | case typelib_TypeClass_LONG: |
486 | value = * static_cast< const sal_Int32 * >( rAny.pData ); |
487 | return true; |
488 | case typelib_TypeClass_UNSIGNED_LONG: |
489 | value = * static_cast< const sal_uInt32 * >( rAny.pData ); |
490 | return true; |
491 | case typelib_TypeClass_HYPER: |
492 | case typelib_TypeClass_UNSIGNED_HYPER: |
493 | value = * static_cast< const sal_Int64 * >( rAny.pData ); |
494 | return true; |
495 | default: |
496 | return false; |
497 | } |
498 | } |
499 | |
500 | template<> |
501 | inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) |
502 | { |
503 | switch (rAny.pType->eTypeClass) |
504 | { |
505 | case typelib_TypeClass_BYTE: |
506 | value = static_cast<sal_uInt64>( * static_cast< const sal_Int8 * >( rAny.pData ) ); |
507 | return true; |
508 | case typelib_TypeClass_SHORT: |
509 | value = static_cast<sal_uInt64>( * static_cast< const sal_Int16 * >( rAny.pData ) ); |
510 | return true; |
511 | case typelib_TypeClass_UNSIGNED_SHORT: |
512 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
513 | return true; |
514 | case typelib_TypeClass_LONG: |
515 | value = static_cast<sal_uInt64>( * static_cast< const sal_Int32 * >( rAny.pData ) ); |
516 | return true; |
517 | case typelib_TypeClass_UNSIGNED_LONG: |
518 | value = * static_cast< const sal_uInt32 * >( rAny.pData ); |
519 | return true; |
520 | case typelib_TypeClass_HYPER: |
521 | case typelib_TypeClass_UNSIGNED_HYPER: |
522 | value = * static_cast< const sal_uInt64 * >( rAny.pData ); |
523 | return true; |
524 | default: |
525 | return false; |
526 | } |
527 | } |
528 | // float |
529 | |
530 | template<> |
531 | inline bool SAL_CALL operator >>= ( const Any & rAny, float & value ) |
532 | { |
533 | switch (rAny.pType->eTypeClass) |
534 | { |
535 | case typelib_TypeClass_BYTE: |
536 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
537 | return true; |
538 | case typelib_TypeClass_SHORT: |
539 | value = * static_cast< const sal_Int16 * >( rAny.pData ); |
540 | return true; |
541 | case typelib_TypeClass_UNSIGNED_SHORT: |
542 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
543 | return true; |
544 | case typelib_TypeClass_FLOAT: |
545 | value = * static_cast< const float * >( rAny.pData ); |
546 | return true; |
547 | default: |
548 | return false; |
549 | } |
550 | } |
551 | // double |
552 | |
553 | template<> |
554 | inline bool SAL_CALL operator >>= ( const Any & rAny, double & value ) |
555 | { |
556 | switch (rAny.pType->eTypeClass) |
557 | { |
558 | case typelib_TypeClass_BYTE: |
559 | value = * static_cast< const sal_Int8 * >( rAny.pData ); |
560 | return true; |
561 | case typelib_TypeClass_SHORT: |
562 | value = * static_cast< const sal_Int16 * >( rAny.pData ); |
563 | return true; |
564 | case typelib_TypeClass_UNSIGNED_SHORT: |
565 | value = * static_cast< const sal_uInt16 * >( rAny.pData ); |
566 | return true; |
567 | case typelib_TypeClass_LONG: |
568 | value = * static_cast< const sal_Int32 * >( rAny.pData ); |
569 | return true; |
570 | case typelib_TypeClass_UNSIGNED_LONG: |
571 | value = * static_cast< const sal_uInt32 * >( rAny.pData ); |
572 | return true; |
573 | case typelib_TypeClass_FLOAT: |
574 | value = * static_cast< const float * >( rAny.pData ); |
575 | return true; |
576 | case typelib_TypeClass_DOUBLE: |
577 | value = * static_cast< const double * >( rAny.pData ); |
578 | return true; |
579 | default: |
580 | return false; |
581 | } |
582 | } |
583 | // string |
584 | |
585 | template<> |
586 | inline bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) |
587 | { |
588 | if (typelib_TypeClass_STRING == rAny.pType->eTypeClass) |
589 | { |
590 | value = * static_cast< const ::rtl::OUString * >( rAny.pData ); |
591 | return true; |
592 | } |
593 | return false; |
594 | } |
595 | |
596 | template<> |
597 | inline bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) |
598 | { |
599 | return (typelib_TypeClass_STRING == rAny.pType->eTypeClass && |
600 | value == * static_cast< const ::rtl::OUString * >( rAny.pData ) ); |
601 | } |
602 | // type |
603 | |
604 | template<> |
605 | inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) |
606 | { |
607 | if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass) |
608 | { |
609 | value = * static_cast< const Type * >( rAny.pData ); |
610 | return true; |
611 | } |
612 | return false; |
613 | } |
614 | |
615 | template<> |
616 | inline bool SAL_CALL operator == ( const Any & rAny, const Type & value ) |
617 | { |
618 | return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass && |
619 | value.equals( * static_cast< const Type * >( rAny.pData ) )); |
620 | } |
621 | // any |
622 | |
623 | #if defined LIBO_INTERNAL_ONLY1 |
624 | template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete; |
625 | #else |
626 | template<> |
627 | inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) |
628 | { |
629 | if (&rAny != &value) |
630 | { |
631 | ::uno_type_any_assign( |
632 | &value, rAny.pData, rAny.pType, |
633 | cpp_acquire, cpp_release ); |
634 | } |
635 | return true; |
636 | } |
637 | #endif |
638 | // interface |
639 | |
640 | template<> |
641 | inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) |
642 | { |
643 | if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass) |
644 | { |
645 | return static_cast< const BaseReference * >( rAny.pData )->operator == ( value ); |
646 | } |
647 | return false; |
648 | } |
649 | |
650 | // operator to compare to an any. |
651 | |
652 | template< class C > |
653 | inline bool SAL_CALL operator == ( const Any & rAny, const C & value ) |
654 | { |
655 | const Type & rType = ::cppu::getTypeFavourUnsigned(&value); |
656 | return ::uno_type_equalData( |
657 | rAny.pData, rAny.pType, |
658 | const_cast< C * >( &value ), rType.getTypeLibType(), |
659 | cpp_queryInterface, cpp_release ); |
660 | } |
661 | // operator to compare to an any. may use specialized operators ==. |
662 | |
663 | template< class C > |
664 | inline bool SAL_CALL operator != ( const Any & rAny, const C & value ) |
665 | { |
666 | return (! operator == ( rAny, value )); |
667 | } |
668 | |
669 | template <typename T> |
670 | T Any::get() const |
671 | { |
672 | T value = T(); |
673 | if (! (*this >>= value)) { |
674 | throw RuntimeException( |
675 | ::rtl::OUString( |
676 | cppu_Any_extraction_failure_msg( |
677 | this, |
678 | ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ), |
679 | SAL_NO_ACQUIRE ) ); |
680 | } |
681 | return value; |
682 | } |
683 | |
684 | #if defined LIBO_INTERNAL_ONLY1 |
685 | template<> Any Any::get() const = delete; |
686 | #endif |
687 | |
688 | /** |
689 | Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO |
690 | macros, for example). |
691 | |
692 | @since LibreOffice 4.2 |
693 | */ |
694 | template<typename charT, typename traits> |
695 | inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any const &any) { |
696 | o << "<Any: (" << any.getValueTypeName() << ')'; |
697 | switch(any.pType->eTypeClass) { |
698 | case typelib_TypeClass_VOID: |
699 | break; |
700 | case typelib_TypeClass_BOOLEAN: |
701 | o << ' ' << any.get<bool>(); |
702 | break; |
703 | case typelib_TypeClass_BYTE: |
704 | case typelib_TypeClass_SHORT: |
705 | case typelib_TypeClass_LONG: |
706 | case typelib_TypeClass_HYPER: |
707 | o << ' ' << any.get<sal_Int64>(); |
708 | break; |
709 | case typelib_TypeClass_UNSIGNED_SHORT: |
710 | case typelib_TypeClass_UNSIGNED_LONG: |
711 | case typelib_TypeClass_UNSIGNED_HYPER: |
712 | o << ' ' << any.get<sal_uInt64>(); |
713 | break; |
714 | case typelib_TypeClass_FLOAT: |
715 | case typelib_TypeClass_DOUBLE: |
716 | o << ' ' << any.get<double>(); |
717 | break; |
718 | case typelib_TypeClass_CHAR: { |
719 | std::ios_base::fmtflags flgs = o.setf( |
720 | std::ios_base::hex, std::ios_base::basefield); |
721 | charT fill = o.fill('0'); |
722 | o << " U+" << std::setw(4) |
723 | << unsigned(*static_cast<sal_Unicode const *>(any.getValue())); |
724 | o.setf(flgs); |
725 | o.fill(fill); |
726 | break; |
727 | } |
728 | case typelib_TypeClass_STRING: |
729 | o << ' ' << any.get<rtl::OUString>(); |
730 | break; |
731 | case typelib_TypeClass_TYPE: |
732 | o << ' ' << any.get<css::uno::Type>().getTypeName(); |
733 | break; |
734 | case typelib_TypeClass_SEQUENCE: |
735 | o << " len " |
736 | << ((*static_cast<uno_Sequence * const *>(any.getValue()))-> |
737 | nElements); |
738 | break; |
739 | case typelib_TypeClass_ENUM: |
740 | o << ' ' << *static_cast<sal_Int32 const *>(any.getValue()); |
741 | break; |
742 | case typelib_TypeClass_STRUCT: |
743 | case typelib_TypeClass_EXCEPTION: |
744 | o << ' ' << any.getValue(); |
745 | break; |
746 | case typelib_TypeClass_INTERFACE: |
747 | o << ' ' << *static_cast<void * const *>(any.getValue()); |
748 | break; |
749 | default: |
750 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx" , 750, __extension__ __PRETTY_FUNCTION__)); // this cannot happen |
751 | break; |
752 | } |
753 | o << '>'; |
754 | return o; |
755 | } |
756 | |
757 | } |
758 | } |
759 | } |
760 | } |
761 | |
762 | #endif |
763 | |
764 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |