1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docshini.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
37 #ifndef _SVX_DIALOGS_HRC
38 #include <svx/dialogs.hrc>
40 #include <i18npool/mslangid.hxx>
41 #include <sot/storinfo.hxx>
42 #include <sot/storage.hxx>
43 #include <svtools/zforlist.hxx>
44 #include <svtools/ctrltool.hxx>
45 #include <svtools/lingucfg.hxx>
46 #include <sfx2/docfile.hxx>
47 #ifndef _OFA_MISCCFG_HXX //autogen
48 #include <svtools/misccfg.hxx>
50 #include <sfx2/printer.hxx>
51 #include <sfx2/bindings.hxx>
52 #include <svx/asiancfg.hxx>
53 #include <svx/unolingu.hxx>
54 #include <sfx2/request.hxx>
55 #include <svtools/intitem.hxx>
56 #include <svx/adjitem.hxx>
57 #ifndef _SVX_AKRNTEM_HXX
58 #include <svx/akrnitem.hxx>
60 #include <linguistic/lngprops.hxx>
61 #include <com/sun/star/document/UpdateDocMode.hpp>
62 #include <com/sun/star/i18n/ScriptType.hpp>
63 #include <rtl/logfile.hxx>
64 #include <sfx2/docfilt.hxx>
65 #include <svx/xtable.hxx>
66 #ifndef _SVX_DRAWITEM_HXX //autogen
68 #include <svx/drawitem.hxx>
70 #include <svx/fhgtitem.hxx>
71 #include <svx/fontitem.hxx>
72 #include <svx/flstitem.hxx>
73 #ifndef _SVX_TSTPITEM_HXX //autogen
74 #include <svx/tstpitem.hxx>
76 #include <svx/langitem.hxx>
77 #include <svx/colritem.hxx>
78 #include <svx/hyznitem.hxx>
79 #include <svx/svxacorr.hxx>
81 #include <vcl/svapp.hxx>
91 #include <swmodule.hxx>
94 #include <docstyle.hxx>
95 #include <shellio.hxx>
97 #include <swdtflvr.hxx>
101 #include <usrpref.hxx>
102 #include <fontcfg.hxx>
103 #include <poolfmt.hxx>
105 #include <modcfg.hxx>
108 #include <globdoc.hxx>
111 #include <mdiexp.hxx>
112 #include <unotxdoc.hxx>
113 #include <linkenum.hxx>
114 #include <swwait.hxx>
118 #include <globals.hrc>
123 #include <fmtfollowtextflow.hxx>
125 #include <unochart.hxx>
128 #include <tgrditem.hxx>
130 using namespace ::com::sun::star::i18n
;
131 using namespace ::com::sun::star::lang
;
132 using namespace ::com::sun::star::uno
;
133 using namespace ::com::sun::star
;
134 using ::rtl::OUString
;
136 /*-----------------21.09.96 15.29-------------------
138 --------------------------------------------------*/
141 /*--------------------------------------------------------------------
142 Beschreibung: Document laden
143 --------------------------------------------------------------------*/
146 sal_Bool
SwDocShell::InitNew( const uno::Reference
< embed::XStorage
>& xStor
)
148 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDocShell::InitNew" );
150 sal_Bool bRet
= SfxObjectShell::InitNew( xStor
);
151 ASSERT( GetMapUnit() == MAP_TWIP
, "map unit is not twip!" );
152 sal_Bool bHTMLTemplSet
= sal_False
;
155 AddLink(); // pDoc / pIo ggf. anlegen
157 sal_Bool bWeb
= ISA( SwWebDocShell
);
159 bHTMLTemplSet
= SetHTMLTemplate( *GetDoc() );//Styles aus HTML.vor
160 else if( ISA( SwGlobalDocShell
) )
161 GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT
, true); // Globaldokument
165 //JP 12.07.95: so einfach waere es fuer die neu Mimik
166 pDoc->SetDefault( SvxTabStopItem( 1,
167 GetStar Writer App()->GetUsrPref()->GetDefTabDist(),
168 SVX_TAB_ADJUST_DEFAULT,
169 RES_PARATR_TABSTOP));
171 if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
172 SwTransferable::InitOle( this, *pDoc
);
174 // set forbidden characters if necessary
175 SvxAsianConfig aAsian
;
176 Sequence
<Locale
> aLocales
= aAsian
.GetStartEndCharLocales();
177 if(aLocales
.getLength())
179 const Locale
* pLocales
= aLocales
.getConstArray();
180 for(sal_Int32 i
= 0; i
< aLocales
.getLength(); i
++)
182 ForbiddenCharacters aForbidden
;
183 aAsian
.GetStartEndChars( pLocales
[i
], aForbidden
.beginLine
, aForbidden
.endLine
);
184 LanguageType eLang
= SvxLocaleToLanguage(pLocales
[i
]);
185 pDoc
->setForbiddenCharacters( eLang
, aForbidden
);
188 pDoc
->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION
,
189 !aAsian
.IsKerningWesternTextOnly());
190 pDoc
->setCharacterCompressionType(static_cast<SwCharCompressType
>(aAsian
.GetCharDistanceCompression()));
191 pDoc
->setPrintData(*SW_MOD()->GetPrtOptions(bWeb
));
197 SwStdFontConfig
* pStdFont
= SW_MOD()->GetStdFontConfig();
198 SfxPrinter
* pPrt
= pDoc
->getPrinter( false );
201 USHORT aFontWhich
[] =
206 USHORT aFontHeightWhich
[] =
209 RES_CHRATR_CJK_FONTSIZE
,
210 RES_CHRATR_CTL_FONTSIZE
218 USHORT nFontTypes
[] =
220 DEFAULTFONT_LATIN_TEXT
,
221 DEFAULTFONT_CJK_TEXT
,
224 USHORT aLangTypes
[] =
227 RES_CHRATR_CJK_LANGUAGE
,
228 RES_CHRATR_CTL_LANGUAGE
231 for(sal_uInt8 i
= 0; i
< 3; i
++)
233 USHORT nFontWhich
= aFontWhich
[i
];
234 USHORT nFontId
= aFontIds
[i
];
235 SvxFontItem
* pFontItem
= 0;
236 const SvxLanguageItem
& rLang
= (const SvxLanguageItem
&)pDoc
->GetDefault( aLangTypes
[i
] );
237 LanguageType eLanguage
= rLang
.GetLanguage();
238 if(!pStdFont
->IsFontDefault(nFontId
))
240 sEntry
= pStdFont
->GetFontFor(nFontId
);
241 sal_Bool bDelete
= sal_False
;
242 const SfxFont
* pFnt
= pPrt
? pPrt
->GetFontByName(sEntry
): 0;
245 pFnt
= new SfxFont( FAMILY_DONTKNOW
, sEntry
, PITCH_DONTKNOW
,
246 ::gsl_getSystemTextEncoding() );
249 pFontItem
= new SvxFontItem(pFnt
->GetFamily(), pFnt
->GetName(),
250 aEmptyStr
, pFnt
->GetPitch(), pFnt
->GetCharSet(), nFontWhich
);
253 delete (SfxFont
*) pFnt
;
259 // #107782# OJ use korean language if latin was used
262 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguage();
263 switch( eUiLanguage
)
265 case LANGUAGE_KOREAN
:
266 case LANGUAGE_KOREAN_JOHAB
:
267 eLanguage
= eUiLanguage
;
272 Font aLangDefFont
= OutputDevice::GetDefaultFont(
275 DEFAULTFONT_FLAGS_ONLYONE
);
276 pFontItem
= new SvxFontItem(aLangDefFont
.GetFamily(), aLangDefFont
.GetName(),
277 aEmptyStr
, aLangDefFont
.GetPitch(), aLangDefFont
.GetCharSet(), nFontWhich
);
279 pDoc
->SetDefault(*pFontItem
);
282 SwTxtFmtColl
*pColl
= pDoc
->GetTxtCollFromPool(RES_POOLCOLL_STANDARD
);
283 pColl
->ResetFmtAttr(nFontWhich
);
286 sal_Int32 nFontHeight
= pStdFont
->GetFontHeight( FONT_STANDARD
, i
, eLanguage
);
288 nFontHeight
= pStdFont
->GetDefaultHeightFor( nFontId
, eLanguage
);
289 pDoc
->SetDefault(SvxFontHeightItem( nFontHeight
, 100, aFontHeightWhich
[i
] ));
292 SwTxtFmtColl
*pColl
= pDoc
->GetTxtCollFromPool(RES_POOLCOLL_STANDARD
);
293 pColl
->ResetFmtAttr(aFontHeightWhich
[i
]);
297 USHORT aFontIdPoolId
[] =
299 FONT_OUTLINE
, RES_POOLCOLL_HEADLINE_BASE
,
300 FONT_LIST
, RES_POOLCOLL_NUMBUL_BASE
,
301 FONT_CAPTION
, RES_POOLCOLL_LABEL
,
302 FONT_INDEX
, RES_POOLCOLL_REGISTER_BASE
,
303 FONT_OUTLINE_CJK
, RES_POOLCOLL_HEADLINE_BASE
,
304 FONT_LIST_CJK
, RES_POOLCOLL_NUMBUL_BASE
,
305 FONT_CAPTION_CJK
, RES_POOLCOLL_LABEL
,
306 FONT_INDEX_CJK
, RES_POOLCOLL_REGISTER_BASE
,
307 FONT_OUTLINE_CTL
, RES_POOLCOLL_HEADLINE_BASE
,
308 FONT_LIST_CTL
, RES_POOLCOLL_NUMBUL_BASE
,
309 FONT_CAPTION_CTL
, RES_POOLCOLL_LABEL
,
310 FONT_INDEX_CTL
, RES_POOLCOLL_REGISTER_BASE
313 USHORT nFontWhich
= RES_CHRATR_FONT
;
314 USHORT nFontHeightWhich
= RES_CHRATR_FONTSIZE
;
315 LanguageType eLanguage
= static_cast<const SvxLanguageItem
&>(pDoc
->GetDefault( RES_CHRATR_LANGUAGE
)).GetLanguage();
316 for(sal_uInt8 nIdx
= 0; nIdx
< 24; nIdx
+= 2)
320 nFontWhich
= RES_CHRATR_CJK_FONT
;
321 nFontHeightWhich
= RES_CHRATR_CJK_FONTSIZE
;
322 eLanguage
= static_cast<const SvxLanguageItem
&>(pDoc
->GetDefault( RES_CHRATR_CJK_LANGUAGE
)).GetLanguage();
326 nFontWhich
= RES_CHRATR_CTL_FONT
;
327 nFontHeightWhich
= RES_CHRATR_CTL_FONTSIZE
;
328 eLanguage
= static_cast<const SvxLanguageItem
&>(pDoc
->GetDefault( RES_CHRATR_CTL_LANGUAGE
)).GetLanguage();
330 SwTxtFmtColl
*pColl
= 0;
331 if(!pStdFont
->IsFontDefault(aFontIdPoolId
[nIdx
]))
333 sEntry
= pStdFont
->GetFontFor(aFontIdPoolId
[nIdx
]);
334 sal_Bool bDelete
= sal_False
;
335 const SfxFont
* pFnt
= pPrt
? pPrt
->GetFontByName(sEntry
): 0;
338 pFnt
= new SfxFont( FAMILY_DONTKNOW
, sEntry
, PITCH_DONTKNOW
,
339 ::gsl_getSystemTextEncoding() );
342 pColl
= pDoc
->GetTxtCollFromPool(aFontIdPoolId
[nIdx
+ 1]);
343 if( !bHTMLTemplSet
||
344 SFX_ITEM_SET
!= pColl
->GetAttrSet().GetItemState(
345 nFontWhich
, sal_False
) )
347 pColl
->SetFmtAttr(SvxFontItem(pFnt
->GetFamily(), pFnt
->GetName(),
348 aEmptyStr
, pFnt
->GetPitch(), pFnt
->GetCharSet(), nFontWhich
));
352 delete (SfxFont
*) pFnt
;
355 sal_Int32 nFontHeight
= pStdFont
->GetFontHeight( static_cast< sal_Int8
>(aFontIdPoolId
[nIdx
]), 0, eLanguage
);
357 nFontHeight
= pStdFont
->GetDefaultHeightFor( aFontIdPoolId
[nIdx
], eLanguage
);
359 pColl
= pDoc
->GetTxtCollFromPool(aFontIdPoolId
[nIdx
+ 1]);
360 SvxFontHeightItem
aFontHeight( (const SvxFontHeightItem
&)pColl
->GetFmtAttr( nFontHeightWhich
, sal_True
));
361 if(aFontHeight
.GetHeight() != sal::static_int_cast
<sal_uInt32
, sal_Int32
>(nFontHeight
))
363 aFontHeight
.SetHeight(nFontHeight
);
364 pColl
->SetFmtAttr( aFontHeight
);
369 /* #106748# If the default frame direction of a document is RTL
370 the default adjusment is to the right. */
371 if( !bHTMLTemplSet
&&
372 FRMDIR_HORI_RIGHT_TOP
== GetDefaultFrameDirection(GetAppLanguage()) )
373 pDoc
->SetDefault( SvxAdjustItem(SVX_ADJUST_RIGHT
, RES_PARATR_ADJUST
) );
375 // OD 09.10.2003 #i18732# - set dynamic pool default for
376 // item RES_FOLLOW_TEXT_FLOW to FALSE for *new document*.
377 // Thus, redo this change in method <SwDoc::RemoveAllFmtLanguageDependencies()>,
378 // which is called from <SwDocShell::ConvertFrom(..)> in order to restore
379 // the static pool default.
380 pDoc
->SetDefault( SwFmtFollowTextFlow( FALSE
) );
382 // --> collapsing borders FME 2005-05-27 #i29550#
383 pDoc
->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS
, TRUE
) );
386 //#i16874# AutoKerning as default for new documents
387 pDoc
->SetDefault( SvxAutoKernItem( sal_True
, RES_CHRATR_AUTOKERN
) );
389 // --> OD 2005-02-10 #i42080# - Due to the several calls of method <SetDefault(..)>
390 // at the document instance, the document is modified. Thus, reset this
391 // status here. Note: In method <SubInitNew()> this is also done.
392 pDoc
->ResetModified();
398 /*--------------------------------------------------------------------
399 Beschreibung: Ctor mit SfxCreateMode ?????
400 --------------------------------------------------------------------*/
403 SwDocShell::SwDocShell( SfxObjectCreateMode eMode
, sal_Bool _bScriptingSupport
) :
404 SfxObjectShell ( eMode
),
410 nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG
),
411 bInUpdateFontList(false)
413 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDocShell::SwDocShell" );
414 if ( !_bScriptingSupport
)
419 /*--------------------------------------------------------------------
420 Beschreibung: Ctor / Dtor
421 --------------------------------------------------------------------*/
424 SwDocShell::SwDocShell( SwDoc
*pD
, SfxObjectCreateMode eMode
):
425 SfxObjectShell ( eMode
),
431 nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG
),
432 bInUpdateFontList(false)
434 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDocShell::SwDocShell" );
438 /*--------------------------------------------------------------------
440 --------------------------------------------------------------------*/
443 SwDocShell::~SwDocShell()
445 // disable chart related objects now because in ~SwDoc it may be to late for this
448 pDoc
->GetChartControllerHelper().Disconnect();
449 SwChartDataProvider
*pPCD
= pDoc
->GetChartDataProvider();
457 // wir als BroadCaster werden auch unser eigener Listener
458 // (fuer DocInfo/FileNamen/....)
459 EndListening( *this );
460 SvxColorTableItem
* pColItem
= (SvxColorTableItem
*)GetItem(SID_COLOR_TABLE
);
461 // wird nur die DocInfo fuer den Explorer gelesen, ist das Item nicht da
464 XColorTable
* pTable
= pColItem
->GetColorTable();
465 // wurde eine neue Table angelegt, muss sie auch geloescht werden.
466 if((void*)pTable
!= (void*)(XColorTable::GetStdColorTable()) )
470 delete pOLEChildList
;
472 /* -----------------------------10.09.2001 15:59------------------------------
474 ---------------------------------------------------------------------------*/
475 void SwDocShell::Init_Impl()
477 SetPool(&SW_MOD()->GetPool());
478 SetBaseModel(new SwXTextDocument(this));
479 // wir als BroadCaster werden auch unser eigener Listener
480 // (fuer DocInfo/FileNamen/....)
481 StartListening( *this );
482 //position of the "Automatic" style filter for the stylist (app.src)
483 SetAutoStyleFilterIndex(3);
485 // set map unit to twip
486 SetMapUnit( MAP_TWIP
);
488 /*--------------------------------------------------------------------
489 Beschreibung: AddLink
490 --------------------------------------------------------------------*/
493 void SwDocShell::AddLink()
498 pDoc
= aFactory
.GetDoc();
500 pDoc
->set(IDocumentSettingAccess::HTML_MODE
, ISA(SwWebDocShell
) );
504 pDoc
->SetDocShell( this ); // am Doc den DocShell-Pointer setzen
505 uno::Reference
< text::XTextDocument
> xDoc(GetBaseModel(), uno::UNO_QUERY
);
506 ((SwXTextDocument
*)xDoc
.get())->Reactivate(this);
508 SetPool(&pDoc
->GetAttrPool());
510 // am besten erst wenn eine sdbcx::View erzeugt wird !!!
511 pDoc
->SetOle2Link(LINK(this, SwDocShell
, Ole2ModifiedHdl
));
514 /*--------------------------------------------------------------------
515 Beschreibung: neue FontList erzeugen Aenderung Drucker
516 --------------------------------------------------------------------*/
519 void SwDocShell::UpdateFontList()
521 if(!bInUpdateFontList
)
523 bInUpdateFontList
= true;
524 ASSERT(pDoc
, "Kein Doc keine FontList");
528 pFontList
= new FontList( pDoc
->getReferenceDevice( true ) );
529 PutItem( SvxFontListItem( pFontList
, SID_ATTR_CHAR_FONTLIST
) );
531 bInUpdateFontList
= false;
535 /*--------------------------------------------------------------------
536 Beschreibung: RemoveLink
537 --------------------------------------------------------------------*/
540 void SwDocShell::RemoveLink()
542 // Uno-Object abklemmen
543 uno::Reference
< text::XTextDocument
> xDoc(GetBaseModel(), uno::UNO_QUERY
);
544 ((SwXTextDocument
*)xDoc
.get())->Invalidate();
545 aFinishedTimer
.Stop();
548 if( mxBasePool
.is() )
550 static_cast<SwDocStyleSheetPool
*>(mxBasePool
.get())->dispose();
553 sal_Int8 nRefCt
= static_cast< sal_Int8
>(pDoc
->release());
554 pDoc
->SetOle2Link(Link());
555 pDoc
->SetDocShell( 0 );
558 pDoc
= 0; // wir haben das Doc nicht mehr !!
561 void SwDocShell::InvalidateModel()
563 // Uno-Object abklemmen
564 uno::Reference
< text::XTextDocument
> xDoc(GetBaseModel(), uno::UNO_QUERY
);
565 ((SwXTextDocument
*)xDoc
.get())->Invalidate();
567 void SwDocShell::ReactivateModel()
569 // Uno-Object abklemmen
570 uno::Reference
< text::XTextDocument
> xDoc(GetBaseModel(), uno::UNO_QUERY
);
571 ((SwXTextDocument
*)xDoc
.get())->Reactivate(this);
574 /*--------------------------------------------------------------------
575 Beschreibung: Laden, Default-Format
576 --------------------------------------------------------------------*/
579 sal_Bool
SwDocShell::Load( SfxMedium
& rMedium
)
581 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDocShell::Load" );
582 sal_Bool bRet
= sal_False
;
583 if( SfxObjectShell::Load( rMedium
))
585 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "after SfxInPlaceObject::Load" );
586 if( pDoc
) // fuer Letzte Version !!
587 RemoveLink(); // das existierende Loslassen
589 AddLink(); // Link setzen und Daten updaten !!
593 ASSERT( !mxBasePool
.is(), "wer hat seinen Pool nicht zerstoert?" );
594 mxBasePool
= new SwDocStyleSheetPool( *pDoc
, SFX_CREATE_MODE_ORGANIZER
== GetCreateMode() );
595 if(GetCreateMode() != SFX_CREATE_MODE_ORGANIZER
)
597 SFX_ITEMSET_ARG( rMedium
.GetItemSet(), pUpdateDocItem
, SfxUInt16Item
, SID_UPDATEDOCMODE
, sal_False
);
598 nUpdateDocMode
= pUpdateDocItem
? pUpdateDocItem
->GetValue() : document::UpdateDocMode::NO_UPDATE
;
601 SwWait
aWait( *this, sal_True
);
602 sal_uInt32 nErr
= ERR_SWG_READ_ERROR
;
603 switch( GetCreateMode() )
605 // case SFX_CREATE_MODE_INTERNAL:
609 case SFX_CREATE_MODE_ORGANIZER
:
613 ReadXML
->SetOrganizerMode( TRUE
);
614 SwReader
aRdr( rMedium
, aEmptyStr
, pDoc
);
615 nErr
= aRdr
.Read( *ReadXML
);
616 ReadXML
->SetOrganizerMode( FALSE
);
621 case SFX_CREATE_MODE_INTERNAL
:
622 case SFX_CREATE_MODE_EMBEDDED
:
624 // fuer MWERKS (Mac-Compiler): kann nicht selbststaendig casten
625 SwTransferable::InitOle( this, *pDoc
);
627 // SfxProgress unterdruecken, wenn man Embedded ist
628 SW_MOD()->SetEmbeddedLoadSave( sal_True
);
631 case SFX_CREATE_MODE_STANDARD
:
632 case SFX_CREATE_MODE_PREVIEW
:
634 Reader
*pReader
= ReadXML
;
637 // die DocInfo vom Doc am DocShell-Medium setzen
638 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "before ReadDocInfo" );
639 SwReader
aRdr( rMedium
, aEmptyStr
, pDoc
);
640 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "before Read" );
641 nErr
= aRdr
.Read( *pReader
);
642 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "after Read" );
644 // If a XML document is loaded, the global doc/web doc
645 // flags have to be set, because they aren't loaded
647 if( ISA( SwWebDocShell
) )
649 if( !pDoc
->get(IDocumentSettingAccess::HTML_MODE
) )
650 pDoc
->set(IDocumentSettingAccess::HTML_MODE
, true);
652 if( ISA( SwGlobalDocShell
) )
654 if( !pDoc
->get(IDocumentSettingAccess::GLOBAL_DOCUMENT
) )
655 pDoc
->set(IDocumentSettingAccess::GLOBAL_DOCUMENT
, true);
660 ASSERT( !this, "ohne Sw3Reader geht nichts" );
666 ASSERT( !this, "Load: new CreateMode?" );
673 SetError( nErr
, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ) );
674 bRet
= !IsError( nErr
);
676 // --> OD 2006-11-07 #i59688#
677 // // StartFinishedLoading rufen.
678 // if( bRet && !pDoc->IsInLoadAsynchron() &&
679 // GetCreateMode() == SFX_CREATE_MODE_STANDARD )
680 // StartLoadFinishedTimer();
681 if ( bRet
&& !pDoc
->IsInLoadAsynchron() &&
682 GetCreateMode() == SFX_CREATE_MODE_STANDARD
)
688 // SfxProgress unterdruecken, wenn man Embedded ist
689 SW_MOD()->SetEmbeddedLoadSave( sal_False
);
695 /*--------------------------------------------------------------------
697 --------------------------------------------------------------------*/
700 sal_Bool
SwDocShell::LoadFrom( SfxMedium
& rMedium
)
702 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDocShell::LoadFrom" );
703 sal_Bool bRet
= sal_False
;
707 AddLink(); // Link setzen und Daten updaten !!
709 do { // middle check loop
710 sal_uInt32 nErr
= ERR_SWG_READ_ERROR
;
711 //const String& rNm = pStor->GetName();
713 aStreamName
= String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("styles.xml"));
714 uno::Reference
< container::XNameAccess
> xAccess( rMedium
.GetStorage(), uno::UNO_QUERY
);
715 if ( xAccess
->hasByName( aStreamName
) && rMedium
.GetStorage()->isStreamElement( aStreamName
) )
718 SwWait
aWait( *this, sal_True
);
720 ASSERT( !mxBasePool
.is(), "wer hat seinen Pool nicht zerstoert?" );
721 mxBasePool
= new SwDocStyleSheetPool( *pDoc
, SFX_CREATE_MODE_ORGANIZER
== GetCreateMode() );
724 ReadXML
->SetOrganizerMode( TRUE
);
725 SwReader
aRdr( rMedium
, aEmptyStr
, pDoc
);
726 nErr
= aRdr
.Read( *ReadXML
);
727 ReadXML
->SetOrganizerMode( FALSE
);
733 DBG_ERROR("Code removed!");
735 //TODO/LATER: looks like some binary stuff?!
736 // sollte es sich um eine 2. Vrolage handeln ??
737 if( SvStorage::IsStorageFile( rNm ) )
740 const SfxFilter* pFltr = SwIoSystem::GetFileFilter( rNm, aEmptyStr );
741 if( !pFltr || !pFltr->GetUserData().EqualsAscii( FILTER_SWG ))
744 SfxMedium aMed( rNm, STREAM_STD_READ, FALSE );
745 if( 0 == ( nErr = aMed.GetInStream()->GetError() ) )
747 SwWait aWait( *this, sal_True );
748 SwReader aRead( aMed, rNm, pDoc );
749 nErr = aRead.Read( *ReadSwg );
754 SetError( nErr
, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ) );
755 bRet
= !IsError( nErr
);
757 } while( sal_False
);
759 SfxObjectShell::LoadFrom( rMedium
);
760 pDoc
->ResetModified();
765 void SwDocShell::SubInitNew()
767 ASSERT( !mxBasePool
.is(), "wer hat seinen Pool nicht zerstoert?" );
768 mxBasePool
= new SwDocStyleSheetPool( *pDoc
, SFX_CREATE_MODE_ORGANIZER
== GetCreateMode() );
772 pDoc
->setLinkUpdateMode( GLOBALSETTING
);
773 pDoc
->setFieldUpdateFlags( AUTOUPD_GLOBALSETTING
);
775 sal_Bool bWeb
= ISA(SwWebDocShell
);
777 sal_uInt16 nRange
[] = {
778 RES_PARATR_ADJUST
, RES_PARATR_ADJUST
,
779 RES_CHRATR_COLOR
, RES_CHRATR_COLOR
,
780 RES_CHRATR_LANGUAGE
, RES_CHRATR_LANGUAGE
,
781 RES_CHRATR_CJK_LANGUAGE
, RES_CHRATR_CJK_LANGUAGE
,
782 RES_CHRATR_CTL_LANGUAGE
, RES_CHRATR_CTL_LANGUAGE
,
786 nRange
[ (sizeof(nRange
)/sizeof(nRange
[0])) - 3 ] = RES_PARATR_TABSTOP
;
787 nRange
[ (sizeof(nRange
)/sizeof(nRange
[0])) - 2 ] = RES_PARATR_HYPHENZONE
;
789 SfxItemSet
aDfltSet( pDoc
->GetAttrPool(), nRange
);
791 //! get lingu options without loading lingu DLL
792 SvtLinguOptions aLinguOpt
;
794 SvtLinguConfig().GetOptions( aLinguOpt
);
796 sal_Int16 nVal
= MsLangId::resolveSystemLanguageByScriptType(aLinguOpt
.nDefaultLanguage
, ::com::sun::star::i18n::ScriptType::LATIN
),
797 eCJK
= MsLangId::resolveSystemLanguageByScriptType(aLinguOpt
.nDefaultLanguage_CJK
, ::com::sun::star::i18n::ScriptType::ASIAN
),
798 eCTL
= MsLangId::resolveSystemLanguageByScriptType(aLinguOpt
.nDefaultLanguage_CTL
, ::com::sun::star::i18n::ScriptType::COMPLEX
);
799 aDfltSet
.Put( SvxLanguageItem( nVal
, RES_CHRATR_LANGUAGE
) );
800 aDfltSet
.Put( SvxLanguageItem( eCJK
, RES_CHRATR_CJK_LANGUAGE
) );
801 aDfltSet
.Put( SvxLanguageItem( eCTL
, RES_CHRATR_CTL_LANGUAGE
) );
805 SvxHyphenZoneItem
aHyp( (SvxHyphenZoneItem
&) pDoc
->GetDefault(
806 RES_PARATR_HYPHENZONE
) );
807 aHyp
.GetMinLead() = static_cast< BYTE
>(aLinguOpt
.nHyphMinLeading
);
808 aHyp
.GetMinTrail() = static_cast< BYTE
>(aLinguOpt
.nHyphMinTrailing
);
810 aDfltSet
.Put( aHyp
);
812 sal_uInt16 nNewPos
= static_cast< sal_uInt16
>(SW_MOD()->GetUsrPref(FALSE
)->GetDefTab());
814 aDfltSet
.Put( SvxTabStopItem( 1, nNewPos
,
815 SVX_TAB_ADJUST_DEFAULT
, RES_PARATR_TABSTOP
) );
817 aDfltSet
.Put( SvxColorItem( Color( COL_AUTO
), RES_CHRATR_COLOR
) );
819 pDoc
->SetDefault( aDfltSet
);
821 //default page mode for text grid
824 sal_Bool bSquaredPageMode
= SW_MOD()->GetUsrPref(FALSE
)->IsSquaredPageMode();
825 pDoc
->SetDefaultPageMode( bSquaredPageMode
);
828 pDoc
->ResetModified();
832 * Document Interface Access
834 IDocumentDeviceAccess
* SwDocShell::getIDocumentDeviceAccess() { return pDoc
; }
835 const IDocumentSettingAccess
* SwDocShell::getIDocumentSettingAccess() const { return pDoc
; }
836 IDocumentChartDataProviderAccess
* SwDocShell::getIDocumentChartDataProviderAccess() { return pDoc
; }