LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / drwlayer.hxx
blobe71bd6bd0a2d44c8d1f10a445b043065b4ef336a
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 #pragma once
22 #include <svx/fmmodel.hxx>
23 #include <svx/svdundo.hxx>
24 #include "global.hxx"
26 class ScDocument;
27 class SfxObjectShell;
28 class ScDrawObjData;
29 class ScMacroInfo;
30 class ScMarkData;
32 class ScTabDeletedHint final : public SfxHint
34 private:
35 SCTAB nTab;
36 public:
37 ScTabDeletedHint( SCTAB nTabNo );
38 virtual ~ScTabDeletedHint() override;
40 SCTAB GetTab() const { return nTab; }
43 class ScTabSizeChangedHint final : public SfxHint
45 private:
46 SCTAB nTab;
47 public:
48 ScTabSizeChangedHint( SCTAB nTabNo );
49 virtual ~ScTabSizeChangedHint() override;
51 SCTAB GetTab() const { return nTab; }
54 // Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
55 // therefore derived from SdrUndoAction
57 class ScUndoObjData final : public SdrUndoObj
59 private:
60 ScAddress aOldStt;
61 ScAddress aOldEnd;
62 ScAddress aNewStt;
63 ScAddress aNewEnd;
64 public:
65 ScUndoObjData( SdrObject* pObj, const ScAddress& rOS, const ScAddress& rOE,
66 const ScAddress& rNS, const ScAddress& rNE );
67 virtual ~ScUndoObjData() override;
69 virtual void Undo() override;
70 virtual void Redo() override;
73 class ScUndoAnchorData final : public SdrUndoObj
75 private:
76 bool mbWasCellAnchored;
77 bool mbWasResizeWithCell;
78 ScDocument* mpDoc;
79 SCTAB mnTab;
80 public:
81 ScUndoAnchorData( SdrObject* pObj, ScDocument* pDoc, SCTAB nTab );
82 virtual ~ScUndoAnchorData() override;
84 virtual void Undo() override;
85 virtual void Redo() override;
88 // for ScDrawLayer::SetPageSize
89 enum class ScObjectHandling
91 RecalcPosMode, // used for row height or col width changes
92 MoveRTLMode, // used for switch to RTL during import of right-to-left sheet
93 MirrorRTLMode // used for switch between RTL and LTR by .uno:SheetRightToLeft
96 class SC_DLLPUBLIC ScDrawLayer final : public FmFormModel
98 private:
99 OUString aName;
100 ScDocument* pDoc;
101 std::unique_ptr<SdrUndoGroup> pUndoGroup;
102 bool bRecording;
103 bool bAdjustEnabled;
104 bool bHyphenatorSet;
106 private:
107 void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
108 SCCOL nDx,SCROW nDy, bool bUpdateNoteCaptionPos );
110 void ResizeLastRectFromAnchor( const SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bCanResize );
112 public:
113 ScDrawLayer( ScDocument* pDocument, const OUString& rName );
114 virtual ~ScDrawLayer() override;
116 virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override;
117 virtual SdrModel* AllocModel() const override;
118 virtual void SetChanged( bool bFlg = true ) override;
120 bool HasObjects() const;
122 bool ScAddPage( SCTAB nTab );
123 void ScRemovePage( SCTAB nTab );
124 void ScRenamePage( SCTAB nTab, const OUString& rNewName );
125 void ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
126 void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
127 void ResetTab( SCTAB nStart, SCTAB nEnd );
129 ScDocument* GetDocument() const { return pDoc; }
131 void UseHyphenator();
133 bool GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
135 // automatic adjustments
137 void EnableAdjust( bool bSet ) { bAdjustEnabled = bSet; }
139 void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
140 std::unique_ptr<SdrUndoGroup> GetCalcUndo();
141 bool IsRecording() const { return bRecording; }
142 void AddCalcUndo( std::unique_ptr<SdrUndoAction> pUndo );
144 void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
145 SCCOL nDx,SCROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos );
146 void InitializeCellAnchoredObj(SdrObject* pObj, ScDrawObjData& rData);
147 void RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos );
149 bool HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow );
151 void DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
152 SCCOL nCol2,SCROW nRow2, bool bAnchored = false );
153 void DeleteObjectsInSelection( const ScMarkData& rMark );
155 void CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rectangle& rRange );
156 void CopyFromClip( ScDrawLayer* pClipModel,
157 SCTAB nSourceTab, const tools::Rectangle& rSourceRange,
158 const ScAddress& rDestPos, const tools::Rectangle& rDestRange );
160 void SetPageSize(sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos,
161 const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
163 // mirror or move between positive and negative positions for RTL
164 void MirrorRTL( SdrObject* pObj );
165 void MoveRTL(SdrObject* pObj);
166 static void MirrorRectRTL( tools::Rectangle& rRect ); // for bounding rectangles etc.
168 /** Returns the rectangle for the passed cell address in 1/100 mm.
169 @param bMergedCell True = regards merged cells. False = use single column/row size. */
170 static tools::Rectangle GetCellRect( const ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell );
172 // GetVisibleName: name for navigator etc: GetPersistName or GetName
173 // (ChartListenerCollection etc. must use GetPersistName directly)
174 static OUString GetVisibleName( const SdrObject* pObj );
176 SdrObject* GetNamedObject( std::u16string_view rName, sal_uInt16 nId, SCTAB& rFoundTab ) const;
177 // if pnCounter != NULL, the search for a name starts with this index + 1,
178 // and the index really used is returned.
179 OUString GetNewGraphicName( tools::Long* pnCounter = nullptr ) const;
180 void EnsureGraphicNames();
182 static bool IsCellAnchored( const SdrObject& rObj );
183 static bool IsResizeWithCell( const SdrObject& rObj );
184 static void SetPageAnchored( SdrObject& );
185 static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
186 static void SetNonRotatedAnchor( SdrObject&, const ScDrawObjData &rAnchor );
188 // Updates rAnchor based on position of rObj
189 static void GetCellAnchorFromPosition(
190 const tools::Rectangle &rRectangle,
191 ScDrawObjData &rAnchor,
192 const ScDocument &rDoc,
193 SCTAB nTab,
194 bool bHiddenAsZero = true);
196 static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell );
197 static void UpdateCellAnchorFromPositionEnd( const SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true );
198 static ScAnchorType GetAnchorType( const SdrObject& );
199 std::vector<SdrObject*> GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow);
200 std::map<SCROW, std::vector<SdrObject*>> GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow);
201 bool HasObjectsAnchoredInRange(const ScRange& rRange);
202 std::vector<SdrObject*> GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol);
203 void MoveObject(SdrObject* pObj, const ScAddress& rNewPosition);
205 // positions for detective lines
206 static ScDrawObjData* GetObjData( SdrObject* pObj, bool bCreate=false );
207 static ScDrawObjData* GetNonRotatedObjData( SdrObject* pObj, bool bCreate=false );
209 // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
210 // Use this method to get an object with positions on the specified sheet (should be the
211 // sheet on which the object is inserted).
212 static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab );
214 /** Returns true, if the passed object is the caption of a cell note. */
215 static bool IsNoteCaption( SdrObject* pObj );
217 /** Returns the object data, if the passed object is a cell note caption. */
218 static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab );
220 static ScMacroInfo* GetMacroInfo( SdrObject* pObj, bool bCreate = false );
222 private:
223 static SfxObjectShell* pGlobalDrawPersist; // for AllocModel
224 public:
225 static void SetGlobalDrawPersist(SfxObjectShell* pPersist);
226 private:
227 virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
230 extern bool bDrawIsInUndo; // somewhere as member!
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */