LibreOffice Module sd (master) 1
|
The model of the slide sorter gives access to the slides that are to be displayed in the slide sorter view. More...
#include <SlideSorterModel.hxx>
Public Member Functions | |
SlideSorterModel (SlideSorter &rSlideSorter) | |
~SlideSorterModel () | |
void | Dispose () |
SdDrawDocument * | GetDocument () |
This method is present to let the view create a ShowView for displaying slides. More... | |
bool | SetEditMode (EditMode eEditMode) |
Set a new edit mode and return whether the edit mode really has been changed. More... | |
EditMode | GetEditMode () const |
sal_Int32 | GetPageCount () const |
Return the number of slides in the document regardless of whether they are visible or not or whether they are hidden or not. More... | |
SharedPageDescriptor | GetPageDescriptor (const sal_Int32 nPageIndex, const bool bCreate=true) const |
Return a page descriptor for the page with the specified index. More... | |
sal_Int32 | GetIndex (const css::uno::Reference< css::drawing::XDrawPage > &rxSlide) const |
Return a page descriptor for the given XDrawPage. More... | |
sal_Int32 | GetIndex (const SdrPage *pPage) const |
Return a page descriptor for the given SdrPage. More... | |
sal_uInt16 | GetCoreIndex (const sal_Int32 nIndex) const |
Return an index for accessing an SdrModel that corresponds to the given SlideSorterModel index. More... | |
void | Resync () |
Call this method after the document has changed its structure. More... | |
void | ClearDescriptorList () |
Delete all descriptors that currently are in the container. More... | |
void | SynchronizeDocumentSelection () |
Set the selection of the document to exactly that of the called model. More... | |
void | SynchronizeModelSelection () |
Set the selection of the called model to exactly that of the document. More... | |
::osl::Mutex & | GetMutex () |
Return the mutex so that the caller can lock it and then safely access the model. More... | |
void | SetDocumentSlides (const css::uno::Reference< css::container::XIndexAccess > &rxSlides) |
Set the XIndexAccess from which the called SlideSorterModel takes its pages. More... | |
css::uno::Reference< css::container::XIndexAccess > | GetDocumentSlides () const |
Return the set of pages that is currently displayed by the slide sorter. More... | |
void | UpdatePageList () |
This method is called when the edit mode has changed. More... | |
bool | IsReadOnly () const |
void | SaveCurrentSelection () |
The current selection is saved by copying the ST_Selected state into ST_WasSelected for slides. More... | |
vcl::Region | RestoreSelection () |
The current selection is restored from the ST_WasSelected state from the slides. More... | |
bool | NotifyPageEvent (const SdrPage *pPage) |
Typically called from controller::Listener this method handles the insertion and deletion of single pages. More... | |
Private Member Functions | |
void | AdaptSize () |
Resize the descriptor container according to current values of page kind and edit mode. More... | |
SdPage * | GetPage (const sal_Int32 nCoreIndex) const |
void | InsertSlide (SdPage *pPage, bool bMarkSelected) |
bool | DeleteSlide (const SdPage *pPage) |
void | UpdateIndices (const sal_Int32 nFirstIndex) |
Private Attributes | |
mutable::osl::Mutex | maMutex |
SlideSorter & | mrSlideSorter |
css::uno::Reference< css::container::XIndexAccess > | mxSlides |
EditMode | meEditMode |
mutable ::std::vector< SharedPageDescriptor > | maPageDescriptors |
The model of the slide sorter gives access to the slides that are to be displayed in the slide sorter view.
Via the SetDocumentSlides() method this set of slides can be modified (but do not call it directly, use SlideSorterController::SetDocumentSlides() instead.)
Definition at line 54 of file SlideSorterModel.hxx.
sd::slidesorter::model::SlideSorterModel::SlideSorterModel | ( | SlideSorter & | rSlideSorter | ) |
Definition at line 120 of file SlideSorterModel.cxx.
References Page.
sd::slidesorter::model::SlideSorterModel::~SlideSorterModel | ( | ) |
Definition at line 127 of file SlideSorterModel.cxx.
References ClearDescriptorList().
|
private |
Resize the descriptor container according to current values of page kind and edit mode.
Definition at line 487 of file SlideSorterModel.cxx.
References maPageDescriptors, and mxSlides.
Referenced by Resync(), and SetDocumentSlides().
void sd::slidesorter::model::SlideSorterModel::ClearDescriptorList | ( | ) |
Delete all descriptors that currently are in the container.
The size of the container, however, is not altered. Use the AdaptSize method for that.
Definition at line 327 of file SlideSorterModel.cxx.
References maMutex, maPageDescriptors, and SAL_INFO.
Referenced by Dispose(), Resync(), SetDocumentSlides(), and ~SlideSorterModel().
|
private |
Definition at line 595 of file SlideSorterModel.cxx.
References GetIndex(), GetPage(), SdrPage::IsInserted(), o3tl::make_unsigned(), maPageDescriptors, nIndex, sd::slidesorter::model::PageDescriptor::ST_Selected, and UpdateIndices().
Referenced by NotifyPageEvent().
void sd::slidesorter::model::SlideSorterModel::Dispose | ( | ) |
Definition at line 132 of file SlideSorterModel.cxx.
References ClearDescriptorList().
sal_uInt16 sd::slidesorter::model::SlideSorterModel::GetCoreIndex | ( | const sal_Int32 | nIndex | ) | const |
Return an index for accessing an SdrModel that corresponds to the given SlideSorterModel index.
In many cases we just have to apply the n*2+1 magic. Only when a special model is set, like a custom slide show, then the returned value is different.
Definition at line 274 of file SlideSorterModel.cxx.
References GetPageDescriptor(), mxSlides, and nIndex.
Referenced by sd::slidesorter::controller::Clipboard::DetermineInsertPosition(), and sd::slidesorter::controller::Clipboard::PasteTransferable().
SdDrawDocument * sd::slidesorter::model::SlideSorterModel::GetDocument | ( | ) |
This method is present to let the view create a ShowView for displaying slides.
Definition at line 137 of file SlideSorterModel.cxx.
References sd::ViewShellBase::GetDocument(), sd::slidesorter::SlideSorter::GetViewShellBase(), and mrSlideSorter.
Referenced by sd::slidesorter::controller::Clipboard::AcceptDrop(), sd::slidesorter::controller::SlotManager::ChangeSlideExclusionState(), accessibility::AccessibleSlideSorterView::Implementation::ConnectListeners(), sd::slidesorter::controller::Clipboard::CreateSlideTransferable(), sd::slidesorter::controller::Clipboard::CreateTransferableUserData(), sd::slidesorter::controller::SelectionManager::DeleteSelectedMasterPages(), sd::slidesorter::controller::SelectionManager::DeleteSelectedNormalPages(), sd::slidesorter::controller::SlotManager::ExecCtrl(), sd::slidesorter::controller::Clipboard::ExecuteDrop(), sd::slidesorter::controller::SlotManager::FuSupport(), sd::slidesorter::controller::SlotManager::FuTemporary(), sd::slidesorter::controller::SlotManager::GetClipboardState(), sd::slidesorter::controller::SlotManager::GetMenuState(), sd::slidesorter::view::ViewCacheContext::GetModel(), GetPage(), sd::slidesorter::controller::SlotManager::GetStatusBarState(), sd::slidesorter::controller::SlideSorterController::HandleModelChange(), sd::slidesorter::controller::Listener::HandleModelChange(), sd::slidesorter::controller::Listener::HandleShapeModification(), sd::slidesorter::controller::SlideSorterController::Init(), sd::slidesorter::controller::SlotManager::InsertSlide(), sd::slidesorter::controller::Listener::Listener(), sd::slidesorter::controller::Listener::Notify(), sd::slidesorter::controller::Clipboard::PasteTransferable(), accessibility::AccessibleSlideSorterView::Implementation::ReleaseListeners(), sd::slidesorter::controller::Listener::ReleaseListeners(), sd::slidesorter::controller::SlotManager::RenameSlideFromDrawViewShell(), Resync(), and sd::slidesorter::controller::SelectionFunction::ModeHandler::SwitchView().
Reference< container::XIndexAccess > sd::slidesorter::model::SlideSorterModel::GetDocumentSlides | ( | ) | const |
Return the set of pages that is currently displayed by the slide sorter.
Definition at line 437 of file SlideSorterModel.cxx.
References maMutex, and mxSlides.
Referenced by sd::slidesorter::controller::SlideSorterController::SetDocumentSlides().
|
inline |
Definition at line 78 of file SlideSorterModel.hxx.
References meEditMode.
Referenced by sd::slidesorter::controller::SlideSorterController::ChangeEditMode(), sd::slidesorter::controller::SlideSorterController::Command(), sd::slidesorter::controller::SelectionManager::DeleteSelectedMasterPages(), sd::slidesorter::controller::SelectionManager::DeleteSelectedNormalPages(), sd::slidesorter::controller::SelectionManager::DeleteSelectedPages(), sd::slidesorter::controller::DragAndDropContext::DragAndDropContext(), sd::slidesorter::controller::SlideSorterController::FinishEditModeChange(), sd::slidesorter::controller::SlotManager::GetClipboardState(), sd::slidesorter::controller::SlotManager::GetMenuState(), sd::slidesorter::controller::Clipboard::HandleSlotCall(), sd::slidesorter::controller::SlotManager::InsertSlide(), sd::slidesorter::controller::Clipboard::IsDropAccepted(), sd::slidesorter::controller::SlideSorterController::PrepareEditModeChange(), and sd::slidesorter::controller::SlotManager::RenameSlideFromDrawViewShell().
sal_Int32 sd::slidesorter::model::SlideSorterModel::GetIndex | ( | const css::uno::Reference< css::drawing::XDrawPage > & | rxSlide | ) | const |
Return a page descriptor for the given XDrawPage.
Page descriptors are created on demand. The page descriptor is found (or not found) in (at most) linear time. Note that all page descriptors in front of the one associated with the given XDrawPage are created when not yet present. When the XDrawPage is not found then all descriptors are created.
Referenced by DeleteSlide(), sd::slidesorter::controller::CurrentSlideManager::NotifyCurrentSlideChange(), and sd::slidesorter::controller::PageSelector::SelectPage().
sal_Int32 sd::slidesorter::model::SlideSorterModel::GetIndex | ( | const SdrPage * | pPage | ) | const |
Return a page descriptor for the given SdrPage.
Page descriptors are created on demand. The page descriptor is found (or not found) in (at most) linear time. Note that all page descriptors in front of the one associated with the given XDrawPage are created when not yet present. When the SdrPage is not found then all descriptors are created.
Definition at line 236 of file SlideSorterModel.cxx.
References GetPageDescriptor(), SdrPage::GetPageNum(), maMutex, maPageDescriptors, nCount, and nIndex.
|
inline |
Return the mutex so that the caller can lock it and then safely access the model.
Definition at line 162 of file SlideSorterModel.hxx.
References maMutex.
Referenced by sd::slidesorter::view::SlideSorterView::PostModelChange().
|
private |
Definition at line 660 of file SlideSorterModel.cxx.
References GetDocument(), SdDrawDocument::GetMasterSdPage(), SdDrawDocument::GetSdPage(), meEditMode, Page, and Standard.
Referenced by DeleteSlide(), GetPageDescriptor(), InsertSlide(), and Resync().
sal_Int32 sd::slidesorter::model::SlideSorterModel::GetPageCount | ( | ) | const |
Return the number of slides in the document regardless of whether they are visible or not or whether they are hidden or not.
The number of slides depends on the set of slides available through the XIndexAccess given to SetDocumentSlides().
Definition at line 157 of file SlideSorterModel.cxx.
References maPageDescriptors.
Referenced by sd::slidesorter::controller::CurrentSlideManager::AcquireCurrentSlide(), sd::slidesorter::controller::PageSelector::CheckConsistency(), sd::slidesorter::controller::SlideSorterController::CheckForMasterPageAssignment(), sd::slidesorter::controller::SlideSorterController::CheckForSlideTransitionAssignment(), sd::slidesorter::controller::SelectionManager::DeleteSelectedPages(), sd::slidesorter::controller::PageSelector::DeselectAllPages(), sd::slidesorter::controller::ScrollBarManager::DetermineScrollBarVisibilities(), sd::slidesorter::controller::Clipboard::DoCut(), sd::slidesorter::controller::Clipboard::DoDelete(), sd::slidesorter::controller::FocusManager::FocusManager(), sd::slidesorter::controller::SlotManager::FuTemporary(), sd::slidesorter::controller::SelectionManager::GetInsertionPosition(), sd::slidesorter::controller::PageSelector::GetPageCount(), GetPageDescriptor(), sd::slidesorter::view::SlideSorterView::GetPageIndexAtPoint(), sd::slidesorter::controller::SlotManager::GetStatusBarState(), sd::slidesorter::controller::SelectionFunction::GotoPage(), sd::slidesorter::controller::SelectionFunction::KeyInput(), sd::slidesorter::controller::FocusManager::MoveFocus(), sd::slidesorter::view::SlideSorterView::Rearrange(), sd::slidesorter::controller::PageSelector::SelectAllPages(), sd::slidesorter::controller::SelectionManager::SetInsertionPosition(), sd::slidesorter::controller::ScrollBarManager::TestScrollBarVisibilities(), accessibility::AccessibleSlideSorterView::Implementation::UpdateChildren(), and sd::slidesorter::view::SlideSorterView::UpdatePreciousFlags().
SharedPageDescriptor sd::slidesorter::model::SlideSorterModel::GetPageDescriptor | ( | const sal_Int32 | nPageIndex, |
const bool | bCreate = true |
||
) | const |
Return a page descriptor for the page with the specified index.
Page descriptors are created on demand. The page descriptor is found (or not found) in constant time.
nPageIndex | The index of the requested slide. The valid values are 0 to GetPageCount()-1. |
bCreate | When <TRUE> and the requested page descriptor is missing then it is created. When <FALSE> then an empty reference is returned for missing descriptors. |
Definition at line 162 of file SlideSorterModel.cxx.
References GetPage(), GetPageCount(), maMutex, maPageDescriptors, and mxSlides.
Referenced by sd::slidesorter::controller::CurrentSlideManager::AcquireCurrentSlide(), sd::slidesorter::controller::PageSelector::CheckConsistency(), sd::slidesorter::controller::Clipboard::CreateTransferableUserData(), sd::slidesorter::controller::PageSelector::DeselectPage(), sd::slidesorter::view::SlideSorterView::DeterminePageObjectVisibilities(), sd::slidesorter::controller::Clipboard::ExecuteOrAcceptShapeDrop(), sd::slidesorter::controller::SlideSorterController::FinishEditModeChange(), accessibility::AccessibleSlideSorterView::Implementation::GetAccessibleChild(), accessibility::AccessibleSlideSorterObject::getBounds(), GetCoreIndex(), sd::slidesorter::view::ViewCacheContext::GetDescriptor(), sd::slidesorter::controller::FocusManager::GetFocusedPageDescriptor(), GetIndex(), sd::slidesorter::view::Layouter::Implementation::GetInnerBoundingBox(), accessibility::AccessibleSlideSorterObject::GetPage(), sd::slidesorter::controller::SlideSorterController::GetPageAt(), sd::slidesorter::controller::PageSelector::GetPageSelection(), sd::slidesorter::controller::SelectionFunction::GotoPage(), sd::slidesorter::controller::CurrentSlideManager::HandleModelChange(), InsertSlide(), sd::slidesorter::controller::SlotManager::InsertSlide(), sd::slidesorter::controller::PageSelector::IsPageExcluded(), sd::slidesorter::controller::PageSelector::IsPageSelected(), sd::slidesorter::controller::SlideSorterController::PageNameHasChanged(), sd::slidesorter::view::SlideSorterView::Paint(), sd::slidesorter::view::SlideSorterView::Rearrange(), sd::slidesorter::controller::PageSelector::SelectPage(), sd::slidesorter::controller::Clipboard::SelectPageRange(), sd::slidesorter::controller::CurrentSlideManager::SwitchCurrentSlide(), sd::slidesorter::controller::ScrollBarManager::TestScrollBarVisibilities(), sd::slidesorter::controller::PageSelector::UpdateCurrentPage(), and sd::slidesorter::view::SlideSorterView::UpdatePreciousFlags().
|
private |
Definition at line 561 of file SlideSorterModel.cxx.
References sd::slidesorter::model::FromCoreIndex(), GetPage(), GetPageDescriptor(), SdrPage::GetPageNum(), maPageDescriptors, mxSlides, nIndex, sd::slidesorter::model::PageDescriptor::ST_Selected, and UpdateIndices().
Referenced by NotifyPageEvent().
bool sd::slidesorter::model::SlideSorterModel::IsReadOnly | ( | ) | const |
Definition at line 495 of file SlideSorterModel.cxx.
References sd::ViewShellBase::GetDocShell(), sd::slidesorter::SlideSorter::GetViewShellBase(), SfxObjectShell::IsReadOnly(), and mrSlideSorter.
Referenced by sd::slidesorter::controller::InsertionIndicatorHandler::Start().
bool sd::slidesorter::model::SlideSorterModel::NotifyPageEvent | ( | const SdrPage * | pPage | ) |
Typically called from controller::Listener this method handles the insertion and deletion of single pages.
Definition at line 533 of file SlideSorterModel.cxx.
References DeleteSlide(), SdPage::GetPageKind(), InsertSlide(), SdrPage::IsInserted(), SdrPage::IsMasterPage(), maMutex, MasterPage, meEditMode, and Standard.
Referenced by sd::slidesorter::controller::Listener::HandleModelChange().
vcl::Region sd::slidesorter::model::SlideSorterModel::RestoreSelection | ( | ) |
The current selection is restored from the ST_WasSelected state from the slides.
Definition at line 516 of file SlideSorterModel.cxx.
References sd::slidesorter::model::PageEnumerationProvider::CreateAllPagesEnumeration(), sd::slidesorter::model::PageEnumeration::GetNextElement(), sd::slidesorter::model::PageEnumeration::HasMoreElements(), sd::slidesorter::model::PageDescriptor::ST_Selected, sd::slidesorter::model::PageDescriptor::ST_WasSelected, and vcl::Region::Union().
void sd::slidesorter::model::SlideSorterModel::Resync | ( | ) |
Call this method after the document has changed its structure.
For now this method uses a trivial algorithm: throw away all descriptors and create them anew (on demand).
This will get the model in sync with the SdDrawDocument. This method tries not to throw away too much information already gathered. This is especially important for previews of complex pages that take some time to create.
The main problem that we are facing when designing a better algorithm is that we can not compare pointers to pages stored in the PageDescriptor objects and those obtained from the document: pages may have been deleted and others may have been created at the exact same memory locations.
Definition at line 290 of file SlideSorterModel.cxx.
References AdaptSize(), ClearDescriptorList(), sd::slidesorter::controller::PageSelector::CountSelectedPages(), sd::slidesorter::SlideSorter::GetController(), GetDocument(), GetPage(), sd::slidesorter::controller::SlideSorterController::GetPageSelector(), SdDrawDocument::GetSdPageCount(), maMutex, maPageDescriptors, mrSlideSorter, nCount, nIndex, SAL_INFO, Standard, SynchronizeDocumentSelection(), and SynchronizeModelSelection().
Referenced by sd::slidesorter::controller::SlideSorterController::PostModelChange().
void sd::slidesorter::model::SlideSorterModel::SaveCurrentSelection | ( | ) |
The current selection is saved by copying the ST_Selected state into ST_WasSelected for slides.
Definition at line 504 of file SlideSorterModel.cxx.
References sd::slidesorter::model::PageEnumerationProvider::CreateAllPagesEnumeration(), sd::slidesorter::model::PageEnumeration::GetNextElement(), sd::slidesorter::model::PageEnumeration::HasMoreElements(), sd::slidesorter::model::PageDescriptor::ST_Selected, and sd::slidesorter::model::PageDescriptor::ST_WasSelected.
void sd::slidesorter::model::SlideSorterModel::SetDocumentSlides | ( | const css::uno::Reference< css::container::XIndexAccess > & | rxSlides | ) |
Set the XIndexAccess from which the called SlideSorterModel takes its pages.
rxSlides | The set of slides accessible through this XIndexAccess are not necessarily the same as the ones of the XModel of the XController (although it typically is a subset). |
Definition at line 380 of file SlideSorterModel.cxx.
References AdaptSize(), ClearDescriptorList(), sd::slidesorter::controller::PageSelector::CountSelectedPages(), sd::slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(), sd::slidesorter::SlideSorter::GetController(), sd::ViewShell::getCurrentPage(), sd::slidesorter::controller::SlideSorterController::GetCurrentSlideManager(), sd::ViewShell::GetFrameView(), sd::slidesorter::model::PageEnumeration::GetNextElement(), sd::slidesorter::controller::SlideSorterController::GetPageSelector(), sd::FrameView::GetSelectedPage(), sd::slidesorter::controller::SlideSorterController::GetSlotManager(), sd::slidesorter::SlideSorter::GetViewShell(), sd::slidesorter::model::PageEnumeration::HasMoreElements(), maMutex, mrSlideSorter, mxSlides, SynchronizeDocumentSelection(), and SynchronizeModelSelection().
Referenced by sd::slidesorter::controller::SlideSorterController::SetDocumentSlides().
bool sd::slidesorter::model::SlideSorterModel::SetEditMode | ( | EditMode | eEditMode | ) |
Set a new edit mode and return whether the edit mode really has been changed.
When the edit mode is changed then the previous page descriptor list is replaced by a new one which has to be repainted.
Definition at line 145 of file SlideSorterModel.cxx.
References meEditMode, and UpdatePageList().
Referenced by sd::slidesorter::controller::SlideSorterController::ChangeEditMode().
void sd::slidesorter::model::SlideSorterModel::SynchronizeDocumentSelection | ( | ) |
Set the selection of the document to exactly that of the called model.
Definition at line 354 of file SlideSorterModel.cxx.
References sd::slidesorter::model::PageEnumerationProvider::CreateAllPagesEnumeration(), sd::slidesorter::model::PageEnumeration::GetNextElement(), sd::slidesorter::model::PageEnumeration::HasMoreElements(), maMutex, and sd::slidesorter::model::PageDescriptor::ST_Selected.
Referenced by Resync(), and SetDocumentSlides().
void sd::slidesorter::model::SlideSorterModel::SynchronizeModelSelection | ( | ) |
Set the selection of the called model to exactly that of the document.
Definition at line 367 of file SlideSorterModel.cxx.
References sd::slidesorter::model::PageEnumerationProvider::CreateAllPagesEnumeration(), sd::slidesorter::model::PageEnumeration::GetNextElement(), sd::slidesorter::model::PageEnumeration::HasMoreElements(), maMutex, and sd::slidesorter::model::PageDescriptor::ST_Selected.
Referenced by Resync(), and SetDocumentSlides().
|
private |
Definition at line 636 of file SlideSorterModel.cxx.
References maPageDescriptors, and nCount.
Referenced by DeleteSlide(), and InsertSlide().
void sd::slidesorter::model::SlideSorterModel::UpdatePageList | ( | ) |
This method is called when the edit mode has changed.
It calls SetDocumentSlides() with the set of slides or master pages obtained from the model of the XController.
Definition at line 443 of file SlideSorterModel.cxx.
References sd::slidesorter::SlideSorter::GetController(), sd::slidesorter::SlideSorter::GetXController(), maMutex, MasterPage, meEditMode, mrSlideSorter, Page, sd::slidesorter::controller::SlideSorterController::SetDocumentSlides(), and xController.
Referenced by SetEditMode().
|
private |
Definition at line 207 of file SlideSorterModel.hxx.
Referenced by ClearDescriptorList(), GetDocumentSlides(), GetIndex(), GetMutex(), GetPageDescriptor(), NotifyPageEvent(), Resync(), SetDocumentSlides(), SynchronizeDocumentSelection(), SynchronizeModelSelection(), and UpdatePageList().
|
private |
Definition at line 211 of file SlideSorterModel.hxx.
Referenced by AdaptSize(), ClearDescriptorList(), DeleteSlide(), GetIndex(), GetPageCount(), GetPageDescriptor(), InsertSlide(), Resync(), and UpdateIndices().
|
private |
Definition at line 210 of file SlideSorterModel.hxx.
Referenced by GetEditMode(), GetPage(), NotifyPageEvent(), SetEditMode(), and UpdatePageList().
|
private |
Definition at line 208 of file SlideSorterModel.hxx.
Referenced by GetDocument(), IsReadOnly(), Resync(), SetDocumentSlides(), and UpdatePageList().
|
private |
Definition at line 209 of file SlideSorterModel.hxx.
Referenced by AdaptSize(), GetCoreIndex(), GetDocumentSlides(), GetPageDescriptor(), InsertSlide(), and SetDocumentSlides().