summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2002-08-15 08:29:12 +0000
committerDaniel Rentz <dr@openoffice.org>2002-08-15 08:29:12 +0000
commit73b2cd61f9ee66918e76393425c5f075f4d3c679 (patch)
treeda5c2eac270dfa389d9efaa36a58e80b92e12c16
parentc5a1dc53955eecee3cef582c55a87dc429997d7d (diff)
#101677# accessibility for CSV import
-rw-r--r--sc/source/ui/Accessibility/AccessibleCsvControl.cxx1744
-rw-r--r--sc/source/ui/Accessibility/makefile.mk99
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx14
-rw-r--r--sc/source/ui/dbgui/csvcontrol.cxx83
-rw-r--r--sc/source/ui/dbgui/csvgrid.cxx660
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx253
-rw-r--r--sc/source/ui/dbgui/csvtablebox.cxx135
-rw-r--r--sc/source/ui/inc/AccessibleCsvControl.hxx769
-rw-r--r--sc/source/ui/inc/asciiopt.hxx6
-rw-r--r--sc/source/ui/inc/csvcontrol.hxx87
-rw-r--r--sc/source/ui/inc/csvgrid.hxx178
-rw-r--r--sc/source/ui/inc/csvruler.hxx81
-rw-r--r--sc/source/ui/inc/csvtablebox.hxx95
13 files changed, 3469 insertions, 735 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
new file mode 100644
index 000000000000..a803a85ab7bc
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
@@ -0,0 +1,1744 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleCsvControl.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dr $ $Date: 2002-08-15 09:27:02 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#include "AccessibleCsvControl.hxx"
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLERELATIONTYPE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleRelationType.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETEXTTYPE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleTextType.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETABLEMODELCHANGE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETABLEMODELCHANGETYPE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#endif
+#ifndef _TOOLKIT_HELPER_CONVERT_HXX_
+#include <toolkit/helper/convert.hxx>
+#endif
+#ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
+#include <unotools/accessiblerelationsethelper.hxx>
+#endif
+#ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX
+#include <unotools/accessiblestatesethelper.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+#ifndef _SC_CSVCONTROL_HXX
+#include "csvcontrol.hxx"
+#endif
+#ifndef _SC_CSVRULER_HXX
+#include "csvruler.hxx"
+#endif
+#ifndef _SC_CSVGRID_HXX
+#include "csvgrid.hxx"
+#endif
+
+#ifndef SC_UNOGUARD_HXX
+#include "unoguard.hxx"
+#endif
+
+#ifndef SC_SCRESID_HXX
+#include "scresid.hxx"
+#endif
+#include "sc.hrc"
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::utl::AccessibleRelationSetHelper;
+using ::utl::AccessibleStateSetHelper;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::lang::DisposedException;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::beans::PropertyValue;
+using namespace ::drafts::com::sun::star::accessibility;
+
+
+// ----------------------------------------------------------------------------
+
+const sal_uInt16 nRulerRole = AccessibleRole::TEXT;
+const sal_uInt16 nGridRole = AccessibleRole::TABLE;
+const sal_uInt16 nCellRole = AccessibleRole::TEXT;
+
+const sal_Unicode cRulerDot = '.';
+const sal_Unicode cRulerLine = '|';
+
+
+// forwarders =================================================================
+#if 0
+/** Used for cell text handling. */
+class ScCsvCellViewForwarder : public SvxViewForwarder
+{
+private:
+ ScCsvGrid* mpGrid;
+
+public:
+ ScCsvViewForwarder( ScCsvGrid* pGrid );
+ virtual ~ScCsvViewForwarder();
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+};
+#endif
+
+// CSV base control ===========================================================
+
+DBG_NAME( ScAccessibleCsvControl )
+
+ScAccessibleCsvControl::ScAccessibleCsvControl(
+ const Reference< XAccessible >& rxParent,
+ ScCsvControl& rControl,
+ sal_uInt16 nRole ) :
+ ScAccessibleContextBase( rxParent, nRole ),
+ mpControl( &rControl )
+{
+ DBG_CTOR( ScAccessibleCsvControl, NULL );
+}
+
+ScAccessibleCsvControl::~ScAccessibleCsvControl()
+{
+ DBG_DTOR( ScAccessibleCsvControl, NULL );
+ implDispose();
+}
+
+void SAL_CALL ScAccessibleCsvControl::disposing()
+{
+ mpControl = NULL;
+ ScAccessibleContextBase::disposing();
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvControl::getAccessibleAt( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvControl::isVisible() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetControl().IsVisible();
+}
+
+void SAL_CALL ScAccessibleCsvControl::grabFocus() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ implGetControl().GrabFocus();
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvControl::SendFocusEvent( bool bFocused )
+{
+ if( bFocused )
+ CommitFocusGained();
+ else
+ CommitFocusLost();
+}
+
+void ScAccessibleCsvControl::SendCaretEvent()
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendCaretEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendSelectionEvent()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_SELECTION_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ CommitChange( aEvent );
+}
+
+void ScAccessibleCsvControl::SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendTableUpdateEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendInsertColumnEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendRemoveColumnEvent - Illegal call" );
+}
+
+
+// helpers --------------------------------------------------------------------
+
+Rectangle ScAccessibleCsvControl::GetBoundingBoxOnScreen() const throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetControl().GetWindowExtentsRelative( NULL );
+}
+
+Rectangle ScAccessibleCsvControl::GetBoundingBox() const throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetControl().GetWindowExtentsRelative( implGetControl().GetAccessibleParentWindow() );
+}
+
+void ScAccessibleCsvControl::getUuid( Sequence< sal_Int8 >& rSeq )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ if( !rSeq.hasElements() )
+ {
+ rSeq.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( rSeq.getArray() ), NULL, sal_True );
+ }
+}
+
+void ScAccessibleCsvControl::ensureAlive() const throw( DisposedException )
+{
+ if( !implIsAlive() )
+ throw DisposedException();
+}
+
+ScCsvControl& ScAccessibleCsvControl::implGetControl() const
+{
+ DBG_ASSERT( mpControl, "ScAccessibleCsvControl::implGetControl - missing control" );
+ return *mpControl;
+}
+
+Reference< XAccessible > ScAccessibleCsvControl::implGetChildByRole(
+ const Reference< XAccessible >& rxParentObj, sal_uInt16 nRole ) throw( RuntimeException )
+{
+ Reference< XAccessible > xAccObj;
+ if( rxParentObj.is() )
+ {
+ Reference< XAccessibleContext > xParentCtxt = rxParentObj->getAccessibleContext();
+ if( xParentCtxt.is() )
+ {
+ sal_Int32 nCount = xParentCtxt->getAccessibleChildCount();
+ sal_Int32 nIndex = 0;
+ while( !xAccObj.is() && (nIndex < nCount) )
+ {
+ Reference< XAccessible > xCurrObj = xParentCtxt->getAccessibleChild( nIndex );
+ if( xCurrObj.is() )
+ {
+ Reference< XAccessibleContext > xCurrCtxt = xCurrObj->getAccessibleContext();
+ if( xCurrCtxt.is() && (xCurrCtxt->getAccessibleRole() == nRole) )
+ xAccObj = xCurrObj;
+ }
+ }
+ }
+ }
+ return xAccObj;
+}
+
+AccessibleStateSetHelper* ScAccessibleCsvControl::implCreateStateSet()
+{
+ ScUnoGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = new AccessibleStateSetHelper();
+ if( implIsAlive() )
+ {
+ const ScCsvControl& rCtrl = implGetControl();
+ pStateSet->AddState( AccessibleStateType::OPAQUE );
+ if( rCtrl.IsEnabled() )
+ pStateSet->AddState( AccessibleStateType::ENABLED );
+ if( isShowing() )
+ pStateSet->AddState( AccessibleStateType::SHOWING );
+ if( isVisible() )
+ pStateSet->AddState( AccessibleStateType::VISIBLE );
+ }
+ else
+ pStateSet->AddState( AccessibleStateType::DEFUNC );
+ return pStateSet;
+}
+
+void ScAccessibleCsvControl::implDispose()
+{
+ if( implIsAlive() )
+ {
+ // prevent multiple call of dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+Point ScAccessibleCsvControl::implGetRelPos( const Point& rPos ) const
+{
+ return rPos - implGetControl().GetWindowExtentsRelative( NULL ).TopLeft();
+}
+
+Point ScAccessibleCsvControl::implGetAbsPos( const Point& rPos ) const
+{
+ return rPos + implGetControl().GetWindowExtentsRelative( NULL ).TopLeft();
+}
+
+
+// Ruler ======================================================================
+
+/** Converts a ruler cursor position to API text index. */
+sal_Int32 lcl_GetApiPos( sal_Int32 nRulerPos )
+{
+ sal_Int32 nApiPos = nRulerPos;
+ sal_Int32 nStart = (nRulerPos - 1) / 10;
+ sal_Int32 nExp = 1;
+ while( nStart >= nExp )
+ {
+ nApiPos += nStart - nExp + 1;
+ nExp *= 10;
+ }
+ return ::std::max( nApiPos, 0L );
+}
+
+/** Converts an API text index to a ruler cursor position. */
+sal_Int32 lcl_GetRulerPos( sal_Int32 nApiPos )
+{
+ sal_Int32 nDiv = 10;
+ sal_Int32 nExp = 10;
+ sal_Int32 nRulerPos = 0;
+ sal_Int32 nApiBase = 0;
+ sal_Int32 nApiLimit = 10;
+ while( nApiPos >= nApiLimit )
+ {
+ ++nDiv;
+ nRulerPos = nExp;
+ nExp *= 10;
+ nApiBase = nApiLimit;
+ nApiLimit = lcl_GetApiPos( nExp );
+ }
+ sal_Int32 nRelPos = nApiPos - nApiBase;
+ return nRulerPos + nRelPos / nDiv * 10 + ::std::max( nRelPos % nDiv - nDiv + 10L, 0L );
+}
+
+
+// ----------------------------------------------------------------------------
+
+DBG_NAME( ScAccessibleCsvRuler )
+
+ScAccessibleCsvRuler::ScAccessibleCsvRuler( ScCsvRuler& rRuler ) :
+ ScAccessibleCsvControl( rRuler.GetAccessibleParentWindow()->GetAccessible(), rRuler, nRulerRole )
+{
+ DBG_CTOR( ScAccessibleCsvRuler, NULL );
+ constructStringBuffer();
+}
+
+ScAccessibleCsvRuler::~ScAccessibleCsvRuler()
+{
+ DBG_DTOR( ScAccessibleCsvRuler, NULL );
+ implDispose();
+}
+
+
+// XAccessibleContext ---------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getAccessibleChildCount() throw( RuntimeException )
+{
+ ensureAlive();
+ return 0;
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvRuler::getAccessibleChild( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ throw IndexOutOfBoundsException();
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
+ Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nGridRole );
+ if( xAccObj.is() )
+ {
+ Sequence< Reference< XInterface > > aSeq( 1 );
+ aSeq[ 0 ] = xAccObj;
+ pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLER_FOR, aSeq ) );
+ }
+ return pRelationSet;
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
+ if( implGetRuler().HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ }
+ return pStateSet;
+}
+
+
+// XAccessibleText ------------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCaretPosition() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return lcl_GetApiPos( implGetRuler().GetRulerCursorPos() );
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::setCaretPosition( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ ScCsvRuler& rRuler = implGetRuler();
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+ rRuler.Execute( CSVCMD_MOVERULERCURSOR, nRulerPos );
+ return rRuler.GetRulerCursorPos() == nRulerPos;
+}
+
+sal_Unicode SAL_CALL ScAccessibleCsvRuler::getCharacter( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return maBuffer.charAt( nIndex );
+}
+
+Sequence< PropertyValue > SAL_CALL ScAccessibleCsvRuler::getCharacterAttributes( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ Sequence< PropertyValue > aSeq; //! TODO
+//! TODO split attribute: waiting for #102221#
+// if( implHasSplit( nIndex ) )
+// {
+// sal_Int32 nLen = aSeq.getLength();
+// aSeq.realloc( nLen + 1 );
+// aSeq[ nLen ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
+// aSeq[ nLen ].Value <<= ...;
+// }
+ return aSeq;
+}
+
+ScAccessibleCsvRuler::AwtRectangle SAL_CALL ScAccessibleCsvRuler::getCharacterBounds( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ ScCsvRuler& rRuler = implGetRuler();
+ Point aPos( rRuler.GetX( lcl_GetRulerPos( nIndex ) ) - rRuler.GetCharWidth() / 2, 0 );
+ return AwtRectangle( aPos.X(), aPos.Y(), rRuler.GetCharWidth(), rRuler.GetSizePixel().Height() );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCharacterCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetTextLength();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getIndexAtPoint( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ScCsvRuler& rRuler = implGetRuler();
+ Point aPos( implGetRelPos( VCLPoint( rPoint ) ) );
+ return ::std::min( ::std::max( rRuler.GetPosFromX( aPos.X() ), 0L ), rRuler.GetPosCount() );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getSelectedText() throw( RuntimeException )
+{
+ ensureAlive();
+ return OUString();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionStart() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionEnd() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getText() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return OUString( maBuffer.getStr(), implGetTextLength() );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidRange( nStartIndex, nEndIndex );
+ return OUString( maBuffer.getStr() + nStartIndex, nEndIndex - nStartIndex );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+
+ OUStringBuffer aText;
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ aText.append( maBuffer.charAt( nIndex ) );
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ if( nRulerPos % 10 )
+ aText.append( maBuffer.charAt( nIndex ) );
+ else
+ aText.append( nRulerPos );
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ aText.append( maBuffer.getStr(), implGetTextLength() );
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
+ sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
+ aText.append( maBuffer.getStr() + nFirstIndex, nLastIndex - nFirstIndex + 1 );
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+ return aText.makeStringAndClear();
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+
+ OUString aText;
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ if( nIndex > 0 )
+ aText = getTextAtIndex( nIndex - 1, nTextType );
+ // else empty string
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ if( nRulerPos > 0 )
+ aText = getTextAtIndex( lcl_GetApiPos( nRulerPos - 1 ), nTextType );
+ // else empty string
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ // empty string
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
+ if( nFirstIndex > 0 )
+ aText = getTextAtIndex( nFirstIndex - 1, nTextType );
+ // else empty string
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+ return aText;
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+
+ OUString aText;
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+ sal_Int32 nLastValid = implGetTextLength() - 1;
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ if( nIndex < nLastValid )
+ aText = getTextAtIndex( nIndex + 1, nTextType );
+ // else empty string
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ if( nRulerPos < implGetRuler().GetPosCount() )
+ aText = getTextAtIndex( lcl_GetApiPos( nRulerPos + 1 ), nTextType );
+ // else empty string
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ // empty string
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
+ if( nLastIndex < nLastValid )
+ aText = getTextAtIndex( nLastIndex + 1, nTextType );
+ // else empty string
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+ return aText;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+
+// XInterface -----------------------------------------------------------------
+
+Any SAL_CALL ScAccessibleCsvRuler::queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( RuntimeException )
+{
+ Any aAny( ScAccessibleCsvRulerImpl::queryInterface( rType ) );
+ return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
+}
+
+void SAL_CALL ScAccessibleCsvRuler::acquire() throw ()
+{
+ ScAccessibleCsvControl::acquire();
+}
+
+void SAL_CALL ScAccessibleCsvRuler::release() throw ()
+{
+ ScAccessibleCsvControl::release();
+}
+
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvRuler::getImplementationName() throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "ScAccessibleCsvRuler" ) );
+}
+
+
+// XTypeProvider --------------------------------------------------------------
+
+Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvRuler::getTypes() throw( RuntimeException )
+{
+ Sequence< ::com::sun::star::uno::Type > aSeq( 1 );
+ aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleText >* >( NULL ) );
+ return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
+}
+
+Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvRuler::getImplementationId() throw( RuntimeException )
+{
+ static Sequence< sal_Int8 > aSeq;
+ getUuid( aSeq );
+ return aSeq;
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvRuler::SendCaretEvent()
+{
+ sal_Int32 nPos = implGetRuler().GetRulerCursorPos();
+ if( nPos != POS_INVALID )
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_CARET_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= nPos;
+ CommitChange( aEvent );
+ }
+}
+
+
+// helpers --------------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleName() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVRULER_NAME ) );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleDescription() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVRULER_DESCR ) );
+}
+
+void ScAccessibleCsvRuler::ensureValidIndex( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( nIndex >= implGetTextLength() )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvRuler::ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( rnStartIndex > rnEndIndex )
+ ::std::swap( rnStartIndex, rnEndIndex );
+ if( (rnStartIndex < 0) || (rnEndIndex > implGetTextLength()) )
+ throw IndexOutOfBoundsException();
+}
+
+ScCsvRuler& ScAccessibleCsvRuler::implGetRuler() const
+{
+ return static_cast< ScCsvRuler& >( implGetControl() );
+}
+
+void ScAccessibleCsvRuler::constructStringBuffer() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ // extend existing string buffer to new ruler size
+ sal_Int32 nRulerCount = implGetRuler().GetPosCount();
+ sal_Int32 nRulerPos = lcl_GetRulerPos( maBuffer.getLength() );
+ for( ; nRulerPos <= nRulerCount; ++nRulerPos ) // include last position
+ {
+ switch( nRulerPos % 10 )
+ {
+ case 0: maBuffer.append( nRulerPos ); break;
+ case 5: maBuffer.append( cRulerLine ); break;
+ default: maBuffer.append( cRulerDot );
+ }
+ }
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetTextLength() const
+{
+ return lcl_GetApiPos( implGetRuler().GetPosCount() + 1 );
+}
+
+bool ScAccessibleCsvRuler::implHasSplit( sal_Int32 nApiPos )
+{
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nApiPos );
+ return implGetRuler().HasSplit( nRulerPos ) && (nApiPos == lcl_GetApiPos( nRulerPos ));
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetFirstEqualFormatted( sal_Int32 nApiPos )
+{
+ bool bSplit = implHasSplit( nApiPos );
+ while( (nApiPos > 0) && (implHasSplit( nApiPos - 1 ) == bSplit) )
+ --nApiPos;
+ return nApiPos;
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetLastEqualFormatted( sal_Int32 nApiPos )
+{
+ bool bSplit = implHasSplit( nApiPos );
+ sal_Int32 nLength = implGetTextLength();
+ while( (nApiPos < nLength - 1) && (implHasSplit( nApiPos + 1 ) == bSplit) )
+ ++nApiPos;
+ return nApiPos;
+}
+
+
+// Grid =======================================================================
+
+/** Converts a grid columnm index to an API column index. */
+inline sal_Int32 lcl_GetApiColumn( sal_uInt32 nGridColumn )
+{
+ return (nGridColumn != VEC_NOTFOUND) ? static_cast< sal_Int32 >( nGridColumn + 1 ) : 0;
+}
+
+/** Converts an API columnm index to a ScCsvGrid column index. */
+inline sal_uInt32 lcl_GetGridColumn( sal_Int32 nApiColumn )
+{
+ return (nApiColumn > 0) ? static_cast< sal_uInt32 >( nApiColumn - 1 ) : VEC_NOTFOUND;
+}
+
+
+// ----------------------------------------------------------------------------
+
+DBG_NAME( ScAccessibleCsvGrid )
+
+ScAccessibleCsvGrid::ScAccessibleCsvGrid( ScCsvGrid& rGrid ) :
+ ScAccessibleCsvControl( rGrid.GetAccessibleParentWindow()->GetAccessible(), rGrid, nGridRole )
+{
+ DBG_CTOR( ScAccessibleCsvGrid, NULL );
+}
+
+ScAccessibleCsvGrid::~ScAccessibleCsvGrid()
+{
+ DBG_DTOR( ScAccessibleCsvGrid, NULL );
+ implDispose();
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAt( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+
+ const ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nColumn = (rPoint.X > rGrid.GetOffsetX()) ? lcl_GetApiColumn( rGrid.GetColumnFromX( rPoint.X ) ) : 0;
+ sal_Int32 nRow = (rPoint.Y > rGrid.GetOffsetY()) ? (rGrid.GetLineFromY( rPoint.Y ) - rGrid.GetFirstVisLine() + 1) : 0;
+ return implCreateCellObj( nRow, nColumn );
+}
+
+
+// XAccessibleContext ---------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleChildCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetCellCount();
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleChild( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return implCreateCellObj( implGetRow( nIndex ), implGetColumn( nIndex ) );
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
+ Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nRulerRole );
+ if( xAccObj.is() )
+ {
+ Sequence< Reference< XInterface > > aSeq( 1 );
+ aSeq[ 0 ] = xAccObj;
+ pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLED_BY, aSeq ) );
+ }
+ return pRelationSet;
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ pStateSet->AddState( AccessibleStateType::MULTISELECTABLE );
+ pStateSet->AddState( AccessibleStateType::CHILDREN_TRANSIENT );
+ if( implGetGrid().HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ }
+ else
+ pStateSet->AddState( AccessibleStateType::DEFUNC );
+ return pStateSet;
+}
+
+
+// XAccessibleTable -----------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetRowCount();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetColumnCount();
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleRowDescription( sal_Int32 nRow )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( nRow, 0 );
+ return implGetCellText( nRow, 0 );
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( 0, nColumn );
+ return implGetCellText( 0, nColumn );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return 1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return 1;
+}
+
+Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleRowHeaders()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnHeaders()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleRows()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return Sequence< sal_Int32 >();
+}
+
+Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleColumns()
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+
+ ScCsvGrid& rGrid = implGetGrid();
+ Sequence< sal_Int32 > aSeq( implGetColumnCount() );
+
+ sal_Int32 nSeqIx = 0;
+ sal_uInt32 nColIx = rGrid.GetFirstSelected();
+ for( ; nColIx != VEC_NOTFOUND; ++nSeqIx, nColIx = rGrid.GetNextSelected( nColIx ) )
+ aSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx );
+
+ aSeq.realloc( nSeqIx );
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleRowSelected( sal_Int32 nRow )
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nColumn );
+ return implIsColumnSelected( nColumn );
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( nRow, nColumn );
+ return implCreateCellObj( nRow, nColumn );
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCaption()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleSummary()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ return isAccessibleColumnSelected( nColumn );
+}
+
+
+// XAccessibleExtendedTable ---------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetIndex( nRow, nColumn );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRow( sal_Int32 nChildIndex )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetRow( nChildIndex );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumn( sal_Int32 nChildIndex )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetColumn( nChildIndex );
+}
+
+
+// XAccessibleSelection -------------------------------------------------------
+
+void SAL_CALL ScAccessibleCsvGrid::selectAccessibleChild( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ sal_Int32 nColumn = implGetColumn( nChildIndex );
+ if( nChildIndex == 0 )
+ implGetGrid().SelectAll();
+ else
+ implSelectColumn( nColumn, true );
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ sal_Int32 nColumn = implGetColumn( nChildIndex );
+ return implIsColumnSelected( nColumn );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::clearAccessibleSelection() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ implGetGrid().SelectAll( false );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::selectAllAccessible() throw( RuntimeException )
+{
+ selectAccessibleChild( 0 );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChildCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetRowCount() * implGetSelColumnCount();
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ sal_Int32 nColumns = implGetSelColumnCount();
+ if( nColumns == 0 )
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nRow = nSelectedChildIndex / nColumns;
+ sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
+ return getAccessibleCellAt( nRow, nColumn );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ sal_Int32 nColumns = implGetSelColumnCount();
+ if( nColumns == 0 )
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
+ ensureValidPosition( nSelectedChildIndex / nColumns, nColumn );
+ if( nColumn > 0 )
+ implSelectColumn( nColumn, false );
+}
+
+
+// XInterface -----------------------------------------------------------------
+
+Any SAL_CALL ScAccessibleCsvGrid::queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( RuntimeException )
+{
+ Any aAny( ScAccessibleCsvGridImpl::queryInterface( rType ) );
+ return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::acquire() throw ()
+{
+ ScAccessibleCsvControl::acquire();
+}
+
+void SAL_CALL ScAccessibleCsvGrid::release() throw ()
+{
+ ScAccessibleCsvControl::release();
+}
+
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvGrid::getImplementationName() throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "ScAccessibleCsvGrid" ) );
+}
+
+
+// XTypeProvider --------------------------------------------------------------
+
+Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvGrid::getTypes() throw( RuntimeException )
+{
+ Sequence< ::com::sun::star::uno::Type > aSeq( 2 );
+ aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleTable >* >( NULL ) );
+ aSeq[ 1 ] = getCppuType( static_cast< const Reference< XAccessibleSelection >* >( NULL ) );
+ return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
+}
+
+Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvGrid::getImplementationId() throw( RuntimeException )
+{
+ static Sequence< sal_Int8 > aSeq;
+ getUuid( aSeq );
+ return aSeq;
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvGrid::SendFocusEvent( bool bFocused )
+{
+ ScAccessibleCsvControl::SendFocusEvent( bFocused );
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_ACTIVE_DESCENDANT_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ (bFocused ? aEvent.NewValue : aEvent.OldValue) <<=
+ getAccessibleCellAt( 0, lcl_GetApiColumn( implGetGrid().GetFocusColumn() ) );
+ CommitChange( aEvent );
+}
+
+void ScAccessibleCsvGrid::SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::UPDATE, 0, bAllRows ? implGetRowCount() - 1 : 0,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_TABLE_MODEL_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+void ScAccessibleCsvGrid::SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::INSERT, 0, implGetRowCount() - 1,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_TABLE_MODEL_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+void ScAccessibleCsvGrid::SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::DELETE, 0, implGetRowCount() - 1,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACCESSIBLE_TABLE_MODEL_EVENT;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+
+// helpers --------------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleName() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVGRID_NAME ) );
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleDescription() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVGRID_DESCR ) );
+}
+
+void ScAccessibleCsvGrid::ensureValidIndex( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nIndex < 0) || (nIndex >= implGetCellCount()) )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvGrid::ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nRow < 0) || (nRow >= implGetRowCount()) || (nColumn < 0) || (nColumn >= implGetColumnCount()) )
+ throw IndexOutOfBoundsException();
+}
+
+ScCsvGrid& ScAccessibleCsvGrid::implGetGrid() const
+{
+ return static_cast< ScCsvGrid& >( implGetControl() );
+}
+
+bool ScAccessibleCsvGrid::implIsColumnSelected( sal_Int32 nColumn ) const
+{
+ return (nColumn > 0) && implGetGrid().IsSelected( lcl_GetGridColumn( nColumn ) );
+}
+
+void ScAccessibleCsvGrid::implSelectColumn( sal_Int32 nColumn, bool bSelect )
+{
+ if( nColumn > 0 )
+ implGetGrid().Select( lcl_GetGridColumn( nColumn ), bSelect );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetRowCount() const
+{
+ return static_cast< sal_Int32 >( implGetGrid().GetLastVisLine() - implGetGrid().GetFirstVisLine() + 2 );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetColumnCount() const
+{
+ return static_cast< sal_Int32 >( implGetGrid().GetColumnCount() + 1 );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetSelColumnCount() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nCount = 0;
+ for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != VEC_NOTFOUND; nColIx = rGrid.GetNextSelected( nColIx ) )
+ ++nCount;
+ return nCount;
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetSelColumn( sal_Int32 nSelColumn ) const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nColumn = 0;
+ for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != VEC_NOTFOUND; nColIx = rGrid.GetNextSelected( nColIx ) )
+ {
+ if( nColumn == nSelColumn )
+ return static_cast< sal_Int32 >( nColIx + 1 );
+ ++nColumn;
+ }
+ return 0;
+}
+
+OUString ScAccessibleCsvGrid::implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nLine = nRow + rGrid.GetFirstVisLine() - 1;
+ OUString aCellStr;
+ if( (nColumn > 0) && (nRow > 0) )
+ aCellStr = rGrid.GetCellText( lcl_GetGridColumn( nColumn ), nLine );
+ else if( nRow > 0 )
+ aCellStr = OUString::valueOf( nLine + 1L );
+ else if( nColumn > 0 )
+ aCellStr = rGrid.GetColumnTypeName( lcl_GetGridColumn( nColumn ) );
+ return aCellStr;
+}
+
+
+ScAccessibleCsvControl* ScAccessibleCsvGrid::implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const
+{
+ return new ScAccessibleCsvCell( implGetGrid(), implGetCellText( nRow, nColumn ), nRow, nColumn );
+}
+
+
+// ============================================================================
+
+DBG_NAME( ScAccessibleCsvCell )
+
+ScAccessibleCsvCell::ScAccessibleCsvCell(
+ ScCsvGrid& rGrid,
+ const ::rtl::OUString& rCellText,
+ sal_Int32 nRow, sal_Int32 nColumn ) :
+ ScAccessibleCsvControl( rGrid.GetAccessible(), rGrid, nCellRole ),
+ maCellText( rCellText ),
+ mnLine( nRow ? (nRow + rGrid.GetFirstVisLine() - 1) : POS_INVALID ),
+ mnColumn( lcl_GetGridColumn( nColumn ) ),
+ mnIndex( nRow * (rGrid.GetColumnCount() + 1) + nColumn )
+{
+ DBG_CTOR( ScAccessibleCsvCell, NULL );
+}
+
+ScAccessibleCsvCell::~ScAccessibleCsvCell()
+{
+ DBG_DTOR( ScAccessibleCsvCell, NULL );
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+void SAL_CALL ScAccessibleCsvCell::grabFocus() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ScCsvGrid& rGrid = implGetGrid();
+ rGrid.Execute( CSVCMD_MOVEGRIDCURSOR, rGrid.GetColumnPos( mnColumn ) );
+}
+
+
+// XAccessibleContext -----------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleChildCount() throw( RuntimeException )
+{
+ ensureAlive();
+ return 0;
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvCell::getAccessibleChild( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ throw IndexOutOfBoundsException();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleIndexInParent() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return mnIndex;
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvCell::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return new AccessibleRelationSetHelper();
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvCell::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ const ScCsvGrid& rGrid = implGetGrid();
+ pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
+ if( mnColumn != VEC_NOTFOUND )
+ {
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ pStateSet->AddState( AccessibleStateType::SELECTABLE );
+ }
+ if( rGrid.HasFocus() && (rGrid.GetFocusColumn() == mnColumn) )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ if( rGrid.IsSelected( mnColumn ) )
+ pStateSet->AddState( AccessibleStateType::SELECTED );
+ }
+ return pStateSet;
+}
+
+
+// XAccessibleText ------------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getCaretPosition() throw( RuntimeException )
+{
+ ensureAlive();
+ return 0;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvCell::setCaretPosition( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+sal_Unicode SAL_CALL ScAccessibleCsvCell::getCharacter( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return maCellText.getStr()[ nIndex ];
+}
+
+Sequence< PropertyValue > SAL_CALL ScAccessibleCsvCell::getCharacterAttributes( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return Sequence< PropertyValue >(); //! TODO
+}
+
+ScAccessibleCsvCell::AwtRectangle SAL_CALL ScAccessibleCsvCell::getCharacterBounds( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ ScCsvGrid& rGrid = implGetGrid();
+ return AwtRectangle( nIndex * rGrid.GetCharWidth(), 0, rGrid.GetCharWidth(), rGrid.GetLineHeight() );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getCharacterCount() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return maCellText.getLength();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getIndexAtPoint( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ sal_Int32 nIndex = rPoint.X / implGetGrid().GetCharWidth();
+ return ((0 <= nIndex) && (nIndex < maCellText.getLength())) ? nIndex : -1;
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getSelectedText() throw( RuntimeException )
+{
+ ensureAlive();
+ return OUString();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getSelectionStart() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getSelectionEnd() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getText() throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return maCellText;
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ ensureValidRange( nStartIndex, nEndIndex );
+ return maCellText.copy( nStartIndex, nEndIndex - nStartIndex );
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return OUString(); //! TODO
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return OUString(); //! TODO
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return OUString(); //! TODO
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+
+// XInterface -----------------------------------------------------------------
+
+Any SAL_CALL ScAccessibleCsvCell::queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( RuntimeException )
+{
+ Any aAny( ScAccessibleCsvCellImpl::queryInterface( rType ) );
+ return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
+}
+
+void SAL_CALL ScAccessibleCsvCell::acquire() throw()
+{
+ ScAccessibleCsvControl::acquire();
+}
+
+void SAL_CALL ScAccessibleCsvCell::release() throw()
+{
+ ScAccessibleCsvControl::release();
+}
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvCell::getImplementationName() throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "ScAccessibleCsvCell" ) );
+}
+
+
+// XTypeProvider --------------------------------------------------------------
+
+Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvCell::getTypes() throw( RuntimeException )
+{
+ Sequence< ::com::sun::star::uno::Type > aSeq( 1 );
+ aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleText >* >( NULL ) );
+ return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
+}
+
+Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvCell::getImplementationId() throw( RuntimeException )
+{
+ static Sequence< sal_Int8 > aSeq;
+ getUuid( aSeq );
+ return aSeq;
+}
+
+
+// helpers --------------------------------------------------------------------
+
+Rectangle ScAccessibleCsvCell::GetBoundingBoxOnScreen() const throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ Rectangle aRect( implGetBoundingBox() );
+ aRect.SetPos( implGetAbsPos( aRect.TopLeft() ) );
+ return aRect;
+}
+
+Rectangle ScAccessibleCsvCell::GetBoundingBox() const throw( RuntimeException )
+{
+ ScUnoGuard aGuard;
+ ensureAlive();
+ return implGetBoundingBox();
+}
+
+Rectangle ScAccessibleCsvCell::implGetBoundingBox() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ Point aPos;
+ Size aSize( rGrid.GetOffsetX(), rGrid.GetOffsetY() );
+ if( mnColumn != VEC_NOTFOUND )
+ {
+ aPos.X() = rGrid.GetColumnX( mnColumn );
+ aSize.Width() = rGrid.GetColumnWidth( mnColumn );
+ }
+ if( mnLine == POS_INVALID )
+ {
+ aPos.Y() = rGrid.GetY( mnLine );
+ aSize.Height() = rGrid.GetLineHeight();
+ }
+ return Rectangle( aPos, aSize );
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::createAccessibleName() throw( RuntimeException )
+{
+ return OUString();
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::createAccessibleDescription() throw( RuntimeException )
+{
+ return OUString();
+}
+
+void ScAccessibleCsvCell::ensureValidIndex( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( nIndex >= maCellText.getLength() )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvCell::ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( rnStartIndex > rnEndIndex )
+ ::std::swap( rnStartIndex, rnEndIndex );
+ if( (rnStartIndex < 0) || (rnEndIndex > maCellText.getLength()) )
+ throw IndexOutOfBoundsException();
+}
+
+ScCsvGrid& ScAccessibleCsvCell::implGetGrid() const
+{
+ return static_cast< ScCsvGrid& >( implGetControl() );
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/Accessibility/makefile.mk b/sc/source/ui/Accessibility/makefile.mk
index 8d1381e79625..fdced8381560 100644
--- a/sc/source/ui/Accessibility/makefile.mk
+++ b/sc/source/ui/Accessibility/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.14 $
+# $Revision: 1.15 $
#
-# last change: $Author: hjs $ $Date: 2002-08-14 12:59:48 $
+# last change: $Author: dr $ $Date: 2002-08-15 09:27:02 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -81,64 +81,45 @@ AUTOSEG=true
# --- Files --------------------------------------------------------
-CXXFILES = \
- AccessibleContextBase.cxx \
- AccessibleTableBase.cxx \
- AccessibleDocument.cxx \
- AccessibleSpreadsheet.cxx \
- AccessibleCell.cxx \
- AccessibleSpreadsheet.cxx \
- AccessibilityHints.cxx \
- AccessibleDocumentBase.cxx \
- AccessibleCellBase.cxx \
- AccessibleDocumentPagePreview.cxx \
- AccessiblePreviewTable.cxx \
- AccessiblePreviewCell.cxx \
- AccessiblePreviewHeaderCell.cxx \
- AccessiblePageHeader.cxx \
- AccessibleText.cxx \
- AccessiblePageHeaderArea.cxx \
- DrawModelBroadcaster.cxx \
- AccessibleEditObject.cxx \
- AccessibleDataPilotControl.cxx
+SLOFILES = \
+ $(SLO)$/AccessibleContextBase.obj \
+ $(SLO)$/AccessibleTableBase.obj \
+ $(SLO)$/AccessibleDocument.obj \
+ $(SLO)$/AccessibleSpreadsheet.obj \
+ $(SLO)$/AccessibleCell.obj \
+ $(SLO)$/AccessibilityHints.obj \
+ $(SLO)$/AccessibleDocumentBase.obj \
+ $(SLO)$/AccessibleCellBase.obj \
+ $(SLO)$/AccessibleDocumentPagePreview.obj \
+ $(SLO)$/AccessiblePreviewTable.obj \
+ $(SLO)$/AccessiblePreviewCell.obj \
+ $(SLO)$/AccessiblePreviewHeaderCell.obj \
+ $(SLO)$/AccessiblePageHeader.obj \
+ $(SLO)$/AccessibleText.obj \
+ $(SLO)$/AccessiblePageHeaderArea.obj \
+ $(SLO)$/DrawModelBroadcaster.obj \
+ $(SLO)$/AccessibleEditObject.obj \
+ $(SLO)$/AccessibleDataPilotControl.obj \
+ $(SLO)$/AccessibleCsvControl.obj
-EXCEPTIONSFILES=\
- $(SLO)$/AccessibleContextBase.obj \
- $(SLO)$/AccessibleTableBase.obj \
- $(SLO)$/AccessibleDocument.obj \
- $(SLO)$/AccessibleSpreadsheet.obj \
- $(SLO)$/AccessibleCell.obj \
- $(SLO)$/AccessibleDocumentBase.obj \
- $(SLO)$/AccessibleCellBase.obj \
- $(SLO)$/AccessibleDocumentPagePreview.obj \
- $(SLO)$/AccessiblePreviewTable.obj \
- $(SLO)$/AccessiblePreviewCell.obj \
- $(SLO)$/AccessiblePreviewHeaderCell.obj \
- $(SLO)$/AccessiblePageHeader.obj \
- $(SLO)$/AccessiblePageHeaderArea.obj \
- $(SLO)$/DrawModelBroadcaster.obj \
- $(SLO)$/AccessibleEditObject.obj \
- $(SLO)$/AccessibleDataPilotControl.obj
-
-SLOFILES = \
- $(SLO)$/AccessibleContextBase.obj \
- $(SLO)$/AccessibleTableBase.obj \
- $(SLO)$/AccessibleDocument.obj \
- $(SLO)$/AccessibleSpreadsheet.obj \
- $(SLO)$/AccessibleCell.obj \
- $(SLO)$/AccessibilityHints.obj \
- $(SLO)$/AccessibleDocumentBase.obj \
- $(SLO)$/AccessibleCellBase.obj \
- $(SLO)$/AccessibleDocumentPagePreview.obj \
- $(SLO)$/AccessiblePreviewTable.obj \
- $(SLO)$/AccessiblePreviewCell.obj \
- $(SLO)$/AccessiblePreviewHeaderCell.obj \
- $(SLO)$/AccessiblePageHeader.obj \
- $(SLO)$/AccessibleText.obj \
- $(SLO)$/AccessiblePageHeaderArea.obj \
- $(SLO)$/DrawModelBroadcaster.obj \
- $(SLO)$/AccessibleEditObject.obj \
- $(SLO)$/AccessibleDataPilotControl.obj
+EXCEPTIONSFILES= \
+ $(SLO)$/AccessibleContextBase.obj \
+ $(SLO)$/AccessibleTableBase.obj \
+ $(SLO)$/AccessibleDocument.obj \
+ $(SLO)$/AccessibleSpreadsheet.obj \
+ $(SLO)$/AccessibleCell.obj \
+ $(SLO)$/AccessibleDocumentBase.obj \
+ $(SLO)$/AccessibleCellBase.obj \
+ $(SLO)$/AccessibleDocumentPagePreview.obj \
+ $(SLO)$/AccessiblePreviewTable.obj \
+ $(SLO)$/AccessiblePreviewCell.obj \
+ $(SLO)$/AccessiblePreviewHeaderCell.obj \
+ $(SLO)$/AccessiblePageHeader.obj \
+ $(SLO)$/AccessiblePageHeaderArea.obj \
+ $(SLO)$/DrawModelBroadcaster.obj \
+ $(SLO)$/AccessibleEditObject.obj \
+ $(SLO)$/AccessibleDataPilotControl.obj \
+ $(SLO)$/AccessibleCsvControl.obj
# --- Tagets -------------------------------------------------------
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index d6c4500f1e2d..1a096a72ac8e 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: asciiopt.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:48:29 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:28:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -172,24 +172,22 @@ void ScAsciiOptions::SetColInfo( USHORT nCount, const xub_StrLen* pStart, const
}
-void ScAsciiOptions::SetColumnInfo( const ScCsvExtColPosVec& rColPosVec, const ScCsvExtColTypeVec& rColTypeVec )
+void ScAsciiOptions::SetColumnInfo( const ScCsvExpDataVec& rDataVec )
{
- DBG_ASSERT( rColPosVec.size() == rColTypeVec.size(), "ScAsciiOptions::SetColInfo - vector sizes not equal" );
-
delete[] pColStart;
pColStart = NULL;
delete[] pColFormat;
pColFormat = NULL;
- nInfoCount = static_cast< sal_uInt16 >( rColPosVec.size() );
+ nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() );
if( nInfoCount )
{
pColStart = new xub_StrLen[ nInfoCount ];
pColFormat = new sal_uInt8[ nInfoCount ];
for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx )
{
- pColStart[ nIx ] = rColPosVec[ nIx ];
- pColFormat[ nIx ] = rColTypeVec[ nIx ];
+ pColStart[ nIx ] = rDataVec[ nIx ].mnIndex;
+ pColFormat[ nIx ] = rDataVec[ nIx ].mnType;
}
}
}
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx
index dcc8bddad66e..7748f8cb9222 100644
--- a/sc/source/ui/dbgui/csvcontrol.cxx
+++ b/sc/source/ui/dbgui/csvcontrol.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvcontrol.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:48:30 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:28:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,6 +74,10 @@
#include <tools/debug.hxx>
#endif
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#include "AccessibleCsvControl.hxx"
+#endif
+
// ============================================================================
@@ -116,6 +120,7 @@ ScCsvDiff ScCsvLayoutData::GetDiff( const ScCsvLayoutData& rData ) const
ScCsvControl::ScCsvControl( ScCsvControl& rParent ) :
Control( &rParent, WB_TABSTOP | WB_NODIALOGCONTROL ),
mrData( rParent.GetLayoutData() ),
+ mpAccessible( NULL ),
mbValidGfx( false )
{
}
@@ -123,6 +128,7 @@ ScCsvControl::ScCsvControl( ScCsvControl& rParent ) :
ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle ) :
Control( pParent, nStyle ),
mrData( rData ),
+ mpAccessible( NULL ),
mbValidGfx( false )
{
}
@@ -130,10 +136,68 @@ ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBi
ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId ) :
Control( pParent, rResId ),
mrData( rData ),
+ mpAccessible( NULL ),
mbValidGfx( false )
{
}
+ScCsvControl::~ScCsvControl()
+{
+ if( mpAccessible )
+ mpAccessible->dispose();
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvControl::GetFocus()
+{
+ Control::GetFocus();
+ AccSendFocusEvent( true );
+}
+
+void ScCsvControl::LoseFocus()
+{
+ Control::LoseFocus();
+ AccSendFocusEvent( false );
+}
+
+void ScCsvControl::AccSendFocusEvent( bool bFocused )
+{
+ if( mpAccessible )
+ mpAccessible->SendFocusEvent( bFocused );
+}
+
+void ScCsvControl::AccSendCaretEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendCaretEvent();
+}
+
+void ScCsvControl::AccSendSelectionEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendSelectionEvent();
+}
+
+void ScCsvControl::AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ if( mpAccessible )
+ mpAccessible->SendTableUpdateEvent( nFirstColumn, nLastColumn, bAllRows );
+}
+
+void ScCsvControl::AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendInsertColumnEvent( nFirstColumn, nLastColumn );
+}
+
+void ScCsvControl::AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendRemoveColumnEvent( nFirstColumn, nLastColumn );
+}
+
// repaint helpers ------------------------------------------------------------
@@ -229,6 +293,11 @@ sal_Int32 ScCsvControl::GetY( sal_Int32 nLine ) const
return GetOffsetY() + (nLine - GetFirstVisLine()) * GetLineHeight();
}
+sal_Int32 ScCsvControl::GetLineFromY( sal_Int32 nY ) const
+{
+ return (nY - GetOffsetY()) / GetLineHeight() + GetFirstVisLine();
+}
+
// static helpers -------------------------------------------------------------
@@ -273,5 +342,15 @@ ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd )
}
+// accessibility --------------------------------------------------------------
+
+ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible()
+{
+ mpAccessible = ImplCreateAccessible();
+ mxAccessible = mpAccessible;
+ return mxAccessible;
+}
+
+
// ============================================================================
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 6ef8fc268ad1..140b65078f63 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvgrid.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: dr $ $Date: 2002-08-06 16:12:21 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:28:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,6 +92,10 @@
#include "impex.hxx"
#endif
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#include "AccessibleCsvControl.hxx"
+#endif
+
// *** edit engine ***
#include "scitems.hxx"
#include <svx/eeitem.hxx>
@@ -110,14 +114,18 @@
// ============================================================================
-struct Func_SetDefault
+struct Func_SetType
{
- inline void operator()( ScCsvColState& rState ) { rState.mnType = CSV_TYPE_DEFAULT; }
+ sal_Int32 mnType;
+ inline Func_SetType( sal_Int32 nType ) : mnType( nType ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.mnType = mnType; }
};
-struct Func_Deselect
+struct Func_Select
{
- inline void operator()( ScCsvColState& rState ) { rState.Select( false ); }
+ bool mbSelect;
+ inline Func_Select( bool bSelect ) : mbSelect( bSelect ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.Select( mbSelect ); }
};
@@ -147,73 +155,7 @@ ScCsvGrid::~ScCsvGrid()
}
-// initialization -------------------------------------------------------------
-
-void ScCsvGrid::InitColors()
-{
- maBackColor = Color( mrColorConfig.GetColorValue( ::svx::DOCCOLOR ).nColor );
- maGridColor = Color( mrColorConfig.GetColorValue( ::svx::CALCGRID ).nColor );
- maGridPBColor = Color( mrColorConfig.GetColorValue( ::svx::CALCPAGEBREAK ).nColor );
- maAppBackColor = Color( mrColorConfig.GetColorValue( ::svx::APPBACKGROUND ).nColor );
-
- const StyleSettings& rSett = GetSettings().GetStyleSettings();
- maTextColor = rSett.GetButtonTextColor();
- maHeaderBackColor = rSett.GetFaceColor();
- maHeaderGridColor = rSett.GetDarkShadowColor();
- maSelectColor = rSett.GetActiveColor();
-
- InvalidateGfx();
-}
-
-void ScCsvGrid::InitFonts()
-{
- maMonoFont = OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
- maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) );
-
- /* *** Set edit engine defaults ***
- maMonoFont for Latin script, smaller default font for Asian and Complex script. */
-
- // get default fonts
- SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
- SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
- SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
- ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
-
- // create item set for defaults
- SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
- EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont );
- aDefSet.Put( aAsianItem );
- aDefSet.Put( aComplexItem );
-
- // set Asian/Complex font size to width of character in Latin font
- aDefSet.Put( SvxFontHeightItem( GetCharWidth(), 100, EE_CHAR_FONTHEIGHT_CJK ) );
- aDefSet.Put( SvxFontHeightItem( GetCharWidth(), 100, EE_CHAR_FONTHEIGHT_CTL ) );
-
- // copy other items from default font
- const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
- aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
- aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
- const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
- aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
- aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
- const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
- aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
- aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
-
- mpEditEngine->SetDefaults( aDefSet );
- InvalidateGfx();
-}
-
-void ScCsvGrid::InitSizeData()
-{
- maWinSize = GetSizePixel();
- maBackgrDev.SetOutputSizePixel( maWinSize );
- maGridDev.SetOutputSizePixel( maWinSize );
- InvalidateGfx();
-}
-
-
-// grid handling --------------------------------------------------------------
+// common grid handling -------------------------------------------------------
void ScCsvGrid::UpdateLayoutData()
{
@@ -238,8 +180,10 @@ void ScCsvGrid::UpdateOffsetX()
void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
{
- DisableRepaint();
ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
+ if( nDiff == CSV_DIFF_EQUAL ) return;
+
+ DisableRepaint();
if( nDiff & CSV_DIFF_RULERCURSOR )
{
@@ -251,8 +195,7 @@ void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
{
if( GetPosCount() < rOldData.mnPosCount )
{
- ImplClearSelection();
- Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ SelectAll( false );
maSplits.RemoveRange( GetPosCount(), rOldData.mnPosCount );
}
else
@@ -267,10 +210,10 @@ void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
UpdateOffsetX();
}
- if( nDiff & CSV_DIFF_POSOFFSET )
+ ScCsvDiff nHVDiff = nDiff & (CSV_DIFF_HORIZONTAL | CSV_DIFF_VERTICAL);
+ if( nHVDiff == CSV_DIFF_POSOFFSET )
ImplDrawHorzScrolled( rOldData.mnPosOffset );
-
- if( nDiff & ((CSV_DIFF_HORIZONTAL | CSV_DIFF_VERTICAL) & ~CSV_DIFF_POSOFFSET) )
+ else if( nHVDiff != CSV_DIFF_EQUAL )
InvalidateGfx();
EnableRepaint();
@@ -304,41 +247,72 @@ sal_Int32 ScCsvGrid::GetNoScrollCol( sal_Int32 nPos ) const
return nNewPos;
}
-bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
+void ScCsvGrid::InitColors()
{
- sal_uInt32 nColIx = GetColumnFromPos( nPos );
- bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
- if( bRet )
- {
- ScCsvColState aState( GetColumnType( nColIx ) );
- aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
- maColStates.insert( maColStates.begin() + nColIx + 1, aState );
- }
- return bRet;
+ maBackColor = Color( mrColorConfig.GetColorValue( ::svx::DOCCOLOR ).nColor );
+ maGridColor = Color( mrColorConfig.GetColorValue( ::svx::CALCGRID ).nColor );
+ maGridPBColor = Color( mrColorConfig.GetColorValue( ::svx::CALCPAGEBREAK ).nColor );
+ maAppBackColor = Color( mrColorConfig.GetColorValue( ::svx::APPBACKGROUND ).nColor );
+
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ maTextColor = rSett.GetButtonTextColor();
+ maHeaderBackColor = rSett.GetFaceColor();
+ maHeaderGridColor = rSett.GetDarkShadowColor();
+ maSelectColor = rSett.GetActiveColor();
+
+ InvalidateGfx();
}
-bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
+void ScCsvGrid::InitFonts()
{
- bool bRet = maSplits.Remove( nPos );
- if( bRet )
- {
- sal_uInt32 nColIx = GetColumnFromPos( nPos );
- bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
- maColStates.erase( maColStates.begin() + nColIx + 1 );
- maColStates[ nColIx ].Select( bSel );
- }
- return bRet;
+ maMonoFont = OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
+ maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) );
+
+ /* *** Set edit engine defaults ***
+ maMonoFont for Latin script, smaller default font for Asian and Complex script. */
+
+ // get default fonts
+ SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
+ SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
+ SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
+ ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
+
+ // create item set for defaults
+ SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
+ EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont );
+ aDefSet.Put( aAsianItem );
+ aDefSet.Put( aComplexItem );
+
+ // set Asian/Complex font size to width of character in Latin font
+ aDefSet.Put( SvxFontHeightItem( GetCharWidth(), 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ aDefSet.Put( SvxFontHeightItem( GetCharWidth(), 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ // copy other items from default font
+ const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+ const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+ const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+
+ mpEditEngine->SetDefaults( aDefSet );
+ InvalidateGfx();
}
-void ScCsvGrid::ImplClearSplits()
+void ScCsvGrid::InitSizeData()
{
- maSplits.Clear();
- maSplits.Insert( 0 );
- maSplits.Insert( GetPosCount() );
- maColStates.resize( 1 );
+ maWinSize = GetSizePixel();
+ maBackgrDev.SetOutputSizePixel( maWinSize );
+ maGridDev.SetOutputSizePixel( maWinSize );
InvalidateGfx();
}
+
+// split handling -------------------------------------------------------------
+
void ScCsvGrid::InsertSplit( sal_Int32 nPos )
{
if( ImplInsertSplit( nPos ) )
@@ -382,6 +356,7 @@ void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
ImplDrawColumn( nColIx - 1 );
ImplDrawColumn( nColIx );
ValidateGfx(); // performance: do not redraw all columns
+ AccSendTableUpdateEvent( nColIx - 1, nColIx );
}
else
{
@@ -417,46 +392,90 @@ void ScCsvGrid::SetSplits( const ScCsvSplits& rSplits )
EnableRepaint();
}
-void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
+bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
{
- sal_Int32 nLine = GetFirstVisLine();
- switch( eDir )
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
+ if( bRet )
{
- case MOVE_PREV: --nLine; break;
- case MOVE_NEXT: ++nLine; break;
- case MOVE_FIRST: nLine = 0; break;
- case MOVE_LAST: nLine = GetMaxLineOffset(); break;
- case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
- case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
+ ScCsvColState aState( GetColumnType( nColIx ) );
+ aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
+ maColStates.insert( maColStates.begin() + nColIx + 1, aState );
+ AccSendInsertColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
}
- Execute( CSVCMD_SETLINEOFFSET, nLine );
+ return bRet;
}
-void ScCsvGrid::ExecutePopup( const Point& rPos )
+bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
{
- sal_uInt16 nItemId = maPopup.Execute( this, rPos );
- if( nItemId ) // 0 = cancelled
- Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
+ bool bRet = maSplits.Remove( nPos );
+ if( bRet )
+ {
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
+ maColStates.erase( maColStates.begin() + nColIx + 1 );
+ maColStates[ nColIx ].Select( bSel );
+ AccSendRemoveColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
+ }
+ return bRet;
}
+void ScCsvGrid::ImplClearSplits()
+{
+ sal_uInt32 nColumns = GetColumnCount();
+ maSplits.Clear();
+ maSplits.Insert( 0 );
+ maSplits.Insert( GetPosCount() );
+ maColStates.resize( 1 );
+ InvalidateGfx();
+ AccSendRemoveColumnEvent( 1, nColumns - 1 );
+}
-// column data ----------------------------------------------------------------
+// columns/column types -------------------------------------------------------
-sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
+sal_uInt32 ScCsvGrid::GetFirstVisColumn() const
{
- return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
+ return GetColumnFromPos( GetFirstVisPos() );
}
-void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
+sal_uInt32 ScCsvGrid::GetLastVisColumn() const
{
- if( IsValidColumn( nColIndex ) )
- maColStates[ nColIndex ].mnType = nColType;
+ return GetColumnFromPos( Min( GetLastVisPos(), GetPosCount() ) - 1 );
}
-const String& ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
+bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
{
- sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
- return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : EMPTY_STRING;
+ return nColIndex < GetColumnCount();
+}
+
+bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) &&
+ (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
+ (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
+}
+
+sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
+{
+ return GetX( GetColumnPos( nColIndex ) );
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
+{
+ sal_Int32 nPos = (nX - GetOffsetX()) / GetCharWidth() + GetFirstVisPos();
+ return (nPos >= GetFirstVisPos()) ? GetColumnFromPos( nPos ) : VEC_NOTFOUND;
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
+{
+ return maSplits.UpperBound( nPos );
+}
+
+sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
}
void ScCsvGrid::SetColumnStates( const ScCsvColStateVec& rStates )
@@ -464,6 +483,22 @@ void ScCsvGrid::SetColumnStates( const ScCsvColStateVec& rStates )
maColStates = rStates;
maColStates.resize( maSplits.Count() - 1 );
Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ AccSendTableUpdateEvent( 0, GetColumnCount(), false );
+ AccSendSelectionEvent();
+}
+
+sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
+}
+
+void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
+{
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].mnType = nColType;
+ AccSendTableUpdateEvent( nColIndex, nColIndex, false );
+ }
}
sal_Int32 ScCsvGrid::GetSelColumnType() const
@@ -493,7 +528,7 @@ void ScCsvGrid::SetSelColumnType( sal_Int32 nType )
}
}
-void ScCsvGrid::SetTypeNames( const ScCsvStringVec& rTypeNames )
+void ScCsvGrid::SetTypeNames( const StringVec& rTypeNames )
{
DBG_ASSERT( !rTypeNames.empty(), "ScCsvGrid::SetTypeNames - vector is empty" );
maTypeNames = rTypeNames;
@@ -506,86 +541,13 @@ void ScCsvGrid::SetTypeNames( const ScCsvStringVec& rTypeNames )
for( nIx = 0, nItemId = 1; nIx < nCount; ++nIx, ++nItemId )
maPopup.InsertItem( nItemId, maTypeNames[ nIx ] );
- ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetDefault() );
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
}
-void ScCsvGrid::ImplSetTextLineSep(
- sal_Int32 nLine, const String& rTextLine,
- const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
-{
- sal_uInt32 nLineIx = nLine - GetFirstVisLine();
- while( maTexts.size() <= nLineIx )
- maTexts.push_back( ScCsvStringVec() );
- ScCsvStringVec& rStrVec = maTexts[ nLineIx ];
- rStrVec.clear();
-
- // scan for separators
- String aCellText;
- const sal_Unicode* pSepChars = rSepChars.GetBuffer();
- const sal_Unicode* pChar = rTextLine.GetBuffer();
- sal_uInt32 nColIx = 0;
-
- while( *pChar && (nColIx < CSV_MAXCOLCOUNT) )
- {
- // scan for next cell text
- pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep );
-
- // update column width
- sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + 1L );
- if( IsValidColumn( nColIx ) )
- {
- // expand existing column
- sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
- if( nDiff > 0 )
- {
- Execute( CSVCMD_SETPOSCOUNT, GetPosCount() + nDiff );
- for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
- {
- sal_Int32 nPos = maSplits[ nSplitIx ];
- maSplits.Remove( nPos );
- maSplits.Insert( nPos + nDiff );
- }
- }
- }
- else
- {
- // append new column
- sal_Int32 nLastPos = GetPosCount();
- Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
- ImplInsertSplit( nLastPos );
- }
-
- if( aCellText.Len() <= CSV_MAXSTRLEN )
- rStrVec.push_back( aCellText );
- else
- rStrVec.push_back( aCellText.Copy( 0, CSV_MAXSTRLEN ) );
- ++nColIx;
- }
- InvalidateGfx();
-}
-
-void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine )
+const String& ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
{
- sal_Int32 nChars = rTextLine.Len();
- if( nChars > GetPosCount() )
- Execute( CSVCMD_SETPOSCOUNT, nChars );
-
- sal_uInt32 nLineIx = nLine - GetFirstVisLine();
- while( maTexts.size() <= nLineIx )
- maTexts.push_back( ScCsvStringVec() );
-
- ScCsvStringVec& rStrVec = maTexts[ nLineIx ];
- rStrVec.clear();
- sal_uInt32 nColCount = GetColumnCount();
- xub_StrLen nStrLen = rTextLine.Len();
- xub_StrLen nStrIx = 0;
- for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
- {
- xub_StrLen nChars = static_cast< xub_StrLen >( GetColumnWidth( nColIx ) );
- rStrVec.push_back( rTextLine.Copy( nStrIx, Max( nChars, CSV_MAXSTRLEN ) ) );
- nStrIx += nChars;
- }
- InvalidateGfx();
+ sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
+ return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : EMPTY_STRING;
}
sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
@@ -598,87 +560,131 @@ sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
void ScCsvGrid::FillColumnDataSep( ScAsciiOptions& rOptions ) const
{
- ScCsvExtColPosVec aColIndexVec;
- ScCsvExtColTypeVec aColTypeVec;
sal_uInt32 nCount = GetColumnCount();
+ ScCsvExpDataVec aDataVec;
for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
{
if( GetColumnType( nColIx ) != CSV_TYPE_DEFAULT )
- {
// 1-based column index
- aColIndexVec.push_back( static_cast< xub_StrLen >( nColIx + 1 ) );
- aColTypeVec.push_back( lcl_GetExtColumnType( GetColumnType( nColIx ) ) );
- }
+ aDataVec.push_back( ScCsvExpData(
+ static_cast< xub_StrLen >( nColIx + 1 ),
+ lcl_GetExtColumnType( GetColumnType( nColIx ) ) ) );
}
- rOptions.SetColumnInfo( aColIndexVec, aColTypeVec );
+ rOptions.SetColumnInfo( aDataVec );
}
void ScCsvGrid::FillColumnDataFix( ScAsciiOptions& rOptions ) const
{
sal_uInt32 nCount = Min( GetColumnCount(), MAXCOL + 1UL );
- ScCsvExtColPosVec aColPosVec( nCount + 1 );
- ScCsvExtColTypeVec aColTypeVec( nCount + 1 );
+ ScCsvExpDataVec aDataVec( nCount + 1 );
for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
{
- aColPosVec[ nColIx ] = static_cast< xub_StrLen >(
+ ScCsvExpData& rData = aDataVec[ nColIx ];
+ rData.mnIndex = static_cast< xub_StrLen >(
Min( static_cast< sal_Int32 >( STRING_MAXLEN ), GetColumnPos( nColIx ) ) );
- aColTypeVec[ nColIx ] = lcl_GetExtColumnType( GetColumnType( nColIx ) );
+ rData.mnType = lcl_GetExtColumnType( GetColumnType( nColIx ) );
}
- aColPosVec[ nCount ] = STRING_MAXLEN;
- aColTypeVec[ nCount ] = SC_COL_SKIP;
- rOptions.SetColumnInfo( aColPosVec, aColTypeVec );
+ aDataVec[ nCount ].mnIndex = STRING_MAXLEN;
+ aDataVec[ nCount ].mnType = SC_COL_SKIP;
+ rOptions.SetColumnInfo( aDataVec );
}
-
-// column position ------------------------------------------------------------
-
-sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
+void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
{
- return maSplits.UpperBound( nPos );
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_FIRST: nLine = 0; break;
+ case MOVE_LAST: nLine = GetMaxLineOffset(); break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
}
-sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
+void ScCsvGrid::ExecutePopup( const Point& rPos )
{
- return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
+ sal_uInt16 nItemId = maPopup.Execute( this, rPos );
+ if( nItemId ) // 0 = cancelled
+ Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
}
-sal_uInt32 ScCsvGrid::GetFirstVisColumn() const
+
+// selection handling ---------------------------------------------------------
+
+bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
{
- return GetColumnFromPos( GetFirstVisPos() );
+ return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
}
-sal_uInt32 ScCsvGrid::GetLastVisColumn() const
+sal_uInt32 ScCsvGrid::GetFirstSelected() const
{
- return GetColumnFromPos( Min( GetLastVisPos(), GetPosCount() ) - 1 );
+ return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
}
-bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
+sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
{
- return nColIndex < GetColumnCount();
+ sal_uInt32 nColCount = GetColumnCount();
+ for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
+ if( IsSelected( nColIx ) )
+ return nColIx;
+ return VEC_NOTFOUND;
}
-bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
+void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
{
- return IsValidColumn( nColIndex ) &&
- (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
- (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].Select( bSelect );
+ ImplDrawColumnSelection( nColIndex );
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex;
+ AccSendSelectionEvent();
+ }
}
-sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
+void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
{
- return GetX( GetColumnPos( nColIndex ) );
+ Select( nColIndex, !IsSelected( nColIndex ) );
}
-sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
+void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
{
- sal_Int32 nPos = (nX - GetOffsetX()) / GetCharWidth() + GetFirstVisPos();
- return (nPos >= GetFirstVisPos()) ? GetColumnFromPos( nPos ) : VEC_NOTFOUND;
+ if( nColIndex1 == VEC_NOTFOUND )
+ Select( nColIndex2 );
+ else if( nColIndex2 == VEC_NOTFOUND )
+ Select( nColIndex1 );
+ else if( nColIndex1 > nColIndex2 )
+ {
+ SelectRange( nColIndex2, nColIndex1, bSelect );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ }
+ else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
+ {
+ for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
+ {
+ maColStates[ nColIx ].Select( bSelect );
+ ImplDrawColumnSelection( nColIx );
+ }
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ AccSendSelectionEvent();
+ }
}
-
-// selection handling ---------------------------------------------------------
+void ScCsvGrid::SelectAll( bool bSelect )
+{
+ SelectRange( 0, GetColumnCount() - 1, bSelect );
+}
void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex )
{
@@ -724,86 +730,122 @@ void ScCsvGrid::MoveCursorRel( ScMoveMode eDir )
void ScCsvGrid::ImplClearSelection()
{
- ::std::for_each( maColStates.begin(), maColStates.end(), Func_Deselect() );
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_Select( false ) );
ImplDrawGridDev();
}
-bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
+void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
{
- return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
+ if( !(nModifier & KEY_MOD1) )
+ ImplClearSelection();
+ if( nModifier & KEY_SHIFT ) // SHIFT always expands
+ SelectRange( mnRecentSelCol, nColIndex );
+ else if( !(nModifier & KEY_MOD1) ) // no SHIFT/CTRL always selects 1 column
+ Select( nColIndex );
+ else if( IsTracking() ) // CTRL in tracking does not toggle
+ Select( nColIndex, mbMTSelecting );
+ else // CTRL only toggles
+ ToggleSelect( nColIndex );
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
}
-sal_uInt32 ScCsvGrid::GetFirstSelected() const
-{
- return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
-}
-sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
-{
- sal_uInt32 nColCount = GetColumnCount();
- for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
- if( IsSelected( nColIx ) )
- return nColIx;
- return VEC_NOTFOUND;
-}
+// cell contents --------------------------------------------------------------
-void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
+void ScCsvGrid::ImplSetTextLineSep(
+ sal_Int32 nLine, const String& rTextLine,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
{
- if( IsValidColumn( nColIndex ) )
+ if( nLine < GetFirstVisLine() ) return;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+
+ // scan for separators
+ String aCellText;
+ const sal_Unicode* pSepChars = rSepChars.GetBuffer();
+ const sal_Unicode* pChar = rTextLine.GetBuffer();
+ sal_uInt32 nColIx = 0;
+
+ while( *pChar && (nColIx < CSV_MAXCOLCOUNT) )
{
- maColStates[ nColIndex ].Select( bSelect );
- ImplDrawColumnSelection( nColIndex );
- Repaint();
- Execute( CSVCMD_EXPORTCOLUMNTYPE );
- if( bSelect )
- mnRecentSelCol = nColIndex;
+ // scan for next cell text
+ pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep );
+
+ // update column width
+ sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + 1L );
+ if( IsValidColumn( nColIx ) )
+ {
+ // expand existing column
+ sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
+ if( nDiff > 0 )
+ {
+ Execute( CSVCMD_SETPOSCOUNT, GetPosCount() + nDiff );
+ for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
+ {
+ sal_Int32 nPos = maSplits[ nSplitIx ];
+ maSplits.Remove( nPos );
+ maSplits.Insert( nPos + nDiff );
+ }
+ }
+ }
+ else
+ {
+ // append new column
+ sal_Int32 nLastPos = GetPosCount();
+ Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
+ ImplInsertSplit( nLastPos );
+ }
+
+ if( aCellText.Len() <= CSV_MAXSTRLEN )
+ rStrVec.push_back( aCellText );
+ else
+ rStrVec.push_back( aCellText.Copy( 0, CSV_MAXSTRLEN ) );
+ ++nColIx;
}
+ InvalidateGfx();
}
-void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
+void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine )
{
- Select( nColIndex, !IsSelected( nColIndex ) );
-}
+ if( nLine < GetFirstVisLine() ) return;
-void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
-{
- if( nColIndex1 == VEC_NOTFOUND )
- Select( nColIndex2 );
- else if( nColIndex2 == VEC_NOTFOUND )
- Select( nColIndex1 );
- else if( nColIndex1 > nColIndex2 )
- {
- SelectRange( nColIndex2, nColIndex1, bSelect );
- if( bSelect )
- mnRecentSelCol = nColIndex1;
- }
- else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
+ sal_Int32 nChars = rTextLine.Len();
+ if( nChars > GetPosCount() )
+ Execute( CSVCMD_SETPOSCOUNT, nChars );
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+ sal_uInt32 nColCount = GetColumnCount();
+ xub_StrLen nStrLen = rTextLine.Len();
+ xub_StrLen nStrIx = 0;
+ for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
{
- for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
- {
- maColStates[ nColIx ].Select( bSelect );
- ImplDrawColumnSelection( nColIx );
- }
- Repaint();
- Execute( CSVCMD_EXPORTCOLUMNTYPE );
- if( bSelect )
- mnRecentSelCol = nColIndex1;
+ xub_StrLen nChars = static_cast< xub_StrLen >( GetColumnWidth( nColIx ) );
+ rStrVec.push_back( rTextLine.Copy( nStrIx, Max( nChars, CSV_MAXSTRLEN ) ) );
+ nStrIx += nChars;
}
+ InvalidateGfx();
}
-void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
+const String& ScCsvGrid::GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const
{
- if( !(nModifier & KEY_MOD1) )
- ImplClearSelection();
- if( nModifier & KEY_SHIFT ) // SHIFT always expands
- SelectRange( mnRecentSelCol, nColIndex );
- else if( !(nModifier & KEY_MOD1) ) // no SHIFT/CTRL always selects 1 column
- Select( nColIndex );
- else if( IsTracking() ) // CTRL in tracking does not toggle
- Select( nColIndex, mbMTSelecting );
- else // CTRL only toggles
- ToggleSelect( nColIndex );
- Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
+ if( nLine < GetFirstVisLine() ) return EMPTY_STRING;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ if( nLineIx >= maTexts.size() ) return EMPTY_STRING;
+
+ const StringVec& rStrVec = maTexts[ nLineIx ];
+ if( nColIndex >= rStrVec.size() ) return EMPTY_STRING;
+
+ return rStrVec[ nColIndex ];
}
@@ -1110,7 +1152,7 @@ void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
sal_Int32 nLineCount = Min( GetLastVisLine() - GetFirstVisLine() + 1UL, maTexts.size() );
for( sal_Int32 nLine = 0; nLine < nLineCount; ++nLine )
{
- ScCsvStringVec& rStrVec = maTexts[ nLine ];
+ StringVec& rStrVec = maTexts[ nLine ];
if( nColIndex < rStrVec.size() )
ImplDrawCellText( Point( nX1, GetY( GetFirstVisLine() + nLine ) ), rStrVec[ nColIndex ] );
}
@@ -1141,7 +1183,7 @@ void ScCsvGrid::ImplDrawRowHeaders()
{
String aText( String::CreateFromInt32( nLine + 1 ) );
sal_Int32 nX = (GetOffsetX() - maBackgrDev.GetTextWidth( aText )) / 2;
- maBackgrDev.DrawText( Point( nX, GetY( nLine ) + 1 ), aText );
+ maBackgrDev.DrawText( Point( nX, GetY( nLine ) ), aText );
}
// grid
@@ -1285,5 +1327,13 @@ void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex )
}
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvGrid( *this );
+}
+
+
// ============================================================================
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index 0a8c2f05f133..d5244e3f9cdb 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvruler.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:48:32 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:28:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,6 +70,10 @@
#include "csvruler.hxx"
#endif
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#include "AccessibleCsvControl.hxx"
+#endif
+
// ============================================================================
@@ -79,10 +83,40 @@ ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
{
InitColors();
InitSizeData();
+ maBackgrDev.SetFont( GetFont() );
+ maRulerDev.SetFont( GetFont() );
+}
+
+
+// common ruler handling ------------------------------------------------------
+
+void ScCsvRuler::SetPosSizePixel(
+ sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_uInt16 nFlags )
+{
+ if( nFlags & WINDOW_POSSIZE_HEIGHT )
+ nHeight = GetTextHeight() + mnSplitSize + 2;
+ ScCsvControl::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
}
+void ScCsvRuler::ApplyLayout( const ScCsvLayoutData& rOldData )
+{
+ ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData ) & (CSV_DIFF_HORIZONTAL | CSV_DIFF_RULERCURSOR);
+ if( nDiff == CSV_DIFF_EQUAL ) return;
-// initialization -------------------------------------------------------------
+ DisableRepaint();
+ if( nDiff & CSV_DIFF_HORIZONTAL )
+ {
+ InitSizeData();
+ if( GetRulerCursorPos() >= GetPosCount() )
+ MoveCursor( GetPosCount() - 1 );
+ }
+ if( nDiff & CSV_DIFF_RULERCURSOR )
+ {
+ ImplInvertCursor( rOldData.mnPosCursor );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+ EnableRepaint();
+}
void ScCsvRuler::InitColors()
{
@@ -112,55 +146,6 @@ void ScCsvRuler::InitSizeData()
InvalidateGfx();
}
-
-// ruler handling -------------------------------------------------------------
-
-void ScCsvRuler::ApplyLayout( const ScCsvLayoutData& rOldData )
-{
- ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
-
- if( nDiff & (CSV_DIFF_HORIZONTAL | CSV_DIFF_RULERCURSOR) )
- {
- DisableRepaint();
- if( nDiff & CSV_DIFF_HORIZONTAL )
- {
- InitSizeData();
- if( GetRulerCursorPos() >= GetPosCount() )
- MoveCursor( GetPosCount() - 1 );
- }
- if( nDiff & CSV_DIFF_RULERCURSOR )
- {
- ImplInvertCursor( rOldData.mnPosCursor );
- ImplInvertCursor( GetRulerCursorPos() );
- }
- EnableRepaint();
- }
-}
-
-sal_Int32 ScCsvRuler::FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const
-{
- sal_Int32 nNewPos = nPos;
- if( nNewPos != POS_INVALID )
- {
- switch( eDir )
- {
- case MOVE_FIRST:
- nNewPos = Min( nPos, FindEmptyPos( 0, MOVE_NEXT ) );
- break;
- case MOVE_LAST:
- nNewPos = Max( nPos, FindEmptyPos( GetPosCount(), MOVE_PREV ) );
- break;
- case MOVE_PREV:
- while( HasSplit( --nNewPos ) );
- break;
- case MOVE_NEXT:
- while( HasSplit( ++nNewPos ) );
- break;
- }
- }
- return IsValidSplitPos( nNewPos ) ? nNewPos : POS_INVALID;
-}
-
void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
{
DisableRepaint();
@@ -168,6 +153,7 @@ void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
Execute( CSVCMD_MOVERULERCURSOR, IsVisibleSplitPos( nPos ) ? nPos : POS_INVALID );
EnableRepaint();
+ AccSendCaretEvent();
}
void ScCsvRuler::MoveCursorRel( ScMoveMode eDir )
@@ -212,6 +198,22 @@ void ScCsvRuler::MoveCursorToSplit( ScMoveMode eDir )
}
}
+void ScCsvRuler::ScrollVertRel( ScMoveMode eDir )
+{
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 1; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 1; break;
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
+}
+
+
+// split handling -------------------------------------------------------------
+
sal_Int32 ScCsvRuler::GetNoScrollPos( sal_Int32 nPos ) const
{
sal_Int32 nNewPos = nPos;
@@ -231,19 +233,6 @@ sal_Int32 ScCsvRuler::GetNoScrollPos( sal_Int32 nPos ) const
return nNewPos;
}
-void ScCsvRuler::ScrollVertRel( ScMoveMode eDir )
-{
- sal_Int32 nLine = GetFirstVisLine();
- switch( eDir )
- {
- case MOVE_PREV: --nLine; break;
- case MOVE_NEXT: ++nLine; break;
- case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 1; break;
- case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 1; break;
- }
- Execute( CSVCMD_SETLINEOFFSET, nLine );
-}
-
void ScCsvRuler::InsertSplit( sal_Int32 nPos )
{
if( maSplits.Insert( nPos ) )
@@ -290,6 +279,30 @@ void ScCsvRuler::RemoveAllSplits()
Repaint( true );
}
+sal_Int32 ScCsvRuler::FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != POS_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ nNewPos = Min( nPos, FindEmptyPos( 0, MOVE_NEXT ) );
+ break;
+ case MOVE_LAST:
+ nNewPos = Max( nPos, FindEmptyPos( GetPosCount(), MOVE_PREV ) );
+ break;
+ case MOVE_PREV:
+ while( HasSplit( --nNewPos ) );
+ break;
+ case MOVE_NEXT:
+ while( HasSplit( ++nNewPos ) );
+ break;
+ }
+ }
+ return IsValidSplitPos( nNewPos ) ? nNewPos : POS_INVALID;
+}
+
void ScCsvRuler::MoveCurrSplit( sal_Int32 nNewPos )
{
DisableRepaint();
@@ -308,64 +321,9 @@ void ScCsvRuler::MoveCurrSplitRel( ScMoveMode eDir )
}
}
-void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
-{
- mnPosMTStart = mnPosMTCurr = nPos;
- mbPosMTMoved = false;
- maOldSplits = maSplits;
- Execute( CSVCMD_INSERTSPLIT, nPos );
- if( HasSplit( nPos ) )
- StartTracking( STARTTRACK_BUTTONREPEAT );
-}
-
-void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
-{
- if( mnPosMTCurr != nPos )
- {
- DisableRepaint();
- MoveCursor( nPos );
- if( (mnPosMTCurr != mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) )
- Execute( CSVCMD_INSERTSPLIT, nPos );
- else
- Execute( CSVCMD_MOVESPLIT, mnPosMTCurr, nPos );
- mnPosMTCurr = nPos;
- mbPosMTMoved = true;
- EnableRepaint();
- }
-}
-
-void ScCsvRuler::EndMouseTracking( bool bApply )
-{
- if( bApply ) // tracking finished successfully
- {
- // remove on simple click on an existing split
- if( (mnPosMTCurr == mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) && !mbPosMTMoved )
- Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
- }
- else // tracking cancelled
- {
- MoveCursor( mnPosMTStart );
- // move split to origin
- if( maOldSplits.HasSplit( mnPosMTStart ) )
- MoveMouseTracking( mnPosMTStart );
- // remove temporarily inserted split
- else if( !maOldSplits.HasSplit( mnPosMTCurr ) )
- Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
- }
- mnPosMTStart = POS_INVALID;
-}
-
// event handling -------------------------------------------------------------
-void ScCsvRuler::SetPosSizePixel(
- sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_uInt16 nFlags )
-{
- if( nFlags & WINDOW_POSSIZE_HEIGHT )
- nHeight = GetTextHeight() + mnSplitSize + 2;
- ScCsvControl::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
-}
-
void ScCsvRuler::Resize()
{
ScCsvControl::Resize();
@@ -482,6 +440,53 @@ void ScCsvRuler::KeyInput( const KeyEvent& rKEvt )
ScCsvControl::KeyInput( rKEvt );
}
+void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
+{
+ mnPosMTStart = mnPosMTCurr = nPos;
+ mbPosMTMoved = false;
+ maOldSplits = maSplits;
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ if( HasSplit( nPos ) )
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+}
+
+void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
+{
+ if( mnPosMTCurr != nPos )
+ {
+ DisableRepaint();
+ MoveCursor( nPos );
+ if( (mnPosMTCurr != mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ else
+ Execute( CSVCMD_MOVESPLIT, mnPosMTCurr, nPos );
+ mnPosMTCurr = nPos;
+ mbPosMTMoved = true;
+ EnableRepaint();
+ }
+}
+
+void ScCsvRuler::EndMouseTracking( bool bApply )
+{
+ if( bApply ) // tracking finished successfully
+ {
+ // remove on simple click on an existing split
+ if( (mnPosMTCurr == mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) && !mbPosMTMoved )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ else // tracking cancelled
+ {
+ MoveCursor( mnPosMTStart );
+ // move split to origin
+ if( maOldSplits.HasSplit( mnPosMTStart ) )
+ MoveMouseTracking( mnPosMTStart );
+ // remove temporarily inserted split
+ else if( !maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ mnPosMTStart = POS_INVALID;
+}
+
// painting -------------------------------------------------------------------
@@ -620,5 +625,13 @@ void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos )
}
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvRuler::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvRuler( *this );
+}
+
+
// ============================================================================
diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx
index 03960b9fffdb..24842e9c07fa 100644
--- a/sc/source/ui/dbgui/csvtablebox.cxx
+++ b/sc/source/ui/dbgui/csvtablebox.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvtablebox.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:48:33 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:28:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -103,7 +103,46 @@ ScCsvTableBox::ScCsvTableBox( Window* pParent, const ResId& rResId ) :
}
-// initialization -------------------------------------------------------------
+// common table box handling --------------------------------------------------
+
+void ScCsvTableBox::SetSeparatorsMode()
+{
+ if( mbFixedMode )
+ {
+ // rescue data for fixed width mode
+ mnFixedWidth = GetPosCount();
+ maFixColStates = maGrid.GetColumnStates();
+ // switch to separators mode
+ mbFixedMode = false;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, 1 );
+ Execute( CSVCMD_NEWCELLTEXTS );
+ maGrid.SetColumnStates( maSepColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
+
+void ScCsvTableBox::SetFixedWidthMode()
+{
+ if( !mbFixedMode )
+ {
+ // rescue data for separators mode
+ maSepColStates = maGrid.GetColumnStates();
+ // switch to fixed width mode
+ mbFixedMode = true;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth );
+ maGrid.SetSplits( maRuler.GetSplits() );
+ maGrid.SetColumnStates( maFixColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
void ScCsvTableBox::Init()
{
@@ -190,56 +229,19 @@ void ScCsvTableBox::InitVScrollBar()
maVScroll.SetThumbPos( GetFirstVisLine() );
}
-void ScCsvTableBox::InitTypes( const ListBox& rListBox )
-{
- sal_uInt16 nTypeCount = rListBox.GetEntryCount();
- ScCsvStringVec aTypeNames( nTypeCount );
- for( sal_uInt16 nIndex = 0; nIndex < nTypeCount; ++nIndex )
- aTypeNames[ nIndex ] = rListBox.GetEntry( nIndex );
- maGrid.SetTypeNames( aTypeNames );
-}
-
-
-// control handling -----------------------------------------------------------
-
-void ScCsvTableBox::SetSeparatorsMode()
+void ScCsvTableBox::MakePosVisible( sal_Int32 nPos )
{
- if( mbFixedMode )
+ if( (0 <= nPos) && (nPos < GetPosCount()) )
{
- // rescue data for fixed width mode
- mnFixedWidth = GetPosCount();
- maFixColStates = maGrid.GetColumnStates();
- // switch to separators mode
- mbFixedMode = false;
- // reset and reinitialize controls
- DisableRepaint();
- Execute( CSVCMD_SETLINEOFFSET, 0 );
- Execute( CSVCMD_SETPOSCOUNT, 1 );
- Execute( CSVCMD_NEWCELLTEXTS );
- maGrid.SetColumnStates( maSepColStates );
- InitControls();
- EnableRepaint();
+ if( nPos - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - CSV_SCROLL_DIST );
+ else if( nPos + CSV_SCROLL_DIST >= GetLastVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - GetVisPosCount() + CSV_SCROLL_DIST + 1 );
}
}
-void ScCsvTableBox::SetFixedWidthMode()
-{
- if( !mbFixedMode )
- {
- // rescue data for separators mode
- maSepColStates = maGrid.GetColumnStates();
- // switch to fixed width mode
- mbFixedMode = true;
- // reset and reinitialize controls
- DisableRepaint();
- Execute( CSVCMD_SETLINEOFFSET, 0 );
- Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth );
- maGrid.SetSplits( maRuler.GetSplits() );
- maGrid.SetColumnStates( maFixColStates );
- InitControls();
- EnableRepaint();
- }
-}
+
+// cell contents --------------------------------------------------------------
void ScCsvTableBox::SetUniStrings(
const String* pTextLines, const String& rSepChars,
@@ -279,6 +281,18 @@ void ScCsvTableBox::SetByteStrings(
EnableRepaint();
}
+
+// column settings ------------------------------------------------------------
+
+void ScCsvTableBox::InitTypes( const ListBox& rListBox )
+{
+ sal_uInt16 nTypeCount = rListBox.GetEntryCount();
+ StringVec aTypeNames( nTypeCount );
+ for( sal_uInt16 nIndex = 0; nIndex < nTypeCount; ++nIndex )
+ aTypeNames[ nIndex ] = rListBox.GetEntry( nIndex );
+ maGrid.SetTypeNames( aTypeNames );
+}
+
void ScCsvTableBox::FillColumnData( ScAsciiOptions& rOptions ) const
{
if( mbFixedMode )
@@ -287,17 +301,6 @@ void ScCsvTableBox::FillColumnData( ScAsciiOptions& rOptions ) const
maGrid.FillColumnDataSep( rOptions );
}
-void ScCsvTableBox::MakePosVisible( sal_Int32 nPos )
-{
- if( (0 <= nPos) && (nPos < GetPosCount()) )
- {
- if( nPos - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
- Execute( CSVCMD_SETPOSOFFSET, nPos - CSV_SCROLL_DIST );
- else if( nPos + CSV_SCROLL_DIST >= GetLastVisPos() )
- Execute( CSVCMD_SETPOSOFFSET, nPos - GetVisPosCount() + CSV_SCROLL_DIST + 1 );
- }
-}
-
// event handling -------------------------------------------------------------
@@ -479,5 +482,19 @@ IMPL_LINK( ScCsvTableBox, ScrollEndHdl, ScrollBar*, pScrollBar )
}
+// accessibility --------------------------------------------------------------
+
+ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible()
+{
+ // do not use the ScCsvControl mechanism, return default accessible object
+ return Control::CreateAccessible();
+}
+
+ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible()
+{
+ return NULL; // not used, see CreateAccessible()
+}
+
+
// ============================================================================
diff --git a/sc/source/ui/inc/AccessibleCsvControl.hxx b/sc/source/ui/inc/AccessibleCsvControl.hxx
new file mode 100644
index 000000000000..dd73d4fb97a4
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleCsvControl.hxx
@@ -0,0 +1,769 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleCsvControl.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#define _SC_ACCESSIBLECSVCONTROL_HXX
+
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETEXT_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessibleText.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETABLE_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessibleTable.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESELECTION_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessibleSelection.hpp>
+#endif
+
+#ifndef _SV_GEN_HXX
+#include <vcl/gen.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
+#include "AccessibleContextBase.hxx"
+#endif
+
+
+// ============================================================================
+
+class ScCsvControl;
+namespace utl { class AccessibleStateSetHelper; }
+
+/** Accessible base class used for CSV controls. */
+class ScAccessibleCsvControl : public ScAccessibleContextBase
+{
+protected:
+ typedef ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::accessibility::XAccessible > XAccessibleRef;
+ typedef ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::accessibility::XAccessibleRelationSet > XAccessibleRelationSetRef;
+ typedef ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::accessibility::XAccessibleStateSet > XAccessibleStateSetRef;
+
+ typedef ::com::sun::star::awt::Point AwtPoint;
+ typedef ::com::sun::star::awt::Size AwtSize;
+ typedef ::com::sun::star::awt::Rectangle AwtRectangle;
+
+private:
+ ScCsvControl* mpControl; /// Pointer to the VCL control.
+
+public:
+ explicit ScAccessibleCsvControl(
+ const XAccessibleRef& rxParent,
+ ScCsvControl& rControl,
+ sal_uInt16 nRole );
+ virtual ~ScAccessibleCsvControl();
+ virtual void SAL_CALL disposing();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Returns the child at the specified point (cell returns NULL). */
+ virtual XAccessibleRef SAL_CALL getAccessibleAt( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the control is visible. */
+ virtual sal_Bool SAL_CALL isVisible() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Sets the focus to this control. */
+ virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a GetFocus or LoseFocus event to all listeners. */
+ virtual void SendFocusEvent( bool bFocused );
+ /** Sends a caret changed event to all listeners. */
+ virtual void SendCaretEvent();
+ /** Sends a selection changed event to all listeners. */
+ virtual void SendSelectionEvent();
+ /** Sends a table model changed event for changed cell contents to all listeners. */
+ virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
+ /** Sends a table model changed event for an inserted column to all listeners. */
+ virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to all listeners. */
+ virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's current bounding box relative to the desktop. */
+ virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's current bounding box relative to the parent object. */
+ virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Creates a new UUID in rSeq, if it is empty. Locks mutex internally. */
+ void getUuid( ::com::sun::star::uno::Sequence< sal_Int8 >& rSeq );
+
+ /** Returns whether the object is alive. Must be called with locked mutex. */
+ inline bool implIsAlive() const { return !rBHelper.bDisposed && !rBHelper.bInDispose && mpControl; }
+ /** Throws an exception, if the object is disposed/disposing or any pointer
+ is missing. Should be used with locked mutex! */
+ void ensureAlive() const throw( ::com::sun::star::lang::DisposedException );
+
+ /** Returns the VCL control. Assumes a living object. */
+ ScCsvControl& implGetControl() const;
+
+ /** Returns the first child of rxParentObj, which has the role nRole. */
+ XAccessibleRef implGetChildByRole( const XAccessibleRef& rxParentObj, sal_uInt16 nRole )
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
+ ::utl::AccessibleStateSetHelper* implCreateStateSet();
+
+ /** Disposes the object. This is a helper called from destructors only. */
+ void implDispose();
+
+ /** Converts the screen position rPos to a position relative to this control. */
+ Point implGetRelPos( const Point& rPos ) const;
+ /** Converts the control-relative position to an absolute screen position. */
+ Point implGetAbsPos( const Point& rPos ) const;
+};
+
+
+// ============================================================================
+
+class ScCsvRuler;
+
+typedef ::cppu::ImplHelper1<
+ ::drafts::com::sun::star::accessibility::XAccessibleText >
+ ScAccessibleCsvRulerImpl;
+
+/** Accessible class representing the CSV ruler control. */
+class ScAccessibleCsvRuler : public ScAccessibleCsvControl, public ScAccessibleCsvRulerImpl
+{
+protected:
+ typedef ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > PropertyValueSeq;
+
+private:
+ ::rtl::OUStringBuffer maBuffer; /// Contains the text representation of the ruler.
+
+public:
+ explicit ScAccessibleCsvRuler( ScCsvRuler& rRuler );
+ virtual ~ScAccessibleCsvRuler();
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count (the ruler does not have children). */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception (the ruler does not have childern). */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the grid control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleText --------------------------------------------------------
+
+ /** Return the position of the caret. */
+ virtual sal_Int32 SAL_CALL getCaretPosition() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Sets the position of the caret. */
+ virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified character. */
+ virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the attributes of the specified character. */
+ virtual PropertyValueSeq SAL_CALL getCharacterAttributes( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the screen coordinates of the specified character. */
+ virtual AwtRectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the count of characters. */
+ virtual sal_Int32 SAL_CALL getCharacterCount() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the character index at the specified screen coordinate. */
+ virtual sal_Int32 SAL_CALL getIndexAtPoint( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected text (ruler returns empty string). */
+ virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the start index of the selection (ruler returns -1). */
+ virtual sal_Int32 SAL_CALL getSelectionStart() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the end index of the selection (ruler returns -1). */
+ virtual sal_Int32 SAL_CALL getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Selects a part of the text (ruler does nothing). */
+ virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the entire text. */
+ virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified range [Start,End) of the text. */
+ virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified text portion. */
+ virtual ::rtl::OUString SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Copies the specified text range into the clipboard (ruler does nothing). */
+ virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider ----------------------------------------------------------
+
+ /** Returns a sequence with all supported interface types. */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns an implementation ID. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a caret changed event to all listeners. */
+ virtual void SendCaretEvent();
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception, if the specified character position is invalid. */
+ void ensureValidIndex( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified character range [Start,End) is invalid.
+ @descr If Start>End, swaps Start and End before checking. */
+ void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Returns the VCL ruler control. Assumes a living object. */
+ ScCsvRuler& implGetRuler() const;
+
+ /** Builds the entire string buffer. */
+ void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns the character count of the text. */
+ sal_Int32 implGetTextLength() const;
+
+ /** Returns true, if the character at the specified index has a split. */
+ bool implHasSplit( sal_Int32 nApiPos );
+
+ /** Returns the first character index with equal formatting as at nApiPos. */
+ sal_Int32 implGetFirstEqualFormatted( sal_Int32 nApiPos );
+ /** Returns the last character index with equal formatting as at nApiPos. */
+ sal_Int32 implGetLastEqualFormatted( sal_Int32 nApiPos );
+};
+
+
+// ============================================================================
+
+class ScCsvGrid;
+
+typedef ::cppu::ImplHelper2<
+ ::drafts::com::sun::star::accessibility::XAccessibleTable,
+ ::drafts::com::sun::star::accessibility::XAccessibleSelection >
+ ScAccessibleCsvGridImpl;
+
+/** Accessible class representing the CSV grid control. */
+class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCsvGridImpl
+{
+protected:
+ typedef ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::accessibility::XAccessibleTable > XAccessibleTableRef;
+
+public:
+ explicit ScAccessibleCsvGrid( ScCsvGrid& rGrid );
+ virtual ~ScAccessibleCsvGrid();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Returns the cell at the specified point. */
+ virtual XAccessibleRef SAL_CALL getAccessibleAt( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count (count of cells in the table). */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified child cell. */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the ruler control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleTable -------------------------------------------------------
+
+ /** Returns the number of rows in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleRowCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of columns in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleColumnCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the description of the specified row in the table. */
+ virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the description text of the specified column in the table. */
+ virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of rows occupied at a specified row and column.
+ @descr Returns always 1 (Merged cells not supported). */
+ virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of rows occupied at a specified row and column.
+ @descr Returns always 1 (Merged cells not supported). */
+ virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the row headers as an AccessibleTable. */
+ virtual XAccessibleTableRef SAL_CALL getAccessibleRowHeaders()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the column headers as an AccessibleTable. */
+ virtual XAccessibleTableRef SAL_CALL getAccessibleColumnHeaders()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected rows as a sequence. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected columns as a sequence. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /**Returns true, if the specified row is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the specified column is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the accessible cell object at the specified position. */
+ virtual XAccessibleRef SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the caption object of the table. */
+ virtual XAccessibleRef SAL_CALL getAccessibleCaption()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the summary description object of the table. */
+ virtual XAccessibleRef SAL_CALL getAccessibleSummary()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the cell at a specified position is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleExtendedTable -----------------------------------------------
+
+ /** Returns the child index of the cell at the specified position. */
+ virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the row index of the specified child. */
+ virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the column index of the specified child. */
+ virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleSelection ---------------------------------------------------
+
+ /** Selects the specified child (selects the entire column or the entire table). */
+ virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the specified child is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Deselects all cells. */
+ virtual void SAL_CALL clearAccessibleSelection()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Selects all cells. */
+ virtual void SAL_CALL selectAllAccessible()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the count of selected children. */
+ virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the child with the specified index in all selected children. */
+ virtual XAccessibleRef SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Deselects the child with the specified index in all selected children. */
+ virtual void SAL_CALL deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider ----------------------------------------------------------
+
+ /** Returns a sequence with all supported interface types. */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns an implementation ID. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a GetFocus or LoseFocus event to all listeners. */
+ virtual void SendFocusEvent( bool bFocused );
+ /** Sends a table model changed event for changed cell contents to all listeners. */
+ virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
+ /** Sends a table model changed event for an inserted column to all listeners. */
+ virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to all listeners. */
+ virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception, if nIndex is not a valid child index. */
+ void ensureValidIndex( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified position is invalid. */
+ void ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Returns the VCL grid control. Assumes a living object. */
+ ScCsvGrid& implGetGrid() const;
+
+ /** Returns true, if the specified column (including header) is selected. */
+ bool implIsColumnSelected( sal_Int32 nColumn ) const;
+ /** Selects the specified column (including header). */
+ void implSelectColumn( sal_Int32 nColumn, bool bSelect );
+
+ /** Returns the count of visible rows in the table (including header). */
+ sal_Int32 implGetRowCount() const;
+ /** Returns the total column count in the table (including header). */
+ sal_Int32 implGetColumnCount() const;
+ /** Returns the count of selected columns in the table. */
+ sal_Int32 implGetSelColumnCount() const;
+ /** Returns the total cell count in the table (including header). */
+ inline sal_Int32 implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
+
+ /** Returns the row index from cell index (including header). */
+ inline sal_Int32 implGetRow( sal_Int32 nIndex ) const { return nIndex / implGetColumnCount(); }
+ /** Returns the column index from cell index (including header). */
+ inline sal_Int32 implGetColumn( sal_Int32 nIndex ) const { return nIndex % implGetColumnCount(); }
+ /** Returns the absolute column index of the nSelColumn-th selected column. */
+ sal_Int32 implGetSelColumn( sal_Int32 nSelColumn ) const;
+ /** Returns the child index from cell position (including header). */
+ inline sal_Int32 implGetIndex( sal_Int32 nRow, sal_Int32 nColumn ) const { return nRow * implGetColumnCount() + nColumn; }
+
+ /** Returns the contents of the specified cell (including header). Indexes must be valid. */
+ ::rtl::OUString implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const;
+ /** Creates a new accessible object of the specified cell. Indexes must be valid. */
+ ScAccessibleCsvControl* implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const;
+};
+
+
+// ============================================================================
+
+typedef ::cppu::ImplHelper1<
+ ::drafts::com::sun::star::accessibility::XAccessibleText >
+ ScAccessibleCsvCellImpl;
+
+/** Accessible class representing a cell of the CSV grid control. */
+class ScAccessibleCsvCell : public ScAccessibleCsvControl, public ScAccessibleCsvCellImpl
+{
+protected:
+ typedef ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > PropertyValueSeq;
+
+private:
+ ::rtl::OUString maCellText; /// The text contents of this cell.
+ sal_Int32 mnLine; /// The grid line index (core index).
+ sal_uInt32 mnColumn; /// The grid column index (core index).
+ sal_Int32 mnIndex; /// The index of the cell in the table.
+
+public:
+ explicit ScAccessibleCsvCell(
+ ScCsvGrid& rGrid,
+ const ::rtl::OUString& rCellText,
+ sal_Int32 nRow, sal_Int32 nColumn );
+ virtual ~ScAccessibleCsvCell();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Sets the focus to the column of this cell. */
+ virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count (count of cells in the table). */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified child cell. */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the index of this cell in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the ruler control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleText --------------------------------------------------------
+
+ /** Return the position of the caret (not supported). */
+ virtual sal_Int32 SAL_CALL getCaretPosition() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Sets the position of the caret (not supported). */
+ virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified character. */
+ virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the attributes of the specified character. */
+ virtual PropertyValueSeq SAL_CALL getCharacterAttributes( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the screen coordinates of the specified character. */
+ virtual AwtRectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the count of characters. */
+ virtual sal_Int32 SAL_CALL getCharacterCount() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the character index at the specified screen coordinate. */
+ virtual sal_Int32 SAL_CALL getIndexAtPoint( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected text (not supported). */
+ virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the start index of the selection (not supported). */
+ virtual sal_Int32 SAL_CALL getSelectionStart() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the end index of the selection (not supported). */
+ virtual sal_Int32 SAL_CALL getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Selects a part of the text (not supported). */
+ virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the entire text. */
+ virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified range [Start,End) of the text. */
+ virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified text portion. */
+ virtual ::rtl::OUString SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Copies the specified text range into the clipboard (not supported). */
+ virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider ----------------------------------------------------------
+
+ /** Returns a sequence with all supported interface types. */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns an implementation ID. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's current bounding box relative to the desktop. */
+ virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's current bounding box relative to the parent object. */
+ virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the bounding box of the cell. */
+ Rectangle implGetBoundingBox() const;
+
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception, if the specified character position is invalid. */
+ void ensureValidIndex( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified character range [Start,End) is invalid.
+ @descr If Start>End, swaps Start and End before checking. */
+ void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Returns the VCL grid control. Assumes a living object. */
+ ScCsvGrid& implGetGrid() const;
+};
+
+
+// ============================================================================
+
+#endif
+
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index a5da489df339..ff9628879a58 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: asciiopt.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:47:39 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -147,7 +147,7 @@ public:
void SetStartRow( long nRow) { nStartRow= nRow; }
void SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat );
- void SetColumnInfo( const ScCsvExtColPosVec& rColPosVec, const ScCsvExtColTypeVec& rColTypeVec );
+ void SetColumnInfo( const ScCsvExpDataVec& rDataVec );
};
diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx
index 47a0c7fb5b1a..54639893119e 100644
--- a/sc/source/ui/inc/csvcontrol.hxx
+++ b/sc/source/ui/inc/csvcontrol.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvcontrol.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:47:40 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,18 +75,18 @@
#include "csvsplits.hxx"
#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
-// ============================================================================
-
-typedef ::std::vector< String > ScCsvStringVec;
-typedef ::std::vector< ScCsvStringVec > ScCsvStringVecVec;
-// types for exported data
-typedef ::std::vector< xub_StrLen > ScCsvExtColPosVec;
-typedef ::std::vector< sal_uInt8 > ScCsvExtColTypeVec;
+class ScAccessibleCsvControl;
+namespace drafts { namespace com { namespace sun { namespace star { namespace accessibility {
+ class XAccessible;
+} } } } }
-// ----------------------------------------------------------------------------
+// ============================================================================
/** Minimum character count for a column in separators mode. */
const sal_Int32 CSV_MINCOLWIDTH = 8;
@@ -121,6 +121,22 @@ const sal_uInt8 SC_COL_ENGLISH = 10;
// ============================================================================
+/** Exported data of a column (data used in the dialog). */
+struct ScCsvExpData
+{
+ xub_StrLen mnIndex; /// Index of a column.
+ sal_uInt8 mnType; /// External type of the column.
+
+ inline ScCsvExpData() : mnIndex( 0 ), mnType( SC_COL_STANDARD ) {}
+ inline ScCsvExpData( xub_StrLen nIndex, sal_uInt8 nType ) :
+ mnIndex( nIndex ), mnType( nType ) {}
+};
+
+typedef ::std::vector< ScCsvExpData > ScCsvExpDataVec;
+
+
+// ============================================================================
+
/** Specifies which element should be used to perform an action. */
enum ScMoveMode
{
@@ -184,7 +200,7 @@ struct ScCsvLayoutData
mutable sal_Int32 mnNoRepaint; /// >0 = no repaint.
- ScCsvLayoutData();
+ explicit ScCsvLayoutData();
/** Returns differences to rData.
@descr For each difference the appropriate bit is set in the returned value. */
@@ -260,7 +276,7 @@ private:
sal_Int32 mnParam2; /// Second parameter.
public:
- inline ScCsvCmd() : meType( CSVCMD_NONE ),
+ inline explicit ScCsvCmd() : meType( CSVCMD_NONE ),
mnParam1( POS_INVALID ), mnParam2( POS_INVALID ) {}
inline void Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 );
@@ -281,19 +297,46 @@ inline void ScCsvCmd::Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nPar
/** Base class for the CSV ruler and the data grid control. Implements command handling. */
class ScCsvControl : public Control
{
+protected:
+ typedef ::std::vector< String > StringVec;
+ typedef ::std::vector< StringVec > StringVecVec;
+
+ typedef ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::accessibility::XAccessible > XAccessibleRef;
+
private:
Link maCmdHdl; /// External command handler.
ScCsvCmd maCmd; /// Data of last command.
-
const ScCsvLayoutData& mrData; /// Shared layout data.
+ XAccessibleRef mxAccessible; /// The accessible object of the control.
+ ScAccessibleCsvControl* mpAccessible; /// Pointer to the accessible implementation object.
bool mbValidGfx; /// Content of virtual devices valid?
// ------------------------------------------------------------------------
public:
- ScCsvControl( ScCsvControl& rParent );
- ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle = 0 );
- ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId );
+ explicit ScCsvControl( ScCsvControl& rParent );
+ explicit ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle = 0 );
+ explicit ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId );
+ virtual ~ScCsvControl();
+
+ // event handling ---------------------------------------------------------
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ /** Sends a GetFocus or LoseFocus event to the accessibility object. */
+ void AccSendFocusEvent( bool bFocused );
+ /** Sends a caret changed event to the accessibility object. */
+ void AccSendCaretEvent();
+ /** Sends a selection changed event to the accessibility object. */
+ void AccSendSelectionEvent();
+ /** Sends a table model changed event for changed cell contents to the accessibility object. */
+ void AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows = true );
+ /** Sends a table model changed event for an inserted column to the accessibility object. */
+ void AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to the accessibility object. */
+ void AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
// repaint helpers --------------------------------------------------------
@@ -382,6 +425,8 @@ public:
inline sal_Int32 GetLineHeight() const { return mrData.mnLineHeight; }
/** Returns output Y coordinate of the specified line. */
sal_Int32 GetY( sal_Int32 nLine ) const;
+ /** Returns line index from output coordinate. */
+ sal_Int32 GetLineFromY( sal_Int32 nY ) const;
/** Returns the ruler cursor position. */
inline sal_Int32 GetRulerCursorPos() const { return mrData.mnPosCursor; }
@@ -399,6 +444,16 @@ public:
/** Returns direction code for the keys UP, DOWN, HOME, END, PAGE UP, PAGE DOWN.
@param bHomeEnd false = ignore HOME and END key. */
static ScMoveMode GetVertDirection( sal_uInt16 nCode, bool bHomeEnd );
+
+ // accessibility ----------------------------------------------------------
+public:
+ /** Creates and returns the accessible object of this control. Do not overwrite in
+ derived classes, use ImplCreateAccessible() instead. */
+ virtual XAccessibleRef CreateAccessible();
+
+protected:
+ /** Derived classes create a new accessible object here. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible() = NULL;
};
diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx
index ca0c4fd68171..7646de2bf046 100644
--- a/sc/source/ui/inc/csvgrid.hxx
+++ b/sc/source/ui/inc/csvgrid.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvgrid.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:47:40 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,6 +90,7 @@
namespace svx { class ColorConfig; }
class ScEditEngineDefaulter;
class ScAsciiOptions;
+class ScAccessibleCsvControl;
// ============================================================================
@@ -138,7 +139,7 @@ typedef ::std::vector< ScCsvColState > ScCsvColStateVec;
class ScCsvGrid : public ScCsvControl, public SfxListener
{
private:
- typedef ::std::auto_ptr< ScEditEngineDefaulter > ScEditEnginePtr;
+ typedef ::std::auto_ptr< ScEditEngineDefaulter > ScEditEnginePtr;
VirtualDevice maBackgrDev; /// Grid background, headers, cell texts.
VirtualDevice maGridDev; /// Data grid with selection and cursor.
@@ -161,8 +162,8 @@ private:
ScCsvSplits maSplits; /// Vector with split positions.
ScCsvColStateVec maColStates; /// State of each column.
- ScCsvStringVec maTypeNames; /// UI names of data types.
- ScCsvStringVecVec maTexts; /// 2D-vector for cell texts.
+ StringVec maTypeNames; /// UI names of data types.
+ StringVecVec maTexts; /// 2D-vector for cell texts.
sal_Int32 mnFirstImpLine; /// First imported line (0-based).
sal_uInt32 mnRecentSelCol; /// Index of most recently selected column.
@@ -171,14 +172,11 @@ private:
// ------------------------------------------------------------------------
public:
- ScCsvGrid( ScCsvControl& rParent );
+ explicit ScCsvGrid( ScCsvControl& rParent );
virtual ~ScCsvGrid();
- // grid handling ----------------------------------------------------------
-
- /** Redraws the entire data grid. */
- void ImplRedraw();
-
+ // common grid handling ---------------------------------------------------
+public:
/** Updates layout data dependent from the control's state. */
void UpdateLayoutData();
/** Updates X coordinate of first visible position dependent from line numbers. */
@@ -191,6 +189,16 @@ public:
/** Finds a column position nearest to nPos which does not cause scrolling the visible area. */
sal_Int32 GetNoScrollCol( sal_Int32 nPos ) const;
+private:
+ /** Reads colors from system settings. */
+ void InitColors();
+ /** Initializes all font settings. */
+ void InitFonts();
+ /** Initializes all data dependent from the control's size. */
+ void InitSizeData();
+
+ // split handling ---------------------------------------------------------
+public:
/** Inserts a split. */
void InsertSplit( sal_Int32 nPos );
/** Removes a split. */
@@ -202,54 +210,7 @@ public:
/** Removes all splits and inserts the splits from rSplits. */
void SetSplits( const ScCsvSplits& rSplits );
- /** Returns the vector with the states of all columns. */
- inline const ScCsvColStateVec& GetColumnStates() const { return maColStates; }
- /** Sets all column states to the values in the passed vector. */
- void SetColumnStates( const ScCsvColStateVec& rColStates );
- /** Returns the data type of the selected columns (or -1, if different types are selected). */
- sal_Int32 GetSelColumnType() const;
- /** Changes the data type of all selected columns. */
- void SetSelColumnType( sal_Int32 nType );
- /** Sets new UI data type names. */
- void SetTypeNames( const ScCsvStringVec& rTypeNames );
-
- /** Fills all cells of a line with the passed text (separators mode). */
- void ImplSetTextLineSep(
- sal_Int32 nLine, const String& rTextLine,
- const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
- /** Fills all cells of a line with the passed text (fixed width mode). */
- void ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine );
-
- /** Fills the options object with column data for separators mode. */
- void FillColumnDataSep( ScAsciiOptions& rOptions ) const;
- /** Fills the options object with column data for fixed width mode. */
- void FillColumnDataFix( ScAsciiOptions& rOptions ) const;
-
- // event handling ---------------------------------------------------------
-protected:
- virtual void Resize();
- virtual void GetFocus();
- virtual void LoseFocus();
-
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void Tracking( const TrackingEvent& rTEvt );
- virtual void KeyInput( const KeyEvent& rKEvt );
- virtual void Command( const CommandEvent& rCEvt );
-
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
- virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
-
- // initialization ---------------------------------------------------------
private:
- /** Reads colors from system settings. */
- void InitColors();
- /** Initializes all font settings. */
- void InitFonts();
- /** Initializes all data dependent from the control's size. */
- void InitSizeData();
-
- // grid handling ----------------------------------------------------------
-
/** Inserts a split and adjusts column data. */
bool ImplInsertSplit( sal_Int32 nPos );
/** Removes a split and adjusts column data. */
@@ -257,14 +218,10 @@ private:
/** Clears the split array and re-inserts boundary splits. */
void ImplClearSplits();
+ // columns/column types ---------------------------------------------------
+public:
/** Returns the number of columns. */
inline sal_uInt32 GetColumnCount() const { return maColStates.size(); }
- /** Returns start position of the column with the specified index. */
- inline sal_Int32 GetColumnPos( sal_uInt32 nColIndex ) const { return maSplits[ nColIndex ]; }
- /** Returns the character width of the column with the specified index. */
- sal_Int32 GetColumnWidth( sal_uInt32 nColIndex ) const;
- /** Returns column index from position. A split counts to its following column. */
- sal_uInt32 GetColumnFromPos( sal_Int32 nPos ) const;
/** Returns the index of the first visible column. */
sal_uInt32 GetFirstVisColumn() const;
/** Returns the index of the last visible column. */
@@ -279,15 +236,37 @@ private:
sal_Int32 GetColumnX( sal_uInt32 nColIndex ) const;
/** Returns column index from output coordinate. */
sal_uInt32 GetColumnFromX( sal_Int32 nX ) const;
- /** Returns column index from output coordinate, jumps to previous/next column, if nX is out of bounds. */
- sal_uInt32 GetTrackingColumnFromX( sal_Int32 nX ) const;
+ /** Returns start position of the column with the specified index. */
+ inline sal_Int32 GetColumnPos( sal_uInt32 nColIndex ) const { return maSplits[ nColIndex ]; }
+ /** Returns column index from position. A split counts to its following column. */
+ sal_uInt32 GetColumnFromPos( sal_Int32 nPos ) const;
+ /** Returns the character width of the column with the specified index. */
+ sal_Int32 GetColumnWidth( sal_uInt32 nColIndex ) const;
+
+ /** Returns the vector with the states of all columns. */
+ inline const ScCsvColStateVec& GetColumnStates() const { return maColStates; }
+ /** Sets all column states to the values in the passed vector. */
+ void SetColumnStates( const ScCsvColStateVec& rColStates );
+ /** Returns the data type of the selected columns. */
+ sal_Int32 GetSelColumnType() const;
+ /** Changes the data type of all selected columns. */
+ void SetSelColumnType( sal_Int32 nType );
+ /** Sets new UI data type names. */
+ void SetTypeNames( const StringVec& rTypeNames );
+ /** Returns the UI type name of the specified column. */
+ const String& GetColumnTypeName( sal_uInt32 nColIndex ) const;
+
+ /** Fills the options object with column data for separators mode. */
+ void FillColumnDataSep( ScAsciiOptions& rOptions ) const;
+ /** Fills the options object with column data for fixed width mode. */
+ void FillColumnDataFix( ScAsciiOptions& rOptions ) const;
+
+private:
/** Returns the data type of the specified column. */
sal_Int32 GetColumnType( sal_uInt32 nColIndex ) const;
/** Returns the data type of the specified column. */
void SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType );
- /** Returns the UI type name of the specified column. */
- const String& GetColumnTypeName( sal_uInt32 nColIndex ) const;
/** Scrolls data grid vertically. */
void ScrollVertRel( ScMoveMode eDir );
@@ -295,17 +274,7 @@ private:
void ExecutePopup( const Point& rPos );
// selection handling -----------------------------------------------------
-
- /** Returns index of the focused column. */
- inline sal_uInt32 GetFocusColumn() const { return GetColumnFromPos( GetGridCursorPos() ); }
- /** Moves column cursor to a new position. */
- void MoveCursor( sal_uInt32 nColIndex );
- /** Moves column cursor to the given direction. */
- void MoveCursorRel( ScMoveMode eDir );
-
- /** Clears the entire selection without notify. */
- void ImplClearSelection();
-
+public:
/** Returns true, if the specified column is selected. */
bool IsSelected( sal_uInt32 nColIndex ) const;
/** Returns index of the first selected column. */
@@ -321,16 +290,58 @@ private:
void ToggleSelect( sal_uInt32 nColIndex );
/** Selects or deselects the specified column range. */
void SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect = true );
- /** Selects all columns. */
- inline void SelectAll() { SelectRange( 0, GetColumnCount() - 1 ); }
+ /** Selects or deselects all columns. */
+ void SelectAll( bool bSelect = true );
+
+ /** Returns index of the focused column. */
+ inline sal_uInt32 GetFocusColumn() const { return GetColumnFromPos( GetGridCursorPos() ); }
+
+private:
+ /** Moves column cursor to a new position. */
+ void MoveCursor( sal_uInt32 nColIndex );
+ /** Moves column cursor to the given direction. */
+ void MoveCursorRel( ScMoveMode eDir );
+
+ /** Clears the entire selection without notify. */
+ void ImplClearSelection();
/** Executes selection action for a specific column. */
void DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier );
+ // cell contents ----------------------------------------------------------
+public:
+ /** Fills all cells of a line with the passed text (separators mode). */
+ void ImplSetTextLineSep(
+ sal_Int32 nLine, const String& rTextLine,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
+ /** Fills all cells of a line with the passed text (fixed width mode). */
+ void ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine );
+
+ /** Returns the text of the specified cell. */
+ const String& GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const;
+
+ // event handling ---------------------------------------------------------
+protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
// painting ---------------------------------------------------------------
protected:
virtual void Paint( const Rectangle& );
+public:
+ /** Redraws the entire data grid. */
+ void ImplRedraw();
+
private:
/** Returns the width of the control. */
inline sal_Int32 GetWidth() const { return maWinSize.Width(); }
@@ -369,6 +380,11 @@ private:
/** Draws directly tracking rectangle to the column with the specified index. */
void ImplDrawTrackingRect( sal_uInt32 nColIndex );
+
+ // accessibility ----------------------------------------------------------
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
};
diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx
index 6c861673fe4e..4c3c91e1775c 100644
--- a/sc/source/ui/inc/csvruler.hxx
+++ b/sc/source/ui/inc/csvruler.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvruler.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:47:41 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,6 +76,9 @@
#endif
+class ScAccessibleCsvControl;
+
+
// ============================================================================
/** A ruler control for the CSV import dialog. Supports setting and moving
@@ -105,13 +108,10 @@ private:
// ------------------------------------------------------------------------
public:
- ScCsvRuler( ScCsvControl& rParent );
-
- // ruler handling ---------------------------------------------------------
-
- /** Redraws the entire ruler. */
- void ImplRedraw();
+ explicit ScCsvRuler( ScCsvControl& rParent );
+ // common ruler handling --------------------------------------------------
+public:
/** Sets position and size of the ruler. The height is calculated internally. */
virtual void SetPosSizePixel(
sal_Int32 nX, sal_Int32 nY,
@@ -121,6 +121,24 @@ public:
/** Apply current layout data to the ruler. */
void ApplyLayout( const ScCsvLayoutData& rOldData );
+private:
+ /** Reads colors from system settings. */
+ void InitColors();
+ /** Initializes all data dependent from the control's size. */
+ void InitSizeData();
+
+ /** Moves cursor to a new position.
+ @param bScroll TRUE = The method may scroll the ruler. */
+ void MoveCursor( sal_Int32 nPos, bool bScroll = true );
+ /** Moves cursor to the given direction. */
+ void MoveCursorRel( ScMoveMode eDir );
+ /** Sets cursor to an existing split, according to eDir. */
+ void MoveCursorToSplit( ScMoveMode eDir );
+ /** Scrolls data grid vertically. */
+ void ScrollVertRel( ScMoveMode eDir );
+
+ // split handling ---------------------------------------------------------
+public:
/** Returns the split array. */
inline const ScCsvSplits& GetSplits() const { return maSplits; }
/** Returns the number of splits. */
@@ -145,6 +163,15 @@ public:
/** Removes all splits of the ruler. */
void RemoveAllSplits();
+private:
+ /** Finds next position without a split. */
+ sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
+
+ /** Moves split and cursor to nNewPos and commits event. */
+ void MoveCurrSplit( sal_Int32 nNewPos );
+ /** Moves split and cursor to the given direction and commits event. */
+ void MoveCurrSplitRel( ScMoveMode eDir );
+
// event handling ---------------------------------------------------------
protected:
virtual void Resize();
@@ -158,36 +185,7 @@ protected:
virtual void KeyInput( const KeyEvent& rKEvt );
- // initialization ---------------------------------------------------------
private:
- /** Reads colors from system settings. */
- void InitColors();
- /** Initializes all data dependent from the control's size. */
- void InitSizeData();
-
- // ruler handling ---------------------------------------------------------
-
- /** Returns the height the ruler needs to draw itself. */
- sal_Int32 GetRequiredHeight() const;
-
- /** Finds next position without a split. */
- sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
-
- /** Moves cursor to a new position.
- @param bScroll TRUE = The method may scroll the ruler. */
- void MoveCursor( sal_Int32 nPos, bool bScroll = true );
- /** Moves cursor to the given direction. */
- void MoveCursorRel( ScMoveMode eDir );
- /** Sets cursor to an existing split, according to eDir. */
- void MoveCursorToSplit( ScMoveMode eDir );
- /** Scrolls data grid vertically. */
- void ScrollVertRel( ScMoveMode eDir );
-
- /** Moves split and cursor to nNewPos and commits event. */
- void MoveCurrSplit( sal_Int32 nNewPos );
- /** Moves split and cursor to the given direction and commits event. */
- void MoveCurrSplitRel( ScMoveMode eDir );
-
/** Starts tracking at the specified position. */
void StartMouseTracking( sal_Int32 nPos );
/** Moves tracking to a new position. */
@@ -200,6 +198,10 @@ private:
protected:
virtual void Paint( const Rectangle& );
+public:
+ /** Redraws the entire ruler. */
+ void ImplRedraw();
+
private:
/** Returns the width of the control. */
inline sal_Int32 GetWidth() const { return maWinSize.Width(); }
@@ -225,6 +227,11 @@ private:
/** Sets arrow or horizontal split pointer. */
void ImplSetMousePointer( sal_Int32 nPos );
+
+ // accessibility ----------------------------------------------------------
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
};
diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx
index 0ddbe926fcbf..4d7acae72913 100644
--- a/sc/source/ui/inc/csvtablebox.hxx
+++ b/sc/source/ui/inc/csvtablebox.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: csvtablebox.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dr $ $Date: 2002-08-01 12:47:42 $
+ * last change: $Author: dr $ $Date: 2002-08-15 09:29:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,8 +82,6 @@
#endif
-// ----------------------------------------------------------------------------
-
class ListBox;
class ScAsciiOptions;
@@ -120,51 +118,16 @@ private:
// ------------------------------------------------------------------------
public:
- ScCsvTableBox( Window* pParent );
- ScCsvTableBox( Window* pParent, const ResId& rResId );
-
- // initialization ---------------------------------------------------------
-
- /** Reads UI strings for data types from the list box. */
- void InitTypes( const ListBox& rListBox );
-
- /** Sets a new handler for "update cell texts" requests. */
- inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; }
- /** Returns the handler for "update cell texts" requests. */
- inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; }
- /** Sets a new handler for "column selection changed" events. */
- inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; }
- /** Returns the handler for "column selection changed" events. */
- inline const Link& GetColTypeHdl() const { return maColTypeHdl; }
-
- // control handling -------------------------------------------------------
+ explicit ScCsvTableBox( Window* pParent );
+ explicit ScCsvTableBox( Window* pParent, const ResId& rResId );
+ // common table box handling ----------------------------------------------
+public:
/** Sets the control to separators mode. */
void SetSeparatorsMode();
/** Sets the control to fixed width mode. */
void SetFixedWidthMode();
- /** Returns the data type of the selected columns. */
- inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); }
-
- /** Fills all cells of all lines with the passed texts (Unicode strings). */
- void SetUniStrings(
- const String* pTextLines, const String& rSepChars,
- sal_Unicode cTextSep, bool bMergeSep );
- /** Fills all cells of all lines with the passed texts (ByteStrings). */
- void SetByteStrings(
- const ByteString* pLineTexts, CharSet eCharSet,
- const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
-
- /** Fills the options object with current column data. */
- void FillColumnData( ScAsciiOptions& rOptions ) const;
-
- // event handling ---------------------------------------------------------
-protected:
- virtual void Resize();
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
-
- // initialization ---------------------------------------------------------
private:
/** Initialisation on construction. */
void Init();
@@ -175,8 +138,6 @@ private:
/** Initializes size and position data of vertical scrollbar. */
void InitVScrollBar();
- // control handling -------------------------------------------------------
-
/** Calculates and sets valid position offset nearest to nPos. */
inline void ImplSetPosOffset( sal_Int32 nPos )
{ maData.mnPosOffset = Max( Min( nPos, GetMaxPosOffset() ), 0L ); }
@@ -186,11 +147,55 @@ private:
/** Moves controls (not cursors!) so that nPos becomes visible. */
void MakePosVisible( sal_Int32 nPos );
+ // cell contents ----------------------------------------------------------
+public:
+ /** Fills all cells of all lines with the passed texts (Unicode strings). */
+ void SetUniStrings(
+ const String* pTextLines, const String& rSepChars,
+ sal_Unicode cTextSep, bool bMergeSep );
+ /** Fills all cells of all lines with the passed texts (ByteStrings). */
+ void SetByteStrings(
+ const ByteString* pLineTexts, CharSet eCharSet,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
+
+ // column settings --------------------------------------------------------
+public:
+ /** Reads UI strings for data types from the list box. */
+ void InitTypes( const ListBox& rListBox );
+ /** Returns the data type of the selected columns. */
+ inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); }
+
+ /** Fills the options object with current column data. */
+ void FillColumnData( ScAsciiOptions& rOptions ) const;
+
// event handling ---------------------------------------------------------
+public:
+ /** Sets a new handler for "update cell texts" requests. */
+ inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; }
+ /** Returns the handler for "update cell texts" requests. */
+ inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; }
+ /** Sets a new handler for "column selection changed" events. */
+ inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; }
+ /** Returns the handler for "column selection changed" events. */
+ inline const Link& GetColTypeHdl() const { return maColTypeHdl; }
+protected:
+ virtual void Resize();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+private:
DECL_LINK( CsvCmdHdl, ScCsvControl* );
DECL_LINK( ScrollHdl, ScrollBar* );
DECL_LINK( ScrollEndHdl, ScrollBar* );
+
+ // accessibility ----------------------------------------------------------
+public:
+ /** Creates and returns the accessible object of this control. */
+ virtual XAccessibleRef CreateAccessible();
+
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
};