1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SVX_SVDVIEW_HXX
21 #define INCLUDED_SVX_SVDVIEW_HXX
22 
23 // HACK to avoid too deep includes and to have some
24 // levels free in svdmark itself (MS compiler include depth limit)
25 #include <svx/svdhdl.hxx>
26 #include <tools/weakbase.h>
27 #include <svtools/accessibilityoptions.hxx>
28 #include <svx/svxdllapi.h>
29 #include <svx/svdcrtv.hxx>
30 #include <vcl/event.hxx>
31 #include <unotools/options.hxx>
32 #include <basegfx/polygon/b2dpolypolygon.hxx>
33 
34 //  class hierarchy of View:
35 //         SfxListener
36 //         SdrPaintView    PntV   Action            ModChg   Attr   Notify
37 //         SdrSnapView     SnpV   Action
38 //
39 //         SdrMarkView     MrkV   Action   MrkChg   ModChg          Notify
40 //
41 //         SdrEditView     EdtV            MrkChg   ModChg   Attr
42 //         SdrPolyEditView PoEV
43 //         SdrGlueEditView GlEV
44 //         SdrObjEditView  EdxV   Action            ModChg   Attr   Notify
45 //
46 //         SdrExchangeView XcgV
47 //         SdrDragView     DrgV   Action
48 //
49 //         SdrCreateView   CrtV   Action
50 //         SdrView         View
51 
52 class SvxURLField;
53 namespace sdr::contact { class ObjectContact; }
54 
55 enum class SdrViewContext {
56     Standard,
57     PointEdit,
58     GluePointEdit,
59     Graphic,
60     Media,
61     Table
62 };
63 
64 enum class SdrEventKind {
65     NONE,
66     TextEdit,
67     MoveAction,
68     EndAction,
69     BackAction,
70     EndCreate,
71     EndDrag,
72     MarkObj,
73     MarkPoint,
74     MarkGluePoint,
75     BeginMark,
76     BeginInsertObjPoint,
77     EndInsertObjPoint,
78     BeginInsertGluePoint,
79     BeginDragHelpline,
80     BeginDragObj,
81     BeginCreateObj,
82     BeginMacroObj,
83     BeginTextEdit,
84     EndMark,
85     BrkMark,
86     ExecuteUrl
87 };
88 
89 /* for PickAnything() */
90 enum class SdrMouseEventKind
91 {
92     BUTTONDOWN = 1,
93     MOVE       = 2,
94     BUTTONUP   = 3,
95 };
96 
97 // helper class SdrViewEvent
98 struct SVXCORE_DLLPUBLIC SdrViewEvent
99 {
100     SdrHdl*                     pHdl;
101     SdrObject*                  pObj;
102     SdrObject*                  pRootObj;        // mark this when SdrBeginTextEdit is executed
103     SdrPageView*                pPV;
104     const SvxURLField*          pURLField;
105 
106     Point                       aLogicPos;
107     SdrHitKind                  eHit;
108     SdrEventKind                eEvent;
109 
110     sal_uInt16                  nMouseClicks;
111     MouseEventModifiers         nMouseMode;
112     sal_uInt16                  nMouseCode;
113     sal_uInt16                  nHlplIdx;
114     sal_uInt16                  nGlueId;
115 
116     bool                        bMouseDown : 1;
117     bool                        bMouseUp : 1;
118     bool                        bIsAction : 1;       // Action is active
119     bool                        bIsTextEdit : 1;     // TextEdit runs currently
120     bool                        bAddMark : 1;
121     bool                        bUnmark : 1;
122     bool                        bPrevNextMark : 1;
123     bool                        bMarkPrev : 1;
124 
125 public:
126     SdrViewEvent();
127     ~SdrViewEvent();
128 };
129 
130 // helper class for all D&D overlays
131 class SVXCORE_DLLPUBLIC SdrDropMarkerOverlay
132 {
133     // The OverlayObjects
134     sdr::overlay::OverlayObjectList               maObjects;
135 
136     void ImplCreateOverlays(
137         const SdrView& rView,
138         const basegfx::B2DPolyPolygon& rLinePolyPolygon);
139 
140 public:
141     SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
142     SdrDropMarkerOverlay(const SdrView& rView, const tools::Rectangle& rRectangle);
143     SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
144     ~SdrDropMarkerOverlay();
145 };
146 
147 
148 class SVXCORE_DLLPUBLIC SdrView : public SdrCreateView, public tools::WeakBase
149 {
150     friend class                SdrPageView;
151 
152     bool                        bNoExtendedMouseDispatcher : 1;
153     bool                        bNoExtendedKeyDispatcher : 1;
154     bool                        mbMasterPagePaintCaching : 1;
155 
156     SvtAccessibilityOptions maAccessibilityOptions;
157 
158 public:
159     explicit SdrView(
160         SdrModel& rSdrModel,
161         OutputDevice* pOut = nullptr);
162 
163     virtual ~SdrView() override;
164 
165     // The default value for all dispatchers is activated. If the app for example
166     // wants to intervene in MouseDispatcher for special treatment, you have to
167     // deactivate the MouseDispatcher with the help of the method below and you have
168     // to implement it yourself. Example for MouseButtonDown:
169     //      SdrViewEvent aVEvt;
170     //      SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN,aVEvt);
171     //      ... here application-specific intervention ...
172     //      pSdrView->DoMouseEvent(aVEvt);
173     //      SetPointer(GetPreferredPointer(...))
174     //      CaptureMouse(...)
EnableExtendedMouseEventDispatcher(bool bOn)175     void EnableExtendedMouseEventDispatcher(bool bOn) { bNoExtendedMouseDispatcher = !bOn; }
IsExtendedMouseEventDispatcherEnabled() const176     bool IsExtendedMouseEventDispatcherEnabled() const { return bNoExtendedMouseDispatcher; }
177 
EnableExtendedKeyInputDispatcher(bool bOn)178     void EnableExtendedKeyInputDispatcher(bool bOn) { bNoExtendedKeyDispatcher=!bOn; }
IsExtendedKeyInputDispatcherEnabled() const179     bool IsExtendedKeyInputDispatcherEnabled() const { return bNoExtendedKeyDispatcher; }
180 
181     void SetMasterPagePaintCaching(bool bOn);
IsMasterPagePaintCaching() const182     bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
183 
184     bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
185     virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
186     virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
187     virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
188     using SdrCreateView::RequestHelp;
189     virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
190 
191     virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
192 
SetAttributes(const SfxItemSet & rSet,bool bReplaceAll=false)193     bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
194 
195     /* new interface src537 */
196     void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
197 
198     // incomplete implementation:
199     // OutputDevice is necessary to determine HandleSize.
200     // If NULL the first signed on Win is used.
201     PointerStyle GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, bool bLeftDown=false) const;
202     SdrHitKind PickAnything(const MouseEvent& rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
203     SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
204     bool DoMouseEvent(const SdrViewEvent& rVEvt);
205     virtual SdrViewContext GetContext() const;
206 
207     // The methods consider the particular context:
208     // - simple drawing
209     // - mode for editing points
210     // - mode for editing glue points
211     // - TextEdit
212     // - ... to be continued
213     void MarkAll();
214     void UnmarkAll();
215 
216     const tools::Rectangle& GetMarkedRect() const;
217 
218     virtual void DeleteMarked();
219 
220     // Marking objects, traverse stations or glue points (depending on view-
221     // context) by enveloping the selection frame.
222     //   bAddMark=TRUE: add to existing selection (->Shift)
223     //   bUnmark=TRUE: remove objects from selection which are inside of
224     //                 the enveloped frame.
225     bool BegMark(const Point& rPnt, bool bAddMark, bool bUnmark);
226 
227     // The following actions are possible:
228     //   - ObjectCreating
229     //   - ObjectMarking
230     //   - Object-specific dragging
231     //   - General dragging
232     // and more...
233     OUString GetStatusText();
234 
getAccessibilityOptions()235     SvtAccessibilityOptions& getAccessibilityOptions() { return maAccessibilityOptions;}
236 
237     virtual void onAccessibilityOptionsChanged();
238 
239     // Do not create ObjectContact locally, but offer a call to allow override
240     // and to create own derivations of ObjectContact
241     virtual sdr::contact::ObjectContact* createViewSpecificObjectContact(
242         SdrPageWindow& rPageWindow,
243         const char* pDebugName) const;
244 
245     // Interactive Move Action programmatically
246     bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint, const sal_Int32 aObjectOrdNum = -1);
247 };
248 
249 // First of all the app creates a SdrModel.
250 // Then it opens a Win and creates a SdrView.
251 // ShowSdrPage() announces a page at SdrView.
252 // It's possible to show SdrView in any Wins at once.
253 // internal:
254 // SdrView can show as many Wins as it wants at once. Pages are announced
255 // or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
256 // page there is a SdrPageView instance in container aPages. If more than one page
257 // is showed, you have to pay attention that the offset parameter of ShowSdrPage()
258 // is conformed to the size of the page (to prevent overlapping of two pages).
259 //
260 // elementary methods:
261 // ~~~~~~~~~~~~~~~~~~~~
262 //   simple events:
263 //   ~~~~~~~~~~~~~~~~
264 //     bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
265 //     bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
266 //     bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
267 //     bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
268 //     bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
269 //
270 //   SfxItems:
271 //   ~~~~~~~~~
272 //     sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
273 //     sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
274 //     SfxStyleSheet* GetStyleSheet() const;
275 //     sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
276 //
277 //   others:
278 //   ~~~~~~~~~~
279 //     Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
280 //     OUString GetStatusText();
281 
282 #endif // INCLUDED_SVX_SVDVIEW_HXX
283 
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
285