[Libreoffice-commits] .: 2 commits - sd/source

Radek Doulík rodo at kemper.freedesktop.org
Wed Dec 8 03:09:47 PST 2010


 sd/source/filter/eppt/epptbase.hxx       |    3 
 sd/source/filter/eppt/epptooxml.hxx      |    2 
 sd/source/filter/eppt/pptx-epptbase.cxx  |   11 +-
 sd/source/filter/eppt/pptx-epptooxml.cxx |  156 ++++++++++++++++++++++++++-----
 sd/source/ui/unoidl/unoobj.cxx           |   23 ++++
 sd/source/ui/unoidl/unoobj.hxx           |    1 
 6 files changed, 172 insertions(+), 24 deletions(-)

New commits:
commit dd62b195253b91c5ec9bd993cd8cfb5bfdfb9918
Author: Radek Doulik <rodo at novell.com>
Date:   Wed Dec 8 12:08:16 2010 +0100

    export slide layouts to pptx

diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx
index b0576ee..b24aab1 100644
--- a/sd/source/filter/eppt/epptbase.hxx
+++ b/sd/source/filter/eppt/epptbase.hxx
@@ -86,7 +86,7 @@ struct PHLayout
     BOOL    bSecOutlinerPossible;
 };
 
-enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3 };
+enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
 
 class PropValue
 {
@@ -404,6 +404,7 @@ public:
     PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
     PHLayout& GetLayout( sal_Int32 nOffset ) const;
     sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
+    sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
 
     sal_Bool CreateSlide( sal_uInt32 nPageNum );
     sal_Bool CreateSlideMaster( sal_uInt32 nPageNum );
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 75f9f1c..fd93a3e 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -90,6 +90,7 @@ public:
     static const char* GetSideDirection( sal_uInt8 nDirection );
     static const char* GetCornerDirection( sal_uInt8 nDirection );
     static const char* Get8Direction( sal_uInt8 nDirection );
+    static       int   GetPPTXLayoutId( int nOffset );
 
 protected:
 
@@ -98,6 +99,7 @@ protected:
     virtual void ImplWriteNotes( sal_uInt32 nPageNum );
     virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet );
     virtual void ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum );
+    void ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum );
     void WriteTheme( sal_Int32 nThemeNum );
 
     virtual sal_Bool ImplCreateDocument();
diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx
index 47084b9..a1f4759 100644
--- a/sd/source/filter/eppt/pptx-epptbase.cxx
+++ b/sd/source/filter/eppt/pptx-epptbase.cxx
@@ -453,6 +453,15 @@ sal_Int32 PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference
     if ( GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Layout" ) ) ), sal_True )
         aAny >>= nLayout;
 
+    DBG(printf("GetLayoutOffset %d\n", nLayout));
+
+    return nLayout;
+}
+
+sal_Int32 PPTWriterBase::GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
+{
+    sal_Int32 nLayout = GetLayoutOffset( rXPropSet );
+
     if ( ( nLayout >= 21 ) && ( nLayout <= 26 ) )   // NOTES _> HANDOUT6
         nLayout = 20;
     if ( ( nLayout >= 27 ) && ( nLayout <= 30 ) )   // VERTICAL LAYOUT
@@ -465,7 +474,7 @@ sal_Int32 PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference
 
 PHLayout& PPTWriterBase::GetLayout(  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
 {
-    return pPHLayout[ GetLayoutOffset( rXPropSet ) ];
+    return pPHLayout[ GetLayoutOffsetFixed( rXPropSet ) ];
 }
 
 // ---------------------------------------------------------------------------------------------
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index ff85aac..8f13148 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -121,7 +121,93 @@ public:
     sal_Bool WritePlaceholder( Reference< XShape > xShape, PlaceholderType ePlaceholder, sal_Bool bMaster );
 };
 
-    PowerPointShapeExport::PowerPointShapeExport( FSHelperPtr pFS, ShapeHashMap* pShapeMap, PowerPointExport* pFB )
+enum PPTXLayout {
+    LAYOUT_BLANK,
+    LAYOUT_TITLE_SLIDE,
+    LAYOUT_TITLE_CONTENT,
+    LAYOUT_TITLE_2CONTENT,
+    LAYOUT_TITLE,
+    LAYOUT_CENTERED_TEXT,
+    LAYOUT_TITLE_2CONTENT_CONTENT,
+    LAYOUT_TITLE_CONTENT_2CONTENT,
+    LAYOUT_TITLE_2CONTENT_OVER_CONTENT,
+    LAYOUT_TITLE_CONTENT_OVER_CONTENT,
+    LAYOUT_TITLE_4CONTENT,
+    LAYOUT_TITLE_6CONTENT,
+    LAYOUT_SIZE
+};
+
+struct PPTXLayoutInfo {
+    int nType;
+    const char* sName;
+    const char* sType;
+};
+
+static PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE] = {
+    { 20, "Blank Slide", "blank" },
+    { 0, "Title Slide", "tx" },
+    { 1, "Title, Content", "obj" },
+    { 3, "Title, 2 Content", "twoObj" },
+    { 19, "Title Only", "titleOnly" },
+    { 32, "Centered Text", "objOnly" },                       // not exactly, but close
+    { 15, "Title, 2 Content and Content", "twoObjAndObj" },
+    { 12, "Title Content and 2 Content", "objAndTwoObj" },
+    { 16, "Title, 2 Content over Content", "twoObjOverTx" },      // not exactly, but close
+    { 14, "Title, Content over Content", "objOverTx" },           // not exactly, but close
+    { 18, "Title, 4 Content", "fourObj" },
+    { 33, "Title, 6 Content", "blank" }                           // not defined => blank
+};
+
+int PowerPointExport::GetPPTXLayoutId( int nOffset )
+{
+    int nId = LAYOUT_BLANK;
+
+    DBG(printf("GetPPTXLayoutId %d\n", nOffset));
+
+    switch( nOffset ) {
+        case 0:
+            nId = LAYOUT_TITLE_SLIDE;
+            break;
+        case 1:
+            nId = LAYOUT_TITLE_CONTENT;
+            break;
+        case 3:
+            nId = LAYOUT_TITLE_2CONTENT;
+            break;
+        case 19:
+            nId = LAYOUT_TITLE;
+            break;
+        case 15:
+            nId = LAYOUT_TITLE_2CONTENT_CONTENT;
+            break;
+        case 12:
+            nId = LAYOUT_TITLE_CONTENT_2CONTENT;
+            break;
+        case 16:
+            nId = LAYOUT_TITLE_2CONTENT_OVER_CONTENT;
+            break;
+        case 14:
+            nId = LAYOUT_TITLE_CONTENT_OVER_CONTENT;
+            break;
+        case 18:
+            nId = LAYOUT_TITLE_4CONTENT;
+            break;
+        case 32:
+            nId = LAYOUT_CENTERED_TEXT;
+            break;
+        case 33:
+            nId = LAYOUT_TITLE_6CONTENT;
+            break;
+        case 20:
+        default:
+            nId = LAYOUT_BLANK;
+            break;
+    }
+
+    return nId;
+}
+
+PowerPointShapeExport::PowerPointShapeExport( FSHelperPtr pFS, ShapeHashMap* pShapeMap, PowerPointExport* pFB )
         : ShapeExport( XML_p, pFS, pShapeMap, pFB )
     , mrExport( *pFB )
 {
@@ -1209,7 +1295,7 @@ void PowerPointExport::ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNu
                  US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" ),
                  OUStringBuffer()
                  .appendAscii( "../slideLayouts/slideLayout" )
-                 .append( GetLayoutFileId( GetLayoutOffset( mXPagePropSet ), nMasterNum ) )
+                 .append( GetLayoutFileId( GetPPTXLayoutId( GetLayoutOffset( mXPagePropSet ) ), nMasterNum ) )
                  .appendAscii( ".xml" )
                  .makeStringAndClear() );
 
@@ -1381,7 +1467,7 @@ void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPr
     pFS->startElementNS( XML_p, XML_cSld, FSEND );
 
     ImplWriteBackground( pFS, aXBackgroundPropSet );
-    WriteShapeTree( pFS, MASTER, TRUE );
+    WriteShapeTree( pFS, LAYOUT, TRUE );
 
     pFS->endElementNS( XML_p, XML_cSld );
 
@@ -1405,20 +1491,15 @@ void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPr
     pFS->startElementNS( XML_p, XML_sldLayoutIdLst, FSEND );
 
     int nCount = 0;
-    for( int i = 0; i < EPP_LAYOUT_SIZE; i++) {
-
-    sal_Int32 nLayoutFileId = GetLayoutFileId( i, nPageNum );
-    if( nLayoutFileId > 0 ) {
-        AddLayoutIdAndRelation( pFS, nLayoutFileId );
-        nCount++;
-    }
-    }
-
-    if( nCount == 0 ) {
-    // add at least empty layout, so that we don't have master page
-    // without layout, such master cannot be used in ppt
-    ImplWriteLayout( 0, nPageNum );
-    AddLayoutIdAndRelation( pFS, GetLayoutFileId( 0, nPageNum ) );
+    for( int i = 0; i < LAYOUT_SIZE; i++) {
+        sal_Int32 nLayoutFileId = GetLayoutFileId( i, nPageNum );
+        if( nLayoutFileId > 0 ) {
+            AddLayoutIdAndRelation( pFS, nLayoutFileId );
+            nCount++;
+        } else {
+            ImplWritePPTXLayout( i, nPageNum );
+            AddLayoutIdAndRelation( pFS, GetLayoutFileId( i, nPageNum ) );
+        }
     }
 
     pFS->endElementNS( XML_p, XML_sldLayoutIdLst );
@@ -1430,14 +1511,39 @@ void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPr
 
 sal_Int32 PowerPointExport::GetLayoutFileId( sal_Int32 nOffset, sal_uInt32 nMasterNum )
 {
+    DBG(printf("GetLayoutFileId offset: %d master: %d", nOffset, nMasterNum));
     if( mLayoutInfo[ nOffset ].mnFileIdArray.size() <= nMasterNum )
-    return 0;
+        return 0;
 
     return mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ];
 }
 
 void PowerPointExport::ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum )
 {
+    // we write all the layouts together with master(s)
+    // ImplWritePPTXLayout( GetPPTXLayoutId( nOffset ), nMasterNum );
+}
+
+void PowerPointExport::ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum )
+{
+    DBG(printf("write layout: %d\n", nOffset));
+
+    Reference< drawing::XDrawPagesSupplier > xDPS( getModel(), uno::UNO_QUERY );
+    Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY );
+    Reference< drawing::XDrawPage > xSlide;
+    Reference< container::XIndexAccess > xIndexAccess( xDrawPages, uno::UNO_QUERY );
+
+    xSlide = xDrawPages->insertNewByIndex( xIndexAccess->getCount() );
+    if( xSlide.is() )
+        DBG(printf("new page created\n"));
+
+    Reference< beans::XPropertySet > xPropSet( xSlide, uno::UNO_QUERY );
+    xPropSet->setPropertyValue( US( "Layout" ), makeAny( short( aLayoutInfo[ nOffset ].nType ) ) );
+    dump_pset( xPropSet );
+
+    mXPagePropSet = Reference< XPropertySet >( xSlide, UNO_QUERY );
+    mXShapes = Reference< XShapes >( xSlide, UNO_QUERY );
+
     if( mLayoutInfo[ nOffset ].mnFileIdArray.size() < mnMasterPages ) {
     mLayoutInfo[ nOffset ].mnFileIdArray.resize( mnMasterPages );
     }
@@ -1464,14 +1570,16 @@ void PowerPointExport::ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum
 
     pFS->startElementNS( XML_p, XML_sldLayout,
                          PNMSS,
-                         XML_type, "title",
+                         XML_type, aLayoutInfo[ nOffset ].sType,
                          XML_preserve, "1",
                          FSEND );
 
     pFS->startElementNS( XML_p, XML_cSld,
-                         XML_name, "Title Slide",
+                         XML_name, aLayoutInfo[ nOffset ].sName,
                          FSEND );
-    pFS->write( MINIMAL_SPTREE ); // TODO: write actual shape tree
+    //pFS->write( MINIMAL_SPTREE ); // TODO: write actual shape tree
+    WriteShapeTree( pFS, LAYOUT, TRUE );
+
     pFS->endElementNS( XML_p, XML_cSld );
 
     pFS->endElementNS( XML_p, XML_sldLayout );
@@ -1479,6 +1587,8 @@ void PowerPointExport::ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum
     mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ] = mnLayoutFileIdMax;
 
     mnLayoutFileIdMax ++;
+
+    xDrawPages->remove( xSlide );
 }
 
 void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, sal_Bool bMaster )
@@ -1514,7 +1624,7 @@ void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, sal_
 
 ShapeExport& PowerPointShapeExport::WritePageShape( Reference< XShape > xShape, PageType ePageType, sal_Bool bPresObj )
 {
-    if( ePageType == NOTICE && bPresObj )
+    if( ( ePageType == NOTICE && bPresObj ) || ePageType == LAYOUT )
     return WritePlaceholderShape( xShape, SlideImage );
 
     return WriteTextShape( xShape );
@@ -1522,6 +1632,7 @@ ShapeExport& PowerPointShapeExport::WritePageShape( Reference< XShape > xShape,
 
 sal_Bool PowerPointShapeExport::WritePlaceholder( Reference< XShape > xShape, PlaceholderType ePlaceholder, sal_Bool bMaster )
 {
+    DBG(printf("WritePlaceholder %d %d\n", bMaster, ShapeExport::NonEmptyText( xShape )));
     if( bMaster && ShapeExport::NonEmptyText( xShape ) ) {
     WritePlaceholderShape( xShape, ePlaceholder );
 
@@ -1575,6 +1686,7 @@ ShapeExport& PowerPointShapeExport::WritePlaceholderShape( Reference< XShape > x
     default:
         DBG(printf("warning: unhandled placeholder type: %d\n", ePlaceholder));
     }
+    DBG(printf("write placeholder %s\n", pType));
     mpFS->singleElementNS( XML_p, XML_ph, XML_type, pType, FSEND );
     mpFS->endElementNS( XML_p, XML_nvPr );
     mpFS->endElementNS( XML_p, XML_nvSpPr );
commit 85cc7564e834bc8f65c90b51ade26bffaecc10ba
Author: Radek Doulik <rodo at novell.com>
Date:   Wed Dec 8 12:06:11 2010 +0100

    add placeholder text to XShape properties

diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index e666329..b51c7e7 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -144,6 +144,7 @@ static SdTypesCache gImplTypesCache;
 
 #define WID_THAT_NEED_ANIMINFO 19
 
+#define WID_PLACEHOLDERTEXT 24
 
 
         #define IMPRESS_MAP_ENTRIES \
@@ -168,6 +169,7 @@ static SdTypesCache gImplTypesCache;
         { MAP_CHAR_LEN(UNO_NAME_OBJ_VERB),			WID_VERB,			 &::getCppuType((const sal_Int32*)0),						0, 0},\
         { MAP_CHAR_LEN("IsAnimation"),				WID_ISANIMATION,	 &::getBooleanCppuType(),									0, 0},\
         { MAP_CHAR_LEN("NavigationOrder"),			WID_NAVORDER,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
+        { MAP_CHAR_LEN("PlaceholderText"),	        WID_PLACEHOLDERTEXT, &::getCppuType((const OUString*)0),						0, 0},\
         { 0,0,0,0,0,0}
 
 
@@ -777,6 +779,9 @@ void SAL_CALL SdXShape::setPropertyValue( const ::rtl::OUString& aPropertyName,
         case WID_ISANIMATION:
             aRet <<= (sal_Bool)( pInfo && pInfo->mbIsMovie);
             break;
+        case WID_PLACEHOLDERTEXT:
+            aRet <<= GetPlaceholderText();
+            break;
         case WID_BOOKMARK:
         {
             OUString aString;
@@ -965,6 +970,24 @@ sal_Bool SdXShape::IsEmptyPresObj() const throw()
     return sal_False;
 }
 
+OUString SdXShape::GetPlaceholderText() const
+{
+    // only possible if this actually *is* a presentation object
+    if( !IsPresObj() )
+        return OUString();
+
+    SdrObject* pObj = mpShape->GetSdrObject();
+    if( pObj == NULL )
+        return OUString();
+
+    SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
+    DBG_ASSERT( pPage, "no page?" );
+    if( pPage == NULL )
+        return OUString();
+
+    return pPage->GetPresObjText( pPage->GetPresObjKind(pObj) );
+ }
+
 /** sets/reset the empty status of a presentation object
 */
 void SdXShape::SetEmptyPresObj( sal_Bool bEmpty ) throw()
diff --git a/sd/source/ui/unoidl/unoobj.hxx b/sd/source/ui/unoidl/unoobj.hxx
index c32da8d..809a985 100644
--- a/sd/source/ui/unoidl/unoobj.hxx
+++ b/sd/source/ui/unoidl/unoobj.hxx
@@ -72,6 +72,7 @@ private:
     void SetMasterDepend( sal_Bool bDepend ) throw();
 
     SdrObject* GetSdrObject() const throw();
+    ::rtl::OUString GetPlaceholderText() const;
 
     com::sun::star::uno::Sequence< sal_Int8 >* mpImplementationId;
 


More information about the Libreoffice-commits mailing list