summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-19 21:47:04 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-21 21:32:56 +0100
commite48b4275ceee82bd0eb128b2947302b9022e9c89 (patch)
treec40d1d0d100c67c7fc8076e34b9d8e0769638d37 /svx
parent6fc75b669438728ba6a4e55d53a79fa0cf006529 (diff)
report the saved mimetype when saving graphic + mime from stream
When saving we need to determine which mime type to use for the graphic. Return this information back to the caller so the metadata can be written into the file if necessary. Also add function to determine the mime type from the XGraphic by converting it to a stream first (only then we can determine the format that will actually be used and written to the storage file. Change-Id: I796da715e47f29d77dea605a2769a2217ecd6ba5 Reviewed-on: https://gerrit.libreoffice.org/49992 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/xml/xmlgrhlp.cxx28
1 files changed, 21 insertions, 7 deletions
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 08eb4a2c0fa7..ffdf60a21972 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -1052,18 +1052,21 @@ uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphicFromOu
return xGraphic;
}
-OUString SAL_CALL SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName)
+OUString SAL_CALL SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ OUString & rOutSavedMimeType, OUString const & rRequestName)
{
- return implSaveGraphic(rxGraphic, rRequestName);
+ return implSaveGraphic(rxGraphic, rOutSavedMimeType, rRequestName);
}
OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
{
OUString aEmpty;
- return implSaveGraphic(rxGraphic, aEmpty);
+ OUString aOutMimeType;
+ return implSaveGraphic(rxGraphic, aOutMimeType, aEmpty);
}
-OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName)
+OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ OUString & rOutSavedMimeType, OUString const & rRequestName)
{
Graphic aGraphic(rxGraphic);
@@ -1210,6 +1213,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
{
pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
}
+ rOutSavedMimeType = aMimeType;
bSuccess = (pStream->GetError() == ERRCODE_NONE);
}
else
@@ -1220,9 +1224,14 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
OUString aFormat;
if (aGraphic.IsAnimated())
+ {
aFormat = "gif";
+ }
else
+ {
aFormat = "png";
+ }
+ rOutSavedMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aFormat.toUtf8());
bSuccess = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForShortName(aFormat)) == ERRCODE_NONE);
}
@@ -1230,6 +1239,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
{
pStream->SetVersion(SOFFICE_FILEFORMAT_8);
pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP);
+ rOutSavedMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension("svm");
// SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
GDIMetaFile& rMtf(const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()));
@@ -1247,11 +1257,14 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
pStream->WriteBytes(rLink.GetData(), rLink.GetDataSize());
}
else
+ {
rMtf.Write(*pStream);
+ }
bSuccess = (pStream->GetError() == ERRCODE_NONE);
}
}
+
if (!bSuccess)
return OUString();
@@ -1417,7 +1430,7 @@ protected:
saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
virtual OUString SAL_CALL
- saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName) override;
+ saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutSavedMimeType, OUString const & rRequestName) override;
virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
@@ -1490,9 +1503,10 @@ OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphic(css::uno::Referenc
return m_xGraphicStorageHandler->saveGraphic(rxGraphic);
}
-OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName)
+OUString SAL_CALL SvXMLGraphicImportExportHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ OUString & rOutSavedMimeType, OUString const & rRequestName)
{
- return m_xGraphicStorageHandler->saveGraphicByName(rxGraphic, rRequestName);
+ return m_xGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutSavedMimeType, rRequestName);
}
uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicImportExportHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)