if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
{
ScDocument& rDoc = GetViewData().GetDocument(); if ( (bOnlyASample || bInFormatDialog) && aRange.aStart.Row() != aRange.aEnd.Row() )
{ // limit range to one data row // (only when the call comes from a format dialog)
ScHorizontalCellIterator aIter( rDoc, aRange.aStart.Tab(),
aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row() );
SCCOL nCol;
SCROW nRow; if ( aIter.GetNext( nCol, nRow ) )
{
aRange.aStart.SetCol( nCol );
aRange.aStart.SetRow( nRow );
aRange.aEnd.SetRow( nRow );
} else
aRange.aEnd = aRange.aStart;
} else
{ // #i111531# with 1M rows it was necessary to limit the range // to the actually used data area.
SCCOL nCol1, nCol2;
SCROW nRow1, nRow2;
SCTAB nTab1, nTab2;
aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); bool bShrunk;
rDoc.ShrinkToUsedDataArea( bShrunk, nTab1, nCol1, nRow1, nCol2, nRow2, false); if (bShrunk)
{
aRange.aStart.SetCol( nCol1 );
aRange.aStart.SetRow( nRow1 );
aRange.aEnd.SetCol( nCol2 );
aRange.aEnd.SetRow( nRow2 );
}
}
ScImportExport aObj( rDoc, aRange ); // tdf#148437 - if cell contains a formula, overwrite entire content of the cell
aObj.SetFormulas(true);
OUString aExportOUString; /* TODO: STRING_TSVC under some circumstances? */
aObj.ExportString( aExportOUString, SotClipboardFormatId::STRING );
aStrSelection = convertLineEnd(aExportOUString, LINEEND_CR);
// replace Tab/CR with space, if for dialog or through Basic/SelectionTextExt, // or when it is a single row. // Otherwise keep Tabs in multi-row (for instance mail or Basic/SelectionText). // for mail the Tabs are then later changed into (multiple) spaces.
if ( bAsText )
{ if ( GetViewData().IsActive() )
{ // if the view is active, always use InsertURLField, which starts EditMode // and selects the URL, so it can be changed from the URL bar / dialog
InsertURLField( rName, rURL, rTarget );
} else
{ // if the view is not active, InsertURLField doesn't work // -> use InsertBookmark to directly manipulate cell content // bTryReplace=sal_True -> if cell contains only one URL, replace it
staticvoid lcl_SelectFieldAfterInsert( EditView& rView )
{
ESelection aSel = rView.GetSelection(); if (aSel.start.nIndex == aSel.end.nIndex && aSel.start.nIndex > 0)
{ // Cursor is behind the inserted field -> extend selection to the left
// Check if user selected a whole cell by single click, and cell has content. // tdf#80043 - if true, replace the entire content of the selected cell instead of // inserting a duplicate, or appending the url. if (!bIsEditMode && !bSelectFirst && pTableView && !sSeltext.isEmpty())
{
nSelInd = sSeltext.getLength();
bSelectFirst = true;
}
if ( bSelectFirst )
{ if ( pTopView )
pTopView->SetSelection( ESelection(0,0,0,1) ); if ( pTableView )
pTableView->SetSelection( ESelection(0,0,0,nSelInd) );
}