android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / drviewsg.cxx
blob2563168433d852d37df0044f6a5acf9c39eb127e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <DrawViewShell.hxx>
21 #include <ViewShellImplementation.hxx>
23 #include <svx/svxids.hrc>
24 #include <svx/imapdlg.hxx>
25 #include <sfx2/request.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <svx/svdograf.hxx>
28 #include <svx/ImageMapInfo.hxx>
30 #include <app.hrc>
32 #include <drawdoc.hxx>
33 #include <sdmod.hxx>
34 #include <optsitem.hxx>
35 #include <FrameView.hxx>
36 #include <drawview.hxx>
38 namespace sd {
40 void DrawViewShell::ExecIMap( SfxRequest const & rReq )
42 // during a slide show, nothing is executed!
43 if(HasCurrentFunction(SID_PRESENTATION) )
44 return;
46 if ( rReq.GetSlot() != SID_IMAP_EXEC )
47 return;
49 SdrMark* pMark = mpDrawView->GetMarkedObjectList().GetMark(0);
51 if ( !pMark )
52 return;
54 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
55 SvxIMapDlg* pDlg = ViewShell::Implementation::GetImageMapDialog();
57 if ( pDlg->GetEditingObject() == static_cast<void*>(pSdrObj) )
59 const ImageMap& rImageMap = pDlg->GetImageMap();
60 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
62 if ( !pIMapInfo )
63 pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
64 else
65 pIMapInfo->SetImageMap( rImageMap );
67 GetDoc()->SetChanged();
71 void DrawViewShell::GetIMapState( SfxItemSet& rSet )
73 bool bDisable = true;
75 if( GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
77 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
79 if ( rMarkList.GetMarkCount() == 1 )
81 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
83 SvxIMapDlg* pImageMapDialog = ViewShell::Implementation::GetImageMapDialog();
84 if ( ( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr /*|| pObj->ISA( SdrOle2Obj )*/ )
85 && pImageMapDialog!=nullptr
86 && ( pImageMapDialog->GetEditingObject() == static_cast<void const *>(pObj) ) )
88 bDisable = false;
93 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
96 void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
98 // during a slide show, nothing is executed!
99 if(HasCurrentFunction(SID_PRESENTATION))
100 return;
102 bool bDefault = false;
103 sal_uInt16 nSlot = rReq.GetSlot();
105 SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
107 switch( nSlot )
109 case SID_SOLID_CREATE:
110 pOptions->SetSolidDragging( !mpDrawView->IsSolidDragging() );
111 break;
113 // Grid- / Help lines option
114 case SID_GRID_VISIBLE: // not here yet!
116 pOptions->SetGridVisible( !mpDrawView->IsGridVisible() );
118 break;
120 case SID_GRID_USE:
122 pOptions->SetUseGridSnap( !mpDrawView->IsGridSnap() );
124 break;
126 case SID_HELPLINES_VISIBLE: // not here yet!
128 pOptions->SetHelplines( !mpDrawView->IsHlplVisible() );
130 break;
132 case SID_HELPLINES_USE:
134 pOptions->SetSnapHelplines( !mpDrawView->IsHlplSnap() );
136 break;
138 case SID_HELPLINES_MOVE:
140 pOptions->SetDragStripes( !mpDrawView->IsDragStripes() );
142 break;
144 case SID_SNAP_BORDER:
146 pOptions->SetSnapBorder( !mpDrawView->IsBordSnap() );
148 break;
150 case SID_SNAP_FRAME:
152 pOptions->SetSnapFrame( !mpDrawView->IsOFrmSnap() );
154 break;
156 case SID_SNAP_POINTS:
158 pOptions->SetSnapPoints( !mpDrawView->IsOPntSnap() );
160 break;
162 case SID_QUICKEDIT:
164 pOptions->SetQuickEdit( !mpDrawView->IsQuickTextEditMode() );
166 break;
168 case SID_PICK_THROUGH:
170 pOptions->SetPickThrough(
171 !mpDrawView->GetModel().IsPickThroughTransparentTextFrames() );
173 break;
175 case SID_DOUBLECLICK_TEXTEDIT:
177 pOptions->SetDoubleClickTextEdit( !mpFrameView->IsDoubleClickTextEdit() );
179 break;
181 case SID_CLICK_CHANGE_ROTATION:
183 pOptions->SetClickChangeRotation( !mpFrameView->IsClickChangeRotation() );
185 break;
187 default:
188 bDefault = true;
189 break;
192 if( bDefault )
193 return;
195 pOptions->StoreConfig();
197 // Saves the configuration IMMEDIATELY
198 // SfxGetpApp()->SaveConfiguration();
199 WriteFrameViewData();
201 mpFrameView->Update( pOptions );
202 ReadFrameViewData( mpFrameView );
204 Invalidate( nSlot );
205 rReq.Done();
209 void DrawViewShell::GetOptionsBarState( SfxItemSet& rSet )
211 rSet.Put( SfxBoolItem( SID_SOLID_CREATE, mpDrawView->IsSolidDragging() ) );
212 rSet.Put( SfxBoolItem( SID_GRID_VISIBLE, mpDrawView->IsGridVisible() ) );
213 rSet.Put( SfxBoolItem( SID_GRID_USE, mpDrawView->IsGridSnap() ) );
214 rSet.Put( SfxBoolItem( SID_HELPLINES_VISIBLE, mpDrawView->IsHlplVisible() ) );
215 rSet.Put( SfxBoolItem( SID_HELPLINES_USE, mpDrawView->IsHlplSnap() ) );
216 rSet.Put( SfxBoolItem( SID_HELPLINES_MOVE, mpDrawView->IsDragStripes() ) );
218 rSet.Put( SfxBoolItem( SID_SNAP_BORDER, mpDrawView->IsBordSnap() ) );
219 rSet.Put( SfxBoolItem( SID_SNAP_FRAME, mpDrawView->IsOFrmSnap() ) );
220 rSet.Put( SfxBoolItem( SID_SNAP_POINTS, mpDrawView->IsOPntSnap() ) );
222 rSet.Put( SfxBoolItem( SID_QUICKEDIT, mpDrawView->IsQuickTextEditMode() ) );
223 rSet.Put( SfxBoolItem( SID_PICK_THROUGH,
224 mpDrawView->GetModel().IsPickThroughTransparentTextFrames() ) );
226 rSet.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT, mpFrameView->IsDoubleClickTextEdit() ) );
227 rSet.Put( SfxBoolItem( SID_CLICK_CHANGE_ROTATION, mpFrameView->IsClickChangeRotation() ) );
230 } // end of namespace sd
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */