Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #ifndef GCC
22 : # pragma hdrstop
23 : #endif
24 :
25 : #include <tools/stream.hxx>
26 : #include <svtools/filter.hxx>
27 : #include <svtools/FilterConfigItem.hxx>
28 : #include <svtools/svtools.hrc>
29 : #include <svtools/svtresid.hxx>
30 : #include <com/sun/star/io/XStream.hpp>
31 : #include <com/sun/star/awt/Size.hpp>
32 : #include <com/sun/star/view/XSelectionSupplier.hpp>
33 : #include <com/sun/star/frame/XModel.hpp>
34 : #include <com/sun/star/frame/XController.hpp>
35 : #include <com/sun/star/drawing/XDrawView.hpp>
36 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 : #include <com/sun/star/graphic/XPrimitiveFactory2D.hpp>
38 : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
39 : #include <com/sun/star/document/XExporter.hpp>
40 : #include <com/sun/star/document/XFilter.hpp>
41 : #include <unotools/streamwrap.hxx>
42 : #include <vcl/msgbox.hxx>
43 : #include <vcl/svapp.hxx>
44 : #include <vcl/outdev.hxx>
45 : #include <vcl/graph.hxx>
46 : #include <rtl/ustrbuf.hxx>
47 : #include <basegfx/matrix/b2dhommatrix.hxx>
48 : #include "exportdialog.hxx"
49 :
50 : #define FORMAT_UNKNOWN 0
51 : #define FORMAT_JPG 1
52 : #define FORMAT_PNG 2
53 : #define FORMAT_BMP 3
54 : #define FORMAT_GIF 4
55 : #define FORMAT_PBM 5
56 : #define FORMAT_PGM 6
57 : #define FORMAT_PPM 7
58 : #define FORMAT_PCT 8
59 : #define FORMAT_RAS 9
60 : #define FORMAT_TIF 10
61 : #define FORMAT_XPM 11
62 : #define FORMAT_WMF 12
63 : #define FORMAT_EMF 13
64 : #define FORMAT_EPS 14
65 : #define FORMAT_MET 15
66 : #define FORMAT_SVG 16
67 : #define FORMAT_SVM 17
68 :
69 : #define UNIT_DEFAULT -1
70 : #define UNIT_INCH 0
71 : #define UNIT_CM 1
72 : #define UNIT_MM 2
73 : #define UNIT_POINT 3
74 : #define UNIT_PIXEL 4
75 : #define UNIT_MAX_ID UNIT_PIXEL
76 :
77 : using namespace ::com::sun::star;
78 :
79 0 : static sal_Int16 GetFilterFormat(const OUString& rExt)
80 : {
81 0 : sal_Int16 nFormat = FORMAT_UNKNOWN;
82 0 : if ( rExt == "JPG" )
83 0 : nFormat = FORMAT_JPG;
84 0 : else if ( rExt == "PNG" )
85 0 : nFormat = FORMAT_PNG;
86 0 : else if ( rExt == "BMP" )
87 0 : nFormat = FORMAT_BMP;
88 0 : else if ( rExt == "GIF" )
89 0 : nFormat = FORMAT_GIF;
90 0 : else if ( rExt == "PBM" )
91 0 : nFormat = FORMAT_PBM;
92 0 : else if ( rExt == "PGM" )
93 0 : nFormat = FORMAT_PGM;
94 0 : else if ( rExt == "PPM" )
95 0 : nFormat = FORMAT_PPM;
96 0 : else if ( rExt == "PCT" )
97 0 : nFormat = FORMAT_PCT;
98 0 : else if ( rExt == "RAS" )
99 0 : nFormat = FORMAT_RAS;
100 0 : else if ( rExt == "TIF" )
101 0 : nFormat = FORMAT_TIF;
102 0 : else if ( rExt == "XPM" )
103 0 : nFormat = FORMAT_XPM;
104 0 : else if ( rExt == "WMF" )
105 0 : nFormat = FORMAT_WMF;
106 0 : else if ( rExt == "EMF" )
107 0 : nFormat = FORMAT_EMF;
108 0 : else if ( rExt == "EPS" )
109 0 : nFormat = FORMAT_EPS;
110 0 : else if ( rExt == "MET" )
111 0 : nFormat = FORMAT_MET;
112 0 : else if ( rExt == "SVG" )
113 0 : nFormat = FORMAT_SVG;
114 0 : else if ( rExt == "SVM" )
115 0 : nFormat = FORMAT_SVM;
116 0 : return nFormat;
117 : }
118 :
119 0 : static MapUnit GetMapUnit( sal_Int32 nUnit )
120 : {
121 0 : MapUnit aMapUnit( MAP_PIXEL );
122 0 : switch( nUnit )
123 : {
124 0 : case UNIT_INCH : aMapUnit = MAP_INCH; break;
125 0 : case UNIT_CM : aMapUnit = MAP_CM; break;
126 0 : case UNIT_MM : aMapUnit = MAP_MM; break;
127 0 : case UNIT_POINT : aMapUnit = MAP_POINT; break;
128 0 : case UNIT_PIXEL : aMapUnit = MAP_PIXEL; break;
129 : }
130 0 : return aMapUnit;
131 : }
132 :
133 0 : sal_Int32 ExportDialog::GetDefaultUnit()
134 : {
135 0 : sal_Int32 nDefaultUnit = UNIT_CM;
136 0 : switch( mrFltCallPara.eFieldUnit )
137 : {
138 : // case FUNIT_NONE :
139 : // case FUNIT_PERCENT :
140 : // case FUNIT_CUSTOM :
141 0 : default: nDefaultUnit = UNIT_CM; break;
142 :
143 : case FUNIT_MILE : // PASSTHROUGH INTENDED
144 : case FUNIT_FOOT :
145 : case FUNIT_TWIP :
146 0 : case FUNIT_PICA : nDefaultUnit = UNIT_INCH; break;
147 :
148 : case FUNIT_KM : // PASSTHROUGH INTENDED
149 : case FUNIT_M :
150 0 : case FUNIT_100TH_MM : nDefaultUnit = UNIT_CM; break;
151 :
152 0 : case FUNIT_INCH : nDefaultUnit = UNIT_INCH; break;
153 0 : case FUNIT_CM : nDefaultUnit = UNIT_CM; break;
154 0 : case FUNIT_MM : nDefaultUnit = UNIT_MM; break;
155 0 : case FUNIT_POINT : nDefaultUnit = UNIT_POINT; break;
156 : }
157 0 : return nDefaultUnit;
158 : }
159 :
160 0 : static basegfx::B2DRange GetShapeRangeForXShape( const uno::Reference< drawing::XShape >& rxShape,
161 : const uno::Reference< graphic::XPrimitiveFactory2D >& rxPrimitiveFactory2D, const uno::Sequence< beans::PropertyValue >& rViewInformation )
162 : {
163 0 : basegfx::B2DRange aShapeRange;
164 :
165 0 : const uno::Sequence< beans::PropertyValue > aParams;
166 0 : const uno::Sequence< uno::Reference< graphic::XPrimitive2D > > aPrimitiveSequence( rxPrimitiveFactory2D->createPrimitivesFromXShape( rxShape, aParams ) );
167 :
168 0 : const sal_Int32 nCount = aPrimitiveSequence.getLength();
169 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
170 : {
171 0 : const geometry::RealRectangle2D aRect( aPrimitiveSequence[ nIndex ]->getRange( rViewInformation ) );
172 0 : aShapeRange.expand( basegfx::B2DTuple( aRect.X1, aRect.Y1 ) );
173 0 : aShapeRange.expand( basegfx::B2DTuple( aRect.X2, aRect.Y2 ) );
174 : }
175 0 : return aShapeRange;
176 : }
177 :
178 0 : uno::Sequence< beans::PropertyValue > ExportDialog::GetFilterData( sal_Bool bUpdateConfig )
179 : {
180 0 : if ( bUpdateConfig )
181 : {
182 0 : sal_Int32 nUnit = mpLbSizeX->GetSelectEntryPos();
183 0 : if ( nUnit < 0 )
184 0 : nUnit = UNIT_CM;
185 :
186 0 : if ( ( mnInitialResolutionUnit == UNIT_DEFAULT ) && ( nUnit == GetDefaultUnit() ) )
187 0 : nUnit = UNIT_DEFAULT;
188 :
189 : // updating ui configuration
190 0 : if ( mbIsPixelFormat )
191 : {
192 0 : if ( nUnit > UNIT_MAX_ID )
193 0 : nUnit = UNIT_PIXEL;
194 :
195 0 : sal_Int32 nResolution = mpNfResolution->GetValue();
196 0 : if ( nResolution < 1 )
197 0 : nResolution = 96;
198 :
199 0 : mpOptionsItem->WriteInt32(OUString("PixelExportUnit"), nUnit);
200 0 : mpOptionsItem->WriteInt32(OUString("PixelExportResolution"), nResolution);
201 0 : mpOptionsItem->WriteInt32(OUString("PixelExportResolutionUnit"), mpLbResolution->GetSelectEntryPos());
202 : }
203 : else
204 : {
205 0 : if ( nUnit >= UNIT_PIXEL )
206 0 : nUnit = UNIT_CM;
207 :
208 0 : mpOptionsItem->WriteInt32(OUString("VectorExportUnit"), nUnit);
209 : }
210 : }
211 :
212 : FilterConfigItem* pFilterOptions;
213 0 : if ( bUpdateConfig )
214 0 : pFilterOptions = mpFilterOptionsItem;
215 : else
216 : {
217 0 : uno::Sequence< beans::PropertyValue > aFilterData( mpFilterOptionsItem->GetFilterData() );
218 0 : pFilterOptions = new FilterConfigItem( &aFilterData );
219 : }
220 :
221 0 : const OUString sLogicalWidth(OUString("LogicalWidth"));
222 0 : const OUString sLogicalHeight(OUString("LogicalHeight"));
223 0 : if ( mbIsPixelFormat )
224 : {
225 0 : pFilterOptions->WriteInt32(OUString("PixelWidth"), static_cast< sal_Int32 >( maSize.Width ) );
226 0 : pFilterOptions->WriteInt32(OUString("PixelHeight"), static_cast< sal_Int32 >( maSize.Height ) );
227 0 : if ( maResolution.Width && maResolution.Height )
228 : {
229 0 : const double f100thmmPerPixelX = 100000.0 / maResolution.Width;
230 0 : const double f100thmmPerPixelY = 100000.0 / maResolution.Height;
231 0 : sal_Int32 nLogicalWidth = static_cast< sal_Int32 >( f100thmmPerPixelX * maSize.Width );
232 0 : sal_Int32 nLogicalHeight= static_cast< sal_Int32 >( f100thmmPerPixelY * maSize.Height );
233 0 : if ( nLogicalWidth && nLogicalHeight )
234 : {
235 0 : pFilterOptions->WriteInt32( sLogicalWidth, nLogicalWidth );
236 0 : pFilterOptions->WriteInt32( sLogicalHeight, nLogicalHeight );
237 : }
238 : }
239 : }
240 : else
241 : {
242 0 : pFilterOptions->WriteInt32( sLogicalWidth, static_cast< sal_Int32 >( maSize.Width ) );
243 0 : pFilterOptions->WriteInt32( sLogicalHeight, static_cast< sal_Int32 >( maSize.Height ) );
244 : }
245 0 : switch ( mnFormat )
246 : {
247 : case FORMAT_JPG :
248 : {
249 0 : sal_Int32 nColor = mpLbColorDepth->GetSelectEntryPos();
250 0 : if ( nColor == 1 )
251 0 : nColor = 0;
252 : else
253 0 : nColor = 1;
254 0 : pFilterOptions->WriteInt32(OUString("ColorMode"), nColor);
255 0 : pFilterOptions->WriteInt32(OUString("Quality"), static_cast<sal_Int32>(mpSbCompression->GetThumbPos()));
256 : }
257 0 : break;
258 :
259 : case FORMAT_PNG :
260 : {
261 0 : pFilterOptions->WriteInt32(OUString("Compression"), static_cast<sal_Int32>(mpSbCompression->GetThumbPos()));
262 0 : sal_Int32 nInterlace = 0;
263 0 : if ( mpCbInterlaced->IsChecked() )
264 0 : nInterlace++;
265 0 : pFilterOptions->WriteInt32(OUString("Interlaced"), nInterlace);
266 : }
267 0 : break;
268 :
269 : case FORMAT_BMP :
270 : {
271 0 : pFilterOptions->WriteInt32(OUString("Color"), mpLbColorDepth->GetSelectEntryPos() + 1);
272 0 : pFilterOptions->WriteBool(OUString("RLE_Coding"), mpCbRLEEncoding->IsChecked());
273 : }
274 0 : break;
275 :
276 : case FORMAT_GIF :
277 : {
278 0 : sal_Int32 nValue = 0;
279 0 : if ( mpCbInterlaced->IsChecked() )
280 0 : nValue++;
281 0 : pFilterOptions->WriteInt32(OUString("Interlaced"), nValue);
282 :
283 0 : nValue = 0;
284 0 : if (mpCbSaveTransparency->IsChecked())
285 0 : nValue++;
286 0 : pFilterOptions->WriteInt32(OUString("Translucent"), nValue);
287 : }
288 0 : break;
289 :
290 : case FORMAT_PBM :
291 : case FORMAT_PGM :
292 : case FORMAT_PPM :
293 : {
294 0 : sal_Int32 nFormat = 0;
295 0 : if ( mpRbText->IsChecked() )
296 0 : nFormat++;
297 0 : pFilterOptions->WriteInt32(OUString("FileFormat"), nFormat);
298 : }
299 0 : break;
300 :
301 : case FORMAT_EPS :
302 : {
303 0 : sal_Int32 nCheck = 0;
304 0 : if ( mpCbEPSPreviewTIFF->IsChecked() )
305 0 : nCheck++;
306 0 : if ( mpCbEPSPreviewEPSI->IsChecked() )
307 0 : nCheck += 2;
308 0 : pFilterOptions->WriteInt32(OUString("Preview"), nCheck);
309 :
310 0 : nCheck = 1;
311 0 : if ( mpRbEPSLevel2->IsChecked() )
312 0 : nCheck++;
313 0 : pFilterOptions->WriteInt32(OUString("Version"), nCheck);
314 :
315 0 : nCheck = 1;
316 0 : if ( mpRbEPSColorFormat2->IsChecked() )
317 0 : nCheck++;
318 0 : pFilterOptions->WriteInt32(OUString("ColorFormat"), nCheck);
319 :
320 0 : nCheck = 1;
321 0 : if ( mpRbEPSCompressionNone->IsChecked() )
322 0 : nCheck++;
323 0 : pFilterOptions->WriteInt32(OUString("CompressionMode"), nCheck);
324 : }
325 0 : break;
326 : }
327 :
328 0 : uno::Sequence< beans::PropertyValue > aRet( pFilterOptions->GetFilterData() );
329 0 : if ( bUpdateConfig == sal_False )
330 0 : delete pFilterOptions;
331 0 : return aRet;
332 : }
333 :
334 : //
335 0 : awt::Size ExportDialog::GetOriginalSize()
336 : {
337 0 : basegfx::B2DRange aShapesRange;
338 :
339 0 : if ( mxPage.is () )
340 : {
341 0 : uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY );
342 0 : if ( xPagePropSet.is() )
343 : {
344 0 : sal_Int32 nWidth = 0;
345 0 : sal_Int32 nHeight= 0;
346 0 : com::sun::star::uno::Any aAny;
347 0 : aAny = xPagePropSet->getPropertyValue(OUString("Width"));
348 0 : aAny >>= nWidth;
349 0 : aAny = xPagePropSet->getPropertyValue(OUString("Height"));
350 0 : aAny >>= nHeight;
351 0 : aShapesRange = basegfx::B2DRange( 0, 0, nWidth, nHeight );
352 0 : }
353 : }
354 : else
355 : {
356 : uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory(
357 0 : mxMgr->createInstance(OUString("com.sun.star.comp.graphic.PrimitiveFactory2D")), uno::UNO_QUERY);
358 0 : if ( xPrimitiveFactory.is() )
359 : {
360 0 : basegfx::B2DHomMatrix aViewTransformation( Application::GetDefaultDevice()->GetViewTransformation() );
361 0 : com::sun::star::geometry::AffineMatrix2D aTransformation;
362 0 : aTransformation.m00 = aViewTransformation.get(0,0);
363 0 : aTransformation.m01 = aViewTransformation.get(0,1);
364 0 : aTransformation.m02 = aViewTransformation.get(0,2);
365 0 : aTransformation.m10 = aViewTransformation.get(1,0);
366 0 : aTransformation.m11 = aViewTransformation.get(1,1);
367 0 : aTransformation.m12 = aViewTransformation.get(1,2);
368 :
369 0 : const OUString sViewTransformation( RTL_CONSTASCII_USTRINGPARAM( "ViewTransformation" ) );
370 0 : uno::Sequence< beans::PropertyValue > aViewInformation( 1 );
371 0 : aViewInformation[ 0 ].Value <<= aTransformation;
372 0 : aViewInformation[ 0 ].Name = sViewTransformation;
373 :
374 0 : if ( mxShape.is() )
375 0 : aShapesRange = GetShapeRangeForXShape( mxShape, xPrimitiveFactory, aViewInformation );
376 0 : else if ( mxShapes.is() )
377 : {
378 0 : const sal_Int32 nCount = mxShapes->getCount();
379 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
380 : {
381 0 : uno::Reference< drawing::XShape > xShape;
382 0 : mxShapes->getByIndex( nIndex ) >>= xShape;
383 0 : aShapesRange.expand( GetShapeRangeForXShape( xShape, xPrimitiveFactory, aViewInformation ) );
384 0 : }
385 0 : }
386 0 : }
387 : }
388 0 : return awt::Size( static_cast<sal_Int32>(aShapesRange.getWidth()), static_cast<sal_Int32>(aShapesRange.getHeight()) );
389 : }
390 :
391 0 : void ExportDialog::GetGraphicSource()
392 : {
393 0 : if ( mxSourceDocument.is() )
394 : {
395 0 : uno::Reference< frame::XModel > xModel( mxSourceDocument, uno::UNO_QUERY );
396 0 : if ( xModel.is() )
397 : {
398 0 : uno::Reference< frame::XController > xController( xModel->getCurrentController() );
399 0 : if ( xController.is() )
400 : {
401 0 : if ( mbExportSelection ) // check if there is a selection
402 : {
403 0 : uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY );
404 0 : if ( xSelectionSupplier.is() )
405 : {
406 0 : uno::Any aAny( xSelectionSupplier->getSelection() );
407 0 : if ( ! ( aAny >>= mxShapes ) )
408 0 : aAny >>= mxShape;
409 0 : }
410 : }
411 0 : if ( !mxShape.is() && !mxShapes.is() )
412 : {
413 0 : uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY );
414 0 : if ( xDrawView.is() )
415 : {
416 0 : uno::Reference< drawing::XDrawPage > xCurrentPage( xDrawView->getCurrentPage() );
417 0 : if ( xCurrentPage.is() )
418 : {
419 0 : mxPage = xCurrentPage; // exporting whole page
420 0 : }
421 0 : }
422 : }
423 0 : }
424 0 : }
425 : }
426 0 : }
427 :
428 0 : sal_Bool ExportDialog::GetGraphicStream()
429 : {
430 0 : sal_Bool bRet = sal_False;
431 :
432 0 : if ( !IsTempExportAvailable() )
433 : {
434 0 : delete mpTempStream, mpTempStream = new SvMemoryStream();
435 0 : maBitmap = Bitmap();
436 0 : return bRet;
437 : }
438 :
439 0 : sal_Bool bRecreateOutputStream = mpTempStream->Tell() == 0;
440 :
441 0 : static uno::Sequence< beans::PropertyValue > aOldFilterData;
442 0 : uno::Sequence< beans::PropertyValue > aNewFilterData( GetFilterData( sal_False ) );
443 0 : if ( aOldFilterData != aNewFilterData )
444 : {
445 0 : aOldFilterData = aNewFilterData;
446 0 : bRecreateOutputStream = sal_True;
447 : }
448 : try
449 : {
450 0 : if ( bRecreateOutputStream )
451 : {
452 0 : delete mpTempStream, mpTempStream = new SvMemoryStream();
453 0 : maBitmap = Bitmap();
454 :
455 0 : uno::Reference < io::XStream > xStream( new utl::OStreamWrapper( *mpTempStream ) );
456 0 : uno::Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
457 :
458 : uno::Reference< document::XExporter > xGraphicExporter(
459 0 : mxMgr->createInstance(OUString("com.sun.star.drawing.GraphicExportFilter")), uno::UNO_QUERY_THROW);
460 0 : uno::Reference< document::XFilter > xFilter( xGraphicExporter, uno::UNO_QUERY_THROW );
461 :
462 0 : sal_Int32 nProperties = 2;
463 0 : uno::Sequence< beans::PropertyValue > aFilterData( nProperties );
464 :
465 :
466 0 : OUString sFormat( maExt );
467 0 : uno::Sequence< beans::PropertyValue > aDescriptor( 3 );
468 0 : aDescriptor[0].Name = OUString("OutputStream");
469 0 : aDescriptor[0].Value <<= xOutputStream;
470 0 : aDescriptor[1].Name = OUString("FilterName");
471 0 : aDescriptor[1].Value <<= sFormat;
472 0 : aDescriptor[2].Name = OUString("FilterData");
473 0 : aDescriptor[2].Value <<= aNewFilterData;
474 :
475 0 : uno::Reference< lang::XComponent > xSourceDoc;
476 0 : if ( mxPage.is() )
477 0 : xSourceDoc = uno::Reference< lang::XComponent >( mxPage, uno::UNO_QUERY_THROW );
478 0 : else if ( mxShapes.is() )
479 0 : xSourceDoc = uno::Reference< lang::XComponent >( mxShapes, uno::UNO_QUERY_THROW );
480 0 : else if ( mxShape.is() )
481 0 : xSourceDoc = uno::Reference< lang::XComponent >( mxShape, uno::UNO_QUERY_THROW );
482 0 : if ( xSourceDoc.is() )
483 : {
484 0 : xGraphicExporter->setSourceDocument( xSourceDoc );
485 0 : xFilter->filter( aDescriptor );
486 0 : bRet = sal_True;
487 :
488 0 : if ( mnFormat == FORMAT_JPG )
489 : {
490 0 : mpTempStream->Seek( STREAM_SEEK_TO_BEGIN );
491 0 : maBitmap = GetGraphicBitmap( *mpTempStream );
492 0 : mpTempStream->Seek( STREAM_SEEK_TO_END );
493 : }
494 0 : }
495 : }
496 : else
497 0 : bRet = sal_True;
498 : }
499 0 : catch( uno::Exception& )
500 : {
501 :
502 : // ups
503 :
504 : }
505 0 : return bRet;
506 : }
507 :
508 0 : Bitmap ExportDialog::GetGraphicBitmap( SvStream& rInputStream )
509 : {
510 0 : Bitmap aRet;
511 0 : Graphic aGraphic;
512 0 : GraphicFilter aFilter( sal_False );
513 0 : if ( aFilter.ImportGraphic( aGraphic, String(), rInputStream, GRFILTER_FORMAT_NOTFOUND, NULL, 0, static_cast<com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*>(NULL), NULL ) == GRFILTER_OK )
514 : {
515 0 : aRet = aGraphic.GetBitmap();
516 : }
517 0 : return aRet;
518 : }
519 :
520 0 : sal_uInt32 ExportDialog::GetRawFileSize() const
521 : {
522 0 : sal_uInt64 nRawFileSize = 0;
523 0 : if ( mbIsPixelFormat )
524 : {
525 0 : sal_Int32 nBitsPerPixel = 24;
526 0 : String aEntry( mpLbColorDepth->GetSelectEntry() );
527 0 : if ( ms1BitTreshold == aEntry )
528 0 : nBitsPerPixel = 1;
529 0 : else if ( ms1BitDithered == aEntry )
530 0 : nBitsPerPixel = 1;
531 0 : else if ( ms4BitGrayscale == aEntry )
532 0 : nBitsPerPixel = 4;
533 0 : else if ( ms4BitColorPalette == aEntry )
534 0 : nBitsPerPixel = 8;
535 0 : else if ( ms8BitGrayscale == aEntry )
536 0 : nBitsPerPixel = 8;
537 0 : else if ( ms8BitColorPalette == aEntry )
538 0 : nBitsPerPixel = 8;
539 0 : else if ( ms24BitColor == aEntry )
540 0 : nBitsPerPixel = 24;
541 :
542 0 : if ( mbIsPixelFormat )
543 : {
544 0 : nRawFileSize = ( maSize.Width * nBitsPerPixel + 7 ) &~ 7; // rounding up to 8 bits
545 0 : nRawFileSize /= 8; // in bytes
546 0 : nRawFileSize *= maSize.Height;
547 : }
548 0 : if ( nRawFileSize > SAL_MAX_UINT32 )
549 0 : nRawFileSize = 0;
550 : }
551 0 : return static_cast< sal_uInt32 >( nRawFileSize );
552 : }
553 :
554 : // checks if the source dimension/resolution is not too big
555 : // to determine the exact graphic output size and preview for jpg
556 0 : sal_Bool ExportDialog::IsTempExportAvailable() const
557 : {
558 0 : return GetRawFileSize() < static_cast< sal_uInt32 >( mnMaxFilesizeForRealtimePreview );
559 : }
560 :
561 0 : ExportDialog::ExportDialog(FltCallDialogParameter& rPara,
562 : const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > rxMgr,
563 : const com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rxSourceDocument,
564 : sal_Bool bExportSelection, sal_Bool bIsPixelFormat)
565 : : ModalDialog(rPara.pWindow, "GraphicExportDialog", "svt/ui/graphicexport.ui")
566 : , mrFltCallPara(rPara)
567 : , mxMgr(rxMgr)
568 : , mxSourceDocument(rxSourceDocument)
569 : , mpSbCompression(NULL)
570 : , mpNfCompression(NULL)
571 : , msEstimatedSizePix1(SVT_RESSTR(STR_SVT_ESTIMATED_SIZE_PIX_1))
572 : , msEstimatedSizePix2(SVT_RESSTR(STR_SVT_ESTIMATED_SIZE_PIX_2))
573 : , msEstimatedSizeVec(SVT_RESSTR(STR_SVT_ESTIMATED_SIZE_VEC))
574 : , ms1BitTreshold(SVT_RESSTR(STR_SVT_1BIT_THRESHOLD))
575 : , ms1BitDithered(SVT_RESSTR(STR_SVT_1BIT_DITHERED))
576 : , ms4BitGrayscale(SVT_RESSTR(STR_SVT_4BIT_GRAYSCALE))
577 : , ms4BitColorPalette(SVT_RESSTR(STR_SVT_4BIT_COLOR_PALETTE))
578 : , ms8BitGrayscale(SVT_RESSTR(STR_SVT_8BIT_GRAYSCALE))
579 : , ms8BitColorPalette(SVT_RESSTR(STR_SVT_8BIT_COLOR_PALETTE))
580 : , ms24BitColor(SVT_RESSTR(STR_SVT_24BIT_TRUE_COLOR))
581 : , maExt(rPara.aFilterExt)
582 : , mnFormat(FORMAT_UNKNOWN)
583 : , mnMaxFilesizeForRealtimePreview(0)
584 0 : , mpTempStream(new SvMemoryStream())
585 : , maOriginalSize(awt::Size(0, 0))
586 : , mbIsPixelFormat(bIsPixelFormat)
587 : , mbExportSelection(bExportSelection)
588 0 : , mbPreserveAspectRatio(sal_True)
589 : {
590 0 : get(mpMfSizeX, "widthmf-nospin");
591 0 : get(mpMfSizeY, "heightmf-nospin");
592 0 : get(mpLbSizeX, "widthlb");
593 0 : get(mpFtResolution, "resolutionft");
594 0 : get(mpNfResolution, "resolutionmf-nospin");
595 0 : get(mpLbResolution, "resolutionlb");
596 :
597 0 : get(mpColorDepth, "colordepth");
598 0 : get(mpLbColorDepth, "colordepthlb");
599 :
600 0 : get(mpJPGQuality, "jpgquality");
601 0 : get(mpPNGCompression, "pngcompression");
602 :
603 0 : get(mpBMPCompression, "bmpcompression");
604 0 : get(mpCbRLEEncoding, "rlecb");
605 :
606 0 : get(mpMode, "mode");
607 0 : get(mpCbInterlaced, "interlacedcb");
608 :
609 0 : get(mpDrawingObjects, "drawingobjects");
610 0 : get(mpCbSaveTransparency, "savetransparencycb");
611 :
612 0 : get(mpEncoding, "encoding");
613 0 : get(mpRbBinary, "binarycb");
614 0 : get(mpRbText, "textcb");
615 :
616 0 : get(mpEPSGrid, "epsgrid");
617 0 : get(mpCbEPSPreviewTIFF, "tiffpreviewcb");
618 0 : get(mpCbEPSPreviewEPSI, "epsipreviewcb");
619 0 : get(mpRbEPSLevel1, "level1rb");
620 0 : get(mpRbEPSLevel2, "level2rb");
621 0 : get(mpRbEPSColorFormat1, "color1rb");
622 0 : get(mpRbEPSColorFormat2, "color2rb");
623 0 : get(mpRbEPSCompressionLZW, "compresslzw");
624 0 : get(mpRbEPSCompressionNone, "compressnone");
625 :
626 0 : GetGraphicSource();
627 :
628 0 : get(mpInfo, "information");
629 0 : get(mpFtEstimatedSize, "estsizeft");;
630 :
631 0 : get(mpBtnOK, "ok");
632 :
633 0 : maExt.ToUpperAscii();
634 :
635 0 : String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Export/" ) );
636 0 : mpOptionsItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
637 0 : aFilterConfigPath.Append( maExt );
638 0 : mpFilterOptionsItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
639 :
640 : mnInitialResolutionUnit = mbIsPixelFormat
641 0 : ? mpOptionsItem->ReadInt32(OUString("PixelExportUnit"), UNIT_DEFAULT)
642 0 : : mpOptionsItem->ReadInt32(OUString( "VectorExportUnit"), UNIT_DEFAULT);
643 :
644 0 : mnMaxFilesizeForRealtimePreview = mpOptionsItem->ReadInt32(OUString("MaxFilesizeForRealtimePreview"), 0);
645 0 : mpFtEstimatedSize->SetText(OUString(" \n "));
646 :
647 0 : String aTitle(maExt);
648 0 : aTitle += GetText();
649 0 : SetText(aTitle);
650 :
651 0 : mnFormat = GetFilterFormat( maExt );
652 :
653 0 : Size aResolution( Application::GetDefaultDevice()->LogicToPixel( Size( 100, 100 ), MAP_CM ) );
654 0 : maResolution.Width = aResolution.Width();
655 0 : maResolution.Height= aResolution.Height();
656 0 : maOriginalSize = GetOriginalSize();
657 0 : if ( bIsPixelFormat )
658 : {
659 0 : double fPixelsPer100thmm = static_cast< double >( maResolution.Width ) / 100000.0;
660 : maSize = awt::Size( static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Width ) + 0.5 ),
661 0 : static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Height ) + 0.5 ) );
662 : }
663 : else
664 : {
665 0 : maSize = maOriginalSize;
666 : }
667 :
668 0 : setupControls();
669 :
670 : // Size
671 0 : mpLbSizeX->SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
672 :
673 0 : if (mpSbCompression)
674 0 : mpSbCompression->SetScrollHdl(LINK(this, ExportDialog, SbCompressionUpdateHdl));
675 0 : if (mpNfCompression)
676 0 : mpNfCompression->SetModifyHdl(LINK(this, ExportDialog, UpdateHdl));
677 :
678 0 : mpMfSizeX->SetModifyHdl( LINK( this, ExportDialog, UpdateHdlMtfSizeX ) );
679 0 : mpMfSizeY->SetModifyHdl( LINK( this, ExportDialog, UpdateHdlMtfSizeY ) );
680 :
681 0 : mpNfResolution->SetModifyHdl( LINK( this, ExportDialog, UpdateHdlNfResolution ) );
682 0 : mpLbResolution->SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
683 :
684 0 : mpLbColorDepth->SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
685 :
686 0 : mpCbInterlaced->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
687 :
688 0 : mpCbSaveTransparency->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
689 :
690 0 : mpCbEPSPreviewTIFF->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
691 0 : mpCbEPSPreviewEPSI->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
692 :
693 0 : mpRbEPSCompressionLZW->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
694 0 : mpRbEPSCompressionNone->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
695 :
696 0 : mpRbBinary->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
697 0 : mpRbText->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
698 :
699 : // BMP
700 0 : mpCbRLEEncoding->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
701 :
702 : // EPS
703 0 : mpRbEPSLevel1->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
704 0 : mpRbEPSLevel2->SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
705 :
706 0 : mpBtnOK->SetClickHdl( LINK( this, ExportDialog, OK ) );
707 :
708 0 : updateControls();
709 0 : }
710 :
711 0 : void ExportDialog::setupSizeControls()
712 : {
713 0 : sal_Int32 nUnit = mnInitialResolutionUnit;
714 0 : if (nUnit == UNIT_DEFAULT)
715 0 : nUnit = GetDefaultUnit();
716 :
717 0 : if (!mbIsPixelFormat)
718 : {
719 0 : mpFtResolution->Hide();
720 0 : mpNfResolution->Hide();
721 0 : mpLbResolution->Hide();
722 0 : mpLbSizeX->RemoveEntry( UNIT_PIXEL ); // removing pixel
723 0 : if ( nUnit >= UNIT_PIXEL )
724 0 : nUnit = UNIT_CM;
725 : }
726 0 : else if ( nUnit > UNIT_MAX_ID )
727 0 : nUnit = UNIT_PIXEL;
728 0 : if ( nUnit < 0 )
729 0 : nUnit = UNIT_CM;
730 0 : mpLbSizeX->SelectEntryPos( static_cast< sal_uInt16 >( nUnit ) );
731 :
732 0 : if ( mbIsPixelFormat ) // TODO: (metafileresolutionsupport) should be supported for vector formats also... this makes
733 : { // sense eg for bitmap fillings in metafiles, to preserve high dpi output
734 : // (atm without special vector support the bitmaps are rendered with 96dpi)
735 0 : sal_Int32 nResolution = mpOptionsItem->ReadInt32(OUString("PixelExportResolution"), 96);
736 0 : if ( nResolution < 1 )
737 0 : nResolution = 96;
738 0 : mpNfResolution->SetValue( nResolution );
739 :
740 0 : sal_Int32 nResolutionUnit = mpOptionsItem->ReadInt32(OUString("PixelExportResolutionUnit"), 1);
741 0 : if ( ( nResolutionUnit < 0 ) || ( nResolutionUnit > 2 ) )
742 0 : nResolutionUnit = 1;
743 0 : mpLbResolution->SelectEntryPos( static_cast< sal_uInt16 >( nResolutionUnit ) );
744 : }
745 0 : }
746 :
747 0 : void ExportDialog::createFilterOptions()
748 : {
749 0 : switch( mnFormat )
750 : {
751 : case FORMAT_JPG :
752 : {
753 0 : sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(OUString("ColorMode"), 0);
754 0 : if ( nColor == 1 )
755 0 : nColor = 0;
756 : else
757 0 : nColor = 1;
758 0 : mpLbColorDepth->InsertEntry( ms8BitGrayscale );
759 0 : mpLbColorDepth->InsertEntry( ms24BitColor );
760 0 : mpLbColorDepth->SelectEntryPos( nColor );
761 0 : mpColorDepth->Show();
762 :
763 : // Quality
764 0 : mpJPGQuality->Show();
765 0 : sal_Int32 nQuality = mpFilterOptionsItem->ReadInt32(OUString("Quality"), 75);
766 0 : if ((nQuality < 1 ) || (nQuality > 100))
767 0 : nQuality = 75;
768 0 : get(mpSbCompression, "compressionjpgsb");
769 0 : get(mpNfCompression, "compressionjpgnf-nospin");
770 0 : mpSbCompression->SetRangeMin( 1 );
771 0 : mpSbCompression->SetRangeMax( 100 );
772 0 : mpNfCompression->SetMin( 1 );
773 0 : mpNfCompression->SetMax( 100 );
774 0 : mpNfCompression->SetValue( nQuality );
775 0 : mpNfCompression->SetStrictFormat( sal_True );
776 : }
777 0 : break;
778 : case FORMAT_PNG :
779 : {
780 : // Compression 1..9
781 0 : mpPNGCompression->Show();
782 0 : sal_Int32 nCompression = mpFilterOptionsItem->ReadInt32(OUString("Compression"), 6);
783 0 : if ( ( nCompression < 1 ) || ( nCompression > 9 ) )
784 0 : nCompression = 6;
785 0 : get(mpSbCompression, "compressionpngsb");
786 0 : get(mpNfCompression, "compressionpngnf-nospin");
787 0 : mpSbCompression->SetRangeMin( 1 );
788 0 : mpSbCompression->SetRangeMax( 9 );
789 0 : mpNfCompression->SetMin( 1 );
790 0 : mpNfCompression->SetMax( 9 );
791 0 : mpNfCompression->SetValue( 9 );
792 0 : mpNfCompression->SetStrictFormat( sal_True );
793 :
794 : // Interlaced
795 0 : mpMode->Show();
796 0 : mpCbInterlaced->Check( mpFilterOptionsItem->ReadInt32(OUString("Interlaced"), 0) != 0);
797 : }
798 0 : break;
799 : case FORMAT_BMP :
800 : {
801 0 : sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(OUString("Color"), 0);
802 0 : if ( nColor == 0 )
803 0 : nColor = 6;
804 : else
805 0 : nColor--;
806 0 : mpLbColorDepth->InsertEntry( ms1BitTreshold );
807 0 : mpLbColorDepth->InsertEntry( ms1BitDithered );
808 0 : mpLbColorDepth->InsertEntry( ms4BitGrayscale );
809 0 : mpLbColorDepth->InsertEntry( ms4BitColorPalette );
810 0 : mpLbColorDepth->InsertEntry( ms8BitGrayscale );
811 0 : mpLbColorDepth->InsertEntry( ms8BitColorPalette );
812 0 : mpLbColorDepth->InsertEntry( ms24BitColor );
813 0 : mpLbColorDepth->SelectEntryPos( nColor );
814 0 : mpColorDepth->Show();
815 :
816 : // RLE coding
817 0 : mpBMPCompression->Show();
818 0 : mpCbRLEEncoding->Check(mpFilterOptionsItem->ReadBool(OUString("RLE_Coding"), sal_True));
819 : }
820 0 : break;
821 : case FORMAT_GIF :
822 : {
823 0 : mpMode->Show();
824 0 : mpCbInterlaced->Check(mpFilterOptionsItem->ReadInt32(OUString("Interlaced"), 1) != 0);
825 :
826 0 : mpDrawingObjects->Show();
827 0 : mpCbSaveTransparency->Check(mpFilterOptionsItem->ReadInt32(OUString("Translucent"), 1) != 0);
828 : }
829 0 : break;
830 : case FORMAT_PBM :
831 : case FORMAT_PGM :
832 : case FORMAT_PPM :
833 : {
834 : // RB Binary / Text
835 0 : mpEncoding->Show();
836 0 : sal_Int32 nFormat = mpFilterOptionsItem->ReadInt32(OUString("FileFormat"), 1);
837 0 : mpRbBinary->Check( nFormat == 0 );
838 0 : mpRbText->Check( nFormat != 0 );
839 : }
840 0 : break;
841 : case FORMAT_EPS :
842 : {
843 0 : mpEPSGrid->Show();
844 :
845 0 : sal_Int32 nPreview = mpFilterOptionsItem->ReadInt32(OUString("Preview"), 0);
846 0 : sal_Int32 nVersion = mpFilterOptionsItem->ReadInt32(OUString("Version"), 2);
847 0 : sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(OUString("ColorFormat"), 0);
848 0 : sal_Int32 nCompr = mpFilterOptionsItem->ReadInt32(OUString("CompressionMode"), 2);
849 :
850 0 : mpFilterOptionsItem->ReadInt32(OUString("TextMode"), 0);
851 :
852 0 : mpCbEPSPreviewTIFF->Check( ( nPreview & 1 ) != 0 );
853 0 : mpCbEPSPreviewEPSI->Check( ( nPreview & 2 ) != 0 );
854 :
855 0 : mpRbEPSLevel1->Check( nVersion == 1 );
856 0 : mpRbEPSLevel2->Check( nVersion == 2 );
857 :
858 0 : mpRbEPSColorFormat1->Check( nColor == 1 );
859 0 : mpRbEPSColorFormat2->Check( nColor != 1 );
860 :
861 0 : mpRbEPSCompressionLZW->Check( nCompr == 1 );
862 0 : mpRbEPSCompressionNone->Check( nCompr != 1 );
863 : }
864 0 : break;
865 : }
866 0 : }
867 :
868 0 : void ExportDialog::setupControls()
869 : {
870 0 : setupSizeControls();
871 0 : createFilterOptions();
872 :
873 0 : if (mnMaxFilesizeForRealtimePreview || mbIsPixelFormat)
874 0 : mpInfo->Show();
875 0 : }
876 :
877 0 : static OUString ImpValueOfInKB( const sal_Int64& rVal )
878 : {
879 0 : double fVal( static_cast<double>( rVal ) );
880 0 : fVal /= ( 1 << 10 );
881 0 : fVal += 0.05;
882 0 : OUStringBuffer aVal( OUString::valueOf( fVal ) );
883 0 : sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
884 0 : if ( nX > 0 )
885 0 : aVal.setLength( nX + 2 );
886 0 : return aVal.makeStringAndClear();
887 : }
888 :
889 0 : void ExportDialog::updateControls()
890 : {
891 0 : GetGraphicStream();
892 :
893 : // Size Controls
894 0 : if ( !mbIsPixelFormat )
895 : {
896 0 : awt::Size aSize100thmm( maSize );
897 : Size aSize( LogicToLogic( Size( aSize100thmm.Width * 100, aSize100thmm.Height * 100 ), MAP_100TH_MM,
898 0 : MapMode( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ) ) ) );
899 0 : mpMfSizeX->SetValue( aSize.Width() );
900 0 : mpMfSizeY->SetValue( aSize.Height() );
901 : }
902 : else
903 : {
904 0 : MapUnit aMapUnit( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ) );
905 0 : if ( aMapUnit == MAP_PIXEL )
906 : { // calculating pixel count via resolution and original graphic size
907 0 : mpMfSizeX->SetDecimalDigits( 0 );
908 0 : mpMfSizeY->SetDecimalDigits( 0 );
909 0 : mpMfSizeX->SetValue( maSize.Width );
910 0 : mpMfSizeY->SetValue( maSize.Height );
911 : }
912 : else
913 : {
914 0 : mpMfSizeX->SetDecimalDigits( 2 );
915 0 : mpMfSizeY->SetDecimalDigits( 2 );
916 : double fRatio;
917 0 : switch( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ) )
918 : {
919 0 : case MAP_INCH : fRatio = static_cast< double >( maResolution.Width ) * 0.0254; break;
920 0 : case MAP_MM : fRatio = static_cast< double >( maResolution.Width ) * 0.001; break;
921 0 : case MAP_POINT :fRatio = ( static_cast< double >( maResolution.Width ) * 0.0254 ) / 72.0; break;
922 : default:
923 0 : case MAP_CM : fRatio = static_cast< double >( maResolution.Width ) * 0.01; break;
924 : }
925 0 : mpMfSizeX->SetValue( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Width * 100 ) / fRatio ) + 0.5 ) );
926 0 : mpMfSizeY->SetValue( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Height * 100 ) / fRatio ) + 0.5 ) );
927 : }
928 : }
929 0 : sal_Int32 nResolution = 0;
930 0 : switch( mpLbResolution->GetSelectEntryPos() )
931 : {
932 0 : case 0 : nResolution = maResolution.Width / 100; break; // pixels / cm
933 0 : case 2 : nResolution = maResolution.Width; break; // pixels / meter
934 : default:
935 0 : case 1 : nResolution = static_cast< sal_Int32 >(maResolution.Width * 0.0254); break; // pixels / inch
936 : }
937 0 : mpNfResolution->SetValue( nResolution );
938 :
939 0 : if (mpSbCompression && mpSbCompression->IsVisible() && mpNfCompression)
940 0 : mpSbCompression->SetThumbPos(mpNfCompression->GetValue());
941 :
942 : // updating estimated size
943 0 : sal_Int64 nRealFileSize( mpTempStream->Tell() );
944 0 : if ( mbIsPixelFormat )
945 : {
946 0 : String aEst( nRealFileSize ? msEstimatedSizePix2 : msEstimatedSizePix1 );
947 0 : sal_Int64 nRawFileSize( GetRawFileSize() );
948 0 : xub_StrLen nInd = aEst.Search( '%' );
949 0 : aEst.Replace( nInd, 2, ImpValueOfInKB( nRawFileSize ) );
950 :
951 0 : if ( nRealFileSize )
952 : {
953 0 : nInd = aEst.Search( '%', nInd );
954 0 : aEst.Replace( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
955 : }
956 0 : mpFtEstimatedSize->SetText( aEst );
957 : }
958 : else
959 : {
960 0 : if ( mnMaxFilesizeForRealtimePreview )
961 : {
962 0 : String aEst( msEstimatedSizeVec );
963 0 : xub_StrLen nInd = aEst.Search( '%', 0 );
964 0 : aEst.Replace( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
965 0 : mpFtEstimatedSize->SetText( aEst );
966 : }
967 : }
968 :
969 : // EPS
970 0 : if ( mpRbEPSLevel1->IsVisible() )
971 : {
972 0 : sal_Bool bEnabled = mpRbEPSLevel1->IsChecked() == sal_False;
973 0 : mpRbEPSColorFormat1->Enable( bEnabled );
974 0 : mpRbEPSColorFormat2->Enable( bEnabled );
975 0 : mpRbEPSCompressionLZW->Enable( bEnabled );
976 0 : mpRbEPSCompressionNone->Enable( bEnabled );
977 : }
978 0 : }
979 :
980 0 : ExportDialog::~ExportDialog()
981 : {
982 0 : delete mpFilterOptionsItem;
983 0 : delete mpOptionsItem;
984 0 : }
985 :
986 :
987 : /*************************************************************************
988 : |*
989 : |* Speichert eingestellte Werte in ini-Datei
990 : |*
991 : \************************************************************************/
992 0 : IMPL_LINK_NOARG(ExportDialog, UpdateHdl)
993 : {
994 0 : updateControls();
995 0 : return 0;
996 : }
997 :
998 0 : IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeX)
999 : {
1000 0 : double fRatio = static_cast< double >( maOriginalSize.Height ) / maOriginalSize.Width;
1001 :
1002 0 : if ( mbIsPixelFormat )
1003 : {
1004 0 : switch( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ) )
1005 : {
1006 0 : case MAP_INCH : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * mpMfSizeX->GetValue() / 100.0 + 0.5 ); break;
1007 0 : case MAP_CM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.01 * mpMfSizeX->GetValue() / 100.0 + 0.5 ); break;
1008 0 : case MAP_MM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.001 * mpMfSizeX->GetValue() / 100.0 + 0.5 ); break;
1009 0 : case MAP_POINT : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * mpMfSizeX->GetValue() / 100.0 * 72 + 0.5 ); break;
1010 : default:
1011 0 : case MAP_PIXEL : maSize.Width = mpMfSizeX->GetValue(); break;
1012 : }
1013 0 : maSize.Height = static_cast< sal_Int32 >( fRatio * maSize.Width + 0.5 );
1014 : }
1015 : else
1016 : {
1017 0 : Fraction aFract( 1, 100 );
1018 0 : sal_Int32 nWidth = mpMfSizeX->GetValue();
1019 0 : sal_Int32 nHeight= static_cast< sal_Int32 >( nWidth * fRatio );
1020 0 : const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) );
1021 0 : MapMode aSourceMapMode( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ),Point(), aFract, aFract );
1022 0 : Size aDest( LogicToLogic( aSource, aSourceMapMode, MAP_100TH_MM ) );
1023 :
1024 0 : maSize.Width = aDest.Width();
1025 0 : if ( mbPreserveAspectRatio )
1026 0 : maSize.Height = aDest.Height();
1027 : }
1028 0 : updateControls();
1029 0 : return 0;
1030 : }
1031 :
1032 0 : IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeY)
1033 : {
1034 0 : double fRatio = static_cast< double >( maOriginalSize.Width ) / maOriginalSize.Height;
1035 :
1036 0 : if ( mbIsPixelFormat )
1037 : {
1038 0 : switch( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ) )
1039 : {
1040 0 : case MAP_INCH : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * mpMfSizeY->GetValue() / 100.0 + 0.5 ); break;
1041 0 : case MAP_CM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.01 * mpMfSizeY->GetValue() / 100.0 + 0.5 ); break;
1042 0 : case MAP_MM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.001 * mpMfSizeY->GetValue() / 100.0 + 0.5 ); break;
1043 0 : case MAP_POINT : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * mpMfSizeY->GetValue() / 100.0 * 72 + 0.5 ); break;
1044 : default:
1045 0 : case MAP_PIXEL : maSize.Height = mpMfSizeY->GetValue(); break;
1046 : }
1047 0 : maSize.Width = static_cast< sal_Int32 >( fRatio * maSize.Height + 0.5 );
1048 : }
1049 : else
1050 : {
1051 0 : Fraction aFract( 1, 100 );
1052 0 : sal_Int32 nHeight= mpMfSizeY->GetValue();
1053 0 : sal_Int32 nWidth = static_cast< sal_Int32 >( nHeight * fRatio );
1054 0 : const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) );
1055 0 : MapMode aSourceMapMode( GetMapUnit( mpLbSizeX->GetSelectEntryPos() ),Point(), aFract, aFract );
1056 0 : Size aDest( LogicToLogic( aSource, aSourceMapMode, MAP_100TH_MM ) );
1057 :
1058 0 : maSize.Height = aDest.Height();
1059 0 : if ( mbPreserveAspectRatio )
1060 0 : maSize.Width = aDest.Width();
1061 : }
1062 0 : updateControls();
1063 0 : return 0;
1064 : }
1065 :
1066 0 : IMPL_LINK_NOARG(ExportDialog, UpdateHdlNfResolution)
1067 : {
1068 0 : sal_Int32 nResolution = mpNfResolution->GetValue();
1069 0 : if ( mpLbResolution->GetSelectEntryPos() == 0 ) // pixels / cm
1070 0 : nResolution *= 100;
1071 0 : else if ( mpLbResolution->GetSelectEntryPos() == 1 ) // pixels / inch
1072 0 : nResolution = static_cast< sal_Int32 >( ( ( static_cast< double >( nResolution ) + 0.5 ) / 0.0254 ) );
1073 0 : maResolution.Width = nResolution;
1074 0 : maResolution.Height= nResolution;
1075 :
1076 0 : updateControls();
1077 0 : return 0;
1078 : }
1079 :
1080 0 : IMPL_LINK_NOARG(ExportDialog, SbCompressionUpdateHdl)
1081 : {
1082 0 : mpNfCompression->SetValue( mpSbCompression->GetThumbPos() );
1083 0 : updateControls();
1084 0 : return 0;
1085 : }
1086 :
1087 0 : IMPL_LINK_NOARG(ExportDialog, OK)
1088 : {
1089 : // writing config parameter
1090 :
1091 :
1092 0 : mrFltCallPara.aFilterData = GetFilterData( sal_True );
1093 0 : EndDialog( RET_OK );
1094 :
1095 0 : return 0;
1096 108 : }
1097 :
1098 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|