LibreOffice Module sd (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sd::slidesorter::model::SlideSorterModel Class Referencefinal

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>

Collaboration diagram for sd::slidesorter::model::SlideSorterModel:
[legend]

Public Member Functions

 SlideSorterModel (SlideSorter &rSlideSorter)
 
 ~SlideSorterModel ()
 
void Dispose ()
 
SdDrawDocumentGetDocument ()
 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...
 
SdPageGetPage (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
 
SlideSortermrSlideSorter
 
css::uno::Reference< css::container::XIndexAccess > mxSlides
 
EditMode meEditMode
 
mutable ::std::vector< SharedPageDescriptormaPageDescriptors
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SlideSorterModel()

sd::slidesorter::model::SlideSorterModel::SlideSorterModel ( SlideSorter rSlideSorter)

Definition at line 120 of file SlideSorterModel.cxx.

References Page.

◆ ~SlideSorterModel()

sd::slidesorter::model::SlideSorterModel::~SlideSorterModel ( )

Definition at line 127 of file SlideSorterModel.cxx.

References ClearDescriptorList().

Member Function Documentation

◆ AdaptSize()

void sd::slidesorter::model::SlideSorterModel::AdaptSize ( )
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().

◆ ClearDescriptorList()

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().

◆ DeleteSlide()

bool sd::slidesorter::model::SlideSorterModel::DeleteSlide ( const SdPage pPage)
private

◆ Dispose()

void sd::slidesorter::model::SlideSorterModel::Dispose ( )

Definition at line 132 of file SlideSorterModel.cxx.

References ClearDescriptorList().

◆ GetCoreIndex()

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().

◆ GetDocument()

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().

◆ GetDocumentSlides()

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().

◆ GetEditMode()

EditMode sd::slidesorter::model::SlideSorterModel::GetEditMode ( ) const
inline

◆ GetIndex() [1/2]

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.

Returns
Returns the index to the requested page descriptor or -1 when there is no such page descriptor.

Referenced by DeleteSlide(), sd::slidesorter::controller::CurrentSlideManager::NotifyCurrentSlideChange(), and sd::slidesorter::controller::PageSelector::SelectPage().

◆ GetIndex() [2/2]

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.

Returns
Returns the index to the requested page descriptor or -1 when there is no such page descriptor.

Definition at line 236 of file SlideSorterModel.cxx.

References GetPageDescriptor(), SdrPage::GetPageNum(), maMutex, maPageDescriptors, nCount, and nIndex.

◆ GetMutex()

::osl::Mutex & sd::slidesorter::model::SlideSorterModel::GetMutex ( )
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().

◆ GetPage()

SdPage * sd::slidesorter::model::SlideSorterModel::GetPage ( const sal_Int32  nCoreIndex) const
private

◆ GetPageCount()

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().

◆ GetPageDescriptor()

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.

Parameters
nPageIndexThe index of the requested slide. The valid values are 0 to GetPageCount()-1.
bCreateWhen <TRUE> and the requested page descriptor is missing then it is created. When <FALSE> then an empty reference is returned for missing descriptors.
Returns
When the given index is not valid, i.e. lower than zero or larger than or equal to the number of pages then an empty reference is returned. Note that the page count may change between calls to GetPageCount() and GetPageDescriptor().

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().

◆ InsertSlide()

void sd::slidesorter::model::SlideSorterModel::InsertSlide ( SdPage pPage,
bool  bMarkSelected 
)
private

◆ IsReadOnly()

bool sd::slidesorter::model::SlideSorterModel::IsReadOnly ( ) const

◆ NotifyPageEvent()

bool sd::slidesorter::model::SlideSorterModel::NotifyPageEvent ( const SdrPage pPage)

Typically called from controller::Listener this method handles the insertion and deletion of single pages.

Returns
Returns <TRUE> when the given page is relevant for the current page kind and edit mode.

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().

◆ RestoreSelection()

vcl::Region sd::slidesorter::model::SlideSorterModel::RestoreSelection ( )

The current selection is restored from the ST_WasSelected state from the slides.

Returns
The returned region has to be repainted to reflect the updated selection states.

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().

◆ Resync()

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().

◆ SaveCurrentSelection()

void sd::slidesorter::model::SlideSorterModel::SaveCurrentSelection ( )

◆ SetDocumentSlides()

void sd::slidesorter::model::SlideSorterModel::SetDocumentSlides ( const css::uno::Reference< css::container::XIndexAccess > &  rxSlides)

◆ SetEditMode()

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.

Returns
A return value of <TRUE> indicates that the edit mode has changed and thus the page descriptor list has been set up to reflect that change. A repaint is necessary.

Definition at line 145 of file SlideSorterModel.cxx.

References meEditMode, and UpdatePageList().

Referenced by sd::slidesorter::controller::SlideSorterController::ChangeEditMode().

◆ SynchronizeDocumentSelection()

void sd::slidesorter::model::SlideSorterModel::SynchronizeDocumentSelection ( )

◆ SynchronizeModelSelection()

void sd::slidesorter::model::SlideSorterModel::SynchronizeModelSelection ( )

◆ UpdateIndices()

void sd::slidesorter::model::SlideSorterModel::UpdateIndices ( const sal_Int32  nFirstIndex)
private

Definition at line 636 of file SlideSorterModel.cxx.

References maPageDescriptors, and nCount.

Referenced by DeleteSlide(), and InsertSlide().

◆ UpdatePageList()

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().

Member Data Documentation

◆ maMutex

mutable::osl::Mutex sd::slidesorter::model::SlideSorterModel::maMutex
private

◆ maPageDescriptors

mutable ::std::vector<SharedPageDescriptor> sd::slidesorter::model::SlideSorterModel::maPageDescriptors
private

◆ meEditMode

EditMode sd::slidesorter::model::SlideSorterModel::meEditMode
private

◆ mrSlideSorter

SlideSorter& sd::slidesorter::model::SlideSorterModel::mrSlideSorter
private

◆ mxSlides

css::uno::Reference<css::container::XIndexAccess> sd::slidesorter::model::SlideSorterModel::mxSlides
private

The documentation for this class was generated from the following files: