crashtesting: assert on reimport of docx export of ooo102874-2.doc
[LibreOffice.git] / svtools / source / filter / exportdialog.cxx
blob0347385cbae4369e3c6acfea30b20a7c6f06fd50
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <algorithm>
24 #include <comphelper/propertyvalue.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <tools/stream.hxx>
27 #include <tools/fract.hxx>
28 #include <utility>
29 #include <vcl/graphicfilter.hxx>
30 #include <vcl/FilterConfigItem.hxx>
31 #include <svtools/strings.hrc>
32 #include <svtools/svtresid.hxx>
33 #include <svtools/DocumentToGraphicRenderer.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/awt/Size.hpp>
36 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
37 #include <com/sun/star/drawing/XDrawView.hpp>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/frame/XController.hpp>
40 #include <com/sun/star/graphic/PrimitiveFactory2D.hpp>
41 #include <com/sun/star/geometry/AffineMatrix2D.hpp>
42 #include <com/sun/star/io/XStream.hpp>
43 #include <unotools/streamwrap.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/outdev.hxx>
46 #include <vcl/graph.hxx>
47 #include <rtl/ustrbuf.hxx>
48 #include <basegfx/matrix/b2dhommatrix.hxx>
49 #include "exportdialog.hxx"
51 #define FORMAT_UNKNOWN 0
52 #define FORMAT_JPG 1
53 #define FORMAT_PNG 2
54 #define FORMAT_BMP 3
55 #define FORMAT_GIF 4
56 #define FORMAT_TIF 10
57 #define FORMAT_WMF 12
58 #define FORMAT_EMF 13
59 #define FORMAT_EPS 14
60 #define FORMAT_SVG 16
61 #define FORMAT_WEBP 17
63 #define UNIT_DEFAULT -1
64 #define UNIT_INCH 0
65 #define UNIT_CM 1
66 #define UNIT_MM 2
67 #define UNIT_POINT 3
68 #define UNIT_PIXEL 4
69 #define UNIT_MAX_ID UNIT_PIXEL
71 using namespace ::com::sun::star;
73 static sal_Int16 GetFilterFormat(std::u16string_view rExt)
75 sal_Int16 nFormat = FORMAT_UNKNOWN;
76 if ( rExt == u"JPG" )
77 nFormat = FORMAT_JPG;
78 else if ( rExt == u"PNG" )
79 nFormat = FORMAT_PNG;
80 else if ( rExt == u"BMP" )
81 nFormat = FORMAT_BMP;
82 else if ( rExt == u"GIF" )
83 nFormat = FORMAT_GIF;
84 else if ( rExt == u"TIF" )
85 nFormat = FORMAT_TIF;
86 else if ( rExt == u"WMF" )
87 nFormat = FORMAT_WMF;
88 else if ( rExt == u"EMF" )
89 nFormat = FORMAT_EMF;
90 else if ( rExt == u"EPS" )
91 nFormat = FORMAT_EPS;
92 else if ( rExt == u"SVG" )
93 nFormat = FORMAT_SVG;
94 else if ( rExt == u"WEBP" )
95 nFormat = FORMAT_WEBP;
96 return nFormat;
99 static MapUnit GetMapUnit( sal_Int32 nUnit )
101 MapUnit aMapUnit( MapUnit::MapPixel );
102 switch( nUnit )
104 case UNIT_INCH : aMapUnit = MapUnit::MapInch; break;
105 case UNIT_CM : aMapUnit = MapUnit::MapCM; break;
106 case UNIT_MM : aMapUnit = MapUnit::MapMM; break;
107 case UNIT_POINT : aMapUnit = MapUnit::MapPoint; break;
108 case UNIT_PIXEL : aMapUnit = MapUnit::MapPixel; break;
110 return aMapUnit;
113 sal_Int32 ExportDialog::GetDefaultUnit() const
115 sal_Int32 nDefaultUnit;
116 switch( mrFltCallPara.eFieldUnit )
118 // case FieldUnit::NONE :
119 // case FieldUnit::PERCENT :
120 // case FieldUnit::CUSTOM :
121 case FieldUnit::KM : // PASSTHROUGH INTENDED
122 case FieldUnit::M :
123 case FieldUnit::MM_100TH :
124 case FieldUnit::CM :
125 default: nDefaultUnit = UNIT_CM; break;
127 case FieldUnit::MILE : // PASSTHROUGH INTENDED
128 case FieldUnit::FOOT :
129 case FieldUnit::TWIP :
130 case FieldUnit::PICA :
131 case FieldUnit::INCH : nDefaultUnit = UNIT_INCH; break;
133 case FieldUnit::MM : nDefaultUnit = UNIT_MM; break;
134 case FieldUnit::POINT : nDefaultUnit = UNIT_POINT; break;
136 return nDefaultUnit;
139 static basegfx::B2DRange GetShapeRangeForXShape( const uno::Reference< drawing::XShape >& rxShape,
140 const uno::Reference< graphic::XPrimitiveFactory2D >& rxPrimitiveFactory2D, const uno::Sequence< beans::PropertyValue >& rViewInformation )
142 basegfx::B2DRange aShapeRange;
144 const uno::Sequence< beans::PropertyValue > aParams;
145 const uno::Sequence< uno::Reference< graphic::XPrimitive2D > > aPrimitiveSequence( rxPrimitiveFactory2D->createPrimitivesFromXShape( rxShape, aParams ) );
147 for( const auto& rPrimitive : aPrimitiveSequence )
149 const geometry::RealRectangle2D aRect( rPrimitive->getRange( rViewInformation ) );
150 aShapeRange.expand( basegfx::B2DTuple( aRect.X1, aRect.Y1 ) );
151 aShapeRange.expand( basegfx::B2DTuple( aRect.X2, aRect.Y2 ) );
153 return aShapeRange;
156 uno::Sequence< beans::PropertyValue > ExportDialog::GetFilterData( bool bUpdateConfig )
158 if ( bUpdateConfig )
160 sal_Int32 nUnit = mxLbSizeX->get_active();
161 if ( nUnit < 0 )
162 nUnit = UNIT_CM;
164 if ( ( mnInitialResolutionUnit == UNIT_DEFAULT ) && ( nUnit == GetDefaultUnit() ) )
165 nUnit = UNIT_DEFAULT;
167 // updating ui configuration
168 if ( mbIsPixelFormat )
170 if ( nUnit > UNIT_MAX_ID )
171 nUnit = UNIT_PIXEL;
173 sal_Int32 nResolution = mxNfResolution->get_value();
174 if ( nResolution < 1 )
175 nResolution = 96;
177 mpOptionsItem->WriteInt32(u"PixelExportUnit"_ustr, nUnit);
178 mpOptionsItem->WriteInt32(u"PixelExportResolution"_ustr, nResolution);
179 mpOptionsItem->WriteInt32(u"PixelExportResolutionUnit"_ustr, mxLbResolution->get_active());
181 else
183 if ( nUnit >= UNIT_PIXEL )
184 nUnit = UNIT_CM;
186 mpOptionsItem->WriteInt32(u"VectorExportUnit"_ustr, nUnit);
190 FilterConfigItem* pFilterOptions;
191 if ( bUpdateConfig )
192 pFilterOptions = mpFilterOptionsItem.get();
193 else
195 uno::Sequence< beans::PropertyValue > aFilterData( mpFilterOptionsItem->GetFilterData() );
196 pFilterOptions = new FilterConfigItem( &aFilterData );
199 static constexpr OUString sLogicalWidth(u"LogicalWidth"_ustr);
200 static constexpr OUString sLogicalHeight(u"LogicalHeight"_ustr);
201 if ( mbIsPixelFormat )
203 pFilterOptions->WriteInt32(u"PixelWidth"_ustr, maSize.Width );
204 pFilterOptions->WriteInt32(u"PixelHeight"_ustr, maSize.Height );
205 if ( maResolution.Width && maResolution.Height )
207 const double f100thmmPerPixelX = 100000.0 / maResolution.Width;
208 const double f100thmmPerPixelY = 100000.0 / maResolution.Height;
209 sal_Int32 nLogicalWidth = static_cast< sal_Int32 >( f100thmmPerPixelX * maSize.Width );
210 sal_Int32 nLogicalHeight= static_cast< sal_Int32 >( f100thmmPerPixelY * maSize.Height );
211 if ( nLogicalWidth && nLogicalHeight )
213 pFilterOptions->WriteInt32( sLogicalWidth, nLogicalWidth );
214 pFilterOptions->WriteInt32( sLogicalHeight, nLogicalHeight );
218 else
220 pFilterOptions->WriteInt32( sLogicalWidth, maSize.Width );
221 pFilterOptions->WriteInt32( sLogicalHeight, maSize.Height );
223 switch ( mnFormat )
225 case FORMAT_JPG :
227 sal_Int32 nColor = mxLbColorDepth->get_active();
228 if ( nColor == 1 )
229 nColor = 0;
230 else
231 nColor = 1;
232 pFilterOptions->WriteInt32(u"ColorMode"_ustr, nColor);
233 assert(mpSbCompression);
234 pFilterOptions->WriteInt32(u"Quality"_ustr, static_cast<sal_Int32>(mpSbCompression->get_value()));
236 break;
238 case FORMAT_PNG :
240 assert(mpSbCompression);
241 pFilterOptions->WriteInt32(u"Compression"_ustr, static_cast<sal_Int32>(mpSbCompression->get_value()));
242 sal_Int32 nInterlace = 0;
243 if ( mxCbInterlaced->get_active() )
244 nInterlace++;
245 pFilterOptions->WriteInt32(u"Interlaced"_ustr, nInterlace);
246 sal_Int32 nValue = 0;
247 if ( mxCbSaveTransparency->get_active() )
248 nValue++;
249 pFilterOptions->WriteInt32(u"Translucent"_ustr, nValue);
251 break;
253 case FORMAT_BMP :
255 pFilterOptions->WriteInt32(u"Color"_ustr, mxLbColorDepth->get_active() + 1);
256 pFilterOptions->WriteBool(u"RLE_Coding"_ustr, mxCbRLEEncoding->get_active());
258 break;
260 case FORMAT_GIF :
262 sal_Int32 nValue = 0;
263 if ( mxCbInterlaced->get_active() )
264 nValue++;
265 pFilterOptions->WriteInt32(u"Interlaced"_ustr, nValue);
267 nValue = 0;
268 if (mxCbSaveTransparency->get_active())
269 nValue++;
270 pFilterOptions->WriteInt32(u"Translucent"_ustr, nValue);
272 break;
274 case FORMAT_EPS :
276 sal_Int32 nCheck = 0;
277 if ( mxCbEPSPreviewTIFF->get_active() )
278 nCheck++;
279 if ( mxCbEPSPreviewEPSI->get_active() )
280 nCheck += 2;
281 pFilterOptions->WriteInt32(u"Preview"_ustr, nCheck);
283 nCheck = 1;
284 if ( mxRbEPSLevel2->get_active() )
285 nCheck++;
286 pFilterOptions->WriteInt32(u"Version"_ustr, nCheck);
288 nCheck = 1;
289 if ( mxRbEPSColorFormat2->get_active() )
290 nCheck++;
291 pFilterOptions->WriteInt32(u"ColorFormat"_ustr, nCheck);
293 nCheck = 1;
294 if ( mxRbEPSCompressionNone->get_active() )
295 nCheck++;
296 pFilterOptions->WriteInt32(u"CompressionMode"_ustr, nCheck);
298 break;
300 case FORMAT_WEBP :
302 assert(mpSbCompression);
303 pFilterOptions->WriteInt32(u"Quality"_ustr, static_cast<sal_Int32>(mpSbCompression->get_value()));
304 pFilterOptions->WriteBool(u"Lossless"_ustr, mxCbLossless->get_active());
306 break;
310 uno::Sequence< beans::PropertyValue > aRet( pFilterOptions->GetFilterData() );
311 if ( !bUpdateConfig )
312 delete pFilterOptions;
313 return aRet;
317 awt::Size ExportDialog::GetOriginalSize()
319 basegfx::B2DRange aShapesRange;
321 if ( mxPage.is () )
323 uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY );
324 if ( xPagePropSet.is() )
326 sal_Int32 nWidth = 0;
327 sal_Int32 nHeight= 0;
328 css::uno::Any aAny;
329 aAny = xPagePropSet->getPropertyValue(u"Width"_ustr);
330 aAny >>= nWidth;
331 aAny = xPagePropSet->getPropertyValue(u"Height"_ustr);
332 aAny >>= nHeight;
333 aShapesRange = basegfx::B2DRange( 0, 0, nWidth, nHeight );
336 else if (mxShapes.is() || mxShape.is())
338 uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory = graphic::PrimitiveFactory2D::create( mxContext );
340 basegfx::B2DHomMatrix aViewTransformation( Application::GetDefaultDevice()->GetViewTransformation() );
341 css::geometry::AffineMatrix2D aTransformation;
342 aTransformation.m00 = aViewTransformation.get(0,0);
343 aTransformation.m01 = aViewTransformation.get(0,1);
344 aTransformation.m02 = aViewTransformation.get(0,2);
345 aTransformation.m10 = aViewTransformation.get(1,0);
346 aTransformation.m11 = aViewTransformation.get(1,1);
347 aTransformation.m12 = aViewTransformation.get(1,2);
349 uno::Sequence< beans::PropertyValue > aViewInformation{ comphelper::makePropertyValue(
350 u"ViewTransformation"_ustr, aTransformation) };
352 if ( mxShape.is() )
353 aShapesRange = GetShapeRangeForXShape( mxShape, xPrimitiveFactory, aViewInformation );
354 else if ( mxShapes.is() )
356 const sal_Int32 nCount = mxShapes->getCount();
357 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
359 uno::Reference< drawing::XShape > xShape;
360 mxShapes->getByIndex( nIndex ) >>= xShape;
361 aShapesRange.expand( GetShapeRangeForXShape( xShape, xPrimitiveFactory, aViewInformation ) );
365 else if (!mbGraphicsSource)
367 DocumentToGraphicRenderer aRenderer( mxSourceDocument, mbExportSelection);
368 const sal_Int32 nCurrentPage = aRenderer.getCurrentPage();
369 const Size aSize = aRenderer.getDocumentSizeIn100mm( nCurrentPage);
370 return awt::Size( aSize.Width(), aSize.Height());
372 return awt::Size( static_cast<sal_Int32>(aShapesRange.getWidth()), static_cast<sal_Int32>(aShapesRange.getHeight()) );
375 void ExportDialog::GetGraphicSource()
377 if (mxGraphic.is())
378 return;
380 if ( !mxSourceDocument.is() )
381 return;
383 uno::Reference< frame::XModel > xModel( mxSourceDocument, uno::UNO_QUERY );
384 if ( !xModel.is() )
385 return;
387 uno::Reference< frame::XController > xController( xModel->getCurrentController() );
388 if ( !xController.is() )
389 return;
391 if ( mbExportSelection ) // check if there is a selection
393 if (DocumentToGraphicRenderer::isShapeSelected( mxShapes, mxShape, xController))
394 mbGraphicsSource = true;
396 if ( !mxShape.is() && !mxShapes.is() && mbGraphicsSource )
398 uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY );
399 if ( xDrawView.is() )
401 uno::Reference< drawing::XDrawPage > xCurrentPage( xDrawView->getCurrentPage() );
402 if ( xCurrentPage.is() )
404 mxPage = std::move(xCurrentPage); // exporting whole page
408 // For !mbGraphicsSource the mxSourceDocument is used, from
409 // which XRenderable can query XController and
410 // XSelectionSupplier the same.
413 void ExportDialog::GetGraphicStream()
415 if ( !IsTempExportAvailable() )
417 mpTempStream.reset(new SvMemoryStream());
418 return;
421 bool bRecreateOutputStream = mpTempStream->Tell() == 0;
423 static uno::Sequence< beans::PropertyValue > aOldFilterData;
424 uno::Sequence< beans::PropertyValue > aNewFilterData( GetFilterData( false ) );
425 if ( aOldFilterData != aNewFilterData )
427 aOldFilterData = aNewFilterData;
428 bRecreateOutputStream = true;
432 if ( bRecreateOutputStream )
434 mpTempStream.reset(new SvMemoryStream());
436 uno::Reference< graphic::XGraphic > xGraphic;
437 if (!mbGraphicsSource && !mxGraphic.is())
439 // Create a Graphic to be used below.
440 DocumentToGraphicRenderer aRenderer( mxSourceDocument, mbExportSelection);
441 const sal_Int32 nCurrentPage = aRenderer.getCurrentPage();
442 const Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels( nCurrentPage);
444 const Size aTargetSizePixel( mbIsPixelFormat ?
445 Size( maSize.Width, maSize.Height) :
446 aDocumentSizePixel );
448 Graphic aGraphic( aRenderer.renderToGraphic( nCurrentPage,
449 aDocumentSizePixel, aTargetSizePixel, COL_WHITE, /*bExtOutDevData=*/false));
450 xGraphic = aGraphic.GetXGraphic();
453 if ( mxGraphic.is() || xGraphic.is() )
455 Graphic aGraphic( mxGraphic.is() ? mxGraphic : xGraphic );
457 if ( aGraphic.GetType() == GraphicType::Bitmap )
459 Size aSizePixel( aGraphic.GetSizePixel() );
460 if( maSize.Width && maSize.Height &&
461 ( ( maSize.Width != aSizePixel.Width() ) ||
462 ( maSize.Height != aSizePixel.Height() ) ) )
464 BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
465 // export: use highest quality
466 aBmpEx.Scale( Size( maSize.Width, maSize.Height ), BmpScaleFlag::Lanczos );
467 aGraphic = aBmpEx;
471 GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
472 const sal_uInt16 nFilter = rFilter.GetExportFormatNumberForShortName( maExt );
473 if ( rFilter.IsExportPixelFormat( nFilter ) )
475 mpTempStream->SetResizeOffset(1024);
476 mpTempStream->SetStreamSize(1024);
477 rFilter.ExportGraphic( aGraphic, u"", *mpTempStream, nFilter, &aNewFilterData );
480 else
482 uno::Reference< lang::XComponent > xSourceDoc;
483 if ( mxPage.is() )
484 xSourceDoc.set( mxPage, uno::UNO_QUERY_THROW );
485 else if ( mxShapes.is() )
486 xSourceDoc.set( mxShapes, uno::UNO_QUERY_THROW );
487 else if ( mxShape.is() )
488 xSourceDoc.set( mxShape, uno::UNO_QUERY_THROW );
489 if ( xSourceDoc.is() )
491 uno::Reference < io::XStream > xStream( new utl::OStreamWrapper( *mpTempStream ) );
492 uno::Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
494 OUString sFormat( maExt );
495 uno::Sequence< beans::PropertyValue > aDescriptor{
496 comphelper::makePropertyValue(u"OutputStream"_ustr, xOutputStream),
497 comphelper::makePropertyValue(u"FilterName"_ustr, sFormat),
498 comphelper::makePropertyValue(u"FilterData"_ustr, aNewFilterData)
501 uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter =
502 drawing::GraphicExportFilter::create( mxContext );
504 xGraphicExporter->setSourceDocument( xSourceDoc );
505 xGraphicExporter->filter( aDescriptor );
510 catch( uno::Exception& )
513 // ups
518 sal_uInt32 ExportDialog::GetRawFileSize() const
520 sal_uInt64 nRawFileSize = 0;
521 if ( mbIsPixelFormat )
523 sal_Int32 nBitsPerPixel = 24;
524 OUString aEntry(mxLbColorDepth->get_active_text());
525 if ( ms1BitThreshold == aEntry )
526 nBitsPerPixel = 1;
527 else if ( ms8BitGrayscale == aEntry )
528 nBitsPerPixel = 8;
529 else if ( ms8BitColorPalette == aEntry )
530 nBitsPerPixel = 8;
531 else if ( ms24BitColor == aEntry )
532 nBitsPerPixel = 24;
534 if ( mbIsPixelFormat )
536 nRawFileSize = ( maSize.Width * nBitsPerPixel + 7 ) &~ 7; // rounding up to 8 bits
537 nRawFileSize /= 8; // in bytes
538 nRawFileSize *= maSize.Height;
540 if ( nRawFileSize > SAL_MAX_UINT32 )
541 nRawFileSize = 0;
543 return static_cast< sal_uInt32 >( nRawFileSize );
546 // checks if the source dimension/resolution is not too big
547 // to determine the exact graphic output size and preview for jpg
548 bool ExportDialog::IsTempExportAvailable() const
550 return GetRawFileSize() < o3tl::make_unsigned( mnMaxFilesizeForRealtimePreview );
553 ExportDialog::ExportDialog(FltCallDialogParameter& rPara,
554 css::uno::Reference< css::uno::XComponentContext > xContext,
555 const css::uno::Reference< css::lang::XComponent >& rxSourceDocument,
556 bool bExportSelection, bool bIsPixelFormat, bool bGraphicsSource,
557 const css::uno::Reference< css::graphic::XGraphic >& rxGraphic)
558 : GenericDialogController(rPara.pWindow, u"svt/ui/graphicexport.ui"_ustr, u"GraphicExportDialog"_ustr)
559 , mrFltCallPara(rPara)
560 , mxContext(std::move(xContext))
561 , mxSourceDocument(rxSourceDocument)
562 , mxGraphic(rxGraphic)
563 , msEstimatedSizePix1(SvtResId(STR_SVT_ESTIMATED_SIZE_PIX_1))
564 , msEstimatedSizePix2(SvtResId(STR_SVT_ESTIMATED_SIZE_PIX_2))
565 , msEstimatedSizeVec(SvtResId(STR_SVT_ESTIMATED_SIZE_VEC))
566 , ms1BitThreshold(SvtResId(STR_SVT_1BIT_THRESHOLD))
567 , ms8BitGrayscale(SvtResId(STR_SVT_8BIT_GRAYSCALE))
568 , ms8BitColorPalette(SvtResId(STR_SVT_8BIT_COLOR_PALETTE))
569 , ms24BitColor(SvtResId(STR_SVT_24BIT_TRUE_COLOR))
570 , maExt(rPara.aFilterExt)
571 , mnFormat(FORMAT_UNKNOWN)
572 , mnMaxFilesizeForRealtimePreview(0)
573 , mpTempStream(new SvMemoryStream())
574 , maOriginalSize(awt::Size(0, 0))
575 , mbIsPixelFormat(bIsPixelFormat)
576 , mbExportSelection(bExportSelection)
577 , mbGraphicsSource(bGraphicsSource)
578 , mpSbCompression(nullptr)
579 , mpNfCompression(nullptr)
580 , mxMfSizeX(m_xBuilder->weld_spin_button(u"widthmf"_ustr))
581 , mxLbSizeX(m_xBuilder->weld_combo_box(u"widthlb"_ustr))
582 , mxMfSizeY(m_xBuilder->weld_spin_button( u"heightmf"_ustr))
583 , mxFtResolution(m_xBuilder->weld_label(u"resolutionft"_ustr))
584 , mxNfResolution(m_xBuilder->weld_spin_button(u"resolutionmf"_ustr))
585 , mxLbResolution(m_xBuilder->weld_combo_box(u"resolutionlb"_ustr))
586 , mxColorDepth(m_xBuilder->weld_widget(u"colordepth"_ustr))
587 , mxLbColorDepth(m_xBuilder->weld_combo_box(u"colordepthlb"_ustr))
588 , mxJPGWEBPQuality(m_xBuilder->weld_widget(u"jpgwebpquality"_ustr))
589 , mxPNGCompression(m_xBuilder->weld_widget(u"pngcompression"_ustr))
590 , mxSbPngCompression(m_xBuilder->weld_scale(u"compressionpngsb"_ustr))
591 , mxNfPngCompression(m_xBuilder->weld_spin_button(u"compressionpngnf"_ustr))
592 , mxSbJpgWebpCompression(m_xBuilder->weld_scale(u"compressionjpgwebpsb"_ustr))
593 , mxNfJpgWebpCompression(m_xBuilder->weld_spin_button(u"compressionjpgwebpnf"_ustr))
594 , mxCbLossless(m_xBuilder->weld_check_button(u"losslesscb"_ustr))
595 , mxMode(m_xBuilder->weld_widget(u"mode"_ustr))
596 , mxCbInterlaced(m_xBuilder->weld_check_button(u"interlacedcb"_ustr))
597 , mxBMPCompression(m_xBuilder->weld_widget(u"bmpcompression"_ustr))
598 , mxCbRLEEncoding(m_xBuilder->weld_check_button(u"rlecb"_ustr))
599 , mxDrawingObjects(m_xBuilder->weld_widget(u"drawingobjects"_ustr))
600 , mxCbSaveTransparency(m_xBuilder->weld_check_button(u"savetransparencycb"_ustr))
601 , mxEncoding(m_xBuilder->weld_widget(u"encoding"_ustr))
602 , mxRbBinary(m_xBuilder->weld_radio_button(u"binarycb"_ustr))
603 , mxRbText(m_xBuilder->weld_radio_button(u"textcb"_ustr))
604 , mxEPSGrid(m_xBuilder->weld_widget(u"epsgrid"_ustr))
605 , mxModifyDimension(m_xBuilder->weld_radio_button(u"modifydimensionscb"_ustr))
606 , mxModifyResolution(m_xBuilder->weld_radio_button(u"modifyresolutioncb"_ustr))
607 , mxCbEPSPreviewTIFF(m_xBuilder->weld_check_button(u"tiffpreviewcb"_ustr))
608 , mxCbEPSPreviewEPSI(m_xBuilder->weld_check_button(u"epsipreviewcb"_ustr))
609 , mxRbEPSLevel1(m_xBuilder->weld_radio_button(u"level1rb"_ustr))
610 , mxRbEPSLevel2(m_xBuilder->weld_radio_button(u"level2rb"_ustr))
611 , mxRbEPSColorFormat1(m_xBuilder->weld_radio_button(u"color1rb"_ustr))
612 , mxRbEPSColorFormat2(m_xBuilder->weld_radio_button(u"color2rb"_ustr))
613 , mxRbEPSCompressionLZW(m_xBuilder->weld_radio_button(u"compresslzw"_ustr))
614 , mxRbEPSCompressionNone(m_xBuilder->weld_radio_button(u"compressnone"_ustr))
615 , mxInfo(m_xBuilder->weld_widget(u"information"_ustr))
616 , mxFtEstimatedSize(m_xBuilder->weld_label(u"estsizeft"_ustr))
617 , mxBtnOK(m_xBuilder->weld_button(u"ok"_ustr))
619 GetGraphicSource();
621 maExt = maExt.toAsciiUpperCase();
623 OUString aFilterConfigPath( u"Office.Common/Filter/Graphic/Export/"_ustr );
624 mpOptionsItem.reset(new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData ));
625 aFilterConfigPath += maExt;
626 mpFilterOptionsItem.reset(new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData ));
628 mnInitialResolutionUnit = mbIsPixelFormat
629 ? mpOptionsItem->ReadInt32(u"PixelExportUnit"_ustr, UNIT_DEFAULT)
630 : mpOptionsItem->ReadInt32(u"VectorExportUnit"_ustr, UNIT_DEFAULT);
632 mnMaxFilesizeForRealtimePreview = std::max(
633 mpOptionsItem->ReadInt32(u"MaxFilesizeForRealtimePreview"_ustr, 0), sal_Int32(0));
634 mxFtEstimatedSize->set_label(u" \n "_ustr);
636 m_xDialog->set_title(m_xDialog->get_title().replaceFirst("%1", maExt)); //Set dialog title
638 mnFormat = GetFilterFormat( maExt );
640 Size aResolution( Application::GetDefaultDevice()->LogicToPixel(Size(100, 100), MapMode(MapUnit::MapCM)) );
641 maResolution.Width = aResolution.Width();
642 maResolution.Height= aResolution.Height();
644 if ( mxGraphic.is() )
646 Graphic aGraphic(mxGraphic);
647 Size aSize = aGraphic.GetSizePixel();
648 maSize = awt::Size(aSize.getWidth(), aSize.getHeight());
649 double f100thmmPerPixel = 100000.0 / static_cast< double >( maResolution.Width );
650 maOriginalSize = awt::Size(
651 static_cast< sal_Int32 >( f100thmmPerPixel * maSize.Width ),
652 static_cast< sal_Int32 >( f100thmmPerPixel * maSize.Height ) );
654 else
656 maOriginalSize = GetOriginalSize();
657 if ( bIsPixelFormat )
659 double fPixelsPer100thmm = static_cast< double >( maResolution.Width ) / 100000.0;
660 maSize = awt::Size( static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Width ) + 0.5 ),
661 static_cast< sal_Int32 >( ( fPixelsPer100thmm * maOriginalSize.Height ) + 0.5 ) );
663 else
665 maSize = maOriginalSize;
668 setupControls();
670 // Size
671 mxLbSizeX->connect_changed( LINK( this, ExportDialog, SelectListBoxHdl ) );
673 if (mpSbCompression)
674 mpSbCompression->connect_value_changed(LINK(this, ExportDialog, SbCompressionUpdateHdl));
675 if (mpNfCompression)
676 mpNfCompression->connect_value_changed(LINK(this, ExportDialog, SelectHdl));
678 mxMfSizeX->connect_value_changed( LINK( this, ExportDialog, UpdateHdlMtfSizeX ) );
679 mxMfSizeY->connect_value_changed( LINK( this, ExportDialog, UpdateHdlMtfSizeY ) );
681 mxNfResolution->connect_value_changed( LINK( this, ExportDialog, UpdateHdlNfResolution ) );
682 mxLbResolution->connect_changed( LINK( this, ExportDialog, SelectListBoxHdl ) );
684 mxLbColorDepth->connect_changed( LINK( this, ExportDialog, SelectListBoxHdl ) );
686 mxCbInterlaced->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
688 mxCbLossless->connect_toggled( LINK( this, ExportDialog, UpdateHdlLossless ) );
690 mxCbSaveTransparency->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
692 mxModifyDimension->connect_toggled( LINK( this, ExportDialog, UpdateLock ) );
693 mxModifyResolution->connect_toggled( LINK( this, ExportDialog, UpdateLock ) );
695 mxCbEPSPreviewTIFF->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
696 mxCbEPSPreviewEPSI->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
698 mxRbEPSCompressionLZW->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
699 mxRbEPSCompressionNone->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
701 mxRbBinary->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
702 mxRbText->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
704 // BMP
705 mxCbRLEEncoding->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
707 // EPS
708 mxRbEPSLevel1->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
709 mxRbEPSLevel2->connect_toggled( LINK( this, ExportDialog, UpdateHdl ) );
711 mxBtnOK->connect_clicked( LINK( this, ExportDialog, OK ) );
713 updateControls();
716 void ExportDialog::setupSizeControls()
718 sal_Int32 nUnit = mnInitialResolutionUnit;
719 if (nUnit == UNIT_DEFAULT)
720 nUnit = GetDefaultUnit();
722 if (!mbIsPixelFormat)
724 mxFtResolution->hide();
725 mxNfResolution->hide();
726 mxLbResolution->hide();
727 mxLbSizeX->remove( UNIT_PIXEL ); // removing pixel
728 if ( nUnit >= UNIT_PIXEL )
729 nUnit = UNIT_CM;
731 else if ( nUnit > UNIT_MAX_ID )
732 nUnit = UNIT_PIXEL;
733 if ( nUnit < 0 )
734 nUnit = UNIT_CM;
735 mxLbSizeX->set_active( static_cast< sal_uInt16 >( nUnit ) );
737 if ( !mbIsPixelFormat ) // TODO: (metafileresolutionsupport) should be supported for vector formats also... this makes
738 return;
740 // sense eg for bitmap fillings in metafiles, to preserve high dpi output
741 // (atm without special vector support the bitmaps are rendered with 96dpi)
742 sal_Int32 nResolution = mpOptionsItem->ReadInt32(u"PixelExportResolution"_ustr, 96);
743 if ( nResolution < 1 )
744 nResolution = 96;
745 mxNfResolution->set_value( nResolution );
747 sal_Int32 nResolutionUnit = mpOptionsItem->ReadInt32(u"PixelExportResolutionUnit"_ustr, 1);
748 if ( ( nResolutionUnit < 0 ) || ( nResolutionUnit > 2 ) )
749 nResolutionUnit = 1;
750 mxLbResolution->set_active( static_cast< sal_uInt16 >( nResolutionUnit ) );
753 void ExportDialog::createFilterOptions()
755 switch( mnFormat )
757 case FORMAT_JPG :
759 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(u"ColorMode"_ustr, 0);
760 if ( nColor == 1 )
761 nColor = 0;
762 else
763 nColor = 1;
764 mxLbColorDepth->append_text( ms8BitGrayscale );
765 mxLbColorDepth->append_text( ms24BitColor );
766 mxLbColorDepth->set_active( nColor );
767 mxColorDepth->show();
769 // Quality
770 mxJPGWEBPQuality->show();
771 sal_Int32 nQuality = mpFilterOptionsItem->ReadInt32(u"Quality"_ustr, 75);
772 if ((nQuality < 1 ) || (nQuality > 100))
773 nQuality = 75;
774 mpSbCompression = mxSbJpgWebpCompression.get();
775 mpNfCompression = mxNfJpgWebpCompression.get();
776 mpSbCompression->set_range(1, 100);
777 mpNfCompression->set_range(1, 100);
778 mpNfCompression->set_value(nQuality);
779 mxCbLossless->hide(); // only for WebP
781 break;
782 case FORMAT_PNG :
784 // Compression 1..9
785 mxPNGCompression->show();
786 sal_Int32 nCompression = mpFilterOptionsItem->ReadInt32(u"Compression"_ustr, 6);
787 if ( ( nCompression < 1 ) || ( nCompression > 9 ) )
788 nCompression = 6;
790 mpSbCompression = mxSbPngCompression.get();
791 mpNfCompression = mxNfPngCompression.get();
792 mpSbCompression->set_range(1, 9);
793 mpNfCompression->set_range(1, 9);
794 mpNfCompression->set_value(nCompression);
796 // Interlaced
797 mxMode->show();
798 mxCbInterlaced->set_active(mpFilterOptionsItem->ReadInt32(u"Interlaced"_ustr, 0) != 0);
800 // Transparency
801 mxDrawingObjects->show();
802 mxCbSaveTransparency->set_active(mpFilterOptionsItem->ReadInt32(u"Translucent"_ustr, 1) != 0);
804 break;
805 case FORMAT_BMP :
807 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(u"Color"_ustr, 0);
808 if ( nColor == 0 )
809 nColor = 6;
810 else
811 nColor--;
812 mxLbColorDepth->append_text( ms1BitThreshold );
813 mxLbColorDepth->append_text( ms8BitGrayscale );
814 mxLbColorDepth->append_text( ms8BitColorPalette );
815 mxLbColorDepth->append_text( ms24BitColor );
816 mxLbColorDepth->set_active( nColor );
817 mxColorDepth->show();
819 // RLE coding
820 mxBMPCompression->show();
821 mxCbRLEEncoding->set_active(mpFilterOptionsItem->ReadBool(u"RLE_Coding"_ustr, true));
823 break;
824 case FORMAT_GIF :
826 // Interlaced
827 mxMode->show();
828 mxCbInterlaced->set_active(mpFilterOptionsItem->ReadInt32(u"Interlaced"_ustr, 1) != 0);
830 // Transparency
831 mxDrawingObjects->show();
832 mxCbSaveTransparency->set_active(mpFilterOptionsItem->ReadInt32(u"Translucent"_ustr, 1) != 0);
834 break;
835 case FORMAT_EPS :
837 mxEPSGrid->show();
839 sal_Int32 nPreview = mpFilterOptionsItem->ReadInt32(u"Preview"_ustr, 0);
840 sal_Int32 nVersion = mpFilterOptionsItem->ReadInt32(u"Version"_ustr, 2);
841 sal_Int32 nColor = mpFilterOptionsItem->ReadInt32(u"ColorFormat"_ustr, 0);
842 sal_Int32 nCompr = mpFilterOptionsItem->ReadInt32(u"CompressionMode"_ustr, 2);
844 mpFilterOptionsItem->ReadInt32(u"TextMode"_ustr, 0);
846 mxCbEPSPreviewTIFF->set_active( ( nPreview & 1 ) != 0 );
847 mxCbEPSPreviewEPSI->set_active( ( nPreview & 2 ) != 0 );
849 mxRbEPSLevel1->set_active( nVersion == 1 );
850 mxRbEPSLevel2->set_active( nVersion == 2 );
852 mxRbEPSColorFormat1->set_active( nColor == 1 );
853 mxRbEPSColorFormat2->set_active( nColor != 1 );
855 mxRbEPSCompressionLZW->set_active( nCompr == 1 );
856 mxRbEPSCompressionNone->set_active( nCompr != 1 );
858 break;
859 case FORMAT_WEBP :
861 // Quality
862 mxJPGWEBPQuality->show();
863 sal_Int32 nQuality = mpFilterOptionsItem->ReadInt32(u"Quality"_ustr, 75);
864 if ((nQuality < 1 ) || (nQuality > 100))
865 nQuality = 75;
866 mpSbCompression = mxSbJpgWebpCompression.get();
867 mpNfCompression = mxNfJpgWebpCompression.get();
868 mpSbCompression->set_range(1, 100);
869 mpNfCompression->set_range(1, 100);
870 mpNfCompression->set_value(nQuality);
872 // Lossless
873 mxCbLossless->set_active(mpFilterOptionsItem->ReadBool(u"Lossless"_ustr, true));
874 UpdateHdlLossless(*mxCbLossless);
876 break;
880 void ExportDialog::setupControls()
882 setupSizeControls();
883 createFilterOptions();
885 if (mnMaxFilesizeForRealtimePreview || mbIsPixelFormat)
886 mxInfo->show();
889 static OUString ImpValueOfInKB( sal_Int64 rVal )
891 double fVal( static_cast<double>( rVal ) );
892 fVal /= ( 1 << 10 );
893 fVal += 0.05;
894 OUStringBuffer aVal( OUString::number( fVal ) );
895 sal_Int32 nX( aVal.indexOf( '.' ) );
896 if ( nX > 0 )
897 aVal.setLength( nX + 2 );
898 return aVal.makeStringAndClear();
901 void ExportDialog::updateControls()
903 // Size Controls
904 if ( !mbIsPixelFormat )
906 awt::Size aSize100thmm( maSize );
907 Size aSize( OutputDevice::LogicToLogic( Size(aSize100thmm.Width * 100, aSize100thmm.Height * 100),
908 MapMode(MapUnit::Map100thMM),
909 MapMode( GetMapUnit( mxLbSizeX->get_active() ) ) ) );
910 mxMfSizeX->set_value( aSize.Width() );
911 mxMfSizeY->set_value( aSize.Height() );
913 else
915 MapUnit aMapUnit( GetMapUnit( mxLbSizeX->get_active() ) );
916 if ( aMapUnit == MapUnit::MapPixel )
917 { // calculating pixel count via resolution and original graphic size
918 mxMfSizeX->set_digits( 0 );
919 mxMfSizeY->set_digits( 0 );
920 mxMfSizeX->set_value( maSize.Width );
921 mxMfSizeY->set_value( maSize.Height );
923 else
925 mxMfSizeX->set_digits( 2 );
926 mxMfSizeY->set_digits( 2 );
927 double fRatio;
928 switch( GetMapUnit( mxLbSizeX->get_active() ) )
930 case MapUnit::MapInch : fRatio = static_cast< double >( maResolution.Width ) * 0.0254; break;
931 case MapUnit::MapMM : fRatio = static_cast< double >( maResolution.Width ) * 0.001; break;
932 case MapUnit::MapPoint :fRatio = ( static_cast< double >( maResolution.Width ) * 0.0254 ) / 72.0; break;
933 default:
934 case MapUnit::MapCM : fRatio = static_cast< double >( maResolution.Width ) * 0.01; break;
936 mxMfSizeX->set_value( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Width * 100 ) / fRatio ) + 0.5 ) );
937 mxMfSizeY->set_value( static_cast< sal_Int32 >( ( static_cast< double >( maSize.Height * 100 ) / fRatio ) + 0.5 ) );
940 sal_Int32 nResolution = 0;
941 switch( mxLbResolution->get_active() )
943 case 0 : nResolution = maResolution.Width / 100; break; // pixels / cm
944 case 2 : nResolution = maResolution.Width; break; // pixels / meter
945 default:
946 case 1 : nResolution = static_cast< sal_Int32 >(maResolution.Width * 0.0254); break; // pixels / inch
948 mxNfResolution->set_value( nResolution );
950 if (mpSbCompression && mpSbCompression->get_visible() && mpNfCompression)
951 mpSbCompression->set_value(mpNfCompression->get_value());
953 GetGraphicStream();
955 // updating estimated size
956 sal_Int64 nRealFileSize( mpTempStream->Tell() );
957 if ( mbIsPixelFormat )
959 OUString aEst( nRealFileSize ? msEstimatedSizePix2 : msEstimatedSizePix1 );
960 sal_Int64 nRawFileSize( GetRawFileSize() );
961 sal_Int32 nInd = aEst.indexOf( "%" );
962 if (nInd != -1)
963 aEst = aEst.replaceAt( nInd, 2, ImpValueOfInKB( nRawFileSize ) );
965 if ( nRealFileSize && nInd != -1 )
967 nInd = aEst.indexOf( "%", nInd );
968 if (nInd != -1)
969 aEst = aEst.replaceAt( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
971 mxFtEstimatedSize->set_label( aEst );
973 else
975 if ( mnMaxFilesizeForRealtimePreview )
977 OUString aEst( msEstimatedSizeVec );
978 sal_Int32 nInd = aEst.indexOf( "%" );
979 if (nInd != -1)
980 aEst = aEst.replaceAt( nInd, 2, ImpValueOfInKB( nRealFileSize ) );
981 mxFtEstimatedSize->set_label( aEst );
985 // EPS
986 if ( mxRbEPSLevel1->get_visible() )
988 bool bEnabled = !mxRbEPSLevel1->get_active();
989 mxRbEPSColorFormat1->set_sensitive( bEnabled );
990 mxRbEPSColorFormat2->set_sensitive( bEnabled );
991 mxRbEPSCompressionLZW->set_sensitive( bEnabled );
992 mxRbEPSCompressionNone->set_sensitive( bEnabled );
996 ExportDialog::~ExportDialog()
1000 /*************************************************************************
1002 |* stores values set in the ini-file
1004 \************************************************************************/
1005 IMPL_LINK_NOARG(ExportDialog, SelectHdl, weld::SpinButton&, void)
1007 updateControls();
1010 IMPL_LINK_NOARG(ExportDialog, SelectListBoxHdl, weld::ComboBox&, void)
1012 updateControls();
1015 IMPL_LINK_NOARG(ExportDialog, UpdateHdl, weld::Toggleable&, void)
1017 updateControls();
1020 IMPL_LINK_NOARG(ExportDialog, UpdateHdlLossless, weld::Toggleable&, void)
1022 mpSbCompression->set_sensitive(!mxCbLossless->get_active());
1023 mpNfCompression->set_sensitive(!mxCbLossless->get_active());
1024 updateControls();
1027 IMPL_LINK_NOARG(ExportDialog, UpdateLock, weld::Toggleable&, void)
1029 if (mxModifyResolution->get_active())
1031 mxMfSizeY->set_sensitive(false);
1032 mxMfSizeX->set_sensitive(false);
1033 mxNfResolution->set_sensitive(true);
1035 else
1037 mxMfSizeY->set_sensitive(true);
1038 mxMfSizeX->set_sensitive(true);
1039 mxNfResolution->set_sensitive(false);
1041 updateControls();
1045 IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeX, weld::SpinButton&, void)
1047 double fRatio = static_cast< double >( maOriginalSize.Height ) / maOriginalSize.Width;
1049 if ( mbIsPixelFormat )
1051 switch( GetMapUnit( mxLbSizeX->get_active() ) )
1053 case MapUnit::MapInch : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * mxMfSizeX->get_value() / 100.0 + 0.5 ); break;
1054 case MapUnit::MapCM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.01 * mxMfSizeX->get_value() / 100.0 + 0.5 ); break;
1055 case MapUnit::MapMM : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.001 * mxMfSizeX->get_value() / 100.0 + 0.5 ); break;
1056 case MapUnit::MapPoint : maSize.Width = static_cast< sal_Int32 >( static_cast< double >( maResolution.Width ) * 0.0254 * mxMfSizeX->get_value() / 100.0 * 72 + 0.5 ); break;
1057 default:
1058 case MapUnit::MapPixel : maSize.Width = mxMfSizeX->get_value(); break;
1060 maSize.Height = static_cast< sal_Int32 >( fRatio * maSize.Width + 0.5 );
1062 else
1064 Fraction aFract( 1, 100 );
1065 sal_Int32 nWidth = mxMfSizeX->get_value();
1066 sal_Int32 nHeight= static_cast< sal_Int32 >( nWidth * fRatio );
1067 const Size aSource( nWidth, nHeight );
1068 MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), aFract, aFract );
1069 Size aDest(OutputDevice::LogicToLogic(aSource, aSourceMapMode, MapMode(MapUnit::Map100thMM)));
1071 maSize.Width = aDest.Width();
1072 maSize.Height = aDest.Height();
1074 updateControls();
1077 IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeY, weld::SpinButton&, void)
1079 double fRatio = static_cast< double >( maOriginalSize.Width ) / maOriginalSize.Height;
1081 if ( mbIsPixelFormat )
1083 switch( GetMapUnit( mxLbSizeX->get_active() ) )
1085 case MapUnit::MapInch : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * mxMfSizeY->get_value() / 100.0 + 0.5 ); break;
1086 case MapUnit::MapCM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.01 * mxMfSizeY->get_value() / 100.0 + 0.5 ); break;
1087 case MapUnit::MapMM : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.001 * mxMfSizeY->get_value() / 100.0 + 0.5 ); break;
1088 case MapUnit::MapPoint : maSize.Height = static_cast< sal_Int32 >( static_cast< double >( maResolution.Height ) * 0.0254 * mxMfSizeY->get_value() / 100.0 * 72 + 0.5 ); break;
1089 default:
1090 case MapUnit::MapPixel : maSize.Height = mxMfSizeY->get_value(); break;
1092 maSize.Width = static_cast< sal_Int32 >( fRatio * maSize.Height + 0.5 );
1094 else
1096 Fraction aFract( 1, 100 );
1097 sal_Int32 nHeight= mxMfSizeY->get_value();
1098 sal_Int32 nWidth = static_cast< sal_Int32 >( nHeight * fRatio );
1099 const Size aSource( nWidth, nHeight );
1100 MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), aFract, aFract );
1101 Size aDest( OutputDevice::LogicToLogic(aSource, aSourceMapMode, MapMode(MapUnit::Map100thMM)) );
1103 maSize.Height = aDest.Height();
1104 maSize.Width = aDest.Width();
1106 updateControls();
1109 IMPL_LINK_NOARG(ExportDialog, UpdateHdlNfResolution, weld::SpinButton&, void)
1111 auto nResolution = mxNfResolution->get_value();
1112 if ( mxLbResolution->get_active() == 0 ) // pixels / cm
1113 nResolution *= 100;
1114 else if ( mxLbResolution->get_active() == 1 ) // pixels / inch
1115 nResolution = static_cast< sal_Int32 >( ( ( static_cast< double >( nResolution ) + 0.5 ) / 0.0254 ) );
1116 maResolution.Width = nResolution;
1117 maResolution.Height= nResolution;
1119 updateControls();
1122 IMPL_LINK_NOARG(ExportDialog, SbCompressionUpdateHdl, weld::Scale&, void)
1124 mpNfCompression->set_value(mpSbCompression->get_value());
1125 updateControls();
1128 IMPL_LINK_NOARG(ExportDialog, OK, weld::Button&, void)
1130 // writing config parameter
1132 mrFltCallPara.aFilterData = GetFilterData( true );
1133 m_xDialog->response(RET_OK);
1136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */