bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / view / drviewsi.cxx
blob930e9b0305ce11017893691e384c3b8fd704d95c
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/xtable.hxx>
22 #include "sdattr.hxx"
23 #include <svl/aeitem.hxx>
24 #include <editeng/eeitem.hxx>
25 #include <sfx2/request.hxx>
26 #include <svx/svditer.hxx>
27 #include <editeng/colritem.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <svx/svxids.hrc>
30 #include <svx/svdundo.hxx>
31 #include <svx/view3d.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <svx/float3d.hxx>
34 #include <svx/f3dchild.hxx>
35 #include <svx/dialogs.hrc>
36 #include <vcl/msgbox.hxx>
38 #include "app.hrc"
39 #include "strings.hrc"
41 #include "drawdoc.hxx"
42 #include "DrawDocShell.hxx"
43 #include "anminfo.hxx"
44 #include "unoaprms.hxx"
45 #include "sdundogr.hxx"
46 #include "drawview.hxx"
47 #include "Window.hxx"
48 #include "sdresid.hxx"
50 using namespace ::com::sun::star;
52 namespace sd {
54 #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
56 /**
57 * Handle SfxRequests for EffekteWindow
59 void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
61 CheckLineTo (rReq);
63 sal_uInt16 nSId = rReq.GetSlot();
65 switch( nSId )
67 case SID_3D_INIT:
69 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
70 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
71 if( pWindow )
73 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
74 if( p3DWin )
75 p3DWin->InitColorLB( GetDoc() );
78 break;
80 case SID_3D_STATE:
82 Update3DWindow();
84 break;
86 case SID_3D_ASSIGN:
88 AssignFrom3DWindow();
90 break;
95 void DrawViewShell::Update3DWindow()
97 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
98 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
99 if( pWindow )
101 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
102 if( p3DWin && p3DWin->IsUpdateMode() )
104 SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
105 p3DWin->Update( aTmpItemSet );
110 /*----------------------------------------------------------------------------*/
112 void DrawViewShell::AssignFrom3DWindow()
114 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
115 SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
116 if( pWin )
118 Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWin->GetWindow() );
119 if( p3DWin && GetView() )
121 if(!GetView()->IsPresObjSelected())
123 SfxItemSet aSet( GetDoc()->GetPool(),
124 SDRATTR_START, SDRATTR_END,
125 0, 0);
126 p3DWin->GetAttr( aSet );
128 // own UNDO-compounding also around transformation in 3D
129 GetView()->BegUndo(SD_RESSTR(STR_UNDO_APPLY_3D_FAVOURITE));
131 if(GetView()->IsConvertTo3DObjPossible())
133 // assign only text-attribute
134 SfxItemSet aTextSet( GetDoc()->GetPool(),
135 EE_ITEMS_START, EE_ITEMS_END, 0 );
136 aTextSet.Put( aSet, false );
137 GetView()->SetAttributes( aTextSet );
139 // transform text into 3D
140 sal_uInt16 nSId = SID_CONVERT_TO_3D;
141 SfxBoolItem aItem( nSId, true );
142 GetViewFrame()->GetDispatcher()->Execute(
143 nSId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
145 // Determine if a FILL attribute is set.
146 // If not, hard set a fill attribute
147 drawing::FillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
148 if(eFillStyle == drawing::FillStyle_NONE)
149 aSet.Put(XFillStyleItem (drawing::FillStyle_SOLID));
151 // remove some 3DSCENE attributes since these were
152 // created by convert to 3D and may not be changed
153 // to the defaults again.
154 aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
155 aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
156 aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
159 // assign attribute
160 GetView()->Set3DAttributes( aSet );
162 // end UNDO
163 GetView()->EndUndo();
165 else
167 ScopedVclPtrInstance<InfoBox> aInfoBox (
168 GetActiveWindow(),
169 SD_RESSTR(STR_ACTION_NOTPOSSIBLE));
170 aInfoBox->Execute();
173 // get focus back
174 GetActiveWindow()->GrabFocus();
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */