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)
58 , mbReadOnly(bReadOnly)
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())
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())
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);
562 DBG_ASSERT(aTmpURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL");
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(
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);
703 for (sal_uInt32
i = 0;
i < nCount;
i++)
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);
SvStream & WriteBool(bool b)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadSgaObject(SvStream &rIn, SgaObject &rObj)
SAL_DLLPRIVATE Gallery * GetParent() const
std::vector< std::unique_ptr< GalleryObject > > & getObjectList()
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SgaObjectSvDraw insertModel(const FmFormModel &rModel, const INetURLObject &rUserURL)
bool SvxDrawingLayerExport(SdrModel *pModel, const uno::Reference< io::XOutputStream > &xOut, const Reference< lang::XComponent > &xComponent)
SgaObjectBmp insertGraphic(const Graphic &rGraphic, const GfxLink &aGfxLink, const ConvertDataFormat &nExportFormat, const INetURLObject &rUserURL)
css::uno::Any getPropertyValue(const OUString &rPropertyName)
#define STREAM_SEEK_TO_END
SAL_DLLPRIVATE const INetURLObject & GetRelativeURL() const
const INetURLObject & getURL() const
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteSgaObject(SvStream &rOut, const SgaObject &rObj)
FmFormModel * GetModel() const
EmbeddedObjectRef * pObject
void BurnInStyleSheetAttributes()
const sal_uInt8 * GetData() const
DateTime getModificationDate() const
bool CreateDir(const INetURLObject &rURL)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
SgaObjectSvDraw insertModelStream(const tools::SvRef< SotTempStream > &rxModelStream, const INetURLObject &rUserURL)
INetURLObject ImplGetURL(const GalleryObject *pObject)
bool implWriteSgaObject(const SgaObject &rObj, sal_uInt32 nPos, GalleryObject *pExistentEntry)
bool CopyTo(SotStorage *pDestStg)
const GDIMetaFile & GetGDIMetaFile() const
SvStream & WriteUInt32(sal_uInt32 nUInt32)
tools::SvRef< SotStorage > m_aSvDrawStorageRef
virtual void SetTitle(const OUString &rNewTitle) override
void insertObject(const SgaObject &rObj, GalleryObject *pFoundEntry, sal_uInt32 nInsertPos)
static bool FileExists(const INetURLObject &rURL, std::u16string_view rExt)
const INetURLObject & GetSdvURL() const
const INetURLObject & GetThmURL() const
#define TOOLS_WARN_EXCEPTION(area, stream)
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
#define ERRCODE_IO_GENERAL
#define DBG_ASSERT(sCon, aError)
OUString const & GetURL() const
static void insertFileOrDirURL(const INetURLObject &rFileOrDirURL, std::vector< INetURLObject > &rURLVector)
sal_uInt32 COMPAT_FORMAT(char char1, char char2, char char3, char char4)
tools::SvRef< SotStorageStream > OpenSotStream(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE)
SvStream & writeGalleryTheme(SvStream &rOStm, const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
void removeObject(const std::unique_ptr< GalleryObject > &pEntry)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
bool KillFile(const INetURLObject &rURL)
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
bool IsNameFromResource() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
void setDestDir(const OUString &rDestDir, bool bRelative)
bool readModel(const GalleryObject *pObject, SdrModel &rModel)
INetProtocol GetProtocol() const
const GalleryObject * getForPosition(sal_uInt32 nPos) const
SAL_DLLPRIVATE void ImplCreateSvDrawStorage()
const INetURLObject & GetSdgURL() const
void Write(SvStream &rStmToWrite)
Reference< XComponentContext > getProcessComponentContext()
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool readModelStream(const GalleryObject *pObject, tools::SvRef< SotTempStream > const &rxModelStream)
SAL_DLLPRIVATE bool implWrite(const GalleryTheme &rTheme, const GalleryThemeEntry *pThm)
static bool IsCoded(SvStream &rStm, sal_uInt32 &rVersion)
sal_uInt32 GetDataSize() const
#define SAL_WARN(area, stream)
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
SgaObjectSvDraw updateSvDrawObject(const GalleryObject *pEntry)
GalleryBinaryEngine(const GalleryBinaryStorageLocations &rGalleryStorageLocations, GalleryObjectCollection &rGalleryObjectCollection, bool bReadOnly)
std::unique_ptr< GalleryObjectStorage > m_pGalleryObjectStorage
static char const * GetExtensionForConvertDataFormat(ConvertDataFormat nFormat)
std::unique_ptr< SgaObject > implReadSgaObject(GalleryObject const *pEntry)
bool Remove(const OUString &rEleName)
const OUString & GetThemeName() const
INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject &rUserURL, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
SAL_DLLPRIVATE const tools::SvRef< SotStorage > & GetSvDrawStorage() const
SAL_DLLPRIVATE ~GalleryBinaryEngine()
GalleryObjectCollection & mrGalleryObjectCollection
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool m_bDetectedRangeSegmentation false