27#include <osl/thread.hxx>
35#include <com/sun/star/ucb/ContentCreationException.hpp>
36#include <com/sun/star/sdbc/XResultSet.hpp>
37#include <com/sun/star/ucb/XContentAccess.hpp>
43#include <tools/datetime.hxx>
56 : maGalleryStorageLocations(rGalleryBinaryStorageLocations)
57 , mrGalleryObjectCollection(rGalleryObjectCollection)
59 , m_bDestDirRelative(false)
80 mbReadOnly ? StreamMode::READ : StreamMode::STD_READWRITE);
87 catch (
const css::ucb::ContentCreationException&)
114 StreamMode::WRITE | StreamMode::COPY_ON_SYMLINK | StreamMode::TRUNC));
118 StreamMode::WRITE | StreamMode::TRUNC));
134 sal_uInt32 nInsertPos)
141 if (rObj.GetTitle().isEmpty())
147 const_cast<SgaObject&
>(rObj).
SetTitle(pOldObj->GetTitle());
150 else if (rObj.GetTitle() ==
"__<empty>__")
151 const_cast<SgaObject&
>(rObj).SetTitle(
"");
172 std::unique_ptr<SgaObject> pSgaObj;
181 sal_uInt32 nInventor;
185 pIStm->ReadUInt32(nInventor);
238 if (!pOStm->GetError())
254 pEntry = pExistentEntry;
259 pEntry->
eObjKind = rObj.GetObjKind();
273 if (xSotStorage.
is())
277 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
279 if (xInputStream.
is() && !xInputStream->GetError())
283 xInputStream->SetBufferSize(0);
296 if (xSotStorage.
is())
300 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
302 if (xOutputStream.
is() && !xOutputStream->GetError())
310 uno::Reference<io::XOutputStream> xDocOut(
317 aMemoryStream.
Seek(0);
319 xOutputStream->SetBufferSize(16348);
321 aCodec.
Write(aMemoryStream);
323 xOutputStream->SetBufferSize(0);
324 xOutputStream->Commit();
325 bRet = !xOutputStream->GetError();
343 if (xSotStorage.
is())
347 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
349 if (xInputStream.
is() && !xInputStream->GetError())
353 xInputStream->SetBufferSize(16348);
366 uno::Reference<io::XOutputStream> xDocOut(
377 xInputStream->SetBufferSize(0);
390 if (xSotStorage.
is())
394 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
396 if (xOutputStream.
is() && !xOutputStream->GetError())
400 xOutputStream->SetBufferSize(16348);
401 aCodec.
Write(*rxModelStream);
403 if (!xOutputStream->GetError())
405 xOutputStream->Seek(0);
421 sal_uInt32 nNextNumber = 1999;
422 char const*
pExt =
nullptr;
428 aInfoFileURL.
Append(
u"sdddndx1");
438 pIStm->ReadUInt32(nNextNumber);
449 OUString aFileName =
"gallery/svdraw/dd" + OUString::number(++nNextNumber % 99999999);
450 aNewURL =
INetURLObject(aFileName, INetProtocol::PrivSoffice);
456 if (*
pObject->m_oStorageUrl == aNewURL)
465 OUString aFileName =
"dd" + OUString::number(++nNextNumber % 999999);
468 aFileName += OUString(
pExt, strlen(
pExt), RTL_TEXTENCODING_ASCII_US);
471 aNewURL.
Append(aFileName);
483 pOStm->WriteUInt32(nNextNumber);
494 std::unique_ptr<SvStream> pOStm(
496 StreamMode::WRITE | StreamMode::TRUNC));
503 if (ConvertDataFormat::SVM == nExportFormat)
540 if (pIStm.
is() && !pIStm->GetError())
542 pIStm->SetBufferSize(16384);
546 pIStm->SetBufferSize(0);
567 StreamMode::WRITE | StreamMode::TRUNC));
569 if (pIStm && pTmpStm)
574 std::unique_ptr<SgaObject> pObj;
602 pEntry->
nOffset = pTmpStm->Tell();
609 OSL_FAIL(
"File(s) could not be opened");
624 StreamMode::STD_READWRITE));
628 catch (
const css::ucb::ContentCreationException&)
647 std::vector<INetURLObject>& rURLVector)
653 uno::Reference<ucb::XCommandEnvironment>(),
655 bool bFolder =
false;
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())
667 while (xResultSet->next())
669 aURL.SetSmartURL(xContentAccess->queryContentIdentifierString());
670 rURLVector.push_back(
aURL);
675 rURLVector.push_back(rFileOrDirURL);
677 catch (
const ucb::ContentCreationException&)
680 catch (
const uno::RuntimeException&)
683 catch (
const uno::Exception&)
693 const sal_uInt32 rId = rTheme.
GetId();
699 RTL_TEXTENCODING_UTF8);
746 aPath = aPath.copy(std::min(
757 bool aFound = aPath.indexOf(
m_aDestDir) != -1;
776 const sal_uInt64 nReservePos = rOStm.
Tell();
789 std::unique_ptr<char[]> pReserve(
new char[nRest]);
790 memset(pReserve.get(), 0, nRest);
800 uno::Reference<ucb::XCommandEnvironment>(),
802 util::DateTime aDateTimeModified;
806 ::utl::typeConvert(aDateTimeModified, aDateTime);
void Write(SvStream &rStmToWrite)
static bool IsCoded(SvStream &rStm, sal_uInt32 &rVersion)
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
bool IsNameFromResource() const
SAL_DLLPRIVATE Gallery * GetParent() const
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
SAL_DLLPRIVATE const INetURLObject & GetRelativeURL() const
const sal_uInt8 * GetData() const
sal_uInt32 GetDataSize() const
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 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()
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)
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)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual void SetTitle(const OUString &rNewTitle) override
EmbeddedObjectRef * pObject
#define ERRCODE_IO_GENERAL
static bool FileExists(const INetURLObject &rURL, std::u16string_view rExt)
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
bool CreateDir(const INetURLObject &rURL)
INetURLObject ImplGetURL(const GalleryObject *pObject)
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
bool KillFile(const INetURLObject &rURL)
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
SvStream & ReadSgaObject(SvStream &rIn, SgaObject &rObj)
SvStream & WriteSgaObject(SvStream &rOut, const SgaObject &rObj)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
#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)