LibreOffice Module sc (master)  1
userdat.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 #ifndef INCLUDED_SC_INC_USERDAT_HXX
21 #define INCLUDED_SC_INC_USERDAT_HXX
22 
23 #include <svx/svdobj.hxx>
24 #include <vcl/imap.hxx>
25 #include "address.hxx"
26 #include "drwlayer.hxx"
27 
28 // Object IDs for UserData
29 #define SC_UD_OBJDATA 1
30 // SVX_IMAPINFO_ID = 2
31 #define SC_UD_MACRODATA 3
32 
34 {
35 public:
36  enum Type { CellNote, ValidationCircle, DetectiveArrow, DrawingObject };
37 
43  bool mbResizeWithCell = false;
44  bool mbWasInHiddenRow = false;
45 
46  explicit ScDrawObjData();
47 
48  const tools::Rectangle & getShapeRect() const { return maShapeRect; };
49  const tools::Rectangle & getLastCellRect() const { return maLastCellRect; };
50  void setShapeRect(const ScDocument* rDoc, tools::Rectangle rNewRect, bool bIsVisible=true)
51  {
52  // bIsVisible should be false when the object is hidden obviously. we dont want to store the old cell rect in that
53  // case because it will have height=0
54  if (maStart.IsValid() && mbResizeWithCell && bIsVisible)
55  maLastCellRect = ScDrawLayer::GetCellRect(*rDoc, maStart, true);
56  maShapeRect = rNewRect;
57  mbWasInHiddenRow = !bIsVisible;
58  };
59 
60 private:
61  virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override;
62 
63  // Stores the last cell rect this shape was anchored to.
64  // Needed when the cell is resized to resize the image accordingly.
66  // Stores the rect of the shape to which this ScDrawObjData belongs.
68 };
69 
70 class SAL_DLLPUBLIC_RTTI ScMacroInfo : public SdrObjUserData
71 {
72 public:
73  ScMacroInfo();
74  virtual ~ScMacroInfo() override;
75 
76  ScMacroInfo(ScMacroInfo const &) = default;
77  ScMacroInfo(ScMacroInfo &&) = default;
78  ScMacroInfo & operator =(ScMacroInfo const &) = delete; // due to SdrObjUserData
79  ScMacroInfo & operator =(ScMacroInfo &&) = delete; // due to SdrObjUserData
80 
81  virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override;
82 
83  void SetMacro( const OUString& rMacro ) { maMacro = rMacro; }
84  const OUString& GetMacro() const { return maMacro; }
85 
86  void SetHlink( const OUString& rHlink ) { maHlink = rHlink; }
87  const OUString& GetHlink() const { return maHlink; }
88 
89 private:
90  OUString maMacro;
91  OUString maHlink;
92 };
93 
94 #endif
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SdrObjUserData > Clone(SdrObject *pObj1) const =0
const OUString & GetMacro() const
Definition: userdat.hxx:84
static tools::Rectangle GetCellRect(const ScDocument &rDoc, const ScAddress &rPos, bool bMergedCell)
Returns the rectangle for the passed cell address in 1/100 mm.
Definition: drwlayer.cxx:1848
ScAddress maStart
Definition: userdat.hxx:38
void setShapeRect(const ScDocument *rDoc, tools::Rectangle rNewRect, bool bIsVisible=true)
Definition: userdat.hxx:50
tools::Rectangle maLastCellRect
Definition: userdat.hxx:65
Point maEndOffset
Definition: userdat.hxx:41
bool IsValid() const
Definition: address.hxx:293
const tools::Rectangle & getShapeRect() const
Definition: userdat.hxx:48
void SetHlink(const OUString &rHlink)
Definition: userdat.hxx:86
void SetMacro(const OUString &rMacro)
Definition: userdat.hxx:83
OUString maMacro
Definition: userdat.hxx:90
Point maStartOffset
Definition: userdat.hxx:40
OUString maHlink
Definition: userdat.hxx:91
tools::Rectangle maShapeRect
Definition: userdat.hxx:67
const OUString & GetHlink() const
Definition: userdat.hxx:87
void operator=(const SdrObjUserData &rData)=delete
ScAddress maEnd
Definition: userdat.hxx:39
const tools::Rectangle & getLastCellRect() const
Definition: userdat.hxx:49
#define SC_DLLPUBLIC
Definition: scdllapi.h:28