xref: /AOO41X/main/sd/source/ui/view/drviewsi.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawViewShell.hxx"
28 #include <svx/xtable.hxx>
29 #include "sdattr.hxx"
30 #include <svl/aeitem.hxx>
31 #include <editeng/eeitem.hxx>
32 #include <sfx2/request.hxx>
33 #include <svx/svditer.hxx>
34 #include <editeng/colritem.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #ifndef _SVXIDS_HRC
37 #include <svx/svxids.hrc>
38 #endif
39 #include <svx/svdundo.hxx>
40 #include <svx/view3d.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <svx/float3d.hxx>
43 #include <svx/f3dchild.hxx>
44 #ifndef _SVX_DIALOGS_HRC //autogen
45 #include <svx/dialogs.hrc>
46 #endif
47 #include <vcl/msgbox.hxx>
48 
49 
50 #include "app.hrc"
51 #include "strings.hrc"
52 
53 #include "drawdoc.hxx"
54 #include "DrawDocShell.hxx"
55 #include "anminfo.hxx"
56 #include "unoaprms.hxx"                 // Undo-Action
57 #include "sdundogr.hxx"                 // Undo Gruppe
58 #include "drawview.hxx"
59 #include "Window.hxx"
60 #include "sdresid.hxx"
61 
62 using namespace ::com::sun::star;
63 
64 namespace sd {
65 
66 #define ATTR_MISSING    0       // Attribut nicht verfuegbar
67 #define ATTR_MIXED      1       // Attribut uneindeutig (bei Mehrfachselektion)
68 #define ATTR_SET        2       // Attribut eindeutig
69 
70 #define ITEMVALUE(ItemSet,Id,Cast)  ((const Cast&)(ItemSet).Get(Id)).GetValue()
71 
72 /*************************************************************************
73 |*
74 |* SfxRequests fuer EffekteWindow bearbeiten
75 |*
76 \************************************************************************/
77 
ExecEffectWin(SfxRequest & rReq)78 void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
79 {
80     CheckLineTo (rReq);
81 
82     sal_uInt16 nSId = rReq.GetSlot();
83 
84     switch( nSId )
85     {
86         case SID_3D_INIT:
87         {
88             sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
89             SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
90             if( pWindow )
91             {
92                 Svx3DWin* p3DWin = (Svx3DWin*)( pWindow->GetWindow() );
93                 if( p3DWin )
94                     p3DWin->InitColorLB( GetDoc() );
95             }
96         }
97         break;
98 
99         case SID_3D_STATE:
100         {
101             Update3DWindow();
102         }
103         break;
104 
105         case SID_3D_ASSIGN:
106         {
107             AssignFrom3DWindow();
108         }
109         break;
110 
111     }
112 }
113 
114 /*************************************************************************
115 |*
116 |* 3D - Assign / Update
117 |*
118 \************************************************************************/
Update3DWindow()119 void DrawViewShell::Update3DWindow()
120 {
121     sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
122     SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
123     if( pWindow )
124     {
125         Svx3DWin* p3DWin = (Svx3DWin*) pWindow->GetWindow();
126         if( p3DWin && p3DWin->IsUpdateMode() )
127         {
128             SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
129             p3DWin->Update( aTmpItemSet );
130         }
131     }
132 }
133 
134 /*----------------------------------------------------------------------------*/
135 
AssignFrom3DWindow()136 void DrawViewShell::AssignFrom3DWindow()
137 {
138     sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
139     SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
140     if( pWin )
141     {
142         Svx3DWin* p3DWin = (Svx3DWin*) pWin->GetWindow();
143         if( p3DWin && GetView() )
144         {
145             if(!GetView()->IsPresObjSelected())
146             {
147                 SfxItemSet aSet( GetDoc()->GetPool(),
148                     SDRATTR_START,  SDRATTR_END,
149                     0, 0);
150                 p3DWin->GetAttr( aSet );
151 
152                 // Eigene UNDO-Klammerung auch um die Wandlung in 3D
153                 GetView()->BegUndo(String(SdResId(STR_UNDO_APPLY_3D_FAVOURITE)));
154 
155                 if(GetView()->IsConvertTo3DObjPossible())
156                 {
157                     // Nur TextAttribute zuweisen
158                     SfxItemSet aTextSet( GetDoc()->GetPool(),
159                         EE_ITEMS_START, EE_ITEMS_END, 0 );
160                     aTextSet.Put( aSet, sal_False );
161                     GetView()->SetAttributes( aTextSet );
162 
163                     // Text in 3D umwandeln
164                     sal_uInt16 nSId = SID_CONVERT_TO_3D;
165                     SfxBoolItem aItem( nSId, sal_True );
166                     GetViewFrame()->GetDispatcher()->Execute(
167                         nSId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
168 
169                     // Feststellen, ob ein FILL_Attribut gesetzt ist.
170                     // Falls nicht, Fuellattribut hart setzen
171                     XFillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
172                     if(eFillStyle == XFILL_NONE)
173                         aSet.Put(XFillStyleItem (XFILL_SOLID));
174 
175                     // remove some 3DSCENE attributes since these were
176                     // created by convert to 3D and may not be changed
177                     // to the defaults again.
178                     aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
179                     aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
180                     aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
181                 }
182 
183                 // Attribute zuweisen
184                 GetView()->Set3DAttributes( aSet );
185 
186                 // Ende UNDO
187                 GetView()->EndUndo();
188             }
189             else
190             {
191                 InfoBox aInfoBox (
192                     GetActiveWindow(),
193                     String(SdResId(STR_ACTION_NOTPOSSIBLE)));
194                 aInfoBox.Execute();
195             }
196 
197             // Focus zurueckholen
198             GetActiveWindow()->GrabFocus();
199         }
200     }
201 }
202 
203 }
204