[Libreoffice-commits] .: Branch 'ooo-build-3-2-1' - patches/dev300

Radek Doulík rodo at kemper.freedesktop.org
Tue Nov 16 14:00:29 PST 2010


 patches/dev300/apply                                                       |    1 
 patches/dev300/oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff |  252 ++++++++++
 2 files changed, 253 insertions(+)

New commits:
commit 18f7e9bd24ad3df1272bde93da7bd231f160cb1f
Author: Radek Doulik <rodo at novell.com>
Date:   Tue Nov 16 22:58:50 2010 +0100

    fix size of imported textboxes (placeholders) - backport from LO, n#650051
    
    * patches/dev300/apply:
    * patches/dev300/oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff:

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 97c532c..09fe717 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -4157,3 +4157,4 @@ oox-pptx-import-fix-customshapes-and-groups.diff, n#621739, rodo
 oox-pptx-import-fix-groups-2.diff, n#619678, rodo
 oox-pptx-import-fix-text-paragraph-autofit.diff, n#650035, rodo
 oox-pptx-import-fix-table-style.diff, n#650008, rodo
+oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff, n#650051, rodo
diff --git a/patches/dev300/oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff b/patches/dev300/oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff
new file mode 100644
index 0000000..d8a7980
--- /dev/null
+++ b/patches/dev300/oox-pptx-import-backport-from-LO-fix-zero-sized-shapes.diff
@@ -0,0 +1,252 @@
+--- oox/source/ppt/pptshapecontext.cxx	2010-11-16 21:51:54.000000000 +0100
++++ oox/source/ppt/pptshapecontext.cxx	2010-10-25 18:35:08.000000000 +0200
+@@ -63,123 +65,149 @@
+ {
+ }
+ 
++oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes )
++{
++    oox::drawingml::ShapePtr aShapePtr;
++    std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
++    while( aRevIter != rShapes.rend() )
++    {
++        if ( (*aRevIter)->getSubType() == nMasterPlaceholder )
++        {
++            if ( ( nSubTypeIndex == -1 ) || ( nSubTypeIndex == (*aRevIter)->getSubTypeIndex() ) )
++            {
++                aShapePtr = *aRevIter;
++                break;
++            }
++        }
++        std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
++        aShapePtr = findPlaceholder( nMasterPlaceholder, nSubTypeIndex, rChildren );
++        if ( aShapePtr.get() )
++            break;
++        aRevIter++;
++    }
++    return aShapePtr;
++}
++
++// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
++oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder,
++    sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes )
++{
++    oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, nSubTypeIndex, rShapes );
++    return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, nSubTypeIndex, rShapes );
++}
++
+ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+ {
+     Reference< XFastContextHandler > xRet;
+ 
+     switch( aElementToken )
+     {
+-    // nvSpPr CT_ShapeNonVisual begin
+-//	case NMSP_PPT|XML_drElemPr:
+-//		break;
+-    case NMSP_PPT|XML_cNvPr:
+-        mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
+-        mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
+-        break;
+-    case NMSP_PPT|XML_ph:
+-    {
+-        sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
+-        mpShapePtr->setSubType( nSubType );
+-	OUString sIdx( xAttribs->getOptionalValue( XML_idx ) );
+-	sal_Bool bHasIdx = sIdx.getLength() > 0;
+-	sal_Int32 nIdx = sIdx.toInt32();
+-	mpShapePtr->setSubTypeIndex( nIdx );
+-
+-	if ( nSubType || bHasIdx )
++        // nvSpPr CT_ShapeNonVisual begin
++        //	case NMSP_PPT|XML_drElemPr:
++        //		break;
++        case NMSP_PPT|XML_cNvPr:
+         {
+-            PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
+-            if ( pPPTShapePtr )
++            mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
++            mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
++            break;
++        }
++        case NMSP_PPT|XML_ph:
++        {
++            sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
++            mpShapePtr->setSubType( nSubType );
++            if( xAttribs->hasAttribute( XML_idx ) )
++                mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
++            if ( nSubType )
+             {
+-                oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
+-		oox::drawingml::ShapePtr pPlaceholder;
+-
+-		if ( bHasIdx && eShapeLocation == Slide )
+-		{
+-		    // TODO: use id to shape map
+-		  SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
+-		  if ( pMasterPersist.get() )
+-		    pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
+-		}
+-		if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
++                PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
++                if ( pPPTShapePtr )
+                 {
+-                    // inheriting properties from placeholder objects by cloning shape
+-
+-                    sal_Int32 nFirstPlaceholder = 0;
+-                    sal_Int32 nSecondPlaceholder = 0;
+-                    switch( nSubType )
++                    oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
++                    if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
+                     {
+-                        case XML_ctrTitle :		// slide/layout
+-                            nFirstPlaceholder = XML_ctrTitle;
+-                            nSecondPlaceholder = XML_title;
+-                            break;
+-                        case XML_subTitle :		// slide/layout
+-                            nFirstPlaceholder = XML_subTitle;
+-                            nSecondPlaceholder = XML_title;
+-                            break;
+-                        case XML_obj :			// slide/layout
+-                            nFirstPlaceholder = XML_obj;
+-                            nSecondPlaceholder = XML_body;
+-                            break;
+-                        case XML_dt :			// slide/layout/master/notes/notesmaster/handoutmaster
+-                        case XML_sldNum :		// slide/layout/master/notes/notesmaster/handoutmaster
+-                        case XML_ftr :			// slide/layout/master/notes/notesmaster/handoutmaster
+-                        case XML_hdr :			// notes/notesmaster/handoutmaster
+-                        case XML_body :			// slide/layout/master/notes/notesmaster
+-                        case XML_title :		// slide/layout/master/
+-                        case XML_chart :		// slide/layout
+-                        case XML_tbl :			// slide/layout
+-                        case XML_clipArt :		// slide/layout
+-                        case XML_dgm :			// slide/layout
+-                        case XML_media :		// slide/layout
+-                        case XML_sldImg :		// notes/notesmaster
+-                        case XML_pic :			// slide/layout
+-                            nFirstPlaceholder = nSubType;
+-                        default:
+-                            break;
+-                    }
+-                    if ( nFirstPlaceholder )
+-                    {
+-                        if ( eShapeLocation == Layout )		// for layout objects the referenced object can be found within the same shape tree
+-			  pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, -1, mpSlidePersistPtr->getShapes()->getChildren() );
+-                        else if ( eShapeLocation == Slide )	// normal slide shapes have to search within the corresponding master tree for referenced objects
++                        // inheriting properties from placeholder objects by cloning shape
++                        sal_Int32 nFirstPlaceholder = 0;
++                        sal_Int32 nSecondPlaceholder = 0;
++                        switch( nSubType )
+                         {
+-                            SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
+-                            if ( pMasterPersist.get() )
+-                                pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(),
+-                                    pMasterPersist->getShapes()->getChildren() );
++                            case XML_ctrTitle :		// slide/layout
++                                  nFirstPlaceholder = XML_ctrTitle;
++                                  nSecondPlaceholder = XML_title;
++                              break;
++
++                              case XML_subTitle :		// slide/layout
++                                  nFirstPlaceholder = XML_subTitle;
++                                  nSecondPlaceholder = XML_title;
++                              break;
++
++                             case XML_obj :			// slide/layout
++                                  nFirstPlaceholder = XML_obj;
++                                  nSecondPlaceholder = XML_body;
++                              break;
++
++                            case XML_dt :			// slide/layout/master/notes/notesmaster/handoutmaster
++                              case XML_sldNum :		// slide/layout/master/notes/notesmaster/handoutmaster
++                              case XML_ftr :			// slide/layout/master/notes/notesmaster/handoutmaster
++                              case XML_hdr :			// notes/notesmaster/handoutmaster
++                              case XML_body :			// slide/layout/master/notes/notesmaster
++                              case XML_title :		// slide/layout/master/
++                              case XML_chart :		// slide/layout
++                              case XML_tbl :			// slide/layout
++                              case XML_clipArt :		// slide/layout
++                              case XML_dgm :			// slide/layout
++                              case XML_media :		// slide/layout
++                              case XML_sldImg :		// notes/notesmaster
++                              case XML_pic :			// slide/layout
++                                  nFirstPlaceholder = nSubType;
++                              default:
++                                  break;
+                         }
++                          if ( nFirstPlaceholder )
++                          {
++                              oox::drawingml::ShapePtr pPlaceholder;
++                              if ( eShapeLocation == Layout )		// for layout objects the referenced object can be found within the same shape tree
++                                pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, -1, mpSlidePersistPtr->getShapes()->getChildren() );
++                              else if ( eShapeLocation == Slide )	// normal slide shapes have to search within the corresponding master tree for referenced objects
++                              {
++                                  SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
++                                  if ( pMasterPersist.get() )
++                                    pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
++                                pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
++                              }
++                              if ( pPlaceholder.get() )
++                              {
++                                  mpShapePtr->applyShapeReference( *pPlaceholder.get() );
++                                  PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
++                                  if ( pPPTShape )
++                                      pPPTShape->setReferenced( sal_True );
++                    pPPTShapePtr->setPlaceholder( pPlaceholder );
++                              }
++                          }
+                     }
+-                }
+-		if ( pPlaceholder.get() )
+-		{
+-		    mpShapePtr->applyShapeReference( *pPlaceholder.get() );
+-		    PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
+-		    if ( pPPTShape )
+-		      pPPTShape->setReferenced( sal_True );
+-				    pPPTShapePtr->setPlaceholder( pPlaceholder );
+-		}
+-            }
++                  }
++
++              }
++              break;
+         }
+-        break;
+-    }
+-    // nvSpPr CT_ShapeNonVisual end
+ 
+-    case NMSP_PPT|XML_spPr:
+-        xRet = new PPTShapePropertiesContext( *this, *mpShapePtr );
+-        break;
++        // nvSpPr CT_ShapeNonVisual end
+ 
+-    case NMSP_PPT|XML_style:
+-        xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
+-        break;
++        case NMSP_PPT|XML_spPr:
++            xRet = new PPTShapePropertiesContext( *this, *mpShapePtr );
++            break;
+ 
+-    case NMSP_PPT|XML_txBody:
+-    {
+-        oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
+-        xTextBody->getTextProperties().maPropertyMap[ PROP_FontIndependentLineSpacing ] <<= static_cast< sal_Bool >( sal_True );
+-        mpShapePtr->setTextBody( xTextBody );
+-        xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
+-        break;
+-    }
++        case NMSP_PPT|XML_style:
++            xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
++            break;
++
++        case NMSP_PPT|XML_txBody:
++        {
++            oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
++            xTextBody->getTextProperties().maPropertyMap[ PROP_FontIndependentLineSpacing ] <<= static_cast< sal_Bool >( sal_True );
++            mpShapePtr->setTextBody( xTextBody );
++            xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
++            break;
++        }
+     }
+ 
+     if( !xRet.is() )


More information about the Libreoffice-commits mailing list