LibreOffice Module svx (master) 1
galleryfilestorage.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 <svx/unomodel.hxx>
21#include <svx/fmmodel.hxx>
22#include <svx/galtheme.hxx>
23#include <galobj.hxx>
26#include <svx/gallery1.hxx>
27#include <osl/thread.hxx>
28#include "codec.hxx"
29#include "gallerydrawmodel.hxx"
30#include <vcl/cvtgrf.hxx>
32
33#include <sal/log.hxx>
34
35#include <com/sun/star/ucb/ContentCreationException.hpp>
36#include <com/sun/star/sdbc/XResultSet.hpp>
37#include <com/sun/star/ucb/XContentAccess.hpp>
41#include <tools/urlobj.hxx>
43#include <tools/datetime.hxx>
44#include <unotools/datetime.hxx>
47#include <unotools/tempfile.hxx>
48#include <ucbhelper/content.hxx>
49#include <tools/vcompat.hxx>
50
51using namespace ::com::sun::star;
52
54 const GalleryStorageLocations& rGalleryBinaryStorageLocations,
55 GalleryObjectCollection& rGalleryObjectCollection, bool bReadOnly)
56 : maGalleryStorageLocations(rGalleryBinaryStorageLocations)
57 , mrGalleryObjectCollection(rGalleryObjectCollection)
58 , mbReadOnly(bReadOnly)
59 , m_bDestDirRelative(false)
60{
62}
63
65
66void GalleryFileStorage::setDestDir(const OUString& rDestDir, bool bRelative)
67{
68 m_aDestDir = rDestDir;
69 m_bDestDirRelative = bRelative;
70}
71
73
75{
76 try
77 {
80 mbReadOnly ? StreamMode::READ : StreamMode::STD_READWRITE);
81 // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
82 if ((m_aSvDrawStorageRef->GetError() != ERRCODE_NONE) && !mbReadOnly)
85 StreamMode::READ);
86 }
87 catch (const css::ucb::ContentCreationException&)
88 {
89 TOOLS_WARN_EXCEPTION("svx", "failed to open: " << GetSdvURL().GetMainURL(
91 << "due to");
92 }
93}
94
96{
98}
99
101{
102 INetURLObject aPathURL(GetThmURL());
103
104 aPathURL.removeSegment();
105 aPathURL.removeFinalSlash();
106
107 DBG_ASSERT(aPathURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
108
109 if (FileExists(aPathURL) || CreateDir(aPathURL))
110 {
111#ifdef UNX
112 std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
114 StreamMode::WRITE | StreamMode::COPY_ON_SYMLINK | StreamMode::TRUNC));
115#else
116 std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
118 StreamMode::WRITE | StreamMode::TRUNC));
119#endif
120
121 if (pOStm)
122 {
123 writeGalleryTheme(*pOStm, rTheme, pThm);
124 pOStm.reset();
125 return true;
126 }
127
128 return false;
129 }
130 return true;
131}
132
133void GalleryFileStorage::insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry,
134 sal_uInt32 nInsertPos)
135{
136 if (pFoundEntry)
137 {
138 GalleryObject aNewEntry;
139
140 // update title of new object if necessary
141 if (rObj.GetTitle().isEmpty())
142 {
143 std::unique_ptr<SgaObject> pOldObj(implReadSgaObject(pFoundEntry));
144
145 if (pOldObj)
146 {
147 const_cast<SgaObject&>(rObj).SetTitle(pOldObj->GetTitle());
148 }
149 }
150 else if (rObj.GetTitle() == "__<empty>__")
151 const_cast<SgaObject&>(rObj).SetTitle("");
152
153 implWriteSgaObject(rObj, nInsertPos, &aNewEntry);
154 pFoundEntry->nOffset = aNewEntry.nOffset;
155 }
156 else
157 implWriteSgaObject(rObj, nInsertPos, nullptr);
158}
159
160void GalleryFileStorage::removeObject(const std::unique_ptr<GalleryObject>& pEntry)
161{
164
165 if (SgaObjKind::SvDraw == pEntry->eObjKind)
166 GetSvDrawStorage()->Remove(
167 pEntry->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE));
168}
169
170std::unique_ptr<SgaObject> GalleryFileStorage::implReadSgaObject(GalleryObject const* pEntry)
171{
172 std::unique_ptr<SgaObject> pSgaObj;
173
174 if (pEntry)
175 {
176 std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
177 GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
178
179 if (pIStm)
180 {
181 sal_uInt32 nInventor;
182
183 // Check to ensure that the file is a valid SGA file
184 pIStm->Seek(pEntry->nOffset);
185 pIStm->ReadUInt32(nInventor);
186
187 if (nInventor == COMPAT_FORMAT('S', 'G', 'A', '3'))
188 {
189 pIStm->Seek(pEntry->nOffset);
190
191 switch (pEntry->eObjKind)
192 {
194 pSgaObj.reset(new SgaObjectBmp());
195 break;
197 pSgaObj.reset(new SgaObjectAnim());
198 break;
199 case SgaObjKind::Inet:
200 pSgaObj.reset(new SgaObjectINet());
201 break;
203 pSgaObj.reset(new SgaObjectSvDraw());
204 break;
206 pSgaObj.reset(new SgaObjectSound());
207 break;
208
209 default:
210 break;
211 }
212
213 if (pSgaObj)
214 {
215 ReadSgaObject(*pIStm, *pSgaObj);
216 pSgaObj->ImplUpdateURL(*pEntry->m_oStorageUrl);
217 }
218 }
219 }
220 }
221
222 return pSgaObj;
223}
224
225bool GalleryFileStorage::implWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos,
226 GalleryObject* pExistentEntry)
227{
228 std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
229 GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE));
230 bool bRet = false;
231
232 if (pOStm)
233 {
234 const sal_uInt32 nOffset = pOStm->Seek(STREAM_SEEK_TO_END);
235
236 rObj.WriteData(*pOStm, m_aDestDir);
237
238 if (!pOStm->GetError())
239 {
240 GalleryObject* pEntry;
241
242 if (!pExistentEntry)
243 {
244 pEntry = new GalleryObject;
246 {
248 mrGalleryObjectCollection.getObjectList().begin() + nPos, pEntry);
249 }
250 else
251 mrGalleryObjectCollection.getObjectList().emplace_back(pEntry);
252 }
253 else
254 pEntry = pExistentEntry;
255
256 pEntry->m_oStorageUrl = rObj.GetURL();
257
258 pEntry->nOffset = nOffset;
259 pEntry->eObjKind = rObj.GetObjKind();
260 bRet = true;
261 }
262 }
263
264 return bRet;
265}
266
268{
270 bool bRet = false;
272
273 if (xSotStorage.is())
274 {
275 const OUString aStreamName(GetSvDrawStreamNameFromURL(aURL));
277 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
278
279 if (xInputStream.is() && !xInputStream->GetError())
280 {
281 xInputStream->SetBufferSize(STREAMBUF_SIZE);
282 bRet = GallerySvDrawImport(*xInputStream, rModel);
283 xInputStream->SetBufferSize(0);
284 }
285 }
286 return bRet;
287}
288
290 const INetURLObject& rUserURL)
291{
294 bool bRet = false;
295
296 if (xSotStorage.is())
297 {
298 const OUString aStreamName(GetSvDrawStreamNameFromURL(aURL));
299 tools::SvRef<SotStorageStream> xOutputStream(
300 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
301
302 if (xOutputStream.is() && !xOutputStream->GetError())
303 {
304 SvMemoryStream aMemoryStream(65535, 65535);
305 FmFormModel* pFormModel = const_cast<FmFormModel*>(&rModel);
306
307 pFormModel->BurnInStyleSheetAttributes();
308
309 {
310 uno::Reference<io::XOutputStream> xDocOut(
311 new utl::OOutputStreamWrapper(aMemoryStream));
312
313 if (xDocOut.is())
314 (void)SvxDrawingLayerExport(pFormModel, xDocOut);
315 }
316
317 aMemoryStream.Seek(0);
318
319 xOutputStream->SetBufferSize(16348);
320 GalleryCodec aCodec(*xOutputStream);
321 aCodec.Write(aMemoryStream);
322
323 xOutputStream->SetBufferSize(0);
324 xOutputStream->Commit();
325 bRet = !xOutputStream->GetError();
326 }
327 }
328 if (bRet)
329 {
330 SgaObjectSvDraw aObjSvDraw(rModel, aURL);
331 return aObjSvDraw;
332 }
333 return SgaObjectSvDraw();
334}
335
337 tools::SvRef<SotTempStream> const& rxModelStream)
338{
341 bool bRet = false;
342
343 if (xSotStorage.is())
344 {
345 const OUString aStreamName(GetSvDrawStreamNameFromURL(aURL));
347 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
348
349 if (xInputStream.is() && !xInputStream->GetError())
350 {
351 sal_uInt32 nVersion = 0;
352
353 xInputStream->SetBufferSize(16348);
354
355 if (GalleryCodec::IsCoded(*xInputStream, nVersion))
356 {
357 SvxGalleryDrawModel aModel;
358
359 if (aModel.GetModel())
360 {
361 if (GallerySvDrawImport(*xInputStream, *aModel.GetModel()))
362 {
364
365 {
366 uno::Reference<io::XOutputStream> xDocOut(
367 new utl::OOutputStreamWrapper(*rxModelStream));
368
369 SvxDrawingLayerExport(aModel.GetModel(), xDocOut);
370 }
371 }
372
373 bRet = (rxModelStream->GetError() == ERRCODE_NONE);
374 }
375 }
376
377 xInputStream->SetBufferSize(0);
378 }
379 }
380 return bRet;
381}
382
385 const INetURLObject& rUserURL)
386{
389
390 if (xSotStorage.is())
391 {
392 const OUString aStreamName(GetSvDrawStreamNameFromURL(aURL));
393 tools::SvRef<SotStorageStream> xOutputStream(
394 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
395
396 if (xOutputStream.is() && !xOutputStream->GetError())
397 {
398 GalleryCodec aCodec(*xOutputStream);
399
400 xOutputStream->SetBufferSize(16348);
401 aCodec.Write(*rxModelStream);
402
403 if (!xOutputStream->GetError())
404 {
405 xOutputStream->Seek(0);
406 SgaObjectSvDraw aObjSvDraw(*xOutputStream, aURL);
407 return aObjSvDraw;
408 }
409 }
410 }
411 return SgaObjectSvDraw();
412}
413
415 const INetURLObject& rUserURL,
416 ConvertDataFormat nFormat)
417{
418 INetURLObject aDir(rUserURL);
419 INetURLObject aInfoFileURL(rUserURL);
420 INetURLObject aNewURL;
421 sal_uInt32 nNextNumber = 1999;
422 char const* pExt = nullptr;
423 bool bExists;
424
425 aDir.Append(u"dragdrop");
426 CreateDir(aDir);
427
428 aInfoFileURL.Append(u"sdddndx1");
429
430 // read next possible number
431 if (FileExists(aInfoFileURL))
432 {
433 std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
434 aInfoFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
435
436 if (pIStm)
437 {
438 pIStm->ReadUInt32(nNextNumber);
439 }
440 }
441
443
444 do
445 {
446 // get URL
447 if (SgaObjKind::SvDraw == eObjKind)
448 {
449 OUString aFileName = "gallery/svdraw/dd" + OUString::number(++nNextNumber % 99999999);
450 aNewURL = INetURLObject(aFileName, INetProtocol::PrivSoffice);
451
452 bExists = false;
453
455 {
456 if (*pObject->m_oStorageUrl == aNewURL)
457 {
458 bExists = true;
459 break;
460 }
461 }
462 }
463 else
464 {
465 OUString aFileName = "dd" + OUString::number(++nNextNumber % 999999);
466
467 if (pExt)
468 aFileName += OUString(pExt, strlen(pExt), RTL_TEXTENCODING_ASCII_US);
469
470 aNewURL = aDir;
471 aNewURL.Append(aFileName);
472
473 bExists = FileExists(aNewURL);
474 }
475 } while (bExists);
476
477 // write updated number
478 std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
479 aInfoFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE));
480
481 if (pOStm)
482 {
483 pOStm->WriteUInt32(nNextNumber);
484 }
485
486 return aNewURL;
487}
488
490 const ConvertDataFormat& nExportFormat,
491 const INetURLObject& rUserURL)
492{
493 const INetURLObject aURL(implCreateUniqueURL(SgaObjKind::Bitmap, rUserURL, nExportFormat));
494 std::unique_ptr<SvStream> pOStm(
496 StreamMode::WRITE | StreamMode::TRUNC));
497 bool bRet = false;
498
499 if (pOStm)
500 {
501 pOStm->SetVersion(SOFFICE_FILEFORMAT_50);
502
503 if (ConvertDataFormat::SVM == nExportFormat)
504 {
505 GDIMetaFile aMtf(rGraphic.GetGDIMetaFile());
506
507 SvmWriter aWriter(*pOStm);
508 aWriter.Write(aMtf);
509 bRet = (pOStm->GetError() == ERRCODE_NONE);
510 }
511 else
512 {
513 if (aGfxLink.GetDataSize() && aGfxLink.GetData())
514 {
515 pOStm->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
516 bRet = (pOStm->GetError() == ERRCODE_NONE);
517 }
518 else
519 bRet = (GraphicConverter::Export(*pOStm, rGraphic, nExportFormat) == ERRCODE_NONE);
520 }
521
522 pOStm.reset();
523 }
524 if (bRet)
525 {
526 const SgaObjectBmp aObjBmp(aURL);
527 return aObjBmp;
528 }
529 return SgaObjectBmp();
530}
531
533{
534 if (GetSvDrawStorage().is())
535 {
536 const OUString aStmName(GetSvDrawStreamNameFromURL(*pEntry->m_oStorageUrl));
538 = GetSvDrawStorage()->OpenSotStream(aStmName, StreamMode::READ);
539
540 if (pIStm.is() && !pIStm->GetError())
541 {
542 pIStm->SetBufferSize(16384);
543
544 SgaObjectSvDraw aNewObj(*pIStm, *pEntry->m_oStorageUrl);
545
546 pIStm->SetBufferSize(0);
547
548 return aNewObj;
549 }
550 }
551 return SgaObjectSvDraw();
552}
553
555{
557 INetURLObject aInURL(GetSdgURL());
558 INetURLObject aTmpURL(aTmp.GetURL());
559
560 DBG_ASSERT(aInURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
561 DBG_ASSERT(aTmpURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
562
563 std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
564 aInURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
565 std::unique_ptr<SvStream> pTmpStm(::utl::UcbStreamHelper::CreateStream(
567 StreamMode::WRITE | StreamMode::TRUNC));
568
569 if (pIStm && pTmpStm)
570 {
571 for (const auto& i : mrGalleryObjectCollection.getObjectList())
572 {
573 GalleryObject* pEntry = i.get();
574 std::unique_ptr<SgaObject> pObj;
575
576 switch (pEntry->eObjKind)
577 {
579 pObj.reset(new SgaObjectBmp());
580 break;
582 pObj.reset(new SgaObjectAnim());
583 break;
584 case SgaObjKind::Inet:
585 pObj.reset(new SgaObjectINet());
586 break;
588 pObj.reset(new SgaObjectSvDraw());
589 break;
591 pObj.reset(new SgaObjectSound());
592 break;
593
594 default:
595 break;
596 }
597
598 if (pObj)
599 {
600 pIStm->Seek(pEntry->nOffset);
601 ReadSgaObject(*pIStm, *pObj);
602 pEntry->nOffset = pTmpStm->Tell();
603 WriteSgaObject(*pTmpStm, *pObj);
604 }
605 }
606 }
607 else
608 {
609 OSL_FAIL("File(s) could not be opened");
610 }
611
612 pIStm.reset();
613 pTmpStm.reset();
614
615 CopyFile(aTmpURL, aInURL);
616 KillFile(aTmpURL);
617
618 ErrCode nStorErr = ERRCODE_NONE;
619
620 try
621 {
622 tools::SvRef<SotStorage> aTempStorageRef(
624 StreamMode::STD_READWRITE));
625 GetSvDrawStorage()->CopyTo(aTempStorageRef.get());
626 nStorErr = GetSvDrawStorage()->GetError();
627 }
628 catch (const css::ucb::ContentCreationException&)
629 {
630 TOOLS_WARN_EXCEPTION("svx", "failed to open: "
632 << "due to");
633 nStorErr = ERRCODE_IO_GENERAL;
634 }
635
636 if (nStorErr == ERRCODE_NONE)
637 {
639 CopyFile(aTmpURL, GetSdvURL());
641 }
642
643 KillFile(aTmpURL);
644}
645
647 std::vector<INetURLObject>& rURLVector)
648{
650 try
651 {
653 uno::Reference<ucb::XCommandEnvironment>(),
655 bool bFolder = false;
656
657 aCnt.getPropertyValue("IsFolder") >>= bFolder;
658
659 if (bFolder)
660 {
661 uno::Sequence<OUString> aProps{ "Url" };
662 uno::Reference<sdbc::XResultSet> xResultSet(
663 aCnt.createCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY));
664 uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY);
665 if (xContentAccess.is())
666 {
667 while (xResultSet->next())
668 {
669 aURL.SetSmartURL(xContentAccess->queryContentIdentifierString());
670 rURLVector.push_back(aURL);
671 }
672 }
673 }
674 else
675 rURLVector.push_back(rFileOrDirURL);
676 }
677 catch (const ucb::ContentCreationException&)
678 {
679 }
680 catch (const uno::RuntimeException&)
681 {
682 }
683 catch (const uno::Exception&)
684 {
685 }
686}
687
689 const GalleryThemeEntry* pThm)
690{
691 const INetURLObject rRelURL1 = rTheme.GetParent()->GetRelativeURL();
692 const INetURLObject rRelURL2 = rTheme.GetParent()->GetUserURL();
693 const sal_uInt32 rId = rTheme.GetId();
695 bool bRel;
696
697 rOStm.WriteUInt16(0x0004);
699 RTL_TEXTENCODING_UTF8);
700 rOStm.WriteUInt32(nCount).WriteUInt16(osl_getThreadTextEncoding());
701
702 for (sal_uInt32 i = 0; i < nCount; i++)
703 {
705 OUString aPath;
706
707 if (SgaObjKind::SvDraw == pObj->eObjKind)
708 {
710 bRel = false;
711 }
712 else
713 {
714 aPath = pObj->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE);
715 aPath = aPath.copy(
716 0, std::min(rRelURL1.GetMainURL(INetURLObject::DecodeMechanism::NONE).getLength(),
717 aPath.getLength()));
718 bRel = aPath == rRelURL1.GetMainURL(INetURLObject::DecodeMechanism::NONE);
719
720 if (bRel
722 .getLength()
723 > (rRelURL1.GetMainURL(INetURLObject::DecodeMechanism::NONE).getLength() + 1)))
724 {
725 aPath = pObj->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE);
726 aPath = aPath.copy(
727 std::min(rRelURL1.GetMainURL(INetURLObject::DecodeMechanism::NONE).getLength(),
728 aPath.getLength()));
729 }
730 else
731 {
732 aPath = pObj->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE);
733 aPath = aPath.copy(
734 0,
735 std::min(rRelURL2.GetMainURL(INetURLObject::DecodeMechanism::NONE).getLength(),
736 aPath.getLength()));
737 bRel = aPath == rRelURL2.GetMainURL(INetURLObject::DecodeMechanism::NONE);
738
739 if (bRel
741 .getLength()
742 > (rRelURL2.GetMainURL(INetURLObject::DecodeMechanism::NONE).getLength()
743 + 1)))
744 {
745 aPath = pObj->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE);
746 aPath = aPath.copy(std::min(
748 aPath.getLength()));
749 }
750 else
751 aPath = pObj->m_oStorageUrl->GetMainURL(INetURLObject::DecodeMechanism::NONE);
752 }
753 }
754
755 if (!m_aDestDir.isEmpty())
756 {
757 bool aFound = aPath.indexOf(m_aDestDir) != -1;
758 aPath = aPath.replaceFirst(m_aDestDir, "");
759 if (aFound)
760 bRel = m_bDestDirRelative;
761 else
762 SAL_WARN("svx", "failed to replace destdir of '" << m_aDestDir << "' in '" << aPath
763 << "'");
764 }
765
766 rOStm.WriteBool(bRel);
767 write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStm, aPath, RTL_TEXTENCODING_UTF8);
768 rOStm.WriteUInt32(pObj->nOffset).WriteUInt16(static_cast<sal_uInt16>(pObj->eObjKind));
769 }
770
771 // more recently, a 512-byte reserve buffer is written,
772 // to recognize them two sal_uInt32-Ids will be written.
773 rOStm.WriteUInt32(COMPAT_FORMAT('G', 'A', 'L', 'R'))
774 .WriteUInt32(COMPAT_FORMAT('E', 'S', 'R', 'V'));
775
776 const sal_uInt64 nReservePos = rOStm.Tell();
777 std::unique_ptr<VersionCompatWrite> pCompat(new VersionCompatWrite(rOStm, 2));
778
779 rOStm.WriteUInt32(rId).WriteBool(pThm->IsNameFromResource()); // From version 2 and up
780
781 pCompat.reset();
782
783 // Fill the rest of the buffer.
784 const tools::Long nRest
785 = std::max(tools::Long(512 - (rOStm.Tell() - nReservePos)), tools::Long(0));
786
787 if (nRest)
788 {
789 std::unique_ptr<char[]> pReserve(new char[nRest]);
790 memset(pReserve.get(), 0, nRest);
791 rOStm.WriteBytes(pReserve.get(), nRest);
792 }
793
794 return rOStm;
795}
796
798{
800 uno::Reference<ucb::XCommandEnvironment>(),
802 util::DateTime aDateTimeModified;
803 DateTime aDateTime(DateTime::EMPTY);
804
805 aCnt.getPropertyValue("DateModified") >>= aDateTimeModified;
806 ::utl::typeConvert(aDateTimeModified, aDateTime);
807
808 return aDateTime;
809}
810
811/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Write(SvStream &rStmToWrite)
Definition: codec.cxx:56
static bool IsCoded(SvStream &rStm, sal_uInt32 &rVersion)
Definition: codec.cxx:32
tools::SvRef< SotStorage > m_aSvDrawStorageRef
SAL_DLLPRIVATE ~GalleryFileStorage()
SgaObjectSvDraw updateSvDrawObject(const GalleryObject *pEntry)
const INetURLObject & GetSdgURL() const
DateTime getModificationDate() const
void removeObject(const std::unique_ptr< GalleryObject > &pEntry)
SAL_DLLPRIVATE const tools::SvRef< SotStorage > & GetSvDrawStorage() const
SgaObjectSvDraw insertModelStream(const tools::SvRef< SotTempStream > &rxModelStream, const INetURLObject &rUserURL)
std::unique_ptr< SgaObject > implReadSgaObject(GalleryObject const *pEntry)
void setDestDir(const OUString &rDestDir, bool bRelative)
bool implWriteSgaObject(const SgaObject &rObj, sal_uInt32 nPos, GalleryObject *pExistentEntry)
SAL_DLLPRIVATE bool implWrite(const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
bool readModel(const GalleryObject *pObject, SdrModel &rModel)
SgaObjectSvDraw insertModel(const FmFormModel &rModel, const INetURLObject &rUserURL)
bool readModelStream(const GalleryObject *pObject, tools::SvRef< SotTempStream > const &rxModelStream)
SvStream & writeGalleryTheme(SvStream &rOStm, const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
GalleryFileStorage(const GalleryStorageLocations &rGalleryStorageLocations, GalleryObjectCollection &rGalleryObjectCollection, bool bReadOnly)
SgaObjectBmp insertGraphic(const Graphic &rGraphic, const GfxLink &aGfxLink, const ConvertDataFormat &nExportFormat, const INetURLObject &rUserURL)
INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject &rUserURL, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
static void insertFileOrDirURL(const INetURLObject &rFileOrDirURL, std::vector< INetURLObject > &rURLVector)
void insertObject(const SgaObject &rObj, GalleryObject *pFoundEntry, sal_uInt32 nInsertPos)
GalleryObjectCollection & mrGalleryObjectCollection
SAL_DLLPRIVATE void ImplCreateSvDrawStorage()
const INetURLObject & GetSdvURL() const
const INetURLObject & GetThmURL() const
const GalleryObject * getForPosition(sal_uInt32 nPos) const
std::vector< std::unique_ptr< GalleryObject > > & getObjectList()
const OUString & GetThemeName() const
Definition: gallery1.hxx:64
bool IsNameFromResource() const
Definition: gallery1.hxx:75
sal_uInt32 GetId() const
Definition: galtheme.cxx:772
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:118
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
Definition: gallery1.hxx:140
SAL_DLLPRIVATE const INetURLObject & GetRelativeURL() const
Definition: gallery1.hxx:141
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
const GDIMetaFile & GetGDIMetaFile() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeFinalSlash()
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
INetProtocol GetProtocol() const
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void BurnInStyleSheetAttributes()
Definition: svdmodel.cxx:794
sal_uInt64 Tell() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteBool(bool b)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & Write(const GDIMetaFile &rMetaFile)
FmFormModel * GetModel() const
static char const * GetExtensionForConvertDataFormat(ConvertDataFormat nFormat)
T * get() const
bool is() const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
css::uno::Reference< css::sdbc::XResultSet > createCursor(const css::uno::Sequence< OUString > &rPropertyNames, ResultSetInclude eMode=INCLUDE_FOLDERS_AND_DOCUMENTS)
OUString const & GetURL() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
virtual void SetTitle(const OUString &rNewTitle) override
float u
EmbeddedObjectRef * pObject
#define ERRCODE_IO_GENERAL
#define ERRCODE_NONE
sal_Int16 nVersion
#define SOFFICE_FILEFORMAT_50
bool bReadOnly
static bool FileExists(const INetURLObject &rURL, std::u16string_view rExt)
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
Definition: galmisc.cxx:76
bool CreateDir(const INetURLObject &rURL)
Definition: galmisc.cxx:229
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:553
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
Definition: galmisc.cxx:188
bool KillFile(const INetURLObject &rURL)
Definition: galmisc.cxx:287
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
Definition: galmisc.cxx:261
SgaObjKind
Definition: galmisc.hxx:57
#define STREAMBUF_SIZE
Definition: galmisc.hxx:68
SvStream & ReadSgaObject(SvStream &rIn, SgaObject &rObj)
Definition: galobj.cxx:247
SvStream & WriteSgaObject(SvStream &rOut, const SgaObject &rObj)
Definition: galobj.cxx:241
sal_uInt16 nPos
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
int i
long Long
ConvertDataFormat
#define STREAM_SEEK_TO_END
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
std::optional< INetURLObject > m_oStorageUrl
sal_uInt32 COMPAT_FORMAT(char char1, char char2, char char3, char char4)
bool SvxDrawingLayerExport(SdrModel *pModel, const uno::Reference< io::XOutputStream > &xOut, const Reference< lang::XComponent > &xComponent)
Definition: xmlexport.cxx:40
const char * pExt
Definition: xtable.cxx:372