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