1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 25 #define _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 26 27 #include <toolkit/dllapi.h> 28 #include <com/sun/star/uno/Reference.h> 29 #include <com/sun/star/uno/Sequence.h> 30 31 #include <com/sun/star/lang/IllegalArgumentException.hpp> 32 #include <com/sun/star/awt/MouseEvent.hpp> 33 34 35 namespace com { namespace sun { namespace star { namespace uno { 36 class XInterface; 37 }}}} 38 39 namespace com { namespace sun { namespace star { namespace awt { 40 class XBitmap; 41 class XWindow; 42 class XWindow2; 43 class XWindowPeer; 44 class XGraphics; 45 class XRegion; 46 class XDevice; 47 class XPointer; 48 class XToolkit; 49 class XFont; 50 class XControlContainer; 51 struct Size; 52 struct Point; 53 struct SimpleFontMetric; 54 struct FontDescriptor; 55 struct Rectangle; 56 struct KeyEvent; 57 }}}} 58 59 60 #include <vcl/bitmapex.hxx> 61 #include <vcl/region.hxx> 62 #include <vcl/metric.hxx> 63 #include <tools/mapunit.hxx> 64 #include <tools/fldunit.hxx> 65 #include <tools/poly.hxx> 66 67 class Window; 68 class OutputDevice; 69 class MouseEvent; 70 class KeyEvent; 71 72 // ---------------------------------------------------- 73 // class VclUnoHelper 74 // ---------------------------------------------------- 75 class TOOLKIT_DLLPUBLIC VCLUnoHelper 76 { 77 public: 78 // Toolkit 79 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit> CreateToolkit(); 80 81 // Bitmap 82 static BitmapEx GetBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>& rxBitmap ); 83 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap> CreateBitmap( const BitmapEx& rBitmap ); 84 85 // Window 86 static Window* GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& rxWindow ); 87 static Window* GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2>& rxWindow2 ); 88 static Window* GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& rxWindowPeer ); 89 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> GetInterface( Window* pWindow ); 90 91 // OutputDevice 92 static OutputDevice* GetOutputDevice( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>& rxDevice ); 93 static OutputDevice* GetOutputDevice( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics>& rxGraphics ); 94 95 // Region 96 static Region GetRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ); 97 98 99 // Pointer 100 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer> CreatePointer(); 101 102 // Polygon 103 static Polygon CreatePolygon( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY ); 104 105 // Font 106 static ::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& rFont ); 107 static Font CreateFont( const ::com::sun::star::awt::FontDescriptor& rDescr, const Font& rInitFont ); 108 static Font CreateFont( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont >& rxFont ); 109 static ::com::sun::star::awt::SimpleFontMetric CreateFontMetric( const FontMetric& rFontMetric ); 110 static float ConvertFontWidth( FontWidth eWidth ); 111 static FontWidth ConvertFontWidth( float f ); 112 static float ConvertFontWeight( FontWeight eWeight ); 113 static FontWeight ConvertFontWeight( float f ); 114 115 // Rectangle 116 static sal_Bool IsZero( ::com::sun::star::awt::Rectangle rRect ); 117 118 static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> CreateControlContainer( Window* pWindow ); 119 120 // MapUnits 121 static MapUnit UnoEmbed2VCLMapUnit( sal_Int32 nUnoEmbedMapUnit ); 122 static sal_Int32 VCL2UnoEmbedMapUnit( MapUnit nVCLMapUnit ); 123 124 //======================================================================== 125 //= MeasurementUnitConversion 126 //======================================================================== 127 /** small helper to convert between <type>MeasurementUnit</type> and 128 <type>FieldUnit</type> 129 */ 130 static sal_Int16 ConvertToMeasurementUnit( FieldUnit _nFieldUnit, sal_Int16 _rFieldToUNOValueFactor ); 131 static FieldUnit ConvertToFieldUnit( sal_Int16 _nMeasurementUnit, sal_Int16& _rFieldToUNOValueFactor ); 132 133 static MapUnit /* MapModeUnit */ ConvertToMapModeUnit(sal_Int16 /* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit) throw (::com::sun::star::lang::IllegalArgumentException); 134 static sal_Int16 /* com.sun.star.util.MeasureUnit.* */ ConvertToMeasurementUnit(MapUnit /* MapModeUnit */ _nMapModeUnit) throw (::com::sun::star::lang::IllegalArgumentException); 135 136 static ::Size /* VCLSize */ ConvertToVCLSize(::com::sun::star::awt::Size const& _aSize); 137 static ::com::sun::star::awt::Size ConvertToAWTSize(::Size /* VCLSize */ const& _aSize); 138 139 static ::Point /* VCLPoint */ ConvertToVCLPoint(::com::sun::star::awt::Point const& _aPoint); 140 static ::com::sun::star::awt::Point ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint); 141 142 static ::Rectangle ConvertToVCLRect( ::com::sun::star::awt::Rectangle const & _rRect ); 143 static ::com::sun::star::awt::Rectangle ConvertToAWTRect( ::Rectangle const & _rRect ); 144 145 static ::com::sun::star::awt::MouseEvent 146 createMouseEvent( 147 const ::MouseEvent& _rVclEvent, 148 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext 149 ); 150 151 static ::com::sun::star::awt::KeyEvent 152 createKeyEvent( 153 const ::KeyEvent& _rVclEvent, 154 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext 155 ); 156 }; 157 158 159 #endif // _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 160