Line data Source code
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/dialogs.hrc>
23 :
24 : #include "app.hrc"
25 : #include "View.hxx"
26 : #include "Window.hxx"
27 : #include "OutlineViewShell.hxx"
28 : #include "drawview.hxx"
29 : #include "drawdoc.hxx"
30 : #include "DrawViewShell.hxx"
31 : #include "ViewShell.hxx"
32 : #include "fuzoom.hxx" // wegen SidArrayZoom[]
33 :
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>
42 :
43 : namespace sd {
44 :
45 0 : TYPEINIT1( FuScale, FuPoor );
46 :
47 : /*************************************************************************
48 : |*
49 : |* Konstruktor
50 : |*
51 : \************************************************************************/
52 :
53 0 : FuScale::FuScale (
54 : ViewShell* pViewSh,
55 : ::sd::Window* pWin,
56 : ::sd::View* pView,
57 : SdDrawDocument* pDoc,
58 : SfxRequest& rReq)
59 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
60 : {
61 0 : }
62 :
63 0 : FunctionReference FuScale::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
64 : {
65 0 : FunctionReference xFunc( new FuScale( pViewSh, pWin, pView, pDoc, rReq ) );
66 0 : xFunc->DoExecute(rReq);
67 0 : return xFunc;
68 : }
69 :
70 0 : void FuScale::DoExecute( SfxRequest& rReq )
71 : {
72 : sal_Int16 nValue;
73 :
74 0 : const SfxItemSet* pArgs = rReq.GetArgs();
75 :
76 0 : if( !pArgs )
77 : {
78 0 : SfxItemSet aNewAttr( mpDoc->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
79 : SvxZoomItem* pZoomItem;
80 0 : sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
81 :
82 0 : nValue = (sal_Int16) mpWindow->GetZoom();
83 :
84 : // Zoom auf Seitengroesse ?
85 0 : if( mpViewShell && mpViewShell->ISA( DrawViewShell ) &&
86 0 : static_cast<DrawViewShell*>(mpViewShell)->IsZoomOnPage() )
87 : {
88 0 : pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nValue );
89 : }
90 : else
91 : {
92 0 : pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nValue );
93 : }
94 :
95 : // Bereich einschraenken
96 0 : if( mpViewShell )
97 : {
98 0 : if( mpViewShell->ISA( DrawViewShell ) )
99 : {
100 0 : SdrPageView* pPageView = mpView->GetSdrPageView();
101 0 : if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
102 : // || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
103 : {
104 0 : nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
105 : }
106 : }
107 0 : else if( mpViewShell->ISA( OutlineViewShell ) )
108 : {
109 0 : nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
110 0 : nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
111 0 : nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
112 : }
113 : }
114 :
115 0 : pZoomItem->SetValueSet( nZoomValues );
116 0 : aNewAttr.Put( *pZoomItem );
117 :
118 0 : AbstractSvxZoomDialog* pDlg=NULL;
119 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
120 0 : if(pFact)
121 : {
122 0 : pDlg = pFact->CreateSvxZoomDialog(NULL, aNewAttr);
123 : }
124 :
125 0 : if( pDlg )
126 : {
127 0 : pDlg->SetLimits( (sal_uInt16)mpWindow->GetMinZoom(), (sal_uInt16)mpWindow->GetMaxZoom() );
128 0 : sal_uInt16 nResult = pDlg->Execute();
129 0 : switch( nResult )
130 : {
131 : case RET_CANCEL:
132 : {
133 0 : delete pDlg;
134 0 : delete pZoomItem;
135 0 : rReq.Ignore ();
136 0 : return; // Abbruch
137 : }
138 : default:
139 : {
140 0 : rReq.Ignore ();
141 : /*
142 : rReq.Done( *( pDlg->GetOutputItemSet() ) );
143 : pArgs = rReq.GetArgs();*/
144 : }
145 0 : break;
146 : }
147 :
148 0 : const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
149 :
150 0 : delete pDlg;
151 :
152 0 : switch (((const SvxZoomItem &) aArgs.Get (SID_ATTR_ZOOM)).GetType ())
153 : {
154 : case SVX_ZOOM_PERCENT:
155 : {
156 0 : nValue = ((const SvxZoomItem &) aArgs.Get (SID_ATTR_ZOOM)).GetValue ();
157 :
158 0 : mpViewShell->SetZoom( nValue );
159 :
160 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
161 : }
162 0 : break;
163 :
164 : case SVX_ZOOM_OPTIMAL:
165 : {
166 0 : if( mpViewShell->ISA( DrawViewShell ) )
167 : {
168 : // Namensverwirrung: SID_SIZE_ALL -> Zoom auf alle Objekte
169 : // --> Wird als Optimal im Programm angeboten
170 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
171 : }
172 : }
173 0 : break;
174 :
175 : case SVX_ZOOM_PAGEWIDTH:
176 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
177 0 : break;
178 :
179 : case SVX_ZOOM_WHOLEPAGE:
180 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
181 0 : break;
182 : default:
183 0 : break;
184 0 : }
185 : }
186 :
187 0 : delete pZoomItem;
188 : }
189 0 : else if(mpViewShell && (pArgs->Count () == 1))
190 : {
191 0 : SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, sal_False);
192 0 : mpViewShell->SetZoom (pScale->GetValue ());
193 :
194 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
195 : }
196 :
197 : }
198 :
199 9 : } // end of namespace sd
200 :
201 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|