1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX
21 #define INCLUDED_OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX
23 #include <oox/core/fragmenthandler2.hxx>
24 #include <oox/drawingml/shape.hxx>
31 /** Relative shape position in a chart object. */
34 double mfX
; /// X coordinate relative to chart object (0.0 to 1.0).
35 double mfY
; /// Y coordinate relative to chart object (0.0 to 1.0).
37 AnchorPosModel() : mfX( -1.0 ), mfY( -1.0 ) {}
38 bool isValid() const { return (0.0 <= mfX
) && (mfX
<= 1.0) && (0.0 <= mfY
) && (mfY
<= 1.0); }
42 /** Absolute shape size in a chart object (in EMUs). */
43 struct AnchorSizeModel
: public EmuSize
45 AnchorSizeModel() : EmuSize( -1, -1 ) {}
46 bool isValid() const { return (Width
>= 0) && (Height
>= 0); }
50 /** Contains the position of a shape in the chart object. Supports different
51 shape anchor modes (absolute, relative).
56 explicit ShapeAnchor( bool bRelSize
);
58 /** Imports the absolute anchor size from the cdr:ext element. */
59 void importExt( const AttributeList
& rAttribs
);
60 /** Sets an the relative anchor position from the cdr:from or cdr:to element. */
61 void setPos( sal_Int32 nElement
, sal_Int32 nParentContext
, const OUString
& rValue
);
63 /** Calculates the resulting shape anchor in EMUs. */
64 EmuRectangle
calcAnchorRectEmu( const EmuRectangle
& rChartRect
) const;
67 AnchorPosModel maFrom
; /// Top-left position relative to chart object.
68 AnchorPosModel maTo
; /// Bottom-right position relative to chart object.
69 AnchorSizeModel maSize
; /// Shape size, if anchor has absolute size.
70 bool const mbRelSize
; /// True = relative size, false = absolute size.
73 /** Handler for a chart drawing fragment (c:userShapes root element).
75 class ChartDrawingFragment
: public ::oox::core::FragmentHandler2
78 explicit ChartDrawingFragment(
79 ::oox::core::XmlFilterBase
& rFilter
,
80 const OUString
& rFragmentPath
,
81 const css::uno::Reference
< css::drawing::XShapes
>& rxDrawPage
,
82 const css::awt::Size
& rChartSize
,
83 const css::awt::Point
& rShapesOffset
,
85 virtual ~ChartDrawingFragment() override
;
87 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) override
;
88 virtual void onCharacters( const OUString
& rChars
) override
;
89 virtual void onEndElement() override
;
92 css::uno::Reference
< css::drawing::XShapes
>
93 mxDrawPage
; /// Drawing page of this sheet.
94 ::oox::drawingml::ShapePtr mxShape
; /// Current top-level shape.
95 std::shared_ptr
< ShapeAnchor
> mxAnchor
; /// Current anchor of top-level shape.
96 EmuRectangle maChartRectEmu
; /// Position and size of the chart object for embedded shapes (in EMUs).
97 bool const mbOleSupport
; /// True = allow to insert OLE objects into the drawing page.
102 } // namespace drawingml
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */