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 : #include <LibreOfficeKit/LibreOfficeKitTypes.h>
80 :
81 : #include <typeinfo>
82 :
83 : using namespace ::com::sun::star;
84 : using namespace ::com::sun::star::uno;
85 :
86 :
87 :
88 : static
89 0 : bool operator> (const util::DateTime& i_rLeft, const util::DateTime& i_rRight)
90 : {
91 0 : if ( i_rLeft.Year != i_rRight.Year )
92 0 : return i_rLeft.Year > i_rRight.Year;
93 :
94 0 : if ( i_rLeft.Month != i_rRight.Month )
95 0 : return i_rLeft.Month > i_rRight.Month;
96 :
97 0 : if ( i_rLeft.Day != i_rRight.Day )
98 0 : return i_rLeft.Day > i_rRight.Day;
99 :
100 0 : if ( i_rLeft.Hours != i_rRight.Hours )
101 0 : return i_rLeft.Hours > i_rRight.Hours;
102 :
103 0 : if ( i_rLeft.Minutes != i_rRight.Minutes )
104 0 : return i_rLeft.Minutes > i_rRight.Minutes;
105 :
106 0 : if ( i_rLeft.Seconds != i_rRight.Seconds )
107 0 : return i_rLeft.Seconds > i_rRight.Seconds;
108 :
109 0 : if ( i_rLeft.NanoSeconds != i_rRight.NanoSeconds )
110 0 : return i_rLeft.NanoSeconds > i_rRight.NanoSeconds;
111 :
112 0 : return false;
113 : }
114 :
115 : std::shared_ptr<GDIMetaFile>
116 4981 : SfxObjectShell::GetPreviewMetaFile( bool bFullContent ) const
117 : {
118 4981 : return CreatePreviewMetaFile_Impl( bFullContent );
119 : }
120 :
121 : std::shared_ptr<GDIMetaFile>
122 4981 : SfxObjectShell::CreatePreviewMetaFile_Impl( bool bFullContent ) const
123 : {
124 : // DoDraw can only be called when no printing is done, otherwise
125 : // the printer may be turned off
126 4981 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
127 5061 : if ( pFrame && pFrame->GetViewShell() &&
128 5025 : pFrame->GetViewShell()->GetPrinter() &&
129 4 : pFrame->GetViewShell()->GetPrinter()->IsPrinting() )
130 0 : return std::shared_ptr<GDIMetaFile>();
131 :
132 4981 : std::shared_ptr<GDIMetaFile> xFile(new GDIMetaFile);
133 :
134 9962 : ScopedVclPtrInstance< VirtualDevice > pDevice;
135 4981 : pDevice->EnableOutput( false );
136 :
137 9962 : MapMode aMode( this->GetMapUnit() );
138 4981 : pDevice->SetMapMode( aMode );
139 4981 : xFile->SetPrefMapMode( aMode );
140 :
141 4981 : Size aTmpSize;
142 : sal_Int8 nAspect;
143 4981 : if ( bFullContent )
144 : {
145 4903 : nAspect = ASPECT_CONTENT;
146 4903 : aTmpSize = GetVisArea( nAspect ).GetSize();
147 : }
148 : else
149 : {
150 78 : nAspect = ASPECT_THUMBNAIL;
151 78 : aTmpSize = const_cast<SfxObjectShell*>(this)->GetFirstPageSize();
152 : }
153 :
154 4981 : xFile->SetPrefSize( aTmpSize );
155 : DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(),
156 : "size of first page is 0, override GetFirstPageSize or set vis-area!" );
157 :
158 4981 : xFile->Record( pDevice );
159 :
160 : LanguageType eLang;
161 9962 : SvtCTLOptions aCTLOptions;
162 4981 : if ( SvtCTLOptions::NUMERALS_HINDI == aCTLOptions.GetCTLTextNumerals() )
163 0 : eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
164 4981 : else if ( SvtCTLOptions::NUMERALS_ARABIC == aCTLOptions.GetCTLTextNumerals() )
165 4981 : eLang = LANGUAGE_ENGLISH;
166 : else
167 0 : eLang = (LanguageType) Application::GetSettings().GetLanguageTag().getLanguageType();
168 :
169 4981 : pDevice->SetDigitLanguage( eLang );
170 :
171 4981 : const_cast<SfxObjectShell*>(this)->DoDraw( pDevice, Point(0,0), aTmpSize, JobSetup(), nAspect );
172 :
173 4981 : xFile->Stop();
174 :
175 9962 : return xFile;
176 : }
177 :
178 :
179 :
180 831 : void SfxObjectShell::UpdateDocInfoForSave()
181 : {
182 831 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
183 :
184 : // clear user data if recommend (see 'Tools - Options - Open/StarOffice - Security')
185 1662 : if ( SvtSecurityOptions().IsOptionSet(
186 1662 : SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO ) )
187 : {
188 0 : xDocProps->resetUserData( OUString() );
189 : }
190 831 : else if ( IsModified() )
191 : {
192 42 : OUString aUserName = SvtUserOptions().GetFullName();
193 42 : if ( !IsUseUserData() )
194 : {
195 : // remove all data pointing to the current user
196 0 : if (xDocProps->getAuthor().equals(aUserName)) {
197 0 : xDocProps->setAuthor( OUString() );
198 : }
199 0 : xDocProps->setModifiedBy( OUString() );
200 0 : if (xDocProps->getPrintedBy().equals(aUserName)) {
201 0 : xDocProps->setPrintedBy( OUString() );
202 : }
203 : }
204 : else
205 : {
206 : // update ModificationAuthor, revision and editing time
207 42 : ::DateTime now( ::DateTime::SYSTEM );
208 42 : xDocProps->setModificationDate( now.GetUNODateTime() );
209 42 : xDocProps->setModifiedBy( aUserName );
210 42 : UpdateTime_Impl( xDocProps );
211 42 : }
212 831 : }
213 831 : }
214 :
215 :
216 :
217 : static void
218 42 : lcl_add(util::Duration & rDur, tools::Time const& rTime)
219 : {
220 : // here we don't care about overflow: rDur is converted back to seconds
221 : // anyway, and tools::Time cannot store more than ~4000 hours
222 42 : rDur.Hours += rTime.GetHour();
223 42 : rDur.Minutes += rTime.GetMin();
224 42 : rDur.Seconds += rTime.GetSec();
225 42 : }
226 :
227 : // Update the processing time
228 42 : void SfxObjectShell::UpdateTime_Impl(
229 : const uno::Reference<document::XDocumentProperties> & i_xDocProps)
230 : {
231 : // Get old time from documentinfo
232 42 : const sal_Int32 secs = i_xDocProps->getEditingDuration();
233 : util::Duration editDuration(sal_False, 0, 0, 0,
234 42 : secs/3600, (secs%3600)/60, secs%60, 0);
235 :
236 : // Initialize some local member! Its necessary for wollow operations!
237 42 : DateTime aNow( DateTime::SYSTEM ); // Date and time at current moment
238 42 : tools::Time n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation
239 42 : sal_uIntPtr nDays = 0 ; // Count of days between now and last editing
240 42 : tools::Time nAddTime (0) ; // Value to add on aOldTime
241 :
242 : // Safe impossible cases!
243 : // User has changed time to the past between last editing and now ... its not possible!!!
244 : DBG_ASSERT( !(aNow.GetDate()<pImp->nTime.GetDate()), "Timestamp of last change is in the past ?!..." );
245 :
246 : // Do the follow only, if user has NOT changed time to the past.
247 : // Else add a time of 0 to aOldTime ... !!!
248 42 : if (aNow.GetDate()>=pImp->nTime.GetDate())
249 : {
250 : // Get count of days last editing.
251 42 : nDays = aNow.GetSecFromDateTime(pImp->nTime.GetDate())/86400 ;
252 :
253 42 : if (nDays==0)
254 : {
255 : // If no day between now and last editing - calculate time directly.
256 42 : nAddTime = (const tools::Time&)aNow - (const tools::Time&)pImp->nTime ;
257 : }
258 0 : else if (nDays<=31)
259 : {
260 : // If time of working without save greater then 1 month (!) ....
261 : // we add 0 to aOldTime!
262 :
263 : // If 1 or up to 31 days between now and last editing - calculate time indirectly.
264 : // nAddTime = (24h - nTime) + (nDays * 24h) + aNow
265 0 : --nDays;
266 0 : nAddTime = nDays*n24Time.GetTime() ;
267 0 : nAddTime += n24Time-(const tools::Time&)pImp->nTime ;
268 0 : nAddTime += aNow ;
269 : }
270 :
271 42 : lcl_add(editDuration, nAddTime);
272 : }
273 :
274 42 : pImp->nTime = aNow;
275 : try {
276 42 : const sal_Int32 newSecs( (editDuration.Hours*3600)
277 42 : + (editDuration.Minutes*60) + editDuration.Seconds);
278 42 : i_xDocProps->setEditingDuration(newSecs);
279 42 : i_xDocProps->setEditingCycles(i_xDocProps->getEditingCycles() + 1);
280 : }
281 0 : catch (const lang::IllegalArgumentException &)
282 : {
283 : // ignore overflow
284 : }
285 42 : }
286 :
287 :
288 :
289 0 : VclPtr<SfxDocumentInfoDialog> SfxObjectShell::CreateDocumentInfoDialog
290 : (
291 : vcl::Window* pParent,
292 : const SfxItemSet& rSet
293 : )
294 : {
295 0 : return VclPtr<SfxDocumentInfoDialog>::Create(pParent, rSet);
296 : }
297 :
298 :
299 :
300 :
301 0 : std::set<Color> SfxObjectShell::GetDocColors()
302 : {
303 0 : std::set<Color> empty;
304 0 : return empty;
305 : }
306 :
307 0 : SfxStyleSheetBasePool* SfxObjectShell::GetStyleSheetPool()
308 : {
309 0 : return 0;
310 : }
311 :
312 : struct Styles_Impl
313 : {
314 : SfxStyleSheetBase *pSource;
315 : SfxStyleSheetBase *pDest;
316 : };
317 :
318 0 : void SfxObjectShell::LoadStyles
319 : (
320 : SfxObjectShell &rSource /* the document template from which
321 : the styles are to be loaded */
322 : )
323 :
324 : /* [Description]
325 :
326 : This method is called by the SFx if styles are to be loaded from a template.
327 : Existing styles are in this case overwritten. The document must then be
328 : re-formatted. Therefore, applications usually override this method
329 : and call the implementation in the base class.
330 : */
331 :
332 : {
333 0 : SfxStyleSheetBasePool *pSourcePool = rSource.GetStyleSheetPool();
334 : DBG_ASSERT(pSourcePool, "Source-DocumentShell ohne StyleSheetPool");
335 0 : SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool();
336 : DBG_ASSERT(pMyPool, "Dest-DocumentShell ohne StyleSheetPool");
337 0 : pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_ALL);
338 0 : boost::scoped_array<Styles_Impl> pFound(new Styles_Impl[pSourcePool->Count()]);
339 0 : sal_uInt16 nFound = 0;
340 :
341 0 : SfxStyleSheetBase *pSource = pSourcePool->First();
342 0 : while ( pSource )
343 : {
344 : SfxStyleSheetBase *pDest =
345 0 : pMyPool->Find( pSource->GetName(), pSource->GetFamily() );
346 0 : if ( !pDest )
347 : {
348 0 : pDest = &pMyPool->Make( pSource->GetName(),
349 0 : pSource->GetFamily(), pSource->GetMask());
350 : // Setting of Parents, the next style
351 : }
352 0 : pFound[nFound].pSource = pSource;
353 0 : pFound[nFound].pDest = pDest;
354 0 : ++nFound;
355 0 : pSource = pSourcePool->Next();
356 : }
357 :
358 0 : for ( sal_uInt16 i = 0; i < nFound; ++i )
359 : {
360 0 : pFound[i].pDest->GetItemSet().PutExtended(pFound[i].pSource->GetItemSet(), SfxItemState::DONTCARE, SfxItemState::DEFAULT);
361 0 : if(pFound[i].pSource->HasParentSupport())
362 0 : pFound[i].pDest->SetParent(pFound[i].pSource->GetParent());
363 0 : if(pFound[i].pSource->HasFollowSupport())
364 0 : pFound[i].pDest->SetFollow(pFound[i].pSource->GetParent());
365 0 : }
366 0 : }
367 :
368 0 : sfx2::StyleManager* SfxObjectShell::GetStyleManager()
369 : {
370 0 : return nullptr;
371 : }
372 :
373 3249 : void SfxObjectShell::UpdateFromTemplate_Impl( )
374 :
375 : /* [Description]
376 :
377 : This internal method checks whether the document was created from a
378 : template, and if this is newer than the document. If this is the case,
379 : the user is asked if the Templates (StyleSheets) should be updated.
380 : If this is answered positively, the StyleSheets are updated.
381 : */
382 :
383 : {
384 : // Storage-medium?
385 3249 : SfxMedium *pFile = GetMedium();
386 : DBG_ASSERT( pFile, "cannot UpdateFromTemplate without medium" );
387 3249 : if ( !pFile )
388 2893 : return;
389 :
390 3249 : if ( !::utl::LocalFileHelper::IsLocalFile( pFile->GetName() ) )
391 : // update only for documents loaded from the local file system
392 807 : return;
393 :
394 : // only for own storage formats
395 2442 : uno::Reference< embed::XStorage > xDocStor = pFile->GetStorage();
396 2442 : if ( !pFile->GetFilter() || !pFile->GetFilter()->IsOwnFormat() )
397 2086 : return;
398 :
399 356 : SFX_ITEMSET_ARG( pFile->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
400 356 : sal_Int16 bCanUpdateFromTemplate = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
401 :
402 : // created from template?
403 712 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
404 712 : OUString aTemplName( xDocProps->getTemplateName() );
405 712 : OUString aTemplURL( xDocProps->getTemplateURL() );
406 712 : OUString aFoundName;
407 :
408 356 : if ( !aTemplName.isEmpty() || (!aTemplURL.isEmpty() && !IsReadOnly()) )
409 : {
410 : // try to locate template, first using filename this must be done
411 : // because writer global document uses this "great" idea to manage
412 : // the templates of all parts in the master document but it is NOT
413 : // an error if the template filename points not to a valid file
414 41 : SfxDocumentTemplates aTempl;
415 41 : 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 41 : 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 35 : aTempl.GetFull( OUString(), aTemplName, aFoundName );
429 : }
430 :
431 356 : if ( !aFoundName.isEmpty() )
432 : {
433 : // check existence of template storage
434 6 : aTemplURL = aFoundName;
435 :
436 : // should the document checked against changes in the template ?
437 6 : if ( IsQueryLoadTemplate() )
438 : {
439 6 : bool bLoad = false;
440 :
441 : // load document properties of template
442 6 : bool bOK = false;
443 6 : util::DateTime aTemplDate;
444 : try
445 : {
446 : Reference<document::XDocumentProperties> const
447 : xTemplateDocProps( document::DocumentProperties::create(
448 6 : ::comphelper::getProcessComponentContext()));
449 6 : xTemplateDocProps->loadFromMedium(aTemplURL,
450 12 : Sequence<beans::PropertyValue>());
451 0 : aTemplDate = xTemplateDocProps->getModificationDate();
452 6 : bOK = true;
453 : }
454 6 : catch (const Exception& e)
455 : {
456 : SAL_INFO("sfx.doc", "caught exception" << e.Message);
457 : }
458 :
459 : // if modify date was read successfully
460 6 : if ( bOK )
461 : {
462 : // compare modify data of template with the last check date of the document
463 0 : const util::DateTime aInfoDate( xDocProps->getTemplateDate() );
464 0 : if ( aTemplDate > aInfoDate )
465 : {
466 : // ask user
467 0 : if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE
468 0 : || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE )
469 0 : bLoad = true;
470 0 : else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG )
471 : {
472 0 : OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).toString() );
473 0 : sMessage = sMessage.replaceAll( "$(ARG1)", aTemplName );
474 0 : ScopedVclPtrInstance< sfx2::QueryTemplateBox > aBox(GetDialogParent(), sMessage);
475 0 : if ( RET_YES == aBox->Execute() )
476 0 : bLoad = true;
477 : }
478 :
479 0 : if( !bLoad )
480 : {
481 : // user refuses, so don't ask again for this document
482 0 : SetQueryLoadTemplate(false);
483 0 : SetModified( true );
484 : }
485 : }
486 : }
487 :
488 6 : if ( bLoad )
489 : {
490 : // styles should be updated, create document in organizer mode to read in the styles
491 : //TODO: testen!
492 0 : SfxObjectShellLock xTemplDoc = CreateObjectByFactoryName( GetFactory().GetFactoryName(), SfxObjectCreateMode::ORGANIZER );
493 0 : xTemplDoc->DoInitNew(0);
494 :
495 : // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended!
496 : //xTemplDoc->SetBaseURL( aFoundName );
497 :
498 : // TODO/LATER: make sure that we don't use binary templates!
499 0 : SfxMedium aMedium( aFoundName, STREAM_STD_READ );
500 0 : if ( xTemplDoc->LoadFrom( aMedium ) )
501 : {
502 : // transfer styles from xTemplDoc to this document
503 : // TODO/MBA: make sure that no BaseURL is needed in *this* document
504 0 : LoadStyles(*xTemplDoc);
505 :
506 : // remember date/time of check
507 0 : xDocProps->setTemplateDate(aTemplDate);
508 : // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format )
509 0 : }
510 : }
511 : }
512 356 : }
513 : }
514 :
515 75307489 : bool SfxObjectShell::IsHelpDocument() const
516 : {
517 75307489 : const SfxFilter* pFilter = GetMedium()->GetFilter();
518 75307489 : return (pFilter && pFilter->GetFilterName() == "writer_web_HTML_help");
519 : }
520 :
521 49 : void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName )
522 : {
523 : // only care about reseting this data for openoffice formats otherwise
524 49 : if ( IsOwnStorageFormat_Impl( *GetMedium()) )
525 : {
526 4 : uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
527 4 : xDocProps->setTemplateURL( OUString() );
528 4 : xDocProps->setTemplateName( OUString() );
529 4 : xDocProps->setTemplateDate( util::DateTime() );
530 4 : xDocProps->resetUserData( OUString() );
531 :
532 : // TODO/REFACTOR:
533 : // Title?
534 :
535 4 : if( ::utl::LocalFileHelper::IsLocalFile( rFileName ) )
536 : {
537 4 : OUString aFoundName;
538 4 : if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) )
539 : {
540 0 : INetURLObject aObj( rFileName );
541 0 : xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) );
542 0 : xDocProps->setTemplateName( rTemplateName );
543 :
544 0 : ::DateTime now( ::DateTime::SYSTEM );
545 0 : xDocProps->setTemplateDate( now.GetUNODateTime() );
546 :
547 0 : SetQueryLoadTemplate( true );
548 4 : }
549 4 : }
550 : }
551 49 : }
552 :
553 171 : bool SfxObjectShell::IsQueryLoadTemplate() const
554 : {
555 171 : return pImp->bQueryLoadTemplate;
556 : }
557 :
558 207 : bool SfxObjectShell::IsUseUserData() const
559 : {
560 207 : return pImp->bUseUserData;
561 : }
562 :
563 498 : void SfxObjectShell::SetQueryLoadTemplate( bool bNew )
564 : {
565 498 : if ( pImp->bQueryLoadTemplate != bNew )
566 26 : SetModified( true );
567 498 : pImp->bQueryLoadTemplate = bNew;
568 498 : }
569 :
570 498 : void SfxObjectShell::SetUseUserData( bool bNew )
571 : {
572 498 : if ( pImp->bUseUserData != bNew )
573 12 : SetModified( true );
574 498 : pImp->bUseUserData = bNew;
575 498 : }
576 :
577 3236 : bool SfxObjectShell::IsLoadReadonly() const
578 : {
579 3236 : return pImp->bLoadReadonly;
580 : }
581 :
582 165 : bool SfxObjectShell::IsSaveVersionOnClose() const
583 : {
584 165 : return pImp->bSaveVersionOnClose;
585 : }
586 :
587 496 : void SfxObjectShell::SetLoadReadonly( bool bNew )
588 : {
589 496 : if ( pImp->bLoadReadonly != bNew )
590 2 : SetModified( true );
591 496 : pImp->bLoadReadonly = bNew;
592 496 : }
593 :
594 498 : void SfxObjectShell::SetSaveVersionOnClose( bool bNew )
595 : {
596 498 : if ( pImp->bSaveVersionOnClose != bNew )
597 3 : SetModified( true );
598 498 : pImp->bSaveVersionOnClose = bNew;
599 498 : }
600 :
601 3713 : sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const
602 : {
603 3713 : return pImp->m_nModifyPasswordHash;
604 : }
605 :
606 1508 : bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash )
607 : {
608 7504 : if ( ( !IsReadOnly() && !IsReadOnlyUI() )
609 4560 : || !(pImp->nFlagsInProgress & SfxLoadedFlags::MAINDOCUMENT ) )
610 : {
611 : // the hash can be changed only in editable documents,
612 : // or during loading of document
613 1508 : pImp->m_nModifyPasswordHash = nHash;
614 1508 : return true;
615 : }
616 :
617 0 : return false;
618 : }
619 :
620 3784 : uno::Sequence< beans::PropertyValue > SfxObjectShell::GetModifyPasswordInfo() const
621 : {
622 3784 : return pImp->m_aModifyPasswordInfo;
623 : }
624 :
625 1387 : bool SfxObjectShell::SetModifyPasswordInfo( const uno::Sequence< beans::PropertyValue >& aInfo )
626 : {
627 6899 : if ( ( !IsReadOnly() && !IsReadOnlyUI() )
628 4197 : || !(pImp->nFlagsInProgress & SfxLoadedFlags::MAINDOCUMENT ) )
629 : {
630 : // the hash can be changed only in editable documents,
631 : // or during loading of document
632 1387 : pImp->m_aModifyPasswordInfo = aInfo;
633 1387 : return true;
634 : }
635 :
636 0 : return false;
637 : }
638 :
639 15 : void SfxObjectShell::SetModifyPasswordEntered( bool bEntered )
640 : {
641 15 : pImp->m_bModifyPasswordEntered = bEntered;
642 15 : }
643 :
644 1 : bool SfxObjectShell::IsModifyPasswordEntered()
645 : {
646 1 : return pImp->m_bModifyPasswordEntered;
647 : }
648 :
649 0 : void SfxObjectShell::libreOfficeKitCallback(int /*nType*/, const char* /*pPayload*/) const
650 : {
651 : SAL_INFO("tiled-rendering", "SfxObjectShell::libreOfficeKitCallback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
652 0 : }
653 :
654 60 : bool SfxObjectShell::isTiledRendering() const
655 : {
656 : SAL_INFO("tiled-rendering", "SfxObjectShell::isTiledRendering interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
657 60 : return false;
658 648 : }
659 :
660 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|