Branch data 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 : : |*
50 : : |* SfxRequests fuer Navigator bearbeiten
51 : : |*
52 : : \************************************************************************/
53 : :
54 : 264 : void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
55 : : {
56 : 264 : CheckLineTo (rReq);
57 : :
58 : 264 : sal_uInt16 nSId = rReq.GetSlot();
59 : :
60 [ + - - ]: 264 : switch( nSId )
61 : : {
62 : : case SID_NAVIGATOR_INIT:
63 : : {
64 : 264 : sal_uInt16 nId = SID_NAVIGATOR;
65 : 264 : SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
66 [ - + ]: 264 : if( pWindow )
67 : : {
68 : 0 : SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
69 [ # # ]: 0 : if( pNavWin )
70 : 0 : pNavWin->InitTreeLB( GetDoc() );
71 : : }
72 : : }
73 : 264 : break;
74 : :
75 : : case SID_NAVIGATOR_PEN:
76 : : case SID_NAVIGATOR_PAGE:
77 : : case SID_NAVIGATOR_OBJECT:
78 : : {
79 [ # # ][ # # ]: 0 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
80 [ # # ][ # # ]: 0 : if (xSlideshow.is() && xSlideshow->isRunning() )
[ # # ][ # # ]
81 : : {
82 [ # # ]: 0 : xSlideshow->receiveRequest( rReq );
83 : : }
84 [ # # ]: 0 : else if (nSId == SID_NAVIGATOR_PAGE)
85 : : {
86 [ # # ][ # # ]: 0 : if ( mpDrawView->IsTextEdit() )
87 [ # # ]: 0 : mpDrawView->SdrEndTextEdit();
88 : :
89 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
90 : : PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
91 [ # # ]: 0 : Get(SID_NAVIGATOR_PAGE)).GetValue();
92 : :
93 [ # # # # : 0 : switch (eJump)
# # ]
94 : : {
95 : : case PAGE_FIRST:
96 : : {
97 : : // Sprung zu erster Seite
98 [ # # ]: 0 : SwitchPage(0);
99 : : }
100 : 0 : break;
101 : :
102 : : case PAGE_LAST:
103 : : {
104 : : // Sprung zu letzter Seite
105 [ # # ][ # # ]: 0 : SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
[ # # ]
106 : : }
107 : 0 : break;
108 : :
109 : : case PAGE_NEXT:
110 : : {
111 : : // Sprung zu naechster Seite
112 [ # # ]: 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
113 : :
114 [ # # ][ # # ]: 0 : if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
[ # # ]
115 : : {
116 [ # # ]: 0 : SwitchPage(nSdPage + 1);
117 : : }
118 : : }
119 : 0 : break;
120 : :
121 : : case PAGE_PREVIOUS:
122 : : {
123 : : // Sprung zu vorheriger Seite
124 [ # # ]: 0 : sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
125 : :
126 [ # # ]: 0 : if (nSdPage > 0)
127 : : {
128 [ # # ]: 0 : SwitchPage(nSdPage - 1);
129 : : }
130 : : }
131 : 0 : break;
132 : :
133 : : case PAGE_NONE:
134 : 0 : break;
135 : : }
136 : : }
137 [ # # ]: 0 : else if (nSId == SID_NAVIGATOR_OBJECT)
138 : : {
139 [ # # ]: 0 : String aBookmarkStr;
140 [ # # ]: 0 : aBookmarkStr += sal_Unicode( '#' );
141 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
142 : : String aTarget = ((SfxStringItem&) pArgs->
143 [ # # ][ # # ]: 0 : Get(SID_NAVIGATOR_OBJECT)).GetValue();
144 [ # # ]: 0 : aBookmarkStr += aTarget;
145 [ # # ]: 0 : SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
146 [ # # ][ # # ]: 0 : SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
[ # # ][ # # ]
[ # # ]
147 [ # # ]: 0 : SfxViewFrame* pFrame = GetViewFrame();
148 [ # # ]: 0 : SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
149 [ # # ]: 0 : SfxBoolItem aBrowseItem(SID_BROWSE, sal_True);
150 : : pFrame->GetDispatcher()->
151 : : Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
152 [ # # ][ # # ]: 0 : &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
153 : : }
154 : :
155 [ # # ]: 0 : SfxBindings& rBindings = GetViewFrame()->GetBindings();
156 [ # # ]: 0 : rBindings.Invalidate( SID_NAVIGATOR_STATE );
157 [ # # ]: 0 : rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
158 : : }
159 : 0 : break;
160 : :
161 : : default:
162 : 0 : break;
163 : : }
164 : 264 : }
165 : :
166 : : /*************************************************************************
167 : : |*
168 : : |* Statuswerte fuer Navigator zurueckgeben
169 : : |*
170 : : \************************************************************************/
171 : :
172 : 264 : void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
173 : : {
174 : 264 : sal_uInt32 nState = NAVSTATE_NONE;
175 : 264 : sal_uInt16 nCurrentPage = 0;
176 : 264 : sal_uInt16 nFirstPage = 0;
177 : : sal_uInt16 nLastPage;
178 : 264 : sal_Bool bEndless = sal_False;
179 [ + - ]: 264 : String aPageName;
180 : :
181 [ + - ][ + - ]: 264 : rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
182 [ + - ][ + - ]: 264 : if( xSlideshow.is() && xSlideshow->isRunning() )
[ - + ][ - + ]
183 : : {
184 : : // pen activated?
185 [ # # ][ # # ]: 0 : nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
186 : :
187 [ # # ]: 0 : nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
188 [ # # ]: 0 : nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
189 [ # # ]: 0 : nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
190 [ # # ]: 0 : bEndless = xSlideshow->isEndless();
191 : :
192 : : // Get the page for the current page number.
193 : 0 : SdPage* pPage = 0;
194 [ # # ][ # # ]: 0 : if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
[ # # ]
195 [ # # ][ # # ]: 0 : pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
196 : :
197 [ # # ]: 0 : if(pPage)
198 [ # # ][ # # ]: 0 : aPageName = pPage->GetName();
199 : : }
200 : : else
201 : : {
202 : 264 : nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
203 : :
204 [ + - ]: 264 : if (mpActualPage != NULL)
205 : : {
206 [ + - ]: 264 : nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
207 [ + - ][ + - ]: 264 : aPageName = mpActualPage->GetName();
208 : : }
209 [ + - ][ + - ]: 264 : nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
210 : : }
211 : :
212 : : // erste Seite / vorherige Seite
213 [ + - ]: 264 : if( nCurrentPage == nFirstPage )
214 : : {
215 : 264 : nState |= NAVBTN_FIRST_DISABLED;
216 [ + - ]: 264 : if( !bEndless )
217 : 264 : nState |= NAVBTN_PREV_DISABLED;
218 : : else
219 : 0 : nState |= NAVBTN_PREV_ENABLED;
220 : : }
221 : : else
222 : : {
223 : 0 : nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
224 : : }
225 : :
226 : : // letzte Seite / naechste Seite
227 [ + + ]: 264 : if( nCurrentPage == nLastPage )
228 : : {
229 : 261 : nState |= NAVBTN_LAST_DISABLED;
230 [ + - ]: 261 : if( !bEndless )
231 : 261 : nState |= NAVBTN_NEXT_DISABLED;
232 : : else
233 : 0 : nState |= NAVBTN_NEXT_ENABLED;
234 : : }
235 : : else
236 : : {
237 : 3 : nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
238 : : }
239 : :
240 [ + - ][ + - ]: 264 : rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
[ + - ]
241 [ + - ][ + - ]: 264 : rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
[ + - ][ + - ]
242 : 264 : }
243 : :
244 : : } // end of namespace sd
245 : :
246 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|