summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/viewfun4.cxx
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 10:04:47 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 10:04:47 +0000
commit5099046dccb69af04e2a3adafad8e06c0832bd06 (patch)
treebf9a7b20c84fec1a18a65c66b6a0a25d6bc7e2f7 /sc/source/ui/view/viewfun4.cxx
parent6189b25c86e18ef0021ea2f3ba256be36d0fb4be (diff)
CWS-TOOLING: integrate CWS calc51
2009-07-17 15:47:46 +0200 er r274098 : #i101544# more thorough reference checking in chart data ranges; also prevent some possible crash if invalid ranges were to be passed to document/cell access. 2009-07-16 14:20:11 +0200 er r274051 : #i101544# let ScRefTokenHelper::compileRangeRepresentation() fail on all possible non-reference occasions 2009-07-07 10:11:40 +0200 nn r273776 : #i35579# don't use long instead of sal_Int32 2009-07-03 16:41:39 +0200 nn r273711 : msvc warnings 2009-07-03 14:18:45 +0200 nn r273698 : msvc warning 2009-07-03 11:30:41 +0200 nn r273685 : #i35579# move new tokens to the end 2009-07-03 10:12:55 +0200 nn r273681 : CWS-TOOLING: rebase CWS calc51 to trunk@273468 (milestone: DEV300:m51) 2009-06-30 17:57:30 +0200 nn r273529 : #i103027# EnterData: if it's a formula, don't pass EditTextObject to undo 2009-06-29 14:31:18 +0200 er r273474 : #i101544# #i101645# #i102388# applied diff from CWS dr68ooo311 2009-06-29 10:30:20 +0200 nn r273457 : #i103161# DeleteCells: always leave list action 2009-06-24 16:16:34 +0200 nn r273353 : gcc warnings 2009-06-17 11:50:28 +0200 tbe r273055 : #i35579# Standard filter requires more options 2009-06-17 11:44:22 +0200 tbe r273054 : #i35579# Standard filter requires more options 2009-06-17 11:22:23 +0200 tbe r273052 : #i35579# Standard filter requires more options 2009-06-15 18:29:32 +0200 nn r273006 : #160063# UseFormulaData: check parenthesis position 2009-06-12 15:41:16 +0200 nn r272923 : #i99250# handle range lists in DoAutoOutline (patch from dtardon) 2009-06-11 15:07:05 +0200 nn r272874 : #i86943# GetNextPos: skip overlapped cells 2009-06-11 11:17:37 +0200 nn r272856 : #i97726# EnterData: get text from EditTextObject for repeat string of undo action 2009-06-10 20:45:07 +0200 nn r272839 : #i102566# minimum amount of code between updates of calculation progress (patch by cmc) 2009-06-10 20:22:02 +0200 nn r272838 : #i69524# PasteFile: specify target for SID_OPENDOC 2009-06-09 17:33:08 +0200 nn r272789 : #i16615# absolute/relative reference conversion for cell ranges (patch by gaojingmei)
Diffstat (limited to 'sc/source/ui/view/viewfun4.cxx')
-rw-r--r--sc/source/ui/view/viewfun4.cxx128
1 files changed, 127 insertions, 1 deletions
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 57fef68c5f83..0f3a1c812802 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -81,6 +81,9 @@
#include "impex.hxx"
#include "editutil.hxx"
#include "editable.hxx"
+#include "dociter.hxx"
+#include "reffind.hxx"
+#include "compiler.hxx"
using namespace com::sun::star;
@@ -187,7 +190,128 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
ShowAllCursors();
}
}
+void ScViewFunc::DoRefConversion( BOOL bRecord )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScRange aMarkRange;
+ rMark.MarkToSimple();
+ BOOL bMulti = rMark.IsMultiMarked();
+ if (bMulti)
+ rMark.GetMultiMarkArea( aMarkRange );
+ else if (rMark.IsMarked())
+ rMark.GetMarkArea( aMarkRange );
+ else
+ {
+ aMarkRange = ScRange( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ }
+ ScEditableTester aTester( pDoc, aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),rMark );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bOk = FALSE;
+
+ ScDocument* pUndoDoc = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nTab = aMarkRange.aStart.Tab();
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( rMark.GetSelectCount() > 1 )
+ {
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( rMark.GetTableSelect(i) && i != nTab )
+ pUndoDoc->AddUndoTab( i, i );
+ }
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ALL, bMulti, pUndoDoc, &rMark );
+ }
+
+ ScRangeListRef xRanges;
+ GetViewData()->GetMultiArea( xRanges );
+ ULONG nCount = xRanges->Count();
+
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ if (rMark.GetTableSelect(i))
+ {
+ for (ULONG j=0; j<nCount; j++)
+ {
+ ScRange aRange = *xRanges->GetObject(j);
+ aRange.aStart.SetTab(i);
+ aRange.aEnd.SetTab(i);
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while ( pCell )
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ String aOld;
+ ((ScFormulaCell*)pCell)->GetFormula(aOld);
+ xub_StrLen nLen = aOld.Len();
+ ScRefFinder aFinder( aOld, pDoc );
+ aFinder.ToggleRel( 0, nLen );
+ if (aFinder.GetFound())
+ {
+ ScAddress aPos = ((ScFormulaCell*)pCell)->aPos;
+ String aNew = aFinder.GetText();
+ ScCompiler aComp( pDoc, aPos);
+ aComp.SetGrammar(pDoc->GetGrammar());
+ ScTokenArray* pArr = aComp.CompileString( aNew );
+ ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos,
+ pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
+ pDoc->PutCell( aPos, pNewCell );
+ bOk = TRUE;
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+ }
+ }
+ if (bRecord)
+ {
+ ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nTab = aMarkRange.aStart.Tab();
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( rMark.GetSelectCount() > 1 )
+ {
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( rMark.GetTableSelect(i) && i != nTab )
+ pRedoDoc->AddUndoTab( i, i );
+ }
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ALL, bMulti, pRedoDoc, &rMark );
+
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRefConversion( pDocSh,
+ aMarkRange, rMark, pUndoDoc, pRedoDoc, bMulti, IDF_ALL) );
+ }
+
+ pDocSh->PostPaint( aMarkRange, PAINT_GRID );
+ pDocSh->UpdateOle(GetViewData());
+ pDocSh->SetDocumentModified();
+ CellContentChanged();
+
+ if (!bOk)
+ ErrorMessage(STR_ERR_NOREF);
+}
// Thesaurus - Undo ok
void ScViewFunc::DoThesaurus( BOOL bRecord )
{
@@ -537,11 +661,13 @@ BOOL ScViewFunc::PasteFile( const Point& rPos, const String& rFile, BOOL bLink )
SfxDispatcher &rDispatcher = GetViewData()->GetDispatcher();
SfxStringItem aFileNameItem( SID_FILE_NAME, aStrURL );
SfxStringItem aFilterItem( SID_FILTER_NAME, pFlt->GetName() );
+ // #i69524# add target, as in SfxApplication when the Open dialog is used
+ SfxStringItem aTargetItem( SID_TARGETNAME, String::CreateFromAscii("_default") );
// Asynchron oeffnen, kann naemlich auch aus D&D heraus passieren
// und das bekommt dem MAC nicht so gut ...
return BOOL( 0 != rDispatcher.Execute( SID_OPENDOC,
- SFX_CALLMODE_ASYNCHRON, &aFileNameItem, &aFilterItem, 0L) );
+ SFX_CALLMODE_ASYNCHRON, &aFileNameItem, &aFilterItem, &aTargetItem, 0L) );
}
}