bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / sidebar / MasterPagesSelector.hxx
blobfa22290a15d65ad7657497521db8b66286f1baa5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGESSELECTOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGESSELECTOR_HXX
23 #include <memory>
24 #include "MasterPageContainer.hxx"
25 #include <SlideSorterViewShell.hxx>
26 #include "PreviewValueSet.hxx"
27 #include <sfx2/sidebar/ILayoutableWindow.hxx>
29 #include <osl/mutex.hxx>
31 namespace com { namespace sun { namespace star { namespace ui { class XSidebar; } } } }
32 class MouseEvent;
33 class SdDrawDocument;
34 class SdPage;
36 namespace sd {
37 class ViewShellBase;
40 namespace sd { namespace sidebar {
42 /** Base class of a menu that lets the user select from a list of
43 templates or designs that are loaded from files.
45 class MasterPagesSelector
46 : public PreviewValueSet,
47 public sfx2::sidebar::ILayoutableWindow
49 public:
50 MasterPagesSelector (
51 vcl::Window* pParent,
52 SdDrawDocument& rDocument,
53 ViewShellBase& rBase,
54 const std::shared_ptr<MasterPageContainer>& rpContainer,
55 const css::uno::Reference<css::ui::XSidebar>& rxSidebar);
56 virtual ~MasterPagesSelector() override;
57 virtual void dispose() override;
59 virtual void LateInit();
61 sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
63 /** Make the selector empty. This method clear the value set from any
64 entries. Override this method to add functionality, especially to
65 destroy objects set as data items at the value set.
67 void ClearPageSet();
69 void SetHelpId( const OString& aId );
71 /** Mark the preview that belongs to the given index as not up-to-date
72 anymore with respect to page content or preview size.
73 The implementation of this method will either sunchronously or
74 asynchronously call UpdatePreview().
75 @param nIndex
76 Index into the value set control that is used for displaying the
77 previews.
79 void InvalidatePreview (const SdPage* pPage);
81 void UpdateAllPreviews();
83 // ILayoutableWindow
84 virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth) override;
86 protected:
87 mutable ::osl::Mutex maMutex;
88 std::shared_ptr<MasterPageContainer> mpContainer;
90 SdDrawDocument& mrDocument;
91 ViewShellBase& mrBase;
93 SdPage* GetSelectedMasterPage();
95 /** Assign the given master page to all slides of the document.
96 @param pMasterPage
97 The master page to assign to all slides.
99 void AssignMasterPageToAllSlides (SdPage* pMasterPage);
101 /** Assign the given master page to all slides that are selected in a
102 slide sorter that is displayed in the lef or center pane. When both
103 panes display a slide sorter then the one in the center pane is
104 used.
106 void AssignMasterPageToSelectedSlides (SdPage* pMasterPage);
108 virtual void AssignMasterPageToPageList (
109 SdPage* pMasterPage,
110 const std::shared_ptr<std::vector<SdPage*>>& rPageList);
112 virtual void NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent);
114 typedef ::std::pair<int, MasterPageContainer::Token> UserData;
115 UserData* GetUserData (int nIndex) const;
116 void SetUserData (int nIndex, std::unique_ptr<UserData> pData);
118 sal_Int32 GetIndexForToken (MasterPageContainer::Token aToken) const;
119 typedef ::std::vector<MasterPageContainer::Token> ItemList;
120 void UpdateItemList (::std::unique_ptr<ItemList> && pList);
121 void Clear();
122 /** Invalidate the specified item so that on the next Fill() this item
123 is updated.
125 void InvalidateItem (MasterPageContainer::Token aToken);
127 // For every item in the ValueSet we store its associated token. This
128 // allows a faster access and easier change tracking.
129 ItemList maCurrentItemList;
130 typedef ::std::map<MasterPageContainer::Token,sal_Int32> TokenToValueSetIndex;
131 TokenToValueSetIndex maTokenToValueSetIndex;
133 ItemList maLockedMasterPages;
134 /** Lock master pages in the given list and release locks that were
135 previously acquired.
137 void UpdateLocks (const ItemList& rItemList);
139 void Fill();
140 virtual void Fill (ItemList& rItemList) = 0;
142 /** Give derived classes the opportunity to provide their own context
143 menu. If they do then they probably have to provide their own
144 Execute() and GetState() methods as well.
146 virtual OUString GetContextMenuUIFile() const;
148 virtual void Command (const CommandEvent& rEvent) override;
150 virtual void ProcessPopupMenu (Menu& rMenu);
151 virtual void ExecuteCommand(const OString& rIdent);
153 private:
154 css::uno::Reference<css::ui::XSidebar> mxSidebar;
156 /** The offset between ValueSet index and MasterPageContainer::Token
157 last seen. This value is used heuristically to speed up the lookup
158 of an index for a token.
160 DECL_LINK(ClickHandler, ValueSet*, void);
161 DECL_LINK(RightClickHandler, const MouseEvent&, void);
162 DECL_LINK(ContainerChangeListener, MasterPageContainerChangeEvent&, void);
163 DECL_LINK(OnMenuItemSelected, Menu*, bool);
165 void SetItem (
166 sal_uInt16 nIndex,
167 MasterPageContainer::Token aToken);
168 void AddTokenToIndexEntry (
169 sal_uInt16 nIndex,
170 MasterPageContainer::Token aToken);
171 void RemoveTokenToIndexEntry (
172 sal_uInt16 nIndex,
173 MasterPageContainer::Token aToken);
176 } } // end of namespace sd::sidebar
178 #endif
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */