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