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 : #include <stdio.h>
61 :
62 36 : SfxBroadcaster* ScDocument::GetDrawBroadcaster()
63 : {
64 36 : return pDrawLayer;
65 : }
66 :
67 141 : void ScDocument::BeginDrawUndo()
68 : {
69 141 : if (pDrawLayer)
70 129 : pDrawLayer->BeginCalcUndo(false);
71 141 : }
72 :
73 0 : rtl::Reference<XColorList> ScDocument::GetColorList()
74 : {
75 0 : if (pDrawLayer)
76 0 : return pDrawLayer->GetColorList();
77 : else
78 : {
79 0 : if (!pColorList.is())
80 0 : pColorList = XColorList::CreateStdColorList();
81 0 : return pColorList;
82 : }
83 : }
84 :
85 3 : void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
86 : {
87 3 : if (pDrawLayer && pSrcDoc->pDrawLayer)
88 : {
89 1 : SdrPage* pOldPage = pSrcDoc->pDrawLayer->GetPage(static_cast<sal_uInt16>(nSrcPos));
90 1 : SdrPage* pNewPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nDestPos));
91 :
92 1 : if (pOldPage && pNewPage)
93 : {
94 1 : SdrObjListIter aIter( *pOldPage, IM_FLAT );
95 1 : SdrObject* pOldObject = aIter.Next();
96 2 : while (pOldObject)
97 : {
98 : // #116235#
99 0 : SdrObject* pNewObject = pOldObject->Clone();
100 : // SdrObject* pNewObject = pOldObject->Clone( pNewPage, pDrawLayer );
101 0 : pNewObject->SetModel(pDrawLayer);
102 0 : pNewObject->SetPage(pNewPage);
103 :
104 0 : pNewObject->NbcMove(Size(0,0));
105 0 : pNewPage->InsertObject( pNewObject );
106 :
107 0 : if (pDrawLayer->IsRecording())
108 0 : pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
109 :
110 0 : pOldObject = aIter.Next();
111 1 : }
112 : }
113 : }
114 :
115 : // make sure the data references of charts are adapted
116 : // (this must be after InsertObject!)
117 3 : ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pSrcDoc, this, nSrcPos, nDestPos );
118 3 : ScChartHelper::UpdateChartsOnDestinationPage(this, nDestPos);
119 3 : }
120 :
121 2023 : void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
122 : {
123 2023 : if (pDocShell && !pShell)
124 0 : pShell = pDocShell;
125 :
126 2023 : if (!pDrawLayer)
127 : {
128 333 : OUString aName;
129 333 : if ( pShell && !pShell->IsLoading() ) // don't call GetTitle while loading
130 178 : aName = pShell->GetTitle();
131 333 : pDrawLayer = new ScDrawLayer( this, aName );
132 :
133 333 : sfx2::LinkManager* pMgr = GetDocLinkManager().getLinkManager(bAutoCalc);
134 333 : if (pMgr)
135 332 : pDrawLayer->SetLinkManager(pMgr);
136 :
137 : // Drawing pages are accessed by table number, so they must also be present
138 : // for preceding table numbers, even if the tables aren't allocated
139 : // (important for clipboard documents).
140 :
141 333 : SCTAB nDrawPages = 0;
142 : SCTAB nTab;
143 728 : for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
144 395 : if (maTabs[nTab])
145 395 : nDrawPages = nTab + 1; // needed number of pages
146 :
147 728 : for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
148 : {
149 395 : pDrawLayer->ScAddPage( nTab ); // always add page, with or without the table
150 395 : if (maTabs[nTab])
151 : {
152 395 : OUString aTabName;
153 395 : maTabs[nTab]->GetName(aTabName);
154 395 : pDrawLayer->ScRenamePage( nTab, aTabName );
155 :
156 395 : maTabs[nTab]->SetDrawPageSize(false,false); // set the right size immediately
157 : }
158 : }
159 :
160 333 : pDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() );
161 :
162 333 : UpdateDrawPrinter();
163 :
164 : // set draw defaults directly
165 333 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
166 333 : rDrawPool.SetPoolDefaultItem( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
167 :
168 333 : UpdateDrawLanguages();
169 333 : if (bImportingXML)
170 47 : pDrawLayer->EnableAdjust(false);
171 :
172 333 : pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
173 333 : pDrawLayer->SetCharCompressType( GetAsianCompression() );
174 333 : pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
175 : }
176 2023 : }
177 :
178 2958 : void ScDocument::UpdateDrawLanguages()
179 : {
180 2958 : if (pDrawLayer)
181 : {
182 393 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
183 393 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eLanguage, EE_CHAR_LANGUAGE ) );
184 393 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCjkLanguage, EE_CHAR_LANGUAGE_CJK ) );
185 393 : rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCtlLanguage, EE_CHAR_LANGUAGE_CTL ) );
186 : }
187 2958 : }
188 :
189 541 : void ScDocument::UpdateDrawPrinter()
190 : {
191 541 : if (pDrawLayer)
192 : {
193 : // use the printer even if IsValid is false
194 : // Application::GetDefaultDevice causes trouble with changing MapModes
195 353 : pDrawLayer->SetRefDevice(GetRefDevice());
196 : }
197 541 : }
198 :
199 1114 : void ScDocument::SetDrawPageSize(SCTAB nTab)
200 : {
201 1114 : if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
202 1114 : return;
203 :
204 1114 : maTabs[nTab]->SetDrawPageSize();
205 : }
206 :
207 123 : bool ScDocument::IsChart( const SdrObject* pObject )
208 : {
209 : // #109985#
210 : // IsChart() implementation moved to svx drawinglayer
211 123 : if(pObject && OBJ_OLE2 == pObject->GetObjIdentifier())
212 : {
213 123 : return ((SdrOle2Obj*)pObject)->IsChart();
214 : }
215 :
216 0 : return false;
217 : }
218 :
219 0 : IMPL_LINK_INLINE_START( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex )
220 : {
221 0 : return (sal_IntPtr) &((GetColorList()->GetColor(*pColorIndex))->GetColor());
222 : }
223 0 : IMPL_LINK_INLINE_END( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex )
224 :
225 1710 : void ScDocument::DeleteDrawLayer()
226 : {
227 1710 : delete pDrawLayer;
228 1710 : }
229 :
230 1982 : bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const
231 : {
232 1982 : return pDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer );
233 : }
234 :
235 1 : void ScDocument::DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
236 : {
237 1 : pDrawLayer->ScMovePage(nOldPos,nNewPos);
238 1 : }
239 :
240 2 : void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
241 : {
242 : // angelegt wird die Page schon im ScTable ctor
243 2 : pDrawLayer->ScCopyPage( nOldPos, nNewPos );
244 2 : }
245 :
246 9 : void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
247 : const ScMarkData& rMark )
248 : {
249 9 : if (!pDrawLayer)
250 17 : return;
251 :
252 1 : SCTAB nTabCount = GetTableCount();
253 1 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
254 2 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
255 1 : if (maTabs[*itr])
256 1 : pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
257 : }
258 :
259 1 : void ScDocument::DeleteObjectsInSelection( const ScMarkData& rMark )
260 : {
261 1 : if (!pDrawLayer)
262 2 : return;
263 :
264 0 : pDrawLayer->DeleteObjectsInSelection( rMark );
265 : }
266 :
267 21 : bool ScDocument::HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark )
268 : {
269 : // pTabMark is used only for selected tables. If pTabMark is 0, all tables of rRange are used.
270 :
271 21 : if (!pDrawLayer)
272 8 : return false;
273 :
274 13 : SCTAB nStartTab = 0;
275 13 : SCTAB nEndTab = static_cast<SCTAB>(maTabs.size());
276 13 : if ( !pTabMark )
277 : {
278 13 : nStartTab = rRange.aStart.Tab();
279 13 : nEndTab = rRange.aEnd.Tab();
280 : }
281 :
282 26 : for (SCTAB nTab = nStartTab; nTab <= nEndTab; nTab++)
283 : {
284 13 : if ( !pTabMark || pTabMark->GetTableSelect(nTab) )
285 : {
286 13 : Rectangle aMMRect = GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(),
287 26 : rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
288 :
289 13 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
290 : OSL_ENSURE(pPage,"Page ?");
291 13 : if (pPage)
292 : {
293 13 : SdrObjListIter aIter( *pPage, IM_FLAT );
294 13 : SdrObject* pObject = aIter.Next();
295 39 : while (pObject)
296 : {
297 13 : if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
298 0 : aMMRect.IsInside( pObject->GetCurrentBoundRect() ) )
299 0 : return true;
300 :
301 13 : pObject = aIter.Next();
302 13 : }
303 : }
304 : }
305 : }
306 :
307 13 : return false;
308 : }
309 :
310 :
311 0 : void ScDocument::StartAnimations( SCTAB nTab, Window* pWin )
312 : {
313 0 : if (!pDrawLayer)
314 0 : return;
315 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
316 : OSL_ENSURE(pPage,"Page ?");
317 0 : if (!pPage)
318 0 : return;
319 :
320 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
321 0 : SdrObject* pObject = aIter.Next();
322 0 : while (pObject)
323 : {
324 0 : if (pObject->ISA(SdrGrafObj))
325 : {
326 0 : SdrGrafObj* pGrafObj = (SdrGrafObj*)pObject;
327 0 : if ( pGrafObj->IsAnimated() )
328 : {
329 0 : const Rectangle& rRect = pGrafObj->GetCurrentBoundRect();
330 0 : pGrafObj->StartAnimation( pWin, rRect.TopLeft(), rRect.GetSize() );
331 : }
332 : }
333 0 : pObject = aIter.Next();
334 0 : }
335 : }
336 :
337 :
338 1579 : bool ScDocument::HasBackgroundDraw( SCTAB nTab, const Rectangle& rMMRect ) const
339 : {
340 : // Gibt es Objekte auf dem Hintergrund-Layer, die (teilweise) von rMMRect
341 : // betroffen sind?
342 : // (fuer Drawing-Optimierung, vor dem Hintergrund braucht dann nicht geloescht
343 : // zu werden)
344 :
345 1579 : if (!pDrawLayer)
346 0 : return false;
347 1579 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
348 : OSL_ENSURE(pPage,"Page ?");
349 1579 : if (!pPage)
350 0 : return false;
351 :
352 1579 : bool bFound = false;
353 :
354 1579 : SdrObjListIter aIter( *pPage, IM_FLAT );
355 1579 : SdrObject* pObject = aIter.Next();
356 3590 : while (pObject && !bFound)
357 : {
358 432 : if ( pObject->GetLayer() == SC_LAYER_BACK && pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
359 0 : bFound = true;
360 432 : pObject = aIter.Next();
361 : }
362 :
363 1579 : return bFound;
364 : }
365 :
366 1 : bool ScDocument::HasAnyDraw( SCTAB nTab, const Rectangle& rMMRect ) const
367 : {
368 : // Gibt es ueberhaupt Objekte, die (teilweise) von rMMRect
369 : // betroffen sind?
370 : // (um leere Seiten beim Drucken zu erkennen)
371 :
372 1 : if (!pDrawLayer)
373 1 : return false;
374 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
375 : OSL_ENSURE(pPage,"Page ?");
376 0 : if (!pPage)
377 0 : return false;
378 :
379 0 : bool bFound = false;
380 :
381 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
382 0 : SdrObject* pObject = aIter.Next();
383 0 : while (pObject && !bFound)
384 : {
385 0 : if ( pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
386 0 : bFound = true;
387 0 : pObject = aIter.Next();
388 : }
389 :
390 0 : return bFound;
391 : }
392 :
393 63 : void ScDocument::EnsureGraphicNames()
394 : {
395 63 : if (pDrawLayer)
396 63 : pDrawLayer->EnsureGraphicNames();
397 63 : }
398 :
399 0 : SdrObject* ScDocument::GetObjectAtPoint( SCTAB nTab, const Point& rPos )
400 : {
401 : // fuer Drag&Drop auf Zeichenobjekt
402 :
403 0 : SdrObject* pFound = NULL;
404 0 : if (pDrawLayer && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
405 : {
406 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
407 : OSL_ENSURE(pPage,"Page ?");
408 0 : if (pPage)
409 : {
410 0 : SdrObjListIter aIter( *pPage, IM_FLAT );
411 0 : SdrObject* pObject = aIter.Next();
412 0 : while (pObject)
413 : {
414 0 : if ( pObject->GetCurrentBoundRect().IsInside(rPos) )
415 : {
416 : // Intern interessiert gar nicht
417 : // Objekt vom Back-Layer nur, wenn kein Objekt von anderem Layer getroffen
418 :
419 0 : SdrLayerID nLayer = pObject->GetLayer();
420 0 : if ( (nLayer != SC_LAYER_INTERN) && (nLayer != SC_LAYER_HIDDEN) )
421 : {
422 0 : if ( nLayer != SC_LAYER_BACK ||
423 0 : !pFound || pFound->GetLayer() == SC_LAYER_BACK )
424 : {
425 0 : pFound = pObject;
426 : }
427 : }
428 : }
429 : // weitersuchen -> letztes (oberstes) getroffenes Objekt nehmen
430 :
431 0 : pObject = aIter.Next();
432 0 : }
433 : }
434 : }
435 0 : return pFound;
436 : }
437 :
438 142 : bool ScDocument::IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
439 : SCCOL nEndCol, SCROW nEndRow, bool bLeftIsEmpty,
440 : ScRange* pLastRange, Rectangle* pLastMM ) const
441 : {
442 142 : if (!IsBlockEmpty( nTab, nStartCol, nStartRow, nEndCol, nEndRow ))
443 140 : return false;
444 :
445 2 : if (HasAttrib(ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), HASATTR_LINES))
446 : // We want to print sheets with borders even if there is no cell content.
447 1 : return false;
448 :
449 1 : Rectangle aMMRect;
450 1 : if ( pLastRange && pLastMM && nTab == pLastRange->aStart.Tab() &&
451 1 : nStartRow == pLastRange->aStart.Row() && nEndRow == pLastRange->aEnd.Row() )
452 : {
453 : // keep vertical part of aMMRect, only update horizontal position
454 0 : aMMRect = *pLastMM;
455 :
456 0 : long nLeft = 0;
457 : SCCOL i;
458 0 : for (i=0; i<nStartCol; i++)
459 0 : nLeft += GetColWidth(i,nTab);
460 0 : long nRight = nLeft;
461 0 : for (i=nStartCol; i<=nEndCol; i++)
462 0 : nRight += GetColWidth(i,nTab);
463 :
464 0 : aMMRect.Left() = (long)(nLeft * HMM_PER_TWIPS);
465 0 : aMMRect.Right() = (long)(nRight * HMM_PER_TWIPS);
466 : }
467 : else
468 1 : aMMRect = GetMMRect( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
469 :
470 1 : if ( pLastRange && pLastMM )
471 : {
472 0 : *pLastRange = ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
473 0 : *pLastMM = aMMRect;
474 : }
475 :
476 1 : if ( HasAnyDraw( nTab, aMMRect ))
477 0 : return false;
478 :
479 1 : if ( nStartCol > 0 && !bLeftIsEmpty )
480 : {
481 : // aehnlich wie in ScPrintFunc::AdjustPrintArea
482 : //! ExtendPrintArea erst ab Start-Spalte des Druckbereichs
483 :
484 0 : SCCOL nExtendCol = nStartCol - 1;
485 0 : SCROW nTmpRow = nEndRow;
486 :
487 : // ExtendMerge() is non-const, but called without refresh. GetPrinter()
488 : // might create and assign a printer.
489 0 : ScDocument* pThis = const_cast<ScDocument*>(this);
490 :
491 : pThis->ExtendMerge( 0,nStartRow, nExtendCol,nTmpRow, nTab,
492 0 : false ); // kein Refresh, incl. Attrs
493 :
494 0 : OutputDevice* pDev = pThis->GetPrinter();
495 0 : pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize
496 0 : ExtendPrintArea( pDev, nTab, 0, nStartRow, nExtendCol, nEndRow );
497 0 : if ( nExtendCol >= nStartCol )
498 0 : return false;
499 : }
500 :
501 1 : return true;
502 : }
503 :
504 2640 : void ScDocument::Clear( bool bFromDestructor )
505 : {
506 2640 : TableContainer::iterator it = maTabs.begin();
507 4309 : for (;it != maTabs.end(); ++it)
508 1669 : delete *it;
509 2640 : maTabs.clear();
510 2640 : delete pSelectionAttr;
511 2640 : pSelectionAttr = NULL;
512 :
513 2640 : if (pDrawLayer)
514 : {
515 322 : pDrawLayer->ClearModel( bFromDestructor );
516 : }
517 2640 : }
518 :
519 1384 : bool ScDocument::HasDetectiveObjects(SCTAB nTab) const
520 : {
521 : // looks for detective objects, annotations don't count
522 : // (used to adjust scale so detective objects hit their cells better)
523 :
524 1384 : bool bFound = false;
525 :
526 1384 : if (pDrawLayer)
527 : {
528 1060 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
529 : OSL_ENSURE(pPage,"Page ?");
530 1060 : if (pPage)
531 : {
532 1060 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
533 1060 : SdrObject* pObject = aIter.Next();
534 2527 : while (pObject && !bFound)
535 : {
536 : // anything on the internal layer except captions (annotations)
537 407 : if ( (pObject->GetLayer() == SC_LAYER_INTERN) && !ScDrawLayer::IsNoteCaption( pObject ) )
538 0 : bFound = true;
539 :
540 407 : pObject = aIter.Next();
541 1060 : }
542 : }
543 : }
544 :
545 1384 : return bFound;
546 : }
547 :
548 63 : void ScDocument::UpdateFontCharSet()
549 : {
550 : // In alten Versionen (bis incl. 4.0 ohne SP) wurden beim Austausch zwischen
551 : // Systemen die CharSets in den Font-Attributen nicht angepasst.
552 : // Das muss fuer Dokumente bis incl SP2 nun nachgeholt werden:
553 : // Alles, was nicht SYMBOL ist, wird auf den System-CharSet umgesetzt.
554 : // Bei neuen Dokumenten (Version SC_FONTCHARSET) sollte der CharSet stimmen.
555 :
556 63 : bool bUpdateOld = ( nSrcVer < SC_FONTCHARSET );
557 :
558 63 : rtl_TextEncoding eSysSet = osl_getThreadTextEncoding();
559 63 : if ( eSrcSet != eSysSet || bUpdateOld )
560 : {
561 : sal_uInt32 nCount,i;
562 : SvxFontItem* pItem;
563 :
564 62 : ScDocumentPool* pPool = xPoolHelper->GetDocPool();
565 62 : nCount = pPool->GetItemCount2(ATTR_FONT);
566 143 : for (i=0; i<nCount; i++)
567 : {
568 81 : pItem = (SvxFontItem*)pPool->GetItem2(ATTR_FONT, i);
569 151 : if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
570 0 : ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
571 70 : pItem->SetCharSet(eSysSet);
572 : }
573 :
574 62 : if ( pDrawLayer )
575 : {
576 62 : SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
577 62 : nCount = rDrawPool.GetItemCount2(EE_CHAR_FONTINFO);
578 66 : for (i=0; i<nCount; i++)
579 : {
580 4 : pItem = (SvxFontItem*)rDrawPool.GetItem2(EE_CHAR_FONTINFO, i);
581 4 : if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
582 0 : ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
583 0 : pItem->SetCharSet( eSysSet );
584 : }
585 : }
586 : }
587 63 : }
588 :
589 800 : void ScDocument::SetLoadingMedium( bool bVal )
590 : {
591 800 : bLoadingMedium = bVal;
592 800 : TableContainer::iterator it = maTabs.begin();
593 1961 : for (; it != maTabs.end(); ++it)
594 : {
595 1161 : if (!*it)
596 800 : return;
597 :
598 1161 : (*it)->SetLoadingMedium(bVal);
599 : }
600 : }
601 :
602 218 : void ScDocument::SetImportingXML( bool bVal )
603 : {
604 218 : bImportingXML = bVal;
605 218 : if (pDrawLayer)
606 49 : pDrawLayer->EnableAdjust(!bImportingXML);
607 :
608 218 : if ( !bVal )
609 : {
610 : // #i57869# after loading, do the real RTL mirroring for the sheets that have the LoadingRTL flag set
611 :
612 332 : for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++ )
613 223 : if ( maTabs[nTab]->IsLoadingRTL() )
614 : {
615 0 : maTabs[nTab]->SetLoadingRTL( false );
616 0 : SetLayoutRTL( nTab, true ); // includes mirroring; bImportingXML must be cleared first
617 : }
618 : }
619 :
620 218 : SetLoadingMedium(bVal);
621 218 : }
622 :
623 216 : void ScDocument::SetXMLFromWrapper( bool bVal )
624 : {
625 216 : bXMLFromWrapper = bVal;
626 216 : }
627 :
628 1596 : rtl::Reference<SvxForbiddenCharactersTable> ScDocument::GetForbiddenCharacters()
629 : {
630 1596 : return xForbiddenCharacters;
631 : }
632 :
633 35 : void ScDocument::SetForbiddenCharacters( const rtl::Reference<SvxForbiddenCharactersTable> xNew )
634 : {
635 35 : xForbiddenCharacters = xNew;
636 35 : if ( pEditEngine )
637 4 : pEditEngine->SetForbiddenCharsTable( xForbiddenCharacters );
638 35 : if ( pDrawLayer )
639 20 : pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
640 35 : }
641 :
642 788 : bool ScDocument::IsValidAsianCompression() const
643 : {
644 788 : return ( nAsianCompression != SC_ASIANCOMPRESSION_INVALID );
645 : }
646 :
647 1542 : sal_uInt8 ScDocument::GetAsianCompression() const
648 : {
649 1542 : if ( nAsianCompression == SC_ASIANCOMPRESSION_INVALID )
650 16 : return 0;
651 : else
652 1526 : return nAsianCompression;
653 : }
654 :
655 389 : void ScDocument::SetAsianCompression(sal_uInt8 nNew)
656 : {
657 389 : nAsianCompression = nNew;
658 389 : if ( pEditEngine )
659 0 : pEditEngine->SetAsianCompressionMode( nAsianCompression );
660 389 : if ( pDrawLayer )
661 2 : pDrawLayer->SetCharCompressType( nAsianCompression );
662 389 : }
663 :
664 788 : bool ScDocument::IsValidAsianKerning() const
665 : {
666 788 : return ( nAsianKerning != SC_ASIANKERNING_INVALID );
667 : }
668 :
669 1542 : bool ScDocument::GetAsianKerning() const
670 : {
671 1542 : if ( nAsianKerning == SC_ASIANKERNING_INVALID )
672 16 : return false;
673 : else
674 1526 : return static_cast<bool>(nAsianKerning);
675 : }
676 :
677 389 : void ScDocument::SetAsianKerning(bool bNew)
678 : {
679 389 : nAsianKerning = (sal_uInt8)bNew;
680 389 : if ( pEditEngine )
681 0 : pEditEngine->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
682 389 : if ( pDrawLayer )
683 2 : pDrawLayer->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
684 389 : }
685 :
686 1186 : void ScDocument::ApplyAsianEditSettings( ScEditEngineDefaulter& rEngine )
687 : {
688 1186 : rEngine.SetForbiddenCharsTable( xForbiddenCharacters );
689 1186 : rEngine.SetAsianCompressionMode( GetAsianCompression() );
690 1186 : rEngine.SetKernAsianPunctuation( GetAsianKerning() );
691 1288 : }
692 :
693 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|