Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svdedxv.hxx
blob005000ddacbf21ba1dbbb2ae27e0dd77cc4bf29b
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 <memory>
30 class SdrOutliner;
31 class OutlinerView;
32 class EditStatus;
33 class EditFieldInfo;
34 class ImpSdrEditPara;
35 struct PasteOrDropInfos;
36 class SdrUndoManager;
38 namespace com { namespace sun { namespace star { namespace uno {
39 class Any;
40 } } } }
42 namespace sdr {
43 class SelectionController;
46 enum SdrEndTextEditKind {SDRENDTEXTEDIT_UNCHANGED, // textobject unchanged
47 SDRENDTEXTEDIT_CHANGED, // textobject changed
48 SDRENDTEXTEDIT_DELETED, // textobject implicitly deleted
49 SDRENDTEXTEDIT_SHOULDBEDELETED}; // for writer: textobject should be deleted
52 // - general edit for objectspecific properties
53 // - textedit for all drawobjects, inherited from SdrTextObj
54 // - macromod
57 class SVX_DLLPUBLIC SdrObjEditView: public SdrGlueEditView
59 friend class SdrPageView;
60 friend class ImpSdrEditPara;
62 protected:
63 // TextEdit
64 SdrObjectWeakRef mxTextEditObj; // current object in TextEdit
65 SdrPageView* pTextEditPV;
66 SdrOutliner* pTextEditOutliner; // outliner for the TextEdit
67 OutlinerView* pTextEditOutlinerView; // current view of the outliners
68 VclPtr<vcl::Window> pTextEditWin; // matching window to pTextEditOutlinerView
69 vcl::Cursor* pTextEditCursorMerker; // to restore the cursor in each window
70 ImpSdrEditPara* pEditPara; // trashbin for everything else to stay compatible
71 SdrObject* pMacroObj;
72 SdrPageView* pMacroPV;
73 VclPtr<vcl::Window> pMacroWin;
75 Rectangle aTextEditArea;
76 Rectangle aMinTextEditArea;
77 Link<> aOldCalcFieldValueLink; // for call the old handler
78 Point aMacroDownPos;
80 sal_uInt16 nMacroTol;
82 bool bTextEditDontDelete : 1; // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
83 bool bTextEditOnlyOneView : 1; // a single OutlinerView (f. spellchecking)
84 bool bTextEditNewObj : 1; // current edited object was just recreated
85 bool bQuickTextEditMode : 1; // persistent(->CrtV). Default=TRUE
86 bool bMacroMode : 1; // persistent(->CrtV). Default=TRUE
87 bool bMacroDown : 1;
89 rtl::Reference< sdr::SelectionController > mxSelectionController;
90 rtl::Reference< sdr::SelectionController > mxLastSelectionController;
92 private:
93 ::svl::IUndoManager* mpOldTextEditUndoManager;
95 SVX_DLLPRIVATE void ImpClearVars();
97 protected:
98 // central method to get an SdrUndoManager for enhanced TextEdit. Default will
99 // try to return a dynamic_casted GetModel()->GetSdrUndoManager(). Applications
100 // which want to use this feature will need to override this virtual method,
101 // provide their document UndoManager and derive it from SdrUndoManager.
102 virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const;
104 OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const;
106 // Create a new OutlinerView at the heap and initialize all required parameters.
107 // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
108 OutlinerView* ImpMakeOutlinerView(vcl::Window* pWin, bool bNoPaint, OutlinerView* pGivenView) const;
109 void ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect, OutputDevice& rTargetDevice) const;
110 void ImpInvalidateOutlinerView(OutlinerView& rOutlView) const;
112 // Check if the whole text is selected.
113 // Still returns sal_True if there is no text present.
114 bool ImpIsTextEditAllSelected() const;
115 void ImpMakeTextCursorAreaVisible();
117 // handler for AutoGrowing text with active Outliner
118 DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
119 DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
121 // link for EndTextEditHdl
122 DECL_LINK(EndTextEditHdl, SdrUndoManager*);
124 void ImpMacroUp(const Point& rUpPos);
125 void ImpMacroDown(const Point& rDownPos);
127 DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos* );
128 DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos* );
130 protected:
131 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
132 SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut = 0L);
133 virtual ~SdrObjEditView();
135 public:
137 // used to call the old ImpPaintOutlinerView. Will be replaced when the
138 // outliner will be displayed on the overlay in edit mode.
139 void TextEditDrawing(SdrPaintWindow& rPaintWindow) const;
141 // Actionhandling for macromod
142 virtual bool IsAction() const SAL_OVERRIDE;
143 virtual void MovAction(const Point& rPnt) SAL_OVERRIDE;
144 virtual void EndAction() SAL_OVERRIDE;
145 virtual void BrkAction() SAL_OVERRIDE;
146 virtual void BckAction() SAL_OVERRIDE;
147 virtual void TakeActionRect(Rectangle& rRect) const SAL_OVERRIDE;
149 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
150 virtual void ModelHasChanged() SAL_OVERRIDE;
153 // TextEdit over an outliner
155 // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
156 void SetQuickTextEditMode(bool bOn) { bQuickTextEditMode=bOn; }
157 bool IsQuickTextEditMode() const { return bQuickTextEditMode; }
159 // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
160 // The cursor of the currently edited window is stored with SdrBeginTextEdit()
161 // and restored with SdrEndTextEdit().
162 // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
163 // when SdrEndTextEdit is called.
164 // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
165 // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
166 // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
167 // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
168 // StatusEventHdl.
169 // Similarly a specific OutlinerView can be specified.
171 virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = 0L, vcl::Window* pWin = 0L, bool bIsNewObj = false,
172 SdrOutliner* pGivenOutliner = 0L, OutlinerView* pGivenOutlinerView = 0L,
173 bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true);
174 // bDontDeleteReally is a special parameter for writer
175 // If this flag is set, then a maybe empty textobject is not deleted.
176 // Instead you get a return code SDRENDTEXTEDIT_SHOULDBEDELETED
177 // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
178 // deleted.
179 virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false);
180 virtual bool IsTextEdit() const SAL_OVERRIDE;
182 // This method returns sal_True, if the point rHit is inside the
183 // objectspace or the OutlinerView.
184 bool IsTextEditHit(const Point& rHit, short nTol) const;
186 // This method returns sal_True, if the point rHit is inside the
187 // handle-thick frame, which surrounds the OutlinerView at TextFrames.
188 bool IsTextEditFrameHit(const Point& rHit) const;
190 // At active selection, between MouseButtonDown and
191 // MouseButtonUp, this method always returns TRUE.
192 bool IsTextEditInSelectionMode() const;
194 // If sb needs the object out of the TextEdit:
195 SdrObject* GetTextEditObject() const { return mxTextEditObj.get(); }
197 // info about TextEditPageView. Default is 0L.
198 virtual SdrPageView* GetTextEditPageView() const SAL_OVERRIDE;
200 // Current window of the outliners.
201 vcl::Window* GetTextEditWin() const { return pTextEditWin; }
202 void SetTextEditWin(vcl::Window* pWin);
204 // Now at this outliner, events can be send, attributes can be set,
205 // call Cut/Copy/Paste, call Undo/Redo, and so on...
206 const SdrOutliner* GetTextEditOutliner() const { return pTextEditOutliner; }
207 SdrOutliner* GetTextEditOutliner() { return pTextEditOutliner; }
208 const OutlinerView* GetTextEditOutlinerView() const { return pTextEditOutlinerView; }
209 OutlinerView* GetTextEditOutlinerView() { return pTextEditOutlinerView; }
211 virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) SAL_OVERRIDE;
212 virtual bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
213 virtual bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
214 virtual bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
215 virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) SAL_OVERRIDE;
217 // #97766# make virtual to change implementation e.g. for SdOutlineView
218 virtual SvtScriptType GetScriptType() const;
220 /* new interface src537 */
221 bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
223 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
224 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
225 bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
227 // Intern: at mounting new OutlinerView...
228 virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) SAL_OVERRIDE;
229 virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin) SAL_OVERRIDE;
231 sal_uInt16 GetSelectionLevel() const;
235 // Object-MacroModus (e.g. rect as button or sth. like that):
237 // Persistent. Default TRUE. SvDraw evaluates the flag e.g. at SdrView::GetPreferredPointer().
238 // Has only effect, if the document has draw-objects with macrofunctionality (SdrObject::HasMacro()==sal_True).
239 void SetMacroMode(bool bOn) { bMacroMode=bOn; }
240 bool IsMacroMode() const { return bMacroMode; }
241 bool BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin);
242 bool BegMacroObj(const Point& rPnt, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin) { return BegMacroObj(rPnt,-2,pObj,pPV,pWin); }
243 void MovMacroObj(const Point& rPnt);
244 void BrkMacroObj();
245 bool EndMacroObj();
246 bool IsMacroObj() const { return pMacroObj!=NULL; }
247 bool IsMacroObjDown() const { return bMacroDown; }
249 /** fills the given any with a XTextCursor for the current text selection.
250 Leaves the any untouched if there currently is no text selected */
251 void getTextSelection( ::com::sun::star::uno::Any& rSelection );
253 virtual void MarkListHasChanged() SAL_OVERRIDE;
255 rtl::Reference< sdr::SelectionController > getSelectionController() const { return mxSelectionController; }
257 /** returns true if the shape identified by its inventor and identifier supports format paint brush operation */
258 static bool SupportsFormatPaintbrush( sal_uInt32 nObjectInventor, sal_uInt16 nObjectIdentifier );
260 /** returns a format paint brush set from the current selection */
261 bool TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet );
263 /** applies a format paint brush set from the current selection.
264 if bNoCharacterFormats is true, no character attributes are changed.
265 if bNoParagraphFormats is true, no paragraph attributes are changed.
267 void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
269 /** helper function for selections with multiple SdrText for one SdrTextObj (f.e. tables ) */
270 static void ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats );
272 protected:
273 virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos );
274 virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos );
278 #endif // INCLUDED_SVX_SVDEDXV_HXX
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */