diff options
105 files changed, 3828 insertions, 1571 deletions
diff --git a/accessibility/inc/accessibility/extended/AccessibleToolPanelDeck.hxx b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeck.hxx new file mode 100755 index 000000000000..10c6520b6a3d --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeck.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ACC_ACCESSIBLETOOLPANELDECK_HXX +#define ACC_ACCESSIBLETOOLPANELDECK_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> +#include <toolkit/awt/vclxaccessiblecomponent.hxx> + +#include <boost/scoped_ptr.hpp> + +namespace svt +{ + class ToolPanelDeck; +} + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + //================================================================================================================== + //= AccessibleToolPanelDeck + //================================================================================================================== + class AccessibleToolPanelDeck_Impl; + typedef VCLXAccessibleComponent AccessibleToolPanelDeck_Base; + class AccessibleToolPanelDeck : public AccessibleToolPanelDeck_Base + { + public: + AccessibleToolPanelDeck( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck + ); + + using AccessibleToolPanelDeck_Base::NotifyAccessibleEvent; + + protected: + virtual ~AccessibleToolPanelDeck(); + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); + + // XAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // VCLXAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& i_rVclWindowEvent ); + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ); + + private: + ::boost::scoped_ptr< AccessibleToolPanelDeck_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... + +#endif // ACC_ACCESSIBLETOOLPANELDECK_HXX diff --git a/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBar.hxx b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBar.hxx new file mode 100644 index 000000000000..cc2d39c5acbf --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBar.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ACC_ACCESSIBLETOOLPANELTABBAR_HXX +#define ACC_ACCESSIBLETOOLPANELTABBAR_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> +#include <toolkit/awt/vclxaccessiblecomponent.hxx> + +#include <boost/scoped_ptr.hpp> + +namespace svt +{ + class IToolPanelDeck; + class PanelTabBar; +} + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + //================================================================================================================== + //= AccessibleToolPanelTabBar + //================================================================================================================== + class AccessibleToolPanelTabBar_Impl; + typedef VCLXAccessibleComponent AccessibleToolPanelTabBar_Base; + class AccessibleToolPanelTabBar : public AccessibleToolPanelTabBar_Base + { + public: + AccessibleToolPanelTabBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar + ); + + using AccessibleToolPanelTabBar_Base::NotifyAccessibleEvent; + + protected: + virtual ~AccessibleToolPanelTabBar(); + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); + + // XAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // VCLXAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& i_rVclWindowEvent ); + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ); + + private: + ::boost::scoped_ptr< AccessibleToolPanelTabBar_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... + +#endif // ACC_ACCESSIBLETOOLPANELTABBAR_HXX diff --git a/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx new file mode 100644 index 000000000000..80b2ccaaf104 --- /dev/null +++ b/accessibility/inc/accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ACC_ACCESSIBLETOOLPANELDECKTABBARITEM_HXX +#define ACC_ACCESSIBLETOOLPANELDECKTABBARITEM_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <comphelper/accessiblecomponenthelper.hxx> +#include <cppuhelper/implbase1.hxx> + +#include <boost/scoped_ptr.hpp> + +namespace svt +{ + class IToolPanelDeck; + class PanelTabBar; +} + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + //================================================================================================================== + //= AccessibleToolPanelDeckTabBarItem + //================================================================================================================== + class AccessibleToolPanelDeckTabBarItem_Impl; + typedef ::comphelper::OAccessibleExtendedComponentHelper AccessibleToolPanelDeckTabBarItem_Base; + class AccessibleToolPanelDeckTabBarItem : public AccessibleToolPanelDeckTabBarItem_Base + { + public: + AccessibleToolPanelDeckTabBarItem( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar, + const size_t i_nItemPos + ); + + using AccessibleToolPanelDeckTabBarItem_Base::NotifyAccessibleEvent; + using AccessibleToolPanelDeckTabBarItem_Base::lateInit; + + protected: + virtual ~AccessibleToolPanelDeckTabBarItem(); + + public: + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); + + // XAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grabFocus( ) 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); + + // XAccessibleExtendedComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getToolTipText( ) throw (::com::sun::star::uno::RuntimeException); + + protected: + // OCommonAccessibleComponent + virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + protected: + ::boost::scoped_ptr< AccessibleToolPanelDeckTabBarItem_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... + +#endif // ACC_ACCESSIBLETOOLPANELDECKTABBARITEM_HXX diff --git a/accessibility/inc/accessibility/helper/accessiblestrings.hrc b/accessibility/inc/accessibility/helper/accessiblestrings.hrc index 859da828beb1..1f936e678b98 100644 --- a/accessibility/inc/accessibility/helper/accessiblestrings.hrc +++ b/accessibility/inc/accessibility/helper/accessiblestrings.hrc @@ -45,7 +45,8 @@ #define RID_STR_ACC_ACTION_DECBLOCK ( RID_TK_ACC_START + 6 ) -#define RID_STR_ACC_NAME_BROWSEBUTTON ( RID_TK_ACC_START + 1000 ) +#define RID_STR_ACC_NAME_BROWSEBUTTON ( RID_TK_ACC_START + 100 ) +#define RID_STR_ACC_DESC_PANELDECL_TABBAR ( RID_TK_ACC_START + 101 ) // ----------------------------------------------------------------------------- diff --git a/accessibility/inc/accessibility/standard/vclxaccessibletoolbox.hxx b/accessibility/inc/accessibility/standard/vclxaccessibletoolbox.hxx index 168938d50a6c..7283cec6a95c 100644 --- a/accessibility/inc/accessibility/standard/vclxaccessibletoolbox.hxx +++ b/accessibility/inc/accessibility/standard/vclxaccessibletoolbox.hxx @@ -57,6 +57,7 @@ private: void UpdateAllItems_Impl(); void UpdateItemName_Impl( sal_Int32 _nPos ); void UpdateItemEnabled_Impl( sal_Int32 _nPos ); + void UpdateCustomPopupItemp_Impl( Window* pWindow, bool bOpen ); void HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent, bool _bShow ); void ReleaseSubToolBox( ToolBox* _pSubToolBox ); diff --git a/accessibility/source/extended/AccessibleToolPanelDeck.cxx b/accessibility/source/extended/AccessibleToolPanelDeck.cxx new file mode 100755 index 000000000000..6976b221a8b5 --- /dev/null +++ b/accessibility/source/extended/AccessibleToolPanelDeck.cxx @@ -0,0 +1,412 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_accessibility.hxx" + +#include "accessibility/extended/AccessibleToolPanelDeck.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ + +#include <svtools/toolpanel/toolpaneldeck.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <tools/diagnose_ex.h> + +#include <boost/noncopyable.hpp> +#include <vector> + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessible; + using ::com::sun::star::accessibility::XAccessibleContext; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::accessibility::XAccessibleRelationSet; + using ::com::sun::star::accessibility::XAccessibleStateSet; + using ::com::sun::star::accessibility::IllegalAccessibleComponentStateException; + using ::com::sun::star::awt::XFont; + /** === end UNO using === **/ + namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType; + + typedef ::com::sun::star::awt::Rectangle UnoRectangle; + typedef ::com::sun::star::awt::Point UnoPoint; + + //================================================================================================================== + //= AccessibleToolPanelDeck_Impl - declaration + //================================================================================================================== + class AccessibleToolPanelDeck_Impl :public ::boost::noncopyable + ,public ::svt::IToolPanelDeckListener + { + public: + AccessibleToolPanelDeck_Impl( + AccessibleToolPanelDeck& i_rAntiImpl, + const Reference< XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck + ); + + void checkDisposed(); + bool isDisposed() const { return m_pPanelDeck == NULL; } + void dispose(); + + ~AccessibleToolPanelDeck_Impl(); + + Reference< XAccessible > getOwnAccessible() const; + Reference< XAccessible > getActivePanelAccessible(); + + protected: + // IToolPanelDeckListener + virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + public: + AccessibleToolPanelDeck& m_rAntiImpl; + Reference< XAccessible > m_xAccessibleParent; + ::svt::ToolPanelDeck* m_pPanelDeck; + + typedef ::std::vector< Reference< XAccessible > > AccessibleChildren; + Reference< XAccessible > m_xActivePanelAccessible; + }; + + //================================================================================================================== + //= MethodGuard + //================================================================================================================== + namespace + { + class MethodGuard + { + public: + MethodGuard( AccessibleToolPanelDeck_Impl& i_rImpl ) + :m_aGuard( Application::GetSolarMutex() ) + { + i_rImpl.checkDisposed(); + } + ~MethodGuard() + { + } + + void clear() + { + m_aGuard.clear(); + } + + private: + ::vos::OClearableGuard m_aGuard; + }; + } + + //================================================================================================================== + //= AccessibleToolPanelDeck_Impl - implementation + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeck_Impl::AccessibleToolPanelDeck_Impl( AccessibleToolPanelDeck& i_rAntiImpl, const Reference< XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck ) + :m_rAntiImpl( i_rAntiImpl ) + ,m_xAccessibleParent( i_rAccessibleParent ) + ,m_pPanelDeck( &i_rPanelDeck ) + ,m_xActivePanelAccessible() + { + m_pPanelDeck->AddListener( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeck_Impl::~AccessibleToolPanelDeck_Impl() + { + if ( !isDisposed() ) + dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::dispose() + { + ENSURE_OR_RETURN_VOID( !isDisposed(), "disposed twice" ); + m_pPanelDeck->RemoveListener( *this ); + m_pPanelDeck = NULL; + m_xAccessibleParent.clear(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::checkDisposed() + { + if ( isDisposed() ) + throw DisposedException( ::rtl::OUString(), *&m_rAntiImpl ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelDeck_Impl::getOwnAccessible() const + { + Reference< XAccessible > xOwnAccessible( static_cast< XAccessible* >( m_rAntiImpl.GetVCLXWindow() ) ); + OSL_ENSURE( xOwnAccessible->getAccessibleContext() == Reference< XAccessibleContext >( &m_rAntiImpl ), + "AccessibleToolPanelDeck_Impl::getOwnAccessible: could not retrieve proper XAccessible for /myself!" ); + return xOwnAccessible; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelDeck_Impl::getActivePanelAccessible() + { + ENSURE_OR_RETURN( !isDisposed(), "AccessibleToolPanelDeck_Impl::getActivePanelAccessible: already disposed!", NULL ); + + if ( !m_xActivePanelAccessible.is() ) + { + ::boost::optional< size_t > aActivePanel( m_pPanelDeck->GetActivePanel() ); + ENSURE_OR_RETURN( !!aActivePanel, "AccessibleToolPanelDeck_Impl::getActivePanelAccessible: this should not be called without an active panel!", NULL ); + ::svt::PToolPanel pActivePanel( m_pPanelDeck->GetPanel( *aActivePanel ) ); + ENSURE_OR_RETURN( pActivePanel.get() != NULL, "AccessibleToolPanelDeck_Impl::getActivePanelAccessible: no active panel!", NULL ); + m_xActivePanelAccessible = pActivePanel->CreatePanelAccessible( getOwnAccessible() ); + OSL_ENSURE( m_xActivePanelAccessible.is(), "AccessibleToolPanelDeck_Impl::getActivePanelAccessible: illegal accessible returned by the panel!" ); + } + + return m_xActivePanelAccessible; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ) + { + (void)i_pPanel; + (void)i_nPosition; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::PanelRemoved( const size_t i_nPosition ) + { + (void)i_nPosition; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + if ( !!i_rOldActive ) + { + if ( !m_xActivePanelAccessible.is() ) + { + // again, this might in theory happen if the XAccessible for the active panel has never before been requested. + // In this case, just say that all our children are invalid, so they all must be re-requested. + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any() ); + } + else + { + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::CHILD, makeAny( m_xActivePanelAccessible ), Any() ); + } + } + + m_xActivePanelAccessible.clear(); + + if ( !!i_rNewActive ) + { + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), makeAny( getActivePanelAccessible() ) ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ) + { + MethodGuard aGuard( *this ); + + (void)i_rNewLayouter; + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck_Impl::Dying() + { + // the tool panel deck is dying, so dispose ourself + m_rAntiImpl.dispose(); + } + + //================================================================================================================== + //= AccessibleToolPanelDeck + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeck::AccessibleToolPanelDeck( const Reference< XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck ) + :AccessibleToolPanelDeck_Base( i_rPanelDeck.GetWindowPeer() ) + ,m_pImpl( new AccessibleToolPanelDeck_Impl( *this, i_rAccessibleParent, i_rPanelDeck ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeck::~AccessibleToolPanelDeck() + { + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 SAL_CALL AccessibleToolPanelDeck::getAccessibleChildCount( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + sal_Int32 nChildCount( m_pImpl->m_pPanelDeck->GetLayouter()->GetAccessibleChildCount() ); + + ::boost::optional< size_t > aActivePanel( m_pImpl->m_pPanelDeck->GetActivePanel() ); + if ( !!aActivePanel ) + return ++nChildCount; + + return nChildCount; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeck::getAccessibleChild( sal_Int32 i_nIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + const sal_Int32 nChildCount( getAccessibleChildCount() ); + if ( ( i_nIndex < 0 ) || ( i_nIndex >= nChildCount ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + // first "n" children are provided by the layouter + const size_t nLayouterCount( m_pImpl->m_pPanelDeck->GetLayouter()->GetAccessibleChildCount() ); + if ( size_t( i_nIndex ) < nLayouterCount ) + return m_pImpl->m_pPanelDeck->GetLayouter()->GetAccessibleChild( + size_t( i_nIndex ), + m_pImpl->getOwnAccessible() + ); + + // the last child is the XAccessible of the active panel + return m_pImpl->getActivePanelAccessible(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeck::getAccessibleParent( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + const Reference< XAccessible > xParent = implGetForeignControlledParent(); + if ( xParent.is() ) + return xParent; + return m_pImpl->m_xAccessibleParent; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int16 SAL_CALL AccessibleToolPanelDeck::getAccessibleRole( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + return AccessibleRole::PANEL; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeck::getAccessibleAtPoint( const UnoPoint& i_rPoint ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + const ::Point aRequestedPoint( VCLUnoHelper::ConvertToVCLPoint( i_rPoint ) ); + // check the panel window itself + const ::Window& rActivePanelAnchor( m_pImpl->m_pPanelDeck->GetPanelWindowAnchor() ); + const Rectangle aPanelAnchorArea( rActivePanelAnchor.GetPosPixel(), rActivePanelAnchor.GetOutputSizePixel() ); + if ( aPanelAnchorArea.IsInside( aRequestedPoint ) ) + // note that this assumes that the Window which actually implements the concrete panel covers + // the complete area of its "anchor" Window. But this is ensured by the ToolPanelDeck implementation. + return m_pImpl->getActivePanelAccessible(); + + // check the XAccessible instances provided by the layouter + try + { + const ::svt::PDeckLayouter pLayouter( m_pImpl->m_pPanelDeck->GetLayouter() ); + ENSURE_OR_THROW( pLayouter.get() != NULL, "invalid layouter" ); + + const size_t nLayouterChildren = pLayouter->GetAccessibleChildCount(); + for ( size_t i=0; i<nLayouterChildren; ++i ) + { + const Reference< XAccessible > xLayoutItemAccessible( pLayouter->GetAccessibleChild( i, m_pImpl->getOwnAccessible() ), UNO_SET_THROW ); + const Reference< XAccessibleComponent > xLayoutItemComponent( xLayoutItemAccessible->getAccessibleContext(), UNO_QUERY_THROW ); + const ::Rectangle aLayoutItemBounds( VCLUnoHelper::ConvertToVCLRect( xLayoutItemComponent->getBounds() ) ); + if ( aLayoutItemBounds.IsInside( aRequestedPoint ) ) + return xLayoutItemAccessible; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AccessibleToolPanelDeck::grabFocus( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + m_pImpl->m_pPanelDeck->GrabFocus(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AccessibleToolPanelDeck::disposing() + { + AccessibleToolPanelDeck_Base::disposing(); + m_pImpl->dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelDeck::GetChildAccessible( const VclWindowEvent& i_rVclWindowEvent ) + { + // don't let the base class generate any A11Y events from VclWindowEvent, we completely manage those + // A11Y events ourself + (void)i_rVclWindowEvent; + return NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeck::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ) + { + AccessibleToolPanelDeck_Base::FillAccessibleStateSet( i_rStateSet ); + if ( m_pImpl->isDisposed() ) + { + i_rStateSet.AddState( AccessibleStateType::DEFUNC ); + } + else + { + i_rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + } + } + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... diff --git a/accessibility/source/extended/AccessibleToolPanelDeckTabBar.cxx b/accessibility/source/extended/AccessibleToolPanelDeckTabBar.cxx new file mode 100644 index 000000000000..7e97e3714172 --- /dev/null +++ b/accessibility/source/extended/AccessibleToolPanelDeckTabBar.cxx @@ -0,0 +1,459 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_accessibility.hxx" + +#include "accessibility/extended/AccessibleToolPanelDeckTabBar.hxx" +#include "accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx" +#include "accessibility/helper/accresmgr.hxx" +#include "accessibility/helper/accessiblestrings.hrc" + +/** === begin UNO includes === **/ +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ + +#include <svtools/toolpanel/toolpaneldeck.hxx> +#include <svtools/toolpanel/paneltabbar.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/button.hxx> +#include <vos/mutex.hxx> +#include <tools/diagnose_ex.h> + +#include <vector> + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessible; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::accessibility::XAccessibleContext; + /** === end UNO using === **/ + + namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType; + + typedef ::com::sun::star::awt::Point UnoPoint; + typedef ::com::sun::star::awt::Size UnoSize; + typedef ::com::sun::star::awt::Rectangle UnoRectangle; + + //================================================================================================================== + //= AccessibleWrapper + //================================================================================================================== + typedef ::cppu::WeakImplHelper1< XAccessible > AccessibleWrapper_Base; + class AccessibleWrapper : public AccessibleWrapper_Base + { + public: + AccessibleWrapper( const Reference< XAccessibleContext >& i_rContext ) + :m_xContext( i_rContext ) + { + } + + // XAccessible + virtual Reference< XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (RuntimeException) + { + return m_xContext; + } + + private: + const Reference< XAccessibleContext > m_xContext; + }; + + //================================================================================================================== + //= AccessibleToolPanelTabBar_Impl + //================================================================================================================== + class AccessibleToolPanelTabBar_Impl :public ::boost::noncopyable + ,public ::svt::IToolPanelDeckListener + { + public: + AccessibleToolPanelTabBar_Impl( + AccessibleToolPanelTabBar& i_rAntiImpl, + const Reference< XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar + ); + ~AccessibleToolPanelTabBar_Impl(); + + void checkDisposed(); + bool isDisposed() const { return m_pPanelDeck == NULL; } + void dispose(); + + ::svt::IToolPanelDeck* getPanelDeck() const { return m_pPanelDeck; } + ::svt::PanelTabBar* getTabBar() const { return m_pTabBar; } + const Reference< XAccessible >& getAccessibleParent() const { return m_xAccessibleParent; } + Reference< XAccessible > getAccessiblePanelItem( size_t i_nPosition ); + Reference< XAccessible > getOwnAccessible() const; + + protected: + // IToolPanelDeckListener + virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + DECL_LINK( OnWindowEvent, const VclSimpleEvent* ); + + private: + AccessibleToolPanelTabBar& m_rAntiImpl; + Reference< XAccessible > m_xAccessibleParent; + ::svt::IToolPanelDeck* m_pPanelDeck; + ::svt::PanelTabBar* m_pTabBar; + ::std::vector< Reference< XAccessible > > m_aChildren; + }; + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelTabBar_Impl::AccessibleToolPanelTabBar_Impl( AccessibleToolPanelTabBar& i_rAntiImpl, + const Reference< XAccessible >& i_rAccessibleParent, ::svt::IToolPanelDeck& i_rPanelDeck, ::svt::PanelTabBar& i_rTabBar ) + :m_rAntiImpl( i_rAntiImpl ) + ,m_xAccessibleParent( i_rAccessibleParent ) + ,m_pPanelDeck( &i_rPanelDeck ) + ,m_pTabBar( &i_rTabBar ) + ,m_aChildren() + { + m_pPanelDeck->AddListener( *this ); + m_aChildren.resize( m_pPanelDeck->GetPanelCount() ); + + const String sAccessibleDescription( TK_RES_STRING( RID_STR_ACC_DESC_PANELDECL_TABBAR ) ); + i_rTabBar.SetAccessibleName( sAccessibleDescription ); + i_rTabBar.SetAccessibleDescription( sAccessibleDescription ); + + i_rTabBar.GetScrollButton( true ).AddEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); + i_rTabBar.GetScrollButton( false ).AddEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::checkDisposed() + { + if ( isDisposed() ) + throw DisposedException( ::rtl::OUString(), *&m_rAntiImpl ); + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelTabBar_Impl::~AccessibleToolPanelTabBar_Impl() + { + if ( !isDisposed() ) + dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::dispose() + { + ENSURE_OR_RETURN_VOID( !isDisposed(), "disposed twice" ); + m_pPanelDeck->RemoveListener( *this ); + m_pPanelDeck = NULL; + + m_pTabBar->GetScrollButton( true ).RemoveEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); + m_pTabBar->GetScrollButton( false ).RemoveEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); + m_pTabBar = NULL; + + m_xAccessibleParent.clear(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelTabBar_Impl::getAccessiblePanelItem( size_t i_nPosition ) + { + ENSURE_OR_RETURN( !isDisposed(), "AccessibleToolPanelTabBar_Impl::getAccessiblePanelItem: already disposed!", NULL ); + ENSURE_OR_RETURN( i_nPosition < m_aChildren.size(), "AccessibleToolPanelTabBar_Impl::getAccessiblePanelItem: invalid index!", NULL ); + + Reference< XAccessible >& rAccessibleChild( m_aChildren[ i_nPosition ] ); + if ( !rAccessibleChild.is() ) + { + ::rtl::Reference< AccessibleToolPanelDeckTabBarItem > pAccesibleItemContext( new AccessibleToolPanelDeckTabBarItem( + getOwnAccessible(), *m_pPanelDeck, *m_pTabBar, i_nPosition ) ); + rAccessibleChild.set( new AccessibleWrapper( pAccesibleItemContext.get() ) ); + pAccesibleItemContext->lateInit( rAccessibleChild ); + } + return rAccessibleChild; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelTabBar_Impl::getOwnAccessible() const + { + Reference< XAccessible > xOwnAccessible( static_cast< XAccessible* >( m_rAntiImpl.GetVCLXWindow() ) ); + OSL_ENSURE( xOwnAccessible->getAccessibleContext() == Reference< XAccessibleContext >( &m_rAntiImpl ), + "AccessibleToolPanelTabBar_Impl::getOwnAccessible: could not retrieve proper XAccessible for /myself!" ); + return xOwnAccessible; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ) + { + ENSURE_OR_RETURN_VOID( i_nPosition <= m_aChildren.size(), "AccessibleToolPanelTabBar_Impl::PanelInserted: illegal position (or invalid cache!)" ); + (void)i_pPanel; + m_aChildren.insert( m_aChildren.begin() + i_nPosition, NULL ); + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), makeAny( getAccessiblePanelItem( i_nPosition ) ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::PanelRemoved( const size_t i_nPosition ) + { + ENSURE_OR_RETURN_VOID( i_nPosition < m_aChildren.size(), "AccessibleToolPanelTabBar_Impl::PanelInserted: illegal position (or invalid cache!)" ); + + const Reference< XAccessible > xOldChild( getAccessiblePanelItem( i_nPosition ) ); + m_aChildren.erase( m_aChildren.begin() + i_nPosition ); + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::CHILD, makeAny( xOldChild ), Any() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + (void)i_rOldActive; + (void)i_rNewActive; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ) + { + (void)i_rNewLayouter; + m_rAntiImpl.dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar_Impl::Dying() + { + m_rAntiImpl.dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + IMPL_LINK( AccessibleToolPanelTabBar_Impl, OnWindowEvent, const VclSimpleEvent*, i_pEvent ) + { + ENSURE_OR_RETURN( !isDisposed(), "AccessibleToolPanelTabBar_Impl::OnWindowEvent: already disposed!", 0L ); + + const VclWindowEvent* pWindowEvent( dynamic_cast< const VclWindowEvent* >( i_pEvent ) ); + if ( !pWindowEvent ) + return 0L; + + const bool bForwardButton = ( pWindowEvent->GetWindow() == &m_pTabBar->GetScrollButton( true ) ); + const bool bBackwardButton = ( pWindowEvent->GetWindow() == &m_pTabBar->GetScrollButton( false ) ); + ENSURE_OR_RETURN( bForwardButton || bBackwardButton, "AccessibleToolPanelTabBar_Impl::OnWindowEvent: where does this come from?", 0L ); + + const bool bShow = ( i_pEvent->GetId() == VCLEVENT_WINDOW_SHOW ); + const bool bHide = ( i_pEvent->GetId() == VCLEVENT_WINDOW_HIDE ); + if ( !bShow && !bHide ) + // not interested in events other than visibility changes + return 0L; + + const Reference< XAccessible > xButtonAccessible( m_pTabBar->GetScrollButton( bForwardButton ).GetAccessible() ); + const Any aOldChild( bHide ? xButtonAccessible : Reference< XAccessible >() ); + const Any aNewChild( bShow ? xButtonAccessible : Reference< XAccessible >() ); + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldChild, aNewChild ); + + return 1L; + } + + //================================================================================================================== + //= MethodGuard + //================================================================================================================== + namespace + { + class MethodGuard + { + public: + MethodGuard( AccessibleToolPanelTabBar_Impl& i_rImpl ) + :m_aGuard( Application::GetSolarMutex() ) + { + i_rImpl.checkDisposed(); + } + ~MethodGuard() + { + } + + void clear() + { + m_aGuard.clear(); + } + + private: + ::vos::OClearableGuard m_aGuard; + }; + } + + //================================================================================================================== + //= AccessibleToolPanelTabBar + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelTabBar::AccessibleToolPanelTabBar( const Reference< XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, ::svt::PanelTabBar& i_rTabBar ) + :AccessibleToolPanelTabBar_Base( i_rTabBar.GetWindowPeer() ) + ,m_pImpl( new AccessibleToolPanelTabBar_Impl( *this, i_rAccessibleParent, i_rPanelDeck, i_rTabBar ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelTabBar::~AccessibleToolPanelTabBar() + { + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 SAL_CALL AccessibleToolPanelTabBar::getAccessibleChildCount( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + const bool bHasScrollBack = m_pImpl->getTabBar()->GetScrollButton( false ).IsVisible(); + const bool bHasScrollForward = m_pImpl->getTabBar()->GetScrollButton( true ).IsVisible(); + + return m_pImpl->getPanelDeck()->GetPanelCount() + + ( bHasScrollBack ? 1 : 0 ) + + ( bHasScrollForward ? 1 : 0 ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelTabBar::getAccessibleChild( sal_Int32 i_nIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + const bool bHasScrollBack = m_pImpl->getTabBar()->GetScrollButton( false ).IsVisible(); + const bool bHasScrollForward = m_pImpl->getTabBar()->GetScrollButton( true ).IsVisible(); + + const bool bScrollBackRequested = ( bHasScrollBack && ( i_nIndex == 0 ) ); + const bool bScrollForwardRequested = ( bHasScrollForward && ( i_nIndex == getAccessibleChildCount() - 1 ) ); + OSL_ENSURE( !( bScrollBackRequested && bScrollForwardRequested ), "AccessibleToolPanelTabBar::getAccessibleChild: ouch!" ); + + if ( bScrollBackRequested || bScrollForwardRequested ) + { + Reference< XAccessible > xScrollButtonAccessible( m_pImpl->getTabBar()->GetScrollButton( bScrollForwardRequested ).GetAccessible() ); + ENSURE_OR_RETURN( xScrollButtonAccessible.is(), "AccessibleToolPanelTabBar::getAccessibleChild: invalid button accessible!", NULL ); + #if OSL_DEBUG_LEVEL > 0 + Reference< XAccessibleContext > xScrollButtonContext( xScrollButtonAccessible->getAccessibleContext() ); + ENSURE_OR_RETURN( xScrollButtonContext.is(), "AccessibleToolPanelTabBar::getAccessibleChild: invalid button accessible context!", xScrollButtonAccessible ); + OSL_ENSURE( xScrollButtonContext->getAccessibleParent() == m_pImpl->getOwnAccessible(), + "AccessibleToolPanelTabBar::getAccessibleChild: wrong parent at the button's accesible!" ); + #endif + return xScrollButtonAccessible; + } + + return m_pImpl->getAccessiblePanelItem( i_nIndex - ( bHasScrollBack ? 1 : 0 ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelTabBar::getAccessibleParent( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + return m_pImpl->getAccessibleParent(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int16 SAL_CALL AccessibleToolPanelTabBar::getAccessibleRole( ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + return AccessibleRole::PAGE_TAB_LIST; + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + bool lcl_covers( const ::Window& i_rWindow, const ::Point& i_rPoint ) + { + const Rectangle aWindowBounds( i_rWindow.GetWindowExtentsRelative( i_rWindow.GetParent() ) ); + return aWindowBounds.IsInside( i_rPoint ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL AccessibleToolPanelTabBar::getAccessibleAtPoint( const UnoPoint& i_rPoint ) throw (RuntimeException) + { + MethodGuard aGuard( *m_pImpl ); + + // check the tab items + const UnoPoint aOwnScreenPos( getLocationOnScreen() ); + const ::Point aRequestedScreenPoint( i_rPoint.X + aOwnScreenPos.X, i_rPoint.Y + aOwnScreenPos.Y ); + + for ( size_t i=0; i<m_pImpl->getPanelDeck()->GetPanelCount(); ++i ) + { + const ::Rectangle aItemScreenRect( m_pImpl->getTabBar()->GetItemScreenRect(i) ); + if ( aItemScreenRect.IsInside( aRequestedScreenPoint ) ) + return m_pImpl->getAccessiblePanelItem(i); + } + + // check the scroll buttons + const ::Point aRequestedClientPoint( VCLUnoHelper::ConvertToVCLPoint( i_rPoint ) ); + + const bool bHasScrollBack = m_pImpl->getTabBar()->GetScrollButton( false ).IsVisible(); + if ( bHasScrollBack && lcl_covers( m_pImpl->getTabBar()->GetScrollButton( false ), aRequestedClientPoint ) ) + return m_pImpl->getTabBar()->GetScrollButton( false ).GetAccessible(); + + const bool bHasScrollForward = m_pImpl->getTabBar()->GetScrollButton( true ).IsVisible(); + if ( bHasScrollForward && lcl_covers( m_pImpl->getTabBar()->GetScrollButton( true ), aRequestedClientPoint ) ) + return m_pImpl->getTabBar()->GetScrollButton( true ).GetAccessible(); + + // no hit + return NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AccessibleToolPanelTabBar::disposing() + { + AccessibleToolPanelTabBar_Base::disposing(); + m_pImpl->dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > AccessibleToolPanelTabBar::GetChildAccessible( const VclWindowEvent& i_rVclWindowEvent ) + { + // don't let the base class generate any A11Y events from VclWindowEvent, we completely manage those + // A11Y events ourself + (void)i_rVclWindowEvent; + return NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelTabBar::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ) + { + AccessibleToolPanelTabBar_Base::FillAccessibleStateSet( i_rStateSet ); + i_rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + + ENSURE_OR_RETURN_VOID( !m_pImpl->isDisposed(), "AccessibleToolPanelTabBar::FillAccessibleStateSet: already disposed!" ); + if ( m_pImpl->getTabBar()->IsVertical() ) + i_rStateSet.AddState( AccessibleStateType::VERTICAL ); + else + i_rStateSet.AddState( AccessibleStateType::HORIZONTAL ); + } + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... diff --git a/accessibility/source/extended/AccessibleToolPanelDeckTabBarItem.cxx b/accessibility/source/extended/AccessibleToolPanelDeckTabBarItem.cxx new file mode 100644 index 000000000000..0cdfd8480457 --- /dev/null +++ b/accessibility/source/extended/AccessibleToolPanelDeckTabBarItem.cxx @@ -0,0 +1,455 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_accessibility.hxx" + +#include "accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ + +#include <svtools/toolpanel/toolpaneldeck.hxx> +#include <svtools/toolpanel/paneltabbar.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <unotools/accessiblerelationsethelper.hxx> +#include <tools/diagnose_ex.h> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +//...................................................................................................................... +namespace accessibility +{ +//...................................................................................................................... + + typedef ::com::sun::star::awt::Rectangle UnoRectangle; + typedef ::com::sun::star::awt::Point UnoPoint; + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessible; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::accessibility::XAccessibleRelationSet; + using ::com::sun::star::accessibility::XAccessibleStateSet; + using ::com::sun::star::accessibility::XAccessibleComponent; + using ::com::sun::star::accessibility::XAccessibleExtendedComponent; + using ::com::sun::star::awt::XFont; + /** === end UNO using === **/ + + namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; + namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType; + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + + //================================================================================================================== + //= AccessibleToolPanelDeckTabBarItem_Impl + //================================================================================================================== + class AccessibleToolPanelDeckTabBarItem_Impl : public ::svt::IToolPanelDeckListener + { + public: + AccessibleToolPanelDeckTabBarItem_Impl( + AccessibleToolPanelDeckTabBarItem& i_rAntiImpl, + const Reference< XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar, + const size_t i_nItemPos + ); + ~AccessibleToolPanelDeckTabBarItem_Impl(); + + ::svt::PanelTabBar* getTabBar() const { return m_pTabBar; } + + // IToolPanelDeckListener + virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + public: + bool isDisposed() const { return m_pPanelDeck == NULL; } + void checkDisposed() const; + void dispose(); + + const Reference< XAccessible >& + getAccessibleParent() const { return m_xAccessibleParent; } + size_t getItemPos() const { return m_nItemPos; } + + Reference< XAccessibleComponent > getParentAccessibleComponent() const; + ::svt::IToolPanelDeck* getPanelDeck() const { return m_pPanelDeck; } + ::rtl::OUString getPanelDisplayName(); + + private: + void impl_notifyBoundRectChanges(); + void impl_notifyStateChange( const sal_Int16 i_nLostState, const sal_Int16 i_nGainedState ); + + private: + AccessibleToolPanelDeckTabBarItem& m_rAntiImpl; + Reference< XAccessible > m_xAccessibleParent; + ::svt::IToolPanelDeck* m_pPanelDeck; + ::svt::PanelTabBar* m_pTabBar; + size_t m_nItemPos; + }; + + //================================================================================================================== + //= AccessibleToolPanelDeckTabBarItem_Impl + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeckTabBarItem_Impl::AccessibleToolPanelDeckTabBarItem_Impl( AccessibleToolPanelDeckTabBarItem& i_rAntiImpl, + const Reference< XAccessible >& i_rAccessibleParent, ::svt::IToolPanelDeck& i_rPanelDeck, ::svt::PanelTabBar& i_rTabBar, + const size_t i_nItemPos ) + :m_rAntiImpl( i_rAntiImpl ) + ,m_xAccessibleParent( i_rAccessibleParent ) + ,m_pPanelDeck( &i_rPanelDeck ) + ,m_pTabBar( &i_rTabBar ) + ,m_nItemPos( i_nItemPos ) + { + m_pPanelDeck->AddListener( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeckTabBarItem_Impl::~AccessibleToolPanelDeckTabBarItem_Impl() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::checkDisposed() const + { + if ( isDisposed() ) + throw DisposedException( ::rtl::OUString(), *&m_rAntiImpl ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::dispose() + { + ENSURE_OR_RETURN_VOID( !isDisposed(), "AccessibleToolPanelDeckTabBarItem_Impl::dispose: disposed twice!" ); + + m_xAccessibleParent.clear(); + m_pPanelDeck->RemoveListener( *this ); + m_pPanelDeck = NULL; + m_pTabBar = NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessibleComponent > AccessibleToolPanelDeckTabBarItem_Impl::getParentAccessibleComponent() const + { + Reference< XAccessible > xAccessibleParent( m_rAntiImpl.getAccessibleParent(), UNO_QUERY_THROW ); + return Reference< XAccessibleComponent >( xAccessibleParent->getAccessibleContext(), UNO_QUERY ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString AccessibleToolPanelDeckTabBarItem_Impl::getPanelDisplayName() + { + const ::svt::PToolPanel pPanel( m_pPanelDeck->GetPanel( getItemPos() ) ); + if ( pPanel.get() == NULL ) + throw DisposedException(); + return pPanel->GetDisplayName(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::impl_notifyBoundRectChanges() + { + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::impl_notifyStateChange( const sal_Int16 i_nLostState, const sal_Int16 i_nGainedState ) + { + m_rAntiImpl.NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, + i_nLostState > -1 ? makeAny( i_nLostState ) : Any(), + i_nGainedState > -1 ? makeAny( i_nGainedState ) : Any() + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ) + { + (void)i_pPanel; + if ( i_nPosition <= m_nItemPos ) + ++m_nItemPos; + impl_notifyBoundRectChanges(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::PanelRemoved( const size_t i_nPosition ) + { + if ( i_nPosition == m_nItemPos ) + { + m_rAntiImpl.dispose(); + } + else if ( i_nPosition < m_nItemPos ) + { + --m_nItemPos; + impl_notifyBoundRectChanges(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + if ( m_nItemPos == i_rOldActive ) + { + impl_notifyStateChange( AccessibleStateType::ACTIVE, -1 ); + impl_notifyStateChange( AccessibleStateType::SELECTED, -1 ); + } + else if ( m_nItemPos == i_rNewActive ) + { + impl_notifyStateChange( -1, AccessibleStateType::ACTIVE ); + impl_notifyStateChange( -1, AccessibleStateType::SELECTED ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ) + { + (void)i_rNewLayouter; + // if the tool panel deck has a new layouter, then the old layouter, and thus all items it was + // responsible for, died. So do we. + dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + void AccessibleToolPanelDeckTabBarItem_Impl::Dying() + { + // if the tool panel deck is dying, then its layouter dies, so should we. + dispose(); + } + + //================================================================================================================== + //= ItemMethodGuard + //================================================================================================================== + class ItemMethodGuard + { + public: + ItemMethodGuard( AccessibleToolPanelDeckTabBarItem_Impl& i_rImpl ) + :m_aGuard( Application::GetSolarMutex() ) + { + i_rImpl.checkDisposed(); + } + ~ItemMethodGuard() + { + } + + void clear() + { + m_aGuard.clear(); + } + + private: + ::vos::OClearableGuard m_aGuard; + }; + + //================================================================================================================== + //= AccessibleToolPanelDeckTabBarItem + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeckTabBarItem::AccessibleToolPanelDeckTabBarItem( const Reference< XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, ::svt::PanelTabBar& i_rTabBar, const size_t i_nItemPos ) + :m_pImpl( new AccessibleToolPanelDeckTabBarItem_Impl( *this, i_rAccessibleParent, i_rPanelDeck, i_rTabBar, i_nItemPos ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AccessibleToolPanelDeckTabBarItem::~AccessibleToolPanelDeckTabBarItem() + { + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleChildCount( ) throw (RuntimeException) + { + return 0; + } + + //-------------------------------------------------------------------- + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) + { + (void)i; + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + } + + //-------------------------------------------------------------------- + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleParent( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getAccessibleParent(); + } + + //-------------------------------------------------------------------- + sal_Int16 SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleRole( ) throw (RuntimeException) + { + return AccessibleRole::PAGE_TAB; + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleDescription( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getPanelDisplayName(); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleName( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getPanelDisplayName(); + } + + //-------------------------------------------------------------------- + Reference< XAccessibleRelationSet > SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleRelationSet( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + ::utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper; + return pRelationSet; + } + + //-------------------------------------------------------------------- + Reference< XAccessibleStateSet > SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleStateSet( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + + ::utl::AccessibleStateSetHelper* pStateSet( new ::utl::AccessibleStateSetHelper ); + pStateSet->AddState( AccessibleStateType::FOCUSABLE ); + pStateSet->AddState( AccessibleStateType::SELECTABLE ); + pStateSet->AddState( AccessibleStateType::ICONIFIED ); + + if ( m_pImpl->getItemPos() == m_pImpl->getPanelDeck()->GetActivePanel() ) + { + pStateSet->AddState( AccessibleStateType::ACTIVE ); + pStateSet->AddState( AccessibleStateType::SELECTED ); + } + + if ( m_pImpl->getItemPos() == m_pImpl->getTabBar()->GetFocusedPanelItem() ) + pStateSet->AddState( AccessibleStateType::FOCUSED ); + + if ( m_pImpl->getTabBar()->IsEnabled() ) + pStateSet->AddState( AccessibleStateType::ENABLED ); + + if ( m_pImpl->getTabBar()->IsVisible() ) + { + pStateSet->AddState( AccessibleStateType::SHOWING ); + pStateSet->AddState( AccessibleStateType::VISIBLE ); + } + + return pStateSet; + } + + + //-------------------------------------------------------------------- + Reference< XAccessible > SAL_CALL AccessibleToolPanelDeckTabBarItem::getAccessibleAtPoint( const UnoPoint& i_rLocation ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + // we do not have children ... + (void)i_rLocation; + return NULL; + } + + //-------------------------------------------------------------------- + void SAL_CALL AccessibleToolPanelDeckTabBarItem::grabFocus( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + m_pImpl->getTabBar()->FocusPanelItem( m_pImpl->getItemPos() ); + } + + //-------------------------------------------------------------------- + ::sal_Int32 SAL_CALL AccessibleToolPanelDeckTabBarItem::getForeground( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + Reference< XAccessibleComponent > xParentComponent( m_pImpl->getParentAccessibleComponent(), UNO_SET_THROW ); + return xParentComponent->getForeground(); + } + + //-------------------------------------------------------------------- + ::sal_Int32 SAL_CALL AccessibleToolPanelDeckTabBarItem::getBackground( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + Reference< XAccessibleComponent > xParentComponent( m_pImpl->getParentAccessibleComponent(), UNO_SET_THROW ); + return xParentComponent->getBackground(); + } + + //-------------------------------------------------------------------- + Reference< XFont > SAL_CALL AccessibleToolPanelDeckTabBarItem::getFont( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + Reference< XAccessibleExtendedComponent > xParentComponent( m_pImpl->getParentAccessibleComponent(), UNO_QUERY_THROW ); + // TODO: strictly, this is not correct: The TabBar implementation of the TabLayouter might use + // a different font ... + return xParentComponent->getFont(); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL AccessibleToolPanelDeckTabBarItem::getTitledBorderText( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + // no support + return ::rtl::OUString(); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL AccessibleToolPanelDeckTabBarItem::getToolTipText( ) throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getPanelDisplayName(); + } + + //-------------------------------------------------------------------- + UnoRectangle SAL_CALL AccessibleToolPanelDeckTabBarItem::implGetBounds() throw (RuntimeException) + { + ItemMethodGuard aGuard( *m_pImpl ); + + const ::Rectangle aItemScreenRect( m_pImpl->getTabBar()->GetItemScreenRect( m_pImpl->getItemPos() ) ); + + Reference< XAccessibleComponent > xParentComponent( m_pImpl->getParentAccessibleComponent(), UNO_SET_THROW ); + const UnoPoint aParentLocation( xParentComponent->getLocationOnScreen() ); + return UnoRectangle( + aItemScreenRect.Left() - aParentLocation.X, + aItemScreenRect.Top() - aParentLocation.Y, + aItemScreenRect.GetWidth(), + aItemScreenRect.GetHeight() + ); + } + + //-------------------------------------------------------------------- + void SAL_CALL AccessibleToolPanelDeckTabBarItem::disposing() + { + ItemMethodGuard aGuard( *m_pImpl ); + m_pImpl->dispose(); + } + +//...................................................................................................................... +} // namespace accessibility +//...................................................................................................................... diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx index a352ed51a78c..0468cce97d94 100644 --- a/accessibility/source/extended/accessiblelistbox.cxx +++ b/accessibility/source/extended/accessiblelistbox.cxx @@ -131,8 +131,8 @@ namespace accessibility break; // --> OD 2009-04-01 #i92103# - case VCLEVENT_LISTBOX_ENTRY_EXPANDED : - case VCLEVENT_LISTBOX_ENTRY_COLLAPSED : + case VCLEVENT_ITEM_EXPANDED : + case VCLEVENT_ITEM_COLLAPSED : { SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() ); if ( pEntry ) @@ -141,7 +141,7 @@ namespace accessibility new AccessibleListBoxEntry( *getListBox(), pEntry, this ); Reference< XAccessible > xChild = pAccListBoxEntry; const short nAccEvent = - ( rVclWindowEvent.GetId() == VCLEVENT_LISTBOX_ENTRY_EXPANDED ) + ( rVclWindowEvent.GetId() == VCLEVENT_ITEM_EXPANDED ) ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED; uno::Any aListBoxEntry; diff --git a/accessibility/source/extended/makefile.mk b/accessibility/source/extended/makefile.mk index 446ec73ec1b7..27f4403c8210 100644..100755 --- a/accessibility/source/extended/makefile.mk +++ b/accessibility/source/extended/makefile.mk @@ -70,7 +70,10 @@ SLOFILES=\ $(SLO)$/AccessibleGridControlHeader.obj \ $(SLO)$/AccessibleGridControlTableCell.obj \ $(SLO)$/AccessibleGridControlHeaderCell.obj \ - $(SLO)$/AccessibleGridControlTable.obj + $(SLO)$/AccessibleGridControlTable.obj \ + $(SLO)$/AccessibleToolPanelDeck.obj \ + $(SLO)$/AccessibleToolPanelDeckTabBar.obj \ + $(SLO)$/AccessibleToolPanelDeckTabBarItem.obj # --- Targets ------------------------------------------------------- diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index 50d3ac682377..7279b5e2ff60 100644..100755 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -29,18 +29,12 @@ #include "precompiled_accessibility.hxx" #include <accessibility/helper/acc_factory.hxx> -#ifndef _TOOLKIT_AWT_VCLXWINDOWS_HXX #include <toolkit/awt/vclxwindows.hxx> -#endif #include <accessibility/standard/vclxaccessiblebutton.hxx> #include <accessibility/standard/vclxaccessiblecheckbox.hxx> -#ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLEDROPDOWCOMBOBOX_HXX #include <accessibility/standard/vclxaccessibledropdowncombobox.hxx> -#endif #include <accessibility/standard/vclxaccessiblecombobox.hxx> -#ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLEDROPDOWLISTBOX_HXX #include <accessibility/standard/vclxaccessibledropdownlistbox.hxx> -#endif #include <accessibility/standard/vclxaccessibleedit.hxx> #include <accessibility/standard/vclxaccessiblefixedhyperlink.hxx> #include <accessibility/standard/vclxaccessiblefixedtext.hxx> @@ -67,13 +61,17 @@ #include <accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx> #include <accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx> #include <accessibility/extended/accessibleeditbrowseboxcell.hxx> +#include <accessibility/extended/AccessibleToolPanelDeck.hxx> +#include <accessibility/extended/AccessibleToolPanelDeckTabBar.hxx> +#include <accessibility/extended/AccessibleToolPanelDeckTabBarItem.hxx> #include <vcl/lstbox.hxx> #include <vcl/combobox.hxx> #include <accessibility/extended/AccessibleGridControl.hxx> #include <svtools/accessibletable.hxx> -#include "vcl/popupmenuwindow.hxx" +#include <vcl/popupmenuwindow.hxx> +#include <cppuhelper/implbase1.hxx> -#include <floatingwindowaccessible.hxx> +#include "floatingwindowaccessible.hxx" //........................................................................ namespace accessibility @@ -227,6 +225,18 @@ inline bool hasFloatingChild(Window *pWindow) sal_uInt16 _nColPos ) const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelDeck( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck + ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelTabBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar + ); + protected: virtual ~AccessibleFactory(); }; @@ -508,6 +518,20 @@ inline bool hasFloatingChild(Window *pWindow) _rxFocusWindow, _rBrowseBox, _nRowPos, _nColPos ); } + //-------------------------------------------------------------------- + Reference< XAccessibleContext > AccessibleFactory::createAccessibleToolPanelDeck( + const Reference< XAccessible >& i_rAccessibleParent, ::svt::ToolPanelDeck& i_rPanelDeck ) + { + return new AccessibleToolPanelDeck( i_rAccessibleParent, i_rPanelDeck ); + } + + //-------------------------------------------------------------------- + Reference< XAccessibleContext > AccessibleFactory::createAccessibleToolPanelTabBar( + const Reference< XAccessible >& i_rAccessibleParent, ::svt::IToolPanelDeck& i_rPanelDeck, ::svt::PanelTabBar& i_rTabBar ) + { + return new AccessibleToolPanelTabBar( i_rAccessibleParent, i_rPanelDeck, i_rTabBar ); + } + //........................................................................ } // namespace accessibility //........................................................................ diff --git a/accessibility/source/helper/accessiblestrings.src b/accessibility/source/helper/accessiblestrings.src index 4df1391f3c1d..ee7f77f9b502 100644 --- a/accessibility/source/helper/accessiblestrings.src +++ b/accessibility/source/helper/accessiblestrings.src @@ -70,3 +70,7 @@ String RID_STR_ACC_NAME_BROWSEBUTTON Text [ en-US ] = "Browse"; }; +String RID_STR_ACC_DESC_PANELDECL_TABBAR +{ + Text [ en-US ] = "Panel Deck Tab Bar"; +}; diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index 52b7a7f83cab..ce796af77ab4 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -441,6 +441,26 @@ void VCLXAccessibleToolBox::UpdateAllItems_Impl() } } } + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( Window* pWindow, bool bOpen ) +{ + ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + if( pWindow && pToolBox ) + { + Reference< XAccessible > xChild( pWindow->GetAccessible() ); + if( xChild.is() ) + { + Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( pToolBox->GetDownItemId() ) ) ) ); + VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() ); + + pItem->SetChild( xChild ); + pItem->NotifyChildEvent( xChild, bOpen ); + } + } +} + // ----------------------------------------------------------------------------- void VCLXAccessibleToolBox::UpdateItemName_Impl( sal_Int32 _nPos ) { @@ -582,6 +602,13 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow break; } + case VCLEVENT_DROPDOWN_OPEN: + case VCLEVENT_DROPDOWN_CLOSE: + { + UpdateCustomPopupItemp_Impl( static_cast< Window* >( rVclWindowEvent.GetData() ), rVclWindowEvent.GetId() == VCLEVENT_DROPDOWN_OPEN ); + break; + } + case VCLEVENT_OBJECT_DYING : { // if this toolbox is a subtoolbox, we have to relese it from its parent diff --git a/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java b/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java index 02ec7fea2232..6e8e45bc4e82 100644 --- a/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java +++ b/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java @@ -588,28 +588,39 @@ public class AccessibilityWorkBench javax.swing.tree.TreePath aPath = aEvent.getPath(); maTree.scrollPathToVisible (aPath); Object aObject = aPath.getLastPathComponent(); - if (aObject instanceof XAccessible) { - XAccessible xAccessible = (XAccessible) aObject; - if (maObjectViewContainer != null) { - ((AccessibilityModel) maTree.getModel()).addEventListener((TreeNode) aObject, maObjectViewContainer); - maObjectViewContainer.SetObject (xAccessible.getAccessibleContext()); - } + implSetCurrentObject( aObject ); + if (aObject instanceof XAccessible) + { + if (maObjectViewContainer != null) + maObjectViewContainer.SetObject( ((XAccessible)aObject).getAccessibleContext() ); } if (maCanvas != null) maCanvas.SelectObject ((TreeNode) aObject); setCursor (aCursor); } else { - if (maObjectViewContainer != null) { - ((AccessibilityModel) maTree.getModel()).removeEventListener((TreeNode) aEvent.getPath().getLastPathComponent(), maObjectViewContainer); + implSetCurrentObject( aEvent.getPath().getLastPathComponent() ); + if (maObjectViewContainer != null) maObjectViewContainer.SetObject (null); - } if (maCanvas != null) maCanvas.SelectObject (null); } } - + private void implSetCurrentObject( Object i_object ) + { + if ( maObjectViewContainer == null ) + return; + if ( maCurrentObject != null ) + { + AccessibilityModel.removeEventListener( (TreeNode)maCurrentObject, maObjectViewContainer ); + } + maCurrentObject = i_object; + if ( maCurrentObject != null ) + { + AccessibilityModel.addEventListener( (TreeNode)maCurrentObject, maObjectViewContainer ); + } + } // XEventListener public void disposing (EventObject aSourceObj) @@ -687,4 +698,5 @@ public class AccessibilityWorkBench maShapesButton; private JMenuBar maMenuBar; private boolean mbInitialized; + private Object maCurrentObject = null; } diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java index 93823e9a1941..81a499aabf0d 100644 --- a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java @@ -75,8 +75,7 @@ class AccessibilityNode extends DefaultMutableTreeNode implements XAccessible, if (xAccessibleContext != null) { try { XAccessibleEventBroadcaster xAccessibleEventBroadcaster = - (XAccessibleEventBroadcaster) UnoRuntime.queryInterface( - XAccessibleEventBroadcaster.class, xAccessibleContext); + UnoRuntime.queryInterface( XAccessibleEventBroadcaster.class, xAccessibleContext ); if (xAccessibleEventBroadcaster != null) { if (attach) { xAccessibleEventBroadcaster.addEventListener(this); @@ -91,9 +90,9 @@ class AccessibilityNode extends DefaultMutableTreeNode implements XAccessible, } public void disposing(com.sun.star.lang.EventObject eventObject) { - XAccessibleEventListener listener = this.listener; - if (listener != null) { - listener.disposing(eventObject); + XAccessibleEventListener localListener = this.listener; + if (localListener != null) { + localListener.disposing(eventObject); } treeModel.removeNode(userObject); @@ -135,22 +134,20 @@ class AccessibilityNode extends DefaultMutableTreeNode implements XAccessible, public void notifyEvent(AccessibleEventObject accessibleEventObject) { if (accessibleEventObject.EventId == AccessibleEventId.CHILD) { - XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface( - XAccessible.class, accessibleEventObject.OldValue); + XAccessible xAccessible = UnoRuntime.queryInterface( XAccessible.class, accessibleEventObject.OldValue ); if (xAccessible != null) { handleChildRemoved(xAccessible); } - xAccessible = (XAccessible) UnoRuntime.queryInterface( - XAccessible.class, accessibleEventObject.NewValue); + xAccessible = UnoRuntime.queryInterface( XAccessible.class, accessibleEventObject.NewValue ); if (xAccessible != null) { handleChildAdded(xAccessible); } } - XAccessibleEventListener listener = this.listener; - if (listener != null) { - listener.notifyEvent(accessibleEventObject); + XAccessibleEventListener localListener = this.listener; + if (localListener != null) { + localListener.notifyEvent(accessibleEventObject); } } diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java index 5b4bdcdcc4e4..67e8091e027f 100644 --- a/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java @@ -64,6 +64,7 @@ class EventMonitorView public EventMonitorView (ObjectViewContainer aContainer) { super (aContainer); + mnLineNo = 0; Layout(); } @@ -85,7 +86,7 @@ class EventMonitorView maScrollPane = new JScrollPane (maText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - maScrollPane.setPreferredSize (new Dimension (300,80)); + maScrollPane.setPreferredSize (new Dimension (300,200)); GridBagConstraints aConstraints = new GridBagConstraints (); aConstraints.weightx = 1; @@ -112,7 +113,7 @@ class EventMonitorView public void notifyEvent (AccessibleEventObject aEvent) { - maText.append (NameProvider.getEventName (aEvent.EventId) + " : " + maText.append ((mnLineNo++) + ". " + NameProvider.getEventName (aEvent.EventId) + " : " + aEvent.OldValue.toString() + " -> " + aEvent.NewValue.toString() + "\n"); @@ -120,5 +121,6 @@ class EventMonitorView } private JTextArea maText; + private int mnLineNo; private JScrollPane maScrollPane; } diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 2d1cccd9fc51..bfe6c30364ad 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -5311,13 +5311,13 @@ BOOL StatementControl::Execute() { // Wir flschen einen Parameter if ( aUId.HasNumeric() ) { - nParams = PARAM_ULONG_1; + nParams |= PARAM_ULONG_1; nLNr1 = USHORT( aUId.GetNum() ); DBG_ASSERT( nLNr1 <= 0xFFFF, "ID on ToolBox > 0xFFFF" ); } else { - nParams = PARAM_STR_1; + nParams |= PARAM_STR_1; aString1 = aUId.GetStr(); } } @@ -5330,9 +5330,9 @@ BOOL StatementControl::Execute() BOOL bItemFound = FALSE;\ {\ SmartId aButtonId;\ - if( nParams == PARAM_STR_1 )\ + if( nParams & PARAM_STR_1 )\ aButtonId = SmartId( aString1 );\ - if( nParams == PARAM_ULONG_1 )\ + if( nParams & PARAM_ULONG_1 )\ aButtonId = SmartId( nLNr1 );\ for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.Matches(pTB->GetItemCommand(pTB->GetItemId(nItemPos))) &&\ !aButtonId.Matches(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\ @@ -5341,12 +5341,12 @@ BOOL StatementControl::Execute() ReportError( aUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\ else\ {\ - if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled )\ + if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled && nMethodId != M_GetState )\ {\ ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\ bItemFound = FALSE;\ }\ - else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) )\ + else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) && nMethodId != M_GetState )\ {\ ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\ bItemFound = FALSE;\ @@ -5738,19 +5738,28 @@ BOOL StatementControl::Execute() pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK )); break; case M_Check : - pItem->SetStateChecked(); - pTree->CheckButtonHdl(); - pTree->InvalidateEntry( pThisEntry ); + if ( !pItem->IsStateChecked() ) + { + pItem->SetStateChecked(); + pTree->CheckButtonHdl(); + pTree->InvalidateEntry( pThisEntry ); + } break; case M_UnCheck : - pItem->SetStateUnchecked(); - pTree->CheckButtonHdl(); - pTree->InvalidateEntry( pThisEntry ); + if ( pItem->IsStateChecked() || pItem->IsStateTristate() ) + { + pItem->SetStateUnchecked(); + pTree->CheckButtonHdl(); + pTree->InvalidateEntry( pThisEntry ); + } break; case M_TriState : - pItem->SetStateTristate(); - pTree->CheckButtonHdl(); - pTree->InvalidateEntry( pThisEntry ); + if ( !pItem->IsStateTristate() ) + { + pItem->SetStateTristate(); + pTree->CheckButtonHdl(); + pTree->InvalidateEntry( pThisEntry ); + } break; default: ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); @@ -6282,6 +6291,8 @@ protected: MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,MOUSE_LEFT,KEY_MOD1); pTC->getSelEngine()->SelMouseButtonDown( aMEvnt ); pTC->getSelEngine()->SelMouseButtonUp( aMEvnt ); + if ( pTC->IsRowSelected( nNr1-1 ) ) + pTC->Select(); } else ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "find pos" ) ); diff --git a/basctl/prj/d.lst b/basctl/prj/d.lst index ffd8e07b1e36..d05ff35bdabc 100644 --- a/basctl/prj/d.lst +++ b/basctl/prj/d.lst @@ -4,8 +4,6 @@ mkdir: %_DEST%\xml%_EXT%\uiconfig\modules mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\toolbar -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\accelerator -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\accelerator\en-US mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\statusbar ..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid @@ -22,5 +20,4 @@ mkdir: %_DEST%\inc%_EXT%\basctl ..\uiconfig\basicide\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\menubar\*.xml ..\uiconfig\basicide\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\toolbar\*.xml -..\uiconfig\basicide\accelerator\en-US\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\accelerator\en-US\*.xml ..\uiconfig\basicide\statusbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\BasicIDE\statusbar\*.xml diff --git a/basctl/source/basicide/makefile.mk b/basctl/source/basicide/makefile.mk index 62c4755112d1..b225b987b24b 100644 --- a/basctl/source/basicide/makefile.mk +++ b/basctl/source/basicide/makefile.mk @@ -49,6 +49,7 @@ CDEFS+=-DBASICDEBUG EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \ $(SLO)$/scriptdocument.obj \ + $(SLO)$/basicbox.obj \ $(SLO)$/basidesh.obj \ $(SLO)$/basides1.obj \ $(SLO)$/basides2.obj \ @@ -75,7 +76,6 @@ EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \ $(SLO)$/documentenumeration.obj SLOFILES = $(EXCEPTIONSFILES) \ - $(SLO)$/basicbox.obj \ $(SLO)$/baside2b.obj \ $(SLO)$/brkdlg.obj \ $(SLO)$/objdlg.obj \ diff --git a/basctl/uiconfig/basicide/accelerator/en-GB/default.xml b/basctl/uiconfig/basicide/accelerator/en-GB/default.xml deleted file mode 100644 index 94d5e84a8413..000000000000 --- a/basctl/uiconfig/basicide/accelerator/en-GB/default.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE accel:acceleratorlist PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "accelerator.dtd"> -<accel:acceleratorlist xmlns:accel="http://openoffice.org/2001/accel" xmlns:xlink="http://www.w3.org/1999/xlink"> - <accel:item accel:code="KEY_F5" xlink:href=".uno:RunBasic"/> - <accel:item accel:code="KEY_F5" accel:shift="true" xlink:href=".uno:BasicStop"/> - <accel:item accel:code="KEY_F7" xlink:href=".uno:AddWatch"/> - <accel:item accel:code="KEY_F8" xlink:href=".uno:BasicStepInto"/> - <accel:item accel:code="KEY_F8" accel:shift="true" xlink:href=".uno:BasicStepOver"/> - <accel:item accel:code="KEY_F9" xlink:href=".uno:ToggleBreakPoint"/> - <accel:item accel:code="KEY_F9" accel:shift="true" xlink:href=".uno:ToggleBreakPointEnabled"/> -</accel:acceleratorlist> diff --git a/basctl/uiconfig/basicide/accelerator/en-US/default.xml b/basctl/uiconfig/basicide/accelerator/en-US/default.xml deleted file mode 100644 index 94d5e84a8413..000000000000 --- a/basctl/uiconfig/basicide/accelerator/en-US/default.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE accel:acceleratorlist PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "accelerator.dtd"> -<accel:acceleratorlist xmlns:accel="http://openoffice.org/2001/accel" xmlns:xlink="http://www.w3.org/1999/xlink"> - <accel:item accel:code="KEY_F5" xlink:href=".uno:RunBasic"/> - <accel:item accel:code="KEY_F5" accel:shift="true" xlink:href=".uno:BasicStop"/> - <accel:item accel:code="KEY_F7" xlink:href=".uno:AddWatch"/> - <accel:item accel:code="KEY_F8" xlink:href=".uno:BasicStepInto"/> - <accel:item accel:code="KEY_F8" accel:shift="true" xlink:href=".uno:BasicStepOver"/> - <accel:item accel:code="KEY_F9" xlink:href=".uno:ToggleBreakPoint"/> - <accel:item accel:code="KEY_F9" accel:shift="true" xlink:href=".uno:ToggleBreakPointEnabled"/> -</accel:acceleratorlist> diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index d243ce96f27c..303b54688eea 100644..100755 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -389,14 +389,14 @@ void SpellDialog::UpdateBoxes_Impl() } // ----------------------------------------------------------------------- -void SpellDialog::SpellContinue_Impl(bool bUseSavedSentence) +void SpellDialog::SpellContinue_Impl(bool bUseSavedSentence, bool bIgnoreCurrentError ) { //initially or after the last error of a sentence MarkNextError will fail //then GetNextSentence() has to be called followed again by MarkNextError() //MarkNextError is not initally called if the UndoEdit mode is active bool bNextSentence = false; - if((!aSentenceED.IsUndoEditMode() && aSentenceED.MarkNextError()) || - true == ( bNextSentence = GetNextSentence_Impl(bUseSavedSentence) && aSentenceED.MarkNextError())) + if((!aSentenceED.IsUndoEditMode() && aSentenceED.MarkNextError( bIgnoreCurrentError )) || + true == ( bNextSentence = GetNextSentence_Impl(bUseSavedSentence, aSentenceED.IsUndoEditMode()) && aSentenceED.MarkNextError( false ))) { const SpellErrorDescription* pSpellErrorDescription = aSentenceED.GetAlternatives(); if( pSpellErrorDescription ) @@ -473,7 +473,7 @@ IMPL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog *, EMPTYARG ) } else { - if( SvtLinguConfig().HasAnyVendorImages() ) + if( SvtLinguConfig().HasVendorImages( "SpellAndGrammarDialogImage" ) ) { pThis->aVendorImageFI.Show(); Size aVendorSize = pThis->aVendorImageFI.GetSizePixel(); @@ -795,14 +795,12 @@ IMPL_LINK( SpellDialog, IgnoreHdl, Button *, EMPTYARG ) } else { - //in case the error has been changed manually it has to be restored + //in case the error has been changed manually it has to be restored, + // since the users choice now was to ignore the error aSentenceED.RestoreCurrentError(); - rParent.ApplyChangedSentence(aSentenceED.CreateSpellPortions(true)); - aSentenceED.ResetModified(); // the word is being ignored - SpellContinue_Impl(); - bModified = false; + SpellContinue_Impl( false, true ); } return 1; } @@ -1074,11 +1072,8 @@ IMPL_LINK(SpellDialog, ModifyHdl, SentenceEditWindow_Impl*, pEd) -----------------------------------------------------------------------*/ IMPL_LINK(SpellDialog, CancelHdl, Button *, EMPTYARG ) { - //apply changes first - if there are any - if(aSentenceED.IsModified()) - { - rParent.ApplyChangedSentence(aSentenceED.CreateSpellPortions(false)); - } + //apply changes and ignored text parts first - if there are any + rParent.ApplyChangedSentence(aSentenceED.CreateSpellPortions(true), false); Close(); return 0; } @@ -1158,15 +1153,17 @@ void SpellDialog::InvalidateDialog() /*-- 10.09.2003 08:35:56--------------------------------------------------- -----------------------------------------------------------------------*/ -bool SpellDialog::GetNextSentence_Impl(bool bUseSavedSentence) +bool SpellDialog::GetNextSentence_Impl(bool bUseSavedSentence, bool bRecheck) { bool bRet = false; - if(!bUseSavedSentence && aSentenceED.IsModified()) + if(!bUseSavedSentence /*&& aSentenceED.IsModified()*/) { - rParent.ApplyChangedSentence(aSentenceED.CreateSpellPortions(false)); + //apply changes and ignored text parts + rParent.ApplyChangedSentence(aSentenceED.CreateSpellPortions(true), bRecheck); } + aSentenceED.ResetIgnoreErrorsAt(); aSentenceED.ResetModified(); - SpellPortions aSentence = bUseSavedSentence ? m_aSavedSentence : rParent.GetNextWrongSentence(); + SpellPortions aSentence = bUseSavedSentence ? m_aSavedSentence : rParent.GetNextWrongSentence( bRecheck ); if(!bUseSavedSentence) m_aSavedSentence = aSentence; bool bHasReplaced = false; @@ -1177,8 +1174,8 @@ bool SpellDialog::GetNextSentence_Impl(bool bUseSavedSentence) if(!ApplyChangeAllList_Impl(aSentence, bHasReplaced)) { - rParent.ApplyChangedSentence(aSentence); - aSentence = rParent.GetNextWrongSentence(); + rParent.ApplyChangedSentence(aSentence, bRecheck); + aSentence = rParent.GetNextWrongSentence( bRecheck ); } else break; @@ -1642,8 +1639,10 @@ long SentenceEditWindow_Impl::PreNotify( NotifyEvent& rNEvt ) /*-- 10.09.2003 13:38:14--------------------------------------------------- -----------------------------------------------------------------------*/ -bool SentenceEditWindow_Impl::MarkNextError() +bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError ) { + if (bIgnoreCurrentError) + m_aIgnoreErrorsAt.insert( m_nErrorStart ); ExtTextEngine* pTextEngine = GetTextEngine(); USHORT nTextLen = pTextEngine->GetTextLen(0); if(m_nErrorEnd >= nTextLen - 1) @@ -1981,7 +1980,8 @@ svx::SpellPortions SentenceEditWindow_Impl::CreateSpellPortions( bool bSetIgnore aPortion1.eLanguage = eLang; aPortion1.sText = pTextEngine->GetText( TextSelection(TextPaM(0, nStart), TextPaM(0, aStart->nPosition))); - if( bSetIgnoreFlag && m_nErrorStart == nStart ) + bool bIsIgnoreError = m_aIgnoreErrorsAt.find( nStart ) != m_aIgnoreErrorsAt.end(); + if( bSetIgnoreFlag && bIsIgnoreError /*m_nErrorStart == nStart*/ ) { aPortion1.bIgnoreThisError = true; } diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index 91136b607a22..16026aaff6d1 100644..100755 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -28,52 +28,51 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cui.hxx" -// include --------------------------------------------------------------- -#include <tools/shl.hxx> -#include <tools/list.hxx> -#include <com/sun/star/linguistic2/XPossibleHyphens.hpp> -#include <vcl/msgbox.hxx> -#include "cuires.hrc" -#include "hyphen.hrc" -#include <editeng/svxenum.hxx> #include "hyphen.hxx" +#include "hyphen.hrc" +#include "cuires.hrc" +#include "dialmgr.hxx" + #include <editeng/splwrap.hxx> -#include <svx/dlgutil.hxx> -#include <svx/dialmgr.hxx> +#include <editeng/svxenum.hxx> #include <editeng/unolingu.hxx> #include <svtools/langtab.hxx> -#include "dialmgr.hxx" +#include <svx/dialmgr.hxx> +#include <svx/dlgutil.hxx> +#include <tools/list.hxx> +#include <tools/shl.hxx> +#include <vcl/msgbox.hxx> -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::linguistic2; +#include <com/sun/star/linguistic2/XPossibleHyphens.hpp> -#undef S2U -#undef U2S -//#define S2U(s) StringToOUString(s, CHARSET_SYSTEM) -//#define U2S(s) OUStringToString(s, CHARSET_SYSTEM) +using namespace ::com::sun::star; -// define ---------------------------------------------------------------- -#define HYPHHERE '-' +#define HYPH_POS_CHAR '=' #define CONTINUE_HYPH USHRT_MAX -// Dies ist nur ein Hack, weil an dieser Stelle das extern char aus hmwrap -// nicht bekannt ist, wird demnaechst in hmwrap durch ein define ersetzt. -#define SW_SOFT_HYPHEN '=' +#define CUR_HYPH_POS_CHAR '-' + + +// class HyphenEdit_Impl ------------------------------------------------------- -// class SvxHyphenEdit --------------------------------------------------- +class HyphenEdit_Impl : public Edit +{ +public: + HyphenEdit_Impl( Window* pParent, const ResId& rResId ); + +protected: + virtual void KeyInput( const KeyEvent &rKEvt ); +}; -SvxHyphenEdit::SvxHyphenEdit( Window* pParent, const ResId& rResId ) : +HyphenEdit_Impl::HyphenEdit_Impl( Window* pParent, const ResId& rResId ) : Edit( pParent, rResId ) { } -// ----------------------------------------------------------------------- -void SvxHyphenEdit::KeyInput( const KeyEvent& rKEvt ) +void HyphenEdit_Impl::KeyInput( const KeyEvent& rKEvt ) { // sal_uInt16 nMod = rKEvt.GetKeyCode().GetModifier(); sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); @@ -99,123 +98,143 @@ void SvxHyphenEdit::KeyInput( const KeyEvent& rKEvt ) } } -// class SvxHyphenWordDialog --------------------------------------------- -SvxHyphenWordDialog::SvxHyphenWordDialog( const String &rWord, LanguageType nLang, - Window* pParent, - Reference< XHyphenator > &xHyphen, - SvxSpellWrapper* pWrapper ) : - SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_HYPHENATE ) ), - - aWordFT ( this, CUI_RES( FT_WORD ) ), - aWordEdit ( this, CUI_RES( ED_WORD ) ), - aLeftBtn ( this, CUI_RES( BTN_LEFT ) ), - aRightBtn ( this, CUI_RES( BTN_RIGHT ) ), - aOkBtn ( this, CUI_RES( BTN_HYPH_CUT ) ), - aCancelBtn ( this, CUI_RES( BTN_HYPH_CANCEL ) ), - aContBtn ( this, CUI_RES( BTN_HYPH_CONTINUE ) ), - aDelBtn ( this, CUI_RES( BTN_HYPH_DELETE ) ), - aHelpBtn ( this, CUI_RES( BTN_HYPH_HELP ) ), - aLabel ( GetText() ), - pHyphWrapper ( pWrapper ), - xHyphenator ( xHyphen ), - aActWord ( rWord ), - nActLanguage ( nLang ), +// struct SvxHyphenWordDialog_Impl --------------------------------------------- + +struct SvxHyphenWordDialog_Impl +{ + SvxHyphenWordDialog * m_pDialog; +// Window * m_pParent; + + FixedText aWordFT; + HyphenEdit_Impl aWordEdit; + ImageButton aLeftBtn; + ImageButton aRightBtn; + OKButton aOkBtn; + PushButton aContBtn; + PushButton aDelBtn; + FixedLine aFLBottom; + HelpButton aHelpBtn; + PushButton aHyphAll; + CancelButton aCancelBtn; + String aLabel; + SvxSpellWrapper* pHyphWrapper; + uno::Reference< linguistic2::XHyphenator > xHyphenator; + uno::Reference< linguistic2::XPossibleHyphens > xPossHyph; + String aEditWord; // aEditWord and aWordEdit.GetText() differ only by the character for the current selected hyphenation position + String aActWord; // actual word to be hyphenated + LanguageType nActLanguage; // and its language + sal_uInt16 nMaxHyphenationPos; // right most valid hyphenation pos + sal_uInt16 nHyphPos; + sal_uInt16 nOldPos; + sal_Int32 nHyphenationPositionsOffset; + sal_Bool bBusy; + + + void EnableLRBtn_Impl(); + String EraseUnusableHyphens_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > &rxPossHyph, sal_uInt16 nMaxHyphenationPos ); + + void InitControls_Impl(); + void ContinueHyph_Impl( sal_uInt16 nInsPos = 0 ); + sal_uInt16 GetHyphIndex_Impl(); + void SelLeft_Impl(); + void SelRight_Impl(); + + DECL_LINK( Left_Impl, Button* ); + DECL_LINK( Right_Impl, Button* ); + DECL_LINK( CutHdl_Impl, Button* ); + DECL_LINK( ContinueHdl_Impl, Button* ); + DECL_LINK( DeleteHdl_Impl, Button* ); + DECL_LINK( HyphenateAllHdl_Impl, Button* ); + DECL_LINK( CancelHdl_Impl, Button* ); + DECL_LINK( GetFocusHdl_Impl, Edit* ); + + + SvxHyphenWordDialog_Impl( + SvxHyphenWordDialog * pDialog, + const String &rWord, + LanguageType nLang, + uno::Reference< linguistic2::XHyphenator > &xHyphen, + SvxSpellWrapper* pWrapper ); + ~SvxHyphenWordDialog_Impl(); +}; + + +SvxHyphenWordDialog_Impl::SvxHyphenWordDialog_Impl( + SvxHyphenWordDialog * pDialog, + const String &rWord, + LanguageType nLang, + uno::Reference< linguistic2::XHyphenator > &xHyphen, + SvxSpellWrapper* pWrapper ) : + + m_pDialog ( pDialog ), + aWordFT ( pDialog, CUI_RES( FT_WORD ) ), + aWordEdit ( pDialog, CUI_RES( ED_WORD ) ), + aLeftBtn ( pDialog, CUI_RES( BTN_LEFT ) ), + aRightBtn ( pDialog, CUI_RES( BTN_RIGHT ) ), + aOkBtn ( pDialog, CUI_RES( BTN_HYPH_CUT ) ), + aContBtn ( pDialog, CUI_RES( BTN_HYPH_CONTINUE ) ), + aDelBtn ( pDialog, CUI_RES( BTN_HYPH_DELETE ) ), + aFLBottom ( pDialog, CUI_RES( FL_BOTTOM ) ), + aHelpBtn ( pDialog, CUI_RES( BTN_HYPH_HELP ) ), + aHyphAll ( pDialog, CUI_RES( BTN_HYPH_ALL ) ), + aCancelBtn ( pDialog, CUI_RES( BTN_HYPH_CANCEL ) ), + aLabel ( pDialog->GetText() ), + pHyphWrapper ( NULL ), + xHyphenator ( NULL ), + xPossHyph ( NULL ), + aActWord ( ), + nActLanguage ( LANGUAGE_NONE ), + nMaxHyphenationPos ( 0 ), nHyphPos ( 0 ), nOldPos ( 0 ), + nHyphenationPositionsOffset( 0 ), bBusy ( sal_False ) { - aContBtn.SetClickHdl( - LINK( this, SvxHyphenWordDialog, ContinueHdl_Impl ) ); - aOkBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, CutHdl_Impl ) ); - aDelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, DeleteHdl_Impl ) ); - aCancelBtn.SetClickHdl( - LINK( this, SvxHyphenWordDialog, CancelHdl_Impl ) ); - aLeftBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Left_Impl ) ); - aRightBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Right_Impl ) ); - - aWordEdit.SetGetFocusHdl( - LINK( this, SvxHyphenWordDialog, GetFocusHdl_Impl ) ); - - Reference< XHyphenatedWord > xHyphWord( pWrapper ? - pWrapper->GetLast() : Reference< XInterface > () , UNO_QUERY ); - DBG_ASSERT(xHyphWord.is(), "missing hyphenated word"); - nMaxHyphenationPos = xHyphWord.is() ? xHyphWord->getHyphenationPos() : 0; - SetLabel_Impl( nLang ); + aActWord = rWord; + nActLanguage = nLang; + xHyphenator = xHyphen; + pHyphWrapper = pWrapper; + + uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( pHyphWrapper ? + pHyphWrapper->GetLast() : NULL, uno::UNO_QUERY ); + DBG_ASSERT( xHyphWord.is(), "hyphenation result missing" ); + if (xHyphWord.is()) + { + DBG_ASSERT( aActWord == String( xHyphWord->getWord() ), "word mismatch" ); + DBG_ASSERT( nActLanguage == SvxLocaleToLanguage( xHyphWord->getLocale() ), "language mismatch" ); + nMaxHyphenationPos = xHyphWord->getHyphenationPos(); + } InitControls_Impl(); aWordEdit.GrabFocus(); - FreeResource(); - - // disable controls if service is not available - if (!xHyphenator.is()) - Enable( sal_False ); + aLeftBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, Left_Impl ) ); + aRightBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, Right_Impl ) ); + aOkBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, CutHdl_Impl ) ); + aContBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, ContinueHdl_Impl ) ); + aDelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, DeleteHdl_Impl ) ); + aHyphAll.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, HyphenateAllHdl_Impl ) ); + aCancelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, CancelHdl_Impl ) ); + aWordEdit.SetGetFocusHdl( LINK( this, SvxHyphenWordDialog_Impl, GetFocusHdl_Impl ) ); } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::SelLeft() +SvxHyphenWordDialog_Impl::~SvxHyphenWordDialog_Impl() { - String aTxt( aWordEdit.GetText() ); - - for ( xub_StrLen i = nOldPos + 1; i-- > 0 ; ) - { - DBG_ASSERT(i <= aTxt.Len(), "index out of range"); - if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) - { - aTxt.SetChar( i, sal_Unicode( HYPHHERE ) ); - - if ( nOldPos != 0 && nOldPos != aTxt.Len() ) - aTxt.SetChar( nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); - nOldPos = i; - aWordEdit.SetText( aTxt ); - aWordEdit.GrabFocus(); - aWordEdit.SetSelection( Selection( i, i + 1 ) ); - break; - } - } - nHyphPos = GetHyphIndex_Impl(); - EnableLRBtn_Impl(); -} - -// ----------------------------------------------------------------------- - -void SvxHyphenWordDialog::SelRight() -{ - String aTxt( aWordEdit.GetText() ); - - for ( xub_StrLen i = nOldPos + 1; i < aTxt.Len(); ++i ) - { - if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) - { - aTxt.SetChar( i, sal_Unicode( HYPHHERE ) ); - - if ( nOldPos != 0 && nOldPos != aTxt.Len() ) - aTxt.SetChar( nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); - nOldPos = i; - aWordEdit.SetText( aTxt ); - aWordEdit.GrabFocus(); - aWordEdit.SetSelection( Selection( i, i + 1 ) ); - break; - } - } - nHyphPos = GetHyphIndex_Impl(); - EnableLRBtn_Impl(); } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::EnableLRBtn_Impl() +void SvxHyphenWordDialog_Impl::EnableLRBtn_Impl() { - String aTxt( aWordEdit.GetText() ); + String aTxt( aEditWord ); xub_StrLen nLen = aTxt.Len(); xub_StrLen i; aRightBtn.Disable(); for ( i = nOldPos + 2; i < nLen; ++i ) { - if ( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) + if ( aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ) ) { aRightBtn.Enable(); break; @@ -228,7 +247,7 @@ void SvxHyphenWordDialog::EnableLRBtn_Impl() aLeftBtn.Disable(); for ( i = nOldPos; i-- > 0; ) { - if ( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) + if ( aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ) ) { aLeftBtn.Enable(); break; @@ -236,42 +255,55 @@ void SvxHyphenWordDialog::EnableLRBtn_Impl() } } -// ----------------------------------------------------------------------- - -void SvxHyphenWordDialog::SetLabel_Impl( LanguageType nLang ) -{ - String aLangStr( SvtLanguageTable::GetLanguageString( nLang ) ); - String aTmp( aLabel ); - aTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); - aTmp.Append( aLangStr ); - aTmp.Append( sal_Unicode( ')' ) ); - SetText( aTmp ); -} - -// ----------------------------------------------------------------------- - -String SvxHyphenWordDialog::EraseUnusableHyphens_Impl( - Reference< XPossibleHyphens > &rxPossHyph, +String SvxHyphenWordDialog_Impl::EraseUnusableHyphens_Impl( + uno::Reference< linguistic2::XPossibleHyphens > &rxPossHyph, sal_uInt16 _nMaxHyphenationPos ) { // returns a String showing only those hyphen positions which will result // in a line break if hyphenation is done there + // 1) we will need to discard all hyphenation positions at th end that + // will not result in a line break where the text to the left still fits + // on the line. + // 2) since as from OOo 3.2 '-' are part of a word an thus text like + // 'multi-line-editor' is regarded as single word we also need to discard those + // hyphenation positions to the left of the rightmost '-' that is still left of + // the rightmost valid hyphenation position according to 1) + // + // Example: + // If the possible hyphenation position in 'multi-line-editor' are to eb marked + // by '=' then the text will look like this 'mul=ti-line-ed=it=or'. + // If now the first line is only large enough for 'multi-line-edi' we need to discard + // the last possible hyphnation point because of 1). The the right most valid + // hyphenation position is "ed=itor". The first '-' left of this position is + // "line-ed", thus because of 2) we now need to discard all possible hyphneation + // positions to the left of that as well. Thus in the end leaving us with just + // 'multi-line-ed=itor' as return value for this function. (Just one valid hyphenation + // position for the user too choose from. However ALL the '-' characters in the word + // will ALWAYS be valid implicit hyphenation positions for the core to choose from! + // And thus even if this word is skipped in the hyphenation dialog it will still be broken + // right after 'multi-line-' (actually it might already be broken up that way before + // the hyphenation dialog is called!). + // Thus rule 2) just eliminates those positions which will not be used by the core at all + // even if the user were to select one of them. String aTxt; DBG_ASSERT(rxPossHyph.is(), "missing possible hyphens"); if (rxPossHyph.is()) { + DBG_ASSERT( aActWord == String( rxPossHyph->getWord() ), "word mismatch" ); + aTxt = String( rxPossHyph->getPossibleHyphens() ); - Sequence< sal_Int16 > aHyphenationPositions( + nHyphenationPositionsOffset = 0; + uno::Sequence< sal_Int16 > aHyphenationPositions( rxPossHyph->getHyphenationPositions() ); sal_Int32 nLen = aHyphenationPositions.getLength(); const sal_Int16 *pHyphenationPos = aHyphenationPositions.getConstArray(); // find position nIdx after which all hyphen positions are unusable - xub_StrLen nIdx = STRING_NOTFOUND, - nPos; + xub_StrLen nIdx = STRING_NOTFOUND; + xub_StrLen nPos = 0, nPos1 = 0, nPos2 = 0; if (nLen) { xub_StrLen nStart = 0; @@ -282,7 +314,7 @@ String SvxHyphenWordDialog::EraseUnusableHyphens_Impl( else { // find corresponding hyphen pos in string - nPos = aTxt.Search( sal_Unicode( SW_SOFT_HYPHEN ), nStart ); + nPos = aTxt.Search( sal_Unicode( HYPH_POS_CHAR ), nStart ); if (nStart == STRING_NOTFOUND) break; @@ -296,66 +328,77 @@ String SvxHyphenWordDialog::EraseUnusableHyphens_Impl( } DBG_ASSERT(nIdx != STRING_NOTFOUND, "no usable hyphenation position"); - // remove not usable hyphens from string + // 1) remove all not usable hyphenation positions from the end of the string nPos = nIdx == STRING_NOTFOUND ? 0 : nIdx + 1; - String aTmp( sal_Unicode( SW_SOFT_HYPHEN ) ), - aEmpty; + nPos1 = nPos; //save for later use in 2) below + const String aTmp( sal_Unicode( HYPH_POS_CHAR ) ); + const String aEmpty; while (nPos != STRING_NOTFOUND) nPos = aTxt.SearchAndReplace( aTmp, aEmpty, nPos + 1 ); + + // 2) remove all hyphenation positions from the start that are not considered by the core + const String aSearchRange( aTxt.Copy( 0, nPos1 ) ); + nPos2 = aSearchRange.SearchBackward( '-' ); // the '-' position the core will use by default + if (nPos2 != STRING_NOTFOUND) + { + String aLeft( aSearchRange.Copy( 0, nPos2 ) ); + nPos = 0; + while (nPos != STRING_NOTFOUND) + { + nPos = aLeft.SearchAndReplace( aTmp, aEmpty, nPos + 1 ); + if (nPos != STRING_NOTFOUND) + ++nHyphenationPositionsOffset; + } + aTxt.Replace( 0, nPos2, aLeft ); + } } return aTxt; } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::InitControls_Impl() +void SvxHyphenWordDialog_Impl::InitControls_Impl() { - String aTxt; xPossHyph = NULL; if (xHyphenator.is()) { lang::Locale aLocale( SvxCreateLocale(nActLanguage) ); xPossHyph = xHyphenator->createPossibleHyphens( aActWord, aLocale, - Sequence< PropertyValue >() ); + uno::Sequence< beans::PropertyValue >() ); if (xPossHyph.is()) - { - aTxt = EraseUnusableHyphens_Impl( xPossHyph, nMaxHyphenationPos ); - } - SetLabel_Impl( nActLanguage ); + aEditWord = EraseUnusableHyphens_Impl( xPossHyph, nMaxHyphenationPos ); } - aWordEdit.SetText( aTxt ); + aWordEdit.SetText( aEditWord ); - nOldPos = aTxt.Len(); - SelLeft(); + nOldPos = aEditWord.Len(); + SelLeft_Impl(); EnableLRBtn_Impl(); } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::ContinueHyph_Impl( sal_uInt16 nInsPos ) +void SvxHyphenWordDialog_Impl::ContinueHyph_Impl( sal_uInt16 nInsPos ) { if ( nInsPos != CONTINUE_HYPH && xPossHyph.is()) { if (nInsPos) { - //String aTmp( U2S( xPossHyph->getPossibleHyphens() ) ); - String aTmp( aWordEdit.GetText() ); + String aTmp( aEditWord ); DBG_ASSERT(nInsPos <= aTmp.Len() - 2, "wrong hyphen position"); - sal_uInt16 nIdxPos = 0; - sal_uInt16 i = 0; - sal_Unicode c; - while (i < aTmp.Len() && HYPHHERE != (c = aTmp.GetChar(i++)) ) + sal_Int16 nIdxPos = -1; + for (sal_uInt16 i = 0; i <= nInsPos; ++i) { - if (SW_SOFT_HYPHEN == c) + if (HYPH_POS_CHAR == aTmp.GetChar( i )) nIdxPos++; } + // take the possible hyphenation positions that got removed from the + // start of the wor dinot account: + nIdxPos += nHyphenationPositionsOffset; - Sequence< sal_Int16 > aSeq = xPossHyph->getHyphenationPositions(); + uno::Sequence< sal_Int16 > aSeq = xPossHyph->getHyphenationPositions(); sal_Int32 nLen = aSeq.getLength(); DBG_ASSERT(nLen, "empty sequence"); - DBG_ASSERT(nIdxPos < nLen, "index out of range"); - if (nLen && nIdxPos < nLen) + DBG_ASSERT(0 <= nIdxPos && nIdxPos < nLen, "index out of range"); + if (nLen && 0 <= nIdxPos && nIdxPos < nLen) { nInsPos = aSeq.getConstArray()[ nIdxPos ]; pHyphWrapper->InsertHyphen( nInsPos ); @@ -370,58 +413,130 @@ void SvxHyphenWordDialog::ContinueHyph_Impl( sal_uInt16 nInsPos ) if ( pHyphWrapper->FindSpellError() ) { - Reference< XHyphenatedWord > xHyphWord( pHyphWrapper->GetLast(), UNO_QUERY ); + uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( pHyphWrapper->GetLast(), uno::UNO_QUERY ); // adapt actual word and language to new found hyphenation result if(xHyphWord.is()) { - aActWord = String( xHyphWord->getWord() ); + aActWord = String( xHyphWord->getWord() ); nActLanguage = SvxLocaleToLanguage( xHyphWord->getLocale() ); nMaxHyphenationPos = xHyphWord->getHyphenationPos(); InitControls_Impl(); + m_pDialog->SetWindowTitle( nActLanguage ); } } else - EndDialog( RET_OK ); + m_pDialog->EndDialog( RET_OK ); } -// ----------------------------------------------------------------------- -sal_uInt16 SvxHyphenWordDialog::GetHyphIndex_Impl() +sal_uInt16 SvxHyphenWordDialog_Impl::GetHyphIndex_Impl() { sal_uInt16 nPos = 0; - String aTxt(aWordEdit.GetText()); + String aTxt( aWordEdit.GetText() ); for ( sal_uInt16 i=0 ; i < aTxt.Len(); ++i ) { - sal_Unicode nChar = aTxt.GetChar( i ); - - if ( nChar == HYPHHERE ) + sal_Unicode cChar = aTxt.GetChar( i ); + if ( cChar == CUR_HYPH_POS_CHAR ) break; - - if ( nChar != SW_SOFT_HYPHEN ) + if ( cChar != HYPH_POS_CHAR ) nPos++; } return nPos; } -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, CutHdl_Impl, Button *, EMPTYARG ) +void SvxHyphenWordDialog_Impl::SelLeft_Impl() +{ + DBG_ASSERT( nOldPos > 0, "invalid hyphenation position" ); + if (nOldPos > 0) + { + String aTxt( aEditWord ); + for ( xub_StrLen i = nOldPos - 1; i > 0; --i) + { + DBG_ASSERT(i <= aTxt.Len(), "index out of range"); + if (aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR )) + { + aTxt.SetChar( i, sal_Unicode( CUR_HYPH_POS_CHAR ) ); + + nOldPos = i; + aWordEdit.SetText( aTxt ); + aWordEdit.GrabFocus(); + aWordEdit.SetSelection( Selection( i, i + 1 ) ); + break; + } + } + nHyphPos = GetHyphIndex_Impl(); + EnableLRBtn_Impl(); + } +} + + +void SvxHyphenWordDialog_Impl::SelRight_Impl() +{ + String aTxt( aEditWord ); + for ( xub_StrLen i = nOldPos + 1; i < aTxt.Len(); ++i ) + { + if (aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR )) + { + aTxt.SetChar( i, sal_Unicode( CUR_HYPH_POS_CHAR ) ); + + nOldPos = i; + aWordEdit.SetText( aTxt ); + aWordEdit.GrabFocus(); + aWordEdit.SetSelection( Selection( i, i + 1 ) ); + break; + } + } + nHyphPos = GetHyphIndex_Impl(); + EnableLRBtn_Impl(); +} + + +IMPL_LINK( SvxHyphenWordDialog_Impl, CutHdl_Impl, Button *, EMPTYARG ) { if( !bBusy ) { bBusy = sal_True; - ContinueHyph_Impl( nHyphPos ); + ContinueHyph_Impl( /*nHyphPos*/nOldPos ); bBusy = sal_False; } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, CutHdl_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButton*/ ) +{ + if( !bBusy ) + { + try + { + uno::Reference< beans::XPropertySet > xProp( SvxGetLinguPropertySet() ); + const rtl::OUString aName( rtl::OUString::createFromAscii( "IsHyphAuto" ) ); + uno::Any aAny; + + aAny <<= sal_True; + xProp->setPropertyValue( aName, aAny ); + + bBusy = sal_True; + ContinueHyph_Impl( /*nHyphPos*/nOldPos ); + bBusy = sal_False; + + aAny <<= sal_False; + xProp->setPropertyValue( aName, aAny ); + } + catch (uno::Exception &e) + { + (void) e; + DBG_ASSERT( 0, "Hyphenate All failed" ); + } + } + return 0; +} + + +IMPL_LINK( SvxHyphenWordDialog_Impl, DeleteHdl_Impl, Button *, EMPTYARG ) { if( !bBusy ) { @@ -431,11 +546,9 @@ IMPL_LINK_INLINE_START( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, ContinueHdl_Impl, Button *, EMPTYARG ) { if( !bBusy ) { @@ -445,69 +558,100 @@ IMPL_LINK_INLINE_START( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYAR } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, CancelHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, CancelHdl_Impl, Button *, EMPTYARG ) { if( !bBusy ) { bBusy = sal_True; pHyphWrapper->SpellEnd(); - EndDialog( RET_CANCEL ); + m_pDialog->EndDialog( RET_CANCEL ); bBusy = sal_False; } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, CancelHdl_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, Left_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, Left_Impl, Button *, EMPTYARG ) { if( !bBusy ) { bBusy = sal_True; - SelLeft(); + SelLeft_Impl(); bBusy = sal_False; } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, Left_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, Right_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, Right_Impl, Button *, EMPTYARG ) { if( !bBusy ) { bBusy = sal_True; - SelRight(); + SelRight_Impl(); bBusy = sal_False; } return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, Right_Impl, Button *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxHyphenWordDialog, GetFocusHdl_Impl, Edit *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, GetFocusHdl_Impl, Edit *, EMPTYARG ) { aWordEdit.SetSelection( Selection( nOldPos, nOldPos + 1 ) ); return 0; } -IMPL_LINK_INLINE_END( SvxHyphenWordDialog, GetFocusHdl_Impl, Edit *, EMPTYARG ) -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, LangError_Impl, void *, nLang ) +// class SvxHyphenWordDialog --------------------------------------------- + +SvxHyphenWordDialog::SvxHyphenWordDialog( + const String &rWord, LanguageType nLang, + Window* pParent, + uno::Reference< linguistic2::XHyphenator > &xHyphen, + SvxSpellWrapper* pWrapper ) : + + SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_HYPHENATE ) ) { - // Status anzeigen - String aErr( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_IntPtr)nLang ) ); - aErr += CUI_RESSTR( RID_SVXSTR_HMERR_CHECKINSTALL ); - InfoBox( this, aErr ).Execute(); - return 0; + m_pImpl = std::auto_ptr< SvxHyphenWordDialog_Impl >( + new SvxHyphenWordDialog_Impl( this, rWord, nLang, xHyphen, pWrapper ) ); + + FreeResource(); + + SetWindowTitle( nLang ); + + // disable controls if service is not available + if (!m_pImpl->xHyphenator.is()) + Enable( sal_False ); +} + + +SvxHyphenWordDialog::~SvxHyphenWordDialog() +{ +} + + +void SvxHyphenWordDialog::SetWindowTitle( LanguageType nLang ) +{ + String aLangStr( SvtLanguageTable::GetLanguageString( nLang ) ); + String aTmp( m_pImpl->aLabel ); + aTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); + aTmp.Append( aLangStr ); + aTmp.Append( sal_Unicode( ')' ) ); + SetText( aTmp ); +} + + +void SvxHyphenWordDialog::SelLeft() +{ + m_pImpl->SelRight_Impl(); +} + + +void SvxHyphenWordDialog::SelRight() +{ + m_pImpl->SelLeft_Impl(); } diff --git a/cui/source/dialogs/hyphen.hrc b/cui/source/dialogs/hyphen.hrc index 2c6722298655..f76e2aa75770 100644..100755 --- a/cui/source/dialogs/hyphen.hrc +++ b/cui/source/dialogs/hyphen.hrc @@ -33,13 +33,14 @@ #define BTN_LEFT 11 #define BTN_RIGHT 12 #define FT_WORD 13 +#define FL_BOTTOM 14 #define BTN_HYPH_CONTINUE 20 #define BTN_HYPH_DELETE 21 #define BTN_HYPH_CUT 22 #define BTN_HYPH_CANCEL 23 #define BTN_HYPH_HELP 24 - +#define BTN_HYPH_ALL 25 #endif diff --git a/cui/source/dialogs/hyphen.src b/cui/source/dialogs/hyphen.src index 71720867fcc9..f10e94626f31 100644..100755 --- a/cui/source/dialogs/hyphen.src +++ b/cui/source/dialogs/hyphen.src @@ -40,104 +40,87 @@ String RID_SVXSTR_HMERR_CHECKINSTALL ModalDialog RID_SVXDLG_HYPHENATE { HelpId = HID_HYPHENATE ; - Size = MAP_APPFONT ( 188 , 100 ) ; + Size = MAP_APPFONT ( 200 , 111 ) ; OutputSize = TRUE ; SvLook = TRUE ; Text [ en-US ] = "Hyphenation" ; Moveable = TRUE ; + + FixedText FT_WORD + { + Pos = MAP_APPFONT ( 5 , 5 ) ; + Size = MAP_APPFONT ( 120 , 8 ) ; + Text [ en-US ] = "~Word" ; + }; Edit ED_WORD { BORDER = TRUE ; - Pos = MAP_APPFONT ( 6 , 17 ) ; - Size = MAP_APPFONT ( 120 , 12 ) ; + Pos = MAP_APPFONT ( 5 , 17 ) ; + Size = MAP_APPFONT ( 132 , 12 ) ; TABSTOP = TRUE ; LEFT = TRUE ; }; ImageButton BTN_LEFT { - Pos = MAP_APPFONT ( 6 , 33 ) ; + Pos = MAP_APPFONT ( 56 , 33 ) ; Size = MAP_APPFONT ( 14 , 14 ) ; TABSTOP = TRUE ; SYMBOL = IMAGEBUTTON_ARROW_LEFT ; }; ImageButton BTN_RIGHT { - Pos = MAP_APPFONT ( 22 , 33 ) ; + Pos = MAP_APPFONT ( 75 , 33 ) ; Size = MAP_APPFONT ( 14 , 14 ) ; TABSTOP = TRUE ; Symbol = IMAGEBUTTON_ARROW_RIGHT ; }; - FixedText FT_WORD + OKButton BTN_HYPH_CUT { - Pos = MAP_APPFONT ( 6 , 6 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; - Text [ en-US ] = "~Word" ; + Pos = MAP_APPFONT ( 144 , 17 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + Text [ en-US ] = "H~yphenate" ; + TABSTOP = TRUE ; + DEFBUTTON = TRUE ; }; PushButton BTN_HYPH_CONTINUE { - Pos = MAP_APPFONT ( 132 , 43 ) ; + Pos = MAP_APPFONT ( 144 , 35 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; - Text [ en-US ] = "~Next" ; + Text [ en-US ] = "~Skip" ; TABSTOP = TRUE ; }; PushButton BTN_HYPH_DELETE { - Pos = MAP_APPFONT ( 132 , 60 ) ; + Pos = MAP_APPFONT ( 144 , 52 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; Text [ en-US ] = "~Remove" ; TABSTOP = TRUE ; }; - OKButton BTN_HYPH_CUT + FixedLine FL_BOTTOM + { + Pos = MAP_APPFONT ( 0 , 81 ) ; + Size = MAP_APPFONT ( 200 , 8 ) ; + }; + HelpButton BTN_HYPH_HELP { - Pos = MAP_APPFONT ( 132 , 6 ) ; + Pos = MAP_APPFONT ( 5 , 93 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; - Text [ en-US ] = "~Hyphenate" ; TABSTOP = TRUE ; - DEFBUTTON = TRUE ; }; - CancelButton BTN_HYPH_CANCEL + PushButton BTN_HYPH_ALL { - Pos = MAP_APPFONT ( 132 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT ( 63 , 93 ) ; + Size = MAP_APPFONT ( 74 , 14 ) ; + Text [ en-US ] = "Hyphenate ~All" ; TABSTOP = TRUE ; }; - HelpButton BTN_HYPH_HELP + CancelButton BTN_HYPH_CANCEL { - Pos = MAP_APPFONT ( 132 , 80 ) ; + Pos = MAP_APPFONT ( 144 , 93 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; + Text [ en-US ] = "~Close"; TABSTOP = TRUE ; }; }; - // ******************************************************************* EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index c1a96541c5b7..bf617b126747 100644..100755 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -26,10 +26,21 @@ ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove + #include "precompiled_cui.hxx" +#include "thesdlg.hrc" +#include "thesdlg.hxx" +#include "thesdlg_impl.hxx" +#include "cuires.hrc" +#include "dialmgr.hxx" + +#include <editeng/unolingu.hxx> #include <tools/shl.hxx> #include <svl/lngmisc.hxx> +#include <svtools/filter.hxx> +#include <svtools/svlbitm.hxx> +#include <svtools/svtreebx.hxx> #include <vcl/wrkwin.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> @@ -39,25 +50,28 @@ #include <svx/dlgutil.hxx> #include <svx/dialmgr.hxx> #include <svx/svxerr.hxx> -#include "cuires.hrc" -#include "thesdlg.hrc" #include <editeng/unolingu.hxx> #include <svx/langbox.hxx> #include <svtools/langtab.hxx> -#include "dialmgr.hxx" -#include <svx/dialogs.hrc> -#include <editeng/editerr.hxx> +#include <unotools/lingucfg.hxx> +#include <i18npool/mslangid.hxx> +#include <comphelper/processfactory.hxx> +#include <osl/file.hxx> + + +#include <stack> +#include <algorithm> + +#include <com/sun/star/linguistic2/XThesaurus.hpp> +#include <com/sun/star/linguistic2/XMeaning.hpp> +#include <com/sun/star/linguistic2/XLinguServiceManager.hpp> using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::linguistic2; +using ::rtl::OUString; + + +#define A2S(x) String::CreateFromAscii( x ) -#undef S2U -#undef U2S -//#define S2U(s) StringToOUString(s, CHARSET_SYSTEM) -//#define U2S(s) OUStringToString(s, CHARSET_SYSTEM) // GetReplaceEditString ------------------------------- @@ -89,171 +103,237 @@ static void GetReplaceEditString( String &rText ) rText.EraseLeadingAndTrailingChars( sal_Unicode(' ') ); } -// struct ThesDlg_Impl --------------------------------------------------- +// class LookUpComboBox_Impl -------------------------------------------------- -struct ThesDlg_Impl +LookUpComboBox_Impl::LookUpComboBox_Impl( + Window *pParent, const ResId &rResId, SvxThesaurusDialog_Impl &rImpl ) : + ComboBox (pParent, rResId), + m_rDialogImpl( rImpl ) { - Reference< XThesaurus > xThesaurus; - ::rtl::OUString aLookUpText; - sal_Int16 nLookUpLanguage; + m_aModifyTimer.SetTimeoutHdl( LINK( this, LookUpComboBox_Impl, ModifyTimer_Hdl ) ); + m_aModifyTimer.SetTimeout( 500 ); + + EnableAutocomplete( FALSE ); +} - ThesDlg_Impl( Reference< XThesaurus > & xThes ); - SfxErrorContext* pErrContext; // ErrorContext, - // w"ahrend der Dialog oben ist -}; -ThesDlg_Impl::ThesDlg_Impl(Reference< XThesaurus > & xThes) : - xThesaurus (xThes) +LookUpComboBox_Impl::~LookUpComboBox_Impl() { - pErrContext = NULL; - nLookUpLanguage = LANGUAGE_NONE; } -// class SvxThesaurusLanguageDlg_Impl ------------------------------------ +void LookUpComboBox_Impl::Modify() +{ + m_aModifyTimer.Start(); +} + -class SvxThesaurusLanguageDlg_Impl : public ModalDialog +IMPL_LINK( LookUpComboBox_Impl, ModifyTimer_Hdl, Timer *, EMPTYARG /*pTimer*/ ) { -private: - SvxLanguageBox aLangLB; - FixedLine aLangFL; - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; + m_rDialogImpl.LookUp( GetText() ); + m_aModifyTimer.Stop(); + return 0; +} - DECL_LINK( DoubleClickHdl_Impl, ListBox * ); -public: - SvxThesaurusLanguageDlg_Impl( Window* pParent ); +// class ReplaceEdit_Impl -------------------------------------------------- - sal_uInt16 GetLanguage() const; - void SetLanguage( sal_uInt16 nLang ); -}; +ReplaceEdit_Impl::ReplaceEdit_Impl( + Window *pParent, const ResId &rResId ) : + Edit (pParent, rResId) +{ +} -// ----------------------------------------------------------------------- +ReplaceEdit_Impl::~ReplaceEdit_Impl() +{ +} -SvxThesaurusLanguageDlg_Impl::SvxThesaurusLanguageDlg_Impl( Window* pParent ) : - ModalDialog( pParent, CUI_RES( RID_SVXDLG_THES_LANGUAGE ) ), +void ReplaceEdit_Impl::Modify() +{ + if (m_pBtn) + m_pBtn->Enable( GetText().Len() > 0 ); +} - aLangLB ( this, CUI_RES( LB_THES_LANGUAGE ) ), - aLangFL ( this, CUI_RES( FL_THES_LANGUAGE ) ), - aOKBtn ( this, CUI_RES( BTN_LANG_OK ) ), - aCancelBtn ( this, CUI_RES( BTN_LANG_CANCEL ) ), - aHelpBtn ( this, CUI_RES( BTN_LANG_HELP ) ) +void ReplaceEdit_Impl::SetText( const XubString& rStr ) { - FreeResource(); + Edit::SetText( rStr ); + Modify(); +} - aLangLB.SetLanguageList( LANG_LIST_THES_USED, FALSE, FALSE ); - aLangLB.SetDoubleClickHdl( - LINK( this, SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl ) ); + +void ReplaceEdit_Impl::SetText( const XubString& rStr, const Selection& rNewSelection ) +{ + Edit::SetText( rStr, rNewSelection ); + Modify(); } -// ----------------------------------------------------------------------- +// class ThesaurusAlternativesCtrl_Impl ---------------------------------- -sal_uInt16 SvxThesaurusLanguageDlg_Impl::GetLanguage() const +void AlternativesString_Impl::Paint( + const Point& rPos, + SvLBox& rDev, USHORT, + SvLBoxEntry* pEntry ) { - sal_uInt16 nLang = aLangLB.GetSelectLanguage(); - return nLang; + AlternativesUserData_Impl* pData = (AlternativesUserData_Impl*)pEntry->GetUserData(); + Point aPos( rPos ); + Font aOldFont( rDev.GetFont()); + if (pData && pData->IsHeader()) + { + Font aFont( aOldFont ); + aFont.SetWeight( WEIGHT_BOLD ); + rDev.SetFont( aFont ); + aPos.X() = 0; + } + else + aPos.X() += 5; + rDev.DrawText( aPos, GetText() ); + rDev.SetFont( aOldFont ); } -// ----------------------------------------------------------------------- -void SvxThesaurusLanguageDlg_Impl::SetLanguage( sal_uInt16 nLang ) +ThesaurusAlternativesCtrl_Impl::ThesaurusAlternativesCtrl_Impl( + Window* pParent, + SvxThesaurusDialog_Impl &rImpl ) : + SvxCheckListBox( pParent, CUI_RES( CT_THES_ALTERNATIVES ) ), + m_rDialogImpl( rImpl ) { - aLangLB.SelectLanguage( nLang ); + SetWindowBits( WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE ); + SetHighlightRange(); } -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl, ListBox *, EMPTYARG ) +ThesaurusAlternativesCtrl_Impl::~ThesaurusAlternativesCtrl_Impl() { - EndDialog( RET_OK ); - return 0; + ClearUserData(); } -IMPL_LINK_INLINE_END( SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl, ListBox *, EMPTYARG ) -// class SvxThesaurusDialog ---------------------------------------------- +void ThesaurusAlternativesCtrl_Impl::ClearUserData() +{ + for (USHORT i = 0; i < GetEntryCount(); ++i) + delete (AlternativesUserData_Impl*)GetEntry(i)->GetUserData(); +} -// ----------------------------------------------------------------------- - - -SvxThesaurusDialog::SvxThesaurusDialog( Window* pParent, Reference< XThesaurus > xThes, - const String &rWord, sal_Int16 nLanguage) : - - SvxStandardDialog( pParent, CUI_RES( RID_SVXDLG_THESAURUS ) ), - - aWordText ( this, CUI_RES( FT_WORD ) ), - aWordLB ( this, CUI_RES( LB_WORD ) ), - aReplaceText( this, CUI_RES( FT_REPL ) ), - aReplaceEdit( this, CUI_RES( ED_REPL ) ), - aMeanText ( this, CUI_RES( FT_MEAN ) ), - aMeanLB ( this, CUI_RES( LB_MEAN ) ), - aSynonymText( this, CUI_RES( FT_SYNON ) ), - aSynonymLB ( this, CUI_RES( LB_SYNON ) ), - aVarFL ( this, CUI_RES( FL_VAR ) ), - aOkBtn ( this, CUI_RES( BTN_THES_OK ) ), - aCancelBtn ( this, CUI_RES( BTN_THES_CANCEL ) ), - aLookUpBtn ( this, CUI_RES( BTN_LOOKUP ) ), - aLangBtn ( this, CUI_RES( BTN_LANGUAGE ) ), - aHelpBtn ( this, CUI_RES( BTN_THES_HELP ) ), - aErrStr ( CUI_RES( STR_ERR_WORDNOTFOUND ) ) -{ - pImpl = new ThesDlg_Impl( xThes ); - pImpl->aLookUpText = ::rtl::OUString( rWord ); - pImpl->nLookUpLanguage = nLanguage; - pImpl->pErrContext = - new SfxErrorContext( ERRCTX_SVX_LINGU_THESAURUS, String(), this, - RID_SVXERRCTX, &DIALOG_MGR() ); - - aLangBtn.SetClickHdl( LINK( this, SvxThesaurusDialog, LanguageHdl_Impl ) ); - aLookUpBtn.SetClickHdl( LINK( this, SvxThesaurusDialog, LookUpHdl_Impl ) ); - aMeanLB.SetSelectHdl( LINK( this, SvxThesaurusDialog, EntryHdl_Impl ) ); - aSynonymLB.SetSelectHdl( LINK( this, SvxThesaurusDialog, SynonymHdl_Impl ) ); - Link aLink = LINK( this, SvxThesaurusDialog, SelectHdl_Impl ); - aMeanLB.SetDoubleClickHdl( aLink ); - aSynonymLB.SetDoubleClickHdl( aLink ); - aWordLB.SetSelectHdl( aLink ); - FreeResource(); +SvLBoxEntry * ThesaurusAlternativesCtrl_Impl::AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader ) +{ + SvLBoxEntry* pEntry = new SvLBoxEntry; + String aText; + if (bIsHeader && nVal >= 0) + { + aText = String::CreateFromInt32( nVal ); + aText += A2S( ". " ); + } + pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) ); // add empty column + aText += rText; + pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) ); // otherwise crash + pEntry->AddItem( new AlternativesString_Impl( pEntry, 0, aText ) ); - ::rtl::OUString aTmp( rWord ); - linguistic::RemoveHyphens( aTmp ); - linguistic::ReplaceControlChars( aTmp ); - aReplaceEdit.SetText( aTmp ); - aWordLB.InsertEntry( aTmp ); - aWordLB.SelectEntry( aTmp ); + AlternativesUserData_Impl* pUserData = new AlternativesUserData_Impl( rText, bIsHeader ); + pEntry->SetUserData( pUserData ); + GetModel()->Insert( pEntry ); - Init_Impl( nLanguage ); + if (bIsHeader) + GetViewDataEntry( pEntry )->SetSelectable( false ); - // disable controls if service is missing - if (!pImpl->xThesaurus.is()) - Enable( sal_False ); + return pEntry; } -// ----------------------------------------------------------------------- +void ThesaurusAlternativesCtrl_Impl::KeyInput( const KeyEvent& rKEvt ) +{ + const KeyCode& rKey = rKEvt.GetKeyCode(); + + if (rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_ESCAPE) + GetParent()->KeyInput( rKEvt ); // parent will close dialog... + else if (rKey.GetCode() == KEY_SPACE) + m_rDialogImpl.AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry + else if (GetEntryCount()) + SvxCheckListBox::KeyInput( rKEvt ); +} -SvxThesaurusDialog::~SvxThesaurusDialog() + +void ThesaurusAlternativesCtrl_Impl::Paint( const Rectangle& rRect ) +{ + if (!m_rDialogImpl.m_bWordFound) + { +/* Push( PUSH_FONT ); + + Font aFont( GetFont() ); + aFont.SetHeight( 2 * aFont.GetHeight() ); + SetFont( aFont ); +*/ + Size aTextSize( GetTextWidth( m_rDialogImpl.aErrStr ), GetTextHeight() ); + aTextSize = LogicToPixel( aTextSize ); + Point aPos; + aPos.X() += GetSizePixel().Width() / 2 - aTextSize.Width() / 2; + aPos.Y() += GetSizePixel().Height() / 2 /*- aTextSize.Height() / 2*/; + aPos = PixelToLogic( aPos ); + DrawText( aPos, m_rDialogImpl.aErrStr ); + +// Pop(); + } + else + SvxCheckListBox::Paint( rRect ); +} + + +// struct SvxThesaurusDialog_Impl ---------------------------------------- + +SvxThesaurusDialog_Impl::SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ) : + m_pDialog ( pDialog ), + aVendorImageFI ( pDialog, CUI_RES( IMG_VENDOR ) ), + aLeftBtn ( pDialog, CUI_RES( BTN_LEFT ) ), + aWordText ( pDialog, CUI_RES( FT_WORD ) ), + aWordCB ( pDialog, CUI_RES( CB_WORD ), *this ), + m_aAlternativesText ( pDialog, CUI_RES( FT_THES_ALTERNATIVES ) ), + m_pAlternativesCT ( new ThesaurusAlternativesCtrl_Impl( pDialog, *this ) ), + aReplaceText ( pDialog, CUI_RES( FT_REPL ) ), + aReplaceEdit ( pDialog, CUI_RES( ED_REPL ) ), + aFL ( pDialog, CUI_RES( FL_VAR ) ), + aHelpBtn ( pDialog, CUI_RES( BTN_THES_HELP ) ), + aLangMBtn ( pDialog, CUI_RES( MB_LANGUAGE ) ), + aReplaceBtn ( pDialog, CUI_RES( BTN_THES_OK ) ), + aCancelBtn ( pDialog, CUI_RES( BTN_THES_CANCEL ) ), + aErrStr ( CUI_RES( STR_ERR_TEXTNOTFOUND ) ), + aVendorDefaultImage ( CUI_RES( IMG_DEFAULT_VENDOR ) ), + aVendorDefaultImageHC ( CUI_RES( IMG_DEFAULT_VENDOR_HC ) ), + xThesaurus ( NULL ), + aLookUpText (), + nLookUpLanguage ( LANGUAGE_NONE ), + m_bWordFound( false ) +{ + // note: FreeResource must only be called in the c-tor of SvxThesaurusDialog + + aReplaceEdit.SetButton( &aReplaceBtn ); + + aLeftBtn.SetClickHdl( LINK( this, SvxThesaurusDialog_Impl, LeftBtnHdl_Impl ) ); + aWordCB.SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, WordSelectHdl_Impl ) ); + aLangMBtn.SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, LanguageHdl_Impl ) ); + m_pAlternativesCT->SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, AlternativesSelectHdl_Impl )); + m_pAlternativesCT->SetDoubleClickHdl( LINK( this, SvxThesaurusDialog_Impl, AlternativesDoubleClickHdl_Impl )); + + Application::PostUserEvent( STATIC_LINK( this, SvxThesaurusDialog_Impl, VendorImageInitHdl ) ); +} + + +SvxThesaurusDialog_Impl::~SvxThesaurusDialog_Impl() { - delete pImpl->pErrContext; - delete pImpl; + delete aLangMBtn.GetPopupMenu(); } -// ----------------------------------------------------------------------- -uno::Sequence< Reference< XMeaning > > SAL_CALL - SvxThesaurusDialog::queryMeanings_Impl( - ::rtl::OUString& rTerm, - const Locale& rLocale, - const beans::PropertyValues& rProperties ) - throw(lang::IllegalArgumentException, uno::RuntimeException) +uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL SvxThesaurusDialog_Impl::queryMeanings_Impl( + OUString& rTerm, + const lang::Locale& rLocale, + const beans::PropertyValues& rProperties ) + throw(lang::IllegalArgumentException, uno::RuntimeException) { - uno::Sequence< Reference< XMeaning > > aMeanings( - pImpl->xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) ); + uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings( + xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) ); // text with '.' at the end? if (0 == aMeanings.getLength() && rTerm.getLength() && @@ -263,7 +343,7 @@ uno::Sequence< Reference< XMeaning > > SAL_CALL // end of a sentence and not an abbreviation... String aTxt( rTerm ); aTxt.EraseTrailingChars( '.' ); - aMeanings = pImpl->xThesaurus->queryMeanings( aTxt, rLocale, rProperties ); + aMeanings = xThesaurus->queryMeanings( aTxt, rLocale, rProperties ); if (aMeanings.getLength()) { rTerm = aTxt; @@ -273,220 +353,394 @@ uno::Sequence< Reference< XMeaning > > SAL_CALL return aMeanings; } -// ----------------------------------------------------------------------- -sal_uInt16 SvxThesaurusDialog::GetLanguage() const +bool SvxThesaurusDialog_Impl::UpdateAlternativesBox_Impl() { - return pImpl->nLookUpLanguage; + lang::Locale aLocale( SvxCreateLocale( nLookUpLanguage ) ); + uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings = queryMeanings_Impl( + aLookUpText, aLocale, uno::Sequence< beans::PropertyValue >() ); + const sal_Int32 nMeanings = aMeanings.getLength(); + const uno::Reference< linguistic2::XMeaning > *pMeanings = aMeanings.getConstArray(); + + m_pAlternativesCT->SetUpdateMode( FALSE ); + + // clear old user data of control before creating new ones via AddEntry below + m_pAlternativesCT->ClearUserData(); + + m_pAlternativesCT->Clear(); + for (sal_Int32 i = 0; i < nMeanings; ++i) + { + OUString rMeaningTxt = pMeanings[i]->getMeaning(); + uno::Sequence< OUString > aSynonyms( pMeanings[i]->querySynonyms() ); + const sal_Int32 nSynonyms = aSynonyms.getLength(); + const OUString *pSynonyms = aSynonyms.getConstArray(); + DBG_ASSERT( rMeaningTxt.getLength() > 0, "meaning with empty text" ); + DBG_ASSERT( nSynonyms > 0, "meaning without synonym" ); + + m_pAlternativesCT->AddEntry( i + 1, rMeaningTxt, true ); + for (sal_Int32 k = 0; k < nSynonyms; ++k) + m_pAlternativesCT->AddEntry( -1, pSynonyms[k], false ); + } + + m_pAlternativesCT->SetUpdateMode( TRUE ); + + return nMeanings > 0; } -// ----------------------------------------------------------------------- -void SvxThesaurusDialog::UpdateMeaningBox_Impl( uno::Sequence< Reference< XMeaning > > *pMeaningSeq ) +void SvxThesaurusDialog_Impl::LookUp( const String &rText ) { - // create temporary meaning list if not supplied from somewhere else - sal_Bool bTmpSeq = sal_False; - if (!pMeaningSeq && pImpl->xThesaurus.is()) - { - bTmpSeq = sal_True; - lang::Locale aLocale( SvxCreateLocale( pImpl->nLookUpLanguage ) ); - uno::Sequence< Reference< XMeaning > > aTmpMean = queryMeanings_Impl( - pImpl->aLookUpText, aLocale, Sequence< PropertyValue >() ); + if (rText != aWordCB.GetText()) // avoid moving of the cursor if the text is the same + aWordCB.SetText( rText ); + LookUp_Impl(); +} - pMeaningSeq = new Sequence< Reference< XMeaning > > ( aTmpMean ); - // set new replace edit text if a different look up text was used - // see: queryMeanings_Impl - aReplaceEdit.SetText( pImpl->aLookUpText ); +IMPL_LINK( SvxThesaurusDialog_Impl, LeftBtnHdl_Impl, Button *, pBtn ) +{ + if (pBtn && aLookUpHistory.size() >= 2) + { + aLookUpHistory.pop(); // remove current look up word from stack + aWordCB.SetText( aLookUpHistory.top() ); // retrieve previous look up word + aLookUpHistory.pop(); + LookUp_Impl(); } + return 0; +} - sal_Int32 nMeaningCount = pMeaningSeq ? pMeaningSeq->getLength() : 0; - const Reference< XMeaning > *pMeaning = pMeaningSeq ? pMeaningSeq->getConstArray() : NULL; - aMeanLB.Clear(); - for ( sal_Int32 i = 0; i < nMeaningCount; ++i ) - aMeanLB.InsertEntry( pMeaning[i]->getMeaning() ); - - // remove temporary meaning list - if (bTmpSeq) - delete pMeaningSeq; - if (aMeanLB.GetEntryCount() > 0) - aMeanLB.SelectEntryPos(0); - UpdateSynonymBox_Impl(); +IMPL_LINK( SvxThesaurusDialog_Impl, LanguageHdl_Impl, MenuButton *, pBtn ) +{ + PopupMenu *pMenu = aLangMBtn.GetPopupMenu(); + if (pMenu && pBtn) + { + USHORT nItem = pBtn->GetCurItemId(); + String aLangText( pMenu->GetItemText( nItem ) ); + LanguageType nLang = SvtLanguageTable().GetType( aLangText ); + DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" ); + if (xThesaurus->hasLocale( SvxCreateLocale( nLang ) )) + nLookUpLanguage = nLang; + m_pDialog->SetWindowTitle( nLang ); + UpdateVendorImage(); + LookUp_Impl(); + } + return 0; } -// ----------------------------------------------------------------------- -void SvxThesaurusDialog::UpdateSynonymBox_Impl() +void SvxThesaurusDialog_Impl::LookUp_Impl() { + String aText( aWordCB.GetText() ); + + aLookUpText = OUString( aText ); + if (aLookUpText.getLength() > 0 && + (aLookUpHistory.size() == 0 || aLookUpText != aLookUpHistory.top())) + aLookUpHistory.push( aLookUpText ); + + m_bWordFound = UpdateAlternativesBox_Impl(); + m_pAlternativesCT->Enable( m_bWordFound ); - aSynonymLB.Clear(); + if ( aWordCB.GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND ) + aWordCB.InsertEntry( aText ); - sal_uInt16 nPos = aMeanLB.GetSelectEntryPos(); // active meaning pos - if (nPos != LISTBOX_ENTRY_NOTFOUND && pImpl->xThesaurus.is()) + aReplaceEdit.SetText( String() ); + aLeftBtn.Enable( aLookUpHistory.size() > 1 ); +} + + +IMPL_LINK( SvxThesaurusDialog_Impl, WordSelectHdl_Impl, ComboBox *, pBox ) +{ + if (pBox && !aWordCB.IsTravelSelect()) // act only upon return key and not when traveling with cursor keys { - // get Reference< XMeaning > for selected meaning - lang::Locale aLocale( SvxCreateLocale( pImpl->nLookUpLanguage ) ); - Reference< XMeaning > xMeaning = queryMeanings_Impl( - pImpl->aLookUpText, aLocale, Sequence< PropertyValue >() ) - .getConstArray()[ nPos ]; - - uno::Sequence< ::rtl::OUString > aSynonyms; - if (xMeaning.is()) - aSynonyms = xMeaning->querySynonyms(); - - sal_Int32 nSynonymCount = aSynonyms.getLength(); - const ::rtl::OUString *pSynonym = aSynonyms.getConstArray(); - for ( sal_Int32 i=0; i < nSynonymCount; ++i ) - aSynonymLB.InsertEntry( pSynonym[i] ); + USHORT nPos = pBox->GetSelectEntryPos(); + String aStr( pBox->GetEntry( nPos ) ); + GetReplaceEditString( aStr ); + aWordCB.SetText( aStr ); + LookUp_Impl(); } + return 0; } -// ----------------------------------------------------------------------- -void SvxThesaurusDialog::Apply() +IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesSelectHdl_Impl, SvxCheckListBox *, pBox ) { + SvLBoxEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL; + if (pEntry) + { + AlternativesUserData_Impl * pData = (AlternativesUserData_Impl *) pEntry->GetUserData(); + String aStr; + if (!pData->IsHeader()) + { + aStr = pData->GetText(); + GetReplaceEditString( aStr ); + } + aReplaceEdit.SetText( aStr ); + } + return 0; } -// ----------------------------------------------------------------------- -void SvxThesaurusDialog::Init_Impl(sal_Int16 nLanguage) + +IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesDoubleClickHdl_Impl, SvxCheckListBox *, pBox ) { - // Sprache anpassen - String aStr( GetText() ); - aStr.Erase( aStr.Search( sal_Unicode( '(' ) ) - 1 ); - aStr.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ) ); - //aStr += GetLanguageString( (LanguageType)pImpl->pThesaurus->GetLanguage() ); - aStr += SvtLanguageTable::GetLanguageString( (LanguageType) nLanguage ); - aStr.Append( sal_Unicode( ')' ) ); - SetText( aStr ); // Text der Window-Leiste setzen (Wort + Sprache) + SvLBoxEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL; + if (pEntry) + { + AlternativesUserData_Impl * pData = (AlternativesUserData_Impl *) pEntry->GetUserData(); + String aStr; + if (!pData->IsHeader()) + { + aStr = pData->GetText(); + GetReplaceEditString( aStr ); + } - // adapt meanings according to (new) language - UpdateMeaningBox_Impl(); + aWordCB.SetText( aStr ); + if (aStr.Len() > 0) + LookUp_Impl(); + } + + //! workaround to set the selection since calling SelectEntryPos within + //! the double click handler does not work + Application::PostUserEvent( STATIC_LINK( this, SvxThesaurusDialog_Impl, SelectFirstHdl_Impl ), pBox ); + return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, LookUpHdl_Impl, Button *, pBtn ) +IMPL_STATIC_LINK( SvxThesaurusDialog_Impl, SelectFirstHdl_Impl, SvxCheckListBox *, pBox ) { + (void) pThis; + if (pBox && pBox->GetEntryCount() > 0) + pBox->SelectEntryPos( 0 ); + return 0; +} - EnterWait(); +//////////////////////////////////////////////////////////// - String aText( aReplaceEdit.GetText() ); +static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl ) +{ + Image aRes; + + OUString aTmp; + osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp ); + + Graphic aGraphic; + const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) ); + if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic, NULL, NULL ) ) + { + aRes = Image( aGraphic.GetBitmapEx() ); + } + return aRes; +} - ::rtl::OUString aOldLookUpText = pImpl->aLookUpText; - pImpl->aLookUpText = ::rtl::OUString( aText ); - uno::Sequence< Reference< XMeaning > > aMeanings; - if (pImpl->xThesaurus.is()) - aMeanings = queryMeanings_Impl( - pImpl->aLookUpText, - SvxCreateLocale( pImpl->nLookUpLanguage ), - Sequence< PropertyValue >() ); +static String lcl_GetThesImplName( const lang::Locale &rLocale ) +{ + String aRes; - LeaveWait(); - if ( aMeanings.getLength() == 0 ) + uno::Reference< linguistic2::XLinguServiceManager > xLngMgr; + try { - if( pBtn == &aCancelBtn ) // called via double click - { - pImpl->aLookUpText = aOldLookUpText; - } - else + uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); + xLngMgr = uno::Reference< linguistic2::XLinguServiceManager >( xMSF->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.linguistic2.LinguServiceManager" ))), uno::UNO_QUERY_THROW ); + + DBG_ASSERT( xLngMgr.is(), "LinguServiceManager missing" ); + if (xLngMgr.is()) { - UpdateMeaningBox_Impl( &aMeanings ); - if( pBtn == &aLookUpBtn ) - InfoBox( this, aErrStr ).Execute(); + uno::Sequence< OUString > aServiceNames = xLngMgr->getConfiguredServices( + OUString::createFromAscii("com.sun.star.linguistic2.Thesaurus"), rLocale ); + // there should be at most one thesaurus configured for each language + DBG_ASSERT( aServiceNames.getLength() <= 1, "more than one thesaurus found. Should not be possible" ); + if (aServiceNames.getLength() == 1) + aRes = aServiceNames[0]; } - return 0; + } + catch (uno::Exception &e) + { + (void) e; + DBG_ASSERT( 0, "failed to get thesaurus" ); } - UpdateMeaningBox_Impl( &aMeanings ); + return aRes; +} - if ( aWordLB.GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND ) - aWordLB.InsertEntry( aText ); - aWordLB.SelectEntry( aText ); - aMeanLB.SelectEntryPos( 0 ); +void SvxThesaurusDialog_Impl::UpdateVendorImage() +{ + m_pDialog->SetUpdateMode( sal_False ); - String aStr( aMeanLB.GetSelectEntry() ); - GetReplaceEditString( aStr ); - aReplaceEdit.SetText( aStr ); - aSynonymLB.SetNoSelection(); + SvtLinguConfig aCfg; + if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) + { + const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); - return 0; + Image aImage; + String sThesImplName( lcl_GetThesImplName( SvxCreateLocale( nLookUpLanguage ) ) ); + OUString aThesDialogImageUrl( aCfg.GetThesaurusDialogImage( sThesImplName, bHC ) ); + if (sThesImplName.Len() > 0 && aThesDialogImageUrl.getLength() > 0) + aImage = Image( lcl_GetImageFromPngUrl( aThesDialogImageUrl ) ); + else + aImage = bHC ? aVendorDefaultImageHC : aVendorDefaultImage; + aVendorImageFI.SetImage( aImage ); + } + + m_pDialog->SetUpdateMode( sal_True ); } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, Button *, EMPTYARG ) +IMPL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl *, EMPTYARG ) { - if (!pImpl->xThesaurus.is()) - return 0; + pThis->m_pDialog->SetUpdateMode( sal_False ); - SvxThesaurusLanguageDlg_Impl aDlg( this ); - sal_uInt16 nLang = pImpl->nLookUpLanguage; - aDlg.SetLanguage( nLang ); - - if ( aDlg.Execute() == RET_OK ) + SvtLinguConfig aCfg; + if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) { - nLang = aDlg.GetLanguage(); - if (pImpl->xThesaurus->hasLocale( SvxCreateLocale( nLang ) )) - pImpl->nLookUpLanguage = nLang; - UpdateMeaningBox_Impl(); - Init_Impl( nLang ); + const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); + Image aImage( bHC ? pThis->aVendorDefaultImageHC : pThis->aVendorDefaultImage ); + pThis->aVendorImageFI.SetImage( aImage ); + pThis->aVendorImageFI.Show(); + + // move down visible controls according to the vendor images height + Size aVendorSize = pThis->aVendorImageFI.GetSizePixel(); + Size aImageSize = pThis->aVendorImageFI.GetImage().GetSizePixel(); + if (aImageSize.Height()) + { + aVendorSize.Height() = aImageSize.Height(); + if(aVendorSize.Width() < aImageSize.Width()) + aVendorSize.Width() = aImageSize.Width(); + pThis->aVendorImageFI.SetSizePixel( aVendorSize ); + } + const sal_Int32 nDiff = aVendorSize.Height(); + pThis->aVendorImageFI.SetSizePixel( aVendorSize ); + Control* aControls[] = { + &pThis->aLeftBtn, + &pThis->aWordText, + &pThis->aWordCB, + &pThis->m_aAlternativesText, + pThis->m_pAlternativesCT.get(), + &pThis->aReplaceText, + &pThis->aReplaceEdit, + &pThis->aFL, + &pThis->aHelpBtn, + &pThis->aLangMBtn, + &pThis->aReplaceBtn, + &pThis->aCancelBtn, + 0 + }; + sal_Int32 nControl = 0; + while (aControls[nControl]) + { + Point aPos = aControls[nControl]->GetPosPixel(); + aPos.Y() += nDiff; + aControls[nControl]->SetPosPixel(aPos); + ++nControl; + } + Size aDlgSize = pThis->m_pDialog->GetSizePixel(); + aDlgSize.Height() += nDiff; + pThis->m_pDialog->SetSizePixel( aDlgSize ); + pThis->m_pDialog->Invalidate(); } + pThis->UpdateVendorImage(); + pThis->m_pDialog->SetUpdateMode( sal_True ); + return 0; -} +}; -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, SynonymHdl_Impl, ListBox *, EMPTYARG ) +// class SvxThesaurusDialog ---------------------------------------------- + +SvxThesaurusDialog::SvxThesaurusDialog( + Window* pParent, + uno::Reference< linguistic2::XThesaurus > xThes, + const String &rWord, + LanguageType nLanguage ) : + + SvxStandardDialog( pParent, CUI_RES( RID_SVXDLG_THESAURUS ) ) { - if ( aSynonymLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ) + m_pImpl = std::auto_ptr< SvxThesaurusDialog_Impl >(new SvxThesaurusDialog_Impl( this )); + + m_pImpl->xThesaurus = xThes; + m_pImpl->aLookUpText = OUString( rWord ); + m_pImpl->nLookUpLanguage = nLanguage; + if (rWord.Len() > 0) + m_pImpl->aLookUpHistory.push( rWord ); + + FreeResource(); + + OUString aTmp( rWord ); + linguistic::RemoveHyphens( aTmp ); + linguistic::ReplaceControlChars( aTmp ); + String aTmp2( aTmp ); + m_pImpl->aReplaceEdit.SetText( aTmp2 ); + m_pImpl->aWordCB.InsertEntry( aTmp2 ); + + m_pImpl->LookUp( aTmp2 ); + m_pImpl->m_pAlternativesCT->GrabFocus(); + m_pImpl->aLeftBtn.Enable( sal_False ); + + // fill language menu button list + SvtLanguageTable aLangTab; + uno::Sequence< lang::Locale > aLocales; + if (m_pImpl->xThesaurus.is()) + aLocales = m_pImpl->xThesaurus->getLocales(); + const sal_Int32 nLocales = aLocales.getLength(); + const lang::Locale *pLocales = aLocales.getConstArray(); + delete m_pImpl->aLangMBtn.GetPopupMenu(); + PopupMenu* pMenu = new PopupMenu; + pMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS ); + std::vector< OUString > aLangVec; + for (sal_Int32 i = 0; i < nLocales; ++i ) { - String aStr( aSynonymLB.GetSelectEntry() ); - GetReplaceEditString( aStr ); - aReplaceEdit.SetText( aStr ); + const LanguageType nLang = SvxLocaleToLanguage( pLocales[i] ); + DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" ); + aLangVec.push_back( aLangTab.GetString( nLang ) ); } - return 0; + std::sort( aLangVec.begin(), aLangVec.end() ); + for (size_t i = 0; i < aLangVec.size(); ++i) + pMenu->InsertItem( (USHORT)i+1, aLangVec[i] ); // menu items should be enumerated from 1 and not 0 + m_pImpl->aLangMBtn.SetPopupMenu( pMenu ); + + SetWindowTitle( nLanguage ); + + // disable controls if service is missing + if (!m_pImpl->xThesaurus.is()) + Enable( sal_False ); } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, SelectHdl_Impl, ListBox *, pBox ) +SvxThesaurusDialog::~SvxThesaurusDialog() { - String aStr( pBox->GetSelectEntry() ); - GetReplaceEditString( aStr ); - aReplaceEdit.SetText( aStr ); +} - //! 'aCancelBtn' is used to indicate that the handler is called as result - //! of a double click action. - LookUpHdl_Impl( &aCancelBtn /* ??? &aLookUpBtn */ ); - return 0; +void SvxThesaurusDialog::SetWindowTitle( LanguageType nLanguage ) +{ + // Sprache anpassen + String aStr( GetText() ); + aStr.Erase( aStr.Search( sal_Unicode( '(' ) ) - 1 ); + aStr.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ) ); + aStr += SvtLanguageTable().GetLanguageString( nLanguage ); + aStr.Append( sal_Unicode( ')' ) ); + SetText( aStr ); // set window title } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, EntryHdl_Impl, ListBox *, EMPTYARG ) +String SvxThesaurusDialog::GetWord() { + return m_pImpl->aReplaceEdit.GetText(); +} - UpdateSynonymBox_Impl(); - return 0; +sal_uInt16 SvxThesaurusDialog::GetLanguage() const +{ + return m_pImpl->nLookUpLanguage; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxThesaurusDialog, SpellErrorHdl_Impl, void *, pError ) +void SvxThesaurusDialog::Apply() { - // Der "ubergebene Pointer pError ist die falsche Sprachen-Nummer - LanguageType eLang = (LanguageType)(sal_uIntPtr)pError; - String aErr( SvtLanguageTable::GetLanguageString( eLang ) ); - // Fehlermeldung ausgeben - ErrorHandler::HandleError( - *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) ); - return 0; } + diff --git a/cui/source/dialogs/thesdlg.hrc b/cui/source/dialogs/thesdlg.hrc index 9621422a1894..994c933246de 100644..100755 --- a/cui/source/dialogs/thesdlg.hrc +++ b/cui/source/dialogs/thesdlg.hrc @@ -29,30 +29,23 @@ // defines --------------------------------------------------------------- +#define BTN_LEFT 9 #define BTN_THES_OK 10 #define BTN_THES_CANCEL 11 -#define BTN_LANGUAGE 12 +#define MB_LANGUAGE 12 #define BTN_THES_HELP 13 -#define BTN_LOOKUP 14 #define FT_WORD 15 -#define LB_WORD 16 -#define FT_MEAN 17 -#define LB_MEAN 18 -#define FT_SYNON 19 -#define LB_SYNON 20 +#define CB_WORD 16 #define FT_REPL 21 #define ED_REPL 22 -#define FL_VAR 23 - -#define STR_ERR_WORDNOTFOUND 30 - -// LanguageDialog -------------------------------------------------------- - -#define LB_THES_LANGUAGE 10 -#define FL_THES_LANGUAGE 11 -#define BTN_LANG_OK 12 -#define BTN_LANG_CANCEL 12 -#define BTN_LANG_HELP 13 +#define FL_VAR 23 +#define FT_THES_ALTERNATIVES 24 +#define CT_THES_ALTERNATIVES 25 +#define IMG_VENDOR 26 +#define IMG_DEFAULT_VENDOR 27 +#define IMG_DEFAULT_VENDOR_HC 28 + +#define STR_ERR_TEXTNOTFOUND 101 #endif diff --git a/cui/source/dialogs/thesdlg.src b/cui/source/dialogs/thesdlg.src index c7caa659b1c0..16d724473d20 100644..100755 --- a/cui/source/dialogs/thesdlg.src +++ b/cui/source/dialogs/thesdlg.src @@ -24,185 +24,123 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - // include --------------------------------------------------------------- + #include "cuires.hrc" #include "thesdlg.hrc" #include "helpid.hrc" #include <svx/svxids.hrc> // SID_THESAURUS -// pragma ---------------------------------------------------------------- // RID_SVXDLG_THES ------------------------------------------------------- ModalDialog RID_SVXDLG_THESAURUS { HelpId = SID_THESAURUS ; OutputSize = TRUE ; - Size = MAP_APPFONT ( 285 , 116 ) ; + Size = MAP_APPFONT ( 235, 230 ) ; Text [ en-US ] = "Thesaurus" ; - Moveable = TRUE ; SvLook = TRUE ; - OkButton BTN_THES_OK - { - Pos = MAP_APPFONT ( 219 , 6 ) ; - Size = MAP_APPFONT ( 60 , 14 ) ; - DefButton = TRUE ; - }; - CancelButton BTN_THES_CANCEL - { - Pos = MAP_APPFONT ( 219 , 23 ) ; - Size = MAP_APPFONT ( 60 , 14 ) ; - }; - PushButton BTN_LOOKUP + Moveable = TRUE ; + + FixedImage IMG_VENDOR { - Pos = MAP_APPFONT ( 219 , 40 ) ; - Size = MAP_APPFONT ( 60 , 14 ) ; - Text [ en-US ] = "~Search" ; + Pos = MAP_APPFONT ( 0, 0 ) ; + Size = MAP_APPFONT ( 235, 0 ) ; // correct size will be applied at runtime + Hide = TRUE; }; - PushButton BTN_LANGUAGE + + ImageButton BTN_LEFT { - Pos = MAP_APPFONT ( 219 , 57 ) ; - Size = MAP_APPFONT ( 60 , 14 ) ; - Text [ en-US ] = "~Language..." ; - }; - HelpButton BTN_THES_HELP - { - Pos = MAP_APPFONT ( 219 , 77 ) ; - Size = MAP_APPFONT ( 60 , 14 ) ; + Pos = MAP_APPFONT ( 5 , 15 ) ; + Size = MAP_APPFONT ( 14 , 14 ) ; + TABSTOP = TRUE ; + SYMBOL = IMAGEBUTTON_ARROW_LEFT ; }; FixedText FT_WORD { - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 96 , 8 ) ; - Text [ en-US ] = "~Word" ; + Pos = MAP_APPFONT ( 24 , 5 ) ; + Size = MAP_APPFONT ( 143 , 8 ) ; + Text [ en-US ] = "Current ~word" ; LEFT = TRUE ; }; - ListBox LB_WORD + ComboBox CB_WORD { DropDown = TRUE ; - Pos = MAP_APPFONT ( 12 , 25 ) ; - Size = MAP_APPFONT ( 96 , 65 ) ; + Pos = MAP_APPFONT ( 24 , 16 ) ; + Size = MAP_APPFONT ( 141 , 60 ) ; // have drop down space for several lines }; - FixedText FT_MEAN + MenuButton MB_LANGUAGE { - Pos = MAP_APPFONT ( 12 , 43 ) ; - Size = MAP_APPFONT ( 96 , 8 ) ; - Text [ en-US ] = "~Meaning " ; - LEFT = TRUE ; - }; - ListBox LB_MEAN - { - BORDER = TRUE ; - Pos = MAP_APPFONT ( 12 , 55 ) ; - Size = MAP_APPFONT ( 96 , 50 ) ; - AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( 170 , 16 ) ; + Size = MAP_APPFONT ( 60 , 14 ) ; + Text [ en-US ] = "~Language" ; }; - FixedText FT_SYNON + + FixedText FT_THES_ALTERNATIVES { - Pos = MAP_APPFONT ( 111 , 43 ) ; - Size = MAP_APPFONT ( 96 , 8 ) ; - Text [ en-US ] = "Sy~nonym" ; + Pos = MAP_APPFONT ( 5 , 33 ) ; + Size = MAP_APPFONT ( 255 , 8 ) ; + Text [ en-US ] = "~Alternatives" ; LEFT = TRUE ; }; - ListBox LB_SYNON + Control CT_THES_ALTERNATIVES { - BORDER = TRUE ; - Pos = MAP_APPFONT ( 111 , 55 ) ; - Size = MAP_APPFONT ( 96 , 50 ) ; - AutoHScroll = TRUE ; + HelpID = HID_CT_THES_ALTERNATIVES ; // also needed for automatic testing to find the control + Pos = MAP_APPFONT ( 5 , 45 ) ; + Size = MAP_APPFONT ( 225 , 121 ) ; + Border = TRUE; + TabStop = TRUE ; }; + FixedText FT_REPL { - Pos = MAP_APPFONT ( 111 , 14 ) ; - Size = MAP_APPFONT ( 96 , 8 ) ; - Text [ en-US ] = "~Replace" ; + Pos = MAP_APPFONT ( 5 , 173 ) ; + Size = MAP_APPFONT ( 255 , 8 ) ; + Text [ en-US ] = "Replace ~with" ; LEFT = TRUE ; }; Edit ED_REPL { BORDER = TRUE ; - Pos = MAP_APPFONT ( 111 , 25 ) ; - Size = MAP_APPFONT ( 96 , 12 ) ; + Pos = MAP_APPFONT ( 5 , 184 ) ; + Size = MAP_APPFONT ( 225 , 12 ) ; LEFT = TRUE ; }; FixedLine FL_VAR { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 207 , 8 ) ; - Text [ en-US ] = "Variations" ; + Pos = MAP_APPFONT ( 0 , 200 ) ; + Size = MAP_APPFONT ( 235 , 8 ) ; }; - String STR_ERR_WORDNOTFOUND + + HelpButton BTN_THES_HELP { - Text [ en-US ] = "Word not found in thesaurus" ; + Pos = MAP_APPFONT ( 5 , 210 ) ; + Size = MAP_APPFONT ( 60 , 14 ) ; }; -}; - // RID_SVXDLG_THES_LANGUAGE ---------------------------------------------- -ModalDialog RID_SVXDLG_THES_LANGUAGE -{ - HelpId = HID_THES_LANGUAGE ; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 170 , 86 ) ; - /* ### ACHTUNG: Neuer Text in Resource? Sprache auswhlen : Sprache auswhlen */ - /* ### ACHTUNG: Neuer Text in Resource? Sprache auswhlen : Sprache auswhlen */ - Text [ en-US ] = "Select Language" ; - Moveable = TRUE ; - ListBox LB_THES_LANGUAGE + OkButton BTN_THES_OK { - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 90 , 60 ) ; - Sort = TRUE ; + Pos = MAP_APPFONT ( 105 , 210 ) ; + Size = MAP_APPFONT ( 60 , 14 ) ; + Text [ en-US ] = "~Replace" ; + DefButton = TRUE ; }; - FixedLine FL_THES_LANGUAGE + CancelButton BTN_THES_CANCEL { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 102 , 8 ) ; - Text [ en-US ] = "Selection" ; + Pos = MAP_APPFONT ( 170 , 210 ) ; + Size = MAP_APPFONT ( 60 , 14 ) ; }; - OKButton BTN_LANG_OK + + String STR_ERR_TEXTNOTFOUND { - Pos = MAP_APPFONT ( 114 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - DefButton = TRUE ; + Text [ en-US ] = "No alternatives found." ; }; - CancelButton BTN_LANG_CANCEL + + Image IMG_DEFAULT_VENDOR { - Pos = MAP_APPFONT ( 114 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + ImageBitmap = Bitmap { File = "vendor01.png"; }; }; - HelpButton BTN_LANG_HELP + Image IMG_DEFAULT_VENDOR_HC { - Pos = MAP_APPFONT ( 114 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + ImageBitmap = Bitmap { File = "vendor01h.png"; }; }; }; - // ********************************************************************** EOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cui/source/dialogs/thesdlg_impl.hxx b/cui/source/dialogs/thesdlg_impl.hxx new file mode 100755 index 000000000000..70ce91391456 --- /dev/null +++ b/cui/source/dialogs/thesdlg_impl.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * 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: $ + * $Revision: $ + * + * 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 _SVX_THESDLG_IMPL_HXX +#define _SVX_THESDLG_IMPL_HXX + +#include "thesdlg.hxx" + +#include <svtools/ehdl.hxx> +#include <svx/checklbx.hxx> +#include <vcl/button.hxx> +#include <vcl/combobox.hxx> +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +#include <vcl/image.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/menubtn.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/timer.hxx> +#include <vcl/wrkwin.hxx> + +#include <com/sun/star/linguistic2/XThesaurus.hpp> +#include <com/sun/star/linguistic2/XMeaning.hpp> + +#include <stack> +#include <algorithm> + +using namespace ::com::sun::star; +using ::rtl::OUString; + +// class LookUpComboBox_Impl -------------------------------------------------- + +class LookUpComboBox_Impl : public ComboBox +{ + Timer m_aModifyTimer; + Selection m_aSelection; + Button * m_pBtn; + SvxThesaurusDialog_Impl & m_rDialogImpl; + + // disable copy c-tor and assignment operator + LookUpComboBox_Impl( const LookUpComboBox_Impl & ); + LookUpComboBox_Impl & operator = ( const LookUpComboBox_Impl & ); + +public: + LookUpComboBox_Impl( Window *pParent, const ResId &rResId, SvxThesaurusDialog_Impl &rImpl ); + virtual ~LookUpComboBox_Impl(); + + DECL_LINK( ModifyTimer_Hdl, Timer * ); + + void SetButton( Button *pBtn ) { m_pBtn = pBtn; } + + // ComboBox + virtual void Modify(); +}; + +// class ReplaceEdit_Impl -------------------------------------------------- + +class ReplaceEdit_Impl : public Edit +{ + Button * m_pBtn; + + // disable copy c-tor and assignment operator + ReplaceEdit_Impl( const ReplaceEdit_Impl & ); + ReplaceEdit_Impl & operator = ( const ReplaceEdit_Impl & ); + +public: + ReplaceEdit_Impl( Window *pParent, const ResId &rResId ); + virtual ~ReplaceEdit_Impl(); + + void SetButton( Button *pBtn ) { m_pBtn = pBtn; } + + // Edit + virtual void Modify(); + virtual void SetText( const XubString& rStr ); + virtual void SetText( const XubString& rStr, const Selection& rNewSelection ); +}; + +// class ThesaurusAlternativesCtrl_Impl ---------------------------------- + +class AlternativesUserData_Impl +{ + String sText; + bool bHeader; + + // disable copy c-tor and assignment operator + AlternativesUserData_Impl( const AlternativesUserData_Impl & ); + AlternativesUserData_Impl & operator = ( const AlternativesUserData_Impl & ); + +public: + AlternativesUserData_Impl( const String &rText, bool bIsHeader ) : + sText(rText), + bHeader(bIsHeader) + { + } + + bool IsHeader() const { return bHeader; } + const String& GetText() const { return sText; } +}; + + +class AlternativesString_Impl : public SvLBoxString +{ +public: + + AlternativesString_Impl( SvLBoxEntry* pEntry, USHORT nFlags, const String& rStr ) + : SvLBoxString( pEntry, nFlags, rStr ) {} + + virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags, SvLBoxEntry* pEntry); +}; + + +class ThesaurusAlternativesCtrl_Impl : + public SvxCheckListBox +{ + SvxThesaurusDialog_Impl & m_rDialogImpl; + + // disable copy c-tor and assignment operator + ThesaurusAlternativesCtrl_Impl( const ThesaurusAlternativesCtrl_Impl & ); + ThesaurusAlternativesCtrl_Impl & operator = ( const ThesaurusAlternativesCtrl_Impl & ); + +public: + ThesaurusAlternativesCtrl_Impl( Window* pParent, SvxThesaurusDialog_Impl &rImpl ); + virtual ~ThesaurusAlternativesCtrl_Impl(); + + + SvLBoxEntry * AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader ); + void ClearUserData(); + + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); +}; + + +// struct SvxThesaurusDialog_Impl ---------------------------------------- + +struct SvxThesaurusDialog_Impl +{ + SvxThesaurusDialog * m_pDialog; + + FixedImage aVendorImageFI; + ImageButton aLeftBtn; + FixedText aWordText; + LookUpComboBox_Impl aWordCB; + FixedText m_aAlternativesText; + boost::shared_ptr< ThesaurusAlternativesCtrl_Impl > m_pAlternativesCT; + FixedText aReplaceText; + ReplaceEdit_Impl aReplaceEdit; + FixedLine aFL; + HelpButton aHelpBtn; + MenuButton aLangMBtn; + OKButton aReplaceBtn; + CancelButton aCancelBtn; + + String aErrStr; + Image aVendorDefaultImage; + Image aVendorDefaultImageHC; + + uno::Reference< linguistic2::XThesaurus > xThesaurus; + OUString aLookUpText; + LanguageType nLookUpLanguage; + std::stack< OUString > aLookUpHistory; + bool m_bWordFound; + + + // Handler + DECL_LINK( LeftBtnHdl_Impl, Button * ); + DECL_LINK( LanguageHdl_Impl, MenuButton * ); + DECL_LINK( LookUpHdl_Impl, Button * ); + DECL_LINK( WordSelectHdl_Impl, ComboBox * ); + DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * ); + DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * ); + + DECL_STATIC_LINK( SvxThesaurusDialog_Impl, SelectFirstHdl_Impl, SvxCheckListBox * ); + DECL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl * ); + + + SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ); + ~SvxThesaurusDialog_Impl(); + + uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL + queryMeanings_Impl( ::rtl::OUString& rTerm, const lang::Locale& rLocale, const beans::PropertyValues& rProperties ) throw(lang::IllegalArgumentException, uno::RuntimeException); + + bool UpdateAlternativesBox_Impl(); + void UpdateVendorImage(); + void LookUp( const String &rText ); + void LookUp_Impl(); +}; + +#endif + diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index a2deb5192389..8d233b71e890 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -50,6 +50,8 @@ #include <svtools/xtextedt.hxx> #include <editeng/SpellPortions.hxx> +#include <set> + class ScrollBar; class TextEngine; class ExtTextView; @@ -72,11 +74,12 @@ class SentenceEditWindow_Impl : public MultiLineEdit/*, public SfxListener*/ using MultiLineEdit::SetText; private: + std::set< USHORT > m_aIgnoreErrorsAt; USHORT m_nErrorStart; USHORT m_nErrorEnd; bool m_bIsUndoEditMode; - Link m_aModifyLink; + Link m_aModifyLink; void CallModifyLink() {m_aModifyLink.Call(this);} @@ -93,7 +96,7 @@ public: void SetAttrib( const TextAttrib& rAttr, ULONG nPara, USHORT nStart, USHORT nEnd ); void SetText( const String& rStr ); - bool MarkNextError(); + bool MarkNextError( bool bIgnoreCurrentError ); void ChangeMarkedWord(const String& rNewWord, LanguageType eLanguage); void MoveErrorMarkTo(USHORT nErrorStart, USHORT nErrorEnd, bool bGrammar); String GetErrorText() const; @@ -121,6 +124,8 @@ public: void UndoActionEnd( USHORT nId ); void MoveErrorEnd(long nOffset); + + void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); } }; @@ -221,7 +226,7 @@ private: void InitUserDicts(); void UpdateBoxes_Impl(); void Init_Impl(); - void SpellContinue_Impl(bool UseSavedSentence = false); + void SpellContinue_Impl(bool UseSavedSentence = false, bool bIgnoreCurrentError = false ); void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;} void Impl_Restore(); @@ -230,7 +235,7 @@ private: /** Retrieves the next sentence. */ - bool GetNextSentence_Impl(bool bUseSavedSentence); + bool GetNextSentence_Impl(bool bUseSavedSentence, bool bRechek /*for rechecking the curretn sentence*/); /** Corrects all errors that have been selected to be changed always */ bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced); diff --git a/cui/source/inc/helpid.hrc b/cui/source/inc/helpid.hrc index 1d98daa179e1..c4a50ec1bf62 100644..100755 --- a/cui/source/inc/helpid.hrc +++ b/cui/source/inc/helpid.hrc @@ -373,14 +373,15 @@ #define HID_THES_LANGUAGE (HID_CUI_START + 338) #define HID_OFAPAGE_QUOTE_SW_CLB (HID_CUI_START + 339) #define HID_OFAPAGE_QUOTE_CLB (HID_CUI_START + 340) +#define HID_CT_THES_ALTERNATIVES (HID_CUI_START + 341) -// please adjust ACT_SVX_HID_END2 below if you add entries here! +// please adjust ACT_CUI_HID_END below if you add entries here! // ----------------------------------------------------------------------- // Overrun check --------------------------------------------------------- // ----------------------------------------------------------------------- -#define ACT_CUI_HID_END HID_CUI_START + 340 +#define ACT_CUI_HID_END HID_CUI_START + 341 #if ACT_CUI_HID_END > HID_CUI_END #error Resource-Ueberlauf in #line, #file diff --git a/cui/source/inc/hyphen.hxx b/cui/source/inc/hyphen.hxx index 42ec38e31331..502b212c8a91 100644..100755 --- a/cui/source/inc/hyphen.hxx +++ b/cui/source/inc/hyphen.hxx @@ -29,6 +29,8 @@ // include --------------------------------------------------------------- +#include <memory> + #include <vcl/edit.hxx> #include <vcl/button.hxx> #include <vcl/fixed.hxx> @@ -45,73 +47,24 @@ namespace linguistic2{ class SvxSpellWrapper; -// class SvxHyphenEdit --------------------------------------------------- - -class SvxHyphenEdit : public Edit -{ -public: - SvxHyphenEdit( Window* pParent, const ResId& rResId ); - -protected: - virtual void KeyInput( const KeyEvent &rKEvt ); -}; - // class SvxHyphenWordDialog --------------------------------------------- +struct SvxHyphenWordDialog_Impl; + class SvxHyphenWordDialog : public SfxModalDialog { + std::auto_ptr< SvxHyphenWordDialog_Impl > m_pImpl; + public: SvxHyphenWordDialog( const String &rWord, LanguageType nLang, Window* pParent, - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XHyphenator > &xHyphen, + ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenator > &xHyphen, SvxSpellWrapper* pWrapper ); + virtual ~SvxHyphenWordDialog(); + void SetWindowTitle( LanguageType nLang ); void SelLeft(); void SelRight(); - -private: - FixedText aWordFT; - SvxHyphenEdit aWordEdit; - ImageButton aLeftBtn; - ImageButton aRightBtn; - OKButton aOkBtn; - CancelButton aCancelBtn; - PushButton aContBtn; - PushButton aDelBtn; - HelpButton aHelpBtn; - String aLabel; - SvxSpellWrapper* pHyphWrapper; - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XHyphenator > xHyphenator; - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XPossibleHyphens > xPossHyph; - String aActWord; // actual (to be displayed) word - LanguageType nActLanguage; // and language - sal_uInt16 nMaxHyphenationPos; // right most valid hyphenation pos - sal_uInt16 nHyphPos; - sal_uInt16 nOldPos; - sal_Bool bBusy; - - void EnableLRBtn_Impl(); - void SetLabel_Impl( LanguageType nLang ); - String EraseUnusableHyphens_Impl( - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XPossibleHyphens > &rxPossHyph, - sal_uInt16 nMaxHyphenationPos ); - - void InitControls_Impl(); - void ContinueHyph_Impl( sal_uInt16 nInsPos = 0 ); - sal_uInt16 GetHyphIndex_Impl(); - - DECL_LINK( CutHdl_Impl, Button* ); - DECL_LINK( DeleteHdl_Impl, Button* ); - DECL_LINK( ContinueHdl_Impl, Button* ); - DECL_LINK( CancelHdl_Impl, Button* ); - DECL_LINK( Left_Impl, Button* ); - DECL_LINK( Right_Impl, Button* ); - DECL_LINK( GetFocusHdl_Impl, Edit* ); - DECL_LINK( LangError_Impl, void* ); }; diff --git a/cui/source/inc/thesdlg.hxx b/cui/source/inc/thesdlg.hxx index d46c2ce5affa..99b292b560a5 100644..100755 --- a/cui/source/inc/thesdlg.hxx +++ b/cui/source/inc/thesdlg.hxx @@ -27,94 +27,34 @@ #ifndef _SVX_THESDLG_HXX #define _SVX_THESDLG_HXX -// include --------------------------------------------------------------- -#include <vcl/edit.hxx> -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/fixed.hxx> -#include <svx/stddlg.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/linguistic2/XThesaurus.hpp> -// forward --------------------------------------------------------------- +#include "svx/stddlg.hxx" +#include "svx/svxdllapi.h" -struct ThesDlg_Impl; +#include <memory> -class SvxThesaurusLanguageDlg_Impl; -namespace com { namespace sun { namespace star { - namespace linguistic2 { - class XThesaurus; - class XMeaning; - } - namespace lang { - struct Locale; - } -}}} +///////////////////////////////////////////////////////////////// -// class SvxThesaurusDialog ---------------------------------------------- +struct SvxThesaurusDialog_Impl; class SvxThesaurusDialog : public SvxStandardDialog { -public: - friend class SvxThesaurusLanguageDlg_Impl; + std::auto_ptr< SvxThesaurusDialog_Impl > m_pImpl; + + SVX_DLLPRIVATE virtual void Apply(); +public: SvxThesaurusDialog( Window* pParent, - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XThesaurus > xThesaurus, - const String &rWord, sal_Int16 nLanguage ); + ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XThesaurus > xThesaurus, + const String &rWord, LanguageType nLanguage ); ~SvxThesaurusDialog(); - String GetWord() { return aReplaceEdit.GetText(); } - + void SetWindowTitle( LanguageType nLanguage ); + String GetWord(); sal_uInt16 GetLanguage() const; - -private: - FixedText aWordText; - ListBox aWordLB; - FixedText aReplaceText; - Edit aReplaceEdit; - FixedText aMeanText; - ListBox aMeanLB; - FixedText aSynonymText; - ListBox aSynonymLB; - FixedLine aVarFL; - - OKButton aOkBtn; - CancelButton aCancelBtn; - PushButton aLookUpBtn; - PushButton aLangBtn; - HelpButton aHelpBtn; - - String aErrStr; - - ThesDlg_Impl* pImpl; // always != NULL - - virtual void Apply(); - - void UpdateSynonymBox_Impl(); - void UpdateMeaningBox_Impl( - ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XMeaning > > *pMeaningSeq = NULL ); - void Init_Impl(sal_Int16 nLanguage); - - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XMeaning > > - SAL_CALL queryMeanings_Impl( - ::rtl::OUString& rTerm, - const ::com::sun::star::lang::Locale& rLocale, - const ::com::sun::star::beans::PropertyValues& rProperties ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - // Handler - DECL_LINK( SelectHdl_Impl, ListBox * ); - DECL_LINK( SynonymHdl_Impl, ListBox * ); - DECL_LINK( LookUpHdl_Impl, Button * ); - DECL_LINK( LanguageHdl_Impl, Button * ); - DECL_LINK( EntryHdl_Impl, ListBox * ); - DECL_LINK( SpellErrorHdl_Impl, void * ); }; #endif diff --git a/cui/source/options/dbregisterednamesconfig.cxx b/cui/source/options/dbregisterednamesconfig.cxx index 1c4f12b6eb75..38b9897ad4e9 100644 --- a/cui/source/options/dbregisterednamesconfig.cxx +++ b/cui/source/options/dbregisterednamesconfig.cxx @@ -38,8 +38,9 @@ #include <comphelper/processfactory.hxx> #include <svl/eitem.hxx> #include <svl/itemset.hxx> -#include <tools/diagnose_ex.h> +#include <unotools/pathoptions.hxx> #include <unotools/confignode.hxx> +#include <tools/diagnose_ex.h> //........................................................................ namespace svx diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index b63d9afc647e..880f8d263c6b 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -1830,7 +1830,7 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) while ( _pViewFrame ) { _pViewFrame->GetDispatcher()->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L); - _pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); + _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame ); } } } diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx index d633b597878d..2ffeb0d09739 100644 --- a/extensions/source/abpilot/abpfinalpage.cxx +++ b/extensions/source/abpilot/abpfinalpage.cxx @@ -141,12 +141,12 @@ namespace abp } //--------------------------------------------------------------------- - sal_Bool FinalPage::commitPage( CommitPageReason _eReason ) + sal_Bool FinalPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return sal_False; - if ( ( eTravelBackward != _eReason ) + if ( ( ::svt::WizardTypes::eTravelBackward != _eReason ) && ( !m_aLocationController.prepareCommit() ) ) return sal_False; diff --git a/extensions/source/abpilot/abpfinalpage.hxx b/extensions/source/abpilot/abpfinalpage.hxx index 415bc31f2bc1..27d6522d7df6 100644 --- a/extensions/source/abpilot/abpfinalpage.hxx +++ b/extensions/source/abpilot/abpfinalpage.hxx @@ -66,7 +66,7 @@ namespace abp protected: // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); // TabDialog overridables virtual void ActivatePage(); diff --git a/extensions/source/abpilot/abspilot.cxx b/extensions/source/abpilot/abspilot.cxx index b315893b6447..d8007873a2c4 100644 --- a/extensions/source/abpilot/abspilot.cxx +++ b/extensions/source/abpilot/abspilot.cxx @@ -213,14 +213,11 @@ namespace abp } //--------------------------------------------------------------------- - sal_Bool OAddessBookSourcePilot::onFinish(sal_Int32 _nResult) + sal_Bool OAddessBookSourcePilot::onFinish() { - if (!OAddessBookSourcePilot_Base::onFinish(_nResult)) + if ( !OAddessBookSourcePilot_Base::onFinish() ) return sal_False; - if (RET_OK != _nResult) - return sal_True; - implCommitAll(); addressconfig::markPilotSuccess( getORB() ); @@ -283,9 +280,7 @@ namespace abp if ( aTables.empty() ) { - if ( ( _eReason == eValidateNoUI ) - || ( RET_YES != QueryBox( this, ModuleRes( RID_QRY_NOTABLES ) ).Execute() ) - ) + if ( RET_YES != QueryBox( this, ModuleRes( RID_QRY_NOTABLES ) ).Execute() ) { // cannot ask the user, or the user chose to use this data source, though there are no tables bAllow = sal_False; diff --git a/extensions/source/abpilot/abspilot.hxx b/extensions/source/abpilot/abspilot.hxx index b0f3b900871b..0abdacd0281d 100644 --- a/extensions/source/abpilot/abspilot.hxx +++ b/extensions/source/abpilot/abspilot.hxx @@ -79,7 +79,7 @@ namespace abp virtual ::svt::OWizardPage* createPage( WizardState _nState ); virtual void enterState( WizardState _nState ); virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason ); - virtual sal_Bool onFinish( sal_Int32 _nResult ); + virtual sal_Bool onFinish(); // RoadmapWizard virtual String getStateDisplayName( WizardState _nState ) const; diff --git a/extensions/source/abpilot/tableselectionpage.cxx b/extensions/source/abpilot/tableselectionpage.cxx index 0cefba92ab5a..869c806ea819 100644 --- a/extensions/source/abpilot/tableselectionpage.cxx +++ b/extensions/source/abpilot/tableselectionpage.cxx @@ -109,7 +109,7 @@ namespace abp } //--------------------------------------------------------------------- - sal_Bool TableSelectionPage::commitPage( CommitPageReason _eReason ) + sal_Bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return sal_False; diff --git a/extensions/source/abpilot/tableselectionpage.hxx b/extensions/source/abpilot/tableselectionpage.hxx index 36bc792fd0e7..d2d878c65d5f 100644 --- a/extensions/source/abpilot/tableselectionpage.hxx +++ b/extensions/source/abpilot/tableselectionpage.hxx @@ -51,7 +51,7 @@ namespace abp protected: // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); // TabDialog overridables virtual void ActivatePage(); diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx index 6188b7d21628..fd83630e81d9 100644 --- a/extensions/source/abpilot/typeselectionpage.cxx +++ b/extensions/source/abpilot/typeselectionpage.cxx @@ -207,18 +207,15 @@ namespace abp } //--------------------------------------------------------------------- - sal_Bool TypeSelectionPage::commitPage( CommitPageReason _eReason ) + sal_Bool TypeSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return sal_False; if (AST_INVALID == getSelectedType( )) { - if ( _eReason != eValidateNoUI ) - { - ErrorBox aError(this, ModuleRes(RID_ERR_NEEDTYPESELECTION)); - aError.Execute(); - } + ErrorBox aError(this, ModuleRes(RID_ERR_NEEDTYPESELECTION)); + aError.Execute(); return sal_False; } diff --git a/extensions/source/abpilot/typeselectionpage.hxx b/extensions/source/abpilot/typeselectionpage.hxx index 18c8d6b9697d..9df17bb1d77f 100644 --- a/extensions/source/abpilot/typeselectionpage.hxx +++ b/extensions/source/abpilot/typeselectionpage.hxx @@ -83,7 +83,7 @@ namespace abp protected: // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); // TabDialog overridables virtual void ActivatePage(); diff --git a/extensions/source/dbpilots/commonpagesdbp.cxx b/extensions/source/dbpilots/commonpagesdbp.cxx index 7b58c8de8560..88d8e2eb352e 100644 --- a/extensions/source/dbpilots/commonpagesdbp.cxx +++ b/extensions/source/dbpilots/commonpagesdbp.cxx @@ -164,7 +164,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OTableSelectionPage::commitPage( CommitPageReason _eReason ) + sal_Bool OTableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OControlWizardPage::commitPage(_eReason)) return sal_False; @@ -493,7 +493,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool ODBFieldPage::commitPage( CommitPageReason _eReason ) + sal_Bool ODBFieldPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OMaybeListSelectionPage::commitPage(_eReason)) return sal_False; diff --git a/extensions/source/dbpilots/commonpagesdbp.hxx b/extensions/source/dbpilots/commonpagesdbp.hxx index 3cbe1ac2b514..a20587b36d72 100644 --- a/extensions/source/dbpilots/commonpagesdbp.hxx +++ b/extensions/source/dbpilots/commonpagesdbp.hxx @@ -64,7 +64,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); protected: DECL_LINK( OnListboxSelection, ListBox* ); @@ -131,7 +131,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); // own overridables virtual String& getDBFieldSetting() = 0; diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index b97eb60504b4..c5d816486ecc 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -156,7 +156,7 @@ namespace dbp _rList.Clear(); const ::rtl::OUString* pItems = _rItems.getConstArray(); const ::rtl::OUString* pEnd = pItems + _rItems.getLength(); - WizardState nPos; + ::svt::WizardTypes::WizardState nPos; sal_Int32 nIndex = 0; for (;pItems < pEnd; ++pItems, ++nIndex) { @@ -172,7 +172,7 @@ namespace dbp _rList.Clear(); const ::rtl::OUString* pItems = _rItems.getConstArray(); const ::rtl::OUString* pEnd = pItems + _rItems.getLength(); - WizardState nPos; + ::svt::WizardTypes::WizardState nPos; sal_Int32 nIndex = 0; for (;pItems < pEnd; ++pItems) { @@ -254,7 +254,7 @@ namespace dbp m_pFormDatasource->SetText(sDataSource); m_pFormTable->SetText(sCommand); - WizardState nCommandTypeResourceId = 0; + ::svt::WizardTypes::WizardState nCommandTypeResourceId = 0; switch (nCommandType) { case CommandType::TABLE: diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx index 6e28567aef62..7606fc7bec65 100644 --- a/extensions/source/dbpilots/gridwizard.cxx +++ b/extensions/source/dbpilots/gridwizard.cxx @@ -33,6 +33,7 @@ #include <comphelper/stl_types.hxx> #include <tools/string.hxx> #include <com/sun/star/form/XGridColumnFactory.hpp> +#include <com/sun/star/awt/MouseWheelBehavior.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <tools/debug.hxx> #include "dbptools.hxx" @@ -52,6 +53,7 @@ namespace dbp using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; + using namespace ::com::sun::star::awt; using namespace ::svt; //===================================================================== @@ -111,6 +113,7 @@ namespace dbp static const ::rtl::OUString s_sDataFieldProperty = ::rtl::OUString::createFromAscii("DataField"); static const ::rtl::OUString s_sLabelProperty = ::rtl::OUString::createFromAscii("Label"); static const ::rtl::OUString s_sWidthProperty = ::rtl::OUString::createFromAscii("Width"); + static const ::rtl::OUString s_sMouseWheelBehavior = ::rtl::OUString::createFromAscii("MouseWheelBehavior"); static const ::rtl::OUString s_sEmptyString; // collect "descriptors" for the to-be-created (grid)columns @@ -202,23 +205,24 @@ namespace dbp // create a (grid)column for the (resultset)column try { - Reference< XPropertySet > xColumn = xColumnFactory->createColumn(*pColumnServiceName); + Reference< XPropertySet > xColumn( xColumnFactory->createColumn(*pColumnServiceName), UNO_SET_THROW ); + Reference< XPropertySetInfo > xColumnPSI( xColumn->getPropertySetInfo(), UNO_SET_THROW ); ::rtl::OUString sColumnName(*pColumnServiceName); disambiguateName(xExistenceChecker, sColumnName); - if (xColumn.is()) - { - // the data field the column should be bound to - xColumn->setPropertyValue(s_sDataFieldProperty, makeAny(*pFormFieldName)); - // the label - xColumn->setPropertyValue(s_sLabelProperty, makeAny(::rtl::OUString(*pFormFieldName) += *pColumnLabelPostfix)); - // the width (<void/> => column will be auto-sized) - xColumn->setPropertyValue(s_sWidthProperty, Any()); - - // insert the column - xColumnContainer->insertByName(sColumnName, makeAny(xColumn)); - } + // the data field the column should be bound to + xColumn->setPropertyValue(s_sDataFieldProperty, makeAny(*pFormFieldName)); + // the label + xColumn->setPropertyValue(s_sLabelProperty, makeAny(::rtl::OUString(*pFormFieldName) += *pColumnLabelPostfix)); + // the width (<void/> => column will be auto-sized) + xColumn->setPropertyValue(s_sWidthProperty, Any()); + + if ( xColumnPSI->hasPropertyByName( s_sMouseWheelBehavior ) ) + xColumn->setPropertyValue( s_sMouseWheelBehavior, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ); + + // insert the column + xColumnContainer->insertByName(sColumnName, makeAny(xColumn)); } catch(Exception&) { @@ -285,9 +289,9 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OGridWizard::onFinish(sal_Int32 _nResult) + sal_Bool OGridWizard::onFinish() { - if (!OControlWizard::onFinish(_nResult)) + if ( !OControlWizard::onFinish() ) return sal_False; implApplySettings(); @@ -362,7 +366,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OGridFieldsSelection::commitPage( CommitPageReason _eReason ) + sal_Bool OGridFieldsSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OGridPage::commitPage(_eReason)) return sal_False; diff --git a/extensions/source/dbpilots/gridwizard.hxx b/extensions/source/dbpilots/gridwizard.hxx index d0f255ede729..85b91d274345 100644 --- a/extensions/source/dbpilots/gridwizard.hxx +++ b/extensions/source/dbpilots/gridwizard.hxx @@ -68,8 +68,7 @@ namespace dbp virtual WizardState determineNextState( WizardState _nCurrentState ) const; virtual void enterState( WizardState _nState ); virtual sal_Bool leaveState( WizardState _nState ); - - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual sal_Bool onFinish(); virtual sal_Bool approveControl(sal_Int16 _nClassId); @@ -114,7 +113,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; protected: diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx index 7bf3138bf5fe..9956cfe86428 100644 --- a/extensions/source/dbpilots/groupboxwiz.cxx +++ b/extensions/source/dbpilots/groupboxwiz.cxx @@ -79,7 +79,7 @@ namespace dbp } //--------------------------------------------------------------------- - OWizardPage* OGroupBoxWizard::createPage(WizardState _nState) + OWizardPage* OGroupBoxWizard::createPage(::svt::WizardTypes::WizardState _nState) { switch (_nState) { @@ -106,7 +106,7 @@ namespace dbp } //--------------------------------------------------------------------- - WizardTypes::WizardState OGroupBoxWizard::determineNextState( WizardState _nCurrentState ) const + WizardTypes::WizardState OGroupBoxWizard::determineNextState( ::svt::WizardTypes::WizardState _nCurrentState ) const { switch (_nCurrentState) { @@ -133,7 +133,7 @@ namespace dbp } //--------------------------------------------------------------------- - void OGroupBoxWizard::enterState(WizardState _nState) + void OGroupBoxWizard::enterState(::svt::WizardTypes::WizardState _nState) { // some stuff to do before calling the base class (modifying our settings) switch (_nState) @@ -187,18 +187,15 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OGroupBoxWizard::onFinish(sal_Int32 _nResult) + sal_Bool OGroupBoxWizard::onFinish() { - if (RET_OK != _nResult) - return OControlWizard::onFinish(_nResult); - // commit the basic control setttings commitControlSettings(&m_aSettings); // create the radio buttons createRadios(); - return OControlWizard::onFinish(_nResult); + return OControlWizard::onFinish(); } //===================================================================== @@ -265,7 +262,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool ORadioSelectionPage::commitPage( CommitPageReason _eReason ) + sal_Bool ORadioSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OGBWPage::commitPage(_eReason)) return sal_False; @@ -277,7 +274,7 @@ namespace dbp rSettings.aValues.clear(); rSettings.aLabels.reserve(m_aExistingRadios.GetEntryCount()); rSettings.aValues.reserve(m_aExistingRadios.GetEntryCount()); - for (WizardState i=0; i<m_aExistingRadios.GetEntryCount(); ++i) + for (::svt::WizardTypes::WizardState i=0; i<m_aExistingRadios.GetEntryCount(); ++i) { rSettings.aLabels.push_back(m_aExistingRadios.GetEntry(i)); rSettings.aValues.push_back(String::CreateFromInt32((sal_Int32)(i + 1))); @@ -393,7 +390,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool ODefaultFieldSelectionPage::commitPage( CommitPageReason _eReason ) + sal_Bool ODefaultFieldSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OMaybeListSelectionPage::commitPage(_eReason)) return sal_False; @@ -416,7 +413,7 @@ namespace dbp ,m_aValue (this, ModuleRes(ET_OPTIONVALUE)) ,m_aOptionsLabel (this, ModuleRes(FT_RADIOBUTTONS)) ,m_aOptions (this, ModuleRes(LB_RADIOBUTTONS)) - ,m_nLastSelection((WizardState)-1) + ,m_nLastSelection((::svt::WizardTypes::WizardState)-1) { FreeResource(); @@ -440,7 +437,7 @@ namespace dbp //--------------------------------------------------------------------- void OOptionValuesPage::implTraveledOptions() { - if ((WizardState)-1 != m_nLastSelection) + if ((::svt::WizardTypes::WizardState)-1 != m_nLastSelection) { // save the value for the last option DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!"); @@ -480,7 +477,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OOptionValuesPage::commitPage( CommitPageReason _eReason ) + sal_Bool OOptionValuesPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OGBWPage::commitPage(_eReason)) return sal_False; @@ -548,7 +545,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OFinalizeGBWPage::commitPage( CommitPageReason _eReason ) + sal_Bool OFinalizeGBWPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OGBWPage::commitPage(_eReason)) return sal_False; diff --git a/extensions/source/dbpilots/groupboxwiz.hxx b/extensions/source/dbpilots/groupboxwiz.hxx index 97a2cd1a3109..de0f9767f3a4 100644 --- a/extensions/source/dbpilots/groupboxwiz.hxx +++ b/extensions/source/dbpilots/groupboxwiz.hxx @@ -73,8 +73,7 @@ namespace dbp virtual ::svt::OWizardPage* createPage( WizardState _nState ); virtual WizardState determineNextState( WizardState _nCurrentState ) const; virtual void enterState( WizardState _nState ); - - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual sal_Bool onFinish(); virtual sal_Bool approveControl(sal_Int16 _nClassId); @@ -117,7 +116,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; DECL_LINK( OnMoveEntry, PushButton* ); @@ -145,7 +144,7 @@ namespace dbp protected: // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); } }; @@ -164,7 +163,8 @@ namespace dbp ListBox m_aOptions; StringArray m_aUncommittedValues; - WizardState m_nLastSelection; + ::svt::WizardTypes::WizardState + m_nLastSelection; public: OOptionValuesPage( OControlWizard* _pParent ); @@ -175,7 +175,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); void implTraveledOptions(); @@ -217,7 +217,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; }; diff --git a/extensions/source/dbpilots/listcombowizard.cxx b/extensions/source/dbpilots/listcombowizard.cxx index 2e810654baa4..bf3f56781d63 100644 --- a/extensions/source/dbpilots/listcombowizard.cxx +++ b/extensions/source/dbpilots/listcombowizard.cxx @@ -226,14 +226,11 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OListComboWizard::onFinish(sal_Int32 _nResult) + sal_Bool OListComboWizard::onFinish() { - if (!OControlWizard::onFinish(_nResult)) + if ( !OControlWizard::onFinish() ) return sal_False; - if (RET_OK != _nResult) - return sal_True; - implApplySettings(); return sal_True; } @@ -362,14 +359,14 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OContentTableSelection::commitPage( CommitPageReason _eReason ) + sal_Bool OContentTableSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OLCPage::commitPage(_eReason)) return sal_False; OListComboSettings& rSettings = getSettings(); rSettings.sListContentTable = m_aSelectTable.GetSelectEntry(); - if (!rSettings.sListContentTable.Len() && (eTravelBackward != _eReason)) + if (!rSettings.sListContentTable.Len() && (::svt::WizardTypes::eTravelBackward != _eReason)) // need to select a table return sal_False; @@ -440,7 +437,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OContentFieldSelection::commitPage( CommitPageReason _eReason ) + sal_Bool OContentFieldSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OLCPage::commitPage(_eReason)) return sal_False; @@ -518,7 +515,7 @@ namespace dbp } //--------------------------------------------------------------------- - sal_Bool OLinkFieldsPage::commitPage( CommitPageReason _eReason ) + sal_Bool OLinkFieldsPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if (!OLCPage::commitPage(_eReason)) return sal_False; diff --git a/extensions/source/dbpilots/listcombowizard.hxx b/extensions/source/dbpilots/listcombowizard.hxx index 7dcf32316236..05f7f70ea65d 100644 --- a/extensions/source/dbpilots/listcombowizard.hxx +++ b/extensions/source/dbpilots/listcombowizard.hxx @@ -80,8 +80,7 @@ namespace dbp virtual WizardState determineNextState( WizardState _nCurrentState ) const; virtual void enterState( WizardState _nState ); virtual sal_Bool leaveState( WizardState _nState ); - - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual sal_Bool onFinish(); virtual sal_Bool approveControl(sal_Int16 _nClassId); @@ -129,7 +128,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; protected: @@ -163,7 +162,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; }; @@ -190,7 +189,7 @@ namespace dbp // OWizardPage overridables virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); virtual bool canAdvance() const; private: diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 5c3fdba085c3..282130daea0b 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -594,7 +594,7 @@ namespace pcr } catch( const Exception& ) { - OSL_ENSURE( false, "EventHandler::EventHandler: caught an exception while classifying the component!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -825,7 +825,7 @@ namespace pcr } catch( const Exception& ) { - DBG_ERROR( "EventHandler::getSupportedProperties: caught an exception !" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -1048,7 +1048,7 @@ namespace pcr } catch( const Exception& ) { - OSL_ENSURE( false, "EventHandler::impl_getFormComponentScriptEvents_nothrow: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -1080,7 +1080,7 @@ namespace pcr } catch( const Exception& ) { - OSL_ENSURE( false, "EventHandler::impl_getCopmonentListenerTypes_nothrow: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -1105,7 +1105,7 @@ namespace pcr } catch( const Exception& ) { - OSL_ENSURE( false, "EventHandler::impl_getDialogElementScriptEvents_nothrow: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -1120,7 +1120,7 @@ namespace pcr { Reference< XTabControllerModel > xComponentAsTCModel( m_xComponent, UNO_QUERY_THROW ); Reference< XFormController > xController( - m_aContext.createComponent( (const rtl::OUString&)SERVICE_FORMCONTROLLER ), UNO_QUERY_THROW ); + m_aContext.createComponent( "com.sun.star.form.runtime.FormController" ), UNO_QUERY_THROW ); xController->setModel( xComponentAsTCModel ); xReturn = xController; @@ -1212,7 +1212,7 @@ namespace pcr } catch( const Exception& ) { - OSL_ENSURE( false, "EventHandler::impl_setFormComponentScriptEvent_nothrow: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } diff --git a/extensions/source/propctrlr/pcrstrings.hxx b/extensions/source/propctrlr/pcrstrings.hxx index 9a611f5fce7f..e2a81c9920ca 100644 --- a/extensions/source/propctrlr/pcrstrings.hxx +++ b/extensions/source/propctrlr/pcrstrings.hxx @@ -38,9 +38,6 @@ namespace pcr // properties PCR_CONSTASCII_STRING( PROPERTY_TABBINGMODEL, "TabbingModel" ); - // services - PCR_CONSTASCII_STRING( SERVICE_FORMCONTROLLER, "com.sun.star.form.FormController" ); - //............................................................................ } // namespace pcr //............................................................................ diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index dd7da492ff57..09d90f1eaa83 100644..100755 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -169,7 +169,9 @@ progress_callback( void *clientp, double dltotal, double dlnow, double ultotal, if( ! out->StopCondition.check() ) { - double fPercent = (dlnow + out->Offset) * 100 / (dltotal + out->Offset); + double fPercent = 0; + if ( dltotal + out->Offset ) + fPercent = (dlnow + out->Offset) * 100 / (dltotal + out->Offset); if( fPercent < 0 ) fPercent = 0; @@ -262,6 +264,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx rtl::OString aURL(rtl::OUStringToOString(rURL, RTL_TEXTENCODING_UTF8)); curl_easy_setopt(pCURL, CURLOPT_URL, aURL.getStr()); + // abort on http errors + curl_easy_setopt(pCURL, CURLOPT_FAILONERROR, 1); + // enable redirection curl_easy_setopt(pCURL, CURLOPT_FOLLOWLOCATION, 1); @@ -300,6 +305,19 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx ret = true; } + if ( CURLE_PARTIAL_FILE == cc ) + { + // this sometimes happens, when a user throws away his user data, but has already + // completed the download of an update. + double fDownloadSize; + curl_easy_getinfo( pCURL, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fDownloadSize ); + if ( -1 == fDownloadSize ) + { + out.Handler->downloadFinished(out.File); + ret = true; + } + } + // Avoid target file being removed else if( (CURLE_ABORTED_BY_CALLBACK == cc) || out.StopCondition.check() ) ret = true; @@ -313,7 +331,30 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx if( NULL != error_message ) aMessage = error_message; - out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); + if ( CURLE_HTTP_RETURNED_ERROR == cc ) + { + long nError; + curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError ); + + if ( 403 == nError ) + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ) ); + else if ( 404 == nError ) + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ) ); + else if ( 416 == nError ) + { + // we got this error probably, because we already downloaded the file + out.Handler->downloadFinished(out.File); + ret = true; + } + else + { + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( ":error code = " ) ); + aMessage += aMessage.valueOf( nError ); + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " !" ) ); + } + } + if ( !ret ) + out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); } curl_easy_cleanup(pCURL); @@ -330,14 +371,52 @@ Download::start(const rtl::OUString& rURL, const rtl::OUString& rFile, const rtl OSL_ASSERT( m_aHandler.is() ); OutData out(m_aCondition); + rtl::OUString aFile( rFile ); + + // when rFile is empty, there is no remembered file name. If there is already a file with the + // same name ask the user if she wants to resume a download or restart the download + if ( !aFile.getLength() ) + { + // GetFileName() + rtl::OUString aURL( rURL ); + // ensure no trailing '/' + sal_Int32 nLen = aURL.getLength(); + while( (nLen > 0) && ('/' == aURL[ nLen-1 ]) ) + aURL = aURL.copy( 0, --nLen ); + + // extract file name last '/' + sal_Int32 nIndex = aURL.lastIndexOf('/'); + aFile = rDestinationDir + aURL.copy( nIndex ); + + // check for existing file + oslFileError rc = osl_openFile( aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); + osl_closeFile(out.FileHandle); + out.FileHandle = NULL; + + if( osl_File_E_EXIST == rc ) + { + if ( m_aHandler->checkDownloadDestination( aURL.copy( nIndex+1 ) ) ) + { + osl_removeFile( aFile.pData ); + aFile = rtl::OUString(); + } + else + m_aHandler->downloadStarted( aFile, 0 ); + } + else + { + osl_removeFile( aFile.pData ); + aFile = rtl::OUString(); + } + } - out.File = rFile; + out.File = aFile; out.DestinationDir = rDestinationDir; out.Handler = m_aHandler; - if( rFile.getLength() > 0 ) + if( aFile.getLength() > 0 ) { - oslFileError rc = osl_openFile(rFile.pData, &out.FileHandle, osl_File_OpenFlag_Write); + oslFileError rc = osl_openFile(aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write); if( osl_File_E_None == rc ) { diff --git a/extensions/source/update/check/download.hxx b/extensions/source/update/check/download.hxx index 1b2fb678417b..ff16ef52f7fb 100644 --- a/extensions/source/update/check/download.hxx +++ b/extensions/source/update/check/download.hxx @@ -35,6 +35,8 @@ struct DownloadInteractionHandler : public rtl::IReference { + virtual bool checkDownloadDestination(const rtl::OUString& rFileName) = 0; + // called if the destination file already exists, but resume is false virtual bool downloadTargetExists(const rtl::OUString& rFileName) = 0; diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index 522bac4c96ef..8419569bd949 100644..100755 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -800,6 +800,8 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, aModel.getUpdateEntry(m_aUpdateInfo); bool obsoleteUpdateInfo = isObsoleteUpdateInfo(aUpdateEntryVersion); + bool bContinueDownload = false; + bool bDownloadAvailable = false; m_bHasExtensionUpdate = checkForPendingUpdates( xContext ); m_bShowExtUpdDlg = false; @@ -808,10 +810,7 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, if( aLocalFileName.getLength() > 0 ) { - bool downloadPaused = aModel.isDownloadPaused(); - - enableDownload(true, downloadPaused); - setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING); + bContinueDownload = true; // Try to get the number of bytes already on disk osl::DirectoryItem aDirectoryItem; @@ -820,16 +819,36 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, osl::FileStatus aFileStatus(FileStatusMask_FileSize); if( osl::DirectoryItem::E_None == aDirectoryItem.getFileStatus(aFileStatus) ) { - // Calculate initial percent value. - if( aModel.getDownloadSize() > 0 ) + sal_Int64 nDownloadSize = aModel.getDownloadSize(); + sal_Int64 nFileSize = aFileStatus.getFileSize(); + + if( nDownloadSize > 0 ) { - sal_Int32 nPercent = (sal_Int32) (100 * aFileStatus.getFileSize() / aModel.getDownloadSize()); - getUpdateHandler()->setProgress(nPercent); + if ( nDownloadSize <= nFileSize ) // we have already downloaded everthing + { + bContinueDownload = false; + bDownloadAvailable = true; + m_aImageName = getImageFromFileName( aLocalFileName ); + } + else // Calculate initial percent value. + { + sal_Int32 nPercent = (sal_Int32) (100 * nFileSize / nDownloadSize); + getUpdateHandler()->setProgress( nPercent ); + } } } } + + if ( bContinueDownload ) + { + bool downloadPaused = aModel.isDownloadPaused(); + + enableDownload(true, downloadPaused); + setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING); + } + } - else + if ( !bContinueDownload ) { // We do this intentionally only if no download is in progress .. if( obsoleteUpdateInfo ) @@ -842,6 +861,8 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, // Data is outdated, probably due to installed update rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( xContext, *this ); aConfig->clearUpdateFound(); + aConfig->clearLocalFileName(); + m_aUpdateInfo = UpdateInfo(); // Remove outdated release notes @@ -851,7 +872,10 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, else { enableAutoCheck(aModel.isAutoCheckEnabled()); - setUIState(getUIState(m_aUpdateInfo)); + if ( bDownloadAvailable ) + setUIState( UPDATESTATE_DOWNLOAD_AVAIL ); + else + setUIState(getUIState(m_aUpdateInfo)); } } } @@ -940,6 +964,10 @@ UpdateCheck::install() aParameter += UNISTRING(" &"); #endif + + rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext ); + rModel->clearLocalFileName(); + xShellExecute->execute(aInstallImage, aParameter, nFlags); ShutdownThread *pShutdownThread = new ShutdownThread( m_xContext ); (void) pShutdownThread; @@ -1105,6 +1133,23 @@ UpdateCheck::downloadTargetExists(const rtl::OUString& rFileName) } //------------------------------------------------------------------------------ +bool UpdateCheck::checkDownloadDestination( const rtl::OUString& rFileName ) +{ + osl::ClearableMutexGuard aGuard(m_aMutex); + + rtl::Reference< UpdateHandler > aUpdateHandler( getUpdateHandler() ); + + bool bReload = false; + + if( aUpdateHandler->isVisible() ) + { + bReload = aUpdateHandler->showOverwriteWarning( rFileName ); + } + + return bReload; +} + +//------------------------------------------------------------------------------ void UpdateCheck::downloadStalled(const rtl::OUString& rErrorMessage) @@ -1135,15 +1180,18 @@ UpdateCheck::downloadProgressAt(sal_Int8 nPercent) void UpdateCheck::downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize) { - osl::MutexGuard aGuard(m_aMutex); + if ( nFileSize > 0 ) + { + osl::MutexGuard aGuard(m_aMutex); - rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext)); - aModel->storeLocalFileName(rLocalFileName, nFileSize); + rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext)); + aModel->storeLocalFileName(rLocalFileName, nFileSize); - // Bring-up release note for position 1 .. - const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled())); - if( aURL.getLength() > 0 ) - showReleaseNote(aURL); + // Bring-up release note for position 1 .. + const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled())); + if( aURL.getLength() > 0 ) + showReleaseNote(aURL); + } } //------------------------------------------------------------------------------ @@ -1156,9 +1204,6 @@ UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName) // no more retries m_pThread->terminate(); - rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext); - rModel->clearLocalFileName(); - m_aImageName = getImageFromFileName(rLocalFileName); UpdateInfo aUpdateInfo(m_aUpdateInfo); @@ -1166,6 +1211,7 @@ UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName) setUIState(UPDATESTATE_DOWNLOAD_AVAIL); // Bring-up release note for position 2 .. + rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext ); const rtl::OUString aURL(getReleaseNote(aUpdateInfo, 2, rModel->isAutoDownloadEnabled())); if( aURL.getLength() > 0 ) showReleaseNote(aURL); diff --git a/extensions/source/update/check/updatecheck.hxx b/extensions/source/update/check/updatecheck.hxx index 59a1727f4bd9..7283288769e0 100644 --- a/extensions/source/update/check/updatecheck.hxx +++ b/extensions/source/update/check/updatecheck.hxx @@ -111,6 +111,8 @@ public: virtual void downloadProgressAt(sal_Int8 nProcent); virtual void downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize); virtual void downloadFinished(const rtl::OUString& rLocalFileName); + // checks if the download target already exists and asks user what to do next + virtual bool checkDownloadDestination( const rtl::OUString& rFile ); // Cancels the download action (and resumes checking if enabled) void cancelDownload(); diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index b3e559c5f136..9f78b33270c2 100644..100755 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -398,7 +398,7 @@ UpdateCheckConfig::storeLocalFileName(const rtl::OUString& rLocalFileName, sal_I if( m_xContainer->hasByName(aNameList[i]) ) m_xContainer->replaceByName(aNameList[i], aValueList[i]); else - m_xContainer->insertByName(aNameList[i],aValueList[i]); + m_xContainer->insertByName(aNameList[i], aValueList[i]); } commitChanges(); diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index cd1c5f1f721a..bb38c34a0b4e 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -52,6 +52,7 @@ #include "com/sun/star/awt/XThrobber.hpp" #include "com/sun/star/awt/XTopWindow.hpp" #include "com/sun/star/awt/XVclWindowPeer.hpp" +#include "com/sun/star/awt/XVclContainer.hpp" #include "com/sun/star/awt/XWindow.hpp" #include "com/sun/star/awt/XWindow2.hpp" @@ -101,7 +102,8 @@ UpdateHandler::UpdateHandler( const uno::Reference< uno::XComponentContext > & r mbVisible( false ), mbStringsLoaded( false ), mbMinimized( false ), - mbListenerAdded(false) + mbListenerAdded(false), + mbShowsMessageBox(false) { } @@ -232,6 +234,11 @@ void UpdateHandler::setVisible( bool bVisible ) //-------------------------------------------------------------------- void UpdateHandler::setProgress( sal_Int32 nPercent ) { + if ( nPercent > 100 ) + nPercent = 100; + else if ( nPercent < 0 ) + nPercent = 0; + if ( nPercent != mnPercent ) { osl::MutexGuard aGuard( maMutex ); @@ -478,7 +485,18 @@ void SAL_CALL UpdateHandler::handle( uno::Reference< task::XInteractionRequest > void SAL_CALL UpdateHandler::queryTermination( const lang::EventObject& ) throw ( frame::TerminationVetoException, uno::RuntimeException ) { - setVisible( false ); + if ( mbShowsMessageBox ) + { + uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY ); + if ( xTopWindow.is() ) + xTopWindow->toFront(); + + throw frame::TerminationVetoException( + UNISTRING("The office cannot be closed while displaying a warning!"), + uno::Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), uno::UNO_QUERY)); + } + else + setVisible( false ); } //------------------------------------------------------------------------------ @@ -707,6 +725,9 @@ void UpdateHandler::loadStrings() msInstallError = loadString( xBundle, RID_UPDATE_STR_INSTALL_ERROR ); msOverwriteWarning = loadString( xBundle, RID_UPDATE_STR_OVERWRITE_WARNING ); msPercent = loadString( xBundle, RID_UPDATE_STR_PERCENT ); + msReloadWarning = loadString( xBundle, RID_UPDATE_STR_RELOAD_WARNING ); + msReloadReload = loadString( xBundle, RID_UPDATE_STR_RELOAD_RELOAD ); + msReloadContinue = loadString( xBundle, RID_UPDATE_STR_RELOAD_CONTINUE ); msStatusFL = loadString( xBundle, RID_UPDATE_FT_STATUS ); msDescription = loadString( xBundle, RID_UPDATE_FT_DESCRIPTION ); @@ -943,12 +964,14 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); if ( xMsgBox.is() ) { + mbShowsMessageBox = true; sal_Int16 nRet; // xMsgBox->setCaptionText( msCancelTitle ); xMsgBox->setMessageText( rWarningText ); nRet = xMsgBox->execute(); if ( nRet == 2 ) // RET_YES == 2 bRet = true; + mbShowsMessageBox = false; } uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); @@ -959,6 +982,86 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const } //-------------------------------------------------------------------- +bool UpdateHandler::showWarning( const rtl::OUString &rWarningText, + const rtl::OUString &rBtnText_1, + const rtl::OUString &rBtnText_2 ) const +{ + bool bRet = false; + + uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY ); + if ( !xControl.is() ) return bRet; + + uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer(); + if ( !xPeer.is() ) return bRet; + + uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit(); + if ( !xToolkit.is() ) return bRet; + + awt::WindowDescriptor aDescriptor; + + sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE; + nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO; + nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO; + + aDescriptor.Type = awt::WindowClass_MODALTOP; + aDescriptor.WindowServiceName = UNISTRING( "warningbox" ); + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = xPeer; + aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 ); + aDescriptor.WindowAttributes = nWindowAttributes; + + uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); + if ( xMsgBox.is() ) + { + uno::Reference< awt::XVclContainer > xMsgBoxCtrls( xMsgBox, uno::UNO_QUERY ); + if ( xMsgBoxCtrls.is() ) + { + uno::Sequence< uno::Reference< awt::XWindow > > xChildren = xMsgBoxCtrls->getWindows(); + + for ( long i=0; i < xChildren.getLength(); i++ ) + { + uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY ); + if ( xMsgBoxCtrl.is() ) + { + bool bIsDefault = true; + uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") ); + aValue >>= bIsDefault; + if ( bIsDefault ) + xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_1 ) ); + else + xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_2 ) ); + } + } + } + + sal_Int16 nRet; + // xMsgBox->setCaptionText( msCancelTitle ); + mbShowsMessageBox = true; + xMsgBox->setMessageText( rWarningText ); + nRet = xMsgBox->execute(); + if ( nRet == 2 ) // RET_YES == 2 + bRet = true; + + mbShowsMessageBox = false; + } + + uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + + return bRet; +} + +//-------------------------------------------------------------------- +bool UpdateHandler::showOverwriteWarning( const rtl::OUString& rFileName ) const +{ + rtl::OUString aMsg( msReloadWarning ); + searchAndReplaceAll( aMsg, UNISTRING( "%FILENAME" ), rFileName ); + searchAndReplaceAll( aMsg, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath ); + return showWarning( aMsg, msReloadContinue, msReloadReload ); +} + +//-------------------------------------------------------------------- bool UpdateHandler::showOverwriteWarning() const { return showWarning( msOverwriteWarning ); diff --git a/extensions/source/update/check/updatehdl.hrc b/extensions/source/update/check/updatehdl.hrc index 6389a661bf6c..ad3d472eaf68 100644 --- a/extensions/source/update/check/updatehdl.hrc +++ b/extensions/source/update/check/updatehdl.hrc @@ -47,6 +47,9 @@ #define RID_UPDATE_STR_PERCENT RID_UPDATE_HDL_START + 18 #define RID_UPDATE_STR_DOWNLOAD_DESCR RID_UPDATE_HDL_START + 19 #define RID_UPDATE_STR_INSTALL_ERROR RID_UPDATE_HDL_START + 20 + #define RID_UPDATE_STR_RELOAD_WARNING RID_UPDATE_HDL_START + 21 + #define RID_UPDATE_STR_RELOAD_RELOAD RID_UPDATE_HDL_START + 22 + #define RID_UPDATE_STR_RELOAD_CONTINUE RID_UPDATE_HDL_START + 23 #define RID_UPDATE_FT_DESCRIPTION RID_UPDATE_HDL_START + 25 #define RID_UPDATE_FT_STATUS RID_UPDATE_HDL_START + 26 diff --git a/extensions/source/update/check/updatehdl.hxx b/extensions/source/update/check/updatehdl.hxx index 696e2cdda0cf..bd525853dda1 100644 --- a/extensions/source/update/check/updatehdl.hxx +++ b/extensions/source/update/check/updatehdl.hxx @@ -98,6 +98,7 @@ private: bool mbStringsLoaded; bool mbMinimized; bool mbListenerAdded; + mutable bool mbShowsMessageBox; osl::Mutex maMutex; @@ -125,6 +126,9 @@ private: rtl::OUString msInstallError; // RID_UPDATE_STR_INSTALL_ERROR rtl::OUString msOverwriteWarning; // RID_UPDATE_STR_OVERWRITE_WARNING rtl::OUString msPercent; // RID_UPDATE_STR_PERCENT + rtl::OUString msReloadWarning; // RID_UPDATE_STR_OVERWRITE_WARNING + rtl::OUString msReloadReload; // RID_UPDATE_STR_OVERWRITE_WARNING + rtl::OUString msReloadContinue; // RID_UPDATE_STR_OVERWRITE_WARNING rtl::OUString msStatusFL; // RID_UPDATE_FT_STATUS rtl::OUString msDescription; // RID_UPDATE_FT_DESCRIPTION rtl::OUString msClose; // RID_UPDATE_BTN_CLOSE @@ -184,6 +188,8 @@ public: rtl::OUString getBubbleTitle( UpdateState eState ); rtl::OUString getDefaultInstErrMsg(); bool showWarning( const rtl::OUString &rWarning ) const; + bool showWarning( const rtl::OUString &rWarning, const rtl::OUString& rBtnText_1, const rtl::OUString& rBtnText_2 ) const; + bool showOverwriteWarning( const rtl::OUString &rFileName ) const; bool showOverwriteWarning() const; // Allows runtime exceptions to be thrown by const methods diff --git a/extensions/source/update/check/updatehdl.src b/extensions/source/update/check/updatehdl.src index d371a80b33cb..58f88b7e4852 100644 --- a/extensions/source/update/check/updatehdl.src +++ b/extensions/source/update/check/updatehdl.src @@ -122,6 +122,21 @@ String RID_UPDATE_STR_OVERWRITE_WARNING Text [ en-US ] = "A file with that name already exists! Do you want to overwrite the existing file?"; }; +String RID_UPDATE_STR_RELOAD_WARNING +{ + Text [ en-US ] = "A file with the name '%FILENAME' already exists in '%DOWNLOAD_PATH'! Do you want to continue with the download or delete and reload the file?"; +}; + +String RID_UPDATE_STR_RELOAD_RELOAD +{ + Text [ en-US ] = "Reload File"; +}; + +String RID_UPDATE_STR_RELOAD_CONTINUE +{ + Text [ en-US ] = "Continue"; +}; + String RID_UPDATE_STR_PERCENT { Text [ en-US ] = "%PERCENT%"; diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index 4dfdb61cbb2b..278e561de251 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -532,26 +532,11 @@ void OComboBoxModel::loadData( bool _bForce ) else { // otherwise look for the alias - Reference<XSQLQueryComposerFactory> xFactory(xConnection, UNO_QUERY); - if (!xFactory.is()) - break; - - Reference<XSQLQueryComposer> xComposer = xFactory->createQueryComposer(); - try - { - Reference<XPropertySet> xFormAsSet(xForm, UNO_QUERY); - ::rtl::OUString aStatement; - xFormAsSet->getPropertyValue(PROPERTY_ACTIVECOMMAND) >>= aStatement; - xComposer->setQuery(aStatement); - } - catch(Exception&) - { - disposeComponent(xComposer); - break; - } + Reference<XPropertySet> xFormProp(xForm,UNO_QUERY); + Reference< XColumnsSupplier > xSupplyFields; + xFormProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupplyFields; // search the field - Reference< XColumnsSupplier > xSupplyFields(xComposer, UNO_QUERY); DBG_ASSERT(xSupplyFields.is(), "OComboBoxModel::loadData : invalid query composer !"); Reference< XNameAccess > xFieldNames = xSupplyFields->getColumns(); @@ -562,8 +547,6 @@ void OComboBoxModel::loadData( bool _bForce ) if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet)) xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName; } - - disposeComponent(xComposer); } if (!aFieldName.getLength()) diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index b4c7eddf81d8..9cbc5237cf95 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -397,17 +397,10 @@ namespace frm const Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); // create a query composer - const Reference< XConnection > xConnection( ::dbtools::getConnection( xForm ), UNO_SET_THROW ); - const Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY_THROW ); - const Reference< XSQLQueryComposer > xComposer( xFactory->createQueryComposer(), UNO_SET_THROW ); - - // set the statement on the composer - ::rtl::OUString sStatement; - xFormProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sStatement; - xComposer->setQuery( sStatement ); + Reference< XColumnsSupplier > xSuppColumns; + xFormProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSuppColumns; - // the field we're bound to - const Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY_THROW ); + const Reference< XConnection > xConnection( ::dbtools::getConnection( xForm ), UNO_SET_THROW ); const Reference< XNameAccess > xFieldNames( xSuppColumns->getColumns(), UNO_SET_THROW ); if ( !xFieldNames->hasByName( sFieldName ) ) return; @@ -417,7 +410,7 @@ namespace frm xComposerFieldProps->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName; // obtain the table of the field - const Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY_THROW ); + const Reference< XTablesSupplier > xSuppTables( xSuppColumns, UNO_QUERY_THROW ); const Reference< XNameAccess > xTablesNames( xSuppTables->getTables(), UNO_SET_THROW ); const Reference< XNamed > xNamedTable( xTablesNames->getByName( sTableName ), UNO_QUERY_THROW ); sTableName = xNamedTable->getName(); diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 6e11fa7c9dbb..a35a300dda78 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -580,7 +580,7 @@ void OFormattedModel::_propertyChanged( const com::sun::star::beans::PropertyCha // as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have // to recalc it, which is done by translateDbColumnToControlValue - if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast()) + if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast()) { setControlValue( translateDbColumnToControlValue(), eOther ); } diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 88135c040d71..d2de4882dead 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -174,6 +174,8 @@ namespace frm m_eListSourceType = ListSourceType_VALUELIST; m_aBoundColumn <<= (sal_Int16)1; initValueProperty( PROPERTY_SELECT_SEQ, PROPERTY_ID_SELECT_SEQ); + + startAggregatePropertyListening( PROPERTY_STRINGITEMLIST ); } //------------------------------------------------------------------ @@ -191,6 +193,8 @@ namespace frm ,m_nBoundColumnType( DataType::SQLNULL ) { DBG_CTOR(OListBoxModel,NULL); + + startAggregatePropertyListening( PROPERTY_STRINGITEMLIST ); } //------------------------------------------------------------------ @@ -453,6 +457,22 @@ namespace frm } //------------------------------------------------------------------------------ + void OListBoxModel::_propertyChanged( const PropertyChangeEvent& i_rEvent ) throw ( RuntimeException ) + { + if ( i_rEvent.PropertyName == PROPERTY_STRINGITEMLIST ) + { + ControlModelLock aLock( *this ); + // SYNCHRONIZED -----> + // our aggregate internally changed its StringItemList property - reflect this in our "overridden" + // version of the property + setNewStringItemList( i_rEvent.NewValue, aLock ); + // <----- SYNCHRONIZED + return; + } + OBoundControlModel::_propertyChanged( i_rEvent ); + } + + //------------------------------------------------------------------------------ void OListBoxModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const { OBoundControlModel::describeAggregateProperties( _rAggregateProps ); @@ -700,25 +720,10 @@ namespace frm else { // otherwise look for the alias - Reference<XSQLQueryComposerFactory> xFactory(xConnection, UNO_QUERY); - if (!xFactory.is()) - break; - - Reference<XSQLQueryComposer> xComposer = xFactory->createQueryComposer(); - try - { - ::rtl::OUString aStatement; - xFormProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= aStatement; - xComposer->setQuery( aStatement ); - } - catch(Exception&) - { - disposeComponent(xComposer); - break; - } + Reference< XColumnsSupplier > xSupplyFields; + xFormProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupplyFields; // search the field - Reference<XColumnsSupplier> xSupplyFields(xComposer, UNO_QUERY); DBG_ASSERT(xSupplyFields.is(), "OListBoxModel::loadData : invalid query composer !"); Reference<XNameAccess> xFieldNames = xSupplyFields->getColumns(); @@ -729,7 +734,6 @@ namespace frm if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet)) xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName; } - disposeComponent(xComposer); } } if (!aFieldName.getLength()) diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index 04db6069d89e..46ab6b872fb8 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -134,6 +134,9 @@ protected: // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException); + // OPropertyChangeListener + virtual void _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& _rEvt ) throw ( ::com::sun::star::uno::RuntimeException ); + // prevent method hiding using OBoundControlModel::getFastPropertyValue; using OBoundControlModel::setPropertyValues; diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 48e6159585ab..68f3e0e7773f 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -48,6 +48,8 @@ #include <com/sun/star/form/XConfirmDeleteListener.hpp> #include <com/sun/star/sdb/RowChangeEvent.hpp> #include <com/sun/star/sdb/RowChangeAction.hpp> +#include <com/sun/star/sdb/SQLFilterOperator.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/form/XReset.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> @@ -94,6 +96,7 @@ namespace frm using ::com::sun::star::form::runtime::FeatureState; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::sdbc::SQLException; + using namespace ::com::sun::star::sdbc; using ::com::sun::star::form::XForm; using ::com::sun::star::ucb::AlreadyInitializedException; using ::com::sun::star::util::XModifyBroadcaster; @@ -112,6 +115,7 @@ namespace frm using ::com::sun::star::sdbcx::XRowLocate; using ::com::sun::star::form::XConfirmDeleteListener; using ::com::sun::star::sdb::RowChangeEvent; + using namespace ::com::sun::star::sdb; using ::com::sun::star::form::XReset; using ::com::sun::star::beans::XMultiPropertySet; using ::com::sun::star::uno::makeAny; @@ -1684,7 +1688,23 @@ namespace frm void FormOperations::impl_appendFilterByColumn_throw( const void* _pActionParam ) const { const param_appendFilterByColumn* pParam = static_cast< const param_appendFilterByColumn* >( _pActionParam ); - m_xParser->appendFilterByColumn( pParam->xField, sal_True ); + sal_Int32 nOp = SQLFilterOperator::EQUAL; + if ( pParam->xField.is() ) + { + sal_Int32 nType = 0; + pParam->xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType; + switch(nType) + { + case DataType::VARCHAR: + case DataType::CHAR: + case DataType::LONGVARCHAR: + nOp = SQLFilterOperator::LIKE; + break; + default: + nOp = SQLFilterOperator::EQUAL; + } + } + m_xParser->appendFilterByColumn( pParam->xField, sal_True,nOp ); } //------------------------------------------------------------------------------ diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx index 3b0871cc36b6..3b0871cc36b6 100644..100755 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 2e81c80c4321..be11586bc4fb 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -3280,7 +3280,7 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const ::rtl::OUString& aProp ) if ( ( ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE || m_pData->m_nStorageType == embed::StorageFormats::OFOPXML ) && aPropertyName.equalsAscii( "MediaType" ) ) - || m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName.equalsAscii( "Encrypted" ) + || ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName.equalsAscii( "Encrypted" ) ) || aPropertyName.equalsAscii( "Compressed" ) ) { m_pImpl->GetStreamProperties(); diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx index 68c393fed08b..12aa89e03db0 100644 --- a/package/source/xstor/xfactory.cxx +++ b/package/source/xstor/xfactory.cxx @@ -273,7 +273,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr } else if ( xStream.is() ) { - if ( ( nStorageMode & embed::ElementModes::WRITE ) && !xStream->getOutputStream().is() + if ( ( ( nStorageMode & embed::ElementModes::WRITE ) && !xStream->getOutputStream().is() ) || !xStream->getInputStream().is() ) throw uno::Exception(); // TODO: access denied diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 007f199332c5..9c90c4ce35dd 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -4808,11 +4808,11 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName, m_pImpl->m_bIsModified = sal_True; } } - else if ( m_pData->m_bIsRoot && ( aPropertyName.equalsAscii( "HasEncryptedEntries" ) + else if ( ( m_pData->m_bIsRoot && ( aPropertyName.equalsAscii( "HasEncryptedEntries" ) || aPropertyName.equalsAscii( "HasNonEncryptedEntries" ) || aPropertyName.equalsAscii( "IsInconsistent" ) || aPropertyName.equalsAscii( "URL" ) - || aPropertyName.equalsAscii( "RepairPackage" ) ) + || aPropertyName.equalsAscii( "RepairPackage" ) ) ) || aPropertyName.equalsAscii( "IsRoot" ) || aPropertyName.equalsAscii( "MediaTypeFallbackUsed" ) ) throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); @@ -4856,8 +4856,8 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName, else throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); } - else if ( m_pData->m_bIsRoot && ( aPropertyName.equalsAscii( "URL" ) - || aPropertyName.equalsAscii( "RepairPackage" ) ) + else if ( ( m_pData->m_bIsRoot && ( aPropertyName.equalsAscii( "URL" ) + || aPropertyName.equalsAscii( "RepairPackage" ) ) ) || aPropertyName.equalsAscii( "IsRoot" ) ) throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); else diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 14ef46190f3d..2238cf870d02 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -787,14 +787,14 @@ sal_Int32 ZipFile::readCEN() aEntry.nOffset += nLocPos; aEntry.nOffset *= -1; - if ( aEntry.nPathLen < 0 || aEntry.nPathLen > ZIP_MAXNAMELEN ) - throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "name length exceeds ZIP_MAXNAMELEN bytes" ) ), Reference < XInterface > () ); + if ( aEntry.nPathLen < 0 ) + throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "unexpected name length" ) ), Reference < XInterface > () ); - if ( nCommentLen < 0 || nCommentLen > ZIP_MAXNAMELEN ) - throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "comment length exceeds ZIP_MAXNAMELEN bytes" ) ), Reference < XInterface > () ); + if ( nCommentLen < 0 ) + throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "unexpected comment length" ) ), Reference < XInterface > () ); - if ( aEntry.nExtraLen < 0 || aEntry.nExtraLen > ZIP_MAXEXTRA ) - throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "extra header info exceeds ZIP_MAXEXTRA bytes") ), Reference < XInterface > () ); + if ( aEntry.nExtraLen < 0 ) + throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "unexpected extra header info length") ), Reference < XInterface > () ); // read always in UTF8, some tools seem not to set UTF8 bit aEntry.sPath = rtl::OUString::intern ( (sal_Char *) aMemGrabber.getCurrentPos(), @@ -879,7 +879,7 @@ sal_Int32 ZipFile::recover() sal_Int32 nDataSize = ( aEntry.nMethod == DEFLATED ) ? aEntry.nCompressedSize : aEntry.nSize; sal_Int32 nBlockLength = nDataSize + aEntry.nPathLen + aEntry.nExtraLen + 30 + nDescrLength; - if ( aEntry.nPathLen <= ZIP_MAXNAMELEN && aEntry.nExtraLen < ZIP_MAXEXTRA + if ( aEntry.nPathLen >= 0 && aEntry.nExtraLen >= 0 && ( nGenPos + nPos + nBlockLength ) <= nLength ) { // read always in UTF8, some tools seem not to set UTF8 bit diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index b4648426049e..f0c4a11d22f4 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -776,11 +776,18 @@ Any SAL_CALL ZipPackageFolder::getPropertyValue( const OUString& PropertyName ) void ZipPackageFolder::doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) { - if ( pEntry->IsFolder() ) - maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageFolder *> ( pEntry ) ); - else - maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageStream *> ( pEntry ) ); - + try + { + if ( pEntry->IsFolder() ) + maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageFolder *> ( pEntry ) ); + else + maContents[pEntry->getName()] = new ContentInfo ( static_cast < ZipPackageStream *> ( pEntry ) ); + } + catch(const uno::Exception& rEx) + { + (void)rEx; + throw; + } if ( bSetParent ) pEntry->setParent ( *this ); } diff --git a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx index 86cba0908bbb..9a933eea0334 100755 --- a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx +++ b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx @@ -177,8 +177,8 @@ static BOOL MoveFileExImpl( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, D extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) { - std::_tstring sInstDir = GetMsiProperty( handle, TEXT("BASISINSTALLLOCATION") ); - std::_tstring sResourceDir = sInstDir + TEXT("program\\resource\\"); + std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); + std::_tstring sResourceDir = sInstDir + TEXT("Basis\\program\\resource\\"); std::_tstring sPattern = sResourceDir + TEXT("vcl*.res"); WIN32_FIND_DATA aFindFileData; diff --git a/setup_native/source/win32/customactions/languagepacks/respintest.cxx b/setup_native/source/win32/customactions/languagepacks/respintest.cxx index bdfb97dfb3e1..6a98af8a3f30 100644 --- a/setup_native/source/win32/customactions/languagepacks/respintest.cxx +++ b/setup_native/source/win32/customactions/languagepacks/respintest.cxx @@ -88,7 +88,7 @@ namespace extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle) { - string sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); + string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); // MessageBox(NULL, sOfficeInstallPath.c_str(), "DEBUG", MB_OK); diff --git a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx index d6f0933077fc..6285d64ebe3f 100755 --- a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx +++ b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx @@ -544,8 +544,7 @@ static std::queue< std::_tstring > getProfileKeys( const std::_tstring& aFileNam extern "C" UINT __stdcall InstallPatchedFiles( MSIHANDLE handle ) { std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); - std::_tstring sBasisInstDir = GetMsiProperty( handle, TEXT("BASISINSTALLLOCATION") ); - std::_tstring sProgramDir = sBasisInstDir + TEXT("program\\"); + std::_tstring sProgramDir = sInstDir + TEXT("Basis\\program\\"); std::_tstring sPatchFile = sProgramDir + TEXT("patchlist.txt"); std::queue< std::_tstring > aSectionNames; @@ -605,16 +604,11 @@ extern "C" UINT __stdcall UninstallPatchedFiles( MSIHANDLE handle ) HKEY hKey; std::_tstring sInstDir; - std::_tstring sBasisInstDir; std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") ); if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("BASISINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sBasisInstDir = szValue; - } if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; @@ -623,10 +617,6 @@ extern "C" UINT __stdcall UninstallPatchedFiles( MSIHANDLE handle ) } else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("BASISINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sBasisInstDir = szValue; - } if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; @@ -636,7 +626,7 @@ extern "C" UINT __stdcall UninstallPatchedFiles( MSIHANDLE handle ) else return ERROR_SUCCESS; - std::_tstring sProgramDir = sBasisInstDir + TEXT("program\\"); + std::_tstring sProgramDir = sInstDir + TEXT("Basis\\program\\"); std::_tstring sPatchFile = sProgramDir + TEXT("patchlist.txt"); std::queue< std::_tstring > aSectionNames; @@ -689,8 +679,8 @@ extern "C" UINT __stdcall UninstallPatchedFiles( MSIHANDLE handle ) extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) { - std::_tstring sInstDir = GetMsiProperty( handle, TEXT("BASISINSTALLLOCATION") ); - std::_tstring sResourceDir = sInstDir + TEXT("program\\resource\\"); + std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); + std::_tstring sResourceDir = sInstDir + TEXT("Basis\\program\\resource\\"); std::_tstring sPattern = sResourceDir + TEXT("vcl*.res"); WIN32_FIND_DATA aFindFileData; @@ -733,8 +723,8 @@ extern "C" UINT __stdcall SetFeatureState( MSIHANDLE handle ) // 1. Reading Product Code from setup.ini of installed Office - std::_tstring sInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); - // MessageBox(NULL, sInstallPath.c_str(), "BASISINSTALLLOCATION", MB_OK); + std::_tstring sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); + // MessageBox(NULL, sInstallPath.c_str(), "INSTALLLOCATION", MB_OK); std::_tstring sSetupiniPath = sInstallPath + TEXT("program\\setup.ini"); TCHAR szProductCode[32767]; @@ -869,8 +859,8 @@ extern "C" UINT __stdcall ShowOnlineUpdateDialog( MSIHANDLE handle ) // Online Update functionality is always available. Then the dialog // that offers the Online Update is superfluous. - std::_tstring sInstDir = GetMsiProperty( handle, TEXT("BASISINSTALLLOCATION") ); - std::_tstring sProgramDir = sInstDir + TEXT("program\\"); + std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); + std::_tstring sProgramDir = sInstDir + TEXT("Basis\\program\\"); std::_tstring sSearchFile = sProgramDir + TEXT("updchk.uno.dll"); WIN32_FIND_DATA data; diff --git a/setup_native/source/win32/customactions/quickstarter/quickstarter.cxx b/setup_native/source/win32/customactions/quickstarter/quickstarter.cxx index f732a3a8ad57..25659a0b4109 100644 --- a/setup_native/source/win32/customactions/quickstarter/quickstarter.cxx +++ b/setup_native/source/win32/customactions/quickstarter/quickstarter.cxx @@ -15,13 +15,13 @@ std::string GetOfficeInstallationPath(MSIHANDLE handle) DWORD sz = 0; LPTSTR dummy = TEXT(""); - if (MsiGetProperty(handle, TEXT("OFFICEINSTALLLOCATION"), dummy, &sz) == ERROR_MORE_DATA) + if (MsiGetProperty(handle, TEXT("INSTALLLOCATION"), dummy, &sz) == ERROR_MORE_DATA) { sz++; // space for the final '\0' DWORD nbytes = sz * sizeof(TCHAR); LPTSTR buff = reinterpret_cast<LPTSTR>(_alloca(nbytes)); ZeroMemory(buff, nbytes); - MsiGetProperty(handle, TEXT("OFFICEINSTALLLOCATION"), buff, &sz); + MsiGetProperty(handle, TEXT("INSTALLLOCATION"), buff, &sz); progpath = buff; } return progpath; diff --git a/setup_native/source/win32/customactions/rebase/rebase.cxx b/setup_native/source/win32/customactions/rebase/rebase.cxx index 4d031bee908a..dfe1e82e1e9b 100644 --- a/setup_native/source/win32/customactions/rebase/rebase.cxx +++ b/setup_native/source/win32/customactions/rebase/rebase.cxx @@ -126,13 +126,11 @@ static BOOL rebaseImagesInFolder( MSIHANDLE handle, const std::string& sPath, LP static BOOL rebaseImages( MSIHANDLE handle, LPVOID pAddress ) { - std::string sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); - std::string sBasisInstallPath = GetMsiProperty(handle, TEXT("BASISINSTALLLOCATION")); - std::string sUreInstallPath = GetMsiProperty(handle, TEXT("UREINSTALLLOCATION")); + std::string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); - std::string sBasisDir = sBasisInstallPath + TEXT("program\\"); - std::string sOfficeDir = sOfficeInstallPath + TEXT("program\\"); - std::string sUreDir = sUreInstallPath + TEXT("bin\\"); + std::string sBasisDir = sInstallPath + TEXT("Basis\\program\\"); + std::string sOfficeDir = sInstallPath + TEXT("program\\"); + std::string sUreDir = sInstallPath + TEXT("URE\\bin\\"); BOOL bResult = rebaseImagesInFolder( handle, sBasisDir, pAddress ); bResult &= rebaseImagesInFolder( handle, sOfficeDir, pAddress ); diff --git a/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx b/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx index 8cfc1fb08597..2941ba5a8e27 100644 --- a/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx +++ b/setup_native/source/win32/customactions/reg4msdoc/msihelper.cxx @@ -52,7 +52,7 @@ bool IsAllUserInstallation(MSIHANDLE handle) std::wstring GetOfficeInstallationPath(MSIHANDLE handle) { std::wstring progpath; - GetMsiProp(handle, TEXT("OFFICEINSTALLLOCATION"), progpath); + GetMsiProp(handle, TEXT("INSTALLLOCATION"), progpath); return progpath; } diff --git a/setup_native/source/win32/customactions/reg64/reg64.cxx b/setup_native/source/win32/customactions/reg64/reg64.cxx index 2264a228030d..53eb16a99583 100644..100755 --- a/setup_native/source/win32/customactions/reg64/reg64.cxx +++ b/setup_native/source/win32/customactions/reg64/reg64.cxx @@ -56,13 +56,14 @@ WINADVAPI LONG WINAPI RegDeleteKeyExW(HKEY,LPCWSTR,REGSAM,DWORD); // in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems. // Also defined in setup_native\source\win32\customactions\reg64\reg64.cxx,source\win32\customactions\shellextensions\shellextensions.cxx and // extensions\source\activex\main\so_activex.cpp + #ifndef KEY_WOW64_64KEY #define KEY_WOW64_64KEY (0x0100) #endif #define TABLE_NAME L"Reg64" -#define BASISINSTALLLOCATION L"[BASISINSTALLLOCATION]" +#define INSTALLLOCATION L"[INSTALLLOCATION]" bool isInstall4AllUsers; wchar_t * sBasisInstallLocation; @@ -214,9 +215,10 @@ wchar_t* GetBasisInstallLocation( MSIHANDLE hMSI ) OutputDebugStringFormat(L"GetBasisInstallLocation - START\n" ); bool bResult = FALSE; wchar_t* pVal = NULL; - GetMsiProp( hMSI, L"BASISINSTALLLOCATION", &pVal); + GetMsiProp( hMSI, L"INSTALLLOCATION", &pVal); OutputDebugStringFormat(L"GetBasisInstallLocation - ENDE\n" ); + return pVal; } @@ -325,14 +327,14 @@ bool DoRegEntries( MSIHANDLE& rhMSI, OPERATION op, MSIHANDLE& rhView) - wchar_t* nPos = wcsstr(szValue , BASISINSTALLLOCATION); + wchar_t* nPos = wcsstr(szValue , INSTALLLOCATION); if ( NULL != nPos) { DWORD nPrefixSize = nPos - szValue; DWORD nPropSize = wcslen(sBasisInstallLocation); - DWORD nPostfixSize = dwValue - wcslen( BASISINSTALLLOCATION ); + DWORD nPostfixSize = dwValue - wcslen( INSTALLLOCATION ); DWORD nNewValueBytes = (nPropSize + nPostfixSize + 1) * sizeof( wchar_t ); wchar_t* newValue = reinterpret_cast<wchar_t*>( malloc( nNewValueBytes ) ); @@ -345,7 +347,7 @@ bool DoRegEntries( MSIHANDLE& rhMSI, OPERATION op, MSIHANDLE& rhView) wcsncat(newValue, sBasisInstallLocation, nPropSize * sizeof( wchar_t )); // postfix - wcsncat(newValue, nPos + ( wcslen( BASISINSTALLLOCATION ) ), nPropSize * sizeof( wchar_t )); + wcsncat(newValue, nPos + ( wcslen( INSTALLLOCATION ) ), nPropSize * sizeof( wchar_t )); wcsncpy(szValue, newValue, nNewValueBytes <=1024? nNewValueBytes: 1024); diff --git a/setup_native/source/win32/customactions/regactivex/regactivex.cxx b/setup_native/source/win32/customactions/regactivex/regactivex.cxx index 1e91ccbd8599..037824689a47 100644 --- a/setup_native/source/win32/customactions/regactivex/regactivex.cxx +++ b/setup_native/source/win32/customactions/regactivex/regactivex.cxx @@ -170,7 +170,7 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue ) BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath ) { wchar_t* pProgPath = NULL; - if ( GetMsiProp( hMSI, L"OFFICEINSTALLLOCATION", &pProgPath ) && pProgPath ) + if ( GetMsiProp( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath ) { char* pCharProgPath = UnicodeToAnsiString( pProgPath ); #ifdef OWN_DEBUG_PRINT diff --git a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx index 09f60b7a66d5..9a028953fef1 100755 --- a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx +++ b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx @@ -184,12 +184,12 @@ extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) // renaming the vcl resource doesn't work reliable with OS >= Windows Vista if (osverinfo.dwMajorVersion < 6 ) { - std::_tstring sInstDir = GetMsiProperty( handle, TEXT("BASISINSTALLLOCATION") ); + std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); // Property empty -> no office installed if ( sInstDir.length() == 0 ) return ERROR_SUCCESS; - std::_tstring sResourceDir = sInstDir + TEXT("program\\resource\\"); + std::_tstring sResourceDir = sInstDir + TEXT("Basis\\program\\resource\\"); std::_tstring sPattern = sResourceDir + TEXT("vcl*.res"); // std::_tstring mystr; @@ -233,7 +233,7 @@ extern "C" UINT __stdcall IsOfficeRunning( MSIHANDLE handle ) } else { - std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); + std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); // Property empty -> no office installed if ( sOfficeInstallPath.length() == 0 ) return ERROR_SUCCESS; diff --git a/setup_native/source/win32/customactions/shellextensions/copyeditiondata.cxx b/setup_native/source/win32/customactions/shellextensions/copyeditiondata.cxx index 28dfcc0e18b6..7dc5194a18cb 100644 --- a/setup_native/source/win32/customactions/shellextensions/copyeditiondata.cxx +++ b/setup_native/source/win32/customactions/shellextensions/copyeditiondata.cxx @@ -100,7 +100,7 @@ extern "C" UINT __stdcall copyEditionData(MSIHANDLE install) { wchar_t * end; boost::scoped_array<wchar_t> to( getProperty( - install, L"OFFICEINSTALLLOCATION", + install, L"INSTALLLOCATION", LCL_STRING0(L"program\\edition\0"), &end)); if (!to) { return ERROR_INSTALL_FAILURE; diff --git a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx index 522c52a9aac9..517915cb831f 100644 --- a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx +++ b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx @@ -93,7 +93,7 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) { bool fSuccess = true; bool bFailIfExist = true; - std::_tstring sDestDir = GetMsiProperty( handle, TEXT("OFFICEINSTALLLOCATION") ); + std::_tstring sDestDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); std::_tstring sShareInstallDir = sDestDir + TEXT("share\\extension\\install\\"); // creating directories diff --git a/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx b/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx index 2b022cfb3b8e..f7cf0247c631 100644 --- a/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx +++ b/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx @@ -161,18 +161,6 @@ extern "C" UINT __stdcall ShowProperties(MSIHANDLE handle) string myText = TEXT("INSTALLLOCATION: ") + property; MessageBox(NULL, myText.c_str(), "INSTALLLOCATION", MB_OK); - property = GetMsiProperty(handle, TEXT("UREINSTALLLOCATION")); - myText = TEXT("UREINSTALLLOCATION: ") + property; - MessageBox(NULL, myText.c_str(), "UREINSTALLLOCATION", MB_OK); - - property = GetMsiProperty(handle, TEXT("BASISINSTALLLOCATION")); - myText = TEXT("BASISINSTALLLOCATION: ") + property; - MessageBox(NULL, myText.c_str(), "BASISINSTALLLOCATION", MB_OK); - - property = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); - myText = TEXT("OFFICEINSTALLLOCATION: ") + property; - MessageBox(NULL, myText.c_str(), "OFFICEINSTALLLOCATION", MB_OK); - property = GetMsiProperty(handle, TEXT("Installed")); myText = TEXT("Installed: ") + property; MessageBox(NULL, myText.c_str(), "Installed", MB_OK); diff --git a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx index 114e24955820..fb0897e728fe 100644 --- a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx +++ b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx @@ -98,12 +98,14 @@ namespace extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) { - string sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); - string sBasisInstallPath = GetMsiProperty(handle, TEXT("BASISINSTALLLOCATION")); - string sUreInstallPath = GetMsiProperty(handle, TEXT("UREINSTALLLOCATION")); + string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); - string sBasisLinkPath = sOfficeInstallPath + TEXT("basis-link"); - string sUreLinkPath = sBasisInstallPath + TEXT("ure-link"); + string sOfficeInstallPath = sInstallPath; + string sBasisInstallPath = sInstallPath + TEXT("Basis\\"); + string sUreInstallPath = sInstallPath + TEXT("URE\\"); + + string sBasisLinkPath = sInstallPath + TEXT("basis-link"); + string sUreLinkPath = sInstallPath + TEXT("Basis\\ure-link"); if ( IsSetMsiProperty(handle, TEXT("ADMININSTALL")) ) { @@ -208,9 +210,11 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle) extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle) { - string sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEUNINSTALLLOCATION")); - string sBasisInstallPath = GetMsiProperty(handle, TEXT("BASISUNINSTALLLOCATION")); - string sUreInstallPath = GetMsiProperty(handle, TEXT("UREUNINSTALLLOCATION")); + string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); + + string sOfficeInstallPath = sInstallPath; + string sBasisInstallPath = sInstallPath + TEXT("Basis\\"); + string sUreInstallPath = sInstallPath + TEXT("URE\\"); string sBasisLinkPath = sOfficeInstallPath + TEXT("basis-link"); string sUreLinkPath = sBasisInstallPath + TEXT("ure-link"); diff --git a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx index 1d3692e456b0..c8035799a539 100755 --- a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx +++ b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx @@ -91,27 +91,6 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle ) if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("OFFICEINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_CURRENT_USER", MB_OK ); - } - - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("BASISINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("BASISINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_CURRENT_USER", MB_OK ); - } - - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("UREINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("UREINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_CURRENT_USER", MB_OK ); - } - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; @@ -123,27 +102,6 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle ) } else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("OFFICEINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_LOCAL_MACHINE", MB_OK ); - } - - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("BASISINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("BASISINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_LOCAL_MACHINE", MB_OK ); - } - - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("UREINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) - { - sInstDir = szValue; - MsiSetProperty(handle, TEXT("UREINSTALLLOCATION"), sInstDir.c_str()); - // MessageBox( NULL, sInstDir.c_str(), "Found in HKEY_LOCAL_MACHINE", MB_OK ); - } - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; diff --git a/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx b/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx index bb339953ff34..ea9bfae3864b 100755 --- a/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx +++ b/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx @@ -115,7 +115,7 @@ extern "C" UINT __stdcall ExecutePostUninstallScript( MSIHANDLE handle ) if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } @@ -123,7 +123,7 @@ extern "C" UINT __stdcall ExecutePostUninstallScript( MSIHANDLE handle ) } else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } diff --git a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx index 191bb5fad393..3906d2584fd1 100644 --- a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx +++ b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx @@ -317,7 +317,7 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath ) extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle) { - std::_tstring sInstDir = GetMsiProperty( handle, TEXT("OFFICEINSTALLLOCATION") ); + std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe"); std::_tstring sShareInstallDir = sInstDir + TEXT("share\\extension\\install\\"); std::_tstring sPattern = sShareInstallDir + TEXT("*.oxt"); @@ -415,7 +415,7 @@ extern "C" UINT __stdcall DeregisterExtensions(MSIHANDLE handle) if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } @@ -423,7 +423,7 @@ extern "C" UINT __stdcall DeregisterExtensions(MSIHANDLE handle) } else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } @@ -533,7 +533,7 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } @@ -541,7 +541,7 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) } else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("OFFICEINSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) { sInstDir = szValue; } diff --git a/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx index 49d5e50be426..5adab408139d 100644 --- a/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx +++ b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx @@ -78,7 +78,7 @@ extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle ) // MessageBox(NULL, sDesktopFile.c_str(), TEXT("OfficeMenuFolder"), MB_OK | MB_ICONINFORMATION); - std::_tstring sIconFile = GetMsiProperty( handle, TEXT("OFFICEINSTALLLOCATION") ) + TEXT("program\\soffice.exe"); + std::_tstring sIconFile = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ) + TEXT("program\\soffice.exe"); OSVERSIONINFO osverinfo; osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); diff --git a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx index d9c271133ac0..70064b58807c 100644 --- a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx +++ b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx @@ -183,12 +183,12 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath ) extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle ) { - std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); + std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); std::_tstring sRenameSrc = sOfficeInstallPath + TEXT("program"); std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_old"); -// MessageBox(NULL, sRenameSrc.c_str(), "OFFICEINSTALLLOCATION", MB_OK); +// MessageBox(NULL, sRenameSrc.c_str(), "INSTALLLOCATION", MB_OK); bool bSuccess = MoveFile( sRenameSrc.c_str(), sRenameDst.c_str() ); if ( !bSuccess ) @@ -216,7 +216,7 @@ extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle ) extern "C" UINT __stdcall RemovePrgFolder( MSIHANDLE handle ) { - std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("OFFICEINSTALLLOCATION")); + std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION")); std::_tstring sRemoveDir = sOfficeInstallPath + TEXT("program_old"); // MessageBox(NULL, sRemoveDir.c_str(), "REMOVING OLD DIR", MB_OK); diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java b/wizards/com/sun/star/wizards/common/NumberFormatter.java index c8471214ec46..cb183eb29c25 100644 --- a/wizards/com/sun/star/wizards/common/NumberFormatter.java +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java @@ -201,6 +201,7 @@ public class NumberFormatter Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale"); int NewFormatKey = defineNumberFormat(FormatString, oLocale); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject); + xPSet.setPropertyValue("FormatsSupplier", _oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier()); if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat")) { xPSet.setPropertyValue("NumberFormat", new Integer(NewFormatKey)); diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 16f8587e535c..f46c3fd657d4 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -108,7 +108,6 @@ public class DBMetaData public com.sun.star.sdb.tools.XConnectionTools ConnectionTools; public com.sun.star.lang.XMultiServiceFactory xMSF; public XComponent xConnectionComponent; - public SQLQueryComposer oSQLQueryComposer; private XNameAccess m_xTableNames; private XInteractionHandler oInteractionHandler; @@ -1117,7 +1116,6 @@ public class DBMetaData ConnectionTools = null; xMSF = null; xConnectionComponent = null; - oSQLQueryComposer = null; CommandObjects = null; } } diff --git a/wizards/com/sun/star/wizards/db/QueryMetaData.java b/wizards/com/sun/star/wizards/db/QueryMetaData.java index 2c49de15696b..bad14c2faa20 100644 --- a/wizards/com/sun/star/wizards/db/QueryMetaData.java +++ b/wizards/com/sun/star/wizards/db/QueryMetaData.java @@ -36,6 +36,7 @@ import com.sun.star.wizards.common.*; public class QueryMetaData extends CommandMetaData { + private SQLQueryComposer oSQLQueryComposer = null; FieldColumn CurFieldColumn; public String Command; // Vector CommandNamesV; @@ -290,4 +291,10 @@ public class QueryMetaData extends CommandMetaData } return iAggregate; } + public SQLQueryComposer getSQLQueryComposer() + { + if ( oSQLQueryComposer == null ) + oSQLQueryComposer = new SQLQueryComposer(this); + return oSQLQueryComposer; + } } diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index a6a63c5a4fc7..0a52f6a3a7a9 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -60,7 +60,7 @@ public class SQLQueryComposer // String m_sFromClause; public XSingleSelectQueryAnalyzer m_xQueryAnalyzer; Vector composedCommandNames = new Vector(1); - public XSingleSelectQueryComposer m_xQueryComposer; + private XSingleSelectQueryComposer m_xQueryComposer; XMultiServiceFactory xMSF; boolean bincludeGrouping = true; @@ -160,10 +160,8 @@ public class SQLQueryComposer { for (int i = 0; i < CurDBMetaData.getFilterConditions().length; i++) { - String sCurFieldName = CurDBMetaData.getFilterConditions()[i][0].Name; m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); } - String s = m_xQueryAnalyzer.getQuery(); } catch (Exception exception) { @@ -270,9 +268,10 @@ public class SQLQueryComposer return m_xQueryAnalyzer.getQuery(); } - private String getFromClause() + public String getFromClause() { String sFromClause = "FROM"; + composedCommandNames.clear(); String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); for (int i = 0; i < sCommandNames.length; i++) { @@ -291,20 +290,27 @@ public class SQLQueryComposer public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) { + return setQueryCommand(_xParentWindow,_bincludeGrouping, _baddAliasFieldNames,true); + } + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery) + { try { String s; bincludeGrouping = _bincludeGrouping; - String sFromClause = getFromClause(); - String sSelectClause = getSelectClause(_baddAliasFieldNames); - String queryclause = sSelectClause + " " + sFromClause; - m_xQueryAnalyzer.setQuery(queryclause); - if (CurDBMetaData.getFilterConditions() != null) + if ( addQuery ) { - if (CurDBMetaData.getFilterConditions().length > 0) + String sFromClause = getFromClause(); + String sSelectClause = getSelectClause(_baddAliasFieldNames); + String queryclause = sSelectClause + " " + sFromClause; + m_xQueryAnalyzer.setQuery(queryclause); + if (CurDBMetaData.getFilterConditions() != null) { - CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions())); - m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); + if (CurDBMetaData.getFilterConditions().length > 0) + { + CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions())); + m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); + } } } s = m_xQueryAnalyzer.getQuery(); @@ -333,6 +339,8 @@ public class SQLQueryComposer { FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname); CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName()); + if ( curComposedCommandName == null ) + return _fieldname; String curAliasName = curComposedCommandName.getAliasName(); return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName()); } @@ -418,4 +426,8 @@ public class SQLQueryComposer typeexception.printStackTrace(System.out); } } + public XSingleSelectQueryComposer getQueryComposer() + { + return m_xQueryComposer; + } } diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java index 3ed03e47b1ee..fb4191277b8c 100644 --- a/wizards/com/sun/star/wizards/document/Control.java +++ b/wizards/com/sun/star/wizards/document/Control.java @@ -33,6 +33,7 @@ import com.sun.star.awt.XControlModel; import com.sun.star.awt.XLayoutConstrains; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.container.XNamed; @@ -97,8 +98,13 @@ public class Control extends Shape icontroltype = _icontroltype; sServiceName = oFormHandler.sModelServices[getControlType()]; Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName); - xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oControlModel); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oControlModel); + xControlModel = UnoRuntime.queryInterface( XControlModel.class, oControlModel ); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oControlModel ); + + XPropertySetInfo xPSI = xPropertySet.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropertySet.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + insertControlInContainer(_FieldName); xControlShape.setControl(xControlModel); if (_xGroupShapes == null) @@ -110,7 +116,7 @@ public class Control extends Shape _xGroupShapes.add(xShape); } xControl = oFormHandler.xControlAccess.getControl(xControlModel); - xControlPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl); + xControlPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xControl ); xWindowPeer = xControl.getPeer(); } catch (Exception e) diff --git a/wizards/com/sun/star/wizards/document/DatabaseControl.java b/wizards/com/sun/star/wizards/document/DatabaseControl.java index 66d9195c0c2f..b0b1523840a9 100644 --- a/wizards/com/sun/star/wizards/document/DatabaseControl.java +++ b/wizards/com/sun/star/wizards/document/DatabaseControl.java @@ -29,6 +29,7 @@ package com.sun.star.wizards.document; import com.sun.star.awt.Point; import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; import com.sun.star.container.XNameContainer; import com.sun.star.drawing.XShapes; import com.sun.star.sdbc.DataType; @@ -92,6 +93,11 @@ public class DatabaseControl extends Control xPropColumn.setPropertyValue("DataField", sFieldName); xPropColumn.setPropertyValue("Label", _columntitle); xPropColumn.setPropertyValue("Width", new Integer(0)); // Width of column is adjusted to Columname + + XPropertySetInfo xPSI = xPropColumn.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropColumn.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + setNumericLimits(); _oGridControl.xNameContainer.insertByName(sFieldName, xPropColumn); } diff --git a/wizards/com/sun/star/wizards/document/GridControl.java b/wizards/com/sun/star/wizards/document/GridControl.java index d946d592ffc0..66bae37e1ed3 100644 --- a/wizards/com/sun/star/wizards/document/GridControl.java +++ b/wizards/com/sun/star/wizards/document/GridControl.java @@ -60,15 +60,15 @@ public class GridControl extends Shape { fieldcolumns = _fieldcolumns; Object oGridModel = oFormHandler.xMSFDoc.createInstance(oFormHandler.sModelServices[FormHandler.SOGRIDCONTROL]); - xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oGridModel); - xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oGridModel); + xNameContainer = UnoRuntime.queryInterface( XNameContainer.class, oGridModel ); + xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, oGridModel ); _xFormName.insertByName(_sname, oGridModel); - xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oGridModel); + xControlModel = UnoRuntime.queryInterface( XControlModel.class, oGridModel ); xControlShape.setControl(xControlModel); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oGridModel); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oGridModel ); oFormHandler.xDrawPage.add(xShape); - xGridColumnFactory = (XGridColumnFactory) UnoRuntime.queryInterface(XGridColumnFactory.class, oGridModel); - xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, oGridModel); + xGridColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, oGridModel ); + xComponent = UnoRuntime.queryInterface( XComponent.class, oGridModel ); // Helper.setUnoPropertyValue(oGridModel, "Name", _sname); for (int i = 0; i < fieldcolumns.length; i++) diff --git a/wizards/com/sun/star/wizards/letter/LocaleCodes.java b/wizards/com/sun/star/wizards/letter/LocaleCodes.java index bf0292c4d6af..82994f40dc6b 100644 --- a/wizards/com/sun/star/wizards/letter/LocaleCodes.java +++ b/wizards/com/sun/star/wizards/letter/LocaleCodes.java @@ -41,7 +41,7 @@ public class LocaleCodes extends Resource public LocaleCodes(XMultiServiceFactory xmsf) { super(xmsf, UNIT_NAME, MODULE_NAME); - allLanguageStrings = getStringList(16750); // STR_ARR_SVT_LANGUAGE_TABLE from svtools/source/misc/langtab.src + allLanguageStrings = getStringList(16635); // STR_ARR_SVT_LANGUAGE_TABLE from svtools/source/misc/langtab.src } public String getLanguageString(String MSID) diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index ca2a232c8ef8..35d1edf37bde 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -169,10 +169,9 @@ public class Finalizer public String finish() { - CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); String queryName = getTitle(); - if ( CurDBMetaData.oSQLQueryComposer.setQueryCommand( m_queryWizard.xWindow, true, true ) - && CurDBMetaData.createQuery( CurDBMetaData.oSQLQueryComposer, queryName ) + if ( CurDBMetaData.getSQLQueryComposer().setQueryCommand( m_queryWizard.xWindow, true, true ) + && CurDBMetaData.createQuery( CurDBMetaData.getSQLQueryComposer(), queryName ) ) return queryName; diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java index 9c8180a05c2d..05f7ad2a6a5b 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -256,13 +256,12 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals(""))) { - getRecordParser().oSQLQueryComposer = new SQLQueryComposer(getRecordParser()); DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) { getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue("Command"); - getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(getRecordParser().Command); - getRecordParser().oSQLQueryComposer.prependSortingCriteria(); + getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); + getRecordParser().getSQLQueryComposer().prependSortingCriteria(); } else { diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index 61ab85c6094d..2bffd2b4bea3 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -268,10 +268,10 @@ public class ReportWizard extends DatabaseObjectWizard implements XTextListener, boolean bQueryCreated = false; if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) { - bQueryCreated = m_reportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(this.xWindow, false, false); + bQueryCreated = m_reportDocument.getRecordParser().getSQLQueryComposer().setQueryCommand(this.xWindow, false, false); m_reportDocument.setCommandType(CommandType.COMMAND); - String sQuery = m_reportDocument.getRecordParser().oSQLQueryComposer.getQuery(); + String sQuery = m_reportDocument.getRecordParser().getSQLQueryComposer().getQuery(); m_reportDocument.setCommand(sQuery); } else @@ -286,11 +286,11 @@ public class ReportWizard extends DatabaseObjectWizard implements XTextListener, { // String sCommand = (String) oCommand.xPropertySet.getPropertyValue("Command"); bQueryCreated = (!sCommand.equals("")); - m_reportDocument.getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); - m_reportDocument.getRecordParser().oSQLQueryComposer.prependSortingCriteria(); + m_reportDocument.getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(sCommand); + m_reportDocument.getRecordParser().getSQLQueryComposer().prependSortingCriteria(); // TODO: check with query m_reportDocument.setCommandType(CommandType.COMMAND); - m_reportDocument.setCommand(m_reportDocument.getRecordParser().oSQLQueryComposer.getQuery()); + m_reportDocument.setCommand(m_reportDocument.getRecordParser().getSQLQueryComposer().getQuery()); bQueryCreated = true; } else @@ -479,7 +479,6 @@ public static XLogger getLogger() if ( m_reportDocument.getRecordParser().getConnection( m_wizardContext ) ) { - m_reportDocument.getRecordParser().oSQLQueryComposer = new SQLQueryComposer(m_reportDocument.getRecordParser()); buildSteps(); m_reportDocument.checkInvariants(); diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java index 8b40528fe832..85b797d3b640 100644 --- a/wizards/com/sun/star/wizards/ui/FilterComponent.java +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -33,13 +33,19 @@ import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XControl; import com.sun.star.awt.XListBox; import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.PropertyAttribute; import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertyContainer; import com.sun.star.beans.XPropertySet; import com.sun.star.lang.EventObject; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lib.uno.helper.PropertySet; import com.sun.star.sdbc.DataType; +import com.sun.star.uno.Any; import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; import com.sun.star.wizards.common.NumberFormatter; @@ -48,6 +54,8 @@ import com.sun.star.wizards.common.JavaTools; import com.sun.star.wizards.common.Properties; import com.sun.star.wizards.db.FieldColumn; import com.sun.star.wizards.db.QueryMetaData; +import java.util.logging.Level; +import java.util.logging.Logger; public class FilterComponent { @@ -112,10 +120,10 @@ public class FilterComponent final int SO_SECONDBOOLFIELDNAME = 256 + 2; final int SO_THIRDBOOLFIELDNAME = 256 + 3; final int SO_FOURTHBOOLFIELDNAME = 256 + 4; - int SO_BOOLEANLIST[] = { + int SO_BOOLEANLIST[] = + { SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME }; - final int SO_OPTQUERYMODE = 5; int SOI_MATCHALL = 0; int SOI_MATCHANY = 1; @@ -127,25 +135,23 @@ public class FilterComponent public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) { - try + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + String sControlName = ""; + switch (iKey) { - int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); - String sControlName = ""; - switch (iKey) - { - // case SOOPTQUERYMODE: - // getfilterstate(); - case SO_FIRSTFIELDNAME: - case SO_SECONDFIELDNAME: - case SO_THIRDFIELDNAME: - case SO_FOURTHFIELDNAME: - sControlName = getControlName(EventObject.Source); - String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); - XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); - String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); - FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName); - - String sControlNameTextValue = "txtValue" + sControlNameSuffix; + // case SOOPTQUERYMODE: + // getfilterstate(); + case SO_FIRSTFIELDNAME: + case SO_SECONDFIELDNAME: + case SO_THIRDFIELDNAME: + case SO_FOURTHFIELDNAME: + sControlName = getControlName(EventObject.Source); + String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); + XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); + String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); + FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName); + + String sControlNameTextValue = "txtValue" + sControlNameSuffix; // String sControlNameBooleanList = "lstBoolean" + sControlNameSuffix; // if (aFieldColumn.FieldType == DataType.BOOLEAN) // { @@ -158,41 +164,36 @@ public class FilterComponent // CurUnoDialog.setControlVisible(sControlNameTextValue, true); // CurUnoDialog.setControlVisible(sControlNameBooleanList, false); - XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); - XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); - Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat())); - final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); - aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter); + XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); + XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); + Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat())); + final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); + aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter); // } - break; - case SO_FIRSTCONDITION: - case SO_SECONDCONDITION: - case SO_THIRDCONDITION: - case SO_FOURTHCONDITION: - sControlName = getControlName(EventObject.Source); - break; - case SOOPTORMODE: - case SOOPTANDMODE: - // getfilterstate(); - return; + break; + case SO_FIRSTCONDITION: + case SO_SECONDCONDITION: + case SO_THIRDCONDITION: + case SO_FOURTHCONDITION: + sControlName = getControlName(EventObject.Source); + break; + case SOOPTORMODE: + case SOOPTANDMODE: + // getfilterstate(); + return; case SO_FIRSTBOOLFIELDNAME: case SO_SECONDBOOLFIELDNAME: case SO_THIRDBOOLFIELDNAME: case SO_FOURTHBOOLFIELDNAME: - sControlName = getControlName(EventObject.Source); + sControlName = getControlName(EventObject.Source); break; - default: - break; - } - togglefollowingControlRow(sControlName); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); + default: + break; } + togglefollowingControlRow(sControlName); } public void disposing(com.sun.star.lang.EventObject eventObject) @@ -205,15 +206,8 @@ public class FilterComponent public void textChanged(TextEvent EventObject) { - try - { - String sName = getControlName(EventObject.Source); - togglefollowingControlRow(sName); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } + String sName = getControlName(EventObject.Source); + togglefollowingControlRow(sName); } public void disposing(EventObject EventObject) @@ -245,10 +239,10 @@ public class FilterComponent } public static String getIndexNumber(String _sStr) - { - String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length()); - return sLastNumber; - } + { + String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length()); + return sLastNumber; + } /** * Enable the next ControlRow if the Condition is complete in the current line @@ -290,102 +284,67 @@ public class FilterComponent int nFilterCount = getFilterCount(); if (nFilterCount > 0) { - if (this.getfilterstate() == this.SOI_MATCHALL) - { - filterconditions = new PropertyValue[1][nFilterCount]; - } - else - { - filterconditions = new PropertyValue[nFilterCount][1]; - } - int a = 0; - for (int i = 0; i < RowCount; i++) + try { - ControlRow CurControlRow = oControlRows[i]; - if (CurControlRow.isEnabled()) + final String serviceName = "com.sun.star.beans.PropertyBag"; + final XPropertyContainer column = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, oQueryMetaData.xMSF.createInstance(serviceName)); + + column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR); + column.addProperty("Name", PropertyAttribute.BOUND, ""); + final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column); + + if ( oQueryMetaData.getSQLQueryComposer().getQuery().length() == 0) + { + final String fromClause = oQueryMetaData.getSQLQueryComposer().getFromClause(); + StringBuffer sql = new StringBuffer(); + sql.append(oQueryMetaData.getSQLQueryComposer().getSelectClause(true)); + sql.append(' '); + sql.append(fromClause); + oQueryMetaData.getSQLQueryComposer().getQueryComposer().setElementaryQuery(sql.toString()); + } + int a = 0; + for (int i = 0; i < RowCount; i++) { - if (CurControlRow.isConditionComplete()) + ControlRow CurControlRow = oControlRows[i]; + if (CurControlRow.isEnabled()) { - Object aValue; - String sFieldName = CurControlRow.getSelectedFieldName(); - int nOperator = (int) CurControlRow.getSelectedOperator(); - FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); - if (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getTextFormatKey()) - { - aValue = "'" + CurControlRow.getValue() + "'"; - } -//// TODO the following code is bound to be deprecated as soon as the query composer is able to handle date/time values as numbers - else if ((aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getDateFormatKey()) || - (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getDateTimeFormatKey())) - { - String sDate = CurControlRow.getDateTimeString(true); - aValue = "{D '" + sDate + "' }"; // FormatsSupplier - } - else if (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getTimeFormatKey()) - { - String sTime = CurControlRow.getDateTimeString(true); - aValue = "'{T '" + sTime + "' }"; - } - else - { - aValue = CurControlRow.getValue(); - // if void - if (! AnyConverter.isVoid(aValue)) - { - switch (aFieldColumn.getFieldType()) - { - case DataType.TINYINT: - case DataType.BIGINT: - case DataType.INTEGER: - case DataType.SMALLINT: - if ( AnyConverter.isDouble(aValue) ) - aValue = String.valueOf(((Double) aValue).intValue()); - break; - case DataType.BIT: - case DataType.BOOLEAN: - // curValue = CurControlRow.getText(); // wrong! (creates something like 'WAHR'/'FALSCH' if german locale is used. - - // double dblvalue = ((Double) curValue).doubleValue(); - //curValue = new Boolean(dblvalue == 1.0); // wrong! we need a string, not a boolean value - - // converts the '1.0'/'0.0' (EffectiveValue) to a 'boolean' String like 'true'/'false' - if ( AnyConverter.isDouble(aValue) ) - aValue = String.valueOf(((Double) aValue).intValue() == 1); - break; - default: - aValue = String.valueOf(aValue); - break; - } - } - } - - PropertyValue oPropertyValue = Properties.createProperty(sFieldName, aValue, nOperator); - if (getfilterstate()/*this.ifilterstate*/ == this.SOI_MATCHALL) + if (CurControlRow.isConditionComplete()) { - if (i == 0) + String sFieldName = CurControlRow.getSelectedFieldName(); + int nOperator = (int) CurControlRow.getSelectedOperator(); + FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); + columnSet.setPropertyValue("Name", aFieldColumn.getFieldName()); + columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type")); + Object value = CurControlRow.getValue(); + switch(aFieldColumn.getFieldType()) { - filterconditions[0] = new PropertyValue[nFilterCount]; + case DataType.TIMESTAMP: + case DataType.DATE: + value = ((Double)value) - oQueryMetaData.getNullDateCorrection(); + break; } - filterconditions[0][a] = oPropertyValue; + column.addProperty("Value", PropertyAttribute.MAYBEVOID, value); + columnSet.setPropertyValue("Value", value); + oQueryMetaData.getSQLQueryComposer().getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator); } - else - { - filterconditions[a][0] = oPropertyValue; - } - a++; } } + filterconditions = oQueryMetaData.getSQLQueryComposer().getQueryComposer().getStructuredFilter(); + int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); + if (iduplicate[0] != -1) + { + PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]]; + String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); + CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); + return new PropertyValue[][] + { + }; + } } - int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); - if (iduplicate[0] != -1) + catch (Exception ex) { - PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]]; - String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); - CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); - CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); - return new PropertyValue[][] - { - }; + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); } } else @@ -413,8 +372,10 @@ public class FilterComponent String soperator = sLogicOperators[_filtercondition.Handle - 1]; sreturn = JavaTools.replaceSubString(sreturn, soperator, "<LOGICOPERATOR>"); String sDisplayValue = ""; - if ( !AnyConverter.isVoid(_filtercondition.Value) ) + if (!AnyConverter.isVoid(_filtercondition.Value)) + { sDisplayValue = AnyConverter.toString(_filtercondition.Value); + } sreturn = JavaTools.replaceSubString(sreturn, sDisplayValue, "<VALUE>"); return sreturn; } @@ -443,24 +404,17 @@ public class FilterComponent private void addfiltercondition(int _index, String _curFieldName, Object _curValue, int _curOperator) { - try + String ValString = String.valueOf(_curValue); + PropertyValue oPropertyValue = Properties.createProperty(_curFieldName, ValString, _curOperator); + getfilterstate(); + if (getfilterstate() == this.SOI_MATCHALL) { - String ValString = String.valueOf(_curValue); - PropertyValue oPropertyValue = Properties.createProperty(_curFieldName, ValString, _curOperator); - getfilterstate(); - if (getfilterstate() == this.SOI_MATCHALL) + if (_index == 0) { - if (_index == 0) - { - filterconditions[0] = new PropertyValue[getFilterCount()]; - } - filterconditions[0][_index] = new PropertyValue(); - filterconditions[0][_index] = oPropertyValue; + filterconditions[0] = new PropertyValue[getFilterCount()]; } - } - catch (Exception exception) - { - exception.printStackTrace(System.out); + filterconditions[0][_index] = new PropertyValue(); + filterconditions[0][_index] = oPropertyValue; } } @@ -475,8 +429,8 @@ public class FilterComponent } } return a; - // FilterCount = a; - // return FilterCount; + // FilterCount = a; + // return FilterCount; } /** Creates a new instance of FilterComponent @@ -492,95 +446,88 @@ public class FilterComponent */ public FilterComponent(WizardDialog CurUnoDialog, XMultiServiceFactory _xMSF, int iStep, int iPosX, int iPosY, int iWidth, int FilterCount, QueryMetaData _oQueryMetaData, int _firstHelpID) { - try - { - this.curHelpID = _firstHelpID; - this.xMSF = _xMSF; - this.IStep = Integer.valueOf(iStep); - - curtabindex = UnoDialog.setInitialTabindex(iStep); - this.CurUnoDialog = CurUnoDialog; - this.RowCount = FilterCount; - this.oQueryMetaData = _oQueryMetaData; - boolean bEnabled; - sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); - // iStartPosX = iPosX; - // iStartPosY = iPosY; - - String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9); - String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10); - slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17); - slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24); - slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25); - sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null - sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false - - sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89); - - // create Radiobuttons - // * match all - // * match one - optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), - new String[] - { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "State", - "Step", - "TabIndex", - "Width" - }, - new Object[] - { - Integer.valueOf(9), - "HID:" + curHelpID++, - soptMatchAll, - Integer.valueOf(iPosX), - Integer.valueOf(iPosY), - Short.valueOf((short) 1), - IStep, - Short.valueOf(curtabindex++), - Integer.valueOf(203) - }); - optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), - new String[] - { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" - }, - new Object[] - { - Integer.valueOf(9), - "HID:" + curHelpID++, - soptMatchAny, - Integer.valueOf(iPosX), - Integer.valueOf(iPosY + 12), - IStep, - Short.valueOf(curtabindex++), - Integer.valueOf(203) - }); - getfilterstate(); - - oControlRows = new ControlRow[FilterCount]; - for (int i = 0; i < FilterCount; i++) - { - bEnabled = (i == 0); - oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); - iPosY += 43; - } - } - catch (Exception exception) + this.curHelpID = _firstHelpID; + this.xMSF = _xMSF; + this.IStep = Integer.valueOf(iStep); + + curtabindex = UnoDialog.setInitialTabindex(iStep); + this.CurUnoDialog = CurUnoDialog; + this.RowCount = FilterCount; + this.oQueryMetaData = _oQueryMetaData; + boolean bEnabled; + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); + // iStartPosX = iPosX; + // iStartPosY = iPosY; + + String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9); + String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10); + slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17); + slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24); + slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25); + sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null + sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false + + sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89); + + // create Radiobuttons + // * match all + // * match one + optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), + new String[] + { + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "State", + "Step", + "TabIndex", + "Width" + }, + new Object[] + { + Integer.valueOf(9), + "HID:" + curHelpID++, + soptMatchAll, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY), + Short.valueOf((short) 1), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), + new String[] + { + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" + }, + new Object[] + { + Integer.valueOf(9), + "HID:" + curHelpID++, + soptMatchAny, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY + 12), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + getfilterstate(); + + oControlRows = new ControlRow[FilterCount]; + for (int i = 0; i < FilterCount; i++) { - exception.printStackTrace(System.out); + bEnabled = (i == 0); + oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); + iPosY += 43; } } @@ -636,29 +583,21 @@ public class FilterComponent public void addNumberFormats() { - try - { - iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD"); - iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS"); - iDateTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS"); - } - catch (Exception e) - { - e.printStackTrace(System.out); - } + iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD"); + iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS"); + iDateTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS"); } // ------------------------------------------------------------------------- // // // ------------------------------------------------------------------------- - class ControlRow { + private final static int SOLSTFIELDNAME = 3; private final static int SOLSTOPERATOR = 4; private final static int SOTXTVALUE = 5; - protected XInterface[] ControlElements = new XInterface[6]; private boolean m_bEnabled; String[] FieldNames; @@ -775,7 +714,7 @@ public class FilterComponent Boolean.TRUE, Integer.valueOf(13), "HID:" + _firstRowHelpID++, - Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */) , + Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */), Integer.valueOf(nPosX1), Integer.valueOf(iCompPosY + 23), IStep, @@ -805,7 +744,7 @@ public class FilterComponent Boolean.TRUE, Integer.valueOf(13), "HID:" + _firstRowHelpID++, - Short.valueOf((short) sLogicOperators.length /* 7 */ ), + Short.valueOf((short) sLogicOperators.length /* 7 */), Integer.valueOf(nPosX2), Integer.valueOf(iCompPosY + 23), IStep, @@ -880,8 +819,9 @@ public class FilterComponent { int nSelOperator = getSelectedOperator(); // short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); - if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL || /* is null */ - nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL + || /* is null */ nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + { // disable value field Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.FALSE); @@ -943,13 +883,27 @@ public class FilterComponent { sValue = JavaTools.replaceSubString(sValue, "", "{D '"); sValue = JavaTools.replaceSubString(sValue, "", "' }"); - oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue); + try + { + oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } } else if (sValue.indexOf("{T '") > -1) { sValue = JavaTools.replaceSubString(sValue, "", "{T '"); sValue = JavaTools.replaceSubString(sValue, "", "' }"); - oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue); + try + { + oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } } } else if (AnyConverter.isBoolean(_filtercondition.Value)) @@ -1001,7 +955,9 @@ public class FilterComponent m_bEnabled = _bEnabled; if (isEnabled()) { - short[] iselected = new short[] {}; + short[] iselected = new short[] + { + }; try { iselected = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); @@ -1012,7 +968,10 @@ public class FilterComponent } if ((iselected.length) == 0) { - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] { 0 }); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] + { + 0 + }); } } else if (!isConditionComplete()) @@ -1044,28 +1003,28 @@ public class FilterComponent short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); switch (SelFields[0]) { - case 0: - return com.sun.star.sdb.SQLFilterOperator.EQUAL; - case 1: - return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; - case 2: - return com.sun.star.sdb.SQLFilterOperator.LESS; - case 3: - return com.sun.star.sdb.SQLFilterOperator.GREATER; - case 4: - return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; - case 5: - return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; - case 6: - return com.sun.star.sdb.SQLFilterOperator.LIKE; - case 7: - return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; - case 8: - return com.sun.star.sdb.SQLFilterOperator.SQLNULL; - case 9: - return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; - default: - return -1; + case 0: + return com.sun.star.sdb.SQLFilterOperator.EQUAL; + case 1: + return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; + case 2: + return com.sun.star.sdb.SQLFilterOperator.LESS; + case 3: + return com.sun.star.sdb.SQLFilterOperator.GREATER; + case 4: + return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; + case 5: + return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; + case 6: + return com.sun.star.sdb.SQLFilterOperator.LIKE; + case 7: + return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; + case 8: + return com.sun.star.sdb.SQLFilterOperator.SQLNULL; + case 9: + return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; + default: + return -1; } } catch (Exception exception) @@ -1078,43 +1037,19 @@ public class FilterComponent // TODO make a difference between Text and Numbers protected Object getValue() { - try - { - return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue")); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - return null; + return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue")); } protected Object getText() { - try - { - return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Text")); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - return null; + return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Text")); } protected String getDateTimeString(boolean bgetDate) { - try - { double dblValue = ((Double) getValue()).doubleValue(); NumberFormatter oNumberFormatter = oQueryMetaData.getNumberFormatter(); return oNumberFormatter.convertNumberToString(iDateTimeFormat, dblValue); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - return null; - } } } } |