[Libreoffice-commits] .: 22 commits - sw/qa sw/source writerfilter/Library_writerfilter.mk writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Aug 18 04:30:43 PDT 2011


 sw/qa/core/filters-test.cxx                       |    6 
 sw/source/filter/rtf/swparrtf.cxx                 |    6 
 writerfilter/Library_writerfilter.mk              |    1 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   12 +
 writerfilter/source/filter/RtfFilter.cxx          |   63 ++----
 writerfilter/source/rtftok/rtfcontrolwords.cxx    |    4 
 writerfilter/source/rtftok/rtfcontrolwords.hxx    |    6 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |  201 ++++++++++++++++++----
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |   32 +++
 writerfilter/source/rtftok/rtffly.hxx             |  110 ++++++++++++
 writerfilter/source/rtftok/rtfsdrimport.cxx       |    4 
 11 files changed, 353 insertions(+), 92 deletions(-)

New commits:
commit 2cce29a36d857b8e0bdf139bc1823681ae23c08c
Merge: fedb09d... 13c00ce...
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 13:30:13 2011 +0200

    Merge remote-tracking branch 'feature/gsoc2011_rtfimport'

commit 13c00ce322e78eb4e0f50ab84ded19cd6aae1ded
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 12:11:03 2011 +0200

    Enable the writerfilter-based RTF import in non-experimental mode
    
    Disable the unit tests in sw, as that would duplicate the unit test in
    writerfilter now.
    
    Do not remove the old filter yet, so this commit can be reverted later
    if needed.

diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index e9d2e4a..c9616ec 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -171,12 +171,6 @@ void FiltersTest::testCVEs()
 
     recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/xml/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), false);
 
-    recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), true);
-
-    recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), false);
-
-    recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/indeterminate")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), indeterminate);
-
     recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), true);
 
     recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), false);
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 60e5d46..9fe62ed 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -103,7 +103,6 @@
 #include <svx/xflclit.hxx>
 #include <svx/xlnwtit.hxx>
 #include <svx/svdoutl.hxx>
-#include <svtools/miscopt.hxx>
 #include <unotools/streamwrap.hxx>
 #include <comphelper/processfactory.hxx>
 #include <editeng/outlobj.hxx>
@@ -163,10 +162,7 @@ sal_uLong SwRTFReader::Read( SwDoc &rDoc, const String& /*rBaseURL*/, SwPaM& /*r
 
 extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF()
 {
-    SvtMiscOptions aMiscOptions;
-    if (aMiscOptions.IsExperimentalMode())
-        return new SwRTFReader();
-    return new RtfReader();
+    return new SwRTFReader();
 }
 
 // Aufruf fuer die allg. Reader-Schnittstelle
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk
index 69ca172..087ef26 100644
--- a/writerfilter/Library_writerfilter.mk
+++ b/writerfilter/Library_writerfilter.mk
@@ -60,7 +60,6 @@ $(eval $(call gb_Library_add_linked_libs,writerfilter,\
     rtftok \
     sal \
     sot \
-    svt \
     tl \
     utl \
     $(gb_STDLIBS) \
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index af45896..764c8bb 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -36,7 +36,6 @@
 #include <dmapper/DomainMapper.hxx>
 #include <rtftok/RTFDocument.hxx>
 #include <com/sun/star/frame/XFrame.hpp>
-#include <svtools/miscopt.hxx>
 
 using namespace ::rtl;
 using namespace ::cppu;
@@ -70,56 +69,40 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
         return xFltr->filter(aDescriptor);
     }
 
-    SvtMiscOptions aMiscOptions;
-    if (aMiscOptions.IsExperimentalMode() || !m_xDstDoc.is() )
+    try
     {
-        try
-        {
-            MediaDescriptor aMediaDesc( aDescriptor );
+        MediaDescriptor aMediaDesc( aDescriptor );
 #ifdef DEBUG_IMPORT
-            OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
-            ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr();
+        OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
+        ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr();
 
-            writerfilter::TagLogger::Pointer_t dmapperLogger
-                (writerfilter::TagLogger::getInstance("DOMAINMAPPER"));
-            dmapperLogger->setFileName(sURLc);
-            dmapperLogger->startDocument();
+        writerfilter::TagLogger::Pointer_t dmapperLogger
+            (writerfilter::TagLogger::getInstance("DOMAINMAPPER"));
+        dmapperLogger->setFileName(sURLc);
+        dmapperLogger->startDocument();
 #endif
-            uno::Reference< io::XInputStream > xInputStream;
+        uno::Reference< io::XInputStream > xInputStream;
 
-            aMediaDesc.addInputStream();
-            aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] >>= xInputStream;
+        aMediaDesc.addInputStream();
+        aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] >>= xInputStream;
 
-            uno::Reference<frame::XFrame> xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(),
-                    uno::Reference<frame::XFrame>());
+        uno::Reference<frame::XFrame> xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(),
+                uno::Reference<frame::XFrame>());
 
-            writerfilter::Stream::Pointer_t pStream(
-                    new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF));
-            writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
-                    writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame));
-            pDocument->resolve(*pStream);
+        writerfilter::Stream::Pointer_t pStream(
+                new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF));
+        writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
+                writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame));
+        pDocument->resolve(*pStream);
 #ifdef DEBUG_IMPORT
-            dmapperLogger->endDocument();
+        dmapperLogger->endDocument();
 #endif
-            return sal_True;
-        }
-        catch( const uno::Exception& rEx)
-        {
-            return sal_False;
-        }
+        return sal_True;
     }
-
-    // if not, then use the old importer
-    uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
-    uno::Reference< uno::XInterface > xIfc( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfImport" ))), uno::UNO_QUERY_THROW);
-    if (!xIfc.is())
-        return sal_False;
-    uno::Reference< document::XImporter > xImprtr(xIfc, uno::UNO_QUERY_THROW);
-    uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW);
-    if (!xImprtr.is() || !xFltr.is())
+    catch( const uno::Exception& rEx)
+    {
         return sal_False;
-    xImprtr->setTargetDocument(m_xDstDoc);
-    return xFltr->filter(aDescriptor);
+    }
 }
 
 void RtfFilter::cancel(  ) throw (uno::RuntimeException)
commit 7f3a3e02d723edf00e09dbb1d2020e0084545338
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 02:28:45 2011 +0200

    Tokenize text::HoriOrientation

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 30fe732..6f2a6a4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <editeng/borderline.hxx>
@@ -726,6 +727,8 @@ void RTFDocumentImpl::checkChangedFrame()
 
         xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), uno::Any(m_aStates.top().aFrame.nAnchorType));
+        if (m_aStates.top().aFrame.bPositionToggle)
+            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("PositionToggle")), uno::Any(m_aStates.top().aFrame.bPositionToggle));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX)));
@@ -1844,6 +1847,12 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_PVPG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_FRAME; break;
         case RTF_PHCOL: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::FRAME; break;
         case RTF_PVPARA: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::FRAME; break;
+
+        case RTF_POSXC: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::CENTER; break;
+        case RTF_POSXI: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::LEFT; m_aStates.top().aFrame.bPositionToggle = sal_True; break;
+        case RTF_POSXO: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::RIGHT; m_aStates.top().aFrame.bPositionToggle = sal_True; break;
+        case RTF_POSXL: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::LEFT; break;
+        case RTF_POSXR: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::RIGHT; break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -2416,6 +2425,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             m_aStates.top().aFrame.nH = TWIP_TO_MM100(nParam);
             break;
         case RTF_POSX:
+            m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::NONE;
             m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam);
             break;
         case RTF_POSY:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a89d3da..e5e25a5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -196,6 +196,7 @@ namespace writerfilter {
                 sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
                 sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation;
                 sal_Int16 nAnchorType;
+                sal_Bool bPositionToggle;
         };
 
         /// State of the parser, which gets saved / restored when changing groups.
commit 57f28d9900edc48cbe5239c2b8597f8f5c5c3edb
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 02:14:02 2011 +0200

    complete text::VertOrientation

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index df327c7..30fe732 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1834,9 +1834,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_FORMSHADE:
             // Noop, this is the default in Writer.
             break;
-        case RTF_POSYT:
-            m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP;
-            break;
+        case RTF_POSYT: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP; break;
+        case RTF_POSYB: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::BOTTOM; break;
+        case RTF_POSYC: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::CENTER; break;
+
         case RTF_PHMRG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
         case RTF_PVMRG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
         case RTF_PHPG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME; break;
@@ -2418,6 +2419,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam);
             break;
         case RTF_POSY:
+            m_aStates.top().aFrame.nVertOrient = text::VertOrientation::NONE;
             m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam);
             break;
         case RTF_DFRMTXTX:
commit 5d2a624f466f4c81847b07a63ca2d26c39efc33f
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 02:09:30 2011 +0200

    tokenize text::RelOrientation

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b998d28..df327c7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -34,8 +34,8 @@
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/SizeType.hpp>
-#include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
 #include <editeng/borderline.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -1834,6 +1834,15 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_FORMSHADE:
             // Noop, this is the default in Writer.
             break;
+        case RTF_POSYT:
+            m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP;
+            break;
+        case RTF_PHMRG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
+        case RTF_PVMRG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
+        case RTF_PHPG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME; break;
+        case RTF_PVPG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_FRAME; break;
+        case RTF_PHCOL: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::FRAME; break;
+        case RTF_PVPARA: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::FRAME; break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
commit d8ceaa2fb5f74526695ea5c3ca974e0808f1b343
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 01:54:39 2011 +0200

    implement RTF_FLYANCHOR

diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index 00a11a5..aef56ab 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1847,6 +1847,7 @@ RTFSymbol aRTFControlWords[] = {
     {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT},
     {"flyvert", CONTROL_VALUE, RTF_FLYVERT},
     {"flyhorz", CONTROL_VALUE, RTF_FLYHORZ},
+    {"flyanchor", CONTROL_VALUE, RTF_FLYANCHOR},
 };
 int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords);
 
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index 2c1a05b..9c355bb 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -1846,7 +1846,8 @@ enum RTFKeyword
     RTF_ZWNJ,
     RTF_FLYMAINCNT,
     RTF_FLYVERT,
-    RTF_FLYHORZ
+    RTF_FLYHORZ,
+    RTF_FLYANCHOR
 };
 
 /// Types of an RTF Control Word
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index abf2a87..b998d28 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -725,6 +725,7 @@ void RTFDocumentImpl::checkChangedFrame()
         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("AnchorType")), uno::Any(m_aStates.top().aFrame.nAnchorType));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation));
         xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX)));
@@ -2434,6 +2435,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 m_aStates.top().aFrame.nHoriOrientRelation = aHoriOrient.GetRelation();
             }
             break;
+        case RTF_FLYANCHOR:
+            m_aStates.top().aFrame.nAnchorType = nParam;
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 4fecf1a..a89d3da 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -195,6 +195,7 @@ namespace writerfilter {
                 sal_Int32 nX, nY, nW, nH;
                 sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
                 sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation;
+                sal_Int16 nAnchorType;
         };
 
         /// State of the parser, which gets saved / restored when changing groups.
commit e4c1f2a7abcca5f8398f90ce05820456954543e9
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 01:53:16 2011 +0200

    dmapper: don't reset anchor type of text frames

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f4d2c20..0d2e311 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1430,7 +1430,6 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
         uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW );
         bool bIsGraphic = xSInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ) );
 
-        xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic  ?  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) );
         xProps->setPropertyValue(
                 rPropNameSupplier.GetName( PROP_OPAQUE ),
                 uno::makeAny( true ) );
@@ -1440,6 +1439,10 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
             uno::Reference<text::XTextRange> xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW);
             xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False);
         }
+        else
+        {
+            xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic  ?  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) );
+        }
     }
     catch ( const uno::Exception& e )
     {
commit 0b415dac18c23052b5dcf0f76445d7bb4f6fbe01
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 01:03:51 2011 +0200

    these ctors are unused

diff --git a/writerfilter/source/rtftok/rtffly.hxx b/writerfilter/source/rtftok/rtffly.hxx
index d5e5239..a03dc82 100644
--- a/writerfilter/source/rtftok/rtffly.hxx
+++ b/writerfilter/source/rtftok/rtffly.hxx
@@ -39,12 +39,6 @@ namespace writerfilter {
                     Value.nVal = nValue;
                 }
 
-                RTFVertOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient)
-                {
-                    Value.Flags.nOrient = nOrient;
-                    Value.Flags.nRelOrient = nRelOrient;
-                }
-
                 sal_uInt16 GetOrient() const
                 {
                     return Value.Flags.nOrient;
@@ -81,13 +75,6 @@ namespace writerfilter {
                     Value.nVal = nValue;
                 }
 
-                RTFHoriOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient)
-                {
-                    Value.Flags.nOrient = nOrient;
-                    Value.Flags.nRelOrient = nRelOrient;
-                    Value.Flags.nRelAnchor = 0;
-                }
-
                 sal_uInt16 GetOrient() const
                 {
                     return Value.Flags.nOrient;
commit 2e67f17fb3aedb41edb72abf87b40bd5ab746296
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 01:01:57 2011 +0200

    fly props are needed outside their destination

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b99db4d..abf2a87 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2636,6 +2636,8 @@ int RTFDocumentImpl::popState()
     bool bPopShapeProperties = false;
     bool bPopPictureProperties = false;
     bool bFaltEnd = false;
+    RTFFrame aFrame;
+    bool bPopFrame = false;
 
     if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE)
     {
@@ -2951,6 +2953,11 @@ int RTFDocumentImpl::popState()
         aSprms = m_aStates.top().aTableSprms;
         bFaltEnd = true;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_FLYMAINCONTENT)
+    {
+        aFrame = m_aStates.top().aFrame;
+        bPopFrame = true;
+    }
 
     // See if we need to end a track change
     RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange);
@@ -3004,6 +3011,8 @@ int RTFDocumentImpl::popState()
     }
     else if (bFaltEnd)
         m_aStates.top().aTableSprms = aSprms;
+    else if (bPopFrame)
+        m_aStates.top().aFrame = aFrame;
     if (bPopPictureProperties)
     {
         m_aStates.top().aPicture = aPicture;
commit 6c8d683a4b23c812cf7484ad483bed3fc2e8797f
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 00:56:43 2011 +0200

    implement RTF_FLYVERT and RTF_FLYHORZ

diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index dfdec07..00a11a5 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1845,6 +1845,8 @@ RTFSymbol aRTFControlWords[] = {
     {"zwnbo", CONTROL_SYMBOL, RTF_ZWNBO},
     {"zwnj", CONTROL_SYMBOL, RTF_ZWNJ},
     {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT},
+    {"flyvert", CONTROL_VALUE, RTF_FLYVERT},
+    {"flyhorz", CONTROL_VALUE, RTF_FLYHORZ},
 };
 int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords);
 
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index b3ca6e2..2c1a05b 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -1844,7 +1844,9 @@ enum RTFKeyword
     RTF_ZWJ,
     RTF_ZWNBO,
     RTF_ZWNJ,
-    RTF_FLYMAINCNT
+    RTF_FLYMAINCNT,
+    RTF_FLYVERT,
+    RTF_FLYHORZ
 };
 
 /// Types of an RTF Control Word
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 4f62fed..b99db4d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -725,9 +725,11 @@ void RTFDocumentImpl::checkChangedFrame()
         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("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient));
+        xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation));
         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("VertOrient")), uno::Any(m_aStates.top().aFrame.nVertOrient));
+        xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation")), uno::Any(m_aStates.top().aFrame.nVertOrientRelation));
         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)));
@@ -2418,6 +2420,20 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin =
                 m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam);
             break;
+        case RTF_FLYVERT:
+            {
+                RTFVertOrient aVertOrient(nParam);
+                m_aStates.top().aFrame.nVertOrient = aVertOrient.GetOrient();
+                m_aStates.top().aFrame.nVertOrientRelation = aVertOrient.GetRelation();
+            }
+            break;
+        case RTF_FLYHORZ:
+            {
+                RTFHoriOrient aHoriOrient(nParam);
+                m_aStates.top().aFrame.nHoriOrient = aHoriOrient.GetOrient();
+                m_aStates.top().aFrame.nHoriOrientRelation = aHoriOrient.GetRelation();
+            }
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 5ebc3a7..4fecf1a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -192,8 +192,9 @@ namespace writerfilter {
         class RTFFrame
         {
             public:
-                int nX, nY, nW, nH;
-                int nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
+                sal_Int32 nX, nY, nW, nH;
+                sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
+                sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation;
         };
 
         /// State of the parser, which gets saved / restored when changing groups.
commit a5d694abef5b889f4f9e8645e1f7f713c25a72fd
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 00:38:48 2011 +0200

    enter RTF_FLYMAINCNT

diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index 0d7f0c0..dfdec07 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1844,6 +1844,7 @@ RTFSymbol aRTFControlWords[] = {
     {"zwj", CONTROL_SYMBOL, RTF_ZWJ},
     {"zwnbo", CONTROL_SYMBOL, RTF_ZWNBO},
     {"zwnj", CONTROL_SYMBOL, RTF_ZWNJ},
+    {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT},
 };
 int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords);
 
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index 55e17e3..b3ca6e2 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -1843,7 +1843,8 @@ enum RTFKeyword
     RTF_ZWBO,
     RTF_ZWJ,
     RTF_ZWNBO,
-    RTF_ZWNJ
+    RTF_ZWNJ,
+    RTF_FLYMAINCNT
 };
 
 /// Types of an RTF Control Word
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f3e9b9d..4f62fed 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -58,6 +58,7 @@
 #include <rtfsprm.hxx>
 #include <rtfreferenceproperties.hxx>
 #include <rtfskipdestination.hxx>
+#include <rtffly.hxx>
 
 #define TWIP_TO_MM100(TWIP)     ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
 
@@ -1212,6 +1213,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_FALT:
             m_aStates.top().nDestinationState = DESTINATION_FALT;
             break;
+        case RTF_FLYMAINCNT:
+            m_aStates.top().nDestinationState = DESTINATION_FLYMAINCONTENT;
+            break;
         case RTF_LISTTEXT:
             // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
         case RTF_NONESTTABLES:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index bb3faec..5ebc3a7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -112,7 +112,8 @@ namespace writerfilter {
             DESTINATION_RESULT,
             DESTINATION_ANNOTATIONDATE,
             DESTINATION_ANNOTATIONAUTHOR,
-            DESTINATION_FALT
+            DESTINATION_FALT,
+            DESTINATION_FLYMAINCONTENT
         };
 
         enum RTFBorderState
commit 32ebb1e83072688cfc6056304ae73dcd57d5421e
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 00:34:42 2011 +0200

    Add data structures to import LO-specific fly frame RTF extensions

diff --git a/writerfilter/source/rtftok/rtffly.hxx b/writerfilter/source/rtftok/rtffly.hxx
new file mode 100644
index 0000000..d5e5239
--- /dev/null
+++ b/writerfilter/source/rtftok/rtffly.hxx
@@ -0,0 +1,123 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef _RTFFLY_HXX_
+#define _RTFFLY_HXX_
+
+namespace writerfilter {
+    namespace rtftok {
+        /// Stores the vertical orientation properties of an RTF fly frame.
+        class RTFVertOrient
+        {
+            public:
+                RTFVertOrient(sal_uInt16 nValue)
+                {
+                    Value.nVal = nValue;
+                }
+
+                RTFVertOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient)
+                {
+                    Value.Flags.nOrient = nOrient;
+                    Value.Flags.nRelOrient = nRelOrient;
+                }
+
+                sal_uInt16 GetOrient() const
+                {
+                    return Value.Flags.nOrient;
+                }
+
+                sal_uInt16 GetRelation() const
+                {
+                    return Value.Flags.nRelOrient;
+                }
+
+                sal_uInt16 GetValue() const
+                {
+                    return Value.nVal;
+                }
+
+            private:
+                union
+                {
+                    struct
+                    {
+                        sal_uInt16 nOrient : 4;
+                        sal_uInt16 nRelOrient : 1;
+                    } Flags;
+                    sal_uInt16 nVal;
+                } Value;
+        };
+
+        /// Stores the horizontal orientation properties of an RTF fly frame.
+        class RTFHoriOrient
+        {
+            public:
+                RTFHoriOrient(sal_uInt16 nValue)
+                {
+                    Value.nVal = nValue;
+                }
+
+                RTFHoriOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient)
+                {
+                    Value.Flags.nOrient = nOrient;
+                    Value.Flags.nRelOrient = nRelOrient;
+                    Value.Flags.nRelAnchor = 0;
+                }
+
+                sal_uInt16 GetOrient() const
+                {
+                    return Value.Flags.nOrient;
+                }
+
+                sal_uInt16 GetRelation() const
+                {
+                    return Value.Flags.nRelOrient;
+                }
+
+                sal_uInt16 GetValue() const
+                {
+                    return Value.nVal;
+                }
+
+            private:
+                union
+                {
+                    struct
+                    {
+                        sal_uInt16 nOrient : 4;
+                        sal_uInt16 nRelAnchor : 4;
+                        sal_uInt16 nRelOrient : 1;
+                    } Flags;
+                    sal_uInt16 nVal;
+                } Value;
+        };
+    } // namespace rtftok
+} // namespace writerfilter
+
+#endif // _RTFFLY_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2f2c6b05cb2d36db394831a1399cf359bd224a71
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Aug 18 00:07:36 2011 +0200

    Support empty paragraphs in text frames

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7db3b1a..f3e9b9d 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 c3595f6..bb3faec 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;
commit fd0a8ca9574493f2d52ef1de5104ffdd6226369b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Aug 17 23:54:17 2011 +0200

    Support multiple paragraphs inside a single frame

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 4f85e69..7db3b1a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -293,7 +293,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_aStyleTableEntries(),
     m_nCurrentStyleIndex(0),
     m_bEq(false),
-    m_bIsInFrame(false)
+    m_bWasInFrame(false)
 {
     OSL_ASSERT(xInputStream.is());
     m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True);
@@ -427,13 +427,6 @@ void RTFDocumentImpl::parBreak()
     Mapper().endCharacterGroup();
     Mapper().endParagraphGroup();
 
-    if (m_bIsInFrame)
-    {
-        m_bIsInFrame = false;
-        Mapper().endShape();
-        Mapper().endParagraphGroup();
-    }
-
     // If we are not in a table, then the next table row will be the first one.
     RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable);
     if (!pValue.get())
@@ -709,6 +702,14 @@ int RTFDocumentImpl::resolveChars(char ch)
     return 0;
 }
 
+bool RTFDocumentImpl::inFrame()
+{
+    return m_aStates.top().aFrame.nW > 0
+        || m_aStates.top().aFrame.nH > 0
+        || m_aStates.top().aFrame.nX > 0
+        || m_aStates.top().aFrame.nY > 0;
+}
+
 void RTFDocumentImpl::text(OUString& rString)
 {
     bool bRet = true;
@@ -811,10 +812,7 @@ void RTFDocumentImpl::text(OUString& rString)
     if (m_bNeedPap)
     {
         // Check if this is a frame.
-        if (m_aStates.top().aFrame.nW > 0
-                || m_aStates.top().aFrame.nH > 0
-                || m_aStates.top().aFrame.nX > 0
-                || m_aStates.top().aFrame.nY > 0)
+        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);
@@ -836,7 +834,14 @@ void RTFDocumentImpl::text(OUString& rString)
 
             Mapper().startShape(xShape);
             Mapper().startParagraphGroup();
-            m_bIsInFrame = true;
+        }
+        else if (!inFrame() && m_bWasInFrame)
+        {
+            Mapper().endParagraphGroup();
+            Mapper().endShape();
+            Mapper().endParagraphGroup();
+            Mapper().startParagraphGroup();
+            m_bWasInFrame = false;
         }
 
         if (!m_pCurrentBuffer)
@@ -1268,6 +1273,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 }
                 // but don't emit properties yet, since they may change till the first text token arrives
                 m_bNeedPap = true;
+                m_bWasInFrame = inFrame();
             }
             break;
         case RTF_SECT:
@@ -1598,6 +1604,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_PARD:
             m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
             m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
+            m_aStates.top().aFrame = RTFFrame();
             m_pCurrentBuffer = 0;
             break;
         case RTF_SECTD:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 5c683b2..c3595f6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -335,6 +335,7 @@ namespace writerfilter {
                 void checkFirstRun();
                 void sectBreak(bool bFinal);
                 void replayBuffer(RTFBuffer_t& rBuffer);
+                bool inFrame();
 
                 uno::Reference<uno::XComponentContext> const& m_xContext;
                 uno::Reference<io::XInputStream> const& m_xInputStream;
@@ -412,7 +413,7 @@ namespace writerfilter {
                 int m_nCurrentStyleIndex;
                 bool m_bEq;
                 /// If we are in a frame.
-                bool m_bIsInFrame;
+                bool m_bWasInFrame;
 
         };
     } // namespace rtftok
commit b7633fa4b2ff9fd54a608dcdbf72c3372ee0fdd9
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Aug 17 21:12:17 2011 +0200

    Implement textframe margins

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e0c864c..4f85e69 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -829,10 +829,10 @@ void RTFDocumentImpl::text(OUString& rString)
             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(0)));
-            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(0)));
-            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(0)));
-            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(0)));
+            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();
@@ -2390,6 +2390,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_POSY:
             m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam);
             break;
+        case RTF_DFRMTXTX:
+            m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_DFRMTXTY:
+            m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_DXFRTEXT:
+            m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin =
+                m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam);
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index fda4280..5c683b2 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -192,6 +192,7 @@ namespace writerfilter {
         {
             public:
                 int nX, nY, nW, nH;
+                int nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
         };
 
         /// State of the parser, which gets saved / restored when changing groups.
commit 174b65ec87676078da23952e3fe61ab1366fcfb8
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Aug 17 20:20:12 2011 +0200

    initial textframe support

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8078ceb..e0c864c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -32,6 +32,10 @@
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
 #include <com/sun/star/io/UnexpectedEOFException.hpp>
 #include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
+#include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
 #include <editeng/borderline.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -288,7 +292,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_nCurrentFontIndex(0),
     m_aStyleTableEntries(),
     m_nCurrentStyleIndex(0),
-    m_bEq(false)
+    m_bEq(false),
+    m_bIsInFrame(false)
 {
     OSL_ASSERT(xInputStream.is());
     m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True);
@@ -422,6 +427,13 @@ void RTFDocumentImpl::parBreak()
     Mapper().endCharacterGroup();
     Mapper().endParagraphGroup();
 
+    if (m_bIsInFrame)
+    {
+        m_bIsInFrame = false;
+        Mapper().endShape();
+        Mapper().endParagraphGroup();
+    }
+
     // If we are not in a table, then the next table row will be the first one.
     RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable);
     if (!pValue.get())
@@ -798,6 +810,35 @@ void RTFDocumentImpl::text(OUString& rString)
     checkFirstRun();
     if (m_bNeedPap)
     {
+        // Check if this is a frame.
+        if (m_aStates.top().aFrame.nW > 0
+                || m_aStates.top().aFrame.nH > 0
+                || m_aStates.top().aFrame.nX > 0
+                || m_aStates.top().aFrame.nY > 0)
+        {
+            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(0)));
+            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(0)));
+            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(0)));
+            xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(0)));
+
+            Mapper().startShape(xShape);
+            Mapper().startParagraphGroup();
+            m_bIsInFrame = true;
+        }
+
         if (!m_pCurrentBuffer)
             Mapper().props(pParagraphProperties);
         else
@@ -2337,6 +2378,18 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_AFTNSTART:
             lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue);
             break;
+        case RTF_ABSW:
+            m_aStates.top().aFrame.nW = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_ABSH:
+            m_aStates.top().aFrame.nH = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_POSX:
+            m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_POSY:
+            m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam);
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -2997,6 +3050,7 @@ RTFParserState::RTFParserState()
     aLevelNumbers(),
     aPicture(),
     aShape(),
+    aFrame(),
     nCellX(0),
     nCells(0),
     bIsCjk(false),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index b0c4668..fda4280 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -187,6 +187,13 @@ namespace writerfilter {
                 short nCropT, nCropB, nCropL, nCropR;
         };
 
+        /// Stores the properties of a frame
+        class RTFFrame
+        {
+            public:
+                int nX, nY, nW, nH;
+        };
+
         /// State of the parser, which gets saved / restored when changing groups.
         class RTFParserState
         {
@@ -241,6 +248,7 @@ namespace writerfilter {
 
                 RTFPicture aPicture;
                 RTFShape aShape;
+                RTFFrame aFrame;
 
                 /// Current cellx value.
                 int nCellX;
@@ -402,6 +410,8 @@ namespace writerfilter {
                 RTFReferenceTable::Entries_t m_aStyleTableEntries;
                 int m_nCurrentStyleIndex;
                 bool m_bEq;
+                /// If we are in a frame.
+                bool m_bIsInFrame;
 
         };
     } // namespace rtftok
commit 2f6dab766808e9e0382382d7f781d3892539556b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Aug 17 18:24:33 2011 +0200

    dmapper: textframes have to be inserted before text can be appended to them

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index dc487b5..f4d2c20 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1412,6 +1412,7 @@ void DomainMapper_Impl::PopAnnotation()
 
 void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape > xShape )
 {
+    uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
     m_bIsInShape = true;
     try
     {
@@ -1433,6 +1434,12 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
         xProps->setPropertyValue(
                 rPropNameSupplier.GetName( PROP_OPAQUE ),
                 uno::makeAny( true ) );
+        if (xSInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextFrame"))))
+        {
+            uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY_THROW);
+            uno::Reference<text::XTextRange> xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW);
+            xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False);
+        }
     }
     catch ( const uno::Exception& e )
     {
commit 997cd18a65c9b21a3a76a47e2c247b002e95e0e9
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 15 13:09:12 2011 +0200

    send crop values to dmapper

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2cb8e4a..8078ceb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2102,6 +2102,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_PICHGOAL:
             m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam);
             break;
+        case RTF_PICCROPL: m_aStates.top().aPicture.nCropL = TWIP_TO_MM100(nParam); break;
+        case RTF_PICCROPR: m_aStates.top().aPicture.nCropR = TWIP_TO_MM100(nParam); break;
+        case RTF_PICCROPT: m_aStates.top().aPicture.nCropT = TWIP_TO_MM100(nParam); break;
+        case RTF_PICCROPB: m_aStates.top().aPicture.nCropB = TWIP_TO_MM100(nParam); break;
         case RTF_SHPWRK:
             {
                 int nValue = 0;
commit db55a6392840145f2c7a677fc34ca88273d86411
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 15 12:54:01 2011 +0200

    implement RTF_PICWGOAL and RTF_PICHGOAL

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6b8c3a5..2cb8e4a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -594,9 +594,17 @@ int RTFDocumentImpl::resolvePict(bool bInline)
     RTFValue::Pointer_t pGraphicValue(new RTFValue(aGraphicAttributes, aGraphicSprms));
     // extent sprm
     RTFSprms aExtentAttributes;
-    for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes->begin(); i != m_aStates.top().aCharacterAttributes->end(); ++i)
-        if (i->first == NS_rtf::LN_XEXT || i->first == NS_rtf::LN_YEXT)
-            aExtentAttributes->push_back(make_pair(i->first, i->second));
+    int nXExt, nYExt;
+    nXExt = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
+    nYExt = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
+    if (m_aStates.top().aPicture.nScaleX != 100)
+        nXExt = (((long)m_aStates.top().aPicture.nScaleX) * ( nXExt - ( m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR ))) / 100L;
+    if (m_aStates.top().aPicture.nScaleY != 100)
+        nYExt = (((long)m_aStates.top().aPicture.nScaleY) * ( nYExt - ( m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB ))) / 100L;
+    RTFValue::Pointer_t pXExtValue(new RTFValue(nXExt));
+    RTFValue::Pointer_t pYExtValue(new RTFValue(nYExt));
+    aExtentAttributes->push_back(make_pair(NS_rtf::LN_XEXT, pXExtValue));
+    aExtentAttributes->push_back(make_pair(NS_rtf::LN_YEXT, pYExtValue));
     RTFValue::Pointer_t pExtentValue(new RTFValue(aExtentAttributes));
     // docpr sprm
     RTFSprms aDocprAttributes;
@@ -1844,20 +1852,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         return 0;
     }
 
-    // Trivial character attributes.
-    switch (nKeyword)
-    {
-        case RTF_PICW: nSprm = NS_rtf::LN_XEXT; if (m_aStates.top().nPictureScaleX) nParam = m_aStates.top().nPictureScaleX * nParam; break;
-        case RTF_PICH: nSprm = NS_rtf::LN_YEXT; if (m_aStates.top().nPictureScaleY) nParam = m_aStates.top().nPictureScaleY * nParam; break;
-        default: break;
-    }
-    if (nSprm > 0)
-    {
-        RTFValue::Pointer_t pValue(new RTFValue(nParam));
-        m_aStates.top().aCharacterAttributes->push_back(make_pair(nSprm, pValue));
-        return 0;
-    }
-
     // Info group.
     switch (nKeyword)
     {
@@ -2091,10 +2085,22 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             // Ignore these for now, the exporter always emits them with a zero parameter.
             break;
         case RTF_PICSCALEX:
-            m_aStates.top().nPictureScaleX = 0.01 * nParam;
+            m_aStates.top().aPicture.nScaleX = nParam;
             break;
         case RTF_PICSCALEY:
-            m_aStates.top().nPictureScaleY = 0.01 * nParam;
+            m_aStates.top().aPicture.nScaleY = nParam;
+            break;
+        case RTF_PICW:
+            m_aStates.top().aPicture.nWidth = nParam;
+            break;
+        case RTF_PICH:
+            m_aStates.top().aPicture.nHeight = nParam;
+            break;
+        case RTF_PICWGOAL:
+            m_aStates.top().aPicture.nGoalWidth = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_PICHGOAL:
+            m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam);
             break;
         case RTF_SHPWRK:
             {
@@ -2525,6 +2531,7 @@ int RTFDocumentImpl::popState()
     bool bListOverrideEntryEnd = false;
     bool bLevelTextEnd = false;
     RTFShape aShape;
+    RTFPicture aPicture;
     bool bPopShapeProperties = false;
     bool bPopPictureProperties = false;
     bool bFaltEnd = false;
@@ -2642,6 +2649,7 @@ int RTFDocumentImpl::popState()
             || m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTY)
     {
         aShape = m_aStates.top().aShape;
+        aPicture = m_aStates.top().aPicture;
         aAttributes = m_aStates.top().aCharacterAttributes;
         if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
             aShape.aProperties.push_back(make_pair(m_aStates.top().aDestinationText.makeStringAndClear(), OUString()));
@@ -2669,7 +2677,7 @@ int RTFDocumentImpl::popState()
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUEPICT)
     {
         bPopPictureProperties = true;
-        aAttributes = m_aStates.top().aCharacterAttributes;
+        aPicture = m_aStates.top().aPicture;
         aDestinationText = m_aStates.top().aDestinationText;
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPETEXT)
@@ -2890,13 +2898,14 @@ int RTFDocumentImpl::popState()
     else if (bPopShapeProperties)
     {
         m_aStates.top().aShape = aShape;
+        m_aStates.top().aPicture = aPicture;
         m_aStates.top().aCharacterAttributes = aAttributes;
     }
     else if (bFaltEnd)
         m_aStates.top().aTableSprms = aSprms;
     if (bPopPictureProperties)
     {
-        m_aStates.top().aCharacterAttributes = aAttributes;
+        m_aStates.top().aPicture = aPicture;
         m_aStates.top().aDestinationText = aDestinationText;
     }
     if (m_pCurrentBuffer == &m_aSuperBuffer)
@@ -2982,8 +2991,7 @@ RTFParserState::RTFParserState()
     nListLevelNum(0),
     aListLevelEntries(),
     aLevelNumbers(),
-    nPictureScaleX(0),
-    nPictureScaleY(0),
+    aPicture(),
     aShape(),
     nCellX(0),
     nCells(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 463b605..b0c4668 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -177,6 +177,16 @@ namespace writerfilter {
                 int nBottom;
         };
 
+        /// Stores the properties of a picture.
+        class RTFPicture
+        {
+            public:
+                sal_uInt16 nWidth, nHeight;
+                sal_uInt16 nGoalWidth, nGoalHeight;
+                sal_uInt16 nScaleX, nScaleY;
+                short nCropT, nCropB, nCropL, nCropR;
+        };
+
         /// State of the parser, which gets saved / restored when changing groups.
         class RTFParserState
         {
@@ -229,8 +239,7 @@ namespace writerfilter {
                 /// List of character positions in leveltext to replace.
                 std::vector<sal_Int32> aLevelNumbers;
 
-                float nPictureScaleX;
-                float nPictureScaleY;
+                RTFPicture aPicture;
                 RTFShape aShape;
 
                 /// Current cellx value.
commit 08a968d1004ec77b6b3c4da5d70f0b39e938e73d
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 15 12:20:19 2011 +0200

    unused code: picture size is set in the extent attributes

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d24fded..6b8c3a5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -566,15 +566,6 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         uno::Reference<graphic::XGraphic> xGraphic = xGraphicProvider->queryGraphic(aMediaProperties);
         xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Bitmap")), uno::Any(xGraphic));
 
-        // Set size
-        awt::Size aSize;
-        for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes->begin(); i != m_aStates.top().aCharacterAttributes->end(); ++i)
-            if (i->first == NS_rtf::LN_XEXT)
-                aSize.Width = i->second->getInt();
-            else if (i->first == NS_rtf::LN_YEXT)
-                aSize.Height = i->second->getInt();
-        xShape->setSize(aSize);
-
         RTFValue::Pointer_t pShapeValue(new RTFValue(xShape));
         m_aObjectAttributes->push_back(make_pair(NS_ooxml::LN_shape, pShapeValue));
         return 0;
commit eecb1bb4efc8f82e4b32720d8878000214f4db5f
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 12 18:33:52 2011 +0200

    no special handling of text box shapes, we already have a drawpage set

diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 71482c9..46664f5 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -274,7 +274,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                     OUStringToOString( i->second, RTL_TEXTENCODING_UTF8 ).getStr());
     }
 
-    if (nType == 75 || nType == 202) // picture frame or text box
+    if (nType == 75) // picture frame
     {
         if (bPib)
             m_rImport.resolvePict(false);
commit dddba7cb21e052179ae1bd3eb7da97d1f992b57b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 12 17:41:38 2011 +0200

    bugus null pointer check

diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 212eecd..71482c9 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -63,7 +63,7 @@ RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument,
     : m_rImport(rDocument)
 {
     uno::Reference<drawing::XDrawPageSupplier> xDrawings(xDstDoc, uno::UNO_QUERY);
-    if (m_xDrawPage.is() && xDrawings.is())
+    if (xDrawings.is())
         m_xDrawPage.set(xDrawings->getDrawPage(), uno::UNO_QUERY);
 }
 


More information about the Libreoffice-commits mailing list