[Libreoffice-commits] core.git: filter/source

nd101 (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 26 16:54:53 UTC 2020


 filter/source/msfilter/svdfppt.cxx |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

New commits:
commit f1b5e0422b421de39c9fee9a87b6fceee8e48bbd
Author:     nd101 <Fong at nd.com.cn>
AuthorDate: Thu Mar 12 12:07:56 2020 +0800
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Nov 26 17:54:03 2020 +0100

    tdf#131269 - fix importing PPT with different notes/presentations order
    
    Normal PPT has the order of master-presentation-note slides. But for
    certain PPT document, the order is master-note-presentation.
    This fix is to change the importing of page list for those documents
    with different structure.
    
    Change-Id: I2d682a30a3550a6182fcfff7f71f4993ca27a5f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90362
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 36e58f2438f1..09e69e9fcb6a 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1509,12 +1509,21 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
 
             DffRecordHeader* pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText );
             PptSlidePersistEntry* pPreviousPersist = nullptr;
+            DffRecordHeader* pSlideListHd = aDocRecManager.GetRecordHeader(PPT_PST_List);
+            sal_uLong nPSTList = 0;
+            if (pSlideListHd) nPSTList = pSlideListHd->GetRecBegFilePos();
+            sal_uInt16 nRealPageNum = 0;
+            // Normal PPT document has order of Master slides - Presentation slides - Note slides
+            // for document with the order of Master slides - Note slides - Presentation slides
+            // we need to swap the later two sections
+            bool notePresentationSwap = false;
             for (sal_uInt16 nPageListNum = 0;
                  pSlideListWithTextHd && nPageListNum < 3; ++nPageListNum)
             {
                 pSlideListWithTextHd->SeekToContent( rStCtrl );
-                PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) );
+                PptSlidePersistList* pPageList = nullptr;
                 sal_uInt32 nSlideListWithTextHdEndOffset = pSlideListWithTextHd->GetRecEndFilePos();
+                nRealPageNum = nPageListNum;
                 while ( SeekToRec( rStCtrl, PPT_PST_SlidePersistAtom, nSlideListWithTextHdEndOffset ) )
                 {
                     if ( pPreviousPersist )
@@ -1522,8 +1531,23 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
                     std::unique_ptr<PptSlidePersistEntry> pE2(new PptSlidePersistEntry);
                     ReadPptSlidePersistAtom( rStCtrl, pE2->aPersistAtom );
                     pE2->nSlidePersistStartOffset = rStCtrl.Tell();
-                    pE2->ePageKind = PptPageKind( nPageListNum );
+                    // Note/Presentation section swap
+                    if (nPageListNum == 1 && pE2->nSlidePersistStartOffset < nPSTList)
+                    {
+                        notePresentationSwap = true;
+                    }
+                    if (notePresentationSwap)
+                    {
+                        if (nPageListNum == 1) nRealPageNum = 2;
+                        else if (nPageListNum == 2) nRealPageNum = 1;
+                    }
+
+                    pE2->ePageKind = PptPageKind(nRealPageNum);
                     pPreviousPersist = pE2.get();
+                    if (!pPageList)
+                    {
+                        pPageList = GetPageList(PptPageKind(nRealPageNum));
+                    }
                     pPageList->push_back(std::move(pE2));
                 }
                 if ( pPreviousPersist )


More information about the Libreoffice-commits mailing list