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
This commit is contained in:
Radek Doulik 2012-05-23 17:05:36 +02:00
parent 1bb9a60a96
commit 038564c910
5 changed files with 21 additions and 3 deletions

View file

@ -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(

View file

@ -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;

View file

@ -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)

View file

@ -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;
}
} }

View file

@ -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