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