CWS-TOOLING: integrate CWS renaissance2

This commit is contained in:
Ivo Hinkelmann 2010-06-03 11:55:10 +02:00
commit a665d66d5f
19 changed files with 4410 additions and 58 deletions

View file

@ -0,0 +1,141 @@
/*************************************************************************
*
* 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 __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_
#define __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_
#include "svtools/svtdllapi.h"
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/XUriReference.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
//_________________________________________________________________________________________________________________
// includes of other projects
//_________________________________________________________________________________________________________________
#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/compbase7.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <cppuhelper/weak.hxx>
#include <rtl/ustring.hxx>
namespace svt
{
struct PopupMenuControllerBaseDispatchInfo;
typedef ::cppu::WeakComponentImplHelper7<
com::sun::star::lang::XServiceInfo ,
com::sun::star::frame::XPopupMenuController ,
com::sun::star::lang::XInitialization ,
com::sun::star::frame::XStatusListener ,
com::sun::star::awt::XMenuListener ,
com::sun::star::frame::XDispatchProvider ,
com::sun::star::frame::XDispatch > PopupMenuControllerBaseType;
class SVT_DLLPUBLIC PopupMenuControllerBase : protected ::comphelper::OBaseMutex, // Struct for right initalization of mutex member! Must be first of baseclasses.
public PopupMenuControllerBaseType
{
public:
PopupMenuControllerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
virtual ~PopupMenuControllerBase();
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0;
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0;
// XPopupMenuController
virtual void SAL_CALL setPopupMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& PopupMenu ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException);
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0;
// XMenuListener
virtual void SAL_CALL highlight( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL select( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL activate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deactivate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
// XDispatchProvider
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& sTarget, sal_Int32 nFlags ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& lDescriptor ) throw( ::com::sun::star::uno::RuntimeException );
// XDispatch
virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& seqProperties ) throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException );
// XEventListener
virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
protected:
void throwIfDisposed() throw ( ::com::sun::star::uno::RuntimeException );
/** helper method to cause statusChanged is called once for the given command url */
void SAL_CALL updateCommand( const rtl::OUString& rCommandURL );
/** this function is called upon disposing the component
*/
virtual void SAL_CALL disposing();
virtual void resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
virtual void impl_setPopupMenu();
virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL);
::rtl::OUString determineBaseURL( const ::rtl::OUString& aURL );
DECL_STATIC_LINK( PopupMenuControllerBase, ExecuteHdl_Impl, PopupMenuControllerBaseDispatchInfo* );
bool m_bInitialized;
rtl::OUString m_aCommandURL;
rtl::OUString m_aBaseURL;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xDispatch;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > m_xPopupMenu;
};
}
#endif // __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_

View file

@ -0,0 +1,85 @@
/*************************************************************************
*
* 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 __SVTOOLS_POPUPWINDOWCONTROLLER_HXX_
#define __SVTOOLS_POPUPWINDOWCONTROLLER_HXX_
#include "svtools/svtdllapi.h"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include "svtools/toolboxcontroller.hxx"
#include "boost/scoped_ptr.hpp"
class Window;
namespace svt
{
class PopupWindowControllerImpl;
class SVT_DLLPUBLIC PopupWindowController : public svt::ToolboxController, public ::com::sun::star::lang::XServiceInfo
{
public:
PopupWindowController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
const rtl::OUString& aCommandURL );
~PopupWindowController();
virtual ::Window* createPopupWindow( ::Window* pParent ) = 0;
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw ();
virtual void SAL_CALL release() throw ();
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) = 0;
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) = 0;
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
// XToolbarController
virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
private:
boost::scoped_ptr< PopupWindowControllerImpl > mpImpl;
};
} // namespace svt
#endif // __SVTOOLS_POPUPWINDOWCONTROLLER_HXX_

View file

@ -0,0 +1,155 @@
/*************************************************************************
*
* 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 _SVTOOLS_TOOLBARMENU_HXX_
#define _SVTOOLS_TOOLBARMENU_HXX_
#include "svtools/svtdllapi.h"
#include <com/sun/star/frame/FeatureStateEvent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <vector>
#include <rtl/ref.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/menu.hxx>
#include <vcl/dockwin.hxx>
class ValueSet;
namespace svtools {
class ToolbarMenuEntry;
struct ToolbarMenu_Impl;
class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow
{
friend class ToolbarMenuStatusListener;
friend struct ToolbarMenu_Impl;
public:
ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
Window* pParentWindow,
WinBits nBits );
ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
Window* pParentWindow,
const ResId& rResId );
~ToolbarMenu();
virtual void MouseMove( const MouseEvent& rMEvt );
virtual void MouseButtonDown( const MouseEvent& rMEvt );
virtual void MouseButtonUp( const MouseEvent& rMEvt );
virtual void KeyInput( const KeyEvent& rKEvent );
virtual void Command( const CommandEvent& rCEvt );
virtual void Paint( const Rectangle& rRect );
virtual void RequestHelp( const HelpEvent& rHEvt );
virtual void GetFocus();
virtual void LoseFocus();
void appendEntry( int nEntryId, const String& rStr, MenuItemBits nItemBits = 0 );
void appendEntry( int nEntryId, const Image& rImage, MenuItemBits nItemBits = 0 );
void appendEntry( int nEntryId, const String& rStr, const Image& rImage, MenuItemBits nItemBits = 0 );
void appendEntry( int nEntryId, Control* pControl, MenuItemBits nItemBits = 0 );
void appendSeparator();
/** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */
ValueSet* createEmptyValueSetControl();
void checkEntry( int nEntryId, bool bCheck = true );
bool isEntryChecked( int nEntryId ) const;
void enableEntry( int nEntryId, bool bEnable = true );
bool isEntryEnabled( int nEntryId ) const;
void setEntryText( int nEntryId, const String& rStr );
const String& getEntryText( int nEntryId ) const;
void setEntryImage( int nEntryId, const Image& rImage );
const Image& getEntryImage( int nEntryId ) const;
const Size& getMenuSize() const;
void SetSelectHdl( const Link& rLink );
const Link& GetSelectHdl() const;
int getSelectedEntryId() const;
int getHighlightedEntryId() const;
void highlightFirstEntry();
protected:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
// todo: move to new base class that will replace SfxPopupWindow
void AddStatusListener( const rtl::OUString& rCommandURL );
void RemoveStatusListener( const rtl::OUString& rCommandURL );
void UpdateStatus( const rtl::OUString& rCommandURL );
bool IsInPopupMode();
void EndPopupMode();
// XStatusListener (subclasses must override this one to get the status updates
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
void StateChanged( StateChangedType nType );
void DataChanged( const DataChangedEvent& rDCEvt );
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame() const;
private:
DECL_LINK( HighlightHdl, Control * );
void initStatusListener();
void implInit( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
void initWindow();
Size implCalcSize();
void appendEntry( ToolbarMenuEntry* pEntry );
void implPaint( ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false );
void implHighlightEntry( int nHighlightEntry, bool bHighlight );
void implHighlightEntry( const MouseEvent& rMEvt, bool bMBDown );
void implChangeHighlightEntry( int nEntry );
void implSelectEntry( int nSelectedEntry );
ToolbarMenuEntry* implCursorUpDown( bool bUp, bool bHomeEnd );
ToolbarMenuEntry* implGetEntry( int nEntry ) const;
ToolbarMenuEntry* implSearchEntry( int nEntryId ) const;
ToolbarMenu_Impl* mpImpl;
};
} // namespace svtools
#endif

View file

@ -48,6 +48,8 @@
#define INCLUDED_HASH_MAP
#endif
class ToolBox;
namespace svt
{
struct ToolboxController_Impl;
@ -103,7 +105,16 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
const rtl::OUString& getCommandURL() const { return m_aCommandURL; }
const rtl::OUString& getModuleName() const;
void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
void enable( bool bEnable );
protected:
bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
struct Listener
{
Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :

View file

@ -426,6 +426,9 @@ public:
void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
void SetHighlightHdl( const Link& rLink );
const Link& GetHighlightHdl() const;
private:
/** Determine whether RTL (right to left writing) is active. For this
method to return <true/> two conditions have to be fullfilled:

4
svtools/source/control/makefile.mk Normal file → Executable file
View file

@ -51,7 +51,9 @@ EXCEPTIONSFILES=\
$(SLO)$/scriptedtext.obj\
$(SLO)$/fmtfield.obj \
$(SLO)$/inettbc.obj \
$(SLO)$/valueacc.obj
$(SLO)$/valueacc.obj \
$(SLO)$/toolbarmenu.obj \
$(SLO)$/toolbarmenuacc.obj
SLOFILES=\
$(EXCEPTIONSFILES) \

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,314 @@
/*************************************************************************
*
* 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.
*
************************************************************************/
#include <vos/mutex.hxx>
#include <vcl/image.hxx>
#include <vcl/menu.hxx>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/compbase5.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <rtl/ref.hxx>
#include <vector>
#include "framestatuslistener.hxx"
#include "svtools/valueset.hxx"
namespace svtools {
struct ToolbarMenu_Impl;
class ToolbarMenu;
class ToolbarMenuEntry;
typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener > > EventListenerVector;
typedef std::vector< ToolbarMenuEntry * > ToolbarMenuEntryVector;
const int EXTRAITEMHEIGHT = 0; // 4;
const int SEPARATOR_HEIGHT = 4;
const int TITLE_ID = -1;
const int BORDER_X = 0;
const int BORDER_Y = 0;
// --------------------
// - ToolbarMenuEntry -
// --------------------
class ToolbarMenuEntry
{
public:
ToolbarMenu& mrMenu;
int mnEntryId;
MenuItemBits mnBits;
Size maSize;
bool mbHasText;
bool mbHasImage;
bool mbChecked;
bool mbEnabled;
String maText;
Image maImage;
Control* mpControl;
Rectangle maRect;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > mxAccContext;
public:
ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const String& rText, MenuItemBits nBits );
ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const Image& rImage, MenuItemBits nBits );
ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, const Image& rImage, const String& rText, MenuItemBits nBits );
ToolbarMenuEntry( ToolbarMenu& rMenu, int nEntryId, Control* pControl, MenuItemBits nBits );
~ToolbarMenuEntry();
void init( int nEntryId, MenuItemBits nBits );
const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& GetAccessible( bool bCreate = false );
sal_Int32 getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessibleChild( sal_Int32 index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
void selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
bool HasCheck() const
{
return mbChecked || ( mnBits & ( MIB_RADIOCHECK | MIB_CHECKABLE | MIB_AUTOCHECK ) );
}
};
// ---------------
// - ToolbarMenuAcc -
// ---------------
typedef ::cppu::WeakComponentImplHelper5<
::com::sun::star::accessibility::XAccessible,
::com::sun::star::accessibility::XAccessibleEventBroadcaster,
::com::sun::star::accessibility::XAccessibleContext,
::com::sun::star::accessibility::XAccessibleComponent,
::com::sun::star::accessibility::XAccessibleSelection >
ToolbarMenuAccComponentBase;
class ToolbarMenuAcc :
public ::comphelper::OBaseMutex,
public ToolbarMenuAccComponentBase
{
public:
ToolbarMenuAcc( ToolbarMenu_Impl& rParent );
~ToolbarMenuAcc();
void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
public:
// XAccessible
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
// XAccessibleEventBroadcaster
using cppu::WeakComponentImplHelper5<com::sun::star::accessibility::XAccessible, com::sun::star::accessibility::XAccessibleEventBroadcaster, com::sun::star::accessibility::XAccessibleContext, com::sun::star::accessibility::XAccessibleComponent, com::sun::star::accessibility::XAccessibleSelection>::addEventListener;
virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
using cppu::WeakComponentImplHelper5<com::sun::star::accessibility::XAccessible, com::sun::star::accessibility::XAccessibleEventBroadcaster, com::sun::star::accessibility::XAccessibleContext, com::sun::star::accessibility::XAccessibleComponent, com::sun::star::accessibility::XAccessibleSelection>::removeEventListener;
virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
// XAccessibleContext
virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
// XAccessibleComponent
virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
// XAccessibleSelection
virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
DECL_LINK( WindowEventListener, VclSimpleEvent* );
private:
EventListenerVector mxEventListeners;
ToolbarMenu_Impl* mpParent;
/// The current FOCUSED state.
bool mbIsFocused;
void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
/** Tell all listeners that the object is dying. This callback is
usually called from the WeakComponentImplHelper class.
*/
virtual void SAL_CALL disposing (void);
/** Check whether or not the object has been disposed (or is in the
state of beeing disposed). If that is the case then
DisposedException is thrown to inform the (indirect) caller of the
foul deed.
*/
void ThrowIfDisposed (void) throw (::com::sun::star::lang::DisposedException);
};
// -----------------------
// - ToolbarMenuEntryAcc -
// -----------------------
typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::accessibility::XAccessible,
::com::sun::star::accessibility::XAccessibleEventBroadcaster,
::com::sun::star::accessibility::XAccessibleContext,
::com::sun::star::accessibility::XAccessibleComponent > ToolbarMenuEntryAccBase;
class ToolbarMenuEntryAcc : public ::comphelper::OBaseMutex,
public ToolbarMenuEntryAccBase
{
public:
ToolbarMenuEntryAcc( ToolbarMenuEntry* pParent );
~ToolbarMenuEntryAcc();
void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
// XAccessible
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
// XAccessibleEventBroadcaster
using ToolbarMenuEntryAccBase::addEventListener;
virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
using ToolbarMenuEntryAccBase::removeEventListener;
virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
// XAccessibleContext
virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
// XAccessibleComponent
virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
private:
EventListenerVector mxEventListeners;
::vos::OMutex maMutex;
ToolbarMenuEntry* mpParent;
/** Tell all listeners that the object is dying. This callback is
usually called from the WeakComponentImplHelper class.
*/
virtual void SAL_CALL disposing (void);
};
// -----------------------------------------------------------------------------
struct ToolbarMenu_Impl
{
ToolbarMenu& mrMenu;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
rtl::Reference< svt::FrameStatusListener > mxStatusListener;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceManager;
rtl::Reference< ToolbarMenuAcc > mxAccessible;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxOldSelection;
ToolbarMenuEntryVector maEntryVector;
int mnCheckPos;
int mnImagePos;
int mnTextPos;
int mnHighlightedEntry;
int mnSelectedEntry;
int mnLastColumn;
Size maSize;
Link maSelectHdl;
ToolbarMenu_Impl( ToolbarMenu& rMenu, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame );
~ToolbarMenu_Impl();
void setAccessible( ToolbarMenuAcc* pAccessible );
void fireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
bool hasAccessibleListeners();
sal_Int32 getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessibleChild( sal_Int32 index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessibleChild( Control* pControl, sal_Int32 childIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
void selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
sal_Bool isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
void clearAccessibleSelection();
ToolbarMenuEntry* implGetEntry( int nEntry ) const;
void notifyHighlightedEntry();
void implHighlightControl( USHORT nCode, Control* pControl );
};
}

View file

@ -976,10 +976,7 @@ sal_Int16 SAL_CALL ValueItemAcc::getAccessibleRole()
::rtl::OUString SAL_CALL ValueItemAcc::getAccessibleDescription()
throw (uno::RuntimeException)
{
const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
String aRet( RTL_CONSTASCII_USTRINGPARAM( "ValueSet item" ) );
return aRet;
return ::rtl::OUString();
}
// -----------------------------------------------------------------------------
@ -1239,7 +1236,7 @@ sal_Int32 SAL_CALL ValueItemAcc::getBackground( )
throw (uno::RuntimeException)
{
UINT32 nColor;
if (mpParent->meType == VALUESETITEM_COLOR)
if (mpParent && mpParent->meType == VALUESETITEM_COLOR)
nColor = mpParent->maColor.GetColor();
else
nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();

1
svtools/source/control/valueimp.hxx Normal file → Executable file
View file

@ -111,6 +111,7 @@ struct ValueSet_Impl
{
::std::auto_ptr< ValueItemList > mpItemList;
bool mbIsTransientChildrenDisabled;
Link maHighlightHdl;
ValueSet_Impl() : mpItemList( ::std::auto_ptr< ValueItemList >( new ValueItemList() ) ),
mbIsTransientChildrenDisabled( false )

View file

@ -1418,7 +1418,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
{
USHORT nLastItem = (USHORT)mpImpl->mpItemList->Count();
USHORT nItemPos = VALUESET_ITEM_NOTFOUND;
USHORT nCurPos;
USHORT nCurPos = VALUESET_ITEM_NONEITEM;
USHORT nCalcPos;
if ( !nLastItem || !ImplGetFirstItem() )
@ -1431,8 +1431,6 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
if ( mnSelItemId )
nCurPos = GetItemPos( mnSelItemId );
else
nCurPos = VALUESET_ITEM_NONEITEM;
nCalcPos = nCurPos;
//switch off selection mode if key travelling is used
@ -1528,30 +1526,20 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
nCalcPos - ( nLineCount * mnCols ));
else
{
if( (KEY_UP == rKEvt.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET) )
if ( mpNoneItem )
{
Window* pParent = GetParent();
pParent->GrabFocus();
pParent->KeyInput( rKEvt );
break;
mnCurCol = nCalcPos%mnCols;
nItemPos = VALUESET_ITEM_NONEITEM;
}
else
{
if ( mpNoneItem )
{
mnCurCol = nCalcPos%mnCols;
nItemPos = VALUESET_ITEM_NONEITEM;
}
if ( nLastItem+1 <= mnCols )
nItemPos = nCalcPos;
else
{
if ( nLastItem+1 <= mnCols )
nItemPos = nCalcPos;
else
{
nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols);
if ( nItemPos+mnCols <= nLastItem )
nItemPos = nItemPos + mnCols;
}
nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols);
if ( nItemPos+mnCols <= nLastItem )
nItemPos = nItemPos + mnCols;
}
}
}
@ -1580,6 +1568,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
nCalcPos + ( nLineCount * mnCols ));
else
{
#if 0
if( (KEY_DOWN == rKEvt.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET) )
{
Window* pParent = GetParent();
@ -1588,6 +1577,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
break;
}
else
#endif
{
if ( mpNoneItem )
{
@ -1620,7 +1610,6 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
bDefault = TRUE;
break;
}
if(!bDefault)
EndSelection();
if ( nItemPos != VALUESET_ITEM_NOTFOUND )
@ -1630,6 +1619,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
nItemId = GetItemId( nItemPos );
else
nItemId = 0;
if ( nItemId != mnSelItemId )
{
SelectItem( nItemId );
@ -2278,6 +2268,7 @@ void ValueSet::SelectItem( USHORT nItemId )
::com::sun::star::uno::Any aOldAny, aNewAny;
ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny );
}
mpImpl->maHighlightHdl.Call(this);
}
}
@ -2749,3 +2740,19 @@ bool ValueSet::IsRTLActive (void)
return Application::GetSettings().GetLayoutRTL() && IsRTLEnabled();
}
// -----------------------------------------------------------------------
void ValueSet::SetHighlightHdl( const Link& rLink )
{
mpImpl->maHighlightHdl = rLink;
}
// -----------------------------------------------------------------------
const Link& ValueSet::GetHighlightHdl() const
{
return mpImpl->maHighlightHdl;
}
// -----------------------------------------------------------------------

View file

@ -55,7 +55,9 @@ SLOFILES= \
$(SLO)$/unoevent.obj \
$(SLO)$/unoiface.obj \
$(SLO)$/unoimap.obj \
$(SLO)$/svtxgridcontrol.obj
$(SLO)$/svtxgridcontrol.obj \
$(SLO)$/popupwindowcontroller.obj \
$(SLO)$/popupmenucontrollerbase.obj
# --- Targets ------------------------------------------------------

View file

@ -0,0 +1,420 @@
/*************************************************************************
*
* 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_svtools.hxx"
//_________________________________________________________________________________________________________________
// my own includes
//_________________________________________________________________________________________________________________
#include "svtools/popupmenucontrollerbase.hxx"
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/awt/MenuItemStyle.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/awt/XMenuExtended.hpp>
//_________________________________________________________________________________________________________________
// includes of other projects
//_________________________________________________________________________________________________________________
#ifndef _VCL_MENU_HXX_
#include <vcl/menu.hxx>
#endif
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
#include <vos/mutex.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
//
using ::rtl::OUString;
using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
namespace svt
{
struct PopupMenuControllerBaseDispatchInfo
{
Reference< XDispatch > mxDispatch;
const URL maURL;
const Sequence< PropertyValue > maArgs;
PopupMenuControllerBaseDispatchInfo( const Reference< XDispatch >& xDispatch, const URL& rURL, const Sequence< PropertyValue >& rArgs )
: mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
};
PopupMenuControllerBase::PopupMenuControllerBase( const Reference< XMultiServiceFactory >& xServiceManager ) :
::comphelper::OBaseMutex(),
PopupMenuControllerBaseType(m_aMutex),
m_bInitialized( false ),
m_xServiceManager( xServiceManager )
{
if ( m_xServiceManager.is() )
m_xURLTransformer.set( m_xServiceManager->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))),UNO_QUERY );
}
PopupMenuControllerBase::~PopupMenuControllerBase()
{
}
// protected function
void PopupMenuControllerBase::throwIfDisposed() throw ( RuntimeException )
{
if (rBHelper.bDisposed || rBHelper.bInDispose)
throw com::sun::star::lang::DisposedException();
}
// protected function
void PopupMenuControllerBase::resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu )
{
VCLXPopupMenu* pPopupMenu = 0;
if ( rPopupMenu.is() && rPopupMenu->getItemCount() > 0 )
{
pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
if ( pPopupMenu )
{
vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
pVCLPopupMenu->Clear();
}
}
}
void SAL_CALL PopupMenuControllerBase::disposing()
{
// Reset our members and set disposed flag
osl::MutexGuard aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xPopupMenu.clear();
m_xServiceManager.clear();
}
// XServiceInfo
sal_Bool SAL_CALL PopupMenuControllerBase::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
{
const Sequence< rtl::OUString > aSNL( getSupportedServiceNames() );
const rtl::OUString * pArray = aSNL.getConstArray();
for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
if( pArray[i] == ServiceName )
return true;
return false;
}
// XEventListener
void SAL_CALL PopupMenuControllerBase::disposing( const EventObject& ) throw ( RuntimeException )
{
osl::MutexGuard aLock( m_aMutex );
m_xFrame.clear();
m_xDispatch.clear();
m_xPopupMenu.clear();
}
// XMenuListener
void SAL_CALL PopupMenuControllerBase::highlight( const awt::MenuEvent& ) throw (RuntimeException)
{
}
void PopupMenuControllerBase::impl_select(const Reference< XDispatch >& _xDispatch,const URL& aURL)
{
Sequence<PropertyValue> aArgs;
OSL_ENSURE(_xDispatch.is(),"PopupMenuControllerBase::impl_select: No dispatch");
if ( _xDispatch.is() )
_xDispatch->dispatch( aURL, aArgs );
}
void SAL_CALL PopupMenuControllerBase::select( const awt::MenuEvent& rEvent ) throw (RuntimeException)
{
throwIfDisposed();
osl::MutexGuard aLock( m_aMutex );
Reference< awt::XMenuExtended > xExtMenu( m_xPopupMenu, UNO_QUERY );
if( xExtMenu.is() )
{
Sequence<PropertyValue> aArgs;
dispatchCommand( xExtMenu->getCommand( rEvent.MenuId ), aArgs );
}
}
void PopupMenuControllerBase::dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs )
{
osl::MutexGuard aLock( m_aMutex );
throwIfDisposed();
try
{
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY_THROW );
URL aURL;
aURL.Complete = sCommandURL;
m_xURLTransformer->parseStrict( aURL );
Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW );
Application::PostUserEvent( STATIC_LINK(0, PopupMenuControllerBase, ExecuteHdl_Impl), new PopupMenuControllerBaseDispatchInfo( xDispatch, aURL, rArgs ) );
}
catch( Exception& )
{
}
}
IMPL_STATIC_LINK_NOINSTANCE( PopupMenuControllerBase, ExecuteHdl_Impl, PopupMenuControllerBaseDispatchInfo*, pDispatchInfo )
{
pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs );
delete pDispatchInfo;
return 0;
}
void SAL_CALL PopupMenuControllerBase::activate( const awt::MenuEvent& ) throw (RuntimeException)
{
}
void SAL_CALL PopupMenuControllerBase::deactivate( const awt::MenuEvent& ) throw (RuntimeException)
{
}
void SAL_CALL PopupMenuControllerBase::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException )
{
osl::ClearableMutexGuard aLock( m_aMutex );
throwIfDisposed();
aLock.clear();
updateCommand( m_aCommandURL );
}
void SAL_CALL PopupMenuControllerBase::updateCommand( const rtl::OUString& rCommandURL )
{
osl::ClearableMutexGuard aLock( m_aMutex );
Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
Reference< XDispatch > xDispatch( m_xDispatch );
URL aTargetURL;
aTargetURL.Complete = rCommandURL;
m_xURLTransformer->parseStrict( aTargetURL );
aLock.clear();
// Add/remove status listener to get a status update once
if ( xDispatch.is() )
{
xDispatch->addStatusListener( xStatusListener, aTargetURL );
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
}
}
// XDispatchProvider
Reference< XDispatch > SAL_CALL
PopupMenuControllerBase::queryDispatch(
const URL& /*aURL*/,
const rtl::OUString& /*sTarget*/,
sal_Int32 /*nFlags*/ )
throw( RuntimeException )
{
// must be implemented by subclass
osl::MutexGuard aLock( m_aMutex );
throwIfDisposed();
return Reference< XDispatch >();
}
Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispatches( const Sequence< DispatchDescriptor >& lDescriptor ) throw( RuntimeException )
{
// Create return list - which must have same size then the given descriptor
// It's not allowed to pack it!
osl::ClearableMutexGuard aLock( m_aMutex );
throwIfDisposed();
aLock.clear();
sal_Int32 nCount = lDescriptor.getLength();
uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
// Step over all descriptors and try to get any dispatcher for it.
for( sal_Int32 i=0; i<nCount; ++i )
{
lDispatcher[i] = queryDispatch( lDescriptor[i].FeatureURL ,
lDescriptor[i].FrameName ,
lDescriptor[i].SearchFlags );
}
return lDispatcher;
}
// XDispatch
void SAL_CALL
PopupMenuControllerBase::dispatch(
const URL& /*aURL*/,
const Sequence< PropertyValue >& /*seqProperties*/ )
throw( ::com::sun::star::uno::RuntimeException )
{
// must be implemented by subclass
osl::MutexGuard aLock( m_aMutex );
throwIfDisposed();
}
void SAL_CALL
PopupMenuControllerBase::addStatusListener(
const Reference< XStatusListener >& xControl,
const URL& aURL )
throw( ::com::sun::star::uno::RuntimeException )
{
osl::ResettableMutexGuard aLock( m_aMutex );
throwIfDisposed();
aLock.clear();
bool bStatusUpdate( false );
rBHelper.addListener( ::getCppuType( &xControl ), xControl );
aLock.reset();
if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 )
bStatusUpdate = true;
aLock.clear();
if ( bStatusUpdate )
{
// Dummy update for popup menu controllers
FeatureStateEvent aEvent;
aEvent.FeatureURL = aURL;
aEvent.IsEnabled = sal_True;
aEvent.Requery = sal_False;
aEvent.State = Any();
xControl->statusChanged( aEvent );
}
}
void SAL_CALL PopupMenuControllerBase::removeStatusListener(
const Reference< XStatusListener >& xControl,
const URL& /*aURL*/ )
throw( ::com::sun::star::uno::RuntimeException )
{
rBHelper.removeListener( ::getCppuType( &xControl ), xControl );
}
::rtl::OUString PopupMenuControllerBase::determineBaseURL( const ::rtl::OUString& aURL )
{
// Just use the main part of the URL for popup menu controllers
sal_Int32 nQueryPart( 0 );
sal_Int32 nSchemePart( 0 );
rtl::OUString aMainURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.popup:" ));
nSchemePart = aURL.indexOf( ':' );
if (( nSchemePart > 0 ) &&
( aURL.getLength() > ( nSchemePart+1 )))
{
nQueryPart = aURL.indexOf( '?', nSchemePart );
if ( nQueryPart > 0 )
aMainURL += aURL.copy( nSchemePart, nQueryPart-nSchemePart );
else if ( nQueryPart == -1 )
aMainURL += aURL.copy( nSchemePart+1 );
}
return aMainURL;
}
// XInitialization
void SAL_CALL PopupMenuControllerBase::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
{
osl::MutexGuard aLock( m_aMutex );
sal_Bool bInitalized( m_bInitialized );
if ( !bInitalized )
{
PropertyValue aPropValue;
rtl::OUString aCommandURL;
Reference< XFrame > xFrame;
for ( int i = 0; i < aArguments.getLength(); i++ )
{
if ( aArguments[i] >>= aPropValue )
{
if ( aPropValue.Name.equalsAscii( "Frame" ))
aPropValue.Value >>= xFrame;
else if ( aPropValue.Name.equalsAscii( "CommandURL" ))
aPropValue.Value >>= aCommandURL;
}
}
if ( xFrame.is() && aCommandURL.getLength() )
{
m_xFrame = xFrame;
m_aCommandURL = aCommandURL;
m_aBaseURL = determineBaseURL( aCommandURL );
m_bInitialized = true;
}
}
}
// XPopupMenuController
void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException )
{
osl::MutexGuard aLock( m_aMutex );
throwIfDisposed();
if ( m_xFrame.is() && !m_xPopupMenu.is() )
{
// Create popup menu on demand
vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
m_xPopupMenu = xPopupMenu;
m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY ));
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
URL aTargetURL;
aTargetURL.Complete = m_aCommandURL;
m_xURLTransformer->parseStrict( aTargetURL );
m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
impl_setPopupMenu();
updatePopupMenu();
}
}
void PopupMenuControllerBase::impl_setPopupMenu()
{
}
}

View file

@ -0,0 +1,258 @@
/*************************************************************************
*
* 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_svtools.hxx"
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/svapp.hxx>
#include "svtools/popupwindowcontroller.hxx"
#include "svtools/toolbarmenu.hxx"
using rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
namespace svt
{
class PopupWindowControllerImpl
{
public:
PopupWindowControllerImpl();
~PopupWindowControllerImpl();
void SetPopupWindow( ::Window* pPopupWindow, ToolBox* pToolBox );
DECL_LINK( WindowEventListener, VclSimpleEvent* );
DECL_STATIC_LINK( PopupWindowControllerImpl, AsyncDeleteWindowHdl, Window* );
private:
::Window* mpPopupWindow;
ToolBox* mpToolBox;
};
PopupWindowControllerImpl::PopupWindowControllerImpl()
: mpPopupWindow( 0 )
, mpToolBox( 0 )
{
}
PopupWindowControllerImpl::~PopupWindowControllerImpl()
{
if( mpPopupWindow )
SetPopupWindow(0,0);
}
void PopupWindowControllerImpl::SetPopupWindow( ::Window* pPopupWindow, ToolBox* pToolBox )
{
if( mpPopupWindow )
{
mpPopupWindow->RemoveEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ) );
Application::PostUserEvent( STATIC_LINK( this, PopupWindowControllerImpl, AsyncDeleteWindowHdl ), mpPopupWindow );
}
mpPopupWindow = pPopupWindow;
mpToolBox = pToolBox;
if( mpPopupWindow )
{
mpPopupWindow->AddEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ));
}
}
IMPL_LINK( PopupWindowControllerImpl, WindowEventListener, VclSimpleEvent*, pEvent )
{
VclWindowEvent* pWindowEvent = dynamic_cast< VclWindowEvent* >( pEvent );
if( pWindowEvent )
{
switch( pWindowEvent->GetId() )
{
case VCLEVENT_WINDOW_CLOSE:
case VCLEVENT_WINDOW_ENDPOPUPMODE:
SetPopupWindow(0,0);
break;
case VCLEVENT_WINDOW_SHOW:
{
if( mpPopupWindow )
{
if( mpToolBox )
mpToolBox->CallEventListeners( VCLEVENT_DROPDOWN_OPEN, (void*)mpPopupWindow );
mpPopupWindow->CallEventListeners( VCLEVENT_WINDOW_GETFOCUS, 0 );
svtools::ToolbarMenu* pToolbarMenu = dynamic_cast< svtools::ToolbarMenu* >( mpPopupWindow );
if( pToolbarMenu )
pToolbarMenu->highlightFirstEntry();
break;
}
break;
}
case VCLEVENT_WINDOW_HIDE:
{
if( mpPopupWindow )
{
mpPopupWindow->CallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS, 0 );
if( mpToolBox )
mpToolBox->CallEventListeners( VCLEVENT_DROPDOWN_CLOSE, (void*)mpPopupWindow );
}
break;
}
}
}
return 1;
}
//--------------------------------------------------------------------
IMPL_STATIC_LINK( PopupWindowControllerImpl, AsyncDeleteWindowHdl, Window*, pWindow )
{
(void)*pThis;
delete pWindow;
return 0;
}
//========================================================================
// class PopupWindowController
//========================================================================
PopupWindowController::PopupWindowController( const Reference< lang::XMultiServiceFactory >& rServiceManager,
const Reference< frame::XFrame >& xFrame,
const OUString& aCommandURL )
: svt::ToolboxController( rServiceManager, xFrame, aCommandURL )
, mpImpl( new PopupWindowControllerImpl() )
{
}
PopupWindowController::~PopupWindowController()
{
}
// XInterface
Any SAL_CALL PopupWindowController::queryInterface( const Type& aType )
throw (RuntimeException)
{
Any a( ToolboxController::queryInterface( aType ) );
if ( a.hasValue() )
return a;
return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
}
void SAL_CALL PopupWindowController::acquire() throw ()
{
ToolboxController::acquire();
}
void SAL_CALL PopupWindowController::release() throw ()
{
ToolboxController::release();
}
// XServiceInfo
sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& ServiceName ) throw(RuntimeException)
{
const Sequence< OUString > aSNL( getSupportedServiceNames() );
const OUString * pArray = aSNL.getConstArray();
for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
if( pArray[i] == ServiceName )
return true;
return false;
}
// XInitialization
void SAL_CALL PopupWindowController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
svt::ToolboxController::initialize( aArguments );
if( m_aCommandURL.getLength() )
addStatusListener( m_aCommandURL );
}
// XComponent
void SAL_CALL PopupWindowController::dispose() throw (RuntimeException)
{
if( m_aCommandURL.getLength() )
removeStatusListener( m_aCommandURL );
svt::ToolboxController::dispose();
}
// XStatusListener
void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException )
{
svt::ToolboxController::statusChanged(rEvent);
enable( rEvent.IsEnabled );
}
// XToolbarController
void SAL_CALL PopupWindowController::execute( sal_Int16 KeyModifier ) throw (RuntimeException)
{
svt::ToolboxController::execute( KeyModifier );
}
void SAL_CALL PopupWindowController::click() throw (RuntimeException)
{
svt::ToolboxController::click();
}
void SAL_CALL PopupWindowController::doubleClick() throw (RuntimeException)
{
svt::ToolboxController::doubleClick();
}
Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() throw (RuntimeException)
{
ToolBox* pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
if( pToolBox )
{
::Window* pItemWindow = pToolBox->GetItemWindow( pToolBox->GetDownItemId() );
::Window* pWin = createPopupWindow( pItemWindow ? pItemWindow : pToolBox );
if( pWin )
{
pWin->EnableDocking(true);
mpImpl->SetPopupWindow(pWin,pToolBox);
::Window::GetDockingManager()->StartPopupMode( pToolBox, pWin, FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
}
}
return Reference< awt::XWindow >();
}
Reference< awt::XWindow > SAL_CALL PopupWindowController::createItemWindow( const Reference< awt::XWindow >& /*Parent*/ )
throw (RuntimeException)
{
return Reference< awt::XWindow >();
}
}

View file

@ -43,6 +43,8 @@
#endif
#include <vcl/toolbox.hxx>
using ::rtl::OUString;
using namespace ::cppu;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::uno;
@ -54,10 +56,29 @@ using namespace ::com::sun::star::frame;
namespace svt
{
struct DispatchInfo
{
Reference< XDispatch > mxDispatch;
const URL maURL;
const Sequence< PropertyValue > maArgs;
DispatchInfo( const Reference< XDispatch >& xDispatch, const URL& rURL, const Sequence< PropertyValue >& rArgs )
: mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
};
struct ToolboxController_Impl
{
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer;
rtl::OUString m_sModuleName;
sal_uInt16 m_nToolBoxId;
DECL_STATIC_LINK( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo* );
ToolboxController_Impl()
: m_nToolBoxId( SAL_MAX_UINT16 )
{}
};
ToolboxController::ToolboxController(
@ -166,11 +187,6 @@ void SAL_CALL ToolboxController::release() throw ()
void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments )
throw ( Exception, RuntimeException )
{
const rtl::OUString aFrameName( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
const rtl::OUString aCommandURLName( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ));
const rtl::OUString aServiceManagerName( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
const rtl::OUString aParentWindow( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
bool bInitialized( true );
{
@ -192,14 +208,16 @@ throw ( Exception, RuntimeException )
{
if ( aArguments[i] >>= aPropValue )
{
if ( aPropValue.Name.equalsAscii( "Frame" ))
if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Frame") ))
m_xFrame.set(aPropValue.Value,UNO_QUERY);
else if ( aPropValue.Name.equalsAscii( "CommandURL" ))
else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CommandURL") ))
aPropValue.Value >>= m_aCommandURL;
else if ( aPropValue.Name.equalsAscii( "ServiceManager" ))
else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ServiceManager") ))
m_xServiceManager.set(aPropValue.Value,UNO_QUERY);
else if ( aPropValue.Name.equalsAscii( "ParentWindow" ))
else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ParentWindow") ))
m_pImpl->m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ModuleName" ) ) )
aPropValue.Value >>= m_pImpl->m_sModuleName;
}
}
@ -704,4 +722,77 @@ Reference< ::com::sun::star::awt::XWindow > ToolboxController::getParent() const
{
return m_pImpl->m_xParentWindow;
}
const rtl::OUString& ToolboxController::getModuleName() const
{
return m_pImpl->m_sModuleName;
}
void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs )
{
try
{
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY_THROW );
URL aURL;
aURL.Complete = sCommandURL;
getURLTransformer()->parseStrict( aURL );
Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW );
Application::PostUserEvent( STATIC_LINK(0, ToolboxController_Impl, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
}
catch( Exception& )
{
}
}
//--------------------------------------------------------------------
IMPL_STATIC_LINK_NOINSTANCE( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
{
pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs );
delete pDispatchInfo;
return 0;
}
void ToolboxController::enable( bool bEnable )
{
ToolBox* pToolBox = 0;
sal_uInt16 nItemId = 0;
if( getToolboxId( nItemId, &pToolBox ) )
{
pToolBox->EnableItem( nItemId, bEnable ? TRUE : FALSE );
}
}
bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
{
if( (m_pImpl->m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
return m_pImpl->m_nToolBoxId;
ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
if( (m_pImpl->m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
{
const sal_uInt16 nCount = pToolBox->GetItemCount();
for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
{
const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
if ( pToolBox->GetItemCommand( nItemId ) == String( m_aCommandURL ) )
{
m_pImpl->m_nToolBoxId = nItemId;
break;
}
}
}
if( ppToolBox )
*ppToolBox = pToolBox;
rItemId = m_pImpl->m_nToolBoxId;
return (rItemId != SAL_MAX_UINT16) && (( ppToolBox == 0) || (*ppToolBox != 0) );
}
} // svt

View file

@ -152,7 +152,7 @@ public:
void Unlock();
BOOL IsLocked() const;
void StartPopupMode( ToolBox* pParentToolBox );
void StartPopupMode( ToolBox* pParentToolBox, ULONG nPopupModeFlags );
BOOL IsInPopupMode() const;
void TitleButtonClick( USHORT nButton );
@ -234,7 +234,10 @@ public:
BOOL IsLocked( const Window *pWin );
void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin );
void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin, ULONG nPopupModeFlags );
BOOL IsInPopupMode( const Window *pWin );
void EndPopupMode( const Window *pWin );
// required because those methods are not virtual in Window (!!!) and must
// be availbale from the toolkit

View file

@ -124,6 +124,8 @@ namespace dnd {
namespace vcl { struct ControlLayoutData; }
namespace svt { class PopupWindowControllerImpl; }
// ---------------
// - WindowTypes -
// ---------------
@ -362,6 +364,8 @@ class VCL_DLLPUBLIC Window : public OutputDevice
friend class ImplPopupFloatWin;
friend class MenuFloatingWindow;
friend class svt::PopupWindowControllerImpl;
private:
// NOTE: to remove many dependencies of other modules
// to this central file, all members are now hidden

View file

@ -426,11 +426,19 @@ void DockingManager::SetFloatingMode( const Window *pWindow, BOOL bFloating )
pWrapper->SetFloatingMode( bFloating );
}
void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow, ULONG nFlags )
{
ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
if( pWrapper )
pWrapper->StartPopupMode( pParentToolBox );
pWrapper->StartPopupMode( pParentToolBox, nFlags );
}
void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
{
StartPopupMode( pParentToolBox, pWindow, FLOATWIN_POPUPMODE_ALLOWTEAROFF |
FLOATWIN_POPUPMODE_NOFOCUSCLOSE |
FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |
FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
}
BOOL DockingManager::IsInPopupMode( const Window *pWindow )
@ -442,6 +450,17 @@ BOOL DockingManager::IsInPopupMode( const Window *pWindow )
return FALSE;
}
// -----------------------------------------------------------------------
void DockingManager::EndPopupMode( const Window *pWin )
{
ImplDockingWindowWrapper *pWrapper = GetDockingWindowWrapper( pWin );
if( pWrapper && pWrapper->GetFloatingWindow() && pWrapper->GetFloatingWindow()->IsInPopupMode() )
pWrapper->GetFloatingWindow()->EndPopupMode();
}
// -----------------------------------------------------------------------
void DockingManager::AddWindow( const Window *pWindow )
{
ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
@ -515,12 +534,15 @@ private:
ImplDockingWindowWrapper* mpDockingWin;
BOOL mbHighlight;
BOOL mbMoving;
bool mbTrackingEnabled;
Point maDelta;
Point maTearOffPosition;
bool mbGripAtBottom;
bool mbHasGrip;
void ImplSetBorder();
public:
ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin );
ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
~ImplPopupFloatWin();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
@ -537,9 +559,11 @@ public:
Point GetTearOffPosition() const;
void DrawGrip();
void DrawBorder();
bool hasGrip() const { return mbHasGrip; }
};
ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin ) :
ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
{
mpWindowImpl->mbToolbarFloatingWindow = TRUE; // indicate window type, required for accessibility
@ -547,6 +571,9 @@ ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper*
mpDockingWin = pDockingWin;
mbHighlight = FALSE;
mbMoving = FALSE;
mbTrackingEnabled = FALSE;
mbGripAtBottom = TRUE;
mbHasGrip = bHasGrip;
ImplSetBorder();
}
@ -582,7 +609,9 @@ void ImplPopupFloatWin::ImplSetBorder()
// we're using a special border for the grip
// by setting those members the method SetOutputSizePixel() can
// be used to set the proper window size
mpWindowImpl->mnTopBorder = 1 + POPUP_DRAGHEIGHT+2;
mpWindowImpl->mnTopBorder = 1;
if( hasGrip() )
mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
mpWindowImpl->mnBottomBorder = 1;
mpWindowImpl->mnLeftBorder = 1;
mpWindowImpl->mnRightBorder = 1;
@ -596,13 +625,25 @@ void ImplPopupFloatWin::Resize()
Rectangle ImplPopupFloatWin::GetDragRect() const
{
return Rectangle( 1, 1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
Rectangle aRect;
if( hasGrip() )
{
aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
if( mbGripAtBottom )
{
int height = GetOutputSizePixel().Height();
aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
}
}
return aRect;
}
Point ImplPopupFloatWin::GetToolboxPosition() const
{
// return inner position where a toolbox could be placed
Point aPt( 1, 1+GetDragRect().getHeight() ); // grip + border
Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) ); // grip + border
return aPt;
}
@ -616,7 +657,6 @@ Point ImplPopupFloatWin::GetTearOffPosition() const
void ImplPopupFloatWin::DrawBorder()
{
SetFillColor();
SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
Point aPt;
Rectangle aRect( aPt, GetOutputSizePixel() );
@ -626,9 +666,16 @@ void ImplPopupFloatWin::DrawBorder()
if( !aItemClipRect.IsEmpty() )
{
aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
// draw the excluded border part with the background color of a toolbox
SetClipRegion( Region( aItemClipRect ) );
SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
DrawRect( aRect );
aClipRgn.Exclude( aItemClipRect );
SetClipRegion( aClipRgn );
}
SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
DrawRect( aRect );
SetClipRegion( oldClipRgn );
}
@ -724,7 +771,8 @@ void ImplPopupFloatWin::Paint( const Rectangle& )
Rectangle aRect( aPt, GetOutputSizePixel() );
DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
DrawBorder();
DrawGrip();
if( hasGrip() )
DrawGrip();
}
void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
@ -733,7 +781,7 @@ void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
if( !ToolBox::AlwaysLocked() ) // no tear off if locking is enabled
{
if( rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
{
// start window move
mbMoving = TRUE;
@ -755,6 +803,7 @@ void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
{
mbTrackingEnabled = false;
FloatingWindow::MouseButtonUp( rMEvt );
}
@ -769,6 +818,11 @@ void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
ImplMirrorFramePos(aState.maPos);
maTearOffPosition = GetWindow( WINDOW_BORDER )->GetPosPixel();
maDelta = aState.maPos - maTearOffPosition;
mbTrackingEnabled = true;
}
else
{
mbTrackingEnabled = false;
}
}
@ -1187,7 +1241,7 @@ BOOL ImplDockingWindowWrapper::IsTitleButtonVisible( USHORT nButton ) const
// -----------------------------------------------------------------------
void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox )
void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, ULONG nFlags )
{
// do nothing if window is floating
if( IsFloatingMode() )
@ -1202,7 +1256,7 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox )
mpOldBorderWin = NULL; // no border window found
// the new parent for popup mode
ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this );
ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
pWin->SetText( GetWindow()->GetText() );
@ -1232,12 +1286,6 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox )
// (SetPosPixel etc. check for valid mpFloatWin pointer)
mpFloatWin = pWin;
ULONG nFlags = FLOATWIN_POPUPMODE_ALLOWTEAROFF |
FLOATWIN_POPUPMODE_NOFOCUSCLOSE |
FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |
FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE;
// |FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE;
// if the subtoolbar was opened via keyboard make sure that key events
// will go into subtoolbar
if( pParentToolBox->IsKeyEvent() )
@ -1339,7 +1387,7 @@ void ImplDockingWindowWrapper::SetFloatingMode( BOOL bFloatMode )
aSettings.SetStyleSettings( aStyleSettings );
pWin->SetSettings( aSettings );*/
mpFloatWin = pWin;
// mpFloatWin = pWin;
GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
@ -1374,6 +1422,8 @@ void ImplDockingWindowWrapper::SetFloatingMode( BOOL bFloatMode )
pWin->SetMinOutputSizePixel( maMinOutSize );
pWin->SetMaxOutputSizePixel( maMaxOutSize );
mpFloatWin = pWin;
if ( bVisible )
GetWindow()->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );