summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-05-27 20:49:36 +0200
committerJan Holesovsky <kendy@suse.cz>2011-05-27 20:49:36 +0200
commit102d51ec7c35c0b90fff89093d1d2d8c47ea0b7c (patch)
treefbf7ceecacb8233b9cf8f65baf210d2bf011f1a6 /oox
parente959581b2d44bff812ffddd34b750e4f9f29e187 (diff)
parent6c80a64574879415a093e8c3054528ce037beaf4 (diff)
Merge branch 'master' of git://anongit.freedesktop.org/libreoffice/filters
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/export/drawingml.hxx2
-rw-r--r--oox/inc/oox/export/shapes.hxx10
-rw-r--r--oox/source/export/drawingml.cxx6
-rw-r--r--oox/source/export/shapes.cxx140
4 files changed, 136 insertions, 22 deletions
diff --git a/oox/inc/oox/export/drawingml.hxx b/oox/inc/oox/export/drawingml.hxx
index 92603afc633e..93b0358b138e 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 37e68613f6a5..a9459c8540f7 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 48f4eb453ee0..4e94e905b37f 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 8bd8a3985fa5..be720432624c 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,17 +951,119 @@ 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(0);
+ 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(0);
+
+ 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;
}
@@ -979,7 +1087,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 +1119,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();
}