salprn.cxx (cdf0e10c) salprn.cxx (92a1bdef)
1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *

--- 171 unchanged lines hidden (view full) ---

180
181sal_Bool AquaSalInfoPrinter::Setup( SalFrame*, ImplJobSetup* )
182{
183 return sal_False;
184}
185
186// -----------------------------------------------------------------------
187
1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *

--- 171 unchanged lines hidden (view full) ---

180
181sal_Bool AquaSalInfoPrinter::Setup( SalFrame*, ImplJobSetup* )
182{
183 return sal_False;
184}
185
186// -----------------------------------------------------------------------
187
188static struct PaperSizeEntry
189{
190 double fWidth;
191 double fHeight;
192 Paper nPaper;
193} aPaperSizes[] =
194{
195 { 842, 1191, PAPER_A3 },
196 { 595, 842, PAPER_A4 },
197 { 420, 595, PAPER_A5 },
198 { 612, 792, PAPER_LETTER },
199 { 612, 1008, PAPER_LEGAL },
200 { 728, 1032, PAPER_B4_JIS },
201 { 516, 729, PAPER_B5_JIS },
202 { 792, 1224, PAPER_TABLOID }
203};
204
205static bool getPaperSize( double& o_fWidth, double& o_fHeight, const Paper i_ePaper )
206{
207 for(unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
208 {
209 if( aPaperSizes[i].nPaper == i_ePaper )
210 {
211 o_fWidth = aPaperSizes[i].fWidth;
212 o_fHeight = aPaperSizes[i].fHeight;
213 return true;
214 }
215 }
216 return false;
217}
218
219static Paper recognizePaper( double i_fWidth, double i_fHeight )
220{
221 Paper aPaper = PAPER_USER;
222 sal_uInt64 nPaperDesc = 1000000*sal_uInt64(i_fWidth) + sal_uInt64(i_fHeight);
223 switch( nPaperDesc )
224 {
225 case 842001191: aPaper = PAPER_A3; break;
226 case 595000842: aPaper = PAPER_A4; break;
227 case 420000595: aPaper = PAPER_A5; break;
228 case 612000792: aPaper = PAPER_LETTER; break;
229 case 728001032: aPaper = PAPER_B4_JIS; break;
230 case 516000729: aPaper = PAPER_B5_JIS; break;
231 case 612001008: aPaper = PAPER_LEGAL; break;
232 case 792001224: aPaper = PAPER_TABLOID; break;
233 default:
234 aPaper = PAPER_USER;
235 break;
236 }
237
238 if( aPaper == PAPER_USER )
239 {
240 // search with fuzz factor
241 for( unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
242 {
243 double w = (i_fWidth > aPaperSizes[i].fWidth) ? i_fWidth - aPaperSizes[i].fWidth : aPaperSizes[i].fWidth - i_fWidth;
244 double h = (i_fHeight > aPaperSizes[i].fHeight) ? i_fHeight - aPaperSizes[i].fHeight : aPaperSizes[i].fHeight - i_fHeight;
245 if( w < 3 && h < 3 )
246 {
247 aPaper = aPaperSizes[i].nPaper;
248 break;
249 }
250 }
251 }
252
253 return aPaper;
254}
255
256sal_Bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
257{
258 // FIXME: implement driver data
259 if( io_pSetupData && io_pSetupData->mpDriverData )
260 return SetData( ~0, io_pSetupData );
261
262
263 sal_Bool bSuccess = sal_True;
264
265 // set system type
266 io_pSetupData->mnSystem = JOBSETUP_SYSTEM_MAC;
267
268 // get paper format
269 if( mpPrintInfo )
270 {
271 NSSize aPaperSize = [mpPrintInfo paperSize];
272 double width = aPaperSize.width, height = aPaperSize.height;
273 // set paper
188sal_Bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
189{
190 // FIXME: implement driver data
191 if( io_pSetupData && io_pSetupData->mpDriverData )
192 return SetData( ~0, io_pSetupData );
193
194
195 sal_Bool bSuccess = sal_True;
196
197 // set system type
198 io_pSetupData->mnSystem = JOBSETUP_SYSTEM_MAC;
199
200 // get paper format
201 if( mpPrintInfo )
202 {
203 NSSize aPaperSize = [mpPrintInfo paperSize];
204 double width = aPaperSize.width, height = aPaperSize.height;
205 // set paper
274 io_pSetupData->mePaperFormat = recognizePaper( width, height );
206 PaperInfo aInfo( PtTo10Mu( width ), PtTo10Mu( height ) );
207 aInfo.doSloppyFit();
208 io_pSetupData->mePaperFormat = aInfo.getPaper();
275 if( io_pSetupData->mePaperFormat == PAPER_USER )
276 {
277 io_pSetupData->mnPaperWidth = PtTo10Mu( width );
278 io_pSetupData->mnPaperHeight = PtTo10Mu( height );
279 }
280 else
281 {
282 io_pSetupData->mnPaperWidth = 0;

--- 59 unchanged lines hidden (view full) ---

342 if( io_pSetupData->mnPaperWidth && io_pSetupData->mnPaperHeight )
343 {
344 width = io_pSetupData->mnPaperWidth;
345 height = io_pSetupData->mnPaperHeight;
346 }
347 }
348 else
349 {
209 if( io_pSetupData->mePaperFormat == PAPER_USER )
210 {
211 io_pSetupData->mnPaperWidth = PtTo10Mu( width );
212 io_pSetupData->mnPaperHeight = PtTo10Mu( height );
213 }
214 else
215 {
216 io_pSetupData->mnPaperWidth = 0;

--- 59 unchanged lines hidden (view full) ---

276 if( io_pSetupData->mnPaperWidth && io_pSetupData->mnPaperHeight )
277 {
278 width = io_pSetupData->mnPaperWidth;
279 height = io_pSetupData->mnPaperHeight;
280 }
281 }
282 else
283 {
350 double w = 595, h = 842;
351 getPaperSize( w, h, io_pSetupData->mePaperFormat );
352 width = static_cast<long>(PtTo10Mu( w ));
353 height = static_cast<long>(PtTo10Mu( h ));
284 PaperInfo aInfo( io_pSetupData->mePaperFormat );
285 width = aInfo.getWidth();
286 height = aInfo.getHeight();
354 }
355
356 setPaperSize( width, height, mePageOrientation );
357 }
358 }
359
360 return mpPrintInfo != nil;
361}

--- 532 unchanged lines hidden ---
287 }
288
289 setPaperSize( width, height, mePageOrientation );
290 }
291 }
292
293 return mpPrintInfo != nil;
294}

--- 532 unchanged lines hidden ---