LibreOffice Module svx (master)  1
svdedxv.hxx
Go to the documentation of this file.
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_SVDEDXV_HXX
21 #define INCLUDED_SVX_SVDEDXV_HXX
22 
23 #include <rtl/ref.hxx>
24 #include <svl/languageoptions.hxx>
25 #include <svx/svxdllapi.h>
26 #include <svx/svdglev.hxx>
28 #include <editeng/editview.hxx>
29 #include <memory>
30 
31 class SdrOutliner;
32 class OutlinerView;
33 class EditStatus;
34 class EditFieldInfo;
35 class ImpSdrEditPara;
36 struct PasteOrDropInfos;
37 class SdrUndoManager;
39 
40 namespace com::sun::star::uno {
41  class Any;
42 }
43 
44 namespace sdr {
45  class SelectionController;
46 }
47 
49 {
50  Unchanged, // textobject unchanged
51  Changed, // textobject changed
52  Deleted, // textobject implicitly deleted
53  ShouldBeDeleted // for writer: textobject should be deleted
54 };
55 
56 // - general edit for objectspecific properties
57 // - textedit for all drawobjects, inherited from SdrTextObj
58 // - macromode
59 
60 
61 class SVXCORE_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditViewCallbacks
62 {
63  friend class SdrPageView;
64  friend class ImpSdrEditPara;
65 
66  // Now derived from EditViewCallbacks and overriding these callbacks to
67  // allow own EditText visualization
68  virtual void EditViewInvalidate(const tools::Rectangle& rRect) override;
69  virtual void EditViewSelectionChange() override;
70  virtual OutputDevice& EditViewOutputDevice() const override;
71  virtual Point EditViewPointerPosPixel() const override;
72  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() override;
73  virtual void EditViewInputContext(const InputContext& rInputContext) override;
74  virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) override;
75 
76  // The OverlayObjects used for visualizing active TextEdit (currently
77  // using TextEditOverlayObject, but not limited to it
79 
80 protected:
81  // TextEdit
83  mxTextEditObj; // current object in TextEdit
85  std::unique_ptr<SdrOutliner> pTextEditOutliner; // outliner for the TextEdit
86  OutlinerView* pTextEditOutlinerView; // current view of the outliners
87  VclPtr<vcl::Window> pTextEditWin; // matching window to pTextEditOutlinerView
88  vcl::Cursor* pTextEditCursorBuffer; // to restore the cursor in each window
92 
97 
98  sal_uInt16 nMacroTol;
99 
100  bool bTextEditDontDelete : 1; // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
101  bool bTextEditOnlyOneView : 1; // a single OutlinerView (f. spellchecking)
102  bool bTextEditNewObj : 1; // current edited object was just recreated
103  bool bQuickTextEditMode : 1; // persistent(->CrtV). Default=TRUE
104  bool bMacroDown : 1;
105 
108 
109 private:
111 
112 protected:
113  // central method to get an SdrUndoManager for enhanced TextEdit. Default will
114  // try to return a dynamic_casted GetModel()->GetSdrUndoManager(). Applications
115  // which want to use this feature will need to override this virtual method,
116  // provide their document UndoManager and derive it from SdrUndoManager.
117  virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const;
118 
119  void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
120  std::unique_ptr<TextChainCursorManager> ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool *bOutHandled);
121 
122 
123  OutlinerView* ImpFindOutlinerView(vcl::Window const * pWin) const;
124 
125  // Create a new OutlinerView at the heap and initialize all required parameters.
126  // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
127  OutlinerView* ImpMakeOutlinerView(vcl::Window* pWin, OutlinerView* pGivenView, SfxViewShell* pViewShell = nullptr) const;
128  void ImpPaintOutlinerView(OutlinerView& rOutlView, const tools::Rectangle& rRect, OutputDevice& rTargetDevice) const;
129  void ImpInvalidateOutlinerView(OutlinerView const & rOutlView) const;
130 
131  // Chaining
132  void ImpChainingEventHdl();
133  DECL_LINK(ImpAfterCutOrPasteChainingEventHdl, LinkParamNone*, void);
134 
135 
136  // Check if the whole text is selected.
137  // Still returns sal_True if there is no text present.
138  bool ImpIsTextEditAllSelected() const;
139  void ImpMakeTextCursorAreaVisible();
140 
141  // handler for AutoGrowing text with active Outliner
142  DECL_LINK(ImpOutlinerStatusEventHdl, EditStatus&, void);
143  DECL_LINK(ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, void);
144 
145  // link for EndTextEditHdl
146  DECL_LINK(EndTextEditHdl, SdrUndoManager*, void);
147 
148  void ImpMacroUp(const Point& rUpPos);
149  void ImpMacroDown(const Point& rDownPos);
150 
151  DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos*, void );
152  DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos*, void );
153 
154 protected:
155  // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
157  SdrModel& rSdrModel,
158  OutputDevice* pOut);
159 
160  virtual ~SdrObjEditView() override;
161 
162 public:
163 
164  // used to call the old ImpPaintOutlinerView. Will be replaced when the
165  // outliner will be displayed on the overlay in edit mode.
166  void TextEditDrawing(SdrPaintWindow& rPaintWindow);
167 
168  // Actionhandling for macromode
169  virtual bool IsAction() const override;
170  virtual void MovAction(const Point& rPnt) override;
171  virtual void EndAction() override;
172  virtual void BrkAction() override;
173  virtual void BckAction() override;
174  virtual void TakeActionRect(tools::Rectangle& rRect) const override;
175 
176  SdrPageView* ShowSdrPage(SdrPage* pPage) override;
177  void HideSdrPage() override;
178 
179  virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
180  virtual void ModelHasChanged() override;
181 
182 
183  // TextEdit over an outliner
184 
185  // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
186  void SetQuickTextEditMode(bool bOn) { bQuickTextEditMode=bOn; }
187  bool IsQuickTextEditMode() const { return bQuickTextEditMode; }
188 
189  // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
190  // The cursor of the currently edited window is stored with SdrBeginTextEdit()
191  // and restored with SdrEndTextEdit().
192  // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
193  // when SdrEndTextEdit is called.
194  // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
195  // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
196  // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
197  // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
198  // StatusEventHdl.
199  // Similarly a specific OutlinerView can be specified.
200 
201  virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = nullptr, vcl::Window* pWin = nullptr, bool bIsNewObj = false,
202  SdrOutliner* pGivenOutliner = nullptr, OutlinerView* pGivenOutlinerView = nullptr,
203  bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true);
204  // bDontDeleteReally is a special parameter for writer
205  // If this flag is set, then a maybe empty textobject is not deleted.
206  // Instead you get a return code SdrEndTextEditKind::ShouldBeDeleted
207  // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
208  // deleted.
209  virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false);
210  virtual bool IsTextEdit() const final override;
211 
212  // This method returns sal_True, if the point rHit is inside the
213  // objectspace or the OutlinerView.
214  bool IsTextEditHit(const Point& rHit) const;
215 
216  // This method returns sal_True, if the point rHit is inside the
217  // handle-thick frame, which surrounds the OutlinerView at TextFrames.
218  bool IsTextEditFrameHit(const Point& rHit) const;
219 
220  // At active selection, between MouseButtonDown and
221  // MouseButtonUp, this method always returns TRUE.
222  bool IsTextEditInSelectionMode() const;
223 
224  // If sb needs the object out of the TextEdit:
225  SdrTextObj* GetTextEditObject() const { return mxTextEditObj.get(); }
226 
227  // info about TextEditPageView. Default is 0L.
228  SdrPageView* GetTextEditPageView() const;
229 
230  // Current window of the outliners.
231  void SetTextEditWin(vcl::Window* pWin);
232 
233  // Now at this outliner, events can be send, attributes can be set,
234  // call Cut/Copy/Paste, call Undo/Redo, and so on...
235  const SdrOutliner* GetTextEditOutliner() const { return pTextEditOutliner.get(); }
236  SdrOutliner* GetTextEditOutliner() { return pTextEditOutliner.get(); }
237  const OutlinerView* GetTextEditOutlinerView() const { return pTextEditOutlinerView; }
238  OutlinerView* GetTextEditOutlinerView() { return pTextEditOutlinerView; }
239 
240  virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
241  virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
242  virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
243  virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
244  virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
245 
246  // #97766# make virtual to change implementation e.g. for SdOutlineView
247  virtual SvtScriptType GetScriptType() const;
248 
249  /* new interface src537 */
250  void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
251 
252  bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
253  SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
254  void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
255 
256  // Intern: at mounting new OutlinerView...
257  virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) override;
258  virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin) override;
259 
260  sal_uInt16 GetSelectionLevel() const;
261 
262 
263  // Object MacroMode (e.g. rect as button or sth. like that):
264 
265  void BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin);
266  void BegMacroObj(const Point& rPnt, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin) { BegMacroObj(rPnt,-2,pObj,pPV,pWin); }
267  void MovMacroObj(const Point& rPnt);
268  void BrkMacroObj();
269  bool EndMacroObj();
270  bool IsMacroObj() const { return pMacroObj!=nullptr; }
271 
274  void getTextSelection( css::uno::Any& rSelection );
275 
276  virtual void MarkListHasChanged() override;
277 
278  const rtl::Reference< sdr::SelectionController >& getSelectionController() const { return mxSelectionController; }
279 
281  static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor, sal_uInt16 nObjectIdentifier );
282 
284  void TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet );
285 
290  void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
291 
293  static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats );
294 
295 protected:
296  virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo );
297  virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo );
298 
299 };
300 
301 #endif // INCLUDED_SVX_SVDEDXV_HXX
302 
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool MouseButtonUp(const MouseEvent &, OutputDevice *)
Definition: svdpntv.hxx:454
virtual bool IsTextEdit() const
Definition: svdpntv.cxx:296
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdedtv1.cxx:1300
OString OOO_DLLPUBLIC_TEST getTextSelection(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, OString mimeType)
std::unique_ptr< SdrOutliner > pTextEditOutliner
Definition: svdedxv.hxx:85
bool IsMacroObj() const
Definition: svdedxv.hxx:270
rtl::Reference< sdr::SelectionController > mxLastSelectionController
Definition: svdedxv.hxx:107
virtual void DeleteWindowFromPaintView(OutputDevice *pOldWin)
Definition: svdpntv.cxx:393
tools::Rectangle aMinTextEditArea
Definition: svdedxv.hxx:94
SdrEndTextEditKind
Definition: svdedxv.hxx:48
virtual void BckAction() override
Definition: svdmrkv.cxx:317
SdrInventor
Definition: svdobj.hxx:98
SdrOutliner * GetTextEditOutliner()
Definition: svdedxv.hxx:236
virtual void BrkAction() override
Definition: svdmrkv.cxx:325
virtual bool MouseButtonDown(const MouseEvent &, OutputDevice *)
Definition: svdpntv.hxx:453
virtual bool MouseMove(const MouseEvent &rMEvt, OutputDevice *pWin) override
handle mouse over effects for handles
Definition: svdmrkv.cxx:1492
tools::Rectangle aTextEditArea
Definition: svdedxv.hxx:93
virtual void ModelHasChanged() override
Definition: svdedtv.cxx:385
SfxStyleSheet * GetStyleSheet() const
Definition: svdedtv1.cxx:1321
void SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdedtv1.cxx:1312
virtual bool KeyInput(const KeyEvent &rKEvt, vcl::Window *pWin)
Definition: svdpntv.cxx:776
sdr::overlay::OverlayObjectList maTEOverlayGroup
Definition: svdedxv.hxx:78
const SdrOutliner * GetTextEditOutliner() const
Definition: svdedxv.hxx:235
SvtScriptType
VclPtr< vcl::Window > pTextEditWin
Definition: svdedxv.hxx:87
virtual void MarkListHasChanged() override
Definition: svdedtv.cxx:379
tools::WeakReference< SdrTextObj > mxTextEditObj
Definition: svdedxv.hxx:83
VclPtr< vcl::Window > pMacroWin
Definition: svdedxv.hxx:91
virtual void MovAction(const Point &rPnt) override
Definition: svdmrkv.cxx:281
virtual void EndAction() override
Definition: svdmrkv.cxx:299
SdrPageView * pTextEditPV
Definition: svdedxv.hxx:84
void SetQuickTextEditMode(bool bOn)
Definition: svdedxv.hxx:186
virtual bool IsAction() const override
Definition: svdmrkv.cxx:276
Link< EditFieldInfo *, void > aOldCalcFieldValueLink
Definition: svdedxv.hxx:95
OutlinerView * GetTextEditOutlinerView()
Definition: svdedxv.hxx:238
const OutlinerView * GetTextEditOutlinerView() const
Definition: svdedxv.hxx:237
virtual SdrPageView * ShowSdrPage(SdrPage *pPage)
Definition: svdpntv.cxx:355
const rtl::Reference< sdr::SelectionController > & getSelectionController() const
Definition: svdedxv.hxx:278
virtual bool Command(const CommandEvent &, vcl::Window *)
Definition: svdpntv.hxx:457
virtual void AddWindowToPaintView(OutputDevice *pNewWin, vcl::Window *pWindow)
Definition: svdpntv.cxx:381
Abstract DrawObject.
Definition: svdobj.hxx:258
DECL_LINK(ImpComeBackHdl, Timer *, void)
sal_uInt16 nMacroTol
Definition: svdedxv.hxx:98
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
Definition: svdedtv1.cxx:1330
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: svdmrkv.cxx:199
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svdmrkv.cxx:333
vcl::Cursor * pTextEditCursorBuffer
Definition: svdedxv.hxx:88
OutlinerView * pTextEditOutlinerView
Definition: svdedxv.hxx:86
bool IsQuickTextEditMode() const
Definition: svdedxv.hxx:187
SdrPageView * pMacroPV
Definition: svdedxv.hxx:90
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SfxUndoManager * mpOldTextEditUndoManager
Definition: svdedxv.hxx:110
Point aMacroDownPos
Definition: svdedxv.hxx:96
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
void BegMacroObj(const Point &rPnt, SdrObject *pObj, SdrPageView *pPV, vcl::Window *pWin)
Definition: svdedxv.hxx:266
rtl::Reference< sdr::SelectionController > mxSelectionController
Definition: svdedxv.hxx:106
virtual void HideSdrPage() override
Definition: svdmrkv.cxx:352
SdrObject * pMacroObj
Definition: svdedxv.hxx:89