diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-07-01 15:06:47 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-07-01 15:06:47 +0000 |
commit | 95177195995c9004d9f17fcde1e4f9873dc4457f (patch) | |
tree | 7bf48e8809bdc719b1c583b8953cff04eacb8f54 /xmloff/source/text/txtparai.cxx | |
parent | 7303e27f2b874700f340ace8909f78e6733ca956 (diff) |
INTEGRATION: CWS odfmetadata (1.67.50); FILE MERGED
2008/06/19 17:06:57 mst 1.67.50.1: #i90620#: import xml:id in text elements
- xmloff/source/text/XMLIndexTOCContext.cxx:
+ XMLIndexTOCContext::StartElement(): attribute xml:id
- xmloff/source/text/XMLSectionImportContext{.hxx,.cxx}:
+ XMLSectionToken: new token: XML_TOK_SECTION_XMLID
+ XMLSectionImportContext::ProcessAttributes(): attribute xml:id
- xmloff/source/text/XMLTextListBlockContext{.hxx,.cxx}:
+ XMLTextListBlockContext::XMLTextListBlockContext(): attribute xml:id
- xmloff/source/text/XMLTextListItemContext.cxx:
+ XMLTextListItemContext::XMLTextListItemContext(): attribute xml:id
- xmloff/source/text/XMLTextMarkImportContext{.hxx,.cxx}:
+ refactor methods to pass XmlId around
+ XMLTextMarkImportContext::FindName(): attribute xml:id
- xmloff/source/text/txtparai{.hxx,.cxx}:
+ new class XMLMetaImportContext
+ XMLImpSpanContext_Impl::CreateChildContext():
handle TEXT_META and (provisionally) TEXT_META_FIELD
+ XMLParaContext::XMLParaContext(): attribute xml:id
Diffstat (limited to 'xmloff/source/text/txtparai.cxx')
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 176 |
1 files changed, 165 insertions, 11 deletions
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 4224353b6400..7acc5118875c 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: txtparai.cxx,v $ - * $Revision: 1.67 $ + * $Revision: 1.68 $ * * This file is part of OpenOffice.org. * @@ -35,9 +35,7 @@ #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> -#ifndef _TOOLS_STRINGS_HXX #include <tools/string.hxx> -#endif #include <svtools/svarray.hxx> #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextCursor.hpp> @@ -47,6 +45,7 @@ #include <com/sun/star/container/XIndexReplace.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/rdf/XMetadatable.hpp> #include <xmloff/xmlictxt.hxx> @@ -54,17 +53,11 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/nmspmap.hxx> #include "xmlnmspe.hxx" -#ifndef _XMLOFF_TXTIMP_HXX #include <xmloff/txtimp.hxx> -#endif -#ifndef _XMLOFF_TXTPARAI_HXX #include "txtparai.hxx" -#endif #include "txtfldi.hxx" #include <xmloff/xmluconv.hxx> -#ifndef _XMLOFF_XMLFOOTNOTEIMPORTCONTEXT_HXX #include "XMLFootnoteImportContext.hxx" -#endif #include "XMLTextMarkImportContext.hxx" #include "XMLTextFrameContext.hxx" #include <xmloff/XMLCharContext.hxx> @@ -72,6 +65,7 @@ #include <xmloff/XMLEventsImportContext.hxx> #include "XMLChangeImportContext.hxx" + // OD 2004-04-21 #i26791# #include <txtparaimphint.hxx> typedef XMLHint_Impl *XMLHint_ImplPtr; @@ -208,10 +202,11 @@ XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl( SvXMLImportContext(rImport, nPrefix, rLocalName) { OUString sName; + OUString dummy; // borrow FindName from XMLTextMarkImportContext, where bookmarks // and point references are handled. - if (XMLTextMarkImportContext::FindName(GetImport(), xAttrList, sName)) + if (XMLTextMarkImportContext::FindName(GetImport(), xAttrList, sName, dummy)) { XMLHint_Impl* pHint = new XMLReferenceHint_Impl( sName, rImport.GetTextImport()->GetCursor()->getStart() ); @@ -251,9 +246,10 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( SvXMLImportContext(rImport, nPrefix, rLocalName) { OUString sName; + OUString dummy; // borrow from XMLTextMarkImportContext - if (XMLTextMarkImportContext::FindName(GetImport(), xAttrList, sName)) + if (XMLTextMarkImportContext::FindName(GetImport(), xAttrList, sName, dummy)) { // search for reference start sal_uInt16 nCount = rHints.Count(); @@ -673,6 +669,131 @@ SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext( // --------------------------------------------------------------------- +/** text:meta and text:meta-field +//FIXME neither finished nor tested + */ +class XMLMetaImportContext : public SvXMLImportContext +{ + XMLHints_Impl& mrHints; +// XMLStyleHint_Impl *pHint; + + sal_Bool& mrIgnoreLeadingSpace; + + /// start position + Reference<XTextRange> mxStart; + + OUString mXmlId; + +public: + TYPEINFO(); + + XMLMetaImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, +// enum XMLTextPElemTokens nTok, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ); + + virtual ~XMLMetaImportContext(); + + virtual void EndElement(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 i_nPrefix, const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList ); + + virtual void Characters( const OUString& i_rChars ); +}; + +TYPEINIT1( XMLMetaImportContext , SvXMLImportContext ); + +XMLMetaImportContext::XMLMetaImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ) + : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ), + mrHints( i_rHints ), + mrIgnoreLeadingSpace( i_rIgnoreLeadingSpace ), + mxStart() +{ +//FIXME: RDFa (text:meta) + const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0); + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) ); + const OUString& rValue( i_xAttrList->getValueByIndex( i ) ); + + OUString sLocalName; + sal_uInt16 nPrefix = + GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, + &sLocalName ); +// FIXME: only meta-field + if( XML_NAMESPACE_TEXT == nPrefix && + IsXMLToken( sLocalName, XML_DATA_STYLE_NAME ) ) + { +// pHint->SetStyleName( rValue ); + break; + } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken(sLocalName, XML_ID) ) + { + mXmlId = rValue; + } + } + //FIXME meta-field xml:id mandatory + mxStart = GetImport().GetTextImport()->GetCursorAsRange()->getStart(); +} + +XMLMetaImportContext::~XMLMetaImportContext() +{ +} + +void XMLMetaImportContext::EndElement() +{ + OSL_ENSURE(mxStart.is(), "no mxStart?"); + + Reference<XTextRange> xEndRange( + GetImport().GetTextImport()->GetCursorAsRange()->getStart() ); + + // create range for insertion + Reference<XTextCursor> xInsertionCursor( + GetImport().GetTextImport()->GetText()->createTextCursorByRange( + xEndRange) ); + xInsertionCursor->gotoRange(mxStart, sal_True); + + Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY); + + OUString sName; +//FIXME + // insert bookmark +// XMLTextMarkImportContext::CreateAndInsertMark +} + +SvXMLImportContext * XMLMetaImportContext::CreateChildContext( + sal_uInt16 i_nPrefix, const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList ) +{ + const SvXMLTokenMap& rTokenMap = + GetImport().GetTextImport()->GetTextPElemTokenMap(); + sal_uInt16 nToken = rTokenMap.Get( i_nPrefix, i_rLocalName ); + + return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix, + i_rLocalName, i_xAttrList, nToken, mrHints, mrIgnoreLeadingSpace ); +} + +void XMLMetaImportContext::Characters( const OUString& i_rChars ) +{ + //FIXME do we need to call ConvertStarFonts? + GetImport().GetTextImport()->InsertString( i_rChars, mrIgnoreLeadingSpace ); +} + +// --------------------------------------------------------------------- + /** * Process index marks. @@ -1443,6 +1564,15 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( sal_False); break; + case XML_TOK_TEXT_META: + case XML_TOK_TEXT_META_FIELD: +// FIXME: should test before enabling... +#if 0 + pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName, + xAttrList, rHints, rIgnoreLeadingSpace ); + break; +#endif + default: // none of the above? then it's probably a text field! pContext = @@ -1546,6 +1676,10 @@ XMLParaContext::XMLParaContext( &aLocalName ); switch( rTokenMap.Get( nPrefix, aLocalName ) ) { +//FIXME: RDFa + case XML_TOK_TEXT_P_XMLID: + sXmlId = rValue; + break; case XML_TOK_TEXT_P_STYLE_NAME: sStyleName = rValue; break; @@ -1640,6 +1774,26 @@ XMLParaContext::~XMLParaContext() return; // Robust (defect file) xAttrCursor->gotoRange( xEnd, sal_True ); + // xml:id for RDF metadata + if (sXmlId.getLength() > 0) { + try { + const uno::Reference<container::XEnumerationAccess> xEA + (xAttrCursor, uno::UNO_QUERY_THROW); + const uno::Reference<container::XEnumeration> xEnum( + xEA->createEnumeration(), uno::UNO_QUERY_THROW); + OSL_ENSURE(xEnum->hasMoreElements(), "xml:id: no paragraph?"); + if (xEnum->hasMoreElements()) { + uno::Reference<rdf::XMetadatable> xMeta; + xEnum->nextElement() >>= xMeta; +//FIXME not yet +// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable"); + GetImport().SetXmlId(xMeta, sXmlId); + OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?"); + } + } catch (uno::Exception &) { + } + } + OUString sCellParaStyleName = xTxtImport->sCellParaStyleDefault; if( sCellParaStyleName.getLength() > 0 ) { |