Hey there, 

can some1 please review the attached patch for 3.4?  Export of xlsx docs 
containing images or charts (GraphicObjectShape) fails with generic "cannot 
write" error (there is no particular bug id. associated with the issue so far 
... but I didn't search fdo bugzilla so well)

The problematic code is introduced by commit b49d4405f4a8919. I haven't even 
remote clue what is it supposed (not) to be doing, more specifically why an 
attempt to retrieve value of non-existing property 
('Is[Empty]PresentationObject') throws an exception and/or why the object in 
question doesn't have the mentioned property. There is handful of places where 
property value is being retrieved without  prior checking all over the code.

Anyway, the patch seems to do the job (the spreadsheet with imgs is saved as 
xlsx) and moreover, a similar trick is used in xmloff module 
(source/draw/shapeexport2.cxx, XMLShapeExport::ImpExportPresentationAttribute 
method)
Thx

B.
-- 
  \\\\\              Katarina Machalkova    
  \\\\\\\__o          LibO developer
__\\\\\\\'/_          & hedgehog painter
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index aea1812..5127921 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,30 @@ 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;
+	        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;
+               xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj; 
+               DBG(printf("presentation object %d, props:\n", bIsPresObj));
+               if( bIsPresObj )
+                    return sal_True;
+           }
+       }
     }
 
     Reference< XSimpleText > xText( xShape, UNO_QUERY );

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to