diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2003-04-01 08:49:09 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2003-04-01 08:49:09 +0000 |
commit | c8325858f282482751985a12cadeb3c9f7c9b08e (patch) | |
tree | bd068a512141a3d15c46e35a6c048bf073f33673 /xmloff/source | |
parent | 33a6649fe95458d365a8d0e1bbe7436b9f7539f5 (diff) |
INTEGRATION: CWS fme02 (1.16.90); FILE MERGED
2003/03/21 20:18:55 dvo 1.16.90.1: #105712# load/save PritnerIndependentLayout property (int16) as string
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/core/DocumentSettingsContext.cxx | 40 | ||||
-rw-r--r-- | xmloff/source/core/SettingsExportHelper.cxx | 71 |
2 files changed, 89 insertions, 22 deletions
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx index 79b2cb5d5d73..b98384e83a88 100644 --- a/xmloff/source/core/DocumentSettingsContext.cxx +++ b/xmloff/source/core/DocumentSettingsContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DocumentSettingsContext.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mtg $ $Date: 2001-07-27 09:53:22 $ + * last change: $Author: vg $ $Date: 2003-04-01 09:47:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,9 @@ #ifndef _COM_SUN_STAR_DOCUMENT_XVIEWDATASUPPLIER_HPP_ #include <com/sun/star/document/XViewDataSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_DOCUMENT_PRINTERINDEPENDENTLAYOUT_HPP_ +#include <com/sun/star/document/PrinterIndependentLayout.hpp> +#endif #ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> #endif @@ -234,6 +237,7 @@ class XMLConfigItemContext : public SvXMLImportContext rtl::OUString sValue; uno::Sequence<sal_Int8> aDecoded; com::sun::star::uno::Any& rAny; + const rtl::OUString rItemName; XMLConfigBaseContext* pBaseContext; public: @@ -241,6 +245,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, com::sun::star::uno::Any& rAny, + const rtl::OUString& rItemName, XMLConfigBaseContext* pBaseContext); virtual ~XMLConfigItemContext(); @@ -251,6 +256,8 @@ public: virtual void Characters( const ::rtl::OUString& rChars ); virtual void EndElement(); + + virtual void ManipulateConfigItem(); }; //============================================================================= @@ -347,7 +354,7 @@ SvXMLImportContext *CreateSettingsContext(SvXMLImport& rImport, USHORT nPrefix, if (nPrefix == XML_NAMESPACE_CONFIG) { if (IsXMLToken(rLocalName, XML_CONFIG_ITEM)) - pContext = new XMLConfigItemContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext); + pContext = new XMLConfigItemContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, rProp.Name, pBaseContext); else if((IsXMLToken(rLocalName, XML_CONFIG_ITEM_SET)) || (IsXMLToken(rLocalName, XML_CONFIG_ITEM_MAP_ENTRY)) ) pContext = new XMLConfigItemSetContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext); @@ -502,12 +509,14 @@ XMLConfigItemContext::XMLConfigItemContext(SvXMLImport& rImport, USHORT nPrfx, c const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, com::sun::star::uno::Any& rTempAny, + const rtl::OUString& rTempItemName, XMLConfigBaseContext* pTempBaseContext) : SvXMLImportContext(rImport, nPrfx, rLName), rAny(rTempAny), pBaseContext(pTempBaseContext), sType(), - sValue() + sValue(), + rItemName(rTempItemName) { sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) @@ -633,12 +642,35 @@ void XMLConfigItemContext::EndElement() } else DBG_ERROR("wrong type"); + + ManipulateConfigItem(); + pBaseContext->AddPropertyValue(); } else DBG_ERROR("no BaseContext"); } +/** There are some instances where there is a mismatch between API and + * XML mapping of a setting. In this case, this method allows us to + * manipulate the values accordingly. */ +void XMLConfigItemContext::ManipulateConfigItem() +{ + if( rItemName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "PrinterIndependentLayout" ) ) ) + { + rtl::OUString sValue; + rAny >>= sValue; + + sal_Int16 nTmp = + sValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("disabled")) + ? document::PrinterIndependentLayout::DISABLED + : document::PrinterIndependentLayout::ENABLED; + rAny <<= nTmp; + } +} + + //============================================================================= XMLConfigItemMapNamedContext::XMLConfigItemMapNamedContext(SvXMLImport& rImport, USHORT nPrfx, const rtl::OUString& rLName, diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx index 089b70ebb2c0..4d3059e81b29 100644 --- a/xmloff/source/core/SettingsExportHelper.cxx +++ b/xmloff/source/core/SettingsExportHelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SettingsExportHelper.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mtg $ $Date: 2001-07-27 09:54:08 $ + * last change: $Author: vg $ $Date: 2003-04-01 09:49:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,6 +109,9 @@ #ifndef _COM_SUN_STAR_FORMULA_SYMBOLDESCRIPTOR_HPP_ #include <com/sun/star/formula/SymbolDescriptor.hpp> #endif +#ifndef _COM_SUN_STAR_DOCUMENT_PRINTERINDEPENDENTLAYOUT_HPP_ +#include <com/sun/star/document/PrinterIndependentLayout.hpp> +#endif #ifndef _XMLENUMS_HXX_ #include <xmlenums.hxx> #endif @@ -125,10 +128,19 @@ XMLSettingsExportHelper::~XMLSettingsExportHelper() { } + +/** function to allow changing the API and XML representation; + implementation below */ +void lcl_manipulateSetting( uno::Any&, const rtl::OUString& ); + + void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny, const rtl::OUString& rName) const { - uno::TypeClass eClass = rAny.getValueTypeClass(); + uno::Any aAny( rAny ); + lcl_manipulateSetting( aAny, rName ); + + uno::TypeClass eClass = aAny.getValueTypeClass(); switch (eClass) { case uno::TypeClass_VOID: @@ -143,94 +155,94 @@ void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny, break; case uno::TypeClass_BOOLEAN: { - exportBool(::cppu::any2bool(rAny), rName); + exportBool(::cppu::any2bool(aAny), rName); } break; case uno::TypeClass_BYTE: { sal_Int8 nInt8; - rAny >>= nInt8; + aAny >>= nInt8; exportByte(nInt8, rName); } break; case uno::TypeClass_SHORT: { sal_Int16 nInt16; - rAny >>= nInt16; + aAny >>= nInt16; exportShort(nInt16, rName); } break; case uno::TypeClass_LONG: { sal_Int32 nInt32; - rAny >>= nInt32; + aAny >>= nInt32; exportInt(nInt32, rName); } break; case uno::TypeClass_HYPER: { sal_Int64 nInt64; - rAny >>= nInt64; + aAny >>= nInt64; exportLong(nInt64, rName); } break; case uno::TypeClass_DOUBLE: { double fDouble; - rAny >>= fDouble; + aAny >>= fDouble; exportDouble(fDouble, rName); } break; case uno::TypeClass_STRING: { rtl::OUString sString; - rAny >>= sString; + aAny >>= sString; exportString(sString, rName); } break; default: { - uno::Type aType = rAny.getValueType(); + uno::Type aType = aAny.getValueType(); if (aType.equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ) ) { uno::Sequence< beans::PropertyValue> aProps; - rAny >>= aProps; + aAny >>= aProps; exportSequencePropertyValue(aProps, rName); } else if( aType.equals(getCppuType( (uno::Sequence<sal_Int8> *)0 ) ) ) { uno::Sequence< sal_Int8 > aProps; - rAny >>= aProps; + aAny >>= aProps; exportbase64Binary(aProps, rName); } else if (aType.equals(getCppuType( (uno::Reference<container::XNameContainer> *)0 ) ) || aType.equals(getCppuType( (uno::Reference<container::XNameAccess> *)0 ) )) { uno::Reference< container::XNameAccess> aNamed; - rAny >>= aNamed; + aAny >>= aNamed; exportNameAccess(aNamed, rName); } else if (aType.equals(getCppuType( (uno::Reference<container::XIndexAccess> *)0 ) ) || aType.equals(getCppuType( (uno::Reference<container::XIndexContainer> *)0 ) ) ) { uno::Reference<container::XIndexAccess> aIndexed; - rAny >>= aIndexed; + aAny >>= aIndexed; exportIndexAccess(aIndexed, rName); } else if (aType.equals(getCppuType( (util::DateTime *)0 ) ) ) { util::DateTime aDateTime; - rAny >>= aDateTime; + aAny >>= aDateTime; exportDateTime(aDateTime, rName); } else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) ) { - exportForbiddenCharacters( rAny, rName ); + exportForbiddenCharacters( aAny, rName ); } else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) ) { uno::Sequence< formula::SymbolDescriptor > aProps; - rAny >>= aProps; + aAny >>= aProps; exportSymbolDescriptors(aProps, rName); } else @@ -545,3 +557,26 @@ void XMLSettingsExportHelper::exportSettings( DBG_ASSERT(aProps.getLength(), "no properties to export"); exportSequencePropertyValue(aProps, rName); } + + +/** For some settings we may want to change their API representation + * from their XML settings representation. This is your chance to do + * so! + */ +void lcl_manipulateSetting( + uno::Any& rAny, + const rtl::OUString& rName ) +{ + if( rName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "PrinterIndependentLayout" ) ) ) + { + sal_Int16 nTmp; + if( rAny >>= nTmp ) + { + if( nTmp == document::PrinterIndependentLayout::ENABLED ) + rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("enabled")); + else if( nTmp == document::PrinterIndependentLayout::DISABLED ) + rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disabled")); + } + } +} |