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 
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::clipboard::XClipboard> GetClipboard() const override;
73  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() override;
74  virtual void EditViewInputContext(const InputContext& rInputContext) override;
75  virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) override;
76 
77  // The OverlayObjects used for visualizing active TextEdit (currently
78  // using TextEditOverlayObject, but not limited to it
80 
81 protected:
82  // TextEdit
83  tools::WeakReference<SdrTextObj> mxTextEditObj; // current object in TextEdit
85  std::unique_ptr<SdrOutliner> mpTextEditOutliner; // outliner for the TextEdit
86  OutlinerView* mpTextEditOutlinerView; // current view of the outliners
87  VclPtr<vcl::Window> mpTextEditWin; // matching window to pTextEditOutlinerView
88 
89  vcl::Cursor* pTextEditCursorBuffer; // to restore the cursor in each window
93 
98 
99  sal_uInt16 nMacroTol;
100 
101  bool mbTextEditDontDelete : 1; // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
102  bool mbTextEditOnlyOneView : 1; // a single OutlinerView (f. spellchecking)
103  bool mbTextEditNewObj : 1; // current edited object was just recreated
104  bool mbQuickTextEditMode : 1; // persistent(->CrtV). Default=TRUE
105  bool mbMacroDown : 1;
106 
109 
110 private:
112  std::unique_ptr<SdrUndoManager> mpLocalTextEditUndoManager;
113 
114 protected:
115  // Create a local UndoManager that is used for text editing.
116  virtual std::unique_ptr<SdrUndoManager> createLocalTextUndoManager();
117 
118  void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
119  std::unique_ptr<TextChainCursorManager> ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool *bOutHandled);
120 
121  OutlinerView* ImpFindOutlinerView(vcl::Window const * pWin) const;
122 
123  // Create a new OutlinerView at the heap and initialize all required parameters.
124  // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
125  OutlinerView* ImpMakeOutlinerView(vcl::Window* pWin, OutlinerView* pGivenView, SfxViewShell* pViewShell = nullptr) const;
126  void ImpPaintOutlinerView(OutlinerView& rOutlView, const tools::Rectangle& rRect, OutputDevice& rTargetDevice) const;
127  void ImpInvalidateOutlinerView(OutlinerView const & rOutlView) const;
128 
129  // Chaining
130  void ImpChainingEventHdl();
131  DECL_LINK(ImpAfterCutOrPasteChainingEventHdl, LinkParamNone*, void);
132 
133 
134  // Check if the whole text is selected.
135  // Still returns sal_True if there is no text present.
136  bool ImpIsTextEditAllSelected() const;
137  void ImpMakeTextCursorAreaVisible();
138 
139  // handler for AutoGrowing text with active Outliner
140  DECL_LINK(ImpOutlinerStatusEventHdl, EditStatus&, void);
141  DECL_LINK(ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, void);
142 
143  // link for EndTextEditHdl
144  DECL_LINK(EndTextEditHdl, SdrUndoManager*, void);
145 
146  void ImpMacroUp(const Point& rUpPos);
147  void ImpMacroDown(const Point& rDownPos);
148 
149  DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos*, void );
150  DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos*, void );
151 
152 protected:
153  // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
155  SdrModel& rSdrModel,
156  OutputDevice* pOut);
157 
158  virtual ~SdrObjEditView() override;
159 
160 public:
161 
162  // used to call the old ImpPaintOutlinerView. Will be replaced when the
163  // outliner will be displayed on the overlay in edit mode.
164  void TextEditDrawing(SdrPaintWindow& rPaintWindow);
165 
166  // Actionhandling for macromode
167  virtual bool IsAction() const override;
168  virtual void MovAction(const Point& rPnt) override;
169  virtual void EndAction() override;
170  virtual void BrkAction() override;
171  virtual void BckAction() override;
172  virtual void TakeActionRect(tools::Rectangle& rRect) const override;
173 
174  SdrPageView* ShowSdrPage(SdrPage* pPage) override;
175  void HideSdrPage() override;
176 
177  virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
178  virtual void ModelHasChanged() override;
179 
180  const std::unique_ptr<SdrUndoManager>& getViewLocalUndoManager() const
181  {
182  return mpLocalTextEditUndoManager;
183  }
184 
185  // TextEdit over an outliner
186 
187  // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
188  void SetQuickTextEditMode(bool bOn)
189  {
190  mbQuickTextEditMode = bOn;
191  }
192  bool IsQuickTextEditMode() const
193  {
194  return mbQuickTextEditMode;
195  }
196 
197  // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
198  // The cursor of the currently edited window is stored with SdrBeginTextEdit()
199  // and restored with SdrEndTextEdit().
200  // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
201  // when SdrEndTextEdit is called.
202  // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
203  // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
204  // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
205  // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
206  // StatusEventHdl.
207  // Similarly a specific OutlinerView can be specified.
208 
209  virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = nullptr, vcl::Window* pWin = nullptr, bool bIsNewObj = false,
210  SdrOutliner* pGivenOutliner = nullptr, OutlinerView* pGivenOutlinerView = nullptr,
211  bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true);
212  // bDontDeleteReally is a special parameter for writer
213  // If this flag is set, then a maybe empty textobject is not deleted.
214  // Instead you get a return code SdrEndTextEditKind::ShouldBeDeleted
215  // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
216  // deleted.
217  virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false);
218  virtual bool IsTextEdit() const final override;
219 
220  // This method returns sal_True, if the point rHit is inside the
221  // objectspace or the OutlinerView.
222  bool IsTextEditHit(const Point& rHit) const;
223 
224  // This method returns sal_True, if the point rHit is inside the
225  // handle-thick frame, which surrounds the OutlinerView at TextFrames.
226  bool IsTextEditFrameHit(const Point& rHit) const;
227 
228  // At active selection, between MouseButtonDown and
229  // MouseButtonUp, this method always returns TRUE.
230  bool IsTextEditInSelectionMode() const;
231 
232  // If sb needs the object out of the TextEdit:
233  SdrTextObj* GetTextEditObject() const { return mxTextEditObj.get(); }
234 
235  // info about TextEditPageView. Default is 0L.
236  SdrPageView* GetTextEditPageView() const;
237 
238  // Current window of the outliners.
239  void SetTextEditWin(vcl::Window* pWin);
240 
241  // Now at this outliner, events can be send, attributes can be set,
242  // call Cut/Copy/Paste, call Undo/Redo, and so on...
244  {
245  return mpTextEditOutliner.get();
246  }
248  {
249  return mpTextEditOutliner.get();
250  }
252  {
253  return mpTextEditOutlinerView;
254  }
256  {
257  return mpTextEditOutlinerView;
258  }
259 
260  virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
261  virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
262  virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
263  virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
264  virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
265 
266  // #97766# make virtual to change implementation e.g. for SdOutlineView
267  virtual SvtScriptType GetScriptType() const;
268 
269  /* new interface src537 */
270  void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
271 
272  bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
273  SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
274  void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
275 
276  // Intern: at mounting new OutlinerView...
277  virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) override;
278  virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin) override;
279 
280  sal_uInt16 GetSelectionLevel() const;
281 
282 
283  // Object MacroMode (e.g. rect as button or sth. like that):
284 
285  void BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin);
286  void BegMacroObj(const Point& rPnt, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin) { BegMacroObj(rPnt,-2,pObj,pPV,pWin); }
287  void MovMacroObj(const Point& rPnt);
288  void BrkMacroObj();
289  bool EndMacroObj();
290  bool IsMacroObj() const { return pMacroObj!=nullptr; }
291 
294  void getTextSelection( css::uno::Any& rSelection );
295 
296  virtual void MarkListHasChanged() override;
297 
298  const rtl::Reference< sdr::SelectionController >& getSelectionController() const { return mxSelectionController; }
299 
301  static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor, sal_uInt16 nObjectIdentifier );
302 
304  void TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet );
305 
310  void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
311 
313  static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats );
314 
315  void DisposeUndoManager();
316 
317 protected:
318  virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo );
319  virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo );
320 
321 };
322 
323 #endif // INCLUDED_SVX_SVDEDXV_HXX
324 
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void EditViewInvalidate(const tools::Rectangle &rRect)=0
virtual bool MouseButtonUp(const MouseEvent &, OutputDevice *)
Definition: svdpntv.hxx:449
virtual bool IsTextEdit() const
Definition: svdpntv.cxx:297
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdedtv1.cxx:1306
OString OOO_DLLPUBLIC_TEST getTextSelection(const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable, OString mimeType)
virtual Point EditViewPointerPosPixel() const =0
bool IsMacroObj() const
Definition: svdedxv.hxx:290
rtl::Reference< sdr::SelectionController > mxLastSelectionController
Definition: svdedxv.hxx:108
virtual void DeleteWindowFromPaintView(OutputDevice *pOldWin)
Definition: svdpntv.cxx:394
tools::Rectangle aMinTextEditArea
Definition: svdedxv.hxx:95
const std::unique_ptr< SdrUndoManager > & getViewLocalUndoManager() const
Definition: svdedxv.hxx:180
SdrEndTextEditKind
Definition: svdedxv.hxx:48
virtual void BckAction() override
Definition: svdmrkv.cxx:323
std::unique_ptr< SdrOutliner > mpTextEditOutliner
Definition: svdedxv.hxx:85
SdrInventor
Definition: svdobj.hxx:99
SdrOutliner * GetTextEditOutliner()
Definition: svdedxv.hxx:247
virtual void BrkAction() override
Definition: svdmrkv.cxx:331
virtual bool MouseButtonDown(const MouseEvent &, OutputDevice *)
Definition: svdpntv.hxx:448
virtual bool MouseMove(const MouseEvent &rMEvt, OutputDevice *pWin) override
handle mouse over effects for handles
Definition: svdmrkv.cxx:1613
OutlinerView * mpTextEditOutlinerView
Definition: svdedxv.hxx:86
std::unique_ptr< SdrUndoManager > mpLocalTextEditUndoManager
Definition: svdedxv.hxx:112
tools::Rectangle aTextEditArea
Definition: svdedxv.hxx:94
virtual void ModelHasChanged() override
Definition: svdedtv.cxx:385
virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const =0
SfxStyleSheet * GetStyleSheet() const
Definition: svdedtv1.cxx:1327
void SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdedtv1.cxx:1318
virtual bool KeyInput(const KeyEvent &rKEvt, vcl::Window *pWin)
Definition: svdpntv.cxx:777
sdr::overlay::OverlayObjectList maTEOverlayGroup
Definition: svdedxv.hxx:79
const SdrOutliner * GetTextEditOutliner() const
Definition: svdedxv.hxx:243
SvtScriptType
virtual void MarkListHasChanged() override
Definition: svdedtv.cxx:379
tools::WeakReference< SdrTextObj > mxTextEditObj
Definition: svdedxv.hxx:83
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
VclPtr< vcl::Window > pMacroWin
Definition: svdedxv.hxx:92
virtual void MovAction(const Point &rPnt) override
Definition: svdmrkv.cxx:287
void SetQuickTextEditMode(bool bOn)
Definition: svdedxv.hxx:188
virtual bool IsAction() const override
Definition: svdmrkv.cxx:282
Link< EditFieldInfo *, void > aOldCalcFieldValueLink
Definition: svdedxv.hxx:96
OutlinerView * GetTextEditOutlinerView()
Definition: svdedxv.hxx:255
const OutlinerView * GetTextEditOutlinerView() const
Definition: svdedxv.hxx:251
virtual SdrPageView * ShowSdrPage(SdrPage *pPage)
Definition: svdpntv.cxx:356
const rtl::Reference< sdr::SelectionController > & getSelectionController() const
Definition: svdedxv.hxx:298
virtual bool Command(const CommandEvent &, vcl::Window *)
Definition: svdpntv.hxx:452
virtual void AddWindowToPaintView(OutputDevice *pNewWin, vcl::Window *pWindow)
Definition: svdpntv.cxx:382
Abstract DrawObject.
Definition: svdobj.hxx:259
DECL_LINK(ImpComeBackHdl, Timer *, void)
sal_uInt16 nMacroTol
Definition: svdedxv.hxx:99
virtual OutputDevice & EditViewOutputDevice() const =0
virtual void EditViewSelectionChange()=0
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
Definition: svdedtv1.cxx:1336
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: svdmrkv.cxx:199
reference_type * get() const
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svdmrkv.cxx:339
vcl::Cursor * pTextEditCursorBuffer
Definition: svdedxv.hxx:89
bool IsQuickTextEditMode() const
Definition: svdedxv.hxx:192
SdrPageView * pMacroPV
Definition: svdedxv.hxx:91
SdrPageView * mpTextEditPV
Definition: svdedxv.hxx:84
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SfxUndoManager * mpOldTextEditUndoManager
Definition: svdedxv.hxx:111
Point aMacroDownPos
Definition: svdedxv.hxx:97
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:286
rtl::Reference< sdr::SelectionController > mxSelectionController
Definition: svdedxv.hxx:107
VclPtr< vcl::Window > mpTextEditWin
Definition: svdedxv.hxx:87
virtual void HideSdrPage() override
Definition: svdmrkv.cxx:358
SdrObject * pMacroObj
Definition: svdedxv.hxx:90
virtual void EditViewInputContext(const InputContext &rInputContext)=0
virtual void EditViewCursorRect(const tools::Rectangle &rRect, int nExtTextInputWidth)=0