LibreOffice Module sc (master)  1
drawview.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 <svx/fmview.hxx>
23 
24 #include <global.hxx>
25 
26 namespace com::sun::star::datatransfer { class XTransferable; }
27 
28 class ScDocument;
29 class ScViewData;
30 class ScDrawObjData;
31 class SdrUndoManager;
32 
33 class ScDrawView final : public FmFormView
34 {
39  Fraction aScaleX; // Factor for Drawing-MapMode
41  std::unique_ptr<SdrDropMarkerOverlay> pDropMarker;
44 
45  void Construct();
46 
47  virtual void ModelHasChanged() override;
48 
49  // add custom handles (used by other apps, e.g. AnchorPos)
50  virtual void AddCustomHdl() override;
51 
53 
54  // support enhanced text edit for draw objects
55  virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const override;
56 
57 public:
58  ScDrawView(
59  OutputDevice* pOut,
60  ScViewData* pData);
61 
62  virtual ~ScDrawView() override;
63 
64  virtual void MarkListHasChanged() override;
65  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
66 
67  virtual void DoConnect(SdrOle2Obj* pOleObj) override;
68 
69  virtual void MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin ) override;
70 
71  virtual void DeleteMarked() override;
72 
73  virtual bool SdrBeginTextEdit(
74  SdrObject* pObj,
75  SdrPageView* pPV = nullptr,
76  vcl::Window* pWin = nullptr,
77  bool bIsNewObj = false,
78  SdrOutliner* pGivenOutliner = nullptr,
79  OutlinerView* pGivenOutlinerView = nullptr,
80  bool bDontDeleteOutliner = false,
81  bool bOnlyOneView = false,
82  bool bGrabFocus = true) override;
83 
84  virtual SdrEndTextEditKind SdrEndTextEdit( bool bDontDeleteReally = false ) override;
85 
86  void MarkDropObj( SdrObject* pObj );
87 
88  void SetMarkedToLayer( SdrLayerID nLayerNo );
89 
90  void InvalidateAttribs();
92 
93  void BeginDrag( vcl::Window* pWindow, const Point& rStartPos );
94  void DoCut();
95  void DoCopy();
96 
97  void GetScale( Fraction& rFractX, Fraction& rFractY ) const;
98  void RecalcScale();
99  void UpdateWorkArea();
100  SCTAB GetTab() const { return nTab; }
101 
102  void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;
103 
104  void SetPageAnchored();
105  void SetCellAnchored(bool bResizeWithCell);
106  ScAnchorType GetAnchorType() const;
107 
108  void UpdateIMap( SdrObject* pObj );
109 
110  void UpdateUserViewOptions();
111 
112  void SetMarkedOriginalSize();
113  void FitToCellSize();
114 
115  bool SelectObject( std::u16string_view rName );
116  bool HasMarkedControl() const;
117  bool HasMarkedInternal() const;
118 
119  bool InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV);
120 
124 
127  void LockCalcLayer( SdrLayerID nLayer, bool bLock );
128 
131  void LockBackgroundLayer( bool bLock ) { LockCalcLayer( SC_LAYER_BACK, bLock ); }
132 
135  void LockInternalLayer( bool bLock = true ) { LockCalcLayer( SC_LAYER_INTERN, bLock ); }
138 
139  SdrEndTextEditKind ScEndTextEdit(); // calls SetDrawTextUndo(0)
140  css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable();
141 
142  SdrObject* GetObjectByName(std::u16string_view rName);
143  bool GetObjectIsMarked( const SdrObject * pObject );
144  void SelectCurrentViewObject( std::u16string_view rName );
145 
146  // #i123922# helper which checks if a Graphic may be applied to an existing
147  // SdrObject; if it's a SdrGrafObj the fill will be replaced. If it's a
148  // fillable, non-OLE SdrObject, the FillStyle will be adapted
150  SdrObject& rHitObject,
151  const Graphic& rGraphic,
152  const OUString& rBeginUndoText,
153  const OUString& rFile);
154 
155  static void CheckOle( const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneOle );
156 
157  void SyncForGrid( SdrObject* pObj );
158 
160  SdrObject& rSdrObject,
161  basegfx::B2DVector& rTarget) const;
163  const basegfx::B2DRange& rB2DRange,
164  basegfx::B2DVector& rTarget) const;
166 
168  SfxViewShell* GetSfxViewShell() const override;
169 
170  // Do not create ObjectContact locally, but offer a call to allow override
171  // and to create own derivations of ObjectContact
173  SdrPageWindow& rPageWindow,
174  const char* pDebugName) const override;
175 };
176 
177 extern Point aDragStartDiff;
178 
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true) override
Definition: drawview.cxx:543
void UpdateUserViewOptions()
Definition: drawview.cxx:626
virtual ~ScDrawView() override
Definition: drawview.cxx:133
void ImplClearCalcDropMarker()
Definition: drawview.cxx:128
Fraction aScaleX
Definition: drawview.hxx:39
void UpdateIMap(SdrObject *pObj)
Definition: drawvie3.cxx:226
void CalcNormScale(Fraction &rFractX, Fraction &rFractY) const
Definition: drawvie4.cxx:411
SdrEndTextEditKind
void InvalidateAttribs()
Definition: drawview.cxx:153
void LockInternalLayer(bool bLock=true)
Locks/unlocks the internal layer that contains caption objects of cell notes.
Definition: drawview.hxx:135
SdrObject * GetObjectByName(std::u16string_view rName)
Definition: drawview.cxx:650
bool HasMarkedInternal() const
Definition: drawview.cxx:253
constexpr SdrLayerID SC_LAYER_BACK(1)
virtual void AddCustomHdl() override
Definition: drawview.cxx:138
ScViewData * pViewData
Definition: drawview.hxx:35
bool HasMarkedControl() const
Definition: drawview.cxx:244
void resetGridOffsetsForAllSdrPageViews()
Definition: drawview.cxx:974
void LockBackgroundLayer(bool bLock)
Locks/unlocks the background layer that contains background objects.
Definition: drawview.hxx:131
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: drawvie3.cxx:199
virtual void DeleteMarked() override
Definition: drawview.cxx:856
Point aDragStartDiff
Definition: drawvie4.cxx:56
void LockCalcLayer(SdrLayerID nLayer, bool bLock)
Locks/unlocks the specified layer in the draw page.
Definition: drawview.cxx:835
Fraction aScaleY
Definition: drawview.hxx:40
void BeginDrag(vcl::Window *pWindow, const Point &rStartPos)
Definition: drawvie4.cxx:58
void GetScale(Fraction &rFractX, Fraction &rFractY) const
Definition: drawview.cxx:292
void MarkDropObj(SdrObject *pObj)
Definition: drawview.cxx:905
void UpdateWorkArea()
Definition: drawview.cxx:263
void SyncForGrid(SdrObject *pObj)
Definition: drawview.cxx:925
ScAnchorType
Definition: global.hxx:382
virtual void MarkListHasChanged() override
Definition: drawview.cxx:358
void SelectCurrentViewObject(std::u16string_view rName)
Definition: drawview.cxx:681
void Construct()
Definition: drawview.cxx:71
bool calculateGridOffsetForB2DRange(const basegfx::B2DRange &rB2DRange, basegfx::B2DVector &rTarget) const
Definition: drawview.cxx:1060
virtual SdrUndoManager * getSdrUndoManagerForEnhancedTextEdit() const override
Definition: drawview.cxx:1109
static void CheckOle(const SdrMarkList &rMarkList, bool &rAnyOle, bool &rOneOle)
Definition: drawvie4.cxx:328
void SetCellAnchored(bool bResizeWithCell)
Definition: drawvie3.cxx:87
bool SelectObject(std::u16string_view rName)
Definition: drawview.cxx:732
void SetMarkedToLayer(SdrLayerID nLayerNo)
Definition: drawview.cxx:212
void InvalidateDrawTextAttrs()
Definition: drawview.cxx:162
SfxViewShell * GetSfxViewShell() const override
See SdrMarkView::GetSfxViewShell().
Definition: drawview.cxx:851
void RecalcScale()
Definition: drawview.cxx:298
ScDrawView(OutputDevice *pOut, ScViewData *pData)
Definition: drawvie3.cxx:40
SCTAB GetTab() const
Definition: drawview.hxx:100
void SetPageAnchored()
Definition: drawvie3.cxx:62
virtual void DoConnect(SdrOle2Obj *pOleObj) override
Definition: drawview.cxx:352
void DoCut()
Definition: drawview.cxx:284
bool InsertObjectSafe(SdrObject *pObj, SdrPageView &rPV)
Definition: drawview.cxx:804
SdrObject * pDropMarkObj
Definition: drawview.hxx:42
void UnlockInternalLayer()
Unlocks the internal layer that contains caption objects of cell notes.
Definition: drawview.hxx:137
virtual void ModelHasChanged() override
Definition: drawview.cxx:612
void SetMarkedOriginalSize()
Definition: drawvie4.cxx:432
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
Definition: drawview.cxx:588
ScAnchorType GetAnchorType() const
Definition: drawvie3.cxx:113
VclPtr< OutputDevice > pDev
Definition: drawview.hxx:36
std::unique_ptr< SdrDropMarkerOverlay > pDropMarker
Definition: drawview.hxx:41
SdrObject * GetMarkedNoteCaption(ScDrawObjData **ppCaptData)
Returns the selected object, if it is the caption object of a cell note.
Definition: drawview.cxx:820
constexpr SdrLayerID SC_LAYER_INTERN(2)
ScDocument & rDoc
needed ?
Definition: drawview.hxx:37
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:894
SdrObject * ApplyGraphicToObject(SdrObject &rHitObject, const Graphic &rGraphic, const OUString &rBeginUndoText, const OUString &rFile)
Definition: drawview.cxx:1115
css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable()
Definition: drawvie4.cxx:375
virtual sdr::contact::ObjectContact * createViewSpecificObjectContact(SdrPageWindow &rPageWindow, const char *pDebugName) const override
Definition: drawview.cxx:1243
void DoCopy()
Definition: drawvie4.cxx:333
bool bInConstruct
Definition: drawview.hxx:43
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin) override
Definition: drawview.cxx:842
void FitToCellSize()
Definition: drawvie4.cxx:523
bool calculateGridOffsetForSdrObject(SdrObject &rSdrObject, basegfx::B2DVector &rTarget) const
Definition: drawview.cxx:998
bool GetObjectIsMarked(const SdrObject *pObject)
Definition: drawview.cxx:794
sal_Int16 SCTAB
Definition: types.hxx:22
SCTAB nTab
Definition: drawview.hxx:38