diff options
author | Xiaofei Zhang <Zhangxiaofei@openoffice.org> | 2010-11-10 13:50:33 +0800 |
---|---|---|
committer | Xiaofei Zhang <Zhangxiaofei@openoffice.org> | 2010-11-10 13:50:33 +0800 |
commit | 3491b4ac4fe34cacea5f4d0a4594d4a88cbbe7b2 (patch) | |
tree | 8dc60b794b88dd87c965d149c93fa3ac81e3096c /vcl/source | |
parent | 66e7dc1197e76e686ba731382d032a9a72849959 (diff) | |
parent | 95f71183414a50d12cd4bbacf47d711672e63268 (diff) |
removetooltypes01: #i112600# resync to DEV300_m92; remove tooltypes from xmloff, linguistic, vcl, svtools, accessibility, fpicker, uui and framework
Diffstat (limited to 'vcl/source')
81 files changed, 3618 insertions, 3201 deletions
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index 62fcb136765d..354a4124d9e3 100644 --- a/vcl/source/app/dbggui.cxx +++ b/vcl/source/app/dbggui.cxx @@ -37,32 +37,33 @@ #include <cmath> #include <limits.h> -#include <vcl/svdata.hxx> -#include <svsys.h> +#include "vcl/svdata.hxx" +#include "svsys.h" #ifdef WNT #undef min #endif -#include <tools/debug.hxx> -#include <vcl/svdata.hxx> -#include <vcl/svapp.hxx> -#include <vcl/event.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/button.hxx> -#include <vcl/edit.hxx> -#include <vcl/fixed.hxx> -#include <vcl/group.hxx> -#include <vcl/field.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/wrkwin.hxx> -#include <vcl/sound.hxx> -#include <vcl/threadex.hxx> -#include <vcl/dbggui.hxx> -#include <com/sun/star/i18n/XCharacterClassification.hpp> - -#include <vcl/unohelp.hxx> -#include <vcl/unohelp2.hxx> -#include <vos/mutex.hxx> +#include "tools/debug.hxx" +#include "vcl/svdata.hxx" +#include "vcl/svapp.hxx" +#include "vcl/event.hxx" +#include "vcl/lstbox.hxx" +#include "vcl/button.hxx" +#include "vcl/edit.hxx" +#include "vcl/fixed.hxx" +#include "vcl/group.hxx" +#include "vcl/field.hxx" +#include "vcl/msgbox.hxx" +#include "vcl/wrkwin.hxx" +#include "vcl/sound.hxx" +#include "vcl/threadex.hxx" +#include "vcl/dbggui.hxx" +#include "com/sun/star/i18n/XCharacterClassification.hpp" + +#include "vcl/unohelp.hxx" +#include "vcl/unohelp2.hxx" +#include "vos/mutex.hxx" +#include "vcl/salinst.hxx" #include <map> #include <algorithm> @@ -1963,9 +1964,11 @@ void DbgPrintWindow( const char* pLine ) // ======================================================================= -#ifdef WNT -void ImplDbgTestSolarMutex(); -#endif +void ImplDbgTestSolarMutex() +{ + bool bCheck = ImplGetSVData()->mpDefInst->CheckYieldMutex(); + OSL_ENSURE( bCheck, "SolarMutex not locked" ); +} // ======================================================================= @@ -1973,9 +1976,7 @@ void DbgGUIInit() { DbgSetPrintMsgBox( DbgPrintMsgBox ); DbgSetPrintWindow( DbgPrintWindow ); -#ifdef WNT DbgSetTestSolarMutex( ImplDbgTestSolarMutex ); -#endif } // ----------------------------------------------------------------------- @@ -1984,9 +1985,7 @@ void DbgGUIDeInit() { DbgSetPrintMsgBox( NULL ); DbgSetPrintWindow( NULL ); -#ifdef WNT DbgSetTestSolarMutex( NULL ); -#endif DbgWindow* pDbgWindow = ImplGetSVData()->maWinData.mpDbgWin; if ( pDbgWindow ) diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 9164f4afe175..26722188e7e5 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -62,12 +62,7 @@ Help::~Help() // ----------------------------------------------------------------------- -sal_Bool Help::Start( sal_uIntPtr, const Window* ) -{ - return sal_False; -} - -void Help::OpenHelpAgent( sal_uIntPtr ) +void Help::OpenHelpAgent( const rtl::OString& ) { } @@ -78,11 +73,9 @@ sal_Bool Help::Start( const XubString&, const Window* ) return sal_False; } -// ----------------------------------------------------------------------- - -XubString Help::GetHelpText( sal_uIntPtr, const Window* ) +sal_Bool Help::SearchKeyword( const XubString& ) { - return ImplGetSVEmptyStr(); + return sal_False; } // ----------------------------------------------------------------------- @@ -444,7 +437,7 @@ void HelpTextWindow::Paint( const Rectangle& ) if ( IsNativeControlSupported( CTRL_TOOLTIP, PART_ENTIRE_CONTROL ) ) { // #i46472# workaround gcc3.3 temporary problem - Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( Point( 0, 0 ), GetOutputSizePixel() ); ImplControlValue aControlValue; bNativeOK = DrawNativeControl( CTRL_TOOLTIP, PART_ENTIRE_CONTROL, aCtrlRegion, 0, aControlValue, rtl::OUString() ); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index b1b89efd6318..7123b9bc5184 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -74,6 +74,29 @@ void SalInstance::FillFontPathList( std::list< rtl::OString >& ) // do nothing } +SalMenu* SalInstance::CreateMenu( sal_Bool, Menu* ) +{ + // default: no native menus + return NULL; +} + +void SalInstance::DestroyMenu( SalMenu* pMenu ) +{ + (void)pMenu; + OSL_ENSURE( pMenu == 0, "DestroyMenu called with non-native menus" ); +} + +SalMenuItem* SalInstance::CreateMenuItem( const SalItemParams* ) +{ + return NULL; +} + +void SalInstance::DestroyMenuItem( SalMenuItem* pItem ) +{ + (void)pItem; + OSL_ENSURE( pItem == 0, "DestroyMenu called with non-native menus" ); +} + SalTimer::~SalTimer() { } diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 5e329525b08b..f675301de198 100755..100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -424,7 +424,10 @@ ImplStyleData::ImplStyleData() mnPushButtonStyle = 0; mnTabControlStyle = 0; mnLogoDisplayTime = LOGO_DISPLAYTIME_STARTTIME; - mnDragFullOptions = 0; + mnDragFullOptions = DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE | + DRAGFULL_OPTION_OBJECTMOVE | DRAGFULL_OPTION_OBJECTSIZE | + DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT | + DRAGFULL_OPTION_SCROLL; mnAnimationOptions = 0; mnSelectionOptions = 0; mnDisplayOptions = 0; @@ -1041,6 +1044,8 @@ sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const (mpData->mnUseSystemUIFonts == rSet.mpData->mnUseSystemUIFonts) && (mpData->mnUseFlatBorders == rSet.mpData->mnUseFlatBorders) && (mpData->mnUseFlatMenues == rSet.mpData->mnUseFlatMenues) && + (mpData->mnSymbolsStyle == rSet.mpData->mnSymbolsStyle) && + (mpData->mnPreferredSymbolsStyle == rSet.mpData->mnPreferredSymbolsStyle) && (mpData->maFaceColor == rSet.mpData->maFaceColor) && (mpData->maCheckedColor == rSet.mpData->maCheckedColor) && (mpData->maLightColor == rSet.mpData->maLightColor) && @@ -1235,7 +1240,7 @@ sal_Bool MiscSettings::GetEnableATToolSupport() const &hkey) ) { DWORD dwType; - BYTE Data[6]; // possible values: "true", "false", "1", "0", DWORD + sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD DWORD cbData = sizeof(Data); if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", @@ -1313,7 +1318,7 @@ void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable ) &hkey) ) { DWORD dwType; - BYTE Data[6]; // possible values: "true", "false", 1, 0 + sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0 DWORD cbData = sizeof(Data); if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", @@ -1324,7 +1329,7 @@ void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable ) case REG_SZ: RegSetValueEx(hkey, "SupportAssistiveTechnology", NULL, dwType, - bEnable ? (BYTE *) "true" : (BYTE *) "false", + bEnable ? (sal_uInt8 *) "true" : (sal_uInt8 *) "false", bEnable ? sizeof("true") : sizeof("false")); break; case REG_DWORD: diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index 614684891be1..faae833e4d7b 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -27,47 +27,49 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <string.h> -#ifndef _SV_SVSYS_HXX -#include <svsys.h> -#endif -#include <vcl/salinst.hxx> -#include <vcl/salframe.hxx> - -#ifndef _VOS_MUTEX_HXX -#include <vos/mutex.hxx> -#endif - -#include <osl/process.h> -#include <osl/file.hxx> -#include <uno/current_context.hxx> -#include <cppuhelper/implbase1.hxx> -#include <tools/debug.hxx> -#include <unotools/fontcfg.hxx> -#include <vcl/configsettings.hxx> -#include <vcl/svdata.hxx> -#include <vcl/window.h> -#include <vcl/svapp.hxx> -#include <vcl/wrkwin.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/unohelp.hxx> -#include <vcl/button.hxx> // for Button::GetStandardText -#include <vcl/dockwin.hxx> // for DockingManager -#include <vcl/salimestatus.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/awt/XExtendedToolkit.hpp> -#include <com/sun/star/java/JavaNotConfiguredException.hpp> -#include <com/sun/star/java/JavaVMCreationFailureException.hpp> -#include <com/sun/star/java/MissingJavaRuntimeException.hpp> -#include <com/sun/star/java/JavaDisabledException.hpp> - -#include <com/sun/star/lang/XComponent.hpp> +#include "rtl/instance.hxx" +#include "osl/process.h" +#include "osl/file.hxx" + +#include "svsys.h" + +#include "tools/debug.hxx" +#include "tools/resary.hxx" + +#include "vcl/salinst.hxx" +#include "vcl/salframe.hxx" +#include "vcl/configsettings.hxx" +#include "vcl/svdata.hxx" +#include "vcl/window.h" +#include "vcl/svapp.hxx" +#include "vcl/wrkwin.hxx" +#include "vcl/msgbox.hxx" +#include "vcl/unohelp.hxx" +#include "vcl/button.hxx" // for Button::GetStandardText +#include "vcl/dockwin.hxx" // for DockingManager +#include "vcl/salimestatus.hxx" +#include "vcl/salsys.hxx" +#include "vcl/svids.hrc" + +#include "unotools/fontcfg.hxx" + +#include "vos/mutex.hxx" + +#include "cppuhelper/implbase1.hxx" +#include "uno/current_context.hxx" + +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/lang/XComponent.hpp" +#include "com/sun/star/awt/XExtendedToolkit.hpp" +#include "com/sun/star/java/JavaNotConfiguredException.hpp" +#include "com/sun/star/java/JavaVMCreationFailureException.hpp" +#include "com/sun/star/java/MissingJavaRuntimeException.hpp" +#include "com/sun/star/java/JavaDisabledException.hpp" #include <stdio.h> -#include <vcl/salsys.hxx> -#include <vcl/svids.hrc> -#include <rtl/instance.hxx> using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -112,7 +114,6 @@ void ImplInitSVData() // init global instance data memset( pImplSVData, 0, sizeof( ImplSVData ) ); pImplSVData->maHelpData.mbAutoHelpId = sal_True; - pImplSVData->maHelpData.mbAutoHelpId = sal_True; pImplSVData->maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT ); // find out whether we are running in the testtool @@ -163,6 +164,11 @@ void ImplDeInitSVData() delete pSVData->maAppData.mpMSFTempFileName; pSVData->maAppData.mpMSFTempFileName = NULL; } + + if( pSVData->maCtrlData.mpFieldUnitStrings ) + delete pSVData->maCtrlData.mpFieldUnitStrings, pSVData->maCtrlData.mpFieldUnitStrings = NULL; + if( pSVData->maCtrlData.mpCleanUnitStrings ) + delete pSVData->maCtrlData.mpCleanUnitStrings, pSVData->maCtrlData.mpCleanUnitStrings = NULL; } // ----------------------------------------------------------------------- @@ -240,6 +246,52 @@ ResId VclResId( sal_Int32 nId ) return ResId( nId, *pMgr ); } +FieldUnitStringList* ImplGetFieldUnits() +{ + ImplSVData* pSVData = ImplGetSVData(); + if( ! pSVData->maCtrlData.mpFieldUnitStrings ) + { + ResMgr* pResMgr = ImplGetResMgr(); + if( pResMgr ) + { + ResStringArray aUnits( ResId (SV_FUNIT_STRINGS, *pResMgr) ); + sal_uInt32 nUnits = aUnits.Count(); + pSVData->maCtrlData.mpFieldUnitStrings = new FieldUnitStringList(); + pSVData->maCtrlData.mpFieldUnitStrings->reserve( nUnits ); + for( sal_uInt32 i = 0; i < nUnits; i++ ) + { + std::pair< String, FieldUnit > aElement( aUnits.GetString(i), static_cast<FieldUnit>(aUnits.GetValue(i)) ); + pSVData->maCtrlData.mpFieldUnitStrings->push_back( aElement ); + } + } + } + return pSVData->maCtrlData.mpFieldUnitStrings; +} + +FieldUnitStringList* ImplGetCleanedFieldUnits() +{ + ImplSVData* pSVData = ImplGetSVData(); + if( ! pSVData->maCtrlData.mpCleanUnitStrings ) + { + FieldUnitStringList* pUnits = ImplGetFieldUnits(); + if( pUnits ) + { + size_t nUnits = pUnits->size(); + pSVData->maCtrlData.mpCleanUnitStrings = new FieldUnitStringList(); + pSVData->maCtrlData.mpCleanUnitStrings->reserve( nUnits ); + for( size_t i = 0; i < nUnits; i++ ) + { + String aUnit( (*pUnits)[i].first ); + aUnit.EraseAllChars( sal_Unicode( ' ' ) ); + aUnit.ToLowerAscii(); + std::pair< String, FieldUnit > aElement( aUnit, (*pUnits)[i].second ); + pSVData->maCtrlData.mpCleanUnitStrings->push_back( aElement ); + } + } + } + return pSVData->maCtrlData.mpCleanUnitStrings; +} + DockingManager* ImplGetDockingManager() { ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/components/factory.cxx b/vcl/source/components/factory.cxx index 6bed493cacde..7cfdecbfdb00 100644 --- a/vcl/source/components/factory.cxx +++ b/vcl/source/components/factory.cxx @@ -62,6 +62,10 @@ extern Sequence< OUString > SAL_CALL FontIdentificator_getSupportedServiceNames( extern OUString SAL_CALL FontIdentificator_getImplementationName(); extern Reference< XInterface > SAL_CALL FontIdentificator_createInstance( const Reference< XMultiServiceFactory > & ); +extern Sequence< OUString > SAL_CALL StringMirror_getSupportedServiceNames(); +extern OUString SAL_CALL StringMirror_getImplementationName(); +extern Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory > & ); + extern Sequence< OUString > SAL_CALL Clipboard_getSupportedServiceNames(); extern OUString SAL_CALL Clipboard_getImplementationName(); extern Reference< XSingleServiceFactory > SAL_CALL Clipboard_createFactory( const Reference< XMultiServiceFactory > & ); @@ -84,62 +88,6 @@ extern "C" { *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - VCL_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pXUnoKey ) - { - if( pXUnoKey ) - { - try - { - Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) ); - - OUStringBuffer aImplName(64); - aImplName.appendAscii( "/" ); - aImplName.append( vcl_session_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl_session_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - - aImplName.appendAscii( "/" ); - aImplName.append( vcl::DisplayAccess_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl::DisplayAccess_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - - aImplName.appendAscii( "/" ); - aImplName.append( vcl::FontIdentificator_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl::FontIdentificator_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - - #if defined UNX - aImplName.appendAscii( "/" ); - aImplName.append( vcl::Clipboard_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl::Clipboard_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - - aImplName.appendAscii( "/" ); - aImplName.append( vcl::DragSource_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl::DragSource_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - - aImplName.appendAscii( "/" ); - aImplName.append( vcl::DropTarget_getImplementationName() ); - aImplName.appendAscii( "/UNO/SERVICES/" ); - aImplName.append( vcl::DropTarget_getSupportedServiceNames()[0] ); - xKey->createKey( aImplName.makeStringAndClear() ); - #endif - - return sal_True; - } - catch( ::com::sun::star::registry::InvalidRegistryException& ) - { - } - } - return sal_False; - } - VCL_DLLPUBLIC void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, void* pXUnoSMgr, @@ -172,6 +120,12 @@ extern "C" { xMgr, vcl::FontIdentificator_getImplementationName(), vcl::FontIdentificator_createInstance, vcl::FontIdentificator_getSupportedServiceNames() ); } + else if( vcl::StringMirror_getImplementationName().equalsAscii( pImplementationName ) ) + { + xFactory = ::cppu::createSingleFactory( + xMgr, vcl::StringMirror_getImplementationName(), vcl::StringMirror_createInstance, + vcl::StringMirror_getSupportedServiceNames() ); + } else if( vcl::Clipboard_getImplementationName().equalsAscii( pImplementationName ) ) { xFactory = vcl::Clipboard_createFactory( xMgr ); diff --git a/vcl/source/components/makefile.mk b/vcl/source/components/makefile.mk index e30975dbc099..982687104c01 100644 --- a/vcl/source/components/makefile.mk +++ b/vcl/source/components/makefile.mk @@ -39,9 +39,10 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- -SLOFILES= $(SLO)$/display.obj \ - $(SLO)$/dtranscomp.obj \ - $(SLO)$/fontident.obj \ +SLOFILES= $(SLO)$/display.obj \ + $(SLO)$/dtranscomp.obj \ + $(SLO)$/fontident.obj \ + $(SLO)$/stringmirror.obj \ $(SLO)$/factory.obj # --- Targets ------------------------------------------------------ diff --git a/vcl/source/components/stringmirror.cxx b/vcl/source/components/stringmirror.cxx new file mode 100644 index 000000000000..78806914a7c4 --- /dev/null +++ b/vcl/source/components/stringmirror.cxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_vcl.hxx" + +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/util/XStringMapping.hpp" + +#include "cppuhelper/implbase2.hxx" +#include "rtl/ustrbuf.hxx" +#include "vcl/svapp.hxx" + +using ::rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::util; + +// ----------------------------------------------------------------------- + +namespace vcl +{ + +class StringMirror : public ::cppu::WeakAggImplHelper2< XStringMapping, XServiceInfo > +{ +public: + StringMirror() + {} + + virtual ~StringMirror() + {} + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const OUString& ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + // XStringMapping + virtual sal_Bool SAL_CALL mapStrings( Sequence< OUString >& io_rStrings ) throw (RuntimeException) + { + sal_Int32 nItems = io_rStrings.getLength(); + for( sal_Int32 n = 0; n < nItems; n++ ) + { + rtl::OUString& rStr( io_rStrings.getArray()[n] ); + + sal_Int32 nLen = rStr.getLength(); + rtl::OUStringBuffer aMirror( nLen ); + for(sal_Int32 i = nLen - 1; i >= 0; i--) + { + sal_Unicode cChar = rStr[ i ]; + aMirror.append(sal_Unicode(GetMirroredChar(cChar))); + } + rStr = aMirror.makeStringAndClear(); + } + return sal_True; + } +}; + +Sequence< OUString > StringMirror_getSupportedServiceNames() +{ + static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.StringMirror" ) ); + static Sequence< OUString > aServiceNames( &aServiceName, 1 ); + return aServiceNames; +} + +OUString StringMirror_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "vcl::StringMirror" ) ); +} + +Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory >& ) +{ + return static_cast< ::cppu::OWeakObject * >( new StringMirror ); +} + + +// XServiceInfo +OUString SAL_CALL StringMirror::getImplementationName() throw (RuntimeException) +{ + return StringMirror_getImplementationName(); +} + +sal_Bool SAL_CALL StringMirror::supportsService( const OUString& i_rServiceName ) throw (RuntimeException) +{ + Sequence< OUString > aSN( StringMirror_getSupportedServiceNames() ); + for( sal_Int32 nService = 0; nService < aSN.getLength(); nService++ ) + { + if( aSN[nService] == i_rServiceName ) + return sal_True; + } + return sal_False; +} + +Sequence< OUString > SAL_CALL StringMirror::getSupportedServiceNames() throw (RuntimeException) +{ + return StringMirror_getSupportedServiceNames(); +} + +} // namespace vcl diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 038a77518935..0db9413dbf1f 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -83,6 +83,7 @@ class ImplCommonButtonData { public: Rectangle maFocusRect; + Rectangle maSymbolRect; sal_uInt16 mnButtonState; sal_Bool mbSmallSymbol; @@ -334,6 +335,18 @@ const Rectangle& Button::GetFocusRect() const // ----------------------------------------------------------------------- +const Rectangle& Button::ImplGetSymbolRect() const +{ + return mpButtonData->maSymbolRect; +} + +void Button::ImplSetSymbolRect( const Rectangle& i_rRect ) +{ + mpButtonData->maSymbolRect = i_rRect; +} + +// ----------------------------------------------------------------------- + sal_uInt16 Button::ImplGetTextStyle( XubString& rText, WinBits nWinStyle, sal_uIntPtr nDrawFlags ) { @@ -883,7 +896,8 @@ void PushButton::ImplInitSettings( sal_Bool bFont, // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled() // otherwise the formcontrol button will be overdrawn due to PARENTCLIPMODE_NOCLIP // for radio and checkbox this is ok as they shoud appear transparent in documents - if ( IsNativeControlSupported( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL ) ) + if ( IsNativeControlSupported( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL ) || + (GetStyle() & WB_FLATBUTTON) != 0 ) { EnableChildTransparentMode( sal_True ); SetParentClipMode( PARENTCLIPMODE_NOCLIP ); @@ -1142,7 +1156,9 @@ static void ImplDrawBtnDropDownArrow( OutputDevice* pDev, void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uIntPtr nDrawFlags, const Rectangle& rRect, - bool bLayout ) + bool bLayout, + bool bMenuBtnSep + ) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); Rectangle aInRect = rRect; @@ -1176,6 +1192,9 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uIntPtr nDra Size aSize = rRect.GetSize(); Point aPos = rRect.TopLeft(); + sal_uIntPtr nImageSep = 1 + (pDev->GetTextHeight()-10)/2; + if( nImageSep < 1 ) + nImageSep = 1; if ( mnDDStyle == PUSHBUTTON_DROPDOWN_MENUBUTTON ) { if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) @@ -1186,33 +1205,41 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uIntPtr nDra aInRect.Left() = aInRect.Right() - nSymbolSize; aSize.Width() -= ( 5 + nSymbolSize ); - ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, - 1, nDrawFlags, nTextStyle ); + ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, + nDrawFlags, nTextStyle, NULL, true ); } else ImplCalcSymbolRect( aInRect ); if( ! bLayout ) { + long nDistance = (aInRect.GetHeight() > 10) ? 2 : 1; DecorationView aDecoView( pDev ); + if( bMenuBtnSep ) + { + long nX = aInRect.Left() - 2*nDistance;; + Point aStartPt( nX, aInRect.Top()+nDistance ); + Point aEndPt( nX, aInRect.Bottom()-nDistance ); + aDecoView.DrawSeparator( aStartPt, aEndPt ); + } aDecoView.DrawSymbol( aInRect, SYMBOL_SPIN_DOWN, aColor, nStyle ); + aInRect.Left() -= 2*nDistance; + ImplSetSymbolRect( aInRect ); } } else { Rectangle aSymbolRect; - sal_uIntPtr nImageSep = 1 + (pDev->GetTextHeight()-10)/2; - if( nImageSep < 1 ) - nImageSep = 1; // FIXME: (GetStyle() & WB_FLATBUTTON) != 0 is preliminary // in the next major this should be replaced by "true" ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags, - nTextStyle, IsSymbol() ? &aSymbolRect : NULL, (GetStyle() & WB_FLATBUTTON) != 0 ); + nTextStyle, IsSymbol() ? &aSymbolRect : NULL, true ); if ( IsSymbol() && ! bLayout ) { DecorationView aDecoView( pDev ); aDecoView.DrawSymbol( aSymbolRect, meSymbol, aColor, nStyle ); + ImplSetSymbolRect( aSymbolRect ); } if ( mnDDStyle == PUSHBUTTON_DROPDOWN_TOOLBOX && !bLayout ) @@ -1314,7 +1341,6 @@ void PushButton::ImplDrawPushButton( bool bLayout ) // for CTRL_LISTBOX/PART_BUTTON_DOWN and CTRL_COMBOBOX/PART_BUTTON_DOWN ImplControlValue aControlValue; - Region aCtrlRegion( aInRect ); ControlState nState = 0; if ( mbPressed ) nState |= CTRL_STATE_PRESSED; @@ -1326,7 +1352,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) ) nState |= CTRL_STATE_ROLLOVER; - bNativeOK = DrawNativeControl( aCtrlType, PART_BUTTON_DOWN, aCtrlRegion, nState, + bNativeOK = DrawNativeControl( aCtrlType, PART_BUTTON_DOWN, aInRect, nState, aControlValue, rtl::OUString() ); } } @@ -1336,12 +1362,16 @@ void PushButton::ImplDrawPushButton( bool bLayout ) return; bool bRollOver = (IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() )); + bool bDrawMenuSep = true; + if( (GetStyle() & WB_FLATBUTTON) ) + { + if( ! bRollOver && ! HasFocus() ) + bDrawMenuSep = false; + } if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == sal_True ) { - PushButtonValue aPBVal; - ImplControlValue aControlValue; - aControlValue.setOptionalVal( &aPBVal ); - Region aCtrlRegion( aInRect ); + PushButtonValue aControlValue; + Rectangle aCtrlRegion( aInRect ); ControlState nState = 0; if ( mbPressed || IsChecked() ) nState |= CTRL_STATE_PRESSED; @@ -1354,7 +1384,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) nState |= CTRL_STATE_ROLLOVER; if( GetStyle() & WB_BEVELBUTTON ) - aPBVal.mbBevelButton = true; + aControlValue.mbBevelButton = true; // draw frame into invisible window to have aInRect modified correctly // but do not shift the inner rect for pressed buttons (ie remove BUTTON_DRAW_PRESSED) @@ -1373,7 +1403,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) Size aFontSize( Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetSize() ); aFontSize = LogicToPixel( aFontSize, MapMode( MAP_POINT ) ); Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) ); - aPBVal.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() ); + aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() ); if( ((nState & CTRL_STATE_ROLLOVER)) || ! (GetStyle() & WB_FLATBUTTON) ) { @@ -1388,7 +1418,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) // draw content using the same aInRect as non-native VCL would do ImplDrawPushButtonContent( this, (nState&CTRL_STATE_ROLLOVER) ? WINDOW_DRAW_ROLLOVER : 0, - aInRect, bLayout ); + aInRect, bLayout, bDrawMenuSep ); if ( HasFocus() ) ShowFocus( ImplGetFocusRect() ); @@ -1414,7 +1444,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) } // draw content - ImplDrawPushButtonContent( this, 0, aInRect, bLayout ); + ImplDrawPushButtonContent( this, 0, aInRect, bLayout, bDrawMenuSep ); if( ! bLayout && HasFocus() ) { @@ -1434,22 +1464,19 @@ void PushButton::ImplSetDefButton( sal_Bool bSet ) if ( (IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == sal_True ) { - Region aBoundingRgn, aContentRgn; + Rectangle aBound, aCont; Rectangle aCtrlRect( 0, 0, 80, 20 ); // use a constant size to avoid accumulating // will not work if the theme has dynamic adornment sizes ImplControlValue aControlValue; - Region aCtrlRegion( aCtrlRect ); + Rectangle aCtrlRegion( aCtrlRect ); ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED; // get native size of a 'default' button // and adjust the VCL button if more space for adornment is required if( GetNativeControlRegion( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState, aControlValue, rtl::OUString(), - aBoundingRgn, aContentRgn ) ) + aBound, aCont ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - Rectangle aBound(aBoundingRgn.GetBoundRect()); - dLeft = aCont.Left() - aBound.Left(); dTop = aCont.Top() - aBound.Top(); dRight = aBound.Right() - aCont.Right(); @@ -1738,7 +1765,7 @@ void PushButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, nButtonStyle |= BUTTON_DRAW_CHECKED; aRect = aDecoView.DrawButton( aRect, nButtonStyle ); - ImplDrawPushButtonContent( pDev, nFlags, aRect, false ); + ImplDrawPushButtonContent( pDev, nFlags, aRect, false, true ); pDev->Pop(); } @@ -2004,6 +2031,8 @@ Size PushButton::CalcMinimumSize( long nMaxWidth ) const aSize = Size( 16, 12 ); else aSize = Size( 26, 24 ); + if( mnDDStyle == PUSHBUTTON_DROPDOWN_MENUBUTTON ) + aSize.Width() += 4; } else if ( IsImage() && ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) ) aSize = GetModeImage().GetSizePixel(); @@ -2334,9 +2363,8 @@ void RadioButton::ImplDrawRadioButtonState() // no native drawing for image radio buttons if ( !maImage && (bNativeOK=IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)) == sal_True ) { - ImplControlValue aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 ); + ImplControlValue aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF ); Rectangle aCtrlRect( maStateRect.TopLeft(), maStateRect.GetSize() ); - Region aCtrlRegion( aCtrlRect ); ControlState nState = 0; if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED; @@ -2347,7 +2375,7 @@ void RadioButton::ImplDrawRadioButtonState() if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) ) nState |= CTRL_STATE_ROLLOVER; - bNativeOK = DrawNativeControl( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState, + bNativeOK = DrawNativeControl( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRect, nState, aControlValue,rtl::OUString() ); } @@ -3198,17 +3226,16 @@ Size RadioButton::ImplGetRadioImageSize() const { ImplControlValue aControlValue; // #i45896# workaround gcc3.3 temporary problem - Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); + Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() ); ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED; - Region aBoundingRgn, aContentRgn; + Rectangle aBoundingRgn, aContentRgn; // get native size of a radio button if( pThis->GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - aSize = aCont.GetSize(); + aSize = aContentRgn.GetSize(); bDefaultSize = false; } } @@ -3323,16 +3350,15 @@ void RadioButton::ImplSetMinimumNWFSize() ImplControlValue aControlValue; Size aCurSize( GetSizePixel() ); - Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), aCurSize ) ); - Region aBoundingRgn, aContentRgn; + Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize ); + Rectangle aBoundingRgn, aContentRgn; // get native size of a radiobutton if( GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - Size aSize = aCont.GetSize(); + Size aSize = aContentRgn.GetSize(); if( aSize.Height() > aCurSize.Height() ) { @@ -3509,8 +3535,8 @@ void CheckBox::ImplDrawCheckBoxState() if ( (bNativeOK=IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL)) == sal_True ) { - ImplControlValue aControlValue( meState == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 ); - Region aCtrlRegion( maStateRect ); + ImplControlValue aControlValue( meState == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF ); + Rectangle aCtrlRegion( maStateRect ); ControlState nState = 0; if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED; @@ -3688,11 +3714,14 @@ void CheckBox::ImplCheck() else eNewState = STATE_NOCHECK; meState = eNewState; - ImplInvalidateOrDrawCheckBoxState(); ImplDelData aDelData; ImplAddDel( &aDelData ); - Toggle(); + if( (GetStyle() & WB_EARLYTOGGLE) ) + Toggle(); + ImplInvalidateOrDrawCheckBoxState(); + if( ! (GetStyle() & WB_EARLYTOGGLE) ) + Toggle(); if ( aDelData.IsDelete() ) return; ImplRemoveDel( &aDelData ); @@ -4141,17 +4170,16 @@ Size CheckBox::ImplGetCheckImageSize() const { ImplControlValue aControlValue; // #i45896# workaround gcc3.3 temporary problem - Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); + Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() ); ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED; - Region aBoundingRgn, aContentRgn; + Rectangle aBoundingRgn, aContentRgn; // get native size of a check box if( pThis->GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - aSize = aCont.GetSize(); + aSize = aContentRgn.GetSize(); bDefaultSize = false; } } @@ -4231,16 +4259,15 @@ void CheckBox::ImplSetMinimumNWFSize() ImplControlValue aControlValue; Size aCurSize( GetSizePixel() ); - Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), aCurSize ) ); - Region aBoundingRgn, aContentRgn; + Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize ); + Rectangle aBoundingRgn, aContentRgn; // get native size of a radiobutton if( GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - Size aSize = aCont.GetSize(); + Size aSize = aContentRgn.GetSize(); if( aSize.Height() > aCurSize.Height() ) { @@ -4441,8 +4468,8 @@ void DisclosureButton::ImplDrawCheckBoxState() Rectangle aStateRect( GetStateRect() ); - ImplControlValue aControlValue( GetState() == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 ); - Region aCtrlRegion( aStateRect ); + ImplControlValue aControlValue( GetState() == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF ); + Rectangle aCtrlRegion( aStateRect ); ControlState nState = 0; if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED; diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 0060a724b83d..6ecf0f1d4696 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -139,8 +139,8 @@ void ComboBox::ImplCalcEditHeight() if ( !IsDropDownBox() ) mnDDHeight += 4; - Region aCtrlRegion( Rectangle( (const Point&)Point(), Size( 10, 10 ) ) ); - Region aBoundRegion, aContentRegion; + Rectangle aCtrlRegion( Point( 0, 0 ), Size( 10, 10 ) ); + Rectangle aBoundRegion, aContentRegion; ImplControlValue aControlValue; ControlType aType = IsDropDownBox() ? CTRL_COMBOBOX : CTRL_EDITBOX; if( GetNativeControlRegion( aType, PART_ENTIRE_CONTROL, @@ -149,7 +149,7 @@ void ComboBox::ImplCalcEditHeight() aControlValue, rtl::OUString(), aBoundRegion, aContentRegion ) ) { - const long nNCHeight = aBoundRegion.GetBoundRect().GetHeight(); + const long nNCHeight = aBoundRegion.GetHeight(); if( mnDDHeight < nNCHeight ) mnDDHeight = sal::static_int_cast<sal_uInt16>( nNCHeight ); } @@ -629,10 +629,10 @@ void ComboBox::Resize() Window *pBorder = GetWindow( WINDOW_BORDER ); ImplControlValue aControlValue; Point aPoint; - Region aContent, aBound; + Rectangle aContent, aBound; // use the full extent of the control - Region aArea( Rectangle(aPoint, pBorder->GetOutputSizePixel()) ); + Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) @@ -641,7 +641,7 @@ void ComboBox::Resize() aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) ); aContent.Move(-aPoint.X(), -aPoint.Y()); - mpBtn->SetPosSizePixel( aContent.GetBoundRect().Left(), nTop, aContent.GetBoundRect().getWidth(), (nBottom-nTop) ); + mpBtn->SetPosSizePixel( aContent.Left(), nTop, aContent.getWidth(), (nBottom-nTop) ); // adjust the size of the edit field if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_SUB_EDIT, @@ -651,13 +651,12 @@ void ComboBox::Resize() aContent.Move(-aPoint.X(), -aPoint.Y()); // use the themes drop down size - Rectangle aContentRect = aContent.GetBoundRect(); - mpSubEdit->SetPosSizePixel( aContentRect.TopLeft(), aContentRect.GetSize() ); + mpSubEdit->SetPosSizePixel( aContent.TopLeft(), aContent.GetSize() ); } else { // use the themes drop down size for the button - aOutSz.Width() -= aContent.GetBoundRect().getWidth(); + aOutSz.Width() -= aContent.getWidth(); mpSubEdit->SetSizePixel( aOutSz ); } } @@ -1011,6 +1010,14 @@ void ComboBox::Clear() mpImplLB->Clear(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMREMOVED, (void*) sal_IntPtr(-1) ); } +// ----------------------------------------------------------------------- + +Image ComboBox::GetEntryImage( sal_uInt16 nPos ) const +{ + if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) ) + return mpImplLB->GetEntryList()->GetEntryImage( nPos ); + return Image(); +} // ----------------------------------------------------------------------- diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 4fe401eca98e..e42dce4880cc 100644..100755 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -122,6 +122,7 @@ struct DDInfo sal_Bool bStarterOfDD; sal_Bool bDroppedInMe; sal_Bool bVisCursor; + sal_Bool bIsStringSupported; DDInfo() { @@ -130,6 +131,7 @@ struct DDInfo bStarterOfDD = sal_False; bDroppedInMe = sal_False; bVisCursor = sal_False; + bIsStringSupported = sal_False; } }; @@ -1799,6 +1801,9 @@ sal_Bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) } break; + /* #i101255# disable autocomplete tab forward/backward + users expect tab/shif-tab to move the focus to other controls + not suddenly to cycle the autocompletion case KEY_TAB: { if ( !mbReadOnly && maAutocompleteHdl.IsSet() && @@ -1820,6 +1825,7 @@ sal_Bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) } } break; + */ default: { @@ -2842,7 +2848,7 @@ Size Edit::CalcMinimumSize() const Size aMinSize ( CalcSize( 3 ) ); if( aSize.Width() < aMinSize.Width() ) aSize.Width() = aMinSize.Width(); - // add some space between text entry an border + // add some space between text entry and border aSize.Height() += 4; aSize = CalcWindowSize( aSize ); @@ -2850,18 +2856,25 @@ Size Edit::CalcMinimumSize() const // ask NWF what if it has an opinion, too ImplControlValue aControlValue; Rectangle aRect( Point( 0, 0 ), aSize ); - Region aContent, aBound; + Rectangle aContent, aBound; if( const_cast<Edit*>(this)->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { - Rectangle aBoundRect( aContent.GetBoundRect() ); - if( aBoundRect.GetHeight() > aSize.Height() ) - aSize.Height() = aBoundRect.GetHeight(); + if( aBound.GetHeight() > aSize.Height() ) + aSize.Height() = aBound.GetHeight(); } return aSize; } +Size Edit::GetMinimumEditSize() +{ + Window* pDefWin = ImplGetDefaultWindow(); + Edit aEdit( pDefWin, WB_BORDER ); + Size aSize( aEdit.CalcMinimumSize() ); + return aSize; +} + // ----------------------------------------------------------------------- Size Edit::GetOptimalSize(WindowSizeType eType) const @@ -3055,17 +3068,26 @@ void Edit::drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& rDTDE.Context->dropComplete( bChanges ); } -void Edit::dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& ) throw (::com::sun::star::uno::RuntimeException) +void Edit::dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException) { if ( !mpDDInfo ) { mpDDInfo = new DDInfo; } -// sal_Bool bTextContent = mbReadOnly ? sal_False : sal_True; // quiery from rDTDEE.SupportedDataFlavors() -// if ( bTextContent ) -// rDTDEE.Context->acceptDrop(datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE); -// else -// rDTDEE.Context->rejectDrop(); + // search for string data type + const Sequence< com::sun::star::datatransfer::DataFlavor >& rFlavors( rDTDE.SupportedDataFlavors ); + sal_Int32 nEle = rFlavors.getLength(); + mpDDInfo->bIsStringSupported = sal_False; + for( sal_Int32 i = 0; i < nEle; i++ ) + { + sal_Int32 nIndex = 0; + rtl::OUString aMimetype = rFlavors[i].MimeType.getToken( 0, ';', nIndex ); + if( aMimetype.equalsAscii( "text/plain" ) ) + { + mpDDInfo->bIsStringSupported = sal_True; + break; + } + } } void Edit::dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& ) throw (::com::sun::star::uno::RuntimeException) @@ -3097,7 +3119,7 @@ void Edit::dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEv aSel.Justify(); // Don't accept drop in selection or read-only field... - if ( IsReadOnly() || aSel.IsInside( mpDDInfo->nDropPos ) ) + if ( IsReadOnly() || aSel.IsInside( mpDDInfo->nDropPos ) || ! mpDDInfo->bIsStringSupported ) { ImplHideDDCursor(); rDTDE.Context->rejectDrag(); diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 90b70f2b2b63..b45ea4bdc7af 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -52,8 +52,6 @@ using namespace ::com::sun::star; -static ResStringArray *strAllUnits = NULL; - // ----------------------------------------------------------------------- #define FORMAT_NUMERIC 1 @@ -224,6 +222,42 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, return sal_True; } +static void ImplUpdateSeparatorString( String& io_rText, + const String& rOldDecSep, const String& rNewDecSep, + const String& rOldThSep, const String& rNewThSep ) +{ + rtl::OUStringBuffer aBuf( io_rText.Len() ); + xub_StrLen nIndexDec = 0, nIndexTh = 0, nIndex = 0; + + const sal_Unicode* pBuffer = io_rText.GetBuffer(); + while( nIndex != STRING_NOTFOUND ) + { + nIndexDec = io_rText.Search( rOldDecSep, nIndex ); + nIndexTh = io_rText.Search( rOldThSep, nIndex ); + if( (nIndexTh != STRING_NOTFOUND && nIndexDec != STRING_NOTFOUND && nIndexTh < nIndexDec ) + || (nIndexTh != STRING_NOTFOUND && nIndexDec == STRING_NOTFOUND) + ) + { + aBuf.append( pBuffer + nIndex, nIndexTh - nIndex ); + aBuf.append( rNewThSep ); + nIndex = nIndexTh + rOldThSep.Len(); + } + else if( nIndexDec != STRING_NOTFOUND ) + { + aBuf.append( pBuffer + nIndex, nIndexDec - nIndex ); + aBuf.append( rNewDecSep ); + nIndex = nIndexDec + rOldDecSep.Len(); + } + else + { + aBuf.append( pBuffer + nIndex ); + nIndex = STRING_NOTFOUND; + } + } + + io_rText = aBuf.makeStringAndClear(); +} + static void ImplUpdateSeparators( const String& rOldDecSep, const String& rNewDecSep, const String& rOldThSep, const String& rNewThSep, Edit* pEdit ) @@ -236,10 +270,7 @@ static void ImplUpdateSeparators( const String& rOldDecSep, const String& rNewDe sal_Bool bUpdateMode = pEdit->IsUpdateMode(); pEdit->SetUpdateMode( sal_False ); String aText = pEdit->GetText(); - if( bChangeDec ) - aText.SearchAndReplaceAll( rNewDecSep, rOldDecSep ); - if( bChangeTh ) - aText.SearchAndReplaceAll( rNewThSep, rOldThSep ); + ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); pEdit->SetText( aText ); ComboBox* pCombo = dynamic_cast<ComboBox*>(pEdit); @@ -250,12 +281,11 @@ static void ImplUpdateSeparators( const String& rOldDecSep, const String& rNewDe for ( sal_uInt16 i=0; i < nEntryCount; i++ ) { aText = pCombo->GetEntry( i ); - if( bChangeDec ) - aText.SearchAndReplaceAll( rNewDecSep, rOldDecSep ); - if( bChangeTh ) - aText.SearchAndReplaceAll( rNewThSep, rOldThSep ); + void* pEntryData = pCombo->GetEntryData( i ); + ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); pCombo->RemoveEntry( i ); pCombo->InsertEntry( aText, i ); + pCombo->SetEntryData( i, pEntryData ); } } if( bUpdateMode ) @@ -1099,34 +1129,37 @@ static XubString ImplMetricGetUnitText( const XubString& rStr ) // #104355# support localized mesaurements -static String ImplMetricToString( FieldUnit rUnit ) +static const String& ImplMetricToString( FieldUnit rUnit ) { - if( !strAllUnits ) + FieldUnitStringList* pList = ImplGetFieldUnits(); + if( pList ) { - ResMgr* pResMgr = ImplGetResMgr(); - strAllUnits = new ResStringArray( ResId (SV_FUNIT_STRINGS, *pResMgr) ); + // return unit's default string (ie, the first one ) + for( FieldUnitStringList::const_iterator it = pList->begin(); it != pList->end(); ++it ) + { + if ( it->second == rUnit ) + return it->first; + } } - // return unit's default string (ie, the first one ) - for( sal_uInt16 i=0; i < strAllUnits->Count(); i++ ) - if( (FieldUnit) strAllUnits->GetValue( i ) == rUnit ) - return strAllUnits->GetString( i ); - return String(); + return String::EmptyString(); } static FieldUnit ImplStringToMetric( const String &rMetricString ) { - if( !strAllUnits ) + FieldUnitStringList* pList = ImplGetCleanedFieldUnits(); + if( pList ) { - ResMgr* pResMgr = ImplGetResMgr(); - strAllUnits = new ResStringArray( ResId (SV_FUNIT_STRINGS, *pResMgr) ); + // return FieldUnit + String aStr( rMetricString ); + aStr.ToLowerAscii(); + aStr.EraseAllChars( sal_Unicode( ' ' ) ); + for( FieldUnitStringList::const_iterator it = pList->begin(); it != pList->end(); ++it ) + { + if ( it->first.Equals( aStr ) ) + return it->second; + } } - // return FieldUnit - String aStr( rMetricString ); - aStr.ToLowerAscii(); - for( sal_uInt16 i=0; i < strAllUnits->Count(); i++ ) - if ( strAllUnits->GetString( i ).Equals( aStr ) ) - return (FieldUnit) strAllUnits->GetValue( i ); return FUNIT_NONE; } diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 5cdcf3943a65..2db2ef005203 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -27,13 +27,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/decoview.hxx> -#include <vcl/event.hxx> -#include <vcl/fixed.hxx> -#include <vcl/controldata.hxx> -#include <vcl/window.h> +#include "vcl/decoview.hxx" +#include "vcl/event.hxx" +#include "vcl/fixed.hxx" +#include "vcl/controldata.hxx" +#include "vcl/window.h" -#include <tools/rc.h> +#include "tools/rc.h" // ======================================================================= @@ -501,7 +501,7 @@ void FixedLine::ImplDraw( bool bLayout ) String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; DecorationView aDecoView( this ); - if ( !aText.Len() || (nWinStyle & WB_VERT) ) + if ( !aText.Len() ) { if( !pVector ) { @@ -520,11 +520,34 @@ void FixedLine::ImplDraw( bool bLayout ) } } } + else if( (nWinStyle & WB_VERT) ) + { + long nWidth = GetTextWidth( aText ); + Push( PUSH_FONT ); + Font aFont( GetFont() ); + aFont.SetOrientation( 900 ); + SetFont( aFont ); + Point aStartPt( aOutSize.Width()/2, aOutSize.Height()-1 ); + if( (nWinStyle & WB_VCENTER) ) + aStartPt.Y() -= (aOutSize.Height() - nWidth)/2; + Point aTextPt( aStartPt ); + aTextPt.X() -= GetTextHeight()/2; + DrawText( aTextPt, aText, 0, STRING_LEN, pVector, pDisplayText ); + Pop(); + if( aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER ) + aDecoView.DrawSeparator( Point( aStartPt.X(), aOutSize.Height()-1 ), + Point( aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER ) ); + if( aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0 ) + aDecoView.DrawSeparator( Point( aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER ), + Point( aStartPt.X(), 0 ) ); + } else { sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS; Rectangle aRect( 0, 0, aOutSize.Width(), aOutSize.Height() ); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + if( (nWinStyle & WB_CENTER) ) + nStyle |= TEXT_DRAW_CENTER; if ( !IsEnabled() ) nStyle |= TEXT_DRAW_DISABLE; @@ -539,6 +562,8 @@ void FixedLine::ImplDraw( bool bLayout ) { long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2); aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false ); + if( aRect.Left() > FIXEDLINE_TEXT_BORDER ) + aDecoView.DrawSeparator( Point( 0, nTop ), Point( aRect.Left()-FIXEDLINE_TEXT_BORDER, nTop ), false ); } } } diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 2c4f2109eab0..8d70bc1fd991 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -2356,7 +2356,11 @@ IMPL_LINK( ImplListBox, MRUChanged, void*, EMPTYARG ) IMPL_LINK( ImplListBox, LBWindowScrolled, void*, EMPTYARG ) { + long nSet = GetTopEntry(); + if( nSet > mpVScrollBar->GetRangeMax() ) + mpVScrollBar->SetRangeMax( GetEntryList()->GetEntryCount() ); mpVScrollBar->SetThumbPos( GetTopEntry() ); + mpHScrollBar->SetThumbPos( GetLeftIndent() ); maScrollHdl.Call( this ); @@ -2395,7 +2399,11 @@ void ImplListBox::ImplCheckScrollBars() mbVScroll = sal_True; // Ueberpruefung des rausgescrollten Bereichs - SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft... + if( GetEntryList()->GetSelectEntryCount() == 1 && + GetEntryList()->GetSelectEntryPos( 0 ) != LISTBOX_ENTRY_NOTFOUND ) + ShowProminentEntry( GetEntryList()->GetSelectEntryPos( 0 ) ); + else + SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft... } else { @@ -2428,7 +2436,11 @@ void ImplListBox::ImplCheckScrollBars() mbVScroll = sal_True; // Ueberpruefung des rausgescrollten Bereichs - SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft... + if( GetEntryList()->GetSelectEntryCount() == 1 && + GetEntryList()->GetSelectEntryPos( 0 ) != LISTBOX_ENTRY_NOTFOUND ) + ShowProminentEntry( GetEntryList()->GetSelectEntryPos( 0 ) ); + else + SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft... } } @@ -2819,7 +2831,7 @@ void ImplWin::ImplDraw( bool bLayout ) sal_Int32 nLeft, nTop, nRight, nBottom; pWin->GetBorder( nLeft, nTop, nRight, nBottom ); Point aPoint( -nLeft, -nTop ); - Region aCtrlRegion( Rectangle( aPoint - GetPosPixel(), pWin->GetSizePixel() ) ); + Rectangle aCtrlRegion( aPoint - GetPosPixel(), pWin->GetSizePixel() ); sal_Bool bMouseOver = sal_False; if( GetParent() ) @@ -2838,8 +2850,7 @@ void ImplWin::ImplDraw( bool bLayout ) if( ! (nParentStyle & WB_BORDER) || (nParentStyle & WB_NOBORDER) ) { Rectangle aParentRect( Point( 0, 0 ), pWin->GetSizePixel() ); - Region aParentReg( aParentRect ); - pWin->DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aParentReg, + pWin->DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aParentRect, nState, aControlValue, rtl::OUString() ); } diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 25cb57c7859b..1c13aef10340 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -44,9 +44,10 @@ #include "tools/debug.hxx" +#include <vcl/dndevdis.hxx> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> - -// ======================================================================= +// ======================================================================= ListBox::ListBox( WindowType nType ) : Control( nType ) { @@ -119,6 +120,8 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) Control::ImplInit( pParent, nStyle, NULL ); SetBackground(); + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener> xDrop = new DNDEventDispatcher(this); + if( nStyle & WB_DROPDOWN ) { sal_Int32 nLeft, nTop, nRight, nBottom; @@ -129,14 +132,14 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) ) { ImplControlValue aControlValue; - Region aCtrlRegion( Rectangle( (const Point&)Point(), Size( 20, mnDDHeight ) ) ); - Region aBoundingRgn( aCtrlRegion ); - Region aContentRgn( aCtrlRegion ); + Rectangle aCtrlRegion( Point( 0, 0 ), Size( 20, mnDDHeight ) ); + Rectangle aBoundingRgn( aCtrlRegion ); + Rectangle aContentRgn( aCtrlRegion ); if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - sal_Int32 nHeight = aBoundingRgn.GetBoundRect().GetHeight(); + sal_Int32 nHeight = aBoundingRgn.GetHeight(); if( nHeight > mnDDHeight ) mnDDHeight = static_cast<sal_uInt16>(nHeight); } @@ -145,16 +148,19 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) mpFloatWin = new ImplListBoxFloatingWindow( this ); mpFloatWin->SetAutoWidth( sal_True ); mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) ); + mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop); mpImplWin = new ImplWin( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER ); mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) ); mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) ); mpImplWin->Show(); + mpImplWin->GetDropTarget()->addDropTargetListener(xDrop); mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); ImplInitDropDownButton( mpBtn ); mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) ); mpBtn->Show(); + mpBtn->GetDropTarget()->addDropTargetListener(xDrop); } @@ -170,6 +176,9 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) mpImplLB->SetPosPixel( Point() ); mpImplLB->Show(); + mpImplLB->GetDropTarget()->addDropTargetListener(xDrop); + mpImplLB->SetDropTraget(xDrop); + if ( mpFloatWin ) { mpFloatWin->SetImplListBox( mpImplLB ); @@ -652,10 +661,10 @@ void ListBox::Resize() Window *pBorder = GetWindow( WINDOW_BORDER ); ImplControlValue aControlValue; Point aPoint; - Region aContent, aBound; + Rectangle aContent, aBound; // use the full extent of the control - Region aArea( Rectangle(aPoint, pBorder->GetOutputSizePixel()) ); + Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); if ( GetNativeControlRegion( CTRL_LISTBOX, PART_BUTTON_DOWN, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) @@ -665,8 +674,8 @@ void ListBox::Resize() aContent.Move( -aPoint.X(), -aPoint.Y() ); // use the themes drop down size for the button - aOutSz.Width() = aContent.GetBoundRect().Left(); - mpBtn->SetPosSizePixel( aContent.GetBoundRect().Left(), nTop, aContent.GetBoundRect().Right(), (nBottom-nTop) ); + aOutSz.Width() = aContent.Left(); + mpBtn->SetPosSizePixel( aContent.Left(), nTop, aContent.Right(), (nBottom-nTop) ); // adjust the size of the edit field if ( GetNativeControlRegion( CTRL_LISTBOX, PART_SUB_EDIT, @@ -676,7 +685,6 @@ void ListBox::Resize() aContent.Move( -aPoint.X(), -aPoint.Y() ); // use the themes drop down size - Rectangle aContentRect = aContent.GetBoundRect(); if( ! (GetStyle() & WB_BORDER) && ImplGetSVData()->maNWFData.mbNoFocusRects ) { // no border but focus ring behavior -> we have a problem; the @@ -684,11 +692,11 @@ void ListBox::Resize() // let's do the best we can and center vertically, so it doesn't look // completely wrong. Size aSz( GetOutputSizePixel() ); - long nDiff = aContentRect.Top() - (aSz.Height() - aContentRect.GetHeight())/2; - aContentRect.Top() -= nDiff; - aContentRect.Bottom() -= nDiff; + long nDiff = aContent.Top() - (aSz.Height() - aContent.GetHeight())/2; + aContent.Top() -= nDiff; + aContent.Bottom() -= nDiff; } - mpImplWin->SetPosSizePixel( aContentRect.TopLeft(), aContentRect.GetSize() ); + mpImplWin->SetPosSizePixel( aContent.TopLeft(), aContent.GetSize() ); } else mpImplWin->SetSizePixel( aOutSz ); @@ -1327,15 +1335,14 @@ Size ListBox::CalcMinimumSize() const // see how large the edit area inside is to estimate what is needed for the dropdown ImplControlValue aControlValue; Point aPoint; - Region aContent, aBound; + Rectangle aContent, aBound; Size aTestSize( 100, 20 ); - Region aArea( Rectangle( aPoint, aTestSize ) ); + Rectangle aArea( aPoint, aTestSize ); if( const_cast<ListBox*>(this)->GetNativeControlRegion( CTRL_LISTBOX, PART_SUB_EDIT, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { // use the themes drop down size - Rectangle aContentRect = aContent.GetBoundRect(); - aSz.Width() += aTestSize.Width() - aContentRect.GetWidth(); + aSz.Width() += aTestSize.Width() - aContent.GetWidth(); } else aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize(); @@ -1347,13 +1354,12 @@ Size ListBox::CalcMinimumSize() const { ImplControlValue aControlValue; Rectangle aRect( Point( 0, 0 ), aSz ); - Region aContent, aBound; + Rectangle aContent, aBound; if( const_cast<ListBox*>(this)->GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { - Rectangle aBoundRect( aBound.GetBoundRect() ); - if( aBoundRect.GetHeight() > aSz.Height() ) - aSz.Height() = aBoundRect.GetHeight(); + if( aBound.GetHeight() > aSz.Height() ) + aSz.Height() = aBound.GetHeight(); } } @@ -1615,7 +1621,6 @@ const Wallpaper& ListBox::GetDisplayBackground() const } // ======================================================================= - MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) : ListBox( WINDOW_MULTILISTBOX ) { diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx index ef7c230dc24e..ce6d09e3d74e 100644 --- a/vcl/source/control/menubtn.cxx +++ b/vcl/source/control/menubtn.cxx @@ -169,20 +169,27 @@ IMPL_LINK( MenuButton, ImplMenuTimeoutHdl, Timer*, EMPTYARG ) void MenuButton::MouseButtonDown( const MouseEvent& rMEvt ) { + bool bExecute = true; if ( mnMenuMode & MENUBUTTON_MENUMODE_TIMED ) { - if ( !mpMenuTimer ) + // if the separated dropdown symbol is hit, + // execute the popup immediately + if( ! ImplGetSymbolRect().IsInside( rMEvt.GetPosPixel() ) ) { - mpMenuTimer = new Timer; - mpMenuTimer->SetTimeoutHdl( LINK( this, MenuButton, ImplMenuTimeoutHdl ) ); - } + if ( !mpMenuTimer ) + { + mpMenuTimer = new Timer; + mpMenuTimer->SetTimeoutHdl( LINK( this, MenuButton, ImplMenuTimeoutHdl ) ); + } - mpMenuTimer->SetTimeout( GetSettings().GetMouseSettings().GetActionDelay() ); - mpMenuTimer->Start(); + mpMenuTimer->SetTimeout( GetSettings().GetMouseSettings().GetActionDelay() ); + mpMenuTimer->Start(); - PushButton::MouseButtonDown( rMEvt ); + PushButton::MouseButtonDown( rMEvt ); + bExecute = false; + } } - else + if( bExecute ) { if ( PushButton::ImplHitTestPushButton( this, rMEvt.GetPosPixel() ) ) { diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index 730b96eaee89..5ad387190645 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -342,8 +342,8 @@ void ScrollBar::ImplCalc( sal_Bool bUpdate ) Rectangle& maTrackRect = mpData->maTrackRect; // TODO: remove when maTrackRect is no longer in mpData if ( mbCalcSize ) { - const Region aControlRegion( Rectangle( (const Point&)Point(0,0), aSize ) ); - Region aBtn1Region, aBtn2Region, aTrackRegion, aBoundingRegion; + const Rectangle aControlRegion( Point(0,0), aSize ); + Rectangle aBtn1Region, aBtn2Region, aTrackRegion, aBoundingRegion; if ( GetStyle() & WB_HORZ ) { @@ -352,8 +352,8 @@ void ScrollBar::ImplCalc( sal_Bool bUpdate ) GetNativeControlRegion( CTRL_SCROLLBAR, PART_BUTTON_RIGHT, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aBoundingRegion, aBtn2Region ) ) { - maBtn1Rect = aBtn1Region.GetBoundRect(); - maBtn2Rect = aBtn2Region.GetBoundRect(); + maBtn1Rect = aBtn1Region; + maBtn2Rect = aBtn2Region; } else { @@ -366,7 +366,7 @@ void ScrollBar::ImplCalc( sal_Bool bUpdate ) if ( GetNativeControlRegion( CTRL_SCROLLBAR, PART_TRACK_HORZ_AREA, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aBoundingRegion, aTrackRegion ) ) - maTrackRect = aTrackRegion.GetBoundRect(); + maTrackRect = aTrackRegion; else maTrackRect = Rectangle( maBtn1Rect.TopRight(), maBtn2Rect.BottomLeft() ); @@ -393,8 +393,8 @@ void ScrollBar::ImplCalc( sal_Bool bUpdate ) GetNativeControlRegion( CTRL_SCROLLBAR, PART_BUTTON_DOWN, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aBoundingRegion, aBtn2Region ) ) { - maBtn1Rect = aBtn1Region.GetBoundRect(); - maBtn2Rect = aBtn2Region.GetBoundRect(); + maBtn1Rect = aBtn1Region; + maBtn2Rect = aBtn2Region; } else { @@ -407,7 +407,7 @@ void ScrollBar::ImplCalc( sal_Bool bUpdate ) if ( GetNativeControlRegion( CTRL_SCROLLBAR, PART_TRACK_VERT_AREA, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aBoundingRegion, aTrackRegion ) ) - maTrackRect = aTrackRegion.GetBoundRect(); + maTrackRect = aTrackRegion; else maTrackRect = Rectangle( maBtn1Rect.BottomLeft()+Point(0,1), maBtn2Rect.TopRight() ); @@ -524,7 +524,7 @@ void ScrollBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) { - ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + ScrollbarValue scrValue; sal_Bool bNativeOK = IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL); if( bNativeOK ) @@ -535,7 +535,6 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) if( IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT) ) { ControlState nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 ); - ScrollbarValue scrValue; scrValue.mnMin = mnMinRange; scrValue.mnMax = mnMaxRange; @@ -570,20 +569,14 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) } } - aControlValue.setOptionalVal( (void *)(&scrValue) ); - -#if 1 - Region aCtrlRegion; + Rectangle aCtrlRegion; aCtrlRegion.Union( maBtn1Rect ); aCtrlRegion.Union( maBtn2Rect ); aCtrlRegion.Union( maPage1Rect ); aCtrlRegion.Union( maPage2Rect ); aCtrlRegion.Union( maThumbRect ); -#else - const Region aCtrlRegion( Rectangle( Point(0,0), GetOutputSizePixel() ) ); -#endif bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT), - aCtrlRegion, nState, aControlValue, rtl::OUString() ); + aCtrlRegion, nState, scrValue, rtl::OUString() ); } else { @@ -591,8 +584,8 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) { sal_uInt32 part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER; sal_uInt32 part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER; - Region aCtrlRegion1( maPage1Rect ); - Region aCtrlRegion2( maPage2Rect ); + Rectangle aCtrlRegion1( maPage1Rect ); + Rectangle aCtrlRegion2( maPage2Rect ); ControlState nState1 = (IsEnabled() ? CTRL_STATE_ENABLED : 0) | (HasFocus() ? CTRL_STATE_FOCUSED : 0); ControlState nState2 = nState1; @@ -613,18 +606,18 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) if ( nDrawFlags & SCRBAR_DRAW_PAGE1 ) bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, - aControlValue, rtl::OUString() ); + scrValue, rtl::OUString() ); if ( nDrawFlags & SCRBAR_DRAW_PAGE2 ) bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, - aControlValue, rtl::OUString() ); + scrValue, rtl::OUString() ); } if ( (nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2) ) { sal_uInt32 part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP; sal_uInt32 part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN; - Region aCtrlRegion1( maBtn1Rect ); - Region aCtrlRegion2( maBtn2Rect ); + Rectangle aCtrlRegion1( maBtn1Rect ); + Rectangle aCtrlRegion2( maBtn2Rect ); ControlState nState1 = HasFocus() ? CTRL_STATE_FOCUSED : 0; ControlState nState2 = nState1; @@ -655,16 +648,16 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) if ( nDrawFlags & SCRBAR_DRAW_BTN1 ) bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, - aControlValue, rtl::OUString() ); + scrValue, rtl::OUString() ); if ( nDrawFlags & SCRBAR_DRAW_BTN2 ) bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, - aControlValue, rtl::OUString() ); + scrValue, rtl::OUString() ); } if ( (nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty() ) { ControlState nState = IsEnabled() ? CTRL_STATE_ENABLED : 0; - Region aCtrlRegion( maThumbRect ); + Rectangle aCtrlRegion( maThumbRect ); if ( mnStateFlags & SCRBAR_STATE_THUMB_DOWN ) nState |= CTRL_STATE_PRESSED; @@ -683,7 +676,7 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags ) } bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT), - aCtrlRegion, nState, aControlValue, rtl::OUString() ); + aCtrlRegion, nState, scrValue, rtl::OUString() ); } } } @@ -920,7 +913,7 @@ void ScrollBar::ImplDoMouseAction( const Point& rMousePos, sal_Bool bCallAction sal_Bool bIsInside = sal_False; Point aPoint( 0, 0 ); - Region aControlRegion( Rectangle( aPoint, GetOutputSizePixel() ) ); + Rectangle aControlRegion( aPoint, GetOutputSizePixel() ); switch ( meScrollType ) { @@ -953,7 +946,7 @@ void ScrollBar::ImplDoMouseAction( const Point& rMousePos, sal_Bool bCallAction case SCROLL_PAGEUP: // HitTestNativeControl, see remark at top of file if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_LEFT: PART_TRACK_VERT_UPPER, - Region( maPage1Rect ), rMousePos, bIsInside )? + maPage1Rect, rMousePos, bIsInside )? bIsInside: maPage1Rect.IsInside( rMousePos ) ) { @@ -967,7 +960,7 @@ void ScrollBar::ImplDoMouseAction( const Point& rMousePos, sal_Bool bCallAction case SCROLL_PAGEDOWN: // HitTestNativeControl, see remark at top of file if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_RIGHT: PART_TRACK_VERT_LOWER, - Region( maPage2Rect ), rMousePos, bIsInside )? + maPage2Rect, rMousePos, bIsInside )? bIsInside: maPage2Rect.IsInside( rMousePos ) ) { @@ -1030,7 +1023,7 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) sal_Bool bDragToMouse = sal_False; Point aPoint( 0, 0 ); - Region aControlRegion( Rectangle( aPoint, GetOutputSizePixel() ) ); + Rectangle aControlRegion( aPoint, GetOutputSizePixel() ); if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_BUTTON_LEFT: PART_BUTTON_UP, aControlRegion, rMousePos, bIsInside )? @@ -1063,7 +1056,7 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) else { bool bThumbHit = HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_THUMB_HORZ : PART_THUMB_VERT, - Region( maThumbRect ), rMousePos, bIsInside ) + maThumbRect, rMousePos, bIsInside ) ? bIsInside : maThumbRect.IsInside( rMousePos ); bool bDragHandling = rMEvt.IsMiddle() || bThumbHit || ImplGetSVData()->maNWFData.mbScrollbarJumpPage; if( bDragHandling ) @@ -1112,7 +1105,7 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) // HitTestNativeControl, see remark at top of file if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER, - Region( maPage1Rect ), rMousePos, bIsInside )? + maPage1Rect, rMousePos, bIsInside )? bIsInside: maPage1Rect.IsInside( rMousePos ) ) { @@ -1387,7 +1380,7 @@ Rectangle* ScrollBar::ImplFindPartRect( const Point& rPt ) sal_Bool bIsInside = sal_False; Point aPoint( 0, 0 ); - Region aControlRegion( Rectangle( aPoint, GetOutputSizePixel() ) ); + Rectangle aControlRegion( aPoint, GetOutputSizePixel() ); if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_BUTTON_LEFT: PART_BUTTON_UP, aControlRegion, rPt, bIsInside )? @@ -1401,19 +1394,19 @@ Rectangle* ScrollBar::ImplFindPartRect( const Point& rPt ) return &maBtn2Rect; // HitTestNativeControl, see remark at top of file else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER, - Region( maPage1Rect ), rPt, bIsInside)? + maPage1Rect, rPt, bIsInside)? bIsInside: maPage1Rect.IsInside( rPt ) ) return &maPage1Rect; // HitTestNativeControl, see remark at top of file else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER, - Region( maPage2Rect ), rPt, bIsInside)? + maPage2Rect, rPt, bIsInside)? bIsInside: maPage2Rect.IsInside( rPt ) ) return &maPage2Rect; // HitTestNativeControl, see remark at top of file else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_THUMB_HORZ : PART_THUMB_VERT, - Region( maThumbRect ), rPt, bIsInside)? + maThumbRect, rPt, bIsInside)? bIsInside: maThumbRect.IsInside( rPt ) ) return &maThumbRect; diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 588ade6cf9e5..ef23e3cda032 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -195,15 +195,14 @@ void Slider::ImplUpdateRects( sal_Bool bUpdate ) else maChannel2Rect.SetEmpty(); - const Region aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) ); - Region aThumbBounds, aThumbContent; + const Rectangle aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) ); + Rectangle aThumbBounds, aThumbContent; if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aThumbBounds, aThumbContent ) ) { - Rectangle aRect( aThumbBounds.GetBoundRect() ); - maThumbRect.Left() = mnThumbPixPos - aRect.GetWidth()/2; - maThumbRect.Right() = maThumbRect.Left() + aRect.GetWidth() - 1; + maThumbRect.Left() = mnThumbPixPos - aThumbBounds.GetWidth()/2; + maThumbRect.Right() = maThumbRect.Left() + aThumbBounds.GetWidth() - 1; bInvalidateAll = true; } } @@ -230,15 +229,14 @@ void Slider::ImplUpdateRects( sal_Bool bUpdate ) else maChannel2Rect.SetEmpty(); - const Region aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) ); - Region aThumbBounds, aThumbContent; + const Rectangle aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) ); + Rectangle aThumbBounds, aThumbContent; if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT, aControlRegion, 0, ImplControlValue(), rtl::OUString(), aThumbBounds, aThumbContent ) ) { - Rectangle aRect( aThumbBounds.GetBoundRect() ); - maThumbRect.Top() = mnThumbPixPos - aRect.GetHeight()/2; - maThumbRect.Bottom() = maThumbRect.Top() + aRect.GetHeight() - 1; + maThumbRect.Top() = mnThumbPixPos - aThumbBounds.GetHeight()/2; + maThumbRect.Bottom() = maThumbRect.Top() + aThumbBounds.GetHeight() - 1; bInvalidateAll = true; } } @@ -388,7 +386,6 @@ void Slider::ImplDraw( sal_uInt16 nDrawFlags ) ImplCalc( sal_False ); ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA; - ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); ControlState nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 ); SliderValue sldValue; @@ -402,11 +399,10 @@ void Slider::ImplDraw( sal_uInt16 nDrawFlags ) if( maThumbRect.IsInside( GetPointerPosPixel() ) ) sldValue.mnThumbState |= CTRL_STATE_ROLLOVER; } - aControlValue.setOptionalVal( (void *)(&sldValue) ); - const Region aCtrlRegion( Rectangle( Point(0,0), GetOutputSizePixel() ) ); + const Rectangle aCtrlRegion( Point(0,0), GetOutputSizePixel() ); bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart, - aCtrlRegion, nState, aControlValue, rtl::OUString() ); + aCtrlRegion, nState, sldValue, rtl::OUString() ); if( bNativeOK ) return; diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 522af98d4d45..36003061f513 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -88,15 +88,12 @@ sal_Bool ImplDrawNativeSpinfield( Window *pWin, const SpinbuttonValue& rSpinbutt // there is just no useful native support for spinfields with dropdown !(pWin->GetStyle() & WB_DROPDOWN) ) { - ImplControlValue aControlValue; - aControlValue.setOptionalVal( (void*) &rSpinbuttonValue ); - if( pWin->IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnUpperPart) && pWin->IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnLowerPart) ) { // only paint the embedded spin buttons, all buttons are painted at once - bNativeOK = pWin->DrawNativeControl( CTRL_SPINBOX, PART_ALL_BUTTONS, Region(), CTRL_STATE_ENABLED, - aControlValue, rtl::OUString() ); + bNativeOK = pWin->DrawNativeControl( CTRL_SPINBOX, PART_ALL_BUTTONS, Rectangle(), CTRL_STATE_ENABLED, + rSpinbuttonValue, rtl::OUString() ); } else { @@ -115,17 +112,18 @@ sal_Bool ImplDrawNativeSpinfield( Window *pWin, const SpinbuttonValue& rSpinbutt Point aPt; Size aSize( pBorder->GetOutputSizePixel() ); // the size of the border window, i.e., the whole control - Region aBound, aContent; - Region aNatRgn( Rectangle( aPt, aSize ) ); - if( pBorder->GetNativeControlRegion(CTRL_SPINBOX, PART_ENTIRE_CONTROL, - aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) + Rectangle aBound, aContent; + Rectangle aNatRgn( aPt, aSize ); + if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize && + pBorder->GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL, + aNatRgn, 0, rSpinbuttonValue, rtl::OUString(), aBound, aContent) ) { - aSize = aContent.GetBoundRect().GetSize(); + aSize = aContent.GetSize(); } - Region aRgn( Rectangle( aPt, aSize ) ); + Rectangle aRgn( aPt, aSize ); bNativeOK = pBorder->DrawNativeControl( CTRL_SPINBOX, PART_ENTIRE_CONTROL, aRgn, CTRL_STATE_ENABLED, - aControlValue, rtl::OUString() ); + rSpinbuttonValue, rtl::OUString() ); pBorder->SetClipRegion( oldRgn ); } @@ -139,12 +137,9 @@ sal_Bool ImplDrawNativeSpinbuttons( Window *pWin, const SpinbuttonValue& rSpinbu if( pWin->IsNativeControlSupported(CTRL_SPINBUTTONS, PART_ENTIRE_CONTROL) ) { - ImplControlValue aControlValue; - aControlValue.setOptionalVal( (void*) &rSpinbuttonValue ); - // only paint the standalone spin buttons, all buttons are painted at once - bNativeOK = pWin->DrawNativeControl( CTRL_SPINBUTTONS, PART_ALL_BUTTONS, Region(), CTRL_STATE_ENABLED, - aControlValue, rtl::OUString() ); + bNativeOK = pWin->DrawNativeControl( CTRL_SPINBUTTONS, PART_ALL_BUTTONS, Rectangle(), CTRL_STATE_ENABLED, + rSpinbuttonValue, rtl::OUString() ); } return bNativeOK; } @@ -705,7 +700,7 @@ void SpinField::ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rec nBottom1--; sal_Bool bNativeRegionOK = sal_False; - Region aContentUp, aContentDown; + Rectangle aContentUp, aContentDown; if ( (pDev->GetOutDevType() == OUTDEV_WINDOW) && // there is just no useful native support for spinfields with dropdown @@ -717,11 +712,11 @@ void SpinField::ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rec // get the system's spin button size ImplControlValue aControlValue; - Region aBound; + Rectangle aBound; Point aPoint; // use the full extent of the control - Region aArea( Rectangle( aPoint, pBorder->GetOutputSizePixel() ) ); + Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); bNativeRegionOK = pWin->GetNativeControlRegion(CTRL_SPINBOX, PART_BUTTON_UP, @@ -740,8 +735,8 @@ void SpinField::ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rec if( bNativeRegionOK ) { - rSpinUpArea = aContentUp.GetBoundRect(); - rSpinDownArea = aContentDown.GetBoundRect(); + rSpinUpArea = aContentUp; + rSpinDownArea = aContentDown; } else { @@ -774,11 +769,11 @@ void SpinField::Resize() ImplControlValue aControlValue; Point aPoint; - Region aContent, aBound; + Rectangle aContent, aBound; // use the full extent of the control Window *pBorder = GetWindow( WINDOW_BORDER ); - Region aArea( Rectangle(aPoint, pBorder->GetOutputSizePixel()) ); + Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); // adjust position and size of the edit field if ( GetNativeControlRegion(CTRL_SPINBOX, PART_SUB_EDIT, @@ -789,10 +784,9 @@ void SpinField::Resize() aContent.Move(-aPoint.X(), -aPoint.Y()); // use the themes drop down size - Rectangle aContentRect = aContent.GetBoundRect(); - mpEdit->SetPosPixel( aContentRect.TopLeft() ); + mpEdit->SetPosPixel( aContent.TopLeft() ); bSubEditPositioned = true; - aSize = aContentRect.GetSize(); + aSize = aContent.GetSize(); } else { diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 7f4afb197cbe..858726778880 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -42,7 +42,6 @@ #include "vcl/controldata.hxx" #include "vcl/sound.hxx" #include "vcl/lstbox.hxx" -#include "vcl/smartid.hxx" #include "vcl/window.h" @@ -59,7 +58,7 @@ struct ImplTabItem String maText; String maFormatText; String maHelpText; - sal_uIntPtr mnHelpId; + rtl::OString maHelpId; Rectangle maRect; sal_uInt16 mnLine; bool mbFullVisible; @@ -67,7 +66,7 @@ struct ImplTabItem Image maTabImage; ImplTabItem() - : mnId( 0 ), mnTabPageResId( 0 ), mpTabPage( NULL ), mnHelpId( 0 ), + : mnId( 0 ), mnTabPageResId( 0 ), mpTabPage( NULL ), mnLine( 0 ), mbFullVisible( sal_False ), mbEnabled( true ) {} }; @@ -151,7 +150,6 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) mbRestoreUnqId = sal_False; mbSingleLine = sal_False; mbScroll = sal_False; - mbRestoreSmartId = sal_False; mbSmallInvalidate = sal_False; mbExtraSpace = sal_False; mpTabCtrlData = new ImplTabCtrlData; @@ -411,15 +409,14 @@ Size TabControl::ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ) aSize.Width() += TAB_TABOFFSET_X*2; aSize.Height() += TAB_TABOFFSET_Y*2; - Region aCtrlRegion( Rectangle( (const Point&)Point( 0, 0 ), aSize ) ); - Region aBoundingRgn, aContentRgn; - const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + Rectangle aCtrlRegion( Point( 0, 0 ), aSize ); + Rectangle aBoundingRgn, aContentRgn; + const ImplControlValue aControlValue; if(GetNativeControlRegion( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aCont(aContentRgn.GetBoundRect()); - return aCont.GetSize(); + return aContentRgn.GetSize(); } // For systems without synthetic bold support @@ -706,11 +703,9 @@ void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ) if ( pOldPage ) { if ( mbRestoreHelpId ) - pCtrlParent->SetHelpId( 0 ); + pCtrlParent->SetHelpId( rtl::OString() ); if ( mbRestoreUnqId ) - pCtrlParent->SetUniqueId( 0 ); - if( mbRestoreSmartId ) - pCtrlParent->SetSmartHelpId( SmartId() ); + pCtrlParent->SetUniqueId( rtl::OString() ); pOldPage->DeactivatePage(); } @@ -720,21 +715,16 @@ void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ) // activate page here so the conbtrols can be switched // also set the help id of the parent window to that of the tab page - if ( !GetHelpId() ) + if ( !GetHelpId().getLength() ) { mbRestoreHelpId = sal_True; pCtrlParent->SetHelpId( pPage->GetHelpId() ); } - if ( !pCtrlParent->GetUniqueId() ) + if ( !pCtrlParent->GetUniqueId().getLength() ) { mbRestoreUnqId = sal_True; pCtrlParent->SetUniqueId( pPage->GetUniqueId() ); } - if( ! GetSmartHelpId().HasAny() ) - { - mbRestoreSmartId = sal_True; - pCtrlParent->SetSmartHelpId( pPage->GetSmartHelpId() ); - } pPage->ActivatePage(); @@ -938,8 +928,7 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo if( !bLayout && (bNativeOK = IsNativeControlSupported(CTRL_TAB_ITEM, PART_ENTIRE_CONTROL)) == sal_True ) { - ImplControlValue aControlValue; - Region aCtrlRegion( pItem->maRect ); + Rectangle aCtrlRegion( pItem->maRect ); ControlState nState = 0; if( pItem->mnId == mnCurPageId ) @@ -974,10 +963,9 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo tiValue.mnAlignment |= TABITEM_FIRST_IN_GROUP; if ( bLastInGroup ) tiValue.mnAlignment |= TABITEM_LAST_IN_GROUP; - aControlValue.setOptionalVal( (void *)(&tiValue) ); bNativeOK = DrawNativeControl( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL, aCtrlRegion, nState, - aControlValue, rtl::OUString() ); + tiValue, rtl::OUString() ); } if( ! bLayout && !bNativeOK ) @@ -1236,7 +1224,7 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout ) sal_Bool bNativeOK = sal_False; if( ! bLayout && (bNativeOK = IsNativeControlSupported( CTRL_TAB_PANE, PART_ENTIRE_CONTROL) ) == sal_True ) { - const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + const ImplControlValue aControlValue; ControlState nState = CTRL_STATE_ENABLED; int part = PART_ENTIRE_CONTROL; @@ -1250,10 +1238,8 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout ) if( !rRect.IsEmpty() ) aClipRgn.Intersect( rRect ); - Region aCtrlRegion( aRect ); - Rectangle aClipRect( aClipRgn.GetBoundRect() ); - if( !aClipRgn.IsEmpty() ) //&& aClipRect.getHeight() && aClipRect.getWidth() ) - bNativeOK = DrawNativeControl( CTRL_TAB_PANE, part, aCtrlRegion, nState, + if( !aClipRgn.IsEmpty() ) + bNativeOK = DrawNativeControl( CTRL_TAB_PANE, part, aRect, nState, aControlValue, rtl::OUString() ); } else @@ -1491,13 +1477,13 @@ void TabControl::RequestHelp( const HelpEvent& rHEvt ) } else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { - sal_uIntPtr nHelpId = GetHelpId( nItemId ); - if ( nHelpId ) + rtl::OUString aHelpId( rtl::OStringToOUString( GetHelpId( nItemId ), RTL_TEXTENCODING_UTF8 ) ); + if ( aHelpId.getLength() ) { // Wenn eine Hilfe existiert, dann ausloesen Help* pHelp = Application::GetHelp(); if ( pHelp ) - pHelp->Start( nHelpId, this ); + pHelp->Start( aHelpId, this ); return; } } @@ -1579,7 +1565,7 @@ void TabControl::Command( const CommandEvent& rCEvt ) aMenu.InsertItem( it->mnId, it->maText, MIB_CHECKABLE | MIB_RADIOCHECK ); if ( it->mnId == mnCurPageId ) aMenu.CheckItem( it->mnId ); - aMenu.SetHelpId( it->mnId, it->mnHelpId ); + aMenu.SetHelpId( it->mnId, it->maHelpId ); } sal_uInt16 nId = aMenu.Execute( this, aMenuPos ); @@ -1831,7 +1817,6 @@ void TabControl::InsertPage( sal_uInt16 nPageId, const XubString& rText, pItem->mnId = nPageId; pItem->mpTabPage = NULL; pItem->mnTabPageResId = 0; - pItem->mnHelpId = 0; pItem->maText = rText; pItem->mbFullVisible = sal_False; @@ -2159,11 +2144,11 @@ const XubString& TabControl::GetHelpText( sal_uInt16 nPageId ) const if ( pItem ) { - if ( !pItem->maHelpText.Len() && pItem->mnHelpId ) + if ( !pItem->maHelpText.Len() && pItem->maHelpId.getLength() ) { Help* pHelp = Application::GetHelp(); if ( pHelp ) - pItem->maHelpText = pHelp->GetHelpText( pItem->mnHelpId, this ); + pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this ); } return pItem->maHelpText; @@ -2174,24 +2159,25 @@ const XubString& TabControl::GetHelpText( sal_uInt16 nPageId ) const // ----------------------------------------------------------------------- -void TabControl::SetHelpId( sal_uInt16 nPageId, sal_uIntPtr nHelpId ) +void TabControl::SetHelpId( sal_uInt16 nPageId, const rtl::OString& rHelpId ) { ImplTabItem* pItem = ImplGetItem( nPageId ); if ( pItem ) - pItem->mnHelpId = nHelpId; + pItem->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -sal_uIntPtr TabControl::GetHelpId( sal_uInt16 nPageId ) const +rtl::OString TabControl::GetHelpId( sal_uInt16 nPageId ) const { + rtl::OString aRet; ImplTabItem* pItem = ImplGetItem( nPageId ); if ( pItem ) - return pItem->mnHelpId; - else - return 0; + aRet = pItem->maHelpId; + + return aRet; } // ----------------------------------------------------------------------- diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 04e53960b6fa..c94aad3cbab6 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1397,6 +1397,7 @@ static void FindCmap(TrueTypeFont *ttf) sal_uInt32 table_size = getTableSize(ttf, O_cmap); sal_uInt16 ncmaps = GetUInt16(table, 2, 1); unsigned int i; + sal_uInt32 AppleUni = 0; // Apple Unicode sal_uInt32 ThreeZero = 0; /* MS Symbol */ sal_uInt32 ThreeOne = 0; /* MS UCS-2 */ sal_uInt32 ThreeTwo = 0; /* MS ShiftJIS */ @@ -1423,7 +1424,7 @@ static void FindCmap(TrueTypeFont *ttf) /* Unicode tables in Apple fonts */ if (pID == 0) { - ThreeOne = offset; break; + AppleUni = offset; } if (pID == 3) { @@ -1440,6 +1441,10 @@ static void FindCmap(TrueTypeFont *ttf) } } + // fall back to AppleUnicode if there are no ThreeOne/Threezero tables + if( AppleUni && !ThreeZero && !ThreeOne) + ThreeOne = AppleUni; + if (ThreeOne) { ttf->cmapType = CMAP_MS_Unicode; ttf->cmap = table + ThreeOne; diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 26380c63ccc2..01ec9ae85126 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -961,8 +961,8 @@ sal_Bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) const long nScanlineSize = pWriteAcc->GetScanlineSize(); const long nNewWidth1 = nNewWidth - 1L; const long nNewHeight1 = nNewHeight - 1L; - const long nWidth1 = pReadAcc->Width() - 1L; - const long nHeight1 = pReadAcc->Height() - 1L; + const long nWidth = pReadAcc->Width(); + const long nHeight = pReadAcc->Height(); long* pLutX = new long[ nNewWidth ]; long* pLutY = new long[ nNewHeight ]; long nX, nY, nMapY, nActY = 0L; @@ -970,10 +970,10 @@ sal_Bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) if( nNewWidth1 && nNewHeight1 ) { for( nX = 0L; nX < nNewWidth; nX++ ) - pLutX[ nX ] = nX * nWidth1 / nNewWidth1; + pLutX[ nX ] = nX * nWidth / nNewWidth; for( nY = 0L; nY < nNewHeight; nY++ ) - pLutY[ nY ] = nY * nHeight1 / nNewHeight1; + pLutY[ nY ] = nY * nHeight / nNewHeight; while( nActY < nNewHeight ) { diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index c916bc8481aa..9d7e51c44b96 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -841,6 +841,49 @@ void GDIMetaFile::Move( long nX, long nY ) } } +void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) +{ + const Size aBaseOffset( nX, nY ); + Size aOffset( aBaseOffset ); + VirtualDevice aMapVDev; + + aMapVDev.EnableOutput( sal_False ); + aMapVDev.SetReferenceDevice( nDPIX, nDPIY ); + aMapVDev.SetMapMode( GetPrefMapMode() ); + + for( MetaAction* pAct = (MetaAction*) First(); pAct; pAct = (MetaAction*) Next() ) + { + const long nType = pAct->GetType(); + MetaAction* pModAct; + + if( pAct->GetRefCount() > 1 ) + { + Replace( pModAct = pAct->Clone(), GetCurPos() ); + pAct->Delete(); + } + else + pModAct = pAct; + + if( ( META_MAPMODE_ACTION == nType ) || + ( META_PUSH_ACTION == nType ) || + ( META_POP_ACTION == nType ) ) + { + pModAct->Execute( &aMapVDev ); + if( aMapVDev.GetMapMode().GetMapUnit() == MAP_PIXEL ) + { + aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() ); + MapMode aMap( aMapVDev.GetMapMode() ); + aOffset.Width() = static_cast<long>(aOffset.Width() * (double)aMap.GetScaleX()); + aOffset.Height() = static_cast<long>(aOffset.Height() * (double)aMap.GetScaleY()); + } + else + aOffset = aMapVDev.LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() ); + } + + pModAct->Move( aOffset.Width(), aOffset.Height() ); + } +} + // ------------------------------------------------------------------------ void GDIMetaFile::Scale( double fScaleX, double fScaleY ) diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx index 489ef3833935..1a3c4954834a 100644 --- a/vcl/source/gdi/gfxlink.cxx +++ b/vcl/source/gdi/gfxlink.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include <osl/file.h> #include <tools/vcompat.hxx> #include <tools/urlobj.hxx> #include <tools/debug.hxx> @@ -398,12 +399,10 @@ ImpSwap::ImpSwap( sal_uInt8* pData, sal_uIntPtr nDataSize ) : { ::utl::TempFile aTempFile; - maURL = INetURLObject(aTempFile.GetURL()); - - if( maURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) + maURL = aTempFile.GetURL(); + if( maURL.getLength() ) { - SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( maURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); - + SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); if( pOStm ) { pOStm->Write( pData, mnDataSize ); @@ -412,28 +411,8 @@ ImpSwap::ImpSwap( sal_uInt8* pData, sal_uIntPtr nDataSize ) : if( bError ) { - try - { - ::ucbhelper::Content aCnt( maURL.GetMainURL( INetURLObject::NO_DECODE ), - ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() ); - - aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ), - ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) ); - } - catch( const ::com::sun::star::ucb::ContentCreationException& ) - { - } - catch( const ::com::sun::star::uno::RuntimeException& ) - { - } - catch( const ::com::sun::star::ucb::CommandAbortedException& ) - { - } - catch( const ::com::sun::star::uno::Exception& ) - { - } - - maURL = INetURLObject(); + osl_removeFile( maURL.pData ); + maURL = String(); } } } @@ -445,28 +424,7 @@ ImpSwap::ImpSwap( sal_uInt8* pData, sal_uIntPtr nDataSize ) : ImpSwap::~ImpSwap() { if( IsSwapped() ) - { - try - { - ::ucbhelper::Content aCnt( maURL.GetMainURL( INetURLObject::NO_DECODE ), - ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() ); - - aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ), - ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) ); - } - catch( const ::com::sun::star::ucb::ContentCreationException& ) - { - } - catch( const ::com::sun::star::uno::RuntimeException& ) - { - } - catch( const ::com::sun::star::ucb::CommandAbortedException& ) - { - } - catch( const ::com::sun::star::uno::Exception& ) - { - } - } + osl_removeFile( maURL.pData ); } // ------------------------------------------------------------------------ @@ -477,8 +435,7 @@ sal_uInt8* ImpSwap::GetData() const if( IsSwapped() ) { - SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE ); - + SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE ); if( pIStm ) { pData = new sal_uInt8[ mnDataSize ]; diff --git a/vcl/source/gdi/imgcons.cxx b/vcl/source/gdi/imgcons.cxx deleted file mode 100644 index 30148b85734e..000000000000 --- a/vcl/source/gdi/imgcons.cxx +++ /dev/null @@ -1,574 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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_vcl.hxx" - -#include <tools/stream.hxx> -#include <vcl/bmpacc.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/image.hxx> -#include <vcl/imgcons.hxx> - -// ------------------- -// - ImplColorMapper - -// ------------------- - -class ImplColorMapper -{ - Color maCol; - sal_uIntPtr mnR; - sal_uIntPtr mnG; - sal_uIntPtr mnB; - sal_uIntPtr mnT; - sal_uIntPtr mnRShift; - sal_uIntPtr mnGShift; - sal_uIntPtr mnBShift; - sal_uIntPtr mnTShift; - - sal_uIntPtr ImplCalcMaskShift( sal_uIntPtr nVal ); - -public: - - ImplColorMapper( sal_uIntPtr nRMask, sal_uIntPtr nGMask, sal_uIntPtr nBMask, sal_uIntPtr nTMask ); - ~ImplColorMapper(); - - const Color& ImplGetColor( sal_uIntPtr nColor ) - { - maCol.SetRed( (sal_uInt8) ( ( nColor & mnR ) >> mnRShift ) ); - maCol.SetGreen( (sal_uInt8) ( ( nColor & mnG ) >> mnGShift ) ); - maCol.SetBlue( (sal_uInt8) ( ( nColor & mnB ) >> mnBShift ) ); - maCol.SetTransparency( (sal_uInt8) ( ( nColor & mnT ) >> mnTShift ) ); - return maCol; - } -}; - -// ----------------------------------------------------------------------------- - -ImplColorMapper::ImplColorMapper( sal_uIntPtr nRMask, sal_uIntPtr nGMask, sal_uIntPtr nBMask, sal_uIntPtr nTMask ) : - mnR( nRMask ), - mnG( nGMask ), - mnB( nBMask ), - mnT( nTMask ) -{ - mnRShift = ImplCalcMaskShift( mnR ); - mnGShift = ImplCalcMaskShift( mnG ); - mnBShift = ImplCalcMaskShift( mnB ); - mnTShift = ImplCalcMaskShift( mnT ); -} - -// ----------------------------------------------------------------------------- - -ImplColorMapper::~ImplColorMapper() -{ -} - -// ----------------------------------------------------------------------------- - -sal_uIntPtr ImplColorMapper::ImplCalcMaskShift( sal_uIntPtr nVal ) -{ - DBG_ASSERT( nVal > 0, "Mask has no value!" ); - - sal_uIntPtr nRet = 0UL; - - for( sal_uIntPtr i = 0UL; i < 32; i++ ) - { - if( nVal & ( 1UL << i ) ) - { - nRet = i; - break; - } - } - - return nRet; -} - -// ----------------- -// - ImageConsumer - -// ----------------- - -ImageConsumer::ImageConsumer() : - mpMapper( NULL ), - mpPal ( NULL ), - mnStatus( 0UL ), - mbTrans ( sal_False ) -{ -} - -// ----------------------------------------------------------------------------- - -ImageConsumer::~ImageConsumer() -{ - delete[] mpPal; - delete mpMapper; -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::Init( sal_uInt32 nWidth, sal_uInt32 nHeight ) -{ - maSize = Size( nWidth, nHeight ); - maBitmap = maMask = Bitmap(); - mnStatus = 0UL; - mbTrans = sal_False; -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::SetColorModel( sal_uInt16 nBitCount, - sal_uInt32 nPalEntries, const sal_uInt32* pRGBAPal, - sal_uInt32 nRMask, sal_uInt32 nGMask, sal_uInt32 nBMask, sal_uInt32 nAMask ) -{ - DBG_ASSERT( maSize.Width() && maSize.Height(), "Missing call to ImageConsumer::Init(...)!" ); - - BitmapPalette aPal( Min( (sal_uInt16) nPalEntries, (sal_uInt16) 256 ) ); - - if( nPalEntries ) - { - BitmapColor aCol; - const sal_Int32* pTmp = (sal_Int32*) pRGBAPal; - - delete mpMapper; - mpMapper = NULL; - - delete[] mpPal; - mpPal = new Color[ nPalEntries ]; - - for( sal_uIntPtr i = 0; i < nPalEntries; i++, pTmp++ ) - { - Color& rCol = mpPal[ i ]; - sal_uInt8 cVal; - - cVal = (sal_uInt8) ( ( *pTmp & 0xff000000UL ) >> 24L ); - rCol.SetRed( cVal ); - - if( i < (sal_uIntPtr) aPal.GetEntryCount() ) - aPal[ (sal_uInt16) i ].SetRed( cVal ); - - cVal = (sal_uInt8) ( ( *pTmp & 0x00ff0000UL ) >> 16L ); - rCol.SetGreen( cVal ); - - if( i < (sal_uIntPtr) aPal.GetEntryCount() ) - aPal[ (sal_uInt16) i ].SetGreen( cVal ); - - cVal = (sal_uInt8) ( ( *pTmp & 0x0000ff00UL ) >> 8L ); - rCol.SetBlue( cVal ); - - if( i < (sal_uIntPtr) aPal.GetEntryCount() ) - aPal[ (sal_uInt16) i ].SetBlue( cVal ); - - rCol.SetTransparency( (sal_uInt8) ( ( *pTmp & 0x000000ffL ) ) ); - } - - if( nBitCount <= 1 ) - nBitCount = 1; - else if( nBitCount <= 4 ) - nBitCount = 4; - else if( nBitCount <= 8 ) - nBitCount = 8; - else - nBitCount = 24; - } - else - { - delete mpMapper; - mpMapper = new ImplColorMapper( nRMask, nGMask, nBMask, nAMask ); - - delete[] mpPal; - mpPal = NULL; - - nBitCount = 24; - } - - if( !maBitmap ) - { - - maBitmap = Bitmap( maSize, nBitCount, &aPal ); - maMask = Bitmap( maSize, 1 ); - maMask.Erase( COL_BLACK ); - mbTrans = sal_False; - } -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::SetPixelsByBytes( sal_uInt32 nConsX, sal_uInt32 nConsY, - sal_uInt32 nConsWidth, sal_uInt32 nConsHeight, - const sal_uInt8* pData, sal_uInt32 nOffset, sal_uInt32 nScanSize ) -{ - DBG_ASSERT( !!maBitmap && !!maMask, "Missing call to ImageConsumer::SetColorModel(...)!" ); - - BitmapWriteAccess* pBmpAcc = maBitmap.AcquireWriteAccess(); - BitmapWriteAccess* pMskAcc = maMask.AcquireWriteAccess(); - sal_Bool bDataChanged = sal_False; - - if( pBmpAcc && pMskAcc ) - { - const long nWidth = pBmpAcc->Width(); - const long nHeight = pBmpAcc->Height(); - - maChangedRect = Rectangle( Point(), Size( nWidth, nHeight ) ); - maChangedRect.Intersection( Rectangle( Point( nConsX, nConsY ), Size( nConsWidth, nConsHeight ) ) ); - - if( !maChangedRect.IsEmpty() ) - { - const long nStartX = maChangedRect.Left(); - const long nEndX = maChangedRect.Right(); - const long nStartY = maChangedRect.Top(); - const long nEndY = maChangedRect.Bottom(); - - if( mpMapper && ( pBmpAcc->GetBitCount() > 8 ) ) - { - BitmapColor aCol; - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_uInt8* pTmp = pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const Color& rCol = mpMapper->ImplGetColor( *pTmp++ ); - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aCol.SetRed( rCol.GetRed() ); - aCol.SetGreen( rCol.GetGreen() ); - aCol.SetBlue( rCol.GetBlue() ); - pBmpAcc->SetPixel( nY, nX, aCol ); - } - } - } - - bDataChanged = sal_True; - } - else if( mpPal && ( pBmpAcc->GetBitCount() <= 8 ) ) - { - BitmapColor aIndex( (sal_uInt8) 0 ); - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_uInt8* pTmp = pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const sal_uInt8 cIndex = *pTmp++; - const Color& rCol = mpPal[ cIndex ]; - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aIndex.SetIndex( cIndex ); - pBmpAcc->SetPixel( nY, nX, aIndex ); - } - } - } - - bDataChanged = sal_True; - } - else if( mpPal && ( pBmpAcc->GetBitCount() > 8 ) ) - { - BitmapColor aCol; - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_uInt8* pTmp = pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const sal_uInt8 cIndex = *pTmp++; - const Color& rCol = mpPal[ cIndex ]; - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aCol.SetRed( rCol.GetRed() ); - aCol.SetGreen( rCol.GetGreen() ); - aCol.SetBlue( rCol.GetBlue() ); - pBmpAcc->SetPixel( nY, nX, aCol ); - } - } - } - - bDataChanged = sal_True; - } - else - { - DBG_ERROR( "Producer format error!" ); - maChangedRect.SetEmpty(); - } - } - } - else - maChangedRect.SetEmpty(); - - maBitmap.ReleaseAccess( pBmpAcc ); - maMask.ReleaseAccess( pMskAcc ); - - if( bDataChanged ) - DataChanged(); -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::SetPixelsByLongs( sal_uInt32 nConsX, sal_uInt32 nConsY, - sal_uInt32 nConsWidth, sal_uInt32 nConsHeight, - const sal_uInt32* pData, sal_uInt32 nOffset, sal_uInt32 nScanSize ) -{ - DBG_ASSERT( !!maBitmap && !!maMask, "Missing call to ImageConsumer::SetColorModel(...)!" ); - - BitmapWriteAccess* pBmpAcc = maBitmap.AcquireWriteAccess(); - BitmapWriteAccess* pMskAcc = maMask.AcquireWriteAccess(); - sal_Bool bDataChanged = sal_False; - - if( pBmpAcc && pMskAcc ) - { - const long nWidth = pBmpAcc->Width(); - const long nHeight = pBmpAcc->Height(); - - maChangedRect = Rectangle( Point(), Size( nWidth, nHeight ) ); - maChangedRect.Intersection( Rectangle( Point( nConsX, nConsY ), Size( nConsWidth, nConsHeight ) ) ); - - if( !maChangedRect.IsEmpty() ) - { - const long nStartX = maChangedRect.Left(); - const long nEndX = maChangedRect.Right(); - const long nStartY = maChangedRect.Top(); - const long nEndY = maChangedRect.Bottom(); - - if( mpMapper && ( pBmpAcc->GetBitCount() > 8 ) ) - { - BitmapColor aCol; - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_Int32* pTmp = (sal_Int32*) pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const Color& rCol = mpMapper->ImplGetColor( *pTmp++ ); - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aCol.SetRed( rCol.GetRed() ); - aCol.SetGreen( rCol.GetGreen() ); - aCol.SetBlue( rCol.GetBlue() ); - pBmpAcc->SetPixel( nY, nX, aCol ); - } - } - } - - bDataChanged = sal_True; - } - else if( mpPal && ( pBmpAcc->GetBitCount() <= 8 ) ) - { - BitmapColor aIndex( (sal_uInt8) 0 ); - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_Int32* pTmp = (sal_Int32*) pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const sal_Int32 nIndex = *pTmp++; - const Color& rCol = mpPal[ nIndex ]; - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aIndex.SetIndex( (sal_uInt8) nIndex ); - pBmpAcc->SetPixel( nY, nX, aIndex ); - } - } - } - - bDataChanged = sal_True; - } - else if( mpPal && ( pBmpAcc->GetBitCount() > 8 ) ) - { - BitmapColor aCol; - BitmapColor aMskWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) ); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - const sal_Int32* pTmp = (sal_Int32*) pData + ( nY - nStartY ) * nScanSize + nOffset; - - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - const sal_Int32 nIndex = *pTmp++; - const Color& rCol = mpPal[ nIndex ]; - - // 0: Transparent; >0: Non-Transparent - if( !rCol.GetTransparency() ) - { - pMskAcc->SetPixel( nY, nX, aMskWhite ); - mbTrans = sal_True; - } - else - { - aCol.SetRed( rCol.GetRed() ); - aCol.SetGreen( rCol.GetGreen() ); - aCol.SetBlue( rCol.GetBlue() ); - pBmpAcc->SetPixel( nY, nX, aCol ); - } - } - } - - bDataChanged = sal_True; - } - else - { - DBG_ERROR( "Producer format error!" ); - maChangedRect.SetEmpty(); - } - } - } - else - maChangedRect.SetEmpty(); - - maBitmap.ReleaseAccess( pBmpAcc ); - maMask.ReleaseAccess( pMskAcc ); - - if( bDataChanged ) - DataChanged(); -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::Completed( sal_uInt32 nStatus /*, ImageProducer& rProducer */ ) -{ - delete mpMapper; - mpMapper = NULL; - delete[] mpPal; - mpPal = NULL; - maSize = Size(); - mnStatus = nStatus; - - switch( nStatus ) - { - case( SINGLEFRAMEDONE ): - case( STATICIMAGEDONE ): - { - if( !mbTrans ) - maMask = Bitmap(); - } - break; - - case( IMAGEERROR ): - case( IMAGEABORTED ): - maBitmap = maMask = Bitmap(); - break; - - default: - break; - } - -// rProducer.RemoveConsumer( *this ); - - if( maDoneLink.IsSet() ) - maDoneLink.Call( this ); -} - -// ----------------------------------------------------------------------------- - -void ImageConsumer::DataChanged() -{ - if( maChgLink.IsSet() ) - maChgLink.Call( this ); -} - -// ----------------------------------------------------------------------------- - -sal_uInt32 ImageConsumer::GetStatus() const -{ - return mnStatus; -} - -// ----------------------------------------------------------------------------- - -sal_Bool ImageConsumer::GetData( BitmapEx& rBmpEx ) const -{ - const sal_Bool bRet = ( SINGLEFRAMEDONE == mnStatus || STATICIMAGEDONE == mnStatus ); - - if( bRet ) - { - if( !!maMask ) - rBmpEx = BitmapEx( maBitmap, maMask ); - else - rBmpEx = BitmapEx( maBitmap ); - } - - return bRet; -} - -// ----------------------------------------------------------------------------- - -sal_Bool ImageConsumer::GetData( Image& rImage ) const -{ - const sal_Bool bRet = ( SINGLEFRAMEDONE == mnStatus || STATICIMAGEDONE == mnStatus ); - - if( bRet ) - { - if( !!maMask ) - rImage = Image( maBitmap, maMask ); - else - rImage = Image( maBitmap ); - } - - return bRet; -} diff --git a/vcl/source/gdi/impimage.cxx b/vcl/source/gdi/impimage.cxx index 4fb91beefb01..2632d0f55460 100644 --- a/vcl/source/gdi/impimage.cxx +++ b/vcl/source/gdi/impimage.cxx @@ -553,14 +553,14 @@ void ImplImageBmp::Draw( sal_uInt16 nPos, OutputDevice* pOutDev, // ----------------------------------------------------------------------- void ImplImageBmp::ImplUpdateDisplayBmp( OutputDevice* -#if defined WIN || defined WNT +#if defined WNT pOutDev #endif ) { if( !mpDisplayBmp && !maBmpEx.IsEmpty() ) { -#if defined WIN || defined WNT +#if defined WNT if( maBmpEx.IsAlpha() ) mpDisplayBmp = new BitmapEx( maBmpEx ); else diff --git a/vcl/source/gdi/impprn.cxx b/vcl/source/gdi/impprn.cxx deleted file mode 100644 index dad8c5c9be3f..000000000000 --- a/vcl/source/gdi/impprn.cxx +++ /dev/null @@ -1,584 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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_vcl.hxx" - -#define _SPOOLPRINTER_EXT -#include "tools/queue.hxx" -#include "vcl/svapp.hxx" -#include "vcl/metaact.hxx" -#include "vcl/gdimtf.hxx" -#include "vcl/timer.hxx" -#include "vcl/impprn.hxx" -#include "vcl/jobset.h" - -#include "vcl/svdata.hxx" -#include "vcl/salprn.hxx" - -// ----------- -// - Defines - -// ----------- - -#define OPTIMAL_BMP_RESOLUTION 300 -#define NORMAL_BMP_RESOLUTION 200 - -// ======================================================================= - -struct QueuePage -{ - GDIMetaFile* mpMtf; - JobSetup* mpSetup; - sal_uInt16 mnPage; - sal_Bool mbEndJob; - - QueuePage() { mpMtf = NULL; mpSetup = NULL; } - ~QueuePage() { delete mpMtf; if ( mpSetup ) delete mpSetup; } -}; - -// ======================================================================= - -ImplQPrinter::ImplQPrinter( Printer* pParent ) : - Printer( pParent->GetName() ), - mpParent( pParent ), - mbAborted( false ), - mbUserCopy( false ), - mbDestroyAllowed( true ), - mbDestroyed( false ), - mnMaxBmpDPIX( mnDPIX ), - mnMaxBmpDPIY( mnDPIY ), - mnCurCopyCount( 0 ) -{ - SetSelfAsQueuePrinter( sal_True ); - SetPrinterProps( pParent ); - SetPageQueueSize( 0 ); - mnCopyCount = pParent->mnCopyCount; - mbCollateCopy = pParent->mbCollateCopy; -} - -// ----------------------------------------------------------------------- - -ImplQPrinter::~ImplQPrinter() -{ - for( std::vector< QueuePage* >::iterator it = maQueue.begin(); - it != maQueue.end(); ++it ) - delete (*it); -} - -// ----------------------------------------------------------------------------- - -void ImplQPrinter::Destroy() -{ - if( mbDestroyAllowed ) - delete this; - else - mbDestroyed = sal_True; -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::ImplPrintMtf( GDIMetaFile& rPrtMtf, long nMaxBmpDPIX, long nMaxBmpDPIY ) -{ - for( MetaAction* pAct = rPrtMtf.FirstAction(); pAct && !mbAborted; pAct = rPrtMtf.NextAction() ) - { - const sal_uIntPtr nType = pAct->GetType(); - sal_Bool bExecuted = sal_False; - - if( nType == META_COMMENT_ACTION ) - { - // search for special comments ( ..._BEGIN/..._END ) - MetaCommentAction* pComment = (MetaCommentAction*) pAct; - - if( pComment->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) - { - pAct = rPrtMtf.NextAction(); - - // if next action is a GradientEx action, execute this and - // skip actions until a XGRAD_SEQ_END comment is found - if( pAct && ( pAct->GetType() == META_GRADIENTEX_ACTION ) ) - { - MetaGradientExAction* pGradientExAction = (MetaGradientExAction*) pAct; - DrawGradientEx( this, pGradientExAction->GetPolyPolygon(), pGradientExAction->GetGradient() ); - - // seek to end of this comment - do - { - pAct = rPrtMtf.NextAction(); - } - while( pAct && - ( ( pAct->GetType() != META_COMMENT_ACTION ) || - ( ( (MetaCommentAction*) pAct )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) != COMPARE_EQUAL ) ) ); - - bExecuted = sal_True; - } - } - else if( pComment->GetComment().CompareIgnoreCaseToAscii( "PRNSPOOL_TRANSPARENTBITMAP_BEGIN" ) == COMPARE_EQUAL ) - { - pAct = rPrtMtf.NextAction(); - - if( pAct && ( pAct->GetType() == META_BMPSCALE_ACTION ) ) - { - // execute action here to avoid DPI processing of bitmap; - pAct->Execute( this ); - -#ifdef VERBOSE_DEBUG - Push(); - SetLineColor(COL_RED); - SetFillColor(); - DrawRect( Rectangle( - static_cast<MetaBmpScaleAction*>(pAct)->GetPoint(), - static_cast<MetaBmpScaleAction*>(pAct)->GetSize()) ); - Pop(); -#endif - - // seek to end of this comment - do - { - pAct = rPrtMtf.NextAction(); - } - while( pAct && - ( ( pAct->GetType() != META_COMMENT_ACTION ) || - ( ( (MetaCommentAction*) pAct )->GetComment().CompareIgnoreCaseToAscii( "PRNSPOOL_TRANSPARENTBITMAP_END" ) != COMPARE_EQUAL ) ) ); - - bExecuted = sal_True; - } - } - } - else if( nType == META_GRADIENT_ACTION ) - { - MetaGradientAction* pGradientAction = (MetaGradientAction*) pAct; - DrawGradientEx( this, pGradientAction->GetRect(), pGradientAction->GetGradient() ); - bExecuted = sal_True; - } - else if( nType == META_BMPSCALE_ACTION ) - { - MetaBmpScaleAction* pBmpScaleAction = (MetaBmpScaleAction*) pAct; - const Bitmap& rBmp = pBmpScaleAction->GetBitmap(); - - DrawBitmap( pBmpScaleAction->GetPoint(), pBmpScaleAction->GetSize(), - GetDownsampledBitmap( pBmpScaleAction->GetSize(), - Point(), rBmp.GetSizePixel(), - rBmp, nMaxBmpDPIX, nMaxBmpDPIY ) ); - - bExecuted = sal_True; - } - else if( nType == META_BMPSCALEPART_ACTION ) - { - MetaBmpScalePartAction* pBmpScalePartAction = (MetaBmpScalePartAction*) pAct; - const Bitmap& rBmp = pBmpScalePartAction->GetBitmap(); - - DrawBitmap( pBmpScalePartAction->GetDestPoint(), pBmpScalePartAction->GetDestSize(), - GetDownsampledBitmap( pBmpScalePartAction->GetDestSize(), - pBmpScalePartAction->GetSrcPoint(), pBmpScalePartAction->GetSrcSize(), - rBmp, nMaxBmpDPIX, nMaxBmpDPIY ) ); - - bExecuted = sal_True; - } - else if( nType == META_BMPEXSCALE_ACTION ) - { - MetaBmpExScaleAction* pBmpExScaleAction = (MetaBmpExScaleAction*) pAct; - const BitmapEx& rBmpEx = pBmpExScaleAction->GetBitmapEx(); - - DrawBitmapEx( pBmpExScaleAction->GetPoint(), pBmpExScaleAction->GetSize(), - GetDownsampledBitmapEx( pBmpExScaleAction->GetSize(), - Point(), rBmpEx.GetSizePixel(), - rBmpEx, nMaxBmpDPIX, nMaxBmpDPIY ) ); - - bExecuted = sal_True; - } - else if( nType == META_BMPEXSCALEPART_ACTION ) - { - MetaBmpExScalePartAction* pBmpExScalePartAction = (MetaBmpExScalePartAction*) pAct; - const BitmapEx& rBmpEx = pBmpExScalePartAction->GetBitmapEx(); - - DrawBitmapEx( pBmpExScalePartAction->GetDestPoint(), pBmpExScalePartAction->GetDestSize(), - GetDownsampledBitmapEx( pBmpExScalePartAction->GetDestSize(), - pBmpExScalePartAction->GetSrcPoint(), pBmpExScalePartAction->GetSrcSize(), - rBmpEx, nMaxBmpDPIX, nMaxBmpDPIY ) ); - - bExecuted = sal_True; - } - else if( nType == META_TRANSPARENT_ACTION ) - { - MetaTransparentAction* pTransAct = static_cast<MetaTransparentAction*>(pAct); - sal_uInt16 nTransparency( pTransAct->GetTransparence() ); - - // #i10613# Respect transparency for draw color - if( nTransparency ) - { - Push( PUSH_LINECOLOR|PUSH_FILLCOLOR ); - - // assume white background for alpha blending - Color aLineColor( GetLineColor() ); - aLineColor.SetRed( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetRed()) / 100L ) ); - aLineColor.SetGreen( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetGreen()) / 100L ) ); - aLineColor.SetBlue( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetBlue()) / 100L ) ); - SetLineColor( aLineColor ); - - Color aFillColor( GetFillColor() ); - aFillColor.SetRed( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aFillColor.GetRed()) / 100L ) ); - aFillColor.SetGreen( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aFillColor.GetGreen()) / 100L ) ); - aFillColor.SetBlue( static_cast<sal_uInt8>( (255L*nTransparency + (100L - nTransparency)*aFillColor.GetBlue()) / 100L ) ); - SetFillColor( aFillColor ); - } - - DrawPolyPolygon( pTransAct->GetPolyPolygon() ); - - if( nTransparency ) - Pop(); - - bExecuted = sal_True; - } - else if( nType == META_FLOATTRANSPARENT_ACTION ) - { - MetaFloatTransparentAction* pFloatAction = (MetaFloatTransparentAction*) pAct; - GDIMetaFile& rMtf = (GDIMetaFile&) pFloatAction->GetGDIMetaFile(); - MapMode aDrawMap( rMtf.GetPrefMapMode() ); - Point aDestPoint( LogicToPixel( pFloatAction->GetPoint() ) ); - Size aDestSize( LogicToPixel( pFloatAction->GetSize() ) ); - - if( aDestSize.Width() && aDestSize.Height() ) - { - Size aTmpPrefSize( LogicToPixel( rMtf.GetPrefSize(), aDrawMap ) ); - - if( !aTmpPrefSize.Width() ) - aTmpPrefSize.Width() = aDestSize.Width(); - - if( !aTmpPrefSize.Height() ) - aTmpPrefSize.Height() = aDestSize.Height(); - - Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() ); - Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() ); - - aDrawMap.SetScaleX( aScaleX *= aDrawMap.GetScaleX() ); - aDrawMap.SetScaleY( aScaleY *= aDrawMap.GetScaleY() ); - aDrawMap.SetOrigin( PixelToLogic( aDestPoint, aDrawMap ) ); - - Push(); - SetMapMode( aDrawMap ); - ImplPrintMtf( rMtf, nMaxBmpDPIX, nMaxBmpDPIY ); - Pop(); - } - - bExecuted = sal_True; - } - - if( !bExecuted && pAct ) - pAct->Execute( this ); - - if( ! ImplGetSVData()->maGDIData.mbPrinterPullModel ) - Application::Reschedule(); - } -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::PrePrintPage( QueuePage* pPage ) -{ - mnRestoreDrawMode = GetDrawMode(); - mnMaxBmpDPIX = mnDPIX; - mnMaxBmpDPIY = mnDPIY; - - const PrinterOptions& rPrinterOptions = GetPrinterOptions(); - - if( rPrinterOptions.IsReduceBitmaps() ) - { - // calculate maximum resolution for bitmap graphics - if( PRINTER_BITMAP_OPTIMAL == rPrinterOptions.GetReducedBitmapMode() ) - { - mnMaxBmpDPIX = Min( (long) OPTIMAL_BMP_RESOLUTION, mnMaxBmpDPIX ); - mnMaxBmpDPIY = Min( (long) OPTIMAL_BMP_RESOLUTION, mnMaxBmpDPIY ); - } - else if( PRINTER_BITMAP_NORMAL == rPrinterOptions.GetReducedBitmapMode() ) - { - mnMaxBmpDPIX = Min( (long) NORMAL_BMP_RESOLUTION, mnMaxBmpDPIX ); - mnMaxBmpDPIY = Min( (long) NORMAL_BMP_RESOLUTION, mnMaxBmpDPIY ); - } - else - { - mnMaxBmpDPIX = Min( (long) rPrinterOptions.GetReducedBitmapResolution(), mnMaxBmpDPIX ); - mnMaxBmpDPIY = Min( (long) rPrinterOptions.GetReducedBitmapResolution(), mnMaxBmpDPIY ); - } - } - - // convert to greysacles - if( rPrinterOptions.IsConvertToGreyscales() ) - { - SetDrawMode( GetDrawMode() | ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | - DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); - } - - // disable transparency output - if( rPrinterOptions.IsReduceTransparency() && ( PRINTER_TRANSPARENCY_NONE == rPrinterOptions.GetReducedTransparencyMode() ) ) - { - SetDrawMode( GetDrawMode() | DRAWMODE_NOTRANSPARENCY ); - } - - maCurPageMetaFile = GDIMetaFile(); - RemoveTransparenciesFromMetaFile( *pPage->mpMtf, maCurPageMetaFile, mnMaxBmpDPIX, mnMaxBmpDPIY, - rPrinterOptions.IsReduceTransparency(), - rPrinterOptions.GetReducedTransparencyMode() == PRINTER_TRANSPARENCY_AUTO, - rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency() - ); -} - -void ImplQPrinter::PostPrintPage() -{ - SetDrawMode( mnRestoreDrawMode ); -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::PrintPage( unsigned int nPage ) -{ - if( nPage >= maQueue.size() ) - return; - mnCurCopyCount = (mbUserCopy && !mbCollateCopy) ? mnCopyCount : 1; - QueuePage* pActPage = maQueue[nPage]; - PrePrintPage( pActPage ); - if ( pActPage->mpSetup ) - SetJobSetup( *pActPage->mpSetup ); - - StartPage(); - ImplPrintMtf( maCurPageMetaFile, mnMaxBmpDPIX, mnMaxBmpDPIY ); - EndPage(); - - mnCurCopyCount--; - if( mnCurCopyCount == 0 ) - PostPrintPage(); -} - -// ----------------------------------------------------------------------- - -ImplJobSetup* ImplQPrinter::GetPageSetup( unsigned int nPage ) const -{ - return nPage >= maQueue.size() ? NULL : - ( maQueue[nPage]->mpSetup ? maQueue[nPage]->mpSetup->ImplGetData() : NULL ); -} - -// ----------------------------------------------------------------------- -sal_uIntPtr ImplQPrinter::GetPrintPageCount() const -{ - sal_uIntPtr nPageCount = maQueue.size() * ((mbUserCopy && !mbCollateCopy) ? mnCopyCount : 1); - return nPageCount; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( ImplQPrinter, ImplPrintHdl, Timer*, EMPTYARG ) -{ - // Ist Drucken abgebrochen wurden? - if( !IsPrinting() || ( mpParent->IsJobActive() && ( maQueue.size() < (sal_uIntPtr)mpParent->GetPageQueueSize() ) ) ) - return 0; - - // Druck-Job zuende? - QueuePage* pActPage = maQueue.front(); - maQueue.erase( maQueue.begin() ); - - - vcl::DeletionListener aDel( this ); - if ( pActPage->mbEndJob ) - { - maTimer.Stop(); - delete pActPage; - if( ! EndJob() ) - mpParent->Error(); - if( ! aDel.isDeleted() ) - mpParent->ImplEndPrint(); - } - else - { - mbDestroyAllowed = sal_False; - - PrePrintPage( pActPage ); - - sal_uInt16 nCopyCount = 1; - if( mbUserCopy && !mbCollateCopy ) - nCopyCount = mnCopyCount; - - for ( sal_uInt16 i = 0; i < nCopyCount; i++ ) - { - if ( pActPage->mpSetup ) - { - SetJobSetup( *pActPage->mpSetup ); - if ( mbAborted ) - break; - } - - StartPage(); - - if ( mbAborted ) - break; - - ImplPrintMtf( maCurPageMetaFile, mnMaxBmpDPIX, mnMaxBmpDPIY ); - - if( !mbAborted ) - EndPage(); - else - break; - } - - PostPrintPage(); - - delete pActPage; - mbDestroyAllowed = sal_True; - - if( mbDestroyed ) - Destroy(); - } - - return 0; -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::StartQueuePrint() -{ - if( ! ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - maTimer.SetTimeout( 50 ); - maTimer.SetTimeoutHdl( LINK( this, ImplQPrinter, ImplPrintHdl ) ); - maTimer.Start(); - } -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::EndQueuePrint() -{ - if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - DBG_ASSERT( mpPrinter, "no SalPrinter in ImplQPrinter" ); - if( mpPrinter ) - { - #if 0 - mpPrinter->StartJob( mbPrintFile ? &maPrintFile : NULL, - Application::GetDisplayName(), - maJobSetup.ImplGetConstData(), - this ); - #endif - EndJob(); - mpParent->ImplEndPrint(); - } - } - else - { - QueuePage* pQueuePage = new QueuePage; - pQueuePage->mbEndJob = sal_True; - maQueue.push_back( pQueuePage ); - } -} - -// ----------------------------------------------------------------------- - -bool ImplQPrinter::GetPaperRanges( std::vector< sal_uIntPtr >& o_rRanges, bool i_bIncludeOrientationChanges ) const -{ - bool bRet = false; - - if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - bRet = true; - o_rRanges.clear(); - - if( ! maQueue.empty() ) - { - sal_uIntPtr nCurPage = 0; - - // get first job data - const ImplJobSetup* pLastFormat = NULL; - if( maQueue.front()->mpSetup ) - pLastFormat = maQueue.front()->mpSetup->ImplGetConstData(); - - // begin first range - o_rRanges.push_back( 0 ); - for( std::vector< QueuePage* >::const_iterator it = maQueue.begin(); - it != maQueue.end(); ++it, ++nCurPage ) - { - const ImplJobSetup* pNewSetup = (*it)->mpSetup ? (*it)->mpSetup->ImplGetConstData() : NULL; - if( pNewSetup && pNewSetup != pLastFormat ) - { - bool bChange = false; - if( pLastFormat == NULL ) - { - bChange = true; - } - else if( ! i_bIncludeOrientationChanges && - pNewSetup->meOrientation != pLastFormat->meOrientation ) - { - bChange = true; - } - else if( pNewSetup->mePaperFormat != pLastFormat->mePaperFormat || - ( pNewSetup->mePaperFormat == PAPER_USER && - ( pNewSetup->mnPaperWidth != pLastFormat->mnPaperWidth || - pNewSetup->mnPaperHeight != pLastFormat->mnPaperHeight ) ) ) - { - bChange = true; - } - else if( pNewSetup->mnPaperBin != pLastFormat->mnPaperBin ) - { - bChange = true; - } - if( bChange ) - { - o_rRanges.push_back( nCurPage ); - pLastFormat = pNewSetup; - } - } - } - - o_rRanges.push_back( nCurPage ); - } - } - - return bRet; -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::AbortQueuePrint() -{ - maTimer.Stop(); - mbAborted = sal_True; - AbortJob(); -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::AddQueuePage( GDIMetaFile* pPage, sal_uInt16 nPage, sal_Bool bNewJobSetup ) -{ - QueuePage* pQueuePage = new QueuePage; - pQueuePage->mpMtf = pPage; - pQueuePage->mnPage = nPage; - pQueuePage->mbEndJob = sal_False; - // ensure that the first page has a valid setup, this is needed - // in GetPaperRanges (used in pullmodel) - // caution: this depends on mnCurPage in Printer being - // 0: not printing 1: after StartJob, 2 after first EndPage, 3+ at following EndPage calls - if ( bNewJobSetup || (nPage == 2 && ImplGetSVData()->maGDIData.mbPrinterPullModel) ) - pQueuePage->mpSetup = new JobSetup( mpParent->GetJobSetup() ); - maQueue.push_back( pQueuePage ); -} diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index f069828f25f9..ac2e586a41cb 100644..100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -50,6 +50,7 @@ CDEFS+=-DENABLE_GRAPHITE EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/outdev.obj \ $(SLO)$/outdev3.obj \ + $(SLO)$/outdevnative.obj \ $(SLO)$/gfxlink.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ @@ -62,6 +63,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/impgraph.obj \ $(SLO)$/metric.obj \ $(SLO)$/pdfwriter_impl.obj \ + $(SLO)$/pdfwriter_impl2.obj \ $(SLO)$/pdffontcache.obj\ $(SLO)$/bmpconv.obj \ $(SLO)$/pdfextoutdevdata.obj \ @@ -84,7 +86,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/bitmap4.obj \ $(SLO)$/alpha.obj \ $(SLO)$/bitmapex.obj \ - $(SLO)$/imgcons.obj \ $(SLO)$/bmpacc.obj \ $(SLO)$/bmpacc2.obj \ $(SLO)$/bmpacc3.obj \ @@ -106,7 +107,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/outdev4.obj \ $(SLO)$/outdev5.obj \ $(SLO)$/outdev6.obj \ - $(SLO)$/outdevnative.obj \ $(SLO)$/regband.obj \ $(SLO)$/region.obj \ $(SLO)$/wall.obj \ diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 8dd52b66b77d..fb4aee897d73 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -3793,7 +3793,6 @@ MetaAction* MetaFloatTransparentAction::Clone() void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove ) { maPoint.Move( nHorzMove, nVertMove ); - maMtf.Move(nHorzMove, nVertMove); } // ------------------------------------------------------------------------ @@ -3804,7 +3803,6 @@ void MetaFloatTransparentAction::Scale( double fScaleX, double fScaleY ) ImplScaleRect( aRectangle, fScaleX, fScaleY ); maPoint = aRectangle.TopLeft(); maSize = aRectangle.GetSize(); - maMtf.Scale(fScaleX, fScaleY); } // ------------------------------------------------------------------------ @@ -4078,7 +4076,7 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) aMemStm >> aFill; PolyPolygon aPath; aFill.getPath( aPath ); - aPath.Scale( nXMove, nYMove ); + aPath.Move( nXMove, nYMove ); aFill.setPath( aPath ); aDest << aFill; } diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx index e65ffb6d381a..01f88e9d8860 100644 --- a/vcl/source/gdi/metric.cxx +++ b/vcl/source/gdi/metric.cxx @@ -34,6 +34,8 @@ #include <vector> #include <set> +#include <cstdio> + // ======================================================================= ImplFontMetric::ImplFontMetric() @@ -51,6 +53,7 @@ ImplFontMetric::ImplFontMetric() inline void ImplFontMetric::AddReference() { + // TODO: disable refcounting on the default maps? ++mnRefCount; } @@ -58,6 +61,7 @@ inline void ImplFontMetric::AddReference() inline void ImplFontMetric::DeReference() { + // TODO: disable refcounting on the default maps? if( --mnRefCount <= 0 ) delete this; } @@ -252,7 +256,7 @@ ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR ) , mpGlyphIds( rCR.mpGlyphIds ) , mnRangeCount( rCR.mnRangeCount ) , mnCharCount( 0 ) -, mnRefCount( 1 ) +, mnRefCount( 0 ) { const sal_uInt32* pRangePtr = mpRangeCodes; for( int i = mnRangeCount; --i >= 0; pRangePtr += 2 ) @@ -263,7 +267,8 @@ ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR ) } } -static ImplFontCharMap* pDefaultImplFontCharMap = NULL; +static ImplFontCharMap* pDefaultUnicodeImplFontCharMap = NULL; +static ImplFontCharMap* pDefaultSymbolImplFontCharMap = NULL; static const sal_uInt32 aDefaultUnicodeRanges[] = {0x0020,0xD800, 0xE000,0xFFF0}; static const sal_uInt32 aDefaultSymbolRanges[] = {0x0020,0x0100, 0xF020,0xF100}; @@ -284,44 +289,60 @@ ImplFontCharMap::~ImplFontCharMap() delete[] mpRangeCodes; delete[] mpStartGlyphs; delete[] mpGlyphIds; -} + } // ----------------------------------------------------------------------- -ImplFontCharMap* ImplFontCharMap::GetDefaultMap( bool bSymbols) +namespace { - if( pDefaultImplFontCharMap ) - pDefaultImplFontCharMap->AddReference(); - else + ImplFontCharMap *GetDefaultUnicodeMap() { - const sal_uInt32* pRangeCodes = aDefaultUnicodeRanges; - int nCodesCount = sizeof(aDefaultUnicodeRanges) / sizeof(*pRangeCodes); - if( bSymbols ) + if( !pDefaultUnicodeImplFontCharMap ) { - pRangeCodes = aDefaultSymbolRanges; - nCodesCount = sizeof(aDefaultSymbolRanges) / sizeof(*pRangeCodes); + const sal_uInt32* pRangeCodes = aDefaultUnicodeRanges; + int nCodesCount = sizeof(aDefaultUnicodeRanges) / sizeof(*pRangeCodes); + CmapResult aDefaultCR( false, pRangeCodes, nCodesCount/2 ); + pDefaultUnicodeImplFontCharMap = new ImplFontCharMap( aDefaultCR ); + pDefaultUnicodeImplFontCharMap->AddReference(); } - CmapResult aDefaultCR( bSymbols, pRangeCodes, nCodesCount/2 ); - pDefaultImplFontCharMap = new ImplFontCharMap( aDefaultCR ); + return pDefaultUnicodeImplFontCharMap; } - return pDefaultImplFontCharMap; + ImplFontCharMap *GetDefaultSymbolMap() + { + if( !pDefaultSymbolImplFontCharMap ) + { + const sal_uInt32* pRangeCodes = aDefaultSymbolRanges; + int nCodesCount = sizeof(aDefaultSymbolRanges) / sizeof(*pRangeCodes); + CmapResult aDefaultCR( true, pRangeCodes, nCodesCount/2 ); + pDefaultSymbolImplFontCharMap = new ImplFontCharMap( aDefaultCR ); + pDefaultSymbolImplFontCharMap->AddReference(); + } + + return pDefaultSymbolImplFontCharMap; + } +} + +ImplFontCharMap* ImplFontCharMap::GetDefaultMap( bool bSymbols) +{ + return bSymbols ? GetDefaultSymbolMap() : GetDefaultUnicodeMap(); } // ----------------------------------------------------------------------- -void ImplFontCharMap::AddReference() +void ImplFontCharMap::AddReference( void ) const { + // TODO: disable refcounting on the default maps? ++mnRefCount; } // ----------------------------------------------------------------------- -void ImplFontCharMap::DeReference() +void ImplFontCharMap::DeReference( void ) const { if( --mnRefCount <= 0 ) - if( this != pDefaultImplFontCharMap ) + if( (this != pDefaultUnicodeImplFontCharMap) && (this != pDefaultSymbolImplFontCharMap) ) delete this; } @@ -815,7 +836,9 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) FontCharMap::FontCharMap() : mpImpl( ImplFontCharMap::GetDefaultMap() ) -{} +{ + mpImpl->AddReference(); +} // ----------------------------------------------------------------------- @@ -841,19 +864,14 @@ int FontCharMap::CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const // ----------------------------------------------------------------------- -void FontCharMap::Reset( ImplFontCharMap* pNewMap ) +void FontCharMap::Reset( const ImplFontCharMap* pNewMap ) { + mpImpl->DeReference(); if( pNewMap == NULL ) - { - mpImpl->DeReference(); mpImpl = ImplFontCharMap::GetDefaultMap(); - } else if( pNewMap != mpImpl ) - { - mpImpl->DeReference(); mpImpl = pNewMap; - mpImpl->AddReference(); - } + mpImpl->AddReference(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index fb97eab78f97..cb654a89366c 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2311,7 +2311,7 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt ) aB2DPolyLine = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyLine); } - if(mpGraphics->DrawPolyLine(aB2DPolyLine, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this)) + if( mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this)) { return; } @@ -2416,7 +2416,7 @@ void OutputDevice::impPaintLineGeometryWithEvtlExpand( if(bTryAA) { - bDone = mpGraphics->DrawPolyLine(aCandidate, basegfx::B2DVector(1.0, 1.0), basegfx::B2DLINEJOIN_NONE, this); + bDone = mpGraphics->DrawPolyLine( aCandidate, 0.0, basegfx::B2DVector(1.0,1.0), basegfx::B2DLINEJOIN_NONE, this); } if(!bDone) @@ -2605,7 +2605,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) aB2DPolyLine = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyLine); } - if(mpGraphics->DrawPolyLine(aB2DPolyLine, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this)) + if(mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this)) { return; } @@ -2653,7 +2653,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && LINE_SOLID == rLineInfo.GetStyle()) { - DrawPolyLine(rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin()); + DrawPolyLine( rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin()); return; } @@ -2785,7 +2785,7 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly ) aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon); } - bSuccess = mpGraphics->DrawPolyLine(aB2DPolygon, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolygon, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); } if(bSuccess) @@ -2877,7 +2877,7 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) for(sal_uInt32 a(0); bSuccess && a < aB2DPolyPolygon.count(); a++) { - bSuccess = mpGraphics->DrawPolyLine(aB2DPolyPolygon.getB2DPolygon(a), aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); } } @@ -3000,7 +3000,7 @@ void OutputDevice::ImpDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPo for(sal_uInt32 a(0);bSuccess && a < aB2DPolyPolygon.count(); a++) { - bSuccess = mpGraphics->DrawPolyLine(aB2DPolyPolygon.getB2DPolygon(a), aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this); } } @@ -3047,7 +3047,7 @@ bool OutputDevice::ImpTryDrawPolyLineDirect( } // draw the polyline - return mpGraphics->DrawPolyLine(aB2DPolygon, aB2DLineWidth, eLineJoin, this); + return mpGraphics->DrawPolyLine( aB2DPolygon, 0.0, aB2DLineWidth, eLineJoin, this); } void OutputDevice::DrawPolyLine( diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx index c6ec8ede4fa0..4f964e119c69 100644..100755 --- a/vcl/source/gdi/outdev2.cxx +++ b/vcl/source/gdi/outdev2.cxx @@ -1614,6 +1614,18 @@ void OutputDevice::DrawPixel( const Polygon& rPts, const Color& rColor ) // ------------------------------------------------------------------------ +namespace +{ + sal_uInt8 lcl_calcColor( const sal_uInt8 nSourceColor, const sal_uInt8 nSourceOpaq, const sal_uInt8 nDestColor ) + { + int c = ( (int)nDestColor * ( 255 - nSourceOpaq ) ) + + (int)nSourceOpaq * (int)nSourceColor; + return sal_uInt8( c / 255 ); + } +} + +// ------------------------------------------------------------------------ + Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp, BitmapReadAccess* pP, BitmapReadAccess* pA, @@ -1626,7 +1638,6 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp, const long* pMapY ) { BitmapColor aDstCol,aSrcCol; - sal_uInt8 nSrcAlpha, nDstAlpha; Bitmap res; int nX, nOutX, nY, nOutY; @@ -1660,36 +1671,23 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp, aSrcCol = pP->GetColor( nMapY, nMapX ); aDstCol = pB->GetColor( nY, nX ); - nSrcAlpha = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex(); - nDstAlpha = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex(); + const sal_uInt8 nSrcOpaq = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex(); + const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex(); - if( nSrcAlpha + nDstAlpha == 0 ) - { - // #i70653# zero alpha -> zero color values - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ 0 ] + nD ) >> 16UL ] + - nVCLGLut[ ( nVCLLut[ 0 ] + nD ) >> 16UL ] + - nVCLBLut[ ( nVCLLut[ 0 ] + nD ) >> 16UL ] ) ); - } - else - { - aDstCol.SetRed( (sal_uInt8)(((int)(aSrcCol.GetRed())*nSrcAlpha + (int)(aDstCol.GetRed())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - aDstCol.SetGreen( (sal_uInt8)(((int)(aSrcCol.GetGreen())*nSrcAlpha + (int)(aDstCol.GetGreen())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - aDstCol.SetBlue( (sal_uInt8)(((int)(aSrcCol.GetBlue())*nSrcAlpha + (int)(aDstCol.GetBlue())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16UL ] + - nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16UL ] + - nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16UL ] ) ); - } + aDstCol.SetRed( lcl_calcColor( aSrcCol.GetRed(), nSrcOpaq, aDstCol.GetRed() ) ); + aDstCol.SetBlue( lcl_calcColor( aSrcCol.GetBlue(), nSrcOpaq, aDstCol.GetBlue() ) ); + aDstCol.SetGreen( lcl_calcColor( aSrcCol.GetGreen(), nSrcOpaq, aDstCol.GetGreen() ) ); + + aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16UL ] + + nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16UL ] + + nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16UL ] ) ); pW->SetPixel( nY, nX, aIndex ); // Have to perform the compositing 'algebra' in // the inverse alpha space (with 255 meaning // opaque), otherwise, transitivity is not // achieved. - nSrcAlpha = 255-COLOR_CHANNEL_MERGE( 255, (sal_uInt8)nDstAlpha, nSrcAlpha ); + const sal_uInt8 nSrcAlpha = 255-COLOR_CHANNEL_MERGE( 255, (sal_uInt8)nDstOpaq, nSrcOpaq ); aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ nSrcAlpha ] + nD ) >> 16UL ] + nVCLGLut[ ( nVCLLut[ nSrcAlpha ] + nD ) >> 16UL ] + @@ -1718,25 +1716,12 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp, aSrcCol = pP->GetColor( nMapY, nMapX ); aDstCol = pB->GetColor( nY, nX ); - nSrcAlpha = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex(); - nDstAlpha = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex(); + const sal_uInt8 nSrcOpaq = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex(); + const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex(); - if( nSrcAlpha + nDstAlpha == 0 ) - { - // #i70653# zero alpha -> zero color values - aDstCol.SetRed(0); - aDstCol.SetGreen(0); - aDstCol.SetBlue(0); - } - else - { - aDstCol.SetRed( (sal_uInt8)(((int)(aSrcCol.GetRed())*nSrcAlpha + (int)(aDstCol.GetRed())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - aDstCol.SetGreen( (sal_uInt8)(((int)(aSrcCol.GetGreen())*nSrcAlpha + (int)(aDstCol.GetGreen())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - aDstCol.SetBlue( (sal_uInt8)(((int)(aSrcCol.GetBlue())*nSrcAlpha + (int)(aDstCol.GetBlue())*nDstAlpha) / - (nSrcAlpha+nDstAlpha)) ); - } + aDstCol.SetRed( lcl_calcColor( aSrcCol.GetRed(), nSrcOpaq, aDstCol.GetRed() ) ); + aDstCol.SetBlue( lcl_calcColor( aSrcCol.GetBlue(), nSrcOpaq, aDstCol.GetBlue() ) ); + aDstCol.SetGreen( lcl_calcColor( aSrcCol.GetGreen(), nSrcOpaq, aDstCol.GetGreen() ) ); pB->SetPixel( nY, nX, aDstCol ); @@ -1744,7 +1729,7 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp, // the inverse alpha space (with 255 meaning // opaque), otherwise, transitivity is not // achieved. - nSrcAlpha = 255-COLOR_CHANNEL_MERGE( 255, (sal_uInt8)nDstAlpha, nSrcAlpha ); + const sal_uInt8 nSrcAlpha = 255-COLOR_CHANNEL_MERGE( 255, (sal_uInt8)nDstOpaq, nSrcOpaq ); pAlphaW->SetPixel( nY, nX, Color(nSrcAlpha, nSrcAlpha, nSrcAlpha) ); } @@ -2003,7 +1988,15 @@ void OutputDevice::ImplDrawAlpha( const Bitmap& rBmp, const AlphaMask& rAlpha, const long nSrcWidth = aBmpRect.GetWidth(), nSrcHeight = aBmpRect.GetHeight(); const long nDstWidth = aDstRect.GetWidth(), nDstHeight = aDstRect.GetHeight(); const long nOutWidth = aOutSz.Width(), nOutHeight = aOutSz.Height(); - const long nOffX = aDstRect.Left() - aOutPt.X(), nOffY = aDstRect.Top() - aOutPt.Y(); + // calculate offset in original bitmap + // in RTL case this is a little more complicated since the contents of the + // bitmap is not mirrored (it never is), however the paint region and bmp region + // are in mirrored coordinates, so the intersection of (aOutPt,aOutSz) with these + // is content wise somewhere else and needs to take mirroring into account + const long nOffX = IsRTLEnabled() + ? aOutSz.Width() - aDstRect.GetWidth() - (aDstRect.Left() - aOutPt.X()) + : aDstRect.Left() - aOutPt.X(), + nOffY = aDstRect.Top() - aOutPt.Y(); long nX, nOutX, nY, nOutY; long nMirrOffX = 0; long nMirrOffY = 0; @@ -2017,7 +2010,6 @@ void OutputDevice::ImplDrawAlpha( const Bitmap& rBmp, const AlphaMask& rAlpha, for( nX = 0L, nOutX = nOffX; nX < nDstWidth; nX++, nOutX++ ) { pMapX[ nX ] = aBmpRect.Left() + nOutX * nSrcWidth / nOutWidth; - if( bHMirr ) pMapX[ nX ] = nMirrOffX - pMapX[ nX ]; } diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index ff6fac84c35f..d093047872a0 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -27,62 +27,57 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <cstring> -#include <i18npool/mslangid.hxx> -#ifndef _SV_SVSYS_HXX -#include <svsys.h> -#endif -#include <vcl/salgdi.hxx> -#include <vcl/sallayout.hxx> -#include <rtl/tencinfo.h> -#include <tools/debug.hxx> -#include <vcl/svdata.hxx> -#include <vcl/metric.hxx> -#include <vcl/impfont.hxx> -#include <vcl/metaact.hxx> -#include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> -#include <vcl/outfont.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <tools/poly.hxx> -#include <vcl/outdev.h> -#include <vcl/virdev.hxx> -#include <vcl/print.hxx> -#include <vcl/event.hxx> -#include <vcl/window.h> -#include <vcl/window.hxx> -#include <vcl/svapp.hxx> -#include <vcl/bmpacc.hxx> -#include <unotools/fontcvt.hxx> -#include <vcl/outdev.hxx> -#include <vcl/edit.hxx> -#include <unotools/fontcfg.hxx> -#include <vcl/sysdata.hxx> -#include <vcl/textlayout.hxx> -#ifndef _OSL_FILE_H -#include <osl/file.h> -#endif +#include "i18npool/mslangid.hxx" + +#include "svsys.h" +#include "vcl/salgdi.hxx" +#include "vcl/sallayout.hxx" +#include "rtl/tencinfo.h" +#include "tools/debug.hxx" +#include "vcl/svdata.hxx" +#include "vcl/metric.hxx" +#include "vcl/impfont.hxx" +#include "vcl/metaact.hxx" +#include "vcl/gdimtf.hxx" +#include "vcl/outdata.hxx" +#include "vcl/outfont.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "basegfx/polygon/b2dpolypolygon.hxx" +#include "basegfx/matrix/b2dhommatrix.hxx" +#include "tools/poly.hxx" +#include "vcl/outdev.h" +#include "vcl/virdev.hxx" +#include "vcl/print.hxx" +#include "vcl/event.hxx" +#include "vcl/window.h" +#include "vcl/window.hxx" +#include "vcl/svapp.hxx" +#include "vcl/bmpacc.hxx" +#include "unotools/fontcvt.hxx" +#include "vcl/outdev.hxx" +#include "vcl/edit.hxx" +#include "unotools/fontcfg.hxx" +#include "vcl/sysdata.hxx" +#include "vcl/textlayout.hxx" +#include "vcl/svids.hrc" +#include "osl/file.h" #ifdef ENABLE_GRAPHITE -#include <vcl/graphite_features.hxx> +#include "vcl/graphite_features.hxx" #endif #ifdef USE_BUILTIN_RASTERIZER -#include <vcl/glyphcache.hxx> +#include "vcl/glyphcache.hxx" #endif -#include <vcl/unohelp.hxx> -#include <pdfwriter_impl.hxx> -#include <vcl/controllayout.hxx> -#include <rtl/logfile.hxx> +#include "vcl/unohelp.hxx" +#include "pdfwriter_impl.hxx" +#include "vcl/controllayout.hxx" +#include "rtl/logfile.hxx" -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HDL_ -#include <com/sun/star/beans/PropertyValues.hdl> -#endif -#include <com/sun/star/i18n/XBreakIterator.hpp> -#include <com/sun/star/i18n/WordType.hpp> -#include <com/sun/star/linguistic2/XLinguServiceManager.hpp> +#include "com/sun/star/beans/PropertyValues.hpp" +#include "com/sun/star/i18n/XBreakIterator.hpp" +#include "com/sun/star/i18n/WordType.hpp" +#include "com/sun/star/linguistic2/XLinguServiceManager.hpp" #if defined UNX #define GLYPH_FONT_HEIGHT 128 @@ -92,7 +87,7 @@ #define GLYPH_FONT_HEIGHT 256 #endif -#include <sal/alloca.h> +#include "sal/alloca.h" #include <cmath> #include <cstring> @@ -1327,11 +1322,11 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const "msmincho", "fzmingti", "fzheiti", "ipamincho", "sazanamimincho", "kochimincho", "", "sunbatang", "sundotum", "baekmukdotum", "gulim", "batang", "dotum", "", "hgmincholightj", "msunglightsc", "msunglighttc", "hymyeongjolightk", "", - "tahoma", "dejavusans", "timesnewroman", "lucidatypewriter", "lucidasans", "nimbussansl", "", + "tahoma", "dejavusans", "timesnewroman", "liberationsans", "", "shree", "mangal", "", "raavi", "shruti", "tunga", "", "latha", "gautami", "kartika", "vrinda", "", - "shayyalmt", "naskmt", "", + "shayyalmt", "naskmt", "scheherazade", "", "david", "nachlieli", "lucidagrande", "", "norasi", "angsanaupc", "", "khmerossystem", "", @@ -1381,6 +1376,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const } } +#ifdef SAL_FONTENUM_STABLE_ON_PLATFORM // #i113472# // sort the list of fonts for glyph fallback by quality (highest first) // #i33947# keep the EUDC font at the front of the list // an insertion sort is good enough for this short list @@ -1396,6 +1392,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const break; pFallbackList[ j+1 ] = pTestFont; } +#endif #if defined(HDU_DEBUG) for( int i = 0; i < nMaxLevel; ++i ) @@ -1529,7 +1526,7 @@ void ImplDevFontList::Add( ImplFontData* pNewData ) // add font alias if available // a font alias should never win against an original font with similar quality - if( aMapNames.Len() >= nMapNameIndex ) + if( aMapNames.Len() <= nMapNameIndex ) break; if( bKeepNewData ) // try to recycle obsoleted object pNewData = pNewData->CreateAlias(); @@ -1645,10 +1642,25 @@ ImplDevFontListData* ImplDevFontList::ImplFindBySubstFontAttr( const utl::FontNa pFoundData = ImplFindBySearchName( aSearchName ); if( pFoundData ) - break; + return pFoundData; } - return pFoundData; + // use known attributes from the configuration to find a matching substitute + const sal_uIntPtr nSearchType = rFontAttr.Type; + if( nSearchType != 0 ) + { + const FontWeight eSearchWeight = rFontAttr.Weight; + const FontWidth eSearchWidth = rFontAttr.Width; + const FontItalic eSearchSlant = ITALIC_DONTKNOW; + const FontFamily eSearchFamily = FAMILY_DONTKNOW; + const String aSearchName; + pFoundData = ImplFindByAttributes( nSearchType, + eSearchWeight, eSearchWidth, eSearchFamily, eSearchSlant, aSearchName ); + if( pFoundData ) + return pFoundData; + } + + return NULL; } // ----------------------------------------------------------------------- @@ -1889,10 +1901,11 @@ ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( sal_uIntPtr nSearchT nTestMatch -= 1000000; // test font name substrings - if( (rSearchFamilyName.Len() && pData->maMatchFamilyName.Len()) + // TODO: calculate name matching score using e.g. Levenstein distance + if( (rSearchFamilyName.Len() >= 4) && (pData->maMatchFamilyName.Len() >= 4) && ((rSearchFamilyName.Search( pData->maMatchFamilyName ) != STRING_NOTFOUND) || (pData->maMatchFamilyName.Search( rSearchFamilyName ) != STRING_NOTFOUND)) ) - nTestMatch += 100000*2; + nTestMatch += 5000; // test SERIF attribute if( nSearchType & IMPL_FONT_ATTR_SERIF ) @@ -2909,6 +2922,18 @@ void OutputDevice::ImplInitFontList() const mpGraphics->GetDevFontList( mpFontList ); } } + if( meOutDevType == OUTDEV_WINDOW && ! mpFontList->Count() ) + { + String aError( RTL_CONSTASCII_USTRINGPARAM( "Application error: no fonts and no vcl resource found on your system" ) ); + ResMgr* pMgr = ImplGetResMgr(); + if( pMgr ) + { + String aResStr( ResId( SV_ACCESSERROR_NO_FONTS, *pMgr ) ); + if( aResStr.Len() ) + aError = aResStr; + } + Application::Abort( aError ); + } } // ======================================================================= @@ -3130,17 +3155,17 @@ long OutputDevice::ImplGetTextWidth( const SalLayout& rSalLayout ) const // ----------------------------------------------------------------------- void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, long nHeight ) + long nDistX, long nDistY, long nWidth, long nHeight ) { + long nX = nDistX; + long nY = nDistY; + short nOrientation = mpFontEntry->mnOrientation; if ( nOrientation ) { // Rotate rect without rounding problems for 90 degree rotations if ( !(nOrientation % 900) ) { - nX -= nBaseX; - nY -= nBaseY; - if ( nOrientation == 900 ) { long nTemp = nX; @@ -3168,12 +3193,11 @@ void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, nHeight = nTemp; nX -= nWidth; } - - nX += nBaseX; - nY += nBaseY; } else { + nX += nBaseX; + nY += nBaseY; // inflate because polygons are drawn smaller Rectangle aRect( Point( nX, nY ), Size( nWidth+1, nHeight+1 ) ); Polygon aPoly( aRect ); @@ -3183,6 +3207,8 @@ void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, } } + nX += nBaseX; + nY += nBaseY; mpGraphics->DrawRect( nX, nY, nWidth, nHeight, this ); } @@ -3203,7 +3229,7 @@ void OutputDevice::ImplDrawTextBackground( const SalLayout& rSalLayout ) mpGraphics->SetFillColor( ImplColorToSal( GetTextFillColor() ) ); mbInitFillColor = sal_True; - ImplDrawTextRect( nX, nY, nX, nY-mpFontEntry->maMetric.mnAscent-mnEmphasisAscent, + ImplDrawTextRect( nX, nY, 0, -(mpFontEntry->maMetric.mnAscent + mnEmphasisAscent), nWidth, mpFontEntry->mnLineHeight+mnEmphasisAscent+mnEmphasisDescent ); } @@ -3488,7 +3514,7 @@ static void ImplDrawWavePixel( long nOriginX, long nOriginY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, - long nStartX, long nStartY, + long nDistX, long nDistY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor ) @@ -3496,6 +3522,9 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, if ( !nHeight ) return; + long nStartX = nBaseX + nDistX; + long nStartY = nBaseY + nDistY; + // Bei Hoehe von 1 Pixel reicht es, eine Linie auszugeben if ( (nLineWidth == 1) && (nHeight == 1) ) { @@ -3510,7 +3539,6 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, ImplRotatePos( nBaseX, nBaseY, nEndX, nEndY, nOrientation ); } mpGraphics->DrawLine( nStartX, nStartY, nEndX, nEndY, this ); - } else { @@ -3610,7 +3638,7 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ) @@ -3636,7 +3664,7 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, nLineWidth = 1; if ( eTextLine == UNDERLINE_BOLDWAVE ) nLineWidth *= 2; - nLinePos += nY - (nLineHeight / 2); + nLinePos += nDistY - (nLineHeight / 2); long nLineWidthHeight = ((nLineWidth*mnDPIX)+(mnDPIY/2))/mnDPIY; if ( eTextLine == UNDERLINE_DOUBLEWAVE ) { @@ -3657,16 +3685,16 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, nLineDY2 = 1; nLinePos -= nLineWidthHeight-nLineDY2; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); nLinePos += nLineWidthHeight+nLineDY; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); } else { nLinePos -= nLineWidthHeight/2; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); } } @@ -3674,7 +3702,7 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ) @@ -3684,6 +3712,8 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nLinePos = 0; long nLinePos2 = 0; + const long nY = nDistY; + if ( eTextLine > UNDERLINE_LAST ) eTextLine = UNDERLINE_SINGLE; @@ -3751,7 +3781,7 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, mpGraphics->SetFillColor( ImplColorToSal( aColor ) ); mbInitFillColor = sal_True; - long nLeft = nX; + long nLeft = nDistX; switch ( eTextLine ) { @@ -3904,7 +3934,7 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontStrikeout eStrikeout, Color aColor ) { @@ -3913,6 +3943,8 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nLinePos = 0; long nLinePos2 = 0; + long nY = nDistY; + if ( eStrikeout > STRIKEOUT_LAST ) eStrikeout = STRIKEOUT_SINGLE; @@ -3945,7 +3977,7 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, mpGraphics->SetFillColor( ImplColorToSal( aColor ) ); mbInitFillColor = sal_True; - long nLeft = nX; + const long& nLeft = nDistX; switch ( eStrikeout ) { @@ -3966,7 +3998,7 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontStrikeout eStrikeout, Color aColor ) { @@ -4000,12 +4032,12 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // calculate acceptable strikeout length // allow the strikeout to be one pixel larger than the text it strikes out - long nMaxWidth = nStrikeoutWidth / 2; + long nMaxWidth = nStrikeoutWidth * 3 / 4; if ( nMaxWidth < 2 ) nMaxWidth = 2; nMaxWidth += nWidth + 1; - int nStrikeStrLen = (nMaxWidth + nStrikeoutWidth - 1) / nStrikeoutWidth; + int nStrikeStrLen = (nMaxWidth - 1) / nStrikeoutWidth; // if the text width is smaller than the strikeout text, then do not // strike out at all. This case requires user interaction, e.g. adding // a space to the text @@ -4020,7 +4052,9 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, const String aStrikeoutText( aChars, xub_StrLen(nStrikeStrLen) ); if( mpFontEntry->mnOrientation ) - ImplRotatePos( nBaseX, nBaseY, nX, nY, mpFontEntry->mnOrientation ); + ImplRotatePos( 0, 0, nDistX, nDistY, mpFontEntry->mnOrientation ); + nBaseX += nDistX; + nBaseY += nDistY; // strikeout text has to be left aligned sal_uIntPtr nOrigTLM = mnTextLayoutMode; @@ -4036,7 +4070,7 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, SetTextColor( aColor ); ImplInitTextColor(); - pLayout->DrawBase() = Point( nX+mnTextOffX, nY+mnTextOffY ); + pLayout->DrawBase() = Point( nBaseX+mnTextOffX, nBaseY+mnTextOffY ); pLayout->DrawText( *mpGraphics ); pLayout->Release(); @@ -4046,8 +4080,8 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- -void OutputDevice::ImplDrawTextLine( long nBaseX, - long nX, long nY, long nWidth, +void OutputDevice::ImplDrawTextLine( long nX, long nY, + long nDistX, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, @@ -4063,10 +4097,14 @@ void OutputDevice::ImplDrawTextLine( long nBaseX, sal_Bool bUnderlineDone = sal_False; sal_Bool bOverlineDone = sal_False; - // TODO: fix rotated text if ( IsRTLEnabled() ) + { // --- RTL --- mirror at basex - nX = nBaseX - nWidth - (nX - nBaseX - 1); + long nXAdd = nWidth - nDistX; + if( mpFontEntry->mnOrientation ) + nXAdd = FRound( nXAdd * cos( mpFontEntry->mnOrientation * F_PI1800 ) ); + nX += nXAdd - 1; + } if ( !IsTextLineColor() ) aUnderlineColor = GetTextColor(); @@ -4079,7 +4117,7 @@ void OutputDevice::ImplDrawTextLine( long nBaseX, (eUnderline == UNDERLINE_DOUBLEWAVE) || (eUnderline == UNDERLINE_BOLDWAVE) ) { - ImplDrawWaveTextLine( nBaseX, nY, nX, nY, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); + ImplDrawWaveTextLine( nX, nY, nDistX, 0, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); bUnderlineDone = sal_True; } if ( (eOverline == UNDERLINE_SMALLWAVE) || @@ -4087,25 +4125,25 @@ void OutputDevice::ImplDrawTextLine( long nBaseX, (eOverline == UNDERLINE_DOUBLEWAVE) || (eOverline == UNDERLINE_BOLDWAVE) ) { - ImplDrawWaveTextLine( nBaseX, nY, nX, nY, nWidth, eOverline, aOverlineColor, sal_True ); + ImplDrawWaveTextLine( nX, nY, nDistX, 0, nWidth, eOverline, aOverlineColor, sal_True ); bOverlineDone = sal_True; } if ( (eStrikeout == STRIKEOUT_SLASH) || (eStrikeout == STRIKEOUT_X) ) { - ImplDrawStrikeoutChar( nBaseX, nY, nX, nY, nWidth, eStrikeout, aStrikeoutColor ); + ImplDrawStrikeoutChar( nX, nY, nDistX, 0, nWidth, eStrikeout, aStrikeoutColor ); bStrikeoutDone = sal_True; } if ( !bUnderlineDone ) - ImplDrawStraightTextLine( nBaseX, nY, nX, nY, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); + ImplDrawStraightTextLine( nX, nY, nDistX, 0, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); if ( !bOverlineDone ) - ImplDrawStraightTextLine( nBaseX, nY, nX, nY, nWidth, eOverline, aOverlineColor, sal_True ); + ImplDrawStraightTextLine( nX, nY, nDistX, 0, nWidth, eOverline, aOverlineColor, sal_True ); if ( !bStrikeoutDone ) - ImplDrawStrikeoutLine( nBaseX, nY, nX, nY, nWidth, eStrikeout, aStrikeoutColor ); + ImplDrawStrikeoutLine( nX, nY, nDistX, 0, nWidth, eStrikeout, aStrikeoutColor ); } // ----------------------------------------------------------------------- @@ -4115,34 +4153,49 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, { if( bWordLine ) { - Point aPos, aStartPt; - sal_Int32 nWidth = 0, nAdvance=0; + // draw everything relative to the layout base point + const Point aStartPt = rSalLayout.DrawBase(); + // calculate distance of each word from the base point + Point aPos; + sal_Int32 nDist = 0, nWidth = 0, nAdvance=0; for( int nStart = 0;;) { + // iterate through the layouted glyphs sal_GlyphId nGlyphIndex; if( !rSalLayout.GetNextGlyphs( 1, &nGlyphIndex, aPos, nStart, &nAdvance ) ) break; + // calculate the boundaries of each word if( !rSalLayout.IsSpacingGlyph( nGlyphIndex ) ) { if( !nWidth ) { - aStartPt = aPos;//rSalLayout.DrawBase() - (aPos - rSalLayout.DrawOffset()); + // get the distance to the base point (as projected to baseline) + nDist = aPos.X() - aStartPt.X(); + if( mpFontEntry->mnOrientation ) + { + const long nDY = aPos.Y() - aStartPt.Y(); + const double fRad = mpFontEntry->mnOrientation * F_PI1800; + nDist = FRound( nDist*cos(fRad) - nDY*sin(fRad) ); + } } + // update the length of the textline nWidth += nAdvance; } else if( nWidth > 0 ) { - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + // draw the textline for each word + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); nWidth = 0; } } + // draw textline for the last word if( nWidth > 0 ) { - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } @@ -4150,7 +4203,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, { Point aStartPt = rSalLayout.GetDrawPosition(); int nWidth = rSalLayout.GetTextWidth() / rSalLayout.GetUnitsPerPixel(); - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), 0, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } @@ -4169,7 +4222,7 @@ void OutputDevice::ImplDrawMnemonicLine( long nX, long nY, long nWidth ) nX = nBaseX - nWidth - (nX - nBaseX - 1); } - ImplDrawTextLine( nBaseX, nX, nY, nWidth, STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, sal_False ); + ImplDrawTextLine( nX, nY, 0, nWidth, STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, sal_False ); } // ----------------------------------------------------------------------- @@ -5417,7 +5470,7 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth, Point aPos = ImplLogicToDevicePixel( rPos ); nWidth = ImplLogicWidthToDevicePixel( nWidth ); aPos += Point( mnTextOffX, mnTextOffY ); - ImplDrawTextLine( aPos.X(), aPos.X(), aPos.Y(), nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); + ImplDrawTextLine( aPos.X(), aPos.X(), 0, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); if( mpAlphaVDev ) mpAlphaVDev->DrawTextLine( rPos, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); @@ -5494,7 +5547,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos, if( nWaveHeight > pFontEntry->maMetric.mnWUnderlineSize ) nWaveHeight = pFontEntry->maMetric.mnWUnderlineSize; - ImplDrawWaveLine( nStartX, nStartY, nStartX, nStartY, + ImplDrawWaveLine( nStartX, nStartY, 0, 0, nEndX-nStartX, nWaveHeight, 1, nOrientation, GetLineColor() ); if( mpAlphaVDev ) @@ -6057,6 +6110,11 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay rtl::OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData; + + ImplFontMetricData aOrigMetric( aFontSelData ); + // TODO: use cached metric in fontentry + mpGraphics->GetFontMetric( &aOrigMetric ); + // when device specific font substitution may have been performed for // the originally selected font then make sure that a fallback to that // font is performed first @@ -6101,7 +6159,27 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay } #endif + // TODO: try to get the metric data from the GFB's mpFontEntry + ImplFontMetricData aSubstituteMetric( aFontSelData ); pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel ); + mpGraphics->GetFontMetric( &aSubstituteMetric, nFallbackLevel ); + + const long nOriginalHeight = aOrigMetric.mnAscent + aOrigMetric.mnDescent; + const long nSubstituteHeight = aSubstituteMetric.mnAscent + aSubstituteMetric.mnDescent; + // Too tall, shrink it a bit. Need a better calculation to include extra + // factors and any extra wriggle room we might have available? + // TODO: should we scale by max-ascent/max-descent instead of design height? + if( nSubstituteHeight > nOriginalHeight ) + { + const float fScale = nOriginalHeight / (float)nSubstituteHeight; + const float fOrigHeight = aFontSelData.mfExactHeight; + const int nOrigHeight = aFontSelData.mnHeight; + aFontSelData.mfExactHeight *= fScale; + aFontSelData.mnHeight = static_cast<int>(aFontSelData.mfExactHeight); + pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel ); + aFontSelData.mnHeight = nOrigHeight; + aFontSelData.mfExactHeight = fOrigHeight; + } // create and add glyph fallback layout to multilayout rLayoutArgs.ResetPos(); @@ -6763,7 +6841,20 @@ String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, c if ( nIndex != STRING_LEN ) { - if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) + if( (nStyle & TEXT_DRAW_CENTERELLIPSIS) == TEXT_DRAW_CENTERELLIPSIS ) + { + String aTmpStr( aStr ); + xub_StrLen nEraseChars = 4; + while( nEraseChars < aStr.Len() && _rLayout.GetTextWidth( aTmpStr, 0, aTmpStr.Len() ) > nMaxWidth ) + { + aTmpStr = aStr; + xub_StrLen i = (aTmpStr.Len() - nEraseChars)/2; + aTmpStr.Erase( i, nEraseChars++ ); + aTmpStr.InsertAscii( "...", i ); + } + aStr = aTmpStr; + } + else if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) { aStr.Erase( nIndex ); if ( nIndex > 1 ) @@ -7946,7 +8037,7 @@ sal_Bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( !mpFontEntry ) return sal_False; - // a little font charmap cache helps considerably +#ifdef ENABLE_IFC_CACHE // a little font charmap cache helps considerably static const int NMAXITEMS = 16; static int nUsedItems = 0, nCurItem = 0; @@ -7964,10 +8055,12 @@ sal_Bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const rFontCharMap.Reset( aCache[i].maCharMap.mpImpl ); } else // need to cache +#endif // ENABLE_IFC_CACHE { - ImplFontCharMap* pNewMap = mpGraphics->GetImplFontCharMap(); + const ImplFontCharMap* pNewMap = mpGraphics->GetImplFontCharMap(); rFontCharMap.Reset( pNewMap ); +#ifdef ENABLE_IFC_CACHE // manage cache round-robin and insert data CharMapCacheItem& rItem = aCache[ nCurItem ]; rItem.mpFontData = pFontData; @@ -7978,6 +8071,7 @@ sal_Bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( ++nUsedItems >= NMAXITEMS ) nUsedItems = NMAXITEMS; +#endif // ENABLE_IFC_CACHE } if( rFontCharMap.IsDefaultMap() ) diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index 0d51196eac09..f479da39c546 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -184,18 +184,31 @@ void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsFillColor()) + && ROP_OVERPAINT == GetRasterOp() ) { // b2dpolygon support not implemented yet on non-UNX platforms const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); basegfx::B2DPolyPolygon aB2DPolyPolygon(rB2DPolyPoly); - // transform the polygon and ensure closed - aB2DPolyPolygon.transform(aTransform); - aB2DPolyPolygon.setClosed(true); + // transform the polygon into device space and ensure it is closed + aB2DPolyPolygon.transform( aTransform ); + aB2DPolyPolygon.setClosed( true ); + + bool bDrawnOk = true; + if( IsFillColor() ) + bDrawnOk = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, fTransparency, this ); + if( bDrawnOk && IsLineColor() ) + { + const basegfx::B2DVector aHairlineWidth(1,1); + const int nPolyCount = aB2DPolyPolygon.count(); + for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx ) + { + const ::basegfx::B2DPolygon aOnePoly = aB2DPolyPolygon.getB2DPolygon( nPolyIdx ); + mpGraphics->DrawPolyLine( aOnePoly, fTransparency, aHairlineWidth, ::basegfx::B2DLINEJOIN_NONE, this ); + } + } - if(mpGraphics->DrawPolyPolygon(aB2DPolyPolygon, fTransparency, this)) + if( bDrawnOk ) { #if 0 // MetaB2DPolyPolygonAction is not implemented yet: @@ -287,14 +300,17 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, // get the polygon in device coordinates basegfx::B2DPolyPolygon aB2DPolyPolygon( rPolyPoly.getB2DPolyPolygon() ); - aB2DPolyPolygon.setClosed( true ); const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); aB2DPolyPolygon.transform( aTransform ); - // draw the transparent polygon - bDrawn = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, nTransparencePercent*0.01, this ); + const double fTransparency = 0.01 * nTransparencePercent; + if( mbFillColor ) + { + // draw the transparent polygon + // NOTE: filled polygons are assumed to be drawn as if they were always closed + bDrawn = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, fTransparency, this ); + } - // DrawTransparent() assumes that the border is NOT to be drawn transparently??? if( mbLineColor ) { // disable the fill color for now @@ -305,7 +321,7 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx ) { const ::basegfx::B2DPolygon& rPolygon = aB2DPolyPolygon.getB2DPolygon( nPolyIdx ); - mpGraphics->DrawPolyLine( rPolygon, aLineWidths, ::basegfx::B2DLINEJOIN_NONE, this ); + bDrawn = mpGraphics->DrawPolyLine( rPolygon, fTransparency, aLineWidths, ::basegfx::B2DLINEJOIN_NONE, this ); } // prepare to restore the fill color mbInitFillColor = mbFillColor; @@ -329,6 +345,12 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, if( OUTDEV_PRINTER == meOutDevType ) { + if(100 <= nTransparencePercent) + { + // #i112959# 100% transparent, draw nothing + return; + } + Rectangle aPolyRect( LogicToPixel( rPolyPoly ).GetBoundRect() ); const Size aDPISize( LogicToPixel( Size( 1, 1 ), MAP_INCH ) ); const long nBaseExtent = Max( FRound( aDPISize.Width() / 300. ), 1L ); @@ -343,30 +365,40 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, case( 25 ): nMove = nBaseExtent * 3; break; case( 50 ): nMove = nBaseExtent * 4; break; case( 75 ): nMove = nBaseExtent * 6; break; - // TODO What is the correct VALUE??? + + // #i112959# very transparent (88 < nTransparencePercent <= 99) + case( 100 ): nMove = nBaseExtent * 8; break; + + // #i112959# not transparent (nTransparencePercent < 13) default: nMove = 0; break; } Push( PUSH_CLIPREGION | PUSH_LINECOLOR ); IntersectClipRegion( rPolyPoly ); SetLineColor( GetFillColor() ); - - Rectangle aRect( aPolyRect.TopLeft(), Size( aPolyRect.GetWidth(), nBaseExtent ) ); - const sal_Bool bOldMap = mbMap; EnableMapMode( sal_False ); - while( aRect.Top() <= aPolyRect.Bottom() ) + if(nMove) { - DrawRect( aRect ); - aRect.Move( 0, nMove ); - } + Rectangle aRect( aPolyRect.TopLeft(), Size( aPolyRect.GetWidth(), nBaseExtent ) ); + while( aRect.Top() <= aPolyRect.Bottom() ) + { + DrawRect( aRect ); + aRect.Move( 0, nMove ); + } - aRect = Rectangle( aPolyRect.TopLeft(), Size( nBaseExtent, aPolyRect.GetHeight() ) ); - while( aRect.Left() <= aPolyRect.Right() ) + aRect = Rectangle( aPolyRect.TopLeft(), Size( nBaseExtent, aPolyRect.GetHeight() ) ); + while( aRect.Left() <= aPolyRect.Right() ) + { + DrawRect( aRect ); + aRect.Move( nMove, 0 ); + } + } + else { - DrawRect( aRect ); - aRect.Move( nMove, 0 ); + // #i112959# if not transparent, draw full rectangle in clip region + DrawRect( aPolyRect ); } EnableMapMode( bOldMap ); @@ -1119,7 +1151,7 @@ void OutputDevice::Erase() { ImplControlValue aControlValue; Point aGcc3WorkaroundTemporary; - Region aCtrlRegion( Rectangle( aGcc3WorkaroundTemporary, GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( aGcc3WorkaroundTemporary, GetOutputSizePixel() ); ControlState nState = 0; if( pWindow->IsEnabled() ) nState |= CTRL_STATE_ENABLED; diff --git a/vcl/source/gdi/outdevnative.cxx b/vcl/source/gdi/outdevnative.cxx index 3879bd5386d7..7bf4a5a73ec1 100644 --- a/vcl/source/gdi/outdevnative.cxx +++ b/vcl/source/gdi/outdevnative.cxx @@ -59,6 +59,38 @@ static bool lcl_enableNativeWidget( const OutputDevice& i_rDevice ) } } +ImplControlValue::~ImplControlValue() +{ +} + +ScrollbarValue::~ScrollbarValue() +{ +} + +SliderValue::~SliderValue() +{ +} + +TabitemValue::~TabitemValue() +{ +} + +SpinbuttonValue::~SpinbuttonValue() +{ +} + +ToolbarValue::~ToolbarValue() +{ +} + +MenubarValue::~MenubarValue() +{ +} + +PushButtonValue::~PushButtonValue() +{ +} + // ----------------------------------------------------------------------- // These functions are mainly passthrough functions that allow access to // the SalFrame behind a Window object for native widget rendering purposes. @@ -83,7 +115,7 @@ sal_Bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart sal_Bool OutputDevice::HitTestNativeControl( ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, const Point& aPos, sal_Bool& rIsInside ) { @@ -95,7 +127,7 @@ sal_Bool OutputDevice::HitTestNativeControl( ControlType nType, return sal_False; Point aWinOffs( mnOutOffX, mnOutOffY ); - Region screenRegion( rControlRegion ); + Rectangle screenRegion( rControlRegion ); screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); return( mpGraphics->HitTestNativeControl(nType, nPart, screenRegion, Point( aPos.X() + mnOutOffX, aPos.Y() + mnOutOffY ), @@ -104,47 +136,117 @@ sal_Bool OutputDevice::HitTestNativeControl( ControlType nType, // ----------------------------------------------------------------------- -static void lcl_moveControlValue( ControlType nType, const ImplControlValue& aValue, const Point& rDelta ) +static boost::shared_ptr< ImplControlValue > lcl_transformControlValue( const ImplControlValue& rVal, OutputDevice& rDev ) { - if( aValue.getOptionalVal() ) + boost::shared_ptr< ImplControlValue > aResult; + switch( rVal.getType() ) { - switch( nType ) + case CTRL_SLIDER: { - case CTRL_SLIDER: - { - SliderValue* pSlVal = reinterpret_cast<SliderValue*>(aValue.getOptionalVal()); - pSlVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_SCROLLBAR: - { - ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(aValue.getOptionalVal()); - pScVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); - pScVal->maButton1Rect.Move( rDelta.X(), rDelta.Y() ); - pScVal->maButton2Rect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_SPINBOX: - case CTRL_SPINBUTTONS: - { - SpinbuttonValue* pSpVal = reinterpret_cast<SpinbuttonValue*>(aValue.getOptionalVal()); - pSpVal->maUpperRect.Move( rDelta.X(), rDelta.Y() ); - pSpVal->maLowerRect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_TOOLBAR: - { - ToolbarValue* pTVal = reinterpret_cast<ToolbarValue*>(aValue.getOptionalVal()); - pTVal->maGripRect.Move( rDelta.X(), rDelta.Y() ); - } + const SliderValue* pSlVal = static_cast<const SliderValue*>(&rVal); + SliderValue* pNew = new SliderValue( *pSlVal ); + aResult.reset( pNew ); + pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pSlVal->maThumbRect ); + } + break; + case CTRL_SCROLLBAR: + { + const ScrollbarValue* pScVal = static_cast<const ScrollbarValue*>(&rVal); + ScrollbarValue* pNew = new ScrollbarValue( *pScVal ); + aResult.reset( pNew ); + pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pScVal->maThumbRect ); + pNew->maButton1Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton1Rect ); + pNew->maButton2Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton2Rect ); + } + break; + case CTRL_SPINBUTTONS: + { + const SpinbuttonValue* pSpVal = static_cast<const SpinbuttonValue*>(&rVal); + SpinbuttonValue* pNew = new SpinbuttonValue( *pSpVal ); + aResult.reset( pNew ); + pNew->maUpperRect = rDev.ImplLogicToDevicePixel( pSpVal->maUpperRect ); + pNew->maLowerRect = rDev.ImplLogicToDevicePixel( pSpVal->maLowerRect ); + } + break; + case CTRL_TOOLBAR: + { + const ToolbarValue* pTVal = static_cast<const ToolbarValue*>(&rVal); + ToolbarValue* pNew = new ToolbarValue( *pTVal ); + aResult.reset( pNew ); + pNew->maGripRect = rDev.ImplLogicToDevicePixel( pTVal->maGripRect ); + } + break; + case CTRL_TAB_ITEM: + { + const TabitemValue* pTIVal = static_cast<const TabitemValue*>(&rVal); + TabitemValue* pNew = new TabitemValue( *pTIVal ); + aResult.reset( pNew ); + } + break; + case CTRL_MENUBAR: + { + const MenubarValue* pMVal = static_cast<const MenubarValue*>(&rVal); + MenubarValue* pNew = new MenubarValue( *pMVal ); + aResult.reset( pNew ); + } + break; + case CTRL_PUSHBUTTON: + { + const PushButtonValue* pBVal = static_cast<const PushButtonValue*>(&rVal); + PushButtonValue* pNew = new PushButtonValue( *pBVal ); + aResult.reset( pNew ); + } + break; + case CTRL_GENERIC: + aResult.reset( new ImplControlValue( rVal ) ); break; + default: + OSL_ENSURE( 0, "unknown ImplControlValue type !" ); + break; + } + return aResult; +} + +#if 0 +static void lcl_moveControlValue( ControlType nType, const ImplControlValue& aValue, const Point& rDelta ) +{ + switch( aValue.getType() ) + { + case CTRL_SLIDER: + { + SliderValue* pSlVal = static_cast<SliderValue*>(const_cast<ImplControlValue*>(&aValue)); + pSlVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_SCROLLBAR: + { + ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(const_cast<ImplControlValue*>(&aValue)); + pScVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); + pScVal->maButton1Rect.Move( rDelta.X(), rDelta.Y() ); + pScVal->maButton2Rect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_SPINBOX: + case CTRL_SPINBUTTONS: + { + SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(const_cast<ImplControlValue*>(&aValue)); + pSpVal->maUpperRect.Move( rDelta.X(), rDelta.Y() ); + pSpVal->maLowerRect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_TOOLBAR: + { + ToolbarValue* pTVal = static_cast<ToolbarValue*>(const_cast<ImplControlValue*>(&aValue)); + pTVal->maGripRect.Move( rDelta.X(), rDelta.Y() ); } + break; } } +#endif sal_Bool OutputDevice::DrawNativeControl( ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, ::rtl::OUString aCaption ) @@ -183,22 +285,15 @@ sal_Bool OutputDevice::DrawNativeControl( ControlType nType, // Convert the coordinates from relative to Window-absolute, so we draw // in the correct place in platform code - Point aWinOffs( mnOutOffX, mnOutOffY ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - - // do so for ImplControlValue members, also - lcl_moveControlValue( nType, aValue, aWinOffs ); + boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) ); + Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) ); Region aTestRegion( GetActiveClipRegion() ); aTestRegion.Intersect( rControlRegion ); if( aTestRegion == rControlRegion ) nState |= CTRL_CACHING_ALLOWED; // control is not clipped, caching allowed - sal_Bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, aValue, aCaption, this ); - - // transform back ImplControlValue members - lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); + sal_Bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this ); return bRet; } @@ -208,7 +303,7 @@ sal_Bool OutputDevice::DrawNativeControl( ControlType nType, sal_Bool OutputDevice::DrawNativeControlText(ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, ::rtl::OUString aCaption ) @@ -233,15 +328,10 @@ sal_Bool OutputDevice::DrawNativeControlText(ControlType nType, // Convert the coordinates from relative to Window-absolute, so we draw // in the correct place in platform code - Point aWinOffs( mnOutOffX, mnOutOffY ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - lcl_moveControlValue( nType, aValue, aWinOffs ); - - sal_Bool bRet = mpGraphics->DrawNativeControlText(nType, nPart, screenRegion, nState, aValue, aCaption, this ); + boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) ); + Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) ); - // transform back ImplControlValue members - lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); + sal_Bool bRet = mpGraphics->DrawNativeControlText(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this ); return bRet; } @@ -251,12 +341,12 @@ sal_Bool OutputDevice::DrawNativeControlText(ControlType nType, sal_Bool OutputDevice::GetNativeControlRegion( ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, ::rtl::OUString aCaption, - Region &rNativeBoundingRegion, - Region &rNativeContentRegion ) + Rectangle &rNativeBoundingRegion, + Rectangle &rNativeContentRegion ) { if( !lcl_enableNativeWidget( *this ) ) return sal_False; @@ -267,22 +357,18 @@ sal_Bool OutputDevice::GetNativeControlRegion( ControlType nType, // Convert the coordinates from relative to Window-absolute, so we draw // in the correct place in platform code - Point aWinOffs( mnOutOffX, mnOutOffY ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - lcl_moveControlValue( nType, aValue, aWinOffs ); + boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) ); + Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) ); - sal_Bool bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, aValue, + sal_Bool bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, rNativeBoundingRegion, rNativeContentRegion, this ); if( bRet ) { // transform back native regions - rNativeBoundingRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); - rNativeContentRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); + rNativeBoundingRegion = ImplDevicePixelToLogic( rNativeBoundingRegion ); + rNativeContentRegion = ImplDevicePixelToLogic( rNativeContentRegion ); } - // transform back ImplControlValue members - lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); return bRet; } diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index e9140cffc6a0..3f9024e257d5 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -40,7 +40,7 @@ PDFWriter::AnyWidget::~AnyWidget() PDFWriter::PDFWriter( const PDFWriter::PDFWriterContext& rContext ) : - pImplementation( new PDFWriterImpl( rContext ) ) + pImplementation( new PDFWriterImpl( rContext, *this ) ) { } @@ -569,3 +569,8 @@ std::set< PDFWriter::ErrorCode > PDFWriter::GetErrors() { return ((PDFWriterImpl*)pImplementation)->getErrors(); } + +void PDFWriter::PlayMetafile( const GDIMetaFile& i_rMTF, const vcl::PDFWriter::PlayMetafileContext& i_rPlayContext, PDFExtOutDevData* i_pData ) +{ + ((PDFWriterImpl*)pImplementation)->playMetafile( i_rMTF, i_pData, i_rPlayContext, NULL); +} diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 88e183040277..0d0963f72b5c 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -32,6 +32,7 @@ #include <math.h> #include <algorithm> +#include <tools/urlobj.hxx> #include <pdfwriter_impl.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> @@ -66,6 +67,7 @@ #include "cppuhelper/implbase1.hxx" #include <icc/sRGB-IEC61966-2.1.hxx> #include <vcl/lineinfo.hxx> +#include "vcl/strhelper.hxx" using namespace vcl; using namespace rtl; @@ -1691,7 +1693,7 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal * class PDFWriterImpl */ -PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext ) +PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, PDFWriter& i_rOuterFace ) : m_pReferenceDevice( NULL ), m_aMapMode( MAP_POINT, Point(), Fraction( 1L, pointToPixel(1) ), Fraction( 1L, pointToPixel(1) ) ), @@ -1717,7 +1719,8 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext ) m_aCreationMetaDateString( 64 ), m_pEncryptionBuffer( NULL ), m_nEncryptionBufferSize( 0 ), - m_bIsPDF_A1( false ) + m_bIsPDF_A1( false ), + m_rOuterFace( i_rOuterFace ) { #ifdef DO_TEST_PDF static bool bOnce = true; @@ -2136,7 +2139,10 @@ OutputDevice* PDFWriterImpl::getReferenceDevice() m_pReferenceDevice = pVDev; - pVDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_PDF1 ); + if( m_aContext.DPIx == 0 || m_aContext.DPIy == 0 ) + pVDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_PDF1 ); + else + pVDev->SetReferenceDevice( m_aContext.DPIx, m_aContext.DPIy ); pVDev->SetOutputSizePixel( Size( 640, 480 ) ); pVDev->SetMapMode( MAP_MM ); @@ -4081,15 +4087,15 @@ bool PDFWriterImpl::emitFonts() } else if( (aSubsetInfo.m_nFontType & FontSubsetInfo::TYPE1_PFB) != 0 ) // TODO: also support PFA? { - unsigned char* pBuffer = new unsigned char[ (int)nLength1 ]; + boost::shared_array<unsigned char> pBuffer( new unsigned char[ nLength1 ] ); sal_uInt64 nBytesRead = 0; - CHECK_RETURN( (osl_File_E_None == osl_readFile( aFontFile, pBuffer, nLength1, &nBytesRead ) ) ); + CHECK_RETURN( (osl_File_E_None == osl_readFile( aFontFile, pBuffer.get(), nLength1, &nBytesRead ) ) ); DBG_ASSERT( nBytesRead==nLength1, "PDF-FontSubset read incomplete!" ); CHECK_RETURN( (osl_File_E_None == osl_setFilePos( aFontFile, osl_Pos_Absolut, 0 ) ) ); // get the PFB-segment lengths ThreeInts aSegmentLengths = {0,0,0}; - getPfbSegmentLengths( pBuffer, (int)nBytesRead, aSegmentLengths ); + getPfbSegmentLengths( pBuffer.get(), (int)nBytesRead, aSegmentLengths ); // the lengths below are mandatory for PDF-exported Type1 fonts // because the PFB segment headers get stripped! WhyOhWhy. aLine.append( (sal_Int32)aSegmentLengths[0] ); @@ -4106,11 +4112,9 @@ bool PDFWriterImpl::emitFonts() // emit PFB-sections without section headers beginCompression(); checkAndEnableStreamEncryption( nFontStream ); - CHECK_RETURN( writeBuffer( pBuffer+ 6, aSegmentLengths[0] ) ); - CHECK_RETURN( writeBuffer( pBuffer+12 + aSegmentLengths[0], aSegmentLengths[1] ) ); - CHECK_RETURN( writeBuffer( pBuffer+18 + aSegmentLengths[0] + aSegmentLengths[1], aSegmentLengths[2] ) ); - - delete[] pBuffer; + CHECK_RETURN( writeBuffer( &pBuffer[6], aSegmentLengths[0] ) ); + CHECK_RETURN( writeBuffer( &pBuffer[12] + aSegmentLengths[0], aSegmentLengths[1] ) ); + CHECK_RETURN( writeBuffer( &pBuffer[18] + aSegmentLengths[0] + aSegmentLengths[1], aSegmentLengths[2] ) ); } else { @@ -8500,6 +8504,7 @@ void PDFWriterImpl::beginRedirect( SvStream* pStream, const Rectangle& rTargetRe { push( PUSH_ALL ); + // force reemitting clip region clearClipRegion(); updateGraphicsState(); @@ -8543,7 +8548,10 @@ SvStream* PDFWriterImpl::endRedirect() } pop(); - // force reemitting colors + // force reemitting colors and clip region + clearClipRegion(); + m_aCurrentPDFState.m_bClipRegion = m_aGraphicsStack.front().m_bClipRegion; + m_aCurrentPDFState.m_aClipRegion = m_aGraphicsStack.front().m_aClipRegion; m_aCurrentPDFState.m_aLineColor = Color( COL_TRANSPARENT ); m_aCurrentPDFState.m_aFillColor = Color( COL_TRANSPARENT ); @@ -10840,7 +10848,7 @@ sal_Int32 PDFWriterImpl::setOutlineItemText( sal_Int32 nItem, const OUString& rT if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) return -1; - m_aOutline[ nItem ].m_aTitle = rText; + m_aOutline[ nItem ].m_aTitle = psp::WhitespaceToSpace( rText ); return 0; } diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 85a470870dd9..a4b50b0bd3c1 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -1095,6 +1095,7 @@ i12626 /* true if PDF/A-1a or PDF/A-1b is output */ sal_Bool m_bIsPDF_A1; + PDFWriter& m_rOuterFace; /* i12626 @@ -1109,8 +1110,14 @@ methods for PDF security /* algorithm 3.4 or 3.5: computing the encryption dictionary's user password value ( /U ) revision 2 or 3 of the standard security handler */ void computeUDictionaryValue(); + // helper for playMetafile + void implWriteGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient, + VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& ); + void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx, + VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& ); + public: - PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext ); + PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, PDFWriter& ); ~PDFWriterImpl(); /* for OutputDevice so the reference device can have a list @@ -1134,6 +1141,7 @@ public: bool emit(); std::set< PDFWriter::ErrorCode > getErrors(); void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); } + void playMetafile( const GDIMetaFile&, vcl::PDFExtOutDevData*, const vcl::PDFWriter::PlayMetafileContext&, VirtualDevice* pDummyDev = NULL ); Size getCurPageSize() const { diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx new file mode 100644 index 000000000000..0f11310572e6 --- /dev/null +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -0,0 +1,1035 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +#include "precompiled_vcl.hxx" + +#include "pdfwriter_impl.hxx" +#include "vcl/pdfextoutdevdata.hxx" +#include "vcl/virdev.hxx" +#include "vcl/gdimtf.hxx" +#include "vcl/metaact.hxx" +#include "vcl/graph.hxx" +#include "vcl/svdata.hxx" +#include "unotools/streamwrap.hxx" +#include "unotools/processfactory.hxx" + +#include "comphelper/processfactory.hxx" +#include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/io/XSeekable.hpp" +#include "com/sun/star/graphic/XGraphicProvider.hpp" + +using namespace vcl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; + +// ----------------------------------------------------------------------------- + +void PDFWriterImpl::implWriteGradient( const PolyPolygon& i_rPolyPoly, const Gradient& i_rGradient, + VirtualDevice* i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext ) +{ + GDIMetaFile aTmpMtf; + + i_pDummyVDev->AddGradientActions( i_rPolyPoly.GetBoundRect(), i_rGradient, aTmpMtf ); + + m_rOuterFace.Push(); + m_rOuterFace.IntersectClipRegion( i_rPolyPoly.getB2DPolyPolygon() ); + playMetafile( aTmpMtf, NULL, i_rContext, i_pDummyVDev ); + m_rOuterFace.Pop(); +} + +// ----------------------------------------------------------------------------- + +void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSize, const BitmapEx& i_rBitmapEx, + VirtualDevice* i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext ) +{ + if ( !i_rBitmapEx.IsEmpty() && i_rSize.Width() && i_rSize.Height() ) + { + BitmapEx aBitmapEx( i_rBitmapEx ); + Point aPoint( i_rPoint ); + Size aSize( i_rSize ); + + // #i19065# Negative sizes have mirror semantics on + // OutputDevice. BitmapEx and co. have no idea about that, so + // perform that _before_ doing anything with aBitmapEx. + sal_uIntPtr nMirrorFlags(BMP_MIRROR_NONE); + if( aSize.Width() < 0 ) + { + aSize.Width() *= -1; + aPoint.X() -= aSize.Width(); + nMirrorFlags |= BMP_MIRROR_HORZ; + } + if( aSize.Height() < 0 ) + { + aSize.Height() *= -1; + aPoint.Y() -= aSize.Height(); + nMirrorFlags |= BMP_MIRROR_VERT; + } + + if( nMirrorFlags != BMP_MIRROR_NONE ) + { + aBitmapEx.Mirror( nMirrorFlags ); + } + if( i_rContext.m_nMaxImageResolution > 50 ) + { + // do downsampling if neccessary + const Size aDstSizeTwip( i_pDummyVDev->PixelToLogic( i_pDummyVDev->LogicToPixel( aSize ), MAP_TWIP ) ); + const Size aBmpSize( aBitmapEx.GetSizePixel() ); + const double fBmpPixelX = aBmpSize.Width(); + const double fBmpPixelY = aBmpSize.Height(); + const double fMaxPixelX = aDstSizeTwip.Width() * i_rContext.m_nMaxImageResolution / 1440.0; + const double fMaxPixelY = aDstSizeTwip.Height() * i_rContext.m_nMaxImageResolution / 1440.0; + + // check, if the bitmap DPI exceeds the maximum DPI (allow 4 pixel rounding tolerance) + if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) || + ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) && + ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) ) + { + // do scaling + Size aNewBmpSize; + const double fBmpWH = fBmpPixelX / fBmpPixelY; + const double fMaxWH = fMaxPixelX / fMaxPixelY; + + if( fBmpWH < fMaxWH ) + { + aNewBmpSize.Width() = FRound( fMaxPixelY * fBmpWH ); + aNewBmpSize.Height() = FRound( fMaxPixelY ); + } + else if( fBmpWH > 0.0 ) + { + aNewBmpSize.Width() = FRound( fMaxPixelX ); + aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH); + } + if( aNewBmpSize.Width() && aNewBmpSize.Height() ) + aBitmapEx.Scale( aNewBmpSize ); + else + aBitmapEx.SetEmpty(); + } + } + + const Size aSizePixel( aBitmapEx.GetSizePixel() ); + if ( aSizePixel.Width() && aSizePixel.Height() ) + { + sal_Bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression; + if ( ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) ) + bUseJPGCompression = sal_False; + + SvMemoryStream aStrm; + Bitmap aMask; + + bool bTrueColorJPG = true; + if ( bUseJPGCompression ) + { + sal_uInt32 nZippedFileSize; // sj: we will calculate the filesize of a zipped bitmap + { // to determine if jpeg compression is usefull + SvMemoryStream aTemp; + aTemp.SetCompressMode( aTemp.GetCompressMode() | COMPRESSMODE_ZBITMAP ); + aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator + aTemp << aBitmapEx; // is capable of zlib stream compression + aTemp.Seek( STREAM_SEEK_TO_END ); + nZippedFileSize = aTemp.Tell(); + } + if ( aBitmapEx.IsTransparent() ) + { + if ( aBitmapEx.IsAlpha() ) + aMask = aBitmapEx.GetAlpha().GetBitmap(); + else + aMask = aBitmapEx.GetMask(); + } + Graphic aGraphic( aBitmapEx.GetBitmap() ); + sal_Int32 nColorMode = 0; + + Sequence< PropertyValue > aFilterData( 2 ); + aFilterData[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ); + aFilterData[ 0 ].Value <<= sal_Int32(i_rContext.m_nJPEGQuality); + aFilterData[ 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColorMode" ) ); + aFilterData[ 1 ].Value <<= nColorMode; + + try + { + uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( aStrm ); + Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xGraphicProvider( ImplGetSVData()->maAppData.mxMSF->createInstance( + OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ); + if ( xGraphicProvider.is() ) + { + Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); + Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); + rtl::OUString aMimeType( ::rtl::OUString::createFromAscii( "image/jpeg" ) ); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); + aOutMediaProperties[0].Name = ::rtl::OUString::createFromAscii( "OutputStream" ); + aOutMediaProperties[0].Value <<= xOut; + aOutMediaProperties[1].Name = ::rtl::OUString::createFromAscii( "MimeType" ); + aOutMediaProperties[1].Value <<= aMimeType; + aOutMediaProperties[2].Name = ::rtl::OUString::createFromAscii( "FilterData" ); + aOutMediaProperties[2].Value <<= aFilterData; + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + xOut->flush(); + if ( xSeekable->getLength() > nZippedFileSize ) + { + bUseJPGCompression = sal_False; + } + else + { + aStrm.Seek( STREAM_SEEK_TO_END ); + + xSeekable->seek( 0 ); + Sequence< PropertyValue > aArgs( 1 ); + aArgs[ 0 ].Name = ::rtl::OUString::createFromAscii( "InputStream" ); + aArgs[ 0 ].Value <<= xStream; + Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); + if ( xPropSet.is() ) + { + sal_Int16 nBitsPerPixel = 24; + if ( xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "BitsPerPixel" ) ) >>= nBitsPerPixel ) + { + bTrueColorJPG = nBitsPerPixel != 8; + } + } + } + } + else + bUseJPGCompression = sal_False; + } + catch( uno::Exception& ) + { + bUseJPGCompression = sal_False; + } + } + if ( bUseJPGCompression ) + m_rOuterFace.DrawJPGBitmap( aStrm, bTrueColorJPG, aSizePixel, Rectangle( aPoint, aSize ), aMask ); + else if ( aBitmapEx.IsTransparent() ) + m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx ); + else + m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap() ); + } + } +} + + +// ----------------------------------------------------------------------------- + +void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevData* i_pOutDevData, const vcl::PDFWriter::PlayMetafileContext& i_rContext, VirtualDevice* pDummyVDev ) +{ + bool bAssertionFired( false ); + + VirtualDevice* pPrivateDevice = NULL; + if( ! pDummyVDev ) + { + pPrivateDevice = pDummyVDev = new VirtualDevice(); + pDummyVDev->EnableOutput( sal_False ); + pDummyVDev->SetMapMode( i_rMtf.GetPrefMapMode() ); + } + GDIMetaFile aMtf( i_rMtf ); + + for( sal_uInt32 i = 0, nCount = aMtf.GetActionCount(); i < nCount; ) + { + if ( !i_pOutDevData || !i_pOutDevData->PlaySyncPageAct( m_rOuterFace, i ) ) + { + const MetaAction* pAction = aMtf.GetAction( i ); + const sal_uInt16 nType = pAction->GetType(); + + switch( nType ) + { + case( META_PIXEL_ACTION ): + { + const MetaPixelAction* pA = (const MetaPixelAction*) pAction; + m_rOuterFace.DrawPixel( pA->GetPoint(), pA->GetColor() ); + } + break; + + case( META_POINT_ACTION ): + { + const MetaPointAction* pA = (const MetaPointAction*) pAction; + m_rOuterFace.DrawPixel( pA->GetPoint() ); + } + break; + + case( META_LINE_ACTION ): + { + const MetaLineAction* pA = (const MetaLineAction*) pAction; + if ( pA->GetLineInfo().IsDefault() ) + m_rOuterFace.DrawLine( pA->GetStartPoint(), pA->GetEndPoint() ); + else + m_rOuterFace.DrawLine( pA->GetStartPoint(), pA->GetEndPoint(), pA->GetLineInfo() ); + } + break; + + case( META_RECT_ACTION ): + { + const MetaRectAction* pA = (const MetaRectAction*) pAction; + m_rOuterFace.DrawRect( pA->GetRect() ); + } + break; + + case( META_ROUNDRECT_ACTION ): + { + const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction; + m_rOuterFace.DrawRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); + } + break; + + case( META_ELLIPSE_ACTION ): + { + const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction; + m_rOuterFace.DrawEllipse( pA->GetRect() ); + } + break; + + case( META_ARC_ACTION ): + { + const MetaArcAction* pA = (const MetaArcAction*) pAction; + m_rOuterFace.DrawArc( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case( META_PIE_ACTION ): + { + const MetaArcAction* pA = (const MetaArcAction*) pAction; + m_rOuterFace.DrawPie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case( META_CHORD_ACTION ): + { + const MetaChordAction* pA = (const MetaChordAction*) pAction; + m_rOuterFace.DrawChord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case( META_POLYGON_ACTION ): + { + const MetaPolygonAction* pA = (const MetaPolygonAction*) pAction; + m_rOuterFace.DrawPolygon( pA->GetPolygon() ); + } + break; + + case( META_POLYLINE_ACTION ): + { + const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction; + if ( pA->GetLineInfo().IsDefault() ) + m_rOuterFace.DrawPolyLine( pA->GetPolygon() ); + else + m_rOuterFace.DrawPolyLine( pA->GetPolygon(), pA->GetLineInfo() ); + } + break; + + case( META_POLYPOLYGON_ACTION ): + { + const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pAction; + m_rOuterFace.DrawPolyPolygon( pA->GetPolyPolygon() ); + } + break; + + case( META_GRADIENT_ACTION ): + { + const MetaGradientAction* pA = (const MetaGradientAction*) pAction; + const PolyPolygon aPolyPoly( pA->GetRect() ); + + implWriteGradient( aPolyPoly, pA->GetGradient(), pDummyVDev, i_rContext ); + } + break; + + case( META_GRADIENTEX_ACTION ): + { + const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction; + implWriteGradient( pA->GetPolyPolygon(), pA->GetGradient(), pDummyVDev, i_rContext ); + } + break; + + case META_HATCH_ACTION: + { + const MetaHatchAction* pA = (const MetaHatchAction*) pAction; + m_rOuterFace.DrawHatch( pA->GetPolyPolygon(), pA->GetHatch() ); + } + break; + + case( META_TRANSPARENT_ACTION ): + { + const MetaTransparentAction* pA = (const MetaTransparentAction*) pAction; + m_rOuterFace.DrawTransparent( pA->GetPolyPolygon(), pA->GetTransparence() ); + } + break; + + case( META_FLOATTRANSPARENT_ACTION ): + { + const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction; + + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); + const Point& rPos = pA->GetPoint(); + const Size& rSize= pA->GetSize(); + const Gradient& rTransparenceGradient = pA->GetGradient(); + + // special case constant alpha value + if( rTransparenceGradient.GetStartColor() == rTransparenceGradient.GetEndColor() ) + { + const Color aTransCol( rTransparenceGradient.GetStartColor() ); + const sal_uInt16 nTransPercent = aTransCol.GetLuminance() * 100 / 255; + m_rOuterFace.BeginTransparencyGroup(); + playMetafile( aTmpMtf, NULL, i_rContext, pDummyVDev ); + m_rOuterFace.EndTransparencyGroup( Rectangle( rPos, rSize ), nTransPercent ); + } + else + { + const Size aDstSizeTwip( pDummyVDev->PixelToLogic( pDummyVDev->LogicToPixel( rSize ), MAP_TWIP ) ); + sal_Int32 nMaxBmpDPI = i_rContext.m_bOnlyLosslessCompression ? 300 : 72; + if( i_rContext.m_nMaxImageResolution > 50 ) + { + if ( nMaxBmpDPI > i_rContext.m_nMaxImageResolution ) + nMaxBmpDPI = i_rContext.m_nMaxImageResolution; + } + const sal_Int32 nPixelX = (sal_Int32)((double)aDstSizeTwip.Width() * (double)nMaxBmpDPI / 1440.0); + const sal_Int32 nPixelY = (sal_Int32)((double)aDstSizeTwip.Height() * (double)nMaxBmpDPI / 1440.0); + if ( nPixelX && nPixelY ) + { + Size aDstSizePixel( nPixelX, nPixelY ); + VirtualDevice* pVDev = new VirtualDevice; + if( pVDev->SetOutputSizePixel( aDstSizePixel ) ) + { + Bitmap aPaint, aMask; + AlphaMask aAlpha; + Point aPoint; + + MapMode aMapMode( pDummyVDev->GetMapMode() ); + aMapMode.SetOrigin( aPoint ); + pVDev->SetMapMode( aMapMode ); + Size aDstSize( pVDev->PixelToLogic( aDstSizePixel ) ); + + Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() ); + if ( aMtfOrigin.X() || aMtfOrigin.Y() ) + aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() ); + double fScaleX = (double)aDstSize.Width() / (double)aTmpMtf.GetPrefSize().Width(); + double fScaleY = (double)aDstSize.Height() / (double)aTmpMtf.GetPrefSize().Height(); + if( fScaleX != 1.0 || fScaleY != 1.0 ) + aTmpMtf.Scale( fScaleX, fScaleY ); + aTmpMtf.SetPrefMapMode( aMapMode ); + + // create paint bitmap + aTmpMtf.WindStart(); + aTmpMtf.Play( pVDev, aPoint, aDstSize ); + aTmpMtf.WindStart(); + + pVDev->EnableMapMode( sal_False ); + aPaint = pVDev->GetBitmap( aPoint, aDstSizePixel ); + pVDev->EnableMapMode( sal_True ); + + // create mask bitmap + pVDev->SetLineColor( COL_BLACK ); + pVDev->SetFillColor( COL_BLACK ); + pVDev->DrawRect( Rectangle( aPoint, aDstSize ) ); + pVDev->SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT | + DRAWMODE_WHITEBITMAP | DRAWMODE_WHITEGRADIENT ); + aTmpMtf.WindStart(); + aTmpMtf.Play( pVDev, aPoint, aDstSize ); + aTmpMtf.WindStart(); + pVDev->EnableMapMode( sal_False ); + aMask = pVDev->GetBitmap( aPoint, aDstSizePixel ); + pVDev->EnableMapMode( sal_True ); + + // create alpha mask from gradient + pVDev->SetDrawMode( DRAWMODE_GRAYGRADIENT ); + pVDev->DrawGradient( Rectangle( aPoint, aDstSize ), rTransparenceGradient ); + pVDev->SetDrawMode( DRAWMODE_DEFAULT ); + pVDev->EnableMapMode( sal_False ); + pVDev->DrawMask( aPoint, aDstSizePixel, aMask, Color( COL_WHITE ) ); + aAlpha = pVDev->GetBitmap( aPoint, aDstSizePixel ); + implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), pDummyVDev, i_rContext ); + } + delete pVDev; + } + } + } + break; + + case( META_EPS_ACTION ): + { + const MetaEPSAction* pA = (const MetaEPSAction*) pAction; + const GDIMetaFile aSubstitute( pA->GetSubstitute() ); + + m_rOuterFace.Push(); + pDummyVDev->Push(); + + MapMode aMapMode( aSubstitute.GetPrefMapMode() ); + Size aOutSize( pDummyVDev->LogicToLogic( pA->GetSize(), pDummyVDev->GetMapMode(), aMapMode ) ); + aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); + aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); + aMapMode.SetOrigin( pDummyVDev->LogicToLogic( pA->GetPoint(), pDummyVDev->GetMapMode(), aMapMode ) ); + + m_rOuterFace.SetMapMode( aMapMode ); + pDummyVDev->SetMapMode( aMapMode ); + playMetafile( aSubstitute, NULL, i_rContext, pDummyVDev ); + pDummyVDev->Pop(); + m_rOuterFace.Pop(); + } + break; + + case( META_COMMENT_ACTION ): + if( ! i_rContext.m_bTransparenciesWereRemoved ) + { + const MetaCommentAction* pA = (const MetaCommentAction*) pAction; + String aSkipComment; + + if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + { + const MetaGradientExAction* pGradAction = NULL; + sal_Bool bDone = sal_False; + + while( !bDone && ( ++i < nCount ) ) + { + pAction = aMtf.GetAction( i ); + + if( pAction->GetType() == META_GRADIENTEX_ACTION ) + pGradAction = (const MetaGradientExAction*) pAction; + else if( ( pAction->GetType() == META_COMMENT_ACTION ) && + ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + { + bDone = sal_True; + } + } + + if( pGradAction ) + implWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), pDummyVDev, i_rContext ); + } + else + { + const sal_uInt8* pData = pA->GetData(); + if ( pData ) + { + SvMemoryStream aMemStm( (void*)pData, pA->GetDataSize(), STREAM_READ ); + sal_Bool bSkipSequence = sal_False; + ByteString sSeqEnd; + + if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) ) + { + sSeqEnd = ByteString( "XPATHSTROKE_SEQ_END" ); + SvtGraphicStroke aStroke; + aMemStm >> aStroke; + + Polygon aPath; + aStroke.getPath( aPath ); + + PolyPolygon aStartArrow; + PolyPolygon aEndArrow; + double fTransparency( aStroke.getTransparency() ); + double fStrokeWidth( aStroke.getStrokeWidth() ); + SvtGraphicStroke::DashArray aDashArray; + + aStroke.getStartArrow( aStartArrow ); + aStroke.getEndArrow( aEndArrow ); + aStroke.getDashArray( aDashArray ); + + bSkipSequence = sal_True; + if ( aStartArrow.Count() || aEndArrow.Count() ) + bSkipSequence = sal_False; + if ( aDashArray.size() && ( fStrokeWidth != 0.0 ) && ( fTransparency == 0.0 ) ) + bSkipSequence = sal_False; + if ( bSkipSequence ) + { + PDFWriter::ExtLineInfo aInfo; + aInfo.m_fLineWidth = fStrokeWidth; + aInfo.m_fTransparency = fTransparency; + aInfo.m_fMiterLimit = aStroke.getMiterLimit(); + switch( aStroke.getCapType() ) + { + default: + case SvtGraphicStroke::capButt: aInfo.m_eCap = PDFWriter::capButt;break; + case SvtGraphicStroke::capRound: aInfo.m_eCap = PDFWriter::capRound;break; + case SvtGraphicStroke::capSquare: aInfo.m_eCap = PDFWriter::capSquare;break; + } + switch( aStroke.getJoinType() ) + { + default: + case SvtGraphicStroke::joinMiter: aInfo.m_eJoin = PDFWriter::joinMiter;break; + case SvtGraphicStroke::joinRound: aInfo.m_eJoin = PDFWriter::joinRound;break; + case SvtGraphicStroke::joinBevel: aInfo.m_eJoin = PDFWriter::joinBevel;break; + case SvtGraphicStroke::joinNone: + aInfo.m_eJoin = PDFWriter::joinMiter; + aInfo.m_fMiterLimit = 0.0; + break; + } + aInfo.m_aDashArray = aDashArray; + + if(SvtGraphicStroke::joinNone == aStroke.getJoinType() + && fStrokeWidth > 0.0) + { + // emulate no edge rounding by handling single edges + const sal_uInt16 nPoints(aPath.GetSize()); + const bool bCurve(aPath.HasFlags()); + + for(sal_uInt16 a(0); a + 1 < nPoints; a++) + { + if(bCurve + && POLY_NORMAL != aPath.GetFlags(a + 1) + && a + 2 < nPoints + && POLY_NORMAL != aPath.GetFlags(a + 2) + && a + 3 < nPoints) + { + const Polygon aSnippet(4, + aPath.GetConstPointAry() + a, + aPath.GetConstFlagAry() + a); + m_rOuterFace.DrawPolyLine( aSnippet, aInfo ); + a += 2; + } + else + { + const Polygon aSnippet(2, + aPath.GetConstPointAry() + a); + m_rOuterFace.DrawPolyLine( aSnippet, aInfo ); + } + } + } + else + { + m_rOuterFace.DrawPolyLine( aPath, aInfo ); + } + } + } + else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) + { + sSeqEnd = ByteString( "XPATHFILL_SEQ_END" ); + SvtGraphicFill aFill; + aMemStm >> aFill; + + if ( ( aFill.getFillType() == SvtGraphicFill::fillSolid ) && ( aFill.getFillRule() == SvtGraphicFill::fillEvenOdd ) ) + { + double fTransparency = aFill.getTransparency(); + if ( fTransparency == 0.0 ) + { + PolyPolygon aPath; + aFill.getPath( aPath ); + + bSkipSequence = sal_True; + m_rOuterFace.DrawPolyPolygon( aPath ); + } + else if ( fTransparency == 1.0 ) + bSkipSequence = sal_True; + } +/* #i81548# removing optimization for fill textures, because most of the texture settings are not + exported properly. In OpenOffice 3.1 the drawing layer will support graphic primitives, then it + will not be a problem to optimize the filltexture export. But for wysiwyg is more important than + filesize. + else if( aFill.getFillType() == SvtGraphicFill::fillTexture && aFill.isTiling() ) + { + sal_Int32 nPattern = mnCachePatternId; + Graphic aPatternGraphic; + aFill.getGraphic( aPatternGraphic ); + bool bUseCache = false; + SvtGraphicFill::Transform aPatTransform; + aFill.getTransform( aPatTransform ); + + if( mnCachePatternId >= 0 ) + { + SvtGraphicFill::Transform aCacheTransform; + maCacheFill.getTransform( aCacheTransform ); + if( aCacheTransform.matrix[0] == aPatTransform.matrix[0] && + aCacheTransform.matrix[1] == aPatTransform.matrix[1] && + aCacheTransform.matrix[2] == aPatTransform.matrix[2] && + aCacheTransform.matrix[3] == aPatTransform.matrix[3] && + aCacheTransform.matrix[4] == aPatTransform.matrix[4] && + aCacheTransform.matrix[5] == aPatTransform.matrix[5] + ) + { + Graphic aCacheGraphic; + maCacheFill.getGraphic( aCacheGraphic ); + if( aCacheGraphic == aPatternGraphic ) + bUseCache = true; + } + } + + if( ! bUseCache ) + { + + // paint graphic to metafile + GDIMetaFile aPattern; + pDummyVDev->SetConnectMetaFile( &aPattern ); + pDummyVDev->Push(); + pDummyVDev->SetMapMode( aPatternGraphic.GetPrefMapMode() ); + + aPatternGraphic.Draw( &rDummyVDev, Point( 0, 0 ) ); + pDummyVDev->Pop(); + pDummyVDev->SetConnectMetaFile( NULL ); + aPattern.WindStart(); + + MapMode aPatternMapMode( aPatternGraphic.GetPrefMapMode() ); + // prepare pattern from metafile + Size aPrefSize( aPatternGraphic.GetPrefSize() ); + // FIXME: this magic -1 shouldn't be necessary + aPrefSize.Width() -= 1; + aPrefSize.Height() -= 1; + aPrefSize = m_rOuterFace.GetReferenceDevice()-> + LogicToLogic( aPrefSize, + &aPatternMapMode, + &m_rOuterFace.GetReferenceDevice()->GetMapMode() ); + // build bounding rectangle of pattern + Rectangle aBound( Point( 0, 0 ), aPrefSize ); + m_rOuterFace.BeginPattern( aBound ); + m_rOuterFace.Push(); + pDummyVDev->Push(); + m_rOuterFace.SetMapMode( aPatternMapMode ); + pDummyVDev->SetMapMode( aPatternMapMode ); + ImplWriteActions( m_rOuterFace, NULL, aPattern, rDummyVDev ); + pDummyVDev->Pop(); + m_rOuterFace.Pop(); + + nPattern = m_rOuterFace.EndPattern( aPatTransform ); + + // try some caching and reuse pattern + mnCachePatternId = nPattern; + maCacheFill = aFill; + } + + // draw polypolygon with pattern fill + PolyPolygon aPath; + aFill.getPath( aPath ); + m_rOuterFace.DrawPolyPolygon( aPath, nPattern, aFill.getFillRule() == SvtGraphicFill::fillEvenOdd ); + + bSkipSequence = sal_True; + } +*/ + } + if ( bSkipSequence ) + { + while( ++i < nCount ) + { + pAction = aMtf.GetAction( i ); + if ( pAction->GetType() == META_COMMENT_ACTION ) + { + ByteString sComment( ((MetaCommentAction*)pAction)->GetComment() ); + if ( sComment.Equals( sSeqEnd ) ) + break; + } + // #i44496# + // the replacement action for stroke is a filled rectangle + // the set fillcolor of the replacement is part of the graphics + // state and must not be skipped + else if( pAction->GetType() == META_FILLCOLOR_ACTION ) + { + const MetaFillColorAction* pMA = (const MetaFillColorAction*) pAction; + if( pMA->IsSetting() ) + m_rOuterFace.SetFillColor( pMA->GetColor() ); + else + m_rOuterFace.SetFillColor(); + } + } + } + } + } + } + break; + + case( META_BMP_ACTION ): + { + const MetaBmpAction* pA = (const MetaBmpAction*) pAction; + BitmapEx aBitmapEx( pA->GetBitmap() ); + Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(), + aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); + if( ! ( aSize.Width() && aSize.Height() ) ) + aSize = pDummyVDev->PixelToLogic( aBitmapEx.GetSizePixel() ); + implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pDummyVDev, i_rContext ); + } + break; + + case( META_BMPSCALE_ACTION ): + { + const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction; + implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), BitmapEx( pA->GetBitmap() ), pDummyVDev, i_rContext ); + } + break; + + case( META_BMPSCALEPART_ACTION ): + { + const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction; + BitmapEx aBitmapEx( pA->GetBitmap() ); + aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pDummyVDev, i_rContext ); + } + break; + + case( META_BMPEX_ACTION ): + { + const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction; + BitmapEx aBitmapEx( pA->GetBitmapEx() ); + Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(), + aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); + implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pDummyVDev, i_rContext ); + } + break; + + case( META_BMPEXSCALE_ACTION ): + { + const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction; + implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), pDummyVDev, i_rContext ); + } + break; + + case( META_BMPEXSCALEPART_ACTION ): + { + const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction; + BitmapEx aBitmapEx( pA->GetBitmapEx() ); + aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pDummyVDev, i_rContext ); + } + break; + + case( META_MASK_ACTION ): + case( META_MASKSCALE_ACTION ): + case( META_MASKSCALEPART_ACTION ): + { + DBG_ERROR( "MetaMask...Action not supported yet" ); + } + break; + + case( META_TEXT_ACTION ): + { + const MetaTextAction* pA = (const MetaTextAction*) pAction; + m_rOuterFace.DrawText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ) ); + } + break; + + case( META_TEXTRECT_ACTION ): + { + const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; + m_rOuterFace.DrawText( pA->GetRect(), String( pA->GetText() ), pA->GetStyle() ); + } + break; + + case( META_TEXTARRAY_ACTION ): + { + const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; + m_rOuterFace.DrawTextArray( pA->GetPoint(), pA->GetText(), pA->GetDXArray(), pA->GetIndex(), pA->GetLen() ); + } + break; + + case( META_STRETCHTEXT_ACTION ): + { + const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction; + m_rOuterFace.DrawStretchText( pA->GetPoint(), pA->GetWidth(), pA->GetText(), pA->GetIndex(), pA->GetLen() ); + } + break; + + + case( META_TEXTLINE_ACTION ): + { + const MetaTextLineAction* pA = (const MetaTextLineAction*) pAction; + m_rOuterFace.DrawTextLine( pA->GetStartPoint(), pA->GetWidth(), pA->GetStrikeout(), pA->GetUnderline(), pA->GetOverline() ); + + } + break; + + case( META_CLIPREGION_ACTION ): + { + const MetaClipRegionAction* pA = (const MetaClipRegionAction*) pAction; + + if( pA->IsClipping() ) + { + if( pA->GetRegion().IsEmpty() ) + m_rOuterFace.SetClipRegion( basegfx::B2DPolyPolygon() ); + else + { + Region aReg( pA->GetRegion() ); + m_rOuterFace.SetClipRegion( aReg.ConvertToB2DPolyPolygon() ); + } + } + else + m_rOuterFace.SetClipRegion(); + } + break; + + case( META_ISECTRECTCLIPREGION_ACTION ): + { + const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pAction; + m_rOuterFace.IntersectClipRegion( pA->GetRect() ); + } + break; + + case( META_ISECTREGIONCLIPREGION_ACTION ): + { + const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*) pAction; + Region aReg( pA->GetRegion() ); + m_rOuterFace.IntersectClipRegion( aReg.ConvertToB2DPolyPolygon() ); + } + break; + + case( META_MOVECLIPREGION_ACTION ): + { + const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*) pAction; + m_rOuterFace.MoveClipRegion( pA->GetHorzMove(), pA->GetVertMove() ); + } + break; + + case( META_MAPMODE_ACTION ): + { + const_cast< MetaAction* >( pAction )->Execute( pDummyVDev ); + m_rOuterFace.SetMapMode( pDummyVDev->GetMapMode() ); + } + break; + + case( META_LINECOLOR_ACTION ): + { + const MetaLineColorAction* pA = (const MetaLineColorAction*) pAction; + + if( pA->IsSetting() ) + m_rOuterFace.SetLineColor( pA->GetColor() ); + else + m_rOuterFace.SetLineColor(); + } + break; + + case( META_FILLCOLOR_ACTION ): + { + const MetaFillColorAction* pA = (const MetaFillColorAction*) pAction; + + if( pA->IsSetting() ) + m_rOuterFace.SetFillColor( pA->GetColor() ); + else + m_rOuterFace.SetFillColor(); + } + break; + + case( META_TEXTLINECOLOR_ACTION ): + { + const MetaTextLineColorAction* pA = (const MetaTextLineColorAction*) pAction; + + if( pA->IsSetting() ) + m_rOuterFace.SetTextLineColor( pA->GetColor() ); + else + m_rOuterFace.SetTextLineColor(); + } + break; + + case( META_OVERLINECOLOR_ACTION ): + { + const MetaOverlineColorAction* pA = (const MetaOverlineColorAction*) pAction; + + if( pA->IsSetting() ) + m_rOuterFace.SetOverlineColor( pA->GetColor() ); + else + m_rOuterFace.SetOverlineColor(); + } + break; + + case( META_TEXTFILLCOLOR_ACTION ): + { + const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pAction; + + if( pA->IsSetting() ) + m_rOuterFace.SetTextFillColor( pA->GetColor() ); + else + m_rOuterFace.SetTextFillColor(); + } + break; + + case( META_TEXTCOLOR_ACTION ): + { + const MetaTextColorAction* pA = (const MetaTextColorAction*) pAction; + m_rOuterFace.SetTextColor( pA->GetColor() ); + } + break; + + case( META_TEXTALIGN_ACTION ): + { + const MetaTextAlignAction* pA = (const MetaTextAlignAction*) pAction; + m_rOuterFace.SetTextAlign( pA->GetTextAlign() ); + } + break; + + case( META_FONT_ACTION ): + { + const MetaFontAction* pA = (const MetaFontAction*) pAction; + m_rOuterFace.SetFont( pA->GetFont() ); + } + break; + + case( META_PUSH_ACTION ): + { + const MetaPushAction* pA = (const MetaPushAction*) pAction; + + pDummyVDev->Push( pA->GetFlags() ); + m_rOuterFace.Push( pA->GetFlags() ); + } + break; + + case( META_POP_ACTION ): + { + pDummyVDev->Pop(); + m_rOuterFace.Pop(); + } + break; + + case( META_LAYOUTMODE_ACTION ): + { + const MetaLayoutModeAction* pA = (const MetaLayoutModeAction*) pAction; + m_rOuterFace.SetLayoutMode( pA->GetLayoutMode() ); + } + break; + + case META_TEXTLANGUAGE_ACTION: + { + const MetaTextLanguageAction* pA = (const MetaTextLanguageAction*) pAction; + m_rOuterFace.SetDigitLanguage( pA->GetTextLanguage() ); + } + break; + + case( META_WALLPAPER_ACTION ): + { + const MetaWallpaperAction* pA = (const MetaWallpaperAction*) pAction; + m_rOuterFace.DrawWallpaper( pA->GetRect(), pA->GetWallpaper() ); + } + break; + + case( META_RASTEROP_ACTION ): + { + // !!! >>> we don't want to support this actions + } + break; + + case( META_REFPOINT_ACTION ): + { + // !!! >>> we don't want to support this actions + } + break; + + default: + // #i24604# Made assertion fire only once per + // metafile. The asserted actions here are all + // deprecated + if( !bAssertionFired ) + { + bAssertionFired = true; + DBG_ERROR( "PDFExport::ImplWriteActions: deprecated and unsupported MetaAction encountered" ); + } + break; + } + i++; + } + } + + delete pPrivateDevice; +} + + diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 5c2358ca667d..7faeb63dcd8a 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -404,9 +404,20 @@ static Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic break; case META_LINE_ACTION: - aActionBounds = Rectangle( static_cast<const MetaLineAction&>(rAct).GetStartPoint(), - static_cast<const MetaLineAction&>(rAct).GetEndPoint() ); + { + const MetaLineAction& rMetaLineAction = static_cast<const MetaLineAction&>(rAct); + aActionBounds = Rectangle( rMetaLineAction.GetStartPoint(), rMetaLineAction.GetEndPoint() ); + const long nLineWidth(rMetaLineAction.GetLineInfo().GetWidth()); + if(nLineWidth) + { + const long nHalfLineWidth((nLineWidth + 1) / 2); + aActionBounds.Left() -= nHalfLineWidth; + aActionBounds.Top() -= nHalfLineWidth; + aActionBounds.Right() += nHalfLineWidth; + aActionBounds.Bottom() += nHalfLineWidth; + } break; + } case META_RECT_ACTION: aActionBounds = static_cast<const MetaRectAction&>(rAct).GetRect(); @@ -446,8 +457,20 @@ static Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic break; case META_POLYLINE_ACTION: - aActionBounds = static_cast<const MetaPolyLineAction&>(rAct).GetPolygon().GetBoundRect(); + { + const MetaPolyLineAction& rMetaPolyLineAction = static_cast<const MetaPolyLineAction&>(rAct); + aActionBounds = rMetaPolyLineAction.GetPolygon().GetBoundRect(); + const long nLineWidth(rMetaPolyLineAction.GetLineInfo().GetWidth()); + if(nLineWidth) + { + const long nHalfLineWidth((nLineWidth + 1) / 2); + aActionBounds.Left() -= nHalfLineWidth; + aActionBounds.Top() -= nHalfLineWidth; + aActionBounds.Right() += nHalfLineWidth; + aActionBounds.Bottom() += nHalfLineWidth; + } break; + } case META_POLYGON_ACTION: aActionBounds = static_cast<const MetaPolygonAction&>(rAct).GetPolygon().GetBoundRect(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index ecb403117b6b..84c308eef65f 100644..100755 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -150,6 +150,7 @@ public: typedef std::hash_map< rtl::OUString, size_t, rtl::OUStringHash > PropertyToIndexMap; typedef std::hash_map< rtl::OUString, ControlDependency, rtl::OUStringHash > ControlDependencyMap; + typedef std::hash_map< rtl::OUString, Sequence< sal_Bool >, rtl::OUStringHash > ChoiceDisableMap; boost::shared_ptr<Printer> mpPrinter; Sequence< PropertyValue > maUIOptions; @@ -158,6 +159,7 @@ public: PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; + ChoiceDisableMap maChoiceDisableMap; sal_Bool mbFirstPage; sal_Bool mbLastPage; sal_Bool mbReversePageOrder; @@ -173,6 +175,7 @@ public: // if set, pages are centered and trimmed onto the fixed page Size maFixedPageSize; sal_Int32 mnDefaultPaperBin; + sal_Int32 mnFixedPaperBin; ImplPrinterControllerData() : mbFirstPage( sal_True ), @@ -180,21 +183,22 @@ public: mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ), - mnDefaultPaperBin( -1 ) + mnDefaultPaperBin( -1 ), + mnFixedPaperBin( -1 ) {} ~ImplPrinterControllerData() { delete mpProgress; } - Size getRealPaperSize( const Size& i_rPageSize ) const + Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const { if( maFixedPageSize.Width() > 0 && maFixedPageSize.Height() > 0 ) return maFixedPageSize; - if( maMultiPage.nRows * maMultiPage.nColumns > 1 ) + if( maMultiPage.nRows * maMultiPage.nColumns > 1 && ! bNoNUP ) return maMultiPage.aPaperSize; return i_rPageSize; } bool isFixedPageSize() const { return maFixedPageSize.Width() != 0 && maFixedPageSize.Height() != 0; } - PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps ); + PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP ); }; PrinterController::PrinterController() @@ -444,8 +448,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr if( ! aDlg.Execute() ) { GDIMetaFile aPageFile; - i_pController->setLastPage( sal_True ); - i_pController->getFilteredPageFile( 0, aPageFile ); + i_pController->abortJob(); return; } if( aDlg.isPrintToFile() ) @@ -453,9 +456,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr rtl::OUString aFile = queryFile( pController->getPrinter().get() ); if( ! aFile.getLength() ) { - GDIMetaFile aPageFile; - i_pController->setLastPage( sal_True ); - i_pController->getFilteredPageFile( 0, aPageFile ); + i_pController->abortJob(); return; } pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), @@ -557,7 +558,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: mnCurPage = 1; mnCurPrintPage = 1; mbPrinting = sal_True; - if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) + if( GetCapabilities( PRINTER_CAPABILITIES_USEPULLMODEL ) ) { mbJobActive = sal_True; // sallayer does all necessary page printing @@ -594,17 +595,25 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: i_pController->jobStarted(); int nJobs = 1; - int nRepeatCount = bUserCopy ? mnCopyCount : 1; + int nOuterRepeatCount = 1; + int nInnerRepeatCount = 1; + if( bUserCopy ) + { + if( mbCollateCopy ) + nOuterRepeatCount = mnCopyCount; + else + nInnerRepeatCount = mnCopyCount; + } if( bSinglePrintJobs ) { nJobs = mnCopyCount; nCopies = 1; - nRepeatCount = 1; + nOuterRepeatCount = nInnerRepeatCount = 1; } for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ ) { - bool bError = false; + bool bError = false, bAborted = false; if( mpPrinter->StartJob( pPrintFile, i_rJobName, Application::GetDisplayName(), @@ -616,13 +625,26 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: mbJobActive = sal_True; i_pController->createProgressDialog(); int nPages = i_pController->getFilteredPageCount(); - for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) + for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ ) { - for( int nPage = 0; nPage < nPages; nPage++ ) + for( int nPage = 0; nPage < nPages && ! bAborted; nPage++ ) { - if( nPage == nPages-1 && nIteration == nRepeatCount-1 && nJobIteration == nJobs-1 ) - i_pController->setLastPage( sal_True ); - i_pController->printFilteredPage( nPage ); + for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ ) + { + if( nPage == nPages-1 && + nOuterIteration == nOuterRepeatCount-1 && + nInnerIteration == nInnerRepeatCount-1 && + nJobIteration == nJobs-1 ) + { + i_pController->setLastPage( sal_True ); + } + i_pController->printFilteredPage( nPage ); + if( i_pController->isProgressCanceled() ) + { + i_pController->abortJob(); + bAborted = true; + } + } } // FIXME: duplex ? } @@ -708,6 +730,7 @@ void PrinterController::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), makeAny( rtl::OUString( i_rPrinter->GetName() ) ) ); mpImplData->mnDefaultPaperBin = mpImplData->mpPrinter->GetPaperBin(); + mpImplData->mnFixedPaperBin = -1; } bool PrinterController::setupPrinter( Window* i_pParent ) @@ -715,15 +738,20 @@ bool PrinterController::setupPrinter( Window* i_pParent ) bool bRet = false; if( mpImplData->mpPrinter.get() ) { + // get old data Size aPaperSize( mpImplData->mpPrinter->PixelToLogic( mpImplData->mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + sal_uInt16 nPaperBin = mpImplData->mpPrinter->GetPaperBin(); + + // call driver setup bRet = mpImplData->mpPrinter->Setup( i_pParent ); if( bRet ) { - // was the papersize overridden ? if so we need to take action + // was papersize or bin overridden ? if so we need to take action Size aNewPaperSize( mpImplData->mpPrinter->PixelToLogic( mpImplData->mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); - if( aNewPaperSize != aPaperSize ) + sal_uInt16 nNewPaperBin = mpImplData->mpPrinter->GetPaperBin(); + if( aNewPaperSize != aPaperSize || nNewPaperBin != nPaperBin ) { mpImplData->maFixedPageSize = aNewPaperSize; mpImplData->maPageCache.invalidate(); @@ -732,13 +760,14 @@ bool PrinterController::setupPrinter( Window* i_pParent ) aOverrideSize.Height = aNewPaperSize.Height(); setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OverridePageSize" ) ), makeAny( aOverrideSize ) ); + mpImplData->mnFixedPaperBin = nNewPaperBin; } } } return bRet; } -PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( const Sequence< PropertyValue >& i_rProps ) +PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP ) { PrinterController::PageSize aPageSize; aPageSize.aSize = mpPrinter->GetPaperSize(); @@ -773,7 +802,7 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons if( aSetSize.Width && aSetSize.Height ) { Size aSetPaperSize( aSetSize.Width, aSetSize.Height ); - Size aRealPaperSize( getRealPaperSize( aSetPaperSize ) ); + Size aRealPaperSize( getRealPaperSize( aSetPaperSize, bNoNUP ) ); if( aRealPaperSize != aCurSize ) aIsSize = aSetSize; } @@ -783,7 +812,7 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons aPageSize.aSize.Width() = aIsSize.Width; aPageSize.aSize.Height() = aIsSize.Height; - Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); + Size aRealPaperSize( getRealPaperSize( aPageSize.aSize, bNoNUP ) ); if( aRealPaperSize != aCurSize ) mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); } @@ -849,7 +878,7 @@ PrinterController::PageSize PrinterController::getPageFile( int i_nUnfilteredPag mpImplData->mpPrinter->SetMapMode( aMapMode ); // modify job setup if necessary - PrinterController::PageSize aPageSize = mpImplData->modifyJobSetup( aPageParm ); + PrinterController::PageSize aPageSize = mpImplData->modifyJobSetup( aPageParm, true ); o_rMtf.SetPrefSize( aPageSize.aSize ); o_rMtf.SetPrefMapMode( aMapMode ); @@ -931,7 +960,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 ) { PrinterController::PageSize aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); - Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize ); + Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize, true ); mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize, ! mpImplData->isFixedPageSize() ); if( aPaperSize != aPageSize.aSize ) @@ -940,7 +969,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte o_rMtf.WindStart(); long nDX = (aPaperSize.Width() - aPageSize.aSize.Width()) / 2; long nDY = (aPaperSize.Height() - aPageSize.aSize.Height()) / 2; - o_rMtf.Move( nDX, nDY ); + o_rMtf.Move( nDX, nDY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() ); o_rMtf.WindStart(); o_rMtf.SetPrefSize( aPaperSize ); aPageSize.aSize = aPaperSize; @@ -953,7 +982,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte sal_Bool bIsLastPage = mpImplData->mbLastPage; mpImplData->mbLastPage = sal_False; - Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) ); + Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize, false ) ); // multi page area: page size minus margins + one time spacing right and down // the added spacing is so each subpage can be calculated including its spacing @@ -1002,6 +1031,14 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte nCellX = (nSubPage / rMPS.nRows); nCellY = (nSubPage % rMPS.nRows); break; + case PrinterController::RLTB: + nCellX = rMPS.nColumns - 1 - (nSubPage % rMPS.nColumns); + nCellY = (nSubPage / rMPS.nColumns); + break; + case PrinterController::TBRL: + nCellX = rMPS.nColumns - 1 - (nSubPage / rMPS.nRows); + nCellY = (nSubPage % rMPS.nRows); + break; } // scale the metafile down to a sub page size double fScaleX = double(aSubPageSize.Width())/double(aPageSize.aSize.Width()); @@ -1015,7 +1052,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte long nOffY = (aSubPageSize.Height() - long(double(aPageSize.aSize.Height()) * fScale)) / 2; long nX = rMPS.nLeftMargin + nOffX + nAdvX * nCellX; long nY = rMPS.nTopMargin + nOffY + nAdvY * nCellY; - aPageFile.Move( nX, nY ); + aPageFile.Move( nX, nY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() ); aPageFile.WindStart(); // calculate border rectangle Rectangle aSubPageRect( Point( nX, nY ), @@ -1129,13 +1166,18 @@ void PrinterController::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); // aPageSize was filtered through mpImplData->getRealPaperSize already by getFilteredPageFile() mpImplData->mpPrinter->SetPaperSizeUser( aPageSize.aSize, ! mpImplData->isFixedPageSize() ); + if( mpImplData->mnFixedPaperBin != -1 && + mpImplData->mpPrinter->GetPaperBin() != mpImplData->mnFixedPaperBin ) + { + mpImplData->mpPrinter->SetPaperBin( mpImplData->mnFixedPaperBin ); + } - // if full paper are is meant, move the output to accomodate for pageoffset + // if full paper is meant to be used, move the output to accomodate for pageoffset if( aPageSize.bFullPaper ) { Point aPageOffset( mpImplData->mpPrinter->GetPageOffset() ); aPageFile.WindStart(); - aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y() ); + aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y(), mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() ); } GDIMetaFile aCleanedFile; @@ -1167,6 +1209,13 @@ void PrinterController::jobFinished( view::PrintableState ) void PrinterController::abortJob() { setJobState( view::PrintableState_JOB_ABORTED ); + // applications (well, sw) depend on a page request with "IsLastPage" = true + // to free resources, else they (well, sw) will crash eventually + setLastPage( sal_True ); + delete mpImplData->mpProgress; + mpImplData->mpProgress = NULL; + GDIMetaFile aMtf; + getPageFile( 0, aMtf, false ); } void PrinterController::setLastPage( sal_Bool i_bLastPage ) @@ -1299,6 +1348,7 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ bool bHaveProperty = false; rtl::OUString aPropName; vcl::ImplPrinterControllerData::ControlDependency aDep; + Sequence< sal_Bool > aChoicesDisabled; for( int n = 0; n < aOptProp.getLength(); n++ ) { const beans::PropertyValue& rEntry( aOptProp[ n ] ); @@ -1326,6 +1376,10 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ { rEntry.Value >>= aDep.mnDependsOnEntry; } + else if( rEntry.Name.equalsAscii( "ChoicesDisabled" ) ) + { + rEntry.Value >>= aChoicesDisabled; + } } if( bHaveProperty ) { @@ -1338,6 +1392,8 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ } if( aDep.maDependsOnName.getLength() > 0 ) mpImplData->maControlDependencies[ aPropName ] = aDep; + if( aChoicesDisabled.getLength() > 0 ) + mpImplData->maChoiceDisableMap[ aPropName ] = aChoicesDisabled; } } } @@ -1413,6 +1469,20 @@ bool PrinterController::isUIOptionEnabled( const rtl::OUString& i_rProperty ) co return bEnabled; } +bool PrinterController::isUIChoiceEnabled( const rtl::OUString& i_rProperty, sal_Int32 i_nValue ) const +{ + bool bEnabled = true; + ImplPrinterControllerData::ChoiceDisableMap::const_iterator it = + mpImplData->maChoiceDisableMap.find( i_rProperty ); + if(it != mpImplData->maChoiceDisableMap.end() ) + { + const Sequence< sal_Bool >& rDisabled( it->second ); + if( i_nValue >= 0 && i_nValue < rDisabled.getLength() ) + bEnabled = ! rDisabled[i_nValue]; + } + return bEnabled; +} + rtl::OUString PrinterController::getDependency( const rtl::OUString& i_rProperty ) const { rtl::OUString aDependency; @@ -1499,6 +1569,11 @@ void PrinterController::createProgressDialog() mpImplData->mpProgress->reset(); } +bool PrinterController::isProgressCanceled() const +{ + return mpImplData->mpProgress && mpImplData->mpProgress->isCanceled(); +} + void PrinterController::setMultipage( const MultiPageSetup& i_rMPS ) { mpImplData->maMultiPage = i_rMPS; @@ -1789,14 +1864,20 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, const Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, const rtl::OUString& i_rType, + const Sequence< sal_Bool >& i_rDisabledChoices, const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { UIControlOptions aOpt( i_rControlOptions ); sal_Int32 nUsed = aOpt.maAddProps.getLength(); - aOpt.maAddProps.realloc( nUsed + 1 ); + aOpt.maAddProps.realloc( nUsed + 1 + (i_rDisabledChoices.getLength() ? 1 : 0) ); aOpt.maAddProps[nUsed].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); aOpt.maAddProps[nUsed].Value = makeAny( i_rChoices ); + if( i_rDisabledChoices.getLength() ) + { + aOpt.maAddProps[nUsed+1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChoicesDisabled" ) ); + aOpt.maAddProps[nUsed+1].Value = makeAny( i_rDisabledChoices ); + } PropertyValue aVal; aVal.Name = i_rProperty; diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index a1156c4b0aee..b0635f9c5af5 100644..100755 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -405,6 +405,7 @@ void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, cons } bool SalGraphics::drawPolyLine( const basegfx::B2DPolygon& /*rPolyPolygon*/, + double /*fTransparency*/, const basegfx::B2DVector& /*rLineWidths*/, basegfx::B2DLineJoin /*eLineJoin*/) { @@ -536,7 +537,7 @@ sal_Bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt3 return bRet; } -bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon& i_rPolygon, +bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon& i_rPolygon, double fTransparency, const ::basegfx::B2DVector& i_rLineWidth, basegfx::B2DLineJoin i_eLineJoin, const OutputDevice* i_pOutDev ) { @@ -544,10 +545,10 @@ bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon& i_rPolygon, if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) { basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) ); - bRet = drawPolyLine( aMirror, i_rLineWidth, i_eLineJoin ); + bRet = drawPolyLine( aMirror, fTransparency, i_rLineWidth, i_eLineJoin ); } else - bRet = drawPolyLine( i_rPolygon, i_rLineWidth, i_eLineJoin ); + bRet = drawPolyLine( i_rPolygon, fTransparency, i_rLineWidth, i_eLineJoin ); return bRet; } @@ -668,13 +669,13 @@ sal_Bool SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, v return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize ); } -sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, +sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, const Point& aPos, sal_Bool& rIsInside, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { Point pt( aPos ); - Region rgn( rControlRegion ); + Rectangle rgn( rControlRegion ); mirror( pt.X(), pOutDev ); mirror( rgn, pOutDev ); return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside ); @@ -683,51 +684,48 @@ sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside ); } -void SalGraphics::mirror( ControlType nType, const ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const +void SalGraphics::mirror( ControlType , const ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const { - if( rVal.getOptionalVal() ) + switch( rVal.getType() ) { - switch( nType ) + case CTRL_SLIDER: { - case CTRL_SLIDER: - { - SliderValue* pSlVal = reinterpret_cast<SliderValue*>(rVal.getOptionalVal()); - mirror(pSlVal->maThumbRect,pOutDev,bBack); - } - break; - case CTRL_SCROLLBAR: - { - ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(rVal.getOptionalVal()); - mirror(pScVal->maThumbRect,pOutDev,bBack); - mirror(pScVal->maButton1Rect,pOutDev,bBack); - mirror(pScVal->maButton2Rect,pOutDev,bBack); - } - break; - case CTRL_SPINBOX: - case CTRL_SPINBUTTONS: - { - SpinbuttonValue* pSpVal = reinterpret_cast<SpinbuttonValue*>(rVal.getOptionalVal()); - mirror(pSpVal->maUpperRect,pOutDev,bBack); - mirror(pSpVal->maLowerRect,pOutDev,bBack); - } - break; - case CTRL_TOOLBAR: - { - ToolbarValue* pTVal = reinterpret_cast<ToolbarValue*>(rVal.getOptionalVal()); - mirror(pTVal->maGripRect,pOutDev,bBack); - } - break; + SliderValue* pSlVal = static_cast<SliderValue*>(const_cast<ImplControlValue*>(&rVal)); + mirror(pSlVal->maThumbRect,pOutDev,bBack); + } + break; + case CTRL_SCROLLBAR: + { + ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(const_cast<ImplControlValue*>(&rVal)); + mirror(pScVal->maThumbRect,pOutDev,bBack); + mirror(pScVal->maButton1Rect,pOutDev,bBack); + mirror(pScVal->maButton2Rect,pOutDev,bBack); + } + break; + case CTRL_SPINBOX: + case CTRL_SPINBUTTONS: + { + SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(const_cast<ImplControlValue*>(&rVal)); + mirror(pSpVal->maUpperRect,pOutDev,bBack); + mirror(pSpVal->maLowerRect,pOutDev,bBack); + } + break; + case CTRL_TOOLBAR: + { + ToolbarValue* pTVal = static_cast<ToolbarValue*>(const_cast<ImplControlValue*>(&rVal)); + mirror(pTVal->maGripRect,pOutDev,bBack); } + break; } } -sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, +sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& aCaption, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { - Region rgn( rControlRegion ); + Rectangle rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); sal_Bool bRet = drawNativeControl( nType, nPart, rgn, nState, aValue, aCaption ); @@ -738,13 +736,13 @@ sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, c return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption ); } -sal_Bool SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, +sal_Bool SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& aCaption, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { - Region rgn( rControlRegion ); + Rectangle rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); sal_Bool bRet = drawNativeControlText( nType, nPart, rgn, nState, aValue, aCaption ); @@ -755,13 +753,13 @@ sal_Bool SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPar return drawNativeControlText( nType, nPart, rControlRegion, nState, aValue, aCaption ); } -sal_Bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, +sal_Bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& aCaption, - Region &rNativeBoundingRegion, Region &rNativeContentRegion, const OutputDevice *pOutDev ) + Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { - Region rgn( rControlRegion ); + Rectangle rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); if( getNativeControlRegion( nType, nPart, rgn, nState, aValue, aCaption, diff --git a/vcl/source/gdi/salnativewidgets-none.cxx b/vcl/source/gdi/salnativewidgets-none.cxx index 62007cd28d04..4cbce4c5298a 100644 --- a/vcl/source/gdi/salnativewidgets-none.cxx +++ b/vcl/source/gdi/salnativewidgets-none.cxx @@ -58,7 +58,7 @@ sal_Bool SalGraphics::IsNativeControlSupported( ControlType, ControlPart ) */ sal_Bool SalGraphics::hitTestNativeControl( ControlType, ControlPart, - const Region&, + const Rectangle&, const Point&, sal_Bool& ) { @@ -77,7 +77,7 @@ sal_Bool SalGraphics::hitTestNativeControl( ControlType, */ sal_Bool SalGraphics::drawNativeControl( ControlType, ControlPart, - const Region&, + const Rectangle&, ControlState, const ImplControlValue&, const OUString& ) @@ -98,7 +98,7 @@ sal_Bool SalGraphics::drawNativeControl( ControlType, */ sal_Bool SalGraphics::drawNativeControlText( ControlType, ControlPart, - const Region&, + const Rectangle&, ControlState, const ImplControlValue&, const OUString& ) @@ -122,12 +122,12 @@ sal_Bool SalGraphics::drawNativeControlText( ControlType, */ sal_Bool SalGraphics::getNativeControlRegion( ControlType, ControlPart, - const Region&, + const Rectangle&, ControlState, const ImplControlValue&, const OUString&, - Region &, - Region & ) + Rectangle &, + Rectangle & ) { return( sal_False ); } diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index e3dd47c30085..ba8dad14733c 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -301,6 +301,7 @@ FtFontInfo::FtFontInfo( const ImplDevFontAttributes& rDevFontAttributes, mnSynthetic( nSynthetic ), mnFontId( nFontId ), maDevFontAttributes( rDevFontAttributes ), + mpFontCharMap( NULL ), mpChar2Glyph( NULL ), mpGlyph2Char( NULL ), mpExtraKernInfo( pExtraKernInfo ) @@ -318,6 +319,8 @@ FtFontInfo::FtFontInfo( const ImplDevFontAttributes& rDevFontAttributes, FtFontInfo::~FtFontInfo() { + if( mpFontCharMap ) + mpFontCharMap->DeReference(); delete mpExtraKernInfo; delete mpChar2Glyph; delete mpGlyph2Char; @@ -520,10 +523,25 @@ void* FreetypeServerFont::GetFtFace() const FreetypeManager::~FreetypeManager() { -// This crashes on Solaris 10 -// TODO: check which versions have this problem -// -// FT_Error rcFT = FT_Done_FreeType( aLibFT ); + // an application about to exit can omit garbage collecting the heap + // since it makes things slower and introduces risks if the heap was not perfect + // for debugging, for memory grinding or leak checking the env allows to force GC + const char* pEnv = getenv( "SAL_FORCE_GC_ON_EXIT" ); + if( pEnv && (*pEnv != '0') ) + { + // cleanup container of fontinfos + for( FontList::const_iterator it = maFontList.begin(); it != maFontList.end(); ++it ) + { + FtFontInfo* pInfo = (*it).second; + delete pInfo; + } + maFontList.clear(); + +#if 0 // FT_Done_FreeType crashes on Solaris 10 + // TODO: check which versions have this problem + FT_Error rcFT = FT_Done_FreeType( aLibFT ); +#endif + } } // ----------------------------------------------------------------------- @@ -895,6 +913,9 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions) } } #endif + + if( mnPrioEmbedded <= 0 ) + mnLoadFlags |= FT_LOAD_NO_BITMAP; } // ----------------------------------------------------------------------- @@ -1730,16 +1751,39 @@ bool FreetypeServerFont::GetGlyphBitmap8( int nGlyphIndex, RawBitmap& rRawBitmap // determine unicode ranges in font // ----------------------------------------------------------------------- -// TODO: replace with GetFontCharMap() -bool FreetypeServerFont::GetFontCodeRanges( CmapResult& rResult ) const +const ImplFontCharMap* FreetypeServerFont::GetImplFontCharMap( void ) const +{ + const ImplFontCharMap* pIFCMap = mpFontInfo->GetImplFontCharMap(); + return pIFCMap; +} + +const ImplFontCharMap* FtFontInfo::GetImplFontCharMap( void ) +{ + // check if the charmap is already cached + if( mpFontCharMap ) + return mpFontCharMap; + + // get the charmap and cache it + CmapResult aCmapResult; + bool bOK = GetFontCodeRanges( aCmapResult ); + if( bOK ) + mpFontCharMap = new ImplFontCharMap( aCmapResult ); + else + mpFontCharMap = ImplFontCharMap::GetDefaultMap(); + mpFontCharMap->AddReference(); + return mpFontCharMap; +} + +// TODO: merge into method GetFontCharMap() +bool FtFontInfo::GetFontCodeRanges( CmapResult& rResult ) const { - rResult.mbSymbolic = mpFontInfo->IsSymbolFont(); + rResult.mbSymbolic = IsSymbolFont(); // TODO: is the full CmapResult needed on platforms calling this? if( FT_IS_SFNT( maFaceFT ) ) { sal_uIntPtr nLength = 0; - const unsigned char* pCmap = mpFontInfo->GetTable( "cmap", &nLength ); + const unsigned char* pCmap = GetTable( "cmap", &nLength ); if( pCmap && (nLength > 0) ) if( ParseCMAP( pCmap, nLength, rResult ) ) return true; diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx index 1ab6539e2005..a520958e9d73 100644 --- a/vcl/source/glyphs/gcach_ftyp.hxx +++ b/vcl/source/glyphs/gcach_ftyp.hxx @@ -94,6 +94,9 @@ public: int GetGlyphIndex( sal_UCS4 cChar ) const; void CacheGlyphIndex( sal_UCS4 cChar, int nGI ) const; + bool GetFontCodeRanges( CmapResult& ) const; + const ImplFontCharMap* GetImplFontCharMap( void ); + bool HasExtraKerning() const; int GetExtraKernPairs( ImplKernPairData** ) const; int GetExtraGlyphKernValue( int nLeftGlyph, int nRightGlyph ) const; @@ -108,6 +111,8 @@ private: sal_IntPtr mnFontId; ImplDevFontAttributes maDevFontAttributes; + const ImplFontCharMap* mpFontCharMap; + // cache unicode->glyphid mapping because looking it up is expensive // TODO: change to hash_multimap when a use case requires a m:n mapping typedef ::std::hash_map<int,int> Int2IntMap; @@ -181,6 +186,7 @@ public: virtual bool NeedsArtificialItalic() const { return mbArtItalic; } virtual void FetchFontMetric( ImplFontMetricData&, long& rFactor ) const; + virtual const ImplFontCharMap* GetImplFontCharMap( void ) const; virtual int GetGlyphIndex( sal_UCS4 ) const; int GetRawGlyphIndex( sal_UCS4 ) const; @@ -203,7 +209,6 @@ protected: int ApplyGlyphTransform( int nGlyphFlags, FT_GlyphRec_*, bool ) const; virtual void InitGlyphData( int nGlyphIndex, GlyphData& ) const; - virtual bool GetFontCodeRanges( CmapResult& ) const; bool ApplyGSUB( const ImplFontSelectData& ); virtual ServerFontLayoutEngine* GetLayoutEngine(); diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index e5670829b4d1..16a30d57b8fb 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -78,12 +78,18 @@ GlyphCache::~GlyphCache() void GlyphCache::InvalidateAllGlyphs() { -#if 0 // TODO: implement uncaching of all glyph shapes and metrics - for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it ) - delete const_cast<ServerFont*>( it->second ); - maFontList.clear(); - mpCurrentGCFont = NULL; -#endif + // an application about to exit can omit garbage collecting the heap + // since it makes things slower and introduces risks if the heap was not perfect + // for debugging, for memory grinding or leak checking the env allows to force GC + const char* pEnv = getenv( "SAL_FORCE_GC_ON_EXIT" ); + if( pEnv && (*pEnv != '0') ) + { + // uncache of all glyph shapes and metrics + for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it ) + delete const_cast<ServerFont*>( it->second ); + maFontList.clear(); + mpCurrentGCFont = NULL; + } } // ----------------------------------------------------------------------- diff --git a/vcl/source/glyphs/graphite_adaptors.cxx b/vcl/source/glyphs/graphite_adaptors.cxx index b51c1f4724e0..9473c8832845 100644 --- a/vcl/source/glyphs/graphite_adaptors.cxx +++ b/vcl/source/glyphs/graphite_adaptors.cxx @@ -99,12 +99,18 @@ FontProperties::FontProperties(const FreetypeServerFont &font) throw() fItalic = false; } - // Get the font name. + // Get the font name, but prefix with file name hash in case + // there are 2 fonts on the system with the same face name + sal_Int32 nHashCode = font.GetFontFileName()->hashCode(); + ::rtl::OUStringBuffer nHashFaceName; + nHashFaceName.append(nHashCode, 16); const sal_Unicode * name = font.GetFontSelData().maName.GetBuffer(); - const size_t name_sz = std::min(sizeof szFaceName/sizeof(wchar_t)-1, - size_t(font.GetFontSelData().maName.Len())); + nHashFaceName.append(name); - std::copy(name, name + name_sz, szFaceName); + const size_t name_sz = std::min(sizeof szFaceName/sizeof(wchar_t)-1, + static_cast<size_t>(nHashFaceName.getLength())); + + std::copy(nHashFaceName.getStr(), nHashFaceName.getStr() + name_sz, szFaceName); szFaceName[name_sz] = '\0'; } @@ -120,13 +126,13 @@ GraphiteFontAdaptor::GraphiteFontAdaptor(ServerFont & sfont, const sal_Int32 dpi mfEmUnits(static_cast<FreetypeServerFont &>(sfont).GetMetricsFT().y_ppem), mpFeatures(NULL) { - //std::wstring face_name(maFontProperties.szFaceName); const rtl::OString aLang = MsLangId::convertLanguageToIsoByteString( sfont.GetFontSelData().meLanguage ); -#ifdef DEBUG - printf("GraphiteFontAdaptor %lx\n", (long)this); -#endif rtl::OString name = rtl::OUStringToOString( sfont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 ); +#ifdef DEBUG + printf("GraphiteFontAdaptor %lx %s italic=%u bold=%u\n", (long)this, name.getStr(), + maFontProperties.fItalic, maFontProperties.fBold); +#endif sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1; if (nFeat > 0) { @@ -259,21 +265,24 @@ const void * GraphiteFontAdaptor::getTable(gr::fontTableId32 table_id, size_t * // Return the glyph's metrics in pixels. void GraphiteFontAdaptor::getGlyphMetrics(gr::gid16 nGlyphId, gr::Rect & aBounding, gr::Point & advances) { - // Graphite gets really confused if the glyphs have been transformed, so - // if orientation has been set we can't use the font's glyph cache - // unfortunately the font selection data, doesn't always have the orientation - // set, even if it was when the glyphs were cached, so we use our own cache. - -// const GlyphMetric & metric = mrFont.GetGlyphMetric(nGlyphId); -// -// aBounding.right = aBounding.left = metric.GetOffset().X(); -// aBounding.bottom = aBounding.top = -metric.GetOffset().Y(); -// aBounding.right += metric.GetSize().Width(); -// aBounding.bottom -= metric.GetSize().Height(); -// -// advances.x = metric.GetDelta().X(); -// advances.y = -metric.GetDelta().Y(); - + // There used to be problems when orientation was set however, this no + // longer seems to be the case and the Glyph Metric cache in + // FreetypeServerFont is more efficient since it lasts between calls to VCL +#if 1 + const GlyphMetric & metric = mrFont.GetGlyphMetric(nGlyphId); + + aBounding.right = aBounding.left = metric.GetOffset().X(); + aBounding.bottom = aBounding.top = -metric.GetOffset().Y(); + aBounding.right += metric.GetSize().Width(); + aBounding.bottom -= metric.GetSize().Height(); + + advances.x = metric.GetDelta().X(); + advances.y = -metric.GetDelta().Y(); + +#else + // The problem with the code below is that the cache only lasts + // as long as the life time of the GraphiteFontAdaptor, which + // is created once per call to X11SalGraphics::GetTextLayout GlyphMetricMap::const_iterator gm_itr = maGlyphMetricMap.find(nGlyphId); if (gm_itr != maGlyphMetricMap.end()) { @@ -321,6 +330,7 @@ void GraphiteFontAdaptor::getGlyphMetrics(gr::gid16 nGlyphId, gr::Rect & aBoundi // Now add an entry to our metrics map. maGlyphMetricMap[nGlyphId] = std::make_pair(aBounding, advances); } +#endif } #endif diff --git a/vcl/source/glyphs/graphite_cache.cxx b/vcl/source/glyphs/graphite_cache.cxx index 64bbb0a38d60..7682cdb6c8ba 100644 --- a/vcl/source/glyphs/graphite_cache.cxx +++ b/vcl/source/glyphs/graphite_cache.cxx @@ -36,10 +36,10 @@ #include <tools/debug.hxx> #include <vcl/sallayout.hxx> -#include <tools/preextstl.h> +#include <preextstl.h> #include <graphite/GrClient.h> #include <graphite/Segment.h> -#include <tools/postextstl.h> +#include <postextstl.h> #include <rtl/ustring.hxx> #include <vcl/graphite_layout.hxx> @@ -105,7 +105,7 @@ GrSegRecord * GraphiteSegmentCache::cacheSegment(TextSourceAdaptor * adapter, gr // when the next key is added, the record for the prevKey's m_nextKey field // is updated to the newest key so that m_oldestKey can be updated to the // next oldest key when the record for m_oldestKey is deleted - if (m_segMap.size() > SEG_CACHE_SIZE) + if (m_segMap.size() > m_nSegCacheSize) { GraphiteSegMap::iterator oldestPair = m_segMap.find(reinterpret_cast<long>(m_oldestKey)); // oldest record may no longer exist if a buffer was changed diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx index ff2fd8f306b1..8a011606ab41 100644 --- a/vcl/source/glyphs/graphite_layout.cxx +++ b/vcl/source/glyphs/graphite_layout.cxx @@ -56,6 +56,10 @@ #include <svsys.h> #endif +#ifdef UNX +#include <vcl/graphite_adaptors.hxx> +#endif + #include <vcl/salgdi.hxx> #include <unicode/uchar.h> @@ -63,13 +67,13 @@ #include <unicode/uscript.h> // Graphite Libraries (must be after vcl headers on windows) -#include <tools/preextstl.h> +#include <preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/ITextSource.h> #include <graphite/Segment.h> #include <graphite/SegmentPainter.h> -#include <tools/postextstl.h> +#include <postextstl.h> #include <vcl/graphite_layout.hxx> #include <vcl/graphite_features.hxx> @@ -175,7 +179,8 @@ GraphiteLayout::Glyphs::fill_from(gr::Segment & rSegment, ImplLayoutArgs &rArgs, glyph_range_t iGlyphs = rSegment.glyphs(); int nGlyphs = iGlyphs.second - iGlyphs.first; gr::GlyphIterator prevBase = iGlyphs.second; - float fMinX = rSegment.advanceWidth(); + float fSegmentAdvance = rSegment.advanceWidth(); + float fMinX = fSegmentAdvance; float fMaxX = 0.0f; rGlyph2Char.assign(nGlyphs, -1); long nDxOffset = 0; @@ -222,7 +227,8 @@ GraphiteLayout::Glyphs::fill_from(gr::Segment & rSegment, ImplLayoutArgs &rArgs, nFirstGlyphInCluster != nGlyphIndex) { std::pair <float,float> aBounds = - appendCluster(rSegment, rArgs, bRtl, nFirstCharInCluster, + appendCluster(rSegment, rArgs, bRtl, + fSegmentAdvance, nFirstCharInCluster, nNextChar, nFirstGlyphInCluster, nGlyphIndex, fScaling, rChar2Base, rGlyph2Char, rCharDxs, nDxOffset); fMinX = std::min(aBounds.first, fMinX); @@ -285,7 +291,8 @@ GraphiteLayout::Glyphs::fill_from(gr::Segment & rSegment, ImplLayoutArgs &rArgs, nFirstGlyphInCluster != nGlyphIndex) { std::pair <float,float> aBounds = - appendCluster(rSegment, rArgs, bRtl, nFirstCharInCluster, nNextChar, + appendCluster(rSegment, rArgs, bRtl, fSegmentAdvance, + nFirstCharInCluster, nNextChar, nFirstGlyphInCluster, nGlyphIndex, fScaling, rChar2Base, rGlyph2Char, rCharDxs, nDxOffset); fMinX = std::min(aBounds.first, fMinX); @@ -334,11 +341,11 @@ GraphiteLayout::Glyphs::fill_from(gr::Segment & rSegment, ImplLayoutArgs &rArgs, } } -std::pair<float,float> GraphiteLayout::Glyphs::appendCluster(gr::Segment & rSeg, - ImplLayoutArgs & rArgs, bool bRtl, int nFirstCharInCluster, int nNextChar, - int nFirstGlyphInCluster, int nNextGlyph, float fScaling, - std::vector<int> & rChar2Base, std::vector<int> & rGlyph2Char, - std::vector<int> & rCharDxs, long & rDXOffset) +std::pair<float,float> GraphiteLayout::Glyphs::appendCluster(gr::Segment& rSeg, + ImplLayoutArgs & rArgs, bool bRtl,float fSegmentAdvance, + int nFirstCharInCluster, int nNextChar, int nFirstGlyphInCluster, + int nNextGlyph, float fScaling, std::vector<int> & rChar2Base, + std::vector<int> & rGlyph2Char, std::vector<int> & rCharDxs, long & rDXOffset) { glyph_range_t iGlyphs = rSeg.glyphs(); int nGlyphs = iGlyphs.second - iGlyphs.first; @@ -402,9 +409,9 @@ std::pair<float,float> GraphiteLayout::Glyphs::appendCluster(gr::Segment & rSeg, gr::GlyphInfo aGlyph = *(iGlyphs.first + j); if (j + nDelta >= nGlyphs || j + nDelta < 0) // at rhs ltr,rtl { - fNextOrigin = rSeg.advanceWidth(); - nNextOrigin = round(rSeg.advanceWidth() * fScaling + rDXOffset); - aBounds.second = std::max(rSeg.advanceWidth(), aBounds.second); + fNextOrigin = fSegmentAdvance; + nNextOrigin = round(fSegmentAdvance * fScaling + rDXOffset); + aBounds.second = std::max(fSegmentAdvance, aBounds.second); } else { @@ -546,7 +553,7 @@ GraphiteLayout::GraphiteLayout(const gr::Font & font, const grutils::GrFeaturePa // If true, it can cause end of line spaces to be hidden e.g. Doulos SIL maLayout.setStartOfLine(false); maLayout.setEndOfLine(false); -// maLayout.setDumbFallback(false); + maLayout.setDumbFallback(true); // trailing ws doesn't seem to always take affect if end of line is true maLayout.setTrailingWs(gr::ktwshAll); #ifdef GRLAYOUT_DEBUG @@ -587,19 +594,39 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs) { #ifdef GRCACHE GrSegRecord * pSegRecord = NULL; - gr::Segment * pSegment = CreateSegment(rArgs, &pSegRecord); - if (!pSegment) - return false; - + gr::Segment * pSegment = NULL; + // Graphite can in rare cases crash with a zero length + if (rArgs.mnMinCharPos < rArgs.mnEndCharPos) + { + pSegment = CreateSegment(rArgs, &pSegRecord); + if (!pSegment) + return false; + } + else + { + clear(); + return true; + } // layout the glyphs as required by OpenOffice bool success = LayoutGlyphs(rArgs, pSegment, pSegRecord); if (pSegRecord) pSegRecord->unlock(); else delete pSegment; #else - gr::Segment * pSegment = CreateSegment(rArgs); - bool success = LayoutGlyphs(rArgs, pSegment); - delete pSegment; + gr::Segment * pSegment = NULL; + bool success = true; + if (rArgs.mnMinCharPos < rArgs.mnEndCharPos) + { + pSegment = CreateSegment(rArgs); + if (!pSegment) + return false; + success = LayoutGlyphs(rArgs, pSegment); + if (pSegment) delete pSegment; + } + else + { + clear(); + } #endif return success; } @@ -649,7 +676,19 @@ public: #endif return hash; }; - +protected: + virtual void UniqueCacheInfo( ext_std::wstring& stuFace, bool& fBold, bool& fItalic ) + { +#ifdef WIN32 + dynamic_cast<GraphiteWinFont&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic); +#else +#ifdef UNX + dynamic_cast<GraphiteFontAdaptor&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic); +#else +#error Unknown base type for gr::Font::UniqueCacheInfo +#endif +#endif + } private: gr::Font & mrRealFont; }; @@ -701,7 +740,7 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs) (GraphiteCacheHandler::instance).getCache(aFontHash); if (pCache) { - *pSegRecord = pCache->getSegment(rArgs, bRtl, nSegCharLimit); + *pSegRecord = pCache->getSegment(rArgs, bRtl, limit); if (*pSegRecord) { pSegment = (*pSegRecord)->getSegment(); @@ -715,7 +754,34 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs) (*pSegRecord)->clearVectors(); } mpTextSrc->switchLayoutArgs(rArgs); - return pSegment; + if (limit > rArgs.mnMinCharPos && limit == rArgs.mnEndCharPos + && pSegment->stopCharacter() != limit) + { + // check that the last character is not part of a ligature + glyph_set_range_t aGlyphSet = pSegment->charToGlyphs(limit - 1); + if (aGlyphSet.first == aGlyphSet.second) + { + // no glyphs associated with this glyph - occurs mid ligature + pSegment = NULL; + *pSegRecord = NULL; + } + else + { + while (aGlyphSet.first != aGlyphSet.second) + { + int lastChar = static_cast<int>((*aGlyphSet.first).lastChar()); + if (lastChar >= limit) + { + pSegment = NULL; + *pSegRecord = NULL; + break; + } + aGlyphSet.first++; + } + } + } + if (pSegment) + return pSegment; } } #endif @@ -738,6 +804,14 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs) } else { +#ifdef GRLAYOUT_DEBUG + fprintf(grLog(), "Gr::LayoutText failed: "); + for (int i = mnMinCharPos; i < limit; i++) + { + fprintf(grLog(), "%04x ", rArgs.mpStr[i]); + } + fprintf(grLog(), "\n"); +#endif clear(); return NULL; } @@ -897,7 +971,7 @@ long GraphiteLayout::FillDXArray( sal_Int32* pDXArray ) const if (i > 0) pDXArray[i] -= mvCharDxs[i-1]; } #ifdef GRLAYOUT_DEBUG - fprintf(grLog(),"%d,%d,%ld ", (int)i, (int)mvCharDxs[i], pDXArray[i]); + fprintf(grLog(),"%d,%d,%d ", (int)i, (int)mvCharDxs[i], pDXArray[i]); #endif } //std::adjacent_difference(mvCharDxs.begin(), mvCharDxs.end(), pDXArray); @@ -974,13 +1048,13 @@ void GraphiteLayout::expandOrCondense(ImplLayoutArgs &rArgs) { if (mvGlyphs[i].IsClusterStart()) { - nOffset = fExtraPerCluster * nCluster; + nOffset = FRound( fExtraPerCluster * nCluster ); size_t nCharIndex = mvGlyph2Char[i]; mvCharDxs[nCharIndex] += nOffset; // adjust char dxs for rest of characters in cluster while (++nCharIndex < mvGlyph2Char.size()) { - int nChar2Base = (mvChar2BaseGlyph[nCharIndex] == -1)? -1 : mvChar2BaseGlyph[nCharIndex] & GLYPH_INDEX_MASK; + int nChar2Base = (mvChar2BaseGlyph[nCharIndex] == -1)? -1 : (int)(mvChar2BaseGlyph[nCharIndex] & GLYPH_INDEX_MASK); if (nChar2Base == -1 || nChar2Base == static_cast<int>(i)) mvCharDxs[nCharIndex] += nOffset; } @@ -1003,14 +1077,15 @@ void GraphiteLayout::expandOrCondense(ImplLayoutArgs &rArgs) Glyphs::iterator iGlyph = mvGlyphs.begin(); while (iGlyph != iLastGlyph) { - iGlyph->maLinearPos.X() = static_cast<float>(iGlyph->maLinearPos.X()) * fXFactor; + iGlyph->maLinearPos.X() = FRound( fXFactor * iGlyph->maLinearPos.X() ); ++iGlyph; } for (size_t i = 0; i < mvCharDxs.size(); i++) { - mvCharDxs[i] = fXFactor * static_cast<float>(mvCharDxs[i]); + mvCharDxs[i] = FRound( fXFactor * mvCharDxs[i] ); } } + mnWidth = rArgs.mnLayoutWidth; } void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDeltaWidth) @@ -1020,7 +1095,7 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt #ifdef GRLAYOUT_DEBUG for (size_t iDx = 0; iDx < mvCharDxs.size(); iDx++) - fprintf(grLog(),"%d,%d,%ld ", (int)iDx, (int)mvCharDxs[iDx], args.mpDXArray[iDx]); + fprintf(grLog(),"%d,%d,%d ", (int)iDx, (int)mvCharDxs[iDx], args.mpDXArray[iDx]); fprintf(grLog(),"ApplyDx\n"); #endif bool bRtl = mnLayoutFlags & SAL_LAYOUT_BIDI_RTL; @@ -1029,11 +1104,11 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt { nXOffset = args.mpDXArray[nChars - 1] - mvCharDxs[nChars - 1]; } - int nPrevClusterGlyph = (bRtl)? mvGlyphs.size() : -1; + int nPrevClusterGlyph = (bRtl)? (signed)mvGlyphs.size() : -1; int nPrevClusterLastChar = -1; for (size_t i = 0; i < nChars; i++) { - int nChar2Base = (mvChar2BaseGlyph[i] == -1)? -1 : mvChar2BaseGlyph[i] & GLYPH_INDEX_MASK; + int nChar2Base = (mvChar2BaseGlyph[i] == -1)? -1 : (int)(mvChar2BaseGlyph[i] & GLYPH_INDEX_MASK); if ((nChar2Base > -1) && (nChar2Base != nPrevClusterGlyph)) { assert((nChar2Base > -1) && (nChar2Base < (signed)mvGlyphs.size())); @@ -1047,11 +1122,11 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt int nLastGlyph = nChar2Base; for (; j < nChars; j++) { - int nChar2BaseJ = (mvChar2BaseGlyph[j] == -1)? -1 : mvChar2BaseGlyph[j] & GLYPH_INDEX_MASK; + int nChar2BaseJ = (mvChar2BaseGlyph[j] == -1)? -1 : (int)(mvChar2BaseGlyph[j] & GLYPH_INDEX_MASK); assert((nChar2BaseJ >= -1) && (nChar2BaseJ < (signed)mvGlyphs.size())); if (nChar2BaseJ != -1 && mvGlyphs[nChar2BaseJ].IsClusterStart()) { - nLastGlyph = nChar2BaseJ + ((bRtl)? 1 : -1); + nLastGlyph = nChar2BaseJ + ((bRtl)? +1 : -1); nLastChar = j - 1; break; } @@ -1090,7 +1165,7 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt } long nDWidth = nNewClusterWidth - nOrigClusterWidth; #ifdef GRLAYOUT_DEBUG - fprintf(grLog(), "c%d last glyph %d/%d\n", i, nLastGlyph, mvGlyphs.size()); + fprintf(grLog(), "c%lu last glyph %d/%lu\n", i, nLastGlyph, mvGlyphs.size()); #endif assert((nLastGlyph > -1) && (nLastGlyph < (signed)mvGlyphs.size())); mvGlyphs[nLastGlyph].mnNewWidth += nDWidth; @@ -1128,7 +1203,7 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt std::copy(args.mpDXArray, args.mpDXArray + nChars, mvCharDxs.begin() + (args.mnMinCharPos - mnMinCharPos)); #ifdef GRLAYOUT_DEBUG - fprintf(grLog(),"ApplyDx %ld(%ld)\n", args.mpDXArray[nChars - 1], mnWidth); + fprintf(grLog(),"ApplyDx %d(%ld)\n", args.mpDXArray[nChars - 1], mnWidth); #endif mnWidth = args.mpDXArray[nChars - 1]; } @@ -1170,7 +1245,7 @@ void GraphiteLayout::kashidaJustify(std::vector<int>& rDeltaWidths, sal_GlyphId } nKashidaCount = 1 + (nGapWidth / nKashidaWidth); #ifdef GRLAYOUT_DEBUG - printf("inserting %d kashidas at %ld\n", nKashidaCount, (*i).mnGlyphIndex); + printf("inserting %d kashidas at %u\n", nKashidaCount, (*i).mnGlyphIndex); #endif GlyphItem glyphItem = *i; Point aPos(0, 0); @@ -1309,7 +1384,7 @@ void GraphiteLayout::GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray pCaretXArray[i] = pCaretXArray[i+1] = 0; } #ifdef GRLAYOUT_DEBUG - fprintf(grLog(),"%d,%ld-%ld\t", nCharSlot, pCaretXArray[i], pCaretXArray[i+1]); + fprintf(grLog(),"%d,%d-%d\t", nCharSlot, pCaretXArray[i], pCaretXArray[i+1]); #endif } #ifdef GRLAYOUT_DEBUG diff --git a/vcl/source/glyphs/graphite_textsrc.hxx b/vcl/source/glyphs/graphite_textsrc.hxx index 2b9c705a5ea7..388f8a631b49 100644 --- a/vcl/source/glyphs/graphite_textsrc.hxx +++ b/vcl/source/glyphs/graphite_textsrc.hxx @@ -59,11 +59,11 @@ #include "vcl/dllapi.h" // Libraries -#include <tools/preextstl.h> +#include <preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/ITextSource.h> -#include <tools/postextstl.h> +#include <postextstl.h> // Module type definitions and forward declarations. // @@ -93,6 +93,7 @@ public: virtual ext_std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich); virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset); virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2); + virtual bool featureVariations() { return false; } operator ImplLayoutArgs & () throw(); void setFeatures(const grutils::GrFeatureParser * pFeatures); diff --git a/vcl/source/helper/makefile.mk b/vcl/source/helper/makefile.mk index e708bdec9eaa..1a417417dbe4 100644 --- a/vcl/source/helper/makefile.mk +++ b/vcl/source/helper/makefile.mk @@ -46,7 +46,6 @@ SLOFILES=\ $(SLO)$/canvastools.obj \ $(SLO)$/xconnection.obj \ $(SLO)$/threadex.obj \ - $(SLO)$/smartid.obj \ $(SLO)$/lazydelete.obj # --- Targets ------------------------------------------------------ diff --git a/vcl/source/helper/smartid.cxx b/vcl/source/helper/smartid.cxx deleted file mode 100755 index 15bbd3129908..000000000000 --- a/vcl/source/helper/smartid.cxx +++ /dev/null @@ -1,264 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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_vcl.hxx" -#include <vcl/smartid.hxx> - -struct ImplSmartIdData -{ - String aUId; - sal_uIntPtr nUId; - sal_Bool bHasStringId; - sal_Bool bHasNumericId; -}; - - -ImplSmartIdData* SmartId::GetSmartIdData() -{ - if ( !mpData ) - { - mpData = new ImplSmartIdData; -// mpData->aUId = ""; - mpData->nUId = 0; - mpData->bHasStringId = sal_False; - mpData->bHasNumericId = sal_False; - } - return mpData; -} - - -SmartId::SmartId( const String& rId ) -: mpData( NULL ) -{ - GetSmartIdData()->aUId = rId; - GetSmartIdData()->bHasStringId = sal_True; -} - -SmartId::SmartId( sal_uIntPtr nId ) -: mpData( NULL ) -{ - GetSmartIdData()->nUId = nId; - GetSmartIdData()->bHasNumericId = sal_True; -} - -SmartId::SmartId( const String& rId, sal_uIntPtr nId ) -: mpData( NULL ) -{ - GetSmartIdData()->aUId = rId; - GetSmartIdData()->bHasStringId = sal_True; - GetSmartIdData()->nUId = nId; - GetSmartIdData()->bHasNumericId = sal_True; -} - -SmartId::SmartId() -: mpData( NULL ) -{} - -SmartId::SmartId( const SmartId& rId ) -: mpData( NULL ) -{ - if ( rId.mpData ) - { - GetSmartIdData(); - mpData->aUId = rId.mpData->aUId; - mpData->bHasStringId = rId.mpData->bHasStringId; - mpData->nUId = rId.mpData->nUId; - mpData->bHasNumericId = rId.mpData->bHasNumericId; - } -} - -SmartId& SmartId::operator = ( const SmartId& rId ) -{ - if ( rId.mpData ) - GetSmartIdData(); - else - { - delete mpData; - mpData = NULL; - } - if ( mpData && rId.mpData ) - { - mpData->aUId = rId.mpData->aUId; - mpData->bHasStringId = rId.mpData->bHasStringId; - mpData->nUId = rId.mpData->nUId; - mpData->bHasNumericId = rId.mpData->bHasNumericId; - } - return *this; -} - -SmartId::~SmartId() -{ - if ( mpData ) - delete mpData; -#ifdef DBG_UTIL - if ( mpData ) - mpData = (ImplSmartIdData*)0xDeadBeef; -#endif -} - -void SmartId::UpdateId( const SmartId& rId, SmartIdUpdateMode aMode ) -{ - // Check if ImplData is needed - if ( aMode != SMART_SET_SMART || ( rId.HasString() || rId.HasNumeric() ) ) - GetSmartIdData(); - - if ( aMode == SMART_SET_STR || aMode == SMART_SET_ALL || ( aMode == SMART_SET_SMART && rId.HasString() ) ) - { - GetSmartIdData()->aUId = rId.GetStr(); - GetSmartIdData()->bHasStringId = rId.HasString(); - } - if ( aMode == SMART_SET_NUM || aMode == SMART_SET_ALL || ( aMode == SMART_SET_SMART && rId.HasNumeric() ) ) - { - GetSmartIdData()->nUId = rId.GetNum(); - GetSmartIdData()->bHasNumericId = rId.HasNumeric(); - } - - // remove ImplData when no IDs are set. This is Important because Implementation of Equals() Matches and HasAny relies on it - if ( mpData && !mpData->bHasStringId && !mpData->bHasNumericId ) - { - delete mpData; - mpData = NULL; - } -} - -sal_Bool SmartId::HasNumeric() const -{ - if ( !mpData ) - return sal_False; - else - return mpData->bHasNumericId; -} - -sal_Bool SmartId::HasString() const -{ - if ( !mpData ) - return sal_False; - else - return mpData->bHasStringId; -} - -sal_Bool SmartId::HasAny() const -{ - return mpData != NULL; -} - -sal_uIntPtr SmartId::GetNum() const -{ - if ( !mpData ) - return 0; - else - return mpData->nUId; -} - -String SmartId::GetStr() const -{ - if ( !mpData ) - return String(); - else - return mpData->aUId; -} - - -String SmartId::GetText() const // return String for UI usage -{ - String aRes; - if ( HasNumeric() ) - aRes = String::CreateFromInt64( GetNum() ); - if ( HasString() ) - { - if ( HasNumeric() ) - aRes.AppendAscii( "/" ); - aRes.Append( GetStr() ); - } - return aRes; -} - -sal_Bool SmartId::Matches( const String &rId )const -{ - if ( HasString() ) - return GetStr().EqualsIgnoreCaseAscii( rId ); - else - return sal_False; -} - -sal_Bool SmartId::Matches( const sal_uIntPtr nId ) const -{ - if ( HasNumeric() ) - return GetNum() == nId; - else - return sal_False; -} - -/****************************************************************************** -If Both Ids have nither Strings nor Numbers they don't match -If both Ids have Strings the result of Matching these is returned. -Numbers are then Ignored. -Else Matching Numbers is attempted. -******************************************************************************/ -sal_Bool SmartId::Matches( const SmartId &rId ) const -{ - if ( !mpData || !rId.mpData ) - return sal_False; - else if ( HasString() && rId.HasString() ) - return Matches( rId.GetStr() ); - else - return rId.HasNumeric() && Matches( rId.GetNum() ); -} - -sal_Bool SmartId::Equals( const SmartId &rId ) const -{ - if ( mpData && rId.mpData ) - return mpData->aUId.EqualsIgnoreCaseAscii( rId.mpData->aUId ) - && mpData->bHasStringId == rId.mpData->bHasStringId - && mpData->nUId == rId.mpData->nUId - && mpData->bHasNumericId == rId.mpData->bHasNumericId; - else if ( !mpData && !rId.mpData ) - return sal_True; - else - return sal_False; -} - -sal_Bool SmartId::operator == ( const SmartId& rRight ) const -{ - return Equals( rRight ); -} - -sal_Bool SmartId::operator < ( const SmartId& rRight ) const -{ - if ( HasString() && rRight.HasString() && GetStr() != rRight.GetStr() ) - return GetStr() < rRight.GetStr(); - else if ( HasNumeric() && rRight.HasNumeric() && GetNum() != rRight.GetNum() ) - return GetNum() < rRight.GetNum(); - else - { // Sort Strings to Front - if ( HasString() ) - return rRight.HasString() && rRight.HasNumeric(); - else - return rRight.HasString() || (!HasNumeric() && rRight.HasNumeric()); - } -} diff --git a/vcl/source/helper/strhelper.cxx b/vcl/source/helper/strhelper.cxx index 03f157d4b52b..b1da78ebbf23 100644 --- a/vcl/source/helper/strhelper.cxx +++ b/vcl/source/helper/strhelper.cxx @@ -365,8 +365,8 @@ String WhitespaceToSpace( const String& rLine, sal_Bool bProtect ) else { *pLeap = *pRun; - *pLeap++; - *pRun++; + ++pLeap; + ++pRun; } } } @@ -422,8 +422,8 @@ ByteString WhitespaceToSpace( const ByteString& rLine, sal_Bool bProtect ) else { *pLeap = *pRun; - *pLeap++; - *pRun++; + ++pLeap; + ++pRun; } } } diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 58f0a477c848..436ab40bdc5f 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -29,6 +29,7 @@ ModalDialog SV_DLG_PRINT { + HelpID = "vcl:ModalDialog:SV_DLG_PRINT"; Text [en-US] = "Print"; Closeable = TRUE; Sizeable = TRUE; @@ -64,6 +65,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_PAGE_EDIT { + HelpID = "vcl:NumericField:SV_DLG_PRINT:SV_PRINT_PAGE_EDIT"; Pos = MAP_APPFONT( 5, 140 ); Size = MAP_APPFONT( 30, 12 ); SVLook = TRUE; @@ -80,18 +82,21 @@ ModalDialog SV_DLG_PRINT }; PushButton SV_PRINT_PAGE_FORWARD { + HelpID = "vcl:PushButton:SV_DLG_PRINT:SV_PRINT_PAGE_FORWARD"; Pos = MAP_APPFONT( 95, 140 ); Size = MAP_APPFONT( 15, 12 ); HelpText [en-US] = "Scroll one page forward."; }; PushButton SV_PRINT_PAGE_BACKWARD { + HelpID = "vcl:PushButton:SV_DLG_PRINT:SV_PRINT_PAGE_BACKWARD"; Pos = MAP_APPFONT( 80, 140 ); Size = MAP_APPFONT( 15, 12 ); HelpText [en-US] = "Scroll one page backward."; }; TabControl SV_PRINT_TABCTRL { + HelpID = "vcl:TabControl:SV_DLG_PRINT:SV_PRINT_TABCTRL"; Pos = MAP_APPFONT( 140, 5 ); Size = MAP_APPFONT( 205, 175 ); }; @@ -123,6 +128,7 @@ ModalDialog SV_DLG_PRINT TabPage SV_PRINT_TAB_NUP { + HelpID = "vcl:TabPage:SV_PRINT_TAB_NUP"; Text [en-US] = "Page Layout"; Hide = TRUE; @@ -134,6 +140,7 @@ ModalDialog SV_DLG_PRINT }; RadioButton SV_PRINT_PRT_NUP_DEFAULT_BTN { + HelpID = "vcl:RadioButton:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_DEFAULT_BTN"; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 10 ); Text [en-US] = "~Default"; @@ -141,12 +148,14 @@ ModalDialog SV_DLG_PRINT }; RadioButton SV_PRINT_PRT_NUP_BROCHURE_BTN { + HelpID = "vcl:RadioButton:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_BROCHURE_BTN"; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 10 ); Text = ""; }; RadioButton SV_PRINT_PRT_NUP_PAGES_BTN { + HelpID = "vcl:RadioButton:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_PAGES_BTN"; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 10 ); Text [en-US] = "Pa~ges per sheet"; @@ -154,6 +163,7 @@ ModalDialog SV_DLG_PRINT }; ListBox SV_PRINT_PRT_NUP_PAGES_BOX { + HelpID = "vcl:ListBox:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_PAGES_BOX"; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 80 ); Border = TRUE; @@ -180,6 +190,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_PRT_NUP_COLS_EDT { + HelpID = "vcl:NumericField:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_COLS_EDT"; Pos = MAP_APPFONT( 55, 20 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; @@ -198,6 +209,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_PRT_NUP_ROWS_EDT { + HelpID = "vcl:NumericField:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_ROWS_EDT"; Pos = MAP_APPFONT( 55, 35 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; @@ -215,6 +227,7 @@ ModalDialog SV_DLG_PRINT }; MetricField SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT { + HelpID = "vcl:MetricField:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT"; Pos = MAP_APPFONT( 55, 95 ); Size = MAP_APPFONT( 40, 12 ); Spin = TRUE; @@ -237,6 +250,7 @@ ModalDialog SV_DLG_PRINT }; MetricField SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT { + HelpID = "vcl:MetricField:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT"; Pos = MAP_APPFONT( 155, 95 ); Size = MAP_APPFONT( 40, 12 ); Spin = TRUE; @@ -259,6 +273,7 @@ ModalDialog SV_DLG_PRINT }; ListBox SV_PRINT_PRT_NUP_ORIENTATION_BOX { + HelpID = "vcl:ListBox:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_ORIENTATION_BOX"; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 40 ); Border = TRUE; @@ -280,20 +295,24 @@ ModalDialog SV_DLG_PRINT }; ListBox SV_PRINT_PRT_NUP_ORDER_BOX { + HelpID = "vcl:ListBox:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_ORDER_BOX"; Pos = MAP_APPFONT( 0, 0 ); - Size = MAP_APPFONT( 10, 20 ); + Size = MAP_APPFONT( 10, 50 ); DropDown = TRUE; Border = TRUE; CurPos = 0; StringList [en-US] = { - < "left to right, then down"; SV_PRINT_PRT_NUP_ORDER_LRTD; >; - < "top to bottom, then right"; SV_PRINT_PRT_NUP_ORDER_TDLR; >; + < "left to right, then down"; SV_PRINT_PRT_NUP_ORDER_LRTB; >; + < "top to bottom, then right"; SV_PRINT_PRT_NUP_ORDER_TBLR; >; + < "top to bottom, then left"; SV_PRINT_PRT_NUP_ORDER_TBRL; >; + < "right to left, then down"; SV_PRINT_PRT_NUP_ORDER_RLTB; >; }; HelpText [en-US] = "Select order in which pages are to be printed."; }; CheckBox SV_PRINT_PRT_NUP_BORDER_CB { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_NUP:SV_PRINT_PRT_NUP_BORDER_CB"; Pos = MAP_APPFONT( 10, 65 ); Size = MAP_APPFONT( 150, 12 ); Text [en-US] = "Draw a border around each page"; @@ -303,6 +322,7 @@ ModalDialog SV_DLG_PRINT TabPage SV_PRINT_TAB_JOB { + HelpID = "vcl:TabPage:SV_PRINT_TAB_JOB"; Text [en-US] = "General"; Hide = TRUE; @@ -314,6 +334,7 @@ ModalDialog SV_DLG_PRINT }; ListBox SV_PRINT_PRINTERS { + HelpID = "vcl:ListBox:SV_PRINT_TAB_JOB:SV_PRINT_PRINTERS"; Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 100, 80 ); Border = TRUE; @@ -322,6 +343,7 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_DETAILS_BTN { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_JOB:SV_PRINT_DETAILS_BTN"; Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 5, 5 ); Text [en-US] = "Details"; @@ -347,6 +369,7 @@ ModalDialog SV_DLG_PRINT }; PushButton SV_PRINT_PRT_SETUP { + HelpID = "vcl:PushButton:SV_PRINT_TAB_JOB:SV_PRINT_PRT_SETUP"; Pos = MAP_APPFONT( 115, 5 ); Size = MAP_APPFONT( 50, 15 ); Text [en-US] = "Properties..."; @@ -366,6 +389,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_COPYCOUNT_FIELD { + HelpID = "vcl:NumericField:SV_PRINT_TAB_JOB:SV_PRINT_COPYCOUNT_FIELD"; Pos = MAP_APPFONT( 10, 56 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; @@ -382,6 +406,7 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_COLLATE { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_JOB:SV_PRINT_COLLATE"; Pos = MAP_APPFONT( 95, 45 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; @@ -411,6 +436,7 @@ ModalDialog SV_DLG_PRINT TabPage SV_PRINT_TAB_OPT { + HelpID = "vcl:TabPage:SV_PRINT_TAB_OPT"; Text [en-US] = "Options"; Hide = TRUE; @@ -422,6 +448,7 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_OPT_TOFILE { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_OPT:SV_PRINT_OPT_TOFILE"; Pos = MAP_APPFONT( 10, 20 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print to ~file"; @@ -429,6 +456,7 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_OPT_SINGLEJOBS { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_OPT:SV_PRINT_OPT_SINGLEJOBS"; Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "~Create single print jobs for collated output"; @@ -436,6 +464,7 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_OPT_REVERSE { + HelpID = "vcl:CheckBox:SV_PRINT_TAB_OPT:SV_PRINT_OPT_REVERSE"; Pos = MAP_APPFONT( 10, 50 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print in ~reverse page order"; @@ -446,6 +475,7 @@ ModalDialog SV_DLG_PRINT ModelessDialog SV_DLG_PRINT_PROGRESS { + HelpID = "vcl:ModelessDialog:SV_DLG_PRINT_PROGRESS"; Text [en-US] = "Printing"; Closeable = FALSE; Sizeable = FALSE; @@ -488,5 +518,6 @@ StringArray SV_PRINT_NATIVE_STRINGS < "Page number"; >; < "Number of pages"; >; < "More"; >; + < "Print selection only"; >; }; }; diff --git a/vcl/source/src/stdtext.src b/vcl/source/src/stdtext.src index 2c6574220a5f..1b95f7bb1d72 100644 --- a/vcl/source/src/stdtext.src +++ b/vcl/source/src/stdtext.src @@ -101,6 +101,11 @@ String SV_ACCESSERROR_TURNAROUND_MSG Text [ en-US ] = "The Java Access Bridge could not be started."; }; +String SV_ACCESSERROR_NO_FONTS +{ + Text [ en-US ] = "No fonts could be found on the system."; +}; + String SV_STDTEXT_ABOUT { Text [ en-US ] = "About %PRODUCTNAME"; diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index dad48235f8fb..9749299d4d6b 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -728,7 +728,10 @@ MatrixArranger::~MatrixArranger() { } -Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector<long>& o_rColumnWidths, std::vector<long>& o_rRowHeights ) const +Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, + std::vector<long>& o_rColumnWidths, std::vector<long>& o_rRowHeights, + std::vector<sal_Int32>& o_rColumnPrio, std::vector<sal_Int32>& o_rRowPrio + ) const { Size aMatrixSize( 2*m_nOuterBorder, 2*m_nOuterBorder ); @@ -746,6 +749,8 @@ Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector<long>& // now allocate row and column depth vectors o_rColumnWidths = std::vector< long >( nColumns, 0 ); o_rRowHeights = std::vector< long >( nRows, 0 ); + o_rColumnPrio = std::vector< sal_Int32 >( nColumns, 0 ); + o_rRowPrio = std::vector< sal_Int32 >( nRows, 0 ); // get sizes an allocate them into rows/columns for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); @@ -756,6 +761,10 @@ Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector<long>& o_rColumnWidths[ it->m_nX ] = aSize.Width(); if( aSize.Height() > o_rRowHeights[ it->m_nY ] ) o_rRowHeights[ it->m_nY ] = aSize.Height(); + if( it->m_nExpandPriority > o_rColumnPrio[ it->m_nX ] ) + o_rColumnPrio[ it->m_nX ] = it->m_nExpandPriority; + if( it->m_nExpandPriority > o_rRowPrio[ it->m_nY ] ) + o_rRowPrio[ it->m_nY ] = it->m_nExpandPriority; } // add up sizes @@ -775,9 +784,48 @@ Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector<long>& Size MatrixArranger::getOptimalSize( WindowSizeType i_eType ) const { std::vector<long> aColumnWidths, aRowHeights; - return getOptimalSize( i_eType, aColumnWidths, aRowHeights ); + std::vector<sal_Int32> aColumnPrio, aRowPrio; + return getOptimalSize( i_eType, aColumnWidths, aRowHeights, aColumnPrio, aRowPrio ); } +void MatrixArranger::distributeExtraSize( std::vector<long>& io_rSizes, const std::vector<sal_Int32>& i_rPrios, long i_nExtraWidth ) +{ + if( ! io_rSizes.empty() && io_rSizes.size() == i_rPrios.size() ) // sanity check + { + // find all elements with the highest expand priority + size_t nElements = io_rSizes.size(); + std::vector< size_t > aIndices; + sal_Int32 nHighPrio = 0; + for( size_t i = 0; i < nElements; i++ ) + { + sal_Int32 nCurPrio = i_rPrios[ i ]; + if( nCurPrio > nHighPrio ) + { + aIndices.clear(); + nHighPrio = nCurPrio; + } + if( nCurPrio == nHighPrio ) + aIndices.push_back( i ); + } + + // distribute extra space evenly among collected elements + nElements = aIndices.size(); + if( nElements > 0 ) + { + long nDelta = i_nExtraWidth / nElements; + for( size_t i = 0; i < nElements; i++ ) + { + io_rSizes[ aIndices[i] ] += nDelta; + i_nExtraWidth -= nDelta; + } + // add the last pixels to the last row element + if( i_nExtraWidth > 0 && nElements > 0 ) + io_rSizes[aIndices.back()] += i_nExtraWidth; + } + } +} + + void MatrixArranger::resize() { // assure that we have at least one row and column @@ -786,19 +834,30 @@ void MatrixArranger::resize() // check if we can get optimal size, else fallback to minimal size std::vector<long> aColumnWidths, aRowHeights; - Size aOptSize( getOptimalSize( WINDOWSIZE_PREFERRED, aColumnWidths, aRowHeights ) ); + std::vector<sal_Int32> aColumnPrio, aRowPrio; + Size aOptSize( getOptimalSize( WINDOWSIZE_PREFERRED, aColumnWidths, aRowHeights, aColumnPrio, aRowPrio ) ); if( aOptSize.Height() > m_aManagedArea.GetHeight() || aOptSize.Width() > m_aManagedArea.GetWidth() ) { std::vector<long> aMinColumnWidths, aMinRowHeights; - getOptimalSize( WINDOWSIZE_MINIMUM, aMinColumnWidths, aMinRowHeights ); + getOptimalSize( WINDOWSIZE_MINIMUM, aMinColumnWidths, aMinRowHeights, aColumnPrio, aRowPrio ); if( aOptSize.Height() > m_aManagedArea.GetHeight() ) aRowHeights = aMinRowHeights; if( aOptSize.Width() > m_aManagedArea.GetWidth() ) aColumnWidths = aMinColumnWidths; } - // FIXME: distribute extra space available + // distribute extra space available + long nExtraSize = m_aManagedArea.GetWidth(); + for( size_t i = 0; i < aColumnWidths.size(); ++i ) + nExtraSize -= aColumnWidths[i] + m_nBorderX; + if( nExtraSize > 0 ) + distributeExtraSize( aColumnWidths, aColumnPrio, nExtraSize ); + nExtraSize = m_aManagedArea.GetHeight(); + for( size_t i = 0; i < aRowHeights.size(); ++i ) + nExtraSize -= aRowHeights[i] + m_nBorderY; + if( nExtraSize > 0 ) + distributeExtraSize( aRowHeights, aRowPrio, nExtraSize ); // prepare offsets std::vector<long> aColumnX( aColumnWidths.size() ); diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index 2cd24857c156..79454d8b1fe5 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1151,15 +1151,13 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei if( mbNWFBorder ) { ImplControlValue aControlValue; - Region aCtrlRegion( Rectangle( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) ) ); - Region aBoundingRgn( aCtrlRegion ); - Region aContentRgn( aCtrlRegion ); + Rectangle aCtrlRegion( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) ); + Rectangle aBounds( aCtrlRegion ); + Rectangle aContent( aCtrlRegion ); if( pWin->GetNativeControlRegion( aCtrlType, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), - aBoundingRgn, aContentRgn ) ) + aBounds, aContent ) ) { - Rectangle aBounds( aBoundingRgn.GetBoundRect() ); - Rectangle aContent( aContentRgn.GetBoundRect() ); mnLeftBorder = aContent.Left() - aBounds.Left(); mnRightBorder = aBounds.Right() - aContent.Right(); mnTopBorder = aContent.Top() - aBounds.Top(); @@ -1346,13 +1344,16 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* nState |= CTRL_STATE_ROLLOVER; Point aPoint; - Region aCtrlRegion( Rectangle( aPoint, Size( mnWidth, mnHeight ) ) ); - - Region aBoundingRgn( Rectangle( aPoint, Size( mnWidth, mnHeight ) ) ); - Region aContentRgn=aCtrlRegion; - if(pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion, - nState, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn )) { - aCtrlRegion=aContentRgn; + Rectangle aCtrlRegion( aPoint, Size( mnWidth, mnHeight ) ); + + Rectangle aBoundingRgn( aPoint, Size( mnWidth, mnHeight ) ); + Rectangle aContentRgn( aCtrlRegion ); + if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize && + pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion, + nState, aControlValue, rtl::OUString(), + aBoundingRgn, aContentRgn )) + { + aCtrlRegion=aContentRgn; } bNativeOK = pWin->DrawNativeControl( aCtrlType, aCtrlPart, aCtrlRegion, nState, diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx index 4927505d7e4b..4ce3c34d65e4 100644 --- a/vcl/source/window/btndlg.cxx +++ b/vcl/source/window/btndlg.cxx @@ -530,22 +530,19 @@ XubString ButtonDialog::GetButtonHelpText( sal_uInt16 nId ) const // ----------------------------------------------------------------------- -void ButtonDialog::SetButtonHelpId( sal_uInt16 nId, sal_uIntPtr nHelpId ) +void ButtonDialog::SetButtonHelpId( sal_uInt16 nId, const rtl::OString& rHelpId ) { ImplBtnDlgItem* pItem = ImplGetItem( nId ); if ( pItem ) - pItem->mpPushButton->SetHelpId( nHelpId ); + pItem->mpPushButton->SetHelpId( rHelpId ); } // ----------------------------------------------------------------------- -sal_uIntPtr ButtonDialog::GetButtonHelpId( sal_uInt16 nId ) const +rtl::OString ButtonDialog::GetButtonHelpId( sal_uInt16 nId ) const { ImplBtnDlgItem* pItem = ImplGetItem( nId ); - if ( pItem ) - return pItem->mpPushButton->GetHelpId(); - else - return 0; + return pItem ? rtl::OString( pItem->mpPushButton->GetHelpId() ) : rtl::OString(); } diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index 31ecb4763e4b..117b13010602 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -877,12 +877,12 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect, if( pWin->GetType() == WINDOW_BORDERWINDOW ) nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER; ImplControlValue aControlValue( nValueStyle ); - Region aBound, aContent; - Region aNatRgn( rRect ); + Rectangle aBound, aContent; + Rectangle aNatRgn( rRect ); if(pWin && pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { - rRect = aContent.GetBoundRect(); + rRect = aContent; } else if ( nStyle & FRAME_DRAW_MONO ) ImplDrawDPILineRect( pDev, rRect, NULL, bRound ); @@ -922,15 +922,15 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect, if( pWin->GetType() == WINDOW_BORDERWINDOW ) nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER; ImplControlValue aControlValue( nValueStyle ); - Region aBound, aContent; - Region aNatRgn( rRect ); + Rectangle aBound, aContent; + Rectangle aNatRgn( rRect ); if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { if( pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED, aControlValue, rtl::OUString()) ) { - rRect = aContent.GetBoundRect(); + rRect = aContent; return; } } diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 5681d6c2b724..bf4cc231fcc7 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -1058,29 +1058,10 @@ static sal_Unicode getAccel( const String& rStr ) return nChar; } -Window* Window::GetLabelFor() const +static Window* ImplGetLabelFor( Window* pFrameWindow, WindowType nMyType, Window* pLabel, sal_Unicode nAccel ) { - if ( mpWindowImpl->mbDisableAccessibleLabelForRelation ) - return NULL; - Window* pWindow = NULL; - Window* pFrameWindow = ImplGetFrameWindow(); - - WinBits nFrameStyle = pFrameWindow->GetStyle(); - if( ! ( nFrameStyle & WB_DIALOGCONTROL ) - || ( nFrameStyle & WB_NODIALOGCONTROL ) - ) - return NULL; - - if ( mpWindowImpl->mpRealParent ) - pWindow = mpWindowImpl->mpRealParent->GetParentLabelFor( this ); - - if( pWindow ) - return pWindow; - sal_Unicode nAccel = getAccel( GetText() ); - - WindowType nMyType = GetType(); if( nMyType == WINDOW_FIXEDTEXT || nMyType == WINDOW_FIXEDLINE || nMyType == WINDOW_GROUPBOX ) @@ -1092,7 +1073,7 @@ Window* Window::GetLabelFor() const // get index, form start and form end sal_uInt16 nIndex=0, nFormStart=0, nFormEnd=0; pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow, - const_cast<Window*>(this), + pLabel, nIndex, nFormStart, nFormEnd ); @@ -1139,32 +1120,39 @@ Window* Window::GetLabelFor() const return pWindow; } -// ----------------------------------------------------------------------- - -Window* Window::GetLabeledBy() const +Window* Window::GetLabelFor() const { - if ( mpWindowImpl->mbDisableAccessibleLabeledByRelation ) + if ( mpWindowImpl->mbDisableAccessibleLabelForRelation ) return NULL; Window* pWindow = NULL; Window* pFrameWindow = ImplGetFrameWindow(); + WinBits nFrameStyle = pFrameWindow->GetStyle(); + if( ! ( nFrameStyle & WB_DIALOGCONTROL ) + || ( nFrameStyle & WB_NODIALOGCONTROL ) + ) + return NULL; + if ( mpWindowImpl->mpRealParent ) - pWindow = mpWindowImpl->mpRealParent->GetParentLabeledBy( this ); + pWindow = mpWindowImpl->mpRealParent->GetParentLabelFor( this ); if( pWindow ) return pWindow; - // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels - if( GetType() == WINDOW_CHECKBOX || GetType() == WINDOW_RADIOBUTTON ) - return NULL; + sal_Unicode nAccel = getAccel( GetText() ); -// if( ! ( GetType() == WINDOW_FIXEDTEXT || -// GetType() == WINDOW_FIXEDLINE || -// GetType() == WINDOW_GROUPBOX ) ) - // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text. - // See tools/options/print for example. - WindowType nMyType = GetType(); + pWindow = ImplGetLabelFor( pFrameWindow, GetType(), const_cast<Window*>(this), nAccel ); + if( ! pWindow && mpWindowImpl->mpRealParent ) + pWindow = ImplGetLabelFor( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this), nAccel ); + return pWindow; +} + +// ----------------------------------------------------------------------- + +static Window* ImplGetLabeledBy( Window* pFrameWindow, WindowType nMyType, Window* pLabeled ) +{ + Window* pWindow = NULL; if ( (nMyType != WINDOW_GROUPBOX) && (nMyType != WINDOW_FIXEDLINE) ) { // search for a control that labels this window @@ -1176,16 +1164,16 @@ Window* Window::GetLabeledBy() const // get form start and form end and index of this control sal_uInt16 nIndex, nFormStart, nFormEnd; Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow, - const_cast<Window*>(this), + pLabeled, nIndex, nFormStart, nFormEnd ); if( pSWindow && nIndex != nFormStart ) { - if( GetType() == WINDOW_PUSHBUTTON || - GetType() == WINDOW_HELPBUTTON || - GetType() == WINDOW_OKBUTTON || - GetType() == WINDOW_CANCELBUTTON ) + if( nMyType == WINDOW_PUSHBUTTON || + nMyType == WINDOW_HELPBUTTON || + nMyType == WINDOW_OKBUTTON || + nMyType == WINDOW_CANCELBUTTON ) { nFormStart = nIndex-1; } @@ -1217,6 +1205,39 @@ Window* Window::GetLabeledBy() const return pWindow; } +Window* Window::GetLabeledBy() const +{ + if ( mpWindowImpl->mbDisableAccessibleLabeledByRelation ) + return NULL; + + Window* pWindow = NULL; + Window* pFrameWindow = ImplGetFrameWindow(); + + if ( mpWindowImpl->mpRealParent ) + { + pWindow = mpWindowImpl->mpRealParent->GetParentLabeledBy( this ); + + if( pWindow ) + return pWindow; + } + + // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels + if( GetType() == WINDOW_CHECKBOX || GetType() == WINDOW_RADIOBUTTON ) + return NULL; + +// if( ! ( GetType() == WINDOW_FIXEDTEXT || +// GetType() == WINDOW_FIXEDLINE || +// GetType() == WINDOW_GROUPBOX ) ) + // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text. + // See tools/options/print for example. + + pWindow = ImplGetLabeledBy( pFrameWindow, GetType(), const_cast<Window*>(this) ); + if( ! pWindow && mpWindowImpl->mpRealParent ) + pWindow = ImplGetLabeledBy( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this) ); + + return pWindow; +} + // ----------------------------------------------------------------------- KeyEvent Window::GetActivationKey() const diff --git a/vcl/source/window/dndevdis.cxx b/vcl/source/window/dndevdis.cxx index efc49be6fbf8..e4d5a8c4c0eb 100644 --- a/vcl/source/window/dndevdis.cxx +++ b/vcl/source/window/dndevdis.cxx @@ -28,8 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <dndevdis.hxx> -#include <dndlcon.hxx> +#include <vcl/dndevdis.hxx> +#include <vcl/dndlcon.hxx> #include <vcl/window.h> #include <vos/mutex.hxx> diff --git a/vcl/source/window/dndevdis.hxx b/vcl/source/window/dndevdis.hxx deleted file mode 100644 index 5b91bd0713ec..000000000000 --- a/vcl/source/window/dndevdis.hxx +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * - ************************************************************************/ - -#ifndef _DNDEVDIS_HXX_ -#define _DNDEVDIS_HXX_ - -#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> -#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> - -#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGESTURERECOGNIZER_HPP_ -#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> -#endif -#include <cppuhelper/implbase3.hxx> -#include <vcl/window.hxx> - -class DNDEventDispatcher: public ::cppu::WeakImplHelper3< - ::com::sun::star::datatransfer::dnd::XDropTargetListener, - ::com::sun::star::datatransfer::dnd::XDropTargetDragContext, - ::com::sun::star::datatransfer::dnd::XDragGestureListener > -{ - Window * m_pTopWindow; - Window * m_pCurrentWindow; - - ::osl::Mutex m_aMutex; - ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavorList; - - /* - * fire the events on the dnd listener container of the specified window - */ - - sal_Int32 fireDragEnterEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, - const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction, - const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& aFlavorList ) throw(::com::sun::star::uno::RuntimeException); - - sal_Int32 fireDragOverEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, - const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction ) throw(::com::sun::star::uno::RuntimeException); - - sal_Int32 fireDragExitEvent( Window *pWindow ) throw(::com::sun::star::uno::RuntimeException); - - sal_Int32 fireDropActionChangedEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, - const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction ) throw(::com::sun::star::uno::RuntimeException); - - sal_Int32 fireDropEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext >& xContext, - const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction, - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable ) throw(::com::sun::star::uno::RuntimeException); - - sal_Int32 fireDragGestureEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >& xSource, - const ::com::sun::star::uno::Any event, const Point& rOrigin, const sal_Int8 nDragAction )throw(::com::sun::star::uno::RuntimeException); - -public: - - DNDEventDispatcher( Window * pTopWindow ); - virtual ~DNDEventDispatcher(); - - /* - * XDropTargetDragContext - */ - - virtual void SAL_CALL acceptDrag( sal_Int8 dropAction ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rejectDrag() throw(::com::sun::star::uno::RuntimeException); - - /* - * XDropTargetListener - */ - - virtual void SAL_CALL drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); - - /* - * XDragGestureListener - */ - - virtual void SAL_CALL dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw(::com::sun::star::uno::RuntimeException); - - - /* - * XEventListener - */ - - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& eo ) throw(::com::sun::star::uno::RuntimeException); -}; - -//================================================================================================== -// -//================================================================================================== - -#endif diff --git a/vcl/source/window/dndlcon.cxx b/vcl/source/window/dndlcon.cxx index c5d78dd6bae3..07819e76f957 100644 --- a/vcl/source/window/dndlcon.cxx +++ b/vcl/source/window/dndlcon.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include<dndlcon.hxx> +#include <vcl/dndlcon.hxx> using namespace ::cppu; using namespace ::com::sun::star::uno; diff --git a/vcl/source/window/dndlcon.hxx b/vcl/source/window/dndlcon.hxx deleted file mode 100644 index 5a41a20e4271..000000000000 --- a/vcl/source/window/dndlcon.hxx +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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. - * - ************************************************************************/ - -#ifndef _DNDLCON_HXX_ -#define _DNDLCON_HXX_ - -#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> -#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> -#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> -#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> -#include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp> -#include <cppuhelper/compbase4.hxx> - -#include <vcl/unohelp2.hxx> - -class DNDListenerContainer : public ::vcl::unohelper::MutexHelper, - public ::cppu::WeakComponentImplHelper4< - ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer, \ - ::com::sun::star::datatransfer::dnd::XDropTargetDragContext, - ::com::sun::star::datatransfer::dnd::XDropTargetDropContext, - ::com::sun::star::datatransfer::dnd::XDropTarget > -{ - sal_Bool m_bActive; - sal_Int8 m_nDefaultActions; - - ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext > m_xDropTargetDragContext; - ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext > m_xDropTargetDropContext; - -public: - - DNDListenerContainer( sal_Int8 nDefaultActions ); - virtual ~DNDListenerContainer(); - - sal_uInt32 fireDropEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext >& context, - sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions, - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& transferable ); - - sal_uInt32 fireDragExitEvent(); - - sal_uInt32 fireDragOverEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, - sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions ); - - sal_uInt32 fireDragEnterEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, - sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions, - const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& dataFlavor ); - - sal_uInt32 fireDropActionChangedEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, - sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions ); - - sal_uInt32 fireDragGestureEvent( - sal_Int8 dragAction, sal_Int32 dragOriginX, sal_Int32 dragOriginY, - const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >& dragSource, - const ::com::sun::star::uno::Any& triggerEvent ); - - /* - * XDragGestureRecognizer - */ - - virtual void SAL_CALL addDragGestureListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureListener >& dgl ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeDragGestureListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureListener >& dgl ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL resetRecognizer( ) throw(::com::sun::star::uno::RuntimeException); - - /* - * XDropTargetDragContext - */ - - virtual void SAL_CALL acceptDrag( sal_Int8 dragOperation ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rejectDrag( ) throw (::com::sun::star::uno::RuntimeException); - - - /* - * XDropTargetDropContext - */ - - virtual void SAL_CALL acceptDrop( sal_Int8 dropOperation ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rejectDrop( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dropComplete( sal_Bool success ) throw (::com::sun::star::uno::RuntimeException); - - /* - * XDropTarget - */ - - virtual void SAL_CALL addDropTargetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeDropTargetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isActive( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setActive( sal_Bool active ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(::com::sun::star::uno::RuntimeException); -}; - - -//================================================================================================== -// -//================================================================================================== - -#endif diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx index afdf5ca99035..6c8519b68a1e 100644 --- a/vcl/source/window/dockingarea.cxx +++ b/vcl/source/window/dockingarea.cxx @@ -152,23 +152,21 @@ void DockingAreaWindow::Paint( const Rectangle& ) EnableNativeWidget( sal_True ); // only required because the toolkit curently switches this flag off if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) ) { - ImplControlValue aControlValue; - ToolbarValue aToolbarValue; + ToolbarValue aControlValue; if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG ) { // give NWF a hint that this dockingarea is adjacent to the menubar // useful for special gradient effects that should cover both windows - aToolbarValue.mbIsTopDockingArea = sal_True; + aControlValue.mbIsTopDockingArea = sal_True; } - aControlValue.setOptionalVal( (void *)(&aToolbarValue) ); ControlState nState = CTRL_STATE_ENABLED; if( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB ) { // draw a single toolbar background covering the whole docking area Point tmp; - Region aCtrlRegion( Rectangle( tmp, GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( tmp, GetOutputSizePixel() ); DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT, aCtrlRegion, nState, aControlValue, rtl::OUString() ); @@ -231,7 +229,7 @@ void DockingAreaWindow::Paint( const Rectangle& ) aTBRect.Bottom() = aOutSz.Height() - 1; } DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT, - Region( aTBRect), nState, aControlValue, rtl::OUString() ); + aTBRect, nState, aControlValue, rtl::OUString() ); } } } diff --git a/vcl/source/window/javachild.cxx b/vcl/source/window/javachild.cxx index 2cd18b897ff5..aa198c85c138 100644 --- a/vcl/source/window/javachild.cxx +++ b/vcl/source/window/javachild.cxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: javachild.cxx,v $ + * $Revision: 1.12 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,32 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" - -#ifdef SOLAR_JAVA -#include <jni.h> -#endif -#include <comphelper/processfactory.hxx> - -#include <vcl/unohelp.hxx> -#include <rtl/process.h> -#include <rtl/ref.hxx> -#include <jvmaccess/virtualmachine.hxx> -#include <com/sun/star/java/XJavaVM.hpp> -#include <com/sun/star/java/XJavaThreadRegister_11.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -#ifndef _SV_SVSYS_HXX -#include <svsys.h> -#endif -#include <vcl/salinst.hxx> -#include <vcl/salframe.hxx> -#include <vcl/window.hxx> -#include <vcl/salobj.hxx> #include <vcl/javachild.hxx> -#include <vcl/svdata.hxx> -#include <vcl/sysdata.hxx> - -using namespace ::com::sun::star; // ------------------- // - JavaChildWindow - @@ -79,129 +57,7 @@ JavaChildWindow::~JavaChildWindow() // ----------------------------------------------------------------------- -void JavaChildWindow::implTestJavaException( void* pEnv ) -{ -#ifdef SOLAR_JAVA - JNIEnv* pJavaEnv = reinterpret_cast< JNIEnv* >( pEnv ); - jthrowable jtThrowable = pJavaEnv->ExceptionOccurred(); - - if( jtThrowable ) - { // is it a java exception ? -#if OSL_DEBUG_LEVEL > 1 - pJavaEnv->ExceptionDescribe(); -#endif // OSL_DEBUG_LEVEL > 1 - pJavaEnv->ExceptionClear(); - - jclass jcThrowable = pJavaEnv->FindClass("java/lang/Throwable"); - jmethodID jmThrowable_getMessage = pJavaEnv->GetMethodID(jcThrowable, "getMessage", "()Ljava/lang/String;"); - jstring jsMessage = (jstring) pJavaEnv->CallObjectMethod(jtThrowable, jmThrowable_getMessage); - ::rtl::OUString ouMessage; - - if(jsMessage) - { - const jchar * jcMessage = pJavaEnv->GetStringChars(jsMessage, NULL); - ouMessage = ::rtl::OUString(jcMessage); - pJavaEnv->ReleaseStringChars(jsMessage, jcMessage); - } - - throw uno::RuntimeException(ouMessage, uno::Reference<uno::XInterface>()); - } -#endif // SOLAR_JAVA -} - -// ----------------------------------------------------------------------- - sal_IntPtr JavaChildWindow::getParentWindowHandleForJava() { - sal_IntPtr nRet = 0; - -#if defined WNT - nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->hWnd ); -#elif defined QUARTZ - // FIXME: this is wrong - nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->pView ); -#elif defined UNX -#ifdef SOLAR_JAVA - uno::Reference< lang::XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() ); - - if( xFactory.is() && ( GetSystemData()->aWindow > 0 ) ) - { - try - { - ::rtl::Reference< ::jvmaccess::VirtualMachine > xVM; - uno::Reference< java::XJavaVM > xJavaVM( xFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine") ) ), uno::UNO_QUERY ); - uno::Sequence< sal_Int8 > aProcessID( 17 ); - - rtl_getGlobalProcessId( (sal_uInt8*) aProcessID.getArray() ); - aProcessID[ 16 ] = 0; - OSL_ENSURE(sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *), "Pointer cannot be represented as sal_Int64"); - sal_Int64 nPointer = reinterpret_cast< sal_Int64 >( static_cast< jvmaccess::VirtualMachine * >(0)); - xJavaVM->getJavaVM(aProcessID) >>= nPointer; - xVM = reinterpret_cast< jvmaccess::VirtualMachine * >(nPointer); - - if( xVM.is() ) - { - try - { - ::jvmaccess::VirtualMachine::AttachGuard aVMAttachGuard( xVM ); - JNIEnv* pEnv = aVMAttachGuard.getEnvironment(); - - jclass jcToolkit = pEnv->FindClass("java/awt/Toolkit"); - implTestJavaException(pEnv); - - jmethodID jmToolkit_getDefaultToolkit = pEnv->GetStaticMethodID( jcToolkit, "getDefaultToolkit", "()Ljava/awt/Toolkit;" ); - implTestJavaException(pEnv); - - pEnv->CallStaticObjectMethod(jcToolkit, jmToolkit_getDefaultToolkit); - implTestJavaException(pEnv); - - jclass jcMotifAppletViewer = pEnv->FindClass("sun/plugin/navig/motif/MotifAppletViewer"); - if( pEnv->ExceptionOccurred() ) - { - pEnv->ExceptionClear(); - - jcMotifAppletViewer = pEnv->FindClass( "sun/plugin/viewer/MNetscapePluginContext"); - implTestJavaException(pEnv); - } - - jclass jcClassLoader = pEnv->FindClass("java/lang/ClassLoader"); - implTestJavaException(pEnv); - - jmethodID jmClassLoader_loadLibrary = pEnv->GetStaticMethodID( jcClassLoader, "loadLibrary", "(Ljava/lang/Class;Ljava/lang/String;Z)V"); - implTestJavaException(pEnv); - - jstring jsplugin = pEnv->NewStringUTF("javaplugin_jni"); - implTestJavaException(pEnv); - - pEnv->CallStaticVoidMethod(jcClassLoader, jmClassLoader_loadLibrary, jcMotifAppletViewer, jsplugin, JNI_FALSE); - implTestJavaException(pEnv); - - jmethodID jmMotifAppletViewer_getWidget = pEnv->GetStaticMethodID( jcMotifAppletViewer, "getWidget", "(IIIII)I" ); - implTestJavaException(pEnv); - - const Size aSize( GetOutputSizePixel() ); - jint ji_widget = pEnv->CallStaticIntMethod( jcMotifAppletViewer, jmMotifAppletViewer_getWidget, - GetSystemData()->aWindow, 0, 0, aSize.Width(), aSize.Height() ); - implTestJavaException(pEnv); - - nRet = static_cast< sal_IntPtr >( ji_widget ); - } - catch( uno::RuntimeException& ) - { - } - - if( !nRet ) - nRet = static_cast< sal_IntPtr >( GetSystemData()->aWindow ); - } - } - catch( ... ) - { - } - } -#endif // SOLAR_JAVA -#else // WNT || QUARTZ || UNX - // TBD -#endif - - return nRet; + return SystemChildWindow::GetParentWindowHandle( sal_True ); } diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 4679915d3627..f79d83c6dc5d 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -157,7 +157,7 @@ struct MenuItemData XubString aTipHelpText; // TipHelp-String (eg, expanded filenames) XubString aCommandStr; // CommandString XubString aHelpCommandStr; // Help command string (to reference external help) - sal_uIntPtr nHelpId; // Help-Id + rtl::OString aHelpId; // Help-Id sal_uIntPtr nUserValue; // User value Image aImage; // Image KeyCode aAccelKey; // Accelerator-Key @@ -252,7 +252,6 @@ MenuItemData* MenuItemList::Insert( sal_uInt16 nId, MenuItemType eType, pData->nBits = nBits; pData->pSubMenu = NULL; pData->pAutoSubMenu = NULL; - pData->nHelpId = 0; pData->nUserValue = 0; pData->bChecked = sal_False; pData->bEnabled = sal_True; @@ -284,7 +283,6 @@ void MenuItemList::InsertSeparator( sal_uInt16 nPos ) pData->nBits = 0; pData->pSubMenu = NULL; pData->pAutoSubMenu = NULL; - pData->nHelpId = 0; pData->nUserValue = 0; pData->bChecked = sal_False; pData->bEnabled = sal_True; @@ -844,14 +842,14 @@ static sal_Bool ImplHandleHelpEvent( Window* pMenuWindow, Menu* pMenu, sal_uInt1 // Ist eine ID vorhanden, dann Hilfe mit der ID aufrufen, sonst // den Hilfe-Index String aCommand = pMenu->GetItemCommand( nId ); - sal_uIntPtr nHelpId = pMenu->GetHelpId( nId ); + rtl::OString aHelpId( pMenu->GetHelpId( nId ) ); + if( ! aHelpId.getLength() ) + aHelpId = OOO_HELP_INDEX; if ( aCommand.Len() ) pHelp->Start( aCommand, NULL ); - else if ( nHelpId ) - pHelp->Start( nHelpId, NULL ); else - pHelp->Start( OOO_HELP_INDEX, NULL ); + pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), NULL ); } bDone = sal_True; } @@ -938,6 +936,14 @@ Menu::~Menu() if ( nEventId ) Application::RemoveUserEvent( nEventId ); + // Notify deletion of this menu + ImplMenuDelData* pDelData = mpFirstDel; + while ( pDelData ) + { + pDelData->mpMenu = NULL; + pDelData = pDelData->mpNext; + } + bKilled = sal_True; delete pItemList; @@ -970,9 +976,9 @@ void Menu::ImplInit() bInCallback = sal_False; bKilled = sal_False; mpLayoutData = NULL; - + mpFirstDel = NULL; // Dtor notification list // Native-support: returns NULL if not supported - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu( bIsMenuBar ); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu( bIsMenuBar, this ); } Menu* Menu::ImplGetStartedFrom() const @@ -1034,19 +1040,29 @@ void Menu::CreateAutoMnemonics() void Menu::Activate() { bInCallback = sal_True; + + ImplMenuDelData aDelData( this ); + ImplCallEventListeners( VCLEVENT_MENU_ACTIVATE, ITEMPOS_INVALID ); - if ( !aActivateHdl.Call( this ) ) + + if( !aDelData.isDeleted() ) { - Menu* pStartMenu = ImplGetStartMenu(); - if ( pStartMenu && ( pStartMenu != this ) ) + if ( !aActivateHdl.Call( this ) ) { - pStartMenu->bInCallback = sal_True; - // MT 11/01: Call EventListener here? I don't know... - pStartMenu->aActivateHdl.Call( this ); - pStartMenu->bInCallback = sal_False; + if( !aDelData.isDeleted() ) + { + Menu* pStartMenu = ImplGetStartMenu(); + if ( pStartMenu && ( pStartMenu != this ) ) + { + pStartMenu->bInCallback = sal_True; + // MT 11/01: Call EventListener here? I don't know... + pStartMenu->aActivateHdl.Call( this ); + pStartMenu->bInCallback = sal_False; + } + } } + bInCallback = sal_False; } - bInCallback = sal_False; } void Menu::Deactivate() @@ -1059,33 +1075,49 @@ void Menu::Deactivate() } bInCallback = sal_True; + + ImplMenuDelData aDelData( this ); + Menu* pStartMenu = ImplGetStartMenu(); ImplCallEventListeners( VCLEVENT_MENU_DEACTIVATE, ITEMPOS_INVALID ); - if ( !aDeactivateHdl.Call( this ) ) + + if( !aDelData.isDeleted() ) { - if ( pStartMenu && ( pStartMenu != this ) ) + if ( !aDeactivateHdl.Call( this ) ) { - pStartMenu->bInCallback = sal_True; - pStartMenu->aDeactivateHdl.Call( this ); - pStartMenu->bInCallback = sal_False; + if( !aDelData.isDeleted() ) + { + if ( pStartMenu && ( pStartMenu != this ) ) + { + pStartMenu->bInCallback = sal_True; + pStartMenu->aDeactivateHdl.Call( this ); + pStartMenu->bInCallback = sal_False; + } + } } } - bInCallback = sal_False; - if ( this == pStartMenu ) - GetpApp()->HideHelpStatusText(); + if( !aDelData.isDeleted() ) + { + bInCallback = sal_False; + + if ( this == pStartMenu ) + GetpApp()->HideHelpStatusText(); + } } void Menu::Highlight() { + ImplMenuDelData aDelData( this ); + Menu* pStartMenu = ImplGetStartMenu(); - if ( !aHighlightHdl.Call( this ) ) + if ( !aHighlightHdl.Call( this ) && !aDelData.isDeleted() ) { if ( pStartMenu && ( pStartMenu != this ) ) pStartMenu->aHighlightHdl.Call( this ); } - if ( GetCurItemId() ) + if ( !aDelData.isDeleted() && GetCurItemId() ) GetpApp()->ShowHelpStatusText( GetHelpText( GetCurItemId() ) ); } @@ -1112,14 +1144,19 @@ void Menu::ImplSelect() void Menu::Select() { + ImplMenuDelData aDelData( this ); + ImplCallEventListeners( VCLEVENT_MENU_SELECT, GetItemPos( GetCurItemId() ) ); - if ( !aSelectHdl.Call( this ) ) + if ( !aDelData.isDeleted() && !aSelectHdl.Call( this ) ) { - Menu* pStartMenu = ImplGetStartMenu(); - if ( pStartMenu && ( pStartMenu != this ) ) + if( !aDelData.isDeleted() ) { - pStartMenu->nSelectedId = nSelectedId; - pStartMenu->aSelectHdl.Call( this ); + Menu* pStartMenu = ImplGetStartMenu(); + if ( pStartMenu && ( pStartMenu != this ) ) + { + pStartMenu->nSelectedId = nSelectedId; + pStartMenu->aSelectHdl.Call( this ); + } } } } @@ -1141,6 +1178,8 @@ void Menu::RequestHelp( const HelpEvent& ) void Menu::ImplCallEventListeners( sal_uIntPtr nEvent, sal_uInt16 nPos ) { + ImplMenuDelData aDelData( this ); + VclMenuEvent aEvent( this, nEvent, nPos ); // This is needed by atk accessibility bridge @@ -1149,16 +1188,22 @@ void Menu::ImplCallEventListeners( sal_uIntPtr nEvent, sal_uInt16 nPos ) ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent ); } - if ( !maEventListeners.empty() ) + if ( !aDelData.isDeleted() && !maEventListeners.empty() ) maEventListeners.Call( &aEvent ); - Menu* pMenu = this; - while ( pMenu ) + if( !aDelData.isDeleted() ) { - if ( !maChildEventListeners.empty() ) - maChildEventListeners.Call( &aEvent ); + Menu* pMenu = this; + while ( pMenu ) + { + if ( !maChildEventListeners.empty() ) + maChildEventListeners.Call( &aEvent ); - pMenu = ( pMenu->pStartedFrom != pMenu ) ? pMenu->pStartedFrom : NULL; + if( aDelData.isDeleted() ) + break; + + pMenu = ( pMenu->pStartedFrom != pMenu ) ? pMenu->pStartedFrom : NULL; + } } } @@ -1283,15 +1328,14 @@ void Menu::InsertItem( const ResId& rResId, sal_uInt16 nPos ) SetHelpText( nItemId, aHelpText ); } - sal_uIntPtr nHelpId = 0; if ( nObjMask & RSC_MENUITEM_HELPID ) { - nHelpId = ReadLongRes(); + rtl::OString aHelpId( ReadByteStringRes() ); if ( !bSep ) - SetHelpId( nItemId, nHelpId ); + SetHelpId( nItemId, aHelpId ); } - if( !bSep /* && SvHelpSettings::HelpText( aHelpText, nHelpId ) */ ) + if( !bSep ) SetHelpText( nItemId, aHelpText ); if ( nObjMask & RSC_MENUITEM_KEYCODE ) @@ -1416,7 +1460,7 @@ void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 n pThis->CheckItem( nId, sal_True ); if ( !rMenu.IsItemEnabled( nId ) ) pThis->EnableItem( nId, sal_False ); - pThis->SetHelpId( nId, pData->nHelpId ); + pThis->SetHelpId( nId, pData->aHelpId ); pThis->SetHelpText( nId, pData->aHelpText ); pThis->SetAccelKey( nId, pData->aAccelKey ); pThis->SetItemCommand( nId, pData->aCommandStr ); @@ -1992,7 +2036,7 @@ const XubString& Menu::ImplGetHelpText( sal_uInt16 nItemId ) const if ( pData ) { if ( !pData->aHelpText.Len() && - (( pData->nHelpId ) || ( pData->aCommandStr.Len() ))) + (( pData->aHelpId.getLength() ) || ( pData->aCommandStr.Len() ))) { Help* pHelp = Application::GetHelp(); if ( pHelp ) @@ -2000,8 +2044,8 @@ const XubString& Menu::ImplGetHelpText( sal_uInt16 nItemId ) const if ( pData->aCommandStr.Len() ) pData->aHelpText = pHelp->GetHelpText( pData->aCommandStr, NULL ); - if( !pData->aHelpText.Len() && pData->nHelpId ) - pData->aHelpText = pHelp->GetHelpText( pData->nHelpId, NULL ); + if( !pData->aHelpText.Len() && pData->aHelpId.getLength() ) + pData->aHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pData->aHelpId, RTL_TEXTENCODING_UTF8 ), NULL ); } } @@ -2034,22 +2078,29 @@ const XubString& Menu::GetTipHelpText( sal_uInt16 nItemId ) const return ImplGetSVEmptyStr(); } -void Menu::SetHelpId( sal_uInt16 nItemId, sal_uIntPtr nHelpId ) +void Menu::SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ) { MenuItemData* pData = pItemList->GetData( nItemId ); if ( pData ) - pData->nHelpId = nHelpId; + pData->aHelpId = rHelpId; } -sal_uIntPtr Menu::GetHelpId( sal_uInt16 nItemId ) const +rtl::OString Menu::GetHelpId( sal_uInt16 nItemId ) const { + rtl::OString aRet; + MenuItemData* pData = pItemList->GetData( nItemId ); if ( pData ) - return pData->nHelpId; - else - return 0; + { + if ( pData->aHelpId.getLength() ) + aRet = pData->aHelpId; + else + aRet = ::rtl::OUStringToOString( pData->aCommandStr, RTL_TEXTENCODING_UTF8 ); + } + + return aRet; } Menu& Menu::operator=( const Menu& rMenu ) @@ -2221,10 +2272,10 @@ long Menu::ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, lon if( ! bIsMenuBar ) { ImplControlValue aVal; - Region aNativeBounds; - Region aNativeContent; + Rectangle aNativeBounds; + Rectangle aNativeContent; Point tmp( 0, 0 ); - Region aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); + Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) { if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), @@ -2237,8 +2288,8 @@ long Menu::ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, lon aNativeContent ) ) { - rCheckHeight = aNativeBounds.GetBoundRect().GetHeight(); - rMaxWidth = aNativeContent.GetBoundRect().GetWidth(); + rCheckHeight = aNativeBounds.GetHeight(); + rMaxWidth = aNativeContent.GetWidth(); } } if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) @@ -2253,14 +2304,50 @@ long Menu::ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, lon aNativeContent ) ) { - rRadioHeight = aNativeBounds.GetBoundRect().GetHeight(); - rMaxWidth = Max (rMaxWidth, aNativeContent.GetBoundRect().GetWidth()); + rRadioHeight = aNativeBounds.GetHeight(); + rMaxWidth = Max (rMaxWidth, aNativeContent.GetWidth()); } } } return (rCheckHeight > rRadioHeight) ? rCheckHeight : rRadioHeight; } +// ----------------------------------------------------------------------- + +void Menu::ImplAddDel( ImplMenuDelData& rDel ) +{ + DBG_ASSERT( !rDel.mpMenu, "Menu::ImplAddDel(): cannot add ImplMenuDelData twice !" ); + if( !rDel.mpMenu ) + { + rDel.mpMenu = this; + rDel.mpNext = mpFirstDel; + mpFirstDel = &rDel; + } +} + +// ----------------------------------------------------------------------- + +void Menu::ImplRemoveDel( ImplMenuDelData& rDel ) +{ + rDel.mpMenu = NULL; + if ( mpFirstDel == &rDel ) + { + mpFirstDel = rDel.mpNext; + } + else + { + ImplMenuDelData* pData = mpFirstDel; + while ( pData && (pData->mpNext != &rDel) ) + pData = pData->mpNext; + + DBG_ASSERT( pData, "Menu::ImplRemoveDel(): ImplMenuDelData not registered !" ); + if( pData ) + pData->mpNext = rDel.mpNext; + } +} + +// ----------------------------------------------------------------------- + Size Menu::ImplCalcSize( Window* pWin ) { // | Checked| Image| Text| Accel/Popup| @@ -2397,6 +2484,16 @@ Size Menu::ImplCalcSize( Window* pWin ) if ( !bIsMenuBar ) { + // popup menus should not be wider than half the screen + // except on rather small screens + // TODO: move GetScreenNumber from SystemWindow to Window ? + // currently we rely on internal privileges + unsigned int nScreenNumber = pWin->ImplGetWindowImpl()->mpFrame->maGeometry.nScreenNumber; + Rectangle aDispRect( Application::GetScreenPosSizePixel( nScreenNumber ) ); + long nScreenWidth = aDispRect.GetWidth() >= 800 ? aDispRect.GetWidth() : 800; + if( nMaxWidth > nScreenWidth/2 ) + nMaxWidth = nScreenWidth/2; + sal_uInt16 gfxExtra = (sal_uInt16) Max( nExtra, 7L ); // #107710# increase space between checkmarks/images/text nCheckPos = (sal_uInt16)nExtra; if (nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) @@ -2433,10 +2530,10 @@ Size Menu::ImplCalcSize( Window* pWin ) if( pWindow->IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) ) { ImplControlValue aVal; - Region aNativeBounds; - Region aNativeContent; + Rectangle aNativeBounds; + Rectangle aNativeContent; Point tmp( 0, 0 ); - Region aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); + Rectangle aCtrlRegion( tmp, Size( 100, 15 ) ); if( pWindow->GetNativeControlRegion( ControlType(CTRL_MENUBAR), ControlPart(PART_ENTIRE_CONTROL), aCtrlRegion, @@ -2447,7 +2544,7 @@ Size Menu::ImplCalcSize( Window* pWin ) aNativeContent ) ) { - int nNativeHeight = aNativeBounds.GetBoundRect().GetHeight(); + int nNativeHeight = aNativeBounds.GetHeight(); if( nNativeHeight > aSz.Height() ) aSz.Height() = nNativeHeight; } @@ -2472,7 +2569,7 @@ static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRec if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) { ImplControlValue aControlValue; - Region aCtrlRegion( i_rRect ); + Rectangle aCtrlRegion( i_rRect ); ControlState nState = CTRL_STATE_PRESSED | CTRL_STATE_ENABLED; aControlValue.setTristateVal( BUTTONVALUE_ON ); @@ -2490,6 +2587,26 @@ static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRec } } +static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_nMaxWidth ) +{ + xub_StrLen nPos = STRING_NOTFOUND; + String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) ); + aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS ); + // re-insert mnemonic + if( nPos != STRING_NOTFOUND ) + { + if( nPos < aNonMnem.Len() && i_rLong.GetChar(nPos+1) == aNonMnem.GetChar(nPos) ) + { + rtl::OUStringBuffer aBuf( i_rLong.Len() ); + aBuf.append( aNonMnem.GetBuffer(), nPos ); + aBuf.append( sal_Unicode('~') ); + aBuf.append( aNonMnem.GetBuffer()+nPos ); + aNonMnem = aBuf.makeStringAndClear(); + } + } + return aNonMnem; +} + void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, sal_Bool bHighlighted, bool bLayout ) const { // Fuer Symbole: nFontHeight x nFontHeight @@ -2606,7 +2723,7 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) ); pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart, - Region( aCheckRect ), + aCheckRect, nState, ImplControlValue(), OUString() ); @@ -2680,7 +2797,19 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa pWin->GetSettings().GetStyleSettings().GetMenuColor(); pWin->SetBackground( Wallpaper( aBg ) ); } - pWin->DrawCtrlText( aTmpPos, pData->aText, 0, pData->aText.Len(), nStyle, pVector, pDisplayText ); + // how much space is there for the text ? + long nMaxItemTextWidth = aOutSz.Width() - aTmpPos.X() - nExtra - nOuterSpace; + if( !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() ) + { + XubString aAccText = pData->aAccelKey.GetName(); + nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 3*nExtra; + } + if( !bIsMenuBar && pData->pSubMenu ) + { + nMaxItemTextWidth -= nFontHeight - nExtra; + } + String aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) ); + pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.Len(), nStyle, pVector, pDisplayText ); if( bSetTmpBackground ) pWin->SetBackground(); } @@ -2790,13 +2919,19 @@ Menu* Menu::ImplGetStartMenu() void Menu::ImplCallHighlight( sal_uInt16 nHighlightedItem ) { + ImplMenuDelData aDelData( this ); + nSelectedId = 0; MenuItemData* pData = pItemList->GetDataFromPos( nHighlightedItem ); if ( pData ) nSelectedId = pData->nId; ImplCallEventListeners( VCLEVENT_MENU_HIGHLIGHT, GetItemPos( GetCurItemId() ) ); - Highlight(); - nSelectedId = 0; + + if( !aDelData.isDeleted() ) + { + Highlight(); + nSelectedId = 0; + } } IMPL_LINK( Menu, ImplCallSelect, Menu*, EMPTYARG ) @@ -3292,10 +3427,14 @@ sal_Bool MenuBar::HandleMenuActivateEvent( Menu *pMenu ) const { if( pMenu ) { + ImplMenuDelData aDelData( this ); + pMenu->pStartedFrom = (Menu*)this; pMenu->bInCallback = sal_True; pMenu->Activate(); - pMenu->bInCallback = sal_False; + + if( !aDelData.isDeleted() ) + pMenu->bInCallback = sal_False; } return sal_True; } @@ -3304,10 +3443,13 @@ sal_Bool MenuBar::HandleMenuDeActivateEvent( Menu *pMenu ) const { if( pMenu ) { + ImplMenuDelData aDelData( this ); + pMenu->pStartedFrom = (Menu*)this; pMenu->bInCallback = sal_True; pMenu->Deactivate(); - pMenu->bInCallback = sal_False; + if( !aDelData.isDeleted() ) + pMenu->bInCallback = sal_False; } return sal_True; } @@ -3318,13 +3460,18 @@ sal_Bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEv pMenu = ((Menu*) this)->ImplFindMenu( nHighlightEventId ); if( pMenu ) { + ImplMenuDelData aDelData( pMenu ); + if( mnHighlightedItemPos != ITEMPOS_INVALID ) pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, mnHighlightedItemPos ); - pMenu->mnHighlightedItemPos = pMenu->GetItemPos( nHighlightEventId ); - pMenu->nSelectedId = nHighlightEventId; - pMenu->pStartedFrom = (Menu*)this; - pMenu->ImplCallHighlight( pMenu->mnHighlightedItemPos ); + if( !aDelData.isDeleted() ) + { + pMenu->mnHighlightedItemPos = pMenu->GetItemPos( nHighlightEventId ); + pMenu->nSelectedId = nHighlightEventId; + pMenu->pStartedFrom = (Menu*)this; + pMenu->ImplCallHighlight( pMenu->mnHighlightedItemPos ); + } return sal_True; } else @@ -3621,7 +3768,7 @@ sal_uInt16 PopupMenu::ImplExecute( Window* pW, const Rectangle& rRect, sal_uIntP if ( GetItemCount() ) { SalMenu* pMenu = ImplGetSalMenu(); - if( pMenu && pMenu->ShowNativePopupMenu( pWin, aRect, nPopupModeFlags | FLOATWIN_POPUPMODE_GRABFOCUS ) ) + if( pMenu && bRealExecute && pMenu->ShowNativePopupMenu( pWin, aRect, nPopupModeFlags | FLOATWIN_POPUPMODE_GRABFOCUS ) ) { pWin->StopExecute(0); pWin->doShutdown(); @@ -4578,7 +4725,7 @@ void MenuFloatingWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) IntersectClipRegion( Rectangle( Point( nX, nY ), Size( aSz.Width(), pData->aSz.Height() ) ) ); Rectangle aCtrlRect( Point( nX, 0 ), Size( aPxSize.Width()-nX, aPxSize.Height() ) ); DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, - Region( aCtrlRect ), + aCtrlRect, CTRL_STATE_ENABLED, ImplControlValue(), OUString() ); @@ -4587,7 +4734,7 @@ void MenuFloatingWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) { bDrawItemRect = false; if( sal_False == DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_ITEM, - Region( aItemRect ), + aItemRect, CTRL_STATE_SELECTED | ( pData->bEnabled? CTRL_STATE_ENABLED: 0 ), ImplControlValue(), OUString() ) ) @@ -4925,7 +5072,7 @@ void MenuFloatingWindow::Paint( const Rectangle& ) Size aPxSize( GetOutputSizePixel() ); aPxSize.Width() -= nX; DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, - Region( Rectangle( Point( nX, 0 ), aPxSize ) ), + Rectangle( Point( nX, 0 ), aPxSize ), CTRL_STATE_ENABLED, ImplControlValue(), OUString() ); @@ -5439,23 +5586,21 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) ) { // draw background (transparency) - ImplControlValue aControlValue; - MenubarValue aMenubarValue; - aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - aControlValue.setOptionalVal( (void *)(&aMenubarValue) ); + MenubarValue aControlValue; + aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); Point tmp(0,0); - Region aBgRegion( Rectangle( tmp, GetOutputSizePixel() ) ); + Rectangle aBgRegion( tmp, GetOutputSizePixel() ); DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aBgRegion, CTRL_STATE_ENABLED, aControlValue, OUString() ); - ImplAddNWFSeparator( this, aMenubarValue ); + ImplAddNWFSeparator( this, aControlValue ); // draw selected item DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM, - Region( aRect ), + aRect, CTRL_STATE_ENABLED | CTRL_STATE_SELECTED, aControlValue, OUString() ); @@ -5471,18 +5616,15 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) { if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) { - ImplControlValue aControlValue; MenubarValue aMenubarValue; aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - aControlValue.setOptionalVal( (void *)(&aMenubarValue) ); // use full window size to get proper gradient // but clip accordingly Point aPt; Rectangle aCtrlRect( aPt, GetOutputSizePixel() ); - Region aCtrlRegion( aCtrlRect ); - DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString() ); + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, CTRL_STATE_ENABLED, aMenubarValue, rtl::OUString() ); ImplAddNWFSeparator( this, aMenubarValue ); } else @@ -5713,14 +5855,12 @@ void MenuBarWindow::Paint( const Rectangle& ) if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) { Point aPt; - Region aCtrlRegion( Rectangle( aPt, GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( aPt, GetOutputSizePixel() ); - ImplControlValue aControlValue; MenubarValue aMenubarValue; aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - aControlValue.setOptionalVal( (void *)(&aMenubarValue) ); - DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString() ); + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aMenubarValue, rtl::OUString() ); ImplAddNWFSeparator( this, aMenubarValue ); } SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); @@ -5989,3 +6129,17 @@ bool MenuBarWindow::HandleMenuButtonEvent( sal_uInt16 i_nButtonId ) } return sal_False; } + +ImplMenuDelData::ImplMenuDelData( const Menu* pMenu ) +: mpNext( 0 ) +, mpMenu( 0 ) +{ + if( pMenu ) + const_cast< Menu* >( pMenu )->ImplAddDel( *this ); +} + +ImplMenuDelData::~ImplMenuDelData() +{ + if( mpMenu ) + const_cast< Menu* >( mpMenu )->ImplRemoveDel( *this ); +} diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index 487476e97fc2..60d6f6b27fbf 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -196,10 +196,9 @@ MessBox::MessBox( Window* pParent, const ResId& rResId ) : sal_uInt16 nLoButtons = ReadShortRes(); sal_uInt16 nHiDefButton = ReadShortRes(); sal_uInt16 nLoDefButton = ReadShortRes(); - sal_uInt16 nHiHelpId = ReadShortRes(); - sal_uInt16 nLoHelpId = ReadShortRes(); + rtl::OString aHelpId( ReadByteStringRes() ); /* sal_uInt16 bSysModal = */ ReadShortRes(); - SetHelpId( ((sal_uIntPtr)nHiHelpId << 16) + nLoHelpId ); + SetHelpId( aHelpId ); WinBits nBits = (((sal_uIntPtr)nHiButtons << 16) + nLoButtons) | (((sal_uIntPtr)nHiDefButton << 16) + nLoDefButton); ImplInit( pParent, nBits | WB_MOVEABLE | WB_HORZ | WB_CENTER ); @@ -233,7 +232,7 @@ MessBox::~MessBox() void MessBox::ImplPosControls() { - if ( GetHelpId() ) + if ( GetHelpId().getLength() ) { if ( !mbHelpBtn ) { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 875dd7950780..cc1dc965034f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -46,7 +46,7 @@ #include "unotools/localedatawrapper.hxx" -#include "rtl/ustrbuf.hxx" +#include "rtl/strbuf.hxx" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/container/XNameAccess.hpp" @@ -61,14 +61,16 @@ using namespace com::sun::star::container; using namespace com::sun::star::beans; #define HELPID_PREFIX ".HelpId:vcl:PrintDialog" -#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ), HID_PRINTDLG ) ) -#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ), HID_PRINTDLG ) ) +#define SMHID2( a, b ) SetHelpId( rtl::OString( HELPID_PREFIX ":" a ":" b ) ) +#define SMHID1( a ) SetHelpId( rtl::OString( HELPID_PREFIX ":" a ) ) PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ) , maOrigSize( 10, 10 ) , maPageVDev( *this ) , maToolTipString( String( VclResId( SV_PRINT_PRINTPREVIEW_TXT ) ) ) + , maHorzDim( this, WB_HORZ | WB_CENTER ) + , maVertDim( this, WB_VERT | WB_VCENTER ) { SetPaintTransparent( sal_True ); SetBackground(); @@ -76,6 +78,11 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const Re maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); else maPageVDev.SetBackground( Color( COL_WHITE ) ); + maHorzDim.Show(); + maVertDim.Show(); + + maHorzDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); + maVertDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); } PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() @@ -162,9 +169,10 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC void PrintDialog::PrintPreviewWindow::Resize() { Size aNewSize( GetSizePixel() ); + long nTextHeight = maHorzDim.GetTextHeight(); // leave small space for decoration - aNewSize.Width() -= 2; - aNewSize.Height() -= 2; + aNewSize.Width() -= nTextHeight + 2; + aNewSize.Height() -= nTextHeight + 2; Size aScaledSize; double fScale = 1.0; @@ -206,16 +214,28 @@ void PrintDialog::PrintPreviewWindow::Resize() } maPageVDev.SetOutputSizePixel( aScaledSize, sal_False ); + + // position dimension lines + Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2, + nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 ); + maHorzDim.SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ), + Size( maPreviewSize.Width(), nTextHeight ) ); + maVertDim.SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ), + Size( nTextHeight, maPreviewSize.Height() ) ); + } void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { + long nTextHeight = maHorzDim.GetTextHeight(); Size aSize( GetSizePixel() ); + aSize.Width() -= nTextHeight; + aSize.Height() -= nTextHeight; if( maReplacementString.getLength() != 0 ) { // replacement is active Push(); - Rectangle aTextRect( Point( 0, 0 ), aSize ); + Rectangle aTextRect( Point( nTextHeight, nTextHeight ), aSize ); DecorationView aVw( this ); aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP ); aTextRect.Left() += 2; @@ -233,8 +253,8 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { GDIMetaFile aMtf( maMtf ); - Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2, - (aSize.Height() - maPreviewSize.Height()) / 2 ); + Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2 + nTextHeight, + (aSize.Height() - maPreviewSize.Height()) / 2 + nTextHeight ); Size aVDevSize( maPageVDev.GetOutputSizePixel() ); const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); @@ -294,13 +314,6 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi { rtl::OUStringBuffer aBuf( 256 ); aBuf.append( maToolTipString ); - #if OSL_DEBUG_LEVEL > 0 - aBuf.appendAscii( "\n---\nPageSize: " ); - aBuf.append( sal_Int32( i_rOrigSize.Width()/100) ); - aBuf.appendAscii( "mm x " ); - aBuf.append( sal_Int32( i_rOrigSize.Height()/100) ); - aBuf.appendAscii( "mm" ); - #endif SetQuickHelpText( aBuf.makeStringAndClear() ); maMtf = i_rNewPreview; if( useHCColorReplacement() ) @@ -312,6 +325,27 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi maReplacementString = i_rReplacement; maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); maPageVDev.EnableOutput( sal_True ); + + // use correct measurements + const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() ); + MapUnit eUnit = MAP_MM; + int nDigits = 0; + if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) + { + eUnit = MAP_100TH_INCH; + nDigits = 2; + } + Size aLogicPaperSize( LogicToLogic( i_rOrigSize, MapMode( MAP_100TH_MM ), MapMode( eUnit ) ) ); + String aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) ); + aBuf.append( aNumText ); + aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); + maHorzDim.SetText( aBuf.makeStringAndClear() ); + + aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ); + aBuf.append( aNumText ); + aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); + maVertDim.SetText( aBuf.makeStringAndClear() ); + Resize(); Invalidate(); } @@ -364,12 +398,18 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) int nX = 0, nY = 0; switch( mnOrderMode ) { - case SV_PRINT_PRT_NUP_ORDER_LRTD: + case SV_PRINT_PRT_NUP_ORDER_LRTB: nX = (i % mnColumns); nY = (i / mnColumns); break; - case SV_PRINT_PRT_NUP_ORDER_TDLR: + case SV_PRINT_PRT_NUP_ORDER_TBLR: nX = (i / mnRows); nY = (i % mnRows); break; + case SV_PRINT_PRT_NUP_ORDER_RLTB: + nX = mnColumns - 1 - (i % mnColumns); nY = (i / mnColumns); + break; + case SV_PRINT_PRT_NUP_ORDER_TBRL: + nX = mnColumns - 1 - (i / mnRows); nY = (i % mnRows); + break; } Size aTextSize( GetTextWidth( aPageText ), nTextHeight ); int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2; @@ -498,8 +538,10 @@ void PrintDialog::NUpTabPage::showAdvancedControls( bool i_bShow ) void PrintDialog::NUpTabPage::setupLayout() { - Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - long nIndent = 3*aBorder.Width(); + Size aBorder( LogicToPixel( Size( 6, 6 ), MapMode( MAP_APPFONT ) ) ); + /* According to OOo style guide, the horizontal indentation of child + elements to their parent element should always be 6 map units. */ + long nIndent = aBorder.Width(); maLayout.setParentWindow( this ); maLayout.setOuterBorder( aBorder.Width() ); @@ -1125,24 +1167,24 @@ bool PrintDialog::isSingleJobs() static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId = -1, const rtl::OUString& i_rPropName = rtl::OUString() ) { - rtl::OUStringBuffer aBuf( 256 ); - aBuf.appendAscii( HELPID_PREFIX ); + rtl::OStringBuffer aBuf( 256 ); + aBuf.append( HELPID_PREFIX ); if( i_rPropName.getLength() ) { - aBuf.append( sal_Unicode( ':' ) ); - aBuf.append( i_rPropName ); + aBuf.append( ':' ); + aBuf.append( rtl::OUStringToOString( i_rPropName, RTL_TEXTENCODING_UTF8 ) ); } if( i_pType ) { - aBuf.append( sal_Unicode( ':' ) ); - aBuf.appendAscii( i_pType ); + aBuf.append( ':' ); + aBuf.append( i_pType ); } if( i_nId >= 0 ) { - aBuf.append( sal_Unicode( ':' ) ); + aBuf.append( ':' ); aBuf.append( i_nId ); } - i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear(), HID_PRINTDLG ) ); + i_pWindow->SetHelpId( aBuf.makeStringAndClear() ); } static void setHelpText( Window* /*i_pWindow*/, const Sequence< rtl::OUString >& /*i_rHelpTexts*/, sal_Int32 /*i_nIndex*/ ) @@ -1192,6 +1234,7 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + Sequence< sal_Bool > aChoicesDisabled; Sequence< rtl::OUString > aHelpTexts; sal_Int64 nMinValue = 0, nMaxValue = 0; sal_Int32 nCurHelpText = 0; @@ -1215,6 +1258,10 @@ void PrintDialog::setupOptionalUI() { rEntry.Value >>= aChoices; } + else if( rEntry.Name.equalsAscii( "ChoicesDisabled" ) ) + { + rEntry.Value >>= aChoicesDisabled; + } else if( rEntry.Name.equalsAscii( "Property" ) ) { PropertyValue aVal; @@ -1497,6 +1544,8 @@ void PrintDialog::setupOptionalUI() pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); + if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] == sal_True ) + pBtn->Enable( sal_False ); pBtn->Show(); maPropertyToWindowMap[ aPropertyName ].push_back( pBtn ); maControlToPropertyMap[pBtn] = aPropertyName; @@ -1821,6 +1870,16 @@ void PrintDialog::checkOptionalControlDependencies() } } + if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first) ) + { + std::map< Window*, sal_Int32 >::const_iterator r_it = maControlToNumValMap.find( it->first ); + if( r_it != maControlToNumValMap.end() ) + { + bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second ); + } + } + + bool bIsEnabled = it->first->IsEnabled(); // Enable does not do a change check first, so can be less cheap than expected if( bShouldbeEnabled != bIsEnabled ) @@ -2059,10 +2118,14 @@ void PrintDialog::updateNup() int nOrderMode = int(sal_IntPtr(maNUpPage.maNupOrderBox.GetEntryData( maNUpPage.maNupOrderBox.GetSelectEntryPos() ))); - if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTD ) + if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTB ) aMPS.nOrder = PrinterController::LRTB; - else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TDLR ) + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBLR ) aMPS.nOrder = PrinterController::TBLR; + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_RLTB ) + aMPS.nOrder = PrinterController::RLTB; + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBRL ) + aMPS.nOrder = PrinterController::TBRL; int nOrientationMode = int(sal_IntPtr(maNUpPage.maNupOrientationBox.GetEntryData( maNUpPage.maNupOrientationBox.GetSelectEntryPos() ))); @@ -2128,7 +2191,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) if( pHelp ) { // FIXME: find out proper help URL and use here - pHelp->Start( HID_PRINTDLG, GetParent() ); + pHelp->Start( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ), GetParent() ); } } else if( pButton == &maForwardBtn ) @@ -2514,13 +2577,13 @@ void PrintProgressDialog::implCalcProgressRect() if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) { ImplControlValue aValue; - Region aControlRegion( Rectangle( Point(), Size( 100, mnProgressHeight ) ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Point(), Size( 100, mnProgressHeight ) ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) { - mnProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + mnProgressHeight = aNativeControlRegion.GetHeight(); } mbNativeProgress = true; } @@ -2556,6 +2619,7 @@ void PrintProgressDialog::tick() void PrintProgressDialog::reset() { + mbCanceled = false; setProgress( 0 ); } diff --git a/vcl/source/window/seleng.cxx b/vcl/source/window/seleng.cxx index a61d2e7290bf..9d7727493490 100644 --- a/vcl/source/window/seleng.cxx +++ b/vcl/source/window/seleng.cxx @@ -218,8 +218,15 @@ sal_Bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt ) Point aPos = rMEvt.GetPosPixel(); aLastMove = rMEvt; - pWin->CaptureMouse(); - nFlags |= SELENG_IN_SEL; + if( !rMEvt.IsRight() ) + { + pWin->CaptureMouse(); + nFlags |= SELENG_IN_SEL; + } + else + { + nModifier = 0; + } switch ( nModifier ) { @@ -327,7 +334,7 @@ sal_Bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt ) |* *************************************************************************/ -sal_Bool SelectionEngine::SelMouseButtonUp( const MouseEvent& /* rMEvt */ ) +sal_Bool SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt ) { aWTimer.Stop(); //DbgOut("Up"); @@ -336,7 +343,11 @@ sal_Bool SelectionEngine::SelMouseButtonUp( const MouseEvent& /* rMEvt */ ) nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL); return sal_False; } - pWin->ReleaseMouse(); + + if( !rMEvt.IsRight() ) + { + pWin->ReleaseMouse(); + } if( (nFlags & SELENG_WAIT_UPEVT) && !(nFlags & SELENG_CMDEVT) && eSelMode != SINGLE_SELECTION) diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index a698e13c7695..3a66ead3944c 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -49,7 +49,8 @@ // ======================================================================= -// Achtung: Darf keine Objekte enthalten, da mit memmove/memcpy gearbeitet wird +// Attention: Must not contain non-PODs because array is enlarged/copied +// with the use of memmove/memcpy. struct ImplSplitItem { long mnSize; @@ -71,6 +72,10 @@ struct ImplSplitItem SplitWindowItemBits mnBits; sal_Bool mbFixed; sal_Bool mbSubSize; + /// Minimal width or height of the item. -1 means no restriction. + long mnMinSize; + /// Maximal width or height of the item. -1 means no restriction. + long mnMaxSize; }; struct ImplSplitSet @@ -85,6 +90,28 @@ struct ImplSplitSet sal_Bool mbCalcPix; }; + + +/** Check whether the given size is inside the valid range defined by + [rItem.mnMinSize,rItem.mnMaxSize]. When it is not inside it then return + the upper or lower bound, respectively. Otherwise return the given size + unmodified. + Note that either mnMinSize and/or mnMaxSize can be -1 in which case the + size has not lower or upper bound. +*/ +namespace { + long ValidateSize (const long nSize, const ImplSplitItem rItem) + { + if (rItem.mnMinSize>=0 && nSize<rItem.mnMinSize) + return rItem.mnMinSize; + else if (rItem.mnMaxSize>0 && nSize>rItem.mnMaxSize) + return rItem.mnMaxSize; + else + return nSize; + } +} + + #define SPLITWIN_SPLITSIZE 3 #define SPLITWIN_SPLITSIZEEX 4 #define SPLITWIN_SPLITSIZEEXLN 6 @@ -2850,7 +2877,7 @@ void SplitWindow::InsertItem( sal_uInt16 nId, Window* pWindow, long nSize, DBG_ASSERT( !ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::InsertItem() - Id already exists" ); #endif - // Size muss min. 1 sein + // Size has to be at least 1. if ( nSize < 1 ) nSize = 1; @@ -2858,7 +2885,7 @@ void SplitWindow::InsertItem( sal_uInt16 nId, Window* pWindow, long nSize, ImplSplitSet* pNewSet; ImplSplitItem* pItem; - // Platz fuer neues Item schaffen + // Make room for the new item. if ( nPos > pSet->mnItems ) nPos = pSet->mnItems; ImplSplitItem* pNewItems = new ImplSplitItem[pSet->mnItems+1]; @@ -2871,19 +2898,21 @@ void SplitWindow::InsertItem( sal_uInt16 nId, Window* pWindow, long nSize, pSet->mnItems++; pSet->mbCalcPix = sal_True; - // Item anlegen und erweitern + // Create and initialize item. pItem = &(pSet->mpItems[nPos]); memset( pItem, 0, sizeof( ImplSplitItem ) ); pItem->mnSize = nSize; pItem->mnId = nId; pItem->mnBits = nBits; + pItem->mnMinSize=-1; + pItem->mnMaxSize=-1; if ( pWindow ) { pItem->mpWindow = pWindow; pItem->mpOrgParent = pWindow->GetParent(); - // Window mit SplitWindow verbinden + // Attach window to SplitWindow. pWindow->Hide(); pWindow->SetParent( this ); } @@ -3251,6 +3280,10 @@ void SplitWindow::SplitItem( sal_uInt16 nId, long nNewSize, nItems = pSet->mnItems; pItems = pSet->mpItems; + // When there is an explicit minimum or maximum size then move nNewSize + // into that range (when it is not yet already in it.) + nNewSize = ValidateSize(nNewSize, pItems[nPos]); + if ( mbCalc ) { pItems[nPos].mnSize = nNewSize; @@ -3552,6 +3585,36 @@ long SplitWindow::GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const return 0; } + + + +void SplitWindow::SetItemSizeRange (sal_uInt16 nId, const Range aRange) +{ + sal_uInt16 nPos; + ImplSplitSet* pSet = ImplFindItem(mpBaseSet, nId, nPos); + + if (pSet != NULL) + { + pSet->mpItems[nPos].mnMinSize = aRange.Min(); + pSet->mpItems[nPos].mnMaxSize = aRange.Max(); + } +} + + + + +Range SplitWindow::GetItemSizeRange (sal_uInt16 nId) const +{ + sal_uInt16 nPos; + ImplSplitSet* pSet = ImplFindItem(mpBaseSet, nId, nPos); + + if (pSet != NULL) + return Range (pSet->mpItems[nPos].mnMinSize, pSet->mpItems[nPos].mnMaxSize); + else + return Range(-1,-1); +} + + // ----------------------------------------------------------------------- void SplitWindow::SetItemBits( sal_uInt16 nId, SplitWindowItemBits nNewBits ) diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 69f87705e7a4..3ad9fc72d575 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -89,7 +89,7 @@ struct ImplStatusItem XubString maText; XubString maHelpText; XubString maQuickHelpText; - sal_uIntPtr mnHelpId; + rtl::OString maHelpId; void* mpUserData; sal_Bool mbVisible; XubString maAccessibleName; @@ -320,6 +320,8 @@ void StatusBar::ImplFormat() nExtraWidth2 = 0; } nX = STATUSBAR_OFFSET_X; + if( ImplHasMirroredGraphics() && IsRTLEnabled() ) + nX += ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset; } pItem = mpItemList->First(); @@ -544,7 +546,7 @@ void DrawProgress( Window* pWindow, const Point& rPos, long nPerc = (nPercent2 > 10000) ? 10000 : nPercent2; ImplControlValue aValue( nFullWidth * (long)nPerc / 10000 ); Rectangle aDrawRect( rPos, Size( nFullWidth, nPrgsHeight ) ); - Region aControlRegion( aDrawRect ); + Rectangle aControlRegion( aDrawRect ); if( bNeedErase ) { Window* pEraseWindow = pWindow; @@ -711,13 +713,13 @@ void StatusBar::ImplCalcProgressRect() if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) { ImplControlValue aValue; - Region aControlRegion( Rectangle( (const Point&)Point(), maPrgsFrameRect.GetSize() ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Rectangle( (const Point&)Point(), maPrgsFrameRect.GetSize() ) ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) != sal_False ) { - long nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + long nProgressHeight = aNativeControlRegion.GetHeight(); if( nProgressHeight > maPrgsFrameRect.GetHeight() ) { long nDelta = nProgressHeight - maPrgsFrameRect.GetHeight(); @@ -833,7 +835,7 @@ void StatusBar::Resize() { // Breite und Hoehe abfragen und merken Size aSize = GetOutputSizePixel(); - mnDX = aSize.Width(); + mnDX = aSize.Width() - ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset; mnDY = aSize.Height(); mnCalcHeight = mnDY; // subtract border @@ -904,9 +906,9 @@ void StatusBar::RequestHelp( const HelpEvent& rHEvt ) else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { String aCommand = GetItemCommand( nItemId ); - sal_uIntPtr nHelpId = GetHelpId( nItemId ); + rtl::OString aHelpId( GetHelpId( nItemId ) ); - if ( aCommand.Len() || nHelpId ) + if ( aCommand.Len() || aHelpId.getLength() ) { // Wenn eine Hilfe existiert, dann ausloesen Help* pHelp = Application::GetHelp(); @@ -914,8 +916,8 @@ void StatusBar::RequestHelp( const HelpEvent& rHEvt ) { if ( aCommand.Len() ) pHelp->Start( aCommand, this ); - else if ( nHelpId ) - pHelp->Start( nHelpId, this ); + else if ( aHelpId.getLength() ) + pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), this ); } return; } @@ -1031,7 +1033,6 @@ void StatusBar::InsertItem( sal_uInt16 nItemId, sal_uIntPtr nWidth, pItem->mnBits = nBits; pItem->mnWidth = (long)nWidth+nFudge+STATUSBAR_OFFSET; pItem->mnOffset = nOffset; - pItem->mnHelpId = 0; pItem->mpUserData = 0; pItem->mbVisible = sal_True; @@ -1473,15 +1474,15 @@ const XubString& StatusBar::GetHelpText( sal_uInt16 nItemId ) const if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { ImplStatusItem* pItem = mpItemList->GetObject( nPos ); - if ( !pItem->maHelpText.Len() && ( pItem->mnHelpId || pItem->maCommand.Len() )) + if ( !pItem->maHelpText.Len() && ( pItem->maHelpId.getLength() || pItem->maCommand.Len() )) { Help* pHelp = Application::GetHelp(); if ( pHelp ) { if ( pItem->maCommand.Len() ) pItem->maHelpText = pHelp->GetHelpText( pItem->maCommand, this ); - if ( !pItem->maHelpText.Len() && pItem->mnHelpId ) - pItem->maHelpText = pHelp->GetHelpText( pItem->mnHelpId, this ); + if ( !pItem->maHelpText.Len() && pItem->maHelpId.getLength() ) + pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this ); } } @@ -1518,24 +1519,31 @@ const XubString& StatusBar::GetQuickHelpText( sal_uInt16 nItemId ) const // ----------------------------------------------------------------------- -void StatusBar::SetHelpId( sal_uInt16 nItemId, sal_uIntPtr nHelpId ) +void StatusBar::SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ) { sal_uInt16 nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - mpItemList->GetObject( nPos )->mnHelpId = nHelpId; + mpItemList->GetObject( nPos )->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -sal_uIntPtr StatusBar::GetHelpId( sal_uInt16 nItemId ) const +rtl::OString StatusBar::GetHelpId( sal_uInt16 nItemId ) const { sal_uInt16 nPos = GetItemPos( nItemId ); + rtl::OString aRet; if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mnHelpId; - else - return 0; + { + ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + if ( pItem->maHelpId.getLength() ) + aRet = pItem->maHelpId; + else + aRet = ::rtl::OUStringToOString( pItem->maCommand, RTL_TEXTENCODING_UTF8 ); + } + + return aRet; } // ----------------------------------------------------------------------- @@ -1723,13 +1731,13 @@ Size StatusBar::CalcWindowSizePixel() const if( pThis->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) { ImplControlValue aValue; - Region aControlRegion( Rectangle( (const Point&)Point(), Size( nCalcWidth, nMinHeight ) ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( (const Point&)Point(), Size( nCalcWidth, nMinHeight ) ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( pThis->GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + nProgressHeight = aNativeControlRegion.GetHeight(); } } @@ -1737,14 +1745,13 @@ Size StatusBar::CalcWindowSizePixel() const pThis->IsNativeControlSupported( CTRL_FRAME, PART_BORDER ) ) { ImplControlValue aControlValue( FRAME_DRAW_NODRAW ); - Region aBound, aContent; - Region aNatRgn( Rectangle( Point( 0, 0 ), Size( 150, 50 ) ) ); + Rectangle aBound, aContent; + Rectangle aNatRgn( Point( 0, 0 ), Size( 150, 50 ) ); if( pThis->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { mpImplData->mnItemBorderWidth = - ( aBound.GetBoundRect().GetHeight() - - aContent.GetBoundRect().GetHeight() ) / 2; + ( aBound.GetHeight() - aContent.GetHeight() ) / 2; } } diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx index 7e24afc38092..9e7a30e983cb 100644 --- a/vcl/source/window/syschild.cxx +++ b/vcl/source/window/syschild.cxx @@ -28,25 +28,34 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_SVSYS_HXX #include <svsys.h> -#endif +#include <rtl/process.h> +#include <rtl/ref.hxx> +#include <tools/rc.h> +#include <vcl/window.h> #include <vcl/salinst.hxx> #include <vcl/salframe.hxx> #include <vcl/window.hxx> #include <vcl/salobj.hxx> - -#ifndef _SV_RC_H -#include <tools/rc.h> -#endif #include <vcl/svdata.hxx> -#ifndef _SV_WIDNOW_H -#include <vcl/window.h> -#endif +#include <vcl/sysdata.hxx> #include <vcl/svapp.hxx> #include <vcl/syschild.hxx> +#include <vcl/unohelp.hxx> +#ifdef SOLAR_JAVA +#include <jni.h> +#endif + +#include <comphelper/processfactory.hxx> +#include <jvmaccess/virtualmachine.hxx> +#include <com/sun/star/java/XJavaVM.hpp> +#include <com/sun/star/java/XJavaThreadRegister_11.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vcl/syschild.hxx> +using namespace ::com::sun::star; // ======================================================================= @@ -183,6 +192,8 @@ void SystemChildWindow::EnableEraseBackground( sal_Bool bEnable ) mpWindowImpl->mpSysObj->EnableEraseBackground( bEnable ); } +// ----------------------------------------------------------------------- + sal_Bool SystemChildWindow::IsEraseBackgroundEnabled() { if ( mpWindowImpl->mpSysObj ) @@ -190,3 +201,138 @@ sal_Bool SystemChildWindow::IsEraseBackgroundEnabled() else return sal_False; } + +// ----------------------------------------------------------------------- + +void SystemChildWindow::ImplTestJavaException( void* pEnv ) +{ +#ifdef SOLAR_JAVA + JNIEnv* pJavaEnv = reinterpret_cast< JNIEnv* >( pEnv ); + jthrowable jtThrowable = pJavaEnv->ExceptionOccurred(); + + if( jtThrowable ) + { // is it a java exception ? +#if OSL_DEBUG_LEVEL > 1 + pJavaEnv->ExceptionDescribe(); +#endif // OSL_DEBUG_LEVEL > 1 + pJavaEnv->ExceptionClear(); + + jclass jcThrowable = pJavaEnv->FindClass("java/lang/Throwable"); + jmethodID jmThrowable_getMessage = pJavaEnv->GetMethodID(jcThrowable, "getMessage", "()Ljava/lang/String;"); + jstring jsMessage = (jstring) pJavaEnv->CallObjectMethod(jtThrowable, jmThrowable_getMessage); + ::rtl::OUString ouMessage; + + if(jsMessage) + { + const jchar * jcMessage = pJavaEnv->GetStringChars(jsMessage, NULL); + ouMessage = ::rtl::OUString(jcMessage); + pJavaEnv->ReleaseStringChars(jsMessage, jcMessage); + } + + throw uno::RuntimeException(ouMessage, uno::Reference<uno::XInterface>()); + } +#endif // SOLAR_JAVA +} + +// ----------------------------------------------------------------------- + +sal_IntPtr SystemChildWindow::GetParentWindowHandle( sal_Bool bUseJava ) +{ + sal_IntPtr nRet = 0; + +#if defined WNT + nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->hWnd ); +#elif defined QUARTZ + // FIXME: this is wrong + nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->pView ); +#elif defined UNX + if( !bUseJava ) + { + nRet = (sal_IntPtr) GetSystemData()->aWindow; + } +#ifdef SOLAR_JAVA + else + { + uno::Reference< lang::XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() ); + + if( xFactory.is() && ( GetSystemData()->aWindow > 0 ) ) + { + try + { + ::rtl::Reference< ::jvmaccess::VirtualMachine > xVM; + uno::Reference< java::XJavaVM > xJavaVM( xFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine") ) ), uno::UNO_QUERY ); + uno::Sequence< sal_Int8 > aProcessID( 17 ); + + rtl_getGlobalProcessId( (sal_uInt8*) aProcessID.getArray() ); + aProcessID[ 16 ] = 0; + OSL_ENSURE(sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *), "Pointer cannot be represented as sal_Int64"); + sal_Int64 nPointer = reinterpret_cast< sal_Int64 >( static_cast< jvmaccess::VirtualMachine * >(0)); + xJavaVM->getJavaVM(aProcessID) >>= nPointer; + xVM = reinterpret_cast< jvmaccess::VirtualMachine * >(nPointer); + + if( xVM.is() ) + { + try + { + ::jvmaccess::VirtualMachine::AttachGuard aVMAttachGuard( xVM ); + JNIEnv* pEnv = aVMAttachGuard.getEnvironment(); + + jclass jcToolkit = pEnv->FindClass("java/awt/Toolkit"); + ImplTestJavaException(pEnv); + + jmethodID jmToolkit_getDefaultToolkit = pEnv->GetStaticMethodID( jcToolkit, "getDefaultToolkit", "()Ljava/awt/Toolkit;" ); + ImplTestJavaException(pEnv); + + pEnv->CallStaticObjectMethod(jcToolkit, jmToolkit_getDefaultToolkit); + ImplTestJavaException(pEnv); + + jclass jcMotifAppletViewer = pEnv->FindClass("sun/plugin/navig/motif/MotifAppletViewer"); + if( pEnv->ExceptionOccurred() ) + { + pEnv->ExceptionClear(); + + jcMotifAppletViewer = pEnv->FindClass( "sun/plugin/viewer/MNetscapePluginContext"); + ImplTestJavaException(pEnv); + } + + jclass jcClassLoader = pEnv->FindClass("java/lang/ClassLoader"); + ImplTestJavaException(pEnv); + + jmethodID jmClassLoader_loadLibrary = pEnv->GetStaticMethodID( jcClassLoader, "loadLibrary", "(Ljava/lang/Class;Ljava/lang/String;Z)V"); + ImplTestJavaException(pEnv); + + jstring jsplugin = pEnv->NewStringUTF("javaplugin_jni"); + ImplTestJavaException(pEnv); + + pEnv->CallStaticVoidMethod(jcClassLoader, jmClassLoader_loadLibrary, jcMotifAppletViewer, jsplugin, JNI_FALSE); + ImplTestJavaException(pEnv); + + jmethodID jmMotifAppletViewer_getWidget = pEnv->GetStaticMethodID( jcMotifAppletViewer, "getWidget", "(IIIII)I" ); + ImplTestJavaException(pEnv); + + const Size aSize( GetOutputSizePixel() ); + jint ji_widget = pEnv->CallStaticIntMethod( jcMotifAppletViewer, jmMotifAppletViewer_getWidget, + GetSystemData()->aWindow, 0, 0, aSize.Width(), aSize.Height() ); + ImplTestJavaException(pEnv); + + nRet = static_cast< sal_IntPtr >( ji_widget ); + } + catch( uno::RuntimeException& ) + { + } + + if( !nRet ) + nRet = static_cast< sal_IntPtr >( GetSystemData()->aWindow ); + } + } + catch( ... ) + { + } + } + } +#endif // SOLAR_JAVA +#else // WNT || QUARTZ || UNX +#endif + + return nRet; +} diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 019ad941e5d6..b1947c5c8aae 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -773,7 +773,7 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) sal_Bool bWrapped = sal_False; while( pWin ) { - if( !pWin->ImplIsRealParentPath( this ) && + if( !pWin->ImplIsRealParentPath( this ) && ( pWin != this ) && pWin->ImplGetWindow()->IsTopWindow() && pWin->mpWindowImpl->mbReallyVisible ) { SalFrameGeometry g = pWin->mpWindowImpl->mpFrame->GetGeometry(); diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx index 26e9b9ec309a..efee2aa38979 100644 --- a/vcl/source/window/tabpage.cxx +++ b/vcl/source/window/tabpage.cxx @@ -149,7 +149,7 @@ void TabPage::Paint( const Rectangle& ) // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design) if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) ) { - const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + const ImplControlValue aControlValue; ControlState nState = CTRL_STATE_ENABLED; int part = PART_ENTIRE_CONTROL; @@ -160,7 +160,7 @@ void TabPage::Paint( const Rectangle& ) Point aPoint; // pass the whole window region to NWF as the tab body might be a gradient or bitmap // that has to be scaled properly, clipping makes sure that we do not paint too much - Region aCtrlRegion( Rectangle( aPoint, GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( aPoint, GetOutputSizePixel() ); DrawNativeControl( CTRL_TAB_BODY, part, aCtrlRegion, nState, aControlValue, rtl::OUString() ); } diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx index 2ecaf93f4e93..71a8f2ec2a30 100644 --- a/vcl/source/window/taskpanelist.cxx +++ b/vcl/source/window/taskpanelist.cxx @@ -206,7 +206,7 @@ sal_Bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent ) sal_Bool bFocusInList = sal_False; KeyCode aKeyCode = aKeyEvent.GetKeyCode(); sal_Bool bForward = !aKeyCode.IsShift(); - if( aKeyCode.GetCode() == KEY_F6 ) // F6 + if( aKeyCode.GetCode() == KEY_F6 && ! aKeyCode.IsMod2() ) // F6 { bSplitterOnly = aKeyCode.IsMod1() && aKeyCode.IsShift(); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index a3b3a1dfdbe4..a659aec19019 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -215,13 +215,13 @@ int ToolBox::ImplGetDragWidth( ToolBox* pThis ) ImplControlValue aControlValue; Point aPoint; - Region aContent, aBound; - Region aArea( Rectangle(aPoint, pThis->GetOutputSizePixel()) ); + Rectangle aContent, aBound; + Rectangle aArea( aPoint, pThis->GetOutputSizePixel() ); if ( pThis->GetNativeControlRegion(CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { - width = pThis->mbHorz ? aContent.GetBoundRect().GetWidth() : aContent.GetBoundRect().GetHeight(); + width = pThis->mbHorz ? aContent.GetWidth() : aContent.GetHeight(); } } return width; @@ -338,16 +338,14 @@ void ToolBox::ImplDrawGrip( ToolBox* pThis ) sal_Bool bNativeOk = sal_False; if( pThis->IsNativeControlSupported( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_HORZ : PART_THUMB_VERT ) ) { - ImplControlValue aControlValue; ToolbarValue aToolbarValue; aToolbarValue.maGripRect = pWrapper->GetDragArea(); - aControlValue.setOptionalVal( (void *)(&aToolbarValue) ); Point aPt; - Region aCtrlRegion( Rectangle( aPt, pThis->GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( aPt, pThis->GetOutputSizePixel() ); ControlState nState = CTRL_STATE_ENABLED; bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ, - aCtrlRegion, nState, aControlValue, rtl::OUString() ); + aCtrlRegion, nState, aToolbarValue, rtl::OUString() ); } if( bNativeOk ) @@ -557,7 +555,7 @@ sal_Bool ToolBox::ImplDrawNativeBackground( ToolBox* pThis, const Region & ) { // use NWF Point aPt; - Region aCtrlRegion( Rectangle( aPt, pThis->GetOutputSizePixel() ) ); + Rectangle aCtrlRegion( aPt, pThis->GetOutputSizePixel() ); ControlState nState = CTRL_STATE_ENABLED; return pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT, @@ -1918,9 +1916,9 @@ sal_Bool ToolBox::ImplCalcItem() // determine minimum size necessary in NWF { Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); - Region aReg = aRect; + Rectangle aReg( aRect ); ImplControlValue aVal; - Region aNativeBounds, aNativeContent; + Rectangle aNativeBounds, aNativeContent; if( IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) { if( GetNativeControlRegion( CTRL_TOOLBAR, PART_BUTTON, @@ -1929,7 +1927,7 @@ sal_Bool ToolBox::ImplCalcItem() aVal, OUString(), aNativeBounds, aNativeContent ) ) { - aRect = aNativeBounds.GetBoundRect(); + aRect = aNativeBounds; if( aRect.GetWidth() > nMinWidth ) nMinWidth = aRect.GetWidth(); if( aRect.GetHeight() > nMinHeight ) @@ -1954,7 +1952,7 @@ sal_Bool ToolBox::ImplCalcItem() aVal, OUString(), aNativeBounds, aNativeContent ) ) { - aRect = aNativeBounds.GetBoundRect(); + aRect = aNativeBounds; if( aRect.GetHeight() > mnWinHeight ) mnWinHeight = aRect.GetHeight(); } @@ -1966,7 +1964,7 @@ sal_Bool ToolBox::ImplCalcItem() aVal, OUString(), aNativeBounds, aNativeContent ) ) { - aRect = aNativeBounds.GetBoundRect(); + aRect = aNativeBounds; if( aRect.GetHeight() > mnWinHeight ) mnWinHeight = aRect.GetHeight(); } @@ -1978,7 +1976,7 @@ sal_Bool ToolBox::ImplCalcItem() aVal, OUString(), aNativeBounds, aNativeContent ) ) { - aRect = aNativeBounds.GetBoundRect(); + aRect = aNativeBounds; if( aRect.GetHeight() > mnWinHeight ) mnWinHeight = aRect.GetHeight(); } @@ -3418,7 +3416,6 @@ static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 h if( !bIsWindow && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) { ImplControlValue aControlValue; - Region aCtrlRegion( rRect ); ControlState nState = 0; if ( highlight == 1 ) nState |= CTRL_STATE_PRESSED; @@ -3429,7 +3426,7 @@ static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 h bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, - aCtrlRegion, nState, aControlValue, rtl::OUString() ); + rRect, nState, aControlValue, rtl::OUString() ); } if( !bNativeOk ) @@ -3454,6 +3451,8 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight, sal_Bool bPain MetricVector* pVector = bLayout ? &mpData->m_pLayoutData->m_aUnicodeBoundRects : NULL; String* pDisplayText = bLayout ? &mpData->m_pLayoutData->m_aDisplayText : NULL; + bHighlight = bHighlight && pItem->mbEnabled; + // Falls Rechteck ausserhalb des sichbaren Bereichs liegt if ( pItem->maRect.IsEmpty() ) return; @@ -4821,15 +4820,15 @@ const XubString& ToolBox::ImplGetHelpText( sal_uInt16 nItemId ) const if ( pItem ) { - if ( !pItem->maHelpText.Len() && ( pItem->mnHelpId || pItem->maCommandStr.Len() )) + if ( !pItem->maHelpText.Len() && ( pItem->maHelpId.getLength() || pItem->maCommandStr.Len() )) { Help* pHelp = Application::GetHelp(); if ( pHelp ) { if ( pItem->maCommandStr.Len() ) pItem->maHelpText = pHelp->GetHelpText( pItem->maCommandStr, this ); - if ( !pItem->maHelpText.Len() && pItem->mnHelpId ) - pItem->maHelpText = pHelp->GetHelpText( pItem->mnHelpId, this ); + if ( !pItem->maHelpText.Len() && pItem->maHelpId.getLength() ) + pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this ); } } @@ -4895,9 +4894,9 @@ void ToolBox::RequestHelp( const HelpEvent& rHEvt ) else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { String aCommand = GetItemCommand( nItemId ); - sal_uIntPtr nHelpId = GetHelpId( nItemId ); + rtl::OString aHelpId( GetHelpId( nItemId ) ); - if ( aCommand.Len() || nHelpId ) + if ( aCommand.Len() || aHelpId.getLength() ) { // Wenn eine Hilfe existiert, dann ausloesen Help* pHelp = Application::GetHelp(); @@ -4905,8 +4904,8 @@ void ToolBox::RequestHelp( const HelpEvent& rHEvt ) { if ( aCommand.Len() ) pHelp->Start( aCommand, this ); - else if ( nHelpId ) - pHelp->Start( nHelpId, this ); + else if ( aHelpId.getLength() ) + pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), this ); } return; } @@ -6311,7 +6310,7 @@ void ToolBox::ImplDisableFlatButtons() &hkey) ) { DWORD dwType = 0; - BYTE Data[6]; // possible values: "true", "false", "1", "0", DWORD + sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD DWORD cbData = sizeof(Data); if( ERROR_SUCCESS == RegQueryValueEx(hkey, "DisableFlatToolboxButtons", diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 3852586bdb90..e6f5767f1331 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -99,7 +99,6 @@ ImplToolItem::ImplToolItem() mnId = 0; mpWindow = NULL; mpUserData = NULL; - mnHelpId = 0; meType = TOOLBOXITEM_BUTTON; mnBits = 0; meState = STATE_NOCHECK; @@ -124,7 +123,6 @@ ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const Image& rImage, mnId = nItemId; mpWindow = NULL; mpUserData = NULL; - mnHelpId = 0; meType = TOOLBOXITEM_BUTTON; mnBits = nItemBits; meState = STATE_NOCHECK; @@ -149,7 +147,6 @@ ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const XubString& rText, mnId = nItemId; mpWindow = NULL; mpUserData = NULL; - mnHelpId = 0; meType = TOOLBOXITEM_BUTTON; mnBits = nItemBits; meState = STATE_NOCHECK; @@ -175,7 +172,6 @@ ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const Image& rImage, mnId = nItemId; mpWindow = NULL; mpUserData = NULL; - mnHelpId = 0; meType = TOOLBOXITEM_BUTTON; mnBits = nItemBits; meState = STATE_NOCHECK; @@ -204,7 +200,7 @@ ImplToolItem::ImplToolItem( const ImplToolItem& rItem ) : maQuickHelpText ( rItem.maQuickHelpText ), maHelpText ( rItem.maHelpText ), maCommandStr ( rItem.maCommandStr ), - mnHelpId ( rItem.mnHelpId ), + maHelpId ( rItem.maHelpId ), maRect ( rItem.maRect ), maCalcRect ( rItem.maCalcRect ), maItemSize ( rItem.maItemSize ), @@ -243,7 +239,7 @@ ImplToolItem& ImplToolItem::operator=( const ImplToolItem& rItem ) maQuickHelpText = rItem.maQuickHelpText; maHelpText = rItem.maHelpText; maCommandStr = rItem.maCommandStr; - mnHelpId = rItem.mnHelpId; + maHelpId = rItem.maHelpId; maRect = rItem.maRect; maCalcRect = rItem.maCalcRect; mnSepSize = rItem.mnSepSize; @@ -595,7 +591,7 @@ void ToolBox::InsertItem( const ResId& rResId, sal_uInt16 nPos ) aItem.mnBits = (ToolBoxItemBits)ReadLongRes(); if( nObjMask & RSC_TOOLBOXITEM_HELPID ) - aItem.mnHelpId = ReadLongRes(); + aItem.maHelpId = ReadByteStringRes(); if ( nObjMask & RSC_TOOLBOXITEM_TEXT ) { @@ -1923,24 +1919,31 @@ const XubString& ToolBox::GetHelpText( sal_uInt16 nItemId ) const // ----------------------------------------------------------------------- -void ToolBox::SetHelpId( sal_uInt16 nItemId, sal_uIntPtr nHelpId ) +void ToolBox::SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ) { ImplToolItem* pItem = ImplGetItem( nItemId ); if ( pItem ) - pItem->mnHelpId = nHelpId; + pItem->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -sal_uIntPtr ToolBox::GetHelpId( sal_uInt16 nItemId ) const +rtl::OString ToolBox::GetHelpId( sal_uInt16 nItemId ) const { + rtl::OString aRet; + ImplToolItem* pItem = ImplGetItem( nItemId ); if ( pItem ) - return pItem->mnHelpId; - else - return 0; + { + if ( pItem->maHelpId.getLength() ) + aRet = pItem->maHelpId; + else + aRet = ::rtl::OUStringToOString( pItem->maCommandStr, RTL_TEXTENCODING_UTF8 ); + } + + return aRet; } // ----------------------------------------------------------------------- diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index aca39334585a..58772a599faa 100644..100755 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -88,8 +88,8 @@ #include "vcl/dialog.hxx" #include "vcl/unowrap.hxx" -#include "dndlcon.hxx" -#include "dndevdis.hxx" +#include "vcl/dndlcon.hxx" +#include "vcl/dndevdis.hxx" #include "vcl/impbmpconv.hxx" #include "unotools/confignode.hxx" #include "vcl/gdimtf.hxx" @@ -243,18 +243,17 @@ void Window::ImplInitAppFontData( Window* pWindow ) // of control sizes, if yes, make app font scalings larger // so dialog positioning is not completely off ImplControlValue aControlValue; - Region aCtrlRegion( (const Rectangle&)Rectangle( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) ) ); - Region aBoundingRgn( aCtrlRegion ); - Region aContentRgn( aCtrlRegion ); + Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) ); + Rectangle aBoundingRgn( aCtrlRegion ); + Rectangle aContentRgn( aCtrlRegion ); if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion, CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn ) ) { - Rectangle aContentRect( aContentRgn.GetBoundRect() ); // comment: the magical +6 is for the extra border in bordered // (which is the standard) edit fields - if( aContentRect.GetHeight() - nTextHeight > (nTextHeight+4)/4 ) - pSVData->maGDIData.mnAppFontY = (aContentRect.GetHeight()-4) * 10; + if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 ) + pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10; } } @@ -613,8 +612,6 @@ void Window::ImplInitWindowData( WindowType nType ) mpWindowImpl->mnX = 0; // X-Position to Parent mpWindowImpl->mnY = 0; // Y-Position to Parent mpWindowImpl->mnAbsScreenX = 0; // absolute X-position on screen, used for RTL window positioning - mpWindowImpl->mnHelpId = 0; // help id - mpWindowImpl->mnUniqId = 0; // unique id mpWindowImpl->mpChildClipRegion = NULL; // Child-Clip-Region when ClipChildren mpWindowImpl->mpPaintRegion = NULL; // Paint-ClipRegion mpWindowImpl->mnStyle = 0; // style (init in ImplInitWindow) @@ -1180,20 +1177,14 @@ void Window::ImplCallMove() // ----------------------------------------------------------------------- -static sal_uIntPtr ImplAutoHelpID( ResMgr* pResMgr ) +static rtl::OString ImplAutoHelpID( ResMgr* pResMgr ) { - if ( !Application::IsAutoHelpIdEnabled() ) - return 0; - - sal_uIntPtr nHID = 0; - - DBG_ASSERT( pResMgr, "No res mgr for auto help id" ); - if( ! pResMgr ) - return 0; + rtl::OString aRet; - nHID = pResMgr->GetAutoHelpId(); + if( pResMgr && Application::IsAutoHelpIdEnabled() ) + aRet = pResMgr->GetAutoHelpId(); - return nHID; + return aRet; } // ----------------------------------------------------------------------- @@ -1213,22 +1204,23 @@ WinBits Window::ImplInitRes( const ResId& rResId ) void Window::ImplLoadRes( const ResId& rResId ) { - // newer move this line after IncrementRes - char* pRes = (char*)GetClassRes(); - pRes += 12; - sal_uInt32 nHelpId = (sal_uInt32)GetLongRes( (void*)pRes ); - if ( !nHelpId ) - nHelpId = ImplAutoHelpID( rResId.GetResMgr() ); - SetHelpId( nHelpId ); - sal_uIntPtr nObjMask = ReadLongRes(); + // we need to calculate auto helpids before the resource gets closed + // if the resource only contains flags, it will be closed before we try to read a help id + // so we always create an auto help id that might be overwritten later + // HelpId + rtl::OString aHelpId = ImplAutoHelpID( rResId.GetResMgr() ); + // ResourceStyle sal_uIntPtr nRSStyle = ReadLongRes(); // WinBits ReadLongRes(); - // HelpId - ReadLongRes(); + + if( nObjMask & WINDOW_HELPID ) + aHelpId = ReadByteStringRes(); + + SetHelpId( aHelpId ); sal_Bool bPos = sal_False; sal_Bool bSize = sal_False; @@ -1295,7 +1287,7 @@ void Window::ImplLoadRes( const ResId& rResId ) if ( nObjMask & WINDOW_EXTRALONG ) SetData( (void*)ReadLongRes() ); if ( nObjMask & WINDOW_UNIQUEID ) - SetUniqueId( (sal_uIntPtr)ReadLongRes() ); + SetUniqueId( ReadByteStringRes() ); if ( nObjMask & WINDOW_BORDER_STYLE ) { @@ -1323,8 +1315,6 @@ ImplWinData* Window::ImplGetWinData() const mpWindowImpl->mpWinData->mnIsTopWindow = (sal_uInt16) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mpWindowImpl->mpWinData->mbMouseOver = sal_False; mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? sal_False : sal_True; // sal_True: try to draw this control with native theme API - mpWindowImpl->mpWinData->mpSmartHelpId = NULL; - mpWindowImpl->mpWinData->mpSmartUniqueId = NULL; } return mpWindowImpl->mpWinData; @@ -4735,10 +4725,6 @@ Window::~Window() delete mpWindowImpl->mpWinData->mpFocusRect; if ( mpWindowImpl->mpWinData->mpTrackRect ) delete mpWindowImpl->mpWinData->mpTrackRect; - if ( mpWindowImpl->mpWinData->mpSmartHelpId ) - delete mpWindowImpl->mpWinData->mpSmartHelpId; - if ( mpWindowImpl->mpWinData->mpSmartUniqueId ) - delete mpWindowImpl->mpWinData->mpSmartUniqueId; delete mpWindowImpl->mpWinData; } @@ -4980,29 +4966,18 @@ void Window::RequestHelp( const HelpEvent& rHEvt ) } else { - SmartId aSmartId = GetSmartHelpId(); - - sal_uIntPtr nNumHelpId = 0; - String aStrHelpId; - if( aSmartId.HasString() ) - aStrHelpId = aSmartId.GetStr(); - if( aSmartId.HasNumeric() ) - nNumHelpId = aSmartId.GetNum(); - - if ( !nNumHelpId && aStrHelpId.Len() == 0 && ImplGetParent() ) + String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); + if ( aStrHelpId.Len() == 0 && ImplGetParent() ) ImplGetParent()->RequestHelp( rHEvt ); else { - if ( !nNumHelpId && aStrHelpId.Len() == 0 ) - nNumHelpId = OOO_HELP_INDEX; - Help* pHelp = Application::GetHelp(); if ( pHelp ) { if( aStrHelpId.Len() > 0 ) pHelp->Start( aStrHelpId, this ); else - pHelp->Start( nNumHelpId, this ); + pHelp->Start( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OOO_HELP_INDEX ) ), this ); } } } @@ -8131,32 +8106,22 @@ const XubString& Window::GetHelpText() const { DBG_CHKTHIS( Window, ImplDbgCheckWindow ); - SmartId aSmartId = GetSmartHelpId(); - - sal_uIntPtr nNumHelpId = 0; - String aStrHelpId; - if( aSmartId.HasString() ) - aStrHelpId = aSmartId.GetStr(); - if( aSmartId.HasNumeric() ) - nNumHelpId = aSmartId.GetNum(); + String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); bool bStrHelpId = (aStrHelpId.Len() > 0); - if ( !mpWindowImpl->maHelpText.Len() && (nNumHelpId || bStrHelpId) ) + if ( !mpWindowImpl->maHelpText.Len() && bStrHelpId ) { if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) ) { Help* pHelp = Application::GetHelp(); if ( pHelp ) { - if( bStrHelpId ) - ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this ); - else - ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( nNumHelpId, this ); + ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this ); mpWindowImpl->mbHelpTextDynamic = sal_False; } } } - else if( mpWindowImpl->mbHelpTextDynamic && (nNumHelpId || bStrHelpId) ) + else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId ) { static const char* pEnv = getenv( "HELP_DEBUG" ); if( pEnv && *pEnv ) @@ -8164,10 +8129,7 @@ const XubString& Window::GetHelpText() const rtl::OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.Len() ); aTxt.append( mpWindowImpl->maHelpText ); aTxt.appendAscii( "\n------------------\n" ); - if( bStrHelpId ) - aTxt.append( rtl::OUString( aStrHelpId ) ); - else - aTxt.append( sal_Int32( nNumHelpId ) ); + aTxt.append( rtl::OUString( aStrHelpId ) ); mpWindowImpl->maHelpText = aTxt.makeStringAndClear(); } mpWindowImpl->mbHelpTextDynamic = sal_False; @@ -8650,7 +8612,10 @@ Reference< XClipboard > Window::GetClipboard() if( xFactory.is() ) { - mpWindowImpl->mpFrameData->mxClipboard = Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ) ), UNO_QUERY ); + mpWindowImpl->mpFrameData->mxClipboard = Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboardExt" ) ), UNO_QUERY ); + + if( !mpWindowImpl->mpFrameData->mxClipboard.is() ) + mpWindowImpl->mpFrameData->mxClipboard = Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ) ), UNO_QUERY ); #if defined(UNX) && !defined(QUARTZ) // unix clipboard needs to be initialized if( mpWindowImpl->mpFrameData->mxClipboard.is() ) @@ -8713,6 +8678,9 @@ Reference< XClipboard > Window::GetPrimarySelection() static Reference< XClipboard > s_xSelection; if ( !s_xSelection.is() ) + s_xSelection = Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboardExt" ) ), UNO_QUERY ); + + if ( !s_xSelection.is() ) s_xSelection = Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboard" ) ), UNO_QUERY ); mpWindowImpl->mpFrameData->mxSelection = s_xSelection; @@ -9396,7 +9364,7 @@ void Window::DrawSelectionBackground( const Rectangle& rRect, if( bDark ) aSelectionFillCol = COL_BLACK; else - nPercent = bRoundEdges ? 90 : 80; // just checked (light) + nPercent = 80; // just checked (light) } else { @@ -9411,7 +9379,7 @@ void Window::DrawSelectionBackground( const Rectangle& rRect, nPercent = 0; } else - nPercent = bRoundEdges ? 50 : 20; // selected, pressed or checked ( very dark ) + nPercent = bRoundEdges ? 40 : 20; // selected, pressed or checked ( very dark ) } else if( bChecked || highlight == 1 ) { @@ -9424,7 +9392,7 @@ void Window::DrawSelectionBackground( const Rectangle& rRect, nPercent = 0; } else - nPercent = bRoundEdges ? 70 : 35; // selected, pressed or checked ( very dark ) + nPercent = bRoundEdges ? 60 : 35; // selected, pressed or checked ( very dark ) } else { @@ -9440,7 +9408,7 @@ void Window::DrawSelectionBackground( const Rectangle& rRect, nPercent = 0; } else - nPercent = bRoundEdges ? 80 : 70; // selected ( dark ) + nPercent = 70; // selected ( dark ) } } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 2334c3c468f9..b4dad39cbebc 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1442,115 +1442,31 @@ Window* Window::ImplGetTopmostFrameWindow() return pTopmostParent->mpWindowImpl->mpFrameWindow; } -// making these Methods out of line to be able to change them lateron without complete rebuild -// TODO: Set the SmartId in here and remove mpWindowImpl->mnHelpId -void Window::SetHelpId( sal_uIntPtr nHelpId ) +void Window::SetHelpId( const rtl::OString& rHelpId ) { - SetSmartHelpId(SmartId(nHelpId)); + mpWindowImpl->maHelpId = rHelpId; } -sal_uIntPtr Window::GetHelpId() const +const rtl::OString& Window::GetHelpId() const { - return mpWindowImpl->mnHelpId; + return mpWindowImpl->maHelpId; } -void Window::SetSmartHelpId( const SmartId& aId, SmartIdUpdateMode aMode ) +void Window::SetUniqueId( const rtl::OString& rUniqueId ) { - // create SmartId if required - if ( (aMode == SMART_SET_STR) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasString() ) ) - { - if ( !ImplGetWinData()->mpSmartHelpId ) - ImplGetWinData()->mpSmartHelpId = new SmartId(); - } - - // if we have a SmartId (eather from earlier call or just created) fill with new values - if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId ) - ImplGetWinData()->mpSmartHelpId->UpdateId( aId, aMode ); - - if ( (aMode == SMART_SET_NUM) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasNumeric() ) ) - { - mpWindowImpl->mnHelpId = aId.GetNum(); - } -} - -SmartId Window::GetSmartHelpId() const -{ - if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId ) - { - if ( mpWindowImpl->mnHelpId || mpWindowImpl->mpWinData->mpSmartHelpId->HasNumeric() ) - mpWindowImpl->mpWinData->mpSmartHelpId->UpdateId( SmartId( mpWindowImpl->mnHelpId ), SMART_SET_NUM ); - return *mpWindowImpl->mpWinData->mpSmartHelpId; - } - else - { - if ( mpWindowImpl->mnHelpId ) - return SmartId( mpWindowImpl->mnHelpId ); - else - return SmartId(); - } -} - - -// making these Methods out of line to be able to change them lateron without complete rebuild -// TODO: Set the SmartId in here and remove mpWindowImpl->mnUniqId -void Window::SetUniqueId( sal_uIntPtr nUniqueId ) { mpWindowImpl->mnUniqId = nUniqueId; } -sal_uIntPtr Window::GetUniqueId() const { return mpWindowImpl->mnUniqId; } - - -void Window::SetSmartUniqueId( const SmartId& aId, SmartIdUpdateMode aMode ) -{ - // create SmartId if required - if ( (aMode == SMART_SET_STR) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasString() ) ) - { - if ( !ImplGetWinData()->mpSmartUniqueId ) - ImplGetWinData()->mpSmartUniqueId = new SmartId(); - } - - // if we have a SmartId (eather from earlier call or just created) fill with new values - if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId ) - ImplGetWinData()->mpSmartUniqueId->UpdateId( aId, aMode ); - - if ( (aMode == SMART_SET_NUM) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasNumeric() ) ) - mpWindowImpl->mnUniqId = aId.GetNum(); + mpWindowImpl->maUniqId = rUniqueId; } -SmartId Window::GetSmartUniqueId() const +const rtl::OString& Window::GetUniqueId() const { - if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId ) - { - if ( mpWindowImpl->mnUniqId || mpWindowImpl->mpWinData->mpSmartUniqueId->HasNumeric() ) - mpWindowImpl->mpWinData->mpSmartUniqueId->UpdateId( SmartId( mpWindowImpl->mnUniqId ), SMART_SET_NUM ); - return *mpWindowImpl->mpWinData->mpSmartUniqueId; - } - else - { - if ( mpWindowImpl->mnUniqId ) - return SmartId( mpWindowImpl->mnUniqId ); - else - return SmartId(); - } + return mpWindowImpl->maUniqId; } -SmartId Window::GetSmartUniqueOrHelpId() const +const rtl::OString& Window::GetUniqueOrHelpId() const { - if ( ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId ) || mpWindowImpl->mnHelpId ) - { - if ( ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId ) || mpWindowImpl->mnUniqId ) - { - SmartId aTemp = GetSmartHelpId(); - aTemp.UpdateId( GetSmartUniqueId() ); - return aTemp; - } - else - return GetSmartHelpId(); - } - else - return GetSmartUniqueId(); + return mpWindowImpl->maUniqId.getLength() ? mpWindowImpl->maUniqId : mpWindowImpl->maHelpId; } - - - // --------- old inline methods --------------- Window* Window::ImplGetWindow() diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 7498de8a167d..a5820a752788 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -62,7 +62,7 @@ #include <vcl/salgdi.hxx> #include <vcl/menu.hxx> -#include <dndlcon.hxx> +#include <vcl/dndlcon.hxx> #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> #include <com/sun/star/awt/MouseEvent.hpp> |