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