ooo-build r15560 - in trunk: . patches/dev300



Author: rodo
Date: Wed Mar 18 06:55:50 2009
New Revision: 15560
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15560&view=rev

Log:
2009-03-18  Radek Doulik  <rodo novell com>

	* build/ooo310-m4/oox/source/ppt/pptshapecontext.cxx: added new
	helper method findPlaceholderByIndex, which lookups shape by index
	(PPTShapeContext::createFastChildContext): when idx attribute is
	present in p:ph inside slide, lookup the placeholder by index
	instead by type only

	* patches/dev300/apply: added oox-fix-placeholder-layout.diff,
	which fixes n#485316 and partially n#480223



Added:
   trunk/patches/dev300/oox-fix-placeholder-layout.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Wed Mar 18 06:55:50 2009
@@ -2009,6 +2009,8 @@
 
 buildfix-oox-depends-on-unotools.diff
 
+oox-fix-placeholder-layout.diff, n#485316, n#480223, rodo
+
 [ CalcFixes  <= dev300-m42 <= ooo310-m1]
 # Support PHONETIC function to display asian phonetic guide.
 calc-formula-asian-phonetic-m1.diff, i#80764, i#80765, i#80766, kohei

Added: trunk/patches/dev300/oox-fix-placeholder-layout.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/oox-fix-placeholder-layout.diff	Wed Mar 18 06:55:50 2009
@@ -0,0 +1,105 @@
+diff --git oox/inc/oox/drawingml/shape.hxx oox/inc/oox/drawingml/shape.hxx
+index 5a7e7e5..5405d9d 100644
+--- oox/inc/oox/drawingml/shape.hxx
++++ oox/inc/oox/drawingml/shape.hxx
+@@ -112,6 +112,7 @@ public:
+     void                            setSubType( sal_uInt32 nSubType ) { mnSubType = nSubType; }
+     sal_Int32                       getSubType() const { return mnSubType; }
+     void                            setIndex( sal_uInt32 nIndex ) { mnIndex = nIndex; }
++    sal_Int32                       getIndex() { return mnIndex; }
+ 
+     // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
+     void                            setDefaults();
+diff --git oox/source/ppt/pptshapecontext.cxx oox/source/ppt/pptshapecontext.cxx
+index f87d03d..5acf932 100644
+--- oox/source/ppt/pptshapecontext.cxx
++++ oox/source/ppt/pptshapecontext.cxx
+@@ -85,6 +85,26 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st
+ 	return aShapePtr;
+ }
+ 
++oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, 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)->getIndex() == nIdx )
++		{
++			aShapePtr = *aRevIter;
++			break;
++		}
++		std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
++		aShapePtr = findPlaceholderByIndex( nIdx, 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, std::vector< oox::drawingml::ShapePtr >& rShapes )
+ {
+@@ -109,14 +129,27 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
+ 	{
+ 		sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
+ 		mpShapePtr->setSubType( nSubType );
+-		mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
+-		if ( nSubType )
++		OUString sIdx( xAttribs->getOptionalValue( XML_idx ) );
++		sal_Bool bHasIdx = sIdx.getLength() > 0;
++		sal_Int32 nIdx = sIdx.toInt32();
++		mpShapePtr->setIndex( nIdx );
++
++		if ( nSubType || bHasIdx )
+ 		{
+ 			PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
+ 			if ( pPPTShapePtr )
+ 			{
+ 				oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
+-				if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
++				oox::drawingml::ShapePtr pPlaceholder;
++
++				if ( bHasIdx && eShapeLocation == Slide )
++				{
++				    // TODO: use id to shape map
++				    SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
++				    if ( pMasterPersist.get() )
++					pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
++				}
++				if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
+ 				{
+ 					// inheriting properties from placeholder objects by cloning shape
+ 
+@@ -154,7 +187,6 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
+ 					}
+ 					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, mpSlidePersistPtr->getShapes()->getChildren() );
+ 						else if ( eShapeLocation == Slide )	// normal slide shapes have to search within the corresponding master tree for referenced objects
+@@ -163,15 +195,15 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
+ 							if ( pMasterPersist.get() )
+                                 pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
+ 						}
+-						if ( pPlaceholder.get() )
+-						{
+-							mpShapePtr->applyShapeReference( *pPlaceholder.get() );
+-							PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
+-							if ( pPPTShape )
+-								pPPTShape->setReferenced( sal_True );
+-						}
+ 					}
+ 				}
++				if ( pPlaceholder.get() )
++				{
++				    mpShapePtr->applyShapeReference( *pPlaceholder.get() );
++				    PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
++				    if ( pPPTShape )
++					pPPTShape->setReferenced( sal_True );
++				}
+ 			}
+ 		}
+ 		break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]