1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "precompiled_sd.hxx"
25 
26 #include "ImpressViewShellBase.hxx"
27 
28 #include "DrawDocShell.hxx"
29 #include "sdresid.hxx"
30 #include "strings.hrc"
31 #include "app.hrc"
32 #include "framework/FrameworkHelper.hxx"
33 #include "framework/ImpressModule.hxx"
34 #include "MasterPageObserver.hxx"
35 #include <sfx2/request.hxx>
36 
37 namespace sd {
38 
39 TYPEINIT1(ImpressViewShellBase, ViewShellBase);
40 
41 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
42 // new ImpressViewShellBase object has been constructed.
43 
44 SfxViewFactory* ImpressViewShellBase::pFactory;
CreateInstance(SfxViewFrame * pFrame,SfxViewShell * pOldView)45 SfxViewShell* __EXPORT ImpressViewShellBase::CreateInstance (
46     SfxViewFrame *pFrame, SfxViewShell *pOldView)
47 {
48     ImpressViewShellBase* pBase = new ImpressViewShellBase(pFrame, pOldView);
49     pBase->LateInit(::rtl::OUString());
50     return pBase;
51 }
RegisterFactory(sal_uInt16 nPrio)52 void ImpressViewShellBase::RegisterFactory( sal_uInt16 nPrio )
53 {
54     pFactory = new SfxViewFactory(
55         &CreateInstance,&InitFactory,nPrio,"Default");
56     InitFactory();
57 }
InitFactory()58 void ImpressViewShellBase::InitFactory()
59 {
60 	SFX_VIEW_REGISTRATION(DrawDocShell);
61 }
62 
63 
64 
65 
66 
67 
68 
69 
ImpressViewShellBase(SfxViewFrame * _pFrame,SfxViewShell * pOldShell)70 ImpressViewShellBase::ImpressViewShellBase (
71     SfxViewFrame* _pFrame,
72     SfxViewShell* pOldShell)
73     : ViewShellBase (_pFrame, pOldShell)
74 {
75     MasterPageObserver::Instance().RegisterDocument (*GetDocShell()->GetDoc());
76 }
77 
78 
79 
80 
~ImpressViewShellBase(void)81 ImpressViewShellBase::~ImpressViewShellBase (void)
82 {
83     MasterPageObserver::Instance().UnregisterDocument (*GetDocShell()->GetDoc());
84 }
85 
86 
87 
88 
Execute(SfxRequest & rRequest)89 void ImpressViewShellBase::Execute (SfxRequest& rRequest)
90 {
91 	sal_uInt16 nSlotId = rRequest.GetSlot();
92 
93 	switch (nSlotId)
94     {
95         case SID_LEFT_PANE_DRAW:
96             // Prevent a Draw-only slots from being executed.
97             rRequest.Cancel();
98             break;
99 
100         default:
101             // The remaining requests are forwarded to our base class.
102             ViewShellBase::Execute(rRequest);
103             break;
104     }
105 }
106 
107 
108 
109 
InitializeFramework(void)110 void ImpressViewShellBase::InitializeFramework (void)
111 {
112     ::com::sun::star::uno::Reference<com::sun::star::frame::XController>
113         xController (GetController());
114     sd::framework::ImpressModule::Initialize(xController);
115 }
116 
117 } // end of namespace sd
118 
119