diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-13 07:10:18 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-13 07:10:18 +0000 |
commit | 6366f1e08bedfc1ed6fd654d5fc722a4818f619f (patch) | |
tree | 0ec1fc28008bf0d46e9a0f3315765ffbb8820fb2 | |
parent | 24116c5a42d26a1970558f9fb65314a5a985862f (diff) |
CWS-TOOLING: integrate CWS dba31g
2009-02-06 09:31:37 +0100 fs r267443 : line ends
2009-02-06 09:31:16 +0100 fs r267442 : line ends
2009-01-26 09:21:13 +0100 msc r266904 : #i10000# reactive tests
2009-01-21 12:38:53 +0100 msc r266657 : #i98316# add bugid
2009-01-20 14:49:04 +0100 msc r266584 : i97307
2009-01-20 13:43:22 +0100 oj r266572 : #i978i97860# merge changes from dba31h
2009-01-19 12:12:27 +0100 oj r266487 : #i97307# wrong shortcuts
2009-01-12 11:45:03 +0100 fs r266139 : #i97867# ImplPaint: don't paint if there are not items (yet)
2009-01-08 20:34:46 +0100 fs r266039 : ignore output paths
2009-01-08 20:25:45 +0100 fs r266038 : spelling: unxols4 -> unxsols4
2009-01-08 20:16:10 +0100 fs r266037 : BUILD_QADEVOOO
2009-01-08 20:15:35 +0100 fs r266036 : ignore output paths
2009-01-07 22:47:01 +0100 fs r265978 : close the document after the test
2009-01-07 22:40:22 +0100 fs r265977 : tweak the test, some behavior worked in a timing-dependent fashion only
2009-01-07 13:21:48 +0100 lla r265961 : #i96526# need FileAccess instead of File due to URL incompatibity
2009-01-07 12:27:19 +0100 lla r265959 : #i96526# need FileAccess instead of File due to URL incompatibity
2009-01-06 13:30:04 +0100 fs r265917 : #158964# GetFormControl: don't accept requests for model which do not belong to the page displayed in the given view
2009-01-06 13:30:04 +0100 fs r265916 : #158964# GetUnoControl: don't accept requests for a view where a foreign page is displayed
2009-01-06 13:26:37 +0100 fs r265915 : #158964# FmXPageViewWinRec::dispose: catch exceptions (fixes the symptom, the root cause is fixed elsewhere)
2009-01-06 09:52:38 +0100 oj r265897 : #i97307# shortcuts
2009-01-06 09:41:26 +0100 fs r265896 : #i10000#
2009-01-05 13:40:38 +0100 fs r265866 : CWS-TOOLING: rebase CWS dba31g to trunk@265758 (milestone: DEV300:m38)
2008-12-18 11:35:43 +0100 fs r265678 : document the new InputRequired property
2008-12-17 07:25:18 +0100 oj r265578 : #i97307# insert new Accelerators handling in configuration
2008-12-16 09:52:27 +0100 lla r265526 : #i96526# error message is a problem with no existance default.otr occur
2008-12-16 09:33:14 +0100 oj r265525 : #i96948# remove merge conflict with StreamName
2008-12-16 09:22:12 +0100 oj r265524 : #i96935# set reportcomponent for custom shape
2008-12-15 10:32:38 +0100 oj r265463 : #i96965# do not add connection for selfreferencing table
2008-12-12 14:00:56 +0100 fs r265416 : #i97044# EnableFocusSelectionHide=FALSE => don't hide selection when not focused (this is more of a side effect), and preserve the selection when gaining the focus (this is the desired effect)
2008-12-11 15:32:32 +0100 fs r265319 : prevent a deadlock during complex.dbaccess.DatabaseDocument test
2008-12-11 15:31:25 +0100 fs r265317 : prevent a deadlock during complex.dbaccess.DatabaseDocument test
2008-12-11 13:45:06 +0100 fs r265296 : #i97137#
2008-12-11 12:43:00 +0100 fs r265285 : #i97134#
2008-12-10 13:20:28 +0100 lla r265175 : #94067# add (APP|SYS)FONT to XUnitConversion interface implementation
2008-12-10 13:08:22 +0100 lla r265173 : #i94067# add (APP|SYS)FONT
2008-12-10 09:21:39 +0100 fs r265151 : #i95010# implement a non-hacky solution for #i94033#, by making Begin/Do/EndCompleteRedraw virtual
2008-12-09 17:29:32 +0100 fs r265120 : #i96636#
-rw-r--r-- | toolkit/qa/complex/xunitconversion/XUnitConversionTest.java | 5 | ||||
-rw-r--r-- | toolkit/source/awt/vclxdevice.cxx | 12 | ||||
-rw-r--r-- | toolkit/source/helper/vclunohelper.cxx | 1462 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 85 |
4 files changed, 793 insertions, 771 deletions
diff --git a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java b/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java index be1ebef84a17..8f2d5ca839c5 100644 --- a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java +++ b/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java @@ -177,6 +177,11 @@ public class XUnitConversionTest extends ComplexTestCase assure("Size.Width not correct", delta(aSizeInMM_100TH.Width, aSizeInMM_10TH.Width * 10) < 10); assure("Size.Height not correct", delta(aSizeInMM_100TH.Height, aSizeInMM_10TH.Height * 10) < 10); + // new + checkSize(aSize, com.sun.star.util.MeasureUnit.PIXEL, "pixel"); + checkSize(aSize, com.sun.star.util.MeasureUnit.APPFONT, "appfont"); + checkSize(aSize, com.sun.star.util.MeasureUnit.SYSFONT, "sysfont"); + // simply check some more parameters checkSize(aSize, com.sun.star.util.MeasureUnit.MM, "mm"); checkSize(aSize, com.sun.star.util.MeasureUnit.CM, "cm"); diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx index af26e36072ed..cf00e1480a96 100644 --- a/toolkit/source/awt/vclxdevice.cxx +++ b/toolkit/source/awt/vclxdevice.cxx @@ -282,17 +282,16 @@ VCLXVirtualDevice::~VCLXVirtualDevice() // ----------------------------------------------------------------------------- -// ::com::sun::star::awt::XUnitConversion +// Interface implementation of ::com::sun::star::awt::XUnitConversion // ----------------------------------------------------------------------------- ::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToLogic( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { (void)aPoint; ::vos::OGuard aGuard( GetMutex() ); - if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT || - TargetUnit == com::sun::star::util::MeasureUnit::PIXEL) + if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT ) { - // pixel or percentage not allowed here + // percentage not allowed here throw ::com::sun::star::lang::IllegalArgumentException(); } @@ -339,10 +338,9 @@ VCLXVirtualDevice::~VCLXVirtualDevice() { (void)aSize; ::vos::OGuard aGuard( GetMutex() ); - if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT || - TargetUnit == com::sun::star::util::MeasureUnit::PIXEL) + if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT) { - // pixel or percentage not allowed here + // percentage not allowed here throw ::com::sun::star::lang::IllegalArgumentException(); } diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index 298fb710d8a4..8d7b4579cb66 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -1,723 +1,739 @@ -/************************************************************************* - * - * 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/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> - -// ---------------------------------------------------- -// 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; -*/ - 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_SYSFONT: - break; - - case MAP_APPFONT: - break; - - case MAP_RELATIVE: - break; - - case MAP_REALAPPFONT: - break; - - case MAP_LASTENUMDUMMY: - 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; -} - - +/*************************************************************************
+ *
+ * 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/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>
+
+// ----------------------------------------------------
+// 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;
+}
+
+
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 25a086060fcf..561d550b1168 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -1230,55 +1230,58 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout ) } } - // Some native toolkits (GTK+) draw tabs right-to-left, with an - // overlap between adjacent tabs - bool bDrawTabsRTL = IsNativeControlSupported( CTRL_TAB_ITEM, PART_TABS_DRAW_RTL ); - ImplTabItem * pFirstTab = NULL; - ImplTabItem * pLastTab = NULL; - size_t idx; - - // Event though there is a tab overlap with GTK+, the first tab is not - // overlapped on the left side. Other tookits ignore this option. - if ( bDrawTabsRTL ) - { - pFirstTab = &mpTabCtrlData->maItemList.front(); - pLastTab = &mpTabCtrlData->maItemList.back(); - idx = mpTabCtrlData->maItemList.size()-1; - } - else + if ( !mpTabCtrlData->maItemList.empty() ) { - pLastTab = &mpTabCtrlData->maItemList.back(); - pFirstTab = &mpTabCtrlData->maItemList.front(); - idx = 0; - } + // Some native toolkits (GTK+) draw tabs right-to-left, with an + // overlap between adjacent tabs + bool bDrawTabsRTL = IsNativeControlSupported( CTRL_TAB_ITEM, PART_TABS_DRAW_RTL ); + ImplTabItem * pFirstTab = NULL; + ImplTabItem * pLastTab = NULL; + size_t idx; - while ( idx < mpTabCtrlData->maItemList.size() ) - { - ImplTabItem* pItem = &mpTabCtrlData->maItemList[idx]; - if ( pItem != pCurItem ) + // Event though there is a tab overlap with GTK+, the first tab is not + // overlapped on the left side. Other tookits ignore this option. + if ( bDrawTabsRTL ) + { + pFirstTab = &mpTabCtrlData->maItemList.front(); + pLastTab = &mpTabCtrlData->maItemList.back(); + idx = mpTabCtrlData->maItemList.size()-1; + } + else + { + pLastTab = &mpTabCtrlData->maItemList.back(); + pFirstTab = &mpTabCtrlData->maItemList.front(); + idx = 0; + } + + while ( idx < mpTabCtrlData->maItemList.size() ) + { + ImplTabItem* pItem = &mpTabCtrlData->maItemList[idx]; + if ( pItem != pCurItem ) + { + Region aClipRgn( GetActiveClipRegion() ); + aClipRgn.Intersect( pItem->maRect ); + if( !rRect.IsEmpty() ) + aClipRgn.Intersect( rRect ); + if( bLayout || !aClipRgn.IsEmpty() ) + ImplDrawItem( pItem, aCurRect, bLayout, (pItem==pFirstTab), (pItem==pLastTab), FALSE ); + } + + if ( bDrawTabsRTL ) + idx--; + else + idx++; + } + + if ( pCurItem ) { Region aClipRgn( GetActiveClipRegion() ); - aClipRgn.Intersect( pItem->maRect ); + aClipRgn.Intersect( pCurItem->maRect ); if( !rRect.IsEmpty() ) aClipRgn.Intersect( rRect ); if( bLayout || !aClipRgn.IsEmpty() ) - ImplDrawItem( pItem, aCurRect, bLayout, (pItem==pFirstTab), (pItem==pLastTab), FALSE ); + ImplDrawItem( pCurItem, aCurRect, bLayout, (pCurItem==pFirstTab), (pCurItem==pLastTab), TRUE ); } - - if ( bDrawTabsRTL ) - idx--; - else - idx++; - } - - if ( pCurItem ) - { - Region aClipRgn( GetActiveClipRegion() ); - aClipRgn.Intersect( pCurItem->maRect ); - if( !rRect.IsEmpty() ) - aClipRgn.Intersect( rRect ); - if( bLayout || !aClipRgn.IsEmpty() ) - ImplDrawItem( pCurItem, aCurRect, bLayout, (pCurItem==pFirstTab), (pCurItem==pLastTab), TRUE ); } if ( !bLayout && HasFocus() ) |