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