Kaydet (Commit) 038564c9 authored tarafından Radek Doulik's avatar Radek Doulik

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
üst 1bb9a60a
...@@ -189,6 +189,7 @@ protected: ...@@ -189,6 +189,7 @@ protected:
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
const ::com::sun::star::awt::Rectangle* pShapeRect, const ::com::sun::star::awt::Rectangle* pShapeRect,
sal_Bool bClearText, sal_Bool bClearText,
sal_Bool bDoNotInsertEmptyTextBody,
basegfx::B2DHomMatrix& aTransformation ); basegfx::B2DHomMatrix& aTransformation );
void addChildren( void addChildren(
......
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > & xAt, const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > & xAt,
const TextCharacterProperties& rTextStyleProperties, const TextCharacterProperties& rTextStyleProperties,
const TextListStylePtr& pMasterTextListStyle ) const; const TextListStylePtr& pMasterTextListStyle ) const;
bool isEmpty();
protected: protected:
TextParagraphVector maParagraphs; TextParagraphVector maParagraphs;
TextBodyProperties maTextProperties; TextBodyProperties maTextProperties;
......
...@@ -212,7 +212,7 @@ void Shape::addShape( ...@@ -212,7 +212,7 @@ void Shape::addShape(
if( !sServiceName.isEmpty() ) if( !sServiceName.isEmpty() )
{ {
basegfx::B2DHomMatrix aMatrix( aTransformation ); 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() ) if( pShapeMap && !msId.isEmpty() )
{ {
...@@ -327,6 +327,7 @@ Reference< XShape > Shape::createAndInsert( ...@@ -327,6 +327,7 @@ Reference< XShape > Shape::createAndInsert(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
const awt::Rectangle* /* pShapeRect */, const awt::Rectangle* /* pShapeRect */,
sal_Bool bClearText, sal_Bool bClearText,
sal_Bool bDoNotInsertEmptyTextBody,
basegfx::B2DHomMatrix& aParentTransformation ) basegfx::B2DHomMatrix& aParentTransformation )
{ {
bool bIsEmbMedia = false; bool bIsEmbMedia = false;
...@@ -567,7 +568,7 @@ Reference< XShape > Shape::createAndInsert( ...@@ -567,7 +568,7 @@ Reference< XShape > Shape::createAndInsert(
getTextBody()->getTextProperties().pushVertSimulation(); getTextBody()->getTextProperties().pushVertSimulation();
// in some cases, we don't have any text body. // in some cases, we don't have any text body.
if( getTextBody() ) if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
{ {
Reference < XText > xText( mxShape, UNO_QUERY ); Reference < XText > xText( mxShape, UNO_QUERY );
if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape) if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape)
......
...@@ -77,6 +77,21 @@ void TextBody::insertAt( ...@@ -77,6 +77,21 @@ void TextBody::insertAt(
(*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg ); (*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;
}
} } } }
......
...@@ -338,7 +338,7 @@ void PPTShape::addShape( ...@@ -338,7 +338,7 @@ void PPTShape::addShape(
} else } else
setMasterTextListStyle( aMasterTextListStyle ); 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 ) ) if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) )
{ {
try try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment