tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sd / source / ui / view / drviewsd.cxx
bloba72b76acdd13d0e9dc5250b05decb5d9bb881570
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/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>
33 #include <app.hrc>
34 #include <sdpage.hxx>
35 #include <drawdoc.hxx>
36 #include <DrawDocShell.hxx>
37 #include <pgjump.hxx>
38 #include <navigatr.hxx>
39 #include <drawview.hxx>
41 namespace sd {
43 /**
44 * handle SfxRequests for navigator
46 void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
48 CheckLineTo (rReq);
50 sal_uInt16 nSId = rReq.GetSlot();
52 switch( nSId )
54 case SID_NAVIGATOR_INIT:
56 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( SID_NAVIGATOR );
57 if( pWindow )
59 SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>(pWindow->GetWindow());
60 if( pNavWin )
61 pNavWin->InitTreeLB( GetDoc() );
64 break;
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() );
77 switch (eJump)
79 case PAGE_FIRST:
81 // jump to first page
82 SwitchPage(0);
84 break;
86 case PAGE_LAST:
88 // jump to last page
89 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
91 break;
93 case PAGE_NEXT:
95 // jump to next page
96 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
98 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
100 SwitchPage(nSdPage + 1);
103 break;
105 case PAGE_PREVIOUS:
107 // jump to previous page
108 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
110 if (nSdPage > 0)
112 SwitchPage(nSdPage - 1);
115 break;
117 case PAGE_NONE:
118 break;
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 );
141 break;
143 default:
144 break;
148 void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
150 NavState nState = NavState::NONE;
151 sal_uInt16 nCurrentPage = 0;
152 sal_uInt16 nLastPage;
153 OUString aPageName;
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;
170 else
172 nState |= NavState::BtnFirstEnabled | NavState::BtnPrevEnabled;
175 // last page / next page
176 if( nCurrentPage == nLastPage )
178 nState |= NavState::BtnLastDisabled | NavState::BtnNextDisabled;
180 else
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: */