summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-04-25 11:28:49 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-04-25 11:59:00 +0200
commitf1fdcdea5436e927dde9b4dd242c4f90c2a75e9d (patch)
treebd08dba85d42b1c9f55ec64ce8b6794f97cc43d8 /writerfilter
parentbec0bab00eeed78ccdb7065554dcf9e898f499fa (diff)
avoid code duplication by introducing RTFDocumentImpl::singleChar
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx86
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
2 files changed, 24 insertions, 64 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ed89aa2983e1..ba4db683e76a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -833,6 +833,24 @@ bool RTFFrame::inFrame()
|| nY > 0;
}
+void RTFDocumentImpl::singleChar(sal_uInt8 nValue)
+{
+ sal_uInt8 sValue[] = { nValue };
+ if (!m_pCurrentBuffer)
+ {
+ Mapper().startCharacterGroup();
+ Mapper().text(sValue, 1);
+ Mapper().endCharacterGroup();
+ }
+ else
+ {
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
+ RTFValue::Pointer_t pValue(new RTFValue(*sValue));
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
+ }
+}
+
void RTFDocumentImpl::text(OUString& rString)
{
bool bRet = true;
@@ -1075,22 +1093,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
if (aBuf.toString().equals("EQ"))
m_bEq = true;
else
- {
- sal_uInt8 sFieldStart[] = { 0x13 };
- if (!m_pCurrentBuffer)
- {
- Mapper().startCharacterGroup();
- Mapper().text(sFieldStart, 1);
- Mapper().endCharacterGroup();
- }
- else
- {
- m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
- RTFValue::Pointer_t pValue(new RTFValue(*sFieldStart));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
- }
- }
+ singleChar(0x13);
m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
}
break;
@@ -3025,42 +3028,12 @@ int RTFDocumentImpl::popState()
m_aFormfieldSprms->clear();
}
if (!m_bEq)
- {
- sal_uInt8 sFieldSep[] = { 0x14 };
- if (!m_pCurrentBuffer)
- {
- Mapper().startCharacterGroup();
- Mapper().text(sFieldSep, 1);
- Mapper().endCharacterGroup();
- }
- else
- {
- m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
- RTFValue::Pointer_t pValue(new RTFValue(*sFieldSep));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
- }
- }
+ singleChar(0x14);
}
else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT)
{
if (!m_bEq)
- {
- sal_uInt8 sFieldEnd[] = { 0x15 };
- if (!m_pCurrentBuffer)
- {
- Mapper().startCharacterGroup();
- Mapper().text(sFieldEnd, 1);
- Mapper().endCharacterGroup();
- }
- else
- {
- m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
- RTFValue::Pointer_t pValue(new RTFValue(*sFieldEnd));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
- }
- }
+ singleChar(0x15);
else
m_bEq = false;
}
@@ -3465,22 +3438,7 @@ int RTFDocumentImpl::popState()
else if (aState.nDestinationState == DESTINATION_FIELD)
{
if (aState.nFieldStatus == FIELD_INSTRUCTION)
- {
- sal_uInt8 sFieldEnd[] = { 0x15 };
- if (!m_pCurrentBuffer)
- {
- Mapper().startCharacterGroup();
- Mapper().text(sFieldEnd, 1);
- Mapper().endCharacterGroup();
- }
- else
- {
- m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
- RTFValue::Pointer_t pValue(new RTFValue(*sFieldEnd));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
- m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
- }
- }
+ singleChar(0x15);
}
else if (bPopShapeProperties)
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index c905909334a1..d47ab1a0876d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -397,6 +397,8 @@ namespace writerfilter {
void resolveSubstream(sal_uInt32 nPos, Id nId, rtl::OUString& rIgnoreFirst);
void text(rtl::OUString& rString);
+ // Sends a single character to dmapper, taking care of buffering.
+ void singleChar(sal_uInt8 nValue);
void parBreak();
void tableBreak();
void checkNeedPap();