[Libreoffice-commits] .: 4 commits - filter/inc filter/source oox/source sw/qa sw/source

Lubos Lunak llunak at kemper.freedesktop.org
Mon May 28 09:07:02 PDT 2012


 filter/inc/filter/msfilter/msdffimp.hxx |    2 +
 filter/source/msfilter/msdffimp.cxx     |   20 +++++++++++++++++--
 oox/source/vml/vmlshape.cxx             |    6 ++---
 oox/source/vml/vmlshapecontext.cxx      |    9 ++++++++
 sw/qa/extras/ww8tok/data/n757118.doc    |binary
 sw/qa/extras/ww8tok/ww8tok.cxx          |   33 ++++++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8graf2.cxx       |   30 ++++++++++++++++++++---------
 sw/source/filter/ww8/ww8par.cxx         |   12 +++++++++++
 8 files changed, 98 insertions(+), 14 deletions(-)

New commits:
commit 985f9740f76fb735ea99868cf6b0445811ef568f
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon May 28 17:49:59 2012 +0200

    testcase for bnc#757118
    
    Change-Id: I992c114669a9012a18982cf8cd313e3bdccdcb32

diff --git a/sw/qa/extras/ww8tok/data/n757118.doc b/sw/qa/extras/ww8tok/data/n757118.doc
new file mode 100644
index 0000000..2c69485
Binary files /dev/null and b/sw/qa/extras/ww8tok/data/n757118.doc differ
diff --git a/sw/qa/extras/ww8tok/ww8tok.cxx b/sw/qa/extras/ww8tok/ww8tok.cxx
index fc9f650..08c77c0 100644
--- a/sw/qa/extras/ww8tok/ww8tok.cxx
+++ b/sw/qa/extras/ww8tok/ww8tok.cxx
@@ -27,6 +27,7 @@
 
 #include "../swmodeltestbase.hxx"
 
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/TableBorder.hpp>
 #include <com/sun/star/text/XDependentTextField.hpp>
@@ -46,6 +47,7 @@ public:
     void testN760294();
     void testN750255();
     void testN652364();
+    void testN757118();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -53,6 +55,7 @@ public:
     CPPUNIT_TEST(testN760294);
     CPPUNIT_TEST(testN750255);
     CPPUNIT_TEST(testN652364);
+    CPPUNIT_TEST(testN757118);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -175,6 +178,36 @@ xray para2.PageStyleName
     CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
 }
 
+void Test::testN757118()
+{
+    load( "n757118.doc" );
+/*
+Two pairs of horizontal rules (one absolute width, one relative width)
+have the same width (full page width, half page width).
+xray ThisComponent.DrawPage.getByIndex(0).BoundRect
+*/
+    uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
+    uno::Reference<drawing::XShape> rule1, rule2, rule3, rule4;
+    drawPage->getByIndex(0) >>= rule1;
+    drawPage->getByIndex(1) >>= rule2;
+    drawPage->getByIndex(2) >>= rule3;
+    drawPage->getByIndex(3) >>= rule4;
+    uno::Reference<beans::XPropertySet> ruleProperties1(rule1, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> ruleProperties2(rule2, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> ruleProperties3(rule3, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> ruleProperties4(rule4, uno::UNO_QUERY);
+    awt::Rectangle boundRect1, boundRect2, boundRect3, boundRect4;
+    ruleProperties1->getPropertyValue( "BoundRect" ) >>= boundRect1;
+    ruleProperties2->getPropertyValue( "BoundRect" ) >>= boundRect2;
+    ruleProperties3->getPropertyValue( "BoundRect" ) >>= boundRect3;
+    ruleProperties4->getPropertyValue( "BoundRect" ) >>= boundRect4;
+    // compare, allow for < 5 differences because of rounding errors
+    CPPUNIT_ASSERT( abs( boundRect1.Width - boundRect3.Width ) < 5 );
+    CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 5845298e615a599d5edc7c42275b52ae954250e8
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon May 28 17:21:10 2012 +0200

    fix horizontal rule width in .doc documents (bnc#757118)
    
    MSO uses undocumented properties that seem to map to o:hr and o:hrpct
    from .docx (including differences between .docx spec and implementation),
    so treat horizontal rule width the same way in .doc too. Also remove
    the guesswork for #i17200# that is not quite correct and no longer needed.
    
    Change-Id: Ibec543fa1679ca0b20e86ef6b4f77147b18dff7e

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index ad2e55a..db15f86 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -319,6 +319,8 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
     sal_Bool        bVFlip :1;
     sal_Bool        bHFlip :1;
     sal_Bool        bAutoWidth      :1;
+    int             relativeHorizontalWidth; // in 0.1% or -1 for none
+    bool            isHorizontalRule;
 
     SvxMSDffImportRec();
     SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 49ba211..9d5e1dc 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5209,6 +5209,18 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                         *(pImpRec->pYRelTo) = nUDData;
                         break;
                     case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
+                    case 0x0393:
+                    // This seems to correspond to o:hrpct from .docx (even including
+                    // the difference that it's in 0.1% even though the .docx spec
+                    // says it's in 1%).
+                        pImpRec->relativeHorizontalWidth = nUDData;
+                        break;
+                    case 0x0394:
+                    // And this is really just a guess, but a mere presence of this
+                    // flag makes a horizontal rule be as wide as the page (unless
+                    // overriden by something), so it probably matches o:hr from .docx.
+                        pImpRec->isHorizontalRule = true;
+                        break;
                 }
                 if ( rSt.GetError() != 0 )
                     break;
@@ -7507,7 +7519,9 @@ SvxMSDffImportRec::SvxMSDffImportRec()
       aTextId( 0, 0 ),
       nNextShapeId( 0 ),
       nShapeId( 0 ),
-      eShapeType( mso_sptNil )
+      eShapeType( mso_sptNil ),
+      relativeHorizontalWidth( -1 ),
+      isHorizontalRule( false )
 {
       eLineStyle      = mso_lineSimple; // GPF-Bug #66227#
       eLineDashing    = mso_lineSolid;
@@ -7545,7 +7559,9 @@ SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy)
       aTextId( rCopy.aTextId ),
       nNextShapeId( rCopy.nNextShapeId ),
       nShapeId( rCopy.nShapeId ),
-      eShapeType( rCopy.eShapeType )
+      eShapeType( rCopy.eShapeType ),
+      relativeHorizontalWidth( rCopy.relativeHorizontalWidth ),
+      isHorizontalRule( rCopy.isHorizontalRule )
 {
     if (rCopy.pXRelTo)
     {
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 3bcbaf7..93ef5e7 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -528,15 +528,6 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
             // verlinkte Grafik im Escher-Objekt
             SdrObject* pObject = 0;
 
-            //#i17200#, a bit of guesswork I'm afraid
-            if (aPic.dxaGoal == 1000 && aPic.mx == 1)  //100% hack ?
-            {
-                aPic.mx = msword_cast<sal_uInt16>(
-                    maSectionManager.GetPageWidth() -
-                    maSectionManager.GetPageRight() -
-                    maSectionManager.GetPageLeft());
-            }
-
             WW8PicDesc aPD( aPic );
             String aGrName;
             if (!pMSDffManager)
@@ -577,6 +568,27 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
 
                 if( pRecord )
                 {
+
+                    // Horizontal rule may have its width given as % of page width
+                    // (-1 is used if not given, 0 means the object has fixed width).
+                    // Additionally, if it's a horizontal rule without width given,
+                    // assume 100.0% width.
+                    int relativeWidth = pRecord->relativeHorizontalWidth;
+                    if( relativeWidth == -1 )
+                        relativeWidth = pRecord->isHorizontalRule ? 1000 : 0;
+                    if( relativeWidth != 0 )
+                    {
+                        aPic.mx = msword_cast<sal_uInt16>(
+                            maSectionManager.GetPageWidth() -
+                            maSectionManager.GetPageRight() -
+                            maSectionManager.GetPageLeft()) * relativeWidth / 1000;
+                        aPD = WW8PicDesc( aPic );
+                        // This SetSnapRect() call adjusts the size of the object itself,
+                        // no idea why it's this call (or even what the call actually does),
+                        // but that's what ImportGraf() (called by ImportObj()) uses.
+                        pObject->SetSnapRect( Rectangle( 0, 0, aPD.nWidth, aPD.nHeight ));
+                    }
+
                     //A graphic of this type in this location is always
                     //inline, and uses the pic in the same mould as ww6
                     //graphics.
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index fdeafca..1d245c2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -490,6 +490,18 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                         *(pImpRec->pYRelTo) = nUDData;
                         break;
                     case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
+                    case 0x0393:
+                    // This seems to correspond to o:hrpct from .docx (even including
+                    // the difference that it's in 0.1% even though the .docx spec
+                    // says it's in 1%).
+                        pImpRec->relativeHorizontalWidth = nUDData;
+                        break;
+                    case 0x0394:
+                    // And this is really just a guess, but a mere presence of this
+                    // flag makes a horizontal rule be as wide as the page (unless
+                    // overriden by something), so it probably matches o:hr from .docx.
+                        pImpRec->isHorizontalRule = true;
+                        break;
                 }
                 if ( rSt.GetError() != 0 )
                     break;
commit 96c7ab19b77c2f90acd4c34552474b0f616f48a7
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri May 25 11:16:40 2012 +0200

    hack the same meaning for o:hr handling like MSO uses
    
    This doesn't in fact change much in LO, since ShapeType::getAbsRectangle()
    uses 0 as the reference size, 100% is still actually 0.
    
    Change-Id: I81690d710402224c8477c90ad14672b593aacc24

diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index ddae966..e6485f3 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -267,6 +267,15 @@ ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper& rParent, ShapeType& r
     mrTypeModel.moCoordPos = lclDecodeInt32Pair( rAttribs, XML_coordorigin );
     mrTypeModel.moCoordSize = lclDecodeInt32Pair( rAttribs, XML_coordsize );
     setStyle( rAttribs.getString( XML_style, OUString() ) );
+    if( lclDecodeBool( rAttribs, O_TOKEN( hr )).get( false ))
+    {   // MSO's handling of o:hr width is nowhere near what the spec says:
+        // - o:hrpct is not in % but in 0.1%
+        // - if o:hrpct is not given, 100% width is assumed
+        // - given width is used only if explicit o:hrpct="0" is given
+        OUString hrpct = rAttribs.getString( O_TOKEN( hrpct ), "1000" );
+        if( hrpct != "0" )
+            mrTypeModel.maWidth = OUString::valueOf( hrpct.toInt32() / 10 ) + "%";
+    }
 
     // stroke settings (may be overridden by v:stroke element later)
     mrTypeModel.maStrokeModel.moStroked = lclDecodeBool( rAttribs, XML_stroked );
commit c52ba433491afbca70aa1977a624c795bdd5b9ef
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri May 25 11:04:06 2012 +0200

    Y, height are in Y coordinates
    
    Change-Id: If75567533b5e00417f749bd8e957a317dda02804

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 4000932..0a10e07 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -175,7 +175,7 @@ Rectangle ShapeType::getAbsRectangle() const
     if ( nWidth == 0 )
         nWidth = 1;
 
-    sal_Int32 nHeight = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, true, true );
+    sal_Int32 nHeight = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, false, true );
     if ( nHeight == 0 )
         nHeight = 1;
 
@@ -464,10 +464,10 @@ Reference<XShape> LineShape::implConvertAndInsert(const Reference<XShapes>& rxSh
     sal_Int32 nIndex = 0;
 
     aShapeRect.X = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maFrom.getToken(0, ',', nIndex), 0, true, true);
-    aShapeRect.Y = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maFrom.getToken(0, ',', nIndex), 0, true, true);
+    aShapeRect.Y = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maFrom.getToken(0, ',', nIndex), 0, false, true);
     nIndex = 0;
     aShapeRect.Width = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maTo.getToken(0, ',', nIndex), 0, true, true) - aShapeRect.X;
-    aShapeRect.Height = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maTo.getToken(0, ',', nIndex), 0, true, true) - aShapeRect.Y;
+    aShapeRect.Height = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maTo.getToken(0, ',', nIndex), 0, false, true) - aShapeRect.Y;
 
     return SimpleShape::implConvertAndInsert(rxShapes, aShapeRect);
 }


More information about the Libreoffice-commits mailing list