Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "scitems.hxx"
21 : #include <editeng/eeitem.hxx>
22 :
23 : #include <sot/exchange.hxx>
24 : #include <editeng/autokernitem.hxx>
25 : #include <editeng/fontitem.hxx>
26 : #include <editeng/forbiddencharacterstable.hxx>
27 : #include <editeng/langitem.hxx>
28 : #include <osl/thread.h>
29 : #include <svx/svdetc.hxx>
30 : #include <svx/svditer.hxx>
31 : #include <svx/svdocapt.hxx>
32 : #include <svx/svdograf.hxx>
33 : #include <svx/svdoole2.hxx>
34 : #include <svx/svdouno.hxx>
35 : #include <svx/svdpage.hxx>
36 : #include <svx/svdundo.hxx>
37 : #include <svx/xtable.hxx>
38 : #include <sfx2/objsh.hxx>
39 : #include <sfx2/printer.hxx>
40 : #include <unotools/saveopt.hxx>
41 : #include <unotools/pathoptions.hxx>
42 :
43 : #include "document.hxx"
44 : #include "docoptio.hxx"
45 : #include "table.hxx"
46 : #include "drwlayer.hxx"
47 : #include "markdata.hxx"
48 : #include "patattr.hxx"
49 : #include "rechead.hxx"
50 : #include "poolhelp.hxx"
51 : #include "docpool.hxx"
52 : #include "detfunc.hxx"
53 : #include "editutil.hxx"
54 : #include "postit.hxx"
55 : #include "charthelper.hxx"
56 : #include "interpre.hxx"
57 : #include <documentlinkmgr.hxx>
58 :
59 : using namespace ::com::sun::star;
60 :
61 36 : SfxBroadcaster* ScDocument::GetDrawBroadcaster()
62 : {
63 36 : return pDrawLayer;
64 : }
65 :
66 173 : void ScDocument::BeginDrawUndo()
67 : {
68 173 : if (pDrawLayer)
69 131 : pDrawLayer->BeginCalcUndo(false);
70 173 : }
71 :
72 0 : rtl::Reference<XColorList> ScDocument::GetColorList()
73 : {
74 0 : if (pDrawLayer)
75 0 : return pDrawLayer->GetColorList();
76 : else
77 : {
78 0 : if (!pColorList.is())
79 0 : pColorList = XColorList::CreateStdColorList();
80 0 : return pColorList;
81 : }
82 : }
83 :
84 13 : void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
85 : {
86 13 : if (pDrawLayer && pSrcDoc->pDrawLayer)
87 : {
88 10 : SdrPage* pOldPage = pSrcDoc->pDrawLayer->GetPage(static_cast<sal_uInt16>(nSrcPos));
89 10 : SdrPage* pNewPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nDestPos));
90 :
91 10 : if (pOldPage && pNewPage)
92 : {
93 10 : SdrObjListIter aIter( *pOldPage, IM_FLAT );
94 10 : SdrObject* pOldObject = aIter.Next();
95 20 : while (pOldObject)
96 : {
97 : // #116235#
98 0 : SdrObject* pNewObject = pOldObject->Clone();
99 : // SdrObject* pNewObject = pOldObject->Clone( pNewPage, pDrawLayer );
100 0 : pNewObject->SetModel(pDrawLayer);
101 0 : pNewObject->SetPage(pNewPage);
102 :
103 0 : pNewObject->NbcMove(Size(0,0));
104 0 : pNewPage->InsertObject( pNewObject );
105 :
106 0 : if (pDrawLayer->IsRecording())
107 0 : pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
108 :
109 0 : pOldObject = aIter.Next();
110 10 : }
111 : }
112 : }
113 :
114 : // make sure the data references of charts are adapted
115 : // (this must be after InsertObject!)
116 13 : ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pSrcDoc, this, nSrcPos, nDestPos );
117 13 : ScChartHelper::UpdateChartsOnDestinationPage(this, nDestPos);
118 13 : }
119 :
120 3704 : void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
121 : {
122 3704 : if (pDocShell && !pShell)
123 0 : pShell = pDocShell;
124 :
125 3704 : if (!pDrawLayer)
126 : {
127 549 : OUString aName;
128 549 : if ( pShell && !pShell->IsLoading() ) // don't call GetTitle while loading
129 234 : aName = pShell->GetTitle();
130 549 : pDrawLayer = new ScDrawLayer( this, aName );
131 :
132 549 : sfx2::LinkManager* pMgr = GetDocLinkManager().getLinkManager(bAutoCalc);
133 549 : if (pMgr)
134 548 : pDrawLayer->SetLinkManager(pMgr);
135 :
136 : //UUUU set DrawingLayer's SfxItemPool at Calc's SfxItemPool as
137 : // secondary pool to support DrawingLayer FillStyle ranges (and similar)
138 : // in SfxItemSets using the Calc SfxItemPool. This is e.g. needed when
139 : // the PageStyle using SvxBrushItem is visualized and will be potentially
140 : // used more intense in the future
141 549 : if (xPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy for SharePooledResources called
142 : {
143 548 : ScDocumentPool* pLocalPool = xPoolHelper->GetDocPool();
144 :
145 548 : if (pLocalPool)
146 : {
147 : OSL_ENSURE(!pLocalPool->GetSecondaryPool(), "OOps, already a secondary pool set where the DrawingLayer ItemPool is to be placed (!)");
148 548 : pLocalPool->SetSecondaryPool(&pDrawLayer->GetItemPool());
149 : }
150 : }
151 :
152 : // Drawing pages are accessed by table number, so they must also be present
153 : // for preceding table numbers, even if the tables aren't allocated
154 : // (important for clipboard documents).
155 :
156 549 : SCTAB nDrawPages = 0;
157 : SCTAB nTab;
158 1261 : for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
159 712 : if (maTabs[nTab])
160 712 : nDrawPages = nTab + 1; // needed number of pages
161 :
162 1261 : for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
163 : {
164 712 : pDrawLayer->ScAddPage( nTab ); // always add page, with or without the table
165 712 : if (maTabs[nTab])
166 : {
167 712 : OUString aTabName;
168 712 : maTabs[nTab]->GetName(aTabName);
169 712 : pDrawLayer->ScRenamePage( nTab, aTabName );
170 :
171 712 : maTabs[nTab]->SetDrawPageSize(false,false); // set the right size immediately
172 : }
173 : }
174 :
175 549 : pDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() );
176 :
177 549 : UpdateDrawPrinter();
178 :
179 : // set draw defaults directly
180 549 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
181 549 : rDrawPool.SetPoolDefaultItem( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
182 :
183 549 : UpdateDrawLanguages();
184 549 : if (bImportingXML)
185 84 : pDrawLayer->EnableAdjust(false);
186 :
187 549 : pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
188 549 : pDrawLayer->SetCharCompressType( GetAsianCompression() );
189 549 : pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
190 : }
191 3704 : }
192 :
193 4000 : void ScDocument::UpdateDrawLanguages()
194 : {
195 4000 : if (pDrawLayer)
196 : {
197 624 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
198 624 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eLanguage, EE_CHAR_LANGUAGE ) );
199 624 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCjkLanguage, EE_CHAR_LANGUAGE_CJK ) );
200 624 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCtlLanguage, EE_CHAR_LANGUAGE_CTL ) );
201 : }
202 4000 : }
203 :
204 840 : void ScDocument::UpdateDrawPrinter()
205 : {
206 840 : if (pDrawLayer)
207 : {
208 : // use the printer even if IsValid is false
209 : // Application::GetDefaultDevice causes trouble with changing MapModes
210 575 : pDrawLayer->SetRefDevice(GetRefDevice());
211 : }
212 840 : }
213 :
214 3130 : void ScDocument::SetDrawPageSize(SCTAB nTab)
215 : {
216 3130 : if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
217 3130 : return;
218 :
219 3130 : maTabs[nTab]->SetDrawPageSize();
220 : }
221 :
222 412 : bool ScDocument::IsChart( const SdrObject* pObject )
223 : {
224 : // #109985#
225 : // IsChart() implementation moved to svx drawinglayer
226 412 : if(pObject && OBJ_OLE2 == pObject->GetObjIdentifier())
227 : {
228 412 : return static_cast<const SdrOle2Obj*>(pObject)->IsChart();
229 : }
230 :
231 0 : return false;
232 : }
233 :
234 0 : IMPL_LINK( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex )
235 : {
236 0 : return reinterpret_cast<sal_IntPtr>( &((GetColorList()->GetColor(*pColorIndex))->GetColor()) );
237 : }
238 :
239 2287 : void ScDocument::DeleteDrawLayer()
240 : {
241 : //UUUU remove DrawingLayer's SfxItemPool from Calc's SfxItemPool where
242 : // it is registered as secondary pool
243 2287 : if (xPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy for SharePooledResources called
244 : {
245 1294 : ScDocumentPool* pLocalPool = xPoolHelper->GetDocPool();
246 :
247 1294 : if(pLocalPool && pLocalPool->GetSecondaryPool())
248 : {
249 540 : pLocalPool->SetSecondaryPool(0);
250 : }
251 : }
252 2287 : delete pDrawLayer;
253 2287 : pDrawLayer = 0;
254 2287 : }
255 :
256 3632 : bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const
257 : {
258 3632 : return pDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer );
259 : }
260 :
261 1 : void ScDocument::DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
262 : {
263 1 : pDrawLayer->ScMovePage(nOldPos,nNewPos);
264 1 : }
265 :
266 2 : void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
267 : {
268 : // page is already created in ScTable ctor
269 2 : pDrawLayer->ScCopyPage( nOldPos, nNewPos );
270 2 : }
271 :
272 14 : void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
273 : const ScMarkData& rMark )
274 : {
275 14 : if (!pDrawLayer)
276 27 : return;
277 :
278 1 : SCTAB nTabCount = GetTableCount();
279 1 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
280 2 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
281 1 : if (maTabs[*itr])
282 1 : pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
283 : }
284 :
285 1 : void ScDocument::DeleteObjectsInSelection( const ScMarkData& rMark )
286 : {
287 1 : if (!pDrawLayer)
288 2 : return;
289 :
290 0 : pDrawLayer->DeleteObjectsInSelection( rMark );
291 : }
292 :
293 28 : bool ScDocument::HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark )
294 : {
295 : // pTabMark is used only for selected tables. If pTabMark is 0, all tables of rRange are used.
296 :
297 28 : if (!pDrawLayer)
298 15 : return false;
299 :
300 13 : SCTAB nStartTab = 0;
301 13 : SCTAB nEndTab = static_cast<SCTAB>(maTabs.size());
302 13 : if ( !pTabMark )
303 : {
304 13 : nStartTab = rRange.aStart.Tab();
305 13 : nEndTab = rRange.aEnd.Tab();
306 : }
307 :
308 26 : for (SCTAB nTab = nStartTab; nTab <= nEndTab; nTab++)
309 : {
310 13 : if ( !pTabMark || pTabMark->GetTableSelect(nTab) )
311 : {
312 13 : Rectangle aMMRect = GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(),
313 26 : rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
314 :
315 13 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
316 : OSL_ENSURE(pPage,"Page ?");
317 13 : if (pPage)
318 : {
319 13 : SdrObjListIter aIter( *pPage, IM_FLAT );
320 13 : SdrObject* pObject = aIter.Next();
321 39 : while (pObject)
322 : {
323 13 : if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
324 0 : aMMRect.IsInside( pObject->GetCurrentBoundRect() ) )
325 0 : return true;
326 :
327 13 : pObject = aIter.Next();
328 13 : }
329 : }
330 : }
331 : }
332 :
333 13 : return false;
334 : }
335 :
336 0 : void ScDocument::StartAnimations( SCTAB nTab, vcl::Window* pWin )
337 : {
338 0 : if (!pDrawLayer)
339 0 : return;
340 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
341 : OSL_ENSURE(pPage,"Page ?");
342 0 : if (!pPage)
343 0 : return;
344 :
345 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
346 0 : SdrObject* pObject = aIter.Next();
347 0 : while (pObject)
348 : {
349 0 : if (pObject->ISA(SdrGrafObj))
350 : {
351 0 : SdrGrafObj* pGrafObj = static_cast<SdrGrafObj*>(pObject);
352 0 : if ( pGrafObj->IsAnimated() )
353 : {
354 0 : const Rectangle& rRect = pGrafObj->GetCurrentBoundRect();
355 0 : pGrafObj->StartAnimation( pWin, rRect.TopLeft(), rRect.GetSize() );
356 : }
357 : }
358 0 : pObject = aIter.Next();
359 0 : }
360 : }
361 :
362 2964 : bool ScDocument::HasBackgroundDraw( SCTAB nTab, const Rectangle& rMMRect ) const
363 : {
364 : // Are there objects in the background layer who are (partly) affected by rMMRect
365 : // (for Drawing optimization, no deletion in front of the background
366 2964 : if (!pDrawLayer)
367 0 : return false;
368 2964 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
369 : OSL_ENSURE(pPage,"Page ?");
370 2964 : if (!pPage)
371 0 : return false;
372 :
373 2964 : bool bFound = false;
374 :
375 2964 : SdrObjListIter aIter( *pPage, IM_FLAT );
376 2964 : SdrObject* pObject = aIter.Next();
377 6543 : while (pObject && !bFound)
378 : {
379 615 : if ( pObject->GetLayer() == SC_LAYER_BACK && pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
380 0 : bFound = true;
381 615 : pObject = aIter.Next();
382 : }
383 :
384 2964 : return bFound;
385 : }
386 :
387 1 : bool ScDocument::HasAnyDraw( SCTAB nTab, const Rectangle& rMMRect ) const
388 : {
389 : // Are there any objects at all who are (partly) affected by rMMRect?
390 : // (To detect blank pages when printing)
391 1 : if (!pDrawLayer)
392 1 : return false;
393 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
394 : OSL_ENSURE(pPage,"Page ?");
395 0 : if (!pPage)
396 0 : return false;
397 :
398 0 : bool bFound = false;
399 :
400 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
401 0 : SdrObject* pObject = aIter.Next();
402 0 : while (pObject && !bFound)
403 : {
404 0 : if ( pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
405 0 : bFound = true;
406 0 : pObject = aIter.Next();
407 : }
408 :
409 0 : return bFound;
410 : }
411 :
412 85 : void ScDocument::EnsureGraphicNames()
413 : {
414 85 : if (pDrawLayer)
415 85 : pDrawLayer->EnsureGraphicNames();
416 85 : }
417 :
418 0 : SdrObject* ScDocument::GetObjectAtPoint( SCTAB nTab, const Point& rPos )
419 : {
420 : // for Drag&Drop on draw object
421 0 : SdrObject* pFound = NULL;
422 0 : if (pDrawLayer && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
423 : {
424 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
425 : OSL_ENSURE(pPage,"Page ?");
426 0 : if (pPage)
427 : {
428 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
429 0 : SdrObject* pObject = aIter.Next();
430 0 : while (pObject)
431 : {
432 0 : if ( pObject->GetCurrentBoundRect().IsInside(rPos) )
433 : {
434 : // Intern is of no interest
435 : // Only object form background layer, when no object form another layer is found
436 0 : SdrLayerID nLayer = pObject->GetLayer();
437 0 : if ( (nLayer != SC_LAYER_INTERN) && (nLayer != SC_LAYER_HIDDEN) )
438 : {
439 0 : if ( nLayer != SC_LAYER_BACK ||
440 0 : !pFound || pFound->GetLayer() == SC_LAYER_BACK )
441 : {
442 0 : pFound = pObject;
443 : }
444 : }
445 : }
446 : // Continue search -> take last (on top) found object
447 0 : pObject = aIter.Next();
448 0 : }
449 : }
450 : }
451 0 : return pFound;
452 : }
453 :
454 120 : bool ScDocument::IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
455 : SCCOL nEndCol, SCROW nEndRow, bool bLeftIsEmpty,
456 : ScRange* pLastRange, Rectangle* pLastMM ) const
457 : {
458 120 : if (!IsBlockEmpty( nTab, nStartCol, nStartRow, nEndCol, nEndRow ))
459 118 : return false;
460 :
461 2 : if (HasAttrib(ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), HASATTR_LINES))
462 : // We want to print sheets with borders even if there is no cell content.
463 1 : return false;
464 :
465 1 : Rectangle aMMRect;
466 1 : if ( pLastRange && pLastMM && nTab == pLastRange->aStart.Tab() &&
467 1 : nStartRow == pLastRange->aStart.Row() && nEndRow == pLastRange->aEnd.Row() )
468 : {
469 : // keep vertical part of aMMRect, only update horizontal position
470 0 : aMMRect = *pLastMM;
471 :
472 0 : long nLeft = 0;
473 : SCCOL i;
474 0 : for (i=0; i<nStartCol; i++)
475 0 : nLeft += GetColWidth(i,nTab);
476 0 : long nRight = nLeft;
477 0 : for (i=nStartCol; i<=nEndCol; i++)
478 0 : nRight += GetColWidth(i,nTab);
479 :
480 0 : aMMRect.Left() = (long)(nLeft * HMM_PER_TWIPS);
481 0 : aMMRect.Right() = (long)(nRight * HMM_PER_TWIPS);
482 : }
483 : else
484 1 : aMMRect = GetMMRect( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
485 :
486 1 : if ( pLastRange && pLastMM )
487 : {
488 0 : *pLastRange = ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
489 0 : *pLastMM = aMMRect;
490 : }
491 :
492 1 : if ( HasAnyDraw( nTab, aMMRect ))
493 0 : return false;
494 :
495 1 : if ( nStartCol > 0 && !bLeftIsEmpty )
496 : {
497 : // similar to in ScPrintFunc::AdjustPrintArea
498 : // ExtendPrintArea starting only from the start column of the print area
499 :
500 0 : SCCOL nExtendCol = nStartCol - 1;
501 0 : SCROW nTmpRow = nEndRow;
502 :
503 : // ExtendMerge() is non-const, but called without refresh. GetPrinter()
504 : // might create and assign a printer.
505 0 : ScDocument* pThis = const_cast<ScDocument*>(this);
506 :
507 : pThis->ExtendMerge( 0,nStartRow, nExtendCol,nTmpRow, nTab,
508 0 : false ); // no Refresh, incl. Attrs
509 :
510 0 : OutputDevice* pDev = pThis->GetPrinter();
511 0 : pDev->SetMapMode( MAP_PIXEL ); // Important for GetNeededSize
512 0 : ExtendPrintArea( pDev, nTab, 0, nStartRow, nExtendCol, nEndRow );
513 0 : if ( nExtendCol >= nStartCol )
514 0 : return false;
515 : }
516 :
517 1 : return true;
518 : }
519 :
520 3287 : void ScDocument::Clear( bool bFromDestructor )
521 : {
522 3287 : TableContainer::iterator it = maTabs.begin();
523 5592 : for (;it != maTabs.end(); ++it)
524 2305 : delete *it;
525 3287 : maTabs.clear();
526 3287 : delete pSelectionAttr;
527 3287 : pSelectionAttr = NULL;
528 :
529 3287 : if (pDrawLayer)
530 : {
531 540 : pDrawLayer->ClearModel( bFromDestructor );
532 : }
533 3287 : }
534 :
535 2338 : bool ScDocument::HasDetectiveObjects(SCTAB nTab) const
536 : {
537 : // looks for detective objects, annotations don't count
538 : // (used to adjust scale so detective objects hit their cells better)
539 :
540 2338 : bool bFound = false;
541 :
542 2338 : if (pDrawLayer)
543 : {
544 1912 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
545 : OSL_ENSURE(pPage,"Page ?");
546 1912 : if (pPage)
547 : {
548 1912 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
549 1912 : SdrObject* pObject = aIter.Next();
550 4590 : while (pObject && !bFound)
551 : {
552 : // anything on the internal layer except captions (annotations)
553 766 : if ( (pObject->GetLayer() == SC_LAYER_INTERN) && !ScDrawLayer::IsNoteCaption( pObject ) )
554 0 : bFound = true;
555 :
556 766 : pObject = aIter.Next();
557 1912 : }
558 : }
559 : }
560 :
561 2338 : return bFound;
562 : }
563 :
564 85 : void ScDocument::UpdateFontCharSet()
565 : {
566 : // In old versions (until 4.0 without SP), when switching between systems,
567 : // the Font attribute was not adjusted.
568 : // This has to be redone for Documents until SP2:
569 : // Everything that is not SYMBOL is set to system CharSet.
570 : // CharSet should be correct for new documents (version SC_FONTCHARSET)
571 :
572 85 : bool bUpdateOld = ( nSrcVer < SC_FONTCHARSET );
573 :
574 85 : rtl_TextEncoding eSysSet = osl_getThreadTextEncoding();
575 85 : if ( eSrcSet != eSysSet || bUpdateOld )
576 : {
577 : sal_uInt32 nCount,i;
578 : SvxFontItem* pItem;
579 :
580 84 : ScDocumentPool* pPool = xPoolHelper->GetDocPool();
581 84 : nCount = pPool->GetItemCount2(ATTR_FONT);
582 190 : for (i=0; i<nCount; i++)
583 : {
584 106 : pItem = const_cast<SvxFontItem*>(static_cast<const SvxFontItem*>(pPool->GetItem2(ATTR_FONT, i)));
585 196 : if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
586 0 : ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
587 90 : pItem->SetCharSet(eSysSet);
588 : }
589 :
590 84 : if ( pDrawLayer )
591 : {
592 84 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
593 84 : nCount = rDrawPool.GetItemCount2(EE_CHAR_FONTINFO);
594 88 : for (i=0; i<nCount; i++)
595 : {
596 4 : pItem = const_cast<SvxFontItem*>(static_cast<const SvxFontItem*>(rDrawPool.GetItem2(EE_CHAR_FONTINFO, i)));
597 4 : if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
598 0 : ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
599 0 : pItem->SetCharSet( eSysSet );
600 : }
601 : }
602 : }
603 85 : }
604 :
605 1272 : void ScDocument::SetLoadingMedium( bool bVal )
606 : {
607 1272 : bLoadingMedium = bVal;
608 1272 : TableContainer::iterator it = maTabs.begin();
609 2919 : for (; it != maTabs.end(); ++it)
610 : {
611 1647 : if (!*it)
612 1272 : return;
613 :
614 1647 : (*it)->SetLoadingMedium(bVal);
615 : }
616 : }
617 :
618 398 : void ScDocument::SetImportingXML( bool bVal )
619 : {
620 398 : bImportingXML = bVal;
621 398 : if (pDrawLayer)
622 144 : pDrawLayer->EnableAdjust(!bImportingXML);
623 :
624 398 : if ( !bVal )
625 : {
626 : // #i57869# after loading, do the real RTL mirroring for the sheets that have the LoadingRTL flag set
627 :
628 532 : for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++ )
629 333 : if ( maTabs[nTab]->IsLoadingRTL() )
630 : {
631 0 : maTabs[nTab]->SetLoadingRTL( false );
632 0 : SetLayoutRTL( nTab, true ); // includes mirroring; bImportingXML must be cleared first
633 : }
634 : }
635 :
636 398 : SetLoadingMedium(bVal);
637 398 : }
638 :
639 2527 : rtl::Reference<SvxForbiddenCharactersTable> ScDocument::GetForbiddenCharacters()
640 : {
641 2527 : return xForbiddenCharacters;
642 : }
643 :
644 56 : void ScDocument::SetForbiddenCharacters(const rtl::Reference<SvxForbiddenCharactersTable>& rNew)
645 : {
646 56 : xForbiddenCharacters = rNew;
647 56 : if ( pEditEngine )
648 5 : EditEngine::SetForbiddenCharsTable( xForbiddenCharacters );
649 56 : if ( pDrawLayer )
650 30 : pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
651 56 : }
652 :
653 1250 : bool ScDocument::IsValidAsianCompression() const
654 : {
655 1250 : return ( nAsianCompression != SC_ASIANCOMPRESSION_INVALID );
656 : }
657 :
658 2340 : sal_uInt8 ScDocument::GetAsianCompression() const
659 : {
660 2340 : if ( nAsianCompression == SC_ASIANCOMPRESSION_INVALID )
661 19 : return 0;
662 : else
663 2321 : return nAsianCompression;
664 : }
665 :
666 612 : void ScDocument::SetAsianCompression(sal_uInt8 nNew)
667 : {
668 612 : nAsianCompression = nNew;
669 612 : if ( pEditEngine )
670 0 : pEditEngine->SetAsianCompressionMode( nAsianCompression );
671 612 : if ( pDrawLayer )
672 2 : pDrawLayer->SetCharCompressType( nAsianCompression );
673 612 : }
674 :
675 1250 : bool ScDocument::IsValidAsianKerning() const
676 : {
677 1250 : return ( nAsianKerning != SC_ASIANKERNING_INVALID );
678 : }
679 :
680 2340 : bool ScDocument::GetAsianKerning() const
681 : {
682 2340 : if ( nAsianKerning == SC_ASIANKERNING_INVALID )
683 19 : return false;
684 : else
685 2321 : return static_cast<bool>(nAsianKerning);
686 : }
687 :
688 612 : void ScDocument::SetAsianKerning(bool bNew)
689 : {
690 612 : nAsianKerning = (sal_uInt8)bNew;
691 612 : if ( pEditEngine )
692 0 : pEditEngine->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
693 612 : if ( pDrawLayer )
694 2 : pDrawLayer->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
695 612 : }
696 :
697 1757 : void ScDocument::ApplyAsianEditSettings( ScEditEngineDefaulter& rEngine )
698 : {
699 1757 : EditEngine::SetForbiddenCharsTable( xForbiddenCharacters );
700 1757 : rEngine.SetAsianCompressionMode( GetAsianCompression() );
701 1757 : rEngine.SetKernAsianPunctuation( GetAsianKerning() );
702 1913 : }
703 :
704 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|