2002-02-04 13:10:18 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: accpara.cxx,v $
|
|
|
|
*
|
2002-02-18 16:09:50 +00:00
|
|
|
* $Revision: 1.4 $
|
2002-02-04 13:10:18 +00:00
|
|
|
*
|
2002-02-18 16:09:50 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2002-02-18 17:09:50 $
|
2002-02-04 13:10:18 +00:00
|
|
|
*
|
|
|
|
* 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): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifdef PRECOMPILED
|
|
|
|
#include "core_pch.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _TXTFRM_HXX
|
|
|
|
#include <txtfrm.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _NDTXT_HXX
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#ifndef _VOS_MUTEX_HXX_ //autogen
|
|
|
|
#include <vos/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
|
|
|
|
#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
|
|
|
|
#endif
|
2002-02-05 14:52:06 +00:00
|
|
|
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
|
2002-02-18 15:27:35 +00:00
|
|
|
#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
|
2002-02-05 14:52:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
|
|
|
|
#include <unotools/accessiblestatesethelper.hxx>
|
|
|
|
#endif
|
2002-02-04 13:10:18 +00:00
|
|
|
#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HPP_
|
|
|
|
#include <com/sun/star/i18n/WordType.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BREAKIT_HXX
|
|
|
|
#include <breakit.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _ACCPARA_HXX
|
|
|
|
#include "accpara.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _ACCESS_HRC
|
|
|
|
#include "access.hrc"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::i18n;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::drafts::com::sun::star::accessibility;
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
|
|
|
const sal_Char sServiceName[] = "com.sun.star.text.AccessibleParagraphView";
|
|
|
|
const sal_Char sImplementationName[] = "SwAccessibleParagraph";
|
|
|
|
const xub_StrLen MAX_DESC_TEXT_LEN = 40;
|
|
|
|
|
2002-02-05 14:52:06 +00:00
|
|
|
void SwAccessibleParagraph::SetStates(
|
|
|
|
::utl::AccessibleStateSetHelper& rStateSet )
|
|
|
|
{
|
|
|
|
SwAccessibleContext::SetStates( rStateSet );
|
|
|
|
|
|
|
|
// MULTILINE
|
|
|
|
rStateSet.AddState( AccessibleStateType::MULTILINE );
|
|
|
|
|
|
|
|
// SELECTABLE
|
|
|
|
rStateSet.AddState( AccessibleStateType::SELECTABLE );
|
|
|
|
|
|
|
|
// TODO: SELECTED
|
|
|
|
}
|
|
|
|
|
2002-02-04 13:10:18 +00:00
|
|
|
SwAccessibleParagraph::SwAccessibleParagraph(
|
|
|
|
sal_Int32 nPara,
|
|
|
|
const Rectangle& rVisArea,
|
|
|
|
const SwTxtFrm *pTxtFrm ) :
|
|
|
|
SwAccessibleContext( AccessibleRole::PARAGRAPH, rVisArea, pTxtFrm )
|
|
|
|
{
|
|
|
|
const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode();
|
|
|
|
sal_uInt16 nResId = (pTxtNd->GetOutlineNum() && !pTxtNd->GetNum())
|
|
|
|
? STR_ACCESS_HEADING_NAME
|
|
|
|
: STR_ACCESS_PARAGRAPH_NAME;
|
|
|
|
OUString sArg( OUString::valueOf( nPara ) );
|
|
|
|
SetName( GetResource( nResId, &sArg ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwAccessibleParagraph::~SwAccessibleParagraph()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-02-18 16:09:50 +00:00
|
|
|
OUString SAL_CALL SwAccessibleParagraph::getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException)
|
2002-02-04 13:10:18 +00:00
|
|
|
{
|
|
|
|
vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
|
|
|
|
CHECK_FOR_DEFUNC( XAccessibleContext )
|
|
|
|
|
|
|
|
SwTxtFrm *pTxtFrm = PTR_CAST( SwTxtFrm, GetFrm() );
|
|
|
|
if( !pTxtFrm )
|
|
|
|
{
|
|
|
|
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (no text frame)" );
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode();
|
|
|
|
const String& rText = pTxtNd->GetTxt();
|
|
|
|
xub_StrLen nLen = (xub_StrLen)pBreakIt->xBreak->endOfSentence(
|
|
|
|
rText, 0, pBreakIt->GetLocale(
|
|
|
|
pTxtNd->GetLang( 0 ) ));
|
|
|
|
if( nLen > MAX_DESC_TEXT_LEN )
|
|
|
|
{
|
|
|
|
nLen = (xub_StrLen)pBreakIt->xBreak->getWordBoundary(
|
|
|
|
rText, MAX_DESC_TEXT_LEN,
|
|
|
|
pBreakIt->GetLocale( pTxtNd->GetLang( MAX_DESC_TEXT_LEN ) ),
|
|
|
|
WordType::ANY_WORD, sal_True ).endPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString sArg1( rText.Copy( 0, nLen ) );
|
|
|
|
|
|
|
|
sal_uInt16 nResId;
|
|
|
|
OUString sArg2, *pArg2 = 0;
|
|
|
|
if( pTxtNd->GetOutlineNum() && !pTxtNd->GetNum() )
|
|
|
|
{
|
|
|
|
sArg2 = OUString( pTxtNd->GetNumString() );
|
|
|
|
if( sArg2.getLength() )
|
|
|
|
{
|
|
|
|
nResId = STR_ACCESS_HEADING_WITH_NUM_DESC;
|
|
|
|
pArg2 = &sArg2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nResId = STR_ACCESS_HEADING_DESC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nResId = STR_ACCESS_PARAGRAPH_DESC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetResource( nResId, &sArg1, pArg2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
Locale SAL_CALL SwAccessibleParagraph::getLocale (void)
|
|
|
|
throw (::drafts::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
|
|
|
|
SwTxtFrm *pTxtFrm = PTR_CAST( SwTxtFrm, GetFrm() );
|
|
|
|
if( !pTxtFrm )
|
|
|
|
{
|
|
|
|
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (no text frame)" );
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode();
|
|
|
|
Locale aLoc( pBreakIt->GetLocale( pTxtNd->GetLang( 0 ) ) );
|
|
|
|
|
|
|
|
return aLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SAL_CALL SwAccessibleParagraph::getImplementationName()
|
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SwAccessibleParagraph::supportsService(
|
|
|
|
const ::rtl::OUString& sTestServiceName)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return sTestServiceName.equalsAsciiL( sServiceName, sizeof(sServiceName)-1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
Sequence< OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames()
|
|
|
|
throw( ::com::sun::star::uno::RuntimeException )
|
|
|
|
{
|
|
|
|
Sequence< OUString > aRet(1);
|
|
|
|
OUString* pArray = aRet.getArray();
|
|
|
|
pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
|
|
|
|
return aRet;
|
|
|
|
}
|