You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2013/05/07 07:39:17 UTC

svn commit: r1479765 [3/3] - in /openoffice/trunk/main: sc/source/ui/app/ sc/source/ui/view/ sd/source/core/ sd/source/ui/animations/ sd/source/ui/view/ sfx2/sdi/ svx/ svx/inc/ svx/inc/svx/ svx/sdi/ svx/source/gallery2/ svx/source/items/ sw/source/ui/s...

Modified: openoffice/trunk/main/svx/inc/GalleryControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/GalleryControl.hxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/GalleryControl.hxx (original)
+++ openoffice/trunk/main/svx/inc/GalleryControl.hxx Tue May  7 05:39:15 2013
@@ -67,12 +67,6 @@ private:
 
 protected:
 	void ThemeSelectionHasChanged (void);
-							
-	INetURLObject GetURL (void) const;
-	String GetFilterName (void) const;
-	Graphic GetGraphic (void) const;
-	sal_Bool GetVCDrawModel (FmFormModel& rModel) const;
-	sal_Bool IsLinkage (void) const;
 };
 
 } } // end of namespace svx::sidebar

Modified: openoffice/trunk/main/svx/inc/galbrws2.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/galbrws2.hxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/galbrws2.hxx (original)
+++ openoffice/trunk/main/svx/inc/galbrws2.hxx Tue May  7 05:39:15 2013
@@ -34,6 +34,9 @@
 #include <svtools/miscopt.hxx>
 #include "svx/galbrws.hxx"
 
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
 // ----------------------
 // - GalleryBrowserMode -
 // ----------------------
@@ -94,6 +97,7 @@ class GalleryListView;
 class GalleryPreview;
 class Menu;
 class SgaObject;
+struct DispatchInfo;
 
 namespace svx { namespace sidebar { class GalleryControl; } }
 
@@ -119,7 +123,9 @@ private:
 	sal_uIntPtr				mnCurActionPos;
     GalleryBrowserMode  meMode;
     GalleryBrowserMode  meLastMode;
-	sal_Bool				mbCurActionIsLinkage;
+
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
+    com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > m_xTransformer;
 
     void                InitSettings();
 
@@ -127,7 +133,6 @@ private:
 	void				ImplUpdateInfoBar();
     sal_uIntPtr               ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
     void                ImplSelectItemId( sal_uIntPtr nItemId );
-    void                ImplExecute( sal_uInt16 nId );
 
 	// Control
 	virtual void		Resize();
@@ -136,7 +141,6 @@ private:
 	// SfxListener
 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
 
-						DECL_LINK( MenuSelectHdl, Menu* pMenu );
 						DECL_LINK( SelectObjectHdl, void* );
 						DECL_LINK( SelectTbxHdl, ToolBox* );
 						DECL_LINK( MiscHdl, void* );
@@ -167,14 +171,24 @@ public:
 	String				GetFilterName() const;
 	Graphic				GetGraphic() const;
 	sal_Bool				GetVCDrawModel( FmFormModel& rModel ) const;
-	sal_Bool				IsLinkage() const;
 
 	sal_Int8			AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& rEvt );
 	sal_Int8			ExecuteDrop( DropTargetHelper& rTarget, const ExecuteDropEvent& rEvt );
     void                StartDrag( Window* pWindow, const Point* pDragPoint = NULL );
     void                TogglePreview( Window* pWindow, const Point* pPreviewPoint = NULL );
     void                ShowContextMenu( Window* pWindow, const Point* pContextPoint = NULL );
-    sal_Bool                KeyInput( const KeyEvent& rEvt, Window* pWindow );
+    sal_Bool            KeyInput( const KeyEvent& rEvt, Window* pWindow );
+
+    com::sun::star::uno::Reference< com::sun::star::frame::XFrame > GetFrame() const;
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > GetUNOContext() const { return m_xContext; }
+    com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > GetURLTransformer() const { return m_xTransformer; }
+
+    void Execute( sal_uInt16 nId );
+    void Dispatch( sal_uInt16 nId,
+                   const com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > &rxDispatch = com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >(),
+                   const com::sun::star::util::URL &rURL = com::sun::star::util::URL() );
+
+    DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo* );
 };
 
 #endif

Modified: openoffice/trunk/main/svx/inc/svx/galbrws.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/galbrws.hxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/galbrws.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/galbrws.hxx Tue May  7 05:39:15 2013
@@ -95,12 +95,6 @@ public:						
 											Window* pParent, const ResId& rResId );
 							~GalleryBrowser();
 
-	INetURLObject			GetURL() const;
-	String					GetFilterName() const;
-	Graphic					GetGraphic() const;
-	sal_Bool					GetVCDrawModel( FmFormModel& rModel ) const;
-	sal_Bool					IsLinkage() const;
-
     sal_Bool                    KeyInput( const KeyEvent& rKEvt, Window* pWindow );
 };
 

Modified: openoffice/trunk/main/svx/inc/svx/gallery.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/gallery.hxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/gallery.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/gallery.hxx Tue May  7 05:39:15 2013
@@ -34,16 +34,6 @@
 // - Defines -
 // -----------
 
-#define SGA_FORMAT_NONE		0x00000000L
-#define	SGA_FORMAT_STRING	0x00000001L
-#define	SGA_FORMAT_GRAPHIC	0x00000010L
-#define	SGA_FORMAT_SOUND	0x00000100L
-#define SGA_FORMAT_OLE          0x00001000L
-#define	SGA_FORMAT_SVDRAW	0x00010000L
-#define	SGA_FORMAT_ALL		0xFFFFFFFFL
-
-#define SVX_GALLERY() (GalleryExplorer::GetGallery())
-
 // Defines for preinstalled themes
 #define GALLERY_THEME_3D                1
 #define GALLERY_THEME_ANIMATIONS	2
@@ -101,22 +91,8 @@ class OutputDevice;
 
 class SVX_DLLPUBLIC GalleryExplorer
 {
-private:
-
-	SVX_DLLPRIVATE static Gallery*				ImplGetGallery();
-
 public:
 
-	static GalleryExplorer*		GetGallery();
-
-public:
-
-	INetURLObject				GetURL() const;
-	String						GetFilterName() const;
-	Graphic						GetGraphic() const;
-	sal_Bool						GetVCDrawModel( FmFormModel& rModel ) const;
-	sal_Bool						IsLinkage() const;
-
 	static sal_Bool					FillThemeList( List& rThemeList );
 
 								// FillObjList is filling rObjList with Strings of the internal Gallery Object URL
@@ -129,11 +105,6 @@ public:
 	static sal_Bool					InsertURL( const String& rThemeName, const String& rURL );
 	static sal_Bool					InsertURL( sal_uIntPtr nThemeId, const String& rURL );
 
-	static sal_Bool					InsertURL( const String& rThemeName, const String& rURL,
-										   const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ );
-	static sal_Bool					InsertURL( sal_uIntPtr nThemeId, const String& rURL,
-										   const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ );
-
 	static sal_uIntPtr				GetObjCount( const String& rThemeName );
 	static sal_uIntPtr				GetObjCount( sal_uIntPtr nThemeId );
 

Added: openoffice/trunk/main/svx/inc/svx/galleryitem.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/galleryitem.hxx?rev=1479765&view=auto
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/galleryitem.hxx (added)
+++ openoffice/trunk/main/svx/inc/svx/galleryitem.hxx Tue May  7 05:39:15 2013
@@ -0,0 +1,80 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SVX_GALLERYITEMITEM_HXX
+#define _SVX_GALLERYITEMITEM_HXX
+
+#include <svx/svxdllapi.h>
+#include <svl/poolitem.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+// property names map those from css::gallery::GalleryItem
+// with exception of "AsLink" and "FilterName"
+#define SVXGALLERYITEM_TYPE     "GalleryItemType"
+#define SVXGALLERYITEM_LINK     "AsLink"
+#define SVXGALLERYITEM_URL      "URL"
+#define SVXGALLERYITEM_FILTER   "FilterName"
+#define SVXGALLERYITEM_DRAWING  "Drawing"
+#define SVXGALLERYITEM_GRAPHIC  "Graphic"
+#define SVXGALLERYITEM_PARAMS   6
+#define SVXGALLERYITEM_ARGNAME  "GalleryItem"
+
+DBG_NAMEEX_VISIBILITY( SvxGalleryItem, SVX_DLLPUBLIC )
+
+class SVX_DLLPUBLIC SvxGalleryItem : public SfxPoolItem
+{
+    sal_Int8 m_nType;
+    sal_Bool m_bIsLink;
+    rtl::OUString m_aURL;
+    rtl::OUString m_aFilterName;
+    com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xDrawing;
+    com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > m_xGraphic;
+
+public:
+    TYPEINFO();
+
+    SvxGalleryItem();
+    SvxGalleryItem( const SvxGalleryItem& );
+    SvxGalleryItem( const sal_uInt16 nId );
+    ~SvxGalleryItem();
+
+    sal_Int8 GetType() const { return m_nType; }
+    sal_Bool IsLink() const { return m_bIsLink; }
+    const rtl::OUString GetURL() const { return m_aURL; }
+    const rtl::OUString GetFilterName() const { return m_aFilterName; }
+    const com::sun::star::uno::Reference< com::sun::star::lang::XComponent > GetDrawing() const { return m_xDrawing; }
+    const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > GetGraphic() const { return m_xGraphic; }
+
+    // pure virtual methods from SfxPoolItem
+    virtual int          operator==( const SfxPoolItem& ) const;
+    virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+    // bridge to UNO
+    virtual sal_Bool     QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+    virtual sal_Bool     PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+    // not implemented
+    virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
+    virtual SvStream&    Store(SvStream &, sal_uInt16 nItemVersion) const;
+};
+
+#endif

Modified: openoffice/trunk/main/svx/sdi/svx.sdi
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/sdi/svx.sdi?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/sdi/svx.sdi (original)
+++ openoffice/trunk/main/svx/sdi/svx.sdi Tue May  7 05:39:15 2013
@@ -410,6 +410,35 @@ SfxVoidItem AutoFormat SID_AUTOFORMAT
 
 //--------------------------------------------------------------------------
 
+SfxVoidItem BackgroundImage SID_GALLERY_BG_BRUSH
+(SvxBrushItem Background SID_GALLERY_BG_BRUSH, SfxUInt16Item Position SID_GALLERY_BG_POS)
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = TRUE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* status: */
+    SlotType = SfxStringItem
+
+    /* config: */
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_INSERT;
+]
+
+//--------------------------------------------------------------------------
+
 SfxStringItem TableStyle SID_TABLE_STYLE
 ()
 [
@@ -6198,13 +6227,13 @@ SfxVoidItem PreviousAnnotation SID_PREVI
 ]
 
 //--------------------------------------------------------------------------
-SfxUInt32Item InsertGalleryPic SID_GALLERY_FORMATS
-()
+SfxVoidItem InsertGalleryPic SID_GALLERY_FORMATS
+(SvxGalleryItem GalleryItem SID_GALLERY_FORMATS)
 [
 	/* flags: */
 	AutoUpdate = FALSE,
 	Cachable = Cachable,
-	FastCall = TRUE,
+	FastCall = FALSE,
 	HasCoreId = FALSE,
 	HasDialog = FALSE,
 	ReadOnlyDoc = FALSE,

Modified: openoffice/trunk/main/svx/sdi/svxitems.sdi
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/sdi/svxitems.sdi?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/sdi/svxitems.sdi (original)
+++ openoffice/trunk/main/svx/sdi/svxitems.sdi Tue May  7 05:39:15 2013
@@ -692,3 +692,5 @@ struct ZoomSlider
     INT16  SvxMaxZoom           MID_ZOOMSLIDER_MAXZOOM;
 };
 item ZoomSlider SvxZoomSliderItem;
+
+item String SvxGalleryItem; // dummy for sequence

Modified: openoffice/trunk/main/svx/source/gallery2/GalleryControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/GalleryControl.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/GalleryControl.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/GalleryControl.cxx Tue May  7 05:39:15 2013
@@ -240,48 +240,6 @@ void GalleryControl::ThemeSelectionHasCh
 }
 
 
-
-
-INetURLObject GalleryControl::GetURL (void) const
-{
-	return mpBrowser2->GetURL();
-}
-
-
-
-
-String GalleryControl::GetFilterName (void) const
-{
-	return mpBrowser2->GetFilterName();
-}
-
-
-
-
-Graphic GalleryControl::GetGraphic(void) const
-{
-	return mpBrowser2->GetGraphic();
-}
-
-
-
-
-sal_Bool GalleryControl::GetVCDrawModel( FmFormModel& rModel ) const
-{
-	return mpBrowser2->GetVCDrawModel( rModel );
-}
-
-
-
-
-sal_Bool GalleryControl::IsLinkage (void) const
-{
-	return mpBrowser2->IsLinkage();
-}
-
-
-
-
 IMPL_LINK( GalleryControl, SplitHdl, void*, EMPTYARG )
 {
     if(mpSplitter->IsHorizontal())

Modified: openoffice/trunk/main/svx/source/gallery2/galbrws.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galbrws.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galbrws.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galbrws.cxx Tue May  7 05:39:15 2013
@@ -266,41 +266,6 @@ void GalleryBrowser::ThemeSelectionHasCh
 
 // -----------------------------------------------------------------------------
 
-INetURLObject GalleryBrowser::GetURL() const
-{
-	return mpBrowser2->GetURL();
-}
-
-// -----------------------------------------------------------------------------
-
-String GalleryBrowser::GetFilterName() const
-{
-	return mpBrowser2->GetFilterName();
-}
-
-// -----------------------------------------------------------------------------
-
-Graphic GalleryBrowser::GetGraphic() const
-{
-	return mpBrowser2->GetGraphic();
-}
-
-// -----------------------------------------------------------------------------
-
-sal_Bool GalleryBrowser::GetVCDrawModel( FmFormModel& rModel ) const
-{
-	return mpBrowser2->GetVCDrawModel( rModel );
-}
-
-// -----------------------------------------------------------------------------
-
-sal_Bool GalleryBrowser::IsLinkage() const
-{
-	return mpBrowser2->IsLinkage();
-}
-
-// -----------------------------------------------------------------------------
-
 IMPL_LINK( GalleryBrowser, SplitHdl, void*, EMPTYARG )
 {
     if(mpSplitter->IsHorizontal())

Modified: openoffice/trunk/main/svx/source/gallery2/galbrws2.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galbrws2.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galbrws2.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galbrws2.cxx Tue May  7 05:39:15 2013
@@ -55,6 +55,15 @@
 #include <svx/dialogs.hrc>
 #include "GalleryControl.hxx"
 
+#include <svx/svxcommands.h>
+#include <svx/galleryitem.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/style/GraphicLocation.hpp>
+#include <map>
+
 // -----------
 // - Defines -
 // -----------
@@ -64,225 +73,360 @@
 #define TBX_ID_ICON 1
 #define TBX_ID_LIST 2
 
+#define C2U( cstr ) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(cstr)))
+
+namespace css = ::com::sun::star;
+using rtl::OUString;
+
 // -----------
 // - statics -
 // -----------
 
 GalleryBrowserMode GalleryBrowser2::meInitMode = GALLERYBROWSERMODE_ICON;
 
-// --------------------------
-// - GalleryBackgroundPopup -
-// --------------------------
-
-class GalleryBackgroundPopup : public PopupMenu, public SfxControllerItem
+struct DispatchInfo
 {
-	const GalleryTheme* mpTheme;
-	sal_uIntPtr				mnObjectPos;
-
-	virtual void		Select();
-	virtual void		StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
-
-public:
-
-					GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos );
-					~GalleryBackgroundPopup();
+    css::util::URL                                  TargetURL;
+    css::uno::Sequence< css::beans::PropertyValue > Arguments;
+    css::uno::Reference< css::frame::XDispatch >    Dispatch;
 };
 
-// ------------------------------------------------------------------------
-DBG_NAME(GalleryBackgroundPopup)
-
-GalleryBackgroundPopup::GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos ) :
-			SfxControllerItem	( SID_GALLERY_BG_BRUSH, SfxViewFrame::Current()->GetBindings() ),
-			mpTheme				( pTheme ),
-			mnObjectPos			( nObjectPos )
+IMPL_STATIC_LINK_NOINSTANCE( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo*, pDispatchInfo )
 {
-    DBG_CTOR(GalleryBackgroundPopup,NULL);
+    if ( pDispatchInfo && pDispatchInfo->Dispatch.is() )
+    {
+        try
+        {
+            pDispatchInfo->Dispatch->dispatch( pDispatchInfo->TargetURL,
+                                               pDispatchInfo->Arguments );
+        }
+        catch ( const css::uno::Exception& )
+        {
+        }
+    }
 
-	SfxViewFrame::Current()->GetBindings().Update( SID_GALLERY_BG_BRUSH );
-	RemoveDisabledEntries();
+    delete pDispatchInfo;
+    return 0;
 }
 
-// ------------------------------------------------------------------------
-
-GalleryBackgroundPopup::~GalleryBackgroundPopup()
+namespace
 {
 
-    DBG_DTOR(GalleryBackgroundPopup,NULL);
-}
+struct CommandInfo
+{
+    css::util::URL                               URL;
+    css::uno::Reference< css::frame::XDispatch > Dispatch;
 
-// ------------------------------------------------------------------------
+    CommandInfo( const OUString &rURL )
+    {
+        URL.Complete = rURL;
+    }
+};
 
-void GalleryBackgroundPopup::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pItem )
+class GalleryThemePopup : public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
 {
-	if ( ( nSID == SID_GALLERY_BG_BRUSH ) && pItem && ( eState != SFX_ITEM_DISABLED ) )
-	{
-		SfxStringListItem*	pStrLstItem;
-		SfxStringItem*		pStrItem;
+private:
+    const GalleryTheme* mpTheme;
+    sal_uIntPtr         mnObjectPos;
+    sal_Bool            mbPreview;
+    PopupMenu           maPopupMenu;
+    PopupMenu           maBackgroundPopup;
+    GalleryBrowser2*    mpBrowser;
 
-		PopupMenu::Clear();
+    typedef std::map< int, CommandInfo > CommandInfoMap;
+    CommandInfoMap   m_aCommandInfo;
 
-		if( ( pStrLstItem = PTR_CAST( SfxStringListItem, pItem ) ) != NULL )
-		{
-			List* pList = pStrLstItem->GetList();
+    void Execute( const CommandInfo &rCmdInfo,
+                  const css::uno::Sequence< css::beans::PropertyValue > &rArguments );
 
-			if( pList )
-				for ( sal_uIntPtr i = 0, nCount = pList->Count(); i < nCount; i++ )
-					InsertItem( (sal_uInt16) i + 1, *(String*) pList->GetObject( i ) );
-		}
-		else if( ( pStrItem = PTR_CAST( SfxStringItem, pItem ) ) != NULL )
-			InsertItem( 1, pStrItem->GetValue() );
-		else
-		{
-			DBG_ERROR( "SgaBGPopup::StateChanged(...): Wrong item type!" );
-		}
-	}
-}
+    DECL_LINK( MenuSelectHdl, Menu* pMenu );
+    DECL_LINK( BackgroundMenuSelectHdl, Menu* pMenu );
+public:
+    GalleryThemePopup( const GalleryTheme* pTheme,
+                       sal_uIntPtr nObjectPos,
+                       sal_Bool bPreview,
+                       GalleryBrowser2* pBrowser );
+    ~GalleryThemePopup();
 
-// ------------------------------------------------------------------------
+    void ExecutePopup( Window *pParent, const ::Point &aPos );
+
+    virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent &rEvent) throw ( css::uno::RuntimeException );
+    virtual void SAL_CALL disposing( const css::lang::EventObject &rSource) throw ( css::uno::RuntimeException );
+};
 
-void GalleryBackgroundPopup::Select()
+DBG_NAME(GalleryThemePopup)
+
+GalleryThemePopup::GalleryThemePopup(
+    const GalleryTheme* pTheme,
+    sal_uIntPtr nObjectPos,
+    sal_Bool bPreview,
+    GalleryBrowser2* pBrowser )
+    : mpTheme( pTheme )
+    , mnObjectPos( nObjectPos )
+    , mbPreview( bPreview )
+    , maPopupMenu( GAL_RESID( RID_SVXMN_GALLERY2 ) )
+    , maBackgroundPopup()
+    , mpBrowser( pBrowser )
 {
-	Menu::Select();
+    DBG_CTOR(GalleryThemePopup,NULL);
 
-	const INetURLObject	aURL( mpTheme->GetObjectURL( mnObjectPos ) );
-	const SvxBrushItem	aBrushItem( aURL.GetMainURL( INetURLObject::NO_DECODE ), String(), GPOS_TILED, SID_GALLERY_BG_BRUSH );
-	const SfxUInt16Item aPosItem( SID_GALLERY_BG_POS, GetCurItemId() - 1 );
-	const SfxStringItem	aPathItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+    // SID_GALLERY_ENABLE_ADDCOPY
+    m_aCommandInfo.insert(
+        CommandInfoMap::value_type(
+            SID_GALLERY_ENABLE_ADDCOPY,
+            CommandInfo( C2U(CMD_SID_GALLERY_ENABLE_ADDCOPY ))));
+    // SID_GALLERY_BG_BRUSH
+    m_aCommandInfo.insert(
+        CommandInfoMap::value_type(
+            SID_GALLERY_BG_BRUSH,
+            CommandInfo(C2U(CMD_SID_GALLERY_BG_BRUSH ))));
+    // SID_GALLERY_FORMATS
+    m_aCommandInfo.insert(
+        CommandInfoMap::value_type(
+            SID_GALLERY_FORMATS,
+            CommandInfo(C2U(CMD_SID_GALLERY_FORMATS ))));
 
-	SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_GALLERY_BG_BRUSH,
-							  SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
-							  &aBrushItem, &aPosItem, &aPathItem, 0L );
 }
 
-// ---------------------
-// - GalleryThemePopup -
-// ---------------------
-
-class GalleryThemePopup : public PopupMenu, public SfxControllerItem
+GalleryThemePopup::~GalleryThemePopup()
 {
-	GalleryBackgroundPopup	maBackgroundPopup;
-	const GalleryTheme*		mpTheme;
-	sal_uIntPtr					mnObjectPos;
-	sal_Bool					mbPreview;
-
-	virtual void			StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+    DBG_DTOR(GalleryThemePopup,NULL);
+}
 
-public:
+void SAL_CALL GalleryThemePopup::statusChanged(
+    const css::frame::FeatureStateEvent &rEvent )
+throw ( css::uno::RuntimeException )
+{
+    const OUString &rURL = rEvent.FeatureURL.Complete;
+    if ( rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( CMD_SID_GALLERY_ENABLE_ADDCOPY ) ) )
+    {
+        if ( !rEvent.IsEnabled )
+        {
+            PopupMenu *pAddMenu = maPopupMenu.GetPopupMenu( MN_ADDMENU );
+            pAddMenu->EnableItem( MN_ADD, sal_False );
+            pAddMenu->EnableItem( MN_ADD_LINK, sal_False );
+        }
+    }
+    else if ( rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( CMD_SID_GALLERY_BG_BRUSH ) ) )
+    {
+        maBackgroundPopup.Clear();
+        if ( rEvent.IsEnabled )
+        {
+            OUString sItem;
+            css::uno::Sequence< OUString > sItems;
+            if ( ( rEvent.State >>= sItem ) && sItem.getLength() )
+            {
+                maBackgroundPopup.InsertItem( 1, sItem );
+            }
+            else if ( ( rEvent.State >>= sItems ) && sItems.getLength() )
+            {
+                const OUString *pStr = sItems.getConstArray();
+                const OUString *pEnd = pStr + sItems.getLength();
+                for ( sal_uInt16 nId = 1; pStr != pEnd; pStr++, nId++ )
+                {
+                    maBackgroundPopup.InsertItem( nId, *pStr );
+                }
+            }
+        }
+    }
+}
 
-							GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos, sal_Bool bPreview );
-							~GalleryThemePopup();
-};
+void SAL_CALL GalleryThemePopup::disposing(
+    const css::lang::EventObject &/*rSource*/)
+throw ( css::uno::RuntimeException )
+{
+}
 
-// ------------------------------------------------------------------------
-DBG_NAME(GalleryThemePopup)
+void GalleryThemePopup::Execute(
+    const CommandInfo &rCmdInfo,
+    const css::uno::Sequence< css::beans::PropertyValue > &rArguments )
+{
+    if ( rCmdInfo.Dispatch.is() )
+    {
+        DispatchInfo *pInfo = new DispatchInfo;
+        pInfo->TargetURL = rCmdInfo.URL;
+        pInfo->Arguments = rArguments;
+        pInfo->Dispatch = rCmdInfo.Dispatch;
+
+        if ( !Application::PostUserEvent(
+                STATIC_LINK( 0, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
+            delete pInfo;
+    }
+}
 
-GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos, sal_Bool bPreview ) :
-	PopupMenu			( GAL_RESID( RID_SVXMN_GALLERY2 ) ),
-	SfxControllerItem	( SID_GALLERY_ENABLE_ADDCOPY, SfxViewFrame::Current()->GetBindings() ),
-	maBackgroundPopup	( pTheme, nObjectPos ),
-	mpTheme				( pTheme ),
-	mnObjectPos			( nObjectPos ),
-	mbPreview			( bPreview )
+void GalleryThemePopup::ExecutePopup( Window *pWindow, const ::Point &aPos )
 {
-    DBG_CTOR(GalleryThemePopup,NULL);
+    css::uno::Reference< css::frame::XStatusListener > xThis( this );
 
-	const SgaObjKind	eObjKind = mpTheme->GetObjectKind( mnObjectPos );
-	PopupMenu*			pAddMenu = GetPopupMenu( MN_ADDMENU );
-	SfxBindings&		rBindings = SfxViewFrame::Current()->GetBindings();
-    INetURLObject       aURL;
+    const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos );
+    PopupMenu*       pAddMenu = maPopupMenu.GetPopupMenu( MN_ADDMENU );
+    INetURLObject    aURL;
 
     const_cast< GalleryTheme* >( mpTheme )->GetURL( mnObjectPos, aURL );
     const sal_Bool bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID );
 
-	pAddMenu->EnableItem( MN_ADD, bValidURL && SGA_OBJ_SOUND != eObjKind );
-	pAddMenu->EnableItem( MN_ADD_LINK, bValidURL && SGA_OBJ_SVDRAW != eObjKind );
+    pAddMenu->EnableItem( MN_ADD, bValidURL && SGA_OBJ_SOUND != eObjKind );
+    pAddMenu->EnableItem( MN_ADD_LINK, bValidURL && SGA_OBJ_SVDRAW != eObjKind );
 
-    EnableItem( MN_ADDMENU, pAddMenu->IsItemEnabled( MN_ADD ) || pAddMenu->IsItemEnabled( MN_ADD_LINK ) );
-    EnableItem( MN_PREVIEW, bValidURL );
-    
-    CheckItem( MN_PREVIEW, mbPreview );
+    maPopupMenu.EnableItem( MN_ADDMENU, pAddMenu->IsItemEnabled( MN_ADD ) || pAddMenu->IsItemEnabled( MN_ADD_LINK ) );
+    maPopupMenu.EnableItem( MN_PREVIEW, bValidURL );
 
-	if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() )
-	{
-		EnableItem( MN_DELETE, sal_False );
-		EnableItem( MN_TITLE, sal_False );
+    maPopupMenu.CheckItem( MN_PREVIEW, mbPreview );
 
-		if( mpTheme->IsReadOnly() )
-			EnableItem( MN_PASTECLIPBOARD, sal_False );
-		
-		if( !mpTheme->GetObjectCount() )
-			EnableItem( MN_COPYCLIPBOARD, sal_False );
-	}
-	else
-	{
-		EnableItem( MN_DELETE, !bPreview );
-		EnableItem( MN_TITLE, sal_True );
-		EnableItem( MN_COPYCLIPBOARD, sal_True );
-		EnableItem( MN_PASTECLIPBOARD, sal_True );
-	}
+    if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() )
+    {
+        maPopupMenu.EnableItem( MN_DELETE, sal_False );
+        maPopupMenu.EnableItem( MN_TITLE, sal_False );
+
+        if( mpTheme->IsReadOnly() )
+            maPopupMenu.EnableItem( MN_PASTECLIPBOARD, sal_False );
+
+        if( !mpTheme->GetObjectCount() )
+            maPopupMenu.EnableItem( MN_COPYCLIPBOARD, sal_False );
+    }
+    else
+    {
+        maPopupMenu.EnableItem( MN_DELETE, !mbPreview );
+        maPopupMenu.EnableItem( MN_TITLE, sal_True );
+        maPopupMenu.EnableItem( MN_COPYCLIPBOARD, sal_True );
+        maPopupMenu.EnableItem( MN_PASTECLIPBOARD, sal_True );
+    }
 
 #ifdef GALLERY_USE_CLIPBOARD
-	if( IsItemEnabled( MN_PASTECLIPBOARD ) )
+    if( maPopupMenu.IsItemEnabled( MN_PASTECLIPBOARD ) )
     {
-    	TransferableDataHelper	aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
-    	sal_Bool					bEnable = sal_False;
+        TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
+        sal_Bool               bEnable = sal_False;
 
-	    if( aDataHelper.GetFormatCount() )
-	    {
-		    if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) ||
-			    aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ||
-			    aDataHelper.HasFormat( FORMAT_FILE ) ||
-			    aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
-			    aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) ||
-			    aDataHelper.HasFormat( FORMAT_BITMAP ) )
-		    {
-			    bEnable = sal_True;
-		    }
-	    }
+        if( aDataHelper.GetFormatCount() )
+        {
+            if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) ||
+                aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ||
+                aDataHelper.HasFormat( FORMAT_FILE ) ||
+                aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
+                aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) ||
+                aDataHelper.HasFormat( FORMAT_BITMAP ) )
+            {
+                bEnable = sal_True;
+            }
+        }
 
         if( !bEnable )
-    		EnableItem( MN_PASTECLIPBOARD, sal_False );
+            maPopupMenu.EnableItem( MN_PASTECLIPBOARD, sal_False );
     }
 #else
-	EnableItem( MN_COPYCLIPBOARD, sal_False );
-	EnableItem( MN_PASTECLIPBOARD, sal_False );
+    maPopupMenu.EnableItem( MN_COPYCLIPBOARD, sal_False );
+    maPopupMenu.EnableItem( MN_PASTECLIPBOARD, sal_False );
 #endif
 
-	if( !maBackgroundPopup.GetItemCount() || ( eObjKind == SGA_OBJ_SVDRAW ) || ( eObjKind == SGA_OBJ_SOUND ) )
-		pAddMenu->EnableItem( MN_BACKGROUND, sal_False );
-	else
-	{
-		pAddMenu->EnableItem( MN_BACKGROUND, sal_True );
-		pAddMenu->SetPopupMenu( MN_BACKGROUND, &maBackgroundPopup );
-	}
+    // update status
+    css::uno::Reference< css::frame::XDispatchProvider> xDispatchProvider(
+        mpBrowser->GetFrame(), css::uno::UNO_QUERY );
+    css::uno::Reference< css::util::XURLTransformer > xTransformer(
+        mpBrowser->GetURLTransformer() );
+    for ( CommandInfoMap::iterator it = m_aCommandInfo.begin();
+         it != m_aCommandInfo.end(); it++ )
+    {
+        try
+        {
+            CommandInfo &rCmdInfo = it->second;
+            if ( xTransformer.is() )
+                xTransformer->parseStrict( rCmdInfo.URL );
 
-	rBindings.Update( SID_GALLERY_ENABLE_ADDCOPY );
-	RemoveDisabledEntries();
-}
+            if ( xDispatchProvider.is() )
+            {
+                rCmdInfo.Dispatch = xDispatchProvider->queryDispatch(
+                    rCmdInfo.URL,
+                    C2U( "_self" ),
+                    css::frame::FrameSearchFlag::SELF );
+            }
 
-// ------------------------------------------------------------------------
+            if ( rCmdInfo.Dispatch.is() )
+            {
+                rCmdInfo.Dispatch->addStatusListener( this, rCmdInfo.URL );
+                rCmdInfo.Dispatch->removeStatusListener( this, rCmdInfo.URL );
+            }
+        }
+        catch ( ... )
+        {}
+    }
 
-GalleryThemePopup::~GalleryThemePopup()
-{
+    if( !maBackgroundPopup.GetItemCount() || ( eObjKind == SGA_OBJ_SVDRAW ) || ( eObjKind == SGA_OBJ_SOUND ) )
+        pAddMenu->EnableItem( MN_BACKGROUND, sal_False );
+    else
+    {
+        pAddMenu->EnableItem( MN_BACKGROUND, sal_True );
+        pAddMenu->SetPopupMenu( MN_BACKGROUND, &maBackgroundPopup );
+        maBackgroundPopup.SetSelectHdl( LINK( this, GalleryThemePopup, BackgroundMenuSelectHdl ) );
+    }
 
-    DBG_DTOR(GalleryThemePopup,NULL);
+    pAddMenu->RemoveDisabledEntries();
+    if ( !pAddMenu->GetItemCount() )
+        maPopupMenu.EnableItem( MN_ADDMENU, sal_False );
+    maPopupMenu.RemoveDisabledEntries();
+
+    maPopupMenu.SetSelectHdl( LINK( this, GalleryThemePopup, MenuSelectHdl ) );
+    maPopupMenu.Execute( pWindow, aPos );
 }
 
-// ------------------------------------------------------------------------
+IMPL_LINK( GalleryThemePopup, MenuSelectHdl, Menu*, pMenu )
+{
+    if( !pMenu )
+        return 0;
+
+    sal_uInt16 nId( pMenu->GetCurItemId() );
+    switch ( nId )
+    {
+        case( MN_ADD ):
+        case( MN_ADD_LINK ):
+        {
+            const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_FORMATS );
+            if ( it != m_aCommandInfo.end() )
+                mpBrowser->Dispatch( nId,
+                                     it->second.Dispatch,
+                                     it->second.URL );
+        }
+        break;
+
+        default:
+            mpBrowser->Execute( nId );
+    }
+
+    return 0;
+}
 
-void GalleryThemePopup::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pItem )
+IMPL_LINK( GalleryThemePopup, BackgroundMenuSelectHdl, Menu*, pMenu )
 {
-	if( ( nSID == SID_GALLERY_ENABLE_ADDCOPY ) && pItem && ( eState != SFX_ITEM_DISABLED ) )
-	{
-		SfxBoolItem*        pBoolItem = PTR_CAST( SfxBoolItem, pItem );
-    	const SgaObjKind	eObjKind = mpTheme->GetObjectKind( mnObjectPos );
-		
-        DBG_ASSERT( pBoolItem || pBoolItem == 0, "SfxBoolItem erwartet!");
-		
-        GetPopupMenu( MN_ADDMENU )->EnableItem( MN_ADD, pBoolItem->GetValue() && ( eObjKind != SGA_OBJ_SOUND ) );
-	}
+    if( !pMenu )
+        return 0;
+
+    sal_uInt16 nPos( pMenu->GetCurItemId() - 1 );
+    OUString aURL( mpBrowser->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
+    OUString aFilterName( mpBrowser->GetFilterName() );
+
+    css::uno::Sequence< css::beans::PropertyValue > aArgs( 6 );
+    aArgs[0].Name = C2U( "Background.Transparent" );
+    aArgs[0].Value <<= sal_Int32( 0 ); // 0 - 100
+    aArgs[1].Name = C2U( "Background.BackColor" );
+    aArgs[1].Value <<= sal_Int32( - 1 );
+    aArgs[2].Name = C2U( "Background.URL" );
+    aArgs[2].Value <<= aURL;
+    aArgs[3].Name = C2U( "Background.Filtername" ); // FIXME should be FilterName
+    aArgs[3].Value <<= aFilterName;
+    aArgs[4].Name = C2U( "Background.Position" );
+    aArgs[4].Value <<= css::style::GraphicLocation_TILED;
+    aArgs[5].Name = C2U( "Position" );
+    aArgs[5].Value <<= nPos;
+
+    const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_BG_BRUSH );
+    if ( it != m_aCommandInfo.end() )
+        Execute( it->second, aArgs );
+
+    return 0;
 }
 
+} // end anonymous namespace
+
 // ------------------
 // - GalleryToolBox -
 // ------------------
@@ -328,11 +472,17 @@ GalleryBrowser2::GalleryBrowser2( Window
 	maInfoBar			( this, WB_LEFT | WB_VCENTER ),
 	mnCurActionPos		( 0xffffffff ),
     meMode              ( GALLERYBROWSERMODE_NONE ),
-    meLastMode          ( GALLERYBROWSERMODE_NONE ),
-	mbCurActionIsLinkage( sal_False )
+    meLastMode          ( GALLERYBROWSERMODE_NONE )
 {
     DBG_CTOR(GalleryBrowser2,NULL);
-    
+
+    m_xContext.set( ::comphelper::getProcessComponentContext() );
+
+    m_xTransformer.set(
+        m_xContext->getServiceManager()->createInstanceWithContext(
+            C2U( "com.sun.star.util.URLTransformer" ), m_xContext ),
+                    css::uno::UNO_QUERY );
+
     Image       aDummyImage;
     const Link  aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) );
     Font        aInfoFont( maInfoBar.GetControlFont() );
@@ -549,23 +699,25 @@ void GalleryBrowser2::TogglePreview( Win
 
 void GalleryBrowser2::ShowContextMenu( Window*, const Point* pContextPoint )
 {
-    Point		aSelPos;
-	const sal_uIntPtr nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos );
+    Point aSelPos;
+    const sal_uIntPtr nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos );
 
-	if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) )
-	{
+    if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) )
+    {
         ImplSelectItemId( nItemId );
 
-		SfxViewFrame* pCurrentViewFrame = SfxViewFrame::Current();
-		if ( pCurrentViewFrame )
-		{
-			SfxBindings& rBindings = pCurrentViewFrame->GetBindings();
-			rBindings.ENTERREGISTRATIONS();
-			GalleryThemePopup aMenu( mpCurTheme, nItemId - 1, GALLERYBROWSERMODE_PREVIEW == GetMode() );
-			rBindings.LEAVEREGISTRATIONS();
-			aMenu.SetSelectHdl( LINK( this, GalleryBrowser2, MenuSelectHdl ) );
-			aMenu.Execute( this, aSelPos  );
-		}
+        css::uno::Reference< css::frame::XFrame > xFrame( GetFrame() );
+        if ( xFrame.is() )
+        {
+            mnCurActionPos = nItemId - 1;
+            rtl::Reference< GalleryThemePopup > rPopup(
+                new GalleryThemePopup(
+                    mpCurTheme,
+                    mnCurActionPos,
+                    GALLERYBROWSERMODE_PREVIEW == GetMode(),
+                    this ) );
+            rPopup->ExecutePopup( this, aSelPos  );
+        }
 	}
 }
 
@@ -624,13 +776,19 @@ sal_Bool GalleryBrowser2::KeyInput( cons
             case( KEY_INSERT ):
             case( KEY_I ):
             {
+                // Inserting a gallery item in the document must be dispatched
                 if( bAddLink && rKEvt.GetKeyCode().IsShift() && rKEvt.GetKeyCode().IsMod1() )
                     nExecuteId = MN_ADD_LINK;
                 else if( bAdd )
                     nExecuteId = MN_ADD;
+                if( nExecuteId )
+                {
+                    Dispatch( nExecuteId );
+                    return sal_True;
+                }
             }
             break;
-        
+
             case( KEY_DELETE ):
             case( KEY_D ):
             {
@@ -652,7 +810,7 @@ sal_Bool GalleryBrowser2::KeyInput( cons
 
         if( nExecuteId )
         {
-            ImplExecute( nExecuteId );
+            Execute( nExecuteId );
             bRet = sal_True;
         }
     }
@@ -991,50 +1149,144 @@ void GalleryBrowser2::ImplSelectItemId( 
 
 // -----------------------------------------------------------------------------
 
-void GalleryBrowser2::ImplExecute( sal_uInt16 nId )
+css::uno::Reference< css::frame::XFrame >
+GalleryBrowser2::GetFrame() const
 {
-    Point		aSelPos;
-	const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+    css::uno::Reference< css::frame::XFrame > xFrame;
+    SfxViewFrame* pCurrentViewFrame = SfxViewFrame::Current();
+    if ( pCurrentViewFrame )
+    {
+        SfxBindings& rBindings = pCurrentViewFrame->GetBindings();
+        xFrame.set( rBindings.GetActiveFrame() );
+    }
 
-    if( mpCurTheme && nItemId )
+    return xFrame;
+}
+
+void GalleryBrowser2::Dispatch(
+     sal_uInt16 nId,
+    const css::uno::Reference< css::frame::XDispatch > &rxDispatch,
+    const css::util::URL &rURL )
+{
+    Point aSelPos;
+    const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+    if( !mpCurTheme || !nItemId )
+        return;
+
+    mnCurActionPos = nItemId - 1;
+
+    switch( nId )
     {
-        mnCurActionPos = nItemId - 1;
+        case( MN_ADD ):
+        case( MN_ADD_LINK ):
+        {
+            css::uno::Reference< css::frame::XDispatch > xDispatch( rxDispatch );
+            css::util::URL aURL = rURL;
 
-		switch( nId )
-		{
-			case( MN_ADD ):
-			case( MN_ADD_LINK ):
-			{
-				sal_uInt32 nFormat = 0;
+            if ( !xDispatch.is() )
+            {
+                css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(
+                    GetFrame(), css::uno::UNO_QUERY );
+                if ( !xDispatchProvider.is() || !m_xTransformer.is() )
+                    return;
+
+                aURL.Complete = C2U( CMD_SID_GALLERY_FORMATS );
+                m_xTransformer->parseStrict( aURL );
+                xDispatch = xDispatchProvider->queryDispatch(
+                    aURL,
+                    C2U( "_self" ),
+                    css::frame::FrameSearchFlag::SELF );
+            }
 
-				mbCurActionIsLinkage = ( MN_ADD_LINK == nId );
-		
-				switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
-				{
-					case( SGA_OBJ_BMP ):
-					case( SGA_OBJ_ANIM ):
-					case( SGA_OBJ_INET ):
-						nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_STRING;
-					break;
+            if ( !xDispatch.is() )
+                return;
 
-					case ( SGA_OBJ_SOUND ) :
-						nFormat = SGA_FORMAT_SOUND | SGA_FORMAT_STRING;
-					break;
+            sal_Int8 nType = 0;
+            sal_Bool bIsLink( MN_ADD_LINK == nId );
+            OUString aFileURL, aFilterName;
+            css::uno::Reference< css::lang::XComponent > xDrawing;
+            css::uno::Reference< css::graphic::XGraphic > xGraphic;
 
-					case( SGA_OBJ_SVDRAW ):
-						nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_SVDRAW | SGA_FORMAT_STRING;
-					break;
+            aFilterName = GetFilterName();
 
-					default :
-					break;
-				}
+            switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
+            {
+                case( SGA_OBJ_BMP ):
+                case( SGA_OBJ_ANIM ):
+                case( SGA_OBJ_INET ):
+                // TODO drawing objects are inserted as drawings only via drag&drop
+                case( SGA_OBJ_SVDRAW ):
+                    nType = css::gallery::GalleryItemType::GRAPHIC;
+                break;
+
+                case ( SGA_OBJ_SOUND ) :
+                    nType = css::gallery::GalleryItemType::MEDIA;
+                break;
+
+                default:
+                    nType = css::gallery::GalleryItemType::EMPTY;
+                break;
+            }
 
-				const SfxUInt32Item aItem( SID_GALLERY_FORMATS, nFormat );
-				SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( 
-					SID_GALLERY_FORMATS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
-			}
-			break;
+            if ( bIsLink )
+            {
+                aFileURL = mpCurTheme->GetObjectURL( mnCurActionPos ).GetMainURL( INetURLObject::NO_DECODE );
+                OSL_ENSURE( aFileURL.getLength(), "gallery item is link but no URL!" );
+            }
 
+            Graphic aGraphic;
+            sal_Bool bGraphic = mpCurTheme->GetGraphic( mnCurActionPos, aGraphic );
+            if ( bGraphic && !!aGraphic )
+                xGraphic.set( aGraphic.GetXGraphic() );
+            OSL_ENSURE( xGraphic.is(), "gallery item is graphic, but the reference is invalid!" );
+
+            css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS );
+
+            aSeq[0].Name = C2U( SVXGALLERYITEM_TYPE );
+            aSeq[0].Value <<= nType;
+            aSeq[1].Name = C2U( SVXGALLERYITEM_LINK );
+            aSeq[1].Value <<= bIsLink;
+            aSeq[2].Name = C2U( SVXGALLERYITEM_URL );
+            aSeq[2].Value <<= aFileURL;
+            aSeq[3].Name = C2U( SVXGALLERYITEM_FILTER );
+            aSeq[3].Value <<= aFilterName;
+            aSeq[4].Name = C2U( SVXGALLERYITEM_DRAWING );
+            aSeq[4].Value <<= xDrawing;
+            aSeq[5].Name = C2U( SVXGALLERYITEM_GRAPHIC );
+            aSeq[5].Value <<= xGraphic;
+
+            css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
+            aArgs[0].Name = C2U( SVXGALLERYITEM_ARGNAME );
+            aArgs[0].Value <<= aSeq;
+
+            DispatchInfo *pInfo = new DispatchInfo;
+            pInfo->TargetURL = aURL;
+            pInfo->Arguments = aArgs;
+            pInfo->Dispatch = xDispatch;
+
+            if ( !Application::PostUserEvent(
+                    STATIC_LINK( 0, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
+                delete pInfo;
+        }
+        break;
+
+        default:
+        break;
+    }
+}
+
+void GalleryBrowser2::Execute( sal_uInt16 nId )
+{
+    Point		aSelPos;
+	const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+    if( mpCurTheme && nItemId )
+    {
+        mnCurActionPos = nItemId - 1;
+
+		switch( nId )
+		{
 			case( MN_PREVIEW ):
                 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
 			break;
@@ -1235,23 +1487,6 @@ sal_Bool GalleryBrowser2::GetVCDrawModel
 
 // -----------------------------------------------------------------------------
 
-sal_Bool GalleryBrowser2::IsLinkage() const
-{
-	return mbCurActionIsLinkage;
-}
-
-// -----------------------------------------------------------------------------
-
-IMPL_LINK( GalleryBrowser2, MenuSelectHdl, Menu*, pMenu )
-{
-	if( pMenu )
-        ImplExecute( pMenu->GetCurItemId() );
-
-	return 0;
-}
-
-// -----------------------------------------------------------------------------
-
 IMPL_LINK( GalleryBrowser2, SelectObjectHdl, void*, EMPTYARG )
 {
 	ImplUpdateInfoBar();
@@ -1266,7 +1501,7 @@ IMPL_LINK( GalleryBrowser2, SelectTbxHdl
         SetMode( GALLERYBROWSERMODE_ICON );
     else if( pBox->GetCurItemId() == TBX_ID_LIST )
         SetMode( GALLERYBROWSERMODE_LIST );
-        
+
 	return 0L;
 }
 

Modified: openoffice/trunk/main/svx/source/gallery2/galexpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galexpl.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galexpl.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galexpl.cxx Tue May  7 05:39:15 2013
@@ -42,71 +42,9 @@ static SfxListener aLockListener;
 // - GalleryExplorer -
 // -------------------
 
-Gallery* GalleryExplorer::ImplGetGallery()
-{
-	static Gallery* pGallery = NULL;
-
-    ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-
-	if( !pGallery )
-		pGallery = Gallery::GetGalleryInstance();
-
-	return pGallery;
-}
-
-// ------------------------------------------------------------------------
-
-GalleryExplorer* GalleryExplorer::GetGallery()
-{
-	static GalleryExplorer* pThis = NULL;
-
-    ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-
-	// only create a dummy object which can be accessed
-	if( !pThis )
-		pThis = new GalleryExplorer;
-
-	return pThis;
-}
-
-// ------------------------------------------------------------------------
-
-INetURLObject GalleryExplorer::GetURL() const
-{
-	return GALLERYBROWSER()->GetURL();
-}
-
-String GalleryExplorer::GetFilterName() const
-{
-	return GALLERYBROWSER()->GetFilterName();
-}
-
-// ------------------------------------------------------------------------
-
-Graphic GalleryExplorer::GetGraphic() const
-{
-	return GALLERYBROWSER()->GetGraphic();
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool GalleryExplorer::GetVCDrawModel( FmFormModel& rModel ) const
-{
-	return GALLERYBROWSER()->GetVCDrawModel( rModel );
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool GalleryExplorer::IsLinkage() const
-{
-	return GALLERYBROWSER()->IsLinkage();
-}
-
-// ------------------------------------------------------------------------
-
 sal_Bool GalleryExplorer::FillThemeList( List& rThemeList )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 
 	if( pGal )
 	{
@@ -126,7 +64,7 @@ sal_Bool GalleryExplorer::FillThemeList(
 
 sal_Bool GalleryExplorer::FillObjList( const String& rThemeName, List& rObjList )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 
 	if( pGal )
 	{
@@ -149,7 +87,7 @@ sal_Bool GalleryExplorer::FillObjList( c
 
 sal_Bool GalleryExplorer::FillObjList( sal_uIntPtr nThemeId, List& rObjList )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? FillObjList( pGal->GetThemeName( nThemeId ), rObjList ) : sal_False );
 }
 
@@ -157,7 +95,7 @@ sal_Bool GalleryExplorer::FillObjList( s
 
 sal_Bool GalleryExplorer::FillObjListTitle( const sal_uInt32 nThemeId, std::vector< rtl::OUString >& rList )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	if( pGal )
 	{
         SfxListener     aListener;
@@ -185,21 +123,7 @@ sal_Bool GalleryExplorer::FillObjListTit
 
 sal_Bool GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL )
 {
-	return InsertURL( rThemeName, rURL, SGA_FORMAT_ALL );
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL )
-{
-	return InsertURL( nThemeId, rURL, SGA_FORMAT_ALL );
-}
-
-// ------------------------------------------------------------------------
-
-sal_Bool GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL, const sal_uIntPtr )
-{
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -221,17 +145,17 @@ sal_Bool GalleryExplorer::InsertURL( con
 
 // ------------------------------------------------------------------------
 
-sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL, const sal_uIntPtr nSgaFormat )
+sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL )
 {
-	Gallery* pGal = ImplGetGallery();
-	return( pGal ? InsertURL( pGal->GetThemeName( nThemeId ), rURL, nSgaFormat ) : sal_False );
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
+	return( pGal ? InsertURL( pGal->GetThemeName( nThemeId ), rURL ) : sal_False );
 }
 
 // ------------------------------------------------------------------------
 
 sal_uIntPtr GalleryExplorer::GetObjCount( const String& rThemeName )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_uIntPtr		nRet = 0;
 
 	if( pGal )
@@ -253,7 +177,7 @@ sal_uIntPtr GalleryExplorer::GetObjCount
 
 sal_uIntPtr GalleryExplorer::GetObjCount( sal_uIntPtr nThemeId )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? GetObjCount( pGal->GetThemeName( nThemeId ) ) : sal_False );
 }
 
@@ -263,7 +187,7 @@ sal_Bool GalleryExplorer::GetGraphicObj(
 									 Graphic* pGraphic, BitmapEx* pThumb,
 									 sal_Bool bProgress )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -292,7 +216,7 @@ sal_Bool GalleryExplorer::GetGraphicObj(
 									 Graphic* pGraphic, BitmapEx* pThumb,
 									 sal_Bool bProgress )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? GetGraphicObj( pGal->GetThemeName( nThemeId ), nPos, pGraphic, pThumb, bProgress ) : sal_False );
 }
 
@@ -300,7 +224,7 @@ sal_Bool GalleryExplorer::GetGraphicObj(
 
 sal_Bool GalleryExplorer::InsertGraphicObj( const String& rThemeName, const Graphic& rGraphic )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -322,7 +246,7 @@ sal_Bool GalleryExplorer::InsertGraphicO
 
 sal_Bool GalleryExplorer::InsertGraphicObj( sal_uIntPtr nThemeId, const Graphic& rGraphic )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? InsertGraphicObj( pGal->GetThemeName( nThemeId ), rGraphic ) : sal_False );
 }
 
@@ -330,7 +254,7 @@ sal_Bool GalleryExplorer::InsertGraphicO
 
 sal_uIntPtr GalleryExplorer::GetSdrObjCount( const String& rThemeName )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_uIntPtr		nRet = 0;
 
 	if( pGal )
@@ -355,7 +279,7 @@ sal_uIntPtr GalleryExplorer::GetSdrObjCo
 
 sal_uIntPtr GalleryExplorer::GetSdrObjCount( sal_uIntPtr nThemeId  )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? GetSdrObjCount( pGal->GetThemeName( nThemeId ) ) : sal_False );
 }
 
@@ -364,7 +288,7 @@ sal_uIntPtr GalleryExplorer::GetSdrObjCo
 sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos,
 								 SdrModel* pModel, BitmapEx* pThumb )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -401,7 +325,7 @@ sal_Bool GalleryExplorer::GetSdrObj( con
 sal_Bool GalleryExplorer::GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos,
 								 SdrModel* pModel, BitmapEx* pThumb )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb ) : sal_False );
 }
 
@@ -409,7 +333,7 @@ sal_Bool GalleryExplorer::GetSdrObj( sal
 
 sal_Bool GalleryExplorer::InsertSdrObj( const String& rThemeName, FmFormModel& rModel )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -431,7 +355,7 @@ sal_Bool GalleryExplorer::InsertSdrObj( 
 
 sal_Bool GalleryExplorer::InsertSdrObj( sal_uIntPtr nThemeId, FmFormModel& rModel )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? InsertSdrObj( pGal->GetThemeName( nThemeId ), rModel ) : sal_False );
 }
 
@@ -439,7 +363,7 @@ sal_Bool GalleryExplorer::InsertSdrObj( 
 
 sal_Bool GalleryExplorer::BeginLocking( const String& rThemeName )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -460,7 +384,7 @@ sal_Bool GalleryExplorer::BeginLocking( 
 
 sal_Bool GalleryExplorer::BeginLocking( sal_uIntPtr nThemeId )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? BeginLocking( pGal->GetThemeName( nThemeId ) ) : sal_False );
 }
 
@@ -468,7 +392,7 @@ sal_Bool GalleryExplorer::BeginLocking( 
 
 sal_Bool GalleryExplorer::EndLocking( const String& rThemeName )
 {
-	Gallery*	pGal = ImplGetGallery();
+	Gallery*	pGal = ::Gallery::GetGalleryInstance();
 	sal_Bool		bRet = sal_False;
 
 	if( pGal )
@@ -499,7 +423,7 @@ sal_Bool GalleryExplorer::EndLocking( co
 
 sal_Bool GalleryExplorer::EndLocking( sal_uIntPtr nThemeId )
 {
-	Gallery* pGal = ImplGetGallery();
+	Gallery* pGal = ::Gallery::GetGalleryInstance();
 	return( pGal ? EndLocking( pGal->GetThemeName( nThemeId ) ) : sal_False );
 }
 

Added: openoffice/trunk/main/svx/source/items/galleryitem.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/items/galleryitem.cxx?rev=1479765&view=auto
==============================================================================
--- openoffice/trunk/main/svx/source/items/galleryitem.cxx (added)
+++ openoffice/trunk/main/svx/source/items/galleryitem.cxx Tue May  7 05:39:15 2013
@@ -0,0 +1,185 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+
+#include <svx/galleryitem.hxx>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace css = ::com::sun::star;
+
+DBG_NAMEEX( SvxGalleryItem )
+DBG_NAME( SvxGalleryItem )
+
+TYPEINIT1_AUTOFACTORY( SvxGalleryItem, SfxPoolItem );
+
+SvxGalleryItem::SvxGalleryItem()
+    : m_nType( css::gallery::GalleryItemType::EMPTY )
+    , m_bIsLink( sal_False )
+{
+    DBG_CTOR(SvxGalleryItem, 0);
+}
+
+SvxGalleryItem::SvxGalleryItem( const SvxGalleryItem &rItem )
+    : SfxPoolItem( rItem )
+    , m_nType( rItem.m_nType )
+    , m_bIsLink( rItem.m_bIsLink )
+    , m_aURL( rItem.m_aURL )
+    , m_xDrawing( rItem.m_xDrawing )
+    , m_xGraphic( rItem.m_xGraphic )
+{
+    DBG_CTOR(SvxGalleryItem, 0);
+}
+
+SvxGalleryItem::SvxGalleryItem(
+    const ::sal_uInt16 nId )
+    : SfxPoolItem( nId )
+    , m_nType( css::gallery::GalleryItemType::EMPTY )
+    , m_bIsLink( sal_False )
+{
+    DBG_CTOR(SvxGalleryItem, 0);
+}
+
+SvxGalleryItem::~SvxGalleryItem()
+{
+    DBG_DTOR(SvxGalleryItem, 0);
+}
+
+sal_Bool SvxGalleryItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
+{
+    css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS );
+
+    aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_TYPE ));
+    aSeq[0].Value <<= m_nType;
+    aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_LINK ));
+    aSeq[1].Value <<= m_bIsLink;
+    aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_URL ));
+    aSeq[2].Value <<= m_aURL;
+    aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_FILTER ));
+    aSeq[3].Value <<= m_aURL;
+    aSeq[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_DRAWING ));
+    aSeq[4].Value <<= m_xDrawing;
+    aSeq[5].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_GRAPHIC ));
+    aSeq[5].Value <<= m_xGraphic;
+
+    rVal <<= aSeq;
+
+    return sal_True;
+}
+
+sal_Bool SvxGalleryItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /* nMemberId */)
+{
+    css::uno::Sequence< css::beans::PropertyValue > aSeq;
+
+    if ( !( rVal >>= aSeq ) || ( aSeq.getLength() < SVXGALLERYITEM_PARAMS ) )
+        return sal_False;
+
+    int nConverted(0);
+    sal_Bool bAllConverted( sal_True );
+    sal_Bool bIsSetType( sal_False );
+
+    sal_Int8 nType(0);
+    sal_Bool bIsLink( sal_False );
+    rtl::OUString aURL, aFilterName;
+    css::uno::Reference< css::lang::XComponent > xDrawing;
+    css::uno::Reference< css::graphic::XGraphic > xGraphic;
+
+    const css::beans::PropertyValue *pProp = aSeq.getConstArray();
+    const css::beans::PropertyValue *pEnd = pProp + aSeq.getLength();
+    for ( ; pProp != pEnd; pProp++ )
+    {
+        if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_TYPE ) ) )
+        {
+            bAllConverted &= bIsSetType = ( pProp->Value >>= nType );
+            ++nConverted;
+        }
+        else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_LINK ) ) )
+        {
+            bAllConverted &= ( pProp->Value >>= bIsLink );
+            ++nConverted;
+        }
+        else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_URL ) ) )
+        {
+            bAllConverted &= ( pProp->Value >>= aURL );
+            ++nConverted;
+        }
+        else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_FILTER ) ) )
+        {
+            bAllConverted &= ( pProp->Value >>= aFilterName );
+            ++nConverted;
+        }
+        else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_DRAWING ) ) )
+        {
+            bAllConverted &= ( pProp->Value >>= xDrawing );
+            ++nConverted;
+        }
+        else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_GRAPHIC ) ) )
+        {
+            bAllConverted &= ( pProp->Value >>= xGraphic );
+            ++nConverted;
+        }
+    }
+
+    if ( !bAllConverted || nConverted != SVXGALLERYITEM_PARAMS )
+        return sal_False;
+
+    m_nType = nType;
+    m_bIsLink = bIsLink;
+    m_aURL = aURL;
+    m_aFilterName = aFilterName;
+    m_xDrawing = xDrawing;
+    m_xGraphic = xGraphic;
+
+    return sal_True;
+}
+
+int SvxGalleryItem::operator==( const SfxPoolItem& rAttr ) const
+{
+    DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+    const SvxGalleryItem& rItem = static_cast<const SvxGalleryItem&>(rAttr);
+
+    int bRet = m_nType  == rItem.m_nType &&
+            m_bIsLink   == rItem.m_bIsLink &&
+            m_aURL      == rItem.m_aURL &&
+            m_xDrawing  == rItem.m_xDrawing &&
+            m_xGraphic  == rItem.m_xGraphic;
+
+    return bRet;
+}
+
+SfxPoolItem* SvxGalleryItem::Clone( SfxItemPool * ) const
+{
+    return new SvxGalleryItem( *this );
+}
+
+SvStream& SvxGalleryItem::Store( SvStream& rStream, sal_uInt16 /*nItemVersion*/ ) const
+{
+    return rStream;
+}
+
+SfxPoolItem* SvxGalleryItem::Create(SvStream& , sal_uInt16) const
+{
+    return 0;
+}

Modified: openoffice/trunk/main/sw/source/ui/shells/basesh.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/shells/basesh.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/shells/basesh.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/shells/basesh.cxx Tue May  7 05:39:15 2013
@@ -112,6 +112,8 @@
 #include <comcore.hrc>
 
 #include <unomid.h>
+#include <svx/galleryitem.hxx>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
 
 FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END;
 
@@ -730,55 +732,57 @@ void SwBaseShell::Execute(SfxRequest &rR
 		break;
 		case SID_GALLERY_FORMATS:
 		{
-			const int nSelType = rSh.GetSelectionType();
-            if(SFX_ITEM_SET == pArgs->GetItemState( nSlot, sal_True, &pItem))
-            {
-                GalleryExplorer* pGal = 0;
-                if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) &&
-                    0!= (pGal = SVX_GALLERY())&&
-                    0 != (SGA_FORMAT_GRAPHIC & ((SfxUInt32Item*)pItem)->GetValue()))
-                {
-                    SwWait aWait( *rView.GetDocShell(), sal_True );
+            SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
+            if ( !pGalleryItem )
+                break;
 
-                    String aGrfName, aFltName;
-                    const Graphic aGrf( pGal->GetGraphic() );
+            const int nSelType = rSh.GetSelectionType();
+            sal_Int8 nGalleryItemType( pGalleryItem->GetType() );
 
-                    if( pGal->IsLinkage() )
-                    {
-                        // Verknuepft
-                        aGrfName = pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE);
-                        aFltName = pGal->GetFilterName();
-                    }
+            if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) &&
+                nGalleryItemType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
+            {
+                SwWait aWait( *rView.GetDocShell(), sal_True );
 
-                    if ( nSelType & nsSelectionType::SEL_GRF )
-                        rSh.ReRead( aGrfName, aFltName, &aGrf );
-                    else
-                        rSh.Insert( aGrfName, aFltName, aGrf );
+                String aGrfName, aFltName;
+                const Graphic aGrf( pGalleryItem->GetGraphic() );
 
-                    GetView().GetEditWin().GrabFocus();
-                }
-                else if(!rSh.IsSelFrmMode() && SGA_FORMAT_SOUND & ((SfxUInt32Item*)pItem)->GetValue())
+                if( pGalleryItem->IsLink() )
                 {
-        		    const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
-       			    GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
+                    // Verknuepft
+                    aGrfName = pGalleryItem->GetURL();
+                    aFltName = pGalleryItem->GetFilterName();
+                }
+
+                if ( nSelType & nsSelectionType::SEL_GRF )
+                    rSh.ReRead( aGrfName, aFltName, &aGrf );
+                else
+                    rSh.Insert( aGrfName, aFltName, aGrf );
+
+                GetView().GetEditWin().GrabFocus();
+            }
+            else if(!rSh.IsSelFrmMode() &&
+                nGalleryItemType == com::sun::star::gallery::GalleryItemType::MEDIA  )
+            {
+                const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
+                GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
 /*
-                    String sURL( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
-                    String sLabel( pGal->GetURL().getBase() );
-                    String sTarget; // empty string!
-
-                    bool bIsHTMLMode =
-                        0 == ( HTMLMODE_ON &
-                               ::GetHtmlMode( GetView().GetDocShell() ) );
-
-                    // in Writer, we insert a button which plays the
-                    // sound. In Writer/Web, we just insert a (text) link.
-                    if( bIsHTMLMode )
-                        InsertURLButton( sURL, sTarget, sLabel );
-                    else
-                        rSh.InsertURL( SwFmtINetFmt( sURL, sTarget ), sLabel );
+                String sURL( pGalleryItem->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
+                String sLabel( pGalleryItem->GetURL().getBase() );
+                String sTarget; // empty string!
+
+                bool bIsHTMLMode =
+                    0 == ( HTMLMODE_ON &
+                            ::GetHtmlMode( GetView().GetDocShell() ) );
+
+                // in Writer, we insert a button which plays the
+                // sound. In Writer/Web, we just insert a (text) link.
+                if( bIsHTMLMode )
+                    InsertURLButton( sURL, sTarget, sLabel );
+                else
+                    rSh.InsertURL( SwFmtINetFmt( sURL, sTarget ), sLabel );
 */
-                }
-			}
+            }
 		}
 		break;
 		case FN_PAGE_STYLE_SET_COLS:
@@ -2859,14 +2863,22 @@ void SwBaseShell::ExecuteGallery(SfxRequ
 	{
 		case SID_GALLERY_BG_BRUSH:
 		{
+            if ( !pArgs )
+                break;
+
 			int nSel = rSh.GetSelectionType();
 			if ( nSel & nsSelectionType::SEL_DRW_TXT )
 				break;
 
-			sal_uInt8 nPos = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(SID_GALLERY_BG_POS)).GetValue();
+            SFX_REQUEST_ARG( rReq, pPos, SfxUInt16Item, SID_GALLERY_BG_POS, sal_False );
+            SFX_REQUEST_ARG( rReq, pBrush, SvxBrushItem, SID_GALLERY_BG_BRUSH, sal_False );
+            if ( !pPos || !pBrush )
+                break;
+
+			sal_uInt8 nPos = pPos->GetValue();
 			++nPos;
 
-			SvxBrushItem aBrush( (SvxBrushItem&)pArgs->Get(SID_GALLERY_BG_BRUSH));
+			SvxBrushItem aBrush( *pBrush );
 			aBrush.SetWhich( RES_BACKGROUND );
 			if ( nPos == nParagraphPos )
 				rSh.SetAttr( aBrush );

Modified: openoffice/trunk/main/sw/source/ui/shells/slotadd.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/shells/slotadd.cxx?rev=1479765&r1=1479764&r2=1479765&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/shells/slotadd.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/shells/slotadd.cxx Tue May  7 05:39:15 2013
@@ -141,6 +141,7 @@
 #include <svx/xlncapit.hxx>
 #include <svx/xlinjoit.hxx>
 #include <svx/AffineMatrixItem.hxx>
+#include <svx/galleryitem.hxx>
 
 #define SFX_TYPEMAP
 #include <sfx2/msg.hxx>