diff options
-rw-r--r-- | vcl/inc/vcl/print.hxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/print3.cxx | 31 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 17 |
3 files changed, 49 insertions, 1 deletions
diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 96822d9bc756..af83b2db40e1 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -478,6 +478,7 @@ public: */ void enableUIOption( const rtl::OUString& rPropName, bool bEnable ); bool isUIOptionEnabled( const rtl::OUString& rPropName ) const; + bool isUIChoiceEnabled( const rtl::OUString& rPropName, sal_Int32 nChoice ) const; /* returns the property name rPropName depends on or an empty string if no dependency exists. */ @@ -649,6 +650,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, const rtl::OUString& i_rType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), + const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(), const UIControlOptions& i_rControlOptions = UIControlOptions() ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 191f8f26dc75..f6bd81ef1bea 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -150,6 +150,7 @@ public: typedef std::hash_map< rtl::OUString, size_t, rtl::OUStringHash > PropertyToIndexMap; typedef std::hash_map< rtl::OUString, ControlDependency, rtl::OUStringHash > ControlDependencyMap; + typedef std::hash_map< rtl::OUString, Sequence< sal_Bool >, rtl::OUStringHash > ChoiceDisableMap; boost::shared_ptr<Printer> mpPrinter; Sequence< PropertyValue > maUIOptions; @@ -158,6 +159,7 @@ public: PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; + ChoiceDisableMap maChoiceDisableMap; sal_Bool mbFirstPage; sal_Bool mbLastPage; sal_Bool mbReversePageOrder; @@ -1299,6 +1301,7 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ bool bHaveProperty = false; rtl::OUString aPropName; vcl::ImplPrinterControllerData::ControlDependency aDep; + Sequence< sal_Bool > aChoicesDisabled; for( int n = 0; n < aOptProp.getLength(); n++ ) { const beans::PropertyValue& rEntry( aOptProp[ n ] ); @@ -1326,6 +1329,10 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ { rEntry.Value >>= aDep.mnDependsOnEntry; } + else if( rEntry.Name.equalsAscii( "ChoicesDisabled" ) ) + { + rEntry.Value >>= aChoicesDisabled; + } } if( bHaveProperty ) { @@ -1338,6 +1345,8 @@ void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_ } if( aDep.maDependsOnName.getLength() > 0 ) mpImplData->maControlDependencies[ aPropName ] = aDep; + if( aChoicesDisabled.getLength() > 0 ) + mpImplData->maChoiceDisableMap[ aPropName ] = aChoicesDisabled; } } } @@ -1413,6 +1422,20 @@ bool PrinterController::isUIOptionEnabled( const rtl::OUString& i_rProperty ) co return bEnabled; } +bool PrinterController::isUIChoiceEnabled( const rtl::OUString& i_rProperty, sal_Int32 i_nValue ) const +{ + bool bEnabled = true; + ImplPrinterControllerData::ChoiceDisableMap::const_iterator it = + mpImplData->maChoiceDisableMap.find( i_rProperty ); + if(it != mpImplData->maChoiceDisableMap.end() ) + { + const Sequence< sal_Bool >& rDisabled( it->second ); + if( i_nValue >= 0 && i_nValue < rDisabled.getLength() ) + bEnabled = ! rDisabled[i_nValue]; + } + return bEnabled; +} + rtl::OUString PrinterController::getDependency( const rtl::OUString& i_rProperty ) const { rtl::OUString aDependency; @@ -1789,14 +1812,20 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, const Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, const rtl::OUString& i_rType, + const Sequence< sal_Bool >& i_rDisabledChoices, const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { UIControlOptions aOpt( i_rControlOptions ); sal_Int32 nUsed = aOpt.maAddProps.getLength(); - aOpt.maAddProps.realloc( nUsed + 1 ); + aOpt.maAddProps.realloc( nUsed + 1 + (i_rDisabledChoices.getLength() ? 1 : 0) ); aOpt.maAddProps[nUsed].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); aOpt.maAddProps[nUsed].Value = makeAny( i_rChoices ); + if( i_rDisabledChoices.getLength() ) + { + aOpt.maAddProps[nUsed+1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChoicesDisabled" ) ); + aOpt.maAddProps[nUsed+1].Value = makeAny( i_rDisabledChoices ); + } PropertyValue aVal; aVal.Name = i_rProperty; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 35077b1cff0e..13cba8a4ce81 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1192,6 +1192,7 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + Sequence< sal_Bool > aChoicesDisabled; Sequence< rtl::OUString > aHelpTexts; sal_Int64 nMinValue = 0, nMaxValue = 0; sal_Int32 nCurHelpText = 0; @@ -1215,6 +1216,10 @@ void PrintDialog::setupOptionalUI() { rEntry.Value >>= aChoices; } + else if( rEntry.Name.equalsAscii( "ChoicesDisabled" ) ) + { + rEntry.Value >>= aChoicesDisabled; + } else if( rEntry.Name.equalsAscii( "Property" ) ) { PropertyValue aVal; @@ -1497,6 +1502,8 @@ void PrintDialog::setupOptionalUI() pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); + if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] == sal_True ) + pBtn->Enable( FALSE ); pBtn->Show(); maPropertyToWindowMap[ aPropertyName ].push_back( pBtn ); maControlToPropertyMap[pBtn] = aPropertyName; @@ -1821,6 +1828,16 @@ void PrintDialog::checkOptionalControlDependencies() } } + if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first) ) + { + std::map< Window*, sal_Int32 >::const_iterator r_it = maControlToNumValMap.find( it->first ); + if( r_it != maControlToNumValMap.end() ) + { + bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second ); + } + } + + bool bIsEnabled = it->first->IsEnabled(); // Enable does not do a change check first, so can be less cheap than expected if( bShouldbeEnabled != bIsEnabled ) |