n#703032: Fixed an RTF import crash when handling formdata in non-FORM fields
This commit is contained in:
@@ -288,6 +288,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
|
|||||||
m_aStyleTableEntries(),
|
m_aStyleTableEntries(),
|
||||||
m_nCurrentStyleIndex(0),
|
m_nCurrentStyleIndex(0),
|
||||||
m_bEq(false),
|
m_bEq(false),
|
||||||
|
m_bFormField(false),
|
||||||
m_bWasInFrame(false),
|
m_bWasInFrame(false),
|
||||||
m_bIsInFrame(false),
|
m_bIsInFrame(false),
|
||||||
m_aUnicodeBuffer()
|
m_aUnicodeBuffer()
|
||||||
@@ -969,18 +970,32 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
|
|||||||
break;
|
break;
|
||||||
case RTF_FLDINST:
|
case RTF_FLDINST:
|
||||||
{
|
{
|
||||||
|
// Look for the field type
|
||||||
sal_Int32 nPos = Strm().Tell();
|
sal_Int32 nPos = Strm().Tell();
|
||||||
OStringBuffer aBuf;
|
OStringBuffer aBuf;
|
||||||
char ch;
|
char ch;
|
||||||
for (int i = 0; i < 4; ++i)
|
bool bFoundCode = false;
|
||||||
|
bool bInKeyword = false;
|
||||||
|
while (!bFoundCode && ch != '}')
|
||||||
{
|
{
|
||||||
Strm() >> ch;
|
Strm() >> ch;
|
||||||
|
if ('\\' == ch)
|
||||||
|
bInKeyword = true;
|
||||||
|
if (!bInKeyword && isalnum(ch))
|
||||||
aBuf.append(ch);
|
aBuf.append(ch);
|
||||||
|
else if (bInKeyword && isspace(ch))
|
||||||
|
bInKeyword = false;
|
||||||
|
if (aBuf.getLength() > 0 && !isalnum(ch))
|
||||||
|
bFoundCode = true;
|
||||||
}
|
}
|
||||||
Strm().Seek(nPos);
|
Strm().Seek(nPos);
|
||||||
|
|
||||||
|
// Form data should be handled only for form fields if any
|
||||||
|
if (aBuf.toString().indexOf(OString("FORM")) != -1 )
|
||||||
|
m_bFormField = true;
|
||||||
|
|
||||||
// EQ fields are not really fields in fact.
|
// EQ fields are not really fields in fact.
|
||||||
if (aBuf.toString().equals("{ EQ"))
|
if (aBuf.toString().equals("EQ"))
|
||||||
m_bEq = true;
|
m_bEq = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2871,7 +2886,7 @@ int RTFDocumentImpl::popState()
|
|||||||
RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
|
RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
|
||||||
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFDDList_listEntry, pValue));
|
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFDDList_listEntry, pValue));
|
||||||
}
|
}
|
||||||
else if (m_aStates.top().nDestinationState == DESTINATION_DATAFIELD)
|
else if (m_aStates.top().nDestinationState == DESTINATION_DATAFIELD && m_bFormField)
|
||||||
{
|
{
|
||||||
OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), m_aStates.top().nCurrentEncoding);
|
OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), m_aStates.top().nCurrentEncoding);
|
||||||
// decode hex dump
|
// decode hex dump
|
||||||
@@ -2914,6 +2929,8 @@ int RTFDocumentImpl::popState()
|
|||||||
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFData_name, pNValue));
|
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFData_name, pNValue));
|
||||||
RTFValue::Pointer_t pDValue(new RTFValue(OStringToOUString(aDefaultText, m_aStates.top().nCurrentEncoding)));
|
RTFValue::Pointer_t pDValue(new RTFValue(OStringToOUString(aDefaultText, m_aStates.top().nCurrentEncoding)));
|
||||||
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFTextInput_default, pDValue));
|
m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFTextInput_default, pDValue));
|
||||||
|
|
||||||
|
m_bFormField = false;
|
||||||
}
|
}
|
||||||
else if (m_aStates.top().nDestinationState == DESTINATION_CREATIONTIME && m_xDocumentProperties.is())
|
else if (m_aStates.top().nDestinationState == DESTINATION_CREATIONTIME && m_xDocumentProperties.is())
|
||||||
m_xDocumentProperties->setCreationDate(lcl_getDateTime(m_aStates));
|
m_xDocumentProperties->setCreationDate(lcl_getDateTime(m_aStates));
|
||||||
|
@@ -425,6 +425,7 @@ namespace writerfilter {
|
|||||||
RTFReferenceTable::Entries_t m_aStyleTableEntries;
|
RTFReferenceTable::Entries_t m_aStyleTableEntries;
|
||||||
int m_nCurrentStyleIndex;
|
int m_nCurrentStyleIndex;
|
||||||
bool m_bEq;
|
bool m_bEq;
|
||||||
|
bool m_bFormField;
|
||||||
/// If we were in a frame.
|
/// If we were in a frame.
|
||||||
bool m_bWasInFrame;
|
bool m_bWasInFrame;
|
||||||
/// If a frame start token is already sent to dmapper (nesting them is not OK).
|
/// If a frame start token is already sent to dmapper (nesting them is not OK).
|
||||||
|
Reference in New Issue
Block a user