1d119d52dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5d119d52dSAndrew Rist * distributed with this work for additional information 6d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8d119d52dSAndrew Rist * "License"); you may not use this file except in compliance 9d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14d119d52dSAndrew Rist * software distributed under the License is distributed on an 15d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16d119d52dSAndrew Rist * KIND, either express or implied. See the License for the 17d119d52dSAndrew Rist * specific language governing permissions and limitations 18d119d52dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20d119d52dSAndrew Rist *************************************************************/ 21d119d52dSAndrew Rist 22d119d52dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 30cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp> 31cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 32cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 33cdf0e10cSrcweir #include <com/sun/star/document/XStandaloneDocumentInfo.hpp> 34cdf0e10cSrcweir #include <com/sun/star/beans/XFastPropertySet.hpp> 35cdf0e10cSrcweir #include <tools/cachestr.hxx> 36cdf0e10cSrcweir #include <vcl/msgbox.hxx> 37cdf0e10cSrcweir #include <svl/style.hxx> 38cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <svl/stritem.hxx> 41cdf0e10cSrcweir #include <svl/intitem.hxx> 42cdf0e10cSrcweir #include <svl/rectitem.hxx> 43cdf0e10cSrcweir #include <svl/eitem.hxx> 44cdf0e10cSrcweir #include <svl/urihelper.hxx> 45cdf0e10cSrcweir #include <svl/ctloptions.hxx> 46cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 47cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 48cdf0e10cSrcweir #include <unotools/securityoptions.hxx> 49cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 50cdf0e10cSrcweir #include <svtools/ehdl.hxx> 51cdf0e10cSrcweir #include <tools/datetime.hxx> 52cdf0e10cSrcweir #include <math.h> 53cdf0e10cSrcweir 54cdf0e10cSrcweir #include <unotools/saveopt.hxx> 55cdf0e10cSrcweir #include <unotools/useroptions.hxx> 56cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 57cdf0e10cSrcweir #include <vcl/virdev.hxx> 58cdf0e10cSrcweir #include <vcl/oldprintadaptor.hxx> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include <sfx2/app.hxx> 61cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 62cdf0e10cSrcweir #include "appdata.hxx" 63cdf0e10cSrcweir #include <sfx2/dinfdlg.hxx> 64cdf0e10cSrcweir #include "fltfnc.hxx" 65cdf0e10cSrcweir #include <sfx2/docfac.hxx> 66cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 67cdf0e10cSrcweir #include <sfx2/objsh.hxx> 68cdf0e10cSrcweir #include "objshimp.hxx" 69cdf0e10cSrcweir #include <sfx2/evntconf.hxx> 70cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 71cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 72cdf0e10cSrcweir #include <sfx2/printer.hxx> 73cdf0e10cSrcweir #include "sfx2/basmgr.hxx" 74cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 75cdf0e10cSrcweir #include <sfx2/doctempl.hxx> 76cdf0e10cSrcweir #include "doc.hrc" 77cdf0e10cSrcweir #include <sfx2/sfxbasemodel.hxx> 78cdf0e10cSrcweir #include <sfx2/docfile.hxx> 79cdf0e10cSrcweir #include <sfx2/request.hxx> 80cdf0e10cSrcweir #include "openflag.hxx" 81cdf0e10cSrcweir #include "querytemplate.hxx" 82cdf0e10cSrcweir 83cdf0e10cSrcweir using namespace ::com::sun::star; 84cdf0e10cSrcweir using namespace ::com::sun::star::uno; 85cdf0e10cSrcweir 86cdf0e10cSrcweir //==================================================================== 87cdf0e10cSrcweir 88cdf0e10cSrcweir //==================================================================== 89cdf0e10cSrcweir 90cdf0e10cSrcweir static 91cdf0e10cSrcweir bool operator> (const util::DateTime& i_rLeft, const util::DateTime& i_rRight) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if ( i_rLeft.Year != i_rRight.Year ) 94cdf0e10cSrcweir return i_rLeft.Year > i_rRight.Year; 95cdf0e10cSrcweir 96cdf0e10cSrcweir if ( i_rLeft.Month != i_rRight.Month ) 97cdf0e10cSrcweir return i_rLeft.Month > i_rRight.Month; 98cdf0e10cSrcweir 99cdf0e10cSrcweir if ( i_rLeft.Day != i_rRight.Day ) 100cdf0e10cSrcweir return i_rLeft.Day > i_rRight.Day; 101cdf0e10cSrcweir 102cdf0e10cSrcweir if ( i_rLeft.Hours != i_rRight.Hours ) 103cdf0e10cSrcweir return i_rLeft.Hours > i_rRight.Hours; 104cdf0e10cSrcweir 105cdf0e10cSrcweir if ( i_rLeft.Minutes != i_rRight.Minutes ) 106cdf0e10cSrcweir return i_rLeft.Minutes > i_rRight.Minutes; 107cdf0e10cSrcweir 108cdf0e10cSrcweir if ( i_rLeft.Seconds != i_rRight.Seconds ) 109cdf0e10cSrcweir return i_rLeft.Seconds > i_rRight.Seconds; 110cdf0e10cSrcweir 111cdf0e10cSrcweir if ( i_rLeft.HundredthSeconds != i_rRight.HundredthSeconds ) 112cdf0e10cSrcweir return i_rLeft.HundredthSeconds > i_rRight.HundredthSeconds; 113cdf0e10cSrcweir 114cdf0e10cSrcweir return sal_False; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir ::boost::shared_ptr<GDIMetaFile> 119cdf0e10cSrcweir SfxObjectShell::GetPreviewMetaFile( sal_Bool bFullContent ) const 120cdf0e10cSrcweir { 121cdf0e10cSrcweir return CreatePreviewMetaFile_Impl( bFullContent, sal_False ); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir 125cdf0e10cSrcweir ::boost::shared_ptr<GDIMetaFile> 126cdf0e10cSrcweir SfxObjectShell::CreatePreviewMetaFile_Impl( sal_Bool bFullContent, sal_Bool bHighContrast ) const 127cdf0e10cSrcweir { 128cdf0e10cSrcweir // Nur wenn gerade nicht gedruckt wird, darf DoDraw aufgerufen 129cdf0e10cSrcweir // werden, sonst wird u.U. der Printer abgeschossen ! 130cdf0e10cSrcweir SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this ); 131cdf0e10cSrcweir if ( pFrame && pFrame->GetViewShell() && 132cdf0e10cSrcweir pFrame->GetViewShell()->GetPrinter() && 133cdf0e10cSrcweir pFrame->GetViewShell()->GetPrinter()->IsPrinting() ) 134cdf0e10cSrcweir return ::boost::shared_ptr<GDIMetaFile>(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir ::boost::shared_ptr<GDIMetaFile> pFile(new GDIMetaFile); 137cdf0e10cSrcweir 138cdf0e10cSrcweir VirtualDevice aDevice; 139cdf0e10cSrcweir aDevice.EnableOutput( sal_False ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir // adjust the output device if HC-metafile is requested 142cdf0e10cSrcweir if ( bHighContrast ) 143cdf0e10cSrcweir aDevice.SetDrawMode( aDevice.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir MapMode aMode( ((SfxObjectShell*)this)->GetMapUnit() ); 146cdf0e10cSrcweir aDevice.SetMapMode( aMode ); 147cdf0e10cSrcweir pFile->SetPrefMapMode( aMode ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir Size aTmpSize; 150cdf0e10cSrcweir sal_Int8 nAspect; 151cdf0e10cSrcweir if ( bFullContent ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir nAspect = ASPECT_CONTENT; 154cdf0e10cSrcweir aTmpSize = GetVisArea( nAspect ).GetSize(); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir else 157cdf0e10cSrcweir { 158cdf0e10cSrcweir nAspect = ASPECT_THUMBNAIL; 159cdf0e10cSrcweir aTmpSize = ((SfxObjectShell*)this)->GetFirstPageSize(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir pFile->SetPrefSize( aTmpSize ); 163cdf0e10cSrcweir DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(), 164cdf0e10cSrcweir "size of first page is 0, overload GetFirstPageSize or set vis-area!" ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir pFile->Record( &aDevice ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir LanguageType eLang; 169*982b9f78SArmin Le Grand // #120038# use local incarnation, so deletion cannot be forgotten 170*982b9f78SArmin Le Grand const SvtCTLOptions aCTLOptions; 171*982b9f78SArmin Le Grand 172*982b9f78SArmin Le Grand if ( SvtCTLOptions::NUMERALS_HINDI == aCTLOptions.GetCTLTextNumerals() ) 173cdf0e10cSrcweir eLang = LANGUAGE_ARABIC_SAUDI_ARABIA; 174*982b9f78SArmin Le Grand else if ( SvtCTLOptions::NUMERALS_ARABIC == aCTLOptions.GetCTLTextNumerals() ) 175cdf0e10cSrcweir eLang = LANGUAGE_ENGLISH; 176cdf0e10cSrcweir else 177cdf0e10cSrcweir eLang = (LanguageType) Application::GetSettings().GetLanguage(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir aDevice.SetDigitLanguage( eLang ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir ((SfxObjectShell*)this)->DoDraw( &aDevice, Point(0,0), aTmpSize, JobSetup(), nAspect ); 182cdf0e10cSrcweir pFile->Stop(); 183cdf0e10cSrcweir 184cdf0e10cSrcweir return pFile; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir //==================================================================== 188cdf0e10cSrcweir 189cdf0e10cSrcweir void SfxObjectShell::UpdateDocInfoForSave() 190cdf0e10cSrcweir { 191cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); 192cdf0e10cSrcweir 193cdf0e10cSrcweir // clear user data if recommend (see 'Tools - Options - Open/StarOffice - Security') 194cdf0e10cSrcweir if ( SvtSecurityOptions().IsOptionSet( 195cdf0e10cSrcweir SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO ) ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir xDocProps->resetUserData( ::rtl::OUString() ); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir else if ( IsModified() ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir String aUserName = SvtUserOptions().GetFullName(); 202cdf0e10cSrcweir if ( !IsUseUserData() ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir // remove all data pointing to the current user 205cdf0e10cSrcweir if (xDocProps->getAuthor().equals(aUserName)) { 206cdf0e10cSrcweir xDocProps->setAuthor( ::rtl::OUString() ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir xDocProps->setModifiedBy( ::rtl::OUString() ); 209cdf0e10cSrcweir if (xDocProps->getPrintedBy().equals(aUserName)) { 210cdf0e10cSrcweir xDocProps->setPrintedBy( ::rtl::OUString() ); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir } 213cdf0e10cSrcweir else 214cdf0e10cSrcweir { 215cdf0e10cSrcweir // update ModificationAuthor, revision and editing time 216cdf0e10cSrcweir ::DateTime now; 217cdf0e10cSrcweir xDocProps->setModificationDate( util::DateTime( 218cdf0e10cSrcweir now.Get100Sec(), now.GetSec(), now.GetMin(), 219cdf0e10cSrcweir now.GetHour(), now.GetDay(), now.GetMonth(), 220cdf0e10cSrcweir now.GetYear() ) ); 221cdf0e10cSrcweir xDocProps->setModifiedBy( aUserName ); 222cdf0e10cSrcweir if ( !HasName() || pImp->bIsSaving ) 223cdf0e10cSrcweir // QUESTION: not in case of "real" SaveAs as this is meant to create a new document 224cdf0e10cSrcweir UpdateTime_Impl( xDocProps ); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir } 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir //-------------------------------------------------------------------- 230cdf0e10cSrcweir 231cdf0e10cSrcweir static void 232cdf0e10cSrcweir lcl_add(util::Duration & rDur, Time const& rTime) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir // here we don't care about overflow: rDur is converted back to seconds 235cdf0e10cSrcweir // anyway, and Time cannot store more than ~4000 hours 236cdf0e10cSrcweir rDur.Hours += rTime.GetHour(); 237cdf0e10cSrcweir rDur.Minutes += rTime.GetMin(); 238cdf0e10cSrcweir rDur.Seconds += rTime.GetSec(); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir // Bearbeitungszeit aktualisieren 242cdf0e10cSrcweir void SfxObjectShell::UpdateTime_Impl( 243cdf0e10cSrcweir const uno::Reference<document::XDocumentProperties> & i_xDocProps) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // Get old time from documentinfo 246cdf0e10cSrcweir const sal_Int32 secs = i_xDocProps->getEditingDuration(); 247cdf0e10cSrcweir util::Duration editDuration(sal_False, 0, 0, 0, 248cdf0e10cSrcweir secs/3600, (secs%3600)/60, secs%60, 0); 249cdf0e10cSrcweir 250cdf0e10cSrcweir // Initialize some local member! Its neccessary for wollow operations! 251cdf0e10cSrcweir DateTime aNow ; // Date and time at current moment 252cdf0e10cSrcweir Time n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation 253cdf0e10cSrcweir sal_uIntPtr nDays = 0 ; // Count of days between now and last editing 254cdf0e10cSrcweir Time nAddTime (0) ; // Value to add on aOldTime 255cdf0e10cSrcweir 256cdf0e10cSrcweir // Safe impossible cases! 257cdf0e10cSrcweir // User has changed time to the past between last editing and now ... its not possible!!! 258cdf0e10cSrcweir DBG_ASSERT( !(aNow.GetDate()<pImp->nTime.GetDate()), "Timestamp of last change is in the past ?!..." ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir // Do the follow only, if user has NOT changed time to the past. 261cdf0e10cSrcweir // Else add a time of 0 to aOldTime ... !!! 262cdf0e10cSrcweir if (aNow.GetDate()>=pImp->nTime.GetDate()) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir // Get count of days last editing. 265cdf0e10cSrcweir nDays = aNow.GetSecFromDateTime(pImp->nTime.GetDate())/86400 ; 266cdf0e10cSrcweir 267cdf0e10cSrcweir if (nDays==0) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir // If no day between now and last editing - calculate time directly. 270cdf0e10cSrcweir nAddTime = (const Time&)aNow - (const Time&)pImp->nTime ; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir else 273cdf0e10cSrcweir // If time of working without save greater then 1 month (!) .... 274cdf0e10cSrcweir // we add 0 to aOldTime! 275cdf0e10cSrcweir if (nDays<=31) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // If 1 or up to 31 days between now and last editing - calculate time indirectly. 278cdf0e10cSrcweir // nAddTime = (24h - nTime) + (nDays * 24h) + aNow 279cdf0e10cSrcweir --nDays; 280cdf0e10cSrcweir nAddTime = nDays*n24Time.GetTime() ; 281cdf0e10cSrcweir nAddTime += n24Time-(const Time&)pImp->nTime ; 282cdf0e10cSrcweir nAddTime += aNow ; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir lcl_add(editDuration, nAddTime); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir pImp->nTime = aNow; 289cdf0e10cSrcweir try { 290cdf0e10cSrcweir const sal_Int32 newSecs( (editDuration.Hours*3600) 291cdf0e10cSrcweir + (editDuration.Minutes*60) + editDuration.Seconds); 292cdf0e10cSrcweir i_xDocProps->setEditingDuration(newSecs); 293cdf0e10cSrcweir i_xDocProps->setEditingCycles(i_xDocProps->getEditingCycles() + 1); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir catch (lang::IllegalArgumentException &) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir // ignore overflow 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir //-------------------------------------------------------------------- 302cdf0e10cSrcweir 303cdf0e10cSrcweir SfxDocumentInfoDialog* SfxObjectShell::CreateDocumentInfoDialog 304cdf0e10cSrcweir ( 305cdf0e10cSrcweir Window* pParent, 306cdf0e10cSrcweir const SfxItemSet& rSet 307cdf0e10cSrcweir ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir return new SfxDocumentInfoDialog(pParent, rSet); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir //-------------------------------------------------------------------- 313cdf0e10cSrcweir 314cdf0e10cSrcweir SfxStyleSheetBasePool* SfxObjectShell::GetStyleSheetPool() 315cdf0e10cSrcweir { 316cdf0e10cSrcweir return 0; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir void SfxObjectShell::SetOrganizerSearchMask( 320cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool) const 321cdf0e10cSrcweir { 322cdf0e10cSrcweir pStylePool->SetSearchMask( 323cdf0e10cSrcweir SFX_STYLE_FAMILY_ALL, 324cdf0e10cSrcweir SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir //-------------------------------------------------------------------- 328cdf0e10cSrcweir 329cdf0e10cSrcweir sal_uInt16 SfxObjectShell::GetContentCount( 330cdf0e10cSrcweir sal_uInt16 nIdx1, 331cdf0e10cSrcweir sal_uInt16 /*nIdx2*/) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir switch(nIdx1) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir case INDEX_IGNORE: 336cdf0e10cSrcweir return DEF_CONTENT_COUNT; 337cdf0e10cSrcweir case CONTENT_STYLE: 338cdf0e10cSrcweir { 339cdf0e10cSrcweir SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool(); 340cdf0e10cSrcweir if(!pStylePool) 341cdf0e10cSrcweir return 0; 342cdf0e10cSrcweir SetOrganizerSearchMask(pStylePool); 343cdf0e10cSrcweir return pStylePool->Count(); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir case CONTENT_MACRO: 346cdf0e10cSrcweir break; 347cdf0e10cSrcweir /* 348cdf0e10cSrcweir case CONTENT_CONFIG: 349cdf0e10cSrcweir return ( GetConfigManager() ) ? 350cdf0e10cSrcweir GetConfigManager()->GetItemCount() : 0; 351cdf0e10cSrcweir break; 352cdf0e10cSrcweir */ 353cdf0e10cSrcweir } 354cdf0e10cSrcweir return 0; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir 358cdf0e10cSrcweir //-------------------------------------------------------------------- 359cdf0e10cSrcweir //TODO/CLEANUP: remove this method (it's virtual) 360cdf0e10cSrcweir void SfxObjectShell::TriggerHelpPI(sal_uInt16 nIdx1, sal_uInt16 nIdx2, sal_uInt16) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if(nIdx1==CONTENT_STYLE && nIdx2 != INDEX_IGNORE) //StyleSheets 363cdf0e10cSrcweir { 364cdf0e10cSrcweir SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool(); 365cdf0e10cSrcweir SetOrganizerSearchMask(pStylePool); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir sal_Bool SfxObjectShell::CanHaveChilds(sal_uInt16 nIdx1, 370cdf0e10cSrcweir sal_uInt16 nIdx2) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir switch(nIdx1) { 373cdf0e10cSrcweir case INDEX_IGNORE: 374cdf0e10cSrcweir return sal_True; 375cdf0e10cSrcweir case CONTENT_STYLE: 376cdf0e10cSrcweir return INDEX_IGNORE == nIdx2 || !GetStyleSheetPool()? sal_False: sal_True; 377cdf0e10cSrcweir case CONTENT_MACRO: 378cdf0e10cSrcweir //!! return INDEX_IGNORE == nIdx2? sal_False: sal_True; 379cdf0e10cSrcweir return sal_False; 380cdf0e10cSrcweir /* 381cdf0e10cSrcweir case CONTENT_CONFIG: 382cdf0e10cSrcweir return INDEX_IGNORE == nIdx2 ? sal_False : sal_True; 383cdf0e10cSrcweir */ 384cdf0e10cSrcweir } 385cdf0e10cSrcweir return sal_False; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir //-------------------------------------------------------------------- 389cdf0e10cSrcweir 390cdf0e10cSrcweir void SfxObjectShell::GetContent(String &rText, 391cdf0e10cSrcweir Bitmap &rClosedBitmap, 392cdf0e10cSrcweir Bitmap &rOpenedBitmap, 393cdf0e10cSrcweir sal_Bool &bCanDel, 394cdf0e10cSrcweir sal_uInt16 i, 395cdf0e10cSrcweir sal_uInt16 nIdx1, 396cdf0e10cSrcweir sal_uInt16 nIdx2 ) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir DBG_ERRORFILE( "Non high contrast method called. Please update calling code!" ); 399cdf0e10cSrcweir SfxObjectShell::GetContent( rText, rClosedBitmap, rOpenedBitmap, BMP_COLOR_NORMAL, bCanDel, i, nIdx1, nIdx2 ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir //-------------------------------------------------------------------- 403cdf0e10cSrcweir 404cdf0e10cSrcweir void SfxObjectShell::GetContent(String &rText, 405cdf0e10cSrcweir Bitmap &rClosedBitmap, 406cdf0e10cSrcweir Bitmap &rOpenedBitmap, 407cdf0e10cSrcweir BmpColorMode eColorMode, 408cdf0e10cSrcweir sal_Bool &bCanDel, 409cdf0e10cSrcweir sal_uInt16 i, 410cdf0e10cSrcweir sal_uInt16 nIdx1, 411cdf0e10cSrcweir sal_uInt16 /*nIdx2*/ ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir bCanDel=sal_True; 414cdf0e10cSrcweir 415cdf0e10cSrcweir switch(nIdx1) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir case INDEX_IGNORE: 418cdf0e10cSrcweir { 419cdf0e10cSrcweir sal_uInt16 nTextResId = 0; 420cdf0e10cSrcweir sal_uInt16 nClosedBitmapResId = 0; // evtl. sp"ater mal unterschiedliche 421cdf0e10cSrcweir sal_uInt16 nOpenedBitmapResId = 0; // " " " " 422cdf0e10cSrcweir switch(i) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir case CONTENT_STYLE: 425cdf0e10cSrcweir nTextResId = STR_STYLES; 426cdf0e10cSrcweir if ( eColorMode == BMP_COLOR_NORMAL ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir nClosedBitmapResId= BMP_STYLES_CLOSED; 429cdf0e10cSrcweir nOpenedBitmapResId= BMP_STYLES_OPENED; 430cdf0e10cSrcweir } 431cdf0e10cSrcweir else 432cdf0e10cSrcweir { 433cdf0e10cSrcweir nClosedBitmapResId= BMP_STYLES_CLOSED_HC; 434cdf0e10cSrcweir nOpenedBitmapResId= BMP_STYLES_OPENED_HC; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir break; 437cdf0e10cSrcweir case CONTENT_MACRO: 438cdf0e10cSrcweir nTextResId = STR_MACROS; 439cdf0e10cSrcweir if ( eColorMode == BMP_COLOR_NORMAL ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir nClosedBitmapResId= BMP_STYLES_CLOSED; 442cdf0e10cSrcweir nOpenedBitmapResId= BMP_STYLES_OPENED; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir else 445cdf0e10cSrcweir { 446cdf0e10cSrcweir nClosedBitmapResId= BMP_STYLES_CLOSED_HC; 447cdf0e10cSrcweir nOpenedBitmapResId= BMP_STYLES_OPENED_HC; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir break; 450cdf0e10cSrcweir /* 451cdf0e10cSrcweir case CONTENT_CONFIG: 452cdf0e10cSrcweir nTextResId = STR_CONFIG; 453cdf0e10cSrcweir nClosedBitmapResId= BMP_STYLES_CLOSED; 454cdf0e10cSrcweir nOpenedBitmapResId= BMP_STYLES_OPENED; 455cdf0e10cSrcweir break; 456cdf0e10cSrcweir */ 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir if ( nTextResId ) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir rText = String(SfxResId(nTextResId)); 462cdf0e10cSrcweir rClosedBitmap = Bitmap(SfxResId(nClosedBitmapResId)); 463cdf0e10cSrcweir rOpenedBitmap = Bitmap(SfxResId(nOpenedBitmapResId)); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir break; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir case CONTENT_STYLE: 469cdf0e10cSrcweir { 470cdf0e10cSrcweir SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool(); 471cdf0e10cSrcweir SetOrganizerSearchMask(pStylePool); 472cdf0e10cSrcweir SfxStyleSheetBase *pStyle = (*pStylePool)[i]; 473cdf0e10cSrcweir rText = pStyle->GetName(); 474cdf0e10cSrcweir bCanDel=((pStyle->GetMask() & SFXSTYLEBIT_USERDEF) 475cdf0e10cSrcweir == SFXSTYLEBIT_USERDEF); 476cdf0e10cSrcweir rClosedBitmap = rOpenedBitmap = 477cdf0e10cSrcweir GetStyleFamilyBitmap(pStyle->GetFamily(), eColorMode ); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir break; 480cdf0e10cSrcweir case CONTENT_MACRO: 481cdf0e10cSrcweir break; 482cdf0e10cSrcweir /* 483cdf0e10cSrcweir case CONTENT_CONFIG: 484cdf0e10cSrcweir if ( GetConfigManager() ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir rText = GetConfigManager()->GetItem(i); 487cdf0e10cSrcweir bCanDel = GetConfigManager()->CanDelete(i); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir else 490cdf0e10cSrcweir rText = String(); 491cdf0e10cSrcweir rClosedBitmap = Bitmap(SfxResId(BMP_STYLES_CLOSED)); 492cdf0e10cSrcweir rOpenedBitmap = Bitmap(SfxResId(BMP_STYLES_OPENED)); 493cdf0e10cSrcweir break; 494cdf0e10cSrcweir */ 495cdf0e10cSrcweir } 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir //-------------------------------------------------------------------- 499cdf0e10cSrcweir Bitmap SfxObjectShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir DBG_ERRORFILE( "Non high contrast method called. Please update calling code!" ); 502cdf0e10cSrcweir return SfxObjectShell::GetStyleFamilyBitmap( eFamily, BMP_COLOR_NORMAL ); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir //-------------------------------------------------------------------- 506cdf0e10cSrcweir 507cdf0e10cSrcweir Bitmap SfxObjectShell::GetStyleFamilyBitmap(SfxStyleFamily eFamily, BmpColorMode eColorMode ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir sal_uInt16 nResId = 0; 510cdf0e10cSrcweir switch(eFamily) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR: 513cdf0e10cSrcweir nResId = ( eColorMode == BMP_COLOR_NORMAL ) ? BMP_STYLES_FAMILY1 : BMP_STYLES_FAMILY1_HC; 514cdf0e10cSrcweir break; 515cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: 516cdf0e10cSrcweir nResId = ( eColorMode == BMP_COLOR_NORMAL ) ? BMP_STYLES_FAMILY2 : BMP_STYLES_FAMILY2_HC; 517cdf0e10cSrcweir break; 518cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME: 519cdf0e10cSrcweir nResId = ( eColorMode == BMP_COLOR_NORMAL ) ? BMP_STYLES_FAMILY3 : BMP_STYLES_FAMILY3_HC; 520cdf0e10cSrcweir break; 521cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE : 522cdf0e10cSrcweir nResId = ( eColorMode == BMP_COLOR_NORMAL ) ? BMP_STYLES_FAMILY4 : BMP_STYLES_FAMILY4_HC; 523cdf0e10cSrcweir break; 524cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: 525cdf0e10cSrcweir case SFX_STYLE_FAMILY_ALL: 526cdf0e10cSrcweir break; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir if ( nResId ) 530cdf0e10cSrcweir return Bitmap(SfxResId(nResId)); 531cdf0e10cSrcweir else 532cdf0e10cSrcweir return Bitmap(); 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir 536cdf0e10cSrcweir //-------------------------------------------------------------------- 537cdf0e10cSrcweir 538cdf0e10cSrcweir sal_Bool SfxObjectShell::Insert(SfxObjectShell &rSource, 539cdf0e10cSrcweir sal_uInt16 nSourceIdx1, 540cdf0e10cSrcweir sal_uInt16 nSourceIdx2, 541cdf0e10cSrcweir sal_uInt16 /*nSourceIdx3*/, 542cdf0e10cSrcweir sal_uInt16 &nIdx1, 543cdf0e10cSrcweir sal_uInt16 &nIdx2, 544cdf0e10cSrcweir sal_uInt16 &/*nIdx3*/, 545cdf0e10cSrcweir sal_uInt16 &/*nDeleted*/) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir sal_Bool bRet = sal_False; 548cdf0e10cSrcweir 549cdf0e10cSrcweir if (INDEX_IGNORE == nIdx1 && CONTENT_STYLE == nSourceIdx1) 550cdf0e10cSrcweir nIdx1 = CONTENT_STYLE; 551cdf0e10cSrcweir 552cdf0e10cSrcweir if (CONTENT_STYLE == nSourceIdx1 && CONTENT_STYLE == nIdx1) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir SfxStyleSheetBasePool* pHisPool = rSource.GetStyleSheetPool(); 555cdf0e10cSrcweir SfxStyleSheetBasePool* pMyPool = GetStyleSheetPool(); 556cdf0e10cSrcweir SetOrganizerSearchMask(pHisPool); 557cdf0e10cSrcweir SetOrganizerSearchMask(pMyPool); 558cdf0e10cSrcweir SfxStyleSheetBase* pHisSheet = NULL; 559cdf0e10cSrcweir 560cdf0e10cSrcweir if ( pHisPool && pHisPool->Count() > nSourceIdx2 ) 561cdf0e10cSrcweir pHisSheet = (*pHisPool)[nSourceIdx2]; 562cdf0e10cSrcweir 563cdf0e10cSrcweir // Einfuegen ist nur dann noetig, wenn ein StyleSheet 564cdf0e10cSrcweir // zwischen unterschiedlichen(!) Pools bewegt wird 565cdf0e10cSrcweir 566cdf0e10cSrcweir if ( pHisSheet && pMyPool != pHisPool ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir if (INDEX_IGNORE == nIdx2) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir nIdx2 = pMyPool->Count(); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir // wenn so eine Vorlage schon existiert: loeschen! 574cdf0e10cSrcweir String aOldName(pHisSheet->GetName()); 575cdf0e10cSrcweir SfxStyleFamily eOldFamily = pHisSheet->GetFamily(); 576cdf0e10cSrcweir 577cdf0e10cSrcweir SfxStyleSheetBase* pExist = pMyPool->Find(aOldName, eOldFamily); 578cdf0e10cSrcweir // sal_uInt16 nOldHelpId = pExist->GetHelpId(??? VB ueberlegt sich was); 579cdf0e10cSrcweir sal_Bool bUsedOrUserDefined; 580cdf0e10cSrcweir if( pExist ) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir bUsedOrUserDefined = 583cdf0e10cSrcweir pExist->IsUsed() || pExist->IsUserDefined(); 584cdf0e10cSrcweir if( ErrorHandler::HandleError( 585cdf0e10cSrcweir *new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE, aOldName ) ) 586cdf0e10cSrcweir != ERRCODE_BUTTON_OK ) 587cdf0e10cSrcweir return sal_False; 588cdf0e10cSrcweir else 589cdf0e10cSrcweir { 590cdf0e10cSrcweir pMyPool->Replace( *pHisSheet, *pExist ); 591cdf0e10cSrcweir SetModified( sal_True ); 592cdf0e10cSrcweir nIdx2 = nIdx1 = INDEX_IGNORE; 593cdf0e10cSrcweir return sal_True; 594cdf0e10cSrcweir } 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir SfxStyleSheetBase& rNewSheet = pMyPool->Make( 598cdf0e10cSrcweir aOldName, eOldFamily, 599cdf0e10cSrcweir pHisSheet->GetMask(), nIdx2); 600cdf0e10cSrcweir 601cdf0e10cSrcweir // ItemSet der neuen Vorlage fuellen 602cdf0e10cSrcweir rNewSheet.GetItemSet().Set(pHisSheet->GetItemSet()); 603cdf0e10cSrcweir 604cdf0e10cSrcweir // wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow? 605cdf0e10cSrcweir SfxStyleSheetBase* pTestSheet = pMyPool->First(); 606cdf0e10cSrcweir while (pTestSheet) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir if (pTestSheet->GetFamily() == eOldFamily && 609cdf0e10cSrcweir pTestSheet->HasParentSupport() && 610cdf0e10cSrcweir pTestSheet->GetParent() == aOldName) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir pTestSheet->SetParent(aOldName); 613cdf0e10cSrcweir // Verknuepfung neu aufbauen 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir if (pTestSheet->GetFamily() == eOldFamily && 617cdf0e10cSrcweir pTestSheet->HasFollowSupport() && 618cdf0e10cSrcweir pTestSheet->GetFollow() == aOldName) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir pTestSheet->SetFollow(aOldName); 621cdf0e10cSrcweir // Verknuepfung neu aufbauen 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir pTestSheet = pMyPool->Next(); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir bUsedOrUserDefined = 627cdf0e10cSrcweir rNewSheet.IsUsed() || rNewSheet.IsUserDefined(); 628cdf0e10cSrcweir 629cdf0e10cSrcweir 630cdf0e10cSrcweir // hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen 631cdf0e10cSrcweir if (pHisSheet->HasParentSupport()) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir const String& rParentName = pHisSheet->GetParent(); 634cdf0e10cSrcweir if (0 != rParentName.Len()) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir SfxStyleSheetBase* pParentOfNew = 637cdf0e10cSrcweir pMyPool->Find(rParentName, eOldFamily); 638cdf0e10cSrcweir if (pParentOfNew) 639cdf0e10cSrcweir rNewSheet.SetParent(rParentName); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir // hat der Neue einen Follow? wenn ja, mit gleichem 644cdf0e10cSrcweir // Namen bei uns suchen 645cdf0e10cSrcweir if (pHisSheet->HasFollowSupport()) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir const String& rFollowName = pHisSheet->GetFollow(); 648cdf0e10cSrcweir if (0 != rFollowName.Len()) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir SfxStyleSheetBase* pFollowOfNew = 651cdf0e10cSrcweir pMyPool->Find(rFollowName, eOldFamily); 652cdf0e10cSrcweir if (pFollowOfNew) 653cdf0e10cSrcweir rNewSheet.SetFollow(rFollowName); 654cdf0e10cSrcweir } 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir SetModified( sal_True ); 658cdf0e10cSrcweir if( !bUsedOrUserDefined ) nIdx2 = nIdx1 = INDEX_IGNORE; 659cdf0e10cSrcweir 660cdf0e10cSrcweir bRet = sal_True; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir else 663cdf0e10cSrcweir bRet = sal_False; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir /* 666cdf0e10cSrcweir else if (nSourceIdx1 == CONTENT_CONFIG) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir nIdx1 = CONTENT_CONFIG; 669cdf0e10cSrcweir 670cdf0e10cSrcweir SfxConfigManager *pCfgMgr = SFX_CFGMANAGER(); 671cdf0e10cSrcweir if ( !GetConfigManager() ) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir SetConfigManager(new SfxConfigManager(0, pCfgMgr)); 674cdf0e10cSrcweir SetTemplateConfig(sal_False); 675cdf0e10cSrcweir if (this == Current()) 676cdf0e10cSrcweir GetConfigManager()->Activate(pCfgMgr); 677cdf0e10cSrcweir } 678cdf0e10cSrcweir 679cdf0e10cSrcweir if (GetConfigManager()->CopyItem( 680cdf0e10cSrcweir nSourceIdx2, nIdx2, rSource.GetConfigManager())) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir SetModified(sal_True); 683cdf0e10cSrcweir bRet = sal_True; 684cdf0e10cSrcweir SFX_APP()->GetDispatcher_Impl()->Update_Impl(sal_True); 685cdf0e10cSrcweir } 686cdf0e10cSrcweir } 687cdf0e10cSrcweir */ 688cdf0e10cSrcweir return bRet; 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691cdf0e10cSrcweir //-------------------------------------------------------------------- 692cdf0e10cSrcweir 693cdf0e10cSrcweir sal_Bool SfxObjectShell::Remove 694cdf0e10cSrcweir ( 695cdf0e10cSrcweir sal_uInt16 nIdx1, 696cdf0e10cSrcweir sal_uInt16 nIdx2, 697cdf0e10cSrcweir sal_uInt16 /*nIdx3*/ 698cdf0e10cSrcweir ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir sal_Bool bRet = sal_False; 701cdf0e10cSrcweir 702cdf0e10cSrcweir if (CONTENT_STYLE == nIdx1) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir SfxStyleSheetBasePool* pMyPool = GetStyleSheetPool(); 705cdf0e10cSrcweir 706cdf0e10cSrcweir SetOrganizerSearchMask(pMyPool); 707cdf0e10cSrcweir 708cdf0e10cSrcweir SfxStyleSheetBase* pMySheet = (*pMyPool)[nIdx2]; 709cdf0e10cSrcweir String aName(pMySheet->GetName()); 710cdf0e10cSrcweir String aEmpty; 711cdf0e10cSrcweir SfxStyleFamily eFamily = pMySheet->GetFamily(); 712cdf0e10cSrcweir pMyPool->Remove(pMySheet); 713cdf0e10cSrcweir bRet = sal_True; 714cdf0e10cSrcweir 715cdf0e10cSrcweir SfxStyleSheetBase* pTestSheet = pMyPool->First(); 716cdf0e10cSrcweir while (pTestSheet) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir if (pTestSheet->GetFamily() == eFamily && 719cdf0e10cSrcweir pTestSheet->HasParentSupport() && 720cdf0e10cSrcweir pTestSheet->GetParent() == aName) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir pTestSheet->SetParent(aEmpty); // Verknuepfung aufloesen 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir if (pTestSheet->GetFamily() == eFamily && 726cdf0e10cSrcweir pTestSheet->HasFollowSupport() && 727cdf0e10cSrcweir pTestSheet->GetFollow() == aName) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir pTestSheet->SetFollow(aEmpty); // Verknuepfung aufloesen 730cdf0e10cSrcweir } 731cdf0e10cSrcweir 732cdf0e10cSrcweir pTestSheet = pMyPool->Next(); 733cdf0e10cSrcweir } 734cdf0e10cSrcweir 735cdf0e10cSrcweir SetModified( sal_True ); 736cdf0e10cSrcweir } 737cdf0e10cSrcweir 738cdf0e10cSrcweir return bRet; 739cdf0e10cSrcweir } 740cdf0e10cSrcweir 741cdf0e10cSrcweir //-------------------------------------------------------------------- 742cdf0e10cSrcweir 743cdf0e10cSrcweir sal_Bool SfxObjectShell::Print 744cdf0e10cSrcweir ( 745cdf0e10cSrcweir Printer& rPrt, 746cdf0e10cSrcweir sal_uInt16 nIdx1, 747cdf0e10cSrcweir sal_uInt16 /*nIdx2*/, 748cdf0e10cSrcweir sal_uInt16 /*nIdx3*/, 749cdf0e10cSrcweir const String* pObjectName 750cdf0e10cSrcweir ) 751cdf0e10cSrcweir 752cdf0e10cSrcweir /* [Beschreibung] 753cdf0e10cSrcweir */ 754cdf0e10cSrcweir 755cdf0e10cSrcweir { 756cdf0e10cSrcweir switch(nIdx1) 757cdf0e10cSrcweir { 758cdf0e10cSrcweir case CONTENT_STYLE: 759cdf0e10cSrcweir { 760cdf0e10cSrcweir SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool(); 761cdf0e10cSrcweir SetOrganizerSearchMask(pStylePool); 762cdf0e10cSrcweir SfxStyleSheetIterator* pIter = pStylePool->CreateIterator( 763cdf0e10cSrcweir pStylePool->GetSearchFamily(), pStylePool->GetSearchMask() ); 764cdf0e10cSrcweir sal_uInt16 nStyles = pIter->Count(); 765cdf0e10cSrcweir SfxStyleSheetBase *pStyle = pIter->First(); 766cdf0e10cSrcweir if ( !pStyle ) 767cdf0e10cSrcweir return sal_True; 768cdf0e10cSrcweir 769cdf0e10cSrcweir // pepare adaptor for old style StartPage/EndPage printing 770cdf0e10cSrcweir boost::shared_ptr< Printer > pPrinter( new Printer( rPrt.GetJobSetup() ) ); 771cdf0e10cSrcweir vcl::OldStylePrintAdaptor* pAdaptor = new vcl::OldStylePrintAdaptor( pPrinter ); 772cdf0e10cSrcweir boost::shared_ptr< vcl::PrinterController > pController( pAdaptor ); 773cdf0e10cSrcweir 774cdf0e10cSrcweir pAdaptor->StartPage(); 775cdf0e10cSrcweir 776cdf0e10cSrcweir pPrinter->SetMapMode(MapMode(MAP_10TH_MM)); 777cdf0e10cSrcweir Font aFont( DEFINE_CONST_UNICODE( "Arial" ), Size(0, 64)); // 18pt 778cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD); 779cdf0e10cSrcweir pPrinter->SetFont(aFont); 780cdf0e10cSrcweir const Size aPageSize(pPrinter->GetOutputSize()); 781cdf0e10cSrcweir const sal_uInt16 nXIndent = 200; 782cdf0e10cSrcweir sal_uInt16 nYIndent = 200; 783cdf0e10cSrcweir Point aOutPos(nXIndent, nYIndent); 784cdf0e10cSrcweir String aHeader(SfxResId(STR_PRINT_STYLES_HEADER)); 785cdf0e10cSrcweir if ( pObjectName ) 786cdf0e10cSrcweir aHeader += *pObjectName; 787cdf0e10cSrcweir else 788cdf0e10cSrcweir aHeader += GetTitle(); 789cdf0e10cSrcweir long nTextHeight( pPrinter->GetTextHeight() ); 790cdf0e10cSrcweir pPrinter->DrawText(aOutPos, aHeader); 791cdf0e10cSrcweir aOutPos.Y() += nTextHeight; 792cdf0e10cSrcweir aOutPos.Y() += nTextHeight/2; 793cdf0e10cSrcweir aFont.SetSize(Size(0, 35)); // 10pt 794cdf0e10cSrcweir nStyles = 1; 795cdf0e10cSrcweir while(pStyle) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir // print template name 798cdf0e10cSrcweir String aStr(pStyle->GetName()); 799cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD); 800cdf0e10cSrcweir pPrinter->SetFont(aFont); 801cdf0e10cSrcweir nTextHeight = pPrinter->GetTextHeight(); 802cdf0e10cSrcweir // check for new page 803cdf0e10cSrcweir if ( aOutPos.Y() + nTextHeight*2 > 804cdf0e10cSrcweir aPageSize.Height() - (long) nYIndent ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir pAdaptor->EndPage(); 807cdf0e10cSrcweir pAdaptor->StartPage(); 808cdf0e10cSrcweir aOutPos.Y() = nYIndent; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir pPrinter->DrawText(aOutPos, aStr); 811cdf0e10cSrcweir aOutPos.Y() += nTextHeight; 812cdf0e10cSrcweir 813cdf0e10cSrcweir // print template description 814cdf0e10cSrcweir aFont.SetWeight(WEIGHT_NORMAL); 815cdf0e10cSrcweir pPrinter->SetFont(aFont); 816cdf0e10cSrcweir aStr = pStyle->GetDescription(); 817cdf0e10cSrcweir const char cDelim = ' '; 818cdf0e10cSrcweir sal_uInt16 nStart = 0, nIdx = 0; 819cdf0e10cSrcweir 820cdf0e10cSrcweir nTextHeight = pPrinter->GetTextHeight(); 821cdf0e10cSrcweir // break text into lines 822cdf0e10cSrcweir while(nIdx < aStr.Len()) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir sal_uInt16 nOld = nIdx; 825cdf0e10cSrcweir long nTextWidth; 826cdf0e10cSrcweir nIdx = aStr.Search(cDelim, nStart); 827cdf0e10cSrcweir nTextWidth = pPrinter->GetTextWidth(aStr, nStart, nIdx-nStart); 828cdf0e10cSrcweir while(nIdx != STRING_NOTFOUND && 829cdf0e10cSrcweir aOutPos.X() + nTextWidth < 830cdf0e10cSrcweir aPageSize.Width() - (long) nXIndent) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir nOld = nIdx; 833cdf0e10cSrcweir nIdx = aStr.Search(cDelim, nIdx+1); 834cdf0e10cSrcweir nTextWidth = pPrinter->GetTextWidth(aStr, nStart, nIdx-nStart); 835cdf0e10cSrcweir } 836cdf0e10cSrcweir String aTmp(aStr, nStart, nIdx == STRING_NOTFOUND? 837cdf0e10cSrcweir STRING_LEN : 838cdf0e10cSrcweir nOld-nStart); 839cdf0e10cSrcweir if ( aTmp.Len() ) 840cdf0e10cSrcweir { 841cdf0e10cSrcweir nStart = nOld+1; // trailing space 842cdf0e10cSrcweir } 843cdf0e10cSrcweir else 844cdf0e10cSrcweir { 845cdf0e10cSrcweir sal_uInt16 nChar = 1; 846cdf0e10cSrcweir while( 847cdf0e10cSrcweir nStart + nChar < aStr.Len() && 848cdf0e10cSrcweir aOutPos.X() + pPrinter->GetTextWidth( 849cdf0e10cSrcweir aStr, nStart, nChar) < 850cdf0e10cSrcweir aPageSize.Width() - nXIndent) 851cdf0e10cSrcweir ++nChar; 852cdf0e10cSrcweir aTmp = String(aStr, nStart, nChar-1); 853cdf0e10cSrcweir nIdx = nStart + nChar; 854cdf0e10cSrcweir nStart = nIdx; 855cdf0e10cSrcweir } 856cdf0e10cSrcweir if ( aOutPos.Y() + nTextHeight*2 > 857cdf0e10cSrcweir aPageSize.Height() - nYIndent ) 858cdf0e10cSrcweir { 859cdf0e10cSrcweir pAdaptor->EndPage(); 860cdf0e10cSrcweir pAdaptor->StartPage(); 861cdf0e10cSrcweir aOutPos.Y() = nYIndent; 862cdf0e10cSrcweir } 863cdf0e10cSrcweir pPrinter->DrawText(aOutPos, aTmp); 864cdf0e10cSrcweir aOutPos.Y() += pPrinter->GetTextHeight(); 865cdf0e10cSrcweir } 866cdf0e10cSrcweir pStyle = pIter->Next(); 867cdf0e10cSrcweir } 868cdf0e10cSrcweir pAdaptor->EndPage(); 869cdf0e10cSrcweir 870cdf0e10cSrcweir Printer::PrintJob( pController, rPrt.GetJobSetup() ); 871cdf0e10cSrcweir 872cdf0e10cSrcweir delete pIter; 873cdf0e10cSrcweir break; 874cdf0e10cSrcweir } 875cdf0e10cSrcweir default: 876cdf0e10cSrcweir return sal_False; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir return sal_True; 879cdf0e10cSrcweir } 880cdf0e10cSrcweir 881cdf0e10cSrcweir //-------------------------------------------------------------------- 882cdf0e10cSrcweir 883cdf0e10cSrcweir void SfxObjectShell::LoadStyles 884cdf0e10cSrcweir ( 885cdf0e10cSrcweir SfxObjectShell &rSource /* die Dokument-Vorlage, aus der 886cdf0e10cSrcweir die Styles geladen werden sollen */ 887cdf0e10cSrcweir ) 888cdf0e10cSrcweir 889cdf0e10cSrcweir /* [Beschreibung] 890cdf0e10cSrcweir 891cdf0e10cSrcweir Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage 892cdf0e10cSrcweir Styles nachgeladen werden sollen. Bestehende Styles soll dabei 893cdf0e10cSrcweir "uberschrieben werden. Das Dokument mu"s daher neu formatiert werden. 894cdf0e10cSrcweir Daher werden die Applikationen in der Regel diese Methode "uberladen 895cdf0e10cSrcweir und in ihrer Implementierung die Implementierung der Basisklasse 896cdf0e10cSrcweir rufen. 897cdf0e10cSrcweir */ 898cdf0e10cSrcweir 899cdf0e10cSrcweir { 900cdf0e10cSrcweir struct Styles_Impl 901cdf0e10cSrcweir { 902cdf0e10cSrcweir SfxStyleSheetBase *pSource; 903cdf0e10cSrcweir SfxStyleSheetBase *pDest; 904cdf0e10cSrcweir // Styles_Impl () : pSource(0), pDest(0) {} 905cdf0e10cSrcweir }; 906cdf0e10cSrcweir 907cdf0e10cSrcweir SfxStyleSheetBasePool *pSourcePool = rSource.GetStyleSheetPool(); 908cdf0e10cSrcweir DBG_ASSERT(pSourcePool, "Source-DocumentShell ohne StyleSheetPool"); 909cdf0e10cSrcweir SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool(); 910cdf0e10cSrcweir DBG_ASSERT(pMyPool, "Dest-DocumentShell ohne StyleSheetPool"); 911cdf0e10cSrcweir pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, 0xffff); 912cdf0e10cSrcweir Styles_Impl *pFound = new Styles_Impl[pSourcePool->Count()]; 913cdf0e10cSrcweir sal_uInt16 nFound = 0; 914cdf0e10cSrcweir 915cdf0e10cSrcweir SfxStyleSheetBase *pSource = pSourcePool->First(); 916cdf0e10cSrcweir while ( pSource ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir SfxStyleSheetBase *pDest = 919cdf0e10cSrcweir pMyPool->Find( pSource->GetName(), pSource->GetFamily() ); 920cdf0e10cSrcweir if ( !pDest ) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir pDest = &pMyPool->Make( pSource->GetName(), 923cdf0e10cSrcweir pSource->GetFamily(), pSource->GetMask()); 924cdf0e10cSrcweir // Setzen des Parents, der Folgevorlage 925cdf0e10cSrcweir } 926cdf0e10cSrcweir pFound[nFound].pSource = pSource; 927cdf0e10cSrcweir pFound[nFound].pDest = pDest; 928cdf0e10cSrcweir ++nFound; 929cdf0e10cSrcweir pSource = pSourcePool->Next(); 930cdf0e10cSrcweir } 931cdf0e10cSrcweir 932cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nFound; ++i ) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir pFound[i].pDest->GetItemSet().PutExtended(pFound[i].pSource->GetItemSet(), SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT); 935cdf0e10cSrcweir // pFound[i].pDest->SetHelpId(pFound[i].pSource->GetHelpId()); 936cdf0e10cSrcweir if(pFound[i].pSource->HasParentSupport()) 937cdf0e10cSrcweir pFound[i].pDest->SetParent(pFound[i].pSource->GetParent()); 938cdf0e10cSrcweir if(pFound[i].pSource->HasFollowSupport()) 939cdf0e10cSrcweir pFound[i].pDest->SetFollow(pFound[i].pSource->GetParent()); 940cdf0e10cSrcweir } 941cdf0e10cSrcweir delete [] pFound; 942cdf0e10cSrcweir } 943cdf0e10cSrcweir 944cdf0e10cSrcweir //-------------------------------------------------------------------- 945cdf0e10cSrcweir 946cdf0e10cSrcweir void SfxObjectShell::UpdateFromTemplate_Impl( ) 947cdf0e10cSrcweir 948cdf0e10cSrcweir /* [Beschreibung] 949cdf0e10cSrcweir 950cdf0e10cSrcweir Diese interne Methode pr"uft, ob das Dokument aus einem Template 951cdf0e10cSrcweir erzeugt wurde, und ob dieses neuer ist als das Dokument. Ist dies 952cdf0e10cSrcweir der Fall, wird der Benutzer gefragt, ob die Vorlagen (StyleSheets) 953cdf0e10cSrcweir updated werden sollen. Wird dies positiv beantwortet, werden die 954cdf0e10cSrcweir StyleSheets updated. 955cdf0e10cSrcweir */ 956cdf0e10cSrcweir 957cdf0e10cSrcweir { 958cdf0e10cSrcweir // Storage-medium? 959cdf0e10cSrcweir SfxMedium *pFile = GetMedium(); 960cdf0e10cSrcweir DBG_ASSERT( pFile, "cannot UpdateFromTemplate without medium" ); 961cdf0e10cSrcweir if ( !pFile ) 962cdf0e10cSrcweir return; 963cdf0e10cSrcweir 964cdf0e10cSrcweir if ( !::utl::LocalFileHelper::IsLocalFile( pFile->GetName() ) ) 965cdf0e10cSrcweir // update only for documents loaded from the local file system 966cdf0e10cSrcweir return; 967cdf0e10cSrcweir 968cdf0e10cSrcweir // only for own storage formats 969cdf0e10cSrcweir uno::Reference< embed::XStorage > xDocStor = pFile->GetStorage(); 970cdf0e10cSrcweir if ( !pFile->GetFilter() || !pFile->GetFilter()->IsOwnFormat() ) 971cdf0e10cSrcweir return; 972cdf0e10cSrcweir 973cdf0e10cSrcweir SFX_ITEMSET_ARG( pFile->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False); 974cdf0e10cSrcweir sal_Int16 bCanUpdateFromTemplate = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE; 975cdf0e10cSrcweir 976cdf0e10cSrcweir // created from template? 977cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); 978cdf0e10cSrcweir ::rtl::OUString aTemplName( xDocProps->getTemplateName() ); 979cdf0e10cSrcweir ::rtl::OUString aTemplURL( xDocProps->getTemplateURL() ); 980cdf0e10cSrcweir String aFoundName; 981cdf0e10cSrcweir 982cdf0e10cSrcweir if ( aTemplName.getLength() || (aTemplURL.getLength() && !IsReadOnly()) ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir // try to locate template, first using filename 985cdf0e10cSrcweir // this must be done because writer global document uses this "great" idea to manage the templates of all parts 986cdf0e10cSrcweir // in the master document 987cdf0e10cSrcweir // but it is NOT an error if the template filename points not to a valid file 988cdf0e10cSrcweir SfxDocumentTemplates aTempl; 989cdf0e10cSrcweir aTempl.Construct(); 990cdf0e10cSrcweir if ( aTemplURL.getLength() ) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir String aURL; 993cdf0e10cSrcweir if( ::utl::LocalFileHelper::ConvertSystemPathToURL( aTemplURL, GetMedium()->GetName(), aURL ) ) 994cdf0e10cSrcweir aFoundName = aURL; 995cdf0e10cSrcweir } 996cdf0e10cSrcweir 997cdf0e10cSrcweir if( !aFoundName.Len() && aTemplName.getLength() ) 998cdf0e10cSrcweir // if the template filename did not lead to success, try to get a file name for the logical template name 999cdf0e10cSrcweir aTempl.GetFull( String(), aTemplName, aFoundName ); 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir if ( aFoundName.Len() ) 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir // check existence of template storage 1005cdf0e10cSrcweir aTemplURL = aFoundName; 1006cdf0e10cSrcweir sal_Bool bLoad = sal_False; 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir // should the document checked against changes in the template ? 1009cdf0e10cSrcweir if ( IsQueryLoadTemplate() ) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir // load document info of template 1012cdf0e10cSrcweir sal_Bool bOK = sal_False; 1013cdf0e10cSrcweir util::DateTime aTemplDate; 1014cdf0e10cSrcweir try 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir Reference < document::XStandaloneDocumentInfo > xDocInfo ( 1017cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 1018cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 1019cdf0e10cSrcweir "com.sun.star.document.StandaloneDocumentInfo") ) ), 1020cdf0e10cSrcweir UNO_QUERY_THROW ); 1021cdf0e10cSrcweir Reference < beans::XFastPropertySet > xSet( xDocInfo, 1022cdf0e10cSrcweir UNO_QUERY_THROW ); 1023cdf0e10cSrcweir xDocInfo->loadFromURL( aTemplURL ); 1024cdf0e10cSrcweir Any aAny = xSet->getFastPropertyValue( WID_DATE_MODIFIED ); 1025cdf0e10cSrcweir ::com::sun::star::util::DateTime aTmp; 1026cdf0e10cSrcweir if ( aAny >>= aTemplDate ) 1027cdf0e10cSrcweir { 1028cdf0e10cSrcweir // get modify date from document info 1029cdf0e10cSrcweir bOK = sal_True; 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir catch ( Exception& ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir } 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir // if modify date was read successfully 1037cdf0e10cSrcweir if ( bOK ) 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir // compare modify data of template with the last check date of the document 1040cdf0e10cSrcweir const util::DateTime aInfoDate( xDocProps->getTemplateDate() ); 1041cdf0e10cSrcweir if ( aTemplDate > aInfoDate ) 1042cdf0e10cSrcweir { 1043cdf0e10cSrcweir // ask user 1044cdf0e10cSrcweir if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE 1045cdf0e10cSrcweir || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE ) 1046cdf0e10cSrcweir bLoad = sal_True; 1047cdf0e10cSrcweir else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG ) 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir String sMessage( SfxResId( STR_QRYTEMPL_MESSAGE ) ); 1050cdf0e10cSrcweir sMessage.SearchAndReplace( String::CreateFromAscii("$(ARG1)"), aTemplName ); 1051cdf0e10cSrcweir sfx2::QueryTemplateBox aBox( GetDialogParent(), sMessage ); 1052cdf0e10cSrcweir if ( RET_YES == aBox.Execute() ) 1053cdf0e10cSrcweir bLoad = sal_True; 1054cdf0e10cSrcweir } 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir if( !bLoad ) 1057cdf0e10cSrcweir { 1058cdf0e10cSrcweir // user refuses, so don't ask again for this document 1059cdf0e10cSrcweir SetQueryLoadTemplate(sal_False); 1060cdf0e10cSrcweir SetModified( sal_True ); 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir } 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir if ( bLoad ) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir // styles should be updated, create document in organizer mode to read in the styles 1068cdf0e10cSrcweir //TODO: testen! 1069cdf0e10cSrcweir SfxObjectShellLock xTemplDoc = CreateObjectByFactoryName( GetFactory().GetFactoryName(), SFX_CREATE_MODE_ORGANIZER ); 1070cdf0e10cSrcweir xTemplDoc->DoInitNew(0); 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended! 1073cdf0e10cSrcweir //xTemplDoc->SetBaseURL( aFoundName ); 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir // TODO/LATER: make sure that we don't use binary templates! 1076cdf0e10cSrcweir SfxMedium aMedium( aFoundName, STREAM_STD_READ ); 1077cdf0e10cSrcweir if ( xTemplDoc->LoadFrom( aMedium ) ) 1078cdf0e10cSrcweir { 1079cdf0e10cSrcweir // transfer styles from xTemplDoc to this document 1080cdf0e10cSrcweir // TODO/MBA: make sure that no BaseURL is needed in *this* document 1081cdf0e10cSrcweir LoadStyles(*xTemplDoc); 1082cdf0e10cSrcweir 1083cdf0e10cSrcweir // remember date/time of check 1084cdf0e10cSrcweir xDocProps->setTemplateDate(aTemplDate); 1085cdf0e10cSrcweir // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format ) 1086cdf0e10cSrcweir //REPLACE pInfo->Save(xDocStor); 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir } 1091cdf0e10cSrcweir } 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir sal_Bool SfxObjectShell::IsHelpDocument() const 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir const SfxFilter* pFilter = GetMedium()->GetFilter(); 1096cdf0e10cSrcweir return ( pFilter && pFilter->GetFilterName().CompareToAscii("writer_web_HTML_help") == COMPARE_EQUAL ); 1097cdf0e10cSrcweir } 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir void SfxObjectShell::ResetFromTemplate( const String& rTemplateName, const String& rFileName ) 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir // only care about reseting this data for openoffice formats otherwise 1102cdf0e10cSrcweir if ( IsOwnStorageFormat_Impl( *GetMedium()) ) 1103cdf0e10cSrcweir { 1104cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); 1105cdf0e10cSrcweir xDocProps->setTemplateURL( ::rtl::OUString() ); 1106cdf0e10cSrcweir xDocProps->setTemplateName( ::rtl::OUString() ); 1107cdf0e10cSrcweir xDocProps->setTemplateDate( util::DateTime() ); 1108cdf0e10cSrcweir xDocProps->resetUserData( ::rtl::OUString() ); 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir // TODO/REFACTOR: 1111cdf0e10cSrcweir // Title? 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir if( ::utl::LocalFileHelper::IsLocalFile( rFileName ) ) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir String aFoundName; 1116cdf0e10cSrcweir if( SFX_APP()->Get_Impl()->GetDocumentTemplates()->GetFull( String(), rTemplateName, aFoundName ) ) 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir INetURLObject aObj( rFileName ); 1119cdf0e10cSrcweir xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); 1120cdf0e10cSrcweir xDocProps->setTemplateName( rTemplateName ); 1121cdf0e10cSrcweir 1122cdf0e10cSrcweir ::DateTime now; 1123cdf0e10cSrcweir xDocProps->setTemplateDate( util::DateTime( 1124cdf0e10cSrcweir now.Get100Sec(), now.GetSec(), now.GetMin(), 1125cdf0e10cSrcweir now.GetHour(), now.GetDay(), now.GetMonth(), 1126cdf0e10cSrcweir now.GetYear() ) ); 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir SetQueryLoadTemplate( sal_True ); 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir } 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir } 1133cdf0e10cSrcweir 1134cdf0e10cSrcweir sal_Bool SfxObjectShell::IsQueryLoadTemplate() const 1135cdf0e10cSrcweir { 1136cdf0e10cSrcweir return pImp->bQueryLoadTemplate; 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir sal_Bool SfxObjectShell::IsUseUserData() const 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir return pImp->bUseUserData; 1142cdf0e10cSrcweir } 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir void SfxObjectShell::SetQueryLoadTemplate( sal_Bool bNew ) 1145cdf0e10cSrcweir { 1146cdf0e10cSrcweir if ( pImp->bQueryLoadTemplate != bNew ) 1147cdf0e10cSrcweir SetModified( sal_True ); 1148cdf0e10cSrcweir pImp->bQueryLoadTemplate = bNew; 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir void SfxObjectShell::SetUseUserData( sal_Bool bNew ) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir if ( pImp->bUseUserData != bNew ) 1154cdf0e10cSrcweir SetModified( sal_True ); 1155cdf0e10cSrcweir pImp->bUseUserData = bNew; 1156cdf0e10cSrcweir } 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir sal_Bool SfxObjectShell::IsLoadReadonly() const 1159cdf0e10cSrcweir { 1160cdf0e10cSrcweir return pImp->bLoadReadonly; 1161cdf0e10cSrcweir } 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir sal_Bool SfxObjectShell::IsSaveVersionOnClose() const 1164cdf0e10cSrcweir { 1165cdf0e10cSrcweir return pImp->bSaveVersionOnClose; 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir void SfxObjectShell::SetLoadReadonly( sal_Bool bNew ) 1169cdf0e10cSrcweir { 1170cdf0e10cSrcweir if ( pImp->bLoadReadonly != bNew ) 1171cdf0e10cSrcweir SetModified( sal_True ); 1172cdf0e10cSrcweir pImp->bLoadReadonly = bNew; 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir if ( pImp->bSaveVersionOnClose != bNew ) 1178cdf0e10cSrcweir SetModified( sal_True ); 1179cdf0e10cSrcweir pImp->bSaveVersionOnClose = bNew; 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir 1182cdf0e10cSrcweir sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const 1183cdf0e10cSrcweir { 1184cdf0e10cSrcweir return pImp->m_nModifyPasswordHash; 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir if ( ( !IsReadOnly() && !IsReadOnlyUI() ) 1190cdf0e10cSrcweir || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) 1191cdf0e10cSrcweir { 1192cdf0e10cSrcweir // the hash can be changed only in editable documents, 1193cdf0e10cSrcweir // or during loading of document 1194cdf0e10cSrcweir pImp->m_nModifyPasswordHash = nHash; 1195cdf0e10cSrcweir return sal_True; 1196cdf0e10cSrcweir } 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir return sal_False; 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SfxObjectShell::GetModifyPasswordInfo() const 1202cdf0e10cSrcweir { 1203cdf0e10cSrcweir return pImp->m_aModifyPasswordInfo; 1204cdf0e10cSrcweir } 1205cdf0e10cSrcweir 1206cdf0e10cSrcweir sal_Bool SfxObjectShell::SetModifyPasswordInfo( const uno::Sequence< beans::PropertyValue >& aInfo ) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir if ( ( !IsReadOnly() && !IsReadOnlyUI() ) 1209cdf0e10cSrcweir || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir // the hash can be changed only in editable documents, 1212cdf0e10cSrcweir // or during loading of document 1213cdf0e10cSrcweir pImp->m_aModifyPasswordInfo = aInfo; 1214cdf0e10cSrcweir return sal_True; 1215cdf0e10cSrcweir } 1216cdf0e10cSrcweir 1217cdf0e10cSrcweir return sal_False; 1218cdf0e10cSrcweir } 1219cdf0e10cSrcweir 1220cdf0e10cSrcweir void SfxObjectShell::SetModifyPasswordEntered( sal_Bool bEntered ) 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir pImp->m_bModifyPasswordEntered = bEntered; 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir sal_Bool SfxObjectShell::IsModifyPasswordEntered() 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir return pImp->m_bModifyPasswordEntered; 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir 1230