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