2009-09-09 07:53:55 +0200 oj r275964 : replace strlen with rtl_str_getLength 2009-09-07 20:59:10 +0200 fs r275913 : disable the CopyTableWizard test until issue 104869 is fixed 2009-09-07 12:17:31 +0200 oj r275885 : #i104810# remove de as lang 2009-09-05 22:26:21 +0200 fs r275857 : protect StateChanged against re-entrance 2009-09-05 22:25:52 +0200 fs r275856 : don't attempt to classify the parent of a form as control 2009-09-05 22:25:29 +0200 fs r275855 : protect against re-entrance 2009-09-05 00:11:40 +0200 fs r275835 : #i10000# 2009-09-04 23:25:50 +0200 fs r275834 : #i10000# 2009-09-04 23:23:47 +0200 fs r275833 : #i10000# 2009-09-04 21:49:37 +0200 fs r275830 : #i10000# correct wrong conflict resolution 2009-09-04 20:59:51 +0200 fs r275829 : CWS-TOOLING: rebase CWS dba32g to trunk@275801 (milestone: DEV300:m57) 2009-09-04 11:08:32 +0200 oj r275791 : #i104780# new version 1.2.0 2009-09-03 22:29:21 +0200 fs r275775 : OSL_TRACE doesn't need \n anymore 2009-09-03 08:33:21 +0200 fs r275743 : CWS-TOOLING: rebase CWS dba32g to trunk@275331 (milestone: DEV300:m56) 2009-09-02 13:48:12 +0200 fs r275708 : removed useless include 2009-09-02 13:45:43 +0200 fs r275707 : more since tags, which are used across offapi/udkapi 2009-09-02 13:23:04 +0200 fs r275705 : should *not* have the dtor, copy ctor, and assignment operator compiler-generated, else we run into trouble as soon as the compiler creates different versions of our singleton member's static data in different libraries 2009-09-02 12:32:45 +0200 fs r275704 : AutoIncrementIsPrimaryKey is a driver setting, not a data source setting 2009-09-02 11:42:49 +0200 fs r275701 : URL meta data are meta data which are valid for all connections of this type, not per-data-source properties. Settings them as data source properties is a hack. 2009-09-02 08:43:34 +0200 fs r275696 : 3.x.x is not a valid 'since' tag 2009-09-01 16:05:24 +0200 fs r275665 : #i104686# don't treat controls bound to read-only columns as required 2009-09-01 13:10:22 +0200 fs r275657 : #i104574# use PageUp/Down to scroll through the complete page 2009-09-01 07:04:48 +0200 oj r275641 : #i104104# correct line ends 2009-08-31 15:52:34 +0200 fs r275612 : #i104410# 2009-08-31 12:29:05 +0200 fs r275596 : #i104364# 2009-08-31 12:28:56 +0200 fs r275595 : #i104364# 2009-08-31 11:43:09 +0200 fs r275593 : #i104649# JavaDriverClassPath is also a known JDBC-bridge setting 2009-08-31 11:41:37 +0200 fs r275592 : #i104649# 2009-08-28 21:48:27 +0200 fs r275552 : during #i96862#: renamed the configuration data which controls availability of certain DBA-related UI 2009-08-28 21:48:17 +0200 fs r275551 : #i96862# do not show the 'Create a new database' option when a) no embedded/dBase driver is installed or b) the configuration requests to hide the option 2009-08-28 21:47:19 +0200 fs r275550 : during #i96862#: renamed the configuration data which controls availability of certain DBA-related UI 2009-08-28 21:46:41 +0200 fs r275549 : #i96862# renamed and extended the configuration data which controls availability of certain DBA-related UI 2009-08-28 15:10:19 +0200 fs r275535 : #i96862# if no embedded driver is installed, use dBase for creating new DBs. If no dBase driver is installed, too, do not offer the 'Create new database' option 2009-08-28 14:03:04 +0200 fs r275532 : #i104454# allow multiple fields to display the same column 2009-08-28 13:14:00 +0200 fs r275528 : #i104584# driver meta data do not belong into a data source's settings 2009-08-28 13:09:57 +0200 fs r275527 : properly chech the MySQL type buttons (else next/back in the wizard leads to state with two buttons checked) 2009-08-28 13:09:17 +0200 fs r275526 : #i104584# driver meta data do not belong into a data source's settings 2009-08-28 13:07:18 +0200 fs r275525 : BooleanComparisonMode is a property, or a feature - but not a driver meta data 2009-08-28 11:00:31 +0200 fs r275521 : #i104580# 2009-08-28 10:40:05 +0200 fs r275519 : #i104577# correct assertion: If the template node type is ANY, then any value type is allowed 2009-08-28 10:09:30 +0200 fs r275518 : #i104575# implement Named Pipe UI 2009-08-28 10:09:07 +0200 fs r275517 : pass the trigger-event to IWindowOperator::operateOn / work with VclWindowEvents, not VclSimpleEvents 2009-08-27 14:27:36 +0200 fs r275484 : ImplPosTabPage: respect mbEmptyViewMargin for WINDOWALIGN_LEFT 2009-08-27 13:43:56 +0200 fs r275480 : merging latest changes from CWS dba32f herein 2009-08-27 13:23:07 +0200 fs r275475 : #i103882# 2009-08-27 11:56:55 +0200 fs r275466 : #i104544# SetState: Do not call Update at the window which we just set text for. It should (sic\!) not be needed, but causes trouble 2009-08-27 11:55:34 +0200 fs r275465 : #i104544# do not allow re-entrance for impl_ensureControl_nothrow Actually, this is part of the fix only. I also removed the code which triggered this re-entrance (from the grid control implementation), but to ensure it won't happen, again, I added some safety herein. 2009-08-27 10:14:11 +0200 fs r275459 : preparations for supporting a 'NamedPipe' parameter for the MySQL Connector/OOo 2009-08-27 10:13:21 +0200 fs r275458 : preparations for supporting a 'NamedPipe' setting for the MySQL Connector/OOo 2009-08-27 10:11:14 +0200 fs r275456 : outsourced the MySQLNative settings into a dedicated class, to not duplicate all the code in two tab page implementations 2009-08-26 14:18:13 +0200 fs r275422 : #i10000# 2009-08-26 13:26:36 +0200 fs r275419 : ignore output paths 2009-08-26 13:23:38 +0200 fs r275417 : support the LocalSocket property for the MySQL native driver 2009-08-26 13:17:05 +0200 fs r275416 : some re-factoring, to outsource the tab page for setting up the MySQLNative connection, into a dedicated class (needed later) 2009-08-26 13:15:15 +0200 fs r275415 : support a NoThousandSep property for NumericFormatters - I'm tired of correcting this at runtime, instead of controlling it in the resource 2009-08-26 11:45:08 +0200 fs r275410 : oops, 'flat' shouldn't have got lost 2009-08-26 09:38:57 +0200 fs r275398 : #i102631# when saving the document fails, ensure that the interaction handler really can handle/display the error 2009-08-26 09:37:05 +0200 fs r275397 : #i102631# don't let non-IO/RuntimeExceptions escape from DatabaseDocument::store*, wrap them into an IOException 2009-08-26 09:35:39 +0200 fs r275395 : let the default interaction handler implement XInteractionHandler2 2009-08-25 13:51:34 +0200 fs r275352 : #i102631# createTempFile: pass URL through FileHelper.getOOoCompatibleFileURL 2009-08-25 13:49:23 +0200 fs r275351 : #i102631# createTempFileURL: immediately delete the file implicitly created by createTempFile, we really only need the URL 2009-08-24 14:49:07 +0200 fs r275318 : #i10000# 2009-08-24 14:36:03 +0200 fs r275315 : properly terminate message with 0 character 2009-08-24 14:35:45 +0200 fs r275314 : trace method concepts in non-pro, if special flag is enabled 2009-08-24 14:24:17 +0200 fs r275312 : #i98973# filter some more events for grid control columns 2009-08-24 14:15:23 +0200 fs r275311 : #i98973# implement XComboBox for combo box cells 2009-08-24 13:39:24 +0200 fs r275308 : #i98973# do not display the 'actionPerformed' event for grid combo box columns 2009-08-24 12:52:03 +0200 fs r275303 : #i98973# implement XCheckBox and XButton for check box cells 2009-08-24 11:56:05 +0200 oj r275300 : #i104447# wrong default for orientation 2009-08-24 10:51:21 +0200 fs r275296 : in the script selector dialog, interpret a double click onto a function as OK 2009-08-24 10:50:56 +0200 fs r275295 : localize some to-be-displayed names, consolidate some code regarding form/control naming 2009-08-21 14:28:05 +0200 fs r275255 : #i98973# implement KeyListeners 2009-08-21 14:27:20 +0200 fs r275254 : #i98973# move the conversion VCL[Mouse|Key]Event->Awt[Mouse|Key]Event from vclxwindow.cxx to VCLUnoHelper 2009-08-21 14:08:50 +0200 fs r275248 : #i98973# implement Mouse- and MouseMotion-broadcasting 2009-08-21 13:31:08 +0200 fs r275244 : #i98973# implement text and change listeners at text cells 2009-08-21 12:47:38 +0200 fs r275234 : #i104399# some refactoring: If the MySQL Connector/OOo is installed, it registers for the sdbc:mysqlc: protocol (now known as DST_MYSQL_NATIVE_DIRECT). However, we do not want to display this in the UI, instead we display "MySQL" only, which collects DST_MYSQL_ODBC, DST_MYSQL_JDBC, and DST_MYSQL_NATIVE. 2009-08-21 12:45:18 +0200 fs r275232 : #i104399# also register for the sdbc:mysql:mysqlc protocol, decide at runtime (depending on the availability of sdbc:mysqlc:), whether it is really accepted. This prevents that the C/OOo extension needs to register *our* implementation name for the sdbc:mysql:mysqlc: protocol, which would be somewhat weird 2009-08-20 16:18:48 +0200 fs r275190 : merging the latest changes from CWS dba32f (which this CWS was created from) 2009-08-19 20:19:59 +0200 fs r275160 : add some spacing between the radios 2009-08-19 14:50:15 +0200 fs r275150 : #i98973# slightly refactoring the grid cell implementations, to prepare for proper events being fired. Implement focus events for the moment, more to come. 2009-08-19 10:53:38 +0200 fs r275142 : #i99936# initialize newly created models 2009-08-18 23:03:48 +0200 fs r275132 : merging latest changes from CWS dba32f 2009-08-18 15:14:08 +0200 fs r275110 : #i102819# SetColumnPos: SCROLL_CLIP is deadly here
803 lines
29 KiB
C++
803 lines
29 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: vclunohelper.cxx,v $
|
|
* $Revision: 1.19 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_toolkit.hxx"
|
|
|
|
#include <tools/debug.hxx>
|
|
#include <tools/stream.hxx>
|
|
#include <vcl/bitmap.hxx>
|
|
#include <vcl/window.hxx>
|
|
#include <com/sun/star/util/MeasureUnit.hpp>
|
|
#include <com/sun/star/awt/XBitmap.hpp>
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
#include <com/sun/star/awt/XDevice.hpp>
|
|
#include <com/sun/star/awt/XPointer.hpp>
|
|
#include <com/sun/star/awt/SimpleFontMetric.hpp>
|
|
#include <com/sun/star/awt/FontDescriptor.hpp>
|
|
#include <com/sun/star/awt/XControlContainer.hpp>
|
|
#include <com/sun/star/awt/FontWeight.hpp>
|
|
#include <com/sun/star/awt/FontWidth.hpp>
|
|
#include <com/sun/star/awt/KeyModifier.hpp>
|
|
#include <com/sun/star/awt/MouseButton.hpp>
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
#include <com/sun/star/embed/EmbedMapUnits.hpp>
|
|
|
|
#include <com/sun/star/graphic/XGraphic.hpp>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
#include <toolkit/helper/convert.hxx>
|
|
#include <toolkit/awt/vclxbitmap.hxx>
|
|
#include <toolkit/awt/vclxregion.hxx>
|
|
#include <toolkit/awt/vclxwindow.hxx>
|
|
#include <toolkit/awt/vclxgraphics.hxx>
|
|
#include <toolkit/awt/vclxpointer.hxx>
|
|
#include <toolkit/awt/vclxfont.hxx>
|
|
#include <toolkit/controls/unocontrolcontainer.hxx>
|
|
#include <toolkit/controls/unocontrolcontainermodel.hxx>
|
|
|
|
#include <vcl/graph.hxx>
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <com/sun/star/awt/Size.hpp>
|
|
#include <com/sun/star/awt/Point.hpp>
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
// ----------------------------------------------------
|
|
// class VCLUnoHelper
|
|
// ----------------------------------------------------
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit> VCLUnoHelper::CreateToolkit()
|
|
{
|
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
|
|
::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > xI = xMSF->createInstance( ::rtl::OUString::createFromAscii( szServiceName2_Toolkit ) );
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit> xToolkit;
|
|
if ( xI.is() )
|
|
xToolkit = ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit>( xI, ::com::sun::star::uno::UNO_QUERY );
|
|
|
|
return xToolkit;
|
|
}
|
|
|
|
BitmapEx VCLUnoHelper::GetBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>& rxBitmap )
|
|
{
|
|
BitmapEx aBmp;
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic( rxBitmap, ::com::sun::star::uno::UNO_QUERY );
|
|
if( xGraphic.is() )
|
|
{
|
|
Graphic aGraphic( xGraphic );
|
|
aBmp = aGraphic.GetBitmapEx();
|
|
}
|
|
else if ( rxBitmap.is() )
|
|
{
|
|
VCLXBitmap* pVCLBitmap = VCLXBitmap::GetImplementation( rxBitmap );
|
|
if ( pVCLBitmap )
|
|
aBmp = pVCLBitmap->GetBitmap();
|
|
else
|
|
{
|
|
Bitmap aDIB, aMask;
|
|
{
|
|
::com::sun::star::uno::Sequence<sal_Int8> aBytes = rxBitmap->getDIB();
|
|
SvMemoryStream aMem( (char*) aBytes.getArray(), aBytes.getLength(), STREAM_READ );
|
|
aMem >> aDIB;
|
|
}
|
|
{
|
|
::com::sun::star::uno::Sequence<sal_Int8> aBytes = rxBitmap->getMaskDIB();
|
|
SvMemoryStream aMem( (char*) aBytes.getArray(), aBytes.getLength(), STREAM_READ );
|
|
aMem >> aMask;
|
|
}
|
|
aBmp = BitmapEx( aDIB, aMask );
|
|
}
|
|
}
|
|
return aBmp;
|
|
}
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap> VCLUnoHelper::CreateBitmap( const BitmapEx& rBitmap )
|
|
{
|
|
Graphic aGraphic( rBitmap );
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap> xBmp( aGraphic.GetXGraphic(), ::com::sun::star::uno::UNO_QUERY );
|
|
return xBmp;
|
|
}
|
|
|
|
Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& rxWindow )
|
|
{
|
|
VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow );
|
|
return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL;
|
|
}
|
|
|
|
Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2>& rxWindow )
|
|
{
|
|
VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow );
|
|
return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL;
|
|
}
|
|
|
|
Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& rxWindow )
|
|
{
|
|
VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow );
|
|
return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL;
|
|
}
|
|
|
|
Region VCLUnoHelper::GetRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion )
|
|
{
|
|
Region aRegion;
|
|
VCLXRegion* pVCLRegion = VCLXRegion::GetImplementation( rxRegion );
|
|
if ( pVCLRegion )
|
|
aRegion = pVCLRegion->GetRegion();
|
|
else
|
|
{
|
|
::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects = rxRegion->getRectangles();
|
|
sal_Int32 nRects = aRects.getLength();
|
|
for ( sal_Int32 n = 0; n < nRects; n++ )
|
|
aRegion.Union( VCLRectangle( aRects.getArray()[n] ) );
|
|
}
|
|
return aRegion;
|
|
}
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> VCLUnoHelper::GetInterface( Window* pWindow )
|
|
{
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWin;
|
|
if ( pWindow )
|
|
{
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> xPeer = pWindow->GetComponentInterface();
|
|
xWin = xWin.query( xPeer );
|
|
}
|
|
return xWin;
|
|
}
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer> VCLUnoHelper::CreatePointer()
|
|
{
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer> xPointer = new VCLXPointer;
|
|
return xPointer;
|
|
}
|
|
|
|
OutputDevice* VCLUnoHelper::GetOutputDevice( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>& rxDevice )
|
|
{
|
|
OutputDevice* pOutDev = NULL;
|
|
VCLXDevice* pDev = VCLXDevice::GetImplementation( rxDevice );
|
|
if ( pDev )
|
|
pOutDev = pDev->GetOutputDevice();
|
|
return pOutDev;
|
|
}
|
|
|
|
OutputDevice* VCLUnoHelper::GetOutputDevice( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics>& rxGraphics )
|
|
{
|
|
OutputDevice* pOutDev = NULL;
|
|
VCLXGraphics* pGrf = VCLXGraphics::GetImplementation( rxGraphics );
|
|
if ( pGrf )
|
|
pOutDev = pGrf->GetOutputDevice();
|
|
return pOutDev;
|
|
}
|
|
|
|
Polygon VCLUnoHelper::CreatePolygon( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY )
|
|
{
|
|
sal_uInt32 nLen = DataX.getLength();
|
|
const sal_Int32* pDataX = DataX.getConstArray();
|
|
const sal_Int32* pDataY = DataY.getConstArray();
|
|
Polygon aPoly( (sal_uInt16) nLen );
|
|
for ( sal_uInt16 n = 0; n < nLen; n++ )
|
|
{
|
|
Point aPnt;
|
|
aPnt.X() = pDataX[n];
|
|
aPnt.Y() = pDataY[n];
|
|
aPoly[n] = aPnt;
|
|
}
|
|
return aPoly;
|
|
}
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> VCLUnoHelper::CreateControlContainer( Window* pWindow )
|
|
{
|
|
UnoControlContainer* pContainer = new UnoControlContainer( pWindow->GetComponentInterface( sal_True ) );
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > x = pContainer;
|
|
|
|
UnoControlModel* pContainerModel = new UnoControlContainerModel;
|
|
pContainer->setModel( (::com::sun::star::awt::XControlModel*)pContainerModel );
|
|
|
|
return x;
|
|
}
|
|
|
|
float VCLUnoHelper::ConvertFontWidth( FontWidth eWidth )
|
|
{
|
|
if( eWidth == WIDTH_DONTKNOW )
|
|
return ::com::sun::star::awt::FontWidth::DONTKNOW;
|
|
else if( eWidth == WIDTH_ULTRA_CONDENSED )
|
|
return ::com::sun::star::awt::FontWidth::ULTRACONDENSED;
|
|
else if( eWidth == WIDTH_EXTRA_CONDENSED )
|
|
return ::com::sun::star::awt::FontWidth::EXTRACONDENSED;
|
|
else if( eWidth == WIDTH_CONDENSED )
|
|
return ::com::sun::star::awt::FontWidth::CONDENSED;
|
|
else if( eWidth == WIDTH_SEMI_CONDENSED )
|
|
return ::com::sun::star::awt::FontWidth::SEMICONDENSED;
|
|
else if( eWidth == WIDTH_NORMAL )
|
|
return ::com::sun::star::awt::FontWidth::NORMAL;
|
|
else if( eWidth == WIDTH_SEMI_EXPANDED )
|
|
return ::com::sun::star::awt::FontWidth::SEMIEXPANDED;
|
|
else if( eWidth == WIDTH_EXPANDED )
|
|
return ::com::sun::star::awt::FontWidth::EXPANDED;
|
|
else if( eWidth == WIDTH_EXTRA_EXPANDED )
|
|
return ::com::sun::star::awt::FontWidth::EXTRAEXPANDED;
|
|
else if( eWidth == WIDTH_ULTRA_EXPANDED )
|
|
return ::com::sun::star::awt::FontWidth::ULTRAEXPANDED;
|
|
|
|
DBG_ERROR( "Unknown FontWidth" );
|
|
return ::com::sun::star::awt::FontWidth::DONTKNOW;
|
|
}
|
|
|
|
FontWidth VCLUnoHelper::ConvertFontWidth( float f )
|
|
{
|
|
if( f <= ::com::sun::star::awt::FontWidth::DONTKNOW )
|
|
return WIDTH_DONTKNOW;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::ULTRACONDENSED )
|
|
return WIDTH_ULTRA_CONDENSED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::EXTRACONDENSED )
|
|
return WIDTH_EXTRA_CONDENSED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::CONDENSED )
|
|
return WIDTH_CONDENSED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::SEMICONDENSED )
|
|
return WIDTH_SEMI_CONDENSED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::NORMAL )
|
|
return WIDTH_NORMAL;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::SEMIEXPANDED )
|
|
return WIDTH_SEMI_EXPANDED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::EXPANDED )
|
|
return WIDTH_EXPANDED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::EXTRAEXPANDED )
|
|
return WIDTH_EXTRA_EXPANDED;
|
|
else if( f <= ::com::sun::star::awt::FontWidth::ULTRAEXPANDED )
|
|
return WIDTH_ULTRA_EXPANDED;
|
|
|
|
DBG_ERROR( "Unknown FontWidth" );
|
|
return WIDTH_DONTKNOW;
|
|
}
|
|
|
|
float VCLUnoHelper::ConvertFontWeight( FontWeight eWeight )
|
|
{
|
|
if( eWeight == WEIGHT_DONTKNOW )
|
|
return ::com::sun::star::awt::FontWeight::DONTKNOW;
|
|
else if( eWeight == WEIGHT_THIN )
|
|
return ::com::sun::star::awt::FontWeight::THIN;
|
|
else if( eWeight == WEIGHT_ULTRALIGHT )
|
|
return ::com::sun::star::awt::FontWeight::ULTRALIGHT;
|
|
else if( eWeight == WEIGHT_LIGHT )
|
|
return ::com::sun::star::awt::FontWeight::LIGHT;
|
|
else if( eWeight == WEIGHT_SEMILIGHT )
|
|
return ::com::sun::star::awt::FontWeight::SEMILIGHT;
|
|
else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) )
|
|
return ::com::sun::star::awt::FontWeight::NORMAL;
|
|
else if( eWeight == WEIGHT_SEMIBOLD )
|
|
return ::com::sun::star::awt::FontWeight::SEMIBOLD;
|
|
else if( eWeight == WEIGHT_BOLD )
|
|
return ::com::sun::star::awt::FontWeight::BOLD;
|
|
else if( eWeight == WEIGHT_ULTRABOLD )
|
|
return ::com::sun::star::awt::FontWeight::ULTRABOLD;
|
|
else if( eWeight == WEIGHT_BLACK )
|
|
return ::com::sun::star::awt::FontWeight::BLACK;
|
|
|
|
DBG_ERROR( "Unknown FontWeigth" );
|
|
return ::com::sun::star::awt::FontWeight::DONTKNOW;
|
|
}
|
|
|
|
FontWeight VCLUnoHelper::ConvertFontWeight( float f )
|
|
{
|
|
if( f <= ::com::sun::star::awt::FontWeight::DONTKNOW )
|
|
return WEIGHT_DONTKNOW;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::THIN )
|
|
return WEIGHT_THIN;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::ULTRALIGHT )
|
|
return WEIGHT_ULTRALIGHT;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::LIGHT )
|
|
return WEIGHT_LIGHT;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::SEMILIGHT )
|
|
return WEIGHT_SEMILIGHT;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::NORMAL )
|
|
return WEIGHT_NORMAL;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::SEMIBOLD )
|
|
return WEIGHT_SEMIBOLD;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::BOLD )
|
|
return WEIGHT_BOLD;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::ULTRABOLD )
|
|
return WEIGHT_ULTRABOLD;
|
|
else if( f <= ::com::sun::star::awt::FontWeight::BLACK )
|
|
return WEIGHT_BLACK;
|
|
|
|
DBG_ERROR( "Unknown FontWeigth" );
|
|
return WEIGHT_DONTKNOW;
|
|
}
|
|
|
|
|
|
::com::sun::star::awt::FontDescriptor VCLUnoHelper::CreateFontDescriptor( const Font& rFont )
|
|
{
|
|
::com::sun::star::awt::FontDescriptor aFD;
|
|
aFD.Name = rFont.GetName();
|
|
aFD.StyleName = rFont.GetStyleName();
|
|
aFD.Height = (sal_Int16)rFont.GetSize().Height();
|
|
aFD.Width = (sal_Int16)rFont.GetSize().Width();
|
|
aFD.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
|
|
aFD.CharSet = rFont.GetCharSet();
|
|
aFD.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
|
|
aFD.CharacterWidth = VCLUnoHelper::ConvertFontWidth( rFont.GetWidthType() );
|
|
aFD.Weight= VCLUnoHelper::ConvertFontWeight( rFont.GetWeight() );
|
|
aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
|
|
aFD.Underline = sal::static_int_cast< sal_Int16 >(rFont.GetUnderline());
|
|
aFD.Strikeout = sal::static_int_cast< sal_Int16 >(rFont.GetStrikeout());
|
|
aFD.Orientation = rFont.GetOrientation();
|
|
aFD.Kerning = rFont.IsKerning();
|
|
aFD.WordLineMode = rFont.IsWordLineMode();
|
|
aFD.Type = 0; // ??? => Nur an Metric...
|
|
return aFD;
|
|
}
|
|
|
|
Font VCLUnoHelper::CreateFont( const ::com::sun::star::awt::FontDescriptor& rDescr, const Font& rInitFont )
|
|
{
|
|
Font aFont( rInitFont );
|
|
if ( rDescr.Name.getLength() )
|
|
aFont.SetName( rDescr.Name );
|
|
if ( rDescr.StyleName.getLength() )
|
|
aFont.SetStyleName( rDescr.StyleName );
|
|
if ( rDescr.Height )
|
|
aFont.SetSize( Size( rDescr.Width, rDescr.Height ) );
|
|
if ( (FontFamily)rDescr.Family != FAMILY_DONTKNOW )
|
|
aFont.SetFamily( (FontFamily)rDescr.Family );
|
|
if ( (CharSet)rDescr.CharSet != RTL_TEXTENCODING_DONTKNOW )
|
|
aFont.SetCharSet( (CharSet)rDescr.CharSet );
|
|
if ( (FontPitch)rDescr.Pitch != PITCH_DONTKNOW )
|
|
aFont.SetPitch( (FontPitch)rDescr.Pitch );
|
|
if ( rDescr.CharacterWidth )
|
|
aFont.SetWidthType( VCLUnoHelper::ConvertFontWidth( rDescr.CharacterWidth ) );
|
|
if ( rDescr.Weight )
|
|
aFont.SetWeight( VCLUnoHelper::ConvertFontWeight( rDescr.Weight ) );
|
|
if ( (FontItalic)rDescr.Slant != ITALIC_DONTKNOW )
|
|
aFont.SetItalic( (FontItalic)rDescr.Slant );
|
|
if ( (FontUnderline)rDescr.Underline != UNDERLINE_DONTKNOW )
|
|
aFont.SetUnderline( (FontUnderline)rDescr.Underline );
|
|
if ( (FontStrikeout)rDescr.Strikeout != STRIKEOUT_DONTKNOW )
|
|
aFont.SetStrikeout( (FontStrikeout)rDescr.Strikeout );
|
|
|
|
// Kein DONTKNOW
|
|
aFont.SetOrientation( (short)rDescr.Orientation );
|
|
aFont.SetKerning( rDescr.Kerning );
|
|
aFont.SetWordLineMode( rDescr.WordLineMode );
|
|
|
|
return aFont;
|
|
}
|
|
|
|
Font VCLUnoHelper::CreateFont( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont >& rxFont )
|
|
{
|
|
Font aFont;
|
|
VCLXFont* pVCLXFont = VCLXFont::GetImplementation( rxFont );
|
|
if ( pVCLXFont )
|
|
aFont = pVCLXFont->GetFont();
|
|
return aFont;
|
|
}
|
|
|
|
|
|
::com::sun::star::awt::SimpleFontMetric VCLUnoHelper::CreateFontMetric( const FontMetric& rFontMetric )
|
|
{
|
|
::com::sun::star::awt::SimpleFontMetric aFM;
|
|
aFM.Ascent = (sal_Int16)rFontMetric.GetAscent();
|
|
aFM.Descent = (sal_Int16)rFontMetric.GetDescent();
|
|
aFM.Leading = (sal_Int16)rFontMetric.GetIntLeading();
|
|
aFM.Slant = (sal_Int16)rFontMetric.GetSlant();
|
|
aFM.FirstChar = 0x0020;
|
|
aFM.LastChar = 0xFFFD;
|
|
return aFM;
|
|
}
|
|
|
|
sal_Bool VCLUnoHelper::IsZero( ::com::sun::star::awt::Rectangle rRect )
|
|
{
|
|
return ( !rRect.X && !rRect.Y && !rRect.Width && !rRect.Height );
|
|
}
|
|
|
|
MapUnit VCLUnoHelper::UnoEmbed2VCLMapUnit( sal_Int32 nUnoEmbedMapUnit )
|
|
{
|
|
switch( nUnoEmbedMapUnit )
|
|
{
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_100TH_MM:
|
|
return MAP_100TH_MM;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_10TH_MM:
|
|
return MAP_10TH_MM;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_MM:
|
|
return MAP_MM;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_CM:
|
|
return MAP_CM;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_1000TH_INCH:
|
|
return MAP_1000TH_INCH;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_100TH_INCH:
|
|
return MAP_100TH_INCH;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_10TH_INCH:
|
|
return MAP_10TH_INCH;
|
|
case ::com::sun::star::embed::EmbedMapUnits::ONE_INCH:
|
|
return MAP_INCH;
|
|
case ::com::sun::star::embed::EmbedMapUnits::POINT:
|
|
return MAP_POINT;
|
|
case ::com::sun::star::embed::EmbedMapUnits::TWIP:
|
|
return MAP_TWIP;
|
|
case ::com::sun::star::embed::EmbedMapUnits::PIXEL:
|
|
return MAP_PIXEL;
|
|
}
|
|
|
|
OSL_ENSURE( sal_False, "Unexpected UNO map mode is provided!\n" );
|
|
return MAP_LASTENUMDUMMY;
|
|
}
|
|
|
|
sal_Int32 VCLUnoHelper::VCL2UnoEmbedMapUnit( MapUnit nVCLMapUnit )
|
|
{
|
|
switch( nVCLMapUnit )
|
|
{
|
|
case MAP_100TH_MM:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_100TH_MM;
|
|
case MAP_10TH_MM:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_10TH_MM;
|
|
case MAP_MM:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_MM;
|
|
case MAP_CM:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_CM;
|
|
case MAP_1000TH_INCH:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_1000TH_INCH;
|
|
case MAP_100TH_INCH:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_100TH_INCH;
|
|
case MAP_10TH_INCH:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_10TH_INCH;
|
|
case MAP_INCH:
|
|
return ::com::sun::star::embed::EmbedMapUnits::ONE_INCH;
|
|
case MAP_POINT:
|
|
return ::com::sun::star::embed::EmbedMapUnits::POINT;
|
|
case MAP_TWIP:
|
|
return ::com::sun::star::embed::EmbedMapUnits::TWIP;
|
|
case MAP_PIXEL:
|
|
return ::com::sun::star::embed::EmbedMapUnits::PIXEL;
|
|
default: ; // avoid compiler warning
|
|
}
|
|
|
|
OSL_ENSURE( sal_False, "Unexpected VCL map mode is provided!\n" );
|
|
return -1;
|
|
}
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
//====================================================================
|
|
//= file-local helpers
|
|
//====================================================================
|
|
namespace
|
|
{
|
|
enum UnitConversionDirection
|
|
{
|
|
FieldUnitToMeasurementUnit,
|
|
MeasurementUnitToFieldUnit
|
|
};
|
|
|
|
sal_Int16 convertMeasurementUnit( sal_Int16 _nUnit, UnitConversionDirection eDirection, sal_Int16& _rFieldToUNOValueFactor )
|
|
{
|
|
static struct _unit_table
|
|
{
|
|
FieldUnit eFieldUnit;
|
|
sal_Int16 nMeasurementUnit;
|
|
sal_Int16 nFieldToMeasureFactor;
|
|
} aUnits[] = {
|
|
{ FUNIT_NONE, -1 , -1},
|
|
{ FUNIT_MM, MeasureUnit::MM, 1 }, // must precede MM_10TH
|
|
{ FUNIT_MM, MeasureUnit::MM_10TH, 10 },
|
|
{ FUNIT_100TH_MM, MeasureUnit::MM_100TH, 1 },
|
|
{ FUNIT_CM, MeasureUnit::CM, 1 },
|
|
{ FUNIT_M, MeasureUnit::M, 1 },
|
|
{ FUNIT_KM, MeasureUnit::KM, 1 },
|
|
{ FUNIT_TWIP, MeasureUnit::TWIP, 1 },
|
|
{ FUNIT_POINT, MeasureUnit::POINT, 1 },
|
|
{ FUNIT_PICA, MeasureUnit::PICA, 1 },
|
|
{ FUNIT_INCH, MeasureUnit::INCH, 1 }, // must precede INCH_*TH
|
|
{ FUNIT_INCH, MeasureUnit::INCH_10TH, 10 },
|
|
{ FUNIT_INCH, MeasureUnit::INCH_100TH, 100 },
|
|
{ FUNIT_INCH, MeasureUnit::INCH_1000TH, 1000 },
|
|
{ FUNIT_FOOT, MeasureUnit::FOOT, 1 },
|
|
{ FUNIT_MILE, MeasureUnit::MILE, 1 },
|
|
};
|
|
for ( size_t i = 0; i < sizeof( aUnits ) / sizeof( aUnits[0] ); ++i )
|
|
{
|
|
if ( eDirection == FieldUnitToMeasurementUnit )
|
|
{
|
|
if ( ( aUnits[ i ].eFieldUnit == (FieldUnit)_nUnit ) && ( aUnits[ i ].nFieldToMeasureFactor == _rFieldToUNOValueFactor ) )
|
|
return aUnits[ i ].nMeasurementUnit;
|
|
}
|
|
else
|
|
{
|
|
if ( aUnits[ i ].nMeasurementUnit == _nUnit )
|
|
{
|
|
_rFieldToUNOValueFactor = aUnits[ i ].nFieldToMeasureFactor;
|
|
return (sal_Int16)aUnits[ i ].eFieldUnit;
|
|
}
|
|
}
|
|
}
|
|
if ( eDirection == FieldUnitToMeasurementUnit )
|
|
return -1;
|
|
|
|
_rFieldToUNOValueFactor = 1;
|
|
return (sal_Int16)FUNIT_NONE;
|
|
}
|
|
}
|
|
//========================================================================
|
|
//= MeasurementUnitConversion
|
|
//========================================================================
|
|
//------------------------------------------------------------------------
|
|
sal_Int16 VCLUnoHelper::ConvertToMeasurementUnit( FieldUnit _nFieldUnit, sal_Int16 _nUNOToFieldValueFactor )
|
|
{
|
|
return convertMeasurementUnit( (sal_Int16)_nFieldUnit, FieldUnitToMeasurementUnit, _nUNOToFieldValueFactor );
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
FieldUnit VCLUnoHelper::ConvertToFieldUnit( sal_Int16 _nMeasurementUnit, sal_Int16& _rFieldToUNOValueFactor )
|
|
{
|
|
return (FieldUnit)convertMeasurementUnit( _nMeasurementUnit, MeasurementUnitToFieldUnit, _rFieldToUNOValueFactor );
|
|
}
|
|
|
|
|
|
MapUnit /* MapModeUnit */ VCLUnoHelper::ConvertToMapModeUnit(sal_Int16 /* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit) throw (::com::sun::star::lang::IllegalArgumentException)
|
|
{
|
|
MapUnit eMode;
|
|
switch(_nMeasureUnit)
|
|
{
|
|
case com::sun::star::util::MeasureUnit::MM_100TH:
|
|
eMode = MAP_100TH_MM;
|
|
break;
|
|
|
|
|
|
case com::sun::star::util::MeasureUnit::MM_10TH:
|
|
eMode = MAP_10TH_MM;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::MM:
|
|
eMode = MAP_MM;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::CM:
|
|
eMode = MAP_CM;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::INCH_1000TH:
|
|
eMode = MAP_1000TH_INCH;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::INCH_100TH:
|
|
eMode = MAP_100TH_INCH;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::INCH_10TH:
|
|
eMode = MAP_10TH_INCH;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::INCH:
|
|
eMode = MAP_INCH;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::POINT:
|
|
eMode = MAP_POINT;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::TWIP:
|
|
eMode = MAP_TWIP;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::PIXEL:
|
|
eMode = MAP_PIXEL;
|
|
break;
|
|
|
|
/*
|
|
case com::sun::star::util::MeasureUnit::M:
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::KM:
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::PICA:
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::FOOT:
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::MILE:
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::PERCENT:
|
|
break;
|
|
*/
|
|
case com::sun::star::util::MeasureUnit::APPFONT:
|
|
eMode = MAP_APPFONT;
|
|
break;
|
|
|
|
case com::sun::star::util::MeasureUnit::SYSFONT:
|
|
eMode = MAP_SYSFONT;
|
|
break;
|
|
|
|
/*
|
|
case com::sun::star::util::MeasureUnit::RELATIVE:
|
|
eMode = MAP_RELATIVE;
|
|
break;
|
|
case com::sun::star::util::MeasureUnit::REALAPPFONT:
|
|
eMode = MAP_REALAPPFONT;
|
|
break;
|
|
*/
|
|
|
|
default:
|
|
throw ::com::sun::star::lang::IllegalArgumentException(::rtl::OUString::createFromAscii("Unsupported measure unit."), NULL, 1 );
|
|
}
|
|
return eMode;
|
|
}
|
|
|
|
sal_Int16 /* com.sun.star.util.MeasureUnit.* */ VCLUnoHelper::ConvertToMeasurementUnit(MapUnit /* MapModeUnit */ _eMapModeUnit) throw (::com::sun::star::lang::IllegalArgumentException)
|
|
{
|
|
sal_Int16 nMeasureUnit = 0;
|
|
switch (_eMapModeUnit)
|
|
{
|
|
case MAP_100TH_MM:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::MM_100TH;
|
|
break;
|
|
|
|
case MAP_10TH_MM:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::MM_10TH;
|
|
break;
|
|
|
|
case MAP_MM:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::MM;
|
|
break;
|
|
|
|
case MAP_CM:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::CM;
|
|
break;
|
|
|
|
case MAP_1000TH_INCH:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::INCH_1000TH;
|
|
break;
|
|
|
|
case MAP_100TH_INCH:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::INCH_100TH;
|
|
break;
|
|
|
|
case MAP_10TH_INCH:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::INCH_10TH;
|
|
break;
|
|
|
|
case MAP_INCH:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::INCH;
|
|
break;
|
|
|
|
case MAP_POINT:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::POINT;
|
|
break;
|
|
|
|
case MAP_TWIP:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::TWIP;
|
|
break;
|
|
|
|
case MAP_PIXEL:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::PIXEL;
|
|
break;
|
|
|
|
case MAP_APPFONT:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::APPFONT;
|
|
break;
|
|
|
|
case MAP_SYSFONT:
|
|
nMeasureUnit = com::sun::star::util::MeasureUnit::SYSFONT;
|
|
break;
|
|
|
|
/*
|
|
case MAP_RELATIVE:
|
|
break;
|
|
|
|
case MAP_REALAPPFONT:
|
|
break;
|
|
*/
|
|
default:
|
|
throw ::com::sun::star::lang::IllegalArgumentException(::rtl::OUString::createFromAscii("Unsupported MapMode unit."), NULL, 1 );
|
|
}
|
|
return nMeasureUnit;
|
|
}
|
|
|
|
::Size VCLUnoHelper::ConvertToVCLSize(com::sun::star::awt::Size const& _aSize)
|
|
{
|
|
::Size aVCLSize(_aSize.Width, _aSize.Height);
|
|
return aVCLSize;
|
|
}
|
|
|
|
com::sun::star::awt::Size VCLUnoHelper::ConvertToAWTSize(::Size /* VCLSize */ const& _aSize)
|
|
{
|
|
com::sun::star::awt::Size aAWTSize(_aSize.Width(), _aSize.Height());
|
|
return aAWTSize;
|
|
}
|
|
|
|
|
|
::Point VCLUnoHelper::ConvertToVCLPoint(com::sun::star::awt::Point const& _aPoint)
|
|
{
|
|
::Point aVCLPoint(_aPoint.X, _aPoint.Y);
|
|
return aVCLPoint;
|
|
}
|
|
|
|
com::sun::star::awt::Point VCLUnoHelper::ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint)
|
|
{
|
|
com::sun::star::awt::Point aAWTPoint(_aPoint.X(), _aPoint.Y());
|
|
return aAWTPoint;
|
|
}
|
|
|
|
::Rectangle VCLUnoHelper::ConvertToVCLRect( ::com::sun::star::awt::Rectangle const & _rRect )
|
|
{
|
|
return ::Rectangle( _rRect.X, _rRect.Y, _rRect.X + _rRect.Width - 1, _rRect.Y + _rRect.Height - 1 );
|
|
}
|
|
|
|
::com::sun::star::awt::Rectangle VCLUnoHelper::ConvertToAWTRect( ::Rectangle const & _rRect )
|
|
{
|
|
return ::com::sun::star::awt::Rectangle( _rRect.Left(), _rRect.Top(), _rRect.GetWidth(), _rRect.GetHeight() );
|
|
}
|
|
|
|
awt::MouseEvent VCLUnoHelper::createMouseEvent( const ::MouseEvent& _rVclEvent, const uno::Reference< uno::XInterface >& _rxContext )
|
|
{
|
|
awt::MouseEvent aMouseEvent;
|
|
aMouseEvent.Source = _rxContext;
|
|
|
|
aMouseEvent.Modifiers = 0;
|
|
if ( _rVclEvent.IsShift() )
|
|
aMouseEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT;
|
|
if ( _rVclEvent.IsMod1() )
|
|
aMouseEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1;
|
|
if ( _rVclEvent.IsMod2() )
|
|
aMouseEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2;
|
|
|
|
aMouseEvent.Buttons = 0;
|
|
if ( _rVclEvent.IsLeft() )
|
|
aMouseEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT;
|
|
if ( _rVclEvent.IsRight() )
|
|
aMouseEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT;
|
|
if ( _rVclEvent.IsMiddle() )
|
|
aMouseEvent.Buttons |= ::com::sun::star::awt::MouseButton::MIDDLE;
|
|
|
|
aMouseEvent.X = _rVclEvent.GetPosPixel().X();
|
|
aMouseEvent.Y = _rVclEvent.GetPosPixel().Y();
|
|
aMouseEvent.ClickCount = _rVclEvent.GetClicks();
|
|
aMouseEvent.PopupTrigger = sal_False;
|
|
|
|
return aMouseEvent;
|
|
}
|
|
|
|
awt::KeyEvent VCLUnoHelper::createKeyEvent( const ::KeyEvent& _rVclEvent, const uno::Reference< uno::XInterface >& _rxContext )
|
|
{
|
|
awt::KeyEvent aKeyEvent;
|
|
aKeyEvent.Source = _rxContext;
|
|
|
|
aKeyEvent.Modifiers = 0;
|
|
if ( _rVclEvent.GetKeyCode().IsShift() )
|
|
aKeyEvent.Modifiers |= awt::KeyModifier::SHIFT;
|
|
if ( _rVclEvent.GetKeyCode().IsMod1() )
|
|
aKeyEvent.Modifiers |= awt::KeyModifier::MOD1;
|
|
if ( _rVclEvent.GetKeyCode().IsMod2() )
|
|
aKeyEvent.Modifiers |= awt::KeyModifier::MOD2;
|
|
if ( _rVclEvent.GetKeyCode().IsMod3() )
|
|
aKeyEvent.Modifiers |= awt::KeyModifier::MOD3;
|
|
|
|
aKeyEvent.KeyCode = _rVclEvent.GetKeyCode().GetCode();
|
|
aKeyEvent.KeyChar = _rVclEvent.GetCharCode();
|
|
aKeyEvent.KeyFunc = ::sal::static_int_cast< sal_Int16 >( _rVclEvent.GetKeyCode().GetFunction());
|
|
|
|
return aKeyEvent;
|
|
}
|