1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formula.cxx,v $
10 * $Revision: 1.18.30.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //----------------------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/objsh.hxx>
42 #include <svtools/zforlist.hxx>
43 #include <svtools/stritem.hxx>
44 #include <svtools/svtreebx.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <sfx2/topfrm.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vcl/mnemonic.hxx>
49 #include <unotools/charclass.hxx>
50 #include <tools/urlobj.hxx>
51 #include <formula/formulahelper.hxx>
52 #include <formula/IFunctionDescription.hxx>
54 #include "tokenuno.hxx"
55 #include "formula.hxx"
56 #include "formdata.hxx"
57 #include "globstr.hrc"
58 #include "scresid.hxx"
59 #include "reffact.hxx"
60 #include "document.hxx"
63 #include "inputhdl.hxx"
64 #include "tabvwsh.hxx"
65 #include "appoptio.hxx"
67 #include "funcdesc.hxx"
68 #include "formula/token.hxx"
69 #include "tokenarray.hxx"
71 #include "servuno.hxx"
72 #include "unonames.hxx"
73 #include "externalrefmgr.hxx"
75 #include <com/sun/star/table/CellAddress.hpp>
77 //============================================================================
78 using namespace formula
;
79 using namespace com::sun::star
;
81 ScDocument
* ScFormulaDlg::pDoc
= NULL
;
82 ScAddress
ScFormulaDlg::aCursorPos
;
86 // --------------------------------------------------------------------------
87 // Initialisierung / gemeinsame Funktionen fuer Dialog
88 // --------------------------------------------------------------------------
90 ScFormulaDlg::ScFormulaDlg( SfxBindings
* pB
, SfxChildWindow
* pCW
,
91 Window
* pParent
, ScViewData
* pViewData
,formula::IFunctionManager
* _pFunctionMgr
)
92 : formula::FormulaDlg( pB
, pCW
, pParent
, true,true,true,this, _pFunctionMgr
,this)
95 m_aHelper
.SetWindow(this);
96 ScModule
* pScMod
= SC_MOD();
97 pScMod
->InputEnterHandler();
98 ScTabViewShell
* pScViewShell
= NULL
;
100 // title has to be from the view that opened the dialog,
101 // even if it's not the current view
103 SfxObjectShell
* pParentDoc
= NULL
;
106 SfxDispatcher
* pMyDisp
= pB
->GetDispatcher();
109 SfxViewFrame
* pMyViewFrm
= pMyDisp
->GetFrame();
112 pScViewShell
= PTR_CAST( ScTabViewShell
, pMyViewFrm
->GetViewShell() );
114 pScViewShell
->UpdateInputHandler(TRUE
);
115 pParentDoc
= pMyViewFrm
->GetObjectShell();
119 //if ( !pParentDoc && pScViewShell ) // use current only if above fails
120 // pParentDoc = pScViewShell->GetObjectShell();
122 // aDocName = pParentDoc->GetTitle();
125 pDoc
= pViewData
->GetDocument();
126 m_xParser
.set(ScServiceProvider::MakeInstance(SC_SERVICE_FORMULAPARS
,(ScDocShell
*)pDoc
->GetDocumentShell()),uno::UNO_QUERY
);
127 uno::Reference
< beans::XPropertySet
> xSet(m_xParser
,uno::UNO_QUERY
);
128 xSet
->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COMPILEFAP
)),uno::makeAny(sal_True
));
130 m_xOpCodeMapper
.set(ScServiceProvider::MakeInstance(SC_SERVICE_OPCODEMAPPER
,(ScDocShell
*)pDoc
->GetDocumentShell()),uno::UNO_QUERY
);
132 ScInputHandler
* pInputHdl
= SC_MOD()->GetInputHdl(pScViewShell
);
134 DBG_ASSERT( pInputHdl
, "Missing input handler :-/" );
137 pInputHdl
->NotifyChange( NULL
);
139 m_aHelper
.enableInput( FALSE
);
140 m_aHelper
.EnableSpreadsheets();
142 m_aHelper
.SetDispatcherLock( TRUE
);
147 ScFormEditData
* pData
= pScMod
->GetFormEditData();
150 //Nun wird es Zeit den Inputhandler festzulegen
151 pScMod
->SetRefInputHdl(pScMod
->GetInputHdl());
153 pDoc
= pViewData
->GetDocument();
154 SCCOL nCol
= pViewData
->GetCurX();
155 SCROW nRow
= pViewData
->GetCurY();
156 SCTAB nTab
= pViewData
->GetTabNo();
157 aCursorPos
= ScAddress( nCol
, nRow
, nTab
);
159 pScMod
->InitFormEditData(); // neu anlegen
160 pData
= pScMod
->GetFormEditData();
161 pData
->SetInputHandler(pScMod
->GetInputHdl());
162 pData
->SetDocShell(pViewData
->GetDocShell());
164 DBG_ASSERT(pData
,"FormEditData ist nicht da");
166 formula::FormulaDlgMode eMode
= FORMULA_FORMDLG_FORMULA
; // Default...
168 // Formel vorhanden? Dann editieren
171 pDoc
->GetFormula( nCol
, nRow
, nTab
, aFormula
);
172 BOOL bEdit
= ( aFormula
.Len() > 1 );
173 BOOL bMatrix
= FALSE
;
176 bMatrix
= CheckMatrix(aFormula
);
178 xub_StrLen nFStart
= 0;
179 xub_StrLen nFEnd
= 0;
180 if ( GetFormulaHelper().GetNextFunc( aFormula
, FALSE
, nFStart
, &nFEnd
) )
182 pScMod
->InputReplaceSelection( aFormula
);
183 pScMod
->InputSetSelection( nFStart
, nFEnd
);
184 xub_StrLen PrivStart
, PrivEnd
;
185 pScMod
->InputGetSelection( PrivStart
, PrivEnd
);
187 eMode
= SetMeText(pScMod
->InputGetFormulaStr(),PrivStart
, PrivEnd
,bMatrix
,TRUE
,TRUE
);
188 pData
->SetFStart( nFStart
);
196 String aNewFormula
= '=';
197 if ( aFormula
.Len() > 0 && aFormula
.GetChar(0) == '=' )
198 aNewFormula
=aFormula
;
200 pScMod
->InputReplaceSelection( aNewFormula
);
201 pScMod
->InputSetSelection( 1, aNewFormula
.Len()+1 );
202 xub_StrLen PrivStart
, PrivEnd
;
203 pScMod
->InputGetSelection( PrivStart
, PrivEnd
);
204 SetMeText(pScMod
->InputGetFormulaStr(),PrivStart
, PrivEnd
,bMatrix
,FALSE
,FALSE
);
206 pData
->SetFStart( 1 ); // hinter dem "="
209 pData
->SetMode( (USHORT
) eMode
);
210 String rStrExp
= GetMeText();
212 pCell
= new ScFormulaCell( pDoc
, aCursorPos
, rStrExp
);
219 void ScFormulaDlg::notifyChange()
221 ScModule
* pScMod
= SC_MOD();
223 ScInputHandler
* pInputHdl
= pScMod
->GetInputHdl();
225 pInputHdl
->NotifyChange( NULL
);
227 // -----------------------------------------------------------------------------
228 void ScFormulaDlg::fill()
230 ScModule
* pScMod
= SC_MOD();
231 ScFormEditData
* pData
= pScMod
->GetFormEditData();
236 // Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten)
237 // pDoc und aCursorPos nicht neu initialisieren
238 //pDoc = pViewData->GetDocument();
239 if(IsInputHdl(pData
->GetInputHandler()))
241 pScMod
->SetRefInputHdl(pData
->GetInputHandler());
245 PtrTabViewShell pTabViewShell
;
246 ScInputHandler
* pInputHdl
= GetNextInputHandler(pData
->GetDocShell(),&pTabViewShell
);
248 if ( pInputHdl
== NULL
) //DocShell hat keinen InputHandler mehr,
249 { //hat der Anwender halt Pech gehabt.
251 pInputHdl
= pScMod
->GetInputHdl();
255 pInputHdl
->SetRefViewShell(pTabViewShell
);
257 pScMod
->SetRefInputHdl(pInputHdl
);
258 pData
->SetInputHandler(pInputHdl
);
261 String
aOldFormulaTmp(pScMod
->InputGetFormulaStr());
262 pScMod
->InputSetSelection( 0, aOldFormulaTmp
.Len());
264 rStrExp
=pData
->GetUndoStr();
265 pScMod
->InputReplaceSelection(rStrExp
);
269 pCell
= new ScFormulaCell( pDoc
, aCursorPos
, rStrExp
);
272 // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde!
273 pScMod
->SetRefInputHdl(NULL
);
277 __EXPORT
ScFormulaDlg::~ScFormulaDlg()
279 ScModule
* pScMod
= SC_MOD();
280 ScFormEditData
* pData
= pScMod
->GetFormEditData();
282 if (pData
) // wird nicht ueber Close zerstoert;
284 //Referenz Inputhandler zuruecksetzen
285 pScMod
->SetRefInputHdl(NULL
);
286 } // if (pData) // wird nicht ueber Close zerstoert;
291 BOOL
ScFormulaDlg::IsInputHdl(ScInputHandler
* pHdl
)
295 // gehoert der InputHandler zu irgendeiner ViewShell ?
297 TypeId aScType
= TYPE(ScTabViewShell
);
298 SfxViewShell
* pSh
= SfxViewShell::GetFirst( &aScType
);
299 while ( pSh
&& !bAlive
)
301 if (((ScTabViewShell
*)pSh
)->GetInputHandler() == pHdl
)
303 pSh
= SfxViewShell::GetNext( *pSh
, &aScType
);
310 ScInputHandler
* ScFormulaDlg::GetNextInputHandler(ScDocShell
* pDocShell
,PtrTabViewShell
* ppViewSh
)
312 ScInputHandler
* pHdl
=NULL
;
314 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( pDocShell
, TYPE(SfxTopViewFrame
) );
315 while( pFrame
&& pHdl
==NULL
)
317 SfxViewShell
* p
= pFrame
->GetViewShell();
318 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
,p
);
321 pHdl
=pViewSh
->GetInputHandler();
322 if(ppViewSh
!=NULL
) *ppViewSh
=pViewSh
;
324 pFrame
= SfxViewFrame::GetNext(*pFrame
,pDocShell
, TYPE(SfxTopViewFrame
) );
332 BOOL __EXPORT
ScFormulaDlg::Close()
338 // --------------------------------------------------------------------------
339 // Funktionen fuer rechte Seite
340 // --------------------------------------------------------------------------
341 bool ScFormulaDlg::calculateValue( const String
& rStrExp
, String
& rStrResult
)
345 ::std::auto_ptr
<ScFormulaCell
> pFCell( new ScFormulaCell( pDoc
, aCursorPos
, rStrExp
) );
347 // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen,
348 // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
349 // eingefuegt wird, bei der Einzeldarstellung aber als
350 // single-Zellbezug interpretiert wird
351 BOOL bColRowName
= pCell
->HasColRowName();
354 // ColRowName im RPN-Code?
355 if ( pCell
->GetCode()->GetCodeLen() <= 1 )
356 { // ==1: einzelner ist als Parameter immer Bereich
357 // ==0: es waere vielleicht einer, wenn..
358 String
aBraced( '(' );
361 pFCell
.reset( new ScFormulaCell( pDoc
, aCursorPos
, aBraced
) );
367 USHORT nErrCode
= pFCell
->GetErrCode();
370 SvNumberFormatter
& aFormatter
= *(pDoc
->GetFormatTable());
372 if ( pFCell
->IsValue() )
374 double n
= pFCell
->GetValue();
375 ULONG nFormat
= aFormatter
.GetStandardFormat( n
, 0,
376 pFCell
->GetFormatType(), ScGlobal::eLnge
);
377 aFormatter
.GetOutputString( n
, nFormat
,
378 rStrResult
, &pColor
);
384 pFCell
->GetString( aStr
);
385 ULONG nFormat
= aFormatter
.GetStandardFormat(
386 pFCell
->GetFormatType(), ScGlobal::eLnge
);
387 aFormatter
.GetOutputString( aStr
, nFormat
,
388 rStrResult
, &pColor
);
392 if ( bColRowName
|| (aTestRange
.Parse(rStrExp
) & SCA_VALID
) )
393 rStrResult
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." ));
397 rStrResult
+= ScGlobal::GetErrorString(nErrCode
);
399 if(!isUserMatrix() && pFCell
->GetMatrixFlag())
409 // virtuelle Methoden von ScAnyRefDlg:
410 void ScFormulaDlg::RefInputStart( formula::RefEdit
* pEdit
, formula::RefButton
* pButton
)
412 ::std::pair
<formula::RefButton
*,formula::RefEdit
*> aPair
= RefInputStartBefore( pEdit
, pButton
);
413 m_aHelper
.RefInputStart( aPair
.second
, aPair
.first
);
414 RefInputStartAfter( aPair
.second
, aPair
.first
);
416 void ScFormulaDlg::RefInputDone( BOOL bForced
)
418 m_aHelper
.RefInputDone( bForced
);
419 RefInputDoneAfter( bForced
);
422 void ScFormulaDlg::SetReference( const ScRange
& rRef
, ScDocument
* pRefDoc
)
424 const IFunctionDescription
* pFunc
= getCurrentFunctionDescription();
425 if ( pFunc
&& pFunc
->getSuppressedArgumentCount() > 0 )
428 BOOL bRefNull
= UpdateParaWin(theSel
);
430 if ( rRef
.aStart
!= rRef
.aEnd
&& bRefNull
)
432 RefInputStart(GetActiveEdit());
436 BOOL bOtherDoc
= ( pRefDoc
!= pDoc
&& pRefDoc
->GetDocumentShell()->HasName() );
439 // Referenz auf anderes Dokument - wie inputhdl.cxx
441 DBG_ASSERT(rRef
.aStart
.Tab()==rRef
.aEnd
.Tab(), "nStartTab!=nEndTab");
444 rRef
.Format( aTmp
, SCA_VALID
|SCA_TAB_3D
, pRefDoc
); // immer 3d
446 SfxObjectShell
* pObjSh
= pRefDoc
->GetDocumentShell();
448 // #i75893# convert escaped URL of the document to something user friendly
449 // String aFileName = pObjSh->GetMedium()->GetName();
450 String aFileName
= pObjSh
->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS
);
453 aRefStr
+= aFileName
;
454 aRefStr
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "'#" ));
459 USHORT nFmt
= ( rRef
.aStart
.Tab() == aCursorPos
.Tab() )
461 : SCA_VALID
| SCA_TAB_3D
;
462 rRef
.Format( aRefStr
, nFmt
, pRefDoc
, pRefDoc
->GetAddressConvention() );
465 UpdateParaWin(theSel
,aRefStr
);
469 BOOL
ScFormulaDlg::IsRefInputMode() const
471 const IFunctionDescription
* pDesc
= getCurrentFunctionDescription();
472 BOOL bRef
= (pDesc
&& (pDesc
->getSuppressedArgumentCount() > 0)) && (pDoc
!=NULL
);
476 BOOL
ScFormulaDlg::IsDocAllowed(SfxObjectShell
* pDocSh
) const
478 // not allowed: different from this doc, and no name
479 // pDocSh is always a ScDocShell
480 if ( pDocSh
&& ((ScDocShell
*)pDocSh
)->GetDocument() != pDoc
&& !pDocSh
->HasName() )
483 return TRUE
; // everything else is allowed
486 void ScFormulaDlg::SetActive()
488 const IFunctionDescription
* pFunc
= getCurrentFunctionDescription();
489 if ( pFunc
&& pFunc
->getSuppressedArgumentCount() > 0 )
496 void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc
* pFuncDescP
)
498 if (pFuncDescP
&& pFuncDescP
->nFIndex
!=0)
500 ScModule
* pScMod
= SC_MOD();
501 pScMod
->InsertEntryToLRUList(pFuncDescP
->nFIndex
);
505 void ScFormulaDlg::doClose(BOOL
/*_bOk*/)
507 m_aHelper
.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
509 void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription
* _pDesc
)
511 const ScFuncDesc
* pDesc
= dynamic_cast<const ScFuncDesc
*>(_pDesc
);
514 void ScFormulaDlg::showReference(const String
& _sFormula
)
516 ShowReference(_sFormula
);
518 void ScFormulaDlg::ShowReference(const String
& _sFormula
)
520 m_aHelper
.ShowReference(_sFormula
);
522 void ScFormulaDlg::HideReference( BOOL bDoneRefMode
)
524 m_aHelper
.HideReference(bDoneRefMode
);
526 void ScFormulaDlg::ViewShellChanged( ScTabViewShell
* pScViewShell
)
528 m_aHelper
.ViewShellChanged( pScViewShell
);
530 void ScFormulaDlg::AddRefEntry( )
534 BOOL
ScFormulaDlg::IsTableLocked( ) const
536 // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
539 void ScFormulaDlg::ToggleCollapsed( formula::RefEdit
* pEdit
, formula::RefButton
* pButton
)
541 m_aHelper
.ToggleCollapsed(pEdit
,pButton
);
543 void ScFormulaDlg::ReleaseFocus( formula::RefEdit
* pEdit
, formula::RefButton
* pButton
)
545 m_aHelper
.ReleaseFocus(pEdit
,pButton
);
547 void ScFormulaDlg::dispatch(BOOL _bOK
,BOOL _bMartixChecked
)
549 SfxBoolItem
aRetItem( SID_DLG_RETOK
, _bOK
);
550 SfxBoolItem
aMatItem( SID_DLG_MATRIX
, _bMartixChecked
);
551 SfxStringItem
aStrItem( SCITEM_STRING
, getCurrentFormula() );
553 // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist,
554 // ist der String leer. Dann nicht die alte Formel loeschen.
555 if ( !aStrItem
.GetValue().Len() )
556 aRetItem
.SetValue( FALSE
); // FALSE = Cancel
558 m_aHelper
.SetDispatcherLock( FALSE
); // Modal-Modus ausschalten
562 GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION
,
563 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
564 &aRetItem
, &aStrItem
, &aMatItem
, 0L );
566 void ScFormulaDlg::setDispatcherLock( BOOL bLock
)
568 m_aHelper
.SetDispatcherLock( bLock
);
570 void ScFormulaDlg::setReferenceInput(const formula::FormEditData
* _pData
)
572 ScModule
* pScMod
= SC_MOD();
573 ScFormEditData
* pData
= const_cast<ScFormEditData
*>(dynamic_cast<const ScFormEditData
*>(_pData
));
574 pScMod
->SetRefInputHdl(pData
->GetInputHandler());
576 void ScFormulaDlg::deleteFormData()
578 ScModule
* pScMod
= SC_MOD();
579 pScMod
->ClearFormEditData(); // pData wird ungueltig!
581 void ScFormulaDlg::clear()
585 //Referenz Inputhandler zuruecksetzen
586 ScModule
* pScMod
= SC_MOD();
587 pScMod
->SetRefInputHdl(NULL
);
589 // Enable() der Eingabezeile erzwingen:
590 ScTabViewShell
* pScViewShell
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
592 pScViewShell
->UpdateInputHandler();
594 void ScFormulaDlg::switchBack()
596 ScModule
* pScMod
= SC_MOD();
597 // auf das Dokument zurueckschalten
598 // (noetig, weil ein fremdes oben sein kann - #34222#)
599 ScInputHandler
* pHdl
= pScMod
->GetInputHdl();
602 pHdl
->ViewShellGone(NULL
); // -> aktive View neu holen
603 pHdl
->ShowRefFrame();
606 // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput)
607 ScTabViewShell
* pScViewShell
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
610 ScViewData
* pVD
=pScViewShell
->GetViewData();
611 SCTAB nExecTab
= aCursorPos
.Tab();
612 if ( nExecTab
!= pVD
->GetTabNo() )
613 pScViewShell
->SetTabNo( nExecTab
);
615 SCROW nRow
=aCursorPos
.Row();
616 SCCOL nCol
=aCursorPos
.Col();
618 if(pVD
->GetCurX()!=nCol
|| pVD
->GetCurY()!=nRow
)
619 pScViewShell
->SetCursor(nCol
,nRow
);
622 formula::FormEditData
* ScFormulaDlg::getFormEditData() const
624 ScModule
* pScMod
= SC_MOD();
625 return pScMod
->GetFormEditData();
627 void ScFormulaDlg::setCurrentFormula(const String
& _sReplacement
)
629 ScModule
* pScMod
= SC_MOD();
630 pScMod
->InputReplaceSelection(_sReplacement
);
632 void ScFormulaDlg::setSelection(xub_StrLen _nStart
,xub_StrLen _nEnd
)
634 ScModule
* pScMod
= SC_MOD();
635 pScMod
->InputSetSelection( _nStart
, _nEnd
);
637 void ScFormulaDlg::getSelection(xub_StrLen
& _nStart
,xub_StrLen
& _nEnd
) const
639 ScModule
* pScMod
= SC_MOD();
640 pScMod
->InputGetSelection( _nStart
, _nEnd
);
642 String
ScFormulaDlg::getCurrentFormula() const
644 ScModule
* pScMod
= SC_MOD();
645 return pScMod
->InputGetFormulaStr();
647 formula::IFunctionManager
* ScFormulaDlg::getFunctionManager()
649 return ScGlobal::GetStarCalcFunctionMgr();
651 uno::Reference
< sheet::XFormulaParser
> ScFormulaDlg::getFormulaParser() const
655 uno::Reference
< sheet::XFormulaOpCodeMapper
> ScFormulaDlg::getFormulaOpCodeMapper() const
657 return m_xOpCodeMapper
;
660 table::CellAddress
ScFormulaDlg::getReferencePosition() const
662 return table::CellAddress(aCursorPos
.Tab(),aCursorPos
.Col(),aCursorPos
.Row());
665 ::std::auto_ptr
<formula::FormulaTokenArray
> ScFormulaDlg::convertToTokenArray(const uno::Sequence
< sheet::FormulaToken
>& _aTokenList
)
667 ::std::auto_ptr
<formula::FormulaTokenArray
> pArray(new ScTokenArray());
668 pArray
->Fill( _aTokenList
, pDoc
->GetExternalRefManager());