1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
23 #include <editeng/editeng.hxx>
24 #include <editeng/forbiddencharacterstable.hxx>
25 #include <osl/thread.h>
26 #include <svx/xtable.hxx>
27 #include <sfx2/linkmgr.hxx>
28 #include <svx/svdpool.hxx>
29 #include <svx/svdobj.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/objsh.hxx>
32 #include <sfx2/docfile.hxx>
33 #include <sfx2/printer.hxx>
34 #include <svl/zforlist.hxx>
35 #include <svl/zformat.hxx>
36 #include <vcl/virdev.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <svl/PasswordHelper.hxx>
39 #include <svl/sharedstringpool.hxx>
40 #include <tools/tenccvt.hxx>
41 #include <tools/urlobj.hxx>
43 #include <basic/basmgr.hxx>
45 #include "document.hxx"
48 #include "patattr.hxx"
49 #include "rangenam.hxx"
52 #include "docpool.hxx"
53 #include "stlpool.hxx"
54 #include "stlsheet.hxx"
55 #include "globstr.hrc"
56 #include "chartarr.hxx"
57 #include "chartlock.hxx"
58 #include "rechead.hxx"
61 #include "bcaslot.hxx"
62 #include "adiasync.hxx"
63 #include "addinlis.hxx"
64 #include "chartlis.hxx"
65 #include "markdata.hxx"
66 #include "conditio.hxx"
67 #include "colorscale.hxx"
68 #include "validat.hxx"
69 #include "progress.hxx"
70 #include "detdata.hxx"
72 #include "ddelink.hxx"
73 #include "chgtrack.hxx"
74 #include "chgviset.hxx"
75 #include "editutil.hxx"
77 #include "dpobject.hxx"
78 #include "scrdata.hxx"
79 #include "poolhelp.hxx"
80 #include "unoreflist.hxx"
81 #include "listenercalls.hxx"
82 #include "recursionhelper.hxx"
83 #include "lookupcache.hxx"
84 #include "externalrefmgr.hxx"
85 #include "appoptio.hxx"
87 #include "../../ui/inc/viewutil.hxx"
88 #include "tabprotection.hxx"
89 #include "formulaparserpool.hxx"
90 #include "clipparam.hxx"
91 #include "macromgr.hxx"
92 #include "formulacell.hxx"
93 #include "clipcontext.hxx"
94 #include "refupdatecontext.hxx"
95 #include "refreshtimerprotector.hxx"
96 #include "scopetools.hxx"
97 #include "formulagroup.hxx"
98 #include "documentlinkmgr.hxx"
99 #include "interpre.hxx"
100 #include <tokenstringcontext.hxx>
102 #include <listenercontext.hxx>
104 using namespace com::sun::star
;
106 // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
107 // dtor plus helpers are convenient.
108 struct ScLookupCacheMapImpl
110 ScLookupCacheMap aCacheMap
;
111 ~ScLookupCacheMapImpl()
119 ScLookupCacheMap aTmp
;
120 aCacheMap
.swap( aTmp
);
125 for (ScLookupCacheMap::iterator
it( aCacheMap
.begin()); it
!= aCacheMap
.end(); ++it
)
130 // STATIC DATA -----------------------------------------------------------
132 ScDocument::ScDocument( ScDocumentMode eMode
, SfxObjectShell
* pDocShell
) :
133 mpCellStringPool(new svl::SharedStringPool(ScGlobal::pCharClass
)),
134 mpFormulaGroupCxt(NULL
),
135 maCalcConfig( ScInterpreter::GetGlobalConfig()),
136 mpUndoManager( NULL
),
141 pVirtualDevice_100th_mm( NULL
),
143 pValidationList( NULL
),
144 pFormatExchangeList( NULL
),
146 pDPCollection( NULL
),
147 pFormulaTree( NULL
),
148 pEOFormulaTree( NULL
),
149 pFormulaTrack( NULL
),
150 pEOFormulaTrack( NULL
),
153 pChangeTrack( NULL
),
154 pUnoBroadcaster( NULL
),
155 pUnoListenerCalls( NULL
),
156 pUnoRefUndoList( NULL
),
157 pChangeViewSettings( NULL
),
158 pScriptTypeData( NULL
),
159 pCacheFieldEditEngine( NULL
),
160 pViewOptions( NULL
),
162 pExtDocOptions( NULL
),
163 pConsolidateDlgData( NULL
),
164 pRecursionHelper( NULL
),
165 pAutoNameCache( NULL
),
166 pLookupCacheMapImpl( NULL
),
167 pPreviewFont( NULL
),
168 pPreviewCellStyle( NULL
),
170 nRangeOverflowType( 0 ),
171 aCurTextWidthCalcPos(MAXCOL
,0,0),
173 nFormulaCodeInTree(0),
174 nXMLImportedFormulaCount( 0 ),
176 nMacroInterpretLevel(0),
177 nInterpreterTableOpLevel(0),
178 nSrcVer( SC_CURRENT_VERSION
),
179 nSrcMaxRow( MAXROW
),
180 nFormulaTrackCount(0),
181 bHardRecalcState(false),
183 eLinkMode(LM_UNKNOWN
),
184 bAutoCalc( eMode
== SCDOCMODE_DOCUMENT
),
185 bAutoCalcShellDisabled( false ),
186 bForcedFormulaPending( false ),
187 bCalculatingFormulaTree( false ),
188 bIsClip( eMode
== SCDOCMODE_CLIP
),
189 bIsUndo( eMode
== SCDOCMODE_UNDO
),
191 bIsEmbedded( false ),
192 bInsertingFromOtherDoc( false ),
193 bLoadingMedium( false ),
194 bImportingXML( false ),
195 bCalcingAfterLoad( false ),
196 bNoListening( false ),
198 bInLinkUpdate( false ),
199 bChartListenerCollectionNeedsUpdate( false ),
200 bHasForcedFormulas( false ),
201 bInDtorClear( false ),
202 bExpandRefs( false ),
203 bDetectiveDirty( false ),
204 nMacroCallMode( SC_MACROCALL_ALLOWED
),
205 bHasMacroFunc( false ),
207 nAsianCompression(SC_ASIANCOMPRESSION_INVALID
),
208 nAsianKerning(SC_ASIANKERNING_INVALID
),
209 bPastingDrawFromOtherDoc( false ),
210 nInDdeLinkUpdate( 0 ),
211 bInUnoBroadcast( false ),
212 bInUnoListenerCall( false ),
213 eGrammar( formula::FormulaGrammar::GRAM_NATIVE
),
214 bStyleSheetUsageInvalid( true ),
215 mbUndoEnabled( true ),
216 mbAdjustHeightEnabled( true ),
217 mbExecuteLinkEnabled( true ),
218 mbChangeReadOnlyEnabled( false ),
219 mbStreamValidLocked( false ),
220 mbUserInteractionEnabled(true),
221 mnNamedRangesLockCount(0),
222 mbUseEmbedFonts(false)
224 SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT
);
226 eSrcSet
= osl_getThreadTextEncoding();
228 if ( eMode
== SCDOCMODE_DOCUMENT
)
230 xPoolHelper
= new ScPoolHelper( this );
232 pBASM
= new ScBroadcastAreaSlotMachine( this );
233 pChartListenerCollection
= new ScChartListenerCollection( this );
234 pRefreshTimerControl
= new ScRefreshTimerControl
;
239 pChartListenerCollection
= NULL
;
240 pRefreshTimerControl
= NULL
;
242 pDBCollection
= new ScDBCollection(this);
243 pSelectionAttr
= NULL
;
244 pChartCollection
= new ScChartCollection
;
245 apTemporaryChartLock
.reset( new ScTemporaryChartLock(this) );
246 xColNameRanges
= new ScRangePairList
;
247 xRowNameRanges
= new ScRangePairList
;
249 // languages for a visible document are set by docshell later (from options)
250 SetLanguage( ScGlobal::eLnge
, ScGlobal::eLnge
, ScGlobal::eLnge
);
252 aTrackIdle
.SetIdleHdl( LINK( this, ScDocument
, TrackTimeHdl
) );
253 aTrackIdle
.SetPriority( SchedulerPriority::LOW
);
256 sfx2::LinkManager
* ScDocument::GetLinkManager()
258 return GetDocLinkManager().getLinkManager(true);
261 const sfx2::LinkManager
* ScDocument::GetLinkManager() const
263 return GetDocLinkManager().getExistingLinkManager();
266 sc::DocumentLinkManager
& ScDocument::GetDocLinkManager()
269 mpDocLinkMgr
.reset(new sc::DocumentLinkManager(*this, pShell
));
270 return *mpDocLinkMgr
;
273 const sc::DocumentLinkManager
& ScDocument::GetDocLinkManager() const
275 return const_cast<ScDocument
*>(this)->GetDocLinkManager();
278 void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram
)
281 eGram
== formula::FormulaGrammar::GRAM_ODFF
||
282 eGram
== formula::FormulaGrammar::GRAM_PODF
,
283 "ScDocument::SetStorageGrammar: wrong storage grammar");
285 eStorageGrammar
= eGram
;
287 // FIXME: the XML import shouldn't strip brackets, the compiler should
288 // digest them instead, which could also speedup reference recognition
291 eXmlImportGrammar
= formula::FormulaGrammar::mergeToGrammar( eGram
,
292 formula::FormulaGrammar::CONV_OOO
);
295 void ScDocument::SetDocVisible( bool bSet
)
297 // called from view ctor - only for a visible document,
298 // each new sheet's RTL flag is initialized from the locale
302 sal_uInt32
ScDocument::GetDocumentID() const
304 const ScDocument
* pThis
= this;
305 sal_uInt32 nCrc
= rtl_crc32( 0, &pThis
, sizeof(ScDocument
*) );
306 // the this pointer only might not be sufficient
307 nCrc
= rtl_crc32( nCrc
, &pShell
, sizeof(SfxObjectShell
*) );
311 void ScDocument::StartChangeTracking()
314 pChangeTrack
= new ScChangeTrack( this );
317 void ScDocument::EndChangeTracking()
323 void ScDocument::SetChangeTrack( ScChangeTrack
* pTrack
)
325 OSL_ENSURE( pTrack
->GetDocument() == this, "SetChangeTrack: different documents" );
326 if ( !pTrack
|| pTrack
== pChangeTrack
|| pTrack
->GetDocument() != this )
329 pChangeTrack
= pTrack
;
332 IMPL_LINK_NOARG_TYPED(ScDocument
, TrackTimeHdl
, Idle
*, void)
334 if ( ScDdeLink::IsInUpdate() ) // do not nest
336 aTrackIdle
.Start(); // try again later
338 else if (pShell
) // execute
341 pShell
->Broadcast( SfxSimpleHint( FID_DATACHANGED
) );
345 if (!pShell
->IsModified())
347 pShell
->SetModified( true );
348 SfxBindings
* pBindings
= GetViewBindings();
351 pBindings
->Invalidate( SID_SAVEDOC
);
352 pBindings
->Invalidate( SID_DOC_MODIFIED
);
358 void ScDocument::SetExpandRefs( bool bVal
)
363 void ScDocument::StartTrackTimer()
365 if (!aTrackIdle
.IsActive()) // do not postpone for forever
369 ScDocument::~ScDocument()
371 OSL_PRECOND( !bInLinkUpdate
, "bInLinkUpdate in dtor" );
375 // first of all disable all refresh timers by deleting the control
376 if ( pRefreshTimerControl
)
377 { // To be sure there isn't anything running do it with a protector,
378 // this ensures also that nothing needs the control anymore.
379 ScRefreshTimerProtector
aProt( GetRefreshTimerControlAddress() );
380 delete pRefreshTimerControl
, pRefreshTimerControl
= NULL
;
383 mxFormulaParserPool
.reset();
384 // Destroy the external ref mgr instance here because it has a timer
385 // which needs to be stopped before the app closes.
386 pExternalRefMgr
.reset();
388 ScAddInAsync::RemoveDocument( this );
389 ScAddInListener::RemoveDocument( this );
390 DELETEZ( pChartListenerCollection
); // before pBASM because of potential Listener!
391 DELETEZ( pLookupCacheMapImpl
); // before pBASM because of listeners
392 // destroy BroadcastAreas first to avoid un-needed Single-EndListenings of Formula-Cells
393 delete pBASM
; // BroadcastAreaSlotMachine
396 delete pUnoBroadcaster
; // broadcasted nochmal SFX_HINT_DYING
397 pUnoBroadcaster
= NULL
;
399 delete pUnoRefUndoList
;
400 delete pUnoListenerCalls
;
402 Clear( true ); // true = from destructor (needed for SdrModel::ClearModel)
406 for( ScValidationDataList::iterator it
= pValidationList
->begin(); it
!= pValidationList
->end(); ++it
)
408 pValidationList
->clear();
409 DELETEZ(pValidationList
);
412 delete pDBCollection
;
413 delete pSelectionAttr
;
414 apTemporaryChartLock
.reset();
415 delete pChartCollection
;
417 delete pFormatExchangeList
;
418 pPrinter
.disposeAndClear();
420 delete pConsolidateDlgData
;
422 delete pDetOpList
; // also deletes entries
426 delete pChangeViewSettings
; // and delete
427 pVirtualDevice_100th_mm
.disposeAndClear();
429 delete pDPCollection
;
431 // delete the EditEngine before destroying the xPoolHelper
432 delete pCacheFieldEditEngine
;
434 if ( xPoolHelper
.is() && !bIsClip
)
435 xPoolHelper
->SourceDocumentGone();
438 delete pScriptTypeData
;
439 delete pRecursionHelper
;
442 SAL_WARN_IF( pAutoNameCache
, "sc.core", "AutoNameCache still set in dtor" );
444 mpFormulaGroupCxt
.reset();
445 mpCellStringPool
.reset();
448 void ScDocument::InitClipPtrs( ScDocument
* pSourceDoc
)
450 OSL_ENSURE(bIsClip
, "InitClipPtrs and not bIsClip");
454 for(ScValidationDataList::iterator it
= pValidationList
->begin(); it
!= pValidationList
->end(); ++it
)
456 pValidationList
->clear();
457 DELETEZ(pValidationList
);
462 SharePooledResources(pSourceDoc
);
464 // conditional Formats / validations
465 // TODO: Copy Templates?
466 const ScValidationDataList
* pSourceValid
= pSourceDoc
->pValidationList
;
468 pValidationList
= new ScValidationDataList(this, *pSourceValid
);
470 // store Links in Stream
472 if (pSourceDoc
->GetDocLinkManager().hasDdeLinks())
474 pClipData
= new SvMemoryStream
;
475 pSourceDoc
->SaveDdeLinks(*pClipData
);
480 // Options pointers exist (ImplCreateOptions) for any document.
481 // Must be copied for correct results in OLE objects (#i42666#).
482 SetDocOptions( pSourceDoc
->GetDocOptions() );
483 SetViewOptions( pSourceDoc
->GetViewOptions() );
486 SvNumberFormatter
* ScDocument::GetFormatTable() const
488 return xPoolHelper
->GetFormTable();
491 SvNumberFormatter
* ScDocument::CreateFormatTable() const
493 return xPoolHelper
->CreateNumberFormatter();
496 SfxItemPool
* ScDocument::GetEditPool() const
498 return xPoolHelper
->GetEditPool();
501 SfxItemPool
* ScDocument::GetEnginePool() const
503 return xPoolHelper
->GetEnginePool();
506 ScFieldEditEngine
& ScDocument::GetEditEngine()
510 pEditEngine
= new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
511 pEditEngine
->SetUpdateMode( false );
512 pEditEngine
->EnableUndo( false );
513 pEditEngine
->SetRefMapMode( MAP_100TH_MM
);
514 ApplyAsianEditSettings( *pEditEngine
);
519 ScNoteEditEngine
& ScDocument::GetNoteEngine()
523 pNoteEngine
= new ScNoteEditEngine( GetEnginePool(), GetEditPool() );
524 pNoteEngine
->SetUpdateMode( false );
525 pNoteEngine
->EnableUndo( false );
526 pNoteEngine
->SetRefMapMode( MAP_100TH_MM
);
527 ApplyAsianEditSettings( *pNoteEngine
);
528 const SfxItemSet
& rItemSet
= GetDefPattern()->GetItemSet();
529 SfxItemSet
* pEEItemSet
= new SfxItemSet( pNoteEngine
->GetEmptyItemSet() );
530 ScPatternAttr::FillToEditItemSet( *pEEItemSet
, rItemSet
);
531 pNoteEngine
->SetDefaults( pEEItemSet
); // edit engine takes ownership
536 void ScDocument::ResetClip( ScDocument
* pSourceDoc
, const ScMarkData
* pMarks
)
540 InitClipPtrs(pSourceDoc
);
542 for (SCTAB i
= 0; i
< static_cast<SCTAB
>(pSourceDoc
->maTabs
.size()); i
++)
543 if (pSourceDoc
->maTabs
[i
])
544 if (!pMarks
|| pMarks
->GetTableSelect(i
))
547 pSourceDoc
->maTabs
[i
]->GetName(aString
);
548 if ( i
< static_cast<SCTAB
>(maTabs
.size()) )
550 maTabs
[i
] = new ScTable(this, i
, aString
);
555 if( i
> static_cast<SCTAB
>(maTabs
.size()) )
557 maTabs
.resize(i
, NULL
);
559 maTabs
.push_back(new ScTable(this, i
, aString
));
561 maTabs
[i
]->SetLayoutRTL( pSourceDoc
->maTabs
[i
]->IsLayoutRTL() );
566 OSL_FAIL("ResetClip");
570 void ScDocument::ResetClip( ScDocument
* pSourceDoc
, SCTAB nTab
)
574 InitClipPtrs(pSourceDoc
);
575 if (nTab
>= static_cast<SCTAB
>(maTabs
.size()))
577 maTabs
.resize(nTab
+1, NULL
);
579 maTabs
[nTab
] = new ScTable(this, nTab
,
581 if (nTab
< static_cast<SCTAB
>(pSourceDoc
->maTabs
.size()) && pSourceDoc
->maTabs
[nTab
])
582 maTabs
[nTab
]->SetLayoutRTL( pSourceDoc
->maTabs
[nTab
]->IsLayoutRTL() );
586 OSL_FAIL("ResetClip");
590 void ScDocument::EnsureTable( SCTAB nTab
)
592 bool bExtras
= !bIsUndo
; // Column-Widths, Row-Heights, Flags
593 if (static_cast<size_t>(nTab
) >= maTabs
.size())
594 maTabs
.resize(nTab
+1, NULL
);
597 maTabs
[nTab
] = new ScTable(this, nTab
, "temp", bExtras
, bExtras
);
600 ScRefCellValue
ScDocument::GetRefCellValue( const ScAddress
& rPos
)
602 if (!TableExists(rPos
.Tab()))
603 return ScRefCellValue(); // empty
605 return maTabs
[rPos
.Tab()]->GetRefCellValue(rPos
.Col(), rPos
.Row());
608 svl::SharedStringPool
& ScDocument::GetSharedStringPool()
610 return *mpCellStringPool
;
613 const svl::SharedStringPool
& ScDocument::GetSharedStringPool() const
615 return *mpCellStringPool
;
618 bool ScDocument::GetPrintArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
,
621 if (ValidTab(nTab
) && nTab
< static_cast<SCTAB
>(maTabs
.size()) && maTabs
[nTab
])
623 bool bAny
= maTabs
[nTab
]->GetPrintArea( rEndCol
, rEndRow
, bNotes
);
626 ScRange
aDrawRange(0,0,nTab
, MAXCOL
,MAXROW
,nTab
);
627 if (DrawGetPrintArea( aDrawRange
, true, true ))
629 if (aDrawRange
.aEnd
.Col()>rEndCol
) rEndCol
=aDrawRange
.aEnd
.Col();
630 if (aDrawRange
.aEnd
.Row()>rEndRow
) rEndRow
=aDrawRange
.aEnd
.Row();
642 bool ScDocument::GetPrintAreaHor( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
,
643 SCCOL
& rEndCol
, bool bNotes
) const
645 if (ValidTab(nTab
) && nTab
< static_cast<SCTAB
>(maTabs
.size()) && maTabs
[nTab
])
647 bool bAny
= maTabs
[nTab
]->GetPrintAreaHor( nStartRow
, nEndRow
, rEndCol
, bNotes
);
650 ScRange
aDrawRange(0,nStartRow
,nTab
, MAXCOL
,nEndRow
,nTab
);
651 if (DrawGetPrintArea( aDrawRange
, true, false ))
653 if (aDrawRange
.aEnd
.Col()>rEndCol
) rEndCol
=aDrawRange
.aEnd
.Col();
664 bool ScDocument::GetPrintAreaVer( SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
,
665 SCROW
& rEndRow
, bool bNotes
) const
667 if (ValidTab(nTab
) && nTab
< static_cast<SCTAB
>(maTabs
.size()) && maTabs
[nTab
])
669 bool bAny
= maTabs
[nTab
]->GetPrintAreaVer( nStartCol
, nEndCol
, rEndRow
, bNotes
);
672 ScRange
aDrawRange(nStartCol
,0,nTab
, nEndCol
,MAXROW
,nTab
);
673 if (DrawGetPrintArea( aDrawRange
, false, true ))
675 if (aDrawRange
.aEnd
.Row()>rEndRow
) rEndRow
=aDrawRange
.aEnd
.Row();
686 bool ScDocument::GetDataStart( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
) const
688 if (ValidTab(nTab
) && nTab
< static_cast<SCTAB
>(maTabs
.size()) && maTabs
[nTab
])
690 bool bAny
= maTabs
[nTab
]->GetDataStart( rStartCol
, rStartRow
);
693 ScRange
aDrawRange(0,0,nTab
, MAXCOL
,MAXROW
,nTab
);
694 if (DrawGetPrintArea( aDrawRange
, true, true ))
696 if (aDrawRange
.aStart
.Col()<rStartCol
) rStartCol
=aDrawRange
.aStart
.Col();
697 if (aDrawRange
.aStart
.Row()<rStartRow
) rStartRow
=aDrawRange
.aStart
.Row();
709 bool ScDocument::GetTiledRenderingArea(SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const
711 if (!GetPrintArea(nTab
, rEndCol
, rEndRow
, false))
714 // we need some reasonable minimal document size
724 bool ScDocument::MoveTab( SCTAB nOldPos
, SCTAB nNewPos
, ScProgress
* pProgress
)
726 if (nOldPos
== nNewPos
)
729 SCTAB nTabCount
= static_cast<SCTAB
>(maTabs
.size());
734 if (ValidTab(nOldPos
) && nOldPos
< nTabCount
)
738 sc::AutoCalcSwitch
aACSwitch(*this, false);
740 SetNoListening( true );
741 if (nNewPos
== SC_TAB_APPEND
|| nNewPos
>= nTabCount
)
742 nNewPos
= nTabCount
-1;
745 // TODO: combine with UpdateReference!
747 sc::RefUpdateMoveTabContext
aCxt( *this, nOldPos
, nNewPos
);
749 SCsTAB nDz
= ((SCsTAB
)nNewPos
) - (SCsTAB
)nOldPos
;
750 ScRange
aSourceRange( 0,0,nOldPos
, MAXCOL
,MAXROW
,nOldPos
);
752 pRangeName
->UpdateMoveTab(aCxt
);
754 pDBCollection
->UpdateMoveTab( nOldPos
, nNewPos
);
755 xColNameRanges
->UpdateReference( URM_REORDER
, this, aSourceRange
, 0,0,nDz
);
756 xRowNameRanges
->UpdateReference( URM_REORDER
, this, aSourceRange
, 0,0,nDz
);
758 pDPCollection
->UpdateReference( URM_REORDER
, aSourceRange
, 0,0,nDz
);
760 pDetOpList
->UpdateReference( this, URM_REORDER
, aSourceRange
, 0,0,nDz
);
761 UpdateChartRef( URM_REORDER
,
762 0,0,nOldPos
, MAXCOL
,MAXROW
,nOldPos
, 0,0,nDz
);
763 UpdateRefAreaLinks( URM_REORDER
, aSourceRange
, 0,0,nDz
);
764 if ( pValidationList
)
765 pValidationList
->UpdateMoveTab(aCxt
);
766 if ( pUnoBroadcaster
)
767 pUnoBroadcaster
->Broadcast( ScUpdateRefHint( URM_REORDER
,
768 aSourceRange
, 0,0,nDz
) );
770 ScTable
* pSaveTab
= maTabs
[nOldPos
];
771 maTabs
.erase(maTabs
.begin()+nOldPos
);
772 maTabs
.insert(maTabs
.begin()+nNewPos
, pSaveTab
);
773 TableContainer::iterator it
= maTabs
.begin();
774 for (SCTAB i
= 0; i
< nTabCount
; i
++)
776 maTabs
[i
]->UpdateMoveTab(aCxt
, i
, pProgress
);
778 for (; it
!= maTabs
.end(); ++it
)
780 (*it
)->UpdateCompile();
781 SetNoListening( false );
784 // sheet names of references may not be valid until sheet is moved
785 pChartListenerCollection
->UpdateScheduledSeriesRanges();
787 sc::SetFormulaDirtyContext aFormulaDirtyCxt
;
788 SetAllFormulasDirty(aFormulaDirtyCxt
);
791 DrawMovePage( static_cast<sal_uInt16
>(nOldPos
), static_cast<sal_uInt16
>(nNewPos
) );
799 bool ScDocument::CopyTab( SCTAB nOldPos
, SCTAB nNewPos
, const ScMarkData
* pOnlyMarked
)
801 if (SC_TAB_APPEND
== nNewPos
|| nNewPos
>= static_cast<SCTAB
>(maTabs
.size()))
802 nNewPos
= static_cast<SCTAB
>(maTabs
.size());
804 GetName(nOldPos
, aName
);
806 // check first if Prefix is valid; if not, then only avoid duplicates
807 bool bPrefix
= ValidTabName( aName
);
808 OSL_ENSURE(bPrefix
, "invalid table name");
811 CreateValidTabName(aName
);
815 bValid
= ValidNewTabName(aName
);
817 bValid
= !GetTable( aName
, nDummy
);
819 sc::AutoCalcSwitch
aACSwitch(*this, false);
820 sc::RefUpdateInsertTabContext
aCxt( *this, nNewPos
, 1);
821 sc::StartListeningContext
aSLCxt(*this);
825 if (nNewPos
>= static_cast<SCTAB
>(maTabs
.size()))
827 nNewPos
= static_cast<SCTAB
>(maTabs
.size());
828 maTabs
.push_back(new ScTable(this, nNewPos
, aName
));
832 if (ValidTab(nNewPos
) && (nNewPos
< static_cast<SCTAB
>(maTabs
.size())))
834 SetNoListening( true );
836 ScRange
aRange( 0,0,nNewPos
, MAXCOL
,MAXROW
,MAXTAB
);
837 xColNameRanges
->UpdateReference( URM_INSDEL
, this, aRange
, 0,0,1 );
838 xRowNameRanges
->UpdateReference( URM_INSDEL
, this, aRange
, 0,0,1 );
840 pRangeName
->UpdateInsertTab(aCxt
);
842 pDBCollection
->UpdateReference(
843 URM_INSDEL
, 0,0,nNewPos
, MAXCOL
,MAXROW
,MAXTAB
, 0,0,1 );
845 pDPCollection
->UpdateReference( URM_INSDEL
, aRange
, 0,0,1 );
847 pDetOpList
->UpdateReference( this, URM_INSDEL
, aRange
, 0,0,1 );
848 UpdateChartRef( URM_INSDEL
, 0,0,nNewPos
, MAXCOL
,MAXROW
,MAXTAB
, 0,0,1 );
849 UpdateRefAreaLinks( URM_INSDEL
, aRange
, 0,0,1 );
850 if ( pUnoBroadcaster
)
851 pUnoBroadcaster
->Broadcast( ScUpdateRefHint( URM_INSDEL
, aRange
, 0,0,1 ) );
854 for (TableContainer::iterator it
= maTabs
.begin(); it
!= maTabs
.end(); ++it
)
855 if (*it
&& it
!= (maTabs
.begin() + nOldPos
))
856 (*it
)->UpdateInsertTab(aCxt
);
857 maTabs
.push_back(NULL
);
858 for (i
= static_cast<SCTAB
>(maTabs
.size())-1; i
> nNewPos
; i
--)
859 maTabs
[i
] = maTabs
[i
- 1];
860 if (nNewPos
<= nOldPos
)
862 maTabs
[nNewPos
] = new ScTable(this, nNewPos
, aName
);
864 for (TableContainer::iterator it
= maTabs
.begin(); it
!= maTabs
.end(); ++it
)
865 if (*it
&& it
!= maTabs
.begin()+nOldPos
&& it
!= maTabs
.begin() + nNewPos
)
866 (*it
)->UpdateCompile();
867 SetNoListening( false );
868 for (TableContainer::iterator it
= maTabs
.begin(); it
!= maTabs
.end(); ++it
)
869 if (*it
&& it
!= maTabs
.begin()+nOldPos
&& it
!= maTabs
.begin()+nNewPos
)
870 (*it
)->StartListeners(aSLCxt
, true);
873 pValidationList
->UpdateInsertTab(aCxt
);
875 // sheet names of references may not be valid until sheet is copied
876 pChartListenerCollection
->UpdateScheduledSeriesRanges();
885 SetNoListening( true ); // noch nicht bei CopyToTable/Insert
886 sc::CopyToDocContext
aCopyDocCxt(*this);
887 maTabs
[nOldPos
]->CopyToTable(aCopyDocCxt
, 0, 0, MAXCOL
, MAXROW
, IDF_ALL
, (pOnlyMarked
!= NULL
),
888 maTabs
[nNewPos
], pOnlyMarked
);
889 maTabs
[nNewPos
]->SetTabBgColor(maTabs
[nOldPos
]->GetTabBgColor());
891 SCTAB nDz
= nNewPos
- nOldPos
;
892 sc::RefUpdateContext
aRefCxt(*this);
893 aRefCxt
.meMode
= URM_COPY
;
894 aRefCxt
.maRange
= ScRange(0, 0, nNewPos
, MAXCOL
, MAXROW
, nNewPos
);
895 aRefCxt
.mnTabDelta
= nDz
;
896 maTabs
[nNewPos
]->UpdateReference(aRefCxt
, NULL
);
898 maTabs
[nNewPos
]->UpdateInsertTabAbs(nNewPos
); // move all paragraphs up by one!!
899 maTabs
[nOldPos
]->UpdateInsertTab(aCxt
);
901 maTabs
[nOldPos
]->UpdateCompile();
902 maTabs
[nNewPos
]->UpdateCompile( true ); // maybe already compiled in Clone, but used names need recompilation
903 SetNoListening( false );
904 maTabs
[nOldPos
]->StartListeners(aSLCxt
, true);
905 maTabs
[nNewPos
]->StartListeners(aSLCxt
, true);
907 sc::SetFormulaDirtyContext aFormulaDirtyCxt
;
908 SetAllFormulasDirty(aFormulaDirtyCxt
);
911 DrawCopyPage( static_cast<sal_uInt16
>(nOldPos
), static_cast<sal_uInt16
>(nNewPos
) );
914 pDPCollection
->CopyToTab(nOldPos
, nNewPos
);
916 maTabs
[nNewPos
]->SetPageStyle( maTabs
[nOldPos
]->GetPageStyle() );
917 maTabs
[nNewPos
]->SetPendingRowHeights( maTabs
[nOldPos
]->IsPendingRowHeights() );
919 // Copy the custom print range if exists.
920 maTabs
[nNewPos
]->CopyPrintRange(*maTabs
[nOldPos
]);
922 // Copy the RTL settings
923 maTabs
[nNewPos
]->SetLayoutRTL(maTabs
[nOldPos
]->IsLayoutRTL());
924 maTabs
[nNewPos
]->SetLoadingRTL(maTabs
[nOldPos
]->IsLoadingRTL());
930 sal_uLong
ScDocument::TransferTab( ScDocument
* pSrcDoc
, SCTAB nSrcPos
,
931 SCTAB nDestPos
, bool bInsertNew
,
934 sal_uLong nRetVal
= 1; // 0 => error 1 = ok
938 if (pSrcDoc
->pShell
->GetMedium())
940 pSrcDoc
->maFileURL
= pSrcDoc
->pShell
->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI
);
941 // for unsaved files use the title name and adjust during save of file
942 if (pSrcDoc
->maFileURL
.isEmpty())
943 pSrcDoc
->maFileURL
= pSrcDoc
->pShell
->GetName();
947 pSrcDoc
->maFileURL
= pSrcDoc
->pShell
->GetName();
951 if (bInsertNew
) // re-insert
954 pSrcDoc
->GetName(nSrcPos
, aName
);
955 CreateValidTabName(aName
);
956 bValid
= InsertTab(nDestPos
, aName
);
958 // Copy the RTL settings
959 maTabs
[nDestPos
]->SetLayoutRTL(pSrcDoc
->maTabs
[nSrcPos
]->IsLayoutRTL());
960 maTabs
[nDestPos
]->SetLoadingRTL(pSrcDoc
->maTabs
[nSrcPos
]->IsLoadingRTL());
962 else // replace existing tables
964 if (ValidTab(nDestPos
) && nDestPos
< static_cast<SCTAB
>(maTabs
.size()) && maTabs
[nDestPos
])
966 maTabs
[nDestPos
]->DeleteArea( 0,0, MAXCOL
,MAXROW
, IDF_ALL
);
974 bool bOldAutoCalcSrc
= false;
975 bool bOldAutoCalc
= GetAutoCalc();
976 SetAutoCalc( false ); // avoid repeated calculations
977 SetNoListening( true );
980 bOldAutoCalcSrc
= pSrcDoc
->GetAutoCalc();
981 pSrcDoc
->SetAutoCalc( true ); // in case something needs calculation
985 NumFmtMergeHandler
aNumFmtMergeHdl(this, pSrcDoc
);
987 sc::CopyToDocContext
aCxt(*this);
988 nDestPos
= std::min(nDestPos
, (SCTAB
)(GetTableCount() - 1));
989 { // scope for bulk broadcast
990 ScBulkBroadcast
aBulkBroadcast( pBASM
);
991 pSrcDoc
->maTabs
[nSrcPos
]->CopyToTable(aCxt
, 0, 0, MAXCOL
, MAXROW
,
992 ( bResultsOnly
? IDF_ALL
& ~IDF_FORMULA
: IDF_ALL
),
993 false, maTabs
[nDestPos
] );
996 maTabs
[nDestPos
]->SetTabNo(nDestPos
);
997 maTabs
[nDestPos
]->SetTabBgColor(pSrcDoc
->maTabs
[nSrcPos
]->GetTabBgColor());
1001 sc::RefUpdateContext
aRefCxt(*this);
1002 aRefCxt
.meMode
= URM_COPY
;
1003 aRefCxt
.maRange
= ScRange(0, 0, nDestPos
, MAXCOL
, MAXROW
, nDestPos
);
1004 aRefCxt
.mnTabDelta
= nDestPos
- nSrcPos
;
1005 maTabs
[nDestPos
]->UpdateReference(aRefCxt
, NULL
);
1007 // Readjust self-contained absolute references to this sheet
1008 maTabs
[nDestPos
]->TestTabRefAbs(nSrcPos
);
1009 sc::CompileFormulaContext
aFormulaCxt(this);
1010 maTabs
[nDestPos
]->CompileAll(aFormulaCxt
);
1013 SetNoListening( false );
1014 if ( !bResultsOnly
)
1016 sc::StartListeningContext
aSLCxt(*this);
1017 maTabs
[nDestPos
]->StartListeners(aSLCxt
, true);
1019 SetDirty( ScRange( 0, 0, nDestPos
, MAXCOL
, MAXROW
, nDestPos
), false);
1022 pSrcDoc
->SetAutoCalc( bOldAutoCalcSrc
);
1023 SetAutoCalc( bOldAutoCalc
);
1028 TransferDrawPage( pSrcDoc
, nSrcPos
, nDestPos
);
1030 maTabs
[nDestPos
]->SetPendingRowHeights( pSrcDoc
->maTabs
[nSrcPos
]->IsPendingRowHeights() );
1034 bool bVbaEnabled
= IsInVBAMode();
1038 SfxObjectShell
* pSrcShell
= pSrcDoc
->GetDocumentShell();
1041 OUString
aLibName("Standard");
1042 const BasicManager
*pBasicManager
= pSrcShell
->GetBasicManager();
1043 if (pBasicManager
&& !pBasicManager
->GetName().isEmpty())
1045 aLibName
= pSrcShell
->GetBasicManager()->GetName();
1049 uno::Reference
< script::XLibraryContainer
> xLibContainer
= pSrcShell
->GetBasicContainer();
1050 uno::Reference
< container::XNameContainer
> xLib
;
1051 if( xLibContainer
.is() )
1053 uno::Any aLibAny
= xLibContainer
->getByName(aLibName
);
1059 OUString sSrcCodeName
;
1060 pSrcDoc
->GetCodeName( nSrcPos
, sSrcCodeName
);
1061 OUString sRTLSource
;
1062 xLib
->getByName( sSrcCodeName
) >>= sRTLSource
;
1063 sSource
= sRTLSource
;
1065 VBA_InsertModule( *this, nDestPos
, sCodeName
, sSource
);
1072 void ScDocument::SetError( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const sal_uInt16 nError
)
1074 if (ValidTab(nTab
) && nTab
< static_cast<SCTAB
>(maTabs
.size()))
1076 maTabs
[nTab
]->SetError( nCol
, nRow
, nError
);
1079 void ScDocument::SetFormula(
1080 const ScAddress
& rPos
, const ScTokenArray
& rArray
, formula::FormulaGrammar::Grammar eGram
)
1082 if (!TableExists(rPos
.Tab()))
1085 maTabs
[rPos
.Tab()]->SetFormula(rPos
.Col(), rPos
.Row(), rArray
, eGram
);
1088 void ScDocument::SetFormula(
1089 const ScAddress
& rPos
, const OUString
& rFormula
, formula::FormulaGrammar::Grammar eGram
)
1091 if (!TableExists(rPos
.Tab()))
1094 maTabs
[rPos
.Tab()]->SetFormula(rPos
.Col(), rPos
.Row(), rFormula
, eGram
);
1097 ScFormulaCell
* ScDocument::SetFormulaCell( const ScAddress
& rPos
, ScFormulaCell
* pCell
)
1099 if (!TableExists(rPos
.Tab()))
1105 return maTabs
[rPos
.Tab()]->SetFormulaCell(rPos
.Col(), rPos
.Row(), pCell
);
1108 bool ScDocument::SetFormulaCells( const ScAddress
& rPos
, std::vector
<ScFormulaCell
*>& rCells
)
1113 ScTable
* pTab
= FetchTable(rPos
.Tab());
1117 return pTab
->SetFormulaCells(rPos
.Col(), rPos
.Row(), rCells
);
1120 void ScDocument::SetConsolidateDlgData( const ScConsolidateParam
* pData
)
1122 delete pConsolidateDlgData
;
1125 pConsolidateDlgData
= new ScConsolidateParam( *pData
);
1127 pConsolidateDlgData
= NULL
;
1130 void ScDocument::SetChangeViewSettings(const ScChangeViewSettings
& rNew
)
1132 if (pChangeViewSettings
==NULL
)
1133 pChangeViewSettings
= new ScChangeViewSettings
;
1135 OSL_ENSURE( pChangeViewSettings
, "Oops. No ChangeViewSettings :-( by!" );
1137 *pChangeViewSettings
=rNew
;
1140 ScFieldEditEngine
* ScDocument::CreateFieldEditEngine()
1142 ScFieldEditEngine
* pNewEditEngine
= NULL
;
1143 if (!pCacheFieldEditEngine
)
1145 pNewEditEngine
= new ScFieldEditEngine(
1146 this, GetEnginePool(), GetEditPool(), false);
1150 if ( !bImportingXML
)
1152 // #i66209# previous use might not have restored update mode,
1153 // ensure same state as for a new EditEngine (UpdateMode = true)
1154 if ( !pCacheFieldEditEngine
->GetUpdateMode() )
1155 pCacheFieldEditEngine
->SetUpdateMode(true);
1158 pNewEditEngine
= pCacheFieldEditEngine
;
1159 pCacheFieldEditEngine
= NULL
;
1161 return pNewEditEngine
;
1164 void ScDocument::DisposeFieldEditEngine(ScFieldEditEngine
*& rpEditEngine
)
1166 if (!pCacheFieldEditEngine
&& rpEditEngine
)
1168 pCacheFieldEditEngine
= rpEditEngine
;
1169 pCacheFieldEditEngine
->Clear();
1172 delete rpEditEngine
;
1173 rpEditEngine
= NULL
;
1176 ScRecursionHelper
* ScDocument::CreateRecursionHelperInstance()
1178 return new ScRecursionHelper
;
1181 ScLookupCache
& ScDocument::GetLookupCache( const ScRange
& rRange
)
1183 ScLookupCache
* pCache
= 0;
1184 if (!pLookupCacheMapImpl
)
1185 pLookupCacheMapImpl
= new ScLookupCacheMapImpl
;
1186 ScLookupCacheMap::iterator
it( pLookupCacheMapImpl
->aCacheMap
.find( rRange
));
1187 if (it
== pLookupCacheMapImpl
->aCacheMap
.end())
1189 pCache
= new ScLookupCache( this, rRange
);
1190 AddLookupCache( *pCache
);
1193 pCache
= (*it
).second
;
1197 void ScDocument::AddLookupCache( ScLookupCache
& rCache
)
1199 if (!pLookupCacheMapImpl
->aCacheMap
.insert( ::std::pair
< const ScRange
,
1200 ScLookupCache
*>( rCache
.getRange(), &rCache
)).second
)
1202 OSL_FAIL( "ScDocument::AddLookupCache: couldn't add to hash map");
1205 StartListeningArea( rCache
.getRange(), false, &rCache
);
1208 void ScDocument::RemoveLookupCache( ScLookupCache
& rCache
)
1210 ScLookupCacheMap::iterator
it( pLookupCacheMapImpl
->aCacheMap
.find(
1211 rCache
.getRange()));
1212 if (it
== pLookupCacheMapImpl
->aCacheMap
.end())
1214 OSL_FAIL( "ScDocument::RemoveLookupCache: range not found in hash map");
1218 ScLookupCache
* pCache
= (*it
).second
;
1219 pLookupCacheMapImpl
->aCacheMap
.erase( it
);
1220 EndListeningArea( pCache
->getRange(), false, &rCache
);
1224 void ScDocument::ClearLookupCaches()
1226 if( pLookupCacheMapImpl
)
1227 pLookupCacheMapImpl
->clear();
1230 bool ScDocument::IsCellInChangeTrack(const ScAddress
&cell
,Color
*pColCellBoder
)
1232 ScChangeTrack
* pTrack
= GetChangeTrack();
1233 ScChangeViewSettings
* pSettings
= GetChangeViewSettings();
1234 if ( !pTrack
|| !pTrack
->GetFirst() || !pSettings
|| !pSettings
->ShowChanges() )
1235 return false; // missing or turned-off
1236 ScActionColorChanger
aColorChanger(*pTrack
);
1237 // Clipping happens from outside
1238 //! TODO: without Clipping; only paint affected cells ??!??!?
1239 const ScChangeAction
* pAction
= pTrack
->GetFirst();
1242 ScChangeActionType eType
;
1243 if ( pAction
->IsVisible() )
1245 eType
= pAction
->GetType();
1246 const ScBigRange
& rBig
= pAction
->GetBigRange();
1247 if ( rBig
.aStart
.Tab() == cell
.Tab())
1249 ScRange aRange
= rBig
.MakeRange();
1250 if ( eType
== SC_CAT_DELETE_ROWS
)
1251 aRange
.aEnd
.SetRow( aRange
.aStart
.Row() );
1252 else if ( eType
== SC_CAT_DELETE_COLS
)
1253 aRange
.aEnd
.SetCol( aRange
.aStart
.Col() );
1254 if (ScViewUtil::IsActionShown( *pAction
, *pSettings
, *this ) )
1256 if (aRange
.In(cell
))
1258 if (pColCellBoder
!= NULL
)
1260 aColorChanger
.Update( *pAction
);
1261 Color
aColor( aColorChanger
.GetColor() );
1262 *pColCellBoder
= aColor
;
1268 if ( eType
== SC_CAT_MOVE
&&
1269 static_cast<const ScChangeActionMove
*>(pAction
)->
1270 GetFromRange().aStart
.Tab() == cell
.Col() )
1272 ScRange aRange
= static_cast<const ScChangeActionMove
*>(pAction
)->
1273 GetFromRange().MakeRange();
1274 if (ScViewUtil::IsActionShown( *pAction
, *pSettings
, *this ) )
1276 if (aRange
.In(cell
))
1278 if (pColCellBoder
!= NULL
)
1280 aColorChanger
.Update( *pAction
);
1281 Color
aColor( aColorChanger
.GetColor() );
1282 *pColCellBoder
= aColor
;
1289 pAction
= pAction
->GetNext();
1294 void ScDocument::GetCellChangeTrackNote( const ScAddress
&aCellPos
, OUString
&aTrackText
,bool &bLeftEdge
)
1298 ScChangeTrack
* pTrack
= GetChangeTrack();
1299 ScChangeViewSettings
* pSettings
= GetChangeViewSettings();
1300 if ( pTrack
&& pTrack
->GetFirst() && pSettings
&& pSettings
->ShowChanges())
1302 const ScChangeAction
* pFound
= NULL
;
1303 const ScChangeAction
* pFoundContent
= NULL
;
1304 const ScChangeAction
* pFoundMove
= NULL
;
1306 const ScChangeAction
* pAction
= pTrack
->GetFirst();
1309 if ( pAction
->IsVisible() &&
1310 ScViewUtil::IsActionShown( *pAction
, *pSettings
, *this ) )
1312 ScChangeActionType eType
= pAction
->GetType();
1313 const ScBigRange
& rBig
= pAction
->GetBigRange();
1314 if ( rBig
.aStart
.Tab() == aCellPos
.Tab())
1316 ScRange aRange
= rBig
.MakeRange();
1317 if ( eType
== SC_CAT_DELETE_ROWS
)
1318 aRange
.aEnd
.SetRow( aRange
.aStart
.Row() );
1319 else if ( eType
== SC_CAT_DELETE_COLS
)
1320 aRange
.aEnd
.SetCol( aRange
.aStart
.Col() );
1321 if ( aRange
.In( aCellPos
) )
1323 pFound
= pAction
; // the last wins
1326 case SC_CAT_CONTENT
:
1327 pFoundContent
= pAction
;
1330 pFoundMove
= pAction
;
1338 if ( eType
== SC_CAT_MOVE
)
1341 static_cast<const ScChangeActionMove
*>(pAction
)->
1342 GetFromRange().MakeRange();
1343 if ( aRange
.In( aCellPos
) )
1350 pAction
= pAction
->GetNext();
1354 if ( pFoundContent
&& pFound
->GetType() != SC_CAT_CONTENT
)
1355 pFound
= pFoundContent
; // Content wins
1356 if ( pFoundMove
&& pFound
->GetType() != SC_CAT_MOVE
&&
1357 pFoundMove
->GetActionNumber() >
1358 pFound
->GetActionNumber() )
1359 pFound
= pFoundMove
; // Move wins
1360 // for deleted columns: arrow on left side of row
1361 if ( pFound
->GetType() == SC_CAT_DELETE_COLS
)
1363 DateTime aDT
= pFound
->GetDateTime();
1364 aTrackText
= pFound
->GetUser();
1366 aTrackText
+= ScGlobal::pLocaleData
->getDate(aDT
);
1368 aTrackText
+= ScGlobal::pLocaleData
->getTime(aDT
);
1369 aTrackText
+= ":\n";
1370 OUString aComStr
= pFound
->GetComment();
1371 if(!aComStr
.isEmpty())
1373 aTrackText
+= aComStr
;
1374 aTrackText
+= "\n( ";
1376 pFound
->GetDescription( aTrackText
, this );
1377 if (!aComStr
.isEmpty())
1385 void ScDocument::SetPreviewFont( SfxItemSet
* pFont
)
1387 delete pPreviewFont
;
1388 pPreviewFont
= pFont
;
1391 void ScDocument::SetPreviewSelection( ScMarkData
& rSel
)
1393 maPreviewSelection
= rSel
;
1396 SfxItemSet
* ScDocument::GetPreviewFont( SCCOL nCol
, SCROW nRow
, SCTAB nTab
)
1398 SfxItemSet
* pRet
= NULL
;
1401 ScMarkData aSel
= GetPreviewSelection();
1402 if ( aSel
.IsCellMarked( nCol
, nRow
) && aSel
.GetFirstSelected() == nTab
)
1403 pRet
= pPreviewFont
;
1408 ScStyleSheet
* ScDocument::GetPreviewCellStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
)
1410 ScStyleSheet
* pRet
= NULL
;
1411 ScMarkData aSel
= GetPreviewSelection();
1412 if ( pPreviewCellStyle
&& aSel
.IsCellMarked( nCol
, nRow
) && aSel
.GetFirstSelected() == nTab
)
1413 pRet
= pPreviewCellStyle
;
1416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */