Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx
Warning:line 1564, column 26
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name unoobj.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 -isystem /usr/include/libxml2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -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 SD_DLLIMPLEMENTATION -D SDUI_DLL_NAME="libsduilo.so" -D SYSTEM_LIBXML -D ENABLE_SDREMOTE -D ENABLE_SDREMOTE_BLUETOOTH -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/external/bluez_bluetooth/inc -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/sd/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/slidesorter/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sd/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -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/sd/source/ui/unoidl/unoobj.cxx

/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx

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#include <sal/config.h>
21
22#include <memory>
23#include <string_view>
24#include <utility>
25
26#include <com/sun/star/style/XStyle.hpp>
27#include <com/sun/star/presentation/ClickAction.hpp>
28#include <com/sun/star/beans/PropertyAttribute.hpp>
29#include <com/sun/star/beans/PropertyState.hpp>
30#include <rtl/ustrbuf.hxx>
31#include <svl/itemprop.hxx>
32#include <svl/style.hxx>
33#include <svx/svdpool.hxx>
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/app.hxx>
36#include <svtools/unoimap.hxx>
37#include <svtools/unoevent.hxx>
38#include <sfx2/bindings.hxx>
39#include <sfx2/event.hxx>
40#include <sfx2/sfxsids.hrc>
41#include <comphelper/extract.hxx>
42#include <cppuhelper/implbase.hxx>
43#include <cppuhelper/supportsservice.hxx>
44#include <svx/unoshape.hxx>
45#include <svx/svdotext.hxx>
46#include <svx/unoapi.hxx>
47#include <svx/svdopath.hxx>
48#include <svx/svdoole2.hxx>
49#include <svx/svdograf.hxx>
50#include <svx/ImageMapInfo.hxx>
51#include <filter/msfilter/msdffimp.hxx>
52#include <svl/instrm.hxx>
53#include <editeng/outlobj.hxx>
54#include <Outliner.hxx>
55#include <comphelper/sequence.hxx>
56#include <svx/svdogrp.hxx>
57#include <o3tl/typed_flags_set.hxx>
58#include <vcl/svapp.hxx>
59#include <tools/debug.hxx>
60
61#include <anminfo.hxx>
62#include "unoobj.hxx"
63#include <unoprnms.hxx>
64#include <unomodel.hxx>
65#include <drawdoc.hxx>
66#include <sdmod.hxx>
67#include <sdpage.hxx>
68#include <ViewShell.hxx>
69#include <unopage.hxx>
70#include <DrawDocShell.hxx>
71#include <EffectMigration.hxx>
72
73using namespace ::sd;
74using namespace ::com::sun::star;
75using namespace ::com::sun::star::presentation;
76using namespace ::com::sun::star::animations;
77
78using ::com::sun::star::uno::Any;
79using ::com::sun::star::drawing::XShape;
80
81#define WID_EFFECT1 1
82#define WID_SPEED2 2
83#define WID_TEXTEFFECT3 3
84#define WID_BOOKMARK4 4
85#define WID_CLICKACTION5 5
86#define WID_PLAYFULL6 6
87#define WID_SOUNDFILE7 7
88#define WID_SOUNDON8 8
89#define WID_BLUESCREEN9 9
90#define WID_VERB10 10
91#define WID_DIMCOLOR11 11
92#define WID_DIMHIDE12 12
93#define WID_DIMPREV13 13
94#define WID_PRESORDER14 14
95#define WID_STYLE15 15
96#define WID_ANIMPATH16 16
97#define WID_IMAGEMAP17 17
98#define WID_ISANIMATION18 18
99#define WID_THAT_NEED_ANIMINFO19 19
100
101#define WID_ISEMPTYPRESOBJ20 20
102#define WID_ISPRESOBJ21 21
103#define WID_MASTERDEPEND22 22
104
105#define WID_NAVORDER23 23
106#define WID_PLACEHOLDERTEXT24 24
107#define WID_LEGACYFRAGMENT25 25
108
109#define IMPRESS_MAP_ENTRIES{ u"" "LegacyFragment",25, cppu::UnoType<drawing::XShape>
::get(), 0, 0}, { u"" "AnimationPath", 16, cppu::UnoType<drawing
::XShape>::get(), 0, 0}, { u"" "Bookmark", 4, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "DimColor", 11, cppu::UnoType
<sal_Int32>::get(), 0, 0}, { u"" "DimHide", 12, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "DimPrevious", 13, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Effect", 1, cppu::UnoType<
presentation::AnimationEffect>::get(), 0, 0}, { u"" "IsEmptyPresentationObject"
,20, cppu::UnoType<bool>::get(), 0, 0}, { u"" "IsPresentationObject"
, 21, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute
::READONLY, 0}, { u"" "IsPlaceholderDependent",22, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "OnClick", 5, cppu::UnoType
<presentation::ClickAction>::get(), 0, 0}, { u"" "PlayFull"
, 6, cppu::UnoType<bool>::get(), 0, 0}, { u"" "PresentationOrder"
, 14, cppu::UnoType<sal_Int32>::get(), 0, 0}, { u"" "Style"
, 15, cppu::UnoType<style::XStyle>::get(), css::beans::
PropertyAttribute::MAYBEVOID, 0}, { u"" "Sound", 7, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "SoundOn", 8, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Speed", 2, cppu::UnoType<
presentation::AnimationSpeed>::get(), 0, 0}, { u"" "TextEffect"
, 3, cppu::UnoType<presentation::AnimationEffect>::get(
), 0, 0}, { u"" "TransparentColor", 9, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"" "Verb", 10, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"IsAnimation", 18, cppu::UnoType<bool
>::get(), 0, 0}, { u"NavigationOrder", 23, cppu::UnoType<
sal_Int32>::get(), 0, 0}, { u"PlaceholderText", 24, cppu::
UnoType<OUString>::get(), 0, 0}, { u"", 0, css::uno::Type
(), 0, 0 }
\
110 { u"" UNO_NAME_OBJ_LEGACYFRAGMENT"LegacyFragment",WID_LEGACYFRAGMENT25, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
111 { u"" UNO_NAME_OBJ_ANIMATIONPATH"AnimationPath", WID_ANIMPATH16, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
112 { u"" UNO_NAME_OBJ_BOOKMARK"Bookmark", WID_BOOKMARK4, cppu::UnoType<OUString>::get(), 0, 0},\
113 { u"" UNO_NAME_OBJ_DIMCOLOR"DimColor", WID_DIMCOLOR11, cppu::UnoType<sal_Int32>::get(), 0, 0},\
114 { u"" UNO_NAME_OBJ_DIMHIDE"DimHide", WID_DIMHIDE12, cppu::UnoType<bool>::get(), 0, 0},\
115 { u"" UNO_NAME_OBJ_DIMPREV"DimPrevious", WID_DIMPREV13, cppu::UnoType<bool>::get(), 0, 0},\
116 { u"" UNO_NAME_OBJ_EFFECT"Effect", WID_EFFECT1, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
117 { u"" UNO_NAME_OBJ_ISEMPTYPRESOBJ"IsEmptyPresentationObject",WID_ISEMPTYPRESOBJ20, cppu::UnoType<bool>::get(), 0, 0},\
118 { u"" UNO_NAME_OBJ_ISPRESOBJ"IsPresentationObject", WID_ISPRESOBJ21, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},\
119 { u"" UNO_NAME_OBJ_MASTERDEPENDENT"IsPlaceholderDependent",WID_MASTERDEPEND22, cppu::UnoType<bool>::get(), 0, 0},\
120 { u"" UNO_NAME_OBJ_CLICKACTION"OnClick", WID_CLICKACTION5, cppu::UnoType<presentation::ClickAction>::get(), 0, 0},\
121 { u"" UNO_NAME_OBJ_PLAYFULL"PlayFull", WID_PLAYFULL6, cppu::UnoType<bool>::get(), 0, 0},\
122 { u"" UNO_NAME_OBJ_PRESORDER"PresentationOrder", WID_PRESORDER14, cppu::UnoType<sal_Int32>::get(), 0, 0},\
123 { u"" UNO_NAME_OBJ_STYLE"Style", WID_STYLE15, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
124 { u"" UNO_NAME_OBJ_SOUNDFILE"Sound", WID_SOUNDFILE7, cppu::UnoType<OUString>::get(), 0, 0},\
125 { u"" UNO_NAME_OBJ_SOUNDON"SoundOn", WID_SOUNDON8, cppu::UnoType<bool>::get(), 0, 0},\
126 { u"" UNO_NAME_OBJ_SPEED"Speed", WID_SPEED2, cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},\
127 { u"" UNO_NAME_OBJ_TEXTEFFECT"TextEffect", WID_TEXTEFFECT3, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
128 { u"" UNO_NAME_OBJ_BLUESCREEN"TransparentColor", WID_BLUESCREEN9, cppu::UnoType<sal_Int32>::get(), 0, 0},\
129 { u"" UNO_NAME_OBJ_VERB"Verb", WID_VERB10, cppu::UnoType<sal_Int32>::get(), 0, 0},\
130 { u"IsAnimation", WID_ISANIMATION18, cppu::UnoType<bool>::get(), 0, 0},\
131 { u"NavigationOrder", WID_NAVORDER23, cppu::UnoType<sal_Int32>::get(), 0, 0},\
132 { u"PlaceholderText", WID_PLACEHOLDERTEXT24, cppu::UnoType<OUString>::get(), 0, 0},\
133 { u"", 0, css::uno::Type(), 0, 0 }
134
135 static const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
136 {
137
138 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl[] =
139 {
140 { u"ImageMap", WID_IMAGEMAP17, cppu::UnoType<container::XIndexContainer>::get(), 0, 0 },
141 IMPRESS_MAP_ENTRIES{ u"" "LegacyFragment",25, cppu::UnoType<drawing::XShape>
::get(), 0, 0}, { u"" "AnimationPath", 16, cppu::UnoType<drawing
::XShape>::get(), 0, 0}, { u"" "Bookmark", 4, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "DimColor", 11, cppu::UnoType
<sal_Int32>::get(), 0, 0}, { u"" "DimHide", 12, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "DimPrevious", 13, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Effect", 1, cppu::UnoType<
presentation::AnimationEffect>::get(), 0, 0}, { u"" "IsEmptyPresentationObject"
,20, cppu::UnoType<bool>::get(), 0, 0}, { u"" "IsPresentationObject"
, 21, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute
::READONLY, 0}, { u"" "IsPlaceholderDependent",22, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "OnClick", 5, cppu::UnoType
<presentation::ClickAction>::get(), 0, 0}, { u"" "PlayFull"
, 6, cppu::UnoType<bool>::get(), 0, 0}, { u"" "PresentationOrder"
, 14, cppu::UnoType<sal_Int32>::get(), 0, 0}, { u"" "Style"
, 15, cppu::UnoType<style::XStyle>::get(), css::beans::
PropertyAttribute::MAYBEVOID, 0}, { u"" "Sound", 7, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "SoundOn", 8, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Speed", 2, cppu::UnoType<
presentation::AnimationSpeed>::get(), 0, 0}, { u"" "TextEffect"
, 3, cppu::UnoType<presentation::AnimationEffect>::get(
), 0, 0}, { u"" "TransparentColor", 9, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"" "Verb", 10, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"IsAnimation", 18, cppu::UnoType<bool
>::get(), 0, 0}, { u"NavigationOrder", 23, cppu::UnoType<
sal_Int32>::get(), 0, 0}, { u"PlaceholderText", 24, cppu::
UnoType<OUString>::get(), 0, 0}, { u"", 0, css::uno::Type
(), 0, 0 }
142 };
143 return aImpress_SdXShapePropertyGraphicMap_Impl;
144 }
145
146 static const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
147 {
148
149 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl[] =
150 {
151 IMPRESS_MAP_ENTRIES{ u"" "LegacyFragment",25, cppu::UnoType<drawing::XShape>
::get(), 0, 0}, { u"" "AnimationPath", 16, cppu::UnoType<drawing
::XShape>::get(), 0, 0}, { u"" "Bookmark", 4, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "DimColor", 11, cppu::UnoType
<sal_Int32>::get(), 0, 0}, { u"" "DimHide", 12, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "DimPrevious", 13, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Effect", 1, cppu::UnoType<
presentation::AnimationEffect>::get(), 0, 0}, { u"" "IsEmptyPresentationObject"
,20, cppu::UnoType<bool>::get(), 0, 0}, { u"" "IsPresentationObject"
, 21, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute
::READONLY, 0}, { u"" "IsPlaceholderDependent",22, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "OnClick", 5, cppu::UnoType
<presentation::ClickAction>::get(), 0, 0}, { u"" "PlayFull"
, 6, cppu::UnoType<bool>::get(), 0, 0}, { u"" "PresentationOrder"
, 14, cppu::UnoType<sal_Int32>::get(), 0, 0}, { u"" "Style"
, 15, cppu::UnoType<style::XStyle>::get(), css::beans::
PropertyAttribute::MAYBEVOID, 0}, { u"" "Sound", 7, cppu::UnoType
<OUString>::get(), 0, 0}, { u"" "SoundOn", 8, cppu::UnoType
<bool>::get(), 0, 0}, { u"" "Speed", 2, cppu::UnoType<
presentation::AnimationSpeed>::get(), 0, 0}, { u"" "TextEffect"
, 3, cppu::UnoType<presentation::AnimationEffect>::get(
), 0, 0}, { u"" "TransparentColor", 9, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"" "Verb", 10, cppu::UnoType<sal_Int32
>::get(), 0, 0}, { u"IsAnimation", 18, cppu::UnoType<bool
>::get(), 0, 0}, { u"NavigationOrder", 23, cppu::UnoType<
sal_Int32>::get(), 0, 0}, { u"PlaceholderText", 24, cppu::
UnoType<OUString>::get(), 0, 0}, { u"", 0, css::uno::Type
(), 0, 0 }
152 };
153 return aImpress_SdXShapePropertySimpleMap_Impl;
154 }
155
156 #define DRAW_MAP_ENTRIES{ u"" "Bookmark", 4, cppu::UnoType<OUString>::get(), 0,
0}, { u"" "OnClick", 5, cppu::UnoType<presentation::ClickAction
>::get(),0, 0}, { u"" "Style", 15, cppu::UnoType<style::
XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0
}, { u"NavigationOrder", 23, cppu::UnoType<sal_Int32>::
get(), 0, 0}, { u"", 0, css::uno::Type(), 0, 0 }
\
157 { u"" UNO_NAME_OBJ_BOOKMARK"Bookmark", WID_BOOKMARK4, cppu::UnoType<OUString>::get(), 0, 0},\
158 { u"" UNO_NAME_OBJ_CLICKACTION"OnClick", WID_CLICKACTION5, cppu::UnoType<presentation::ClickAction>::get(),0, 0},\
159 { u"" UNO_NAME_OBJ_STYLE"Style", WID_STYLE15, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
160 { u"NavigationOrder", WID_NAVORDER23, cppu::UnoType<sal_Int32>::get(), 0, 0},\
161 { u"", 0, css::uno::Type(), 0, 0 }
162
163 static const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
164 {
165 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl[] =
166 {
167 DRAW_MAP_ENTRIES{ u"" "Bookmark", 4, cppu::UnoType<OUString>::get(), 0,
0}, { u"" "OnClick", 5, cppu::UnoType<presentation::ClickAction
>::get(),0, 0}, { u"" "Style", 15, cppu::UnoType<style::
XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0
}, { u"NavigationOrder", 23, cppu::UnoType<sal_Int32>::
get(), 0, 0}, { u"", 0, css::uno::Type(), 0, 0 }
168 };
169 return aDraw_SdXShapePropertyMap_Impl;
170 }
171 static const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
172 {
173 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl[] =
174 {
175 { u"ImageMap", WID_IMAGEMAP17, cppu::UnoType<container::XIndexContainer>::get(), 0, 0 },
176 DRAW_MAP_ENTRIES{ u"" "Bookmark", 4, cppu::UnoType<OUString>::get(), 0,
0}, { u"" "OnClick", 5, cppu::UnoType<presentation::ClickAction
>::get(),0, 0}, { u"" "Style", 15, cppu::UnoType<style::
XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0
}, { u"NavigationOrder", 23, cppu::UnoType<sal_Int32>::
get(), 0, 0}, { u"", 0, css::uno::Type(), 0, 0 }
177 };
178 return aDraw_SdXShapePropertyGraphicMap_Impl;
179 }
180 static const SfxItemPropertyMapEntry* lcl_ImplGetShapePropertyMap( bool bImpress, bool bGraphicObj )
181 {
182 const SfxItemPropertyMapEntry* pRet = nullptr;
183 if( bImpress )
184 {
185 if( bGraphicObj )
186 pRet = lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
187 else
188 pRet = lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
189 }
190 else
191 {
192 if( bGraphicObj )
193 pRet = lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
194 else
195 pRet = lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
196 }
197 return pRet;
198
199 }
200 static const SvxItemPropertySet* lcl_ImplGetShapePropertySet( bool bImpress, bool bGraphicObj )
201 {
202 const SvxItemPropertySet* pRet = nullptr;
203 if( bImpress )
204 {
205 if( bGraphicObj )
206 {
207 static SvxItemPropertySet aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
208 pRet = &aImpress_SdXShapePropertyGraphicSet_Impl;
209 }
210 else
211 {
212 static SvxItemPropertySet aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
213 pRet = &aImpress_SdXShapePropertySet_Impl;
214 }
215 }
216 else
217 {
218 if( bGraphicObj )
219 {
220 static SvxItemPropertySet aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
221 pRet = &aDraw_SdXShapePropertyGraphicSet_Impl;
222 }
223 else
224 {
225 static SvxItemPropertySet aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
226 pRet = &aDraw_SdXShapePropertySet_Impl;
227 }
228 }
229 return pRet;
230 }
231 static const SfxItemPropertyMapEntry* lcl_GetEmpty_SdXShapePropertyMap_Impl()
232 {
233 static const SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl[] =
234 {
235 { u"", 0, css::uno::Type(), 0, 0 }
236 };
237 return aEmpty_SdXShapePropertyMap_Impl;
238 }
239
240 static const SvxItemPropertySet* lcl_GetEmpty_SdXShapePropertySet_Impl()
241 {
242 static SvxItemPropertySet aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool() );
243 return &aEmptyPropSet;
244 }
245const SvEventDescription* ImplGetSupportedMacroItems()
246{
247 static const SvEventDescription aMacroDescriptionsImpl[] =
248 {
249 { SvMacroItemId::OnMouseOver, "OnMouseOver" },
250 { SvMacroItemId::OnMouseOut, "OnMouseOut" },
251 { SvMacroItemId::NONE, nullptr }
252 };
253
254 return aMacroDescriptionsImpl;
255}
256
257SdXShape::SdXShape(SvxShape* pShape, SdXImpressDocument* pModel)
258: mpShape( pShape ),
259 mpPropSet( pModel?
260 lcl_ImplGetShapePropertySet(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
261 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
262 mpMap( pModel?
263 lcl_ImplGetShapePropertyMap(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
264 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
265 mpModel(pModel)
266{
267
268 pShape->setMaster( this );
269}
270
271SdXShape::~SdXShape() throw()
272{
273}
274
275void SdXShape::dispose()
276{
277 mpShape->setMaster( nullptr );
278 delete this;
279}
280
281uno::Any SAL_CALL SdXShape::queryInterface( const uno::Type & rType )
282{
283 return mpShape->queryInterface( rType );
284}
285
286void SAL_CALL SdXShape::acquire() throw()
287{
288 mpShape->acquire();
289}
290
291void SAL_CALL SdXShape::release() throw()
292{
293 mpShape->release();
294}
295
296bool SdXShape::queryAggregation( const css::uno::Type & rType, css::uno::Any& aAny )
297{
298 if( mpModel && mpModel ->IsImpressDocument() )
299 {
300 if( rType == cppu::UnoType<document::XEventsSupplier>::get())
301 {
302 aAny <<= uno::Reference< document::XEventsSupplier >(this);
303 return true;
304 }
305 }
306
307 return false;
308}
309
310uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes()
311{
312 if( mpModel && !mpModel->IsImpressDocument() )
313 {
314 return mpShape->_getTypes();
315 }
316 else
317 {
318 sal_uInt32 nObjId = mpShape->getShapeKind();
319 uno::Sequence< uno::Type > aTypes;
320 SdTypesCache& gImplTypesCache = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->gImplTypesCache;
321 SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) );
322 if( aIter == gImplTypesCache.end() )
323 {
324 aTypes = mpShape->_getTypes();
325 sal_uInt32 nCount = aTypes.getLength();
326 aTypes.realloc( nCount+1 );
327 aTypes[nCount] = cppu::UnoType<lang::XTypeProvider>::get();
328
329 gImplTypesCache.insert(std::make_pair(nObjId, aTypes));
330 }
331 else
332 {
333 // use the already computed implementation id
334 aTypes = (*aIter).second;
335 }
336 return aTypes;
337 }
338}
339
340// XPropertyState
341beans::PropertyState SAL_CALL SdXShape::getPropertyState( const OUString& PropertyName )
342{
343 SolarMutexGuard aGuard;
344
345 if( mpPropSet->getPropertyMapEntry(PropertyName) )
346 {
347 return beans::PropertyState_DIRECT_VALUE;
348 }
349 else
350 {
351 SdrObject* pObj = mpShape->GetSdrObject();
352 if( pObj == nullptr || ( pObj->getSdrPageFromSdrObject()->IsMasterPage() && pObj->IsEmptyPresObj() ) )
353 return beans::PropertyState_DEFAULT_VALUE;
354
355 return mpShape->_getPropertyState( PropertyName );
356 }
357}
358
359void SAL_CALL SdXShape::setPropertyToDefault( const OUString& PropertyName )
360{
361 SolarMutexGuard aGuard;
362
363 if( mpPropSet->getPropertyMapEntry(PropertyName) )
364 {
365 return;
366 }
367 else
368 {
369 mpShape->_setPropertyToDefault(PropertyName);
370 }
371}
372
373uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName )
374{
375 SolarMutexGuard aGuard;
376
377 if( mpPropSet->getPropertyMapEntry(aPropertyName) )
378 {
379 return getPropertyValue( aPropertyName );
380 }
381 else
382 {
383 uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) );
384 return aRet;
385 }
386}
387
388//XPropertySet
389css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo()
390{
391 SfxItemPropertyMapEntry const * nObjId = mpShape->getPropertyMapEntries();
392 css::uno::Reference<css::beans::XPropertySetInfo> pInfo;
393
394 SdExtPropertySetInfoCache& rCache = (mpModel && mpModel->IsImpressDocument()) ?
395 SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->gImplImpressPropertySetInfoCache : SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->gImplDrawPropertySetInfoCache;
396
397 SdExtPropertySetInfoCache::iterator aIter( rCache.find( nObjId ) );
398 if( aIter == rCache.end() )
399 {
400 uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() );
401 pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() );
402
403 rCache.insert(std::make_pair(nObjId, pInfo));
404 }
405 else
406 {
407 // use the already computed implementation id
408 pInfo = (*aIter).second;
409 }
410
411 return pInfo;
412}
413
414void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue )
415{
416 SolarMutexGuard aGuard;
417
418 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
419
420 if( pEntry )
421 {
422 SdrObject* pObj = mpShape->GetSdrObject();
423 if( pObj )
424 {
425 SdAnimationInfo* pInfo = GetAnimationInfo(pEntry->nWID <= WID_THAT_NEED_ANIMINFO19);
426
427 switch(pEntry->nWID)
428 {
429 case WID_NAVORDER23:
430 {
431 sal_Int32 nNavOrder = 0;
432 if(!(aValue >>= nNavOrder))
433 throw lang::IllegalArgumentException();
434
435 SdrObjList* pObjList = pObj->getParentSdrObjListFromSdrObject();
436 if( pObjList )
437 pObjList->SetObjectNavigationPosition( *pObj, (nNavOrder < 0) ? SAL_MAX_UINT32((sal_uInt32) 0xFFFFFFFF) : static_cast< sal_uInt32 >( nNavOrder ) );
438 break;
439 }
440
441 case WID_EFFECT1:
442 {
443 AnimationEffect eEffect;
444 if(!(aValue >>= eEffect))
445 throw lang::IllegalArgumentException();
446
447 EffectMigration::SetAnimationEffect( mpShape, eEffect );
448 break;
449 }
450 case WID_TEXTEFFECT3:
451 {
452 AnimationEffect eEffect;
453 if(!(aValue >>= eEffect))
454 throw lang::IllegalArgumentException();
455
456 EffectMigration::SetTextAnimationEffect( mpShape, eEffect );
457 break;
458 }
459 case WID_SPEED2:
460 {
461 AnimationSpeed eSpeed;
462 if(!(aValue>>=eSpeed))
463 throw lang::IllegalArgumentException();
464
465 EffectMigration::SetAnimationSpeed( mpShape, eSpeed );
466 break;
467 }
468 case WID_ISANIMATION18:
469 {
470 bool bIsAnimation(false);
471
472 if(!(aValue >>= bIsAnimation))
473 {
474 throw lang::IllegalArgumentException();
475 }
476
477 if(bIsAnimation)
478 {
479 SdrObjGroup* pGroup = dynamic_cast< SdrObjGroup* >(pObj);
480 SdPage* pPage = pGroup ? dynamic_cast< SdPage* >(pGroup->getSdrPageFromSdrObject()) : nullptr;
481
482 if (pPage)
483 {
484 // #i42894# Animated Group object, migrate that effect
485 EffectMigration::CreateAnimatedGroup(*pGroup, *pPage);
486
487 // #i42894# unfortunately when doing this all group members have to
488 // be moved to the page as direct members, else the currently
489 // available forms of animation do not work. If it succeeds,
490 // the group is empty and can be removed and deleted
491 if(!pGroup->GetSubList()->GetObjCount())
492 {
493 pPage->NbcRemoveObject(pGroup->GetOrdNum());
494
495 // always use SdrObject::Free(...) for SdrObjects (!)
496 SdrObject* pTemp(pGroup);
497 SdrObject::Free(pTemp);
498 }
499 }
500 }
501 //pInfo->mbIsMovie = bIsAnimation;
502 break;
503 }
504 case WID_BOOKMARK4:
505 {
506 OUString aString;
507 if(!(aValue >>= aString))
508 throw lang::IllegalArgumentException();
509
510 pInfo->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString ) );
511 break;
512 }
513 case WID_CLICKACTION5:
514 ::cppu::any2enum< presentation::ClickAction >( pInfo->meClickAction, aValue);
515 break;
516
517// TODO: WID_PLAYFULL:
518 case WID_SOUNDFILE7:
519 {
520 OUString aString;
521 if(!(aValue >>= aString))
522 throw lang::IllegalArgumentException();
523 pInfo->maSoundFile = aString;
524 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
525 break;
526 }
527
528 case WID_SOUNDON8:
529 {
530 if( !(aValue >>= pInfo->mbSoundOn) )
531 throw lang::IllegalArgumentException();
532 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
533 break;
534 }
535 case WID_VERB10:
536 {
537 sal_Int32 nVerb = 0;
538 if(!(aValue >>= nVerb))
539 throw lang::IllegalArgumentException();
540
541 pInfo->mnVerb = static_cast<sal_uInt16>(nVerb);
542 break;
543 }
544 case WID_DIMCOLOR11:
545 {
546 sal_Int32 nColor = 0;
547
548 if( !(aValue >>= nColor) )
549 throw lang::IllegalArgumentException();
550
551 EffectMigration::SetDimColor( mpShape, nColor );
552 break;
553 }
554 case WID_DIMHIDE12:
555 {
556 bool bDimHide = false;
557 if( !(aValue >>= bDimHide) )
558 throw lang::IllegalArgumentException();
559
560 EffectMigration::SetDimHide( mpShape, bDimHide );
561 break;
562 }
563 case WID_DIMPREV13:
564 {
565 bool bDimPrevious = false;
566 if( !(aValue >>= bDimPrevious) )
567 throw lang::IllegalArgumentException();
568
569 EffectMigration::SetDimPrevious( mpShape, bDimPrevious );
570 break;
571 }
572 case WID_PRESORDER14:
573 {
574 sal_Int32 nNewPos = 0;
575 if( !(aValue >>= nNewPos) )
576 throw lang::IllegalArgumentException();
577
578 EffectMigration::SetPresentationOrder( mpShape, nNewPos );
579 break;
580 }
581 case WID_STYLE15:
582 SetStyleSheet( aValue );
583 break;
584 case WID_ISEMPTYPRESOBJ20:
585 SetEmptyPresObj( ::cppu::any2bool(aValue) );
586 break;
587 case WID_MASTERDEPEND22:
588 SetMasterDepend( ::cppu::any2bool(aValue) );
589 break;
590
591 case WID_LEGACYFRAGMENT25:
592 {
593 uno::Reference< io::XInputStream > xInputStream;
594 aValue >>= xInputStream;
595 if( xInputStream.is() )
596 {
597 SvInputStream aStream( xInputStream );
598 SdrObject* pObject = mpShape->GetSdrObject();
599 SvxMSDffManager::ReadObjText( aStream, pObject );
600 }
601 }
602 break;
603
604 case WID_ANIMPATH16:
605 {
606 uno::Reference< drawing::XShape > xShape( aValue, uno::UNO_QUERY );
607 SdrPathObj* pObj2 = xShape.is() ? dynamic_cast< SdrPathObj* >( GetSdrObjectFromXShape( xShape ) ) : nullptr;
608
609 if( pObj2 == nullptr )
610 throw lang::IllegalArgumentException();
611
612 EffectMigration::SetAnimationPath( mpShape, pObj2 );
613 break;
614 }
615 case WID_IMAGEMAP17:
616 {
617 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
618 if( pDoc )
619 {
620 ImageMap aImageMap;
621 uno::Reference< uno::XInterface > xImageMap;
622 aValue >>= xImageMap;
623
624 if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
625 throw lang::IllegalArgumentException();
626
627 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(pObj);
628 if( pIMapInfo )
629 {
630 // replace existing image map
631 pIMapInfo->SetImageMap( aImageMap );
632 }
633 else
634 {
635 // insert new user data with image map
636 pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(aImageMap) ));
637 }
638 }
639 }
640 break;
641 }
642 }
643 }
644 else
645 {
646 mpShape->_setPropertyValue(aPropertyName, aValue);
647 }
648
649 if( mpModel )
650 mpModel->SetModified();
651}
652
653css::uno::Any SAL_CALL SdXShape::getPropertyValue( const OUString& PropertyName )
654{
655 SolarMutexGuard aGuard;
656
657 uno::Any aRet;
658
659 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
660
661 if( pEntry && mpShape->GetSdrObject() )
662 {
663 SdAnimationInfo* pInfo = GetAnimationInfo();
664
665 switch(pEntry->nWID)
666 {
667 case WID_NAVORDER23:
668 {
669 const sal_uInt32 nNavOrder = mpShape->GetSdrObject()->GetNavigationPosition();
670 aRet <<= nNavOrder == SAL_MAX_UINT32((sal_uInt32) 0xFFFFFFFF) ? static_cast<sal_Int32>(-1) : static_cast< sal_Int32 >(nNavOrder);
671 }
672 break;
673 case WID_EFFECT1:
674 aRet <<= EffectMigration::GetAnimationEffect( mpShape );
675 break;
676 case WID_TEXTEFFECT3:
677 aRet <<= EffectMigration::GetTextAnimationEffect( mpShape );
678 break;
679 case WID_ISPRESOBJ21:
680 aRet <<= IsPresObj();
681 break;
682 case WID_ISEMPTYPRESOBJ20:
683 aRet <<= IsEmptyPresObj();
684 break;
685 case WID_MASTERDEPEND22:
686 aRet <<= IsMasterDepend();
687 break;
688 case WID_SPEED2:
689 aRet <<= EffectMigration::GetAnimationSpeed( mpShape );
690 break;
691 case WID_ISANIMATION18:
692 aRet <<= (pInfo && pInfo->mbIsMovie);
693 break;
694 case WID_PLACEHOLDERTEXT24:
695 aRet <<= GetPlaceholderText();
696 break;
697 case WID_BOOKMARK4:
698 {
699 OUString aString;
700 SdDrawDocument* pDoc = mpModel ? mpModel->GetDoc() : nullptr;
701 if (pInfo && pDoc)
702 {
703 // is the bookmark a page?
704 bool bIsMasterPage;
705 if(pDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage ) != SDRPAGE_NOTFOUND0xFFFF)
706 {
707 aString = SdDrawPage::getPageApiNameFromUiName( pInfo->GetBookmark() );
708 }
709 else
710 {
711 aString = pInfo->GetBookmark() ;
712 sal_Int32 nPos = aString.lastIndexOf( '#' );
713 if( nPos >= 0 )
714 {
715 OUString aURL( aString.copy( 0, nPos+1 ) );
716 OUString aName( aString.copy( nPos+1 ) );
717 if(pDoc->GetPageByName( aName, bIsMasterPage ) != SDRPAGE_NOTFOUND0xFFFF)
718 {
719 aURL += SdDrawPage::getPageApiNameFromUiName( aName );
720 aString = aURL;
721 }
722 }
723 }
724 }
725
726 aRet <<= aString;
727 break;
728 }
729 case WID_CLICKACTION5:
730 aRet <<= ( pInfo?pInfo->meClickAction:presentation::ClickAction_NONE );
731 break;
732 case WID_PLAYFULL6:
733 aRet <<= ( pInfo && pInfo->mbPlayFull );
734 break;
735 case WID_SOUNDFILE7:
736 aRet <<= EffectMigration::GetSoundFile( mpShape );
737 break;
738 case WID_SOUNDON8:
739 aRet <<= EffectMigration::GetSoundOn( mpShape );
740 break;
741 case WID_BLUESCREEN9:
742 aRet <<= pInfo ? pInfo->maBlueScreen : Color(0x00ffffff);
743 break;
744 case WID_VERB10:
745 aRet <<= static_cast<sal_Int32>( pInfo?pInfo->mnVerb:0 );
746 break;
747 case WID_DIMCOLOR11:
748 aRet <<= EffectMigration::GetDimColor( mpShape );
749 break;
750 case WID_DIMHIDE12:
751 aRet <<= EffectMigration::GetDimHide( mpShape );
752 break;
753 case WID_DIMPREV13:
754 aRet <<= EffectMigration::GetDimPrevious( mpShape );
755 break;
756 case WID_PRESORDER14:
757 aRet <<= EffectMigration::GetPresentationOrder( mpShape );
758 break;
759 case WID_STYLE15:
760 aRet = GetStyleSheet();
761 break;
762 case WID_IMAGEMAP17:
763 {
764 uno::Reference< uno::XInterface > xImageMap;
765
766 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
767 if( pDoc )
768 {
769
770 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(mpShape->GetSdrObject());
771 if( pIMapInfo )
772 {
773 const ImageMap& rIMap = pIMapInfo->GetImageMap();
774 xImageMap = SvUnoImageMap_createInstance( rIMap, ImplGetSupportedMacroItems() );
775 }
776 else
777 {
778 xImageMap = SvUnoImageMap_createInstance();
779 }
780 }
781
782 aRet <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
783 break;
784 }
785 }
786 }
787 else
788 {
789 aRet = mpShape->_getPropertyValue(PropertyName);
790 }
791
792 return aRet;
793}
794
795/** */
796SdAnimationInfo* SdXShape::GetAnimationInfo( bool bCreate ) const
797{
798 SdAnimationInfo* pInfo = nullptr;
799
800 SdrObject* pObj = mpShape->GetSdrObject();
4
Calling 'SvxShape::GetSdrObject'
12
Returning from 'SvxShape::GetSdrObject'
801 if(pObj
12.1
'pObj' is non-null
12.1
'pObj' is non-null
12.1
'pObj' is non-null
12.1
'pObj' is non-null
)
13
Taking true branch
802 pInfo = SdDrawDocument::GetShapeUserData(*pObj, bCreate);
14
Value assigned to 'pInfo'
803
804 return pInfo;
15
Returning pointer (loaded from 'pInfo')
805}
806
807uno::Sequence< OUString > SAL_CALL SdXShape::getSupportedServiceNames()
808{
809 std::vector<std::u16string_view> aAdd{ u"com.sun.star.presentation.Shape",
810 u"com.sun.star.document.LinkTarget" };
811
812 SdrObject* pObj = mpShape->GetSdrObject();
813 if(pObj && pObj->GetObjInventor() == SdrInventor::Default )
814 {
815 sal_uInt32 nInventor = pObj->GetObjIdentifier();
816 switch( nInventor )
817 {
818 case OBJ_TITLETEXT:
819 aAdd.emplace_back(u"com.sun.star.presentation.TitleTextShape");
820 break;
821 case OBJ_OUTLINETEXT:
822 aAdd.emplace_back(u"com.sun.star.presentation.OutlinerShape");
823 break;
824 }
825 }
826 return comphelper::concatSequences(mpShape->_getSupportedServiceNames(), aAdd);
827}
828
829/** checks if this is a presentation object
830 */
831bool SdXShape::IsPresObj() const
832{
833 SdrObject* pObj = mpShape->GetSdrObject();
834 if(pObj)
835 {
836 SdPage* pPage = dynamic_cast<SdPage* >(pObj->getSdrPageFromSdrObject());
837 if(pPage)
838 return pPage->GetPresObjKind(pObj) != PresObjKind::NONE;
839 }
840 return false;
841}
842
843/** checks if this presentation object is empty
844 */
845bool SdXShape::IsEmptyPresObj() const
846{
847 SdrObject* pObj = mpShape->GetSdrObject();
848 if( (pObj != nullptr) && pObj->IsEmptyPresObj() )
849 {
850 // check if the object is in edit, then if it's temporarily not empty
851 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
852 if( pTextObj == nullptr )
853 return true;
854
855 return !pTextObj->CanCreateEditOutlinerParaObject();
856 }
857
858 return false;
859}
860
861OUString SdXShape::GetPlaceholderText() const
862{
863 // only possible if this actually *is* a presentation object
864 if( !IsPresObj() )
865 return OUString();
866
867 SdrObject* pObj = mpShape->GetSdrObject();
868 if( pObj == nullptr )
869 return OUString();
870
871 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
872 DBG_ASSERT( pPage, "no page?" )do { if (true && (!(pPage))) { sal_detail_logFormat((
SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "872" ": "), "%s", "no page?"); } } while (false)
;
873 if( pPage == nullptr )
874 return OUString();
875
876 return pPage->GetPresObjText( pPage->GetPresObjKind(pObj) );
877}
878
879/** sets/reset the empty status of a presentation object
880*/
881void SdXShape::SetEmptyPresObj(bool bEmpty)
882{
883 // only possible if this actually *is* a presentation object
884 if( !IsPresObj() )
885 return;
886
887 SdrObject* pObj = mpShape->GetSdrObject();
888 if( pObj == nullptr )
889 return;
890
891 if( pObj->IsEmptyPresObj() == bEmpty )
892 return;
893
894 if(!bEmpty)
895 {
896 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
897 const bool bVertical = pOutlinerParaObject && pOutlinerParaObject->IsVertical();
898
899 // really delete SdrOutlinerObj at pObj
900 pObj->NbcSetOutlinerParaObject(nullptr);
901 if( bVertical && dynamic_cast<SdrTextObj*>( pObj ) )
902 static_cast<SdrTextObj*>(pObj)->SetVerticalWriting( true );
903
904 SdrGrafObj* pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj );
905 if( pGraphicObj )
906 {
907 Graphic aEmpty;
908 pGraphicObj->SetGraphic(aEmpty);
909 }
910 else
911 {
912 SdrOle2Obj* pOleObj = dynamic_cast< SdrOle2Obj* >( pObj );
913 if( pOleObj )
914 {
915 pOleObj->ClearGraphic();
916 }
917 }
918 }
919 else
920 {
921 // now set an empty OutlinerParaObject at pObj without
922 // any content but with the style of the old OutlinerParaObjects
923 // first paragraph
924 do
925 {
926 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
927 DBG_ASSERT( pDoc, "no document?" )do { if (true && (!(pDoc))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "927" ": "), "%s", "no document?"); } } while (false)
;
928 if( pDoc == nullptr)
929 break;
930
931 SdOutliner* pOutliner = pDoc->GetInternalOutliner();
932 DBG_ASSERT( pOutliner, "no outliner?" )do { if (true && (!(pOutliner))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "932" ": "), "%s", "no outliner?"); } } while (false)
;
933 if( pOutliner == nullptr )
934 break;
935
936 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
937 DBG_ASSERT( pPage, "no page?" )do { if (true && (!(pPage))) { sal_detail_logFormat((
SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "937" ": "), "%s", "no page?"); } } while (false)
;
938 if( pPage == nullptr )
939 break;
940
941 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
942 pOutliner->SetText( *pOutlinerParaObject );
943 const bool bVertical = pOutliner->IsVertical();
944
945 pOutliner->Clear();
946 pOutliner->SetVertical( bVertical );
947 pOutliner->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(pDoc->GetStyleSheetPool()) );
948 pOutliner->SetStyleSheet( 0, pPage->GetTextStyleSheetForObject( pObj ) );
949 pOutliner->Insert( pPage->GetPresObjText( pPage->GetPresObjKind(pObj) ) );
950 pObj->SetOutlinerParaObject( pOutliner->CreateParaObject() );
951 pOutliner->Clear();
952 }
953 while(false);
954 }
955
956 pObj->SetEmptyPresObj(bEmpty);
957}
958
959bool SdXShape::IsMasterDepend() const throw()
960{
961 SdrObject* pObj = mpShape->GetSdrObject();
962 return pObj && pObj->GetUserCall() != nullptr;
963}
964
965void SdXShape::SetMasterDepend( bool bDepend ) throw()
966{
967 if( IsMasterDepend() == bDepend )
968 return;
969
970 SdrObject* pObj = mpShape->GetSdrObject();
971 if( pObj )
972 {
973 if( bDepend )
974 {
975 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
976 pObj->SetUserCall( pPage );
977 }
978 else
979 {
980 pObj->SetUserCall( nullptr );
981 }
982 }
983}
984
985void SdXShape::SetStyleSheet( const uno::Any& rAny )
986{
987 SdrObject* pObj = mpShape->GetSdrObject();
988 if( pObj == nullptr )
989 throw beans::UnknownPropertyException();
990
991 uno::Reference< style::XStyle > xStyle( rAny, uno::UNO_QUERY );
992 SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
993
994 const SfxStyleSheet* pOldStyleSheet = pObj->GetStyleSheet();
995 if( pOldStyleSheet == pStyleSheet )
996 return;
997
998 if( pStyleSheet == nullptr || (pStyleSheet->GetFamily() != SfxStyleFamily::Para && pStyleSheet->GetFamily() != SfxStyleFamily::Page) )
999 throw lang::IllegalArgumentException();
1000
1001 pObj->SetStyleSheet( pStyleSheet, false );
1002
1003 SdDrawDocument* pDoc = mpModel? mpModel->GetDoc() : nullptr;
1004 if( pDoc )
1005 {
1006 ::sd::DrawDocShell* pDocSh = pDoc->GetDocSh();
1007 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
1008
1009 if( pViewSh )
1010 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2((5000 + 541) + 1) );
1011 }
1012}
1013
1014uno::Any SdXShape::GetStyleSheet() const
1015{
1016 SdrObject* pObj = mpShape->GetSdrObject();
1017 if( pObj == nullptr )
1018 throw beans::UnknownPropertyException();
1019
1020 SfxStyleSheet* pStyleSheet = pObj->GetStyleSheet();
1021 // it is possible for shapes inside a draw to have a presentation style
1022 // but we don't want this for the api
1023 if( (pStyleSheet == nullptr) || ((pStyleSheet->GetFamily() != SfxStyleFamily::Para) && !mpModel->IsImpressDocument()) )
1024 return Any();
1025
1026 return Any( uno::Reference< style::XStyle >( dynamic_cast< SfxUnoStyleSheet* >( pStyleSheet ) ) );
1027}
1028
1029class SdUnoEventsAccess : public cppu::WeakImplHelper< css::container::XNameReplace, css::lang::XServiceInfo >
1030{
1031private:
1032 SdXShape* mpShape;
1033
1034public:
1035 explicit SdUnoEventsAccess(SdXShape* pShape) throw();
1036
1037 // XNameReplace
1038 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
1039
1040 // XNameAccess
1041 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
1042 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
1043 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
1044
1045 // XElementAccess
1046 virtual css::uno::Type SAL_CALL getElementType( ) override;
1047 virtual sal_Bool SAL_CALL hasElements( ) override;
1048
1049 // XServiceInfo
1050 virtual OUString SAL_CALL getImplementationName( ) override;
1051 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1052 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
1053};
1054
1055// XEventsSupplier
1056uno::Reference< container::XNameReplace > SAL_CALL SdXShape::getEvents( )
1057{
1058 return new SdUnoEventsAccess( this );
1059}
1060
1061constexpr OUStringLiteral gaStrOnClick( u"OnClick" );
1062constexpr OUStringLiteral gaStrServiceName( u"com.sun.star.documents.Events" );
1063constexpr OUStringLiteral gaStrEventType( u"EventType" );
1064constexpr OUStringLiteral gaStrPresentation( u"Presentation" );
1065constexpr OUStringLiteral gaStrLibrary(u"Library");
1066constexpr OUStringLiteral gaStrMacroName(u"MacroName");
1067constexpr OUStringLiteral gaStrClickAction( u"ClickAction" );
1068constexpr OUStringLiteral gaStrBookmark( u"Bookmark" );
1069constexpr OUStringLiteral gaStrEffect( u"Effect" );
1070constexpr OUStringLiteral gaStrPlayFull( u"PlayFull" );
1071constexpr OUStringLiteral gaStrVerb( u"Verb" );
1072constexpr OUStringLiteral gaStrSoundURL( u"SoundURL" );
1073constexpr OUStringLiteral gaStrSpeed( u"Speed" );
1074constexpr OUStringLiteral gaStrStarBasic( u"StarBasic" );
1075constexpr OUStringLiteral gaStrScript( u"Script" );
1076
1077SdUnoEventsAccess::SdUnoEventsAccess( SdXShape* pShape ) throw()
1078 : mpShape( pShape )
1079{
1080}
1081
1082namespace {
1083
1084enum class FoundFlags {
1085 NONE = 0x0000,
1086 ClickAction = 0x0001,
1087 Bookmark = 0x0002,
1088 Effect = 0x0004,
1089 PlayFull = 0x0008,
1090 Verb = 0x0010,
1091 SoundUrl = 0x0020,
1092 Speed = 0x0040,
1093 EventType = 0x0080,
1094 Macro = 0x0100,
1095 Library = 0x0200,
1096};
1097
1098}
1099
1100namespace o3tl {
1101 template<> struct typed_flags<FoundFlags> : is_typed_flags<FoundFlags, 0x03ff> {};
1102}
1103
1104static void clearEventsInAnimationInfo( SdAnimationInfo* pInfo )
1105{
1106 pInfo->SetBookmark( "" );
1107 pInfo->mbSecondSoundOn = false;
1108 pInfo->mbSecondPlayFull = false;
1109 pInfo->meClickAction = presentation::ClickAction_NONE;
1110 pInfo->meSecondEffect = presentation::AnimationEffect_NONE;
1111 pInfo->meSecondSpeed = presentation::AnimationSpeed_MEDIUM;
1112 pInfo->mnVerb = 0;
1113}
1114
1115// XNameReplace
1116void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno::Any& aElement )
1117{
1118 if( mpShape == nullptr || aName != gaStrOnClick )
1119 throw container::NoSuchElementException();
1120
1121 uno::Sequence< beans::PropertyValue > aProperties;
1122 if( !aElement.hasValue() || aElement.getValueType() != getElementType() || !(aElement >>= aProperties) )
1123 throw lang::IllegalArgumentException();
1124
1125 FoundFlags nFound = FoundFlags::NONE;
1126
1127 OUString aStrEventType;
1128 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1129 presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
1130 presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
1131 OUString aStrSoundURL;
1132 bool bPlayFull = false;
1133 sal_Int32 nVerb = 0;
1134 OUString aStrMacro;
1135 OUString aStrLibrary;
1136 OUString aStrBookmark;
1137
1138 for( const beans::PropertyValue& rProperty : std::as_const(aProperties) )
1139 {
1140 if( !( nFound & FoundFlags::EventType ) && rProperty.Name == gaStrEventType )
1141 {
1142 if( rProperty.Value >>= aStrEventType )
1143 {
1144 nFound |= FoundFlags::EventType;
1145 continue;
1146 }
1147 }
1148 else if( !( nFound & FoundFlags::ClickAction ) && rProperty.Name == gaStrClickAction )
1149 {
1150 if( rProperty.Value >>= eClickAction )
1151 {
1152 nFound |= FoundFlags::ClickAction;
1153 continue;
1154 }
1155 }
1156 else if( !( nFound & FoundFlags::Macro ) && ( rProperty.Name == gaStrMacroName || rProperty.Name == gaStrScript ) )
1157 {
1158 if( rProperty.Value >>= aStrMacro )
1159 {
1160 nFound |= FoundFlags::Macro;
1161 continue;
1162 }
1163 }
1164 else if( !( nFound & FoundFlags::Library ) && rProperty.Name == gaStrLibrary )
1165 {
1166 if( rProperty.Value >>= aStrLibrary )
1167 {
1168 nFound |= FoundFlags::Library;
1169 continue;
1170 }
1171 }
1172 else if( !( nFound & FoundFlags::Effect ) && rProperty.Name == gaStrEffect )
1173 {
1174 if( rProperty.Value >>= eEffect )
1175 {
1176 nFound |= FoundFlags::Effect;
1177 continue;
1178 }
1179 }
1180 else if( !( nFound & FoundFlags::Bookmark ) && rProperty.Name == gaStrBookmark )
1181 {
1182 if( rProperty.Value >>= aStrBookmark )
1183 {
1184 nFound |= FoundFlags::Bookmark;
1185 continue;
1186 }
1187 }
1188 else if( !( nFound & FoundFlags::Speed ) && rProperty.Name == gaStrSpeed )
1189 {
1190 if( rProperty.Value >>= eSpeed )
1191 {
1192 nFound |= FoundFlags::Speed;
1193 continue;
1194 }
1195 }
1196 else if( !( nFound & FoundFlags::SoundUrl ) && rProperty.Name == gaStrSoundURL )
1197 {
1198 if( rProperty.Value >>= aStrSoundURL )
1199 {
1200 nFound |= FoundFlags::SoundUrl;
1201 continue;
1202 }
1203 }
1204 else if( !( nFound & FoundFlags::PlayFull ) && rProperty.Name == gaStrPlayFull )
1205 {
1206 if( rProperty.Value >>= bPlayFull )
1207 {
1208 nFound |= FoundFlags::PlayFull;
1209 continue;
1210 }
1211 }
1212 else if( !( nFound & FoundFlags::Verb ) && rProperty.Name == gaStrVerb )
1213 {
1214 if( rProperty.Value >>= nVerb )
1215 {
1216 nFound |= FoundFlags::Verb;
1217 continue;
1218 }
1219 }
1220
1221 throw lang::IllegalArgumentException();
1222 }
1223
1224 bool bOk = false;
1225 do
1226 {
1227 if( !( nFound & FoundFlags::EventType ) )
1228 break;
1229
1230 if( aStrEventType == gaStrPresentation )
1231 {
1232 if( !( nFound & FoundFlags::ClickAction ) )
1233 break;
1234
1235 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo();
1236 if( presentation::ClickAction_NONE == eClickAction && nullptr == pInfo )
1237 {
1238 bOk = true;
1239 break;
1240 }
1241
1242 if( nullptr == pInfo )
1243 pInfo = mpShape->GetAnimationInfo( true );
1244
1245 DBG_ASSERT( pInfo, "shape animation info could not be created!" )do { if (true && (!(pInfo))) { sal_detail_logFormat((
SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "1245" ": "), "%s", "shape animation info could not be created!"
); } } while (false)
;
1246 if( nullptr == pInfo )
1247 break;
1248
1249 clearEventsInAnimationInfo( pInfo );
1250 pInfo->meClickAction = eClickAction;
1251
1252 switch( eClickAction )
1253 {
1254 case presentation::ClickAction_NONE:
1255 case presentation::ClickAction_PREVPAGE:
1256 case presentation::ClickAction_NEXTPAGE:
1257 case presentation::ClickAction_FIRSTPAGE:
1258 case presentation::ClickAction_LASTPAGE:
1259 case presentation::ClickAction_INVISIBLE:
1260 case presentation::ClickAction_STOPPRESENTATION:
1261 {
1262 bOk = true;
1263 }
1264 break;
1265
1266 case presentation::ClickAction_PROGRAM:
1267 case presentation::ClickAction_BOOKMARK:
1268 case presentation::ClickAction_DOCUMENT:
1269 if( nFound & FoundFlags::Bookmark )
1270 {
1271 if( eClickAction == presentation::ClickAction_BOOKMARK )
1272 {
1273 aStrBookmark = getUiNameFromPageApiNameImpl( aStrBookmark );
1274 }
1275 else if( eClickAction == presentation::ClickAction_DOCUMENT )
1276 {
1277 sal_Int32 nPos = aStrBookmark.lastIndexOf( '#' );
1278 if( nPos >= 0 )
1279 {
1280 OUString aURL( aStrBookmark.copy( 0, nPos+1 ) );
1281 aURL += getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) );
1282 aStrBookmark = aURL;
1283 }
1284 }
1285
1286 pInfo->SetBookmark( aStrBookmark );
1287 bOk = true;
1288 }
1289 break;
1290
1291 case presentation::ClickAction_MACRO:
1292 if( nFound & FoundFlags::Macro )
1293 {
1294 pInfo->SetBookmark( aStrMacro );
1295 bOk = true;
1296 }
1297 break;
1298
1299 case presentation::ClickAction_VERB:
1300 if( nFound & FoundFlags::Verb )
1301 {
1302 pInfo->mnVerb = static_cast<sal_uInt16>(nVerb);
1303 bOk = true;
1304 }
1305 break;
1306
1307 case presentation::ClickAction_VANISH:
1308 if( !( nFound & FoundFlags::Effect ) )
1309 break;
1310
1311 pInfo->meSecondEffect = eEffect;
1312 pInfo->meSecondSpeed = nFound & FoundFlags::Speed ? eSpeed : presentation::AnimationSpeed_MEDIUM;
1313
1314 bOk = true;
1315
1316 [[fallthrough]];
1317
1318 case presentation::ClickAction_SOUND:
1319 if( nFound & FoundFlags::SoundUrl )
1320 {
1321 pInfo->SetBookmark( aStrSoundURL );
1322 if( eClickAction != presentation::ClickAction_SOUND )
1323 pInfo->mbSecondSoundOn = !aStrSoundURL.isEmpty();
1324 pInfo->mbSecondPlayFull = (nFound & FoundFlags::PlayFull) && bPlayFull;
1325
1326 bOk = true;
1327 }
1328 break;
1329 default:
1330 break;
1331 }
1332 }
1333 else
1334 {
1335 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( true );
1336
1337 DBG_ASSERT( pInfo, "shape animation info could not be created!" )do { if (true && (!(pInfo))) { sal_detail_logFormat((
SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unoobj.cxx"
":" "1337" ": "), "%s", "shape animation info could not be created!"
); } } while (false)
;
1338 if( nullptr == pInfo )
1339 break;
1340
1341 clearEventsInAnimationInfo( pInfo );
1342 pInfo->meClickAction = presentation::ClickAction_MACRO;
1343
1344 if ( SfxApplication::IsXScriptURL( aStrMacro ) )
1345 {
1346 pInfo->SetBookmark( aStrMacro );
1347 }
1348 else
1349 {
1350 sal_Int32 nIdx{ 0 };
1351 const OUString aLibName = aStrMacro.getToken(0, '.', nIdx);
1352 const OUString aModulName = aStrMacro.getToken(0, '.', nIdx);
1353 const OUString aMacroName = aStrMacro.getToken(0, '.', nIdx);
1354
1355 OUStringBuffer sBuffer;
1356 sBuffer.append( aMacroName );
1357 sBuffer.append( '.' );
1358 sBuffer.append( aModulName );
1359 sBuffer.append( '.' );
1360 sBuffer.append( aLibName );
1361 sBuffer.append( '.' );
1362
1363 if ( aStrLibrary == "StarOffice" )
1364 {
1365 sBuffer.append( "BASIC" );
1366 }
1367 else
1368 {
1369 sBuffer.append( aStrLibrary );
1370 }
1371
1372 pInfo->SetBookmark( sBuffer.makeStringAndClear() );
1373 }
1374 bOk = true;
1375 }
1376 }
1377 while(false);
1378
1379 if( !bOk )
1380 throw lang::IllegalArgumentException();
1381}
1382
1383// XNameAccess
1384uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName )
1385{
1386 if( mpShape == nullptr || aName != gaStrOnClick )
1
Assuming the condition is false
2
Taking false branch
1387 throw container::NoSuchElementException();
1388
1389 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo();
3
Calling 'SdXShape::GetAnimationInfo'
16
Returning from 'SdXShape::GetAnimationInfo'
17
'pInfo' initialized here
1390
1391 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1392 if( pInfo )
18
Assuming 'pInfo' is null
19
Taking false branch
1393 eClickAction = pInfo->meClickAction;
1394
1395 sal_Int32 nPropertyCount = 2;
1396 switch( eClickAction )
20
Control jumps to 'case 0:' at line 1398
1397 {
1398 case presentation::ClickAction_NONE:
1399 case presentation::ClickAction_PREVPAGE:
1400 case presentation::ClickAction_NEXTPAGE:
1401 case presentation::ClickAction_FIRSTPAGE:
1402 case presentation::ClickAction_LASTPAGE:
1403 case presentation::ClickAction_INVISIBLE:
1404 case presentation::ClickAction_STOPPRESENTATION:
1405 break;
21
Execution continues on line 1426
1406 case presentation::ClickAction_PROGRAM:
1407 case presentation::ClickAction_VERB:
1408 case presentation::ClickAction_BOOKMARK:
1409 case presentation::ClickAction_DOCUMENT:
1410 case presentation::ClickAction_MACRO:
1411 if ( !SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1412 nPropertyCount += 1;
1413 break;
1414
1415 case presentation::ClickAction_SOUND:
1416 nPropertyCount += 2;
1417 break;
1418
1419 case presentation::ClickAction_VANISH:
1420 nPropertyCount += 4;
1421 break;
1422 default:
1423 break;
1424 }
1425
1426 uno::Sequence< beans::PropertyValue > aProperties( nPropertyCount );
1427 beans::PropertyValue* pProperties = aProperties.getArray();
1428
1429 uno::Any aAny;
1430
1431 if( eClickAction
21.1
'eClickAction' is not equal to 'ClickAction_MACRO'
21.1
'eClickAction' is not equal to 'ClickAction_MACRO'
21.1
'eClickAction' is not equal to 'ClickAction_MACRO'
21.1
'eClickAction' is not equal to 'ClickAction_MACRO'
== presentation::ClickAction_MACRO )
22
Taking false branch
1432 {
1433 if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1434 {
1435 // Scripting Framework URL
1436 aAny <<= OUString(gaStrScript);
1437 pProperties->Name = gaStrEventType;
1438 pProperties->Handle = -1;
1439 pProperties->Value = aAny;
1440 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1441 pProperties++;
1442
1443 aAny <<= pInfo->GetBookmark();
1444 pProperties->Name = gaStrScript;
1445 pProperties->Handle = -1;
1446 pProperties->Value = aAny;
1447 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1448 pProperties++;
1449 }
1450 else
1451 {
1452 // Old Basic macro URL
1453 aAny <<= OUString(gaStrStarBasic);
1454 pProperties->Name = gaStrEventType;
1455 pProperties->Handle = -1;
1456 pProperties->Value = aAny;
1457 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1458 pProperties++;
1459
1460 OUString aMacro = pInfo->GetBookmark();
1461
1462 // aMacro has got following format:
1463 // "Macroname.Modulname.Libname.Documentname" or
1464 // "Macroname.Modulname.Libname.Applicationname"
1465 sal_Int32 nIdx{ 0 };
1466 const OUString aMacroName = aMacro.getToken(0, '.', nIdx);
1467 const OUString aModulName = aMacro.getToken(0, '.', nIdx);
1468 const OUString aLibName = aMacro.getToken(0, '.', nIdx);
1469
1470 OUString sBuffer = aLibName +
1471 "." +
1472 aModulName +
1473 "." +
1474 aMacroName;
1475
1476 aAny <<= sBuffer;
1477 pProperties->Name = gaStrMacroName;
1478 pProperties->Handle = -1;
1479 pProperties->Value = aAny;
1480 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1481 pProperties++;
1482
1483 aAny <<= OUString( "StarOffice" );
1484 pProperties->Name = gaStrLibrary;
1485 pProperties->Handle = -1;
1486 pProperties->Value = aAny;
1487 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1488 }
1489 }
1490 else
1491 {
1492 aAny <<= OUString(gaStrPresentation);
1493 pProperties->Name = gaStrEventType;
1494 pProperties->Handle = -1;
1495 pProperties->Value = aAny;
1496 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1497 pProperties++;
1498
1499 aAny <<= eClickAction;
23
Calling 'operator<<=<com::sun::star::presentation::ClickAction>'
25
Returning from 'operator<<=<com::sun::star::presentation::ClickAction>'
1500 pProperties->Name = gaStrClickAction;
1501 pProperties->Handle = -1;
1502 pProperties->Value = aAny;
1503 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1504 pProperties++;
1505
1506 switch( eClickAction )
26
Control jumps to 'case 8:' at line 1561
1507 {
1508 case presentation::ClickAction_NONE:
1509 case presentation::ClickAction_PREVPAGE:
1510 case presentation::ClickAction_NEXTPAGE:
1511 case presentation::ClickAction_FIRSTPAGE:
1512 case presentation::ClickAction_LASTPAGE:
1513 case presentation::ClickAction_INVISIBLE:
1514 case presentation::ClickAction_STOPPRESENTATION:
1515 break;
1516 case presentation::ClickAction_BOOKMARK:
1517 {
1518 const OUString aStrBookmark( getPageApiNameFromUiName( pInfo->GetBookmark()) );
1519 pProperties->Name = gaStrBookmark;
1520 pProperties->Handle = -1;
1521 pProperties->Value <<= aStrBookmark;
1522 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1523 }
1524 break;
1525
1526 case presentation::ClickAction_DOCUMENT:
1527 case presentation::ClickAction_PROGRAM:
1528 {
1529 OUString aString( pInfo->GetBookmark());
1530 sal_Int32 nPos = aString.lastIndexOf( '#' );
1531 if( nPos >= 0 )
1532 {
1533 OUString aURL( aString.copy( 0, nPos+1 ) );
1534 aURL += getPageApiNameFromUiName( aString.copy( nPos+1 ) );
1535 aString = aURL;
1536 }
1537 pProperties->Name = gaStrBookmark;
1538 pProperties->Handle = -1;
1539 pProperties->Value <<= aString;
1540 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1541 }
1542 break;
1543
1544 case presentation::ClickAction_VANISH:
1545 aAny <<= pInfo->meSecondEffect;
1546 pProperties->Name = gaStrEffect;
1547 pProperties->Handle = -1;
1548 pProperties->Value = aAny;
1549 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1550 pProperties++;
1551
1552 aAny <<= pInfo->meSecondSpeed;
1553 pProperties->Name = gaStrSpeed;
1554 pProperties->Handle = -1;
1555 pProperties->Value = aAny;
1556 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1557 pProperties++;
1558
1559 [[fallthrough]];
1560
1561 case presentation::ClickAction_SOUND:
1562 if( eClickAction
26.1
'eClickAction' is equal to 'ClickAction_SOUND'
26.1
'eClickAction' is equal to 'ClickAction_SOUND'
26.1
'eClickAction' is equal to 'ClickAction_SOUND'
26.1
'eClickAction' is equal to 'ClickAction_SOUND'
== presentation::ClickAction_SOUND || pInfo->mbSecondSoundOn )
1563 {
1564 aAny <<= pInfo->GetBookmark();
27
Called C++ object pointer is null
1565 pProperties->Name = gaStrSoundURL;
1566 pProperties->Handle = -1;
1567 pProperties->Value = aAny;
1568 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1569 pProperties++;
1570
1571 pProperties->Name = gaStrPlayFull;
1572 pProperties->Handle = -1;
1573 pProperties->Value <<= pInfo->mbSecondPlayFull;
1574 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1575 }
1576 break;
1577
1578 case presentation::ClickAction_VERB:
1579 aAny <<= static_cast<sal_Int32>(pInfo->mnVerb);
1580 pProperties->Name = gaStrVerb;
1581 pProperties->Handle = -1;
1582 pProperties->Value = aAny;
1583 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1584 break;
1585 default:
1586 break;
1587 }
1588 }
1589
1590 aAny <<= aProperties;
1591 return aAny;
1592}
1593
1594uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getElementNames( )
1595{
1596 return { gaStrOnClick };
1597}
1598
1599sal_Bool SAL_CALL SdUnoEventsAccess::hasByName( const OUString& aName )
1600{
1601 return aName == gaStrOnClick;
1602}
1603
1604// XElementAccess
1605uno::Type SAL_CALL SdUnoEventsAccess::getElementType( )
1606{
1607 return cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get();
1608}
1609
1610sal_Bool SAL_CALL SdUnoEventsAccess::hasElements( )
1611{
1612 return true;
1613}
1614
1615// XServiceInfo
1616OUString SAL_CALL SdUnoEventsAccess::getImplementationName( )
1617{
1618 return "SdUnoEventsAccess";
1619}
1620
1621sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName )
1622{
1623 return cppu::supportsService(this, ServiceName);
1624}
1625
1626uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames( )
1627{
1628 return { gaStrServiceName };
1629}
1630
1631/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/svx/unoshape.hxx

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#ifndef INCLUDED_SVX_UNOSHAPE_HXX
21#define INCLUDED_SVX_UNOSHAPE_HXX
22
23#include <memory>
24#include <com/sun/star/document/XActionLockable.hpp>
25#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
26#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
27#include <com/sun/star/drawing/XShape.hpp>
28#include <com/sun/star/lang/XComponent.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
30#include <com/sun/star/beans/XPropertyState.hpp>
31#include <com/sun/star/lang/XServiceInfo.hpp>
32#include <com/sun/star/lang/XUnoTunnel.hpp>
33#include <com/sun/star/awt/Point.hpp>
34#include <com/sun/star/drawing/PolygonKind.hpp>
35#include <com/sun/star/drawing/XShapes.hpp>
36#include <com/sun/star/drawing/XShapes2.hpp>
37#include <com/sun/star/drawing/XShapeGroup.hpp>
38#include <com/sun/star/container/XNamed.hpp>
39#include <com/sun/star/container/XChild.hpp>
40#include <com/sun/star/beans/XMultiPropertySet.hpp>
41#include <com/sun/star/beans/XMultiPropertyStates.hpp>
42#include <com/sun/star/drawing/XConnectorShape.hpp>
43#include <com/sun/star/drawing/XControlShape.hpp>
44#include <basegfx/polygon/b2dpolypolygon.hxx>
45#include <sal/types.h>
46#include <tools/weakbase.hxx>
47#include <svl/lstner.hxx>
48#include <editeng/unoipset.hxx>
49#include <osl/mutex.hxx>
50#include <svx/svxdllapi.h>
51#include <rtl/ref.hxx>
52#include <com/sun/star/uno/Any.hxx>
53#include <editeng/unotext.hxx>
54
55#include <svx/svdobj.hxx>
56
57#include <comphelper/servicehelper.hxx>
58
59#include <cppuhelper/implbase1.hxx>
60#include <cppuhelper/implbase12.hxx>
61
62class SfxItemSet;
63class SdrModel;
64class SvxDrawPage;
65class SvGlobalName;
66class Pair;
67class IOpenGLRenderer;
68
69// Dimension arrows change size/position on save/reload (#i59051#)
70namespace basegfx
71 {
72 class B2DPolyPolygon;
73 } // end of namespace basegfx
74
75class SvxShapeMutex
76{
77protected:
78 ::osl::Mutex maMutex;
79};
80
81struct SvxShapeImpl;
82class SvxShapeMaster;
83class SvxItemPropertySet;
84class SfxItemSet;
85
86void SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxItemPropertySet_setPropertyValue( const SfxItemPropertySimpleEntry* pMap,
87 const css::uno::Any& rVal, SfxItemSet& rSet );
88
89css::uno::Any SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxItemPropertySet_getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet );
90
91
92// WARNING: if you update the supported interfaces,
93// also update SvxShape::_getTypes()
94typedef ::cppu::WeakAggImplHelper12<
95 css::drawing::XShape,
96 css::lang::XComponent,
97 css::beans::XPropertySet,
98 css::beans::XMultiPropertySet,
99 css::beans::XPropertyState,
100 css::lang::XUnoTunnel,
101 css::container::XNamed,
102 css::drawing::XGluePointsSupplier,
103 css::container::XChild,
104 css::lang::XServiceInfo,
105 css::document::XActionLockable,
106 css::beans::XMultiPropertyStates> SvxShape_UnoImplHelper;
107
108class SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxShape : public SvxShape_UnoImplHelper,
109 public SfxListener,
110 public SvxShapeMutex
111{
112private:
113 css::awt::Size maSize;
114 css::awt::Point maPosition;
115 OUString maShapeType;
116 OUString maShapeName;
117
118 /** these members are used to optimize XMultiProperty calls */
119 std::unique_ptr<SvxShapeImpl> mpImpl;
120 bool mbIsMultiPropertyCall;
121
122 css::uno::WeakReference< css::container::XIndexContainer > mxGluePoints;
123
124protected:
125 friend class SvxDrawPage;
126 friend class SvxShapeConnector;
127 friend class SdXShape;
128
129 const SvxItemPropertySet* mpPropSet;
130 const SfxItemPropertyMapEntry* maPropMapEntries;
131
132private:
133 ::tools::WeakReference< SdrObject > mpSdrObjectWeakReference;
134
135protected:
136 // translations for writer, which works in TWIPS
137 void ForceMetricToItemPoolMetric(Pair& rPoint) const throw();
138 void ForceMetricToItemPoolMetric(Point& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); }
139 void ForceMetricToItemPoolMetric(Size& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); }
140 void ForceMetricTo100th_mm(Pair& rPoint) const throw();
141 void ForceMetricTo100th_mm(Point& rPoint) const throw() { ForceMetricTo100th_mm(rPoint.toPair()); }
142 void ForceMetricTo100th_mm(Size& rPoint) const throw() { ForceMetricTo100th_mm(rPoint.toPair()); }
143
144 // version for basegfx::B2DPolyPolygon
145 void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw();
146 void ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw();
147
148 // tdf#117145 version for basegfx::B2DHomMatrix
149 void ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix& rB2DHomMatrix) const throw();
150 void ForceMetricTo100th_mm(basegfx::B2DHomMatrix& rB2DHomMatrix) const throw();
151
152 css::uno::Any GetAnyForItem( SfxItemSet const & aSet, const SfxItemPropertySimpleEntry* pMap ) const;
153
154 bool SetFillAttribute( sal_uInt16 nWID, const OUString& rName );
155
156 /** called from the XActionLockable interface methods on initial locking */
157 virtual void lock();
158
159 /** called from the XActionLockable interface methods on final unlock */
160 virtual void unlock();
161
162 /** used from the XActionLockable interface */
163 sal_uInt16 mnLockCount;
164
165 const SfxItemPropertyMapEntry* getPropertyMapEntries() const { return maPropMapEntries; }
166
167 void updateShapeKind();
168 void endSetPropertyValues();
169
170 // override these for special property handling in subcasses. Return true if property is handled
171 /// @throws css::beans::UnknownPropertyException
172 /// @throws css::beans::PropertyVetoException
173 /// @throws css::lang::IllegalArgumentException
174 /// @throws css::lang::WrappedTargetException
175 /// @throws css::uno::RuntimeException
176 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue );
177 /// @throws css::beans::UnknownPropertyException
178 /// @throws css::lang::WrappedTargetException
179 /// @throws css::uno::RuntimeException
180 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue );
181 /// @throws css::beans::UnknownPropertyException
182 /// @throws css::uno::RuntimeException
183 virtual bool getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, css::beans::PropertyState& rState );
184 /// @throws css::beans::UnknownPropertyException
185 /// @throws css::uno::RuntimeException
186 virtual bool setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty );
187
188public:
189 /// @throws css::uno::RuntimeException
190 SvxShape( SdrObject* pObj );
191 /// @throws css::uno::RuntimeException
192 SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet );
193 virtual ~SvxShape() throw () override;
194
195 // Internals
196 void ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet);
197 virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage );
198 /** takes the ownership of the SdrObject.
199
200 When the shape is disposed, and it has the ownership of its associated SdrObject, then
201 it will delete this object.
202 */
203 void TakeSdrObjectOwnership();
204 bool HasSdrObjectOwnership() const;
205
206 // used exclusively by SdrObject
207 void InvalidateSdrObject();
208
209 // Encapsulated access to SdrObject
210 SdrObject* GetSdrObject() const { return mpSdrObjectWeakReference.get(); }
5
Calling 'WeakReference::get'
10
Returning from 'WeakReference::get'
11
Returning pointer, which participates in a condition later
211 bool HasSdrObject() const { return mpSdrObjectWeakReference.is(); }
212
213 void SetShapeType( const OUString& ShapeType ) { maShapeType = ShapeType; }
214 /// @throws css::uno::RuntimeException
215 css::uno::Any GetBitmap( bool bMetaFile = false ) const;
216
217 svx::PropertyChangeNotifier& getShapePropertyChangeNotifier();
218
219 void setShapeKind( sal_uInt32 nKind );
220 sal_uInt32 getShapeKind() const;
221
222 // styles need this
223 static bool SetFillAttribute( sal_uInt16 nWID, const OUString& rName, SfxItemSet& rSet, SdrModel const * pModel );
224 static bool SetFillAttribute( sal_uInt16 nWID, const OUString& rName, SfxItemSet& rSet );
225
226 /** same as SetFillAttribute but for property names instead of which ids,
227 and the property found is returned instead of set at the object
228 directly.
229 */
230
231 UNO3_GETIMPLEMENTATION_DECL( SvxShape )static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId
() throw(); virtual sal_Int64 getSomething( const css::uno::Sequence
< sal_Int8 >& aIdentifier ) override;
232
233 // access methods for master objects
234 /// @throws css::uno::RuntimeException
235 css::uno::Reference< css::beans::XPropertySetInfo > const & _getPropertySetInfo( );
236 /// @throws css::beans::UnknownPropertyException
237 /// @throws css::beans::PropertyVetoException
238 /// @throws css::lang::IllegalArgumentException
239 /// @throws css::lang::WrappedTargetException
240 /// @throws css::uno::RuntimeException
241 void _setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue );
242 /// @throws css::beans::UnknownPropertyException
243 /// @throws css::lang::WrappedTargetException
244 /// @throws css::uno::RuntimeException
245 css::uno::Any _getPropertyValue( const OUString& PropertyName );
246
247 /// @throws css::beans::UnknownPropertyException
248 /// @throws css::uno::RuntimeException
249 css::beans::PropertyState _getPropertyState( const OUString& PropertyName );
250 /// @throws css::beans::UnknownPropertyException
251 /// @throws css::uno::RuntimeException
252 void _setPropertyToDefault( const OUString& PropertyName );
253 /// @throws css::beans::UnknownPropertyException
254 /// @throws css::lang::WrappedTargetException
255 /// @throws css::uno::RuntimeException
256 css::uno::Any _getPropertyDefault( const OUString& aPropertyName );
257
258 /// @throws css::uno::RuntimeException
259 css::uno::Sequence< OUString > _getSupportedServiceNames();
260
261 /// @throws css::uno::RuntimeException
262 css::uno::Sequence< css::uno::Type > const & _getTypes( );
263
264 void setMaster( SvxShapeMaster* pMaster );
265
266 // SfxListener
267 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw () override;
268
269 // XAggregation
270 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override;
271
272 // XNamed
273 virtual OUString SAL_CALL getName( ) override;
274 virtual void SAL_CALL setName( const OUString& aName ) override;
275
276 // XShapeDescriptor
277 virtual OUString SAL_CALL getShapeType() override;
278
279 // XShape
280 virtual css::awt::Point SAL_CALL getPosition() override;
281 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
282 virtual css::awt::Size SAL_CALL getSize() override;
283 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
284
285 // XComponent
286 virtual void SAL_CALL dispose() override;
287 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
288 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
289
290 // XPropertySet
291 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
292 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
293 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
294 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
295 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
296 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
297 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
298
299 // XMultiPropertySet
300 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
301 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
302 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
303 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
304 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
305
306 // XPropertyState
307 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
308 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
309 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
310 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
311
312 // XMultiPropertyStates
313 virtual void SAL_CALL setAllPropertiesToDefault() override;
314 virtual void SAL_CALL setPropertiesToDefault(
315 const css::uno::Sequence<
316 OUString >& aPropertyNames ) override;
317 virtual css::uno::Sequence< css::uno::Any >
318 SAL_CALL getPropertyDefaults(
319 const css::uno::Sequence<
320 OUString >& aPropertyNames ) override;
321
322 // XServiceInfo
323 virtual OUString SAL_CALL getImplementationName() override;
324 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
325 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
326
327 // XGluePointsSupplier
328 virtual css::uno::Reference< css::container::XIndexContainer > SAL_CALL getGluePoints( ) override;
329
330 // XChild
331 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
332 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
333
334 // XTypeProvider
335 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
336 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
337
338 // XActionLockable
339 virtual sal_Bool SAL_CALL isActionLocked( ) override;
340 virtual void SAL_CALL addActionLock( ) override;
341 virtual void SAL_CALL removeActionLock( ) override;
342 virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override;
343 virtual sal_Int16 SAL_CALL resetActionLocks( ) override;
344
345private:
346 /** initializes SdrObj-dependent members. Only to be called when GetSdrObject() != NULL
347 */
348 SVX_DLLPRIVATE__attribute__ ((visibility("hidden"))) void impl_initFromSdrObject();
349 /// CTOR-Impl
350 SVX_DLLPRIVATE__attribute__ ((visibility("hidden"))) void impl_construct();
351};
352
353class SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxShapeText : public SvxShape, public SvxUnoTextBase
354{
355protected:
356 /** called from the XActionLockable interface methods on initial locking */
357 virtual void lock() override;
358
359 /** called from the XActionLockable interface methods on final unlock */
360 virtual void unlock() override;
361
362protected:
363 // override these for special property handling in subcasses. Return true if property is handled
364 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
365 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
366 virtual bool getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, css::beans::PropertyState& rState ) override;
367 virtual bool setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) override;
368
369public:
370 SvxShapeText(SdrObject* pObj);
371 SvxShapeText(SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet);
372 virtual ~SvxShapeText() throw () override;
373
374 virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override;
375
376 // XInterface
377 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
378 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
379 virtual void SAL_CALL acquire() throw() override
380 { SvxShape::acquire(); }
381 virtual void SAL_CALL release() throw() override
382 { SvxShape::release(); }
383
384 // XServiceInfo
385 virtual OUString SAL_CALL getImplementationName() override;
386 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
387 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
388
389 // css::text::XTextRange
390 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
391 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
392 virtual OUString SAL_CALL getString() override;
393 virtual void SAL_CALL setString( const OUString& aString ) override;
394
395 // XUnoTunnel
396 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
397
398 // XTypeProvider
399 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
400 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
401};
402
403class SvxShapeRect final : public SvxShapeText
404{
405public:
406 SvxShapeRect(SdrObject* pObj);
407 virtual ~SvxShapeRect() throw () override;
408
409 // XInterface
410 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
411 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
412 virtual void SAL_CALL acquire() throw() override
413 { OWeakAggObject::acquire(); }
414 virtual void SAL_CALL release() throw() override
415 { OWeakAggObject::release(); }
416
417 // XServiceInfo
418 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
419};
420
421/***********************************************************************
422* *
423***********************************************************************/
424class SvxShapeGroup final : public SvxShape,
425 public css::drawing::XShapeGroup,
426 public css::drawing::XShapes2,
427 public css::drawing::XShapes
428{
429private:
430 rtl::Reference< SvxDrawPage> mxPage;
431
432 void addUnoShape( const css::uno::Reference< css::drawing::XShape >& xShape, size_t nPos );
433
434public:
435 SvxShapeGroup(SdrObject* pObj,SvxDrawPage* pDrawPage);
436 virtual ~SvxShapeGroup() throw () override;
437
438 virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override;
439
440 // XInterface
441 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
442 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
443 virtual void SAL_CALL acquire() throw() override
444 { SvxShape::acquire(); }
445 virtual void SAL_CALL release() throw() override
446 { SvxShape::release(); }
447
448 // XShapes
449 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
450 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
451
452 // XShapes2
453 virtual void SAL_CALL addTop( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
454 virtual void SAL_CALL addBottom( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
455
456 // XElementAccess
457 virtual css::uno::Type SAL_CALL getElementType() override;
458 virtual sal_Bool SAL_CALL hasElements() override;
459
460 // XIndexAccess
461 virtual sal_Int32 SAL_CALL getCount() override ;
462 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
463
464 // XShapeDescriptor
465 virtual OUString SAL_CALL getShapeType() override;
466
467 // XShape
468 virtual css::awt::Point SAL_CALL getPosition() override;
469 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
470 virtual css::awt::Size SAL_CALL getSize() override;
471 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
472
473 // XShapeGroup
474 virtual void SAL_CALL enterGroup( ) override;
475 virtual void SAL_CALL leaveGroup( ) override;
476
477 // XTypeProvider
478 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
479};
480
481/***********************************************************************
482* *
483***********************************************************************/
484class SvxShapeConnector : public css::drawing::XConnectorShape,
485 public SvxShapeText
486{
487public:
488 SvxShapeConnector(SdrObject* pObj);
489 virtual ~SvxShapeConnector() throw() override;
490
491 // XInterface
492 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
493 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
494 virtual void SAL_CALL acquire() throw() override
495 { SvxShapeText::acquire(); }
496 virtual void SAL_CALL release() throw() override
497 { SvxShapeText::release(); }
498
499 // XShapeDescriptor
500 virtual OUString SAL_CALL getShapeType() override;
501
502 // XShape
503 virtual css::awt::Point SAL_CALL getPosition() override;
504 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
505 virtual css::awt::Size SAL_CALL getSize() override;
506 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
507
508 // XConnectorShape
509 virtual void SAL_CALL connectStart( const css::uno::Reference< css::drawing::XConnectableShape >& xShape, css::drawing::ConnectionType nPos ) override;
510 virtual void SAL_CALL connectEnd( const css::uno::Reference< css::drawing::XConnectableShape >& xShape, css::drawing::ConnectionType nPos ) override;
511 virtual void SAL_CALL disconnectBegin( const css::uno::Reference< css::drawing::XConnectableShape >& xShape ) override;
512 virtual void SAL_CALL disconnectEnd( const css::uno::Reference< css::drawing::XConnectableShape >& xShape ) override;
513
514 // XTypeProvider
515 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
516 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
517};
518
519/***********************************************************************
520* *
521***********************************************************************/
522class SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxShapeControl final : public css::drawing::XControlShape, public SvxShapeText
523{
524protected:
525 using SvxUnoTextRangeBase::setPropertyValue;
526 using SvxUnoTextRangeBase::getPropertyValue;
527
528public:
529 SvxShapeControl(SdrObject* pObj);
530 virtual ~SvxShapeControl() throw() override;
531
532 // XInterface
533 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
534 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
535 virtual void SAL_CALL acquire() throw() override
536 { SvxShapeText::acquire(); }
537 virtual void SAL_CALL release() throw() override
538 { SvxShapeText::release(); }
539
540 // XPropertySet
541 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
542 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
543
544 // XPropertyState
545 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
546 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
547 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
548
549 // XShapeDescriptor
550 virtual OUString SAL_CALL getShapeType() override;
551
552 // XShape
553 virtual css::awt::Point SAL_CALL getPosition() override;
554 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
555 virtual css::awt::Size SAL_CALL getSize() override;
556 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
557
558 // XControlShape
559 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getControl() override;
560 virtual void SAL_CALL setControl( const css::uno::Reference< css::awt::XControlModel >& xControl ) override;
561
562 // XTypeProvider
563 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
564 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
565};
566
567/***********************************************************************
568* *
569***********************************************************************/
570class SvxShapeDimensioning final : public SvxShapeText
571{
572public:
573 SvxShapeDimensioning(SdrObject* pObj);
574 virtual ~SvxShapeDimensioning() throw() override;
575};
576
577/***********************************************************************
578* *
579***********************************************************************/
580class SvxShapeCircle final : public SvxShapeText
581{
582public:
583 SvxShapeCircle(SdrObject* pObj);
584 virtual ~SvxShapeCircle() throw () override;
585};
586
587/***********************************************************************
588* *
589***********************************************************************/
590
591// #i118485# changed parent to SvxShapeText to allow Text handling over UNO API
592class SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxOle2Shape : public SvxShapeText
593{
594protected:
595 // override these for special property handling in subcasses. Return true if property is handled
596 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
597 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
598
599 void resetModifiedState();
600
601 SvGlobalName GetClassName_Impl(OUString& rHexCLSID);
602public:
603 SvxOle2Shape(SdrObject* pObj);
604 SvxOle2Shape(SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet);
605 virtual ~SvxOle2Shape() throw() override;
606
607 bool createObject( const SvGlobalName &aClassName );
608
609 void createLink( const OUString& aLinkURL );
610};
611
612
613/***********************************************************************
614* *
615***********************************************************************/
616class SvxShapePolyPolygon final : public SvxShapeText
617{
618 using SvxUnoTextRangeBase::setPropertyValue;
619 using SvxUnoTextRangeBase::getPropertyValue;
620
621 // override these for special property handling in subcasses. Return true if property is handled
622 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
623 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
624
625 // local helper to detect PolygonKind from SdrObject::GetObjIdentifier()
626 css::drawing::PolygonKind GetPolygonKind() const;
627
628public:
629 /// @throws css::lang::IllegalArgumentException
630 /// @throws css::beans::PropertyVetoException
631 SvxShapePolyPolygon( SdrObject* pObj );
632 virtual ~SvxShapePolyPolygon() throw() override;
633
634 // Local support functions
635 /// @throws css::uno::RuntimeException
636 void SetPolygon(const basegfx::B2DPolyPolygon& rNew);
637 basegfx::B2DPolyPolygon GetPolygon() const throw();
638};
639
640/***********************************************************************
641* *
642***********************************************************************/
643
644class SvxGraphicObject final : public SvxShapeText
645{
646 using SvxUnoTextRangeBase::setPropertyValue;
647 using SvxUnoTextRangeBase::getPropertyValue;
648
649 // override these for special property handling in subcasses. Return true if property is handled
650 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
651 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
652
653public:
654 SvxGraphicObject(SdrObject* pObj);
655 virtual ~SvxGraphicObject() throw() override;
656};
657
658/***********************************************************************
659* *
660***********************************************************************/
661class Svx3DSceneObject final : public css::drawing::XShapes, public SvxShape
662{
663private:
664 rtl::Reference< SvxDrawPage > mxPage;
665
666protected:
667 using SvxShape::setPropertyValue;
668 using SvxShape::getPropertyValue;
669
670public:
671 Svx3DSceneObject(SdrObject* pObj, SvxDrawPage* pDrawPage);
672 // override these for special property handling in subcasses. Return true if property is handled
673 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
674 virtual bool getPropertyValueImpl(const OUString& rName, const SfxItemPropertySimpleEntry* pProperty,
675 css::uno::Any& rValue ) override;
676
677 virtual ~Svx3DSceneObject() throw() override;
678
679 virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override;
680
681 // XInterface
682 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
683 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
684 virtual void SAL_CALL acquire() throw() override
685 { SvxShape::acquire(); }
686 virtual void SAL_CALL release() throw() override
687 { SvxShape::release(); }
688
689 // XShapes
690 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
691 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
692
693 // XElementAccess
694 virtual css::uno::Type SAL_CALL getElementType( ) override;
695 virtual sal_Bool SAL_CALL hasElements( ) override;
696
697 // XIndexAccess
698 virtual sal_Int32 SAL_CALL getCount( ) override ;
699 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
700
701 // XServiceInfo
702 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
703
704 // XTypeProvider
705 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
706};
707
708/***********************************************************************
709* *
710***********************************************************************/
711class Svx3DCubeObject final : public SvxShape
712{
713 // override these for special property handling in subcasses. Return true if property is handled
714 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
715 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
716
717public:
718 Svx3DCubeObject(SdrObject* pObj);
719 virtual ~Svx3DCubeObject() throw() override;
720
721 // XServiceInfo
722 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
723};
724
725/***********************************************************************
726* *
727***********************************************************************/
728class Svx3DSphereObject final : public SvxShape
729{
730public:
731 Svx3DSphereObject(SdrObject* pObj);
732private:
733 // override these for special property handling in subcasses. Return true if property is handled
734 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
735 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
736
737 virtual ~Svx3DSphereObject() throw() override;
738
739 // XServiceInfo
740 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
741};
742
743/***********************************************************************
744* *
745***********************************************************************/
746class Svx3DLatheObject final : public SvxShape
747{
748 // override these for special property handling in subcasses. Return true if property is handled
749 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
750 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
751
752public:
753 Svx3DLatheObject(SdrObject* pObj);
754 virtual ~Svx3DLatheObject() throw() override;
755
756 // XServiceInfo
757 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
758};
759
760/***********************************************************************
761* *
762***********************************************************************/
763class Svx3DExtrudeObject final : public SvxShape
764{
765public:
766 Svx3DExtrudeObject(SdrObject* pObj);
767private:
768 // override these for special property handling in subcasses. Return true if property is handled
769 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
770 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
771
772 virtual ~Svx3DExtrudeObject() throw() override;
773
774 // XServiceInfo
775 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
776};
777
778/***********************************************************************
779* *
780***********************************************************************/
781class Svx3DPolygonObject final : public SvxShape
782{
783 // override these for special property handling in subcasses. Return true if property is handled
784 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
785 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
786
787public:
788 Svx3DPolygonObject(SdrObject* pObj);
789 virtual ~Svx3DPolygonObject() throw() override;
790
791 // XServiceInfo
792 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
793};
794
795/***********************************************************************
796* *
797***********************************************************************/
798typedef ::cppu::WeakAggImplHelper1<
799 css::drawing::XEnhancedCustomShapeDefaulter
800 > SvxShape_UnoImplHelper1;
801
802class SVXCORE_DLLPUBLIC__attribute__ ((visibility("default"))) SvxCustomShape final : public SvxShapeText, public SvxShape_UnoImplHelper1
803{
804protected:
805 using SvxUnoTextRangeBase::setPropertyValue;
806 using SvxUnoTextRangeBase::getPropertyValue;
807
808public:
809 SvxCustomShape(SdrObject* pObj);
810 // override these for special property handling in subcasses. Return true if property is handled
811 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
812
813
814 virtual ~SvxCustomShape() throw () override;
815
816 // XInterface
817 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
818 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
819 virtual void SAL_CALL acquire() throw() override
820 { SvxShapeText::acquire(); }
821 virtual void SAL_CALL release() throw() override
822 { SvxShapeText::release(); }
823
824 // XShape
825 virtual css::awt::Point SAL_CALL getPosition() override;
826
827 // XPropertySet
828 void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
829
830 // XTypeProvider
831 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
832 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
833
834 //XEnhancedCustomShapeDefaulter
835 virtual void SAL_CALL createCustomShapeDefaults( const OUString& rShapeType ) override;
836};
837
838/***********************************************************************
839* *
840***********************************************************************/
841
842class SvxMediaShape final : public SvxShape
843{
844public:
845 SvxMediaShape(SdrObject* pObj, OUString const & referer);
846 virtual ~SvxMediaShape() throw() override;
847
848private:
849 // override these for special property handling in subcasses. Return true if property is handled
850 virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override;
851 virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, css::uno::Any& rValue ) override;
852
853 OUString referer_;
854};
855
856#endif
857
858/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/tools/weakbase.hxx

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#ifndef INCLUDED_TOOLS_WEAKBASE_HXX
21#define INCLUDED_TOOLS_WEAKBASE_HXX
22
23#include <tools/weakbase.h>
24
25/// see weakbase.h for documentation
26
27namespace tools
28{
29
30template< class reference_type >
31inline WeakReference< reference_type >::WeakReference()
32{
33 mpWeakConnection = new WeakConnection;
34}
35
36template< class reference_type >
37inline WeakReference< reference_type >::WeakReference( reference_type* pReference )
38{
39 reset( pReference );
40}
41
42template< class reference_type >
43inline WeakReference< reference_type >::WeakReference( const WeakReference< reference_type >& rWeakRef )
44{
45 mpWeakConnection = rWeakRef.mpWeakConnection;
46}
47
48template< class reference_type >
49inline WeakReference< reference_type >::WeakReference( WeakReference< reference_type >&& rWeakRef )
50{
51 mpWeakConnection = std::move(rWeakRef.mpWeakConnection);
52 rWeakRef.reset();
53}
54
55template< class reference_type >
56inline bool WeakReference< reference_type >::is() const
57{
58 return mpWeakConnection->mpReference != nullptr;
59}
60
61template< class reference_type >
62inline reference_type * WeakReference< reference_type >::get() const
63{
64 auto pWeakBase = mpWeakConnection->mpReference;
65 if (!pWeakBase)
6
Assuming 'pWeakBase' is non-null, which participates in a condition later
7
Taking false branch
66 return nullptr;
67 assert(dynamic_cast<reference_type *>(pWeakBase))(static_cast <bool> (dynamic_cast<reference_type *>
(pWeakBase)) ? void (0) : __assert_fail ("dynamic_cast<reference_type *>(pWeakBase)"
, "/home/maarten/src/libreoffice/core/include/tools/weakbase.hxx"
, 67, __extension__ __PRETTY_FUNCTION__))
;
8
'?' condition is true
68 return static_cast<reference_type *>(pWeakBase);
9
Returning pointer (loaded from 'pWeakBase'), which participates in a condition later
69}
70
71template< class reference_type >
72inline void WeakReference< reference_type >::reset( reference_type* pReference )
73{
74 if( pReference )
75 mpWeakConnection = pReference->getWeakConnection();
76 else
77 reset();
78}
79
80template< class reference_type >
81inline void WeakReference< reference_type >::reset()
82{
83 mpWeakConnection = new WeakConnection;
84}
85
86template< class reference_type >
87inline reference_type * WeakReference< reference_type >::operator->() const
88{
89 return get();
90}
91
92template< class reference_type >
93inline reference_type& WeakReference< reference_type >::operator*() const
94{
95 return *get();
96}
97
98template< class reference_type >
99inline bool WeakReference< reference_type >::operator==(const reference_type * pReferenceObject) const
100{
101 return mpWeakConnection->mpReference == pReferenceObject;
102}
103
104template< class reference_type >
105inline bool WeakReference< reference_type >::operator==(const WeakReference<reference_type> & handle) const
106{
107 return mpWeakConnection == handle.mpWeakConnection;
108}
109
110template< class reference_type >
111inline bool WeakReference< reference_type >::operator!=(const WeakReference<reference_type> & handle) const
112{
113 return mpWeakConnection != handle.mpWeakConnection;
114}
115
116template< class reference_type >
117inline bool WeakReference< reference_type >::operator<(const WeakReference<reference_type> & handle) const
118{
119 return mpWeakConnection->mpReference < handle.mpWeakConnection->mpReference;
120}
121
122template< class reference_type >
123inline bool WeakReference< reference_type >::operator>(const WeakReference<reference_type> & handle) const
124{
125 return mpWeakConnection->mpReference > handle.mpWeakConnection->mpReference;
126}
127
128template< class reference_type >
129inline WeakReference<reference_type>& WeakReference<reference_type>::operator= (
130 const WeakReference<reference_type>& rReference)
131{
132 if (&rReference != this)
133 mpWeakConnection = rReference.mpWeakConnection;
134 return *this;
135}
136
137template< class reference_type >
138inline WeakReference<reference_type>& WeakReference<reference_type>::operator= (
139 WeakReference<reference_type>&& rReference)
140{
141 mpWeakConnection = std::move(rReference.mpWeakConnection);
142 return *this;
143}
144
145inline void WeakBase::clearWeak()
146{
147 if( mpWeakConnection.is() )
148 mpWeakConnection->mpReference = nullptr;
149}
150
151inline WeakConnection* WeakBase::getWeakConnection()
152{
153 if( !mpWeakConnection.is() )
154 mpWeakConnection = new WeakConnection( this );
155 return mpWeakConnection.get();
156}
157
158}
159
160#endif
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx

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
41extern "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
45namespace com
46{
47namespace sun
48{
49namespace star
50{
51namespace uno
52{
53
54
55inline Any::Any()
56{
57 ::uno_any_construct( this, NULL__null, NULL__null, cpp_acquire );
58}
59
60
61template <typename T>
62inline 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
70inline 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
79template<typename T1, typename T2>
80Any::Any(rtl::OUStringConcat<T1, T2> && value):
81 Any(rtl::OUString(std::move(value)))
82{}
83#endif
84
85inline Any::Any( const Any & rAny )
86{
87 ::uno_type_any_construct( this, rAny.pData, rAny.pType, cpp_acquire );
88}
89
90inline 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
97inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr )
98{
99 ::uno_any_construct(
100 this, const_cast< void * >( pData_ ), pTypeDescr, cpp_acquire );
101}
102
103inline 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
109inline Any::~Any()
110{
111 ::uno_any_destruct(
112 this, cpp_release );
113}
114
115inline 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
128namespace detail {
129
130inline 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
146Any::Any(Any && other) noexcept {
147 detail::moveAnyInternals(other, *this);
148}
149
150Any & 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
158inline ::rtl::OUString Any::getValueTypeName() const
159{
160 return ::rtl::OUString( pType->pTypeName );
161}
162
163inline 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
170inline 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
177inline 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
184inline void Any::clear()
185{
186 ::uno_any_clear(
187 this, cpp_release );
188}
189
190inline 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
198template <typename T>
199inline 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
209template<> bool Any::has<Any>() const = delete;
210#endif
211
212inline 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
219inline 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
227template< class C >
228inline Any SAL_CALL makeAny( const C & value )
229{
230 return Any(value);
231}
232
233#if !defined LIBO_INTERNAL_ONLY1
234template<> Any makeAny(sal_uInt16 const & value)
235{ return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); }
236#endif
237
238template<typename T> Any toAny(T const & value) { return makeAny(value); }
239
240template<> Any toAny(Any const & value) { return value; }
241
242#if defined LIBO_INTERNAL_ONLY1
243
244template<typename T1, typename T2>
245Any makeAny(rtl::OUStringConcat<T1, T2> && value)
246{ return Any(std::move(value)); }
247
248template<typename T1, typename T2>
249Any toAny(rtl::OUStringConcat<T1, T2> && value)
250{ return makeAny(std::move(value)); }
251
252template<typename T>
253Any makeAny(rtl::OUStringNumber<T> && value)
254{ return Any(OUString(std::move(value))); }
255
256template<typename T>
257Any toAny(rtl::OUStringNumber<T> && value)
258{ return makeAny(std::move(value)); }
259
260template<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
265template<> 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
273template< class C >
274inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
275{
276 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
277 ::uno_type_any_assign(
24
Value assigned to 'eClickAction', which participates in a condition later
278 &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
279 cpp_acquire, cpp_release );
280}
281
282// additionally for C++ bool:
283
284template<>
285inline 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"
295template< class C1, class C2 >
296inline 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}
304template<typename T1, typename T2>
305void operator <<=(Any &, rtl::OUStringConcat<T1, T2> const &) = delete;
306template< class C >
307inline 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}
315template<typename T>
316void operator <<=(Any &, rtl::OUStringNumber<T> const &) = delete;
317#endif
318
319#if defined LIBO_INTERNAL_ONLY1
320template<> void SAL_CALL operator <<=(Any &, Any const &) = delete;
321#endif
322
323template< class C >
324inline 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
336template<>
337inline 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
347template<>
348inline 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
355template<>
356inline 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
367template<>
368inline 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
377template<>
378inline 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
389template<>
390inline 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
406template<>
407inline 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
424template<>
425inline 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
447template<>
448inline 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
471template<>
472inline 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
500template<>
501inline 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
530template<>
531inline 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
553template<>
554inline 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
585template<>
586inline 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
596template<>
597inline 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
604template<>
605inline 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
615template<>
616inline 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
624template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete;
625#else
626template<>
627inline 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
640template<>
641inline 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
652template< class C >
653inline 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
663template< class C >
664inline bool SAL_CALL operator != ( const Any & rAny, const C & value )
665{
666 return (! operator == ( rAny, value ));
667}
668
669template <typename T>
670T 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
685template<> 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*/
694template<typename charT, typename traits>
695inline 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: */