summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2001-03-28 12:59:54 +0000
committerFrank Schönheit <fs@openoffice.org>2001-03-28 12:59:54 +0000
commit86fadf1e2fe7747bad999e87ff2ff4b3b1c48f3b (patch)
tree0edcc52693f6cce503704254d2c9151e3f103e99 /xmloff/source
parentc2d8ab9029cdf2545d167c3f0904ff6af202c447 (diff)
#85371# +simulateDefaultedAttribute / +encounteredAttribute
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/forms/propertyimport.cxx32
-rw-r--r--xmloff/source/forms/propertyimport.hxx31
2 files changed, 56 insertions, 7 deletions
diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx
index a1bcf9ff30bb..628954d2015f 100644
--- a/xmloff/source/forms/propertyimport.cxx
+++ b/xmloff/source/forms/propertyimport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertyimport.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: fs $ $Date: 2001-03-28 09:59:38 $
+ * last change: $Author: fs $ $Date: 2001-03-28 13:59:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,9 @@
#ifndef _XMLOFF_PRSTYLEI_HXX_
#include "prstylei.hxx"
#endif
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include "xmlnmspe.hxx"
+#endif
#ifndef _DATE_HXX
#include <tools/date.hxx>
#endif
@@ -165,6 +168,8 @@ namespace xmloff
{
nNamespace = m_rContext.getGlobalContext().GetNamespaceMap().GetKeyByAttrName(_rxAttrList->getNameByIndex(i), &sLocalName);
handleAttribute(nNamespace, sLocalName, _rxAttrList->getValueByIndex(i));
+
+ m_aEncounteredAttributes.insert(sLocalName);
}
// TODO: create PropertyValues for all the attributes which were not present, because they were implied
@@ -178,6 +183,20 @@ namespace xmloff
}
//---------------------------------------------------------------------
+ sal_Bool OPropertyImport::encounteredAttribute(const ::rtl::OUString& _rAttributeName) const
+ {
+ return m_aEncounteredAttributes.end() != m_aEncounteredAttributes.find(_rAttributeName);
+ }
+
+ //---------------------------------------------------------------------
+ void OPropertyImport::simluateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault)
+ {
+ ::rtl::OUString sLocalAttrName = ::rtl::OUString::createFromAscii(_pAttributeName);
+ if (!encounteredAttribute(sLocalAttrName))
+ handleAttribute(XML_NAMESPACE_FORM, sLocalAttrName, ::rtl::OUString::createFromAscii(_pAttributeDefault));
+ }
+
+ //---------------------------------------------------------------------
void OPropertyImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
{
const OAttribute2Property::AttributeAssignment* pProperty = m_rContext.getAttributeMap().getAttributeTranslation(_rLocalName);
@@ -354,8 +373,8 @@ namespace xmloff
::com::sun::star::util::Time OPropertyImport::implGetTime(double _nValue)
{
::com::sun::star::util::Time aTime;
- sal_Int32 nIntValue = _nValue * 8640000.0;
- nIntValue *= 8640000.0;
+ sal_Int32 nIntValue = sal_Int32(_nValue * 8640000);
+ nIntValue *= 8640000;
aTime.HundredthSeconds = nIntValue % 100;
nIntValue /= 100;
aTime.Seconds = nIntValue % 60;
@@ -363,7 +382,7 @@ namespace xmloff
aTime.Minutes = nIntValue % 60;
nIntValue /= 60;
OSL_ENSURE(nIntValue < 24, "OPropertyImport::implGetTime: more than a day?");
- aTime.Hours = nIntValue;
+ aTime.Hours = (sal_uInt16)nIntValue;
return aTime;
}
@@ -536,6 +555,9 @@ namespace xmloff
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.10 2001/03/28 09:59:38 fs
+ * #85097# correctly import boolean properties with inverse semantics
+ *
* Revision 1.9 2001/03/16 14:36:39 sab
* did the required change (move of extract.hxx form cppuhelper to comphelper)
*
diff --git a/xmloff/source/forms/propertyimport.hxx b/xmloff/source/forms/propertyimport.hxx
index c1f608b5e71b..71ffa54d5f52 100644
--- a/xmloff/source/forms/propertyimport.hxx
+++ b/xmloff/source/forms/propertyimport.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertyimport.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: fs $ $Date: 2001-03-28 09:59:38 $
+ * last change: $Author: fs $ $Date: 2001-03-28 13:59:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -108,6 +108,9 @@ namespace xmloff
PropertyValueArray m_aValues;
// the values which the instance collects between StartElement and EndElement
+ DECLARE_STL_STDKEY_SET( ::rtl::OUString, StringSet );
+ StringSet m_aEncounteredAttributes;
+
IFormsImportContext& m_rContext;
// TODO: think about the restriction that the class does not know anything about the object it is importing.
@@ -144,6 +147,27 @@ namespace xmloff
const ::rtl::OUString& _rLocalName,
const ::rtl::OUString& _rValue);
+ /** determine if the element imported by the object had an given attribute.
+ <p>Please be aware of the fact that the name given must be a local name, i.e. not contain a namespace.
+ All form relevant attributes are in the same namespace, so this would be an redundant information.</p>
+ */
+ sal_Bool encounteredAttribute(const ::rtl::OUString& _rAttributeName) const;
+
+ /** determine if the element imported by the object had an given attribute.
+ <p>Please be aware of the fact that the name given must be a local name, i.e. not contain a namespace.
+ All form relevant attributes are in the same namespace, so this would be an redundant information.</p>
+ */
+ sal_Bool encounteredAttribute(const sal_Char* _pAttributeName) const { return encounteredAttribute(::rtl::OUString::createFromAscii(_pAttributeName)); }
+
+ /** can be used to handle properties where the attribute default and the property default differ.
+ <p>In such case, if the property had the attribute default upon writing, nothing is read, so upon reading,
+ the property is still at it's own default (which is not the attribute default).<p/>
+ <p>This method, if told the attribute and the property, and the (implied) attribute default, sets the
+ property value as if the attribute was encountered.</p>
+ @see encounteredAttribute
+ */
+ void simluateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault);
+
void implPushBackPropertyValue(const ::com::sun::star::beans::PropertyValue& _rProp)
{ m_aValues.push_back(_rProp); }
@@ -244,6 +268,9 @@ namespace xmloff
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.6 2001/03/28 09:59:38 fs
+ * #85097# correctly import boolean properties with inverse semantics
+ *
* Revision 1.5 2001/02/01 09:46:47 fs
* no own style handling anymore - the shape exporter is responsible for our styles now
*