summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/xmlgrhlp.hxx8
-rw-r--r--offapi/com/sun/star/document/XGraphicStorageHandler.idl6
-rw-r--r--svx/source/xml/xmlgrhlp.cxx42
3 files changed, 47 insertions, 9 deletions
diff --git a/include/svx/xmlgrhlp.hxx b/include/svx/xmlgrhlp.hxx
index 0137f0044b67..a9eca5495a20 100644
--- a/include/svx/xmlgrhlp.hxx
+++ b/include/svx/xmlgrhlp.hxx
@@ -48,6 +48,7 @@ class SVX_DLLPUBLIC SvXMLGraphicHelper final : public cppu::WeakComponentImplHel
css::document::XGraphicStorageHandler,
css::document::XBinaryStreamResolver>
{
+private:
typedef ::std::pair< OUString, OUString > URLPair;
typedef ::std::vector< URLPair > URLPairVector;
typedef ::std::vector< GraphicObject > GraphicObjectVector;
@@ -94,6 +95,8 @@ class SVX_DLLPUBLIC SvXMLGraphicHelper final : public cppu::WeakComponentImplHel
virtual void SAL_CALL disposing() override;
+ SVX_DLLPRIVATE OUString implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName);
+
public:
SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode );
@@ -111,11 +114,14 @@ public:
// XGraphicStorageHandler
virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
- loadGraphic(const OUString& aURL) override;
+ loadGraphic(OUString const & aURL) override;
virtual OUString SAL_CALL
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;
+
virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
diff --git a/offapi/com/sun/star/document/XGraphicStorageHandler.idl b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
index 7172710df56d..b0c9ee2efa26 100644
--- a/offapi/com/sun/star/document/XGraphicStorageHandler.idl
+++ b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
@@ -15,15 +15,17 @@
module com { module sun { module star { module document {
-/** used to load, save and serialize XGraphic objects
-
+/** used to load, save and serialize XGraphic objects to the document storage
*/
interface XGraphicStorageHandler : com::sun::star::uno::XInterface
{
+
com::sun::star::graphic::XGraphic loadGraphic([in] string aURL);
string saveGraphic([in] com::sun::star::graphic::XGraphic xGraphic);
+ string saveGraphicByName([in] com::sun::star::graphic::XGraphic xGraphic, [in] string aRequestedName);
+
com::sun::star::io::XInputStream createInputStream([in] com::sun::star::graphic::XGraphic xGraphic);
};
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 296bd3f9a57e..e109defbefbe 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -695,10 +695,12 @@ bool SvXMLGraphicHelper::ImplWriteGraphic( const OUString& rPictureStorageName,
// higher PDF version, while aGfxLink still contains the
// original data provided by the user.
pStream->WriteBytes(rPdfData.getConstArray(), rPdfData.getLength());
- bRet = (pStream->GetError() == ERRCODE_NONE);
}
else
+ {
pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
+ }
+ bRet = (pStream->GetError() == ERRCODE_NONE);
}
else
{
@@ -991,7 +993,7 @@ OUString SAL_CALL SvXMLGraphicHelper::resolveGraphicObjectURL( const OUString& r
}
// XGraphicStorageHandler
-uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphic(const OUString& rURL)
+uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphic(OUString const & rURL)
{
osl::MutexGuard aGuard(maMutex);
@@ -1023,8 +1025,19 @@ uno::Reference<graphic::XGraphic> SAL_CALL SvXMLGraphicHelper::loadGraphic(const
return xGraphic;
}
+OUString SAL_CALL SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName)
+{
+ return implSaveGraphic(rxGraphic, rRequestName);
+}
+
OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic)
{
+ OUString aEmpty;
+ return implSaveGraphic(rxGraphic, aEmpty);
+}
+
+OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString const & rRequestName)
+{
Graphic aGraphic(rxGraphic);
auto aIterator = maExportGraphics.find(aGraphic);
@@ -1037,8 +1050,6 @@ OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graph
if (aGraphicObject.GetType() != GraphicType::NONE)
{
- OUString sId = OStringToOUString(aGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
-
const GfxLink aGfxLink(aGraphic.GetLink());
OUString aExtension;
bool bUseGfxLink = true;
@@ -1101,7 +1112,16 @@ OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graph
}
}
- OUString rPictureStreamName = sId + aExtension;
+ OUString rPictureStreamName;
+ if (!rRequestName.isEmpty())
+ {
+ rPictureStreamName = rRequestName + aExtension;
+ }
+ else
+ {
+ OUString sId = OStringToOUString(aGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
+ rPictureStreamName = sId + aExtension;
+ }
SvxGraphicHelperStream_Impl aStream(ImplGetGraphicStream(XML_GRAPHICSTORAGE_NAME, rPictureStreamName));
@@ -1158,10 +1178,12 @@ OUString SAL_CALL SvXMLGraphicHelper::saveGraphic(css::uno::Reference<css::graph
// higher PDF version, while aGfxLink still contains the
// original data provided by the user.
pStream->WriteBytes(rPdfData.getConstArray(), rPdfData.getLength());
- bSuccess = (pStream->GetError() == ERRCODE_NONE);
}
else
+ {
pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
+ }
+ bSuccess = (pStream->GetError() == ERRCODE_NONE);
}
else
{
@@ -1364,6 +1386,9 @@ protected:
virtual OUString SAL_CALL
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;
+
virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
@@ -1430,6 +1455,11 @@ 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)
+{
+ return m_xGraphicStorageHandler->saveGraphicByName(rxGraphic, rRequestName);
+}
+
uno::Reference<io::XInputStream> SAL_CALL SvXMLGraphicImportExportHelper::createInputStream(uno::Reference<graphic::XGraphic> const & rxGraphic)
{
return m_xGraphicStorageHandler->createInputStream(rxGraphic);