LibreOffice Module oox (master) 1
graphichelper.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#ifndef INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
21#define INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
22
23#include <map>
24
25#include <com/sun/star/awt/DeviceInfo.hpp>
26#include <com/sun/star/uno/Reference.hxx>
27#include <oox/dllapi.h>
29#include <oox/helper/helper.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>
36
37struct WmfExternal;
38class OutputDevice;
39
40namespace 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; }
50}
51
52namespace oox {
53
54
59{
60public:
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();
66
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;
73
74 // System colors and predefined colors ------------------------------------
75
77 ::Color getSystemColor( sal_Int32 nToken, ::Color nDefaultRgb = API_RGB_TRANSPARENT ) const;
79 virtual ::Color getSchemeColor( sal_Int32 nToken ) const;
81 virtual ::Color getPaletteColor( sal_Int32 nPaletteIdx ) const;
82
83 virtual sal_Int32 getDefaultChartAreaFillStyle() const;
84
86 static sal_Int32 getDefaultChartAreaLineStyle();
87
89 static sal_Int16 getDefaultChartAreaLineWidth();
90
91 // Device info and device dependent unit conversion -----------------------
92
94 const css::awt::DeviceInfo& getDeviceInfo() const { return maDeviceInfo;}
95
97 sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const;
99 sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const;
101 css::awt::Size convertScreenPixelToHmm( const css::awt::Size& rPixel ) const;
102
104 double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const;
106 double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const;
108 css::awt::Point convertHmmToScreenPixel( const css::awt::Point& rHmm ) const;
110 css::awt::Size convertHmmToScreenPixel( const css::awt::Size& rHmm ) const;
111
113 css::awt::Point convertHmmToAppFont( const css::awt::Point& rHmm ) const;
115 css::awt::Size convertHmmToAppFont( const css::awt::Size& rHmm ) const;
116
117
118 // Graphics and graphic objects ------------------------------------------
119
121 css::uno::Reference< css::graphic::XGraphic >
123 const css::uno::Reference< css::io::XInputStream >& rxInStrm,
124 const WmfExternal* pExtHeader = nullptr ) const;
125
127 css::uno::Reference< css::graphic::XGraphic >
128 importGraphic( const StreamDataSequence& rGraphicData ) const;
129
131 css::uno::Reference< css::graphic::XGraphic >
132 importEmbeddedGraphic(
133 const OUString& rStreamName,
134 const WmfExternal* pExtHeader = nullptr ) const;
135
138 css::awt::Size getOriginalSize( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ) const;
139
140 void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper);
141
142 void initializeGraphicMapperIfNeeded() const;
143private:
144
145 css::uno::Reference< css::uno::XComponentContext > mxContext;
146 css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider;
148 css::awt::DeviceInfo maDeviceInfo;
149 ::std::map< sal_Int32, ::Color > maSystemPalette;
153 css::uno::Reference<css::graphic::XGraphicMapper> mxGraphicMapper;
154};
155
156
157} // namespace oox
158
159#endif
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
const css::awt::DeviceInfo & getDeviceInfo() const
Returns information about the output device.
double mfPixelPerHmmY
Number of screen pixels per 1/100 mm in Y direction.
css::uno::Reference< css::graphic::XGraphic > importGraphic(const css::uno::Reference< css::io::XInputStream > &rxInStrm, const WmfExternal *pExtHeader=nullptr) const
Imports a graphic from the passed input stream.
css::awt::DeviceInfo maDeviceInfo
Current output device info.
GraphicHelper(const GraphicHelper &)=delete
::std::map< sal_Int32, ::Color > maSystemPalette
Maps system colors (XML tokens) to RGB color values.
css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider
StorageRef mxStorage
Storage containing embedded graphics.
css::awt::Size convertHmmToAppFont(const css::awt::Size &rHmm) const
Converts the passed size from 1/100 mm to AppFont units.
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::graphic::XGraphicMapper > mxGraphicMapper
GraphicHelper & operator=(const GraphicHelper &)=delete
double mfPixelPerHmmX
Number of screen pixels per 1/100 mm in X direction.
GraphicHelper & operator=(GraphicHelper &&)=delete
VclPtr< OutputDevice > mxDefaultOutputDevice
GraphicHelper(GraphicHelper &&)=delete
css::awt::Size convertHmmToScreenPixel(const css::awt::Size &rHmm) const
Converts the passed size from 1/100 mm to screen pixels.
GraphicHelper(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &rxTargetFrame, StorageRef xStorage)
css::awt::Point convertHmmToScreenPixel(const css::awt::Point &rHmm) const
Converts the passed point from 1/100 mm to screen pixels.
css::awt::Point convertHmmToAppFont(const css::awt::Point &rHmm) const
Converts the passed point from 1/100 mm to AppFont units.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
css::uno::Sequence< sal_Int8 > StreamDataSequence
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.