diff options
author | Daniel Vogelheim <dvo@openoffice.org> | 2001-01-15 12:36:17 +0000 |
---|---|---|
committer | Daniel Vogelheim <dvo@openoffice.org> | 2001-01-15 12:36:17 +0000 |
commit | 5689a392042b1a4c90d08def617eae58edba049c (patch) | |
tree | 4504afafc8ac2f808f36455e4d755c0ad1d655d7 /xmloff | |
parent | 8967409f68801b7b0e8acd8cce1afc923716a39a (diff) |
- added: annotations im-/export (annotation fields)
- added: script im-/export (script fields)
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtflde.hxx | 21 | ||||
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 126 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 112 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 223 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 6 |
5 files changed, 466 insertions, 22 deletions
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index c3852b5bdc5e..89de05880b36 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -2,9 +2,9 @@ * * $RCSfile: txtflde.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: dvo $ $Date: 2000-12-11 19:10:43 $ + * last change: $Author: dvo $ $Date: 2001-01-15 13:36:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,7 +78,8 @@ class SvXMLExport; class SvXMLNumFmtExport; namespace com { namespace sun { namespace star { namespace util { -struct DateTime; + struct DateTime; + struct Date; }}}} /// field IDs, @@ -280,6 +281,11 @@ protected: const sal_Char* pValue, /// attribute value const sal_Char* pDefault); /// attribute default + /// export a string as a sequence of paragraphs + void ProcessParagraphSequence( + /// string containing the paragraphs + const ::rtl::OUString& sParagraphSequence); + /// export a numbering format (numeric, roman, alphabetic, etc.) void ProcessNumberingType( sal_Int16 nNumberingType); /// numbering type key @@ -322,6 +328,11 @@ protected: const ::com::sun::star::util::DateTime& rTime, /// date/time value sal_Bool bIsDate ); /// export as date (rather than date/time)? + /// export date according to ISO 8601 + void ProcessDate( + const sal_Char* sXMLName, /// name of attribute + const ::com::sun::star::util::Date& rTime); /// date value + /// export all attributes for bibliography data fields void ProcessBibliographyData( ::com::sun::star::uno::Reference < @@ -432,6 +443,10 @@ private: const ::rtl::OUString sPropertyURL; const ::rtl::OUString sPropertyTargetFrame; const ::rtl::OUString sPropertyFields; + const ::rtl::OUString sPropertyScriptType; + const ::rtl::OUString sPropertyURLContent; + const ::rtl::OUString sPropertyAuthor; + const ::rtl::OUString sPropertyDate; const ::rtl::OUString sEmpty; }; diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index 6abd2b00d21f..f4e20cddde5c 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -2,9 +2,9 @@ * * $RCSfile: txtfldi.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: dvo $ $Date: 2000-12-19 12:47:04 $ + * last change: $Author: dvo $ $Date: 2001-01-15 13:36:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,10 @@ #include <com/sun/star/util/DateTime.hpp> #endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif + #ifndef _XMLOFF_XMLICTXT_HXX #include "xmlictxt.hxx" #endif @@ -163,6 +167,13 @@ enum XMLTextFieldAttrTokens XML_TOK_TEXTFIELD_HREF, XML_TOK_TEXTFIELD_TARGET_FRAME, + XML_TOK_TEXTFIELD_DATE, + XML_TOK_TEXTFIELD_AUTHOR, + XML_TOK_TEXTFIELD_SCRIPT, + XML_TOK_TEXTFIELD_ANNOTATION, + XML_TOK_TEXTFIELD_THREF, // text:href (as opposed to xlink:href) + XML_TOK_TEXTFIELD_LANGUAGE, + XML_TOK_TEXTFIELD_UNKNOWN }; @@ -1326,4 +1337,115 @@ protected: }; +/** + * Import all text into a string buffer. Paragraph elements (<text:p>) + * are recognized and cause a return character (0x0a) to be added. + */ +class XMLStringBufferImportContext : public SvXMLImportContext +{ + ::rtl::OUStringBuffer& rTextBuffer; + +public: + + TYPEINFO(); + + XMLStringBufferImportContext( + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const ::rtl::OUString& sLocalName, + ::rtl::OUStringBuffer& rBuffer); + + virtual ~XMLStringBufferImportContext(); + + virtual SvXMLImportContext *CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + virtual void Characters( + const ::rtl::OUString& rChars ); + + virtual void EndElement(); +}; + + +/** Import an annotation field (<text:annotation>) */ +class XMLAnnotationImportContext : public XMLTextFieldImportContext +{ + const ::rtl::OUString sPropertyAuthor; + const ::rtl::OUString sPropertyContent; + const ::rtl::OUString sPropertyDate; + + ::rtl::OUString sAuthor; + ::rtl::OUStringBuffer aTextBuffer; + ::com::sun::star::util::Date aDate; + + sal_Bool bAuthorOK; + sal_Bool bDateOK; + +public: + + TYPEINFO(); + + XMLAnnotationImportContext(SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const ::rtl::OUString& sLocalName); + +protected: + + /// process attributes + virtual void ProcessAttribute( sal_uInt16 nAttrToken, + const ::rtl::OUString& sAttrValue ); + + /// set properties + virtual void PrepareField( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & xPropertySet); + + virtual SvXMLImportContext *CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); +}; + + +/** Import a script field (<text:script>) */ +class XMLScriptImportContext : public XMLTextFieldImportContext +{ + const ::rtl::OUString sPropertyScriptType; + const ::rtl::OUString sPropertyURLContent; + const ::rtl::OUString sPropertyContent; + + ::rtl::OUString sContent; + ::rtl::OUString sScriptType; + + sal_Bool bContentOK; + sal_Bool bScriptTypeOK; + sal_Bool bUrlContent; + +public: + + TYPEINFO(); + + XMLScriptImportContext(SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const ::rtl::OUString& sLocalName); + +protected: + + /// process attributes + virtual void ProcessAttribute( sal_uInt16 nAttrToken, + const ::rtl::OUString& sAttrValue ); + + /// set properties + virtual void PrepareField( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & xPropertySet); +}; + + #endif diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 8816cb666f82..028c60c7577a 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtflde.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: dvo $ $Date: 2000-12-12 18:30:35 $ + * last change: $Author: dvo $ $Date: 2001-01-15 13:36:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,10 +64,6 @@ * export of all text fields */ -#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ -#include <com/sun/star/util/DateTime.hpp> -#endif - #ifndef _XMLOFF_TXTFLDE_HXX #include "txtflde.hxx" #endif @@ -104,6 +100,14 @@ #include "numehelp.hxx" #endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif + +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif + #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -364,6 +368,8 @@ inline sal_Int8 const GetInt8Property(const OUString&, const Reference<XPropertySet> &); inline DateTime const GetDateTimeProperty( const OUString& sPropName, const Reference<XPropertySet> & xPropSet); +inline Date const GetDateProperty( const OUString& sPropName, + const Reference<XPropertySet> & xPropSet); @@ -435,7 +441,11 @@ XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp ) RTL_CONSTASCII_USTRINGPARAM("DependentTextFields")), sPropertyURL(RTL_CONSTASCII_USTRINGPARAM("URL")), sPropertyTargetFrame(RTL_CONSTASCII_USTRINGPARAM("TargetFrame")), - sPropertyFields(RTL_CONSTASCII_USTRINGPARAM("Fields")) + sPropertyFields(RTL_CONSTASCII_USTRINGPARAM("Fields")), + sPropertyScriptType(RTL_CONSTASCII_USTRINGPARAM("ScriptType")), + sPropertyURLContent(RTL_CONSTASCII_USTRINGPARAM("URLContent")), + sPropertyAuthor(RTL_CONSTASCII_USTRINGPARAM("Author")), + sPropertyDate(RTL_CONSTASCII_USTRINGPARAM("Date")) { } @@ -1228,6 +1238,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) GetStringProperty(sPropertyDataTableName, xPropSet)); ProcessString(sXML_condition, GetStringProperty(sPropertyCondition, xPropSet)); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation for database next field"); ExportElement(sXML_database_next); break; @@ -1240,6 +1252,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) GetStringProperty(sPropertyCondition, xPropSet)); ProcessInteger(sXML_row_number, GetIntProperty(sPropertySetNumber, xPropSet)); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation for database select field"); ExportElement(sXML_database_select); break; @@ -1356,6 +1370,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) case FIELD_ID_HIDDEN_PARAGRAPH: ProcessString(sXML_condition, GetStringProperty(sPropertyCondition, xPropSet)); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation for hidden paragraph field"); ExportElement(sXML_hidden_paragraph); break; @@ -1398,6 +1414,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) GetBoolProperty(sPropertyOn, xPropSet), sal_True); ProcessInteger(sXML_page_adjust, GetInt16Property(sPropertyOffset, xPropSet), 0); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation page variable field"); ExportElement(sXML_page_variable_set); break; @@ -1507,10 +1525,37 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) } case FIELD_ID_SCRIPT: + ProcessString(sXML_language, + GetStringProperty(sPropertyScriptType, xPropSet)); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation for script field"); + if (GetBoolProperty(sPropertyURLContent, xPropSet)) + { + ProcessString(sXML_href, + GetStringProperty(sPropertyContent, xPropSet)); + ExportElement(sXML_script); + } + else + { + ExportElement(sXML_script, + GetStringProperty(sPropertyContent, xPropSet)); + } + break; + case FIELD_ID_ANNOTATION: - // TODO: implement these fields!!! - GetExport().GetDocHandler()->characters(sPresentation); + { + ProcessString(sXML_author, + GetStringProperty(sPropertyAuthor, xPropSet)); + ProcessDate(sXML_date, + GetDateProperty(sPropertyDate, xPropSet)); + DBG_ASSERT(sPresentation.equals(sEmpty), + "Unexpected presentation for annotation field"); + SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, + sXML_annotation, sal_False, sal_True); + ProcessParagraphSequence( + GetStringProperty(sPropertyContent, xPropSet)); break; + } case FIELD_ID_UNKNOWN: default: @@ -2013,6 +2058,22 @@ void XMLTextFieldExport::ProcessString( } +/// export a string as a sequence of paragraphs +void XMLTextFieldExport::ProcessParagraphSequence( + const ::rtl::OUString& sParagraphSequence) +{ + // iterate over all string-pieces separated by return (0x0a) and + // put each inside a paragraph element. + SvXMLTokenEnumerator aEnumerator(sParagraphSequence, sal_Char(0x0a)); + OUString aSubString; + while (aEnumerator.getNextToken(aSubString)) + { + SvXMLElementExport aParagraph( + GetExport(), XML_NAMESPACE_TEXT, sXML_p, sal_True, sal_False); + GetExport().GetDocHandler()->characters(aSubString); + } +} + // export an integer attribute void XMLTextFieldExport::ProcessInteger(const sal_Char* pXmlName, sal_Int32 nNum) @@ -2122,6 +2183,20 @@ void XMLTextFieldExport::ProcessDateTime(const sal_Char* sXMLName, ProcessString(sXMLName, aBuffer.makeStringAndClear()); } +/// export date according to ISO 8601 +void XMLTextFieldExport::ProcessDate( + const sal_Char* sXMLName, + const ::com::sun::star::util::Date& rDate) +{ + // the easiest way: delegate to ProcessDateTime (as date) + DateTime aDateTime; + aDateTime.Day = rDate.Day; + aDateTime.Month = rDate.Month; + aDateTime.Year = rDate.Year; + ProcessDateTime(sXMLName, aDateTime, sal_True); +} + + /// export a date, time, or duration void XMLTextFieldExport::ProcessDateTime(const sal_Char* sXMLName, sal_Int32 nMinutes, @@ -2137,6 +2212,7 @@ void XMLTextFieldExport::ProcessDateTime(const sal_Char* sXMLName, } } + SvXMLEnumMapEntry __READONLY_DATA aBibliographyDataTypeMap[] = { { sXML_article, BibliographyDataType::ARTICLE }, @@ -2870,7 +2946,7 @@ inline Double const GetDoubleProperty( const Reference<XPropertySet> & xPropSet) { Any aAny = xPropSet->getPropertyValue(sPropName); - Double fDouble; + Double fDouble = 0.0; aAny >>= fDouble; return fDouble; } @@ -2890,7 +2966,7 @@ inline sal_Int32 const GetIntProperty( const Reference<XPropertySet> & xPropSet) { Any aAny = xPropSet->getPropertyValue(sPropName); - sal_Int32 nInt; + sal_Int32 nInt = 0; aAny >>= nInt; return nInt; } @@ -2900,7 +2976,7 @@ inline sal_Int16 const GetInt16Property( const Reference<XPropertySet> & xPropSet) { Any aAny = xPropSet->getPropertyValue(sPropName); - sal_Int16 nInt; + sal_Int16 nInt = 0; aAny >>= nInt; return nInt; } @@ -2910,7 +2986,7 @@ inline sal_Int8 const GetInt8Property( const Reference<XPropertySet> & xPropSet) { Any aAny = xPropSet->getPropertyValue(sPropName); - sal_Int8 nInt; + sal_Int8 nInt = 0; aAny >>= nInt; return nInt; } @@ -2924,3 +3000,13 @@ inline DateTime const GetDateTimeProperty( aAny >>= aTime; return aTime; } + +inline Date const GetDateProperty( + const OUString& sPropName, + const Reference<XPropertySet> & xPropSet) +{ + Any aAny = xPropSet->getPropertyValue(sPropName); + Date aDate; + aAny >>= aDate; + return aDate; +} diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index e9bed84e1149..e028faebdc5f 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtfldi.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: dvo $ $Date: 2000-12-19 12:47:03 $ + * last change: $Author: dvo $ $Date: 2001-01-15 13:36:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -217,6 +217,7 @@ using namespace ::com::sun::star::text; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::document; +using namespace ::com::sun::star::util; using namespace ::com::sun::star::xml::sax; @@ -279,6 +280,8 @@ const sal_Char sAPI_get_reference[] = "GetReference"; const sal_Char sAPI_sheet_name[] = "SheetName"; const sal_Char sAPI_url[] = "URL"; const sal_Char sAPI_bibliography[] = "Bibliography"; +const sal_Char sAPI_annotation[] = "Annotation"; +const sal_Char sAPI_script[] = "Script"; // property names const sal_Char sAPI_is_fixed[] = "IsFixed"; @@ -326,6 +329,9 @@ const sal_Char sAPI_dde_command_element[] = "DDECommandElement"; // sAPI_url: also used as service name const sal_Char sAPI_target_frame[] = "TargetFrame"; const sal_Char sAPI_representation[] = "Representation"; +const sal_Char sAPI_date[] = "Date"; +const sal_Char sAPI_url_content[] = "URLContent"; +const sal_Char sAPI_script_type[] = "ScriptType"; const sal_Char sAPI_true[] = "TRUE"; @@ -381,6 +387,12 @@ static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] = { XML_NAMESPACE_XLINK, sXML_href, XML_TOK_TEXTFIELD_HREF }, { XML_NAMESPACE_OFFICE, sXML_target_frame_name, XML_TOK_TEXTFIELD_TARGET_FRAME }, + { XML_NAMESPACE_TEXT, sXML_date, XML_TOK_TEXTFIELD_DATE }, + { XML_NAMESPACE_TEXT, sXML_author, XML_TOK_TEXTFIELD_AUTHOR }, + { XML_NAMESPACE_TEXT, sXML_script, XML_TOK_TEXTFIELD_SCRIPT }, + { XML_NAMESPACE_TEXT, sXML_annotation, XML_TOK_TEXTFIELD_ANNOTATION }, + { XML_NAMESPACE_TEXT, sXML_href, XML_TOK_TEXTFIELD_THREF }, + { XML_NAMESPACE_TEXT, sXML_language, XML_TOK_TEXTFIELD_LANGUAGE }, XML_TOKEN_MAP_END }; @@ -753,6 +765,16 @@ XMLTextFieldImportContext::CreateTextFieldImportContext( nPrefix, rName ); break; + case XML_TOK_TEXT_ANNOTATION: + pContext = new XMLAnnotationImportContext( rImport, rHlp, + nPrefix, rName); + break; + + case XML_TOK_TEXT_SCRIPT: + pContext = new XMLScriptImportContext( rImport, rHlp, + nPrefix, rName); + break; + default: // ignore! May not even be a textfield. // (Reminder: This method is called inside default:-branch) @@ -3364,3 +3386,200 @@ const sal_Char* XMLBibliographyFieldImportContext::MapBibliographyFieldName( return pName; } + +// +// XMLStringBufferImportContext +// + + +TYPEINIT1(XMLStringBufferImportContext, SvXMLImportContext); + +XMLStringBufferImportContext::XMLStringBufferImportContext( + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& sLocalName, + OUStringBuffer& rBuffer) : + SvXMLImportContext(rImport, nPrefix, sLocalName), + rTextBuffer(rBuffer) +{ +} + +XMLStringBufferImportContext::~XMLStringBufferImportContext() +{ +} + +SvXMLImportContext *XMLStringBufferImportContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList) +{ + return new XMLStringBufferImportContext(GetImport(), nPrefix, + rLocalName, rTextBuffer); +} + +void XMLStringBufferImportContext::Characters( + const OUString& rChars ) +{ + rTextBuffer.append(rChars); +} + +void XMLStringBufferImportContext::EndElement() +{ + // add return for paragraph elements + if ( (XML_NAMESPACE_TEXT == GetPrefix()) && + (GetLocalName().equalsAsciiL(sXML_p, sizeof(sXML_p)-1)) ) + { + rTextBuffer.append(sal_Unicode(0x0a)); + } +} + + + +// +// Annotation Field +// + +TYPEINIT1(XMLAnnotationImportContext, XMLTextFieldImportContext); + +XMLAnnotationImportContext::XMLAnnotationImportContext( + SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const OUString& sLocalName) : + XMLTextFieldImportContext(rImport, rHlp, sAPI_annotation, + nPrfx, sLocalName), + sPropertyAuthor(RTL_CONSTASCII_USTRINGPARAM(sAPI_author)), + sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content)), + sPropertyDate(RTL_CONSTASCII_USTRINGPARAM(sAPI_date)), + bDateOK(sal_False), + bAuthorOK(sal_False) +{ +} + +void XMLAnnotationImportContext::ProcessAttribute( + sal_uInt16 nAttrToken, + const OUString& sAttrValue ) +{ + switch (nAttrToken) + { + case XML_TOK_TEXTFIELD_DATE: + { + DateTime aDateTime; + if (SvXMLUnitConverter::convertDateTime(aDateTime, sAttrValue)) + { + aDate.Year = aDateTime.Year; + aDate.Month = aDateTime.Month; + aDate.Day = aDateTime.Day; + bDateOK = sal_True; + } + break; + } + + case XML_TOK_TEXTFIELD_AUTHOR: + sAuthor = sAttrValue; + bAuthorOK = sal_True; + break; + + default: + // ignore + break; + } + + bValid = bDateOK && bAuthorOK; +} + +SvXMLImportContext* XMLAnnotationImportContext::CreateChildContext( + USHORT nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList >& xAttrList ) +{ + return new XMLStringBufferImportContext(GetImport(), nPrefix, + rLocalName, aTextBuffer); +} + +void XMLAnnotationImportContext::PrepareField( + const Reference<XPropertySet> & xPropertySet) +{ + Any aAny; + + aAny <<= sAuthor; + xPropertySet->setPropertyValue(sPropertyAuthor, aAny); + + aAny <<= aDate; + xPropertySet->setPropertyValue(sPropertyDate, aAny); + + // delete last paragraph mark (if necessary) + OUString sBuffer = aTextBuffer.makeStringAndClear(); + if (sal_Char(0x0a) == sBuffer.getStr()[sBuffer.getLength()-1]) + { + sBuffer = sBuffer.copy(0, sBuffer.getLength()-1); + } + + aAny <<= sBuffer; + xPropertySet->setPropertyValue(sPropertyContent, aAny); +} + + + +// +// script field +// + +TYPEINIT1(XMLScriptImportContext, XMLTextFieldImportContext); + +XMLScriptImportContext::XMLScriptImportContext( + SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const OUString& sLocalName) : + XMLTextFieldImportContext(rImport, rHlp, sAPI_script, + nPrfx, sLocalName), + sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content)), + sPropertyScriptType(RTL_CONSTASCII_USTRINGPARAM(sAPI_script_type)), + sPropertyURLContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_url_content)), + bContentOK(sal_False), + bUrlContent(sal_False), + bScriptTypeOK(sal_False) +{ +} + +void XMLScriptImportContext::ProcessAttribute( + sal_uInt16 nAttrToken, + const OUString& sAttrValue ) +{ + switch (nAttrToken) + { + case XML_TOK_TEXTFIELD_THREF: + case XML_TOK_TEXTFIELD_SCRIPT: + sContent = sAttrValue; + bUrlContent = (nAttrToken == XML_TOK_TEXTFIELD_THREF); + bContentOK = sal_True; + break; + + case XML_TOK_TEXTFIELD_LANGUAGE: + sScriptType = sAttrValue; + bScriptTypeOK = sal_True; + break; + + default: + // ignore + break; + } + + bValid = bContentOK && bScriptTypeOK; +} + +void XMLScriptImportContext::PrepareField( + const Reference<XPropertySet> & xPropertySet) +{ + Any aAny; + + aAny <<= sContent; + xPropertySet->setPropertyValue(sPropertyContent, aAny); + + aAny.setValue(&bUrlContent, ::getBooleanCppuType()); + xPropertySet->setPropertyValue(sPropertyURLContent, aAny); + + aAny <<= sScriptType; + xPropertySet->setPropertyValue(sPropertyScriptType, aAny); +} diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 9f515064090c..0a52d4ebbb5c 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ + * last change: $Author: dvo $ $Date: 2001-01-15 13:36:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -387,6 +387,8 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] = { XML_NAMESPACE_TEXT, sXML_endnote_ref, XML_TOK_TEXT_ENDNOTE_REF }, { XML_NAMESPACE_TEXT, sXML_bibliography_mark, XML_TOK_TEXT_BIBLIOGRAPHY_MARK }, + { XML_NAMESPACE_TEXT, sXML_annotation, XML_TOK_TEXT_ANNOTATION }, + { XML_NAMESPACE_TEXT, sXML_script, XML_TOK_TEXT_SCRIPT }, // Calc fields { XML_NAMESPACE_TEXT, sXML_sheet_name, XML_TOK_TEXT_SHEET_NAME }, |