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_TOOLKIT_HELPER_VCLUNOHELPER_HXX
21 #define INCLUDED_TOOLKIT_HELPER_VCLUNOHELPER_HXX
23 #include <toolkit/dllapi.h>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/uno/Sequence.h>
27 #include <com/sun/star/lang/IllegalArgumentException.hpp>
28 #include <com/sun/star/awt/FontSlant.hpp>
29 #include <com/sun/star/awt/MouseEvent.hpp>
31 #include <vcl/bitmapex.hxx>
32 #include <vcl/region.hxx>
33 #include <vcl/metric.hxx>
34 #include <vcl/vclptr.hxx>
35 #include <vcl/window.hxx>
36 #include <tools/mapunit.hxx>
37 #include <tools/fldunit.hxx>
38 #include <tools/poly.hxx>
41 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
45 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
56 class XControlContainer
;
59 struct SimpleFontMetric
;
60 struct FontDescriptor
;
73 class TOOLKIT_DLLPUBLIC VCLUnoHelper
77 static css::uno::Reference
< css::awt::XToolkit
> CreateToolkit();
80 static BitmapEx
GetBitmap( const css::uno::Reference
< css::awt::XBitmap
>& rxBitmap
);
81 static css::uno::Reference
< css::awt::XBitmap
> CreateBitmap( const BitmapEx
& rBitmap
);
84 static VclPtr
< vcl::Window
> GetWindow( const css::uno::Reference
< css::awt::XWindow
>& rxWindow
);
85 static VclPtr
< vcl::Window
> GetWindow( const css::uno::Reference
< css::awt::XWindow2
>& rxWindow2
);
86 static VclPtr
< vcl::Window
> GetWindow( const css::uno::Reference
< css::awt::XWindowPeer
>& rxWindowPeer
);
87 static css::uno::Reference
< css::awt::XWindow
> GetInterface( vcl::Window
* pWindow
);
90 static OutputDevice
* GetOutputDevice( const css::uno::Reference
< css::awt::XDevice
>& rxDevice
);
91 static OutputDevice
* GetOutputDevice( const css::uno::Reference
< css::awt::XGraphics
>& rxGraphics
);
94 static vcl::Region
GetRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
);
97 static tools::Polygon
CreatePolygon( const css::uno::Sequence
< sal_Int32
>& DataX
, const css::uno::Sequence
< sal_Int32
>& DataY
);
99 /** convert Font to css::awt::FontDescriptor
100 @param rFont Font to be converted
101 @return the new FontDescriptor
103 static css::awt::FontDescriptor
CreateFontDescriptor( const vcl::Font
& rFont
);
104 static vcl::Font
CreateFont( const css::awt::FontDescriptor
& rDescr
, const vcl::Font
& rInitFont
);
105 static vcl::Font
CreateFont( const css::uno::Reference
< css::awt::XFont
>& rxFont
);
106 static css::awt::SimpleFontMetric
CreateFontMetric( const FontMetric
& rFontMetric
);
107 static float ConvertFontWidth( FontWidth eWidth
);
108 static FontWidth
ConvertFontWidth( float f
);
109 static float ConvertFontWeight( FontWeight eWeight
);
110 static FontWeight
ConvertFontWeight( float f
);
111 static css::awt::FontSlant
ConvertFontSlant( FontItalic eWeight
);
112 static FontItalic
ConvertFontSlant( css::awt::FontSlant
);
115 static bool IsZero(const css::awt::Rectangle
& rRect
);
117 static css::uno::Reference
< css::awt::XControlContainer
> CreateControlContainer( vcl::Window
* pWindow
);
120 static MapUnit
UnoEmbed2VCLMapUnit( sal_Int32 nUnoEmbedMapUnit
);
121 static sal_Int32
VCL2UnoEmbedMapUnit( MapUnit nVCLMapUnit
);
124 //= MeasurementUnitConversion
126 /** small helper to convert between MeasurementUnit and
129 static sal_Int16
ConvertToMeasurementUnit( FieldUnit _nFieldUnit
, sal_Int16 _rFieldToUNOValueFactor
);
130 static FieldUnit
ConvertToFieldUnit( sal_Int16 _nMeasurementUnit
, sal_Int16
& _rFieldToUNOValueFactor
);
132 static MapUnit
/* MapModeUnit */ ConvertToMapModeUnit(sal_Int16
/* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit
) throw (css::lang::IllegalArgumentException
);
134 static ::Size
/* VCLSize */ ConvertToVCLSize(css::awt::Size
const& _aSize
);
135 static css::awt::Size
ConvertToAWTSize(::Size
/* VCLSize */ const& _aSize
);
137 static ::Point
/* VCLPoint */ ConvertToVCLPoint(css::awt::Point
const& _aPoint
);
138 static css::awt::Point
ConvertToAWTPoint(::Point
/* VCLPoint */ const& _aPoint
);
140 static ::Rectangle
ConvertToVCLRect( css::awt::Rectangle
const & _rRect
);
141 static css::awt::Rectangle
ConvertToAWTRect( ::Rectangle
const & _rRect
);
143 static css::awt::MouseEvent
145 const ::MouseEvent
& _rVclEvent
,
146 const css::uno::Reference
< css::uno::XInterface
>& _rxContext
149 static ::MouseEvent
createVCLMouseEvent( const css::awt::MouseEvent
& _rAwtEvent
);
151 static css::awt::KeyEvent
153 const ::KeyEvent
& _rVclEvent
,
154 const css::uno::Reference
< css::uno::XInterface
>& _rxContext
157 static ::KeyEvent
createVCLKeyEvent( const css::awt::KeyEvent
& _rAwtEvent
);
161 #endif // INCLUDED_TOOLKIT_HELPER_VCLUNOHELPER_HXX
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */