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 _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
21 #define _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/MouseEvent.hpp>
31 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
35 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
46 class XControlContainer
;
49 struct SimpleFontMetric
;
50 struct FontDescriptor
;
56 #include <vcl/bitmapex.hxx>
57 #include <vcl/region.hxx>
58 #include <vcl/metric.hxx>
59 #include <tools/mapunit.hxx>
60 #include <tools/fldunit.hxx>
61 #include <tools/poly.hxx>
68 // ----------------------------------------------------
70 // ----------------------------------------------------
71 class TOOLKIT_DLLPUBLIC VCLUnoHelper
75 static ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XToolkit
> CreateToolkit();
78 static BitmapEx
GetBitmap( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XBitmap
>& rxBitmap
);
79 static ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XBitmap
> CreateBitmap( const BitmapEx
& rBitmap
);
82 static Window
* GetWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& rxWindow
);
83 static Window
* GetWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow2
>& rxWindow2
);
84 static Window
* GetWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& rxWindowPeer
);
85 static ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> GetInterface( Window
* pWindow
);
88 static OutputDevice
* GetOutputDevice( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDevice
>& rxDevice
);
89 static OutputDevice
* GetOutputDevice( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& rxGraphics
);
92 static Region
GetRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
);
95 static Polygon
CreatePolygon( const ::com::sun::star::uno::Sequence
< sal_Int32
>& DataX
, const ::com::sun::star::uno::Sequence
< sal_Int32
>& DataY
);
97 /** convert Font to ::com::sun::star::awt::FontDescriptor
98 @param rFont Font to be converted
99 @return the new FontDescriptor
101 static ::com::sun::star::awt::FontDescriptor
CreateFontDescriptor( const Font
& rFont
);
102 static Font
CreateFont( const ::com::sun::star::awt::FontDescriptor
& rDescr
, const Font
& rInitFont
);
103 static Font
CreateFont( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFont
>& rxFont
);
104 static ::com::sun::star::awt::SimpleFontMetric
CreateFontMetric( const FontMetric
& rFontMetric
);
105 static float ConvertFontWidth( FontWidth eWidth
);
106 static FontWidth
ConvertFontWidth( float f
);
107 static float ConvertFontWeight( FontWeight eWeight
);
108 static FontWeight
ConvertFontWeight( float f
);
111 static sal_Bool
IsZero( ::com::sun::star::awt::Rectangle rRect
);
113 static ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
> CreateControlContainer( Window
* pWindow
);
116 static MapUnit
UnoEmbed2VCLMapUnit( sal_Int32 nUnoEmbedMapUnit
);
117 static sal_Int32
VCL2UnoEmbedMapUnit( MapUnit nVCLMapUnit
);
119 //========================================================================
120 //= MeasurementUnitConversion
121 //========================================================================
122 /** small helper to convert between <type>MeasurementUnit</type> and
123 <type>FieldUnit</type>
125 static sal_Int16
ConvertToMeasurementUnit( FieldUnit _nFieldUnit
, sal_Int16 _rFieldToUNOValueFactor
);
126 static FieldUnit
ConvertToFieldUnit( sal_Int16 _nMeasurementUnit
, sal_Int16
& _rFieldToUNOValueFactor
);
128 static MapUnit
/* MapModeUnit */ ConvertToMapModeUnit(sal_Int16
/* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit
) throw (::com::sun::star::lang::IllegalArgumentException
);
130 static ::Size
/* VCLSize */ ConvertToVCLSize(::com::sun::star::awt::Size
const& _aSize
);
131 static ::com::sun::star::awt::Size
ConvertToAWTSize(::Size
/* VCLSize */ const& _aSize
);
133 static ::Point
/* VCLPoint */ ConvertToVCLPoint(::com::sun::star::awt::Point
const& _aPoint
);
134 static ::com::sun::star::awt::Point
ConvertToAWTPoint(::Point
/* VCLPoint */ const& _aPoint
);
136 static ::Rectangle
ConvertToVCLRect( ::com::sun::star::awt::Rectangle
const & _rRect
);
137 static ::com::sun::star::awt::Rectangle
ConvertToAWTRect( ::Rectangle
const & _rRect
);
139 static ::com::sun::star::awt::MouseEvent
141 const ::MouseEvent
& _rVclEvent
,
142 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContext
145 static ::com::sun::star::awt::KeyEvent
147 const ::KeyEvent
& _rVclEvent
,
148 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContext
153 #endif // _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */