summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-12 11:07:41 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-13 15:23:53 +0200
commit8c0a8d9db351fc05534d7552036889543f3a89d4 (patch)
tree9c800b812b57ee35f38ddb2108d48d65d63ca44f
parentd211641cc616d684406efce8de468ffe1ca4253e (diff)
writerfilter: read w:commentRangeStart and w:commentRangeEnd elements
Change-Id: I8da1e43ffe6a78f14ab0901ae73c4ee39f1cbe44
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx44
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx10
-rw-r--r--writerfilter/source/ooxml/model.xml16
4 files changed, 72 insertions, 4 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9d2bc189dcf5..d6589bb4fa81 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 a69e9115e4db..ec7bf74976fe 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 ce56e22678db..2a49c696e406 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 4d0d191f7c4d..10965f22c05b 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"/>