Files
libreoffice/editeng/source/accessibility/AccessibleStaticTextBase.cxx

992 lines
36 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes (at least) relevant parts of: linecap: Reintegrating finished LineCap feature Patch contributed by Regina Henschel http://svn.apache.org/viewvc?view=revision&revision=1232507 Patches contributed by Sven Jacobi impress212: #i81610# fixed animation export http://svn.apache.org/viewvc?view=revision&revision=1167620 impress212: drawinglayer gbuild environment changes http://svn.apache.org/viewvc?view=revision&revision=1167627 http://svn.apache.org/viewvc?view=revision&revision=1167628 impress212: DffPropSet -> minor code improvements, removing table http://svn.apache.org/viewvc?view=revision&revision=1167634 impress212: #158494# fixed excel import (text rotation) http://svn.apache.org/viewvc?view=revision&revision=1167638 Patches contributed by Armin Le Grand Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement http://svn.apache.org/viewvc?view=revision&revision=1220836 #118728# changed indentifying definitions for Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1229961 #118838# LineGeometry creation for complicated cases optimized to create single Polygons http://svn.apache.org/viewvc?view=revision&revision=1236232 #119176# corrected file type detection for SVG for svg files without xml header http://svn.apache.org/viewvc?view=revision&revision=1309445 #118728# Extended Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1230531 #118529# solve break converters and convert commands for OLEs and images http://svn.apache.org/viewvc?view=revision&revision=1186168 svg: added WaE changes from branch svgreplacement to trunc http://svn.apache.org/viewvc?view=revision&revision=1222974 svg: corrected missing member initialization http://svn.apache.org/viewvc?view=revision&revision=1226134 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles to bitmapEx ... http://svn.apache.org/viewvc?view=revision&revision=1293316 fix for #118525#: removed no longer used variable maOriginalMapMode, one more exception eliminated http://svn.apache.org/viewvc?view=revision&revision=1227097 #16758# Added buffering to the VDev usages of the VclProcessor2D derivates... http://svn.apache.org/viewvc?view=revision&revision=1229521 #116758# Secured VDev buffer device to Vcl deinit http://svn.apache.org/viewvc?view=revision&revision=1230574 #116758# added remembering allocated VDevs for VDevBuffer to be able to also delete these when vcl goes down; it should never happen, but You never know http://svn.apache.org/viewvc?view=revision&revision=1230927 #118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive representation instead of TransparencePrimitive2D http://svn.apache.org/viewvc?view=revision&revision=1231198 #118822# secured 3D geometry creation (slices) by subdividing the 2D source polyPolygon early http://svn.apache.org/viewvc?view=revision&revision=1234749 #118829# enhanced Svg gradient quality, obstacles avoided http://svn.apache.org/viewvc?view=revision&revision=1235361 #118834# Unified usage of TextBreakupHelper as single tooling class for i18n text primitive breakup http://svn.apache.org/viewvc?view=revision&revision=1236110 #118853# added square pixel size limit to conversion of TransparencePrimitive2D to Metafile action http://svn.apache.org/viewvc?view=revision&revision=1237656 #118824# coreccted mirroring and boundrect when the graphicmanager is used for bitmap output http://svn.apache.org/viewvc?view=revision&revision=1240097 #115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for various optimization scenarios http://svn.apache.org/viewvc?view=revision&revision=1241434 #118783# Corrected errors in ID strings, corrected Svg line/fill export, corrected polygon close state http://svn.apache.org/viewvc?view=revision&revision=1232006 #118796# corrected null-pointer usage in SVG text exporter http://svn.apache.org/viewvc?view=revision&revision=1240262 #118729# Use GraphicStreamUrl and GraphicUrl to allow multi image import with linked graphics, too http://svn.apache.org/viewvc?view=revision&revision=1229962 #118898# corrected error in GDIMetaFile::GetBoundRect in handling MetaFloatTransparentAction http://svn.apache.org/viewvc?view=revision&revision=1293349 #118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping http://svn.apache.org/viewvc?view=revision&revision=1237725 #115962# Better (but not yet optimal, see comments in task) handling of MetaFloatTransparentAction in PDF export http://svn.apache.org/viewvc?view=revision&revision=1241078 IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ... http://svn.apache.org/viewvc?view=revision&revision=1200879 118779# Added svg content streaming in/out to ImpGraphic stream operators http://svn.apache.org/viewvc?view=revision&revision=1231908 linecap: correctons for WaE and mac drawing http://svn.apache.org/viewvc?view=revision&revision=1232793 svg: uses current system Dpi for Svg replacement image creation http://svn.apache.org/viewvc?view=revision&revision=1233948 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1394326 Remove duplicate header includes. cws mba34issues01: #i117720#: convert assertion into warning http://svn.apache.org/viewvc?view=revision&revision=1172352 118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand. http://svn.apache.org/viewvc?view=revision&revision=1182166 cws mba34issues01: #i117714#: remove assertion http://svn.apache.org/viewvc?view=revision&revision=1172357 Patch contributed by Jurgen Schmidt add some additional checks to ensure proper reading operations http://svn.apache.org/viewvc?view=revision&revision=1209022 mostly prefer our stream / bounds checking work. Patches contributed by Herbert Duerr #i118816# add clarifying comment regarding Font::*Color*() methods http://svn.apache.org/viewvc?view=revision&revision=1233833 extend macro->string handling for empty strings http://svn.apache.org/viewvc?view=revision&revision=1175801 avoid magic constants for SALCOLOR_NONE http://svn.apache.org/viewvc?view=revision&revision=1177543 initialize slant properly in ImplFontMetricData constructor (author=iorsh) http://svn.apache.org/viewvc?view=revision&revision=1177551 #i118675# make check for extension updates more stable http://svn.apache.org/viewvc?view=revision&revision=1214797 #a118617# remove VBasicEventListener.dll binary There are no known users depending on its CLSID http://svn.apache.org/viewvc?view=revision&revision=1203697 Patches contributed by Ariel Constenla-Haile Fix build breaker on Linux/gcc http://svn.apache.org/viewvc?view=revision&revision=1221104 Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG http://svn.apache.org/viewvc?view=revision&revision=1215559 Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider instances of <SwFlyDrawObj> http://svn.apache.org/viewvc?view=revision&revision=1172120 sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 gnumake4 work variously from Hans-Joachim Lankenau http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1396782 http://svn.apache.org/viewvc?view=revision&revision=1394707 plus some amount of re-splitting of legacy headers. Patch contributed by Pavel Janik WaE: Remove unused variables. http://svn.apache.org/viewvc?view=revision&revision=1230697 Patches contributed by Takashi Ono mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 Patch contributed by Christian Lippka impress212: #i98044# re enable Text menu for outline and title shapes http://svn.apache.org/viewvc?view=revision&revision=1167639 Patch contributed by Andre Fischer 118674: Made category B code optional and disabled by default. http://svn.apache.org/viewvc?view=revision&revision=1215131 118881: Ignore empty paragraphs after bullets. http://svn.apache.org/viewvc?view=revision&revision=1296205 Patches contributed by Philipp Lohmann ooo340fixes: #i117780# use rtl allocator http://svn.apache.org/viewvc?view=revision&revision=1172087 ooo34gsl02: #i117807# fix an off by one error (index actually inside the pfb section header) http://svn.apache.org/viewvc?view=revision&revision=1167576 various cleanups, related compilation fixes, warning cleanups, re-working of obsolete stl template pieces to use boost instead, changed string classes, re-adapt KDE about data, about dialog, fixing warnings, and other fixes & improvements. Disable svg import / render for about/ branding code-paths for now. Restore full icon theme set. Remove OS/2 conditionals and sources. Remove conflicting gtk/full-screen monitors support. Retain existing svg rasterizer files - temporarily disabled. Standardize stringificaiton and fixup dllpostfix issues. Rename SvgGradientHelper::== to equalTo to avoid overloading issues. Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
// Global header
#include <limits.h>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <osl/mutex.hxx>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <comphelper/sequence.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/accessibility/AccessibleTextType.hpp>
// Project-local header
#include <editeng/editdata.hxx>
#include <editeng/unopracc.hxx>
#include "editeng/unoedprx.hxx"
#include <editeng/AccessibleStaticTextBase.hxx>
#include "editeng/AccessibleEditableTextPara.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
/* TODO:
=====
- separate adapter functionality from AccessibleStaticText class
- refactor common loops into templates, using mem_fun
*/
namespace accessibility
{
typedef ::std::vector< beans::PropertyValue > PropertyValueVector;
class PropertyValueEqualFunctor : public ::std::binary_function< beans::PropertyValue, beans::PropertyValue, bool >
{
public:
PropertyValueEqualFunctor()
{}
bool operator() ( const beans::PropertyValue& lhs, const beans::PropertyValue& rhs ) const
{
return ( lhs.Name == rhs.Name && lhs.Value == rhs.Value );
}
};
sal_Unicode cNewLine(0x0a);
// Static Helper
ESelection MakeSelection( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex )
{
DBG_ASSERT(nStartPara >= 0 && nStartPara <= SAL_MAX_INT32 &&
nStartIndex >= 0 && nStartIndex <= USHRT_MAX &&
nEndPara >= 0 && nEndPara <= SAL_MAX_INT32 &&
nEndIndex >= 0 && nEndIndex <= USHRT_MAX ,
2002-08-16 10:58:06 +00:00
"AccessibleStaticTextBase_Impl::MakeSelection: index value overflow");
return ESelection(nStartPara, nStartIndex, nEndPara, nEndIndex);
}
// AccessibleStaticTextBase_Impl declaration
/** AccessibleStaticTextBase_Impl
This class implements the AccessibleStaticTextBase
functionality, mainly by forwarding the calls to an aggregated
AccessibleEditableTextPara. As this is a therefore non-trivial
adapter, factoring out the common functionality from
AccessibleEditableTextPara might be a profitable future task.
*/
class AccessibleStaticTextBase_Impl
{
friend class AccessibleStaticTextBase;
public:
// receive pointer to our frontend class and view window
AccessibleStaticTextBase_Impl();
~AccessibleStaticTextBase_Impl();
void SetEditSource( ::std::unique_ptr< SvxEditSource > && pEditSource );
void SetEventSource( const uno::Reference< XAccessible >& rInterface )
{
mxThis = rInterface;
}
void SetOffset( const Point& );
void Dispose();
AccessibleEditableTextPara& GetParagraph( sal_Int32 nPara ) const;
sal_Int32 GetParagraphCount() const;
CWS-TOOLING: integrate CWS swa11y32_2nd 2009-08-13 13:04:09 +0200 mav r274936 : #i104204# remove support for Ctrl-Tab 2009-08-13 09:59:22 +0200 od r274924 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit also object:state-changed:focus, if cursor is inside <XAccessibleText> object 2009-08-11 12:15:11 +0200 tl r274851 : CWS-TOOLING: rebase CWS swa11y32_2nd to trunk@274622 (milestone: DEV300:m54) 2009-07-14 17:35:03 +0200 tl r273982 : 2009-07-10 10:46:39 +0200 tl r273879 : CWS-TOOLING: rebase CWS swa11y32 to trunk@273468 (milestone: DEV300:m51) 2009-07-01 14:00:25 +0200 mav r273577 : #i102879# the text of the button should not change 2009-07-01 13:16:19 +0200 od r273574 : #159496# method <GetHelpAnchor_Impl(..)> - do not release the solar mutex 2009-06-29 15:29:10 +0200 od r273476 : #i95042# method <CreateXWindow(..)> - return instance <VCLXComboBox> for <Window> instance of type <MetricBox>. note: <MetricBox> is inherited from <ComboBox> 2009-06-23 15:49:32 +0200 mav r273283 : #i101967# fix tab-control implementation 2009-06-22 13:56:22 +0200 od r273229 : #i100938# method <text_wrapper_get_run_attributes(..)> - always provide start_offset and end_offset - do _not_ increment the end_offset provide by <accessibility::TextSegment> instance 2009-06-02 12:09:03 +0200 mav r272492 : #i101959# Let the additional dialog window add its childred to the parents tab-hierarchy 2009-06-02 09:55:39 +0200 mav r272484 : #i102015# allow to have indirect child windows in tab-hierarchy 2009-06-02 09:49:42 +0200 mav r272482 : #i102015# Let the windows containing the extension dialog controls add controls to the tab hierarchy 2009-05-27 15:45:33 +0200 od r272354 : #i101012# method <SvxIconChoiceCtrl_Impl::EntrySelected(..)> - emit vcl event LISTBOX_SELECT only in case that the given entry is selected. 2009-05-27 09:54:36 +0200 od r272333 : #i92103# map UNO-API accessible events list box entry expanded/collapsed to corresponding atk events. 2009-05-27 09:52:15 +0200 od r272331 : #i92103# process list box entry expanded/collapsed events 2009-05-27 09:49:19 +0200 od r272330 : #i92103# emit vcl event list box entry expanded/collapsed 2009-05-26 10:42:05 +0200 od r272283 : #i93269# correct fix: check success of <queryInterface> call 2009-05-04 15:52:04 +0200 od r271469 : #i92103# new vcl event ids VCLEVENT_LISTBOX_ENTRY_EXPANDED and VCLEVENT_LISTBOX_ENTRY_COLLAPSED 2009-05-04 15:10:20 +0200 od r271460 : #i92103# refine definition of new constants 2009-05-04 14:36:44 +0200 od r271454 : #i92103# new constants for indicating that a list box entry is expanded respectively collapsed. 2009-04-30 16:09:40 +0200 od r271421 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit text_caret_moved event for <XAccessibleText> object, if cursor is inside the <XAccessibleText> object. 2009-04-22 14:00:10 +0200 tl r271105 : warning-free code 2009-04-22 09:17:30 +0200 tl r271073 : CWS-TOOLING: rebase CWS swa11y32 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 12:53:03 +0200 cd r270974 : #i83639# Check extendedhelp state to provide correct tool tip text 2009-04-03 13:07:13 +0200 tl r270471 : #i63983# changed accessible object names to empty strings 2009-04-01 15:52:09 +0200 tl r270336 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:12:42 +0200 tl r270333 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:10:34 +0200 tl r270331 : warning-free code 2009-04-01 12:54:44 +0200 tl r270319 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-04-01 12:52:56 +0200 tl r270318 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-03-27 18:31:01 +0100 tbe r270166 : #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells 2009-03-13 13:43:54 +0100 tl r269476 : #i94322# ImpEditView::ShowCursor and nPara == USHRT_MAX problem fixed 2009-03-12 10:27:30 +0100 tl r269366 : warning-free code; unresolved external dbg_out when compiling with debug=t 2009-03-11 12:40:31 +0100 tl r269312 : warning-free code Solaris x86 2009-03-10 15:49:01 +0100 tl r269279 : #i86443# handle GetColumnCount() == 0 2009-03-10 10:48:32 +0100 cl r269254 : #i91742# name cells for accessibility 2009-03-09 17:06:33 +0100 cl r269203 : #i91742# call init on accessible cells
2009-08-26 13:37:34 +00:00
EPosition Index2Internal( sal_Int32 nFlatIndex ) const
{
return ImpCalcInternal( nFlatIndex, false );
}
CWS-TOOLING: integrate CWS swa11y32_2nd 2009-08-13 13:04:09 +0200 mav r274936 : #i104204# remove support for Ctrl-Tab 2009-08-13 09:59:22 +0200 od r274924 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit also object:state-changed:focus, if cursor is inside <XAccessibleText> object 2009-08-11 12:15:11 +0200 tl r274851 : CWS-TOOLING: rebase CWS swa11y32_2nd to trunk@274622 (milestone: DEV300:m54) 2009-07-14 17:35:03 +0200 tl r273982 : 2009-07-10 10:46:39 +0200 tl r273879 : CWS-TOOLING: rebase CWS swa11y32 to trunk@273468 (milestone: DEV300:m51) 2009-07-01 14:00:25 +0200 mav r273577 : #i102879# the text of the button should not change 2009-07-01 13:16:19 +0200 od r273574 : #159496# method <GetHelpAnchor_Impl(..)> - do not release the solar mutex 2009-06-29 15:29:10 +0200 od r273476 : #i95042# method <CreateXWindow(..)> - return instance <VCLXComboBox> for <Window> instance of type <MetricBox>. note: <MetricBox> is inherited from <ComboBox> 2009-06-23 15:49:32 +0200 mav r273283 : #i101967# fix tab-control implementation 2009-06-22 13:56:22 +0200 od r273229 : #i100938# method <text_wrapper_get_run_attributes(..)> - always provide start_offset and end_offset - do _not_ increment the end_offset provide by <accessibility::TextSegment> instance 2009-06-02 12:09:03 +0200 mav r272492 : #i101959# Let the additional dialog window add its childred to the parents tab-hierarchy 2009-06-02 09:55:39 +0200 mav r272484 : #i102015# allow to have indirect child windows in tab-hierarchy 2009-06-02 09:49:42 +0200 mav r272482 : #i102015# Let the windows containing the extension dialog controls add controls to the tab hierarchy 2009-05-27 15:45:33 +0200 od r272354 : #i101012# method <SvxIconChoiceCtrl_Impl::EntrySelected(..)> - emit vcl event LISTBOX_SELECT only in case that the given entry is selected. 2009-05-27 09:54:36 +0200 od r272333 : #i92103# map UNO-API accessible events list box entry expanded/collapsed to corresponding atk events. 2009-05-27 09:52:15 +0200 od r272331 : #i92103# process list box entry expanded/collapsed events 2009-05-27 09:49:19 +0200 od r272330 : #i92103# emit vcl event list box entry expanded/collapsed 2009-05-26 10:42:05 +0200 od r272283 : #i93269# correct fix: check success of <queryInterface> call 2009-05-04 15:52:04 +0200 od r271469 : #i92103# new vcl event ids VCLEVENT_LISTBOX_ENTRY_EXPANDED and VCLEVENT_LISTBOX_ENTRY_COLLAPSED 2009-05-04 15:10:20 +0200 od r271460 : #i92103# refine definition of new constants 2009-05-04 14:36:44 +0200 od r271454 : #i92103# new constants for indicating that a list box entry is expanded respectively collapsed. 2009-04-30 16:09:40 +0200 od r271421 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit text_caret_moved event for <XAccessibleText> object, if cursor is inside the <XAccessibleText> object. 2009-04-22 14:00:10 +0200 tl r271105 : warning-free code 2009-04-22 09:17:30 +0200 tl r271073 : CWS-TOOLING: rebase CWS swa11y32 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 12:53:03 +0200 cd r270974 : #i83639# Check extendedhelp state to provide correct tool tip text 2009-04-03 13:07:13 +0200 tl r270471 : #i63983# changed accessible object names to empty strings 2009-04-01 15:52:09 +0200 tl r270336 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:12:42 +0200 tl r270333 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:10:34 +0200 tl r270331 : warning-free code 2009-04-01 12:54:44 +0200 tl r270319 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-04-01 12:52:56 +0200 tl r270318 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-03-27 18:31:01 +0100 tbe r270166 : #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells 2009-03-13 13:43:54 +0100 tl r269476 : #i94322# ImpEditView::ShowCursor and nPara == USHRT_MAX problem fixed 2009-03-12 10:27:30 +0100 tl r269366 : warning-free code; unresolved external dbg_out when compiling with debug=t 2009-03-11 12:40:31 +0100 tl r269312 : warning-free code Solaris x86 2009-03-10 15:49:01 +0100 tl r269279 : #i86443# handle GetColumnCount() == 0 2009-03-10 10:48:32 +0100 cl r269254 : #i91742# name cells for accessibility 2009-03-09 17:06:33 +0100 cl r269203 : #i91742# call init on accessible cells
2009-08-26 13:37:34 +00:00
EPosition Range2Internal( sal_Int32 nFlatIndex ) const
{
return ImpCalcInternal( nFlatIndex, true );
}
sal_Int32 Internal2Index( EPosition nEEIndex ) const;
void CorrectTextSegment( TextSegment& aTextSegment,
int nPara ) const;
bool SetSelection( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex );
bool CopyText( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex );
Rectangle GetParagraphBoundingBox() const;
bool RemoveLineBreakCount( sal_Int32& rIndex );
private:
2002-08-16 10:58:06 +00:00
EPosition ImpCalcInternal( sal_Int32 nFlatIndex, bool bExclusive ) const;
// our frontend class (the one implementing the actual
// interface). That's not necessarily the one containing the impl
// pointer
uno::Reference< XAccessible > mxThis;
// implements our functionality, we're just an adapter (guarded by solar mutex)
mutable AccessibleEditableTextPara* mpTextParagraph;
uno::Reference< XAccessible > mxParagraph;
// a wrapper for the text forwarders (guarded by solar mutex)
mutable SvxEditSourceAdapter maEditSource;
// guard for maOffset
mutable ::osl::Mutex maMutex;
/// our current offset to the containing shape/cell (guarded by maMutex)
Point maOffset;
};
// AccessibleStaticTextBase_Impl implementation
AccessibleStaticTextBase_Impl::AccessibleStaticTextBase_Impl() :
mxThis( nullptr ),
mpTextParagraph( new AccessibleEditableTextPara(nullptr) ),
mxParagraph( mpTextParagraph ),
maEditSource(),
maMutex(),
maOffset(0,0)
{
// TODO: this is still somewhat of a hack, all the more since
// now the maTextParagraph has an empty parent reference set
}
AccessibleStaticTextBase_Impl::~AccessibleStaticTextBase_Impl()
{
}
void AccessibleStaticTextBase_Impl::SetEditSource( ::std::unique_ptr< SvxEditSource > && pEditSource )
{
maEditSource.SetEditSource( std::move(pEditSource) );
if( mpTextParagraph )
mpTextParagraph->SetEditSource( &maEditSource );
}
void AccessibleStaticTextBase_Impl::SetOffset( const Point& rPoint )
{
// guard against non-atomic access to maOffset data structure
{
::osl::MutexGuard aGuard( maMutex );
maOffset = rPoint;
}
if( mpTextParagraph )
mpTextParagraph->SetEEOffset( rPoint );
}
void AccessibleStaticTextBase_Impl::Dispose()
{
// we're the owner of the paragraph, so destroy it, too
if( mpTextParagraph )
mpTextParagraph->Dispose();
// drop references
mxParagraph = nullptr;
mxThis = nullptr;
mpTextParagraph = nullptr;
}
AccessibleEditableTextPara& AccessibleStaticTextBase_Impl::GetParagraph( sal_Int32 nPara ) const
{
if( !mpTextParagraph )
throw lang::DisposedException ("object has been already disposed", mxThis );
// TODO: Have a different method on AccessibleEditableTextPara
// that does not care about state changes
mpTextParagraph->SetParagraphIndex( nPara );
return *mpTextParagraph;
}
sal_Int32 AccessibleStaticTextBase_Impl::GetParagraphCount() const
{
if( !mpTextParagraph )
return 0;
else
return mpTextParagraph->GetTextForwarder().GetParagraphCount();
}
sal_Int32 AccessibleStaticTextBase_Impl::Internal2Index( EPosition nEEIndex ) const
{
// XXX checks for overflow and returns maximum if so
sal_Int32 aRes(0);
for(sal_Int32 i=0; i<nEEIndex.nPara; ++i)
{
sal_Int32 nCount = GetParagraph(i).getCharacterCount();
if (SAL_MAX_INT32 - aRes > nCount)
return SAL_MAX_INT32;
aRes += nCount;
}
if (SAL_MAX_INT32 - aRes > nEEIndex.nIndex)
return SAL_MAX_INT32;
return aRes + nEEIndex.nIndex;
}
void AccessibleStaticTextBase_Impl::CorrectTextSegment( TextSegment& aTextSegment,
int nPara ) const
{
// Keep 'invalid' values at the TextSegment
if( aTextSegment.SegmentStart != -1 &&
2012-02-01 19:36:28 +01:00
aTextSegment.SegmentEnd != -1 )
{
// #112814# Correct TextSegment by paragraph offset
sal_Int32 nOffset(0);
int i;
for(i=0; i<nPara; ++i)
nOffset += GetParagraph(i).getCharacterCount();
aTextSegment.SegmentStart += nOffset;
aTextSegment.SegmentEnd += nOffset;
}
}
2002-08-16 10:58:06 +00:00
EPosition AccessibleStaticTextBase_Impl::ImpCalcInternal( sal_Int32 nFlatIndex, bool bExclusive ) const
{
if( nFlatIndex < 0 )
throw lang::IndexOutOfBoundsException("AccessibleStaticTextBase_Impl::Index2Internal: character index out of bounds",
mxThis);
// gratuitously accepting larger indices here, AccessibleEditableTextPara will throw eventually
sal_Int32 nCurrPara, nCurrIndex, nParas, nCurrCount;
2002-08-16 10:58:06 +00:00
for( nCurrPara=0, nParas=GetParagraphCount(), nCurrCount=0, nCurrIndex=0; nCurrPara<nParas; ++nCurrPara )
{
nCurrCount = GetParagraph( nCurrPara ).getCharacterCount();
nCurrIndex += nCurrCount;
if( nCurrIndex >= nFlatIndex )
{
// check overflow
DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= SAL_MAX_INT32 &&
nFlatIndex - nCurrIndex + nCurrCount >= 0 && nFlatIndex - nCurrIndex + nCurrCount <= USHRT_MAX ,
"AccessibleStaticTextBase_Impl::Index2Internal: index value overflow");
return EPosition(nCurrPara, nFlatIndex - nCurrIndex + nCurrCount);
}
}
2002-08-16 10:58:06 +00:00
// #102170# Allow one-past the end for ranges
if( bExclusive && nCurrIndex == nFlatIndex )
{
// check overflow
DBG_ASSERT(nCurrPara > 0 && nCurrPara <= SAL_MAX_INT32 &&
2002-08-16 10:58:06 +00:00
nFlatIndex - nCurrIndex + nCurrCount >= 0 && nFlatIndex - nCurrIndex + nCurrCount <= USHRT_MAX ,
"AccessibleStaticTextBase_Impl::Index2Internal: index value overflow");
return EPosition(nCurrPara-1, nFlatIndex - nCurrIndex + nCurrCount);
2002-08-16 10:58:06 +00:00
}
// not found? Out of bounds
throw lang::IndexOutOfBoundsException("AccessibleStaticTextBase_Impl::Index2Internal: character index out of bounds",
mxThis);
}
bool AccessibleStaticTextBase_Impl::SetSelection( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex )
{
if( !mpTextParagraph )
return false;
try
{
SvxEditViewForwarder& rCacheVF = mpTextParagraph->GetEditViewForwarder( true );
return rCacheVF.SetSelection( MakeSelection(nStartPara, nStartIndex, nEndPara, nEndIndex) );
}
catch( const uno::RuntimeException& )
{
return false;
}
}
bool AccessibleStaticTextBase_Impl::CopyText( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex )
{
if( !mpTextParagraph )
return false;
try
{
SvxEditViewForwarder& rCacheVF = mpTextParagraph->GetEditViewForwarder( true );
mpTextParagraph->GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
bool aRetVal;
// save current selection
ESelection aOldSelection;
rCacheVF.GetSelection( aOldSelection );
rCacheVF.SetSelection( MakeSelection(nStartPara, nStartIndex, nEndPara, nEndIndex) );
aRetVal = rCacheVF.Copy();
rCacheVF.SetSelection( aOldSelection ); // restore
return aRetVal;
}
catch( const uno::RuntimeException& )
{
return false;
}
}
Rectangle AccessibleStaticTextBase_Impl::GetParagraphBoundingBox() const
{
Rectangle aRect;
if( mpTextParagraph )
{
awt::Rectangle aAwtRect = mpTextParagraph->getBounds();
aRect = Rectangle( Point( aAwtRect.X, aAwtRect.Y ), Size( aAwtRect.Width, aAwtRect.Height ) );
}
else
{
aRect.SetEmpty();
}
return aRect;
}
//the input argument is the index(including "\n" ) in the string.
//the function will calculate the actual index(not including "\n") in the string.
//and return true if the index is just at a "\n"
bool AccessibleStaticTextBase_Impl::RemoveLineBreakCount( sal_Int32& rIndex )
{
// get the total char number inside the cell.
sal_Int32 i, nCount, nParas;
for( i=0, nCount=0, nParas=GetParagraphCount(); i<nParas; ++i )
nCount += GetParagraph(i).getCharacterCount();
nCount = nCount + (nParas-1);
if( nCount == 0 && rIndex == 0) return false;
sal_Int32 nCurrPara, nCurrCount;
sal_Int32 nLineBreakPos = 0, nLineBreakCount = 0;
sal_Int32 nParaCount = GetParagraphCount();
for ( nCurrCount = 0, nCurrPara = 0; nCurrPara < nParaCount; nCurrPara++ )
{
nCurrCount += GetParagraph( nCurrPara ).getCharacterCount();
nLineBreakPos = nCurrCount++;
if ( rIndex == nLineBreakPos )
{
rIndex -= (++nLineBreakCount);//(++nLineBreakCount);
if ( rIndex < 0)
{
rIndex = 0;
}
//if the index is at the last position of the last paragraph
//there is no "\n" , so we should increase rIndex by 1 and return false.
if ( (nCurrPara+1) == nParaCount )
{
rIndex++;
return false;
}
else
{
return true;
}
}
else if ( rIndex < nLineBreakPos )
{
rIndex -= nLineBreakCount;
return false;
}
else
{
nLineBreakCount++;
}
}
return false;
}
// AccessibleStaticTextBase implementation
AccessibleStaticTextBase::AccessibleStaticTextBase( ::std::unique_ptr< SvxEditSource > && pEditSource ) :
mpImpl( new AccessibleStaticTextBase_Impl() )
{
SolarMutexGuard aGuard;
SetEditSource( std::move(pEditSource) );
}
AccessibleStaticTextBase::~AccessibleStaticTextBase()
{
}
void AccessibleStaticTextBase::SetEditSource( ::std::unique_ptr< SvxEditSource > && pEditSource )
{
#ifdef DBG_UTIL
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX();
mpImpl->SetEditSource( std::move(pEditSource) );
#else
mpImpl->SetEditSource( std::move(pEditSource) );
#endif
}
void AccessibleStaticTextBase::SetEventSource( const uno::Reference< XAccessible >& rInterface )
{
mpImpl->SetEventSource( rInterface );
}
void AccessibleStaticTextBase::SetOffset( const Point& rPoint )
{
#ifdef DBG_UTIL
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX();
mpImpl->SetOffset( rPoint );
#else
mpImpl->SetOffset( rPoint );
#endif
}
void AccessibleStaticTextBase::Dispose()
{
mpImpl->Dispose();
}
// XAccessibleContext
sal_Int32 SAL_CALL AccessibleStaticTextBase::getAccessibleChildCount() throw (uno::RuntimeException, std::exception)
{
// no children at all
return 0;
}
uno::Reference< XAccessible > SAL_CALL AccessibleStaticTextBase::getAccessibleChild( sal_Int32 /*i*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
// no children at all
return uno::Reference< XAccessible >();
}
uno::Reference< XAccessible > SAL_CALL AccessibleStaticTextBase::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (uno::RuntimeException, std::exception)
{
// no children at all
return uno::Reference< XAccessible >();
}
// XAccessibleText
sal_Int32 SAL_CALL AccessibleStaticTextBase::getCaretPosition() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 i, nPos, nParas;
for( i=0, nPos=-1, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
{
if( (nPos=mpImpl->GetParagraph(i).getCaretPosition()) != -1 )
return nPos;
}
return nPos;
}
sal_Bool SAL_CALL AccessibleStaticTextBase::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
2002-06-26 14:43:05 +00:00
{
return setSelection(nIndex, nIndex);
2002-06-26 14:43:05 +00:00
}
sal_Unicode SAL_CALL AccessibleStaticTextBase::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
EPosition aPos( mpImpl->Index2Internal(nIndex) );
return mpImpl->GetParagraph( aPos.nPara ).getCharacter( aPos.nIndex );
}
uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleStaticTextBase::getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
//get the actual index without "\n"
mpImpl->RemoveLineBreakCount( nIndex );
EPosition aPos( mpImpl->Index2Internal(nIndex) );
return mpImpl->GetParagraph( aPos.nPara ).getCharacterAttributes( aPos.nIndex, aRequestedAttributes );
}
awt::Rectangle SAL_CALL AccessibleStaticTextBase::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
// #108900# Allow ranges for nIndex, as one-past-the-end
// values are now legal, too.
EPosition aPos( mpImpl->Range2Internal(nIndex) );
// #i70916# Text in spread sheet cells return the wrong extents
AccessibleEditableTextPara& rPara = mpImpl->GetParagraph( aPos.nPara );
awt::Rectangle aParaBounds( rPara.getBounds() );
awt::Rectangle aBounds( rPara.getCharacterBounds( aPos.nIndex ) );
aBounds.X += aParaBounds.X;
aBounds.Y += aParaBounds.Y;
return aBounds;
}
sal_Int32 SAL_CALL AccessibleStaticTextBase::getCharacterCount() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 i, nCount, nParas;
for( i=0, nCount=0, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
nCount += mpImpl->GetParagraph(i).getCharacterCount();
//count on the number of "\n" which equals number of paragraphs decrease 1.
nCount = nCount + (nParas-1);
return nCount;
}
sal_Int32 SAL_CALL AccessibleStaticTextBase::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
const sal_Int32 nParas( mpImpl->GetParagraphCount() );
sal_Int32 nIndex;
int i;
for( i=0; i<nParas; ++i )
{
// TODO: maybe exploit the fact that paragraphs are
// ordered vertically for early exit
// #i70916# Text in spread sheet cells return the wrong extents
AccessibleEditableTextPara& rPara = mpImpl->GetParagraph( i );
awt::Rectangle aParaBounds( rPara.getBounds() );
awt::Point aPoint( rPoint );
aPoint.X -= aParaBounds.X;
aPoint.Y -= aParaBounds.Y;
// #112814# Use correct index offset
if ( ( nIndex = rPara.getIndexAtPoint( aPoint ) ) != -1 )
return mpImpl->Internal2Index(EPosition(i, nIndex));
}
return -1;
}
OUString SAL_CALL AccessibleStaticTextBase::getSelectedText() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nStart( getSelectionStart() );
sal_Int32 nEnd( getSelectionEnd() );
// #104481# Return the empty string for 'no selection'
if( nStart < 0 || nEnd < 0 )
return OUString();
CWS-TOOLING: integrate CWS aw058 2008-11-19 14:27:57 +0100 aw r263994 : #i95264# corrected line primitive range calculation for hairlines 2008-11-18 11:31:52 +0100 wg r263754 : i96156 2008-11-18 11:22:38 +0100 wg r263752 : i96156 2008-11-13 11:46:49 +0100 aw r263626 : #i93169# used flag the wrong way; true means that nothing was done yet 2008-11-12 15:33:41 +0100 wg r263601 : i96156 2008-11-12 13:22:38 +0100 wg r263592 : i95527 2008-11-12 13:18:51 +0100 wg r263591 : i95527 2008-10-29 13:22:02 +0100 aw r262794 : #i93485# identified reason and with PL's help changed problem accordingly with usage of an old fallback. This will need to be optimized again by HDU when he finds the time. 2008-10-28 18:23:04 +0100 aw r262763 : unxmacxi compiler warning fixed 2008-10-28 18:17:01 +0100 aw r262762 : unxmacxi compiler warning fixed 2008-10-28 17:55:18 +0100 aw r262761 : unxmacxi compiler warning fixed 2008-10-28 13:48:22 +0100 aw r262743 : #i93485# added UnifiedAlphaPrimitive2D to VclRenderer; corrected getB2DRange implementations for hairlines which are view-dependent 2008-10-28 12:40:55 +0100 aw r262735 : #i93485# had to move Pre/PostPaint to LocalPre/PostPaint since PrePaint is a virtual window method 2008-10-27 15:54:10 +0100 aw r262679 : #i19871# adapted the call order to parent implementations in some Nbc methods in SdrPathObj due to errors in SnapRect recalculation when GluePoints are involved 2008-10-24 18:31:48 +0200 aw r262661 : #i77187# disable all buttons in bezier toolbar when move and/or resize protected object is involved 2008-10-24 18:30:16 +0200 aw r262660 : #i77187# simplified and secured model changers, added toolbar update, disabled move drag start when polygon point is selected 2008-10-24 12:57:50 +0200 hdu r262635 : #i93485# use device transformation for SAL layer 2008-10-24 12:41:37 +0200 hdu r262634 : #i93485# use device transformation for SAL layer 2008-10-23 19:46:12 +0200 aw r262630 : mac compiler warning fixed 2008-10-23 18:15:02 +0200 aw r262628 : #i93485# modified dialog previews to use prerendering 2008-10-23 18:14:27 +0200 aw r262627 : #i93485# added assert when render helper uses Window as copy source 2008-10-22 18:07:30 +0200 aw r262610 : #i95264# fixes assertion 2008-10-22 14:31:51 +0200 aw r262606 : #i89661# also enabling DrawTransparent shortcut for VCL-Renderer 2008-10-22 14:10:31 +0200 aw r262604 : #i89661# new HitTest 2D primitive to support BoundRect and HitTest calculations/tests 2008-10-22 14:09:22 +0200 aw r262603 : #i89661# new HitTest tolerance, new TextFrame selection overlay, support for HitTest geometry 2008-10-22 14:08:16 +0200 aw r262602 : #i89661# correcting old HitTest tolerance expansion 2008-10-20 15:31:48 +0200 aw r262321 : #i89661# added patch to test it 2008-10-20 11:50:31 +0200 aw r262310 : #i87762# removed no longer used icons (aw053) 2008-10-17 15:41:48 +0200 aw r262288 : #i93169#, #i93180# FormControl corrections for Primitive handling 2008-10-17 15:40:54 +0200 aw r262287 : #i93169#, #i93180# FormControl corrections for Primitive handling 2008-10-16 11:12:44 +0200 aw r262253 : #i93595# removed superfluous grid interface 2008-10-16 11:11:20 +0200 aw r262252 : #i93595# changed grid display to sub-grid usage and new defaults 2008-10-15 15:09:40 +0200 aw r262234 : #i93597# moved flag for only vertical PageBorder, added reacting on it to primitive creation 2008-10-15 15:09:09 +0200 aw r262233 : #i93597# moved flag for only vertical PageBorder 2008-10-15 15:08:46 +0200 aw r262232 : #i93597# moved flag for only vertical PageBorder, added reacting on it to primitive creation 2008-10-14 16:27:07 +0200 aw r262207 : #i93648# (flushViewObjectContacts) and #i93318# (propertyChange) 2008-10-14 16:25:10 +0200 aw r262206 : #i93318# back to old state since detecting a change is not placed well at the primitive (which is a graphical information at the itme it was fetched). Instead i will add the needed check and flush at the FormControl's VOC 2008-10-14 13:47:38 +0200 aw r262201 : #i93318# added a change listener to the XControlModel and code to make the operator== at control primitive fail
2008-11-19 14:05:59 +00:00
return getTextRange( nStart, nEnd );
}
sal_Int32 SAL_CALL AccessibleStaticTextBase::getSelectionStart() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 i, nPos, nParas;
for( i=0, nPos=-1, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
{
if( (nPos=mpImpl->GetParagraph(i).getSelectionStart()) != -1 )
return nPos;
}
return nPos;
}
sal_Int32 SAL_CALL AccessibleStaticTextBase::getSelectionEnd() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 i, nPos, nParas;
for( i=0, nPos=-1, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
{
if( (nPos=mpImpl->GetParagraph(i).getSelectionEnd()) != -1 )
return nPos;
}
return nPos;
}
sal_Bool SAL_CALL AccessibleStaticTextBase::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
2002-08-16 10:58:06 +00:00
EPosition aStartIndex( mpImpl->Range2Internal(nStartIndex) );
EPosition aEndIndex( mpImpl->Range2Internal(nEndIndex) );
return mpImpl->SetSelection( aStartIndex.nPara, aStartIndex.nIndex,
aEndIndex.nPara, aEndIndex.nIndex );
}
OUString SAL_CALL AccessibleStaticTextBase::getText() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 i, nParas;
OUString aRes;
for( i=0, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
aRes += mpImpl->GetParagraph(i).getText();
return aRes;
}
OUString SAL_CALL AccessibleStaticTextBase::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
2002-08-16 10:58:06 +00:00
if( nStartIndex > nEndIndex )
::std::swap(nStartIndex, nEndIndex);
//if startindex equals endindex we will get nothing. So return an empty string directly.
if ( nStartIndex == nEndIndex )
{
return OUString();
}
bool bStart = mpImpl->RemoveLineBreakCount( nStartIndex );
//if the start index is just at a "\n", we need to begin from the next char
if ( bStart )
{
nStartIndex++;
}
//we need to find out whether the previous position of the current endindex is at "\n" or not
//if yes we need to mark it and add "\n" at the end of the result
sal_Int32 nTemp = nEndIndex - 1;
bool bEnd = mpImpl->RemoveLineBreakCount( nTemp );
bool bTemp = mpImpl->RemoveLineBreakCount( nEndIndex );
//if the below condition is true it indicates an empty paragraph with just a "\n"
//so we need to set one "\n" flag to avoid duplication.
if ( bStart && bEnd && ( nStartIndex == nEndIndex) )
{
bEnd = false;
}
//if the current endindex is at a "\n", we need to increase endindex by 1 to make sure
//the char before "\n" is included. Because string returned by this function will not include
//the char at the endindex.
if ( bTemp )
{
nEndIndex++;
}
OUString aRes;
2002-08-16 10:58:06 +00:00
EPosition aStartIndex( mpImpl->Range2Internal(nStartIndex) );
EPosition aEndIndex( mpImpl->Range2Internal(nEndIndex) );
// #102170# Special case: start and end paragraph are identical
if( aStartIndex.nPara == aEndIndex.nPara )
{
//we don't return the string directly now for that we have to do some further process for "\n"
aRes = mpImpl->GetParagraph( aStartIndex.nPara ).getTextRange( aStartIndex.nIndex, aEndIndex.nIndex );
}
else
{
sal_Int32 i( aStartIndex.nPara );
aRes = mpImpl->GetParagraph(i).getTextRange( aStartIndex.nIndex,
mpImpl->GetParagraph(i).getCharacterCount()/*-1*/);
++i;
// paragraphs inbetween are fully included
for( ; i<aEndIndex.nPara; ++i )
{
aRes += OUString(cNewLine);
aRes += mpImpl->GetParagraph(i).getText();
}
if( i<=aEndIndex.nPara )
{
//if the below condition is matched it means that endindex is at mid of the last paragraph
//we need to add a "\n" before we add the last part of the string.
if ( !bEnd && aEndIndex.nIndex )
{
aRes += OUString(cNewLine);
}
aRes += mpImpl->GetParagraph(i).getTextRange( 0, aEndIndex.nIndex );
}
}
//According to the flag we marked before, we have to add "\n" at the beginning
//or at the end of the result string.
if ( bStart )
{
aRes = OUString(cNewLine) + aRes;
}
if ( bEnd )
{
aRes += OUString(cNewLine);
}
return aRes;
}
css::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (css::lang::IndexOutOfBoundsException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
bool bLineBreak = mpImpl->RemoveLineBreakCount( nIndex );
2002-08-16 10:58:06 +00:00
EPosition aPos( mpImpl->Range2Internal(nIndex) );
css::accessibility::TextSegment aResult;
if( AccessibleTextType::PARAGRAPH == aTextType )
{
// #106393# Special casing one behind last paragraph is
// not necessary, since then, we return the content and
// boundary of that last paragraph. Range2Internal is
// tolerant against that, and returns the last paragraph
// in aPos.nPara.
// retrieve full text of the paragraph
aResult.SegmentText = mpImpl->GetParagraph( aPos.nPara ).getText();
// #112814# Adapt the start index with the paragraph offset
aResult.SegmentStart = mpImpl->Internal2Index( EPosition( aPos.nPara, 0 ) );
aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
}
else if ( AccessibleTextType::ATTRIBUTE_RUN == aTextType )
{
SvxAccessibleTextAdapter& rTextForwarder = mpImpl->GetParagraph( aPos.nIndex ).GetTextForwarder();
sal_Int32 nStartIndex, nEndIndex;
if ( rTextForwarder.GetAttributeRun( nStartIndex, nEndIndex, aPos.nPara, aPos.nIndex, true ) )
{
aResult.SegmentText = getTextRange( nStartIndex, nEndIndex );
aResult.SegmentStart = nStartIndex;
aResult.SegmentEnd = nEndIndex;
}
}
else
{
// No special handling required, forward to wrapped class
aResult = mpImpl->GetParagraph( aPos.nPara ).getTextAtIndex( aPos.nIndex, aTextType );
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
if ( bLineBreak )
{
aResult.SegmentText = OUString(cNewLine);
}
}
return aResult;
}
css::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (css::lang::IndexOutOfBoundsException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nOldIdx = nIndex;
bool bLineBreak = mpImpl->RemoveLineBreakCount( nIndex );
2002-08-16 10:58:06 +00:00
EPosition aPos( mpImpl->Range2Internal(nIndex) );
css::accessibility::TextSegment aResult;
if( AccessibleTextType::PARAGRAPH == aTextType )
{
if( aPos.nIndex == mpImpl->GetParagraph( aPos.nPara ).getCharacterCount() )
{
// #103589# Special casing one behind the last paragraph
aResult.SegmentText = mpImpl->GetParagraph( aPos.nPara ).getText();
// #112814# Adapt the start index with the paragraph offset
aResult.SegmentStart = mpImpl->Internal2Index( EPosition( aPos.nPara, 0 ) );
}
else if( aPos.nPara > 0 )
{
aResult.SegmentText = mpImpl->GetParagraph( aPos.nPara - 1 ).getText();
// #112814# Adapt the start index with the paragraph offset
aResult.SegmentStart = mpImpl->Internal2Index( EPosition( aPos.nPara - 1, 0 ) );
}
aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
}
else
{
// No special handling required, forward to wrapped class
aResult = mpImpl->GetParagraph( aPos.nPara ).getTextBeforeIndex( aPos.nIndex, aTextType );
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
if ( bLineBreak && (nOldIdx-1) >= 0)
{
aResult = getTextAtIndex( nOldIdx-1, aTextType );
}
}
return aResult;
}
css::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (css::lang::IndexOutOfBoundsException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nTemp = nIndex+1;
bool bLineBreak = mpImpl->RemoveLineBreakCount( nTemp );
mpImpl->RemoveLineBreakCount( nIndex );
2002-08-16 10:58:06 +00:00
EPosition aPos( mpImpl->Range2Internal(nIndex) );
css::accessibility::TextSegment aResult;
if( AccessibleTextType::PARAGRAPH == aTextType )
{
// Special casing one behind the last paragraph is not
// necessary, this case is invalid here for
// getTextBehindIndex
if( aPos.nPara + 1 < mpImpl->GetParagraphCount() )
{
aResult.SegmentText = mpImpl->GetParagraph( aPos.nPara + 1 ).getText();
// #112814# Adapt the start index with the paragraph offset
aResult.SegmentStart = mpImpl->Internal2Index( EPosition( aPos.nPara + 1, 0 ) );
aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
}
}
else
{
// No special handling required, forward to wrapped class
aResult = mpImpl->GetParagraph( aPos.nPara ).getTextBehindIndex( aPos.nIndex, aTextType );
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
if ( bLineBreak )
{
aResult.SegmentText = OUString(cNewLine) + aResult.SegmentText;
}
}
return aResult;
}
sal_Bool SAL_CALL AccessibleStaticTextBase::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
2002-08-16 10:58:06 +00:00
if( nStartIndex > nEndIndex )
::std::swap(nStartIndex, nEndIndex);
EPosition aStartIndex( mpImpl->Range2Internal(nStartIndex) );
EPosition aEndIndex( mpImpl->Range2Internal(nEndIndex) );
return mpImpl->CopyText( aStartIndex.nPara, aStartIndex.nIndex,
aEndIndex.nPara, aEndIndex.nIndex );
}
// XAccessibleTextAttributes
uno::Sequence< beans::PropertyValue > AccessibleStaticTextBase::getDefaultAttributes( const uno::Sequence< OUString >& RequestedAttributes ) throw (uno::RuntimeException, std::exception)
{
// get the intersection of the default attributes of all paragraphs
SolarMutexGuard aGuard;
PropertyValueVector aDefAttrVec(
comphelper::sequenceToContainer<PropertyValueVector>(mpImpl->GetParagraph( 0 ).getDefaultAttributes( RequestedAttributes )) );
const sal_Int32 nParaCount = mpImpl->GetParagraphCount();
for ( sal_Int32 nPara = 1; nPara < nParaCount; ++nPara )
{
uno::Sequence< beans::PropertyValue > aSeq = mpImpl->GetParagraph( nPara ).getDefaultAttributes( RequestedAttributes );
PropertyValueVector aIntersectionVec;
PropertyValueVector::const_iterator aEnd = aDefAttrVec.end();
for ( PropertyValueVector::const_iterator aItr = aDefAttrVec.begin(); aItr != aEnd; ++aItr )
{
const beans::PropertyValue* pItr = aSeq.getConstArray();
const beans::PropertyValue* pEnd = pItr + aSeq.getLength();
const beans::PropertyValue* pFind = ::std::find_if( pItr, pEnd, ::std::bind2nd( PropertyValueEqualFunctor(), std::cref( *aItr ) ) );
if ( pFind != pEnd )
{
aIntersectionVec.push_back( *pFind );
}
}
aDefAttrVec.swap( aIntersectionVec );
if ( aDefAttrVec.empty() )
{
break;
}
}
return comphelper::containerToSequence(aDefAttrVec);
}
uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleStaticTextBase::getRunAttributes( sal_Int32 nIndex, const uno::Sequence< OUString >& RequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
{
// get those default attributes of the paragraph, which are not part
// of the intersection of all paragraphs and add them to the run attributes
SolarMutexGuard aGuard;
EPosition aPos( mpImpl->Index2Internal( nIndex ) );
AccessibleEditableTextPara& rPara = mpImpl->GetParagraph( aPos.nPara );
uno::Sequence< beans::PropertyValue > aDefAttrSeq = rPara.getDefaultAttributes( RequestedAttributes );
uno::Sequence< beans::PropertyValue > aRunAttrSeq = rPara.getRunAttributes( aPos.nIndex, RequestedAttributes );
uno::Sequence< beans::PropertyValue > aIntersectionSeq = getDefaultAttributes( RequestedAttributes );
PropertyValueVector aDiffVec;
const beans::PropertyValue* pDefAttr = aDefAttrSeq.getConstArray();
const sal_Int32 nLength = aDefAttrSeq.getLength();
for ( sal_Int32 i = 0; i < nLength; ++i )
{
const beans::PropertyValue* pItr = aIntersectionSeq.getConstArray();
const beans::PropertyValue* pEnd = pItr + aIntersectionSeq.getLength();
bool bNone = ::std::none_of( pItr, pEnd, ::std::bind2nd( PropertyValueEqualFunctor(), std::cref( pDefAttr[i] ) ) );
if ( bNone && pDefAttr[i].Handle != 0)
{
2009-11-30 15:58:46 +00:00
aDiffVec.push_back( pDefAttr[i] );
}
}
return ::comphelper::concatSequences( aRunAttrSeq, comphelper::containerToSequence(aDiffVec) );
}
CWS-TOOLING: integrate CWS swa11y32_2nd 2009-08-13 13:04:09 +0200 mav r274936 : #i104204# remove support for Ctrl-Tab 2009-08-13 09:59:22 +0200 od r274924 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit also object:state-changed:focus, if cursor is inside <XAccessibleText> object 2009-08-11 12:15:11 +0200 tl r274851 : CWS-TOOLING: rebase CWS swa11y32_2nd to trunk@274622 (milestone: DEV300:m54) 2009-07-14 17:35:03 +0200 tl r273982 : 2009-07-10 10:46:39 +0200 tl r273879 : CWS-TOOLING: rebase CWS swa11y32 to trunk@273468 (milestone: DEV300:m51) 2009-07-01 14:00:25 +0200 mav r273577 : #i102879# the text of the button should not change 2009-07-01 13:16:19 +0200 od r273574 : #159496# method <GetHelpAnchor_Impl(..)> - do not release the solar mutex 2009-06-29 15:29:10 +0200 od r273476 : #i95042# method <CreateXWindow(..)> - return instance <VCLXComboBox> for <Window> instance of type <MetricBox>. note: <MetricBox> is inherited from <ComboBox> 2009-06-23 15:49:32 +0200 mav r273283 : #i101967# fix tab-control implementation 2009-06-22 13:56:22 +0200 od r273229 : #i100938# method <text_wrapper_get_run_attributes(..)> - always provide start_offset and end_offset - do _not_ increment the end_offset provide by <accessibility::TextSegment> instance 2009-06-02 12:09:03 +0200 mav r272492 : #i101959# Let the additional dialog window add its childred to the parents tab-hierarchy 2009-06-02 09:55:39 +0200 mav r272484 : #i102015# allow to have indirect child windows in tab-hierarchy 2009-06-02 09:49:42 +0200 mav r272482 : #i102015# Let the windows containing the extension dialog controls add controls to the tab hierarchy 2009-05-27 15:45:33 +0200 od r272354 : #i101012# method <SvxIconChoiceCtrl_Impl::EntrySelected(..)> - emit vcl event LISTBOX_SELECT only in case that the given entry is selected. 2009-05-27 09:54:36 +0200 od r272333 : #i92103# map UNO-API accessible events list box entry expanded/collapsed to corresponding atk events. 2009-05-27 09:52:15 +0200 od r272331 : #i92103# process list box entry expanded/collapsed events 2009-05-27 09:49:19 +0200 od r272330 : #i92103# emit vcl event list box entry expanded/collapsed 2009-05-26 10:42:05 +0200 od r272283 : #i93269# correct fix: check success of <queryInterface> call 2009-05-04 15:52:04 +0200 od r271469 : #i92103# new vcl event ids VCLEVENT_LISTBOX_ENTRY_EXPANDED and VCLEVENT_LISTBOX_ENTRY_COLLAPSED 2009-05-04 15:10:20 +0200 od r271460 : #i92103# refine definition of new constants 2009-05-04 14:36:44 +0200 od r271454 : #i92103# new constants for indicating that a list box entry is expanded respectively collapsed. 2009-04-30 16:09:40 +0200 od r271421 : #i93269# method <atk_wrapper_focus_idle_handler(..)> - emit text_caret_moved event for <XAccessibleText> object, if cursor is inside the <XAccessibleText> object. 2009-04-22 14:00:10 +0200 tl r271105 : warning-free code 2009-04-22 09:17:30 +0200 tl r271073 : CWS-TOOLING: rebase CWS swa11y32 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 12:53:03 +0200 cd r270974 : #i83639# Check extendedhelp state to provide correct tool tip text 2009-04-03 13:07:13 +0200 tl r270471 : #i63983# changed accessible object names to empty strings 2009-04-01 15:52:09 +0200 tl r270336 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:12:42 +0200 tl r270333 : #i90991# accessible names and description for paragraphs should be empty 2009-04-01 15:10:34 +0200 tl r270331 : warning-free code 2009-04-01 12:54:44 +0200 tl r270319 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-04-01 12:52:56 +0200 tl r270318 : #i89176# Implementation of XAccessibleMultiLineText in EditEngine 2009-03-27 18:31:01 +0100 tbe r270166 : #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells 2009-03-13 13:43:54 +0100 tl r269476 : #i94322# ImpEditView::ShowCursor and nPara == USHRT_MAX problem fixed 2009-03-12 10:27:30 +0100 tl r269366 : warning-free code; unresolved external dbg_out when compiling with debug=t 2009-03-11 12:40:31 +0100 tl r269312 : warning-free code Solaris x86 2009-03-10 15:49:01 +0100 tl r269279 : #i86443# handle GetColumnCount() == 0 2009-03-10 10:48:32 +0100 cl r269254 : #i91742# name cells for accessibility 2009-03-09 17:06:33 +0100 cl r269203 : #i91742# call init on accessible cells
2009-08-26 13:37:34 +00:00
Rectangle AccessibleStaticTextBase::GetParagraphBoundingBox() const
{
return mpImpl->GetParagraphBoundingBox();
}
} // end of namespace accessibility
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */