summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2002-05-24 06:48:49 +0000
committerThomas Lange <tl@openoffice.org>2002-05-24 06:48:49 +0000
commit815d673408b8f0f67cb463d5b5ddaf3126c9f0f3 (patch)
tree02665006e11c50c9d515a489c4565f0feccb08e9
parent8960f57cdd3f8d404ba123d4b546bfcadf98429a (diff)
#98669# accessibility in Math
-rw-r--r--starmath/inc/document.hxx6
-rw-r--r--starmath/inc/node.hxx12
-rw-r--r--starmath/source/accessibility.cxx132
-rw-r--r--starmath/source/accessibility.hxx13
-rw-r--r--starmath/source/document.cxx14
-rw-r--r--starmath/source/edit.cxx9
-rw-r--r--starmath/source/node.cxx38
7 files changed, 171 insertions, 53 deletions
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index d1e7b6898f58..adafb15576d9 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: document.hxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: tl $ $Date: 2002-01-04 13:29:11 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:47:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -258,6 +258,8 @@ public:
const SmNode * GetFormulaTree() const { return pTree; }
void SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
+ String GetAccessibleText();
+
EditEngine & GetEditEngine();
SfxItemPool & GetEditEngineItemPool();
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 9195f1621c63..f646aaf10182 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: node.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: cmc $ $Date: 2001-12-06 14:22:20 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:47:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -188,6 +188,8 @@ public:
virtual void Draw(OutputDevice &rDev, const Point &rPosition) const;
+ virtual String GetAccessibleText() const;
+
USHORT GetRow() const { return (USHORT)aNodeToken.nRow; }
USHORT GetColumn() const { return (USHORT)aNodeToken.nCol; }
@@ -235,6 +237,8 @@ public:
void SetSubNodes(const SmNodeArray &rNodeArray);
virtual SmStructureNode & operator = ( const SmStructureNode &rNode );
+
+ virtual String GetAccessibleText() const;
};
@@ -267,6 +271,8 @@ protected:
{}
public:
+
+ virtual String GetAccessibleText() const;
};
@@ -404,6 +410,8 @@ public:
virtual void CreateTextFromNode(String &rText);
virtual void Draw(OutputDevice &rDev, const Point &rPosition) const;
+
+ virtual String GetAccessibleText() const;
};
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index df32ff94b7fb..dacba52a159a 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessibility.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: vg $ $Date: 2002-05-23 13:00:49 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:48:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,9 @@
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETEXTTYPE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleTextType.hpp>
+#endif
#ifndef _COM_SUN_STAR_AWT_FOCUSEVENT_HPP_
#include <com/sun/star/awt/FocusEvent.hpp>
#endif
@@ -72,6 +75,12 @@
#include <com/sun/star/awt/XFocusListener.hpp>
#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XFLUSHABLECLIPBOARD_HPP_
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#endif
#ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
#include <unotools/accessiblestatesethelper.hxx>
@@ -88,9 +97,9 @@
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
#endif
-/*#ifndef _SVX_UNOEDACC_HXX_
-#include <svx/inc/unoedacc.hxx>
-#endif*/
+#ifndef _SVX_UNOEDACC_HXX_
+#include <svx/unoedacc.hxx>
+#endif
#ifndef _ACCESSIBILITY_HXX_
#include "accessibility.hxx"
@@ -115,7 +124,7 @@ using namespace drafts::com::sun::star::accessibility;
//////////////////////////////////////////////////////////////////////
SmAccessibility::SmAccessibility( SmGraphicWindow *pGraphicWin ) :
- pWin (pGraphicWin),
+ pWin (pGraphicWin),
aFocusListeners (aListenerMutex),
aAccEventListeners (aListenerMutex)
{
@@ -152,6 +161,15 @@ SmDocShell * SmAccessibility::GetDoc_Impl()
return pView ? pView->GetDoc() : 0;
}
+String SmAccessibility::GetAccessibleText_Impl()
+{
+ String aTxt;
+ SmDocShell *pDoc = GetDoc_Impl();
+ if (pDoc)
+ aTxt = pDoc->GetAccessibleText();
+ return aTxt;
+}
+
void SmAccessibility::ClearWin()
{
pWin = 0; // implicitly results in AccessibleStateType::DEFUNC set
@@ -439,18 +457,40 @@ Locale SAL_CALL SmAccessibility::getLocale()
}
+void SAL_CALL SmAccessibility::addEventListener(
+ const Reference< XAccessibleEventListener >& xListener )
+ throw (RuntimeException)
+{
+ //vos::OGuard aGuard(Application::GetSolarMutex());
+ if (pWin) // not disposing (about to destroy view shell)
+ aAccEventListeners.addInterface( xListener );
+}
+
+void SAL_CALL SmAccessibility::removeEventListener(
+ const Reference< XAccessibleEventListener >& xListener )
+ throw (RuntimeException)
+{
+ //vos::OGuard aGuard(Application::GetSolarMutex());
+ aAccEventListeners.removeInterface( xListener );
+}
+
sal_Int32 SAL_CALL SmAccessibility::getCaretPosition()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return 0;
+ return -1;
}
sal_Unicode SAL_CALL SmAccessibility::getCharacter( sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return '\0';
+
+ xub_StrLen nIdx = (xub_StrLen) nIndex;
+ String aTxt( GetAccessibleText_Impl() );
+ if (!(0 <= nIdx && nIdx < aTxt.Len()))
+ throw IndexOutOfBoundsException();
+ return aTxt.GetChar( nIdx );
}
Sequence< beans::PropertyValue > SAL_CALL SmAccessibility::getCharacterAttributes(
@@ -472,14 +512,14 @@ sal_Int32 SAL_CALL SmAccessibility::getCharacterCount()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return 0;
+ return GetAccessibleText_Impl().Len();
}
sal_Int32 SAL_CALL SmAccessibility::getIndexAtPoint( const awt::Point& aPoint )
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return 0;
+ return -1;
}
OUString SAL_CALL SmAccessibility::getSelectedText()
@@ -493,14 +533,14 @@ sal_Int32 SAL_CALL SmAccessibility::getSelectionStart()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return 0;
+ return -1;
}
sal_Int32 SAL_CALL SmAccessibility::getSelectionEnd()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return 0;
+ return -1;
}
sal_Bool SAL_CALL SmAccessibility::setSelection(
@@ -516,7 +556,7 @@ OUString SAL_CALL SmAccessibility::getText()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return OUString();
+ return GetAccessibleText_Impl();
}
OUString SAL_CALL SmAccessibility::getTextRange(
@@ -525,7 +565,15 @@ OUString SAL_CALL SmAccessibility::getTextRange(
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return OUString();
+ String aTxt( GetAccessibleText_Impl() );
+ xub_StrLen nStart = (xub_StrLen) nStartIndex;
+ xub_StrLen nEnd = (xub_StrLen) nEndIndex;
+ if (!(0 <= nStart && nStart < aTxt.Len()) ||
+ !(0 <= nEnd && nEnd < aTxt.Len()))
+ throw IndexOutOfBoundsException();
+ if (nStartIndex > nEndIndex)
+ return OUString();
+ return aTxt.Copy( nStart, nEnd );
}
OUString SAL_CALL SmAccessibility::getTextAtIndex(
@@ -534,7 +582,10 @@ OUString SAL_CALL SmAccessibility::getTextAtIndex(
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return OUString();
+ if (AccessibleTextType::CHARACTER != aTextType)
+ return OUString();
+ String aTxt( GetAccessibleText_Impl() );
+ return aTxt.Copy(nIndex, 1);
}
OUString SAL_CALL SmAccessibility::getTextBeforeIndex(
@@ -543,7 +594,10 @@ OUString SAL_CALL SmAccessibility::getTextBeforeIndex(
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return OUString();
+ if (AccessibleTextType::CHARACTER != aTextType)
+ return OUString();
+ String aTxt( GetAccessibleText_Impl() );
+ return aTxt.Copy(0, nIndex);
}
OUString SAL_CALL SmAccessibility::getTextBehindIndex(
@@ -552,7 +606,10 @@ OUString SAL_CALL SmAccessibility::getTextBehindIndex(
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return OUString();
+ if (AccessibleTextType::CHARACTER != aTextType)
+ return OUString();
+ String aTxt( GetAccessibleText_Impl() );
+ return aTxt.Copy(nIndex, aTxt.Len()-1);
}
sal_Bool SAL_CALL SmAccessibility::copyText(
@@ -561,24 +618,33 @@ sal_Bool SAL_CALL SmAccessibility::copyText(
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return FALSE;
-}
+ String aTxt( GetAccessibleText_Impl() );
+ String aCopy( aTxt.Copy(nStartIndex, nEndIndex - nStartIndex + 1) );
+ sal_Bool bReturn = sal_False;
+/*
+ if ( pWin )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = pWin->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
-void SAL_CALL SmAccessibility::addEventListener(
- const Reference< XAccessibleEventListener >& xListener )
- throw (RuntimeException)
-{
- //vos::OGuard aGuard(Application::GetSolarMutex());
- if (pWin) // not disposing (about to destroy view shell)
- aAccEventListeners.addInterface( xListener );
-}
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
-void SAL_CALL SmAccessibility::removeEventListener(
- const Reference< XAccessibleEventListener >& xListener )
- throw (RuntimeException)
-{
- //vos::OGuard aGuard(Application::GetSolarMutex());
- aAccEventListeners.removeInterface( xListener );
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+*/
+ return bReturn;
}
+
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index 88e4fb290640..f78381febb18 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessibility.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: vg $ $Date: 2002-05-23 14:17:48 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:48:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -129,6 +129,7 @@ class SmAccessibility :
protected:
SmDocShell * GetDoc_Impl();
+ String GetAccessibleText_Impl();
public:
SmAccessibility( SmGraphicWindow *pGraphicWin );
@@ -171,6 +172,10 @@ public:
virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::drafts::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
+ // XAccessibleEventBroadcaster
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
// XAccessibleText
virtual sal_Int32 SAL_CALL getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
@@ -188,10 +193,6 @@ public:
virtual ::rtl::OUString SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
-
- // XAccessibleEventBroadcaster
- virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
};
#endif
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 2005fbefce09..254bdad68db1 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: document.cxx,v $
*
- * $Revision: 1.51 $
+ * $Revision: 1.52 $
*
- * last change: $Author: tl $ $Date: 2002-03-21 10:13:38 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:48:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -369,6 +369,16 @@ void SmDocShell::SetFormat(SmFormat& rFormat)
SetModified(TRUE);
}
+String SmDocShell::GetAccessibleText()
+{
+ String aAccTxt;
+ if (!pTree)
+ Parse();
+ DBG_ASSERT( pTree, "Tree missing" );
+ if (pTree)
+ aAccTxt = pTree->GetAccessibleText();
+ return aAccTxt;
+}
void SmDocShell::Parse()
{
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 1c69c8fbd899..a385a8f15b06 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: edit.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: tl $ $Date: 2002-05-15 13:47:26 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:48:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -371,10 +371,7 @@ void SmEditWindow::Command(const CommandEvent& rCEvt)
PopupMenu* pPopupMenu = new PopupMenu(SmResId(RID_COMMANDMENU));
pPopupMenu->SetSelectHdl(LINK(this, SmEditWindow, MenuSelectHdl));
- Point aPos(5, 5);
- if (rCEvt.IsMouseEvent())
- aPos = rCEvt.GetMousePosPixel();
- pPopupMenu->Execute( this, aPos );
+ pPopupMenu->Execute( this, rCEvt.GetMousePosPixel() );
delete pPopupMenu;
}
else if (pEditView)
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 57c54cfd0c97..fb2cc1df5377 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: node.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: tl $ $Date: 2002-04-18 11:50:14 $
+ * last change: $Author: tl $ $Date: 2002-05-24 07:48:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -604,6 +604,12 @@ const SmNode * SmNode::FindRectClosestTo(const Point &rPoint) const
return pResult;
}
+String SmNode::GetAccessibleText() const
+{
+ DBG_ERROR( "SmNode: GetAccessibleText not overloaded" );
+ return String();
+}
+
///////////////////////////////////////////////////////////////////////////
@@ -691,6 +697,23 @@ SmNode * SmStructureNode::GetSubNode(USHORT nIndex)
}
+String SmStructureNode::GetAccessibleText() const
+{
+ String aTxt;
+ USHORT nNodes = GetNumSubNodes();
+ for (USHORT i = 0; i < nNodes; ++i)
+ {
+ const SmNode *pNode = ((SmStructureNode *) this)->GetSubNode(i);
+ if (pNode)
+ {
+ aTxt += pNode->GetAccessibleText();
+ if (aTxt.Len() && ' ' != aTxt.GetChar( aTxt.Len() - 1 ))
+ aTxt += String::CreateFromAscii( " " );
+ }
+ }
+ return aTxt;
+}
+
///////////////////////////////////////////////////////////////////////////
@@ -714,6 +737,13 @@ SmNode * SmVisibleNode::GetSubNode(USHORT nIndex)
///////////////////////////////////////////////////////////////////////////
+String SmGraphicNode::GetAccessibleText() const
+{
+ return String::CreateFromAscii( " " );
+}
+
+///////////////////////////////////////////////////////////////////////////
+
void SmExpressionNode::CreateTextFromNode(String &rText)
{
@@ -2557,6 +2587,10 @@ void SmTextNode::Draw(OutputDevice &rDev, const Point& rPosition) const
#endif
}
+String SmTextNode::GetAccessibleText() const
+{
+ return aText;
+}
/**************************************************************************/