[Libreoffice-commits] core.git: 7 commits - include/oox oox/source sw/qa

Miklos Vajna vmiklos at suse.cz
Tue Jul 2 02:56:09 PDT 2013


 include/oox/vml/vmlshape.hxx                |    1 
 include/oox/vml/vmltextbox.hxx              |   11 +++++-
 include/oox/vml/vmltextboxcontext.hxx       |   15 ++++++---
 oox/source/vml/vmlshape.cxx                 |    9 +++++
 oox/source/vml/vmlshapecontext.cxx          |    1 
 oox/source/vml/vmltextbox.cxx               |   34 ++++++++++++++++++--
 oox/source/vml/vmltextboxcontext.cxx        |   46 +++++++++++++++++++++++-----
 sw/qa/extras/ooxmlimport/data/fdo46361.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx    |   25 ++++++++++++++-
 9 files changed, 124 insertions(+), 18 deletions(-)

New commits:
commit 2bc574599bf47ab3d2d4e201e80896a91f225efe
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Jul 2 11:49:58 2013 +0200

    more SAL_OVERRIDE
    
    Change-Id: I7b3e908a0ce00f0d844803fdf628d3d757de92bd

diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx
index 150297f..37626d5 100644
--- a/include/oox/vml/vmltextboxcontext.hxx
+++ b/include/oox/vml/vmltextboxcontext.hxx
@@ -42,10 +42,10 @@ public:
                             const AttributeList& rAttribs );
 
     virtual ::oox::core::ContextHandlerRef
-                        onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
-    virtual void        onCharacters( const OUString& rChars );
-    virtual void        onStartElement(const AttributeList& rAttribs);
-    virtual void        onEndElement();
+                        onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
+    virtual void        onCharacters( const OUString& rChars ) SAL_OVERRIDE;
+    virtual void        onStartElement(const AttributeList& rAttribs) SAL_OVERRIDE;
+    virtual void        onEndElement() SAL_OVERRIDE;
 
 private:
     TextBox&            mrTextBox;
@@ -66,9 +66,9 @@ public:
                             const GraphicHelper& graphicHelper );
 
     virtual ::oox::core::ContextHandlerRef
-                        onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+                        onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
     virtual void        onStartElement(const AttributeList& rAttribs) SAL_OVERRIDE;
-    virtual void        onEndElement();
+    virtual void        onEndElement() SAL_OVERRIDE;
 
 private:
     TextBox&            mrTextBox;
commit 2a2105b002c482e6536d5c3046c9e7783c0cdca3
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Jul 2 11:45:54 2013 +0200

    fdo#46361 testcase
    
    Change-Id: Ie7ce4fb5c32ff4b3c1f3d7ee92d8358ae67fc6c1

diff --git a/sw/qa/extras/ooxmlimport/data/fdo46361.docx b/sw/qa/extras/ooxmlimport/data/fdo46361.docx
new file mode 100644
index 0000000..2f894e4
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo46361.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 7eaaa9f..d53094e 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -11,6 +11,7 @@
 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
@@ -122,6 +123,7 @@ public:
     void testN820504();
     void testFdo43641();
     void testTableAutoColumnFixedSize();
+    void testFdo46361();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -210,6 +212,7 @@ void Test::run()
         {"n820504.docx", &Test::testN820504},
         {"fdo43641.docx", &Test::testFdo43641},
         {"table-auto-column-fixed-size.docx", &Test::testTableAutoColumnFixedSize},
+        {"fdo46361.docx", &Test::testFdo46361},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1474,6 +1477,26 @@ void Test::testTableAutoColumnFixedSize()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(3996)), getProperty<sal_Int32>(xTextTable, "Width"));
 }
 
+void Test::testFdo46361()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xGroupShape(xDraws->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
+    // This was CENTER.
+    CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust"));
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
+    // This was LEFT.
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust")));
+    // This was black, not green.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x008000), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
+    // \n char was missing due to unhandled w:br.
+    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
+    // \n chars were missing, due to unhandled multiple w:p tags.
+    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY)->getString());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit ef53d4aec2a3d690de2c7cdaf73ca95bbe29a433
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 13:59:47 2013 +0200

    fdo#46361 oox: handle w:color for groupshape textboxes
    
    Change-Id: Ifcbf622a04a4b3f06d95c079d5e13ec3f505268f

diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 3b81caf..e3d07b8 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -103,6 +103,12 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
             aPropertyValue.Value = uno::makeAny(eAdjust);
             aPropVec.push_back(aPropertyValue);
         }
+        if (rFont.moColor.has())
+        {
+            aPropertyValue.Name = "CharColor";
+            aPropertyValue.Value = uno::makeAny(rFont.moColor.get().toUInt32(16));
+            aPropVec.push_back(aPropertyValue);
+        }
         uno::Sequence<beans::PropertyValue> aPropSeq(aPropVec.size());
         beans::PropertyValue* pValues = aPropSeq.getArray();
         for (std::vector<beans::PropertyValue>::iterator i = aPropVec.begin(); i != aPropVec.end(); ++i)
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 9fbf26c..d91c66a 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -129,6 +129,9 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs)
         case OOX_TOKEN(doc, br):
             mrTextBox.appendPortion( maParagraph, maFont, "\n" );
         break;
+        case OOX_TOKEN(doc, color):
+            maFont.moColor = rAttribs.getString( OOX_TOKEN(doc, val) );
+        break;
     }
 }
 
commit 5a737fca37cd5a5f90aa03a30688d447677d3b8a
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 16:47:56 2013 +0200

    fdo#46361 oox: handle w:jc for groupshape textboxes
    
    Change-Id: I21391d9a9f5b5173b599006287b33fdaab3c0c75

diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx
index 4975e6b..fc97dc7 100644
--- a/include/oox/vml/vmltextbox.hxx
+++ b/include/oox/vml/vmltextbox.hxx
@@ -37,6 +37,12 @@ struct ShapeTypeModel;
 
 // ============================================================================
 
+/// A text paragraph in a textbox.
+struct TextParagraphModel
+{
+    OptValue<OUString> moParaAdjust; ///< Paragraph adjust (left, center, right, etc.)
+};
+
 /** Font settings for a text portion in a textbox. */
 struct OOX_DLLPUBLIC TextFontModel
 {
@@ -57,10 +63,11 @@ struct OOX_DLLPUBLIC TextFontModel
 /** A text portion in a textbox with the same formatting for all characters. */
 struct TextPortionModel
 {
+    TextParagraphModel  maParagraph;
     TextFontModel       maFont;
     OUString     maText;
 
-    explicit            TextPortionModel( const TextFontModel& rFont, const OUString& rText );
+    explicit            TextPortionModel( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
 };
 
 // ============================================================================
@@ -72,7 +79,7 @@ public:
     explicit            TextBox(ShapeTypeModel& rTypeModel);
 
     /** Appends a new text portion to the textbox. */
-    void                appendPortion( const TextFontModel& rFont, const OUString& rText );
+    void                appendPortion( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
 
     /** Returns the current number of text portions. */
     inline size_t       getPortionCount() const { return maPortions.size(); }
diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx
index 1a44e41..150297f 100644
--- a/include/oox/vml/vmltextboxcontext.hxx
+++ b/include/oox/vml/vmltextboxcontext.hxx
@@ -36,6 +36,7 @@ public:
     explicit            TextPortionContext(
                             ::oox::core::ContextHandler2Helper& rParent,
                             TextBox& rTextBox,
+                            TextParagraphModel& rParagraph,
                             const TextFontModel& rParentFont,
                             sal_Int32 nElement,
                             const AttributeList& rAttribs );
@@ -48,6 +49,7 @@ public:
 
 private:
     TextBox&            mrTextBox;
+    TextParagraphModel  maParagraph;
     TextFontModel       maFont;
     size_t              mnInitialPortions;
 };
@@ -65,10 +67,12 @@ public:
 
     virtual ::oox::core::ContextHandlerRef
                         onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+    virtual void        onStartElement(const AttributeList& rAttribs) SAL_OVERRIDE;
     virtual void        onEndElement();
 
 private:
     TextBox&            mrTextBox;
+    TextParagraphModel  maParagraph;
 };
 
 // ============================================================================
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 27b4234..3b81caf 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/text/XTextAppend.hpp>
 #include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 namespace oox {
 namespace vml {
@@ -34,7 +35,8 @@ TextFontModel::TextFontModel()
 {
 }
 
-TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& rText ) :
+TextPortionModel::TextPortionModel( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText ) :
+    maParagraph( rParagraph ),
     maFont( rFont ),
     maText( rText )
 {
@@ -50,9 +52,9 @@ TextBox::TextBox(ShapeTypeModel& rTypeModel)
 {
 }
 
-void TextBox::appendPortion( const TextFontModel& rFont, const OUString& rText )
+void TextBox::appendPortion( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText )
 {
-    maPortions.push_back( TextPortionModel( rFont, rText ) );
+    maPortions.push_back( TextPortionModel( rParagraph, rFont, rText ) );
 }
 
 const TextFontModel* TextBox::getFirstFont() const
@@ -75,6 +77,7 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
     {
         beans::PropertyValue aPropertyValue;
         std::vector<beans::PropertyValue> aPropVec;
+        const TextParagraphModel& rParagraph = aIt->maParagraph;
         const TextFontModel& rFont = aIt->maFont;
         if (rFont.mobBold.has())
         {
@@ -88,6 +91,18 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
             aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.);
             aPropVec.push_back(aPropertyValue);
         }
+        if (rParagraph.moParaAdjust.has())
+        {
+            style::ParagraphAdjust eAdjust = style::ParagraphAdjust_LEFT;
+            if (rParagraph.moParaAdjust.get() == "center")
+                eAdjust = style::ParagraphAdjust_CENTER;
+            else if (rParagraph.moParaAdjust.get() == "right")
+                eAdjust = style::ParagraphAdjust_RIGHT;
+
+            aPropertyValue.Name = "ParaAdjust";
+            aPropertyValue.Value = uno::makeAny(eAdjust);
+            aPropVec.push_back(aPropertyValue);
+        }
         uno::Sequence<beans::PropertyValue> aPropSeq(aPropVec.size());
         beans::PropertyValue* pValues = aPropSeq.getArray();
         for (std::vector<beans::PropertyValue>::iterator i = aPropVec.begin(); i != aPropVec.end(); ++i)
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 4c025c9..9fbf26c 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -34,10 +34,11 @@ using ::oox::core::ContextHandlerRef;
 // ============================================================================
 
 TextPortionContext::TextPortionContext( ContextHandler2Helper& rParent,
-        TextBox& rTextBox, const TextFontModel& rParentFont,
+        TextBox& rTextBox, TextParagraphModel& rParagraph, const TextFontModel& rParentFont,
         sal_Int32 nElement, const AttributeList& rAttribs ) :
     ContextHandler2( rParent ),
     mrTextBox( rTextBox ),
+    maParagraph( rParagraph ),
     maFont( rParentFont ),
     mnInitialPortions( rTextBox.getPortionCount() )
 {
@@ -96,7 +97,7 @@ ContextHandlerRef TextPortionContext::onCreateContext( sal_Int32 nElement, const
     OSL_ENSURE( nElement != XML_font, "TextPortionContext::onCreateContext - nested <font> elements" );
     if (getNamespace(getCurrentElement()) == NMSP_doc)
         return this;
-    return new TextPortionContext( *this, mrTextBox, maFont, nElement, rAttribs );
+    return new TextPortionContext( *this, mrTextBox, maParagraph, maFont, nElement, rAttribs );
 }
 
 void TextPortionContext::onCharacters( const OUString& rChars )
@@ -108,10 +109,10 @@ void TextPortionContext::onCharacters( const OUString& rChars )
     {
         case XML_span:
             // replace all NBSP characters with SP
-            mrTextBox.appendPortion( maFont, rChars.replace( 0xA0, ' ' ) );
+            mrTextBox.appendPortion( maParagraph, maFont, rChars.replace( 0xA0, ' ' ) );
         break;
         default:
-            mrTextBox.appendPortion( maFont, rChars );
+            mrTextBox.appendPortion( maParagraph, maFont, rChars );
     }
 }
 
@@ -126,7 +127,7 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs)
             maFont.monSize = rAttribs.getInteger( OOX_TOKEN(doc, val) );
         break;
         case OOX_TOKEN(doc, br):
-            mrTextBox.appendPortion( maFont, "\n" );
+            mrTextBox.appendPortion( maParagraph, maFont, "\n" );
         break;
     }
 }
@@ -153,7 +154,7 @@ void TextPortionContext::onEndElement()
         meantime, the space character has to be added manually.
      */
     if( mrTextBox.getPortionCount() == mnInitialPortions )
-        mrTextBox.appendPortion( maFont, OUString( sal_Unicode( ' ' ) ) );
+        mrTextBox.appendPortion( maParagraph, maFont, OUString( sal_Unicode( ' ' ) ) );
 }
 
 // ============================================================================
@@ -207,22 +208,41 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att
             else if (nElement == OOX_TOKEN(doc, txbxContent)) return this;
         break;
         case XML_div:
-            if( nElement == XML_font ) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs );
+            if( nElement == XML_font ) return new TextPortionContext( *this, mrTextBox, maParagraph, TextFontModel(), nElement, rAttribs );
         break;
         case OOX_TOKEN(doc, txbxContent):
             if (nElement == OOX_TOKEN(doc, p)) return this;
         break;
         case OOX_TOKEN(doc, p):
-            if (nElement == OOX_TOKEN(doc, r)) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs );
+            if (nElement == OOX_TOKEN(doc, r))
+                return new TextPortionContext( *this, mrTextBox, maParagraph, TextFontModel(), nElement, rAttribs );
+            else
+                return this;
+        break;
+        case OOX_TOKEN(doc, pPr):
+            return this;
         break;
     }
     return 0;
 }
 
+void TextBoxContext::onStartElement(const AttributeList& rAttribs)
+{
+    switch (getCurrentElement())
+    {
+        case OOX_TOKEN(doc, jc):
+            maParagraph.moParaAdjust = rAttribs.getString( OOX_TOKEN(doc, val) );
+        break;
+    }
+}
+
 void TextBoxContext::onEndElement()
 {
     if (getCurrentElement() == OOX_TOKEN(doc, p))
-        mrTextBox.appendPortion( TextFontModel(), "\n" );
+    {
+        mrTextBox.appendPortion( maParagraph, TextFontModel(), "\n" );
+        maParagraph = TextParagraphModel();
+    }
 }
 
 // ============================================================================
commit 6bf79576aeca243db553ed3b5eade492dc35337b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 13:15:54 2013 +0200

    fdo#46361 oox: VML import of v-text-anchor for drawinglayer shapes
    
    Change-Id: Ib73d17fd8c9325f7f062d4a15b655e36b84bd351

diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index ca815ec..0312ec1 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -96,6 +96,7 @@ struct OOX_DLLPUBLIC ShapeTypeModel
     OptValue< OUString > moWrapAnchorY;  ///< The base object from which our vertical positioning should be calculated.
     OptValue< ::rtl::OUString > moWrapType;     ///< How to wrap the text around the object
     OptValue< ::rtl::OUString > moWrapSide;     ///< On which side to wrap the text around the object
+    OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically.
 
     explicit            ShapeTypeModel();
 
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 1cb4772..f95b7e1 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/awt/XControlModel.hpp>
 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -560,6 +561,14 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
             }
         }
 
+        // drawinglayer default is center, MSO default is top.
+        drawing::TextVerticalAdjust eTextVerticalAdjust = drawing::TextVerticalAdjust_TOP;
+        if (maTypeModel.maVTextAnchor == "middle")
+            eTextVerticalAdjust = drawing::TextVerticalAdjust_CENTER;
+        else if (maTypeModel.maVTextAnchor == "bottom")
+            eTextVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
+        PropertySet(xShape).setAnyProperty(PROP_TextVerticalAdjust, makeAny(eTextVerticalAdjust));
+
         if (getTextBox())
             getTextBox()->convert(xShape);
     }
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index efa6e38..3c47c66 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -417,6 +417,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle )
             else if( aName.equalsAscii( "visibility" ) )
                 mrTypeModel.mbVisible = !aValue.equalsAscii( "hidden" );
             else if( aName == "mso-wrap-style" ) mrTypeModel.maWrapStyle = aValue;
+            else if ( aName == "v-text-anchor" ) mrTypeModel.maVTextAnchor = aValue;
         }
     }
 }
commit f24e4c74d7d6a7d95090c6fa6a584fed7787706c
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 12:20:09 2013 +0200

    fdo#46361 oox: handle multiple w:p for groupshape textboxes
    
    One testcase had to be adjusted, as it seems previously we stripped all
    newlines at the end (I consider that as a bug), and now we only strip
    the last one (so the resulting number of paragraphs on the shape and in
    the source document equal).
    
    Change-Id: Ic22b96c2992b53c72e2609e2286622173b86065c

diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx
index 755d2d5..1a44e41 100644
--- a/include/oox/vml/vmltextboxcontext.hxx
+++ b/include/oox/vml/vmltextboxcontext.hxx
@@ -65,6 +65,7 @@ public:
 
     virtual ::oox::core::ContextHandlerRef
                         onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+    virtual void        onEndElement();
 
 private:
     TextBox&            mrTextBox;
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 1499091..27b4234 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -95,6 +95,13 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
         xTextAppend->appendTextPortion(aIt->maText, aPropSeq);
     }
 
+    // Remove the last character of the shape text, if it would be a newline.
+    uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
+    xCursor->gotoEnd(false);
+    xCursor->goLeft(1, true);
+    if (xCursor->getString() == "\n")
+        xCursor->setString("");
+
     if ( maLayoutFlow == "vertical" )
     {
         uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index c04b624..4c025c9 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -219,6 +219,12 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att
     return 0;
 }
 
+void TextBoxContext::onEndElement()
+{
+    if (getCurrentElement() == OOX_TOKEN(doc, p))
+        mrTextBox.appendPortion( TextFontModel(), "\n" );
+}
+
 // ============================================================================
 
 } // namespace vml
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 985bd66..7eaaa9f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -365,7 +365,7 @@ xray ThisComponent.DrawPage(1).getByIndex(0).Anchor.PageStyleName
     uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
     uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(1), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xShape(xShapes->getByIndex(0), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("TEXT1"), xShape->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("TEXT1\n"), xShape->getString());
     // we want to test the textbox is on the first page (it was put onto another page without the fix),
     // use a small trick and instead of checking the page layout, check the page style
     uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY);
commit b1f78c44c1acc246f06a963383232c9bf649a06b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 12:05:23 2013 +0200

    fdo#46361 oox: handle w:br for groupshape textboxes
    
    Change-Id: Ib78891614256b197cefbe766a4a4a9c76219f1cf

diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 0adf943..c04b624 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -125,6 +125,9 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs)
         case OOX_TOKEN(doc, sz):
             maFont.monSize = rAttribs.getInteger( OOX_TOKEN(doc, val) );
         break;
+        case OOX_TOKEN(doc, br):
+            mrTextBox.appendPortion( maFont, "\n" );
+        break;
     }
 }
 


More information about the Libreoffice-commits mailing list