cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / view / drviewsi.cxx
blob0398408249c0e7943116b69e25c341eee3bb57a7
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 <svx/xfillit0.hxx>
22 #include <editeng/eeitem.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svx/svxids.hrc>
26 #include <sfx2/dispatch.hxx>
27 #include <svx/float3d.hxx>
28 #include <svx/f3dchild.hxx>
29 #include <vcl/weld.hxx>
31 #include <strings.hrc>
33 #include <drawdoc.hxx>
34 #include <Window.hxx>
35 #include <sdresid.hxx>
37 using namespace ::com::sun::star;
39 namespace sd {
41 /**
42 * Handle SfxRequests for EffekteWindow
44 void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
46 CheckLineTo (rReq);
48 sal_uInt16 nSId = rReq.GetSlot();
50 switch( nSId )
52 case SID_3D_INIT:
54 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
55 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
56 if( pWindow )
58 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
59 if( p3DWin )
60 p3DWin->InitColorLB();
63 break;
65 case SID_3D_STATE:
67 Update3DWindow();
69 break;
71 case SID_3D_ASSIGN:
73 AssignFrom3DWindow();
75 break;
80 void DrawViewShell::Update3DWindow()
82 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
83 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
84 if( pWindow )
86 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
87 if( p3DWin && p3DWin->IsUpdateMode() )
89 SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
90 p3DWin->Update( aTmpItemSet );
95 /*----------------------------------------------------------------------------*/
97 void DrawViewShell::AssignFrom3DWindow()
99 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
100 SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
101 if( !pWin )
102 return;
104 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWin->GetWindow() );
105 if( !(p3DWin && GetView()) )
106 return;
108 if(!GetView()->IsPresObjSelected())
110 SfxItemSetFixed<SDRATTR_START, SDRATTR_END> aSet( GetDoc()->GetPool() );
111 p3DWin->GetAttr( aSet );
113 // own UNDO-compounding also around transformation in 3D
114 GetView()->BegUndo(SdResId(STR_UNDO_APPLY_3D_FAVOURITE));
116 if(GetView()->IsConvertTo3DObjPossible())
118 // assign only text-attribute
119 SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aTextSet( GetDoc()->GetPool() );
120 aTextSet.Put( aSet, false );
121 GetView()->SetAttributes( aTextSet );
123 // transform text into 3D
124 sal_uInt16 nSId = SID_CONVERT_TO_3D;
125 SfxBoolItem aItem( nSId, true );
126 GetViewFrame()->GetDispatcher()->ExecuteList(
127 nSId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
128 { &aItem });
130 // Determine if a FILL attribute is set.
131 // If not, hard set a fill attribute
132 drawing::FillStyle eFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue();
133 if(eFillStyle == drawing::FillStyle_NONE)
134 aSet.Put(XFillStyleItem (drawing::FillStyle_SOLID));
136 // remove some 3DSCENE attributes since these were
137 // created by convert to 3D and may not be changed
138 // to the defaults again.
139 aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
140 aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
141 aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
144 // assign attribute
145 GetView()->Set3DAttributes( aSet );
147 // end UNDO
148 GetView()->EndUndo();
150 else
152 vcl::Window* pWindow = GetActiveWindow();
153 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr,
154 VclMessageType::Info, VclButtonsType::Ok,
155 SdResId(STR_ACTION_NOTPOSSIBLE)));
156 xInfoBox->run();
159 // get focus back
160 GetActiveWindow()->GrabFocus();
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */