1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuscale.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "fuscale.hxx"
37 #include <svx/dialogs.hrc>
41 #ifndef SD_WINDOW_SHELL_HXX
44 #include "OutlineViewShell.hxx"
45 #include "drawview.hxx"
46 #include "drawdoc.hxx"
47 #include "DrawViewShell.hxx"
48 #include "ViewShell.hxx"
49 #include "fuzoom.hxx" // wegen SidArrayZoom[]
51 #ifndef _MSGBOX_HXX //autogen
52 #include <vcl/msgbox.hxx>
54 #include <svx/svdpagv.hxx>
55 #include <sfx2/viewfrm.hxx>
56 #include <sfx2/dispatch.hxx>
57 #include <svx/zoom_def.hxx>
58 #include <svx/zoomitem.hxx>
59 #include <sfx2/request.hxx>
60 #include <svx/svxdlg.hxx>
61 #include <svx/dialogs.hrc>
65 TYPEINIT1( FuScale
, FuPoor
);
67 /*************************************************************************
71 \************************************************************************/
79 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
83 FunctionReference
FuScale::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
85 FunctionReference
xFunc( new FuScale( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
86 xFunc
->DoExecute(rReq
);
90 void FuScale::DoExecute( SfxRequest
& rReq
)
94 const SfxItemSet
* pArgs
= rReq
.GetArgs();
98 SfxItemSet
aNewAttr( mpDoc
->GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
99 SvxZoomItem
* pZoomItem
;
100 USHORT nZoomValues
= SVX_ZOOM_ENABLE_ALL
;
102 nValue
= (INT16
) mpWindow
->GetZoom();
104 // Zoom auf Seitengroesse ?
105 if( mpViewShell
&& mpViewShell
->ISA( DrawViewShell
) &&
106 static_cast<DrawViewShell
*>(mpViewShell
)->IsZoomOnPage() )
108 pZoomItem
= new SvxZoomItem( SVX_ZOOM_WHOLEPAGE
, nValue
);
112 pZoomItem
= new SvxZoomItem( SVX_ZOOM_PERCENT
, nValue
);
115 // Bereich einschraenken
118 if( mpViewShell
->ISA( DrawViewShell
) )
120 SdrPageView
* pPageView
= mpView
->GetSdrPageView();
121 if( ( pPageView
&& pPageView
->GetObjList()->GetObjCount() == 0 ) )
122 // || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
124 nZoomValues
&= ~SVX_ZOOM_ENABLE_OPTIMAL
;
127 else if( mpViewShell
->ISA( OutlineViewShell
) )
129 nZoomValues
&= ~SVX_ZOOM_ENABLE_OPTIMAL
;
130 nZoomValues
&= ~SVX_ZOOM_ENABLE_WHOLEPAGE
;
131 nZoomValues
&= ~SVX_ZOOM_ENABLE_PAGEWIDTH
;
135 pZoomItem
->SetValueSet( nZoomValues
);
136 aNewAttr
.Put( *pZoomItem
);
138 AbstractSvxZoomDialog
* pDlg
=NULL
;
139 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
142 pDlg
= pFact
->CreateSvxZoomDialog(NULL
, aNewAttr
, RID_SVXDLG_ZOOM
);
147 pDlg
->SetLimits( (USHORT
)mpWindow
->GetMinZoom(), (USHORT
)mpWindow
->GetMaxZoom() );
148 USHORT nResult
= pDlg
->Execute();
162 rReq.Done( *( pDlg->GetOutputItemSet() ) );
163 pArgs = rReq.GetArgs();*/
168 const SfxItemSet
aArgs (*(pDlg
->GetOutputItemSet ()));
172 // SvxZoomType eZT = ((const SvxZoomItem &) aArgs.Get (RID_SVXDLG_ZOOM)).GetType ();
173 switch (((const SvxZoomItem
&) aArgs
.Get (RID_SVXDLG_ZOOM
)).GetType ())
175 case SVX_ZOOM_PERCENT
:
177 nValue
= ((const SvxZoomItem
&) aArgs
.Get (RID_SVXDLG_ZOOM
)).GetValue ();
179 mpViewShell
->SetZoom( nValue
);
181 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
185 case SVX_ZOOM_OPTIMAL
:
187 if( mpViewShell
->ISA( DrawViewShell
) )
189 // Namensverwirrung: SID_SIZE_ALL -> Zoom auf alle Objekte
190 // --> Wird als Optimal im Programm angeboten
191 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
196 case SVX_ZOOM_PAGEWIDTH
:
197 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
200 case SVX_ZOOM_WHOLEPAGE
:
201 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
210 else if(mpViewShell
&& (pArgs
->Count () == 1))
212 SFX_REQUEST_ARG (rReq
, pScale
, SfxUInt32Item
, ID_VAL_ZOOM
, FALSE
);
213 mpViewShell
->SetZoom (pScale
->GetValue ());
215 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
220 } // end of namespace sd