LibreOffice Module sc (master)  1
tabvwsh.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include <formula/errorcodes.hxx>
23 #include <formula/opcode.hxx>
24 #include <svx/fmshell.hxx>
25 #include <sfx2/viewsh.hxx>
26 #include <editeng/svxenum.hxx>
27 #include <o3tl/deleter.hxx>
28 #include <scdllapi.h>
29 #include "dbfunc.hxx"
30 #include "target.hxx"
31 #include <shellids.hxx>
32 #include <tabprotection.hxx>
33 #include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp>
34 
35 #include <memory>
36 #include <map>
37 
38 class SdrOle2Obj;
39 class SfxBindings;
40 class SfxChildWindow;
41 class SvxNumberInfoItem;
42 struct SfxChildWinInfo;
43 
44 class ScArea;
45 class ScAuditingShell;
46 class ScDrawShell;
48 class ScEditShell;
49 class ScInputHandler;
50 class ScPivotShell;
51 class ScDrawFormShell;
52 class ScCellShell;
53 class ScOleObjectShell;
54 class ScGraphicShell;
55 class ScMediaShell;
56 class ScChartShell;
57 class ScPageBreakShell;
58 class ScDPObject;
60 class ScRangeName;
61 
62 struct ScHeaderFieldData;
63 
64 namespace editeng { class SvxBorderLine; }
65 
66 namespace com::sun::star::frame { class XDispatchProviderInterceptor; }
67 
68 namespace svx {
69  class ExtrusionBar;
70  class FontworkBar;
71 }
72 
74 {
87 };
88 
89 class ScFormEditData;
91 {
92 private:
94  sal_uInt16 nDrawSfxId;
96  OUString sDrawCustom; // current custom shape type
97  std::unique_ptr<ScDrawShell> pDrawShell;
98  std::unique_ptr<ScDrawTextObjectBar> pDrawTextShell;
99  std::unique_ptr<ScEditShell> pEditShell;
100  std::unique_ptr<ScPivotShell> pPivotShell;
101  std::unique_ptr<ScAuditingShell> pAuditingShell;
102  std::unique_ptr<ScDrawFormShell> pDrawFormShell;
103  std::unique_ptr<ScCellShell> pCellShell;
104  std::unique_ptr<ScOleObjectShell> pOleObjectShell;
105  std::unique_ptr<ScChartShell> pChartShell;
106  std::unique_ptr<ScGraphicShell> pGraphicShell;
107  std::unique_ptr<ScMediaShell> pMediaShell;
108  std::unique_ptr<ScPageBreakShell> pPageBreakShell;
109  std::unique_ptr<svx::ExtrusionBar> pExtrusionBarShell;
110  std::unique_ptr<svx::FontworkBar> pFontworkBarShell;
111 
112  std::unique_ptr<FmFormShell> pFormShell;
113 
114  std::unique_ptr<ScFormEditData> mpFormEditData;
115  std::unique_ptr<ScInputHandler, o3tl::default_delete<ScInputHandler>> mpInputHandler; // for OLE input cell
116 
117  std::unique_ptr<::editeng::SvxBorderLine> pCurFrameLine;
118 
119  css::uno::Reference< css::frame::XDispatchProviderInterceptor >
121 
123 
125  std::unique_ptr<ScDPObject> pDialogDPObject;
126 
127  std::unique_ptr<ScNavigatorSettings> pNavSettings;
128 
129  // used in first Activate
131 
140 
141  bool bFormShellAtTop; // does the FormShell need to be on top?
142 
143  bool bDontSwitch; // Don't turn off EditShell
144  bool bInFormatDialog; // for GetSelectionText
145 
146  bool bReadOnly; // to detect status changes
147 
148  bool bIsActive;
149 
150  bool bForceFocusOnCurCell; // #i123629#
151 
154 
155  sal_uInt16 nCurRefDlgId;
156 
157  std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster;
158 
159  // ugly hack for Add button in ScNameDlg
160  std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap;
162  OUString maName;
163  OUString maScope;
164 private:
165  void Construct( TriState nForceDesignMode );
166 
167  SfxShell* GetMySubShell() const;
168 
169  void DoReadUserData( const OUString& rData );
170  void DoReadUserDataSequence( const css::uno::Sequence< css::beans::PropertyValue >& rSettings );
171  bool IsSignatureLineSelected();
172  bool IsSignatureLineSigned();
173  bool IsQRCodeSelected();
174 
175  DECL_LINK( SimpleRefClose, const OUString*, void );
176  DECL_LINK( SimpleRefDone, const OUString&, void );
177  DECL_LINK( SimpleRefAborted, const OUString&, void );
178  DECL_LINK( SimpleRefChange, const OUString&, void );
179  DECL_LINK( FormControlActivated, LinkParamNone*, void );
180  DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void );
181 
182 protected:
183  virtual void Activate(bool bMDI) override;
184  virtual void Deactivate(bool bMDI) override;
185  virtual bool PrepareClose( bool bUI = true ) override;
186 
187  virtual void ShowCursor(bool bOn) override;
188 
189  virtual void Move() override; // notification
190 
191  virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) override; // new
192  virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) override;
193  virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) override;
194 
195  virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override;
196 
197  virtual OUString GetSelectionText( bool bWholeWord = false ) override;
198  virtual bool HasSelection( bool bText = true ) const override;
199 
200  virtual void WriteUserData(OUString &, bool bBrowse = false) override;
201  virtual void ReadUserData(const OUString &, bool bBrowse = false) override;
202  virtual void WriteUserDataSequence (css::uno::Sequence < css::beans::PropertyValue >& ) override;
203  virtual void ReadUserDataSequence (const css::uno::Sequence < css::beans::PropertyValue >& ) override;
204 
205  virtual void UIDeactivated( SfxInPlaceClient* pClient ) override;
206 
207  virtual bool KeyInput( const KeyEvent &rKeyEvent ) override;
208  virtual SdrView* GetDrawView() const override;
209 
210 public:
212  SFX_DECL_VIEWFACTORY(ScTabViewShell);
213 
214 private:
216  static void InitInterface_Impl();
217 
218 public:
221  ScTabViewShell( SfxViewFrame* pViewFrame,
222  SfxViewShell* pOldSh );
223 
224  virtual ~ScTabViewShell() override;
225 
226  weld::Window* GetDialogParent();
227 
228  bool IsRefInputMode() const;
229  void ExecuteInputDirect();
230 
231  const ScInputHandler* GetInputHandler() const { return mpInputHandler.get(); }
232  ScInputHandler* GetInputHandler() { return mpInputHandler.get(); }
233  void UpdateInputHandler( bool bForce = false, bool bStopEditing = true );
234  void UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust );
235  bool TabKeyInput(const KeyEvent& rKEvt);
236  bool SfxKeyInput(const KeyEvent& rKEvt);
237 
238  void SetActive();
239 
240  ::editeng::SvxBorderLine* GetDefaultFrameLine() const { return pCurFrameLine.get(); }
241  void SetDefaultFrameLine(const ::editeng::SvxBorderLine* pLine );
242 
243  void Execute( SfxRequest& rReq );
244  void GetState( SfxItemSet& rSet );
245 
246  void ExecuteTable( SfxRequest& rReq );
247  void GetStateTable( SfxItemSet& rSet );
248 
249  void WindowChanged();
250  void ExecDraw(SfxRequest&);
251  void ExecDrawIns(SfxRequest& rReq);
252  void GetDrawState(SfxItemSet &rSet);
253  void GetDrawInsState(SfxItemSet &rSet);
254  void ExecGallery(const SfxRequest& rReq);
255 
256  void ExecChildWin(const SfxRequest& rReq);
257 
258  void ExecImageMap( SfxRequest& rReq );
259  void GetImageMapState( SfxItemSet& rSet );
260 
261  void ExecuteSave( SfxRequest& rReq );
262  void GetSaveState( SfxItemSet& rSet );
263  void ExecSearch( SfxRequest& rReq );
264 
265  void ExecuteUndo(SfxRequest& rReq);
266  void GetUndoState(SfxItemSet &rSet);
267 
268  void ExecuteObject(const SfxRequest& rReq);
269  void GetObjectState(SfxItemSet &rSet);
270 
271  void ExecDrawOpt(const SfxRequest& rReq);
272  void GetDrawOptState(SfxItemSet &rSet);
273 
274  void UpdateDrawShell();
275  void SetDrawShell( bool bActive );
276  void SetDrawTextShell( bool bActive );
277 
278  void SetPivotShell( bool bActive );
279  void SetDialogDPObject( std::unique_ptr<ScDPObject> pObj );
280  const ScDPObject* GetDialogDPObject() const { return pDialogDPObject.get(); }
281 
282  void SetDontSwitch(bool bFlag){bDontSwitch=bFlag;}
283 
284  void SetAuditShell( bool bActive );
285  void SetDrawFormShell( bool bActive );
286  void SetEditShell(EditView* pView, bool bActive );
287  void SetOleObjectShell( bool bActive );
288  void SetChartShell( bool bActive );
289  void SetGraphicShell( bool bActive );
290  void SetMediaShell( bool bActive );
291 
292  void SetDrawShellOrSub();
293  void SetCurSubShell( ObjectSelectionType eOST, bool bForce = false );
294 
295  void SetFormShellAtTop( bool bSet );
296 
297  ObjectSelectionType GetCurObjectSelectionType() const { return eCurOST; }
298 
299  virtual ErrCode DoVerb(sal_Int32 nVerb) override;
300 
301  void StopEditShell();
302  bool IsDrawTextShell() const;
303  bool IsAuditShell() const;
304 
305  void SetDrawTextUndo( SfxUndoManager* pUndoMgr );
306 
307  void FillFieldData( ScHeaderFieldData& rData );
308 
309  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
310 
311  ScNavigatorSettings* GetNavigatorSettings();
312 
313  // Drucken:
314  virtual SfxPrinter* GetPrinter( bool bCreate = false ) override;
315  virtual sal_uInt16 SetPrinter( SfxPrinter* pNewPrinter,
316  SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override;
317 
318  virtual bool HasPrintOptionsPage() const override;
319  virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions) override;
320 
321  void ConnectObject( const SdrOle2Obj* pObj );
322  void ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb);
323 
324  void DeactivateOle();
325 
326  static ScTabViewShell* GetActiveViewShell();
327 
328  std::shared_ptr<SfxModelessDialogController> CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW,
329  const SfxChildWinInfo* pInfo,
330  weld::Window* pParent, sal_uInt16 nSlotId);
331 
332  void UpdateOleZoom();
333 
334  virtual const FmFormShell* GetFormShell() const override { return pFormShell.get(); }
335  virtual FmFormShell* GetFormShell() override { return pFormShell.get(); }
336 
337  void InsertURL( const OUString& rName, const OUString& rURL, const OUString& rTarget,
338  sal_uInt16 nMode );
339  void InsertURLButton( const OUString& rName, const OUString& rURL, const OUString& rTarget,
340  const Point* pInsPos );
341  void InsertURLField( const OUString& rName, const OUString& rURL, const OUString& rTarget );
342 
343  bool SelectObject( std::u16string_view rName );
344 
345  void SetInFormatDialog(bool bFlag) {bInFormatDialog=bFlag;}
346 
347  void ForceMove() { Move(); }
348 
349  static std::unique_ptr<SvxNumberInfoItem> MakeNumberInfoItem( ScDocument& rDoc, const ScViewData& rViewData );
350 
351  static void UpdateNumberFormatter( const SvxNumberInfoItem& rInfoItem );
352 
353  void ExecuteCellFormatDlg( SfxRequest& rReq, const OString &rTabPage);
354 
355  bool GetFunction( OUString& rFuncStr, FormulaError nErrCode );
356 
357  void StartSimpleRefDialog( const OUString& rTitle, const OUString& rInitVal,
358  bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection );
359  void StopSimpleRefDialog();
360 
361  void SetCurRefDlgId( sal_uInt16 nNew );
362 
363  void AddAccessibilityObject( SfxListener& rObject );
364  void RemoveAccessibilityObject( SfxListener& rObject );
365  void BroadcastAccessibility( const SfxHint &rHint );
366  bool HasAccessibilityObjects() const;
367 
368  bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash);
369 
370  using ScTabView::ShowCursor;
371 
372  bool IsActive() const { return bIsActive; }
373  OUString GetFormula(const ScAddress& rAddress);
374  bool UseSubTotal(ScRangeList* pRangeList);
375  OUString DoAutoSum(bool& rRangeFinder, bool& rSubTotal, const OpCode eCode);
376 
377  // ugly hack to call Define Names from Manage Names
378  void SwitchBetweenRefDialogs(SfxModelessDialogController* pDialog);
379  // #i123629#
380  bool GetForceFocusOnCurCell() const { return bForceFocusOnCurCell; }
381  void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; }
383  int getPart() const override;
385  void afterCallbackRegistered() override;
387  void NotifyCursor(SfxViewShell* pViewShell) const override;
389  static void notifyAllViewsHeaderInvalidation(const SfxViewShell* pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex);
390  static bool isAnyEditViewInRange(const SfxViewShell* pForViewShell, bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
393  static void notifyAllViewsSheetGeomInvalidation(const SfxViewShell* pForViewShell, bool bColumns, bool bRows, bool bSizes,
394  bool bHidden, bool bFiltered, bool bGroups, SCTAB nCurrentTabIndex);
395  css::uno::Reference<css::drawing::XShapes> getSelectedXShapes();
396  static css::uno::Reference<css::datatransfer::XTransferable2> GetClipData(vcl::Window* pWin);
397 
398  void InitFormEditData();
399  void ClearFormEditData();
400  ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
401 
403  bool ShouldDisableEditHyperlink() const;
406  void EnableEditHyperlink();
407 
408  virtual tools::Rectangle getLOKVisibleArea() const override;
409 };
410 
411 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxCellHorJustify
void ForceMove()
Definition: tabvwsh.hxx:347
DECL_LINK(ScrollHdl, ScrollBar *, void)
OUString sDrawCustom
Definition: tabvwsh.hxx:96
bool bFormShellAtTop
Definition: tabvwsh.hxx:141
bool bFirstActivate
Definition: tabvwsh.hxx:130
std::unique_ptr< ScInputHandler, o3tl::default_delete< ScInputHandler > > mpInputHandler
Definition: tabvwsh.hxx:115
const ScDPObject * GetDialogDPObject() const
Definition: tabvwsh.hxx:280
virtual const FmFormShell * GetFormShell() const override
Definition: tabvwsh.hxx:334
std::unique_ptr< ScGraphicShell > pGraphicShell
Definition: tabvwsh.hxx:106
HeaderType
Definition: tabview.hxx:57
virtual std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions)
virtual FmFormShell * GetFormShell() override
Definition: tabvwsh.hxx:335
#define SCID_TABVIEW_SHELL
Definition: shellids.hxx:25
std::unique_ptr< ScDPObject > pDialogDPObject
Definition: tabvwsh.hxx:125
std::map< OUString, std::unique_ptr< ScRangeName > > m_RangeMap
Definition: tabvwsh.hxx:160
bool bActiveGraphicSh
Definition: tabvwsh.hxx:137
sal_uInt16 nCurRefDlgId
Definition: tabvwsh.hxx:155
std::unique_ptr< ScMediaShell > pMediaShell
Definition: tabvwsh.hxx:107
bool bInPrepareClose
Definition: tabvwsh.hxx:152
std::unique_ptr< ScOleObjectShell > pOleObjectShell
Definition: tabvwsh.hxx:104
void GetState(SdrMarkView *pSdrView, SfxItemSet &rSet)
bool GetForceFocusOnCurCell() const
Definition: tabvwsh.hxx:380
Contains settings of the navigator listbox.
Definition: navsett.hxx:29
bool IsActive() const
Definition: tabvwsh.hxx:372
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange)
std::unique_ptr< ScCellShell > pCellShell
Definition: tabvwsh.hxx:103
virtual OUString GetSelectionText(bool bCompleteWords=false)
void SetDontSwitch(bool bFlag)
Definition: tabvwsh.hxx:282
bool bActiveDrawFormSh
Definition: tabvwsh.hxx:134
SdrObjKind
std::unique_ptr< FmFormShell > pFormShell
Definition: tabvwsh.hxx:112
virtual bool HasPrintOptionsPage() const
bool bActiveDrawSh
Definition: tabvwsh.hxx:132
bool bActiveDrawTextSh
Definition: tabvwsh.hxx:133
virtual void WriteUserData(OUString &, bool bBrowse=false)
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL)
virtual int getPart() const
SfxPrinterChangeFlags
std::unique_ptr< ScEditShell > pEditShell
Definition: tabvwsh.hxx:99
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
css::uno::Reference< css::frame::XDispatchProviderInterceptor > xDisProvInterceptor
Definition: tabvwsh.hxx:120
void SetForceFocusOnCurCell(bool bFlag)
Definition: tabvwsh.hxx:381
OpCode
ScTabViewTarget aTarget
Definition: tabvwsh.hxx:124
ScPasswordHash
std::unique_ptr< ScDrawFormShell > pDrawFormShell
Definition: tabvwsh.hxx:102
bool bForceFocusOnCurCell
Definition: tabvwsh.hxx:150
std::unique_ptr< ScNavigatorSettings > pNavSettings
Definition: tabvwsh.hxx:127
std::unique_ptr< ScDrawTextObjectBar > pDrawTextShell
Definition: tabvwsh.hxx:98
::editeng::SvxBorderLine * GetDefaultFrameLine() const
Definition: tabvwsh.hxx:240
ScFormEditData * GetFormEditData()
Definition: tabvwsh.hxx:400
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:478
std::unique_ptr< svx::FontworkBar > pFontworkBarShell
Definition: tabvwsh.hxx:110
std::unique_ptr< ScPivotShell > pPivotShell
Definition: tabvwsh.hxx:100
OUString maScope
Definition: tabvwsh.hxx:163
virtual void ReadUserData(const OUString &, bool bBrowse=false)
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize)
virtual void Activate(bool IsMDIActivate) override
bool bInFormatDialog
Definition: tabvwsh.hxx:144
bool bActiveEditSh
Definition: tabvwsh.hxx:139
const ::avmedia::MediaItem * Execute(SdrMarkView *pSdrView, SfxRequest const &rReq)
sal_uInt16 nDrawSfxId
Definition: tabvwsh.hxx:94
virtual void QueryObjAreaPixel(tools::Rectangle &rRect) const
virtual void UIDeactivated(SfxInPlaceClient *pClient)
virtual void Deactivate(bool IsMDIActivate) override
FormulaError
std::unique_ptr< ScDrawShell > pDrawShell
Definition: tabvwsh.hxx:97
virtual void NotifyCursor(SfxViewShell *) const
virtual void afterCallbackRegistered()
virtual ErrCode DoVerb(sal_Int32 nVerb)
std::unique_ptr< ScChartShell > pChartShell
Definition: tabvwsh.hxx:105
std::unique_ptr< ScFormEditData > mpFormEditData
Definition: tabvwsh.hxx:114
virtual void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &)
ObjectSelectionType eCurOST
Definition: tabvwsh.hxx:93
bool bActiveOleObjectSh
Definition: tabvwsh.hxx:135
virtual tools::Rectangle getLOKVisibleArea() const
bool bActiveMediaSh
Definition: tabvwsh.hxx:138
std::unique_ptr< SfxBroadcaster > pAccessibilityBroadcaster
Definition: tabvwsh.hxx:157
OUString maName
Definition: tabvwsh.hxx:162
virtual SfxPrinter * GetPrinter(bool bCreate=false)
virtual SdrView * GetDrawView() const
void ShowCursor()
Definition: tabview3.cxx:246
ScInputHandler * GetInputHandler()
Definition: tabvwsh.hxx:232
std::unique_ptr< svx::ExtrusionBar > pExtrusionBarShell
Definition: tabvwsh.hxx:109
ObjectSelectionType GetCurObjectSelectionType() const
Definition: tabvwsh.hxx:297
virtual bool KeyInput(const KeyEvent &rKeyEvent)
std::unique_ptr<::editeng::SvxBorderLine > pCurFrameLine
Definition: tabvwsh.hxx:117
virtual void Move()
virtual bool HasSelection(bool bText=true) const
virtual void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
TriState
std::unique_ptr< ScAuditingShell > pAuditingShell
Definition: tabvwsh.hxx:101
ObjectSelectionType
Definition: tabvwsh.hxx:73
bool bDontSwitch
Definition: tabvwsh.hxx:143
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
bool bActiveChartSh
Definition: tabvwsh.hxx:136
std::unique_ptr< ScPageBreakShell > pPageBreakShell
Definition: tabvwsh.hxx:108
virtual bool PrepareClose(bool bUI=true)
sal_Int16 SCTAB
Definition: types.hxx:22
virtual void SetZoomFactor(const Fraction &rZoomX, const Fraction &rZoomY)
SdrObjKind eFormObjKind
Definition: tabvwsh.hxx:95
#define SFX_DECL_INTERFACE(nId)
void SetInFormatDialog(bool bFlag)
Definition: tabvwsh.hxx:345