Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / tools / MediaDescriptorHelper.cxx
blobab5de9574667d7f7734c698ef59724fc5710596d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 using namespace ::com::sun::star;
29 namespace apphelper
32 MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence<
33 beans::PropertyValue > & rMediaDescriptor )
34 : m_aModelProperties(rMediaDescriptor.getLength())
36 css::uno::Sequence< css::beans::PropertyValue >
37 aRegularProperties(rMediaDescriptor.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated
38 css::uno::Sequence< css::beans::PropertyValue >
39 aDeprecatedProperties(rMediaDescriptor.getLength()); //these are properties which are described in service com.sun.star.document.MediaDescriptor but are marked as deprecated
40 impl_init();
41 sal_Int32 nRegularCount = 0;
42 sal_Int32 nDeprecatedCount = 0;
43 sal_Int32 nModelCount = 0;
45 auto addRegularProp = [&aRegularProperties, &nRegularCount](const beans::PropertyValue& rRegularProp)
47 aRegularProperties[nRegularCount] = rRegularProp;
48 ++nRegularCount;
50 auto addModelProp = [this, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp)
52 addRegularProp(rModelProp);
53 m_aModelProperties[nModelCount] = rModelProp;
54 ++nModelCount;
56 auto addDepreciatedProp = [&aDeprecatedProperties, &nDeprecatedCount](const beans::PropertyValue& rDeprecatedProp)
58 aDeprecatedProperties[nDeprecatedCount] = rDeprecatedProp;
59 ++nDeprecatedCount;
62 //read given rMediaDescriptor and store in internal structures:
63 for( sal_Int32 i= rMediaDescriptor.getLength();i--;)
65 const beans::PropertyValue& rProp = rMediaDescriptor[i];
67 if (rProp.Name == "AsTemplate")
69 addModelProp(rProp);
71 else if (rProp.Name == "Author")
73 addModelProp(rProp);
75 else if (rProp.Name == "CharacterSet")
77 addModelProp(rProp);
79 else if (rProp.Name == "Comment")
81 addModelProp(rProp);
83 else if (rProp.Name == "ComponentData")
85 addModelProp(rProp);
87 else if (rProp.Name == "FileName")
89 addDepreciatedProp(rProp);
91 else if (rProp.Name == "FilterData")
93 addModelProp(rProp);
95 else if (rProp.Name == "FilterName")
97 ISSET_FilterName = rProp.Value >>= FilterName;
98 addModelProp(rProp);
100 else if (rProp.Name == "FilterFlags")
102 addDepreciatedProp(rProp);
104 else if (rProp.Name == "FilterOptions")
106 addModelProp(rProp);
108 else if (rProp.Name == "FrameName")
110 addModelProp(rProp);
112 else if (rProp.Name == "Hidden")
114 addModelProp(rProp);
116 else if (rProp.Name == "HierarchicalDocumentName")
118 rProp.Value >>= HierarchicalDocumentName;
119 addModelProp(rProp);
121 else if (rProp.Name == "OutputStream")
123 ISSET_OutputStream = rProp.Value >>= OutputStream;
124 addRegularProp(rProp);
126 else if (rProp.Name == "InputStream")
128 ISSET_InputStream = rProp.Value >>= InputStream;
129 addRegularProp(rProp);
131 else if (rProp.Name == "InteractionHandler")
133 addRegularProp(rProp);
135 else if (rProp.Name == "JumpMark")
137 addRegularProp(rProp);
139 else if (rProp.Name == "MediaType")
141 addModelProp(rProp);
143 else if (rProp.Name == "OpenFlags")
145 addDepreciatedProp(rProp);
147 else if (rProp.Name == "OpenNewView")
149 addRegularProp(rProp);
151 else if (rProp.Name == "Overwrite")
153 addModelProp(rProp);
155 else if (rProp.Name == "Password")
157 addModelProp(rProp);
159 else if (rProp.Name == "PosSize")
161 addRegularProp(rProp);
163 else if (rProp.Name == "PostData")
165 addRegularProp(rProp);
167 else if (rProp.Name == "PostString")
169 addDepreciatedProp(rProp);
171 else if (rProp.Name == "Preview")
173 addModelProp(rProp);
175 else if (rProp.Name == "ReadOnly")
177 rProp.Value >>= ReadOnly;
178 addRegularProp(rProp);
180 else if (rProp.Name == "Referer")
182 addModelProp(rProp);
184 else if (rProp.Name == "SetEmbedded")
186 addRegularProp(rProp);
188 else if (rProp.Name == "Silent")
190 addRegularProp(rProp);
192 else if (rProp.Name == "StatusIndicator")
194 addRegularProp(rProp);
196 else if (rProp.Name == "Storage")
198 ISSET_Storage = rProp.Value >>= Storage;
199 addModelProp(rProp);
201 else if (rProp.Name == "Stream")
203 ISSET_Stream = rProp.Value >>= Stream;
204 addModelProp(rProp);
206 else if (rProp.Name == "TemplateName")
208 addDepreciatedProp(rProp);
210 else if (rProp.Name == "TemplateRegionName")
212 addDepreciatedProp(rProp);
214 else if (rProp.Name == "Unpacked")
216 addModelProp(rProp);
218 else if (rProp.Name == "URL")
220 ISSET_URL = rProp.Value >>= URL;
221 addModelProp(rProp);
223 else if (rProp.Name == "Version")
225 addModelProp(rProp);
227 else if (rProp.Name == "ViewData")
229 addModelProp(rProp);
231 else if (rProp.Name == "ViewId")
233 addModelProp(rProp);
235 else if (rProp.Name == "WinExtent")
237 addDepreciatedProp(rProp);
241 aRegularProperties.realloc(nRegularCount);
242 aDeprecatedProperties.realloc(nDeprecatedCount);
243 m_aModelProperties.realloc(nModelCount);
246 void MediaDescriptorHelper::impl_init()
248 ISSET_FilterName = false;
250 ISSET_OutputStream = false;
251 ISSET_InputStream = false;
253 ReadOnly = false;
254 ISSET_URL = false;
256 ISSET_Storage = false;
257 ISSET_Stream = false;
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */