Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/oox/shape/ShapeContextHandler.hxx
Line
Count
Source
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
#pragma once
20
21
#include <memory>
22
#include <stack>
23
#include <cppuhelper/implbase.hxx>
24
#include <oox/drawingml/color.hxx>
25
#include <oox/drawingml/graphicshapecontext.hxx>
26
#include <oox/core/fragmenthandler2.hxx>
27
#include <oox/core/xmlfilterbase.hxx>
28
#include <rtl/ref.hxx>
29
#include <com/sun/star/document/XDocumentProperties.hpp>
30
#include <com/sun/star/graphic/XGraphicMapper.hpp>
31
#include <com/sun/star/drawing/XDrawPage.hpp>
32
#include <com/sun/star/frame/XModel.hpp>
33
34
namespace oox::vml { class DrawingFragment; }
35
36
namespace oox::shape {
37
38
class LockedCanvasContext;
39
class ShapeFilterBase;
40
class WordprocessingCanvasContext;
41
class WpgContext;
42
class WpsContext;
43
44
class ShapeFragmentHandler final : public core::FragmentHandler2
45
{
46
public:
47
    typedef rtl::Reference<ShapeFragmentHandler> Pointer_t;
48
49
    explicit ShapeFragmentHandler(core::XmlFilterBase& rFilter,
50
                                  const OUString& rFragmentPath )
51
4.69k
    : FragmentHandler2(rFilter, rFragmentPath)
52
4.69k
    {
53
4.69k
    }
54
};
55
56
class OOX_DLLPUBLIC ShapeContextHandler final :
57
    public ::cppu::WeakImplHelper< css::xml::sax::XFastContextHandler >
58
{
59
public:
60
    explicit ShapeContextHandler(rtl::Reference<ShapeFilterBase> xFilterBase);
61
62
    virtual ~ShapeContextHandler() override;
63
64
    // css::xml::sax::XFastContextHandler:
65
    virtual void SAL_CALL startFastElement
66
    (::sal_Int32 Element,
67
     const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
68
69
    virtual void SAL_CALL startUnknownElement
70
    (const OUString & Namespace,
71
     const OUString & Name,
72
     const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
73
74
    virtual void SAL_CALL endFastElement(::sal_Int32 Element) override;
75
76
    virtual void SAL_CALL endUnknownElement
77
    (const OUString & Namespace,
78
     const OUString & Name) override;
79
80
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
81
    createFastChildContext
82
    (::sal_Int32 Element,
83
     const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
84
85
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
86
    createUnknownChildContext
87
    (const OUString & Namespace,
88
     const OUString & Name,
89
     const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
90
91
    virtual void SAL_CALL characters(const OUString & aChars) override;
92
93
    css::uno::Reference< css::drawing::XShape > getShape();
94
95
    void setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > & the_value);
96
97
    void setModel(const css::uno::Reference< css::frame::XModel > & the_value);
98
99
    void setRelationFragmentPath(const OUString & the_value);
100
101
    sal_Int32 getStartToken() const;
102
    void popStartToken();
103
    void pushStartToken( sal_Int32 _starttoken );
104
105
    void setPosition(const css::awt::Point& rPosition);
106
    void setSize(const css::awt::Size& rSize);
107
108
451k
    const bool& getFullWPGSupport() { return m_bFullWPGSUpport; }
109
4.24k
    void setFullWPGSupport(bool bUse) { m_bFullWPGSUpport = bUse; }
110
111
439k
    bool isWordProcessingGroupShape() const { return mxWpgContext ? true : false; }
112
427k
    bool isWordprocessingCanvas() const { return mxWordprocessingCanvasContext ? true : false; }
113
114
    void setDocumentProperties(const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
115
    void setMediaDescriptor(const css::uno::Sequence<css::beans::PropertyValue>& rMediaDescriptor);
116
117
    void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rGraphicMapper);
118
119
671
    void setTheme(const oox::drawingml::ThemePtr& pTheme) { mpThemePtr = pTheme; }
120
8.86k
    const oox::drawingml::ThemePtr& getTheme() const { return mpThemePtr; }
121
122
private:
123
    ShapeContextHandler(ShapeContextHandler const &) = delete;
124
    void operator =(ShapeContextHandler const &) = delete;
125
126
    // Special stack which always has at least one element.
127
    // In case of group shapes with embedded content it will have more element than one.
128
    std::stack<sal_uInt32> mnStartTokenStack;
129
130
    css::awt::Point maPosition;
131
    css::awt::Size maSize;  // from cx and cy, in EMU
132
    bool m_bFullWPGSUpport; // Is this DrawingML shape supposed to be processed as WPG?
133
134
    drawingml::ShapePtr mpShape;
135
    std::shared_ptr< vml::Drawing > mpDrawing;
136
137
    typedef rtl::Reference<drawingml::GraphicShapeContext>
138
    GraphicShapeContextPtr;
139
    rtl::Reference<vml::DrawingFragment> mxDrawingFragmentHandler;
140
    css::uno::Reference<XFastContextHandler> mxGraphicShapeContext;
141
    rtl::Reference<drawingml::DiagramGraphicDataContext> mxDiagramShapeContext;
142
    rtl::Reference<LockedCanvasContext> mxLockedCanvasContext;
143
    rtl::Reference<WordprocessingCanvasContext> mxWordprocessingCanvasContext;
144
    rtl::Reference<WpsContext> mxWpsContext;
145
    css::uno::Reference<css::drawing::XShape> mxSavedShape;
146
    rtl::Reference<WpgContext> mxWpgContext;
147
    rtl::Reference<drawingml::ChartGraphicDataContext> mxChartShapeContext;
148
    css::uno::Reference<css::document::XDocumentProperties> mxDocumentProperties;
149
    css::uno::Sequence<css::beans::PropertyValue> maMediaDescriptor;
150
151
    ::rtl::Reference< ShapeFilterBase > mxShapeFilterBase;
152
    drawingml::ThemePtr mpThemePtr;
153
    css::uno::Reference<css::drawing::XDrawPage> mxDrawPage;
154
    OUString msRelationFragmentPath;
155
156
    css::uno::Reference<XFastContextHandler> const & getGraphicShapeContext(::sal_Int32 Element);
157
    css::uno::Reference<XFastContextHandler> getChartShapeContext(::sal_Int32 Element);
158
    css::uno::Reference<XFastContextHandler> getDrawingShapeContext();
159
    css::uno::Reference<XFastContextHandler> getDiagramShapeContext();
160
    css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement);
161
    css::uno::Reference<XFastContextHandler> getWordprocessingCanvasContext(sal_Int32 nElement);
162
    css::uno::Reference<XFastContextHandler> getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement);
163
    css::uno::Reference<XFastContextHandler> getWpgContext(sal_Int32 nElement);
164
    css::uno::Reference<XFastContextHandler> getContextHandler(sal_Int32 nElement = 0);
165
166
    void applyFontRefColor(const oox::drawingml::ShapePtr& pShape,
167
                           const oox::drawingml::Color& rFontRefColor);
168
};
169
}
170
171
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */