1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objcont.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 #include <com/sun/star/uno/Reference.hxx>
36 #include <com/sun/star/document/XDocumentProperties.hpp>
37 #include <com/sun/star/document/UpdateDocMode.hpp>
38 #include <com/sun/star/frame/XLayoutManager.hpp>
39 #include <com/sun/star/embed/ElementModes.hpp>
40 #include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
41 #include <com/sun/star/beans/XFastPropertySet.hpp>
42 #include <tools/cachestr.hxx>
43 #include <vcl/msgbox.hxx>
44 #include <svtools/style.hxx>
45 #include <vcl/wrkwin.hxx>
47 #include <svtools/stritem.hxx>
48 #include <svtools/intitem.hxx>
49 #include <svtools/rectitem.hxx>
50 #include <svtools/eitem.hxx>
51 #include <svtools/urihelper.hxx>
52 #include <svtools/ctloptions.hxx>
53 #include <comphelper/processfactory.hxx>
54 #include <comphelper/storagehelper.hxx>
55 #include <svtools/securityoptions.hxx>
56 #include <svtools/sfxecode.hxx>
57 #include <svtools/ehdl.hxx>
58 #include <tools/datetime.hxx>
61 #include <svtools/saveopt.hxx>
62 #include <svtools/useroptions.hxx>
63 #include <unotools/localfilehelper.hxx>
64 #include <vcl/virdev.hxx>
66 #include <sfx2/app.hxx>
67 #include "sfxresid.hxx"
68 #include "appdata.hxx"
69 #include <sfx2/dinfdlg.hxx>
71 #include <sfx2/docfac.hxx>
72 #include <sfx2/viewsh.hxx>
73 #include <sfx2/objsh.hxx>
74 #include "objshimp.hxx"
75 #include <sfx2/evntconf.hxx>
76 #include "sfxhelp.hxx"
77 #include <sfx2/dispatch.hxx>
78 #include <sfx2/printer.hxx>
79 #include <sfx2/topfrm.hxx>
81 #include <sfx2/doctempl.hxx>
83 #include <sfx2/sfxbasemodel.hxx>
84 #include <sfx2/docfile.hxx>
85 #include <sfx2/request.hxx>
86 #include "openflag.hxx"
87 #include "querytemplate.hxx"
89 using namespace ::com::sun::star
;
90 using namespace ::com::sun::star::uno
;
92 //====================================================================
94 #define SFX_WINDOWS_STREAM "SfxWindows"
95 #define SFX_PREVIEW_STREAM "SfxPreview"
97 //====================================================================
100 bool operator> (const util::DateTime
& i_rLeft
, const util::DateTime
& i_rRight
)
102 if ( i_rLeft
.Year
!= i_rRight
.Year
)
103 return i_rLeft
.Year
> i_rRight
.Year
;
105 if ( i_rLeft
.Month
!= i_rRight
.Month
)
106 return i_rLeft
.Month
> i_rRight
.Month
;
108 if ( i_rLeft
.Day
!= i_rRight
.Day
)
109 return i_rLeft
.Day
> i_rRight
.Day
;
111 if ( i_rLeft
.Hours
!= i_rRight
.Hours
)
112 return i_rLeft
.Hours
> i_rRight
.Hours
;
114 if ( i_rLeft
.Minutes
!= i_rRight
.Minutes
)
115 return i_rLeft
.Minutes
> i_rRight
.Minutes
;
117 if ( i_rLeft
.Seconds
!= i_rRight
.Seconds
)
118 return i_rLeft
.Seconds
> i_rRight
.Seconds
;
120 if ( i_rLeft
.HundredthSeconds
!= i_rRight
.HundredthSeconds
)
121 return i_rLeft
.HundredthSeconds
> i_rRight
.HundredthSeconds
;
127 ::boost::shared_ptr
<GDIMetaFile
>
128 SfxObjectShell::GetPreviewMetaFile( sal_Bool bFullContent
) const
130 return CreatePreviewMetaFile_Impl( bFullContent
, sal_False
);
134 ::boost::shared_ptr
<GDIMetaFile
>
135 SfxObjectShell::CreatePreviewMetaFile_Impl( sal_Bool bFullContent
, sal_Bool bHighContrast
) const
137 // Nur wenn gerade nicht gedruckt wird, darf DoDraw aufgerufen
138 // werden, sonst wird u.U. der Printer abgeschossen !
139 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( this );
140 if ( pFrame
&& pFrame
->GetViewShell() &&
141 pFrame
->GetViewShell()->GetPrinter() &&
142 pFrame
->GetViewShell()->GetPrinter()->IsPrinting() )
143 return ::boost::shared_ptr
<GDIMetaFile
>();
145 ::boost::shared_ptr
<GDIMetaFile
> pFile(new GDIMetaFile
);
147 VirtualDevice aDevice
;
148 aDevice
.EnableOutput( FALSE
);
150 // adjust the output device if HC-metafile is requested
152 aDevice
.SetDrawMode( aDevice
.GetDrawMode() | DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
| DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
);
154 MapMode
aMode( ((SfxObjectShell
*)this)->GetMapUnit() );
155 aDevice
.SetMapMode( aMode
);
156 pFile
->SetPrefMapMode( aMode
);
162 nAspect
= ASPECT_CONTENT
;
163 aTmpSize
= GetVisArea( nAspect
).GetSize();
167 nAspect
= ASPECT_THUMBNAIL
;
168 aTmpSize
= ((SfxObjectShell
*)this)->GetFirstPageSize();
171 pFile
->SetPrefSize( aTmpSize
);
172 DBG_ASSERT( aTmpSize
.Height()*aTmpSize
.Width(),
173 "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
175 pFile
->Record( &aDevice
);
178 SvtCTLOptions
* pCTLOptions
= new SvtCTLOptions
;
179 if ( SvtCTLOptions::NUMERALS_HINDI
== pCTLOptions
->GetCTLTextNumerals() )
180 eLang
= LANGUAGE_ARABIC_SAUDI_ARABIA
;
181 else if ( SvtCTLOptions::NUMERALS_ARABIC
== pCTLOptions
->GetCTLTextNumerals() )
182 eLang
= LANGUAGE_ENGLISH
;
184 eLang
= (LanguageType
) Application::GetSettings().GetLanguage();
186 aDevice
.SetDigitLanguage( eLang
);
188 ((SfxObjectShell
*)this)->DoDraw( &aDevice
, Point(0,0), aTmpSize
, JobSetup(), nAspect
);
194 //REMOVE FASTBOOL SfxObjectShell::SaveWindows_Impl( SvStorage &rStor ) const
196 //REMOVE SvStorageStreamRef xStream = rStor.OpenStream( DEFINE_CONST_UNICODE( SFX_WINDOWS_STREAM ),
197 //REMOVE STREAM_TRUNC | STREAM_STD_READWRITE);
198 //REMOVE if ( !xStream )
199 //REMOVE return FALSE;
201 //REMOVE xStream->SetBufferSize(1024);
202 //REMOVE xStream->SetVersion( rStor.GetVersion() );
204 //REMOVE // "uber alle Fenster iterieren (aber aktives Window zuletzt)
205 //REMOVE SfxViewFrame *pActFrame = SfxViewFrame::Current();
206 //REMOVE if ( !pActFrame || pActFrame->GetObjectShell() != this )
207 //REMOVE pActFrame = SfxViewFrame::GetFirst(this);
209 //REMOVE String aActWinData;
210 //REMOVE for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame) ); pFrame;
211 //REMOVE pFrame = SfxViewFrame::GetNext(*pFrame, this, TYPE(SfxTopViewFrame) ) )
213 //REMOVE // Bei Dokumenten, die Outplace aktiv sind, kann beim Speichern auch schon die View weg sein!
214 //REMOVE if ( pFrame->GetViewShell() )
216 //REMOVE SfxTopFrame* pTop = (SfxTopFrame*) pFrame->GetFrame();
217 //REMOVE pTop->GetTopWindow_Impl();
219 //REMOVE char cToken = ',';
220 //REMOVE const BOOL bActWin = pActFrame == pFrame;
221 //REMOVE String aUserData;
222 //REMOVE pFrame->GetViewShell()->WriteUserData(aUserData);
224 //REMOVE // assemble ini-data
225 //REMOVE String aWinData;
226 //REMOVE aWinData += String::CreateFromInt32( pFrame->GetCurViewId() );
227 //REMOVE aWinData += cToken;
229 //REMOVE if ( !pWin || pWin->IsMaximized() )
230 //REMOVE aWinData += SFX_WINSIZE_MAX;
231 //REMOVE else if ( pWin->IsMinimized() )
232 //REMOVE aWinData += SFX_WINSIZE_MIN;
235 //REMOVE aWinData += cToken;
236 //REMOVE aWinData += aUserData;
238 //REMOVE // aktives kennzeichnen
239 //REMOVE aWinData += cToken;
240 //REMOVE aWinData += bActWin ? '1' : '0';
242 //REMOVE // je nachdem merken oder abspeichern
243 //REMOVE if ( bActWin )
244 //REMOVE aActWinData = aWinData;
246 //REMOVE xStream->WriteByteString( aWinData );
250 //REMOVE // aktives Window hinterher
251 //REMOVE xStream->WriteByteString( aActWinData );
252 //REMOVE return !xStream->GetError();
255 //====================================================================
257 SfxViewFrame
* SfxObjectShell::LoadWindows_Impl( SfxTopFrame
*pPreferedFrame
)
259 DBG_ASSERT( pPreferedFrame
, "Call without preferred Frame is not supported anymore!" );
260 if ( pImp
->bLoadingWindows
|| !pPreferedFrame
)
263 DBG_ASSERT( GetMedium(), "A Medium should exist here!");
269 SfxViewFrame
*pPrefered
= pPreferedFrame
? pPreferedFrame
->GetCurrentViewFrame() : 0;
271 BOOL bLoadDocWins
= aOpt
.IsSaveDocWins() && !pPrefered
;
273 // try to get viewdata information for XML format
274 REFERENCE
< XVIEWDATASUPPLIER
> xViewDataSupplier( GetModel(), ::com::sun::star::uno::UNO_QUERY
);
275 REFERENCE
< XINDEXACCESS
> xViewData
;
277 if ( xViewDataSupplier
.is() )
279 xViewData
= xViewDataSupplier
->getViewData();
280 if ( !xViewData
.is() )
286 SfxViewFrame
*pActiveFrame
= 0;
288 SfxItemSet
*pSet
= GetMedium()->GetItemSet();
290 pImp
->bLoadingWindows
= TRUE
;
291 BOOL bLoaded
= FALSE
;
294 // get saved information for all views
298 FASTBOOL bMaximized
=FALSE
;
300 String aUserData
; // used in the binary format
301 SEQUENCE
< PROPERTYVALUE
> aSeq
; // used in the XML format
304 // active view is the first view in the container
305 FASTBOOL bActive
= ( nView
== 0 );
307 if ( nView
== xViewData
->getCount() )
311 // get viewdata and look for the stored ViewId
312 ::com::sun::star::uno::Any aAny
= xViewData
->getByIndex( nView
++ );
315 for ( sal_Int32 n
=0; n
<aSeq
.getLength(); n
++ )
317 const PROPERTYVALUE
& rProp
= aSeq
[n
];
318 if ( rProp
.Name
.compareToAscii("ViewId") == COMPARE_EQUAL
)
323 aTmp
.Erase( 0, 4 ); // format is like in "view3"
324 nViewId
= (USHORT
) aTmp
.ToInt32();
330 // load only active view, but current item is not the active one ?
331 // in XML format the active view is the first one
332 if ( !bLoadDocWins
&& !bActive
)
335 // check for minimized/maximized/size
336 if ( aPosSize
.EqualsAscii( "max" ) )
338 else if ( aPosSize
.EqualsAscii( "min" ) )
349 pSet
->ClearItem( SID_USER_DATA
);
350 SfxViewFrame
*pFrame
= 0;
353 // use the frame from the arguments, but don't set a window size
355 if ( pFrame
->GetViewShell() || !pFrame
->GetObjectShell() )
357 pSet
->ClearItem( SID_VIEW_POS_SIZE
);
358 pSet
->ClearItem( SID_WIN_POSSIZE
);
359 pSet
->Put( SfxUInt16Item( SID_VIEW_ID
, nViewId
) );
361 // avoid flickering controllers
362 SfxBindings
&rBind
= pFrame
->GetBindings();
363 rBind
.ENTERREGISTRATIONS();
365 // set document into frame
366 pPreferedFrame
->InsertDocument( this );
368 // restart controller updating
369 rBind
.LEAVEREGISTRATIONS();
374 pFrame
->CreateView_Impl( nViewId
);
381 // open in the background
382 pSet
->Put( SfxUInt16Item( SID_VIEW_ZOOM_MODE
, 0 ) );
384 pSet
->Put( SfxRectangleItem( SID_VIEW_POS_SIZE
, Rectangle( aPt
, aSz
) ) );
387 pSet
->Put( SfxUInt16Item( SID_VIEW_ID
, nViewId
) );
389 if ( pPreferedFrame
)
391 // Frame "ubergeben, allerdings ist der noch leer
392 pPreferedFrame
->InsertDocument( this );
393 pFrame
= pPreferedFrame
->GetCurrentViewFrame();
397 pFrame
= SfxTopFrame::Create( this, nViewId
, FALSE
, pSet
)->GetCurrentViewFrame();
400 // only temporary data, don't hold it in the itemset
401 pSet
->ClearItem( SID_VIEW_POS_SIZE
);
402 pSet
->ClearItem( SID_WIN_POSSIZE
);
403 pSet
->ClearItem( SID_VIEW_ZOOM_MODE
);
408 // UserData hier einlesen, da es ansonsten immer mit bBrowse=TRUE
409 // aufgerufen wird, beim Abspeichern wurde aber bBrowse=FALSE verwendet
410 if ( pFrame
&& pFrame
->GetViewShell() )
412 if ( aUserData
.Len() )
413 pFrame
->GetViewShell()->ReadUserData( aUserData
, !bLoadDocWins
);
414 else if ( aSeq
.getLength() )
415 pFrame
->GetViewShell()->ReadUserDataSequence( aSeq
, !bLoadDocWins
);
418 // perhaps there are more windows to load
419 pPreferedFrame
= NULL
;
422 pActiveFrame
= pFrame
;
424 if( pPrefered
|| !bLoadDocWins
)
425 // load only active window
433 pActiveFrame
->MakeActive_Impl( TRUE
);
436 pImp
->bLoadingWindows
= FALSE
;
437 return pPrefered
&& bLoaded
? pPrefered
: pActiveFrame
;
440 //====================================================================
442 void SfxObjectShell::UpdateDocInfoForSave()
444 uno::Reference
<document::XDocumentProperties
> xDocProps(getDocProperties());
446 // clear user data if recommend (see 'Tools - Options - Open/StarOffice - Security')
447 if ( SvtSecurityOptions().IsOptionSet(
448 SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO
) )
450 xDocProps
->resetUserData( ::rtl::OUString() );
452 else if ( IsModified() )
454 String aUserName
= SvtUserOptions().GetFullName();
455 if ( !IsUseUserData() )
457 // remove all data pointing to the current user
458 if (xDocProps
->getAuthor().equals(aUserName
)) {
459 xDocProps
->setAuthor( ::rtl::OUString() );
461 xDocProps
->setModifiedBy( ::rtl::OUString() );
462 if (xDocProps
->getPrintedBy().equals(aUserName
)) {
463 xDocProps
->setPrintedBy( ::rtl::OUString() );
468 // update ModificationAuthor, revision and editing time
470 xDocProps
->setModificationDate( util::DateTime(
471 now
.Get100Sec(), now
.GetSec(), now
.GetMin(),
472 now
.GetHour(), now
.GetDay(), now
.GetMonth(),
474 xDocProps
->setModifiedBy( aUserName
);
475 if ( !HasName() || pImp
->bIsSaving
)
476 // QUESTION: not in case of "real" SaveAs as this is meant to create a new document
477 UpdateTime_Impl( xDocProps
);
482 //--------------------------------------------------------------------
484 // Bearbeitungszeit aktualisieren
485 void SfxObjectShell::UpdateTime_Impl(
486 const uno::Reference
<document::XDocumentProperties
> & i_xDocProps
)
488 // Get old time from documentinfo
489 sal_Int32 secs
= i_xDocProps
->getEditingDuration();
490 Time
aOldTime(secs
/3600, (secs
%3600)/60, secs
%60);
492 // Initialize some local member! Its neccessary for wollow operations!
493 DateTime aNow
; // Date and time at current moment
494 Time
n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation
495 ULONG nDays
= 0 ; // Count of days between now and last editing
496 Time
nAddTime (0) ; // Value to add on aOldTime
498 // Safe impossible cases!
499 // User has changed time to the past between last editing and now ... its not possible!!!
500 DBG_ASSERT( !(aNow
.GetDate()<pImp
->nTime
.GetDate()), "Timestamp of last change is in the past ?!..." );
502 // Do the follow only, if user has NOT changed time to the past.
503 // Else add a time of 0 to aOldTime ... !!!
504 if (aNow
.GetDate()>=pImp
->nTime
.GetDate())
506 // Get count of days last editing.
507 nDays
= aNow
.GetSecFromDateTime(pImp
->nTime
.GetDate())/86400 ;
511 // If no day between now and last editing - calculate time directly.
512 nAddTime
= (const Time
&)aNow
- (const Time
&)pImp
->nTime
;
515 // If time of working without save greater then 1 month (!) ....
516 // we add 0 to aOldTime!
519 // If 1 or up to 31 days between now and last editing - calculate time indirectly.
520 // nAddTime = (24h - nTime) + (nDays * 24h) + aNow
522 nAddTime
= nDays
*n24Time
.GetTime() ;
523 nAddTime
+= n24Time
-(const Time
&)pImp
->nTime
;
527 aOldTime
+= nAddTime
;
532 i_xDocProps
->setEditingDuration(
533 aOldTime
.GetHour()*3600+aOldTime
.GetMin()*60+aOldTime
.GetSec());
534 i_xDocProps
->setEditingCycles(i_xDocProps
->getEditingCycles() + 1);
536 catch (lang::IllegalArgumentException
&)
542 //--------------------------------------------------------------------
544 SfxDocumentInfoDialog
* SfxObjectShell::CreateDocumentInfoDialog
547 const SfxItemSet
& rSet
550 return new SfxDocumentInfoDialog(pParent
, rSet
);
553 //--------------------------------------------------------------------
555 SfxStyleSheetBasePool
* SfxObjectShell::GetStyleSheetPool()
560 void SfxObjectShell::SetOrganizerSearchMask(
561 SfxStyleSheetBasePool
* pStylePool
) const
563 pStylePool
->SetSearchMask(
564 SFX_STYLE_FAMILY_ALL
,
565 SFXSTYLEBIT_USERDEF
| SFXSTYLEBIT_USED
);
568 //--------------------------------------------------------------------
570 USHORT
SfxObjectShell::GetContentCount(
577 return DEF_CONTENT_COUNT
;
580 SfxStyleSheetBasePool
*pStylePool
= GetStyleSheetPool();
583 SetOrganizerSearchMask(pStylePool
);
584 return pStylePool
->Count();
590 return ( GetConfigManager() ) ?
591 GetConfigManager()->GetItemCount() : 0;
599 //--------------------------------------------------------------------
600 //TODO/CLEANUP: remove this method (it's virtual)
601 void SfxObjectShell::TriggerHelpPI(USHORT nIdx1
, USHORT nIdx2
, USHORT
)
603 if(nIdx1
==CONTENT_STYLE
&& nIdx2
!= INDEX_IGNORE
) //StyleSheets
605 SfxStyleSheetBasePool
*pStylePool
= GetStyleSheetPool();
606 SetOrganizerSearchMask(pStylePool
);
607 #ifdef WIR_KOENNEN_WIEDER_HILFE_FUER_STYLESHEETS
608 SfxStyleSheetBase
*pStyle
= (*pStylePool
)[nIdx2
];
612 ULONG nHelpId
=pStyle
->GetHelpId(aHelpFile
);
613 SfxHelpPI
* pHelpPI
= SFX_APP()->GetHelpPI();
614 if ( pHelpPI
&& nHelpId
)
615 pHelpPI
->LoadTopic( nHelpId
);
621 BOOL
SfxObjectShell::CanHaveChilds(USHORT nIdx1
,
628 return INDEX_IGNORE
== nIdx2
|| !GetStyleSheetPool()? FALSE
: TRUE
;
630 //!! return INDEX_IGNORE == nIdx2? FALSE: TRUE;
634 return INDEX_IGNORE == nIdx2 ? FALSE : TRUE;
640 //--------------------------------------------------------------------
642 void SfxObjectShell::GetContent(String
&rText
,
643 Bitmap
&rClosedBitmap
,
644 Bitmap
&rOpenedBitmap
,
650 DBG_ERRORFILE( "Non high contrast method called. Please update calling code!" );
651 SfxObjectShell::GetContent( rText
, rClosedBitmap
, rOpenedBitmap
, BMP_COLOR_NORMAL
, bCanDel
, i
, nIdx1
, nIdx2
);
654 //--------------------------------------------------------------------
656 void SfxObjectShell::GetContent(String
&rText
,
657 Bitmap
&rClosedBitmap
,
658 Bitmap
&rOpenedBitmap
,
659 BmpColorMode eColorMode
,
671 USHORT nTextResId
= 0;
672 USHORT nClosedBitmapResId
= 0; // evtl. sp"ater mal unterschiedliche
673 USHORT nOpenedBitmapResId
= 0; // " " " "
677 nTextResId
= STR_STYLES
;
678 if ( eColorMode
== BMP_COLOR_NORMAL
)
680 nClosedBitmapResId
= BMP_STYLES_CLOSED
;
681 nOpenedBitmapResId
= BMP_STYLES_OPENED
;
685 nClosedBitmapResId
= BMP_STYLES_CLOSED_HC
;
686 nOpenedBitmapResId
= BMP_STYLES_OPENED_HC
;
690 nTextResId
= STR_MACROS
;
691 if ( eColorMode
== BMP_COLOR_NORMAL
)
693 nClosedBitmapResId
= BMP_STYLES_CLOSED
;
694 nOpenedBitmapResId
= BMP_STYLES_OPENED
;
698 nClosedBitmapResId
= BMP_STYLES_CLOSED_HC
;
699 nOpenedBitmapResId
= BMP_STYLES_OPENED_HC
;
704 nTextResId = STR_CONFIG;
705 nClosedBitmapResId= BMP_STYLES_CLOSED;
706 nOpenedBitmapResId= BMP_STYLES_OPENED;
713 rText
= String(SfxResId(nTextResId
));
714 rClosedBitmap
= Bitmap(SfxResId(nClosedBitmapResId
));
715 rOpenedBitmap
= Bitmap(SfxResId(nOpenedBitmapResId
));
722 SfxStyleSheetBasePool
*pStylePool
= GetStyleSheetPool();
723 SetOrganizerSearchMask(pStylePool
);
724 SfxStyleSheetBase
*pStyle
= (*pStylePool
)[i
];
725 rText
= pStyle
->GetName();
726 bCanDel
=((pStyle
->GetMask() & SFXSTYLEBIT_USERDEF
)
727 == SFXSTYLEBIT_USERDEF
);
728 rClosedBitmap
= rOpenedBitmap
=
729 GetStyleFamilyBitmap(pStyle
->GetFamily(), eColorMode
);
736 if ( GetConfigManager() )
738 rText = GetConfigManager()->GetItem(i);
739 bCanDel = GetConfigManager()->CanDelete(i);
743 rClosedBitmap = Bitmap(SfxResId(BMP_STYLES_CLOSED));
744 rOpenedBitmap = Bitmap(SfxResId(BMP_STYLES_OPENED));
750 //--------------------------------------------------------------------
751 Bitmap
SfxObjectShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily
)
753 DBG_ERRORFILE( "Non high contrast method called. Please update calling code!" );
754 return SfxObjectShell::GetStyleFamilyBitmap( eFamily
, BMP_COLOR_NORMAL
);
757 //--------------------------------------------------------------------
759 Bitmap
SfxObjectShell::GetStyleFamilyBitmap(SfxStyleFamily eFamily
, BmpColorMode eColorMode
)
764 case SFX_STYLE_FAMILY_CHAR
:
765 nResId
= ( eColorMode
== BMP_COLOR_NORMAL
) ? BMP_STYLES_FAMILY1
: BMP_STYLES_FAMILY1_HC
;
767 case SFX_STYLE_FAMILY_PARA
:
768 nResId
= ( eColorMode
== BMP_COLOR_NORMAL
) ? BMP_STYLES_FAMILY2
: BMP_STYLES_FAMILY2_HC
;
770 case SFX_STYLE_FAMILY_FRAME
:
771 nResId
= ( eColorMode
== BMP_COLOR_NORMAL
) ? BMP_STYLES_FAMILY3
: BMP_STYLES_FAMILY3_HC
;
773 case SFX_STYLE_FAMILY_PAGE
:
774 nResId
= ( eColorMode
== BMP_COLOR_NORMAL
) ? BMP_STYLES_FAMILY4
: BMP_STYLES_FAMILY4_HC
;
776 case SFX_STYLE_FAMILY_PSEUDO
:
777 case SFX_STYLE_FAMILY_ALL
:
782 return Bitmap(SfxResId(nResId
));
788 //--------------------------------------------------------------------
790 BOOL
SfxObjectShell::Insert(SfxObjectShell
&rSource
,
793 USHORT
/*nSourceIdx3*/,
797 USHORT
&/*nDeleted*/)
801 if (INDEX_IGNORE
== nIdx1
&& CONTENT_STYLE
== nSourceIdx1
)
802 nIdx1
= CONTENT_STYLE
;
804 if (CONTENT_STYLE
== nSourceIdx1
&& CONTENT_STYLE
== nIdx1
)
806 SfxStyleSheetBasePool
* pHisPool
= rSource
.GetStyleSheetPool();
807 SfxStyleSheetBasePool
* pMyPool
= GetStyleSheetPool();
808 SetOrganizerSearchMask(pHisPool
);
809 SetOrganizerSearchMask(pMyPool
);
810 SfxStyleSheetBase
* pHisSheet
= NULL
;
812 if ( pHisPool
&& pHisPool
->Count() > nSourceIdx2
)
813 pHisSheet
= (*pHisPool
)[nSourceIdx2
];
815 // Einfuegen ist nur dann noetig, wenn ein StyleSheet
816 // zwischen unterschiedlichen(!) Pools bewegt wird
818 if ( pHisSheet
&& pMyPool
!= pHisPool
)
820 if (INDEX_IGNORE
== nIdx2
)
822 nIdx2
= pMyPool
->Count();
825 // wenn so eine Vorlage schon existiert: loeschen!
826 String
aOldName(pHisSheet
->GetName());
827 SfxStyleFamily eOldFamily
= pHisSheet
->GetFamily();
829 SfxStyleSheetBase
* pExist
= pMyPool
->Find(aOldName
, eOldFamily
);
830 // USHORT nOldHelpId = pExist->GetHelpId(??? VB ueberlegt sich was);
831 BOOL bUsedOrUserDefined
;
835 pExist
->IsUsed() || pExist
->IsUserDefined();
836 if( ErrorHandler::HandleError(
837 *new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE
, aOldName
) )
838 != ERRCODE_BUTTON_OK
)
842 pMyPool
->Replace( *pHisSheet
, *pExist
);
844 nIdx2
= nIdx1
= INDEX_IGNORE
;
849 SfxStyleSheetBase
& rNewSheet
= pMyPool
->Make(
850 aOldName
, eOldFamily
,
851 pHisSheet
->GetMask(), nIdx2
);
853 // ItemSet der neuen Vorlage fuellen
854 rNewSheet
.GetItemSet().Set(pHisSheet
->GetItemSet());
856 // wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow?
857 SfxStyleSheetBase
* pTestSheet
= pMyPool
->First();
860 if (pTestSheet
->GetFamily() == eOldFamily
&&
861 pTestSheet
->HasParentSupport() &&
862 pTestSheet
->GetParent() == aOldName
)
864 pTestSheet
->SetParent(aOldName
);
865 // Verknuepfung neu aufbauen
868 if (pTestSheet
->GetFamily() == eOldFamily
&&
869 pTestSheet
->HasFollowSupport() &&
870 pTestSheet
->GetFollow() == aOldName
)
872 pTestSheet
->SetFollow(aOldName
);
873 // Verknuepfung neu aufbauen
876 pTestSheet
= pMyPool
->Next();
879 rNewSheet
.IsUsed() || rNewSheet
.IsUserDefined();
882 // hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen
883 if (pHisSheet
->HasParentSupport())
885 const String
& rParentName
= pHisSheet
->GetParent();
886 if (0 != rParentName
.Len())
888 SfxStyleSheetBase
* pParentOfNew
=
889 pMyPool
->Find(rParentName
, eOldFamily
);
891 rNewSheet
.SetParent(rParentName
);
895 // hat der Neue einen Follow? wenn ja, mit gleichem
896 // Namen bei uns suchen
897 if (pHisSheet
->HasFollowSupport())
899 const String
& rFollowName
= pHisSheet
->GetFollow();
900 if (0 != rFollowName
.Len())
902 SfxStyleSheetBase
* pFollowOfNew
=
903 pMyPool
->Find(rFollowName
, eOldFamily
);
905 rNewSheet
.SetFollow(rFollowName
);
910 if( !bUsedOrUserDefined
) nIdx2
= nIdx1
= INDEX_IGNORE
;
918 else if (nSourceIdx1 == CONTENT_CONFIG)
920 nIdx1 = CONTENT_CONFIG;
922 SfxConfigManager *pCfgMgr = SFX_CFGMANAGER();
923 if ( !GetConfigManager() )
925 SetConfigManager(new SfxConfigManager(0, pCfgMgr));
926 SetTemplateConfig(FALSE);
927 if (this == Current())
928 GetConfigManager()->Activate(pCfgMgr);
931 if (GetConfigManager()->CopyItem(
932 nSourceIdx2, nIdx2, rSource.GetConfigManager()))
936 SFX_APP()->GetDispatcher_Impl()->Update_Impl(TRUE);
943 //--------------------------------------------------------------------
945 BOOL
SfxObjectShell::Remove
954 if (CONTENT_STYLE
== nIdx1
)
956 SfxStyleSheetBasePool
* pMyPool
= GetStyleSheetPool();
958 SetOrganizerSearchMask(pMyPool
);
960 SfxStyleSheetBase
* pMySheet
= (*pMyPool
)[nIdx2
];
961 String
aName(pMySheet
->GetName());
963 SfxStyleFamily eFamily
= pMySheet
->GetFamily();
966 pMyPool
->Remove(pMySheet
);
970 SfxStyleSheetBase
* pTestSheet
= pMyPool
->First();
973 if (pTestSheet
->GetFamily() == eFamily
&&
974 pTestSheet
->HasParentSupport() &&
975 pTestSheet
->GetParent() == aName
)
977 pTestSheet
->SetParent(aEmpty
); // Verknuepfung aufloesen
980 if (pTestSheet
->GetFamily() == eFamily
&&
981 pTestSheet
->HasFollowSupport() &&
982 pTestSheet
->GetFollow() == aName
)
984 pTestSheet
->SetFollow(aEmpty
); // Verknuepfung aufloesen
987 pTestSheet
= pMyPool
->Next();
993 else if (nIdx1 == CONTENT_CONFIG)
995 if (GetConfigManager()->RemoveItem(nIdx2))
999 SFX_APP()->GetDispatcher_Impl()->Update_Impl(TRUE);
1006 //--------------------------------------------------------------------
1008 BOOL
SfxObjectShell::Print
1014 const String
* pObjectName
1025 SfxStyleSheetBasePool
*pStylePool
= GetStyleSheetPool();
1026 SetOrganizerSearchMask(pStylePool
);
1027 SfxStyleSheetIterator
* pIter
= pStylePool
->CreateIterator(
1028 pStylePool
->GetSearchFamily(), pStylePool
->GetSearchMask() );
1029 USHORT nStyles
= pIter
->Count();
1030 SfxStyleSheetBase
*pStyle
= pIter
->First();
1034 if ( !rPrt
.StartJob(String(SfxResId(STR_STYLES
))) )
1039 if ( !rPrt
.StartPage() )
1044 Reference
< task::XStatusIndicator
> xStatusIndicator
;
1045 xStatusIndicator
= SFX_APP()->GetStatusIndicator();
1046 if ( xStatusIndicator
.is() )
1047 xStatusIndicator
->start( String(SfxResId(STR_PRINT_STYLES
)), nStyles
);
1049 rPrt
.SetMapMode(MapMode(MAP_10TH_MM
));
1050 Font
aFont( DEFINE_CONST_UNICODE( "Arial" ), Size(0, 64)); // 18pt
1051 aFont
.SetWeight(WEIGHT_BOLD
);
1052 rPrt
.SetFont(aFont
);
1053 const Size
aPageSize(rPrt
.GetOutputSize());
1054 const USHORT nXIndent
= 200;
1055 USHORT nYIndent
= 200;
1056 Point
aOutPos(nXIndent
, nYIndent
);
1057 String
aHeader(SfxResId(STR_PRINT_STYLES_HEADER
));
1059 aHeader
+= *pObjectName
;
1061 aHeader
+= GetTitle();
1062 long nTextHeight( rPrt
.GetTextHeight() );
1063 rPrt
.DrawText(aOutPos
, aHeader
);
1064 aOutPos
.Y() += nTextHeight
;
1065 aOutPos
.Y() += nTextHeight
/2;
1066 aFont
.SetSize(Size(0, 35)); // 10pt
1070 if ( xStatusIndicator
.is() )
1071 xStatusIndicator
->setValue( nStyles
++ );
1072 // Ausgabe des Vorlagennamens
1073 String
aStr(pStyle
->GetName());
1074 aFont
.SetWeight(WEIGHT_BOLD
);
1075 rPrt
.SetFont(aFont
);
1076 nTextHeight
= rPrt
.GetTextHeight();
1078 if ( aOutPos
.Y() + nTextHeight
*2 >
1079 aPageSize
.Height() - (long) nYIndent
)
1083 aOutPos
.Y() = nYIndent
;
1085 rPrt
.DrawText(aOutPos
, aStr
);
1086 aOutPos
.Y() += nTextHeight
;
1088 // Ausgabe der Vorlagenbeschreibung
1089 aFont
.SetWeight(WEIGHT_NORMAL
);
1090 rPrt
.SetFont(aFont
);
1091 aStr
= pStyle
->GetDescription();
1092 const char cDelim
= ' ';
1093 USHORT nStart
= 0, nIdx
= 0;
1095 nTextHeight
= rPrt
.GetTextHeight();
1096 // wie viele Worte passen auf eine Zeile
1097 while(nIdx
< aStr
.Len())
1101 nIdx
= aStr
.Search(cDelim
, nStart
);
1102 nTextWidth
= rPrt
.GetTextWidth(aStr
, nStart
, nIdx
-nStart
);
1103 while(nIdx
!= STRING_NOTFOUND
&&
1104 aOutPos
.X() + nTextWidth
<
1105 aPageSize
.Width() - (long) nXIndent
)
1108 nIdx
= aStr
.Search(cDelim
, nIdx
+1);
1109 nTextWidth
= rPrt
.GetTextWidth(aStr
, nStart
, nIdx
-nStart
);
1111 String
aTmp(aStr
, nStart
, nIdx
== STRING_NOTFOUND
?
1116 nStart
= nOld
+1; // wegen trailing space
1122 nStart
+ nChar
< aStr
.Len() &&
1123 aOutPos
.X() + rPrt
.GetTextWidth(
1124 aStr
, nStart
, nChar
) <
1125 aPageSize
.Width() - nXIndent
)
1127 aTmp
= String(aStr
, nStart
, nChar
-1);
1128 nIdx
= nStart
+ nChar
;
1131 if ( aOutPos
.Y() + nTextHeight
*2 >
1132 aPageSize
.Height() - nYIndent
)
1136 aOutPos
.Y() = nYIndent
;
1138 rPrt
.DrawText(aOutPos
, aTmp
);
1139 aOutPos
.Y() += rPrt
.GetTextHeight();
1141 pStyle
= pIter
->Next();
1145 if ( xStatusIndicator
.is() )
1146 xStatusIndicator
->end();
1156 //--------------------------------------------------------------------
1158 void SfxObjectShell::LoadStyles
1160 SfxObjectShell
&rSource
/* die Dokument-Vorlage, aus der
1161 die Styles geladen werden sollen */
1166 Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage
1167 Styles nachgeladen werden sollen. Bestehende Styles soll dabei
1168 "uberschrieben werden. Das Dokument mu"s daher neu formatiert werden.
1169 Daher werden die Applikationen in der Regel diese Methode "uberladen
1170 und in ihrer Implementierung die Implementierung der Basisklasse
1177 SfxStyleSheetBase
*pSource
;
1178 SfxStyleSheetBase
*pDest
;
1179 // Styles_Impl () : pSource(0), pDest(0) {}
1182 SfxStyleSheetBasePool
*pSourcePool
= rSource
.GetStyleSheetPool();
1183 DBG_ASSERT(pSourcePool
, "Source-DocumentShell ohne StyleSheetPool");
1184 SfxStyleSheetBasePool
*pMyPool
= GetStyleSheetPool();
1185 DBG_ASSERT(pMyPool
, "Dest-DocumentShell ohne StyleSheetPool");
1186 pSourcePool
->SetSearchMask(SFX_STYLE_FAMILY_ALL
, 0xffff);
1187 Styles_Impl
*pFound
= new Styles_Impl
[pSourcePool
->Count()];
1190 SfxStyleSheetBase
*pSource
= pSourcePool
->First();
1193 SfxStyleSheetBase
*pDest
=
1194 pMyPool
->Find( pSource
->GetName(), pSource
->GetFamily() );
1197 pDest
= &pMyPool
->Make( pSource
->GetName(),
1198 pSource
->GetFamily(), pSource
->GetMask());
1199 // Setzen des Parents, der Folgevorlage
1201 pFound
[nFound
].pSource
= pSource
;
1202 pFound
[nFound
].pDest
= pDest
;
1204 pSource
= pSourcePool
->Next();
1207 for ( USHORT i
= 0; i
< nFound
; ++i
)
1209 pFound
[i
].pDest
->GetItemSet().PutExtended(pFound
[i
].pSource
->GetItemSet(), SFX_ITEM_DONTCARE
, SFX_ITEM_DEFAULT
);
1210 // pFound[i].pDest->SetHelpId(pFound[i].pSource->GetHelpId());
1211 if(pFound
[i
].pSource
->HasParentSupport())
1212 pFound
[i
].pDest
->SetParent(pFound
[i
].pSource
->GetParent());
1213 if(pFound
[i
].pSource
->HasFollowSupport())
1214 pFound
[i
].pDest
->SetFollow(pFound
[i
].pSource
->GetParent());
1219 //--------------------------------------------------------------------
1221 void SfxObjectShell::UpdateFromTemplate_Impl( )
1225 Diese interne Methode pr"uft, ob das Dokument aus einem Template
1226 erzeugt wurde, und ob dieses neuer ist als das Dokument. Ist dies
1227 der Fall, wird der Benutzer gefragt, ob die Vorlagen (StyleSheets)
1228 updated werden sollen. Wird dies positiv beantwortet, werden die
1229 StyleSheets updated.
1234 SfxMedium
*pFile
= GetMedium();
1235 DBG_ASSERT( pFile
, "cannot UpdateFromTemplate without medium" );
1239 if ( !::utl::LocalFileHelper::IsLocalFile( pFile
->GetName() ) )
1240 // update only for documents loaded from the local file system
1243 // only for own storage formats
1244 uno::Reference
< embed::XStorage
> xDocStor
= pFile
->GetStorage();
1245 if ( !pFile
->GetFilter() || !pFile
->GetFilter()->IsOwnFormat() )
1248 SFX_ITEMSET_ARG( pFile
->GetItemSet(), pUpdateDocItem
, SfxUInt16Item
, SID_UPDATEDOCMODE
, sal_False
);
1249 sal_Int16 bCanUpdateFromTemplate
= pUpdateDocItem
? pUpdateDocItem
->GetValue() : document::UpdateDocMode::NO_UPDATE
;
1251 // created from template?
1252 uno::Reference
<document::XDocumentProperties
> xDocProps(getDocProperties());
1253 ::rtl::OUString
aTemplName( xDocProps
->getTemplateName() );
1254 ::rtl::OUString
aTemplURL( xDocProps
->getTemplateURL() );
1257 if ( aTemplName
.getLength() || (aTemplURL
.getLength() && !IsReadOnly()) )
1259 // try to locate template, first using filename
1260 // this must be done because writer global document uses this "great" idea to manage the templates of all parts
1261 // in the master document
1262 // but it is NOT an error if the template filename points not to a valid file
1263 SfxDocumentTemplates aTempl
;
1265 if ( aTemplURL
.getLength() )
1268 if( ::utl::LocalFileHelper::ConvertSystemPathToURL( aTemplURL
, GetMedium()->GetName(), aURL
) )
1272 if( !aFoundName
.Len() && aTemplName
.getLength() )
1273 // if the template filename did not lead to success, try to get a file name for the logical template name
1274 aTempl
.GetFull( String(), aTemplName
, aFoundName
);
1277 if ( aFoundName
.Len() )
1279 // check existence of template storage
1280 aTemplURL
= aFoundName
;
1283 // should the document checked against changes in the template ?
1284 if ( IsQueryLoadTemplate() )
1286 // load document info of template
1288 util::DateTime aTemplDate
;
1291 Reference
< document::XStandaloneDocumentInfo
> xDocInfo (
1292 ::comphelper::getProcessServiceFactory()->createInstance(
1293 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1294 "com.sun.star.document.StandaloneDocumentInfo") ) ),
1296 Reference
< beans::XFastPropertySet
> xSet( xDocInfo
,
1298 xDocInfo
->loadFromURL( aTemplURL
);
1299 Any aAny
= xSet
->getFastPropertyValue( WID_DATE_MODIFIED
);
1300 ::com::sun::star::util::DateTime aTmp
;
1301 if ( aAny
>>= aTemplDate
)
1303 // get modify date from document info
1307 catch ( Exception
& )
1311 // if modify date was read successfully
1314 // compare modify data of template with the last check date of the document
1315 const util::DateTime
aInfoDate( xDocProps
->getTemplateDate() );
1316 if ( aTemplDate
> aInfoDate
)
1319 if( bCanUpdateFromTemplate
== document::UpdateDocMode::QUIET_UPDATE
1320 || bCanUpdateFromTemplate
== document::UpdateDocMode::FULL_UPDATE
)
1322 else if ( bCanUpdateFromTemplate
== document::UpdateDocMode::ACCORDING_TO_CONFIG
)
1324 String
sMessage( SfxResId( STR_QRYTEMPL_MESSAGE
) );
1325 sMessage
.SearchAndReplace( String::CreateFromAscii("$(ARG1)"), aTemplName
);
1326 sfx2::QueryTemplateBox
aBox( GetDialogParent(), sMessage
);
1327 if ( RET_YES
== aBox
.Execute() )
1333 // user refuses, so don't ask again for this document
1334 SetQueryLoadTemplate(FALSE
);
1335 SetModified( TRUE
);
1342 // styles should be updated, create document in organizer mode to read in the styles
1344 SfxObjectShellLock xTemplDoc
= CreateObjectByFactoryName( GetFactory().GetFactoryName(), SFX_CREATE_MODE_ORGANIZER
);
1345 xTemplDoc
->DoInitNew(0);
1347 // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended!
1348 //xTemplDoc->SetBaseURL( aFoundName );
1350 // TODO/LATER: make sure that we don't use binary templates!
1351 SfxMedium
aMedium( aFoundName
, STREAM_STD_READ
);
1352 if ( xTemplDoc
->LoadFrom( aMedium
) )
1354 // transfer styles from xTemplDoc to this document
1355 // TODO/MBA: make sure that no BaseURL is needed in *this* document
1356 LoadStyles(*xTemplDoc
);
1358 // remember date/time of check
1359 xDocProps
->setTemplateDate(aTemplDate
);
1360 // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format )
1361 //REPLACE pInfo->Save(xDocStor);
1365 SfxConfigManager *pCfgMgr = SFX_CFGMANAGER();
1367 SfxConfigManager *pTemplCfg = new SfxConfigManager(aTemplStor, pCfgMgr);
1368 SetConfigManager(pTemplCfg);
1369 SetTemplateConfig(TRUE);
1371 // Falls der gerade zerst"orte CfgMgr des Dokuments der
1372 // aktive war, pCfgMgr lieber neu holen
1373 pCfgMgr = SFX_CFGMANAGER();
1375 // ggf. den neuen ConfigManager aktivieren
1376 if ( this == SfxObjectShell::Current() )
1377 pTemplCfg->Activate(pCfgMgr);
1380 // Template und Template-DocInfo werden nicht mehr gebraucht
1381 // delete pTemplInfo;
1386 SfxObjectShellRef
MakeObjectShellForOrganizer_Impl( const String
& aTargetURL
, BOOL bForWriting
)
1388 // check for own format
1389 SfxObjectShellRef xDoc
;
1390 StreamMode nMode
= bForWriting
? SFX_STREAM_READWRITE
: SFX_STREAM_READONLY
;
1391 SfxMedium
*pMed
= new SfxMedium( aTargetURL
, nMode
, FALSE
, 0 );
1392 const SfxFilter
* pFilter
= NULL
;
1393 pMed
->UseInteractionHandler(TRUE
);
1394 if( SFX_APP()->GetFilterMatcher().GuessFilter( *pMed
, &pFilter
) == ERRCODE_NONE
&& pFilter
&& pFilter
->IsOwnFormat() )
1397 xDoc
= SfxObjectShell::CreateObject( pFilter
->GetServiceName(), SFX_CREATE_MODE_ORGANIZER
);
1400 // partially load, so don't use DoLoad!
1402 // TODO/LATER: make sure that we don't use binary templates!
1403 if( xDoc
->LoadFrom( *pMed
) )
1405 // connect to storage, abandon temp. storage
1406 xDoc
->DoSaveCompleted( pMed
);
1418 sal_Bool
SfxObjectShell::IsHelpDocument() const
1420 const SfxFilter
* pFilter
= GetMedium()->GetFilter();
1421 return ( pFilter
&& pFilter
->GetFilterName().CompareToAscii("writer_web_HTML_help") == COMPARE_EQUAL
);
1424 void SfxObjectShell::ResetFromTemplate( const String
& rTemplateName
, const String
& rFileName
)
1426 // only care about reseting this data for openoffice formats otherwise
1427 if ( IsOwnStorageFormat_Impl( *GetMedium()) )
1429 uno::Reference
<document::XDocumentProperties
> xDocProps(getDocProperties());
1430 xDocProps
->setTemplateURL( ::rtl::OUString() );
1431 xDocProps
->setTemplateName( ::rtl::OUString() );
1432 xDocProps
->setTemplateDate( util::DateTime() );
1433 xDocProps
->resetUserData( ::rtl::OUString() );
1438 if( ::utl::LocalFileHelper::IsLocalFile( rFileName
) )
1441 if( SFX_APP()->Get_Impl()->GetDocumentTemplates()->GetFull( String(), rTemplateName
, aFoundName
) )
1443 INetURLObject
aObj( rFileName
);
1444 xDocProps
->setTemplateURL( aObj
.GetMainURL(INetURLObject::DECODE_TO_IURI
) );
1445 xDocProps
->setTemplateName( rTemplateName
);
1448 xDocProps
->setTemplateDate( util::DateTime(
1449 now
.Get100Sec(), now
.GetSec(), now
.GetMin(),
1450 now
.GetHour(), now
.GetDay(), now
.GetMonth(),
1453 SetQueryLoadTemplate( sal_True
);
1459 sal_Bool
SfxObjectShell::IsQueryLoadTemplate() const
1461 return pImp
->bQueryLoadTemplate
;
1464 sal_Bool
SfxObjectShell::IsUseUserData() const
1466 return pImp
->bUseUserData
;
1469 void SfxObjectShell::SetQueryLoadTemplate( sal_Bool bNew
)
1471 if ( pImp
->bQueryLoadTemplate
!= bNew
)
1472 SetModified( TRUE
);
1473 pImp
->bQueryLoadTemplate
= bNew
;
1476 void SfxObjectShell::SetUseUserData( sal_Bool bNew
)
1478 if ( pImp
->bUseUserData
!= bNew
)
1479 SetModified( TRUE
);
1480 pImp
->bUseUserData
= bNew
;
1483 sal_Bool
SfxObjectShell::IsLoadReadonly() const
1485 return pImp
->bLoadReadonly
;
1488 sal_Bool
SfxObjectShell::IsSaveVersionOnClose() const
1490 return pImp
->bSaveVersionOnClose
;
1493 void SfxObjectShell::SetLoadReadonly( sal_Bool bNew
)
1495 if ( pImp
->bLoadReadonly
!= bNew
)
1496 SetModified( TRUE
);
1497 pImp
->bLoadReadonly
= bNew
;
1500 void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew
)
1502 if ( pImp
->bSaveVersionOnClose
!= bNew
)
1503 SetModified( TRUE
);
1504 pImp
->bSaveVersionOnClose
= bNew
;