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