xref: /aoo42x/main/sd/source/ui/view/drviewsg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "DrawViewShell.hxx"
32 #include "ViewShellImplementation.hxx"
33 
34 #ifndef _SVXIDS_HRC
35 #include <svx/svxids.hrc>
36 #endif
37 #ifndef _IMAPDLG_HXX
38 #include <svx/imapdlg.hxx>
39 #endif
40 #include <sfx2/request.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <svx/svdograf.hxx>
44 #include <svx/svdoole2.hxx>
45 
46 
47 #include "app.hrc"
48 
49 #include "drawdoc.hxx"
50 #include "slideshow.hxx"
51 #include "imapinfo.hxx"
52 #include "sdmod.hxx"
53 #include "optsitem.hxx"
54 #ifndef SD_FRAME_VIEW
55 #include "FrameView.hxx"
56 #endif
57 #include "drawview.hxx"
58 
59 #include "fupoor.hxx"
60 
61 namespace sd {
62 
63 /*************************************************************************
64 |*
65 |*
66 |*
67 \************************************************************************/
68 
69 void DrawViewShell::ExecIMap( SfxRequest& rReq )
70 {
71 	// waehrend einer Diashow wird nichts ausgefuehrt!
72 	if(HasCurrentFunction(SID_PRESENTATION) )
73 		return;
74 
75 	if ( rReq.GetSlot() == SID_IMAP_EXEC )
76 	{
77 		SdrMark* pMark = mpDrawView->GetMarkedObjectList().GetMark(0);
78 
79 		if ( pMark )
80 		{
81 			SdrObject*	pSdrObj = pMark->GetMarkedSdrObj();
82 			SvxIMapDlg* pDlg = ViewShell::Implementation::GetImageMapDialog();
83 
84 			if ( pDlg->GetEditingObject() == (void*) pSdrObj )
85 			{
86 				const ImageMap& rImageMap = pDlg->GetImageMap();
87 				SdIMapInfo* 	pIMapInfo = GetDoc()->GetIMapInfo( pSdrObj );
88 
89 				if ( !pIMapInfo )
90 					pSdrObj->InsertUserData( new SdIMapInfo( rImageMap ) );
91 				else
92 					pIMapInfo->SetImageMap( rImageMap );
93 
94                 GetDoc()->SetChanged( sal_True );
95 			}
96 		}
97 	}
98 }
99 
100 
101 /*************************************************************************
102 |*
103 |*
104 |*
105 \************************************************************************/
106 
107 void DrawViewShell::GetIMapState( SfxItemSet& rSet )
108 {
109 	sal_Bool bDisable = sal_True;
110 
111 	if( GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
112 	{
113 		const SdrMarkList&	rMarkList = mpDrawView->GetMarkedObjectList();
114 		const SdrObject*	pObj = NULL;
115 		sal_uLong				nMarkCount = rMarkList.GetMarkCount();
116 
117 		if ( nMarkCount == 1 )
118 		{
119 			pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
120 
121             SvxIMapDlg* pImageMapDialog = ViewShell::Implementation::GetImageMapDialog();
122 			if ( ( pObj->ISA( SdrGrafObj ) /*|| pObj->ISA( SdrOle2Obj )*/ )
123                 && pImageMapDialog!=NULL
124                 && ( pImageMapDialog->GetEditingObject() == (void*) pObj ) )
125 			{
126 				bDisable = sal_False;
127 			}
128 		}
129 	}
130 
131 	rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
132 }
133 
134 /*************************************************************************
135 |*
136 |*	Execute-Methode der Optionsleiste
137 |*
138 \************************************************************************/
139 
140 void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
141 {
142 	// waehrend einer Diashow wird nichts ausgefuehrt!
143 	if(HasCurrentFunction(SID_PRESENTATION))
144 		return;
145 
146 	sal_Bool   bDefault = sal_False;
147 	sal_uInt16 nSlot = rReq.GetSlot();
148 
149 	SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
150 
151 	switch( nSlot )
152 	{
153 		case SID_HANDLES_DRAFT:
154 			pOptions->SetSolidMarkHdl( !mpDrawView->IsSolidMarkHdl() );
155 		break;
156 
157 		case SID_SOLID_CREATE:
158 			pOptions->SetSolidDragging( !mpDrawView->IsSolidDragging() );
159 		break;
160 
161 
162 		// Raster- / Hilfslinien-Optionen
163 		case SID_GRID_VISIBLE: // noch nicht hier !
164 		{
165 			pOptions->SetGridVisible( !mpDrawView->IsGridVisible() );
166 		}
167 		break;
168 
169 		case SID_GRID_USE:
170 		{
171 			pOptions->SetUseGridSnap( !mpDrawView->IsGridSnap() );
172 		}
173 		break;
174 
175 		case SID_HELPLINES_VISIBLE: // noch nicht hier !
176 		{
177 			pOptions->SetHelplines( !mpDrawView->IsHlplVisible() );
178 		}
179 		break;
180 
181 		case SID_HELPLINES_USE:
182 		{
183 			pOptions->SetSnapHelplines( !mpDrawView->IsHlplSnap() );
184 		}
185 		break;
186 
187 		case SID_HELPLINES_MOVE:
188 		{
189 			pOptions->SetDragStripes( !mpDrawView->IsDragStripes() );
190 		}
191 		break;
192 
193 
194 		case SID_SNAP_BORDER:
195 		{
196 			pOptions->SetSnapBorder( !mpDrawView->IsBordSnap() );
197 		}
198 		break;
199 
200 		case SID_SNAP_FRAME:
201 		{
202 			pOptions->SetSnapFrame( !mpDrawView->IsOFrmSnap() );
203 		}
204 		break;
205 
206 		case SID_SNAP_POINTS:
207 		{
208 			pOptions->SetSnapPoints( !mpDrawView->IsOPntSnap() );
209 		}
210 		break;
211 
212 
213 		case SID_QUICKEDIT:
214 		{
215 			pOptions->SetQuickEdit( !mpDrawView->IsQuickTextEditMode() );
216 		}
217 		break;
218 
219 		case SID_PICK_THROUGH:
220 		{
221 			pOptions->SetPickThrough(
222 				!mpDrawView->GetModel()->IsPickThroughTransparentTextFrames() );
223 		}
224 		break;
225 
226 		case SID_BIG_HANDLES:
227 		{
228 			pOptions->SetBigHandles( !mpFrameView->IsBigHandles() );
229 		}
230 		break;
231 
232 		case SID_DOUBLECLICK_TEXTEDIT:
233 		{
234 			pOptions->SetDoubleClickTextEdit( !mpFrameView->IsDoubleClickTextEdit() );
235 		}
236 		break;
237 
238 		case SID_CLICK_CHANGE_ROTATION:
239 		{
240 			pOptions->SetClickChangeRotation( !mpFrameView->IsClickChangeRotation() );
241 		}
242 		break;
243 
244 		default:
245 			bDefault = sal_True;
246 		break;
247 	}
248 
249 	if( !bDefault )
250 	{
251 		pOptions->StoreConfig();
252 
253 		// Speichert die Konfiguration SOFORT
254 		// SFX_APP()->SaveConfiguration();
255 		WriteFrameViewData();
256 
257 		mpFrameView->Update( pOptions );
258 		ReadFrameViewData( mpFrameView );
259 
260 		Invalidate( nSlot );
261 		rReq.Done();
262 	}
263 
264 }
265 
266 
267 /*************************************************************************
268 |*
269 |*	State-Methode der Optionsleiste
270 |*
271 \************************************************************************/
272 
273 void DrawViewShell::GetOptionsBarState( SfxItemSet& rSet )
274 {
275 	rSet.Put( SfxBoolItem( SID_HANDLES_DRAFT, !mpDrawView->IsSolidMarkHdl() ) );
276 	rSet.Put( SfxBoolItem( SID_SOLID_CREATE, mpDrawView->IsSolidDragging() ) );
277 	rSet.Put( SfxBoolItem( SID_GRID_VISIBLE, mpDrawView->IsGridVisible() ) );
278 	rSet.Put( SfxBoolItem( SID_GRID_USE, mpDrawView->IsGridSnap() ) );
279 	rSet.Put( SfxBoolItem( SID_HELPLINES_VISIBLE, mpDrawView->IsHlplVisible() ) );
280 	rSet.Put( SfxBoolItem( SID_HELPLINES_USE, mpDrawView->IsHlplSnap() ) );
281 	rSet.Put( SfxBoolItem( SID_HELPLINES_MOVE, mpDrawView->IsDragStripes() ) );
282 
283 	rSet.Put( SfxBoolItem( SID_SNAP_BORDER, mpDrawView->IsBordSnap() ) );
284 	rSet.Put( SfxBoolItem( SID_SNAP_FRAME, mpDrawView->IsOFrmSnap() ) );
285 	rSet.Put( SfxBoolItem( SID_SNAP_POINTS, mpDrawView->IsOPntSnap() ) );
286 
287 	rSet.Put( SfxBoolItem( SID_QUICKEDIT, mpDrawView->IsQuickTextEditMode() ) );
288 	rSet.Put( SfxBoolItem( SID_PICK_THROUGH, (sal_Bool)
289 				mpDrawView->GetModel()->IsPickThroughTransparentTextFrames() ) );
290 
291 	rSet.Put( SfxBoolItem( SID_BIG_HANDLES, mpFrameView->IsBigHandles() ) );
292 	rSet.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT, mpFrameView->IsDoubleClickTextEdit() ) );
293 	rSet.Put( SfxBoolItem( SID_CLICK_CHANGE_ROTATION, mpFrameView->IsClickChangeRotation() ) );
294 }
295 
296 } // end of namespace sd
297