1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63bba73cSAndrew Rist  * distributed with this work for additional information
6*63bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*63bba73cSAndrew Rist  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist  *
13*63bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist  * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63bba73cSAndrew Rist  * specific language governing permissions and limitations
18*63bba73cSAndrew Rist  * under the License.
19*63bba73cSAndrew Rist  *
20*63bba73cSAndrew Rist  *************************************************************/
21*63bba73cSAndrew Rist 
22*63bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include "propertyexport.hxx"
29cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
30cdf0e10cSrcweir #include "strings.hxx"
31cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
32cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
33cdf0e10cSrcweir #include <xmloff/families.hxx>
34cdf0e10cSrcweir #include <osl/diagnose.h>
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
36cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
37cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
38cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
39cdf0e10cSrcweir #include <osl/diagnose.h>
40cdf0e10cSrcweir #include <comphelper/extract.hxx>
41cdf0e10cSrcweir #include <comphelper/sequence.hxx>
42cdf0e10cSrcweir #include <comphelper/types.hxx>
43cdf0e10cSrcweir #include "callbacks.hxx"
44cdf0e10cSrcweir #include <unotools/datetime.hxx>
45cdf0e10cSrcweir #include <tools/date.hxx>
46cdf0e10cSrcweir #include <tools/time.hxx>
47cdf0e10cSrcweir #include <tools/datetime.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //.........................................................................
50cdf0e10cSrcweir namespace xmloff
51cdf0e10cSrcweir {
52cdf0e10cSrcweir //.........................................................................
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
55cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
56cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	// NO using namespace ...util !!!
59cdf0e10cSrcweir 	// need a tools Date/Time/DateTime below, which would conflict with the uno types then
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	using namespace ::comphelper;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	//=====================================================================
64cdf0e10cSrcweir 	//= OPropertyExport
65cdf0e10cSrcweir 	//=====================================================================
66cdf0e10cSrcweir 	//---------------------------------------------------------------------
OPropertyExport(IFormsExportContext & _rContext,const Reference<XPropertySet> & _rxProps)67cdf0e10cSrcweir 	OPropertyExport::OPropertyExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps)
68cdf0e10cSrcweir 		:m_rContext(_rContext)
69cdf0e10cSrcweir 		,m_xProps(_rxProps)
70cdf0e10cSrcweir         ,m_xPropertyInfo( m_xProps->getPropertySetInfo() )
71cdf0e10cSrcweir         ,m_xPropertyState( _rxProps, UNO_QUERY )
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir 		// caching
74cdf0e10cSrcweir 		::rtl::OUStringBuffer aBuffer;
75cdf0e10cSrcweir 		m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(aBuffer, sal_True);
76cdf0e10cSrcweir 		m_sValueTrue = aBuffer.makeStringAndClear();
77cdf0e10cSrcweir 		m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(aBuffer, sal_False);
78cdf0e10cSrcweir 		m_sValueFalse = aBuffer.makeStringAndClear();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		OSL_ENSURE(m_xPropertyInfo.is(), "OPropertyExport::OPropertyExport: need an XPropertySetInfo!");
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 		// collect the properties which need to be exported
83cdf0e10cSrcweir 		examinePersistence();
84cdf0e10cSrcweir 	}
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	//---------------------------------------------------------------------
shouldExportProperty(const::rtl::OUString & i_propertyName) const87cdf0e10cSrcweir     bool OPropertyExport::shouldExportProperty( const ::rtl::OUString& i_propertyName ) const
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir 		// if the property state is DEFAULT, it does not need to be written - at least
90cdf0e10cSrcweir         // if it's a built-in property, and not a dynamically-added one.
91cdf0e10cSrcweir         bool bIsDefaultValue =    m_xPropertyState.is()
92cdf0e10cSrcweir                             &&  ( PropertyState_DEFAULT_VALUE == m_xPropertyState->getPropertyState( i_propertyName ) );
93cdf0e10cSrcweir         bool bIsDynamicProperty =  m_xPropertyInfo.is()
94cdf0e10cSrcweir                                 && ( ( m_xPropertyInfo->getPropertyByName( i_propertyName ).Attributes & PropertyAttribute::REMOVEABLE ) != 0 );
95cdf0e10cSrcweir 		return ( !bIsDefaultValue || bIsDynamicProperty );
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportRemainingProperties()99cdf0e10cSrcweir 	void OPropertyExport::exportRemainingProperties()
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		// the properties tag (will be created if we have at least one no-default property)
102cdf0e10cSrcweir 		SvXMLElementExport* pPropertiesTag = NULL;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		try
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			Any aValue;
107cdf0e10cSrcweir 			::rtl::OUString sValue;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 			// loop through all the properties which are yet to be exported
110cdf0e10cSrcweir 			for	(	ConstStringSetIterator	aProperty = m_aRemainingProps.begin();
111cdf0e10cSrcweir 					aProperty != m_aRemainingProps.end();
112cdf0e10cSrcweir 					++aProperty
113cdf0e10cSrcweir 				)
114cdf0e10cSrcweir 			{
115cdf0e10cSrcweir 				DBG_CHECK_PROPERTY_NO_TYPE(*aProperty);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	#if OSL_DEBUG_LEVEL > 0
118cdf0e10cSrcweir 				const ::rtl::OUString sPropertyName = *aProperty; (void)sPropertyName;
119cdf0e10cSrcweir 	#endif
120cdf0e10cSrcweir                 if ( !shouldExportProperty( *aProperty ) )
121cdf0e10cSrcweir                     continue;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 				// now that we have the first sub-tag we need the form:properties element
124cdf0e10cSrcweir 				if (!pPropertiesTag)
125cdf0e10cSrcweir 					pPropertiesTag = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, token::XML_PROPERTIES, sal_True, sal_True);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 				// add the name attribute
128cdf0e10cSrcweir 				AddAttribute(XML_NAMESPACE_FORM, token::XML_PROPERTY_NAME, *aProperty);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 				// get the value
131cdf0e10cSrcweir 				aValue = m_xProps->getPropertyValue(*aProperty);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir                 // the type to export
134cdf0e10cSrcweir                 Type aExportType;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir                 // is it a sequence
137cdf0e10cSrcweir 				sal_Bool bIsSequence = TypeClass_SEQUENCE == aValue.getValueTypeClass();
138cdf0e10cSrcweir 				// the type of the property, maybe reduced to the element type of a sequence
139cdf0e10cSrcweir 				if (bIsSequence)
140cdf0e10cSrcweir 					aExportType = getSequenceElementType( aValue.getValueType() );
141cdf0e10cSrcweir 				else
142cdf0e10cSrcweir 					aExportType = aValue.getValueType();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 				// the type attribute
145cdf0e10cSrcweir 				// modified by BerryJia for Bug102407
146cdf0e10cSrcweir                 bool bIsEmptyValue = TypeClass_VOID == aValue.getValueType().getTypeClass();
147cdf0e10cSrcweir                 if ( bIsEmptyValue )
148cdf0e10cSrcweir                 {
149cdf0e10cSrcweir                     com::sun::star::beans::Property aPropDesc;
150cdf0e10cSrcweir 				    aPropDesc = m_xPropertyInfo->getPropertyByName( *aProperty );
151cdf0e10cSrcweir                     aExportType = aPropDesc.Type;
152cdf0e10cSrcweir                 }
153cdf0e10cSrcweir 				token::XMLTokenEnum eValueType = implGetPropertyXMLType( aExportType );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 				if ( bIsEmptyValue )
156cdf0e10cSrcweir 					AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, token::XML_VOID );
157cdf0e10cSrcweir 				else
158cdf0e10cSrcweir 					AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, eValueType );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir                 token::XMLTokenEnum eValueAttName( token::XML_VALUE );
161cdf0e10cSrcweir                 switch ( eValueType )
162cdf0e10cSrcweir                 {
163cdf0e10cSrcweir                 case token::XML_BOOLEAN:    eValueAttName = token::XML_BOOLEAN_VALUE; break;
164cdf0e10cSrcweir                 case token::XML_STRING:     eValueAttName = token::XML_STRING_VALUE;  break;
165cdf0e10cSrcweir                 default:    break;
166cdf0e10cSrcweir                 }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 				if( !bIsSequence && !bIsEmptyValue )
169cdf0e10cSrcweir 				{	// the simple case
170cdf0e10cSrcweir 					//add by BerryJia for Bug102407
171cdf0e10cSrcweir 					sValue = implConvertAny(aValue);
172cdf0e10cSrcweir 					AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
173cdf0e10cSrcweir 				}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 				// start the property tag
177cdf0e10cSrcweir 				SvXMLElementExport aValueTag1(m_rContext.getGlobalContext(),
178cdf0e10cSrcweir 						XML_NAMESPACE_FORM,
179cdf0e10cSrcweir 						bIsSequence ? token::XML_LIST_PROPERTY
180cdf0e10cSrcweir 									: token::XML_PROPERTY, sal_True, sal_True);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 				if (!bIsSequence)
183cdf0e10cSrcweir 					continue;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 				// the not-that-simple case, we need to iterate through the sequence elements
186cdf0e10cSrcweir 				IIterator* pSequenceIterator = NULL;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 				switch ( aExportType.getTypeClass() )
189cdf0e10cSrcweir 				{
190cdf0e10cSrcweir 					case TypeClass_STRING:
191cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< ::rtl::OUString >(aValue);
192cdf0e10cSrcweir 						break;
193cdf0e10cSrcweir 					case TypeClass_DOUBLE:
194cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< double >(aValue);
195cdf0e10cSrcweir 						break;
196cdf0e10cSrcweir 					case TypeClass_BOOLEAN:
197cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< sal_Bool >(aValue);
198cdf0e10cSrcweir 						break;
199cdf0e10cSrcweir 					case TypeClass_BYTE:
200cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< sal_Int8 >(aValue);
201cdf0e10cSrcweir 						break;
202cdf0e10cSrcweir 					case TypeClass_SHORT:
203cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< sal_Int16 >(aValue);
204cdf0e10cSrcweir 						break;
205cdf0e10cSrcweir 					case TypeClass_LONG:
206cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< sal_Int32 >(aValue);
207cdf0e10cSrcweir 						break;
208cdf0e10cSrcweir 					case TypeClass_HYPER:
209cdf0e10cSrcweir 						pSequenceIterator = new OSequenceIterator< sal_Int64 >(aValue);
210cdf0e10cSrcweir 						break;
211cdf0e10cSrcweir 					default:
212cdf0e10cSrcweir 						OSL_ENSURE(sal_False, "OPropertyExport::exportRemainingProperties: unsupported sequence tyoe !");
213cdf0e10cSrcweir 						break;
214cdf0e10cSrcweir 				}
215cdf0e10cSrcweir 				if (pSequenceIterator)
216cdf0e10cSrcweir 				{
217cdf0e10cSrcweir 					while (pSequenceIterator->hasMoreElements())
218cdf0e10cSrcweir 					{
219cdf0e10cSrcweir 						sValue =
220cdf0e10cSrcweir 							implConvertAny(pSequenceIterator->nextElement());
221cdf0e10cSrcweir 						AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
222cdf0e10cSrcweir 						SvXMLElementExport aValueTag(
223cdf0e10cSrcweir 								m_rContext.getGlobalContext(),
224cdf0e10cSrcweir 								XML_NAMESPACE_FORM, token::XML_LIST_VALUE,
225cdf0e10cSrcweir 								sal_True, sal_False);
226cdf0e10cSrcweir 					}
227cdf0e10cSrcweir 				}
228cdf0e10cSrcweir 				delete pSequenceIterator;
229cdf0e10cSrcweir 			}
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir 		catch(...)
232cdf0e10cSrcweir 		{
233cdf0e10cSrcweir 			delete pPropertiesTag;
234cdf0e10cSrcweir 			throw;
235cdf0e10cSrcweir 		}
236cdf0e10cSrcweir 		delete pPropertiesTag;
237cdf0e10cSrcweir 	}
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	//---------------------------------------------------------------------
examinePersistence()240cdf0e10cSrcweir 	void OPropertyExport::examinePersistence()
241cdf0e10cSrcweir 	{
242cdf0e10cSrcweir 		m_aRemainingProps.clear();
243cdf0e10cSrcweir 		Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
244cdf0e10cSrcweir 		const Property* pProperties = aProperties.getConstArray();
245cdf0e10cSrcweir 		for (sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties)
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir 			// no transient props
248cdf0e10cSrcweir             if ( pProperties->Attributes & PropertyAttribute::TRANSIENT )
249cdf0e10cSrcweir                 continue;
250cdf0e10cSrcweir             // no read-only props
251cdf0e10cSrcweir             if ( ( pProperties->Attributes & PropertyAttribute::READONLY ) != 0 )
252cdf0e10cSrcweir                 // except they're dynamically added
253cdf0e10cSrcweir                 if ( ( pProperties->Attributes & PropertyAttribute::REMOVEABLE ) == 0 )
254cdf0e10cSrcweir 				    continue;
255cdf0e10cSrcweir 			m_aRemainingProps.insert(pProperties->Name);
256cdf0e10cSrcweir 		}
257cdf0e10cSrcweir 	}
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportStringPropertyAttribute(const sal_uInt16 _nNamespaceKey,const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName)260cdf0e10cSrcweir 	void OPropertyExport::exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
261cdf0e10cSrcweir 			const ::rtl::OUString& _rPropertyName )
262cdf0e10cSrcweir 	{
263cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( _rPropertyName, ::rtl::OUString );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 		// no try-catch here, this would be to expensive. The outer scope has to handle exceptions (which should not
266cdf0e10cSrcweir 		// happen if we're used correctly :)
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 		// this is way simple, as we don't need to convert anything (the property already is a string)
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		// get the string
271cdf0e10cSrcweir 		::rtl::OUString sPropValue;
272cdf0e10cSrcweir 		m_xProps->getPropertyValue( _rPropertyName ) >>= sPropValue;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 		// add the attribute
275cdf0e10cSrcweir 		if ( sPropValue.getLength() )
276cdf0e10cSrcweir 			AddAttribute( _nNamespaceKey, _pAttributeName, sPropValue );
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 		// the property does not need to be handled anymore
279cdf0e10cSrcweir 		exportedProperty( _rPropertyName );
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey,const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName,const sal_Int8 _nBooleanAttributeFlags)283cdf0e10cSrcweir 	void OPropertyExport::exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
284cdf0e10cSrcweir 			const ::rtl::OUString& _rPropertyName, const sal_Int8 _nBooleanAttributeFlags)
285cdf0e10cSrcweir 	{
286cdf0e10cSrcweir 		DBG_CHECK_PROPERTY_NO_TYPE( _rPropertyName );
287cdf0e10cSrcweir 		// no check of the property value type: this method is allowed to be called with any interger properties
288cdf0e10cSrcweir 		// (e.g. sal_Int32, sal_uInt16 etc)
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		sal_Bool bDefault = (BOOLATTR_DEFAULT_TRUE == (BOOLATTR_DEFAULT_MASK & _nBooleanAttributeFlags));
291cdf0e10cSrcweir 		sal_Bool bDefaultVoid = (BOOLATTR_DEFAULT_VOID == (BOOLATTR_DEFAULT_MASK & _nBooleanAttributeFlags));
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		// get the value
294cdf0e10cSrcweir 		sal_Bool bCurrentValue = bDefault;
295cdf0e10cSrcweir 		Any aCurrentValue = m_xProps->getPropertyValue( _rPropertyName );
296cdf0e10cSrcweir 		if (aCurrentValue.hasValue())
297cdf0e10cSrcweir 		{
298cdf0e10cSrcweir 			bCurrentValue = ::cppu::any2bool(aCurrentValue);
299cdf0e10cSrcweir 			// this will extract a boolean value even if the Any contains a int or short or something like that ...
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 			if (_nBooleanAttributeFlags & BOOLATTR_INVERSE_SEMANTICS)
302cdf0e10cSrcweir 				bCurrentValue = !bCurrentValue;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 			// we have a non-void current value
305cdf0e10cSrcweir 			if (bDefaultVoid || (bDefault != bCurrentValue))
306cdf0e10cSrcweir 				// and (the default is void, or the non-void default does not equal the current value)
307cdf0e10cSrcweir 				// -> write the attribute
308cdf0e10cSrcweir 				AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
309cdf0e10cSrcweir 		}
310cdf0e10cSrcweir 		else
311cdf0e10cSrcweir 			// we have a void current value
312cdf0e10cSrcweir 			if (!bDefaultVoid)
313cdf0e10cSrcweir 				// and we have a non-void default
314cdf0e10cSrcweir 				// -> write the attribute
315cdf0e10cSrcweir 				AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 		// the property does not need to be handled anymore
318cdf0e10cSrcweir 		exportedProperty( _rPropertyName );
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey,const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName,const sal_Int16 _nDefault)322cdf0e10cSrcweir 	void OPropertyExport::exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
323cdf0e10cSrcweir 		const ::rtl::OUString& _rPropertyName, const sal_Int16 _nDefault)
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( _rPropertyName, sal_Int16 );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 		// get the value
328cdf0e10cSrcweir 		sal_Int16 nCurrentValue(_nDefault);
329cdf0e10cSrcweir 		m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 		// add the attribute
332cdf0e10cSrcweir 		if (_nDefault != nCurrentValue)
333cdf0e10cSrcweir 		{
334cdf0e10cSrcweir 			// let the formatter of the export context build a string
335cdf0e10cSrcweir 			::rtl::OUStringBuffer sBuffer;
336cdf0e10cSrcweir 			m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(sBuffer, (sal_Int32)nCurrentValue);
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 			AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear());
339cdf0e10cSrcweir 		}
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		// the property does not need to be handled anymore
342cdf0e10cSrcweir 		exportedProperty( _rPropertyName );
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportInt32PropertyAttribute(const sal_uInt16 _nNamespaceKey,const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName,const sal_Int32 _nDefault)346cdf0e10cSrcweir 	void OPropertyExport::exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
347cdf0e10cSrcweir 		const ::rtl::OUString& _rPropertyName, const sal_Int32 _nDefault )
348cdf0e10cSrcweir 	{
349cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( _rPropertyName, sal_Int32 );
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 		// get the value
352cdf0e10cSrcweir 		sal_Int32 nCurrentValue( _nDefault );
353cdf0e10cSrcweir 		m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		// add the attribute
356cdf0e10cSrcweir 		if ( _nDefault != nCurrentValue )
357cdf0e10cSrcweir 		{
358cdf0e10cSrcweir 			// let the formatter of the export context build a string
359cdf0e10cSrcweir 			::rtl::OUStringBuffer sBuffer;
360cdf0e10cSrcweir 			m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber( sBuffer, nCurrentValue );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 			AddAttribute( _nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear() );
363cdf0e10cSrcweir 		}
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 		// the property does not need to be handled anymore
366cdf0e10cSrcweir 		exportedProperty( _rPropertyName );
367cdf0e10cSrcweir 	}
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportEnumPropertyAttribute(const sal_uInt16 _nNamespaceKey,const sal_Char * _pAttributeName,const sal_Char * _pPropertyName,const SvXMLEnumMapEntry * _pValueMap,const sal_Int32 _nDefault,const sal_Bool _bVoidDefault)370cdf0e10cSrcweir 	void OPropertyExport::exportEnumPropertyAttribute(
371cdf0e10cSrcweir 			const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
372cdf0e10cSrcweir 			const sal_Char* _pPropertyName, const SvXMLEnumMapEntry* _pValueMap,
373cdf0e10cSrcweir 			const sal_Int32 _nDefault, const sal_Bool _bVoidDefault)
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		// get the value
376cdf0e10cSrcweir 		sal_Int32 nCurrentValue(_nDefault);
377cdf0e10cSrcweir 		::rtl::OUString sPropertyName(::rtl::OUString::createFromAscii(_pPropertyName));
378cdf0e10cSrcweir 		Any aValue = m_xProps->getPropertyValue(sPropertyName);
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 		if (aValue.hasValue())
381cdf0e10cSrcweir 		{	// we have a non-void current value
382cdf0e10cSrcweir 			::cppu::enum2int(nCurrentValue, aValue);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 			// add the attribute
385cdf0e10cSrcweir 			if ((_nDefault != nCurrentValue) || _bVoidDefault)
386cdf0e10cSrcweir 			{	// the default does not equal the value, or the default is void and the value isn't
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 				// let the formatter of the export context build a string
389cdf0e10cSrcweir 				::rtl::OUStringBuffer sBuffer;
390cdf0e10cSrcweir 				m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(sBuffer, (sal_uInt16)nCurrentValue, _pValueMap);
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 				AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear());
393cdf0e10cSrcweir 			}
394cdf0e10cSrcweir 		}
395cdf0e10cSrcweir 		else
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			if (!_bVoidDefault)
398cdf0e10cSrcweir 				AddAttributeASCII(_nNamespaceKey, _pAttributeName, "");
399cdf0e10cSrcweir 		}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 		// the property does not need to be handled anymore
402cdf0e10cSrcweir 		exportedProperty(sPropertyName);
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportTargetFrameAttribute()406cdf0e10cSrcweir 	void OPropertyExport::exportTargetFrameAttribute()
407cdf0e10cSrcweir 	{
408cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( PROPERTY_TARGETFRAME, ::rtl::OUString );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 		::rtl::OUString sTargetFrame = comphelper::getString(m_xProps->getPropertyValue(PROPERTY_TARGETFRAME));
411cdf0e10cSrcweir 		if (0 != sTargetFrame.compareToAscii("_blank"))
412cdf0e10cSrcweir 		{	// an empty string and "_blank" have the same meaning and don't have to be written
413cdf0e10cSrcweir 			AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_FRAME)
414cdf0e10cSrcweir 						,OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME)
415cdf0e10cSrcweir 						,sTargetFrame);
416cdf0e10cSrcweir 		}
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 		exportedProperty(PROPERTY_TARGETFRAME);
419cdf0e10cSrcweir 	}
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportRelativeTargetLocation(const ConstAsciiString & _sPropertyName,sal_Int32 _nProperty,bool _bAddType)422cdf0e10cSrcweir 	void OPropertyExport::exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty,bool _bAddType)
423cdf0e10cSrcweir 	{
424cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( _sPropertyName, ::rtl::OUString );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		::rtl::OUString sTargetLocation = comphelper::getString(m_xProps->getPropertyValue(_sPropertyName));
427cdf0e10cSrcweir         if ( sTargetLocation.getLength() )
428cdf0e10cSrcweir                     // If this isn't a GraphicObject then GetRelativeReference
429cdf0e10cSrcweir                     // will be called anyway ( in AddEmbeddedGraphic )
430cdf0e10cSrcweir 		    sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedGraphicObject(sTargetLocation);
431cdf0e10cSrcweir 		AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(_nProperty)
432cdf0e10cSrcweir 					,OAttributeMetaData::getCommonControlAttributeName(_nProperty)
433cdf0e10cSrcweir 					, sTargetLocation);
434cdf0e10cSrcweir 
435cdf0e10cSrcweir         // #i110911# add xlink:type="simple" if required
436cdf0e10cSrcweir         if (_bAddType)
437cdf0e10cSrcweir             AddAttribute(XML_NAMESPACE_XLINK, token::XML_TYPE, token::XML_SIMPLE);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 		exportedProperty(_sPropertyName);
440cdf0e10cSrcweir 	}
441cdf0e10cSrcweir 	//---------------------------------------------------------------------
flagStyleProperties()442cdf0e10cSrcweir 	void OPropertyExport::flagStyleProperties()
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		// flag all the properties which are part of the style as "handled"
445cdf0e10cSrcweir 		UniReference< XMLPropertySetMapper > xStylePropertiesSupplier = m_rContext.getStylePropertyMapper()->getPropertySetMapper();
446cdf0e10cSrcweir 		for (sal_Int32 i=0; i<xStylePropertiesSupplier->GetEntryCount(); ++i)
447cdf0e10cSrcweir 			exportedProperty(xStylePropertiesSupplier->GetEntryAPIName(i));
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 		// the font properties are exported as single properties, but there is a FontDescriptor property which
450cdf0e10cSrcweir 		// collects them all-in-one, this has been exported implicitly
451cdf0e10cSrcweir 		exportedProperty(PROPERTY_FONT);
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 		// for the DateFormat and TimeFormat, there exist wrapper properties which has been exported as
454cdf0e10cSrcweir 		// style, too
455cdf0e10cSrcweir 		exportedProperty(PROPERTY_DATEFORMAT);
456cdf0e10cSrcweir 		exportedProperty(PROPERTY_TIMEFORMAT);
457cdf0e10cSrcweir 
458cdf0e10cSrcweir         // the following properties should have been exported at the shape already:
459cdf0e10cSrcweir         exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) ) );
460cdf0e10cSrcweir         exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) ) );
461cdf0e10cSrcweir         exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScaleMode" ) ) );
462cdf0e10cSrcweir         // ditto the TextWritingMode
463cdf0e10cSrcweir 		exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) ) );
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportGenericPropertyAttribute(const sal_uInt16 _nAttributeNamespaceKey,const sal_Char * _pAttributeName,const sal_Char * _pPropertyName)467cdf0e10cSrcweir 	void OPropertyExport::exportGenericPropertyAttribute(
468cdf0e10cSrcweir 			const sal_uInt16 _nAttributeNamespaceKey, const sal_Char* _pAttributeName, const sal_Char* _pPropertyName)
469cdf0e10cSrcweir 	{
470cdf0e10cSrcweir 		DBG_CHECK_PROPERTY_ASCII_NO_TYPE( _pPropertyName );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 		::rtl::OUString sPropertyName = ::rtl::OUString::createFromAscii(_pPropertyName);
473cdf0e10cSrcweir 		exportedProperty(sPropertyName);
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 		Any aCurrentValue = m_xProps->getPropertyValue(sPropertyName);
476cdf0e10cSrcweir 		if (!aCurrentValue.hasValue())
477cdf0e10cSrcweir 			// nothing to do without a concrete value
478cdf0e10cSrcweir 			return;
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 		::rtl::OUString sValue = implConvertAny(aCurrentValue);
481cdf0e10cSrcweir 		if (!sValue.getLength() && (TypeClass_STRING == aCurrentValue.getValueTypeClass()))
482cdf0e10cSrcweir 		{
483cdf0e10cSrcweir 			// check whether or not the property is allowed to be VOID
484cdf0e10cSrcweir 			Property aProperty = m_xPropertyInfo->getPropertyByName(sPropertyName);
485cdf0e10cSrcweir 			if ((aProperty.Attributes & PropertyAttribute::MAYBEVOID) == 0)
486cdf0e10cSrcweir 				// the string is empty, and the property is not allowed to be void
487cdf0e10cSrcweir 				// -> don't need to write the attibute, 'cause missing it is unambiguous
488cdf0e10cSrcweir 				return;
489cdf0e10cSrcweir 		}
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		// finally add the attribuite to the context
492cdf0e10cSrcweir 		AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sValue);
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	//---------------------------------------------------------------------
exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey,const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName,const sal_Unicode _aQuoteCharacter,const sal_Unicode _aListSeparator)496cdf0e10cSrcweir 	void OPropertyExport::exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const sal_Char* _pAttributeName,
497cdf0e10cSrcweir 		const ::rtl::OUString& _rPropertyName,
498cdf0e10cSrcweir 		const sal_Unicode _aQuoteCharacter, const sal_Unicode _aListSeparator)
499cdf0e10cSrcweir 	{
500cdf0e10cSrcweir 		DBG_CHECK_PROPERTY( _rPropertyName, Sequence< ::rtl::OUString > );
501cdf0e10cSrcweir 		OSL_ENSURE(_aListSeparator != 0, "OPropertyExport::exportStringSequenceAttribute: invalid separator character!");
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aItems;
504cdf0e10cSrcweir 		m_xProps->getPropertyValue( _rPropertyName ) >>= aItems;
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 		::rtl::OUString sFinalList;
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 		// unfortunately the OUString can't append single sal_Unicode characters ...
509cdf0e10cSrcweir 		const ::rtl::OUString sQuote(&_aQuoteCharacter, 1);
510cdf0e10cSrcweir 		const ::rtl::OUString sSeparator(&_aListSeparator, 1);
511cdf0e10cSrcweir 		const sal_Bool bQuote = 0 != sQuote.getLength();
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 		// concatenate the string items
514cdf0e10cSrcweir 		const ::rtl::OUString* pItems = aItems.getConstArray();
515cdf0e10cSrcweir 		const ::rtl::OUString* pEnd = pItems + aItems.getLength();
516cdf0e10cSrcweir 		const ::rtl::OUString* pLastElement = pEnd - 1;
517cdf0e10cSrcweir 		for	(	;
518cdf0e10cSrcweir 				pItems != pEnd;
519cdf0e10cSrcweir 				++pItems
520cdf0e10cSrcweir 			)
521cdf0e10cSrcweir 		{
522cdf0e10cSrcweir 			OSL_ENSURE(!_aQuoteCharacter || (-1 == pItems->indexOf(_aQuoteCharacter)),
523cdf0e10cSrcweir 				"OPropertyExport::exportStringSequenceAttribute: there is an item which contains the quote character!");
524cdf0e10cSrcweir 			OSL_ENSURE(_aQuoteCharacter || (-1 == pItems->indexOf(_aListSeparator)),
525cdf0e10cSrcweir 				"OPropertyExport::exportStringSequenceAttribute: no quote character, but there is an item containing the separator character!");
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 			if (bQuote)
528cdf0e10cSrcweir 				sFinalList += sQuote;
529cdf0e10cSrcweir 			sFinalList += *pItems;
530cdf0e10cSrcweir 			if (bQuote)
531cdf0e10cSrcweir 				sFinalList += sQuote;
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 			if (pItems != pLastElement)
534cdf0e10cSrcweir 				sFinalList += sSeparator;
535cdf0e10cSrcweir 		}
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 		if (sFinalList.getLength())
538cdf0e10cSrcweir 			AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sFinalList);
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 		exportedProperty( _rPropertyName );
541cdf0e10cSrcweir 	}
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 	//---------------------------------------------------------------------
implConvertAny(const Any & _rValue)544cdf0e10cSrcweir 	::rtl::OUString OPropertyExport::implConvertAny(const Any& _rValue)
545cdf0e10cSrcweir 	{
546cdf0e10cSrcweir 		::rtl::OUStringBuffer aBuffer;
547cdf0e10cSrcweir 		switch (_rValue.getValueTypeClass())
548cdf0e10cSrcweir 		{
549cdf0e10cSrcweir 			case TypeClass_STRING:
550cdf0e10cSrcweir 			{	// extract the string
551cdf0e10cSrcweir 				::rtl::OUString sCurrentValue;
552cdf0e10cSrcweir 				_rValue >>= sCurrentValue;
553cdf0e10cSrcweir 				aBuffer.append(sCurrentValue);
554cdf0e10cSrcweir 			}
555cdf0e10cSrcweir 			break;
556cdf0e10cSrcweir 			case TypeClass_DOUBLE:
557cdf0e10cSrcweir 				// let the unit converter format is as string
558cdf0e10cSrcweir 				m_rContext.getGlobalContext().GetMM100UnitConverter().convertDouble(aBuffer, getDouble(_rValue));
559cdf0e10cSrcweir 				break;
560cdf0e10cSrcweir 			case TypeClass_BOOLEAN:
561cdf0e10cSrcweir 				aBuffer = getBOOL(_rValue) ? m_sValueTrue : m_sValueFalse;
562cdf0e10cSrcweir 				break;
563cdf0e10cSrcweir 			case TypeClass_BYTE:
564cdf0e10cSrcweir 			case TypeClass_SHORT:
565cdf0e10cSrcweir 			case TypeClass_LONG:
566cdf0e10cSrcweir 				// let the unit converter format is as string
567cdf0e10cSrcweir 				m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue));
568cdf0e10cSrcweir 				break;
569cdf0e10cSrcweir 			case TypeClass_HYPER:
570cdf0e10cSrcweir 				// TODO
571cdf0e10cSrcweir 				OSL_ENSURE(sal_False, "OPropertyExport::implConvertAny: missing implementation for sal_Int64!");
572cdf0e10cSrcweir 				break;
573cdf0e10cSrcweir 			case TypeClass_ENUM:
574cdf0e10cSrcweir 			{
575cdf0e10cSrcweir 				// convert it into an int32
576cdf0e10cSrcweir 				sal_Int32 nValue = 0;
577cdf0e10cSrcweir 				::cppu::enum2int(nValue, _rValue);
578cdf0e10cSrcweir 				m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(aBuffer, nValue);
579cdf0e10cSrcweir 			}
580cdf0e10cSrcweir 			break;
581cdf0e10cSrcweir 			default:
582cdf0e10cSrcweir 			{	// hmmm .... what else do we know?
583cdf0e10cSrcweir 				double fValue = 0;
584cdf0e10cSrcweir 				::com::sun::star::util::Date aDate;
585cdf0e10cSrcweir 				::com::sun::star::util::Time aTime;
586cdf0e10cSrcweir 				::com::sun::star::util::DateTime aDateTime;
587cdf0e10cSrcweir 				if (_rValue >>= aDate)
588cdf0e10cSrcweir 				{
589cdf0e10cSrcweir 					Date aToolsDate;
590cdf0e10cSrcweir 					::utl::typeConvert(aDate, aToolsDate);
591cdf0e10cSrcweir 					fValue = aToolsDate.GetDate();
592cdf0e10cSrcweir 				}
593cdf0e10cSrcweir 				else if (_rValue >>= aTime)
594cdf0e10cSrcweir 				{
595cdf0e10cSrcweir 					fValue = ((aTime.Hours * 60 + aTime.Minutes) * 60 + aTime.Seconds) * 100 + aTime.HundredthSeconds;
596cdf0e10cSrcweir 					fValue = fValue / 8640000.0;
597cdf0e10cSrcweir 				}
598cdf0e10cSrcweir 				else if (_rValue >>= aDateTime)
599cdf0e10cSrcweir 				{
600cdf0e10cSrcweir 					DateTime aToolsDateTime;
601cdf0e10cSrcweir 					::utl::typeConvert(aDateTime, aToolsDateTime);
602cdf0e10cSrcweir 					// the time part (the digits behind the comma)
603cdf0e10cSrcweir 					fValue = ((aDateTime.Hours * 60 + aDateTime.Minutes) * 60 + aDateTime.Seconds) * 100 + aDateTime.HundredthSeconds;
604cdf0e10cSrcweir 					fValue = fValue / 8640000.0;
605cdf0e10cSrcweir 					// plus the data part (the digits in front of the comma)
606cdf0e10cSrcweir 					fValue += aToolsDateTime.GetDate();
607cdf0e10cSrcweir 				}
608cdf0e10cSrcweir 				else
609cdf0e10cSrcweir 				{
610cdf0e10cSrcweir 					// if any other types are added here, please remember to adjust implGetPropertyXMLType accordingly
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 					// no more options ...
613cdf0e10cSrcweir 					OSL_ENSURE(sal_False, "OPropertyExport::implConvertAny: unsupported value type!");
614cdf0e10cSrcweir 					break;
615cdf0e10cSrcweir 				}
616cdf0e10cSrcweir 				// let the unit converter format is as string
617cdf0e10cSrcweir 				m_rContext.getGlobalContext().GetMM100UnitConverter().convertDouble(aBuffer, fValue);
618cdf0e10cSrcweir 			}
619cdf0e10cSrcweir 			break;
620cdf0e10cSrcweir 		}
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 		return aBuffer.makeStringAndClear();
623cdf0e10cSrcweir 	}
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 	//---------------------------------------------------------------------
implGetPropertyXMLType(const::com::sun::star::uno::Type & _rType)627cdf0e10cSrcweir 	token::XMLTokenEnum OPropertyExport::implGetPropertyXMLType(const ::com::sun::star::uno::Type& _rType)
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir 		// handle the type description
630cdf0e10cSrcweir 		switch (_rType.getTypeClass())
631cdf0e10cSrcweir 		{
632cdf0e10cSrcweir 			case TypeClass_STRING:
633cdf0e10cSrcweir 				return token::XML_STRING;
634cdf0e10cSrcweir 			case TypeClass_DOUBLE:
635cdf0e10cSrcweir 			case TypeClass_BYTE:
636cdf0e10cSrcweir 			case TypeClass_SHORT:
637cdf0e10cSrcweir 			case TypeClass_LONG:
638cdf0e10cSrcweir 			case TypeClass_HYPER:
639cdf0e10cSrcweir 			case TypeClass_ENUM:
640cdf0e10cSrcweir 				return token::XML_FLOAT;
641cdf0e10cSrcweir 			case TypeClass_BOOLEAN:
642cdf0e10cSrcweir 				return token::XML_BOOLEAN;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 			default:
645cdf0e10cSrcweir 				return token::XML_FLOAT;
646cdf0e10cSrcweir 		}
647cdf0e10cSrcweir 	}
648cdf0e10cSrcweir 
649cdf0e10cSrcweir #ifdef DBG_UTIL
650cdf0e10cSrcweir 	//---------------------------------------------------------------------
AddAttribute(sal_uInt16 _nPrefix,const sal_Char * _pName,const::rtl::OUString & _rValue)651cdf0e10cSrcweir 	void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue)
652cdf0e10cSrcweir 	{
653cdf0e10cSrcweir 		OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::rtl::OUString::createFromAscii(_pName)).getLength(),
654cdf0e10cSrcweir 			"OPropertyExport::AddAttribute: already have such an attribute");
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 		m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue);
657cdf0e10cSrcweir 	}
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     //---------------------------------------------------------------------
AddAttribute(sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const::rtl::OUString & _rValue)660cdf0e10cSrcweir     void OPropertyExport::AddAttribute( sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const ::rtl::OUString& _rValue )
661cdf0e10cSrcweir     {
662cdf0e10cSrcweir         OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName( _rName ).getLength(),
663cdf0e10cSrcweir             "OPropertyExport::AddAttribute: already have such an attribute");
664cdf0e10cSrcweir 
665cdf0e10cSrcweir         m_rContext.getGlobalContext().AddAttribute( _nPrefix, _rName, _rValue );
666cdf0e10cSrcweir     }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	//---------------------------------------------------------------------
AddAttributeASCII(sal_uInt16 _nPrefix,const sal_Char * _pName,const sal_Char * pValue)669cdf0e10cSrcweir 	void OPropertyExport::AddAttributeASCII(sal_uInt16 _nPrefix, const sal_Char* _pName, const sal_Char *pValue)
670cdf0e10cSrcweir 	{
671cdf0e10cSrcweir 		OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::rtl::OUString::createFromAscii(_pName)).getLength(),
672cdf0e10cSrcweir 			"OPropertyExport::AddAttributeASCII: already have such an attribute");
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 		m_rContext.getGlobalContext().AddAttributeASCII(_nPrefix, _pName, pValue);
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	//---------------------------------------------------------------------
AddAttribute(sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName,const::rtl::OUString & _rValue)678cdf0e10cSrcweir 	void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const ::rtl::OUString& _rValue)
679cdf0e10cSrcweir 	{
680cdf0e10cSrcweir 		OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).getLength(),
681cdf0e10cSrcweir 			"OPropertyExport::AddAttribute: already have such an attribute");
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 		m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _rValue);
684cdf0e10cSrcweir 	}
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 	//---------------------------------------------------------------------
AddAttribute(sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName,::xmloff::token::XMLTokenEnum _eValue)687cdf0e10cSrcweir 	void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, ::xmloff::token::XMLTokenEnum _eValue )
688cdf0e10cSrcweir 	{
689cdf0e10cSrcweir 		OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).getLength(),
690cdf0e10cSrcweir 			"OPropertyExport::AddAttribute: already have such an attribute");
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 		m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _eValue);
693cdf0e10cSrcweir 	}
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 	//---------------------------------------------------------------------
dbg_implCheckProperty(const::rtl::OUString & _rPropertyName,const Type * _pType)696cdf0e10cSrcweir 	void OPropertyExport::dbg_implCheckProperty(const ::rtl::OUString& _rPropertyName, const Type* _pType)
697cdf0e10cSrcweir 	{
698cdf0e10cSrcweir 		try
699cdf0e10cSrcweir 		{
700cdf0e10cSrcweir 			// the property must exist
701cdf0e10cSrcweir 			if (!m_xPropertyInfo->hasPropertyByName(_rPropertyName))
702cdf0e10cSrcweir 			{
703cdf0e10cSrcweir 				OSL_ENSURE(sal_False,
704cdf0e10cSrcweir 					::rtl::OString("OPropertyExport::dbg_implCheckProperty: no property with the name ") +=
705cdf0e10cSrcweir 					::rtl::OString(_rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US) +=
706cdf0e10cSrcweir 					::rtl::OString("!"));
707cdf0e10cSrcweir 				return;
708cdf0e10cSrcweir 			}
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 			if (_pType)
711cdf0e10cSrcweir 			{
712cdf0e10cSrcweir 				// and it must have the correct type
713cdf0e10cSrcweir 				Property aPropertyDescription = m_xPropertyInfo->getPropertyByName(_rPropertyName);
714cdf0e10cSrcweir 				OSL_ENSURE(aPropertyDescription.Type.equals(*_pType), "OPropertyExport::dbg_implCheckProperty: invalid property type!");
715cdf0e10cSrcweir 			}
716cdf0e10cSrcweir 		}
717cdf0e10cSrcweir 		catch(Exception&)
718cdf0e10cSrcweir 		{
719cdf0e10cSrcweir 			OSL_ENSURE(sal_False, "OPropertyExport::dbg_implCheckProperty: caught an exception, could not check the property!");
720cdf0e10cSrcweir 		}
721cdf0e10cSrcweir 	}
722cdf0e10cSrcweir #endif // DBG_UTIL - dbg_implCheckProperty
723cdf0e10cSrcweir 
724cdf0e10cSrcweir //.........................................................................
725cdf0e10cSrcweir }	// namespace xmloff
726cdf0e10cSrcweir //.........................................................................
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 
729