1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
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
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
;
50 auto addModelProp
= [this, &nModelCount
, &addRegularProp
](const beans::PropertyValue
& rModelProp
)
52 addRegularProp(rModelProp
);
53 m_aModelProperties
[nModelCount
] = rModelProp
;
56 auto addDepreciatedProp
= [&aDeprecatedProperties
, &nDeprecatedCount
](const beans::PropertyValue
& rDeprecatedProp
)
58 aDeprecatedProperties
[nDeprecatedCount
] = rDeprecatedProp
;
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")
71 else if (rProp
.Name
== "Author")
75 else if (rProp
.Name
== "CharacterSet")
79 else if (rProp
.Name
== "Comment")
83 else if (rProp
.Name
== "ComponentData")
87 else if (rProp
.Name
== "FileName")
89 addDepreciatedProp(rProp
);
91 else if (rProp
.Name
== "FilterData")
95 else if (rProp
.Name
== "FilterName")
97 ISSET_FilterName
= rProp
.Value
>>= FilterName
;
100 else if (rProp
.Name
== "FilterFlags")
102 addDepreciatedProp(rProp
);
104 else if (rProp
.Name
== "FilterOptions")
108 else if (rProp
.Name
== "FrameName")
112 else if (rProp
.Name
== "Hidden")
116 else if (rProp
.Name
== "HierarchicalDocumentName")
118 rProp
.Value
>>= HierarchicalDocumentName
;
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")
143 else if (rProp
.Name
== "OpenFlags")
145 addDepreciatedProp(rProp
);
147 else if (rProp
.Name
== "OpenNewView")
149 addRegularProp(rProp
);
151 else if (rProp
.Name
== "Overwrite")
155 else if (rProp
.Name
== "Password")
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")
175 else if (rProp
.Name
== "ReadOnly")
177 rProp
.Value
>>= ReadOnly
;
178 addRegularProp(rProp
);
180 else if (rProp
.Name
== "Referer")
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
;
201 else if (rProp
.Name
== "Stream")
203 ISSET_Stream
= rProp
.Value
>>= Stream
;
206 else if (rProp
.Name
== "TemplateName")
208 addDepreciatedProp(rProp
);
210 else if (rProp
.Name
== "TemplateRegionName")
212 addDepreciatedProp(rProp
);
214 else if (rProp
.Name
== "Unpacked")
218 else if (rProp
.Name
== "URL")
220 ISSET_URL
= rProp
.Value
>>= URL
;
223 else if (rProp
.Name
== "Version")
227 else if (rProp
.Name
== "ViewData")
231 else if (rProp
.Name
== "ViewId")
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;
256 ISSET_Storage
= false;
257 ISSET_Stream
= false;
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */