diff options
author | Andre Fischer <af@openoffice.org> | 2010-03-11 18:35:45 +0100 |
---|---|---|
committer | Andre Fischer <af@openoffice.org> | 2010-03-11 18:35:45 +0100 |
commit | ab3853cc3cd60a0c9a98e20d00568fca99bb01dc (patch) | |
tree | bd3829e28957e83e414eb8092e27e035c649ebb2 /sd/source | |
parent | b21a5ef9255b086a639c0d615f104062f92f4ab9 (diff) |
renaissance1: #i107215# Duplicating several slides inserts them in single row after selection.
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/core/drawdoc2.cxx | 34 | ||||
-rw-r--r-- | sd/source/ui/inc/DrawViewShell.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/inc/ViewShell.hxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 41 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx | 16 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/view/viewshe3.cxx | 12 |
10 files changed, 93 insertions, 50 deletions
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index e208399d636f..eb279d639ce8 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -1384,7 +1384,8 @@ USHORT SdDrawDocument::CreatePage ( AutoLayout eStandardLayout, AutoLayout eNotesLayout, BOOL bIsPageBack, - BOOL bIsPageObj) + BOOL bIsPageObj, + const sal_Int32 nInsertPosition) { SdPage* pPreviousStandardPage; SdPage* pPreviousNotesPage; @@ -1452,22 +1453,24 @@ USHORT SdDrawDocument::CreatePage ( pNotesPage->setHeaderFooterSettings( pPreviousNotesPage->getHeaderFooterSettings() ); return InsertPageSet ( - pActualPage, ePageKind, + pActualPage, + ePageKind, sStandardPageName, sNotesPageName, eStandardLayout, eNotesLayout, bIsPageBack, bIsPageObj, - pStandardPage, - pNotesPage); + pNotesPage, + nInsertPosition); } -USHORT SdDrawDocument::DuplicatePage (USHORT nPageNum) +USHORT SdDrawDocument::DuplicatePage ( + const USHORT nPageNum) { PageKind ePageKind = PK_STANDARD; @@ -1503,7 +1506,8 @@ USHORT SdDrawDocument::DuplicatePage ( AutoLayout eStandardLayout, AutoLayout eNotesLayout, BOOL bIsPageBack, - BOOL bIsPageObj) + BOOL bIsPageObj, + const sal_Int32 nInsertPosition) { SdPage* pPreviousStandardPage; SdPage* pPreviousNotesPage; @@ -1530,16 +1534,17 @@ USHORT SdDrawDocument::DuplicatePage ( pNotesPage = (SdPage*) pPreviousNotesPage->Clone(); return InsertPageSet ( - pActualPage, ePageKind, + pActualPage, + ePageKind, sStandardPageName, sNotesPageName, eStandardLayout, eNotesLayout, bIsPageBack, bIsPageObj, - pStandardPage, - pNotesPage); + pNotesPage, + nInsertPosition); } @@ -1554,9 +1559,9 @@ USHORT SdDrawDocument::InsertPageSet ( AutoLayout eNotesLayout, BOOL bIsPageBack, BOOL bIsPageObj, - SdPage* pStandardPage, - SdPage* pNotesPage) + SdPage* pNotesPage, + sal_Int32 nInsertPosition) { SdPage* pPreviousStandardPage; SdPage* pPreviousNotesPage; @@ -1586,13 +1591,16 @@ USHORT SdDrawDocument::InsertPageSet ( eNotesLayout = pPreviousNotesPage->GetAutoLayout(); } + OSL_ASSERT(nNotesPageNum==nStandardPageNum+1); + if (nInsertPosition < 0) + nInsertPosition = nStandardPageNum; // Set up and insert the standard page. SetupNewPage ( pPreviousStandardPage, pStandardPage, aStandardPageName, - nStandardPageNum, + nInsertPosition, bIsPageBack, bIsPageObj); @@ -1602,7 +1610,7 @@ USHORT SdDrawDocument::InsertPageSet ( pPreviousNotesPage, pNotesPage, aNotesPageName, - nNotesPageNum, + nInsertPosition+1, bIsPageBack, bIsPageObj); diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index b9a3e062955b..f22352ab6f71 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -453,7 +453,8 @@ private: virtual SdPage* CreateOrDuplicatePage ( SfxRequest& rRequest, PageKind ePageKind, - SdPage* pPage); + SdPage* pPage, + const sal_Int32 nInsertPosition = -1); ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager > mxScannerManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener; diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index 130f4ed6cbcd..068968f625d9 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -461,6 +461,9 @@ public: This page is either duplicated or becomes the predecessor of the new slide. If NULL a duplication request is ignored. A new slide is inserted as first slide. + @param nInsertPosition + When -1 (the default) then insert after pPage. Otherwise insert + before the given index (of a standard page). @return The new slide is returned. If for some reason a new page can not be created then NULL is returned. @@ -468,7 +471,8 @@ public: virtual SdPage* CreateOrDuplicatePage ( SfxRequest& rRequest, PageKind ePageKind, - SdPage* pPage); + SdPage* pPage, + const sal_Int32 nInsertPosition = -1); class Implementation; diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx index 14e792d8f5cc..252d645168fc 100644 --- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx +++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx @@ -199,9 +199,7 @@ void InsertionIndicatorHandler::SetPosition ( { mpInsertionIndicatorOverlay->SetLocation(maInsertPosition.GetLocation()); - GetInsertAnimator()->SetInsertPosition( - maInsertPosition, - maIconSize); + GetInsertAnimator()->SetInsertPosition(maInsertPosition); mpInsertionIndicatorOverlay->Show(); } else diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index 8880100a918a..c3b4f8f1fe2b 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -1245,9 +1245,9 @@ void SelectionFunction::ProcessButtonClick ( break; case 1: - // Toggle exclusion state. if ( ! rpDescriptor) return; + // Toggle exclusion state. mrSlideSorter.GetController().GetSlotManager()->ChangeSlideExclusionState( (rpDescriptor->HasState(model::PageDescriptor::ST_Selected) ? model::SharedPageDescriptor() @@ -1256,12 +1256,20 @@ void SelectionFunction::ProcessButtonClick ( break; case 0: - // Insert page after current page. - rSelector.DeselectAllPages(); - rSelector.SelectPage(rpDescriptor); + if ( ! rpDescriptor) + return; + // When the page under the button is not selected then set the + // selection to just this page. + if ( ! rpDescriptor->HasState(model::PageDescriptor::ST_Selected)) + { + rSelector.DeselectAllPages(); + rSelector.SelectPage(rpDescriptor); + } + // Duplicate the selected pages. Insert the new pages right + // after the current selection and select them if (mrSlideSorter.GetViewShell() != NULL) mrSlideSorter.GetViewShell()->GetDispatcher()->Execute( - SID_INSERTPAGE, + SID_DUPLICATE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); break; } diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index ee0b542eaf25..7ea11e841a8e 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -1204,6 +1204,7 @@ void SlotManager::DuplicateSelectedSlides (SfxRequest& rRequest) { // Create a list of the pages that are to be duplicated. The process of // duplication alters the selection. + sal_Int32 nInsertPosition (0); ::std::vector<SdPage*> aPagesToDuplicate; model::PageEnumeration aSelectedPages ( model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); @@ -1211,18 +1212,44 @@ void SlotManager::DuplicateSelectedSlides (SfxRequest& rRequest) { model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); if (pDescriptor && pDescriptor->GetPage()) + { aPagesToDuplicate.push_back(pDescriptor->GetPage()); + nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2; + } } + // Duplicate the pages in aPagesToDuplicate and collect the newly + // created pages in aPagesToSelect. + const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled()); + if (bUndo) + mrSlideSorter.GetView().BegUndo(String(SdResId(STR_INSERTPAGE))); + + ::std::vector<SdPage*> aPagesToSelect; + for(::std::vector<SdPage*>::const_iterator + iPage(aPagesToDuplicate.begin()), + iEnd(aPagesToDuplicate.end()); + iPage!=iEnd; + ++iPage, nInsertPosition+=2) + { + aPagesToSelect.push_back( + mrSlideSorter.GetViewShell()->CreateOrDuplicatePage( + rRequest, PK_STANDARD, *iPage, nInsertPosition)); + } + aPagesToDuplicate.clear(); + + if (bUndo) + mrSlideSorter.GetView().EndUndo(); + + // Set the selection to the pages in aPagesToSelect. + PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); + rSelector.DeselectAllPages(); for_each ( - aPagesToDuplicate.begin(), - aPagesToDuplicate.end(), + aPagesToSelect.begin(), + aPagesToSelect.end(), ::boost::bind( - &ViewShell::CreateOrDuplicatePage, - mrSlideSorter.GetViewShell(), - ::boost::ref(rRequest), - PK_STANDARD, - _1)); + static_cast<void (PageSelector::*)(const SdPage*)>(&PageSelector::SelectPage), + rSelector, + _1)); } diff --git a/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx b/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx index 52c88b6e42cf..affe0824bd8c 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx @@ -53,9 +53,7 @@ public: /** Set the position at which we have to make room for the display of an icon. */ - void SetInsertPosition ( - const InsertPosition& rInsertPosition, - const Size& rIconSize); + void SetInsertPosition (const InsertPosition& rInsertPosition); void Reset (void); diff --git a/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx index eb4e36f803bc..2ecf8eab6498 100644 --- a/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx +++ b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx @@ -134,9 +134,7 @@ public: Implementation (SlideSorter& rSlideSorter); virtual ~Implementation (void); - void SetInsertPosition ( - const InsertPosition& rInsertPosition, - const Size& rIconSize); + void SetInsertPosition (const InsertPosition& rInsertPosition); void Reset (void); @@ -176,11 +174,9 @@ InsertAnimator::InsertAnimator (SlideSorter& rSlideSorter) -void InsertAnimator::SetInsertPosition ( - const InsertPosition& rInsertPosition, - const Size& rIconSize) +void InsertAnimator::SetInsertPosition (const InsertPosition& rInsertPosition) { - mpImplementation->SetInsertPosition(rInsertPosition, rIconSize); + mpImplementation->SetInsertPosition(rInsertPosition); } @@ -216,9 +212,7 @@ InsertAnimator::Implementation::~Implementation (void) -void InsertAnimator::Implementation::SetInsertPosition ( - const InsertPosition& rInsertPosition, - const Size& rIconSize) +void InsertAnimator::Implementation::SetInsertPosition (const InsertPosition& rInsertPosition) { if (maInsertPosition == rInsertPosition) return; @@ -250,7 +244,7 @@ void InsertAnimator::Implementation::SetInsertPosition ( void InsertAnimator::Implementation::Reset (void) { - SetInsertPosition(InsertPosition(), Size(0,0)); + SetInsertPosition(InsertPosition()); } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 12b81a01d3ba..6d3fda131a5a 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1009,7 +1009,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdPage* DrawViewShell::CreateOrDuplicatePage ( SfxRequest& rRequest, PageKind ePageKind, - SdPage* pPage) + SdPage* pPage, + const sal_Int32 nInsertPosition) { SdPage* pNewPage = NULL; if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE) @@ -1018,7 +1019,7 @@ SdPage* DrawViewShell::CreateOrDuplicatePage ( { mpDrawView->SdrEndTextEdit(); } - pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage); + pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition); } return pNewPage; } diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx index 86e441939b0e..7eb225db44bb 100644 --- a/sd/source/ui/view/viewshe3.cxx +++ b/sd/source/ui/view/viewshe3.cxx @@ -218,7 +218,8 @@ void ViewShell::GetMenuState( SfxItemSet &rSet ) SdPage* ViewShell::CreateOrDuplicatePage ( SfxRequest& rRequest, PageKind ePageKind, - SdPage* pPage) + SdPage* pPage, + const sal_Int32 nInsertPosition) { USHORT nSId = rRequest.GetSlot(); SdDrawDocument* pDocument = GetDoc(); @@ -358,7 +359,8 @@ SdPage* ViewShell::CreateOrDuplicatePage ( eStandardLayout, eNotesLayout, bIsPageBack, - bIsPageObj); + bIsPageObj, + nInsertPosition); // Select exactly the new page. USHORT nPageCount (pDocument->GetSdPageCount(ePageKind)); for (USHORT i=0; i<nPageCount; i++) @@ -381,7 +383,8 @@ SdPage* ViewShell::CreateOrDuplicatePage ( eStandardLayout, eNotesLayout, bIsPageBack, - bIsPageObj); + bIsPageObj, + nInsertPosition); break; case SID_DUPLICATE_PAGE: @@ -395,7 +398,8 @@ SdPage* ViewShell::CreateOrDuplicatePage ( eStandardLayout, eNotesLayout, bIsPageBack, - bIsPageObj); + bIsPageObj, + nInsertPosition); break; default: |