/src/libreoffice/chart2/source/tools/MediaDescriptorHelper.cxx
Line | Count | Source |
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 <MediaDescriptorHelper.hxx> |
21 | | #include <com/sun/star/beans/PropertyValue.hpp> |
22 | | #include <com/sun/star/embed/XStorage.hpp> |
23 | | #include <com/sun/star/uno/Sequence.hxx> |
24 | | #include <com/sun/star/uno/Any.hxx> |
25 | | #include <com/sun/star/uno/Reference.hxx> |
26 | | |
27 | | using namespace ::com::sun::star; |
28 | | |
29 | | namespace apphelper |
30 | | { |
31 | | |
32 | | MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence< |
33 | | beans::PropertyValue > & rMediaDescriptor ) |
34 | 0 | : m_aModelProperties(rMediaDescriptor.getLength()) |
35 | 0 | { |
36 | 0 | auto aModelPropertiesRange = asNonConstRange(m_aModelProperties); |
37 | 0 | css::uno::Sequence< css::beans::PropertyValue > |
38 | 0 | aRegularProperties(rMediaDescriptor.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated |
39 | 0 | auto aRegularPropertiesRange = asNonConstRange(aRegularProperties); |
40 | 0 | impl_init(); |
41 | 0 | sal_Int32 nRegularCount = 0; |
42 | 0 | sal_Int32 nModelCount = 0; |
43 | |
|
44 | 0 | auto addRegularProp = [&aRegularPropertiesRange, &nRegularCount](const beans::PropertyValue& rRegularProp) |
45 | 0 | { |
46 | 0 | aRegularPropertiesRange[nRegularCount] = rRegularProp; |
47 | 0 | ++nRegularCount; |
48 | 0 | }; |
49 | 0 | auto addModelProp = [&aModelPropertiesRange, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp) |
50 | 0 | { |
51 | 0 | addRegularProp(rModelProp); |
52 | 0 | aModelPropertiesRange[nModelCount] = rModelProp; |
53 | 0 | ++nModelCount; |
54 | 0 | }; |
55 | | |
56 | | //read given rMediaDescriptor and store in internal structures: |
57 | 0 | for( const beans::PropertyValue& rProp : rMediaDescriptor) |
58 | 0 | { |
59 | 0 | if (rProp.Name == "AsTemplate") |
60 | 0 | { |
61 | 0 | addModelProp(rProp); |
62 | 0 | } |
63 | 0 | else if (rProp.Name == "Author") |
64 | 0 | { |
65 | 0 | addModelProp(rProp); |
66 | 0 | } |
67 | 0 | else if (rProp.Name == "CharacterSet") |
68 | 0 | { |
69 | 0 | addModelProp(rProp); |
70 | 0 | } |
71 | 0 | else if (rProp.Name == "Comment") |
72 | 0 | { |
73 | 0 | addModelProp(rProp); |
74 | 0 | } |
75 | 0 | else if (rProp.Name == "ComponentData") |
76 | 0 | { |
77 | 0 | addModelProp(rProp); |
78 | 0 | } |
79 | 0 | else if (rProp.Name == "FilterData") |
80 | 0 | { |
81 | 0 | addModelProp(rProp); |
82 | 0 | } |
83 | 0 | else if (rProp.Name == "FilterName") |
84 | 0 | { |
85 | 0 | ISSET_FilterName = rProp.Value >>= FilterName; |
86 | 0 | addModelProp(rProp); |
87 | 0 | } |
88 | 0 | else if (rProp.Name == "FilterOptions") |
89 | 0 | { |
90 | 0 | addModelProp(rProp); |
91 | 0 | } |
92 | 0 | else if (rProp.Name == "FrameName") |
93 | 0 | { |
94 | 0 | addModelProp(rProp); |
95 | 0 | } |
96 | 0 | else if (rProp.Name == "Hidden") |
97 | 0 | { |
98 | 0 | addModelProp(rProp); |
99 | 0 | } |
100 | 0 | else if (rProp.Name == "HierarchicalDocumentName") |
101 | 0 | { |
102 | 0 | rProp.Value >>= HierarchicalDocumentName; |
103 | 0 | addModelProp(rProp); |
104 | 0 | } |
105 | 0 | else if (rProp.Name == "OutputStream") |
106 | 0 | { |
107 | 0 | ISSET_OutputStream = rProp.Value >>= OutputStream; |
108 | 0 | addRegularProp(rProp); |
109 | 0 | } |
110 | 0 | else if (rProp.Name == "InputStream") |
111 | 0 | { |
112 | 0 | ISSET_InputStream = rProp.Value >>= InputStream; |
113 | 0 | addRegularProp(rProp); |
114 | 0 | } |
115 | 0 | else if (rProp.Name == "InteractionHandler") |
116 | 0 | { |
117 | 0 | addRegularProp(rProp); |
118 | 0 | } |
119 | 0 | else if (rProp.Name == "JumpMark") |
120 | 0 | { |
121 | 0 | addRegularProp(rProp); |
122 | 0 | } |
123 | 0 | else if (rProp.Name == "MediaType") |
124 | 0 | { |
125 | 0 | addModelProp(rProp); |
126 | 0 | } |
127 | 0 | else if (rProp.Name == "OpenNewView") |
128 | 0 | { |
129 | 0 | addRegularProp(rProp); |
130 | 0 | } |
131 | 0 | else if (rProp.Name == "Overwrite") |
132 | 0 | { |
133 | 0 | addModelProp(rProp); |
134 | 0 | } |
135 | 0 | else if (rProp.Name == "Password") |
136 | 0 | { |
137 | 0 | addModelProp(rProp); |
138 | 0 | } |
139 | 0 | else if (rProp.Name == "PosSize") |
140 | 0 | { |
141 | 0 | addRegularProp(rProp); |
142 | 0 | } |
143 | 0 | else if (rProp.Name == "PostData") |
144 | 0 | { |
145 | 0 | addRegularProp(rProp); |
146 | 0 | } |
147 | 0 | else if (rProp.Name == "Preview") |
148 | 0 | { |
149 | 0 | addModelProp(rProp); |
150 | 0 | } |
151 | 0 | else if (rProp.Name == "ReadOnly") |
152 | 0 | { |
153 | 0 | rProp.Value >>= ReadOnly; |
154 | 0 | addRegularProp(rProp); |
155 | 0 | } |
156 | 0 | else if (rProp.Name == "Referer") |
157 | 0 | { |
158 | 0 | addModelProp(rProp); |
159 | 0 | } |
160 | 0 | else if (rProp.Name == "SetEmbedded") |
161 | 0 | { |
162 | 0 | addRegularProp(rProp); |
163 | 0 | } |
164 | 0 | else if (rProp.Name == "Silent") |
165 | 0 | { |
166 | 0 | addRegularProp(rProp); |
167 | 0 | } |
168 | 0 | else if (rProp.Name == "StatusIndicator") |
169 | 0 | { |
170 | 0 | addRegularProp(rProp); |
171 | 0 | } |
172 | 0 | else if (rProp.Name == "Storage") |
173 | 0 | { |
174 | 0 | ISSET_Storage = rProp.Value >>= Storage; |
175 | 0 | addModelProp(rProp); |
176 | 0 | } |
177 | 0 | else if (rProp.Name == "Stream") |
178 | 0 | { |
179 | 0 | ISSET_Stream = rProp.Value >>= Stream; |
180 | 0 | addModelProp(rProp); |
181 | 0 | } |
182 | 0 | else if (rProp.Name == "Unpacked") |
183 | 0 | { |
184 | 0 | addModelProp(rProp); |
185 | 0 | } |
186 | 0 | else if (rProp.Name == "URL") |
187 | 0 | { |
188 | 0 | ISSET_URL = rProp.Value >>= URL; |
189 | 0 | addModelProp(rProp); |
190 | 0 | } |
191 | 0 | else if (rProp.Name == "Version") |
192 | 0 | { |
193 | 0 | addModelProp(rProp); |
194 | 0 | } |
195 | 0 | else if (rProp.Name == "ViewData") |
196 | 0 | { |
197 | 0 | addModelProp(rProp); |
198 | 0 | } |
199 | 0 | else if (rProp.Name == "ViewId") |
200 | 0 | { |
201 | 0 | addModelProp(rProp); |
202 | 0 | } |
203 | 0 | } |
204 | |
|
205 | 0 | aRegularProperties.realloc(nRegularCount); |
206 | 0 | m_aModelProperties.realloc(nModelCount); |
207 | 0 | } |
208 | | |
209 | | void MediaDescriptorHelper::impl_init() |
210 | 0 | { |
211 | 0 | ISSET_FilterName = false; |
212 | |
|
213 | 0 | ISSET_OutputStream = false; |
214 | 0 | ISSET_InputStream = false; |
215 | |
|
216 | 0 | ReadOnly = false; |
217 | 0 | ISSET_URL = false; |
218 | |
|
219 | 0 | ISSET_Storage = false; |
220 | 0 | ISSET_Stream = false; |
221 | 0 | } |
222 | | |
223 | | } |
224 | | |
225 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |