1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "MediaDescriptorHelper.hxx"
27 
28 using namespace ::com::sun::star;
29 
30 namespace apphelper
31 {
32 
33 
34 const short FLAG_DEPRECATED	=1;
35 const short FLAG_MODEL		=2;
36 
37 #define WRITE_PROPERTY( MediaName, nFlags )				\
38 if(rProp.Name.equals(::rtl::OUString::createFromAscii(#MediaName)))	\
39 {														\
40 	if( rProp.Value >>= MediaName )						\
41 		ISSET_##MediaName = sal_True;					\
42 	if(nFlags & FLAG_DEPRECATED)						\
43 	{													\
44 		m_aDeprecatedProperties[nDeprecatedCount]=rProp;\
45 		nDeprecatedCount++;								\
46 	}													\
47 	else												\
48 	{													\
49 		m_aRegularProperties[nRegularCount]=rProp;		\
50 		nRegularCount++;								\
51 		if( nFlags & FLAG_MODEL)						\
52 		{												\
53 			m_aModelProperties[nModelCount]=rProp;		\
54 			nModelCount++;								\
55 		}												\
56 	}													\
57 }
58 
MediaDescriptorHelper(const uno::Sequence<beans::PropertyValue> & rMediaDescriptor)59 MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence<
60 						beans::PropertyValue > & rMediaDescriptor )
61 {
62 	impl_init();
63 
64 	m_aRegularProperties.realloc(0);
65 	m_aRegularProperties.realloc(rMediaDescriptor.getLength());
66 	sal_Int32 nRegularCount = 0;
67 
68 	m_aDeprecatedProperties.realloc(0);
69 	m_aDeprecatedProperties.realloc(rMediaDescriptor.getLength());
70 	sal_Int32 nDeprecatedCount = 0;
71 
72 	m_aAdditionalProperties.realloc(0);
73 	m_aAdditionalProperties.realloc(rMediaDescriptor.getLength());
74 	sal_Int32 nAdditionalCount = 0;
75 
76 	m_aModelProperties.realloc(0);
77 	m_aModelProperties.realloc(rMediaDescriptor.getLength());
78 	sal_Int32 nModelCount = 0;
79 
80 
81 	//read given rMediaDescriptor and store in internal structures:
82 	for( sal_Int32 i= rMediaDescriptor.getLength();i--;)
83 	{
84 		const beans::PropertyValue& rProp = rMediaDescriptor[i];
85 		WRITE_PROPERTY( AsTemplate, FLAG_MODEL )
86 		else WRITE_PROPERTY( Author, FLAG_MODEL )
87 		else WRITE_PROPERTY( CharacterSet, FLAG_MODEL )
88 		else WRITE_PROPERTY( Comment, FLAG_MODEL )
89 		else WRITE_PROPERTY( ComponentData, FLAG_MODEL )
90 		else WRITE_PROPERTY( FileName, FLAG_DEPRECATED )
91 		else WRITE_PROPERTY( FilterData, FLAG_MODEL )
92 		else WRITE_PROPERTY( FilterName, FLAG_MODEL )
93 		else WRITE_PROPERTY( FilterFlags, FLAG_DEPRECATED)
94 		else WRITE_PROPERTY( FilterOptions, FLAG_MODEL )
95 		else WRITE_PROPERTY( FrameName, FLAG_MODEL )
96 		else WRITE_PROPERTY( Hidden, FLAG_MODEL )
97         else WRITE_PROPERTY( HierarchicalDocumentName, FLAG_MODEL )
98         else WRITE_PROPERTY( OutputStream, 0 )
99 		else WRITE_PROPERTY( InputStream, 0 )
100 		else WRITE_PROPERTY( InteractionHandler, 0 )
101 		else WRITE_PROPERTY( JumpMark, 0 )
102 		else WRITE_PROPERTY( MediaType, FLAG_MODEL )
103 		else WRITE_PROPERTY( OpenFlags, FLAG_DEPRECATED )
104 		else WRITE_PROPERTY( OpenNewView, 0 )
105 		else WRITE_PROPERTY( Overwrite, FLAG_MODEL )
106 		else WRITE_PROPERTY( Password, FLAG_MODEL )
107 		else WRITE_PROPERTY( PosSize, 0 )
108 		else WRITE_PROPERTY( PostData, 0 )
109 		else WRITE_PROPERTY( PostString, FLAG_DEPRECATED )
110 		else WRITE_PROPERTY( Preview, FLAG_MODEL )
111 		else WRITE_PROPERTY( ReadOnly, 0 )
112 		else WRITE_PROPERTY( Referer, FLAG_MODEL )
113 		else WRITE_PROPERTY( SetEmbedded, 0 )
114 		else WRITE_PROPERTY( Silent, 0 )
115 		else WRITE_PROPERTY( StatusIndicator, 0 )
116 		else WRITE_PROPERTY( Storage, FLAG_MODEL )
117 		else WRITE_PROPERTY( Stream, FLAG_MODEL )
118 		else WRITE_PROPERTY( TemplateName, FLAG_DEPRECATED )
119 		else WRITE_PROPERTY( TemplateRegionName, FLAG_DEPRECATED )
120 		else WRITE_PROPERTY( Unpacked, FLAG_MODEL )
121 		else WRITE_PROPERTY( URL, FLAG_MODEL )
122 		else WRITE_PROPERTY( Version, FLAG_MODEL )
123 		else WRITE_PROPERTY( ViewData, FLAG_MODEL )
124 		else WRITE_PROPERTY( ViewId, FLAG_MODEL )
125 		else WRITE_PROPERTY( WinExtent, FLAG_DEPRECATED )
126 		else
127 		{
128 			m_aAdditionalProperties[nAdditionalCount]=rProp;
129 			nAdditionalCount++;
130 		}
131 	}
132 
133 	m_aRegularProperties.realloc(nRegularCount);
134 	m_aDeprecatedProperties.realloc(nDeprecatedCount);
135 	m_aAdditionalProperties.realloc(nAdditionalCount);
136 	m_aModelProperties.realloc(nModelCount);
137 }
138 
impl_init()139 void MediaDescriptorHelper::impl_init()
140 {
141 	AsTemplate = sal_False;
142 	ISSET_AsTemplate = sal_False;
143 
144 	ISSET_Author = sal_False;
145 	ISSET_CharacterSet = sal_False;
146 	ISSET_Comment = sal_False;
147 
148 //	::com::sun::star::uno::Any	ComponentData;
149 	ISSET_ComponentData = sal_False;
150 	ISSET_FileName = sal_False;
151 
152 //	::com::sun::star::uno::Any	FilterData;
153 	ISSET_FilterData = sal_False;
154 	ISSET_FilterName = sal_False;
155 	ISSET_FilterFlags = sal_False;
156 	ISSET_FilterOptions = sal_False;
157 	ISSET_FrameName = sal_False;
158 
159     Hidden = sal_False;
160 	ISSET_Hidden = sal_False;
161     ISSET_HierarchicalDocumentName = sal_False;
162     ISSET_OutputStream = sal_False;
163 	ISSET_InputStream = sal_False;
164 	ISSET_InteractionHandler = sal_False;
165 	ISSET_JumpMark = sal_False;
166 	ISSET_MediaType = sal_False;
167 	ISSET_OpenFlags = sal_False;
168 	OpenNewView = sal_False;
169 	ISSET_OpenNewView = sal_False;
170 	Overwrite = sal_False;
171 	ISSET_Overwrite = sal_False;
172 	ISSET_Password = sal_False;
173 
174 //	::com::sun::star::awt::Rectangle PosSize;
175 	ISSET_PosSize = sal_False;
176 
177 //	::com::sun::star::uno::Sequence< sal_Int8 > PostData;
178 	ISSET_PostData = sal_False;
179 	ISSET_PostString = sal_False;
180     Preview = sal_False;
181 	ISSET_Preview = sal_False;
182 	ReadOnly = sal_False;
183 	ISSET_ReadOnly = sal_False;
184 	ISSET_Referer = sal_False;
185 	ISSET_StatusIndicator = sal_False;
186     Silent = sal_False;
187 	ISSET_Silent = sal_False;
188 	ISSET_TemplateName = sal_False;
189 	ISSET_TemplateRegionName = sal_False;
190 	Unpacked = sal_False;
191 	ISSET_Unpacked = sal_False;
192 	ISSET_URL = sal_False;
193 	Version = 0;
194 	ISSET_Version = sal_False;
195 
196 //	::com::sun::star::uno::Any ViewData;
197 	ISSET_ViewData = sal_False;
198 	ViewId = 0;
199 	ISSET_ViewId = sal_False;
200 
201     ISSET_WinExtent = sal_False;
202 
203     ISSET_Storage = sal_False;
204     ISSET_Stream = sal_False;
205 }
206 
~MediaDescriptorHelper()207 MediaDescriptorHelper::~MediaDescriptorHelper()
208 {
209 
210 }
211 
212 	uno::Sequence< beans::PropertyValue > MediaDescriptorHelper
getReducedForModel()213 ::getReducedForModel()
214 {
215 	return m_aModelProperties;
216 }
217 }
218