tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / oox / helper / graphichelper.hxx
blob906d7330dff3e7d9619691bf41a51b072434bbe2
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 #ifndef INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
21 #define INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
23 #include <map>
25 #include <com/sun/star/awt/DeviceInfo.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <oox/dllapi.h>
28 #include <oox/helper/binarystreambase.hxx>
29 #include <oox/helper/helper.hxx>
30 #include <oox/helper/storagebase.hxx>
31 #include <rtl/ustring.hxx>
32 #include <sal/types.h>
33 #include <com/sun/star/graphic/XGraphicProvider2.hpp>
34 #include <com/sun/star/graphic/XGraphicMapper.hpp>
35 #include <vcl/vclptr.hxx>
37 struct WmfExternal;
38 class OutputDevice;
40 namespace com::sun::star {
41 namespace awt { struct Point; }
42 namespace awt { struct Size; }
43 namespace awt { class XUnitConversion; }
44 namespace io { class XInputStream; }
45 namespace frame { class XFrame; }
46 namespace graphic { class XGraphic; }
47 namespace graphic { class XGraphicObject; }
48 namespace graphic { class XGraphicProvider; }
49 namespace uno { class XComponentContext; }
52 namespace oox {
55 /** Provides helper functions for colors, device measurement conversion,
56 graphics, and graphic objects handling.
58 class OOX_DLLPUBLIC GraphicHelper
60 public:
61 explicit GraphicHelper(
62 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
63 const css::uno::Reference< css::frame::XFrame >& rxTargetFrame,
64 StorageRef xStorage );
65 virtual ~GraphicHelper();
67 // Avoid implicitly defined copy constructors/assignments for the DLLPUBLIC class (they may
68 // require forward-declared classes used internally to be defined in places using GraphicHelper)
69 GraphicHelper(const GraphicHelper&) = delete;
70 GraphicHelper(GraphicHelper&&) = delete;
71 GraphicHelper& operator=(const GraphicHelper&) = delete;
72 GraphicHelper& operator=(GraphicHelper&&) = delete;
74 // System colors and predefined colors ------------------------------------
76 /** Returns a system color specified by the passed XML token identifier. */
77 ::Color getSystemColor( sal_Int32 nToken, ::Color nDefaultRgb = API_RGB_TRANSPARENT ) const;
78 /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */
79 virtual ::Color getSchemeColor( sal_Int32 nToken ) const;
80 /** Derived classes may implement to resolve a ColorMap token from the passed XML token identifier. */
81 virtual void getSchemeColorToken(sal_Int32& nToken) const;
82 /** Derived classes may implement to resolve a palette index to an RGB color. */
83 virtual ::Color getPaletteColor( sal_Int32 nPaletteIdx ) const;
85 virtual sal_Int32 getDefaultChartAreaFillStyle() const;
87 /** Returns chartspace automatic default border style */
88 static sal_Int32 getDefaultChartAreaLineStyle();
90 /** Returns chartspace automatic default border width in Emu */
91 static sal_Int16 getDefaultChartAreaLineWidth();
93 // Device info and device dependent unit conversion -----------------------
95 /** Returns information about the output device. */
96 const css::awt::DeviceInfo& getDeviceInfo() const { return maDeviceInfo;}
98 /** Converts the passed value from horizontal screen pixels to 1/100 mm. */
99 sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const;
100 /** Converts the passed value from vertical screen pixels to 1/100 mm. */
101 sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const;
102 /** Converts the passed size from screen pixels to 1/100 mm. */
103 css::awt::Size convertScreenPixelToHmm( const css::awt::Size& rPixel ) const;
105 /** Converts the passed value from 1/100 mm to horizontal screen pixels. */
106 double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const;
107 /** Converts the passed value from 1/100 mm to vertical screen pixels. */
108 double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const;
109 /** Converts the passed point from 1/100 mm to screen pixels. */
110 css::awt::Point convertHmmToScreenPixel( const css::awt::Point& rHmm ) const;
111 /** Converts the passed size from 1/100 mm to screen pixels. */
112 css::awt::Size convertHmmToScreenPixel( const css::awt::Size& rHmm ) const;
114 /** Converts the passed point from 1/100 mm to AppFont units. */
115 css::awt::Point convertHmmToAppFont( const css::awt::Point& rHmm ) const;
116 /** Converts the passed size from 1/100 mm to AppFont units. */
117 css::awt::Size convertHmmToAppFont( const css::awt::Size& rHmm ) const;
120 // Graphics and graphic objects ------------------------------------------
122 /** Imports a graphic from the passed input stream. */
123 css::uno::Reference< css::graphic::XGraphic >
124 importGraphic(
125 const css::uno::Reference< css::io::XInputStream >& rxInStrm,
126 const WmfExternal* pExtHeader = nullptr,
127 const bool bLazyLoad = true ) const;
129 /** Imports a graphic from the passed binary memory block. */
130 css::uno::Reference< css::graphic::XGraphic >
131 importGraphic( const StreamDataSequence& rGraphicData ) const;
133 /** Imports a graphic from the storage stream with the passed path and name. */
134 css::uno::Reference< css::graphic::XGraphic >
135 importEmbeddedGraphic(
136 const OUString& rStreamName,
137 const WmfExternal* pExtHeader = nullptr ) const;
139 /** calculates the original size of a graphic which is necessary to be able to calculate cropping values
140 @return The original Graphic size in 100thmm */
141 css::awt::Size getOriginalSize( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ) const;
143 void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper);
145 void initializeGraphicMapperIfNeeded() const;
146 private:
148 css::uno::Reference< css::uno::XComponentContext > mxContext;
149 css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider;
150 VclPtr<OutputDevice> mxDefaultOutputDevice;
151 css::awt::DeviceInfo maDeviceInfo; ///< Current output device info.
152 ::std::map< sal_Int32, ::Color > maSystemPalette; ///< Maps system colors (XML tokens) to RGB color values.
153 StorageRef mxStorage; ///< Storage containing embedded graphics.
154 double mfPixelPerHmmX; ///< Number of screen pixels per 1/100 mm in X direction.
155 double mfPixelPerHmmY; ///< Number of screen pixels per 1/100 mm in Y direction.
156 css::uno::Reference<css::graphic::XGraphicMapper> mxGraphicMapper;
160 } // namespace oox
162 #endif
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */