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