diff options
Diffstat (limited to 'vcl/source')
52 files changed, 2367 insertions, 1528 deletions
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index dd9a5b4a15ee..b48db1d6ee97 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 1f9efa7b6e65..2c7ad2fa9c3e 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -62,12 +62,7 @@ Help::~Help() // ----------------------------------------------------------------------- -BOOL Help::Start( ULONG, const Window* ) -{ - return FALSE; -} - -void Help::OpenHelpAgent( ULONG ) +void Help::OpenHelpAgent( const rtl::OString& ) { } @@ -78,11 +73,9 @@ BOOL Help::Start( const XubString&, const Window* ) return FALSE; } -// ----------------------------------------------------------------------- - -XubString Help::GetHelpText( ULONG, const Window* ) +BOOL Help::SearchKeyword( const XubString& ) { - return ImplGetSVEmptyStr(); + return FALSE; } // ----------------------------------------------------------------------- diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 9a2404d36740..2a04389d8f44 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( 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/svdata.cxx b/vcl/source/app/svdata.cxx index f8b0d1d3379f..03b0365cff63 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/combobox.cxx b/vcl/source/control/combobox.cxx index 8efa3404a44a..5b2e8755e5c8 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1010,6 +1010,14 @@ void ComboBox::Clear() mpImplLB->Clear(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMREMOVED, (void*) sal_IntPtr(-1) ); } +// ----------------------------------------------------------------------- + +Image ComboBox::GetEntryImage( USHORT 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 a692cbea0260..5091a4722845 100755 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -1801,6 +1801,9 @@ 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() && @@ -1822,6 +1825,7 @@ BOOL Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) } } break; + */ default: { diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 6c2b06783984..4c4e3c870429 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 @@ -1131,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( USHORT 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( USHORT 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 37406293d7cf..f73cf008a5e5 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 { USHORT 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 02c8d2b5fcb3..bd0179ffe454 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -529,7 +529,8 @@ USHORT ImplEntryList::FindFirstSelectable( USHORT nPos, bool bForward /* = true // ======================================================================= ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) : - Control( pParent, 0 ) + Control( pParent, 0 ), + maQuickSelectionEngine( *this ) { mpEntryList = new ImplEntryList( this ); @@ -568,9 +569,6 @@ ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) : SetTextFillColor(); SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); - maSearchTimeout.SetTimeout( 2500 ); - maSearchTimeout.SetTimeoutHdl( LINK( this, ImplListBoxWindow, SearchStringTimeout ) ); - ImplInitSettings( TRUE, TRUE, TRUE ); ImplCalcMetrics(); } @@ -579,7 +577,6 @@ ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) : ImplListBoxWindow::~ImplListBoxWindow() { - maSearchTimeout.Stop(); delete mpEntryList; } @@ -624,14 +621,6 @@ void ImplListBoxWindow::ImplCalcMetrics() // ----------------------------------------------------------------------- -IMPL_LINK( ImplListBoxWindow, SearchStringTimeout, Timer*, EMPTYARG ) -{ - maSearchStr.Erase(); - return 1; -} - -// ----------------------------------------------------------------------- - void ImplListBoxWindow::Clear() { mpEntryList->Clear(); @@ -648,6 +637,7 @@ void ImplListBoxWindow::Clear() ImplClearLayoutData(); mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; + maQuickSelectionEngine.Reset(); Invalidate(); } @@ -918,7 +908,7 @@ USHORT ImplListBoxWindow::GetLastVisibleEntry() const void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt ) { mbMouseMoveSelect = FALSE; // Nur bis zum ersten MouseButtonDown - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); if ( !IsReadOnly() ) { @@ -1465,7 +1455,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1492,7 +1482,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1523,7 +1513,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) } bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1557,7 +1547,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) } bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1578,7 +1568,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) bDone = TRUE; } } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1604,7 +1594,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) } bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1615,7 +1605,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) ScrollHorz( -HORZ_SCROLL ); bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1626,7 +1616,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) ScrollHorz( HORZ_SCROLL ); bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1638,7 +1628,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) ImplCallSelect(); bDone = FALSE; // RETURN nicht abfangen. } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1653,7 +1643,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) } bDone = TRUE; } - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); } break; @@ -1673,7 +1663,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) SetUpdateMode( bUpdates ); Invalidate(); - maSearchStr.Erase(); + maQuickSelectionEngine.Reset(); bDone = TRUE; break; @@ -1682,43 +1672,12 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) // fall through intentional default: { - xub_Unicode c = rKEvt.GetCharCode(); - - if ( !IsReadOnly() && (c >= 32) && (c != 127) && !rKEvt.GetKeyCode().IsMod2() ) + if ( !IsReadOnly() ) { - maSearchStr += c; - XubString aTmpSearch( maSearchStr ); - - nSelect = mpEntryList->FindMatchingEntry( aTmpSearch, mnCurrentPos ); - if ( (nSelect == LISTBOX_ENTRY_NOTFOUND) && (aTmpSearch.Len() > 1) ) - { - // Wenn alles die gleichen Buchstaben, dann anderer Such-Modus - BOOL bAllEqual = TRUE; - for ( USHORT n = aTmpSearch.Len(); n && bAllEqual; ) - bAllEqual = aTmpSearch.GetChar( --n ) == c; - if ( bAllEqual ) - { - aTmpSearch = c; - nSelect = mpEntryList->FindMatchingEntry( aTmpSearch, mnCurrentPos+1 ); - } - } - if ( nSelect == LISTBOX_ENTRY_NOTFOUND ) - nSelect = mpEntryList->FindMatchingEntry( aTmpSearch, 0 ); - - if ( nSelect != LISTBOX_ENTRY_NOTFOUND ) - { - ShowProminentEntry( nSelect ); - - if ( mpEntryList->IsEntryPosSelected( nSelect ) ) - nSelect = LISTBOX_ENTRY_NOTFOUND; - - maSearchTimeout.Start(); - } - else - maSearchStr.Erase(); - bDone = TRUE; + bDone = maQuickSelectionEngine.HandleKeyEvent( rKEvt ); } - } + } + break; } if ( ( nSelect != LISTBOX_ENTRY_NOTFOUND ) @@ -1744,6 +1703,72 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) } // ----------------------------------------------------------------------- +namespace +{ + static ::vcl::StringEntryIdentifier lcl_getEntry( const ImplEntryList& _rList, USHORT _nPos, String& _out_entryText ) + { + OSL_PRECOND( ( _nPos != LISTBOX_ENTRY_NOTFOUND ), "lcl_getEntry: invalid position!" ); + USHORT nEntryCount( _rList.GetEntryCount() ); + if ( _nPos >= nEntryCount ) + _nPos = 0; + _out_entryText = _rList.GetEntryText( _nPos ); + + // ::vcl::StringEntryIdentifier does not allow for 0 values, but our position is 0-based + // => normalize + return reinterpret_cast< ::vcl::StringEntryIdentifier >( _nPos + 1 ); + } + + static USHORT lcl_getEntryPos( ::vcl::StringEntryIdentifier _entry ) + { + // our pos is 0-based, but StringEntryIdentifier does not allow for a NULL + return static_cast< USHORT >( reinterpret_cast< sal_Int64 >( _entry ) ) - 1; + } +} + +// ----------------------------------------------------------------------- +::vcl::StringEntryIdentifier ImplListBoxWindow::CurrentEntry( String& _out_entryText ) const +{ + return lcl_getEntry( *GetEntryList(), ( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND ) ? 0 : mnCurrentPos + 1, _out_entryText ); +} + +// ----------------------------------------------------------------------- +::vcl::StringEntryIdentifier ImplListBoxWindow::NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const +{ + USHORT nNextPos = lcl_getEntryPos( _currentEntry ) + 1; + return lcl_getEntry( *GetEntryList(), nNextPos, _out_entryText ); +} + +// ----------------------------------------------------------------------- +void ImplListBoxWindow::SelectEntry( ::vcl::StringEntryIdentifier _entry ) +{ + USHORT nSelect = lcl_getEntryPos( _entry ); + if ( mpEntryList->IsEntryPosSelected( nSelect ) ) + { + // ignore that. This method is a callback from the QuickSelectionEngine, which means the user attempted + // to select the given entry by typing its starting letters. No need to act. + return; + } + + // normalize + OSL_ENSURE( nSelect < mpEntryList->GetEntryCount(), "ImplListBoxWindow::SelectEntry: how that?" ); + if( nSelect >= mpEntryList->GetEntryCount() ) + nSelect = mpEntryList->GetEntryCount()-1; + + // make visible + ShowProminentEntry( nSelect ); + + // actually select + mnCurrentPos = nSelect; + if ( SelectEntries( nSelect, LET_KEYMOVE, FALSE, FALSE ) ) + { + mbTravelSelect = TRUE; + mnSelectModifier = 0; + ImplCallSelect(); + mbTravelSelect = FALSE; + } +} + +// ----------------------------------------------------------------------- void ImplListBoxWindow::ImplPaint( USHORT nPos, BOOL bErase, bool bLayout ) { @@ -2356,7 +2381,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 +2424,11 @@ void ImplListBox::ImplCheckScrollBars() mbVScroll = 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 +2461,11 @@ void ImplListBox::ImplCheckScrollBars() mbVScroll = 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... } } diff --git a/vcl/source/control/makefile.mk b/vcl/source/control/makefile.mk index a2553333246d..b1644e58ccd9 100644 --- a/vcl/source/control/makefile.mk +++ b/vcl/source/control/makefile.mk @@ -62,7 +62,8 @@ SLOFILES= $(SLO)$/button.obj \ $(SLO)$/slider.obj \ $(SLO)$/spinfld.obj \ $(SLO)$/spinbtn.obj \ - $(SLO)$/tabctrl.obj + $(SLO)$/tabctrl.obj \ + $(SLO)$/quickselectionengine.obj EXCEPTIONSFILES= \ $(SLO)$/button.obj \ diff --git a/vcl/source/control/quickselectionengine.cxx b/vcl/source/control/quickselectionengine.cxx new file mode 100644 index 000000000000..2d32393bf79a --- /dev/null +++ b/vcl/source/control/quickselectionengine.cxx @@ -0,0 +1,183 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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/quickselectionengine.hxx" +#include "vcl/event.hxx" +#include "vcl/timer.hxx" +#include "vcl/i18nhelp.hxx" +#include "vcl/svapp.hxx" + +#include <boost/optional.hpp> + +//........................................................................ +namespace vcl +{ +//........................................................................ + + //==================================================================== + //= QuickSelectionEngine_Data + //==================================================================== + struct QuickSelectionEngine_Data + { + ISearchableStringList& rEntryList; + String sCurrentSearchString; + ::boost::optional< sal_Unicode > aSingleSearchChar; + Timer aSearchTimeout; + + QuickSelectionEngine_Data( ISearchableStringList& _entryList ) + :rEntryList( _entryList ) + ,sCurrentSearchString() + ,aSingleSearchChar() + ,aSearchTimeout() + { + aSearchTimeout.SetTimeout( 2500 ); + aSearchTimeout.SetTimeoutHdl( LINK( this, QuickSelectionEngine_Data, SearchStringTimeout ) ); + } + + ~QuickSelectionEngine_Data() + { + aSearchTimeout.Stop(); + } + + DECL_LINK( SearchStringTimeout, Timer* ); + }; + + //-------------------------------------------------------------------- + namespace + { + static void lcl_reset( QuickSelectionEngine_Data& _data ) + { + _data.sCurrentSearchString.Erase(); + _data.aSingleSearchChar.reset(); + _data.aSearchTimeout.Stop(); + } + } + + //-------------------------------------------------------------------- + IMPL_LINK( QuickSelectionEngine_Data, SearchStringTimeout, Timer*, /*EMPTYARG*/ ) + { + lcl_reset( *this ); + return 1; + } + + //-------------------------------------------------------------------- + static StringEntryIdentifier findMatchingEntry( const String& _searchString, QuickSelectionEngine_Data& _engineData ) + { + const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetLocaleI18nHelper(); + // TODO: do we really need the Window's settings here? The original code used it ... + + String sEntryText; + // get the "current + 1" entry + StringEntryIdentifier pSearchEntry = _engineData.rEntryList.CurrentEntry( sEntryText ); + if ( pSearchEntry ) + pSearchEntry = _engineData.rEntryList.NextEntry( pSearchEntry, sEntryText ); + // loop 'til we find another matching entry + StringEntryIdentifier pStartedWith = pSearchEntry; + while ( pSearchEntry ) + { + if ( rI18nHelper.MatchString( _searchString, sEntryText ) != 0 ) + break; + + pSearchEntry = _engineData.rEntryList.NextEntry( pSearchEntry, sEntryText ); + if ( pSearchEntry == pStartedWith ) + pSearchEntry = NULL; + } + + return pSearchEntry; + } + + //==================================================================== + //= QuickSelectionEngine + //==================================================================== + //-------------------------------------------------------------------- + QuickSelectionEngine::QuickSelectionEngine( ISearchableStringList& _entryList ) + :m_pData( new QuickSelectionEngine_Data( _entryList ) ) + { + } + + //-------------------------------------------------------------------- + QuickSelectionEngine::~QuickSelectionEngine() + { + } + + //-------------------------------------------------------------------- + bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent ) + { + xub_Unicode c = _keyEvent.GetCharCode(); + + if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() ) + { + m_pData->sCurrentSearchString += c; + OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", ByteString( m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8 ).GetBuffer() ); + + if ( m_pData->sCurrentSearchString.Len() == 1 ) + { // first character in the search -> remmeber + m_pData->aSingleSearchChar.reset( c ); + } + else if ( m_pData->sCurrentSearchString.Len() > 1 ) + { + if ( !!m_pData->aSingleSearchChar && ( *m_pData->aSingleSearchChar != c ) ) + // we already have a "single char", but the current one is different -> reset + m_pData->aSingleSearchChar.reset(); + } + + XubString aSearchTemp( m_pData->sCurrentSearchString ); + + StringEntryIdentifier pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); + OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: found %p", pMatchingEntry ); + if ( !pMatchingEntry && ( aSearchTemp.Len() > 1 ) && !!m_pData->aSingleSearchChar ) + { + // if there's only one letter in the search string, use a different search mode + aSearchTemp = *m_pData->aSingleSearchChar; + pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); + } + + if ( pMatchingEntry ) + { + m_pData->rEntryList.SelectEntry( pMatchingEntry ); + m_pData->aSearchTimeout.Start(); + } + else + { + lcl_reset( *m_pData ); + } + + return true; + } + return false; + } + + //-------------------------------------------------------------------- + void QuickSelectionEngine::Reset() + { + lcl_reset( *m_pData ); + } + +//........................................................................ +} // namespace vcl +//........................................................................ diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 754270e9012f..c51ac834f1b4 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -114,8 +114,9 @@ BOOL ImplDrawNativeSpinfield( Window *pWin, const SpinbuttonValue& rSpinbuttonVa Size aSize( pBorder->GetOutputSizePixel() ); // the size of the border window, i.e., the whole control Rectangle aBound, aContent; Rectangle aNatRgn( aPt, aSize ); - if( pBorder->GetNativeControlRegion(CTRL_SPINBOX, PART_ENTIRE_CONTROL, - aNatRgn, 0, rSpinbuttonValue, rtl::OUString(), aBound, aContent) ) + if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize && + pBorder->GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL, + aNatRgn, 0, rSpinbuttonValue, rtl::OUString(), aBound, aContent) ) { aSize = aContent.GetSize(); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index c892b32534ec..e9696aa8c492 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; - ULONG mnHelpId; + rtl::OString maHelpId; Rectangle maRect; USHORT 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( FALSE ), mbEnabled( true ) {} }; @@ -151,7 +150,6 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) mbRestoreUnqId = FALSE; mbSingleLine = FALSE; mbScroll = FALSE; - mbRestoreSmartId = FALSE; mbSmallInvalidate = FALSE; mbExtraSpace = FALSE; mpTabCtrlData = new ImplTabCtrlData; @@ -705,11 +703,9 @@ void TabControl::ImplChangeTabPage( USHORT nId, USHORT 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(); } @@ -719,21 +715,16 @@ void TabControl::ImplChangeTabPage( USHORT nId, USHORT 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 = TRUE; pCtrlParent->SetHelpId( pPage->GetHelpId() ); } - if ( !pCtrlParent->GetUniqueId() ) + if ( !pCtrlParent->GetUniqueId().getLength() ) { mbRestoreUnqId = TRUE; pCtrlParent->SetUniqueId( pPage->GetUniqueId() ); } - if( ! GetSmartHelpId().HasAny() ) - { - mbRestoreSmartId = TRUE; - pCtrlParent->SetSmartHelpId( pPage->GetSmartHelpId() ); - } pPage->ActivatePage(); @@ -1486,13 +1477,13 @@ void TabControl::RequestHelp( const HelpEvent& rHEvt ) } else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { - ULONG 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; } } @@ -1574,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 ); } USHORT nId = aMenu.Execute( this, aMenuPos ); @@ -1826,7 +1817,6 @@ void TabControl::InsertPage( USHORT nPageId, const XubString& rText, pItem->mnId = nPageId; pItem->mpTabPage = NULL; pItem->mnTabPageResId = 0; - pItem->mnHelpId = 0; pItem->maText = rText; pItem->mbFullVisible = FALSE; @@ -2154,11 +2144,11 @@ const XubString& TabControl::GetHelpText( USHORT 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; @@ -2169,24 +2159,25 @@ const XubString& TabControl::GetHelpText( USHORT nPageId ) const // ----------------------------------------------------------------------- -void TabControl::SetHelpId( USHORT nPageId, ULONG nHelpId ) +void TabControl::SetHelpId( USHORT nPageId, const rtl::OString& rHelpId ) { ImplTabItem* pItem = ImplGetItem( nPageId ); if ( pItem ) - pItem->mnHelpId = nHelpId; + pItem->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -ULONG TabControl::GetHelpId( USHORT nPageId ) const +rtl::OString TabControl::GetHelpId( USHORT 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/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 818a31a10c0f..d36a18a1afba 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -873,8 +873,8 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) { aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() ); MapMode aMap( aMapVDev.GetMapMode() ); - aOffset.Width() = aOffset.Width() * (double)aMap.GetScaleX(); - aOffset.Height() = aOffset.Height() * (double)aMap.GetScaleY(); + 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() ); diff --git a/vcl/source/gdi/impprn.cxx b/vcl/source/gdi/impprn.cxx deleted file mode 100644 index 5224286cdad1..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; - USHORT mnPage; - 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( 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 = TRUE; -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::ImplPrintMtf( GDIMetaFile& rPrtMtf, long nMaxBmpDPIX, long nMaxBmpDPIY ) -{ - for( MetaAction* pAct = rPrtMtf.FirstAction(); pAct && !mbAborted; pAct = rPrtMtf.NextAction() ) - { - const ULONG 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); - USHORT 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<UINT8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetRed()) / 100L ) ); - aLineColor.SetGreen( static_cast<UINT8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetGreen()) / 100L ) ); - aLineColor.SetBlue( static_cast<UINT8>( (255L*nTransparency + (100L - nTransparency)*aLineColor.GetBlue()) / 100L ) ); - SetLineColor( aLineColor ); - - Color aFillColor( GetFillColor() ); - aFillColor.SetRed( static_cast<UINT8>( (255L*nTransparency + (100L - nTransparency)*aFillColor.GetRed()) / 100L ) ); - aFillColor.SetGreen( static_cast<UINT8>( (255L*nTransparency + (100L - nTransparency)*aFillColor.GetGreen()) / 100L ) ); - aFillColor.SetBlue( static_cast<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 ); -} - -// ----------------------------------------------------------------------- -ULONG ImplQPrinter::GetPrintPageCount() const -{ - ULONG 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() < (ULONG)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 = FALSE; - - PrePrintPage( pActPage ); - - USHORT nCopyCount = 1; - if( mbUserCopy && !mbCollateCopy ) - nCopyCount = mnCopyCount; - - for ( USHORT 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 = 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 = TRUE; - maQueue.push_back( pQueuePage ); - } -} - -// ----------------------------------------------------------------------- - -bool ImplQPrinter::GetPaperRanges( std::vector< ULONG >& o_rRanges, bool i_bIncludeOrientationChanges ) const -{ - bool bRet = false; - - if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - bRet = true; - o_rRanges.clear(); - - if( ! maQueue.empty() ) - { - ULONG 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 = TRUE; - AbortJob(); -} - -// ----------------------------------------------------------------------- - -void ImplQPrinter::AddQueuePage( GDIMetaFile* pPage, USHORT nPage, BOOL bNewJobSetup ) -{ - QueuePage* pQueuePage = new QueuePage; - pQueuePage->mpMtf = pPage; - pQueuePage->mnPage = nPage; - pQueuePage->mbEndJob = 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 77df20976c73..ac2e586a41cb 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -63,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 \ diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 94f07b8f17d1..8c1545758c3b 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); } // ------------------------------------------------------------------------ diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx index dffc7c82caf0..6d225ad7e0dc 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 ) @@ -285,7 +289,7 @@ ImplFontCharMap::~ImplFontCharMap() delete[] mpRangeCodes; delete[] mpStartGlyphs; delete[] mpGlyphIds; -} + } // ----------------------------------------------------------------------- @@ -293,14 +297,13 @@ namespace { ImplFontCharMap *GetDefaultUnicodeMap() { - if( pDefaultUnicodeImplFontCharMap ) - pDefaultUnicodeImplFontCharMap->AddReference(); - else + if( !pDefaultUnicodeImplFontCharMap ) { const sal_uInt32* pRangeCodes = aDefaultUnicodeRanges; int nCodesCount = sizeof(aDefaultUnicodeRanges) / sizeof(*pRangeCodes); CmapResult aDefaultCR( false, pRangeCodes, nCodesCount/2 ); pDefaultUnicodeImplFontCharMap = new ImplFontCharMap( aDefaultCR ); + pDefaultUnicodeImplFontCharMap->AddReference(); } return pDefaultUnicodeImplFontCharMap; @@ -308,14 +311,13 @@ namespace ImplFontCharMap *GetDefaultSymbolMap() { - if( pDefaultSymbolImplFontCharMap ) - pDefaultSymbolImplFontCharMap->AddReference(); - else + 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; @@ -329,14 +331,15 @@ ImplFontCharMap* ImplFontCharMap::GetDefaultMap( bool bSymbols) // ----------------------------------------------------------------------- -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 != pDefaultUnicodeImplFontCharMap) && (this != pDefaultSymbolImplFontCharMap) ) @@ -833,7 +836,9 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) FontCharMap::FontCharMap() : mpImpl( ImplFontCharMap::GetDefaultMap() ) -{} +{ + mpImpl->AddReference(); +} // ----------------------------------------------------------------------- @@ -859,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 a011e4ee4a92..847a8d7a299a 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2495,6 +2495,9 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, const bool bDashUsed(LINE_DASH == aInfo.GetStyle()); const bool bLineWidthUsed(aInfo.GetWidth() > 1); + if ( mbInitLineColor ) + ImplInitLineColor(); + if(bDashUsed || bLineWidthUsed) { basegfx::B2DPolygon aLinePolygon; @@ -2505,9 +2508,6 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, } else { - if ( mbInitLineColor ) - ImplInitLineColor(); - mpGraphics->DrawLine( aStartPt.X(), aStartPt.Y(), aEndPt.X(), aEndPt.Y(), this ); } diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx index bea307a4c38d..06dcd73cc3d4 100644 --- a/vcl/source/gdi/outdev2.cxx +++ b/vcl/source/gdi/outdev2.cxx @@ -1988,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; @@ -2002,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 63bc233ef4e0..f4ea98484c33 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> @@ -1531,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(); @@ -2927,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 ); + } } // ======================================================================= @@ -6834,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 ) @@ -8017,7 +8037,7 @@ BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( !mpFontEntry ) return 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; @@ -8035,10 +8055,12 @@ 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; @@ -8049,6 +8071,7 @@ BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( ++nUsedItems >= NMAXITEMS ) nUsedItems = NMAXITEMS; +#endif // ENABLE_IFC_CACHE } if( rFontCharMap.IsDefaultMap() ) diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 5dcce25a0315..969bc51b3cac 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 09cf1734eb6f..5d75c829da8a 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1693,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) ) ), @@ -1719,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; @@ -2138,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 ); @@ -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 ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 2eacdc215dd8..9457aea5f0c2 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..c01b8a9771d8 --- /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. + ULONG 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 USHORT 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 USHORT 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( FALSE ); + aPaint = pVDev->GetBitmap( aPoint, aDstSizePixel ); + pVDev->EnableMapMode( 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( FALSE ); + aMask = pVDev->GetBitmap( aPoint, aDstSizePixel ); + pVDev->EnableMapMode( TRUE ); + + // create alpha mask from gradient + pVDev->SetDrawMode( DRAWMODE_GRAYGRADIENT ); + pVDev->DrawGradient( Rectangle( aPoint, aDstSize ), rTransparenceGradient ); + pVDev->SetDrawMode( DRAWMODE_DEFAULT ); + pVDev->EnableMapMode( 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 BYTE* 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 d560b0b6e7cc..25ba80003fd7 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 8b4bf5163839..98eac5e982d3 100755 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -175,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 ), @@ -182,7 +183,8 @@ public: mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ), - mnDefaultPaperBin( -1 ) + mnDefaultPaperBin( -1 ), + mnFixedPaperBin( -1 ) {} ~ImplPrinterControllerData() { delete mpProgress; } @@ -556,7 +558,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: mnCurPage = 1; mnCurPrintPage = 1; mbPrinting = TRUE; - if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) + if( GetCapabilities( PRINTER_CAPABILITIES_USEPULLMODEL ) ) { mbJobActive = TRUE; // sallayer does all necessary page printing @@ -728,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 ) @@ -735,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 ) ) ); + USHORT 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 ) + USHORT nNewPaperBin = mpImplData->mpPrinter->GetPaperBin(); + if( aNewPaperSize != aPaperSize || nNewPaperBin != nPaperBin ) { mpImplData->maFixedPageSize = aNewPaperSize; mpImplData->maPageCache.invalidate(); @@ -752,6 +760,7 @@ bool PrinterController::setupPrinter( Window* i_pParent ) aOverrideSize.Height = aNewPaperSize.Height(); setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OverridePageSize" ) ), makeAny( aOverrideSize ) ); + mpImplData->mnFixedPaperBin = nNewPaperBin; } } } @@ -1022,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()); @@ -1149,8 +1166,13 @@ 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() ); diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index aeb928c46608..601e46411cd8 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 + } } // ----------------------------------------------------------------------- @@ -1733,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 ) ) { ULONG 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 5ebe70bcbdf9..d760ce1d1fed 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 1953ecf553c4..7181db56dd4d 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_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx index 9d4d2529249d..8a011606ab41 100644 --- a/vcl/source/glyphs/graphite_layout.cxx +++ b/vcl/source/glyphs/graphite_layout.cxx @@ -1085,6 +1085,7 @@ void GraphiteLayout::expandOrCondense(ImplLayoutArgs &rArgs) mvCharDxs[i] = FRound( fXFactor * mvCharDxs[i] ); } } + mnWidth = rArgs.mnLayoutWidth; } void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDeltaWidth) 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 c367aeb2bce5..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; - ULONG nUId; - BOOL bHasStringId; - BOOL bHasNumericId; -}; - - -ImplSmartIdData* SmartId::GetSmartIdData() -{ - if ( !mpData ) - { - mpData = new ImplSmartIdData; -// mpData->aUId = ""; - mpData->nUId = 0; - mpData->bHasStringId = FALSE; - mpData->bHasNumericId = FALSE; - } - return mpData; -} - - -SmartId::SmartId( const String& rId ) -: mpData( NULL ) -{ - GetSmartIdData()->aUId = rId; - GetSmartIdData()->bHasStringId = TRUE; -} - -SmartId::SmartId( ULONG nId ) -: mpData( NULL ) -{ - GetSmartIdData()->nUId = nId; - GetSmartIdData()->bHasNumericId = TRUE; -} - -SmartId::SmartId( const String& rId, ULONG nId ) -: mpData( NULL ) -{ - GetSmartIdData()->aUId = rId; - GetSmartIdData()->bHasStringId = TRUE; - GetSmartIdData()->nUId = nId; - GetSmartIdData()->bHasNumericId = 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; - } -} - -BOOL SmartId::HasNumeric() const -{ - if ( !mpData ) - return FALSE; - else - return mpData->bHasNumericId; -} - -BOOL SmartId::HasString() const -{ - if ( !mpData ) - return FALSE; - else - return mpData->bHasStringId; -} - -BOOL SmartId::HasAny() const -{ - return mpData != NULL; -} - -ULONG 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; -} - -BOOL SmartId::Matches( const String &rId )const -{ - if ( HasString() ) - return GetStr().EqualsIgnoreCaseAscii( rId ); - else - return FALSE; -} - -BOOL SmartId::Matches( const ULONG nId ) const -{ - if ( HasNumeric() ) - return GetNum() == nId; - else - return 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. -******************************************************************************/ -BOOL SmartId::Matches( const SmartId &rId ) const -{ - if ( !mpData || !rId.mpData ) - return FALSE; - else if ( HasString() && rId.HasString() ) - return Matches( rId.GetStr() ); - else - return rId.HasNumeric() && Matches( rId.GetNum() ); -} - -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 TRUE; - else - return FALSE; -} - -BOOL SmartId::operator == ( const SmartId& rRight ) const -{ - return Equals( rRight ); -} - -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/src/print.src b/vcl/source/src/print.src index 010cae338e0e..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; 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 b221d1f7d928..2ff7d0a687e7 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1348,8 +1348,10 @@ void ImplSmallBorderWindowView::DrawWindow( USHORT nDrawFlags, OutputDevice*, co Rectangle aBoundingRgn( aPoint, Size( mnWidth, mnHeight ) ); Rectangle aContentRgn( aCtrlRegion ); - if(pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion, - nState, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn )) + if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize && + pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion, + nState, aControlValue, rtl::OUString(), + aBoundingRgn, aContentRgn )) { aCtrlRegion=aContentRgn; } diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx index e835fe749ed1..9a0452027737 100644 --- a/vcl/source/window/btndlg.cxx +++ b/vcl/source/window/btndlg.cxx @@ -530,22 +530,19 @@ XubString ButtonDialog::GetButtonHelpText( USHORT nId ) const // ----------------------------------------------------------------------- -void ButtonDialog::SetButtonHelpId( USHORT nId, ULONG nHelpId ) +void ButtonDialog::SetButtonHelpId( USHORT nId, const rtl::OString& rHelpId ) { ImplBtnDlgItem* pItem = ImplGetItem( nId ); if ( pItem ) - pItem->mpPushButton->SetHelpId( nHelpId ); + pItem->mpPushButton->SetHelpId( rHelpId ); } // ----------------------------------------------------------------------- -ULONG ButtonDialog::GetButtonHelpId( USHORT nId ) const +rtl::OString ButtonDialog::GetButtonHelpId( USHORT 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/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 64f2b7e0d2a1..055b7e9fe80b 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 USHORT 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 USHORT 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/menu.cxx b/vcl/source/window/menu.cxx index e77eacb2fddf..52ad54957dd0 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) - ULONG nHelpId; // Help-Id + rtl::OString aHelpId; // Help-Id ULONG nUserValue; // User value Image aImage; // Image KeyCode aAccelKey; // Accelerator-Key @@ -252,7 +252,6 @@ MenuItemData* MenuItemList::Insert( USHORT nId, MenuItemType eType, pData->nBits = nBits; pData->pSubMenu = NULL; pData->pAutoSubMenu = NULL; - pData->nHelpId = 0; pData->nUserValue = 0; pData->bChecked = FALSE; pData->bEnabled = TRUE; @@ -284,7 +283,6 @@ void MenuItemList::InsertSeparator( USHORT nPos ) pData->nBits = 0; pData->pSubMenu = NULL; pData->pAutoSubMenu = NULL; - pData->nHelpId = 0; pData->nUserValue = 0; pData->bChecked = FALSE; pData->bEnabled = TRUE; @@ -844,14 +842,14 @@ static BOOL ImplHandleHelpEvent( Window* pMenuWindow, Menu* pMenu, USHORT nHighl // Ist eine ID vorhanden, dann Hilfe mit der ID aufrufen, sonst // den Hilfe-Index String aCommand = pMenu->GetItemCommand( nId ); - ULONG 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 = TRUE; } @@ -980,7 +978,7 @@ void Menu::ImplInit() 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 @@ -1330,15 +1328,14 @@ void Menu::InsertItem( const ResId& rResId, USHORT nPos ) SetHelpText( nItemId, aHelpText ); } - ULONG 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 ) @@ -1463,7 +1460,7 @@ void ImplCopyItem( Menu* pThis, const Menu& rMenu, USHORT nPos, USHORT nNewPos, pThis->CheckItem( nId, TRUE ); if ( !rMenu.IsItemEnabled( nId ) ) pThis->EnableItem( nId, 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 ); @@ -2039,7 +2036,7 @@ const XubString& Menu::ImplGetHelpText( USHORT 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 ) @@ -2047,8 +2044,8 @@ const XubString& Menu::ImplGetHelpText( USHORT 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 ); } } @@ -2081,22 +2078,29 @@ const XubString& Menu::GetTipHelpText( USHORT nItemId ) const return ImplGetSVEmptyStr(); } -void Menu::SetHelpId( USHORT nItemId, ULONG nHelpId ) +void Menu::SetHelpId( USHORT nItemId, const rtl::OString& rHelpId ) { MenuItemData* pData = pItemList->GetData( nItemId ); if ( pData ) - pData->nHelpId = nHelpId; + pData->aHelpId = rHelpId; } -ULONG Menu::GetHelpId( USHORT nItemId ) const +rtl::OString Menu::GetHelpId( USHORT 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 ) @@ -2480,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; + USHORT gfxExtra = (USHORT) Max( nExtra, 7L ); // #107710# increase space between checkmarks/images/text nCheckPos = (USHORT)nExtra; if (nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) @@ -2573,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, USHORT nBorder, long nStartY, MenuItemData* pThisItemOnly, BOOL bHighlighted, bool bLayout ) const { // Fuer Symbole: nFontHeight x nFontHeight @@ -2763,7 +2797,19 @@ void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData* 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(); } diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index 7f7a65cd7fb9..d00d569883d5 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -196,10 +196,9 @@ MessBox::MessBox( Window* pParent, const ResId& rResId ) : USHORT nLoButtons = ReadShortRes(); USHORT nHiDefButton = ReadShortRes(); USHORT nLoDefButton = ReadShortRes(); - USHORT nHiHelpId = ReadShortRes(); - USHORT nLoHelpId = ReadShortRes(); + rtl::OString aHelpId( ReadByteStringRes() ); /* USHORT bSysModal = */ ReadShortRes(); - SetHelpId( ((ULONG)nHiHelpId << 16) + nLoHelpId ); + SetHelpId( aHelpId ); WinBits nBits = (((ULONG)nHiButtons << 16) + nLoButtons) | (((ULONG)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 a0be94674328..5e4e0d59ccc6 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( 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, 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( 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; @@ -1127,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*/ ) @@ -2078,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() ))); @@ -2147,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 ) @@ -2575,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 d4ee01c26d61..322b2937b5c9 100644 --- a/vcl/source/window/seleng.cxx +++ b/vcl/source/window/seleng.cxx @@ -218,8 +218,15 @@ 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 @@ BOOL SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt ) |* *************************************************************************/ -BOOL SelectionEngine::SelMouseButtonUp( const MouseEvent& /* rMEvt */ ) +BOOL SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt ) { aWTimer.Stop(); //DbgOut("Up"); @@ -336,7 +343,11 @@ BOOL SelectionEngine::SelMouseButtonUp( const MouseEvent& /* rMEvt */ ) nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL); return 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/status.cxx b/vcl/source/window/status.cxx index ba4ab7984c52..36f27b1ceee7 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; - ULONG mnHelpId; + rtl::OString maHelpId; void* mpUserData; BOOL mbVisible; XubString maAccessibleName; @@ -906,9 +906,9 @@ void StatusBar::RequestHelp( const HelpEvent& rHEvt ) else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { String aCommand = GetItemCommand( nItemId ); - ULONG 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(); @@ -916,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; } @@ -1033,7 +1033,6 @@ void StatusBar::InsertItem( USHORT nItemId, ULONG nWidth, pItem->mnBits = nBits; pItem->mnWidth = (long)nWidth+nFudge+STATUSBAR_OFFSET; pItem->mnOffset = nOffset; - pItem->mnHelpId = 0; pItem->mpUserData = 0; pItem->mbVisible = TRUE; @@ -1475,15 +1474,15 @@ const XubString& StatusBar::GetHelpText( USHORT 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 ); } } @@ -1520,24 +1519,31 @@ const XubString& StatusBar::GetQuickHelpText( USHORT nItemId ) const // ----------------------------------------------------------------------- -void StatusBar::SetHelpId( USHORT nItemId, ULONG nHelpId ) +void StatusBar::SetHelpId( USHORT nItemId, const rtl::OString& rHelpId ) { USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - mpItemList->GetObject( nPos )->mnHelpId = nHelpId; + mpItemList->GetObject( nPos )->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -ULONG StatusBar::GetHelpId( USHORT nItemId ) const +rtl::OString StatusBar::GetHelpId( USHORT nItemId ) const { USHORT 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; } // ----------------------------------------------------------------------- diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index f3624ef56f59..f6a37658b79f 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -773,7 +773,7 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) BOOL bWrapped = 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/toolbox.cxx b/vcl/source/window/toolbox.cxx index 4de6c88490f6..b71cf1c13c8d 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -4820,15 +4820,15 @@ const XubString& ToolBox::ImplGetHelpText( USHORT 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 ); } } @@ -4894,9 +4894,9 @@ void ToolBox::RequestHelp( const HelpEvent& rHEvt ) else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) { String aCommand = GetItemCommand( nItemId ); - ULONG 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(); @@ -4904,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; } diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 334cdd2d0a64..35a39676353a 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( USHORT 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( USHORT 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( USHORT 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, USHORT 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( USHORT nItemId ) const // ----------------------------------------------------------------------- -void ToolBox::SetHelpId( USHORT nItemId, ULONG nHelpId ) +void ToolBox::SetHelpId( USHORT nItemId, const rtl::OString& rHelpId ) { ImplToolItem* pItem = ImplGetItem( nItemId ); if ( pItem ) - pItem->mnHelpId = nHelpId; + pItem->maHelpId = rHelpId; } // ----------------------------------------------------------------------- -ULONG ToolBox::GetHelpId( USHORT nItemId ) const +rtl::OString ToolBox::GetHelpId( USHORT 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 adedbde4c0f2..77da205131ea 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -612,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) @@ -1179,20 +1177,14 @@ void Window::ImplCallMove() // ----------------------------------------------------------------------- -static ULONG ImplAutoHelpID( ResMgr* pResMgr ) +static rtl::OString ImplAutoHelpID( ResMgr* pResMgr ) { - if ( !Application::IsAutoHelpIdEnabled() ) - return 0; - - ULONG 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; } // ----------------------------------------------------------------------- @@ -1212,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 ); - ULONG 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 ULONG nRSStyle = ReadLongRes(); // WinBits ReadLongRes(); - // HelpId - ReadLongRes(); + + if( nObjMask & WINDOW_HELPID ) + aHelpId = ReadByteStringRes(); + + SetHelpId( aHelpId ); BOOL bPos = FALSE; BOOL bSize = FALSE; @@ -1294,7 +1287,7 @@ void Window::ImplLoadRes( const ResId& rResId ) if ( nObjMask & WINDOW_EXTRALONG ) SetData( (void*)ReadLongRes() ); if ( nObjMask & WINDOW_UNIQUEID ) - SetUniqueId( (ULONG)ReadLongRes() ); + SetUniqueId( ReadByteStringRes() ); if ( nObjMask & WINDOW_BORDER_STYLE ) { @@ -1322,8 +1315,6 @@ ImplWinData* Window::ImplGetWinData() const mpWindowImpl->mpWinData->mnIsTopWindow = (USHORT) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mpWindowImpl->mpWinData->mbMouseOver = FALSE; mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? FALSE : TRUE; // TRUE: try to draw this control with native theme API - mpWindowImpl->mpWinData->mpSmartHelpId = NULL; - mpWindowImpl->mpWinData->mpSmartUniqueId = NULL; } return mpWindowImpl->mpWinData; @@ -4734,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; } @@ -4875,6 +4862,12 @@ void Window::Paint( const Rectangle& rRect ) // ----------------------------------------------------------------------- +void Window::PostPaint() +{ +} + +// ----------------------------------------------------------------------- + void Window::Draw( OutputDevice*, const Point&, const Size&, ULONG ) { DBG_CHKTHIS( Window, ImplDbgCheckWindow ); @@ -4979,29 +4972,18 @@ void Window::RequestHelp( const HelpEvent& rHEvt ) } else { - SmartId aSmartId = GetSmartHelpId(); - - ULONG 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 ); } } } @@ -8130,32 +8112,22 @@ const XubString& Window::GetHelpText() const { DBG_CHKTHIS( Window, ImplDbgCheckWindow ); - SmartId aSmartId = GetSmartHelpId(); - - ULONG 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 = FALSE; } } } - else if( mpWindowImpl->mbHelpTextDynamic && (nNumHelpId || bStrHelpId) ) + else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId ) { static const char* pEnv = getenv( "HELP_DEBUG" ); if( pEnv && *pEnv ) @@ -8163,10 +8135,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 = FALSE; @@ -9401,7 +9370,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 { @@ -9416,7 +9385,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 ) { @@ -9429,7 +9398,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 { @@ -9445,7 +9414,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 02b2713b01cc..e5b58a8b6f3c 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( ULONG nHelpId ) +void Window::SetHelpId( const rtl::OString& rHelpId ) { - SetSmartHelpId(SmartId(nHelpId)); + mpWindowImpl->maHelpId = rHelpId; } -ULONG 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( ULONG nUniqueId ) { mpWindowImpl->mnUniqId = nUniqueId; } -ULONG 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() |