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);
216 pSgaObj->ImplUpdateURL(pEntry->
getURL());
238 if (!pOStm->GetError())
254 pEntry = pExistentEntry;
260 pEntry->
eObjKind = rObj.GetObjKind();
274 if (xSotStorage.
is())
278 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
280 if (xInputStream.
is() && !xInputStream->GetError())
284 xInputStream->SetBufferSize(0);
297 if (xSotStorage.
is())
301 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
303 if (xOutputStream.
is() && !xOutputStream->GetError())
311 uno::Reference<io::XOutputStream> xDocOut(
318 aMemoryStream.
Seek(0);
320 xOutputStream->SetBufferSize(16348);
322 aCodec.
Write(aMemoryStream);
324 xOutputStream->SetBufferSize(0);
325 xOutputStream->Commit();
326 bRet = !xOutputStream->GetError();
344 if (xSotStorage.
is())
348 xSotStorage->OpenSotStream(aStreamName, StreamMode::READ));
350 if (xInputStream.
is() && !xInputStream->GetError())
354 xInputStream->SetBufferSize(16348);
367 uno::Reference<io::XOutputStream> xDocOut(
378 xInputStream->SetBufferSize(0);
391 if (xSotStorage.
is())
395 xSotStorage->OpenSotStream(aStreamName, StreamMode::WRITE | StreamMode::TRUNC));
397 if (xOutputStream.
is() && !xOutputStream->GetError())
401 xOutputStream->SetBufferSize(16348);
402 aCodec.
Write(*rxModelStream);
404 if (!xOutputStream->GetError())
406 xOutputStream->Seek(0);
422 sal_uInt32 nNextNumber = 1999;
423 char const*
pExt =
nullptr;
429 aInfoFileURL.
Append(
u"sdddndx1");
439 pIStm->ReadUInt32(nNextNumber);
450 OUString aFileName =
"gallery/svdraw/dd" + OUString::number(++nNextNumber % 99999999);
451 aNewURL =
INetURLObject(aFileName, INetProtocol::PrivSoffice);
457 if (
pObject->getURL() == aNewURL)
466 OUString aFileName =
"dd" + OUString::number(++nNextNumber % 999999);
469 aFileName += OUString(
pExt, strlen(
pExt), RTL_TEXTENCODING_ASCII_US);
472 aNewURL.
Append(aFileName);
484 pOStm->WriteUInt32(nNextNumber);
495 std::unique_ptr<SvStream> pOStm(
497 StreamMode::WRITE | StreamMode::TRUNC));
504 if (ConvertDataFormat::SVM == nExportFormat)
541 if (pIStm.
is() && !pIStm->GetError())
543 pIStm->SetBufferSize(16384);
547 pIStm->SetBufferSize(0);
568 StreamMode::WRITE | StreamMode::TRUNC));
570 if (pIStm && pTmpStm)
575 std::unique_ptr<SgaObject> pObj;
603 pEntry->
nOffset = pTmpStm->Tell();
610 OSL_FAIL(
"File(s) could not be opened");
625 StreamMode::STD_READWRITE));
629 catch (
const css::ucb::ContentCreationException&)
648 std::vector<INetURLObject>& rURLVector)
654 uno::Reference<ucb::XCommandEnvironment>(),
656 bool bFolder =
false;
662 uno::Sequence<OUString> aProps{
"Url" };
663 uno::Reference<sdbc::XResultSet> xResultSet(
664 aCnt.
createCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY));
665 uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY);
666 if (xContentAccess.is())
668 while (xResultSet->next())
670 aURL.SetSmartURL(xContentAccess->queryContentIdentifierString());
671 rURLVector.push_back(
aURL);
676 rURLVector.push_back(rFileOrDirURL);
678 catch (
const ucb::ContentCreationException&)
681 catch (
const uno::RuntimeException&)
684 catch (
const uno::Exception&)
694 const sal_uInt32 rId = rTheme.
GetId();
700 RTL_TEXTENCODING_UTF8);
745 aPath = aPath.copy(std::min(
756 bool aFound = aPath.indexOf(
m_aDestDir) != -1;
775 const sal_uInt64 nReservePos = rOStm.
Tell();
788 std::unique_ptr<char[]> pReserve(
new char[nRest]);
789 memset(pReserve.get(), 0, nRest);
799 uno::Reference<ucb::XCommandEnvironment>(),
801 util::DateTime aDateTimeModified;
805 ::utl::typeConvert(aDateTimeModified, aDateTime);
void removeObject(const std::unique_ptr< GalleryObject > &pEntry)
bool readModel(const GalleryObject *pObject, SdrModel &rModel)
bool readModelStream(const GalleryObject *pObject, tools::SvRef< SotTempStream > const &rxModelStream)
SvStream & writeGalleryTheme(SvStream &rOStm, const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
SgaObjectSvDraw insertModel(const FmFormModel &rModel, const INetURLObject &rUserURL)
static void insertFileOrDirURL(const INetURLObject &rFileOrDirURL, std::vector< INetURLObject > &rURLVector)
SgaObjectSvDraw updateSvDrawObject(const GalleryObject *pEntry)
SAL_DLLPRIVATE bool implWrite(const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
tools::SvRef< SotStorage > m_aSvDrawStorageRef
bool implWriteSgaObject(const SgaObject &rObj, sal_uInt32 nPos, GalleryObject *pExistentEntry)
void insertObject(const SgaObject &rObj, GalleryObject *pFoundEntry, sal_uInt32 nInsertPos)
GalleryBinaryEngine(const GalleryBinaryStorageLocations &rGalleryStorageLocations, GalleryObjectCollection &rGalleryObjectCollection, bool bReadOnly)
SAL_DLLPRIVATE ~GalleryBinaryEngine()
SAL_DLLPRIVATE const tools::SvRef< SotStorage > & GetSvDrawStorage() const
SgaObjectBmp insertGraphic(const Graphic &rGraphic, const GfxLink &aGfxLink, const ConvertDataFormat &nExportFormat, const INetURLObject &rUserURL)
const INetURLObject & GetThmURL() const
std::unique_ptr< SgaObject > implReadSgaObject(GalleryObject const *pEntry)
const INetURLObject & GetSdvURL() const
INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject &rUserURL, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
GalleryObjectCollection & mrGalleryObjectCollection
SAL_DLLPRIVATE void ImplCreateSvDrawStorage()
const INetURLObject & GetSdgURL() const
DateTime getModificationDate() const
void setDestDir(const OUString &rDestDir, bool bRelative)
SgaObjectSvDraw insertModelStream(const tools::SvRef< SotTempStream > &rxModelStream, const INetURLObject &rUserURL)
void Write(SvStream &rStmToWrite)
static bool IsCoded(SvStream &rStm, sal_uInt32 &rVersion)
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)
const INetURLObject & getURL() const
std::unique_ptr< GalleryObjectStorage > m_pGalleryObjectStorage
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)