2000-11-17 18:03:33 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: propertyexport.cxx,v $
|
|
|
|
*
|
2004-08-02 13:15:40 +00:00
|
|
|
* $Revision: 1.26 $
|
2000-11-17 18:03:33 +00:00
|
|
|
*
|
2004-08-02 13:15:40 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2004-08-02 14:15:40 $
|
2000-11-17 18:03:33 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2000-11-29 09:36:05 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
#ifndef _XMLOFF_FORMS_PROPERTYEXPORT_HXX_
|
|
|
|
#include "propertyexport.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLEXP_HXX
|
|
|
|
#include "xmlexp.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_FORMS_STRINGS_HXX_
|
|
|
|
#include "strings.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLNMSPE_HXX
|
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
|
|
|
#include "xmluconv.hxx"
|
|
|
|
#endif
|
2000-12-18 14:14:35 +00:00
|
|
|
#ifndef _XMLOFF_FAMILIES_HXX_
|
|
|
|
#include "families.hxx"
|
|
|
|
#endif
|
2000-11-17 18:03:33 +00:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#endif
|
2000-11-19 14:41:32 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertyState.hpp>
|
|
|
|
#endif
|
2000-11-17 18:03:33 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
|
|
|
|
#include <com/sun/star/util/Date.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
|
|
|
|
#include <com/sun/star/util/Time.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
|
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
2001-03-16 13:37:07 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2000-11-17 18:03:33 +00:00
|
|
|
#endif
|
2004-08-02 13:15:40 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#endif
|
2000-11-17 18:03:33 +00:00
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#endif
|
2000-12-18 14:14:35 +00:00
|
|
|
#ifndef _XMLOFF_FORMS_CALLBACKS_HXX_
|
|
|
|
#include "callbacks.hxx"
|
|
|
|
#endif
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
#ifndef _UNOTOOLS_DATETIME_HXX_
|
|
|
|
#include <unotools/datetime.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DATE_HXX
|
|
|
|
#include <tools/date.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_TIME_HXX
|
|
|
|
#include <tools/time.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DATETIME_HXX
|
|
|
|
#include <tools/datetime.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
namespace xmloff
|
|
|
|
{
|
|
|
|
//.........................................................................
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
|
2000-12-13 09:38:49 +00:00
|
|
|
// NO using namespace ...util !!!
|
|
|
|
// need a tools Date/Time/DateTime below, which would conflict with the uno types then
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
using namespace ::comphelper;
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//= OPropertyExport
|
|
|
|
//=====================================================================
|
|
|
|
//---------------------------------------------------------------------
|
2000-12-18 14:14:35 +00:00
|
|
|
OPropertyExport::OPropertyExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps)
|
2000-11-17 18:03:33 +00:00
|
|
|
:m_rContext(_rContext)
|
|
|
|
,m_xProps(_rxProps)
|
|
|
|
{
|
2000-11-19 14:41:32 +00:00
|
|
|
// caching
|
|
|
|
::rtl::OUStringBuffer aBuffer;
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(aBuffer, sal_True);
|
2000-11-19 14:41:32 +00:00
|
|
|
m_sValueTrue = aBuffer.makeStringAndClear();
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(aBuffer, sal_False);
|
2000-11-19 14:41:32 +00:00
|
|
|
m_sValueFalse = aBuffer.makeStringAndClear();
|
|
|
|
|
|
|
|
m_xPropertyInfo = m_xProps->getPropertySetInfo();
|
|
|
|
OSL_ENSURE(m_xPropertyInfo.is(), "OPropertyExport::OPropertyExport: need an XPropertySetInfo!");
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
// collect the properties which need to be exported
|
|
|
|
examinePersistence();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::exportRemainingProperties()
|
|
|
|
{
|
2001-04-11 12:44:23 +00:00
|
|
|
// the properties tag (will be created if we have at least one no-default property)
|
|
|
|
SvXMLElementExport* pPropertiesTag = NULL;
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
try
|
2000-11-19 14:41:32 +00:00
|
|
|
{
|
2001-04-11 12:44:23 +00:00
|
|
|
Reference< XPropertyState > xPropertyState(m_xProps, UNO_QUERY);
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
Any aValue;
|
|
|
|
::rtl::OUString sValue;
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
// loop through all the properties which are yet to be exported
|
|
|
|
for ( ConstStringSetIterator aProperty = m_aRemainingProps.begin();
|
|
|
|
aProperty != m_aRemainingProps.end();
|
|
|
|
++aProperty
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_CHECK_PROPERTY_NO_TYPE(*aProperty);
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
const ::rtl::OUString sPropertyName = *aProperty;
|
|
|
|
#endif
|
|
|
|
// if the property state is DEFAULT, it does not need to be written
|
|
|
|
if (xPropertyState.is() && (PropertyState_DEFAULT_VALUE == xPropertyState->getPropertyState(*aProperty)))
|
|
|
|
continue;
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
// now that we have the first sub-tag we need the form:properties element
|
|
|
|
if (!pPropertiesTag)
|
2004-07-13 07:14:38 +00:00
|
|
|
pPropertiesTag = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, token::XML_PROPERTIES, sal_True, sal_True);
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
// add the name attribute
|
2004-07-13 07:14:38 +00:00
|
|
|
AddAttribute(XML_NAMESPACE_FORM, token::XML_PROPERTY_NAME, *aProperty);
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
// get the value
|
|
|
|
aValue = m_xProps->getPropertyValue(*aProperty);
|
|
|
|
|
|
|
|
if (sal_False)
|
2000-11-19 14:41:32 +00:00
|
|
|
{
|
2001-04-11 12:44:23 +00:00
|
|
|
::rtl::OUString sTemp;
|
|
|
|
aValue >>= sTemp;
|
|
|
|
aValue <<= makeAny(Sequence< ::rtl::OUString >(&sTemp, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
// is it a sequence
|
|
|
|
sal_Bool bIsSequence = TypeClass_SEQUENCE == aValue.getValueTypeClass();
|
|
|
|
// the type of the property, maybe reduced to the element type of a sequence
|
|
|
|
Type aSimpleType;
|
|
|
|
if (bIsSequence)
|
|
|
|
aSimpleType = getSequenceElementType(aValue.getValueType());
|
|
|
|
else
|
|
|
|
aSimpleType = aValue.getValueType();
|
|
|
|
|
|
|
|
// the type attribute
|
2002-11-01 11:34:08 +00:00
|
|
|
// modified by BerryJia for Bug102407
|
|
|
|
com::sun::star::beans::Property aPropertyStruct;
|
|
|
|
aPropertyStruct = m_xPropertyInfo->getPropertyByName(*aProperty);
|
2004-07-13 07:14:38 +00:00
|
|
|
token::XMLTokenEnum eValueType =
|
|
|
|
implGetPropertyXMLType(aPropertyStruct.Type);
|
|
|
|
sal_Bool bIsVoid = !bIsSequence &&
|
|
|
|
TypeClass_VOID == aValue.getValueType().getTypeClass();
|
|
|
|
if( bIsVoid )
|
|
|
|
AddAttribute(XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE,
|
|
|
|
token::XML_VOID );
|
|
|
|
else
|
|
|
|
AddAttribute(XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE,
|
|
|
|
eValueType);
|
|
|
|
token::XMLTokenEnum eValue =
|
|
|
|
token::XML_BOOLEAN == eValueType
|
|
|
|
? token::XML_BOOLEAN_VALUE
|
|
|
|
: (token::XML_STRING == eValueType
|
|
|
|
? token::XML_STRING_VALUE
|
|
|
|
: token::XML_VALUE);
|
|
|
|
|
|
|
|
if( !bIsSequence && !bIsVoid )
|
|
|
|
{ // the simple case
|
|
|
|
//add by BerryJia for Bug102407
|
|
|
|
sValue = implConvertAny(aValue);
|
|
|
|
AddAttribute(XML_NAMESPACE_OFFICE, eValue, sValue );
|
|
|
|
}
|
2001-04-11 12:44:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
// start the property tag
|
2004-07-13 07:14:38 +00:00
|
|
|
SvXMLElementExport aValueTag(m_rContext.getGlobalContext(),
|
|
|
|
XML_NAMESPACE_FORM,
|
|
|
|
bIsSequence ? token::XML_LIST_PROPERTY
|
|
|
|
: token::XML_PROPERTY, sal_True, sal_True);
|
2001-04-11 12:44:23 +00:00
|
|
|
|
|
|
|
if (!bIsSequence)
|
|
|
|
continue;
|
2000-11-19 14:41:32 +00:00
|
|
|
|
2001-04-11 12:44:23 +00:00
|
|
|
// the not-that-simple case, we need to iterate through the sequence elements
|
|
|
|
IIterator* pSequenceIterator = NULL;
|
|
|
|
switch (aSimpleType.getTypeClass())
|
|
|
|
{
|
|
|
|
case TypeClass_STRING:
|
|
|
|
pSequenceIterator = new OSequenceIterator< ::rtl::OUString >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_DOUBLE:
|
|
|
|
pSequenceIterator = new OSequenceIterator< double >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_BOOLEAN:
|
|
|
|
pSequenceIterator = new OSequenceIterator< sal_Bool >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_BYTE:
|
|
|
|
pSequenceIterator = new OSequenceIterator< sal_Int8 >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_SHORT:
|
|
|
|
pSequenceIterator = new OSequenceIterator< sal_Int16 >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_LONG:
|
|
|
|
pSequenceIterator = new OSequenceIterator< sal_Int32 >(aValue);
|
|
|
|
break;
|
|
|
|
case TypeClass_HYPER:
|
|
|
|
pSequenceIterator = new OSequenceIterator< sal_Int64 >(aValue);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OSL_ENSURE(sal_False, "OPropertyExport::exportRemainingProperties: unsupported sequence tyoe !");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pSequenceIterator)
|
|
|
|
{
|
|
|
|
while (pSequenceIterator->hasMoreElements())
|
|
|
|
{
|
2004-07-13 07:14:38 +00:00
|
|
|
sValue =
|
|
|
|
implConvertAny(pSequenceIterator->nextElement());
|
|
|
|
AddAttribute(XML_NAMESPACE_OFFICE, eValue, sValue );
|
|
|
|
SvXMLElementExport aValueTag(
|
|
|
|
m_rContext.getGlobalContext(),
|
|
|
|
XML_NAMESPACE_FORM, token::XML_LIST_VALUE,
|
|
|
|
sal_True, sal_False);
|
2001-04-11 12:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pSequenceIterator;
|
|
|
|
}
|
2000-11-19 14:41:32 +00:00
|
|
|
}
|
2001-04-11 12:44:23 +00:00
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
delete pPropertiesTag;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
delete pPropertiesTag;
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::examinePersistence()
|
|
|
|
{
|
|
|
|
m_aRemainingProps.clear();
|
2000-11-19 14:41:32 +00:00
|
|
|
Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
|
|
|
|
const Property* pProperties = aProperties.getConstArray();
|
|
|
|
for (sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties)
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
2000-11-19 14:41:32 +00:00
|
|
|
static sal_Int32 nExcludeIndicator = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
|
|
|
|
if (pProperties->Attributes & nExcludeIndicator)
|
|
|
|
// no readonly props, no transient props
|
|
|
|
continue;
|
|
|
|
m_aRemainingProps.insert(pProperties->Name);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
2002-10-25 07:01:56 +00:00
|
|
|
void OPropertyExport::exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
|
|
|
|
const ::rtl::OUString& _rPropertyName )
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY( _rPropertyName, ::rtl::OUString );
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
// no try-catch here, this would be to expensive. The outer scope has to handle exceptions (which should not
|
|
|
|
// happen if we're used correctly :)
|
|
|
|
|
|
|
|
// this is way simple, as we don't need to convert anything (the property already is a string)
|
|
|
|
|
|
|
|
// get the string
|
|
|
|
::rtl::OUString sPropValue;
|
2002-10-25 07:01:56 +00:00
|
|
|
m_xProps->getPropertyValue( _rPropertyName ) >>= sPropValue;
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
// add the attribute
|
2002-10-25 07:01:56 +00:00
|
|
|
if ( sPropValue.getLength() )
|
|
|
|
AddAttribute( _nNamespaceKey, _pAttributeName, sPropValue );
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
// the property does not need to be handled anymore
|
2002-10-25 07:01:56 +00:00
|
|
|
exportedProperty( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
2000-11-19 14:41:32 +00:00
|
|
|
void OPropertyExport::exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
|
2002-10-25 07:01:56 +00:00
|
|
|
const ::rtl::OUString& _rPropertyName, const sal_Int8 _nBooleanAttributeFlags)
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY_NO_TYPE( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
// no check of the property value type: this method is allowed to be called with any interger properties
|
|
|
|
// (e.g. sal_Int32, sal_uInt16 etc)
|
|
|
|
|
2001-03-29 11:18:58 +00:00
|
|
|
sal_Bool bDefault = (BOOLATTR_DEFAULT_TRUE == (BOOLATTR_DEFAULT_MASK & _nBooleanAttributeFlags));
|
|
|
|
sal_Bool bDefaultVoid = (BOOLATTR_DEFAULT_VOID == (BOOLATTR_DEFAULT_MASK & _nBooleanAttributeFlags));
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
// get the value
|
2001-03-29 11:18:58 +00:00
|
|
|
sal_Bool bCurrentValue = bDefault;
|
2002-10-25 07:01:56 +00:00
|
|
|
Any aCurrentValue = m_xProps->getPropertyValue( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
if (aCurrentValue.hasValue())
|
2001-03-29 11:18:58 +00:00
|
|
|
{
|
2000-11-17 18:03:33 +00:00
|
|
|
bCurrentValue = ::cppu::any2bool(aCurrentValue);
|
|
|
|
// this will extract a boolean value even if the Any contains a int or short or something like that ...
|
|
|
|
|
2001-03-29 11:18:58 +00:00
|
|
|
if (_nBooleanAttributeFlags & BOOLATTR_INVERSE_SEMANTICS)
|
|
|
|
bCurrentValue = !bCurrentValue;
|
2000-11-17 18:03:33 +00:00
|
|
|
|
2001-03-29 11:18:58 +00:00
|
|
|
// we have a non-void current value
|
|
|
|
if (bDefaultVoid || (bDefault != bCurrentValue))
|
|
|
|
// and (the default is void, or the non-void default does not equal the current value)
|
|
|
|
// -> write the attribute
|
|
|
|
AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// we have a void current value
|
|
|
|
if (!bDefaultVoid)
|
|
|
|
// and we have a non-void default
|
|
|
|
// -> write the attribute
|
|
|
|
AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
|
2000-11-17 18:03:33 +00:00
|
|
|
|
2000-11-19 14:41:32 +00:00
|
|
|
// the property does not need to be handled anymore
|
2002-10-25 07:01:56 +00:00
|
|
|
exportedProperty( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
2000-11-19 14:41:32 +00:00
|
|
|
void OPropertyExport::exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
|
2002-10-25 07:01:56 +00:00
|
|
|
const ::rtl::OUString& _rPropertyName, const sal_Int16 _nDefault)
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY( _rPropertyName, sal_Int16 );
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
// get the value
|
|
|
|
sal_Int16 nCurrentValue(_nDefault);
|
2002-10-25 07:01:56 +00:00
|
|
|
m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
// add the attribute
|
|
|
|
if (_nDefault != nCurrentValue)
|
|
|
|
{
|
|
|
|
// let the formatter of the export context build a string
|
|
|
|
::rtl::OUStringBuffer sBuffer;
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(sBuffer, (sal_Int32)nCurrentValue);
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear());
|
|
|
|
}
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
// the property does not need to be handled anymore
|
2002-10-25 07:01:56 +00:00
|
|
|
exportedProperty( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 11:10:15 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
|
|
|
|
const ::rtl::OUString& _rPropertyName, const sal_Int32 _nDefault )
|
|
|
|
{
|
|
|
|
DBG_CHECK_PROPERTY( _rPropertyName, sal_Int32 );
|
|
|
|
|
|
|
|
// get the value
|
|
|
|
sal_Int32 nCurrentValue( _nDefault );
|
|
|
|
m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
|
|
|
|
|
|
|
|
// add the attribute
|
|
|
|
if ( _nDefault != nCurrentValue )
|
|
|
|
{
|
|
|
|
// let the formatter of the export context build a string
|
|
|
|
::rtl::OUStringBuffer sBuffer;
|
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber( sBuffer, nCurrentValue );
|
|
|
|
|
|
|
|
AddAttribute( _nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// the property does not need to be handled anymore
|
|
|
|
exportedProperty( _rPropertyName );
|
|
|
|
}
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
//---------------------------------------------------------------------
|
2000-11-19 14:41:32 +00:00
|
|
|
void OPropertyExport::exportEnumPropertyAttribute(
|
2000-11-17 18:03:33 +00:00
|
|
|
const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName,
|
2001-04-17 06:58:12 +00:00
|
|
|
const sal_Char* _pPropertyName, const SvXMLEnumMapEntry* _pValueMap,
|
|
|
|
const sal_Int32 _nDefault, const sal_Bool _bVoidDefault)
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
|
|
|
// get the value
|
|
|
|
sal_Int32 nCurrentValue(_nDefault);
|
2000-11-19 14:41:32 +00:00
|
|
|
::rtl::OUString sPropertyName(::rtl::OUString::createFromAscii(_pPropertyName));
|
2001-04-17 06:58:12 +00:00
|
|
|
Any aValue = m_xProps->getPropertyValue(sPropertyName);
|
2000-11-17 18:03:33 +00:00
|
|
|
|
2001-04-17 06:58:12 +00:00
|
|
|
if (aValue.hasValue())
|
|
|
|
{ // we have a non-void current value
|
|
|
|
::cppu::enum2int(nCurrentValue, aValue);
|
2000-11-17 18:03:33 +00:00
|
|
|
|
2001-04-17 06:58:12 +00:00
|
|
|
// add the attribute
|
|
|
|
if ((_nDefault != nCurrentValue) || _bVoidDefault)
|
|
|
|
{ // the default does not equal the value, or the default is void and the value isn't
|
|
|
|
|
|
|
|
// let the formatter of the export context build a string
|
|
|
|
::rtl::OUStringBuffer sBuffer;
|
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(sBuffer, (sal_uInt16)nCurrentValue, _pValueMap);
|
|
|
|
|
|
|
|
AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!_bVoidDefault)
|
|
|
|
AddAttributeASCII(_nNamespaceKey, _pAttributeName, "");
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
// the property does not need to be handled anymore
|
|
|
|
exportedProperty(sPropertyName);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
2000-11-19 14:41:32 +00:00
|
|
|
void OPropertyExport::exportTargetFrameAttribute()
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY( PROPERTY_TARGETFRAME, ::rtl::OUString );
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
::rtl::OUString sTargetFrame = comphelper::getString(m_xProps->getPropertyValue(PROPERTY_TARGETFRAME));
|
2001-03-28 12:58:52 +00:00
|
|
|
if (0 != sTargetFrame.compareToAscii("_blank"))
|
2000-11-17 18:03:33 +00:00
|
|
|
{ // an empty string and "_blank" have the same meaning and don't have to be written
|
2004-08-02 13:15:40 +00:00
|
|
|
AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_FRAME)
|
|
|
|
,OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME)
|
|
|
|
,sTargetFrame);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
2001-03-28 12:58:52 +00:00
|
|
|
|
2000-11-19 14:41:32 +00:00
|
|
|
exportedProperty(PROPERTY_TARGETFRAME);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 12:32:38 +00:00
|
|
|
//---------------------------------------------------------------------
|
2002-08-22 06:36:10 +00:00
|
|
|
void OPropertyExport::exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty)
|
2001-06-25 12:32:38 +00:00
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY( _sPropertyName, ::rtl::OUString );
|
2001-06-25 12:32:38 +00:00
|
|
|
|
2002-08-22 06:36:10 +00:00
|
|
|
::rtl::OUString sTargetLocation = comphelper::getString(m_xProps->getPropertyValue(_sPropertyName));
|
2003-12-11 11:10:15 +00:00
|
|
|
if ( sTargetLocation.getLength() )
|
|
|
|
sTargetLocation = m_rContext.getGlobalContext().GetRelativeReference(sTargetLocation);
|
2004-08-02 13:15:40 +00:00
|
|
|
AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(_nProperty)
|
|
|
|
,OAttributeMetaData::getCommonControlAttributeName(_nProperty)
|
|
|
|
, sTargetLocation);
|
2001-06-25 12:32:38 +00:00
|
|
|
|
2002-08-22 06:36:10 +00:00
|
|
|
exportedProperty(_sPropertyName);
|
2001-06-25 12:32:38 +00:00
|
|
|
}
|
2000-11-17 18:03:33 +00:00
|
|
|
//---------------------------------------------------------------------
|
2001-02-01 08:46:47 +00:00
|
|
|
void OPropertyExport::flagStyleProperties()
|
2000-11-19 14:41:32 +00:00
|
|
|
{
|
2000-12-18 14:14:35 +00:00
|
|
|
// flag all the properties which are part of the style as "handled"
|
|
|
|
UniReference< XMLPropertySetMapper > xStylePropertiesSupplier = m_rContext.getStylePropertyMapper()->getPropertySetMapper();
|
|
|
|
for (sal_Int32 i=0; i<xStylePropertiesSupplier->GetEntryCount(); ++i)
|
|
|
|
exportedProperty(xStylePropertiesSupplier->GetEntryAPIName(i));
|
|
|
|
|
|
|
|
// the font properties are exported as single properties, but there is a FontDescriptor property which
|
|
|
|
// collects them all-in-one, this has been exported implicitly
|
2000-11-19 14:41:32 +00:00
|
|
|
exportedProperty(PROPERTY_FONT);
|
2001-05-28 14:00:42 +00:00
|
|
|
|
|
|
|
// for the DateFormat and TimeFormat, there exist wrapper properties which has been exported as
|
|
|
|
// style, too
|
|
|
|
exportedProperty(PROPERTY_DATEFORMAT);
|
|
|
|
exportedProperty(PROPERTY_TIMEFORMAT);
|
2000-11-19 14:41:32 +00:00
|
|
|
}
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
//---------------------------------------------------------------------
|
2000-11-19 14:41:32 +00:00
|
|
|
void OPropertyExport::exportGenericPropertyAttribute(
|
2000-11-17 18:03:33 +00:00
|
|
|
const sal_uInt16 _nAttributeNamespaceKey, const sal_Char* _pAttributeName, const sal_Char* _pPropertyName)
|
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY_ASCII_NO_TYPE( _pPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
|
|
|
|
::rtl::OUString sPropertyName = ::rtl::OUString::createFromAscii(_pPropertyName);
|
2000-11-19 14:41:32 +00:00
|
|
|
exportedProperty(sPropertyName);
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
Any aCurrentValue = m_xProps->getPropertyValue(sPropertyName);
|
|
|
|
if (!aCurrentValue.hasValue())
|
|
|
|
// nothing to do without a concrete value
|
|
|
|
return;
|
|
|
|
|
|
|
|
::rtl::OUString sValue = implConvertAny(aCurrentValue);
|
|
|
|
if (!sValue.getLength() && (TypeClass_STRING == aCurrentValue.getValueTypeClass()))
|
|
|
|
{
|
|
|
|
// check whether or not the property is allowed to be VOID
|
2000-11-19 14:41:32 +00:00
|
|
|
Property aProperty = m_xPropertyInfo->getPropertyByName(sPropertyName);
|
|
|
|
if ((aProperty.Attributes & PropertyAttribute::MAYBEVOID) == 0)
|
|
|
|
// the string is empty, and the property is not allowed to be void
|
|
|
|
// -> don't need to write the attibute, 'cause missing it is unambiguous
|
|
|
|
return;
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// finally add the attribuite to the context
|
|
|
|
AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sValue);
|
2000-11-19 14:41:32 +00:00
|
|
|
}
|
2000-11-17 18:03:33 +00:00
|
|
|
|
2000-11-19 14:41:32 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const sal_Char* _pAttributeName,
|
2002-10-25 07:01:56 +00:00
|
|
|
const ::rtl::OUString& _rPropertyName,
|
2000-11-19 14:41:32 +00:00
|
|
|
const sal_Unicode _aQuoteCharacter, const sal_Unicode _aListSeparator)
|
|
|
|
{
|
2002-10-25 07:01:56 +00:00
|
|
|
DBG_CHECK_PROPERTY( _rPropertyName, Sequence< ::rtl::OUString > );
|
2000-11-19 14:41:32 +00:00
|
|
|
OSL_ENSURE(_aListSeparator != 0, "OPropertyExport::exportStringSequenceAttribute: invalid separator character!");
|
|
|
|
|
|
|
|
Sequence< ::rtl::OUString > aItems;
|
2002-10-25 07:01:56 +00:00
|
|
|
m_xProps->getPropertyValue( _rPropertyName ) >>= aItems;
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
::rtl::OUString sFinalList;
|
|
|
|
|
|
|
|
// unfortunately the OUString can't append single sal_Unicode characters ...
|
|
|
|
const ::rtl::OUString sQuote(&_aQuoteCharacter, 1);
|
|
|
|
const ::rtl::OUString sSeparator(&_aListSeparator, 1);
|
2000-12-06 16:28:05 +00:00
|
|
|
const sal_Bool bQuote = 0 != sQuote.getLength();
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
// concatenate the string items
|
|
|
|
const ::rtl::OUString* pItems = aItems.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pItems + aItems.getLength();
|
|
|
|
const ::rtl::OUString* pLastElement = pEnd - 1;
|
|
|
|
for ( ;
|
|
|
|
pItems != pEnd;
|
|
|
|
++pItems
|
|
|
|
)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(!_aQuoteCharacter || (-1 == pItems->indexOf(_aQuoteCharacter)),
|
|
|
|
"OPropertyExport::exportStringSequenceAttribute: there is an item which contains the quote character!");
|
|
|
|
OSL_ENSURE(_aQuoteCharacter || (-1 == pItems->indexOf(_aListSeparator)),
|
|
|
|
"OPropertyExport::exportStringSequenceAttribute: no quote character, but there is an item containing the separator character!");
|
|
|
|
|
|
|
|
if (bQuote)
|
|
|
|
sFinalList += sQuote;
|
|
|
|
sFinalList += *pItems;
|
|
|
|
if (bQuote)
|
|
|
|
sFinalList += sQuote;
|
|
|
|
|
|
|
|
if (pItems != pLastElement)
|
|
|
|
sFinalList += sSeparator;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sFinalList.getLength())
|
|
|
|
AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sFinalList);
|
|
|
|
|
2002-10-25 07:01:56 +00:00
|
|
|
exportedProperty( _rPropertyName );
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
::rtl::OUString OPropertyExport::implConvertAny(const Any& _rValue)
|
|
|
|
{
|
|
|
|
::rtl::OUStringBuffer aBuffer;
|
|
|
|
switch (_rValue.getValueTypeClass())
|
|
|
|
{
|
|
|
|
case TypeClass_STRING:
|
|
|
|
{ // extract the string
|
|
|
|
::rtl::OUString sCurrentValue;
|
|
|
|
_rValue >>= sCurrentValue;
|
|
|
|
aBuffer.append(sCurrentValue);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TypeClass_DOUBLE:
|
|
|
|
// let the unit converter format is as string
|
2001-02-26 09:28:04 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertDouble(aBuffer, getDouble(_rValue));
|
2000-11-17 18:03:33 +00:00
|
|
|
break;
|
|
|
|
case TypeClass_BOOLEAN:
|
2000-11-19 14:41:32 +00:00
|
|
|
aBuffer = getBOOL(_rValue) ? m_sValueTrue : m_sValueFalse;
|
2000-11-17 18:03:33 +00:00
|
|
|
break;
|
|
|
|
case TypeClass_BYTE:
|
|
|
|
case TypeClass_SHORT:
|
|
|
|
case TypeClass_LONG:
|
|
|
|
// let the unit converter format is as string
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue));
|
2000-11-17 18:03:33 +00:00
|
|
|
break;
|
|
|
|
case TypeClass_HYPER:
|
|
|
|
// TODO
|
2000-11-19 14:41:32 +00:00
|
|
|
OSL_ENSURE(sal_False, "OPropertyExport::implConvertAny: missing implementation for sal_Int64!");
|
2000-11-17 18:03:33 +00:00
|
|
|
break;
|
2000-11-19 14:41:32 +00:00
|
|
|
case TypeClass_ENUM:
|
|
|
|
{
|
|
|
|
// convert it into an int32
|
|
|
|
sal_Int32 nValue;
|
|
|
|
::cppu::enum2int(nValue, _rValue);
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue));
|
2000-11-19 14:41:32 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-11-17 18:03:33 +00:00
|
|
|
default:
|
|
|
|
{ // hmmm .... what else do we know?
|
|
|
|
double fValue = 0;
|
|
|
|
::com::sun::star::util::Date aDate;
|
|
|
|
::com::sun::star::util::Time aTime;
|
|
|
|
::com::sun::star::util::DateTime aDateTime;
|
|
|
|
if (_rValue >>= aDate)
|
|
|
|
{
|
|
|
|
Date aToolsDate;
|
|
|
|
::utl::typeConvert(aDate, aToolsDate);
|
|
|
|
fValue = aToolsDate.GetDate();
|
|
|
|
}
|
|
|
|
else if (_rValue >>= aTime)
|
|
|
|
{
|
|
|
|
fValue = ((aTime.Hours * 60 + aTime.Minutes) * 60 + aTime.Seconds) * 100 + aTime.HundredthSeconds;
|
|
|
|
fValue = fValue / 8640000.0;
|
|
|
|
}
|
|
|
|
else if (_rValue >>= aDateTime)
|
|
|
|
{
|
|
|
|
DateTime aToolsDateTime;
|
|
|
|
::utl::typeConvert(aDateTime, aToolsDateTime);
|
|
|
|
// the time part (the digits behind the comma)
|
|
|
|
fValue = ((aDateTime.Hours * 60 + aDateTime.Minutes) * 60 + aDateTime.Seconds) * 100 + aDateTime.HundredthSeconds;
|
|
|
|
fValue = fValue / 8640000.0;
|
|
|
|
// plus the data part (the digits in front of the comma)
|
|
|
|
fValue += aToolsDateTime.GetDate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-19 14:41:32 +00:00
|
|
|
// if any other types are added here, please remember to adjust implGetPropertyXMLType accordingly
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
// no more options ...
|
2000-11-19 14:41:32 +00:00
|
|
|
OSL_ENSURE(sal_False, "OPropertyExport::implConvertAny: unsupported value type!");
|
2000-11-17 18:03:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// let the unit converter format is as string
|
2001-02-26 09:28:04 +00:00
|
|
|
m_rContext.getGlobalContext().GetMM100UnitConverter().convertDouble(aBuffer, fValue);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aBuffer.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
2000-11-19 14:41:32 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
2004-07-13 07:14:38 +00:00
|
|
|
token::XMLTokenEnum OPropertyExport::implGetPropertyXMLType(const ::com::sun::star::uno::Type& _rType)
|
2000-11-19 14:41:32 +00:00
|
|
|
{
|
|
|
|
// handle the type description
|
|
|
|
switch (_rType.getTypeClass())
|
|
|
|
{
|
|
|
|
case TypeClass_STRING:
|
2004-07-13 07:14:38 +00:00
|
|
|
return token::XML_STRING;
|
2000-11-19 14:41:32 +00:00
|
|
|
case TypeClass_DOUBLE:
|
|
|
|
case TypeClass_BYTE:
|
|
|
|
case TypeClass_SHORT:
|
|
|
|
case TypeClass_LONG:
|
|
|
|
case TypeClass_HYPER:
|
|
|
|
case TypeClass_ENUM:
|
2004-07-13 07:14:38 +00:00
|
|
|
return token::XML_FLOAT;
|
|
|
|
case TypeClass_BOOLEAN:
|
|
|
|
return token::XML_BOOLEAN;
|
2002-11-01 11:34:08 +00:00
|
|
|
|
2000-11-19 14:41:32 +00:00
|
|
|
default:
|
2004-07-13 07:14:38 +00:00
|
|
|
return token::XML_FLOAT;
|
2000-11-19 14:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue)
|
|
|
|
{
|
2000-12-18 14:14:35 +00:00
|
|
|
OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::rtl::OUString::createFromAscii(_pName)).getLength(),
|
2000-11-17 18:03:33 +00:00
|
|
|
"OPropertyExport::AddAttribute: already have such an attribute");
|
|
|
|
|
2000-12-18 14:14:35 +00:00
|
|
|
m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue);
|
2000-11-17 18:03:33 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 15:09:54 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::AddAttribute( sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const ::rtl::OUString& _rValue )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName( _rName ).getLength(),
|
|
|
|
"OPropertyExport::AddAttribute: already have such an attribute");
|
|
|
|
|
|
|
|
m_rContext.getGlobalContext().AddAttribute( _nPrefix, _rName, _rValue );
|
|
|
|
}
|
|
|
|
|
2001-04-17 06:58:12 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::AddAttributeASCII(sal_uInt16 _nPrefix, const sal_Char* _pName, const sal_Char *pValue)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::rtl::OUString::createFromAscii(_pName)).getLength(),
|
|
|
|
"OPropertyExport::AddAttributeASCII: already have such an attribute");
|
|
|
|
|
|
|
|
m_rContext.getGlobalContext().AddAttributeASCII(_nPrefix, _pName, pValue);
|
|
|
|
}
|
|
|
|
|
2004-07-13 07:14:38 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const ::rtl::OUString& _rValue)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).getLength(),
|
|
|
|
"OPropertyExport::AddAttribute: already have such an attribute");
|
|
|
|
|
|
|
|
m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _rValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, ::xmloff::token::XMLTokenEnum _eValue )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0 == m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).getLength(),
|
|
|
|
"OPropertyExport::AddAttribute: already have such an attribute");
|
|
|
|
|
|
|
|
m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _eValue);
|
|
|
|
}
|
|
|
|
|
2000-11-17 18:03:33 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
void OPropertyExport::dbg_implCheckProperty(const ::rtl::OUString& _rPropertyName, const Type* _pType)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// the property must exist
|
2000-11-19 14:41:32 +00:00
|
|
|
if (!m_xPropertyInfo->hasPropertyByName(_rPropertyName))
|
2000-11-17 18:03:33 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False,
|
|
|
|
::rtl::OString("OPropertyExport::dbg_implCheckProperty: no property with the name ") +=
|
|
|
|
::rtl::OString(_rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US) +=
|
|
|
|
::rtl::OString("!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_pType)
|
|
|
|
{
|
|
|
|
// and it must have the correct type
|
2000-11-19 14:41:32 +00:00
|
|
|
Property aPropertyDescription = m_xPropertyInfo->getPropertyByName(_rPropertyName);
|
2000-11-17 18:03:33 +00:00
|
|
|
OSL_ENSURE(aPropertyDescription.Type.equals(*_pType), "OPropertyExport::dbg_implCheckProperty: invalid property type!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False, "OPropertyExport::dbg_implCheckProperty: caught an exception, could not check the property!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DBG_UTIL - dbg_implCheckProperty
|
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
} // namespace xmloff
|
|
|
|
//.........................................................................
|
|
|
|
|
|
|
|
|