diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 20:09:46 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 20:09:46 +0200 |
commit | b4fa21145d504d7f9cbdc6722cc54249b4bb8425 (patch) | |
tree | 4995eb4d73d254e383bc482be45a20ae4cad1d18 /writerfilter/source/ooxml | |
parent | 018458e89c2b6481fbadbcfff038c4fb87dc5c11 (diff) | |
parent | eb666a3d095f56104aa14b302a94ed4f8f53fa89 (diff) |
Merge branch 'master' into feature/gnumake4
Conflicts:
filter/source/config/cache/filtercache.cxx
filter/source/odfflatxml/makefile.mk
oox/Library_oox.mk
oox/Makefile
oox/Module_oox.mk
oox/Package_generated.mk
oox/Package_inc.mk
oox/prj/build.lst
oox/prj/d.lst
oox/prj/makefile.mk
oox/source/dump/makefile.mk
unoxml/Library_unordf.mk
unoxml/Library_unoxml.mk
writerfilter/CppunitTest_writerfilter_doctok.mk
writerfilter/Library_writerfilter.mk
writerfilter/Module_writerfilter.mk
writerfilter/Package_inc.mk
writerfilter/inc/resourcemodel/TagLogger.hxx
writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
writerfilter/prj/build.lst
writerfilter/prj/makefile.mk
writerfilter/qa/complex/ooxml/makefile.mk
writerfilter/qa/cppunittests/doctok/makefile.mk
writerfilter/qa/cppunittests/doctok/testdoctok.cxx
writerfilter/qa/cppunittests/xxml/testXXML.cxx
writerfilter/source/dmapper/DomainMapper.cxx
writerfilter/source/dmapper/DomainMapperTableHandler.cxx
writerfilter/source/dmapper/DomainMapperTableManager.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
writerfilter/source/dmapper/FontTable.cxx
writerfilter/source/dmapper/GraphicHelpers.cxx
writerfilter/source/dmapper/PropertyIds.cxx
writerfilter/source/dmapper/PropertyMap.cxx
writerfilter/source/dmapper/SettingsTable.cxx
writerfilter/source/dmapper/StyleSheetTable.cxx
writerfilter/source/dmapper/TablePropertiesHandler.cxx
writerfilter/source/dmapper/TblStylePrHandler.cxx
writerfilter/source/dmapper/ThemeTable.cxx
writerfilter/source/doctok/WW8DocumentImpl.cxx
writerfilter/source/doctok/resourcesimpl.xsl
writerfilter/source/filter/WriterFilter.cxx
writerfilter/source/generated.mk
writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
writerfilter/source/ooxml/OOXMLFactory.cxx
writerfilter/source/ooxml/OOXMLFactory.hxx
writerfilter/source/ooxml/OOXMLStreamImpl.cxx
writerfilter/source/ooxml/RefAndPointer.hxx
writerfilter/source/resourcemodel/TagLogger.cxx
writerfilter/unocomponent/component.cxx
writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx
writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx
Diffstat (limited to 'writerfilter/source/ooxml')
39 files changed, 2092 insertions, 377 deletions
diff --git a/writerfilter/source/ooxml/Handler.cxx b/writerfilter/source/ooxml/Handler.cxx index 253172805..0f3a2a8dd 100644 --- a/writerfilter/source/ooxml/Handler.cxx +++ b/writerfilter/source/ooxml/Handler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,7 +51,7 @@ void OOXMLFootnoteHandler::attribute(Id name, Value & val) switch (name) { case NS_ooxml::LN_CT_FtnEdnRef_id: - mpFastContext->resolveFootnote(val.getString()); + mpFastContext->resolveFootnote(sal_Int32(val.getInt())); break; default: break; @@ -78,7 +79,7 @@ void OOXMLEndnoteHandler::attribute(Id name, Value & val) switch (name) { case NS_ooxml::LN_CT_FtnEdnRef_id: - mpFastContext->resolveEndnote(val.getString()); + mpFastContext->resolveEndnote(sal_Int32(val.getInt())); break; default: break; @@ -106,7 +107,7 @@ void OOXMLCommentHandler::attribute(Id name, Value & val) switch (name) { case NS_ooxml::LN_CT_Markup_id: - mpFastContext->resolveComment(val.getString()); + mpFastContext->resolveComment(val.getInt()); break; default: ; @@ -308,7 +309,7 @@ OOXMLHyperlinkHandler::~OOXMLHyperlinkHandler() sReturn += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"")); sReturn += mFieldCode; - mpFastContext->characters(sReturn); + mpFastContext->text(sReturn); } void OOXMLHyperlinkHandler::attribute(Id name, Value & val) @@ -346,3 +347,5 @@ void OOXMLHyperlinkHandler::sprm(Sprm & /*rSprm*/) { } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/Handler.hxx b/writerfilter/source/ooxml/Handler.hxx index 956395dfb..d255fb3c2 100644 --- a/writerfilter/source/ooxml/Handler.hxx +++ b/writerfilter/source/ooxml/Handler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -143,3 +144,5 @@ public: }} #endif // INCLUDED_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx index 34408a156..2c1ebba8d 100644 --- a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx +++ b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -84,3 +85,5 @@ string OOXMLBinaryObjectReference::getType() const } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx index 37d6f9d0e..0e6718446 100644 --- a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx +++ b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -53,3 +54,5 @@ public: }} #endif // INCLUDED_OOXML_BINARY_OBJECT_REFERENCE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index 82488a992..48ff93e83 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,7 +44,7 @@ namespace writerfilter { namespace ooxml { -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 TagLogger::Pointer_t debug_logger(TagLogger::getInstance("DEBUG")); #endif @@ -75,7 +76,7 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler, new OOXMLFastDocumentHandler(xContext); pDocHandler->setStream(&rStreamHandler); pDocHandler->setDocument(this); - pDocHandler->setXNoteId(msXNoteId); + pDocHandler->setXNoteId(mnXNoteId); uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler (pDocHandler); @@ -106,14 +107,14 @@ void OOXMLDocumentImpl::resolveFastSubStreamWithId(Stream & rStream, rStream.substream(nId, pStream); } -void OOXMLDocumentImpl::setXNoteId(const rtl::OUString & rId) +void OOXMLDocumentImpl::setXNoteId(const sal_Int32 nId) { - msXNoteId = rId; + mnXNoteId = nId; } -const rtl::OUString & OOXMLDocumentImpl::getXNoteId() const +sal_Int32 OOXMLDocumentImpl::getXNoteId() const { - return msXNoteId; + return mnXNoteId; } void OOXMLDocumentImpl::setXNoteType(const Id & nId) @@ -147,18 +148,18 @@ OOXMLDocumentImpl::getSubStream(const rtl::OUString & rId) writerfilter::Reference<Stream>::Pointer_t OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rType, - const rtl::OUString & rId) + const sal_Int32 nId) { #ifdef DEBUG_DOCUMENT debug_logger->startElement("getXNoteStream"); - debug_logger->attribute("id", rId); - debug_logger->endElement("getXNoteStream"); + debug_logger->attribute("id", nId); + debug_logger->endElement(); #endif OOXMLStream::Pointer_t pStream = (OOXMLDocumentFactory::createStream(mpStream, nType)); OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream); - pDocument->setXNoteId(rId); + pDocument->setXNoteId(nId); pDocument->setXNoteType(rType); return writerfilter::Reference<Stream>::Pointer_t(pDocument); @@ -166,10 +167,10 @@ OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rT void OOXMLDocumentImpl::resolveFootnote(Stream & rStream, const Id & rType, - const rtl::OUString & rNoteId) + const sal_Int32 nNoteId) { writerfilter::Reference<Stream>::Pointer_t pStream = - getXNoteStream(OOXMLStream::FOOTNOTES, rType, rNoteId); + getXNoteStream(OOXMLStream::FOOTNOTES, rType, nNoteId); Id nId; switch (rType) @@ -188,10 +189,10 @@ void OOXMLDocumentImpl::resolveFootnote(Stream & rStream, void OOXMLDocumentImpl::resolveEndnote(Stream & rStream, const Id & rType, - const rtl::OUString & rNoteId) + const sal_Int32 nNoteId) { writerfilter::Reference<Stream>::Pointer_t pStream = - getXNoteStream(OOXMLStream::ENDNOTES, rType, rNoteId); + getXNoteStream(OOXMLStream::ENDNOTES, rType, nNoteId); Id nId; switch (rType) @@ -209,10 +210,10 @@ void OOXMLDocumentImpl::resolveEndnote(Stream & rStream, } void OOXMLDocumentImpl::resolveComment(Stream & rStream, - const rtl::OUString & rId) + const sal_Int32 nId) { writerfilter::Reference<Stream>::Pointer_t pStream = - getXNoteStream(OOXMLStream::COMMENTS, 0, rId); + getXNoteStream(OOXMLStream::COMMENTS, 0, nId); resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_annotation); } @@ -324,7 +325,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) new OOXMLFastDocumentHandler(xContext); pDocHandler->setStream(&rStream); pDocHandler->setDocument(this); - pDocHandler->setXNoteId(msXNoteId); + pDocHandler->setXNoteId(mnXNoteId); pDocHandler->setIsSubstream( mbIsSubstream ); uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler (pDocHandler); @@ -354,7 +355,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) } #ifdef DEBUG_DOCUMENT - debug_logger->endElement("OOXMLDocumentImpl.resolve"); + debug_logger->endElement(); #endif } @@ -400,6 +401,16 @@ uno::Reference<io::XInputStream> OOXMLDocumentImpl::getStorageStream() return mpStream->getStorageStream(); } +void OOXMLDocumentImpl::setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext ) +{ + mxShapeContext = xContext; +} + +uno::Reference<xml::sax::XFastShapeContextHandler> OOXMLDocumentImpl::getShapeContext( ) +{ + return mxShapeContext; +} + OOXMLDocument * OOXMLDocumentFactory::createDocument (OOXMLStream::Pointer_t pStream) @@ -408,3 +419,5 @@ OOXMLDocumentFactory::createDocument } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx.orig b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx.orig new file mode 100644 index 000000000..dac91aa43 --- /dev/null +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx.orig @@ -0,0 +1,428 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/xml/sax/XParser.hpp> + +#include <com/sun/star/xml/sax/SAXException.hpp> +#include <doctok/resourceids.hxx> +#include <ooxml/resourceids.hxx> +#include "OOXMLDocumentImpl.hxx" +#include "OOXMLBinaryObjectReference.hxx" +#include "OOXMLFastDocumentHandler.hxx" +#include "OOXMLPropertySetImpl.hxx" +#include "ooxmlLoggers.hxx" + +#include <iostream> + +using ::com::sun::star::xml::sax::SAXException; +namespace writerfilter { +namespace ooxml +{ + +#if OSL_DEBUG_LEVEL > 1 +TagLogger::Pointer_t debug_logger(TagLogger::getInstance("DEBUG")); +#endif + +using namespace ::std; + +OOXMLDocumentImpl::OOXMLDocumentImpl +(OOXMLStream::Pointer_t pStream) +: mpStream(pStream), mXNoteType(0), mbIsSubstream( false ) +{ +} + +OOXMLDocumentImpl::~OOXMLDocumentImpl() +{ +} + +void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler, + OOXMLStream::StreamType_t nType) +{ + OOXMLStream::Pointer_t pStream + (OOXMLDocumentFactory::createStream(mpStream, nType)); + + uno::Reference< xml::sax::XFastParser > xParser + (mpStream->getFastParser()); + + if (xParser.is()) + { + uno::Reference<uno::XComponentContext> xContext(mpStream->getContext()); + OOXMLFastDocumentHandler * pDocHandler = + new OOXMLFastDocumentHandler(xContext); + pDocHandler->setStream(&rStreamHandler); + pDocHandler->setDocument(this); + pDocHandler->setXNoteId(mnXNoteId); + + uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler + (pDocHandler); + uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler + (mpStream->getFastTokenHandler(xContext)); + + xParser->setFastDocumentHandler(xDocumentHandler); + xParser->setTokenHandler(xTokenHandler); + + uno::Reference<io::XInputStream> xInputStream = + pStream->getDocumentStream(); + + if (xInputStream.is()) + { + struct xml::sax::InputSource oInputSource; + oInputSource.aInputStream = xInputStream; + xParser->parseStream(oInputSource); + + xInputStream->closeInput(); + } + } +} + +void OOXMLDocumentImpl::resolveFastSubStreamWithId(Stream & rStream, + writerfilter::Reference<Stream>::Pointer_t pStream, + sal_uInt32 nId) +{ + rStream.substream(nId, pStream); +} + +void OOXMLDocumentImpl::setXNoteId(const sal_Int32 nId) +{ + mnXNoteId = nId; +} + +sal_Int32 OOXMLDocumentImpl::getXNoteId() const +{ + return mnXNoteId; +} + +void OOXMLDocumentImpl::setXNoteType(const Id & nId) +{ + mXNoteType = nId; +} + +const Id & OOXMLDocumentImpl::getXNoteType() const +{ + return mXNoteType; +} + +const ::rtl::OUString & OOXMLDocumentImpl::getTarget() const +{ + return mpStream->getTarget(); +} + +writerfilter::Reference<Stream>::Pointer_t +OOXMLDocumentImpl::getSubStream(const rtl::OUString & rId) +{ + OOXMLStream::Pointer_t pStream + (OOXMLDocumentFactory::createStream(mpStream, rId)); + + OOXMLDocumentImpl * pTemp; + writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream) ); + pTemp->setModel(mxModel); + pTemp->setDrawPage(mxDrawPage); + pTemp->setIsSubstream( true ); + return pRet; +} + +writerfilter::Reference<Stream>::Pointer_t +OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rType, + const sal_Int32 nId) +{ +#ifdef DEBUG_DOCUMENT + debug_logger->startElement("getXNoteStream"); + debug_logger->attribute("id", nId); + debug_logger->endElement(); +#endif + + OOXMLStream::Pointer_t pStream = + (OOXMLDocumentFactory::createStream(mpStream, nType)); + OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream); + pDocument->setXNoteId(nId); + pDocument->setXNoteType(rType); + + return writerfilter::Reference<Stream>::Pointer_t(pDocument); +} + +void OOXMLDocumentImpl::resolveFootnote(Stream & rStream, + const Id & rType, + const sal_Int32 nNoteId) +{ + writerfilter::Reference<Stream>::Pointer_t pStream = + getXNoteStream(OOXMLStream::FOOTNOTES, rType, nNoteId); + + Id nId; + switch (rType) + { + case NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator: + case NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_continuationSeparator: + nId = rType; + break; + default: + nId = NS_rtf::LN_footnote; + break; + } + + resolveFastSubStreamWithId(rStream, pStream, nId); +} + +void OOXMLDocumentImpl::resolveEndnote(Stream & rStream, + const Id & rType, + const sal_Int32 nNoteId) +{ + writerfilter::Reference<Stream>::Pointer_t pStream = + getXNoteStream(OOXMLStream::ENDNOTES, rType, nNoteId); + + Id nId; + switch (rType) + { + case NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator: + case NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_continuationSeparator: + nId = rType; + break; + default: + nId = NS_rtf::LN_endnote; + break; + } + + resolveFastSubStreamWithId(rStream, pStream, nId); +} + +void OOXMLDocumentImpl::resolveComment(Stream & rStream, + const sal_Int32 nId) +{ + writerfilter::Reference<Stream>::Pointer_t pStream = + getXNoteStream(OOXMLStream::COMMENTS, 0, nId); + + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_annotation); +} + +OOXMLPropertySet * OOXMLDocumentImpl::getPicturePropSet +(const ::rtl::OUString & rId) +{ + OOXMLStream::Pointer_t pStream + (OOXMLDocumentFactory::createStream(mpStream, rId)); + + writerfilter::Reference<BinaryObj>::Pointer_t pPicture + (new OOXMLBinaryObjectReference(pStream)); + + OOXMLValue::Pointer_t pPayloadValue(new OOXMLBinaryValue(pPicture)); + + OOXMLProperty::Pointer_t pPayloadProperty + (new OOXMLPropertyImpl(NS_rtf::LN_payload, pPayloadValue, + OOXMLPropertyImpl::ATTRIBUTE)); + + OOXMLPropertySet::Pointer_t pBlipSet(new OOXMLPropertySetImpl()); + + pBlipSet->add(pPayloadProperty); + + OOXMLValue::Pointer_t pBlipValue(new OOXMLPropertySetValue(pBlipSet)); + + OOXMLProperty::Pointer_t pBlipProperty + (new OOXMLPropertyImpl(NS_rtf::LN_blip, pBlipValue, + OOXMLPropertyImpl::ATTRIBUTE)); + + OOXMLPropertySet * pProps = new OOXMLPropertySetImpl(); + + pProps->add(pBlipProperty); + + return pProps; +} + +void OOXMLDocumentImpl::resolvePicture(Stream & rStream, + const rtl::OUString & rId) +{ + OOXMLPropertySet * pProps = getPicturePropSet(rId); + + rStream.props(writerfilter::Reference<Properties>::Pointer_t(pProps)); +} + +::rtl::OUString OOXMLDocumentImpl::getTargetForId(const ::rtl::OUString & rId) +{ + return mpStream->getTargetForId(rId); +} + +void OOXMLDocumentImpl::resolveHeader(Stream & rStream, + const sal_Int32 type, + const rtl::OUString & rId) +{ + writerfilter::Reference<Stream>::Pointer_t pStream = + getSubStream(rId); + switch (type) + { + case NS_ooxml::LN_Value_ST_HrdFtr_even: + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_headerl); + break; + case NS_ooxml::LN_Value_ST_HrdFtr_default: // here we assume that default is right, but not necessarily true :-( + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_headerr); + break; + case NS_ooxml::LN_Value_ST_HrdFtr_first: + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_headerf); + break; + default: + break; + } +} + +void OOXMLDocumentImpl::resolveFooter(Stream & rStream, + const sal_Int32 type, + const rtl::OUString & rId) +{ + writerfilter::Reference<Stream>::Pointer_t pStream = + getSubStream(rId); + + switch (type) + { + case NS_ooxml::LN_Value_ST_HrdFtr_even: + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_footerl); + break; + case NS_ooxml::LN_Value_ST_HrdFtr_default: // here we assume that default is right, but not necessarily true :-( + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_footerr); + break; + case NS_ooxml::LN_Value_ST_HrdFtr_first: + resolveFastSubStreamWithId(rStream, pStream, NS_rtf::LN_footerf); + break; + default: + break; + } +} + +void OOXMLDocumentImpl::resolve(Stream & rStream) +{ +#ifdef DEBUG_DOCUMENT + debug_logger->startElement("OOXMLDocumentImpl.resolve"); +#endif + + uno::Reference< xml::sax::XFastParser > xParser + (mpStream->getFastParser()); + + if (xParser.is()) + { + uno::Reference<uno::XComponentContext> xContext(mpStream->getContext()); + + OOXMLFastDocumentHandler * pDocHandler = + new OOXMLFastDocumentHandler(xContext); + pDocHandler->setStream(&rStream); + pDocHandler->setDocument(this); + pDocHandler->setXNoteId(mnXNoteId); + pDocHandler->setIsSubstream( mbIsSubstream ); + uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler + (pDocHandler); + uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler + (mpStream->getFastTokenHandler(xContext)); + + resolveFastSubStream(rStream, OOXMLStream::SETTINGS); + resolveFastSubStream(rStream, OOXMLStream::THEME); + resolveFastSubStream(rStream, OOXMLStream::FONTTABLE); + resolveFastSubStream(rStream, OOXMLStream::STYLES); + resolveFastSubStream(rStream, OOXMLStream::NUMBERING); + + xParser->setFastDocumentHandler( xDocumentHandler ); + xParser->setTokenHandler( xTokenHandler ); + + xml::sax::InputSource aParserInput; + aParserInput.aInputStream = mpStream->getDocumentStream(); + try + { + xParser->parseStream(aParserInput); + } + catch (...) { +#ifdef DEBUG_DOCUMENT + debug_logger->element("exception"); +#endif + } + } + +<<<<<<< HEAD +#ifdef DEBUG_DOCUMENT + debug_logger->endElement("OOXMLDocumentImpl.resolve"); +======= +#ifdef DEBUG_RESOLVE + debug_logger->endElement(); +>>>>>>> master +#endif +} + +uno::Reference<io::XInputStream> OOXMLDocumentImpl::getInputStreamForId(const ::rtl::OUString & rId) +{ + OOXMLStream::Pointer_t pStream(OOXMLDocumentFactory::createStream(mpStream, rId)); + + return pStream->getDocumentStream(); +} + +string OOXMLDocumentImpl::getType() const +{ + return "OOXMLDocumentImpl"; +} + +void OOXMLDocumentImpl::setModel(uno::Reference<frame::XModel> xModel) +{ + mxModel.set(xModel); +} + +uno::Reference<frame::XModel> OOXMLDocumentImpl::getModel() +{ + return mxModel; +} + +void OOXMLDocumentImpl::setDrawPage(uno::Reference<drawing::XDrawPage> xDrawPage) +{ + mxDrawPage.set(xDrawPage); +} + +uno::Reference<drawing::XDrawPage> OOXMLDocumentImpl::getDrawPage() +{ + return mxDrawPage; +} + +uno::Reference<io::XInputStream> OOXMLDocumentImpl::getInputStream() +{ + return mpStream->getDocumentStream(); +} + +uno::Reference<io::XInputStream> OOXMLDocumentImpl::getStorageStream() +{ + return mpStream->getStorageStream(); +} + +void OOXMLDocumentImpl::setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext ) +{ + mxShapeContext = xContext; +} + +uno::Reference<xml::sax::XFastShapeContextHandler> OOXMLDocumentImpl::getShapeContext( ) +{ + return mxShapeContext; +} + +OOXMLDocument * +OOXMLDocumentFactory::createDocument +(OOXMLStream::Pointer_t pStream) +{ + return new OOXMLDocumentImpl(pStream); +} + +}} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index 05747a099..194dccea3 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #include <ooxml/OOXMLDocument.hxx> -#ifndef _COM_SUN_STAR_XML_SAX_XFAST_TOKEN_HANDLER_HPP_ #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> -#endif #include "OOXMLPropertySet.hxx" @@ -44,11 +43,12 @@ using namespace ::com::sun::star; class OOXMLDocumentImpl : public OOXMLDocument { OOXMLStream::Pointer_t mpStream; - rtl::OUString msXNoteId; + sal_Int32 mnXNoteId; Id mXNoteType; uno::Reference<frame::XModel> mxModel; uno::Reference<drawing::XDrawPage> mxDrawPage; + uno::Reference<xml::sax::XFastShapeContextHandler> mxShapeContext; bool mbIsSubstream; @@ -66,7 +66,7 @@ protected: writerfilter::Reference<Stream>::Pointer_t getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rType, - const rtl::OUString & rNoteId); + const sal_Int32 nNoteId); void setIsSubstream( bool bSubstream ) { mbIsSubstream = bSubstream; }; @@ -80,10 +80,10 @@ public: virtual void resolveFootnote(Stream & rStream, const Id & rType, - const rtl::OUString & rNoteId); + const sal_Int32 nNoteId); virtual void resolveEndnote(Stream & rStream, const Id & rType, - const rtl::OUString & rNoteId); + const sal_Int32 nNoteId); virtual void resolveHeader(Stream & rStream, const sal_Int32 type, const rtl::OUString & rId); @@ -91,7 +91,7 @@ public: const sal_Int32 type, const rtl::OUString & rId); - virtual void resolveComment(Stream & rStream, const rtl::OUString & rId); + virtual void resolveComment(Stream & rStream, const sal_Int32 nId); virtual OOXMLPropertySet * getPicturePropSet (const ::rtl::OUString & rId); @@ -106,11 +106,15 @@ public: virtual uno::Reference<io::XInputStream> getInputStream(); virtual uno::Reference<io::XInputStream> getStorageStream(); virtual uno::Reference<io::XInputStream> getInputStreamForId(const rtl::OUString & rId); - virtual void setXNoteId(const rtl::OUString & rId); - virtual const ::rtl::OUString & getXNoteId() const; + virtual void setXNoteId(const sal_Int32 nId); + virtual sal_Int32 getXNoteId() const; virtual void setXNoteType(const Id & rId); virtual const Id & getXNoteType() const; virtual const ::rtl::OUString & getTarget() const; + virtual uno::Reference<xml::sax::XFastShapeContextHandler> getShapeContext( ); + virtual void setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext ); }; }} #endif // OOXML_DOCUMENT_IMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx index 4c59e8f6c..81a26254e 100644 --- a/writerfilter/source/ooxml/OOXMLFactory.cxx +++ b/writerfilter/source/ooxml/OOXMLFactory.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -145,7 +146,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, AttributeToResourceMap::const_iterator aIt; AttributeToResourceMap::const_iterator aEndIt = pMap->end(); - for (aIt = pMap->begin(); aIt != aEndIt; aIt++) + for (aIt = pMap->begin(); aIt != aEndIt; ++aIt) { Id nId = (*pTokenToIdMap)[aIt->first]; #ifdef DEBUG_FACTORY @@ -235,7 +236,7 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, pFactory->attributeAction(pHandler, aIt->first, pValue); } #ifdef DEBUG_FACTORY - debug_logger->endElement("list"); + debug_logger->endElement(); #endif } break; @@ -247,12 +248,12 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, } } #ifdef DEBUG_FACTORY - debug_logger->endElement("factory.attribute"); + debug_logger->endElement(); #endif } #ifdef DEBUG_FACTORY - debug_logger->endElement("factory.attributes"); + debug_logger->endElement(); #endif } } @@ -316,7 +317,7 @@ void OOXMLFactory::startAction(OOXMLFastContextHandler * pHandler, sal_Int32 /*n #endif pFactory->startAction(pHandler); #ifdef DEBUG_FACTORY - debug_logger->endElement("factory.startAction"); + debug_logger->endElement(); #endif } } @@ -333,7 +334,7 @@ void OOXMLFactory::endAction(OOXMLFastContextHandler * pHandler, sal_Int32 /*nTo #endif pFactory->endAction(pHandler); #ifdef DEBUG_FACTORY - debug_logger->endElement("factory.endAction"); + debug_logger->endElement(); #endif } } @@ -364,3 +365,4 @@ string OOXMLFactory_ns::getName() const } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx.orig b/writerfilter/source/ooxml/OOXMLFactory.cxx.orig new file mode 100644 index 000000000..fcaccddf4 --- /dev/null +++ b/writerfilter/source/ooxml/OOXMLFactory.cxx.orig @@ -0,0 +1,378 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <stdio.h> + +#include <rtl/instance.hxx> +#include <osl/mutex.hxx> +#include "OOXMLFactory.hxx" +#include "OOXMLFastHelper.hxx" + +namespace writerfilter { +namespace ooxml { + +AttributeInfo::AttributeInfo() +:m_nResource(RT_NoResource), m_nRef(0) +{ +} + +AttributeInfo::AttributeInfo(ResourceType_t nResource, Id nRef) + :m_nResource(nResource), m_nRef(nRef) +{ +} + +CreateElement::CreateElement() +:m_nResource(RT_NoResource), m_nId(0) +{ +} + +CreateElement::CreateElement(ResourceType_t nResource, Id nId) +: m_nResource(nResource), m_nId(nId) +{ +} + +// class OOXMLFactory_ns + +OOXMLFactory_ns::~OOXMLFactory_ns() +{ +} + +AttributeToResourceMapPointer OOXMLFactory_ns::getAttributeToResourceMap(Id nId) +{ + if (m_AttributesMap.find(nId) == m_AttributesMap.end()) + m_AttributesMap[nId] = createAttributeToResourceMap(nId); + + return m_AttributesMap[nId]; +} + +ListValueMapPointer OOXMLFactory_ns::getListValueMap(Id nId) +{ + if (m_ListValuesMap.find(nId) == m_ListValuesMap.end()) + m_ListValuesMap[nId] = createListValueMap(nId); + + return m_ListValuesMap[nId]; +} + +CreateElementMapPointer OOXMLFactory_ns::getCreateElementMap(Id nId) +{ + if (m_CreateElementsMap.find(nId) == m_CreateElementsMap.end()) + m_CreateElementsMap[nId] = createCreateElementMap(nId); + + return m_CreateElementsMap[nId]; +} + +TokenToIdMapPointer OOXMLFactory_ns::getTokenToIdMap(Id nId) +{ + if (m_TokenToIdsMap.find(nId) == m_TokenToIdsMap.end()) + m_TokenToIdsMap[nId] = createTokenToIdMap(nId); + + return m_TokenToIdsMap[nId]; +} + +string OOXMLFactory_ns::getDefineName(Id /*nId*/) const +{ + return ""; +} + +// class OOXMLFactory + +typedef rtl::Static< osl::Mutex, OOXMLFactory > OOXMLFactory_Mutex; + +OOXMLFactory::Pointer_t OOXMLFactory::m_Instance; + +OOXMLFactory::OOXMLFactory() +{ + // multi-thread-safe mutex for all platforms + + osl::MutexGuard aGuard(OOXMLFactory_Mutex::get()); +} + +OOXMLFactory::~OOXMLFactory() +{ +} + +OOXMLFactory::Pointer_t OOXMLFactory::getInstance() +{ + if (m_Instance.get() == NULL) + m_Instance.reset(new OOXMLFactory()); + + return m_Instance; +} + +void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs) +{ + Id nDefine = pHandler->getDefine(); + OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine); + + if (pFactory.get() != NULL) + { +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.attributes"); + debug_logger->attribute("define", pFactory->getDefineName(nDefine)); + char sBuffer[256]; + snprintf(sBuffer, sizeof(sBuffer), "%08" SAL_PRIxUINT32, nDefine); + debug_logger->attribute("define-num", sBuffer); +#endif + + TokenToIdMapPointer pTokenToIdMap = pFactory->getTokenToIdMap(nDefine); + AttributeToResourceMapPointer pMap = pFactory->getAttributeToResourceMap(nDefine); + + AttributeToResourceMap::const_iterator aIt; + AttributeToResourceMap::const_iterator aEndIt = pMap->end(); + + for (aIt = pMap->begin(); aIt != aEndIt; ++aIt) + { + Id nId = (*pTokenToIdMap)[aIt->first]; +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.attribute"); + debug_logger->attribute("name", fastTokenToId(aIt->first)); + debug_logger->attribute("tokenid", (*QNameToString::Instance())(nId)); + snprintf(sBuffer, sizeof(sBuffer), "%08" SAL_PRIxUINT32, nId); + debug_logger->attribute("tokenid-num", sBuffer); +#endif + if (Attribs->hasAttribute(aIt->first)) + { + switch (aIt->second.m_nResource) + { + case RT_Boolean: + { +#ifdef DEBUG_FACTORY + debug_logger->element("boolean"); +#endif + ::rtl::OUString aValue(Attribs->getValue(aIt->first)); + OOXMLFastHelper<OOXMLBooleanValue>::newProperty(pHandler, nId, aValue); + + OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(aValue)); + pFactory->attributeAction(pHandler, aIt->first, pValue); + } + break; + case RT_String: + { +#ifdef DEBUG_FACTORY + debug_logger->element("string"); +#endif + ::rtl::OUString aValue(Attribs->getValue(aIt->first)); + OOXMLFastHelper<OOXMLStringValue>::newProperty + (pHandler, nId, aValue); + + OOXMLValue::Pointer_t pValue(new OOXMLStringValue(aValue)); + pFactory->attributeAction(pHandler, aIt->first, pValue); + } + break; + case RT_Integer: + { +#ifdef DEBUG_FACTORY + debug_logger->element("integer"); +#endif + ::rtl::OUString aValue(Attribs->getValue(aIt->first)); + OOXMLFastHelper<OOXMLIntegerValue>::newProperty + (pHandler, nId, aValue); + + OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(aValue)); + pFactory->attributeAction(pHandler, aIt->first, pValue); + } + break; + case RT_Hex: + { +#ifdef DEBUG_FACTORY + debug_logger->element("hex"); +#endif + ::rtl::OUString aValue(Attribs->getValue(aIt->first)); + OOXMLFastHelper<OOXMLHexValue>::newProperty + (pHandler, nId, aValue); + + OOXMLValue::Pointer_t pValue(new OOXMLHexValue(aValue)); + pFactory->attributeAction(pHandler, aIt->first, pValue); + } + break; + case RT_List: + { +#ifdef DEBUG_FACTORY + debug_logger->startElement("list"); +#endif + ListValueMapPointer pListValueMap = + pFactory->getListValueMap(aIt->second.m_nRef); + + if (pListValueMap.get() != NULL) + { + ::rtl::OUString aValue(Attribs->getValue(aIt->first)); + sal_uInt32 nValue = (*pListValueMap)[aValue]; + +#ifdef DEBUG_FACTORY + debug_logger->attribute("value", aValue); + debug_logger->attribute("value-num", nValue); +#endif + + OOXMLFastHelper<OOXMLIntegerValue>::newProperty + (pHandler, nId, nValue); + + OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(nValue)); + pFactory->attributeAction(pHandler, aIt->first, pValue); + } +#ifdef DEBUG_FACTORY + debug_logger->endElement(); +#endif + } + break; + default: +#ifdef DEBUG_FACTORY + debug_logger->element("unknown-attribute-type"); +#endif + break; + } + } +#ifdef DEBUG_FACTORY + debug_logger->endElement(); +#endif + } + +#ifdef DEBUG_FACTORY + debug_logger->endElement(); +#endif + } +} + +uno::Reference< xml::sax::XFastContextHandler> +OOXMLFactory::createFastChildContext(OOXMLFastContextHandler * pHandler, + sal_Int32 Element) +{ +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.createFastChildContext"); + debug_logger->attribute("token", fastTokenToId(Element)); +#endif + + Id nDefine = pHandler->getDefine(); + + OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine); + + uno::Reference< xml::sax::XFastContextHandler> ret; + + //Avoid handling unknown tokens and recursing to death + if ((Element & 0xffff) < OOXML_FAST_TOKENS_END) + ret = createFastChildContextFromFactory(pHandler, pFactory, Element); + +#ifdef DEBUG_FACTORY + debug_logger->endElement("factory.createFastChildContext"); +#endif + + return ret; +} + +void OOXMLFactory::characters(OOXMLFastContextHandler * pHandler, + const ::rtl::OUString & rString) +{ +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.characters"); + debug_logger->chars(rString); +#endif + + Id nDefine = pHandler->getDefine(); + OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine); + + if (pFactory.get() != NULL) + { + pFactory->charactersAction(pHandler, rString); + } + +#ifdef DEBUG_FACTORY + debug_logger->endElement("factory.characters"); +#endif +} + +void OOXMLFactory::startAction(OOXMLFastContextHandler * pHandler, sal_Int32 /*nToken*/) +{ + Id nDefine = pHandler->getDefine(); + OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine); + + if (pFactory.get() != NULL) + { +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.startAction"); +#endif + pFactory->startAction(pHandler); +<<<<<<< HEAD +#ifdef DEBUG_FACTORY + debug_logger->endElement("factory.startAction"); +======= +#ifdef DEBUG_ELEMENT + debug_logger->endElement(); +>>>>>>> master +#endif + } +} + +void OOXMLFactory::endAction(OOXMLFastContextHandler * pHandler, sal_Int32 /*nToken*/) +{ + Id nDefine = pHandler->getDefine(); + OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine); + + if (pFactory.get() != NULL) + { +#ifdef DEBUG_FACTORY + debug_logger->startElement("factory.endAction"); +#endif + pFactory->endAction(pHandler); +<<<<<<< HEAD +#ifdef DEBUG_FACTORY + debug_logger->endElement("factory.endAction"); +======= +#ifdef DEBUG_ELEMENT + debug_logger->endElement(); +>>>>>>> master +#endif + } +} + +void OOXMLFactory_ns::startAction(OOXMLFastContextHandler *) +{ +} + +void OOXMLFactory_ns::endAction(OOXMLFastContextHandler *) +{ +} + +void OOXMLFactory_ns::charactersAction(OOXMLFastContextHandler *, const ::rtl::OUString &) +{ +} + +void OOXMLFactory_ns::attributeAction(OOXMLFastContextHandler *, sal_Int32, OOXMLValue::Pointer_t) +{ +} + +#ifdef DEBUG_FACTORY +string OOXMLFactory_ns::getName() const +{ + return "noname"; +} +#endif + +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx index f1d9267cf..3fcccb20f 100644 --- a/writerfilter/source/ooxml/OOXMLFactory.hxx +++ b/writerfilter/source/ooxml/OOXMLFactory.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,20 +29,14 @@ #ifndef INCLUDED_OOXML_FACTORY_HXX #define INCLUDED_OOXML_FACTORY_HXX -#include <hash_map> +#include <boost/unordered_map.hpp> #include <boost/shared_ptr.hpp> -#ifndef INCLUDED_WW8_RESOURCE_MODEL_HXX #include <resourcemodel/WW8ResourceModel.hxx> -#endif -#ifndef INCLUDED_OOXML_FAST_TOKENS_HXX #include <ooxml/OOXMLFastTokens.hxx> -#endif -#ifndef INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX #include "OOXMLFastContextHandler.hxx" -#endif namespace writerfilter { namespace ooxml { @@ -52,6 +47,7 @@ enum ResourceType_t { RT_NoResource, RT_Table, RT_Stream, + RT_StreamProperties, RT_List, RT_Integer, RT_Properties, @@ -78,13 +74,13 @@ struct AttributeInfo AttributeInfo(); }; -typedef hash_map<sal_Int32, AttributeInfo, TokenHash> AttributeToResourceMap; +typedef boost::unordered_map<Token_t, AttributeInfo> AttributeToResourceMap; typedef boost::shared_ptr<AttributeToResourceMap> AttributeToResourceMapPointer; -typedef hash_map<Id, AttributeToResourceMapPointer> AttributesMap; +typedef boost::unordered_map<Id, AttributeToResourceMapPointer> AttributesMap; -typedef hash_map<rtl::OUString, sal_Int32, ::rtl::OUStringHash> ListValueMap; +typedef boost::unordered_map<rtl::OUString, sal_Int32, ::rtl::OUStringHash> ListValueMap; typedef boost::shared_ptr<ListValueMap> ListValueMapPointer; -typedef hash_map<Id, ListValueMapPointer> ListValuesMap; +typedef boost::unordered_map<Id, ListValueMapPointer> ListValuesMap; struct CreateElement { @@ -95,15 +91,15 @@ struct CreateElement CreateElement(); }; -typedef hash_map<sal_Int32, CreateElement, TokenHash> CreateElementMap; +typedef boost::unordered_map<Token_t, CreateElement> CreateElementMap; typedef boost::shared_ptr<CreateElementMap> CreateElementMapPointer; -typedef hash_map<Id, CreateElementMapPointer> CreateElementsMap; -typedef hash_map<Id, string> IdToStringMap; +typedef boost::unordered_map<Id, CreateElementMapPointer> CreateElementsMap; +typedef boost::unordered_map<Id, string> IdToStringMap; typedef boost::shared_ptr<IdToStringMap> IdToStringMapPointer; -typedef hash_map<Id, sal_Int32> TokenToIdMap; +typedef boost::unordered_map<Id, Token_t> TokenToIdMap; typedef boost::shared_ptr<TokenToIdMap> TokenToIdMapPointer; -typedef hash_map<Id, TokenToIdMapPointer> TokenToIdsMap; +typedef boost::unordered_map<Id, TokenToIdMapPointer> TokenToIdsMap; class OOXMLFactory_ns { public: @@ -177,3 +173,5 @@ private: } #endif // INCLUDED_OOXML_FACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx.orig b/writerfilter/source/ooxml/OOXMLFactory.hxx.orig new file mode 100644 index 000000000..916a00d5d --- /dev/null +++ b/writerfilter/source/ooxml/OOXMLFactory.hxx.orig @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_OOXML_FACTORY_HXX +#define INCLUDED_OOXML_FACTORY_HXX + +#include <boost/unordered_map.hpp> +#include <boost/shared_ptr.hpp> + +#include <resourcemodel/WW8ResourceModel.hxx> + +#include <ooxml/OOXMLFastTokens.hxx> + +#include "OOXMLFastContextHandler.hxx" + +namespace writerfilter { +namespace ooxml { + +using namespace std; + +enum ResourceType_t { + RT_NoResource, + RT_Table, + RT_Stream, + RT_StreamProperties, + RT_List, + RT_Integer, + RT_Properties, + RT_Hex, + RT_String, + RT_Shape, + RT_Boolean, + RT_HexValue, + RT_Value, + RT_XNote, + RT_TextTableCell, + RT_TextTableRow, + RT_TextTable, + RT_PropertyTable, + RT_Any +}; + +struct AttributeInfo +{ + ResourceType_t m_nResource; + Id m_nRef; + + AttributeInfo(ResourceType_t nResource, Id nRef); + AttributeInfo(); +}; + +<<<<<<< HEAD +typedef hash_map<sal_Int32, AttributeInfo, TokenHash> AttributeToResourceMap; +======= +typedef boost::unordered_map<Token_t, AttributeInfo> AttributeToResourceMap; +>>>>>>> master +typedef boost::shared_ptr<AttributeToResourceMap> AttributeToResourceMapPointer; +typedef boost::unordered_map<Id, AttributeToResourceMapPointer> AttributesMap; + +typedef boost::unordered_map<rtl::OUString, sal_Int32, ::rtl::OUStringHash> ListValueMap; +typedef boost::shared_ptr<ListValueMap> ListValueMapPointer; +typedef boost::unordered_map<Id, ListValueMapPointer> ListValuesMap; + +struct CreateElement +{ + ResourceType_t m_nResource; + Id m_nId; + + CreateElement(ResourceType_t nResource, Id nId); + CreateElement(); +}; + +<<<<<<< HEAD +typedef hash_map<sal_Int32, CreateElement, TokenHash> CreateElementMap; +======= +typedef boost::unordered_map<Token_t, CreateElement> CreateElementMap; +>>>>>>> master +typedef boost::shared_ptr<CreateElementMap> CreateElementMapPointer; +typedef boost::unordered_map<Id, CreateElementMapPointer> CreateElementsMap; +typedef boost::unordered_map<Id, string> IdToStringMap; +typedef boost::shared_ptr<IdToStringMap> IdToStringMapPointer; + +<<<<<<< HEAD +typedef hash_map<Id, sal_Int32> TokenToIdMap; +======= +typedef boost::unordered_map<Id, Token_t> TokenToIdMap; +>>>>>>> master +typedef boost::shared_ptr<TokenToIdMap> TokenToIdMapPointer; +typedef boost::unordered_map<Id, TokenToIdMapPointer> TokenToIdsMap; + +class OOXMLFactory_ns { +public: + typedef boost::shared_ptr<OOXMLFactory_ns> Pointer_t; + + virtual void startAction(OOXMLFastContextHandler * pHandler); + virtual void charactersAction(OOXMLFastContextHandler * pHandler, const ::rtl::OUString & rString); + virtual void endAction(OOXMLFastContextHandler * pHandler); + virtual void attributeAction(OOXMLFastContextHandler * pHandler, sal_Int32 nToken, OOXMLValue::Pointer_t pValue); + virtual string getDefineName(Id nId) const; +#ifdef DEBUG_FACTORY + virtual string getName() const; +#endif + + AttributeToResourceMapPointer getAttributeToResourceMap(Id nId); + ListValueMapPointer getListValueMap(Id nId); + CreateElementMapPointer getCreateElementMap(Id nId); + TokenToIdMapPointer getTokenToIdMap(Id nId); + +protected: + virtual ~OOXMLFactory_ns(); + + AttributesMap m_AttributesMap; + ListValuesMap m_ListValuesMap; + CreateElementsMap m_CreateElementsMap; + TokenToIdsMap m_TokenToIdsMap; + + virtual AttributeToResourceMapPointer createAttributeToResourceMap(Id nId) = 0; + virtual ListValueMapPointer createListValueMap(Id nId) = 0; + virtual CreateElementMapPointer createCreateElementMap(Id nId) = 0; + virtual TokenToIdMapPointer createTokenToIdMap(Id nId) = 0; +}; + +class OOXMLFactory +{ +public: + typedef boost::shared_ptr<OOXMLFactory> Pointer_t; + + static Pointer_t getInstance(); + + uno::Reference< xml::sax::XFastContextHandler> createFastChildContext + (OOXMLFastContextHandler * pHandler, sal_Int32 Element); + + uno::Reference< xml::sax::XFastContextHandler> createFastChildContextFromStart + (OOXMLFastContextHandler * pHandler, sal_Int32 Element); + + void attributes(OOXMLFastContextHandler * pHandler, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs); + + void characters(OOXMLFastContextHandler * pHandler, + const ::rtl::OUString & rString); + + void startAction(OOXMLFastContextHandler * pHandler, sal_Int32 nToken); + void endAction(OOXMLFastContextHandler * pHandler, sal_Int32 nToken); + + virtual ~OOXMLFactory(); + +private: + static Pointer_t m_Instance; + + OOXMLFactory(); + OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id); + + uno::Reference< xml::sax::XFastContextHandler> + createFastChildContextFromFactory(OOXMLFastContextHandler * pHandler, + OOXMLFactory_ns::Pointer_t pFactory, + sal_Int32 Element); +}; + +} +} + +#endif // INCLUDED_OOXML_FACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 87ef41fc9..6ee72513c 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -28,7 +29,7 @@ #include <stdio.h> #include <iostream> #include <set> -#include <rtl/uuid.h> +#include <comphelper/servicehelper.hxx> #include <com/sun/star/drawing/XShapes.hpp> #include <resourcemodel/QNameToString.hxx> #include <resourcemodel/XPathLogger.hxx> @@ -36,6 +37,8 @@ #include <ooxml/resourceids.hxx> #include <doctok/sprmids.hxx> #include <ooxml/OOXMLnamespaceids.hxx> +#include <dmapper/DomainMapper.hxx> +#include <GraphicHelpers.hxx> #include "OOXMLFastContextHandler.hxx" #include "OOXMLFactory.hxx" #include "Handler.hxx" @@ -64,15 +67,6 @@ using ::com::sun::star::lang::XMultiComponentFactory; using namespace ::com::sun::star; using namespace ::std; -static uno::Sequence< sal_Int8 > CreateUnoTunnelId() -{ - static osl::Mutex aCreateMutex; - osl::Guard<osl::Mutex> aGuard( aCreateMutex ); - uno::Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - return aSeq; -} - static string resourceToString (OOXMLFastContextHandler::ResourceEnum_t eResource) { @@ -101,7 +95,7 @@ static string resourceToString set<OOXMLFastContextHandler *> aSetContexts; -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 class OOXMLIdToString : public IdToString { public: @@ -138,6 +132,7 @@ OOXMLFastContextHandler::OOXMLFastContextHandler mnTableDepth(0), mnInstanceNumber(mnInstanceCount), mnRefCount(0), + inPositionV(false), m_xContext(context) { mnInstanceCount++; @@ -160,6 +155,7 @@ OOXMLFastContextHandler::OOXMLFastContextHandler mnTableDepth(0), mnInstanceNumber(mnInstanceCount), mnRefCount(0), + inPositionV(pContext->inPositionV), m_xContext(pContext->m_xContext) { if (pContext != NULL) @@ -197,8 +193,8 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement debug_logger->attribute("type", getType()); debug_logger->attribute("xpath", mpParserState->getXPathLogger().getXPath()); debug_logger->startElement("at-start"); - debug_logger->addTag(toTag()); - debug_logger->endElement("at-start"); + dumpXml( debug_logger ); + debug_logger->endElement(); #endif attributes(Attribs); lcl_startFastElement(Element, Attribs); @@ -232,9 +228,9 @@ throw (uno::RuntimeException, xml::sax::SAXException) #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("at-end"); - debug_logger->addTag(toTag()); - debug_logger->endElement("at-end"); - debug_logger->endElement("contexthandler.element"); + dumpXml( debug_logger ); + debug_logger->endElement(); + debug_logger->endElement(); mpParserState->getXPathLogger().endElement(); #endif } @@ -245,6 +241,11 @@ void OOXMLFastContextHandler::lcl_startFastElement throw (uno::RuntimeException, xml::sax::SAXException) { OOXMLFactory::getInstance()->startAction(this, Element); + if( Element == (NS_wordprocessingDrawing|OOXML_positionV) ) + inPositionV = true; + else if( Element == (NS_wordprocessingDrawing|OOXML_positionH) ) + inPositionV = false; + } void OOXMLFastContextHandler::lcl_endFastElement @@ -259,7 +260,7 @@ void SAL_CALL OOXMLFastContextHandler::endUnknownElement throw (uno::RuntimeException, xml::sax::SAXException) { #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.unknown-element"); + debug_logger->endElement(); mpParserState->getXPathLogger().endElement(); #endif } @@ -280,7 +281,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL (lcl_createFastChildContext(Element, Attribs)); #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.createFastChildContext"); + debug_logger->endElement(); #endif return xResult; @@ -306,7 +307,7 @@ OOXMLFastContextHandler::createUnknownChildContext debug_logger->startElement("contexthandler.createUnknownChildContext"); debug_logger->attribute("namespace", Namespace); debug_logger->attribute("name", Name); - debug_logger->endElement("contexthandler.createUnknownChildContext"); + debug_logger->endElement(); #else (void) Namespace; (void) Name; @@ -330,10 +331,14 @@ throw (uno::RuntimeException, xml::sax::SAXException) OOXMLFactory::getInstance()->characters(this, rString); } +namespace +{ + class theOOXMLFastContextHandlerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theOOXMLFastContextHandlerUnoTunnelId > {}; +} + const uno::Sequence< sal_Int8 > & OOXMLFastContextHandler::getUnoTunnelId() { - static uno::Sequence< sal_Int8 > aSeq = CreateUnoTunnelId(); - return aSeq; + return theOOXMLFastContextHandlerUnoTunnelId::get().getSeq(); } sal_Int64 SAL_CALL OOXMLFastContextHandler::getSomething( const uno::Sequence< sal_Int8 >& rId ) @@ -374,7 +379,7 @@ void OOXMLFastContextHandler::startAction(sal_Int32 Element) #endif lcl_startAction(Element); #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.startAction"); + debug_logger->endElement(); #endif } @@ -390,7 +395,7 @@ void OOXMLFastContextHandler::endAction(sal_Int32 Element) #endif lcl_endAction(Element); #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.endAction"); + debug_logger->endElement(); #endif } @@ -399,56 +404,35 @@ void OOXMLFastContextHandler::lcl_endAction(sal_Int32 Element) OOXMLFactory::getInstance()->endAction(this, Element); } -#ifdef DEBUG -XMLTag::Pointer_t OOXMLFastContextHandler::toPropertiesTag - (OOXMLPropertySet::Pointer_t pProps) -{ - XMLTag::Pointer_t pTag; - - if (pProps.get() != NULL) - { - PropertySetToTagHandler aHandler(IdToString::Pointer_t(new OOXMLIdToString())); - - pProps->resolve(aHandler); - pTag = aHandler.getTag(); - } - - return pTag; -} - -XMLTag::Pointer_t OOXMLFastContextHandler::toTag() const +#if OSL_DEBUG_LEVEL > 1 +void OOXMLFastContextHandler::dumpXml( const TagLogger::Pointer_t pLogger ) const { - XMLTag::Pointer_t pTag(new XMLTag("context")); + pLogger->startElement("context"); static char sBuffer[128]; snprintf(sBuffer, sizeof(sBuffer), "%p", this); - pTag->addAttr("parent", sBuffer); - pTag->addAttr("type", getType()); - pTag->addAttr("resource", getResourceString()); - pTag->addAttr("token", fastTokenToId(getToken())); - pTag->addAttr("id", (*QNameToString::Instance())(getId())); + pLogger->attribute("parent", sBuffer); + pLogger->attribute("type", getType()); + pLogger->attribute("resource", getResourceString()); + pLogger->attribute("token", fastTokenToId(getToken())); + pLogger->attribute("id", (*QNameToString::Instance())(getId())); OOXMLValue::Pointer_t pVal(getValue()); if (pVal.get() != NULL) - pTag->addAttr("value", pVal->toString()); + pLogger->attribute("value", pVal->toString()); else - pTag->addAttr("value", "(null)"); + pLogger->attribute("value", "(null)"); - XMLTag::Pointer_t pTagProps(toPropertiesTag(getPropertySet())); - if (pTagProps.get() != NULL) - pTag->addTag(pTagProps); + pLogger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); - pTag->addTag(mpParserState->toTag()); + mpParserState->dumpXml( pLogger ); - return pTag; + pLogger->endElement(); } -string OOXMLFastContextHandler::toString() const -{ - return toTag()->toString(); -} #endif string OOXMLFastContextHandler::getResourceString() const @@ -466,7 +450,7 @@ void OOXMLFastContextHandler::setId(Id rId) debug_logger->attribute("id", sBuffer); debug_logger->attribute("name", (*QNameToString::Instance())(rId)); - debug_logger->endElement("contexthandler.setId"); + debug_logger->endElement(); #endif mId = rId; @@ -552,7 +536,7 @@ void OOXMLFastContextHandler::sendTableDepth() const mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps)); } #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendTableDepth"); + debug_logger->endElement(); #endif } @@ -833,7 +817,7 @@ void OOXMLFastContextHandler::text(const ::rtl::OUString & sText) #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.text"); debug_logger->chars(sText); - debug_logger->endElement("contexthandler.text"); + debug_logger->endElement(); #endif if (isForwardEvents()) @@ -842,12 +826,56 @@ void OOXMLFastContextHandler::text(const ::rtl::OUString & sText) sText.getLength()); } +/* + HACK. An ugly hack. The problem with wp:positionOffset, wp:alignV and wp:alignH + is that they do not work in the usual OOXML way of <tag val="value"/> but instead + it's <tag>value</tag>, which is otherwise used only things like <t>. And I really + haven't managed to find out how to make this XML parsing monstrosity to handle this + on its own, so the code is modelled after <t> handling and does it manually in a hackish + way - it reads the value as text and converts itself, moreover the reading of the value + is done sooner than lcl_sprms() actually results in processing the tags it is enclosed + in, so the values are stored in PositionHandler for later use. +*/ +void OOXMLFastContextHandler::positionOffset(const ::rtl::OUString & sText) +{ +#ifdef DEBUG_ELEMENT + debug_logger->startElement("positionOffset"); + debug_logger->chars(sText); + debug_logger->endElement(); +#endif + if (isForwardEvents()) + ::writerfilter::dmapper::PositionHandler::setPositionOffset( sText, inPositionV ); +} + +void OOXMLFastContextHandler::alignH(const ::rtl::OUString & sText) +{ +#ifdef DEBUG_ELEMENT + debug_logger->startElement("alignH"); + debug_logger->chars(sText); + debug_logger->endElement(); +#endif + if (isForwardEvents()) + ::writerfilter::dmapper::PositionHandler::setAlignH( sText ); +} + +void OOXMLFastContextHandler::alignV(const ::rtl::OUString & sText) +{ +#ifdef DEBUG_ELEMENT + debug_logger->startElement("alignV"); + debug_logger->chars(sText); + debug_logger->endElement(); +#endif + if (isForwardEvents()) + ::writerfilter::dmapper::PositionHandler::setAlignV( sText ); +} + void OOXMLFastContextHandler::propagateCharacterProperties() { #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.propagateCharacterProperties"); - debug_logger->addTag(toPropertiesTag(getPropertySet())); - debug_logger->endElement("contexthandler.propagateCharacterProperties"); + debug_logger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif mpParserState->setCharacterProperties(getPropertySet()); @@ -857,8 +885,9 @@ void OOXMLFastContextHandler::propagateCharacterPropertiesAsSet(const Id & rId) { #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.propagateCharacterPropertiesAsSet"); - debug_logger->addTag(toPropertiesTag(getPropertySet())); - debug_logger->endElement("contexthandler.propagateCharacterPropertiesAsSet"); + debug_logger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet())); @@ -899,8 +928,9 @@ void OOXMLFastContextHandler::propagateTableProperties() OOXMLPropertySet::Pointer_t pProps = getPropertySet(); #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.propagateTableProperties"); - debug_logger->addTag(toPropertiesTag(pProps)); - debug_logger->endElement("contexthandler.propagateTableProperties"); + debug_logger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif mpParserState->setTableProperties(pProps); @@ -911,11 +941,11 @@ void OOXMLFastContextHandler::sendCellProperties() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.sendCellProperties"); #endif - + mpParserState->resolveCellProperties(*mpStream); - + #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendCellProperties"); + debug_logger->endElement(); #endif } @@ -924,11 +954,11 @@ void OOXMLFastContextHandler::sendRowProperties() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.sendRowProperties"); #endif - + mpParserState->resolveRowProperties(*mpStream); - + #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendRowProperties"); + debug_logger->endElement(); #endif } @@ -937,11 +967,11 @@ void OOXMLFastContextHandler::sendTableProperties() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.sendTableProperties"); #endif - + mpParserState->resolveTableProperties(*mpStream); - + #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendTableProperties"); + debug_logger->endElement(); #endif } @@ -950,7 +980,7 @@ void OOXMLFastContextHandler::clearTableProps() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->element("contexthandler.clearTableProps"); #endif - + mpParserState->setTableProperties(OOXMLPropertySet::Pointer_t (new OOXMLPropertySetImpl())); } @@ -972,8 +1002,9 @@ void OOXMLFastContextHandler::sendPropertiesWithId(const Id & rId) mpStream->props(pPropertySet); #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->addTag(toPropertiesTag(pPropertySet)); - debug_logger->endElement("contexthandler.sendPropertiesWithId"); + debug_logger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif } @@ -1022,7 +1053,7 @@ void OOXMLFastContextHandler::setForwardEvents(bool bForwardEvents) else debug_logger->chars("false"); - debug_logger->endElement("contexthandler.setForwardEvents"); + debug_logger->endElement(); #endif mpParserState->setForwardEvents(bForwardEvents); @@ -1033,37 +1064,37 @@ bool OOXMLFastContextHandler::isForwardEvents() const return mpParserState->isForwardEvents(); } -void OOXMLFastContextHandler::setXNoteId(const ::rtl::OUString & rId) +void OOXMLFastContextHandler::setXNoteId(const sal_Int32 nId) { - mpParserState->setXNoteId(rId); + mpParserState->setXNoteId(nId); } void OOXMLFastContextHandler::setXNoteId(OOXMLValue::Pointer_t pValue) { - mpParserState->setXNoteId(pValue->getString()); + mpParserState->setXNoteId(sal_Int32(pValue->getInt())); } -const rtl::OUString & OOXMLFastContextHandler::getXNoteId() const +sal_Int32 OOXMLFastContextHandler::getXNoteId() const { return mpParserState->getXNoteId(); } void OOXMLFastContextHandler::resolveFootnote -(const rtl::OUString & rId) +(const sal_Int32 nId) { mpParserState->getDocument()->resolveFootnote - (*mpStream, 0, rId); + (*mpStream, 0, nId); } -void OOXMLFastContextHandler::resolveEndnote(const rtl::OUString & rId) +void OOXMLFastContextHandler::resolveEndnote(const sal_Int32 nId) { mpParserState->getDocument()->resolveEndnote - (*mpStream, 0, rId); + (*mpStream, 0, nId); } -void OOXMLFastContextHandler::resolveComment(const rtl::OUString & rId) +void OOXMLFastContextHandler::resolveComment(const sal_Int32 nId) { - mpParserState->getDocument()->resolveComment(*mpStream, rId); + mpParserState->getDocument()->resolveComment(*mpStream, nId); } void OOXMLFastContextHandler::resolvePicture(const rtl::OUString & rId) @@ -1106,7 +1137,7 @@ void OOXMLFastContextHandler::resolvePropertySetAttrs() void OOXMLFastContextHandler::sendPropertyToParent() { #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->startElement("contexthandler.sendPropertyToParent"); + debug_logger->element("sendPropertyToParent"); #endif if (mpParent != NULL) @@ -1119,16 +1150,8 @@ void OOXMLFastContextHandler::sendPropertyToParent() pProp(new OOXMLPropertyImpl(mId, getValue(), OOXMLPropertyImpl::SPRM)); pProps->add(pProp); - -#ifdef DEBUG_CONTEXT_HANDLER - debug_logger->addTag(toPropertiesTag(pProps)); -#endif } } - -#ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendPropertyToParent"); -#endif } void OOXMLFastContextHandler::sendPropertiesToParent() @@ -1139,25 +1162,27 @@ void OOXMLFastContextHandler::sendPropertiesToParent() if (mpParent != NULL) { OOXMLPropertySet::Pointer_t pParentProps(mpParent->getPropertySet()); - + if (pParentProps.get() != NULL) { OOXMLPropertySet::Pointer_t pProps(getPropertySet()); - + if (pProps.get() != NULL) - { + { OOXMLValue::Pointer_t pValue (new OOXMLPropertySetValue(getPropertySet())); - + OOXMLProperty::Pointer_t pProp (new OOXMLPropertyImpl(getId(), pValue, OOXMLPropertyImpl::SPRM)); - + + pParentProps->add(pProp); + } } } #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.sendPropertiesToParent"); + debug_logger->endElement(); #endif } @@ -1200,7 +1225,7 @@ void OOXMLFastContextHandlerStream::sendProperty(Id nId) debug_logger->startElement("contexthandler.sendProperty"); debug_logger->attribute("id", (*QNameToString::Instance())(nId)); debug_logger->chars(xmlify(getPropertySetAttrs()->toString())); - debug_logger->endElement("contexthandler.sendProperty"); + debug_logger->endElement(); #endif OOXMLPropertySetEntryToString aHandler(nId); @@ -1222,7 +1247,7 @@ void OOXMLFastContextHandlerStream::resolvePropertySetAttrs() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("contexthandler.resolvePropertySetAttrs"); debug_logger->chars(mpPropertySetAttrs->toString()); - debug_logger->endElement("contexthandler.resolvePropertySetAttrs"); + debug_logger->endElement(); #endif mpStream->props(mpPropertySetAttrs); } @@ -1279,13 +1304,35 @@ OOXMLValue::Pointer_t OOXMLFastContextHandlerProperties::getValue() const return OOXMLValue::Pointer_t(new OOXMLPropertySetValue(mpPropertySet)); } -#ifdef DEBUG -XMLTag::Pointer_t OOXMLFastContextHandlerProperties::toTag() const +#if OSL_DEBUG_LEVEL > 1 +void OOXMLFastContextHandlerProperties::dumpXml( const TagLogger::Pointer_t pLogger) const { - XMLTag::Pointer_t pTag(OOXMLFastContextHandler::toTag()); - pTag->addAttr("resolve", mbResolve ? "resolve" : "noResolve"); + pLogger->startElement("context"); + + static char sBuffer[128]; + snprintf(sBuffer, sizeof(sBuffer), "%p", this); + + pLogger->attribute("parent", sBuffer); + pLogger->attribute("type", getType()); + pLogger->attribute("resource", getResourceString()); + pLogger->attribute("token", fastTokenToId(getToken())); + pLogger->attribute("id", (*QNameToString::Instance())(getId())); + + OOXMLValue::Pointer_t pVal(getValue()); + + if (pVal.get() != NULL) + pLogger->attribute("value", pVal->toString()); + else + pLogger->attribute("value", "(null)"); + + pLogger->attribute("resolve", mbResolve ? "resolve" : "noResolve"); - return pTag; + pLogger->propertySet(getPropertySet(), + IdToString::Pointer_t(new OOXMLIdToString())); + + mpParserState->dumpXml( pLogger ); + + pLogger->endElement(); } #endif @@ -1389,7 +1436,7 @@ void OOXMLFastContextHandlerProperties::setParent #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("setParent"); debug_logger->chars("OOXMLFastContextHandlerProperties"); - debug_logger->endElement("setParent"); + debug_logger->endElement(); #endif OOXMLFastContextHandler::setParent(pParent); @@ -1440,7 +1487,7 @@ void OOXMLFastContextHandlerPropertyTable::lcl_endFastElement #ifdef DEBUG_PROPERTIES debug_logger->startElement("table"); debug_logger->attribute("id", (*QNameToString::Instance())(mId)); - debug_logger->endElement("table"); + debug_logger->endElement(); #endif mpStream->table(mId, pTable); @@ -1472,7 +1519,7 @@ void OOXMLFastContextHandlerValue::setValue(OOXMLValue::Pointer_t pValue) mpValue = pValue; #ifdef DEBUG_CONTEXT_HANDLER - debug_logger->endElement("contexthandler.setValue"); + debug_logger->endElement(); #endif } @@ -1486,7 +1533,7 @@ void OOXMLFastContextHandlerValue::lcl_endFastElement throw (uno::RuntimeException, xml::sax::SAXException) { sendPropertyToParent(); - + endAction(Element); } @@ -1508,7 +1555,7 @@ void OOXMLFastContextHandlerValue::setDefaultIntegerValue() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->element("setDefaultIntegerValue"); #endif - + if (mpValue.get() == NULL) { OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(0)); @@ -1521,7 +1568,7 @@ void OOXMLFastContextHandlerValue::setDefaultHexValue() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->element("setDefaultHexValue"); #endif - + if (mpValue.get() == NULL) { OOXMLValue::Pointer_t pValue(new OOXMLHexValue(0)); @@ -1534,7 +1581,7 @@ void OOXMLFastContextHandlerValue::setDefaultStringValue() #ifdef DEBUG_CONTEXT_HANDLER debug_logger->element("setDefaultStringValue"); #endif - + if (mpValue.get() == NULL) { OOXMLValue::Pointer_t pValue(new OOXMLStringValue(::rtl::OUString())); @@ -1582,7 +1629,7 @@ void OOXMLFastContextHandlerTable::lcl_endFastElement debug_logger->startElement("table"); string str = (*QNameToString::Instance())(mId); debug_logger->attribute("id", str); - debug_logger->endElement("table"); + debug_logger->endElement(); #endif mpStream->table(mId, pTable); @@ -1616,7 +1663,7 @@ void OOXMLFastContextHandlerTable::newPropertySet OOXMLFastContextHandlerXNote::OOXMLFastContextHandlerXNote (OOXMLFastContextHandler * pContext) -: OOXMLFastContextHandler(pContext) +: OOXMLFastContextHandler(pContext), mbForwardEventsSaved(false) { } @@ -1631,7 +1678,7 @@ void OOXMLFastContextHandlerXNote::lcl_startFastElement { mbForwardEventsSaved = isForwardEvents(); - if (msMyXNoteId.compareTo(getXNoteId()) == 0) + if (mnMyXNoteId == getXNoteId()) setForwardEvents(true); else setForwardEvents(false); @@ -1652,12 +1699,12 @@ void OOXMLFastContextHandlerXNote::checkId(OOXMLValue::Pointer_t pValue) { #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("checkId"); - debug_logger->attribute("myId", pValue->getString()); + debug_logger->attribute("myId", sal_Int32(pValue->getInt())); debug_logger->attribute("id", getXNoteId()); - debug_logger->endElement("checkId"); + debug_logger->endElement(); #endif - msMyXNoteId = pValue->getString(); + mnMyXNoteId = sal_Int32(pValue->getInt()); } /* @@ -1707,11 +1754,11 @@ void OOXMLFastContextHandlerTextTableCell::endCell() #ifdef DEBUG_PROPERTIES debug_logger->startElement("endcell"); - debug_logger->addTag(toPropertiesTag - (OOXMLPropertySet::Pointer_t(pProps->clone()))); - debug_logger->endElement("endcell"); + debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif - mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps)); + mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps)); } } @@ -1764,9 +1811,9 @@ void OOXMLFastContextHandlerTextTableRow::endRow() #ifdef DEBUG_PROPERTIES debug_logger->startElement("endrow"); - debug_logger->addTag(toPropertiesTag - (OOXMLPropertySet::Pointer_t(pProps->clone()))); - debug_logger->endElement("endrow"); + debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); #endif mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps)); @@ -1803,7 +1850,7 @@ void OOXMLFastContextHandlerTextTable::lcl_startFastElement { mpParserState->startTable(); mnTableDepth++; - + boost::shared_ptr<OOXMLPropertySet> pProps( new OOXMLPropertySetImpl ); { OOXMLValue::Pointer_t pVal @@ -1833,7 +1880,7 @@ void OOXMLFastContextHandlerTextTable::lcl_endFastElement OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape (OOXMLFastContextHandler * pContext) -: OOXMLFastContextHandlerProperties(pContext), m_bShapeSent( false ), +: OOXMLFastContextHandlerProperties(pContext), m_bShapeSent( false ), m_bShapeStarted(false) { uno::Reference<uno::XComponentContext> xContext(getComponentContext()); @@ -1842,13 +1889,19 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape uno::Reference<XMultiComponentFactory> rServiceManager (xContext->getServiceManager()); - mrShapeContext.set - (rServiceManager-> - createInstanceWithContext - (::rtl::OUString - (RTL_CONSTASCII_USTRINGPARAM - ("com.sun.star.xml.sax.FastShapeContextHandler")), xContext), - uno::UNO_QUERY); + mrShapeContext.set( getDocument( )->getShapeContext( ) ); + if ( !mrShapeContext.is( ) ) + { + // Define the shape context for the whole document + mrShapeContext.set + (rServiceManager-> + createInstanceWithContext + (::rtl::OUString + (RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.xml.sax.FastShapeContextHandler")), xContext), + uno::UNO_QUERY); + getDocument()->setShapeContext( mrShapeContext ); + } if (mrShapeContext.is()) { @@ -1859,7 +1912,7 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape #ifdef DEBUG_CONTEXT_HANDLER debug_logger->startElement("setRelationFragmentPath"); debug_logger->attribute("path", mpParserState->getTarget()); - debug_logger->endElement("setRelationFragmentPath"); + debug_logger->endElement(); #endif mrShapeContext->setRelationFragmentPath (mpParserState->getTarget()); @@ -1869,7 +1922,7 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape { debug_logger->startElement("error"); debug_logger->chars("failed to get shape handler"); - debug_logger->endElement("error"); + debug_logger->endElement(); } #endif } @@ -1905,7 +1958,7 @@ void SAL_CALL OOXMLFastContextHandlerShape::startUnknownElement void OOXMLFastContextHandlerShape::setToken(Token_t nToken) { OOXMLFastContextHandler::setToken(nToken); - + if (mrShapeContext.is()) mrShapeContext->setStartToken(nToken); } @@ -1921,9 +1974,9 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element ) pValue(new OOXMLShapeValue(xShape)); newProperty(NS_ooxml::LN_shape, pValue); m_bShapeSent = true; - + bool bIsPicture = Element == ( NS_picture | OOXML_pic ); - + // Notify the dmapper that the shape is ready to use if ( !bIsPicture ) { @@ -1945,7 +1998,7 @@ void OOXMLFastContextHandlerShape::lcl_endFastElement } OOXMLFastContextHandlerProperties::lcl_endFastElement(Element); - + // Ending the shape should be the last thing to do bool bIsPicture = Element == ( NS_picture | OOXML_pic ); if ( !bIsPicture && m_bShapeStarted) @@ -1998,7 +2051,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext xContextHandler.set(this); break; } - + return xContextHandler; } @@ -2149,12 +2202,12 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext { debug_logger->startElement("namespace"); debug_logger->attribute("id", fastTokenToId(*aIt)); - debug_logger->endElement("namespace"); + debug_logger->endElement(); aIt++; } - debug_logger->endElement("Wrapper-createChildContext"); + debug_logger->endElement(); #endif bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end(); @@ -2172,7 +2225,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext } else xResult.set(this); - + if ( bInTokens ) { OOXMLFastContextHandlerShape* pShapeCtx = (OOXMLFastContextHandlerShape*)mpParent; @@ -2307,3 +2360,5 @@ Token_t OOXMLFastContextHandlerWrapper::getToken() const } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index 62e796896..1fe964bed 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -145,9 +146,9 @@ public: void mark(const Id & rId, OOXMLValue::Pointer_t pVal); - void resolveFootnote(const rtl::OUString & rId); - void resolveEndnote(const rtl::OUString & rId); - void resolveComment(const rtl::OUString & rId); + void resolveFootnote(const sal_Int32 nId); + void resolveEndnote(const sal_Int32 nId); + void resolveComment(const sal_Int32 nId); void resolvePicture(const rtl::OUString & rId); void resolveHeader(const sal_Int32 type, const rtl::OUString & rId); @@ -165,8 +166,8 @@ public: void setDocument(OOXMLDocument * pDocument); OOXMLDocument * getDocument(); void setXNoteId(OOXMLValue::Pointer_t pValue); - void setXNoteId(const ::rtl::OUString & rId); - const rtl::OUString & getXNoteId() const; + void setXNoteId(const sal_Int32 nId); + sal_Int32 getXNoteId() const; void setForwardEvents(bool bForwardEvents); bool isForwardEvents() const; virtual void setParent(OOXMLFastContextHandler * pParent); @@ -203,6 +204,9 @@ public: void handleLastParagraphInSection(); void endOfParagraph(); void text(const ::rtl::OUString & sText); + void positionOffset(const ::rtl::OUString & sText); + void alignH(const ::rtl::OUString & sText); + void alignV(const ::rtl::OUString & sText); virtual void propagateCharacterProperties(); virtual void propagateCharacterPropertiesAsSet(const Id & rId); virtual void propagateTableProperties(); @@ -224,12 +228,11 @@ public: void sendPropertyToParent(); -#ifdef DEBUG - static XMLTag::Pointer_t toPropertiesTag(OOXMLPropertySet::Pointer_t); - virtual XMLTag::Pointer_t toTag() const; - virtual string toString() const; +#if OSL_DEBUG_LEVEL > 1 + virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const; #endif + sal_uInt32 getInstanceNumber() { return mnInstanceNumber; } protected: OOXMLFastContextHandler * mpParent; Id mId; @@ -279,6 +282,9 @@ protected: sal_uInt32 mnInstanceNumber; sal_uInt32 mnRefCount; + + bool inPositionV; + private: void operator =(OOXMLFastContextHandler &); // not defined @@ -332,8 +338,8 @@ public: virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet); virtual OOXMLPropertySet::Pointer_t getPropertySet() const; -#ifdef DEBUG - virtual XMLTag::Pointer_t toTag() const; +#if OSL_DEBUG_LEVEL > 1 + virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const; #endif protected: @@ -428,7 +434,7 @@ public: private: bool mbForwardEventsSaved; - ::rtl::OUString msMyXNoteId; + sal_Int32 mnMyXNoteId; virtual void lcl_startFastElement (sal_Int32 Element, @@ -631,3 +637,5 @@ private: }; }} #endif // INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx index 407c3a74f..6883e41ed 100644 --- a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -47,7 +48,7 @@ using namespace ::std; OOXMLFastDocumentHandler::OOXMLFastDocumentHandler (uno::Reference< uno::XComponentContext > const & context) -: m_xContext(context) +: m_xContext(context), mpStream(0), mpDocument(0) {} // ::com::sun::star::xml::sax::XFastContextHandler: @@ -84,7 +85,7 @@ OOXMLFastDocumentHandler::getContextHandler() const (new OOXMLFastContextHandler(m_xContext)); mpContextHandler->setStream(mpStream); mpContextHandler->setDocument(mpDocument); - mpContextHandler->setXNoteId(msXNoteId); + mpContextHandler->setXNoteId(mnXNoteId); mpContextHandler->setForwardEvents(true); } @@ -150,9 +151,9 @@ void OOXMLFastDocumentHandler::setDocument(OOXMLDocument * pDocument) mpDocument = pDocument; } -void OOXMLFastDocumentHandler::setXNoteId(const ::rtl::OUString & rXNoteId) +void OOXMLFastDocumentHandler::setXNoteId(const sal_Int32 nXNoteId) { - msXNoteId = rXNoteId; + mnXNoteId = nXNoteId; } void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream ) @@ -161,3 +162,5 @@ void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream ) } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx index d77c56b1c..2dba37b43 100644 --- a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -93,7 +94,7 @@ public: void setStream(Stream * pStream); void setDocument(OOXMLDocument * pDocument); - void setXNoteId(const ::rtl::OUString & rXNoteId); + void setXNoteId(const sal_Int32 nXNoteId); void setIsSubstream( bool bSubstream ); @@ -108,10 +109,12 @@ private: Stream::Pointer_t mpTmpStream; #endif OOXMLDocument * mpDocument; - ::rtl::OUString msXNoteId; + sal_Int32 mnXNoteId; mutable boost::shared_ptr<OOXMLFastContextHandler> mpContextHandler; boost::shared_ptr<OOXMLFastContextHandler> getContextHandler() const; }; }} #endif // INCLUDED_OOXML_FAST_DOCUMENT_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastHelper.hxx b/writerfilter/source/ooxml/OOXMLFastHelper.hxx index 2e256e88b..2871be083 100644 --- a/writerfilter/source/ooxml/OOXMLFastHelper.hxx +++ b/writerfilter/source/ooxml/OOXMLFastHelper.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -191,13 +192,13 @@ void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler, (rValue, RTL_TEXTENCODING_ASCII_US).getStr()); if (aStr.size() == 0) - debug_logger->addTag(XMLTag::Pointer_t(new XMLTag("unknown-qname"))); + debug_logger->element( "unknown-qname" ); #endif pHandler->newProperty(nId, pVal); #ifdef DEBUG_HELPER - debug_logger->endElement("newProperty-from-string"); + debug_logger->endElement(); #endif } @@ -217,9 +218,9 @@ void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler, debug_logger->attribute("value", pVal->toString()); if (aStr.size() == 0) - debug_logger->addTag(XMLTag::Pointer_t(new XMLTag("unknown-qname"))); + debug_logger->element("unknown-qname"); - debug_logger->endElement("helper.newProperty-from-int"); + debug_logger->endElement(); #endif pHandler->newProperty(nId, pVal); @@ -243,12 +244,14 @@ void OOXMLFastHelper<T>::mark(OOXMLFastContextHandler * pHandler, (rValue, RTL_TEXTENCODING_ASCII_US).getStr()); if (aStr.size() == 0) - debug_logger->addTag(XMLTag::Pointer_t(new XMLTag("unknown-qname"))); + debug_logger->element("unknown-qname"); - debug_logger->endElement("helper.mark"); + debug_logger->endElement(); #endif pHandler->mark(nId, pVal); } }} #endif // INCLUDED_FAST_HELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx b/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx index c04121925..20e5a746e 100644 --- a/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -123,3 +124,5 @@ css::uno::Sequence< ::sal_Int8 > SAL_CALL OOXMLFastTokenHandler::getUTF8Identifi } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx b/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx index ee391ea33..f6b900adc 100644 --- a/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -63,3 +64,5 @@ private: }} #endif // INCLUDED_OOXML_FAST_TOKEN_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx b/writerfilter/source/ooxml/OOXMLParserState.cxx index 8a4501c2c..943b6435f 100644 --- a/writerfilter/source/ooxml/OOXMLParserState.cxx +++ b/writerfilter/source/ooxml/OOXMLParserState.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,7 +42,7 @@ OOXMLParserState::OOXMLParserState() : mbInSectionGroup(false), mbInParagraphGroup(false), mbInCharacterGroup(false), - mbLastParagraphInSection(false), + mbLastParagraphInSection(false), mbForwardEvents(true), mnContexts(0), mnHandle(0), @@ -91,7 +92,7 @@ bool OOXMLParserState::isInCharacterGroup() const void OOXMLParserState::setInCharacterGroup(bool bInCharacterGroup) { mbInCharacterGroup = bInCharacterGroup; -} +} void OOXMLParserState::setForwardEvents(bool bForwardEvents) { @@ -127,12 +128,12 @@ OOXMLDocument * OOXMLParserState::getDocument() const return mpDocument; } -void OOXMLParserState::setXNoteId(const rtl::OUString & rId) +void OOXMLParserState::setXNoteId(const sal_Int32 nId) { - mpDocument->setXNoteId(rId); + mpDocument->setXNoteId(nId); } -const rtl::OUString & OOXMLParserState::getXNoteId() const +sal_Int32 OOXMLParserState::getXNoteId() const { return mpDocument->getXNoteId(); } @@ -154,7 +155,7 @@ void OOXMLParserState::resolveCharacterProperties(Stream & rStream) mpCharacterProps.reset(new OOXMLPropertySetImpl()); #ifdef DEBUG_PROPERTIES - debug_logger->endElement("resolveCharacterProperties"); + debug_logger->endElement(); #endif } } @@ -171,37 +172,37 @@ void OOXMLParserState::setCharacterProperties void OOXMLParserState::setCellProperties (OOXMLPropertySet::Pointer_t pProps) { - if (mCellProps.size() > 0) + if (!mCellProps.empty()) { OOXMLPropertySet::Pointer_t & rCellProps = mCellProps.top(); - + if (rCellProps.get() == NULL) rCellProps = pProps; - else + else rCellProps->add(pProps); } } - + void OOXMLParserState::setRowProperties (OOXMLPropertySet::Pointer_t pProps) { - if (mRowProps.size() > 0) + if (!mRowProps.empty()) { OOXMLPropertySet::Pointer_t & rRowProps = mRowProps.top(); - + if (rRowProps.get() == NULL) rRowProps = pProps; - else + else rRowProps->add(pProps); } } void OOXMLParserState::resolveCellProperties(Stream & rStream) { - if (mCellProps.size() > 0) + if (!mCellProps.empty()) { OOXMLPropertySet::Pointer_t & rCellProps = mCellProps.top(); - + if (rCellProps.get() != NULL) { rStream.props(rCellProps); @@ -212,10 +213,10 @@ void OOXMLParserState::resolveCellProperties(Stream & rStream) void OOXMLParserState::resolveRowProperties(Stream & rStream) { - if (mRowProps.size() > 0) + if (!mRowProps.empty()) { OOXMLPropertySet::Pointer_t & rRowProps = mRowProps.top(); - + if (rRowProps.get() != NULL) { rStream.props(rRowProps); @@ -226,10 +227,10 @@ void OOXMLParserState::resolveRowProperties(Stream & rStream) void OOXMLParserState::resolveTableProperties(Stream & rStream) { - if (mTableProps.size() > 0) + if (!mTableProps.empty()) { OOXMLPropertySet::Pointer_t & rTableProps = mTableProps.top(); - + if (rTableProps.get() != NULL) { rStream.props(rTableProps); @@ -241,10 +242,10 @@ void OOXMLParserState::resolveTableProperties(Stream & rStream) void OOXMLParserState::setTableProperties (OOXMLPropertySet::Pointer_t pProps) { - if (mTableProps.size() > 0) + if (!mTableProps.empty()) { OOXMLPropertySet::Pointer_t & rTableProps = mTableProps.top(); - if (rTableProps.get() == NULL) + if (rTableProps.get() == NULL) rTableProps = pProps; else rTableProps->add(pProps); @@ -256,12 +257,12 @@ void OOXMLParserState::startTable() OOXMLPropertySet::Pointer_t pCellProps; OOXMLPropertySet::Pointer_t pRowProps; OOXMLPropertySet::Pointer_t pTableProps; - + mCellProps.push(pCellProps); mRowProps.push(pRowProps); mTableProps.push(pTableProps); } - + void OOXMLParserState::endTable() { mCellProps.pop(); @@ -274,22 +275,17 @@ void OOXMLParserState::incContextCount() mnContexts++; } -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 unsigned int OOXMLParserState::getContextCount() const { return mnContexts; } -string OOXMLParserState::toString() const -{ - return toTag()->toString(); -} - -XMLTag::Pointer_t OOXMLParserState::toTag() const +void OOXMLParserState::dumpXml( const TagLogger::Pointer_t& pLogger ) { - XMLTag::Pointer_t pTag(new XMLTag("parserstate")); + pLogger->startElement("parserstate"); - string sTmp; + string sTmp; if (isInSectionGroup()) sTmp += "s"; @@ -305,20 +301,18 @@ XMLTag::Pointer_t OOXMLParserState::toTag() const sTmp += "c"; else sTmp += "-"; - + if (isForwardEvents()) sTmp += "f"; else sTmp += "-"; - pTag->addAttr("state", sTmp); - pTag->addAttr("XNoteId", - OUStringToOString(getXNoteId(), - RTL_TEXTENCODING_ASCII_US).getStr()); + pLogger->attribute("state", sTmp); + pLogger->attribute("XNoteId", getXNoteId() ); if (mpCharacterProps != OOXMLPropertySet::Pointer_t()) - pTag->chars(mpCharacterProps->toString()); + pLogger->chars(mpCharacterProps->toString()); - return pTag; + pLogger->endElement(); } XPathLogger & OOXMLParserState::getXPathLogger() @@ -328,3 +322,5 @@ XPathLogger & OOXMLParserState::getXPathLogger() #endif }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLParserState.hxx b/writerfilter/source/ooxml/OOXMLParserState.hxx index 4e9a513b2..5bbd90c9d 100644 --- a/writerfilter/source/ooxml/OOXMLParserState.hxx +++ b/writerfilter/source/ooxml/OOXMLParserState.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,7 +32,7 @@ #include <ooxml/OOXMLDocument.hxx> #include "OOXMLPropertySetImpl.hxx" -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 #include <resourcemodel/TagLogger.hxx> #include <resourcemodel/XPathLogger.hxx> #endif @@ -52,13 +53,13 @@ class OOXMLParserState unsigned int mnContexts; unsigned int mnHandle; OOXMLDocument * mpDocument; - rtl::OUString msXNoteId; + sal_Int32 mnXNoteId; rtl::OUString msTarget; OOXMLPropertySet::Pointer_t mpCharacterProps; stack<OOXMLPropertySet::Pointer_t> mCellProps; stack<OOXMLPropertySet::Pointer_t> mRowProps; stack<OOXMLPropertySet::Pointer_t> mTableProps; -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 XPathLogger m_xPathLogger; #endif @@ -89,8 +90,8 @@ public: void setDocument(OOXMLDocument * pDocument); OOXMLDocument * getDocument() const; - void setXNoteId(const rtl::OUString & rId); - const rtl::OUString & getXNoteId() const; + void setXNoteId(const sal_Int32 rId); + sal_Int32 getXNoteId() const; const rtl::OUString & getTarget() const; @@ -108,11 +109,10 @@ public: void incContextCount(); -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 public: unsigned int getContextCount() const; - string toString() const; - XMLTag::Pointer_t toTag() const; + void dumpXml( const TagLogger::Pointer_t& pLogger ); XPathLogger & getXPathLogger(); #endif @@ -121,3 +121,5 @@ public: }} #endif // INCLUDE_OOXML_PARSER_STATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.hxx b/writerfilter/source/ooxml/OOXMLPropertySet.hxx index c2844e396..62c45c5d7 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySet.hxx +++ b/writerfilter/source/ooxml/OOXMLPropertySet.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,3 +81,5 @@ public: }} #endif // INCLUDED_OOXML_PROPERTY_SET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx index e36ee2328..a739c3b48 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -435,11 +436,11 @@ void OOXMLPropertySetImpl::resolve(Properties & rHandler) { debug_logger->startElement("error"); debug_logger->chars("zero-property"); - debug_logger->endElement("error"); + debug_logger->endElement(); } #endif - aIt++; + ++aIt; } } @@ -502,7 +503,7 @@ void OOXMLPropertySetImpl::add(OOXMLPropertySet::Pointer_t pPropertySet) { mProperties.resize(mProperties.size() + pSet->mProperties.size()); for (OOXMLProperties_t::iterator aIt = pSet->mProperties.begin(); - aIt != pSet->mProperties.end(); aIt++) + aIt != pSet->mProperties.end(); ++aIt) add(*aIt); } } @@ -529,7 +530,7 @@ string OOXMLPropertySetImpl::toString() OOXMLProperties_t::iterator aItBegin = begin(); OOXMLProperties_t::iterator aItEnd = end(); - for (OOXMLProperties_t::iterator aIt = aItBegin; aIt != aItEnd; aIt++) + for (OOXMLProperties_t::iterator aIt = aItBegin; aIt != aItEnd; ++aIt) { if (aIt != aItBegin) sResult += ", "; @@ -722,7 +723,7 @@ void OOXMLTableImpl::resolve(Table & rTable) pTable->entry(nPos, pProperties); ++nPos; - it++; + ++it; } } @@ -771,7 +772,7 @@ const ::rtl::OUString & OOXMLPropertySetEntryToString::getString() const } OOXMLPropertySetEntryToInteger::OOXMLPropertySetEntryToInteger(Id nId) -: mnId(nId) +: mnId(nId), mnValue(0) { } @@ -795,3 +796,5 @@ int OOXMLPropertySetEntryToInteger::getValue() const } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx index a558f8a25..6b1dd1994 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -287,3 +288,5 @@ Sprm::Kind SprmKind(sal_uInt32 nSprmCode); } // namespace writerfilter #endif // INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx index e5019d644..784740554 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,9 +31,8 @@ #include "ooxmlLoggers.hxx" #include <iostream> -#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALSTORAGEACCESS_HPP_ #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp> -#endif +#include <com/sun/star/uri/UriReferenceFactory.hpp> //#define DEBUG_STREAM @@ -137,6 +137,11 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> ::rtl::OUString & rDocumentTarget) { bool bFound = false; + static uno::Reference< com::sun::star::uri::XUriReferenceFactory > xFac = ::com::sun::star::uri::UriReferenceFactory::create( mxContext ); + // use '/' to representent the root of the zip package ( and provide a 'file' scheme to + // keep the XUriReference implementation happy ) + // add mspath to represent the 'source' of this stream + uno::Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) + msPath ); static rtl::OUString sType(RTL_CONSTASCII_USTRINGPARAM("Type")); static rtl::OUString sId(RTL_CONSTASCII_USTRINGPARAM("Id")); @@ -152,11 +157,15 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> static rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("Target")); static rtl::OUString sTargetMode(RTL_CONSTASCII_USTRINGPARAM("TargetMode")); static rtl::OUString sExternal(RTL_CONSTASCII_USTRINGPARAM("External")); + static rtl::OUString sVBAProjectType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.microsoft.com/office/2006/relationships/vbaProject")); rtl::OUString sStreamType; switch (nStreamType) { + case VBAPROJECT: + sStreamType = sVBAProjectType; + break; case DOCUMENT: sStreamType = sDocumentType; break; @@ -223,8 +232,16 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> rDocumentTarget = sMyTarget; else { - rDocumentTarget = msPath; - rDocumentTarget += lcl_normalizeTarget(sMyTarget); + // 'Target' is a relative Uri, so a 'Target=/path' + // with a base Uri of file://base/foo will resolve to + // file://base/word. We need something more than some + // simple string concatination here to handle that. + uno::Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse( sMyTarget ); + uno::Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute( xBase, xPart, sal_True, com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN ); + rDocumentTarget = xAbs->getPath(); + // path will start with the fragment separator. need to + // remove that + rDocumentTarget = rDocumentTarget.copy( 1 ); } break; @@ -299,7 +316,7 @@ uno::Reference<xml::sax::XParser> OOXMLStreamImpl::getParser() uno::Reference<xml::sax::XParser> xParser (xFactory->createInstanceWithContext - ( rtl::OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), + ( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser")), mxContext ), uno::UNO_QUERY ); @@ -351,3 +368,5 @@ OOXMLDocumentFactory::createStream } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx.orig b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx.orig new file mode 100644 index 000000000..319178a4d --- /dev/null +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx.orig @@ -0,0 +1,377 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "OOXMLStreamImpl.hxx" +#include "OOXMLFastTokenHandler.hxx" +#include "ooxmlLoggers.hxx" +#include <iostream> + +#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> + +//#define DEBUG_STREAM + +namespace writerfilter { +namespace ooxml +{ + +using namespace ::std; + +OOXMLStreamImpl::OOXMLStreamImpl +(uno::Reference<uno::XComponentContext> xContext, + uno::Reference<io::XInputStream> xStorageStream, StreamType_t nType) +: mxContext(xContext), mxStorageStream(xStorageStream), mnStreamType(nType) +{ + mxStorage.set + (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream + (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream)); + mxRelationshipAccess.set(mxStorage, uno::UNO_QUERY_THROW); + + init(); +} + +OOXMLStreamImpl::OOXMLStreamImpl +(OOXMLStreamImpl & rOOXMLStream, StreamType_t nStreamType) +: mxContext(rOOXMLStream.mxContext), + mxStorageStream(rOOXMLStream.mxStorageStream), + mxStorage(rOOXMLStream.mxStorage), + mnStreamType(nStreamType), + msPath(rOOXMLStream.msPath) +{ + mxRelationshipAccess.set(rOOXMLStream.mxDocumentStream, uno::UNO_QUERY_THROW); + + init(); +} + +OOXMLStreamImpl::OOXMLStreamImpl +(OOXMLStreamImpl & rOOXMLStream, const rtl::OUString & rId) +: mxContext(rOOXMLStream.mxContext), + mxStorageStream(rOOXMLStream.mxStorageStream), + mxStorage(rOOXMLStream.mxStorage), + mnStreamType(UNKNOWN), + msId(rId), + msPath(rOOXMLStream.msPath) +{ + mxRelationshipAccess.set(rOOXMLStream.mxDocumentStream, uno::UNO_QUERY_THROW); + + init(); +} + +OOXMLStreamImpl::~OOXMLStreamImpl() +{ +#ifdef DEBUG_STREAM + debug_logger->endElement("stream"); +#endif +} + +const ::rtl::OUString & OOXMLStreamImpl::getTarget() const +{ + return msTarget; +} + +::rtl::OUString lcl_normalizeTarget(const ::rtl::OUString & s) +{ + const int nStringsToCut = 2; + const ::rtl::OUString aStringToCut[] = { + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("./")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + }; + + bool bDone = false; + sal_Int32 nIndex = 0; + while (!bDone) + { + for (int n = 0; n <= nStringsToCut; n++) + { + if (n == nStringsToCut) + { + bDone = true; + } + else + { + sal_Int32 nNewIndex = s.indexOf(aStringToCut[n], nIndex); + + if (nIndex == nNewIndex) + { + sal_Int32 nLength = aStringToCut[n].getLength(); + nIndex += nLength; + + break; + } + } + } + } + + return s.copy(nIndex); +} + +bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> + xRelationshipAccess, + StreamType_t nStreamType, + const ::rtl::OUString & rId, + ::rtl::OUString & rDocumentTarget) +{ + bool bFound = false; + static uno::Reference< com::sun::star::uri::XUriReferenceFactory > xFac = ::com::sun::star::uri::UriReferenceFactory::create( mxContext ); + // use '/' to representent the root of the zip package ( and provide a 'file' scheme to + // keep the XUriReference implementation happy ) + // add mspath to represent the 'source' of this stream + uno::Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) + msPath ); + + static rtl::OUString sType(RTL_CONSTASCII_USTRINGPARAM("Type")); + static rtl::OUString sId(RTL_CONSTASCII_USTRINGPARAM("Id")); + static rtl::OUString sDocumentType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument")); + static rtl::OUString sStylesType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles")); + static rtl::OUString sNumberingType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering")); + static rtl::OUString sFonttableType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable")); + static rtl::OUString sFootnotesType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes")); + static rtl::OUString sEndnotesType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes")); + static rtl::OUString sCommentsType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments")); + static rtl::OUString sThemeType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme")); + static rtl::OUString sSettingsType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings")); + static rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("Target")); + static rtl::OUString sTargetMode(RTL_CONSTASCII_USTRINGPARAM("TargetMode")); + static rtl::OUString sExternal(RTL_CONSTASCII_USTRINGPARAM("External")); + static rtl::OUString sVBAProjectType(RTL_CONSTASCII_USTRINGPARAM("http://schemas.microsoft.com/office/2006/relationships/vbaProject")); + + rtl::OUString sStreamType; + + switch (nStreamType) + { + case VBAPROJECT: + sStreamType = sVBAProjectType; + break; + case DOCUMENT: + sStreamType = sDocumentType; + break; + case STYLES: + sStreamType = sStylesType; + break; + case NUMBERING: + sStreamType = sNumberingType; + break; + case FONTTABLE: + sStreamType = sFonttableType; + break; + case FOOTNOTES: + sStreamType = sFootnotesType; + break; + case ENDNOTES: + sStreamType = sEndnotesType; + break; + case COMMENTS: + sStreamType = sCommentsType; + break; + case THEME: + sStreamType = sThemeType; + break; + case SETTINGS: + sStreamType = sSettingsType; + break; + default: + break; + } + + if (xRelationshipAccess.is()) + { + uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = + xRelationshipAccess->getAllRelationships(); + + for (sal_Int32 j = 0; j < aSeqs.getLength(); j++) + { + uno::Sequence< beans::StringPair > aSeq = aSeqs[j]; + + bool bExternalTarget = false; + ::rtl::OUString sMyTarget; + for (sal_Int32 i = 0; i < aSeq.getLength(); i++) + { + beans::StringPair aPair = aSeq[i]; + + if (aPair.First.compareTo(sType) == 0 && + aPair.Second.compareTo(sStreamType) == 0) + bFound = true; + else if (aPair.First.compareTo(sId) == 0 && + aPair.Second.compareTo(rId) == 0) + bFound = true; + else if (aPair.First.compareTo(sTarget) == 0) + sMyTarget = aPair.Second; + else if (aPair.First.compareTo(sTargetMode) == 0 && + aPair.Second.compareTo(sExternal) == 0) + bExternalTarget = true; + + } + + if (bFound) + { + if (bExternalTarget) + rDocumentTarget = sMyTarget; + else + { +<<<<<<< HEAD + rDocumentTarget = msPath; + rDocumentTarget += lcl_normalizeTarget(sMyTarget); +======= + // 'Target' is a relative Uri, so a 'Target=/path' + // with a base Uri of file://base/foo will resolve to + // file://base/word. We need something more than some + // simple string concatination here to handle that. + uno::Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse( sMyTarget ); + uno::Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute( xBase, xPart, sal_True, com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN ); + rDocumentTarget = xAbs->getPath(); + // path will start with the fragment separator. need to + // remove that + rDocumentTarget = rDocumentTarget.copy( 1 ); +>>>>>>> master + } + + break; + } + } + } + + return bFound; +} + +::rtl::OUString OOXMLStreamImpl::getTargetForId(const ::rtl::OUString & rId) +{ + ::rtl::OUString sTarget; + + uno::Reference<embed::XRelationshipAccess> xRelationshipAccess + (mxDocumentStream, uno::UNO_QUERY_THROW); + + if (lcl_getTarget(xRelationshipAccess, UNKNOWN, rId, sTarget)) + return sTarget; + + return ::rtl::OUString(); +} + +void OOXMLStreamImpl::init() +{ + bool bFound = lcl_getTarget(mxRelationshipAccess, + mnStreamType, msId, msTarget); +#ifdef DEBUG_STREAM + debug_logger->startElement("stream"); + debug_logger->attribute("target", msTarget); +#endif + + if (bFound) + { + sal_Int32 nLastIndex = msTarget.lastIndexOf('/'); + if (nLastIndex >= 0) + msPath = msTarget.copy(0, nLastIndex + 1); + + uno::Reference<embed::XHierarchicalStorageAccess> + xHierarchicalStorageAccess(mxStorage, uno::UNO_QUERY); + + if (xHierarchicalStorageAccess.is()) + { + uno::Any aAny(xHierarchicalStorageAccess-> + openStreamElementByHierarchicalName + (msTarget, embed::ElementModes::SEEKABLEREAD)); + aAny >>= mxDocumentStream; + } + } +} + +uno::Reference<io::XInputStream> OOXMLStreamImpl::getDocumentStream() +{ + uno::Reference<io::XInputStream> xResult; + + if (mxDocumentStream.is()) + xResult = mxDocumentStream->getInputStream(); + + return xResult; +} + +uno::Reference<io::XInputStream> OOXMLStreamImpl::getStorageStream() +{ + return mxStorageStream; +} + +uno::Reference<xml::sax::XParser> OOXMLStreamImpl::getParser() +{ + uno::Reference<lang::XMultiComponentFactory> xFactory = + uno::Reference<lang::XMultiComponentFactory> + (mxContext->getServiceManager()); + + uno::Reference<xml::sax::XParser> xParser + (xFactory->createInstanceWithContext + ( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser")), + mxContext ), + uno::UNO_QUERY ); + + return xParser; +} + +uno::Reference<uno::XComponentContext> OOXMLStreamImpl::getContext() +{ + return mxContext; +} + +uno::Reference <xml::sax::XFastTokenHandler> +OOXMLStreamImpl::getFastTokenHandler +(uno::Reference<uno::XComponentContext> xContext) +{ + if (! mxFastTokenHandler.is()) + mxFastTokenHandler.set(new OOXMLFastTokenHandler(xContext)); + + return mxFastTokenHandler; +} + +OOXMLStream::Pointer_t +OOXMLDocumentFactory::createStream +(uno::Reference<uno::XComponentContext> xContext, + uno::Reference<io::XInputStream> rStream, + OOXMLStream::StreamType_t nStreamType) +{ + OOXMLStreamImpl * pStream = new OOXMLStreamImpl(xContext, rStream, + nStreamType); + return OOXMLStream::Pointer_t(pStream); +} + +OOXMLStream::Pointer_t +OOXMLDocumentFactory::createStream +(OOXMLStream::Pointer_t pStream, OOXMLStream::StreamType_t nStreamType) +{ + return OOXMLStream::Pointer_t + (new OOXMLStreamImpl(*dynamic_cast<OOXMLStreamImpl *>(pStream.get()), + nStreamType)); +} + +OOXMLStream::Pointer_t +OOXMLDocumentFactory::createStream +(OOXMLStream::Pointer_t pStream, const rtl::OUString & rId) +{ + return OOXMLStream::Pointer_t + (new OOXMLStreamImpl(*dynamic_cast<OOXMLStreamImpl *>(pStream.get()), + rId)); +} + +}} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx index 3d1cef5a0..7987ce450 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -89,3 +90,5 @@ public: }; }} #endif // INCLUDED_OOXML_STREAM_IMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/RefAndPointer.hxx b/writerfilter/source/ooxml/RefAndPointer.hxx index 9a12e455a..7d81d63e3 100644 --- a/writerfilter/source/ooxml/RefAndPointer.hxx +++ b/writerfilter/source/ooxml/RefAndPointer.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,6 +59,8 @@ public: : mRef(xRef) { mpHandler = dynamic_cast<ChildClass *>(xRef.get()); +#ifdef DEBUG_MEMORY +#endif } virtual ~RefAndPointer() @@ -94,3 +97,5 @@ public: }; }} #endif // INCLUDED_REF_AND_POINTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/RefAndPointer.hxx.orig b/writerfilter/source/ooxml/RefAndPointer.hxx.orig new file mode 100644 index 000000000..98e3ed966 --- /dev/null +++ b/writerfilter/source/ooxml/RefAndPointer.hxx.orig @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_REF_AND_POINTER_HXX +#define INCLUDED_REF_AND_POINTER_HXX + +#include <iostream> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +namespace writerfilter { +namespace ooxml +{ +using namespace ::com::sun::star; +using namespace ::std; + +template <class Interface, class ChildClass> +class RefAndPointer +{ + mutable ChildClass * mpHandler; + mutable uno::Reference<Interface> mRef; + +public: + RefAndPointer() + : mpHandler(NULL) + { + } + + RefAndPointer(ChildClass * pHandler) + : mpHandler(pHandler), mRef(pHandler) + { + } + + RefAndPointer(uno::Reference<Interface> xRef) + : mRef(xRef) + { + mpHandler = dynamic_cast<ChildClass *>(xRef.get()); +<<<<<<< HEAD +======= +#ifdef DEBUG_MEMORY + if (mpHandler != NULL) + clog << "MEMORY:" << mpHandler->getInstanceNumber() + << ":RefAndPointer" << endl; +#endif +>>>>>>> master + } + + virtual ~RefAndPointer() + { + } + + void set(ChildClass * pHandler) + { + mpHandler = pHandler; + mRef = pHandler; + } + + void set(uno::Reference<Interface> xHandler) + { + mpHandler = dynamic_cast<ChildClass*>(xHandler.get()); + mRef = xHandler; + } + + ChildClass * getPointer() const { return mpHandler; } + const uno::Reference<Interface> getRef() const { return mRef; } + + RefAndPointer & operator= + (const RefAndPointer & rSrc) + { + set(rSrc.getHandler()); + + return *this; + } + + bool is() { return getRef().is(); } + + operator ChildClass* () { return getPointer(); } + operator uno::Reference<Interface> () { return getRef(); } +}; +}} +#endif // INCLUDED_REF_AND_POINTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/factory.xsl b/writerfilter/source/ooxml/factory.xsl index 544c15002..108ff78c0 100644 --- a/writerfilter/source/ooxml/factory.xsl +++ b/writerfilter/source/ooxml/factory.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify @@ -86,4 +82,4 @@ using namespace ::com::sun::star; </xsl:text> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +</xsl:stylesheet> diff --git a/writerfilter/source/ooxml/factory_ns.xsl b/writerfilter/source/ooxml/factory_ns.xsl index a65d51247..e7bc85e53 100644 --- a/writerfilter/source/ooxml/factory_ns.xsl +++ b/writerfilter/source/ooxml/factory_ns.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify @@ -161,4 +157,4 @@ namespace ooxml { <xsl:text>
</xsl:text> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +</xsl:stylesheet> diff --git a/writerfilter/source/ooxml/factory_values.xsl b/writerfilter/source/ooxml/factory_values.xsl index 4960f58e6..98a7f6d73 100644 --- a/writerfilter/source/ooxml/factory_values.xsl +++ b/writerfilter/source/ooxml/factory_values.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/writerfilter/source/ooxml/factoryimpl.xsl b/writerfilter/source/ooxml/factoryimpl.xsl index 61ca828c3..20f578109 100644 --- a/writerfilter/source/ooxml/factoryimpl.xsl +++ b/writerfilter/source/ooxml/factoryimpl.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify @@ -342,8 +338,8 @@ uno::Reference < xml::sax::XFastParser > OOXMLStreamImpl::getFastParser() (mxContext->getServiceManager()); mxFastParser.set(xFactory->createInstanceWithContext - ( ::rtl::OUString::createFromAscii - ( "com.sun.star.xml.sax.FastParser" ), + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM + ( "com.sun.star.xml.sax.FastParser" )), mxContext ), uno::UNO_QUERY_THROW); </xsl:text> <xsl:for-each select="//namespace-alias"> @@ -389,4 +385,4 @@ namespace ooxml { </xsl:text> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +</xsl:stylesheet> diff --git a/writerfilter/source/ooxml/factoryimpl_ns.xsl b/writerfilter/source/ooxml/factoryimpl_ns.xsl index 1c2af9b92..de0e9ddd4 100644 --- a/writerfilter/source/ooxml/factoryimpl_ns.xsl +++ b/writerfilter/source/ooxml/factoryimpl_ns.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify @@ -182,6 +178,12 @@ OOXMLFactory_ns::Pointer_t </xsl:text> <xsl:for-each select=".//rng:data[@type='int']"> <xsl:text>Integer</xsl:text> </xsl:for-each> + <xsl:for-each select=".//rng:data[@type='integer']"> + <xsl:text>Integer</xsl:text> + </xsl:for-each> + <xsl:for-each select=".//rng:data[@type='string']"> + <xsl:text>String</xsl:text> + </xsl:for-each> </xsl:template> <!-- @@ -522,6 +524,15 @@ CreateElementMapPointer </xsl:text> <xsl:when test="@action='text'"> pHandler->text(sText); </xsl:when> + <xsl:when test="@action='positionOffset'"> + pHandler->positionOffset(sText); + </xsl:when> + <xsl:when test="@action='alignH'"> + pHandler->alignH(sText); + </xsl:when> + <xsl:when test="@action='alignV'"> + pHandler->alignV(sText); + </xsl:when> <xsl:when test="@action='newProperty'"> <xsl:text> OOXMLFastHelper<OOXMLIntegerValue>::newProperty(pHandler, </xsl:text> @@ -629,7 +640,6 @@ CreateElementMapPointer </xsl:text> <xsl:text> }
</xsl:text> </xsl:if> <xsl:if test="string-length($switchblock2) > 0"> - <xsl:text> OOXMLFastContextHandlerValue * pValueHandler = dynamic_cast<OOXMLFastContextHandlerValue *>(pHandler);
</xsl:text> <xsl:text> switch (nDefine)
</xsl:text> <xsl:text> {
</xsl:text> <xsl:value-of select="$switchblock2"/> @@ -942,4 +952,4 @@ namespace ooxml { </xsl:text> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +</xsl:stylesheet> diff --git a/writerfilter/source/ooxml/factoryimpl_values.xsl b/writerfilter/source/ooxml/factoryimpl_values.xsl index 465923d41..7b4e67103 100644 --- a/writerfilter/source/ooxml/factoryimpl_values.xsl +++ b/writerfilter/source/ooxml/factoryimpl_values.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/writerfilter/source/ooxml/factoryinc.xsl b/writerfilter/source/ooxml/factoryinc.xsl index aa54a5c29..aa13bb1c6 100644 --- a/writerfilter/source/ooxml/factoryinc.xsl +++ b/writerfilter/source/ooxml/factoryinc.xsl @@ -7,10 +7,6 @@ OpenOffice.org - a multi-platform office productivity suite - $RCSfile: fastresources_wml.xsl,v $ - - $Revision: 1.3 $ - This file is part of OpenOffice.org. OpenOffice.org is free software: you can redistribute it and/or modify @@ -109,4 +105,4 @@ namespace ooxml { </xsl:text> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +</xsl:stylesheet> diff --git a/writerfilter/source/ooxml/factorytools.xsl b/writerfilter/source/ooxml/factorytools.xsl index a7b0af5f9..6b8f6c4ed 100644 --- a/writerfilter/source/ooxml/factorytools.xsl +++ b/writerfilter/source/ooxml/factorytools.xsl @@ -7,10 +7,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: $ - * - * $Revision: $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 73f157795..815a37185 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -6530,17 +6530,11 @@ </element> </choice> </define> - <define name="CT_PositionOffset"> - <ref name="ST_PositionOffset"/> - </define> <define name="ST_PositionOffset"> <data type="int"> <xs:documentation>Absolute Position Offset Value</xs:documentation> </data> </define> - <define name="CT_AlignH"> - <ref name="ST_AlignH"/> - </define> <define name="ST_AlignH"> <list> <xs:documentation>Relative Horizontal Alignment Positions</xs:documentation> @@ -6584,10 +6578,10 @@ <define name="CT_PosH"> <choice> <element name="align"> - <ref name="CT_AlignH"/> + <ref name="ST_AlignH"/> </element> <element name="posOffset"> - <ref name="CT_PositionOffset"/> + <ref name="ST_PositionOffset"/> </element> </choice> <attribute name="relativeFrom"> @@ -6595,9 +6589,6 @@ <xs:documentation>Horizontal Position Relative Base</xs:documentation> </attribute> </define> - <define name="CT_AlignV"> - <ref name="ST_AlignV"/> - </define> <define name="ST_AlignV"> <list> <xs:documentation>Vertical Alignment Definition</xs:documentation> @@ -6641,10 +6632,10 @@ <define name="CT_PosV"> <choice> <element name="align"> - <ref name="CT_AlignV"/> + <ref name="ST_AlignV"/> </element> <element name="posOffset"> - <ref name="CT_PositionOffset"/> + <ref name="ST_PositionOffset"/> </element> </choice> <attribute name="relativeFrom"> @@ -6826,15 +6817,11 @@ <element name="wrapThrough" tokenid="ooxml:EG_WrapType_wrapThrough"/> <element name="wrapTopAndBottom" tokenid="ooxml:EG_WrapType_wrapTopAndBottom"/> </resource> - <resource name="CT_PositionOffset" resource="Value" tag="shape"/> - <resource name="ST_PositionOffset" resource="Integer" generated="yes"/> - <resource name="CT_AlignH" resource="Value" tag="shape"/> - <resource name="ST_AlignH" resource="List" generated="yes" tag="shape"> - <value name="left" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignH_left">left</value> - <value name="right" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignH_right">right</value> - <value name="center" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignH_center">center</value> - <value name="inside" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignH_inside">inside</value> - <value name="outside" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignH_outside">outside</value> + <resource name="ST_PositionOffset" resource="Value"> + <action name="characters" action="positionOffset"/> + </resource> + <resource name="ST_AlignH" resource="Value"> + <action name="characters" action="alignH"/> </resource> <resource name="ST_RelFromH" resource="List" generated="yes"> <value name="margin" tokenid="ooxml:Value_wordprocessingDrawing_ST_RelFromH_margin">margin</value> @@ -6851,13 +6838,8 @@ <element name="posOffset" tokenid="ooxml:CT_PosH_posOffset"/> <attribute name="relativeFrom" tokenid="ooxml:CT_PosH_relativeFrom"/> </resource> - <resource name="CT_AlignV" resource="Value" tag="shape"/> - <resource name="ST_AlignV" resource="List" generated="yes"> - <value name="top" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignV_top">top</value> - <value name="bottom" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignV_bottom">bottom</value> - <value name="center" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignV_center">center</value> - <value name="inside" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignV_inside">inside</value> - <value name="outside" tokenid="ooxml:Value_wordprocessingDrawing_ST_AlignV_outside">outside</value> + <resource name="ST_AlignV" resource="Value"> + <action name="characters" action="alignV"/> </resource> <resource name="ST_RelFromV" resource="List" generated="yes"> <value name="margin" tokenid="ooxml:Value_wordprocessingDrawing_ST_RelFromV_margin">margin</value> @@ -8013,9 +7995,13 @@ <list> <xs:documentation>Justification</xs:documentation> <choice> - <!-- Left Justification --> + <!-- Align To Leading Edge --> + <value>start</value> + <!-- Align To Trailing Edge --> + <value>end</value> + <!-- Left Justification (ecma) --> <value>left</value> - <!-- Right --> + <!-- Right (ecma) --> <value>right</value> <!-- Center (Equation) --> <value>center</value> @@ -8306,6 +8292,8 @@ <attribute name="val" tokenid="ooxml:CT_Style_val" action="setValue"/> </resource> <resource name="ST_Jc" resource="List" generated="yes"> + <value name="start" tokenid="ooxml:Value_math_ST_Jc_start">left</value> + <value name="end" tokenid="ooxml:Value_math_ST_Jc_end">right</value> <value name="left" tokenid="ooxml:Value_math_ST_Jc_left">left</value> <value name="right" tokenid="ooxml:Value_math_ST_Jc_right">right</value> <value name="center" tokenid="ooxml:Value_math_ST_Jc_center">center</value> @@ -13726,11 +13714,15 @@ <choice> <!-- No Tab Stop --> <value>clear</value> - <!-- Left Tab --> + <!-- Leading Tab --> + <value>start</value> + <!-- Left Tab (ecma) --> <value>left</value> <!-- Centered Tab --> <value>center</value> - <!-- Right Tab --> + <!-- Trailing Tab --> + <value>end</value> + <!-- Right Tab (ecma) --> <value>right</value> <!-- Decimal Tab --> <value>decimal</value> @@ -13841,6 +13833,30 @@ </define> <define name="CT_Ind"> <optional> + <attribute name="end"> + <ref name="ST_SignedTwipsMeasure"/> + <xs:documentation>Left Indentation</xs:documentation> + </attribute> + </optional> + <optional> + <attribute name="endChars"> + <ref name="ST_DecimalNumber"/> + <xs:documentation>Left Indentation in Character Units</xs:documentation> + </attribute> + </optional> + <optional> + <attribute name="start"> + <ref name="ST_SignedTwipsMeasure"/> + <xs:documentation>Left Indentation</xs:documentation> + </attribute> + </optional> + <optional> + <attribute name="startChars"> + <ref name="ST_DecimalNumber"/> + <xs:documentation>Left Indentation in Character Units</xs:documentation> + </attribute> + </optional> + <optional> <attribute name="left"> <ref name="ST_SignedTwipsMeasure"/> <xs:documentation>Left Indentation</xs:documentation> @@ -13893,11 +13909,15 @@ <list> <xs:documentation>Horizontal Alignment Type</xs:documentation> <choice> - <!-- Align Left --> + <!-- Align To Leading Edge --> + <value>start</value> + <!-- Align To Trailing Edge --> + <value>end</value> + <!-- Align Left (ecma) --> <value>left</value> <!-- Align Center --> <value>center</value> - <!-- Align Right --> + <!-- Align Right (ecma) --> <value>right</value> <!-- Justified --> <value>both</value> @@ -15253,7 +15273,7 @@ <define name="CT_FFDDList"> <optional> <element name="result"> - <ref name="CT_DecimalNumber"/> + <ref name="CT_String"/> </element> </optional> <optional> @@ -17475,6 +17495,11 @@ </element> </optional> <optional> + <element name="start"> + <ref name="CT_Border"/> + </element> + </optional> + <optional> <element name="left"> <ref name="CT_Border"/> </element> @@ -17485,6 +17510,11 @@ </element> </optional> <optional> + <element name="end"> + <ref name="CT_Border"/> + </element> + </optional> + <optional> <element name="right"> <ref name="CT_Border"/> </element> @@ -17517,6 +17547,11 @@ </element> </optional> <optional> + <element name="start"> + <ref name="CT_TblWidth"/> + </element> + </optional> + <optional> <element name="left"> <ref name="CT_TblWidth"/> </element> @@ -17531,6 +17566,11 @@ <ref name="CT_TblWidth"/> </element> </optional> + <optional> + <element name="end"> + <ref name="CT_TblWidth"/> + </element> + </optional> </define> <define name="ST_Merge"> <list> @@ -17861,6 +17901,11 @@ </element> </optional> <optional> + <element name="start"> + <ref name="CT_TblWidth"/> + </element> + </optional> + <optional> <element name="left"> <ref name="CT_TblWidth"/> </element> @@ -17875,6 +17920,11 @@ <ref name="CT_TblWidth"/> </element> </optional> + <optional> + <element name="end"> + <ref name="CT_TblWidth"/> + </element> + </optional> </define> <define name="CT_TblBorders"> <optional> @@ -17883,6 +17933,11 @@ </element> </optional> <optional> + <element name="start"> + <ref name="CT_Border"/> + </element> + </optional> + <optional> <element name="left"> <ref name="CT_Border"/> </element> @@ -17893,6 +17948,11 @@ </element> </optional> <optional> + <element name="end"> + <ref name="CT_Border"/> + </element> + </optional> + <optional> <element name="right"> <ref name="CT_Border"/> </element> @@ -18133,13 +18193,13 @@ </attribute> </optional> <attribute name="id"> - <text/> + <ref name="ST_DecimalNumber"/> <xs:documentation>Footnote/Endnote ID Reference</xs:documentation> </attribute> </define> <define name="CT_FtnEdnSepRef"> <attribute name="id"> - <text/> + <ref name="ST_DecimalNumber"/> <xs:documentation>Footnote/Endnote ID</xs:documentation> </attribute> </define> @@ -18154,7 +18214,7 @@ </attribute> </optional> <attribute name="id"> - <text/> + <ref name="ST_DecimalNumber"/> <xs:documentation>Footnote/Endnote ID</xs:documentation> </attribute> </define> @@ -20348,7 +20408,12 @@ </optional> <optional> <element name="charset"> - <ref name="CT_UcharHexNumber"/> + <ref name="CT_Charset"/> + </element> + </optional> + <optional> + <element name="characterSet"> + <ref name="CT_String"/> </element> </optional> <optional> @@ -20404,6 +20469,18 @@ </element> </zeroOrMore> </define> + <define name="CT_Charset"> + <optional> + <attribute name="val"> + <ref name="CT_UcharHexNumber"/> + </attribute> + </optional> + <optional> + <attribute name="characterSet"> + <ref name="ST_String"/> + </attribute> + </optional> + </define> <define name="CT_DivBdr"> <optional> <element name="top"> @@ -21565,8 +21642,10 @@ </resource> <resource name="ST_TabJc" resource="List"> <value tokenid="ooxml:Value_ST_TabJc_clear">clear</value> + <value tokenid="0">start</value> <value tokenid="0">left</value> <value tokenid="1">center</value> + <value tokenid="2">end</value> <value tokenid="2">right</value> <value tokenid="3">decimal</value> <value tokenid="4">bar</value> @@ -21601,19 +21680,26 @@ <attribute name="lineRule" tokenid="ooxml:CT_Spacing_lineRule"/> </resource> <resource name="CT_Ind" resource="Properties" tag="paragraph"> - <attribute name="left" tokenid="ooxml:CT_Ind_left"/> - <attribute name="leftChars" tokenid="ooxml:CT_Ind_leftChars"/> - <attribute name="right" tokenid="ooxml:CT_Ind_right"/> - <attribute name="rightChars" tokenid="ooxml:CT_Ind_rightChars"/> + <attribute name="end" tokenid="ooxml:CT_Ind_end"/> + <attribute name="endChars" tokenid="ooxml:CT_Ind_endChars"/> + <attribute name="start" tokenid="ooxml:CT_Ind_start"/> + <attribute name="startChars" tokenid="ooxml:CT_Ind_startChars"/> <attribute name="hanging" tokenid="ooxml:CT_Ind_hanging"/> <attribute name="hangingChars" tokenid="ooxml:CT_Ind_hangingChars"/> <attribute name="firstLine" tokenid="ooxml:CT_Ind_firstLine"/> <attribute name="firstLineChars" tokenid="ooxml:CT_Ind_firstLineChars"/> + <!-- ECMA 1st version --> + <attribute name="left" tokenid="ooxml:CT_Ind_left"/> + <attribute name="leftChars" tokenid="ooxml:CT_Ind_leftChars"/> + <attribute name="right" tokenid="ooxml:CT_Ind_right"/> + <attribute name="rightChars" tokenid="ooxml:CT_Ind_rightChars"/> </resource> <resource name="ST_Jc" resource="List"> <value tokenid="0">left</value> - <value tokenid="1">center</value> <value tokenid="2">right</value> + <value tokenid="0">start</value> + <value tokenid="1">center</value> + <value tokenid="2">end</value> <value tokenid="3">both</value> <value tokenid="ooxml:Value_ST_Jc_mediumKashida">mediumKashida</value> <value tokenid="ooxml:Value_ST_Jc_distribute">distribute</value> @@ -22619,6 +22705,17 @@ <attribute name="element" tokenid="ooxml:CT_SmartTagRun_element"/> </resource> <resource name="EG_PContent" resource="Properties" tag="content"> + <element name="sdtPr" tokenid="ooxml:CT_SdtPr"/> + <element name="sdtEndPr" tokenid="ooxml:CT_SdtEndPr"/> + <element name="sdtContent" tokenid="ooxml:CT_SdtContentRun"/> + </resource> + <resource name="CT_SdtBlock" resource="Properties"> + <element name="sdtPr" tokenid="ooxml:CT_SdtPr"/> + <element name="sdtEndPr" tokenid="ooxml:CT_SdtEndPr"/> + <element name="sdtContent" tokenid="ooxml:CT_SdtContentBlock"/> + </resource> + <resource name="CT_SdtContentBlock" resource="Properties"/> + <resource name="EG_PContent" resource="Properties" tag="content"> <element name="fldSimple" tokenid="ooxml:EG_PContent_fldSimple"/> <element name="hyperlink" tokenid="ooxml:EG_PContent_hyperlink"/> <element name="subDoc" tokenid="ooxml:EG_PContent_subDoc"/> @@ -22659,8 +22756,10 @@ <resource name="CT_TcBorders" resource="Properties" tag="table"> <kind name="table"/> <element name="top" tokenid="ooxml:CT_TcBorders_top"/> + <element name="start" tokenid="ooxml:CT_TcBorders_start"/> <element name="left" tokenid="ooxml:CT_TcBorders_left"/> <element name="bottom" tokenid="ooxml:CT_TcBorders_bottom"/> + <element name="end" tokenid="ooxml:CT_TcBorders_end"/> <element name="right" tokenid="ooxml:CT_TcBorders_right"/> <element name="insideH" tokenid="ooxml:CT_TcBorders_insideH"/> <element name="insideV" tokenid="ooxml:CT_TcBorders_insideV"/> @@ -22670,8 +22769,10 @@ <resource name="CT_TcMar" resource="Properties" tag="table"> <kind name="table"/> <element name="top" tokenid="ooxml:CT_TcMar_top"/> + <element name="start" tokenid="ooxml:CT_TcMar_start"/> <element name="left" tokenid="ooxml:CT_TcMar_left"/> <element name="bottom" tokenid="ooxml:CT_TcMar_bottom"/> + <element name="end" tokenid="ooxml:CT_TcMar_end"/> <element name="right" tokenid="ooxml:CT_TcMar_right"/> </resource> <resource name="ST_Merge" resource="List"> @@ -22760,15 +22861,19 @@ </resource> <resource name="CT_TblCellMar" resource="Properties" tag="table"> <element name="top" tokenid="ooxml:CT_TblCellMar_top"/> + <element name="start" tokenid="ooxml:CT_TblCellMar_start"/> <element name="left" tokenid="ooxml:CT_TblCellMar_left"/> <element name="bottom" tokenid="ooxml:CT_TblCellMar_bottom"/> + <element name="end" tokenid="ooxml:CT_TblCellMar_end"/> <element name="right" tokenid="ooxml:CT_TblCellMar_right"/> </resource> <resource name="CT_TblBorders" resource="Properties" tag="table"> <kind name="table"/> <element name="top" tokenid="ooxml:CT_TblBorders_top"/> + <element name="start" tokenid="ooxml:CT_TblBorders_start"/> <element name="left" tokenid="ooxml:CT_TblBorders_left"/> <element name="bottom" tokenid="ooxml:CT_TblBorders_bottom"/> + <element name="end" tokenid="ooxml:CT_TblBorders_end"/> <element name="right" tokenid="ooxml:CT_TblBorders_right"/> <element name="insideH" tokenid="ooxml:CT_TblBorders_insideH"/> <element name="insideV" tokenid="ooxml:CT_TblBorders_insideV"/> @@ -23285,6 +23390,10 @@ <attribute name="val" tokenid="ooxml:CT_Panose_val" action="setValue"/> <action name="start" action="setDefaultHexValue"/> </resource> + <resource name="CT_Charset" resource="Properties"> + <attribute name="val" tokenid="ooxml:CT_Charset_val"/> + <attribute name="characterSet" tokenid="ooxml:CT_Charset_characterSet"/> + </resource> <resource name="ST_FontFamily" resource="List"> <value tokenid="ooxml:Value_ST_FontFamily_decorative">decorative</value> <value tokenid="ooxml:Value_ST_FontFamily_modern">modern</value> @@ -23321,6 +23430,7 @@ <element name="altName" tokenid="ooxml:CT_Font_altName"/> <element name="panose1" tokenid="ooxml:CT_Font_panose1"/> <element name="charset" tokenid="ooxml:CT_Font_charset"/> + <element name="characterSet" tokenid="ooxml:CT_Font_characterSet"/> <element name="family" tokenid="ooxml:CT_Font_family"/> <element name="notTrueType" tokenid="ooxml:CT_Font_notTrueType"/> <element name="pitch" tokenid="ooxml:CT_Font_pitch"/> @@ -23350,7 +23460,7 @@ <action name="start" action="footnoteCont"/> <action name="start" action="endnoteSeparator"/> <action name="start" action="endnoteCont"/> ---> + --> <action name="end" action="endCharacterGroup"/> <action name="end" action="endParagraphGroup"/> <action name="end" action="endSectionGroup"/> diff --git a/writerfilter/source/ooxml/ooxmlLoggers.hxx b/writerfilter/source/ooxml/ooxmlLoggers.hxx index badaf0fca..f6340d5b0 100644 --- a/writerfilter/source/ooxml/ooxmlLoggers.hxx +++ b/writerfilter/source/ooxml/ooxmlLoggers.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,7 +29,7 @@ #ifndef INCLUDED_OOXML_LOGGERS_HXX #define INCLUDED_OOXML_LOGGERS_HXX -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 #include <resourcemodel/TagLogger.hxx> @@ -39,3 +40,5 @@ namespace writerfilter { } #endif #endif // INCLUDED_OOXML_LOGGERS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/rngtocxx b/writerfilter/source/ooxml/rngtocxx index 8b75d658f..d4c902cb1 100755 --- a/writerfilter/source/ooxml/rngtocxx +++ b/writerfilter/source/ooxml/rngtocxx @@ -28,5 +28,5 @@ xalan -xsl tokenmapinit.xsl -in model_processed.xml > TokenMapInit.cxx xalan -xsl valuesimpl.xsl -in model_processed.xml > OOXMLvalues.cxx xalan -xsl qnametostr.xsl -in model_processed.xml > qnametostr.tmp xalan -xsl resourceids.xsl -in model_processed.xml > ../../inc/ooxml/resourceids.hxx -xalan -xsl gperfattributes.xsl -in model_processed.xml | gperf -t -E -S1 -LC++ > gperfattributes.hxx -xalan -xsl gperfelements.xsl -in model_processed.xml | gperf -t -E -S1 -LC++ > gperfelements.hxx +xalan -xsl gperfattributes.xsl -in model_processed.xml | $GPERF -t -E -S1 -LC++ > gperfattributes.hxx +xalan -xsl gperfelements.xsl -in model_processed.xml | $GPERF -t -E -S1 -LC++ > gperfelements.hxx |