Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdedxv.hxx
Line
Count
Source
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>
27
#include <svx/selectioncontroller.hxx>
28
#include <editeng/editview.hxx>
29
#include <unotools/weakref.hxx>
30
#include <memory>
31
32
class SdrOutliner;
33
class OutlinerView;
34
class EditStatus;
35
class EditFieldInfo;
36
struct PasteOrDropInfos;
37
class SdrUndoManager;
38
class TextChainCursorManager;
39
40
namespace com::sun::star::uno {
41
    class Any;
42
}
43
44
namespace sdr {
45
    class SelectionController;
46
}
47
48
enum class SdrEndTextEditKind
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::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)
79
    sdr::overlay::OverlayObjectList maTEOverlayGroup;
80
    Timer                           maTextEditUpdateTimer;
81
82
    // IASS: allow reaction to active TextEdit changes
83
    DECL_DLLPRIVATE_LINK(ImpModifyHdl, LinkParamNone*, void);
84
85
    // IASS: timer-based reaction on TextEdit changes
86
    DECL_DLLPRIVATE_LINK(TextEditUpdate, Timer*, void);
87
88
protected:
89
    // TextEdit
90
    unotools::WeakReference<SdrTextObj> mxWeakTextEditObj; // current object in TextEdit
91
    SdrPageView* mpTextEditPV;
92
    std::unique_ptr<SdrOutliner> mpTextEditOutliner; // outliner for the TextEdit
93
    OutlinerView* mpTextEditOutlinerView; // current view of the outliners
94
    VclPtr<vcl::Window> mpTextEditWin; // matching window to pTextEditOutlinerView
95
96
    vcl::Cursor*                m_pTextEditCursorBuffer; // to restore the cursor in each window
97
    SdrObject*                  m_pMacroObj;
98
    SdrPageView*                m_pMacroPV;
99
    VclPtr<vcl::Window>         m_pMacroWin;
100
101
    tools::Rectangle            m_aTextEditArea;
102
    tools::Rectangle            m_aMinTextEditArea;
103
    Link<EditFieldInfo*,void>   m_aOldCalcFieldValueLink; // for call the old handler
104
    Point                       m_aMacroDownPos;
105
106
    sal_uInt16                  m_nMacroTol;
107
108
    bool mbTextEditDontDelete : 1;  // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
109
    bool mbTextEditOnlyOneView : 1; // a single OutlinerView (f. spellchecking)
110
    bool mbTextEditNewObj : 1;      // current edited object was just recreated
111
    bool mbQuickTextEditMode : 1;   // persistent(->CrtV). Default=TRUE
112
    bool mbMacroDown : 1;
113
    bool mbInteractiveSlideShow : 1; // IASS
114
115
    rtl::Reference< sdr::SelectionController > mxSelectionController;
116
    rtl::Reference< sdr::SelectionController > mxLastSelectionController;
117
118
    // check/set if we are in IASS and need to refresh evtl.
119
0
    void setInteractiveSlideShow(bool bNew) { mbInteractiveSlideShow = bNew; }
120
0
    bool isInteractiveSlideShow() const { return mbInteractiveSlideShow; }
121
122
private:
123
    EditUndoManager* mpOldTextEditUndoManager;
124
    std::unique_ptr<SdrUndoManager> mpLocalTextEditUndoManager;
125
126
protected:
127
    // Create a local UndoManager that is used for text editing.
128
    virtual std::unique_ptr<SdrUndoManager> createLocalTextUndoManager();
129
130
    void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
131
    std::unique_ptr<TextChainCursorManager> ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool *bOutHandled);
132
133
    OutlinerView* ImpFindOutlinerView(vcl::Window const * pWin) const;
134
135
    // Create a new OutlinerView at the heap and initialize all required parameters.
136
    // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
137
    OutlinerView* ImpMakeOutlinerView(vcl::Window* pWin, OutlinerView* pGivenView, SfxViewShell* pViewShell = nullptr) const;
138
    void ImpPaintOutlinerView(OutlinerView& rOutlView, const tools::Rectangle& rRect, OutputDevice& rTargetDevice) const;
139
    void ImpInvalidateOutlinerView(OutlinerView const & rOutlView) const;
140
141
    // Chaining
142
    void ImpChainingEventHdl();
143
    DECL_DLLPRIVATE_LINK(ImpAfterCutOrPasteChainingEventHdl, LinkParamNone*, void);
144
145
146
    // Check if the whole text is selected.
147
    // Still returns sal_True if there is no text present.
148
    bool ImpIsTextEditAllSelected() const;
149
    void ImpMakeTextCursorAreaVisible();
150
151
    // handler for AutoGrowing text with active Outliner
152
    DECL_DLLPRIVATE_LINK(ImpOutlinerStatusEventHdl, EditStatus&, void);
153
    DECL_DLLPRIVATE_LINK(ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, void);
154
155
    // link for EndTextEditHdl
156
    DECL_DLLPRIVATE_LINK(EndTextEditHdl, SdrUndoManager*, void);
157
158
    void ImpMacroUp(const Point& rUpPos);
159
    void ImpMacroDown(const Point& rDownPos);
160
161
    DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos*, void );
162
    DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos*, void );
163
164
protected:
165
    // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
166
    SdrObjEditView(
167
        SdrModel& rSdrModel,
168
        OutputDevice* pOut);
169
170
    virtual ~SdrObjEditView() override;
171
172
public:
173
174
    // used to call the old ImpPaintOutlinerView. Will be replaced when the
175
    // outliner will be displayed on the overlay in edit mode.
176
    void TextEditDrawing(SdrPaintWindow& rPaintWindow);
177
178
    // Actionhandling for macromode
179
    virtual bool IsAction() const override;
180
    virtual void MovAction(const Point& rPnt) override;
181
    virtual void EndAction() override;
182
    virtual void BrkAction() override;
183
    virtual void BckAction() override;
184
    virtual void TakeActionRect(tools::Rectangle& rRect) const override;
185
186
    SdrPageView* ShowSdrPage(SdrPage* pPage) override;
187
    void HideSdrPage() override;
188
189
    virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
190
    virtual void ModelHasChanged() override;
191
192
    const std::unique_ptr<SdrUndoManager>& getViewLocalUndoManager() const
193
0
    {
194
0
        return mpLocalTextEditUndoManager;
195
0
    }
196
197
    // TextEdit over an outliner
198
199
    // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
200
    void SetQuickTextEditMode(bool bOn)
201
0
    {
202
0
        mbQuickTextEditMode = bOn;
203
0
    }
204
    bool IsQuickTextEditMode() const
205
0
    {
206
0
        return mbQuickTextEditMode;
207
0
    }
208
209
    // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
210
    // The cursor of the currently edited window is stored with SdrBeginTextEdit()
211
    // and restored with SdrEndTextEdit().
212
    // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
213
    // when SdrEndTextEdit is called.
214
    // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
215
    // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
216
    // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
217
    // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
218
    // StatusEventHdl.
219
    // Similarly a specific OutlinerView can be specified.
220
221
    virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = nullptr, vcl::Window* pWin = nullptr, bool bIsNewObj = false,
222
        SdrOutliner* pGivenOutliner = nullptr, OutlinerView* pGivenOutlinerView = nullptr,
223
        bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true);
224
    // bDontDeleteReally is a special parameter for writer
225
    // If this flag is set, then a maybe empty textobject is not deleted.
226
    // Instead you get a return code SdrEndTextEditKind::ShouldBeDeleted
227
    // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
228
    // deleted.
229
    virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false);
230
    virtual bool IsTextEdit() const final override;
231
232
    // This method returns sal_True, if the point rHit is inside the
233
    // objectspace or the OutlinerView.
234
    bool IsTextEditHit(const Point& rHit) const;
235
236
    // This method returns sal_True, if the point rHit is inside the
237
    // handle-thick frame, which surrounds the OutlinerView at TextFrames.
238
    bool IsTextEditFrameHit(const Point& rHit) const;
239
240
    // At active selection, between MouseButtonDown and
241
    // MouseButtonUp, this method always returns TRUE.
242
    bool IsTextEditInSelectionMode() const;
243
244
    // If sb needs the object out of the TextEdit:
245
0
    SdrTextObj* GetTextEditObject() const { return mxWeakTextEditObj.get().get(); }
246
247
    // info about TextEditPageView. Default is 0L.
248
    SdrPageView* GetTextEditPageView() const;
249
250
    // Current window of the outliners.
251
    void SetTextEditWin(vcl::Window* pWin);
252
253
    // Now at this outliner, events can be send, attributes can be set,
254
    // call Cut/Copy/Paste, call Undo/Redo, and so on...
255
    virtual const SdrOutliner* GetTextEditOutliner() const
256
0
    {
257
0
        return mpTextEditOutliner.get();
258
0
    }
259
    virtual SdrOutliner* GetTextEditOutliner()
260
0
    {
261
0
        return mpTextEditOutliner.get();
262
0
    }
263
    virtual const OutlinerView* GetTextEditOutlinerView() const
264
0
    {
265
0
        return mpTextEditOutlinerView;
266
0
    }
267
    virtual OutlinerView* GetTextEditOutlinerView()
268
0
    {
269
0
        return mpTextEditOutlinerView;
270
0
    }
271
272
    virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
273
    virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
274
    virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
275
    virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
276
    virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
277
278
    // #97766# make virtual to change implementation e.g. for SdOutlineView
279
    virtual SvtScriptType GetScriptType() const;
280
281
    /* new interface src537 */
282
    void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
283
284
    bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
285
    SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
286
    void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
287
288
    // Intern: at mounting new OutlinerView...
289
    virtual void AddDeviceToPaintView(OutputDevice& rNewDev, vcl::Window* pWindow) override;
290
    virtual void DeleteDeviceFromPaintView(OutputDevice& rOldWin) override;
291
292
    sal_uInt16 GetSelectionLevel() const;
293
294
295
    // Object MacroMode (e.g. rect as button or sth. like that):
296
297
    void BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin);
298
0
    void BegMacroObj(const Point& rPnt, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin) { BegMacroObj(rPnt,-2,pObj,pPV,pWin); }
299
    void MovMacroObj(const Point& rPnt);
300
    void BrkMacroObj();
301
    bool EndMacroObj();
302
0
    bool IsMacroObj() const { return m_pMacroObj!=nullptr; }
303
304
    /** fills the given any with a XTextCursor for the current text selection.
305
        Leaves the any untouched if there currently is no text selected */
306
    void getTextSelection( css::uno::Any& rSelection );
307
308
    virtual void MarkListHasChanged() override;
309
310
0
    const rtl::Reference< sdr::SelectionController >& getSelectionController() const { return mxSelectionController; }
311
312
    /** returns true if the shape identified by its inventor and identifier supports format paint brush operation */
313
    static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor, SdrObjKind nObjectIdentifier );
314
315
    /** fills a format paint brush set from the current selection and returns the numbering depth */
316
    sal_Int32 TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet  );
317
318
    /** applies a format paint brush set from the current selection.
319
        if bNoCharacterFormats is true, no character attributes are changed.
320
        if bNoParagraphFormats is true, no paragraph attributes are changed.
321
    */
322
    void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, sal_Int16 nDepth, bool bNoCharacterFormats, bool bNoParagraphFormats );
323
324
    /** helper function for selections with multiple SdrText for one SdrTextObj (f.e. tables ) */
325
    static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, SdrTextObj& rTextObj, SdrText* pText, sal_Int16 nDepth, bool bNoCharacterFormats, bool bNoParagraphFormats );
326
327
    void DisposeUndoManager();
328
329
protected:
330
    virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo );
331
    virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo );
332
333
};
334
335
#endif // INCLUDED_SVX_SVDEDXV_HXX
336
337
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */