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 : #include "DrawViewShell.hxx"
21 :
22 : #include <svx/svxids.hrc>
23 : #include <svl/aeitem.hxx>
24 : #include <svl/stritem.hxx>
25 : #include <sfx2/docfile.hxx>
26 : #include <svl/intitem.hxx>
27 : #include <sfx2/bindings.hxx>
28 : #include <sfx2/dispatch.hxx>
29 : #include <sfx2/request.hxx>
30 :
31 : #include <sfx2/viewfrm.hxx>
32 :
33 : #include "app.hrc"
34 :
35 : #include "sdpage.hxx"
36 : #include "drawdoc.hxx"
37 : #include "DrawDocShell.hxx"
38 : #include "slideshow.hxx"
39 : #include "pgjump.hxx"
40 : #include "NavigatorChildWindow.hxx"
41 : #include "navigatr.hxx"
42 : #include "drawview.hxx"
43 :
44 : namespace sd {
45 :
46 : /**
47 : * handle SfxRequests for navigator
48 : */
49 252 : void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
50 : {
51 252 : CheckLineTo (rReq);
52 :
53 252 : sal_uInt16 nSId = rReq.GetSlot();
54 :
55 252 : switch( nSId )
56 : {
57 : case SID_NAVIGATOR_INIT:
58 : {
59 252 : sal_uInt16 nId = SID_NAVIGATOR;
60 252 : SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
61 252 : if( pWindow )
62 : {
63 8 : SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
64 8 : if( pNavWin )
65 8 : pNavWin->InitTreeLB( GetDoc() );
66 : }
67 : }
68 252 : break;
69 :
70 : case SID_NAVIGATOR_PEN:
71 : case SID_NAVIGATOR_PAGE:
72 : case SID_NAVIGATOR_OBJECT:
73 : {
74 0 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
75 0 : if (xSlideshow.is() && xSlideshow->isRunning() )
76 : {
77 0 : xSlideshow->receiveRequest( rReq );
78 : }
79 0 : else if (nSId == SID_NAVIGATOR_PAGE)
80 : {
81 0 : if ( mpDrawView->IsTextEdit() )
82 0 : mpDrawView->SdrEndTextEdit();
83 :
84 0 : const SfxItemSet* pArgs = rReq.GetArgs();
85 : PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
86 0 : Get(SID_NAVIGATOR_PAGE)).GetValue();
87 :
88 0 : switch (eJump)
89 : {
90 : case PAGE_FIRST:
91 : {
92 : // jump to first page
93 0 : SwitchPage(0);
94 : }
95 0 : break;
96 :
97 : case PAGE_LAST:
98 : {
99 : // jumpt to last page
100 0 : SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
101 : }
102 0 : break;
103 :
104 : case PAGE_NEXT:
105 : {
106 : // jump to next page
107 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
108 :
109 0 : if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
110 : {
111 0 : SwitchPage(nSdPage + 1);
112 : }
113 : }
114 0 : break;
115 :
116 : case PAGE_PREVIOUS:
117 : {
118 : // jump to previous page
119 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
120 :
121 0 : if (nSdPage > 0)
122 : {
123 0 : SwitchPage(nSdPage - 1);
124 : }
125 : }
126 0 : break;
127 :
128 : case PAGE_NONE:
129 0 : break;
130 : }
131 : }
132 0 : else if (nSId == SID_NAVIGATOR_OBJECT)
133 : {
134 0 : OUString aBookmarkStr("#");
135 0 : const SfxItemSet* pArgs = rReq.GetArgs();
136 : OUString aTarget = ((SfxStringItem&) pArgs->
137 0 : Get(SID_NAVIGATOR_OBJECT)).GetValue();
138 0 : aBookmarkStr += aTarget;
139 0 : SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
140 0 : SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
141 0 : SfxViewFrame* pFrame = GetViewFrame();
142 0 : SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
143 0 : SfxBoolItem aBrowseItem(SID_BROWSE, true);
144 : pFrame->GetDispatcher()->
145 : Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
146 0 : &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
147 : }
148 :
149 0 : SfxBindings& rBindings = GetViewFrame()->GetBindings();
150 0 : rBindings.Invalidate( SID_NAVIGATOR_STATE );
151 0 : rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
152 : }
153 0 : break;
154 :
155 : default:
156 0 : break;
157 : }
158 252 : }
159 :
160 256 : void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
161 : {
162 256 : sal_uInt32 nState = NAVSTATE_NONE;
163 256 : sal_uInt16 nCurrentPage = 0;
164 256 : sal_uInt16 nFirstPage = 0;
165 : sal_uInt16 nLastPage;
166 256 : bool bEndless = false;
167 256 : OUString aPageName;
168 :
169 512 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
170 256 : if( xSlideshow.is() && xSlideshow->isRunning() )
171 : {
172 : // pen activated?
173 0 : nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
174 :
175 0 : nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
176 0 : nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
177 0 : nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
178 0 : bEndless = xSlideshow->isEndless();
179 :
180 : // Get the page for the current page number.
181 0 : SdPage* pPage = 0;
182 0 : if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
183 0 : pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
184 :
185 0 : if(pPage)
186 0 : aPageName = pPage->GetName();
187 : }
188 : else
189 : {
190 256 : nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
191 :
192 256 : if (mpActualPage != NULL)
193 : {
194 256 : nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
195 256 : aPageName = mpActualPage->GetName();
196 : }
197 256 : nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
198 : }
199 :
200 : // first page / previous page
201 256 : if( nCurrentPage == nFirstPage )
202 : {
203 256 : nState |= NAVBTN_FIRST_DISABLED;
204 256 : if( !bEndless )
205 256 : nState |= NAVBTN_PREV_DISABLED;
206 : else
207 0 : nState |= NAVBTN_PREV_ENABLED;
208 : }
209 : else
210 : {
211 0 : nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
212 : }
213 :
214 : // last page / next page
215 256 : if( nCurrentPage == nLastPage )
216 : {
217 256 : nState |= NAVBTN_LAST_DISABLED;
218 256 : if( !bEndless )
219 256 : nState |= NAVBTN_NEXT_DISABLED;
220 : else
221 0 : nState |= NAVBTN_NEXT_ENABLED;
222 : }
223 : else
224 : {
225 0 : nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
226 : }
227 :
228 256 : rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
229 512 : rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
230 256 : }
231 :
232 114 : } // end of namespace sd
233 :
234 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|