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  m_xDoc->getIDocumentSettingAccess().set( DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, true);
293  }
294 
295  /* #106748# If the default frame direction of a document is RTL
296  the default adjustment is to the right. */
297  if( !bHTMLTemplSet &&
298  SvxFrameDirection::Horizontal_RL_TB == GetDefaultFrameDirection(GetAppLanguage()) )
299  {
300  m_xDoc->SetDefault( SvxAdjustItem(SvxAdjust::Right, RES_PARATR_ADJUST ) );
301  }
302 
303 // #i29550#
304  m_xDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, true ) );
305 // <-- collapsing
306 
307  //#i16874# AutoKerning as default for new documents
308  m_xDoc->SetDefault( SvxAutoKernItem( true, RES_CHRATR_AUTOKERN ) );
309 
310  // #i42080# - Due to the several calls of method <SetDefault(..)>
311  // at the document instance, the document is modified. Thus, reset this
312  // status here. Note: In method <SubInitNew()> this is also done.
313  m_xDoc->getIDocumentState().ResetModified();
314 
315  return bRet;
316 }
317 
318 // Ctor with SfxCreateMode ?????
320  : SfxObjectShell(eMode)
321  , m_IsInUpdateFontList(false)
322  , m_pStyleManager(new svx::CommonStyleManager(*this))
323  , m_pView(nullptr)
324  , m_pWrtShell(nullptr)
325  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
326  , m_IsATemplate(false)
327  , m_IsRemovedInvisibleContent(false)
328 {
329  Init_Impl();
330 }
331 
332 // Ctor / Dtor
333 SwDocShell::SwDocShell( const SfxModelFlags i_nSfxCreationFlags )
334  : SfxObjectShell ( i_nSfxCreationFlags )
335  , m_IsInUpdateFontList(false)
336  , m_pStyleManager(new svx::CommonStyleManager(*this))
337  , m_pView(nullptr)
338  , m_pWrtShell(nullptr)
339  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
340  , m_IsATemplate(false)
341  , m_IsRemovedInvisibleContent(false)
342 {
343  Init_Impl();
344 }
345 
346 // Ctor / Dtor
348  : SfxObjectShell(eMode)
349  , m_xDoc(&rD)
350  , m_IsInUpdateFontList(false)
351  , m_pStyleManager(new svx::CommonStyleManager(*this))
352  , m_pView(nullptr)
353  , m_pWrtShell(nullptr)
354  , m_nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG)
355  , m_IsATemplate(false)
356  , m_IsRemovedInvisibleContent(false)
357 {
358  Init_Impl();
359 }
360 
361 // Dtor
363 {
364  // disable chart related objects now because in ~SwDoc it may be too late for this
365  if (m_xDoc)
366  {
367  m_xDoc->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
368  SwChartDataProvider *pPCD = m_xDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider();
369  if (pPCD)
370  pPCD->dispose();
371  }
372 
373  RemoveLink();
374  m_pFontList.reset();
375 
376  // we, as BroadCaster also become our own Listener
377  // (for DocInfo/FileNames/...)
378  EndListening( *this );
379 
380  m_pOLEChildList.reset();
381 }
382 
384 {
385  SetPool(&SW_MOD()->GetPool());
386  SetBaseModel(new SwXTextDocument(this));
387  // we, as BroadCaster also become our own Listener
388  // (for DocInfo/FileNames/...)
389  StartListening( *this );
390  //position of the "Automatic" style filter for the stylist (app.src)
392 
393  // set map unit to twip
394  SetMapUnit( MapUnit::MapTwip );
395 }
396 
398 {
399  if (!m_xDoc)
400  {
401  SwDocFac aFactory;
402  m_xDoc = &aFactory.GetDoc();
403  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, dynamic_cast< const SwWebDocShell *>( this ) != nullptr );
404  }
405  m_xDoc->SetDocShell( this ); // set the DocShell-Pointer for Doc
406  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
407  static_cast<SwXTextDocument*>(xDoc.get())->Reactivate(this);
408 
409  SetPool(&m_xDoc->GetAttrPool());
410 
411  // most suitably not until a sdbcx::View is created!!!
412  m_xDoc->SetOle2Link(LINK(this, SwDocShell, Ole2ModifiedHdl));
413 }
414 
415 // create new FontList Change Printer
417 {
419  {
420  m_IsInUpdateFontList = true;
421  OSL_ENSURE(m_xDoc, "No Doc no FontList");
422  if (m_xDoc)
423  {
424  m_pFontList.reset( new FontList( m_xDoc->getIDocumentDeviceAccess().getReferenceDevice(true) ) );
425  PutItem( SvxFontListItem( m_pFontList.get(), SID_ATTR_CHAR_FONTLIST ) );
426  }
427  m_IsInUpdateFontList = false;
428  }
429 }
430 
432 {
433  // disconnect Uno-Object
434  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
435  static_cast<SwXTextDocument*>(xDoc.get())->Invalidate();
436  if (m_xDoc)
437  {
438  if (m_xBasePool.is())
439  {
440  static_cast<SwDocStyleSheetPool*>(m_xBasePool.get())->dispose();
441  m_xBasePool.clear();
442  }
443  m_xDoc->SetOle2Link(Link<bool,void>());
444  m_xDoc->SetDocShell( nullptr );
445  m_xDoc.clear(); // we don't have the Doc anymore!!
446  }
447 }
449 {
450  // disconnect Uno-Object
451  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
452  static_cast<SwXTextDocument*>(xDoc.get())->Invalidate();
453 }
455 {
456  // disconnect Uno-Object
457  uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
458  static_cast<SwXTextDocument*>(xDoc.get())->Reactivate(this);
459 }
460 
461 // Load, Default-Format
462 bool SwDocShell::Load( SfxMedium& rMedium )
463 {
464  bool bRet = false;
465 
466  if (SfxObjectShell::Load(rMedium))
467  {
469  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
470 
471  SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
472  if (m_xDoc) // for last version!!
473  RemoveLink(); // release the existing
474 
475  AddLink(); // set Link and update Data!!
476 
477  // Define some settings for legacy ODF files that have different default values now
478  // (if required, they will be overridden later when settings will be read)
479  if (IsOwnStorageFormat(rMedium))
480  {
481  // legacy processing for tdf#99729
482  if (m_xDoc->getIDocumentDrawModelAccess().GetDrawModel())
483  m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->SetAnchoredTextOverflowLegacy(
484  true);
485  }
486 
487  // Loading
488  // for MD
489  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
490  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
491  if(GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
492  {
493  const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.GetItemSet(), SID_UPDATEDOCMODE, false);
494  m_nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
495  }
496 
497  SwWait aWait( *this, true );
499  switch( GetCreateMode() )
500  {
501  case SfxObjectCreateMode::ORGANIZER:
502  {
503  if( ReadXML )
504  {
505  ReadXML->SetOrganizerMode( true );
506  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
507  nErr = aRdr.Read( *ReadXML );
508  ReadXML->SetOrganizerMode( false );
509  }
510  }
511  break;
512 
513  case SfxObjectCreateMode::INTERNAL:
514  case SfxObjectCreateMode::EMBEDDED:
515  {
516  SwTransferable::InitOle( this );
517  }
518  // suppress SfxProgress, when we are Embedded
519  SW_MOD()->SetEmbeddedLoadSave( true );
520  [[fallthrough]];
521 
522  case SfxObjectCreateMode::STANDARD:
523  {
524  Reader *pReader = ReadXML;
525  if( pReader )
526  {
527  // set Doc's DocInfo at DocShell-Medium
528  SAL_INFO( "sw.ui", "before ReadDocInfo" );
529  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
530  SAL_INFO( "sw.ui", "before Read" );
531  nErr = aRdr.Read( *pReader );
532  SAL_INFO( "sw.ui", "after Read" );
533  // If a XML document is loaded, the global doc/web doc
534  // flags have to be set, because they aren't loaded
535  // by this formats.
536  if( dynamic_cast< const SwWebDocShell *>( this ) != nullptr )
537  {
538  if (!m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE))
539  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true);
540  }
541  if( dynamic_cast< const SwGlobalDocShell *>( this ) != nullptr )
542  {
543  if (!m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT))
544  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::GLOBAL_DOCUMENT, true);
545  }
546  }
547  }
548  break;
549 
550  default:
551  OSL_ENSURE( false, "Load: new CreateMode?" );
552  }
553 
554  UpdateFontList();
555  InitDrawModelAndDocShell(this, m_xDoc ? m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()
556  : nullptr);
557 
558  SetError(nErr);
559  bRet = !nErr.IsError();
560 
561  if (bRet && !m_xDoc->IsInLoadAsynchron() &&
562  GetCreateMode() == SfxObjectCreateMode::STANDARD)
563  {
564  LoadingFinished();
565  }
566 
567  // suppress SfxProgress, when we are Embedded
568  SW_MOD()->SetEmbeddedLoadSave( false );
569  }
570 
571  return bRet;
572 }
573 
575 {
576  bool bRet = false;
577  if (m_xDoc)
578  RemoveLink();
579 
580  AddLink(); // set Link and update Data!!
581 
582  do { // middle check loop
584  OUString aStreamName = "styles.xml";
585  uno::Reference < container::XNameAccess > xAccess = rMedium.GetStorage();
586  if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) )
587  {
588  // Loading
589  SwWait aWait( *this, true );
590  {
591  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
592  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
593  if( ReadXML )
594  {
595  ReadXML->SetOrganizerMode( true );
596  SwReader aRdr(rMedium, OUString(), m_xDoc.get());
597  nErr = aRdr.Read( *ReadXML );
598  ReadXML->SetOrganizerMode( false );
599  }
600  }
601  }
602  else
603  {
604  OSL_FAIL("Code removed!");
605  }
606 
607  SetError(nErr);
608  bRet = !nErr.IsError();
609 
610  } while( false );
611 
612  SfxObjectShell::LoadFrom( rMedium );
613  m_xDoc->getIDocumentState().ResetModified();
614  return bRet;
615 }
616 
618 {
619  OSL_ENSURE( !m_xBasePool.is(), "who hasn't destroyed their Pool?" );
620  m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
621  UpdateFontList();
622  InitDrawModelAndDocShell(this, m_xDoc ? m_xDoc->getIDocumentDrawModelAccess().GetDrawModel() : nullptr);
623 
624  m_xDoc->getIDocumentSettingAccess().setLinkUpdateMode( GLOBALSETTING );
625  m_xDoc->getIDocumentSettingAccess().setFieldUpdateFlags( AUTOUPD_GLOBALSETTING );
626 
627  bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr;
628 
629  static const WhichRangesContainer nRange1(svl::Items<
635  >);
636  static const WhichRangesContainer nRange2(svl::Items<
643  >);
644  SfxItemSet aDfltSet( m_xDoc->GetAttrPool(), bWeb ? nRange1 : nRange2 );
645 
647  SvtLinguOptions aLinguOpt;
648 
650  SvtLinguConfig().GetOptions(aLinguOpt);
651 
652  LanguageType nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN),
653  eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN),
654  eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX);
655  aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) );
656  aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) );
657  aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) );
658 
659  if(!bWeb)
660  {
661  SvxHyphenZoneItem aHyp( m_xDoc->GetDefault(RES_PARATR_HYPHENZONE) );
662  aHyp.GetMinLead() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading);
663  aHyp.GetMinTrail() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing);
664 
665  aDfltSet.Put( aHyp );
666 
667  sal_uInt16 nNewPos = o3tl::toTwips(SW_MOD()->GetUsrPref(false)->GetDefTabInMm100(), o3tl::Length::mm100);
668  if( nNewPos )
669  aDfltSet.Put( SvxTabStopItem( 1, nNewPos,
670  SvxTabAdjust::Default, RES_PARATR_TABSTOP ) );
671  }
672  aDfltSet.Put( SvxColorItem( COL_AUTO, RES_CHRATR_COLOR ) );
673 
674  m_xDoc->SetDefault( aDfltSet );
675 
676  //default page mode for text grid
677  if(!bWeb)
678  {
679  bool bSquaredPageMode = SW_MOD()->GetUsrPref(false)->IsSquaredPageMode();
680  m_xDoc->SetDefaultPageMode( bSquaredPageMode );
681 
682  // only set Widow/Orphan defaults on a new, non-web document - not an opened one
683  if( GetMedium() && GetMedium()->GetOrigURL().isEmpty() )
684  {
685  m_xDoc->SetDefault( SvxWidowsItem( sal_uInt8(2), RES_PARATR_WIDOWS) );
686  m_xDoc->SetDefault( SvxOrphansItem( sal_uInt8(2), RES_PARATR_ORPHANS) );
687  }
688  }
689 
690  m_xDoc->getIDocumentState().ResetModified();
691 }
692 
693 /*
694  * Document Interface Access
695  */
697 {
698  return m_xDoc->getIDocumentDeviceAccess();
699 }
700 
702 {
703  return m_xDoc->getIDocumentChartDataProviderAccess();
704 }
705 
706 /* 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:617
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:416
#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:574
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:1189
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:362
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
static bool IsFuzzing()
SfxObjectCreateMode GetCreateMode() const
virtual void SAL_CALL dispose() override
Definition: unochart.cxx:1356
SAL_DLLPRIVATE void Init_Impl()
Definition: docshini.cxx:383
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:204
#define FONT_INDEX_CJK
Definition: fontcfg.hxx:36
SwDocShell(SfxObjectCreateMode eMode=SfxObjectCreateMode::EMBEDDED)
Doc is required for SO data exchange!
Definition: docshini.cxx:319
#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:431
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:696
bool IsError() const
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
void InvalidateModel()
Definition: docshini.cxx:448
LanguageType GetLanguage() const
static void InitOle(SfxObjectShell *pDoc)
Definition: swdtflvr.cxx:348
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:701
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:462
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:397
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:454
SfxMedium * GetMedium() const