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