[Libreoffice-commits] .: filter/source

Thorsten Behrens thorsten at kemper.freedesktop.org
Mon Feb 14 04:49:09 PST 2011


 filter/source/svg/svgexport.cxx |   45 ++++++++++++++++++++++------------------
 filter/source/svg/svgfilter.hxx |    2 -
 2 files changed, 26 insertions(+), 21 deletions(-)

New commits:
commit 00be94740c86ebd1407a382daf90020a1bcc523f
Author: Kurosawa Takeshi <taken.spc at gmail.com>
Date:   Sat Feb 12 13:26:35 2011 +0900

    Export object's title and description as alternate content
    
    Actually they are stored as "svg:title" and "svg:description" in ODF.
    
    Fixed text such as "Drawing" and "Graphic" is information about class of a shape. Thus use them as class attribute.

diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index bc8bea7..a1e9086 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -510,26 +510,25 @@ sal_Bool SVGFilter::implExportPages( const Reference< XDrawPages >& rxPages,
                 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", implGetValidIDFromInterface( xShapes ) );
 
                 {
-                    SvXMLElementExport	aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", TRUE, TRUE );
-                    const Point			aNullPt;
-
                     {
                         Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
 
                         if( xExtDocHandler.is() )
                         {
-                            SvXMLElementExport	aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", TRUE, TRUE );
-                            OUString			aDesc;
+                            OUString aDesc;
 
                             if( bMaster )
-                                aDesc = B2UCONST( "Master slide" );
+                                aDesc = B2UCONST( "Master_Slide" );
                             else
                                 aDesc = B2UCONST( "Slide" );
 
-                            xExtDocHandler->unknown( aDesc );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aDesc );
                         }
                     }
 
+                    SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", TRUE, TRUE );
+                    const Point        aNullPt;
+
                     if( bMaster )
                     {
                         const GDIMetaFile& rMtf = (*mpObjects)[ xDrawPage ].GetRepresentation();
@@ -639,15 +638,9 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
 
                 if( xShapes.is() )
                 {
+                    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "Group" ) );
                     SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", TRUE, TRUE );
 
-                    {
-                        SvXMLElementExport						aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", TRUE, TRUE );
-                        Reference< XExtendedDocumentHandler >	xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
-
-                        xExtDocHandler->unknown( B2UCONST( "Group" ) );
-                    }
-
                     bRet = implExportShapes( xShapes );
                 }
             }
@@ -663,13 +656,25 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
                 const Size  aSize( aBoundRect.Width, aBoundRect.Height );
 
                 {
+                    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", implGetClassFromShape( rxShape ) );
                     SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", TRUE, TRUE );
 
+                    Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
+
+                    OUString aTitle;
+                    xShapePropSet->getPropertyValue( B2UCONST( "Title" ) ) >>= aTitle;
+                    if( aTitle.getLength() )
                     {
-                        SvXMLElementExport						aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", TRUE, TRUE );
-                        Reference< XExtendedDocumentHandler >	xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
+                        SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "title", TRUE, TRUE );
+                        xExtDocHandler->characters( aTitle );
+                    }
 
-                        xExtDocHandler->unknown( implGetDescriptionFromShape( rxShape ) );
+                    OUString aDescription;
+                    xShapePropSet->getPropertyValue( B2UCONST( "Description" ) ) >>= aDescription;
+                    if( aDescription.getLength() )
+                    {
+                        SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", TRUE, TRUE );
+                        xExtDocHandler->characters( aDescription );
                     }
 
                     if( rMtf.GetActionCount() )
@@ -868,9 +873,9 @@ sal_Bool SVGFilter::implCreateObjectsFromBackground( const Reference< XDrawPage
 
 // -----------------------------------------------------------------------------
 
-OUString SVGFilter::implGetDescriptionFromShape( const Reference< XShape >& rxShape )
+OUString SVGFilter::implGetClassFromShape( const Reference< XShape >& rxShape )
 {
-    OUString			aRet;
+    OUString            aRet;
     const OUString      aShapeType( rxShape->getShapeType() );
 
     if( aShapeType.lastIndexOf( B2UCONST( "drawing.GroupShape" ) ) != -1 )
@@ -886,7 +891,7 @@ OUString SVGFilter::implGetDescriptionFromShape( const Reference< XShape >& rxSh
     else if( aShapeType.lastIndexOf( B2UCONST( "presentation.DateTimeShape" ) ) != -1 )
         aRet = B2UCONST( "Date/Time" );
     else if( aShapeType.lastIndexOf( B2UCONST( "presentation.SlideNumberShape" ) ) != -1 )
-        aRet = B2UCONST( "Slide Number" );
+        aRet = B2UCONST( "Slide_Number" );
     else
         aRet = B2UCONST( "Drawing" );
         
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index ceda422..ba16cec 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -222,7 +222,7 @@ private:
     sal_Bool                            implCreateObjectsFromShape( const Reference< XShape >& rxShape );
     sal_Bool							implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage );
     
-    ::rtl::OUString						implGetDescriptionFromShape( const Reference< XShape >& rxShape );
+    ::rtl::OUString						implGetClassFromShape( const Reference< XShape >& rxShape );
     ::rtl::OUString						implGetValidIDFromInterface( const Reference< XInterface >& rxIf );
     
                                         DECL_LINK( CalcFieldHdl, EditFieldInfo* );


More information about the Libreoffice-commits mailing list