xref: /AOO41X/main/svx/inc/svx/svdview.hxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
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 _SVDVIEW_HXX
25 #define _SVDVIEW_HXX
26 
27 // HACK to avoid too deep includes and to have some
28 // levels free in svdmark itself (MS compiler include depth limit)
29 #include <svx/svdhdl.hxx>
30 #include <tools/weakbase.hxx>
31 #include <svtools/accessibilityoptions.hxx>
32 #include "svx/svxdllapi.h"
33 #include <svx/svdcrtv.hxx>
34 #include <unotools/options.hxx>
35 #include <basegfx/polygon/b2dpolypolygon.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
39 //
40 //  Klassenhierarchie der View:
41 //         SfxListener
42 //         SdrPaintView    PntV   Action            ModChg   Attr   Notify
43 //         SdrSnapView     SnpV   Action
44 //
45 //         SdrMarkView     MrkV   Action   MrkChg   ModChg          Notify
46 //
47 //         SdrEditView     EdtV            MrkChg   ModChg   Attr
48 //         SdrPolyEditView PoEV
49 //         SdrGlueEditView GlEV
50 //         SdrObjEditView  EdxV   Action            ModChg   Attr   Notify
51 //
52 //         SdrExchangeView XcgV
53 //         SdrDragView     DrgV   Action
54 //
55 //         SdrCreateView   CrtV   Action
56 //         SdrView         View
57 //
58 ////////////////////////////////////////////////////////////////////////////////////////////////////
59 
60 //************************************************************
61 //   Vorausdeklarationen
62 //************************************************************
63 
64 class SvxURLField;
65 
66 //************************************************************
67 //   Defines
68 //************************************************************
69 
70 enum SdrViewContext {SDRCONTEXT_STANDARD,
71                      SDRCONTEXT_POINTEDIT,
72                      SDRCONTEXT_GLUEPOINTEDIT,
73                      SDRCONTEXT_GRAPHIC,
74                      SDRCONTEXT_MEDIA,
75                      SDRCONTEXT_TABLE};
76 
77 enum SdrEventKind  {SDREVENT_NONE,
78                     SDREVENT_TEXTEDIT,
79                     SDREVENT_MOVACTION,
80                     SDREVENT_ENDACTION,
81                     SDREVENT_BCKACTION,
82                     SDREVENT_BRKACTION,
83                     SDREVENT_ENDCREATE,
84                     SDREVENT_ENDDRAG,
85                     SDREVENT_MARKOBJ,
86                     SDREVENT_MARKPOINT,
87                     SDREVENT_MARKGLUEPOINT,
88                     SDREVENT_BEGMARK,
89                     SDREVENT_BEGINSOBJPOINT,
90                     SDREVENT_ENDINSOBJPOINT,
91                     SDREVENT_BEGINSGLUEPOINT,
92                     SDREVENT_BEGDRAGHELPLINE,
93                     SDREVENT_BEGDRAGOBJ,
94                     SDREVENT_BEGCREATEOBJ,
95                     SDREVENT_BEGMACROOBJ,
96                     SDREVENT_BEGTEXTEDIT,
97                     SDREVENT_ENDMARK,
98                     SDREVENT_BRKMARK,
99                     SDREVENT_EXECUTEURL};
100 
101 #define SDRMOUSEBUTTONDOWN 1
102 #define SDRMOUSEMOVE       2
103 #define SDRMOUSEBUTTONUP   3
104 
105 //************************************************************
106 //   Hilfsklasse SdrViewEvent
107 //************************************************************
108 
109 struct SVX_DLLPUBLIC SdrViewEvent
110 {
111     SdrHdl*                     pHdl;
112     SdrObject*                  pObj;
113     SdrObject*                  pRootObj;        // Dieses Markieren bei SdrBeginTextEdit
114     SdrPageView*                pPV;
115     const SvxURLField*          pURLField;
116 
117     Point                       aLogicPos;
118     SdrHitKind                  eHit;
119     SdrEventKind                eEvent;
120     SdrHdlKind                  eHdlKind;
121     SdrCreateCmd                eEndCreateCmd;   // auch fuer EndInsPoint
122 
123     sal_uInt16                      nMouseClicks;
124     sal_uInt16                      nMouseMode;
125     sal_uInt16                      nMouseCode;
126     sal_uInt16                      nHlplIdx;
127     sal_uInt16                      nGlueId;
128 
129     unsigned                    bMouseDown : 1;
130     unsigned                    bMouseUp : 1;
131     unsigned                    bDoubleHdlSize : 1;  // Doppelte Handlegroesse wg. TextEdit
132     unsigned                    bIsAction : 1;       // Action ist aktiv
133     unsigned                    bIsTextEdit : 1;     // TextEdit laeuft zur Zeit
134     unsigned                    bTextEditHit : 1;    // offene OutlinerView getroffen
135     unsigned                    bAddMark : 1;
136     unsigned                    bUnmark : 1;
137     unsigned                    bPrevNextMark : 1;
138     unsigned                    bMarkPrev : 1;
139     unsigned                    bInsPointNewObj : 1;
140     unsigned                    bDragWithCopy : 1;
141     unsigned                    bCaptureMouse : 1;
142     unsigned                    bReleaseMouse : 1;
143 
144 public:
145     SdrViewEvent();
146     ~SdrViewEvent();
147 
148     // nEventKind ist SDRMOUSEBUTTONDOWN, SDRMOUSEMOVE oder SDRMOUSEBUTTONUP
149     void SetMouseEvent(const MouseEvent& rMEvt, sal_uInt16 nEventKind);
150 };
151 
152 ////////////////////////////////////////////////////////////////////////////////////////////////////
153 // helper class for all D&D overlays
154 
155 class SVX_DLLPUBLIC SdrDropMarkerOverlay
156 {
157     // The OverlayObjects
158     ::sdr::overlay::OverlayObjectList               maObjects;
159 
160     void ImplCreateOverlays(
161         const SdrView& rView,
162         const basegfx::B2DPolyPolygon& rLinePolyPolygon);
163 
164 public:
165     SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
166     SdrDropMarkerOverlay(const SdrView& rView, const Rectangle& rRectangle);
167     SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
168     ~SdrDropMarkerOverlay();
169 };
170 
171 ////////////////////////////////////////////////////////////////////////////////////////////////////
172 ////////////////////////////////////////////////////////////////////////////////////////////////////
173 //
174 //  @@ @@ @@ @@@@@ @@   @@
175 //  @@ @@ @@ @@    @@   @@
176 //  @@ @@ @@ @@    @@ @ @@
177 //  @@@@@ @@ @@@@  @@@@@@@
178 //   @@@  @@ @@    @@@@@@@
179 //   @@@  @@ @@    @@@ @@@
180 //    @   @@ @@@@@ @@   @@
181 //
182 ////////////////////////////////////////////////////////////////////////////////////////////////////
183 ////////////////////////////////////////////////////////////////////////////////////////////////////
184 
185 class SVX_DLLPUBLIC SdrView: public SdrCreateView, public tools::WeakBase< SdrView >
186 {
187     friend class                SdrPageView;
188 
189     unsigned                    bNoExtendedMouseDispatcher : 1;
190     unsigned                    bNoExtendedKeyDispatcher : 1;
191     unsigned                    bNoExtendedCommandDispatcher : 1;
192     unsigned                    bTextEditOnObjectsWithoutTextIfTextTool : 1;
193     unsigned                    mbMasterPagePaintCaching : 1;
194 
195 protected:
196     SvtAccessibilityOptions maAccessibilityOptions;
197 
198 public:
199     TYPEINFO();
200     SdrView(SdrModel* pModel1, OutputDevice* pOut = 0L);
201     virtual ~SdrView();
202 
203     // Default sind alle Dispatcher aktiviert. Will die App z.B. fuer
204     // Sonderbehandlungen im MouseDispatcher eingreifen, so muss sie
205     // den erweiterten MouseDispather mit unten stehender Methode deaktivieren
206     // und selbst nachimplementieren. Beispiel fuer MouseButtonDown:
207     //      SdrViewEvent aVEvt;
208     //      SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SDRMOUSEBUTTONDOWN,aVEvt);
209     //      ... hier Applikationsspezifischer Eingriff ...
210     //      pSdrView->DoMouseEvent(aVEvt);
211     //      SetPointer(GetPreferedPointer(...))
212     //      CaptureMouse(...)
EnableExtendedMouseEventDispatcher(sal_Bool bOn)213     void EnableExtendedMouseEventDispatcher(sal_Bool bOn) { bNoExtendedMouseDispatcher = !bOn; }
IsExtendedMouseEventDispatcherEnabled() const214     sal_Bool IsExtendedMouseEventDispatcherEnabled() const { return bNoExtendedMouseDispatcher; }
215 
EnableExtendedKeyInputDispatcher(sal_Bool bOn)216     void EnableExtendedKeyInputDispatcher(sal_Bool bOn) { bNoExtendedKeyDispatcher=!bOn; }
IsExtendedKeyInputDispatcherEnabled() const217     sal_Bool IsExtendedKeyInputDispatcherEnabled() const { return bNoExtendedKeyDispatcher; }
218 
EnableExtendedCommandEventDispatcher(sal_Bool bOn)219     void EnableExtendedCommandEventDispatcher(sal_Bool bOn) { bNoExtendedCommandDispatcher=!bOn; }
IsExtendedCommandEventDispatcherEnabled() const220     sal_Bool IsExtendedCommandEventDispatcherEnabled() const { return bNoExtendedCommandDispatcher; }
221 
EnableTextEditOnObjectsWithoutTextIfTextTool(sal_Bool bOn)222     void EnableTextEditOnObjectsWithoutTextIfTextTool(sal_Bool bOn) { bTextEditOnObjectsWithoutTextIfTextTool=bOn; }
IsEnableTextEditOnObjectsWithoutTextIfTextToolEnabled() const223     sal_Bool IsEnableTextEditOnObjectsWithoutTextIfTextToolEnabled() const { return bTextEditOnObjectsWithoutTextIfTextTool; }
224 
225     void SetMasterPagePaintCaching(sal_Bool bOn);
IsMasterPagePaintCaching() const226     sal_Bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
227 
228     sal_Bool KeyInput(const KeyEvent& rKEvt, Window* pWin);
229     virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
230     virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
231     virtual sal_Bool MouseMove(const MouseEvent& rMEvt, Window* pWin);
232     virtual sal_Bool Command(const CommandEvent& rCEvt, Window* pWin);
233 
234     virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
235 
SetAttributes(const SfxItemSet & rSet,sal_Bool bReplaceAll=sal_False)236     sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll=sal_False) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
SetStyleSheet(SfxStyleSheet * pStyleSheet,sal_Bool bDontRemoveHardAttr=sal_False)237     sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr=sal_False) { return SdrCreateView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); }
238 
239     /* new interface src537 */
240     sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
241 
242     SfxStyleSheet* GetStyleSheet() const;
243 
244     // unvollstaendige Implementation:
245     // Das OutputDevice ist notwendig, damit ich die HandleSize ermitteln kann.
246     // Bei NULL wird das 1. angemeldete Win verwendet.
247     Pointer GetPreferedPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, sal_Bool bLeftDown=sal_False) const;
248     SdrHitKind PickAnything(const MouseEvent& rMEvt, sal_uInt16 nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
249     SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
250     sal_Bool DoMouseEvent(const SdrViewEvent& rVEvt);
251     virtual SdrViewContext GetContext() const;
252 
253     // Die Methoden beruecksichtigen den jeweiligen Kontex:
254     // - Einfaches Zeichnen
255     // - Punktbearbeitungs-Mode
256     // - Klebepunkt-Editmode
257     // - TextEdit
258     // - ... to be continued
259     sal_Bool IsMarkPossible() const;
260     void MarkAll();
261     void UnmarkAll();
262     sal_Bool IsAllMarked() const;
263     sal_Bool IsAllMarkPrevNextPossible() const; // das geht naemlich nicht bei TextEdit!
264     sal_Bool MarkNext(sal_Bool bPrev=sal_False);
265     sal_Bool MarkNext(const Point& rPnt, sal_Bool bPrev=sal_False);
266 
267     const Rectangle& GetMarkedRect() const;
268     void SetMarkedRect(const Rectangle& rRect);
269 
270     virtual void DeleteMarked();
271     sal_Bool IsDeleteMarkedPossible() const;
IsDeletePossible() const272     sal_Bool IsDeletePossible() const { return IsDeleteMarkedPossible(); }
273 
274     // Markieren von Objekten, Polygonpunkten oder Klebepunkten (je nach View-
275     // Kontext) durch Aufziehen eines Selektionsrahmens.
276     //   bAddMark=TRUE: zur bestehenden Selektion hinzumarkieren (->Shift)
277     //   bUnmark=TRUE: Bereits selektierte Objekte/Punkte/Klebepunkte die innerhalb
278     //                 des aufgezogenen Rahmens liegen werden deselektiert.
279     sal_Bool BegMark(const Point& rPnt, sal_Bool bAddMark=sal_False, sal_Bool bUnmark=sal_False);
280 
281     // Folgende Actions sind moeglich:
282     //   - ObjectCreating
283     //   - ObjectMarking
284     //   - Object-specific dragging
285     //   - General dragging
286     // und mehr...
287     String GetStatusText();
288 
289     SvtAccessibilityOptions& getAccessibilityOptions();
290 
291     virtual void onAccessibilityOptionsChanged();
292 };
293 
294 #endif //_SVDVIEW_HXX
295 
296 ////////////////////////////////////////////////////////////////////////////////////////////////////
297 //
298 // Die App macht sich zunaechst ein SdrModel.
299 // Anschliessend oeffnet sie ein Win und erzeugt dann eine SdrView.
300 // An der SdrView meldet sie dann mit der Methode ShowSdrPage() eine Seite an.
301 // Eine SdrView kann in beliebig vielen Fenstern gleichzeitig angezeigt werden.
302 // Intern:
303 // Eine SdrView kann beliebig viele Seiten gleichzeitig anzeigen. Seiten
304 // werden an- und abgemeldet mit ShowSdrPage()/HideSdrPage(). Fuer jede angemeldete
305 // Seite wird eine SdrPageView-Instanz im Container aPages angelegt. Bei
306 // gleichzeitiger Anzeige mehrerer Seiten ist darauf zu achten, dass der Offset-
307 // Parameter von ShowSdrPage() der Seitengroesse angepasst ist, da sich sonst die
308 // Seiten ueberlappen koennten.
309 //
310 // Elementare Methoden:
311 // ~~~~~~~~~~~~~~~~~~~~
312 //   Einfache Events:
313 //   ~~~~~~~~~~~~~~~~
314 //     sal_Bool KeyInput(const KeyEvent& rKEvt, Window* pWin);
315 //     sal_Bool MouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
316 //     sal_Bool MouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
317 //     sal_Bool MouseMove(const MouseEvent& rMEvt, Window* pWin);
318 //     sal_Bool Command(const CommandEvent& rCEvt, Window* pWin);
319 //
320 //   Exchange (Clipboard derzeit noch ohne SdrPrivateData):
321 //   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 //     sal_Bool Cut(sal_uIntPtr nFormat=SDR_ANYFORMAT);
323 //     sal_Bool Yank(sal_uIntPtr nFormat=SDR_ANYFORMAT);
324 //     sal_Bool Paste(Window* pWin=NULL, sal_uIntPtr nFormat=SDR_ANYFORMAT);
325 //
326 //   SfxItems:
327 //   ~~~~~~~~~
328 //     sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
329 //     sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
330 //     SfxStyleSheet* GetStyleSheet() const;
331 //     sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
332 //
333 //   Sonstiges:
334 //   ~~~~~~~~~~
335 //     Pointer GetPreferedPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
336 //     String  GetStatusText();
337 //
338 ///////////////////////////////////////////////////////////////////////////////////////////////// */
339 
340