summaryrefslogtreecommitdiff
path: root/starmath/source/unomodel.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'starmath/source/unomodel.cxx')
-rw-r--r--starmath/source/unomodel.cxx151
1 files changed, 141 insertions, 10 deletions
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 8339e4ed66..be3e274a5f 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -37,11 +37,12 @@
#include <sfx2/printer.hxx>
#include <vcl/svapp.hxx>
#include <svtools/ctrltool.hxx>
-#include <svtools/itemprop.hxx>
+#include <svl/itemprop.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/processfactory.hxx>
#include <svx/paperinf.hxx>
#include <vcl/settings.hxx>
+#include <vcl/print.hxx>
#include <toolkit/awt/vclxdevice.hxx>
#include <com/sun/star/beans/PropertyState.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -51,15 +52,14 @@
#include <xmloff/xmluconv.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/propertysetinfo.hxx>
+#include <unotools/moduleoptions.hxx>
+
#include <unomodel.hxx>
#include <document.hxx>
#include <view.hxx>
#include <symbol.hxx>
-#ifndef STARMATH_HRC
#include <starmath.hrc>
-#endif
#include <config.hxx>
-
#include <smdll.hxx>
using namespace ::vos;
@@ -75,11 +75,102 @@ using namespace ::com::sun::star::formula;
using namespace ::com::sun::star::view;
using namespace ::com::sun::star::script;
+
#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+////////////////////////////////////////////////////////////
+
+SmPrintUIOptions::SmPrintUIOptions()
+{
+ ResStringArray aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) );
+ DBG_ASSERT( aLocalizedStrings.Count() >= 18, "resource incomplete" );
+ if( aLocalizedStrings.Count() < 18 ) // bad resource ?
+ return;
+
+ SmModule *pp = SM_MOD1();
+ SmConfig *pConfig = pp->GetConfig();
+ DBG_ASSERT( pConfig, "SmConfig not found" );
+ if (!pConfig)
+ return;
+
+ // create sequence of print UI options
+ // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
+ m_aUIProperties.realloc( 9 );
+
+ // create Section for formula (results in an extra tab page in dialog)
+ SvtModuleOptions aOpt;
+ String aAppGroupname( aLocalizedStrings.GetString( 0 ) );
+ aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
+ aOpt.GetModuleName( SvtModuleOptions::E_SMATH ) );
+ m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() );
+
+ // create subgroup for print options
+ m_aUIProperties[1].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() );
+
+ // create a bool option for title row (matches to SID_PRINTTITLE)
+ m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ),
+ aLocalizedStrings.GetString( 3 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_TITLE_ROW ) ),
+ pConfig->IsPrintTitle() );
+ // create a bool option for formula text (matches to SID_PRINTTEXT)
+ m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ),
+ aLocalizedStrings.GetString( 5 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_FORMULA_TEXT ) ),
+ pConfig->IsPrintFormulaText() );
+ // create a bool option for border (matches to SID_PRINTFRAME)
+ m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ),
+ aLocalizedStrings.GetString( 7 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_BORDER ) ),
+ pConfig->IsPrintFrame() );
+
+ // create subgroup for print format
+ m_aUIProperties[5].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 8 ), rtl::OUString() );
+
+ // create a radio button group for print format (matches to SID_PRINTSIZE)
+ Sequence< rtl::OUString > aChoices( 3 );
+ aChoices[0] = aLocalizedStrings.GetString( 9 );
+ aChoices[1] = aLocalizedStrings.GetString( 11 );
+ aChoices[2] = aLocalizedStrings.GetString( 13 );
+ Sequence< rtl::OUString > aHelpTexts( 3 );
+ aHelpTexts[0] = aLocalizedStrings.GetString( 10 );
+ aHelpTexts[1] = aLocalizedStrings.GetString( 12 );
+ aHelpTexts[2] = aLocalizedStrings.GetString( 14 );
+ OUString aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_FORMAT ) );
+ m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(),
+ aHelpTexts,
+ aPrintFormatProp,
+ aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize())
+ );
+
+ // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
+ vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, sal_True );
+ m_aUIProperties[ 7 ].Value = getRangeControlOpt( rtl::OUString(),
+ aLocalizedStrings.GetString( 14 ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_SCALE ) ),
+ pConfig->GetPrintZoomFactor(), // initial value
+ 10, // min value
+ 1000, // max value
+ aRangeOpt );
+
+ Sequence< PropertyValue > aHintNoLayoutPage( 1 );
+ aHintNoLayoutPage[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HintNoLayoutPage" ) );
+ aHintNoLayoutPage[0].Value = makeAny( sal_True );
+ m_aUIProperties[8].Value <<= aHintNoLayoutPage;
+
+// IsIgnoreSpacesRight is a parser option! Thus we don't add it to the printer UI.
+//
+// // create subgroup for misc options
+// m_aUIProperties[8].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 9 ) );
+//
+// // create a bool option for ignore spacing (matches to SID_NO_RIGHT_SPACES)
+// m_aUIProperties[9].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ),
+// rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_NO_RIGHT_SPACE ) ),
+// pConfig->IsIgnoreSpacesRight() );
+}
+
-////////////////////////////////////////
+////////////////////////////////////////////////////////////
//
// class SmModel
//
@@ -229,11 +320,14 @@ PropertySetInfo * lcl_createModelPropertyInfo ()
SmModel::SmModel( SfxObjectShell *pObjSh )
: SfxBaseModel(pObjSh)
, PropertySetHelper ( lcl_createModelPropertyInfo () )
+, m_pPrintUIOptions( NULL )
+
{
}
//-----------------------------------------------------------------------
SmModel::~SmModel() throw ()
{
+ delete m_pPrintUIOptions;
}
/*-- 28.03.00 14:18:17---------------------------------------------------
@@ -862,10 +956,33 @@ sal_Int32 SAL_CALL SmModel::getRendererCount(
return 1;
}
+
+static Size lcl_GuessPaperSize()
+{
+ Size aRes;
+ Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
+ LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() );
+ if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() )
+ {
+ // in 100th mm
+ PaperInfo aInfo( PAPER_A4 );
+ aRes.Width() = aInfo.getWidth();
+ aRes.Height() = aInfo.getHeight();
+ }
+ else
+ {
+ // in 100th mm
+ PaperInfo aInfo( PAPER_LETTER );
+ aRes.Width() = aInfo.getWidth();
+ aRes.Height() = aInfo.getHeight();
+ }
+ return aRes;
+}
+
uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
sal_Int32 nRenderer,
const uno::Any& /*rSelection*/,
- const uno::Sequence< beans::PropertyValue >& /*xOptions*/ )
+ const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ )
throw (IllegalArgumentException, RuntimeException)
{
::vos::OGuard aGuard(Application::GetSolarMutex());
@@ -885,7 +1002,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
// if paper size is 0 (usually if no 'real' printer is found),
// guess the paper size
if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
- aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM);
+ aPrtPaperSize = lcl_GuessPaperSize();
awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
uno::Sequence< beans::PropertyValue > aRenderer(1);
@@ -893,6 +1010,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
rValue.Value <<= aPageSize;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = new SmPrintUIOptions();
+ m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
+
return aRenderer;
}
@@ -954,7 +1075,7 @@ void SAL_CALL SmModel::render(
// no real printer ??
if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
{
- aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM);
+ aPrtPaperSize = lcl_GuessPaperSize();
// factors from Windows DIN A4
aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941),
(long)(aPrtPaperSize.Height() * 0.961));
@@ -979,8 +1100,18 @@ void SAL_CALL SmModel::render(
OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() -
(aPrtPageOffset.X() + OutputRect.Right()));
- pView->Impl_Print( *pOut, PRINT_SIZE_NORMAL,
- Rectangle( OutputRect ), Point() );
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = new SmPrintUIOptions();
+ m_pPrintUIOptions->processProperties( rxOptions );
+
+ pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() );
+
+ // release SmPrintUIOptions when everything is done.
+ // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
+ if (m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ))
+ {
+ delete m_pPrintUIOptions; m_pPrintUIOptions = 0;
+ }
}
}
}