1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26
27 #ifndef GCC
28 # pragma hdrstop
29 #endif
30
31 #include <tools/ref.hxx>
32 #include <tools/stream.hxx>
33 #include <svtools/filter.hxx>
34 #include <svtools/FilterConfigItem.hxx>
35 #include <com/sun/star/io/XStream.hpp>
36 #include <com/sun/star/awt/Size.hpp>
37 #include <com/sun/star/view/XSelectionSupplier.hpp>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/frame/XController.hpp>
40 #include <com/sun/star/drawing/XDrawView.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/graphic/XPrimitiveFactory2D.hpp>
43 #include <com/sun/star/geometry/AffineMatrix2D.hpp>
44 #include <com/sun/star/document/XExporter.hpp>
45 #include <com/sun/star/document/XFilter.hpp>
46 #include <unotools/streamwrap.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/outdev.hxx>
50 #include <vcl/graph.hxx>
51 #include <rtl/ustrbuf.hxx>
52 #include <basegfx/matrix/b2dhommatrix.hxx>
53 #include "exportdialog.hxx"
54 #include "exportdialog.hrc"
55
56 #define FORMAT_UNKNOWN 0
57 #define FORMAT_JPG 1
58 #define FORMAT_PNG 2
59 #define FORMAT_BMP 3
60 #define FORMAT_GIF 4
61 #define FORMAT_PBM 5
62 #define FORMAT_PGM 6
63 #define FORMAT_PPM 7
64 #define FORMAT_PCT 8
65 #define FORMAT_RAS 9
66 #define FORMAT_TIF 10
67 #define FORMAT_XPM 11
68 #define FORMAT_WMF 12
69 #define FORMAT_EMF 13
70 #define FORMAT_EPS 14
71 #define FORMAT_MET 15
72 #define FORMAT_SVG 16
73 #define FORMAT_SVM 17
74
75 #define UNIT_DEFAULT -1
76 #define UNIT_INCH 0
77 #define UNIT_CM 1
78 #define UNIT_MM 2
79 #define UNIT_POINT 3
80 #define UNIT_PIXEL 4
81 #define UNIT_MAX_ID UNIT_PIXEL
82
83 using namespace ::com::sun::star;
84
GetFilterFormat(String & rExt)85 static sal_Int16 GetFilterFormat( String& rExt )
86 {
87 sal_Int16 nFormat = FORMAT_UNKNOWN;
88 ByteString aExt( rExt, RTL_TEXTENCODING_UTF8 );
89 if ( aExt.Equals( "JPG" ) )
90 nFormat = FORMAT_JPG;
91 else if ( aExt.Equals( "PNG" ) )
92 nFormat = FORMAT_PNG;
93 else if ( aExt.Equals( "BMP" ) )
94 nFormat = FORMAT_BMP;
95 else if ( aExt.Equals( "GIF" ) )
96 nFormat = FORMAT_GIF;
97 else if ( aExt.Equals( "PBM" ) )
98 nFormat = FORMAT_PBM;
99 else if ( aExt.Equals( "PGM" ) )
100 nFormat = FORMAT_PGM;
101 else if ( aExt.Equals( "PPM" ) )
102 nFormat = FORMAT_PPM;
103 else if ( aExt.Equals( "PCT" ) )
104 nFormat = FORMAT_PCT;
105 else if ( aExt.Equals( "RAS" ) )
106 nFormat = FORMAT_RAS;
107 else if ( aExt.Equals( "TIF" ) )
108 nFormat = FORMAT_TIF;
109 else if ( aExt.Equals( "XPM" ) )
110 nFormat = FORMAT_XPM;
111 else if ( aExt.Equals( "WMF" ) )
112 nFormat = FORMAT_WMF;
113 else if ( aExt.Equals( "EMF" ) )
114 nFormat = FORMAT_EMF;
115 else if ( aExt.Equals( "EPS" ) )
116 nFormat = FORMAT_EPS;
117 else if ( aExt.Equals( "MET" ) )
118 nFormat = FORMAT_MET;
119 else if ( aExt.Equals( "SVG" ) )
120 nFormat = FORMAT_SVG;
121 else if ( aExt.Equals( "SVM" ) )
122 nFormat = FORMAT_SVM;
123 return nFormat;
124 }
125
GetMapUnit(sal_Int32 nUnit)126 static MapUnit GetMapUnit( sal_Int32 nUnit )
127 {
128 MapUnit aMapUnit( MAP_PIXEL );
129 switch( nUnit )
130 {
131 case UNIT_INCH : aMapUnit = MAP_INCH; break;
132 case UNIT_CM : aMapUnit = MAP_CM; break;
133 case UNIT_MM : aMapUnit = MAP_MM; break;
134 case UNIT_POINT : aMapUnit = MAP_POINT; break;
135 case UNIT_PIXEL : aMapUnit = MAP_PIXEL; break;
136 }
137 return aMapUnit;
138 }
139
GetDefaultUnit()140 sal_Int32 ExportDialog::GetDefaultUnit()
141 {
142 sal_Int32 nDefaultUnit = UNIT_CM;
143 switch( mrFltCallPara.eFieldUnit )
144 {
145 // case FUNIT_NONE :
146 // case FUNIT_PERCENT :
147 // case FUNIT_CUSTOM :
148 default: nDefaultUnit = UNIT_CM; break;
149
150 case FUNIT_MILE : // PASSTHROUGH INTENDED
151 case FUNIT_FOOT :
152 case FUNIT_TWIP :
153 case FUNIT_PICA : nDefaultUnit = UNIT_INCH; break;
154
155 case FUNIT_KM : // PASSTHROUGH INTENDED
156 case FUNIT_M :
157 case FUNIT_100TH_MM : nDefaultUnit = UNIT_CM; break;
158
159 case FUNIT_INCH : nDefaultUnit = UNIT_INCH; break;
160 case FUNIT_CM : nDefaultUnit = UNIT_CM; break;
161 case FUNIT_MM : nDefaultUnit = UNIT_MM; break;
162 case FUNIT_POINT : nDefaultUnit = UNIT_POINT; break;
163 }
164 return nDefaultUnit;
165 }
166
GetShapeRangeForXShape(const uno::Reference<drawing::XShape> & rxShape,const uno::Reference<graphic::XPrimitiveFactory2D> & rxPrimitiveFactory2D,const uno::Sequence<beans::PropertyValue> & rViewInformation)167 static basegfx::B2DRange GetShapeRangeForXShape( const uno::Reference< drawing::XShape >& rxShape,
168 const uno::Reference< graphic::XPrimitiveFactory2D >& rxPrimitiveFactory2D, const uno::Sequence< beans::PropertyValue >& rViewInformation )
169 {
170 basegfx::B2DRange aShapeRange;
171
172 const uno::Sequence< beans::PropertyValue > aParams;
173 const uno::Sequence< uno::Reference< graphic::XPrimitive2D > > aPrimitiveSequence( rxPrimitiveFactory2D->createPrimitivesFromXShape( rxShape, aParams ) );
174
175 const sal_Int32 nCount = aPrimitiveSequence.getLength();
176 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
177 {
178 const geometry::RealRectangle2D aRect( aPrimitiveSequence[ nIndex ]->getRange( rViewInformation ) );
179 aShapeRange.expand( basegfx::B2DTuple( aRect.X1, aRect.Y1 ) );
180 aShapeRange.expand( basegfx::B2DTuple( aRect.X2, aRect.Y2 ) );
181 }
182 return aShapeRange;
183 }
184
GetFilterData(sal_Bool bUpdateConfig)185 uno::Sequence< beans::PropertyValue > ExportDialog::GetFilterData( sal_Bool bUpdateConfig )
186 {
187 if ( bUpdateConfig )
188 {
189 sal_Int32 nUnit = maLbSizeX.GetSelectEntryPos();
190 if ( nUnit < 0 )
191 nUnit = UNIT_CM;
192
193 if ( ( mnInitialResolutionUnit == UNIT_DEFAULT ) && ( nUnit == GetDefaultUnit() ) )
194 nUnit = UNIT_DEFAULT;
195
196 // updating ui configuration
197 if ( mbIsPixelFormat )
198 {
199 if ( nUnit > UNIT_MAX_ID )
200 nUnit = UNIT_PIXEL;
201
202 sal_Int32 nResolution = maNfResolution.GetValue();
203 if ( nResolution < 1 )
204 nResolution = 96;
205
206 mpOptionsItem->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportUnit" ) ), nUnit );
207 mpOptionsItem->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportResolution" ) ), nResolution );
208 mpOptionsItem->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportResolutionUnit" ) ), maLbResolution.GetSelectEntryPos() );
209 }
210 else
211 {
212 if ( nUnit >= UNIT_PIXEL )
213 nUnit = UNIT_CM;
214
215 mpOptionsItem->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "VectorExportUnit" ) ), nUnit );
216 }
217 }
218
219 FilterConfigItem* pFilterOptions;
220 if ( bUpdateConfig )
221 pFilterOptions = mpFilterOptionsItem;
222 else
223 {
224 uno::Sequence< beans::PropertyValue > aFilterData( mpFilterOptionsItem->GetFilterData() );
225 pFilterOptions = new FilterConfigItem( &aFilterData );
226 }
227
228 const String sLogicalWidth( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalWidth" ) ) );
229 const String sLogicalHeight( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalHeight" ) ) );
230 if ( mbIsPixelFormat )
231 {
232 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelWidth" ) ), static_cast< sal_Int32 >( maSize.Width ) );
233 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelHeight" ) ), static_cast< sal_Int32 >( maSize.Height ) );
234 if ( maResolution.Width && maResolution.Height )
235 {
236 const double f100thmmPerPixelX = 100000.0 / maResolution.Width;
237 const double f100thmmPerPixelY = 100000.0 / maResolution.Height;
238 sal_Int32 nLogicalWidth = static_cast< sal_Int32 >( f100thmmPerPixelX * maSize.Width );
239 sal_Int32 nLogicalHeight= static_cast< sal_Int32 >( f100thmmPerPixelY * maSize.Height );
240 if ( nLogicalWidth && nLogicalHeight )
241 {
242 pFilterOptions->WriteInt32( sLogicalWidth, nLogicalWidth );
243 pFilterOptions->WriteInt32( sLogicalHeight, nLogicalHeight );
244 }
245 }
246 }
247 else
248 {
249 pFilterOptions->WriteInt32( sLogicalWidth, static_cast< sal_Int32 >( maSize.Width ) );
250 pFilterOptions->WriteInt32( sLogicalHeight, static_cast< sal_Int32 >( maSize.Height ) );
251 }
252 switch ( mnFormat )
253 {
254 case FORMAT_JPG :
255 {
256 sal_Int32 nColor = maLbColorDepth.GetSelectEntryPos();
257 if ( nColor == 1 )
258 nColor = 0;
259 else
260 nColor = 1;
261 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ColorMode" ) ), nColor );
262 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), static_cast< sal_Int32 >( maSbCompression.GetThumbPos() ) );
263 }
264 break;
265
266 case FORMAT_PNG :
267 {
268 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Compression" ) ), static_cast< sal_Int32 >( maSbCompression.GetThumbPos() ) );
269 sal_Int32 nInterlace = 0;
270 if ( maCbInterlaced.IsChecked() )
271 nInterlace++;
272 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Interlaced" ) ), nInterlace );
273 sal_Int32 nValue = 0;
274 if ( maCbSaveTransparency.IsChecked() )
275 nValue++;
276 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Translucent" ) ), nValue );
277 }
278 break;
279
280 case FORMAT_BMP :
281 {
282 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ), maLbColorDepth.GetSelectEntryPos() + 1 );
283 pFilterOptions->WriteBool( String( RTL_CONSTASCII_USTRINGPARAM( "RLE_Coding" ) ), maCbRLEEncoding.IsChecked() );
284 }
285 break;
286
287 case FORMAT_GIF :
288 {
289 sal_Int32 nValue = 0;
290 if ( maCbInterlaced.IsChecked() )
291 nValue++;
292 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Interlaced" ) ), nValue );
293
294 nValue = 0;
295 if ( maCbSaveTransparency.IsChecked() )
296 nValue++;
297 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Translucent" ) ), nValue );
298 }
299 break;
300
301 case FORMAT_PBM :
302 case FORMAT_PGM :
303 case FORMAT_PPM :
304 {
305 sal_Int32 nFormat = 0;
306 if ( maRbText.IsChecked() )
307 nFormat++;
308 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "FileFormat" ) ), nFormat );
309 }
310 break;
311
312 case FORMAT_EPS :
313 {
314 sal_Int32 nCheck = 0;
315 if ( maCbEPSPreviewTIFF.IsChecked() )
316 nCheck++;
317 if ( maCbEPSPreviewEPSI.IsChecked() )
318 nCheck += 2;
319 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Preview" ) ), nCheck );
320
321 nCheck = 1;
322 if ( maRbEPSLevel2.IsChecked() )
323 nCheck++;
324 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), nCheck );
325
326 nCheck = 1;
327 if ( maRbEPSColorFormat2.IsChecked() )
328 nCheck++;
329 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ColorFormat" ) ), nCheck );
330
331 nCheck = 1;
332 if ( maRbEPSCompressionNone.IsChecked() )
333 nCheck++;
334 pFilterOptions->WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "CompressionMode" ) ), nCheck );
335 }
336 break;
337 }
338
339 uno::Sequence< beans::PropertyValue > aRet( pFilterOptions->GetFilterData() );
340 if ( bUpdateConfig == sal_False )
341 delete pFilterOptions;
342 return aRet;
343 }
344
345 //
GetOriginalSize()346 awt::Size ExportDialog::GetOriginalSize()
347 {
348 basegfx::B2DRange aShapesRange;
349
350 if ( mxPage.is () )
351 {
352 uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY );
353 if ( xPagePropSet.is() )
354 {
355 sal_Int32 nWidth = 0;
356 sal_Int32 nHeight= 0;
357 com::sun::star::uno::Any aAny;
358 aAny = xPagePropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) );
359 aAny >>= nWidth;
360 aAny = xPagePropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) );
361 aAny >>= nHeight;
362 aShapesRange = basegfx::B2DRange( 0, 0, nWidth, nHeight );
363 }
364 }
365 else
366 {
367 uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory(
368 mxMgr->createInstance( String( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.graphic.PrimitiveFactory2D" ) ) ), uno::UNO_QUERY );
369 if ( xPrimitiveFactory.is() )
370 {
371 basegfx::B2DHomMatrix aViewTransformation( Application::GetDefaultDevice()->GetViewTransformation() );
372 com::sun::star::geometry::AffineMatrix2D aTransformation;
373 aTransformation.m00 = aViewTransformation.get(0,0);
374 aTransformation.m01 = aViewTransformation.get(0,1);
375 aTransformation.m02 = aViewTransformation.get(0,2);
376 aTransformation.m10 = aViewTransformation.get(1,0);
377 aTransformation.m11 = aViewTransformation.get(1,1);
378 aTransformation.m12 = aViewTransformation.get(1,2);
379
380 const rtl::OUString sViewTransformation( RTL_CONSTASCII_USTRINGPARAM( "ViewTransformation" ) );
381 uno::Sequence< beans::PropertyValue > aViewInformation( 1 );
382 aViewInformation[ 0 ].Value <<= aTransformation;
383 aViewInformation[ 0 ].Name = sViewTransformation;
384
385 if ( mxShape.is() )
386 aShapesRange = GetShapeRangeForXShape( mxShape, xPrimitiveFactory, aViewInformation );
387 else if ( mxShapes.is() )
388 {
389 const sal_Int32 nCount = mxShapes->getCount();
390 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
391 {
392 uno::Reference< drawing::XShape > xShape;
393 mxShapes->getByIndex( nIndex ) >>= xShape;
394 aShapesRange.expand( GetShapeRangeForXShape( xShape, xPrimitiveFactory, aViewInformation ) );
395 }
396 }
397 }
398 }
399 return awt::Size( static_cast<sal_Int32>(aShapesRange.getWidth()), static_cast<sal_Int32>(aShapesRange.getHeight()) );
400 }
401
GetGraphicSource()402 void ExportDialog::GetGraphicSource()
403 {
404 if ( mxSourceDocument.is() )
405 {
406 uno::Reference< frame::XModel > xModel( mxSourceDocument, uno::UNO_QUERY );
407 if ( xModel.is() )
408 {
409 uno::Reference< frame::XController > xController( xModel->getCurrentController() );
410 if ( xController.is() )
411 {
412 if ( mbExportSelection ) // check if there is a selection
413 {
414 uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY );
415 if ( xSelectionSupplier.is() )
416 {
417 uno::Any aAny( xSelectionSupplier->getSelection() );
418 if ( ! ( aAny >>= mxShapes ) )
419 aAny >>= mxShape;
420 }
421 }
422 if ( !mxShape.is() && !mxShapes.is() )
423 {
424 uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY );
425 if ( xDrawView.is() )
426 {
427 uno::Reference< drawing::XDrawPage > xCurrentPage( xDrawView->getCurrentPage() );
428 if ( xCurrentPage.is() )
429 {
430 mxPage = xCurrentPage; // exporting whole page
431 }
432 }
433 }
434 }
435 }
436 }
437 }
438
GetGraphicStream()439 sal_Bool ExportDialog::GetGraphicStream()
440 {
441 sal_Bool bRet = sal_False;
442
443 if ( !IsTempExportAvailable() )
444 {
445 delete mpTempStream, mpTempStream = new SvMemoryStream();
446 maBitmap = Bitmap();
447 return bRet;
448 }
449
450 sal_Bool bRecreateOutputStream = mpTempStream->Tell() == 0;
451
452 static uno::Sequence< beans::PropertyValue > aOldFilterData;
453 uno::Sequence< beans::PropertyValue > aNewFilterData( GetFilterData( sal_False ) );
454 if ( aOldFilterData != aNewFilterData )
455 {
456 aOldFilterData = aNewFilterData;
457 bRecreateOutputStream = sal_True;
458 }
459 try
460 {
461 if ( bRecreateOutputStream )
462 {
463 delete mpTempStream, mpTempStream = new SvMemoryStream();
464 maBitmap = Bitmap();
465
466 uno::Reference < io::XStream > xStream( new utl::OStreamWrapper( *mpTempStream ) );
467 uno::Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
468
469 uno::Reference< document::XExporter > xGraphicExporter(
470 mxMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicExportFilter") ) ), uno::UNO_QUERY_THROW );
471 uno::Reference< document::XFilter > xFilter( xGraphicExporter, uno::UNO_QUERY_THROW );
472
473 sal_Int32 nProperties = 2;
474 uno::Sequence< beans::PropertyValue > aFilterData( nProperties );
475
476
477 rtl::OUString sFormat( maExt );
478 uno::Sequence< beans::PropertyValue > aDescriptor( 3 );
479 aDescriptor[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OutputStream") );
480 aDescriptor[0].Value <<= xOutputStream;
481 aDescriptor[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
482 aDescriptor[1].Value <<= sFormat;
483 aDescriptor[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterData") );
484 aDescriptor[2].Value <<= aNewFilterData;
485
486 uno::Reference< lang::XComponent > xSourceDoc;
487 if ( mxPage.is() )
488 xSourceDoc = uno::Reference< lang::XComponent >( mxPage, uno::UNO_QUERY_THROW );
489 else if ( mxShapes.is() )
490 xSourceDoc = uno::Reference< lang::XComponent >( mxShapes, uno::UNO_QUERY_THROW );
491 else if ( mxShape.is() )
492 xSourceDoc = uno::Reference< lang::XComponent >( mxShape, uno::UNO_QUERY_THROW );;
493 if ( xSourceDoc.is() )
494 {
495 xGraphicExporter->setSourceDocument( xSourceDoc );
496 xFilter->filter( aDescriptor );
497 bRet = sal_True;
498
499 if ( mnFormat == FORMAT_JPG )
500 {
501 mpTempStream->Seek( STREAM_SEEK_TO_BEGIN );
502 maBitmap = GetGraphicBitmap( *mpTempStream );
503 mpTempStream->Seek( STREAM_SEEK_TO_END );
504 }
505 }
506 }
507 else
508 bRet = sal_True;
509 }
510 catch( uno::Exception& )
511 {
512
513 // ups
514
515 }
516 return bRet;
517 }
518
GetGraphicBitmap(SvStream & rInputStream)519 Bitmap ExportDialog::GetGraphicBitmap( SvStream& rInputStream )
520 {
521 Bitmap aRet;
522 Graphic aGraphic;
523 GraphicFilter aFilter( sal_False );
524 if ( aFilter.ImportGraphic( aGraphic, String(), rInputStream, GRFILTER_FORMAT_NOTFOUND, NULL, 0, NULL ) == GRFILTER_OK )
525 {
526 aRet = aGraphic.GetBitmap();
527 }
528 return aRet;
529 }
530
GetRawFileSize() const531 sal_uInt32 ExportDialog::GetRawFileSize() const
532 {
533 sal_uInt64 nRawFileSize = 0;
534 if ( mbIsPixelFormat )
535 {
536 sal_Int32 nBitsPerPixel = 24;
537 String aEntry( maLbColorDepth.GetSelectEntry() );
538 if ( ms1BitTreshold == aEntry )
539 nBitsPerPixel = 1;
540 else if ( ms1BitDithered == aEntry )
541 nBitsPerPixel = 1;
542 else if ( ms4BitGrayscale == aEntry )
543 nBitsPerPixel = 4;
544 else if ( ms4BitColorPalette == aEntry )
545 nBitsPerPixel = 8;
546 else if ( ms8BitGrayscale == aEntry )
547 nBitsPerPixel = 8;
548 else if ( ms8BitColorPalette == aEntry )
549 nBitsPerPixel = 8;
550 else if ( ms24BitColor == aEntry )
551 nBitsPerPixel = 24;
552
553 if ( mbIsPixelFormat )
554 {
555 nRawFileSize = ( maSize.Width * nBitsPerPixel + 7 ) &~ 7; // rounding up to 8 bits
556 nRawFileSize /= 8; // in bytes
557 nRawFileSize *= maSize.Height;
558 }
559 if ( nRawFileSize > SAL_MAX_UINT32 )
560 nRawFileSize = 0;
561 }
562 return static_cast< sal_uInt32 >( nRawFileSize );
563 }
564
565 // checks if the source dimension/resolution is not too big
566 // to determine the exact graphic output size and preview for jpg
IsTempExportAvailable() const567 sal_Bool ExportDialog::IsTempExportAvailable() const
568 {
569 return GetRawFileSize() < static_cast< sal_uInt32 >( mnMaxFilesizeForRealtimePreview );
570 }
571
ExportDialog(FltCallDialogParameter & rPara,const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> rxMgr,const com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> & rxSourceDocument,sal_Bool bExportSelection,sal_Bool bIsPixelFormat)572 ExportDialog::ExportDialog( FltCallDialogParameter& rPara,
573 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > rxMgr,
574 const com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rxSourceDocument,
575 sal_Bool bExportSelection, sal_Bool bIsPixelFormat ) :
576 ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT, *rPara.pResMgr ) ),
577 mrFltCallPara ( rPara ),
578 mpMgr ( rPara.pResMgr ),
579 mxMgr ( rxMgr ),
580 mxSourceDocument ( rxSourceDocument ),
581 maFlExportSize ( this, ResId( FL_EXPORT_SIZE, *rPara.pResMgr ) ),
582 maFtSizeX ( this, ResId( FT_SIZEX, *rPara.pResMgr ) ),
583 maMfSizeX ( this, ResId( MF_SIZEX, *rPara.pResMgr ) ),
584 maLbSizeX ( this, ResId( LB_SIZEX, *rPara.pResMgr ) ),
585 maFtSizeY ( this, ResId( FT_SIZEY, *rPara.pResMgr ) ),
586 maMfSizeY ( this, ResId( MF_SIZEY, *rPara.pResMgr ) ),
587 maLbSizeY ( this, ResId( LB_SIZEY, *rPara.pResMgr ) ),
588 maFtResolution ( this, ResId( FT_RESOLUTION, *rPara.pResMgr ) ),
589 maNfResolution ( this, ResId( NF_RESOLUTION, *rPara.pResMgr ) ),
590 maLbResolution ( this, ResId( LB_RESOLUTION, *rPara.pResMgr ) ),
591 maFlColorDepth ( this, ResId( FL_COLOR_DEPTH, *rPara.pResMgr ) ),
592 maLbColorDepth ( this, ResId( LB_COLOR_DEPTH, *rPara.pResMgr ) ),
593 maFlJPGQuality ( this, ResId( FL_JPG_QUALITY, *rPara.pResMgr ) ),
594 maFlMode ( this, ResId( FL_MODE, *rPara.pResMgr ) ),
595 maFlPBMOptions ( this, ResId( FL_PBM_OPTIONS, *rPara.pResMgr ) ),
596 maSbCompression ( this, ResId( SB_COMPRESSION, *rPara.pResMgr ) ),
597 maNfCompression ( this, ResId( NF_COMPRESSION, *rPara.pResMgr ) ),
598 maFtJPGMin ( this, ResId( FT_JPG_MIN, *rPara.pResMgr ) ),
599 maFtJPGMax ( this, ResId( FT_JPG_MAX, *rPara.pResMgr ) ),
600 maFtPNGMin ( this, ResId( FT_PNG_MIN, *rPara.pResMgr ) ),
601 maFtPNGMax ( this, ResId( FT_PNG_MAX, *rPara.pResMgr ) ),
602 maCbJPGPreview ( this, ResId( CB_JPG_PREVIEW, *rPara.pResMgr ) ),
603 maCbInterlaced ( this, ResId( CB_INTERLACED, *rPara.pResMgr ) ),
604 maCbRLEEncoding ( this, ResId( CB_RLE_ENCODING, *rPara.pResMgr ) ),
605 maFlGIFDrawingObjects ( this, ResId( FL_GIF_DRAWING_OBJECTS, *rPara.pResMgr ) ),
606 maCbSaveTransparency ( this, ResId( CB_SAVE_TRANSPARENCY, *rPara.pResMgr ) ),
607 maRbBinary ( this, ResId( RB_BINARY, *rPara.pResMgr ) ),
608 maRbText ( this, ResId( RB_TEXT, *rPara.pResMgr ) ),
609 maFlEPSPreview ( this, ResId( FL_EPS_PREVIEW, *rPara.pResMgr ) ),
610 maCbEPSPreviewTIFF ( this, ResId( CB_EPS_PREVIEW_TIFF, *rPara.pResMgr ) ),
611 maCbEPSPreviewEPSI ( this, ResId( CB_EPS_PREVIEW_EPSI, *rPara.pResMgr ) ),
612 maFlEPSVersion ( this, ResId( FL_EPS_VERSION, *rPara.pResMgr ) ),
613 maRbEPSLevel1 ( this, ResId( RB_EPS_LEVEL1, *rPara.pResMgr ) ),
614 maRbEPSLevel2 ( this, ResId( RB_EPS_LEVEL2, *rPara.pResMgr ) ),
615 maFlEPSColorFormat ( this, ResId( FL_EPS_COLOR_FORMAT, *rPara.pResMgr ) ),
616 maRbEPSColorFormat1 ( this, ResId( RB_EPS_COLOR_FORMAT1, *rPara.pResMgr ) ),
617 maRbEPSColorFormat2 ( this, ResId( RB_EPS_COLOR_FORMAT2, *rPara.pResMgr ) ),
618 maFlCompression ( this, ResId( FL_COMPRESSION, *rPara.pResMgr ) ),
619 maRbEPSCompressionLZW ( this, ResId( RB_EPS_COMPRESSION_LZW, *rPara.pResMgr ) ),
620 maRbEPSCompressionNone ( this, ResId( RB_EPS_COMPRESSION_NONE, *rPara.pResMgr ) ),
621 maFlEstimatedSize ( this, ResId( FL_ESTIMATED_SIZE, *rPara.pResMgr ) ),
622 maFtEstimatedSize ( this, ResId( FT_ESTIMATED_SIZE, *rPara.pResMgr ) ),
623 msEstimatedSizePix1 ( ResId( STR_ESTIMATED_SIZE_PIX_1, *rPara.pResMgr ) ),
624 msEstimatedSizePix2 ( ResId( STR_ESTIMATED_SIZE_PIX_2, *rPara.pResMgr ) ),
625 msEstimatedSizeVec ( ResId( STR_ESTIMATED_SIZE_VEC, *rPara.pResMgr ) ),
626 maFlButtons ( this, ResId( FL_BUTTONS, *rPara.pResMgr ) ),
627 maFbJPGPreview ( this, ResId( FB_JPG_PREVIEW, *rPara.pResMgr ) ),
628 maSbZoom ( this, ResId( SB_ZOOM, *rPara.pResMgr ) ),
629 maNfZoom ( this, ResId( NF_ZOOM, *rPara.pResMgr ) ),
630 maSbJPGPreviewHorz ( this, ResId( SB_JPG_PREVIEW_HORZ, *rPara.pResMgr ) ),
631 maSbJPGPreviewVert ( this, ResId( SB_JPG_PREVIEW_VERT, *rPara.pResMgr ) ),
632 maBtnOK ( this, ResId( BTN_OK, *rPara.pResMgr ) ),
633 maBtnCancel ( this, ResId( BTN_CANCEL, *rPara.pResMgr ) ),
634 maBtnHelp ( this, ResId( BTN_HELP, *rPara.pResMgr ) ),
635 ms1BitTreshold ( ResId( STR_1BIT_THRESHOLD, *rPara.pResMgr ) ),
636 ms1BitDithered ( ResId( STR_1BIT_DITHERED, *rPara.pResMgr ) ),
637 ms4BitGrayscale ( ResId( STR_4BIT_GRAYSCALE, *rPara.pResMgr ) ),
638 ms4BitColorPalette ( ResId( STR_4BIT_COLOR_PALETTE, *rPara.pResMgr ) ),
639 ms8BitGrayscale ( ResId( STR_8BIT_GRAYSCALE, *rPara.pResMgr ) ),
640 ms8BitColorPalette ( ResId( STR_8BIT_COLOR_PALETTE, *rPara.pResMgr ) ),
641 ms24BitColor ( ResId( STR_24BIT_TRUE_COLOR, *rPara.pResMgr ) ),
642 maExt ( rPara.aFilterExt ),
643 mnFormat ( FORMAT_UNKNOWN ),
644 mnMaxFilesizeForRealtimePreview( 0 ),
645 mpTempStream ( new SvMemoryStream() ),
646 maOriginalSize ( awt::Size( 0, 0 ) ),
647 mbPreview ( sal_False ),
648 mbIsPixelFormat ( bIsPixelFormat ),
649 mbExportSelection ( bExportSelection ),
650 mbPreserveAspectRatio ( sal_True )
651 {
652 GetGraphicSource();
653
654 maExt.ToUpperAscii();
655
656 String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Export/" ) );
657 mpOptionsItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
658 aFilterConfigPath.Append( maExt );
659 mpFilterOptionsItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
660
661 mnInitialResolutionUnit = mbIsPixelFormat
662 ? mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportUnit" ) ), UNIT_DEFAULT )
663 : mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "VectorExportUnit" ) ), UNIT_DEFAULT );
664
665 mnMaxFilesizeForRealtimePreview = mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "MaxFilesizeForRealtimePreview" ) ), 0 );
666 maFtEstimatedSize.SetText( String( RTL_CONSTASCII_USTRINGPARAM( " \n " ) ) );
667
668 String aTitle( maExt );
669 aTitle += String( ResId( DLG_EXPORT_TITLE, *mpMgr ) );
670 SetText( aTitle );
671
672 mnFormat = GetFilterFormat( maExt );
673
674 Size aResolution( Application::GetDefaultDevice()->LogicToPixel( Size( 100, 100 ), MAP_CM ) );
675 maResolution.Width = aResolution.Width();
676 maResolution.Height= aResolution.Height();
677 maOriginalSize = GetOriginalSize();
678 if ( bIsPixelFormat )
679 {
680 double fPixelsPer100thmm = static_cast< double >( maResolution.Width ) / 100000.0;
681 maSize = awt::Size( static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Width ) + 0.5 ),
682 static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Height ) + 0.5 ) );
683 }
684 else
685 {
686 maSize = maOriginalSize;
687 }
688
689 // Size
690 maLbSizeX.SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
691
692 maSbCompression.SetScrollHdl( LINK( this, ExportDialog, SbCompressionUpdateHdl ) );
693 maNfCompression.SetModifyHdl( LINK( this, ExportDialog, UpdateHdl ) );
694
695 maMfSizeX.SetModifyHdl( LINK( this, ExportDialog, UpdateHdlMtfSizeX ) );
696 maMfSizeY.SetModifyHdl( LINK( this, ExportDialog, UpdateHdlMtfSizeY ) );
697
698 maNfResolution.SetModifyHdl( LINK( this, ExportDialog, UpdateHdlNfResolution ) );
699 maLbResolution.SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
700
701 maLbColorDepth.SetSelectHdl( LINK( this, ExportDialog, UpdateHdl ) );
702
703 maCbInterlaced.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
704
705 maCbSaveTransparency.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
706
707 maCbEPSPreviewTIFF.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
708 maCbEPSPreviewEPSI.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
709
710 maRbEPSCompressionLZW.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
711 maRbEPSCompressionNone.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
712
713 maRbBinary.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
714 maRbText.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
715
716
717 // JPG Preview
718 // maCbJPGPreview.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
719 maCbJPGPreview.Enable( sal_False );
720
721 maSbJPGPreviewVert.SetScrollHdl( LINK( this, ExportDialog, UpdateHdl ) );
722 maSbJPGPreviewHorz.SetScrollHdl( LINK( this, ExportDialog, UpdateHdl ) );
723 maSbZoom.SetScrollHdl( LINK( this, ExportDialog, UpdateHdl ) );
724
725 // BMP
726 maCbRLEEncoding.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
727
728 // EPS
729 maRbEPSLevel1.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
730 maRbEPSLevel2.SetClickHdl( LINK( this, ExportDialog, UpdateHdl ) );
731
732 maBtnOK.SetClickHdl( LINK( this, ExportDialog, OK ) );
733
734 setupLayout();
735 updateControls();
736
737 FreeResource();
738 }
739
createSizeControls(vcl::RowOrColumn & rLayout)740 void ExportDialog::createSizeControls( vcl::RowOrColumn& rLayout )
741 {
742 size_t nIndex;
743 Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
744 long nIndent = aBorder.Width();
745
746 // Size controls
747 rLayout.addWindow( &maFlExportSize );
748
749 Size aLbMax( maLbSizeX.GetSizePixel() );
750 aLbMax.Width() = Max( aLbMax.Width(), maLbResolution.GetSizePixel().Width() );
751
752 boost::shared_ptr< vcl::LabelColumn > xSizeColumns( new vcl::LabelColumn( &rLayout ) );
753 rLayout.addChild( xSizeColumns );
754
755 // row 1
756 boost::shared_ptr< vcl::RowOrColumn > xColumn( new vcl::RowOrColumn( xSizeColumns.get(), false ) );
757 xSizeColumns->addRow( &maFtSizeX, xColumn, nIndent );
758 Size aMinSize( maMfSizeX.GetSizePixel() );
759 nIndex = xColumn->addWindow( &maMfSizeX );
760 xColumn->setMinimumSize( nIndex, aMinSize );
761 nIndex = xColumn->addWindow( &maLbSizeX );
762 xColumn->setMinimumSize( nIndex, aLbMax );
763
764 // row 2
765 xColumn = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( xSizeColumns.get(), false ) );
766 xSizeColumns->addRow( &maFtSizeY, xColumn, nIndent );
767 nIndex = xColumn->addWindow( &maMfSizeY );
768 xColumn->setMinimumSize( nIndex, aMinSize );
769 nIndex = xColumn->addWindow( &maLbSizeY );
770 xColumn->setMinimumSize( nIndex, aLbMax );
771
772 // row 3
773 if ( mbIsPixelFormat ) // TODO: (metafileresolutionsupport)
774 {
775 xColumn = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( xSizeColumns.get(), false ) );
776 xSizeColumns->addRow( &maFtResolution, xColumn, nIndent );
777 nIndex = xColumn->addWindow( &maNfResolution );
778 xColumn->setMinimumSize( nIndex, aMinSize );
779 nIndex = xColumn->addWindow( &maLbResolution );
780 xColumn->setMinimumSize( nIndex, aLbMax );
781 }
782
783 sal_Int32 nUnit = mnInitialResolutionUnit;
784 if ( nUnit == UNIT_DEFAULT )
785 nUnit = GetDefaultUnit();
786
787 if ( !mbIsPixelFormat )
788 {
789 maLbSizeX.RemoveEntry( UNIT_PIXEL ); // removing pixel
790 if ( nUnit >= UNIT_PIXEL )
791 nUnit = UNIT_CM;
792 }
793 else if ( nUnit > UNIT_MAX_ID )
794 nUnit = UNIT_PIXEL;
795 if ( nUnit < 0 )
796 nUnit = UNIT_CM;
797 maLbSizeX.SelectEntryPos( static_cast< sal_uInt16 >( nUnit ) );
798
799 if ( mbIsPixelFormat ) // TODO: (metafileresolutionsupport) should be supported for vector formats also... this makes
800 { // sense eg for bitmap fillings in metafiles, to preserve high dpi output
801 // (atm without special vector support the bitmaps are rendered with 96dpi)
802 sal_Int32 nResolution = mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportResolution" ) ), 96 );
803 if ( nResolution < 1 )
804 nResolution = 96;
805 maNfResolution.SetValue( nResolution );
806
807 sal_Int32 nResolutionUnit = mpOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "PixelExportResolutionUnit" ) ), 1 );
808 if ( ( nResolutionUnit < 0 ) || ( nResolutionUnit > 2 ) )
809 nResolutionUnit = 1;
810 maLbResolution.SelectEntryPos( static_cast< sal_uInt16 >( nResolutionUnit ) );
811 }
812
813 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
814 rLayout.addChild( xSpacer );
815 }
816
createColorDepthControls(vcl::RowOrColumn & rLayout)817 void ExportDialog::createColorDepthControls( vcl::RowOrColumn& rLayout )
818 {
819 // Color Depth
820 Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
821 long nIndent = aBorder.Width();
822
823 boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &rLayout, false ) );
824 rLayout.addChild( xRow );
825 xRow->addWindow( &maFlColorDepth );
826
827 xRow = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( &rLayout, false ) );
828 rLayout.addChild( xRow );
829 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
830 xRow->addChild( xIndenter );
831 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
832 xIndenter->setChild( xRows );
833 xRows->addWindow( &maLbColorDepth );
834
835 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
836 rLayout.addChild( xSpacer );
837 }
838
createScrollBar(vcl::RowOrColumn & rLayout)839 void ExportDialog::createScrollBar( vcl::RowOrColumn& rLayout )
840 {
841 boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &rLayout, false ) );
842 rLayout.addChild( xRow );
843
844 Size aMinSize( maSbCompression.GetSizePixel() );
845 size_t nIndex = xRow->addWindow( &maSbCompression );
846 xRow->setMinimumSize( nIndex, aMinSize );
847 aMinSize = maNfCompression.GetSizePixel();
848 nIndex = xRow->addWindow( &maNfCompression );
849 xRow->setMinimumSize( nIndex, aMinSize );
850 }
851
createFilterOptions(vcl::RowOrColumn & rLayout)852 void ExportDialog::createFilterOptions( vcl::RowOrColumn& rLayout )
853 {
854 Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
855 long nIndent = aBorder.Width();
856
857 switch( mnFormat )
858 {
859 case FORMAT_JPG :
860 {
861 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ColorMode" ) ), 0 );
862 if ( nColor == 1 )
863 nColor = 0;
864 else
865 nColor = 1;
866 maLbColorDepth.InsertEntry( ms8BitGrayscale );
867 maLbColorDepth.InsertEntry( ms24BitColor );
868 maLbColorDepth.SelectEntryPos( nColor );
869 createColorDepthControls( maLayout );
870
871 rLayout.addWindow( &maFlJPGQuality );
872
873 // Quality
874 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
875 rLayout.addChild( xIndenter );
876 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
877 xIndenter->setChild( xRows );
878 createScrollBar( *xRows.get() );
879 xRows->addWindow( &maFtJPGMin );
880 xRows->addWindow( &maFtJPGMax );
881 if ( maCbJPGPreview.IsEnabled() )
882 xRows->addWindow( &maCbJPGPreview );
883
884 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
885 rLayout.addChild( xSpacer );
886
887 sal_Int32 nQuality = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), 75 );
888 if ( ( nQuality < 1 ) || ( nQuality > 100 ) )
889 nQuality = 75;
890
891 maSbCompression.SetRangeMin( 1 );
892 maSbCompression.SetRangeMax( 100 );
893 maNfCompression.SetMin( 1 );
894 maNfCompression.SetMax( 100 );
895 maNfCompression.SetValue( nQuality );
896 maNfCompression.SetStrictFormat( sal_True );
897 if ( maCbJPGPreview.IsEnabled() )
898 maCbJPGPreview.Check( sal_False );
899 }
900 break;
901 case FORMAT_PNG :
902 {
903 rLayout.addWindow( &maFlCompression );
904
905 // Compression 1..9
906 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
907 rLayout.addChild( xIndenter );
908 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
909 xIndenter->setChild( xRows );
910 createScrollBar( *xRows.get() );
911 xRows->addWindow( &maFtPNGMin );
912 xRows->addWindow( &maFtPNGMax );
913 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
914 rLayout.addChild( xSpacer );
915
916 // Interlaced
917 rLayout.addWindow( &maFlMode );
918 xIndenter.reset( new vcl::Indenter( &rLayout, nIndent ) );
919 rLayout.addChild( xIndenter );
920 xRows.reset( new vcl::RowOrColumn( &rLayout, true ) );
921 xIndenter->setChild( xRows );
922 xRows->addWindow( &maCbInterlaced );
923
924 xSpacer.reset( new vcl::Spacer( &rLayout, 2 ) );
925 rLayout.addChild( xSpacer );
926
927 sal_Int32 nCompression = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Compression" ) ), 6 );
928 if ( ( nCompression < 1 ) || ( nCompression > 9 ) )
929 nCompression = 6;
930 maSbCompression.SetRangeMin( 1 );
931 maSbCompression.SetRangeMax( 9 );
932 maNfCompression.SetMin( 1 );
933 maNfCompression.SetMax( 9 );
934 maNfCompression.SetValue( 9 );
935 maNfCompression.SetStrictFormat( sal_True );
936
937 // transparency
938 xIndenter = boost::shared_ptr< vcl::Indenter >( new vcl::Indenter( &rLayout, nIndent ) );
939 rLayout.addChild( xIndenter );
940 xRows = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( &rLayout, true ) );
941 xIndenter->setChild( xRows );
942 xRows->addWindow( &maCbSaveTransparency );
943 xSpacer.reset( new vcl::Spacer( &rLayout, 2 ) );
944 rLayout.addChild( xSpacer );
945
946 maCbSaveTransparency.Check( mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Translucent" ) ), 1 ) != 0 );
947 maCbInterlaced.Check( mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Interlaced" ) ), 0 ) != 0 );
948 }
949 break;
950 case FORMAT_BMP :
951 {
952 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ), 0 );
953 if ( nColor == 0 )
954 nColor = 6;
955 else
956 nColor--;
957 maLbColorDepth.InsertEntry( ms1BitTreshold );
958 maLbColorDepth.InsertEntry( ms1BitDithered );
959 maLbColorDepth.InsertEntry( ms4BitGrayscale );
960 maLbColorDepth.InsertEntry( ms4BitColorPalette );
961 maLbColorDepth.InsertEntry( ms8BitGrayscale );
962 maLbColorDepth.InsertEntry( ms8BitColorPalette );
963 maLbColorDepth.InsertEntry( ms24BitColor );
964 maLbColorDepth.SelectEntryPos( nColor );
965 createColorDepthControls( maLayout );
966
967 rLayout.addWindow( &maFlCompression );
968 // RLE coding
969 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
970 rLayout.addChild( xIndenter );
971 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
972 xIndenter->setChild( xRows );
973 xRows->addWindow( &maCbRLEEncoding );
974 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
975 rLayout.addChild( xSpacer );
976
977 maCbRLEEncoding.Check( mpFilterOptionsItem->ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "RLE_Coding" ) ), sal_True ) );
978 }
979 break;
980 case FORMAT_GIF :
981 {
982 rLayout.addWindow( &maFlMode );
983 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
984 rLayout.addChild( xIndenter );
985 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
986 xIndenter->setChild( xRows );
987 xRows->addWindow( &maCbInterlaced );
988 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
989 rLayout.addChild( xSpacer );
990
991 rLayout.addWindow( &maFlGIFDrawingObjects );
992 xIndenter = boost::shared_ptr< vcl::Indenter >( new vcl::Indenter( &rLayout, nIndent ) );
993 rLayout.addChild( xIndenter );
994 xRows = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( &rLayout, true ) );
995 xIndenter->setChild( xRows );
996 xRows->addWindow( &maCbSaveTransparency );
997 xSpacer.reset( new vcl::Spacer( &rLayout, 2 ) );
998 rLayout.addChild( xSpacer );
999
1000 maCbInterlaced.Check( mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Interlaced" ) ), 1 ) != 0 );
1001 maCbSaveTransparency.Check( mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Translucent" ) ), 1 ) != 0 );
1002 }
1003 break;
1004 case FORMAT_PBM :
1005 case FORMAT_PGM :
1006 case FORMAT_PPM :
1007 {
1008 rLayout.addWindow( &maFlJPGQuality );
1009
1010 // RB Binary / Text
1011 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( &rLayout, nIndent ) );
1012 rLayout.addChild( xIndenter );
1013 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( &rLayout, true ) );
1014 xIndenter->setChild( xRows );
1015 xRows->addWindow( &maRbBinary );
1016 xRows->addWindow( &maRbText );
1017 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
1018 rLayout.addChild( xSpacer );
1019
1020 sal_Int32 nFormat = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "FileFormat" ) ), 1 );
1021 maRbBinary.Check( nFormat == 0 );
1022 maRbText.Check( nFormat != 0 );
1023 }
1024 break;
1025 case FORMAT_EPS :
1026 {
1027 boost::shared_ptr< vcl::RowOrColumn > xColumns( new vcl::RowOrColumn( &rLayout, false ) );
1028 rLayout.addChild( xColumns );
1029 boost::shared_ptr< vcl::RowOrColumn > xLeft( new vcl::RowOrColumn( &rLayout, true ) );
1030 xColumns->addChild( xLeft );
1031
1032 xLeft->addWindow( &maFlEPSPreview );
1033 boost::shared_ptr< vcl::Indenter > xIndenter( new vcl::Indenter( xLeft.get(), nIndent ) );
1034 xLeft->addChild( xIndenter );
1035 boost::shared_ptr< vcl::RowOrColumn > xRows( new vcl::RowOrColumn( xLeft.get(), true ) );
1036 xIndenter->setChild( xRows );
1037 xRows->addWindow( &maCbEPSPreviewTIFF );
1038 xRows->addWindow( &maCbEPSPreviewEPSI );
1039 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xLeft.get(), 2 ) );
1040 xLeft->addChild( xSpacer );
1041
1042 xLeft->addWindow( &maFlEPSVersion );
1043 xIndenter = boost::shared_ptr< vcl::Indenter >( new vcl::Indenter( xLeft.get(), nIndent ) );
1044 xLeft->addChild( xIndenter );
1045 xRows = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( xLeft.get(), true ) );
1046 xIndenter->setChild( xRows );
1047 xRows->addWindow( &maRbEPSLevel1 );
1048 xRows->addWindow( &maRbEPSLevel2 );
1049 xSpacer.reset( new vcl::Spacer( xLeft.get(), 2 ) );
1050 xLeft->addChild( xSpacer );
1051
1052 boost::shared_ptr< vcl::RowOrColumn > xRight( new vcl::RowOrColumn( &rLayout, true ) );
1053 xColumns->addChild( xRight );
1054
1055 xRight->addWindow( &maFlEPSColorFormat );
1056 xIndenter = boost::shared_ptr< vcl::Indenter >( new vcl::Indenter( xRight.get(), nIndent ) );
1057 xRight->addChild( xIndenter );
1058 xRows = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( xRight.get(), true ) );
1059 xIndenter->setChild( xRows );
1060 xRows->addWindow( &maRbEPSColorFormat1 );
1061 xRows->addWindow( &maRbEPSColorFormat2 );
1062 xSpacer.reset( new vcl::Spacer( xRight.get(), 2 ) );
1063 xRight->addChild( xSpacer );
1064
1065 xRight->addWindow( &maFlCompression );
1066 xIndenter = boost::shared_ptr< vcl::Indenter >( new vcl::Indenter( xRight.get(), nIndent ) );
1067 xRight->addChild( xIndenter );
1068 xRows = boost::shared_ptr< vcl::RowOrColumn >( new vcl::RowOrColumn( xRight.get(), true ) );
1069 xIndenter->setChild( xRows );
1070 xRows->addWindow( &maRbEPSCompressionLZW );
1071 xRows->addWindow( &maRbEPSCompressionNone );
1072
1073 xSpacer.reset( new vcl::Spacer( &rLayout, 2 ) );
1074 rLayout.addChild( xSpacer );
1075
1076 sal_Int32 nPreview = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Preview" ) ), 0 );
1077 sal_Int32 nVersion = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), 2 );
1078 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ColorFormat" ) ), 0 );
1079 sal_Int32 nCompr = mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "CompressionMode" ) ), 2 );
1080
1081 mpFilterOptionsItem->ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "TextMode" ) ), 0 );
1082
1083 maCbEPSPreviewTIFF.Check( ( nPreview & 1 ) != 0 );
1084 maCbEPSPreviewEPSI.Check( ( nPreview & 2 ) != 0 );
1085
1086 maRbEPSLevel1.Check( nVersion == 1 );
1087 maRbEPSLevel2.Check( nVersion == 2 );
1088
1089 maRbEPSColorFormat1.Check( nColor == 1 );
1090 maRbEPSColorFormat2.Check( nColor != 1 );
1091
1092 maRbEPSCompressionLZW.Check( nCompr == 1 );
1093 maRbEPSCompressionNone.Check( nCompr != 1 );
1094 }
1095 break;
1096 }
1097 }
1098
createButtons(vcl::RowOrColumn & rLayout)1099 void ExportDialog::createButtons( vcl::RowOrColumn& rLayout )
1100 {
1101 rLayout.addWindow( &maFlButtons );
1102 boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( &rLayout, 2 ) );
1103 rLayout.addChild( xSpacer );
1104
1105 Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
1106
1107 boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( &rLayout, false ) );
1108 size_t nIndex = rLayout.addChild( xButtons );
1109 rLayout.setBorders( nIndex, aBorder.Width(), 0, aBorder.Width(), aBorder.Width() );
1110
1111 Size aMinSize( maBtnCancel.GetSizePixel() );
1112 // insert help button
1113 xButtons->setMinimumSize( xButtons->addWindow( &maBtnHelp ), aMinSize );
1114
1115 // insert a spacer, cancel and OK buttons are right aligned
1116
1117 xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) );
1118 xButtons->addChild( xSpacer );
1119 xButtons->setMinimumSize( xButtons->addWindow( &maBtnOK ), aMinSize );
1120 xButtons->setMinimumSize( xButtons->addWindow( &maBtnCancel ), aMinSize );
1121 }
1122
setupLayout()1123 void ExportDialog::setupLayout()
1124 {
1125 Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
1126 maLayout.setParentWindow( this );
1127 maLayout.setOuterBorder( aBorder.Width() );
1128
1129 createSizeControls( maLayout );
1130 createFilterOptions( maLayout );
1131
1132 if ( mnMaxFilesizeForRealtimePreview || mbIsPixelFormat )
1133 {
1134 maLayout.addWindow( &maFlEstimatedSize );
1135 maLayout.addWindow( &maFtEstimatedSize );
1136 }
1137 createButtons( maLayout );
1138
1139 maLayout.show();
1140 maDialogSize = maLayout.getOptimalSize( WINDOWSIZE_PREFERRED );
1141 maLayout.setManagedArea( Rectangle( Point(), maDialogSize ) );
1142 SetOutputSizePixel( Size( mbPreview ? maDialogSize.Width() * 2 : maDialogSize.Width(), maDialogSize.Height() ) );
1143
1144 maRectFlButtons = Rectangle( maFlButtons.GetPosPixel(), maFlButtons.GetSizePixel() );
1145 maRectBtnHelp = Rectangle( maBtnHelp.GetPosPixel(), maBtnHelp.GetSizePixel() );
1146 maRectBtnOK = Rectangle( maBtnOK.GetPosPixel(), maBtnOK.GetSizePixel() );
1147 maRectBtnCancel = Rectangle( maBtnCancel.GetPosPixel(), maBtnOK.GetSizePixel() );
1148
1149 maLbSizeY.Hide();
1150 }
1151
ImpValueOfInKB(const sal_Int64 & rVal)1152 static rtl::OUString ImpValueOfInKB( const sal_Int64& rVal )
1153 {
1154 double fVal( static_cast<double>( rVal ) );
1155 fVal /= ( 1 << 10 );
1156 fVal += 0.05;
1157 rtl::OUStringBuffer aVal( rtl::OUString::valueOf( fVal ) );
1158 sal_Int32 nX( rtl::OUString( aVal.getStr() ).indexOf( '.', 0 ) );
1159 if ( nX > 0 )
1160 aVal.setLength( nX + 2 );
1161 return aVal.makeStringAndClear();
1162 }
1163
GetZoomValueFromThumbPos(sal_Int32 nThumbPos)1164 sal_Int32 static GetZoomValueFromThumbPos( sal_Int32 nThumbPos )
1165 {
1166 sal_Int32 nProz = 0;
1167 if ( nThumbPos <= 50 )
1168 nProz = nThumbPos * 2; // so a range of 50 represents 100%
1169 else
1170 nProz = ( ( nThumbPos - 50 ) * 60 ) + 100; // we want to scale up to 3000%
1171 return nProz;
1172 }
1173
updatePreview()1174 void ExportDialog::updatePreview()
1175 {
1176 // JPG
1177 // maCbJPGPreview.Enable( IsTempExportAvailable() );
1178
1179 // if ( maCbJPGPreview.IsEnabled() && maCbJPGPreview.IsChecked() )
1180 if ( mbPreview )
1181 {
1182 long nScrollBarSize = Application::GetSettings().GetStyleSettings().GetScrollBarSize();
1183
1184 Point aPreviewPos( maDialogSize.Width(), 0 );
1185 Size aPreviewSize( maDialogSize.Width(), maFlButtons.GetPosPixel().Y() );
1186
1187 Point aFixedBitmapPos( aPreviewPos );
1188 Size aFixedBitmapSize( aPreviewSize );
1189
1190 maSbZoom.Show( sal_False );
1191 maSbZoom.SetPosPixel( Point( aPreviewPos.X(), aPreviewPos.Y() ) );
1192 maSbZoom.SetSizePixel( Size( aPreviewSize.Width() / 4, nScrollBarSize ) );
1193 maNfZoom.Show( sal_False );
1194 maNfZoom.SetPosPixel( Point( aPreviewPos.X() + aPreviewSize.Width() / 4, aPreviewPos.Y() ) );
1195 maNfZoom.SetSizePixel( Size( aPreviewSize.Width() / 6, nScrollBarSize ) );
1196 maNfZoom.SetValue( GetZoomValueFromThumbPos( maSbZoom.GetThumbPos() ) );
1197 maFbJPGPreview.Show( sal_True );
1198
1199 sal_Int32 nZoom = GetZoomValueFromThumbPos( maSbZoom.GetThumbPos() );
1200 double fSizePixelX = static_cast< double >( maSize.Width * nZoom ) / 100.0;
1201 double fSizePixelY = static_cast< double >( maSize.Height * nZoom ) / 100.0;
1202
1203 double fXRatio = fSizePixelX / maSize.Width; // the size of each pixel
1204 double fYRatio = fSizePixelY / maSize.Height;
1205
1206 sal_Bool bHorzSb = fSizePixelX > aFixedBitmapSize.Width();
1207 sal_Bool bVertSb = fSizePixelY > aFixedBitmapSize.Height();
1208 if ( bHorzSb )
1209 {
1210 aFixedBitmapSize.Height() -= nScrollBarSize;
1211
1212 maSbJPGPreviewHorz.Show( sal_True );
1213 maSbJPGPreviewHorz.SetPosPixel( Point( aFixedBitmapPos.X(), aFixedBitmapPos.Y() + aFixedBitmapSize.Height() ) );
1214 maSbJPGPreviewHorz.SetSizePixel( Size( aFixedBitmapSize.Width(), nScrollBarSize ) );
1215 }
1216 else
1217 {
1218 maSbJPGPreviewHorz.Show( sal_False );
1219 }
1220
1221
1222 if ( bVertSb )
1223 {
1224 aFixedBitmapSize.Width() -= nScrollBarSize;
1225
1226 maSbJPGPreviewVert.Show( sal_True );
1227 maSbJPGPreviewVert.SetPosPixel( Point( aFixedBitmapPos.X() + aFixedBitmapSize.Width(), aFixedBitmapPos.Y() ) );
1228 maSbJPGPreviewVert.SetSizePixel( Size( nScrollBarSize, aFixedBitmapSize.Height() ) );
1229 }
1230 else
1231 {
1232 maSbJPGPreviewVert.Show( sal_False );
1233 }
1234
1235 Point aPos( 0, 0 );
1236 Size aSize;
1237 if ( fXRatio > 1.0 )
1238 {
1239 aSize.Width() = maSize.Width > aFixedBitmapSize.Width() ? maSize.Width : aFixedBitmapSize.Width();
1240 aSize.Width() /= static_cast<long int>(fXRatio);
1241 }
1242 else
1243 {
1244 aSize.Width() = maSize.Width < aFixedBitmapSize.Width() ? maSize.Width : aFixedBitmapSize.Width();
1245 aSize.Width() /= static_cast<long int>(fXRatio);
1246 }
1247
1248 if ( fYRatio > 1.0 )
1249 {
1250 aSize.Height() = maSize.Height > aFixedBitmapSize.Height() ? maSize.Height : aFixedBitmapSize.Height();
1251 aSize.Height() /= static_cast<long int>(fYRatio);
1252 }
1253 else
1254 {
1255 aSize.Height() = maSize.Height < aFixedBitmapSize.Height() ? maSize.Height : aFixedBitmapSize.Height();
1256 aSize.Height() /= static_cast<long int>(fYRatio);
1257 }
1258
1259 if ( aSize.Width() < maSize.Width )
1260 {
1261 sal_Int32 nXDiff = static_cast< sal_Int32 >( ( ( ( maSize.Width - aSize.Width() ) * maSbJPGPreviewHorz.GetThumbPos() ) / 100.0 ) );
1262 aPos.X() += nXDiff;
1263 }
1264 if ( aSize.Height() < maSize.Height )
1265 {
1266 sal_Int32 nYDiff = static_cast< sal_Int32 >( ( ( ( maSize.Height - aSize.Height() ) * maSbJPGPreviewVert.GetThumbPos() ) / 100.0 ) );
1267 aPos.Y() += nYDiff;
1268 }
1269
1270 Bitmap aCroppedBitmap( maBitmap );
1271 aCroppedBitmap.Crop( Rectangle( aPos, aSize ) );
1272 aSize = aCroppedBitmap.GetSizePixel();
1273 aSize = Size( static_cast<long int>(aSize.Width() * fXRatio), static_cast<long int>(aSize.Height() * fYRatio) );
1274 aCroppedBitmap.Scale( aSize );
1275
1276 if ( aSize.Width() > aFixedBitmapSize.Width() )
1277 aSize.Width() = aFixedBitmapSize.Width();
1278 if ( aSize.Height() > aFixedBitmapSize.Height() )
1279 aSize.Height() = aFixedBitmapSize.Height();
1280 Point aPoint( aFixedBitmapPos );
1281 if ( aSize.Width() < aFixedBitmapSize.Width() )
1282 aPoint.X() += ( aFixedBitmapSize.Width() - aSize.Width() ) / 2;
1283 if ( aSize.Height() < aFixedBitmapSize.Height() )
1284 aPoint.Y() += ( aFixedBitmapSize.Height() - aSize.Height() ) / 2;
1285
1286 maFbJPGPreview.SetPosPixel( aPoint );
1287 maFbJPGPreview.SetSizePixel( aSize );
1288 maFbJPGPreview.SetBitmap( aCroppedBitmap );
1289
1290 SetOutputSizePixel( Size( maDialogSize.Width() * 2, maDialogSize.Height() ) );
1291
1292 maFlButtons.SetSizePixel( Size( maRectFlButtons.GetWidth() * 2, maRectFlButtons.GetHeight() ) );
1293 maBtnHelp.SetPosPixel( Point( maRectBtnHelp.Left() + maDialogSize.Width(), maRectBtnHelp.Top() ) );
1294 maBtnOK.SetPosPixel( Point( maRectBtnOK.Left() + maDialogSize.Width(), maRectBtnOK.Top() ) );
1295 maBtnCancel.SetPosPixel( Point( maRectBtnCancel.Left() + maDialogSize.Width(), maRectBtnCancel.Top() ) );
1296 }
1297 else
1298 {
1299 maSbZoom.Show( sal_False );
1300 maNfZoom.Show( sal_False );
1301 maFbJPGPreview.Show( sal_False );
1302 maSbJPGPreviewHorz.Show( sal_False );
1303 maSbJPGPreviewVert.Show( sal_False );
1304
1305 SetOutputSizePixel( maDialogSize );
1306
1307 maFlButtons.SetSizePixel( Size( maRectFlButtons.GetWidth(), maRectFlButtons.GetHeight() ) );
1308 maBtnHelp.SetPosPixel( Point( maRectBtnHelp.Left(), maRectBtnHelp.Top() ) );
1309 maBtnOK.SetPosPixel( Point( maRectBtnOK.Left(), maRectBtnOK.Top() ) );
1310 maBtnCancel.SetPosPixel( Point( maRectBtnCancel.Left(), maRectBtnCancel.Top() ) );
1311 }
1312 }
1313
updateControls()1314 void ExportDialog::updateControls()
1315 {
1316 GetGraphicStream();
1317
1318 // Size Controls
1319 if ( !mbIsPixelFormat )
1320 {
1321 awt::Size aSize100thmm( maSize );
1322 Size aSize( LogicToLogic( Size( aSize100thmm.Width * 100, aSize100thmm.Height * 100 ), MAP_100TH_MM,
1323 MapMode( GetMapUnit( maLbSizeX.GetSelectEntryPos() ) ) ) );
1324 maMfSizeX.SetValue( aSize.Width() );
1325 maMfSizeY.SetValue( aSize.Height() );
1326 }
1327 else
1328 {
1329 MapUnit aMapUnit( GetMapUnit( maLbSizeX.GetSelectEntryPos() ) );
1330 if ( aMapUnit == MAP_PIXEL )
1331 { // calculating pixel count via resolution and original graphic size
1332 maMfSizeX.SetDecimalDigits( 0 );
1333 maMfSizeY.SetDecimalDigits( 0 );
1334 maMfSizeX.SetValue( maSize.Width );
1335 maMfSizeY.SetValue( maSize.Height );
1336 }
1337 else
1338 {
1339 maMfSizeX.SetDecimalDigits( 2 );
1340 maMfSizeY.SetDecimalDigits( 2 );
1341 double fRatio;
1342 switch( GetMapUnit( maLbSizeX.GetSelectEntryPos() ) )
1343 {
1344 case MAP_INCH : fRatio = static_cast< double >( maResolution.Width ) * 0.0254; break;
1345 case MAP_MM : fRatio = static_cast< double >( maResolution.Width ) * 0.001; break;
1346 case MAP_POINT :fRatio = ( static_cast< double >( maResolution.Width ) * 0.0254 ) / 72.0; break;
1347 default:
1348 case MAP_CM : fRatio = static_cast< double >( maResolution.Width ) * 0.01; break;
1349 }
1350 maMfSizeX.SetValue( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Width * 100 ) / fRatio ) + 0.5 ) );
1351 maMfSizeY.SetValue( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Height * 100 ) / fRatio ) + 0.5 ) );
1352 }
1353 }
1354 sal_Int32 nResolution = 0;
1355 switch( maLbResolution.GetSelectEntryPos() )
1356 {
1357 case 0 : nResolution = maResolution.Width / 100; break; // pixels / cm
1358 case 2 : nResolution = maResolution.Width; break; // pixels / meter
1359 default:
1360 case 1 : nResolution = static_cast< sal_Int32 >(maResolution.Width * 0.0254); break; // pixels / inch
1361 }
1362 maNfResolution.SetValue( nResolution );
1363
1364 if ( maSbCompression.IsVisible() )
1365 maSbCompression.SetThumbPos( maNfCompression.GetValue() );
1366
1367 // updating estimated size
1368 sal_Int64 nRealFileSize( mpTempStream->Tell() );
1369 if ( mbIsPixelFormat )
1370 {
1371 String aEst( nRealFileSize ? msEstimatedSizePix2 : msEstimatedSizePix1 );
1372 sal_Int64 nRawFileSize( GetRawFileSize() );
1373 xub_StrLen nInd = aEst.Search( '%' );
1374 aEst.Replace( nInd, 2, ImpValueOfInKB( nRawFileSize ) );
1375
1376 if ( nRealFileSize )
1377 {
1378 nInd = aEst.Search( '%', nInd );
1379 aEst.Replace( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
1380 }
1381 maFtEstimatedSize.SetText( aEst );
1382 }
1383 else
1384 {
1385 if ( mnMaxFilesizeForRealtimePreview )
1386 {
1387 String aEst( msEstimatedSizeVec );
1388 xub_StrLen nInd = aEst.Search( '%', 0 );
1389 aEst.Replace( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
1390 maFtEstimatedSize.SetText( aEst );
1391 }
1392 }
1393 updatePreview();
1394
1395 // EPS
1396 if ( maRbEPSLevel1.IsVisible() )
1397 {
1398 sal_Bool bEnabled = maRbEPSLevel1.IsChecked() == sal_False;
1399 maRbEPSColorFormat1.Enable( bEnabled );
1400 maRbEPSColorFormat2.Enable( bEnabled );
1401 maRbEPSCompressionLZW.Enable( bEnabled );
1402 maRbEPSCompressionNone.Enable( bEnabled );
1403 }
1404 }
1405
~ExportDialog()1406 ExportDialog::~ExportDialog()
1407 {
1408 delete mpFilterOptionsItem;
1409 delete mpOptionsItem;
1410 }
1411
1412
1413 /*************************************************************************
1414 |*
1415 |* Speichert eingestellte Werte in ini-Datei
1416 |*
1417 \************************************************************************/
IMPL_LINK(ExportDialog,UpdateHdl,void *,EMPTYARG)1418 IMPL_LINK( ExportDialog, UpdateHdl, void *, EMPTYARG )
1419 {
1420 updateControls();
1421 return 0;
1422 }
1423
IMPL_LINK(ExportDialog,UpdateHdlMtfSizeX,void *,EMPTYARG)1424 IMPL_LINK( ExportDialog, UpdateHdlMtfSizeX, void *, EMPTYARG )
1425 {
1426 double fRatio = static_cast< double >( maOriginalSize.Height ) / maOriginalSize.Width;
1427
1428 if ( mbIsPixelFormat )
1429 {
1430 switch( GetMapUnit( maLbSizeX.GetSelectEntryPos() ) )
1431 {
1432 case MAP_INCH : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * maMfSizeX.GetValue() / 100.0 + 0.5 ); break;
1433 case MAP_CM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.01 * maMfSizeX.GetValue() / 100.0 + 0.5 ); break;
1434 case MAP_MM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.001 * maMfSizeX.GetValue() / 100.0 + 0.5 ); break;
1435 case MAP_POINT : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * maMfSizeX.GetValue() / 100.0 * 72 + 0.5 ); break;
1436 default:
1437 case MAP_PIXEL : maSize.Width = maMfSizeX.GetValue(); break;
1438 }
1439 maSize.Height = static_cast< sal_Int32 >( fRatio * maSize.Width + 0.5 );
1440 }
1441 else
1442 {
1443 Fraction aFract( 1, 100 );
1444 sal_Int32 nWidth = maMfSizeX.GetValue();
1445 sal_Int32 nHeight= static_cast< sal_Int32 >( nWidth * fRatio );
1446 const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) );
1447 MapMode aSourceMapMode( GetMapUnit( maLbSizeX.GetSelectEntryPos() ),Point(), aFract, aFract );
1448 Size aDest( LogicToLogic( aSource, aSourceMapMode, MAP_100TH_MM ) );
1449
1450 maSize.Width = aDest.Width();
1451 if ( mbPreserveAspectRatio )
1452 maSize.Height = aDest.Height();
1453 }
1454 updateControls();
1455 return 0;
1456 }
1457
IMPL_LINK(ExportDialog,UpdateHdlMtfSizeY,void *,EMPTYARG)1458 IMPL_LINK( ExportDialog, UpdateHdlMtfSizeY, void *, EMPTYARG )
1459 {
1460 double fRatio = static_cast< double >( maOriginalSize.Width ) / maOriginalSize.Height;
1461
1462 if ( mbIsPixelFormat )
1463 {
1464 switch( GetMapUnit( maLbSizeX.GetSelectEntryPos() ) )
1465 {
1466 case MAP_INCH : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * maMfSizeY.GetValue() / 100.0 + 0.5 ); break;
1467 case MAP_CM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.01 * maMfSizeY.GetValue() / 100.0 + 0.5 ); break;
1468 case MAP_MM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.001 * maMfSizeY.GetValue() / 100.0 + 0.5 ); break;
1469 case MAP_POINT : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * maMfSizeY.GetValue() / 100.0 * 72 + 0.5 ); break;
1470 default:
1471 case MAP_PIXEL : maSize.Height = maMfSizeY.GetValue(); break;
1472 }
1473 maSize.Width = static_cast< sal_Int32 >( fRatio * maSize.Height + 0.5 );
1474 }
1475 else
1476 {
1477 Fraction aFract( 1, 100 );
1478 sal_Int32 nHeight= maMfSizeY.GetValue();
1479 sal_Int32 nWidth = static_cast< sal_Int32 >( nHeight * fRatio );
1480 const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) );
1481 MapMode aSourceMapMode( GetMapUnit( maLbSizeX.GetSelectEntryPos() ),Point(), aFract, aFract );
1482 Size aDest( LogicToLogic( aSource, aSourceMapMode, MAP_100TH_MM ) );
1483
1484 maSize.Height = aDest.Height();
1485 if ( mbPreserveAspectRatio )
1486 maSize.Width = aDest.Width();
1487 }
1488 updateControls();
1489 return 0;
1490 }
1491
IMPL_LINK(ExportDialog,UpdateHdlNfResolution,void *,EMPTYARG)1492 IMPL_LINK( ExportDialog, UpdateHdlNfResolution, void *, EMPTYARG )
1493 {
1494 sal_Int32 nResolution = maNfResolution.GetValue();
1495 if ( maLbResolution.GetSelectEntryPos() == 0 ) // pixels / cm
1496 nResolution *= 100;
1497 else if ( maLbResolution.GetSelectEntryPos() == 1 ) // pixels / inch
1498 nResolution = static_cast< sal_Int32 >( ( ( static_cast< double >( nResolution ) + 0.5 ) / 0.0254 ) );
1499 maResolution.Width = nResolution;
1500 maResolution.Height= nResolution;
1501
1502 updateControls();
1503 return 0;
1504 }
1505
IMPL_LINK(ExportDialog,SbCompressionUpdateHdl,void *,EMPTYARG)1506 IMPL_LINK( ExportDialog, SbCompressionUpdateHdl, void *, EMPTYARG )
1507 {
1508 maNfCompression.SetValue( maSbCompression.GetThumbPos() );
1509 updateControls();
1510 return 0;
1511 }
1512
IMPL_LINK(ExportDialog,OK,void *,EMPTYARG)1513 IMPL_LINK( ExportDialog, OK, void *, EMPTYARG )
1514 {
1515 // writing config parameter
1516
1517
1518 mrFltCallPara.aFilterData = GetFilterData( sal_True );
1519 EndDialog( RET_OK );
1520
1521 return 0;
1522 }
1523