RTF export of annotation marks
Change-Id: I079516ad0f30886d175748fdee19fbd71c2704f8
This commit is contained in:
@@ -134,8 +134,6 @@ DECLARE_RTFEXPORT_TEST(testFdo48335, "fdo48335.odt")
|
|||||||
|
|
||||||
DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
|
DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
// FIXME port to AnnotationMarks
|
|
||||||
// See ooxmlexport's testFdo38244().
|
// See ooxmlexport's testFdo38244().
|
||||||
// Test comment range feature.
|
// Test comment range feature.
|
||||||
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
|
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
|
||||||
@@ -145,10 +143,10 @@ DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
|
|||||||
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
|
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
|
||||||
xRunEnum->nextElement();
|
xRunEnum->nextElement();
|
||||||
uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
|
uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
|
CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
|
||||||
xRunEnum->nextElement();
|
xRunEnum->nextElement();
|
||||||
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
|
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
|
CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
|
||||||
|
|
||||||
// Test initials.
|
// Test initials.
|
||||||
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
|
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
|
||||||
@@ -156,7 +154,6 @@ DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
|
|||||||
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
|
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
|
||||||
xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
|
xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
|
CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
|
DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
|
||||||
|
@@ -1472,6 +1472,48 @@ void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts,
|
|||||||
rEnds.clear();
|
rEnds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtfAttributeOutput::WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds )
|
||||||
|
{
|
||||||
|
for ( std::vector< OUString >::const_iterator i = rStarts.begin(), end = rStarts.end(); i != end; ++i )
|
||||||
|
{
|
||||||
|
OString rName = OUStringToOString( *i, RTL_TEXTENCODING_UTF8 );
|
||||||
|
|
||||||
|
// 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_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
|
||||||
|
m_aRun->append(OString::number(nId).getStr());
|
||||||
|
m_aRun->append('}');
|
||||||
|
}
|
||||||
|
rStarts.clear();
|
||||||
|
|
||||||
|
for ( std::vector< OUString >::const_iterator i = rEnds.begin(), end = rEnds.end(); i != end; ++i )
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
if (it != m_rOpenedAnnotationMarksIds.end())
|
||||||
|
{
|
||||||
|
sal_uInt16 nId = ( *it ).second.first;
|
||||||
|
const SwPostItField* pField = ( *it ).second.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)
|
||||||
|
{
|
||||||
|
m_aRunText->append("{");
|
||||||
|
PostitField(pField);
|
||||||
|
m_aRunText->append("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rEnds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg )
|
void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg )
|
||||||
{
|
{
|
||||||
OStringBuffer aSectionBreaks = m_aSectionBreaks;
|
OStringBuffer aSectionBreaks = m_aSectionBreaks;
|
||||||
@@ -3184,6 +3226,16 @@ void RtfAttributeOutput::PostitField( const SwField* pFld )
|
|||||||
|
|
||||||
const SwPostItField& rPFld = *(SwPostItField*)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);
|
||||||
|
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;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
|
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
|
||||||
m_aRunText->append(OUStringToOString(OUString(rPFld.GetInitials()), m_rExport.eCurrentEncoding));
|
m_aRunText->append(OUStringToOString(OUString(rPFld.GetInitials()), m_rExport.eCurrentEncoding));
|
||||||
m_aRunText->append("}");
|
m_aRunText->append("}");
|
||||||
@@ -3205,16 +3257,10 @@ void RtfAttributeOutput::PostitField( const SwField* pFld )
|
|||||||
|
|
||||||
void RtfAttributeOutput::WritePostitFieldStart()
|
void RtfAttributeOutput::WritePostitFieldStart()
|
||||||
{
|
{
|
||||||
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
|
|
||||||
m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
|
|
||||||
m_aRunText->append("}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtfAttributeOutput::WritePostitFieldEnd()
|
void RtfAttributeOutput::WritePostitFieldEnd()
|
||||||
{
|
{
|
||||||
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFEND " ");
|
|
||||||
m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
|
|
||||||
m_aRunText->append("}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
|
bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
|
||||||
@@ -3234,6 +3280,7 @@ bool RtfAttributeOutput::PlaceholderField( const SwField* pField)
|
|||||||
RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
|
RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
|
||||||
: m_rExport( rExport ),
|
: m_rExport( rExport ),
|
||||||
m_bStrikeDouble( false ),
|
m_bStrikeDouble( false ),
|
||||||
|
m_nNextAnnotationMarkId(0),
|
||||||
m_pTableWrt( NULL ),
|
m_pTableWrt( NULL ),
|
||||||
m_bTableCellOpen( false ),
|
m_bTableCellOpen( false ),
|
||||||
m_nTableDepth( 0 ),
|
m_nTableDepth( 0 ),
|
||||||
|
@@ -212,6 +212,7 @@ public:
|
|||||||
|
|
||||||
void WriteField_Impl( const SwField* pFld, ww::eField eType, const OUString& rFldCmd, sal_uInt8 nMode );
|
void WriteField_Impl( const SwField* pFld, ww::eField eType, const OUString& rFldCmd, sal_uInt8 nMode );
|
||||||
void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
|
void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
|
||||||
|
void WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
|
||||||
void WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg );
|
void WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -502,6 +503,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool m_bStrikeDouble;
|
bool m_bStrikeDouble;
|
||||||
|
|
||||||
|
sal_Int32 m_nNextAnnotationMarkId;
|
||||||
|
/// Map of the annotation marks ids
|
||||||
|
std::map< OString, std::pair<sal_uInt16, const SwPostItField*> > m_rOpenedAnnotationMarksIds;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The current table helper.
|
* The current table helper.
|
||||||
*/
|
*/
|
||||||
|
@@ -163,8 +163,32 @@ void RtfExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ )
|
|||||||
m_pAttrOutput->WriteBookmarks_Impl(aStarts, aEnds);
|
m_pAttrOutput->WriteBookmarks_Impl(aStarts, aEnds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtfExport::AppendAnnotationMarks( const SwTxtNode& /*rNode*/, sal_Int32 /*nAktPos*/, sal_Int32 /*nLen*/ )
|
void RtfExport::AppendAnnotationMarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen )
|
||||||
{
|
{
|
||||||
|
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
|
||||||
|
|
||||||
|
std::vector< OUString > aStarts;
|
||||||
|
std::vector< OUString > aEnds;
|
||||||
|
|
||||||
|
IMarkVector aMarks;
|
||||||
|
if ( GetAnnotationMarks( rNode, nAktPos, nAktPos + nLen, aMarks ) )
|
||||||
|
{
|
||||||
|
for ( IMarkVector::const_iterator it = aMarks.begin(), end = aMarks.end();
|
||||||
|
it != end; ++it )
|
||||||
|
{
|
||||||
|
IMark* pMark = (*it);
|
||||||
|
const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
|
||||||
|
const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
|
||||||
|
|
||||||
|
if ( nStart == nAktPos )
|
||||||
|
aStarts.push_back( pMark->GetName() );
|
||||||
|
|
||||||
|
if ( nEnd == nAktPos )
|
||||||
|
aEnds.push_back( pMark->GetName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pAttrOutput->WriteAnnotationMarks_Impl( aStarts, aEnds );
|
||||||
}
|
}
|
||||||
|
|
||||||
//For i120928,to export graphic of bullet for RTF filter
|
//For i120928,to export graphic of bullet for RTF filter
|
||||||
|
Reference in New Issue
Block a user