LibreOffice Module sd (master) 1
fuscale.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 <fuscale.hxx>
21
22#include <svx/svxids.hrc>
23
24#include <app.hrc>
25#include <View.hxx>
26#include <Window.hxx>
27#include <OutlineViewShell.hxx>
28#include <drawdoc.hxx>
29#include <DrawViewShell.hxx>
30#include <ViewShell.hxx>
31#include <fuzoom.hxx>
32
33#include <svx/svdpagv.hxx>
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/dispatch.hxx>
36#include <sfx2/zoomitem.hxx>
37#include <sfx2/request.hxx>
38#include <svx/svxdlg.hxx>
39#include <memory>
40
41namespace sd {
42
43
45 ViewShell* pViewSh,
46 ::sd::Window* pWin,
47 ::sd::View* pView,
48 SdDrawDocument* pDoc,
49 SfxRequest& rReq)
50 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
51{
52}
53
55{
56 rtl::Reference<FuPoor> xFunc( new FuScale( pViewSh, pWin, pView, pDoc, rReq ) );
57 xFunc->DoExecute(rReq);
58 return xFunc;
59}
60
62{
63 sal_Int16 nValue;
64
65 const SfxItemSet* pArgs = rReq.GetArgs();
66
67 if( !pArgs )
68 {
70 std::unique_ptr<SvxZoomItem> pZoomItem;
71 SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
72
73 nValue = static_cast<sal_Int16>(mpWindow->GetZoom());
74
75 // zoom on page size?
76 if( dynamic_cast< DrawViewShell *>( mpViewShell ) &&
77 static_cast<DrawViewShell*>(mpViewShell)->IsZoomOnPage() )
78 {
79 pZoomItem.reset(new SvxZoomItem( SvxZoomType::WHOLEPAGE, nValue ));
80 }
81 else
82 {
83 pZoomItem.reset(new SvxZoomItem( SvxZoomType::PERCENT, nValue ));
84 }
85
86 // limit range
87 if( mpViewShell )
88 {
89 if( dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr )
90 {
91 SdrPageView* pPageView = mpView->GetSdrPageView();
92 if( pPageView && pPageView->GetObjList()->GetObjCount() == 0 )
93 {
94 nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
95 }
96 }
97 else if( dynamic_cast< OutlineViewShell *>( mpViewShell ) != nullptr )
98 {
99 nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
100 nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
101 nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
102 }
103 }
104
105 pZoomItem->SetValueSet( nZoomValues );
106 aNewAttr.Put( std::move(pZoomItem) );
107
110 pDlg->SetLimits( static_cast<sal_uInt16>(mpWindow->GetMinZoom()), static_cast<sal_uInt16>(mpWindow->GetMaxZoom()) );
111 sal_uInt16 nResult = pDlg->Execute();
112 switch( nResult )
113 {
114 case RET_CANCEL:
115 {
116 rReq.Ignore ();
117 return; // Cancel
118 }
119 default:
120 {
121 rReq.Ignore ();
122 }
123 break;
124 }
125
126 const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
127
128 pDlg.disposeAndClear();
129
130 if (!mpViewShell)
131 return;
132
133 switch ( aArgs.Get (SID_ATTR_ZOOM).GetType ())
134 {
135 case SvxZoomType::PERCENT:
136 {
137 nValue = aArgs.Get (SID_ATTR_ZOOM).GetValue ();
138
140
142 }
143 break;
144
145 case SvxZoomType::OPTIMAL:
146 {
147 if( dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr )
148 {
149 // name confusion: SID_SIZE_ALL -> zoom onto all objects
150 // --> the program offers it as optimal
151 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
152 }
153 }
154 break;
155
156 case SvxZoomType::PAGEWIDTH:
157 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
158 break;
159
160 case SvxZoomType::WHOLEPAGE:
161 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
162 break;
163 default:
164 break;
165 }
166 }
167 else if(mpViewShell && (pArgs->Count () == 1))
168 {
169 const SfxUInt32Item* pScale = rReq.GetArg<SfxUInt32Item>(ID_VAL_ZOOM);
170 mpViewShell->SetZoom (pScale->GetValue ());
171
173 }
174
175}
176
177} // end of namespace sd
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 GetValue() const
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
size_t GetObjCount() const
SdrObjList * GetObjList() const
SdrPageView * GetSdrPageView() const
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
sal_uInt16 Count() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void Ignore()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
weld::Window * GetFrameWeld() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
static SvxAbstractDialogFactory * Create()
void disposeAndClear()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
ViewShell * mpViewShell
Definition: fupoor.hxx:145
::sd::View * mpView
Definition: fupoor.hxx:144
FuScale(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuscale.cxx:44
virtual void DoExecute(SfxRequest &rReq) override
Definition: fuscale.cxx:61
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuscale.cxx:54
Show a textual overview of the text contents of all slides.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
virtual void SetZoom(::tools::Long nZoom)
Set zoom factor for all split windows.
Definition: viewshe2.cxx:309
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
sal_Int16 nValue
const sal_uInt16 SidArrayZoom[]
Definition: fuzoom.cxx:36
RET_CANCEL
SvxZoomEnableFlags