RTF import: implement support for tables inside text frames
Change-Id: I6088adad20212cdbcc03b193cc079c51a305602a
This commit is contained in:
parent
2fc088afdf
commit
4ab658b56f
@ -1450,10 +1450,11 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
|
||||
case RTF_SHPTXT:
|
||||
case RTF_DPTXBXTEXT:
|
||||
m_aStates.top().nDestinationState = DESTINATION_SHAPETEXT;
|
||||
checkFirstRun();
|
||||
dispatchFlag(RTF_PARD);
|
||||
m_bNeedPap = true;
|
||||
OSL_ENSURE(!m_aShapetextBuffer.size(), "shapetext buffer is not empty");
|
||||
m_aStates.top().pCurrentBuffer = &m_aShapetextBuffer;
|
||||
if (nKeyword == RTF_SHPTXT)
|
||||
m_pSdrImport->resolve(m_aStates.top().aShape, false);
|
||||
break;
|
||||
case RTF_FORMFIELD:
|
||||
if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
|
||||
@ -2236,7 +2237,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
|
||||
// Reset everything.
|
||||
m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
|
||||
m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
|
||||
if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
|
||||
if (m_aStates.top().pCurrentBuffer != &m_aShapetextBuffer)
|
||||
m_aStates.top().pCurrentBuffer = 0;
|
||||
}
|
||||
else
|
||||
@ -2557,6 +2558,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
|
||||
std::vector<beans::PropertyValue> aDefaults = m_pSdrImport->getTextFrameDefaults(false);
|
||||
for (size_t i = 0; i < aDefaults.size(); ++i)
|
||||
m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
|
||||
checkFirstRun();
|
||||
Mapper().startShape(m_aStates.top().aDrawingObject.xShape);
|
||||
m_aStates.top().aDrawingObject.bHadShapeText = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -3872,12 +3876,16 @@ int RTFDocumentImpl::popState()
|
||||
break;
|
||||
case DESTINATION_SHAPEPROPERTYVALUE:
|
||||
if (aState.aShape.aProperties.size())
|
||||
{
|
||||
aState.aShape.aProperties.back().second = m_aStates.top().aDestinationText.makeStringAndClear();
|
||||
if (m_aStates.top().bHadShapeText)
|
||||
m_pSdrImport->append(aState.aShape.aProperties.back().first, aState.aShape.aProperties.back().second);
|
||||
}
|
||||
break;
|
||||
case DESTINATION_PICPROP:
|
||||
case DESTINATION_SHAPEINSTRUCTION:
|
||||
if (!m_bObject && !aState.bInListpicture)
|
||||
m_pSdrImport->resolve(m_aStates.top().aShape);
|
||||
if (!m_bObject && !aState.bInListpicture && !m_aStates.top().bHadShapeText)
|
||||
m_pSdrImport->resolve(m_aStates.top().aShape, true);
|
||||
break;
|
||||
case DESTINATION_BOOKMARKSTART:
|
||||
{
|
||||
@ -4136,8 +4144,11 @@ int RTFDocumentImpl::popState()
|
||||
|
||||
m_pSdrImport->resolveFLine(xPropertySet, rDrawing.nFLine);
|
||||
|
||||
Mapper().startShape(xShape);
|
||||
replayShapetext();
|
||||
if (!m_aStates.top().aDrawingObject.bHadShapeText)
|
||||
{
|
||||
Mapper().startShape(xShape);
|
||||
replayShapetext();
|
||||
}
|
||||
Mapper().endShape();
|
||||
}
|
||||
break;
|
||||
@ -4581,6 +4592,14 @@ int RTFDocumentImpl::popState()
|
||||
m_xDocumentProperties->setTitle(aState.aDestinationText.makeStringAndClear());
|
||||
}
|
||||
break;
|
||||
case DESTINATION_SHAPETEXT:
|
||||
// If we're leaving the shapetext group (it may have nested ones) and this is a shape, not an old drawingobject.
|
||||
if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
|
||||
{
|
||||
m_aStates.top().bHadShapeText = true;
|
||||
m_pSdrImport->close();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (m_aStates.size() && m_aStates.top().nDestinationState == DESTINATION_PICT)
|
||||
@ -4713,7 +4732,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
|
||||
pCurrentBuffer(0),
|
||||
bHasTableStyle(false),
|
||||
bInListpicture(false),
|
||||
bInBackground(false)
|
||||
bInBackground(false),
|
||||
bHadShapeText(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -4767,7 +4787,8 @@ RTFDrawingObject::RTFDrawingObject()
|
||||
bHasFillColor(false),
|
||||
nDhgt(0),
|
||||
nFLine(-1),
|
||||
nPolyLineCount(0)
|
||||
nPolyLineCount(0),
|
||||
bHadShapeText(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -265,6 +265,7 @@ namespace writerfilter {
|
||||
sal_Int32 nFLine;
|
||||
sal_Int32 nPolyLineCount;
|
||||
uno::Sequence<awt::Point> aPolyLinePoints;
|
||||
bool bHadShapeText;
|
||||
};
|
||||
|
||||
/// Stores the properties of a picture.
|
||||
@ -403,6 +404,8 @@ namespace writerfilter {
|
||||
|
||||
/// If we're inside a \background group.
|
||||
bool bInBackground;
|
||||
|
||||
bool bHadShapeText;
|
||||
};
|
||||
|
||||
class RTFTokenizer;
|
||||
|
@ -166,7 +166,7 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
|
||||
xPropertySet->setPropertyValue("VertOrient", uno::makeAny(nVertOrient));
|
||||
}
|
||||
|
||||
void RTFSdrImport::resolve(RTFShape& rShape)
|
||||
void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
|
||||
{
|
||||
int nType = -1;
|
||||
bool bPib = false;
|
||||
@ -204,7 +204,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
|
||||
break;
|
||||
case ESCHER_ShpInst_Rectangle:
|
||||
case ESCHER_ShpInst_TextBox:
|
||||
if (!m_rImport.getShapetextBuffer().empty())
|
||||
if (!bClose)
|
||||
{
|
||||
createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
|
||||
bTextFrame = true;
|
||||
@ -594,10 +594,24 @@ void RTFSdrImport::resolve(RTFShape& rShape)
|
||||
|
||||
// Send it to dmapper
|
||||
m_rImport.Mapper().startShape(xShape);
|
||||
m_rImport.replayShapetext();
|
||||
if (bClose)
|
||||
{
|
||||
m_rImport.replayShapetext();
|
||||
m_rImport.Mapper().endShape();
|
||||
}
|
||||
m_xShape = xShape;
|
||||
}
|
||||
|
||||
void RTFSdrImport::close()
|
||||
{
|
||||
m_rImport.Mapper().endShape();
|
||||
}
|
||||
|
||||
void RTFSdrImport::append(OUString aKey, OUString aValue)
|
||||
{
|
||||
applyProperty(m_xShape, aKey, aValue);
|
||||
}
|
||||
|
||||
} // namespace rtftok
|
||||
} // namespace writerfilter
|
||||
|
||||
|
@ -21,7 +21,9 @@ namespace writerfilter {
|
||||
RTFSdrImport(RTFDocumentImpl& rImport, uno::Reference<lang::XComponent> const& xDstDoc);
|
||||
virtual ~RTFSdrImport();
|
||||
|
||||
void resolve(RTFShape& rShape);
|
||||
void resolve(RTFShape& rShape, bool bClose);
|
||||
void close();
|
||||
void append(OUString aKey, OUString aValue);
|
||||
void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder);
|
||||
void resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nFLine);
|
||||
/**
|
||||
@ -36,6 +38,7 @@ namespace writerfilter {
|
||||
|
||||
RTFDocumentImpl& m_rImport;
|
||||
uno::Reference<drawing::XDrawPage> m_xDrawPage;
|
||||
uno::Reference<drawing::XShape> m_xShape;
|
||||
};
|
||||
} // namespace rtftok
|
||||
} // namespace writerfilter
|
||||
|
Loading…
x
Reference in New Issue
Block a user