summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorKatarina Machalkova <kmachalkova@suse.cz>2011-05-04 11:49:38 +0200
committerKatarina Machalkova <kmachalkova@suse.cz>2011-05-04 13:47:36 +0200
commitfafc7e0547c1cff6f18b0b60dd44749768250691 (patch)
tree27605334df4e4006d2694259053e27b54dc16605 /oox
parent00c5556869d8f382551675128d3db7bed397a77f (diff)
Check for existence of property before retrieving its value
Is[Empty]PresentationObject prop seems not to be set in Calc/Writer shape objects and retrieving its value throws an exception. This fixes export of xlsx docs with embedded pics/charts. (cherry picked from commit dd719060ab7ba487aff70bbf21418a2c2fb9cce6)
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx42
1 files changed, 31 insertions, 11 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 224b15068353..a8c838ddd1e6 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
@@ -76,6 +77,7 @@
#include <oox/export/chartexport.hxx>
using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::i18n;
@@ -105,6 +107,7 @@ using ::sax_fastparser::FSHelperPtr;
#define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr()
+
struct CustomShapeTypeTranslationTable
{
const char* sOOo;
@@ -408,17 +411,34 @@ awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
sal_Bool ShapeExport::NonEmptyText( Reference< XShape > xShape )
{
Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
- sal_Bool bIsEmptyPresObj = sal_False;
- if( xPropSet.is() && ( xPropSet->getPropertyValue( S( "IsEmptyPresentationObject" ) ) >>= bIsEmptyPresObj ) ) {
- DBG(printf("empty presentation object %d, props:\n", bIsEmptyPresObj));
- if( bIsEmptyPresObj )
- return sal_True;
- }
- sal_Bool bIsPresObj = sal_False;
- if( xPropSet.is() && ( xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj ) ) {
- DBG(printf("presentation object %d, props:\n", bIsPresObj));
- if( bIsPresObj )
- return sal_True;
+
+ if( xPropSet.is() )
+ {
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ if ( xPropSetInfo.is() )
+ {
+ if ( xPropSetInfo->hasPropertyByName( S( "IsEmptyPresentationObject" ) ) )
+ {
+ sal_Bool bIsEmptyPresObj = sal_False;
+ if ( xPropSet->getPropertyValue( S( "IsEmptyPresentationObject" ) ) >>= bIsEmptyPresObj )
+ {
+ DBG(printf("empty presentation object %d, props:\n", bIsEmptyPresObj));
+ if( bIsEmptyPresObj )
+ return sal_True;
+ }
+ }
+
+ if ( xPropSetInfo->hasPropertyByName( S( "IsEmptyPresentationObject" ) ) )
+ {
+ sal_Bool bIsPresObj = sal_False;
+ if ( xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj )
+ {
+ DBG(printf("presentation object %d, props:\n", bIsPresObj));
+ if( bIsPresObj )
+ return sal_True;
+ }
+ }
+ }
}
Reference< XSimpleText > xText( xShape, UNO_QUERY );