[Libreoffice-commits] .: 6 commits - sw/source writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Fri Jul 13 06:24:00 PDT 2012
sw/source/core/unocore/unofield.cxx | 3 -
sw/source/filter/ww8/attributeoutputbase.hxx | 6 ++
sw/source/filter/ww8/docxattributeoutput.cxx | 29 +++++++++++++
sw/source/filter/ww8/docxattributeoutput.hxx | 10 ++++
sw/source/filter/ww8/wrtw8nds.cxx | 21 ++++++++--
writerfilter/source/dmapper/DomainMapper.cxx | 6 ++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 46 +++++++++++++++++++++-
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 10 ++++
writerfilter/source/ooxml/model.xml | 16 ++++++-
9 files changed, 139 insertions(+), 8 deletions(-)
New commits:
commit c097f7a3743246360bbae10e85a10eb00760edde
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jul 13 12:22:31 2012 +0200
dmapper: remove last paragraph of annotations
See commit 94855fbbb977d6acd42c32e157af664d0ede9739 for rationale.
Change-Id: I34838ea9dd60f24d20ac48e6089915b506f5d790
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ec7bf74..e02f53b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1517,6 +1517,8 @@ void DomainMapper_Impl::PopFootOrEndnote()
void DomainMapper_Impl::PopAnnotation()
{
+ RemoveLastParagraph();
+
m_aTextAppendStack.pop();
// See if the annotation will be a single position or a range.
commit 423433ee105faea7775a3869dbf4054ab960480c
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jul 13 11:42:28 2012 +0200
DocxAttributeOutput: overwrite WritePostitFieldStart/End
Change-Id: If8ecbc9a831f26cab81ba47af9114b608592524b
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index e5af719..4d14585 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -566,6 +566,7 @@ void DocxAttributeOutput::EndRun()
}
DoWriteBookmarks( );
+ WriteCommentRanges();
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); // merges with "postponed run start", see above
@@ -593,6 +594,22 @@ void DocxAttributeOutput::EndRun()
EndRedline();
}
+void DocxAttributeOutput::WriteCommentRanges()
+{
+ if (m_bPostitStart)
+ {
+ m_bPostitStart = false;
+ OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
+ m_pSerializer->singleElementNS( XML_w, XML_commentRangeStart, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
+ }
+ if (m_bPostitEnd)
+ {
+ m_bPostitEnd = false;
+ OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
+ m_pSerializer->singleElementNS( XML_w, XML_commentRangeEnd, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
+ }
+}
+
void DocxAttributeOutput::DoWriteBookmarks()
{
// Write the start bookmarks
@@ -3323,6 +3340,16 @@ void DocxAttributeOutput::WritePostitFieldReference()
}
}
+void DocxAttributeOutput::WritePostitFieldStart()
+{
+ m_bPostitStart = true;
+}
+
+void DocxAttributeOutput::WritePostitFieldEnd()
+{
+ m_bPostitEnd = true;
+}
+
void DocxAttributeOutput::WritePostitFields()
{
for( unsigned int i = 0;
@@ -4301,6 +4328,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_bOpenedSectPr( false ),
m_sFieldBkm( ),
m_nNextMarkId( 0 ),
+ m_bPostitStart(false),
+ m_bPostitEnd(false),
m_pTableWrt( NULL ),
m_bTableCellOpen( false ),
m_nTableDepth( 0 ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 99265a0..ca863ae 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -98,6 +98,10 @@ public:
virtual void WritePostitFieldReference();
+ virtual void WritePostitFieldStart();
+
+ virtual void WritePostitFieldEnd();
+
/// Output text (inside a run).
virtual void RunText( const String& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 );
@@ -522,6 +526,7 @@ private:
void DoWriteBookmarks( );
void WritePostponedGraphic();
void WritePostponedMath();
+ void WriteCommentRanges();
void StartField_Impl( FieldInfos& rInfos, bool bWriteRun = sal_False );
void DoWriteCmd( String& rCmd );
@@ -559,6 +564,11 @@ private:
std::vector<rtl::OString> m_rMarksStart;
std::vector<rtl::OString> m_rMarksEnd;
+ /// Is there a postit start to output?
+ bool m_bPostitStart;
+ /// Is there a postit end to output?
+ bool m_bPostitEnd;
+
/// Maps of the bookmarks ids
std::map<rtl::OString, sal_uInt16> m_rOpenedMarksIds;
commit 2e6f9dff530f16db33c52ab289efe18f96f71bb0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jul 13 11:41:40 2012 +0200
MSWordExportBase::OutputTextNode: recognize COMMENTRANGE fieldmarks
Change-Id: I5ad751ff6573d0bac884afaafe48af33cd441b2b
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 9d6daf4..0286004 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -176,6 +176,12 @@ public:
/// for docx w:commentReference
virtual void WritePostitFieldReference() {};
+ /// for docx w:commentRangeStart
+ virtual void WritePostitFieldStart() {};
+
+ /// for docx w:commentRangeEnd
+ virtual void WritePostitFieldEnd() {};
+
/// Output text (inside a run).
virtual void RunText( const String& rText, rtl_TextEncoding eCharSet ) = 0;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index a31f2f0..498f65a 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1862,12 +1862,19 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
sCode = sOUCode;
}
}
- OutputField( NULL, eFieldId, sCode, WRITEFIELD_START | WRITEFIELD_CMD_START );
+
+ bool bCommentRange = pFieldmark && pFieldmark->GetFieldname() == ODF_COMMENTRANGE;
+ if (bCommentRange)
+ AttrOutput().WritePostitFieldStart();
+ else
+ OutputField( NULL, eFieldId, sCode, WRITEFIELD_START | WRITEFIELD_CMD_START );
+
if ( pFieldmark && pFieldmark->GetFieldname( ) == ODF_FORMTEXT )
WriteFormData( *pFieldmark );
else if ( pFieldmark && pFieldmark->GetFieldname( ) == ODF_HYPERLINK )
WriteHyperlinkData( *pFieldmark );
- OutputField( NULL, lcl_getFieldId( pFieldmark ), String(), WRITEFIELD_CMD_END );
+ if (!bCommentRange)
+ OutputField( NULL, lcl_getFieldId( pFieldmark ), String(), WRITEFIELD_CMD_END );
if ( pFieldmark && pFieldmark->GetFieldname() == ODF_UNHANDLED )
{
@@ -1902,7 +1909,11 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
}
}
- OutputField( NULL, eFieldId, String(), WRITEFIELD_CLOSE );
+ if (pFieldmark && pFieldmark->GetFieldname() == ODF_COMMENTRANGE)
+ AttrOutput().WritePostitFieldEnd();
+ else
+ OutputField( NULL, eFieldId, String(), WRITEFIELD_CLOSE );
+
if ( pFieldmark && pFieldmark->GetFieldname() == ODF_FORMTEXT )
AppendBookmark( pFieldmark->GetName(), false );
}
commit 9370212be859ab828b67a486657ee399a6ff2dcd
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Jul 12 18:27:03 2012 +0200
MSWordExportBase::GetBookmarks: COMMENTRANGE fieldmarks are not bookmarks
Change-Id: Ifd4810cf1b4c7a8ea6b080b35d902e66a93eb5c7
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 0a946b8..a31f2f0 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1649,6 +1649,10 @@ bool MSWordExportBase::GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt,
bool bIsStartOk = ( nBStart >= nStt ) && ( nBStart <= nEnd );
bool bIsEndOk = ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
+ IFieldmark* pFieldmark = dynamic_cast<IFieldmark*>(pMark);
+ if (pFieldmark && pFieldmark->GetFieldname() == ODF_COMMENTRANGE)
+ continue;
+
if ( bIsStartOk || bIsEndOk )
rArr.push_back( pMark );
}
commit 8c0a8d9db351fc05534d7552036889543f3a89d4
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Jul 12 11:07:41 2012 +0200
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"/>
commit d211641cc616d684406efce8de468ffe1ca4253e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Jul 12 12:56:31 2012 +0200
SwXTextField: make sure we always insert the field at the end
Change-Id: I5070a4226affaa274e3fbe61d2f2cd182c8bc3bf
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index ab20015..1940bbe 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1761,7 +1761,8 @@ void SwXTextField::attachToRange(
OUString(),
ODF_COMMENTRANGE);
- SwPaM aEnd(*aPam.GetMark(), *aPam.GetMark());
+ // Make sure we always insert the field at the end
+ SwPaM aEnd(*aPam.End(), *aPam.End());
pDoc->InsertPoolItem(aEnd, aFmt, nInsertFlags);
}
else
More information about the Libreoffice-commits
mailing list