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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 8 06:21:25 PST 2012


 oox/inc/oox/vml/vmlshape.hxx               |    2 ++
 oox/inc/oox/vml/vmltextbox.hxx             |    4 ++++
 oox/inc/oox/vml/vmltextboxcontext.hxx      |    3 ++-
 oox/source/token/properties.txt            |    4 ++++
 oox/source/vml/vmlshape.cxx                |    7 +++++++
 oox/source/vml/vmlshapecontext.cxx         |    4 +++-
 oox/source/vml/vmltextbox.cxx              |    1 +
 oox/source/vml/vmltextboxcontext.cxx       |   22 +++++++++++++++++++++-
 sw/qa/extras/ooxmlimport/data/n773061.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |   13 +++++++++++++
 10 files changed, 57 insertions(+), 3 deletions(-)

New commits:
commit 5c87553432058f5241eda1dbfbfa1ec840fe3890
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Nov 8 15:17:36 2012 +0100

    testcase for a recent bnc#773061 fix
    
    Change-Id: I60874c6ad8ccb9767961ed0064b9a15bfc1b07d5

diff --git a/sw/qa/extras/ooxmlimport/data/n773061.docx b/sw/qa/extras/ooxmlimport/data/n773061.docx
new file mode 100644
index 0000000..e0d6001
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n773061.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 33112d4..0da4feb 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -107,6 +107,7 @@ public:
     void testN783638();
     void testFdo52208();
     void testN785767();
+    void testN773061();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -166,6 +167,7 @@ void Test::run()
         {"n783638.docx", &Test::testN783638},
         {"fdo52208.docx", &Test::testFdo52208},
         {"n785767.docx", &Test::testN785767},
+        {"n773061.docx", &Test::testN773061},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1015,6 +1017,17 @@ void Test::testN785767()
     // Check the A1 and B1 cells, the width of both of them was the default value (10000 / 9, as there were 9 cells in the row).
     CPPUNIT_ASSERT_MESSAGE("A1 must not have default width", sal_Int16(10000 / 9) != getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
     CPPUNIT_ASSERT_MESSAGE("B1 must not have default width", sal_Int16(10000 / 9) != getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position);
+
+void Test::testN773061()
+{
+// xray ThisComponent.TextFrames(0).LeftBorderDistance
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ), sal_Int32( 0 ));
+    CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ), sal_Int32( 0 ));
+    CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ), sal_Int32( 0 ));
+    CPPUNIT_ASSERT_EQUAL( getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ), sal_Int32( 0 ));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit f2c55815128fde9f760c5cbf81e3ab18402c5b3d
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Nov 8 14:24:29 2012 +0100

    implement inset attribute of <v:textbox>  (part of bnc#773061)
    
    Change-Id: I1ec9b5d9fed86c44dc0a412c2323033ea67985c9

diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
index c7f288d..87b51d1 100644
--- a/oox/inc/oox/vml/vmlshape.hxx
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -120,6 +120,8 @@ public:
     /** Returns the fragment path to the embedded graphic used by this shape. */
     ::rtl::OUString     getGraphicPath() const;
 
+    const Drawing& getDrawing() const { return mrDrawing; }
+
 protected:
     /** Returns the coordinate system of this shape. */
     ::com::sun::star::awt::Rectangle getCoordSystem() const;
diff --git a/oox/inc/oox/vml/vmltextbox.hxx b/oox/inc/oox/vml/vmltextbox.hxx
index d540937..af69e77 100644
--- a/oox/inc/oox/vml/vmltextbox.hxx
+++ b/oox/inc/oox/vml/vmltextbox.hxx
@@ -74,6 +74,10 @@ public:
     /** Returns the entire text of all text portions. */
     ::rtl::OUString     getText() const;
 
+    /// Text distance from the border (inset attribute of v:textbox), valid only if set.
+    bool borderDistanceSet;
+    int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom;
+
 private:
     typedef ::std::vector< TextPortionModel > PortionVector;
 
diff --git a/oox/inc/oox/vml/vmltextboxcontext.hxx b/oox/inc/oox/vml/vmltextboxcontext.hxx
index 9325414..4fd35d1 100644
--- a/oox/inc/oox/vml/vmltextboxcontext.hxx
+++ b/oox/inc/oox/vml/vmltextboxcontext.hxx
@@ -57,7 +57,8 @@ public:
     explicit            TextBoxContext(
                             ::oox::core::ContextHandler2Helper& rParent,
                             TextBox& rTextBox,
-                            const AttributeList& rAttribs );
+                            const AttributeList& rAttribs,
+                            const GraphicHelper& graphicHelper );
 
     virtual ::oox::core::ContextHandlerRef
                         onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index c925d1f..a252bb2 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -34,6 +34,7 @@ BorderStyle
 BorderTransparency
 BorderWidth
 BottomBorder
+BottomBorderDistance
 BottomMargin
 BulletChar
 BulletColor
@@ -263,6 +264,7 @@ LabelPosition
 LabelSeparator
 LayoutInfo
 LeftBorder
+LeftBorderDistance
 LeftMargin
 LeftPageFooterContent
 LeftPageHeaderContent
@@ -384,6 +386,7 @@ RepeatDelay
 Representation
 RightAngledAxes
 RightBorder
+RightBorderDistance
 RightMargin
 RightPageFooterContent
 RightPageHeaderContent
@@ -495,6 +498,7 @@ Title
 Toggle
 TokenIndex
 TopBorder
+TopBorderDistance
 TopMargin
 Transformation
 TransitionDirection
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 8d84edd..3d5eb1f 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -449,6 +449,13 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
     {
         PropertySet( xShape ).setAnyProperty( PROP_FrameIsAutomaticHeight, makeAny( maTypeModel.mbAutoHeight ) );
         PropertySet( xShape ).setAnyProperty( PROP_SizeType, makeAny( maTypeModel.mbAutoHeight ? SizeType::MIN : SizeType::FIX ) );
+        if( getTextBox()->borderDistanceSet )
+        {
+            PropertySet( xShape ).setAnyProperty( PROP_LeftBorderDistance, makeAny( getTextBox()->borderDistanceLeft ));
+            PropertySet( xShape ).setAnyProperty( PROP_TopBorderDistance, makeAny( getTextBox()->borderDistanceTop ));
+            PropertySet( xShape ).setAnyProperty( PROP_RightBorderDistance, makeAny( getTextBox()->borderDistanceRight ));
+            PropertySet( xShape ).setAnyProperty( PROP_BottomBorderDistance, makeAny( getTextBox()->borderDistanceBottom ));
+        }
     }
     else
     {
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 35525e6..394c963 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -19,6 +19,7 @@
 
 #include "oox/vml/vmlshapecontext.hxx"
 
+#include "oox/core/xmlfilterbase.hxx"
 #include "oox/vml/vmldrawing.hxx"
 #include "oox/vml/vmlshape.hxx"
 #include "oox/vml/vmlshapecontainer.hxx"
@@ -406,7 +407,8 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri
             // Custom shape in Writer with a textbox are transformed into a frame
             dynamic_cast<SimpleShape&>( mrShape ).setService(
                     "com.sun.star.text.TextFrame");
-            return new TextBoxContext( *this, mrShapeModel.createTextBox(), rAttribs );
+            return new TextBoxContext( *this, mrShapeModel.createTextBox(), rAttribs,
+                mrShape.getDrawing().getFilter().getGraphicHelper());
         case VMLX_TOKEN( ClientData ):
             return new ClientDataContext( *this, mrShapeModel.createClientData(), rAttribs );
         case VMLPPT_TOKEN( textdata ):
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 131bdca..03c4eff 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -38,6 +38,7 @@ TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString&
 }
 
 TextBox::TextBox()
+    : borderDistanceSet( false )
 {
 }
 
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 33a64b4..a651fa2 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "oox/vml/vmlformatting.hxx"
 #include "oox/vml/vmltextboxcontext.hxx"
 
 namespace oox {
@@ -117,10 +118,29 @@ void TextPortionContext::onEndElement()
 
 // ============================================================================
 
-TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBox, const AttributeList& /*rAttribs*/ ) :
+TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBox, const AttributeList& rAttribs,
+    const GraphicHelper& graphicHelper ) :
     ContextHandler2( rParent ),
     mrTextBox( rTextBox )
 {
+    if( rAttribs.getString( XML_insetmode ).get() != "auto" )
+    {
+        OUString inset = rAttribs.getString( XML_inset ).get();
+        OUString value;
+        ConversionHelper::separatePair( value, inset, inset, ',' );
+        rTextBox.borderDistanceLeft = ConversionHelper::decodeMeasureToEmu( graphicHelper,
+            value.isEmpty() ? "0.1in" : value, 0, false, false );
+        ConversionHelper::separatePair( value, inset, inset, ',' );
+        rTextBox.borderDistanceTop = ConversionHelper::decodeMeasureToEmu( graphicHelper,
+            value.isEmpty() ? "0.05in" : value, 0, false, false );
+        ConversionHelper::separatePair( value, inset, inset, ',' );
+        rTextBox.borderDistanceRight = ConversionHelper::decodeMeasureToEmu( graphicHelper,
+            value.isEmpty() ? "0.1in" : value, 0, false, false );
+        ConversionHelper::separatePair( value, inset, inset, ',' );
+        rTextBox.borderDistanceBottom = ConversionHelper::decodeMeasureToEmu( graphicHelper,
+            value.isEmpty() ? "0.05in" : value, 0, false, false );
+        rTextBox.borderDistanceSet = true;
+    }
 }
 
 ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )


More information about the Libreoffice-commits mailing list