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