Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
37 :
38 : #include "app.hrc"
39 : #include "strings.hrc"
40 :
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"
49 :
50 : using namespace ::com::sun::star;
51 :
52 : namespace sd {
53 :
54 : #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
55 :
56 : /**
57 : * Handle SfxRequests for EffekteWindow
58 : */
59 165 : void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
60 : {
61 165 : CheckLineTo (rReq);
62 :
63 165 : sal_uInt16 nSId = rReq.GetSlot();
64 :
65 165 : switch( nSId )
66 : {
67 : case SID_3D_INIT:
68 : {
69 0 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
70 0 : SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
71 0 : if( pWindow )
72 : {
73 0 : Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
74 0 : if( p3DWin )
75 0 : p3DWin->InitColorLB( GetDoc() );
76 : }
77 : }
78 0 : break;
79 :
80 : case SID_3D_STATE:
81 : {
82 165 : Update3DWindow();
83 : }
84 165 : break;
85 :
86 : case SID_3D_ASSIGN:
87 : {
88 0 : AssignFrom3DWindow();
89 : }
90 0 : break;
91 :
92 : }
93 165 : }
94 :
95 165 : void DrawViewShell::Update3DWindow()
96 : {
97 165 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
98 165 : SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
99 165 : if( pWindow )
100 : {
101 0 : Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWindow->GetWindow() );
102 0 : if( p3DWin && p3DWin->IsUpdateMode() )
103 : {
104 0 : SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
105 0 : p3DWin->Update( aTmpItemSet );
106 : }
107 : }
108 165 : }
109 :
110 : /*----------------------------------------------------------------------------*/
111 :
112 0 : void DrawViewShell::AssignFrom3DWindow()
113 : {
114 0 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
115 0 : SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
116 0 : if( pWin )
117 : {
118 0 : Svx3DWin* p3DWin = static_cast<Svx3DWin*>( pWin->GetWindow() );
119 0 : if( p3DWin && GetView() )
120 : {
121 0 : if(!GetView()->IsPresObjSelected())
122 : {
123 0 : SfxItemSet aSet( GetDoc()->GetPool(),
124 : SDRATTR_START, SDRATTR_END,
125 0 : 0, 0);
126 0 : p3DWin->GetAttr( aSet );
127 :
128 : // own UNDO-compounding also around transformation in 3D
129 0 : GetView()->BegUndo(SD_RESSTR(STR_UNDO_APPLY_3D_FAVOURITE));
130 :
131 0 : if(GetView()->IsConvertTo3DObjPossible())
132 : {
133 : // assign only text-attribute
134 0 : SfxItemSet aTextSet( GetDoc()->GetPool(),
135 0 : EE_ITEMS_START, EE_ITEMS_END, 0 );
136 0 : aTextSet.Put( aSet, false );
137 0 : GetView()->SetAttributes( aTextSet );
138 :
139 : // transform text into 3D
140 0 : sal_uInt16 nSId = SID_CONVERT_TO_3D;
141 0 : SfxBoolItem aItem( nSId, true );
142 : GetViewFrame()->GetDispatcher()->Execute(
143 0 : nSId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
144 :
145 : // Determine if a FILL attribute is set.
146 : // If not, hard set a fill attribute
147 0 : drawing::FillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
148 0 : if(eFillStyle == drawing::FillStyle_NONE)
149 0 : aSet.Put(XFillStyleItem (drawing::FillStyle_SOLID));
150 :
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 0 : aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
155 0 : aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
156 0 : aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
157 : }
158 :
159 : // assign attribute
160 0 : GetView()->Set3DAttributes( aSet );
161 :
162 : // end UNDO
163 0 : GetView()->EndUndo();
164 : }
165 : else
166 : {
167 : ScopedVclPtrInstance<InfoBox> aInfoBox (
168 0 : GetActiveWindow(),
169 0 : SD_RESSTR(STR_ACTION_NOTPOSSIBLE));
170 0 : aInfoBox->Execute();
171 : }
172 :
173 : // get focus back
174 0 : GetActiveWindow()->GrabFocus();
175 : }
176 : }
177 0 : }
178 :
179 66 : }
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|