xref: /trunk/main/sd/source/ui/inc/View.hxx (revision af89ca6e)
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 
getSmartTags()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 
195     bool ShouldToggleOn(
196         const bool bBulletOnOffMode,
197         const bool bNormalBullet);
198 
199     /** change the bullets/numbering of the marked objects
200 
201         @param bToggle
202         true: just toggle the current bullets/numbering on --> off resp. off --> on
203 
204         @param bHandleBullets
205         true: handle bullets
206         false: handle numbering
207 
208         @param pNumRule
209         numbering rule which needs to be applied. can be 0.
210 
211         @param bSwitchOff
212         true: switch off bullets/numbering
213     */
214     void ChangeMarkedObjectsBulletsNumbering(
215         const bool bToggle,
216         const bool bHandleBullets,
217         const SvxNumRule* pNumRule,
218         const bool bSwitchOff);
219 
SetPossibilitiesDirty()220 	void SetPossibilitiesDirty() { bPossibilitiesDirty = true; }
SetMoveAllowed(bool bSet)221 	void SetMoveAllowed( bool bSet ) { bMoveAllowed = bSet; }
SetMoveProtected(bool bSet)222 	void SetMoveProtected( bool bSet ) { bMoveProtect = bSet; }
SetResizeFreeAllowed(bool bSet)223 	void SetResizeFreeAllowed( bool bSet ) { bResizeFreeAllowed = bSet; }
SetResizePropAllowed(bool bSet)224 	void SetResizePropAllowed( bool bSet ) { bResizePropAllowed = bSet; }
SetResizeProtected(bool bSet)225 	void SetResizeProtected( bool bSet ) { bResizeProtect = bSet; }
226 
SetMarkedPointsSmoothPossible(bool bSet)227 	void SetMarkedPointsSmoothPossible( bool bSet ) { bSetMarkedPointsSmoothPossible = bSet; }
SetMarkedSegmentsKindPossible(bool bSet)228 	void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; }
229 
230 	SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
231 protected:
232 	DECL_LINK( OnParagraphInsertedHdl, ::Outliner * );
233     DECL_LINK( OnParagraphRemovingHdl, ::Outliner * );
234 
235     virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos );
236     virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos );
237 
238 	SdDrawDocument* 	    mpDoc;
239 	DrawDocShell* 			mpDocSh;
240 	ViewShell*				mpViewSh;
241 	SdrMarkList*		    mpDragSrcMarkList;
242 	SdrObject*			    mpDropMarkerObj;
243 	SdrDropMarkerOverlay*	mpDropMarker;
244 	sal_uInt16				    mnDragSrcPgNum;
245 	Point				    maDropPos;
246 	::std::vector< String >	maDropFileVector;
247 	sal_Int8			    mnAction;
248 	Timer				    maDropErrorTimer;
249 	Timer				    maDropInsertFileTimer;
250 	sal_uInt16				    mnLockRedrawSmph;
251 	List*				    mpLockedRedraws;
252 	bool					mbIsDropAllowed;
253 
254 					        DECL_LINK( DropErrorHdl, Timer* );
255 					        DECL_LINK( DropInsertFileHdl, Timer* );
256 					        DECL_LINK( ExecuteNavigatorDrop, SdNavigatorDropEvent* pSdNavigatorDropEvent );
257 
258 	void ImplClearDrawDropMarker();
259 
260 	SmartTagSet				maSmartTags;
261 
262 private:
263     ::std::auto_ptr<ViewClipboard> mpClipboard;
264 };
265 
266 
GetDocSh(void) const267 DrawDocShell* View::GetDocSh (void) const
268 {
269     return mpDocSh;
270 }
GetDoc(void) const271 SdDrawDocument* View::GetDoc (void) const
272 {
273     return mpDoc;
274 }
275 
GetViewShell(void) const276 ViewShell* View::GetViewShell (void) const
277 {
278     return mpViewSh;
279 }
280 
281 } // end of namespace sd
282 
283 #endif
284