diff options
author | Radek Doulik <rodo@novell.com> | 2012-05-23 17:05:36 +0200 |
---|---|---|
committer | Radek Doulik <rodo@novell.com> | 2012-05-23 17:09:14 +0200 |
commit | 038564c910e43f569b7c6abebffe2ad6ec9a1822 (patch) | |
tree | 2c8407e406454fec46fa03ca46b581dfc9135f11 /oox | |
parent | 1bb9a60a9609422c5b74dc547ddb358afbed03f5 (diff) |
do not insert empty texbodies for empty placeholder shapes
- the original problem can be reproduced by creating new empty presentation in powerpoint.
after it is loaded in impress, it was completely blank, without placeholder shape
texts (Click to add title, Click to add text)
Change-Id: I541554e273372ad09cca2fb91e27a17eb1f3a00e
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/drawingml/shape.hxx | 1 | ||||
-rw-r--r-- | oox/inc/oox/drawingml/textbody.hxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 5 | ||||
-rw-r--r-- | oox/source/drawingml/textbody.cxx | 15 | ||||
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 2 |
5 files changed, 21 insertions, 3 deletions
diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx index f2553fb0eef4..09ea5028b94e 100644 --- a/oox/inc/oox/drawingml/shape.hxx +++ b/oox/inc/oox/drawingml/shape.hxx @@ -189,6 +189,7 @@ protected: const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ::com::sun::star::awt::Rectangle* pShapeRect, sal_Bool bClearText, + sal_Bool bDoNotInsertEmptyTextBody, basegfx::B2DHomMatrix& aTransformation ); void addChildren( diff --git a/oox/inc/oox/drawingml/textbody.hxx b/oox/inc/oox/drawingml/textbody.hxx index aa2fdcd71317..7fad554ee9c4 100644 --- a/oox/inc/oox/drawingml/textbody.hxx +++ b/oox/inc/oox/drawingml/textbody.hxx @@ -68,6 +68,7 @@ public: const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > & xAt, const TextCharacterProperties& rTextStyleProperties, const TextListStylePtr& pMasterTextListStyle ) const; + bool isEmpty(); protected: TextParagraphVector maParagraphs; TextBodyProperties maTextProperties; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 9bdb962787a9..be58314124a4 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -212,7 +212,7 @@ void Shape::addShape( if( !sServiceName.isEmpty() ) { basegfx::B2DHomMatrix aMatrix( aTransformation ); - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False, aMatrix ) ); + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False, sal_False, aMatrix ) ); if( pShapeMap && !msId.isEmpty() ) { @@ -327,6 +327,7 @@ Reference< XShape > Shape::createAndInsert( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const awt::Rectangle* /* pShapeRect */, sal_Bool bClearText, + sal_Bool bDoNotInsertEmptyTextBody, basegfx::B2DHomMatrix& aParentTransformation ) { bool bIsEmbMedia = false; @@ -567,7 +568,7 @@ Reference< XShape > Shape::createAndInsert( getTextBody()->getTextProperties().pushVertSimulation(); // in some cases, we don't have any text body. - if( getTextBody() ) + if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) ) { Reference < XText > xText( mxShape, UNO_QUERY ); if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape) diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx index 43ef01287105..5080f0f867f4 100644 --- a/oox/source/drawingml/textbody.cxx +++ b/oox/source/drawingml/textbody.cxx @@ -77,6 +77,21 @@ void TextBody::insertAt( (*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg ); } +bool TextBody::isEmpty() +{ + if ( maParagraphs.size() <= 0 ) + return true; + if ( maParagraphs.size() > 1 ) + return false; + + const TextRunVector aRuns = maParagraphs[0]->getRuns(); + if ( aRuns.size() <= 0 ) + return true; + if ( aRuns.size() > 1 ) + return false; + + return aRuns[0]->getText().getLength() <= 0; +} } } diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index d7fba77af322..9fa052c46308 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -338,7 +338,7 @@ void PPTShape::addShape( } else setMasterTextListStyle( aMasterTextListStyle ); - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText, aTransformation ) ); + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText, mpPlaceholder.get() != NULL, aTransformation ) ); if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) ) { try |