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 auto aModelPropertiesRange
= asNonConstRange(m_aModelProperties
);
37 css::uno::Sequence
< css::beans::PropertyValue
>
38 aRegularProperties(rMediaDescriptor
.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated
39 auto aRegularPropertiesRange
= asNonConstRange(aRegularProperties
);
41 sal_Int32 nRegularCount
= 0;
42 sal_Int32 nModelCount
= 0;
44 auto addRegularProp
= [&aRegularPropertiesRange
, &nRegularCount
](const beans::PropertyValue
& rRegularProp
)
46 aRegularPropertiesRange
[nRegularCount
] = rRegularProp
;
49 auto addModelProp
= [&aModelPropertiesRange
, &nModelCount
, &addRegularProp
](const beans::PropertyValue
& rModelProp
)
51 addRegularProp(rModelProp
);
52 aModelPropertiesRange
[nModelCount
] = rModelProp
;
56 //read given rMediaDescriptor and store in internal structures:
57 for( const beans::PropertyValue
& rProp
: rMediaDescriptor
)
59 if (rProp
.Name
== "AsTemplate")
63 else if (rProp
.Name
== "Author")
67 else if (rProp
.Name
== "CharacterSet")
71 else if (rProp
.Name
== "Comment")
75 else if (rProp
.Name
== "ComponentData")
79 else if (rProp
.Name
== "FilterData")
83 else if (rProp
.Name
== "FilterName")
85 ISSET_FilterName
= rProp
.Value
>>= FilterName
;
88 else if (rProp
.Name
== "FilterOptions")
92 else if (rProp
.Name
== "FrameName")
96 else if (rProp
.Name
== "Hidden")
100 else if (rProp
.Name
== "HierarchicalDocumentName")
102 rProp
.Value
>>= HierarchicalDocumentName
;
105 else if (rProp
.Name
== "OutputStream")
107 ISSET_OutputStream
= rProp
.Value
>>= OutputStream
;
108 addRegularProp(rProp
);
110 else if (rProp
.Name
== "InputStream")
112 ISSET_InputStream
= rProp
.Value
>>= InputStream
;
113 addRegularProp(rProp
);
115 else if (rProp
.Name
== "InteractionHandler")
117 addRegularProp(rProp
);
119 else if (rProp
.Name
== "JumpMark")
121 addRegularProp(rProp
);
123 else if (rProp
.Name
== "MediaType")
127 else if (rProp
.Name
== "OpenNewView")
129 addRegularProp(rProp
);
131 else if (rProp
.Name
== "Overwrite")
135 else if (rProp
.Name
== "Password")
139 else if (rProp
.Name
== "PosSize")
141 addRegularProp(rProp
);
143 else if (rProp
.Name
== "PostData")
145 addRegularProp(rProp
);
147 else if (rProp
.Name
== "Preview")
151 else if (rProp
.Name
== "ReadOnly")
153 rProp
.Value
>>= ReadOnly
;
154 addRegularProp(rProp
);
156 else if (rProp
.Name
== "Referer")
160 else if (rProp
.Name
== "SetEmbedded")
162 addRegularProp(rProp
);
164 else if (rProp
.Name
== "Silent")
166 addRegularProp(rProp
);
168 else if (rProp
.Name
== "StatusIndicator")
170 addRegularProp(rProp
);
172 else if (rProp
.Name
== "Storage")
174 ISSET_Storage
= rProp
.Value
>>= Storage
;
177 else if (rProp
.Name
== "Stream")
179 ISSET_Stream
= rProp
.Value
>>= Stream
;
182 else if (rProp
.Name
== "Unpacked")
186 else if (rProp
.Name
== "URL")
188 ISSET_URL
= rProp
.Value
>>= URL
;
191 else if (rProp
.Name
== "Version")
195 else if (rProp
.Name
== "ViewData")
199 else if (rProp
.Name
== "ViewId")
205 aRegularProperties
.realloc(nRegularCount
);
206 m_aModelProperties
.realloc(nModelCount
);
209 void MediaDescriptorHelper::impl_init()
211 ISSET_FilterName
= false;
213 ISSET_OutputStream
= false;
214 ISSET_InputStream
= false;
219 ISSET_Storage
= false;
220 ISSET_Stream
= false;
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */