1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "impviewframe.hxx" 32*cdf0e10cSrcweir #include "statcach.hxx" 33*cdf0e10cSrcweir #include "sfx2/viewfac.hxx" 34*cdf0e10cSrcweir #include "workwin.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "sfx2/app.hxx" 37*cdf0e10cSrcweir #include "sfx2/bindings.hxx" 38*cdf0e10cSrcweir #include "sfx2/ctrlitem.hxx" 39*cdf0e10cSrcweir #include "sfx2/dispatch.hxx" 40*cdf0e10cSrcweir #include "sfx2/docfac.hxx" 41*cdf0e10cSrcweir #include "sfx2/docfile.hxx" 42*cdf0e10cSrcweir #include "sfx2/objitem.hxx" 43*cdf0e10cSrcweir #include "sfx2/objsh.hxx" 44*cdf0e10cSrcweir #include "sfx2/request.hxx" 45*cdf0e10cSrcweir #include "sfx2/viewfrm.hxx" 46*cdf0e10cSrcweir #include "sfx2/viewsh.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 53*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 54*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 55*cdf0e10cSrcweir #include <svtools/asynclink.hxx> 56*cdf0e10cSrcweir #include <svl/eitem.hxx> 57*cdf0e10cSrcweir #include <svl/intitem.hxx> 58*cdf0e10cSrcweir #include <svl/rectitem.hxx> 59*cdf0e10cSrcweir #include <svl/stritem.hxx> 60*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 61*cdf0e10cSrcweir #include <tools/urlobj.hxx> 62*cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 63*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 64*cdf0e10cSrcweir #include <vcl/window.hxx> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 68*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 69*cdf0e10cSrcweir using namespace ::com::sun::star::util; 70*cdf0e10cSrcweir using namespace ::com::sun::star::container; 71*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 72*cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 73*cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir //------------------------------------------------------------------------ 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir static ::rtl::OUString GetModuleName_Impl( const ::rtl::OUString& sDocService ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xMM( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), uno::UNO_QUERY ); 80*cdf0e10cSrcweir ::rtl::OUString sVar; 81*cdf0e10cSrcweir if ( !xMM.is() ) 82*cdf0e10cSrcweir return sVar; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir try 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir ::comphelper::NamedValueCollection aAnalyzer( xMM->getByName( sDocService ) ); 87*cdf0e10cSrcweir sVar = aAnalyzer.getOrDefault( "ooSetupFactoryUIName", ::rtl::OUString() ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir catch( uno::Exception& ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir sVar = ::rtl::OUString(); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir return sVar; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir //-------------------------------------------------------------------- 98*cdf0e10cSrcweir void SfxFrameViewWindow_Impl::StateChanged( StateChangedType nStateChange ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_INITSHOW ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir SfxObjectShell* pDoc = pFrame->GetObjectShell(); 103*cdf0e10cSrcweir if ( pDoc && !pFrame->IsVisible() ) 104*cdf0e10cSrcweir pFrame->Show(); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir pFrame->Resize(); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir else 109*cdf0e10cSrcweir Window::StateChanged( nStateChange ); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void SfxFrameViewWindow_Impl::Resize() 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) 115*cdf0e10cSrcweir pFrame->Resize(); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir static String _getTabString() 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir String result; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir Reference < XMaterialHolder > xHolder( 123*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 124*cdf0e10cSrcweir DEFINE_CONST_UNICODE("com.sun.star.tab.tabreg") ), UNO_QUERY ); 125*cdf0e10cSrcweir if (xHolder.is()) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir rtl::OUString aTabString; 128*cdf0e10cSrcweir Sequence< NamedValue > sMaterial; 129*cdf0e10cSrcweir if (xHolder->getMaterial() >>= sMaterial) { 130*cdf0e10cSrcweir for (int i=0; i < sMaterial.getLength(); i++) { 131*cdf0e10cSrcweir if ((sMaterial[i].Name.equalsAscii("title")) && 132*cdf0e10cSrcweir (sMaterial[i].Value >>= aTabString)) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir result += ' '; 135*cdf0e10cSrcweir result += String(aTabString); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir return result; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //======================================================================== 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //-------------------------------------------------------------------- 146*cdf0e10cSrcweir String SfxViewFrame::UpdateTitle() 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir /* [Beschreibung] 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir Mit dieser Methode kann der SfxViewFrame gezwungen werden, sich sofort 151*cdf0e10cSrcweir den neuen Titel vom der <SfxObjectShell> zu besorgen. 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir [Anmerkung] 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener 156*cdf0e10cSrcweir zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren 157*cdf0e10cSrcweir m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxTopViewFrames) 158*cdf0e10cSrcweir jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung 159*cdf0e10cSrcweir nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden. 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir [Beispiel] 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if ( rHint.IsA(TYPE(SfxSimpleHint)) ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir switch( ( (SfxSimpleHint&) rHint ).GetId() ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir case SFX_HINT_TITLECHANGED: 171*cdf0e10cSrcweir for ( SfxViewFrame *pTop = SfxViewFrame::GetFirst( this ); 172*cdf0e10cSrcweir pTop; 173*cdf0e10cSrcweir pTop = SfxViewFrame::GetNext( this ); 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir pTop->UpdateTitle(); 176*cdf0e10cSrcweir ... pTop->GetName() ... 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir ... 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir */ 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewFrame, 0); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir const SfxObjectFactory &rFact = GetObjectShell()->GetFactory(); 189*cdf0e10cSrcweir pImp->aFactoryName = String::CreateFromAscii( rFact.GetShortName() ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir SfxObjectShell *pObjSh = GetObjectShell(); 192*cdf0e10cSrcweir if ( !pObjSh ) 193*cdf0e10cSrcweir return String(); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) 196*cdf0e10cSrcweir // // kein UpdateTitle mit Embedded-ObjectShell 197*cdf0e10cSrcweir // return String(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir const SfxMedium *pMedium = pObjSh->GetMedium(); 200*cdf0e10cSrcweir String aURL; 201*cdf0e10cSrcweir GetFrame(); // -Wall required?? 202*cdf0e10cSrcweir if ( pObjSh->HasName() ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir INetURLObject aTmp( pMedium->GetName() ); 205*cdf0e10cSrcweir aURL = aTmp.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir if ( aURL != pImp->aActualURL ) 209*cdf0e10cSrcweir // URL hat sich ge"andert 210*cdf0e10cSrcweir pImp->aActualURL = aURL; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // gibt es noch eine weitere View? 213*cdf0e10cSrcweir sal_uInt16 nViews=0; 214*cdf0e10cSrcweir for ( SfxViewFrame *pView= GetFirst(pObjSh); 215*cdf0e10cSrcweir pView && nViews<2; 216*cdf0e10cSrcweir pView = GetNext(*pView,pObjSh) ) 217*cdf0e10cSrcweir if ( ( pView->GetFrameType() & SFXFRAME_HASTITLE ) && 218*cdf0e10cSrcweir !IsDowning_Impl()) 219*cdf0e10cSrcweir nViews++; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // Titel des Fensters 222*cdf0e10cSrcweir String aTitle; 223*cdf0e10cSrcweir if ( nViews == 2 || pImp->nDocViewNo > 1 ) 224*cdf0e10cSrcweir // dann die Nummer dranh"angen 225*cdf0e10cSrcweir aTitle = pObjSh->UpdateTitle( NULL, pImp->nDocViewNo ); 226*cdf0e10cSrcweir else 227*cdf0e10cSrcweir aTitle = pObjSh->UpdateTitle(); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir // Name des SbxObjects 230*cdf0e10cSrcweir String aSbxName = pObjSh->SfxShell::GetName(); 231*cdf0e10cSrcweir if ( IsVisible() ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir aSbxName += ':'; 234*cdf0e10cSrcweir aSbxName += String::CreateFromInt32(pImp->nDocViewNo); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir SetName( aSbxName ); 238*cdf0e10cSrcweir pImp->aFrameTitle = aTitle; 239*cdf0e10cSrcweir GetBindings().Invalidate( SID_FRAMETITLE ); 240*cdf0e10cSrcweir GetBindings().Invalidate( SID_CURRENT_URL ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir ::rtl::OUString aProductName; 243*cdf0e10cSrcweir ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir aTitle += String::CreateFromAscii( " - " ); 246*cdf0e10cSrcweir aTitle += String(aProductName); 247*cdf0e10cSrcweir aTitle += ' '; 248*cdf0e10cSrcweir ::rtl::OUString aDocServiceName( GetObjectShell()->GetFactory().GetDocumentServiceName() ); 249*cdf0e10cSrcweir aTitle += String( GetModuleName_Impl( aDocServiceName ) ); 250*cdf0e10cSrcweir #ifdef DBG_UTIL 251*cdf0e10cSrcweir ::rtl::OUString aDefault; 252*cdf0e10cSrcweir aTitle += DEFINE_CONST_UNICODE(" ["); 253*cdf0e10cSrcweir String aVerId( utl::Bootstrap::getBuildIdData( aDefault )); 254*cdf0e10cSrcweir aTitle += aVerId; 255*cdf0e10cSrcweir aTitle += ']'; 256*cdf0e10cSrcweir #endif 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // append TAB string if available 259*cdf0e10cSrcweir aTitle += _getTabString(); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir GetBindings().Invalidate( SID_NEWDOCDIRECT ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir /* AS_TITLE 264*cdf0e10cSrcweir Window* pWindow = GetFrame()->GetTopWindow_Impl(); 265*cdf0e10cSrcweir if ( pWindow && pWindow->GetText() != aTitle ) 266*cdf0e10cSrcweir pWindow->SetText( aTitle ); 267*cdf0e10cSrcweir */ 268*cdf0e10cSrcweir return aTitle; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir void SfxViewFrame::Exec_Impl(SfxRequest &rReq ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir // Wenn gerade die Shells ausgetauscht werden... 274*cdf0e10cSrcweir if ( !GetObjectShell() || !GetViewShell() ) 275*cdf0e10cSrcweir return; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir switch ( rReq.GetSlot() ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir case SID_SHOWPOPUPS : 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, SID_SHOWPOPUPS, sal_False); 282*cdf0e10cSrcweir sal_Bool bShow = pShowItem ? pShowItem->GetValue() : sal_True; 283*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pIdItem, SfxUInt16Item, SID_CONFIGITEMID, sal_False); 284*cdf0e10cSrcweir sal_uInt16 nId = pIdItem ? pIdItem->GetValue() : 0; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // ausfuehren 287*cdf0e10cSrcweir SfxWorkWindow *pWorkWin = GetFrame().GetWorkWindow_Impl(); 288*cdf0e10cSrcweir if ( bShow ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir // Zuerst die Floats auch anzeigbar machen 291*cdf0e10cSrcweir pWorkWin->MakeChildsVisible_Impl( bShow ); 292*cdf0e10cSrcweir GetDispatcher()->Update_Impl( sal_True ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // Dann anzeigen 295*cdf0e10cSrcweir GetBindings().HidePopups( !bShow ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir else 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir // Alles hiden 300*cdf0e10cSrcweir SfxBindings *pBind = &GetBindings(); 301*cdf0e10cSrcweir while ( pBind ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir pBind->HidePopupCtrls_Impl( !bShow ); 304*cdf0e10cSrcweir pBind = pBind->GetSubBindings_Impl(); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir pWorkWin->HidePopups_Impl( !bShow, sal_True, nId ); 308*cdf0e10cSrcweir pWorkWin->MakeChildsVisible_Impl( bShow ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir Invalidate( rReq.GetSlot() ); 312*cdf0e10cSrcweir rReq.Done(); 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir case SID_ACTIVATE: 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir MakeActive_Impl( sal_True ); 319*cdf0e10cSrcweir rReq.SetReturnValue( SfxObjectItem( 0, this ) ); 320*cdf0e10cSrcweir break; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir case SID_NEWDOCDIRECT : 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pFactoryItem, SfxStringItem, SID_NEWDOCDIRECT, sal_False); 326*cdf0e10cSrcweir String aFactName; 327*cdf0e10cSrcweir if ( pFactoryItem ) 328*cdf0e10cSrcweir aFactName = pFactoryItem->GetValue(); 329*cdf0e10cSrcweir else if ( pImp->aFactoryName.Len() ) 330*cdf0e10cSrcweir aFactName = pImp->aFactoryName; 331*cdf0e10cSrcweir else 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir DBG_ERROR("Missing argument!"); 334*cdf0e10cSrcweir break; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() ); 338*cdf0e10cSrcweir String aFact = String::CreateFromAscii("private:factory/"); 339*cdf0e10cSrcweir aFact += aFactName; 340*cdf0e10cSrcweir aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); 341*cdf0e10cSrcweir aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) ); 342*cdf0e10cSrcweir aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_blank" ) ) ); 343*cdf0e10cSrcweir SFX_APP()->ExecuteSlot( aReq ); 344*cdf0e10cSrcweir const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() ); 345*cdf0e10cSrcweir if ( pItem ) 346*cdf0e10cSrcweir rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) ); 347*cdf0e10cSrcweir break; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir case SID_CLOSEWIN: 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir // disable CloseWin, if frame is not a task 353*cdf0e10cSrcweir Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY ); 354*cdf0e10cSrcweir if ( !xTask.is() ) 355*cdf0e10cSrcweir break; 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir if ( GetViewShell()->PrepareClose() ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir // weitere Views auf dasselbe Doc? 360*cdf0e10cSrcweir SfxObjectShell *pDocSh = GetObjectShell(); 361*cdf0e10cSrcweir int bOther = sal_False; 362*cdf0e10cSrcweir for ( const SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh ); 363*cdf0e10cSrcweir !bOther && pFrame; 364*cdf0e10cSrcweir pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) ) 365*cdf0e10cSrcweir bOther = (pFrame != this); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir // Doc braucht nur gefragt zu werden, wenn keine weitere View 368*cdf0e10cSrcweir sal_Bool bClosed = sal_False; 369*cdf0e10cSrcweir sal_Bool bUI = sal_True; 370*cdf0e10cSrcweir if ( ( bOther || pDocSh->PrepareClose( bUI ) ) ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir if ( !bOther ) 373*cdf0e10cSrcweir pDocSh->SetModified( sal_False ); 374*cdf0e10cSrcweir rReq.Done(); // unbedingt vor Close() rufen! 375*cdf0e10cSrcweir bClosed = sal_False; 376*cdf0e10cSrcweir try 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir xTask->close(sal_True); 379*cdf0e10cSrcweir bClosed = sal_True; 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir catch( CloseVetoException& ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir bClosed = sal_False; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bClosed )); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir return; 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir rReq.Done(); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir void SfxViewFrame::GetState_Impl( SfxItemSet &rSet ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir SfxObjectShell *pDocSh = GetObjectShell(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir if ( !pDocSh ) 401*cdf0e10cSrcweir return; 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir const sal_uInt16 *pRanges = rSet.GetRanges(); 404*cdf0e10cSrcweir DBG_ASSERT(pRanges, "Set ohne Bereich"); 405*cdf0e10cSrcweir while ( *pRanges ) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir switch(nWhich) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir case SID_NEWDOCDIRECT : 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir if ( pImp->aFactoryName.Len() ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir String aFact = String::CreateFromAscii("private:factory/"); 416*cdf0e10cSrcweir aFact += pImp->aFactoryName; 417*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aFact ) ); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir break; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir case SID_NEWWINDOW: 423*cdf0e10cSrcweir rSet.DisableItem(nWhich); 424*cdf0e10cSrcweir break; 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir case SID_CLOSEWIN: 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir // disable CloseWin, if frame is not a task 429*cdf0e10cSrcweir Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY ); 430*cdf0e10cSrcweir if ( !xTask.is() ) 431*cdf0e10cSrcweir rSet.DisableItem(nWhich); 432*cdf0e10cSrcweir break; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir case SID_SHOWPOPUPS : 436*cdf0e10cSrcweir break; 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir case SID_OBJECT: 439*cdf0e10cSrcweir if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir uno::Any aAny; 442*cdf0e10cSrcweir aAny <<= GetViewShell()->GetVerbs(); 443*cdf0e10cSrcweir rSet.Put( SfxUnoAnyItem( sal_uInt16( SID_OBJECT ), aAny ) ); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir else 446*cdf0e10cSrcweir rSet.DisableItem( SID_OBJECT ); 447*cdf0e10cSrcweir break; 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir default: 450*cdf0e10cSrcweir DBG_ERROR( "invalid message-id" ); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir ++pRanges; 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void SfxViewFrame::INetExecute_Impl( SfxRequest &rRequest ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir sal_uInt16 nSlotId = rRequest.GetSlot(); 460*cdf0e10cSrcweir switch( nSlotId ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir case SID_BROWSE_FORWARD: 463*cdf0e10cSrcweir case SID_BROWSE_BACKWARD: 464*cdf0e10cSrcweir OSL_ENSURE( false, "SfxViewFrame::INetExecute_Impl: SID_BROWSE_FORWARD/BACKWARD are dead!" ); 465*cdf0e10cSrcweir break; 466*cdf0e10cSrcweir case SID_CREATELINK: 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir /*! (pb) we need new implementation to create a link 469*cdf0e10cSrcweir */ 470*cdf0e10cSrcweir break; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir case SID_FOCUSURLBOX: 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir SfxStateCache *pCache = GetBindings().GetAnyStateCache_Impl( SID_OPENURL ); 475*cdf0e10cSrcweir if( pCache ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir SfxControllerItem* pCtrl = pCache->GetItemLink(); 478*cdf0e10cSrcweir while( pCtrl ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir pCtrl->StateChanged( SID_FOCUSURLBOX, SFX_ITEM_UNKNOWN, 0 ); 481*cdf0e10cSrcweir pCtrl = pCtrl->GetItemLink(); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir // Recording 488*cdf0e10cSrcweir rRequest.Done(); 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir void SfxViewFrame::INetState_Impl( SfxItemSet &rItemSet ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir rItemSet.DisableItem( SID_BROWSE_FORWARD ); 494*cdf0e10cSrcweir rItemSet.DisableItem( SID_BROWSE_BACKWARD ); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir // Add/SaveToBookmark bei BASIC-IDE, QUERY-EDITOR etc. disablen 497*cdf0e10cSrcweir SfxObjectShell *pDocSh = GetObjectShell(); 498*cdf0e10cSrcweir sal_Bool bPseudo = pDocSh && !( pDocSh->GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC ); 499*cdf0e10cSrcweir sal_Bool bEmbedded = pDocSh && pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED; 500*cdf0e10cSrcweir if ( !pDocSh || bPseudo || bEmbedded || !pDocSh->HasName() ) 501*cdf0e10cSrcweir rItemSet.DisableItem( SID_CREATELINK ); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir void SfxViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir GetViewShell()->SetZoomFactor( rZoomX, rZoomY ); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir void SfxViewFrame::Activate( sal_Bool bMDI ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir DBG_ASSERT(GetViewShell(), "Keine Shell"); 512*cdf0e10cSrcweir if ( bMDI ) 513*cdf0e10cSrcweir pImp->bActive = sal_True; 514*cdf0e10cSrcweir //(mba): hier evtl. wie in Beanframe NotifyEvent ?! 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir void SfxViewFrame::Deactivate( sal_Bool bMDI ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir DBG_ASSERT(GetViewShell(), "Keine Shell"); 520*cdf0e10cSrcweir if ( bMDI ) 521*cdf0e10cSrcweir pImp->bActive = sal_False; 522*cdf0e10cSrcweir //(mba): hier evtl. wie in Beanframe NotifyEvent ?! 523*cdf0e10cSrcweir } 524