sw/qa/extras/ooxmlimport/ooxmlimport.cxx      |    2 +
 writerfilter/source/dmapper/GraphicImport.cxx |   42 +++++++++++++-------------
 2 files changed, 23 insertions(+), 21 deletions(-)

New commits:
commit 4932775dae4642bd1157495927c7fcda2589ca15
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Tue Nov 26 16:54:05 2013 +0100

    DOCX drawingML shape import: handle wp:align for wps:txbx positioning
    
    I.e. previously only absolutely positioned textboxes were handled, with
    this, centered textboxes are fine as well. Given that the drawingml
    picture import code already supported this, refactor common code to a
    common method.
    
    Change-Id: I56e0dbfa0ffc7e27a70a0e8fb8477681389a51cf

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 551d743..69beb44 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1539,6 +1539,8 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, 
"textbox-wps-only.docx")
     uno::Reference<container::XIndexAccess> 
xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xFrame(xIndexAccess->getByIndex(0), 
uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("Hello world!"), xFrame->getString());
+    // Position wasn't horizontally centered.
+    CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, 
getProperty<sal_Int16>(xFrame, "HoriOrient"));
 
     // Position was the default (hori center, vert top) for the textbox.
     xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index fe5ef95..25056d6 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -354,6 +354,25 @@ public:
         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_TOP_MARGIN ), uno::makeAny(nTopMargin));
         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_BOTTOM_MARGIN ), uno::makeAny(nBottomMargin));
     }
+
+    void applyPosition(uno::Reference< beans::XPropertySet > 
xGraphicObjectProperties) const
+    {
+        PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT          ),
+                uno::makeAny(nHoriOrient));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_POSITION),
+                uno::makeAny(nLeftPosition));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_RELATION ),
+                uno::makeAny(nHoriRelation));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_PAGE_TOGGLE ),
+                uno::makeAny(bPageToggle));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT          ),
+                uno::makeAny(nVertOrient));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_POSITION),
+                uno::makeAny(nTopPosition));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_RELATION ),
+                uno::makeAny(nVertRelation));
+    }
 };
 
 
@@ -1008,12 +1027,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
                         if 
(xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
                         {
                             // For non-textframes, this is handled already in 
oox::drawingml::Shape::createAndInsert().
-                            xShapeProps->setPropertyValue("HoriOrient", 
uno::makeAny(text::HoriOrientation::NONE));
-                            xShapeProps->setPropertyValue("VertOrient", 
uno::makeAny(text::VertOrientation::NONE));
-                            
xShapeProps->setPropertyValue("HoriOrientPosition", 
uno::makeAny(m_pImpl->nLeftPosition));
-                            
xShapeProps->setPropertyValue("VertOrientPosition", 
uno::makeAny(m_pImpl->nTopPosition));
-                            
xShapeProps->setPropertyValue("HoriOrientRelation", 
uno::makeAny(text::RelOrientation::FRAME));
-                            
xShapeProps->setPropertyValue("VertOrientRelation", 
uno::makeAny(text::RelOrientation::FRAME));
+                            m_pImpl->applyPosition(xShapeProps);
                         }
 
                         m_pImpl->applyMargins(xShapeProps);
@@ -1496,21 +1510,7 @@ uno::Reference< text::XTextContent > 
GraphicImport::createGraphicObject( const b
                     m_pImpl->nLeftPosition = 0;
                 }
 
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT          ),
-                    uno::makeAny(m_pImpl->nHoriOrient));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_POSITION),
-                    uno::makeAny(m_pImpl->nLeftPosition));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_HORI_ORIENT_RELATION ),
-                    uno::makeAny(m_pImpl->nHoriRelation));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_PAGE_TOGGLE ),
-                    uno::makeAny(m_pImpl->bPageToggle));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT          ),
-                    uno::makeAny(m_pImpl->nVertOrient));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_POSITION),
-                    uno::makeAny(m_pImpl->nTopPosition));
-                
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( 
PROP_VERT_ORIENT_RELATION ),
-                uno::makeAny(m_pImpl->nVertRelation));
-
+                m_pImpl->applyPosition(xGraphicObjectProperties);
                 bool bOpaque = m_pImpl->bOpaque && 
!m_pImpl->rDomainMapper.IsInHeaderFooter( );
                 if( !bOpaque )
                 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to