Commits

Juergen Schmidt  committed 01c09b1

jsc342: i117866: new service to provide simplified access to some office graphic resources

  • Participants
  • Parent commits 21b3740

Comments (0)

Files changed (9)

File comphelper/JunitTest_comphelper_complex.mk

 $(eval $(call gb_JunitTest_add_sourcefiles,comphelper_complex,\
 	comphelper/qa/complex/comphelper/Map \
 	comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest \
+	comphelper/qa/complex/comphelper/ImageProviderUnitTest \
 ))
 
 $(eval $(call gb_JunitTest_add_jars,comphelper_complex,\
 ))
 
 $(eval $(call gb_JunitTest_add_classes,comphelper_complex,\
+	complex.comphelper.Map \
 	complex.comphelper.SequenceOutputStreamUnitTest \
-	complex.comphelper.Map \
+	complex.comphelper.ImageProviderUnitTest \
 ))
 
 # vim: set noet sw=4 ts=4:

File comphelper/Library_comphelp.mk

 	comphelper/source/misc/ihwrapnofilter \
 	comphelper/source/misc/instancelocker \
 	comphelper/source/misc/interaction \
+	comphelper/source/misc/imageprovider \
 	comphelper/source/misc/legacysingletonfactory \
 	comphelper/source/misc/listenernotification \
 	comphelper/source/misc/locale \
 	comphelper/source/misc/uieventslogger \
 	comphelper/source/misc/weak \
 	comphelper/source/misc/weakeventlistener \
-    comphelper/source/officeinstdir/officeinstallationdirectories \
+	comphelper/source/officeinstdir/officeinstallationdirectories \
 	comphelper/source/processfactory/componentfactory \
 	comphelper/source/processfactory/processfactory \
 	comphelper/source/property/ChainablePropertySet \

File comphelper/qa/complex/comphelper/ImageProviderUnitTest.java

+/*
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * 
+ * OpenOffice.org - a multi-platform office productivity suite
+ * 
+ * This file is part of OpenOffice.org.
+ * 
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ * 
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package complex.comphelper;
+
+import com.sun.star.awt.Size;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.graphic.XGraphic;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ui.ImageProvider;
+import com.sun.star.ui.XImageProvider;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XInterface;
+
+// import org.junit.After;
+import org.junit.AfterClass;
+// import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+
+/** complex test case for the css.util.ImageProvider implementation
+ *
+ * @author jsc
+ */
+public class ImageProviderUnitTest {
+
+    private XImageProvider createImageProvider() {
+        final XComponentContext xContext = connection.getComponentContext();
+        final XImageProvider xProvider = com.sun.star.ui.ImageProvider.create(xContext);
+        return xProvider;
+    }
+
+    @Test public void testHighContrastProperty() throws com.sun.star.uno.Exception
+    {
+        System.out.print("ImageProvider: Test 01 - check property ...");
+
+        final XImageProvider xImgProvider = createImageProvider();
+        assertNotNull("ImageProvider: can't be instantiated", xImgProvider);
+
+        XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xImgProvider);
+        assertNotNull("ImageProvider: doesn't support XPropertySet", xProps);
+
+        XPropertySetInfo xPropInfo = xProps.getPropertySetInfo();
+        assertNotNull("ImageProvider doesn't support XPropertySetInfo", xPropInfo);
+ 
+        final String propname = "HighContrastMode";
+        assertEquals("ImageProvider: doesn't support property HighContrastMode", true, xPropInfo.hasPropertyByName(propname));
+
+        Object o = xPropInfo.getPropertyByName(propname);
+        Property prop = (Property)AnyConverter.toObject(Property.class, o);
+        assertEquals("ImageProvider: property name mismatch", propname, prop.Name);
+        assertEquals("ImageProvider: wrong property type", com.sun.star.uno.Type.BOOLEAN, prop.Type);
+
+        o = xProps.getPropertyValue(propname);
+        boolean hcMode = AnyConverter.toBoolean(o);
+        assertFalse("ImageProvider: wrong initial value for HighContrastProperty", hcMode);
+
+        xProps.setPropertyValue(propname, true);
+        o = xProps.getPropertyValue(propname);
+        hcMode = AnyConverter.toBoolean(o);
+        assertTrue("ImageProvider: error to set HighContrastProperty", hcMode);
+
+        xProps.setPropertyValue(propname, false);
+
+        Property[] props = xPropInfo.getProperties();
+        assertEquals("ImageProvider: unexpected amout of supported properties", 1,  props.length);
+        assertEquals("ImageProvider: unexpected property name", propname ,props[0].Name);
+
+        System.out.println(" OK!");
+    }
+
+    @Test public void testFileTypeIconByMimeType() throws com.sun.star.uno.Exception
+    {
+        System.out.print( "ImageProvider: Test 02 - check FileTypeIconByMimeType...");
+
+        String[] mimetypes = { "application/vnd.oasis.opendocument.text",
+            "application/vnd.oasis.opendocument.text-master",
+            "application/vnd.oasis.opendocument.text-template",
+            "application/vnd.oasis.opendocument.spreadsheet",
+            "application/vnd.oasis.opendocument.spreadsheet-template",
+            "application/vnd.oasis.opendocument.presentation",
+            "application/vnd.oasis.opendocument.presentation-template",
+            "application/vnd.oasis.opendocument.graphics",
+            "application/vnd.oasis.opendocument.graphics-template",
+            "application/vnd.oasis.opendocument.formular",
+            "application/msword",
+            "application/msword-xml",
+            "application/vnd.ms-excel",
+            "application/vnd.ms-excel-xml",
+            "application/vnd.ms-powerpoint",
+            "application/rtf",
+            "text/plain",
+            "text/html",
+            "text/pdf",
+            "application/octet-stream",
+            "image/jpg",
+            "image/png",
+            "image/tiff",
+            "default_dummy_bablubber" };
+
+        final XImageProvider xImgProvider = createImageProvider();
+        assertNotNull(xImgProvider);
+
+        for (String mt : mimetypes) {
+            XGraphic xGraphic = xImgProvider.getFileTypeIconByMimeType(mt, (short)16);
+            assertNotNull("ImageProvider: unexpected null interface", xGraphic);
+
+            XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xGraphic);
+
+            XPropertySetInfo xPropInfo = xProps.getPropertySetInfo();
+            Property[] props = xPropInfo.getProperties();
+
+            Size sz = (Size)AnyConverter.toObject(Size.class, xProps.getPropertyValue("SizePixel"));
+            assertEquals("ImageProvider: unexpected size", 16, sz.Width);
+            assertEquals("ImageProvider: unexpected size", 16, sz.Height);
+
+            xGraphic = xImgProvider.getFileTypeIconByMimeType(mt, (short)32);
+            assertNotNull("ImageProvider: unexpected null interface", xGraphic);
+
+            xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xGraphic);
+            sz = (Size)AnyConverter.toObject(Size.class, xProps.getPropertyValue("SizePixel"));
+            assertEquals("ImageProvider: unexpected size", 32, sz.Width);
+            assertEquals("ImageProvider: unexpected size", 32, sz.Height);
+
+            // test default -> size != 16|32
+            try {
+                xGraphic = xImgProvider.getFileTypeIconByMimeType(mt, (short)99);
+                // should never reached
+                fail("ImageProvider: no expected IllegalArgumentException");
+            } catch (com.sun.star.lang.IllegalArgumentException e) {
+                assertEquals("XImageProvider.getFileTypeIconByMimeType with unsupported iconssize", 2, e.ArgumentPosition);
+            }
+        }
+        System.out.println(" OK!");
+    }
+
+    @Test public void testIconByName() throws com.sun.star.uno.Exception
+    {
+        System.out.print("ImageProvider: Test 03 - check IconByName ...");
+
+        final String[] names = { "folder_open",
+            "folder_up",
+            "arrow_up",
+            "arrow_down",
+            "undo",
+            "redo",
+            "caution",
+            "oologo",
+            "lock",
+            "checkmark_green",
+            "home",
+            "watch" };
+
+
+        final XImageProvider xImgProvider = createImageProvider();
+        assertNotNull(xImgProvider);
+
+        for (String name : names) {
+            // iconsize is currently ignored and only 16x16 icons are returned
+            XGraphic xGraphic = xImgProvider.getIconByName(name, (short)0);
+            assertNotNull("ImageProvider: unexpected null interface", xGraphic);
+
+            XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xGraphic);
+            Size sz = (Size)AnyConverter.toObject(Size.class, xProps.getPropertyValue("SizePixel"));
+            assertEquals("ImageProvider: unexpected size", 16, sz.Width);
+            assertEquals("ImageProvider: unexpected size", 16, sz.Width);
+        }
+
+        // test unknown name -> should be null
+        XGraphic xGraphic = xImgProvider.getIconByName("blablubber", (short)0);
+        assertNull("ImageProvider: unexpected not null interface", xGraphic);
+        System.out.println(" OK!");
+    }
+
+    private XMultiServiceFactory getMSF()
+    {
+        final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+        return xMSF1;
+    }
+
+    // setup and close connections
+    @BeforeClass public static void setUpConnection() throws Exception {
+        System.out.println("setUpConnection()");
+        connection.setUp();
+    }
+
+    @AfterClass public static void tearDownConnection()
+        throws InterruptedException, com.sun.star.uno.Exception
+    {
+        System.out.println("tearDownConnection()");
+        connection.tearDown();
+    }
+
+    private static final OfficeConnection connection = new OfficeConnection();
+}

File comphelper/source/misc/comphelper_services.cxx

 extern void createRegistryInfo_Map();
 extern void createRegistryInfo_OSimpleLogRing();
 extern void createRegistryInfo_OOfficeRestartManager();
+extern void createRegistryInfo_ImageProvider();
 
 //........................................................................
 namespace comphelper { namespace module
                 createRegistryInfo_Map();
                 createRegistryInfo_OSimpleLogRing();
                 createRegistryInfo_OOfficeRestartManager();
+                createRegistryInfo_ImageProvider();
             }
         }
     }

File comphelper/source/misc/imageprovider.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER( update_precomp.py ): autogen include statement, do not remove
+#include "precompiled_comphelper.hxx"
+
+#include "comphelper_module.hxx"
+
+#include "vector"
+#include "hash_map"
+
+#include "sal/config.h"
+#include "rtl/ustrbuf.hxx"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/implbase4.hxx"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/graphic/XGraphicProvider.hpp"
+#include "com/sun/star/ui/XImageProvider.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/uno/TypeClass.hpp"
+
+
+/// anonymous implementation namespace
+namespace {
+
+namespace css = ::com::sun::star;
+
+typedef ::std::vector< ::rtl::OUString > NameParts;
+typedef ::std::hash_map< ::rtl::OUString, NameParts,
+                         ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameMapping;
+                         
+class ImageProviderService:
+    public ::cppu::WeakImplHelper4<
+        css::ui::XImageProvider,
+        css::lang::XServiceInfo,
+        css::beans::XPropertySet,
+        css::beans::XPropertySetInfo>
+{
+public:
+    explicit ImageProviderService(css::uno::Reference< css::uno::XComponentContext > const & context);
+
+    // ::com::sun::star::ui::XImageProvider:
+    virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getFileTypeIconByMimeType(
+        const ::rtl::OUString & mimetype, ::sal_Int16 iconsize)
+        throw (css::uno::RuntimeException, css::lang::IllegalArgumentException);
+    virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIconByName(
+        const ::rtl::OUString & name, ::sal_Int16 iconsize)
+        throw (css::uno::RuntimeException, css::lang::IllegalArgumentException);
+
+    // ::com::sun::star::lang::XServiceInfo:
+    virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException);
+    virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException);
+
+        // XServiceInfo - static versions (used for component registration)
+    static ::rtl::OUString SAL_CALL getImplementationName_static();
+    static css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+    static css::uno::Reference< css::uno::XInterface > SAL_CALL Create(
+        const css::uno::Reference< css::uno::XComponentContext >& context);
+
+    // ::com::sun::star::beans::XPropertySet:
+    // XPropertySet interface is misued here and only the set/get methods and getPropertySetInfoare
+    // implemented to support an implementation detail for accessibility (should be later changed) 
+    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
+        throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setPropertyValue(const ::rtl::OUString & propertyName,
+                                           const ::com::sun::star::uno::Any & value)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+               css::lang::IllegalArgumentException, css::lang::WrappedTargetException);
+    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString & propertyName)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException);
+    virtual void SAL_CALL addPropertyChangeListener(
+        const ::rtl::OUString & propertyName,
+        const css::uno::Reference< css::beans::XPropertyChangeListener > & xListener)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException);
+    virtual void SAL_CALL removePropertyChangeListener(
+        const ::rtl::OUString & propertyName,
+        const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException);
+    virtual void SAL_CALL addVetoableChangeListener(
+        const ::rtl::OUString & propertyName,
+        const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException);
+    virtual void SAL_CALL removeVetoableChangeListener(
+        const ::rtl::OUString & propertyName,
+        const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException);
+
+    // ::com::sun::star::beans::XPropertySetInfo:
+    virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() throw (css::uno::RuntimeException);
+    virtual css::beans::Property SAL_CALL getPropertyByName(const ::rtl::OUString & aName)
+        throw (css::uno::RuntimeException, css::beans::UnknownPropertyException);
+    virtual ::sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString & Name) throw (css::uno::RuntimeException);
+
+private:
+    ImageProviderService(const ImageProviderService &); // not defined
+    ImageProviderService& operator=(const ImageProviderService &); // not defined
+
+    // destructor is private and will be called indirectly by the release call    virtual ~ImageProviderService() {}
+
+    css::uno::Reference< css::graphic::XGraphic > SAL_CALL getGraphic(const ::rtl::OUString & imgurl);
+    
+    css::uno::Reference< css::uno::XComponentContext > m_xContext;
+    css::uno::Reference< css::graphic::XGraphicProvider > m_xProvider;
+    bool m_hcMode;
+
+    NameMapping m_mapping;
+};
+
+ImageProviderService::ImageProviderService(css::uno::Reference< css::uno::XComponentContext > const & context) :
+    m_xContext(context),
+    m_hcMode(false)
+{
+    m_xProvider = css::uno::Reference< css::graphic::XGraphicProvider >(
+        m_xContext->getServiceManager()->createInstanceWithContext(
+            ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")), m_xContext),
+        css::uno::UNO_QUERY_THROW);
+
+}
+
+// ::com::sun::star::ui::XImageProvider:
+css::uno::Reference< css::graphic::XGraphic > SAL_CALL ImageProviderService::getFileTypeIconByMimeType(
+    const ::rtl::OUString & mimetype, ::sal_Int16 iconsize) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
+{
+    ::rtl::OUStringBuffer imgurl(48);
+    imgurl.appendAscii("private:graphicrepository/res/");
+
+    // only 16x16 and 32x32 are supported, Illegel 
+    if (iconsize == 16)
+        imgurl.appendAscii("sx");
+    else if (iconsize == 32)
+        imgurl.appendAscii("lx");
+    else
+        throw  css::lang::IllegalArgumentException(
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("wrong iconsize, supported 16 and 32")),
+            css::uno::Reference< css::uno::XInterface >(), 2);
+    
+    if (m_hcMode) imgurl.appendAscii("h");
+        
+    if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.text"))))       
+        imgurl.appendAscii("03251.png");        
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.text-master")))) 
+        imgurl.appendAscii("03248.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.text-template"))))
+        imgurl.appendAscii("03255.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.spreadsheet"))))
+        imgurl.appendAscii("03250.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.spreadsheet-template"))))
+        imgurl.appendAscii("03254.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.presentation"))))
+        imgurl.appendAscii("03249.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.presentation-template"))))
+        imgurl.appendAscii("03244.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.graphics"))))
+        imgurl.appendAscii("03246.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.graphics-template"))))
+        imgurl.appendAscii("03252.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.formular")))) 
+        imgurl.appendAscii("03247.png");
+    // no ODF section
+    else if (mimetype.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/msword"))) == 0)
+        // includes application/msword-xml
+        imgurl.appendAscii("03162.png");
+    else if (mimetype.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.ms-excel"))) == 0)
+        // includes application/vnd.ms-excel-xml
+        imgurl.appendAscii("03126.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.ms-powerpoint"))) == 0) 
+        // includes application/vnd.ms-powerpoint-xml
+        imgurl.appendAscii("03123.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/rtf"))) ||
+             mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("text/plain")))) 
+        imgurl.appendAscii("03162.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("text/html")))) 
+        imgurl.appendAscii("03139.png");
+    else if (mimetype.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/octet-stream")))) 
+        imgurl.appendAscii("03128.png");
+    else if (mimetype.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/"))) == 0) 
+        imgurl.appendAscii("03137.png");
+    else
+        // default
+        imgurl.appendAscii("03128.png");
+        
+    return getGraphic(imgurl.makeStringAndClear());
+}
+
+css::uno::Reference< css::graphic::XGraphic > SAL_CALL ImageProviderService::getIconByName(
+    const ::rtl::OUString & name, ::sal_Int16 /*iconsize*/) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
+{
+    ::rtl::OUStringBuffer imgurl(48);
+    imgurl.appendAscii("private:graphicrepository/");
+    
+    if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("folder_open"))))
+        m_hcMode ? imgurl.appendAscii("res/fileopen_hc.png") : imgurl.appendAscii("res/fileopen.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("folder_up"))))
+        m_hcMode ? imgurl.appendAscii("res/fph010.png") : imgurl.appendAscii("res/fp010.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arrow_up"))))
+        m_hcMode ? imgurl.appendAscii("reportdesign/res/sch30768.png") : imgurl.appendAscii("reportdesign/res/sc30768.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arrow_down"))))
+        m_hcMode ? imgurl.appendAscii("reportdesign/res/sch30769.png") : imgurl.appendAscii("reportdesign/res/sc30769.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("undo"))))
+        m_hcMode ? imgurl.appendAscii("svx/res/cdh020.png") : imgurl.appendAscii("svx/res/cd020.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("redo"))))
+        m_hcMode ? imgurl.appendAscii("svx/res/cdh021.png") : imgurl.appendAscii("svx/res/cd021.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("caution"))))
+        m_hcMode ? imgurl.appendAscii("desktop/res/caution_16_h.png") : imgurl.appendAscii("desktop/res/caution_16.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("oologo"))))
+        m_hcMode ? imgurl.appendAscii("res/mainapp_16_h.png") : imgurl.appendAscii("res/mainapp_16.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lock"))))
+        m_hcMode ? imgurl.appendAscii("desktop/res/lock_16_h.png") : imgurl.appendAscii("desktop/res/lock_16.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("checkmark_green"))))
+        m_hcMode ? imgurl.appendAscii("svx/res/cdh01.png") : imgurl.appendAscii("svx/res/cd01.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("home"))))
+        m_hcMode ? imgurl.appendAscii("fpicker/res/fph011.png") : imgurl.appendAscii("fpicker/res/fp011.png");
+    else if (name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("watch"))))
+        m_hcMode ? imgurl.appendAscii("sd/res/time_16_h.png") : imgurl.appendAscii("sd/res/time_16.png");
+    else
+        // if unknown name, return empty reference
+        return css::uno::Reference< css::graphic::XGraphic >();
+    
+    return getGraphic(imgurl.makeStringAndClear());
+}
+
+css::uno::Reference< css::graphic::XGraphic > SAL_CALL ImageProviderService::getGraphic(const ::rtl::OUString & imgurl)
+{
+
+    css::uno::Sequence < ::com::sun::star::beans::PropertyValue > props(1);
+    props[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("URL"));
+    props[0].Value <<= imgurl;
+    
+    css::uno::Reference< css::graphic::XGraphic > xGraphic = m_xProvider->queryGraphic(props);
+
+    return xGraphic;
+}
+
+
+// com.sun.star.uno.XServiceInfo:
+::rtl::OUString SAL_CALL ImageProviderService::getImplementationName() throw (css::uno::RuntimeException)
+{
+    return getImplementationName_static();
+}
+
+::rtl::OUString SAL_CALL ImageProviderService::getImplementationName_static()
+{
+    return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.comphelper.ImageProvider" ) );
+}
+
+::sal_Bool SAL_CALL ImageProviderService::supportsService(::rtl::OUString const & serviceName)
+    throw (css::uno::RuntimeException)
+{
+    css::uno::Sequence< ::rtl::OUString > serviceNames = getSupportedServiceNames_static();
+    for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
+        if (serviceNames[i] == serviceName)
+            return sal_True;
+    }
+    return sal_False;
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL ImageProviderService::getSupportedServiceNames()
+    throw (css::uno::RuntimeException)
+{
+    return getSupportedServiceNames_static();
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL ImageProviderService::getSupportedServiceNames_static()
+{
+    css::uno::Sequence< ::rtl::OUString > s( 1 );
+    s[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+        "com.sun.star.ui.ImageProvider" ) );
+    return s;
+}
+
+// com.sun.star.beans.XPropertySet:
+css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL ImageProviderService::getPropertySetInfo()
+    throw (css::uno::RuntimeException)
+{
+    return css::uno::Reference< css::beans::XPropertySetInfo >(
+        static_cast< ::cppu::OWeakObject * >(this), css::uno::UNO_QUERY_THROW);
+}
+
+void SAL_CALL ImageProviderService::setPropertyValue(const ::rtl::OUString & propertyName,
+                                                     const ::com::sun::star::uno::Any & value)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+           css::lang::IllegalArgumentException, css::lang::WrappedTargetException)
+{
+    if (!propertyName.equals(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode")))) {
+        // property not known
+        throw  css::beans::UnknownPropertyException() ;
+    }
+
+    if (value.getValueTypeClass() != css::uno::TypeClass_BOOLEAN) {
+        // illegal property value
+        throw  css::lang::IllegalArgumentException(
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("wrong type, expected is type bool")),
+            css::uno::Reference< css::uno::XInterface >(), 2);
+    }
+
+    value >>= m_hcMode;
+}
+
+::com::sun::star::uno::Any SAL_CALL ImageProviderService::getPropertyValue(const ::rtl::OUString & propertyName)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException)
+{
+    if (!propertyName.equals(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode")))) {
+        // property not known
+        throw  css::beans::UnknownPropertyException() ;
+    }
+
+    css::uno::Any ret;
+    ret <<= m_hcMode;
+    return ret;
+}
+
+void SAL_CALL ImageProviderService::addPropertyChangeListener(
+    const ::rtl::OUString &, const css::uno::Reference< css::beans::XPropertyChangeListener > &)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException)
+{
+    // not implemented/supported
+}
+
+void SAL_CALL ImageProviderService::removePropertyChangeListener(
+    const ::rtl::OUString &, const css::uno::Reference< css::beans::XPropertyChangeListener > &)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException)
+{
+    // not implemented/supported
+}
+
+void SAL_CALL ImageProviderService::addVetoableChangeListener(
+    const ::rtl::OUString &, const css::uno::Reference< css::beans::XVetoableChangeListener > &)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException)
+{
+    // not implemented/supported
+}
+
+void SAL_CALL ImageProviderService::removeVetoableChangeListener(
+    const ::rtl::OUString &, const css::uno::Reference< css::beans::XVetoableChangeListener > &)
+    throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::lang::WrappedTargetException)
+{
+    // not implemented/supported
+}
+
+// com.sun.star.beans.XPropertySetInfo:
+css::uno::Sequence< css::beans::Property > SAL_CALL ImageProviderService::getProperties() throw (css::uno::RuntimeException)
+{
+    css::uno::Sequence< css::beans::Property > props( 1 );
+    props[0] = css::beans::Property(
+        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode")), -1, getBooleanCppuType(), 8);
+    return props;
+}
+
+css::beans::Property SAL_CALL ImageProviderService::getPropertyByName(const ::rtl::OUString & propertyName) throw (css::uno::RuntimeException, css::beans::UnknownPropertyException)
+{
+    if (propertyName.equals(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode"))))
+        return css::beans::Property(
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode")), -1, getBooleanCppuType(), 8);
+    else
+        throw css::beans::UnknownPropertyException();
+    
+    return css::beans::Property();
+}
+
+::sal_Bool SAL_CALL ImageProviderService::hasPropertyByName(const ::rtl::OUString & propertyName)
+    throw (css::uno::RuntimeException)
+{
+    return (propertyName.equals(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HighContrastMode"))) ? true : false); 
+}
+
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL ImageProviderService::Create(
+    const css::uno::Reference< css::uno::XComponentContext >& context)
+{
+    return static_cast< ::cppu::OWeakObject * >( new ImageProviderService(context) );
+}
+
+} // closing anonymous implementation namespace
+
+void createRegistryInfo_ImageProvider()
+{
+    static ::comphelper::module::OAutoRegistration< ImageProviderService > aAutoRegistration;
+}

File comphelper/util/comphelp.component

   <implementation name="org.openoffice.comp.comphelper.EnumerableMap">
     <service name="com.sun.star.container.EnumerableMap"/>
   </implementation>
+  <implementation name="org.openoffice.comp.comphelper.ImageProvider">
+    <service name="com.sun.star.ui.ImageProvider"/>
+  </implementation>
 </component>

File offapi/com/sun/star/ui/ImageProvider.idl

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_ui_ImageProvider__
+#define __com_sun_star_ui_ImageProvider__
+
+#import <com/sun/star/ui/XImageProvider.idl>
+
+
+module com { module sun { module star { module ui {
+    /** This services allows simplified access to some image resources.
+        
+        @since OOo 3.5
+     */                
+    service ImageProvider : XImageProvider;
+}; }; }; };
+
+#endif

File offapi/com/sun/star/ui/XImageProvider.idl

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_ui_XImageProvider__
+#define __com_sun_star_ui_XImageProvider__
+
+#import <com/sun/star/graphic/XGraphic.idl>
+#import <com/sun/star/lang/IllegalArgumentException.idl>
+
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com { module sun { module star { module ui {
+    /** specifies simplified access to some image resources.
+
+        @since OOo 3.5
+    */                
+    interface XImageProvider {
+
+        /** retrieves an icon image which is associated by the given mime-type and size.
+
+            @param mimetype
+                specifies a valid mime-type. Either a valid mapping is avaialble or a default icon is returned.
+        
+            @param iconsize
+                specifies the size of the icon image (16, 32). IllegalArgument is thrown if the iconsize is not supported.
+
+            @return
+                a graphic object that represents the requested file type icon.
+        */
+        com::sun::star::graphic::XGraphic getFileTypeIconByMimeType([in] string mimetype, [in] short iconsize)
+            raises (com::sun::star::lang::IllegalArgumentException);
+
+        /** retrieves an icon image which is associated by the given name and size.
+
+            @param name
+                specifies a unique name that is associated with an image resource.
+        
+            @param iconsize
+                specifies the size of the image.  
+
+            @return
+                a graphic object that represents the requested icon. Or a null interface if the name is unknown
+        */
+        com::sun::star::graphic::XGraphic getIconByName([in] string name, [in] short imagesize)
+            raises (com::sun::star::lang::IllegalArgumentException);
+    };
+}; }; }; };
+
+#endif

File offapi/com/sun/star/ui/makefile.mk

     DockingArea.idl                             \
     GlobalAcceleratorConfiguration.idl          \
     ImageType.idl                               \
+    ImageProvider.idl                           \
     ItemDescriptor.idl                          \
     ItemStyle.idl                               \
     ItemType.idl                                \
     UIElementFactoryManager.idl                 \
     UIElementSettings.idl                       \
     UIElementType.idl                           \
-    WindowContentFactory.idl					\
+    WindowContentFactory.idl			\
     WindowStateConfiguration.idl                \
     XAcceleratorConfiguration.idl               \
     XContextMenuInterception.idl                \
     XContextMenuInterceptor.idl                 \
     XDockingAreaAcceptor.idl                    \
     XImageManager.idl                           \
+    XImageProvider.idl                          \
     XModuleUIConfigurationManager.idl           \
     XModuleUIConfigurationManagerSupplier.idl   \
     XUIConfiguration.idl                        \