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