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