[Libreoffice-commits] .: oox/inc oox/source

Radek Doulík rodo at kemper.freedesktop.org
Mon Mar 7 08:02:30 PST 2011


 oox/inc/oox/drawingml/shape.hxx    |    1 
 oox/inc/oox/ppt/pptshape.hxx       |    2 
 oox/source/ppt/pptshape.cxx        |   85 ++++++++++++++++++++++++++++++++++++-
 oox/source/ppt/pptshapecontext.cxx |   19 ++++++--
 4 files changed, 100 insertions(+), 7 deletions(-)

New commits:
commit 01a0954a9be510af6189e0da25e3ce864b614738
Author: Radek Doulik <rodo at novell.com>
Date:   Mon Mar 7 16:55:36 2011 +0100

    fix placeholder text style n#650026
    
     - make it inherit style from master text list styles, the style of placeholders
       living in master slide was not used, in this case the placeholder has body
       style and should thus use body text style of master slide
     - also added more debug output related to placeholders to make it easier
       debug next time

diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx
index 77acee6..099a7af 100644
--- a/oox/inc/oox/drawingml/shape.hxx
+++ b/oox/inc/oox/drawingml/shape.hxx
@@ -130,6 +130,7 @@ public:
     void                            setName( const rtl::OUString& rName ) { msName = rName; }
     ::rtl::OUString                 getName( ) { return msName; }
     void                            setId( const rtl::OUString& rId ) { msId = rId; }
+    ::rtl::OUString                 getId() { return msId; }
     void							setHidden( sal_Bool bHidden ) { mbHidden = bHidden; }
     sal_Bool						getHidden() const { return mbHidden; };
     void                            setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
diff --git a/oox/inc/oox/ppt/pptshape.hxx b/oox/inc/oox/ppt/pptshape.hxx
index c512a8d..37bd51d 100644
--- a/oox/inc/oox/ppt/pptshape.hxx
+++ b/oox/inc/oox/ppt/pptshape.hxx
@@ -68,6 +68,8 @@ public:
     static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes );
     static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes );
 
+    static oox::drawingml::TextListStylePtr getSubTypeTextListStyle( const SlidePersist& rSlidePersist, sal_Int32 nSubType );
+
 protected:
 
     oox::drawingml::ShapePtr mpPlaceholder;
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 2336d2d..d88f3d4 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -64,6 +64,61 @@ PPTShape::~PPTShape()
 {
 }
 
+static const char* lclDebugSubType( sal_Int32 nType )
+{
+    switch (nType) {
+        case XML_ctrTitle :
+            return "ctrTitle";
+        case XML_title :
+            return "title";
+        case XML_subTitle :
+            return "subTitle";
+        case XML_obj :
+            return "obj";
+        case XML_body :
+            return "body";
+        case XML_dt :
+            return "dt";
+        case XML_hdr :
+            return "hdr";
+        case XML_ftr :
+            return "frt";
+        case XML_sldNum :
+            return "sldNum";
+        case XML_sldImg :
+            return "sldImg";
+    }
+
+    return "unknown - please extend lclDebugSubType";
+}
+
+oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlidePersist& rSlidePersist, sal_Int32 nSubType )
+{
+    oox::drawingml::TextListStylePtr pTextListStyle;
+
+    OSL_TRACE( "subtype style: %s", lclDebugSubType( nSubType ) );
+
+    switch( nSubType )
+    {
+        case XML_ctrTitle :
+        case XML_title :
+        case XML_subTitle :
+            pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle();
+            break;
+        case XML_obj :
+            pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
+            break;
+        case XML_body :
+            if ( rSlidePersist.isNotesPage() )
+                pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle();
+            else
+                pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
+            break;
+    }
+
+    return pTextListStyle;
+}
+
 void PPTShape::addShape(
         const oox::core::XmlFilterBase& rFilterBase,
         const SlidePersist& rSlidePersist,
@@ -72,6 +127,7 @@ void PPTShape::addShape(
         const awt::Rectangle* pShapeRect,
         ::oox::drawingml::ShapeIdMap* pShapeMap )
 {
+    OSL_TRACE("add shape id: %s location: %s", rtl::OUStringToOString(msId, RTL_TEXTENCODING_UTF8 ).getStr(), meShapeLocation == Master ? "master" : meShapeLocation == Slide ? "slide" : "other");
     // only placeholder from layout are being inserted
     if ( mnSubType && ( meShapeLocation == Master ) )
         return;
@@ -179,19 +235,44 @@ void PPTShape::addShape(
             // use placeholder index if possible
             if( mnSubType && getSubTypeIndex() && getSubTypeIndex() != -1 && rSlidePersist.getMasterPersist().get() ) {
                 oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() );
+                if( pPlaceholder.get()) {
+                    OSL_TRACE("found placeholder with index: %d and type: %s", getSubTypeIndex(), lclDebugSubType( mnSubType ));
+                }
                 if( pPlaceholder.get() ) {
+                    PPTShape* pPPTPlaceholder = dynamic_cast< PPTShape* >( pPlaceholder.get() );
+                    TextListStylePtr pNewTextListStyle ( new TextListStyle() );
+
                     if( pPlaceholder->getTextBody() ) {
-                        TextListStylePtr pNewTextListStyle ( new TextListStyle() );
 
                         pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() );
                         if( pPlaceholder->getMasterTextListStyle().get() )
                             pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() );
-                
+
+                        // OSL_TRACE("placeholder body style");
+                        // pPlaceholder->getTextBody()->getTextListStyle().dump();
+                        // OSL_TRACE("master text list style");
+                        // pPlaceholder->getMasterTextListStyle()->dump();
+
                         aMasterTextListStyle = pNewTextListStyle;
                     }
+                    if( pPPTPlaceholder->mpPlaceholder.get() ) {
+                        OSL_TRACE("placeholder has parent placeholder: %s type: %s index: %d",
+                                  rtl::OUStringToOString( pPPTPlaceholder->mpPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr(),
+                                  lclDebugSubType( pPPTPlaceholder->mpPlaceholder->getSubType() ),
+                                  pPPTPlaceholder->mpPlaceholder->getSubTypeIndex() );
+                        OSL_TRACE("has textbody %d", pPPTPlaceholder->mpPlaceholder->getTextBody() != NULL );
+                        TextListStylePtr pPlaceholderStyle = getSubTypeTextListStyle( rSlidePersist, pPPTPlaceholder->mpPlaceholder->getSubType() );
+                        if( pPPTPlaceholder->mpPlaceholder->getTextBody() )
+                            pNewTextListStyle->apply( pPPTPlaceholder->mpPlaceholder->getTextBody()->getTextListStyle() );
+                        if( pPlaceholderStyle.get() ) {
+                            pNewTextListStyle->apply( *pPlaceholderStyle );
+                            //pPlaceholderStyle->dump();
+                        }
+                    }
                 } else if( !mpPlaceholder.get() ) {
                     aMasterTextListStyle.reset();
                 }
+                OSL_TRACE("placeholder id: %s", pPlaceholder.get() ? rtl::OUStringToOString(pPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr() : "not found");
             }
 
             if ( sServiceName.getLength() )
diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx
index d8fc780..a6c3b13 100644
--- a/oox/source/ppt/pptshapecontext.cxx
+++ b/oox/source/ppt/pptshapecontext.cxx
@@ -168,21 +168,30 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
                           {
                               oox::drawingml::ShapePtr pPlaceholder;
                               if ( eShapeLocation == Layout )		// for layout objects the referenced object can be found within the same shape tree
-                                pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, -1, mpSlidePersistPtr->getShapes()->getChildren() );
+                              {
+                                  pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren() );
+                                  if ( !pPlaceholder.get() )
+                                      pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(),
+                                                                      mpSlidePersistPtr->getShapes()->getChildren() );
+                              }
                               else if ( eShapeLocation == Slide )	// normal slide shapes have to search within the corresponding master tree for referenced objects
                               {
                                   SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
-                                  if ( pMasterPersist.get() )
-                                    pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
-                                pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
+                                  if ( pMasterPersist.get() ) {
+                                      pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
+                                      if ( !pPlaceholder.get() )
+                                          pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
+                                                                          pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
+                                  }
                               }
                               if ( pPlaceholder.get() )
                               {
+                                  OSL_TRACE("shape %s will get shape reference %s applied", rtl::OUStringToOString(mpShapePtr->getId(), RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString(pPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr());
                                   mpShapePtr->applyShapeReference( *pPlaceholder.get() );
                                   PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
                                   if ( pPPTShape )
                                       pPPTShape->setReferenced( sal_True );
-                    pPPTShapePtr->setPlaceholder( pPlaceholder );
+                                  pPPTShapePtr->setPlaceholder( pPlaceholder );
                               }
                           }
                     }


More information about the Libreoffice-commits mailing list