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 #pragma once
21 
23 #include "worksheethelper.hxx"
24 
25 namespace oox { class AttributeList; }
26 
27 namespace oox::xls {
28 
31 {
32  explicit AnchorPointModel() : ::oox::drawingml::EmuPoint( -1, -1 ) {}
33  bool isValid() const { return (X >= 0) && (Y >= 0); }
34 };
35 
38 {
39  explicit AnchorSizeModel() : ::oox::drawingml::EmuSize( -1, -1 ) {}
40  bool isValid() const { return (Width >= 0) && (Height >= 0); }
41 };
42 
45 {
46  sal_Int32 mnCol;
47  sal_Int32 mnRow;
48  sal_Int64 mnColOffset;
49  sal_Int64 mnRowOffset;
50 
51  explicit CellAnchorModel();
52  bool isValid() const { return (mnCol >= 0) && (mnRow >= 0); }
53 };
54 
57 {
60 
61  explicit AnchorClientDataModel();
62 };
63 
66 class ShapeAnchor final : public WorksheetHelper
67 {
68 public:
70  {
79  };
80  explicit ShapeAnchor( const WorksheetHelper& rHelper );
81 
83  void importAnchor( sal_Int32 nElement, const AttributeList& rAttribs );
85  void importPos( const AttributeList& rAttribs );
87  void importExt( const AttributeList& rAttribs );
89  void importClientData( const AttributeList& rAttribs );
91  void setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue );
93  void importVmlAnchor( const OUString& rAnchor );
94 
101  bool isAnchorValid() const;
102 
104  ::oox::drawingml::EmuRectangle calcAnchorRectEmu( const css::awt::Size& rPageSizeHmm ) const;
106  css::awt::Rectangle calcAnchorRectHmm( const css::awt::Size& rPageSizeHmm ) const;
107  AnchorType getEditAs() const { return meEditAs; }
108 private:
111 
112 private:
113 
115  enum class CellAnchorType
116  {
117  Emu,
118  Pixel,
119  };
120 
129 };
130 
131 } // namespace oox::xls
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int64 mnRowOffset
X offset inside the column.
Definition: drawingbase.hxx:49
AnchorPointModel maPos
Type of the cell anchor models.
Absolute position in a spreadsheet (in EMUs) independent from cells.
Definition: drawingbase.hxx:30
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:48
::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:66
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:44
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:78
sal_Int32 mnRow
Column index.
Definition: drawingbase.hxx:47
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:37
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:56
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:76
Absolute anchor (top-left corner and size in absolute units).
Definition: drawingbase.hxx:74
void importPos(const AttributeList &rAttribs)
Imports the absolute anchor position from the xdr:pos element.