LibreOffice Module svx (master) 1
UnoGraphicExporter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <vector>
21#include <com/sun/star/io/XOutputStream.hpp>
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/container/XChild.hpp>
24#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <com/sun/star/lang/XComponent.hpp>
26#include <com/sun/star/drawing/XShape.hpp>
27#include <com/sun/star/drawing/XDrawPage.hpp>
28#include <com/sun/star/drawing/XGraphicExportFilter.hpp>
29#include <com/sun/star/graphic/XGraphic.hpp>
30#include <com/sun/star/graphic/XGraphicRenderer.hpp>
31#include <com/sun/star/task/XStatusIndicator.hpp>
32#include <com/sun/star/task/XInteractionHandler.hpp>
33#include <com/sun/star/task/XInteractionContinuation.hpp>
34#include <com/sun/star/uno/XComponentContext.hpp>
35
36#include <tools/debug.hxx>
38#include <tools/urlobj.hxx>
41#include <com/sun/star/drawing/GraphicFilterRequest.hpp>
42#include <com/sun/star/util/URL.hpp>
45#include <vcl/metaact.hxx>
46#include <vcl/svapp.hxx>
47#include <vcl/virdev.hxx>
48#include <svl/outstrm.hxx>
53#include <editeng/numitem.hxx>
54#include <svx/svdograf.hxx>
55#include <svx/xoutbmp.hxx>
56#include <vcl/graphicfilter.hxx>
57#include <svx/svdpage.hxx>
58#include <svx/svdmodel.hxx>
59#include <svx/fmview.hxx>
60#include <svx/fmmodel.hxx>
61#include <svx/unopage.hxx>
62#include <svx/svdoutl.hxx>
63#include <svx/xlineit0.hxx>
64#include <editeng/flditem.hxx>
70#include <memory>
71
72#define MAX_EXT_PIX 2048
73
74using namespace ::comphelper;
75using namespace ::cppu;
76using namespace ::com::sun::star;
77using namespace ::com::sun::star::uno;
78using namespace ::com::sun::star::util;
79using namespace ::com::sun::star::container;
80using namespace ::com::sun::star::drawing;
81using namespace ::com::sun::star::lang;
82using namespace ::com::sun::star::document;
83using namespace ::com::sun::star::beans;
84using namespace ::com::sun::star::task;
85
86// #i102251#
87#include <editeng/editstat.hxx>
88
89namespace {
90
91 struct ExportSettings
92 {
93 OUString maFilterName;
94 OUString maMediaType;
95 URL maURL;
96 css::uno::Reference< css::io::XOutputStream > mxOutputStream;
97 css::uno::Reference< css::graphic::XGraphicRenderer > mxGraphicRenderer;
98 css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
99 css::uno::Reference< css::task::XInteractionHandler > mxInteractionHandler;
100
101 sal_Int32 mnWidth;
102 sal_Int32 mnHeight;
103 bool mbExportOnlyBackground;
104 bool mbScrollText;
105 bool mbUseHighContrast;
106 bool mbTranslucent;
107
108 Sequence< PropertyValue > maFilterData;
109
110 Fraction maScaleX;
111 Fraction maScaleY;
112
113 TriState meAntiAliasing = TRISTATE_INDET;
114
115 explicit ExportSettings(const SdrModel* pSdrModel);
116 };
117
118 ExportSettings::ExportSettings(const SdrModel* pSdrModel)
119 : mnWidth( 0 )
120 ,mnHeight( 0 )
121 ,mbExportOnlyBackground( false )
122 ,mbScrollText( false )
123 ,mbUseHighContrast( false )
124 ,mbTranslucent( false )
125 ,maScaleX( 1, 1 )
126 ,maScaleY( 1, 1 )
127 {
128 if (pSdrModel)
129 {
130 maScaleX = pSdrModel->GetScaleFraction();
131 maScaleY = pSdrModel->GetScaleFraction();
132 }
133 }
134
139 class GraphicExporter : public WeakImplHelper< XGraphicExportFilter, XServiceInfo >
140 {
141 public:
142 GraphicExporter();
143
144 // XFilter
145 virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) override;
146 virtual void SAL_CALL cancel( ) override;
147
148 // XExporter
149 virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) override;
150
151 // XServiceInfo
152 virtual OUString SAL_CALL getImplementationName( ) override;
153 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
154 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
155
156 // XMimeTypeInfo
157 virtual sal_Bool SAL_CALL supportsMimeType( const OUString& MimeTypeName ) override;
158 virtual Sequence< OUString > SAL_CALL getSupportedMimeTypeNames( ) override;
159
160 VclPtr<VirtualDevice> CreatePageVDev( SdrPage* pPage, tools::Long nWidthPixel, tools::Long nHeightPixel ) const;
161
162 DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
163
164 void ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings );
165 bool GetGraphic( ExportSettings const & rSettings, Graphic& aGraphic, bool bVectorType );
166
167 private:
168 Reference< XShape > mxShape;
169 Reference< XDrawPage > mxPage;
170 Reference< XShapes > mxShapes;
172
173 SvxDrawPage* mpUnoPage;
174
175 Link<EditFieldInfo*,void> maOldCalcFieldValueHdl;
176 sal_Int32 mnPageNumber;
177 SdrPage* mpCurrentPage;
178 SdrModel* mpDoc;
179 };
180
183 BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, const Size* pSize )
184 {
185 // use new primitive conversion tooling
186 basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0));
187 sal_uInt32 nMaximumQuadraticPixels(500000);
188
189 if(pSize)
190 {
191 // use 100th mm for primitive bitmap converter tool, input is pixel
192 // use a real OutDev to get the correct DPI, the static LogicToLogic assumes 72dpi which is wrong (!)
193 const Size aSize100th(Application::GetDefaultDevice()->PixelToLogic(*pSize, MapMode(MapUnit::Map100thMM)));
194
195 aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height()));
196
197 // when explicitly pixels are requested from the GraphicExporter, use a *very* high limit
198 // of 16gb (4096x4096 pixels), else use the default for the converters
199 nMaximumQuadraticPixels = std::min(sal_uInt32(4096 * 4096), sal_uInt32(pSize->Width() * pSize->Height()));
200 }
201 else
202 {
203 // use 100th mm for primitive bitmap converter tool
204 const Size aSize100th(OutputDevice::LogicToLogic(rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)));
205
206 aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height()));
207 }
208
209 return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels);
210 }
211
212 Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize )
213 {
214 if( (nWidth == 0) && (nHeight == 0) )
215 return nullptr;
216
217 if( (nWidth == 0) && (nHeight != 0) && (aBoundSize.Height() != 0) )
218 {
219 nWidth = ( nHeight * aBoundSize.Width() ) / aBoundSize.Height();
220 }
221 else if( (nWidth != 0) && (nHeight == 0) && (aBoundSize.Width() != 0) )
222 {
223 nHeight = ( nWidth * aBoundSize.Height() ) / aBoundSize.Width();
224 }
225
226 aOutSize.setWidth( nWidth );
227 aOutSize.setHeight( nHeight );
228
229 return &aOutSize;
230 }
231
232class ImplExportCheckVisisbilityRedirector : public sdr::contact::ViewObjectContactRedirector
233{
234public:
235 explicit ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage );
236
238 const sdr::contact::ViewObjectContact& rOriginal,
239 const sdr::contact::DisplayInfo& rDisplayInfo,
241
242private:
243 SdrPage* mpCurrentPage;
244};
245
246ImplExportCheckVisisbilityRedirector::ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage )
247: mpCurrentPage( pCurrentPage )
248{
249}
250
251void ImplExportCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
252 const sdr::contact::ViewObjectContact& rOriginal,
253 const sdr::contact::DisplayInfo& rDisplayInfo,
255{
257
258 if(pObject)
259 {
260 SdrPage* pPage = mpCurrentPage;
261
262 if(nullptr == pPage)
263 {
264 pPage = pObject->getSdrPageFromSdrObject();
265 }
266
267 if( (pPage == nullptr) || pPage->checkVisibility(rOriginal, rDisplayInfo, false) )
268 {
270 }
271
272 return;
273 }
274 else
275 {
276 // not an object, maybe a page
278 }
279}
280
281GraphicExporter::GraphicExporter()
282: mpUnoPage( nullptr ), mnPageNumber(-1), mpCurrentPage(nullptr), mpDoc( nullptr )
283{
284}
285
286IMPL_LINK(GraphicExporter, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
287{
288 if( pInfo )
289 {
290 if( mpCurrentPage )
291 {
292 pInfo->SetSdrPage( mpCurrentPage );
293 }
294 else if( mnPageNumber != -1 )
295 {
296 const SvxFieldData* pField = pInfo->GetField().GetField();
297 if( dynamic_cast<const SvxPageField*>( pField) )
298 {
299 OUString aPageNumValue;
300 bool bUpper = false;
301
302 switch(mpDoc->GetPageNumType())
303 {
304 case css::style::NumberingType::CHARS_UPPER_LETTER:
305 aPageNumValue += OUStringChar( sal_Unicode((mnPageNumber - 1) % 26 + 'A') );
306 break;
307 case css::style::NumberingType::CHARS_LOWER_LETTER:
308 aPageNumValue += OUStringChar( sal_Unicode((mnPageNumber - 1) % 26 + 'a') );
309 break;
310 case css::style::NumberingType::ROMAN_UPPER:
311 bUpper = true;
312 [[fallthrough]];
313 case css::style::NumberingType::ROMAN_LOWER:
314 aPageNumValue += SvxNumberFormat::CreateRomanString(mnPageNumber, bUpper);
315 break;
316 case css::style::NumberingType::NUMBER_NONE:
317 aPageNumValue = " ";
318 break;
319 default:
320 aPageNumValue += OUString::number( mnPageNumber );
321 }
322
323 pInfo->SetRepresentation( aPageNumValue );
324
325 return;
326 }
327 }
328 }
329
330 maOldCalcFieldValueHdl.Call( pInfo );
331
332 if( pInfo && mpCurrentPage )
333 pInfo->SetSdrPage( nullptr );
334}
335
340VclPtr<VirtualDevice> GraphicExporter::CreatePageVDev( SdrPage* pPage, tools::Long nWidthPixel, tools::Long nHeightPixel ) const
341{
343 MapMode aMM( MapUnit::Map100thMM );
344
345 Point aPoint( 0, 0 );
346 Size aPageSize(pPage->GetSize());
347
348 // use scaling?
349 if( nWidthPixel != 0 )
350 {
351 const Fraction aFrac( nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() );
352
353 aMM.SetScaleX( aFrac );
354
355 if( nHeightPixel == 0 )
356 aMM.SetScaleY( aFrac );
357 }
358
359 if( nHeightPixel != 0 )
360 {
361 const Fraction aFrac( nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() );
362
363 if( nWidthPixel == 0 )
364 aMM.SetScaleX( aFrac );
365
366 aMM.SetScaleY( aFrac );
367 }
368
369 pVDev->SetMapMode( aMM );
370 bool bSuccess(false);
371
372 // #i122820# If available, use pixel size directly
373 if(nWidthPixel && nHeightPixel)
374 {
375 bSuccess = pVDev->SetOutputSizePixel(Size(nWidthPixel, nHeightPixel));
376 }
377 else
378 {
379 bSuccess = pVDev->SetOutputSize(aPageSize);
380 }
381
382 if(bSuccess)
383 {
384 SdrView aView(*mpDoc, pVDev);
385
386 aView.SetPageVisible( false );
387 aView.SetBordVisible( false );
388 aView.SetGridVisible( false );
389 aView.SetHlplVisible( false );
390 aView.SetGlueVisible( false );
391 aView.ShowSdrPage(pPage);
392
393 vcl::Region aRegion (tools::Rectangle( aPoint, aPageSize ) );
394
395 ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
396
397 aView.CompleteRedraw(pVDev, aRegion, &aRedirector);
398 }
399 else
400 {
401 OSL_ENSURE(false, "Could not get a VirtualDevice of requested size (!)");
402 }
403
404 return pVDev;
405}
406
407void GraphicExporter::ParseSettings(const Sequence<PropertyValue>& rDescriptor,
408 ExportSettings& rSettings)
409{
410 Sequence<PropertyValue> aDescriptor = rDescriptor;
411 if (aDescriptor.hasElements())
412 {
414 Sequence<PropertyValue> aFilterData;
415 OUString aFilterOptions;
416 auto it = aMap.find("FilterData");
417 if (it != aMap.end())
418 {
419 it->second >>= aFilterData;
420 }
421 it = aMap.find("FilterOptions");
422 if (it != aMap.end())
423 {
424 it->second >>= aFilterOptions;
425 }
426 if (!aFilterData.hasElements() && !aFilterOptions.isEmpty())
427 {
428 // Allow setting filter data keys from the cmdline.
429 std::vector<PropertyValue> aData
430 = comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
432 if (aFilterData.hasElements())
433 {
434 aMap["FilterData"] <<= aFilterData;
435 aDescriptor = aMap.getAsConstPropertyValueList();
436 }
437 }
438 }
439
440 for( const PropertyValue& rValue : aDescriptor )
441 {
442 if ( rValue.Name == "FilterName" )
443 {
444 rValue.Value >>= rSettings.maFilterName;
445 }
446 else if ( rValue.Name == "MediaType" )
447 {
448 rValue.Value >>= rSettings.maMediaType;
449 }
450 else if ( rValue.Name == "URL" )
451 {
452 if( !( rValue.Value >>= rSettings.maURL ) )
453 {
454 rValue.Value >>= rSettings.maURL.Complete;
455 }
456 }
457 else if ( rValue.Name == "OutputStream" )
458 {
459 rValue.Value >>= rSettings.mxOutputStream;
460 }
461 else if ( rValue.Name == "GraphicRenderer" )
462 {
463 rValue.Value >>= rSettings.mxGraphicRenderer;
464 }
465 else if ( rValue.Name == "StatusIndicator" )
466 {
467 rValue.Value >>= rSettings.mxStatusIndicator;
468 }
469 else if ( rValue.Name == "InteractionHandler" )
470 {
471 rValue.Value >>= rSettings.mxInteractionHandler;
472 }
473 else if( rValue.Name == "Width" ) // for compatibility reasons, deprecated
474 {
475 rValue.Value >>= rSettings.mnWidth;
476 }
477 else if( rValue.Name == "Height" ) // for compatibility reasons, deprecated
478 {
479 rValue.Value >>= rSettings.mnHeight;
480 }
481 else if( rValue.Name == "ExportOnlyBackground" ) // for compatibility reasons, deprecated
482 {
483 rValue.Value >>= rSettings.mbExportOnlyBackground;
484 }
485 else if ( rValue.Name == "FilterData" )
486 {
487 rValue.Value >>= rSettings.maFilterData;
488
489 for( PropertyValue& rDataValue : asNonConstRange(rSettings.maFilterData) )
490 {
491 if ( rDataValue.Name == "Translucent" )
492 {
493 if ( !( rDataValue.Value >>= rSettings.mbTranslucent ) ) // SJ: TODO: The GIF Transparency is stored as int32 in
494 { // configuration files, this has to be changed to boolean
495 sal_Int32 nTranslucent = 0;
496 if ( rDataValue.Value >>= nTranslucent )
497 rSettings.mbTranslucent = nTranslucent != 0;
498 }
499 }
500 else if ( rDataValue.Name == "PixelWidth" )
501 {
502 rDataValue.Value >>= rSettings.mnWidth;
503 }
504 else if ( rDataValue.Name == "PixelHeight" )
505 {
506 rDataValue.Value >>= rSettings.mnHeight;
507 }
508 else if( rDataValue.Name == "Width" ) // for compatibility reasons, deprecated
509 {
510 rDataValue.Value >>= rSettings.mnWidth;
511 rDataValue.Name = "PixelWidth";
512 }
513 else if( rDataValue.Name == "Height" ) // for compatibility reasons, deprecated
514 {
515 rDataValue.Value >>= rSettings.mnHeight;
516 rDataValue.Name = "PixelHeight";
517 }
518 else if ( rDataValue.Name == "ExportOnlyBackground" )
519 {
520 rDataValue.Value >>= rSettings.mbExportOnlyBackground;
521 }
522 else if ( rDataValue.Name == "HighContrast" )
523 {
524 rDataValue.Value >>= rSettings.mbUseHighContrast;
525 }
526 else if ( rDataValue.Name == "PageNumber" )
527 {
528 rDataValue.Value >>= mnPageNumber;
529 }
530 else if ( rDataValue.Name == "ScrollText" )
531 {
532 // #110496# Read flag solitary scroll text metafile
533 rDataValue.Value >>= rSettings.mbScrollText;
534 }
535 else if ( rDataValue.Name == "CurrentPage" )
536 {
537 Reference< XDrawPage > xPage;
538 rDataValue.Value >>= xPage;
539 if( xPage.is() )
540 {
541 SvxDrawPage* pUnoPage = comphelper::getFromUnoTunnel<SvxDrawPage>( xPage );
542 if( pUnoPage && pUnoPage->GetSdrPage() )
543 mpCurrentPage = pUnoPage->GetSdrPage();
544 }
545 }
546 else if ( rDataValue.Name == "ScaleXNumerator" )
547 {
548 sal_Int32 nVal = 1;
549 if( rDataValue.Value >>= nVal )
550 rSettings.maScaleX = Fraction( nVal, rSettings.maScaleX.GetDenominator() );
551 }
552 else if ( rDataValue.Name == "ScaleXDenominator" )
553 {
554 sal_Int32 nVal = 1;
555 if( rDataValue.Value >>= nVal )
556 rSettings.maScaleX = Fraction( rSettings.maScaleX.GetNumerator(), nVal );
557 }
558 else if ( rDataValue.Name == "ScaleYNumerator" )
559 {
560 sal_Int32 nVal = 1;
561 if( rDataValue.Value >>= nVal )
562 rSettings.maScaleY = Fraction( nVal, rSettings.maScaleY.GetDenominator() );
563 }
564 else if ( rDataValue.Name == "ScaleYDenominator" )
565 {
566 sal_Int32 nVal = 1;
567 if( rDataValue.Value >>= nVal )
568 rSettings.maScaleY = Fraction( rSettings.maScaleY.GetNumerator(), nVal );
569 }
570 else if (rDataValue.Name == "AntiAliasing")
571 {
572 bool bAntiAliasing;
573 if (rDataValue.Value >>= bAntiAliasing)
574 rSettings.meAntiAliasing = bAntiAliasing ? TRISTATE_TRUE : TRISTATE_FALSE;
575 }
576 }
577 }
578 }
579
580 // putting the StatusIndicator that we got from the MediaDescriptor into our local FilterData copy
581 if ( rSettings.mxStatusIndicator.is() )
582 {
583 int i = rSettings.maFilterData.getLength();
584 rSettings.maFilterData.realloc( i + 1 );
585 auto pFilterData = rSettings.maFilterData.getArray();
586 pFilterData[ i ].Name = "StatusIndicator";
587 pFilterData[ i ].Value <<= rSettings.mxStatusIndicator;
588 }
589}
590
591bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGraphic, bool bVectorType )
592{
593 if( !mpDoc || !mpUnoPage )
594 return false;
595
596 SdrPage* pPage = mpUnoPage->GetSdrPage();
597 if( !pPage )
598 return false;
599
601 const MapMode aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY );
602
603 SdrOutliner& rOutl=mpDoc->GetDrawOutliner();
604 maOldCalcFieldValueHdl = rOutl.GetCalcFieldValueHdl();
605 rOutl.SetCalcFieldValueHdl( LINK(this, GraphicExporter, CalcFieldValueHdl) );
607
608 // #i102251#
609 const EEControlBits nOldCntrl(rOutl.GetControlWord());
610 EEControlBits nCntrl = nOldCntrl & ~EEControlBits::ONLINESPELLING;
611 rOutl.SetControlWord(nCntrl);
612
613 rtl::Reference<SdrObject> pTempBackgroundShape;
614 std::vector< SdrObject* > aShapes;
615 bool bRet = true;
616
617 // export complete page?
618 if ( !mxShape.is() )
619 {
620 if( rSettings.mbExportOnlyBackground )
621 {
622 const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties();
623
624 if(pCorrectProperties)
625 {
626 pTempBackgroundShape = new SdrRectObj(
627 *mpDoc,
628 tools::Rectangle(Point(0,0), pPage->GetSize()));
629 pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet());
630 pTempBackgroundShape->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
631 pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true);
632 aShapes.push_back(pTempBackgroundShape.get());
633 }
634 }
635 else
636 {
637 const Size aSize( pPage->GetSize() );
638
639 // generate a bitmap to convert it to a pixel format.
640 // For gif pictures there can also be a vector format used (bTranslucent)
641 if ( !bVectorType && !rSettings.mbTranslucent )
642 {
643 tools::Long nWidthPix = 0;
644 tools::Long nHeightPix = 0;
645 if ( rSettings.mnWidth > 0 && rSettings.mnHeight > 0 )
646 {
647 nWidthPix = rSettings.mnWidth;
648 nHeightPix = rSettings.mnHeight;
649 }
650 else
651 {
652 const Size aSizePix( Application::GetDefaultDevice()->LogicToPixel( aSize, aMap ) );
653 if (aSizePix.Width() > MAX_EXT_PIX || aSizePix.Height() > MAX_EXT_PIX)
654 {
655 if (aSizePix.Width() > MAX_EXT_PIX)
656 nWidthPix = MAX_EXT_PIX;
657 else
658 nWidthPix = aSizePix.Width();
659 if (aSizePix.Height() > MAX_EXT_PIX)
660 nHeightPix = MAX_EXT_PIX;
661 else
662 nHeightPix = aSizePix.Height();
663
664 double fWidthDif = static_cast<double>(aSizePix.Width()) / nWidthPix;
665 double fHeightDif = static_cast<double>(aSizePix.Height()) / nHeightPix;
666
667 if (fWidthDif > fHeightDif)
668 nHeightPix = static_cast<tools::Long>(aSizePix.Height() / fWidthDif);
669 else
670 nWidthPix = static_cast<tools::Long>(aSizePix.Width() / fHeightDif);
671 }
672 else
673 {
674 nWidthPix = aSizePix.Width();
675 nHeightPix = aSizePix.Height();
676 }
677 }
678
679 std::unique_ptr<SdrView> xLocalView;
680
681 if (FmFormModel* pFormModel = dynamic_cast<FmFormModel*>(mpDoc))
682 {
683 xLocalView.reset(new FmFormView(*pFormModel, aVDev));
684 }
685 else
686 {
687 xLocalView.reset(new SdrView(*mpDoc, aVDev));
688 }
689
690 ScopedVclPtr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
691
692 if( pVDev )
693 {
694 aGraphic = pVDev->GetBitmapEx( Point(), pVDev->GetOutputSize() );
695 aGraphic.SetPrefMapMode( aMap );
696 aGraphic.SetPrefSize( aSize );
697 }
698 }
699 // create a metafile to export a vector format
700 else
701 {
702 GDIMetaFile aMtf;
703
704 aVDev->SetMapMode( aMap );
705 if( rSettings.mbUseHighContrast )
706 aVDev->SetDrawMode( aVDev->GetDrawMode() | DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient );
707 aVDev->EnableOutput( false );
708 aMtf.Record( aVDev );
709 Size aNewSize;
710
711 // create a view
712 std::unique_ptr< SdrView > pView;
713
714 if (FmFormModel *pFormModel = dynamic_cast<FmFormModel*>(mpDoc))
715 {
716 pView.reset(new FmFormView(*pFormModel, aVDev));
717 }
718 else
719 {
720 pView.reset(new SdrView(*mpDoc, aVDev));
721 }
722
723 pView->SetBordVisible( false );
724 pView->SetPageVisible( false );
725 pView->ShowSdrPage( pPage );
726
727 // tdf#96922 completely deactivate EditView PageVisualization, including
728 // PageBackground (formerly 'wiese').
729 pView->SetPagePaintingAllowed(false);
730
731 const Point aNewOrg( pPage->GetLeftBorder(), pPage->GetUpperBorder() );
732 aNewSize = Size( aSize.Width() - pPage->GetLeftBorder() - pPage->GetRightBorder(),
733 aSize.Height() - pPage->GetUpperBorder() - pPage->GetLowerBorder() );
734 const tools::Rectangle aClipRect( aNewOrg, aNewSize );
735 MapMode aVMap( aMap );
736
737 aVDev->Push();
738 aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
739 aVDev->SetRelativeMapMode( aVMap );
740 aVDev->IntersectClipRegion( aClipRect );
741
742 // Use new StandardCheckVisisbilityRedirector
743 ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
744
745 pView->CompleteRedraw(aVDev, vcl::Region(tools::Rectangle(aNewOrg, aNewSize)), &aRedirector);
746
747 aVDev->Pop();
748
749 aMtf.Stop();
750 aMtf.WindStart();
751 aMtf.SetPrefMapMode( aMap );
752 aMtf.SetPrefSize( aNewSize );
753
754 // AW: Here the current version was filtering out the MetaActionType::CLIPREGIONs
755 // from the metafile. I asked some other developers why this was done, but no
756 // one knew a direct reason. Since it's in for long time, it may be an old
757 // piece of code. MetaFiles save and load ClipRegions with polygons with preserving
758 // the polygons, so a resolution-independent roundtrip is supported. Removed this
759 // code since it destroys some MetaFiles where ClipRegions are used. Anyways,
760 // just filtering them out is a hack, at least the encapsulated content would need
761 // to be clipped geometrically.
762 aGraphic = Graphic(aMtf);
763
764 pView->HideSdrPage();
765
766 if( rSettings.mbTranslucent )
767 {
768 Size aOutSize;
769 aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) );
770 }
771 }
772 }
773 }
774
775 // export only single shape or shape collection
776 else
777 {
778 // build list of SdrObject
779 if( mxShapes.is() )
780 {
781 Reference< XShape > xShape;
782 const sal_Int32 nCount = mxShapes->getCount();
783
784 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
785 {
786 mxShapes->getByIndex( nIndex ) >>= xShape;
788 if( pObj )
789 aShapes.push_back( pObj );
790 }
791 }
792 else
793 {
794 // only one shape
796 if( pObj )
797 aShapes.push_back( pObj );
798 }
799
800 if( aShapes.empty() )
801 bRet = false;
802 }
803
804 if( bRet && !aShapes.empty() )
805 {
806 // special treatment for only one SdrGrafObj that has text
807 bool bSingleGraphic = false;
808
809 if( 1 == aShapes.size() )
810 {
811 if( !bVectorType )
812 {
813 if( auto pGrafObj = dynamic_cast<const SdrGrafObj*>(aShapes.front()) )
814 if (pGrafObj->HasText() )
815 {
816 aGraphic = pGrafObj->GetTransformedGraphic();
817 if ( aGraphic.GetType() == GraphicType::Bitmap )
818 {
819 Size aSizePixel( aGraphic.GetSizePixel() );
820 if( rSettings.mnWidth && rSettings.mnHeight &&
821 ( ( rSettings.mnWidth != aSizePixel.Width() ) ||
822 ( rSettings.mnHeight != aSizePixel.Height() ) ) )
823 {
824 BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
825 // export: use highest quality
826 aBmpEx.Scale( Size( rSettings.mnWidth, rSettings.mnHeight ), BmpScaleFlag::Lanczos );
827 aGraphic = aBmpEx;
828 }
829
830 // #118804# only accept for bitmap graphics, else the
831 // conversion to bitmap will happen anywhere without size control
832 // as evtl. defined in rSettings.mnWidth/mnHeight
833 bSingleGraphic = true;
834 }
835 }
836 }
837 else if( rSettings.mbScrollText )
838 {
839 SdrObject* pObj = aShapes.front();
840 auto pTextObj = DynCastSdrTextObj( pObj);
841 if( pTextObj && pTextObj->HasText() )
842 {
843 tools::Rectangle aScrollRectangle;
844 tools::Rectangle aPaintRectangle;
845
846 const std::unique_ptr< GDIMetaFile > pMtf(
847 pTextObj->GetTextScrollMetaFileAndRectangle(
848 aScrollRectangle, aPaintRectangle ) );
849
850 // take the larger one of the two rectangles (that
851 // should be the bound rect of the retrieved
852 // metafile)
853 tools::Rectangle aTextRect;
854
855 if( aScrollRectangle.Contains( aPaintRectangle ) )
856 aTextRect = aScrollRectangle;
857 else
858 aTextRect = aPaintRectangle;
859
860 // setup pref size and mapmode
861 pMtf->SetPrefSize( aTextRect.GetSize() );
862
863 // set actual origin (mtf is at actual shape
864 // output position)
865 MapMode aLocalMapMode( aMap );
866 aLocalMapMode.SetOrigin(
867 Point( -aPaintRectangle.Left(),
868 -aPaintRectangle.Top() ) );
869 pMtf->SetPrefMapMode( aLocalMapMode );
870
871 pMtf->AddAction( new MetaCommentAction(
872 "XTEXT_SCROLLRECT", 0,
873 reinterpret_cast<sal_uInt8 const*>(&aScrollRectangle),
874 sizeof( tools::Rectangle ) ) );
875 pMtf->AddAction( new MetaCommentAction(
876 "XTEXT_PAINTRECT", 0,
877 reinterpret_cast<sal_uInt8 const*>(&aPaintRectangle),
878 sizeof( tools::Rectangle ) ) );
879
880 aGraphic = Graphic( *pMtf );
881
882 bSingleGraphic = true;
883 }
884 }
885 }
886
887 if( !bSingleGraphic )
888 {
889 // create a metafile for all shapes
891
892 // calculate bound rect for all shapes
893 // tdf#126319 I did not convert all rendering to primities,
894 // that would be to much for this fix. But I did so for the
895 // range calculation to get a valid high quality range.
896 // Based on that the conversion is reliable. With the BoundRect
897 // fetched from the Metafile it was just not possible to get the
898 // examples from the task handled in a way to fit all cases -
899 // due to bad-quality range data from it.
900 basegfx::B2DRange aBound;
901 const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
902
903 {
904 for( SdrObject* pObj : aShapes )
905 {
907 pObj->GetViewContact().getViewIndependentPrimitive2DContainer(aSequence);
908 aBound.expand(aSequence.getB2DRange(aViewInformation2D));
909 }
910 }
911
912 aOut->EnableOutput( false );
913 aOut->SetMapMode( aMap );
914 if( rSettings.mbUseHighContrast )
915 aOut->SetDrawMode( aOut->GetDrawMode() | DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient );
916
917 GDIMetaFile aMtf;
918 aMtf.Clear();
919 aMtf.Record( aOut );
920
921 MapMode aOutMap( aMap );
922 const Size aOnePixelInMtf(
923 Application::GetDefaultDevice()->PixelToLogic(
924 Size(1, 1),
925 aMap));
926 const Size aHalfPixelInMtf(
927 (aOnePixelInMtf.getWidth() + 1) / 2,
928 (aOnePixelInMtf.getHeight() + 1) / 2);
929
930 // tdf#126319 Immediately add needed offset to create metafile,
931 // that avoids to do it later by Metafile::Move what would be expensive
932 aOutMap.SetOrigin(
933 Point(
934 basegfx::fround(-aBound.getMinX() - aHalfPixelInMtf.getWidth()),
935 basegfx::fround(-aBound.getMinY() - aHalfPixelInMtf.getHeight()) ) );
936 aOut->SetRelativeMapMode( aOutMap );
937
938 sdr::contact::DisplayInfo aDisplayInfo;
939
940 if(mpCurrentPage)
941 {
942 if(mpCurrentPage->TRG_HasMasterPage() && pPage->IsMasterPage())
943 {
944 // MasterPage is processed as another page's SubContent
945 aDisplayInfo.SetProcessLayers(mpCurrentPage->TRG_GetMasterPageVisibleLayers());
946 aDisplayInfo.SetSubContentActive(true);
947 }
948 }
949
950 if(!aShapes.empty())
951 {
952 // more effective way to paint a vector of SdrObjects. Hand over the processed page
953 // to have it in the
954 ImplExportCheckVisisbilityRedirector aCheckVisibilityRedirector(mpCurrentPage);
955 sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(*aOut, std::move(aShapes), mpCurrentPage);
956 aMultiObjectPainter.SetViewObjectContactRedirector(&aCheckVisibilityRedirector);
957
958 aMultiObjectPainter.ProcessDisplay(aDisplayInfo);
959 }
960
961 aMtf.Stop();
962 aMtf.WindStart();
963
964 // tdf#126319 Immediately add needed size to target's PrefSize
965 // tdf#150102 Checked that in aBound is indeed the size - 1 (probably
966 // due to old integer stuff using Size()/Rectangle() and getWidth()/GetWidth()
967 // with the old one-less paradigm somewhere), so just correct to the
968 // correct size. Be aware that checking of tdf#126319 is needed, but
969 // looks good in my tests. Still: Changing the central UNO API Metafile
970 // export is always a risky thing, so it will have to show if this will
971 // not influence something else.
972 const Size aBoundSize(
973 basegfx::fround(aBound.getWidth() + 1),
974 basegfx::fround(aBound.getHeight() + 1));
975 aMtf.SetPrefMapMode( aMap );
976 aMtf.SetPrefSize( aBoundSize );
977
978 if( !bVectorType )
979 {
980 Size aOutSize;
981 aGraphic = GetBitmapFromMetaFile( aMtf, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) );
982 }
983 else
984 {
985 aGraphic = aMtf;
986 }
987 }
988 }
989
990 pTempBackgroundShape.clear();
991
992 rOutl.SetCalcFieldValueHdl( maOldCalcFieldValueHdl );
993
994 // #i102251#
995 rOutl.SetControlWord(nOldCntrl);
996
997 return bRet;
998
999}
1000
1001// XFilter
1002sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDescriptor )
1003{
1004 ::SolarMutexGuard aGuard;
1005
1006 if( maGraphic.IsNone() && nullptr == mpUnoPage )
1007 return false;
1008
1009 if( maGraphic.IsNone() && ( nullptr == mpUnoPage->GetSdrPage() || nullptr == mpDoc ) )
1010 return false;
1011
1013
1014 // get the arguments from the descriptor
1015 ExportSettings aSettings(mpDoc);
1016 ParseSettings(aDescriptor, aSettings);
1017
1018 const sal_uInt16 nFilter = !aSettings.maMediaType.isEmpty()
1019 ? rFilter.GetExportFormatNumberForMediaType( aSettings.maMediaType )
1020 : rFilter.GetExportFormatNumberForShortName( aSettings.maFilterName );
1021 bool bVectorType = !rFilter.IsExportPixelFormat( nFilter );
1022
1023 // create the output stuff
1024 Graphic aGraphic = maGraphic;
1025
1026 ErrCode nStatus = ERRCODE_NONE;
1027 if (maGraphic.IsNone())
1028 {
1029 bool bAntiAliasing = SvtOptionsDrawinglayer::IsAntiAliasing();
1030 AllSettings aAllSettings = Application::GetSettings();
1031 StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
1032 bool bUseFontAAFromSystem = aStyleSettings.GetUseFontAAFromSystem();
1033 if (aSettings.meAntiAliasing != TRISTATE_INDET)
1034 {
1035 // This is safe to do globally as we own the solar mutex.
1036 SvtOptionsDrawinglayer::SetAntiAliasing(aSettings.meAntiAliasing == TRISTATE_TRUE, /*bTemporary*/true);
1037 // Opt in to have AA affect font rendering as well.
1038 aStyleSettings.SetUseFontAAFromSystem(false);
1039 aAllSettings.SetStyleSettings(aStyleSettings);
1040 Application::SetSettings(aAllSettings);
1041 }
1042 nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? ERRCODE_NONE : ERRCODE_GRFILTER_FILTERERROR;
1043 if (aSettings.meAntiAliasing != TRISTATE_INDET)
1044 {
1045 SvtOptionsDrawinglayer::SetAntiAliasing(bAntiAliasing, /*bTemporary*/true);
1046 aStyleSettings.SetUseFontAAFromSystem(bUseFontAAFromSystem);
1047 aAllSettings.SetStyleSettings(aStyleSettings);
1048 Application::SetSettings(aAllSettings);
1049 }
1050 }
1051
1052 if( nStatus == ERRCODE_NONE )
1053 {
1054 // export graphic only if it has a size
1055 const Size aGraphSize( aGraphic.GetPrefSize() );
1056 if ( aGraphSize.IsEmpty() )
1057 {
1059 }
1060 else
1061 {
1062 // now we have a graphic, so export it
1063 if( aSettings.mxGraphicRenderer.is() )
1064 {
1065 // render graphic directly into given renderer
1066 aSettings.mxGraphicRenderer->render( aGraphic.GetXGraphic() );
1067 }
1068 else if( aSettings.mxOutputStream.is() )
1069 {
1070 // TODO: Either utilize optional XSeekable functionality for the
1071 // SvOutputStream, or adapt the graphic filter to not seek anymore.
1072 SvMemoryStream aStream( 1024, 1024 );
1073
1074 nStatus = rFilter.ExportGraphic( aGraphic, u"", aStream, nFilter, &aSettings.maFilterData );
1075
1076 // copy temp stream to XOutputStream
1077 SvOutputStream aOutputStream( aSettings.mxOutputStream );
1078 aStream.Seek(0);
1079 aOutputStream.WriteStream( aStream );
1080 }
1081 else
1082 {
1083 INetURLObject aURLObject( aSettings.maURL.Complete );
1084 DBG_ASSERT( aURLObject.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
1085
1086 nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, rFilter, nFilter, &aSettings.maFilterData );
1087 }
1088 }
1089 }
1090
1091 if ( aSettings.mxInteractionHandler.is() && ( nStatus != ERRCODE_NONE ) )
1092 {
1093 Any aInteraction;
1094 Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations{
1095 new ::comphelper::OInteractionApprove()
1096 };
1097
1098 GraphicFilterRequest aErrorCode;
1099 aErrorCode.ErrCode = sal_uInt32(nStatus);
1100 aInteraction <<= aErrorCode;
1101 aSettings.mxInteractionHandler->handle( framework::InteractionRequest::CreateRequest( aInteraction, lContinuations ) );
1102 }
1103 return nStatus == ERRCODE_NONE;
1104}
1105
1106void SAL_CALL GraphicExporter::cancel()
1107{
1108}
1109
1110// XExporter
1111
1113void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XComponent >& xComponent )
1114{
1115 ::SolarMutexGuard aGuard;
1116
1117 mxShapes = nullptr;
1118 mpUnoPage = nullptr;
1119
1120 try
1121 {
1122 // any break inside this one loop while will throw an IllegalArgumentException
1123 do
1124 {
1125 mxPage.set( xComponent, UNO_QUERY );
1126 mxShapes.set( xComponent, UNO_QUERY );
1127 mxShape.set( xComponent, UNO_QUERY );
1128
1129 // Step 1: try a generic XShapes
1130 if( !mxPage.is() && !mxShape.is() && mxShapes.is() )
1131 {
1132 // we do not support empty shape collections
1133 if( 0 == mxShapes->getCount() )
1134 break;
1135
1136 // get first shape to detect corresponding page and model
1137 mxShapes->getByIndex(0) >>= mxShape;
1138 }
1139 else
1140 {
1141 mxShapes = nullptr;
1142 }
1143
1144 // Step 2: try a shape
1145 if( mxShape.is() )
1146 {
1148 {
1149 // This is not a Draw shape, let's see if it's a Writer one.
1150 uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1151 if (!xPropertySet.is())
1152 break;
1153 uno::Reference<graphic::XGraphic> xGraphic(
1154 xPropertySet->getPropertyValue("Graphic"), uno::UNO_QUERY);
1155 if (!xGraphic.is())
1156 break;
1157
1158 maGraphic = Graphic(xGraphic);
1159 if (!maGraphic.IsNone())
1160 return;
1161 else
1162 break;
1163 }
1164
1165 // get page for this shape
1166 Reference< XChild > xChild( mxShape, UNO_QUERY );
1167 if( !xChild.is() )
1168 break;
1169
1170 Reference< XInterface > xInt;
1171 do
1172 {
1173 xInt = xChild->getParent();
1174 mxPage.set( xInt, UNO_QUERY );
1175 if( !mxPage.is() )
1176 xChild.set( xInt, UNO_QUERY );
1177 }
1178 while( !mxPage.is() && xChild.is() );
1179
1180 if( !mxPage.is() )
1181 break;
1182 }
1183
1184 // Step 3: check the page
1185 if( !mxPage.is() )
1186 break;
1187
1188 mpUnoPage = comphelper::getFromUnoTunnel<SvxDrawPage>( mxPage );
1189
1190 if( nullptr == mpUnoPage || nullptr == mpUnoPage->GetSdrPage() )
1191 break;
1192
1193 mpDoc = &mpUnoPage->GetSdrPage()->getSdrModelFromSdrPage();
1194
1195 // Step 4: If we got a generic XShapes test all contained shapes
1196 // if they belong to the same XDrawPage
1197
1198 if( mxShapes.is() )
1199 {
1200 SdrPage* pPage = mpUnoPage->GetSdrPage();
1201 SdrObject* pObj;
1202 Reference< XShape > xShape;
1203
1204 bool bOk = true;
1205
1206 const sal_Int32 nCount = mxShapes->getCount();
1207
1208 // test all but the first shape if they have the same page than
1209 // the first shape
1210 for( sal_Int32 nIndex = 1; bOk && ( nIndex < nCount ); nIndex++ )
1211 {
1212 mxShapes->getByIndex( nIndex ) >>= xShape;
1213 pObj = SdrObject::getSdrObjectFromXShape(xShape);
1214 bOk = pObj && pObj->getSdrPageFromSdrObject() == pPage;
1215 }
1216
1217 if( !bOk )
1218 break;
1219 }
1220
1221 // no errors so far
1222 return;
1223 }
1224 while( false );
1225 }
1226 catch( Exception& )
1227 {
1228 }
1229
1230 throw IllegalArgumentException();
1231}
1232
1233// XServiceInfo
1234OUString SAL_CALL GraphicExporter::getImplementationName( )
1235{
1236 return "com.sun.star.comp.Draw.GraphicExporter";
1237}
1238
1239sal_Bool SAL_CALL GraphicExporter::supportsService( const OUString& ServiceName )
1240{
1241 return cppu::supportsService(this, ServiceName);
1242}
1243
1244Sequence< OUString > SAL_CALL GraphicExporter::getSupportedServiceNames( )
1245{
1246 Sequence< OUString > aSupportedServiceNames { "com.sun.star.drawing.GraphicExportFilter" };
1247 return aSupportedServiceNames;
1248}
1249
1250// XMimeTypeInfo
1251sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& rMimeTypeName )
1252{
1254 sal_uInt16 nCount = rFilter.GetExportFormatCount();
1255 sal_uInt16 nFilter;
1256 for( nFilter = 0; nFilter < nCount; nFilter++ )
1257 {
1258 if( rMimeTypeName == rFilter.GetExportFormatMediaType( nFilter ) )
1259 {
1260 return true;
1261 }
1262 }
1263
1264 return false;
1265}
1266
1267Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames( )
1268{
1270 sal_uInt16 nCount = rFilter.GetExportFormatCount();
1271 sal_uInt16 nFilter;
1272 sal_uInt16 nFound = 0;
1273
1274 Sequence< OUString > aSeq( nCount );
1275 OUString* pStr = aSeq.getArray();
1276
1277 for( nFilter = 0; nFilter < nCount; nFilter++ )
1278 {
1279 OUString aMimeType( rFilter.GetExportFormatMediaType( nFilter ) );
1280 if( !aMimeType.isEmpty() )
1281 {
1282 *pStr++ = aMimeType;
1283 nFound++;
1284 }
1285 }
1286
1287 if( nFound < nCount )
1288 aSeq.realloc( nFound );
1289
1290 return aSeq;
1291}
1292
1293}
1294
1296{
1297 Graphic aGraphic;
1298 try
1299 {
1300 rtl::Reference< GraphicExporter > xExporter( new GraphicExporter() );
1301 Reference< XComponent > xComp( rShape.getUnoShape(), UNO_QUERY_THROW );
1302 xExporter->setSourceDocument( xComp );
1303 ExportSettings aSettings(&rShape.getSdrModelFromSdrObject());
1304 xExporter->GetGraphic( aSettings, aGraphic, true/*bVector*/ );
1305 }
1306 catch( Exception& )
1307 {
1308 TOOLS_WARN_EXCEPTION("svx", "");
1309 }
1310 return aGraphic;
1311}
1312
1313extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1315 css::uno::XComponentContext *,
1316 css::uno::Sequence<css::uno::Any> const &)
1317{
1318 return cppu::acquire(new GraphicExporter);
1319}
1320
1321/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
#define MAX_EXT_PIX
Graphic SvxGetGraphicForShape(SdrObject &rShape)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Draw_GraphicExporter_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
IMPL_LINK(MaskData, PipetteHdl, const OString &, rId, void)
Definition: _bmpmask.cxx:192
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
static void SetSettings(const AllSettings &rSettings)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
void WindStart()
const Size & GetPrefSize() const
void Clear()
void SetPrefMapMode(const MapMode &rMapMode)
void Record(OutputDevice *pOutDev)
const MapMode & GetPrefMapMode() const
void SetPrefSize(const Size &rSize)
sal_uInt16 GetExportFormatNumberForShortName(std::u16string_view rShortName)
static GraphicFilter & GetGraphicFilter()
bool IsExportPixelFormat(sal_uInt16 nFormat)
sal_uInt16 GetExportFormatNumberForMediaType(std::u16string_view rShortName)
ErrCode ExportGraphic(const Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat, const css::uno::Sequence< css::beans::PropertyValue > *pFilterData=nullptr)
sal_uInt16 GetExportFormatCount() const
OUString GetExportFormatMediaType(sal_uInt16 nFormat)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
Size GetPrefSize() const
void SetPrefMapMode(const MapMode &rPrefMapMode)
const GDIMetaFile & GetGDIMetaFile() const
GraphicType GetType() const
bool IsNone() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
void SetPrefSize(const Size &rPrefSize)
INetProtocol GetProtocol() const
void SetOrigin(const Point &rOrigin)
void SetScaleY(const Fraction &rScaleY)
void SetScaleX(const Fraction &rScaleX)
EEControlBits GetControlWord() const
const Link< EditFieldInfo *, void > & GetCalcFieldValueHdl() const
void SetControlWord(EEControlBits nWord)
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
void SetBackgroundColor(const Color &rColor)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:68
const Fraction & GetScaleFraction() const
Definition: svdmodel.hxx:373
SdrPageView * ShowSdrPage(SdrPage *pPage) override
Definition: svdedxv.cxx:131
Abstract DrawObject.
Definition: svdobj.hxx:261
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
Definition: unoshape.cxx:3996
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
Definition: svdobj.cxx:2869
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:279
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:340
SfxStyleSheet * GetStyleSheet() const
Definition: svdpage.hxx:347
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
bool IsMasterPage() const
Definition: svdpage.hxx:462
Size GetSize() const
Definition: svdpage.cxx:1458
sal_Int32 GetUpperBorder() const
Definition: svdpage.cxx:1569
virtual bool checkVisibility(const sdr::contact::ViewObjectContact &rOriginal, const sdr::contact::DisplayInfo &rDisplayInfo, bool bEdit)
this method returns true if the object from the ViewObjectContact should be visible on this page whil...
Definition: svdpage.cxx:1843
sal_Int32 GetRightBorder() const
Definition: svdpage.cxx:1574
sal_Int32 GetLeftBorder() const
Definition: svdpage.cxx:1564
Color GetPageBackgroundColor() const
deprecated returns an averaged background color of this page
Definition: svdpage.cxx:1832
const SdrPageProperties * getCorrectSdrPageProperties() const
Definition: svdpage.cxx:1897
sal_Int32 GetLowerBorder() const
Definition: svdpage.cxx:1579
void SetPageVisible(bool bOn=true)
Definition: svdpntv.hxx:379
virtual void CompleteRedraw(OutputDevice *pOut, const vcl::Region &rReg, sdr::contact::ViewObjectContactRedirector *pRedirector=nullptr)
Definition: svdpntv.cxx:481
void SetHlplVisible(bool bOn=true)
Definition: svdpntv.hxx:385
void SetBordVisible(bool bOn=true)
Definition: svdpntv.hxx:382
void SetGlueVisible(bool bOn=true)
Definition: svdpntv.hxx:387
void SetGridVisible(bool bOn)
Definition: svdpntv.hxx:383
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
bool IsEmpty() const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
bool GetUseFontAAFromSystem() const
void SetUseFontAAFromSystem(bool bUseFontAAFromSystem)
sal_uInt64 Seek(sal_uInt64 nPos)
SdrPage * GetSdrPage() const
Definition: unopage.hxx:77
static OUString CreateRomanString(sal_Int32 nNo, bool bUpper)
static VclPtr< reference_type > Create(Arg &&... arg)
static ErrCode ExportGraphic(const Graphic &rGraphic, const INetURLObject &rURL, GraphicFilter &rFilter, const sal_uInt16 nFormat, const css::uno::Sequence< css::beans::PropertyValue > *pFilterData)
Definition: _xoutbmp.cxx:365
TYPE getWidth() const
TYPE getMinX() const
TYPE getMinY() const
void expand(const Tuple2D< TYPE > &rTuple)
TYPE getHeight() const
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
static css::uno::Reference< css::task::XInteractionRequest > CreateRequest(const css::uno::Any &aRequest, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &lContinuations)
void SetProcessLayers(const SdrLayerIDSet &rSet)
Definition: displayinfo.cxx:35
void SetSubContentActive(bool bNew)
Definition: displayinfo.cxx:77
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
virtual SdrObject * TryToGetSdrObject() const
virtual void createRedirectedPrimitive2DSequence(const sdr::contact::ViewObjectContact &rOriginal, const sdr::contact::DisplayInfo &rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor)
ViewContact & GetViewContact() const
bool Contains(const Point &rPOINT) const
constexpr tools::Long Top() const
constexpr Size GetSize() const
constexpr tools::Long Left() const
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
float u
EEControlBits
EmbeddedObjectRef * pObject
#define ERRCODE_NONE
TriState
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
#define ERRCODE_GRFILTER_FILTERERROR
const Graphic maGraphic
sal_Int32 nIndex
Sequence< sal_Int8 > aSeq
constexpr OUStringLiteral aData
void SetAntiAliasing(bool bOn, bool bTemporary)
B2IRange fround(const B2DRange &rRange)
@ Exception
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::vector< css::beans::PropertyValue > JsonToPropertyValues(const OString &rJson)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
long Long
HashMap_OWString_Interface aMap
const URL maURL
uno::Reference< drawing::XShape > const mxShape
double mnWidth
double mnHeight
const sal_Unicode *const aMimeType[]
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
Definition: svdobj.cxx:3217
BitmapEx convertMetafileToBitmapEx(const GDIMetaFile &rMtf, const basegfx::B2DRange &rTargetRange, const sal_uInt32 nMaximumQuadraticPixels)
Helper to convert any GDIMetaFile to a good quality BitmapEx, using default parameters and graphic::X...
Definition: svdpntv.cxx:107
unsigned char sal_uInt8
unsigned char sal_Bool
sal_uInt16 sal_Unicode