diff options
-rw-r--r-- | sd/inc/drawdoc.hxx | 57 | ||||
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 313 | ||||
-rw-r--r-- | sd/source/core/pglink.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/app/sdxfer.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/view/sdview3.cxx | 8 |
6 files changed, 253 insertions, 143 deletions
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index cf1060471b36..a97d7d129056 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: drawdoc.hxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: af $ $Date: 2002-11-04 14:37:13 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -210,6 +210,8 @@ protected: public: + class InsertBookmarkAsPage_PageFunctorBase; + TYPEINFO(); SdDrawDocument(DocumentType eType, SfxObjectShell* pDocSh); @@ -261,13 +263,62 @@ public: BOOL bReplace, USHORT nPgPos, BOOL bNoDialogs, SdDrawDocShell* pBookmarkDocSh, BOOL bCopy, Point* pObjPos); + /** Insert pages into this document + + This method inserts whole pages into this document, either + selected ones (specified via pBookmarkList/pExchangeList), or + all from the source document. + + @attention Beware! This method in it's current state does not + handle all combinations of their input parameters + correctly. For example, for pBookmarkList=NULL, bReplace=TRUE + is ignored (no replace happens). + + @param pBookmarkList + A list of strings, denoting the names of the pages to be copied + + @param pExchangeList + A list of strings, denoting the names of the pages to be renamed + + @param bLink + Whether the inserted pages should be links to the bookmark document + + @param bReplace + Whether the pages should not be inserted, but replace the pages in + the destination document + + @param nPgPos + Insertion point/start of replacement + + @param bNoDialogs + Whether query dialogs are allowed (e.g. for page scaling) + + @param pBookmarkDocSh + DocShell of the source document (used e.g. to extract the filename + for linked pages) + + @param bCopy + Whether the source document should be treated as immutable (i.e. + inserted pages are not removed from it, but cloned) + + @param bMergeMasterPages + Whether the source document's master pages should be copied, too. + + @param bPreservePageNames + Whether the replace operation should take the name from the new + page, or preserve the old name + */ BOOL InsertBookmarkAsPage(List* pBookmarkList, List* pExchangeList, BOOL bLink, BOOL bReplace, USHORT nPgPos, BOOL bNoDialogs, SdDrawDocShell* pBookmarkDocSh, - BOOL bCopy, BOOL bMergeMasterPages); + BOOL bCopy, BOOL bMergeMasterPages, + BOOL bPreservePageNames); BOOL InsertBookmarkAsObject(List* pBookmarkList, List* pExchangeListL, BOOL bLink, SdDrawDocShell* pBookmarkDocSh, Point* pObjPos); + void IterateBookmarkPages( SdDrawDocument* pBookmarkDoc, List* pBookmarkList, + USHORT nBMSdPageCount, + InsertBookmarkAsPage_PageFunctorBase& rPageIterator ); void CloseBookmarkDoc(); SdrObject* GetObj(const String& rObjName) const; diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index e1393b406a49..fdd79bd0f698 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -2,9 +2,9 @@ * * $RCSfile: drawdoc3.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: iha $ $Date: 2002-11-11 17:23:34 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,9 @@ * ************************************************************************/ +#include <utility> +#include <algorithm> + #ifndef _SV_WRKWIN_HXX #include <vcl/wrkwin.hxx> #endif @@ -343,7 +346,7 @@ BOOL SdDrawDocument::InsertBookmark( { // Zuerst werden alle Seiten-Bookmarks eingefuegt bOK = InsertBookmarkAsPage(pBookmarkList, pExchangeList, bLink, bReplace, - nInsertPos, bNoDialogs, pBookmarkDocSh, bCopy, TRUE); + nInsertPos, bNoDialogs, pBookmarkDocSh, bCopy, TRUE, FALSE); } if ( bOK && pBookmarkList ) @@ -362,6 +365,142 @@ BOOL SdDrawDocument::InsertBookmark( |* \************************************************************************/ +/** Concrete incarnations get called by IterateBookmarkPages, for + every page in the bookmark document/list + */ +class SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase +{ +public: + virtual ~InsertBookmarkAsPage_PageFunctorBase() = 0 {}; + virtual void operator()( SdDrawDocument&, SdPage* ) = 0; +}; + +void SdDrawDocument::IterateBookmarkPages( SdDrawDocument* pBookmarkDoc, List* pBookmarkList, USHORT nBMSdPageCount, + SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase& rPageIterator ) +{ + // + // #96029# Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage + // + int nPos, nEndPos; + + if( !pBookmarkList ) + { + // no list? whole source document + nEndPos = nBMSdPageCount; + } + else + { + // bookmark list? number of entries + nEndPos = pBookmarkList->Count(); + } + + SdPage* pBMPage; + + // iterate over number of pages to insert + for (nPos = 0; nPos < nEndPos; ++nPos) + { + // the master page associated to the nPos'th page to insert + SdPage* pBMMPage = NULL; + + if( !pBookmarkList ) + { + // simply take master page of nPos'th page in source document + pBMMPage = (SdPage*) pBookmarkDoc-> + GetSdPage(nPos, PK_STANDARD)->GetMasterPage(0); + } + else + { + // fetch nPos'th entry from bookmark list, and determine master page + String aBMPgName (*(String*) pBookmarkList->GetObject(nPos)); + BOOL bIsMasterPage; + + USHORT nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage ); + + if (nBMPage != SDRPAGE_NOTFOUND) + { + pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage); + } + else + { + pBMPage = NULL; + } + + // enforce that bookmarked page is a standard page and not already a master page + if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage()) + { + const USHORT nBMSdPage = (nBMPage - 1) / 2; + + pBMMPage = (SdPage*) pBookmarkDoc-> + GetSdPage(nBMSdPage, PK_STANDARD)->GetMasterPage(0); + } + } + + // successfully determined valid (bookmarked) page? + if( pBMMPage ) + { + // yes, call functor + rPageIterator( *this, pBMMPage ); + } + } +} + +class InsertBookmarkAsPage_FindDuplicateLayouts : public SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase +{ +public: + InsertBookmarkAsPage_FindDuplicateLayouts( List* pLayoutsToTransfer, SdDrawDocument* pBookmarkDoc, + List* pBookmarkList, USHORT nBMSdPageCount ) : + mpLayoutsToTransfer(pLayoutsToTransfer), mpBookmarkDoc(pBookmarkDoc), + mpBookmarkList(pBookmarkList), mnBMSdPageCount(nBMSdPageCount) {} + virtual ~InsertBookmarkAsPage_FindDuplicateLayouts() {}; + virtual void operator()( SdDrawDocument&, SdPage* ); +private: + List* mpLayoutsToTransfer; + SdDrawDocument* mpBookmarkDoc; + List* mpBookmarkList; + USHORT mnBMSdPageCount; +}; + +void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage ) +{ + // now check for duplicate masterpage and layout names + // =================================================== + + String sFullLayoutName( pBMMPage->GetLayoutName() ); + String* pLayout = new String(sFullLayoutName); + pLayout->Erase( pLayout->SearchAscii( SD_LT_SEPARATOR )); + + String* pTest = (String*) mpLayoutsToTransfer->First(); + BOOL bFound = FALSE; + + while (pTest && !bFound) // found yet? + { + if (*pLayout == *pTest) + bFound = TRUE; + else + pTest = (String*)mpLayoutsToTransfer->Next(); + } + + const USHORT nMPageCount = rDoc.GetMasterPageCount(); + for (USHORT nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++) + { + /************************************************************** + * Gibt es die Layouts schon im Dokument? + **************************************************************/ + SdPage* pTest = (SdPage*) rDoc.GetMasterPage(nMPage); + String aTest(pTest->GetLayoutName()); + aTest.Erase( aTest.SearchAscii( SD_LT_SEPARATOR )); + + if (aTest == *pLayout) + bFound = TRUE; + } + + if (!bFound) + mpLayoutsToTransfer->Insert(pLayout, LIST_APPEND); + else + delete pLayout; +} + + BOOL SdDrawDocument::InsertBookmarkAsPage( List* pBookmarkList, List* pExchangeList, // Liste der zu verwendenen Namen @@ -371,7 +510,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( BOOL bNoDialogs, SdDrawDocShell* pBookmarkDocSh, BOOL bCopy, - BOOL bMergeMasterPages) + BOOL bMergeMasterPages, + BOOL bPreservePageNames) { BOOL bOK = TRUE; BOOL bContinue = TRUE; @@ -400,9 +540,9 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( return FALSE; } - USHORT nSdPageCount = GetSdPageCount(PK_STANDARD); - USHORT nBMSdPageCount = pBookmarkDoc->GetSdPageCount(PK_STANDARD); - USHORT nMPageCount = GetMasterPageCount(); + const USHORT nSdPageCount = GetSdPageCount(PK_STANDARD); + const USHORT nBMSdPageCount = pBookmarkDoc->GetSdPageCount(PK_STANDARD); + const USHORT nMPageCount = GetMasterPageCount(); if (nSdPageCount==0 || nBMSdPageCount==0 || nMPageCount==0) { @@ -441,133 +581,28 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( } } + /************************************************************************** |* Die benoetigten Praesentations-StyleSheets ermitteln und vor |* den Seiten transferieren, sonst verlieren die Textobjekte |* beim Transfer den Bezug zur Vorlage \*************************************************************************/ - SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager(); - pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_INSERTPAGES)), String()); - - List* pLayoutsToTransfer = new List; - USHORT nBMSdPage; - - if (!pBookmarkList) + SfxUndoManager* pUndoMgr = NULL; + if( pDocSh ) { - /********************************************************************** - * Alle Seiten sollen einfuegt werden: Layouts pruefen - **********************************************************************/ - - for (nBMSdPage = 0; nBMSdPage < nBMSdPageCount; nBMSdPage++) - { - /************************************************************** - * Welche Layouts gibt im Bookmark-Dokument? - **************************************************************/ - SdPage* pBMMPage = (SdPage*) pBookmarkDoc-> - GetSdPage(nBMSdPage, PK_STANDARD)->GetMasterPage(0); - String* pLayout = new String(pBMMPage->GetLayoutName()); - pLayout->Erase( pLayout->SearchAscii( SD_LT_SEPARATOR )); - - String* pTest = (String*) pLayoutsToTransfer->First(); - BOOL bFound = FALSE; - - while (pTest && !bFound) // schon gefunden? - { - if (*pLayout == *pTest) - bFound = TRUE; - else - pTest = (String*)pLayoutsToTransfer->Next(); - } - - for (USHORT nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++) - { - /************************************************************** - * Gibt es die Layouts schon im Dokument? - **************************************************************/ - SdPage* pTest = (SdPage*) GetMasterPage(nMPage); - String aTest(pTest->GetLayoutName()); - aTest.Erase( aTest.SearchAscii( SD_LT_SEPARATOR )); - - if (aTest == *pLayout) - bFound = TRUE; - } - - if (!bFound) - pLayoutsToTransfer->Insert(pLayout, LIST_APPEND); - else - delete pLayout; - } + pUndoMgr = pDocSh->GetUndoManager(); + pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_INSERTPAGES)), String()); } - else - { - /********************************************************************** - * Ausgewaehlte Seiten sollen einfuegt werden: Layouts pruefen - **********************************************************************/ - - SdPage* pBMPage; - - for (USHORT nPos = 0; nPos < pBookmarkList->Count(); nPos++) - { - /****************************************************************** - * Namen der Bookmark-Seiten aus Liste holen - ******************************************************************/ - String aBMPgName (*(String*) pBookmarkList->GetObject(nPos)); - BOOL bIsMasterPage; - - USHORT nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage ); - if (nBMPage != SDRPAGE_NOTFOUND) - { - pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage); - } - else - { - pBMPage = NULL; - } - - if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage()) - { - /************************************************************** - * Es muss eine StandardSeite sein - **************************************************************/ - USHORT nBMSdPage = (nBMPage - 1) / 2; - - SdPage* pMPage = (SdPage*) pBookmarkDoc-> - GetSdPage(nBMSdPage, PK_STANDARD)->GetMasterPage(0); - String* pLayout = new String(pMPage->GetLayoutName()); - pLayout->Erase( pLayout->SearchAscii( SD_LT_SEPARATOR )); - - String* pTest = (String*) pLayoutsToTransfer->First(); - BOOL bFound = FALSE; - - while (pTest && !bFound) // schon gefunden? - { - if (*pLayout == *pTest) - bFound = TRUE; - else - pTest = (String*)pLayoutsToTransfer->Next(); - } + List* pLayoutsToTransfer = new List; - for (USHORT nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++) - { - /********************************************************** - * Gibt es die Layouts schon im Dokument? - **********************************************************/ - SdPage* pTest = (SdPage*) GetMasterPage(nMPage); - String aTest(pTest->GetLayoutName()); - aTest.Erase( aTest.SearchAscii( SD_LT_SEPARATOR )); - - if (aTest == *pLayout) - bFound = TRUE; - } + // + // #96029# Refactored copy'n'pasted layout name collection into IterateBookmarkPages + // + InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( pLayoutsToTransfer, pBookmarkDoc, + pBookmarkList, nBMSdPageCount ); + IterateBookmarkPages( pBookmarkDoc, pBookmarkList, nBMSdPageCount, aSearchFunctor ); - if (!bFound) - pLayoutsToTransfer->Insert(pLayout, LIST_APPEND); - else - delete pLayout; - } - } - } /************************************************************************** * Die tatsaechlich benoetigten Vorlagen kopieren @@ -590,9 +625,12 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( if (pCreatedStyles->Count() > 0) { - SdMoveStyleSheetsUndoAction* pMovStyles = - new SdMoveStyleSheetsUndoAction(this, pCreatedStyles, TRUE); - pUndoMgr->AddUndoAction(pMovStyles); + if( pUndoMgr ) + { + SdMoveStyleSheetsUndoAction* pMovStyles = + new SdMoveStyleSheetsUndoAction(this, pCreatedStyles, TRUE); + pUndoMgr->AddUndoAction(pMovStyles); + } } else { @@ -770,6 +808,13 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( if (pStandardPage) { + if( bPreservePageNames ) + { + // #96029# Take old slide names for inserted pages + SdPage* pPage = (SdPage*) GetPage(nActualInsertPos); + pPage->SetName( pStandardPage->GetName() ); + } + AddUndo(new SdrUndoDelPage(*pStandardPage)); RemovePage(nActualInsertPos+2); } @@ -778,6 +823,13 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( if (pNotesPage) { + if( bPreservePageNames ) + { + // #96029# Take old slide names for inserted pages + SdPage* pNotesPage = (SdPage*) GetPage(nActualInsertPos+1); + pNotesPage->SetName( pStandardPage->GetName() ); + } + AddUndo(new SdrUndoDelPage(*pNotesPage)); RemovePage(nActualInsertPos+2); } @@ -790,6 +842,7 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( } } + /************************************************************************** |* Dabei sind evtl. zu viele Masterpages ruebergekommen, da die |* DrawingEngine gleiche Praesentationslayouts nicht erkennen kann. @@ -809,6 +862,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( { SdPage* pTest = (SdPage*) GetMasterPage(nTest); String aTest(pTest->GetLayoutName()); + + // #96029# nInsertPos > 2 is always true when inserting into non-empty models if ( nInsertPos > 2 && aTest == aMPLayout && eKind == pTest->GetPageKind() ) @@ -821,6 +876,7 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( } } + // #96029# nInsertPos > 2 is always true when inserting into non-empty models if (nInsertPos > 2) { /********************************************************************** @@ -887,6 +943,7 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( String aLayout(pPage->GetLayoutName()); aLayout.Erase(aLayout.SearchAscii( SD_LT_SEPARATOR )); + // update layout and referred master page pPage->SetPresentationLayout(aLayout); if (bScaleObjects) @@ -899,6 +956,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage( pPage->SetOrientation( eOrient ); pPage = GetSdPage(nSdPage, PK_NOTES); + + // update layout and referred master page pPage->SetPresentationLayout(aLayout); if (bScaleObjects) diff --git a/sd/source/core/pglink.cxx b/sd/source/core/pglink.cxx index c8a47e0c0d9f..2ffcaacce609 100644 --- a/sd/source/core/pglink.cxx +++ b/sd/source/core/pglink.cxx @@ -2,9 +2,9 @@ * * $RCSfile: pglink.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ka $ $Date: 2001-10-22 13:36:37 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -153,7 +153,7 @@ void SdPageLink::DataChanged( const String& , } pDoc->InsertBookmarkAsPage(&aBookmarkList, NULL, bLink, bReplace, - nInsertPos, bNoDialogs, NULL, bCopy, TRUE); + nInsertPos, bNoDialogs, NULL, bCopy, TRUE, TRUE); if( !pDoc->pDocLockedInsertingLinks ) pDoc->CloseBookmarkDoc(); diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index c10e920f6f86..1e682a6109dd 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxfer.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.26 $ * - * last change: $Author: cl $ $Date: 2002-11-19 17:22:22 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -686,7 +686,7 @@ void SdTransferable::SetPageBookmarks( const List& rPageBookmarks, BOOL bPersist if( bPersistent ) { pSdDrawDocument->CreateFirstPages(); - pSdDrawDocument->InsertBookmarkAsPage( const_cast< List* >( &rPageBookmarks ), NULL, FALSE, TRUE, 1, TRUE, pSourceDoc->GetDocSh(), TRUE, TRUE ); + pSdDrawDocument->InsertBookmarkAsPage( const_cast< List* >( &rPageBookmarks ), NULL, FALSE, TRUE, 1, TRUE, pSourceDoc->GetDocSh(), TRUE, TRUE, FALSE ); } else { diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 0e89f1332df4..ff4f81e09f9e 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fuinsfil.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: cl $ $Date: 2002-11-06 12:50:26 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -486,7 +486,7 @@ BOOL FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) if( bNameOK ) bOK = pDoc->InsertBookmarkAsPage( pBookmarkList, pExchangeList, bLink, bReplace, nPos, - FALSE, NULL, TRUE, TRUE ); + FALSE, NULL, TRUE, TRUE, FALSE ); // Loeschen der BookmarkList if( pBookmarkList ) diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 69329bd572dc..386a54c583fd 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdview3.cxx,v $ * - * $Revision: 1.44 $ + * $Revision: 1.45 $ * - * last change: $Author: ka $ $Date: 2002-10-20 07:08:42 $ + * last change: $Author: thb $ $Date: 2002-11-19 18:02:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -322,7 +322,7 @@ BOOL SdView::InsertData( const TransferableDataHelper& rDataHelper, nInsertPgCnt = (USHORT) rBookmarkList.Count(); pDoc->InsertBookmarkAsPage( const_cast< List* >( &rBookmarkList ), NULL, FALSE, FALSE, nInsertPos, pOwnData == SD_MOD()->pTransferDrag, - pOwnData->GetPageDocShell(), TRUE, bMergeMasterPages ); + pOwnData->GetPageDocShell(), TRUE, bMergeMasterPages, FALSE ); if( bWait ) pWin->EnterWait(); @@ -344,7 +344,7 @@ BOOL SdView::InsertData( const TransferableDataHelper& rDataHelper, nInsertPgCnt = pDataDoc->GetSdPageCount( PK_STANDARD ); pDoc->InsertBookmarkAsPage( NULL, NULL, FALSE, FALSE, nInsertPos, pOwnData == SD_MOD()->pTransferDrag, - pDataDocSh, TRUE, bMergeMasterPages ); + pDataDocSh, TRUE, bMergeMasterPages, FALSE ); if( bWait ) pWin->EnterWait(); |