tdf#151073 - enable firebird for appstore build w/o experimental mode
[LibreOffice.git] / include / svx / svdedxv.hxx
blobe22670ac88cd8d68ed7c9f68a7b4fd1429f4224d
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;
82 protected:
83 // TextEdit
84 unotools::WeakReference<SdrTextObj> mxWeakTextEditObj; // current object in TextEdit
85 SdrPageView* mpTextEditPV;
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
90 vcl::Cursor* pTextEditCursorBuffer; // to restore the cursor in each window
91 SdrObject* pMacroObj;
92 SdrPageView* pMacroPV;
93 VclPtr<vcl::Window> pMacroWin;
95 tools::Rectangle aTextEditArea;
96 tools::Rectangle aMinTextEditArea;
97 Link<EditFieldInfo*,void> aOldCalcFieldValueLink; // for call the old handler
98 Point aMacroDownPos;
100 sal_uInt16 nMacroTol;
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;
108 rtl::Reference< sdr::SelectionController > mxSelectionController;
109 rtl::Reference< sdr::SelectionController > mxLastSelectionController;
111 private:
112 SfxUndoManager* mpOldTextEditUndoManager;
113 std::unique_ptr<SdrUndoManager> mpLocalTextEditUndoManager;
115 protected:
116 // Create a local UndoManager that is used for text editing.
117 virtual std::unique_ptr<SdrUndoManager> createLocalTextUndoManager();
119 void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
120 std::unique_ptr<TextChainCursorManager> ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool *bOutHandled);
122 OutlinerView* ImpFindOutlinerView(vcl::Window const * pWin) const;
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;
130 // Chaining
131 void ImpChainingEventHdl();
132 DECL_DLLPRIVATE_LINK(ImpAfterCutOrPasteChainingEventHdl, LinkParamNone*, void);
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();
140 // handler for AutoGrowing text with active Outliner
141 DECL_DLLPRIVATE_LINK(ImpOutlinerStatusEventHdl, EditStatus&, void);
142 DECL_DLLPRIVATE_LINK(ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, void);
144 // link for EndTextEditHdl
145 DECL_DLLPRIVATE_LINK(EndTextEditHdl, SdrUndoManager*, void);
147 void ImpMacroUp(const Point& rUpPos);
148 void ImpMacroDown(const Point& rDownPos);
150 DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos*, void );
151 DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos*, void );
153 protected:
154 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
155 SdrObjEditView(
156 SdrModel& rSdrModel,
157 OutputDevice* pOut);
159 virtual ~SdrObjEditView() override;
161 public:
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);
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;
175 SdrPageView* ShowSdrPage(SdrPage* pPage) override;
176 void HideSdrPage() override;
178 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
179 virtual void ModelHasChanged() override;
181 const std::unique_ptr<SdrUndoManager>& getViewLocalUndoManager() const
183 return mpLocalTextEditUndoManager;
186 // TextEdit over an outliner
188 // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
189 void SetQuickTextEditMode(bool bOn)
191 mbQuickTextEditMode = bOn;
193 bool IsQuickTextEditMode() const
195 return mbQuickTextEditMode;
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.
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;
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;
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;
229 // At active selection, between MouseButtonDown and
230 // MouseButtonUp, this method always returns TRUE.
231 bool IsTextEditInSelectionMode() const;
233 // If sb needs the object out of the TextEdit:
234 SdrTextObj* GetTextEditObject() const { return mxWeakTextEditObj.get().get(); }
236 // info about TextEditPageView. Default is 0L.
237 SdrPageView* GetTextEditPageView() const;
239 // Current window of the outliners.
240 void SetTextEditWin(vcl::Window* pWin);
242 // Now at this outliner, events can be send, attributes can be set,
243 // call Cut/Copy/Paste, call Undo/Redo, and so on...
244 const SdrOutliner* GetTextEditOutliner() const
246 return mpTextEditOutliner.get();
248 SdrOutliner* GetTextEditOutliner()
250 return mpTextEditOutliner.get();
252 const OutlinerView* GetTextEditOutlinerView() const
254 return mpTextEditOutlinerView;
256 OutlinerView* GetTextEditOutlinerView()
258 return mpTextEditOutlinerView;
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;
267 // #97766# make virtual to change implementation e.g. for SdOutlineView
268 virtual SvtScriptType GetScriptType() const;
270 /* new interface src537 */
271 void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
273 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
274 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
275 void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
277 // Intern: at mounting new OutlinerView...
278 virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) override;
279 virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin) override;
281 sal_uInt16 GetSelectionLevel() const;
284 // Object MacroMode (e.g. rect as button or sth. like that):
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; }
293 /** fills the given any with a XTextCursor for the current text selection.
294 Leaves the any untouched if there currently is no text selected */
295 void getTextSelection( css::uno::Any& rSelection );
297 virtual void MarkListHasChanged() override;
299 const rtl::Reference< sdr::SelectionController >& getSelectionController() const { return mxSelectionController; }
301 /** returns true if the shape identified by its inventor and identifier supports format paint brush operation */
302 static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor, SdrObjKind nObjectIdentifier );
304 /** returns a format paint brush set from the current selection */
305 void TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet );
307 /** applies a format paint brush set from the current selection.
308 if bNoCharacterFormats is true, no character attributes are changed.
309 if bNoParagraphFormats is true, no paragraph attributes are changed.
311 void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
313 /** helper function for selections with multiple SdrText for one SdrTextObj (f.e. tables ) */
314 static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats );
316 void DisposeUndoManager();
318 protected:
319 virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo );
320 virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo );
324 #endif // INCLUDED_SVX_SVDEDXV_HXX
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */