diff options
author | Christian Lippka <cl@openoffice.org> | 2001-05-09 13:40:42 +0000 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2001-05-09 13:40:42 +0000 |
commit | 3b8bffac96d9bff110d3284011a7828da623e7bb (patch) | |
tree | 68b8758fcb94cff0f051c642ad02058723ddcd32 | |
parent | 219ac03bc4646bcbc1235c58a770bd9e9f8472ff (diff) |
#86415# added support for number styles in draw&impress
-rw-r--r-- | xmloff/inc/XMLNumberStylesImport.hxx | 116 | ||||
-rw-r--r-- | xmloff/inc/txtflde.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/draw/XMLNumberStyles.cxx | 658 | ||||
-rw-r--r-- | xmloff/source/draw/XMLNumberStylesExport.hxx | 92 | ||||
-rw-r--r-- | xmloff/source/draw/makefile.mk | 5 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 72 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp_impl.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp_impl.hxx | 8 | ||||
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 14 |
10 files changed, 973 insertions, 18 deletions
diff --git a/xmloff/inc/XMLNumberStylesImport.hxx b/xmloff/inc/XMLNumberStylesImport.hxx new file mode 100644 index 000000000000..d8661e7f4f0d --- /dev/null +++ b/xmloff/inc/XMLNumberStylesImport.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * $RCSfile: XMLNumberStylesImport.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-05-09 14:37:03 $ + * + * 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 EXPRESSED 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_NUMBERSTYLESIMPORT_HXX +#define _XMLOFF_NUMBERSTYLESIMPORT_HXX + +#ifndef _XMLOFF_XMLSTYLE_HXX +#include "xmlstyle.hxx" +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif + +////////////////////////////////////////////////////////////////////////////// +// presentations:animations + +struct SdXMLFixedDataStyle; +class SdXMLImport; + +class SdXMLNumberFormatImportContext : public SvXMLStyleContext +{ +private: + friend class SdXMLNumberFormatMemberImportContext; + + SdXMLImport& mrImport; + + sal_Bool mbTimeStyle; + sal_Bool mbAutomatic; + sal_uInt8 mnElements[8]; + sal_Int16 mnIndex; + + sal_Int32 mnKey; + + sal_Bool compareStyle( const SdXMLFixedDataStyle* pStyle ) const; + +protected: + void add( rtl::OUString& rNumberStyle, sal_Bool bLong, sal_Bool bTextual, sal_Bool bDecimal02, rtl::OUString& rText ); + +public: + TYPEINFO(); + + SdXMLNumberFormatImportContext( SdXMLImport& rImport, + sal_uInt16 nPrfx, + const rtl::OUString& rLocalName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual ~SdXMLNumberFormatImportContext(); + + virtual void EndElement(); + + virtual SvXMLImportContext * CreateChildContext( USHORT nPrefix, const ::rtl::OUString& rLocalName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + sal_Int32 GetKey() const { return mnKey; } +}; + +#endif // _XMLOFF_NUMBERSTYLESIMPORT_HXX + diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index 1bb9ebd6b930..72f5d7684405 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -2,9 +2,9 @@ * * $RCSfile: txtflde.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: dvo $ $Date: 2001-03-23 16:30:16 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:37:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -351,7 +351,8 @@ protected: double fValue, /// float content; possibly invalid sal_Bool bExportValue, /// export value attribute? sal_Bool bExportValueType, /// export value-type attribute? - sal_Bool bExportStyle); /// export style-sttribute? + sal_Bool bExportStyle, /// export style-sttribute? + sal_Bool bTimeStyle = sal_False); // exporting a time style? /// export times, dates and durations according to ISO 8601 void ProcessDateTime( diff --git a/xmloff/source/draw/XMLNumberStyles.cxx b/xmloff/source/draw/XMLNumberStyles.cxx new file mode 100644 index 000000000000..61308d70ae2d --- /dev/null +++ b/xmloff/source/draw/XMLNumberStyles.cxx @@ -0,0 +1,658 @@ +/************************************************************************* + * + * $RCSfile: XMLNumberStyles.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ + * + * 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 EXPRESSED 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _XMLOFF_NUMBERSTYLESEXPORT_HXX +#include <XMLNumberStylesExport.hxx> +#endif + +#ifndef _XMLOFF_NUMBERSTYLESIMPORT_HXX +#include <XMLNumberStylesImport.hxx> +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#include "xmlkywd.hxx" +#include "sdxmlexp_impl.hxx" +#include "sdxmlimp_impl.hxx" + +using namespace rtl; + +struct SdXMLDataStyleNumber +{ + const char* mpNumberStyle; + sal_Bool mbLong; + sal_Bool mbTextual; + sal_Bool mbDecimal02; + const char* mpText; +} + aSdXMLDataStyleNumbers[] = +{ + { sXML_day, sal_False, sal_False, sal_False, NULL }, + { sXML_day, sal_True, sal_False, sal_False, NULL }, + { sXML_month, sal_True, sal_False, sal_False, NULL }, + { sXML_month, sal_False, sal_True, sal_False, NULL }, + { sXML_month, sal_True, sal_True, sal_False, NULL }, + { sXML_year, sal_False, sal_False, sal_False, NULL }, + { sXML_year, sal_True, sal_False, sal_False, NULL }, + { sXML_day_of_week, sal_False, sal_False, sal_False, NULL }, + { sXML_day_of_week, sal_True, sal_False, sal_False, NULL }, + { sXML_text, sal_False, sal_False, sal_False, "." }, + { sXML_text, sal_False, sal_False, sal_False, " " }, + { sXML_text, sal_False, sal_False, sal_False, ", " }, + { sXML_text, sal_False, sal_False, sal_False, ". " }, + { sXML_hours, sal_False, sal_False, sal_False, NULL }, + { sXML_minutes, sal_False, sal_False, sal_False, NULL }, + { sXML_text, sal_False, sal_False, sal_False, ":" }, + { sXML_am_pm, sal_False, sal_False, sal_False, NULL }, + { sXML_seconds, sal_False, sal_False, sal_False, NULL }, + { sXML_seconds, sal_False, sal_False, sal_True, NULL }, + { NULL } +}; + +// date + +#define DATA_STYLE_NUMBER_END 0 +#define DATA_STYLE_NUMBER_DAY 1 // <number:day/> +#define DATA_STYLE_NUMBER_DAY_LONG 2 // <number:day number:style="long"/> +#define DATA_STYLE_NUMBER_MONTH_LONG 3 // <number:month number:style="long"/> +#define DATA_STYLE_NUMBER_MONTH_TEXT 4 // <number:month number:textual="true"/> +#define DATA_STYLE_NUMBER_MONTH_LONG_TEXT 5 // <number:month number:style="long" number:textual="true"/> +#define DATA_STYLE_NUMBER_YEAR 6 // <number:year/> +#define DATA_STYLE_NUMBER_YEAR_LONG 7 // <number:year number:style="long"/> +#define DATA_STYLE_NUMBER_DAYOFWEEK 8 // <number:day-of-week/> +#define DATA_STYLE_NUMBER_DAYOFWEEK_LONG 9 // <number:day-of-week number:style="long"/> +#define DATA_STYLE_NUMBER_TEXT_POINT 10 // <number:text>.</number:text> +#define DATA_STYLE_NUMBER_TEXT_SPACE 11 // <number:text> </number:text> +#define DATA_STYLE_NUMBER_TEXT_COMMASPACE 12 // <number:text>, </number:text> +#define DATA_STYLE_NUMBER_TEXT_POINTSPACE 13 // <number:text>. </number:text> +#define DATA_STYLE_NUMBER_HOURS 14 // <number:hours/> +#define DATA_STYLE_NUMBER_MINUTES 15 // <number:minutes/> +#define DATA_STYLE_NUMBER_TEXT_COLON 16 // <number:text>:</number:text> +#define DATA_STYLE_NUMBER_AMPM 17 // <number:am-pm/> +#define DATA_STYLE_NUMBER_SECONDS 18 // <number:seconds/> +#define DATA_STYLE_NUMBER_SECONDS_02 19 // <number:seconds number:/> + + +struct SdXMLFixedDataStyle +{ + const char* mpName; + sal_Bool mbAutomatic; + sal_Bool mbDateStyle; + sal_uInt8 mpFormat[8]; +}; + +const SdXMLFixedDataStyle aSdXML_Standard_Short = +{ + "D1", sal_True, sal_True, + { + DATA_STYLE_NUMBER_DAY_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_MONTH_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_YEAR_LONG, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_Standard_Long = +{ + "D2", sal_True, sal_True, + { + DATA_STYLE_NUMBER_DAYOFWEEK_LONG, + DATA_STYLE_NUMBER_TEXT_COMMASPACE, + DATA_STYLE_NUMBER_DAY, + DATA_STYLE_NUMBER_TEXT_POINTSPACE, + DATA_STYLE_NUMBER_MONTH_LONG_TEXT, + DATA_STYLE_NUMBER_TEXT_SPACE, + DATA_STYLE_NUMBER_YEAR_LONG, + 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_1 = +{ + "D3", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAY_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_MONTH_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_YEAR, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_2 = +{ + "D4", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAY_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_MONTH_LONG, + DATA_STYLE_NUMBER_TEXT_POINT, + DATA_STYLE_NUMBER_YEAR_LONG, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_3 = +{ + "D5", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAY, + DATA_STYLE_NUMBER_TEXT_POINTSPACE, + DATA_STYLE_NUMBER_MONTH_TEXT, + DATA_STYLE_NUMBER_TEXT_SPACE, + DATA_STYLE_NUMBER_YEAR_LONG, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_4 = +{ + "D6", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAY, + DATA_STYLE_NUMBER_TEXT_POINTSPACE, + DATA_STYLE_NUMBER_MONTH_LONG_TEXT, + DATA_STYLE_NUMBER_TEXT_SPACE, + DATA_STYLE_NUMBER_YEAR_LONG, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_5 = +{ + "D7", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAYOFWEEK, + DATA_STYLE_NUMBER_TEXT_COMMASPACE, + DATA_STYLE_NUMBER_DAY, + DATA_STYLE_NUMBER_TEXT_POINTSPACE, + DATA_STYLE_NUMBER_MONTH_LONG_TEXT, + DATA_STYLE_NUMBER_TEXT_SPACE, + DATA_STYLE_NUMBER_YEAR_LONG, + 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_DateStyle_6 = +{ + "D8", sal_False, sal_True, + { + DATA_STYLE_NUMBER_DAYOFWEEK_LONG, + DATA_STYLE_NUMBER_TEXT_COMMASPACE, + DATA_STYLE_NUMBER_DAY, + DATA_STYLE_NUMBER_TEXT_POINTSPACE, + DATA_STYLE_NUMBER_MONTH_LONG_TEXT, + DATA_STYLE_NUMBER_TEXT_SPACE, + DATA_STYLE_NUMBER_YEAR_LONG, + 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_1 = +{ "T1", sal_True, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_SECONDS, + DATA_STYLE_NUMBER_AMPM, + 0, 0, + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_2 = +{ "T2", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + 0, 0, 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_3 = +{ "T3", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_SECONDS, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_4 = +{ "T4", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_SECONDS_02, + 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_5 = +{ "T5", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_AMPM, + 0, 0, 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_6 = +{ "T6", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_SECONDS, + DATA_STYLE_NUMBER_AMPM, + 0, 0 + } +}; + +const SdXMLFixedDataStyle aSdXML_TimeStyle_7 = +{ "T7", sal_False, sal_False, + { + DATA_STYLE_NUMBER_HOURS, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_MINUTES, + DATA_STYLE_NUMBER_TEXT_COLON, + DATA_STYLE_NUMBER_SECONDS_02, + DATA_STYLE_NUMBER_AMPM, + 0, 0 + } +}; + +const SdXMLFixedDataStyle* aSdXMLFixedDateFormats[SdXMLDateFormatCount] = +{ + &aSdXML_Standard_Short, + &aSdXML_Standard_Long, + &aSdXML_DateStyle_1, + &aSdXML_DateStyle_2, + &aSdXML_DateStyle_3, + &aSdXML_DateStyle_4, + &aSdXML_DateStyle_5, + &aSdXML_DateStyle_6, +}; + +const SdXMLFixedDataStyle* aSdXMLFixedTimeFormats[SdXMLTimeFormatCount] = +{ + &aSdXML_TimeStyle_1, + &aSdXML_TimeStyle_2, + &aSdXML_TimeStyle_3, + &aSdXML_TimeStyle_4, + &aSdXML_TimeStyle_5, + &aSdXML_TimeStyle_6, + &aSdXML_TimeStyle_7 +}; + +static SdXMLExportStyle( SdXMLExport& rExport, const SdXMLFixedDataStyle* pStyle ) +{ + OUString sAttrValue; + + // name + sAttrValue = OUString::createFromAscii( pStyle->mpName ); + rExport.AddAttribute( XML_NAMESPACE_STYLE, sXML_name, sAttrValue ); + + // family + sAttrValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("data-style")); + rExport.AddAttribute( XML_NAMESPACE_STYLE, sXML_family, sAttrValue ); + + if( pStyle->mbAutomatic ) + { + sAttrValue = OUString::createFromAscii( sXML_true ); + rExport.AddAttribute( XML_NAMESPACE_NUMBER, sXML_automatic_order, sAttrValue ); + } + + SvXMLElementExport aElement( rExport, XML_NAMESPACE_NUMBER, pStyle->mbDateStyle ? sXML_date_style : sXML_time_style, sal_True, sal_True ); + + const sal_uInt8* pElements = (const sal_uInt8*)&pStyle->mpFormat[0]; + + while( *pElements ) + { + SdXMLDataStyleNumber& rElement = aSdXMLDataStyleNumbers[ (*pElements++) - 1 ]; + + if( rElement.mbDecimal02 ) + { + sAttrValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("2")); + rExport.AddAttribute( XML_NAMESPACE_NUMBER, sXML_decimal_places, sAttrValue ); + } + + if( rElement.mbLong ) + { + sAttrValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_long)); + rExport.AddAttribute( XML_NAMESPACE_NUMBER, sXML_style, sAttrValue ); + } + + if( rElement.mbTextual ) + { + sAttrValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)); + rExport.AddAttribute( XML_NAMESPACE_NUMBER, sXML_textual, sAttrValue ); + } + + SvXMLElementExport aNumberStyle( rExport, XML_NAMESPACE_NUMBER, rElement.mpNumberStyle, sal_True, sal_False ); + if( rElement.mpText ) + { + sAttrValue = OUString::createFromAscii( rElement.mpText ); + rExport.GetDocHandler()->characters( sAttrValue ); + } + } +} + +void SdXMLNumberStylesExporter::exportTimeStyle( SdXMLExport& rExport, sal_Int32 nStyle ) +{ + DBG_ASSERT( (nStyle >= 0) && (nStyle < SdXMLTimeFormatCount), "Unknown time style!" ) + SdXMLExportStyle( rExport, aSdXMLFixedTimeFormats[ nStyle ] ); +} + +void SdXMLNumberStylesExporter::exportDateStyle( SdXMLExport& rExport, sal_Int32 nStyle ) +{ + DBG_ASSERT( (nStyle >= 0) && (nStyle < SdXMLDateFormatCount), "Unknown date style!" ) + SdXMLExportStyle( rExport, aSdXMLFixedDateFormats[ nStyle ] ); +} + +OUString SdXMLNumberStylesExporter::getTimeStyleName(const sal_Int32 nTimeFormat ) +{ + sal_Int32 nFormat = nTimeFormat; + if( nFormat > 1 ) + nFormat -= 2; + + if( (nFormat >= 0) && (nFormat < SdXMLTimeFormatCount) ) + { + return OUString::createFromAscii(aSdXMLFixedTimeFormats[nFormat]->mpName ); + } + else + { + return OUString(); + } +} + +OUString SdXMLNumberStylesExporter::getDateStyleName(const sal_Int32 nDateFormat ) +{ + sal_Int32 nFormat = nDateFormat; + if( nFormat > 1 ) + nFormat -= 2; + + if( (nFormat >= 0) && (nFormat < SdXMLDateFormatCount) ) + { + return OUString::createFromAscii(aSdXMLFixedDateFormats[nFormat]->mpName ); + } + else + { + return OUString(); + } +} + + +/////////////////////////////////////////////////////////////////////// +// import + +class SdXMLNumberFormatMemberImportContext : public SvXMLImportContext +{ +private: + SdXMLNumberFormatImportContext* mpParent; + + OUString maNumberStyle; + sal_Bool mbLong; + sal_Bool mbTextual; + sal_Bool mbDecimal02; + OUString maText; + +public: + TYPEINFO(); + + SdXMLNumberFormatMemberImportContext( SvXMLImport& rImport, + sal_uInt16 nPrfx, + const rtl::OUString& rLocalName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, + SdXMLNumberFormatImportContext* pParent ); + virtual ~SdXMLNumberFormatMemberImportContext(); + + virtual void EndElement(); + + virtual void Characters( const ::rtl::OUString& rChars ); +}; + +TYPEINIT1( SdXMLNumberFormatMemberImportContext, SvXMLImportContext ); + +SdXMLNumberFormatMemberImportContext::SdXMLNumberFormatMemberImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, SdXMLNumberFormatImportContext* pParent ) +: SvXMLImportContext(rImport, nPrfx, rLocalName), + mpParent( pParent ), + maNumberStyle( rLocalName ) +{ + mbLong = sal_False; + mbTextual = sal_False; + mbDecimal02 = sal_False; + + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for(sal_Int16 i=0; i < nAttrCount; i++) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + OUString sValue = xAttrList->getValueByIndex( i ); + + if( nPrefix == XML_NAMESPACE_NUMBER ) + { + if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_decimal_places ) ) ) + { + mbDecimal02 = sValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("2") ); + } + else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_style ) ) ) + { + mbLong = sValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_long ) ); + } + else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_textual ) ) ) + { + mbTextual = sValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_true ) ); + } + } + } + +} + +SdXMLNumberFormatMemberImportContext::~SdXMLNumberFormatMemberImportContext() +{ +} + +void SdXMLNumberFormatMemberImportContext::EndElement() +{ + if( mpParent ) + mpParent->add( maNumberStyle, mbLong, mbTextual, mbDecimal02, maText ); +} + +void SdXMLNumberFormatMemberImportContext::Characters( const ::rtl::OUString& rChars ) +{ + maText += rChars; +} + +TYPEINIT1( SdXMLNumberFormatImportContext, SvXMLImportContext ); + + +SdXMLNumberFormatImportContext::SdXMLNumberFormatImportContext( SdXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList) +: SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList), + mbAutomatic( sal_False ), mnIndex(0), mrImport( rImport ), mnKey( -1 ) +{ + mbTimeStyle = rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_time_style ) ); + + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for(sal_Int16 i=0; i < nAttrCount; i++) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + OUString sValue = xAttrList->getValueByIndex( i ); + + if( nPrefix == XML_NAMESPACE_NUMBER ) + { + if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_automatic_order ) ) ) + { + mbAutomatic = sValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_true ) ); + } + } + } +} + +SdXMLNumberFormatImportContext::~SdXMLNumberFormatImportContext() +{ +} + +void SdXMLNumberFormatImportContext::add( OUString& rNumberStyle, sal_Bool bLong, sal_Bool bTextual, sal_Bool bDecimal02, OUString& rText ) +{ + if( mnIndex == -1 || mnIndex == 8 ) + { + mnIndex = -1; + return; + } + + const SdXMLDataStyleNumber* pStyleMember = aSdXMLDataStyleNumbers; + for( sal_uInt8 nIndex = 0; pStyleMember->mpNumberStyle; nIndex++, pStyleMember++ ) + { + if( ((rNumberStyle.compareToAscii( pStyleMember->mpNumberStyle ) == 0) && + (pStyleMember->mbLong == bLong) && + (pStyleMember->mbTextual == bTextual) && + (pStyleMember->mbDecimal02 == bDecimal02) && + ( ( (pStyleMember->mpText == NULL) && (rText.getLength() == 0) ) || + ( pStyleMember->mpText && (rText.compareToAscii( pStyleMember->mpText ) == 0 )) ) ) ) + { + mnElements[mnIndex++] = nIndex + 1; + return; + } + } +} + +sal_Bool SdXMLNumberFormatImportContext::compareStyle( const SdXMLFixedDataStyle* pStyle ) const +{ + if( pStyle->mbAutomatic != mbAutomatic ) + return sal_False; + + for( sal_Int16 nIndex = 0; nIndex < 8; nIndex++ ) + { + if( pStyle->mpFormat[nIndex] != mnElements[nIndex] ) + return sal_False; + } + + return sal_True; +} + +void SdXMLNumberFormatImportContext::EndElement() +{ + for( ; mnIndex < 8; mnIndex++ ) + { + mnElements[mnIndex] = 0; + } + + if( mbTimeStyle ) + { + // compare import with all time styles + for( sal_Int16 nFormat = 0; nFormat < SdXMLTimeFormatCount; nFormat++ ) + { + if( compareStyle( aSdXMLFixedTimeFormats[nFormat] ) ) + { + mnKey = nFormat + 2; + break; + } + } + } + else + { + // compare import with all date styles + for( sal_Int16 nFormat = 0; nFormat < SdXMLDateFormatCount; nFormat++ ) + { + if( compareStyle( aSdXMLFixedDateFormats[nFormat] ) ) + { + mnKey = nFormat + 2; + break; + } + } + } +} + +SvXMLImportContext * SdXMLNumberFormatImportContext::CreateChildContext( USHORT nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + return new SdXMLNumberFormatMemberImportContext( GetImport(), nPrefix, rLocalName, xAttrList, this ); +} diff --git a/xmloff/source/draw/XMLNumberStylesExport.hxx b/xmloff/source/draw/XMLNumberStylesExport.hxx new file mode 100644 index 000000000000..4629916db20e --- /dev/null +++ b/xmloff/source/draw/XMLNumberStylesExport.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * $RCSfile: XMLNumberStylesExport.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ + * + * 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 EXPRESSED 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_NUMBERSTYLESEXPORT_HXX +#define _XMLOFF_NUMBERSTYLESEXPORT_HXX + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +class SdXMLExport; + +const sal_Int16 SdXMLDateFormatCount = 8; +const sal_Int16 SdXMLTimeFormatCount = 7; + +class SdXMLNumberStylesExporter +{ +public: + static void exportTimeStyle( SdXMLExport& rExport, sal_Int32 nStyle ); + static void exportDateStyle( SdXMLExport& rExport, sal_Int32 nStyle ); + + static sal_Int32 getDateStyleCount() { return SdXMLDateFormatCount; } + static sal_Int32 getTimeStyleCount() { return SdXMLTimeFormatCount; } + + static rtl::OUString getTimeStyleName(const sal_Int32 nTimeFormat ); + static rtl::OUString getDateStyleName(const sal_Int32 nDateFormat ); +}; + +#endif // _XMLOFF_NUMBERSTYLESEXPORT_HXX + diff --git a/xmloff/source/draw/makefile.mk b/xmloff/source/draw/makefile.mk index 7e1733723c7e..e2f34473cc59 100644 --- a/xmloff/source/draw/makefile.mk +++ b/xmloff/source/draw/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.13 $ +# $Revision: 1.14 $ # -# last change: $Author: dvo $ $Date: 2001-03-29 14:40:26 $ +# last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -75,6 +75,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- SLOFILES = \ + $(SLO)$/XMLNumberStyles.obj\ $(SLO)$/XMLGraphicsDefaultStyle.obj\ $(SLO)$/viewcontext.obj\ $(SLO)$/eventimp.obj\ diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index dc1d1df69ae9..2767922a2cce 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlexp.cxx,v $ * - * $Revision: 1.61 $ + * $Revision: 1.62 $ * - * last change: $Author: cl $ $Date: 2001-05-02 10:59:52 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -230,6 +230,10 @@ #include "VisAreaExport.hxx" #endif +#ifndef _XMLOFF_NUMBERSTYLESEXPORT_HXX +#include "XMLNumberStylesExport.hxx" +#endif + using namespace ::rtl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -547,7 +551,9 @@ SdXMLExport::SdXMLExport( sal_Bool bIsDraw, sal_uInt16 nExportFlags ) msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ), msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ), msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") ), - msPageLayoutNames( RTL_CONSTASCII_USTRINGPARAM("PageLayoutNames") ) + msPageLayoutNames( RTL_CONSTASCII_USTRINGPARAM("PageLayoutNames") ), + mnUsedDateStyles( NULL ), + mnUsedTimeStyles( NULL ) { @@ -2167,6 +2173,66 @@ void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& ////////////////////////////////////////////////////////////////////////////// +void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat ) +{ + sal_Int32 nFormat = nNumberFormat; + if( nNumberFormat > 1 ) + nFormat -= 2; + + const sal_uInt32 nIndex = 1 << nFormat; + + if( bTimeFormat ) + { + mnUsedTimeStyles |= nIndex; + } + else + { + mnUsedDateStyles |= nIndex; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SdXMLExport::exportDataStyles() +{ + // there are no data styles to export in draw/impress yet +} + +////////////////////////////////////////////////////////////////////////////// + +void SdXMLExport::exportAutoDataStyles() +{ + for( sal_Int16 nDateFormat = 0; nDateFormat < SdXMLNumberStylesExporter::getDateStyleCount(); nDateFormat++ ) + { + const sal_uInt32 nIndex = 1 << nDateFormat; + if( (mnUsedDateStyles & nIndex) != 0 ) + SdXMLNumberStylesExporter::exportDateStyle( *this, nDateFormat ); + } + + for( sal_Int16 nTimeFormat = 0; nTimeFormat < SdXMLNumberStylesExporter::getTimeStyleCount(); nTimeFormat++ ) + { + const sal_uInt32 nIndex = 1 << nTimeFormat; + if( (mnUsedTimeStyles & nIndex) != 0 ) + SdXMLNumberStylesExporter::exportTimeStyle( *this, nTimeFormat ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +OUString SdXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat ) const +{ + if( bTimeFormat ) + { + return SdXMLNumberStylesExporter::getTimeStyleName( nNumberFormat ); + } + else + { + return SdXMLNumberStylesExporter::getDateStyleName( nNumberFormat ); + } +} + +////////////////////////////////////////////////////////////////////////////// + uno::Sequence< OUString > SAL_CALL SdImpressXMLExport_getSupportedServiceNames() throw() { const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Impress.XMLExporter" ) ); diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx index 5b576bea73c5..3366ea220526 100644 --- a/xmloff/source/draw/sdxmlexp_impl.hxx +++ b/xmloff/source/draw/sdxmlexp_impl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlexp_impl.hxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: cl $ $Date: 2001-03-27 22:02:09 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -151,6 +151,9 @@ class SdXMLExport : public SvXMLExport XMLShapeExportPropertyMapper* mpPropertySetMapper; XMLPageExportPropertyMapper* mpPresPagePropsMapper; + sal_uInt32 mnUsedDateStyles; // this is a bitfield of the used formatings for date fields + sal_uInt32 mnUsedTimeStyles; // this is a bitfield of the used formatings for time fields + sal_Bool mbIsDraw; sal_Bool mbFamilyGraphicUsed; sal_Bool mbFamilyPresentationUsed; @@ -212,6 +215,11 @@ public: void SetFamilyGraphicUsed() { mbFamilyGraphicUsed = TRUE; } BOOL IsFamilyPresentationUsed() const { return mbFamilyPresentationUsed; } void SetFamilyPresentationUsed() { mbFamilyPresentationUsed = TRUE; } + + virtual void addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat = sal_False ); + virtual void exportDataStyles(); + virtual void exportAutoDataStyles(); + virtual rtl::OUString getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat = sal_False ) const; }; #endif // _SDXMLEXP_HXX diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 0c158c395791..3e9fe68044ea 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlimp.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: thb $ $Date: 2001-04-26 18:04:11 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -170,6 +170,8 @@ static __FAR_DATA SvXMLTokenMapEntry aStylesElemTokenMap[] = { XML_NAMESPACE_STYLE, sXML_page_master, XML_TOK_STYLES_PAGE_MASTER }, { XML_NAMESPACE_STYLE, sXML_presentation_page_layout, XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT }, { XML_NAMESPACE_STYLE, sXML_style, XML_TOK_STYLES_STYLE }, + { XML_NAMESPACE_NUMBER, sXML_date_style, XML_TOK_STYLES_DATE_STYLE }, + { XML_NAMESPACE_NUMBER, sXML_time_style, XML_TOK_STYLES_TIME_STYLE }, XML_TOKEN_MAP_END }; @@ -975,4 +977,3 @@ void SdXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<c pValues++; } } - diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index f40353d7c450..4343b747c9fe 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlimp_impl.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: cl $ $Date: 2001-03-27 22:02:09 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,7 +115,9 @@ enum SdXMLStylesElemTokenMap XML_TOK_STYLES_MASTER_PAGE, XML_TOK_STYLES_STYLE, XML_TOK_STYLES_PAGE_MASTER, - XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT + XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT, + XML_TOK_STYLES_DATE_STYLE, + XML_TOK_STYLES_TIME_STYLE }; enum SdXMLAutoStylesElemTokenMap diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index de21b82b5196..6dd5f2a5346e 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ximpstyl.cxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.28 $ * - * last change: $Author: cl $ $Date: 2001-04-18 07:48:51 $ + * last change: $Author: cl $ $Date: 2001-05-09 14:40:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,6 +141,10 @@ #include "XMLGraphicsDefaultStyle.hxx" #endif +#ifndef _XMLOFF_NUMBERSTYLESIMPORT_HXX +#include "XMLNumberStylesImport.hxx" +#endif + using namespace ::rtl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1075,6 +1079,12 @@ SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext( pContext = new SdXMLPresentationPageLayoutContext(GetSdImport(), nPrefix, rLocalName, xAttrList); break; } + case XML_TOK_STYLES_DATE_STYLE: + case XML_TOK_STYLES_TIME_STYLE: + { + // number:date-style or number:time-style + pContext = new SdXMLNumberFormatImportContext( GetSdImport(), nPrefix, rLocalName, xAttrList ); + } } // call base class |