summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-15 20:29:48 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-15 20:32:44 +0100
commit30696e84268de28d8eec58693eed2d3df98ef82e (patch)
treeb64e67482d39f56ca20e7b1dd48605cd1be3f338 /sw
parent4a924576e415f16e0571542bb0d683529f9046ff (diff)
RTF export: fix nested comments
Change-Id: I9986855f3160ed6f5856aec9f7d33fc416962e77
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_rtfexport.mk1
-rw-r--r--sw/qa/extras/rtfexport/data/comments-nested.odtbin0 -> 11343 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx9
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx30
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx8
5 files changed, 32 insertions, 16 deletions
diff --git a/sw/CppunitTest_sw_rtfexport.mk b/sw/CppunitTest_sw_rtfexport.mk
index 01b9378f12ed..46227ddefd38 100644
--- a/sw/CppunitTest_sw_rtfexport.mk
+++ b/sw/CppunitTest_sw_rtfexport.mk
@@ -71,6 +71,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_rtfexport,\
ucb/source/ucp/file/ucpfile1 \
unotools/util/utl \
unoxml/source/service/unoxml \
+ uui/util/uui \
writerfilter/util/writerfilter \
xmloff/util/xo \
))
diff --git a/sw/qa/extras/rtfexport/data/comments-nested.odt b/sw/qa/extras/rtfexport/data/comments-nested.odt
new file mode 100644
index 000000000000..e7686058dd3f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/comments-nested.odt
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 2f9a82be9fdd..49e7dfbef316 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -156,6 +156,15 @@ DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
}
+DECLARE_RTFEXPORT_TEST(testCommentsNested, "comments-nested.odt")
+{
+ uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content"));
+
+ uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
+}
+
DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
{
OUString aActual = getFormula(getRun(getParagraph(1), 1));
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 4df549c473ee..ba75e6986908 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1480,8 +1480,7 @@ void RtfAttributeOutput::WriteAnnotationMarks_Impl( std::vector< OUString >& rSt
// Output the annotation mark
sal_uInt16 nId = m_nNextAnnotationMarkId++;
- const SwPostItField* pField = 0; // This will be set by PostitField().
- m_rOpenedAnnotationMarksIds[rName] = std::make_pair(nId, pField);
+ m_rOpenedAnnotationMarksIds[rName] = nId;
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
m_aRun->append(OString::number(nId).getStr());
m_aRun->append('}');
@@ -1493,20 +1492,21 @@ void RtfAttributeOutput::WriteAnnotationMarks_Impl( std::vector< OUString >& rSt
OString rName = OUStringToOString( *i, RTL_TEXTENCODING_UTF8 );
// Get the id of the annotation mark
- std::map< OString, std::pair<sal_uInt16, const SwPostItField*> >::iterator it = m_rOpenedAnnotationMarksIds.find( rName );
+ std::map<OString, sal_uInt16>::iterator it = m_rOpenedAnnotationMarksIds.find(rName);
if (it != m_rOpenedAnnotationMarksIds.end())
{
- sal_uInt16 nId = ( *it ).second.first;
- const SwPostItField* pField = ( *it ).second.second;
+ sal_uInt16 nId = it->second;
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFEND " ");
m_aRun->append(OString::number(nId).getStr());
m_aRun->append('}');
m_rOpenedAnnotationMarksIds.erase( rName );
- if (pField)
+ if (m_aPostitFields.find(nId) != m_aPostitFields.end())
{
m_aRunText->append("{");
- PostitField(pField);
+ m_nCurrentAnnotationMarkId = nId;
+ PostitField(m_aPostitFields[nId]);
+ m_nCurrentAnnotationMarkId = -1;
m_aRunText->append("}");
}
}
@@ -3227,12 +3227,12 @@ void RtfAttributeOutput::PostitField( const SwField* pFld )
const SwPostItField& rPFld = *(SwPostItField*)pFld;
OString aName = OUStringToOString(rPFld.GetName(), RTL_TEXTENCODING_UTF8);
- std::map< OString, std::pair<sal_uInt16, const SwPostItField*> >::iterator it = m_rOpenedAnnotationMarksIds.find(aName);
+ std::map<OString, sal_uInt16>::iterator it = m_rOpenedAnnotationMarksIds.find(aName);
if (it != m_rOpenedAnnotationMarksIds.end())
{
// In case this field is inside annotation marks, we want to write the
// annotation itself after the annotation mark is closed, not here.
- it->second.second = &rPFld;
+ m_aPostitFields[it->second] = &rPFld;
return;
}
@@ -3245,9 +3245,13 @@ void RtfAttributeOutput::PostitField( const SwField* pFld )
m_aRunText->append(OOO_STRING_SVTOOLS_RTF_CHATN);
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
- m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNREF " ");
- m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId++));
- m_aRunText->append('}');
+
+ if (m_nCurrentAnnotationMarkId != -1)
+ {
+ m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNREF " ");
+ m_aRunText->append(m_nCurrentAnnotationMarkId);
+ m_aRunText->append('}');
+ }
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
m_aRunText->append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDateTime()));
m_aRunText->append('}');
@@ -3273,6 +3277,7 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
: m_rExport( rExport ),
m_bStrikeDouble( false ),
m_nNextAnnotationMarkId(0),
+ m_nCurrentAnnotationMarkId(-1),
m_pTableWrt( NULL ),
m_bTableCellOpen( false ),
m_nTableDepth( 0 ),
@@ -3287,7 +3292,6 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
m_aCells(),
m_bSingleEmptyRun(false),
m_bInRun(false),
- m_nPostitFieldsMaxId(0),
m_pFlyFrameSize(0),
m_pPrevPageDesc(0)
{
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 5a358815502a..0f350730192e 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -500,8 +500,9 @@ private:
bool m_bStrikeDouble;
sal_Int32 m_nNextAnnotationMarkId;
- /// Map of the annotation marks ids
- std::map< OString, std::pair<sal_uInt16, const SwPostItField*> > m_rOpenedAnnotationMarksIds;
+ sal_Int32 m_nCurrentAnnotationMarkId;
+ /// Maps annotation mark names to ID's.
+ std::map<OString, sal_uInt16> m_rOpenedAnnotationMarksIds;
/*
* The current table helper.
@@ -577,7 +578,8 @@ private:
bool m_bInRun;
- unsigned int m_nPostitFieldsMaxId;
+ /// Maps ID's to postit fields, used in atrfstart/end and atnref.
+ std::map<sal_uInt16, const SwPostItField*> m_aPostitFields;
/// When exporting fly frames, this holds the real size of the frame.
const Size* m_pFlyFrameSize;