summaryrefslogtreecommitdiff
path: root/writerfilter/source/resourcemodel
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/resourcemodel')
-rw-r--r--writerfilter/source/resourcemodel/Protocol.cxx218
-rw-r--r--writerfilter/source/resourcemodel/ResourceModelHelper.cxx51
-rw-r--r--writerfilter/source/resourcemodel/TagLogger.cxx321
-rw-r--r--writerfilter/source/resourcemodel/WW8Analyzer.cxx219
-rw-r--r--writerfilter/source/resourcemodel/WW8Analyzer.hxx102
-rw-r--r--writerfilter/source/resourcemodel/analyzerfooter4
-rw-r--r--writerfilter/source/resourcemodel/analyzerheader36
-rwxr-xr-xwriterfilter/source/resourcemodel/genqnametostr35
-rw-r--r--writerfilter/source/resourcemodel/makefile.mk202
-rw-r--r--writerfilter/source/resourcemodel/namespace_preprocess.pl65
-rw-r--r--writerfilter/source/resourcemodel/qnametostrfooter24
-rw-r--r--writerfilter/source/resourcemodel/qnametostrheader57
-rw-r--r--writerfilter/source/resourcemodel/resourcemodel.cxx566
-rw-r--r--writerfilter/source/resourcemodel/resourcemodel.hxx113
-rwxr-xr-xwriterfilter/source/resourcemodel/setdebugflags3
-rw-r--r--writerfilter/source/resourcemodel/sprmcodetostrfooter1
-rw-r--r--writerfilter/source/resourcemodel/sprmcodetostrheader50
-rw-r--r--writerfilter/source/resourcemodel/util.cxx430
18 files changed, 2497 insertions, 0 deletions
diff --git a/writerfilter/source/resourcemodel/Protocol.cxx b/writerfilter/source/resourcemodel/Protocol.cxx
new file mode 100644
index 000000000000..0d98b509143a
--- /dev/null
+++ b/writerfilter/source/resourcemodel/Protocol.cxx
@@ -0,0 +1,218 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#include <rtl/ustrbuf.hxx>
+#include <resourcemodel/Protocol.hxx>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <resourcemodel/QNameToString.hxx>
+namespace writerfilter
+{
+
+/*
+ StreamProtocol
+*/
+
+StreamProtocol::StreamProtocol(Stream * pStream,
+ TagLogger::Pointer_t pTagLogger)
+ : m_pStream(pStream), m_pTagLogger(pTagLogger)
+{
+}
+
+StreamProtocol::~StreamProtocol()
+{
+}
+
+void StreamProtocol::startSectionGroup()
+{
+ m_pTagLogger->element("protocol-startSectionGroup");
+ m_pStream->startSectionGroup();
+}
+
+void StreamProtocol::endSectionGroup()
+{
+ m_pTagLogger->element("protocol-endSectionGroup");
+ m_pStream->endSectionGroup();
+}
+
+void StreamProtocol::startParagraphGroup()
+{
+ m_pTagLogger->element("protocol-startParagraphGroup");
+ m_pStream->startParagraphGroup();
+}
+
+void StreamProtocol::endParagraphGroup()
+{
+ m_pTagLogger->element("protocol-endParagraphGroup");
+ m_pStream->endParagraphGroup();
+}
+
+void StreamProtocol::startCharacterGroup()
+{
+ m_pTagLogger->element("protocol-startCharacterGroup");
+ m_pStream->startCharacterGroup();
+}
+
+void StreamProtocol::endCharacterGroup()
+{
+ m_pTagLogger->element("protocol-endCharacterGroup");
+ m_pStream->endCharacterGroup();
+}
+
+void StreamProtocol::text(const sal_uInt8 * data, size_t len)
+{
+ ::rtl::OUString sText((const sal_Char*) data, len,
+ RTL_TEXTENCODING_MS_1252);
+ m_pTagLogger->startElement("protocol-text");
+ m_pTagLogger->chars(sText);
+ m_pTagLogger->endElement();
+
+ m_pStream->text(data, len);
+}
+
+void StreamProtocol::utext(const sal_uInt8 * data, size_t len)
+{
+ ::rtl::OUString sText;
+ ::rtl::OUStringBuffer aBuffer = ::rtl::OUStringBuffer(len);
+ aBuffer.append( (const sal_Unicode *) data, len);
+ sText = aBuffer.makeStringAndClear();
+
+ m_pTagLogger->startElement("protocol-utext");
+ m_pTagLogger->chars(sText);
+ m_pTagLogger->endElement();
+
+ m_pStream->utext(data, len);
+}
+
+void StreamProtocol::props(writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ m_pTagLogger->startElement("protocol-props");
+ m_pStream->props(ref);
+ m_pTagLogger->endElement();
+}
+
+void StreamProtocol::table(Id name,
+ writerfilter::Reference<Table>::Pointer_t ref)
+{
+ m_pTagLogger->startElement("protocol-table");
+ m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
+ m_pStream->table(name, ref);
+ m_pTagLogger->endElement();
+}
+
+void StreamProtocol::substream(Id name,
+ writerfilter::Reference<Stream>::Pointer_t ref)
+{
+ m_pTagLogger->startElement("protocol-substream");
+ m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
+
+ m_pStream->substream(name, ref);
+ m_pTagLogger->endElement();
+}
+
+void StreamProtocol::info(const string & rInfo)
+{
+ m_pStream->info(rInfo);
+}
+
+void StreamProtocol::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
+{
+ m_pTagLogger->element("protocol-startShape");
+
+ m_pStream->startShape(xShape);
+}
+
+void StreamProtocol::endShape()
+{
+ m_pTagLogger->element("protocol-endShape");
+
+ m_pStream->endShape();
+}
+
+/*
+ PropertiesProtocol
+*/
+
+PropertiesProtocol::PropertiesProtocol(Properties * pProperties,
+ TagLogger::Pointer_t pTagLogger)
+: m_pProperties(pProperties), m_pTagLogger(pTagLogger)
+{
+}
+
+PropertiesProtocol::~PropertiesProtocol()
+{
+}
+
+void PropertiesProtocol::attribute(Id name, Value & val)
+{
+ m_pTagLogger->startElement("protocol-attribute");
+ m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
+ m_pTagLogger->attribute("value", val.toString());
+ m_pProperties->attribute(name, val);
+ m_pTagLogger->endElement();
+}
+
+void PropertiesProtocol::sprm(Sprm & _sprm)
+{
+ m_pTagLogger->startElement("protocol-sprm");
+ static char sBuffer[256];
+ snprintf(sBuffer, sizeof(sBuffer), "%04" SAL_PRIxUINT32, _sprm.getId());
+ m_pTagLogger->attribute("id", sBuffer);
+ m_pTagLogger->attribute("name", _sprm.getName());
+ m_pTagLogger->chars(_sprm.toString());
+ m_pProperties->sprm(_sprm);
+ m_pTagLogger->endElement();
+}
+
+/*
+ TableProtocol
+ */
+
+TableProtocol::TableProtocol(Table * pTable, TagLogger::Pointer_t pTagLogger)
+: m_pTable(pTable), m_pTagLogger(pTagLogger)
+{
+}
+
+TableProtocol::~TableProtocol()
+{
+}
+
+void TableProtocol::entry(int pos,
+ writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ m_pTagLogger->startElement("protocol-entry");
+ m_pTagLogger->attribute("pos", pos);
+ m_pTable->entry(pos, ref);
+ m_pTagLogger->endElement();
+}
+
+}
+#endif // DEBUG
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/ResourceModelHelper.cxx b/writerfilter/source/resourcemodel/ResourceModelHelper.cxx
new file mode 100644
index 000000000000..e626de5c3c43
--- /dev/null
+++ b/writerfilter/source/resourcemodel/ResourceModelHelper.cxx
@@ -0,0 +1,51 @@
+/* -*- 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 "resourcemodel/ResourceModelHelper.hxx"
+
+namespace writerfilter {
+namespace resourcemodel {
+
+void resolveSprmProps(Properties & rHandler, Sprm & rSprm)
+{
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if( pProperties.get())
+ pProperties->resolve(rHandler);
+}
+
+void resolveAttributeProperties(Properties & rHandler, Value & val)
+{
+ writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties();
+ if( pProperties.get())
+ pProperties->resolve(rHandler);
+}
+
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/TagLogger.cxx b/writerfilter/source/resourcemodel/TagLogger.cxx
new file mode 100644
index 000000000000..d6ff3019012a
--- /dev/null
+++ b/writerfilter/source/resourcemodel/TagLogger.cxx
@@ -0,0 +1,321 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+#if OSL_DEBUG_LEVEL > 1
+#include <libxml/xmlstring.h>
+#include <string.h>
+#include <resourcemodel/TagLogger.hxx>
+#include <resourcemodel/util.hxx>
+#include <resourcemodel/QNameToString.hxx>
+
+namespace writerfilter
+{
+ struct eqstr
+ {
+ bool operator()(const char* s1, const char* s2) const
+ {
+ return strcmp(s1, s2) == 0;
+ }
+ };
+
+ typedef hash_map<const char *, TagLogger::Pointer_t, hash<const char *>, eqstr> TagLoggerHashMap_t;
+ static TagLoggerHashMap_t * tagLoggers = NULL;
+
+ TagLogger::TagLogger(const char* name)
+ : pWriter( NULL ), pName( name )
+ {
+ }
+
+ TagLogger::~TagLogger()
+ {
+ pWriter = NULL;
+ pName = NULL;
+ }
+
+ void TagLogger::setFileName( const string & filename )
+ {
+ if ( pWriter )
+ endDocument();
+
+ string fileName;
+ char * temp = getenv("TAGLOGGERTMP");
+
+ if (temp != NULL)
+ fileName += temp;
+ else
+ fileName += "/tmp";
+
+ string sPrefix = filename;
+ size_t nLastSlash = sPrefix.find_last_of('/');
+ size_t nLastBackslash = sPrefix.find_last_of('\\');
+ size_t nCutPos = nLastSlash;
+ if (nLastBackslash < nCutPos)
+ nCutPos = nLastBackslash;
+ if (nCutPos < sPrefix.size())
+ sPrefix = sPrefix.substr(nCutPos + 1);
+
+ fileName += "/";
+ fileName += sPrefix;
+ fileName += ".";
+ fileName += pName;
+ fileName += ".xml";
+
+ pWriter = xmlNewTextWriterFilename( fileName.c_str(), 0 );
+ xmlTextWriterSetIndent( pWriter, 4 );
+ }
+
+ TagLogger::Pointer_t TagLogger::getInstance(const char * name)
+ {
+ if (tagLoggers == NULL)
+ tagLoggers = new TagLoggerHashMap_t();
+
+ TagLoggerHashMap_t::iterator aIt = tagLoggers->end();
+
+ if (! tagLoggers->empty())
+ aIt = tagLoggers->find(name);
+
+ if (aIt == tagLoggers->end())
+ {
+ TagLogger::Pointer_t pTagLogger(new TagLogger(name));
+ pair<const char *, TagLogger::Pointer_t> entry(name, pTagLogger);
+ aIt = tagLoggers->insert(entry).first;
+ }
+
+ return aIt->second;
+ }
+
+ void TagLogger::startDocument()
+ {
+ xmlTextWriterStartDocument( pWriter, NULL, NULL, NULL );
+ xmlTextWriterStartElement( pWriter, BAD_CAST( "root" ) );
+ }
+
+ void TagLogger::element(const string & name)
+ {
+ startElement(name);
+ endElement();
+ }
+
+ void TagLogger::startElement(const string & name)
+ {
+ xmlChar* xmlName = xmlCharStrdup( name.c_str() );
+ xmlTextWriterStartElement( pWriter, xmlName );
+ xmlFree( xmlName );
+ }
+
+ void TagLogger::attribute(const string & name, const string & value)
+ {
+ xmlChar* xmlName = xmlCharStrdup( name.c_str() );
+ xmlChar* xmlValue = xmlCharStrdup( value.c_str() );
+ xmlTextWriterWriteAttribute( pWriter, xmlName, xmlValue );
+
+ xmlFree( xmlValue );
+ xmlFree( xmlName );
+ }
+
+ void TagLogger::attribute(const string & name, const ::rtl::OUString & value)
+ {
+ attribute( name, OUStringToOString( value, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+
+ void TagLogger::attribute(const string & name, sal_uInt32 value)
+ {
+ xmlChar* xmlName = xmlCharStrdup( name.c_str() );
+ xmlTextWriterWriteFormatAttribute( pWriter, xmlName,
+ "%" SAL_PRIuUINT32, value );
+ xmlFree( xmlName );
+ }
+
+ void TagLogger::attribute(const string & name, const uno::Any aAny)
+ {
+ string aTmpStrInt;
+ string aTmpStrFloat;
+ string aTmpStrString;
+
+ sal_Int32 nInt = 0;
+ float nFloat = 0.0;
+ ::rtl::OUString aStr;
+
+ xmlChar* xmlName = xmlCharStrdup( name.c_str() );
+ if ( aAny >>= nInt )
+ {
+ xmlTextWriterWriteFormatAttribute( pWriter, xmlName,
+ "%" SAL_PRIdINT32, nInt );
+ }
+ else if ( aAny >>= nFloat )
+ {
+ xmlTextWriterWriteFormatAttribute( pWriter, xmlName,
+ "%f", nFloat );
+ }
+ else if ( aAny >>= aStr )
+ {
+ attribute( name, aStr );
+ }
+ xmlFree( xmlName );
+ }
+
+ void TagLogger::chars(const string & rChars)
+ {
+ xmlChar* xmlChars = xmlCharStrdup( rChars.c_str() );
+ xmlTextWriterWriteString( pWriter, xmlChars );
+ xmlFree( xmlChars );
+ }
+
+ void TagLogger::chars(const ::rtl::OUString & rChars)
+ {
+ chars(OUStringToOString(rChars, RTL_TEXTENCODING_ASCII_US).getStr());
+ }
+
+ void TagLogger::endElement()
+ {
+ xmlTextWriterEndElement( pWriter );
+ }
+
+ void TagLogger::endDocument()
+ {
+ xmlTextWriterEndDocument( pWriter );
+ xmlFreeTextWriter( pWriter );
+ pWriter = NULL;
+ }
+
+
+ class PropertySetDumpHandler : public Properties
+ {
+ IdToString::Pointer_t mpIdToString;
+ TagLogger::Pointer_t m_pLogger;
+
+ public:
+ PropertySetDumpHandler(TagLogger::Pointer_t pLogger,
+ IdToString::Pointer_t pIdToString);
+ virtual ~PropertySetDumpHandler();
+
+ void resolve(writerfilter::Reference<Properties>::Pointer_t props);
+
+ virtual void attribute(Id name, Value & val);
+ virtual void sprm(Sprm & sprm);
+ };
+
+ PropertySetDumpHandler::PropertySetDumpHandler(TagLogger::Pointer_t pLogger,
+ IdToString::Pointer_t pIdToString) :
+ mpIdToString(pIdToString)
+ {
+ m_pLogger = pLogger;
+ }
+
+ PropertySetDumpHandler::~PropertySetDumpHandler()
+ {
+ }
+
+ void PropertySetDumpHandler::resolve(
+ writerfilter::Reference<Properties>::Pointer_t pProps)
+ {
+ if (pProps.get() != NULL)
+ pProps->resolve( *this );
+ }
+
+ void PropertySetDumpHandler::attribute(Id name, Value & val)
+ {
+ m_pLogger->startElement( "attribute" );
+
+ m_pLogger->attribute("name", (*QNameToString::Instance())(name));
+ m_pLogger->attribute("value", val.toString());
+
+ resolve(val.getProperties());
+
+ m_pLogger->endElement();
+ }
+
+ void PropertySetDumpHandler::sprm(Sprm & rSprm)
+ {
+ m_pLogger->startElement( "sprm" );
+
+ string sName;
+
+ if (mpIdToString != IdToString::Pointer_t())
+ sName = mpIdToString->toString(rSprm.getId());
+
+ m_pLogger->attribute( "name", sName );
+
+ m_pLogger->attribute( "id", rSprm.getId() );
+ m_pLogger->attribute( "value", rSprm.getValue()->toString() );
+
+ resolve( rSprm.getProps() );
+
+ m_pLogger->endElement();
+ }
+
+ void TagLogger::propertySet(writerfilter::Reference<Properties>::Pointer_t props,
+ IdToString::Pointer_t pIdToString)
+ {
+ startElement( "propertySet" );
+
+ TagLogger::Pointer_t pLogger( this );
+ PropertySetDumpHandler handler( pLogger, pIdToString );
+ handler.resolve( props );
+
+ endElement( );
+ }
+
+ void TagLogger::unoPropertySet(uno::Reference<beans::XPropertySet> rPropSet)
+ {
+ uno::Reference<beans::XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
+ uno::Sequence<beans::Property> aProps(xPropSetInfo->getProperties());
+
+ startElement( "unoPropertySet" );
+
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ startElement( "property" );
+ ::rtl::OUString sName(aProps[i].Name);
+
+ attribute( "name", sName );
+ try
+ {
+ attribute( "value", rPropSet->getPropertyValue( sName ) );
+ }
+ catch (uno::Exception aException)
+ {
+ startElement( "exception" );
+
+ chars("getPropertyValue(\"");
+ chars(sName);
+ chars("\")");
+
+ endElement( );
+ }
+
+ endElement( );
+ }
+
+ endElement( );
+ }
+
+}
+#endif // DEBUG
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/WW8Analyzer.cxx b/writerfilter/source/resourcemodel/WW8Analyzer.cxx
new file mode 100644
index 000000000000..126d46a96d4b
--- /dev/null
+++ b/writerfilter/source/resourcemodel/WW8Analyzer.cxx
@@ -0,0 +1,219 @@
+/* -*- 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 <WW8Analyzer.hxx>
+#include <doctok/resourceids.hxx>
+#include <resourcemodel/QNameToString.hxx>
+
+namespace writerfilter
+{
+bool eqSalUInt32::operator () (sal_uInt32 n1, sal_uInt32 n2) const
+{
+ return n1 == n2;
+}
+
+WW8Analyzer::WW8Analyzer()
+{
+}
+
+WW8Analyzer::~WW8Analyzer()
+{
+ dumpStats(cout);
+}
+
+void WW8Analyzer::attribute(Id name, Value & val)
+{
+ string aAttrName = (*QNameToString::Instance())(name);
+ string aStr;
+
+ if (aAttrName.length() > 6)
+ aStr = aAttrName.substr(4, 2);
+ else
+ logger("DEBUG", "WW8Analyzer::attribute:" + aAttrName);
+
+ bool bAdd = false;
+ if (aStr.compare("LC") == 0 || aStr.compare("FC") == 0)
+ {
+ if (val.getInt() != 0)
+ {
+ bAdd = true;
+ }
+ }
+ else
+ {
+ bAdd = true;
+ }
+
+ if (bAdd)
+ {
+ if (mAttributeMap.count(name) > 0)
+ {
+ sal_uInt32 nCount = mAttributeMap[name] + 1;
+ mAttributeMap[name] = nCount;
+ }
+ else
+ mAttributeMap[name] = 1;
+
+ mAttributeIdSet.insert(name);
+ }
+}
+
+void WW8Analyzer::sprm(Sprm & sprm_)
+{
+ if (mSprmMap.count(sprm_.getId()) > 0)
+ {
+ sal_uInt32 nCount = mSprmMap[sprm_.getId()] + 1;
+ mSprmMap[sprm_.getId()] = nCount;
+ }
+ else
+ mSprmMap[sprm_.getId()] = 1;
+
+ mSprmIdSet.insert(sprm_.getId());
+
+ writerfilter::Reference<Properties>::Pointer_t pProps = sprm_.getProps();
+
+ if (pProps.get() != NULL)
+ {
+ pProps->resolve(*this);
+ }
+
+}
+
+void WW8Analyzer::entry(int /*pos*/, ::writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ ref->resolve(*this);
+}
+
+void WW8Analyzer::data(const sal_uInt8 * /*buf*/, size_t /*len*/,
+ ::writerfilter::Reference<Properties>::Pointer_t /*ref*/)
+{
+}
+
+void WW8Analyzer::startSectionGroup()
+{
+}
+
+void WW8Analyzer::endSectionGroup()
+{
+}
+
+void WW8Analyzer::startParagraphGroup()
+{
+}
+
+void WW8Analyzer::endParagraphGroup()
+{
+}
+
+void WW8Analyzer::startCharacterGroup()
+{
+}
+
+void WW8Analyzer::endCharacterGroup()
+{
+}
+
+void WW8Analyzer::text(const sal_uInt8 * /*data*/, size_t /*len*/)
+{
+}
+
+void WW8Analyzer::utext(const sal_uInt8 * /*data*/, size_t /*len*/)
+{
+}
+
+void WW8Analyzer::props(writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ ref->resolve(*this);
+}
+
+void WW8Analyzer::table(Id /*id*/, writerfilter::Reference<Table>::Pointer_t ref)
+{
+ ref->resolve(*this);
+}
+
+void WW8Analyzer::substream(Id /*name*/,
+ writerfilter::Reference<Stream>::Pointer_t ref)
+{
+ ref->resolve(*this);
+}
+
+void WW8Analyzer::info(const string & /*info*/)
+{
+}
+
+void WW8Analyzer::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
+{
+}
+
+void WW8Analyzer::endShape( )
+{
+}
+
+void WW8Analyzer::dumpStats(ostream & o) const
+{
+ {
+ for (IdSet::const_iterator aIt = mSprmIdSet.begin();
+ aIt != mSprmIdSet.end(); ++aIt)
+ {
+ sal_uInt32 aId = *aIt;
+
+ o << "<sprm>" << endl
+ << "<id>" << hex << aId << "</id>" << endl
+ << "<name>" << (*SprmIdToString::Instance())(aId)
+ << "</name>" << endl
+ << "<count>" << dec << mSprmMap[aId] << "</count>"
+ << endl
+ << "</sprm>" << endl;
+ }
+ }
+
+ {
+ for (IdSet::const_iterator aIt = mAttributeIdSet.begin();
+ aIt != mAttributeIdSet.end(); ++aIt)
+ {
+ sal_uInt32 aId = *aIt;
+
+ o << "<attribute>" << endl
+ << "<name>" << (*QNameToString::Instance())(aId) << "</name>"
+ << endl
+ << "<count>" << dec << mAttributeMap[aId] << "</count>"
+ << endl
+ << "</attribute>" << endl;
+ }
+ }
+
+}
+
+Stream::Pointer_t createAnalyzer()
+{
+ return Stream::Pointer_t(new WW8Analyzer());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/WW8Analyzer.hxx b/writerfilter/source/resourcemodel/WW8Analyzer.hxx
new file mode 100644
index 000000000000..f2dc392b4ec8
--- /dev/null
+++ b/writerfilter/source/resourcemodel/WW8Analyzer.hxx
@@ -0,0 +1,102 @@
+/* -*- 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_WW8_ANALYZER_HXX
+#define INCLUDED_WW8_ANALYZER_HXX
+
+#include <resourcemodel/WW8ResourceModel.hxx>
+
+#include <hash_set>
+#include <map>
+
+namespace writerfilter
+{
+using namespace std;
+
+struct eqSalUInt32
+{
+ bool operator () (sal_uInt32 n1, sal_uInt32 n2) const;
+};
+
+class WW8Analyzer : public Properties, public Table,
+ public BinaryObj, public Stream
+{
+ typedef map<sal_uInt32, sal_uInt32> SprmMap;
+
+ typedef hash_set<sal_uInt32, hash<sal_uInt32>, eqSalUInt32> IdSet;
+ typedef map<Id, sal_uInt32> AttributeMap;
+
+ mutable SprmMap mSprmMap;
+ IdSet mSprmIdSet;
+ mutable AttributeMap mAttributeMap;
+ IdSet mAttributeIdSet;
+
+public:
+ WW8Analyzer();
+ virtual ~WW8Analyzer();
+
+ // Properties
+
+ virtual void attribute(Id Name, Value & val);
+ virtual void sprm(Sprm & sprm);
+
+ // Table
+
+ virtual void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
+
+ // BinaryObj
+
+ virtual void data(const sal_uInt8* buf, size_t len,
+ writerfilter::Reference<Properties>::Pointer_t ref);
+
+ // Stream
+
+ virtual void startSectionGroup();
+ virtual void endSectionGroup();
+ virtual void startParagraphGroup();
+ virtual void endParagraphGroup();
+ virtual void startCharacterGroup();
+ virtual void endCharacterGroup();
+ virtual void text(const sal_uInt8 * data, size_t len);
+ virtual void utext(const sal_uInt8 * data, size_t len);
+ virtual void props(writerfilter::Reference<Properties>::Pointer_t ref);
+ virtual void table(Id name,
+ writerfilter::Reference<Table>::Pointer_t ref);
+ virtual void substream(Id name,
+ writerfilter::Reference<Stream>::Pointer_t ref);
+ virtual void info(const string & info);
+ virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ virtual void endShape( );
+
+ void dumpStats(ostream & o) const;
+};
+}
+
+#endif // INCLUDED_WW8_ANALYZER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/analyzerfooter b/writerfilter/source/resourcemodel/analyzerfooter
new file mode 100644
index 000000000000..b24a23641b2f
--- /dev/null
+++ b/writerfilter/source/resourcemodel/analyzerfooter
@@ -0,0 +1,4 @@
+ out << "</ids>" << endl;
+}
+
+}
diff --git a/writerfilter/source/resourcemodel/analyzerheader b/writerfilter/source/resourcemodel/analyzerheader
new file mode 100644
index 000000000000..1b4e2674ffab
--- /dev/null
+++ b/writerfilter/source/resourcemodel/analyzerheader
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * 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 <doctok/resourceids.hxx>
+#include <ooxml/resourceids.hxx>
+#include <resourcemodel/QNameToString.hxx>
+
+namespace writerfilter
+{
+void analyzerIds(::std::iostream & out)
+{
+ out << "<ids>" << endl;
diff --git a/writerfilter/source/resourcemodel/genqnametostr b/writerfilter/source/resourcemodel/genqnametostr
new file mode 100755
index 000000000000..12bad07b9b85
--- /dev/null
+++ b/writerfilter/source/resourcemodel/genqnametostr
@@ -0,0 +1,35 @@
+#!/bin/tcsh
+#************************************************************************
+#
+# 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.
+#
+# ***********************************************************************/
+
+cat qnametostrheader > qnametostr.cxx
+cat ../doctok/qnametostr.tmp >> qnametostr.cxx
+cat ../ooxml/qnametostr.tmp >> qnametostr.cxx
+cat qnametostrfooter >> qnametostr.cxx
+cat sprmcodetostrheader > sprmcodetostr.cxx
+cat ../doctok/sprmcodetostr.tmp >> sprmcodetostr.cxx
+echo "}" >> sprmcodetostr.cxx
diff --git a/writerfilter/source/resourcemodel/makefile.mk b/writerfilter/source/resourcemodel/makefile.mk
new file mode 100644
index 000000000000..c1eccd0368a7
--- /dev/null
+++ b/writerfilter/source/resourcemodel/makefile.mk
@@ -0,0 +1,202 @@
+#************************************************************************
+#
+# 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.
+#
+# ***********************************************************************/
+
+PRJ=..$/..
+PRJNAME=writerfilter
+TARGET=resourcemodel
+#LIBTARGET=NO
+#USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/writerfilter.mk
+
+#CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+#CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-DWRITERFILTER_DLLIMPLEMENTATION
+
+
+# --- Files --------------------------------------------------------
+
+# work around gcc taking hours and/or OOM'ing on this file
+NOOPTFILES= \
+ $(SLO)$/qnametostr.obj
+
+SLOFILES= \
+ $(SLO)$/qnametostr.obj \
+ $(SLO)$/sprmcodetostr.obj \
+ $(SLO)$/resourcemodel.obj \
+ $(SLO)$/util.obj \
+ $(SLO)$/TagLogger.obj \
+ $(SLO)$/ResourceModelHelper.obj \
+ $(SLO)$/WW8Analyzer.obj \
+ $(SLO)$/Protocol.obj
+
+SHL1TARGET=$(TARGET)
+
+.IF "$(GUI)"=="UNX" || "$(GUI)"=="MAC"
+RTFTOKLIB=-lrtftok
+DOCTOKLIB=-ldoctok
+OOXMLLIB=-looxml
+.ELIF "$(GUI)"=="WNT"
+RTFTOKLIB=$(LB)$/irtftok.lib
+DOCTOKLIB=$(LB)$/idoctok.lib
+OOXMLLIB=$(LB)$/iooxml.lib
+.ENDIF
+
+SHL1STDLIBS=$(SALLIB)\
+ $(CPPULIB)\
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBG_LEVEL)">="2"
+SHL1STDLIBS+= $(LIBXML2LIB)
+.ENDIF
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1USE_EXPORTS=name
+
+SHL1OBJS=$(SLOFILES)
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEFLIB1NAME=$(TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RESOURCEMODELCXXOUTDIR=$(MISC)
+DOCTOKHXXOUTDIR=$(INCCOM)$/doctok
+OOXMLHXXOUTDIR=$(INCCOM)$/ooxml
+
+DOCTOKHXXOUTDIRCREATED=$(DOCTOKHXXOUTDIR)$/created
+OOXMLHXXOUTDIRCREATED=$(OOXMLHXXOUTDIR)$/created
+
+OOXMLMODEL=..$/ooxml$/model.xml
+OOXMLPREPROCESSXSL=..$/ooxml$/modelpreprocess.xsl
+OOXMLPREPROCESSXSLCOPIED=$(MISC)$/modelpreprocess.xsl
+OOXMLQNAMETOSTRXSL=..$/ooxml$/qnametostr.xsl
+OOXMLANALYZERXSL=..$/ooxml$/analyzer.xsl
+OOXMLRESOURCEIDSXSL=..$/ooxml$/resourceids.xsl
+OOXMLFACTORYTOOLSXSL=..$/ooxml$/factorytools.xsl
+DOCTOKMODEL=..$/doctok$/resources.xmi
+DOCTOKQNAMETOSTRXSL=..$/doctok$/qnametostr.xsl
+DOCTOKANALYZERXSL=..$/doctok$/analyzer.xsl
+DOCTOKSPRMCODETOSTRXSL=..$/doctok$/sprmcodetostr.xsl
+DOCTOKRESOURCEIDSXSL=..$/doctok$/resourceids.xsl
+DOCTOKSPRMIDSXSL=..$/doctok$/sprmids.xsl
+DOCTOKRESOURCETOOLS=..$/doctok$/resourcetools.xsl
+
+NSPROCESS=namespace_preprocess.pl
+
+MODELPROCESSED=$(MISC)$/model_preprocessed.xml
+
+QNAMETOSTRCXX=$(RESOURCEMODELCXXOUTDIR)$/qnametostr.cxx
+OOXMLQNAMETOSTRTMP=$(RESOURCEMODELCXXOUTDIR)$/OOXMLqnameToStr.tmp
+DOCTOKQNAMETOSTRTMP=$(RESOURCEMODELCXXOUTDIR)$/DOCTOKqnameToStr.tmp
+SPRMCODETOSTRCXX=$(RESOURCEMODELCXXOUTDIR)$/sprmcodetostr.cxx
+SPRMCODETOSTRTMP=$(RESOURCEMODELCXXOUTDIR)$/sprmcodetostr.tmp
+DOCTOKRESOURCEIDSHXX=$(DOCTOKHXXOUTDIR)$/resourceids.hxx
+SPRMIDSHXX=$(DOCTOKHXXOUTDIR)$/sprmids.hxx
+OOXMLRESOURCEIDSHXX=$(OOXMLHXXOUTDIR)$/resourceids.hxx
+
+NSXSL=$(MISC)$/namespacesmap.xsl
+NAMESPACESTXT=$(SOLARVER)$/$(INPATH)$/inc$(UPDMINOREXT)$/oox$/namespaces.txt
+
+GENERATEDHEADERS=$(DOCTOKRESOURCEIDSHXX) $(OOXMLRESOURCEIDSHXX) $(SPRMIDSHXX)
+GENERATEDFILES= \
+ $(GENERATEDHEADERS) \
+ $(QNAMETOSTRCXX) \
+ $(SPRMCODETOSTRCXX) \
+ $(MODELPROCESSED) \
+ $(OOXMLQNAMETOSTRTMP) \
+ $(DOCTOKQNAMETOSTRTMP) \
+ $(SPRMCODETOSTRTMP)
+
+$(OOXMLQNAMETOSTRTMP): $(OOXMLQNAMETOSTRXSL) $(MODELPROCESSED)
+ @echo "Making: " $(@:f)
+ $(XSLTPROC) $(OOXMLQNAMETOSTRXSL:s!\!/!) $(MODELPROCESSED) > $@
+
+$(DOCTOKQNAMETOSTRTMP): $(DOCTOKQNAMETOSTRXSL) $(DOCTOKMODEL)
+ @echo "Making: " $(@:f)
+ $(XSLTPROC) $(DOCTOKQNAMETOSTRXSL:s!\!/!) $(DOCTOKMODEL) > $@
+
+$(QNAMETOSTRCXX): $(OOXMLQNAMETOSTRTMP) $(DOCTOKQNAMETOSTRTMP) qnametostrheader qnametostrfooter $(OOXMLFACTORYTOOLSXSL) $(DOCTOKRESOURCETOOLS)
+ @$(TYPE) qnametostrheader $(OOXMLQNAMETOSTRTMP) $(DOCTOKQNAMETOSTRTMP) qnametostrfooter > $@
+
+$(SPRMCODETOSTRTMP): $(DOCTOKSPRMCODETOSTRXSL) $(DOCTOKMODEL)
+ @echo "Making: " $(@:f)
+ $(XSLTPROC) $(DOCTOKSPRMCODETOSTRXSL:s!\!/!) $(DOCTOKMODEL) > $@
+
+$(SPRMCODETOSTRCXX): sprmcodetostrheader $(SPRMCODETOSTRTMP) sprmcodetostrfooter
+ @$(TYPE) $< > $@
+
+$(SLO)$/sprmcodetostr.obj: $(SPRMCODETOSTRCXX)
+$(SLO)$/qnametostr.obj: $(QNAMETOSTRCXX)
+
+$(SLOFILES): $(GENERATEDHEADERS)
+
+$(DOCTOKHXXOUTDIRCREATED):
+ @$(MKDIRHIER) $(DOCTOKHXXOUTDIR)
+ @$(TOUCH) $@
+
+$(DOCTOKRESOURCEIDSHXX): $(DOCTOKHXXOUTDIRCREATED) $(DOCTOKRESOURCETOOLS) $(DOCTOKRESOURCEIDSXSL) $(DOCTOKMODEL)
+ @echo "Making: " $(@:f)
+ $(COMMAND_ECHO)$(XSLTPROC) $(DOCTOKRESOURCEIDSXSL:s!\!/!) $(DOCTOKMODEL) > $@
+
+$(OOXMLHXXOUTDIRCREATED):
+ @$(MKDIRHIER) $(OOXMLHXXOUTDIR)
+ @$(TOUCH) $@
+
+$(OOXMLPREPROCESSXSLCOPIED): $(OOXMLPREPROCESSXSL)
+ @$(COPY) $(OOXMLPREPROCESSXSL) $@
+
+$(NSXSL) : $(OOXMLMODEL) $(NAMESPACESTXT) $(NSPROCESS)
+ @$(PERL) $(NSPROCESS) $(NAMESPACESTXT) > $@
+
+$(MODELPROCESSED): $(NSXSL) $(OOXMLPREPROCESSXSLCOPIED) $(OOXMLMODEL)
+ @echo "Making: " $(@:f)
+ $(COMMAND_ECHO)$(XSLTPROC) $(NSXSL) $(OOXMLMODEL) > $@
+
+$(OOXMLRESOURCEIDSHXX): $(OOXMLHXXOUTDIRCREATED) $(OOXMLFACTORYTOOLSXSL) $(OOXMLRESOURCEIDSXSL) $(MODELPROCESSED)
+ @echo "Making: " $(@:f)
+ $(COMMAND_ECHO)$(XSLTPROC) $(OOXMLRESOURCEIDSXSL:s!\!/!) $(MODELPROCESSED) > $@
+
+$(SPRMIDSHXX): $(DOCTOKHXXOUTDIRCREATED) $(DOCTOKSPRMIDSXSL) $(DOCTOKMODEL)
+ @echo "Making: " $(@:f)
+ $(COMMAND_ECHO)$(XSLTPROC) $(DOCTOKSPRMIDSXSL:s!\!/!) $(DOCTOKMODEL) > $@
+
+.PHONY: genclean genmake gendirs
+
+genclean:
+ rm -f $(GENERATEDFILES)
+
+genmake: $(GENERATEDFILES)
+
diff --git a/writerfilter/source/resourcemodel/namespace_preprocess.pl b/writerfilter/source/resourcemodel/namespace_preprocess.pl
new file mode 100644
index 000000000000..22c172329f61
--- /dev/null
+++ b/writerfilter/source/resourcemodel/namespace_preprocess.pl
@@ -0,0 +1,65 @@
+$ARGV0 = shift @ARGV;
+
+print <<EOF;
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml"/>
+
+ <xsl:include href="./modelpreprocess.xsl"/>
+
+ <xsl:template match="namespace-alias[\@id]">
+ <xsl:variable name="value">
+ <xsl:call-template name="getnamespaceid">
+ <xsl:with-param name="id" select="\@id" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:copy>
+ <xsl:apply-templates select="@*"/>
+ <xsl:attribute name="id">
+ <xsl:value-of select="\$value"/>
+ </xsl:attribute>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template name="getnamespaceid">
+ <xsl:param name='id'/>
+ <xsl:choose>
+EOF
+
+
+# print the mapping
+open ( NAMESPACES, $ARGV0 ) || die "can't open namespace file: $!";
+$group = 0;
+$i = 1;
+while ( <NAMESPACES> )
+{
+ chomp( $_ );
+ $_ =~ s/\s*//g;
+ if ( $_ =~ m/^$/ )
+ {
+ # Start a new group
+ $i = 0;
+ $group++;
+ }
+ elsif ( $_ =~ m/^[^#]/ )
+ {
+ # Neither an empty line nor a comment
+ $_ =~ /^[a-zA-Z0-9-_]+$/ or die "Invalid namespace token $_";
+ $_ =~ s/-/_/g;
+ $no = $group*10 + $i;
+ print <<EOF;
+ <xsl:when test="\$id = '$_'">
+ <xsl:text>$no</xsl:text>
+ </xsl:when>
+EOF
+ ++$i;
+ }
+}
+
+print <<EOF;
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
+EOF
diff --git a/writerfilter/source/resourcemodel/qnametostrfooter b/writerfilter/source/resourcemodel/qnametostrfooter
new file mode 100644
index 000000000000..d0af0f6fa30f
--- /dev/null
+++ b/writerfilter/source/resourcemodel/qnametostrfooter
@@ -0,0 +1,24 @@
+QNameToString::QNameToString()
+{
+ init_doctok();
+ init_ooxml();
+}
+
+void WRITERFILTER_DLLPUBLIC analyzerIds()
+{
+ cout << "<ids type=\"sprm\">" << endl;
+
+ sprmidsToXML(cout);
+ ooxmlsprmidsToXML(cout);
+
+ cout << "</ids>" << endl;
+
+ cout << "<ids type=\"attribute\">" << endl;
+
+ doctokidsToXML(cout);
+ ooxmlidsToXML(cout);
+
+ cout << "</ids>" << endl;
+}
+
+}
diff --git a/writerfilter/source/resourcemodel/qnametostrheader b/writerfilter/source/resourcemodel/qnametostrheader
new file mode 100644
index 000000000000..6cbd0b3fec10
--- /dev/null
+++ b/writerfilter/source/resourcemodel/qnametostrheader
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * 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 <doctok/resourceids.hxx>
+#include <ooxml/resourceids.hxx>
+#include <resourcemodel/QNameToString.hxx>
+#include <stdio.h>
+
+namespace writerfilter
+{
+
+QNameToString::Pointer_t QNameToString::pInstance;
+
+QNameToString::Pointer_t WRITERFILTER_DLLPUBLIC QNameToString::Instance()
+{
+ if (pInstance.get() == NULL)
+ pInstance = QNameToString::Pointer_t(new QNameToString());
+
+ return pInstance;
+}
+
+string WRITERFILTER_DLLPUBLIC QNameToString::operator()(Id qName)
+{
+ string sResult;
+
+ Map::const_iterator aIt = mMap.find(qName);
+
+ if (aIt != mMap.end())
+ sResult = aIt->second;
+
+ return mMap[qName];
+}
+
diff --git a/writerfilter/source/resourcemodel/resourcemodel.cxx b/writerfilter/source/resourcemodel/resourcemodel.cxx
new file mode 100644
index 000000000000..b24ad8d76c85
--- /dev/null
+++ b/writerfilter/source/resourcemodel/resourcemodel.cxx
@@ -0,0 +1,566 @@
+/* -*- 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 <stdio.h>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <resourcemodel/TableManager.hxx>
+#include <resourcemodel/QNameToString.hxx>
+#include <resourcemodel/exceptions.hxx>
+#include <resourcemodel/SubSequence.hxx>
+#include <resourcemodel/util.hxx>
+#include <resourcemodel.hxx>
+
+namespace writerfilter {
+
+class ResourceModelOutputWithDepth : public OutputWithDepth<string>
+{
+public:
+ ResourceModelOutputWithDepth()
+ : OutputWithDepth<string>("<tablegroup>", "</tablegroup>") {}
+
+ ~ResourceModelOutputWithDepth() {outputGroup();}
+
+ void output(const string & str) const { cout << str << endl; }
+};
+
+ResourceModelOutputWithDepth output;
+
+Stream::Pointer_t createStreamHandler()
+{
+ return Stream::Pointer_t(new WW8StreamHandler());
+}
+
+void dump(OutputWithDepth<string> & /*o*/, const char * /*name*/,
+ writerfilter::Reference<Properties>::Pointer_t /*props*/)
+{
+}
+
+void dump(OutputWithDepth<string> & o, const char * name, sal_uInt32 n)
+{
+ char sBuffer[256];
+ snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIuUINT32, n);
+ string tmpStr = name;
+ tmpStr += "=";
+ tmpStr += sBuffer;
+
+ o.addItem(tmpStr);
+}
+
+void dump(OutputWithDepth<string> & /*o*/, const char * /*name*/,
+ const rtl::OUString & /*str*/)
+{
+}
+
+void dump(OutputWithDepth<string> & /*o*/, const char * /*name*/,
+ writerfilter::Reference<BinaryObj>::Pointer_t /*binary*/)
+{
+}
+
+string gInfo = "";
+// ------- WW8TableDataHandler ---------
+
+class TablePropsRef : public writerfilter::Reference<Properties>
+{
+public:
+ typedef boost::shared_ptr<TablePropsRef> Pointer_t;
+
+ TablePropsRef() {}
+ virtual ~TablePropsRef() {}
+
+ virtual void resolve(Properties & /*rHandler*/) {}
+
+ virtual string getType() const { return "TableProps"; }
+ void reset() {}
+ void insert(Pointer_t /* pTablePropsRef */) {}
+};
+
+typedef TablePropsRef::Pointer_t TablePropsRef_t;
+
+class WW8TableDataHandler : public TableDataHandler<string,
+ TablePropsRef_t>
+{
+public:
+ typedef boost::shared_ptr<WW8TableDataHandler> Pointer_t;
+ virtual void startTable(unsigned int nRows, unsigned int nDepth,
+ TablePropsRef_t pProps);
+ virtual void endTable();
+ virtual void startRow(unsigned int nCols,
+ TablePropsRef_t pProps);
+ virtual void endRow();
+ virtual void startCell(const string & start, TablePropsRef_t pProps);
+ virtual void endCell(const string & end);
+};
+
+void WW8TableDataHandler::startTable(unsigned int nRows, unsigned int nDepth,
+ TablePropsRef_t /*pProps*/)
+{
+ char sBuffer[256];
+
+ string tmpStr = "<tabledata.table rows=\"";
+ snprintf(sBuffer, sizeof(sBuffer), "%d", nRows);
+ tmpStr += sBuffer;
+ tmpStr += "\" depth=\"";
+ snprintf(sBuffer, sizeof(sBuffer), "%d", nDepth);
+ tmpStr += sBuffer;
+ tmpStr += "\">";
+
+ output.addItem(tmpStr);
+}
+
+void WW8TableDataHandler::endTable()
+{
+ output.addItem("</tabledata.table>");
+}
+
+void WW8TableDataHandler::startRow
+(unsigned int nCols, TablePropsRef_t /*pProps*/)
+{
+ char sBuffer[256];
+
+ snprintf(sBuffer, sizeof(sBuffer), "%d", nCols);
+ string tmpStr = "<tabledata.row cells=\"";
+ tmpStr += sBuffer;
+ tmpStr += "\">";
+ output.addItem(tmpStr);
+}
+
+void WW8TableDataHandler::endRow()
+{
+ output.addItem("</tabledata.row>");
+}
+
+void WW8TableDataHandler::startCell(const string & start,
+ TablePropsRef_t /*pProps*/)
+{
+ output.addItem("<tabledata.cell>");
+ output.addItem(start);
+ output.addItem(", ");
+}
+
+void WW8TableDataHandler::endCell(const string & end)
+{
+ output.addItem(end);
+ output.addItem("</tabledata.cell>");
+}
+
+// ----- WW8TableDataManager -------------------------------
+
+class WW8TableManager :
+ public TableManager<string, TablePropsRef_t>
+{
+ typedef TableDataHandler<string, TablePropsRef_t>
+ TableDataHandlerPointer_t;
+
+public:
+ WW8TableManager();
+ virtual ~WW8TableManager() {}
+ virtual void endParagraphGroup();
+ virtual bool sprm(Sprm & rSprm);
+};
+
+WW8TableManager::WW8TableManager()
+{
+ TableDataHandler<string, TablePropsRef_t>::Pointer_t pHandler(new WW8TableDataHandler());
+ setHandler(pHandler);
+}
+
+bool WW8TableManager::sprm(Sprm & rSprm)
+{
+ TableManager<string, TablePropsRef_t>::sprm(rSprm);
+ output.setDepth(getTableDepthNew());
+ return true;
+}
+
+void WW8TableManager::endParagraphGroup()
+{
+ string tmpStr = "<tabledepth depth=\"";
+ char sBuffer[256];
+ snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIuUINT32, getTableDepthNew());
+ tmpStr += sBuffer;
+ tmpStr += "\"/>";
+ output.addItem(tmpStr);
+ TableManager<string, TablePropsRef_t>::endParagraphGroup();
+}
+
+WW8TableManager gTableManager;
+
+/* WW8StreamHandler */
+
+WW8StreamHandler::WW8StreamHandler()
+: mnUTextCount(0)
+{
+ output.closeGroup();
+ output.addItem("<stream>");
+ gTableManager.startLevel();
+}
+
+WW8StreamHandler::~WW8StreamHandler()
+{
+ gTableManager.endLevel();
+
+ output.closeGroup();
+ output.addItem("</stream>");
+}
+
+void WW8StreamHandler::startSectionGroup()
+{
+ output.addItem("<section-group>");
+}
+
+void WW8StreamHandler::endSectionGroup()
+{
+ output.addItem("</section-group>");
+}
+
+void WW8StreamHandler::startParagraphGroup()
+{
+ output.openGroup();
+ output.addItem("<paragraph-group>");
+
+ gTableManager.startParagraphGroup();
+ gTableManager.handle(gInfo);
+}
+
+void WW8StreamHandler::endParagraphGroup()
+{
+ gTableManager.endParagraphGroup();
+
+ output.addItem("</paragraph-group>");
+ output.closeGroup();
+
+}
+
+void WW8StreamHandler::startCharacterGroup()
+{
+ output.addItem("<character-group>");
+}
+
+void WW8StreamHandler::endCharacterGroup()
+{
+ output.addItem("</character-group>");
+}
+
+void WW8StreamHandler::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
+{
+ output.addItem("<shape>");
+}
+
+void WW8StreamHandler::endShape( )
+{
+ output.addItem( "</shape>" );
+}
+
+void WW8StreamHandler::text(const sal_uInt8 * data, size_t len)
+{
+ string tmpStr = "<text>";
+
+ for (unsigned int n = 0; n < len; ++n)
+ {
+ switch (static_cast<unsigned char>(data[n]))
+ {
+ case '<':
+ tmpStr += "&lt;";
+
+ break;
+ case '>':
+ tmpStr += "&gt;";
+
+ break;
+
+ case '&':
+ tmpStr += "&amp;";
+
+ break;
+ default:
+ if (isprint(data[n]))
+ tmpStr += static_cast<char>(data[n]);
+ else
+ {
+ char sBuffer[256];
+
+ snprintf(sBuffer, sizeof(sBuffer), "\\0x%02x", data[n]);
+
+ tmpStr += sBuffer;
+ }
+ }
+ }
+
+ tmpStr += "</text>";
+
+ output.addItem(tmpStr);
+
+ gTableManager.text(data, len);
+}
+
+void WW8StreamHandler::utext(const sal_uInt8 * data, size_t len)
+{
+ static char sBuffer[256];
+ snprintf(sBuffer, sizeof(sBuffer), "<utext count=\"%d\">", mnUTextCount);
+ string tmpStr(sBuffer);
+
+ for (unsigned int n = 0; n < len; ++n)
+ {
+ sal_Unicode nChar = data[n * 2] + (data[n * 2 + 1] << 8);
+ if (nChar < 0xff && isprint(nChar))
+ {
+ switch (nChar)
+ {
+ case '&':
+ tmpStr += "&amp;";
+ break;
+ case '<':
+ tmpStr += "&lt;";
+ break;
+ case '>':
+ tmpStr += "&gt;";
+ break;
+ default:
+ tmpStr += static_cast<char>(nChar);
+ }
+ }
+ else
+ {
+ snprintf(sBuffer, sizeof(sBuffer), "\\0x%04x", nChar);
+
+ tmpStr += sBuffer;
+ }
+ }
+
+ tmpStr += "</utext>";
+
+ output.addItem(tmpStr);
+
+ gTableManager.utext(data, len);
+
+ mnUTextCount++;
+}
+
+void WW8StreamHandler::props(writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ WW8PropertiesHandler aHandler;
+
+ output.addItem("<properties type=\"" + ref->getType() + "\">");
+ ref->resolve(aHandler);
+
+ //gTableManager.props(ref);
+
+ output.addItem("</properties>");
+}
+
+void WW8StreamHandler::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
+{
+ WW8TableHandler aHandler;
+
+ output.addItem("<table id=\"" + (*QNameToString::Instance())(name)
+ + "\">");
+
+ try
+ {
+ ref->resolve(aHandler);
+ }
+ catch (Exception e)
+ {
+ output.addItem("<exception>" + e.getText() + "</exception>");
+ }
+
+ output.addItem("</table>");
+}
+
+void WW8StreamHandler::substream(Id name,
+ writerfilter::Reference<Stream>::Pointer_t ref)
+{
+ output.addItem("<substream name=\"" + (*QNameToString::Instance())(name)
+ + "\">");
+
+ gTableManager.startLevel();
+
+ ref->resolve(*this);
+
+ gTableManager.endLevel();
+
+ output.addItem("</substream>");
+}
+
+void WW8StreamHandler::info(const string & info_)
+{
+ gInfo = info_;
+ output.addItem("<info>" + info_ + "</info>");
+}
+
+void WW8PropertiesHandler::attribute(Id name, Value & val)
+{
+ boost::shared_ptr<rtl::OString> pStr(new ::rtl::OString());
+ ::rtl::OUString aStr = val.getString();
+ aStr.convertToString(pStr.get(), RTL_TEXTENCODING_ASCII_US,
+ OUSTRING_TO_OSTRING_CVTFLAGS);
+ string sXMLValue = xmlify(pStr->getStr());
+
+ char sBuffer[256];
+ snprintf(sBuffer, sizeof(sBuffer), "0x%x", val.getInt());
+
+ output.addItem("<attribute name=\"" +
+ (*QNameToString::Instance())(name) +
+ "\" value=\"" +
+ sXMLValue +
+ + "\" hexvalue=\""
+ + sBuffer + "\">");
+
+ writerfilter::Reference<Properties>::Pointer_t pProps = val.getProperties();
+
+ if (pProps.get() != NULL)
+ {
+ output.addItem("<properties name=\"" +
+ (*QNameToString::Instance())(name)
+ + "\" type=\"" + pProps->getType() + "\">");
+
+ try
+ {
+ pProps->resolve(*this);
+ }
+ catch (ExceptionOutOfBounds e)
+ {
+ }
+
+ output.addItem("</properties>");
+ }
+
+ writerfilter::Reference<Stream>::Pointer_t pStream = val.getStream();
+
+ if (pStream.get() != NULL)
+ {
+ try
+ {
+ WW8StreamHandler aHandler;
+
+ pStream->resolve(aHandler);
+ }
+ catch (ExceptionOutOfBounds e)
+ {
+ }
+ }
+
+ writerfilter::Reference<BinaryObj>::Pointer_t pBinObj = val.getBinary();
+
+ if (pBinObj.get() != NULL)
+ {
+ try
+ {
+ WW8BinaryObjHandler aHandler;
+
+ pBinObj->resolve(aHandler);
+ }
+ catch (ExceptionOutOfBounds e)
+ {
+ }
+ }
+
+ output.addItem("</attribute>");
+}
+
+void WW8PropertiesHandler::sprm(Sprm & sprm_)
+{
+ string tmpStr = "<sprm id=\"";
+ char buffer[256];
+ snprintf(buffer, sizeof(buffer), "0x%" SAL_PRIxUINT32, sprm_.getId());
+ tmpStr += buffer;
+ tmpStr += "\" name=\"";
+ tmpStr += sprm_.getName();
+ tmpStr += "\">";
+ output.addItem(tmpStr);
+ output.addItem(sprm_.toString());
+
+ writerfilter::Reference<Properties>::Pointer_t pProps = sprm_.getProps();
+
+ if (pProps.get() != NULL)
+ {
+ output.addItem("<properties type=\"" + pProps->getType() + "\">");
+ pProps->resolve(*this);
+ output.addItem("</properties>");
+ }
+
+ writerfilter::Reference<BinaryObj>::Pointer_t pBinObj = sprm_.getBinary();
+
+ if (pBinObj.get() != NULL)
+ {
+ output.addItem("<binary>");
+ WW8BinaryObjHandler aHandler;
+ pBinObj->resolve(aHandler);
+ output.addItem("</binary>");
+ }
+
+ writerfilter::Reference<Stream>::Pointer_t pStream = sprm_.getStream();
+
+ if (pStream.get() != NULL)
+ {
+ output.addItem("<stream>");
+ WW8StreamHandler aHandler;
+ pStream->resolve(aHandler);
+ output.addItem("</stream>");
+ }
+
+ gTableManager.sprm(sprm_);
+
+ output.addItem("</sprm>");
+}
+
+void WW8TableHandler::entry(int /*pos*/,
+ writerfilter::Reference<Properties>::Pointer_t ref)
+{
+ output.addItem("<tableentry>");
+
+ WW8PropertiesHandler aHandler;
+
+ try
+ {
+ ref->resolve(aHandler);
+ }
+ catch (Exception e)
+ {
+ output.addItem("<exception>" + e.getText() + "</exception>");
+ output.addItem("</tableentry>");
+
+ throw e;
+ }
+
+ output.addItem("</tableentry>");
+}
+
+void WW8BinaryObjHandler::data
+(const sal_uInt8 * buf, size_t length,
+ writerfilter::Reference<Properties>::Pointer_t /*pRef*/)
+{
+#if 1
+ SubSequence<sal_uInt8> aSeq(buf, length);
+
+ aSeq.dump(output);
+#endif
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/resourcemodel.hxx b/writerfilter/source/resourcemodel/resourcemodel.hxx
new file mode 100644
index 000000000000..02caa040ef6c
--- /dev/null
+++ b/writerfilter/source/resourcemodel/resourcemodel.hxx
@@ -0,0 +1,113 @@
+/* -*- 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 <resourcemodel/WW8ResourceModel.hxx>
+
+namespace writerfilter {
+class WW8StreamHandler : public Stream
+{
+ int mnUTextCount;
+
+public:
+ WW8StreamHandler();
+ virtual ~WW8StreamHandler();
+
+ virtual void startSectionGroup();
+ virtual void endSectionGroup();
+ virtual void startParagraphGroup();
+ virtual void endParagraphGroup();
+ virtual void startCharacterGroup();
+ virtual void endCharacterGroup();
+ virtual void text(const sal_uInt8 * data, size_t len);
+ virtual void utext(const sal_uInt8 * data, size_t len);
+
+ virtual void props(writerfilter::Reference<Properties>::Pointer_t ref);
+ virtual void table(Id name,
+ writerfilter::Reference<Table>::Pointer_t ref);
+
+ virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ virtual void endShape( );
+
+ virtual void substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref);
+
+ virtual void info(const string & info);
+};
+
+class WW8PropertiesHandler : public Properties
+{
+ typedef boost::shared_ptr<Sprm> SprmSharedPointer_t;
+ typedef vector<SprmSharedPointer_t> SprmPointers_t;
+ SprmPointers_t sprms;
+
+public:
+ WW8PropertiesHandler()
+ {
+ }
+
+ virtual ~WW8PropertiesHandler()
+ {
+ }
+
+ virtual void attribute(Id name, Value & val);
+ virtual void sprm(Sprm & sprm);
+
+ void dumpSprm(SprmSharedPointer_t sprm);
+ void dumpSprms();
+};
+
+class WW8BinaryObjHandler : public BinaryObj
+{
+public:
+ WW8BinaryObjHandler()
+ {
+ }
+
+ virtual ~WW8BinaryObjHandler()
+ {
+ }
+
+ virtual void data(const sal_uInt8* buf, size_t len,
+ writerfilter::Reference<Properties>::Pointer_t ref);
+};
+
+class WW8TableHandler : public Table
+{
+public:
+ WW8TableHandler()
+ {
+ }
+
+ virtual ~WW8TableHandler()
+ {
+ }
+
+ void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/resourcemodel/setdebugflags b/writerfilter/source/resourcemodel/setdebugflags
new file mode 100755
index 000000000000..dafa563d7a7d
--- /dev/null
+++ b/writerfilter/source/resourcemodel/setdebugflags
@@ -0,0 +1,3 @@
+#!/bin/tcsh
+
+setenv ENFCLAGS "-DDEBUG_ELEMENT -DDEBUG_ATTRIBUTES -DDEBUG_PROPERTIES -DDEBUG_CONTEXT_STACK -DDEBUG_CREATE -DDEBUG_DOMAINMAPPER"
diff --git a/writerfilter/source/resourcemodel/sprmcodetostrfooter b/writerfilter/source/resourcemodel/sprmcodetostrfooter
new file mode 100644
index 000000000000..5c34318c2147
--- /dev/null
+++ b/writerfilter/source/resourcemodel/sprmcodetostrfooter
@@ -0,0 +1 @@
+}
diff --git a/writerfilter/source/resourcemodel/sprmcodetostrheader b/writerfilter/source/resourcemodel/sprmcodetostrheader
new file mode 100644
index 000000000000..ff0663e30bde
--- /dev/null
+++ b/writerfilter/source/resourcemodel/sprmcodetostrheader
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * 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 <doctok/resourceids.hxx>
+#include <ooxml/resourceids.hxx>
+#include <resourcemodel/QNameToString.hxx>
+#include <doctok/sprmids.hxx>
+
+namespace writerfilter
+{
+
+SprmIdToString::Pointer_t SprmIdToString::pInstance;
+
+SprmIdToString::Pointer_t SprmIdToString::Instance()
+{
+ if (pInstance.get() == NULL)
+ pInstance = SprmIdToString::Pointer_t(new SprmIdToString());
+
+ return pInstance;
+}
+
+string SprmIdToString::operator()(sal_uInt32 nId)
+{
+ return mMap[nId];
+}
+
diff --git a/writerfilter/source/resourcemodel/util.cxx b/writerfilter/source/resourcemodel/util.cxx
new file mode 100644
index 000000000000..f36a5797920c
--- /dev/null
+++ b/writerfilter/source/resourcemodel/util.cxx
@@ -0,0 +1,430 @@
+/* -*- 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 <stdio.h>
+#include <stdlib.h>
+#include <fstream>
+#include <string>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/HomogenMatrix3.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <resourcemodel/TagLogger.hxx>
+#include <resourcemodel/util.hxx>
+
+namespace writerfilter
+{
+using namespace com::sun::star;
+using namespace std;
+using text::TextContentAnchorType;
+
+static string & logger_file()
+{
+ static string _logger_file = string(getenv("TEMP")?getenv("TEMP"):"/tmp") + "/writerfilter.ooxml.tmp";
+ return _logger_file;
+}
+
+static ofstream & logger_stream()
+{
+ static ofstream _logger_stream(logger_file().c_str());
+ return _logger_stream;
+}
+
+
+void logger(string prefix, string message)
+{
+ logger_stream() << prefix << ":" << message << endl;
+ logger_stream().flush();
+}
+
+ string xmlify(const string & str)
+ {
+ string result = "";
+ char sBuffer[16];
+
+ for (string::const_iterator aIt = str.begin(); aIt != str.end(); ++aIt)
+ {
+ char c = *aIt;
+
+ if (isprint(c) && c != '\"')
+ {
+ if (c == '<')
+ result += "&lt;";
+ else if (c == '>')
+ result += "&gt;";
+ else if (c == '&')
+ result += "&amp;";
+ else
+ result += c;
+ }
+ else
+ {
+ snprintf(sBuffer, sizeof(sBuffer), "\\%03d", c);
+ result += sBuffer;
+ }
+ }
+
+ return result;
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+string propertysetToString(uno::Reference<beans::XPropertySet> const & xPropSet)
+{
+ string sResult;
+
+ static int nAttribNames = 9;
+ static string sPropertyAttribNames[9] =
+ {
+ "MAYBEVOID",
+ "BOUND",
+ "CONSTRAINED",
+ "TRANSIENT",
+ "READONLY",
+ "MAYBEAMBIGUOUS",
+ "MAYBEDEFAULT",
+ "REMOVEABLE",
+ "OPTIONAL"
+ };
+
+ static const ::rtl::OUString sMetaFile(RTL_CONSTASCII_USTRINGPARAM("MetaFile"));
+
+ uno::Reference<beans::XPropertySetInfo> xPropSetInfo
+ (xPropSet->getPropertySetInfo());
+
+ if (xPropSetInfo.is())
+ {
+ uno::Sequence<beans::Property> aProps(xPropSetInfo->getProperties());
+
+ sResult +="<propertyset>";
+
+ for (sal_Int32 n = 0; n < aProps.getLength(); n++)
+ {
+ ::rtl::OUString sPropName(aProps[n].Name);
+
+ if (xPropSetInfo->hasPropertyByName(sPropName))
+ {
+ bool bPropertyFound = true;
+ uno::Any aAny;
+ try
+ {
+ if (sPropName == sMetaFile)
+ bPropertyFound = false;
+ else
+ xPropSet->getPropertyValue(sPropName) >>= aAny;
+ }
+ catch (beans::UnknownPropertyException)
+ {
+ bPropertyFound = false;
+ }
+
+ if (bPropertyFound)
+ {
+ sResult += "<property name=\"";
+ sResult += OUStringToOString
+ (sPropName, RTL_TEXTENCODING_ASCII_US).getStr();
+ sResult +="\" type=\"";
+
+ ::rtl::OUString sPropType(aProps[n].Type.getTypeName());
+ sResult += OUStringToOString
+ (sPropType, RTL_TEXTENCODING_ASCII_US).getStr();
+
+ sResult += "\" attribs=\"";
+
+ sal_uInt16 nMask = 1;
+ bool bFirstAttrib = true;
+ sal_uInt16 nAttribs = aProps[n].Attributes;
+ for (int i = 0; i < nAttribNames; i++)
+ {
+ if ((nAttribs & nMask) != 0)
+ {
+ if (bFirstAttrib)
+ bFirstAttrib = false;
+ else
+ sResult += "|";
+
+ sResult += sPropertyAttribNames[i];
+ }
+
+ nMask <<= 1;
+ }
+
+ sResult += "\">";
+
+ char buffer[256];
+ if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("byte")))
+ {
+ sal_Int8 nValue = 0;
+ aAny >>= nValue;
+
+ snprintf(buffer, sizeof(buffer), "%d", nValue);
+ sResult += buffer;
+ }
+ if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("short")))
+ {
+ sal_Int16 nValue = 0;
+ aAny >>= nValue;
+
+ snprintf(buffer, sizeof(buffer), "%d", nValue);
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("long")))
+ {
+ sal_Int32 nValue = 0;
+ aAny >>= nValue;
+
+ snprintf(buffer, sizeof(buffer), "%" SAL_PRIdINT32, nValue);
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("float")))
+ {
+ float nValue = 0.0;
+ aAny >>= nValue;
+
+ snprintf(buffer, sizeof(buffer), "%f", nValue);
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("double")))
+ {
+ double nValue = 0.0;
+ aAny >>= nValue;
+
+ snprintf(buffer, sizeof(buffer), "%lf", nValue);
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("boolean")))
+ {
+ sal_Bool nValue = sal_False;
+ aAny >>= nValue;
+
+ if (nValue)
+ sResult += "true";
+ else
+ sResult += "false";
+ }
+ else if (sPropType ==
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("string")))
+ {
+ ::rtl::OUString sValue;
+ aAny >>= sValue;
+
+ sResult += OUStringToOString
+ (sValue, RTL_TEXTENCODING_ASCII_US).getStr();
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.text.TextContentAnchorType")))
+ {
+ text::TextContentAnchorType nValue;
+ aAny >>= nValue;
+
+ switch (nValue)
+ {
+ case text::TextContentAnchorType_AT_PARAGRAPH:
+ sResult += "AT_PARAGRAPH";
+ break;
+ case text::TextContentAnchorType_AS_CHARACTER:
+ sResult += "AS_CHARACTER";
+ break;
+ case text::TextContentAnchorType_AT_PAGE:
+ sResult += "AT_PAGE";
+ break;
+ case text::TextContentAnchorType_AT_FRAME:
+ sResult += "AT_FRAME";
+ break;
+ case text::TextContentAnchorType_AT_CHARACTER:
+ sResult += "AT_CHARACTER";
+ break;
+ case text::TextContentAnchorType_MAKE_FIXED_SIZE:
+ sResult += "MAKE_FIXED_SIZE";
+ break;
+ default:
+ break;
+ }
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.awt.Point")))
+ {
+ awt::Point aPoint;
+ aAny >>= aPoint;
+
+ snprintf(buffer, sizeof(buffer), "(%" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ")", aPoint.X,
+ aPoint.Y);
+
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.awt.Rectangle")))
+ {
+ awt::Rectangle aRect;
+ aAny >>= aRect;
+
+ snprintf(buffer, sizeof(buffer), "(%" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ")",
+ aRect.X, aRect.Y, aRect.Width, aRect.Height);
+ sResult += buffer;
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.drawing.FillStyle")))
+ {
+ drawing::FillStyle nValue;
+ aAny >>= nValue;
+
+ switch (nValue)
+ {
+ case drawing::FillStyle_NONE:
+ sResult += "NONE";
+ break;
+ case drawing::FillStyle_SOLID:
+ sResult += "SOLID";
+ break;
+ case drawing::FillStyle_GRADIENT:
+ sResult += "GRADIENT";
+ break;
+ case drawing::FillStyle_HATCH:
+ sResult += "HATCH";
+ break;
+ case drawing::FillStyle_BITMAP:
+ sResult += "BITMAP";
+ break;
+ case drawing::FillStyle_MAKE_FIXED_SIZE:
+ sResult += "MAKE_FIXED_SIZE";
+ break;
+ }
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.drawing.BitmapMode")))
+ {
+ drawing::BitmapMode nValue;
+ aAny >>= nValue;
+
+ switch (nValue)
+ {
+ case drawing::BitmapMode_REPEAT:
+ sResult += "REPEAT";
+ break;
+ case drawing::BitmapMode_STRETCH:
+ sResult += "STRETCH";
+ break;
+ case drawing::BitmapMode_NO_REPEAT:
+ sResult += "NO_REPEAT";
+ break;
+ case drawing::BitmapMode_MAKE_FIXED_SIZE:
+ sResult += "MAKE_FIXED_SIZE";
+ break;
+ }
+ }
+ else if (sPropType ==
+ ::rtl::OUString
+ (RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.drawing.HomogenMatrix3")))
+ {
+ drawing::HomogenMatrix3 aMatrix;
+ aAny >>= aMatrix;
+
+ snprintf(buffer, sizeof(buffer),
+ "((%f %f %f)(%f %f %f)(%f %f %f))",
+ aMatrix.Line1.Column1,
+ aMatrix.Line1.Column2,
+ aMatrix.Line1.Column3,
+ aMatrix.Line2.Column1,
+ aMatrix.Line2.Column2,
+ aMatrix.Line2.Column3,
+ aMatrix.Line3.Column1,
+ aMatrix.Line3.Column2,
+ aMatrix.Line3.Column3);
+ sResult += buffer;
+ }
+
+ sResult += "</property>";
+ }
+ }
+ else
+ {
+ sResult += "<unknown-property>";
+ sResult += OUStringToOString
+ (sPropName, RTL_TEXTENCODING_ASCII_US).getStr();
+ sResult += "</unknown-property>";
+ }
+ }
+ sResult += "</propertyset>";
+ }
+
+ return sResult;
+}
+
+string toString(uno::Reference< text::XTextRange > textRange)
+{
+ string result;
+
+ if (textRange.get())
+ {
+ rtl::OUString aOUStr = textRange->getString();
+ rtl::OString aOStr(aOUStr.getStr(), aOUStr.getLength(), RTL_TEXTENCODING_ASCII_US );
+
+ result = aOStr.getStr();
+ }
+ else
+ {
+ result="(nil)";
+ }
+
+ return result;
+}
+
+string toString(const string & rString)
+{
+ return rString;
+}
+#endif
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */