cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / view / drviewsg.cxx
blobc0e71e05ad7e53fc1ced53f2705d32cbcbbc2bae
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>
29 #include <officecfg/Office/Draw.hxx>
30 #include <officecfg/Office/Impress.hxx>
32 #include <app.hrc>
34 #include <drawdoc.hxx>
35 #include <sdmod.hxx>
36 #include <optsitem.hxx>
37 #include <FrameView.hxx>
38 #include <drawview.hxx>
40 namespace sd {
42 void DrawViewShell::ExecIMap( SfxRequest const & rReq )
44 // during a slide show, nothing is executed!
45 if(HasCurrentFunction(SID_PRESENTATION) )
46 return;
48 if ( rReq.GetSlot() != SID_IMAP_EXEC )
49 return;
51 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
52 SdrMark* pMark = rMarkList.GetMark(0);
54 if ( !pMark )
55 return;
57 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
58 SvxIMapDlg* pDlg = ViewShell::Implementation::GetImageMapDialog();
60 if ( pDlg->GetEditingObject() == static_cast<void*>(pSdrObj) )
62 const ImageMap& rImageMap = pDlg->GetImageMap();
63 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
65 if ( !pIMapInfo )
66 pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
67 else
68 pIMapInfo->SetImageMap( rImageMap );
70 GetDoc()->SetChanged();
74 void DrawViewShell::GetIMapState( SfxItemSet& rSet )
76 bool bDisable = true;
78 if( GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
80 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
82 if ( rMarkList.GetMarkCount() == 1 )
84 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
86 SvxIMapDlg* pImageMapDialog = ViewShell::Implementation::GetImageMapDialog();
87 if ( ( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr /*|| pObj->ISA( SdrOle2Obj )*/ )
88 && pImageMapDialog!=nullptr
89 && ( pImageMapDialog->GetEditingObject() == static_cast<void const *>(pObj) ) )
91 bDisable = false;
96 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
99 void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
101 // during a slide show, nothing is executed!
102 if(HasCurrentFunction(SID_PRESENTATION))
103 return;
105 bool bDefault = false;
106 sal_uInt16 nSlot = rReq.GetSlot();
108 SdOptions* pOptions = SdModule::get()->GetSdOptions(GetDoc()->GetDocumentType());
109 std::shared_ptr<comphelper::ConfigurationChanges> batch(
110 comphelper::ConfigurationChanges::create());
112 switch( nSlot )
114 case SID_SOLID_CREATE:
115 pOptions->SetSolidDragging( !mpDrawView->IsSolidDragging() );
116 break;
118 // Grid- / Help lines option
119 case SID_GRID_VISIBLE: // not here yet!
121 pOptions->SetGridVisible( !mpDrawView->IsGridVisible() );
123 break;
125 case SID_GRID_USE:
127 pOptions->SetUseGridSnap( !mpDrawView->IsGridSnap() );
129 break;
131 case SID_HELPLINES_VISIBLE: // not here yet!
133 if ( GetDoc()->GetDocumentType() == DocumentType::Impress )
134 officecfg::Office::Impress::Layout::Display::Helpline::set(!mpDrawView->IsHlplVisible(), batch);
135 else
136 officecfg::Office::Draw::Layout::Display::Helpline::set(!mpDrawView->IsHlplVisible(), batch);
138 break;
140 case SID_HELPLINES_USE:
142 if (GetDoc()->GetDocumentType() == DocumentType::Impress)
143 officecfg::Office::Impress::Snap::Object::SnapLine::set(!mpDrawView->IsHlplSnap(), batch);
144 else
145 officecfg::Office::Draw::Snap::Object::SnapLine::set(!mpDrawView->IsHlplSnap(), batch);
147 break;
149 case SID_HELPLINES_MOVE:
151 if ( GetDoc()->GetDocumentType() == DocumentType::Impress )
152 officecfg::Office::Impress::Layout::Display::Guide::set(!mpDrawView->IsDragStripes(), batch);
153 else
154 officecfg::Office::Draw::Layout::Display::Guide::set(!mpDrawView->IsDragStripes(), batch);
156 break;
158 case SID_SNAP_BORDER:
160 if ( GetDoc()->GetDocumentType() == DocumentType::Impress )
161 officecfg::Office::Impress::Snap::Object::PageMargin::set( !mpDrawView->IsBordSnap(), batch );
162 else
163 officecfg::Office::Draw::Snap::Object::PageMargin::set( !mpDrawView->IsBordSnap(), batch );
165 break;
167 case SID_SNAP_FRAME:
169 if ( GetDoc()->GetDocumentType() == DocumentType::Impress )
170 officecfg::Office::Impress::Snap::Object::ObjectFrame::set(!mpDrawView->IsOFrmSnap(), batch);
171 else
172 officecfg::Office::Draw::Snap::Object::ObjectFrame::set(!mpDrawView->IsOFrmSnap(), batch);
174 break;
176 case SID_SNAP_POINTS:
178 if ( GetDoc()->GetDocumentType() == DocumentType::Impress )
179 officecfg::Office::Impress::Snap::Object::ObjectPoint::set( !mpDrawView->IsOPntSnap(), batch );
180 else
181 officecfg::Office::Draw::Snap::Object::ObjectPoint::set( !mpDrawView->IsOPntSnap(), batch );
183 break;
185 case SID_QUICKEDIT:
187 pOptions->SetQuickEdit( !mpDrawView->IsQuickTextEditMode() );
189 break;
191 case SID_PICK_THROUGH:
193 pOptions->SetPickThrough(
194 !mpDrawView->GetModel().IsPickThroughTransparentTextFrames() );
196 break;
198 case SID_DOUBLECLICK_TEXTEDIT:
200 pOptions->SetDoubleClickTextEdit( !mpFrameView->IsDoubleClickTextEdit() );
202 break;
204 case SID_CLICK_CHANGE_ROTATION:
206 pOptions->SetClickChangeRotation( !mpFrameView->IsClickChangeRotation() );
208 break;
210 default:
211 bDefault = true;
212 break;
215 if( bDefault )
216 return;
218 batch->commit();
219 pOptions->StoreConfig();
221 // Saves the configuration IMMEDIATELY
222 // SfxGetpApp()->SaveConfiguration();
223 WriteFrameViewData();
225 mpFrameView->Update( pOptions );
226 ReadFrameViewData( mpFrameView );
228 Invalidate( nSlot );
229 rReq.Done();
233 void DrawViewShell::GetOptionsBarState( SfxItemSet& rSet )
235 rSet.Put( SfxBoolItem( SID_SOLID_CREATE, mpDrawView->IsSolidDragging() ) );
236 rSet.Put( SfxBoolItem( SID_GRID_VISIBLE, mpDrawView->IsGridVisible() ) );
237 rSet.Put( SfxBoolItem( SID_GRID_USE, mpDrawView->IsGridSnap() ) );
238 rSet.Put( SfxBoolItem( SID_HELPLINES_VISIBLE, mpDrawView->IsHlplVisible() ) );
239 rSet.Put( SfxBoolItem( SID_HELPLINES_USE, mpDrawView->IsHlplSnap() ) );
240 rSet.Put( SfxBoolItem( SID_HELPLINES_MOVE, mpDrawView->IsDragStripes() ) );
242 rSet.Put( SfxBoolItem( SID_SNAP_BORDER, mpDrawView->IsBordSnap() ) );
243 rSet.Put( SfxBoolItem( SID_SNAP_FRAME, mpDrawView->IsOFrmSnap() ) );
244 rSet.Put( SfxBoolItem( SID_SNAP_POINTS, mpDrawView->IsOPntSnap() ) );
246 rSet.Put( SfxBoolItem( SID_QUICKEDIT, mpDrawView->IsQuickTextEditMode() ) );
247 rSet.Put( SfxBoolItem( SID_PICK_THROUGH,
248 mpDrawView->GetModel().IsPickThroughTransparentTextFrames() ) );
250 rSet.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT, mpFrameView->IsDoubleClickTextEdit() ) );
251 rSet.Put( SfxBoolItem( SID_CLICK_CHANGE_ROTATION, mpFrameView->IsClickChangeRotation() ) );
254 } // end of namespace sd
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */