xref: /aoo41x/main/sd/source/ui/inc/OutlineView.hxx (revision 67e470da)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_OUTLINE_VIEW_HXX
25 #define SD_OUTLINE_VIEW_HXX
26 
27 #include <vcl/image.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include "View.hxx"
30 
31 class SdPage;
32 class SdrPage;
33 class EditStatus;
34 class Paragraph;
35 class SdrTextObj;
36 class Outliner;
37 class SfxProgress;
38 struct PaintFirstLineInfo;
39 struct PasteOrDropInfos;
40 
41 namespace sd { namespace tools {
42 class EventMultiplexerEvent;
43 } }
44 
45 namespace sd {
46 
47 class DrawDocShell;
48 class OutlineViewShell;
49 class OutlineViewModelChangeGuard;
50 class DrawDocShell;
51 
52 static const int MAX_OUTLINERVIEWS = 4;
53 
54 /*************************************************************************
55 |*
56 |* Ableitung von ::sd::View fuer den Outline-Modus
57 |*
58 \************************************************************************/
59 
60 class OutlineView
61     : public ::sd::View
62 {
63 	friend class OutlineViewModelChangeGuard;
64 public:
65     OutlineView (DrawDocShell* pDocSh,
66         ::Window* pWindow,
67         OutlineViewShell* pOutlineViewSh);
68 	~OutlineView (void);
69 
70     /** This method is called by the view shell that owns the view to tell
71         the view that it can safely connect to the application.
72         This method must not be called before the view shell is on the shell
73         stack.
74     */
75     void ConnectToApplication (void);
76     void DisconnectFromApplication (void);
77 
78 	TYPEINFO();
79 
80 	SdrTextObj* 	GetTitleTextObject(SdrPage* pPage);
81 	SdrTextObj* 	GetOutlineTextObject(SdrPage* pPage);
82 
83 	SdrTextObj* 	CreateTitleTextObject(SdPage* pPage);
84 	SdrTextObj* 	CreateOutlineTextObject(SdPage* pPage);
85 
86 	virtual void AddWindowToPaintView(OutputDevice* pWin);
87 	virtual void DeleteWindowFromPaintView(OutputDevice* pWin);
88 
89 	OutlinerView* 	GetViewByWindow (::Window* pWin) const;
GetOutliner()90 	SdrOutliner*    GetOutliner() { return(mpOutliner) ; }
91 
92 	Paragraph*		GetPrevTitle(const Paragraph* pPara);
93 	Paragraph*		GetNextTitle(const Paragraph* pPara);
94 	SdPage* 		GetActualPage();
95 	SdPage*			GetPageForParagraph( Paragraph* pPara );
96 	Paragraph*		GetParagraphForPage( ::Outliner* pOutl, SdPage* pPage );
97 
98 	/** selects the paragraph for the given page at the outliner view*/
99 	void			SetActualPage( SdPage* pActual );
100 
101 	virtual void Paint (const Rectangle& rRect, ::sd::Window* pWin);
102 	virtual void AdjustPosSizePixel(
103         const Point &rPos,
104         const Size &rSize,
105         ::sd::Window* pWindow);
106 
107 					// Callbacks fuer LINKs
108 	DECL_LINK( ParagraphInsertedHdl, Outliner * );
109 	DECL_LINK( ParagraphRemovingHdl, Outliner * );
110 	DECL_LINK( DepthChangedHdl, Outliner * );
111 	DECL_LINK( StatusEventHdl, EditStatus * );
112 	DECL_LINK( BeginMovingHdl, Outliner * );
113 	DECL_LINK( EndMovingHdl, Outliner * );
114 	DECL_LINK( RemovingPagesHdl, OutlinerView * );
115 	DECL_LINK( IndentingPagesHdl, OutlinerView * );
116 	DECL_LINK( BeginDropHdl, void * );
117 	DECL_LINK( EndDropHdl, void * );
118     DECL_LINK( PaintingFirstLineHdl, PaintFirstLineInfo* );
119 
GetPaperWidth() const120 	sal_uLong		  GetPaperWidth() const { return 2*21000; }  // DIN A4 Breite
121 
122 	sal_Bool		  PrepareClose(sal_Bool bUI = sal_True);
123 
124 	virtual sal_Bool 	GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False ) const;
125 	virtual sal_Bool   	SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll = sal_False);
126 
127 //	virtual sal_Bool	   HasMarkedObjUnused() const;
128 	void			   FillOutliner();
129 	void               SetLinks();
130 	void               ResetLinks() const;
131 
132 	SfxStyleSheet*     GetStyleSheet() const;
133 
134 	void               SetSelectedPages();
135 
136 	virtual sal_Int8 AcceptDrop (
137         const AcceptDropEvent& rEvt,
138         DropTargetHelper& rTargetHelper,
139         ::sd::Window* pTargetWindow = NULL,
140         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
141         sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
142 	virtual sal_Int8 ExecuteDrop (
143         const ExecuteDropEvent& rEvt,
144         DropTargetHelper& rTargetHelper,
145         ::sd::Window* pTargetWindow = NULL,
146         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
147         sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
148 
149 
150 	// #97766# Re-implement GetScriptType for this view to get correct results
151 	virtual sal_uInt16 GetScriptType() const;
152 
153     /** After this method has been called with <TRUE/> following changes of
154         the current page are ignored in that the corresponding text is not
155         selected.
156         This is used to supress unwanted side effects between selection and
157         cursor position.
158     */
159     void IgnoreCurrentPageChanges (bool bIgnore);
160 
161 #if 0
162 	sal_Int32 GetPageNumberWidthPixel();
163 #endif
164 
165     void InvalidateSlideNumberArea();
166 
167 	/** creates and inserts an empty slide for the given paragraph. */
168 	SdPage* InsertSlideForParagraph( Paragraph* pPara );
169 
170 	void UpdateParagraph( sal_uInt16 nPara );
171 
172 protected:
173     virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos );
174     virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos );
175 
176 private:
177 	/** call this method before you do anything that can modify the outliner
178 		and or the drawing document model. It will create needed undo actions */
179 	void BeginModelChange();
180 
181 	/** call this method after BeginModelChange(), when all possible model
182 		changes are done. */
183 	void EndModelChange();
184 
185 	/** merge edit engine undo actions if possible */
186 	void TryToMergeUndoActions();
187 
188 	/** updates all changes in the outliner model to the draw model */
189 	void UpdateDocument();
190 
191 	OutlineViewShell*	mpOutlineViewShell;
192 	SdrOutliner*		mpOutliner;
193 	OutlinerView*		mpOutlinerView[MAX_OUTLINERVIEWS];
194 
195 	List*				mpOldParaOrder;
196 	List*				mpSelectedParas;
197 
198 	sal_uInt16				mnPagesToProcess;	 // fuer die Fortschrittsanzeige
199 	sal_uInt16				mnPagesProcessed;
200 
201 	sal_Bool				mbFirstPaint;
202 
203 	SfxProgress*		mpProgress;
204 
205 	/** stores the last used high contrast mode.
206 		this is changed in onUpdateStyleSettings()
207 	*/
208 	bool mbHighContrastMode;
209 
210 	/** stores the last used document color.
211 		this is changed in onUpdateStyleSettings()
212 	*/
213 	Color maDocColor;
214 
215 	/** updates the high contrast settings and document color if they changed.
216 		@param bForceUpdate	forces the method to set all style settings
217 	*/
218 	void onUpdateStyleSettings( bool bForceUpdate = false );
219 
220 	/** this link is called from the vcl applicaten when the stylesettings
221 		change. Its only purpose is to call onUpdateStyleSettings() then.
222 	*/
223 	DECL_LINK( AppEventListenerHdl, void * );
224 
225     DECL_LINK(EventMultiplexerListener, sd::tools::EventMultiplexerEvent*);
226 
227 	/** holds a model guard during drag and drop between BeginMovingHdl and EndMovingHdl */
228 	std::auto_ptr< OutlineViewModelChangeGuard > maDragAndDropModelGuard;
229 
230 	Font maPageNumberFont;
231 	sal_Int32 mnPageNumberWidthPixel;
232 	Font maBulletFont;
233 
234     SvxLRSpaceItem maLRSpaceItem;
235 	Image maSlideImage;
236 };
237 
238 // calls IgnoreCurrentPageChangesLevel with true in ctor and with false in dtor
239 class OutlineViewPageChangesGuard
240 {
241 public:
242 	OutlineViewPageChangesGuard( OutlineView* pView );
243 	~OutlineViewPageChangesGuard();
244 private:
245 	OutlineView* mpView;
246 };
247 
248 // calls BeginModelChange() on c'tor and EndModelChange() on d'tor
249 class OutlineViewModelChangeGuard
250 {
251 public:
252 	OutlineViewModelChangeGuard( OutlineView& rView );
253 	~OutlineViewModelChangeGuard();
254 private:
255 	OutlineView& mrView;
256 };
257 
258 } // end of namespace sd
259 
260 #endif
261