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