LibreOffice Module sd (master) 1
drviewsd.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <DrawViewShell.hxx>
21
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>
30
31#include <sfx2/viewfrm.hxx>
32
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>
40
41namespace sd {
42
47{
48 CheckLineTo (rReq);
49
50 sal_uInt16 nSId = rReq.GetSlot();
51
52 switch( nSId )
53 {
54 case SID_NAVIGATOR_INIT:
55 {
56 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( SID_NAVIGATOR );
57 if( pWindow )
58 {
59 SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>(pWindow->GetWindow());
60 if( pNavWin )
61 pNavWin->InitTreeLB( GetDoc() );
62 }
63 }
64 break;
65
66 case SID_NAVIGATOR_PAGE:
67 case SID_NAVIGATOR_OBJECT:
68 {
69 if (nSId == SID_NAVIGATOR_PAGE)
70 {
71 if ( mpDrawView->IsTextEdit() )
72 mpDrawView->SdrEndTextEdit();
73
74 const SfxItemSet* pArgs = rReq.GetArgs();
75 PageJump eJump = static_cast<PageJump>( pArgs->Get(SID_NAVIGATOR_PAGE).GetValue() );
76
77 switch (eJump)
78 {
79 case PAGE_FIRST:
80 {
81 // jump to first page
82 SwitchPage(0);
83 }
84 break;
85
86 case PAGE_LAST:
87 {
88 // jump to last page
89 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
90 }
91 break;
92
93 case PAGE_NEXT:
94 {
95 // jump to next page
96 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
97
98 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
99 {
100 SwitchPage(nSdPage + 1);
101 }
102 }
103 break;
104
105 case PAGE_PREVIOUS:
106 {
107 // jump to previous page
108 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
109
110 if (nSdPage > 0)
111 {
112 SwitchPage(nSdPage - 1);
113 }
114 }
115 break;
116
117 case PAGE_NONE:
118 break;
119 }
120 }
121 else if (nSId == SID_NAVIGATOR_OBJECT)
122 {
123 OUString aBookmarkStr("#");
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 });
135 }
136
137 SfxBindings& rBindings = GetViewFrame()->GetBindings();
138 rBindings.Invalidate( SID_NAVIGATOR_STATE );
139 rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
140 }
141 break;
142
143 default:
144 break;
145 }
146}
147
149{
151 sal_uInt16 nCurrentPage = 0;
152 sal_uInt16 nLastPage;
153 OUString aPageName;
154
156
157 if (mpActualPage != nullptr)
158 {
159 nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
160 aPageName = mpActualPage->GetName();
161 }
162 nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
163
164
165 // first page / previous page
166 if( nCurrentPage == 0 )
167 {
169 }
170 else
171 {
173 }
174
175 // last page / next page
176 if( nCurrentPage == nLastPage )
177 {
179 }
180 else
181 {
183 }
184
185 rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, static_cast<sal_uInt32>(nState) ) );
186 rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
187}
188
189} // end of namespace sd
190
191/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
PageKind GetPageKind() const
Definition: sdpage.hxx:205
const OUString & GetName() const
Definition: sdpage.cxx:2505
sal_uInt16 GetPageNum() const
void Invalidate(sal_uInt16 nId)
vcl::Window * GetWindow() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const OUString & GetName() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxChildWindow * GetChildWindow(sal_uInt16)
static void CheckLineTo(SfxRequest &rReq)
check if we have to draw a polyline
Definition: drviewsa.cxx:404
std::unique_ptr< DrawView > mpDrawView
void ExecNavigatorWin(SfxRequest &rReq)
handle SfxRequests for navigator
Definition: drviewsd.cxx:46
void GetNavigatorWinState(SfxItemSet &rSet)
Definition: drviewsd.cxx:148
bool SwitchPage(sal_uInt16 nPage, bool bAllowChangeFocus=true)
Switch to desired page.
Definition: drviews1.cxx:831
void InitTreeLB(const SdDrawDocument *pDoc)
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
sal_Int32 nState
NavState
Definition: navigatr.hxx:39
@ BtnNextEnabled
@ BtnPrevEnabled
@ BtnFirstDisabled
@ BtnPrevDisabled
@ BtnFirstEnabled
@ BtnLastDisabled
@ BtnNextDisabled
@ BtnLastEnabled
PageJump
Definition: pgjump.hxx:23
@ PAGE_NEXT
Definition: pgjump.hxx:27
@ PAGE_FIRST
Definition: pgjump.hxx:25
@ PAGE_NONE
Definition: pgjump.hxx:24
@ PAGE_LAST
Definition: pgjump.hxx:28
@ PAGE_PREVIOUS
Definition: pgjump.hxx:26
static SfxItemSet & rSet