Update ooo320-m1
[ooovba.git] / sd / source / ui / func / fuscale.cxx
blob4ec3b7a71053f7f4d59b5f84ca26c851f4f1300a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuscale.cxx,v $
10 * $Revision: 1.14 $
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>
39 #include "app.hrc"
40 #include "View.hxx"
41 #ifndef SD_WINDOW_SHELL_HXX
42 #include "Window.hxx"
43 #endif
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>
53 #endif
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>
63 namespace sd {
65 TYPEINIT1( FuScale, FuPoor );
67 /*************************************************************************
69 |* Konstruktor
71 \************************************************************************/
73 FuScale::FuScale (
74 ViewShell* pViewSh,
75 ::sd::Window* pWin,
76 ::sd::View* pView,
77 SdDrawDocument* pDoc,
78 SfxRequest& rReq)
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);
87 return xFunc;
90 void FuScale::DoExecute( SfxRequest& rReq )
92 INT16 nValue;
94 const SfxItemSet* pArgs = rReq.GetArgs();
96 if( !pArgs )
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 );
110 else
112 pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nValue );
115 // Bereich einschraenken
116 if( mpViewShell )
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();
140 if(pFact)
142 pDlg = pFact->CreateSvxZoomDialog(NULL, aNewAttr, RID_SVXDLG_ZOOM);
145 if( pDlg )
147 pDlg->SetLimits( (USHORT)mpWindow->GetMinZoom(), (USHORT)mpWindow->GetMaxZoom() );
148 USHORT nResult = pDlg->Execute();
149 switch( nResult )
151 case RET_CANCEL:
153 delete pDlg;
154 delete pZoomItem;
155 rReq.Ignore ();
156 return; // Abbruch
158 default:
160 rReq.Ignore ();
162 rReq.Done( *( pDlg->GetOutputItemSet() ) );
163 pArgs = rReq.GetArgs();*/
165 break;
168 const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
170 delete pDlg;
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 );
183 break;
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);
194 break;
196 case SVX_ZOOM_PAGEWIDTH:
197 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
198 break;
200 case SVX_ZOOM_WHOLEPAGE:
201 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
202 break;
203 default:
204 break;
208 delete pZoomItem;
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