LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / source / filter / inc / drawingfragment.hxx
blobf93a13bc2059e1b5775c83218be1514712fb470a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <memory>
23 #include <oox/drawingml/shapegroupcontext.hxx>
24 #include <oox/ole/axcontrol.hxx>
25 #include <oox/drawingml/shape.hxx>
26 #include <oox/ole/vbaproject.hxx>
27 #include <oox/vml/vmldrawing.hxx>
28 #include <oox/vml/vmldrawingfragment.hxx>
29 #include <oox/vml/vmltextbox.hxx>
30 #include "drawingbase.hxx"
31 #include "excelhandlers.hxx"
33 namespace oox::ole {
34 struct AxFontData;
37 namespace oox::xls {
39 // DrawingML
41 class ShapeMacroAttacher final : public ::oox::ole::VbaMacroAttacherBase
43 public:
44 explicit ShapeMacroAttacher( const OUString& rMacroName,
45 const css::uno::Reference< css::drawing::XShape >& rxShape );
47 private:
48 virtual void attachMacro( const OUString& rMacroUrl ) override;
50 private:
51 css::uno::Reference< css::drawing::XShape > mxShape;
54 class Shape final : public ::oox::drawingml::Shape, public WorksheetHelper
56 public:
57 explicit Shape(
58 const WorksheetHelper& rHelper,
59 const AttributeList& rAttribs,
60 const char* pcServiceName );
62 private:
63 virtual void finalizeXShape(
64 ::oox::core::XmlFilterBase& rFilter,
65 const css::uno::Reference< css::drawing::XShapes >& rxShapes ) override;
67 OUString maMacroName;
70 /** Context handler for creation of shapes embedded in group shapes. */
71 class GroupShapeContext final : public ::oox::drawingml::ShapeGroupContext, public WorksheetHelper
73 public:
74 explicit GroupShapeContext(
75 const ::oox::core::FragmentHandler2& rParent,
76 const WorksheetHelper& rHelper,
77 const ::oox::drawingml::ShapePtr& rxParentShape,
78 const ::oox::drawingml::ShapePtr& rxShape );
80 static ::oox::core::ContextHandlerRef
81 createShapeContext(
82 ::oox::core::FragmentHandler2& rParent,
83 const WorksheetHelper& rHelper,
84 sal_Int32 nElement,
85 const AttributeList& rAttribs,
86 const ::oox::drawingml::ShapePtr& rxParentShape,
87 ::oox::drawingml::ShapePtr* pxShape = nullptr );
89 private:
90 virtual ::oox::core::ContextHandlerRef
91 onCreateContext(
92 sal_Int32 nElement,
93 const ::oox::AttributeList& rAttribs ) override;
96 /** Fragment handler for a complete sheet drawing. */
97 class DrawingFragment final : public WorksheetFragmentBase
99 public:
100 explicit DrawingFragment(
101 const WorksheetHelper& rHelper,
102 const OUString& rFragmentPath );
104 private:
105 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
106 virtual void onCharacters( const OUString& rChars ) override;
107 virtual void onEndElement() override;
109 typedef ::std::unique_ptr< ShapeAnchor > ShapeAnchorRef;
111 css::uno::Reference< css::drawing::XShapes >
112 mxDrawPage; /// Drawing page of this sheet.
113 ::oox::drawingml::ShapePtr mxShape; /// Current top-level shape.
114 ShapeAnchorRef mxAnchor; /// Current anchor of top-level shape.
117 // VML
119 class VmlControlMacroAttacher final : public ::oox::ole::VbaMacroAttacherBase
121 public:
122 explicit VmlControlMacroAttacher( const OUString& rMacroName,
123 const css::uno::Reference< css::container::XIndexContainer >& rxCtrlFormIC,
124 sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle );
126 private:
127 virtual void attachMacro( const OUString& rMacroUrl ) override;
129 private:
130 css::uno::Reference< css::container::XIndexContainer > mxCtrlFormIC;
131 sal_Int32 mnCtrlIndex;
132 sal_Int32 mnCtrlType;
133 sal_Int32 mnDropStyle;
136 class VmlDrawing final : public ::oox::vml::Drawing, public WorksheetHelper
138 public:
139 explicit VmlDrawing( const WorksheetHelper& rHelper );
141 /** Returns the drawing shape for a cell note at the specified position. */
142 const ::oox::vml::ShapeBase* getNoteShape( const ScAddress& rPos ) const;
144 /** Filters cell note shapes. */
145 virtual bool isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const override;
147 /** Returns additional base names for automatic shape name creation. */
148 virtual OUString getShapeBaseName( const ::oox::vml::ShapeBase& rShape ) const override;
150 /** Calculates the shape rectangle from a cell anchor string. */
151 virtual bool convertClientAnchor(
152 css::awt::Rectangle& orShapeRect,
153 const OUString& rShapeAnchor ) const override;
155 /** Creates a UNO control shape for legacy drawing controls. */
156 virtual css::uno::Reference< css::drawing::XShape >
157 createAndInsertClientXShape(
158 const ::oox::vml::ShapeBase& rShape,
159 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
160 const css::awt::Rectangle& rShapeRect ) const override;
162 /** Updates the bounding box covering all shapes of this drawing. */
163 virtual void notifyXShapeInserted(
164 const css::uno::Reference< css::drawing::XShape >& rxShape,
165 const css::awt::Rectangle& rShapeRect,
166 const ::oox::vml::ShapeBase& rShape, bool bGroupChild ) override;
168 private:
169 /** Converts the passed VML textbox text color to an OLE color. */
170 sal_uInt32 convertControlTextColor( const OUString& rTextColor ) const;
171 /** Converts the passed VML textbox font to an ActiveX form control font. */
172 void convertControlFontData(
173 ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor,
174 const ::oox::vml::TextFontModel& rFontModel ) const;
175 /** Converts the caption, the font settings, and the horizontal alignment
176 from the passed VML textbox to ActiveX form control settings. */
177 void convertControlText(
178 ::oox::ole::AxFontData& rAxFontData, sal_uInt32& rnOleTextColor, OUString& rCaption,
179 const ::oox::vml::TextBox* pTextBox, sal_Int32 nTextHAlign ) const;
180 /** Converts the passed VML shape background formatting to ActiveX control formatting. */
181 void convertControlBackground(
182 ::oox::ole::AxMorphDataModelBase& rAxModel,
183 const ::oox::vml::ShapeBase& rShape ) const;
185 private:
186 ::oox::ole::ControlConverter maControlConv;
187 ::oox::vml::TextFontModel maListBoxFont;
190 class VmlDrawingFragment final : public ::oox::vml::DrawingFragment, public WorksheetHelper
192 public:
193 explicit VmlDrawingFragment(
194 const WorksheetHelper& rHelper,
195 const OUString& rFragmentPath );
197 private:
198 virtual void finalizeImport() override;
201 } // namespace oox::xls
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */