Files
libreoffice/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx

732 lines
22 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "AccessibleDrawDocumentView.hxx"
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <rtl/ustring.h>
#include<sfx2/viewfrm.hxx>
#include <svx/AccessibleShape.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdmodel.hxx>
#include <svx/unoapi.hxx>
2002-05-08 09:01:33 +00:00
#include <svx/unoshcol.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include "Window.hxx"
#include <vcl/svapp.hxx>
#include "ViewShell.hxx"
#include "View.hxx"
#include <memory>
2002-08-12 14:41:24 +00:00
#include "accessibility.hrc"
#include "sdresid.hxx"
#include <osl/mutex.hxx>
using ::rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::accessibility;
class SfxViewFrame;
namespace accessibility {
//===== internal ============================================================
AccessibleDrawDocumentView::AccessibleDrawDocumentView (
::sd::Window* pSdWindow,
::sd::ViewShell* pViewShell,
const uno::Reference<frame::XController>& rxController,
const uno::Reference<XAccessible>& rxParent)
: AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
mpChildrenManager (NULL)
{
OSL_TRACE ("AccessibleDrawDocumentView");
UpdateAccessibleName();
}
AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void)
{
OSL_TRACE ("~AccessibleDrawDocumentView");
DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
"~AccessibleDrawDocumentView: object has not been disposed");
}
void AccessibleDrawDocumentView::Init (void)
{
AccessibleDocumentViewBase::Init ();
// Determine the list of shapes on the current page.
uno::Reference<drawing::XShapes> xShapeList;
uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
if (xView.is())
xShapeList = uno::Reference<drawing::XShapes> (
xView->getCurrentPage(), uno::UNO_QUERY);
// Create the children manager.
mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
if (mpChildrenManager != NULL)
{
// Create the page shape and initialize it. The shape is acquired
// before initialization and released after transferring ownership
// to the children manager to prevent premature disposing of the
// shape.
AccessiblePageShape* pPage = CreateDrawPageShape();
if (pPage != NULL)
{
pPage->acquire();
pPage->Init();
mpChildrenManager->AddAccessibleShape (
std::auto_ptr<AccessibleShape>(pPage));
pPage->release();
mpChildrenManager->Update ();
}
2002-05-17 15:15:16 +00:00
mpChildrenManager->UpdateSelection ();
}
}
void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
const IAccessibleViewForwarder* pViewForwarder)
{
AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
if (mpChildrenManager != NULL)
mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
}
/** The page shape is created on every call at the moment (provided that
every thing goes well).
*/
AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
{
AccessiblePageShape* pShape = NULL;
// Create a shape that represents the actual draw page.
uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
if (xView.is())
{
uno::Reference<beans::XPropertySet> xSet (
uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY));
if (xSet.is())
{
// Create a rectangle shape that will represent the draw page.
uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY);
uno::Reference<drawing::XShape> xRectangle;
if (xFactory.is())
xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance (
OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.RectangleShape"))),
uno::UNO_QUERY);
// Set the shape's size and position.
if (xRectangle.is())
{
uno::Any aValue;
awt::Point aPosition;
awt::Size aSize;
// Set size and position of the shape to those of the draw
// page.
aValue = xSet->getPropertyValue (
OUString (RTL_CONSTASCII_USTRINGPARAM("BorderLeft")));
aValue >>= aPosition.X;
aValue = xSet->getPropertyValue (
OUString (RTL_CONSTASCII_USTRINGPARAM("BorderTop")));
aValue >>= aPosition.Y;
xRectangle->setPosition (aPosition);
aValue = xSet->getPropertyValue (
OUString (RTL_CONSTASCII_USTRINGPARAM("Width")));
aValue >>= aSize.Width;
aValue = xSet->getPropertyValue (
OUString (RTL_CONSTASCII_USTRINGPARAM("Height")));
aValue >>= aSize.Height;
xRectangle->setSize (aSize);
// Create the accessible object for the shape and
// initialize it.
pShape = new AccessiblePageShape (
xView->getCurrentPage(), this, maShapeTreeInfo);
}
}
}
return pShape;
}
//===== XAccessibleContext ==================================================
sal_Int32 SAL_CALL
AccessibleDrawDocumentView::getAccessibleChildCount (void)
throw (uno::RuntimeException)
{
ThrowIfDisposed ();
2002-06-07 13:48:28 +00:00
long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount();
// Forward request to children manager.
if (mpChildrenManager != NULL)
mpChildCount += mpChildrenManager->GetChildCount ();
return mpChildCount;
}
uno::Reference<XAccessible> SAL_CALL
AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex)
throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
{
ThrowIfDisposed ();
::osl::ClearableMutexGuard aGuard (maMutex);
2002-06-07 13:48:28 +00:00
// Take care of children of the base class.
sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount();
if (nCount > 0)
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
{
2002-06-07 13:48:28 +00:00
if (nIndex < nCount)
return AccessibleDocumentViewBase::getAccessibleChild(nIndex);
else
nIndex -= nCount;
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
}
2002-06-07 13:48:28 +00:00
// Create a copy of the pointer to the children manager and release the
// mutex before calling any of its methods.
ChildrenManager* pChildrenManager = mpChildrenManager;
aGuard.clear();
2002-06-07 13:48:28 +00:00
// Forward request to children manager.
if (pChildrenManager != NULL)
{
return pChildrenManager->GetChild (nIndex);
}
else
throw lang::IndexOutOfBoundsException (
2010-11-01 21:16:15 +00:00
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("no accessible child with index "))
+ rtl::OUString::valueOf(nIndex),
static_cast<uno::XWeak*>(this));
}
//===== XEventListener ======================================================
void SAL_CALL
AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject)
throw (::com::sun::star::uno::RuntimeException)
{
ThrowIfDisposed ();
AccessibleDocumentViewBase::disposing (rEventObject);
if (rEventObject.Source == mxModel)
{
::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex());
// maShapeTreeInfo has been modified in base class.
if (mpChildrenManager != NULL)
mpChildrenManager->SetInfo (maShapeTreeInfo);
}
}
//===== XPropertyChangeListener =============================================
void SAL_CALL
AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
throw (::com::sun::star::uno::RuntimeException)
{
ThrowIfDisposed ();
AccessibleDocumentViewBase::propertyChange (rEventObject);
OSL_TRACE ("AccessibleDrawDocumentView::propertyChange");
if ( rEventObject.PropertyName == "CurrentPage" )
{
OSL_TRACE (" current page changed");
// Update the accessible name to reflect the current slide.
UpdateAccessibleName();
// The current page changed. Update the children manager accordingly.
uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
if (xView.is() && mpChildrenManager!=NULL)
{
// Inform the children manager to forget all children and give
// him the new ones.
mpChildrenManager->ClearAccessibleShapeList ();
2002-05-13 11:37:02 +00:00
mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
xView->getCurrentPage(), uno::UNO_QUERY));
// Create the page shape and initialize it. The shape is
// acquired before initialization and released after
// transferring ownership to the children manager to prevent
// premature disposing of the shape.
AccessiblePageShape* pPage = CreateDrawPageShape ();
if (pPage != NULL)
{
pPage->acquire();
pPage->Init();
mpChildrenManager->AddAccessibleShape (
std::auto_ptr<AccessibleShape>(pPage));
mpChildrenManager->Update (false);
pPage->release();
}
}
else
OSL_TRACE ("View invalid");
}
else if ( rEventObject.PropertyName == "VisibleArea" )
{
OSL_TRACE (" visible area changed");
2002-04-22 15:13:53 +00:00
if (mpChildrenManager != NULL)
mpChildrenManager->ViewForwarderChanged (
IAccessibleViewForwarderListener::VISIBLE_AREA,
&maViewForwarder);
}
else
{
OSL_TRACE (" unhandled");
}
OSL_TRACE (" done");
}
//===== XServiceInfo ========================================================
::rtl::OUString SAL_CALL
AccessibleDrawDocumentView::getImplementationName (void)
throw (::com::sun::star::uno::RuntimeException)
{
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"AccessibleDrawDocumentView"));
}
::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
AccessibleDrawDocumentView::getSupportedServiceNames (void)
throw (::com::sun::star::uno::RuntimeException)
{
ThrowIfDisposed();
// Get list of supported service names from base class...
uno::Sequence<OUString> aServiceNames =
AccessibleDocumentViewBase::getSupportedServiceNames();
sal_Int32 nCount (aServiceNames.getLength());
// ...and add additional names.
aServiceNames.realloc (nCount + 1);
static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.drawing.AccessibleDrawDocumentView"));
aServiceNames[nCount] = sAdditionalServiceName;
return aServiceNames;
}
/// Create a name for this view.
::rtl::OUString
AccessibleDrawDocumentView::CreateAccessibleName (void)
throw (::com::sun::star::uno::RuntimeException)
{
2002-08-12 14:41:24 +00:00
rtl::OUString sName;
uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
if (xInfo.is())
{
uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
OUString sFirstService = aServices[0];
if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
2002-08-12 14:41:24 +00:00
{
2012-04-07 13:41:56 -03:00
if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sName = ResId::toString(SdResId(SID_SD_A11Y_I_DRAWVIEW_N) );
2002-08-12 14:41:24 +00:00
}
else
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sName = ResId::toString( SdResId(SID_SD_A11Y_D_DRAWVIEW_N) );
2002-08-12 14:41:24 +00:00
}
}
else if ( sFirstService == "com.sun.star.presentation.NotesView" )
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sName = ResId::toString( SdResId(SID_SD_A11Y_I_NOTESVIEW_N) );
2002-08-12 14:41:24 +00:00
}
else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sName = ResId::toString( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_N) );
2002-08-12 14:41:24 +00:00
}
else
{
sName = sFirstService;
}
}
else
{
2012-04-07 13:41:56 -03:00
sName = "AccessibleDrawDocumentView";
2002-08-12 14:41:24 +00:00
}
return sName;
}
/** Create a description for this view. Use the model's description or URL
if a description is not available.
*/
::rtl::OUString
AccessibleDrawDocumentView::CreateAccessibleDescription (void)
throw (::com::sun::star::uno::RuntimeException)
{
rtl::OUString sDescription;
uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
if (xInfo.is())
{
2002-08-12 14:41:24 +00:00
uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
OUString sFirstService = aServices[0];
if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
{
2012-04-07 13:41:56 -03:00
if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sDescription = ResId::toString( SdResId(SID_SD_A11Y_I_DRAWVIEW_D) );
2002-08-12 14:41:24 +00:00
}
else
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sDescription = ResId::toString( SdResId(SID_SD_A11Y_D_DRAWVIEW_D) );
2002-08-12 14:41:24 +00:00
}
}
else if ( sFirstService == "com.sun.star.presentation.NotesView" )
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sDescription = ResId::toString( SdResId(SID_SD_A11Y_I_NOTESVIEW_D) );
2002-08-12 14:41:24 +00:00
}
else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
2002-08-12 14:41:24 +00:00
{
SolarMutexGuard aGuard;
2002-08-12 14:41:24 +00:00
2012-04-07 13:41:56 -03:00
sDescription = ResId::toString( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_D) );
}
else
2002-08-12 14:41:24 +00:00
{
sDescription = sFirstService;
2002-08-12 14:41:24 +00:00
}
}
else
2002-08-12 14:41:24 +00:00
{
2012-04-07 13:41:56 -03:00
sDescription = "Accessible Draw Document";
2002-08-12 14:41:24 +00:00
}
return sDescription;
}
2002-05-08 09:01:33 +00:00
/** Return selection state of specified child
*/
sal_Bool
AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex )
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
2002-05-08 09:01:33 +00:00
uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY );
sal_Bool bRet = sal_False;
OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" );
if( xSel.is() && ( 0 <= nAccessibleChildIndex ) )
{
uno::Any aAny( xSel->getSelection() );
uno::Reference< drawing::XShapes > xShapes;
aAny >>= xShapes;
if( xShapes.is() )
{
AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) );
if( pAcc )
{
uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
if( xShape.is() )
{
for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i )
if( xShapes->getByIndex( i ) == xShape )
bRet = sal_True;
}
}
}
}
return( bRet );
}
2002-05-17 15:15:16 +00:00
/** Select or delselect the specified shapes. The corresponding accessible
shapes are notified over the selection change listeners registered with
the XSelectionSupplier of the controller.
2002-05-08 09:01:33 +00:00
*/
void
AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
2002-05-08 09:01:33 +00:00
uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY );
if( xSel.is() )
{
uno::Any aAny;
if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex )
{
2002-05-17 15:15:16 +00:00
// Select or deselect all children.
2002-05-08 09:01:33 +00:00
if( !bSelect )
xSel->select( aAny );
else
{
uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() );
for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
2002-05-08 09:01:33 +00:00
{
AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) );
if( pAcc && pAcc->GetXShape().is() )
xShapes->add( pAcc->GetXShape() );
}
if( xShapes->getCount() )
{
aAny <<= xShapes;
xSel->select( aAny );
}
}
}
else if( nAccessibleChildIndex >= 0 )
{
2002-05-17 15:15:16 +00:00
// Select or deselect only the child with index
// nAccessibleChildIndex.
AccessibleShape* pAcc = AccessibleShape::getImplementation(
getAccessibleChild( nAccessibleChildIndex ));
// Add or remove the shape that is made accessible from the
// selection of the controller.
2002-05-08 09:01:33 +00:00
if( pAcc )
{
uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
if( xShape.is() )
{
uno::Reference< drawing::XShapes > xShapes;
sal_Bool bFound = sal_False;
aAny = xSel->getSelection();
aAny >>= xShapes;
// Search shape to be selected in current selection.
if (xShapes.is())
{
sal_Int32 nCount = xShapes->getCount();
for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i )
if( xShapes->getByIndex( i ) == xShape )
bFound = sal_True;
}
else
// Create an empty selection to add the shape to.
xShapes = new SvxShapeCollection();
2002-05-08 09:01:33 +00:00
// Update the selection.
2002-05-08 09:01:33 +00:00
if( !bFound && bSelect )
xShapes->add( xShape );
else if( bFound && !bSelect )
xShapes->remove( xShape );
aAny <<= xShapes;
xSel->select( aAny );
}
}
}
}
}
void AccessibleDrawDocumentView::Activated (void)
{
if (mpChildrenManager != NULL)
{
mpChildrenManager->UpdateSelection();
// When none of the children has the focus then claim it for the
// view.
if ( ! mpChildrenManager->HasFocus())
SetState (AccessibleStateType::FOCUSED);
else
ResetState (AccessibleStateType::FOCUSED);
}
}
void AccessibleDrawDocumentView::Deactivated (void)
{
if (mpChildrenManager != NULL)
mpChildrenManager->RemoveFocus();
ResetState (AccessibleStateType::FOCUSED);
}
void AccessibleDrawDocumentView::impl_dispose (void)
{
if (mpChildrenManager != NULL)
{
delete mpChildrenManager;
mpChildrenManager = NULL;
}
AccessibleDocumentViewBase::impl_dispose();
}
/** This method is called from the component helper base class while
disposing.
*/
void SAL_CALL AccessibleDrawDocumentView::disposing (void)
{
// Release resources.
if (mpChildrenManager != NULL)
{
delete mpChildrenManager;
mpChildrenManager = NULL;
}
// Forward call to base classes.
AccessibleDocumentViewBase::disposing ();
}
void AccessibleDrawDocumentView::UpdateAccessibleName (void)
{
OUString sNewName (CreateAccessibleName());
2012-04-07 13:41:56 -03:00
sNewName += ": ";
// Add the number of the current slide.
uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
if (xView.is())
{
uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY);
if (xProperties.is())
try
{
sal_Int16 nPageNumber (0);
2012-04-07 13:41:56 -03:00
if (xProperties->getPropertyValue("Number") >>= nPageNumber)
{
sNewName += OUString::valueOf(sal_Int32(nPageNumber));
}
}
catch (beans::UnknownPropertyException&)
{
}
}
// Add the number of pages/slides.
Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY);
if (xPagesSupplier.is())
{
Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY);
if (xPages.is())
{
2012-04-07 13:41:56 -03:00
sNewName += " / ";
sNewName += OUString::valueOf(xPages->getCount());
}
}
SetAccessibleName (sNewName, AutomaticallyCreated);
}
} // end of namespace accessibility
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */