diff options
author | Philipp Lohmann <pl@openoffice.org> | 2009-04-15 19:11:23 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2009-04-15 19:11:23 +0000 |
commit | 1777b5a68513f7cbfaa239acf16bcc76a49b448c (patch) | |
tree | 6a0e000dc080c5b70e85df3bf1b070dbf9df6557 /starmath/source | |
parent | 1fbd16c4069cf7cdcc9489374596f6c9eb378f1c (diff) |
#i92516# vcl helper for new print ui options
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/unomodel.cxx | 184 |
1 files changed, 38 insertions, 146 deletions
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 971f9c5f2d52..03639668573f 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -80,181 +80,73 @@ using namespace ::com::sun::star::script; #define C2U(cChar) rtl::OUString::createFromAscii(cChar) -class SmPrintUIOptions +class SmPrintUIOptions : public vcl::PrinterOptionsHelper { - ResStringArray m_aLocalizedStrings; - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const PropertyValue* i_pVal = NULL, - const Sequence< rtl::OUString >* i_pChoices = NULL, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rProperty, - sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const rtl::OUString& i_rProperty, - const Sequence< rtl::OUString >& i_rChoices, - sal_Int32 i_nValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); public: SmPrintUIOptions(); - - void addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ); }; SmPrintUIOptions::SmPrintUIOptions() -: m_aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) ) -{ -} - -Any SmPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const PropertyValue* i_pVal, - const Sequence< rtl::OUString >* i_pChoices, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry - ) -{ - Sequence< PropertyValue > aCtrl(6); - sal_Int32 nUsed = 0; - if( i_rTitle.getLength() ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); - aCtrl[nUsed++].Value = makeAny( i_rTitle ); - } - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlType" ) ); - aCtrl[nUsed++].Value = makeAny( i_rType ); - if( i_pVal ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pVal ); - } - if( i_pChoices ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pChoices ); - } - if( i_pDependsOnName ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pDependsOnName ); - if( i_nDependsOnEntry != -1 ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); - aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); - } - } - aCtrl.realloc( nUsed ); - return makeAny( aCtrl ); -} - -Any SmPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rProperty, - sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry ) -{ - PropertyValue aVal; - aVal.Name = i_rProperty; - aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); -} - -Any SmPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const rtl::OUString& i_rProperty, - const Sequence< rtl::OUString >& i_rChoices, - sal_Int32 i_nValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry ) { - PropertyValue aVal; - aVal.Name = i_rProperty; - aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); -} + ResStringArray aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) ); + DBG_ASSERT( aLocalizedStrings.Count() >= 10, "resource incomplete" ); + if( aLocalizedStrings.Count() < 10 ) // bad resource ? + return; -void SmPrintUIOptions::addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ) -{ // create sequence of print UI options - uno::Sequence< beans::PropertyValue > aUIOptions( 10 ); + m_aUIProperties.realloc( 10 ); - DBG_ASSERT( m_aLocalizedStrings.Count() >= 10, "resource incomplete" ); - if( m_aLocalizedStrings.Count() < 10 ) // bad resource ? - return; // create Section for formula (results in an extra tab page in dialog) - aUIOptions[0].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 0 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + m_aUIProperties[0].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ) ); // create subgroup for print options - aUIOptions[1].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 1 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + m_aUIProperties[1].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ) ); // create a bool option for title row - aUIOptions[2].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 2 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TitleRow" ) ), - sal_True ); + m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TitleRow" ) ), + sal_True ); // create a bool option for formula text - aUIOptions[3].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 3 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormulaText" ) ), - sal_True ); + m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormulaText" ) ), + sal_True ); // create a bool option for border - aUIOptions[4].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 4 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Border" ) ), - sal_True ); + m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Border" ) ), + sal_True ); // create subgroup for print format - aUIOptions[5].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 5 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + m_aUIProperties[5].Value = getUIControlOpt( aLocalizedStrings.GetString( 5 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); // create a radio button group for print format Sequence< rtl::OUString > aChoices( 3 ); - aChoices[0] = m_aLocalizedStrings.GetString( 6 ); - aChoices[1] = m_aLocalizedStrings.GetString( 7 ); - aChoices[2] = m_aLocalizedStrings.GetString( 8 ); + aChoices[0] = aLocalizedStrings.GetString( 6 ); + aChoices[1] = aLocalizedStrings.GetString( 7 ); + aChoices[2] = aLocalizedStrings.GetString( 8 ); OUString aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( "PrintFormat" ) ); - aUIOptions[6].Value = getUIControlOpt( rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintFormat" ) ), - aChoices, 0 - ); + m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(), + aPrintFormatProp, + aChoices, 0 + ); // create a numeric box for scale dependent on PrintFormat = "Scaling" - PropertyValue aVal; - aVal.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintScale" ) ); - aVal.Value = makeAny( sal_Int32( 100 ) ); - aUIOptions[ 7 ].Value = getUIControlOpt( rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Range" ) ), - &aVal, - NULL, - &aPrintFormatProp, - 2 ); + m_aUIProperties[ 7 ].Value = getRangeControlOpt( rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintScale" ) ), + 100, // initial value + 10, // min value + 1000, // max value + &aPrintFormatProp, + 2 ); // create subgroup for misc options - aUIOptions[8].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 9 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + m_aUIProperties[8].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 9 ) ); // create a bool option for ignore spacing - aUIOptions[9].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 10 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Border" ) ), - sal_True ); - - sal_Int32 nLen = io_rProps.getLength(); - io_rProps.realloc( nLen+1 ); - io_rProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExtraPrintUIOptions" ) ); - io_rProps[nLen].Value = uno::makeAny( aUIOptions ); + m_aUIProperties[9].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Border" ) ), + sal_True ); } @@ -1106,7 +998,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); rValue.Value <<= aPageSize; - m_pPrintUIOptions->addPrintUIOptions( aRenderer ); + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; } |