writerfilter: read w:commentRangeStart and w:commentRangeEnd elements
Change-Id: I8da1e43ffe6a78f14ab0901ae73c4ee39f1cbe44
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9d2bc18..d6589bb 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1355,6 +1355,12 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Markup_id:
m_pImpl->SetCurrentRedlineId( nIntValue );
break;
case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart:
m_pImpl->AddAnnotationPosition(true);
break;
case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd:
m_pImpl->AddAnnotationPosition(false);
break;
case NS_ooxml::LN_token:
m_pImpl->SetCurrentRedlineToken( nIntValue );
break;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a69e911..ec7bf74 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1518,8 +1518,28 @@ void DomainMapper_Impl::PopFootOrEndnote()
void DomainMapper_Impl::PopAnnotation()
{
m_aTextAppendStack.pop();
uno::Sequence< beans::PropertyValue > aEmptyProperties;
appendTextContent( uno::Reference< text::XTextContent >( m_xAnnotationField, uno::UNO_QUERY_THROW ), aEmptyProperties );
// See if the annotation will be a single position or a range.
if (!m_aAnnotationPosition.m_xStart.is() || !m_aAnnotationPosition.m_xEnd.is())
{
uno::Sequence< beans::PropertyValue > aEmptyProperties;
appendTextContent( uno::Reference< text::XTextContent >( m_xAnnotationField, uno::UNO_QUERY_THROW ), aEmptyProperties );
}
else
{
// Create a range that points to the annotation start/end.
uno::Reference<text::XText> xText = m_aAnnotationPosition.m_xStart->getText();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursorByRange(m_aAnnotationPosition.m_xStart);
xCursor->gotoRange(m_aAnnotationPosition.m_xEnd, true);
uno::Reference<text::XTextRange> xTextRange(xCursor, uno::UNO_QUERY_THROW);
// Attach the annotation to the range.
uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
xTextAppend->insertTextContent(xTextRange, uno::Reference<text::XTextContent>(m_xAnnotationField, uno::UNO_QUERY_THROW), !xCursor->isCollapsed());
}
m_aAnnotationPosition.m_xStart.clear();
m_aAnnotationPosition.m_xEnd.clear();
m_xAnnotationField.clear();
}
@@ -3313,6 +3333,26 @@ void DomainMapper_Impl::AddBookmark( const ::rtl::OUString& rBookmarkName, const
}
}
void DomainMapper_Impl::AddAnnotationPosition(const bool bStart)
{
if (m_aTextAppendStack.empty())
return;
// Create a cursor, pointing to the current position.
uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
uno::Reference<text::XTextRange> xCurrent;
if (xTextAppend.is())
{
uno::Reference<text::XTextCursor> xCursor = xTextAppend->createTextCursorByRange(xTextAppend->getEnd());
xCurrent = xCursor->getStart();
}
// And save it, to be used by PopAnnotation() later.
if (bStart)
m_aAnnotationPosition.m_xStart = xCurrent;
else
m_aAnnotationPosition.m_xEnd = xCurrent;
}
GraphicImportPtr DomainMapper_Impl::GetGraphicImport(GraphicImportType eGraphicImportType)
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index ce56e22..2a49c69 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -235,6 +235,13 @@ struct BookmarkInsertPosition
{}
};
/// Stores the start/end positions of an annotation before its insertion.
struct AnnotationPosition
{
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStart;
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xEnd;
};
struct RedlineParams
{
::rtl::OUString m_sAuthor;
@@ -350,6 +357,7 @@ private:
//annotation import
uno::Reference< beans::XPropertySet > m_xAnnotationField;
AnnotationPosition m_aAnnotationPosition;
void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale);
void SetNumberFormat( const ::rtl::OUString& rCommand,
@@ -545,6 +553,8 @@ public:
void AddBookmark( const ::rtl::OUString& rBookmarkName, const ::rtl::OUString& rId );
void AddAnnotationPosition(const bool bStart);
DomainMapperTableManager& getTableManager()
{
boost::shared_ptr< DomainMapperTableManager > pMngr = m_aTableManagers.top();
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 4d0d191..10965f2 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -14503,6 +14503,12 @@
</attribute>
<ref name="CT_MarkupRange"/>
</define>
<define name="CT_MarkupRangeCommentStart">
<ref name="CT_Markup"/>
</define>
<define name="CT_MarkupRangeCommentEnd">
<ref name="CT_Markup"/>
</define>
<define name="CT_BookmarkRange">
<ref name="CT_MarkupRangeBookmark"/>
<optional>
@@ -14666,10 +14672,10 @@
<ref name="CT_MarkupRange"/>
</element>
<element name="commentRangeStart">
<ref name="CT_MarkupRange"/>
<ref name="CT_MarkupRangeCommentStart"/>
</element>
<element name="commentRangeEnd">
<ref name="CT_MarkupRange"/>
<ref name="CT_MarkupRangeCommentEnd"/>
</element>
<element name="customXmlInsRangeStart">
<ref name="CT_TrackChange"/>
@@ -21958,6 +21964,12 @@
<resource name="CT_MarkupRangeBookmark" resource="Properties" tag="redline">
<attribute name="id" tokenid="rtf:IBKL"/>
</resource>
<resource name="CT_MarkupRangeCommentStart" resource="Properties" tag="content">
<attribute name="id" tokenid="ooxml:EG_RangeMarkupElements_commentRangeStart"/>
</resource>
<resource name="CT_MarkupRangeCommentEnd" resource="Properties" tag="content">
<attribute name="id" tokenid="ooxml:EG_RangeMarkupElements_commentRangeEnd"/>
</resource>
<resource name="CT_BookmarkRange" resource="Properties" tag="reference">
<type name="Bookmark"/>
<attribute name="colFirst" tokenid="ooxml:CT_BookmarkRange_colFirst"/>