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