1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svl/lckbitem.hxx> 28cdf0e10cSrcweir #include <sfx2/frame.hxx> 29cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 30cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 31cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svx/dialogs.hrc> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <editeng/langitem.hxx> 36cdf0e10cSrcweir #include <editeng/editdata.hxx> 37cdf0e10cSrcweir #include <vcl/msgbox.hxx> 38cdf0e10cSrcweir #include <editeng/svxenum.hxx> 39cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 40cdf0e10cSrcweir #include <sfx2/request.hxx> 41cdf0e10cSrcweir #include <sfx2/printer.hxx> 42cdf0e10cSrcweir #include <sfx2/docfile.hxx> 43cdf0e10cSrcweir #include <editeng/paperinf.hxx> 44cdf0e10cSrcweir #include <editeng/eeitem.hxx> 45cdf0e10cSrcweir #include <unotools/useroptions.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include "app.hrc" 48cdf0e10cSrcweir #include "glob.hrc" 49cdf0e10cSrcweir #include "strings.hrc" 50cdf0e10cSrcweir #include "res_bmp.hrc" 51cdf0e10cSrcweir 52cdf0e10cSrcweir #define _SD_DLL // fuer SD_MOD() 53cdf0e10cSrcweir #include "sdmod.hxx" 54cdf0e10cSrcweir #include "sddll.hxx" 55cdf0e10cSrcweir #include "pres.hxx" 56cdf0e10cSrcweir #include "optsitem.hxx" 57cdf0e10cSrcweir #include "ViewShell.hxx" 58cdf0e10cSrcweir #include "sdattr.hxx" 59cdf0e10cSrcweir #include "sdpage.hxx" 60cdf0e10cSrcweir #include "DrawDocShell.hxx" 61cdf0e10cSrcweir #include "drawdoc.hxx" 62cdf0e10cSrcweir #include "assclass.hxx" 63cdf0e10cSrcweir #include "sdenumdef.hxx" 64cdf0e10cSrcweir #include "sdresid.hxx" 65cdf0e10cSrcweir #include "OutlineViewShell.hxx" 66cdf0e10cSrcweir #include "ViewShellBase.hxx" 67cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX 68cdf0e10cSrcweir #include "FrameView.hxx" 69cdf0e10cSrcweir #endif 70cdf0e10cSrcweir #include "FactoryIds.hxx" 71cdf0e10cSrcweir #include "sdabstdlg.hxx" 72cdf0e10cSrcweir #include <memory> 73cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 74cdf0e10cSrcweir #include <boost/scoped_array.hpp> 75cdf0e10cSrcweir #include "slideshow.hxx" 76cdf0e10cSrcweir 77cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 78cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir using ::sd::framework::FrameworkHelper; 82cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 83cdf0e10cSrcweir using ::com::sun::star::frame::XFrame; 84cdf0e10cSrcweir 85cdf0e10cSrcweir namespace { 86cdf0e10cSrcweir 87cdf0e10cSrcweir class OutlineToImpressFinalizer 88cdf0e10cSrcweir { 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir OutlineToImpressFinalizer ( 91cdf0e10cSrcweir ::sd::ViewShellBase& rBase, 92cdf0e10cSrcweir SdDrawDocument& rDocument, 93cdf0e10cSrcweir SvLockBytes& rBytes); 94cdf0e10cSrcweir virtual ~OutlineToImpressFinalizer (void) {}; 95cdf0e10cSrcweir void operator() (bool bEventSeen); 96cdf0e10cSrcweir private: 97cdf0e10cSrcweir ::sd::ViewShellBase& mrBase; 98cdf0e10cSrcweir SdDrawDocument& mrDocument; 99cdf0e10cSrcweir ::boost::shared_ptr<SvMemoryStream> mpStream; 100cdf0e10cSrcweir }; 101cdf0e10cSrcweir 102cdf0e10cSrcweir 103cdf0e10cSrcweir } //end of anonymous namespace 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir /************************************************************************* 107cdf0e10cSrcweir |* 108cdf0e10cSrcweir |* Execute 109cdf0e10cSrcweir |* 110cdf0e10cSrcweir \************************************************************************/ 111cdf0e10cSrcweir 112cdf0e10cSrcweir void SdModule::Execute(SfxRequest& rReq) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir const SfxItemSet* pSet = rReq.GetArgs(); 115cdf0e10cSrcweir sal_uLong nSlotId = rReq.GetSlot(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir switch ( nSlotId ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir case SID_NEWDOC: 120cdf0e10cSrcweir { 121cdf0e10cSrcweir SFX_APP()->ExecuteSlot(rReq, SFX_APP()->GetInterface()); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir break; 124cdf0e10cSrcweir 125cdf0e10cSrcweir case SID_AUTOSPELL_CHECK: 126cdf0e10cSrcweir { 127cdf0e10cSrcweir // automatische Rechtschreibpruefung 128cdf0e10cSrcweir const SfxPoolItem* pItem; 129cdf0e10cSrcweir if( pSet && SFX_ITEM_SET == pSet->GetItemState( 130cdf0e10cSrcweir SID_AUTOSPELL_CHECK, sal_False, &pItem ) ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir sal_Bool bOnlineSpelling = ( (const SfxBoolItem*) pItem )->GetValue(); 133cdf0e10cSrcweir // am Dokument sichern: 134cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 135cdf0e10cSrcweir if( pDocSh ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir SdDrawDocument* pDoc = pDocSh->GetDoc(); 138cdf0e10cSrcweir pDoc->SetOnlineSpell( bOnlineSpelling ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir break; 143cdf0e10cSrcweir 144cdf0e10cSrcweir case SID_ATTR_METRIC: 145cdf0e10cSrcweir { 146cdf0e10cSrcweir const SfxPoolItem* pItem; 147cdf0e10cSrcweir if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_METRIC, sal_True, &pItem ) ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue(); 150cdf0e10cSrcweir switch( eUnit ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir case FUNIT_MM: // nur die Einheiten, die auch im Dialog stehen 153cdf0e10cSrcweir case FUNIT_CM: 154cdf0e10cSrcweir case FUNIT_INCH: 155cdf0e10cSrcweir case FUNIT_PICA: 156cdf0e10cSrcweir case FUNIT_POINT: 157cdf0e10cSrcweir { 158cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() ); 159cdf0e10cSrcweir if(pDocSh) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir DocumentType eDocType = pDocSh->GetDoc()->GetDocumentType(); 162cdf0e10cSrcweir 163cdf0e10cSrcweir PutItem( *pItem ); 164cdf0e10cSrcweir SdOptions* pOptions = GetSdOptions( eDocType ); 165cdf0e10cSrcweir if(pOptions) 166cdf0e10cSrcweir pOptions->SetMetric( (sal_uInt16)eUnit ); 167cdf0e10cSrcweir rReq.Done(); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir break; 171cdf0e10cSrcweir default: 172cdf0e10cSrcweir break; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir } 177cdf0e10cSrcweir break; 178cdf0e10cSrcweir 179cdf0e10cSrcweir case SID_ATTR_LANGUAGE: 180cdf0e10cSrcweir case SID_ATTR_CHAR_CJK_LANGUAGE: 181cdf0e10cSrcweir case SID_ATTR_CHAR_CTL_LANGUAGE: 182cdf0e10cSrcweir { 183cdf0e10cSrcweir const SfxPoolItem* pItem; 184cdf0e10cSrcweir if( pSet && 185cdf0e10cSrcweir ( 186cdf0e10cSrcweir SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_LANGUAGE, sal_False, &pItem ) || 187cdf0e10cSrcweir SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem ) || 188cdf0e10cSrcweir SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem ) 189cdf0e10cSrcweir ) 190cdf0e10cSrcweir ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir // am Dokument sichern: 193cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 194cdf0e10cSrcweir if ( pDocSh ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir LanguageType eLanguage = ( (SvxLanguageItem*)pItem )->GetValue(); 197cdf0e10cSrcweir SdDrawDocument* pDoc = pDocSh->GetDoc(); 198cdf0e10cSrcweir 199cdf0e10cSrcweir if( nSlotId == SID_ATTR_CHAR_CJK_LANGUAGE ) 200cdf0e10cSrcweir pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE_CJK ); 201cdf0e10cSrcweir else if( nSlotId == SID_ATTR_CHAR_CTL_LANGUAGE ) 202cdf0e10cSrcweir pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE_CTL ); 203cdf0e10cSrcweir else 204cdf0e10cSrcweir pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE ); 205cdf0e10cSrcweir 206cdf0e10cSrcweir if( pDoc->GetOnlineSpell() ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir pDoc->StopOnlineSpelling(); 209cdf0e10cSrcweir pDoc->StartOnlineSpelling(); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir } 213cdf0e10cSrcweir } 214cdf0e10cSrcweir break; 215cdf0e10cSrcweir 216cdf0e10cSrcweir case SID_SD_AUTOPILOT: 217cdf0e10cSrcweir case SID_NEWSD: 218cdf0e10cSrcweir { 219cdf0e10cSrcweir SfxFrame* pFrame = ExecuteNewDocument( rReq ); 220cdf0e10cSrcweir // #94442# if a frame was created, set it as return value 221cdf0e10cSrcweir if(pFrame) 222cdf0e10cSrcweir rReq.SetReturnValue(SfxFrameItem(0, pFrame)); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir break; 226cdf0e10cSrcweir 227cdf0e10cSrcweir case SID_OPENHYPERLINK: 228cdf0e10cSrcweir case SID_OPENDOC: 229cdf0e10cSrcweir { 230cdf0e10cSrcweir sal_Bool bIntercept = sal_False; 231cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 232cdf0e10cSrcweir if (pDocShell) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 235cdf0e10cSrcweir if (pViewShell) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir // Prevent documents from opening while the slide 240cdf0e10cSrcweir // show is running, except when this request comes 241cdf0e10cSrcweir // from a shape interaction. 242cdf0e10cSrcweir if (rReq.GetArgs() == NULL) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir bIntercept = sal_True; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir } 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir if (!bIntercept) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir SFX_APP()->ExecuteSlot(rReq, SFX_APP()->GetInterface()); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir else 255cdf0e10cSrcweir { 256cdf0e10cSrcweir ErrorBox(NULL, WB_OK, String(SdResId(STR_CANT_PERFORM_IN_LIVEMODE))).Execute(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pLinkItem, SfxLinkItem, SID_DONELINK, sal_False ); 259cdf0e10cSrcweir if( pLinkItem ) 260cdf0e10cSrcweir pLinkItem->GetValue().Call( 0 ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir break; 264cdf0e10cSrcweir 265cdf0e10cSrcweir case SID_OUTLINE_TO_IMPRESS: 266cdf0e10cSrcweir OutlineToImpress (rReq); 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir 269cdf0e10cSrcweir default: 270cdf0e10cSrcweir break; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir 275cdf0e10cSrcweir 276cdf0e10cSrcweir 277cdf0e10cSrcweir void SdModule::OutlineToImpress (SfxRequest& rRequest) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir const SfxItemSet* pSet = rRequest.GetArgs(); 280cdf0e10cSrcweir 281cdf0e10cSrcweir if (pSet) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir SvLockBytes* pBytes = ((SfxLockBytesItem&) pSet->Get(SID_OUTLINE_TO_IMPRESS)).GetValue(); 284cdf0e10cSrcweir 285cdf0e10cSrcweir if (pBytes) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir SfxObjectShellLock xDocShell; 288cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh; 289cdf0e10cSrcweir xDocShell = pDocSh = new ::sd::DrawDocShell( 290cdf0e10cSrcweir SFX_CREATE_MODE_STANDARD, sal_False); 291cdf0e10cSrcweir if(pDocSh) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir pDocSh->DoInitNew(NULL); 294cdf0e10cSrcweir SdDrawDocument* pDoc = pDocSh->GetDoc(); 295cdf0e10cSrcweir if(pDoc) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir pDoc->CreateFirstPages(); 298cdf0e10cSrcweir pDoc->StopWorkStartupDelay(); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir SFX_REQUEST_ARG( rRequest, pFrmItem, SfxFrameItem, SID_DOCFRAME, sal_False); 302cdf0e10cSrcweir SfxViewFrame::LoadDocumentIntoFrame( *pDocSh, pFrmItem, ::sd::OUTLINE_FACTORY_ID ); 303cdf0e10cSrcweir 304cdf0e10cSrcweir ::sd::ViewShell* pViewSh = pDocSh->GetViewShell(); 305cdf0e10cSrcweir 306cdf0e10cSrcweir if (pViewSh) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir // AutoLayouts muessen fertig sein 309cdf0e10cSrcweir pDoc->StopWorkStartupDelay(); 310cdf0e10cSrcweir 311cdf0e10cSrcweir SfxViewFrame* pViewFrame = pViewSh->GetViewFrame(); 312cdf0e10cSrcweir 313cdf0e10cSrcweir // When the view frame has not been just created we have 314cdf0e10cSrcweir // to switch synchronously to the outline view. 315cdf0e10cSrcweir // (Otherwise the request will be ignored anyway.) 316cdf0e10cSrcweir ::sd::ViewShellBase* pBase 317cdf0e10cSrcweir = dynamic_cast< ::sd::ViewShellBase*>(pViewFrame->GetViewShell()); 318cdf0e10cSrcweir if (pBase != NULL) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir ::boost::shared_ptr<FrameworkHelper> pHelper ( 321cdf0e10cSrcweir FrameworkHelper::Instance(*pBase)); 322cdf0e10cSrcweir pHelper->RequestView( 323cdf0e10cSrcweir FrameworkHelper::msOutlineViewURL, 324cdf0e10cSrcweir FrameworkHelper::msCenterPaneURL); 325cdf0e10cSrcweir 326cdf0e10cSrcweir pHelper->RunOnResourceActivation( 327cdf0e10cSrcweir FrameworkHelper::CreateResourceId( 328cdf0e10cSrcweir FrameworkHelper::msOutlineViewURL, 329cdf0e10cSrcweir FrameworkHelper::msCenterPaneURL), 330cdf0e10cSrcweir OutlineToImpressFinalizer(*pBase, *pDoc, *pBytes)); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir } 333cdf0e10cSrcweir } 334cdf0e10cSrcweir } 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir rRequest.IsDone(); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir 341cdf0e10cSrcweir 342cdf0e10cSrcweir 343cdf0e10cSrcweir /************************************************************************* 344cdf0e10cSrcweir |* 345cdf0e10cSrcweir |* GetState 346cdf0e10cSrcweir |* 347cdf0e10cSrcweir \************************************************************************/ 348cdf0e10cSrcweir 349cdf0e10cSrcweir static bool bOnce = false; 350cdf0e10cSrcweir 351cdf0e10cSrcweir void SdModule::GetState(SfxItemSet& rItemSet) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir // Autopilot waehrend der Praesentation disablen 354cdf0e10cSrcweir if (rItemSet.GetItemState(SID_SD_AUTOPILOT) != SFX_ITEM_UNKNOWN) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir if (!SvtModuleOptions().IsImpress()) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir rItemSet.DisableItem(SID_SD_AUTOPILOT); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir else 361cdf0e10cSrcweir { 362cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 363cdf0e10cSrcweir if (pDocShell) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 366cdf0e10cSrcweir if (pViewShell) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir rItemSet.DisableItem(SID_SD_AUTOPILOT); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir } 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_METRIC ) ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() ); 380cdf0e10cSrcweir if(pDocSh) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir DocumentType eDocType = pDocSh->GetDoc()->GetDocumentType(); 383cdf0e10cSrcweir 384cdf0e10cSrcweir SdOptions* pOptions = GetSdOptions(eDocType); 385cdf0e10cSrcweir rItemSet.Put( SfxUInt16Item( SID_ATTR_METRIC, pOptions->GetMetric() ) ); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir // der Status von SID_OPENDOC wird von der Basisklasse bestimmt 390cdf0e10cSrcweir if (rItemSet.GetItemState(SID_OPENDOC) != SFX_ITEM_UNKNOWN) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir const SfxPoolItem* pItem = SFX_APP()->GetSlotState(SID_OPENDOC, SFX_APP()->GetInterface()); 393cdf0e10cSrcweir if (pItem) 394cdf0e10cSrcweir rItemSet.Put(*pItem); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir // der Status von SID_OPENHYPERLINK wird von der Basisklasse bestimmt 398cdf0e10cSrcweir if (rItemSet.GetItemState(SID_OPENHYPERLINK) != SFX_ITEM_UNKNOWN) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir const SfxPoolItem* pItem = SFX_APP()->GetSlotState(SID_OPENHYPERLINK, SFX_APP()->GetInterface()); 401cdf0e10cSrcweir if (pItem) 402cdf0e10cSrcweir rItemSet.Put(*pItem); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_AUTOSPELL_CHECK ) ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = 408cdf0e10cSrcweir PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 409cdf0e10cSrcweir if( pDocSh ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir SdDrawDocument* pDoc = pDocSh->GetDoc(); 412cdf0e10cSrcweir rItemSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, pDoc->GetOnlineSpell() ) ); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_LANGUAGE ) ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 419cdf0e10cSrcweir if( pDocSh ) 420cdf0e10cSrcweir rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE ), SID_ATTR_LANGUAGE ) ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE ) ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 426cdf0e10cSrcweir if( pDocSh ) 427cdf0e10cSrcweir rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CJK ), SID_ATTR_CHAR_CJK_LANGUAGE ) ); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE ) ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 433cdf0e10cSrcweir if( pDocSh ) 434cdf0e10cSrcweir rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CTL ), SID_ATTR_CHAR_CTL_LANGUAGE ) ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir if ( !bOnce ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 440cdf0e10cSrcweir if( pDocShell ) // Impress or Draw ? 441cdf0e10cSrcweir { 442cdf0e10cSrcweir ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 443cdf0e10cSrcweir 444cdf0e10cSrcweir if( pViewShell && (pDocShell->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir // add our event listener as soon as possible 447cdf0e10cSrcweir Application::AddEventListener( LINK( this, SdModule, EventListenerHdl ) ); 448cdf0e10cSrcweir bOnce = true; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir IMPL_LINK( SdModule, EventListenerHdl, VclSimpleEvent*, pEvent ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir if( pEvent && (pEvent->GetId() == VCLEVENT_WINDOW_COMMAND) && static_cast<VclWindowEvent*>(pEvent)->GetData() ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir const CommandEvent& rEvent = *(const CommandEvent*)static_cast<VclWindowEvent*>(pEvent)->GetData(); 459cdf0e10cSrcweir 460cdf0e10cSrcweir if( rEvent.GetCommand() == COMMAND_MEDIA ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir switch( rEvent.GetMediaCommand() ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir case MEDIA_COMMAND_PLAY: 465cdf0e10cSrcweir { 466cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 467cdf0e10cSrcweir if( pDocShell ) // Impress or Draw ? 468cdf0e10cSrcweir { 469cdf0e10cSrcweir ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 470cdf0e10cSrcweir 471cdf0e10cSrcweir // #i97925# start the presentation if and only if an Impress document is focused 472cdf0e10cSrcweir if( pViewShell && (pDocShell->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ) 473cdf0e10cSrcweir pViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir } 476cdf0e10cSrcweir break; 477cdf0e10cSrcweir 478cdf0e10cSrcweir default: 479cdf0e10cSrcweir break; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir } 482cdf0e10cSrcweir } 483cdf0e10cSrcweir return 0; 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir 487cdf0e10cSrcweir void SdModule::AddSummaryPage (SfxViewFrame* pViewFrame, SdDrawDocument* pDocument) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir if( !pViewFrame || !pViewFrame->GetDispatcher() || !pDocument ) 490cdf0e10cSrcweir return; 491cdf0e10cSrcweir 492cdf0e10cSrcweir pViewFrame->GetDispatcher()->Execute(SID_SUMMARY_PAGE, 493cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); 494cdf0e10cSrcweir 495cdf0e10cSrcweir OSL_ASSERT (pDocument!=NULL); 496cdf0e10cSrcweir 497cdf0e10cSrcweir sal_Int32 nPageCount = pDocument->GetSdPageCount (PK_STANDARD); 498cdf0e10cSrcweir 499cdf0e10cSrcweir // We need at least two pages: the summary page and one to use as 500cdf0e10cSrcweir // template to take the transition parameters from. 501cdf0e10cSrcweir if (nPageCount >= 2) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir // Get a page from which to retrieve the transition parameters. 504cdf0e10cSrcweir SdPage* pTemplatePage = pDocument->GetSdPage (0, PK_STANDARD); 505cdf0e10cSrcweir OSL_ASSERT (pTemplatePage!=NULL); 506cdf0e10cSrcweir 507cdf0e10cSrcweir // The summary page, if it exists, is the last page. 508cdf0e10cSrcweir SdPage* pSummaryPage = pDocument->GetSdPage ( 509cdf0e10cSrcweir (sal_uInt16)nPageCount-1, PK_STANDARD); 510cdf0e10cSrcweir OSL_ASSERT (pSummaryPage!=NULL); 511cdf0e10cSrcweir 512cdf0e10cSrcweir // Take the change mode of the template page as indication of the 513cdf0e10cSrcweir // document's kiosk mode. 514cdf0e10cSrcweir pSummaryPage->setTransitionDuration(pTemplatePage->getTransitionDuration()); 515cdf0e10cSrcweir pSummaryPage->SetPresChange(pTemplatePage->GetPresChange()); 516cdf0e10cSrcweir pSummaryPage->SetTime(pTemplatePage->GetTime()); 517cdf0e10cSrcweir pSummaryPage->SetSound(pTemplatePage->IsSoundOn()); 518cdf0e10cSrcweir pSummaryPage->SetSoundFile(pTemplatePage->GetSoundFile()); 519cdf0e10cSrcweir pSummaryPage->setTransitionType(pTemplatePage->getTransitionType()); 520cdf0e10cSrcweir pSummaryPage->setTransitionSubtype(pTemplatePage->getTransitionSubtype()); 521cdf0e10cSrcweir pSummaryPage->setTransitionDirection(pTemplatePage->getTransitionDirection()); 522cdf0e10cSrcweir pSummaryPage->setTransitionFadeColor(pTemplatePage->getTransitionFadeColor()); 523cdf0e10cSrcweir pSummaryPage->setTransitionDuration(pTemplatePage->getTransitionDuration()); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir SfxFrame* SdModule::CreateFromTemplate( const String& rTemplatePath, const Reference< XFrame >& i_rFrame ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir SfxFrame* pFrame = 0; 530cdf0e10cSrcweir 531cdf0e10cSrcweir SfxObjectShellLock xDocShell; 532cdf0e10cSrcweir 533cdf0e10cSrcweir SfxItemSet* pSet = new SfxAllItemSet( SFX_APP()->GetPool() ); 534cdf0e10cSrcweir pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); 535cdf0e10cSrcweir 536cdf0e10cSrcweir sal_uLong lErr = SFX_APP()->LoadTemplate( xDocShell, rTemplatePath, sal_True, pSet ); 537cdf0e10cSrcweir 538cdf0e10cSrcweir SfxObjectShell* pDocShell = xDocShell; 539cdf0e10cSrcweir 540cdf0e10cSrcweir if( lErr ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir ErrorHandler::HandleError(lErr); 543cdf0e10cSrcweir } 544cdf0e10cSrcweir else if( pDocShell ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir SfxViewFrame* pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pDocShell, i_rFrame ); 547cdf0e10cSrcweir OSL_ENSURE( pViewFrame, "SdModule::CreateFromTemplate: no view frame - was the document really loaded?" ); 548cdf0e10cSrcweir pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir return pFrame; 552cdf0e10cSrcweir 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir SfxFrame* SdModule::ExecuteNewDocument( SfxRequest& rReq ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir SfxFrame* pFrame = 0; 558cdf0e10cSrcweir if ( SvtModuleOptions().IsImpress() ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir Reference< XFrame > xTargetFrame; 561cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pFrmItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False); 562cdf0e10cSrcweir if ( pFrmItem ) 563cdf0e10cSrcweir xTargetFrame = pFrmItem->GetFrame(); 564cdf0e10cSrcweir 565cdf0e10cSrcweir bool bMakeLayoutVisible = false; 566cdf0e10cSrcweir SfxViewFrame* pViewFrame = NULL; 567cdf0e10cSrcweir 568cdf0e10cSrcweir SdOptions* pOpt = GetSdOptions(DOCUMENT_TYPE_IMPRESS); 569cdf0e10cSrcweir bool bStartWithTemplate = pOpt->IsStartWithTemplate(); 570cdf0e10cSrcweir 571cdf0e10cSrcweir bool bNewDocDirect = rReq.GetSlot() == SID_NEWSD; 572cdf0e10cSrcweir if( bNewDocDirect && !bStartWithTemplate ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir //we start without wizard 575cdf0e10cSrcweir 576cdf0e10cSrcweir //check wether we should load a template document 577cdf0e10cSrcweir const ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ); 578cdf0e10cSrcweir String aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) ); 579cdf0e10cSrcweir 580cdf0e10cSrcweir if( aStandardTemplate.Len() > 0 ) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir //load a template document 583cdf0e10cSrcweir pFrame = CreateFromTemplate( aStandardTemplate, xTargetFrame ); 584cdf0e10cSrcweir } 585cdf0e10cSrcweir else 586cdf0e10cSrcweir { 587cdf0e10cSrcweir //create an empty document 588cdf0e10cSrcweir pFrame = CreateEmptyDocument( DOCUMENT_TYPE_IMPRESS, xTargetFrame ); 589cdf0e10cSrcweir bMakeLayoutVisible = true; 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir else 593cdf0e10cSrcweir { 594cdf0e10cSrcweir SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 595cdf0e10cSrcweir std::auto_ptr< AbstractAssistentDlg > pPilotDlg( pFact ? pFact->CreateAssistentDlg( NULL, !bNewDocDirect ) : 0 ); 596cdf0e10cSrcweir 597cdf0e10cSrcweir // Open the Pilot 598cdf0e10cSrcweir if( pPilotDlg.get() && pPilotDlg->Execute()==RET_OK ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir const String aDocPath( pPilotDlg->GetDocPath()); 601cdf0e10cSrcweir const sal_Bool bIsDocEmpty = pPilotDlg->IsDocEmpty(); 602cdf0e10cSrcweir 603cdf0e10cSrcweir // So that you can open the document without AutoLayout-Dialog 604cdf0e10cSrcweir pOpt->SetStartWithTemplate(sal_False); 605cdf0e10cSrcweir if(bNewDocDirect && !pPilotDlg->GetStartWithFlag()) 606cdf0e10cSrcweir bStartWithTemplate = sal_False; 607cdf0e10cSrcweir 608cdf0e10cSrcweir if( pPilotDlg->GetStartType() == ST_OPEN ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir String aFileToOpen = aDocPath; 611cdf0e10cSrcweir 612cdf0e10cSrcweir DBG_ASSERT( aFileToOpen.Len()!=0, "The autopilot should have asked for a file itself already!" ); 613cdf0e10cSrcweir if(aFileToOpen.Len() != 0) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir const String aPasswrd( pPilotDlg->GetPassword() ); 616cdf0e10cSrcweir 617cdf0e10cSrcweir SfxStringItem aFile( SID_FILE_NAME, aFileToOpen ); 618cdf0e10cSrcweir SfxStringItem aReferer( SID_REFERER, UniString() ); 619cdf0e10cSrcweir SfxStringItem aPassword( SID_PASSWORD, aPasswrd ); 620cdf0e10cSrcweir 621cdf0e10cSrcweir if ( xTargetFrame.is() ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir SfxAllItemSet aSet( *rReq.GetArgs()->GetPool() ); 624cdf0e10cSrcweir aSet.Put( aFile ); 625cdf0e10cSrcweir aSet.Put( aReferer ); 626cdf0e10cSrcweir // Put the password into the request 627cdf0e10cSrcweir // only if it is not empty. 628cdf0e10cSrcweir if (aPasswrd.Len() > 0) 629cdf0e10cSrcweir aSet.Put( aPassword ); 630cdf0e10cSrcweir 631cdf0e10cSrcweir const SfxPoolItem* pRet = SfxFrame::OpenDocumentSynchron( aSet, xTargetFrame ); 632cdf0e10cSrcweir const SfxViewFrameItem* pFrameItem = PTR_CAST( SfxViewFrameItem, pRet ); 633cdf0e10cSrcweir if ( pFrameItem && pFrameItem->GetFrame() ) 634cdf0e10cSrcweir pFrame = &pFrameItem->GetFrame()->GetFrame(); 635cdf0e10cSrcweir } 636cdf0e10cSrcweir else 637cdf0e10cSrcweir { 638cdf0e10cSrcweir SfxRequest aRequest (SID_OPENDOC, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool()); 639cdf0e10cSrcweir aRequest.AppendItem (aFile); 640cdf0e10cSrcweir aRequest.AppendItem (aReferer); 641cdf0e10cSrcweir // Put the password into the request 642cdf0e10cSrcweir // only if it is not empty. 643cdf0e10cSrcweir if (aPasswrd.Len() > 0) 644cdf0e10cSrcweir aRequest.AppendItem (aPassword); 645cdf0e10cSrcweir aRequest.AppendItem (SfxStringItem ( 646cdf0e10cSrcweir SID_TARGETNAME, 647cdf0e10cSrcweir String (RTL_CONSTASCII_USTRINGPARAM ("_default")))); 648cdf0e10cSrcweir try 649cdf0e10cSrcweir { 650cdf0e10cSrcweir const SfxPoolItem* pRet = SFX_APP()->ExecuteSlot (aRequest); 651cdf0e10cSrcweir const SfxViewFrameItem* pFrameItem = PTR_CAST( SfxViewFrameItem, pRet ); 652cdf0e10cSrcweir if ( pFrameItem ) 653cdf0e10cSrcweir pFrame = &pFrameItem->GetFrame()->GetFrame(); 654cdf0e10cSrcweir } 655cdf0e10cSrcweir catch (::com::sun::star::uno::Exception e) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir DBG_ASSERT (sal_False, "caught IllegalArgumentException while loading document from Impress autopilot"); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir } 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir pOpt->SetStartWithTemplate(bStartWithTemplate); 663cdf0e10cSrcweir if(bNewDocDirect && !bStartWithTemplate) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir std::auto_ptr< SfxItemSet > pRet( CreateItemSet( SID_SD_EDITOPTIONS ) ); 666cdf0e10cSrcweir if(pRet.get()) 667cdf0e10cSrcweir ApplyItemSet( SID_SD_EDITOPTIONS, *pRet.get() ); 668cdf0e10cSrcweir 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir else 672cdf0e10cSrcweir { 673cdf0e10cSrcweir SfxObjectShellLock xShell( pPilotDlg->GetDocument() ); 674cdf0e10cSrcweir SfxObjectShell* pShell = xShell; 675cdf0e10cSrcweir if( pShell ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pShell, xTargetFrame ); 678cdf0e10cSrcweir DBG_ASSERT( pViewFrame, "no ViewFrame!!" ); 679cdf0e10cSrcweir pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL; 680cdf0e10cSrcweir 681cdf0e10cSrcweir if(bNewDocDirect && !bStartWithTemplate) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir std::auto_ptr< SfxItemSet > pRet( CreateItemSet( SID_SD_EDITOPTIONS ) ); 684cdf0e10cSrcweir if(pRet.get()) 685cdf0e10cSrcweir ApplyItemSet( SID_SD_EDITOPTIONS, *pRet.get() ); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir if( pShell && pViewFrame ) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = 691cdf0e10cSrcweir PTR_CAST(::sd::DrawDocShell,pShell); 692cdf0e10cSrcweir SdDrawDocument* pDoc = pDocShell->GetDoc(); 693cdf0e10cSrcweir 694cdf0e10cSrcweir ::sd::ViewShellBase* pBase = 695cdf0e10cSrcweir ::sd::ViewShellBase::GetViewShellBase ( 696cdf0e10cSrcweir pViewFrame); 697cdf0e10cSrcweir OSL_ASSERT (pBase!=NULL); 698cdf0e10cSrcweir ::boost::shared_ptr<sd::ViewShell> pViewSh = pBase->GetMainViewShell(); 699cdf0e10cSrcweir SdOptions* pOptions = GetSdOptions(pDoc->GetDocumentType()); 700cdf0e10cSrcweir 701cdf0e10cSrcweir if (pOptions && pViewSh.get()) 702cdf0e10cSrcweir { 703cdf0e10cSrcweir // The AutoPilot-document shall be open without its own options 704cdf0e10cSrcweir ::sd::FrameView* pFrameView = pViewSh->GetFrameView(); 705cdf0e10cSrcweir pFrameView->Update(pOptions); 706cdf0e10cSrcweir pViewSh->ReadFrameViewData(pFrameView); 707cdf0e10cSrcweir } 708cdf0e10cSrcweir 709cdf0e10cSrcweir ChangeMedium( pDocShell, pViewFrame, pPilotDlg->GetOutputMedium() ); 710cdf0e10cSrcweir 711cdf0e10cSrcweir if(pPilotDlg->IsSummary()) 712cdf0e10cSrcweir AddSummaryPage(pViewFrame, pDoc); 713cdf0e10cSrcweir 714cdf0e10cSrcweir // empty document 715cdf0e10cSrcweir if((aDocPath.Len() == 0) && pViewFrame && pViewFrame->GetDispatcher()) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir SfxBoolItem aIsChangedItem(SID_MODIFYPAGE, !bIsDocEmpty); 718cdf0e10cSrcweir SfxUInt32Item eAutoLayout( ID_VAL_WHATLAYOUT, (sal_uInt32) AUTOLAYOUT_TITLE ); 719cdf0e10cSrcweir pViewFrame->GetDispatcher()->Execute(SID_MODIFYPAGE, 720cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aIsChangedItem, &eAutoLayout, 0L); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir // clear document info 724cdf0e10cSrcweir using namespace ::com::sun::star; 725cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 726cdf0e10cSrcweir pDocShell->GetModel(), uno::UNO_QUERY_THROW); 727cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> 728cdf0e10cSrcweir xDocProps(xDPS->getDocumentProperties()); 729cdf0e10cSrcweir DBG_ASSERT(xDocProps.is(), "no DocumentProperties"); 730cdf0e10cSrcweir xDocProps->resetUserData( 731cdf0e10cSrcweir SvtUserOptions().GetFullName() ); 732cdf0e10cSrcweir xDocProps->setTemplateName(xDocProps->getTitle()); 733cdf0e10cSrcweir xDocProps->setTemplateURL(pPilotDlg->GetDocPath()); 734cdf0e10cSrcweir 735cdf0e10cSrcweir pDoc->SetChanged(!bIsDocEmpty); 736cdf0e10cSrcweir 737cdf0e10cSrcweir pDocShell->SetUseUserData(sal_True); 738cdf0e10cSrcweir 739cdf0e10cSrcweir // #94652# clear UNDO stack after autopilot 740cdf0e10cSrcweir pDocShell->ClearUndoBuffer(); 741cdf0e10cSrcweir 742cdf0e10cSrcweir bMakeLayoutVisible = true; 743cdf0e10cSrcweir } 744cdf0e10cSrcweir } 745cdf0e10cSrcweir pOpt->SetStartWithTemplate(bStartWithTemplate); 746cdf0e10cSrcweir } 747cdf0e10cSrcweir } 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir if (bMakeLayoutVisible && pViewFrame!=NULL) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir // Make the layout menu visible in the tool pane. 753cdf0e10cSrcweir ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase(pViewFrame); 754cdf0e10cSrcweir if (pBase != NULL) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir FrameworkHelper::Instance(*pBase)->RequestTaskPanel( 757cdf0e10cSrcweir FrameworkHelper::msLayoutTaskPanelURL); 758cdf0e10cSrcweir } 759cdf0e10cSrcweir } 760cdf0e10cSrcweir } 761cdf0e10cSrcweir 762cdf0e10cSrcweir return pFrame; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir SfxFrame* SdModule::CreateEmptyDocument( DocumentType eDocType, const Reference< XFrame >& i_rFrame ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir SfxFrame* pFrame = 0; 768cdf0e10cSrcweir 769cdf0e10cSrcweir SfxObjectShellLock xDocShell; 770cdf0e10cSrcweir ::sd::DrawDocShell* pNewDocSh; 771cdf0e10cSrcweir xDocShell = pNewDocSh = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD,sal_False,eDocType); 772cdf0e10cSrcweir if(pNewDocSh) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir pNewDocSh->DoInitNew(NULL); 775cdf0e10cSrcweir SdDrawDocument* pDoc = pNewDocSh->GetDoc(); 776cdf0e10cSrcweir if(pDoc) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir pDoc->CreateFirstPages(); 779cdf0e10cSrcweir pDoc->StopWorkStartupDelay(); 780cdf0e10cSrcweir } 781cdf0e10cSrcweir 782cdf0e10cSrcweir SfxViewFrame* pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pNewDocSh, i_rFrame ); 783cdf0e10cSrcweir OSL_ENSURE( pViewFrame, "SdModule::CreateEmptyDocument: no view frame - was the document really loaded?" ); 784cdf0e10cSrcweir pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL; 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir return pFrame; 788cdf0e10cSrcweir } 789cdf0e10cSrcweir 790cdf0e10cSrcweir void SdModule::ChangeMedium( ::sd::DrawDocShell* pDocShell, SfxViewFrame* pViewFrame, const sal_Int32 eMedium ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir if( !pDocShell ) 793cdf0e10cSrcweir return; 794cdf0e10cSrcweir 795cdf0e10cSrcweir SdDrawDocument* pDoc = pDocShell->GetDoc(); 796cdf0e10cSrcweir if( !pDoc ) 797cdf0e10cSrcweir return; 798cdf0e10cSrcweir 799cdf0e10cSrcweir // settings for the Outputmedium 800cdf0e10cSrcweir Size aNewSize; 801cdf0e10cSrcweir sal_uInt32 nLeft = 0; 802cdf0e10cSrcweir sal_uInt32 nRight = 0; 803cdf0e10cSrcweir sal_uInt32 nLower = 0; 804cdf0e10cSrcweir sal_uInt32 nUpper = 0; 805cdf0e10cSrcweir switch(eMedium) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir case OUTPUT_PAGE: 808cdf0e10cSrcweir case OUTPUT_OVERHEAD: 809cdf0e10cSrcweir { 810cdf0e10cSrcweir SfxPrinter* pPrinter = pDocShell->GetPrinter(sal_True); 811cdf0e10cSrcweir 812cdf0e10cSrcweir if( pPrinter && pPrinter->IsValid()) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir // Der Printer gibt leider kein exaktes 815cdf0e10cSrcweir // Format (z.B. A4) zurueck 816cdf0e10cSrcweir Size aSize(pPrinter->GetPaperSize()); 817cdf0e10cSrcweir Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, MAP_100TH_MM, sal_True); 818cdf0e10cSrcweir 819cdf0e10cSrcweir if (ePaper != PAPER_USER) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir // Korrekte Size holen 822cdf0e10cSrcweir aSize = SvxPaperInfo::GetPaperSize(ePaper, MAP_100TH_MM); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir if (aSize.Height() > aSize.Width()) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir // Stets Querformat 828cdf0e10cSrcweir aNewSize.Width() = aSize.Height(); 829cdf0e10cSrcweir aNewSize.Height() = aSize.Width(); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir else 832cdf0e10cSrcweir { 833cdf0e10cSrcweir aNewSize = aSize; 834cdf0e10cSrcweir } 835cdf0e10cSrcweir } 836cdf0e10cSrcweir else 837cdf0e10cSrcweir { 838cdf0e10cSrcweir aNewSize=Size(29700, 21000); 839cdf0e10cSrcweir } 840cdf0e10cSrcweir 841cdf0e10cSrcweir if (eMedium == OUTPUT_PAGE) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir nLeft =1000; 844cdf0e10cSrcweir nRight=1000; 845cdf0e10cSrcweir nUpper=1000; 846cdf0e10cSrcweir nLower=1000; 847cdf0e10cSrcweir } 848cdf0e10cSrcweir else 849cdf0e10cSrcweir { 850cdf0e10cSrcweir nLeft =0; 851cdf0e10cSrcweir nRight=0; 852cdf0e10cSrcweir nUpper=0; 853cdf0e10cSrcweir nLower=0; 854cdf0e10cSrcweir } 855cdf0e10cSrcweir } 856cdf0e10cSrcweir break; 857cdf0e10cSrcweir 858cdf0e10cSrcweir case OUTPUT_SLIDE: 859cdf0e10cSrcweir { 860cdf0e10cSrcweir aNewSize = Size(27000, 18000); 861cdf0e10cSrcweir nLeft =0; 862cdf0e10cSrcweir nRight=0; 863cdf0e10cSrcweir nUpper=0; 864cdf0e10cSrcweir nLower=0; 865cdf0e10cSrcweir } 866cdf0e10cSrcweir break; 867cdf0e10cSrcweir 868cdf0e10cSrcweir case OUTPUT_PRESENTATION: 869cdf0e10cSrcweir { 870cdf0e10cSrcweir aNewSize = Size(28000, 21000); 871cdf0e10cSrcweir nLeft =0; 872cdf0e10cSrcweir nRight=0; 873cdf0e10cSrcweir nUpper=0; 874cdf0e10cSrcweir nLower=0; 875cdf0e10cSrcweir } 876cdf0e10cSrcweir break; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir 879cdf0e10cSrcweir sal_Bool bScaleAll = sal_True; 880cdf0e10cSrcweir sal_uInt16 nPageCnt = pDoc->GetMasterSdPageCount(PK_STANDARD); 881cdf0e10cSrcweir sal_uInt16 i; 882cdf0e10cSrcweir SdPage* pPage; 883cdf0e10cSrcweir 884cdf0e10cSrcweir // master pages first 885cdf0e10cSrcweir for (i = 0; i < nPageCnt; i++) 886cdf0e10cSrcweir { 887cdf0e10cSrcweir pPage = pDoc->GetMasterSdPage(i, PK_STANDARD); 888cdf0e10cSrcweir 889cdf0e10cSrcweir if (pPage) 890cdf0e10cSrcweir { 891cdf0e10cSrcweir if(eMedium != OUTPUT_ORIGINAL) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 894cdf0e10cSrcweir pPage->ScaleObjects(aNewSize, aBorderRect, bScaleAll); 895cdf0e10cSrcweir pPage->SetSize(aNewSize); 896cdf0e10cSrcweir pPage->SetBorder(nLeft, nUpper, nRight, nLower); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir SdPage* pNotesPage = pDoc->GetMasterSdPage(i, PK_NOTES); 899cdf0e10cSrcweir DBG_ASSERT( pNotesPage, "Wrong page ordering!" ); 900cdf0e10cSrcweir if( pNotesPage ) pNotesPage->CreateTitleAndLayout(); 901cdf0e10cSrcweir pPage->CreateTitleAndLayout(); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir } 904cdf0e10cSrcweir 905cdf0e10cSrcweir nPageCnt = pDoc->GetSdPageCount(PK_STANDARD); 906cdf0e10cSrcweir 907cdf0e10cSrcweir // then slides 908cdf0e10cSrcweir for (i = 0; i < nPageCnt; i++) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir pPage = pDoc->GetSdPage(i, PK_STANDARD); 911cdf0e10cSrcweir 912cdf0e10cSrcweir if (pPage) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir if(eMedium != OUTPUT_ORIGINAL) 915cdf0e10cSrcweir { 916cdf0e10cSrcweir Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 917cdf0e10cSrcweir pPage->ScaleObjects(aNewSize, aBorderRect, bScaleAll); 918cdf0e10cSrcweir pPage->SetSize(aNewSize); 919cdf0e10cSrcweir pPage->SetBorder(nLeft, nUpper, nRight, nLower); 920cdf0e10cSrcweir } 921cdf0e10cSrcweir SdPage* pNotesPage = pDoc->GetSdPage(i, PK_NOTES); 922cdf0e10cSrcweir DBG_ASSERT( pNotesPage, "Wrong page ordering!" ); 923cdf0e10cSrcweir if( pNotesPage ) pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() ); 924cdf0e10cSrcweir pPage->SetAutoLayout( pPage->GetAutoLayout() ); 925cdf0e10cSrcweir } 926cdf0e10cSrcweir } 927cdf0e10cSrcweir 928cdf0e10cSrcweir SdPage* pHandoutPage = pDoc->GetSdPage(0, PK_HANDOUT); 929cdf0e10cSrcweir pHandoutPage->CreateTitleAndLayout(sal_True); 930cdf0e10cSrcweir 931cdf0e10cSrcweir if( (eMedium != OUTPUT_ORIGINAL) && pViewFrame && pViewFrame->GetDispatcher()) 932cdf0e10cSrcweir { 933cdf0e10cSrcweir pViewFrame->GetDispatcher()->Execute(SID_SIZE_PAGE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); 934cdf0e10cSrcweir } 935cdf0e10cSrcweir } 936cdf0e10cSrcweir 937cdf0e10cSrcweir 938cdf0e10cSrcweir 939cdf0e10cSrcweir 940cdf0e10cSrcweir //===== OutlineToImpressFinalize ============================================== 941cdf0e10cSrcweir 942cdf0e10cSrcweir namespace { 943cdf0e10cSrcweir 944cdf0e10cSrcweir OutlineToImpressFinalizer::OutlineToImpressFinalizer ( 945cdf0e10cSrcweir ::sd::ViewShellBase& rBase, 946cdf0e10cSrcweir SdDrawDocument& rDocument, 947cdf0e10cSrcweir SvLockBytes& rBytes) 948cdf0e10cSrcweir : mrBase(rBase), 949cdf0e10cSrcweir mrDocument(rDocument), 950cdf0e10cSrcweir mpStream() 951cdf0e10cSrcweir { 952cdf0e10cSrcweir // The given stream has a lifetime shorter than this new 953cdf0e10cSrcweir // OutlineToImpressFinalizer object. Therefore a local copy of the 954cdf0e10cSrcweir // stream is created. 955cdf0e10cSrcweir const SvStream* pStream (rBytes.GetStream()); 956cdf0e10cSrcweir if (pStream != NULL) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir // Create a memory stream and prepare to fill it with the content of 959cdf0e10cSrcweir // the original stream. 960cdf0e10cSrcweir mpStream.reset(new SvMemoryStream()); 961cdf0e10cSrcweir static const sal_Size nBufferSize = 4096; 962cdf0e10cSrcweir ::boost::scoped_array<sal_Int8> pBuffer (new sal_Int8[nBufferSize]); 963cdf0e10cSrcweir 964cdf0e10cSrcweir sal_Size nReadPosition (0); 965cdf0e10cSrcweir bool bLoop (true); 966cdf0e10cSrcweir while (bLoop) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir // Read the next part of the original stream. 969cdf0e10cSrcweir sal_Size nReadByteCount (0); 970cdf0e10cSrcweir const ErrCode nErrorCode ( 971cdf0e10cSrcweir rBytes.ReadAt( 972cdf0e10cSrcweir nReadPosition, 973cdf0e10cSrcweir reinterpret_cast<void*>(pBuffer.get()), 974cdf0e10cSrcweir nBufferSize, 975cdf0e10cSrcweir &nReadByteCount)); 976cdf0e10cSrcweir 977cdf0e10cSrcweir // Check the error code and stop copying the stream data when an 978cdf0e10cSrcweir // error has occured. 979cdf0e10cSrcweir switch (nErrorCode) 980cdf0e10cSrcweir { 981cdf0e10cSrcweir case ERRCODE_NONE: 982cdf0e10cSrcweir if (nReadByteCount == 0) 983cdf0e10cSrcweir bLoop = false; 984cdf0e10cSrcweir break; 985cdf0e10cSrcweir case ERRCODE_IO_PENDING: 986cdf0e10cSrcweir break; 987cdf0e10cSrcweir 988cdf0e10cSrcweir default: 989cdf0e10cSrcweir bLoop = false; 990cdf0e10cSrcweir nReadByteCount = 0; 991cdf0e10cSrcweir break; 992cdf0e10cSrcweir } 993cdf0e10cSrcweir 994cdf0e10cSrcweir // Append the read bytes to the end of the memory stream. 995cdf0e10cSrcweir if (nReadByteCount > 0) 996cdf0e10cSrcweir { 997cdf0e10cSrcweir mpStream->Write(reinterpret_cast<void*>(pBuffer.get()), nReadByteCount); 998cdf0e10cSrcweir nReadPosition += nReadByteCount; 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir // Rewind the memory stream so that in the operator() method its 1003cdf0e10cSrcweir // content is properly read. 1004cdf0e10cSrcweir mpStream->Seek(STREAM_SEEK_TO_BEGIN); 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir void OutlineToImpressFinalizer::operator() (bool) 1012cdf0e10cSrcweir { 1013cdf0e10cSrcweir // Fetch the new outline view shell. 1014cdf0e10cSrcweir ::sd::OutlineViewShell* pOutlineShell 1015cdf0e10cSrcweir = dynamic_cast<sd::OutlineViewShell*>(FrameworkHelper::Instance(mrBase)->GetViewShell(FrameworkHelper::msCenterPaneURL).get()); 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir if (pOutlineShell != NULL && mpStream.get() != NULL) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir sd::OutlineView* pView = static_cast<sd::OutlineView*>(pOutlineShell->GetView()); 1020cdf0e10cSrcweir // mba: the stream can't contain any relative URLs, because we don't 1021cdf0e10cSrcweir // have any information about a BaseURL! 1022cdf0e10cSrcweir if ( pOutlineShell->Read(*mpStream, String(), EE_FORMAT_RTF) == 0 ) 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir /* 1025cdf0e10cSrcweir sd::OutlineViewPageChangesGuard aGuard( pView ); 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir // Remove the first empty pages 1028cdf0e10cSrcweir sal_uInt16 nPageCount = mrDocument.GetPageCount(); 1029cdf0e10cSrcweir mrDocument.RemovePage( --nPageCount ); // notes page 1030cdf0e10cSrcweir mrDocument.RemovePage( --nPageCount ); // standard page 1031cdf0e10cSrcweir */ 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir // Call UpdatePreview once for every slide to resync the 1035cdf0e10cSrcweir // document with the outliner of the OutlineViewShell. 1036cdf0e10cSrcweir sal_uInt16 nPageCount (mrDocument.GetSdPageCount(PK_STANDARD)); 1037cdf0e10cSrcweir for (sal_uInt16 nIndex=0; nIndex<nPageCount; nIndex++) 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir SdPage* pPage = mrDocument.GetSdPage(nIndex, PK_STANDARD); 1040cdf0e10cSrcweir // Make the page the actual page so that the 1041cdf0e10cSrcweir // following UpdatePreview() call accesses the 1042cdf0e10cSrcweir // correct paragraphs. 1043cdf0e10cSrcweir pView->SetActualPage(pPage); 1044cdf0e10cSrcweir pOutlineShell->UpdatePreview(pPage, true); 1045cdf0e10cSrcweir } 1046cdf0e10cSrcweir // Select the first slide. 1047cdf0e10cSrcweir SdPage* pPage = mrDocument.GetSdPage(0, PK_STANDARD); 1048cdf0e10cSrcweir pView->SetActualPage(pPage); 1049cdf0e10cSrcweir pOutlineShell->UpdatePreview(pPage, true); 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir // #97231# Undo-Stack needs to be cleared, else the user may remove the 1054cdf0e10cSrcweir // only drawpage and this is a state we cannot handle ATM. 1055cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = mrDocument.GetDocSh(); 1056cdf0e10cSrcweir if( pDocShell ) 1057cdf0e10cSrcweir pDocShell->ClearUndoBuffer(); 1058cdf0e10cSrcweir } 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir 1061cdf0e10cSrcweir } // end of anonymous namespace 1062