summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorHenning Brinkmann <hbrinkm@openoffice.org>2010-02-03 17:04:44 +0100
committerHenning Brinkmann <hbrinkm@openoffice.org>2010-02-03 17:04:44 +0100
commit63504a19a7d0942a0b3a93fc77723bfde6cea4ad (patch)
tree9061358a05e3f5f3274a5d466937a8f66a276fa0 /writerfilter
parent14c25b68aea5ff1bc14869a1e74ca819a04aa467 (diff)
writerfilter07: stack table properties in parser state
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx2
-rw-r--r--writerfilter/source/ooxml/OOXMLParserState.cxx89
-rw-r--r--writerfilter/source/ooxml/OOXMLParserState.hxx12
3 files changed, 79 insertions, 24 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 097b0f6fa2d5..a789fab2c11c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1955,6 +1955,7 @@ void OOXMLFastContextHandlerTextTable::lcl_startFastElement
const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
throw (uno::RuntimeException, xml::sax::SAXException)
{
+ mpParserState->startTable();
mnTableDepth++;
boost::shared_ptr<OOXMLPropertySet> pProps( new OOXMLPropertySetImpl );
@@ -1977,6 +1978,7 @@ void OOXMLFastContextHandlerTextTable::lcl_endFastElement
endAction(Element);
mnTableDepth--;
+ mpParserState->endTable();
}
/*
diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx b/writerfilter/source/ooxml/OOXMLParserState.cxx
index 8c93629d4aeb..8663abd88500 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.cxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.cxx
@@ -222,55 +222,102 @@ void OOXMLParserState::setCharacterProperties
void OOXMLParserState::setCellProperties
(OOXMLPropertySet::Pointer_t pProps)
{
- if (mpCellProps.get() == NULL)
- mpCellProps = pProps;
- else
- mpCellProps->add(pProps);
+ if (mCellProps.size() > 0)
+ {
+ OOXMLPropertySet::Pointer_t & rCellProps = mCellProps.top();
+
+ if (rCellProps.get() == NULL)
+ rCellProps = pProps;
+ else
+ rCellProps->add(pProps);
+ }
}
void OOXMLParserState::setRowProperties
(OOXMLPropertySet::Pointer_t pProps)
{
- if (mpRowProps.get() == NULL)
- mpRowProps = pProps;
- else
- mpRowProps->add(pProps);
+ if (mRowProps.size() > 0)
+ {
+ OOXMLPropertySet::Pointer_t & rRowProps = mRowProps.top();
+
+ if (rRowProps.get() == NULL)
+ rRowProps = pProps;
+ else
+ rRowProps->add(pProps);
+ }
}
void OOXMLParserState::resolveCellProperties(Stream & rStream)
{
- if (mpCellProps.get() != NULL)
+ if (mCellProps.size() > 0)
{
- rStream.props(mpCellProps);
- mpCellProps.reset(new OOXMLPropertySetImpl());
+ OOXMLPropertySet::Pointer_t pCellProps = mCellProps.top();
+
+ if (pCellProps.get() != NULL)
+ {
+ rStream.props(pCellProps);
+ pCellProps.reset(new OOXMLPropertySetImpl());
+ }
}
}
void OOXMLParserState::resolveRowProperties(Stream & rStream)
{
- if (mpRowProps.get() != NULL)
+ if (mRowProps.size() > 0)
{
- rStream.props(mpRowProps);
- mpRowProps.reset(new OOXMLPropertySetImpl());
+ OOXMLPropertySet::Pointer_t pRowProps = mRowProps.top();
+
+ if (pRowProps.get() != NULL)
+ {
+ rStream.props(pRowProps);
+ pRowProps.reset(new OOXMLPropertySetImpl());
+ }
}
}
void OOXMLParserState::resolveTableProperties(Stream & rStream)
{
- if (mpTableProps.get() != NULL)
+ if (mTableProps.size() > 0)
{
- rStream.props(mpTableProps);
- mpTableProps.reset(new OOXMLPropertySetImpl());
+ OOXMLPropertySet::Pointer_t pTableProps = mTableProps.top();
+
+ if (pTableProps.get() != NULL)
+ {
+ rStream.props(pTableProps);
+ pTableProps.reset(new OOXMLPropertySetImpl());
+ }
}
}
void OOXMLParserState::setTableProperties
(OOXMLPropertySet::Pointer_t pProps)
{
- if (mpTableProps.get() == NULL)
- mpTableProps = pProps;
- else
- mpTableProps->add(pProps);
+ if (mTableProps.size() > 0)
+ {
+ OOXMLPropertySet::Pointer_t & rTableProps = mTableProps.top();
+ if (rTableProps.get() == NULL)
+ rTableProps = pProps;
+ else
+ rTableProps->add(pProps);
+ }
+}
+
+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();
+ mRowProps.pop();
+ mTableProps.pop();
}
XMLTag::Pointer_t OOXMLParserState::toTag() const
diff --git a/writerfilter/source/ooxml/OOXMLParserState.hxx b/writerfilter/source/ooxml/OOXMLParserState.hxx
index d988417b0b9f..a72d9825e13c 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.hxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.hxx
@@ -30,6 +30,7 @@
#ifndef INCLUDE_OOXML_PARSER_STATE_HXX
#define INCLUDE_OOXML_PARSER_STATE_HXX
+#include <stack>
#include <ooxml/OOXMLDocument.hxx>
#include <resourcemodel/TagLogger.hxx>
#include "OOXMLPropertySetImpl.hxx"
@@ -38,6 +39,8 @@ namespace writerfilter {
namespace ooxml
{
+using ::std::stack;
+
class OOXMLParserState
{
bool mbInSectionGroup;
@@ -51,9 +54,9 @@ class OOXMLParserState
rtl::OUString msXNoteId;
rtl::OUString msTarget;
OOXMLPropertySet::Pointer_t mpCharacterProps;
- OOXMLPropertySet::Pointer_t mpCellProps;
- OOXMLPropertySet::Pointer_t mpRowProps;
- OOXMLPropertySet::Pointer_t mpTableProps;
+ stack<OOXMLPropertySet::Pointer_t> mCellProps;
+ stack<OOXMLPropertySet::Pointer_t> mRowProps;
+ stack<OOXMLPropertySet::Pointer_t> mTableProps;
public:
typedef boost::shared_ptr<OOXMLParserState> Pointer_t;
@@ -102,6 +105,9 @@ public:
void resolveTableProperties(Stream & rStream);
void setTableProperties(OOXMLPropertySet::Pointer_t pProps);
+ void startTable();
+ void endTable();
+
string toString() const;
XMLTag::Pointer_t toTag() const;
};