LibreOffice Module sw (master)  1
docshini.cxx
Go to the documentation of this file.
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 <hintids.hxx>
21 
22 #include <osl/diagnose.h>
23 #include <sal/log.hxx>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <svtools/ctrltool.hxx>
27 #include <unotools/configmgr.hxx>
28 #include <unotools/lingucfg.hxx>
29 #include <sfx2/docfile.hxx>
30 #include <sfx2/sfxmodelfactory.hxx>
31 #include <sfx2/printer.hxx>
32 #include <svl/asiancfg.hxx>
33 #include <svl/intitem.hxx>
34 #include <tools/UnitConversion.hxx>
35 #include <editeng/adjustitem.hxx>
36 #include <editeng/autokernitem.hxx>
37 #include <com/sun/star/document/UpdateDocMode.hpp>
38 #include <com/sun/star/i18n/ScriptType.hpp>
39 #include <svx/svxids.hrc>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/fontitem.hxx>
42 #include <editeng/flstitem.hxx>
43 #include <editeng/tstpitem.hxx>
44 #include <editeng/langitem.hxx>
45 #include <editeng/colritem.hxx>
46 #include <editeng/orphitem.hxx>
47 #include <editeng/widwitem.hxx>
49 #include <vcl/svapp.hxx>
50 #include <vcl/settings.hxx>
51 #include <prtopt.hxx>
52 #include <fmtcol.hxx>
53 #include <docsh.hxx>
54 #include <wdocsh.hxx>
55 #include <swmodule.hxx>
56 #include <doc.hxx>
62 #include <IDocumentState.hxx>
63 #include <docfac.hxx>
64 #include <docstyle.hxx>
65 #include <shellio.hxx>
66 #include <swdtflvr.hxx>
67 #include <usrpref.hxx>
68 #include <fontcfg.hxx>
69 #include <poolfmt.hxx>
70 #include <globdoc.hxx>
71 #include <unotxdoc.hxx>
72 #include <linkenum.hxx>
73 #include <swwait.hxx>
74 #include <swerror.h>
75 #include <unochart.hxx>
76 #include <drawdoc.hxx>
78 
80 
81 #include <memory>
82 
83 #include <officecfg/Office/Common.hxx>
84 
85 using namespace ::com::sun::star::i18n;
86 using namespace ::com::sun::star::lang;
87 using namespace ::com::sun::star::uno;
88 using namespace ::com::sun::star;
89 
90 // Load Document
91 bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
92 {
93  bool bRet = SfxObjectShell::InitNew( xStor );
94  OSL_ENSURE( GetMapUnit() == MapUnit::MapTwip, "map unit is not twip!" );
95  bool bHTMLTemplSet = false;
96  if( bRet )
97  {
98  AddLink(); // create m_xDoc / pIo if applicable
99 
100  bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr;
101  if ( bWeb )
102  bHTMLTemplSet = SetHTMLTemplate( *GetDoc() );// Styles from HTML.vor
103  else if( dynamic_cast< const SwGlobalDocShell *>( this ) != nullptr )
105 
106  if ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
107  SwTransferable::InitOle( this );
108 
109  // set forbidden characters if necessary
110  const bool bFuzzing = utl::ConfigManager::IsFuzzing();
111  if (!bFuzzing)
112  {
113  SvxAsianConfig aAsian;
114  const Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
115  for(const lang::Locale& rLocale : aLocales)
116  {
117  ForbiddenCharacters aForbidden;
118  aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, aForbidden.endLine);
120  m_xDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden);
121  }
122  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION,
123  !aAsian.IsKerningWesternTextOnly());
124  m_xDoc->getIDocumentSettingAccess().setCharacterCompressionType(aAsian.GetCharDistanceCompression());
125  m_xDoc->getIDocumentDeviceAccess().setPrintData(*SW_MOD()->GetPrtOptions(bWeb));
126  }
127 
128  SubInitNew();
129 
130  // for all
131 
132  SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
133  SfxPrinter* pPrt = m_xDoc->getIDocumentDeviceAccess().getPrinter( false );
134 
135  OUString sEntry;
136  static const sal_uInt16 aFontWhich[] =
137  { RES_CHRATR_FONT,
140  };
141  static const sal_uInt16 aFontHeightWhich[] =
142  {
146  };
147  static const sal_uInt16 aFontIds[] =
148  {
152  };
153  static const DefaultFontType nFontTypes[] =
154  {
155  DefaultFontType::LATIN_TEXT,
156  DefaultFontType::CJK_TEXT,
157  DefaultFontType::CTL_TEXT
158  };
159  static const sal_uInt16 aLangTypes[] =
160  {
164  };
165 
166  for(sal_uInt8 i = 0; i < 3; i++)
167  {
168  sal_uInt16 nFontWhich = aFontWhich[i];
169  sal_uInt16 nFontId = aFontIds[i];
170  std::unique_ptr<SvxFontItem> pFontItem;
171  const SvxLanguageItem& rLang = static_cast<const SvxLanguageItem&>(m_xDoc->GetDefault( aLangTypes[i] ));
172  LanguageType eLanguage = rLang.GetLanguage();
173  if(!pStdFont->IsFontDefault(nFontId))
174  {
175  sEntry = pStdFont->GetFontFor(nFontId);
176 
177  vcl::Font aFont( sEntry, Size( 0, 10 ) );
178  if( pPrt )
179  {
180  aFont = pPrt->GetFontMetric( aFont );
181  }
182 
183  pFontItem.reset(new SvxFontItem(aFont.GetFamilyType(), aFont.GetFamilyName(),
184  OUString(), aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
185  }
186  else
187  {
188  // #107782# OJ use korean language if latin was used
189  if ( i == 0 )
190  {
192  if (MsLangId::isKorean(eUiLanguage))
193  eLanguage = eUiLanguage;
194  }
195 
197  nFontTypes[i],
198  eLanguage,
199  GetDefaultFontFlags::OnlyOne );
200  pFontItem.reset(new SvxFontItem(aLangDefFont.GetFamilyType(), aLangDefFont.GetFamilyName(),
201  OUString(), aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich));
202  }
203  m_xDoc->SetDefault(*pFontItem);
204  if( !bHTMLTemplSet )
205  {
206  SwTextFormatColl *pColl = m_xDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD);
207  pColl->ResetFormatAttr(nFontWhich);
208  }
209  pFontItem.reset();
210  sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage );
211  if(nFontHeight <= 0)
212  nFontHeight = SwStdFontConfig::GetDefaultHeightFor( nFontId, eLanguage );
213  m_xDoc->SetDefault(SvxFontHeightItem( nFontHeight, 100, aFontHeightWhich[i] ));
214  if( !bHTMLTemplSet )
215  {
216  SwTextFormatColl *pColl = m_xDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD);
217  pColl->ResetFormatAttr(aFontHeightWhich[i]);
218  }
219 
220  }
221  sal_uInt16 aFontIdPoolId[] =
222  {
234  FONT_INDEX_CTL, RES_POOLCOLL_REGISTER_BASE
235  };
236 
237  sal_uInt16 nFontWhich = RES_CHRATR_FONT;
238  sal_uInt16 nFontHeightWhich = RES_CHRATR_FONTSIZE;
239  LanguageType eLanguage = m_xDoc->GetDefault( RES_CHRATR_LANGUAGE ).GetLanguage();
240  bool bDisableBuiltinStyles = !bFuzzing && officecfg::Office::Common::Load::DisableBuiltinStyles::get();
241  sal_uInt8 nLimit = bDisableBuiltinStyles ? 0 : 24;
242  for(sal_uInt8 nIdx = 0; nIdx < nLimit; nIdx += 2)
243  {
244  if(nIdx == 8)
245  {
246  nFontWhich = RES_CHRATR_CJK_FONT;
247  nFontHeightWhich = RES_CHRATR_CJK_FONTSIZE;
248  eLanguage = m_xDoc->GetDefault( RES_CHRATR_CJK_LANGUAGE ).GetLanguage();
249  }
250  else if(nIdx == 16)
251  {
252  nFontWhich = RES_CHRATR_CTL_FONT;
253  nFontHeightWhich = RES_CHRATR_CTL_FONTSIZE;
254  eLanguage = m_xDoc->GetDefault( RES_CHRATR_CTL_LANGUAGE ).GetLanguage();
255  }
256  SwTextFormatColl *pColl = nullptr;
257  if(!pStdFont->IsFontDefault(aFontIdPoolId[nIdx]))
258  {
259  sEntry = pStdFont->GetFontFor(aFontIdPoolId[nIdx]);
260 
261  vcl::Font aFont( sEntry, Size( 0, 10 ) );
262  if( pPrt )
263  aFont = pPrt->GetFontMetric( aFont );
264 
265  pColl = m_xDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(aFontIdPoolId[nIdx + 1]);
266  if( !bHTMLTemplSet ||
267  SfxItemState::SET != pColl->GetAttrSet().GetItemState(
268  nFontWhich, false ) )
269  {
270  pColl->SetFormatAttr(SvxFontItem(aFont.GetFamilyType(), aFont.GetFamilyName(),
271  OUString(), aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
272  }
273  }
274  sal_Int32 nFontHeight = pStdFont->GetFontHeight( static_cast< sal_Int8 >(aFontIdPoolId[nIdx]), 0, eLanguage );
275  if(nFontHeight <= 0)
276  nFontHeight = SwStdFontConfig::GetDefaultHeightFor( aFontIdPoolId[nIdx], eLanguage );
277  if(!pColl)
278  pColl = m_xDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(aFontIdPoolId[nIdx + 1]);
279  SvxFontHeightItem aFontHeight( static_cast<const SvxFontHeightItem&>(pColl->GetFormatAttr( nFontHeightWhich )));
280  if(aFontHeight.GetHeight() != sal::static_int_cast<sal_uInt32, sal_Int32>(nFontHeight))
281  {
282  aFontHeight.SetHeight(nFontHeight);
283  pColl->SetFormatAttr( aFontHeight );
284  }
285  }
286 
287  // the default for documents created via 'File/New' should be 'on'
288  // (old documents, where this property was not yet implemented, will get the
289  // value 'false' in the SwDoc c-tor)
290  m_xDoc->getIDocumentSettingAccess().set( DocumentSettingId::MATH_BASELINE_ALIGNMENT,
291  SW_MOD()->GetUsrPref( bWeb )->IsAlignMathObjectsToBaseline() );
292  }
293 
294  /* #106748# If the default frame direction of a document is RTL
295  the default adjustment is to the right. */
296  if( !bHTMLTemplSet &&
297  SvxFrameDirection::Horizontal_RL_TB == GetDefaultFrameDirection(GetAppLanguage()) )
298  {
299  m_xDoc->SetDefault( SvxAdjustItem(SvxAdjust::Right, RES_PARATR_ADJUST ) );
300  }
301 
302 // #i29550#
303  m_xDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, true ) );
304 // <-- collapsing
305 
306  //#i16874# AutoKerning as default for new documents
307  m_xDoc->SetDefault( SvxAutoKernItem( true, RES_CHRATR_AUTOKERN ) );
308 
309  // #i42080# - Due to the several calls of method <SetDefault(..)>
310  // at the document instance, the document is modified. Thus, reset this
311  // status here. Note: In method <SubInitNew()> this is also done.
312  m_xDoc->getIDocumentState().ResetModified();
313 
314  return bRet;
315 }
316 
317 // Ctor with SfxCreateMode ?????
319  : SfxObjectShell(eMode)
320  , m_IsInUpdateFontList(false)
321  , m_pStyleManager(new svx::CommonStyleManager(*this))
322  , m_pView(nullptr)
323  , m_pWrtShell(nullptr)
324  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
325  , m_IsATemplate(false)
326  , m_IsRemovedInvisibleContent(false)
327 {
328  Init_Impl();
329 }
330 
331 // Ctor / Dtor
332 SwDocShell::SwDocShell( const SfxModelFlags i_nSfxCreationFlags )
333  : SfxObjectShell ( i_nSfxCreationFlags )
334  , m_IsInUpdateFontList(false)
335  , m_pStyleManager(new svx::CommonStyleManager(*this))
336  , m_pView(nullptr)
337  , m_pWrtShell(nullptr)
338  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
339  , m_IsATemplate(false)
340  , m_IsRemovedInvisibleContent(false)
341 {
342  Init_Impl();
343 }
344 
345 // Ctor / Dtor
347  : SfxObjectShell(eMode)
348  , m_xDoc(&rD)
349  , m_IsInUpdateFontList(false)
350  , m_pStyleManager(new svx::CommonStyleManager(*this))
351  , m_pView(nullptr)
352  , m_pWrtShell(nullptr)
353  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
354  , m_IsATemplate(false)
355  , m_IsRemovedInvisibleContent(false)
356 {
357  Init_Impl();
358 }
359 
360 // Dtor
362 {
363  // disable chart related objects now because in ~SwDoc it may be too late for this
364  if (m_xDoc)
365  {
366  m_xDoc->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
367  SwChartDataProvider *pPCD = m_xDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider();
368  if (pPCD)
369  pPCD->dispose();
370  }
371 
372  RemoveLink();
373  m_pFontList.reset();
374 
375  // we, as BroadCaster also become our own Listener
376  // (for DocInfo/FileNames/...)
377  EndListening( *this );
378 
379  m_pOLEChildList.reset();
380 }
381 
383 {
384  SetPool(&SW_MOD()->GetPool());
385  SetBaseModel(new SwXTextDocument(this));
386  // we, as BroadCaster also become our own Listener
387  // (for DocInfo/FileNames/...)
388  StartListening( *this );
389  //position of the "Automatic" style filter for the stylist (app.src)
391 
392  // set map unit to twip
393  SetMapUnit( MapUnit::MapTwip );
394 }
395 
397 {
398  if (!m_xDoc)
399  {
400  SwDocFac aFactory;
401  m_xDoc = &aFactory.GetDoc();
402  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, dynamic_cast< const SwWebDocShell *>( this ) != nullptr );
403  }
404  m_xDoc->SetDocShell( this ); // set the DocShell-Pointer for Doc
405  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
406  static_cast<SwXTextDocument*>(xDoc.get())->Reactivate(this);
407 
408  SetPool(&m_xDoc->GetAttrPool());
409 
410  // most suitably not until a sdbcx::View is created!!!
411  m_xDoc->SetOle2Link(LINK(this, SwDocShell, Ole2ModifiedHdl));
412 }
413 
414 // create new FontList Change Printer
416 {
418  {
419  m_IsInUpdateFontList = true;
420  OSL_ENSURE(m_xDoc, "No Doc no FontList");
421  if (m_xDoc)
422  {
423  m_pFontList.reset( new FontList( m_xDoc->getIDocumentDeviceAccess().getReferenceDevice(true) ) );
424  PutItem( SvxFontListItem( m_pFontList.get(), SID_ATTR_CHAR_FONTLIST ) );
425  }
426  m_IsInUpdateFontList = false;
427  }
428 }
429 
431 {
432  // disconnect Uno-Object
433  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
434  static_cast<SwXTextDocument*>(xDoc.get())->Invalidate();
435  if (m_xDoc)
436  {
437  if (m_xBasePool.is())
438  {
439  static_cast<SwDocStyleSheetPool*>(m_xBasePool.get())->dispose();
440  m_xBasePool.clear();
441  }
442  m_xDoc->SetOle2Link(Link<bool,void>());
443  m_xDoc->SetDocShell( nullptr );
444  m_xDoc.clear(); // we don't have the Doc anymore!!
445  }
446 }
448 {
449  // disconnect Uno-Object
450  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
451  static_cast<SwXTextDocument*>(xDoc.get())->Invalidate();
452 }
454 {
455  // disconnect Uno-Object
456  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
457  static_cast<SwXTextDocument*>(xDoc.get())->Reactivate(this);
458 }
459 
460 // Load, Default-Format
461 bool SwDocShell::Load( SfxMedium& rMedium )
462 {
463  bool bRet = false;
464 
465  if (SfxObjectShell::Load(rMedium))
466  {
468  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
469 
470  SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
471  if (m_xDoc) // for last version!!
472  RemoveLink(); // release the existing
473 
474  AddLink(); // set Link and update Data!!
475 
476  // Define some settings for legacy ODF files that have different default values now
477  // (if required, they will be overridden later when settings will be read)
478  if (IsOwnStorageFormat(rMedium))
479  {
480  // legacy processing for tdf#99729
481  if (m_xDoc->getIDocumentDrawModelAccess().GetDrawModel())
482  m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->SetAnchoredTextOverflowLegacy(
483  true);
484  }
485 
486  // Loading
487  // for MD
488  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
489  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
490  if(GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
491  {
492  const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.GetItemSet(), SID_UPDATEDOCMODE, false);
493  m_nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
494  }
495 
496  SwWait aWait( *this, true );
498  switch( GetCreateMode() )
499  {
500  case SfxObjectCreateMode::ORGANIZER:
501  {
502  if( ReadXML )
503  {
504  ReadXML->SetOrganizerMode( true );
505  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
506  nErr = aRdr.Read( *ReadXML );
507  ReadXML->SetOrganizerMode( false );
508  }
509  }
510  break;
511 
512  case SfxObjectCreateMode::INTERNAL:
513  case SfxObjectCreateMode::EMBEDDED:
514  {
515  SwTransferable::InitOle( this );
516  }
517  // suppress SfxProgress, when we are Embedded
518  SW_MOD()->SetEmbeddedLoadSave( true );
519  [[fallthrough]];
520 
521  case SfxObjectCreateMode::STANDARD:
522  {
523  Reader *pReader = ReadXML;
524  if( pReader )
525  {
526  // set Doc's DocInfo at DocShell-Medium
527  SAL_INFO( "sw.ui", "before ReadDocInfo" );
528  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
529  SAL_INFO( "sw.ui", "before Read" );
530  nErr = aRdr.Read( *pReader );
531  SAL_INFO( "sw.ui", "after Read" );
532  // If a XML document is loaded, the global doc/web doc
533  // flags have to be set, because they aren't loaded
534  // by this formats.
535  if( dynamic_cast< const SwWebDocShell *>( this ) != nullptr )
536  {
537  if (!m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE))
538  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true);
539  }
540  if( dynamic_cast< const SwGlobalDocShell *>( this ) != nullptr )
541  {
542  if (!m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT))
543  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::GLOBAL_DOCUMENT, true);
544  }
545  }
546  }
547  break;
548 
549  default:
550  OSL_ENSURE( false, "Load: new CreateMode?" );
551  }
552 
553  UpdateFontList();
554  InitDrawModelAndDocShell(this, m_xDoc ? m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()
555  : nullptr);
556 
557  SetError(nErr);
558  bRet = !nErr.IsError();
559 
560  if (bRet && !m_xDoc->IsInLoadAsynchron() &&
561  GetCreateMode() == SfxObjectCreateMode::STANDARD)
562  {
563  LoadingFinished();
564  }
565 
566  // suppress SfxProgress, when we are Embedded
567  SW_MOD()->SetEmbeddedLoadSave( false );
568  }
569 
570  return bRet;
571 }
572 
574 {
575  bool bRet = false;
576  if (m_xDoc)
577  RemoveLink();
578 
579  AddLink(); // set Link and update Data!!
580 
581  do { // middle check loop
583  OUString aStreamName = "styles.xml";
584  uno::Reference < container::XNameAccess > xAccess = rMedium.GetStorage();
585  if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) )
586  {
587  // Loading
588  SwWait aWait( *this, true );
589  {
590  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
591  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
592  if( ReadXML )
593  {
594  ReadXML->SetOrganizerMode( true );
595  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
596  nErr = aRdr.Read( *ReadXML );
597  ReadXML->SetOrganizerMode( false );
598  }
599  }
600  }
601  else
602  {
603  OSL_FAIL("Code removed!");
604  }
605 
606  SetError(nErr);
607  bRet = !nErr.IsError();
608 
609  } while( false );
610 
611  SfxObjectShell::LoadFrom( rMedium );
612  m_xDoc->getIDocumentState().ResetModified();
613  return bRet;
614 }
615 
617 {
618  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
619  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
620  UpdateFontList();
621  InitDrawModelAndDocShell(this, m_xDoc ? m_xDoc->getIDocumentDrawModelAccess().GetDrawModel() : nullptr);
622 
623  m_xDoc->getIDocumentSettingAccess().setLinkUpdateMode( GLOBALSETTING );
624  m_xDoc->getIDocumentSettingAccess().setFieldUpdateFlags( AUTOUPD_GLOBALSETTING );
625 
626  bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr;
627 
628  static const WhichRangesContainer nRange1(svl::Items<
634  >);
635  static const WhichRangesContainer nRange2(svl::Items<
642  >);
643  SfxItemSet aDfltSet( m_xDoc->GetAttrPool(), bWeb ? nRange1 : nRange2 );
644 
646  SvtLinguOptions aLinguOpt;
647 
649  SvtLinguConfig().GetOptions(aLinguOpt);
650 
651  LanguageType nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN),
652  eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN),
653  eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX);
654  aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) );
655  aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) );
656  aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) );
657 
658  if(!bWeb)
659  {
660  SvxHyphenZoneItem aHyp( m_xDoc->GetDefault(RES_PARATR_HYPHENZONE) );
661  aHyp.GetMinLead() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading);
662  aHyp.GetMinTrail() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing);
663 
664  aDfltSet.Put( aHyp );
665 
666  sal_uInt16 nNewPos = o3tl::toTwips(SW_MOD()->GetUsrPref(false)->GetDefTabInMm100(), o3tl::Length::mm100);
667  if( nNewPos )
668  aDfltSet.Put( SvxTabStopItem( 1, nNewPos,
669  SvxTabAdjust::Default, RES_PARATR_TABSTOP ) );
670  }
671  aDfltSet.Put( SvxColorItem( COL_AUTO, RES_CHRATR_COLOR ) );
672 
673  m_xDoc->SetDefault( aDfltSet );
674 
675  //default page mode for text grid
676  if(!bWeb)
677  {
678  bool bSquaredPageMode = SW_MOD()->GetUsrPref(false)->IsSquaredPageMode();
679  m_xDoc->SetDefaultPageMode( bSquaredPageMode );
680 
681  // only set Widow/Orphan defaults on a new, non-web document - not an opened one
682  if( GetMedium() && GetMedium()->GetOrigURL().isEmpty() )
683  {
684  m_xDoc->SetDefault( SvxWidowsItem( sal_uInt8(2), RES_PARATR_WIDOWS) );
685  m_xDoc->SetDefault( SvxOrphansItem( sal_uInt8(2), RES_PARATR_ORPHANS) );
686  }
687  }
688 
689  m_xDoc->getIDocumentState().ResetModified();
690 }
691 
692 /*
693  * Document Interface Access
694  */
696 {
697  return m_xDoc->getIDocumentDeviceAccess();
698 }
699 
701 {
702  return m_xDoc->getIDocumentChartDataProviderAccess();
703 }
704 
705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Subgroup labels.
Definition: poolfmt.hxx:345
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
SAL_DLLPRIVATE void SubInitNew()
for InitNew and HtmlSourceMode.
Definition: docshini.cxx:616
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
constexpr TypedWhichId< SvxTabStopItem > RES_PARATR_TABSTOP(68)
#define FONT_STANDARD
Definition: fontcfg.hxx:27
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
const OUString & GetFamilyName() const
#define FONT_OUTLINE
Definition: fontcfg.hxx:28
bool IsKerningWesternTextOnly() const
constexpr auto toTwips(N number, Length from)
#define FONT_STANDARD_CJK
Definition: fontcfg.hxx:32
#define FONT_LIST_CTL
Definition: fontcfg.hxx:39
static constexpr auto Items
virtual bool Load(SfxMedium &rMedium)
const LanguageTag & GetUILanguageTag() const
void UpdateFontList()
Definition: docshini.cxx:415
#define FONT_OUTLINE_CJK
Definition: fontcfg.hxx:33
LanguageType getLanguageType(bool bResolveSystem=true) const
std::unique_ptr< comphelper::EmbeddedObjectContainer > m_pOLEChildList
Definition: docsh.hxx:86
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
#define FONT_LIST_CJK
Definition: fontcfg.hxx:34
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
static const AllSettings & GetSettings()
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
Definition: doc.hxx:188
sal_uInt16 GetValue() const
void SetHeight(sal_uInt32 nNewHeight, const sal_uInt16 nNewProp=100, MapUnit eUnit=MapUnit::MapRelative)
void SetOrganizerMode(bool bSet)
Definition: shellio.hxx:265
#define FONT_LIST
Definition: fontcfg.hxx:29
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
constexpr TypedWhichId< SvxAutoKernItem > RES_CHRATR_AUTOKERN(17)
#define FONT_INDEX_CTL
Definition: fontcfg.hxx:41
virtual SAL_DLLPRIVATE bool LoadFrom(SfxMedium &rMedium) override
Definition: docshini.cxx:573
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the and register/unregister the paragragh style at t...
Definition: fmtcol.cxx:343
void LoadingFinished()
linked graphics are now loaded on demand.
Definition: docsh.cxx:1173
sal_Int32 GetFontHeight(sal_uInt8 nFont, sal_uInt8 nScriptType, LanguageType eLang)
Definition: fontcfg.cxx:299
void PutItem(const SfxPoolItem &rItem)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
#define FONT_CAPTION
Definition: fontcfg.hxx:30
FontFamily GetFamilyType()
static bool IsOwnStorageFormat(const SfxMedium &)
sal_uInt8 & GetMinLead()
#define FONT_OUTLINE_CTL
Definition: fontcfg.hxx:38
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
Reader * ReadXML
Definition: fltini.cxx:46
virtual ~SwDocShell() override
Definition: docshini.cxx:361
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
static bool IsFuzzing()
SfxObjectCreateMode GetCreateMode() const
virtual void SAL_CALL dispose() override
Definition: unochart.cxx:1360
SAL_DLLPRIVATE void Init_Impl()
Definition: docshini.cxx:382
SfxItemPool & GetPool() const
constexpr TypedWhichId< SvxHyphenZoneItem > RES_PARATR_HYPHENZONE(69)
bool GetStartEndChars(css::lang::Locale const &locale, OUString &startChars, OUString &endChars) const
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
#define FONT_INDEX_CJK
Definition: fontcfg.hxx:36
SwDocShell(SfxObjectCreateMode eMode=SfxObjectCreateMode::EMBEDDED)
Doc is required for SO data exchange!
Definition: docshini.cxx:318
#define SW_MOD()
Definition: swmodule.hxx:256
FontPitch GetPitch()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
bool IsFontDefault(sal_uInt16 nFontType) const
Definition: fontcfg.cxx:157
SfxObjectCreateMode
CharCompressType GetCharDistanceCompression() const
Subgroup headings.
Definition: poolfmt.hxx:261
void GetOptions(SvtLinguOptions &rOptions) const
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawDocument)
Definition: docshdrw.cxx:32
SAL_DLLPRIVATE void RemoveLink()
Definition: docshini.cxx:430
virtual SAL_DLLPRIVATE bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage) override
FileIO.
Definition: docshini.cxx:91
void SetAutoStyleFilterIndex(sal_uInt16 nSet)
const OUString & GetFontFor(sal_uInt16 nFontType) const
Definition: fontcfg.hxx:87
virtual bool LoadFrom(SfxMedium &rMedium)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(124)
void SetPool(SfxItemPool *pNewPool)
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
SfxItemSet * GetItemSet() const
#define FONT_INDEX
Definition: fontcfg.hxx:31
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
std::unique_ptr< FontList > m_pFontList
Current Fontlist.
Definition: docsh.hxx:73
bool SetHTMLTemplate(SwDoc &rDoc)
Definition: shellio.cxx:907
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool
Passing through for formats.
Definition: docsh.hxx:72
void SetMapUnit(MapUnit nMUnit)
Provides access to the formatting devices of a document.
IDocumentDeviceAccess & getIDocumentDeviceAccess()
Definition: docshini.cxx:695
bool IsError() const
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
void InvalidateModel()
Definition: docshini.cxx:447
LanguageType GetLanguage() const
static void InitOle(SfxObjectShell *pDoc)
Definition: swdtflvr.cxx:347
css::uno::Sequence< css::lang::Locale > GetStartEndCharLocales() const
virtual void Invalidate(sal_uInt16 nId=0) override
sal_uInt32 GetHeight() const
constexpr TypedWhichId< SvxOrphansItem > RES_PARATR_ORPHANS(66)
exports com.sun.star. document
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
bool m_IsInUpdateFontList
prevent nested calls of UpdateFontList
Definition: docsh.hxx:74
unsigned char sal_uInt8
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Definition: docshini.cxx:700
MapUnit GetMapUnit() const
#define SAL_INFO(area, stream)
SfxModelFlags
LanguageType GetAppLanguage()
Definition: init.cxx:723
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
void SetBaseModel(SfxBaseModel *pModel)
virtual SAL_DLLPRIVATE bool Load(SfxMedium &rMedium) override
Definition: docshini.cxx:461
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:369
static bool isKorean(LanguageType nLang)
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: fmtcol.cxx:380
#define FONT_STANDARD_CTL
Definition: fontcfg.hxx:37
DefaultFontType
SvxFrameDirection GetDefaultFrameDirection(LanguageType nLanguage)
Return the AutoCollection by its Id.
Definition: poolfmt.cxx:79
#define ERR_SWG_READ_ERROR
Definition: swerror.h:25
#define FONT_CAPTION_CTL
Definition: fontcfg.hxx:40
sal_Int16 m_nUpdateDocMode
contains the css::document::UpdateDocMode
Definition: docsh.hxx:87
#define FONT_CAPTION_CJK
Definition: fontcfg.hxx:35
Give access to the data-provider for chart.
SAL_DLLPRIVATE void AddLink()
Methods for access to doc.
Definition: docshini.cxx:396
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
static sal_Int32 GetDefaultHeightFor(sal_uInt16 nFontType, LanguageType eLang)
Definition: fontcfg.cxx:249
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
void SetError(ErrCode rErr)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SvxWidowsItem > RES_PARATR_WIDOWS(67)
rtl_TextEncoding GetCharSet() const
SwDoc & GetDoc()
Document is created after calling Read(...).
Definition: docfact.cxx:33
void ReactivateModel()
Definition: docshini.cxx:453
SfxMedium * GetMedium() const