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"
22 using namespace ::com::sun::star
;
28 const short FLAG_DEPRECATED
=1;
29 const short FLAG_MODEL
=2;
31 #define WRITE_PROPERTY( MediaName, nFlags ) \
32 if(rProp.Name.equals(#MediaName)) \
34 if( rProp.Value >>= MediaName ) \
35 ISSET_##MediaName = sal_True; \
36 if(nFlags & FLAG_DEPRECATED) \
38 m_aDeprecatedProperties[nDeprecatedCount]=rProp;\
43 m_aRegularProperties[nRegularCount]=rProp; \
45 if( nFlags & FLAG_MODEL) \
47 m_aModelProperties[nModelCount]=rProp; \
53 MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence
<
54 beans::PropertyValue
> & rMediaDescriptor
)
58 m_aRegularProperties
.realloc(0);
59 m_aRegularProperties
.realloc(rMediaDescriptor
.getLength());
60 sal_Int32 nRegularCount
= 0;
62 m_aDeprecatedProperties
.realloc(0);
63 m_aDeprecatedProperties
.realloc(rMediaDescriptor
.getLength());
64 sal_Int32 nDeprecatedCount
= 0;
66 m_aAdditionalProperties
.realloc(0);
67 m_aAdditionalProperties
.realloc(rMediaDescriptor
.getLength());
68 sal_Int32 nAdditionalCount
= 0;
70 m_aModelProperties
.realloc(0);
71 m_aModelProperties
.realloc(rMediaDescriptor
.getLength());
72 sal_Int32 nModelCount
= 0;
75 //read given rMediaDescriptor and store in internal structures:
76 for( sal_Int32 i
= rMediaDescriptor
.getLength();i
--;)
78 const beans::PropertyValue
& rProp
= rMediaDescriptor
[i
];
79 WRITE_PROPERTY( AsTemplate
, FLAG_MODEL
)
80 else WRITE_PROPERTY( Author
, FLAG_MODEL
)
81 else WRITE_PROPERTY( CharacterSet
, FLAG_MODEL
)
82 else WRITE_PROPERTY( Comment
, FLAG_MODEL
)
83 else WRITE_PROPERTY( ComponentData
, FLAG_MODEL
)
84 else WRITE_PROPERTY( FileName
, FLAG_DEPRECATED
)
85 else WRITE_PROPERTY( FilterData
, FLAG_MODEL
)
86 else WRITE_PROPERTY( FilterName
, FLAG_MODEL
)
87 else WRITE_PROPERTY( FilterFlags
, FLAG_DEPRECATED
)
88 else WRITE_PROPERTY( FilterOptions
, FLAG_MODEL
)
89 else WRITE_PROPERTY( FrameName
, FLAG_MODEL
)
90 else WRITE_PROPERTY( Hidden
, FLAG_MODEL
)
91 else WRITE_PROPERTY( HierarchicalDocumentName
, FLAG_MODEL
)
92 else WRITE_PROPERTY( OutputStream
, 0 )
93 else WRITE_PROPERTY( InputStream
, 0 )
94 else WRITE_PROPERTY( InteractionHandler
, 0 )
95 else WRITE_PROPERTY( JumpMark
, 0 )
96 else WRITE_PROPERTY( MediaType
, FLAG_MODEL
)
97 else WRITE_PROPERTY( OpenFlags
, FLAG_DEPRECATED
)
98 else WRITE_PROPERTY( OpenNewView
, 0 )
99 else WRITE_PROPERTY( Overwrite
, FLAG_MODEL
)
100 else WRITE_PROPERTY( Password
, FLAG_MODEL
)
101 else WRITE_PROPERTY( PosSize
, 0 )
102 else WRITE_PROPERTY( PostData
, 0 )
103 else WRITE_PROPERTY( PostString
, FLAG_DEPRECATED
)
104 else WRITE_PROPERTY( Preview
, FLAG_MODEL
)
105 else WRITE_PROPERTY( ReadOnly
, 0 )
106 else WRITE_PROPERTY( Referer
, FLAG_MODEL
)
107 else WRITE_PROPERTY( SetEmbedded
, 0 )
108 else WRITE_PROPERTY( Silent
, 0 )
109 else WRITE_PROPERTY( StatusIndicator
, 0 )
110 else WRITE_PROPERTY( Storage
, FLAG_MODEL
)
111 else WRITE_PROPERTY( Stream
, FLAG_MODEL
)
112 else WRITE_PROPERTY( TemplateName
, FLAG_DEPRECATED
)
113 else WRITE_PROPERTY( TemplateRegionName
, FLAG_DEPRECATED
)
114 else WRITE_PROPERTY( Unpacked
, FLAG_MODEL
)
115 else WRITE_PROPERTY( URL
, FLAG_MODEL
)
116 else WRITE_PROPERTY( Version
, FLAG_MODEL
)
117 else WRITE_PROPERTY( ViewData
, FLAG_MODEL
)
118 else WRITE_PROPERTY( ViewId
, FLAG_MODEL
)
119 else WRITE_PROPERTY( WinExtent
, FLAG_DEPRECATED
)
122 m_aAdditionalProperties
[nAdditionalCount
]=rProp
;
127 m_aRegularProperties
.realloc(nRegularCount
);
128 m_aDeprecatedProperties
.realloc(nDeprecatedCount
);
129 m_aAdditionalProperties
.realloc(nAdditionalCount
);
130 m_aModelProperties
.realloc(nModelCount
);
133 void MediaDescriptorHelper::impl_init()
135 AsTemplate
= sal_False
;
136 ISSET_AsTemplate
= sal_False
;
138 ISSET_Author
= sal_False
;
139 ISSET_CharacterSet
= sal_False
;
140 ISSET_Comment
= sal_False
;
142 // ::com::sun::star::uno::Any ComponentData;
143 ISSET_ComponentData
= sal_False
;
144 ISSET_FileName
= sal_False
;
146 // ::com::sun::star::uno::Any FilterData;
147 ISSET_FilterData
= sal_False
;
148 ISSET_FilterName
= sal_False
;
149 ISSET_FilterFlags
= sal_False
;
150 ISSET_FilterOptions
= sal_False
;
151 ISSET_FrameName
= sal_False
;
154 ISSET_Hidden
= sal_False
;
155 ISSET_HierarchicalDocumentName
= sal_False
;
156 ISSET_OutputStream
= sal_False
;
157 ISSET_InputStream
= sal_False
;
158 ISSET_InteractionHandler
= sal_False
;
159 ISSET_JumpMark
= sal_False
;
160 ISSET_MediaType
= sal_False
;
161 ISSET_OpenFlags
= sal_False
;
162 OpenNewView
= sal_False
;
163 ISSET_OpenNewView
= sal_False
;
164 Overwrite
= sal_False
;
165 ISSET_Overwrite
= sal_False
;
166 ISSET_Password
= sal_False
;
168 // ::com::sun::star::awt::Rectangle PosSize;
169 ISSET_PosSize
= sal_False
;
171 // ::com::sun::star::uno::Sequence< sal_Int8 > PostData;
172 ISSET_PostData
= sal_False
;
173 ISSET_PostString
= sal_False
;
175 ISSET_Preview
= sal_False
;
176 ReadOnly
= sal_False
;
177 ISSET_ReadOnly
= sal_False
;
178 ISSET_Referer
= sal_False
;
179 ISSET_StatusIndicator
= sal_False
;
181 ISSET_Silent
= sal_False
;
182 ISSET_TemplateName
= sal_False
;
183 ISSET_TemplateRegionName
= sal_False
;
184 Unpacked
= sal_False
;
185 ISSET_Unpacked
= sal_False
;
186 ISSET_URL
= sal_False
;
188 ISSET_Version
= sal_False
;
190 // ::com::sun::star::uno::Any ViewData;
191 ISSET_ViewData
= sal_False
;
193 ISSET_ViewId
= sal_False
;
195 ISSET_WinExtent
= sal_False
;
197 ISSET_Storage
= sal_False
;
198 ISSET_Stream
= sal_False
;
201 uno::Sequence
< beans::PropertyValue
> MediaDescriptorHelper
202 ::getReducedForModel()
204 return m_aModelProperties
;
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */