Bump version to 21.06.18.1
[LibreOffice.git] / sd / source / ui / view / drviewsd.cxx
blob461a69261aaaadddefdfa1d6dd92b0faddee70ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/childwin.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>
34 #include <app.hrc>
35 #include <sdmod.hxx>
36 #include <sdpage.hxx>
37 #include <drawdoc.hxx>
38 #include <DrawDocShell.hxx>
39 #include <pgjump.hxx>
40 #include <navigatr.hxx>
41 #include <drawview.hxx>
43 namespace sd {
45 /**
46 * handle SfxRequests for navigator
48 void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
50 CheckLineTo (rReq);
52 sal_uInt16 nSId = rReq.GetSlot();
54 switch( nSId )
56 case SID_NAVIGATOR_INIT:
58 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( SID_NAVIGATOR );
59 if( pWindow )
61 SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>(pWindow->GetWindow());
62 if( pNavWin )
63 pNavWin->InitTreeLB( GetDoc() );
65 SfxBindings& rBindings = GetViewFrame()->GetBindings();
66 rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
67 rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, true);
69 break;
71 case SID_NAVIGATOR_PAGE:
72 case SID_NAVIGATOR_OBJECT:
74 if (nSId == SID_NAVIGATOR_PAGE)
76 if ( mpDrawView->IsTextEdit() )
77 mpDrawView->SdrEndTextEdit();
79 const SfxItemSet* pArgs = rReq.GetArgs();
80 PageJump eJump = static_cast<PageJump>(static_cast<const SfxUInt16Item&>( pArgs->
81 Get(SID_NAVIGATOR_PAGE)).GetValue());
83 switch (eJump)
85 case PAGE_FIRST:
87 // jump to first page
88 SwitchPage(0);
90 break;
92 case PAGE_LAST:
94 // jump to last page
95 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
97 break;
99 case PAGE_NEXT:
101 // jump to next page
102 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
104 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
106 SwitchPage(nSdPage + 1);
109 break;
111 case PAGE_PREVIOUS:
113 // jump to previous page
114 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
116 if (nSdPage > 0)
118 SwitchPage(nSdPage - 1);
121 break;
123 case PAGE_NONE:
124 break;
127 else if (nSId == SID_NAVIGATOR_OBJECT)
129 OUString aBookmarkStr("#");
130 const SfxItemSet* pArgs = rReq.GetArgs();
131 OUString aTarget = static_cast<const SfxStringItem&>( pArgs->
132 Get(SID_NAVIGATOR_OBJECT)).GetValue();
133 aBookmarkStr += aTarget;
134 SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
135 SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
136 SfxViewFrame* pFrame = GetViewFrame();
137 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
138 SfxBoolItem aBrowseItem(SID_BROWSE, true);
139 pFrame->GetDispatcher()->
140 ExecuteList(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
141 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
144 SfxBindings& rBindings = GetViewFrame()->GetBindings();
145 rBindings.Invalidate( SID_NAVIGATOR_STATE );
146 rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
148 break;
150 default:
151 break;
155 void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
157 NavState nState = NavState::NONE;
158 sal_uInt16 nCurrentPage = 0;
159 sal_uInt16 nLastPage;
160 OUString aPageName;
162 nState |= NavState::TableUpdate;
164 if (mpActualPage != nullptr)
166 nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
167 aPageName = mpActualPage->GetName();
169 nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
172 // first page / previous page
173 if( nCurrentPage == 0 )
175 nState |= NavState::BtnFirstDisabled | NavState::BtnPrevDisabled;
177 else
179 nState |= NavState::BtnFirstEnabled | NavState::BtnPrevEnabled;
182 // last page / next page
183 if( nCurrentPage == nLastPage )
185 nState |= NavState::BtnLastDisabled | NavState::BtnNextDisabled;
187 else
189 nState |= NavState::BtnLastEnabled | NavState::BtnNextEnabled;
192 rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, static_cast<sal_uInt32>(nState) ) );
193 rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
196 } // end of namespace sd
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */