LibreOffice Module sc (master)  1
drawingbase.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_SOURCE_FILTER_INC_DRAWINGBASE_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_DRAWINGBASE_HXX
22 
24 #include "worksheethelper.hxx"
25 
26 namespace oox { class AttributeList; }
27 
28 namespace oox::xls {
29 
32 {
33  explicit AnchorPointModel() : ::oox::drawingml::EmuPoint( -1, -1 ) {}
34  bool isValid() const { return (X >= 0) && (Y >= 0); }
35 };
36 
39 {
40  explicit AnchorSizeModel() : ::oox::drawingml::EmuSize( -1, -1 ) {}
41  bool isValid() const { return (Width >= 0) && (Height >= 0); }
42 };
43 
46 {
47  sal_Int32 mnCol;
48  sal_Int32 mnRow;
49  sal_Int64 mnColOffset;
50  sal_Int64 mnRowOffset;
51 
52  explicit CellAnchorModel();
53  bool isValid() const { return (mnCol >= 0) && (mnRow >= 0); }
54 };
55 
58 {
61 
62  explicit AnchorClientDataModel();
63 };
64 
68 {
69 public:
71  {
80  };
81  explicit ShapeAnchor( const WorksheetHelper& rHelper );
82 
84  void importAnchor( sal_Int32 nElement, const AttributeList& rAttribs );
86  void importPos( const AttributeList& rAttribs );
88  void importExt( const AttributeList& rAttribs );
90  void importClientData( const AttributeList& rAttribs );
92  void setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue );
94  void importVmlAnchor( const OUString& rAnchor );
95 
102  bool isAnchorValid() const;
103 
105  ::oox::drawingml::EmuRectangle calcAnchorRectEmu( const css::awt::Size& rPageSizeHmm ) const;
107  css::awt::Rectangle calcAnchorRectHmm( const css::awt::Size& rPageSizeHmm ) const;
108  AnchorType getEditAs() const { return meEditAs; }
109 private:
112 
113 private:
114 
116  enum class CellAnchorType
117  {
118  Emu,
119  Pixel,
120  };
121 
130 };
131 
132 } // namespace oox::xls
133 
134 #endif
135 
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int64 mnRowOffset
X offset inside the column.
Definition: drawingbase.hxx:50
AnchorPointModel maPos
Type of the cell anchor models.
Absolute position in a spreadsheet (in EMUs) independent from cells.
Definition: drawingbase.hxx:31
AnchorClientDataModel maClientData
Bottom-right position, if anchor is of type two-cell.
AnchorSizeModel maSize
Top-left position, if anchor is of type absolute.
sal_Int64 mnColOffset
Row index.
Definition: drawingbase.hxx:49
::oox::drawingml::EmuRectangle calcAnchorRectEmu(const css::awt::Size &rPageSizeHmm) const
Calculates the resulting shape anchor in EMUs.
Contains the position of a shape in the spreadsheet.
Definition: drawingbase.hxx:67
void importVmlAnchor(const OUString &rAnchor)
Imports the client anchor settings from a VML element.
Position in spreadsheet (cell position and offset inside cell).
Definition: drawingbase.hxx:45
AnchorType getEditAs() const
void importExt(const AttributeList &rAttribs)
Imports the absolute anchor size from the xdr:ext element.
void setCellPos(sal_Int32 nElement, sal_Int32 nParentContext, const OUString &rValue)
Sets an attribute of the cell-dependent anchor position from xdr:from and xdr:to elements.
Two-cell anchor (top-left and bottom-right corner at cell).
Definition: drawingbase.hxx:79
sal_Int32 mnRow
Column index.
Definition: drawingbase.hxx:48
AnchorType meEditAs
Shape client data.
void importClientData(const AttributeList &rAttribs)
Imports the shape client data from the xdr:clientData element.
ShapeAnchor(const WorksheetHelper &rHelper)
Definition: drawingbase.cxx:64
CellAnchorModel maTo
Top-left position, if anchor is not of type absolute.
Absolute size in a spreadsheet (in EMUs).
Definition: drawingbase.hxx:38
css::awt::Rectangle calcAnchorRectHmm(const css::awt::Size &rPageSizeHmm) const
Calculates the resulting shape anchor in 1/100 mm.
bool isAnchorValid() const
Checks whether the shape is visible based on the anchor.
Application-specific client data of a shape.
Definition: drawingbase.hxx:57
void importAnchor(sal_Int32 nElement, const AttributeList &rAttribs)
Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor, xdr:twoCellAnchor).
Definition: drawingbase.cxx:72
CellAnchorType meCellAnchorType
Type of this shape anchor.
CellAnchorType
Specifies how cell positions from CellAnchorModel have to be processed.
CellAnchorModel maFrom
Anchor size, if anchor is not of type two-cell.
CellAnchorModel()
Y offset inside the row.
Definition: drawingbase.cxx:50
::oox::drawingml::EmuPoint calcCellAnchorEmu(const CellAnchorModel &rModel) const
Converts the passed anchor to an absolute position in EMUs.
One-cell anchor (top-left corner at cell, size in absolute units).
Definition: drawingbase.hxx:77
Absolute anchor (top-left corner and size in absolute units).
Definition: drawingbase.hxx:75
void importPos(const AttributeList &rAttribs)
Imports the absolute anchor position from the xdr:pos element.