diff options
1142 files changed, 54592 insertions, 13359 deletions
diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControl.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControl.hxx new file mode 100755 index 000000000000..765dc115fa11 --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControl.hxx @@ -0,0 +1,277 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2009 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControl.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROL_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROL_HXX + +#include <accessibility/extended/AccessibleGridControlBase.hxx> +#include <accessibility/extended/AccessibleGridControlTable.hxx> +#include <cppuhelper/weakref.hxx> +#include <svtools/accessibletable.hxx> + + +#include <memory> + +using namespace ::svt::table; + +// ============================================================================ + +namespace accessibility { + + class AccessibleGridControl_Impl; + +// ============================================================================ + +/** This class represents the complete accessible Grid Control object. */ +class AccessibleGridControl : public AccessibleGridControlBase +{ + friend class AccessibleGridControlAccess; + +protected: + AccessibleGridControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator, + ::svt::table::IAccessibleTable& _rTable + ); + + virtual ~AccessibleGridControl(); + + /** sets the XAccessible which created the context + + <p>To be called only once, and only if in the ctor NULL was passed.</p> + */ + void setCreator( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator + ); + + /** Cleans up members. */ + using AccessibleGridControlBase::disposing; + virtual void SAL_CALL disposing(); + +protected: + // XAccessibleContext ----------------------------------------------------- + + /** @return The count of visible children. */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessible interface of the specified child. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The role of this object (a table). */ + virtual sal_Int16 SAL_CALL getAccessibleRole() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleComponent --------------------------------------------------- + + /** @return + The accessible child rendered under the given point. + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Grabs the focus to the Grid Control. */ + virtual void SAL_CALL grabFocus() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The key bindings associated with this object. */ + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo ----------------------------------------------------------- + + /** @return + The name of this class. + */ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ); + +public: + // helper functions + /** returns the accessible object for the row or the column header bar + */ + inline ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + getHeaderBar( ::svt::table::AccessibleTableControlObjType _eObjType ) + { + return implGetHeaderBar(_eObjType); + } + + /** returns the accessible object for the table representation + */ + inline ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + getTable( ) + { + return implGetTable(); + } + +protected: + // internal virtual methods ----------------------------------------------- + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual Rectangle implGetBoundingBox(); + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual Rectangle implGetBoundingBoxOnScreen(); + + // internal helper methods ------------------------------------------------ + + /** This method creates (once) and returns the accessible data table child. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the data table. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > implGetTable(); + + /** This method creates (once) and returns the specified header bar. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the header bar. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + implGetHeaderBar( ::svt::table::AccessibleTableControlObjType eObjType ); + + /** This method returns one of the children that are always present: + Data table, row and column header bar or corner control. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified child. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + implGetFixedChild( sal_Int32 nChildIndex ); + + /** This method creates and returns an accessible table. + @return An AccessibleGridControlTable. */ + virtual AccessibleGridControlTable* createAccessibleTable(); + +private: + // members ---------------------------------------------------------------- + ::std::auto_ptr< AccessibleGridControl_Impl > m_pImpl; +}; + +// ============================================================================ +/** the XAccessible which creates/returns an AccessibleGridControl + + <p>The instance holds it's XAccessibleContext with a hard reference, while + the contxt holds this instance weak.</p> +*/ +typedef ::cppu::WeakImplHelper1 < ::com::sun::star::accessibility::XAccessible + > AccessibleGridControlAccess_Base; + +class AccessibleGridControlAccess :public AccessibleGridControlAccess_Base + ,public ::svt::table::IAccessibleTableControl +{ +private: + ::osl::Mutex m_aMutex; + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + m_xParent; + ::svt::table::IAccessibleTable& m_rTable; + + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + m_xContext; + AccessibleGridControl* m_pContext; + // note that this pointer is valid as long as m_xContext is valid! + +public: + AccessibleGridControlAccess( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + ::svt::table::IAccessibleTable& _rTable + ); + + /// checks whether the accessible context is still alive + bool isContextAlive() const; + + /// returns the AccessibleContext belonging to this Accessible + inline AccessibleGridControl* getContext() { return m_pContext; } + inline const AccessibleGridControl* getContext() const { return m_pContext; } + +protected: + virtual ~AccessibleGridControlAccess(); + + // XAccessible + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException ); + + // IAccessibleTable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getMyself() + { + return this; + } + void dispose(); + virtual sal_Bool isAlive() const + { + return isContextAlive(); + } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getTableHeader( ::svt::table::AccessibleTableControlObjType _eObjType ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible; + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + xAccessible = pContext->getHeaderBar( _eObjType ); + return xAccessible; + } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getTable() + { + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible; + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + xAccessible = pContext->getTable(); + return xAccessible; + } + virtual void commitEvent( sal_Int16 nEventId, + const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) + { + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + pContext->commitEvent( nEventId, rNewValue, rOldValue ); + } + +private: + AccessibleGridControlAccess(); // never implemented + AccessibleGridControlAccess( const AccessibleGridControlAccess& ); // never implemented + AccessibleGridControlAccess& operator=( const AccessibleGridControlAccess& ); // never implemented +}; + +// ============================================================================ +} // namespace accessibility + +// ============================================================================ + +#endif + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlBase.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlBase.hxx new file mode 100755 index 000000000000..3cfdc182aee8 --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlBase.hxx @@ -0,0 +1,470 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlBase.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLBASE_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLBASE_HXX + +#include <svtools/accessibletable.hxx> +#include <tools/debug.hxx> +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <vcl/svapp.hxx> +#include <cppuhelper/compbase4.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <toolkit/helper/convert.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/awt/XWindow.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/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <comphelper/uno3.hxx> + +// ============================================================================ + +class Window; + +namespace utl { + class AccessibleStateSetHelper; +} + +// ============================================================================ + +namespace accessibility { + +// ============================================================================ + +/** Aquire the solar mutex. */ +class TCSolarGuard : public ::vos::OGuard +{ +public: + inline TCSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {} +}; + +// ============================================================================ + +typedef ::cppu::WeakAggComponentImplHelper4< + ::com::sun::star::accessibility::XAccessibleContext, + ::com::sun::star::accessibility::XAccessibleComponent, + ::com::sun::star::accessibility::XAccessibleEventBroadcaster, + ::com::sun::star::lang::XServiceInfo > + AccessibleGridControlImplHelper; + +/** The GridControl accessible objects inherit from this base class. It + implements basic functionality for various Accessibility interfaces and + the event broadcaster and contains the ::osl::Mutex. */ +class AccessibleGridControlBase : + public ::comphelper::OBaseMutex, + public AccessibleGridControlImplHelper +{ +public: + /** Constructor sets specified name and description. + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eNameText The constant for the name text. + @param eDescrText The constant for the description text. */ + AccessibleGridControlBase( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~AccessibleGridControlBase(); + + /** Commits DeFunc event to listeners and cleans up members. */ + virtual void SAL_CALL disposing(); + +public: + // XAccessibleContext ----------------------------------------------------- + + /** @return A reference to the parent accessible object. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleParent() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The index of this object among the parent's children. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The description of this object. + */ + virtual ::rtl::OUString SAL_CALL getAccessibleDescription() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The name of this object. + */ + virtual ::rtl::OUString SAL_CALL getAccessibleName() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The relation set (the GridControl does not have one). + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL + getAccessibleRelationSet() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The set of current states. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The parent's locale. */ + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() + throw ( ::com::sun::star::accessibility::IllegalAccessibleComponentStateException, + ::com::sun::star::uno::RuntimeException ); + + /** @return + The role of this object. Panel, ROWHEADER, COLUMNHEADER, TABLE, TABLE_CELL are supported. + */ + virtual sal_Int16 SAL_CALL getAccessibleRole() + throw ( ::com::sun::star::uno::RuntimeException ); + + /* Derived classes have to implement: + - getAccessibleChildCount, + - getAccessibleChild, + - getAccessibleRole. + Derived classes may overwrite getAccessibleIndexInParent to increase + performance. */ + + // XAccessibleComponent --------------------------------------------------- + + /** @return + <TRUE/>, if the point lies within the bounding box of this object. */ + virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The bounding box of this object. */ + virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The upper left corner of the bounding box relative to the parent. */ + virtual ::com::sun::star::awt::Point SAL_CALL getLocation() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The upper left corner of the bounding box in screen coordinates. */ + virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The size of the bounding box. */ + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the object is showing. */ + virtual sal_Bool SAL_CALL isShowing() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the object is visible. */ + virtual sal_Bool SAL_CALL isVisible() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the object can accept the focus. */ + virtual sal_Bool SAL_CALL isFocusTraversable() + 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); + + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus, + - getAccessibleKeyBinding. */ + + /** @return + No key bindings supported by default. + */ + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() + throw ( ::com::sun::star::uno::RuntimeException ); + /** @return + The accessible child rendered under the given point. + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleEventBroadcaster -------------------------------------------- + + /** Adds a new event listener */ + using cppu::WeakAggComponentImplHelperBase::addEventListener; + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleEventListener>& rxListener ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Removes an event listener. */ + using cppu::WeakAggComponentImplHelperBase::removeEventListener; + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleEventListener>& rxListener ) + throw ( ::com::sun::star::uno::RuntimeException ); + + // XTypeProvider ---------------------------------------------------------- + + /** @return An unique implementation ID. */ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo ----------------------------------------------------------- + + /** @return Whether the specified service is supported by this class. */ + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return A list of all supported services. */ + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw ( ::com::sun::star::uno::RuntimeException ); + + /* Derived classes have to implement: + - getImplementationName. */ + + // helper methods --------------------------------------------------------- + + /** @return The GridControl object type. */ + inline ::svt::table::AccessibleTableControlObjType getType() const; + + /** Commits an event to all listeners. */ + void commitEvent( + sal_Int16 nEventId, + const ::com::sun::star::uno::Any& rNewValue, + + const ::com::sun::star::uno::Any& rOldValue ); + /** @return <TRUE/>, if the object is not disposed or disposing. */ + sal_Bool isAlive() const; + +protected: + // internal virtual methods ----------------------------------------------- + + /** Determines whether the Grid control is really showing inside of + its parent accessible window. Derived classes may implement different + behaviour. + @attention This method requires locked mutex's and a living object. + @return <TRUE/>, if the object is really showing. */ + virtual sal_Bool implIsShowing(); + + /** Derived classes return the bounding box relative to the parent window. + @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual Rectangle implGetBoundingBox() = 0; + ///** Derived classes return the bounding box in screen coordinates. + // @attention This method requires locked mutex's and a living object. + // @return The bounding box (VCL rect.) in screen coordinates. */ + virtual Rectangle implGetBoundingBoxOnScreen() = 0; + + /** Creates a new AccessibleStateSetHelper and fills it with states of the + current object. This method calls FillStateSet at the GridControl which + fills it with more states depending on the object type. Derived classes + may overwrite this method and add more states. + @attention This method requires locked mutex's. + @return A filled AccessibleStateSetHelper. */ + virtual ::utl::AccessibleStateSetHelper* implCreateStateSetHelper(); + + // internal helper methods ------------------------------------------------ + + /** @throws <type>DisposedException</type> If the object is not alive. */ + void ensureIsAlive() const + throw ( ::com::sun::star::lang::DisposedException ); + + /** @return The ::osl::Mutex member provided by the class OBaseMutex. */ + inline ::osl::Mutex& getOslMutex(); + /** @return Pointer to the global ::osl::Mutex. */ + static inline ::osl::Mutex* getOslGlobalMutex(); + + /** Changes the name of the object (flat assignment, no notify). + @attention This method requires a locked mutex. */ + inline void implSetName( const ::rtl::OUString& rName ); + /** Changes the description of the object (flat assignment, no notify). + @attention This method requires a locked mutex. */ + inline void implSetDescription( const ::rtl::OUString& rDescription ); + + /** Locks all mutex's and calculates the bounding box relative to the + parent window. + @return The bounding box (VCL rect.) relative to the parent object. */ + Rectangle getBoundingBox() + throw ( ::com::sun::star::lang::DisposedException ); + ///** Locks all mutex's and calculates the bounding box in screen + // coordinates. + // @return The bounding box (VCL rect.) in screen coordinates. */ + Rectangle getBoundingBoxOnScreen() + throw ( ::com::sun::star::lang::DisposedException ); + + /** Creates a new UUID, if rId is empty. + @attention This method requires locked global mutex to prevent double + creation of an UUID. */ + static void implCreateUuid( ::com::sun::star::uno::Sequence< sal_Int8 >& rId ); + + ::comphelper::AccessibleEventNotifier::TClientId getClientId() const { return m_aClientId; } + void setClientId(::comphelper::AccessibleEventNotifier::TClientId _aNewClientId) { m_aClientId = _aNewClientId; } + +public: + // public versions of internal helper methods, with access control + struct TC_AccessControl { friend class TC_SolarMethodGuard; private: TC_AccessControl() { } }; + + inline ::osl::Mutex& getMutex( const TC_AccessControl& ) { return getOslMutex(); } + inline void ensureIsAlive( const TC_AccessControl& ) { ensureIsAlive(); } + +protected: + // members ---------------------------------------------------------------- + + /** The parent accessible object. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > m_xParent; + /** The SVT Table control. */ + ::svt::table::IAccessibleTable& m_aTable; + /** The type of this object (for names, descriptions, state sets, ...). */ + ::svt::table::AccessibleTableControlObjType m_eObjType; + +private: + /** Localized name. */ + ::rtl::OUString m_aName; + /** Localized description text. */ + ::rtl::OUString m_aDescription; + ::comphelper::AccessibleEventNotifier::TClientId m_aClientId; +}; + +// ============================================================================ +// a version of AccessibleGridControlBase which implements not only the XAccessibleContext, +// but also the XAccessible + +typedef ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessible + > GridControlAccessibleElement_Base; + +class GridControlAccessibleElement + :public AccessibleGridControlBase + ,public GridControlAccessibleElement_Base +{ +protected: + /** Constructor sets specified name and description. + + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eNameText The constant for the name text. + @param eDescrText The constant for the description text. + */ + GridControlAccessibleElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType eObjType ); + +public: + // XInterface + DECLARE_XINTERFACE( ) + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + +protected: + virtual ~GridControlAccessibleElement(); + +protected: + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() + throw ( ::com::sun::star::uno::RuntimeException ); + +private: + GridControlAccessibleElement(); // never implemented + GridControlAccessibleElement( const GridControlAccessibleElement& ); // never implemented + GridControlAccessibleElement& operator=( const GridControlAccessibleElement& ); // never implemented +}; + +// ============================================================================ +// a helper class for protecting methods which need to lock the solar mutex in addition to the own mutex + +typedef ::osl::MutexGuard OslMutexGuard; + +class TC_SolarMethodGuard : public TCSolarGuard, public OslMutexGuard +{ +public: + inline TC_SolarMethodGuard( AccessibleGridControlBase& _rOwner, bool _bEnsureAlive = true ) + :TCSolarGuard( ) + ,OslMutexGuard( _rOwner.getMutex( AccessibleGridControlBase::TC_AccessControl() ) ) + { + if ( _bEnsureAlive ) + _rOwner.ensureIsAlive( AccessibleGridControlBase::TC_AccessControl() ); + } +}; + +// inlines -------------------------------------------------------------------- + +inline ::svt::table::AccessibleTableControlObjType AccessibleGridControlBase::getType() const +{ + return m_eObjType; +} + +inline ::osl::Mutex& AccessibleGridControlBase::getOslMutex() +{ + return m_aMutex; +} + +inline ::osl::Mutex* AccessibleGridControlBase::getOslGlobalMutex() +{ + return ::osl::Mutex::getGlobalMutex(); +} + +inline void AccessibleGridControlBase::implSetName( + const ::rtl::OUString& rName ) +{ + m_aName = rName; +} + +inline void AccessibleGridControlBase::implSetDescription( + const ::rtl::OUString& rDescription ) +{ + m_aDescription = rDescription; +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + +#endif // ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLBASE_HXX + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlHeader.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlHeader.hxx new file mode 100755 index 000000000000..f164e7576247 --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlHeader.hxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlHeader.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLHEADER_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLHEADER_HXX + + +#include "accessibility/extended/AccessibleGridControlHeaderCell.hxx" +#include "accessibility/extended/AccessibleGridControlTableBase.hxx" + +// ============================================================================ + +namespace accessibility { + +// ============================================================================ + +/** This class represents the accessible object of a header bar of a Grid Control + (row or column header bar). This object supports the + XAccessibleSelection interface. Selecting a child of this object selects + complete rows or columns of the data table. */ +class AccessibleGridControlHeader : public AccessibleGridControlTableBase +{ +public: + /** @param eObjType One of the two allowed types TCTYPE_ROWHEADERBAR or + TCTYPE_COLUMNHEADERBAR. */ + AccessibleGridControlHeader( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~AccessibleGridControlHeader(); + +public: + // XAccessibleContext ----------------------------------------------------- + + /** @return + The XAccessible interface of the specified child. + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The index of this object among the parent's children. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleComponent --------------------------------------------------- + + /** @return The accessible child rendered under the given point. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The key bindings associated with this object. */ + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleTable ------------------------------------------------------- + + /** @return The description text of the specified row. */ + virtual ::rtl::OUString SAL_CALL + getAccessibleRowDescription( sal_Int32 nRow ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The description text of the specified column. */ + virtual ::rtl::OUString SAL_CALL + getAccessibleColumnDescription( sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An index list of completely selected rows. */ + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An index list of completely selected columns. */ + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo ----------------------------------------------------------- + + /** @return The name of this class. */ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An unique implementation ID. */ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw ( ::com::sun::star::uno::RuntimeException ); + +protected: + // internal virtual methods ----------------------------------------------- + /** @attention This method requires locked mutex's and a living object. + @return The absolute child index from the index of selected children. + @throws <type>IndexOutOfBoundsException</type> + If the specified index is invalid. */ + //sal_Int32 implGetChildIndexFromSelectedIndex( sal_Int32 nSelectedChildIndex ) + // throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** Returns the specified row or column. Uses one of the parameters, + depending on object type. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified column/row. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + implGetChild( sal_Int32 nRow, sal_uInt32 nColumnPos ); + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual Rectangle implGetBoundingBox(); + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual Rectangle implGetBoundingBoxOnScreen(); + + /** @attention This method requires locked mutex's and a living object. + @return The count of used rows. */ + virtual sal_Int32 implGetRowCount() const; + /** @attention This method requires locked mutex's and a living object. + @return The count of used columns. */ + virtual sal_Int32 implGetColumnCount() const; + + // internal helper methods ------------------------------------------------ + + /** @return <TRUE/>, if the objects is a header bar for rows. */ + inline sal_Bool isRowBar() const; + /** @return <TRUE/>, if the objects is a header bar for columns. */ + inline sal_Bool isColumnBar() const; + + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified row/column index (depending on type) is invalid. */ + void ensureIsValidHeaderIndex( sal_Int32 nIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); +}; + +// inlines -------------------------------------------------------------------- + +inline sal_Bool AccessibleGridControlHeader::isRowBar() const +{ + return getType() == ::svt::table::TCTYPE_ROWHEADERBAR; +} + +inline sal_Bool AccessibleGridControlHeader::isColumnBar() const +{ + return getType() == ::svt::table::TCTYPE_COLUMNHEADERBAR; +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + +#endif // ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLHEADER_HXX + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlHeaderCell.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlHeaderCell.hxx new file mode 100755 index 000000000000..3827cc7dad0a --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlHeaderCell.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlHeaderCell.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLHEADERCELL_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLHEADERCELL_HXX + +#include "accessibility/extended/AccessibleGridControlTableCell.hxx" + +namespace accessibility +{ + class AccessibleGridControlHeaderCell : public AccessibleGridControlCell, public ::com::sun::star::accessibility::XAccessible + { + sal_Int32 m_nColumnRowId; + public: + AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId, + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& _rTable, + ::svt::table::AccessibleTableControlObjType _eObjType); + /** @return The count of visible children. */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessible interface of the specified child. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 nChildIndex ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException ); + + /** @return The index of this object among the parent's children. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw ( ::com::sun::star::uno::RuntimeException ); + + /** Grabs the focus to the GridControl. */ + virtual void SAL_CALL grabFocus() throw ( ::com::sun::star::uno::RuntimeException ); + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Aquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() throw (); + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() throw (); + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() + throw ( ::com::sun::star::uno::RuntimeException ); + //------------------------------------------------------------------------- + inline sal_Bool isRowBarCell() const + { + return getType() == ::svt::table::TCTYPE_ROWHEADERCELL; + } + + /** @return + The name of this class. + */ + virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( ::com::sun::star::uno::RuntimeException ); + + /** Creates a new AccessibleStateSetHelper and fills it with states of the + current object. + @return + A filled AccessibleStateSetHelper. + */ + ::utl::AccessibleStateSetHelper* implCreateStateSetHelper(); + + protected: + virtual Rectangle implGetBoundingBox(); + + virtual Rectangle implGetBoundingBoxOnScreen(); + private: + ::rtl::OUString m_sHeaderName; + }; +} + +#endif // ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLHEADERCELL_HXX + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlTable.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlTable.hxx new file mode 100755 index 000000000000..c3465c6c32fb --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlTable.hxx @@ -0,0 +1,236 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTable.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLTABLE_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLTABLE_HXX + +#include "accessibility/extended/AccessibleGridControlTableBase.hxx" +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> + +// ============================================================================ + +namespace accessibility { + +// ============================================================================ +typedef ::cppu::ImplHelper1< + ::com::sun::star::accessibility::XAccessibleSelection > + AccessibleGridControlTableImplHelper1; +/** This class represents the accessible object of the data table of a + Grid control. */ +class AccessibleGridControlTable : public AccessibleGridControlTableBase, + public AccessibleGridControlTableImplHelper1 +{ +public: + AccessibleGridControlTable( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType _eType); + +protected: + virtual ~AccessibleGridControlTable(); + +public: + // XAccessibleContext ----------------------------------------------------- + + /** @return The XAccessible interface of the specified child. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The index of this object among the parent's children. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleComponent --------------------------------------------------- + + /** @return The accessible child rendered under the given point. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The key bindings associated with this object. */ + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleTable ------------------------------------------------------- + + /** @return The description text of the specified row. */ + virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The description text of the specified column. */ + virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An index list of completely selected rows. */ + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An index list of completely selected columns. */ + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + // XAccessibleSelection --------------------------------------------------- + + /** Selects the specified child (row or column of the table). */ + virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return <TRUE/>, if the specified child (row/column) is selected. */ + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** Clears the complete selection. */ + virtual void SAL_CALL clearAccessibleSelection() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Selects all children or first, if multiselection is not supported. */ + virtual void SAL_CALL selectAllAccessibleChildren() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The number of selected rows/columns. */ + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The specified selected row/column. */ + 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 ); + + /** Removes the specified row/column from the selection. */ + virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Aquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() throw (); + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() throw (); + // XServiceInfo ----------------------------------------------------------- + + /** @return The name of this class. */ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ); + +protected: + // internal virtual methods ----------------------------------------------- + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual Rectangle implGetBoundingBox(); + ///** @attention This method requires locked mutex's and a living object. + // @return The bounding box (VCL rect.) in screen coordinates. */ + virtual Rectangle implGetBoundingBoxOnScreen(); + + + //// internal helper methods ------------------------------------------------ + /** Returns the specified row or column. Uses one of the parameters, + depending on object type. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified column/row. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + implGetChild( sal_Int32 nRow, sal_uInt16 nColumnPos ); + ///** @attention This method requires a locked mutex. + // @return The XAccessibleTable interface of the specified header bar. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleTable > + implGetHeaderBar( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::uno::RuntimeException ); +}; + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + +#endif // ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLTABLE_HXX + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlTableBase.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlTableBase.hxx new file mode 100755 index 000000000000..aa9eb061f147 --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlTableBase.hxx @@ -0,0 +1,247 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTableBase.hxx,v $ + * $Revision: 1.3 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLTABLEBASE_HXX +#define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROLTABLEBASE_HXX + +#include "accessibility/extended/AccessibleGridControlBase.hxx" +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> + +// ============================================================================ + +namespace accessibility { + +typedef ::cppu::ImplHelper1< + ::com::sun::star::accessibility::XAccessibleTable > + AccessibleGridControlTableImplHelper; + +/** The Grid Control accessible table objects inherit from this base class. It + implements basic functionality for the XAccessibleTable interface. + Grid COntrol table objects are: the data table, the column header bar and the + row header bar. */ +class AccessibleGridControlTableBase : + public GridControlAccessibleElement, + public AccessibleGridControlTableImplHelper +{ +public: + /** Constructor sets specified name and description. + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eNameText The constant for the name text. + @param eDescrText The constant for the description text. */ + AccessibleGridControlTableBase( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~AccessibleGridControlTableBase(); + +public: + // XAccessibleContext ----------------------------------------------------- + + /** @return The count of visible children. */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The role of this object (a table). */ + virtual sal_Int16 SAL_CALL getAccessibleRole() + throw ( ::com::sun::star::uno::RuntimeException ); + + /* Derived classes have to implement: + - getAccessibleChild, + - getAccessibleIndexInParent. */ + + // XAccessibleComponent --------------------------------------------------- + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus, + - getAccessibleKeyBinding. */ + + // XAccessibleTable ------------------------------------------------------- + + /** @return The number of used rows in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleRowCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The number of used columns in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleColumnCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The row extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The column extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The caption cell of the table (not supported). */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleCaption() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The summary object of the table (not supported). */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleSummary() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return The child index of the specified cell. */ + virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The row index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** @return The column index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /* Derived classes have to implement: + - getAccessibleRowDescription, + - getAccessibleColumnDescription, + - getAccessibleRowHeaders, + - getAccessibleColumnHeaders, + - getSelectedAccessibleRows, + - getSelectedAccessibleColumns, + - isAccessibleRowSelected, + - isAccessibleColumnSelected, + - getAccessibleCellAt, + - isAccessibleSelected. */ + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Aquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() throw (); + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() throw (); + + // XTypeProvider ---------------------------------------------------------- + + /** @return A sequence of possible types (received from base classes). */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return An unique implementation ID. */ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw ( ::com::sun::star::uno::RuntimeException ); + +protected: + // internal helper methods ------------------------------------------------ + + /** @attention This method requires locked mutex's and a living object. + @param nColumn + the position of the column in the Accessible world + @return + the position of the column in VCL the Accessible world + */ + sal_uInt16 implToVCLColumnPos( sal_Int32 nColumn ) const; + + /** @attention This method requires locked mutex's and a living object. + @return The number of cells of the table. */ + sal_Int32 implGetChildCount() const; + + /** @attention This method requires locked mutex's and a living object. + @return The row index of the specified cell index. */ + sal_Int32 implGetRow( sal_Int32 nChildIndex ) const; + /** @attention This method requires locked mutex's and a living object. + @return The column index of the specified cell index. */ + sal_Int32 implGetColumn( sal_Int32 nChildIndex ) const; + /** @attention This method requires locked mutex's and a living object. + @return The child index of the specified cell address. */ + sal_Int32 implGetChildIndex( sal_Int32 nRow, sal_Int32 nColumn ) const; + + /** @attention This method requires locked mutex's and a living object. + @return <TRUE/>, if the specified row is selected. */ + sal_Bool implIsRowSelected( sal_Int32 nRow ) const; + + /** @attention This method requires locked mutex's and a living object. + @return The count of selected rows. */ + sal_Int32 implGetSelectedRowCount() const; + + /** Fills a sequence with sorted indexes of completely selected rows. + @attention This method requires locked mutex's and a living object. + @param rSeq Out-parameter that takes the sorted row index list. */ + void implGetSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& rSeq ); + /** Fills a sequence with sorted indexes of completely selected columns. + @attention This method requires locked mutex's and a living object. + @param rSeq Out-parameter that takes the sorted column index list. */ + //void implGetSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& rSeq ); + + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified row index is invalid. */ + void ensureIsValidRow( sal_Int32 nRow ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified column index is invalid. */ + void ensureIsValidColumn( sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified cell address is invalid. */ + void ensureIsValidAddress( sal_Int32 nRow, sal_Int32 nColumn ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified child index is invalid. */ + void ensureIsValidIndex( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); +}; + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + +#endif // ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLTABLEBASE_HXX + diff --git a/accessibility/inc/accessibility/extended/AccessibleGridControlTableCell.hxx b/accessibility/inc/accessibility/extended/AccessibleGridControlTableCell.hxx new file mode 100755 index 000000000000..537cbc138b1c --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleGridControlTableCell.hxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTableCell.hxx,v $ + * $Revision: 1.4 $ + * + * 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 ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLTABLECELL_HXX +#define ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLTABLECELL_HXX + +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase2.hxx> +#include "accessibility/extended/AccessibleGridControlBase.hxx" +#include <svtools/accessibletable.hxx> + +namespace accessibility +{ + class AccessibleGridControlCell : public AccessibleGridControlBase + { + private: + sal_Int32 m_nRowPos; // the row number of the table cell + sal_Int32 m_nColPos; // the column id of the table cell + + protected: + // attribute access + inline sal_Int32 getRowPos( ) const { return m_nRowPos; } + inline sal_Int32 getColumnPos( ) const { return m_nColPos; } + + // XAccessibleComponent + virtual void SAL_CALL grabFocus() throw ( ::com::sun::star::uno::RuntimeException ); + + protected: + AccessibleGridControlCell( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + ::svt::table::IAccessibleTable& _rTable, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + ::svt::table::AccessibleTableControlObjType _eType + ); + + virtual ~AccessibleGridControlCell(); + + private: + AccessibleGridControlCell(); // never implemented + AccessibleGridControlCell( const AccessibleGridControlCell& ); // never implemented + AccessibleGridControlCell& operator=( const AccessibleGridControlCell& ); // never implemented + }; + + typedef ::cppu::ImplHelper2 < ::com::sun::star::accessibility::XAccessibleText + , ::com::sun::star::accessibility::XAccessible + > AccessibleTextHelper_BASE; + // implementation of a table cell of GridControl + class AccessibleGridControlTableCell :public AccessibleGridControlCell + ,public AccessibleTextHelper_BASE + ,public ::comphelper::OCommonAccessibleText + { + private: + sal_Int32 m_nOffset; + + protected: + // OCommonAccessibleText + virtual ::rtl::OUString implGetText(); + virtual ::com::sun::star::lang::Locale implGetLocale(); + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ); + virtual Rectangle implGetBoundingBox(); + virtual Rectangle implGetBoundingBoxOnScreen(); + + public: + AccessibleGridControlTableCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + ::svt::table::IAccessibleTable& _rTable, + sal_Int32 _nRowId, + sal_uInt16 _nColId, + svt::table::AccessibleTableControlObjType eObjType); + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ); + + /** Aquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() throw (); + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() throw (); + + /** @return The index of this object among the parent's children. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The name of this class. + */ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The count of visible children. + */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** @return + The XAccessible interface of the specified child. + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + /** Creates a new AccessibleStateSetHelper and fills it with states of the + current object. + @return + A filled AccessibleStateSetHelper. + */ + ::utl::AccessibleStateSetHelper* implCreateStateSetHelper(); + + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() + throw ( ::com::sun::star::uno::RuntimeException ); + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getCharacterCount() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getIndexAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSelectedText() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectionStart() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectionEnd() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // ACCESSIBILITY_EXT_ACCESSIBILEGRIDCONTROLTABLECELL_HXX + diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx new file mode 100755 index 000000000000..fd24a3f27aa1 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControl.cxx @@ -0,0 +1,391 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControl.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" +#include "accessibility/extended/AccessibleGridControl.hxx" +#include "accessibility/extended/AccessibleGridControlTable.hxx" +#include "accessibility/extended/AccessibleGridControlHeader.hxx" +#include <svtools/accessibletable.hxx> +#include <comphelper/types.hxx> +#include <toolkit/helper/vclunohelper.hxx> +//#include "svtools/table/tablecontrol.hxx" + +// ============================================================================ + +namespace accessibility +{ + +// ============================================================================ + +using ::rtl::OUString; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; +using namespace ::svt; +using namespace ::svt::table; + +// ============================================================================ +class AccessibleGridControl_Impl +{ +public: + /// the XAccessible which created the AccessibleGridControl + WeakReference< XAccessible > m_aCreator; + + /** The data table child. */ + Reference< + ::com::sun::star::accessibility::XAccessible > m_xTable; + AccessibleGridControlTable* m_pTable; + + /** The header bar for rows. */ + Reference< + ::com::sun::star::accessibility::XAccessible > m_xRowHeaderBar; + AccessibleGridControlHeader* m_pRowHeaderBar; + + /** The header bar for columns (first row of the table). */ + Reference< + ::com::sun::star::accessibility::XAccessible > m_xColumnHeaderBar; + AccessibleGridControlHeader* m_pColumnHeaderBar; +}; + +// Ctor/Dtor/disposing -------------------------------------------------------- + +DBG_NAME( AccessibleGridControl ) + +AccessibleGridControl::AccessibleGridControl( + const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxCreator, + IAccessibleTable& _rTable ) + : AccessibleGridControlBase( _rxParent, _rTable, TCTYPE_GRIDCONTROL ) +{ +// DBG_CTOR( AccessibleTableControl, NULL ); + m_pImpl.reset( new AccessibleGridControl_Impl() ); + m_pImpl->m_aCreator = _rxCreator; +} +// ----------------------------------------------------------------------------- +void AccessibleGridControl::setCreator( const Reference< XAccessible >& _rxCreator ) +{ +#if OSL_DEBUG_LEVEL > 0 + Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator; + DBG_ASSERT( !xCreator.is(), "accessibility/extended/AccessibleGridControl::setCreator: creator already set!" ); +#endif + m_pImpl->m_aCreator = _rxCreator; +} + +// ----------------------------------------------------------------------------- +AccessibleGridControl::~AccessibleGridControl() +{ + DBG_DTOR( AccessibleGridControl, NULL ); +} +// ----------------------------------------------------------------------------- + +void SAL_CALL AccessibleGridControl::disposing() +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + + m_pImpl->m_pTable = NULL; + m_pImpl->m_pColumnHeaderBar = NULL; + m_pImpl->m_pRowHeaderBar = NULL; + m_pImpl->m_aCreator = Reference< XAccessible >(); + + Reference< XAccessible > xTable = m_pImpl->m_xTable; + + Reference< XComponent > xComp( m_pImpl->m_xTable, UNO_QUERY ); + if ( xComp.is() ) + { + xComp->dispose(); + } + + AccessibleGridControlBase::disposing(); +} +// ----------------------------------------------------------------------------- + +// XAccessibleContext --------------------------------------------------------- + +sal_Int32 SAL_CALL AccessibleGridControl::getAccessibleChildCount() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_aTable.GetAccessibleControlCount(); +} +// ----------------------------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControl::getAccessibleChild( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount()) + throw IndexOutOfBoundsException(); + + Reference< XAccessible > xChild; + if (isAlive()) + { + if(nChildIndex == 0 && m_aTable.HasColHeader()) + { + if(!m_pImpl->m_xColumnHeaderBar.is()){ + AccessibleGridControlHeader* pColHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_COLUMNHEADERBAR); + m_pImpl->m_xColumnHeaderBar = pColHeaderBar; + } + xChild = m_pImpl->m_xColumnHeaderBar; + } + else if(m_aTable.HasRowHeader() && (nChildIndex == 1 || nChildIndex == 0)) + { + if(!m_pImpl->m_xRowHeaderBar.is()){ + AccessibleGridControlHeader* pRowHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_ROWHEADERBAR); + m_pImpl->m_xRowHeaderBar = pRowHeaderBar; + } + xChild = m_pImpl->m_xRowHeaderBar; + } + else + { + AccessibleGridControlTable* pTable = new AccessibleGridControlTable(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_TABLE); + m_pImpl->m_xTable = pTable; + xChild = m_pImpl->m_xTable; + } + } + + return xChild; +} +// ----------------------------------------------------------------------------- + +sal_Int16 SAL_CALL AccessibleGridControl::getAccessibleRole() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return AccessibleRole::PANEL; +} +// ----------------------------------------------------------------------------- + +// XAccessibleComponent ------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControl::getAccessibleAtPoint( const awt::Point& rPoint ) + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + Reference< XAccessible > xChild; + sal_Int32 nIndex = 0; + if( m_aTable.ConvertPointToControlIndex( nIndex, VCLPoint( rPoint ) ) ) + xChild = m_aTable.CreateAccessibleControl( nIndex ); + else + { + // try whether point is in one of the fixed children + // (table, header bars, corner control) + Point aPoint( VCLPoint( rPoint ) ); + for( nIndex = 0; (nIndex < 3) && !xChild.is(); ++nIndex ) + { + Reference< XAccessible > xCurrChild( implGetFixedChild( nIndex ) ); + Reference< XAccessibleComponent > + xCurrChildComp( xCurrChild, uno::UNO_QUERY ); + + if( xCurrChildComp.is() && + VCLRectangle( xCurrChildComp->getBounds() ).IsInside( aPoint ) ) + xChild = xCurrChild; + } + } + return xChild; +} +// ----------------------------------------------------------------------------- + +void SAL_CALL AccessibleGridControl::grabFocus() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + m_aTable.GrabFocus(); +} +// ----------------------------------------------------------------------------- + +Any SAL_CALL AccessibleGridControl::getAccessibleKeyBinding() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return Any(); +} +// ----------------------------------------------------------------------------- + +// XServiceInfo --------------------------------------------------------------- + +OUString SAL_CALL AccessibleGridControl::getImplementationName() + throw ( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControl" ) ); +} +// ----------------------------------------------------------------------------- + +// internal virtual methods --------------------------------------------------- + +Rectangle AccessibleGridControl::implGetBoundingBox() +{ + Window* pParent = m_aTable.GetAccessibleParentWindow(); + DBG_ASSERT( pParent, "implGetBoundingBox - missing parent window" ); + return m_aTable.GetWindowExtentsRelative( pParent ); +} +// ----------------------------------------------------------------------------- + +Rectangle AccessibleGridControl::implGetBoundingBoxOnScreen() +{ + return m_aTable.GetWindowExtentsRelative( NULL ); +} +// internal helper methods ---------------------------------------------------- + +Reference< XAccessible > AccessibleGridControl::implGetTable() +{ + if( !m_pImpl->m_xTable.is() ) + { + m_pImpl->m_pTable = createAccessibleTable(); + m_pImpl->m_xTable = m_pImpl->m_pTable; + + } + return m_pImpl->m_xTable; +} +// ----------------------------------------------------------------------------- + +Reference< XAccessible > +AccessibleGridControl::implGetHeaderBar( AccessibleTableControlObjType eObjType ) +{ + Reference< XAccessible > xRet; + Reference< XAccessible >* pxMember = NULL; + + if( eObjType == TCTYPE_ROWHEADERBAR ) + pxMember = &m_pImpl->m_xRowHeaderBar; + else if( eObjType == TCTYPE_COLUMNHEADERBAR ) + pxMember = &m_pImpl->m_xColumnHeaderBar; + + if( pxMember ) + { + if( !pxMember->is() ) + { + AccessibleGridControlHeader* pHeaderBar = new AccessibleGridControlHeader( + (Reference< XAccessible >)m_pImpl->m_aCreator, m_aTable, eObjType ); + + if ( TCTYPE_COLUMNHEADERBAR == eObjType) + m_pImpl->m_pColumnHeaderBar = pHeaderBar; + else + m_pImpl->m_pRowHeaderBar = pHeaderBar; + + *pxMember = pHeaderBar; + } + xRet = *pxMember; + } + return xRet; +} +// ----------------------------------------------------------------------------- +Reference< XAccessible > +AccessibleGridControl::implGetFixedChild( sal_Int32 nChildIndex ) +{ + Reference< XAccessible > xRet; + switch( nChildIndex ) + { + case TCINDEX_COLUMNHEADERBAR: + xRet = implGetHeaderBar( TCTYPE_COLUMNHEADERBAR ); + break; + case TCINDEX_ROWHEADERBAR: + xRet = implGetHeaderBar( TCTYPE_ROWHEADERBAR ); + break; + case TCINDEX_TABLE: + xRet = implGetTable(); + break; + } + return xRet; +} +// ----------------------------------------------------------------------------- +AccessibleGridControlTable* AccessibleGridControl::createAccessibleTable() +{ + Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator; + DBG_ASSERT( xCreator.is(), "accessibility/extended/AccessibleGirdControl::createAccessibleTable: my creator died - how this?" ); + return new AccessibleGridControlTable( xCreator, m_aTable, TCTYPE_TABLE ); +} +// ============================================================================ +// = AccessibleGridControlAccess +// ============================================================================ +DBG_NAME( AccessibleGridControlAccess ) +// ----------------------------------------------------------------------------- +AccessibleGridControlAccess::AccessibleGridControlAccess( const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable ) + :m_xParent( _rxParent ) + ,m_rTable( _rTable ) + ,m_pContext( NULL ) +{ + DBG_CTOR( AccessibleGridControlAccess, NULL ); +} + +// ----------------------------------------------------------------------------- +AccessibleGridControlAccess::~AccessibleGridControlAccess() +{ + DBG_DTOR( AccessibleGridControlAccess, NULL ); +} + +// ----------------------------------------------------------------------------- +void AccessibleGridControlAccess::dispose() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + m_pContext = NULL; + ::comphelper::disposeComponent( m_xContext ); +} + +// ----------------------------------------------------------------------------- +Reference< XAccessibleContext > SAL_CALL AccessibleGridControlAccess::getAccessibleContext() throw ( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + DBG_ASSERT( ( m_pContext && m_xContext.is() ) || ( !m_pContext && !m_xContext.is() ), + "accessibility/extended/AccessibleGridControlAccess::getAccessibleContext: inconsistency!" ); + + // if the context died meanwhile (we're no listener, so it won't tell us explicitily when this happens), + // then reset an re-create. + if ( m_pContext && !m_pContext->isAlive() ) + m_xContext = m_pContext = NULL; + + if ( !m_xContext.is() ) + m_xContext = m_pContext = new AccessibleGridControl( m_xParent, this, m_rTable ); + + return m_xContext; +} + +// ----------------------------------------------------------------------------- +bool AccessibleGridControlAccess::isContextAlive() const +{ + return ( NULL != m_pContext ) && m_pContext->isAlive(); +} + +// ============================================================================ + +} // namespace accessibility diff --git a/accessibility/source/extended/AccessibleGridControlBase.cxx b/accessibility/source/extended/AccessibleGridControlBase.cxx new file mode 100755 index 000000000000..91dd9bd3bdc5 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlBase.cxx @@ -0,0 +1,551 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlBase.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" +#include "accessibility/extended/AccessibleGridControlBase.hxx" +#include <svtools/accessibletable.hxx> +#include <rtl/uuid.h> +// +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <unotools/accessiblerelationsethelper.hxx> + +// ============================================================================ + +using ::rtl::OUString; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; +using namespace ::comphelper; +using namespace ::svt; +using namespace ::svt::table; + + +// ============================================================================ + +namespace accessibility { + +using namespace com::sun::star::accessibility::AccessibleStateType; +// ============================================================================ + +// Ctor/Dtor/disposing -------------------------------------------------------- + +DBG_NAME( AccessibleGridControlBase ) + +AccessibleGridControlBase::AccessibleGridControlBase( + const Reference< XAccessible >& rxParent, + svt::table::IAccessibleTable& rTable, + AccessibleTableControlObjType eObjType ) : + AccessibleGridControlImplHelper( m_aMutex ), + m_xParent( rxParent ), + m_aTable( rTable), + m_eObjType( eObjType ), + m_aName( rTable.GetAccessibleObjectName( eObjType, 0, 0 ) ), + m_aDescription( rTable.GetAccessibleObjectDescription( eObjType ) ), + m_aClientId(0) +{ + DBG_CTOR( AccessibleGridControlBase, NULL ); +} + +AccessibleGridControlBase::~AccessibleGridControlBase() +{ +// DBG_DTOR( AccessibleGridControlBase, NULL ); + + if( isAlive() ) + { + // increment ref count to prevent double call of Dtor + osl_incrementInterlockedCount( &m_refCount ); + dispose(); + } +} + +void SAL_CALL AccessibleGridControlBase::disposing() +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + m_xParent = NULL; +} + +// XAccessibleContext --------------------------------------------------------- + +Reference< XAccessible > SAL_CALL AccessibleGridControlBase::getAccessibleParent() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_xParent; +} + +sal_Int32 SAL_CALL AccessibleGridControlBase::getAccessibleIndexInParent() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + // -1 for child not found/no parent (according to specification) + sal_Int32 nRet = -1; + + Reference< uno::XInterface > xMeMyselfAndI( static_cast< XAccessibleContext* >( this ), uno::UNO_QUERY ); + + // iterate over parent's children and search for this object + if( m_xParent.is() ) + { + Reference< XAccessibleContext > + xParentContext( m_xParent->getAccessibleContext() ); + if( xParentContext.is() ) + { + Reference< uno::XInterface > xChild; + + sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); + for( sal_Int32 nChild = 0; nChild < nChildCount; ++nChild ) + { + xChild = xChild.query( xParentContext->getAccessibleChild( nChild ) ); + + if ( xMeMyselfAndI.get() == xChild.get() ) + { + nRet = nChild; + break; + } + } + } + } + return nRet; +} + +OUString SAL_CALL AccessibleGridControlBase::getAccessibleDescription() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_aDescription; +} + +OUString SAL_CALL AccessibleGridControlBase::getAccessibleName() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_aName; +} + +Reference< XAccessibleRelationSet > SAL_CALL +AccessibleGridControlBase::getAccessibleRelationSet() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + // GridControl does not have relations. + return new utl::AccessibleRelationSetHelper; +} + +Reference< XAccessibleStateSet > SAL_CALL +AccessibleGridControlBase::getAccessibleStateSet() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + // don't check whether alive -> StateSet may contain DEFUNC + return implCreateStateSetHelper(); +} + +lang::Locale SAL_CALL AccessibleGridControlBase::getLocale() + throw ( IllegalAccessibleComponentStateException, uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + if( m_xParent.is() ) + { + Reference< XAccessibleContext > + xParentContext( m_xParent->getAccessibleContext() ); + if( xParentContext.is() ) + return xParentContext->getLocale(); + } + throw IllegalAccessibleComponentStateException(); +} + +// XAccessibleComponent ------------------------------------------------------- + +sal_Bool SAL_CALL AccessibleGridControlBase::containsPoint( const awt::Point& rPoint ) + throw ( uno::RuntimeException ) +{ + return Rectangle( Point(), getBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); +} + +awt::Rectangle SAL_CALL AccessibleGridControlBase::getBounds() + throw ( uno::RuntimeException ) +{ + return AWTRectangle( getBoundingBox() ); +} + +awt::Point SAL_CALL AccessibleGridControlBase::getLocation() + throw ( uno::RuntimeException ) +{ + return AWTPoint( getBoundingBox().TopLeft() ); +} + +awt::Point SAL_CALL AccessibleGridControlBase::getLocationOnScreen() + throw ( uno::RuntimeException ) +{ + return AWTPoint( getBoundingBoxOnScreen().TopLeft() ); +} + +awt::Size SAL_CALL AccessibleGridControlBase::getSize() + throw ( uno::RuntimeException ) +{ + return AWTSize( getBoundingBox().GetSize() ); +} + +sal_Bool SAL_CALL AccessibleGridControlBase::isShowing() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return implIsShowing(); +} + +sal_Bool SAL_CALL AccessibleGridControlBase::isVisible() + throw ( uno::RuntimeException ) +{ + Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet(); + return xStateSet.is() ? + xStateSet->contains( AccessibleStateType::VISIBLE ) : sal_False; +} + +sal_Bool SAL_CALL AccessibleGridControlBase::isFocusTraversable() + throw ( uno::RuntimeException ) +{ + Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet(); + return xStateSet.is() ? + xStateSet->contains( AccessibleStateType::FOCUSABLE ) : sal_False; +} +// XAccessibleEventBroadcaster ------------------------------------------------ + +void SAL_CALL AccessibleGridControlBase::addEventListener( + const Reference< XAccessibleEventListener>& _rxListener ) + throw ( uno::RuntimeException ) +{ + if ( _rxListener.is() ) + { + ::osl::MutexGuard aGuard( getOslMutex() ); + if ( !getClientId( ) ) + setClientId( AccessibleEventNotifier::registerClient( ) ); + + AccessibleEventNotifier::addEventListener( getClientId( ), _rxListener ); + } +} + +void SAL_CALL AccessibleGridControlBase::removeEventListener( + const Reference< XAccessibleEventListener>& _rxListener ) + throw ( uno::RuntimeException ) +{ + if( _rxListener.is() && getClientId( ) ) + { + ::osl::MutexGuard aGuard( getOslMutex() ); + sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + + AccessibleEventNotifier::TClientId nId( getClientId( ) ); + setClientId( 0 ); + AccessibleEventNotifier::revokeClient( nId ); + } + } +} + +// XTypeProvider -------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL AccessibleGridControlBase::getImplementationId() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslGlobalMutex() ); + static Sequence< sal_Int8 > aId; + implCreateUuid( aId ); + return aId; +} + +// XServiceInfo --------------------------------------------------------------- + +sal_Bool SAL_CALL AccessibleGridControlBase::supportsService( + const OUString& rServiceName ) + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + + Sequence< OUString > aSupportedServices( getSupportedServiceNames() ); + const OUString* pArrBegin = aSupportedServices.getConstArray(); + const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength(); + const OUString* pString = pArrBegin; + + for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString ) + ; + + return pString != pArrEnd; +} + +Sequence< OUString > SAL_CALL AccessibleGridControlBase::getSupportedServiceNames() + throw ( uno::RuntimeException ) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); + return Sequence< OUString >( &aServiceName, 1 ); +} +// internal virtual methods --------------------------------------------------- + +sal_Bool AccessibleGridControlBase::implIsShowing() +{ + sal_Bool bShowing = sal_False; + if( m_xParent.is() ) + { + Reference< XAccessibleComponent > + xParentComp( m_xParent->getAccessibleContext(), uno::UNO_QUERY ); + if( xParentComp.is() ) + bShowing = implGetBoundingBox().IsOver( + VCLRectangle( xParentComp->getBounds() ) ); + } + return bShowing; +} + +::utl::AccessibleStateSetHelper* AccessibleGridControlBase::implCreateStateSetHelper() +{ + ::utl::AccessibleStateSetHelper* + pStateSetHelper = new ::utl::AccessibleStateSetHelper; + + if( isAlive() ) + { + // SHOWING done with m_xParent + if( implIsShowing() ) + pStateSetHelper->AddState( AccessibleStateType::SHOWING ); + // GridControl fills StateSet with states depending on object type + m_aTable.FillAccessibleStateSet( *pStateSetHelper, getType() ); + } + else + pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + + return pStateSetHelper; +} + +// internal helper methods ---------------------------------------------------- + +sal_Bool AccessibleGridControlBase::isAlive() const +{ + return !rBHelper.bDisposed && !rBHelper.bInDispose && &m_aTable; +} + +void AccessibleGridControlBase::ensureIsAlive() const + throw ( lang::DisposedException ) +{ + if( !isAlive() ) + throw lang::DisposedException(); +} + +Rectangle AccessibleGridControlBase::getBoundingBox() + throw ( lang::DisposedException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + Rectangle aRect = implGetBoundingBox(); + if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() ) + { + DBG_ERRORFILE( "rectangle doesn't exist" ); + } + return aRect; +} +// +Rectangle AccessibleGridControlBase::getBoundingBoxOnScreen() + throw ( lang::DisposedException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + Rectangle aRect = implGetBoundingBoxOnScreen(); + if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() ) + { + DBG_ERRORFILE( "rectangle doesn't exist" ); + } + return aRect; +} + +void AccessibleGridControlBase::commitEvent( + sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) +{ + ::osl::ClearableMutexGuard aGuard( getOslMutex() ); + if ( !getClientId( ) ) + // if we don't have a client id for the notifier, then we don't have listeners, then + // we don't need to notify anything + return; + + // build an event object + AccessibleEventObject aEvent; + aEvent.Source = *this; + aEvent.EventId = _nEventId; + aEvent.OldValue = _rOldValue; + aEvent.NewValue = _rNewValue; + + // let the notifier handle this event + + AccessibleEventNotifier::addEvent( getClientId( ), aEvent ); +} +// ----------------------------------------------------------------------------- + +void AccessibleGridControlBase::implCreateUuid( Sequence< sal_Int8 >& rId ) +{ + if( !rId.hasElements() ) + { + rId.realloc( 16 ); + rtl_createUuid( reinterpret_cast< sal_uInt8* >( rId.getArray() ), 0, sal_True ); + } +} +// ----------------------------------------------------------------------------- +sal_Int16 SAL_CALL AccessibleGridControlBase::getAccessibleRole() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + sal_Int16 nRole = AccessibleRole::UNKNOWN; + switch ( m_eObjType ) + { + case TCTYPE_ROWHEADERCELL: + nRole = AccessibleRole::ROW_HEADER; + break; + case TCTYPE_COLUMNHEADERCELL: + nRole = AccessibleRole::COLUMN_HEADER; + break; + case TCTYPE_COLUMNHEADERBAR: + case TCTYPE_ROWHEADERBAR: + case TCTYPE_TABLE: + nRole = AccessibleRole::TABLE; + break; + case TCTYPE_TABLECELL: + nRole = AccessibleRole::TABLE_CELL; + break; + case TCTYPE_GRIDCONTROL: + nRole = AccessibleRole::PANEL; + break; + } + return nRole; +} +// ----------------------------------------------------------------------------- +Any SAL_CALL AccessibleGridControlBase::getAccessibleKeyBinding() + throw ( uno::RuntimeException ) +{ + return Any(); +} +// ----------------------------------------------------------------------------- +Reference<XAccessible > SAL_CALL AccessibleGridControlBase::getAccessibleAtPoint( const ::com::sun::star::awt::Point& ) + throw ( uno::RuntimeException ) +{ + return NULL; +} +//// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL AccessibleGridControlBase::getForeground( ) throw (::com::sun::star::uno::RuntimeException) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + sal_Int32 nColor = 0; + Window* pInst = m_aTable.GetWindowInstance(); + if ( pInst ) + { + if ( pInst->IsControlForeground() ) + nColor = pInst->GetControlForeground().GetColor(); + else + { + Font aFont; + if ( pInst->IsControlFont() ) + aFont = pInst->GetControlFont(); + else + aFont = pInst->GetFont(); + nColor = aFont.GetColor().GetColor(); + } + } + + return nColor; +} +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL AccessibleGridControlBase::getBackground( ) throw (::com::sun::star::uno::RuntimeException) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + sal_Int32 nColor = 0; + Window* pInst = m_aTable.GetWindowInstance(); + if ( pInst ) + { + if ( pInst->IsControlBackground() ) + nColor = pInst->GetControlBackground().GetColor(); + else + nColor = pInst->GetBackground().GetColor().GetColor(); + } + + return nColor; +} + +//// ============================================================================ +GridControlAccessibleElement::GridControlAccessibleElement( const Reference< XAccessible >& rxParent, + IAccessibleTable& rTable, + AccessibleTableControlObjType eObjType ) + :AccessibleGridControlBase( rxParent, rTable, eObjType ) +{ +// DBG_CTOR( GridControlAccessibleElement, NULL ); +} + +// XInterface ----------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2( GridControlAccessibleElement, AccessibleGridControlBase, GridControlAccessibleElement_Base) + +// XTypeProvider -------------------------------------------------------------- +IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridControlAccessibleElement, AccessibleGridControlBase, GridControlAccessibleElement_Base ) + +// XAccessible ---------------------------------------------------------------- + +Reference< XAccessibleContext > SAL_CALL GridControlAccessibleElement::getAccessibleContext() throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return this; +} +// ---------------------------------------------------------------------------- +GridControlAccessibleElement::~GridControlAccessibleElement( ) +{ +// DBG_DTOR( GridControlAccessibleElement, NULL ); +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + diff --git a/accessibility/source/extended/AccessibleGridControlHeader.cxx b/accessibility/source/extended/AccessibleGridControlHeader.cxx new file mode 100755 index 000000000000..d8cc7a11d202 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlHeader.cxx @@ -0,0 +1,321 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlHeader.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" + + +#include "accessibility/extended/AccessibleGridControlHeader.hxx" +#include "accessibility/extended/AccessibleGridControlHeaderCell.hxx" +#include "accessibility/extended/AccessibleGridControlTableCell.hxx" +#include <svtools/accessibletable.hxx> + + +// ============================================================================ + +using ::rtl::OUString; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; +using namespace ::svt; +using namespace ::svt::table; + +// ============================================================================ + +namespace accessibility { + +// ============================================================================ + +// Ctor/Dtor/disposing -------------------------------------------------------- + +DBG_NAME( AccessibleGridControlHeader ) + +AccessibleGridControlHeader::AccessibleGridControlHeader( + const Reference< XAccessible >& rxParent, + ::svt::table::IAccessibleTable& rTable, + ::svt::table::AccessibleTableControlObjType eObjType): + AccessibleGridControlTableBase( rxParent, rTable, eObjType ) +{ +// DBG_CTOR( AccessibleGridControlHeaderBar, NULL ); + + DBG_ASSERT( isRowBar() || isColumnBar(), + "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" ); +} + +AccessibleGridControlHeader::~AccessibleGridControlHeader() +{ +// DBG_DTOR( AccessibleGridControlHeader, NULL ); +} + +// XAccessibleContext --------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount()) + throw IndexOutOfBoundsException(); + ensureIsAlive(); + Reference< XAccessible > xChild; + if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR) + { + AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL); + xChild = pColHeaderCell; + } + else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR) + { + AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL); + xChild = pRowHeaderCell; + } + return xChild; +} + +sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader()) + return 1; + else + return 0; +} + +// XAccessibleComponent ------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint ) + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + sal_Int32 nRow = 0; + sal_Int32 nColumnPos = 0; + sal_Bool bConverted = isRowBar() ? + m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) : + m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ); + + return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >(); +} + +void SAL_CALL AccessibleGridControlHeader::grabFocus() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + // focus on header not supported +} + +Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return Any(); // no special key bindings for header +} + +// XAccessibleTable ----------------------------------------------------------- + +OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidRow( nRow ); + return OUString(); // no headers in headers +} + +OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidColumn( nColumn ); + return OUString(); // no headers in headers +} + +Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return NULL; // no headers in headers +} + +Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return NULL; // no headers in headers +} + +Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + Sequence< sal_Int32 > aSelSeq; + // row of column header bar not selectable + if( isRowBar() ) + implGetSelectedRows( aSelSeq ); + return aSelSeq; +} +//columns aren't selectable +Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns() + throw ( uno::RuntimeException ) +{ + return NULL; +} +//To Do - not yet implemented +sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 nRow ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidRow( nRow ); + //return isRowBar() ? implIsRowSelected( nRow ) : sal_False; + return sal_False; +} +//columns aren't selectable +sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + (void)nColumn; + return sal_False; +} + +Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return implGetChild( nRow, implToVCLColumnPos( nColumn ) ); +} +// TO DO - not implemented yet +sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return FALSE; + // return isRowBar() ? implIsRowSelected( nRow ) : implIsColumnSelected( nColumn ); +} + +// XServiceInfo --------------------------------------------------------------- + +OUString SAL_CALL AccessibleGridControlHeader::getImplementationName() + throw ( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeader" ) ); +} + +Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslGlobalMutex() ); + static Sequence< sal_Int8 > aId; + implCreateUuid( aId ); + return aId; +} + +// internal virtual methods --------------------------------------------------- + +Rectangle AccessibleGridControlHeader::implGetBoundingBox() +{ + return m_aTable.calcHeaderRect(isColumnBar()); +} + +Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen() +{ + return m_aTable.calcHeaderRect(isColumnBar()); +} + +sal_Int32 AccessibleGridControlHeader::implGetRowCount() const +{ + return 1; +} + +sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const +{ + return 1; +} + +// internal helper methods ---------------------------------------------------- + +Reference< XAccessible > AccessibleGridControlHeader::implGetChild( + sal_Int32 nRow, sal_uInt32 nColumnPos ) +{ + Reference< XAccessible > xChild; + if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR) + { + AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL); + xChild = pColHeaderCell; + } + else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR) + { + AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL); + xChild = pRowHeaderCell; + } + return xChild; +} + +void AccessibleGridControlHeader::ensureIsValidHeaderIndex( sal_Int32 nIndex ) + throw ( lang::IndexOutOfBoundsException ) +{ + if( isRowBar() ) + ensureIsValidRow( nIndex ); + else + ensureIsValidColumn( nIndex ); +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + diff --git a/accessibility/source/extended/AccessibleGridControlHeaderCell.cxx b/accessibility/source/extended/AccessibleGridControlHeaderCell.cxx new file mode 100755 index 000000000000..52139a694aef --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlHeaderCell.cxx @@ -0,0 +1,173 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlHeaderCell.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" + +#include "accessibility/extended/AccessibleGridControlHeaderCell.hxx" +#include <svtools/accessibletable.hxx> +#include "accessibility/extended/AccessibleGridControl.hxx" + +namespace accessibility +{ + using namespace ::com::sun::star::accessibility; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::uno; + using namespace ::svt; + using namespace ::svt::table; + +AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId, + const Reference< XAccessible >& rxParent, + IAccessibleTable& rTable, + AccessibleTableControlObjType eObjType) +: AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType) +, m_nColumnRowId(_nColumnRowId) +{ +} +/** Creates a new AccessibleStateSetHelper and fills it with states of the + current object. + @return + A filled AccessibleStateSetHelper. +*/ +::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper() +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ::utl::AccessibleStateSetHelper* + pStateSetHelper = new ::utl::AccessibleStateSetHelper; + + if( isAlive() ) + { + // SHOWING done with mxParent + if( implIsShowing() ) + pStateSetHelper->AddState( AccessibleStateType::SHOWING ); + + TCSolarGuard aSolarGuard; + pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); + pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); + pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); + pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); + + if ( m_aTable.IsRowSelected(m_nColumnRowId) ) + pStateSetHelper->AddState( AccessibleStateType::SELECTED ); + } + else + pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + + return pStateSetHelper; +} +// ----------------------------------------------------------------------------- +/** @return + The count of visible children. +*/ +sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount() + throw ( RuntimeException ) +{ + return 0; +} +// ----------------------------------------------------------------------------- + +/** @return + The XAccessible interface of the specified child. +*/ +Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 ) + throw ( IndexOutOfBoundsException,RuntimeException ) +{ + throw IndexOutOfBoundsException(); +} +// XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ) + { + Any aRet = AccessibleGridControlCell::queryInterface(rType); + return aRet; + } + + /** Aquires the object (calls acquire() on base class). */ + void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw () + { + AccessibleGridControlCell::acquire(); + } + + /** Releases the object (calls release() on base class). */ + void SAL_CALL AccessibleGridControlHeaderCell::release() throw () + { + AccessibleGridControlCell::release(); + } + /** @return The XAccessibleContext interface of this object. */ + Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException ) + { + ensureIsAlive(); + return this; + } + +// ----------------------------------------------------------------------------- + +/** Grabs the focus to the column header. */ +void SAL_CALL AccessibleGridControlHeaderCell::grabFocus() + throw ( ::com::sun::star::uno::RuntimeException ) +{ +} +// ----------------------------------------------------------------------------- +/** @return + The name of this class. +*/ +::rtl::OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" ) ); +} +// ----------------------------------------------------------------------------- +Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox() +{ + return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle +} +// ----------------------------------------------------------------------------- + +Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen() +{ + return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle +} +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent() + throw ( RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + sal_Int32 nIndex = m_nColumnRowId; + return nIndex; +} +// ----------------------------------------------------------------------------- +} // namespace accessibility +// ----------------------------------------------------------------------------- + + diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx new file mode 100755 index 000000000000..ba6c229e2dc5 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlTable.cxx @@ -0,0 +1,416 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTable.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" + + +#include "accessibility/extended/AccessibleGridControlTable.hxx" +#include "accessibility/extended/AccessibleGridControlTableCell.hxx" +#include <svtools/accessibletable.hxx> + +// ============================================================================ + +using ::rtl::OUString; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; +using namespace ::svt; +using namespace ::svt::table; +// ============================================================================ + +namespace accessibility { + +// ============================================================================ + +// Ctor/Dtor/disposing -------------------------------------------------------- + +DBG_NAME( AccessibleGridControlTable ) + +AccessibleGridControlTable::AccessibleGridControlTable( + const Reference< XAccessible >& rxParent, + IAccessibleTable& rTable, + AccessibleTableControlObjType _eType) : + AccessibleGridControlTableBase( rxParent, rTable, _eType ) +{ + DBG_CTOR( AccessibleGridControlTable, NULL ); +} + +AccessibleGridControlTable::~AccessibleGridControlTable() +{ + DBG_DTOR( AccessibleGridControlTable, NULL ); +} + +// XAccessibleContext --------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControlTable::getAccessibleChild( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidIndex( nChildIndex ); + return new AccessibleGridControlTableCell(this, m_aTable, nChildIndex/m_aTable.GetColumnCount(), nChildIndex%m_aTable.GetColumnCount(), TCTYPE_TABLECELL); +} + +sal_Int32 SAL_CALL AccessibleGridControlTable::getAccessibleIndexInParent() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + if(m_aTable.HasRowHeader() && m_aTable.HasColHeader()) + return 0; + else if((!m_aTable.HasRowHeader() && m_aTable.HasColHeader()) || (m_aTable.HasRowHeader() && !m_aTable.HasColHeader()) ) + return 1; + else + return 2; + +} + +// XAccessibleComponent ------------------------------------------------------- + +Reference< XAccessible > SAL_CALL +AccessibleGridControlTable::getAccessibleAtPoint( const awt::Point& rPoint ) + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + Reference< XAccessible > xChild; + sal_Int32 nRow = 0; + sal_Int32 nColumnPos = 0; + if( m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) ) + xChild = new AccessibleGridControlTableCell(this, m_aTable, nRow, nColumnPos, TCTYPE_TABLECELL); + + return xChild; +} + +void SAL_CALL AccessibleGridControlTable::grabFocus() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + m_aTable.GrabFocus(); +} + +Any SAL_CALL AccessibleGridControlTable::getAccessibleKeyBinding() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return Any(); // no special key bindings for data table +} + +// XAccessibleTable ----------------------------------------------------------- + +OUString SAL_CALL AccessibleGridControlTable::getAccessibleRowDescription( sal_Int32 nRow ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidRow( nRow ); + return m_aTable.GetRowDescription( nRow ); +} + +OUString SAL_CALL AccessibleGridControlTable::getAccessibleColumnDescription( sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidColumn( nColumn ); + return m_aTable.GetColumnDescription( (sal_uInt16)nColumn ); +} + +Reference< XAccessibleTable > SAL_CALL AccessibleGridControlTable::getAccessibleRowHeaders() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + if(m_aTable.HasColHeader()) + return implGetHeaderBar( 1 ); + else + return implGetHeaderBar( 0 ); +} + +Reference< XAccessibleTable > SAL_CALL AccessibleGridControlTable::getAccessibleColumnHeaders() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return implGetHeaderBar( 0 ); +} + +Sequence< sal_Int32 > SAL_CALL AccessibleGridControlTable::getSelectedAccessibleRows() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + Sequence< sal_Int32 > aSelSeq; + implGetSelectedRows( aSelSeq ); + return aSelSeq; +} + +//columns aren't selectable +Sequence< sal_Int32 > SAL_CALL AccessibleGridControlTable::getSelectedAccessibleColumns() + throw ( uno::RuntimeException ) +{ +// TCSolarGuard aSolarGuard; +// ::osl::MutexGuard aGuard( getOslMutex() ); +// ensureIsAlive(); +// +// Sequence< sal_Int32 > aSelSeq; +// implGetSelectedColumns( aSelSeq ); +// return aSelSeq; + return NULL; +} + +//To Do: not implemented yet +sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleRowSelected( sal_Int32 nRow ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + //TCSolarGuard aSolarGuard; + //::osl::MutexGuard aGuard( getOslMutex() ); + //ensureIsAlive(); + //ensureIsValidRow( nRow ); + //return implIsRowSelected( nRow ); + (void) nRow; + return sal_False; +} + +//columns aren't selectable +sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleColumnSelected( sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + /*TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidColumn( nColumn ); + return implIsColumnSelected( nColumn );*/ + (void) nColumn; + return sal_False; +} + +Reference< XAccessible > SAL_CALL AccessibleGridControlTable::getAccessibleCellAt( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return new AccessibleGridControlTableCell(this, m_aTable, nRow, nColumn, TCTYPE_TABLECELL); +} + +sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleSelected( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + /*TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );*/ + (void) nRow; + (void) nColumn; + return sal_False; +} +//To Do: not implemented yet +void SAL_CALL AccessibleGridControlTable::selectAccessibleChild( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidIndex( nChildIndex ); + //if( isRowBar() ) + // implSelectRow( nChildIndex, sal_True ); + //else + // implSelectColumn( implToVCLColumnPos( nChildIndex ), sal_True ); +} +//To Do - not implemented yet +sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleChildSelected( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + // using interface methods - no mutex + /*return isRowBar() ? + isAccessibleRowSelected( nChildIndex ) : + isAccessibleColumnSelected( nChildIndex );*/ + (void)nChildIndex; + return FALSE; +} +//To Do - not implemented yet +void SAL_CALL AccessibleGridControlTable::clearAccessibleSelection() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); +} +//To Do - not implemented yet +void SAL_CALL AccessibleGridControlTable::selectAllAccessibleChildren() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); +} +//To Do - not implemented yet +sal_Int32 SAL_CALL AccessibleGridControlTable::getSelectedAccessibleChildCount() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + // return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount(); + return 0; +} +//To Do - not implemented yet +Reference< XAccessible > SAL_CALL +AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + (void)nSelectedChildIndex; + // method may throw lang::IndexOutOfBoundsException + //sal_Int32 nIndex = implGetChildIndexFromSelectedIndex( nSelectedChildIndex ); + //return implGetChild( nIndex, implToVCLColumnPos( nIndex ) ); + return NULL; +} +//To Do - not implemented yet +void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + (void)nSelectedChildIndex; + // method may throw lang::IndexOutOfBoundsException + //if ( isAccessibleChildSelected(nSelectedChildIndex) ) + //{ + // if( isRowBar() ) + // implSelectRow( nSelectedChildIndex, sal_False ); + // else + // implSelectColumn( implToVCLColumnPos( nSelectedChildIndex ), sal_False ); + //} +} +// XInterface ----------------------------------------------------------------- + +Any SAL_CALL AccessibleGridControlTable::queryInterface( const uno::Type& rType ) + throw ( uno::RuntimeException ) +{ + Any aAny( AccessibleGridControlTableBase::queryInterface( rType ) ); + return aAny.hasValue() ? + aAny : AccessibleGridControlTableImplHelper1::queryInterface( rType ); +} + +void SAL_CALL AccessibleGridControlTable::acquire() throw () +{ + AccessibleGridControlTableBase::acquire(); +} + +void SAL_CALL AccessibleGridControlTable::release() throw () +{ + AccessibleGridControlTableBase::release(); +} +// XServiceInfo --------------------------------------------------------------- + +OUString SAL_CALL AccessibleGridControlTable::getImplementationName() + throw ( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlTable" ) ); +} + +// internal virtual methods --------------------------------------------------- + +Rectangle AccessibleGridControlTable::implGetBoundingBox() +{ + return m_aTable.calcTableRect(); +} + +Rectangle AccessibleGridControlTable::implGetBoundingBoxOnScreen() +{ + return m_aTable.calcTableRect(); +} +// internal helper methods ---------------------------------------------------- + +Reference< XAccessible > AccessibleGridControlTable::implGetChild( + sal_Int32 nRow, sal_uInt16 nColumnPos ) +{ + (void)nRow; + (void)nColumnPos; + return NULL; +} +//To Do - not implemented yet +//sal_Int32 AccessibleGridControlTable::implGetChildIndexFromSelectedIndex( +// sal_Int32 nSelectedChildIndex ) +// throw ( lang::IndexOutOfBoundsException ) +//{ +// (void)nSelectedChildIndex; +// return 0; +//} +Reference< XAccessibleTable > AccessibleGridControlTable::implGetHeaderBar( + sal_Int32 nChildIndex ) + throw ( uno::RuntimeException ) +{ + Reference< XAccessible > xRet; + Reference< XAccessibleContext > xContext( m_xParent, uno::UNO_QUERY ); + if( xContext.is() ) + { + try + { + xRet = xContext->getAccessibleChild( nChildIndex ); + } + catch( lang::IndexOutOfBoundsException& ) + { + DBG_ERROR( "implGetHeaderBar - wrong child index" ); + } + // RuntimeException goes to caller + } + return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY ); +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + diff --git a/accessibility/source/extended/AccessibleGridControlTableBase.cxx b/accessibility/source/extended/AccessibleGridControlTableBase.cxx new file mode 100755 index 000000000000..bc266f10f323 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlTableBase.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2009 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTableBase.cxx,v $ + * $Revision: 1.3 $ + * + * 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_accessibility.hxx" + + +#include "accessibility/extended/AccessibleGridControlTableBase.hxx" +#include <svtools/accessibletable.hxx> +#include <tools/multisel.hxx> +#include <comphelper/sequence.hxx> + +// ============================================================================ + +using ::rtl::OUString; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; +using namespace ::svt; +using namespace ::svt::table; + +// ============================================================================ + +namespace accessibility { + +// ============================================================================ + +// Ctor/Dtor/disposing -------------------------------------------------------- + +DBG_NAME( AccessibleGridControlTableBase ) + +AccessibleGridControlTableBase::AccessibleGridControlTableBase( + const Reference< XAccessible >& rxParent, + IAccessibleTable& rTable, + AccessibleTableControlObjType eObjType ) : + GridControlAccessibleElement( rxParent, rTable, eObjType ) +{ + DBG_CTOR( AccessibleGridControlTableBase, NULL ); +} + +AccessibleGridControlTableBase::~AccessibleGridControlTableBase() +{ + DBG_DTOR( AccessibleGridControlTableBase, NULL ); +} + +// XAccessibleContext --------------------------------------------------------- + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleChildCount() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + sal_Int32 nChildren = 0; + if(m_eObjType == TCTYPE_ROWHEADERBAR) + nChildren = m_aTable.GetRowCount(); + else if(m_eObjType == TCTYPE_TABLE) + nChildren = m_aTable.GetRowCount()*m_aTable.GetColumnCount(); + else if(m_eObjType == TCTYPE_COLUMNHEADERBAR) + nChildren = m_aTable.GetColumnCount(); + return nChildren; +} + +sal_Int16 SAL_CALL AccessibleGridControlTableBase::getAccessibleRole() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return AccessibleRole::TABLE; +} + +// XAccessibleTable ----------------------------------------------------------- + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRowCount() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_aTable.GetRowCount(); +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumnCount() + throw ( uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + return m_aTable.GetColumnCount(); +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRowExtentAt( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return 1; // merged cells not supported +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumnExtentAt( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return 1; // merged cells not supported +} + +Reference< XAccessible > SAL_CALL AccessibleGridControlTableBase::getAccessibleCaption() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return NULL; // not supported +} + +Reference< XAccessible > SAL_CALL AccessibleGridControlTableBase::getAccessibleSummary() + throw ( uno::RuntimeException ) +{ + ensureIsAlive(); + return NULL; // not supported +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleIndex( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidAddress( nRow, nColumn ); + return implGetChildIndex( nRow, nColumn ); +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRow( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidIndex( nChildIndex ); + return implGetRow( nChildIndex ); +} + +sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumn( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidIndex( nChildIndex ); + return implGetColumn( nChildIndex ); +} + +// XInterface ----------------------------------------------------------------- + +Any SAL_CALL AccessibleGridControlTableBase::queryInterface( const uno::Type& rType ) + throw ( uno::RuntimeException ) +{ + Any aAny( GridControlAccessibleElement::queryInterface( rType ) ); + return aAny.hasValue() ? + aAny : AccessibleGridControlTableImplHelper::queryInterface( rType ); +} + +void SAL_CALL AccessibleGridControlTableBase::acquire() throw () +{ + GridControlAccessibleElement::acquire(); +} + +void SAL_CALL AccessibleGridControlTableBase::release() throw () +{ + GridControlAccessibleElement::release(); +} + +// XTypeProvider -------------------------------------------------------------- + +Sequence< uno::Type > SAL_CALL AccessibleGridControlTableBase::getTypes() + throw ( uno::RuntimeException ) +{ + return ::comphelper::concatSequences( + GridControlAccessibleElement::getTypes(), + AccessibleGridControlTableImplHelper::getTypes() ); +} + +Sequence< sal_Int8 > SAL_CALL AccessibleGridControlTableBase::getImplementationId() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getOslGlobalMutex() ); + static Sequence< sal_Int8 > aId; + implCreateUuid( aId ); + return aId; +} + +// internal helper methods ---------------------------------------------------- + +sal_uInt16 AccessibleGridControlTableBase::implToVCLColumnPos( sal_Int32 nColumn ) const +{ + sal_uInt16 nVCLPos = 0; + if( (0 <= nColumn) && (nColumn < m_aTable.GetColumnCount()) ) + { + // regard "handle column" + if( m_aTable.HasRowHeader() ) + ++nColumn; + nVCLPos = static_cast< sal_uInt16 >( nColumn ); + } + return nVCLPos; +} + +sal_Int32 AccessibleGridControlTableBase::implGetChildCount() const +{ + return m_aTable.GetRowCount()*m_aTable.GetColumnCount(); +} + +sal_Int32 AccessibleGridControlTableBase::implGetRow( sal_Int32 nChildIndex ) const +{ + sal_Int32 nColumns = m_aTable.GetColumnCount(); + return nColumns ? (nChildIndex / nColumns) : 0; +} + +sal_Int32 AccessibleGridControlTableBase::implGetColumn( sal_Int32 nChildIndex ) const +{ + sal_Int32 nColumns = m_aTable.GetColumnCount(); + return nColumns ? (nChildIndex % nColumns) : 0; +} + +sal_Int32 AccessibleGridControlTableBase::implGetChildIndex( + sal_Int32 nRow, sal_Int32 nColumn ) const +{ + return nRow * m_aTable.GetColumnCount() + nColumn; +} + +sal_Bool AccessibleGridControlTableBase::implIsRowSelected( sal_Int32 nRow ) const +{ + return m_aTable.IsRowSelected( nRow ); +} + +sal_Int32 AccessibleGridControlTableBase::implGetSelectedRowCount() const +{ + return m_aTable.GetSelectedRowCount(); +} + +void AccessibleGridControlTableBase::implGetSelectedRows( Sequence< sal_Int32 >& rSeq ) +{ + rSeq = comphelper::containerToSequence(m_aTable.GetSelectedRows()); +} + +void AccessibleGridControlTableBase::ensureIsValidRow( sal_Int32 nRow ) + throw ( lang::IndexOutOfBoundsException ) +{ + if( nRow >= m_aTable.GetRowCount() ) + throw lang::IndexOutOfBoundsException( + OUString( RTL_CONSTASCII_USTRINGPARAM( "row index is invalid" ) ), *this ); +} + +void AccessibleGridControlTableBase::ensureIsValidColumn( sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException ) +{ + if( nColumn >= m_aTable.GetColumnCount() ) + throw lang::IndexOutOfBoundsException( + OUString( RTL_CONSTASCII_USTRINGPARAM("column index is invalid") ), *this ); +} + +void AccessibleGridControlTableBase::ensureIsValidAddress( + sal_Int32 nRow, sal_Int32 nColumn ) + throw ( lang::IndexOutOfBoundsException ) +{ + ensureIsValidRow( nRow ); + ensureIsValidColumn( nColumn ); +} + +void AccessibleGridControlTableBase::ensureIsValidIndex( sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException ) +{ + if( nChildIndex >= implGetChildCount() ) + throw lang::IndexOutOfBoundsException( + OUString( RTL_CONSTASCII_USTRINGPARAM("child index is invalid") ), *this ); +} + +// ============================================================================ + +} // namespace accessibility + +// ============================================================================ + diff --git a/accessibility/source/extended/AccessibleGridControlTableCell.cxx b/accessibility/source/extended/AccessibleGridControlTableCell.cxx new file mode 100755 index 000000000000..981a3e6086b0 --- /dev/null +++ b/accessibility/source/extended/AccessibleGridControlTableCell.cxx @@ -0,0 +1,379 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleGridControlTableCell.cxx,v $ + * $Revision: 1.4 $ + * + * 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_accessibility.hxx" + +#include "accessibility/extended/AccessibleGridControlTableCell.hxx" +#include <svtools/accessibletable.hxx> +#include "accessibility/extended/AccessibleGridControl.hxx" +#include <tools/gen.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> + +namespace accessibility +{ + namespace + { + void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException) + { + if ( _nIndex >= _sText.getLength() ) + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + + sal_Int32 getIndex_Impl( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_uInt16 _nColumnCount ) + { + return _nRow * _nColumnCount + _nColumn; + } + } + using namespace ::com::sun::star::lang; + using namespace utl; + using namespace comphelper; + using ::rtl::OUString; + using ::accessibility::AccessibleGridControl; + using namespace ::com::sun::star::uno; + using ::com::sun::star::accessibility::XAccessible; + using namespace ::com::sun::star::accessibility; + using namespace ::svt; + using namespace ::svt::table; + + + // ============================================================================= + // = AccessibleGridControlCell + // ============================================================================= + //DBG_NAME( svt_AccessibleGridControlCell ) + // ----------------------------------------------------------------------------- + AccessibleGridControlCell::AccessibleGridControlCell( + const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable, + sal_Int32 _nRowPos, sal_uInt16 _nColPos, AccessibleTableControlObjType _eType ) + :AccessibleGridControlBase( _rxParent, _rTable, _eType ) + ,m_nRowPos( _nRowPos ) + ,m_nColPos( _nColPos ) + { +// DBG_CTOR( svt_AccessibleGridControlCell, NULL ); + // set accessible name here, because for that we need the position of the cell + // and so the base class isn't capable of doing this + ::rtl::OUString aAccName; + if(_eType == TCTYPE_TABLECELL) + aAccName = _rTable.GetAccessibleObjectName( TCTYPE_TABLECELL, _nRowPos, _nColPos ); + else if(_eType == TCTYPE_ROWHEADERCELL) + aAccName = _rTable.GetAccessibleObjectName( TCTYPE_ROWHEADERCELL, _nRowPos, 0 ); + else if(_eType == TCTYPE_COLUMNHEADERCELL) + aAccName = _rTable.GetAccessibleObjectName( TCTYPE_COLUMNHEADERCELL, 0, _nRowPos ); + implSetName( aAccName ); + } + + // ----------------------------------------------------------------------------- + AccessibleGridControlCell::~AccessibleGridControlCell() + { + } + + // ----------------------------------------------------------------------------- + void SAL_CALL AccessibleGridControlCell::grabFocus() throw ( RuntimeException ) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + m_aTable.GoToCell( m_nColPos, m_nRowPos ); + } + //// ----------------------------------------------------------------------------- + // implementation of a table cell + ::rtl::OUString AccessibleGridControlTableCell::implGetText() + { + ensureIsAlive(); + //return mpTable->GetAccessibleCellText( getRowPos(), static_cast< USHORT >( getColumnPos() ) ); + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "test" )); + } + + ::com::sun::star::lang::Locale AccessibleGridControlTableCell::implGetLocale() + { + ensureIsAlive(); + return m_aTable.GetAccessible()->getAccessibleContext()->getLocale(); + } + + void AccessibleGridControlTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) + { + nStartIndex = 0; + nEndIndex = 0; + } + + AccessibleGridControlTableCell::AccessibleGridControlTableCell(const Reference<XAccessible >& _rxParent, + IAccessibleTable& _rTable, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + AccessibleTableControlObjType eObjType) + :AccessibleGridControlCell( _rxParent, _rTable, _nRowPos, _nColPos, eObjType ) + { + } + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlTableCell::queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw ( ::com::sun::star::uno::RuntimeException ) + { + Any aRet = AccessibleGridControlCell::queryInterface(rType); + if ( !aRet.hasValue() ) + aRet = AccessibleTextHelper_BASE::queryInterface(rType); + return aRet; + } + + /** Aquires the object (calls acquire() on base class). */ + void SAL_CALL AccessibleGridControlTableCell::acquire() throw () + { + AccessibleGridControlCell::acquire(); + } + + /** Releases the object (calls release() on base class). */ + void SAL_CALL AccessibleGridControlTableCell::release() throw () + { + AccessibleGridControlCell::release(); + } + + ::com::sun::star::awt::Rectangle SAL_CALL AccessibleGridControlTableCell::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + ensureIsAlive(); + if ( !implIsValidIndex( nIndex, implGetText().getLength() ) ) + throw IndexOutOfBoundsException(); + + ::com::sun::star::awt::Rectangle aRect; + + if ( &m_aTable ) + { + aRect = AWTRectangle( m_aTable.GetFieldCharacterBounds( getRowPos(), getColumnPos(), nIndex ) ); + } + + return aRect; + } + + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getIndexAtPoint( const ::com::sun::star::awt::Point& _aPoint ) throw (RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + return m_aTable.GetFieldIndexAtPoint( getRowPos(), getColumnPos(), VCLPoint( _aPoint ) ); + } + + /** @return + The name of this class. + */ + ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getImplementationName() + throw ( ::com::sun::star::uno::RuntimeException ) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlTableCell" ) ); + } + + /** @return The count of visible children. */ + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleChildCount() + throw ( ::com::sun::star::uno::RuntimeException ) + { + return 0; + } + + /** @return The XAccessible interface of the specified child. */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL + AccessibleGridControlTableCell::getAccessibleChild( sal_Int32 ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ) + { + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + } + + /** Creates a new AccessibleStateSetHelper and fills it with states of the + current object. + @return + A filled AccessibleStateSetHelper. + */ + ::utl::AccessibleStateSetHelper* AccessibleGridControlTableCell::implCreateStateSetHelper() + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + ::utl::AccessibleStateSetHelper* pStateSetHelper = new ::utl::AccessibleStateSetHelper; + + if( isAlive() ) + { + // SHOWING done with mxParent + if( implIsShowing() ) + pStateSetHelper->AddState( AccessibleStateType::SHOWING ); + + m_aTable.FillAccessibleStateSetForCell( *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) ); + } + else + pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + + return pStateSetHelper; + } + + + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + Reference< XAccessibleContext > SAL_CALL AccessibleGridControlTableCell::getAccessibleContext() throw ( RuntimeException ) + { + ensureIsAlive(); + return this; + } + + // XAccessibleContext ----------------------------------------------------- + + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleIndexInParent() + throw ( ::com::sun::star::uno::RuntimeException ) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + + return ( getRowPos() * m_aTable.GetColumnCount() ) + getColumnPos(); + } + + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException) + { + return -1; + } + sal_Bool SAL_CALL AccessibleGridControlTableCell::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) + throw IndexOutOfBoundsException(); + + return sal_False; + } + sal_Unicode SAL_CALL AccessibleGridControlTableCell::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getCharacter( nIndex ); + } + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleGridControlTableCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + + ::rtl::OUString sText( implGetText() ); + + if ( !implIsValidIndex( nIndex, sText.getLength() ) ) + throw IndexOutOfBoundsException(); + + return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(); + } + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getCharacterCount( ); + } + + ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getSelectedText( ); + } + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getSelectionStart( ); + } + sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getSelectionEnd( ); + } + sal_Bool SAL_CALL AccessibleGridControlTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) + throw IndexOutOfBoundsException(); + + return sal_False; + } + ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getText( ) throw (::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getText( ); + } + ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ); + } + ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType); + } + ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType); + } + ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType); + } + sal_Bool SAL_CALL AccessibleGridControlTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ::rtl::OUString sText = implGetText(); + checkIndex_Impl( nStartIndex, sText ); + checkIndex_Impl( nEndIndex, sText ); + + //!!! don't know how to put a string into the clipboard + return sal_False; + } + Rectangle AccessibleGridControlTableCell::implGetBoundingBox() + { + return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle + } + // ----------------------------------------------------------------------------- + + Rectangle AccessibleGridControlTableCell::implGetBoundingBoxOnScreen() + { + return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle + } +} diff --git a/accessibility/source/extended/makefile.mk b/accessibility/source/extended/makefile.mk index 701bff8f7b51..34f9158f1f02 100644 --- a/accessibility/source/extended/makefile.mk +++ b/accessibility/source/extended/makefile.mk @@ -64,7 +64,14 @@ SLOFILES=\ $(SLO)$/listboxaccessible.obj \ $(SLO)$/accessiblebrowseboxcell.obj \ $(SLO)$/accessibleeditbrowseboxcell.obj \ - $(SLO)$/textwindowaccessibility.obj + $(SLO)$/textwindowaccessibility.obj \ + $(SLO)$/AccessibleGridControlBase.obj \ + $(SLO)$/AccessibleGridControl.obj \ + $(SLO)$/AccessibleGridControlTableBase.obj \ + $(SLO)$/AccessibleGridControlHeader.obj \ + $(SLO)$/AccessibleGridControlTableCell.obj \ + $(SLO)$/AccessibleGridControlHeaderCell.obj \ + $(SLO)$/AccessibleGridControlTable.obj # --- Targets ------------------------------------------------------- diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index 5c8b742db53c..60e4f416dc3c 100644 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -72,6 +72,8 @@ #include <accessibility/extended/accessibleeditbrowseboxcell.hxx> #include <vcl/lstbox.hxx> #include <vcl/combobox.hxx> +#include <accessibility/extended/AccessibleGridControl.hxx> +#include <svtools/accessibletable.hxx> #include <floatingwindowaccessible.hxx> @@ -94,6 +96,7 @@ inline bool hasFloatingChild(Window *pWindow) using namespace ::com::sun::star::awt; using namespace ::com::sun::star::accessibility; using namespace ::svt; + using namespace ::svt::table; //================================================================ //= IAccessibleFactory @@ -150,6 +153,12 @@ inline bool hasFloatingChild(Window *pWindow) IAccessibleTableProvider& _rBrowseBox ) const; + virtual IAccessibleTableControl* + createAccessibleTableControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + IAccessibleTable& _rTable + ) const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > createAccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, @@ -412,6 +421,13 @@ inline bool hasFloatingChild(Window *pWindow) } //-------------------------------------------------------------------- + IAccessibleTableControl* AccessibleFactory::createAccessibleTableControl( + const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable ) const + { + return new AccessibleGridControlAccess( _rxParent, _rTable ); + } + + //-------------------------------------------------------------------- Reference< XAccessible > AccessibleFactory::createAccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, const Reference< XAccessible >& _xParent ) const { diff --git a/autodoc/source/display/idl/hfi_doc.cxx b/autodoc/source/display/idl/hfi_doc.cxx index d5c686d2bbe0..278859f76acb 100644 --- a/autodoc/source/display/idl/hfi_doc.cxx +++ b/autodoc/source/display/idl/hfi_doc.cxx @@ -55,8 +55,17 @@ HF_IdlDocu::~HF_IdlDocu() } void -HF_IdlDocu::Produce_byDocu4Reference( const ce_info & i_rDocuForReference, - const client & i_rScopeGivingCe ) const +HF_IdlDocu::Produce_fromCodeEntity( const client & i_ce ) const +{ + const ce_info * + i_pDocu = Get_IdlDocu(i_ce.Docu()); + if (i_pDocu != 0) + Produce_byDocuAndScope(*i_pDocu, &i_ce, i_ce); +} + +void +HF_IdlDocu::Produce_fromReference( const ce_info & i_rDocuForReference, + const client & i_rScopeGivingCe ) const { Produce_byDocuAndScope(i_rDocuForReference, 0, i_rScopeGivingCe ); } @@ -121,11 +130,31 @@ HF_IdlDocu::Produce_byDocuAndScope( const ce_info & i_rDocu, } } + std::vector< csi::dsapi::DT_SeeAlsoAtTag* > + aSeeAlsosWithoutText; + std::vector< csi::dsapi::DT_SeeAlsoAtTag* > + aSeeAlsosWithText; + for ( std::vector< ary::inf::AtTag2* >::const_iterator iter = i_rDocu.Tags().begin(); iter != i_rDocu.Tags().end(); ++iter ) { + csi::dsapi::DT_SeeAlsoAtTag* + pSeeAlso = dynamic_cast< csi::dsapi::DT_SeeAlsoAtTag * >(*iter); + if (pSeeAlso != 0 ) + { + if ( pSeeAlso->Text().IsEmpty() ) + { + aSeeAlsosWithoutText.push_back(pSeeAlso); + } + else + { + aSeeAlsosWithText.push_back(pSeeAlso); + } + continue; + } + if ( strlen( (*iter)->Title() ) > 0 ) { HF_IdlTag @@ -137,4 +166,29 @@ HF_IdlDocu::Produce_byDocuAndScope( const ce_info & i_rDocu, *(*iter) ); } } // end for + + if (aSeeAlsosWithoutText.size() > 0) + { + HF_IdlTag + aSeeAlsoTag(Env(), i_rScopeGivingCe); + Xml::Element & + rTerm = rOut.Produce_Term(); + aSeeAlsoTag.Produce_byData( rTerm, + rOut.Produce_Definition(), + aSeeAlsosWithoutText ); + } + + for ( std::vector< csi::dsapi::DT_SeeAlsoAtTag* >::const_iterator + itSee2 = aSeeAlsosWithText.begin(); + itSee2 != aSeeAlsosWithText.end(); + ++itSee2 ) + { + HF_IdlTag + aTag(Env(), i_rScopeGivingCe); + Xml::Element & + rTerm = rOut.Produce_Term(); + aTag.Produce_byData( rTerm, + rOut.Produce_Definition(), + *(*itSee2) ); + } // end for } diff --git a/autodoc/source/display/idl/hfi_doc.hxx b/autodoc/source/display/idl/hfi_doc.hxx index b44fd4822770..9064bba3fee8 100644 --- a/autodoc/source/display/idl/hfi_doc.hxx +++ b/autodoc/source/display/idl/hfi_doc.hxx @@ -53,12 +53,18 @@ class HF_IdlDocu : public HtmlFactory_Idl /** Produces documentation by the CodeInfo accompanying + ->i_ce. + */ + void Produce_fromCodeEntity( + const client & i_ce ) const; + + /** Produces documentation by the CodeInfo accompanying a link or reference to a CodeEntity. @param i_rScopeGivingCe Gives the scope from which links are to be calculated. */ - void Produce_byDocu4Reference( + void Produce_fromReference( const ce_info & i_rDocuForReference, const client & i_rScopeGivingCe ) const; diff --git a/autodoc/source/display/idl/hfi_interface.cxx b/autodoc/source/display/idl/hfi_interface.cxx index 26d548c613e8..1c242f746b58 100644 --- a/autodoc/source/display/idl/hfi_interface.cxx +++ b/autodoc/source/display/idl/hfi_interface.cxx @@ -335,7 +335,7 @@ HF_IdlInterface::produce_BaseHierarchy( Xml::Element & o_screen, HF_IdlDocu aDocuDisplay(Env(), aDocuList); - aDocuDisplay.Produce_byDocu4Reference(*(*it).Info(), i_ce); + aDocuDisplay.Produce_fromReference(*(*it).Info(), i_ce); } else { diff --git a/autodoc/source/display/idl/hfi_property.cxx b/autodoc/source/display/idl/hfi_property.cxx index 282095578a6c..8500a236c791 100644 --- a/autodoc/source/display/idl/hfi_property.cxx +++ b/autodoc/source/display/idl/hfi_property.cxx @@ -378,7 +378,7 @@ HF_IdlCommentedRelationElement::produce_LinkDoc( Environment & io_env, HF_DocEntryList aDocList(io_context); HF_IdlDocu aDocuDisplay(io_env, aDocList); - aDocuDisplay.Produce_byDocu4Reference(*i_commentedRef.Info(), i_ce); + aDocuDisplay.Produce_fromReference(*i_commentedRef.Info(), i_ce); } else { diff --git a/autodoc/source/display/idl/hfi_tag.cxx b/autodoc/source/display/idl/hfi_tag.cxx index 99f4a83732ca..8d194bc43222 100644 --- a/autodoc/source/display/idl/hfi_tag.cxx +++ b/autodoc/source/display/idl/hfi_tag.cxx @@ -93,6 +93,28 @@ HF_IdlTag::Produce_byData( Xml::Element & o_rTitle, } void +HF_IdlTag::Produce_byData( Xml::Element & o_rTitle, + Xml::Element & o_rText, + const std::vector< csi::dsapi::DT_SeeAlsoAtTag* > & + i_seeAlsoVector ) const +{ + o_rTitle << "See also"; + for ( std::vector< csi::dsapi::DT_SeeAlsoAtTag* >::const_iterator + it = i_seeAlsoVector.begin(); + it != i_seeAlsoVector.end(); + ++it ) + { + if (it != i_seeAlsoVector.begin()) + { + o_rText << ", "; + } + HF_IdlTypeText + aLinkText(Env(), o_rText, true, &aTextOut.ScopeGivingCe()); + aLinkText.Produce_byData( (*it)->LinkText() ); + } +} + +void HF_IdlTag::Display_StdAtTag( const csi::dsapi::DT_StdAtTag & i_rTag ) { if ( i_rTag.Text().IsEmpty() ) diff --git a/autodoc/source/display/idl/hfi_tag.hxx b/autodoc/source/display/idl/hfi_tag.hxx index c070c5d15a0a..23f16a46919f 100644 --- a/autodoc/source/display/idl/hfi_tag.hxx +++ b/autodoc/source/display/idl/hfi_tag.hxx @@ -142,6 +142,11 @@ class HF_IdlTag : public HtmlFactory_Idl, Xml::Element & o_rText, const ary::inf::AtTag2 & i_rTag ) const; + void Produce_byData( + Xml::Element & o_rTitle, + Xml::Element & o_rText, + const std::vector< csi::dsapi::DT_SeeAlsoAtTag* > & + i_seeAlsoVector ) const; private: virtual void Display_StdAtTag( const csi::dsapi::DT_StdAtTag & diff --git a/autodoc/source/display/idl/hi_factory.cxx b/autodoc/source/display/idl/hi_factory.cxx index 04ac8e3d2c13..5b711d5d9ed6 100644 --- a/autodoc/source/display/idl/hi_factory.cxx +++ b/autodoc/source/display/idl/hi_factory.cxx @@ -224,7 +224,7 @@ HtmlFactory_Idl::write_Docu( Xml::Element & o_screen, aDocuList( o_screen ); HF_IdlDocu aDocu( Env(), aDocuList ); - aDocu.Produce_byDocu4Reference(*doc, i_ce); + aDocu.Produce_fromCodeEntity(i_ce); } write_ManualLinks(o_screen, i_ce); diff --git a/avmedia/source/quicktime/player.cxx b/avmedia/source/quicktime/player.cxx index e8289570b5ae..29332698016e 100644 --- a/avmedia/source/quicktime/player.cxx +++ b/avmedia/source/quicktime/player.cxx @@ -100,8 +100,6 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : if ((result == noErr) && (mnVersion >= QT701)) { // we have version 7.01 or later, initialize - mpMovie = [QTMovie movie]; - [mpMovie retain]; mbInitialized = true; } [pool release]; @@ -111,44 +109,58 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : Player::~Player() { - if( mbInitialized ) + if( mpMovie ) { - if( mpMovie ) - { - [mpMovie release]; - mpMovie = nil; - } - + [mpMovie release]; + mpMovie = nil; } } +// ------------------------------------------------------------------------------ +QTMovie* Player::getMovie() +{ + OSL_ASSERT( mpMovie ); + return mpMovie; +} // ------------------------------------------------------------------------------ bool Player::create( const ::rtl::OUString& rURL ) { bool bRet = false; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ; -// NSString * aNSStringEscaped = [aNSStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - NSURL* aURL = [NSURL URLWithString:aNSStr ]; - // create the Movie - if( mbInitialized ) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + if( mpMovie ) + { + [mpMovie release]; + mpMovie = nil; + } + + NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ; + NSURL* aURL = [NSURL URLWithString:aNSStr ]; + - mpMovie = [mpMovie initWithURL:aURL error:nil]; + NSError* pErr = nil; + mpMovie = [QTMovie movieWithURL:aURL error:&pErr]; if(mpMovie) { [mpMovie retain]; maURL = rURL; bRet = true; } + if( pErr ) + { + OSL_TRACE( "NSMovie create failed with error %ld (%s)", + (long)[pErr code], + [[pErr localizedDescription] cString] + ); + } + [pool release]; } - [pool release]; - return bRet; } @@ -159,10 +171,10 @@ void SAL_CALL Player::start( ) { OSL_TRACE ("Player::start"); - if ( mbInitialized && mpMovie ) - { + if( mpMovie ) + { [mpMovie play]; - } + } } // ------------------------------------------------------------------------------ @@ -171,11 +183,10 @@ void SAL_CALL Player::stop( ) throw (uno::RuntimeException) { OSL_TRACE ("Player::stop"); - if ( mpMovie ) + if( mpMovie ) { - [mpMovie stop]; + [mpMovie stop]; } - } // ------------------------------------------------------------------------------ @@ -185,7 +196,7 @@ sal_Bool SAL_CALL Player::isPlaying() { bool bRet = false; - if ( mbInitialized ) + if ( mpMovie ) { if ([mpMovie rate] != 0) { @@ -220,10 +231,10 @@ void SAL_CALL Player::setMediaTime( double fTime ) { OSL_TRACE ("Player::setMediaTime"); - if ( mpMovie ) - { - [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)]; - } + if ( mpMovie ) + { + [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)]; + } } // ------------------------------------------------------------------------------ @@ -244,7 +255,6 @@ double SAL_CALL Player::getMediaTime( ) stop(); } - return position; } @@ -256,7 +266,6 @@ void SAL_CALL Player::setStopTime( double fTime ) OSL_TRACE ("Player::setStopTime %f", fTime); mnStopTime = fTime; - } // ------------------------------------------------------------------------------ @@ -264,9 +273,7 @@ void SAL_CALL Player::setStopTime( double fTime ) double SAL_CALL Player::getStopTime( ) throw (uno::RuntimeException) { - double fRet = 0.0; - - fRet = mnStopTime; + double fRet = mnStopTime; return fRet; } diff --git a/avmedia/source/quicktime/player.hxx b/avmedia/source/quicktime/player.hxx index b7cab51005f4..c49ccd62915c 100644 --- a/avmedia/source/quicktime/player.hxx +++ b/avmedia/source/quicktime/player.hxx @@ -83,7 +83,7 @@ public: 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); - QTMovie* getMovie() { return mpMovie; } + QTMovie* getMovie(); private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx index 05acc545c77b..2506c179f413 100644 --- a/avmedia/source/viewer/mediawindowbase_impl.cxx +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -147,9 +147,9 @@ void MediaWindowBaseImpl::stopPlayingInternal( bool bStop ) if( isPlaying() ) { if( bStop ) - mxPlayer->start(); - else mxPlayer->stop(); + else + mxPlayer->start(); } } diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx index 277bf6b9c34e..159bd6f78de9 100644 --- a/basic/inc/basic/basmgr.hxx +++ b/basic/inc/basic/basmgr.hxx @@ -231,6 +231,8 @@ public: ::com::sun::star::uno::Any SetGlobalUNOConstant( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rValue ); + /** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */ + bool GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ); /** determines whether there are password-protected modules whose size exceedes the legacy module size @param _out_rModuleNames diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx index 3ec0803eb4a9..1278972135f9 100644 --- a/basic/inc/basic/sbstar.hxx +++ b/basic/inc/basic/sbstar.hxx @@ -74,6 +74,11 @@ class StarBASIC : public SbxObject BOOL bDocBasic; BasicLibInfo* pLibInfo; // Info block for basic manager SbLanguageMode eLanguageMode; // LanguageMode of the basic object + BOOL bQuit; + + SbxObjectRef pVBAGlobals; + SbxObject* getVBAGlobals( ); + protected: BOOL CError( SbError, const String&, xub_StrLen, xub_StrLen, xub_StrLen ); private: @@ -196,6 +201,10 @@ public: SbxObjectRef getRTL( void ) { return pRtl; } BOOL IsDocBasic() { return bDocBasic; } + SbxVariable* VBAFind( const String& rName, SbxClassType t ); + bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ); + void QuitAndExitApplication(); + BOOL IsQuitApplication() { return bQuit; }; }; #ifndef __SB_SBSTARBASICREF_HXX diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 8cf8a674ec2f..2620852370b1 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -47,6 +47,7 @@ #include <basic/sbuno.hxx> #include <basic/basmgr.hxx> +#include <sbunoobj.hxx> #include "basrid.hxx" #include "sbintern.hxx" #include <sb.hrc> @@ -1767,6 +1768,15 @@ BasicError* BasicManager::GetNextError() DBG_CHKTHIS( BasicManager, 0 ); return pErrorMgr->GetNextError(); } +bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ) +{ + bool bRes = false; + StarBASIC* pStandardLib = GetStdLib(); + OSL_PRECOND( pStandardLib, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" ); + if ( pStandardLib ) + bRes = pStandardLib->GetUNOConstant( _pAsciiName, aOut ); + return bRes; +} Any BasicManager::SetGlobalUNOConstant( const sal_Char* _pAsciiName, const Any& _rValue ) { diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 7776b57829c9..b0c8f4b3c36c 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -95,53 +95,48 @@ Any sbxToUnoValue( SbxVariable* pVar ); Reference< frame::XModel > getModelFromBasic( SbxObject* pBasic ) { - Reference< frame::XModel > xModel; - - SbxObject* basicChosen = pBasic; - - if ( basicChosen == NULL) + OSL_PRECOND( pBasic != NULL, "getModelFromBasic: illegal call!" ); + if ( !pBasic ) + return NULL; + + // look for the ThisComponent variable, first in the parent (which + // might be the document's Basic), then in the parent's parent (which might be + // the application Basic) + const ::rtl::OUString sThisComponent( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ); + SbxVariable* pThisComponent = NULL; + + SbxObject* pLookup = pBasic->GetParent(); + while ( pLookup && !pThisComponent ) { - OSL_TRACE("getModelFromBasic() StarBASIC* is NULL" ); - return xModel; + pThisComponent = pLookup->Find( sThisComponent, SbxCLASS_OBJECT ); + pLookup = pLookup->GetParent(); } - SbxObject* p = pBasic; - SbxObject* pParent = p->GetParent(); - SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL; - - if( pParentParent ) + if ( !pThisComponent ) { - basicChosen = pParentParent; + OSL_TRACE("Failed to get ThisComponent"); + // the application Basic, at the latest, should have this variable + return NULL; } - else if( pParent ) + + Any aThisComponent( sbxToUnoValue( pThisComponent ) ); + Reference< frame::XModel > xModel( aThisComponent, UNO_QUERY ); + if ( !xModel.is() ) { - basicChosen = pParent; + // it's no XModel. Okay, ThisComponent nowadays is allowed to be a controller. + Reference< frame::XController > xController( aThisComponent, UNO_QUERY ); + if ( xController.is() ) + xModel = xController->getModel(); } + if ( !xModel.is() ) + return NULL; - Any aModel; - SbxVariable *pCompVar = basicChosen->Find( UniString(RTL_CONSTASCII_USTRINGPARAM("ThisComponent")), SbxCLASS_OBJECT ); +#if OSL_DEBUG_LEVEL > 0 + OSL_TRACE("Have model ThisComponent points to url %s", + ::rtl::OUStringToOString( xModel->getURL(), + RTL_TEXTENCODING_ASCII_US ).pData->buffer ); +#endif - if ( pCompVar ) - { - aModel = sbxToUnoValue( pCompVar ); - if ( sal_False == ( aModel >>= xModel ) || - !xModel.is() ) - { - OSL_TRACE("Failed to extract model from thisComponent "); - return xModel; - } - else - { - OSL_TRACE("Have model ThisComponent points to url %s", - ::rtl::OUStringToOString( xModel->getURL(), - RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - - } - } - else - { - OSL_TRACE("Failed to get ThisComponent"); - } return xModel; } diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index af056b884826..80fa3c6bb836 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -65,7 +65,29 @@ SV_IMPL_VARARR(SbTextPortions,SbTextPortion) TYPEINIT1(StarBASIC,SbxObject) #define RTLNAME "@SBRTL" +// i#i68894# +const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); +const static String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); + +SbxObject* StarBASIC::getVBAGlobals( ) +{ + if ( !pVBAGlobals ) + pVBAGlobals = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE ); + return pVBAGlobals; +} + +// i#i68894# +SbxVariable* StarBASIC::VBAFind( const String& rName, SbxClassType t ) +{ + if( rName == aThisComponent ) + return NULL; + // rename to init globals + if ( getVBAGlobals( ) ) + return pVBAGlobals->Find( rName, t ); + return NULL; + +} // Create array for conversion SFX <-> VB error code struct SFX_VB_ErrorItem { @@ -303,32 +325,32 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj ) if( pProp ) { SbxProperty* pNewProp = new SbxProperty( *pProp ); - if( pVar->GetType() & SbxARRAY )
- {
- SbxBase* pParObj = pVar->GetObject();
- SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj);
- SbxDimArray* pDest = new SbxDimArray( pVar->GetType() );
- INT32 lb = 0;
- INT32 ub = 0;
-
- pDest->setHasFixedSize( pSource->hasFixedSize() );
- if ( pSource->GetDims() && pSource->hasFixedSize() )
- {
- for ( INT32 j = 1 ; j <= pSource->GetDims(); ++j )
- {
- pSource->GetDim32( (INT32)j, lb, ub );
- pDest->AddDim32( lb, ub );
- }
- }
- else
- pDest->unoAddDim( 0, -1 ); // variant array
-
- USHORT nSavFlags = pVar->GetFlags();
- pNewProp->ResetFlag( SBX_FIXED );
- // need to reset the FIXED flag
- // when calling PutObject ( because the type will not match Object )
- pNewProp->PutObject( pDest );
- pNewProp->SetFlags( nSavFlags );
+ if( pVar->GetType() & SbxARRAY ) + { + SbxBase* pParObj = pVar->GetObject(); + SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj); + SbxDimArray* pDest = new SbxDimArray( pVar->GetType() ); + INT32 lb = 0; + INT32 ub = 0; + + pDest->setHasFixedSize( pSource->hasFixedSize() ); + if ( pSource->GetDims() && pSource->hasFixedSize() ) + { + for ( INT32 j = 1 ; j <= pSource->GetDims(); ++j ) + { + pSource->GetDim32( (INT32)j, lb, ub ); + pDest->AddDim32( lb, ub ); + } + } + else + pDest->unoAddDim( 0, -1 ); // variant array + + USHORT nSavFlags = pVar->GetFlags(); + pNewProp->ResetFlag( SBX_FIXED ); + // need to reset the FIXED flag + // when calling PutObject ( because the type will not match Object ) + pNewProp->PutObject( pDest ); + pNewProp->SetFlags( nSavFlags ); } pProps->PutDirect( pNewProp, i ); } @@ -445,8 +467,8 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) SbProcedureProperty* pNewProp = new SbProcedureProperty ( pProcedureProp->GetName(), pProcedureProp->GetType() ); // ( pProcedureProp->GetName(), pProcedureProp->GetType(), this ); - pNewProp->SetFlags( nFlags_ ); // Copy flags
- pNewProp->ResetFlag( SBX_NO_BROADCAST ); // except the Broadcast if it was set
+ pNewProp->SetFlags( nFlags_ ); // Copy flags + pNewProp->ResetFlag( SBX_NO_BROADCAST ); // except the Broadcast if it was set pProcedureProp->SetFlags( nFlags_ ); pProps->PutDirect( pNewProp, i ); StartListening( pNewProp->GetBroadcaster(), TRUE ); @@ -681,6 +703,8 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic ) pRtl = new SbiStdObject( String( RTL_CONSTASCII_USTRINGPARAM(RTLNAME) ), this ); // Search via StarBasic is always global SetFlag( SBX_GBLSEARCH ); + pVBAGlobals = NULL; + bQuit = FALSE; } // #51727 Override SetModified so that the modified state @@ -995,6 +1019,12 @@ SbxVariable* StarBASIC::FindVarInCurrentScopy return pVar; } +void StarBASIC::QuitAndExitApplication() +{ + Stop(); + bQuit = TRUE; +} + void StarBASIC::Stop() { SbiInstance* p = pINST; @@ -1533,6 +1563,18 @@ BOOL StarBASIC::LoadOldModules( SvStream& ) return FALSE; } +bool StarBASIC::GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ) +{ + bool bRes = false; + ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); + SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( Find( sVarName, SbxCLASS_DONTCARE ) ); + if ( pGlobs ) + { + aOut = pGlobs->getUnoAny(); + bRes = true; + } + return bRes; +} //======================================================================== // #118116 Implementation Collection object diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 2a61557457b7..2d5f4f7cdf89 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -69,6 +69,11 @@ #endif #include <stdio.h> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> +#include <vcl/svapp.hxx> + using namespace ::com::sun::star; TYPEINIT1(SbModule,SbxObject) @@ -84,7 +89,63 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT) SV_IMPL_VARARR(HighlightPortions, HighlightPortion) +class AsyncQuitHandler +{ + AsyncQuitHandler() {} + AsyncQuitHandler( const AsyncQuitHandler&); +public: + static AsyncQuitHandler& instance() + { + static AsyncQuitHandler dInst; + return dInst; + } + void QuitApplication() + { + uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + if ( xFactory.is() ) + { + uno::Reference< frame::XDesktop > xDeskTop( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop") ) ), uno::UNO_QUERY ); + if ( xDeskTop.is() ) + xDeskTop->terminate(); + } + } + DECL_LINK( OnAsyncQuit, void* ); +}; + +IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ ) +{ + QuitApplication(); + return 0L; +} + +#if 0 +bool UnlockControllerHack( StarBASIC* pBasic ) +{ + bool bRes = false; + if ( pBasic && pBasic->IsDocBasic() ) + { + uno::Any aUnoVar; + ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( "ThisComponent" ) ); + SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( pBasic->Find( sVarName, SbxCLASS_DONTCARE ) ); + if ( pGlobs ) + aUnoVar = pGlobs->getUnoAny(); + uno::Reference< frame::XModel > xModel( aUnoVar, uno::UNO_QUERY); + if ( xModel.is() ) + { + try + { + xModel->unlockControllers(); + bRes = true; + } + catch( uno::Exception& ) + { + } + } + } + return bRes; +} +#endif ///////////////////////////////////////////////////////////////////////////// // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen @@ -696,6 +757,13 @@ USHORT SbModule::Run( SbMethod* pMeth ) pINST->nCallLvl--; // Call-Level wieder runter StarBASIC::FatalError( SbERR_STACK_OVERFLOW ); } + + // VBA always ensure screenupdating is enabled after completing + StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent()); +#if 0 + if ( pBasic && pBasic->IsDocBasic() && !pINST ) + UnlockControllerHack( pBasic ); +#endif if( bDelInst ) { // #57841 Uno-Objekte, die in RTL-Funktionen gehalten werden, @@ -705,6 +773,11 @@ USHORT SbModule::Run( SbMethod* pMeth ) delete pINST; pINST = NULL; } + if ( pBasic && pBasic->IsDocBasic() && pBasic->IsQuitApplication() && !pINST ) + { + Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ), NULL ); + } + return nRes; } diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 413d3a6f4def..fb0b217b76c4 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -56,57 +56,6 @@ using com::sun::star::uno::Reference; SbxVariable* getVBAConstant( const String& rName ); -const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); -const static String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); -// i#i68894# -SbxArray* getVBAGlobals( ) -{ - static SbxArrayRef pArray; - static bool isInitialised = false; - if ( isInitialised ) - return pArray; - Reference < XComponentContext > xCtx; - Reference < XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - xCtx.set( xProps->getPropertyValue( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), - UNO_QUERY_THROW ); - SbUnoObject dGlobs( String( RTL_CONSTASCII_USTRINGPARAM("ExcelGlobals") ), xCtx->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/ooo.vba.theGlobals") ) ); - - SbxVariable *vba = dGlobs.Find( String( RTL_CONSTASCII_USTRINGPARAM("getGlobals") ) , SbxCLASS_DONTCARE ); - - if ( vba ) - { - pArray = static_cast<SbxArray *>(vba->GetObject()); - isInitialised = true; - return pArray; - } - return NULL; -} - -// i#i68894# -SbxVariable* VBAFind( const String& rName, SbxClassType t ) -{ - if( rName == aThisComponent ) - return NULL; - - SbxArray *pVBAGlobals = getVBAGlobals( ); - for (USHORT i = 0; pVBAGlobals && i < pVBAGlobals->Count(); i++) - { - SbxVariable *pElem = pVBAGlobals->Get( i ); - if (!pElem || !pElem->IsObject()) - continue; - SbxObject *pVba = static_cast<SbxObject *>(pElem->GetObject()); - SbxVariable *pVbaVar = pVba ? pVba->Find( rName, t ) : NULL; - if( pVbaVar ) - { - return pVbaVar; - } - } - return NULL; - -} - // Suchen eines Elements // Die Bits im String-ID: // 0x8000 - Argv ist belegt @@ -191,7 +140,7 @@ SbxVariable* SbiRuntime::FindElement if ( bVBAEnabled ) { // Try Find in VBA symbols space - pElem = VBAFind( aName, SbxCLASS_DONTCARE ); + pElem = rBasic.VBAFind( aName, SbxCLASS_DONTCARE ); if ( pElem ) bSetName = false; // don't overwrite uno name else diff --git a/comphelper/inc/comphelper/servicedecl.hxx b/comphelper/inc/comphelper/servicedecl.hxx index a11598bdca85..7b77d3ba29e7 100644 --- a/comphelper/inc/comphelper/servicedecl.hxx +++ b/comphelper/inc/comphelper/servicedecl.hxx @@ -169,21 +169,20 @@ template <bool> struct with_args; /// @internal namespace detail { - template <typename ImplT> -class ServiceImpl - : public ::cppu::ImplInheritanceHelper1<ImplT, css::lang::XServiceInfo>, +class OwnServiceImpl + : public ImplT, private ::boost::noncopyable { - typedef ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> BaseT; + typedef ImplT BaseT; public: - ServiceImpl( + OwnServiceImpl( ServiceDecl const& rServiceDecl, css::uno::Sequence<css::uno::Any> const& args, css::uno::Reference<css::uno::XComponentContext> const& xContext ) - : BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {} - ServiceImpl( + :BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {} + OwnServiceImpl( ServiceDecl const& rServiceDecl, css::uno::Reference<css::uno::XComponentContext> const& xContext ) : BaseT(xContext), m_rServiceDecl(rServiceDecl) {} @@ -206,6 +205,22 @@ private: ServiceDecl const& m_rServiceDecl; }; +template <typename ImplT> +class ServiceImpl : public OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > +{ +typedef OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > ServiceImpl_BASE; +public: + ServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Sequence<css::uno::Any> const& args, + css::uno::Reference<css::uno::XComponentContext> const& xContext ) + : ServiceImpl_BASE(rServiceDecl, args, xContext) {} + ServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Reference<css::uno::XComponentContext> const& xContext ) + : ServiceImpl_BASE(rServiceDecl, xContext) {} +}; + template <typename ServiceImplT> struct PostProcessDefault { css::uno::Reference<css::uno::XInterface> @@ -230,7 +245,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<false> > { const& xContext ) const { return m_postProcessFunc( - new ServiceImpl<ImplT>( rServiceDecl, xContext ) ); + new ImplT( rServiceDecl, xContext ) ); } }; @@ -247,7 +262,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > { const& xContext ) const { return m_postProcessFunc( - new ServiceImpl<ImplT>( rServiceDecl, args, xContext ) ); + new ImplT( rServiceDecl, args, xContext ) ); } }; @@ -261,18 +276,17 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > { or just (uno::Reference<uno::XComponentContext>) */ template <typename ImplT_, typename WithArgsT = with_args<false> > -struct class_ { +struct serviceimpl_base { typedef ImplT_ ImplT; - typedef detail::ServiceImpl<ImplT_> ServiceImplT; detail::CreateFuncF const m_createFunc; - typedef detail::PostProcessDefault<ServiceImplT> PostProcessDefaultT; + typedef detail::PostProcessDefault<ImplT> PostProcessDefaultT; /** Default ctor. Implementation class without args, expecting component context as single argument. */ - class_() : m_createFunc( + serviceimpl_base() : m_createFunc( detail::CreateFunc<ImplT, PostProcessDefaultT, WithArgsT>( PostProcessDefaultT() ) ) {} @@ -284,11 +298,29 @@ struct class_ { uno::Reference<uno::XInterface> */ template <typename PostProcessFuncT> - explicit class_( PostProcessFuncT const& postProcessFunc ) + explicit serviceimpl_base( PostProcessFuncT const& postProcessFunc ) : m_createFunc( detail::CreateFunc<ImplT, PostProcessFuncT, WithArgsT>( postProcessFunc ) ) {} }; +template <typename ImplT_, typename WithArgsT = with_args<false> > +struct class_ : public serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > +{ + typedef serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > baseT; + /** Default ctor. Implementation class without args, expecting + component context as single argument. + */ + class_() : baseT() {} + template <typename PostProcessFuncT> + /** Ctor to pass a post processing function/functor. + + @tpl PostProcessDefaultT let your compiler deduce this + @param postProcessFunc function/functor that gets the yet unacquired + ImplT_ pointer returning a + uno::Reference<uno::XInterface> + */ + explicit class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} +}; // // component_... helpers with arbitrary service declarations: diff --git a/configure.in b/configure.in index 37fa42796ce9..3505be436cf6 100644 --- a/configure.in +++ b/configure.in @@ -652,10 +652,13 @@ AC_ARG_WITH(directx-home, Usage: --with-directx-home=<absolute path to Microsoft DirectX SDK> ],,) AC_ARG_WITH(mozilla-build, -[ --with-mozilla-build For Windows users, please supply the path to the +[ --with-mozilla-build For Windows users, please supply the path to the mozilla build tools. Usage: --with-mozilla-build=<absolute path to mozilla build tools> + + At the moment of this writing, an installer for the mozilla build tools + can be obtained from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32. ],[MOZILLABUILD=$withval],) AC_ARG_WITH(local-solenv, [ --with-local-solenv If you have solenv in a location other than ./solenv, @@ -4378,7 +4381,9 @@ if test "$enable_nss_module" != "no"; then if test "$_os" = "WINNT"; then AC_MSG_CHECKING([for Mozilla build tooling]) if test -z "$MOZILLABUILD" ; then -AC_MSG_ERROR([Mozilla build tooling not found. Use --with-mozilla-build=<absolut path to mozilla build tooling (mozilla-build)>]) +AC_MSG_ERROR([Mozilla build tooling not found. +Use the --with-mozilla-build option after installling the tools obtained +from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32]) else if test \( "$WITH_MINGWIN" = "yes" \) ; then if test ! -d "$MOZILLABUILD" ; then diff --git a/connectivity/inc/connectivity/FValue.hxx b/connectivity/inc/connectivity/FValue.hxx index 4196e8d843d9..22a169f4025d 100644 --- a/connectivity/inc/connectivity/FValue.hxx +++ b/connectivity/inc/connectivity/FValue.hxx @@ -44,9 +44,15 @@ #include <com/sun/star/util/Time.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdb/XColumn.hpp> namespace connectivity { + namespace detail + { + class IValueSource; + } + class OOO_DLLPUBLIC_DBTOOLS ORowSetValue { union @@ -361,6 +367,12 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow); void fill(const ::com::sun::star::uno::Any& _rValue); + + void fill( const sal_Int32 _nType, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn ); + + private: + void impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource ); }; /// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted" diff --git a/connectivity/qa/connectivity/tools/DbaseDatabase.java b/connectivity/qa/connectivity/tools/DbaseDatabase.java index 9c1d6ea47411..8846c3995f56 100755 --- a/connectivity/qa/connectivity/tools/DbaseDatabase.java +++ b/connectivity/qa/connectivity/tools/DbaseDatabase.java @@ -65,7 +65,8 @@ public class DbaseDatabase extends AbstractDatabase private void createDBDocument() throws Exception { final File documentFile = File.createTempFile("dbase", ".odb"); - documentFile.deleteOnExit(); + if ( documentFile.exists() ) + documentFile.delete(); final File subPath = new File(documentFile.getParent() + File.separator + documentFile.getName().replaceAll(".odb", "") + File.separator ); subPath.mkdir(); //subPath.deleteOnExit(); diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java index d27816cf4b7e..593a5ad95981 100644 --- a/connectivity/qa/connectivity/tools/HsqlDatabase.java +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -71,7 +71,8 @@ public class HsqlDatabase extends AbstractDatabase private void createDBDocument() throws Exception { final File documentFile = File.createTempFile("testdb", ".odb"); - documentFile.deleteOnExit(); + if ( documentFile.exists() ) + documentFile.delete(); m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile); m_databaseDocument = (XOfficeDatabaseDocument) UnoRuntime.queryInterface( diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index cd09efa227fe..f7943fc4cf45 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -40,13 +40,16 @@ #include <rtl/ustrbuf.hxx> #include <rtl/logfile.hxx> -using namespace connectivity; -using namespace dbtools; +using namespace ::dbtools; using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; +namespace connectivity +{ + namespace { static sal_Bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2) { @@ -1809,6 +1812,107 @@ void ORowSetValue::setSigned(sal_Bool _bMod) } } } + +// ----------------------------------------------------------------------------- +namespace detail +{ + class SAL_NO_VTABLE IValueSource + { + public: + virtual ::rtl::OUString getString() const = 0; + virtual sal_Bool getBoolean() const = 0; + virtual sal_Int8 getByte() const = 0; + virtual sal_Int16 getShort() const = 0; + virtual sal_Int32 getInt() const = 0; + virtual sal_Int64 getLong() const = 0; + virtual float getFloat() const = 0; + virtual double getDouble() const = 0; + virtual Date getDate() const = 0; + virtual Time getTime() const = 0; + virtual DateTime getTimestamp() const = 0; + virtual Sequence< sal_Int8 > getBytes() const = 0; + virtual Reference< XInputStream > getBinaryStream() const = 0; + virtual Reference< XInputStream > getCharacterStream() const = 0; + virtual sal_Bool wasNull() const = 0; + + virtual ~IValueSource() { } + }; + + class RowValue : public IValueSource + { + public: + RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos ) + :m_xRow( _xRow ) + ,m_nPos( _nPos ) + { + } + + // IValueSource + virtual ::rtl::OUString getString() const { return m_xRow->getString( m_nPos ); }; + virtual sal_Bool getBoolean() const { return m_xRow->getBoolean( m_nPos ); }; + virtual sal_Int8 getByte() const { return m_xRow->getByte( m_nPos ); }; + virtual sal_Int16 getShort() const { return m_xRow->getShort( m_nPos ); } + virtual sal_Int32 getInt() const { return m_xRow->getInt( m_nPos ); } + virtual sal_Int64 getLong() const { return m_xRow->getLong( m_nPos ); } + virtual float getFloat() const { return m_xRow->getFloat( m_nPos ); }; + virtual double getDouble() const { return m_xRow->getDouble( m_nPos ); }; + virtual Date getDate() const { return m_xRow->getDate( m_nPos ); }; + virtual Time getTime() const { return m_xRow->getTime( m_nPos ); }; + virtual DateTime getTimestamp() const { return m_xRow->getTimestamp( m_nPos ); }; + virtual Sequence< sal_Int8 > getBytes() const { return m_xRow->getBytes( m_nPos ); }; + virtual Reference< XInputStream > getBinaryStream() const { return m_xRow->getBinaryStream( m_nPos ); }; + virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); }; + virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); }; + + private: + const Reference< XRow > m_xRow; + const sal_Int32 m_nPos; + }; + + class ColumnValue : public IValueSource + { + public: + ColumnValue( const Reference< XColumn >& _rxColumn ) + :m_xColumn( _rxColumn ) + { + } + + // IValueSource + virtual ::rtl::OUString getString() const { return m_xColumn->getString(); }; + virtual sal_Bool getBoolean() const { return m_xColumn->getBoolean(); }; + virtual sal_Int8 getByte() const { return m_xColumn->getByte(); }; + virtual sal_Int16 getShort() const { return m_xColumn->getShort(); } + virtual sal_Int32 getInt() const { return m_xColumn->getInt(); } + virtual sal_Int64 getLong() const { return m_xColumn->getLong(); } + virtual float getFloat() const { return m_xColumn->getFloat(); }; + virtual double getDouble() const { return m_xColumn->getDouble(); }; + virtual Date getDate() const { return m_xColumn->getDate(); }; + virtual Time getTime() const { return m_xColumn->getTime(); }; + virtual DateTime getTimestamp() const { return m_xColumn->getTimestamp(); }; + virtual Sequence< sal_Int8 > getBytes() const { return m_xColumn->getBytes(); }; + virtual Reference< XInputStream > getBinaryStream() const { return m_xColumn->getBinaryStream(); }; + virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); }; + virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); }; + + private: + const Reference< XColumn > m_xColumn; + }; +} + +// ----------------------------------------------------------------------------- +void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rxColumn ) +{ + detail::ColumnValue aColumnValue( _rxColumn ); + impl_fill( _nType, sal_True, aColumnValue ); +} + +// ----------------------------------------------------------------------------- +void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, sal_Bool _bNullable, const Reference< XRow>& _xRow ) +{ + detail::RowValue aRowValue( _xRow, _nPos ); + impl_fill( _nType, _bNullable, aRowValue ); +} + // ----------------------------------------------------------------------------- void ORowSetValue::fill(sal_Int32 _nPos, sal_Int32 _nType, @@ -1819,10 +1923,8 @@ void ORowSetValue::fill(sal_Int32 _nPos, } // ----------------------------------------------------------------------------- -void ORowSetValue::fill(sal_Int32 _nPos, - sal_Int32 _nType, - sal_Bool _bNullable, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow) +void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource ) + { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" ); sal_Bool bReadData = sal_True; @@ -1833,63 +1935,63 @@ void ORowSetValue::fill(sal_Int32 _nPos, case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR: - (*this) = _xRow->getString(_nPos); + (*this) = _rValueSource.getString(); break; case DataType::BIGINT: if ( isSigned() ) - (*this) = _xRow->getLong(_nPos); + (*this) = _rValueSource.getLong(); else - (*this) = _xRow->getString(_nPos); + (*this) = _rValueSource.getString(); break; case DataType::FLOAT: - (*this) = _xRow->getFloat(_nPos); + (*this) = _rValueSource.getFloat(); break; case DataType::DOUBLE: case DataType::REAL: - (*this) = _xRow->getDouble(_nPos); + (*this) = _rValueSource.getDouble(); break; case DataType::DATE: - (*this) = _xRow->getDate(_nPos); + (*this) = _rValueSource.getDate(); break; case DataType::TIME: - (*this) = _xRow->getTime(_nPos); + (*this) = _rValueSource.getTime(); break; case DataType::TIMESTAMP: - (*this) = _xRow->getTimestamp(_nPos); + (*this) = _rValueSource.getTimestamp(); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: - (*this) = _xRow->getBytes(_nPos); + (*this) = _rValueSource.getBytes(); break; case DataType::BIT: case DataType::BOOLEAN: - (*this) = _xRow->getBoolean(_nPos); + (*this) = _rValueSource.getBoolean(); break; case DataType::TINYINT: if ( isSigned() ) - (*this) = _xRow->getByte(_nPos); + (*this) = _rValueSource.getByte(); else - (*this) = _xRow->getShort(_nPos); + (*this) = _rValueSource.getShort(); break; case DataType::SMALLINT: if ( isSigned() ) - (*this) = _xRow->getShort(_nPos); + (*this) = _rValueSource.getShort(); else - (*this) = _xRow->getInt(_nPos); + (*this) = _rValueSource.getInt(); break; case DataType::INTEGER: if ( isSigned() ) - (*this) = _xRow->getInt(_nPos); + (*this) = _rValueSource.getInt(); else - (*this) = _xRow->getLong(_nPos); + (*this) = _rValueSource.getLong(); break; case DataType::CLOB: - (*this) = ::com::sun::star::uno::makeAny(_xRow->getCharacterStream(_nPos)); + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getCharacterStream()); setTypeKind(DataType::CLOB); break; case DataType::BLOB: - (*this) = ::com::sun::star::uno::makeAny(_xRow->getBinaryStream(_nPos)); + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBinaryStream()); setTypeKind(DataType::BLOB); break; default: @@ -1897,7 +1999,7 @@ void ORowSetValue::fill(sal_Int32 _nPos, bReadData = false; break; } - if ( bReadData && _bNullable && _xRow->wasNull() ) + if ( bReadData && _bNullable && _rValueSource.wasNull() ) setNull(); setTypeKind(_nType); } @@ -2043,3 +2145,5 @@ void ORowSetValue::fill(const Any& _rValue) break; } } + +} // namespace connectivity diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx index b3cbb4ae67c7..4c3f3db8b754 100644 --- a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx +++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx @@ -145,6 +145,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) throw(SQ } } + ::connectivity::ODatabaseMetaDataResultSet::ORows aTypeInfoRows; while( xRet->next() ) { ::connectivity::ODatabaseMetaDataResultSet::ORow aRow; @@ -169,8 +170,9 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) throw(SQ else ++aIter; } - m_aTypeInfoRows.push_back(aRow); + aTypeInfoRows.push_back(aRow); } + m_aTypeInfoRows = aTypeInfoRows; } } ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); diff --git a/connectivity/source/drivers/file/quotedstring.cxx b/connectivity/source/drivers/file/quotedstring.cxx index abd2d3b51e44..765c42eeeae2 100644 --- a/connectivity/source/drivers/file/quotedstring.cxx +++ b/connectivity/source/drivers/file/quotedstring.cxx @@ -152,7 +152,6 @@ namespace connectivity // Vorzeitiger Abbruch der Schleife moeglich, denn // wir haben, was wir wollten. nStartPos = i+1; - *pData = 0; break; } else @@ -161,6 +160,7 @@ namespace connectivity } } } // for( xub_StrLen i = nStartPos; i < nLen; ++i ) + *pData = 0; _rStr.ReleaseBufferAccess(xub_StrLen(pData - pStart)); } } diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 1e80a96cf682..7e97d27e1d86 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -55,6 +55,7 @@ #include <connectivity/dbexception.hxx> #include <comphelper/namedvaluecollection.hxx> #include <unotools/confignode.hxx> +#include <unotools/ucbstreamhelper.hxx> #include "resource/hsqldb_res.hrc" #include "resource/sharedresources.hxx" @@ -70,6 +71,8 @@ namespace connectivity using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::embed; + using namespace ::com::sun::star::io; + using namespace ::com::sun::star::task; using namespace ::com::sun::star::reflection; namespace hsqldb @@ -260,6 +263,50 @@ namespace connectivity ); aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) ); + const ::rtl::OUString sProperties( RTL_CONSTASCII_USTRINGPARAM( "properties" ) ); + ::rtl::OUString sMessage; + try + { + if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) ) + { + Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ); + if ( xStream.is() ) + { + ::std::auto_ptr<SvStream> pStream( ::utl::UcbStreamHelper::CreateStream(xStream) ); + if ( pStream.get() ) + { + ByteString sLine; + while ( pStream->ReadLine(sLine) ) + { + if ( sLine.Equals("version=",0,sizeof("version=")-1) ) + { + sLine = sLine.GetToken(1,'='); + const sal_Int32 nMajor = sLine.GetToken(0,'.').ToInt32(); + const sal_Int32 nMinor = sLine.GetToken(1,'.').ToInt32(); + const sal_Int32 nMicro = sLine.GetToken(2,'.').ToInt32(); + if ( nMajor > 1 + || ( nMajor == 1 && nMinor > 8 ) + || ( nMajor == 1 && nMinor == 8 && nMicro > 0 ) ) + { + ::connectivity::SharedResources aResources; + sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION); + } + break; + } + } + } + } // if ( xStream.is() ) + ::comphelper::disposeComponent(xStream); + } + } + catch(Exception&) + { + } + if ( sMessage.getLength() ) + { + ::dbtools::throwGenericSQLException(sMessage ,*this); + } + // readonly? Reference<XPropertySet> xProp(xStorage,UNO_QUERY); if ( xProp.is() ) diff --git a/connectivity/source/drivers/hsqldb/makefile.mk b/connectivity/source/drivers/hsqldb/makefile.mk index 9ed5acb17d4c..c61e4b297ba4 100644 --- a/connectivity/source/drivers/hsqldb/makefile.mk +++ b/connectivity/source/drivers/hsqldb/makefile.mk @@ -102,6 +102,7 @@ SHL1STDLIBS=\ $(DBTOOLSLIB) \ $(JVMFWKLIB) \ $(COMPHELPERLIB) \ + $(TOOLSLIB) \ $(UNOTOOLSLIB) diff --git a/connectivity/source/drivers/mozab/bootstrap/makefile.mk b/connectivity/source/drivers/mozab/bootstrap/makefile.mk index 9b4b05868cd2..00f76ddeb8fd 100644 --- a/connectivity/source/drivers/mozab/bootstrap/makefile.mk +++ b/connectivity/source/drivers/mozab/bootstrap/makefile.mk @@ -30,37 +30,35 @@ #************************************************************************* CALL_CDECL=TRUE -#mozilla specific stuff. -MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT) -MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla -#End of mozilla specific stuff. - PRJ=..$/..$/..$/.. PRJINC=..$/..$/.. PRJNAME=connectivity TARGET=mozbootstrap -USE_DEFFILE=TRUE -ENABLE_EXCEPTIONS=TRUE -VISIBILITY_HIDDEN=TRUE - .IF "$(OS)" == "OS2" all: @echo " Not building under OS/2" .ENDIF # --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF +USE_DEFFILE=TRUE +ENABLE_EXCEPTIONS=TRUE +VISIBILITY_HIDDEN=TRUE + +# --- begin of mozilla specific stuff +MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT) +MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla +# --- end of mozilla specific stuff .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/version.mk +.INCLUDE : ../makefile_mozab.mk + +INCPRE += -I../mozillasrc -#mozilla specific stuff. # --- Files ------------------------------------- SLOFILES += \ @@ -93,95 +91,6 @@ SLOFILES += \ $(SLO)$/MNSProfileDirServiceProvider.obj .ENDIF -CDEFS += -DMOZILLA_INTERNAL_API - -.IF "$(GUI)"=="UNX" -.IF "$(COMNAME)"=="sunpro5" -CFLAGS += -features=tmplife -#This flag is needed to build mozilla 1.7 code -.ENDIF # "$(COMNAME)"=="sunpro5" -.ENDIF - -MOZINC = . -I.. -I..$/mozillasrc -I$(MOZ_INC) -I$(MOZ_INC)$/nspr -I$(MOZ_INC)$/xpcom \ - -I$(MOZ_INC)$/string -I$(MOZ_INC)$/rdf -I$(MOZ_INC)$/msgbase \ - -I$(MOZ_INC)$/addrbook -I$(MOZ_INC)$/mork -I$(MOZ_INC)$/locale \ - -I$(MOZ_INC)$/pref -I$(MOZ_INC)$/mime -I$(MOZ_INC)$/chrome \ - -I$(MOZ_INC)$/necko -I$(MOZ_INC)$/intl -I$(MOZ_INC)$/profile \ - -I$(MOZ_INC)$/embed_base -I$(MOZ_INC)$/mozldap -I$(MOZ_INC)$/uconv\ - -I$(MOZ_INC)$/xpcom_obsolete -I$(MOZ_INC)$/content - -.IF "$(GUI)" == "WNT" -.IF "$(COM)" == "GCC" -INCPOST += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL -CFLAGSCXX += \ - -fno-rtti -Wall -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -.ELSE -.IF "$(DBG_LEVEL)" == "0" -INCPRE += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DDMSVC4 -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL \ - -UDEBUG -CFLAGS += -GR- -W3 -Gy -MD -UDEBUG -.ELSE -INCPRE += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DDMSVC4 -DDEVELOPER_DEBUG -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DDEBUG_Administrator -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL \ - -UDEBUG -CFLAGS += -Zi -GR- -W3 -Gy -MDd -UDEBUG -.IF "$(CCNUMVER)" >= "001399999999" -CDEFS += -D_STL_NOFORCE_MANIFEST -.ENDIF -.ENDIF -.ENDIF -.ENDIF -.IF "$(GUI)" == "UNX" -INCPOST += $(MOZINC) -CDEFS+= -DMOZILLA_CLIENT \ - -DXP_UNIX -.IF "$(OS)" == "LINUX" -CFLAGS += -fPIC -g -CDEFS+= -DOJI - -CFLAGSCXX += \ - -fno-rtti -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -pthread -CDEFS += -DTRACING -.ELIF "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX" -CFLAGS += -fPIC -CFLAGSCXX += \ - -fno-rtti -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -Wno-deprecated -CDEFS += -DTRACING -.ENDIF - -SHL1TARGET_NAME=$(TARGET)$(MOZAB_MAJOR) - -.ENDIF # MACOSX - # --- Targets ---------------------------------- .INCLUDE : target.mk diff --git a/connectivity/source/drivers/mozab/makefile.mk b/connectivity/source/drivers/mozab/makefile.mk index 677e605096c4..76161dc32119 100644 --- a/connectivity/source/drivers/mozab/makefile.mk +++ b/connectivity/source/drivers/mozab/makefile.mk @@ -43,38 +43,28 @@ all: @echo " see http://www.mozilla.org/issues/show_bug.cgi?id=91209" .ENDIF -#mozilla specific stuff. +# --- begin of mozilla specific stuff MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT) MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla .IF "$(OS)"=="WNT" -.IF "$(USE_SHELL)"=="4nt" -MOZ_EMBED_LIB := $(shell @+-dir /ba:f $(MOZ_LIB)$/embed_base_s.lib 2>NUL ) -MOZ_REG_LIB := $(shell @+-dir /ba:f $(MOZ_LIB)$/mozreg_s.lib 2>NUL ) -.ELSE #"$(USE_SHELL)"=="4nt" -MOZ_EMBED_LIB := $(shell @-test -f $(MOZ_LIB)$/embed_base_s.lib && echo $(MOZ_LIB)$/embed_base_s.lib ) -MOZ_REG_LIB := $(shell @-test -f $(MOZ_LIB)$/mozreg_s.lib && echo $(MOZ_LIB)$/mozreg_s.lib ) -.ENDIF + MOZ_EMBED_LIB := $(shell @-test -f $(MOZ_LIB)$/embed_base_s.lib && echo $(MOZ_LIB)$/embed_base_s.lib ) + MOZ_REG_LIB := $(shell @-test -f $(MOZ_LIB)$/mozreg_s.lib && echo $(MOZ_LIB)$/mozreg_s.lib ) -.IF X"$(MOZ_EMBED_LIB)"=="X" -MOZ_EMBED_LIB := $(MOZ_LIB)$/baseembed_s.lib -.ENDIF -.IF X"$(MOZ_REG_LIB)" == "X" -MOZ_REG_LIB := $(MOZ_LIB)$/mozreg.lib -.ENDIF -.ENDIF + MOZ_EMBED_LIB *:= $(MOZ_LIB)$/baseembed_s.lib + MOZ_REG_LIB *:= $(MOZ_LIB)$/mozreg.lib + + .IF "$(COM)"=="GCC" + MOZ_LIB_XPCOM= -L$(MOZ_LIB) -lembed_base_s -lnspr4 -lmozreg_s -lxpcom -lxpcom_core + .ELSE + LIB += $(MOZ_LIB) + MOZ_LIB_XPCOM= $(MOZ_EMBED_LIB) $(MOZ_LIB)$/nspr4.lib $(MOZ_REG_LIB) $(MOZ_LIB)$/xpcom.lib $(MOZ_LIB)$/xpcom_core.lib + .ENDIF -.IF "$(OS)"=="WNT" -.IF "$(COM)"=="GCC" -MOZ_LIB_XPCOM= -L$(MOZ_LIB) -lembed_base_s -lnspr4 -lmozreg_s -lxpcom -lxpcom_core -.ELSE -LIB += $(MOZ_LIB) -MOZ_LIB_XPCOM= $(MOZ_EMBED_LIB) $(MOZ_LIB)$/nspr4.lib $(MOZ_REG_LIB) $(MOZ_LIB)$/xpcom.lib $(MOZ_LIB)$/xpcom_core.lib -.ENDIF .ELSE "$(OS)"=="WNT" -MOZ_LIB_XPCOM= -L$(MOZ_LIB) -lnspr4 -lxpcom_core -lmozreg_s -lembed_base_s + MOZ_LIB_XPCOM = -L$(MOZ_LIB) -lnspr4 -lxpcom_core -lmozreg_s -lembed_base_s .ENDIF -#End of mozilla specific stuff. +# --- end of mozilla specific stuff USE_DEFFILE=TRUE ENABLE_EXCEPTIONS=TRUE @@ -87,10 +77,6 @@ COMPONENT_CONFIG_SCHEMA=$(TARGET)2.xcs # --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF - .INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk @@ -121,7 +107,6 @@ DEF1NAME= $(SHL1TARGET) DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \ $(SLB)$/$(TARGET).lib DEFLIB1NAME=$(TARGET) -#DEF1EXPORTFILE= exports.dxp # --- Files ------------------------------------- @@ -165,6 +150,7 @@ DEPOBJFILES=$(SLO2FILES) # --- MOZAB BASE Library ----------------------------------- SHL2VERSIONMAP= $(TARGET2).map +SHL2NOCHECK=TRUE SHL2TARGET= $(TARGET2)$(DLLPOSTFIX) SHL2OBJS=$(SLO2FILES) SHL2STDLIBS=\ diff --git a/connectivity/source/drivers/mozab/makefile_mozab.mk b/connectivity/source/drivers/mozab/makefile_mozab.mk new file mode 100644 index 000000000000..28b56ec2a84a --- /dev/null +++ b/connectivity/source/drivers/mozab/makefile_mozab.mk @@ -0,0 +1,128 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# 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. +# +#************************************************************************* + +CDEFS += -DMOZILLA_INTERNAL_API + +.IF "$(GUI)"=="UNX" + .IF "$(COMNAME)"=="sunpro5" + CFLAGS += -features=tmplife + #This flag is needed to build mozilla 1.7 code + .ENDIF # "$(COMNAME)"=="sunpro5" +.ENDIF + +MOZINC = . \ + -I.. \ + -I$(MOZ_INC) \ + -I$(MOZ_INC)$/nspr \ + -I$(MOZ_INC)$/xpcom \ + -I$(MOZ_INC)$/string \ + -I$(MOZ_INC)$/rdf \ + -I$(MOZ_INC)$/msgbase \ + -I$(MOZ_INC)$/addrbook \ + -I$(MOZ_INC)$/mork \ + -I$(MOZ_INC)$/locale \ + -I$(MOZ_INC)$/pref \ + -I$(MOZ_INC)$/mime \ + -I$(MOZ_INC)$/chrome \ + -I$(MOZ_INC)$/necko \ + -I$(MOZ_INC)$/intl \ + -I$(MOZ_INC)$/profile \ + -I$(MOZ_INC)$/embed_base \ + -I$(MOZ_INC)$/mozldap \ + -I$(MOZ_INC)$/uconv \ + -I$(MOZ_INC)$/xpcom_obsolete \ + -I$(MOZ_INC)$/content + +.IF "$(GUI)" == "WNT" + CDEFS += \ + -DMOZILLA_CLIENT \ + -DXP_PC \ + -DXP_WIN \ + -DXP_WIN32 \ + -DOJI \ + -DWIN32 \ + -D_X86_ \ + -D_WINDOWS \ + -DMOZ_XUL \ + -DMOZ_REFLOW_PERF \ + -DMOZ_REFLOW_PERF_DSP + .IF "$(COM)" == "GCC" + INCPOST += $(MOZINC) + CFLAGSCXX += \ + -fno-rtti \ + -Wall \ + -Wconversion \ + -Wpointer-arith \ + -Wcast-align \ + -Woverloaded-virtual \ + -Wsynth \ + -Wno-long-long + .ELSE # .IF "$(COM)" == "GCC" + INCPRE += $(MOZINC) + .IF "$(DBG_LEVEL)" != "0" + .IF "$(CCNUMVER)" >= "001399999999" + CDEFS += -D_STL_NOFORCE_MANIFEST + .ENDIF # .IF "$(CCNUMVER)" >= "001399999999" + .ENDIF # .IF "$(DBG_LEVEL)" != "0" + .ENDIF # .IF "$(COM)" == "GCC" +.ENDIF # .IF "$(GUI)" == "WNT" + +.IF "$(GUI)" == "UNX" + INCPOST += $(MOZINC) + CDEFS+= -DMOZILLA_CLIENT \ + -DXP_UNIX + .IF "$(OS)" == "LINUX" + CFLAGS += -fPIC -g + CDEFS += -DOJI + CFLAGSCXX += \ + -fno-rtti \ + -Wconversion \ + -Wpointer-arith \ + -Wcast-align \ + -Woverloaded-virtual \ + -Wsynth \ + -Wno-long-long \ + -pthread + CDEFS += -DTRACING + .ELIF "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX" + CFLAGS += -fPIC + CFLAGSCXX += \ + -fno-rtti \ + -Wconversion \ + -Wpointer-arith \ + -Wcast-align \ + -Woverloaded-virtual \ + -Wsynth \ + -Wno-long-long \ + -Wno-deprecated + CDEFS += -DTRACING + .ENDIF # "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX" + + SHL1TARGET_NAME=$(TARGET)$(MOZAB_MAJOR) + +.ENDIF # "$(GUI)" == "UNX" + diff --git a/connectivity/source/drivers/mozab/mozillasrc/makefile.mk b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk index e31d4c7e412b..1e5b39e0f140 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/makefile.mk +++ b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk @@ -40,16 +40,12 @@ PRJINC=..$/..$/.. PRJNAME=connectivity TARGET=mozabsrc +# --- Settings ---------------------------------- + USE_DEFFILE=TRUE ENABLE_EXCEPTIONS=TRUE VISIBILITY_HIDDEN=TRUE -# --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF - - .INCLUDE : settings.mk .IF ("$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || "$(WITH_MOZILLA)" == "NO" || "$(OS)" == "OS2" @@ -61,8 +57,10 @@ dummy: .INCLUDE : $(PRJ)$/version.mk +.INCLUDE : ../makefile_mozab.mk + +INCPRE += -I../bootstrap -#mozilla specific stuff. # --- Files ------------------------------------- SLOFILES = \ @@ -74,98 +72,9 @@ SLOFILES = \ $(SLO)$/MNSMozabProxy.obj \ $(SLO)$/MNSTerminateListener.obj \ $(SLO)$/MLdapAttributeMap.obj \ - - -CDEFS += -DMOZILLA_INTERNAL_API -.IF "$(GUI)"=="UNX" -.IF "$(COMNAME)"=="sunpro5" -CFLAGS += -features=tmplife -#This flag is needed to build mozilla 1.7 code -.ENDIF # "$(COMNAME)"=="sunpro5" .ENDIF -MOZINC = . -I.. -I..$/bootstrap -I$(MOZ_INC) -I$(MOZ_INC)$/nspr -I$(MOZ_INC)$/xpcom \ - -I$(MOZ_INC)$/string -I$(MOZ_INC)$/rdf -I$(MOZ_INC)$/msgbase \ - -I$(MOZ_INC)$/addrbook -I$(MOZ_INC)$/mork -I$(MOZ_INC)$/locale \ - -I$(MOZ_INC)$/pref -I$(MOZ_INC)$/mime -I$(MOZ_INC)$/chrome \ - -I$(MOZ_INC)$/necko -I$(MOZ_INC)$/intl -I$(MOZ_INC)$/profile \ - -I$(MOZ_INC)$/embed_base -I$(MOZ_INC)$/mozldap -I$(MOZ_INC)$/uconv\ - -I$(MOZ_INC)$/xpcom_obsolete -I$(MOZ_INC)$/content - -.IF "$(GUI)" == "WNT" -.IF "$(COM)"=="GCC" -INCPOST += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL -CFLAGSCXX += \ - -fno-rtti -Wall -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -.ELSE -.IF "$(DBG_LEVEL)" == "0" -INCPRE += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DDMSVC4 -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL \ - -UDEBUG -CFLAGS += -GR- -W3 -Gy -MD -UDEBUG -.ELSE -INCPRE += $(MOZINC) -CDEFS += -DWINVER=0x400 -DMOZILLA_CLIENT \ - -DNS_NET_FILE -DCookieManagement -DSingleSignon -DClientWallet \ - -DTRACING -DXP_PC -DXP_WIN -DXP_WIN32 -DHW_THREADS \ - -DDMSVC4 -DDEVELOPER_DEBUG -DNS_MT_SUPPORTED -DNETLIB_THREAD \ - -DOJI -DWIN32 -D_X86_ -D_WINDOWS \ - -DMOZ_XUL -DMOZ_REFLOW_PERF -DMOZ_REFLOW_PERF_DSP \ - -DDEBUG_Administrator -DNSPR20 -DOS_HAS_DLL -DNO_JNI_STUBS \ - -DNETSCAPE -DMOZILLA_CLIENT -DJS_THREADSAFE -DNECKO -DINCLUDE_XUL \ - -UDEBUG -CFLAGS += -Zi -GR- -W3 -Gy -MDd -UDEBUG -.IF "$(CCNUMVER)" >= "001399999999" -CDEFS += -D_STL_NOFORCE_MANIFEST -.ENDIF -.ENDIF -.ENDIF -.ENDIF -.IF "$(GUI)" == "UNX" -INCPOST += $(MOZINC) -CDEFS+= -DMOZILLA_CLIENT \ - -DXP_UNIX -.IF "$(OS)" == "LINUX" -CFLAGS += -fPIC -g -CDEFS+= -DOJI - -CFLAGSCXX += \ - -fno-rtti -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -pthread -CDEFS += -DTRACING -.ELIF "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX" -CFLAGS += -fPIC -CFLAGSCXX += \ - -fno-rtti -Wconversion -Wpointer-arith \ - -Wcast-align -Woverloaded-virtual -Wsynth \ - -Wno-long-long -Wno-deprecated -CDEFS += -DTRACING -.ENDIF -.ENDIF - -SHL1TARGET_NAME=$(TARGET)$(MOZAB_MAJOR) - -.ENDIF # MACOSX - # --- Targets ---------------------------------- .INCLUDE : target.mk diff --git a/connectivity/source/inc/resource/hsqldb_res.hrc b/connectivity/source/inc/resource/hsqldb_res.hrc index 3b7b9ef15c0a..b9066488d425 100644 --- a/connectivity/source/inc/resource/hsqldb_res.hrc +++ b/connectivity/source/inc/resource/hsqldb_res.hrc @@ -44,6 +44,7 @@ #define STR_NO_TABLE_EDITOR_DIALOG ( STR_HSQLDB_BASE + 3 ) #define STR_NO_TABLENAME ( STR_HSQLDB_BASE + 4 ) #define STR_NO_DOCUMENTUI ( STR_HSQLDB_BASE + 5 ) +#define STR_ERROR_NEW_VERSION ( STR_HSQLDB_BASE + 6 ) #endif // CONNECTIVITY_RESOURCE_HSQLDB_HRC diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index a1fd44014314..8d869c2dea0a 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2074,18 +2074,18 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) if ( SQL_ISRULE(p2ndSearch,boolean_primary) ) p2ndSearch = p2ndSearch->getChild(1); - if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) + if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b { pNewNode = pSearchCondition->removeAt((sal_uInt32)0); replaceAndReset(pSearchCondition,pNewNode); } - else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) + else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b { pNewNode = pSearchCondition->removeAt((sal_uInt32)2); replaceAndReset(pSearchCondition,pNewNode); } - else if ( p2ndSearch->getByRule(OSQLParseNode::boolean_term) ) + else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) ) { // a and ( b or c ) -> ( a and b ) or ( a and c ) // ( b or c ) and a -> ( a and b ) or ( a and c ) @@ -2096,7 +2096,13 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) OSQLParseNode* p1stAnd = MakeANDNode(pA,pB); OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC); pNewNode = MakeORNode(p1stAnd,p2ndAnd); - replaceAndReset(pSearchCondition,pNewNode); + OSQLParseNode* pNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); + pNode->append(pNewNode); + pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); + OSQLParseNode::eraseBraces(p1stAnd); + OSQLParseNode::eraseBraces(p2ndAnd); + replaceAndReset(pSearchCondition,pNode); } } // a or a and b || a or b and a diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index d143dad1ba0f..48ab06f0f635 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -645,3 +645,8 @@ String STR_NO_DOCUMENTUI { Text [ en-US ] = "The provided DocumentUI is not allowed to be NULL."; }; +String STR_ERROR_NEW_VERSION +{ + Text = "The connection could not be established. The database was created by a newer version of %PRODUCTNAME."; +}; + diff --git a/cppuhelper/inc/cppuhelper/weak.hxx b/cppuhelper/inc/cppuhelper/weak.hxx index f4b9c38d2215..9072ba6f6240 100644 --- a/cppuhelper/inc/cppuhelper/weak.hxx +++ b/cppuhelper/inc/cppuhelper/weak.hxx @@ -67,6 +67,12 @@ protected: */ virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** disposes and resets m_pWeakConnectionPoint + @precond + m_refCount equals 0 + */ + void disposeWeakConnectionPoint(); + /** reference count. @attention diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index 0c3f1c556d64..0961c6830d1f 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -379,3 +379,8 @@ UDK_3.6 { # OOo 3.0 __1cEcppuSOPropertySetHelper2t5B6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; __1cEcppuSOPropertySetHelper2t6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; } UDK_3.5; + +UDK_3.7 { # OOo 3.3 + global: + __1cEcppuLOWeakObjectbAdisposeWeakConnectionPoint6M_v_; +} UDK_3.6; diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx index d94614703be5..728f6815c309 100644 --- a/cppuhelper/source/component.cxx +++ b/cppuhelper/source/component.cxx @@ -90,6 +90,10 @@ void OComponentHelper::release() throw() { if (! rBHelper.bDisposed) { + // *before* again incrementing our ref count, ensure that our weak connection point + // will not create references to us anymore (via XAdapter::queryAdapted) + disposeWeakConnectionPoint(); + Reference<XInterface > xHoldAlive( *this ); // First dispose try diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 819c3e046b30..9348e91525c0 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -373,3 +373,9 @@ UDK_3.5 { # OOo 3.0 _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; } UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + _ZN4cppu11OWeakObject26disposeWeakConnectionPointEv; +} UDK_3.5; + diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx index 9caa4ca93615..acf05724c71b 100644 --- a/cppuhelper/source/implbase.cxx +++ b/cppuhelper/source/implbase.cxx @@ -247,6 +247,8 @@ void WeakComponentImplHelperBase::release() throw () { if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); // restore reference count: osl_incrementInterlockedCount( &m_refCount ); if (! rBHelper.bDisposed) { @@ -381,6 +383,8 @@ void WeakAggComponentImplHelperBase::release() OWeakAggObject::release(); } else if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); // restore reference count: osl_incrementInterlockedCount( &m_refCount ); if (! rBHelper.bDisposed) { diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index a90ec88f3ca3..c999ae200ac2 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -271,3 +271,8 @@ UDK_3.5 { # OOo 3.0 global: ??0OPropertySetHelper@cppu@@QAE@AAU?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@1@PAVIEventNotificationHook@1@_N@Z; } UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + ?disposeWeakConnectionPoint@OWeakObject@cppu@@IAEXXZ; +} UDK_3.5; diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx index 306ace09d592..6f2aa70ea2d5 100644 --- a/cppuhelper/source/tdmgr.cxx +++ b/cppuhelper/source/tdmgr.cxx @@ -688,17 +688,17 @@ static void SAL_CALL typelib_callback( catch (container::NoSuchElementException & exc) { (void) exc; // avoid warning about unused variable - OSL_ENSURE( - 0, OUStringToOString( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "typelibrary type not available: ") ) + + OSL_TRACE( + "typelibrary type not available: %s", + OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); } catch (Exception & exc) { (void) exc; // avoid warning about unused variable - OSL_ENSURE( - 0, OUStringToOString( + OSL_TRACE( + "%s", + OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); } } diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index c4055eba4f8a..b518d2526e3b 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -216,25 +216,31 @@ void SAL_CALL OWeakObject::release() throw() if (osl_decrementInterlockedCount( &m_refCount ) == 0) { // notify/clear all weak-refs before object's dtor is executed // (which may check weak-refs to this object): - if (m_pWeakConnectionPoint != 0) { - OWeakConnectionPoint * const p = m_pWeakConnectionPoint; - m_pWeakConnectionPoint = 0; - try { - p->dispose(); - } - catch (RuntimeException const& exc) { - OSL_ENSURE( - false, OUStringToOString( - exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); - static_cast<void>(exc); - } - p->release(); - } + disposeWeakConnectionPoint(); // destroy object: delete this; } } +void OWeakObject::disposeWeakConnectionPoint() +{ + OSL_PRECOND( m_refCount == 0, "OWeakObject::disposeWeakConnectionPoint: only to be called with a ref count of 0!" ); + if (m_pWeakConnectionPoint != 0) { + OWeakConnectionPoint * const p = m_pWeakConnectionPoint; + m_pWeakConnectionPoint = 0; + try { + p->dispose(); + } + catch (RuntimeException const& exc) { + OSL_ENSURE( + false, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + static_cast<void>(exc); + } + p->release(); + } +} + OWeakObject::~OWeakObject() SAL_THROW( (RuntimeException) ) { } diff --git a/dbaccess/inc/documentcontroller.hxx b/dbaccess/inc/documentcontroller.hxx index a16e4c645b06..2ca154625d90 100644 --- a/dbaccess/inc/documentcontroller.hxx +++ b/dbaccess/inc/documentcontroller.hxx @@ -72,18 +72,6 @@ namespace dbaui Controller m_xController; public: - /** constructs the object, and connects the controller to the model - - @param _rxModel - the model to which the controller should be connected - @param _rxController - the controller which should be connected to the model - */ - ModelControllerConnector( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController - ); - /** connects the controller to the model @param _rxModel diff --git a/dbaccess/inc/genericcontroller.hxx b/dbaccess/inc/genericcontroller.hxx index b4570bc1215b..8464f491ff66 100644 --- a/dbaccess/inc/genericcontroller.hxx +++ b/dbaccess/inc/genericcontroller.hxx @@ -531,7 +531,9 @@ namespace dbaui virtual void SAL_CALL removeMouseClickHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseClickHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException); protected: +#ifdef WNT OGenericUnoController(); // never implemented +#endif }; } diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java index c3661ef7ffee..df4aaa2f5cf9 100644 --- a/dbaccess/qa/complex/dbaccess/ApplicationController.java +++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java @@ -53,7 +53,7 @@ import java.io.IOException; /** complex test case for Base's application UI */ -public class ApplicationController extends complexlib.ComplexTestCase +public class ApplicationController extends TestCase { private HsqlDatabase m_database; @@ -66,22 +66,6 @@ public class ApplicationController extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - protected final XComponentContext getComponentContext() - { - XComponentContext context = null; - try - { - final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB()); - context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, - orbProps.getPropertyValue("DefaultContext")); - } - catch (Exception ex) - { - failed("could not retrieve the ComponentContext"); - } - return context; - } - // -------------------------------------------------------------------------------------------------------- public String[] getTestMethodNames() { @@ -98,12 +82,6 @@ public class ApplicationController extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory) param.getMSF(); - } - - // -------------------------------------------------------------------------------------------------------- private void impl_closeDocument() { if (m_database != null) @@ -143,15 +121,17 @@ public class ApplicationController extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - public void before() throws Exception, java.lang.Exception + public void before() throws java.lang.Exception { + super.before(); impl_switchToDocument(null); } // -------------------------------------------------------------------------------------------------------- - public void after() + public void after() throws java.lang.Exception { impl_closeDocument(); + super.after(); } // -------------------------------------------------------------------------------------------------------- @@ -161,9 +141,7 @@ public class ApplicationController extends complexlib.ComplexTestCase // then those changes are saved in the old document, actually final String oldDocumentURL = m_database.getDocumentURL(); - final File documentFile = java.io.File.createTempFile(getTestObjectName(), ".odb"); - documentFile.deleteOnExit(); - final String newDocumentURL = URLHelper.getFileURLFromSystemPath(documentFile.getAbsoluteFile()); + final String newDocumentURL = createTempFileURL(); // store the doc in a new location final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java index 57f51895e73c..8ce063bcdb2a 100644 --- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java @@ -64,6 +64,8 @@ import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.XSingleComponentFactory; import com.sun.star.lang.XTypeProvider; import com.sun.star.script.provider.XScriptProviderSupplier; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdbc.XDataSource; import com.sun.star.sdb.XFormDocumentsSupplier; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdb.XReportDocumentsSupplier; @@ -253,6 +255,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. return new String[] { "testLoadable", + "testDocumentRevenants", "testDocumentEvents", "testGlobalEvents" }; @@ -264,7 +267,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. return "DatabaseDocument"; } - public void before() + // -------------------------------------------------------------------------------------------------------- + public void before() throws java.lang.Exception { super.before(); @@ -292,10 +296,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- - public void after() + public void after() throws java.lang.Exception { - super.after(); - try { // dispose our callback factory. This will automatically remove it from our service @@ -313,6 +315,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. e.printStackTrace(System.err); failed("failed to close the test case"); } + + super.after(); } // -------------------------------------------------------------------------------------------------------- @@ -462,6 +466,27 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- + private PropertyValue[] impl_getMarkerLoadArgs() + { + return new PropertyValue[] + { + new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ), + new PropertyValue( "TestCase_Marker", 0, "Yes", PropertyState.DIRECT_VALUE ) + }; + } + + // -------------------------------------------------------------------------------------------------------- + private boolean impl_hasMarker( final PropertyValue[] _args ) + { + for ( int i=0; i<_args.length; ++i ) + { + if ( _args[i].Name.equals( "TestCase_Marker" ) && _args[i].Value.equals( "Yes" ) ) + return true; + } + return false; + } + + // -------------------------------------------------------------------------------------------------------- private PropertyValue[] impl_getDefaultLoadArgs() { return new PropertyValue[] @@ -505,7 +530,27 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- - public void testDocumentEvents() throws Exception, IOException + private XModel impl_loadDocument( final String _documentURL, final PropertyValue[] _loadArgs ) throws Exception + { + final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, + getORB().createInstance("com.sun.star.frame.Desktop") ); + return (XModel) UnoRuntime.queryInterface( XModel.class, + loader.loadComponentFromURL( _documentURL, _BLANK, 0, _loadArgs ) ); + } + + // -------------------------------------------------------------------------------------------------------- + private void impl_storeDocument( final XModel _document ) throws Exception, IOException + { + // store the document + final String documentURL = FileHelper.getOOoCompatibleFileURL( _document.getURL() ); + final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface( XStorable.class, + _document ); + storeDoc.store(); + + } + + // -------------------------------------------------------------------------------------------------------- + private XModel impl_createDocWithMacro( final String _libName, final String _moduleName, final String _code ) throws Exception, IOException { // create an empty document XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); @@ -514,7 +559,90 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class, databaseDoc); final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries(); - final XNameContainer newLib = basicLibs.createLibrary("EventHandlers"); + final XNameContainer newLib = basicLibs.createLibrary( _libName ); + newLib.insertByName( _moduleName, _code ); + + return databaseDoc; + } + + // -------------------------------------------------------------------------------------------------------- + /** tests various aspects of database document "revenants" + * + * Well, I do not really have a good term for this ... The point is, database documents are in real + * only *one* aspect of a more complex thing. The second aspect is a data source. Both, in some sense, + * just represent different views on the same thing. For a given database, there's at each time at most + * one data source, and at most one database document. Both have a independent life time, and are + * created when needed. + * In particular, a document can be closed (this is what happens when the last UI window displaying + * this document is closed), and then dies. Now when the other "view", the data source, still exists, + * the the underlying document data is not discarded, but kept alive (else the data source would die + * just because the document dies, which is not desired). If the document is loaded, again, then + * it is re-created, using the data of its previous "incarnation". + * + * This method here tests some of those aspects of a document which should survive the death of one + * instance and re-creation as a revenant. + */ + public void testDocumentRevenants() throws Exception, IOException + { + // create an empty document + XModel databaseDoc = impl_createDocWithMacro( "Lib", "Module", + "Sub Hello\n" + + " MsgBox \"Hello\"\n" + + "End Sub\n" + ); + impl_storeDocument( databaseDoc ); + final String documentURL = databaseDoc.getURL(); + + // at this stage, the marker should not yet be present in the doc's args, else some of the below + // tests become meaningless + assure( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) ); + + // obtain the DataSource associated with the document. Keeping this alive + // ensures that the "impl data" of the document is kept alive, too, so when closing + // and re-opening it, this "impl data" must be re-used. + XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( XDocumentDataSource.class, + ((XOfficeDatabaseDocument)UnoRuntime.queryInterface( + XOfficeDatabaseDocument.class, databaseDoc )).getDataSource() ); + + // close and reload the doc + impl_closeDocument(databaseDoc); + databaseDoc = impl_loadDocument( documentURL, impl_getMarkerLoadArgs() ); + // since we just put the marker into the load-call, it should be present at the doc + assure( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) ); + + // The basic library should have survived + final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class, + databaseDoc); + final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries(); + assure( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) ); + final XNameContainer lib = (XNameContainer)UnoRuntime.queryInterface( + XNameContainer.class, basicLibs.getByName( "Lib" ) ); + assure( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) ); + + // now closing the doc, and obtaining it from the data source, should preserve the marker we put into the load + // args + impl_closeDocument( databaseDoc ); + databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, dataSource.getDatabaseDocument() ); + assure( "The test case marker did not survive re-retrieval of the doc from the data source.", + impl_hasMarker( databaseDoc.getArgs() ) ); + + // on the other hand, closing and regurlarly re-loading the doc *without* the marker should indeed + // lose it + impl_closeDocument( databaseDoc ); + databaseDoc = impl_loadDocument( documentURL, impl_getDefaultLoadArgs() ); + assure( "Reloading the document kept the old args, instead of the newly supplied ones.", + !impl_hasMarker( databaseDoc.getArgs() ) ); + + // clean up + impl_closeDocument( databaseDoc ); + } + + // -------------------------------------------------------------------------------------------------------- + public void testDocumentEvents() throws Exception, IOException + { + // create an empty document + final String libName = "EventHandlers"; + final String moduleName = "all"; final String eventHandlerCode = "Option Explicit\n" + "\n" + @@ -530,10 +658,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. "\n" + " oCallback.documentEventOccured( oEvent )\n" + "End Sub\n"; - newLib.insertByName("all", eventHandlerCode); + XModel databaseDoc = impl_createDocWithMacro( libName, moduleName, eventHandlerCode ); + final String documentURL = databaseDoc.getURL(); // bind the macro to the OnLoad event - final String macroURI = "vnd.sun.star.script:EventHandlers.all.OnLoad?language=Basic&location=document"; + final String macroURI = "vnd.sun.star.script:" + libName + "." + moduleName + ".OnLoad?language=Basic&location=document"; final XEventsSupplier eventsSupplier = (XEventsSupplier) UnoRuntime.queryInterface(XEventsSupplier.class, databaseDoc); eventsSupplier.getEvents().replaceByName("OnLoad", new PropertyValue[] @@ -543,19 +672,13 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. }); // store the document, and close it - final String documentURL = FileHelper.getOOoCompatibleFileURL(databaseDoc.getURL()); - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, - databaseDoc); - storeDoc.store(); - impl_closeDocument(databaseDoc); + impl_storeDocument( databaseDoc ); + impl_closeDocument( databaseDoc ); // ensure the macro security configuration is "ask the user for document macro execution" final int oldSecurityLevel = impl_setMacroSecurityLevel(1); // load it, again - final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, - getORB().createInstance("com.sun.star.frame.Desktop")); - m_loadDocState = STATE_LOADING_DOC; // expected order of states is: // STATE_LOADING_DOC - initialized here @@ -568,8 +691,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. final String context = "OnLoad"; impl_startObservingEvents(context); - databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class, - loader.loadComponentFromURL(documentURL, _BLANK, 0, impl_getMacroExecLoadArgs())); + databaseDoc = impl_loadDocument( documentURL, impl_getMacroExecLoadArgs() ); impl_stopObservingEvents(m_documentEvents, new String[] { "OnLoad" @@ -789,7 +911,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // So, wait a few seconds. try { - _actualEvents.wait(5000); + _actualEvents.wait(20000); } catch (InterruptedException ex) { diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java index 1051b549c8f0..40370d9aeebd 100644 --- a/dbaccess/qa/complex/dbaccess/TestCase.java +++ b/dbaccess/qa/complex/dbaccess/TestCase.java @@ -67,12 +67,12 @@ public abstract class TestCase extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - public void before() + public void before() throws java.lang.Exception { } // -------------------------------------------------------------------------------------------------------- - public void after() + public void after() throws java.lang.Exception { } diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 8f84d073f83e..52670f7a9776 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -36,156 +36,55 @@ #include "sdbcoretools.hxx" #include "SingleSelectQueryComposer.hxx" #include "module_dba.hxx" +#include "sdbcoretools.hxx" +#include "CRowSetColumn.hxx" +#include "CRowSetDataColumn.hxx" +#include "RowSetCache.hxx" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "tablecontainer.hxx" -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _CPPUHELPER_INTERFACECONTAINER_H_ -#include <cppuhelper/interfacecontainer.h> -#endif -#ifndef _CPPUHELPER_EXC_HLP_HXX_ -#include <cppuhelper/exc_hlp.hxx> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX -#include <comphelper/componentcontext.hxx> -#endif -#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ -#include <com/sun/star/sdb/XCompletedConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> +#include <com/sun/star/sdb/RowChangeAction.hpp> #include <com/sun/star/sdb/RowSetVetoException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_ +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdbc/FetchDirection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ -#include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ -#include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ #include <com/sun/star/sdbc/XDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ -#include <com/sun/star/sdb/XQueriesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ROWCHANGEACTION_HPP_ -#include <com/sun/star/sdb/RowChangeAction.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_ -#include <com/sun/star/sdb/ErrorCondition.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ #include <com/sun/star/sdbc/XDriverAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ #include <com/sun/star/sdbcx/CompareBookmark.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ -#include <com/sun/star/uno/XNamingService.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX -#include "RowSetCache.hxx" -#endif -#if OSL_DEBUG_LEVEL > 1 -#ifndef _COM_SUN_STAR_SDBC_XDRIVERMANAGER_HPP_ -#include <com/sun/star/sdbc/XDriverManager.hpp> -#endif -#endif -#ifndef _DBACORE_DATACOLUMN_HXX_ -#include "CRowSetDataColumn.hxx" -#endif -#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX -#include "CRowSetColumn.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef _COMPHELPER_SEQSTREAM_HXX -#include <comphelper/seqstream.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H -#include <tools/diagnose_ex.h> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _DBA_CORE_TABLECONTAINER_HXX_ -#include "tablecontainer.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ -#include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefin |