xref: /aoo41x/main/sd/source/ui/inc/View.hxx (revision 766ce4d0)
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_VIEW_HXX
25 #define SD_VIEW_HXX
26 
27 #include "pres.hxx"
28 #include <tools/gen.hxx>
29 #include <svtools/transfer.hxx>
30 #include <svx/fmview.hxx>
31 #include <svx/svdmark.hxx>
32 //#ifndef _SVDVMARK_HXX //autogen
33 //#include <svx/svdvmark.hxx>
34 //#endif
35 #include <svx/svdpage.hxx>
36 #include "fupoor.hxx"
37 
38 #include "smarttag.hxx"
39 #include <editeng/numitem.hxx>
40 
41 class SdDrawDocument;
42 class SdrOle2Obj;
43 class SdrGrafObj;
44 class SdrMediaObj;
45 class OutputDevice;
46 class VirtualDevice;
47 class ImageMap;
48 class Point;
49 class Graphic;
50 class SdrOutliner;
51 class TransferableDataHelper;
52 struct StyleRequestData;
53 class Outliner;
54 
55 namespace sd {
56 
57 class DrawDocShell;
58 struct SdNavigatorDropEvent;
59 class ViewShell;
60 class Window;
61 class ViewClipboard;
62 
63 // -------------------
64 // - SdViewRedrawRec -
65 // -------------------
66 
67 struct SdViewRedrawRec
68 {
69 	OutputDevice* mpOut;
70 	Rectangle	  aRect;
71 };
72 
73 
74 class View : public FmFormView
75 {
76 public:
77     TYPEINFO();
78 
79     View (
80         SdDrawDocument* pDrawDoc,
81         OutputDevice* pOutDev,
82         ViewShell* pViewSh=NULL);
83 	virtual ~View (void);
84 
85 	void                    CompleteRedraw( OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L);
86 
87 	virtual sal_Bool 	        GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False ) const;
88 	virtual sal_Bool   	        SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll = sal_False);
89 	virtual void	        MarkListHasChanged();
90 	virtual void	        ModelHasChanged();
91 	virtual void            SelectAll();
92 	virtual void            DoCut(::Window* pWindow=NULL);
93 	virtual void            DoCopy(::Window* pWindow=NULL);
94 	virtual void            DoPaste(::Window* pWindow=NULL);
95 	virtual void            DoConnect(SdrOle2Obj* pOleObj);
96 	virtual sal_Bool            SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr = sal_False);
97 	virtual void            StartDrag( const Point& rStartPos, ::Window* pWindow );
98 	virtual void            DragFinished( sal_Int8 nDropAction );
99 	virtual sal_Int8 AcceptDrop (
100         const AcceptDropEvent& rEvt,
101         DropTargetHelper& rTargetHelper,
102         ::sd::Window* pTargetWindow = NULL,
103         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
104         sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
105 	virtual sal_Int8 ExecuteDrop (
106         const ExecuteDropEvent& rEvt,
107         DropTargetHelper& rTargetHelper,
108         ::sd::Window* pTargetWindow = NULL,
109         sal_uInt16 nPage = SDRPAGE_NOTFOUND,
110         sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
111 
112 	::com::sun::star::uno::Reference<
113         ::com::sun::star::datatransfer::XTransferable>
114         CreateClipboardDataObject (::sd::View*, ::Window& rWindow);
115 	::com::sun::star::uno::Reference<
116         ::com::sun::star::datatransfer::XTransferable>
117         CreateDragDataObject (::sd::View*, ::Window& rWindow,
118             const Point& rDragPos);
119 	::com::sun::star::uno::Reference<
120         ::com::sun::star::datatransfer::XTransferable>
121         CreateSelectionDataObject (::sd::View*, ::Window& rWindow);
122 
123     void                    UpdateSelectionClipboard( sal_Bool bForceDeselect );
124 
125 	inline DrawDocShell* GetDocSh (void) const;
126     inline SdDrawDocument* GetDoc (void) const;
127     inline ViewShell* GetViewShell (void) const;
128 
129 	virtual sal_Bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = 0L, ::Window* pWin = 0L, sal_Bool bIsNewObj = sal_False,
130 		SdrOutliner* pGivenOutliner = 0L, OutlinerView* pGivenOutlinerView = 0L,
131         sal_Bool bDontDeleteOutliner = sal_False, sal_Bool bOnlyOneView = sal_False, sal_Bool bGrabFocus = sal_True);
132 
133 	virtual SdrEndTextEditKind SdrEndTextEdit(sal_Bool bDontDeleteReally = sal_False);
134 
135 	bool RestoreDefaultText( SdrTextObj* pTextObj );
136 
137 	sal_Bool		            InsertData( const TransferableDataHelper& rDataHelper,
138 							            const Point& rPos, sal_Int8& rDnDAction, sal_Bool bDrag,
139 							            sal_uLong nFormat = 0, sal_uInt16 nPage = SDRPAGE_NOTFOUND, sal_uInt16 nLayer = SDRLAYER_NOTFOUND );
140 	/** gets the metafile from the given transferable helper and insert it as a graphic shape.
141 		@param bOptimize if set to true, the metafile is analyzed and if only one bitmap action is
142 						 present, then is is inserted as a single graphic.
143 	*/
144 	bool					InsertMetaFile( TransferableDataHelper& rDataHelper,
145 											const Point& rInsertPos,
146 											ImageMap* pImageMap, bool bOptimize );
147 
148 	SdrGrafObj*             InsertGraphic( const Graphic& rGraphic,
149 							               sal_Int8& rAction, const Point& rPos,
150 							               SdrObject* pSelectedObj, ImageMap* pImageMap );
151     SdrMediaObj*            InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction,
152 								            const Point& rPos, const Size& rSize );
153 
154 	bool PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions );
155 
156 	sal_Bool	                IsPresObjSelected(sal_Bool bOnPage=sal_True, sal_Bool bOnMasterPage=sal_True, sal_Bool bCheckPresObjListOnly=sal_False, sal_Bool bCheckLayoutOnly=sal_False) const;
157 
158 	void	                SetMarkedOriginalSize();
159 
160 	void	                LockRedraw(sal_Bool bLock);
161 
162 	sal_Bool	                IsMorphingAllowed() const;
163 	sal_Bool	                IsVectorizeAllowed() const;
164 
165 	virtual SfxStyleSheet*  GetStyleSheet() const;
166 
167 	sal_Bool	                GetExchangeList( List*& rpExchangeList, List* pBookmarkList, sal_uInt16 nType );
168 
169 	virtual void onAccessibilityOptionsChanged();
170 
171 	virtual SdrModel*   GetMarkedObjModel() const;
172 	virtual sal_Bool		Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0);
173 	using SdrExchangeView::Paste;
174 
175 	/** returns true if we have an undo manager and there is an open list undo action */
176 	bool isRecordingUndo() const;
177 
178 	virtual void AddCustomHdl();
179 
180 	SmartTagSet& getSmartTags() { return maSmartTags; }
181 	void selectSmartTag( const SmartTagReference& xTag );
182 	void updateHandles();
183 
184 	virtual SdrViewContext GetContext() const;
185 	virtual sal_Bool HasMarkablePoints() const;
186 	virtual sal_uLong GetMarkablePointCount() const;
187 	virtual sal_Bool HasMarkedPoints() const;
188 	virtual sal_uLong GetMarkedPointCount() const;
189 	virtual sal_Bool IsPointMarkable(const SdrHdl& rHdl) const;
190 	virtual sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
191 	virtual void CheckPossibilities();
192 	virtual sal_Bool MarkPoints(const ::Rectangle* pRect, sal_Bool bUnmark);
193 	using SdrMarkView::MarkPoints;
194 	sal_Bool ShouldToggleOn(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet);
195 	void ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule = NULL, sal_Bool bForceBulletOnOff = false);
196 
197 	void SetPossibilitiesDirty() { bPossibilitiesDirty = true; }
198 	void SetMoveAllowed( bool bSet ) { bMoveAllowed = bSet; }
199 	void SetMoveProtected( bool bSet ) { bMoveProtect = bSet; }
200 	void SetResizeFreeAllowed( bool bSet ) { bResizeFreeAllowed = bSet; }
201 	void SetResizePropAllowed( bool bSet ) { bResizePropAllowed = bSet; }
202 	void SetResizeProtected( bool bSet ) { bResizeProtect = bSet; }
203 
204 	void SetMarkedPointsSmoothPossible( bool bSet ) { bSetMarkedPointsSmoothPossible = bSet; }
205 	void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; }
206 
207 	SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
208 protected:
209 	DECL_LINK( OnParagraphInsertedHdl, ::Outliner * );
210     DECL_LINK( OnParagraphRemovingHdl, ::Outliner * );
211 
212     virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos );
213     virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos );
214 
215 	SdDrawDocument* 	    mpDoc;
216 	DrawDocShell* 			mpDocSh;
217 	ViewShell*				mpViewSh;
218 	SdrMarkList*		    mpDragSrcMarkList;
219 	SdrObject*			    mpDropMarkerObj;
220 	SdrDropMarkerOverlay*	mpDropMarker;
221 	sal_uInt16				    mnDragSrcPgNum;
222 	Point				    maDropPos;
223 	::std::vector< String >	maDropFileVector;
224 	sal_Int8			    mnAction;
225 	Timer				    maDropErrorTimer;
226 	Timer				    maDropInsertFileTimer;
227 	sal_uInt16				    mnLockRedrawSmph;
228 	List*				    mpLockedRedraws;
229 	bool					mbIsDropAllowed;
230 
231 					        DECL_LINK( DropErrorHdl, Timer* );
232 					        DECL_LINK( DropInsertFileHdl, Timer* );
233 					        DECL_LINK( ExecuteNavigatorDrop, SdNavigatorDropEvent* pSdNavigatorDropEvent );
234 
235 	void ImplClearDrawDropMarker();
236 
237 	SmartTagSet				maSmartTags;
238 
239 private:
240     ::std::auto_ptr<ViewClipboard> mpClipboard;
241 };
242 
243 
244 DrawDocShell* View::GetDocSh (void) const
245 {
246     return mpDocSh;
247 }
248 SdDrawDocument* View::GetDoc (void) const
249 {
250     return mpDoc;
251 }
252 
253 ViewShell* View::GetViewShell (void) const
254 {
255     return mpViewSh;
256 }
257 
258 } // end of namespace sd
259 
260 #endif
261