--- filter/source/svg/svgimport.cxx	2007-06-25 14:14:23.000000000 +0200
+++ filter/source/svg/svgimport.cxx	2007-06-22 20:31:12.000000000 +0200
@@ -55,7 +55,7 @@ static svg_status_t impl_BeginGroup( voi
 
     pReader->BeginGroup();
     // FIXME set opacity?
-    
+    fprintf( stderr, "BeginGroup\n" );
     return SVG_STATUS_SUCCESS;
 }
 
@@ -79,7 +79,7 @@ static svg_status_t impl_EndGroup( void 
     SVGReader *pReader = static_cast<SVGReader*>( closure );
 
     // FIXME set opacity?
-
+    fprintf( stderr, "EndGroup\n" );
     return pReader->EndGroup()? SVG_STATUS_SUCCESS: SVG_STATUS_PARSE_ERROR;
 }
 
@@ -164,6 +164,7 @@ static svg_status_t impl_SetFillPaint( v
     SVGReader *pReader = static_cast<SVGReader*>( closure );
 
     pReader->CurrentAttr().SetFillPaint( paint );
+    pReader->CurrentTextAttr().SetFillPaint( paint );
 
     return SVG_STATUS_SUCCESS;
 }
@@ -179,32 +180,33 @@ static svg_status_t impl_SetFillRule( vo
 static svg_status_t impl_SetFontFamily( void *closure, const char *family )
 {
     SVGReader *pReader = static_cast<SVGReader*>( closure );
-    fprintf( stderr, "set_font_family\n" );
-
+    //fprintf( stderr, "set_font_family\n" );
+    pReader->CurrentTextAttr().SetCharFontName( family );
     return SVG_STATUS_SUCCESS;
 }
 
 static svg_status_t impl_SetFontSize( void *closure, double size )
 {
     SVGReader *pReader = static_cast<SVGReader*>( closure );
-    fprintf( stderr, "set_font_size\n" );
+    //fprintf( stderr, "set_font_size\n" );
 
+    pReader->CurrentTextAttr().SetCharSize( size );
     return SVG_STATUS_SUCCESS;
 }
 
 static svg_status_t impl_SetFontStyle( void *closure, svg_font_style_t font_style )
 {
     SVGReader *pReader = static_cast<SVGReader*>( closure );
-    fprintf( stderr, "set_font_style\n" );
-
+    //fprintf( stderr, "set_font_style\n" );
+    pReader->CurrentTextAttr().SetCharPosture( font_style );
     return SVG_STATUS_SUCCESS;
 }
 
 static svg_status_t impl_SetFontWeight( void *closure, unsigned int font_weight )
 {
     SVGReader *pReader = static_cast<SVGReader*>( closure );
-    fprintf( stderr, "set_font_weight\n" );
-
+    //fprintf( stderr, "set_font_weight\n" );
+    pReader->CurrentTextAttr().SetCharWeight( font_weight );
     return SVG_STATUS_SUCCESS;
 }
 
@@ -375,9 +377,10 @@ static svg_status_t impl_RenderText( voi
         const char   *utf8 )
 {
     SVGReader *pReader = static_cast<SVGReader*>( closure );
+
     fprintf( stderr, "render_text\n" );
 
-    return SVG_STATUS_SUCCESS;
+    return pReader->Text( x, y, utf8 ) ? SVG_STATUS_SUCCESS: SVG_STATUS_PARSE_ERROR;
 }
 
 static svg_status_t impl_RenderImage( void *closure,
--- filter/source/svg/svgreader.cxx	2007-06-25 14:14:23.000000000 +0200
+++ filter/source/svg/svgreader.cxx	2007-06-22 21:28:24.000000000 +0200
@@ -36,7 +36,9 @@
 #include "svgreader.hxx"
 
 #include <unotools/processfactory.hxx>
-
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <cstring>                              // for strlen
 #include <iostream>
 
 using namespace ::com::sun::star;
@@ -44,11 +46,14 @@ using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::drawing;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;           // for Point
+using namespace ::com::sun::star::text;          // for XText
 using namespace ::basegfx;
 
 // consts //
 
-const double USER_UNIT = 10.0; // FIXME? 10.0 considered a nice magic value ;-)
+// const double USER_UNIT = 10.0; // FIXME? 10.0 considered a nice magic value ;-)
+const double USER_UNIT = 25.0; // FIXME? 25.0 maybe a more sensible value but always magic ;-)
 
 // forward declarations //
 
@@ -60,6 +65,7 @@ sal_Int32 ToInt( const svg_length_t *len
 static const rtl::OUString RECTANGLE_SHAPE(        RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.RectangleShape" ) );
 static const rtl::OUString ELLIPSE_SHAPE(          RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.EllipseShape" ) );
 static const rtl::OUString SHAPE_COLLECTION(       RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ShapeCollection" ) );
+static const rtl::OUString TEXT_SHAPE(             RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TextShape" ) );
 
 static const rtl::OUString PROPERTY_CORNER_RADIUS( RTL_CONSTASCII_USTRINGPARAM( "CornerRadius" ) );
 
@@ -73,6 +79,16 @@ static const rtl::OUString PROPERTY_FILL
 
 static const rtl::OUString PROPERTY_TRANSFORMATION(RTL_CONSTASCII_USTRINGPARAM( "Transformation" ) );
 
+static const rtl::OUString PROPERTY_TEXT_AUTO_GROW_HEIGHT(    RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) );
+static const rtl::OUString PROPERTY_TEXT_AUTO_GROW_WIDTH(     RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowWidth" ) );
+static const rtl::OUString PROPERTY_CHAR_HEIGHT(              RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) );
+static const rtl::OUString PROPERTY_CHAR_WEIGHT(              RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) );
+static const rtl::OUString PROPERTY_CHAR_COLOR(               RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) );
+static const rtl::OUString PROPERTY_CHAR_POSTURE(             RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) );
+static const rtl::OUString PROPERTY_CHAR_FONT_NAME(           RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) );
+
+
+
 // SVGAttributes //
 
 SVGAttributes::SVGAttributes()
@@ -289,10 +306,121 @@ void SVGAttributes::Transform( double a,
 #endif
 }
 
-// SVGGroup //
 
-SVGGroup::SVGGroup( const SVGAttributes &rAttr )
+
+
+//-----------------------------------------------------------------------------
+// SVGTextAttributes 
+//
+
+SVGTextAttributes::SVGTextAttributes()
+{
+}
+
+SVGTextAttributes& SVGTextAttributes::operator=( const SVGTextAttributes &rAttr )
+{
+
+    m_aCharHeight   = rAttr.m_aCharHeight;
+    m_aCharWeight   = rAttr.m_aCharWeight;
+    m_aCharColor    = rAttr.m_aCharColor;
+    m_aCharFontName = rAttr.m_aCharFontName;
+    m_aCharPosture  = rAttr.m_aCharPosture;
+
+    return *this;
+}
+
+void SVGTextAttributes::ApplyProperties( Reference< XPropertySet > &xPropertySet )
+{
+    if ( !xPropertySet.is() )
+        return;
+
+#define APPLY_PROPERTY( name, value ) \
+    if ( !!value && xPropertySet->getPropertySetInfo()->hasPropertyByName( name ) ) \
+    { \
+        xPropertySet->setPropertyValue( name, makeAny( *value ) ); \
+    }
+
+    APPLY_PROPERTY( PROPERTY_CHAR_HEIGHT,     m_aCharHeight   );
+    APPLY_PROPERTY( PROPERTY_CHAR_WEIGHT,     m_aCharWeight   );
+    APPLY_PROPERTY( PROPERTY_CHAR_POSTURE,    m_aCharPosture  );
+    APPLY_PROPERTY( PROPERTY_CHAR_FONT_NAME,  m_aCharFontName );
+    APPLY_PROPERTY( PROPERTY_CHAR_COLOR,      m_aCharColor    );
+
+#undef APPLY_PROPERTY
+}
+
+void SVGTextAttributes::SetCharSize( double size )
+{
+    m_aCharHeight = boost::optional<float>(size);
+}
+
+
+// for reference look at:
+// http://www.w3.org/TR/SVG11/text.html#FontPropertiesUsedBySVG
+// http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-weight
+// and read the documentation of the constants definined into the
+// namespace ::com::sun::star::awt::FontWeight
+void SVGTextAttributes::SetCharWeight( unsigned int font_weight )
+{
+    switch( font_weight )
+    {
+        case 100 : m_aCharWeight = boost::optional<float>(FontWeight::THIN); break;
+        case 200 : m_aCharWeight = boost::optional<float>(FontWeight::LIGHT); break;
+        case 300 : m_aCharWeight = boost::optional<float>(FontWeight::SEMILIGHT); break;
+        case 400 : m_aCharWeight = boost::optional<float>(FontWeight::NORMAL); break;
+        case 500 : m_aCharWeight = boost::optional<float>(FontWeight::SEMIBOLD); break;
+        case 700 : m_aCharWeight = boost::optional<float>(FontWeight::BOLD); break;
+        case 800 : m_aCharWeight = boost::optional<float>(FontWeight::ULTRABOLD); break;
+        case 900 : m_aCharWeight = boost::optional<float>(FontWeight::BLACK); break;
+        default  : m_aCharWeight = boost::optional<float>(FontWeight::DONTKNOW);
+    }
+}
+
+void SVGTextAttributes::SetCharPosture( svg_font_style_t font_style )
+{
+    switch( font_style )
+    {
+        case SVG_FONT_STYLE_NORMAL :  m_aCharPosture = boost::optional< ::com::sun::star::awt::FontSlant >(FontSlant_NONE); break;
+        case SVG_FONT_STYLE_ITALIC :  m_aCharPosture = boost::optional< ::com::sun::star::awt::FontSlant >(FontSlant_ITALIC); break;
+        case SVG_FONT_STYLE_OBLIQUE : m_aCharPosture = boost::optional< ::com::sun::star::awt::FontSlant >(FontSlant_OBLIQUE); break;
+        default :                     m_aCharPosture = boost::optional< ::com::sun::star::awt::FontSlant >(FontSlant_DONTKNOW);
+    }
+}
+
+void SVGTextAttributes::SetCharFontName( const char *family )
+{
+    if ( !family ) return;
+
+    m_aCharFontName = boost::optional< ::rtl::OUString >(rtl::OUString( family, std::strlen(family), RTL_TEXTENCODING_UTF8 ));
+}
+
+
+void SVGTextAttributes::SetFillPaint( const svg_paint_t *paint )
+{
+    if( !paint ) return;
+
+    SetCharColor( &(paint->p.color) );
+}
+
+void SVGTextAttributes::SetCharColor( const svg_color_t *color )
+{
+    if ( !color ) return;
+
+    m_aCharColor = boost::optional< ::com::sun::star::util::Color >(( svg_color_get_red( color ) << 16 ) +
+                   ( svg_color_get_green( color )  << 8 ) +
+                   ( svg_color_get_blue( color ) ) );
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+// SVGGroup
+//
+
+SVGGroup::SVGGroup( const SVGAttributes &rAttr, const SVGTextAttributes &rTextAttr )
     : m_aAttr( rAttr ),
+      m_aTextAttr( rTextAttr ),
       m_xShapes( utl::getProcessServiceFactory()->createInstance( SHAPE_COLLECTION ), UNO_QUERY )
 {
 }
@@ -307,7 +435,12 @@ void SVGGroup::Add( const Reference< XSh
     m_xShapes->add( xShape );
 }
 
-// SVGReader //
+
+
+
+//-----------------------------------------------------------------------------
+// SVGReader
+//
 
 SVGReader::SVGReader( const Reference< XMultiServiceFactory >& xServiceFactory,
                       const Reference< XShapes >& xShapes )
@@ -326,14 +459,28 @@ SVGAttributes& SVGReader::CurrentAttr()
         return m_aGroups.top().Attr();
 }
 
+SVGTextAttributes& SVGReader::CurrentTextAttr()
+{
+    if ( m_bReadingElement || m_aGroups.empty() )
+        return m_aTextAttr;
+    else
+        return m_aGroups.top().TextAttr();
+}
+
 void SVGReader::BeginElement()
 {
     m_bReadingElement = true;
 
     if ( m_aGroups.empty() )
+    {
         m_aElementAttr = SVGAttributes();
+        m_aTextAttr = SVGTextAttributes();
+    }
     else
+    {
         m_aElementAttr = m_aGroups.top().Attr();
+        m_aTextAttr = m_aGroups.top().TextAttr();
+    }
 }
 
 void SVGReader::BeginGroup()
@@ -447,14 +594,14 @@ bool SVGReader::Ellipse( svg_length_t *c
     CreateShape( ELLIPSE_SHAPE, xPropertySet );
 
     Reference< XShape > xShape( xPropertySet, UNO_QUERY );
-    fprintf( stderr, "Position (before):\n  %d, %d\n", xShape->getPosition().X, xShape->getPosition().Y );
+    fprintf( stderr, "Position (before):\n  %d, %d\n", (int)(xShape->getPosition().X), (int)(xShape->getPosition().Y) );
             
     // position, size, shear and rotate
     m_aElementAttr.ApplyTransformation( xPropertySet,
             nX, nY, 2*nRadiusX, 2*nRadiusY,
             nRadiusX, nRadiusY);
 
-    fprintf( stderr, "Position (after):\n  %d, %d\n", xShape->getPosition().X, xShape->getPosition().Y );
+    fprintf( stderr, "Position (after):\n  %d, %d\n", (int)(xShape->getPosition().X), (int)(xShape->getPosition().Y) );
     
     return true;
 }
@@ -473,6 +620,49 @@ void SVGReader::CreateShape( const rtl::
     m_aElementAttr.ApplyProperties( xPropertySet );
 }
 
+
+bool SVGReader::Text( svg_length_t *x, svg_length_t *y, const char *utf8 )
+{
+    if ( m_aGroups.empty() )
+        return false; // error
+
+    fprintf( stderr, ">> SVGReader::Text\n" );
+
+    Point Pos;
+    Pos.X = ToInt( x );
+    Pos.Y = ToInt( y );
+
+    rtl::OUString content( utf8, std::strlen(utf8), RTL_TEXTENCODING_UTF8 );
+
+    // create text shape instance
+    Reference< XShape > xShape( m_xServiceFactory->createInstance( TEXT_SHAPE ), UNO_QUERY );
+    
+    // add to the document and to the top group
+    m_xShapes->add( xShape );
+    m_aGroups.top().Add( xShape );
+
+    Reference< XPropertySet> xPropertySet( xShape, UNO_QUERY );
+    //m_aElementAttr.ApplyProperties( xPropertySet );
+
+    // so the shape grow/shirnk automatically to fit the wrapped text
+    xPropertySet->setPropertyValue( PROPERTY_TEXT_AUTO_GROW_HEIGHT, makeAny( true ) );
+    xPropertySet->setPropertyValue( PROPERTY_TEXT_AUTO_GROW_WIDTH, makeAny( true ) );
+
+    xShape->setPosition( Pos );
+    
+    // set text shape content
+    Reference< XText > xText(xShape, UNO_QUERY);
+    xText->setString( content );
+
+    // set text properties
+    Reference< XPropertySet> xTextPropertySet( xText, UNO_QUERY );
+    m_aTextAttr.ApplyProperties( xTextPropertySet );
+
+
+
+    return true;
+}
+
 sal_Int32 ToInt( const svg_length_t *length )
 {
     if ( !length )
@@ -487,7 +677,7 @@ sal_Int32 ToInt( const svg_length_t *len
         case SVG_LENGTH_UNIT_MM: return sal_Int32( length->value * 100.0 );
         case SVG_LENGTH_UNIT_PC: fprintf( stderr, "TODO: legth type PC not implemented.\n" ); return 1000;
         case SVG_LENGTH_UNIT_PCT: fprintf( stderr, "TODO: legth type PCT not implemented.\n" ); return 1000;
-        case SVG_LENGTH_UNIT_PT: fprintf( stderr, "TODO: legth type PT not implemented.\n" ); return 1000;
+        case SVG_LENGTH_UNIT_PT: return sal_Int32( length->value * 35.277 );
         case SVG_LENGTH_UNIT_PX: return sal_Int32( length->value * USER_UNIT );
         default: fprintf( stderr, "Unknown length type\n" );
     }
--- filter/source/svg/svgreader.hxx	2007-06-25 14:14:23.000000000 +0200
+++ filter/source/svg/svgreader.hxx	2007-06-22 20:37:12.000000000 +0200
@@ -48,6 +48,9 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 #include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+
 
 #include <basegfx/matrix/b2dhommatrix.hxx>
 
@@ -89,16 +92,46 @@ public:
     void                    Transform( double a, double b, double c, double d, double e, double f );
 };
 
+
+class SVGTextAttributes
+{
+    // TODO more attributes...
+    boost::optional< float >                                   m_aCharHeight;
+    boost::optional< float >                                   m_aCharWeight;
+    boost::optional< ::com::sun::star::util::Color >           m_aCharColor;
+    boost::optional< ::rtl::OUString >                         m_aCharFontName;
+    boost::optional< ::com::sun::star::awt::FontSlant >        m_aCharPosture;
+
+
+public:
+    SVGTextAttributes();
+
+    SVGTextAttributes&          operator=( const SVGTextAttributes &rAttr );
+
+    void                    ApplyProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &xPropertySet );
+
+    void                    SetCharSize( double size );
+    void                    SetCharWeight( unsigned int font_weight );
+    void                    SetCharColor( const svg_color_t *color );
+    void                    SetCharPosture( svg_font_style_t font_style );
+    void                    SetCharFontName( const char *family );
+    void                    SetFillPaint( const svg_paint_t *paint );
+
+};
+
+
 class SVGGroup
 {
     SVGAttributes           m_aAttr;
+    SVGTextAttributes       m_aTextAttr;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xShapes;
 
 public:
-    SVGGroup( const SVGAttributes &rAttr = SVGAttributes() );
+    SVGGroup( const SVGAttributes &rAttr = SVGAttributes(), const SVGTextAttributes &rTextAttr = SVGTextAttributes() );
 
     SVGAttributes&          Attr() { return m_aAttr; }
+    SVGTextAttributes&      TextAttr() { return m_aTextAttr; }
     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > AsShapeGroup( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGrouper >& xShapeGrouper );
 
     void                    Add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
@@ -116,6 +149,7 @@ class SVGReader
 
     std::stack< SVGGroup >  m_aGroups;
     SVGAttributes           m_aElementAttr;
+    SVGTextAttributes       m_aTextAttr;
 
     ::com::sun::star::awt::Size m_aViewportSize;
     
@@ -125,6 +159,7 @@ public:
                const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes );
 
     SVGAttributes&          CurrentAttr();
+    SVGTextAttributes&      CurrentTextAttr();
 
     void                    BeginElement();
     void                    BeginGroup();
@@ -138,6 +173,8 @@ public:
     bool                    Ellipse( svg_length_t *cx, svg_length_t *cy,
                                      svg_length_t *rx, svg_length_t *ry );
 
+    bool                    Text( svg_length_t *x, svg_length_t *y, const char *utf8 );
+
 protected:
     void                    CreateShape( const ::rtl::OUString & rServiceName,
                                          ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &xPropertySet );
