Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / ui / inc / OutlineView.hxx
blob06561a6e051eca2edb0818b0d4f77bd916f88a30
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 #pragma once
22 #include <memory>
23 #include <vcl/image.hxx>
24 #include <vcl/vclevent.hxx>
25 #include <editeng/lrspitem.hxx>
26 #include <o3tl/deleter.hxx>
27 #include "View.hxx"
29 class SdPage;
30 class SdrPage;
31 class SdrTextObj;
32 class SfxProgress;
33 struct PasteOrDropInfos;
34 class EditView;
36 namespace sd::tools {
37 class EventMultiplexerEvent;
40 namespace sd {
42 class DrawDocShell;
43 class OutlineViewShell;
44 class OutlineViewModelChangeGuard;
46 const int MAX_OUTLINERVIEWS = 4;
48 /**
49 * Derivative of ::sd::View for the outline mode
51 \************************************************************************/
53 class OutlineView final
54 : public ::sd::View
56 friend class OutlineViewModelChangeGuard;
57 public:
58 OutlineView (DrawDocShell& rDocSh,
59 vcl::Window* pWindow,
60 OutlineViewShell& rOutlineViewSh);
61 virtual ~OutlineView() override;
63 /** This method is called by the view shell that owns the view to tell
64 the view that it can safely connect to the application.
65 This method must not be called before the view shell is on the shell
66 stack.
68 void ConnectToApplication();
69 void DisconnectFromApplication();
72 static SdrTextObj* GetTitleTextObject(SdrPage const * pPage);
73 static SdrTextObj* GetOutlineTextObject(SdrPage const * pPage);
75 static SdrTextObj* CreateTitleTextObject(SdPage* pPage);
76 static SdrTextObj* CreateOutlineTextObject(SdPage* pPage);
78 virtual void AddDeviceToPaintView(OutputDevice& rDev, vcl::Window* pWindow) override;
79 virtual void DeleteDeviceFromPaintView(OutputDevice& rDev) override;
81 OutlinerView* GetViewByWindow(vcl::Window const * pWin) const;
82 SdrOutliner& GetOutliner() { return mrOutliner; }
84 Paragraph* GetPrevTitle(const Paragraph* pPara);
85 Paragraph* GetNextTitle(const Paragraph* pPara);
86 SdPage* GetActualPage();
87 SdPage* GetPageForParagraph( Paragraph* pPara );
88 Paragraph* GetParagraphForPage( ::Outliner const & rOutl, SdPage const * pPage );
90 /** selects the paragraph for the given page at the outliner view*/
91 void SetActualPage( SdPage const * pActual );
93 void Paint (const ::tools::Rectangle& rRect, ::sd::Window const * pWin);
95 // Callbacks for LINKs
96 DECL_LINK( ParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, void );
97 DECL_LINK( ParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, void );
98 DECL_LINK( DepthChangedHdl, ::Outliner::DepthChangeHdlParam, void );
99 DECL_LINK( StatusEventHdl, EditStatus&, void );
100 DECL_LINK( BeginMovingHdl, ::Outliner *, void );
101 DECL_LINK( EndMovingHdl, ::Outliner *, void );
102 DECL_LINK( RemovingPagesHdl, OutlinerView *, bool );
103 DECL_LINK( IndentingPagesHdl, OutlinerView *, bool );
104 DECL_LINK( BeginDropHdl, EditView*, void );
105 DECL_LINK( EndDropHdl, EditView*, void );
106 DECL_LINK( PaintingFirstLineHdl, PaintFirstLineInfo*, void );
108 sal_uLong GetPaperWidth() const { return mnPaperWidth;}
110 void PrepareClose();
112 virtual void GetAttributes( SfxItemSet& rTargetSet, bool bOnlyHardAttr = false ) const override;
113 virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll = false, bool bSlide = false, bool bMaster = false) override;
115 void FillOutliner();
116 void SetLinks();
117 void ResetLinks() const;
119 SfxStyleSheet* GetStyleSheet() const override;
121 void SetSelectedPages();
123 virtual sal_Int8 AcceptDrop (
124 const AcceptDropEvent& rEvt,
125 DropTargetHelper& rTargetHelper,
126 SdrLayerID nLayer) override;
127 virtual sal_Int8 ExecuteDrop (
128 const ExecuteDropEvent& rEvt,
129 ::sd::Window* pTargetWindow,
130 sal_uInt16 nPage,
131 SdrLayerID nLayer) override;
133 // Re-implement GetScriptType for this view to get correct results
134 virtual SvtScriptType GetScriptType() const override;
136 /** After this method has been called with <TRUE/> following changes of
137 the current page are ignored in that the corresponding text is not
138 selected.
139 This is used to suppress unwanted side effects between selection and
140 cursor position.
142 void IgnoreCurrentPageChanges (bool bIgnore);
144 /** creates and inserts an empty slide for the given paragraph. */
145 SdPage* InsertSlideForParagraph( Paragraph* pPara );
147 void UpdateParagraph( sal_Int32 nPara );
149 protected:
150 virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo ) override;
151 virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo ) override;
153 private:
154 /** call this method before you do anything that can modify the outliner
155 and or the drawing document model. It will create needed undo actions */
156 void BeginModelChange();
158 /** call this method after BeginModelChange(), when all possible model
159 changes are done. */
160 void EndModelChange();
162 /** merge edit engine undo actions if possible */
163 void TryToMergeUndoActions();
165 /** updates all changes in the outliner model to the draw model */
166 void UpdateDocument();
168 OutlineViewShell& mrOutlineViewShell;
169 SdrOutliner& mrOutliner;
170 std::unique_ptr<OutlinerView> mpOutlinerViews[MAX_OUTLINERVIEWS];
172 std::vector<Paragraph*> maOldParaOrder;
173 std::vector<Paragraph*> maSelectedParas;
175 sal_Int32 mnPagesToProcess; // for the progress bar
176 sal_Int32 mnPagesProcessed;
178 bool mbFirstPaint;
180 sal_uLong mnPaperWidth;
182 std::unique_ptr<SfxProgress> mpProgress;
184 /** stores the last used document color.
185 this is changed in onUpdateStyleSettings()
187 Color maDocColor;
189 /** updates the high contrast settings and document color if they changed.
190 @param bForceUpdate forces the method to set all style settings
192 void onUpdateStyleSettings( bool bForceUpdate );
194 /** this link is called from the vcl application when the stylesettings
195 change. Its only purpose is to call onUpdateStyleSettings() then.
197 DECL_LINK( AppEventListenerHdl, VclSimpleEvent&, void );
199 DECL_LINK(EventMultiplexerListener, sd::tools::EventMultiplexerEvent&, void);
201 /** holds a model guard during drag and drop between BeginMovingHdl and EndMovingHdl */
202 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> maDragAndDropModelGuard;
204 SvxLRSpaceItem maLRSpaceItem;
205 Image maSlideImage;
208 // calls IgnoreCurrentPageChangesLevel with true in ctor and with false in dtor
209 class OutlineViewPageChangesGuard
211 public:
212 OutlineViewPageChangesGuard( OutlineView* pView );
213 ~OutlineViewPageChangesGuard();
214 private:
215 OutlineView* mpView;
218 // calls BeginModelChange() on c'tor and EndModelChange() on d'tor
219 class OutlineViewModelChangeGuard
221 public:
222 OutlineViewModelChangeGuard( OutlineView& rView );
223 ~OutlineViewModelChangeGuard() COVERITY_NOEXCEPT_FALSE;
224 private:
225 OutlineView& mrView;
228 } // end of namespace sd
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */