diff options
author | Frank Schönheit <fs@openoffice.org> | 2001-04-17 06:58:12 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2001-04-17 06:58:12 +0000 |
commit | 52ff2b217ed451e9a5852bfa69cd6effce5ce381 (patch) | |
tree | 8d8126910741a04f05deb05e66b1dd72b7d6669b /xmloff | |
parent | 138a5fc3d7966a99a5413d0092c3b18d2fd7199c (diff) |
#85427# +_bVoidDefault parameter for addEnumPropertyAttribute
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/forms/propertyexport.cxx | 46 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.hxx | 13 |
2 files changed, 45 insertions, 14 deletions
diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index 5abc45783ce7..24db876602d0 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: propertyexport.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: fs $ $Date: 2001-04-11 13:44:23 $ + * last change: $Author: fs $ $Date: 2001-04-17 07:58:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -480,21 +480,33 @@ namespace xmloff //--------------------------------------------------------------------- void OPropertyExport::exportEnumPropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName, - const sal_Char* _pPropertyName, const SvXMLEnumMapEntry* _pValueMap, const sal_Int32 _nDefault) + const sal_Char* _pPropertyName, const SvXMLEnumMapEntry* _pValueMap, + const sal_Int32 _nDefault, const sal_Bool _bVoidDefault) { // get the value sal_Int32 nCurrentValue(_nDefault); ::rtl::OUString sPropertyName(::rtl::OUString::createFromAscii(_pPropertyName)); - ::cppu::enum2int(nCurrentValue, m_xProps->getPropertyValue(sPropertyName)); + Any aValue = m_xProps->getPropertyValue(sPropertyName); - // add the attribute - if (_nDefault != nCurrentValue) - { - // let the formatter of the export context build a string - ::rtl::OUStringBuffer sBuffer; - m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(sBuffer, (sal_uInt16)nCurrentValue, _pValueMap); + if (aValue.hasValue()) + { // we have a non-void current value + ::cppu::enum2int(nCurrentValue, aValue); - AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear()); + // 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, ""); } // the property does not need to be handled anymore @@ -735,6 +747,15 @@ namespace xmloff } //--------------------------------------------------------------------- + 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); + } + + //--------------------------------------------------------------------- void OPropertyExport::dbg_implCheckProperty(const ::rtl::OUString& _rPropertyName, const Type* _pType) { try @@ -770,6 +791,9 @@ namespace xmloff /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.15 2001/04/11 13:44:23 fs + * #85904# exportRemainingProperties: create the form:properties element only if there is at least one sub element (form:property) + * * Revision 1.14 2001/03/29 12:18:58 fs * #85097# when exporting boolean properties, allow for MAYBEVOID props * diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index 7beadb8b64d6..71001a5dabbb 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -2,9 +2,9 @@ * * $RCSfile: propertyexport.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: fs $ $Date: 2001-03-29 12:18:58 $ + * last change: $Author: fs $ $Date: 2001-04-17 07:58:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -234,7 +234,8 @@ namespace xmloff const sal_Char* _pAttributeName, const sal_Char* _pPropertyName, const SvXMLEnumMapEntry* _pValueMap, - const sal_Int32 _nDefault); + const sal_Int32 _nDefault, + const sal_Bool _bVoidDefault = sal_False); // some very special methods for some very special attribute/property pairs @@ -347,10 +348,13 @@ namespace xmloff #ifdef DBG_UTIL void AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue); + void AddAttributeASCII( sal_uInt16 nPrefix, const sal_Char *pName, const sal_Char *pValue ); #else // in the product version, inline this, so it does not cost us extra time calling into our method inline void AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue) { m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue); } + inline void AddAttributeASCII( sal_uInt16 _nPrefix, const sal_Char* _pName, const sal_Char *pValue ) + { m_rContext.getGlobalContext().AddAttributeASCII(_nPrefix, _pName, pValue); } #endif #ifdef DBG_UTIL @@ -400,6 +404,9 @@ namespace xmloff /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.11 2001/03/29 12:18:58 fs + * #85097# when exporting boolean properties, allow for MAYBEVOID props + * * Revision 1.10 2001/02/01 09:46:47 fs * no own style handling anymore - the shape exporter is responsible for our styles now * |