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