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

Lubos Lunak llunak at kemper.freedesktop.org
Thu Jun 7 08:03:05 PDT 2012


 oox/source/vml/vmlshape.cxx                       |    4 ++
 sw/qa/extras/ooxmltok/data/n764745-alignment.docx |binary
 sw/qa/extras/ooxmltok/ooxmltok.cxx                |   19 +++++++++++++
 sw/source/core/unocore/unodraw.cxx                |   31 ++++++++++++++--------
 4 files changed, 44 insertions(+), 10 deletions(-)

New commits:
commit 133822bd25e269441faaefe7c1e67091d6692e39
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Jun 7 16:48:00 2012 +0200

    testcase of the alignment + anchored inline part of bnc#764745
    
    Change-Id: Iab82a88473c0c1d7cf75fcc1f2064bca105b0293

diff --git a/sw/qa/extras/ooxmltok/data/n764745-alignment.docx b/sw/qa/extras/ooxmltok/data/n764745-alignment.docx
new file mode 100644
index 0000000..d29e980
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n764745-alignment.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 2b050eb..dbd56cd 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -65,6 +65,7 @@ public:
     void testN760764();
     void testN764005();
     void testSmartart();
+    void testN764745();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -83,6 +84,7 @@ public:
     CPPUNIT_TEST(testN760764);
     CPPUNIT_TEST(testN764005);
     CPPUNIT_TEST(testSmartart);
+    CPPUNIT_TEST(testN764745);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -472,6 +474,23 @@ void Test::testSmartart()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
 }
 
+void Test::testN764745()
+{
+    load( "n764745-alignment.docx" );
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
+    // The paragraph is right-aligned and the picture does not explicitly specify position,
+    // so check it's anchored as character and in the right side of the document.
+    text::TextContentAnchorType anchorType;
+    xPropertySet->getPropertyValue("AnchorType") >>= anchorType;
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, anchorType);
+    awt::Point pos;
+    xPropertySet->getPropertyValue("AnchorPosition") >>= pos;
+    // not sure how to find out the document width, but in my test the anchor x is >12000
+    CPPUNIT_ASSERT( pos.X > 10000 );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 21eca1c73ffbec4417dad46bd103215e8e288880
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jun 6 20:45:56 2012 +0200

    shapes with position:static (default) should be anchored inline
    
    Visible with incorrect alignment of the image in the footer
    in the doc from bnc#764745.
    
    Change-Id: Ibea9f38f7404981a9a846c23a09f8244c6020797

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 44fc631..b66546b 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -612,6 +612,10 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
                 aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
                 aPropSet.setProperty(PROP_Opaque, sal_False);
             }
+            else if( maTypeModel.maPosition == "static" || maTypeModel.maPosition.isEmpty())
+            { // static position (the default) means anchored inline
+                aPropSet.setProperty(PROP_AnchorType, makeAny(text::TextContentAnchorType_AS_CHARACTER));
+            }
             if ( maTypeModel.maPositionVerticalRelative == "page" )
             {
                 aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
commit 5de61f7a4ddb502730454e4bf3232f7f4b4175e1
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jun 6 20:29:57 2012 +0200

    handle properly anchor transition at page->at paragraph->as character
    
    Otherwise setting text range afterwards crashes with pHnt being NULL.
    
    Change-Id: Ib4ac2712c061605dcaaa262280c0307f7a9af2ce

diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 329bed9..267f6f2 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1344,18 +1344,29 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
                             aSet.Put( aNewAnchor );
                             pFmt->SetFmtAttr(aSet);
                             bSetAttr = false;
-                            if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
-                                (FLY_AS_CHAR != eOldAnchorId))
+                        }
+                        if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
+                            (FLY_AS_CHAR != eOldAnchorId))
+                        {
+                            SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
+                            if( pDoc->GetCurrentLayout() )
                             {
-                                //the RES_TXTATR_FLYCNT needs to be added now
-                                SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
-                                SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
-                                SwFmtFlyCnt aFmt( pFlyFmt );
-                                pNd->InsertItem(aFmt,
-                                    aPam.GetPoint()->nContent.GetIndex(), 0 );
-                                //aPam.GetPoint()->nContent--;
-
+                                SwCrsrMoveState aState( MV_SETONLYTEXT );
+                                Point aTmp( pObj->GetSnapRect().TopLeft() );
+                                pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
+                            }
+                            else
+                            {
+                                //without access to the layout the last node of the body will be used as anchor position
+                                aPam.Move( fnMoveBackward, fnGoDoc );
                             }
+                            //the RES_TXTATR_FLYCNT needs to be added now
+                            SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
+                            SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
+                            SwFmtFlyCnt aFmt( pFlyFmt );
+                            pNd->InsertItem(aFmt,
+                                aPam.GetPoint()->nContent.GetIndex(), 0 );
+                            //aPam.GetPoint()->nContent--;
                         }
                         if( bSetAttr )
                             pFmt->SetFmtAttr(aSet);


More information about the Libreoffice-commits mailing list