summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-08-28 12:57:55 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-08-28 13:03:40 +0200
commitb6c18e3bc78724e65c78577c6e513f894c4e93b4 (patch)
tree1c0fc79153a81b3145af66583fe1a1c970c92371 /writerfilter/source/rtftok
parent84c54990c0dbd3385a4a653afe63d0fa7b1c435b (diff)
Move group handling from RTFDocumentImpl to RTFTokenizer
This is one step towards hiding the RTFDocument implementation from RTFTokenizer. Change-Id: Ief35a2440cac3147495675d344e1efc64f5fbc2e
Diffstat (limited to 'writerfilter/source/rtftok')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx4
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.cxx30
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.hxx8
4 files changed, 36 insertions, 22 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 330c34d6ec6e..bd72dd6f4e13 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -232,7 +232,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_xDstDoc(xDstDoc),
m_xFrame(xFrame),
m_xStatusIndicator(xStatusIndicator),
- m_nGroup(0),
m_aDefaultState(this),
m_bSkipUnknown(false),
m_aFontEncodings(),
@@ -3203,7 +3202,7 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
int RTFDocumentImpl::pushState()
{
- //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before push: " << m_nGroup);
+ //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before push: " << m_pTokenizer->getGroup());
checkUnicode();
m_nGroupStartPos = Strm().Tell();
@@ -3219,7 +3218,7 @@ int RTFDocumentImpl::pushState()
m_aStates.push(aState);
m_aStates.top().aDestinationText.setLength(0);
- m_nGroup++;
+ m_pTokenizer->pushGroup();
switch (m_aStates.top().nDestinationState)
{
@@ -3297,7 +3296,7 @@ void RTFDocumentImpl::resetAttributes()
int RTFDocumentImpl::popState()
{
- //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_nGroup " << m_nGroup <<
+ //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_pTokenizer->getGroup() " << m_pTokenizer->getGroup() <<
// ", dest state: " << m_aStates.top().nDestinationState);
checkUnicode();
@@ -3756,7 +3755,7 @@ int RTFDocumentImpl::popState()
}
// This is the end of the doc, see if we need to close the last section.
- if (m_nGroup == 1 && !m_bFirstRun)
+ if (m_pTokenizer->getGroup() == 1 && !m_bFirstRun)
{
m_bDeferredContSectBreak = false;
sectBreak(true);
@@ -3764,7 +3763,7 @@ int RTFDocumentImpl::popState()
m_aStates.pop();
- m_nGroup--;
+ m_pTokenizer->popGroup();
// list table
if (aState.nDestinationState == DESTINATION_LISTENTRY)
@@ -3935,11 +3934,6 @@ RTFParserState& RTFDocumentImpl::getState()
return m_aStates.top();
}
-int RTFDocumentImpl::getGroup() const
-{
- return m_nGroup;
-}
-
void RTFDocumentImpl::setDestinationText(OUString& rString)
{
m_aStates.top().aDestinationText.setLength(0);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index e3120b7aacdf..e2a5aa619632 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -424,8 +424,6 @@ namespace writerfilter {
void seek(sal_uInt32 nPos);
uno::Reference<lang::XMultiServiceFactory> getModelFactory();
RTFParserState& getState();
- /// Number of states on the stack.
- int getGroup() const;
void setDestinationText(rtl::OUString& rString);
/// Resolve a picture: If not inline, then anchored.
int resolvePict(bool bInline);
@@ -493,8 +491,6 @@ namespace writerfilter {
Stream* m_pMapperStream;
boost::shared_ptr<RTFSdrImport> m_pSdrImport;
boost::shared_ptr<RTFTokenizer> m_pTokenizer;
- /// Same as m_aStates.size(), except that this can be negative for invalid input.
- int m_nGroup;
std::stack<RTFParserState> m_aStates;
/// Read by RTF_PARD.
RTFParserState m_aDefaultState;
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index abe8cff110db..3e7a7503d526 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -46,7 +46,8 @@ RTFTokenizer::RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream, uno::R
: m_rImport(rImport),
m_pInStream(pInStream),
m_xStatusIndicator(xStatusIndicator),
- m_aRTFControlWords(std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords))
+ m_aRTFControlWords(std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords)),
+ m_nGroup(0)
{
std::sort(m_aRTFControlWords.begin(), m_aRTFControlWords.end());
}
@@ -93,9 +94,9 @@ int RTFTokenizer::resolveParse()
if (m_xStatusIndicator.is() && (nCurrentPos = Strm().Tell()) > (nLastPos + nPercentSize))
m_xStatusIndicator->setValue(nLastPos = nCurrentPos);
- if (m_rImport.getGroup() < 0)
+ if (m_nGroup < 0)
return ERROR_GROUP_UNDER;
- if (m_rImport.getGroup() > 0 && m_rImport.getState().nInternalState == INTERNAL_BIN)
+ if (m_nGroup > 0 && m_rImport.getState().nInternalState == INTERNAL_BIN)
{
ret = m_rImport.resolveChars(ch);
if (ret)
@@ -114,7 +115,7 @@ int RTFTokenizer::resolveParse()
ret = m_rImport.popState();
if (ret)
return ret;
- if (m_rImport.getGroup() == 0)
+ if (m_nGroup == 0)
{
if (m_rImport.isSubstream())
m_rImport.finishSubstream();
@@ -130,7 +131,7 @@ int RTFTokenizer::resolveParse()
case 0x0a:
break; // ignore these
default:
- if (m_rImport.getGroup() == 0)
+ if (m_nGroup == 0)
return ERROR_CHAR_OVER;
if (m_rImport.getState().nInternalState == INTERNAL_NORMAL)
{
@@ -162,9 +163,9 @@ int RTFTokenizer::resolveParse()
}
}
- if (m_rImport.getGroup() < 0)
+ if (m_nGroup < 0)
return ERROR_GROUP_UNDER;
- else if (m_rImport.getGroup() > 0)
+ else if (m_nGroup > 0)
return ERROR_GROUP_OVER;
return 0;
}
@@ -193,6 +194,21 @@ int RTFTokenizer::asHex(char ch)
return ret;
}
+int RTFTokenizer::getGroup() const
+{
+ return m_nGroup;
+}
+
+void RTFTokenizer::pushGroup()
+{
+ m_nGroup++;
+}
+
+void RTFTokenizer::popGroup()
+{
+ m_nGroup--;
+}
+
int RTFTokenizer::resolveKeyword()
{
char ch;
diff --git a/writerfilter/source/rtftok/rtftokenizer.hxx b/writerfilter/source/rtftok/rtftokenizer.hxx
index bcaafdad8eb9..2fd06ae82b09 100644
--- a/writerfilter/source/rtftok/rtftokenizer.hxx
+++ b/writerfilter/source/rtftok/rtftokenizer.hxx
@@ -43,6 +43,12 @@ namespace writerfilter {
int resolveParse();
int asHex(char ch);
+ /// Number of states on the stack.
+ int getGroup() const;
+ /// To be invoked by the pushState() callback to signal when the importer enters a group.
+ void pushGroup();
+ /// To be invoked by the popState() callback to single when the importer leaves a group.
+ void popGroup();
private:
SvStream& Strm();
int resolveKeyword();
@@ -53,6 +59,8 @@ namespace writerfilter {
uno::Reference<task::XStatusIndicator> const& m_xStatusIndicator;
// This is the same as m_aRTFControlWords, but sorted
std::vector<RTFSymbol> m_aRTFControlWords;
+ /// Same as the size of the importer's states, except that this can be negative for invalid input.
+ int m_nGroup;
};
} // namespace rtftok
} // namespace writerfilter