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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 3 03:39:53 PST 2014


 include/oox/drawingml/shape.hxx                       |    4 ++--
 oox/source/drawingml/shape.cxx                        |    9 +++++----
 oox/source/shape/WpgContext.cxx                       |    5 ++++-
 sw/qa/extras/ooxmlexport/data/groupshape-textbox.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx              |   11 +++++++++++
 5 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit 92518d513fe021be58a0bbeb04fd9306eb23ebda
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 3 12:07:30 2014 +0100

    drawingML import: fix default character height of WPG rectangles
    
    The problem was that due to setting it to 18 in oox, the rectangle
    didn't inherit the default 11 from the document.
    
    Change-Id: I05c3b9c1d64eec58695e2039651a5f015df1f9e4

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 5fcb91c..f39f75d0 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -72,7 +72,7 @@ class OOX_DLLPUBLIC Shape
 {
 public:
 
-    explicit Shape( const sal_Char* pServiceType = 0 );
+    explicit Shape( const sal_Char* pServiceType = 0, bool bDefaultHeight = true );
     explicit Shape( const ShapePtr& pSourceShape );
     virtual ~Shape();
 
@@ -126,7 +126,7 @@ public:
     const OptValue< sal_Int32 >&    getSubTypeIndex() const { return moSubTypeIndex; }
 
     // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
-    void                            setDefaults();
+    void                            setDefaults(bool bHeight);
 
     ::oox::vml::OleObjectInfo&      setOleObjectType();
     ChartShapeInfo&                 setChartType( bool bEmbedShapes );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index a6e61a7..46dedec 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -82,7 +82,7 @@ namespace oox { namespace drawingml {
 
 // ============================================================================
 
-Shape::Shape( const sal_Char* pServiceName )
+Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
 : mbIsChild( false )
 , mpLinePropertiesPtr( new LineProperties )
 , mpFillPropertiesPtr( new FillProperties )
@@ -103,7 +103,7 @@ Shape::Shape( const sal_Char* pServiceName )
 {
     if ( pServiceName )
         msServiceName = OUString::createFromAscii( pServiceName );
-    setDefaults();
+    setDefaults(bDefaultHeight);
 }
 
 Shape::Shape( const ShapePtr& pSourceShape )
@@ -151,7 +151,7 @@ table::TablePropertiesPtr Shape::getTableProperties()
     return mpTablePropertiesPtr;
 }
 
-void Shape::setDefaults()
+void Shape::setDefaults(bool bHeight)
 {
     maDefaultShapeProperties[ PROP_TextAutoGrowHeight ] <<= false;
     maDefaultShapeProperties[ PROP_TextWordWrap ] <<= true;
@@ -159,7 +159,8 @@ void Shape::setDefaults()
     maDefaultShapeProperties[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( 125 );
     maDefaultShapeProperties[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( 250 );
     maDefaultShapeProperties[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( 125 );
-    maDefaultShapeProperties[ PROP_CharHeight ] <<= static_cast< float >( 18.0 );
+    if (bHeight)
+        maDefaultShapeProperties[ PROP_CharHeight ] <<= static_cast< float >( 18.0 );
     maDefaultShapeProperties[ PROP_TextVerticalAdjust ] <<= TextVerticalAdjust_TOP;
     maDefaultShapeProperties[ PROP_ParaAdjust ] <<= static_cast< sal_Int16 >( ParagraphAdjust_LEFT ); // check for RTL?
 }
diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx
index 39bb470..d66b518 100644
--- a/oox/source/shape/WpgContext.cxx
+++ b/oox/source/shape/WpgContext.cxx
@@ -46,7 +46,10 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken
         break;
     case XML_wsp:
     {
-        oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape"));
+        // Don't set default character height, Writer has its own way to set
+        // the default, and if we don't set it here, editeng properly inherits
+        // it.
+        oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false));
         return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
     }
     break;
diff --git a/sw/qa/extras/ooxmlexport/data/groupshape-textbox.docx b/sw/qa/extras/ooxmlexport/data/groupshape-textbox.docx
new file mode 100644
index 0000000..fca71bf
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/groupshape-textbox.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index fa90304..23a8e6f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2198,6 +2198,17 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx")
                 "name", "adj1");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
+{
+    uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
+    // The VML export lost text on textboxes inside groupshapes.
+    // The DML export does not, make sure it stays that way.
+    CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString());
+    // This was 16, i.e. inheriting doc default char height didn't work.
+    CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");


More information about the Libreoffice-commits mailing list