Lines 2-8
Link Here
|
2 |
* |
2 |
* |
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
4 |
* |
5 |
* Copyright 2008 by Sun Microsystems, Inc. |
5 |
* Copyright 2009 by Sun Microsystems, Inc. |
6 |
* |
6 |
* |
7 |
* OpenOffice.org - a multi-platform office productivity suite |
7 |
* OpenOffice.org - a multi-platform office productivity suite |
8 |
* |
8 |
* |
Lines 1163-1169
Link Here
|
1163 |
} |
1163 |
} |
1164 |
|
1164 |
|
1165 |
|
1165 |
|
1166 |
table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1) throw ( uno::RuntimeException ) |
1166 |
table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1) throw ( uno::RuntimeException ) |
1167 |
{ |
1167 |
{ |
1168 |
uno::Reference< table::XCellRange > xRangeParam; |
1168 |
uno::Reference< table::XCellRange > xRangeParam; |
1169 |
switch ( aParam.getValueTypeClass() ) |
1169 |
switch ( aParam.getValueTypeClass() ) |
Lines 1174-1179
Link Here
|
1174 |
aParam >>= rString; |
1174 |
aParam >>= rString; |
1175 |
ScRangeList aCellRanges; |
1175 |
ScRangeList aCellRanges; |
1176 |
ScRange refRange; |
1176 |
ScRange refRange; |
|
|
1177 |
//VBA by minz@cn.ibm.com. Set reference range. |
1178 |
ScUnoConversion::FillScRange( refRange, pAddr ); |
1177 |
if ( getScRangeListForAddress ( rString, pDocSh, refRange, aCellRanges, aConv ) ) |
1179 |
if ( getScRangeListForAddress ( rString, pDocSh, refRange, aCellRanges, aConv ) ) |
1178 |
{ |
1180 |
{ |
1179 |
if ( aCellRanges.First() == aCellRanges.Last() ) |
1181 |
if ( aCellRanges.First() == aCellRanges.Last() ) |
Lines 1470-1475
Link Here
|
1470 |
setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; |
1472 |
setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; |
1471 |
} |
1473 |
} |
1472 |
|
1474 |
|
|
|
1475 |
//Add by minz@cn.ibm.com. Support Range.FormulaLocal. |
1476 |
uno::Any |
1477 |
ScVbaRange::getFormulaLocal() throw (::com::sun::star::uno::RuntimeException) |
1478 |
{ |
1479 |
return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ); |
1480 |
} |
1481 |
|
1482 |
void |
1483 |
ScVbaRange::setFormulaLocal(const uno::Any& rFormula ) throw (uno::RuntimeException) |
1484 |
{ |
1485 |
setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ); |
1486 |
} |
1487 |
|
1473 |
uno::Any |
1488 |
uno::Any |
1474 |
ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) |
1489 |
ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) |
1475 |
{ |
1490 |
{ |
Lines 1745-1757
Link Here
|
1745 |
|
1760 |
|
1746 |
//VBA, minz@cn.ibm.com |
1761 |
//VBA, minz@cn.ibm.com |
1747 |
uno::Sequence< uno::Sequence<rtl::OUString> > aFmArray = xCellRangeFormula->getFormulaArray(); |
1762 |
uno::Sequence< uno::Sequence<rtl::OUString> > aFmArray = xCellRangeFormula->getFormulaArray(); |
1748 |
if( aFmArray.getLength() ) |
1763 |
if( aFmArray.getLength() == 0 ) |
|
|
1764 |
return aMatrix; |
1765 |
else if( aFmArray.getLength() == 1 && aFmArray[0].getLength() == 1 ) |
1749 |
{ |
1766 |
{ |
1750 |
if( aFmArray.getLength() == 1 && aFmArray[0].getLength() == 1 ) |
1767 |
//liuchen 2009-9-23 the string got by excel Range.FormulaArray() does not contain brackets |
1751 |
aMatrix <<= aFmArray[0][0]; |
1768 |
rtl::OUString strMatrix = aFmArray[0][0]; |
1752 |
else |
1769 |
if (strMatrix.indexOf('{') == 0 && strMatrix.lastIndexOf('}') == strMatrix.getLength() - 1) |
1753 |
aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ; |
1770 |
{ |
1754 |
} |
1771 |
aMatrix <<= strMatrix.copy(1, strMatrix.getLength() - 2); |
|
|
1772 |
} |
1773 |
//liuchen 2009-9-23 |
1774 |
|
1775 |
return aMatrix; |
1776 |
} |
1777 |
aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ; |
1755 |
return aMatrix; |
1778 |
return aMatrix; |
1756 |
} |
1779 |
} |
1757 |
|
1780 |
|
Lines 1868-1875
Link Here
|
1868 |
if ( RelativeTo.hasValue() ) |
1891 |
if ( RelativeTo.hasValue() ) |
1869 |
{ |
1892 |
{ |
1870 |
// #TODO should I throw an error if R1C1 is not set? |
1893 |
// #TODO should I throw an error if R1C1 is not set? |
1871 |
|
1894 |
table::CellRangeAddress refParentAddr;//no use |
1872 |
table::CellRangeAddress refAddress = getCellRangeAddressForVBARange( RelativeTo, pDocShell ); |
1895 |
table::CellRangeAddress refAddress = getCellRangeAddressForVBARange( RelativeTo, pDocShell, refParentAddr ); |
1873 |
dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) ); |
1896 |
dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) ); |
1874 |
} |
1897 |
} |
1875 |
aRange.Format( sRange, nFlags, pDoc, dDetails ); |
1898 |
aRange.Format( sRange, nFlags, pDoc, dDetails ); |
Lines 2439-2451
Link Here
|
2439 |
} |
2462 |
} |
2440 |
else |
2463 |
else |
2441 |
{ |
2464 |
{ |
|
|
2465 |
//VBA by minz@cn.ibm.com. Set this range as reference range. |
2466 |
RangeHelper referRange( xReferrer ); |
2467 |
table::CellRangeAddress referAddress = referRange.getCellRangeAddressable()->getRangeAddress(); |
2468 |
|
2442 |
table::CellRangeAddress cell1, cell2; |
2469 |
table::CellRangeAddress cell1, cell2; |
2443 |
cell1 = getCellRangeAddressForVBARange( Cell1, getScDocShell() ); |
2470 |
cell1 = getCellRangeAddressForVBARange( Cell1, getScDocShell(), referAddress ); |
2444 |
// Cell1 & Cell2 defined |
2471 |
// Cell1 & Cell2 defined |
2445 |
// Excel seems to combine the range as the range defined by |
2472 |
// Excel seems to combine the range as the range defined by |
2446 |
// the combination of Cell1 & Cell2 |
2473 |
// the combination of Cell1 & Cell2 |
2447 |
|
2474 |
|
2448 |
cell2 = getCellRangeAddressForVBARange( Cell2, getScDocShell() ); |
2475 |
cell2 = getCellRangeAddressForVBARange( Cell2, getScDocShell(), referAddress ); |
2449 |
|
2476 |
|
2450 |
resultAddress.StartColumn = ( cell1.StartColumn < cell2.StartColumn ) ? cell1.StartColumn : cell2.StartColumn; |
2477 |
resultAddress.StartColumn = ( cell1.StartColumn < cell2.StartColumn ) ? cell1.StartColumn : cell2.StartColumn; |
2451 |
resultAddress.StartRow = ( cell1.StartRow < cell2.StartRow ) ? cell1.StartRow : cell2.StartRow; |
2478 |
resultAddress.StartRow = ( cell1.StartRow < cell2.StartRow ) ? cell1.StartRow : cell2.StartRow; |
Lines 2962-2968
Link Here
|
2962 |
uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange ); |
2989 |
uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange ); |
2963 |
if( xResultRange.is() ) |
2990 |
if( xResultRange.is() ) |
2964 |
{ |
2991 |
{ |
2965 |
xResultRange->Select(); |
2992 |
//VBA by minz@cn.ibm.com. No need to change focus to the found range. |
|
|
2993 |
//xResultRange->Select(); |
2966 |
return xResultRange; |
2994 |
return xResultRange; |
2967 |
} |
2995 |
} |
2968 |
} |
2996 |
} |
Lines 5155-5160
Link Here
|
5155 |
bool bIsSingleCell = isSingleCellRange(); |
5183 |
bool bIsSingleCell = isSingleCellRange(); |
5156 |
bool bIsMultiArea = ( m_Areas->getCount() > 1 ); |
5184 |
bool bIsMultiArea = ( m_Areas->getCount() > 1 ); |
5157 |
ScVbaRange* pRangeToUse = this; |
5185 |
ScVbaRange* pRangeToUse = this; |
|
|
5186 |
uno::Reference< excel::XRange > xUsedRange; |
5158 |
sal_Int32 nType = 0; |
5187 |
sal_Int32 nType = 0; |
5159 |
if ( !( _oType >>= nType ) ) |
5188 |
if ( !( _oType >>= nType ) ) |
5160 |
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); |
5189 |
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); |
Lines 5170-5176
Link Here
|
5170 |
case excel::XlCellType::xlCellTypeConstants: |
5199 |
case excel::XlCellType::xlCellTypeConstants: |
5171 |
case excel::XlCellType::xlCellTypeFormulas: |
5200 |
case excel::XlCellType::xlCellTypeFormulas: |
5172 |
case excel::XlCellType::xlCellTypeVisible: |
5201 |
case excel::XlCellType::xlCellTypeVisible: |
5173 |
case excel::XlCellType::xlCellTypeLastCell: |
5202 |
// case excel::XlCellType::xlCellTypeLastCell: |
5174 |
{ |
5203 |
{ |
5175 |
if ( bIsMultiArea ) |
5204 |
if ( bIsMultiArea ) |
5176 |
{ |
5205 |
{ |
Lines 5217-5228
Link Here
|
5217 |
} |
5246 |
} |
5218 |
else if ( bIsSingleCell ) |
5247 |
else if ( bIsSingleCell ) |
5219 |
{ |
5248 |
{ |
5220 |
uno::Reference< excel::XRange > xUsedRange = getWorksheet()->getUsedRange(); |
5249 |
xUsedRange = getWorksheet()->getUsedRange(); |
5221 |
pRangeToUse = static_cast< ScVbaRange* >( xUsedRange.get() ); |
5250 |
pRangeToUse = dynamic_cast< ScVbaRange* >( xUsedRange.get() ); |
5222 |
} |
5251 |
} |
5223 |
|
5252 |
|
5224 |
break; |
5253 |
break; |
5225 |
} |
5254 |
} |
|
|
5255 |
//the last cell in the used range |
5256 |
case excel::XlCellType::xlCellTypeLastCell: |
5257 |
{ |
5258 |
xUsedRange = getWorksheet()->getUsedRange(); |
5259 |
pRangeToUse = dynamic_cast< ScVbaRange* >( xUsedRange.get() ); |
5260 |
} |
5261 |
break; |
5262 |
|
5226 |
default: |
5263 |
default: |
5227 |
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); |
5264 |
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); |
5228 |
break; |
5265 |
break; |
Lines 5295-5300
Link Here
|
5295 |
} |
5332 |
} |
5296 |
case excel::XlCellType::xlCellTypeLastCell: |
5333 |
case excel::XlCellType::xlCellTypeLastCell: |
5297 |
xRange = Cells( uno::makeAny( getCount() ), uno::Any() ); |
5334 |
xRange = Cells( uno::makeAny( getCount() ), uno::Any() ); |
|
|
5335 |
break; |
5298 |
case excel::XlCellType::xlCellTypeVisible: |
5336 |
case excel::XlCellType::xlCellTypeVisible: |
5299 |
xLocSheetCellRanges = xQuery->queryVisibleCells(); |
5337 |
xLocSheetCellRanges = xQuery->queryVisibleCells(); |
5300 |
break; |
5338 |
break; |