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/stritem.hxx>
24 #include <sfx2/childwin.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>
35 #include <drawdoc.hxx>
36 #include <DrawDocShell.hxx>
38 #include <navigatr.hxx>
39 #include <drawview.hxx>
44 * handle SfxRequests for navigator
46 void DrawViewShell::ExecNavigatorWin( SfxRequest
& rReq
)
50 sal_uInt16 nSId
= rReq
.GetSlot();
54 case SID_NAVIGATOR_INIT
:
56 SfxChildWindow
* pWindow
= GetViewFrame()->GetChildWindow( SID_NAVIGATOR
);
59 SdNavigatorFloat
* pNavWin
= static_cast<SdNavigatorFloat
*>(pWindow
->GetWindow());
61 pNavWin
->InitTreeLB( GetDoc() );
66 case SID_NAVIGATOR_PAGE
:
67 case SID_NAVIGATOR_OBJECT
:
69 if (nSId
== SID_NAVIGATOR_PAGE
)
71 if ( mpDrawView
->IsTextEdit() )
72 mpDrawView
->SdrEndTextEdit();
74 const SfxItemSet
* pArgs
= rReq
.GetArgs();
75 PageJump eJump
= static_cast<PageJump
>( pArgs
->Get(SID_NAVIGATOR_PAGE
).GetValue() );
89 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1);
96 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
98 if (nSdPage
< GetDoc()->GetSdPageCount(mpActualPage
->GetPageKind()) - 1)
100 SwitchPage(nSdPage
+ 1);
107 // jump to previous page
108 sal_uInt16 nSdPage
= (mpActualPage
->GetPageNum() - 1) / 2;
112 SwitchPage(nSdPage
- 1);
121 else if (nSId
== SID_NAVIGATOR_OBJECT
)
123 OUString
aBookmarkStr(u
"#"_ustr
);
124 const SfxItemSet
* pArgs
= rReq
.GetArgs();
125 OUString aTarget
= pArgs
->Get(SID_NAVIGATOR_OBJECT
).GetValue();
126 aBookmarkStr
+= aTarget
;
127 SfxStringItem
aStrItem(SID_FILE_NAME
, aBookmarkStr
);
128 SfxStringItem
aReferer(SID_REFERER
, GetDocSh()->GetMedium()->GetName());
129 SfxViewFrame
* pFrame
= GetViewFrame();
130 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
131 SfxBoolItem
aBrowseItem(SID_BROWSE
, true);
132 pFrame
->GetDispatcher()->
133 ExecuteList(SID_OPENDOC
, SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
134 { &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
});
137 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
138 rBindings
.Invalidate( SID_NAVIGATOR_STATE
);
139 rBindings
.Invalidate( SID_NAVIGATOR_PAGENAME
);
148 void DrawViewShell::GetNavigatorWinState( SfxItemSet
& rSet
)
150 NavState nState
= NavState::NONE
;
151 sal_uInt16 nCurrentPage
= 0;
152 sal_uInt16 nLastPage
;
155 nState
|= NavState::TableUpdate
;
157 if (mpActualPage
!= nullptr)
159 nCurrentPage
= ( mpActualPage
->GetPageNum() - 1 ) / 2;
160 aPageName
= mpActualPage
->GetName();
162 nLastPage
= GetDoc()->GetSdPageCount( mePageKind
) - 1;
165 // first page / previous page
166 if( nCurrentPage
== 0 )
168 nState
|= NavState::BtnFirstDisabled
| NavState::BtnPrevDisabled
;
172 nState
|= NavState::BtnFirstEnabled
| NavState::BtnPrevEnabled
;
175 // last page / next page
176 if( nCurrentPage
== nLastPage
)
178 nState
|= NavState::BtnLastDisabled
| NavState::BtnNextDisabled
;
182 nState
|= NavState::BtnLastEnabled
| NavState::BtnNextEnabled
;
185 rSet
.Put( SfxUInt32Item( SID_NAVIGATOR_STATE
, static_cast<sal_uInt32
>(nState
) ) );
186 rSet
.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME
, aPageName
) );
189 } // end of namespace sd
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */