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
25namespace oox { class AttributeList; }
26
27namespace 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
66class ShapeAnchor final : public WorksheetHelper
67{
68public:
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, std::u16string_view rValue );
93 void importVmlAnchor( std::u16string_view 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; }
108private:
111
112private:
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: */
Contains the position of a shape in the spreadsheet.
Definition: drawingbase.hxx:67
::oox::drawingml::EmuPoint calcCellAnchorEmu(const CellAnchorModel &rModel) const
Converts the passed anchor to an absolute position in EMUs.
AnchorSizeModel maSize
Top-left position, if anchor is of type absolute.
AnchorPointModel maPos
Type of the cell anchor models.
::oox::drawingml::EmuRectangle calcAnchorRectEmu(const css::awt::Size &rPageSizeHmm) const
Calculates the resulting shape anchor in EMUs.
void importExt(const AttributeList &rAttribs)
Imports the absolute anchor size from the xdr:ext element.
AnchorType getEditAs() const
@ ANCHOR_ONECELL
Absolute anchor (top-left corner and size in absolute units).
Definition: drawingbase.hxx:74
@ ANCHOR_TWOCELL
One-cell anchor (top-left corner at cell, size in absolute units).
Definition: drawingbase.hxx:76
@ ANCHOR_VML
Two-cell anchor (top-left and bottom-right corner at cell).
Definition: drawingbase.hxx:78
@ ANCHOR_ABSOLUTE
Anchor type is unknown.
Definition: drawingbase.hxx:72
CellAnchorType meCellAnchorType
Type of this shape anchor.
CellAnchorModel maTo
Top-left position, if anchor is not of type absolute.
void importVmlAnchor(std::u16string_view rAnchor)
Imports the client anchor settings from a VML element.
void importAnchor(sal_Int32 nElement, const AttributeList &rAttribs)
Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor,...
Definition: drawingbase.cxx:73
CellAnchorType
Specifies how cell positions from CellAnchorModel have to be processed.
void setCellPos(sal_Int32 nElement, sal_Int32 nParentContext, std::u16string_view rValue)
Sets an attribute of the cell-dependent anchor position from xdr:from and xdr:to elements.
css::awt::Rectangle calcAnchorRectHmm(const css::awt::Size &rPageSizeHmm) const
Calculates the resulting shape anchor in 1/100 mm.
AnchorClientDataModel maClientData
Bottom-right position, if anchor is of type two-cell.
bool isAnchorValid() const
Checks whether the shape is visible based on the anchor.
CellAnchorModel maFrom
Anchor size, if anchor is not of type two-cell.
void importPos(const AttributeList &rAttribs)
Imports the absolute anchor position from the xdr:pos element.
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:65
@ Emu
Twips (1/20 point).
Application-specific client data of a shape.
Definition: drawingbase.hxx:57
Absolute position in a spreadsheet (in EMUs) independent from cells.
Definition: drawingbase.hxx:31
Absolute size in a spreadsheet (in EMUs).
Definition: drawingbase.hxx:38
Position in spreadsheet (cell position and offset inside cell).
Definition: drawingbase.hxx:45
sal_Int64 mnRowOffset
X offset inside the column.
Definition: drawingbase.hxx:49
sal_Int64 mnColOffset
Row index.
Definition: drawingbase.hxx:48
CellAnchorModel()
Y offset inside the row.
Definition: drawingbase.cxx:51
sal_Int32 mnRow
Column index.
Definition: drawingbase.hxx:47
unsigned long Pixel