1*3a700b0aSSteve Yin /************************************************************** 25fdc4257SSteve Yin * 3*3a700b0aSSteve Yin * Licensed to the Apache Software Foundation (ASF) under one 4*3a700b0aSSteve Yin * or more contributor license agreements. See the NOTICE file 5*3a700b0aSSteve Yin * distributed with this work for additional information 6*3a700b0aSSteve Yin * regarding copyright ownership. The ASF licenses this file 7*3a700b0aSSteve Yin * to you under the Apache License, Version 2.0 (the 8*3a700b0aSSteve Yin * "License"); you may not use this file except in compliance 9*3a700b0aSSteve Yin * with the License. You may obtain a copy of the License at 105fdc4257SSteve Yin * 11*3a700b0aSSteve Yin * http://www.apache.org/licenses/LICENSE-2.0 125fdc4257SSteve Yin * 13*3a700b0aSSteve Yin * Unless required by applicable law or agreed to in writing, 14*3a700b0aSSteve Yin * software distributed under the License is distributed on an 15*3a700b0aSSteve Yin * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3a700b0aSSteve Yin * KIND, either express or implied. See the License for the 17*3a700b0aSSteve Yin * specific language governing permissions and limitations 18*3a700b0aSSteve Yin * under the License. 195fdc4257SSteve Yin * 20*3a700b0aSSteve Yin *************************************************************/ 215fdc4257SSteve Yin 225fdc4257SSteve Yin ////////////////////////////////////////////////////////////////////// 235fdc4257SSteve Yin // AccTextBase.cpp: implementation of the CAccTextBase class. 245fdc4257SSteve Yin ////////////////////////////////////////////////////////////////////// 255fdc4257SSteve Yin #include "stdafx.h" 265fdc4257SSteve Yin #include <string> 275fdc4257SSteve Yin #define WNT 285fdc4257SSteve Yin 295fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleTextType.hpp> 305fdc4257SSteve Yin #include "AccTextBase.h" 315fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessible.hpp> 325fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleContext.hpp> 335fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 345fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleTextSelection.hpp> 355fdc4257SSteve Yin #include "MAccessible.h" 365fdc4257SSteve Yin 375fdc4257SSteve Yin using namespace com::sun::star::accessibility; 385fdc4257SSteve Yin using namespace com::sun::star::uno; 395fdc4257SSteve Yin using namespace rtl; 405fdc4257SSteve Yin 415fdc4257SSteve Yin ////////////////////////////////////////////////////////////////////// 425fdc4257SSteve Yin // Construction/Destruction 435fdc4257SSteve Yin ////////////////////////////////////////////////////////////////////// 445fdc4257SSteve Yin 455fdc4257SSteve Yin OUString ReplaceFourChar(OUString oldOUString); 465fdc4257SSteve Yin 475fdc4257SSteve Yin CAccTextBase::CAccTextBase() 485fdc4257SSteve Yin {} 495fdc4257SSteve Yin 505fdc4257SSteve Yin CAccTextBase::~CAccTextBase() 515fdc4257SSteve Yin {} 525fdc4257SSteve Yin 535fdc4257SSteve Yin 545fdc4257SSteve Yin /** 555fdc4257SSteve Yin * Get special selection. 565fdc4257SSteve Yin * @param startOffset Start selection offset. 575fdc4257SSteve Yin * @param endOffset End selection offset. 585fdc4257SSteve Yin * @param success Variant to accept the result of if the method call is successful. 595fdc4257SSteve Yin * @return Result. 605fdc4257SSteve Yin */ 615fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_addSelection(long startOffset, long endOffset) 625fdc4257SSteve Yin { 635fdc4257SSteve Yin 645fdc4257SSteve Yin CHECK_ENABLE_INF 655fdc4257SSteve Yin 665fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 675fdc4257SSteve Yin 685fdc4257SSteve Yin // #CHECK XInterface# 695fdc4257SSteve Yin if(pUNOInterface == NULL) 705fdc4257SSteve Yin return E_FAIL; 715fdc4257SSteve Yin 725fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 735fdc4257SSteve Yin 745fdc4257SSteve Yin Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY); 755fdc4257SSteve Yin 765fdc4257SSteve Yin if( pRExtension.is() ) 775fdc4257SSteve Yin { 785fdc4257SSteve Yin pRExtension->addSelection(0, startOffset, endOffset); 795fdc4257SSteve Yin return S_OK; 805fdc4257SSteve Yin } 815fdc4257SSteve Yin else 825fdc4257SSteve Yin { 835fdc4257SSteve Yin GetXInterface()->setSelection(startOffset, endOffset); 845fdc4257SSteve Yin return S_OK; 855fdc4257SSteve Yin } 865fdc4257SSteve Yin 875fdc4257SSteve Yin return E_FAIL; 885fdc4257SSteve Yin 895fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 905fdc4257SSteve Yin } 915fdc4257SSteve Yin 925fdc4257SSteve Yin /** 935fdc4257SSteve Yin * Get special attributes. 945fdc4257SSteve Yin * @param offset Offset. 955fdc4257SSteve Yin * @param startOffset Variant to accept start offset. 965fdc4257SSteve Yin * @param endOffset Variant to accept end offset. 975fdc4257SSteve Yin * @param textAttributes Variant to accept attributes. 985fdc4257SSteve Yin * @return Result. 995fdc4257SSteve Yin */ 1005fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_attributes(long offset, long * startOffset, long * endOffset, BSTR * textAttributes) 1015fdc4257SSteve Yin { 1025fdc4257SSteve Yin 1035fdc4257SSteve Yin CHECK_ENABLE_INF 1045fdc4257SSteve Yin 1055fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1065fdc4257SSteve Yin 1075fdc4257SSteve Yin if (startOffset == NULL || endOffset == NULL || textAttributes == NULL) 1085fdc4257SSteve Yin return E_INVALIDARG; 1095fdc4257SSteve Yin // #CHECK XInterface# 1105fdc4257SSteve Yin if(!pRXText.is()) 1115fdc4257SSteve Yin { 1125fdc4257SSteve Yin return E_FAIL; 1135fdc4257SSteve Yin } 1145fdc4257SSteve Yin 1155fdc4257SSteve Yin if( offset < 0 || offset > GetXInterface()->getCharacterCount() ) 1165fdc4257SSteve Yin return E_FAIL; 1175fdc4257SSteve Yin 1185fdc4257SSteve Yin std::wstring strAttrs; 1195fdc4257SSteve Yin 1205fdc4257SSteve Yin strAttrs += L"Version:1;"; 1215fdc4257SSteve Yin 1225fdc4257SSteve Yin Sequence< ::com::sun::star::beans::PropertyValue > pValues = GetXInterface()->getCharacterAttributes(offset, Sequence< rtl::OUString >()); 1235fdc4257SSteve Yin int nCount = pValues.getLength(); 1245fdc4257SSteve Yin 1255fdc4257SSteve Yin short numberingLevel = 0; 1265fdc4257SSteve Yin OUString numberingPrefix; 1275fdc4257SSteve Yin Any anyNumRule; 1285fdc4257SSteve Yin bool bHaveNumberingPrefixAttr = false; 1295fdc4257SSteve Yin bool bHaveNumberingLevel = false; 1305fdc4257SSteve Yin bool bHaveNumberingRules = false; 1315fdc4257SSteve Yin for(int i =0; i<nCount; i++) 1325fdc4257SSteve Yin { 1335fdc4257SSteve Yin 1345fdc4257SSteve Yin ::com::sun::star::beans::PropertyValue &pValue = pValues[i]; 1355fdc4257SSteve Yin if(pValue.Name.compareTo(OUString::createFromAscii("NumberingLevel"))==0) 1365fdc4257SSteve Yin { 1375fdc4257SSteve Yin if (pValue.Value != Any()) 1385fdc4257SSteve Yin pValue.Value >>= numberingLevel; 1395fdc4257SSteve Yin else 1405fdc4257SSteve Yin numberingLevel = -1; 1415fdc4257SSteve Yin bHaveNumberingLevel = true; 1425fdc4257SSteve Yin continue; 1435fdc4257SSteve Yin } 1445fdc4257SSteve Yin if(pValue.Name.compareTo(OUString::createFromAscii("NumberingPrefix"))==0) 1455fdc4257SSteve Yin { 1465fdc4257SSteve Yin pValue.Value >>=numberingPrefix; 1475fdc4257SSteve Yin bHaveNumberingPrefixAttr = true; 1485fdc4257SSteve Yin continue; 1495fdc4257SSteve Yin } 1505fdc4257SSteve Yin if(pValue.Name.compareTo(OUString::createFromAscii("NumberingRules"))==0) 1515fdc4257SSteve Yin { 1525fdc4257SSteve Yin bHaveNumberingRules = true; 1535fdc4257SSteve Yin anyNumRule = pValue.Value; 1545fdc4257SSteve Yin continue; 1555fdc4257SSteve Yin } 1565fdc4257SSteve Yin if (bHaveNumberingLevel && bHaveNumberingRules && bHaveNumberingPrefixAttr) 1575fdc4257SSteve Yin { 1585fdc4257SSteve Yin OLECHAR numProps[512] = {0}; 1595fdc4257SSteve Yin strAttrs+=L";"; 1605fdc4257SSteve Yin numberingPrefix = ReplaceFourChar(numberingPrefix); 1615fdc4257SSteve Yin CMAccessible::get_OLECHAR4Numbering(anyNumRule,numberingLevel,numberingPrefix,numProps); 1625fdc4257SSteve Yin strAttrs += numProps; 1635fdc4257SSteve Yin bHaveNumberingLevel = 0; 1645fdc4257SSteve Yin bHaveNumberingRules = 0; 1655fdc4257SSteve Yin } 1665fdc4257SSteve Yin if( (bHaveNumberingPrefixAttr && i > 1 ) || 1675fdc4257SSteve Yin (!bHaveNumberingPrefixAttr && i > 0 ) ) //element 0 is NumberingPrefix, not write alone 1685fdc4257SSteve Yin { 1695fdc4257SSteve Yin strAttrs+=L";"; 1705fdc4257SSteve Yin } 1715fdc4257SSteve Yin strAttrs += pValue.Name.getStr(); 1725fdc4257SSteve Yin strAttrs += L":"; 1735fdc4257SSteve Yin 1745fdc4257SSteve Yin OLECHAR pTemp[2048] = {0}; 1755fdc4257SSteve Yin 1765fdc4257SSteve Yin if (pValue.Name.compareTo(OUString::createFromAscii("CharBackColor"))==0 || 1775fdc4257SSteve Yin pValue.Name.compareTo(OUString::createFromAscii("CharColor"))==0 || 1785fdc4257SSteve Yin pValue.Name.compareTo(OUString::createFromAscii("CharUnderlineColor"))==0 ) 1795fdc4257SSteve Yin { 1805fdc4257SSteve Yin unsigned long nColor; 1815fdc4257SSteve Yin pValue.Value >>= nColor; 1825fdc4257SSteve Yin OLECHAR pBuf[64]; 1835fdc4257SSteve Yin swprintf( pBuf, L"%08X", nColor ); 1845fdc4257SSteve Yin pTemp[0]=L'#'; 1855fdc4257SSteve Yin wcscat( pTemp, pBuf ); 1865fdc4257SSteve Yin 1875fdc4257SSteve Yin } 1885fdc4257SSteve Yin else 1895fdc4257SSteve Yin { 1905fdc4257SSteve Yin CMAccessible::get_OLECHARFromAny(pValue.Value,pTemp); 1915fdc4257SSteve Yin } 1925fdc4257SSteve Yin 1935fdc4257SSteve Yin strAttrs +=pTemp; 1945fdc4257SSteve Yin } 1955fdc4257SSteve Yin strAttrs +=L";"; 1965fdc4257SSteve Yin // #CHECK# 1975fdc4257SSteve Yin if(*textAttributes) 1985fdc4257SSteve Yin SysFreeString(*textAttributes); 1995fdc4257SSteve Yin *textAttributes = SysAllocString(strAttrs.c_str()); 2005fdc4257SSteve Yin 2015fdc4257SSteve Yin if( offset < GetXInterface()->getCharacterCount() ) 2025fdc4257SSteve Yin { 2035fdc4257SSteve Yin TextSegment textSeg = GetXInterface()->getTextAtIndex(offset, AccessibleTextType::ATTRIBUTE_RUN); 2045fdc4257SSteve Yin *startOffset = textSeg.SegmentStart; 2055fdc4257SSteve Yin *endOffset = textSeg.SegmentEnd; 2065fdc4257SSteve Yin } 2075fdc4257SSteve Yin else 2085fdc4257SSteve Yin { 2095fdc4257SSteve Yin *startOffset = offset; 2105fdc4257SSteve Yin *endOffset = offset; 2115fdc4257SSteve Yin } 2125fdc4257SSteve Yin 2135fdc4257SSteve Yin return S_OK; 2145fdc4257SSteve Yin 2155fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2165fdc4257SSteve Yin } 2175fdc4257SSteve Yin 2185fdc4257SSteve Yin /** 2195fdc4257SSteve Yin * Get caret position. 2205fdc4257SSteve Yin * @param offset Variant to accept caret offset. 2215fdc4257SSteve Yin * @return Result. 2225fdc4257SSteve Yin */ 2235fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_caretOffset(long * offset) 2245fdc4257SSteve Yin { 2255fdc4257SSteve Yin 2265fdc4257SSteve Yin CHECK_ENABLE_INF 2275fdc4257SSteve Yin 2285fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2295fdc4257SSteve Yin 2305fdc4257SSteve Yin if (offset == NULL) 2315fdc4257SSteve Yin return E_INVALIDARG; 2325fdc4257SSteve Yin // #CHECK XInterface# 2335fdc4257SSteve Yin if(!pRXText.is()) 2345fdc4257SSteve Yin { 2355fdc4257SSteve Yin *offset = 0; 2365fdc4257SSteve Yin return S_OK; 2375fdc4257SSteve Yin } 2385fdc4257SSteve Yin 2395fdc4257SSteve Yin *offset = GetXInterface()->getCaretPosition(); 2405fdc4257SSteve Yin return S_OK; 2415fdc4257SSteve Yin 2425fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2435fdc4257SSteve Yin } 2445fdc4257SSteve Yin 2455fdc4257SSteve Yin /** 2465fdc4257SSteve Yin * Get character count. 2475fdc4257SSteve Yin * @param nCharacters Variant to accept character count. 2485fdc4257SSteve Yin * @return Result. 2495fdc4257SSteve Yin */ 2505fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_characterCount(long * nCharacters) 2515fdc4257SSteve Yin { 2525fdc4257SSteve Yin 2535fdc4257SSteve Yin CHECK_ENABLE_INF 2545fdc4257SSteve Yin 2555fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2565fdc4257SSteve Yin 2575fdc4257SSteve Yin if (nCharacters == NULL) 2585fdc4257SSteve Yin return E_INVALIDARG; 2595fdc4257SSteve Yin // #CHECK XInterface# 2605fdc4257SSteve Yin if(!pRXText.is()) 2615fdc4257SSteve Yin { 2625fdc4257SSteve Yin *nCharacters = 0; 2635fdc4257SSteve Yin return S_OK; 2645fdc4257SSteve Yin } 2655fdc4257SSteve Yin 2665fdc4257SSteve Yin *nCharacters = GetXInterface()->getCharacterCount(); 2675fdc4257SSteve Yin return S_OK; 2685fdc4257SSteve Yin 2695fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2705fdc4257SSteve Yin } 2715fdc4257SSteve Yin 2725fdc4257SSteve Yin /** 2735fdc4257SSteve Yin * Get character extents. 2745fdc4257SSteve Yin * @param offset Offset. 2755fdc4257SSteve Yin * @param x Variant to accept x position. 2765fdc4257SSteve Yin * @param y Variant to accept y position. 2775fdc4257SSteve Yin * @param width Variant to accept width. 2785fdc4257SSteve Yin * @param Height Variant to accept height. 2795fdc4257SSteve Yin * @return Result. 2805fdc4257SSteve Yin */ 2815fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_characterExtents(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height) 2825fdc4257SSteve Yin { 2835fdc4257SSteve Yin 2845fdc4257SSteve Yin CHECK_ENABLE_INF 2855fdc4257SSteve Yin 2865fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2875fdc4257SSteve Yin 2885fdc4257SSteve Yin if (x == NULL || height == NULL || y == NULL || width == NULL) 2895fdc4257SSteve Yin return E_INVALIDARG; 2905fdc4257SSteve Yin // #CHECK XInterface# 2915fdc4257SSteve Yin if(!pRXText.is()) 2925fdc4257SSteve Yin return E_FAIL; 2935fdc4257SSteve Yin 2945fdc4257SSteve Yin if(offset < 0 || offset > GetXInterface()->getCharacterCount() ) 2955fdc4257SSteve Yin return E_FAIL; 2965fdc4257SSteve Yin 2975fdc4257SSteve Yin com::sun::star::awt::Rectangle rectangle; 2985fdc4257SSteve Yin rectangle = GetXInterface()->getCharacterBounds(offset); 2995fdc4257SSteve Yin 3005fdc4257SSteve Yin //IA2Point aPoint; 3015fdc4257SSteve Yin com::sun::star::awt::Point aPoint; 3025fdc4257SSteve Yin 3035fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 3045fdc4257SSteve Yin if( !pRContext.is() ) 3055fdc4257SSteve Yin { 3065fdc4257SSteve Yin return E_FAIL; 3075fdc4257SSteve Yin } 3085fdc4257SSteve Yin Reference<XAccessibleComponent> pRComp(pRContext,UNO_QUERY); 3095fdc4257SSteve Yin if( pRComp.is() ) 3105fdc4257SSteve Yin { 3115fdc4257SSteve Yin if(coordType == IA2_COORDTYPE_SCREEN_RELATIVE) 3125fdc4257SSteve Yin { 3135fdc4257SSteve Yin ::com::sun::star::awt::Point pt = pRComp->getLocationOnScreen(); 3145fdc4257SSteve Yin aPoint.X = pt.X; 3155fdc4257SSteve Yin aPoint.Y = pt.Y; 3165fdc4257SSteve Yin } 3175fdc4257SSteve Yin else if(coordType == IA2_COORDTYPE_PARENT_RELATIVE) 3185fdc4257SSteve Yin { 3195fdc4257SSteve Yin ::com::sun::star::awt::Point pt = pRComp->getLocation(); 3205fdc4257SSteve Yin aPoint.X = pt.X; 3215fdc4257SSteve Yin aPoint.Y = pt.Y; 3225fdc4257SSteve Yin } 3235fdc4257SSteve Yin } 3245fdc4257SSteve Yin rectangle.X = rectangle.X + aPoint.X; 3255fdc4257SSteve Yin rectangle.Y = rectangle.Y + aPoint.Y; 3265fdc4257SSteve Yin 3275fdc4257SSteve Yin *x = rectangle.X; 3285fdc4257SSteve Yin *y = rectangle.Y; 3295fdc4257SSteve Yin 3305fdc4257SSteve Yin // GetXInterface()->getCharacterBounds() have different implement in different acc component 3315fdc4257SSteve Yin // But we need return the width/height == 1 for every component when offset == text length. 3325fdc4257SSteve Yin // So we ignore the return result of GetXInterface()->getCharacterBounds() when offset == text length. 3335fdc4257SSteve Yin if( offset == GetXInterface()->getCharacterCount() ) 3345fdc4257SSteve Yin { 3355fdc4257SSteve Yin *width = 1; 3365fdc4257SSteve Yin *height = 1; 3375fdc4257SSteve Yin } 3385fdc4257SSteve Yin else 3395fdc4257SSteve Yin { 3405fdc4257SSteve Yin *width = rectangle.Width; 3415fdc4257SSteve Yin *height = rectangle.Height; 3425fdc4257SSteve Yin } 3435fdc4257SSteve Yin 3445fdc4257SSteve Yin return S_OK; 3455fdc4257SSteve Yin 3465fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 3475fdc4257SSteve Yin } 3485fdc4257SSteve Yin 3495fdc4257SSteve Yin /** 3505fdc4257SSteve Yin * Get selections count. 3515fdc4257SSteve Yin * @param nSelections Variant to accept selections count. 3525fdc4257SSteve Yin * @return Result. 3535fdc4257SSteve Yin */ 3545fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_nSelections(long * nSelections) 3555fdc4257SSteve Yin { 3565fdc4257SSteve Yin 3575fdc4257SSteve Yin CHECK_ENABLE_INF 3585fdc4257SSteve Yin 3595fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 3605fdc4257SSteve Yin 3615fdc4257SSteve Yin if (nSelections == NULL) 3625fdc4257SSteve Yin return E_INVALIDARG; 3635fdc4257SSteve Yin // #CHECK XInterface# 3645fdc4257SSteve Yin if(pUNOInterface == NULL) 3655fdc4257SSteve Yin { 3665fdc4257SSteve Yin *nSelections = 0; 3675fdc4257SSteve Yin return S_OK; 3685fdc4257SSteve Yin } 3695fdc4257SSteve Yin 3705fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 3715fdc4257SSteve Yin 3725fdc4257SSteve Yin Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY); 3735fdc4257SSteve Yin 3745fdc4257SSteve Yin if( pRExtension.is() ) 3755fdc4257SSteve Yin { 3765fdc4257SSteve Yin *nSelections = pRExtension->getSelectedPortionCount(); 3775fdc4257SSteve Yin return S_OK; 3785fdc4257SSteve Yin } 3795fdc4257SSteve Yin 3805fdc4257SSteve Yin long iLength = GetXInterface()->getSelectedText().getLength(); 3815fdc4257SSteve Yin if( iLength> 0) 3825fdc4257SSteve Yin { 3835fdc4257SSteve Yin *nSelections = 1; 3845fdc4257SSteve Yin return S_OK; 3855fdc4257SSteve Yin } 3865fdc4257SSteve Yin 3875fdc4257SSteve Yin *nSelections = 0; 3885fdc4257SSteve Yin return S_OK; 3895fdc4257SSteve Yin 3905fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 3915fdc4257SSteve Yin } 3925fdc4257SSteve Yin 3935fdc4257SSteve Yin /** 3945fdc4257SSteve Yin * Get offset of some special point. 3955fdc4257SSteve Yin * @param x X position of one point. 3965fdc4257SSteve Yin * @param x Y position of one point. 3975fdc4257SSteve Yin * @param coordType Type. 3985fdc4257SSteve Yin * @param offset Variant to accept offset. 3995fdc4257SSteve Yin * @return Result. 4005fdc4257SSteve Yin */ 4015fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_offsetAtPoint(long x, long y, IA2CoordinateType, long * offset) 4025fdc4257SSteve Yin { 4035fdc4257SSteve Yin CHECK_ENABLE_INF 4045fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4055fdc4257SSteve Yin 4065fdc4257SSteve Yin if (offset == NULL) 4075fdc4257SSteve Yin return E_INVALIDARG; 4085fdc4257SSteve Yin // #CHECK XInterface# 4095fdc4257SSteve Yin if(!pRXText.is()) 4105fdc4257SSteve Yin return E_FAIL; 4115fdc4257SSteve Yin 4125fdc4257SSteve Yin com::sun::star::awt::Point point; 4135fdc4257SSteve Yin point.X = x; 4145fdc4257SSteve Yin point.Y = y; 4155fdc4257SSteve Yin *offset = GetXInterface()->getIndexAtPoint(point); 4165fdc4257SSteve Yin return S_OK; 4175fdc4257SSteve Yin 4185fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 4195fdc4257SSteve Yin } 4205fdc4257SSteve Yin 4215fdc4257SSteve Yin /** 4225fdc4257SSteve Yin * Get selection range. 4235fdc4257SSteve Yin * @param selection selection count. 4245fdc4257SSteve Yin * @param startOffset Variant to accept the start offset of special selection. 4255fdc4257SSteve Yin * @param endOffset Variant to accept the end offset of special selection. 4265fdc4257SSteve Yin * @return Result. 4275fdc4257SSteve Yin */ 4285fdc4257SSteve Yin 4295fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_selection(long selectionIndex, long * startOffset, long * endOffset) 4305fdc4257SSteve Yin { 4315fdc4257SSteve Yin 4325fdc4257SSteve Yin CHECK_ENABLE_INF 4335fdc4257SSteve Yin 4345fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4355fdc4257SSteve Yin 4365fdc4257SSteve Yin if (startOffset == NULL || endOffset == NULL ) 4375fdc4257SSteve Yin return E_INVALIDARG; 4385fdc4257SSteve Yin // #CHECK XInterface# 4395fdc4257SSteve Yin if(pUNOInterface == NULL ) 4405fdc4257SSteve Yin return E_FAIL; 4415fdc4257SSteve Yin 4425fdc4257SSteve Yin long nSelection = 0; 4435fdc4257SSteve Yin get_nSelections(&nSelection); 4445fdc4257SSteve Yin 4455fdc4257SSteve Yin if(selectionIndex >= nSelection || selectionIndex < 0 ) 4465fdc4257SSteve Yin return E_FAIL; 4475fdc4257SSteve Yin 4485fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 4495fdc4257SSteve Yin 4505fdc4257SSteve Yin Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY); 4515fdc4257SSteve Yin 4525fdc4257SSteve Yin if( pRExtension.is() ) 4535fdc4257SSteve Yin { 4545fdc4257SSteve Yin *startOffset = pRExtension->getSeletedPositionStart(selectionIndex); 4555fdc4257SSteve Yin *endOffset = pRExtension->getSeletedPositionEnd(selectionIndex); 4565fdc4257SSteve Yin return S_OK; 4575fdc4257SSteve Yin } 4585fdc4257SSteve Yin else if(GetXInterface()->getSelectionEnd() > -1) 4595fdc4257SSteve Yin { 4605fdc4257SSteve Yin *startOffset = GetXInterface()->getSelectionStart(); 4615fdc4257SSteve Yin *endOffset = GetXInterface()->getSelectionEnd(); 4625fdc4257SSteve Yin return S_OK; 4635fdc4257SSteve Yin } 4645fdc4257SSteve Yin 4655fdc4257SSteve Yin *startOffset = 0; 4665fdc4257SSteve Yin *endOffset = 0; 4675fdc4257SSteve Yin return E_FAIL; 4685fdc4257SSteve Yin 4695fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 4705fdc4257SSteve Yin } 4715fdc4257SSteve Yin 4725fdc4257SSteve Yin /** 4735fdc4257SSteve Yin * Get special text. 4745fdc4257SSteve Yin * @param startOffset Start position of special range. 4755fdc4257SSteve Yin * @param endOffset End position of special range. 4765fdc4257SSteve Yin * @param text Variant to accept the text of special range. 4775fdc4257SSteve Yin * @return Result. 4785fdc4257SSteve Yin */ 4795fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_text(long startOffset, long endOffset, BSTR * text) 4805fdc4257SSteve Yin { 4815fdc4257SSteve Yin 4825fdc4257SSteve Yin CHECK_ENABLE_INF 4835fdc4257SSteve Yin 4845fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4855fdc4257SSteve Yin 4865fdc4257SSteve Yin if (text == NULL) 4875fdc4257SSteve Yin return E_INVALIDARG; 4885fdc4257SSteve Yin // #CHECK XInterface# 4895fdc4257SSteve Yin if(!pRXText.is()) 4905fdc4257SSteve Yin return E_FAIL; 4915fdc4257SSteve Yin 4925fdc4257SSteve Yin if (endOffset < -1 || endOffset < startOffset ) 4935fdc4257SSteve Yin { 4945fdc4257SSteve Yin return E_FAIL; 4955fdc4257SSteve Yin } 4965fdc4257SSteve Yin 4975fdc4257SSteve Yin ::rtl::OUString ouStr; 4985fdc4257SSteve Yin if (endOffset == -1 ) 4995fdc4257SSteve Yin { 5005fdc4257SSteve Yin long nLen=0; 5015fdc4257SSteve Yin if(SUCCEEDED(get_characterCount(&nLen))) 5025fdc4257SSteve Yin { 5035fdc4257SSteve Yin ouStr = GetXInterface()->getTextRange( 0, nLen ); 5045fdc4257SSteve Yin } 5055fdc4257SSteve Yin } 5065fdc4257SSteve Yin else 5075fdc4257SSteve Yin { 5085fdc4257SSteve Yin ouStr = GetXInterface()->getTextRange( startOffset, endOffset ); 5095fdc4257SSteve Yin } 5105fdc4257SSteve Yin 5115fdc4257SSteve Yin SysFreeString(*text); 5125fdc4257SSteve Yin *text = SysAllocString((OLECHAR*)ouStr.getStr()); 5135fdc4257SSteve Yin return S_OK; 5145fdc4257SSteve Yin 5155fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 5165fdc4257SSteve Yin } 5175fdc4257SSteve Yin 5185fdc4257SSteve Yin /** 5195fdc4257SSteve Yin * Get special text before some position. 5205fdc4257SSteve Yin * @param offset Special position. 5215fdc4257SSteve Yin * @param boundaryType Boundary type. 5225fdc4257SSteve Yin * @param startOffset Variant to accept the start offset. 5235fdc4257SSteve Yin * @param endOffset Variant to accept the end offset. 5245fdc4257SSteve Yin * @param text Variant to accept the special text. 5255fdc4257SSteve Yin * @return Result. 5265fdc4257SSteve Yin */ 5275fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_textBeforeOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 5285fdc4257SSteve Yin { 5295fdc4257SSteve Yin 5305fdc4257SSteve Yin CHECK_ENABLE_INF 5315fdc4257SSteve Yin 5325fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 5335fdc4257SSteve Yin 5345fdc4257SSteve Yin // #CHECK# 5355fdc4257SSteve Yin if (startOffset == NULL || endOffset == NULL || text == NULL) 5365fdc4257SSteve Yin return E_INVALIDARG; 5375fdc4257SSteve Yin // #CHECK XInterface# 5385fdc4257SSteve Yin if(!pRXText.is()) 5395fdc4257SSteve Yin return E_FAIL; 5405fdc4257SSteve Yin 5415fdc4257SSteve Yin // In New UNO IAccessibleText.idl these constant values are defined as follows: 5425fdc4257SSteve Yin // 5435fdc4257SSteve Yin // const long TEXT_BOUNDARY_CHAR = -1; 5445fdc4257SSteve Yin // const long TEXT_BOUNDARY_TO_CURSOR_POS = -2; 5455fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_WORD = -3; 5465fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_WORD = -4; 5475fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_SENTENCE = -5; 5485fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_SENTENCE = -6; 5495fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_LINE = -7; 5505fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_LINE = -8; 5515fdc4257SSteve Yin // 5525fdc4257SSteve Yin // In UNO, the corresponding values are as follows: 5535fdc4257SSteve Yin // 5545fdc4257SSteve Yin // const short CHARACTER = 1; 5555fdc4257SSteve Yin // const short WORD = 2; 5565fdc4257SSteve Yin // const short SENTENCE = 3; 5575fdc4257SSteve Yin // const short PARAGRAPH = 4; 5585fdc4257SSteve Yin // const short LINE = 5; 5595fdc4257SSteve Yin // const short GLYPH = 6; 5605fdc4257SSteve Yin // const short ATTRIBUTE_RUN = 7; 5615fdc4257SSteve Yin // 5625fdc4257SSteve Yin 5635fdc4257SSteve Yin long lUnoBoundaryType; 5645fdc4257SSteve Yin 5655fdc4257SSteve Yin switch(boundaryType) 5665fdc4257SSteve Yin { 5675fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_CHAR: 5685fdc4257SSteve Yin lUnoBoundaryType = 1; // CHARACTER; 5695fdc4257SSteve Yin break; 5705fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_WORD: 5715fdc4257SSteve Yin lUnoBoundaryType = 2; // WORD; 5725fdc4257SSteve Yin break; 5735fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_SENTENCE: 5745fdc4257SSteve Yin lUnoBoundaryType = 3; // SENTENCE; 5755fdc4257SSteve Yin break; 5765fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_LINE: 5775fdc4257SSteve Yin lUnoBoundaryType = 5; // LINE; 5785fdc4257SSteve Yin break; 5795fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_PARAGRAPH: 5805fdc4257SSteve Yin lUnoBoundaryType = 4; 5815fdc4257SSteve Yin break; 5825fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_ALL: 5835fdc4257SSteve Yin { 5845fdc4257SSteve Yin long nChar; 5855fdc4257SSteve Yin get_nCharacters( &nChar ); 5865fdc4257SSteve Yin *startOffset = 0; 5875fdc4257SSteve Yin *endOffset = nChar; 5885fdc4257SSteve Yin return get_text(0, nChar, text); 5895fdc4257SSteve Yin } 5905fdc4257SSteve Yin break; 5915fdc4257SSteve Yin default: 5925fdc4257SSteve Yin return E_FAIL; 5935fdc4257SSteve Yin } 5945fdc4257SSteve Yin 5955fdc4257SSteve Yin TextSegment segment = GetXInterface()->getTextBeforeIndex( offset, sal_Int16(lUnoBoundaryType)); 5965fdc4257SSteve Yin ::rtl::OUString ouStr = segment.SegmentText; 5975fdc4257SSteve Yin SysFreeString(*text); 5985fdc4257SSteve Yin *text = SysAllocString((OLECHAR*)ouStr.getStr()); 5995fdc4257SSteve Yin *startOffset = segment.SegmentStart; 6005fdc4257SSteve Yin *endOffset = segment.SegmentEnd; 6015fdc4257SSteve Yin 6025fdc4257SSteve Yin return S_OK; 6035fdc4257SSteve Yin 6045fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 6055fdc4257SSteve Yin } 6065fdc4257SSteve Yin 6075fdc4257SSteve Yin /** 6085fdc4257SSteve Yin * Get special text after some position. 6095fdc4257SSteve Yin * @param offset Special position. 6105fdc4257SSteve Yin * @param boundaryType Boundary type. 6115fdc4257SSteve Yin * @param startOffset Variant to accept the start offset. 6125fdc4257SSteve Yin * @param endOffset Variant to accept the end offset. 6135fdc4257SSteve Yin * @param text Variant to accept the special text. 6145fdc4257SSteve Yin * @return Result. 6155fdc4257SSteve Yin */ 6165fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_textAfterOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 6175fdc4257SSteve Yin { 6185fdc4257SSteve Yin 6195fdc4257SSteve Yin CHECK_ENABLE_INF 6205fdc4257SSteve Yin 6215fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 6225fdc4257SSteve Yin 6235fdc4257SSteve Yin if (startOffset == NULL || endOffset == NULL || text == NULL) 6245fdc4257SSteve Yin return E_INVALIDARG; 6255fdc4257SSteve Yin // #CHECK XInterface# 6265fdc4257SSteve Yin if(!pRXText.is()) 6275fdc4257SSteve Yin return E_FAIL; 6285fdc4257SSteve Yin 6295fdc4257SSteve Yin // In New UNO IAccessibleText.idl these constant values are defined as follows: 6305fdc4257SSteve Yin // 6315fdc4257SSteve Yin // const long TEXT_BOUNDARY_CHAR = -1; 6325fdc4257SSteve Yin // const long TEXT_BOUNDARY_TO_CURSOR_POS = -2; 6335fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_WORD = -3; 6345fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_WORD = -4; 6355fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_SENTENCE = -5; 6365fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_SENTENCE = -6; 6375fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_LINE = -7; 6385fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_LINE = -8; 6395fdc4257SSteve Yin // 6405fdc4257SSteve Yin // In UNO, the corresponding values are as follows: 6415fdc4257SSteve Yin // 6425fdc4257SSteve Yin // const short CHARACTER = 1; 6435fdc4257SSteve Yin // const short WORD = 2; 6445fdc4257SSteve Yin // const short SENTENCE = 3; 6455fdc4257SSteve Yin // const short PARAGRAPH = 4; 6465fdc4257SSteve Yin // const short LINE = 5; 6475fdc4257SSteve Yin // const short GLYPH = 6; 6485fdc4257SSteve Yin // const short ATTRIBUTE_RUN = 7; 6495fdc4257SSteve Yin // 6505fdc4257SSteve Yin 6515fdc4257SSteve Yin long lUnoBoundaryType; 6525fdc4257SSteve Yin switch(boundaryType) 6535fdc4257SSteve Yin { 6545fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_CHAR: 6555fdc4257SSteve Yin lUnoBoundaryType = 1; // CHARACTER; 6565fdc4257SSteve Yin break; 6575fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_WORD: 6585fdc4257SSteve Yin lUnoBoundaryType = 2; // WORD; 6595fdc4257SSteve Yin break; 6605fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_SENTENCE: 6615fdc4257SSteve Yin lUnoBoundaryType = 3; // SENTENCE; 6625fdc4257SSteve Yin break; 6635fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_LINE: 6645fdc4257SSteve Yin lUnoBoundaryType = 5; // LINE; 6655fdc4257SSteve Yin break; 6665fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_PARAGRAPH: 6675fdc4257SSteve Yin lUnoBoundaryType = 4; 6685fdc4257SSteve Yin break; 6695fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_ALL: 6705fdc4257SSteve Yin { 6715fdc4257SSteve Yin long nChar; 6725fdc4257SSteve Yin get_nCharacters( &nChar ); 6735fdc4257SSteve Yin *startOffset = 0; 6745fdc4257SSteve Yin *endOffset = nChar; 6755fdc4257SSteve Yin return get_text(0, nChar, text); 6765fdc4257SSteve Yin } 6775fdc4257SSteve Yin break; 6785fdc4257SSteve Yin default: 6795fdc4257SSteve Yin return E_FAIL; 6805fdc4257SSteve Yin } 6815fdc4257SSteve Yin 6825fdc4257SSteve Yin TextSegment segment = GetXInterface()->getTextBehindIndex( offset, sal_Int16(lUnoBoundaryType)); 6835fdc4257SSteve Yin ::rtl::OUString ouStr = segment.SegmentText; 6845fdc4257SSteve Yin SysFreeString(*text); 6855fdc4257SSteve Yin *text = SysAllocString((OLECHAR*)ouStr.getStr()); 6865fdc4257SSteve Yin *startOffset = segment.SegmentStart; 6875fdc4257SSteve Yin *endOffset = segment.SegmentEnd; 6885fdc4257SSteve Yin 6895fdc4257SSteve Yin return S_OK; 6905fdc4257SSteve Yin 6915fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 6925fdc4257SSteve Yin } 6935fdc4257SSteve Yin 6945fdc4257SSteve Yin /** 6955fdc4257SSteve Yin * Get special text at some position. 6965fdc4257SSteve Yin * @param offset Special position. 6975fdc4257SSteve Yin * @param boundaryType Boundary type. 6985fdc4257SSteve Yin * @param startOffset Variant to accept the start offset. 6995fdc4257SSteve Yin * @param endOffset Variant to accept the end offset. 7005fdc4257SSteve Yin * @param text Variant to accept the special text. 7015fdc4257SSteve Yin * @return Result. 7025fdc4257SSteve Yin */ 7035fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_textAtOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 7045fdc4257SSteve Yin { 7055fdc4257SSteve Yin 7065fdc4257SSteve Yin 7075fdc4257SSteve Yin CHECK_ENABLE_INF 7085fdc4257SSteve Yin 7095fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 7105fdc4257SSteve Yin 7115fdc4257SSteve Yin if (startOffset == NULL || text == NULL ||endOffset == NULL) 7125fdc4257SSteve Yin return E_INVALIDARG; 7135fdc4257SSteve Yin // #CHECK XInterface# 7145fdc4257SSteve Yin if(!pRXText.is()) 7155fdc4257SSteve Yin return E_FAIL; 7165fdc4257SSteve Yin 7175fdc4257SSteve Yin // In New UNO IAccessibleText.idl these constant values are defined as follows: 7185fdc4257SSteve Yin // 7195fdc4257SSteve Yin // const long TEXT_BOUNDARY_CHAR = -1; 7205fdc4257SSteve Yin // const long TEXT_BOUNDARY_TO_CURSOR_POS = -2; 7215fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_WORD = -3; 7225fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_WORD = -4; 7235fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_SENTENCE = -5; 7245fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_SENTENCE = -6; 7255fdc4257SSteve Yin // const long TEXT_BOUNDARY_START_OF_LINE = -7; 7265fdc4257SSteve Yin // const long TEXT_BOUNDARY_END_OF_LINE = -8; 7275fdc4257SSteve Yin // 7285fdc4257SSteve Yin // In UNO, the corresponding values are as follows: 7295fdc4257SSteve Yin // 7305fdc4257SSteve Yin // const short CHARACTER = 1; 7315fdc4257SSteve Yin // const short WORD = 2; 7325fdc4257SSteve Yin // const short SENTENCE = 3; 7335fdc4257SSteve Yin // const short PARAGRAPH = 4; 7345fdc4257SSteve Yin // const short LINE = 5; 7355fdc4257SSteve Yin // const short GLYPH = 6; 7365fdc4257SSteve Yin // const short ATTRIBUTE_RUN = 7; 7375fdc4257SSteve Yin // 7385fdc4257SSteve Yin 7395fdc4257SSteve Yin long lUnoBoundaryType; 7405fdc4257SSteve Yin 7415fdc4257SSteve Yin switch(boundaryType) 7425fdc4257SSteve Yin { 7435fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_CHAR: 7445fdc4257SSteve Yin lUnoBoundaryType = 1; // CHARACTER; 7455fdc4257SSteve Yin break; 7465fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_WORD: 7475fdc4257SSteve Yin lUnoBoundaryType = 2; // WORD; 7485fdc4257SSteve Yin break; 7495fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_SENTENCE: 7505fdc4257SSteve Yin lUnoBoundaryType = 3; // SENTENCE; 7515fdc4257SSteve Yin break; 7525fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_LINE: 7535fdc4257SSteve Yin lUnoBoundaryType = 5; // LINE; 7545fdc4257SSteve Yin break; 7555fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_PARAGRAPH: 7565fdc4257SSteve Yin lUnoBoundaryType = 4; 7575fdc4257SSteve Yin break; 7585fdc4257SSteve Yin case IA2_TEXT_BOUNDARY_ALL: 7595fdc4257SSteve Yin { 7605fdc4257SSteve Yin long nChar; 7615fdc4257SSteve Yin get_nCharacters( &nChar ); 7625fdc4257SSteve Yin *startOffset = 0; 7635fdc4257SSteve Yin *endOffset = nChar; 7645fdc4257SSteve Yin return get_text(0, nChar, text); 7655fdc4257SSteve Yin } 7665fdc4257SSteve Yin break; 7675fdc4257SSteve Yin default: 7685fdc4257SSteve Yin return E_FAIL; 7695fdc4257SSteve Yin } 7705fdc4257SSteve Yin 7715fdc4257SSteve Yin TextSegment segment = GetXInterface()->getTextAtIndex( offset, sal_Int16(lUnoBoundaryType)); 7725fdc4257SSteve Yin ::rtl::OUString ouStr = segment.SegmentText; 7735fdc4257SSteve Yin SysFreeString(*text); 7745fdc4257SSteve Yin *text = SysAllocString((OLECHAR*)ouStr.getStr()); 7755fdc4257SSteve Yin *startOffset = segment.SegmentStart; 7765fdc4257SSteve Yin *endOffset = segment.SegmentEnd; 7775fdc4257SSteve Yin 7785fdc4257SSteve Yin return S_OK; 7795fdc4257SSteve Yin 7805fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 7815fdc4257SSteve Yin } 7825fdc4257SSteve Yin 7835fdc4257SSteve Yin /** 7845fdc4257SSteve Yin * Remove selection. 7855fdc4257SSteve Yin * @param selectionIndex Special selection index 7865fdc4257SSteve Yin * @param success Variant to accept the memthod called result. 7875fdc4257SSteve Yin * @return Result. 7885fdc4257SSteve Yin */ 7895fdc4257SSteve Yin STDMETHODIMP CAccTextBase::removeSelection(long selectionIndex) 7905fdc4257SSteve Yin { 7915fdc4257SSteve Yin 7925fdc4257SSteve Yin CHECK_ENABLE_INF 7935fdc4257SSteve Yin 7945fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 7955fdc4257SSteve Yin 7965fdc4257SSteve Yin // #CHECK XInterface# 7975fdc4257SSteve Yin if(pUNOInterface == NULL) 7985fdc4257SSteve Yin { 7995fdc4257SSteve Yin return E_FAIL; 8005fdc4257SSteve Yin } 8015fdc4257SSteve Yin 8025fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 8035fdc4257SSteve Yin 8045fdc4257SSteve Yin Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY); 8055fdc4257SSteve Yin 8065fdc4257SSteve Yin if( pRExtension.is() ) 8075fdc4257SSteve Yin { 8085fdc4257SSteve Yin pRExtension->removeSelection(selectionIndex); 8095fdc4257SSteve Yin return S_OK; 8105fdc4257SSteve Yin } 8115fdc4257SSteve Yin else 8125fdc4257SSteve Yin { 8135fdc4257SSteve Yin GetXInterface()->setSelection(0, 0); 8145fdc4257SSteve Yin return S_OK; 8155fdc4257SSteve Yin } 8165fdc4257SSteve Yin 8175fdc4257SSteve Yin return E_FAIL; 8185fdc4257SSteve Yin 8195fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 8205fdc4257SSteve Yin } 8215fdc4257SSteve Yin 8225fdc4257SSteve Yin /** 8235fdc4257SSteve Yin * Set caret position. 8245fdc4257SSteve Yin * @param offset Special position. 8255fdc4257SSteve Yin * @param success Variant to accept the memthod called result. 8265fdc4257SSteve Yin * @return Result. 8275fdc4257SSteve Yin */ 8285fdc4257SSteve Yin STDMETHODIMP CAccTextBase::setCaretOffset(long offset) 8295fdc4257SSteve Yin { 8305fdc4257SSteve Yin 8315fdc4257SSteve Yin CHECK_ENABLE_INF 8325fdc4257SSteve Yin 8335fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8345fdc4257SSteve Yin 8355fdc4257SSteve Yin // #CHECK XInterface# 8365fdc4257SSteve Yin if(!pRXText.is()) 8375fdc4257SSteve Yin return E_FAIL; 8385fdc4257SSteve Yin 8395fdc4257SSteve Yin GetXInterface()->setCaretPosition( offset); 8405fdc4257SSteve Yin 8415fdc4257SSteve Yin return S_OK; 8425fdc4257SSteve Yin 8435fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 8445fdc4257SSteve Yin } 8455fdc4257SSteve Yin 8465fdc4257SSteve Yin /** 8475fdc4257SSteve Yin * Set special selection. 8485fdc4257SSteve Yin * @param selectionIndex Special selection index. 8495fdc4257SSteve Yin * @param startOffset start position. 8505fdc4257SSteve Yin * @param endOffset end position. 8515fdc4257SSteve Yin * @param success Variant to accept the memthod called result. 8525fdc4257SSteve Yin * @return Result. 8535fdc4257SSteve Yin */ 8545fdc4257SSteve Yin STDMETHODIMP CAccTextBase::setSelection(long, long startOffset, long endOffset) 8555fdc4257SSteve Yin { 8565fdc4257SSteve Yin 8575fdc4257SSteve Yin CHECK_ENABLE_INF 8585fdc4257SSteve Yin 8595fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8605fdc4257SSteve Yin 8615fdc4257SSteve Yin // #CHECK XInterface# 8625fdc4257SSteve Yin if(!pRXText.is()) 8635fdc4257SSteve Yin { 8645fdc4257SSteve Yin return E_FAIL; 8655fdc4257SSteve Yin } 8665fdc4257SSteve Yin 8675fdc4257SSteve Yin GetXInterface()->setSelection( startOffset, endOffset ); 8685fdc4257SSteve Yin 8695fdc4257SSteve Yin return S_OK; 8705fdc4257SSteve Yin 8715fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 8725fdc4257SSteve Yin } 8735fdc4257SSteve Yin 8745fdc4257SSteve Yin /** 8755fdc4257SSteve Yin * Get characters count. 8765fdc4257SSteve Yin * @param nCharacters Variant to accept the characters count. 8775fdc4257SSteve Yin * @return Result. 8785fdc4257SSteve Yin */ 8795fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_nCharacters(long * nCharacters) 8805fdc4257SSteve Yin { 8815fdc4257SSteve Yin 8825fdc4257SSteve Yin CHECK_ENABLE_INF 8835fdc4257SSteve Yin 8845fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8855fdc4257SSteve Yin 8865fdc4257SSteve Yin if (nCharacters == NULL) 8875fdc4257SSteve Yin return E_INVALIDARG; 8885fdc4257SSteve Yin // #CHECK XInterface# 8895fdc4257SSteve Yin if(!pRXText.is()) 8905fdc4257SSteve Yin { 8915fdc4257SSteve Yin *nCharacters = 0; 8925fdc4257SSteve Yin return S_OK; 8935fdc4257SSteve Yin } 8945fdc4257SSteve Yin 8955fdc4257SSteve Yin *nCharacters = GetXInterface()->getCharacterCount(); 8965fdc4257SSteve Yin 8975fdc4257SSteve Yin return S_OK; 8985fdc4257SSteve Yin 8995fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9005fdc4257SSteve Yin } 9015fdc4257SSteve Yin 9025fdc4257SSteve Yin // added by qiuhd, 2006/07/03, for direver 07/11 9035fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_newText( IA2TextSegment *) 9045fdc4257SSteve Yin { 9055fdc4257SSteve Yin return E_NOTIMPL; 9065fdc4257SSteve Yin } 9075fdc4257SSteve Yin 9085fdc4257SSteve Yin STDMETHODIMP CAccTextBase::get_oldText( IA2TextSegment *) 9095fdc4257SSteve Yin { 9105fdc4257SSteve Yin return E_NOTIMPL; 9115fdc4257SSteve Yin } 9125fdc4257SSteve Yin 9135fdc4257SSteve Yin /** 9145fdc4257SSteve Yin * Scroll to special sub-string . 9155fdc4257SSteve Yin * @param startIndex Start index of sub string. 9165fdc4257SSteve Yin * @param endIndex End index of sub string. 9175fdc4257SSteve Yin * @return Result. 9185fdc4257SSteve Yin */ 9195fdc4257SSteve Yin STDMETHODIMP CAccTextBase::scrollSubstringToPoint(long, long, IA2CoordinateType, long, long ) 9205fdc4257SSteve Yin { 9215fdc4257SSteve Yin 9225fdc4257SSteve Yin 9235fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 9245fdc4257SSteve Yin 9255fdc4257SSteve Yin return E_NOTIMPL; 9265fdc4257SSteve Yin 9275fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9285fdc4257SSteve Yin } 9295fdc4257SSteve Yin 9305fdc4257SSteve Yin STDMETHODIMP CAccTextBase::scrollSubstringTo(long, long, IA2ScrollType) 9315fdc4257SSteve Yin { 9325fdc4257SSteve Yin 9335fdc4257SSteve Yin 9345fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 9355fdc4257SSteve Yin 9365fdc4257SSteve Yin return E_NOTIMPL; 9375fdc4257SSteve Yin 9385fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9395fdc4257SSteve Yin } 9405fdc4257SSteve Yin 9415fdc4257SSteve Yin /** 9425fdc4257SSteve Yin * Put UNO interface. 9435fdc4257SSteve Yin * @param pXInterface UNO interface. 9445fdc4257SSteve Yin * @return Result. 9455fdc4257SSteve Yin */ 9465fdc4257SSteve Yin STDMETHODIMP CAccTextBase::put_XInterface(long pXInterface) 9475fdc4257SSteve Yin { 9485fdc4257SSteve Yin 9495fdc4257SSteve Yin CHECK_ENABLE_INF 9505fdc4257SSteve Yin 9515fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 9525fdc4257SSteve Yin 9535fdc4257SSteve Yin CUNOXWrapper::put_XInterface(pXInterface); 9545fdc4257SSteve Yin //special query. 9555fdc4257SSteve Yin if(pUNOInterface == NULL) 9565fdc4257SSteve Yin return E_FAIL; 9575fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 9585fdc4257SSteve Yin if( !pRContext.is() ) 9595fdc4257SSteve Yin { 9605fdc4257SSteve Yin return E_FAIL; 9615fdc4257SSteve Yin } 9625fdc4257SSteve Yin Reference<XAccessibleText> pRXI(pRContext,UNO_QUERY); 9635fdc4257SSteve Yin if( !pRXI.is() ) 9645fdc4257SSteve Yin pRXText = NULL; 9655fdc4257SSteve Yin else 9665fdc4257SSteve Yin pRXText = pRXI; 9675fdc4257SSteve Yin return S_OK; 9685fdc4257SSteve Yin 9695fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9705fdc4257SSteve Yin } 9715fdc4257SSteve Yin 9725fdc4257SSteve Yin OUString ReplaceOneChar(OUString oldOUString, OUString replacedChar, OUString replaceStr) 9735fdc4257SSteve Yin { 9745fdc4257SSteve Yin int iReplace = -1; 9755fdc4257SSteve Yin iReplace = oldOUString.lastIndexOf(replacedChar); 9765fdc4257SSteve Yin if (iReplace > -1) 9775fdc4257SSteve Yin { 9785fdc4257SSteve Yin for(;iReplace>-1;) 9795fdc4257SSteve Yin { 9805fdc4257SSteve Yin oldOUString = oldOUString.replaceAt(iReplace,1, replaceStr); 9815fdc4257SSteve Yin iReplace=oldOUString.lastIndexOf(replacedChar,iReplace); 9825fdc4257SSteve Yin } 9835fdc4257SSteve Yin } 9845fdc4257SSteve Yin return oldOUString; 9855fdc4257SSteve Yin 9865fdc4257SSteve Yin } 9875fdc4257SSteve Yin OUString ReplaceFourChar(OUString oldOUString) 9885fdc4257SSteve Yin { 9895fdc4257SSteve Yin oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii("\\"),OUString::createFromAscii("\\\\")); 9905fdc4257SSteve Yin oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii(";"),OUString::createFromAscii("\\;")); 9915fdc4257SSteve Yin oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii("="),OUString::createFromAscii("\\=")); 9925fdc4257SSteve Yin oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii(","),OUString::createFromAscii("\\,")); 9935fdc4257SSteve Yin oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii(":"),OUString::createFromAscii("\\:")); 9945fdc4257SSteve Yin return oldOUString; 9955fdc4257SSteve Yin } 996