Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "DrawViewShell.hxx"
22 :
23 : #include <svx/svxids.hrc>
24 : #include <svl/aeitem.hxx>
25 : #include <svl/stritem.hxx>
26 : #include <sfx2/docfile.hxx>
27 : #include <svl/intitem.hxx>
28 : #include <sfx2/bindings.hxx>
29 : #include <sfx2/dispatch.hxx>
30 : #include <sfx2/request.hxx>
31 :
32 : #include <sfx2/viewfrm.hxx>
33 :
34 :
35 : #include "app.hrc"
36 :
37 : #include "sdpage.hxx"
38 : #include "drawdoc.hxx"
39 : #include "DrawDocShell.hxx"
40 : #include "slideshow.hxx"
41 : #include "pgjump.hxx"
42 : #include "NavigatorChildWindow.hxx"
43 : #include "navigatr.hxx"
44 : #include "drawview.hxx"
45 :
46 : namespace sd {
47 :
48 : /**
49 : * handle SfxRequests for navigator
50 : */
51 0 : void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
52 : {
53 0 : CheckLineTo (rReq);
54 :
55 0 : sal_uInt16 nSId = rReq.GetSlot();
56 :
57 0 : switch( nSId )
58 : {
59 : case SID_NAVIGATOR_INIT:
60 : {
61 0 : sal_uInt16 nId = SID_NAVIGATOR;
62 0 : SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
63 0 : if( pWindow )
64 : {
65 0 : SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
66 0 : if( pNavWin )
67 0 : pNavWin->InitTreeLB( GetDoc() );
68 : }
69 : }
70 0 : break;
71 :
72 : case SID_NAVIGATOR_PEN:
73 : case SID_NAVIGATOR_PAGE:
74 : case SID_NAVIGATOR_OBJECT:
75 : {
76 0 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
77 0 : if (xSlideshow.is() && xSlideshow->isRunning() )
78 : {
79 0 : xSlideshow->receiveRequest( rReq );
80 : }
81 0 : else if (nSId == SID_NAVIGATOR_PAGE)
82 : {
83 0 : if ( mpDrawView->IsTextEdit() )
84 0 : mpDrawView->SdrEndTextEdit();
85 :
86 0 : const SfxItemSet* pArgs = rReq.GetArgs();
87 : PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
88 0 : Get(SID_NAVIGATOR_PAGE)).GetValue();
89 :
90 0 : switch (eJump)
91 : {
92 : case PAGE_FIRST:
93 : {
94 : // jump to first page
95 0 : SwitchPage(0);
96 : }
97 0 : break;
98 :
99 : case PAGE_LAST:
100 : {
101 : // jumpt to last page
102 0 : SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
103 : }
104 0 : break;
105 :
106 : case PAGE_NEXT:
107 : {
108 : // jump to next page
109 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
110 :
111 0 : if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
112 : {
113 0 : SwitchPage(nSdPage + 1);
114 : }
115 : }
116 0 : break;
117 :
118 : case PAGE_PREVIOUS:
119 : {
120 : // jump to previous page
121 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
122 :
123 0 : if (nSdPage > 0)
124 : {
125 0 : SwitchPage(nSdPage - 1);
126 : }
127 : }
128 0 : break;
129 :
130 : case PAGE_NONE:
131 0 : break;
132 : }
133 : }
134 0 : else if (nSId == SID_NAVIGATOR_OBJECT)
135 : {
136 0 : OUString aBookmarkStr("#");
137 0 : const SfxItemSet* pArgs = rReq.GetArgs();
138 : OUString aTarget = ((SfxStringItem&) pArgs->
139 0 : Get(SID_NAVIGATOR_OBJECT)).GetValue();
140 0 : aBookmarkStr += aTarget;
141 0 : SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
142 0 : SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
143 0 : SfxViewFrame* pFrame = GetViewFrame();
144 0 : SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
145 0 : SfxBoolItem aBrowseItem(SID_BROWSE, true);
146 : pFrame->GetDispatcher()->
147 : Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
148 0 : &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
149 : }
150 :
151 0 : SfxBindings& rBindings = GetViewFrame()->GetBindings();
152 0 : rBindings.Invalidate( SID_NAVIGATOR_STATE );
153 0 : rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
154 : }
155 0 : break;
156 :
157 : default:
158 0 : break;
159 : }
160 0 : }
161 :
162 :
163 0 : void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
164 : {
165 0 : sal_uInt32 nState = NAVSTATE_NONE;
166 0 : sal_uInt16 nCurrentPage = 0;
167 0 : sal_uInt16 nFirstPage = 0;
168 : sal_uInt16 nLastPage;
169 0 : sal_Bool bEndless = sal_False;
170 0 : OUString aPageName;
171 :
172 0 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
173 0 : if( xSlideshow.is() && xSlideshow->isRunning() )
174 : {
175 : // pen activated?
176 0 : nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
177 :
178 0 : nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
179 0 : nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
180 0 : nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
181 0 : bEndless = xSlideshow->isEndless();
182 :
183 : // Get the page for the current page number.
184 0 : SdPage* pPage = 0;
185 0 : if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
186 0 : pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
187 :
188 0 : if(pPage)
189 0 : aPageName = pPage->GetName();
190 : }
191 : else
192 : {
193 0 : nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
194 :
195 0 : if (mpActualPage != NULL)
196 : {
197 0 : nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
198 0 : aPageName = mpActualPage->GetName();
199 : }
200 0 : nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
201 : }
202 :
203 : // first page / previous page
204 0 : if( nCurrentPage == nFirstPage )
205 : {
206 0 : nState |= NAVBTN_FIRST_DISABLED;
207 0 : if( !bEndless )
208 0 : nState |= NAVBTN_PREV_DISABLED;
209 : else
210 0 : nState |= NAVBTN_PREV_ENABLED;
211 : }
212 : else
213 : {
214 0 : nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
215 : }
216 :
217 : // last page / next page
218 0 : if( nCurrentPage == nLastPage )
219 : {
220 0 : nState |= NAVBTN_LAST_DISABLED;
221 0 : if( !bEndless )
222 0 : nState |= NAVBTN_NEXT_DISABLED;
223 : else
224 0 : nState |= NAVBTN_NEXT_ENABLED;
225 : }
226 : else
227 : {
228 0 : nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
229 : }
230 :
231 0 : rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
232 0 : rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
233 0 : }
234 :
235 : } // end of namespace sd
236 :
237 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|