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