summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2002-06-04 17:44:27 +0000
committerThorsten Behrens <thb@openoffice.org>2002-06-04 17:44:27 +0000
commit08845a79bb8f19298a54f3c2a9a82b8da698fbf2 (patch)
treef5abcc3191c296a4dcb0eff7a2d71a22b0444221 /svx
parent77c61241e8e9352ce6140ce00a8347ff5b534194 (diff)
#99840# Fixed various focus problems
Diffstat (limited to 'svx')
-rw-r--r--svx/source/accessibility/AccessibleEditableTextPara.cxx78
-rw-r--r--svx/source/accessibility/AccessibleEditableTextPara.hxx13
-rw-r--r--svx/source/accessibility/AccessibleImageBullet.cxx75
-rw-r--r--svx/source/accessibility/AccessibleImageBullet.hxx11
-rw-r--r--svx/source/accessibility/AccessibleParaManager.hxx26
-rwxr-xr-xsvx/source/accessibility/AccessibleShape.cxx7
-rw-r--r--svx/source/accessibility/AccessibleTextHelper.cxx267
-rw-r--r--svx/source/unodraw/unoshtxt.cxx51
-rw-r--r--svx/source/unoedit/unoedprx.cxx6
9 files changed, 322 insertions, 212 deletions
diff --git a/svx/source/accessibility/AccessibleEditableTextPara.cxx b/svx/source/accessibility/AccessibleEditableTextPara.cxx
index 3fc5ffafae1f..5b2e2cf49be6 100644
--- a/svx/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/svx/source/accessibility/AccessibleEditableTextPara.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleEditableTextPara.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: thb $ $Date: 2002-05-31 13:05:42 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,6 +99,10 @@
#include <com/sun/star/awt/Rectangle.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
#endif
@@ -504,13 +508,26 @@ namespace accessibility
{
try
{
- xListener->notifyEvent( aEvent );
+ xListener->notifyEvent (aEvent);
}
- catch( const uno::Exception& )
+ catch( const lang::DisposedException& e )
{
-#ifdef DBG_UTIL
- DBG_ERROR("AccessibleEditableTextPara::FireEvent: Caught runtime exception from listener, removing object (bridge/listener dead?)");
-#endif
+ // DisposedExceptions from the listener might indicate a
+ // broken connection to a different environment.
+
+ OSL_ENSURE(e.Context.is(), "AccessibleEditableTextPara::FireEvent: caught dispose exception with empty Context field");
+ // If the exception stems from the listener then remove it
+ // from the list of listeners. If the Context field of the
+ // exception is empty this is interpreted to indicate the
+ // listener as well.
+ if (e.Context == xListener
+ || !e.Context.is())
+ aIter.remove();
+ }
+ catch( const uno::Exception& e )
+ {
+ DBG_WARNING1("AccessibleEditableTextPara::FireEvent: exception %s from listener",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_DONTKNOW ).getStr() );
}
}
}
@@ -645,17 +662,18 @@ namespace accessibility
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ // append first 40 characters from text, or first line, if shorter
+ // (writer takes first sentence here, but that's not supported
+ // from EditEngine)
+ // throws if defunc
+ ::rtl::OUString aLine = getTextAtIndex(0, AccessibleTextType::LINE);
+
// Get the string from the resource for the specified id.
String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) );
String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
sParaIndex );
- // append first 40 characters from text, or first line, if shorter
- // (writer takes first sentence here, but that's not supported
- // from EditEngine)
- ::rtl::OUString aLine = getTextAtIndex(0, AccessibleTextType::LINE);
-
if( aLine.getLength() > MaxDescriptionLen )
{
::rtl::OUString aCurrWord;
@@ -686,9 +704,12 @@ namespace accessibility
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ // throws if defunc
+ sal_Int32 nPara( GetParagraphIndex() );
+
// Get the string from the resource for the specified id.
String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_PARAGRAPH_NAME) );
- String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
+ String sParaIndex = ::rtl::OUString::valueOf( nPara );
sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
sParaIndex );
@@ -854,37 +875,6 @@ namespace accessibility
return awt::Size( aRect.Width, aRect.Height );
}
- sal_Bool SAL_CALL AccessibleEditableTextPara::isShowing( ) throw (uno::RuntimeException)
- {
- return IsVisible();
- }
-
- sal_Bool SAL_CALL AccessibleEditableTextPara::isVisible( ) throw (uno::RuntimeException)
- {
- return IsVisible();
- }
-
- sal_Bool SAL_CALL AccessibleEditableTextPara::isFocusTraversable( ) throw (uno::RuntimeException)
- {
- return IsActive();
- }
-
- void SAL_CALL AccessibleEditableTextPara::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // TODO: remove
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
- uno::Reference< uno::XInterface >
- ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
- }
-
- void SAL_CALL AccessibleEditableTextPara::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // TODO: remove
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
- uno::Reference< uno::XInterface >
- ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
- }
-
void SAL_CALL AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException)
{
// set cursor to this paragraph
diff --git a/svx/source/accessibility/AccessibleEditableTextPara.hxx b/svx/source/accessibility/AccessibleEditableTextPara.hxx
index 3311ebb4c0ee..ad40fb6b2fc7 100644
--- a/svx/source/accessibility/AccessibleEditableTextPara.hxx
+++ b/svx/source/accessibility/AccessibleEditableTextPara.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleEditableTextPara.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2002-05-23 12:44:03 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,6 +66,10 @@
#include <tools/gen.hxx>
#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif
@@ -171,11 +175,6 @@ namespace accessibility
virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isShowing( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isFocusTraversable( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
diff --git a/svx/source/accessibility/AccessibleImageBullet.cxx b/svx/source/accessibility/AccessibleImageBullet.cxx
index e809b7f2627e..70a337dc9abb 100644
--- a/svx/source/accessibility/AccessibleImageBullet.cxx
+++ b/svx/source/accessibility/AccessibleImageBullet.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleImageBullet.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: thb $ $Date: 2002-05-31 13:05:42 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,10 @@
#include <com/sun/star/awt/Rectangle.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
#endif
@@ -191,9 +195,12 @@ namespace accessibility
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ // throws if defunc
+ sal_Int32 nPara( GetParagraphIndex() );
+
// Get the string from the resource for the specified id.
String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION) );
- String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
+ String sParaIndex = ::rtl::OUString::valueOf( nPara );
sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
sParaIndex );
@@ -204,9 +211,12 @@ namespace accessibility
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ // throws if defunc
+ sal_Int32 nPara( GetParagraphIndex() );
+
// Get the string from the resource for the specified id.
String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_IMAGEBULLET_NAME) );
- String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
+ String sParaIndex = ::rtl::OUString::valueOf( nPara );
sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
sParaIndex );
@@ -355,40 +365,6 @@ namespace accessibility
return awt::Size( aRect.Width, aRect.Height );
}
- sal_Bool SAL_CALL AccessibleImageBullet::isShowing( ) throw (uno::RuntimeException)
- {
- // TODO: remove
- return sal_False;
- }
-
- sal_Bool SAL_CALL AccessibleImageBullet::isVisible( ) throw (uno::RuntimeException)
- {
- // TODO: remove
- return sal_False;
- }
-
- sal_Bool SAL_CALL AccessibleImageBullet::isFocusTraversable( ) throw (uno::RuntimeException)
- {
- // TODO: remove
- return sal_False;
- }
-
- void SAL_CALL AccessibleImageBullet::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // TODO: remove
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
- uno::Reference< uno::XInterface >
- ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
- }
-
- void SAL_CALL AccessibleImageBullet::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // TODO: remove
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
- uno::Reference< uno::XInterface >
- ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
- }
-
void SAL_CALL AccessibleImageBullet::grabFocus( ) throw (uno::RuntimeException)
{
throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
@@ -494,13 +470,26 @@ namespace accessibility
{
try
{
- xListener->notifyEvent( aEvent );
+ xListener->notifyEvent (aEvent);
}
- catch( const uno::Exception& )
+ catch( const lang::DisposedException& e )
{
-#ifdef DBG_UTIL
- DBG_ERROR("AccessibleImageBullet::FireEvent: Caught runtime exception from listener, removing object (bridge/listener dead?)");
-#endif
+ // DisposedExceptions from the listener might indicate a
+ // broken connection to a different environment.
+
+ OSL_ENSURE(e.Context.is(), "AccessibleImageBullet::FireEvent: caught dispose exception with empty Context field");
+ // If the exception stems from the listener then remove it
+ // from the list of listeners. If the Context field of the
+ // exception is empty this is interpreted to indicate the
+ // listener as well.
+ if (e.Context == xListener
+ || !e.Context.is())
+ aIter.remove();
+ }
+ catch( const uno::Exception& e )
+ {
+ DBG_WARNING1("AccessibleImageBullet::FireEvent: exception %s from listener",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_DONTKNOW ).getStr() );
}
}
}
diff --git a/svx/source/accessibility/AccessibleImageBullet.hxx b/svx/source/accessibility/AccessibleImageBullet.hxx
index 56e55dd5aa41..3e9c17d54e3e 100644
--- a/svx/source/accessibility/AccessibleImageBullet.hxx
+++ b/svx/source/accessibility/AccessibleImageBullet.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleImageBullet.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2002-05-23 12:44:04 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -110,8 +110,6 @@
#include "unoedsrc.hxx"
#endif
-#include <com/sun/star/awt/XFocusListener.hpp>
-
namespace accessibility
{
@@ -163,11 +161,6 @@ namespace accessibility
virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isShowing( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isFocusTraversable( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
diff --git a/svx/source/accessibility/AccessibleParaManager.hxx b/svx/source/accessibility/AccessibleParaManager.hxx
index 67dcf70eabef..6c3759506a59 100644
--- a/svx/source/accessibility/AccessibleParaManager.hxx
+++ b/svx/source/accessibility/AccessibleParaManager.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleParaManager.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2002-05-29 16:09:56 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -241,7 +241,29 @@ namespace accessibility
void SetEditSource ( SvxEditSourceAdapter* pEditSource );
// forwarder to given paragraphs
+ //------------------------------------------------------------------------
+ /** Release the given range of paragraphs
+
+ All ranges have the meaning [start,end), similar to STL
+
+ @param nStartPara
+ Index of paragraph to start with releasing
+
+ @param nEndPara
+ Index of first paragraph to stop with releasing
+ */
void Release( sal_uInt32 nStartPara, sal_uInt32 nEndPara );
+
+ /** Fire event for the given range of paragraphs
+
+ All ranges have the meaning [start,end), similar to STL
+
+ @param nStartPara
+ Index of paragraph to start with event firing
+
+ @param nEndPara
+ Index of first paragraph to stop with event firing
+ */
void FireEvent( sal_uInt32 nStartPara,
sal_uInt32 nEndPara,
const sal_Int16 nEventId,
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index fd7b18bb7f92..d502ace6b000 100755
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleShape.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: af $ $Date: 2002-06-04 10:04:59 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1021,6 +1021,9 @@ void AccessibleShape::ViewForwarderChanged (ChangeType aChangeType,
if (mpChildrenManager != NULL)
mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
+ // update our children that our screen position might have changed
+ if( mpText )
+ mpText->UpdateChildren();
}
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index f8ba7a1a1a21..ab97cdc070c3 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleTextHelper.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: thb $ $Date: 2002-05-29 17:01:52 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:42:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -95,6 +95,10 @@
#include <com/sun/star/awt/Rectangle.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
#endif
@@ -216,6 +220,8 @@ namespace accessibility
void SetFocus( sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException);
sal_Bool HaveFocus() throw (::com::sun::star::uno::RuntimeException);
+ void SetChildFocus( sal_Int32 nChild, sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException);
+ void SetShapeFocus( sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException);
#ifdef DBG_UTIL
void CheckInvariants() const;
@@ -234,8 +240,28 @@ namespace accessibility
void ShutdownEditSource() throw (uno::RuntimeException);
void SetChildrenState( const sal_Int16 nStateId );
+ /** Set the state for multiple children
+
+ All ranges have the meaning [start,end), similar to STL
+
+ @param nStartPara
+ Index of paragraph to start with state setting
+
+ @param nEndPara
+ Index of first paragraph to stop with state setting
+ */
void SetChildrenState( sal_Int32 nStartPara, sal_Int32 nEndPara, const sal_Int16 nStateId );
void UnSetChildrenState( const sal_Int16 nStateId );
+ /** Un-set the state for multiple children
+
+ All ranges have the meaning [start,end), similar to STL
+
+ @param nStartPara
+ Index of paragraph to start with state unsetting
+
+ @param nEndPara
+ Index of first paragraph to stop with state unsetting
+ */
void UnSetChildrenState( sal_Int32 nStartPara, sal_Int32 nEndPara, const sal_Int16 nStateId );
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
@@ -284,8 +310,11 @@ namespace accessibility
// spin lock to prevent notify in notify (guarded by solar mutex)
sal_Bool mbInNotify;
- // whether we have the focus set (guarded by solar mutex)
- sal_Bool mbHaveFocus;
+ // whether the object or it's children has the focus set (guarded by solar mutex)
+ sal_Bool mbGroupHasFocus;
+
+ // whether we (this object) has the focus set (guarded by solar mutex)
+ sal_Bool mbThisHasFocus;
// must be before maStateListeners, has to live longer
mutable ::osl::Mutex maMutex;
@@ -309,7 +338,8 @@ namespace accessibility
mnLastVisibleChild( -2 ),
mnStartIndex( 0 ),
mbInNotify( sal_False ),
- mbHaveFocus( sal_False ),
+ mbGroupHasFocus( sal_False ),
+ mbThisHasFocus( sal_False ),
maStateListeners( maMutex )
{
}
@@ -438,11 +468,44 @@ namespace accessibility
}
}
+ void AccessibleTextHelper_Impl::SetChildFocus( sal_Int32 nChild, sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if( bHaveFocus )
+ {
+ if( mbThisHasFocus )
+ SetShapeFocus( sal_False );
+
+ SetChildrenState( nChild, nChild+1, AccessibleStateType::FOCUSED );
+ }
+ else
+ {
+ UnSetChildrenState( nChild, nChild+1, AccessibleStateType::FOCUSED );
+
+ if( mbGroupHasFocus )
+ SetShapeFocus( sal_True );
+ }
+ }
+
+ void AccessibleTextHelper_Impl::SetShapeFocus( sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Bool bOldFocus( mbThisHasFocus );
+
+ mbThisHasFocus = bHaveFocus;
+
+ if( bOldFocus != bHaveFocus )
+ {
+ if( bHaveFocus )
+ GotPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::ACCESSIBLE_STATE_EVENT );
+ else
+ LostPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::ACCESSIBLE_STATE_EVENT );
+ }
+ }
+
void AccessibleTextHelper_Impl::SetFocus( sal_Bool bHaveFocus ) throw (::com::sun::star::uno::RuntimeException)
{
- sal_Bool bOldFocus( mbHaveFocus );
+ sal_Bool bOldFocus( mbGroupHasFocus );
- mbHaveFocus = bHaveFocus;
+ mbGroupHasFocus = bHaveFocus;
if( IsActive() )
{
@@ -451,25 +514,13 @@ namespace accessibility
// find the one with the cursor and get/set focus accordingly
ESelection aSelection;
if( GetEditViewForwarder().GetSelection( aSelection ) )
- {
- AccessibleParaManager::WeakPara::HardRefType aChild( maParaManager.GetChild(aSelection.nEndPara).first.get() );
- if( maParaManager.IsReferencable(aSelection.nEndPara) )
- {
- if( mbHaveFocus )
- aChild->SetState( AccessibleStateType::FOCUSED );
- else
- aChild->UnSetState( AccessibleStateType::FOCUSED );
- }
- }
+ SetChildFocus( aSelection.nEndPara, bHaveFocus );
}
catch( const uno::Exception& ) {}
}
else if( bOldFocus != bHaveFocus )
{
- if( mbHaveFocus )
- GotPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::ACCESSIBLE_STATE_EVENT );
- else
- LostPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::ACCESSIBLE_STATE_EVENT );
+ SetShapeFocus( bHaveFocus );
}
}
@@ -477,10 +528,7 @@ namespace accessibility
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
- if( mbHaveFocus && !IsActive() )
- return sal_True;
- else
- return sal_False;
+ return mbThisHasFocus;
}
sal_Bool AccessibleTextHelper_Impl::IsActive() const throw (uno::RuntimeException)
@@ -503,28 +551,49 @@ namespace accessibility
{
// notify all affected paragraphs (TODO: may be suboptimal,
// since some paragraphs might stay selected)
-
+#ifdef NOTIFY_SELECTIONS
UnSetChildrenState( maLastSelection.nStartPara,
- maLastSelection.nEndPara,
+ maLastSelection.nEndPara+1,
AccessibleStateType::SELECTED);
maParaManager.FireEvent( maLastSelection.nStartPara,
- maLastSelection.nEndPara,
+ maLastSelection.nEndPara+1,
AccessibleEventId::ACCESSIBLE_SELECTION_EVENT );
+#endif
- maParaManager.FireEvent( maLastSelection.nEndPara,
- maLastSelection.nEndPara+1,
- AccessibleEventId::ACCESSIBLE_CARET_EVENT );
+ // Did the caret move from one paragraph to another?
+ if( maLastSelection.nEndPara != rSelection.nEndPara )
+ {
+ maParaManager.FireEvent( maLastSelection.nEndPara,
+ maLastSelection.nEndPara+1,
+ AccessibleEventId::ACCESSIBLE_CARET_EVENT,
+ uno::makeAny(static_cast<sal_Int32>(-1)),
+ uno::makeAny(maLastSelection.nEndPos) );
+
+ UnSetChildrenState( maLastSelection.nEndPara,
+ maLastSelection.nEndPara+1,
+ AccessibleStateType::FOCUSED );
+ }
+#ifdef NOTIFY_SELECTIONS
SetChildrenState( rSelection.nStartPara,
- rSelection.nEndPara,
+ rSelection.nEndPara+1,
AccessibleStateType::SELECTED);
maParaManager.FireEvent( rSelection.nStartPara,
- rSelection.nEndPara,
+ rSelection.nEndPara+1,
AccessibleEventId::ACCESSIBLE_SELECTION_EVENT );
+#endif
maParaManager.FireEvent( rSelection.nEndPara,
rSelection.nEndPara+1,
- AccessibleEventId::ACCESSIBLE_CARET_EVENT );
+ AccessibleEventId::ACCESSIBLE_CARET_EVENT,
+ uno::makeAny(rSelection.nEndPos),
+ uno::makeAny(maLastSelection.nEndPos) );
+
+ DBG_ASSERT( !mbThisHasFocus && mbGroupHasFocus, "AccessibleTextHelper_Impl::UpdateSelection: editing, but no focus set" );
+
+ SetChildrenState( rSelection.nEndPara,
+ rSelection.nEndPara+1,
+ AccessibleStateType::FOCUSED );
maLastSelection = rSelection;
}
@@ -794,6 +863,8 @@ namespace accessibility
try
{
+ const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
+
// precondition: solar mutex locked
if( pEditSourceHint )
{
@@ -805,9 +876,7 @@ namespace accessibility
pEditSourceHint->GetEndValue() < GetTextForwarder().GetParagraphCount(),
"AccessibleTextHelper_Impl::NotifyHdl: Invalid notification");
- const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
-
- DBG_ASSERT( nParas == maParaManager.GetNum(), "AccessibleTextHelper_Impl::NotifyHdl: event PARASMOVED and paragraph number mismatch");
+ DBG_ASSERT( static_cast<sal_uInt32>(nParas) == maParaManager.GetNum(), "AccessibleTextHelper_Impl::NotifyHdl: event PARASMOVED and paragraph number mismatch");
sal_Int32 nFirst, nMiddle, nLast;
@@ -875,13 +944,13 @@ namespace accessibility
::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
::std::advance( begin, nFirst );
- ::std::advance( end, nLast );
+ ::std::advance( end, nLast+1 );
AccessibleTextHelper_LostChildEvent aFunctor( *this );
::std::for_each( begin, end, aFunctor );
- maParaManager.Release(nFirst, nLast);
+ maParaManager.Release(nFirst, nLast+1);
// should be no need for UpdateVisibleData, since all affected children are cleared.
}
#ifdef DBG_UTIL
@@ -916,18 +985,22 @@ namespace accessibility
switch( pTextHint->GetId() )
{
case TEXT_HINT_MODIFIED:
+ {
// notify listeners
- if( pTextHint->GetValue() == EE_PARA_ALL )
- maParaManager.FireEvent( 0, GetTextForwarder().GetParagraphCount()-1, AccessibleEventId::ACCESSIBLE_TEXT_EVENT );
- else
- maParaManager.FireEvent( pTextHint->GetValue(), AccessibleEventId::ACCESSIBLE_TEXT_EVENT );
+ sal_Int32 nPara( pTextHint->GetValue() );
+ if( nPara < nParas )
+ {
+ if( pTextHint->GetValue() == EE_PARA_ALL )
+ maParaManager.FireEvent( 0, GetTextForwarder().GetParagraphCount(), AccessibleEventId::ACCESSIBLE_TEXT_EVENT );
+ else
+ maParaManager.FireEvent( nPara, AccessibleEventId::ACCESSIBLE_TEXT_EVENT );
+ }
break;
+ }
case TEXT_HINT_PARAINSERTED:
{
// resize child vector to the current child count
- const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
-
maParaManager.SetNum( nParas );
sal_Int32 nFirst(pTextHint->GetValue()), nLast(nParas-1);
@@ -935,61 +1008,65 @@ namespace accessibility
if( pTextHint->GetValue() == EE_PARA_ALL )
nFirst = 0; // all paragraphs
- // since we have no "paragraph index
- // changed" event on UAA, remove
- // [first,last] and insert again later (in
- // UpdateVisibleChildren)
+ if( nFirst < nParas && nLast < nParas )
+ {
+ // since we have no "paragraph index
+ // changed" event on UAA, remove
+ // [first,last] and insert again later (in
+ // UpdateVisibleChildren)
- // move successors of inserted paragraph one position further
- //maParaManager.MoveRightFrom( pTextHint->GetValue() );
+ // move successors of inserted paragraph one position further
+ //maParaManager.MoveRightFrom( pTextHint->GetValue() );
- // release everything from the insertion position until the end
- maParaManager.Release(nFirst, nLast);
+ // release everything from the insertion position until the end
+ maParaManager.Release(nFirst, nLast+1);
- // send CHILD_EVENT to affected children
- ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
- ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
+ // send CHILD_EVENT to affected children
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
- ::std::advance( begin, nFirst );
- ::std::advance( end, nLast );
+ ::std::advance( begin, nFirst );
+ ::std::advance( end, nLast+1 );
- AccessibleTextHelper_LostChildEvent aFunctor( *this );
- ::std::for_each( begin, end, aFunctor );
+ AccessibleTextHelper_LostChildEvent aFunctor( *this );
+ ::std::for_each( begin, end, aFunctor );
+ }
break;
}
case TEXT_HINT_PARAREMOVED:
{
- const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
-
sal_Int32 nFirst(pTextHint->GetValue()), nLast(nParas-1);
if( pTextHint->GetValue() == EE_PARA_ALL )
nFirst = 0; // all paragraphs
- // since we have no "paragraph index
- // changed" event on UAA, remove
- // [first,last] and insert again later (in
- // UpdateVisibleChildren)
+ if( nFirst < nParas && nLast < nParas )
+ {
+ // since we have no "paragraph index
+ // changed" event on UAA, remove
+ // [first,last] and insert again later (in
+ // UpdateVisibleChildren)
- // move successors of removed paragraph one position closer
- // maParaManager.MoveLeftFrom( pTextHint->GetValue() );
+ // move successors of removed paragraph one position closer
+ // maParaManager.MoveLeftFrom( pTextHint->GetValue() );
- // release everything from the remove position until the end
- maParaManager.Release(nFirst, nLast);
+ // release everything from the remove position until the end
+ maParaManager.Release(nFirst, nLast+1);
- // send CHILD_EVENT to affected children
- ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
- ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
+ // send CHILD_EVENT to affected children
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
- ::std::advance( begin, nFirst );
- ::std::advance( end, nLast );
+ ::std::advance( begin, nFirst );
+ ::std::advance( end, nLast+1 );
- AccessibleTextHelper_LostChildEvent aFunctor( *this );
- ::std::for_each( begin, end, aFunctor );
+ AccessibleTextHelper_LostChildEvent aFunctor( *this );
+ ::std::for_each( begin, end, aFunctor );
- // resize child vector to the current child count
- maParaManager.SetNum( nParas );
+ // resize child vector to the current child count
+ maParaManager.SetNum( nParas );
+ }
break;
}
@@ -1021,6 +1098,9 @@ namespace accessibility
{
case HINT_BEGEDIT:
{
+ // per definition, edit mode text has the focus
+ SetFocus( sal_True );
+
// change children state
SetChildrenState( AccessibleStateType::ACTIVE );
SetChildrenState( AccessibleStateType::EDITABLE );
@@ -1033,6 +1113,11 @@ namespace accessibility
}
case HINT_ENDEDIT:
+ // focused child now looses focus
+ ESelection aSelection;
+ if( GetEditViewForwarder().GetSelection( aSelection ) )
+ SetChildFocus( aSelection.nEndPara, sal_False );
+
// change children state
UnSetChildrenState( AccessibleStateType::EDITABLE );
UnSetChildrenState( AccessibleStateType::ACTIVE );
@@ -1065,6 +1150,7 @@ namespace accessibility
#ifdef DBG_UTIL
DBG_ERROR("AccessibleTextHelper_Impl::Notify: Unhandled exception.");
#endif
+ mbInNotify = sal_False;
}
mbInNotify = sal_False;
@@ -1097,13 +1183,26 @@ namespace accessibility
{
try
{
- xListener->notifyEvent( aEvent );
+ xListener->notifyEvent (aEvent);
}
- catch( const uno::Exception& )
+ catch( const lang::DisposedException& e )
{
-#ifdef DBG_UTIL
- DBG_ERROR("AccessibleTextHelper_Impl::StateChangeEvent: Caught runtime exception from listener (bridge/listener dead?).");
-#endif
+ // DisposedExceptions from the listener might indicate a
+ // broken connection to a different environment.
+
+ OSL_ENSURE(e.Context.is(), "AccessibleTextHelper::FireEvent: caught dispose exception with empty Context field");
+ // If the exception stems from the listener then remove it
+ // from the list of listeners. If the Context field of the
+ // exception is empty this is interpreted to indicate the
+ // listener as well.
+ if (e.Context == xListener
+ || !e.Context.is())
+ aIter.remove();
+ }
+ catch( const uno::Exception& e )
+ {
+ DBG_WARNING1("AccessibleTextHelper::FireEvent: exception %s from listener",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_DONTKNOW ).getStr() );
}
}
}
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 68768875bce6..bf3ec38fc568 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoshtxt.cxx,v $
*
- * $Revision: 1.33 $
+ * $Revision: 1.34 $
*
- * last change: $Author: thb $ $Date: 2002-05-29 16:07:34 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:43:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -173,6 +173,7 @@ private:
BOOL mbNeedsUpdate;
BOOL mbOldUndoMode;
BOOL mbForwarderIsEditMode; // have to reflect that, since ENDEDIT can happen more often
+ BOOL mbNotificationsDisabled; // prevent EditEngine/Outliner notifications (e.g. when setting up forwarder)
SvxTextForwarder* GetBackgroundTextForwarder();
SvxTextForwarder* GetEditModeTextForwarder();
@@ -231,7 +232,8 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject )
mbIsLocked ( FALSE ),
mbNeedsUpdate ( FALSE ),
mbOldUndoMode ( FALSE ),
- mbForwarderIsEditMode ( FALSE )
+ mbForwarderIsEditMode ( FALSE ),
+ mbNotificationsDisabled ( FALSE )
{
DBG_ASSERT( mpObject, "invalid pObject!" );
@@ -255,7 +257,8 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrView& rView
mbIsLocked ( FALSE ),
mbNeedsUpdate ( FALSE ),
mbOldUndoMode ( FALSE ),
- mbForwarderIsEditMode ( FALSE )
+ mbForwarderIsEditMode ( FALSE ),
+ mbNotificationsDisabled ( FALSE )
{
if( mpModel )
StartListening( *mpModel );
@@ -356,26 +359,32 @@ void SvxTextEditSourceImpl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
case HINT_BEGEDIT:
- // invalidate old forwarder
- if( !mbForwarderIsEditMode )
+ if( mpObject == pSdrHint->GetObject() )
{
- delete mpTextForwarder;
- mpTextForwarder = NULL;
- }
+ // invalidate old forwarder
+ if( !mbForwarderIsEditMode )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
- // register as listener - need to broadcast state change messages
- if( mpView && mpView->GetTextEditOutliner() )
- mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
+ // register as listener - need to broadcast state change messages
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
- Broadcast( *pSdrHint );
+ Broadcast( *pSdrHint );
+ }
break;
case HINT_ENDEDIT:
- // remove as listener - outliner might outlive ourselves
- if( mpView && mpView->GetTextEditOutliner() )
- mpView->GetTextEditOutliner()->SetNotifyHdl( Link() );
+ if( mpObject == pSdrHint->GetObject() )
+ {
+ // remove as listener - outliner might outlive ourselves
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( Link() );
- Broadcast( *pSdrHint );
+ Broadcast( *pSdrHint );
+ }
break;
}
}
@@ -433,6 +442,9 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
{
sal_Bool bCreated = sal_False;
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = sal_True;
+
if (!mpTextForwarder)
{
if( mpOutliner == NULL )
@@ -555,6 +567,9 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
mpOutliner->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
}
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = sal_False;
+
return mpTextForwarder;
}
@@ -804,7 +819,7 @@ Point SvxTextEditSourceImpl::PixelToLogic( const Point& rPoint, const MapMode& r
IMPL_LINK(SvxTextEditSourceImpl, NotifyHdl, EENotify*, aNotify)
{
- if( aNotify )
+ if( aNotify && !mbNotificationsDisabled )
{
::std::auto_ptr< SfxHint > aHint( SvxEditSourceHintTranslator::EENotification2Hint( aNotify) );
diff --git a/svx/source/unoedit/unoedprx.cxx b/svx/source/unoedit/unoedprx.cxx
index 592dfaf96792..4031f7edcfcd 100644
--- a/svx/source/unoedit/unoedprx.cxx
+++ b/svx/source/unoedit/unoedprx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoedprx.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: thb $ $Date: 2002-05-29 15:49:18 $
+ * last change: $Author: thb $ $Date: 2002-06-04 18:44:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1094,7 +1094,7 @@ USHORT SvxAccessibleTextAdapter::GetLineLen( USHORT nPara, USHORT nLine ) const
SvxAccessibleTextIndex aStartIndex;
SvxAccessibleTextIndex aEndIndex;
USHORT nCurrLine;
- sal_Int32 nCurrIndex, nLastIndex;
+ USHORT nCurrIndex, nLastIndex;
for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine )
{
nLastIndex = nCurrIndex;