Move group handling from RTFDocumentImpl to RTFTokenizer
This is one step towards hiding the RTFDocument implementation from RTFTokenizer. Change-Id: Ief35a2440cac3147495675d344e1efc64f5fbc2e
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user