1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "DrawViewShell.hxx"
#include <svx/svxids.hrc>
#include <svl/aeitem.hxx>
#include <svl/stritem.hxx>
#include <sfx2/docfile.hxx>
#include <svl/intitem.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include "app.hrc"
#include "sdpage.hxx"
#include "drawdoc.hxx"
#include "DrawDocShell.hxx"
#include "slideshow.hxx"
#include "pgjump.hxx"
#include "NavigatorChildWindow.hxx"
#include "navigatr.hxx"
#include "drawview.hxx"
namespace sd {
/**
* handle SfxRequests for navigator
*/
void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
{
CheckLineTo (rReq);
sal_uInt16 nSId = rReq.GetSlot();
switch( nSId )
{
case SID_NAVIGATOR_INIT:
{
sal_uInt16 nId = SID_NAVIGATOR;
SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
if( pWindow )
{
SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
if( pNavWin )
pNavWin->InitTreeLB( GetDoc() );
}
}
break;
case SID_NAVIGATOR_PEN:
case SID_NAVIGATOR_PAGE:
case SID_NAVIGATOR_OBJECT:
{
rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if (xSlideshow.is() && xSlideshow->isRunning() )
{
xSlideshow->receiveRequest( rReq );
}
else if (nSId == SID_NAVIGATOR_PAGE)
{
if ( mpDrawView->IsTextEdit() )
mpDrawView->SdrEndTextEdit();
const SfxItemSet* pArgs = rReq.GetArgs();
PageJump eJump = (PageJump)static_cast<const SfxAllEnumItem&>( pArgs->
Get(SID_NAVIGATOR_PAGE)).GetValue();
switch (eJump)
{
case PAGE_FIRST:
{
// jump to first page
SwitchPage(0);
}
break;
case PAGE_LAST:
{
// jump to last page
SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
}
break;
case PAGE_NEXT:
{
// jump to next page
sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
{
SwitchPage(nSdPage + 1);
}
}
break;
case PAGE_PREVIOUS:
{
// jump to previous page
sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
if (nSdPage > 0)
{
SwitchPage(nSdPage - 1);
}
}
break;
case PAGE_NONE:
break;
}
}
else if (nSId == SID_NAVIGATOR_OBJECT)
{
OUString aBookmarkStr("#");
const SfxItemSet* pArgs = rReq.GetArgs();
OUString aTarget = static_cast<const SfxStringItem&>( pArgs->
Get(SID_NAVIGATOR_OBJECT)).GetValue();
aBookmarkStr += aTarget;
SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
SfxViewFrame* pFrame = GetViewFrame();
SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
SfxBoolItem aBrowseItem(SID_BROWSE, true);
pFrame->GetDispatcher()->
Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
&aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
}
SfxBindings& rBindings = GetViewFrame()->GetBindings();
rBindings.Invalidate( SID_NAVIGATOR_STATE );
rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
}
break;
default:
break;
}
}
void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
{
sal_uInt32 nState = NAVSTATE_NONE;
sal_uInt16 nCurrentPage = 0;
sal_uInt16 nFirstPage = 0;
sal_uInt16 nLastPage;
bool bEndless = false;
OUString aPageName;
rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if( xSlideshow.is() && xSlideshow->isRunning() )
{
// pen activated?
nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
bEndless = xSlideshow->isEndless();
// Get the page for the current page number.
SdPage* pPage = nullptr;
if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
if(pPage)
aPageName = pPage->GetName();
}
else
{
nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
if (mpActualPage != nullptr)
{
nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
aPageName = mpActualPage->GetName();
}
nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
}
// first page / previous page
if( nCurrentPage == nFirstPage )
{
nState |= NAVBTN_FIRST_DISABLED;
if( !bEndless )
nState |= NAVBTN_PREV_DISABLED;
else
nState |= NAVBTN_PREV_ENABLED;
}
else
{
nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
}
// last page / next page
if( nCurrentPage == nLastPage )
{
nState |= NAVBTN_LAST_DISABLED;
if( !bEndless )
nState |= NAVBTN_NEXT_DISABLED;
else
nState |= NAVBTN_NEXT_ENABLED;
}
else
{
nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
}
rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|