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