[PATCH libreoffice-4-0] fdo#30983 RTF filter: fix handling of RTF_PVPG and RTF_PHPG

Miklos Vajna (via Code Review) gerrit at gerrit.libreoffice.org
Wed Mar 27 03:45:31 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3081

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/81/3081/1

fdo#30983 RTF filter: fix handling of RTF_PVPG and RTF_PHPG

There were two issues here:

1) The export filter never exported these keywords.

2) The "flymaincnt" RTF extension we inherited from OOo actually never
worked (i.e. it's like this since 7b0b5cdf, the initial import...), as
RTFVertOrient / RTFHoriOrient's second parameter was stored in 1 bit, so
text::RelOrientation::PAGE_FRAME (7) was read back as 1 instead.

Note that I want to get rid of this flymaincnt extension in the exporter
anyway soon, so killing the RTFVertOrient / RTFHoriOrient duplication is
pointless: the sw version will go away.

(cherry picked from commit b4845db4260db70cb3aaf03758cb4a1ca5fa88ed)

Change-Id: I5335567833ecf87e6b0ba7c73150a7b95c57f237
---
A sw/qa/extras/rtfexport/data/fdo30983.rtf
M sw/qa/extras/rtfexport/rtfexport.cxx
M sw/source/filter/inc/rtf.hxx
M sw/source/filter/ww8/rtfattributeoutput.cxx
M writerfilter/source/rtftok/rtffly.hxx
5 files changed, 78 insertions(+), 6 deletions(-)



diff --git a/sw/qa/extras/rtfexport/data/fdo30983.rtf b/sw/qa/extras/rtfexport/data/fdo30983.rtf
new file mode 100644
index 0000000..bd4dd96
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo30983.rtf
@@ -0,0 +1,43 @@
+{\rtf1\ansi\deff4\adeflang1025
+\paperh15840\paperw12240\margl902\margr958\margt1440\margb735\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn902\margrsxn958\margtsxn1440\margbsxn735\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\absw2380\absh-1244\pvpg\posy465\phpg\posx8437
+{\*\flymaincnt96\flyvert29040\flyhorz30464\flyanchor4\pgndec}
+\s111\sl200\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs16\lang1033
+{\dbch\af5\loch\f1\rtlch \ltrch\loch\loch\f5
+5983 Red Pine Blvd}
+\par \s111\sl200\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs16\lang1033
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+White Bear Township, MN 55110}
+\par \s110\sl200\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs16\lang1033
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+Home 651-426-9645}
+\par \s110\sl200\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs16\lang1033
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+Cell 651-245-1843}
+\par \s110\sl200\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs16\lang1033
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+E-mail dadsouch at gmail.com}
+\par \pard
+\pard\plain \s123\sl240\slmult0\ql\widctlpar
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\li2160\ri0\lin2160\rin0\fi0\sb0\sa440\ltrpar\cf0\expnd-4\expndtw-20\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs48\lang1033\li-11\ri0\lin-11\rin0\fi0\sb0\sa144
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+M}
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+ichael P. Soucheray}
+\par \pard\plain \s114\sl220\slmult0\ql\widctlpar\tx2160\tqr\tx6480
+{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}
+\aspalpha\li0\ri-360\lin0\rin-360\fi0\sb220\sa40\ltrpar\cf0\dbch\af6\langfe255\dbch\af6\afs20\alang1025\loch\f6\fs20\lang1033\li-11\ri0\lin-11\rin0\fi0\sb0\sa144
+{\dbch\af5\rtlch \ltrch\loch\loch\f5
+Experienced general}
+\par }
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 18ddf1b..0610516 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
 
 #include <unotools/tempfile.hxx>
 #include <vcl/svapp.hxx>
@@ -71,6 +72,7 @@
     void testFdo53604();
     void testFdo52286();
     void testFdo61507();
+    void testFdo30983();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -116,6 +118,7 @@
         {"fdo53604.odt", &Test::testFdo53604},
         {"fdo52286.odt", &Test::testFdo52286},
         {"fdo61507.rtf", &Test::testFdo61507},
+        {"fdo30983.rtf", &Test::testFdo30983},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -488,6 +491,16 @@
     CPPUNIT_ASSERT_EQUAL(6, getLength());
 }
 
+void Test::testFdo30983()
+{
+    // These were 'page text area', not 'entire page', i.e. both the horizontal
+    // and vertical positions were incorrect.
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrientRelation"));
+    CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrientRelation"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/inc/rtf.hxx b/sw/source/filter/inc/rtf.hxx
index f2fc54f..f82780a 100644
--- a/sw/source/filter/inc/rtf.hxx
+++ b/sw/source/filter/inc/rtf.hxx
@@ -27,7 +27,7 @@
     union {
         struct {
             sal_uInt16 nOrient : 4;
-            sal_uInt16 nRelOrient : 1;
+            sal_uInt16 nRelOrient : 4;
         } Flags;
         sal_uInt16 nVal;
     } Value;
@@ -52,7 +52,7 @@
         struct {
             sal_uInt16 nOrient : 4;
             sal_uInt16 nRelAnchor : 4;
-            sal_uInt16 nRelOrient : 1;
+            sal_uInt16 nRelOrient : 4;
         } Flags;
         sal_uInt16 nVal;
     } Value;
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 36dc481..33032b1 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2770,7 +2770,15 @@
 
     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
     {
-        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPARA);
+        switch (rFlyVert.GetRelationOrient())
+        {
+            case text::RelOrientation::PAGE_FRAME:
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPG);
+            break;
+            default:
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPARA);
+            break;
+        }
 
         switch (rFlyVert.GetVertOrient())
         {
@@ -2808,7 +2816,15 @@
 
     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
     {
-        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHCOL);
+        switch (rFlyHori.GetRelationOrient())
+        {
+            case text::RelOrientation::PAGE_FRAME:
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHPG);
+            break;
+            default:
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHCOL);
+            break;
+        }
 
         const char* pS = 0;
         switch(rFlyHori.GetHoriOrient())
diff --git a/writerfilter/source/rtftok/rtffly.hxx b/writerfilter/source/rtftok/rtffly.hxx
index 9e2141c..918f800 100644
--- a/writerfilter/source/rtftok/rtffly.hxx
+++ b/writerfilter/source/rtftok/rtffly.hxx
@@ -99,7 +99,7 @@
                     struct
                     {
                         sal_uInt16 nOrient : 4;
-                        sal_uInt16 nRelOrient : 1;
+                        sal_uInt16 nRelOrient : 4;
                     } Flags;
                     sal_uInt16 nVal;
                 } Value;
@@ -180,7 +180,7 @@
                     {
                         sal_uInt16 nOrient : 4;
                         sal_uInt16 nRelAnchor : 4;
-                        sal_uInt16 nRelOrient : 1;
+                        sal_uInt16 nRelOrient : 4;
                     } Flags;
                     sal_uInt16 nVal;
                 } Value;

-- 
To view, visit https://gerrit.libreoffice.org/3081
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5335567833ecf87e6b0ba7c73150a7b95c57f237
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos at suse.cz>



More information about the LibreOffice mailing list