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 * AccEditableText.cpp : Implementation of CUAccCOMApp and DLL registration. 245fdc4257SSteve Yin */ 255fdc4257SSteve Yin #include "stdafx.h" 265fdc4257SSteve Yin #include "UAccCOM2.h" 275fdc4257SSteve Yin #include "AccEditableText.h" 285fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessible.hpp> 295fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleContext.hpp> 305fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleText.hpp> 315fdc4257SSteve Yin #include <com/sun/star/awt/FontSlant.hpp> 325fdc4257SSteve Yin #include <com/sun/star/beans/PropertyValue.hpp> 335fdc4257SSteve Yin #include <com/sun/star/style/LineSpacing.hpp> 345fdc4257SSteve Yin #include <com/sun/star/style/TabStop.hpp> 355fdc4257SSteve Yin #include <vector> 365fdc4257SSteve Yin 375fdc4257SSteve Yin using namespace com::sun::star::accessibility; 385fdc4257SSteve Yin using namespace com::sun::star::uno; 395fdc4257SSteve Yin using namespace com::sun::star::awt; 405fdc4257SSteve Yin using namespace com::sun::star::beans; 415fdc4257SSteve Yin using namespace std; 425fdc4257SSteve Yin 435fdc4257SSteve Yin /** 445fdc4257SSteve Yin * Copys a range of text to the clipboard. 455fdc4257SSteve Yin * 465fdc4257SSteve Yin * @param startOffset the start offset of copying. 475fdc4257SSteve Yin * @param endOffset the end offset of copying. 485fdc4257SSteve Yin * @param success the boolean result to be returned. 495fdc4257SSteve Yin */ 505fdc4257SSteve Yin STDMETHODIMP CAccEditableText::copyText(long startOffset, long endOffset) 515fdc4257SSteve Yin { 525fdc4257SSteve Yin 535fdc4257SSteve Yin CHECK_ENABLE_INF 545fdc4257SSteve Yin 555fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 565fdc4257SSteve Yin 575fdc4257SSteve Yin // #CHECK XInterface# 585fdc4257SSteve Yin if(!pRXEdtTxt.is()) 595fdc4257SSteve Yin { 605fdc4257SSteve Yin return E_FAIL; 615fdc4257SSteve Yin } 625fdc4257SSteve Yin 635fdc4257SSteve Yin if ( GetXInterface()->copyText( startOffset, endOffset ) ) 645fdc4257SSteve Yin return S_OK; 655fdc4257SSteve Yin 665fdc4257SSteve Yin return E_FAIL; 675fdc4257SSteve Yin 685fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 695fdc4257SSteve Yin } 705fdc4257SSteve Yin 715fdc4257SSteve Yin /** 725fdc4257SSteve Yin * Deletes a range of text. 735fdc4257SSteve Yin * 745fdc4257SSteve Yin * @param startOffset the start offset of deleting. 755fdc4257SSteve Yin * @param endOffset the end offset of deleting. 765fdc4257SSteve Yin * @param success the boolean result to be returned. 775fdc4257SSteve Yin */ 785fdc4257SSteve Yin STDMETHODIMP CAccEditableText::deleteText(long startOffset, long endOffset) 795fdc4257SSteve Yin { 805fdc4257SSteve Yin 815fdc4257SSteve Yin CHECK_ENABLE_INF 825fdc4257SSteve Yin 835fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 845fdc4257SSteve Yin 855fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 865fdc4257SSteve Yin return E_FAIL; 875fdc4257SSteve Yin 885fdc4257SSteve Yin if( GetXInterface()->deleteText( startOffset, endOffset ) ) 895fdc4257SSteve Yin return S_OK; 905fdc4257SSteve Yin 915fdc4257SSteve Yin return E_FAIL; 925fdc4257SSteve Yin 935fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 945fdc4257SSteve Yin } 955fdc4257SSteve Yin 965fdc4257SSteve Yin /** 975fdc4257SSteve Yin * Inserts text at a specified offset. 985fdc4257SSteve Yin * 995fdc4257SSteve Yin * @param offset the offset of inserting. 1005fdc4257SSteve Yin * @param text the text to be inserted. 1015fdc4257SSteve Yin * @param success the boolean result to be returned. 1025fdc4257SSteve Yin */ 1035fdc4257SSteve Yin STDMETHODIMP CAccEditableText::insertText(long offset, BSTR * text) 1045fdc4257SSteve Yin { 1055fdc4257SSteve Yin 1065fdc4257SSteve Yin CHECK_ENABLE_INF 1075fdc4257SSteve Yin 1085fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1095fdc4257SSteve Yin 1105fdc4257SSteve Yin if (text == NULL) 1115fdc4257SSteve Yin return E_INVALIDARG; 1125fdc4257SSteve Yin 1135fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 1145fdc4257SSteve Yin return E_FAIL; 1155fdc4257SSteve Yin 1165fdc4257SSteve Yin ::rtl::OUString ouStr(*text); 1175fdc4257SSteve Yin 1185fdc4257SSteve Yin if( GetXInterface()->insertText( ouStr, offset ) ) 1195fdc4257SSteve Yin return S_OK; 1205fdc4257SSteve Yin 1215fdc4257SSteve Yin return E_FAIL; 1225fdc4257SSteve Yin 1235fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1245fdc4257SSteve Yin } 1255fdc4257SSteve Yin 1265fdc4257SSteve Yin /** 1275fdc4257SSteve Yin * Cuts a range of text to the clipboard. 1285fdc4257SSteve Yin * 1295fdc4257SSteve Yin * @param startOffset the start offset of cuting. 1305fdc4257SSteve Yin * @param endOffset the end offset of cuting. 1315fdc4257SSteve Yin * @param success the boolean result to be returned. 1325fdc4257SSteve Yin */ 1335fdc4257SSteve Yin STDMETHODIMP CAccEditableText::cutText(long startOffset, long endOffset) 1345fdc4257SSteve Yin { 1355fdc4257SSteve Yin 1365fdc4257SSteve Yin CHECK_ENABLE_INF 1375fdc4257SSteve Yin 1385fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1395fdc4257SSteve Yin 1405fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 1415fdc4257SSteve Yin return E_FAIL; 1425fdc4257SSteve Yin 1435fdc4257SSteve Yin if( GetXInterface()->cutText( startOffset, endOffset ) ) 1445fdc4257SSteve Yin return S_OK; 1455fdc4257SSteve Yin 1465fdc4257SSteve Yin return E_FAIL; 1475fdc4257SSteve Yin 1485fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1495fdc4257SSteve Yin } 1505fdc4257SSteve Yin 1515fdc4257SSteve Yin /** 1525fdc4257SSteve Yin * Pastes text from clipboard at specified offset. 1535fdc4257SSteve Yin * 1545fdc4257SSteve Yin * @param offset the offset of pasting. 1555fdc4257SSteve Yin * @param success the boolean result to be returned. 1565fdc4257SSteve Yin */ 1575fdc4257SSteve Yin STDMETHODIMP CAccEditableText::pasteText(long offset) 1585fdc4257SSteve Yin { 1595fdc4257SSteve Yin 1605fdc4257SSteve Yin CHECK_ENABLE_INF 1615fdc4257SSteve Yin 1625fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1635fdc4257SSteve Yin 1645fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 1655fdc4257SSteve Yin return E_FAIL; 1665fdc4257SSteve Yin 1675fdc4257SSteve Yin if( GetXInterface()->pasteText( offset ) ) 1685fdc4257SSteve Yin return S_OK; 1695fdc4257SSteve Yin 1705fdc4257SSteve Yin return E_FAIL; 1715fdc4257SSteve Yin 1725fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1735fdc4257SSteve Yin } 1745fdc4257SSteve Yin 1755fdc4257SSteve Yin /** 1765fdc4257SSteve Yin * Replaces range of text with new text. 1775fdc4257SSteve Yin * 1785fdc4257SSteve Yin * @param startOffset the start offset of replacing. 1795fdc4257SSteve Yin * @param endOffset the end offset of replacing. 1805fdc4257SSteve Yin * @param text the replacing text. 1815fdc4257SSteve Yin * @param success the boolean result to be returned. 1825fdc4257SSteve Yin */ 1835fdc4257SSteve Yin STDMETHODIMP CAccEditableText::replaceText(long startOffset, long endOffset, BSTR * text) 1845fdc4257SSteve Yin { 1855fdc4257SSteve Yin 1865fdc4257SSteve Yin CHECK_ENABLE_INF 1875fdc4257SSteve Yin 1885fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1895fdc4257SSteve Yin 1905fdc4257SSteve Yin // #CHECK# 1915fdc4257SSteve Yin if (text == NULL) 1925fdc4257SSteve Yin return E_INVALIDARG; 1935fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 1945fdc4257SSteve Yin return E_FAIL; 1955fdc4257SSteve Yin 1965fdc4257SSteve Yin ::rtl::OUString ouStr(*text); 1975fdc4257SSteve Yin 1985fdc4257SSteve Yin if( GetXInterface()->replaceText( startOffset,endOffset, ouStr) ) 1995fdc4257SSteve Yin return S_OK; 2005fdc4257SSteve Yin return E_FAIL; 2015fdc4257SSteve Yin 2025fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2035fdc4257SSteve Yin } 2045fdc4257SSteve Yin 2055fdc4257SSteve Yin /** 2065fdc4257SSteve Yin * Sets attributes of range of text. 2075fdc4257SSteve Yin * 2085fdc4257SSteve Yin * @param startOffset the start offset. 2095fdc4257SSteve Yin * @param endOffset the end offset. 2105fdc4257SSteve Yin * @param attributes the attribute text. 2115fdc4257SSteve Yin * @param success the boolean result to be returned. 2125fdc4257SSteve Yin */ 2135fdc4257SSteve Yin STDMETHODIMP CAccEditableText::setAttributes(long startOffset, long endOffset, BSTR * attributes) 2145fdc4257SSteve Yin { 2155fdc4257SSteve Yin 2165fdc4257SSteve Yin CHECK_ENABLE_INF 2175fdc4257SSteve Yin 2185fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2195fdc4257SSteve Yin 2205fdc4257SSteve Yin // #CHECK# 2215fdc4257SSteve Yin if (attributes == NULL) 2225fdc4257SSteve Yin return E_INVALIDARG; 2235fdc4257SSteve Yin if( !pRXEdtTxt.is() ) 2245fdc4257SSteve Yin return E_FAIL; 2255fdc4257SSteve Yin 2265fdc4257SSteve Yin ::rtl::OUString ouStr(*attributes); 2275fdc4257SSteve Yin 2285fdc4257SSteve Yin sal_Int32 nIndex = 0; 2295fdc4257SSteve Yin sal_Unicode cTok = ';'; 2305fdc4257SSteve Yin vector< ::rtl::OUString > vecAttr; 2315fdc4257SSteve Yin do 2325fdc4257SSteve Yin { 2335fdc4257SSteve Yin ::rtl::OUString ouToken = ouStr.getToken(0, cTok, nIndex); 2345fdc4257SSteve Yin vecAttr.push_back(ouToken); 2355fdc4257SSteve Yin } 2365fdc4257SSteve Yin while(nIndex >= 0); 2375fdc4257SSteve Yin 2385fdc4257SSteve Yin Sequence< PropertyValue > beanSeq(vecAttr.size()); 2395fdc4257SSteve Yin for(unsigned int i = 0; i < vecAttr.size(); i ++) 2405fdc4257SSteve Yin { 2415fdc4257SSteve Yin ::rtl::OUString attr = vecAttr[i]; 2425fdc4257SSteve Yin sal_Int32 nPos = attr.indexOf(':'); 2435fdc4257SSteve Yin if(nPos > -1) 2445fdc4257SSteve Yin { 2455fdc4257SSteve Yin ::rtl::OUString attrName = attr.copy(0, nPos); 2465fdc4257SSteve Yin ::rtl::OUString attrValue = attr.copy(nPos + 1, attr.getLength() - nPos - 1); 2475fdc4257SSteve Yin beanSeq[i].Name = attrName; 2485fdc4257SSteve Yin get_AnyFromOLECHAR(attrName, attrValue, beanSeq[i].Value); 2495fdc4257SSteve Yin } 2505fdc4257SSteve Yin } 2515fdc4257SSteve Yin 2525fdc4257SSteve Yin if( GetXInterface()->setAttributes( startOffset,endOffset, beanSeq) ) 2535fdc4257SSteve Yin return S_OK; 2545fdc4257SSteve Yin 2555fdc4257SSteve Yin return E_FAIL; 2565fdc4257SSteve Yin 2575fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2585fdc4257SSteve Yin } 2595fdc4257SSteve Yin 2605fdc4257SSteve Yin /** 2615fdc4257SSteve Yin * Convert attributes string to Any type. 2625fdc4257SSteve Yin * Reference to infra\accessibility\bridge\org\openoffice\java\accessibility\AccessibleTextImpl.java 2635fdc4257SSteve Yin * 2645fdc4257SSteve Yin * @param ouName the string of attribute name. 2655fdc4257SSteve Yin * @param ouValue the string of attribute value. 2665fdc4257SSteve Yin * @param rAny the Any object to be returned. 2675fdc4257SSteve Yin */ 2685fdc4257SSteve Yin void CAccEditableText::get_AnyFromOLECHAR(const ::rtl::OUString &ouName, const ::rtl::OUString &ouValue, Any &rAny) 2695fdc4257SSteve Yin { 2705fdc4257SSteve Yin if(ouName.compareTo(L"CharBackColor") == 0 || 2715fdc4257SSteve Yin ouName.compareTo(L"CharColor") == 0 || 2725fdc4257SSteve Yin ouName.compareTo(L"ParaAdjust") == 0 || 2735fdc4257SSteve Yin ouName.compareTo(L"ParaFirstLineIndent") == 0 || 2745fdc4257SSteve Yin ouName.compareTo(L"ParaLeftMargin") == 0 || 2755fdc4257SSteve Yin ouName.compareTo(L"ParaRightMargin") == 0 || 2765fdc4257SSteve Yin ouName.compareTo(L"ParaTopMargin") == 0 || 2775fdc4257SSteve Yin ouName.compareTo(L"ParaBottomMargin") == 0 || 2785fdc4257SSteve Yin ouName.compareTo(L"CharFontPitch") == 0) 2795fdc4257SSteve Yin { 2805fdc4257SSteve Yin // Convert to int. 2815fdc4257SSteve Yin // NOTE: CharFontPitch is not implemented in java file. 2825fdc4257SSteve Yin sal_Int32 nValue = ouValue.toInt32(); 2835fdc4257SSteve Yin rAny.setValue(&nValue, getCppuType((sal_Int32 *)0)); 2845fdc4257SSteve Yin } 2855fdc4257SSteve Yin else if(ouName.compareTo(L"CharShadowed") == 0 || 2865fdc4257SSteve Yin ouName.compareTo(L"CharContoured") == 0) 2875fdc4257SSteve Yin { 2885fdc4257SSteve Yin // Convert to boolean. 2895fdc4257SSteve Yin boolean nValue = (boolean)ouValue.toBoolean(); 2905fdc4257SSteve Yin rAny.setValue(&nValue, getCppuType((sal_Bool *)sal_False)); 2915fdc4257SSteve Yin } 2925fdc4257SSteve Yin else if(ouName.compareTo(L"CharEscapement") == 0 || 2935fdc4257SSteve Yin ouName.compareTo(L"CharStrikeout") == 0 || 2945fdc4257SSteve Yin ouName.compareTo(L"CharUnderline") == 0 || 2955fdc4257SSteve Yin ouName.compareTo(L"CharFontPitch") == 0) 2965fdc4257SSteve Yin { 2975fdc4257SSteve Yin // Convert to short. 2985fdc4257SSteve Yin short nValue = (short)ouValue.toInt32(); 2995fdc4257SSteve Yin rAny.setValue(&nValue, getCppuType((short *)0)); 3005fdc4257SSteve Yin } 3015fdc4257SSteve Yin else if(ouName.compareTo(L"CharHeight") == 0 || 3025fdc4257SSteve Yin ouName.compareTo(L"CharWeight") == 0) 3035fdc4257SSteve Yin { 3045fdc4257SSteve Yin // Convert to float. 3055fdc4257SSteve Yin float fValue = ouValue.toFloat(); 3065fdc4257SSteve Yin rAny.setValue(&fValue, getCppuType((float *)0)); 3075fdc4257SSteve Yin } 3085fdc4257SSteve Yin else if(ouName.compareTo(L"CharFontName") == 0) 3095fdc4257SSteve Yin { 3105fdc4257SSteve Yin // Convert to string. 3115fdc4257SSteve Yin rAny.setValue(&ouValue, getCppuType((::rtl::OUString *)0)); 3125fdc4257SSteve Yin } 3135fdc4257SSteve Yin else if(ouName.compareTo(L"CharPosture") == 0) 3145fdc4257SSteve Yin { 3155fdc4257SSteve Yin // Convert to FontSlant. 3165fdc4257SSteve Yin ::com::sun::star::awt::FontSlant fontSlant = (::com::sun::star::awt::FontSlant)ouValue.toInt32(); 3175fdc4257SSteve Yin rAny.setValue(&fontSlant, getCppuType((::com::sun::star::awt::FontSlant*)0)); 3185fdc4257SSteve Yin } 3195fdc4257SSteve Yin else if(ouName.compareTo(L"ParaTabStops") == 0) 3205fdc4257SSteve Yin { 3215fdc4257SSteve Yin // 3225fdc4257SSteve Yin // Convert to the Sequence with TabStop element. 3235fdc4257SSteve Yin vector< ::com::sun::star::style::TabStop > vecTabStop; 3245fdc4257SSteve Yin ::com::sun::star::style::TabStop tabStop; 3255fdc4257SSteve Yin ::rtl::OUString ouSubValue; 3265fdc4257SSteve Yin sal_Int32 nIndex = 0; 3275fdc4257SSteve Yin sal_Int32 pos = 0, posComma = 0; 3285fdc4257SSteve Yin 3295fdc4257SSteve Yin do 3305fdc4257SSteve Yin { 3315fdc4257SSteve Yin // Position. 3325fdc4257SSteve Yin pos = ouValue.indexOf(L"Position=", pos); 3335fdc4257SSteve Yin if(pos != -1) 3345fdc4257SSteve Yin { 3355fdc4257SSteve Yin posComma = ouValue.indexOf(',', pos + 9); // 9 = length of "Position=". 3365fdc4257SSteve Yin if(posComma != -1) 3375fdc4257SSteve Yin { 3385fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 9, posComma - pos - 9); 3395fdc4257SSteve Yin tabStop.Position = ouSubValue.toInt32(); 3405fdc4257SSteve Yin pos = posComma + 1; 3415fdc4257SSteve Yin 3425fdc4257SSteve Yin // TabAlign. 3435fdc4257SSteve Yin pos = ouValue.indexOf(L"TabAlign=", pos); 3445fdc4257SSteve Yin if(pos != -1) 3455fdc4257SSteve Yin { 3465fdc4257SSteve Yin posComma = ouValue.indexOf(',', pos + 9); // 9 = length of "TabAlign=". 3475fdc4257SSteve Yin if(posComma != -1) 3485fdc4257SSteve Yin { 3495fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 9, posComma - pos - 9); 3505fdc4257SSteve Yin tabStop.Alignment = (::com::sun::star::style::TabAlign)ouSubValue.toInt32(); 3515fdc4257SSteve Yin pos = posComma + 1; 3525fdc4257SSteve Yin 3535fdc4257SSteve Yin // DecimalChar. 3545fdc4257SSteve Yin pos = ouValue.indexOf(L"DecimalChar=", pos); 3555fdc4257SSteve Yin if(pos != -1) 3565fdc4257SSteve Yin { 3575fdc4257SSteve Yin posComma = ouValue.indexOf(',', pos + 11); // 11 = length of "TabAlign=". 3585fdc4257SSteve Yin if(posComma != -1) 3595fdc4257SSteve Yin { 3605fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 11, posComma - pos - 11); 3615fdc4257SSteve Yin tabStop.DecimalChar = (sal_Unicode)ouSubValue.toChar(); 3625fdc4257SSteve Yin pos = posComma + 1; 3635fdc4257SSteve Yin 3645fdc4257SSteve Yin // FillChar. 3655fdc4257SSteve Yin pos = ouValue.indexOf(L"FillChar=", pos); 3665fdc4257SSteve Yin if(pos != -1) 3675fdc4257SSteve Yin { 3685fdc4257SSteve Yin posComma = ouValue.indexOf(',', pos + 9); // 9 = length of "TabAlign=". 3695fdc4257SSteve Yin if(posComma != -1) 3705fdc4257SSteve Yin { 3715fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 9, posComma - pos - 9); 3725fdc4257SSteve Yin tabStop.DecimalChar = (sal_Unicode)ouSubValue.toChar(); 3735fdc4257SSteve Yin pos = posComma + 1; 3745fdc4257SSteve Yin 3755fdc4257SSteve Yin // Complete TabStop element. 3765fdc4257SSteve Yin vecTabStop.push_back(tabStop); 3775fdc4257SSteve Yin } 3785fdc4257SSteve Yin else 3795fdc4257SSteve Yin break; // No match comma. 3805fdc4257SSteve Yin } 3815fdc4257SSteve Yin else 3825fdc4257SSteve Yin break; // No match FillChar. 3835fdc4257SSteve Yin } 3845fdc4257SSteve Yin else 3855fdc4257SSteve Yin break; // No match comma. 3865fdc4257SSteve Yin } 3875fdc4257SSteve Yin else 3885fdc4257SSteve Yin break; // No match DecimalChar. 3895fdc4257SSteve Yin } 3905fdc4257SSteve Yin else 3915fdc4257SSteve Yin break; // No match comma. 3925fdc4257SSteve Yin } 3935fdc4257SSteve Yin else 3945fdc4257SSteve Yin break; // No match TabAlign. 3955fdc4257SSteve Yin } 3965fdc4257SSteve Yin else 3975fdc4257SSteve Yin break; // No match comma. 3985fdc4257SSteve Yin } 3995fdc4257SSteve Yin else 4005fdc4257SSteve Yin break; // No match Position. 4015fdc4257SSteve Yin } 4025fdc4257SSteve Yin while(pos < ouValue.getLength()); 4035fdc4257SSteve Yin 4045fdc4257SSteve Yin // 4055fdc4257SSteve Yin // Dump into Sequence. 4065fdc4257SSteve Yin int iSeqLen = (vecTabStop.size() == 0) ? 1 : vecTabStop.size(); 4075fdc4257SSteve Yin Sequence< ::com::sun::star::style::TabStop > seqTabStop(iSeqLen); 4085fdc4257SSteve Yin 4095fdc4257SSteve Yin if(vecTabStop.size() != 0) 4105fdc4257SSteve Yin { 4115fdc4257SSteve Yin // Dump every element. 4125fdc4257SSteve Yin for(int i = 0; i < iSeqLen; i ++) 4135fdc4257SSteve Yin { 4145fdc4257SSteve Yin seqTabStop[i] = vecTabStop[i]; 4155fdc4257SSteve Yin } 4165fdc4257SSteve Yin } 4175fdc4257SSteve Yin else 4185fdc4257SSteve Yin { 4195fdc4257SSteve Yin // Create default value. 4205fdc4257SSteve Yin seqTabStop[0].Position = 0; 4215fdc4257SSteve Yin seqTabStop[0].Alignment = ::com::sun::star::style::TabAlign_DEFAULT; 4225fdc4257SSteve Yin seqTabStop[0].DecimalChar = '.'; 4235fdc4257SSteve Yin seqTabStop[0].FillChar = ' '; 4245fdc4257SSteve Yin } 4255fdc4257SSteve Yin 4265fdc4257SSteve Yin // Assign to Any object. 4275fdc4257SSteve Yin rAny.setValue(&seqTabStop, getCppuType((Sequence< ::com::sun::star::style::TabStop >*)0)); 4285fdc4257SSteve Yin } 4295fdc4257SSteve Yin else if(ouName.compareTo(L"ParaLineSpacing") == 0) 4305fdc4257SSteve Yin { 4315fdc4257SSteve Yin // Parse value string. 4325fdc4257SSteve Yin ::com::sun::star::style::LineSpacing lineSpacing; 4335fdc4257SSteve Yin ::rtl::OUString ouSubValue; 4345fdc4257SSteve Yin sal_Int32 pos = 0, posComma = 0; 4355fdc4257SSteve Yin 4365fdc4257SSteve Yin pos = ouValue.indexOf(L"Mode=", pos); 4375fdc4257SSteve Yin if(pos != -1) 4385fdc4257SSteve Yin { 4395fdc4257SSteve Yin posComma = ouValue.indexOf(',', pos + 5); // 5 = length of "Mode=". 4405fdc4257SSteve Yin if(posComma != -1) 4415fdc4257SSteve Yin { 4425fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 5, posComma - pos - 5); 4435fdc4257SSteve Yin lineSpacing.Mode = (sal_Int16)ouSubValue.toInt32(); 4445fdc4257SSteve Yin pos = posComma + 1; 4455fdc4257SSteve Yin 4465fdc4257SSteve Yin pos = ouValue.indexOf(L"Height=", pos); 4475fdc4257SSteve Yin if(pos != -1) 4485fdc4257SSteve Yin { 4495fdc4257SSteve Yin ouSubValue = ouValue.copy(pos + 7, ouValue.getLength() - pos - 7); 4505fdc4257SSteve Yin lineSpacing.Height = (sal_Int16)ouSubValue.toInt32(); 4515fdc4257SSteve Yin } 4525fdc4257SSteve Yin else 4535fdc4257SSteve Yin { 4545fdc4257SSteve Yin lineSpacing.Height = (sal_Int16)100; // Default height. 4555fdc4257SSteve Yin } 4565fdc4257SSteve Yin } 4575fdc4257SSteve Yin else 4585fdc4257SSteve Yin { 4595fdc4257SSteve Yin lineSpacing.Height = (sal_Int16)100; // Default height. 4605fdc4257SSteve Yin } 4615fdc4257SSteve Yin } 4625fdc4257SSteve Yin else 4635fdc4257SSteve Yin { 4645fdc4257SSteve Yin // Default Mode and Height. 4655fdc4257SSteve Yin lineSpacing.Mode = (sal_Int16)0; 4665fdc4257SSteve Yin lineSpacing.Height = (sal_Int16)100; // Default height. 4675fdc4257SSteve Yin } 4685fdc4257SSteve Yin 4695fdc4257SSteve Yin // Convert to Any object. 4705fdc4257SSteve Yin rAny.setValue(&lineSpacing, getCppuType((::com::sun::star::style::LineSpacing* )0)); 4715fdc4257SSteve Yin } 4725fdc4257SSteve Yin else 4735fdc4257SSteve Yin { 4745fdc4257SSteve Yin // Do nothing. 4755fdc4257SSteve Yin sal_Int32 nDefault = 0; 4765fdc4257SSteve Yin rAny.setValue(&nDefault, getCppuType((sal_Int32 *)0)); 4775fdc4257SSteve Yin } 4785fdc4257SSteve Yin } 4795fdc4257SSteve Yin 4805fdc4257SSteve Yin /** 4815fdc4257SSteve Yin * Overide of IUNOXWrapper. 4825fdc4257SSteve Yin * 4835fdc4257SSteve Yin * @param pXInterface the pointer of UNO interface. 4845fdc4257SSteve Yin */ 4855fdc4257SSteve Yin STDMETHODIMP CAccEditableText::put_XInterface(long pXInterface) 4865fdc4257SSteve Yin { 4875fdc4257SSteve Yin 4885fdc4257SSteve Yin 4895fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4905fdc4257SSteve Yin 4915fdc4257SSteve Yin CUNOXWrapper::put_XInterface(pXInterface); 4925fdc4257SSteve Yin //special query. 4935fdc4257SSteve Yin if(pUNOInterface == NULL) 4945fdc4257SSteve Yin return E_FAIL; 4955fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 4965fdc4257SSteve Yin if( !pRContext.is() ) 4975fdc4257SSteve Yin { 4985fdc4257SSteve Yin return E_FAIL; 4995fdc4257SSteve Yin } 5005fdc4257SSteve Yin Reference<XAccessibleEditableText> pRXI(pRContext,UNO_QUERY); 5015fdc4257SSteve Yin if( !pRXI.is() ) 5025fdc4257SSteve Yin pRXEdtTxt = NULL; 5035fdc4257SSteve Yin else 5045fdc4257SSteve Yin pRXEdtTxt = pRXI.get(); 5055fdc4257SSteve Yin return S_OK; 5065fdc4257SSteve Yin 5075fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 5085fdc4257SSteve Yin } 509