[Libreoffice-commits] .: 2 commits - oox/source sw/qa

Lubos Lunak llunak at kemper.freedesktop.org
Mon Jun 11 04:51:43 PDT 2012


 oox/source/vml/vmlshape.cxx        |   15 ++++++++++++---
 sw/qa/extras/ooxmltok/ooxmltok.cxx |    5 +++++
 2 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit 0016757efef898205452a586ba5927e5d11fdabe
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Jun 8 19:31:32 2012 +0200

    attempt to anchor vml shapes properly as they should be
    
    This is a mess. Shapes from oox/vml are added to Writer by calling
    SwXDrawPage::add(), which forces the shapes to be AT_PAGE, because
    the pDoc->GetCurrentLayout() there is NULL. After that writerfilter
    in DomainMapper_Impl::PushShapeContext() tries to do further
    tricks with the anchoring. Such as the fix for bnc#764005
    (0a412cc13edf0904524ee2cf1e38ccc36b713065) that broke inline shapes
    because of the AT_PAGE above.
    
    So try to set the proper anchoring already in oox, although I'm not
    entirely sure I got it right. Ideally writerfilter should not touch
    it, but when I simply removed it another testcase breaks, so hopefully
    this all can be cleaned up somewhen later when we have enough testcases
    for all the possibilities.
    
    Change-Id: I7dd95d87bd027ce0f129f76b3377f3d1445c34d1

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index b66546b..d0984ab 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -611,11 +611,20 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
                 aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X);
                 aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
                 aPropSet.setProperty(PROP_Opaque, sal_False);
+                // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
+                // the spec talks about can be), but with Writer SwXDrawPage::add()
+                // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
+                aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
             }
-            else if( maTypeModel.maPosition == "static" || maTypeModel.maPosition.isEmpty())
-            { // static position (the default) means anchored inline
-                aPropSet.setProperty(PROP_AnchorType, makeAny(text::TextContentAnchorType_AS_CHARACTER));
+            else if( maTypeModel.maPosition == "relative" )
+            {   // I'm not very sure this is correct either.
+                aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PARAGRAPH);
             }
+            else // static (is the default) means anchored inline
+            {
+                aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER);
+            }
+
             if ( maTypeModel.maPositionVerticalRelative == "page" )
             {
                 aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
commit 87d28b3a6c3d2d442499672ad0dc1b6c9cd095d1
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Jun 8 19:36:22 2012 +0200

    test also for inline vml shape being anchored inline
    
    This got broken by 0a412cc13edf0904524ee2cf1e38ccc36b713065.
    
    Change-Id: I8d500ea54bee8b09e1a01cf4cd14d08669f49a73

diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index dbd56cd..c53a35f 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -263,9 +263,11 @@ void Test::testN705956_1()
     load( "n705956-1.docx" );
 /*
 Get the first image in the document and check it's the one image in the document.
+It should be also anchored inline (as character).
 image = ThisComponent.DrawPage.getByIndex(0)
 graphic = image.Graphic
 xray graphic.Size
+xray image.AnchorType
 */
     uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
     uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
@@ -279,6 +281,9 @@ xray graphic.Size
     uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(120), bitmap->getSize().Width );
     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(106), bitmap->getSize().Height );
+    text::TextContentAnchorType anchorType;
+    imageProperties->getPropertyValue( "AnchorType" ) >>= anchorType;
+    CPPUNIT_ASSERT_EQUAL( text::TextContentAnchorType_AS_CHARACTER, anchorType );
 }
 
 void Test::testN705956_2()


More information about the Libreoffice-commits mailing list