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 .
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>
38 #include "drawdoc.hxx"
39 #include "DrawDocShell.hxx"
40 #include "slideshow.hxx"
42 #include "NavigatorChildWindow.hxx"
43 #include "navigatr.hxx"
44 #include "drawview.hxx"
49 * handle SfxRequests for navigator
51 void DrawViewShell::ExecNavigatorWin( SfxRequest
& rReq
)
55 sal_uInt16 nSId
= rReq
.GetSlot();
59 case SID_NAVIGATOR_INIT
:
61 sal_uInt16 nId
= SID_NAVIGATOR
;
62 SfxChildWindow
* pWindow
= GetViewFrame()->GetChildWindow( nId
);
65 SdNavigatorWin
* pNavWin
= (SdNavigatorWin
*)( pWindow
->GetContextWindow( SD_MOD() ) );
67 pNavWin
->InitTreeLB( GetDoc() );
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();
101 // jumpt to last page
102 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1);
109 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
111 if (nSdPage
< GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1)
113 SwitchPage(nSdPage
+ 1);
120 // jump to previous page
121 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
125 SwitchPage(nSdPage
- 1);
134 else if (nSId
== SID_NAVIGATOR_OBJECT
)
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
);
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
;
173 rtl::Reference
< SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
174 if( xSlideshow
.is() && xSlideshow
->isRunning() )
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.
186 if( nCurrentPage
< GetDoc()->GetSdPageCount( PK_STANDARD
) )
187 pPage
= GetDoc()->GetSdPage (nCurrentPage
, PK_STANDARD
);
190 aPageName
= pPage
->GetName();
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
;
209 nState
|= NAVBTN_PREV_DISABLED
;
211 nState
|= NAVBTN_PREV_ENABLED
;
215 nState
|= NAVBTN_FIRST_ENABLED
| NAVBTN_PREV_ENABLED
;
218 // last page / next page
219 if( nCurrentPage
== nLastPage
)
221 nState
|= NAVBTN_LAST_DISABLED
;
223 nState
|= NAVBTN_NEXT_DISABLED
;
225 nState
|= NAVBTN_NEXT_ENABLED
;
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: */