summaryrefslogtreecommitdiff
path: root/starmath/source/unomodel.cxx
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2003-04-24 13:08:12 +0000
committerRüdiger Timm <rt@openoffice.org>2003-04-24 13:08:12 +0000
commit90ae4430152fe909ac68315d62b2c2159bc90636 (patch)
treec85d5f0c150a8ddbfac5d2af951f8234cc8c8158 /starmath/source/unomodel.cxx
parent48f3a9d98b30e1118109bbf42d4e72e022c437e6 (diff)
INTEGRATION: CWS mav4 (1.23.70); FILE MERGED
2003/04/15 12:50:02 tl 1.23.70.1: #108782# PDF export with non existing printers fixed
Diffstat (limited to 'starmath/source/unomodel.cxx')
-rw-r--r--starmath/source/unomodel.cxx68
1 files changed, 62 insertions, 6 deletions
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index f61f0ee88b16..726a57cc2d7d 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unomodel.cxx,v $
*
- * $Revision: 1.23 $
+ * $Revision: 1.24 $
*
- * last change: $Author: tl $ $Date: 2002-11-20 08:54:41 $
+ * last change: $Author: rt $ $Date: 2003-04-24 14:08:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,21 @@
#ifndef _SFX_ITEMPROP_HXX
#include <svtools/itemprop.hxx>
#endif
+#ifndef _TOOLS_INTN_HXX
+#include <tools/intn.hxx>
+#endif
+#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
+#include <unotools/localedatawrapper.hxx>
+#endif
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
+#ifndef _SVX_PAPERINF_HXX
+#include <svx/paperinf.hxx>
+#endif
+#ifndef _SV_SETTINGS_HXX
+#include <vcl/settings.hxx>
+#endif
#ifndef _TOOLKIT_AWT_VCLXDEVICE_HXX_
#include <toolkit/awt/vclxdevice.hxx>
#endif
@@ -866,6 +881,30 @@ 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 Twip
+ aRes.Width() = lA4Width;
+ aRes.Height() = lA4Height;
+ }
+ else
+ {
+ // in Twip
+ aRes.Width() = lLetterWidth;
+ aRes.Height() = lLetterHeight;
+ }
+ aRes = OutputDevice::LogicToLogic( aRes, MapMode(MAP_TWIP),
+ MapMode(MAP_100TH_MM) );
+ return aRes;
+}
+
+
uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
sal_Int32 nRenderer,
const uno::Any& rSelection,
@@ -885,6 +924,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
Printer *pPrinter = aPrinterAccess.GetPrinter();
//Point aPrtPageOffset( pPrinter->GetPageOffset() );
Size aPrtPaperSize ( pPrinter->GetPaperSize() );
+
+ // if paper size is 0 (usually if no 'real' printer is found),
+ // guess the paper size
+ if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
+ aPrtPaperSize = lcl_GuessPaperSize();
awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
uno::Sequence< beans::PropertyValue > aRenderer(1);
@@ -938,11 +982,23 @@ void SAL_CALL SmModel::render(
SmPrinterAccess aPrinterAccess( *pDocSh );
Printer *pPrinter = aPrinterAccess.GetPrinter();
- Point aZeroPoint;
- Rectangle OutputRect( aZeroPoint, pPrinter->GetOutputSize() );
-
- Point aPrtPageOffset( pPrinter->GetPageOffset() );
Size aPrtPaperSize ( pPrinter->GetPaperSize() );
+ Size aOutputSize ( pPrinter->GetOutputSize() );
+ Point aPrtPageOffset( pPrinter->GetPageOffset() );
+
+ // no real printer ??
+ if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
+ {
+ aPrtPaperSize = lcl_GuessPaperSize();
+ // factors from Windows DIN A4
+ aOutputSize = Size( aPrtPaperSize.Width() * 0.941,
+ aPrtPaperSize.Height() * 0.961);
+ aPrtPageOffset = Point( aPrtPaperSize.Width() * 0.0250,
+ aPrtPaperSize.Height() * 0.0214);
+ }
+ Point aZeroPoint;
+ Rectangle OutputRect( aZeroPoint, aOutputSize );
+
// set minimum top and bottom border
if (aPrtPageOffset.Y() < 2000)