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