Kaydet (Commit) 2a711902 authored tarafından Matúš Kukan's avatar Matúš Kukan

bnc#880448: Improved handling of placeholder shapes

If subTitle placeholder is not found, try body instead of title.
And use body text styles instead of title, for subTitle.

Also improve PPTShape::findPlaceholder to find placeholder
with just nSecondSubType type without the same index.

Change-Id: I470e7268088eb989fb934007dfcf704f67d8cb1d
üst c70f22b9
...@@ -90,12 +90,10 @@ oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlideP ...@@ -90,12 +90,10 @@ oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlideP
{ {
case XML_ctrTitle : case XML_ctrTitle :
case XML_title : case XML_title :
case XML_subTitle :
pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle();
break; break;
case XML_subTitle :
case XML_obj : case XML_obj :
pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
break;
case XML_body : case XML_body :
if ( rSlidePersist.isNotesPage() ) if ( rSlidePersist.isNotesPage() )
pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle();
...@@ -149,6 +147,7 @@ void PPTShape::addShape( ...@@ -149,6 +147,7 @@ void PPTShape::addShape(
sServiceName = OUString(); sServiceName = OUString();
else { else {
sServiceName = "com.sun.star.presentation.SubtitleShape"; sServiceName = "com.sun.star.presentation.SubtitleShape";
aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
} }
} }
break; break;
...@@ -391,7 +390,8 @@ namespace ...@@ -391,7 +390,8 @@ namespace
// 1. ph with nFirstSubType and the same oSubTypeIndex // 1. ph with nFirstSubType and the same oSubTypeIndex
// 2. ph with nFirstSubType // 2. ph with nFirstSubType
// 3. ph with nSecondSubType and the same oSubTypeIndex // 3. ph with nSecondSubType and the same oSubTypeIndex
// 4. ph with the same oSubTypeIndex // 4. ph with nSecondSubType
// 5. ph with the same oSubTypeIndex
oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal_Int32 nSecondSubType, oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal_Int32 nSecondSubType,
const OptValue< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly ) const OptValue< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly )
{ {
...@@ -399,6 +399,7 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal ...@@ -399,6 +399,7 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal
oox::drawingml::ShapePtr aChoiceShapePtr1; oox::drawingml::ShapePtr aChoiceShapePtr1;
oox::drawingml::ShapePtr aChoiceShapePtr2; oox::drawingml::ShapePtr aChoiceShapePtr2;
oox::drawingml::ShapePtr aChoiceShapePtr3; oox::drawingml::ShapePtr aChoiceShapePtr3;
oox::drawingml::ShapePtr aChoiceShapePtr4;
std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
while (aRevIter != rShapes.rend()) while (aRevIter != rShapes.rend())
{ {
...@@ -413,27 +414,31 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal ...@@ -413,27 +414,31 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal
} }
else if ((*aRevIter)->getSubType() == nSecondSubType && !aChoiceShapePtr2.get()) else if ((*aRevIter)->getSubType() == nSecondSubType && !aChoiceShapePtr2.get())
aChoiceShapePtr2 = *aRevIter; aChoiceShapePtr2 = *aRevIter;
else if (!aChoiceShapePtr3.get()) else if (!aChoiceShapePtr4.get())
aChoiceShapePtr3 = *aRevIter; aChoiceShapePtr4 = *aRevIter;
} }
else if ((*aRevIter)->getSubType() == nFirstSubType && !aChoiceShapePtr1.get()) else if ((*aRevIter)->getSubType() == nFirstSubType && !aChoiceShapePtr1.get())
aChoiceShapePtr1 = *aRevIter; aChoiceShapePtr1 = *aRevIter;
else if ((*aRevIter)->getSubType() == nSecondSubType && !aChoiceShapePtr3.get())
aChoiceShapePtr3 = *aRevIter;
} }
std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
aChoiceShapePtr3 = findPlaceholder( nFirstSubType, nSecondSubType, oSubTypeIndex, rChildren, bMasterOnly ); aChoiceShapePtr4 = findPlaceholder( nFirstSubType, nSecondSubType, oSubTypeIndex, rChildren, bMasterOnly );
if (aChoiceShapePtr3.get()) if (aChoiceShapePtr4.get())
{ {
if (aChoiceShapePtr3->getSubType() == nFirstSubType) if (aChoiceShapePtr4->getSubType() == nFirstSubType)
{ {
if (aChoiceShapePtr3->getSubTypeIndex() == oSubTypeIndex) if (aChoiceShapePtr4->getSubTypeIndex() == oSubTypeIndex)
aShapePtr = aChoiceShapePtr3; aShapePtr = aChoiceShapePtr4;
else else
aChoiceShapePtr1 = aChoiceShapePtr3; aChoiceShapePtr1 = aChoiceShapePtr4;
} }
else if (aChoiceShapePtr3->getSubType() == nSecondSubType && else if (aChoiceShapePtr4->getSubType() == nSecondSubType)
aChoiceShapePtr3->getSubTypeIndex() == oSubTypeIndex)
{ {
aChoiceShapePtr2 = aChoiceShapePtr3; if (aChoiceShapePtr4->getSubTypeIndex() == oSubTypeIndex)
aChoiceShapePtr2 = aChoiceShapePtr4;
else
aChoiceShapePtr3 = aChoiceShapePtr4;
} }
} }
if (aShapePtr.get()) if (aShapePtr.get())
...@@ -446,7 +451,9 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal ...@@ -446,7 +451,9 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstSubType, sal
return aChoiceShapePtr1; return aChoiceShapePtr1;
if (aChoiceShapePtr2.get()) if (aChoiceShapePtr2.get())
return aChoiceShapePtr2; return aChoiceShapePtr2;
return aChoiceShapePtr3; if (aChoiceShapePtr3.get())
return aChoiceShapePtr3;
return aChoiceShapePtr4;
} }
oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly ) oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly )
......
...@@ -96,7 +96,7 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con ...@@ -96,7 +96,7 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con
case XML_subTitle : // slide/layout case XML_subTitle : // slide/layout
nFirstPlaceholder = XML_subTitle; nFirstPlaceholder = XML_subTitle;
nSecondPlaceholder = XML_title; nSecondPlaceholder = XML_body;
break; break;
case XML_obj : // slide/layout case XML_obj : // slide/layout
...@@ -140,7 +140,8 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con ...@@ -140,7 +140,8 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con
} }
if ( pPlaceholder.get() ) if ( pPlaceholder.get() )
{ {
OSL_TRACE("shape %s will get shape reference %s applied", OUStringToOString(mpShapePtr->getId(), RTL_TEXTENCODING_UTF8 ).getStr(), OUStringToOString(pPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr()); SAL_INFO("oox.ppt","shape " << mpShapePtr->getId() <<
" will get shape reference " << pPlaceholder->getId() << " applied");
mpShapePtr->applyShapeReference( *pPlaceholder.get() ); mpShapePtr->applyShapeReference( *pPlaceholder.get() );
PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
if ( pPPTShape ) if ( pPPTShape )
......
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