1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "MediaDescriptorHelper.hxx"
31 
32 using namespace ::com::sun::star;
33 
34 namespace apphelper
35 {
36 
37 
38 const short FLAG_DEPRECATED	=1;
39 const short FLAG_MODEL		=2;
40 
41 #define WRITE_PROPERTY( MediaName, nFlags )				\
42 if(rProp.Name.equals(::rtl::OUString::createFromAscii(#MediaName)))	\
43 {														\
44 	if( rProp.Value >>= MediaName )						\
45 		ISSET_##MediaName = sal_True;					\
46 	if(nFlags & FLAG_DEPRECATED)						\
47 	{													\
48 		m_aDeprecatedProperties[nDeprecatedCount]=rProp;\
49 		nDeprecatedCount++;								\
50 	}													\
51 	else												\
52 	{													\
53 		m_aRegularProperties[nRegularCount]=rProp;		\
54 		nRegularCount++;								\
55 		if( nFlags & FLAG_MODEL)						\
56 		{												\
57 			m_aModelProperties[nModelCount]=rProp;		\
58 			nModelCount++;								\
59 		}												\
60 	}													\
61 }
62 
63 MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence<
64 						beans::PropertyValue > & rMediaDescriptor )
65 {
66 	impl_init();
67 
68 	m_aRegularProperties.realloc(0);
69 	m_aRegularProperties.realloc(rMediaDescriptor.getLength());
70 	sal_Int32 nRegularCount = 0;
71 
72 	m_aDeprecatedProperties.realloc(0);
73 	m_aDeprecatedProperties.realloc(rMediaDescriptor.getLength());
74 	sal_Int32 nDeprecatedCount = 0;
75 
76 	m_aAdditionalProperties.realloc(0);
77 	m_aAdditionalProperties.realloc(rMediaDescriptor.getLength());
78 	sal_Int32 nAdditionalCount = 0;
79 
80 	m_aModelProperties.realloc(0);
81 	m_aModelProperties.realloc(rMediaDescriptor.getLength());
82 	sal_Int32 nModelCount = 0;
83 
84 
85 	//read given rMediaDescriptor and store in internal structures:
86 	for( sal_Int32 i= rMediaDescriptor.getLength();i--;)
87 	{
88 		const beans::PropertyValue& rProp = rMediaDescriptor[i];
89 		WRITE_PROPERTY( AsTemplate, FLAG_MODEL )
90 		else WRITE_PROPERTY( Author, FLAG_MODEL )
91 		else WRITE_PROPERTY( CharacterSet, FLAG_MODEL )
92 		else WRITE_PROPERTY( Comment, FLAG_MODEL )
93 		else WRITE_PROPERTY( ComponentData, FLAG_MODEL )
94 		else WRITE_PROPERTY( FileName, FLAG_DEPRECATED )
95 		else WRITE_PROPERTY( FilterData, FLAG_MODEL )
96 		else WRITE_PROPERTY( FilterName, FLAG_MODEL )
97 		else WRITE_PROPERTY( FilterFlags, FLAG_DEPRECATED)
98 		else WRITE_PROPERTY( FilterOptions, FLAG_MODEL )
99 		else WRITE_PROPERTY( FrameName, FLAG_MODEL )
100 		else WRITE_PROPERTY( Hidden, FLAG_MODEL )
101         else WRITE_PROPERTY( HierarchicalDocumentName, FLAG_MODEL )
102         else WRITE_PROPERTY( OutputStream, 0 )
103 		else WRITE_PROPERTY( InputStream, 0 )
104 		else WRITE_PROPERTY( InteractionHandler, 0 )
105 		else WRITE_PROPERTY( JumpMark, 0 )
106 		else WRITE_PROPERTY( MediaType, FLAG_MODEL )
107 		else WRITE_PROPERTY( OpenFlags, FLAG_DEPRECATED )
108 		else WRITE_PROPERTY( OpenNewView, 0 )
109 		else WRITE_PROPERTY( Overwrite, FLAG_MODEL )
110 		else WRITE_PROPERTY( Password, FLAG_MODEL )
111 		else WRITE_PROPERTY( PosSize, 0 )
112 		else WRITE_PROPERTY( PostData, 0 )
113 		else WRITE_PROPERTY( PostString, FLAG_DEPRECATED )
114 		else WRITE_PROPERTY( Preview, FLAG_MODEL )
115 		else WRITE_PROPERTY( ReadOnly, 0 )
116 		else WRITE_PROPERTY( Referer, FLAG_MODEL )
117 		else WRITE_PROPERTY( SetEmbedded, 0 )
118 		else WRITE_PROPERTY( Silent, 0 )
119 		else WRITE_PROPERTY( StatusIndicator, 0 )
120 		else WRITE_PROPERTY( Storage, FLAG_MODEL )
121 		else WRITE_PROPERTY( Stream, FLAG_MODEL )
122 		else WRITE_PROPERTY( TemplateName, FLAG_DEPRECATED )
123 		else WRITE_PROPERTY( TemplateRegionName, FLAG_DEPRECATED )
124 		else WRITE_PROPERTY( Unpacked, FLAG_MODEL )
125 		else WRITE_PROPERTY( URL, FLAG_MODEL )
126 		else WRITE_PROPERTY( Version, FLAG_MODEL )
127 		else WRITE_PROPERTY( ViewData, FLAG_MODEL )
128 		else WRITE_PROPERTY( ViewId, FLAG_MODEL )
129 		else WRITE_PROPERTY( WinExtent, FLAG_DEPRECATED )
130 		else
131 		{
132 			m_aAdditionalProperties[nAdditionalCount]=rProp;
133 			nAdditionalCount++;
134 		}
135 	}
136 
137 	m_aRegularProperties.realloc(nRegularCount);
138 	m_aDeprecatedProperties.realloc(nDeprecatedCount);
139 	m_aAdditionalProperties.realloc(nAdditionalCount);
140 	m_aModelProperties.realloc(nModelCount);
141 }
142 
143 void MediaDescriptorHelper::impl_init()
144 {
145 	AsTemplate = sal_False;
146 	ISSET_AsTemplate = sal_False;
147 
148 	ISSET_Author = sal_False;
149 	ISSET_CharacterSet = sal_False;
150 	ISSET_Comment = sal_False;
151 
152 //	::com::sun::star::uno::Any	ComponentData;
153 	ISSET_ComponentData = sal_False;
154 	ISSET_FileName = sal_False;
155 
156 //	::com::sun::star::uno::Any	FilterData;
157 	ISSET_FilterData = sal_False;
158 	ISSET_FilterName = sal_False;
159 	ISSET_FilterFlags = sal_False;
160 	ISSET_FilterOptions = sal_False;
161 	ISSET_FrameName = sal_False;
162 
163     Hidden = sal_False;
164 	ISSET_Hidden = sal_False;
165     ISSET_HierarchicalDocumentName = sal_False;
166     ISSET_OutputStream = sal_False;
167 	ISSET_InputStream = sal_False;
168 	ISSET_InteractionHandler = sal_False;
169 	ISSET_JumpMark = sal_False;
170 	ISSET_MediaType = sal_False;
171 	ISSET_OpenFlags = sal_False;
172 	OpenNewView = sal_False;
173 	ISSET_OpenNewView = sal_False;
174 	Overwrite = sal_False;
175 	ISSET_Overwrite = sal_False;
176 	ISSET_Password = sal_False;
177 
178 //	::com::sun::star::awt::Rectangle PosSize;
179 	ISSET_PosSize = sal_False;
180 
181 //	::com::sun::star::uno::Sequence< sal_Int8 > PostData;
182 	ISSET_PostData = sal_False;
183 	ISSET_PostString = sal_False;
184     Preview = sal_False;
185 	ISSET_Preview = sal_False;
186 	ReadOnly = sal_False;
187 	ISSET_ReadOnly = sal_False;
188 	ISSET_Referer = sal_False;
189 	ISSET_StatusIndicator = sal_False;
190     Silent = sal_False;
191 	ISSET_Silent = sal_False;
192 	ISSET_TemplateName = sal_False;
193 	ISSET_TemplateRegionName = sal_False;
194 	Unpacked = sal_False;
195 	ISSET_Unpacked = sal_False;
196 	ISSET_URL = sal_False;
197 	Version = 0;
198 	ISSET_Version = sal_False;
199 
200 //	::com::sun::star::uno::Any ViewData;
201 	ISSET_ViewData = sal_False;
202 	ViewId = 0;
203 	ISSET_ViewId = sal_False;
204 
205     ISSET_WinExtent = sal_False;
206 
207     ISSET_Storage = sal_False;
208     ISSET_Stream = sal_False;
209 }
210 
211 MediaDescriptorHelper::~MediaDescriptorHelper()
212 {
213 
214 }
215 
216 	uno::Sequence< beans::PropertyValue > MediaDescriptorHelper
217 ::getReducedForModel()
218 {
219 	return m_aModelProperties;
220 }
221 }
222