1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include "DrawViewShell.hxx"
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>
31 #include <sfx2/viewfrm.hxx>
36 #include "drawdoc.hxx"
37 #include "DrawDocShell.hxx"
38 #include "slideshow.hxx"
40 #include "NavigatorChildWindow.hxx"
41 #include "navigatr.hxx"
42 #include "drawview.hxx"
47 * handle SfxRequests for navigator
49 void DrawViewShell::ExecNavigatorWin( SfxRequest
& rReq
)
53 sal_uInt16 nSId
= rReq
.GetSlot();
57 case SID_NAVIGATOR_INIT
:
59 sal_uInt16 nId
= SID_NAVIGATOR
;
60 SfxChildWindow
* pWindow
= GetViewFrame()->GetChildWindow( nId
);
63 SdNavigatorWin
* pNavWin
= static_cast<SdNavigatorWin
*>( pWindow
->GetContextWindow( SD_MOD() ) );
65 pNavWin
->InitTreeLB( GetDoc() );
70 case SID_NAVIGATOR_PEN
:
71 case SID_NAVIGATOR_PAGE
:
72 case SID_NAVIGATOR_OBJECT
:
74 rtl::Reference
< SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
75 if (xSlideshow
.is() && xSlideshow
->isRunning() )
77 xSlideshow
->receiveRequest( rReq
);
79 else if (nSId
== SID_NAVIGATOR_PAGE
)
81 if ( mpDrawView
->IsTextEdit() )
82 mpDrawView
->SdrEndTextEdit();
84 const SfxItemSet
* pArgs
= rReq
.GetArgs();
85 PageJump eJump
= (PageJump
)static_cast<const SfxAllEnumItem
&>( pArgs
->
86 Get(SID_NAVIGATOR_PAGE
)).GetValue();
100 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1);
107 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
109 if (nSdPage
< GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1)
111 SwitchPage(nSdPage
+ 1);
118 // jump to previous page
119 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
123 SwitchPage(nSdPage
- 1);
132 else if (nSId
== SID_NAVIGATOR_OBJECT
)
134 OUString
aBookmarkStr("#");
135 const SfxItemSet
* pArgs
= rReq
.GetArgs();
136 OUString aTarget
= static_cast<const SfxStringItem
&>( pArgs
->
137 Get(SID_NAVIGATOR_OBJECT
)).GetValue();
138 aBookmarkStr
+= aTarget
;
139 SfxStringItem
aStrItem(SID_FILE_NAME
, aBookmarkStr
);
140 SfxStringItem
aReferer(SID_REFERER
, GetDocSh()->GetMedium()->GetName());
141 SfxViewFrame
* pFrame
= GetViewFrame();
142 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
143 SfxBoolItem
aBrowseItem(SID_BROWSE
, true);
144 pFrame
->GetDispatcher()->
145 Execute(SID_OPENDOC
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
146 &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
, 0L);
149 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
150 rBindings
.Invalidate( SID_NAVIGATOR_STATE
);
151 rBindings
.Invalidate( SID_NAVIGATOR_PAGENAME
);
160 void DrawViewShell::GetNavigatorWinState( SfxItemSet
& rSet
)
162 sal_uInt32 nState
= NAVSTATE_NONE
;
163 sal_uInt16 nCurrentPage
= 0;
164 sal_uInt16 nFirstPage
= 0;
165 sal_uInt16 nLastPage
;
166 bool bEndless
= false;
169 rtl::Reference
< SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
170 if( xSlideshow
.is() && xSlideshow
->isRunning() )
173 nState
|= xSlideshow
->isDrawingPossible() ? NAVBTN_PEN_CHECKED
: NAVBTN_PEN_UNCHECKED
;
175 nCurrentPage
= (sal_uInt16
)xSlideshow
->getCurrentPageNumber();
176 nFirstPage
= (sal_uInt16
)xSlideshow
->getFirstPageNumber();
177 nLastPage
= (sal_uInt16
)xSlideshow
->getLastPageNumber();
178 bEndless
= xSlideshow
->isEndless();
180 // Get the page for the current page number.
182 if( nCurrentPage
< GetDoc()->GetSdPageCount( PK_STANDARD
) )
183 pPage
= GetDoc()->GetSdPage (nCurrentPage
, PK_STANDARD
);
186 aPageName
= pPage
->GetName();
190 nState
|= NAVBTN_PEN_DISABLED
| NAVTLB_UPDATE
;
192 if (mpActualPage
!= NULL
)
194 nCurrentPage
= ( mpActualPage
->GetPageNum() - 1 ) / 2;
195 aPageName
= mpActualPage
->GetName();
197 nLastPage
= GetDoc()->GetSdPageCount( mePageKind
) - 1;
200 // first page / previous page
201 if( nCurrentPage
== nFirstPage
)
203 nState
|= NAVBTN_FIRST_DISABLED
;
205 nState
|= NAVBTN_PREV_DISABLED
;
207 nState
|= NAVBTN_PREV_ENABLED
;
211 nState
|= NAVBTN_FIRST_ENABLED
| NAVBTN_PREV_ENABLED
;
214 // last page / next page
215 if( nCurrentPage
== nLastPage
)
217 nState
|= NAVBTN_LAST_DISABLED
;
219 nState
|= NAVBTN_NEXT_DISABLED
;
221 nState
|= NAVBTN_NEXT_ENABLED
;
225 nState
|= NAVBTN_LAST_ENABLED
| NAVBTN_NEXT_ENABLED
;
228 rSet
.Put( SfxUInt32Item( SID_NAVIGATOR_STATE
, nState
) );
229 rSet
.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME
, aPageName
) );
232 } // end of namespace sd
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */