1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <hintids.hxx> 32*cdf0e10cSrcweir #include <rtl/logfile.hxx> 33*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34*cdf0e10cSrcweir #include <vcl/svapp.hxx> 35*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 36*cdf0e10cSrcweir #include <vcl/jobset.hxx> 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <svl/whiter.hxx> 39*cdf0e10cSrcweir #include <svl/zforlist.hxx> 40*cdf0e10cSrcweir #include <svl/eitem.hxx> 41*cdf0e10cSrcweir #include <svl/stritem.hxx> 42*cdf0e10cSrcweir #include <svl/PasswordHelper.hxx> 43*cdf0e10cSrcweir #include <editeng/adjitem.hxx> 44*cdf0e10cSrcweir #include <basic/sbx.hxx> 45*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 46*cdf0e10cSrcweir #include <unotools/misccfg.hxx> 47*cdf0e10cSrcweir #include <sfx2/request.hxx> 48*cdf0e10cSrcweir #include <sfx2/passwd.hxx> 49*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 50*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 51*cdf0e10cSrcweir #include <sfx2/evntconf.hxx> 52*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 53*cdf0e10cSrcweir #include <sfx2/printer.hxx> 54*cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 55*cdf0e10cSrcweir #include <svl/srchitem.hxx> 56*cdf0e10cSrcweir #include <editeng/flstitem.hxx> 57*cdf0e10cSrcweir #include <svx/htmlmode.hxx> 58*cdf0e10cSrcweir #include <svtools/soerr.hxx> 59*cdf0e10cSrcweir #include <sot/clsids.hxx> 60*cdf0e10cSrcweir #include <basic/basmgr.hxx> 61*cdf0e10cSrcweir #include <basic/sbmod.hxx> 62*cdf0e10cSrcweir #include <swevent.hxx> 63*cdf0e10cSrcweir #include <fmtpdsc.hxx> 64*cdf0e10cSrcweir #include <fmtfsize.hxx> 65*cdf0e10cSrcweir #include <fmtfld.hxx> 66*cdf0e10cSrcweir #include <node.hxx> 67*cdf0e10cSrcweir #include <swwait.hxx> 68*cdf0e10cSrcweir #include <printdata.hxx> 69*cdf0e10cSrcweir #include <frmatr.hxx> 70*cdf0e10cSrcweir #include <view.hxx> // fuer die aktuelle Sicht 71*cdf0e10cSrcweir #include <edtwin.hxx> 72*cdf0e10cSrcweir #include <PostItMgr.hxx> 73*cdf0e10cSrcweir #include <wrtsh.hxx> // Verbindung zur Core 74*cdf0e10cSrcweir #include <docsh.hxx> // Dokumenterzeugung 75*cdf0e10cSrcweir #include <basesh.hxx> 76*cdf0e10cSrcweir #include <viewopt.hxx> 77*cdf0e10cSrcweir #include <wdocsh.hxx> 78*cdf0e10cSrcweir #include <swmodule.hxx> 79*cdf0e10cSrcweir #include <globdoc.hxx> 80*cdf0e10cSrcweir #include <usrpref.hxx> 81*cdf0e10cSrcweir #include <shellio.hxx> // I/O 82*cdf0e10cSrcweir #include <docstyle.hxx> 83*cdf0e10cSrcweir #include <doc.hxx> 84*cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx> 85*cdf0e10cSrcweir #include <docstat.hxx> 86*cdf0e10cSrcweir #include <pagedesc.hxx> 87*cdf0e10cSrcweir #include <pview.hxx> 88*cdf0e10cSrcweir #include <mdiexp.hxx> 89*cdf0e10cSrcweir #include <swbaslnk.hxx> 90*cdf0e10cSrcweir #include <srcview.hxx> 91*cdf0e10cSrcweir #include <ndindex.hxx> 92*cdf0e10cSrcweir #include <ndole.hxx> 93*cdf0e10cSrcweir #include <swcli.hxx> 94*cdf0e10cSrcweir #include <txtftn.hxx> 95*cdf0e10cSrcweir #include <ftnidx.hxx> 96*cdf0e10cSrcweir #include <fldbas.hxx> 97*cdf0e10cSrcweir #include <docary.hxx> 98*cdf0e10cSrcweir #include <swerror.h> // Fehlermeldungen 99*cdf0e10cSrcweir #include <helpid.h> 100*cdf0e10cSrcweir #include <cmdid.h> 101*cdf0e10cSrcweir #include <globals.hrc> 102*cdf0e10cSrcweir #include <app.hrc> 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir #include <cfgid.h> 105*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 106*cdf0e10cSrcweir #include <unotools/fltrcfg.hxx> 107*cdf0e10cSrcweir #include <svtools/htmlcfg.hxx> 108*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 109*cdf0e10cSrcweir #include <sfx2/objface.hxx> 110*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir #define SwDocShell 113*cdf0e10cSrcweir #include <sfx2/msg.hxx> 114*cdf0e10cSrcweir #include <swslots.hxx> 115*cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp> 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 118*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir #include <unomid.h> 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir #include <sfx2/Metadatable.hxx> 123*cdf0e10cSrcweir #include <switerator.hxx> 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir using rtl::OUString; 126*cdf0e10cSrcweir using namespace ::com::sun::star; 127*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 128*cdf0e10cSrcweir using namespace ::com::sun::star::script; 129*cdf0e10cSrcweir using namespace ::com::sun::star::container; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir SFX_IMPL_INTERFACE( SwDocShell, SfxObjectShell, SW_RES(0) ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION( SID_HYPERLINK_INSERT ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir TYPEINIT2(SwDocShell, SfxObjectShell, SfxListener); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir //------------------------------------------------------------------------- 140*cdf0e10cSrcweir SFX_IMPL_OBJECTFACTORY(SwDocShell, SvGlobalName(SO3_SW_CLASSID), SFXOBJECTSHELL_STD_NORMAL|SFXOBJECTSHELL_HASMENU, "swriter" ) 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /*-------------------------------------------------------------------- 143*cdf0e10cSrcweir Beschreibung: Laden vorbereiten 144*cdf0e10cSrcweir --------------------------------------------------------------------*/ 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, 148*cdf0e10cSrcweir SwCrsrShell *pCrsrShell, 149*cdf0e10cSrcweir SwPaM* pPaM ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir sal_Bool bAPICall = sal_False; 152*cdf0e10cSrcweir const SfxPoolItem* pApiItem; 153*cdf0e10cSrcweir const SfxItemSet* pMedSet; 154*cdf0e10cSrcweir if( 0 != ( pMedSet = rMedium.GetItemSet() ) && SFX_ITEM_SET == 155*cdf0e10cSrcweir pMedSet->GetItemState( FN_API_CALL, sal_True, &pApiItem ) ) 156*cdf0e10cSrcweir bAPICall = ((const SfxBoolItem*)pApiItem)->GetValue(); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir const SfxFilter* pFlt = rMedium.GetFilter(); 159*cdf0e10cSrcweir if( !pFlt ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir if(!bAPICall) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir InfoBox( 0, SW_RESSTR(STR_CANTOPEN)).Execute(); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir return 0; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir String aFileName( rMedium.GetName() ); 168*cdf0e10cSrcweir SwRead pRead = SwReaderWriter::GetReader( pFlt->GetUserData() ); 169*cdf0e10cSrcweir if( !pRead ) 170*cdf0e10cSrcweir return 0; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if( rMedium.IsStorage() 173*cdf0e10cSrcweir ? SW_STORAGE_READER & pRead->GetReaderType() 174*cdf0e10cSrcweir : SW_STREAM_READER & pRead->GetReaderType() ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir *ppRdr = pPaM ? new SwReader( rMedium, aFileName, *pPaM ) : 177*cdf0e10cSrcweir pCrsrShell ? 178*cdf0e10cSrcweir new SwReader( rMedium, aFileName, *pCrsrShell->GetCrsr() ) 179*cdf0e10cSrcweir : new SwReader( rMedium, aFileName, pDoc ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir else 182*cdf0e10cSrcweir return 0; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir // PassWord Checken 185*cdf0e10cSrcweir String aPasswd; 186*cdf0e10cSrcweir if ((*ppRdr)->NeedsPasswd( *pRead )) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir if(!bAPICall) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir SfxPasswordDialog* pPasswdDlg = 191*cdf0e10cSrcweir new SfxPasswordDialog( 0 ); 192*cdf0e10cSrcweir if(RET_OK == pPasswdDlg->Execute()) 193*cdf0e10cSrcweir aPasswd = pPasswdDlg->GetPassword(); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir else 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir const SfxItemSet* pSet = rMedium.GetItemSet(); 198*cdf0e10cSrcweir const SfxPoolItem *pPassItem; 199*cdf0e10cSrcweir if(pSet && SFX_ITEM_SET == pSet->GetItemState(SID_PASSWORD, sal_True, &pPassItem)) 200*cdf0e10cSrcweir aPasswd = ((const SfxStringItem *)pPassItem)->GetValue(); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir if (!(*ppRdr)->CheckPasswd( aPasswd, *pRead )) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir InfoBox( 0, SW_RES(MSG_ERROR_PASSWD)).Execute(); 206*cdf0e10cSrcweir delete *ppRdr; 207*cdf0e10cSrcweir return 0; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir // #i30171# set the UpdateDocMode at the SwDocShell 212*cdf0e10cSrcweir SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); 213*cdf0e10cSrcweir nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir if( pFlt->GetDefaultTemplate().Len() ) 216*cdf0e10cSrcweir pRead->SetTemplateName( pFlt->GetDefaultTemplate() ); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if( pRead == ReadAscii && 0 != rMedium.GetInStream() && 219*cdf0e10cSrcweir pFlt->GetUserData().EqualsAscii( FILTER_TEXT_DLG ) ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir SwAsciiOptions aOpt; 222*cdf0e10cSrcweir const SfxItemSet* pSet; 223*cdf0e10cSrcweir const SfxPoolItem* pItem; 224*cdf0e10cSrcweir if( 0 != ( pSet = rMedium.GetItemSet() ) && SFX_ITEM_SET == 225*cdf0e10cSrcweir pSet->GetItemState( SID_FILE_FILTEROPTIONS, sal_True, &pItem ) ) 226*cdf0e10cSrcweir aOpt.ReadUserData( ((const SfxStringItem*)pItem)->GetValue() ); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir if( pRead ) 229*cdf0e10cSrcweir pRead->GetReaderOpt().SetASCIIOpts( aOpt ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir return pRead; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir /*-------------------------------------------------------------------- 236*cdf0e10cSrcweir Beschreibung: Laden 237*cdf0e10cSrcweir --------------------------------------------------------------------*/ 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir sal_Bool SwDocShell::ConvertFrom( SfxMedium& rMedium ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::ConvertFrom" ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir SwReader* pRdr; 244*cdf0e10cSrcweir SwRead pRead = StartConvertFrom(rMedium, &pRdr); 245*cdf0e10cSrcweir if (!pRead) 246*cdf0e10cSrcweir return sal_False; // #129881# return if no reader is found 247*cdf0e10cSrcweir SotStorageRef pStg=pRead->getSotStorageRef(); // #i45333# save sot storage ref in case of recursive calls 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir SwWait aWait( *this, sal_True ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir // SfxProgress unterdruecken, wenn man Embedded ist 252*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( 253*cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED == GetCreateMode() ); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir pRdr->GetDoc()->set(IDocumentSettingAccess::HTML_MODE, ISA(SwWebDocShell)); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir /* #106748# Restore the pool default if reading a saved document. */ 258*cdf0e10cSrcweir pDoc->RemoveAllFmtLanguageDependencies(); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir sal_uLong nErr = pRdr->Read( *pRead ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // Evtl. ein altes Doc weg 263*cdf0e10cSrcweir if ( pDoc != pRdr->GetDoc() ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir if( pDoc ) 266*cdf0e10cSrcweir RemoveLink(); 267*cdf0e10cSrcweir pDoc = pRdr->GetDoc(); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir AddLink(); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir if ( !mxBasePool.is() ) 272*cdf0e10cSrcweir mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir UpdateFontList(); 276*cdf0e10cSrcweir InitDraw(); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir delete pRdr; 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( sal_False ); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 283*cdf0e10cSrcweir sal_Bool bOk = !IsError( nErr ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir // --> OD 2006-11-07 #i59688# 286*cdf0e10cSrcweir // // StartFinishedLoading rufen. Nicht bei asynchronen Filtern! 287*cdf0e10cSrcweir // // Diese muessen das selbst rufen! 288*cdf0e10cSrcweir // if( bOk && !pDoc->IsInLoadAsynchron() ) 289*cdf0e10cSrcweir // StartLoadFinishedTimer(); 290*cdf0e10cSrcweir if ( bOk && !pDoc->IsInLoadAsynchron() ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir LoadingFinished(); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir // <-- 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir pRead->setSotStorageRef(pStg); // #i45333# save sot storage ref in case of recursive calls 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir return bOk; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir /*-------------------------------------------------------------------- 302*cdf0e10cSrcweir Beschreibung: Sichern des Default-Formats, Stg vorhanden 303*cdf0e10cSrcweir --------------------------------------------------------------------*/ 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir sal_Bool SwDocShell::Save() 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::Save" ); 309*cdf0e10cSrcweir //#i3370# remove quick help to prevent saving of autocorrection suggestions 310*cdf0e10cSrcweir if(pView) 311*cdf0e10cSrcweir pView->GetEditWin().StopQuickHelp(); 312*cdf0e10cSrcweir SwWait aWait( *this, sal_True ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir CalcLayoutForOLEObjects(); // format for OLE objets 315*cdf0e10cSrcweir // --> OD 2006-03-17 #i62875# 316*cdf0e10cSrcweir // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible 317*cdf0e10cSrcweir if ( pWrtShell && pDoc && 318*cdf0e10cSrcweir pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && 319*cdf0e10cSrcweir docfunc::AllDrawObjsOnPage( *pDoc ) ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir // <-- 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir sal_uLong nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE; 326*cdf0e10cSrcweir if( SfxObjectShell::Save() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir switch( GetCreateMode() ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir case SFX_CREATE_MODE_INTERNAL: 331*cdf0e10cSrcweir nErr = 0; 332*cdf0e10cSrcweir break; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir case SFX_CREATE_MODE_ORGANIZER: 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir WriterRef xWrt; 337*cdf0e10cSrcweir ::GetXMLWriter( aEmptyStr, GetMedium()->GetBaseURL( true ), xWrt ); 338*cdf0e10cSrcweir xWrt->SetOrganizerMode( sal_True ); 339*cdf0e10cSrcweir SwWriter aWrt( *GetMedium(), *pDoc ); 340*cdf0e10cSrcweir nErr = aWrt.Write( xWrt ); 341*cdf0e10cSrcweir xWrt->SetOrganizerMode( sal_False ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir break; 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir case SFX_CREATE_MODE_EMBEDDED: 346*cdf0e10cSrcweir // SfxProgress unterdruecken, wenn man Embedded ist 347*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( sal_True ); 348*cdf0e10cSrcweir // kein break; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir case SFX_CREATE_MODE_STANDARD: 351*cdf0e10cSrcweir case SFX_CREATE_MODE_PREVIEW: 352*cdf0e10cSrcweir default: 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir if( pDoc->ContainsMSVBasic() ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir //TODO/MBA: it looks as that this code can be removed! 357*cdf0e10cSrcweir //SvxImportMSVBasic aTmp( *this, pIo->GetStorage() ); 358*cdf0e10cSrcweir //aTmp.SaveOrDelMSVBAStorage( sal_False, aEmptyStr ); 359*cdf0e10cSrcweir if( SvtFilterOptions::Get()->IsLoadWordBasicStorage() ) 360*cdf0e10cSrcweir nVBWarning = GetSaveWarningOfMSVBAStorage( (SfxObjectShell&) (*this) ); 361*cdf0e10cSrcweir pDoc->SetContainsMSVBasic( sal_False ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir // TabellenBox Edit beenden! 365*cdf0e10cSrcweir if( pWrtShell ) 366*cdf0e10cSrcweir pWrtShell->EndAllTblBoxEdit(); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir WriterRef xWrt; 369*cdf0e10cSrcweir ::GetXMLWriter( aEmptyStr, GetMedium()->GetBaseURL( true ), xWrt ); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir sal_Bool bLockedView(sal_False); 372*cdf0e10cSrcweir if ( pWrtShell ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir bLockedView = pWrtShell->IsViewLocked(); 375*cdf0e10cSrcweir pWrtShell->LockView( sal_True ); //lock visible section 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir SwWriter aWrt( *GetMedium(), *pDoc ); 379*cdf0e10cSrcweir nErr = aWrt.Write( xWrt ); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir if ( pWrtShell ) 382*cdf0e10cSrcweir pWrtShell->LockView( bLockedView ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( sal_False ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir SetError( nErr ? nErr : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir SfxViewFrame* pFrm = pWrtShell ? pWrtShell->GetView().GetViewFrame() : 0; 391*cdf0e10cSrcweir if( pFrm ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir pFrm->GetBindings().SetState( SfxStringItem( SID_DOC_MODIFIED, ' ' )); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir return !IsError( nErr ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir /*-------------------------------------------------------------------- 399*cdf0e10cSrcweir Beschreibung: Sichern im Defaultformat 400*cdf0e10cSrcweir --------------------------------------------------------------------*/ 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::SaveAs" ); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir SwWait aWait( *this, sal_True ); 408*cdf0e10cSrcweir //#i3370# remove quick help to prevent saving of autocorrection suggestions 409*cdf0e10cSrcweir if(pView) 410*cdf0e10cSrcweir pView->GetEditWin().StopQuickHelp(); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir //#i91811# mod if we have an active margin window, write back the text 413*cdf0e10cSrcweir if ( pView && 414*cdf0e10cSrcweir pView->GetPostItMgr() && 415*cdf0e10cSrcweir pView->GetPostItMgr()->HasActiveSidebarWin() ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir pView->GetPostItMgr()->UpdateDataOnActiveSidebarWin(); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if( pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) && 421*cdf0e10cSrcweir !pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS) ) 422*cdf0e10cSrcweir RemoveOLEObjects(); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir // Task 75666 - is the Document imported by our Microsoft-Filters? 426*cdf0e10cSrcweir const SfxFilter* pOldFilter = GetMedium()->GetFilter(); 427*cdf0e10cSrcweir if( pOldFilter && 428*cdf0e10cSrcweir ( pOldFilter->GetUserData().EqualsAscii( FILTER_WW8 ) || 429*cdf0e10cSrcweir pOldFilter->GetUserData().EqualsAscii( "CWW6" ) || 430*cdf0e10cSrcweir pOldFilter->GetUserData().EqualsAscii( "WW6" ) || 431*cdf0e10cSrcweir pOldFilter->GetUserData().EqualsAscii( "WW1" ) )) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir // when saving it in our own fileformat, then remove the template 434*cdf0e10cSrcweir // name from the docinfo. 435*cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 436*cdf0e10cSrcweir GetModel(), uno::UNO_QUERY_THROW); 437*cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps 438*cdf0e10cSrcweir = xDPS->getDocumentProperties(); 439*cdf0e10cSrcweir xDocProps->setTemplateName(::rtl::OUString::createFromAscii("")); 440*cdf0e10cSrcweir xDocProps->setTemplateURL(::rtl::OUString::createFromAscii("")); 441*cdf0e10cSrcweir xDocProps->setTemplateDate(::util::DateTime()); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir CalcLayoutForOLEObjects(); // format for OLE objets 446*cdf0e10cSrcweir // --> OD 2006-03-17 #i62875# 447*cdf0e10cSrcweir // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible 448*cdf0e10cSrcweir if ( pWrtShell && pDoc && 449*cdf0e10cSrcweir pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && 450*cdf0e10cSrcweir docfunc::AllDrawObjsOnPage( *pDoc ) ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir // <-- 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir sal_uLong nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE; 457*cdf0e10cSrcweir uno::Reference < embed::XStorage > xStor = rMedium.GetOutputStorage(); 458*cdf0e10cSrcweir if( SfxObjectShell::SaveAs( rMedium ) ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir if( GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) && !ISA( SwGlobalDocShell ) ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir // This is to set the correct class id if SaveAs is 463*cdf0e10cSrcweir // called from SwDoc::SplitDoc to save a normal doc as 464*cdf0e10cSrcweir // global doc. In this case, SaveAs is called at a 465*cdf0e10cSrcweir // normal doc shell, therefore, SfxInplaceObject::SaveAs 466*cdf0e10cSrcweir // will set the wrong class id. 467*cdf0e10cSrcweir SvGlobalName aClassName; 468*cdf0e10cSrcweir String aAppName, aLongUserName, aUserName; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir // The document is closed explicitly, but using SfxObjectShellLock is still more correct here 471*cdf0e10cSrcweir SfxObjectShellLock xDocSh = 472*cdf0e10cSrcweir new SwGlobalDocShell( SFX_CREATE_MODE_INTERNAL ); 473*cdf0e10cSrcweir // the global document can not be a template 474*cdf0e10cSrcweir xDocSh->SetupStorage( xStor, SotStorage::GetVersion( xStor ), sal_False ); 475*cdf0e10cSrcweir xDocSh->DoClose(); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir if( pDoc->ContainsMSVBasic() ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir //TODO/MBA: it looks as that this code can be removed! 481*cdf0e10cSrcweir //SvxImportMSVBasic aTmp( *this, pIo->GetStorage() ); 482*cdf0e10cSrcweir //aTmp.SaveOrDelMSVBAStorage( sal_False, aEmptyStr ); 483*cdf0e10cSrcweir if( SvtFilterOptions::Get()->IsLoadWordBasicStorage() ) 484*cdf0e10cSrcweir nVBWarning = GetSaveWarningOfMSVBAStorage( (SfxObjectShell&) *this ); 485*cdf0e10cSrcweir pDoc->SetContainsMSVBasic( sal_False ); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir // TabellenBox Edit beenden! 489*cdf0e10cSrcweir if( pWrtShell ) 490*cdf0e10cSrcweir pWrtShell->EndAllTblBoxEdit(); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir // Modified-Flag merken und erhalten ohne den Link zu Callen 493*cdf0e10cSrcweir // (fuer OLE; nach Anweisung von MM) 494*cdf0e10cSrcweir sal_Bool bIsModified = pDoc->IsModified(); 495*cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().LockUndoNoModifiedPosition(); 496*cdf0e10cSrcweir Link aOldOLELnk( pDoc->GetOle2Link() ); 497*cdf0e10cSrcweir pDoc->SetOle2Link( Link() ); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir // SfxProgress unterdruecken, wenn man Embedded ist 500*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( 501*cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED == GetCreateMode() ); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir WriterRef xWrt; 504*cdf0e10cSrcweir ::GetXMLWriter( aEmptyStr, rMedium.GetBaseURL( true ), xWrt ); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir sal_Bool bLockedView(sal_False); 507*cdf0e10cSrcweir if ( pWrtShell ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir bLockedView = pWrtShell->IsViewLocked(); 510*cdf0e10cSrcweir pWrtShell->LockView( sal_True ); //lock visible section 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir SwWriter aWrt( rMedium, *pDoc ); 514*cdf0e10cSrcweir nErr = aWrt.Write( xWrt ); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if ( pWrtShell ) 517*cdf0e10cSrcweir pWrtShell->LockView( bLockedView ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if( bIsModified ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir pDoc->SetModified(); 522*cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().UnLockUndoNoModifiedPosition(); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir pDoc->SetOle2Link( aOldOLELnk ); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( sal_False ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir SetError( nErr ? nErr : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir return !IsError( nErr ); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir /*-------------------------------------------------------------------- 534*cdf0e10cSrcweir Beschreibung: Sichern aller Formate 535*cdf0e10cSrcweir --------------------------------------------------------------------*/ 536*cdf0e10cSrcweir SwSrcView* lcl_GetSourceView( SwDocShell* pSh ) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir // sind wir in der SourceView? 539*cdf0e10cSrcweir SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( pSh ); 540*cdf0e10cSrcweir SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0; 541*cdf0e10cSrcweir return PTR_CAST( SwSrcView, pViewShell); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir sal_Bool SwDocShell::ConvertTo( SfxMedium& rMedium ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::ConvertTo" ); 547*cdf0e10cSrcweir const SfxFilter* pFlt = rMedium.GetFilter(); 548*cdf0e10cSrcweir if( !pFlt ) 549*cdf0e10cSrcweir return sal_False; 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir WriterRef xWriter; 552*cdf0e10cSrcweir SwReaderWriter::GetWriter( pFlt->GetUserData(), rMedium.GetBaseURL( true ), xWriter ); 553*cdf0e10cSrcweir if( !xWriter.Is() ) 554*cdf0e10cSrcweir { // Der Filter ist nicht vorhanden 555*cdf0e10cSrcweir InfoBox( 0, 556*cdf0e10cSrcweir SW_RESSTR(STR_DLLNOTFOUND) ).Execute(); 557*cdf0e10cSrcweir return sal_False; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir //#i3370# remove quick help to prevent saving of autocorrection suggestions 561*cdf0e10cSrcweir if(pView) 562*cdf0e10cSrcweir pView->GetEditWin().StopQuickHelp(); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir //#i91811# mod if we have an active margin window, write back the text 565*cdf0e10cSrcweir if ( pView && 566*cdf0e10cSrcweir pView->GetPostItMgr() && 567*cdf0e10cSrcweir pView->GetPostItMgr()->HasActiveSidebarWin() ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir pView->GetPostItMgr()->UpdateDataOnActiveSidebarWin(); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir sal_uLong nVBWarning = 0; 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if( pDoc->ContainsMSVBasic() ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir sal_Bool bSave = pFlt->GetUserData().EqualsAscii( "CWW8" ) 577*cdf0e10cSrcweir && SvtFilterOptions::Get()->IsLoadWordBasicStorage(); 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir if ( bSave ) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir SvStorageRef xStg = new SotStorage( rMedium.GetOutStream(), sal_False ); 582*cdf0e10cSrcweir DBG_ASSERT( !xStg->GetError(), "No storage available for storing VBA macros!" ); 583*cdf0e10cSrcweir if ( !xStg->GetError() ) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir nVBWarning = SaveOrDelMSVBAStorage( (SfxObjectShell&) *this, *xStg, bSave, String::CreateFromAscii("Macros") ); 586*cdf0e10cSrcweir xStg->Commit(); 587*cdf0e10cSrcweir pDoc->SetContainsMSVBasic( sal_True ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir // TabellenBox Edit beenden! 593*cdf0e10cSrcweir if( pWrtShell ) 594*cdf0e10cSrcweir pWrtShell->EndAllTblBoxEdit(); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir if( pFlt->GetUserData().EqualsAscii( "HTML") ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); 599*cdf0e10cSrcweir if( !pHtmlOpt->IsStarBasic() && pHtmlOpt->IsStarBasicWarning() && HasBasic() ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir uno::Reference< XLibraryContainer > xLibCont(GetBasicContainer(), UNO_QUERY); 602*cdf0e10cSrcweir uno::Reference< XNameAccess > xLib; 603*cdf0e10cSrcweir Sequence<rtl::OUString> aNames = xLibCont->getElementNames(); 604*cdf0e10cSrcweir const rtl::OUString* pNames = aNames.getConstArray(); 605*cdf0e10cSrcweir for(sal_Int32 nLib = 0; nLib < aNames.getLength(); nLib++) 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir Any aLib = xLibCont->getByName(pNames[nLib]); 608*cdf0e10cSrcweir aLib >>= xLib; 609*cdf0e10cSrcweir if(xLib.is()) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir Sequence<rtl::OUString> aModNames = xLib->getElementNames(); 612*cdf0e10cSrcweir if(aModNames.getLength()) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir SetError(WARN_SWG_HTML_NO_MACROS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 615*cdf0e10cSrcweir break; 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir UpdateDocInfoForSave(); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir // --> FME 2007-5-7 #i76360# Update document statistics 624*cdf0e10cSrcweir SwDocStat aDocStat( pDoc->GetDocStat() );; 625*cdf0e10cSrcweir pDoc->UpdateDocStat( aDocStat ); 626*cdf0e10cSrcweir // <-- 627*cdf0e10cSrcweir CalcLayoutForOLEObjects(); // format for OLE objets 628*cdf0e10cSrcweir // --> OD 2006-03-17 #i62875# 629*cdf0e10cSrcweir // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible 630*cdf0e10cSrcweir if ( pWrtShell && pDoc && 631*cdf0e10cSrcweir pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && 632*cdf0e10cSrcweir docfunc::AllDrawObjsOnPage( *pDoc ) ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir // <-- 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir if( xWriter->IsStgWriter() && 639*cdf0e10cSrcweir ( /*xWriter->IsSw3Writer() ||*/ 640*cdf0e10cSrcweir pFlt->GetUserData().EqualsAscii( FILTER_XML ) || 641*cdf0e10cSrcweir pFlt->GetUserData().EqualsAscii( FILTER_XMLV ) || 642*cdf0e10cSrcweir pFlt->GetUserData().EqualsAscii( FILTER_XMLVW ) ) ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir // eigenen Typ ermitteln 645*cdf0e10cSrcweir sal_uInt8 nMyType = 0; 646*cdf0e10cSrcweir if( ISA( SwWebDocShell) ) 647*cdf0e10cSrcweir nMyType = 1; 648*cdf0e10cSrcweir else if( ISA( SwGlobalDocShell) ) 649*cdf0e10cSrcweir nMyType = 2; 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir // gewuenschten Typ ermitteln 652*cdf0e10cSrcweir sal_uInt8 nSaveType = 0; 653*cdf0e10cSrcweir sal_uLong nSaveClipId = pFlt->GetFormat(); 654*cdf0e10cSrcweir if( SOT_FORMATSTR_ID_STARWRITERWEB_8 == nSaveClipId || 655*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERWEB_60 == nSaveClipId || 656*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERWEB_50 == nSaveClipId || 657*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERWEB_40 == nSaveClipId ) 658*cdf0e10cSrcweir nSaveType = 1; 659*cdf0e10cSrcweir else if( SOT_FORMATSTR_ID_STARWRITERGLOB_8 == nSaveClipId || 660*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERGLOB_60 == nSaveClipId || 661*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERGLOB_50 == nSaveClipId || 662*cdf0e10cSrcweir SOT_FORMATSTR_ID_STARWRITERGLOB_40 == nSaveClipId ) 663*cdf0e10cSrcweir nSaveType = 2; 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir // Flags am Dokument entsprechend umsetzen 666*cdf0e10cSrcweir sal_Bool bIsHTMLModeSave = GetDoc()->get(IDocumentSettingAccess::HTML_MODE); 667*cdf0e10cSrcweir sal_Bool bIsGlobalDocSave = GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT); 668*cdf0e10cSrcweir sal_Bool bIsGlblDocSaveLinksSave = GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS); 669*cdf0e10cSrcweir if( nMyType != nSaveType ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::HTML_MODE, 1 == nSaveType); 672*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, 2 == nSaveType); 673*cdf0e10cSrcweir if( 2 != nSaveType ) 674*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, false); 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir // if the target format is storage based, then the output storage must be already created 678*cdf0e10cSrcweir if ( rMedium.IsStorage() ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir // set MediaType on target storage 681*cdf0e10cSrcweir // (MediaType will be queried during SaveAs) 682*cdf0e10cSrcweir try 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir // TODO/MBA: testing 685*cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( rMedium.GetStorage(), uno::UNO_QUERY ); 686*cdf0e10cSrcweir if ( xSet.is() ) 687*cdf0e10cSrcweir xSet->setPropertyValue( ::rtl::OUString::createFromAscii("MediaType"), uno::makeAny( ::rtl::OUString( SotExchange::GetFormatMimeType( nSaveClipId ) ) ) ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir catch ( uno::Exception& ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir // Jetzt das Dokument normal speichern 695*cdf0e10cSrcweir sal_Bool bRet = SaveAs( rMedium ); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir if( nMyType != nSaveType ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::HTML_MODE, bIsHTMLModeSave ); 700*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, bIsGlobalDocSave); 701*cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bIsGlblDocSaveLinksSave); 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir return bRet; 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir if( pFlt->GetUserData().EqualsAscii( FILTER_TEXT_DLG ) && 708*cdf0e10cSrcweir ( pWrtShell || !::lcl_GetSourceView( this ) )) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir SwAsciiOptions aOpt; 711*cdf0e10cSrcweir String sItemOpt; 712*cdf0e10cSrcweir const SfxItemSet* pSet; 713*cdf0e10cSrcweir const SfxPoolItem* pItem; 714*cdf0e10cSrcweir if( 0 != ( pSet = rMedium.GetItemSet() ) ) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir if( SFX_ITEM_SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, 717*cdf0e10cSrcweir sal_True, &pItem ) ) 718*cdf0e10cSrcweir sItemOpt = ((const SfxStringItem*)pItem)->GetValue(); 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir if(sItemOpt.Len()) 721*cdf0e10cSrcweir aOpt.ReadUserData( sItemOpt ); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir xWriter->SetAsciiOptions( aOpt ); 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir // SfxProgress unterdruecken, wenn man Embedded ist 727*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( 728*cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED == GetCreateMode()); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir // Kontext aufspannen, um die Anzeige der Selektion zu unterbinden 731*cdf0e10cSrcweir sal_uLong nErrno; 732*cdf0e10cSrcweir String aFileName( rMedium.GetName() ); 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir //Keine View also das ganze Dokument! 735*cdf0e10cSrcweir if ( pWrtShell ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir SwWait aWait( *this, sal_True ); 738*cdf0e10cSrcweir // --> OD 2009-12-31 #i106906# 739*cdf0e10cSrcweir const sal_Bool bFormerLockView = pWrtShell->IsViewLocked(); 740*cdf0e10cSrcweir pWrtShell->LockView( sal_True ); 741*cdf0e10cSrcweir // <-- 742*cdf0e10cSrcweir pWrtShell->StartAllAction(); 743*cdf0e10cSrcweir pWrtShell->Push(); 744*cdf0e10cSrcweir SwWriter aWrt( rMedium, *pWrtShell, sal_True ); 745*cdf0e10cSrcweir nErrno = aWrt.Write( xWriter, &aFileName ); 746*cdf0e10cSrcweir //JP 16.05.97: falls der SFX uns die View waehrend des speicherns 747*cdf0e10cSrcweir // entzieht 748*cdf0e10cSrcweir if( pWrtShell ) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir pWrtShell->Pop(sal_False); 751*cdf0e10cSrcweir pWrtShell->EndAllAction(); 752*cdf0e10cSrcweir // --> OD 2009-12-31 #i106906# 753*cdf0e10cSrcweir pWrtShell->LockView( bFormerLockView ); 754*cdf0e10cSrcweir // <-- 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir else 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir // sind wir in der SourceView? 760*cdf0e10cSrcweir SwSrcView* pSrcView = ::lcl_GetSourceView( this ); 761*cdf0e10cSrcweir if( pSrcView ) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir pSrcView->SaveContentTo(rMedium); 764*cdf0e10cSrcweir nErrno = 0; 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir else 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir SwWriter aWrt( rMedium, *pDoc ); 769*cdf0e10cSrcweir nErrno = aWrt.Write( xWriter, &aFileName ); 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir SW_MOD()->SetEmbeddedLoadSave( sal_False ); 774*cdf0e10cSrcweir SetError( nErrno ? nErrno : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 775*cdf0e10cSrcweir if( !rMedium.IsStorage() ) 776*cdf0e10cSrcweir rMedium.CloseOutStream(); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir return !IsError( nErrno ); 779*cdf0e10cSrcweir } 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir /*-------------------------------------------------------------------- 782*cdf0e10cSrcweir Beschreibung: Haende weg 783*cdf0e10cSrcweir --------------------------------------------------------------------*/ 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir /*-------------------------------------------------------------------- 787*cdf0e10cSrcweir Beschreibung: ??? noch nicht zu aktivieren, muss sal_True liefern 788*cdf0e10cSrcweir --------------------------------------------------------------------*/ 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir sal_Bool SwDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDocShell::SaveCompleted" ); 794*cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::SaveCompleted( xStor ); 795*cdf0e10cSrcweir if( bRet ) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir // erst hier entscheiden, ob das Speichern geklappt hat oder nicht 798*cdf0e10cSrcweir if( IsModified() ) 799*cdf0e10cSrcweir pDoc->SetModified(); 800*cdf0e10cSrcweir else 801*cdf0e10cSrcweir pDoc->ResetModified(); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir if( pOLEChildList ) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir sal_Bool bResetModified = IsEnableSetModified(); 807*cdf0e10cSrcweir if( bResetModified ) 808*cdf0e10cSrcweir EnableSetModified( sal_False ); 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir uno::Sequence < rtl::OUString > aNames = pOLEChildList->GetObjectNames(); 811*cdf0e10cSrcweir for( sal_Int32 n = aNames.getLength(); n; n-- ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir if ( !pOLEChildList->MoveEmbeddedObject( aNames[n-1], GetEmbeddedObjectContainer() ) ) 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir DBG_ERROR( "Copying of objects didn't work!" ); 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir //SvPersist* pPersist = this; 819*cdf0e10cSrcweir //SvInfoObjectRef aRef( pInfList->GetObject( --n )); 820*cdf0e10cSrcweir //pPersist->Move( &aRef, aRef->GetStorageName() ); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir DELETEZ( pOLEChildList ); 824*cdf0e10cSrcweir if( bResetModified ) 825*cdf0e10cSrcweir EnableSetModified( sal_True ); 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir return bRet; 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir /*-------------------------------------------------------------------- 831*cdf0e10cSrcweir Beschreibung: Draw()-Overload fuer OLE2 (Sfx) 832*cdf0e10cSrcweir --------------------------------------------------------------------*/ 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup, 835*cdf0e10cSrcweir sal_uInt16 nAspect ) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir //fix #25341# Draw sollte das Modified nicht beeinflussen 838*cdf0e10cSrcweir sal_Bool bResetModified; 839*cdf0e10cSrcweir if ( sal_True == (bResetModified = IsEnableSetModified()) ) 840*cdf0e10cSrcweir EnableSetModified( sal_False ); 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir //sollte am Document ein JobSetup haengen, dann kopieren wir uns diesen, 843*cdf0e10cSrcweir //um nach dem PrtOle2 diesen wieder am Doc zu verankern. 844*cdf0e10cSrcweir //Einen leeren JobSetup setzen wir nicht ein, denn der wuerde nur zu 845*cdf0e10cSrcweir //fragwuerdigem Ergebnis nach teurer Neuformatierung fuehren (Preview!) 846*cdf0e10cSrcweir JobSetup *pOrig = 0; 847*cdf0e10cSrcweir if ( rSetup.GetPrinterName().Len() && ASPECT_THUMBNAIL != nAspect ) 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir pOrig = const_cast<JobSetup*>(pDoc->getJobsetup()); 850*cdf0e10cSrcweir if( pOrig ) // dann kopieren wir uns den 851*cdf0e10cSrcweir pOrig = new JobSetup( *pOrig ); 852*cdf0e10cSrcweir pDoc->setJobsetup( rSetup ); 853*cdf0e10cSrcweir } 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir Rectangle aRect( nAspect == ASPECT_THUMBNAIL ? 856*cdf0e10cSrcweir GetVisArea( nAspect ) : GetVisArea( ASPECT_CONTENT ) ); 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir pDev->Push(); 859*cdf0e10cSrcweir pDev->SetFillColor(); 860*cdf0e10cSrcweir pDev->SetLineColor(); 861*cdf0e10cSrcweir pDev->SetBackground(); 862*cdf0e10cSrcweir sal_Bool bWeb = 0 != PTR_CAST(SwWebDocShell, this); 863*cdf0e10cSrcweir SwPrintData aOpts; 864*cdf0e10cSrcweir ViewShell::PrtOle2( pDoc, SW_MOD()->GetUsrPref(bWeb), aOpts, pDev, aRect ); 865*cdf0e10cSrcweir pDev->Pop(); 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir if( pOrig ) 868*cdf0e10cSrcweir { 869*cdf0e10cSrcweir pDoc->setJobsetup( *pOrig ); 870*cdf0e10cSrcweir delete pOrig; 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir if ( bResetModified ) 873*cdf0e10cSrcweir EnableSetModified( sal_True ); 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir void SwDocShell::SetVisArea( const Rectangle &rRect ) 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir Rectangle aRect( rRect ); 880*cdf0e10cSrcweir if ( pView ) 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir Size aSz( pView->GetDocSz() ); 883*cdf0e10cSrcweir aSz.Width() += DOCUMENTBORDER; aSz.Height() += DOCUMENTBORDER; 884*cdf0e10cSrcweir long nMoveX = 0, nMoveY = 0; 885*cdf0e10cSrcweir if ( aRect.Right() > aSz.Width() ) 886*cdf0e10cSrcweir nMoveX = aSz.Width() - aRect.Right(); 887*cdf0e10cSrcweir if ( aRect.Bottom() > aSz.Height() ) 888*cdf0e10cSrcweir nMoveY = aSz.Height() - aRect.Bottom(); 889*cdf0e10cSrcweir aRect.Move( nMoveX, nMoveY ); 890*cdf0e10cSrcweir nMoveX = aRect.Left() < 0 ? -aRect.Left() : 0; 891*cdf0e10cSrcweir nMoveY = aRect.Top() < 0 ? -aRect.Top() : 0; 892*cdf0e10cSrcweir aRect.Move( nMoveX, nMoveY ); 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir //Ruft das SfxInPlaceObject::SetVisArea()! 895*cdf0e10cSrcweir pView->SetVisArea( aRect, sal_True ); 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir else 898*cdf0e10cSrcweir SfxObjectShell::SetVisArea( aRect ); 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir Rectangle SwDocShell::GetVisArea( sal_uInt16 nAspect ) const 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir if ( nAspect == ASPECT_THUMBNAIL ) 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir //PreView: VisArea auf die erste Seite einstellen. 907*cdf0e10cSrcweir SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfExtras(), 1 ); 908*cdf0e10cSrcweir SwCntntNode* pNd = pDoc->GetNodes().GoNext( &aIdx ); 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir const SwRect aPageRect = pNd->FindPageFrmRect( sal_False, 0, sal_False ); 911*cdf0e10cSrcweir return aPageRect.SVRect(); 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir return SfxObjectShell::GetVisArea( nAspect ); 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir Printer *SwDocShell::GetDocumentPrinter() 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir return pDoc->getPrinter( false ); 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir OutputDevice* SwDocShell::GetDocumentRefDev() 922*cdf0e10cSrcweir { 923*cdf0e10cSrcweir return pDoc->getReferenceDevice( false ); 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir void SwDocShell::OnDocumentPrinterChanged( Printer * pNewPrinter ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir if ( pNewPrinter ) 929*cdf0e10cSrcweir GetDoc()->setJobsetup( pNewPrinter->GetJobSetup() ); 930*cdf0e10cSrcweir else 931*cdf0e10cSrcweir GetDoc()->setPrinter( 0, true, true ); 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir sal_uLong SwDocShell::GetMiscStatus() const 935*cdf0e10cSrcweir { 936*cdf0e10cSrcweir return SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption 940*cdf0e10cSrcweir sal_uInt16 SwDocShell::GetHiddenInformationState( sal_uInt16 nStates ) 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir // get global state like HIDDENINFORMATION_DOCUMENTVERSIONS 943*cdf0e10cSrcweir sal_uInt16 nState = SfxObjectShell::GetHiddenInformationState( nStates ); 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir if ( nStates & HIDDENINFORMATION_RECORDEDCHANGES ) 946*cdf0e10cSrcweir { 947*cdf0e10cSrcweir if ( GetDoc()->GetRedlineTbl().Count() ) 948*cdf0e10cSrcweir nState |= HIDDENINFORMATION_RECORDEDCHANGES; 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir if ( nStates & HIDDENINFORMATION_NOTES ) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir ASSERT( GetWrtShell(), "No SwWrtShell, no information" ) 953*cdf0e10cSrcweir if ( GetWrtShell() ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir SwFieldType* pType = GetWrtShell()->GetFldType( RES_POSTITFLD, aEmptyStr ); 956*cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pType ); 957*cdf0e10cSrcweir SwFmtFld* pFirst = aIter.First(); 958*cdf0e10cSrcweir while( pFirst ) 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir if( pFirst->GetTxtFld() && pFirst->IsFldInDoc() ) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir nState |= HIDDENINFORMATION_NOTES; 963*cdf0e10cSrcweir break; 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir pFirst = aIter.Next(); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir return nState; 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir // <-- 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir /*-------------------------------------------------------------------- 976*cdf0e10cSrcweir Beschreibung: 977*cdf0e10cSrcweir --------------------------------------------------------------------*/ 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir void SwDocShell::GetState(SfxItemSet& rSet) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir SfxWhichIter aIter(rSet); 983*cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir while (nWhich) 986*cdf0e10cSrcweir { 987*cdf0e10cSrcweir switch (nWhich) 988*cdf0e10cSrcweir { 989*cdf0e10cSrcweir case SID_PRINTPREVIEW: 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir sal_Bool bDisable = IsInPlaceActive(); 992*cdf0e10cSrcweir // Disable "multiple layout" 993*cdf0e10cSrcweir if ( !bDisable ) 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this); 996*cdf0e10cSrcweir while (pTmpFrm) // Preview suchen 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir if ( PTR_CAST(SwView, pTmpFrm->GetViewShell()) && 999*cdf0e10cSrcweir ((SwView*)pTmpFrm->GetViewShell())->GetWrtShell().GetViewOptions()->getBrowseMode() ) 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir bDisable = sal_True; 1002*cdf0e10cSrcweir break; 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this); 1005*cdf0e10cSrcweir } 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir // End of disabled "multiple layout" 1008*cdf0e10cSrcweir if ( bDisable ) 1009*cdf0e10cSrcweir rSet.DisableItem( SID_PRINTPREVIEW ); 1010*cdf0e10cSrcweir else 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir SfxBoolItem aBool( SID_PRINTPREVIEW, sal_False ); 1013*cdf0e10cSrcweir if( PTR_CAST( SwPagePreView, SfxViewShell::Current()) ) 1014*cdf0e10cSrcweir aBool.SetValue( sal_True ); 1015*cdf0e10cSrcweir rSet.Put( aBool ); 1016*cdf0e10cSrcweir } 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir break; 1019*cdf0e10cSrcweir case SID_SOURCEVIEW: 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView() 1022*cdf0e10cSrcweir : SfxViewShell::Current(); 1023*cdf0e10cSrcweir sal_Bool bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView); 1024*cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView)); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir break; 1027*cdf0e10cSrcweir case SID_HTML_MODE: 1028*cdf0e10cSrcweir rSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this))); 1029*cdf0e10cSrcweir break; 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir case FN_ABSTRACT_STARIMPRESS: 1032*cdf0e10cSrcweir case FN_OUTLINE_TO_IMPRESS: 1033*cdf0e10cSrcweir { 1034*cdf0e10cSrcweir SvtModuleOptions aMOpt; 1035*cdf0e10cSrcweir if ( !aMOpt.IsImpress() ) 1036*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir /* no break here */ 1039*cdf0e10cSrcweir case FN_ABSTRACT_NEWDOC: 1040*cdf0e10cSrcweir case FN_OUTLINE_TO_CLIPBOARD: 1041*cdf0e10cSrcweir { 1042*cdf0e10cSrcweir if ( !GetDoc()->GetNodes().GetOutLineNds().Count() ) 1043*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir break; 1046*cdf0e10cSrcweir case SID_BROWSER_MODE: 1047*cdf0e10cSrcweir case FN_PRINT_LAYOUT: 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE); 1050*cdf0e10cSrcweir if(FN_PRINT_LAYOUT == nWhich) 1051*cdf0e10cSrcweir bState = !bState; 1052*cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bState)); 1053*cdf0e10cSrcweir } 1054*cdf0e10cSrcweir break; 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir case FN_NEW_GLOBAL_DOC: 1057*cdf0e10cSrcweir if ( ISA(SwGlobalDocShell) ) 1058*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1059*cdf0e10cSrcweir break; 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir case FN_NEW_HTML_DOC: 1062*cdf0e10cSrcweir if( ISA( SwWebDocShell ) ) 1063*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1064*cdf0e10cSrcweir break; 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir case SID_ATTR_YEAR2000: 1067*cdf0e10cSrcweir { 1068*cdf0e10cSrcweir const SvNumberFormatter* pFmtr = pDoc->GetNumberFormatter(sal_False); 1069*cdf0e10cSrcweir rSet.Put( SfxUInt16Item( nWhich, 1070*cdf0e10cSrcweir static_cast< sal_uInt16 >( 1071*cdf0e10cSrcweir pFmtr ? pFmtr->GetYear2000() 1072*cdf0e10cSrcweir : ::utl::MiscCfg().GetYear2000() ))); 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir break; 1075*cdf0e10cSrcweir case SID_ATTR_CHAR_FONTLIST: 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir rSet.Put( SvxFontListItem( pFontList, SID_ATTR_CHAR_FONTLIST ) ); 1078*cdf0e10cSrcweir } 1079*cdf0e10cSrcweir break; 1080*cdf0e10cSrcweir case SID_MAIL_PREPAREEXPORT: 1081*cdf0e10cSrcweir { 1082*cdf0e10cSrcweir //check if linked content or possibly hidden content is available 1083*cdf0e10cSrcweir //pDoc->UpdateFlds( NULL, false ); 1084*cdf0e10cSrcweir sfx2::LinkManager& rLnkMgr = pDoc->GetLinkManager(); 1085*cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks(); 1086*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1087*cdf0e10cSrcweir if( rLnks.Count() ) 1088*cdf0e10cSrcweir bRet = sal_True; 1089*cdf0e10cSrcweir else 1090*cdf0e10cSrcweir { 1091*cdf0e10cSrcweir //sections with hidden flag, hidden character attribute, hidden paragraph/text or conditional text fields 1092*cdf0e10cSrcweir bRet = pDoc->HasInvisibleContent(); 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bRet ) ); 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir break; 1097*cdf0e10cSrcweir 1098*cdf0e10cSrcweir default: DBG_ASSERT(!this,"Hier darfst Du nicht hinein!"); 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir nWhich = aIter.NextWhich(); 1102*cdf0e10cSrcweir } 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir /*-------------------------------------------------------------------- 1106*cdf0e10cSrcweir Beschreibung: OLE-Hdls 1107*cdf0e10cSrcweir --------------------------------------------------------------------*/ 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir IMPL_LINK( SwDocShell, Ole2ModifiedHdl, void *, p ) 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir // vom Doc wird der Status mitgegeben (siehe doc.cxx) 1113*cdf0e10cSrcweir // Bit 0: -> alter Zustand 1114*cdf0e10cSrcweir // Bit 1: -> neuer Zustand 1115*cdf0e10cSrcweir long nStatus = (long)p; 1116*cdf0e10cSrcweir if( IsEnableSetModified() ) 1117*cdf0e10cSrcweir SetModified( (nStatus & 2) ? sal_True : sal_False ); 1118*cdf0e10cSrcweir return 0; 1119*cdf0e10cSrcweir } 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir /*-------------------------------------------------------------------- 1122*cdf0e10cSrcweir Beschreibung: Pool returnen Hier weil virtuelll 1123*cdf0e10cSrcweir --------------------------------------------------------------------*/ 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir SfxStyleSheetBasePool* SwDocShell::GetStyleSheetPool() 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir return mxBasePool.get(); 1129*cdf0e10cSrcweir } 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir 1132*cdf0e10cSrcweir void SwDocShell::SetView(SwView* pVw) 1133*cdf0e10cSrcweir { 1134*cdf0e10cSrcweir if ( 0 != (pView = pVw) ) 1135*cdf0e10cSrcweir pWrtShell = &pView->GetWrtShell(); 1136*cdf0e10cSrcweir else 1137*cdf0e10cSrcweir pWrtShell = 0; 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir 1141*cdf0e10cSrcweir void SwDocShell::PrepareReload() 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir ::DelAllGrfCacheEntries( pDoc ); 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir // --> OD 2006-11-07 #i59688# 1147*cdf0e10cSrcweir // linked graphics are now loaded on demand. 1148*cdf0e10cSrcweir // Thus, loading of linked graphics no longer needed and necessary for 1149*cdf0e10cSrcweir // the load of document being finished. 1150*cdf0e10cSrcweir void SwDocShell::LoadingFinished() 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir // --> OD 2007-10-08 #i38810# 1153*cdf0e10cSrcweir // Original fix fails after integration of cws xmlsec11: 1154*cdf0e10cSrcweir // interface <SfxObjectShell::EnableSetModified(..)> no longer works, because 1155*cdf0e10cSrcweir // <SfxObjectShell::FinishedLoading(..)> doesn't care about its status and 1156*cdf0e10cSrcweir // enables the document modification again. 1157*cdf0e10cSrcweir // Thus, manuell modify the document, if its modified and its links are updated 1158*cdf0e10cSrcweir // before <FinishedLoading(..)> is called. 1159*cdf0e10cSrcweir const bool bHasDocToStayModified( pDoc->IsModified() && pDoc->LinksUpdated() ); 1160*cdf0e10cSrcweir // // --> OD 2005-02-11 #i38810# - disable method <SetModified(..)>, if document 1161*cdf0e10cSrcweir // // has stay in modified state, due to the update of its links during load. 1162*cdf0e10cSrcweir // bool bResetEnableSetModified(false); 1163*cdf0e10cSrcweir // if ( IsEnableSetModified() && 1164*cdf0e10cSrcweir // pDoc->IsModified() && pDoc->LinksUpdated() ) 1165*cdf0e10cSrcweir // { 1166*cdf0e10cSrcweir // EnableSetModified( sal_False ); 1167*cdf0e10cSrcweir // bResetEnableSetModified = true; 1168*cdf0e10cSrcweir // } 1169*cdf0e10cSrcweir // <-- 1170*cdf0e10cSrcweir FinishedLoading( SFX_LOADED_ALL ); 1171*cdf0e10cSrcweir // // --> OD 2005-02-11 #i38810# 1172*cdf0e10cSrcweir // if ( bResetEnableSetModified ) 1173*cdf0e10cSrcweir // { 1174*cdf0e10cSrcweir // EnableSetModified( sal_True ); 1175*cdf0e10cSrcweir // } 1176*cdf0e10cSrcweir // // <-- 1177*cdf0e10cSrcweir SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this); 1178*cdf0e10cSrcweir if(pVFrame) 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir SfxViewShell* pShell = pVFrame->GetViewShell(); 1181*cdf0e10cSrcweir if(PTR_CAST(SwSrcView, pShell)) 1182*cdf0e10cSrcweir ((SwSrcView*)pShell)->Load(this); 1183*cdf0e10cSrcweir } 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir // --> OD 2007-10-08 #i38810# 1186*cdf0e10cSrcweir if ( bHasDocToStayModified && !pDoc->IsModified() ) 1187*cdf0e10cSrcweir { 1188*cdf0e10cSrcweir pDoc->SetModified(); 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir // <-- 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir // eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen) 1194*cdf0e10cSrcweir void SwDocShell::CancelTransfers() 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir // alle Links vom LinkManager Canceln 1197*cdf0e10cSrcweir aFinishedTimer.Stop(); 1198*cdf0e10cSrcweir pDoc->GetLinkManager().CancelTransfers(); 1199*cdf0e10cSrcweir SfxObjectShell::CancelTransfers(); 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir SwFEShell* SwDocShell::GetFEShell() 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir return pWrtShell; 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir void SwDocShell::RemoveOLEObjects() 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir SwIterator<SwCntntNode,SwFmtColl> aIter( *pDoc->GetDfltGrfFmtColl() ); 1210*cdf0e10cSrcweir for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() ) 1211*cdf0e10cSrcweir { 1212*cdf0e10cSrcweir SwOLENode* pOLENd = pNd->GetOLENode(); 1213*cdf0e10cSrcweir if( pOLENd && ( pOLENd->IsOLEObjectDeleted() || 1214*cdf0e10cSrcweir pOLENd->IsInGlobalDocSection() ) ) 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir if( !pOLEChildList ) 1217*cdf0e10cSrcweir pOLEChildList = new comphelper::EmbeddedObjectContainer; 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir ::rtl::OUString aObjName = pOLENd->GetOLEObj().GetCurrentPersistName(); 1220*cdf0e10cSrcweir GetEmbeddedObjectContainer().MoveEmbeddedObject( aObjName, *pOLEChildList ); 1221*cdf0e10cSrcweir } 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir // When a document is loaded, SwDoc::PrtOLENotify is called to update 1226*cdf0e10cSrcweir // the sizes of math objects. However, for objects that do not have a 1227*cdf0e10cSrcweir // SwFrm at this time, only a flag is set (bIsOLESizeInvalid) and the 1228*cdf0e10cSrcweir // size change takes place later, while calculating the layout in the 1229*cdf0e10cSrcweir // idle handler. If this document is saved now, it is saved with invalid 1230*cdf0e10cSrcweir // sizes. For this reason, the layout has to be calculated before a document is 1231*cdf0e10cSrcweir // saved, but of course only id there are OLE objects with bOLESizeInvalid set. 1232*cdf0e10cSrcweir void SwDocShell::CalcLayoutForOLEObjects() 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir if( !pWrtShell ) 1235*cdf0e10cSrcweir return; 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir SwIterator<SwCntntNode,SwFmtColl> aIter( *pDoc->GetDfltGrfFmtColl() ); 1238*cdf0e10cSrcweir for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() ) 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir SwOLENode* pOLENd = pNd->GetOLENode(); 1241*cdf0e10cSrcweir if( pOLENd && pOLENd->IsOLESizeInvalid() ) 1242*cdf0e10cSrcweir { 1243*cdf0e10cSrcweir pWrtShell->CalcLayout(); 1244*cdf0e10cSrcweir break; 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir } 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks 1251*cdf0e10cSrcweir // This new function is necessary to trigger update of links in docs 1252*cdf0e10cSrcweir // read by the binary filter: 1253*cdf0e10cSrcweir void SwDocShell::UpdateLinks() 1254*cdf0e10cSrcweir { 1255*cdf0e10cSrcweir GetDoc()->UpdateLinks(sal_True); 1256*cdf0e10cSrcweir // --> FME 2005-07-27 #i50703# Update footnote numbers 1257*cdf0e10cSrcweir SwTxtFtn::SetUniqueSeqRefNo( *GetDoc() ); 1258*cdf0e10cSrcweir SwNodeIndex aTmp( GetDoc()->GetNodes() ); 1259*cdf0e10cSrcweir GetDoc()->GetFtnIdxs().UpdateFtn( aTmp ); 1260*cdf0e10cSrcweir // <-- 1261*cdf0e10cSrcweir } 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir uno::Reference< frame::XController > 1264*cdf0e10cSrcweir SwDocShell::GetController() 1265*cdf0e10cSrcweir { 1266*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > aRet; 1267*cdf0e10cSrcweir // --> FME 2007-10-15 #i82346# No view in page preview 1268*cdf0e10cSrcweir if ( GetView() ) 1269*cdf0e10cSrcweir // <-- 1270*cdf0e10cSrcweir aRet = GetView()->GetController(); 1271*cdf0e10cSrcweir return aRet; 1272*cdf0e10cSrcweir } 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir /* -----------------------------12.02.01 12:08-------------------------------- 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 1277*cdf0e10cSrcweir static const char* pEventNames[] = 1278*cdf0e10cSrcweir { 1279*cdf0e10cSrcweir "OnPageCountChange", 1280*cdf0e10cSrcweir "OnMailMerge", 1281*cdf0e10cSrcweir "OnMailMergeFinished", 1282*cdf0e10cSrcweir "OnFieldMerge", 1283*cdf0e10cSrcweir "OnFieldMergeFinished", 1284*cdf0e10cSrcweir "OnLayoutFinished" 1285*cdf0e10cSrcweir }; 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir Sequence< OUString > SwDocShell::GetEventNames() 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir Sequence< OUString > aRet = SfxObjectShell::GetEventNames(); 1290*cdf0e10cSrcweir sal_Int32 nLen = aRet.getLength(); 1291*cdf0e10cSrcweir aRet.realloc(nLen + 6); 1292*cdf0e10cSrcweir OUString* pNames = aRet.getArray(); 1293*cdf0e10cSrcweir pNames[nLen++] = GetEventName(0); 1294*cdf0e10cSrcweir pNames[nLen++] = GetEventName(1); 1295*cdf0e10cSrcweir pNames[nLen++] = GetEventName(2); 1296*cdf0e10cSrcweir pNames[nLen++] = GetEventName(3); 1297*cdf0e10cSrcweir pNames[nLen++] = GetEventName(4); 1298*cdf0e10cSrcweir pNames[nLen] = GetEventName(5); 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir return aRet; 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir static sal_Int32 nEvents=13; 1304*cdf0e10cSrcweir 1305*cdf0e10cSrcweir rtl::OUString SwDocShell::GetEventName( sal_Int32 nIndex ) 1306*cdf0e10cSrcweir { 1307*cdf0e10cSrcweir if ( nIndex<nEvents ) 1308*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii(pEventNames[nIndex]); 1309*cdf0e10cSrcweir return rtl::OUString(); 1310*cdf0e10cSrcweir } 1311*cdf0e10cSrcweir 1312*cdf0e10cSrcweir const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const 1313*cdf0e10cSrcweir { 1314*cdf0e10cSrcweir return pDoc ? &pDoc->GetXmlIdRegistry() : 0; 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir bool SwDocShell::IsChangeRecording() const 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir return (pWrtShell->GetRedlineMode() & nsRedlineMode_t::REDLINE_ON) != 0; 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir bool SwDocShell::HasChangeRecordProtection() const 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir return pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength() > 0; 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir void SwDocShell::SetChangeRecording( bool bActivate ) 1331*cdf0e10cSrcweir { 1332*cdf0e10cSrcweir sal_uInt16 nOn = bActivate ? nsRedlineMode_t::REDLINE_ON : 0; 1333*cdf0e10cSrcweir sal_uInt16 nMode = pWrtShell->GetRedlineMode(); 1334*cdf0e10cSrcweir pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); 1335*cdf0e10cSrcweir } 1336*cdf0e10cSrcweir 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir bool SwDocShell::SetProtectionPassword( const String &rNewPassword ) 1339*cdf0e10cSrcweir { 1340*cdf0e10cSrcweir const SfxAllItemSet aSet( GetPool() ); 1341*cdf0e10cSrcweir const SfxItemSet* pArgs = &aSet; 1342*cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); 1345*cdf0e10cSrcweir Sequence< sal_Int8 > aPasswd = pIDRA->GetRedlinePassword(); 1346*cdf0e10cSrcweir if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, sal_False, &pItem ) 1347*cdf0e10cSrcweir && ((SfxBoolItem*)pItem)->GetValue() == (aPasswd.getLength() > 0)) 1348*cdf0e10cSrcweir return false; 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir bool bRes = false; 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir if (rNewPassword.Len()) 1353*cdf0e10cSrcweir { 1354*cdf0e10cSrcweir // when password protection is applied change tracking must always be active 1355*cdf0e10cSrcweir SetChangeRecording( true ); 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir Sequence< sal_Int8 > aNewPasswd; 1358*cdf0e10cSrcweir SvPasswordHelper::GetHashPassword( aNewPasswd, rNewPassword ); 1359*cdf0e10cSrcweir pIDRA->SetRedlinePassword( aNewPasswd ); 1360*cdf0e10cSrcweir bRes = true; 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir else 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir pIDRA->SetRedlinePassword( Sequence< sal_Int8 >() ); 1365*cdf0e10cSrcweir bRes = true; 1366*cdf0e10cSrcweir } 1367*cdf0e10cSrcweir 1368*cdf0e10cSrcweir return bRes; 1369*cdf0e10cSrcweir } 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir bool SwDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir bool bRes = false; 1375*cdf0e10cSrcweir 1376*cdf0e10cSrcweir const SfxAllItemSet aSet( GetPool() ); 1377*cdf0e10cSrcweir const SfxItemSet* pArgs = &aSet; 1378*cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); 1381*cdf0e10cSrcweir Sequence< sal_Int8 > aPasswdHash( pIDRA->GetRedlinePassword() ); 1382*cdf0e10cSrcweir if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, sal_False, &pItem ) 1383*cdf0e10cSrcweir && ((SfxBoolItem*)pItem)->GetValue() == (aPasswdHash.getLength() != 0)) 1384*cdf0e10cSrcweir return false; 1385*cdf0e10cSrcweir rPasswordHash = aPasswdHash; 1386*cdf0e10cSrcweir bRes = true; 1387*cdf0e10cSrcweir 1388*cdf0e10cSrcweir return bRes; 1389*cdf0e10cSrcweir } 1390*cdf0e10cSrcweir 1391*cdf0e10cSrcweir 1392