summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-10 16:06:54 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-03-10 17:08:22 +0100
commit80918a529bed72a06779fc59d9379be97cb8aca3 (patch)
treead8471df2981afd9bf295241c1569bd2a76383e4 /slideshow
parentba98f6e3e4dbfc23474e13d59bb08c618ee8c4e5 (diff)
slideshow: convert use of GraphicURL to Graphic property
Change-Id: I4e933d592d3408dd7887b81f2efb69068af88202 Reviewed-on: https://gerrit.libreoffice.org/51040 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/shapes/shapeimporter.cxx71
1 files changed, 7 insertions, 64 deletions
diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx
index 3d4122cda94b..3f31fac1099a 100644
--- a/slideshow/source/engine/shapes/shapeimporter.cxx
+++ b/slideshow/source/engine/shapes/shapeimporter.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/drawing/XLayerSupplier.hpp>
#include <com/sun/star/drawing/XLayerManager.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@@ -64,77 +65,19 @@ std::unique_ptr<GraphicObject> importShapeGraphic(uno::Reference<beans::XPropert
{
std::unique_ptr<GraphicObject> xRet;
- OUString aURL;
- if( !getPropertyValue( aURL, xPropSet, "GraphicURL") ||
- aURL.isEmpty() )
+ uno::Reference<graphic::XGraphic> xGraphic;
+ if (!getPropertyValue(xGraphic, xPropSet, "Graphic") || !xGraphic.is())
{
// no or empty property - cannot import shape graphic
return xRet;
}
- OUString const aVndUrl(
- "vnd.sun.star.GraphicObject:" );
- sal_Int32 nIndex( aURL.indexOf( aVndUrl ) );
+ Graphic aGraphic(xGraphic);
+ xRet.reset(new GraphicObject(aGraphic));
- if(nIndex != -1)
+ if (GraphicType::Default == xRet->GetType() || GraphicType::NONE == xRet->GetType())
{
- // skip past the end of the "vnd..." prefix
- nIndex += aVndUrl.getLength();
-
- if(nIndex >= aURL.getLength())
- {
- OSL_FAIL( "ShapeImporter::importShape(): "
- "embedded graphic has no graphic ID" );
- return nullptr;
- }
-
- // unique ID string found in URL, extract
- // to separate string
- OUString const aUniqueId( aURL.copy( nIndex ) );
-
- // TODO(T2): Creating a GraphicObject is not
- // thread safe (internally calls VCL, and has
- // unguarded internal singleton mpGlobalMgr)
-
- // fetch already loaded graphic from graphic manager.
- OString const aOldString(OUStringToOString(aUniqueId,
- RTL_TEXTENCODING_UTF8));
- xRet.reset(new GraphicObject(aOldString));
-
-
- if (GraphicType::Default == xRet->GetType()
- || GraphicType::NONE == xRet->GetType())
- {
- // even the GrfMgr does not seem to know this graphic
- return nullptr;
- }
- }
- else
- {
- // no special string found, graphic must be
- // external. Load via GraphicIm porter
- INetURLObject aTmp( aURL );
- std::unique_ptr<SvStream> pGraphicStream(
- utl::UcbStreamHelper::CreateStream(
- aTmp.GetMainURL( INetURLObject::DecodeMechanism::NONE ),
- StreamMode::READ ) );
- if( !pGraphicStream )
- {
- OSL_FAIL( "ShapeImporter::importShape(): "
- "cannot create input stream for graphic" );
- return nullptr;
- }
-
- Graphic aTmpGraphic;
- if( GraphicConverter::Import(
- *pGraphicStream, aTmpGraphic ) != ERRCODE_NONE )
- {
- OSL_FAIL( "ShapeImporter::importShape(): "
- "Failed to import shape graphic from given URL" );
- return nullptr;
- }
-
- xRet.reset(new GraphicObject(aTmpGraphic));
+ xRet.reset();
}
return xRet;
}