summaryrefslogtreecommitdiff
path: root/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx')
-rw-r--r--sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx126
1 files changed, 59 insertions, 67 deletions
diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx
index b387af6c2cba..7bc2713abaad 100644
--- a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx
+++ b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx
@@ -30,6 +30,7 @@
#include <vcl/image.hxx>
#include <vcl/pngread.hxx>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/StorageFactory.hpp>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
@@ -112,93 +113,84 @@ Image TemplatePreviewProvider::operator() (
// Load the thumbnail from a template document.
uno::Reference<io::XInputStream> xIStream;
- uno::Reference< lang::XMultiServiceFactory > xServiceManager (
- ::comphelper::getProcessServiceFactory());
- if (xServiceManager.is())
+ uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
+ try
{
+ uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create(xContext);
+
+ uno::Sequence<uno::Any> aArgs (2);
+ aArgs[0] <<= msURL;
+ aArgs[1] <<= embed::ElementModes::READ;
+ uno::Reference<embed::XStorage> xDocStorage (
+ xStorageFactory->createInstanceWithArguments(aArgs),
+ uno::UNO_QUERY);
+
try
{
- uno::Reference<lang::XSingleServiceFactory> xStorageFactory(
- xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"),
- uno::UNO_QUERY);
-
- if (xStorageFactory.is())
+ if (xDocStorage.is())
{
- uno::Sequence<uno::Any> aArgs (2);
- aArgs[0] <<= msURL;
- aArgs[1] <<= embed::ElementModes::READ;
- uno::Reference<embed::XStorage> xDocStorage (
- xStorageFactory->createInstanceWithArguments(aArgs),
- uno::UNO_QUERY);
-
- try
- {
- if (xDocStorage.is())
- {
- uno::Reference<embed::XStorage> xStorage (
- xDocStorage->openStorageElement(
- "Thumbnails",
- embed::ElementModes::READ));
- if (xStorage.is())
- {
- uno::Reference<io::XStream> xThumbnailCopy (
- xStorage->cloneStreamElement("thumbnail.png"));
- if (xThumbnailCopy.is())
- xIStream = xThumbnailCopy->getInputStream();
- }
- }
- }
- catch (const uno::Exception& rException)
+ uno::Reference<embed::XStorage> xStorage (
+ xDocStorage->openStorageElement(
+ "Thumbnails",
+ embed::ElementModes::READ));
+ if (xStorage.is())
{
- OSL_TRACE (
- "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s",
- ::rtl::OUStringToOString(msURL,
- RTL_TEXTENCODING_UTF8).getStr(),
- ::rtl::OUStringToOString(rException.Message,
- RTL_TEXTENCODING_UTF8).getStr());
+ uno::Reference<io::XStream> xThumbnailCopy (
+ xStorage->cloneStreamElement("thumbnail.png"));
+ if (xThumbnailCopy.is())
+ xIStream = xThumbnailCopy->getInputStream();
}
+ }
+ }
+ catch (const uno::Exception& rException)
+ {
+ OSL_TRACE (
+ "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s",
+ ::rtl::OUStringToOString(msURL,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
- try
- {
- // An (older) implementation had a bug - The storage
- // name was "Thumbnail" instead of "Thumbnails". The
- // old name is still used as fallback but this code can
- // be removed soon.
- if ( ! xIStream.is())
- {
- uno::Reference<embed::XStorage> xStorage (
- xDocStorage->openStorageElement( "Thumbnail",
- embed::ElementModes::READ));
- if (xStorage.is())
- {
- uno::Reference<io::XStream> xThumbnailCopy (
- xStorage->cloneStreamElement("thumbnail.png"));
- if (xThumbnailCopy.is())
- xIStream = xThumbnailCopy->getInputStream();
- }
- }
- }
- catch (const uno::Exception& rException)
+ try
+ {
+ // An (older) implementation had a bug - The storage
+ // name was "Thumbnail" instead of "Thumbnails". The
+ // old name is still used as fallback but this code can
+ // be removed soon.
+ if ( ! xIStream.is())
+ {
+ uno::Reference<embed::XStorage> xStorage (
+ xDocStorage->openStorageElement( "Thumbnail",
+ embed::ElementModes::READ));
+ if (xStorage.is())
{
- OSL_TRACE (
- "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s",
- ::rtl::OUStringToOString(msURL,
- RTL_TEXTENCODING_UTF8).getStr(),
- ::rtl::OUStringToOString(rException.Message,
- RTL_TEXTENCODING_UTF8).getStr());
+ uno::Reference<io::XStream> xThumbnailCopy (
+ xStorage->cloneStreamElement("thumbnail.png"));
+ if (xThumbnailCopy.is())
+ xIStream = xThumbnailCopy->getInputStream();
}
}
}
catch (const uno::Exception& rException)
{
OSL_TRACE (
- "caught exception while trying to access tuhmbnail of %s: %s",
+ "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s",
::rtl::OUStringToOString(msURL,
RTL_TEXTENCODING_UTF8).getStr(),
::rtl::OUStringToOString(rException.Message,
RTL_TEXTENCODING_UTF8).getStr());
}
}
+ catch (const uno::Exception& rException)
+ {
+ OSL_TRACE (
+ "caught exception while trying to access tuhmbnail of %s: %s",
+ ::rtl::OUStringToOString(msURL,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
// Extract the image from the stream.
BitmapEx aThumbnail;