fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / drviewsd.cxx
bloba3c52e34ec381d3ca54b247d5840904fa4f75389
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "DrawViewShell.hxx"
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>
32 #include <sfx2/viewfrm.hxx>
35 #include "app.hrc"
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"
46 namespace sd {
48 /**
49 * handle SfxRequests for navigator
51 void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
53 CheckLineTo (rReq);
55 sal_uInt16 nSId = rReq.GetSlot();
57 switch( nSId )
59 case SID_NAVIGATOR_INIT:
61 sal_uInt16 nId = SID_NAVIGATOR;
62 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
63 if( pWindow )
65 SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
66 if( pNavWin )
67 pNavWin->InitTreeLB( GetDoc() );
70 break;
72 case SID_NAVIGATOR_PEN:
73 case SID_NAVIGATOR_PAGE:
74 case SID_NAVIGATOR_OBJECT:
76 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
77 if (xSlideshow.is() && xSlideshow->isRunning() )
79 xSlideshow->receiveRequest( rReq );
81 else if (nSId == SID_NAVIGATOR_PAGE)
83 if ( mpDrawView->IsTextEdit() )
84 mpDrawView->SdrEndTextEdit();
86 const SfxItemSet* pArgs = rReq.GetArgs();
87 PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
88 Get(SID_NAVIGATOR_PAGE)).GetValue();
90 switch (eJump)
92 case PAGE_FIRST:
94 // jump to first page
95 SwitchPage(0);
97 break;
99 case PAGE_LAST:
101 // jumpt to last page
102 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
104 break;
106 case PAGE_NEXT:
108 // jump to next page
109 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
111 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
113 SwitchPage(nSdPage + 1);
116 break;
118 case PAGE_PREVIOUS:
120 // jump to previous page
121 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
123 if (nSdPage > 0)
125 SwitchPage(nSdPage - 1);
128 break;
130 case PAGE_NONE:
131 break;
134 else if (nSId == SID_NAVIGATOR_OBJECT)
136 String aBookmarkStr;
137 aBookmarkStr += sal_Unicode( '#' );
138 const SfxItemSet* pArgs = rReq.GetArgs();
139 String aTarget = ((SfxStringItem&) pArgs->
140 Get(SID_NAVIGATOR_OBJECT)).GetValue();
141 aBookmarkStr += aTarget;
142 SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
143 SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
144 SfxViewFrame* pFrame = GetViewFrame();
145 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
146 SfxBoolItem aBrowseItem(SID_BROWSE, sal_True);
147 pFrame->GetDispatcher()->
148 Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
149 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
152 SfxBindings& rBindings = GetViewFrame()->GetBindings();
153 rBindings.Invalidate( SID_NAVIGATOR_STATE );
154 rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
156 break;
158 default:
159 break;
164 void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
166 sal_uInt32 nState = NAVSTATE_NONE;
167 sal_uInt16 nCurrentPage = 0;
168 sal_uInt16 nFirstPage = 0;
169 sal_uInt16 nLastPage;
170 sal_Bool bEndless = sal_False;
171 String aPageName;
173 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
174 if( xSlideshow.is() && xSlideshow->isRunning() )
176 // pen activated?
177 nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
179 nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
180 nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
181 nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
182 bEndless = xSlideshow->isEndless();
184 // Get the page for the current page number.
185 SdPage* pPage = 0;
186 if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
187 pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
189 if(pPage)
190 aPageName = pPage->GetName();
192 else
194 nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
196 if (mpActualPage != NULL)
198 nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
199 aPageName = mpActualPage->GetName();
201 nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
204 // first page / previous page
205 if( nCurrentPage == nFirstPage )
207 nState |= NAVBTN_FIRST_DISABLED;
208 if( !bEndless )
209 nState |= NAVBTN_PREV_DISABLED;
210 else
211 nState |= NAVBTN_PREV_ENABLED;
213 else
215 nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
218 // last page / next page
219 if( nCurrentPage == nLastPage )
221 nState |= NAVBTN_LAST_DISABLED;
222 if( !bEndless )
223 nState |= NAVBTN_NEXT_DISABLED;
224 else
225 nState |= NAVBTN_NEXT_ENABLED;
227 else
229 nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
232 rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
233 rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
236 } // end of namespace sd
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */