oox/inc/oox/drawingml/textbodyproperties.hxx | 3 + oox/source/drawingml/shape.cxx | 3 + oox/source/drawingml/textbodyproperties.cxx | 22 +++++++++++++ oox/source/drawingml/textbodypropertiescontext.cxx | 25 +++------------ oox/source/ppt/pptshape.cxx | 4 ++ oox/source/ppt/pptshapecontext.cxx | 17 +++++++--- oox/source/ppt/slidefragmenthandler.cxx | 34 +++++++++++++++++++++ 7 files changed, 84 insertions(+), 24 deletions(-)
New commits: commit b1653c6b3968921ffee34bab2106c6d4e800179c Author: Muthu Subramanian <sumu...@suse.com> Date: Thu Aug 16 16:57:47 2012 +0530 n#773048: PPTX shape margins need to be rotated as well. diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx index adb9c1f..addad6e 100644 --- a/oox/inc/oox/drawingml/textbodyproperties.hxx +++ b/oox/inc/oox/drawingml/textbodyproperties.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include "oox/helper/helper.hxx" #include "oox/helper/propertymap.hxx" +#include <boost/optional.hpp> namespace oox { namespace drawingml { @@ -43,10 +44,12 @@ struct TextBodyProperties PropertyMap maPropertyMap; OptValue< sal_Int32 > moRotation; OptValue< sal_Int32 > moVert; + boost::optional< sal_Int32 > moInsets[4]; ::com::sun::star::drawing::TextVerticalAdjust meVA; explicit TextBodyProperties(); + void pushRotationAdjustments( sal_Int32 nRotation ); void pushVertSimulation(); }; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 66a1ee1..242dd43 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -525,7 +525,10 @@ Reference< XShape > Shape::createAndInsert( // add properties from textbody to shape properties if( mpTextBody.get() ) + { + mpTextBody->getTextProperties().pushRotationAdjustments( mnRotation ); aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap ); + } // applying properties aShapeProps.assignUsed( getShapeProperties() ); diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx index d007647..8438ed5 100644 --- a/oox/source/drawingml/textbodyproperties.cxx +++ b/oox/source/drawingml/textbodyproperties.cxx @@ -67,6 +67,28 @@ void TextBodyProperties::pushVertSimulation() } } +/* Push adjusted values, taking into consideration Shape Rotation */ +void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation ) +{ + sal_Int32 nOff = 0; + sal_Int32 aProps[] = { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance }; + sal_Int32 n = ( sal_Int32 )( sizeof( aProps ) / sizeof( sal_Int32 ) ); + + switch( nRotation ) // TODO: What happens for part rotations ? + { + case (90*1*60000): nOff = 1; break; + case (90*2*60000): nOff = 2; break; + case (90*3*60000): nOff = 3; break; + default: break; + } + + for( sal_Int32 i = 0; i < n; i++ ) + { + if( moInsets[i] ) + maPropertyMap[ aProps[ ( nOff++ ) % n ] ] <<= static_cast< sal_Int32 >( *moInsets[i] ); + } +} + // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index a654fb6..711da4c 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -63,25 +63,12 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, // ST_Coordinate OUString sValue; - sValue = xAttributes->getOptionalValue( XML_lIns ); - if( !sValue.isEmpty() ) { - sal_Int32 nLeftInset = ( !sValue.isEmpty() ? GetCoordinate( sValue ) : 91440 / 360 ); - mrTextBodyProp.maPropertyMap[ PROP_TextLeftDistance ] <<= static_cast< sal_Int32 >( nLeftInset ); - } - sValue = xAttributes->getOptionalValue( XML_tIns ); - if( !sValue.isEmpty() ) { - sal_Int32 nTopInset = ( !sValue.isEmpty() ? GetCoordinate( sValue ) : 91440 / 360 ); - mrTextBodyProp.maPropertyMap[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( nTopInset ); - } - sValue = xAttributes->getOptionalValue( XML_rIns ); - if( !sValue.isEmpty() ) { - sal_Int32 nRightInset = ( !sValue.isEmpty() ? GetCoordinate( sValue ) : 91440 / 360 ); - mrTextBodyProp.maPropertyMap[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( nRightInset ); - } - sValue = xAttributes->getOptionalValue( XML_bIns ); - if( !sValue.isEmpty() ) { - sal_Int32 nBottonInset = ( !sValue.isEmpty() ? GetCoordinate( sValue ) : 45720 / 360 ); - mrTextBodyProp.maPropertyMap[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( nBottonInset ); + sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns }; + for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++) + { + sValue = xAttributes->getOptionalValue( aIns[i] ); + if( !sValue.isEmpty() ) + mrTextBodyProp.moInsets[i] = GetCoordinate( sValue ); } bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false ); commit d3d19085e3b1132c7aad9767b20e76d0ac7c6cd3 Author: David Tardon <dtar...@redhat.com> Date: Thu Jul 5 06:57:06 2012 +0200 remove forgotten debug printf Change-Id: Iff5a53735d78a2afcf90299a5f28a47f1376e393 diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index d014164..49736dd 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -98,7 +98,6 @@ SlideFragmentHandler::~SlideFragmentHandler() throw() // Import notesMaster PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() ); OUString aNotesFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesMaster" ) ); - printf("notesMaster: %s\n", ::rtl::OUStringToOString(aNotesFragmentPath, RTL_TEXTENCODING_UTF8).getStr() ); std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() ); std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() ); commit 3dd5267d1808180a65f9e401caad791cf3870ac0 Author: Muthu Subramanian <sumu...@suse.com> Date: Wed Jul 4 20:56:47 2012 +0530 n#768027: Slide notesMaster and notes import. diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 2f2e330..417c1bd 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -264,6 +264,10 @@ void PPTShape::addShape( // use placeholder index if possible if( mnSubType && getSubTypeIndex().has() && rSlidePersist.getMasterPersist().get() ) { oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex().get(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() ); + // TODO: Check if this is required for non-notes slides as well... + if( rSlidePersist.isNotesPage() && pPlaceholder.get() && pPlaceholder->getSubType() != getSubType() ) + pPlaceholder.reset(); + if( pPlaceholder.get()) { OSL_TRACE("found placeholder with index: %d and type: %s", getSubTypeIndex().get(), lclDebugSubType( mnSubType )); } diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 0333f5a..c301f23 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -65,14 +65,17 @@ PPTShapeContext::PPTShapeContext( ContextHandler& rParent, const SlidePersistPtr oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, const OptValue< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) { oox::drawingml::ShapePtr aShapePtr; - oox::drawingml::ShapePtr aTmpShapePtr; + oox::drawingml::ShapePtr aChoiceShapePtr1; + oox::drawingml::ShapePtr aChoiceShapePtr2; std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); while( aRevIter != rShapes.rend() ) { if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) { - if( !oSubTypeIndex.has() && aTmpShapePtr == NULL ) - aTmpShapePtr = *aRevIter; + if( !oSubTypeIndex.has() && aChoiceShapePtr1 == NULL ) + aChoiceShapePtr1 = *aRevIter; + else if( aChoiceShapePtr2 == NULL ) + aChoiceShapePtr2 = *aRevIter; if( (*aRevIter)->getSubTypeIndex() == oSubTypeIndex ) { aShapePtr = *aRevIter; @@ -86,7 +89,7 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, co ++aRevIter; } if( aShapePtr == NULL ) - return aTmpShapePtr; + return aChoiceShapePtr1 ? aChoiceShapePtr1 : aChoiceShapePtr2; return aShapePtr; } @@ -185,9 +188,13 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In if ( pMasterPersist.get() ) { if( pPPTShapePtr->getSubTypeIndex().has() ) pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex().get(), pMasterPersist->getShapes()->getChildren() ); - if ( !pPlaceholder.get() ) + // TODO: Check if this is required for non-notes pages as well... + if ( !pPlaceholder.get() || ( pMasterPersist->isNotesPage() && pPlaceholder->getSubType() != nFirstPlaceholder && + pPlaceholder->getSubType() != nSecondPlaceholder ) ) + { pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + } } } if ( pPlaceholder.get() ) diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 9f98742..d014164 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -45,6 +45,7 @@ #include "oox/vml/vmldrawing.hxx" #include "oox/vml/vmldrawingfragment.hxx" #include "oox/drawingml/clrschemecontext.hxx" +#include "oox/ppt/pptimport.hxx" using rtl::OUString; @@ -93,6 +94,40 @@ SlideFragmentHandler::~SlideFragmentHandler() throw() return this; } case PPT_TOKEN( notes ): // CT_NotesSlide + { + // Import notesMaster + PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() ); + OUString aNotesFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesMaster" ) ); + printf("notesMaster: %s\n", ::rtl::OUStringToOString(aNotesFragmentPath, RTL_TEXTENCODING_UTF8).getStr() ); + + std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() ); + std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() ); + while( aIter != rMasterPages.end() ) + { + if( (*aIter)->getPath() == aNotesFragmentPath ) + { + if( !mpSlidePersistPtr->getMasterPersist() ) + mpSlidePersistPtr->setMasterPersist( *aIter ); + break; + } + ++aIter; + } + if( aIter == rMasterPages.end() && !mpSlidePersistPtr->getMasterPersist() ) + { + TextListStylePtr pTextListStyle(new TextListStyle); + SlidePersistPtr pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, sal_True, sal_True, mpSlidePersistPtr->getPage(), + ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpSlidePersistPtr->getNotesTextStyle() ) ); + //pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath ); + pMasterPersistPtr->setPath( aNotesFragmentPath ); + rFilter.getMasterPages().push_back( pMasterPersistPtr ); + FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aNotesFragmentPath, pMasterPersistPtr, Master ) ); + rFilter.importFragment( xMasterFragmentHandler ); + //pMasterPersistPtr->createBackground( rFilter ); + //pMasterPersistPtr->createXShapes( rFilter ); + mpSlidePersistPtr->setMasterPersist( pMasterPersistPtr ); + } + return this; + } case PPT_TOKEN( notesMaster ): // CT_NotesMaster return this; case PPT_TOKEN( cSld ): // CT_CommonSlideData _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits