Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <com/sun/star/uno/Reference.hxx>
22 :
23 : #include <com/sun/star/document/DocumentProperties.hpp>
24 : #include <com/sun/star/document/XDocumentProperties.hpp>
25 : #include <com/sun/star/document/UpdateDocMode.hpp>
26 : #include <com/sun/star/frame/XLayoutManager.hpp>
27 : #include <com/sun/star/embed/ElementModes.hpp>
28 : #include <vcl/msgbox.hxx>
29 : #include <svl/style.hxx>
30 : #include <vcl/wrkwin.hxx>
31 :
32 : #include <svl/stritem.hxx>
33 : #include <svl/intitem.hxx>
34 : #include <svl/rectitem.hxx>
35 : #include <svl/eitem.hxx>
36 : #include <svl/urihelper.hxx>
37 : #include <svl/ctloptions.hxx>
38 : #include <comphelper/storagehelper.hxx>
39 : #include <comphelper/processfactory.hxx>
40 : #include <unotools/securityoptions.hxx>
41 : #include <svtools/sfxecode.hxx>
42 : #include <svtools/ehdl.hxx>
43 : #include <tools/datetime.hxx>
44 : #include <rtl/uri.hxx>
45 : #include <math.h>
46 :
47 : #include <unotools/saveopt.hxx>
48 : #include <unotools/useroptions.hxx>
49 : #include <unotools/localfilehelper.hxx>
50 : #include <vcl/virdev.hxx>
51 : #include <vcl/oldprintadaptor.hxx>
52 : #include <vcl/settings.hxx>
53 :
54 : #include <sfx2/app.hxx>
55 : #include <sfx2/sfxresid.hxx>
56 : #include "appdata.hxx"
57 : #include <sfx2/dinfdlg.hxx>
58 : #include <sfx2/fcontnr.hxx>
59 : #include <sfx2/docfac.hxx>
60 : #include <sfx2/viewsh.hxx>
61 : #include <sfx2/objsh.hxx>
62 : #include "objshimp.hxx"
63 : #include <sfx2/evntconf.hxx>
64 : #include <sfx2/sfxhelp.hxx>
65 : #include <sfx2/dispatch.hxx>
66 : #include <sfx2/printer.hxx>
67 : #include <basic/basmgr.hxx>
68 : #include <svtools/svtools.hrc>
69 : #include <sfx2/viewfrm.hxx>
70 : #include <sfx2/doctempl.hxx>
71 : #include "doc.hrc"
72 : #include <sfx2/sfxbasemodel.hxx>
73 : #include <sfx2/docfile.hxx>
74 : #include <sfx2/request.hxx>
75 : #include "openflag.hxx"
76 : #include "querytemplate.hxx"
77 : #include <boost/scoped_array.hpp>
78 :
79 : using namespace ::com::sun::star;
80 : using namespace ::com::sun::star::uno;
81 :
82 :
83 :
84 : static
85 0 : bool operator> (const util::DateTime& i_rLeft, const util::DateTime& i_rRight)
86 : {
87 0 : if ( i_rLeft.Year != i_rRight.Year )
88 0 : return i_rLeft.Year > i_rRight.Year;
89 :
90 0 : if ( i_rLeft.Month != i_rRight.Month )
91 0 : return i_rLeft.Month > i_rRight.Month;
92 :
93 0 : if ( i_rLeft.Day != i_rRight.Day )
94 0 : return i_rLeft.Day > i_rRight.Day;
95 :
96 0 : if ( i_rLeft.Hours != i_rRight.Hours )
97 0 : return i_rLeft.Hours > i_rRight.Hours;
98 :
99 0 : if ( i_rLeft.Minutes != i_rRight.Minutes )
100 0 : return i_rLeft.Minutes > i_rRight.Minutes;
101 :
102 0 : if ( i_rLeft.Seconds != i_rRight.Seconds )
103 0 : return i_rLeft.Seconds > i_rRight.Seconds;
104 :
105 0 : if ( i_rLeft.NanoSeconds != i_rRight.NanoSeconds )
106 0 : return i_rLeft.NanoSeconds > i_rRight.NanoSeconds;
107 :
108 0 : return false;
109 : }
110 :
111 : ::boost::shared_ptr<GDIMetaFile>
112 9806 : SfxObjectShell::GetPreviewMetaFile( bool bFullContent ) const
113 : {
114 9806 : return CreatePreviewMetaFile_Impl( bFullContent );
115 : }
116 :
117 : ::boost::shared_ptr<GDIMetaFile>
118 9806 : SfxObjectShell::CreatePreviewMetaFile_Impl( bool bFullContent ) const
119 : {
120 : // DoDraw can only be called when no printing is done, otherwise
121 : // the printer may be turned off
122 9806 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
123 9910 : if ( pFrame && pFrame->GetViewShell() &&
124 9866 : pFrame->GetViewShell()->GetPrinter() &&
125 8 : pFrame->GetViewShell()->GetPrinter()->IsPrinting() )
126 0 : return ::boost::shared_ptr<GDIMetaFile>();
127 :
128 9806 : ::boost::shared_ptr<GDIMetaFile> pFile(new GDIMetaFile);
129 :
130 19612 : VirtualDevice aDevice;
131 9806 : aDevice.EnableOutput( false );
132 :
133 19612 : MapMode aMode( ((SfxObjectShell*)this)->GetMapUnit() );
134 9806 : aDevice.SetMapMode( aMode );
135 9806 : pFile->SetPrefMapMode( aMode );
136 :
137 9806 : Size aTmpSize;
138 : sal_Int8 nAspect;
139 9806 : if ( bFullContent )
140 : {
141 9738 : nAspect = ASPECT_CONTENT;
142 9738 : aTmpSize = GetVisArea( nAspect ).GetSize();
143 : }
144 : else
145 : {
146 68 : nAspect = ASPECT_THUMBNAIL;
147 68 : aTmpSize = ((SfxObjectShell*)this)->GetFirstPageSize();
148 : }
149 :
150 9806 : pFile->SetPrefSize( aTmpSize );
151 : DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(),
152 : "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
153 :
154 9806 : pFile->Record( &aDevice );
155 :
156 : LanguageType eLang;
157 19612 : SvtCTLOptions aCTLOptions;
158 9806 : if ( SvtCTLOptions::NUMERALS_HINDI == aCTLOptions.GetCTLTextNumerals() )
159 0 : eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
160 9806 : else if ( SvtCTLOptions::NUMERALS_ARABIC == aCTLOptions.GetCTLTextNumerals() )
161 9806 : eLang = LANGUAGE_ENGLISH;
162 : else
163 0 : eLang = (LanguageType) Application::GetSettings().GetLanguageTag().getLanguageType();
164 :
165 9806 : aDevice.SetDigitLanguage( eLang );
166 :
167 : {
168 : SAL_INFO( "sfx.doc", "PERFORMANCE SfxObjectShell::CreatePreviewMetaFile_Impl" );
169 9806 : ((SfxObjectShell*)this)->DoDraw( &aDevice, Point(0,0), aTmpSize, JobSetup(), nAspect );
170 : }
171 9806 : pFile->Stop();
172 :
173 19612 : return pFile;
174 : }
175 :
176 :
177 :
178 1250 : void SfxObjectShell::UpdateDocInfoForSave()
179 : {
180 1250 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
181 :
182 : // clear user data if recommend (see 'Tools - Options - Open/StarOffice - Security')
183 2500 : if ( SvtSecurityOptions().IsOptionSet(
184 2500 : SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO ) )
185 : {
186 0 : xDocProps->resetUserData( OUString() );
187 : }
188 1250 : else if ( IsModified() )
189 : {
190 8 : OUString aUserName = SvtUserOptions().GetFullName();
191 8 : if ( !IsUseUserData() )
192 : {
193 : // remove all data pointing to the current user
194 0 : if (xDocProps->getAuthor().equals(aUserName)) {
195 0 : xDocProps->setAuthor( OUString() );
196 : }
197 0 : xDocProps->setModifiedBy( OUString() );
198 0 : if (xDocProps->getPrintedBy().equals(aUserName)) {
199 0 : xDocProps->setPrintedBy( OUString() );
200 : }
201 : }
202 : else
203 : {
204 : // update ModificationAuthor, revision and editing time
205 8 : ::DateTime now( ::DateTime::SYSTEM );
206 8 : xDocProps->setModificationDate( util::DateTime(
207 24 : now.GetNanoSec(), now.GetSec(), now.GetMin(),
208 24 : now.GetHour(), now.GetDay(), now.GetMonth(),
209 56 : now.GetYear(), false) );
210 8 : xDocProps->setModifiedBy( aUserName );
211 8 : UpdateTime_Impl( xDocProps );
212 8 : }
213 1250 : }
214 1250 : }
215 :
216 :
217 :
218 : static void
219 8 : lcl_add(util::Duration & rDur, tools::Time const& rTime)
220 : {
221 : // here we don't care about overflow: rDur is converted back to seconds
222 : // anyway, and tools::Time cannot store more than ~4000 hours
223 8 : rDur.Hours += rTime.GetHour();
224 8 : rDur.Minutes += rTime.GetMin();
225 8 : rDur.Seconds += rTime.GetSec();
226 8 : }
227 :
228 : // Update the processing time
229 8 : void SfxObjectShell::UpdateTime_Impl(
230 : const uno::Reference<document::XDocumentProperties> & i_xDocProps)
231 : {
232 : // Get old time from documentinfo
233 8 : const sal_Int32 secs = i_xDocProps->getEditingDuration();
234 : util::Duration editDuration(sal_False, 0, 0, 0,
235 8 : secs/3600, (secs%3600)/60, secs%60, 0);
236 :
237 : // Initialize some local member! Its necessary for wollow operations!
238 8 : DateTime aNow( DateTime::SYSTEM ); // Date and time at current moment
239 8 : tools::Time n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation
240 8 : sal_uIntPtr nDays = 0 ; // Count of days between now and last editing
241 8 : tools::Time nAddTime (0) ; // Value to add on aOldTime
242 :
243 : // Safe impossible cases!
244 : // User has changed time to the past between last editing and now ... its not possible!!!
245 : DBG_ASSERT( !(aNow.GetDate()<pImp->nTime.GetDate()), "Timestamp of last change is in the past ?!..." );
246 :
247 : // Do the follow only, if user has NOT changed time to the past.
248 : // Else add a time of 0 to aOldTime ... !!!
249 8 : if (aNow.GetDate()>=pImp->nTime.GetDate())
250 : {
251 : // Get count of days last editing.
252 8 : nDays = aNow.GetSecFromDateTime(pImp->nTime.GetDate())/86400 ;
253 :
254 8 : if (nDays==0)
255 : {
256 : // If no day between now and last editing - calculate time directly.
257 8 : nAddTime = (const tools::Time&)aNow - (const tools::Time&)pImp->nTime ;
258 : }
259 0 : else if (nDays<=31)
260 : {
261 : // If time of working without save greater then 1 month (!) ....
262 : // we add 0 to aOldTime!
263 :
264 : // If 1 or up to 31 days between now and last editing - calculate time indirectly.
265 : // nAddTime = (24h - nTime) + (nDays * 24h) + aNow
266 0 : --nDays;
267 0 : nAddTime = nDays*n24Time.GetTime() ;
268 0 : nAddTime += n24Time-(const tools::Time&)pImp->nTime ;
269 0 : nAddTime += aNow ;
270 : }
271 :
272 8 : lcl_add(editDuration, nAddTime);
273 : }
274 :
275 8 : pImp->nTime = aNow;
276 : try {
277 8 : const sal_Int32 newSecs( (editDuration.Hours*3600)
278 8 : + (editDuration.Minutes*60) + editDuration.Seconds);
279 8 : i_xDocProps->setEditingDuration(newSecs);
280 8 : i_xDocProps->setEditingCycles(i_xDocProps->getEditingCycles() + 1);
281 : }
282 0 : catch (const lang::IllegalArgumentException &)
283 : {
284 : // ignore overflow
285 : }
286 8 : }
287 :
288 :
289 :
290 0 : SfxDocumentInfoDialog* SfxObjectShell::CreateDocumentInfoDialog
291 : (
292 : vcl::Window* pParent,
293 : const SfxItemSet& rSet
294 : )
295 : {
296 0 : return new SfxDocumentInfoDialog(pParent, rSet);
297 : }
298 :
299 :
300 :
301 :
302 0 : std::vector<Color> SfxObjectShell::GetDocColors()
303 : {
304 0 : std::vector<Color> empty;
305 0 : return empty;
306 : }
307 :
308 0 : SfxStyleSheetBasePool* SfxObjectShell::GetStyleSheetPool()
309 : {
310 0 : return 0;
311 : }
312 :
313 : struct Styles_Impl
314 : {
315 : SfxStyleSheetBase *pSource;
316 : SfxStyleSheetBase *pDest;
317 : };
318 :
319 0 : void SfxObjectShell::LoadStyles
320 : (
321 : SfxObjectShell &rSource /* the document template from which
322 : the styles are to be loaded */
323 : )
324 :
325 : /* [Description]
326 :
327 : This method is called by the SFx if template styles are to be loaded.
328 : Existing styles are in this case overwritten. The document has then to be
329 : newly formatted. Therefore, the application of this method is usually
330 : overloaded and its implementation is calling the implementation in
331 : the base class.
332 : */
333 :
334 : {
335 0 : SfxStyleSheetBasePool *pSourcePool = rSource.GetStyleSheetPool();
336 : DBG_ASSERT(pSourcePool, "Source-DocumentShell ohne StyleSheetPool");
337 0 : SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool();
338 : DBG_ASSERT(pMyPool, "Dest-DocumentShell ohne StyleSheetPool");
339 0 : pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_ALL);
340 0 : boost::scoped_array<Styles_Impl> pFound(new Styles_Impl[pSourcePool->Count()]);
341 0 : sal_uInt16 nFound = 0;
342 :
343 0 : SfxStyleSheetBase *pSource = pSourcePool->First();
344 0 : while ( pSource )
345 : {
346 : SfxStyleSheetBase *pDest =
347 0 : pMyPool->Find( pSource->GetName(), pSource->GetFamily() );
348 0 : if ( !pDest )
349 : {
350 0 : pDest = &pMyPool->Make( pSource->GetName(),
351 0 : pSource->GetFamily(), pSource->GetMask());
352 : // Setting of Parents, the next style
353 : }
354 0 : pFound[nFound].pSource = pSource;
355 0 : pFound[nFound].pDest = pDest;
356 0 : ++nFound;
357 0 : pSource = pSourcePool->Next();
358 : }
359 :
360 0 : for ( sal_uInt16 i = 0; i < nFound; ++i )
361 : {
362 0 : pFound[i].pDest->GetItemSet().PutExtended(pFound[i].pSource->GetItemSet(), SfxItemState::DONTCARE, SfxItemState::DEFAULT);
363 0 : if(pFound[i].pSource->HasParentSupport())
364 0 : pFound[i].pDest->SetParent(pFound[i].pSource->GetParent());
365 0 : if(pFound[i].pSource->HasFollowSupport())
366 0 : pFound[i].pDest->SetFollow(pFound[i].pSource->GetParent());
367 0 : }
368 0 : }
369 :
370 :
371 :
372 5506 : void SfxObjectShell::UpdateFromTemplate_Impl( )
373 :
374 : /* [Description]
375 :
376 : This internal method checks whether the document was created from a
377 : template, and if this is newer than the document. If this is the case,
378 : the user is asked if the Templates (StyleSheets) should be updated.
379 : If this is answered positively, the StyleSheets are updated.
380 : */
381 :
382 : {
383 : // Storage-medium?
384 5506 : SfxMedium *pFile = GetMedium();
385 : DBG_ASSERT( pFile, "cannot UpdateFromTemplate without medium" );
386 5506 : if ( !pFile )
387 5112 : return;
388 :
389 5506 : if ( !::utl::LocalFileHelper::IsLocalFile( pFile->GetName() ) )
390 : // update only for documents loaded from the local file system
391 1516 : return;
392 :
393 : // only for own storage formats
394 3990 : uno::Reference< embed::XStorage > xDocStor = pFile->GetStorage();
395 3990 : if ( !pFile->GetFilter() || !pFile->GetFilter()->IsOwnFormat() )
396 3596 : return;
397 :
398 394 : SFX_ITEMSET_ARG( pFile->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
399 394 : sal_Int16 bCanUpdateFromTemplate = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
400 :
401 : // created from template?
402 788 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
403 788 : OUString aTemplName( xDocProps->getTemplateName() );
404 788 : OUString aTemplURL( xDocProps->getTemplateURL() );
405 788 : OUString aFoundName;
406 :
407 394 : if ( !aTemplName.isEmpty() || (!aTemplURL.isEmpty() && !IsReadOnly()) )
408 : {
409 : // try to locate template, first using filename this must be done
410 : // because writer global document uses this "great" idea to manage
411 : // the templates of all parts in the master document but it is NOT
412 : // an error if the template filename points not to a valid file
413 68 : SfxDocumentTemplates aTempl;
414 68 : aTempl.Construct();
415 68 : if (!aTemplURL.isEmpty())
416 : {
417 : try {
418 12 : aFoundName = ::rtl::Uri::convertRelToAbs(GetMedium()->GetName(),
419 6 : aTemplURL);
420 0 : } catch (::rtl::MalformedUriException const&) {
421 : assert(false); // don't think that's supposed to happen?
422 : }
423 : }
424 :
425 68 : if( aFoundName.isEmpty() && !aTemplName.isEmpty() )
426 : // if the template filename did not lead to success,
427 : // try to get a file name for the logical template name
428 62 : aTempl.GetFull( OUString(), aTemplName, aFoundName );
429 : }
430 :
431 394 : if ( !aFoundName.isEmpty() )
432 : {
433 : // check existence of template storage
434 6 : aTemplURL = aFoundName;
435 6 : bool bLoad = false;
436 :
437 : // should the document checked against changes in the template ?
438 6 : if ( IsQueryLoadTemplate() )
439 : {
440 : // load document properties of template
441 6 : bool bOK = false;
442 6 : util::DateTime aTemplDate;
443 : try
444 : {
445 : Reference<document::XDocumentProperties> const
446 : xTemplateDocProps( document::DocumentProperties::create(
447 6 : ::comphelper::getProcessComponentContext()));
448 6 : xTemplateDocProps->loadFromMedium(aTemplURL,
449 12 : Sequence<beans::PropertyValue>());
450 0 : aTemplDate = xTemplateDocProps->getModificationDate();
451 6 : bOK = true;
452 : }
453 6 : catch (const Exception& e)
454 : {
455 : SAL_INFO("sfx.doc", "caught exception" << e.Message);
456 : }
457 :
458 : // if modify date was read successfully
459 6 : if ( bOK )
460 : {
461 : // compare modify data of template with the last check date of the document
462 0 : const util::DateTime aInfoDate( xDocProps->getTemplateDate() );
463 0 : if ( aTemplDate > aInfoDate )
464 : {
465 : // ask user
466 0 : if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE
467 0 : || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE )
468 0 : bLoad = true;
469 0 : else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG )
470 : {
471 0 : OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).toString() );
472 0 : sMessage = sMessage.replaceAll( "$(ARG1)", aTemplName );
473 0 : sfx2::QueryTemplateBox aBox( GetDialogParent(), sMessage );
474 0 : if ( RET_YES == aBox.Execute() )
475 0 : bLoad = true;
476 : }
477 :
478 0 : if( !bLoad )
479 : {
480 : // user refuses, so don't ask again for this document
481 0 : SetQueryLoadTemplate(false);
482 0 : SetModified( true );
483 : }
484 : }
485 : }
486 :
487 6 : if ( bLoad )
488 : {
489 : // styles should be updated, create document in organizer mode to read in the styles
490 : //TODO: testen!
491 0 : SfxObjectShellLock xTemplDoc = CreateObjectByFactoryName( GetFactory().GetFactoryName(), SFX_CREATE_MODE_ORGANIZER );
492 0 : xTemplDoc->DoInitNew(0);
493 :
494 : // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended!
495 : //xTemplDoc->SetBaseURL( aFoundName );
496 :
497 : // TODO/LATER: make sure that we don't use binary templates!
498 0 : SfxMedium aMedium( aFoundName, STREAM_STD_READ );
499 0 : if ( xTemplDoc->LoadFrom( aMedium ) )
500 : {
501 : // transfer styles from xTemplDoc to this document
502 : // TODO/MBA: make sure that no BaseURL is needed in *this* document
503 0 : LoadStyles(*xTemplDoc);
504 :
505 : // remember date/time of check
506 0 : xDocProps->setTemplateDate(aTemplDate);
507 : // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format )
508 0 : }
509 : }
510 : }
511 394 : }
512 : }
513 :
514 7406 : bool SfxObjectShell::IsHelpDocument() const
515 : {
516 7406 : const SfxFilter* pFilter = GetMedium()->GetFilter();
517 7406 : return (pFilter && pFilter->GetFilterName() == "writer_web_HTML_help");
518 : }
519 :
520 68 : void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName )
521 : {
522 : // only care about reseting this data for openoffice formats otherwise
523 68 : if ( IsOwnStorageFormat_Impl( *GetMedium()) )
524 : {
525 8 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
526 8 : xDocProps->setTemplateURL( OUString() );
527 8 : xDocProps->setTemplateName( OUString() );
528 8 : xDocProps->setTemplateDate( util::DateTime() );
529 8 : xDocProps->resetUserData( OUString() );
530 :
531 : // TODO/REFACTOR:
532 : // Title?
533 :
534 8 : if( ::utl::LocalFileHelper::IsLocalFile( rFileName ) )
535 : {
536 8 : OUString aFoundName;
537 8 : if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) )
538 : {
539 0 : INetURLObject aObj( rFileName );
540 0 : xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) );
541 0 : xDocProps->setTemplateName( rTemplateName );
542 :
543 0 : ::DateTime now( ::DateTime::SYSTEM );
544 0 : xDocProps->setTemplateDate( util::DateTime(
545 0 : now.GetNanoSec(), now.GetSec(), now.GetMin(),
546 0 : now.GetHour(), now.GetDay(), now.GetMonth(),
547 0 : now.GetYear(), false) );
548 :
549 0 : SetQueryLoadTemplate( true );
550 8 : }
551 8 : }
552 : }
553 68 : }
554 :
555 180 : bool SfxObjectShell::IsQueryLoadTemplate() const
556 : {
557 180 : return pImp->bQueryLoadTemplate;
558 : }
559 :
560 182 : bool SfxObjectShell::IsUseUserData() const
561 : {
562 182 : return pImp->bUseUserData;
563 : }
564 :
565 614 : void SfxObjectShell::SetQueryLoadTemplate( bool bNew )
566 : {
567 614 : if ( pImp->bQueryLoadTemplate != bNew )
568 28 : SetModified( true );
569 614 : pImp->bQueryLoadTemplate = bNew;
570 614 : }
571 :
572 614 : void SfxObjectShell::SetUseUserData( bool bNew )
573 : {
574 614 : if ( pImp->bUseUserData != bNew )
575 12 : SetModified( true );
576 614 : pImp->bUseUserData = bNew;
577 614 : }
578 :
579 5392 : bool SfxObjectShell::IsLoadReadonly() const
580 : {
581 5392 : return pImp->bLoadReadonly;
582 : }
583 :
584 174 : bool SfxObjectShell::IsSaveVersionOnClose() const
585 : {
586 174 : return pImp->bSaveVersionOnClose;
587 : }
588 :
589 610 : void SfxObjectShell::SetLoadReadonly( bool bNew )
590 : {
591 610 : if ( pImp->bLoadReadonly != bNew )
592 4 : SetModified( true );
593 610 : pImp->bLoadReadonly = bNew;
594 610 : }
595 :
596 614 : void SfxObjectShell::SetSaveVersionOnClose( bool bNew )
597 : {
598 614 : if ( pImp->bSaveVersionOnClose != bNew )
599 6 : SetModified( true );
600 614 : pImp->bSaveVersionOnClose = bNew;
601 614 : }
602 :
603 5914 : sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const
604 : {
605 5914 : return pImp->m_nModifyPasswordHash;
606 : }
607 :
608 2392 : bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash )
609 : {
610 7176 : if ( ( !IsReadOnly() && !IsReadOnlyUI() )
611 2392 : || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) )
612 : {
613 : // the hash can be changed only in editable documents,
614 : // or during loading of document
615 2392 : pImp->m_nModifyPasswordHash = nHash;
616 2392 : return true;
617 : }
618 :
619 0 : return false;
620 : }
621 :
622 5990 : uno::Sequence< beans::PropertyValue > SfxObjectShell::GetModifyPasswordInfo() const
623 : {
624 5990 : return pImp->m_aModifyPasswordInfo;
625 : }
626 :
627 2214 : bool SfxObjectShell::SetModifyPasswordInfo( const uno::Sequence< beans::PropertyValue >& aInfo )
628 : {
629 6642 : if ( ( !IsReadOnly() && !IsReadOnlyUI() )
630 2214 : || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) )
631 : {
632 : // the hash can be changed only in editable documents,
633 : // or during loading of document
634 2214 : pImp->m_aModifyPasswordInfo = aInfo;
635 2214 : return true;
636 : }
637 :
638 0 : return false;
639 : }
640 :
641 18 : void SfxObjectShell::SetModifyPasswordEntered( bool bEntered )
642 : {
643 18 : pImp->m_bModifyPasswordEntered = bEntered;
644 18 : }
645 :
646 2 : bool SfxObjectShell::IsModifyPasswordEntered()
647 : {
648 2 : return pImp->m_bModifyPasswordEntered;
649 951 : }
650 :
651 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|