LibreOffice Module sd (master) 1
SlideSorterModel.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
23#include <pres.hxx>
24#include <osl/mutex.hxx>
25#include <vcl/region.hxx>
26#include <com/sun/star/uno/Reference.hxx>
27#include <vector>
28
29class SdDrawDocument;
30class SdrPage;
31class SdPage;
32namespace sd::slidesorter
33{
34class SlideSorter;
35}
37{
38class XIndexAccess;
39}
41{
42class XDrawPage;
43}
44
46{
47inline sal_Int32 FromCoreIndex(const sal_uInt16 nCoreIndex) { return (nCoreIndex - 1) / 2; }
48
55{
56public:
57 SlideSorterModel(SlideSorter& rSlideSorter);
58
60 void Dispose();
61
66
76 bool SetEditMode(EditMode eEditMode);
77
78 EditMode GetEditMode() const { return meEditMode; }
79
85 sal_Int32 GetPageCount() const;
86
103 SharedPageDescriptor GetPageDescriptor(const sal_Int32 nPageIndex,
104 const bool bCreate = true) const;
105
116 sal_Int32 GetIndex(const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) const;
117
128 sal_Int32 GetIndex(const SdrPage* pPage) const;
129
135 sal_uInt16 GetCoreIndex(const sal_Int32 nIndex) const;
136
143 void Resync();
144
149 void ClearDescriptorList();
150
154
158
162 ::osl::Mutex& GetMutex() { return maMutex; }
163
171 void SetDocumentSlides(const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
172
175 css::uno::Reference<css::container::XIndexAccess> GetDocumentSlides() const;
176
181 void UpdatePageList();
182
183 bool IsReadOnly() const;
184
189
197
204 bool NotifyPageEvent(const SdrPage* pPage);
205
206private:
207 mutable ::osl::Mutex maMutex;
209 css::uno::Reference<css::container::XIndexAccess> mxSlides;
211 mutable ::std::vector<SharedPageDescriptor> maPageDescriptors;
212
216 void AdaptSize();
217
218 SdPage* GetPage(const sal_Int32 nCoreIndex) const;
219 void InsertSlide(SdPage* pPage, bool bMarkSelected);
220 // return if this page was marked as selected before being removed
221 bool DeleteSlide(const SdPage* pPage);
222 void UpdateIndices(const sal_Int32 nFirstIndex);
223};
224
225} // end of namespace ::sd::slidesorter::model
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
The model of the slide sorter gives access to the slides that are to be displayed in the slide sorter...
void SynchronizeModelSelection()
Set the selection of the called model to exactly that of the document.
bool SetEditMode(EditMode eEditMode)
Set a new edit mode and return whether the edit mode really has been changed.
bool NotifyPageEvent(const SdrPage *pPage)
Typically called from controller::Listener this method handles the insertion and deletion of single p...
SlideSorterModel(SlideSorter &rSlideSorter)
void UpdatePageList()
This method is called when the edit mode has changed.
SdDrawDocument * GetDocument()
This method is present to let the view create a ShowView for displaying slides.
sal_Int32 GetPageCount() const
Return the number of slides in the document regardless of whether they are visible or not or whether ...
css::uno::Reference< css::container::XIndexAccess > GetDocumentSlides() const
Return the set of pages that is currently displayed by the slide sorter.
mutable ::std::vector< SharedPageDescriptor > maPageDescriptors
css::uno::Reference< css::container::XIndexAccess > mxSlides
SharedPageDescriptor GetPageDescriptor(const sal_Int32 nPageIndex, const bool bCreate=true) const
Return a page descriptor for the page with the specified index.
void SetDocumentSlides(const css::uno::Reference< css::container::XIndexAccess > &rxSlides)
Set the XIndexAccess from which the called SlideSorterModel takes its pages.
void SaveCurrentSelection()
The current selection is saved by copying the ST_Selected state into ST_WasSelected for slides.
vcl::Region RestoreSelection()
The current selection is restored from the ST_WasSelected state from the slides.
void ClearDescriptorList()
Delete all descriptors that currently are in the container.
sal_Int32 GetIndex(const css::uno::Reference< css::drawing::XDrawPage > &rxSlide) const
Return a page descriptor for the given XDrawPage.
void SynchronizeDocumentSelection()
Set the selection of the document to exactly that of the called model.
::osl::Mutex & GetMutex()
Return the mutex so that the caller can lock it and then safely access the model.
void UpdateIndices(const sal_Int32 nFirstIndex)
void Resync()
Call this method after the document has changed its structure.
SdPage * GetPage(const sal_Int32 nCoreIndex) const
void AdaptSize()
Resize the descriptor container according to current values of page kind and edit mode.
void InsertSlide(SdPage *pPage, bool bMarkSelected)
sal_uInt16 GetCoreIndex(const sal_Int32 nIndex) const
Return an index for accessing an SdrModel that corresponds to the given SlideSorterModel index.
sal_Int32 FromCoreIndex(const sal_uInt16 nCoreIndex)
std::shared_ptr< PageDescriptor > SharedPageDescriptor
EditMode
Definition: pres.hxx:53