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 <cppuhelper/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, "", *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, "", *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, "", *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, "", *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, "", 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  : cppu::WeakComponentImplHelper<document::XGraphicObjectResolver,
370  document::XGraphicStorageHandler,
371  document::XBinaryStreamResolver>(maMutex)
372 {
373  Init( nullptr, eCreateMode );
374 }
375 
377  : cppu::WeakComponentImplHelper<document::XGraphicObjectResolver,
378  document::XGraphicStorageHandler,
379  document::XBinaryStreamResolver>(maMutex)
380  , meCreateMode(SvXMLGraphicHelperMode::Read)
381 {
382 }
383 
385 {
386 }
387 
389 {
390 }
391 
392 bool SvXMLGraphicHelper::ImplGetStreamNames( const OUString& rURLStr,
393  OUString& rPictureStorageName,
394  OUString& rPictureStreamName )
395 {
396  if (rURLStr.isEmpty())
397  return false;
398 
399  const OUString aURLStr {rURLStr.copy(rURLStr.lastIndexOf(':')+1)};
400 
401  if( !aURLStr.isEmpty() && aURLStr.indexOf('/')<0 ) // just one token?
402  {
403  rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
404  rPictureStreamName = aURLStr;
405  }
406  else
407  SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName);
408 
409  SAL_WARN_IF(rPictureStreamName.isEmpty(), "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
410 
411  return !rPictureStreamName.isEmpty();
412 }
413 
414 uno::Reference < embed::XStorage > SvXMLGraphicHelper::ImplGetGraphicStorage( const OUString& rStorageName )
415 {
416  uno::Reference < embed::XStorage > xRetStorage;
417  if( mxRootStorage.is() )
418  {
419  try
420  {
421  maCurStorageName = rStorageName;
422  xRetStorage = mxRootStorage->openStorageElement(
425  ? embed::ElementModes::READWRITE
426  : embed::ElementModes::READ );
427  }
428  catch ( uno::Exception& )
429  {
430  }
431  //#i43196# try again to open the storage element - this time readonly
432  if(!xRetStorage.is())
433  {
434  try
435  {
436  maCurStorageName = rStorageName;
437  xRetStorage = mxRootStorage->openStorageElement( maCurStorageName, embed::ElementModes::READ );
438  }
439  catch ( uno::Exception& )
440  {
441  }
442  }
443  }
444 
445  return xRetStorage;
446 }
447 
449  const OUString& rPictureStreamName )
450 {
452  aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
453 
454  sal_Int32 nMode = embed::ElementModes::READ;
456  {
457  nMode = embed::ElementModes::READWRITE;
458  }
459 
460  if (aRet.xStorage.is())
461  {
462  aRet.xStream = aRet.xStorage->openStreamElement( rPictureStreamName, nMode );
463  }
464  else if (rPictureStorageName.indexOf('/') != -1)
465  {
466  uno::Reference<embed::XHierarchicalStorageAccess> xHierRootStorage(mxRootStorage,
467  uno::UNO_QUERY);
468  if (xHierRootStorage.is())
469  {
470  try
471  {
472  aRet.xStream = xHierRootStorage->openStreamElementByHierarchicalName(
473  rPictureStorageName + "/" + rPictureStreamName, nMode);
474  aRet.xStorage = mxRootStorage;
475  }
476  catch (const uno::Exception&)
477  {
478  TOOLS_WARN_EXCEPTION("svx",
479  "SvXMLGraphicHelper::ImplGetGraphicStream: failed to open "
480  << rPictureStreamName);
481  }
482  }
483  }
484 
485  if (aRet.xStream.is() && (SvXMLGraphicHelperMode::Write == meCreateMode))
486  {
487  uno::Reference<beans::XPropertySet> xProps(aRet.xStream, uno::UNO_QUERY);
488  xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::makeAny(true));
489  }
490 
491  return aRet;
492 }
493 
494 OUString SvXMLGraphicHelper::ImplGetGraphicMimeType( const OUString& rFileName )
495 {
496  if( ( rFileName.getLength() >= 4 ) && ( rFileName[ rFileName.getLength() - 4 ] == '.' ) )
497  {
498  const OString aExt(OUStringToOString(rFileName.subView(rFileName.getLength() - 3),
499  RTL_TEXTENCODING_ASCII_US));
501  }
502 
503  return OUString();
504 }
505 
506 Graphic SvXMLGraphicHelper::ImplReadGraphic( const OUString& rPictureStorageName,
507  const OUString& rPictureStreamName )
508 {
509  Graphic aReturnGraphic;
510  SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName ) );
511  if (aStream.xStream.is())
512  {
514  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream));
515  Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(*pStream);
516  if (!aGraphic.IsNone())
517  aReturnGraphic = aGraphic;
518  else
519  rGraphicFilter.ImportGraphic(aReturnGraphic, "", *pStream);
520  }
521 
522  return aReturnGraphic;
523 }
524 
525 void SvXMLGraphicHelper::Init( const uno::Reference < embed::XStorage >& rXMLStorage,
526  SvXMLGraphicHelperMode eCreateMode,
527  const OUString& rGraphicMimeType )
528 {
529  mxRootStorage = rXMLStorage;
530  meCreateMode = eCreateMode;
531  maOutputMimeType = rGraphicMimeType;
532 }
533 
534 rtl::Reference<SvXMLGraphicHelper> SvXMLGraphicHelper::Create( const uno::Reference < embed::XStorage >& rXMLStorage,
535  SvXMLGraphicHelperMode eCreateMode )
536 {
538  pThis->Init( rXMLStorage, eCreateMode, OUString() );
539 
540  return pThis;
541 }
542 
544  const OUString& rGraphicMimeType )
545 {
547 
548  pThis->Init( nullptr, eCreateMode, rGraphicMimeType );
549 
550  return pThis;
551 }
552 
553 namespace
554 {
555 
556 void splitUserDataFromURL(OUString const & rWholeURL, OUString & rJustURL, OUString & rUserData)
557 {
558  sal_Int32 nUser = rWholeURL.indexOf('?');
559  if (nUser >= 0)
560  {
561  rJustURL = rWholeURL.copy(0, nUser);
562  nUser++;
563  rUserData = rWholeURL.copy(nUser);
564  }
565  else
566  {
567  rJustURL = rWholeURL;
568  }
569 }
570 
571 } // end anonymous namespace
572 
573 // XGraphicObjectResolver
574 OUString SAL_CALL SvXMLGraphicHelper::resolveGraphicObjectURL( const OUString& /*rURL*/ )
575 {
576  throw uno::RuntimeException("XGraphicObjectResolver has been removed in LibreOffice 6.1");
577 }
578 
579 // XGraphicStorageHandler
580 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphic(OUString const & rURL)
581 {
582  osl::MutexGuard aGuard(maMutex);
583 
584  uno::Reference<graphic::XGraphic> xGraphic;
585 
586  OUString aURLOnly;
587  OUString aUserData;
588  splitUserDataFromURL(rURL, aURLOnly, aUserData);
589 
590  auto aIterator = maGraphicObjects.find(aURLOnly);
591  if (aIterator != maGraphicObjects.end())
592  {
593  return aIterator->second;
594  }
595 
596  OUString aPictureStorageName, aPictureStreamName;
597 
598  if (ImplGetStreamNames(aURLOnly, aPictureStorageName, aPictureStreamName))
599  {
600  const GraphicObject aGraphicObject(ImplReadGraphic(aPictureStorageName, aPictureStreamName));
601 
602  if (aGraphicObject.GetType() != GraphicType::NONE)
603  {
604  xGraphic = aGraphicObject.GetGraphic().GetXGraphic();
605  maGraphicObjects[aURLOnly] = xGraphic;
606  }
607  }
608 
609  return xGraphic;
610 }
611 
612 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream> const & rxOutputStream)
613 {
614  osl::MutexGuard aGuard(maMutex);
615 
616  uno::Reference<graphic::XGraphic> xGraphic;
617 
618  if ((SvXMLGraphicHelperMode::Read == meCreateMode) && rxOutputStream.is())
619  {
620 
621  SvXMLGraphicOutputStream* pGraphicOutputStream = static_cast<SvXMLGraphicOutputStream*>(rxOutputStream.get());
622  if (pGraphicOutputStream)
623  {
624  xGraphic = pGraphicOutputStream->GetGraphic().GetXGraphic();
625  }
626  }
627  return xGraphic;
628 }
629 
630 OUString SAL_CALL SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
631  OUString & rOutSavedMimeType, OUString const & rRequestName)
632 {
633  return implSaveGraphic(rxGraphic, rOutSavedMimeType, rRequestName);
634 }
635 
636 OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
637 {
638  OUString aOutMimeType;
639  return implSaveGraphic(rxGraphic, aOutMimeType, std::u16string_view());
640 }
641 
642 OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
643  OUString & rOutSavedMimeType, std::u16string_view rRequestName)
644 {
645  Graphic aGraphic(rxGraphic);
646 
647  auto aIterator = maExportGraphics.find(aGraphic);
648  if (aIterator != maExportGraphics.end())
649  {
650  auto const & aURLAndMimePair = aIterator->second;
651  rOutSavedMimeType = aURLAndMimePair.second;
652  return aURLAndMimePair.first;
653  }
654 
655  GraphicObject aGraphicObject(aGraphic);
656 
657  if (aGraphicObject.GetType() != GraphicType::NONE)
658  {
659  const GfxLink aGfxLink(aGraphic.GetGfxLink());
660  OUString aExtension;
661  bool bUseGfxLink = true;
662 
663  if (aGfxLink.GetDataSize())
664  {
665  switch (aGfxLink.GetType())
666  {
667  case GfxLinkType::EpsBuffer: aExtension = ".eps"; break;
668  case GfxLinkType::NativeGif: aExtension = ".gif"; break;
669  // #i15508# added BMP type for better exports (checked, works)
670  case GfxLinkType::NativeBmp: aExtension = ".bmp"; break;
671  case GfxLinkType::NativeJpg: aExtension = ".jpg"; break;
672  case GfxLinkType::NativePng: aExtension = ".png"; break;
673  case GfxLinkType::NativeTif: aExtension = ".tif"; break;
674  case GfxLinkType::NativeWmf:
675  if (aGfxLink.IsEMF())
676  aExtension = ".emf";
677  else
678  aExtension = ".wmf";
679  break;
680  case GfxLinkType::NativeMet: aExtension = ".met"; break;
681  case GfxLinkType::NativePct: aExtension = ".pct"; break;
682  case GfxLinkType::NativeSvg:
683  {
684  // backward-compat kludge: since no released OOo
685  // version to date can handle svg properly, wrap it up
686  // into an svm. slight catch22 here, since strict ODF
687  // conformance _recommends_ svg - then again, most old
688  // ODF consumers are believed to be OOo
689  auto nSaneVersion = GetODFSaneDefaultVersion();
690  if ( nSaneVersion < SvtSaveOptions::ODFSVER_012
691  || nSaneVersion == SvtSaveOptions::ODFSVER_012_EXT_COMPAT)
692  {
693  bUseGfxLink = false;
694  aExtension = ".svm";
695  }
696  else
697  {
698  aExtension = ".svg";
699  }
700  break;
701  }
702  case GfxLinkType::NativePdf: aExtension = ".pdf"; break;
703 
704  default:
705  aExtension = ".grf";
706  break;
707  }
708  }
709  else
710  {
711  if (aGraphicObject.GetType() == GraphicType::Bitmap)
712  {
713  if (aGraphicObject.IsAnimated())
714  aExtension = ".gif";
715  else
716  aExtension = ".png";
717  }
718  else if (aGraphicObject.GetType() == GraphicType::GdiMetafile)
719  {
720  // SJ: first check if this metafile is just an eps file, then we will store the eps instead of svm
721  GDIMetaFile& rMetafile(const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()));
722 
723  if (ImplCheckForEPS(rMetafile))
724  aExtension = ".eps";
725  else
726  aExtension = ".svm";
727  }
728  }
729 
730  OUString rPictureStreamName;
731  if (!rRequestName.empty())
732  {
733  rPictureStreamName = rRequestName + aExtension;
734  }
735  else
736  {
737  OUString sId = OStringToOUString(aGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
738  rPictureStreamName = sId + aExtension;
739  }
740 
742 
743  if (aStream.xStream.is())
744  {
745  const OUString aMimeType(ImplGetGraphicMimeType(rPictureStreamName));
746  uno::Reference<beans::XPropertySet> xProps(aStream.xStream, uno::UNO_QUERY);
747 
748  // set stream properties (MediaType/Compression)
749  if (!aMimeType.isEmpty())
750  {
751  xProps->setPropertyValue("MediaType", uno::Any(aMimeType));
752  }
753 
754  // picture formats that actually _do_ benefit from zip
755  // storage compression
756  // .svm pics gets compressed via ZBITMAP old-style stream
757  // option below
758  static const char* aCompressiblePics[] =
759  {
760  "image/svg+xml",
761  "image/x-emf",
762  "image/x-wmf",
763  "image/tiff",
764  "image/x-eps",
765  "image/bmp",
766  "image/x-pict"
767  };
768 
769  bool bSuccess = false;
770 
771  bool bCompressed = aMimeType.isEmpty();
772  if( !bCompressed )
773  {
774  for(const char* p : aCompressiblePics)
775  {
776  if( aMimeType.equalsIgnoreAsciiCaseAscii(p) )
777  {
778  bCompressed = true;
779  break;
780  }
781  }
782  }
783 
784  xProps->setPropertyValue("Compressed", Any(bCompressed));
785 
786  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream));
787  if (bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData())
788  {
789  pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
790  rOutSavedMimeType = aMimeType;
791  bSuccess = (pStream->GetError() == ERRCODE_NONE);
792  }
793  else
794  {
795  if (aGraphic.GetType() == GraphicType::Bitmap)
796  {
798  OUString aFormat;
799 
800  if (aGraphic.IsAnimated())
801  {
802  aFormat = "gif";
803  }
804  else
805  {
806  aFormat = "png";
807  }
808  rOutSavedMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aFormat.toUtf8());
809 
810  bSuccess = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForShortName(aFormat)) == ERRCODE_NONE);
811  }
812  else if (aGraphic.GetType() == GraphicType::GdiMetafile)
813  {
814  pStream->SetVersion(SOFFICE_FILEFORMAT_8);
815  pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP);
817 
818  // SJ: first check if this metafile is just an eps file, then we will store the eps instead of svm
819  GDIMetaFile& rMtf(const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()));
820  const MetaCommentAction* pComment = ImplCheckForEPS(rMtf);
821  if (pComment)
822  {
823  sal_uInt32 nSize = pComment->GetDataSize();
824  const sal_uInt8* pData = pComment->GetData();
825  if (nSize && pData)
826  pStream->WriteBytes(pData, nSize);
827 
828  const MetaEPSAction* pAct = static_cast<const MetaEPSAction*>(rMtf.FirstAction());
829  const GfxLink& rLink = pAct->GetLink();
830 
831  pStream->WriteBytes(rLink.GetData(), rLink.GetDataSize());
832  }
833  else
834  {
835  SvmWriter aWriter(*pStream);
836  aWriter.Write(rMtf);
837  }
838 
839  bSuccess = (pStream->GetError() == ERRCODE_NONE);
840  }
841  }
842 
843  if (!bSuccess)
844  return OUString();
845 
846  uno::Reference<embed::XTransactedObject> xStorage(aStream.xStorage, uno::UNO_QUERY);
847  pStream.reset();
848  aStream.xStream->getOutputStream()->closeOutput();
849  if (xStorage.is())
850  xStorage->commit();
851 
852  OUString aStoragePath = "Pictures/" + rPictureStreamName;
853 
854  // put into cache
855  maExportGraphics[aGraphic] = std::make_pair(aStoragePath, rOutSavedMimeType);
856 
857  return aStoragePath;
858  }
859  }
860 
861  return OUString();
862 }
863 
864 uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)
865 {
866  Reference<XInputStream> xInputStream;
867 
868  Graphic aGraphic(rxGraphic);
869  GraphicObject aGraphicObject(aGraphic);
870 
872  {
874  rtl::Reference<GraphicInputStream> pInputStream(new GraphicInputStream(aGraphicObject, sMimeType));
875 
876  // We release the pointer from unique_ptr and assign it to the input stream return type.
877  // In case the stream doesn't exists, unique_ptr will delete the pointer when we go out of scope.
878  if (pInputStream->exists())
879  xInputStream = pInputStream.get();
880  }
881 
882  return xInputStream;
883 }
884 
885 // XBinaryStreamResolver
887 {
889  return xRet;
890 }
891 
893 {
895 
897  {
898  rtl::Reference<SvXMLGraphicOutputStream> pOutputStream(new SvXMLGraphicOutputStream);
899 
900  if( pOutputStream->Exists() )
901  {
902  xRet = pOutputStream.get();
903  maGrfStms.push_back( xRet );
904  }
905  }
906 
907  return xRet;
908 }
909 
910 OUString SAL_CALL SvXMLGraphicHelper::resolveOutputStream( const Reference< XOutputStream >& rxBinaryStream )
911 {
912  OUString aRet;
913 
914  if( ( SvXMLGraphicHelperMode::Read == meCreateMode ) && rxBinaryStream.is() )
915  {
916  if( ::std::find( maGrfStms.begin(), maGrfStms.end(), rxBinaryStream ) != maGrfStms.end() )
917  {
918  SvXMLGraphicOutputStream* pOStm = static_cast< SvXMLGraphicOutputStream* >( rxBinaryStream.get() );
919 
920  if( pOStm )
921  {
922  const GraphicObject& rGrfObj = pOStm->GetGraphicObject();
923  const OUString aId(OStringToOUString(
924  rGrfObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US));
925 
926  if( !aId.isEmpty() )
927  {
928  aRet = XML_GRAPHICOBJECT_URL_BASE + aId;
929  }
930  }
931  }
932  }
933 
934  return aRet;
935 }
936 
937 // for instantiation via service manager
938 namespace {
939 
940 namespace impl
941 {
942 typedef cppu::WeakComponentImplHelper<lang::XInitialization,
943  document::XGraphicObjectResolver,
944  document::XGraphicStorageHandler,
945  document::XBinaryStreamResolver,
946  lang::XServiceInfo>
947  SvXMLGraphicImportExportHelper_Base;
948 
949 class MutexContainer
950 {
951 public:
952  virtual ~MutexContainer();
953 
954 protected:
955  mutable ::osl::Mutex m_aMutex;
956 };
957 
958 MutexContainer::~MutexContainer()
959 {}
960 
961 } // namespace impl
962 
963 class SvXMLGraphicImportExportHelper :
964  public impl::MutexContainer,
965  public impl::SvXMLGraphicImportExportHelper_Base
966 {
967 public:
968  explicit SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode );
969 
970 protected:
971  // is called from WeakComponentImplHelper when XComponent::dispose() was
972  // called from outside
973  virtual void SAL_CALL disposing() override;
974 
975  // ____ XInitialization ____
976  // one argument is allowed, which is the XStorage
977  virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
978 
979  // ____ XGraphicObjectResolver ____
980  virtual OUString SAL_CALL resolveGraphicObjectURL( const OUString& aURL ) override;
981 
982  // ____ XGraphicStorageHandler ____
983  virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
984  loadGraphic(const OUString& aURL) override;
985 
986  virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
987  loadGraphicFromOutputStream(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream) override;
988 
989  virtual OUString SAL_CALL
990  saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
991 
992  virtual OUString SAL_CALL
993  saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutSavedMimeType, OUString const & rRequestName) override;
994 
995  virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
996  createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
997 
998  // ____ XBinaryStreamResolver ____
999  virtual Reference< io::XInputStream > SAL_CALL getInputStream( const OUString& aURL ) override;
1000  virtual Reference< io::XOutputStream > SAL_CALL createOutputStream() override;
1001  virtual OUString SAL_CALL resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream ) override;
1002 
1003  // ____ XServiceInfo ____
1004  virtual OUString SAL_CALL getImplementationName() override;
1005  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1006  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1007 
1008 private:
1009  SvXMLGraphicHelperMode m_eGraphicHelperMode;
1010  Reference< XGraphicObjectResolver > m_xGraphicObjectResolver;
1011  Reference< XGraphicStorageHandler > m_xGraphicStorageHandler;
1012  Reference< XBinaryStreamResolver > m_xBinaryStreamResolver;
1013 };
1014 
1015 SvXMLGraphicImportExportHelper::SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode ) :
1016  impl::SvXMLGraphicImportExportHelper_Base( m_aMutex ),
1017  m_eGraphicHelperMode( eMode )
1018 {}
1019 
1020 void SAL_CALL SvXMLGraphicImportExportHelper::disposing()
1021 {
1022  Reference< XComponent > xComp( m_xGraphicObjectResolver, UNO_QUERY );
1023  OSL_ASSERT( xComp.is());
1024  if( xComp.is())
1025  xComp->dispose();
1026  // m_xBinaryStreamResolver and m_xGraphicStorageHandler are a reference to the same object,
1027  // don't call dispose() again
1028 }
1029 
1030 // ____ XInitialization ____
1031 void SAL_CALL SvXMLGraphicImportExportHelper::initialize(
1032  const Sequence< Any >& aArguments )
1033 {
1035  if( aArguments.hasElements() )
1036  aArguments[0] >>= xStorage;
1037 
1038  rtl::Reference<SvXMLGraphicHelper> pHelper( SvXMLGraphicHelper::Create( xStorage, m_eGraphicHelperMode ));
1039  m_xGraphicObjectResolver = pHelper;
1040  m_xGraphicStorageHandler = pHelper;
1041  m_xBinaryStreamResolver = pHelper;
1042 }
1043 
1044 // ____ XGraphicObjectResolver ____
1045 OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveGraphicObjectURL( const OUString& aURL )
1046 {
1047  return m_xGraphicObjectResolver->resolveGraphicObjectURL( aURL );
1048 }
1049 
1050 // ____ XGraphicStorageHandler ____
1051 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicImportExportHelper::loadGraphic(OUString const & rURL)
1052 {
1053  return m_xGraphicStorageHandler->loadGraphic(rURL);
1054 }
1055 
1056 uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicImportExportHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream> const & rxOutputStream)
1057 {
1058  return m_xGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
1059 }
1060 
1061 OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
1062 {
1063  return m_xGraphicStorageHandler->saveGraphic(rxGraphic);
1064 }
1065 
1066 OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
1067  OUString & rOutSavedMimeType, OUString const & rRequestName)
1068 {
1069  return m_xGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutSavedMimeType, rRequestName);
1070 }
1071 
1072 uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicImportExportHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)
1073 {
1074  return m_xGraphicStorageHandler->createInputStream(rxGraphic);
1075 }
1076 
1077 // ____ XBinaryStreamResolver ____
1078 Reference< io::XInputStream > SAL_CALL SvXMLGraphicImportExportHelper::getInputStream( const OUString& aURL )
1079 {
1080  return m_xBinaryStreamResolver->getInputStream( aURL );
1081 }
1082 Reference< io::XOutputStream > SAL_CALL SvXMLGraphicImportExportHelper::createOutputStream()
1083 {
1084  return m_xBinaryStreamResolver->createOutputStream();
1085 }
1086 OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
1087 {
1088  return m_xBinaryStreamResolver->resolveOutputStream( aBinaryStream );
1089 }
1090 
1091 // ____ XServiceInfo ____
1092 OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName()
1093 {
1094  if( m_eGraphicHelperMode == SvXMLGraphicHelperMode::Read )
1095  return "com.sun.star.comp.Svx.GraphicImportHelper";
1096  return "com.sun.star.comp.Svx.GraphicExportHelper";
1097 }
1098 
1099 sal_Bool SAL_CALL SvXMLGraphicImportExportHelper::supportsService( const OUString& ServiceName )
1100 {
1101  return cppu::supportsService(this, ServiceName);
1102 }
1103 
1104 Sequence< OUString > SAL_CALL SvXMLGraphicImportExportHelper::getSupportedServiceNames()
1105 {
1106  return { "com.sun.star.document.GraphicObjectResolver",
1107  "com.sun.star.document.GraphicStorageHandler",
1108  "com.sun.star.document.BinaryStreamResolver" };
1109 }
1110 
1111 }
1112 
1124 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1126  css::uno::XComponentContext *,
1127  css::uno::Sequence<css::uno::Any> const &)
1128 {
1129  return cppu::acquire(new SvXMLGraphicImportExportHelper(SvXMLGraphicHelperMode::Read));
1130 }
1131 
1144 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1146  css::uno::XComponentContext *,
1147  css::uno::Sequence<css::uno::Any> const &)
1148 {
1149  return cppu::acquire(new SvXMLGraphicImportExportHelper(SvXMLGraphicHelperMode::Write));
1150 }
1151 
1152 namespace svx {
1153 
1154  void DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& xModel)
1155  {
1156  uno::Reference<lang::XMultiServiceFactory> const xModelFactory(xModel, uno::UNO_QUERY);
1157  assert(xModelFactory.is());
1158  try
1159  {
1160  uno::Reference<util::XCancellable> const xGradient(
1161  xModelFactory->createInstance("com.sun.star.drawing.GradientTable"),
1162  uno::UNO_QUERY );
1163  if (xGradient.is())
1164  {
1165  xGradient->cancel();
1166  }
1167 
1168  uno::Reference<util::XCancellable> const xHatch(
1169  xModelFactory->createInstance("com.sun.star.drawing.HatchTable"),
1170  uno::UNO_QUERY );
1171  if (xHatch.is())
1172  {
1173  xHatch->cancel();
1174  }
1175 
1176  uno::Reference<util::XCancellable> const xBitmap(
1177  xModelFactory->createInstance("com.sun.star.drawing.BitmapTable"),
1178  uno::UNO_QUERY );
1179  if (xBitmap.is())
1180  {
1181  xBitmap->cancel();
1182  }
1183 
1184  uno::Reference<util::XCancellable> const xTransGradient(
1185  xModelFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
1186  uno::UNO_QUERY );
1187  if (xTransGradient.is())
1188  {
1189  xTransGradient->cancel();
1190  }
1191 
1192  uno::Reference<util::XCancellable> const xMarker(
1193  xModelFactory->createInstance("com.sun.star.drawing.MarkerTable"),
1194  uno::UNO_QUERY );
1195  if (xMarker.is())
1196  {
1197  xMarker->cancel();
1198  }
1199 
1200  uno::Reference<util::XCancellable> const xDashes(
1201  xModelFactory->createInstance("com.sun.star.drawing.DashTable"),
1202  uno::UNO_QUERY );
1203  if (xDashes.is())
1204  {
1205  xDashes->cancel();
1206  }
1207  }
1208  catch (const Exception&)
1209  {
1210  TOOLS_WARN_EXCEPTION("svx", "dropUnusedNamedItems(): exception during clearing of unused named items");
1211  }
1212  }
1213 
1214 } // namespace svx
1215 
1216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maOutputMimeType
Definition: xmlgrhlp.hxx:64
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:1125
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL loadGraphicFromOutputStream(css::uno::Reference< css::io::XOutputStream > const &rxOutputStream) override
Definition: xmlgrhlp.cxx:612
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
void SetSynchronMode(bool bTheSync=true)
std::unique_ptr< ContentProperties > pData
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:392
css::uno::Reference< css::embed::XStorage > xStorage
Definition: xmlgrhlp.hxx:45
#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:525
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:574
std::mutex maMutex
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
static SVX_DLLPRIVATE OUString ImplGetGraphicMimeType(const OUString &rFileName)
Definition: xmlgrhlp.cxx:494
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:56
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:910
std::mutex m_aMutex
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:55
bool IsAnimated() const
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:630
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:506
OUString aId
const char *const aMimeType[]
sal_uInt16 GetExportFormatNumberForMediaType(std::u16string_view rShortName)
std::unordered_map< OUString, css::uno::Reference< css::graphic::XGraphic > > maGraphicObjects
Definition: xmlgrhlp.hxx:60
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:892
virtual ~SvXMLGraphicHelper() override
Definition: xmlgrhlp.cxx:384
#define GRFILTER_FORMAT_DONTKNOW
GfxLink GetGfxLink() const
::osl::Mutex maMutex
Definition: xmlgrhlp.hxx:54
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:414
const GfxLink & GetLink() const
SvXMLGraphicHelperMode meCreateMode
Definition: xmlgrhlp.hxx:63
sal_uInt32 GetDataSize() const
std::vector< css::uno::Reference< css::io::XOutputStream > > maGrfStms
Definition: xmlgrhlp.hxx:58
exports com.sun.star. document
virtual OUString SAL_CALL saveGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic) override
Definition: xmlgrhlp.cxx:636
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:1154
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:38
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL loadGraphic(OUString const &aURL) override
Definition: xmlgrhlp.cxx:580
MetaActionType GetType() const
css::uno::Reference< css::io::XStream > xStream
Definition: xmlgrhlp.hxx:46
MetaAction * FirstAction()
static GraphicFilter & GetGraphicFilter()
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:864
virtual void SAL_CALL disposing() override
Definition: xmlgrhlp.cxx:388
SVX_DLLPRIVATE OUString implSaveGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, std::u16string_view rRequestName)
Definition: xmlgrhlp.cxx:642
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:1145
SVX_DLLPRIVATE SvxGraphicHelperStream_Impl ImplGetGraphicStream(const OUString &rPictureStorageName, const OUString &rPictureStreamName)
Definition: xmlgrhlp.cxx:448
std::unordered_map< Graphic, std::pair< OUString, OUString > > maExportGraphics
Definition: xmlgrhlp.hxx:61
#define SOFFICE_FILEFORMAT_8
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream(const OUString &rURL) override
Definition: xmlgrhlp.cxx:886
OUString sId