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 "fuscale.hxx"
22 #include <svx/dialogs.hrc>
27 #include "OutlineViewShell.hxx"
28 #include "drawview.hxx"
29 #include "drawdoc.hxx"
30 #include "DrawViewShell.hxx"
31 #include "ViewShell.hxx"
32 #include "fuzoom.hxx" // because of SidArrayZoom[]
34 #include <vcl/msgbox.hxx>
35 #include <svx/svdpagv.hxx>
36 #include <sfx2/viewfrm.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <svx/zoom_def.hxx>
39 #include <sfx2/zoomitem.hxx>
40 #include <sfx2/request.hxx>
41 #include <svx/svxdlg.hxx>
45 TYPEINIT1( FuScale
, FuPoor
);
53 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
57 FunctionReference
FuScale::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
59 FunctionReference
xFunc( new FuScale( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
60 xFunc
->DoExecute(rReq
);
64 void FuScale::DoExecute( SfxRequest
& rReq
)
68 const SfxItemSet
* pArgs
= rReq
.GetArgs();
72 SfxItemSet
aNewAttr( mpDoc
->GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
73 SvxZoomItem
* pZoomItem
;
74 sal_uInt16 nZoomValues
= SVX_ZOOM_ENABLE_ALL
;
76 nValue
= (sal_Int16
) mpWindow
->GetZoom();
79 if( mpViewShell
&& mpViewShell
->ISA( DrawViewShell
) &&
80 static_cast<DrawViewShell
*>(mpViewShell
)->IsZoomOnPage() )
82 pZoomItem
= new SvxZoomItem( SVX_ZOOM_WHOLEPAGE
, nValue
);
86 pZoomItem
= new SvxZoomItem( SVX_ZOOM_PERCENT
, nValue
);
92 if( mpViewShell
->ISA( DrawViewShell
) )
94 SdrPageView
* pPageView
= mpView
->GetSdrPageView();
95 if( ( pPageView
&& pPageView
->GetObjList()->GetObjCount() == 0 ) )
96 // || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
98 nZoomValues
&= ~SVX_ZOOM_ENABLE_OPTIMAL
;
101 else if( mpViewShell
->ISA( OutlineViewShell
) )
103 nZoomValues
&= ~SVX_ZOOM_ENABLE_OPTIMAL
;
104 nZoomValues
&= ~SVX_ZOOM_ENABLE_WHOLEPAGE
;
105 nZoomValues
&= ~SVX_ZOOM_ENABLE_PAGEWIDTH
;
109 pZoomItem
->SetValueSet( nZoomValues
);
110 aNewAttr
.Put( *pZoomItem
);
112 AbstractSvxZoomDialog
* pDlg
=NULL
;
113 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
116 pDlg
= pFact
->CreateSvxZoomDialog(NULL
, aNewAttr
);
121 pDlg
->SetLimits( (sal_uInt16
)mpWindow
->GetMinZoom(), (sal_uInt16
)mpWindow
->GetMaxZoom() );
122 sal_uInt16 nResult
= pDlg
->Execute();
136 rReq.Done( *( pDlg->GetOutputItemSet() ) );
137 pArgs = rReq.GetArgs();*/
142 const SfxItemSet
aArgs (*(pDlg
->GetOutputItemSet ()));
146 switch (((const SvxZoomItem
&) aArgs
.Get (SID_ATTR_ZOOM
)).GetType ())
148 case SVX_ZOOM_PERCENT
:
150 nValue
= ((const SvxZoomItem
&) aArgs
.Get (SID_ATTR_ZOOM
)).GetValue ();
152 mpViewShell
->SetZoom( nValue
);
154 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
158 case SVX_ZOOM_OPTIMAL
:
160 if( mpViewShell
->ISA( DrawViewShell
) )
162 // name confusion: SID_SIZE_ALL -> zoom onto all objects
163 // --> the program offers it as optimal
164 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
169 case SVX_ZOOM_PAGEWIDTH
:
170 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
173 case SVX_ZOOM_WHOLEPAGE
:
174 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
183 else if(mpViewShell
&& (pArgs
->Count () == 1))
185 SFX_REQUEST_ARG (rReq
, pScale
, SfxUInt32Item
, ID_VAL_ZOOM
, sal_False
);
186 mpViewShell
->SetZoom (pScale
->GetValue ());
188 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
193 } // end of namespace sd
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */