summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorChristian Lippka <cl@openoffice.org>2001-04-26 09:47:54 +0000
committerChristian Lippka <cl@openoffice.org>2001-04-26 09:47:54 +0000
commit3baff6b36ebcec9cb42a819c13aa4d55c1ffcfdc (patch)
tree6a5e982a27196231dfdd3adce9f3505d273c6807 /xmloff/source
parent6f3ceb888b20ace7d195824dde76b6ef26b4553c (diff)
#82045# added export of Rectangle objects
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/core/DocumentSettingsContext.cxx44
-rw-r--r--xmloff/source/core/SettingsExportHelper.cxx32
2 files changed, 72 insertions, 4 deletions
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx
index d502f4507219..c4ca2cb4a855 100644
--- a/xmloff/source/core/DocumentSettingsContext.cxx
+++ b/xmloff/source/core/DocumentSettingsContext.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DocumentSettingsContext.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: cl $ $Date: 2001-04-05 16:41:01 $
+ * last change: $Author: cl $ $Date: 2001-04-26 10:47:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -112,6 +112,10 @@
#include <com/sun/star/document/XViewDataSupplier.hpp>
#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
using namespace com::sun::star;
enum XMLForbiddenCharactersEnum
@@ -542,6 +546,38 @@ void XMLConfigItemContext::Characters( const ::rtl::OUString& rChars )
sValue += rChars;
}
+
+static awt::Rectangle ImplImportRectangle( const rtl::OUString& rValue )
+{
+ awt::Rectangle aRect( 0,0,0,0 );
+
+ rtl::OUStringBuffer sBuffer;
+ const sal_Unicode * pStr = rValue.getStr();
+
+ while( ( *pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9') ) || *pStr == sal_Unicode('-') ) sBuffer.append( *pStr++ );
+ aRect.X = sBuffer.makeStringAndClear().toInt32();
+
+ if( *pStr++ == ',' )
+ {
+ while( ( *pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9') ) || *pStr == sal_Unicode('-') ) sBuffer.append( *pStr++ );
+ aRect.Y = sBuffer.makeStringAndClear().toInt32();
+
+ if( *pStr++ == ',' )
+ {
+ while( ( *pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9') ) || *pStr == sal_Unicode('-') ) sBuffer.append( *pStr++ );
+ aRect.Width = sBuffer.makeStringAndClear().toInt32();
+
+ if( *pStr++ == ',' )
+ {
+ while( ( *pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9') ) || *pStr == sal_Unicode('-') ) sBuffer.append( *pStr++ );
+ aRect.Height = sBuffer.makeStringAndClear().toInt32();
+ }
+ }
+ }
+
+ return aRect;
+}
+
void XMLConfigItemContext::EndElement()
{
if (pBaseContext)
@@ -586,6 +622,10 @@ void XMLConfigItemContext::EndElement()
SvXMLUnitConverter::convertDateTime(aDateTime, sValue);
rAny <<= aDateTime;
}
+ else if (sType.compareToAscii(sXML_rect) == 0)
+ {
+ rAny <<= ImplImportRectangle(sValue);
+ }
else
DBG_ERROR("wrong type");
pBaseContext->AddPropertyValue();
diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx
index 4f1b831dcca5..a9c34aa55652 100644
--- a/xmloff/source/core/SettingsExportHelper.cxx
+++ b/xmloff/source/core/SettingsExportHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: SettingsExportHelper.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: sab $ $Date: 2001-04-06 14:32:26 $
+ * last change: $Author: cl $ $Date: 2001-04-26 10:47:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -212,6 +212,12 @@ void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
{
exportForbiddenCharacters( rAny, rName );
}
+ else if( aType.equals(getCppuType( (const awt::Rectangle *)0 ) ) )
+ {
+ awt::Rectangle aRect;
+ rAny >>= aRect;
+ exportRectangle( aRect, rName );
+ }
else
DBG_ERROR("this type is not implemented now");
}
@@ -436,3 +442,25 @@ void XMLSettingsExportHelper::exportSettings(
DBG_ASSERT(aProps.getLength(), "no properties to export");
exportSequencePropertyValue(aProps, rName);
}
+
+void XMLSettingsExportHelper::exportRectangle(
+ const com::sun::star::awt::Rectangle& aValue,
+ const rtl::OUString rName) const
+{
+ DBG_ASSERT(rName.getLength(), "no name");
+ rExport.AddAttribute(XML_NAMESPACE_CONFIG, sXML_name, rName);
+ rExport.AddAttributeASCII(XML_NAMESPACE_CONFIG, sXML_type, sXML_rect);
+
+ rtl::OUStringBuffer sBuffer;
+
+ sBuffer.append( aValue.X );
+ sBuffer.append( sal_Unicode(',') );
+ sBuffer.append( aValue.Y );
+ sBuffer.append( sal_Unicode(',') );
+ sBuffer.append( aValue.Width );
+ sBuffer.append( sal_Unicode(',') );
+ sBuffer.append( aValue.Height );
+
+ SvXMLElementExport aDoubleElem(rExport, XML_NAMESPACE_CONFIG, sXML_config_item, sal_True, sal_False);
+ rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
+}