summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2011-08-18 00:07:36 +0200
committerMiklos Vajna <vmiklos@frugalware.org>2011-08-18 00:07:36 +0200
commit2f2c6b05cb2d36db394831a1399cf359bd224a71 (patch)
treeeaef9825c761cd9ca266fd3ce4b124dffcdbdd7e /writerfilter
parentfd0a8ca9574493f2d52ef1de5104ffdd6226369b (diff)
Support empty paragraphs in text frames
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx71
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx1
2 files changed, 40 insertions, 32 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7db3b1abbe1e..f3e9b9d4ac50 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -710,6 +710,42 @@ bool RTFDocumentImpl::inFrame()
|| m_aStates.top().aFrame.nY > 0;
}
+void RTFDocumentImpl::checkChangedFrame()
+{
+ // Check if this is a frame.
+ if (inFrame() && !m_bWasInFrame)
+ {
+ uno::Reference<text::XTextFrame> xTextFrame;
+ xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(xTextFrame, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY);
+
+ // RTF allows frames larger than the text content by default
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN));
+
+ xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX)));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY)));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin)));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin)));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nTopMargin)));
+ xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nBottomMargin)));
+
+ Mapper().startShape(xShape);
+ Mapper().startParagraphGroup();
+ }
+ else if (!inFrame() && m_bWasInFrame)
+ {
+ Mapper().endParagraphGroup();
+ Mapper().endShape();
+ Mapper().endParagraphGroup();
+ Mapper().startParagraphGroup();
+ m_bWasInFrame = false;
+ }
+}
+
void RTFDocumentImpl::text(OUString& rString)
{
bool bRet = true;
@@ -811,38 +847,7 @@ void RTFDocumentImpl::text(OUString& rString)
checkFirstRun();
if (m_bNeedPap)
{
- // Check if this is a frame.
- if (inFrame() && !m_bWasInFrame)
- {
- uno::Reference<text::XTextFrame> xTextFrame;
- xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY);
- uno::Reference<drawing::XShape> xShape(xTextFrame, uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY);
-
- // RTF allows frames larger than the text content by default
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN));
-
- xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX)));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY)));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin)));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin)));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nTopMargin)));
- xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nBottomMargin)));
-
- Mapper().startShape(xShape);
- Mapper().startParagraphGroup();
- }
- else if (!inFrame() && m_bWasInFrame)
- {
- Mapper().endParagraphGroup();
- Mapper().endShape();
- Mapper().endParagraphGroup();
- Mapper().startParagraphGroup();
- m_bWasInFrame = false;
- }
+ checkChangedFrame();
if (!m_pCurrentBuffer)
Mapper().props(pParagraphProperties);
@@ -1264,6 +1269,8 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
break;
case RTF_PAR:
{
+ if (m_bNeedPap)
+ checkChangedFrame();
if (!m_pCurrentBuffer)
parBreak();
else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index c3595f69595b..bb3faec417af 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -336,6 +336,7 @@ namespace writerfilter {
void sectBreak(bool bFinal);
void replayBuffer(RTFBuffer_t& rBuffer);
bool inFrame();
+ void checkChangedFrame();
uno::Reference<uno::XComponentContext> const& m_xContext;
uno::Reference<io::XInputStream> const& m_xInputStream;