1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDEDXV_HXX
21 #define INCLUDED_SVX_SVDEDXV_HXX
23 #include <rtl/ref.hxx>
24 #include <svl/languageoptions.hxx>
25 #include <svx/svxdllapi.h>
26 #include <svx/svdglev.hxx>
27 #include <svx/selectioncontroller.hxx>
28 #include <editeng/editview.hxx>
36 struct PasteOrDropInfos
;
38 class TextChainCursorManager
;
40 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
45 class SelectionController
;
48 enum class SdrEndTextEditKind
50 Unchanged
, // textobject unchanged
51 Changed
, // textobject changed
52 Deleted
, // textobject implicitly deleted
53 ShouldBeDeleted
// for writer: textobject should be deleted
56 // - general edit for objectspecific properties
57 // - textedit for all drawobjects, inherited from SdrTextObj
61 class SVX_DLLPUBLIC SdrObjEditView
: public SdrGlueEditView
, public EditViewCallbacks
63 friend class SdrPageView
;
64 friend class ImpSdrEditPara
;
66 // Now derived from EditViewCallbacks and overriding these callbacks to
67 // allow own EditText visualization
68 virtual void EditViewInvalidate(const tools::Rectangle
& rRect
) const override
;
69 virtual void EditViewSelectionChange() const override
;
70 virtual OutputDevice
& EditViewOutputDevice() const override
;
72 // The OverlayObjects used for visualizing active TextEdit (currently
73 // using TextEditOverlayObject, but not limited to it
74 sdr::overlay::OverlayObjectList maTEOverlayGroup
;
78 tools::WeakReference
<SdrTextObj
>
79 mxTextEditObj
; // current object in TextEdit
80 SdrPageView
* pTextEditPV
;
81 std::unique_ptr
<SdrOutliner
> pTextEditOutliner
; // outliner for the TextEdit
82 OutlinerView
* pTextEditOutlinerView
; // current view of the outliners
83 VclPtr
<vcl::Window
> pTextEditWin
; // matching window to pTextEditOutlinerView
84 vcl::Cursor
* pTextEditCursorBuffer
; // to restore the cursor in each window
86 SdrPageView
* pMacroPV
;
87 VclPtr
<vcl::Window
> pMacroWin
;
89 tools::Rectangle aTextEditArea
;
90 tools::Rectangle aMinTextEditArea
;
91 Link
<EditFieldInfo
*,void> aOldCalcFieldValueLink
; // for call the old handler
96 bool bTextEditDontDelete
: 1; // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
97 bool bTextEditOnlyOneView
: 1; // a single OutlinerView (f. spellchecking)
98 bool bTextEditNewObj
: 1; // current edited object was just recreated
99 bool bQuickTextEditMode
: 1; // persistent(->CrtV). Default=TRUE
102 rtl::Reference
< sdr::SelectionController
> mxSelectionController
;
103 rtl::Reference
< sdr::SelectionController
> mxLastSelectionController
;
106 SfxUndoManager
* mpOldTextEditUndoManager
;
108 SVX_DLLPRIVATE
void ImpClearVars();
111 // central method to get an SdrUndoManager for enhanced TextEdit. Default will
112 // try to return a dynamic_casted GetModel()->GetSdrUndoManager(). Applications
113 // which want to use this feature will need to override this virtual method,
114 // provide their document UndoManager and derive it from SdrUndoManager.
115 virtual SdrUndoManager
* getSdrUndoManagerForEnhancedTextEdit() const;
117 void ImpMoveCursorAfterChainingEvent(TextChainCursorManager
*pCursorManager
);
118 TextChainCursorManager
*ImpHandleMotionThroughBoxesKeyInput(const KeyEvent
& rKEvt
, bool *bOutHandled
);
121 OutlinerView
* ImpFindOutlinerView(vcl::Window
const * pWin
) const;
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;
130 void ImpChainingEventHdl();
131 DECL_LINK(ImpAfterCutOrPasteChainingEventHdl
, LinkParamNone
*, void);
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();
139 // handler for AutoGrowing text with active Outliner
140 DECL_LINK(ImpOutlinerStatusEventHdl
, EditStatus
&, void);
141 DECL_LINK(ImpOutlinerCalcFieldValueHdl
, EditFieldInfo
*, void);
143 // link for EndTextEditHdl
144 DECL_LINK(EndTextEditHdl
, SdrUndoManager
*, void);
146 void ImpMacroUp(const Point
& rUpPos
);
147 void ImpMacroDown(const Point
& rDownPos
);
149 DECL_LINK( BeginPasteOrDropHdl
, PasteOrDropInfos
*, void );
150 DECL_LINK( EndPasteOrDropHdl
, PasteOrDropInfos
*, void );
153 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
158 virtual ~SdrObjEditView() override
;
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
) const;
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
;
174 SdrPageView
* ShowSdrPage(SdrPage
* pPage
) override
;
175 void HideSdrPage() override
;
177 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
178 virtual void ModelHasChanged() override
;
181 // TextEdit over an outliner
183 // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
184 void SetQuickTextEditMode(bool bOn
) { bQuickTextEditMode
=bOn
; }
185 bool IsQuickTextEditMode() const { return bQuickTextEditMode
; }
187 // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
188 // The cursor of the currently edited window is stored with SdrBeginTextEdit()
189 // and restored with SdrEndTextEdit().
190 // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
191 // when SdrEndTextEdit is called.
192 // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
193 // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
194 // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
195 // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
197 // Similarly a specific OutlinerView can be specified.
199 virtual bool SdrBeginTextEdit(SdrObject
* pObj
, SdrPageView
* pPV
= nullptr, vcl::Window
* pWin
= nullptr, bool bIsNewObj
= false,
200 SdrOutliner
* pGivenOutliner
= nullptr, OutlinerView
* pGivenOutlinerView
= nullptr,
201 bool bDontDeleteOutliner
= false, bool bOnlyOneView
= false, bool bGrabFocus
= true);
202 // bDontDeleteReally is a special parameter for writer
203 // If this flag is set, then a maybe empty textobject is not deleted.
204 // Instead you get a return code SdrEndTextEditKind::ShouldBeDeleted
205 // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
207 virtual SdrEndTextEditKind
SdrEndTextEdit(bool bDontDeleteReally
= false);
208 virtual bool IsTextEdit() const final override
;
210 // This method returns sal_True, if the point rHit is inside the
211 // objectspace or the OutlinerView.
212 bool IsTextEditHit(const Point
& rHit
) const;
214 // This method returns sal_True, if the point rHit is inside the
215 // handle-thick frame, which surrounds the OutlinerView at TextFrames.
216 bool IsTextEditFrameHit(const Point
& rHit
) const;
218 // At active selection, between MouseButtonDown and
219 // MouseButtonUp, this method always returns TRUE.
220 bool IsTextEditInSelectionMode() const;
222 // If sb needs the object out of the TextEdit:
223 SdrTextObj
* GetTextEditObject() const { return mxTextEditObj
.get(); }
225 // info about TextEditPageView. Default is 0L.
226 SdrPageView
* GetTextEditPageView() const;
228 // Current window of the outliners.
229 void SetTextEditWin(vcl::Window
* pWin
);
231 // Now at this outliner, events can be send, attributes can be set,
232 // call Cut/Copy/Paste, call Undo/Redo, and so on...
233 const SdrOutliner
* GetTextEditOutliner() const { return pTextEditOutliner
.get(); }
234 SdrOutliner
* GetTextEditOutliner() { return pTextEditOutliner
.get(); }
235 const OutlinerView
* GetTextEditOutlinerView() const { return pTextEditOutlinerView
; }
236 OutlinerView
* GetTextEditOutlinerView() { return pTextEditOutlinerView
; }
238 virtual bool KeyInput(const KeyEvent
& rKEvt
, vcl::Window
* pWin
) override
;
239 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) override
;
240 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) override
;
241 virtual bool MouseMove(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) override
;
242 virtual bool Command(const CommandEvent
& rCEvt
, vcl::Window
* pWin
) override
;
244 // #97766# make virtual to change implementation e.g. for SdOutlineView
245 virtual SvtScriptType
GetScriptType() const;
247 /* new interface src537 */
248 void GetAttributes(SfxItemSet
& rTargetSet
, bool bOnlyHardAttr
) const;
250 bool SetAttributes(const SfxItemSet
& rSet
, bool bReplaceAll
);
251 SfxStyleSheet
* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
252 void SetStyleSheet(SfxStyleSheet
* pStyleSheet
, bool bDontRemoveHardAttr
);
254 // Intern: at mounting new OutlinerView...
255 virtual void AddWindowToPaintView(OutputDevice
* pNewWin
, vcl::Window
* pWindow
) override
;
256 virtual void DeleteWindowFromPaintView(OutputDevice
* pOldWin
) override
;
258 sal_uInt16
GetSelectionLevel() const;
261 // Object MacroMode (e.g. rect as button or sth. like that):
263 void BegMacroObj(const Point
& rPnt
, short nTol
, SdrObject
* pObj
, SdrPageView
* pPV
, vcl::Window
* pWin
);
264 void BegMacroObj(const Point
& rPnt
, SdrObject
* pObj
, SdrPageView
* pPV
, vcl::Window
* pWin
) { BegMacroObj(rPnt
,-2,pObj
,pPV
,pWin
); }
265 void MovMacroObj(const Point
& rPnt
);
268 bool IsMacroObj() const { return pMacroObj
!=nullptr; }
270 /** fills the given any with a XTextCursor for the current text selection.
271 Leaves the any untouched if there currently is no text selected */
272 void getTextSelection( css::uno::Any
& rSelection
);
274 virtual void MarkListHasChanged() override
;
276 const rtl::Reference
< sdr::SelectionController
>& getSelectionController() const { return mxSelectionController
; }
278 /** returns true if the shape identified by its inventor and identifier supports format paint brush operation */
279 static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor
, sal_uInt16 nObjectIdentifier
);
281 /** returns a format paint brush set from the current selection */
282 void TakeFormatPaintBrush( std::shared_ptr
< SfxItemSet
>& rFormatSet
);
284 /** applies a format paint brush set from the current selection.
285 if bNoCharacterFormats is true, no character attributes are changed.
286 if bNoParagraphFormats is true, no paragraph attributes are changed.
288 void ApplyFormatPaintBrush( SfxItemSet
& rFormatSet
, bool bNoCharacterFormats
, bool bNoParagraphFormats
);
290 /** helper function for selections with multiple SdrText for one SdrTextObj (f.e. tables ) */
291 static void ApplyFormatPaintBrushToText( SfxItemSet
const & rFormatSet
, SdrTextObj
& rTextObj
, SdrText
* pText
, bool bNoCharacterFormats
, bool bNoParagraphFormats
);
294 virtual void OnBeginPasteOrDrop( PasteOrDropInfos
* pInfo
);
295 virtual void OnEndPasteOrDrop( PasteOrDropInfos
* pInfo
);
299 #endif // INCLUDED_SVX_SVDEDXV_HXX
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */