1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviewsd.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
37 #include <svx/svxids.hrc>
39 #include <svtools/aeitem.hxx>
40 #include <svtools/stritem.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <svtools/intitem.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/request.hxx>
47 #include <sfx2/viewfrm.hxx>
53 #include "drawdoc.hxx"
54 #include "DrawDocShell.hxx"
55 #include "slideshow.hxx"
57 #include "NavigatorChildWindow.hxx"
58 #ifndef SD_NAVIGATION_HXX
59 #include "navigatr.hxx"
61 #include "drawview.hxx"
62 #include "slideshow.hxx"
66 /*************************************************************************
68 |* SfxRequests fuer Navigator bearbeiten
70 \************************************************************************/
72 void DrawViewShell::ExecNavigatorWin( SfxRequest
& rReq
)
76 USHORT nSId
= rReq
.GetSlot();
80 case SID_NAVIGATOR_INIT
:
82 USHORT nId
= SID_NAVIGATOR
;
83 SfxChildWindow
* pWindow
= GetViewFrame()->GetChildWindow( nId
);
86 SdNavigatorWin
* pNavWin
= (SdNavigatorWin
*)( pWindow
->GetContextWindow( SD_MOD() ) );
88 pNavWin
->InitTreeLB( GetDoc() );
93 case SID_NAVIGATOR_PEN
:
94 case SID_NAVIGATOR_PAGE
:
95 case SID_NAVIGATOR_OBJECT
:
97 rtl::Reference
< SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
98 if (xSlideshow
.is() && xSlideshow
->isRunning() )
100 xSlideshow
->receiveRequest( rReq
);
102 else if (nSId
== SID_NAVIGATOR_PAGE
)
104 if ( mpDrawView
->IsTextEdit() )
105 mpDrawView
->SdrEndTextEdit();
107 const SfxItemSet
* pArgs
= rReq
.GetArgs();
108 PageJump eJump
= (PageJump
)((SfxAllEnumItem
&) pArgs
->
109 Get(SID_NAVIGATOR_PAGE
)).GetValue();
115 // Sprung zu erster Seite
122 // Sprung zu letzter Seite
123 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1);
129 // Sprung zu naechster Seite
130 USHORT nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
132 if (nSdPage
< GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1)
134 SwitchPage(nSdPage
+ 1);
141 // Sprung zu vorheriger Seite
142 USHORT nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
146 SwitchPage(nSdPage
- 1);
155 else if (nSId
== SID_NAVIGATOR_OBJECT
)
158 aBookmarkStr
+= sal_Unicode( '#' );
159 const SfxItemSet
* pArgs
= rReq
.GetArgs();
160 String aTarget
= ((SfxStringItem
&) pArgs
->
161 Get(SID_NAVIGATOR_OBJECT
)).GetValue();
162 aBookmarkStr
+= aTarget
;
163 SfxStringItem
aStrItem(SID_FILE_NAME
, aBookmarkStr
);
164 SfxStringItem
aReferer(SID_REFERER
, GetDocSh()->GetMedium()->GetName());
165 SfxViewFrame
* pFrame
= GetViewFrame();
166 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
167 SfxBoolItem
aBrowseItem(SID_BROWSE
, TRUE
);
168 pFrame
->GetDispatcher()->
169 Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
170 &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
, 0L);
173 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
174 rBindings
.Invalidate( SID_NAVIGATOR_STATE
);
175 rBindings
.Invalidate( SID_NAVIGATOR_PAGENAME
);
184 /*************************************************************************
186 |* Statuswerte fuer Navigator zurueckgeben
188 \************************************************************************/
190 void DrawViewShell::GetNavigatorWinState( SfxItemSet
& rSet
)
192 UINT32 nState
= NAVSTATE_NONE
;
193 USHORT nCurrentPage
= 0;
194 USHORT nFirstPage
= 0;
196 BOOL bEndless
= FALSE
;
199 rtl::Reference
< SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
200 if( xSlideshow
.is() && xSlideshow
->isRunning() )
203 nState
|= xSlideshow
->isDrawingPossible() ? NAVBTN_PEN_CHECKED
: NAVBTN_PEN_UNCHECKED
;
205 nCurrentPage
= (USHORT
)xSlideshow
->getCurrentPageNumber();
206 nFirstPage
= (USHORT
)xSlideshow
->getFirstPageNumber();
207 nLastPage
= (USHORT
)xSlideshow
->getLastPageNumber();
208 bEndless
= xSlideshow
->isEndless();
210 // Get the page for the current page number.
212 if( nCurrentPage
< GetDoc()->GetSdPageCount( PK_STANDARD
) )
213 pPage
= GetDoc()->GetSdPage (nCurrentPage
, PK_STANDARD
);
216 aPageName
= pPage
->GetName();
220 nState
|= NAVBTN_PEN_DISABLED
| NAVTLB_UPDATE
;
222 if (mpActualPage
!= NULL
)
224 nCurrentPage
= ( mpActualPage
->GetPageNum() - 1 ) / 2;
225 aPageName
= mpActualPage
->GetName();
227 nLastPage
= GetDoc()->GetSdPageCount( mePageKind
) - 1;
230 // erste Seite / vorherige Seite
231 if( nCurrentPage
== nFirstPage
)
233 nState
|= NAVBTN_FIRST_DISABLED
;
235 nState
|= NAVBTN_PREV_DISABLED
;
237 nState
|= NAVBTN_PREV_ENABLED
;
241 nState
|= NAVBTN_FIRST_ENABLED
| NAVBTN_PREV_ENABLED
;
244 // letzte Seite / naechste Seite
245 if( nCurrentPage
== nLastPage
)
247 nState
|= NAVBTN_LAST_DISABLED
;
249 nState
|= NAVBTN_NEXT_DISABLED
;
251 nState
|= NAVBTN_NEXT_ENABLED
;
255 nState
|= NAVBTN_LAST_ENABLED
| NAVBTN_NEXT_ENABLED
;
258 rSet
.Put( SfxUInt32Item( SID_NAVIGATOR_STATE
, nState
) );
259 rSet
.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME
, aPageName
) );
262 } // end of namespace sd