LibreOffice Module svx (master)  1
xmlgrhlp.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 <sal/config.h>
21 #include <sal/log.hxx>
22 
23 #include <com/sun/star/embed/XTransactedObject.hpp>
24 #include <com/sun/star/embed/ElementModes.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/io/NotConnectedException.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/util/XCancellable.hpp>
31 #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
32 #include <comphelper/fileformat.h>
34 #include <comphelper/compbase.hxx>
35 #include <cppuhelper/implbase.hxx>
37 
38 #include <rtl/ref.hxx>
40 #include <unotools/streamwrap.hxx>
41 #include <unotools/tempfile.hxx>
42 #include <unotools/saveopt.hxx>
43 #include <vcl/filter/SvmWriter.hxx>
44 #include <vcl/gfxlink.hxx>
45 #include <vcl/metaact.hxx>
46 #include <tools/zcodec.hxx>
47 #include <tools/diagnose_ex.h>
48 
49 #include <vcl/GraphicObject.hxx>
50 #include <vcl/graphicfilter.hxx>
51 #include <svx/xmlgrhlp.hxx>
52 #include <svx/xmleohlp.hxx>
53 
54 #include <algorithm>
55 #include <memory>
56 #include <string_view>
57 #include <utility>
58 
59 using namespace com::sun::star;
60 using namespace com::sun::star::uno;
61 using namespace com::sun::star::io;
62 
63 namespace com::sun::star::uno { class XComponentContext; }
64 
65 constexpr OUStringLiteral XML_GRAPHICSTORAGE_NAME = u"Pictures";
66 constexpr OUStringLiteral XML_GRAPHICOBJECT_URL_BASE = u"vnd.sun.star.GraphicObject:";
67 
68 namespace {
69 
70 const MetaCommentAction* ImplCheckForEPS( GDIMetaFile const & rMtf )
71 {
72  const MetaCommentAction* pComment = nullptr;
73 
74  if ( rMtf.GetActionSize() >= 2
75  && rMtf.GetAction(0)->GetType() == MetaActionType::EPS
76  && rMtf.GetAction(1)->GetType() == MetaActionType::COMMENT
77  && ( static_cast<const MetaCommentAction*>(rMtf.GetAction( 1 ))->GetComment() == "EPSReplacementGraphic" ) )
78  pComment = static_cast<const MetaCommentAction*>(rMtf.GetAction( 1 ));
79 
80  return pComment;
81 }
82 
83 class GraphicInputStream : public cppu::WeakImplHelper<XInputStream>
84 {
85 private:
86  virtual sal_Int32 SAL_CALL readBytes(Sequence<sal_Int8> & aData, sal_Int32 nBytesToRead) override;
87  virtual sal_Int32 SAL_CALL readSomeBytes(Sequence<sal_Int8> & aData, sal_Int32 nMaxBytesToRead) override;
88  virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override;
89  virtual sal_Int32 SAL_CALL available() override;
90  virtual void SAL_CALL closeInput() override;
91 
92 private:
93  utl::TempFile maTempFile;
94  Reference<XInputStream> mxStreamWrapper;
95 
96 public:
97 
98  explicit GraphicInputStream(GraphicObject const & raGraphicObject, const OUString & rMimeType);
99  GraphicInputStream(const GraphicInputStream&) = delete;
100 
101  GraphicInputStream& operator=(const GraphicInputStream&) = delete;
102 
103  bool exists() const
104  {
105  return mxStreamWrapper.is();
106  }
107 };
108 
109 
110 GraphicInputStream::GraphicInputStream(GraphicObject const & aGraphicObject, const OUString & rMimeType)
111 {
112  maTempFile.EnableKillingFile();
113 
114  if (aGraphicObject.GetType() == GraphicType::NONE)
115  return;
116 
117  std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | StreamMode::TRUNC);
118 
119  if (!pStream)
120  return;
121 
122  const Graphic& aGraphic(aGraphicObject.GetGraphic());
123  const GfxLink aGfxLink(aGraphic.GetGfxLink());
124  bool bRet = false;
125 
126  if (aGfxLink.GetDataSize() && aGfxLink.GetData())
127  {
128  if (rMimeType.isEmpty())
129  {
130  pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
131  bRet = (pStream->GetError() == ERRCODE_NONE);
132  }
133  else
134  {
136  bRet = (rFilter.ExportGraphic(aGraphic, u"", *pStream, rFilter.GetExportFormatNumberForMediaType(rMimeType)) == ERRCODE_NONE);
137  }
138  }
139  else
140  {
141  if (aGraphic.GetType() == GraphicType::Bitmap)
142  {
144  OUString aFormat = rMimeType;
145 
146  if (aGraphic.IsAnimated())
147  aFormat = "image/gif";
148  else if (aFormat.isEmpty())
149  aFormat = "image/png";
150 
151  bRet = (rFilter.ExportGraphic(aGraphic, u"", *pStream, rFilter.GetExportFormatNumberForMediaType(aFormat)) == ERRCODE_NONE);
152  }
153  else if (rMimeType.isEmpty() && aGraphic.GetType() == GraphicType::GdiMetafile)
154  {
155  pStream->SetVersion(SOFFICE_FILEFORMAT_8);
156  pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP);
157  SvmWriter aWriter(*pStream);
158  aWriter.Write(aGraphic.GetGDIMetaFile());
159  bRet = (pStream->GetError() == ERRCODE_NONE);
160  }
161  else if (!rMimeType.isEmpty())
162  {
164  bRet = ( rFilter.ExportGraphic( aGraphic, u"", *pStream, rFilter.GetExportFormatNumberForMediaType( rMimeType ) ) == ERRCODE_NONE );
165  }
166  }
167 
168  if (bRet)
169  {
170  pStream->Seek( 0 );
171  mxStreamWrapper = new ::utl::OInputStreamWrapper(std::move(pStream));
172  }
173 }
174 
175 sal_Int32 SAL_CALL GraphicInputStream::readBytes(Sequence<sal_Int8> & rData, sal_Int32 nBytesToRead)
176 {
177  if (!mxStreamWrapper.is())
178  throw NotConnectedException();
179 
180  return mxStreamWrapper->readBytes(rData, nBytesToRead);
181 }
182 
183 sal_Int32 SAL_CALL GraphicInputStream::readSomeBytes(Sequence<sal_Int8>& rData, sal_Int32 nMaxBytesToRead )
184 {
185  if (!mxStreamWrapper.is())
186  throw NotConnectedException() ;
187 
188  return mxStreamWrapper->readSomeBytes(rData, nMaxBytesToRead);
189 }
190 
191 void SAL_CALL GraphicInputStream::skipBytes(sal_Int32 nBytesToSkip)
192 {
193  if (!mxStreamWrapper.is())
194  throw NotConnectedException();
195 
196  mxStreamWrapper->skipBytes(nBytesToSkip);
197 }
198 
199 sal_Int32 SAL_CALL GraphicInputStream::available()
200 {
201  if (!mxStreamWrapper.is())
202  throw NotConnectedException();
203 
204  return mxStreamWrapper->available();
205 }
206 
207 void SAL_CALL GraphicInputStream::closeInput()
208 {
209  if (!mxStreamWrapper.is())
210  throw NotConnectedException();
211 
212  mxStreamWrapper->closeInput();
213 }
214 
215 class SvXMLGraphicOutputStream:
216  public cppu::WeakImplHelper<XOutputStream>
217 {
218 private:
219 
220  // XOutputStream
221  virtual void SAL_CALL writeBytes( const Sequence< sal_Int8 >& rData ) override;
222  virtual void SAL_CALL flush() override;
223  virtual void SAL_CALL closeOutput() override;
224 
225 private:
226 
227  std::unique_ptr<::utl::TempFile> mpTmp;
228  std::unique_ptr<SvStream> mpOStm;
229  Reference< XOutputStream > mxStmWrapper;
230  std::unique_ptr<GraphicObject> mxGrfObj;
231  bool mbClosed;
232 
233 public:
234 
235  SvXMLGraphicOutputStream();
236  virtual ~SvXMLGraphicOutputStream() override;
237  SvXMLGraphicOutputStream(const SvXMLGraphicOutputStream&) = delete;
238  SvXMLGraphicOutputStream& operator=(const SvXMLGraphicOutputStream&) = delete;
239 
240  bool Exists() const { return mxStmWrapper.is(); }
241  const GraphicObject& GetGraphicObject();
242  Graphic GetGraphic();
243 };
244 
245 SvXMLGraphicOutputStream::SvXMLGraphicOutputStream()
246  : mpTmp(new ::utl::TempFile)
247  , mxGrfObj(new GraphicObject)
248  , mbClosed(false)
249 {
250  mpTmp->EnableKillingFile();
251 
252  mpOStm = ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), StreamMode::WRITE | StreamMode::TRUNC );
253 
254  if( mpOStm )
255  mxStmWrapper = new ::utl::OOutputStreamWrapper( *mpOStm );
256 }
257 
258 SvXMLGraphicOutputStream::~SvXMLGraphicOutputStream()
259 {
260  mpTmp.reset();
261  mpOStm.reset();
262 }
263 
264 void SAL_CALL SvXMLGraphicOutputStream::writeBytes( const Sequence< sal_Int8 >& rData )
265 {
266  if( !mxStmWrapper.is() )
267  throw NotConnectedException() ;
268 
269  mxStmWrapper->writeBytes( rData );
270 }
271 
272 void SAL_CALL SvXMLGraphicOutputStream::flush()
273 {
274  if( !mxStmWrapper.is() )
275  throw NotConnectedException() ;
276 
277  mxStmWrapper->flush();
278 }
279 
280 void SAL_CALL SvXMLGraphicOutputStream::closeOutput()
281 {
282  if( !mxStmWrapper.is() )
283  throw NotConnectedException() ;
284 
285  mxStmWrapper->closeOutput();
286  mxStmWrapper.clear();
287 
288  mbClosed = true;
289 }
290 
291 Graphic SvXMLGraphicOutputStream::GetGraphic()
292 {
293  Graphic aGraphic;
294 
295  if (mbClosed && mxGrfObj->GetType() == GraphicType::NONE && mpOStm)
296  {
297  mpOStm->Seek( 0 );
298  sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
299  sal_uInt16 nDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
300  GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, u"", *mpOStm ,nFormat,&nDeterminedFormat);
301 
302  if (nDeterminedFormat == GRFILTER_FORMAT_DONTKNOW)
303  {
304  //Read the first two byte to check whether it is a gzipped stream, is so it may be in wmz or emz format
305  //unzip them and try again
306 
307  sal_uInt8 sFirstBytes[ 2 ];
308 
309  sal_uInt64 nStreamLen = mpOStm->TellEnd();
310  mpOStm->Seek( 0 );
311 
312  if ( nStreamLen == 0 )
313  {
314  SvLockBytes* pLockBytes = mpOStm->GetLockBytes();
315  if ( pLockBytes )
316  pLockBytes->SetSynchronMode();
317 
318  nStreamLen = mpOStm->TellEnd();
319  mpOStm->Seek( 0 );
320  }
321  if( nStreamLen >= 2 )
322  {
323  //read two byte
324  mpOStm->ReadBytes(sFirstBytes, 2);
325 
326  if( sFirstBytes[0] == 0x1f && sFirstBytes[1] == 0x8b )
327  {
328  SvMemoryStream aDest;
329  ZCodec aZCodec( 0x8000, 0x8000 );
330  aZCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/true);
331  mpOStm->Seek( 0 );
332  aZCodec.Decompress( *mpOStm, aDest );
333 
334  if (aZCodec.EndCompression())
335  {
336  sal_uInt64 nStreamLen_ = aDest.TellEnd();
337  if (nStreamLen_ > 0)
338  {
339  aDest.Seek(0);
340  GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, u"", aDest ,nFormat,&nDeterminedFormat );
341  }
342  }
343  }
344  }
345  }
346  }
347 
348  if (aGraphic.GetType() != GraphicType::NONE)
349  {
350  mpOStm.reset();
351  mpTmp.reset();
352  }
353  return aGraphic;
354 }
355 
356 const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
357 {
358  Graphic aGraphic(GetGraphic());
359  if (aGraphic.GetType() != GraphicType::NONE)
360  {
361  mxGrfObj.reset(new GraphicObject(aGraphic));
362  }
363  return *mxGrfObj;
364 }
365 
366 }
367 
369 {
370  Init( nullptr, eCreateMode );
371 }
372 
374  : meCreateMode(SvXMLGraphicHelperMode::Read)
375 {
376 }
377 
379 {
380 }
381 
382 bool SvXMLGraphicHelper::ImplGetStreamNames( const OUString& rURLStr,
383  OUString& rPictureStorageName,
384  OUString& rPictureStreamName )
385 {
386  if (rURLStr.isEmpty())
387  return false;
388 
389  const OUString aURLStr {rURLStr.copy(rURLStr.lastIndexOf(':')+1)};
390 
391  if( !aURLStr.isEmpty() && aURLStr.indexOf('/')<0 ) // just one token?
392  {
393  rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
394  rPictureStreamName = aURLStr;
395  }
396  else
397  SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName);
398 
399  SAL_WARN_IF(rPictureStreamName.isEmpty(), "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
400 
401  return !rPictureStreamName.isEmpty();
402 }
403 
404 uno::Reference < embed::XStorage > SvXMLGraphicHelper::ImplGetGraphicStorage( const OUString& rStorageName )
405 {
406  uno::Reference < embed::XStorage > xRetStorage;
407  if( mxRootStorage.is() )
408  {
409  try
410  {
411  maCurStorageName = rStorageName;
412  xRetStorage = mxRootStorage->openStorageElement(
415  ? embed::ElementModes::READWRITE
416  : embed::ElementModes::READ );
417  }
418  catch ( uno::Exception& )
419  {
420  }
421  //#i43196# try again to open the storage element - this time readonly
422  if(!xRetStorage.is())
423  {
424  try
425  {
426  maCurStorageName = rStorageName;
427  xRetStorage = mxRootStorage->openStorageElement( maCurStorageName, embed::ElementModes::READ );
428  }
429  catch ( uno::Exception& )
430  {
431  }
432  }
433  }
434 
435  return xRetStorage;
436 }
437 
439  const OUString& rPictureStreamName )
440 {
442  aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
443 
444  sal_Int32 nMode = embed::ElementModes::READ;
446  {
447  nMode = embed::ElementModes::READWRITE;
448  }
449 
450  if (aRet.xStorage.is())
451  {
452  aRet.xStream = aRet.xStorage->openStreamElement( rPictureStreamName, nMode );
453  }
454  else if (rPictureStorageName.indexOf('/') != -1)
455  {
456  uno::Reference<embed::XHierarchicalStorageAccess> xHierRootStorage(mxRootStorage,
457  uno::UNO_QUERY);
458  if (xHierRootStorage.is())
459  {
460  try
461  {
462  aRet.xStream = xHierRootStorage->openStreamElementByHierarchicalName(
463  rPictureStorageName + "/" + rPictureStreamName, nMode);
464  aRet.xStorage = mxRootStorage;
465  }
466  catch (const uno::Exception&)
467  {
468  TOOLS_WARN_EXCEPTION("svx",
469  "SvXMLGraphicHelper::ImplGetGraphicStream: failed to open "
470  << rPictureStreamName);
471  }
472  }
473  }
474 
475  if (aRet.xStream.is() && (SvXMLGraphicHelperMode::Write == meCreateMode))
476  {
477  uno::Reference<beans::XPropertySet> xProps(aRet.xStream, uno::UNO_QUERY);
478  xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::Any(true));
479  }
480 
481  return aRet;
482 }
483 
484 OUString SvXMLGraphicHelper::ImplGetGraphicMimeType( const OUString& rFileName )
485 {
486  if( ( rFileName.getLength() >= 4 ) && ( rFileName[ rFileName.getLength() - 4 ] == '.' ) )
487  {
488  const OString aExt(OUStringToOString(rFileName.subView(rFileName.getLength() - 3),
489  RTL_TEXTENCODING_ASCII_US));
491  }
492 
493  return OUString();
494 }
495 
496 Graphic SvXMLGraphicHelper::ImplReadGraphic( const OUString& rPictureStorageName,
497  const OUString& rPictureStreamName )
498 {
499  Graphic aReturnGraphic;
500  SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName ) );
501  if (aStream.xStream.is())
502  {
504  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream));
505  Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(*pStream);
506  if (!aGraphic.IsNone())
507  aReturnGraphic = aGraphic;
508  else
509  rGraphicFilter.ImportGraphic(aReturnGraphic, u"", *pStream);
510  }
511 
512  return aReturnGraphic;
513 }
514 
515 void SvXMLGraphicHelper::Init( const uno::Reference < embed::XStorage >& rXMLStorage,
516  SvXMLGraphicHelperMode eCreateMode,
517  const OUString& rGraphicMimeType )
518 {
519  mxRootStorage = rXMLStorage;
520  meCreateMode = eCreateMode;
521  maOutputMimeType = rGraphicMimeType;
522 }
523 
524 rtl::Reference<SvXMLGraphicHelper> SvXMLGraphicHelper::Create( const uno::Reference < embed::XStorage >& rXMLStorage,
525  SvXMLGraphicHelperMode eCreateMode )
526 {
528  pThis->Init( rXMLStorage, eCreateMode, OUString() );
529 
530  return pThis;
531 }
532 
534  const OUString& rGraphicMimeType )
535 {
537 
538  pThis->Init( nullptr, eCreateMode, rGraphicMimeType );
539 
540  return pThis;
541 }
542 
543 namespace
544 {
545 
546 void splitUserDataFromURL(OUString const & rWholeURL, OUString & rJustURL, OUString & rUserData)
547 {
548  sal_Int32 nUser = rWholeURL.indexOf('?');
549  if (nUser >= 0)
550  {
551  rJustURL = rWholeURL.copy(0, nUser);
552  nUser++;
553  rUserData = rWholeURL.copy(nUser);
554  }
555  else
556  {
557  rJustURL = rWholeURL;
558  }
559 }
560 
561 } // end anonymous namespace
562 
563 // XGraphicObjectResolver
564 OUString SAL_CALL SvXMLGraphicHelper::resolveGraphicObjectURL( const OUString& /*rURL*/ )
565 {
566  throw uno::RuntimeException("XGraphicObjectResolver has been removed in LibreOffice 6.1");
567 }
568 
569 // XGraphicStorageHandler
570 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphic(OUString const & rURL)
571 {
572  std::unique_lock aGuard(m_aMutex);
573 
574  uno::Reference<graphic::XGraphic> xGraphic;
575 
576  OUString aURLOnly;
577  OUString aUserData;
578  splitUserDataFromURL(rURL, aURLOnly, aUserData);
579 
580  auto aIterator = maGraphicObjects.find(aURLOnly);
581  if (aIterator != maGraphicObjects.end())
582  {
583  return aIterator->second;
584  }
585 
586  OUString aPictureStorageName, aPictureStreamName;
587 
588  if (ImplGetStreamNames(aURLOnly, aPictureStorageName, aPictureStreamName))
589  {
590  const GraphicObject aGraphicObject(ImplReadGraphic(aPictureStorageName, aPictureStreamName));
591 
592  if (aGraphicObject.GetType() != GraphicType::NONE)
593  {
594  xGraphic = aGraphicObject.GetGraphic().GetXGraphic();
595  maGraphicObjects[aURLOnly] = xGraphic;
596  }
597  }
598 
599  return xGraphic;
600 }
601 
602 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream> const & rxOutputStream)
603 {
604  std::unique_lock aGuard(m_aMutex);
605 
606  uno::Reference<graphic::XGraphic> xGraphic;
607 
608  if ((SvXMLGraphicHelperMode::Read == meCreateMode) && rxOutputStream.is())
609  {
610 
611  SvXMLGraphicOutputStream* pGraphicOutputStream = static_cast<SvXMLGraphicOutputStream*>(rxOutputStream.get());
612  if (pGraphicOutputStream)
613  {
614  xGraphic = pGraphicOutputStream->GetGraphic().GetXGraphic();
615  }
616  }
617  return xGraphic;
618 }
619 
620 OUString SAL_CALL SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
621  OUString & rOutSavedMimeType, OUString const & rRequestName)
622 {
623  return implSaveGraphic(rxGraphic, rOutSavedMimeType, rRequestName);
624 }
625 
626 OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
627 {
628  OUString aOutMimeType;
629  return implSaveGraphic(rxGraphic, aOutMimeType, std::u16string_view());
630 }
631 
632 OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
633  OUString & rOutSavedMimeType, std::u16string_view rRequestName)
634 {
635  Graphic aGraphic(rxGraphic);
636 
637  auto aIterator = maExportGraphics.find(aGraphic);
638  if (aIterator != maExportGraphics.end())
639  {
640  auto const & aURLAndMimePair = aIterator->second;
641  rOutSavedMimeType = aURLAndMimePair.second;
642  return aURLAndMimePair.first;
643  }
644 
645  GraphicObject aGraphicObject(aGraphic);
646 
647  if (aGraphicObject.GetType() != GraphicType::NONE)
648  {
649  const GfxLink aGfxLink(aGraphic.GetGfxLink());
650  OUString aExtension;
651  bool bUseGfxLink = true;
652 
653  if (aGfxLink.GetDataSize())
654  {
655  switch (aGfxLink.GetType())
656  {
657  case GfxLinkType::EpsBuffer: aExtension = ".eps"; break;
658  case GfxLinkType::NativeGif: aExtension = ".gif"; break;
659  // #i15508# added BMP type for better exports (checked, works)
660  case GfxLinkType::NativeBmp: aExtension = ".bmp"; break;
661  case GfxLinkType::NativeJpg: aExtension = ".jpg"; break;
662  case GfxLinkType::NativePng: aExtension = ".png"; break;
663  case GfxLinkType::NativeTif: aExtension = ".tif"; break;
664  case GfxLinkType::NativeWmf:
665  if (aGfxLink.IsEMF())
666  aExtension = ".emf";
667  else
668  aExtension = ".wmf";
669  break;
670  case GfxLinkType::NativeMet: aExtension = ".met"; break;
671  case GfxLinkType::NativePct: aExtension = ".pct"; break;
672  case GfxLinkType::NativeSvg:
673  {
674  // backward-compat kludge: since no released OOo
675  // version to date can handle svg properly, wrap it up
676  // into an svm. slight catch22 here, since strict ODF
677  // conformance _recommends_ svg - then again, most old
678  // ODF consumers are believed to be OOo
679  auto nSaneVersion = GetODFSaneDefaultVersion();
680  if ( nSaneVersion < SvtSaveOptions::ODFSVER_012
681  || nSaneVersion == SvtSaveOptions::ODFSVER_012_EXT_COMPAT)
682  {
683  bUseGfxLink = false;
684  aExtension = ".svm";
685  }
686  else
687  {
688  aExtension = ".svg";
689  }
690  break;
691  }
692  case GfxLinkType::NativePdf: aExtension = ".pdf"; break;
693  case GfxLinkType::NativeWebp: aExtension = ".webp"; break;
694 
695  default:
696  aExtension = ".grf";
697  break;
698  }
699  }
700  else
701  {
702  if (aGraphicObject.GetType() == GraphicType::Bitmap)
703  {
704  if (aGraphicObject.IsAnimated())
705  aExtension = ".gif";
706  else
707  aExtension = ".png";
708  }
709  else if (aGraphicObject.GetType() == GraphicType::GdiMetafile)
710  {
711  // SJ: first check if this metafile is just an eps file, then we will store the eps instead of svm
712  GDIMetaFile& rMetafile(const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()));
713 
714  if (ImplCheckForEPS(rMetafile))
715  aExtension = ".eps";
716  else
717  aExtension = ".svm";
718  }
719  }
720 
721  OUString rPictureStreamName;
722  if (!rRequestName.empty())
723  {
724  rPictureStreamName = rRequestName + aExtension;
725  }
726  else
727  {
728  OUString sId = OStringToOUString(aGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
729  rPictureStreamName = sId + aExtension;
730  }
731 
733 
734  if (aStream.xStream.is())
735  {
736  const OUString aMimeType(ImplGetGraphicMimeType(rPictureStreamName));
737  uno::Reference<beans::XPropertySet> xProps(aStream.xStream, uno::UNO_QUERY);
738 
739  // set stream properties (MediaType/Compression)
740  if (!aMimeType.isEmpty())
741  {
742  xProps->setPropertyValue("MediaType", uno::Any(aMimeType));
743  }
744 
745  // picture formats that actually _do_ benefit from zip
746  // storage compression
747  // .svm pics gets compressed via ZBITMAP old-style stream
748  // option below
749  static const char* aCompressiblePics[] =
750  {
751  "image/svg+xml",
752  "image/x-emf",
753  "image/x-wmf",
754  "image/tiff",
755  "image/x-eps",
756  "image/bmp",
757  "image/x-pict"
758  };
759 
760  bool bSuccess = false;
761 
762  bool bCompressed = aMimeType.isEmpty();
763  if( !bCompressed )
764  {
765  for(const char* p : aCompressiblePics)
766  {
767  if( aMimeType.equalsIgnoreAsciiCaseAscii(p) )
768  {
769  bCompressed = true;
770  break;
771  }
772  }
773  }
774 
775  xProps->setPropertyValue("Compressed", Any(bCompressed));
776 
777  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream));
778  if (bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData())
779  {
780  pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
781  rOutSavedMimeType = aMimeType;
782  bSuccess = (pStream->GetError() == ERRCODE_NONE);
783  }
784  else
785  {
786  if (aGraphic.GetType() == GraphicType::Bitmap)
787  {
789  OUString aFormat;
790 
791  if (aGraphic.IsAnimated())
792  {
793  aFormat = "gif";
794  }
795  else
796  {
797  aFormat = "png";
798  }
799  rOutSavedMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aFormat.toUtf8());
800 
801  bSuccess = (rFilter.ExportGraphic(aGraphic, u"", *pStream, rFilter.GetExportFormatNumberForShortName(aFormat)) == ERRCODE_NONE);
802  }
803  else if (aGraphic.GetType() == GraphicType::GdiMetafile)
804  {
805  pStream->SetVersion(SOFFICE_FILEFORMAT_8);
806  pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP);
808 
809  // SJ: first check if this metafile is just an eps file, then we will store the eps instead of svm
810  GDIMetaFile& rMtf(const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()));
811  const MetaCommentAction* pComment = ImplCheckForEPS(rMtf);
812  if (pComment)
813  {
814  sal_uInt32 nSize = pComment->GetDataSize();
815  const sal_uInt8* pData = pComment->GetData();
816  if (nSize && pData)
817  pStream->WriteBytes(pData, nSize);
818 
819  const MetaEPSAction* pAct = static_cast<const MetaEPSAction*>(rMtf.FirstAction());
820  const GfxLink& rLink = pAct->GetLink();
821 
822  pStream->WriteBytes(rLink.GetData(), rLink.GetDataSize());
823  }
824  else
825  {
826  SvmWriter aWriter(*pStream);
827  aWriter.Write(rMtf);
828  }
829 
830  bSuccess = (pStream->GetError() == ERRCODE_NONE);
831  }
832  }
833 
834  if (!bSuccess)
835  return OUString();
836 
837  uno::Reference<embed::XTransactedObject> xStorage(aStream.xStorage, uno::UNO_QUERY);
838  pStream.reset();
839  aStream.xStream->getOutputStream()->closeOutput();
840  if (xStorage.is())
841  xStorage->commit();
842 
843  OUString aStoragePath = "Pictures/" + rPictureStreamName;
844 
845  // put into cache
846  maExportGraphics[aGraphic] = std::make_pair(aStoragePath, rOutSavedMimeType);
847 
848  return aStoragePath;
849  }
850  }
851 
852  return OUString();
853 }
854 
855 uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)
856 {
857  Reference<XInputStream> xInputStream;
858 
859  Graphic aGraphic(rxGraphic);
860  GraphicObject aGraphicObject(aGraphic);
861 
863  {
865  rtl::Reference<GraphicInputStream> pInputStream(new GraphicInputStream(aGraphicObject, sMimeType));
866 
867  // We release the pointer from unique_ptr and assign it to the input stream return type.
868  // In case the stream doesn't exists, unique_ptr will delete the pointer when we go out of scope.
869  if (pInputStream->exists())
870  xInputStream = pInputStream.get();
871  }
872 
873  return xInputStream;
874 }
875 
876 // XBinaryStreamResolver
878 {
880  return xRet;
881 }
882 
884 {
886 
888  {
889  rtl::Reference<SvXMLGraphicOutputStream> pOutputStream(new SvXMLGraphicOutputStream);
890 
891  if( pOutputStream->Exists() )
892  {
893  xRet = pOutputStream.get();
894  maGrfStms.push_back( xRet );
895  }
896  }
897 
898  return xRet;
899 }
900 
901 OUString SAL_CALL SvXMLGraphicHelper::resolveOutputStream( const Reference< XOutputStream >& rxBinaryStream )
902 {
903  OUString aRet;
904 
905  if( ( SvXMLGraphicHelperMode::Read == meCreateMode ) && rxBinaryStream.is() )
906  {
907  if( ::std::find( maGrfStms.begin(), maGrfStms.end(), rxBinaryStream ) != maGrfStms.end() )
908  {
909  SvXMLGraphicOutputStream* pOStm = static_cast< SvXMLGraphicOutputStream* >( rxBinaryStream.get() );
910 
911  if( pOStm )
912  {
913  const GraphicObject& rGrfObj = pOStm->GetGraphicObject();
914  const OUString aId(OStringToOUString(
915  rGrfObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US));
916 
917  if( !aId.isEmpty() )
918  {
919  aRet = XML_GRAPHICOBJECT_URL_BASE + aId;
920  }
921  }
922  }
923  }
924 
925  return aRet;
926 }
927 
928 // for instantiation via service manager
929 namespace {
930 
931 namespace impl
932 {
933 typedef comphelper::WeakComponentImplHelper<lang::XInitialization,
934  document::XGraphicObjectResolver,
935  document::XGraphicStorageHandler,
936  document::XBinaryStreamResolver,
937  lang::XServiceInfo>
938  SvXMLGraphicImportExportHelper_Base;
939 
940 } // namespace impl
941 
942 class SvXMLGraphicImportExportHelper :
943  public impl::SvXMLGraphicImportExportHelper_Base
944 {
945 public:
946  explicit SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode );
947 
948 protected:
949  // is called from WeakComponentImplHelper when XComponent::dispose() was
950  // called from outside
951  virtual void disposing(std::unique_lock<std::mutex>&) override;
952 
953  // ____ XInitialization ____
954  // one argument is allowed, which is the XStorage
955  virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
956 
957  // ____ XGraphicObjectResolver ____
958  virtual OUString SAL_CALL resolveGraphicObjectURL( const OUString& aURL ) override;
959 
960  // ____ XGraphicStorageHandler ____
961  virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
962  loadGraphic(const OUString& aURL) override;
963 
964  virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
965  loadGraphicFromOutputStream(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream) override;
966 
967  virtual OUString SAL_CALL
968  saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
969 
970  virtual OUString SAL_CALL
971  saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutSavedMimeType, OUString const & rRequestName) override;
972 
973  virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
974  createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
975 
976  // ____ XBinaryStreamResolver ____
977  virtual Reference< io::XInputStream > SAL_CALL getInputStream( const OUString& aURL ) override;
978  virtual Reference< io::XOutputStream > SAL_CALL createOutputStream() override;
979  virtual OUString SAL_CALL resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream ) override;
980 
981  // ____ XServiceInfo ____
982  virtual OUString SAL_CALL getImplementationName() override;
983  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
984  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
985 
986 private:
987  SvXMLGraphicHelperMode m_eGraphicHelperMode;
988  rtl::Reference<SvXMLGraphicHelper> m_xXMLGraphicHelper;
989 };
990 
991 SvXMLGraphicImportExportHelper::SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode ) :
992  m_eGraphicHelperMode( eMode )
993 {}
994 
995 void SvXMLGraphicImportExportHelper::disposing(std::unique_lock<std::mutex>&)
996 {
997  if (m_xXMLGraphicHelper)
998  {
999  m_xXMLGraphicHelper->dispose();
1000  m_xXMLGraphicHelper.clear();
1001  }
1002 }
1003 
1004 // ____ XInitialization ____
1005 void SAL_CALL SvXMLGraphicImportExportHelper::initialize(
1006  const Sequence< Any >& aArguments )
1007 {
1009  if( aArguments.hasElements() )
1010  aArguments[0] >>= xStorage;
1011 
1012  m_xXMLGraphicHelper = SvXMLGraphicHelper::Create( xStorage, m_eGraphicHelperMode );
1013 }
1014 
1015 // ____ XGraphicObjectResolver ____
1016 OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveGraphicObjectURL( const OUString& aURL )
1017 {
1018  return m_xXMLGraphicHelper->resolveGraphicObjectURL( aURL );
1019 }
1020 
1021 // ____ XGraphicStorageHandler ____
1022 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicImportExportHelper::loadGraphic(OUString const & rURL)
1023 {
1024  return m_xXMLGraphicHelper->loadGraphic(rURL);
1025 }
1026 
1027 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicImportExportHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream> const & rxOutputStream)
1028 {
1029  return m_xXMLGraphicHelper->loadGraphicFromOutputStream(rxOutputStream);
1030 }
1031 
1032 OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
1033 {
1034  return m_xXMLGraphicHelper->saveGraphic(rxGraphic);
1035 }
1036 
1037 OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
1038  OUString & rOutSavedMimeType, OUString const & rRequestName)
1039 {
1040  return m_xXMLGraphicHelper->saveGraphicByName(rxGraphic, rOutSavedMimeType, rRequestName);
1041 }
1042 
1043 uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicImportExportHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)
1044 {
1045  return m_xXMLGraphicHelper->createInputStream(rxGraphic);
1046 }
1047 
1048 // ____ XBinaryStreamResolver ____
1049 Reference< io::XInputStream > SAL_CALL SvXMLGraphicImportExportHelper::getInputStream( const OUString& aURL )
1050 {
1051  return m_xXMLGraphicHelper->getInputStream( aURL );
1052 }
1053 Reference< io::XOutputStream > SAL_CALL SvXMLGraphicImportExportHelper::createOutputStream()
1054 {
1055  return m_xXMLGraphicHelper->createOutputStream();
1056 }
1057 OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
1058 {
1059  return m_xXMLGraphicHelper->resolveOutputStream( aBinaryStream );
1060 }
1061 
1062 // ____ XServiceInfo ____
1063 OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName()
1064 {
1065  if( m_eGraphicHelperMode == SvXMLGraphicHelperMode::Read )
1066  return "com.sun.star.comp.Svx.GraphicImportHelper";
1067  return "com.sun.star.comp.Svx.GraphicExportHelper";
1068 }
1069 
1070 sal_Bool SAL_CALL SvXMLGraphicImportExportHelper::supportsService( const OUString& ServiceName )
1071 {
1072  return cppu::supportsService(this, ServiceName);
1073 }
1074 
1075 Sequence< OUString > SAL_CALL SvXMLGraphicImportExportHelper::getSupportedServiceNames()
1076 {
1077  return { "com.sun.star.document.GraphicObjectResolver",
1078  "com.sun.star.document.GraphicStorageHandler",
1079  "com.sun.star.document.BinaryStreamResolver" };
1080 }
1081 
1082 }
1083 
1095 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1097  css::uno::XComponentContext *,
1098  css::uno::Sequence<css::uno::Any> const &)
1099 {
1100  return cppu::acquire(new SvXMLGraphicImportExportHelper(SvXMLGraphicHelperMode::Read));
1101 }
1102 
1115 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1117  css::uno::XComponentContext *,
1118  css::uno::Sequence<css::uno::Any> const &)
1119 {
1120  return cppu::acquire(new SvXMLGraphicImportExportHelper(SvXMLGraphicHelperMode::Write));
1121 }
1122 
1123 namespace svx {
1124 
1125  void DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& xModel)
1126  {
1127  uno::Reference<lang::XMultiServiceFactory> const xModelFactory(xModel, uno::UNO_QUERY);
1128  assert(xModelFactory.is());
1129  try
1130  {
1131  uno::Reference<util::XCancellable> const xGradient(
1132  xModelFactory->createInstance("com.sun.star.drawing.GradientTable"),
1133  uno::UNO_QUERY );
1134  if (xGradient.is())
1135  {
1136  xGradient->cancel();
1137  }
1138 
1139  uno::Reference<util::XCancellable> const xHatch(
1140  xModelFactory->createInstance("com.sun.star.drawing.HatchTable"),
1141  uno::UNO_QUERY );
1142  if (xHatch.is())
1143  {
1144  xHatch->cancel();
1145  }
1146 
1147  uno::Reference<util::XCancellable> const xBitmap(
1148  xModelFactory->createInstance("com.sun.star.drawing.BitmapTable"),
1149  uno::UNO_QUERY );
1150  if (xBitmap.is())
1151  {
1152  xBitmap->cancel();
1153  }
1154 
1155  uno::Reference<util::XCancellable> const xTransGradient(
1156  xModelFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
1157  uno::UNO_QUERY );
1158  if (xTransGradient.is())
1159  {
1160  xTransGradient->cancel();
1161  }
1162 
1163  uno::Reference<util::XCancellable> const xMarker(
1164  xModelFactory->createInstance("com.sun.star.drawing.MarkerTable"),
1165  uno::UNO_QUERY );
1166  if (xMarker.is())
1167  {
1168  xMarker->cancel();
1169  }
1170 
1171  uno::Reference<util::XCancellable> const xDashes(
1172  xModelFactory->createInstance("com.sun.star.drawing.DashTable"),
1173  uno::UNO_QUERY );
1174  if (xDashes.is())
1175  {
1176  xDashes->cancel();
1177  }
1178  }
1179  catch (const Exception&)
1180  {
1181  TOOLS_WARN_EXCEPTION("svx", "dropUnusedNamedItems(): exception during clearing of unused named items");
1182  }
1183  }
1184 
1185 } // namespace svx
1186 
1187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maOutputMimeType
Definition: xmlgrhlp.hxx:63
UNOTOOLS_DLLPUBLIC bool Exists(OUString const &url)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Svx_GraphicImportHelper_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Create this with createInstanceWithArguments.
Definition: xmlgrhlp.cxx:1096
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL loadGraphicFromOutputStream(css::uno::Reference< css::io::XOutputStream > const &rxOutputStream) override
Definition: xmlgrhlp.cxx:602
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
void Init()
void SetSynchronMode(bool bTheSync=true)
bool IsNone() const
static void splitObjectURL(const OUString &aURLNoPar, OUString &rContainerStorageName, OUString &rObjectStorageName)
Definition: xmleohlp.cxx:148
static SVX_DLLPRIVATE bool ImplGetStreamNames(const OUString &rURLStr, OUString &rPictureStorageName, OUString &rPictureStreamName)
Definition: xmlgrhlp.cxx:382
std::unique_ptr< sal_Int32[]> pData
css::uno::Reference< css::embed::XStorage > xStorage
Definition: xmlgrhlp.hxx:44
#define ZCODEC_DEFAULT_COMPRESSION
constexpr OUStringLiteral XML_GRAPHICOBJECT_URL_BASE
Definition: xmlgrhlp.cxx:66
void Init(const css::uno::Reference< css::embed::XStorage > &xXMLStorage, SvXMLGraphicHelperMode eCreateMode, const OUString &rGraphicMimeType=OUString())
Definition: xmlgrhlp.cxx:515
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
const ContentProperties & rData
sal_uInt64 Seek(sal_uInt64 nPos)
tools::Long Decompress(SvStream &rIStm, SvStream &rOStm)
virtual OUString SAL_CALL resolveGraphicObjectURL(const OUString &aURL) override
Definition: xmlgrhlp.cxx:564
static SVX_DLLPRIVATE OUString ImplGetGraphicMimeType(const OUString &rFileName)
Definition: xmlgrhlp.cxx:484
virtual sal_uInt64 TellEnd() override
const sal_uInt8 * GetData() const
Graphic ImportUnloadedGraphic(SvStream &rIStream, sal_uInt64 sizeLimit=0, const Size *pSizeHint=nullptr)
SvStream & Write(const GDIMetaFile &rMetaFile)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
OUString maCurStorageName
Definition: xmlgrhlp.hxx:55
OString GetUniqueID() const
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual OUString SAL_CALL resolveOutputStream(const css::uno::Reference< css::io::XOutputStream > &rxBinaryStream) override
Definition: xmlgrhlp.cxx:901
const GDIMetaFile & GetGDIMetaFile() const
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
sal_uInt16 GetExportFormatNumberForShortName(std::u16string_view rShortName)
css::uno::Reference< css::embed::XStorage > mxRootStorage
Definition: xmlgrhlp.hxx:54
bool IsAnimated() const
virtual void disposing(std::unique_lock< std::mutex > &)
constexpr OUStringLiteral aData
virtual OUString SAL_CALL saveGraphicByName(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutSavedMimeType, OUString const &rRequestName) override
Definition: xmlgrhlp.cxx:620
SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
static OUString GetMimeTypeForExtension(std::string_view rExt)
#define TOOLS_WARN_EXCEPTION(area, stream)
GraphicType GetType() const
SVX_DLLPRIVATE Graphic ImplReadGraphic(const OUString &rPictureStorageName, const OUString &rPictureStreamName)
Definition: xmlgrhlp.cxx:496
sal_uInt16 GetExportFormatNumberForMediaType(std::u16string_view rShortName)
std::unordered_map< OUString, css::uno::Reference< css::graphic::XGraphic > > maGraphicObjects
Definition: xmlgrhlp.hxx:59
float u
void BeginCompression(int nCompressLevel=ZCODEC_DEFAULT_COMPRESSION, bool gzLib=false)
unsigned char sal_Bool
tools::Long EndCompression()
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL createOutputStream() override
Definition: xmlgrhlp.cxx:883
virtual ~SvXMLGraphicHelper() override
Definition: xmlgrhlp.cxx:378
#define GRFILTER_FORMAT_DONTKNOW
GfxLink GetGfxLink() const
ErrCode ExportGraphic(const Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat, const css::uno::Sequence< css::beans::PropertyValue > *pFilterData=nullptr)
GraphicType GetType() const
SVX_DLLPRIVATE css::uno::Reference< css::embed::XStorage > ImplGetGraphicStorage(const OUString &rPictureStorageName)
Definition: xmlgrhlp.cxx:404
const GfxLink & GetLink() const
SvXMLGraphicHelperMode meCreateMode
Definition: xmlgrhlp.hxx:62
sal_uInt32 GetDataSize() const
std::vector< css::uno::Reference< css::io::XOutputStream > > maGrfStms
Definition: xmlgrhlp.hxx:57
virtual OUString SAL_CALL saveGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic) override
Definition: xmlgrhlp.cxx:626
const Graphic & GetGraphic() const
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
unsigned char sal_uInt8
void DropUnusedNamedItems(css::uno::Reference< css::uno::XInterface > const &xModel)
Definition: xmlgrhlp.cxx:1125
MetaAction * GetAction(size_t nAction) const
constexpr OUStringLiteral XML_GRAPHICSTORAGE_NAME
Definition: xmlgrhlp.cxx:65
void * p
size_t GetActionSize() const
SvXMLGraphicHelperMode
Definition: xmlgrhlp.hxx:37
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL loadGraphic(OUString const &aURL) override
Definition: xmlgrhlp.cxx:570
MetaActionType GetType() const
css::uno::Reference< css::io::XStream > xStream
Definition: xmlgrhlp.hxx:45
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
MetaAction * FirstAction()
static GraphicFilter & GetGraphicFilter()
const sal_Unicode *const aMimeType[]
static rtl::Reference< SvXMLGraphicHelper > Create(const css::uno::Reference< css::embed::XStorage > &rXMLStorage, SvXMLGraphicHelperMode eCreateMode)
bool IsAnimated() const
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL createInputStream(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic) override
Definition: xmlgrhlp.cxx:855
SVX_DLLPRIVATE OUString implSaveGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, std::u16string_view rRequestName)
Definition: xmlgrhlp.cxx:632
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Svx_GraphicExportHelper_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Create this with createInstanceWithArguments.
Definition: xmlgrhlp.cxx:1116
SVX_DLLPRIVATE SvxGraphicHelperStream_Impl ImplGetGraphicStream(const OUString &rPictureStorageName, const OUString &rPictureStreamName)
Definition: xmlgrhlp.cxx:438
std::unordered_map< Graphic, std::pair< OUString, OUString > > maExportGraphics
Definition: xmlgrhlp.hxx:60
#define SOFFICE_FILEFORMAT_8
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream(const OUString &rURL) override
Definition: xmlgrhlp.cxx:877
OUString sId
OUString aId