1*cde9e8dcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cde9e8dcSAndrew Rist * distributed with this work for additional information 6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance 9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an 15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the 17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations 18*cde9e8dcSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*cde9e8dcSAndrew Rist *************************************************************/ 21*cde9e8dcSAndrew Rist 22*cde9e8dcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_chart2.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "XMLRangeHelper.hxx" 28cdf0e10cSrcweir #include <unotools/charclass.hxx> 29cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <algorithm> 32cdf0e10cSrcweir #include <functional> 33cdf0e10cSrcweir 34cdf0e10cSrcweir using ::rtl::OUString; 35cdf0e10cSrcweir using ::rtl::OUStringBuffer; 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ================================================================================ 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace 40cdf0e10cSrcweir { 41cdf0e10cSrcweir /** unary function that escapes backslashes and single quotes in a sal_Unicode 42cdf0e10cSrcweir array (which you can get from an OUString with getStr()) and puts the result 43cdf0e10cSrcweir into the OUStringBuffer given in the CTOR 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir class lcl_Escape : public ::std::unary_function< sal_Unicode, void > 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir lcl_Escape( ::rtl::OUStringBuffer & aResultBuffer ) : m_aResultBuffer( aResultBuffer ) {} 49cdf0e10cSrcweir void operator() ( sal_Unicode aChar ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir static const sal_Unicode m_aQuote( '\'' ); 52cdf0e10cSrcweir static const sal_Unicode m_aBackslash( '\\' ); 53cdf0e10cSrcweir 54cdf0e10cSrcweir if( aChar == m_aQuote || 55cdf0e10cSrcweir aChar == m_aBackslash ) 56cdf0e10cSrcweir m_aResultBuffer.append( m_aBackslash ); 57cdf0e10cSrcweir m_aResultBuffer.append( aChar ); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir private: 61cdf0e10cSrcweir ::rtl::OUStringBuffer & m_aResultBuffer; 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ---------------------------------------- 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** unary function that removes backslash escapes in a sal_Unicode array (which 67cdf0e10cSrcweir you can get from an OUString with getStr()) and puts the result into the 68cdf0e10cSrcweir OUStringBuffer given in the CTOR 69cdf0e10cSrcweir */ 70cdf0e10cSrcweir class lcl_UnEscape : public ::std::unary_function< sal_Unicode, void > 71cdf0e10cSrcweir { 72cdf0e10cSrcweir public: 73cdf0e10cSrcweir lcl_UnEscape( ::rtl::OUStringBuffer & aResultBuffer ) : m_aResultBuffer( aResultBuffer ) {} 74cdf0e10cSrcweir void operator() ( sal_Unicode aChar ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir static const sal_Unicode m_aBackslash( '\\' ); 77cdf0e10cSrcweir 78cdf0e10cSrcweir if( aChar != m_aBackslash ) 79cdf0e10cSrcweir m_aResultBuffer.append( aChar ); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir private: 83cdf0e10cSrcweir ::rtl::OUStringBuffer & m_aResultBuffer; 84cdf0e10cSrcweir }; 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ---------------------------------------- 87cdf0e10cSrcweir 88cdf0e10cSrcweir OUStringBuffer lcl_getXMLStringForCell( const ::chart::XMLRangeHelper::Cell & rCell ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir ::rtl::OUStringBuffer aBuffer; 91cdf0e10cSrcweir if( rCell.empty()) 92cdf0e10cSrcweir return aBuffer; 93cdf0e10cSrcweir 94cdf0e10cSrcweir sal_Int32 nCol = rCell.nColumn; 95cdf0e10cSrcweir aBuffer.append( (sal_Unicode)'.' ); 96cdf0e10cSrcweir if( ! rCell.bRelativeColumn ) 97cdf0e10cSrcweir aBuffer.append( (sal_Unicode)'$' ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir // get A, B, C, ..., AA, AB, ... representation of column number 100cdf0e10cSrcweir if( nCol < 26 ) 101cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + nCol) ); 102cdf0e10cSrcweir else if( nCol < 702 ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + nCol / 26 - 1 )); 105cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + nCol % 26) ); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir else // works for nCol <= 18,278 108cdf0e10cSrcweir { 109cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + nCol / 702 - 1 )); 110cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + (nCol % 702) / 26 )); 111cdf0e10cSrcweir aBuffer.append( (sal_Unicode)('A' + nCol % 26) ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir // write row number as number 115cdf0e10cSrcweir if( ! rCell.bRelativeRow ) 116cdf0e10cSrcweir aBuffer.append( (sal_Unicode)'$' ); 117cdf0e10cSrcweir aBuffer.append( rCell.nRow + (sal_Int32)1 ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir return aBuffer; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir void lcl_getSingleCellAddressFromXMLString( 123cdf0e10cSrcweir const ::rtl::OUString& rXMLString, 124cdf0e10cSrcweir sal_Int32 nStartPos, sal_Int32 nEndPos, 125cdf0e10cSrcweir ::chart::XMLRangeHelper::Cell & rOutCell ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir // expect "\$?[a-zA-Z]+\$?[1-9][0-9]*" 128cdf0e10cSrcweir static const sal_Unicode aDollar( '$' ); 129cdf0e10cSrcweir static const sal_Unicode aLetterA( 'A' ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir ::rtl::OUString aCellStr = rXMLString.copy( nStartPos, nEndPos - nStartPos + 1 ).toAsciiUpperCase(); 132cdf0e10cSrcweir const sal_Unicode* pStrArray = aCellStr.getStr(); 133cdf0e10cSrcweir sal_Int32 nLength = aCellStr.getLength(); 134cdf0e10cSrcweir sal_Int32 i = nLength - 1, nColumn = 0; 135cdf0e10cSrcweir 136cdf0e10cSrcweir // parse number for row 137cdf0e10cSrcweir while( CharClass::isAsciiDigit( pStrArray[ i ] ) && i >= 0 ) 138cdf0e10cSrcweir i--; 139cdf0e10cSrcweir rOutCell.nRow = (aCellStr.copy( i + 1 )).toInt32() - 1; 140cdf0e10cSrcweir // a dollar in XML means absolute (whereas in UI it means relative) 141cdf0e10cSrcweir if( pStrArray[ i ] == aDollar ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir i--; 144cdf0e10cSrcweir rOutCell.bRelativeRow = false; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir else 147cdf0e10cSrcweir rOutCell.bRelativeRow = true; 148cdf0e10cSrcweir 149cdf0e10cSrcweir // parse rest for column 150cdf0e10cSrcweir sal_Int32 nPower = 1; 151cdf0e10cSrcweir while( CharClass::isAsciiAlpha( pStrArray[ i ] )) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir nColumn += (pStrArray[ i ] - aLetterA + 1) * nPower; 154cdf0e10cSrcweir i--; 155cdf0e10cSrcweir nPower *= 26; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir rOutCell.nColumn = nColumn - 1; 158cdf0e10cSrcweir 159cdf0e10cSrcweir rOutCell.bRelativeColumn = true; 160cdf0e10cSrcweir if( i >= 0 && 161cdf0e10cSrcweir pStrArray[ i ] == aDollar ) 162cdf0e10cSrcweir rOutCell.bRelativeColumn = false; 163cdf0e10cSrcweir rOutCell.bIsEmpty = false; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir bool lcl_getCellAddressFromXMLString( 167cdf0e10cSrcweir const ::rtl::OUString& rXMLString, 168cdf0e10cSrcweir sal_Int32 nStartPos, sal_Int32 nEndPos, 169cdf0e10cSrcweir ::chart::XMLRangeHelper::Cell & rOutCell, 170cdf0e10cSrcweir ::rtl::OUString& rOutTableName ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir static const sal_Unicode aDot( '.' ); 173cdf0e10cSrcweir static const sal_Unicode aQuote( '\'' ); 174cdf0e10cSrcweir static const sal_Unicode aBackslash( '\\' ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir sal_Int32 nNextDelimiterPos = nStartPos; 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Int32 nDelimiterPos = nStartPos; 179cdf0e10cSrcweir bool bInQuotation = false; 180cdf0e10cSrcweir // parse table name 181cdf0e10cSrcweir while( nDelimiterPos < nEndPos && 182cdf0e10cSrcweir ( bInQuotation || rXMLString[ nDelimiterPos ] != aDot )) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir // skip escaped characters (with backslash) 185cdf0e10cSrcweir if( rXMLString[ nDelimiterPos ] == aBackslash ) 186cdf0e10cSrcweir ++nDelimiterPos; 187cdf0e10cSrcweir // toggle quotation mode when finding single quotes 188cdf0e10cSrcweir else if( rXMLString[ nDelimiterPos ] == aQuote ) 189cdf0e10cSrcweir bInQuotation = ! bInQuotation; 190cdf0e10cSrcweir 191cdf0e10cSrcweir ++nDelimiterPos; 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir if( nDelimiterPos == -1 ) 195cdf0e10cSrcweir return false; 196cdf0e10cSrcweir 197cdf0e10cSrcweir if( nDelimiterPos > nStartPos && nDelimiterPos < nEndPos ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir // there is a table name before the address 200cdf0e10cSrcweir 201cdf0e10cSrcweir ::rtl::OUStringBuffer aTableNameBuffer; 202cdf0e10cSrcweir const sal_Unicode * pTableName = rXMLString.getStr(); 203cdf0e10cSrcweir 204cdf0e10cSrcweir // remove escapes from table name 205cdf0e10cSrcweir ::std::for_each( pTableName + nStartPos, 206cdf0e10cSrcweir pTableName + nDelimiterPos, 207cdf0e10cSrcweir lcl_UnEscape( aTableNameBuffer )); 208cdf0e10cSrcweir 209cdf0e10cSrcweir // unquote quoted table name 210cdf0e10cSrcweir const sal_Unicode * pBuf = aTableNameBuffer.getStr(); 211cdf0e10cSrcweir if( pBuf[ 0 ] == aQuote && 212cdf0e10cSrcweir pBuf[ aTableNameBuffer.getLength() - 1 ] == aQuote ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir ::rtl::OUString aName = aTableNameBuffer.makeStringAndClear(); 215cdf0e10cSrcweir rOutTableName = aName.copy( 1, aName.getLength() - 2 ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir else 218cdf0e10cSrcweir rOutTableName = aTableNameBuffer.makeStringAndClear(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir else 221cdf0e10cSrcweir nDelimiterPos = nStartPos; 222cdf0e10cSrcweir 223cdf0e10cSrcweir for( sal_Int32 i = 0; 224cdf0e10cSrcweir nNextDelimiterPos < nEndPos; 225cdf0e10cSrcweir nDelimiterPos = nNextDelimiterPos, i++ ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir nNextDelimiterPos = rXMLString.indexOf( aDot, nDelimiterPos + 1 ); 228cdf0e10cSrcweir if( nNextDelimiterPos == -1 || 229cdf0e10cSrcweir nNextDelimiterPos > nEndPos ) 230cdf0e10cSrcweir nNextDelimiterPos = nEndPos + 1; 231cdf0e10cSrcweir 232cdf0e10cSrcweir if( i==0 ) 233cdf0e10cSrcweir // only take first cell 234cdf0e10cSrcweir lcl_getSingleCellAddressFromXMLString( 235cdf0e10cSrcweir rXMLString, nDelimiterPos + 1, nNextDelimiterPos - 1, rOutCell ); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir return true; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir bool lcl_getCellRangeAddressFromXMLString( 242cdf0e10cSrcweir const ::rtl::OUString& rXMLString, 243cdf0e10cSrcweir sal_Int32 nStartPos, sal_Int32 nEndPos, 244cdf0e10cSrcweir ::chart::XMLRangeHelper::CellRange & rOutRange ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir bool bResult = true; 247cdf0e10cSrcweir static const sal_Unicode aColon( ':' ); 248cdf0e10cSrcweir static const sal_Unicode aQuote( '\'' ); 249cdf0e10cSrcweir static const sal_Unicode aBackslash( '\\' ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir sal_Int32 nDelimiterPos = nStartPos; 252cdf0e10cSrcweir bool bInQuotation = false; 253cdf0e10cSrcweir // parse table name 254cdf0e10cSrcweir while( nDelimiterPos < nEndPos && 255cdf0e10cSrcweir ( bInQuotation || rXMLString[ nDelimiterPos ] != aColon )) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir // skip escaped characters (with backslash) 258cdf0e10cSrcweir if( rXMLString[ nDelimiterPos ] == aBackslash ) 259cdf0e10cSrcweir ++nDelimiterPos; 260cdf0e10cSrcweir // toggle quotation mode when finding single quotes 261cdf0e10cSrcweir else if( rXMLString[ nDelimiterPos ] == aQuote ) 262cdf0e10cSrcweir bInQuotation = ! bInQuotation; 263cdf0e10cSrcweir 264cdf0e10cSrcweir ++nDelimiterPos; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir if( nDelimiterPos == nEndPos ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir // only one cell 270cdf0e10cSrcweir bResult = lcl_getCellAddressFromXMLString( rXMLString, nStartPos, nEndPos, 271cdf0e10cSrcweir rOutRange.aUpperLeft, 272cdf0e10cSrcweir rOutRange.aTableName ); 273cdf0e10cSrcweir if( !rOutRange.aTableName.getLength() ) 274cdf0e10cSrcweir bResult = false; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir else 277cdf0e10cSrcweir { 278cdf0e10cSrcweir // range (separated by a colon) 279cdf0e10cSrcweir bResult = lcl_getCellAddressFromXMLString( rXMLString, nStartPos, nDelimiterPos - 1, 280cdf0e10cSrcweir rOutRange.aUpperLeft, 281cdf0e10cSrcweir rOutRange.aTableName ); 282cdf0e10cSrcweir if( !rOutRange.aTableName.getLength() ) 283cdf0e10cSrcweir bResult = false; 284cdf0e10cSrcweir 285cdf0e10cSrcweir ::rtl::OUString sTableSecondName; 286cdf0e10cSrcweir if( bResult ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir bResult = lcl_getCellAddressFromXMLString( rXMLString, nDelimiterPos + 1, nEndPos, 289cdf0e10cSrcweir rOutRange.aLowerRight, 290cdf0e10cSrcweir sTableSecondName ); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir if( bResult && 293cdf0e10cSrcweir sTableSecondName.getLength() && 294cdf0e10cSrcweir ! sTableSecondName.equals( rOutRange.aTableName )) 295cdf0e10cSrcweir bResult = false; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir return bResult; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir } // anonymous namespace 302cdf0e10cSrcweir 303cdf0e10cSrcweir // ================================================================================ 304cdf0e10cSrcweir 305cdf0e10cSrcweir namespace chart 306cdf0e10cSrcweir { 307cdf0e10cSrcweir namespace XMLRangeHelper 308cdf0e10cSrcweir { 309cdf0e10cSrcweir 310cdf0e10cSrcweir CellRange getCellRangeFromXMLString( const OUString & rXMLString ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir static const sal_Unicode aSpace( ' ' ); 313cdf0e10cSrcweir static const sal_Unicode aQuote( '\'' ); 314cdf0e10cSrcweir // static const sal_Unicode aDoubleQuote( '\"' ); 315cdf0e10cSrcweir static const sal_Unicode aDollar( '$' ); 316cdf0e10cSrcweir static const sal_Unicode aBackslash( '\\' ); 317cdf0e10cSrcweir 318cdf0e10cSrcweir sal_Int32 nStartPos = 0; 319cdf0e10cSrcweir sal_Int32 nEndPos = nStartPos; 320cdf0e10cSrcweir const sal_Int32 nLength = rXMLString.getLength(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir // reset 323cdf0e10cSrcweir CellRange aResult; 324cdf0e10cSrcweir 325cdf0e10cSrcweir // iterate over different ranges 326cdf0e10cSrcweir for( sal_Int32 i = 0; 327cdf0e10cSrcweir nEndPos < nLength; 328cdf0e10cSrcweir nStartPos = ++nEndPos, i++ ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir // find start point of next range 331cdf0e10cSrcweir 332cdf0e10cSrcweir // ignore leading '$' 333cdf0e10cSrcweir if( rXMLString[ nEndPos ] == aDollar) 334cdf0e10cSrcweir nEndPos++; 335cdf0e10cSrcweir 336cdf0e10cSrcweir bool bInQuotation = false; 337cdf0e10cSrcweir // parse range 338cdf0e10cSrcweir while( nEndPos < nLength && 339cdf0e10cSrcweir ( bInQuotation || rXMLString[ nEndPos ] != aSpace )) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir // skip escaped characters (with backslash) 342cdf0e10cSrcweir if( rXMLString[ nEndPos ] == aBackslash ) 343cdf0e10cSrcweir ++nEndPos; 344cdf0e10cSrcweir // toggle quotation mode when finding single quotes 345cdf0e10cSrcweir else if( rXMLString[ nEndPos ] == aQuote ) 346cdf0e10cSrcweir bInQuotation = ! bInQuotation; 347cdf0e10cSrcweir 348cdf0e10cSrcweir ++nEndPos; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir if( ! lcl_getCellRangeAddressFromXMLString( 352cdf0e10cSrcweir rXMLString, 353cdf0e10cSrcweir nStartPos, nEndPos - 1, 354cdf0e10cSrcweir aResult )) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir // if an error occured, bail out 357cdf0e10cSrcweir return CellRange(); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir return aResult; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir OUString getXMLStringFromCellRange( const CellRange & rRange ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir static const sal_Unicode aSpace( ' ' ); 367cdf0e10cSrcweir static const sal_Unicode aQuote( '\'' ); 368cdf0e10cSrcweir 369cdf0e10cSrcweir ::rtl::OUStringBuffer aBuffer; 370cdf0e10cSrcweir 371cdf0e10cSrcweir if( (rRange.aTableName).getLength()) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir bool bNeedsEscaping = ( rRange.aTableName.indexOf( aQuote ) > -1 ); 374cdf0e10cSrcweir bool bNeedsQuoting = bNeedsEscaping || ( rRange.aTableName.indexOf( aSpace ) > -1 ); 375cdf0e10cSrcweir 376cdf0e10cSrcweir // quote table name if it contains spaces or quotes 377cdf0e10cSrcweir if( bNeedsQuoting ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir // leading quote 380cdf0e10cSrcweir aBuffer.append( aQuote ); 381cdf0e10cSrcweir 382cdf0e10cSrcweir // escape existing quotes 383cdf0e10cSrcweir if( bNeedsEscaping ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir const sal_Unicode * pTableNameBeg = rRange.aTableName.getStr(); 386cdf0e10cSrcweir 387cdf0e10cSrcweir // append the quoted string at the buffer 388cdf0e10cSrcweir ::std::for_each( pTableNameBeg, 389cdf0e10cSrcweir pTableNameBeg + rRange.aTableName.getLength(), 390cdf0e10cSrcweir lcl_Escape( aBuffer ) ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir else 393cdf0e10cSrcweir aBuffer.append( rRange.aTableName ); 394cdf0e10cSrcweir 395cdf0e10cSrcweir // final quote 396cdf0e10cSrcweir aBuffer.append( aQuote ); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir else 399cdf0e10cSrcweir aBuffer.append( rRange.aTableName ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir aBuffer.append( lcl_getXMLStringForCell( rRange.aUpperLeft )); 402cdf0e10cSrcweir 403cdf0e10cSrcweir if( ! rRange.aLowerRight.empty()) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir // we have a range (not a single cell) 406cdf0e10cSrcweir aBuffer.append( sal_Unicode( ':' )); 407cdf0e10cSrcweir aBuffer.append( lcl_getXMLStringForCell( rRange.aLowerRight )); 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir return aBuffer.makeStringAndClear(); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir } // namespace XMLRangeHelper 414cdf0e10cSrcweir } // namespace chart 415