[Libreoffice-commits] core.git: 2 commits - sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Sun May 4 12:30:25 PDT 2014
sw/source/core/access/accpara.cxx | 4
writerfilter/source/rtftok/README | 11
writerfilter/source/rtftok/astyle.options | 11
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 7505 +++++++++++++------------
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1071 +--
5 files changed, 4551 insertions(+), 4051 deletions(-)
New commits:
commit d6c42a503fb4237d5aa86eece3bf1fc1fba87a4b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sun May 4 21:21:29 2014 +0200
coverity#1038298 Unchecked dynamic_cast
Change-Id: Ibb2eca48edb30a88b1ab4bcc35e7e5852efbb436
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 3ed00c6..9f69d01 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1870,9 +1870,9 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl(
break;
}
- if ( dynamic_cast<const SwFlyFrm*>(pUpperFrm) )
+ if ( const SwFlyFrm* pFlyFrm = dynamic_cast<const SwFlyFrm*>(pUpperFrm) )
{
- pUpperFrm = dynamic_cast<const SwFlyFrm*>(pUpperFrm)->GetAnchorFrm();
+ pUpperFrm = pFlyFrm->GetAnchorFrm();
}
else
{
commit da47a7d239fe9b27aa84cd5716e9f7430814beab
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sun May 4 21:06:45 2014 +0200
writerfilter: fix indentation in rtfdocumentimpl
Change-Id: I5588e84a486ca751e94e097bc8bceaa35fe8b969
diff --git a/writerfilter/source/rtftok/README b/writerfilter/source/rtftok/README
index 4adbb75..0a554bb 100644
--- a/writerfilter/source/rtftok/README
+++ b/writerfilter/source/rtftok/README
@@ -10,3 +10,14 @@ grep M_TOKEN starmath/source/ooxmlimport.cxx |sed 's/.*\(M_TOKEN(\) /\1/;s/ ).*/
grep '[^_]M_TOKEN' writerfilter/source/rtftok/rtfdocumentimpl.cxx |sed 's/.*\(M_TOKEN(\)/\1/;s/).*/)/'|sort -u > ~/wf-export-list
diff -u ~/math-import-list ~/wf-export-list |grep ^-M_TOKEN
----
+
+== Coding style
+
+This directory uses mostly the same coding style like the rest of Fridrich's
+libraries. Please run
+
+----
+astyle --options=astyle.options \*.cxx \*.hxx
+----
+
+before committing.
diff --git a/writerfilter/source/rtftok/astyle.options b/writerfilter/source/rtftok/astyle.options
new file mode 100644
index 0000000..e62db10
--- /dev/null
+++ b/writerfilter/source/rtftok/astyle.options
@@ -0,0 +1,11 @@
+# formatting options
+style=allman
+indent=spaces=4
+align-pointer=type
+break-closing-brackets
+pad-header
+unpad-paren
+
+# processing options
+recursive
+suffix=none
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7fffb14..3f32705 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -61,8 +61,10 @@
using std::make_pair;
-namespace writerfilter {
-namespace rtftok {
+namespace writerfilter
+{
+namespace rtftok
+{
static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
{
@@ -75,7 +77,7 @@ static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
}
static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue,
- RTFOverwrite eOverwrite = OVERWRITE_YES, bool bAttribute = true)
+ RTFOverwrite eOverwrite = OVERWRITE_YES, bool bAttribute = true)
{
RTFValue::Pointer_t pParent = rSprms.find(nParent, /*bFirst=*/true, /*bForWrite=*/true);
if (!pParent.get())
@@ -203,7 +205,7 @@ static const char* lcl_RtfToString(RTFKeyword nKeyword)
static util::DateTime lcl_getDateTime(RTFParserState& aState)
{
return util::DateTime(0 /*100sec*/, 0 /*sec*/, aState.nMinute, aState.nHour,
- aState.nDay, aState.nMonth, aState.nYear, false);
+ aState.nDay, aState.nMonth, aState.nYear, false);
}
static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer, bool& rMathNor)
@@ -229,70 +231,70 @@ static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formula
}
RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
- uno::Reference<io::XInputStream> const& xInputStream,
- uno::Reference<lang::XComponent> const& xDstDoc,
- uno::Reference<frame::XFrame> const& xFrame,
- uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
+ uno::Reference<io::XInputStream> const& xInputStream,
+ uno::Reference<lang::XComponent> const& xDstDoc,
+ uno::Reference<frame::XFrame> const& xFrame,
+ uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
: m_xContext(xContext),
- m_xInputStream(xInputStream),
- m_xDstDoc(xDstDoc),
- m_xFrame(xFrame),
- m_xStatusIndicator(xStatusIndicator),
- m_pMapperStream(NULL),
- m_aDefaultState(this),
- m_bSkipUnknown(false),
- m_aFontIndexes(),
- m_aColorTable(),
- m_bFirstRun(true),
- m_bNeedPap(true),
- m_bNeedCr(false),
- m_bNeedCrOrig(false),
- m_bNeedPar(true),
- m_bNeedFinalPar(false),
- m_aListTableSprms(),
- m_aSettingsTableAttributes(),
- m_aSettingsTableSprms(),
- m_xStorage(),
- m_nNestedCells(0),
- m_nTopLevelCells(0),
- m_nInheritingCells(0),
- m_nNestedCurrentCellX(0),
- m_nTopLevelCurrentCellX(0),
- m_nBackupTopLevelCurrentCellX(0),
- m_aTableBufferStack(1), // create top-level buffer already
- m_aSuperBuffer(),
- m_bHasFootnote(false),
- m_pSuperstream(0),
- m_nStreamType(0),
- m_nHeaderFooterPositions(),
- m_nGroupStartPos(0),
- m_aBookmarks(),
- m_aAuthors(),
- m_aFormfieldSprms(),
- m_aFormfieldAttributes(),
- m_nFormFieldType(FORMFIELD_NONE),
- m_aObjectSprms(),
- m_aObjectAttributes(),
- m_bObject(false),
- m_aFontTableEntries(),
- m_nCurrentFontIndex(0),
- m_nCurrentEncoding(0),
- m_nDefaultFontIndex(-1),
- m_aStyleTableEntries(),
- m_nCurrentStyleIndex(0),
- m_bFormField(false),
- m_bIsInFrame(false),
- m_aUnicodeBuffer(),
- m_aHexBuffer(),
- m_bMathNor(false),
- m_bIgnoreNextContSectBreak(false),
- m_nResetBreakOnSectBreak(RTF_invalid),
- m_bNeedSect(false), // done by checkFirstRun
- m_bWasInFrame(false),
- m_bHadPicture(false),
- m_bHadSect(false),
- m_nCellxMax(0),
- m_nListPictureId(0)
+ m_xInputStream(xInputStream),
+ m_xDstDoc(xDstDoc),
+ m_xFrame(xFrame),
+ m_xStatusIndicator(xStatusIndicator),
+ m_pMapperStream(NULL),
+ m_aDefaultState(this),
+ m_bSkipUnknown(false),
+ m_aFontIndexes(),
+ m_aColorTable(),
+ m_bFirstRun(true),
+ m_bNeedPap(true),
+ m_bNeedCr(false),
+ m_bNeedCrOrig(false),
+ m_bNeedPar(true),
+ m_bNeedFinalPar(false),
+ m_aListTableSprms(),
+ m_aSettingsTableAttributes(),
+ m_aSettingsTableSprms(),
+ m_xStorage(),
+ m_nNestedCells(0),
+ m_nTopLevelCells(0),
+ m_nInheritingCells(0),
+ m_nNestedCurrentCellX(0),
+ m_nTopLevelCurrentCellX(0),
+ m_nBackupTopLevelCurrentCellX(0),
+ m_aTableBufferStack(1), // create top-level buffer already
+ m_aSuperBuffer(),
+ m_bHasFootnote(false),
+ m_pSuperstream(0),
+ m_nStreamType(0),
+ m_nHeaderFooterPositions(),
+ m_nGroupStartPos(0),
+ m_aBookmarks(),
+ m_aAuthors(),
+ m_aFormfieldSprms(),
+ m_aFormfieldAttributes(),
+ m_nFormFieldType(FORMFIELD_NONE),
+ m_aObjectSprms(),
+ m_aObjectAttributes(),
+ m_bObject(false),
+ m_aFontTableEntries(),
+ m_nCurrentFontIndex(0),
+ m_nCurrentEncoding(0),
+ m_nDefaultFontIndex(-1),
+ m_aStyleTableEntries(),
+ m_nCurrentStyleIndex(0),
+ m_bFormField(false),
+ m_bIsInFrame(false),
+ m_aUnicodeBuffer(),
+ m_aHexBuffer(),
+ m_bMathNor(false),
+ m_bIgnoreNextContSectBreak(false),
+ m_nResetBreakOnSectBreak(RTF_invalid),
+ m_bNeedSect(false), // done by checkFirstRun
+ m_bWasInFrame(false),
+ m_bHadPicture(false),
+ m_bHadSect(false),
+ m_nCellxMax(0),
+ m_nListPictureId(0)
{
OSL_ASSERT(xInputStream.is());
m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, true));
@@ -323,7 +325,7 @@ Stream& RTFDocumentImpl::Mapper()
return *m_pMapperStream;
}
-void RTFDocumentImpl::setSuperstream(RTFDocumentImpl *pSuperstream)
+void RTFDocumentImpl::setSuperstream(RTFDocumentImpl* pSuperstream)
{
m_pSuperstream = pSuperstream;
}
@@ -466,12 +468,12 @@ void RTFDocumentImpl::checkNeedPap()
if (!m_aStates.top().pCurrentBuffer)
{
writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties(
- getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
- );
+ getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
+ );
// Writer will ignore a page break before a text frame, so guard it with empty paragraphs
bool hasBreakBeforeFrame = m_aStates.top().aFrame.hasProperties() &&
- m_aStates.top().aParagraphSprms.find(NS_ooxml::LN_CT_PPrBase_pageBreakBefore).get();
+ m_aStates.top().aParagraphSprms.find(NS_ooxml::LN_CT_PPrBase_pageBreakBefore).get();
if (hasBreakBeforeFrame)
{
dispatchSymbol(RTF_PAR);
@@ -484,7 +486,7 @@ void RTFDocumentImpl::checkNeedPap()
if (m_aStates.top().aFrame.hasProperties())
{
writerfilter::Reference<Properties>::Pointer_t const pFrameProperties(
- new RTFReferenceProperties(RTFSprms(), m_aStates.top().aFrame.getSprms()));
+ new RTFReferenceProperties(RTFSprms(), m_aStates.top().aFrame.getSprms()));
Mapper().props(pFrameProperties);
}
}
@@ -492,7 +494,7 @@ void RTFDocumentImpl::checkNeedPap()
{
RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
m_aStates.top().pCurrentBuffer->push_back(
- Buf_t(BUFFER_PROPS, pValue));
+ Buf_t(BUFFER_PROPS, pValue));
}
}
}
@@ -589,8 +591,8 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
RTFSprms aSprms;
aSprms.set(NS_ooxml::LN_CT_PPr_sectPr, pValue);
writerfilter::Reference<Properties>::Pointer_t const pProperties(
- new RTFReferenceProperties(aAttributes, aSprms)
- );
+ new RTFReferenceProperties(aAttributes, aSprms)
+ );
// The trick is that we send properties of the previous section right now, which will be exactly what dmapper expects.
Mapper().props(pProperties);
Mapper().endParagraphGroup();
@@ -672,39 +674,39 @@ oox::GraphicHelper& RTFDocumentImpl::getGraphicHelper()
return *m_pGraphicHelper;
}
-void RTFDocumentImpl::resolve(Stream & rMapper)
+void RTFDocumentImpl::resolve(Stream& rMapper)
{
m_pMapperStream = &rMapper;
switch (m_pTokenizer->resolveParse())
{
- case ERROR_OK:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": finished without errors");
- break;
- case ERROR_GROUP_UNDER:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '}'");
- break;
- case ERROR_GROUP_OVER:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '{'");
- throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
- break;
- case ERROR_EOF:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unexpected end of file");
- throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
- break;
- case ERROR_HEX_INVALID:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": invalid hex char");
- throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
- break;
- case ERROR_CHAR_OVER:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": characters after last '}'");
- break;
+ case ERROR_OK:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": finished without errors");
+ break;
+ case ERROR_GROUP_UNDER:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '}'");
+ break;
+ case ERROR_GROUP_OVER:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '{'");
+ throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
+ break;
+ case ERROR_EOF:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unexpected end of file");
+ throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
+ break;
+ case ERROR_HEX_INVALID:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": invalid hex char");
+ throw io::WrongFormatException(m_pTokenizer->getPosition(), uno::Reference< uno::XInterface >());
+ break;
+ case ERROR_CHAR_OVER:
+ SAL_INFO("writerfilter", OSL_THIS_FUNC << ": characters after last '}'");
+ break;
}
}
int RTFDocumentImpl::resolvePict(bool bInline)
{
SvMemoryStream aStream;
- SvStream *pStream = 0;
+ SvStream* pStream = 0;
if (!m_pBinaryData.get())
{
pStream = &aStream;
@@ -712,7 +714,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
// Feed the destination text to a stream.
OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
- const char *str = aStr.getStr();
+ const char* str = aStr.getStr();
for (int i = 0; i < aStr.getLength(); ++i)
{
char ch = str[i];
@@ -726,7 +728,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
count--;
if (!count)
{
- aStream.WriteChar( (char)b );
+ aStream.WriteChar((char)b);
count = 2;
b = 0;
}
@@ -778,12 +780,12 @@ int RTFDocumentImpl::resolvePict(bool bInline)
if (m_xModelFactory.is())
xShape.set(m_xModelFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY);
- if ( xDrawSupplier.is() )
+ uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
+ if (xDrawSupplier.is())
{
- uno::Reference< drawing::XShapes > xShapes( xDrawSupplier->getDrawPage(), uno::UNO_QUERY );
- if ( xShapes.is() )
- xShapes->add( xShape );
+ uno::Reference< drawing::XShapes > xShapes(xDrawSupplier->getDrawPage(), uno::UNO_QUERY);
+ if (xShapes.is())
+ xShapes->add(xShape);
}
// check if the picture is in an OLE object and if the \objdata element is used
@@ -802,7 +804,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
awt::Size aSize;
aSize.Width = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
aSize.Height = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
- xShape->setSize( aSize );
+ xShape->setSize(aSize);
RTFValue::Pointer_t pShapeValue(new RTFValue(xShape));
m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue);
@@ -845,9 +847,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
nXExt = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
nYExt = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
if (m_aStates.top().aPicture.nScaleX != 100)
- nXExt = (((long)m_aStates.top().aPicture.nScaleX) * ( nXExt - ( m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR ))) / 100L;
+ nXExt = (((long)m_aStates.top().aPicture.nScaleX) * (nXExt - (m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR))) / 100L;
if (m_aStates.top().aPicture.nScaleY != 100)
- nYExt = (((long)m_aStates.top().aPicture.nScaleY) * ( nYExt - ( m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB ))) / 100L;
+ nYExt = (((long)m_aStates.top().aPicture.nScaleY) * (nYExt - (m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB))) / 100L;
RTFValue::Pointer_t pXExtValue(new RTFValue(MM100_TO_EMU(nXExt)));
RTFValue::Pointer_t pYExtValue(new RTFValue(MM100_TO_EMU(nYExt)));
aExtentAttributes.set(NS_ooxml::LN_CT_PositiveSize2D_cx, pXExtValue);
@@ -939,11 +941,11 @@ int RTFDocumentImpl::resolveChars(char ch)
if (m_aStates.top().nInternalState == INTERNAL_BIN)
{
m_pBinaryData.reset(new SvMemoryStream());
- m_pBinaryData->WriteChar( ch );
+ m_pBinaryData->WriteChar(ch);
for (int i = 0; i < m_aStates.top().nBinaryToRead - 1; ++i)
{
- Strm().ReadChar( ch );
- m_pBinaryData->WriteChar( ch );
+ Strm().ReadChar(ch);
+ m_pBinaryData->WriteChar(ch);
}
m_aStates.top().nInternalState = INTERNAL_NORMAL;
return 0;
@@ -956,7 +958,7 @@ int RTFDocumentImpl::resolveChars(char ch)
bool bUnicodeChecked = false;
bool bSkipped = false;
- while(!Strm().IsEof() && (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != '{' && ch != '}' && ch != '\\')))
+ while (!Strm().IsEof() && (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != '{' && ch != '}' && ch != '\\')))
{
if (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != 0x0d && ch != 0x0a))
{
@@ -978,7 +980,7 @@ int RTFDocumentImpl::resolveChars(char ch)
// read a single char if we're in hex mode
if (m_aStates.top().nInternalState == INTERNAL_HEX)
break;
- Strm().ReadChar( ch );
+ Strm().ReadChar(ch);
}
if (m_aStates.top().nInternalState != INTERNAL_HEX && !Strm().IsEof())
Strm().SeekRel(-1);
@@ -1006,8 +1008,8 @@ int RTFDocumentImpl::resolveChars(char ch)
if (m_aStates.top().nDestinationState == DESTINATION_COLORTABLE)
{
// we hit a ';' at the end of each color entry
- sal_uInt32 color = (m_aStates.top().aCurrentColor.nRed << 16) | ( m_aStates.top().aCurrentColor.nGreen << 8)
- | m_aStates.top().aCurrentColor.nBlue;
+ sal_uInt32 color = (m_aStates.top().aCurrentColor.nRed << 16) | (m_aStates.top().aCurrentColor.nGreen << 8)
+ | m_aStates.top().aCurrentColor.nBlue;
m_aColorTable.push_back(color);
// set components back to zero
m_aStates.top().aCurrentColor = RTFColorTableEntry();
@@ -1021,9 +1023,9 @@ int RTFDocumentImpl::resolveChars(char ch)
bool RTFFrame::inFrame()
{
return nW > 0
- || nH > 0
- || nX > 0
- || nY > 0;
+ || nH > 0
+ || nX > 0
+ || nY > 0;
}
void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps)
@@ -1062,125 +1064,126 @@ void RTFDocumentImpl::text(OUString& rString)
bool bRet = true;
switch (m_aStates.top().nDestinationState)
{
- case DESTINATION_FONTTABLE:
- case DESTINATION_FONTENTRY:
- case DESTINATION_STYLESHEET:
- case DESTINATION_STYLEENTRY:
- case DESTINATION_REVISIONTABLE:
- case DESTINATION_REVISIONENTRY:
+ case DESTINATION_FONTTABLE:
+ case DESTINATION_FONTENTRY:
+ case DESTINATION_STYLESHEET:
+ case DESTINATION_STYLEENTRY:
+ case DESTINATION_REVISIONTABLE:
+ case DESTINATION_REVISIONENTRY:
+ {
+ // ; is the end of the entry
+ bool bEnd = false;
+ if (rString.endsWithAsciiL(";", 1))
+ {
+ rString = rString.copy(0, rString.getLength() - 1);
+ bEnd = true;
+ }
+ m_aStates.top().aDestinationText.append(rString);
+ if (bEnd)
+ {
+ switch (m_aStates.top().nDestinationState)
{
- // ; is the end of the entry
- bool bEnd = false;
- if (rString.endsWithAsciiL(";", 1))
+ case DESTINATION_FONTTABLE:
+ case DESTINATION_FONTENTRY:
+ {
+ OUString aName = m_aStates.top().aDestinationText.makeStringAndClear();
+ m_aFontNames[m_nCurrentFontIndex] = aName;
+ if (m_nCurrentEncoding > 0)
{
- rString = rString.copy(0, rString.getLength() - 1);
- bEnd = true;
+ m_aFontEncodings[m_nCurrentFontIndex] = m_nCurrentEncoding;
+ m_nCurrentEncoding = 0;
}
- m_aStates.top().aDestinationText.append(rString);
- if (bEnd)
+ m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Font_name, RTFValue::Pointer_t(new RTFValue(aName)));
+
+ writerfilter::Reference<Properties>::Pointer_t const pProp(
+ new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms)
+ );
+
+ //See fdo#47347 initial invalid font entry properties are inserted first,
+ //so when we attempt to insert the correct ones, there's already an
+ //entry in the map for them, so the new ones aren't inserted.
+ RTFReferenceTable::Entries_t::iterator lb = m_aFontTableEntries.lower_bound(m_nCurrentFontIndex);
+ if (lb != m_aFontTableEntries.end() && !(m_aFontTableEntries.key_comp()(m_nCurrentFontIndex, lb->first)))
+ lb->second = pProp;
+ else
+ m_aFontTableEntries.insert(lb, make_pair(m_nCurrentFontIndex, pProp));
+ }
+ break;
+ case DESTINATION_STYLESHEET:
+ case DESTINATION_STYLEENTRY:
+ if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type))
{
- switch (m_aStates.top().nDestinationState)
- {
- case DESTINATION_FONTTABLE:
- case DESTINATION_FONTENTRY:
- {
- OUString aName = m_aStates.top().aDestinationText.makeStringAndClear();
- m_aFontNames[m_nCurrentFontIndex] = aName;
- if (m_nCurrentEncoding > 0)
- {
- m_aFontEncodings[m_nCurrentFontIndex] = m_nCurrentEncoding;
- m_nCurrentEncoding = 0;
- }
- m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Font_name, RTFValue::Pointer_t(new RTFValue(aName)));
-
- writerfilter::Reference<Properties>::Pointer_t const pProp(
- new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms)
- );
-
- //See fdo#47347 initial invalid font entry properties are inserted first,
- //so when we attempt to insert the correct ones, there's already an
- //entry in the map for them, so the new ones aren't inserted.
- RTFReferenceTable::Entries_t::iterator lb = m_aFontTableEntries.lower_bound(m_nCurrentFontIndex);
- if (lb != m_aFontTableEntries.end() && !(m_aFontTableEntries.key_comp()(m_nCurrentFontIndex, lb->first)))
- lb->second = pProp;
- else
- m_aFontTableEntries.insert(lb, make_pair(m_nCurrentFontIndex, pProp));
- }
- break;
- case DESTINATION_STYLESHEET:
- case DESTINATION_STYLEENTRY:
- if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type))
- {
- OUString aName = m_aStates.top().aDestinationText.makeStringAndClear();
- m_aStyleNames[m_nCurrentStyleIndex] = aName;
- RTFValue::Pointer_t pValue(new RTFValue(aName));
- m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue);
- m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
-
- writerfilter::Reference<Properties>::Pointer_t const pProp(
- new RTFReferenceProperties(mergeAttributes(), mergeSprms())
- );
- m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
- }
- else
- SAL_INFO("writerfilter", "no RTF style type defined, ignoring");
- break;
- case DESTINATION_REVISIONTABLE:
- case DESTINATION_REVISIONENTRY:
- m_aAuthors[m_aAuthors.size()] = m_aStates.top().aDestinationText.makeStringAndClear();
- break;
- default: break;
- }
- resetAttributes();
- resetSprms();
+ OUString aName = m_aStates.top().aDestinationText.makeStringAndClear();
+ m_aStyleNames[m_nCurrentStyleIndex] = aName;
+ RTFValue::Pointer_t pValue(new RTFValue(aName));
+ m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue);
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
+
+ writerfilter::Reference<Properties>::Pointer_t const pProp(
+ new RTFReferenceProperties(mergeAttributes(), mergeSprms())
+ );
+ m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
}
+ else
+ SAL_INFO("writerfilter", "no RTF style type defined, ignoring");
+ break;
+ case DESTINATION_REVISIONTABLE:
+ case DESTINATION_REVISIONENTRY:
+ m_aAuthors[m_aAuthors.size()] = m_aStates.top().aDestinationText.makeStringAndClear();
+ break;
+ default:
+ break;
}
- break;
- case DESTINATION_LEVELTEXT:
- case DESTINATION_SHAPEPROPERTYNAME:
- case DESTINATION_SHAPEPROPERTYVALUE:
- case DESTINATION_BOOKMARKEND:
- case DESTINATION_PICT:
- case DESTINATION_SHAPEPROPERTYVALUEPICT:
- case DESTINATION_FORMFIELDNAME:
- case DESTINATION_FORMFIELDLIST:
- case DESTINATION_DATAFIELD:
- case DESTINATION_AUTHOR:
- case DESTINATION_KEYWORDS:
- case DESTINATION_OPERATOR:
- case DESTINATION_COMPANY:
- case DESTINATION_COMMENT:
- case DESTINATION_OBJDATA:
- case DESTINATION_ANNOTATIONDATE:
- case DESTINATION_ANNOTATIONAUTHOR:
- case DESTINATION_ANNOTATIONREFERENCE:
- case DESTINATION_FALT:
- case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
- case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
- case DESTINATION_TITLE:
- case DESTINATION_SUBJECT:
- case DESTINATION_DOCCOMM:
- case DESTINATION_ATNID:
- case DESTINATION_ANNOTATIONREFERENCESTART:
- case DESTINATION_ANNOTATIONREFERENCEEND:
- case DESTINATION_MR:
- case DESTINATION_MCHR:
- case DESTINATION_MPOS:
- case DESTINATION_MVERTJC:
- case DESTINATION_MSTRIKEH:
- case DESTINATION_MDEGHIDE:
- case DESTINATION_MBEGCHR:
- case DESTINATION_MSEPCHR:
- case DESTINATION_MENDCHR:
- case DESTINATION_MSUBHIDE:
- case DESTINATION_MSUPHIDE:
- case DESTINATION_MTYPE:
- case DESTINATION_MGROW:
- m_aStates.top().aDestinationText.append(rString);
- break;
- default:
- bRet = false;
- break;
+ resetAttributes();
+ resetSprms();
+ }
+ }
+ break;
+ case DESTINATION_LEVELTEXT:
+ case DESTINATION_SHAPEPROPERTYNAME:
+ case DESTINATION_SHAPEPROPERTYVALUE:
+ case DESTINATION_BOOKMARKEND:
+ case DESTINATION_PICT:
+ case DESTINATION_SHAPEPROPERTYVALUEPICT:
+ case DESTINATION_FORMFIELDNAME:
+ case DESTINATION_FORMFIELDLIST:
+ case DESTINATION_DATAFIELD:
+ case DESTINATION_AUTHOR:
+ case DESTINATION_KEYWORDS:
+ case DESTINATION_OPERATOR:
+ case DESTINATION_COMPANY:
+ case DESTINATION_COMMENT:
+ case DESTINATION_OBJDATA:
+ case DESTINATION_ANNOTATIONDATE:
+ case DESTINATION_ANNOTATIONAUTHOR:
+ case DESTINATION_ANNOTATIONREFERENCE:
+ case DESTINATION_FALT:
+ case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
+ case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
+ case DESTINATION_TITLE:
+ case DESTINATION_SUBJECT:
+ case DESTINATION_DOCCOMM:
+ case DESTINATION_ATNID:
+ case DESTINATION_ANNOTATIONREFERENCESTART:
+ case DESTINATION_ANNOTATIONREFERENCEEND:
+ case DESTINATION_MR:
+ case DESTINATION_MCHR:
+ case DESTINATION_MPOS:
+ case DESTINATION_MVERTJC:
+ case DESTINATION_MSTRIKEH:
+ case DESTINATION_MDEGHIDE:
+ case DESTINATION_MBEGCHR:
+ case DESTINATION_MSEPCHR:
+ case DESTINATION_MENDCHR:
+ case DESTINATION_MSUBHIDE:
+ case DESTINATION_MSUPHIDE:
+ case DESTINATION_MTYPE:
+ case DESTINATION_MGROW:
+ m_aStates.top().aDestinationText.append(rString);
+ break;
+ default:
+ bRet = false;
+ break;
}
if (bRet)
return;
@@ -1193,7 +1196,7 @@ void RTFDocumentImpl::text(OUString& rString)
// Are we in the middle of the table definition? (No cell defs yet, but we already have some cell props.)
if (m_aStates.top().aTableCellSprms.find(NS_ooxml::LN_CT_TcPrBase_vAlign).get() &&
- m_nTopLevelCells == 0)
+ m_nTopLevelCells == 0)
{
m_aTableBufferStack.back().push_back(
Buf_t(BUFFER_UTEXT, RTFValue::Pointer_t(new RTFValue(rString))));
@@ -1237,7 +1240,7 @@ void RTFDocumentImpl::text(OUString& rString)
if (!pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
Mapper().endCharacterGroup();
- else if(pCurrentBuffer)
+ else if (pCurrentBuffer)
{
RTFValue::Pointer_t pValue;
pCurrentBuffer->push_back(Buf_t(BUFFER_ENDRUN, pValue));
@@ -1245,29 +1248,29 @@ void RTFDocumentImpl::text(OUString& rString)
}
void RTFDocumentImpl::prepareProperties(
- RTFParserState & rState,
- writerfilter::Reference<Properties>::Pointer_t & o_rpParagraphProperties,
- writerfilter::Reference<Properties>::Pointer_t & o_rpFrameProperties,
- writerfilter::Reference<Properties>::Pointer_t & o_rpTableRowProperties,
+ RTFParserState& rState,
+ writerfilter::Reference<Properties>::Pointer_t& o_rpParagraphProperties,
+ writerfilter::Reference<Properties>::Pointer_t& o_rpFrameProperties,
+ writerfilter::Reference<Properties>::Pointer_t& o_rpTableRowProperties,
int const nCells, int const nCurrentCellX)
{
o_rpParagraphProperties = getProperties(
- rState.aParagraphAttributes, rState.aParagraphSprms);
+ rState.aParagraphAttributes, rState.aParagraphSprms);
if (rState.aFrame.hasProperties())
{
o_rpFrameProperties.reset(new RTFReferenceProperties(
- RTFSprms(), rState.aFrame.getSprms()));
+ RTFSprms(), rState.aFrame.getSprms()));
}
// Table width.
RTFValue::Pointer_t const pUnitValue(new RTFValue(3));
lcl_putNestedAttribute(rState.aTableRowSprms,
- NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type,
- pUnitValue);
+ NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type,
+ pUnitValue);
RTFValue::Pointer_t const pWValue(new RTFValue(nCurrentCellX));
lcl_putNestedAttribute(rState.aTableRowSprms,
- NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
+ NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
RTFValue::Pointer_t const pRowValue(new RTFValue(1));
if (nCells > 0)
@@ -1280,21 +1283,21 @@ void RTFDocumentImpl::prepareProperties(
// If no cell margins are defined, the default left/right margin is 0 in Word, but not in Writer.
RTFSprms aAttributes;
aAttributes.set(NS_ooxml::LN_CT_TblWidth_type, RTFValue::Pointer_t(
- new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa)));
+ new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa)));
aAttributes.set(NS_ooxml::LN_CT_TblWidth_w,
- RTFValue::Pointer_t(new RTFValue(0)));
+ RTFValue::Pointer_t(new RTFValue(0)));
lcl_putNestedSprm(rState.aTableRowSprms,
- NS_ooxml::LN_CT_TblPrBase_tblCellMar,
- NS_ooxml::LN_CT_TblCellMar_left,
- RTFValue::Pointer_t(new RTFValue(aAttributes)));
+ NS_ooxml::LN_CT_TblPrBase_tblCellMar,
+ NS_ooxml::LN_CT_TblCellMar_left,
+ RTFValue::Pointer_t(new RTFValue(aAttributes)));
lcl_putNestedSprm(rState.aTableRowSprms,
- NS_ooxml::LN_CT_TblPrBase_tblCellMar,
- NS_ooxml::LN_CT_TblCellMar_right,
- RTFValue::Pointer_t(new RTFValue(aAttributes)));
+ NS_ooxml::LN_CT_TblPrBase_tblCellMar,
+ NS_ooxml::LN_CT_TblCellMar_right,
+ RTFValue::Pointer_t(new RTFValue(aAttributes)));
}
o_rpTableRowProperties.reset(new RTFReferenceProperties(
- rState.aTableRowAttributes, rState.aTableRowSprms));
+ rState.aTableRowAttributes, rState.aTableRowSprms));
}
void RTFDocumentImpl::sendProperties(
@@ -1315,10 +1318,10 @@ void RTFDocumentImpl::sendProperties(
}
void RTFDocumentImpl::replayRowBuffer(
- RTFBuffer_t & rBuffer,
- ::std::deque<RTFSprms> & rCellsSrpms,
- ::std::deque<RTFSprms> & rCellsAttributes,
- int const nCells)
+ RTFBuffer_t& rBuffer,
+ ::std::deque<RTFSprms>& rCellsSrpms,
+ ::std::deque<RTFSprms>& rCellsAttributes,
+ int const nCells)
{
for (int i = 0; i < nCells; ++i)
{
@@ -1328,15 +1331,15 @@ void RTFDocumentImpl::replayRowBuffer(
}
for (size_t i = 0; i < rBuffer.size(); ++i)
{
- SAL_WARN_IF( BUFFER_CELLEND == boost::get<0>(rBuffer[i]),
- "writerfilter.rtf", "dropping table cell!");
+ SAL_WARN_IF(BUFFER_CELLEND == boost::get<0>(rBuffer[i]),
+ "writerfilter.rtf", "dropping table cell!");
}
assert(0 == rCellsSrpms.size());
assert(0 == rCellsAttributes.size());
}
void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
- RTFSprms *const pSprms, RTFSprms const*const pAttributes)
+ RTFSprms* const pSprms, RTFSprms const* const pAttributes)
{
while (rBuffer.size())
{
@@ -1345,21 +1348,21 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
if (boost::get<0>(aTuple) == BUFFER_PROPS)
{
writerfilter::Reference<Properties>::Pointer_t const pProp(
- new RTFReferenceProperties(
- boost::get<1>(aTuple)->getAttributes(),
- boost::get<1>(aTuple)->getSprms())
- );
+ new RTFReferenceProperties(
+ boost::get<1>(aTuple)->getAttributes(),
+ boost::get<1>(aTuple)->getSprms())
+ );
Mapper().props(pProp);
}
else if (boost::get<0>(aTuple) == BUFFER_NESTROW)
{
- TableRowBuffer & rRowBuffer(*boost::get<2>(aTuple));
+ TableRowBuffer& rRowBuffer(*boost::get<2>(aTuple));
replayRowBuffer(rRowBuffer.buffer, rRowBuffer.cellsSprms,
- rRowBuffer.cellsAttributes, rRowBuffer.nCells);
+ rRowBuffer.cellsAttributes, rRowBuffer.nCells);
sendProperties(rRowBuffer.pParaProperties,
- rRowBuffer.pFrameProperties, rRowBuffer.pRowProperties);
+ rRowBuffer.pFrameProperties, rRowBuffer.pRowProperties);
}
else if (boost::get<0>(aTuple) == BUFFER_CELLEND)
{
@@ -1367,7 +1370,7 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
RTFValue::Pointer_t pValue(new RTFValue(1));
pSprms->set(NS_ooxml::LN_tblCell, pValue);
writerfilter::Reference<Properties>::Pointer_t const pTableCellProperties(
- new RTFReferenceProperties(*pAttributes, *pSprms));
+ new RTFReferenceProperties(*pAttributes, *pSprms));
Mapper().props(pTableCellProperties);
tableBreak();
break;
@@ -1405,481 +1408,524 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
RTFSkipDestination aSkip(*this);
switch (nKeyword)
{
- case RTF_RTF:
- break;
- case RTF_FONTTBL:
- m_aStates.top().nDestinationState = DESTINATION_FONTTABLE;
- break;
- case RTF_COLORTBL:
- m_aStates.top().nDestinationState = DESTINATION_COLORTABLE;
- break;
- case RTF_STYLESHEET:
- m_aStates.top().nDestinationState = DESTINATION_STYLESHEET;
- break;
- case RTF_FIELD:
- m_aStates.top().nDestinationState = DESTINATION_FIELD;
- break;
- case RTF_FLDINST:
- {
- // Look for the field type
- sal_Size nPos = Strm().Tell();
- OStringBuffer aBuf;
- char ch = 0;
- bool bFoundCode = false;
- bool bInKeyword = false;
- while (!bFoundCode && ch != '}')
- {
- Strm().ReadChar( ch );
- if ('\\' == ch)
- bInKeyword = true;
- if (!bInKeyword && isalnum(ch))
- aBuf.append(ch);
- else if (bInKeyword && isspace(ch))
- bInKeyword = false;
- if (!aBuf.isEmpty() && !isalnum(ch))
- bFoundCode = true;
- }
- Strm().Seek(nPos);
+ case RTF_RTF:
+ break;
+ case RTF_FONTTBL:
+ m_aStates.top().nDestinationState = DESTINATION_FONTTABLE;
+ break;
+ case RTF_COLORTBL:
+ m_aStates.top().nDestinationState = DESTINATION_COLORTABLE;
+ break;
+ case RTF_STYLESHEET:
+ m_aStates.top().nDestinationState = DESTINATION_STYLESHEET;
+ break;
+ case RTF_FIELD:
+ m_aStates.top().nDestinationState = DESTINATION_FIELD;
+ break;
+ case RTF_FLDINST:
+ {
+ // Look for the field type
+ sal_Size nPos = Strm().Tell();
+ OStringBuffer aBuf;
+ char ch = 0;
+ bool bFoundCode = false;
+ bool bInKeyword = false;
+ while (!bFoundCode && ch != '}')
+ {
+ Strm().ReadChar(ch);
+ if ('\\' == ch)
+ bInKeyword = true;
+ if (!bInKeyword && isalnum(ch))
+ aBuf.append(ch);
+ else if (bInKeyword && isspace(ch))
+ bInKeyword = false;
+ if (!aBuf.isEmpty() && !isalnum(ch))
+ bFoundCode = true;
+ }
+ Strm().Seek(nPos);
- // Form data should be handled only for form fields if any
- if (aBuf.toString().indexOf(OString("FORM")) != -1 )
- m_bFormField = true;
+ // Form data should be handled only for form fields if any
+ if (aBuf.toString().indexOf(OString("FORM")) != -1)
+ m_bFormField = true;
- singleChar(0x13);
- m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
- }
- break;
- case RTF_FLDRSLT:
- m_aStates.top().nDestinationState = DESTINATION_FIELDRESULT;
- break;
- case RTF_LISTTABLE:
- m_aStates.top().nDestinationState = DESTINATION_LISTTABLE;
- break;
- case RTF_LISTPICTURE:
- m_aStates.top().nDestinationState = DESTINATION_LISTPICTURE;
- m_aStates.top().bInListpicture = true;
- break;
- case RTF_LIST:
- m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
- break;
- case RTF_LFOLEVEL:
- m_aStates.top().nDestinationState = DESTINATION_LFOLEVEL;
- m_aStates.top().aTableSprms.clear();
- break;
- case RTF_LISTOVERRIDETABLE:
- m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDETABLE;
- break;
- case RTF_LISTOVERRIDE:
- m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDEENTRY;
- break;
- case RTF_LISTLEVEL:
- m_aStates.top().nDestinationState = DESTINATION_LISTLEVEL;
- break;
- case RTF_LEVELTEXT:
- m_aStates.top().nDestinationState = DESTINATION_LEVELTEXT;
- break;
- case RTF_LEVELNUMBERS:
- m_aStates.top().nDestinationState = DESTINATION_LEVELNUMBERS;
- break;
- case RTF_SHPPICT:
- m_aStates.top().resetFrame();
- m_aStates.top().nDestinationState = DESTINATION_SHPPICT;
- break;
- case RTF_PICT:
- if (m_aStates.top().nDestinationState != DESTINATION_SHAPEPROPERTYVALUE)
- m_aStates.top().nDestinationState = DESTINATION_PICT; // as character
- else
- m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUEPICT; // anchored inside a shape
- break;
- case RTF_PICPROP:
- m_aStates.top().nDestinationState = DESTINATION_PICPROP;
- break;
- case RTF_SP:
- m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTY;
- break;
- case RTF_SN:
- m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYNAME;
- break;
- case RTF_SV:
- m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUE;
- break;
- case RTF_SHP:
- m_bNeedCrOrig = m_bNeedCr;
- m_aStates.top().nDestinationState = DESTINATION_SHAPE;
- m_aStates.top().bInShape = true;
- break;
- case RTF_SHPINST:
- m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
- break;
- case RTF_NESTTABLEPROPS:
- // do not set any properties of outer table at nested table!
- m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
- m_aStates.top().aTableCellAttributes =
- m_aDefaultState.aTableCellAttributes;
- m_aNestedTableCellsSprms.clear();
- m_aNestedTableCellsAttributes.clear();
- m_nNestedCells = 0;
- m_aStates.top().nDestinationState = DESTINATION_NESTEDTABLEPROPERTIES;
- break;
- case RTF_HEADER:
- case RTF_FOOTER:
- case RTF_HEADERL:
- case RTF_HEADERR:
- case RTF_HEADERF:
- case RTF_FOOTERL:
- case RTF_FOOTERR:
- case RTF_FOOTERF:
- if (!m_pSuperstream)
+ singleChar(0x13);
+ m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
+ }
+ break;
+ case RTF_FLDRSLT:
+ m_aStates.top().nDestinationState = DESTINATION_FIELDRESULT;
+ break;
+ case RTF_LISTTABLE:
+ m_aStates.top().nDestinationState = DESTINATION_LISTTABLE;
+ break;
+ case RTF_LISTPICTURE:
+ m_aStates.top().nDestinationState = DESTINATION_LISTPICTURE;
+ m_aStates.top().bInListpicture = true;
+ break;
+ case RTF_LIST:
+ m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
+ break;
+ case RTF_LFOLEVEL:
+ m_aStates.top().nDestinationState = DESTINATION_LFOLEVEL;
+ m_aStates.top().aTableSprms.clear();
+ break;
+ case RTF_LISTOVERRIDETABLE:
+ m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDETABLE;
+ break;
+ case RTF_LISTOVERRIDE:
+ m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDEENTRY;
+ break;
+ case RTF_LISTLEVEL:
+ m_aStates.top().nDestinationState = DESTINATION_LISTLEVEL;
+ break;
+ case RTF_LEVELTEXT:
+ m_aStates.top().nDestinationState = DESTINATION_LEVELTEXT;
+ break;
+ case RTF_LEVELNUMBERS:
+ m_aStates.top().nDestinationState = DESTINATION_LEVELNUMBERS;
+ break;
+ case RTF_SHPPICT:
+ m_aStates.top().resetFrame();
+ m_aStates.top().nDestinationState = DESTINATION_SHPPICT;
+ break;
+ case RTF_PICT:
+ if (m_aStates.top().nDestinationState != DESTINATION_SHAPEPROPERTYVALUE)
+ m_aStates.top().nDestinationState = DESTINATION_PICT; // as character
+ else
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUEPICT; // anchored inside a shape
+ break;
+ case RTF_PICPROP:
+ m_aStates.top().nDestinationState = DESTINATION_PICPROP;
+ break;
+ case RTF_SP:
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTY;
+ break;
+ case RTF_SN:
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYNAME;
+ break;
+ case RTF_SV:
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUE;
+ break;
+ case RTF_SHP:
+ m_bNeedCrOrig = m_bNeedCr;
+ m_aStates.top().nDestinationState = DESTINATION_SHAPE;
+ m_aStates.top().bInShape = true;
+ break;
+ case RTF_SHPINST:
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
+ break;
+ case RTF_NESTTABLEPROPS:
+ // do not set any properties of outer table at nested table!
+ m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
+ m_aStates.top().aTableCellAttributes =
+ m_aDefaultState.aTableCellAttributes;
+ m_aNestedTableCellsSprms.clear();
+ m_aNestedTableCellsAttributes.clear();
+ m_nNestedCells = 0;
+ m_aStates.top().nDestinationState = DESTINATION_NESTEDTABLEPROPERTIES;
+ break;
+ case RTF_HEADER:
+ case RTF_FOOTER:
+ case RTF_HEADERL:
+ case RTF_HEADERR:
+ case RTF_HEADERF:
+ case RTF_FOOTERL:
+ case RTF_FOOTERR:
+ case RTF_FOOTERF:
+ if (!m_pSuperstream)
+ {
+ Id nId = 0;
+ sal_Size nPos = m_nGroupStartPos - 1;
+ switch (nKeyword)
{
- Id nId = 0;
- sal_Size nPos = m_nGroupStartPos - 1;
- switch (nKeyword)
- {
- case RTF_HEADER: nId = NS_ooxml::LN_headerr; break;
- case RTF_FOOTER: nId = NS_ooxml::LN_footerr; break;
- case RTF_HEADERL: nId = NS_ooxml::LN_headerl; break;
- case RTF_HEADERR: nId = NS_ooxml::LN_headerr; break;
- case RTF_HEADERF: nId = NS_ooxml::LN_headerf; break;
- case RTF_FOOTERL: nId = NS_ooxml::LN_footerl; break;
- case RTF_FOOTERR: nId = NS_ooxml::LN_footerr; break;
- case RTF_FOOTERF: nId = NS_ooxml::LN_footerf; break;
- default: break;
- }
- m_nHeaderFooterPositions.push(make_pair(nId, nPos));
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ case RTF_HEADER:
+ nId = NS_ooxml::LN_headerr;
+ break;
+ case RTF_FOOTER:
+ nId = NS_ooxml::LN_footerr;
+ break;
+ case RTF_HEADERL:
+ nId = NS_ooxml::LN_headerl;
+ break;
+ case RTF_HEADERR:
+ nId = NS_ooxml::LN_headerr;
+ break;
+ case RTF_HEADERF:
+ nId = NS_ooxml::LN_headerf;
+ break;
+ case RTF_FOOTERL:
+ nId = NS_ooxml::LN_footerl;
+ break;
+ case RTF_FOOTERR:
+ nId = NS_ooxml::LN_footerr;
+ break;
+ case RTF_FOOTERF:
+ nId = NS_ooxml::LN_footerf;
+ break;
+ default:
+ break;
}
- break;
- case RTF_FOOTNOTE:
- if (!m_pSuperstream)
- {
- Id nId = NS_ooxml::LN_footnote;
+ m_nHeaderFooterPositions.push(make_pair(nId, nPos));
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ }
+ break;
+ case RTF_FOOTNOTE:
+ if (!m_pSuperstream)
+ {
+ Id nId = NS_ooxml::LN_footnote;
- // Check if this is an endnote.
- OStringBuffer aBuf;
- char ch;
- for (int i = 0; i < 7; ++i)
- {
- Strm().ReadChar( ch );
- aBuf.append(ch);
- }
- OString aKeyword = aBuf.makeStringAndClear();
- if (aKeyword.equals("\\ftnalt"))
- nId = NS_ooxml::LN_endnote;
-
- m_bHasFootnote = true;
- if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer)
- m_aStates.top().pCurrentBuffer = 0;
- bool bCustomMark = false;
- OUString aCustomMark;
- while (m_aSuperBuffer.size())
- {
- Buf_t aTuple = m_aSuperBuffer.front();
- m_aSuperBuffer.pop_front();
- if (boost::get<0>(aTuple) == BUFFER_UTEXT)
- {
- aCustomMark = boost::get<1>(aTuple)->getString();
- bCustomMark = true;
- }
- }
- m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
- if (bCustomMark)
- Mapper().startCharacterGroup();
- resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
- if (bCustomMark)
- {
- m_aStates.top().aCharacterAttributes.clear();
- m_aStates.top().aCharacterSprms.clear();
- RTFValue::Pointer_t pValue(new RTFValue(1));
- m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdnRef_customMarkFollows, pValue);
- text(aCustomMark);
- Mapper().endCharacterGroup();
- }
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- }
- break;
- case RTF_BKMKSTART:
- m_aStates.top().nDestinationState = DESTINATION_BOOKMARKSTART;
- break;
- case RTF_BKMKEND:
- m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
- break;
- case RTF_REVTBL:
- m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
- break;
- case RTF_ANNOTATION:
- if (!m_pSuperstream)
+ // Check if this is an endnote.
+ OStringBuffer aBuf;
+ char ch;
+ for (int i = 0; i < 7; ++i)
{
- resolveSubstream(m_nGroupStartPos - 1, NS_ooxml::LN_annotation);
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ Strm().ReadChar(ch);
+ aBuf.append(ch);
}
- else
+ OString aKeyword = aBuf.makeStringAndClear();
+ if (aKeyword.equals("\\ftnalt"))
+ nId = NS_ooxml::LN_endnote;
+
+ m_bHasFootnote = true;
+ if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer)
+ m_aStates.top().pCurrentBuffer = 0;
+ bool bCustomMark = false;
+ OUString aCustomMark;
+ while (m_aSuperBuffer.size())
{
- // If there is an author set, emit it now.
- if (!m_aAuthor.isEmpty() || !m_aAuthorInitials.isEmpty())
+ Buf_t aTuple = m_aSuperBuffer.front();
+ m_aSuperBuffer.pop_front();
+ if (boost::get<0>(aTuple) == BUFFER_UTEXT)
{
- RTFSprms aAttributes;
- if (!m_aAuthor.isEmpty())
- {
- RTFValue::Pointer_t pValue(new RTFValue(m_aAuthor));
- aAttributes.set(NS_ooxml::LN_CT_TrackChange_author, pValue);
- }
- if (!m_aAuthorInitials.isEmpty())
- {
- RTFValue::Pointer_t pValue(new RTFValue(m_aAuthorInitials));
- aAttributes.set(NS_ooxml::LN_CT_Comment_initials, pValue);
- }
- writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
- Mapper().props(pProperties);
+ aCustomMark = boost::get<1>(aTuple)->getString();
+ bCustomMark = true;
}
}
- break;
- case RTF_SHPTXT:
- case RTF_DPTXBXTEXT:
+ m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
+ if (bCustomMark)
+ Mapper().startCharacterGroup();
+ resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
+ if (bCustomMark)
{
- bool bPictureFrame = false;
- for (size_t i = 0; i < m_aStates.top().aShape.aProperties.size(); ++i)
- {
- std::pair<OUString, OUString>& rProperty = m_aStates.top().aShape.aProperties[i];
- if (rProperty.first == "shapeType" && rProperty.second == OUString::number(ESCHER_ShpInst_PictureFrame))
- {
- bPictureFrame = true;
- break;
- }
- }
- if (bPictureFrame)
- // Skip text on picture frames.
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- else
- {
- m_aStates.top().nDestinationState = DESTINATION_SHAPETEXT;
- checkFirstRun();
- dispatchFlag(RTF_PARD);
- m_bNeedPap = true;
- if (nKeyword == RTF_SHPTXT)
- {
- if (!m_aStates.top().pCurrentBuffer)
- m_pSdrImport->resolve(m_aStates.top().aShape, false);
- else
- {
- RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aShape));
- m_aStates.top().pCurrentBuffer->push_back(
- Buf_t(BUFFER_STARTSHAPE, pValue));
- }
- }
- }
+ m_aStates.top().aCharacterAttributes.clear();
+ m_aStates.top().aCharacterSprms.clear();
+ RTFValue::Pointer_t pValue(new RTFValue(1));
+ m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdnRef_customMarkFollows, pValue);
+ text(aCustomMark);
+ Mapper().endCharacterGroup();
}
- break;
- case RTF_FORMFIELD:
- if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
- m_aStates.top().nDestinationState = DESTINATION_FORMFIELD;
- break;
- case RTF_FFNAME:
- m_aStates.top().nDestinationState = DESTINATION_FORMFIELDNAME;
- break;
- case RTF_FFL:
- m_aStates.top().nDestinationState = DESTINATION_FORMFIELDLIST;
- break;
- case RTF_DATAFIELD:
- m_aStates.top().nDestinationState = DESTINATION_DATAFIELD;
- break;
- case RTF_INFO:
- m_aStates.top().nDestinationState = DESTINATION_INFO;
- break;
- case RTF_CREATIM:
- m_aStates.top().nDestinationState = DESTINATION_CREATIONTIME;
- break;
- case RTF_REVTIM:
- m_aStates.top().nDestinationState = DESTINATION_REVISIONTIME;
- break;
- case RTF_PRINTIM:
- m_aStates.top().nDestinationState = DESTINATION_PRINTTIME;
- break;
- case RTF_AUTHOR:
- m_aStates.top().nDestinationState = DESTINATION_AUTHOR;
- break;
- case RTF_KEYWORDS:
- m_aStates.top().nDestinationState = DESTINATION_KEYWORDS;
- break;
- case RTF_OPERATOR:
- m_aStates.top().nDestinationState = DESTINATION_OPERATOR;
- break;
- case RTF_COMPANY:
- m_aStates.top().nDestinationState = DESTINATION_COMPANY;
- break;
- case RTF_COMMENT:
- m_aStates.top().nDestinationState = DESTINATION_COMMENT;
- break;
- case RTF_OBJECT:
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ }
+ break;
+ case RTF_BKMKSTART:
+ m_aStates.top().nDestinationState = DESTINATION_BOOKMARKSTART;
+ break;
+ case RTF_BKMKEND:
+ m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
+ break;
+ case RTF_REVTBL:
+ m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
+ break;
+ case RTF_ANNOTATION:
+ if (!m_pSuperstream)
+ {
+ resolveSubstream(m_nGroupStartPos - 1, NS_ooxml::LN_annotation);
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ }
+ else
+ {
+ // If there is an author set, emit it now.
+ if (!m_aAuthor.isEmpty() || !m_aAuthorInitials.isEmpty())
{
- // beginning of an OLE Object
- m_aStates.top().nDestinationState = DESTINATION_OBJECT;
-
- // check if the object is in a special container (e.g. a table)
- if (!m_aStates.top().pCurrentBuffer)
+ RTFSprms aAttributes;
+ if (!m_aAuthor.isEmpty())
{
- // the object is in a table or another container.
- // Don't try to treate it as an OLE object (fdo#53594).
- // Use the \result (RTF_RESULT) element of the object instead,
- // the result element contain picture representing the OLE Object.
- m_bObject = true;
+ RTFValue::Pointer_t pValue(new RTFValue(m_aAuthor));
+ aAttributes.set(NS_ooxml::LN_CT_TrackChange_author, pValue);
}
+ if (!m_aAuthorInitials.isEmpty())
+ {
+ RTFValue::Pointer_t pValue(new RTFValue(m_aAuthorInitials));
+ aAttributes.set(NS_ooxml::LN_CT_Comment_initials, pValue);
+ }
+ writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
+ Mapper().props(pProperties);
}
- break;
- case RTF_OBJDATA:
- // check if the object is in a special container (e.g. a table)
- if (m_aStates.top().pCurrentBuffer)
- {
- // the object is in a table or another container.
- // Use the \result (RTF_RESULT) element of the object instead,
- // of the \objdata.
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- }
- else
+ }
+ break;
+ case RTF_SHPTXT:
+ case RTF_DPTXBXTEXT:
+ {
+ bool bPictureFrame = false;
+ for (size_t i = 0; i < m_aStates.top().aShape.aProperties.size(); ++i)
+ {
+ std::pair<OUString, OUString>& rProperty = m_aStates.top().aShape.aProperties[i];
+ if (rProperty.first == "shapeType" && rProperty.second == OUString::number(ESCHER_ShpInst_PictureFrame))
{
- m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+ bPictureFrame = true;
+ break;
}
- break;
- case RTF_RESULT:
- m_aStates.top().nDestinationState = DESTINATION_RESULT;
- break;
- case RTF_ATNDATE:
- m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONDATE;
- break;
- case RTF_ATNAUTHOR:
- m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONAUTHOR;
- break;
- case RTF_ATNREF:
- m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCE;
- break;
- case RTF_FALT:
- m_aStates.top().nDestinationState = DESTINATION_FALT;
- break;
- case RTF_FLYMAINCNT:
- m_aStates.top().nDestinationState = DESTINATION_FLYMAINCONTENT;
- break;
- case RTF_LISTTEXT:
- // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
- case RTF_NONESTTABLES:
- // This destination should be ignored by readers that support nested tables.
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- break;
- case RTF_DO:
- m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
- break;
- case RTF_PN:
- m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING;
- break;
- case RTF_PNTEXT:
- // This destination should be ignored by readers that support paragraph numbering.
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- break;
- case RTF_PNTXTA:
- m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
- break;
- case RTF_PNTXTB:
- m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
- break;
- case RTF_TITLE:
- // \title inside \upr but outside \ud should be ignored.
- if (m_aStates.top().nDestinationState != DESTINATION_UPR)
- m_aStates.top().nDestinationState = DESTINATION_TITLE;
- else
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- break;
- case RTF_SUBJECT:
- m_aStates.top().nDestinationState = DESTINATION_SUBJECT;
- break;
- case RTF_DOCCOMM:
- m_aStates.top().nDestinationState = DESTINATION_DOCCOMM;
- break;
- case RTF_ATRFSTART:
- m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCESTART;
- break;
- case RTF_ATRFEND:
- m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCEEND;
- break;
- case RTF_ATNID:
- m_aStates.top().nDestinationState = DESTINATION_ATNID;
- break;
- case RTF_MMATH:
- case RTF_MOMATHPARA:
- // Nothing to do here (just enter the destination) till RTF_MMATHPR is implemented.
- break;
- case RTF_MR: m_aStates.top().nDestinationState = DESTINATION_MR; break;
- case RTF_MCHR: m_aStates.top().nDestinationState = DESTINATION_MCHR; break;
- case RTF_MPOS: m_aStates.top().nDestinationState = DESTINATION_MPOS; break;
- case RTF_MVERTJC: m_aStates.top().nDestinationState = DESTINATION_MVERTJC; break;
- case RTF_MSTRIKEH: m_aStates.top().nDestinationState = DESTINATION_MSTRIKEH; break;
- case RTF_MDEGHIDE: m_aStates.top().nDestinationState = DESTINATION_MDEGHIDE; break;
- case RTF_MTYPE: m_aStates.top().nDestinationState = DESTINATION_MTYPE; break;
- case RTF_MGROW: m_aStates.top().nDestinationState = DESTINATION_MGROW; break;
- case RTF_MHIDETOP:
- case RTF_MHIDEBOT:
- case RTF_MHIDELEFT:
- case RTF_MHIDERIGHT:
- // SmOoxmlImport::handleBorderBox will ignore these anyway, so silently ignore for now.
+ }
+ if (bPictureFrame)
+ // Skip text on picture frames.
m_aStates.top().nDestinationState = DESTINATION_SKIP;
- break;
- case RTF_MSUBHIDE: m_aStates.top().nDestinationState = DESTINATION_MSUBHIDE; break;
- case RTF_MSUPHIDE: m_aStates.top().nDestinationState = DESTINATION_MSUPHIDE; break;
- case RTF_MBEGCHR: m_aStates.top().nDestinationState = DESTINATION_MBEGCHR; break;
- case RTF_MSEPCHR: m_aStates.top().nDestinationState = DESTINATION_MSEPCHR; break;
- case RTF_MENDCHR: m_aStates.top().nDestinationState = DESTINATION_MENDCHR; break;
- case RTF_UPR:
- m_aStates.top().nDestinationState = DESTINATION_UPR;
- break;
- case RTF_UD:
- // Anything inside \ud is just normal Unicode content.
- m_aStates.top().nDestinationState = DESTINATION_NORMAL;
- break;
- case RTF_BACKGROUND:
- m_aStates.top().nDestinationState = DESTINATION_BACKGROUND;
- m_aStates.top().bInBackground = true;
- break;
- case RTF_SHPGRP:
- {
- RTFLookahead aLookahead(Strm(), m_pTokenizer->getGroupStart());
- if (!aLookahead.hasTable())
- {
- uno::Reference<drawing::XShapes> xGroupShape(m_xModelFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
- if (xDrawSupplier.is())
- {
- uno::Reference<drawing::XShape> xShape(xGroupShape, uno::UNO_QUERY);
- xDrawSupplier->getDrawPage()->add(xShape);
- }
- m_pSdrImport->pushParent(xGroupShape);
- m_aStates.top().bCreatedShapeGroup = true;
- }
- m_aStates.top().nDestinationState = DESTINATION_SHAPEGROUP;
- m_aStates.top().bInShapeGroup = true;
- }
- break;
- case RTF_FTNSEP:
- m_aStates.top().nDestinationState = DESTINATION_FOOTNOTESEPARATOR;
- m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdn_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator)));
- break;
- default:
+ else
+ {
+ m_aStates.top().nDestinationState = DESTINATION_SHAPETEXT;
+ checkFirstRun();
+ dispatchFlag(RTF_PARD);
+ m_bNeedPap = true;
+ if (nKeyword == RTF_SHPTXT)
{
- // Check if it's a math token.
- RTFMathSymbol aSymbol;
- aSymbol.eKeyword = nKeyword;
- if (RTFTokenizer::lookupMathKeyword(aSymbol))
+ if (!m_aStates.top().pCurrentBuffer)
+ m_pSdrImport->resolve(m_aStates.top().aShape, false);
+ else
{
- m_aMathBuffer.appendOpeningTag(aSymbol.nToken);
- m_aStates.top().nDestinationState = aSymbol.eDestination;
- return 0;
+ RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aShape));
+ m_aStates.top().pCurrentBuffer->push_back(
+ Buf_t(BUFFER_STARTSHAPE, pValue));
}
-
- SAL_INFO("writerfilter", "TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
- // Make sure we skip destinations (even without \*) till we don't handle them
- m_aStates.top().nDestinationState = DESTINATION_SKIP;
- aSkip.setParsed(false);
}
- break;
+ }
}
+ break;
+ case RTF_FORMFIELD:
+ if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
+ m_aStates.top().nDestinationState = DESTINATION_FORMFIELD;
+ break;
+ case RTF_FFNAME:
+ m_aStates.top().nDestinationState = DESTINATION_FORMFIELDNAME;
+ break;
+ case RTF_FFL:
+ m_aStates.top().nDestinationState = DESTINATION_FORMFIELDLIST;
+ break;
+ case RTF_DATAFIELD:
+ m_aStates.top().nDestinationState = DESTINATION_DATAFIELD;
+ break;
+ case RTF_INFO:
+ m_aStates.top().nDestinationState = DESTINATION_INFO;
+ break;
+ case RTF_CREATIM:
+ m_aStates.top().nDestinationState = DESTINATION_CREATIONTIME;
+ break;
+ case RTF_REVTIM:
+ m_aStates.top().nDestinationState = DESTINATION_REVISIONTIME;
+ break;
+ case RTF_PRINTIM:
+ m_aStates.top().nDestinationState = DESTINATION_PRINTTIME;
+ break;
+ case RTF_AUTHOR:
+ m_aStates.top().nDestinationState = DESTINATION_AUTHOR;
+ break;
+ case RTF_KEYWORDS:
+ m_aStates.top().nDestinationState = DESTINATION_KEYWORDS;
+ break;
+ case RTF_OPERATOR:
+ m_aStates.top().nDestinationState = DESTINATION_OPERATOR;
+ break;
+ case RTF_COMPANY:
+ m_aStates.top().nDestinationState = DESTINATION_COMPANY;
+ break;
+ case RTF_COMMENT:
+ m_aStates.top().nDestinationState = DESTINATION_COMMENT;
+ break;
+ case RTF_OBJECT:
+ {
+ // beginning of an OLE Object
+ m_aStates.top().nDestinationState = DESTINATION_OBJECT;
- return 0;
+ // check if the object is in a special container (e.g. a table)
+ if (!m_aStates.top().pCurrentBuffer)
+ {
+ // the object is in a table or another container.
+ // Don't try to treate it as an OLE object (fdo#53594).
+ // Use the \result (RTF_RESULT) element of the object instead,
+ // the result element contain picture representing the OLE Object.
+ m_bObject = true;
+ }
+ }
+ break;
+ case RTF_OBJDATA:
+ // check if the object is in a special container (e.g. a table)
+ if (m_aStates.top().pCurrentBuffer)
+ {
+ // the object is in a table or another container.
+ // Use the \result (RTF_RESULT) element of the object instead,
+ // of the \objdata.
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ }
+ else
+ {
+ m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+ }
+ break;
+ case RTF_RESULT:
+ m_aStates.top().nDestinationState = DESTINATION_RESULT;
+ break;
+ case RTF_ATNDATE:
+ m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONDATE;
+ break;
+ case RTF_ATNAUTHOR:
+ m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONAUTHOR;
+ break;
+ case RTF_ATNREF:
+ m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCE;
+ break;
+ case RTF_FALT:
+ m_aStates.top().nDestinationState = DESTINATION_FALT;
+ break;
+ case RTF_FLYMAINCNT:
+ m_aStates.top().nDestinationState = DESTINATION_FLYMAINCONTENT;
+ break;
+ case RTF_LISTTEXT:
+ // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
+ case RTF_NONESTTABLES:
+ // This destination should be ignored by readers that support nested tables.
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ break;
+ case RTF_DO:
+ m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
+ break;
+ case RTF_PN:
+ m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING;
+ break;
+ case RTF_PNTEXT:
+ // This destination should be ignored by readers that support paragraph numbering.
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ break;
+ case RTF_PNTXTA:
+ m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
+ break;
+ case RTF_PNTXTB:
+ m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
+ break;
+ case RTF_TITLE:
+ // \title inside \upr but outside \ud should be ignored.
+ if (m_aStates.top().nDestinationState != DESTINATION_UPR)
+ m_aStates.top().nDestinationState = DESTINATION_TITLE;
+ else
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ break;
+ case RTF_SUBJECT:
+ m_aStates.top().nDestinationState = DESTINATION_SUBJECT;
+ break;
+ case RTF_DOCCOMM:
+ m_aStates.top().nDestinationState = DESTINATION_DOCCOMM;
+ break;
+ case RTF_ATRFSTART:
+ m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCESTART;
+ break;
+ case RTF_ATRFEND:
+ m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONREFERENCEEND;
+ break;
+ case RTF_ATNID:
+ m_aStates.top().nDestinationState = DESTINATION_ATNID;
+ break;
+ case RTF_MMATH:
+ case RTF_MOMATHPARA:
+ // Nothing to do here (just enter the destination) till RTF_MMATHPR is implemented.
+ break;
+ case RTF_MR:
+ m_aStates.top().nDestinationState = DESTINATION_MR;
+ break;
+ case RTF_MCHR:
+ m_aStates.top().nDestinationState = DESTINATION_MCHR;
+ break;
+ case RTF_MPOS:
+ m_aStates.top().nDestinationState = DESTINATION_MPOS;
+ break;
+ case RTF_MVERTJC:
+ m_aStates.top().nDestinationState = DESTINATION_MVERTJC;
+ break;
+ case RTF_MSTRIKEH:
+ m_aStates.top().nDestinationState = DESTINATION_MSTRIKEH;
+ break;
+ case RTF_MDEGHIDE:
+ m_aStates.top().nDestinationState = DESTINATION_MDEGHIDE;
+ break;
+ case RTF_MTYPE:
+ m_aStates.top().nDestinationState = DESTINATION_MTYPE;
+ break;
+ case RTF_MGROW:
+ m_aStates.top().nDestinationState = DESTINATION_MGROW;
+ break;
+ case RTF_MHIDETOP:
+ case RTF_MHIDEBOT:
+ case RTF_MHIDELEFT:
+ case RTF_MHIDERIGHT:
+ // SmOoxmlImport::handleBorderBox will ignore these anyway, so silently ignore for now.
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ break;
+ case RTF_MSUBHIDE:
+ m_aStates.top().nDestinationState = DESTINATION_MSUBHIDE;
+ break;
+ case RTF_MSUPHIDE:
+ m_aStates.top().nDestinationState = DESTINATION_MSUPHIDE;
+ break;
+ case RTF_MBEGCHR:
+ m_aStates.top().nDestinationState = DESTINATION_MBEGCHR;
+ break;
+ case RTF_MSEPCHR:
+ m_aStates.top().nDestinationState = DESTINATION_MSEPCHR;
+ break;
+ case RTF_MENDCHR:
+ m_aStates.top().nDestinationState = DESTINATION_MENDCHR;
+ break;
+ case RTF_UPR:
+ m_aStates.top().nDestinationState = DESTINATION_UPR;
+ break;
+ case RTF_UD:
+ // Anything inside \ud is just normal Unicode content.
+ m_aStates.top().nDestinationState = DESTINATION_NORMAL;
+ break;
+ case RTF_BACKGROUND:
+ m_aStates.top().nDestinationState = DESTINATION_BACKGROUND;
+ m_aStates.top().bInBackground = true;
+ break;
+ case RTF_SHPGRP:
+ {
+ RTFLookahead aLookahead(Strm(), m_pTokenizer->getGroupStart());
+ if (!aLookahead.hasTable())
+ {
+ uno::Reference<drawing::XShapes> xGroupShape(m_xModelFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
+ if (xDrawSupplier.is())
+ {
+ uno::Reference<drawing::XShape> xShape(xGroupShape, uno::UNO_QUERY);
+ xDrawSupplier->getDrawPage()->add(xShape);
+ }
+ m_pSdrImport->pushParent(xGroupShape);
+ m_aStates.top().bCreatedShapeGroup = true;
+ }
+ m_aStates.top().nDestinationState = DESTINATION_SHAPEGROUP;
+ m_aStates.top().bInShapeGroup = true;
+ }
+ break;
+ case RTF_FTNSEP:
+ m_aStates.top().nDestinationState = DESTINATION_FOOTNOTESEPARATOR;
+ m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdn_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator)));
+ break;
+ default:
+ {
+ // Check if it's a math token.
+ RTFMathSymbol aSymbol;
+ aSymbol.eKeyword = nKeyword;
+ if (RTFTokenizer::lookupMathKeyword(aSymbol))
+ {
+ m_aMathBuffer.appendOpeningTag(aSymbol.nToken);
+ m_aStates.top().nDestinationState = aSymbol.eDestination;
+ return 0;
+ }
+
+ SAL_INFO("writerfilter", "TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
+ // Make sure we skip destinations (even without \*) till we don't handle them
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ aSkip.setParsed(false);
+ }
+ break;
+ }
+
+ return 0;
}
int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
@@ -1892,7 +1938,8 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
RTFSkipDestination aSkip(*this);
if (RTF_LINE == nKeyword)
- { // very special handling since text() will eat lone '\n'
+ {
+ // very special handling since text() will eat lone '\n'
singleChar('\n');
return 0;
}
@@ -1900,18 +1947,41 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
sal_uInt8 cCh = 0;
switch (nKeyword)
{
- case RTF_TAB: cCh = '\t'; break;
- case RTF_BACKSLASH: cCh = '\\'; break;
- case RTF_LBRACE: cCh = '{'; break;
- case RTF_RBRACE: cCh = '}'; break;
- case RTF_EMDASH: cCh = 151; break;
- case RTF_ENDASH: cCh = 150; break;
- case RTF_BULLET: cCh = 149; break;
- case RTF_LQUOTE: cCh = 145; break;
- case RTF_RQUOTE: cCh = 146; break;
- case RTF_LDBLQUOTE: cCh = 147; break;
- case RTF_RDBLQUOTE: cCh = 148; break;
- default: break;
+ case RTF_TAB:
+ cCh = '\t';
+ break;
+ case RTF_BACKSLASH:
+ cCh = '\\';
+ break;
+ case RTF_LBRACE:
+ cCh = '{';
+ break;
+ case RTF_RBRACE:
+ cCh = '}';
+ break;
+ case RTF_EMDASH:
+ cCh = 151;
+ break;
+ case RTF_ENDASH:
+ cCh = 150;
+ break;
+ case RTF_BULLET:
+ cCh = 149;
+ break;
+ case RTF_LQUOTE:
+ cCh = 145;
+ break;
+ case RTF_RQUOTE:
+ cCh = 146;
+ break;
+ case RTF_LDBLQUOTE:
+ cCh = 147;
+ break;
+ case RTF_RDBLQUOTE:
+ cCh = 148;
+ break;
+ default:
+ break;
}
if (cCh > 0)
{
@@ -1922,296 +1992,297 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
switch (nKeyword)
{
- case RTF_IGNORE:
- {
- m_bSkipUnknown = true;
- aSkip.setReset(false);
- return 0;
- }
- break;
- case RTF_PAR:
- {
- checkFirstRun();
- bool bNeedPap = m_bNeedPap;
- checkNeedPap();
- if (bNeedPap)
- runProps();
- if (!m_aStates.top().pCurrentBuffer)
- {
- if (m_aStates.top().nDestinationState == DESTINATION_FOOTNOTESEPARATOR)
- {
- static const sal_Unicode uCR = 0xd;
- Mapper().utext((const sal_uInt8*)&uCR, 1);
- }
- else
- parBreak();
- // Not in table? Reset max width.
- m_nCellxMax = 0;
- }
- else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
- {
- RTFValue::Pointer_t pValue;
- m_aStates.top().pCurrentBuffer->push_back(
- Buf_t(BUFFER_PAR, pValue));
- }
- // but don't emit properties yet, since they may change till the first text token arrives
- m_bNeedPap = true;
- if (!m_aStates.top().aFrame.inFrame())
- m_bNeedPar = false;
- m_bNeedFinalPar = false;
- }
- break;
- case RTF_SECT:
- {
- m_bHadSect = true;
- if (m_bIgnoreNextContSectBreak)
- m_bIgnoreNextContSectBreak = false;
- else
- {
- sectBreak();
- if (m_nResetBreakOnSectBreak != RTF_invalid)
- { // this should run on _second_ \sect after \page
- dispatchSymbol(m_nResetBreakOnSectBreak); // lazy reset
- m_nResetBreakOnSectBreak = RTF_invalid;
- m_bNeedSect = false; // dispatchSymbol set it
- }
- }
- }
- break;
- case RTF_NOBREAK:
- {
- OUString aStr(SVT_HARD_SPACE);
- text(aStr);
- }
- break;
- case RTF_NOBRKHYPH:
+ case RTF_IGNORE:
+ {
+ m_bSkipUnknown = true;
+ aSkip.setReset(false);
+ return 0;
+ }
+ break;
+ case RTF_PAR:
+ {
+ checkFirstRun();
+ bool bNeedPap = m_bNeedPap;
+ checkNeedPap();
+ if (bNeedPap)
+ runProps();
+ if (!m_aStates.top().pCurrentBuffer)
+ {
+ if (m_aStates.top().nDestinationState == DESTINATION_FOOTNOTESEPARATOR)
{
- OUString aStr(SVT_HARD_HYPHEN);
- text(aStr);
+ static const sal_Unicode uCR = 0xd;
+ Mapper().utext((const sal_uInt8*)&uCR, 1);
}
- break;
- case RTF_OPTHYPH:
+ else
+ parBreak();
+ // Not in table? Reset max width.
+ m_nCellxMax = 0;
+ }
+ else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
+ {
+ RTFValue::Pointer_t pValue;
+ m_aStates.top().pCurrentBuffer->push_back(
+ Buf_t(BUFFER_PAR, pValue));
+ }
+ // but don't emit properties yet, since they may change till the first text token arrives
+ m_bNeedPap = true;
+ if (!m_aStates.top().aFrame.inFrame())
+ m_bNeedPar = false;
+ m_bNeedFinalPar = false;
+ }
+ break;
+ case RTF_SECT:
+ {
+ m_bHadSect = true;
+ if (m_bIgnoreNextContSectBreak)
+ m_bIgnoreNextContSectBreak = false;
+ else
+ {
+ sectBreak();
+ if (m_nResetBreakOnSectBreak != RTF_invalid)
{
- OUString aStr(SVT_SOFT_HYPHEN);
- text(aStr);
+ // this should run on _second_ \sect after \page
+ dispatchSymbol(m_nResetBreakOnSectBreak); // lazy reset
+ m_nResetBreakOnSectBreak = RTF_invalid;
+ m_bNeedSect = false; // dispatchSymbol set it
}
- break;
- case RTF_HEXCHAR:
- m_aStates.top().nInternalState = INTERNAL_HEX;
- break;
- case RTF_CELL:
- case RTF_NESTCELL:
- {
- checkFirstRun();
- if (m_bNeedPap)
- {
- // There were no runs in the cell, so we need to send paragraph and character properties here.
- RTFValue::Pointer_t pPValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
- m_aTableBufferStack.back().push_back(
- Buf_t(BUFFER_PROPS, pPValue));
- RTFValue::Pointer_t pCValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
- m_aTableBufferStack.back().push_back(
- Buf_t(BUFFER_PROPS, pCValue));
- }
+ }
+ }
+ break;
+ case RTF_NOBREAK:
+ {
+ OUString aStr(SVT_HARD_SPACE);
+ text(aStr);
+ }
+ break;
+ case RTF_NOBRKHYPH:
+ {
+ OUString aStr(SVT_HARD_HYPHEN);
+ text(aStr);
+ }
+ break;
+ case RTF_OPTHYPH:
+ {
+ OUString aStr(SVT_SOFT_HYPHEN);
+ text(aStr);
+ }
+ break;
+ case RTF_HEXCHAR:
+ m_aStates.top().nInternalState = INTERNAL_HEX;
+ break;
+ case RTF_CELL:
+ case RTF_NESTCELL:
+ {
+ checkFirstRun();
+ if (m_bNeedPap)
+ {
+ // There were no runs in the cell, so we need to send paragraph and character properties here.
+ RTFValue::Pointer_t pPValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
+ m_aTableBufferStack.back().push_back(
+ Buf_t(BUFFER_PROPS, pPValue));
+ RTFValue::Pointer_t pCValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
+ m_aTableBufferStack.back().push_back(
+ Buf_t(BUFFER_PROPS, pCValue));
+ }
- RTFValue::Pointer_t pValue;
- m_aTableBufferStack.back().push_back(
- Buf_t(BUFFER_CELLEND, pValue));
- m_bNeedPap = true;
- }
- break;
- case RTF_NESTROW:
+ RTFValue::Pointer_t pValue;
+ m_aTableBufferStack.back().push_back(
+ Buf_t(BUFFER_CELLEND, pValue));
+ m_bNeedPap = true;
+ }
+ break;
+ case RTF_NESTROW:
+ {
+ boost::shared_ptr<TableRowBuffer> const pBuffer(
+ new TableRowBuffer(
+ m_aTableBufferStack.back(),
+ m_aNestedTableCellsSprms,
+ m_aNestedTableCellsAttributes,
+ m_nNestedCells));
+ prepareProperties(m_aStates.top(),
+ pBuffer->pParaProperties,
+ pBuffer->pFrameProperties,
+ pBuffer->pRowProperties,
+ m_nNestedCells, m_nNestedCurrentCellX);
+
+ assert(m_aStates.top().pCurrentBuffer == &m_aTableBufferStack.back());
+ if (m_aTableBufferStack.size() == 1)
+ {
+ throw io::WrongFormatException(
+ "mismatch between \\itap and number of \\nestrow", 0);
+ }
+ // note: there may be several states pointing to table buffer!
+ for (size_t i = 0; i < m_aStates.size(); ++i)
+ {
+ if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back())
{
- boost::shared_ptr<TableRowBuffer> const pBuffer(
- new TableRowBuffer(
- m_aTableBufferStack.back(),
- m_aNestedTableCellsSprms,
- m_aNestedTableCellsAttributes,
- m_nNestedCells));
- prepareProperties(m_aStates.top(),
- pBuffer->pParaProperties,
- pBuffer->pFrameProperties,
- pBuffer->pRowProperties,
- m_nNestedCells, m_nNestedCurrentCellX);
-
- assert(m_aStates.top().pCurrentBuffer == &m_aTableBufferStack.back());
- if (m_aTableBufferStack.size() == 1)
- {
- throw io::WrongFormatException(
- "mismatch between \\itap and number of \\nestrow", 0);
- }
- // note: there may be several states pointing to table buffer!
- for (size_t i = 0; i < m_aStates.size(); ++i)
- {
- if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back())
- {
- m_aStates[i].pCurrentBuffer =
- &m_aTableBufferStack[m_aTableBufferStack.size()-2];
- }
- }
- m_aTableBufferStack.pop_back();
- m_aTableBufferStack.back().push_back(
- Buf_t(BUFFER_NESTROW, RTFValue::Pointer_t(), pBuffer));
-
- m_aNestedTableCellsSprms.clear();
- m_aNestedTableCellsAttributes.clear();
- m_nNestedCells = 0;
- m_bNeedPap = true;
+ m_aStates[i].pCurrentBuffer =
+ &m_aTableBufferStack[m_aTableBufferStack.size()-2];
}
- break;
- case RTF_ROW:
- {
- bool bRestored = false;
- // Ending a row, but no cells defined?
- // See if there was an invalid table row reset, so we can restore cell infos to help invalid documents.
- if (!m_nTopLevelCurrentCellX && m_nBackupTopLevelCurrentCellX)
- {
- restoreTableRowProperties();
- bRestored = true;
- }
+ }
+ m_aTableBufferStack.pop_back();
+ m_aTableBufferStack.back().push_back(
+ Buf_t(BUFFER_NESTROW, RTFValue::Pointer_t(), pBuffer));
- // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): add a fake cell.
- const int MINLAY = 23; // sw/inc/swtypes.hxx, minimal possible size of frames.
- if ((m_nCellxMax - m_nTopLevelCurrentCellX) >= MINLAY)
- dispatchValue(RTF_CELLX, m_nCellxMax);
+ m_aNestedTableCellsSprms.clear();
+ m_aNestedTableCellsAttributes.clear();
+ m_nNestedCells = 0;
+ m_bNeedPap = true;
+ }
+ break;
+ case RTF_ROW:
+ {
+ bool bRestored = false;
+ // Ending a row, but no cells defined?
+ // See if there was an invalid table row reset, so we can restore cell infos to help invalid documents.
+ if (!m_nTopLevelCurrentCellX && m_nBackupTopLevelCurrentCellX)
+ {
+ restoreTableRowProperties();
+ bRestored = true;
+ }
- if (m_nTopLevelCells)
- {
- // Make a backup before we start popping elements
- m_aTableInheritingCellsSprms = m_aTopLevelTableCellsSprms;
- m_aTableInheritingCellsAttributes = m_aTopLevelTableCellsAttributes;
- m_nInheritingCells = m_nTopLevelCells;
- }
- else
- {
- // No table definition? Then inherit from the previous row
- m_aTopLevelTableCellsSprms = m_aTableInheritingCellsSprms;
- m_aTopLevelTableCellsAttributes = m_aTableInheritingCellsAttributes;
- m_nTopLevelCells = m_nInheritingCells;
- }
+ // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic WW8TabDesc::CalcDefaults(): add a fake cell.
+ const int MINLAY = 23; // sw/inc/swtypes.hxx, minimal possible size of frames.
+ if ((m_nCellxMax - m_nTopLevelCurrentCellX) >= MINLAY)
+ dispatchValue(RTF_CELLX, m_nCellxMax);
- while (m_aTableBufferStack.size() > 1)
- {
- SAL_WARN("writerfilter.rtf", "dropping extra table buffer");
- // note: there may be several states pointing to table buffer!
- for (size_t i = 0; i < m_aStates.size(); ++i)
- {
- if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back())
- {
- m_aStates[i].pCurrentBuffer =
- &m_aTableBufferStack.front();
- }
- }
- m_aTableBufferStack.pop_back();
- }
+ if (m_nTopLevelCells)
+ {
+ // Make a backup before we start popping elements
+ m_aTableInheritingCellsSprms = m_aTopLevelTableCellsSprms;
+ m_aTableInheritingCellsAttributes = m_aTopLevelTableCellsAttributes;
+ m_nInheritingCells = m_nTopLevelCells;
+ }
+ else
+ {
+ // No table definition? Then inherit from the previous row
+ m_aTopLevelTableCellsSprms = m_aTableInheritingCellsSprms;
+ m_aTopLevelTableCellsAttributes = m_aTableInheritingCellsAttributes;
+ m_nTopLevelCells = m_nInheritingCells;
+ }
- replayRowBuffer(m_aTableBufferStack.back(),
- m_aTopLevelTableCellsSprms, m_aTopLevelTableCellsAttributes,
- m_nTopLevelCells);
-
- m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
- m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
-
- writerfilter::Reference<Properties>::Pointer_t paraProperties;
- writerfilter::Reference<Properties>::Pointer_t frameProperties;
- writerfilter::Reference<Properties>::Pointer_t rowProperties;
- prepareProperties(m_aStates.top(),
- paraProperties, frameProperties, rowProperties,
- m_nTopLevelCells, m_nTopLevelCurrentCellX);
- sendProperties(paraProperties, frameProperties, rowProperties);
-
- m_bNeedPap = true;
- m_bNeedFinalPar = true;
- m_aTableBufferStack.back().clear();
- m_nTopLevelCells = 0;
-
- if (bRestored)
- // We restored cell definitions, clear these now.
- // This is necessary, as later cell definitions want to overwrite the restored ones.
- resetTableRowProperties();
- }
- break;
- case RTF_COLUMN:
- {
- bool bColumns = false; // If we have multiple columns
- RTFValue::Pointer_t pCols = m_aStates.top().aSectionSprms.find(NS_ooxml::LN_EG_SectPrContents_cols);
- if (pCols.get())
- {
- RTFValue::Pointer_t pNum = pCols->getAttributes().find(NS_ooxml::LN_CT_Columns_num);
- if (pNum.get() && pNum->getInt() > 1)
- bColumns = true;
- }
- if (bColumns)
- {
- sal_uInt8 sBreak[] = { 0xe };
- Mapper().startCharacterGroup();
- Mapper().text(sBreak, 1);
- Mapper().endCharacterGroup();
- }
- else
- dispatchSymbol(RTF_PAGE);
- }
- break;
- case RTF_CHFTN:
- // Nothing to do, dmapper assumes this is the default.
- break;
- case RTF_PAGE:
+ while (m_aTableBufferStack.size() > 1)
+ {
+ SAL_WARN("writerfilter.rtf", "dropping extra table buffer");
+ // note: there may be several states pointing to table buffer!
+ for (size_t i = 0; i < m_aStates.size(); ++i)
{
- // If we're inside a continuous section, we should send a section break, not a page one.
- RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_ooxml::LN_EG_SectPrContents_type);
- // Unless we're on a title page.
- RTFValue::Pointer_t pTitlePg = m_aStates.top().aSectionSprms.find(NS_ooxml::LN_EG_SectPrContents_titlePg);
- if (((pBreak.get() && !pBreak->getInt())
- || m_nResetBreakOnSectBreak == RTF_SBKNONE)
- && !(pTitlePg.get() && pTitlePg->getInt()))
- {
- if (m_bWasInFrame)
- {
- dispatchSymbol(RTF_PAR);
- m_bWasInFrame = false;
- }
- sectBreak();
- // note: this will not affect the following section break
- // but the one just pushed
- dispatchFlag(RTF_SBKPAGE);
- if (m_bNeedPar)
- dispatchSymbol(RTF_PAR);
- m_bIgnoreNextContSectBreak = true;
- // arrange to clean up the syntetic RTF_SBKPAGE
- m_nResetBreakOnSectBreak = RTF_SBKNONE;
- }
- else
+ if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back())
{
- checkNeedPap();
- sal_uInt8 sBreak[] = { 0xc };
- Mapper().text(sBreak, 1);
- if (!m_bNeedPap)
- parBreak();
- m_bNeedCr = true;
+ m_aStates[i].pCurrentBuffer =
+ &m_aTableBufferStack.front();
}
}
- break;
- case RTF_CHPGN:
- {
- OUString aStr("PAGE");
- singleChar(0x13);
- text(aStr);
- singleChar(0x14, true);
- singleChar(0x15);
- }
- break;
- case RTF_CHFTNSEP:
- {
- static const sal_Unicode uFtnEdnSep = 0x3;
- Mapper().utext((const sal_uInt8*)&uFtnEdnSep, 1);
- }
- break;
- default:
+ m_aTableBufferStack.pop_back();
+ }
+
+ replayRowBuffer(m_aTableBufferStack.back(),
+ m_aTopLevelTableCellsSprms, m_aTopLevelTableCellsAttributes,
+ m_nTopLevelCells);
+
+ m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
+ m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
+
+ writerfilter::Reference<Properties>::Pointer_t paraProperties;
+ writerfilter::Reference<Properties>::Pointer_t frameProperties;
+ writerfilter::Reference<Properties>::Pointer_t rowProperties;
+ prepareProperties(m_aStates.top(),
+ paraProperties, frameProperties, rowProperties,
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list