[Libreoffice-commits] .: oox/inc oox/source
Radek DoulÃk
rodo at kemper.freedesktop.org
Tue May 24 06:49:26 PDT 2011
oox/inc/oox/export/drawingml.hxx | 2
oox/inc/oox/export/shapes.hxx | 10 ++
oox/source/export/drawingml.cxx | 6 -
oox/source/export/shapes.cxx | 138 ++++++++++++++++++++++++++++++++++-----
4 files changed, 134 insertions(+), 22 deletions(-)
New commits:
commit 8f4c0cfbbdcb028f6d784c729ea33536ee2df050
Author: Radek Doulik <rodo at novell.com>
Date: Tue May 24 15:31:11 2011 +0200
drawingML export, write table shapes
diff --git a/oox/inc/oox/export/drawingml.hxx b/oox/inc/oox/export/drawingml.hxx
index 92603af..93b0358 100644
--- a/oox/inc/oox/export/drawingml.hxx
+++ b/oox/inc/oox/export/drawingml.hxx
@@ -94,7 +94,7 @@ public:
void WriteTransformation( const Rectangle& rRectangle,
sal_Int32 nXmlNamespace, sal_Bool bFlipH = false, sal_Bool bFlipV = false, sal_Int32 nRotation = 0 );
- void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape );
+ void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > rXIface );
void WriteParagraph( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
void WriteParagraphProperties( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
diff --git a/oox/inc/oox/export/shapes.hxx b/oox/inc/oox/export/shapes.hxx
index b2c165f..b2a9860 100644
--- a/oox/inc/oox/export/shapes.hxx
+++ b/oox/inc/oox/export/shapes.hxx
@@ -88,7 +88,7 @@ public:
sal_Int32 GetXmlNamespace() const;
ShapeExport& SetXmlNamespace( sal_Int32 nXmlNamespace );
- static sal_Bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ static sal_Bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
virtual ShapeExport&
WriteBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, sal_Bool bClosed );
@@ -133,6 +133,7 @@ public:
* <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
* <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenBezierShape</td></tr>
* <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
* <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
* <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
* <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
@@ -152,14 +153,19 @@ public:
virtual ShapeExport&
WriteShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
virtual ShapeExport&
- WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface, sal_Int32 nXmlNamespace );
virtual ShapeExport&
WriteTextShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
virtual ShapeExport&
+ WriteTableShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ virtual ShapeExport&
WriteOLE2Shape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
virtual ShapeExport&
WriteUnknownShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape );
+
+
sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB );
sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 48f4eb4..4e94e90 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1232,10 +1232,10 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
mpFS->endElementNS( XML_a, XML_p );
}
-void DrawingML::WriteText( Reference< XShape > rXShape )
+void DrawingML::WriteText( Reference< XInterface > rXIface )
{
- Reference< XText > xXText( rXShape, UNO_QUERY );
- Reference< XPropertySet > rXPropSet( rXShape, UNO_QUERY );
+ Reference< XText > xXText( rXIface, UNO_QUERY );
+ Reference< XPropertySet > rXPropSet( rXIface, UNO_QUERY );
if( !xXText.is() )
return;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 8758e0c..eb6dad3 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -58,6 +58,10 @@
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/table/XTable.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/table/XMergeableCell.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <tools/stream.hxx>
@@ -81,6 +85,7 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::table;
using ::com::sun::star::beans::PropertyState;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::beans::XPropertySet;
@@ -408,9 +413,9 @@ awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
return awt::Size( aRetSize.Width(), aRetSize.Height() );
}
-sal_Bool ShapeExport::NonEmptyText( Reference< XShape > xShape )
+sal_Bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
{
- Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
+ Reference< XPropertySet > xPropSet( xIface, UNO_QUERY );
if( xPropSet.is() )
{
@@ -441,7 +446,7 @@ sal_Bool ShapeExport::NonEmptyText( Reference< XShape > xShape )
}
}
- Reference< XSimpleText > xText( xShape, UNO_QUERY );
+ Reference< XSimpleText > xText( xIface, UNO_QUERY );
if( xText.is() )
return xText->getString().getLength();
@@ -488,7 +493,7 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -571,7 +576,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -611,7 +616,7 @@ ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape )
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -775,7 +780,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape )
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
@@ -822,7 +827,7 @@ ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape )
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -889,7 +894,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -917,6 +922,7 @@ static const NameToConvertMapType& lcl_GetConverters()
shape_converters[ "com.sun.star.drawing.OpenBezierShape" ] = &ShapeExport::WriteOpenBezierShape;
shape_converters[ "com.sun.star.drawing.RectangleShape" ] = &ShapeExport::WriteRectangleShape;
shape_converters[ "com.sun.star.drawing.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape;
+ shape_converters[ "com.sun.star.drawing.TableShape" ] = &ShapeExport::WriteTableShape;
shape_converters[ "com.sun.star.drawing.TextShape" ] = &ShapeExport::WriteTextShape;
shape_converters[ "com.sun.star.presentation.DateTimeShape" ] = &ShapeExport::WriteTextShape;
shape_converters[ "com.sun.star.presentation.FooterShape" ] = &ShapeExport::WriteTextShape;
@@ -945,20 +951,120 @@ ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
return *this;
}
-ShapeExport& ShapeExport::WriteTextBox( Reference< XShape > xShape )
+ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int32 nXmlNamespace )
{
- if( NonEmptyText( xShape ) )
+ if( NonEmptyText( xIface ) )
{
FSHelperPtr pFS = GetFS();
- pFS->startElementNS( mnXmlNamespace, XML_txBody, FSEND );
- WriteText( xShape );
- pFS->endElementNS( mnXmlNamespace, XML_txBody );
+ pFS->startElementNS( nXmlNamespace, XML_txBody, FSEND );
+ WriteText( xIface );
+ pFS->endElementNS( nXmlNamespace, XML_txBody );
}
return *this;
}
+void ShapeExport::WriteTable( Reference< XShape > rXShape )
+{
+ OSL_TRACE("write table");
+
+ Reference< XTable > xTable;
+ Reference< XPropertySet > xPropSet( rXShape, UNO_QUERY );
+
+ mpFS->startElementNS( XML_a, XML_graphic, FSEND );
+ mpFS->startElementNS( XML_a, XML_graphicData, XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/table", FSEND );
+
+ if ( xPropSet.is() && ( xPropSet->getPropertyValue( S("Model") ) >>= xTable ) )
+ {
+ mpFS->startElementNS( XML_a, XML_tbl, FSEND );
+ mpFS->singleElementNS( XML_a, XML_tblPr, FSEND );
+
+ Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
+ Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
+ Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
+ sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
+ sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
+
+ std::vector< std::pair< sal_Int32, sal_Int32 > > aColumns;
+ std::vector< std::pair< sal_Int32, sal_Int32 > > aRows;
+
+ mpFS->startElementNS( XML_a, XML_tblGrid, FSEND );
+
+ for ( sal_Int32 x = 0; x < nColumnCount; x++ )
+ {
+ Reference< XPropertySet > xColPropSet( xColumns->getByIndex( x ), UNO_QUERY_THROW );
+ sal_Int32 nWidth;
+ xColPropSet->getPropertyValue( S("Width") ) >>= nWidth;
+
+ mpFS->singleElementNS( XML_a, XML_gridCol, XML_w, I64S(MM100toEMU(nWidth)), FSEND );
+ }
+
+ mpFS->endElementNS( XML_a, XML_tblGrid );
+
+ Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
+ sal_Int32 nRowHeight = xRowPropSet->getPropertyValue( S("Height") ) >>= nRowHeight;
+
+ mpFS->startElementNS( XML_a, XML_tr, XML_h, I64S( MM100toEMU( nRowHeight ) ), FSEND );
+
+ for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ )
+ {
+ Reference< XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW );
+ if ( !xCell->isMerged() )
+ {
+ mpFS->startElementNS( XML_a, XML_tc, FSEND );
+
+ WriteTextBox( xCell, XML_a );
+
+ mpFS->singleElementNS( XML_a, XML_tcPr, FSEND );
+ mpFS->endElementNS( XML_a, XML_tc );
+ }
+ }
+
+ mpFS->endElementNS( XML_a, XML_tr );
+ }
+
+ mpFS->endElementNS( XML_a, XML_tbl );
+ }
+
+ mpFS->endElementNS( XML_a, XML_graphicData );
+ mpFS->endElementNS( XML_a, XML_graphic );
+}
+
+ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape )
+{
+ FSHelperPtr pFS = GetFS();
+
+ OSL_TRACE("write table shape");
+
+ pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
+
+ pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
+
+ pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ XML_id, I32S( GetNewShapeID( xShape ) ),
+ XML_name, IDS(Table),
+ FSEND );
+
+ pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
+ FSEND );
+
+ if( GetDocumentType() == DOCUMENT_PPTX )
+ pFS->singleElementNS( mnXmlNamespace, XML_nvPr,
+ FSEND );
+ pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
+
+ WriteShapeTransformation( xShape, mnXmlNamespace );
+ WriteTable( xShape );
+
+ pFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
+
+ return *this;
+}
+
ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
{
FSHelperPtr pFS = GetFS();
@@ -979,7 +1085,7 @@ ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
WriteBlipFill( Reference< XPropertySet >(xShape, UNO_QUERY ), S( "GraphicURL" ) );
pFS->endElementNS( mnXmlNamespace, XML_spPr );
- WriteTextBox( xShape );
+ WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_sp );
@@ -1011,7 +1117,7 @@ ShapeExport& ShapeExport::WriteUnknownShape( Reference< XShape > )
return *this;
}
-size_t ShapeExport::ShapeHash::operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > rXShape ) const
+size_t ShapeExport::ShapeHash::operator()( const Reference < XShape > rXShape ) const
{
return rXShape->getShapeType().hashCode();
}
More information about the Libreoffice-commits
mailing list