xref: /core/svx/source/engine3d/float3d.cxx (revision bc91cc47)
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 <sal/config.h>
21 
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/module.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svl/eitem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svl/itempool.hxx>
28 #include <svtools/colrdlg.hxx>
29 #include <svx/colorbox.hxx>
30 #include <svx/f3dchild.hxx>
31 #include <svx/xfillit0.hxx>
32 #include <svx/xflclit.hxx>
33 #include <svx/xlineit0.hxx>
34 #include <svx/fmmodel.hxx>
35 #include <svx/dlgutil.hxx>
36 #include <svx/obj3d.hxx>
37 #include <svx/sdshitm.hxx>
38 #include <svx/svx3ditems.hxx>
39 
40 #include <svx/dialmgr.hxx>
41 #include <svx/viewpt3d.hxx>
42 
43 #include <svx/svxids.hrc>
44 #include <svx/strings.hrc>
45 
46 #include <editeng/colritem.hxx>
47 #include <osl/diagnose.h>
48 #include <svx/e3ditem.hxx>
49 #include <svl/whiter.hxx>
50 #include <svtools/unitconv.hxx>
51 
52 #include <svx/float3d.hxx>
53 #include <com/sun/star/drawing/TextureKind2.hpp>
54 
55 #include <bitmaps.hlst>
56 
57 using namespace com::sun::star;
58 
59 SFX_IMPL_DOCKINGWINDOW_WITHID( Svx3DChildWindow, SID_3D_WIN )
60 
61 struct Svx3DWinImpl
62 {
63     SfxItemPool*        pPool;
64 };
65 
66 namespace {
67     /** Get the dispatcher from the current view frame, or, if that is not
68         available, from the given bindings.
69         @param pBindings
70             May be NULL.
71         @returns NULL when both the current view frame is NULL and the given
72             bindings are NULL.
73     */
LocalGetDispatcher(const SfxBindings * pBindings)74     SfxDispatcher* LocalGetDispatcher (const SfxBindings* pBindings)
75     {
76         SfxDispatcher* pDispatcher = nullptr;
77 
78         if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
79             pDispatcher = pViewFrame->GetDispatcher();
80         else if (pBindings != nullptr)
81             pDispatcher = pBindings->GetDispatcher();
82 
83         return pDispatcher;
84     }
85 }
86 
Svx3DWin(SfxBindings * pInBindings,SfxChildWindow * pCW,vcl::Window * pParent)87 Svx3DWin::Svx3DWin(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* pParent)
88     : SfxDockingWindow(pInBindings, pCW, pParent,
89         u"Docking3DEffects"_ustr, u"svx/ui/docking3deffects.ui"_ustr)
90 
91     , m_xBtnGeo(m_xBuilder->weld_toggle_button(u"geometry"_ustr))
92     , m_xBtnRepresentation(m_xBuilder->weld_toggle_button(u"representation"_ustr))
93     , m_xBtnLight(m_xBuilder->weld_toggle_button(u"light"_ustr))
94     , m_xBtnTexture(m_xBuilder->weld_toggle_button(u"texture"_ustr))
95     , m_xBtnMaterial(m_xBuilder->weld_toggle_button(u"material"_ustr))
96     , m_xBtnUpdate(m_xBuilder->weld_toggle_button(u"update"_ustr))
97     , m_xBtnAssign(m_xBuilder->weld_button(u"assign"_ustr))
98 
99     , m_xFLGeometrie(m_xBuilder->weld_container(u"geoframe"_ustr))
100     , m_xFtPercentDiagonal(m_xBuilder->weld_label(u"diagonalft"_ustr))
101     , m_xMtrPercentDiagonal(m_xBuilder->weld_metric_spin_button(u"diagonal"_ustr, FieldUnit::PERCENT))
102     , m_xFtBackscale(m_xBuilder->weld_label(u"scaleddepthft"_ustr))
103     , m_xMtrBackscale(m_xBuilder->weld_metric_spin_button(u"scaleddepth"_ustr, FieldUnit::PERCENT))
104     , m_xFtEndAngle(m_xBuilder->weld_label(u"angleft"_ustr))
105     , m_xMtrEndAngle(m_xBuilder->weld_metric_spin_button(u"angle"_ustr, FieldUnit::DEGREE))
106     , m_xFtDepth(m_xBuilder->weld_label(u"depthft"_ustr))
107     , m_xMtrDepth(m_xBuilder->weld_metric_spin_button(u"depth"_ustr, FieldUnit::CM))
108 
109     , m_xFLSegments(m_xBuilder->weld_container(u"segmentsframe"_ustr))
110     , m_xNumHorizontal(m_xBuilder->weld_spin_button(u"hori"_ustr))
111     , m_xNumVertical(m_xBuilder->weld_spin_button(u"veri"_ustr))
112 
113     , m_xFLNormals(m_xBuilder->weld_container(u"normals"_ustr))
114     , m_xBtnNormalsObj(m_xBuilder->weld_toggle_button(u"objspecific"_ustr))
115     , m_xBtnNormalsFlat(m_xBuilder->weld_toggle_button(u"flat"_ustr))
116     , m_xBtnNormalsSphere(m_xBuilder->weld_toggle_button(u"spherical"_ustr))
117     , m_xBtnNormalsInvert(m_xBuilder->weld_toggle_button(u"invertnormals"_ustr))
118     , m_xBtnTwoSidedLighting(m_xBuilder->weld_toggle_button(u"doublesidedillum"_ustr))
119     , m_xBtnDoubleSided(m_xBuilder->weld_toggle_button(u"doublesided"_ustr))
120 
121     , m_xFLRepresentation(m_xBuilder->weld_container(u"shadingframe"_ustr))
122     , m_xLbShademode(m_xBuilder->weld_combo_box(u"mode"_ustr))
123 
124     , m_xFLShadow(m_xBuilder->weld_container(u"shadowframe"_ustr))
125     , m_xBtnShadow3d(m_xBuilder->weld_toggle_button(u"shadow"_ustr))
126     , m_xFtSlant(m_xBuilder->weld_label(u"slantft"_ustr))
127     , m_xMtrSlant(m_xBuilder->weld_metric_spin_button(u"slant"_ustr, FieldUnit::DEGREE))
128 
129     , m_xFLCamera(m_xBuilder->weld_container(u"cameraframe"_ustr))
130     , m_xMtrDistance(m_xBuilder->weld_metric_spin_button(u"distance"_ustr, FieldUnit::CM))
131     , m_xMtrFocalLength(m_xBuilder->weld_metric_spin_button(u"focal"_ustr, FieldUnit::CM))
132 
133     , m_xFLLight(m_xBuilder->weld_container(u"illumframe"_ustr))
134     , m_xBtnLight1(new LightButton(m_xBuilder->weld_toggle_button(u"light1"_ustr)))
135     , m_xBtnLight2(new LightButton(m_xBuilder->weld_toggle_button(u"light2"_ustr)))
136     , m_xBtnLight3(new LightButton(m_xBuilder->weld_toggle_button(u"light3"_ustr)))
137     , m_xBtnLight4(new LightButton(m_xBuilder->weld_toggle_button(u"light4"_ustr)))
138     , m_xBtnLight5(new LightButton(m_xBuilder->weld_toggle_button(u"light5"_ustr)))
139     , m_xBtnLight6(new LightButton(m_xBuilder->weld_toggle_button(u"light6"_ustr)))
140     , m_xBtnLight7(new LightButton(m_xBuilder->weld_toggle_button(u"light7"_ustr)))
141     , m_xBtnLight8(new LightButton(m_xBuilder->weld_toggle_button(u"light8"_ustr)))
142     , m_xLbLight1(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor1"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0302null143     , m_xLbLight2(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor2"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0402null144     , m_xLbLight3(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor3"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0502null145     , m_xLbLight4(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor4"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0602null146     , m_xLbLight5(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor5"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0702null147     , m_xLbLight6(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor6"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0802null148     , m_xLbLight7(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor7"_ustr), [this]{ return GetFrameWeld(); }))
__anon02f6dc4f0902null149     , m_xLbLight8(new ColorListBox(m_xBuilder->weld_menu_button(u"lightcolor8"_ustr), [this]{ return GetFrameWeld(); }))
150     , m_xBtnLightColor(m_xBuilder->weld_button(u"colorbutton1"_ustr))
__anon02f6dc4f0a02null151     , m_xLbAmbientlight(new ColorListBox(m_xBuilder->weld_menu_button(u"ambientcolor"_ustr), [this]{ return GetFrameWeld(); }))
152     , m_xBtnAmbientColor(m_xBuilder->weld_button(u"colorbutton2"_ustr))
153 
154     , m_xFLTexture(m_xBuilder->weld_container(u"textureframe"_ustr))
155     , m_xBtnTexLuminance(m_xBuilder->weld_toggle_button(u"textype"_ustr))
156     , m_xBtnTexColor(m_xBuilder->weld_toggle_button(u"texcolor"_ustr))
157     , m_xBtnTexReplace(m_xBuilder->weld_toggle_button(u"texreplace"_ustr))
158     , m_xBtnTexModulate(m_xBuilder->weld_toggle_button(u"texmodulate"_ustr))
159     , m_xBtnTexObjectX(m_xBuilder->weld_toggle_button(u"texobjx"_ustr))
160     , m_xBtnTexParallelX(m_xBuilder->weld_toggle_button(u"texparallelx"_ustr))
161     , m_xBtnTexCircleX(m_xBuilder->weld_toggle_button(u"texcirclex"_ustr))
162     , m_xBtnTexObjectY(m_xBuilder->weld_toggle_button(u"texobjy"_ustr))
163     , m_xBtnTexParallelY(m_xBuilder->weld_toggle_button(u"texparallely"_ustr))
164     , m_xBtnTexCircleY(m_xBuilder->weld_toggle_button(u"texcircley"_ustr))
165     , m_xBtnTexFilter(m_xBuilder->weld_toggle_button(u"texfilter"_ustr))
166 
167     , m_xFLMaterial(m_xBuilder->weld_container(u"materialframe"_ustr))
168     , m_xLbMatFavorites(m_xBuilder->weld_combo_box(u"favorites"_ustr))
__anon02f6dc4f0b02null169     , m_xLbMatColor(new ColorListBox(m_xBuilder->weld_menu_button(u"objcolor"_ustr), [this]{ return GetFrameWeld(); }))
170     , m_xBtnMatColor(m_xBuilder->weld_button(u"colorbutton3"_ustr))
__anon02f6dc4f0c02null171     , m_xLbMatEmission(new ColorListBox(m_xBuilder->weld_menu_button(u"illumcolor"_ustr), [this]{ return GetFrameWeld(); }))
172     , m_xBtnEmissionColor(m_xBuilder->weld_button(u"colorbutton4"_ustr))
173 
174     , m_xFLMatSpecular(m_xBuilder->weld_container(u"specframe"_ustr))
__anon02f6dc4f0d02null175     , m_xLbMatSpecular(new ColorListBox(m_xBuilder->weld_menu_button(u"speccolor"_ustr), [this]{ return GetFrameWeld(); }))
176     , m_xBtnSpecularColor(m_xBuilder->weld_button(u"colorbutton5"_ustr))
177     , m_xMtrMatSpecularIntensity(m_xBuilder->weld_metric_spin_button(u"intensity"_ustr, FieldUnit::PERCENT))
178 
179     , m_xCtlPreview(new Svx3DPreviewControl)
180     , m_xCtlPreviewWin(new weld::CustomWeld(*m_xBuilder, u"preview"_ustr, *m_xCtlPreview))
181 
182     , m_xLightPreviewGrid(m_xBuilder->weld_container(u"lightpreviewgrid"_ustr))
183     , m_xHoriScale(m_xBuilder->weld_scale(u"horiscale"_ustr))
184     , m_xVertScale(m_xBuilder->weld_scale(u"vertscale"_ustr))
185     , m_xBtn_Corner(m_xBuilder->weld_button(u"corner"_ustr))
186     , m_xLightPreview(new Svx3DLightControl)
187     , m_xCtlLightPreviewWin(new weld::CustomWeld(*m_xBuilder, u"lightpreview"_ustr, *m_xLightPreview))
188     , m_xCtlLightPreview(new SvxLightCtl3D(*m_xLightPreview, *m_xHoriScale, *m_xVertScale, *m_xBtn_Corner)) // TODO might be other body widget as arg 1
189 
190     , m_xBtnConvertTo3D(m_xBuilder->weld_button(u"to3d"_ustr))
191     , m_xBtnLatheObject(m_xBuilder->weld_button(u"tolathe"_ustr))
192     , m_xBtnPerspective(m_xBuilder->weld_toggle_button(u"perspective"_ustr))
193 
194     , bUpdate(false)
195     , eViewType(ViewType3D::Geo)
196     , pBindings(pInBindings)
197     , mpImpl(new Svx3DWinImpl)
198     , ePoolUnit(MapUnit::MapMM)
199 {
200     SetText(SvxResId(RID_SVXDLG_FLOAT3D_STR_TITLE));
201 
202     weld::DrawingArea* pDrawingArea = m_xCtlPreview->GetDrawingArea();
203     Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(83, 76), MapMode(MapUnit::MapAppFont)));
204     pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
205     m_xCtlPreview->SetOutputSizePixel(aSize);
206 
207     m_xLightPreviewGrid->set_size_request(aSize.Width(), aSize.Height());
208     pDrawingArea = m_xLightPreview->GetDrawingArea();
209     pDrawingArea->set_size_request(42, 42); // small to fit to m_xLightPreviewGrid
210 
211     mpImpl->pPool = nullptr;
212 
213     // Set Metric
214     eFUnit = pInBindings->GetDispatcher()->GetModule()->GetFieldUnit();
215 
216     m_xMtrDepth->set_unit( eFUnit );
217     m_xMtrDistance->set_unit( eFUnit );
218     m_xMtrFocalLength->set_unit( eFUnit );
219 
220     pControllerItem.reset( new Svx3DCtrlItem(SID_3D_STATE, pBindings) );
221     pConvertTo3DItem.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D, pBindings) );
222     pConvertTo3DLatheItem.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D_LATHE_FAST, pBindings) );
223 
224     m_xBtnAssign->connect_clicked( LINK( this, Svx3DWin, ClickAssignHdl ) );
225     m_xBtnUpdate->connect_toggled( LINK( this, Svx3DWin, ClickUpdateHdl ) );
226 
227     Link<weld::Button&,void> aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
228     m_xBtnGeo->connect_clicked( aLink );
229     m_xBtnRepresentation->connect_clicked( aLink );
230     m_xBtnLight->connect_clicked( aLink );
231     m_xBtnTexture->connect_clicked( aLink );
232     m_xBtnMaterial->connect_clicked( aLink );
233 
234     aLink = LINK( this, Svx3DWin, ClickHdl );
235     m_xBtnPerspective->connect_clicked( aLink );
236     m_xBtnConvertTo3D->connect_clicked( aLink );
237     m_xBtnLatheObject->connect_clicked( aLink );
238 
239     // Geometry
240     m_xBtnNormalsObj->connect_clicked( aLink );
241     m_xBtnNormalsFlat->connect_clicked( aLink );
242     m_xBtnNormalsSphere->connect_clicked( aLink );
243     m_xBtnTwoSidedLighting->connect_clicked( aLink );
244     m_xBtnNormalsInvert->connect_clicked( aLink );
245     m_xBtnDoubleSided->connect_clicked( aLink );
246 
247     // Representation
248     m_xBtnShadow3d->connect_clicked( aLink );
249 
250     // Lighting
251     m_xBtnLight1->connect_clicked( aLink );
252     m_xBtnLight2->connect_clicked( aLink );
253     m_xBtnLight3->connect_clicked( aLink );
254     m_xBtnLight4->connect_clicked( aLink );
255     m_xBtnLight5->connect_clicked( aLink );
256     m_xBtnLight6->connect_clicked( aLink );
257     m_xBtnLight7->connect_clicked( aLink );
258     m_xBtnLight8->connect_clicked( aLink );
259 
260     // Textures
261     m_xBtnTexLuminance->connect_clicked( aLink );
262     m_xBtnTexColor->connect_clicked( aLink );
263     m_xBtnTexReplace->connect_clicked( aLink );
264     m_xBtnTexModulate->connect_clicked( aLink );
265     m_xBtnTexParallelX->connect_clicked( aLink );
266     m_xBtnTexCircleX->connect_clicked( aLink );
267     m_xBtnTexObjectX->connect_clicked( aLink );
268     m_xBtnTexParallelY->connect_clicked( aLink );
269     m_xBtnTexCircleY->connect_clicked( aLink );
270     m_xBtnTexObjectY->connect_clicked( aLink );
271     m_xBtnTexFilter->connect_clicked( aLink );
272 
273     // Material
274     aLink = LINK( this, Svx3DWin, ClickColorHdl );
275     m_xBtnLightColor->connect_clicked( aLink );
276     m_xBtnAmbientColor->connect_clicked( aLink );
277     m_xBtnMatColor->connect_clicked( aLink );
278     m_xBtnEmissionColor->connect_clicked( aLink );
279     m_xBtnSpecularColor->connect_clicked( aLink );
280 
281 
282     Link<weld::ComboBox&,void> aLink2 = LINK( this, Svx3DWin, SelectHdl );
283     Link<ColorListBox&,void> aLink4 = LINK( this, Svx3DWin, SelectColorHdl );
284     m_xLbMatFavorites->connect_changed( aLink2 );
285     m_xLbMatColor->SetSelectHdl( aLink4 );
286     m_xLbMatEmission->SetSelectHdl( aLink4 );
287     m_xLbMatSpecular->SetSelectHdl( aLink4 );
288     m_xLbLight1->SetSelectHdl( aLink4 );
289     m_xLbLight2->SetSelectHdl( aLink4 );
290     m_xLbLight3->SetSelectHdl( aLink4 );
291     m_xLbLight4->SetSelectHdl( aLink4 );
292     m_xLbLight5->SetSelectHdl( aLink4 );
293     m_xLbLight6->SetSelectHdl( aLink4 );
294     m_xLbLight7->SetSelectHdl( aLink4 );
295     m_xLbLight8->SetSelectHdl( aLink4 );
296     m_xLbAmbientlight->SetSelectHdl( aLink4 );
297     m_xLbShademode->connect_changed( aLink2 );
298 
299     Link<weld::MetricSpinButton&,void> aLink3 = LINK( this, Svx3DWin, ModifyMetricHdl );
300     Link<weld::SpinButton&,void> aLink5 = LINK( this, Svx3DWin, ModifySpinHdl );
301     m_xMtrMatSpecularIntensity->connect_value_changed( aLink3 );
302     m_xNumHorizontal->connect_value_changed( aLink5 );
303     m_xNumVertical->connect_value_changed( aLink5 );
304     m_xMtrSlant->connect_value_changed( aLink3 );
305 
306     // Preview callback
307     m_xCtlLightPreview->SetUserSelectionChangeCallback(LINK( this, Svx3DWin, ChangeSelectionCallbackHdl ));
308 
309     aSize = GetOutputSizePixel();
310     SetMinOutputSizePixel( aSize );
311 
312     Construct();
313 
314     // Initiation of the initialization of the ColorLBs
315     SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
316     if (pDispatcher != nullptr)
317     {
318         SfxBoolItem aItem( SID_3D_INIT, true );
319         pDispatcher->ExecuteList(SID_3D_INIT,
320                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
321     }
322 
323     Reset();
324 
325     //lock down the size of the initial largest default mode as the permanent size
326     aSize = get_preferred_size();
327     set_width_request(aSize.Width());
328     set_height_request(aSize.Height());
329 }
330 
~Svx3DWin()331 Svx3DWin::~Svx3DWin()
332 {
333     disposeOnce();
334 }
335 
dispose()336 void Svx3DWin::dispose()
337 {
338     pModel.reset();
339 
340     pControllerItem.reset();
341     pConvertTo3DItem.reset();
342     pConvertTo3DLatheItem.reset();
343 
344     mpImpl.reset();
345 
346     m_xBtnGeo.reset();
347     m_xBtnRepresentation.reset();
348     m_xBtnLight.reset();
349     m_xBtnTexture.reset();
350     m_xBtnMaterial.reset();
351     m_xBtnUpdate.reset();
352     m_xBtnAssign.reset();
353     m_xFLGeometrie.reset();
354     m_xFtPercentDiagonal.reset();
355     m_xMtrPercentDiagonal.reset();
356     m_xFtBackscale.reset();
357     m_xMtrBackscale.reset();
358     m_xFtEndAngle.reset();
359     m_xMtrEndAngle.reset();
360     m_xFtDepth.reset();
361     m_xMtrDepth.reset();
362     m_xFLSegments.reset();
363     m_xNumHorizontal.reset();
364     m_xNumVertical.reset();
365     m_xFLNormals.reset();
366     m_xBtnNormalsObj.reset();
367     m_xBtnNormalsFlat.reset();
368     m_xBtnNormalsSphere.reset();
369     m_xBtnNormalsInvert.reset();
370     m_xBtnTwoSidedLighting.reset();
371     m_xBtnDoubleSided.reset();
372     m_xFLRepresentation.reset();
373     m_xLbShademode.reset();
374     m_xFLShadow.reset();
375     m_xBtnShadow3d.reset();
376     m_xFtSlant.reset();
377     m_xMtrSlant.reset();
378     m_xFLCamera.reset();
379     m_xMtrDistance.reset();
380     m_xMtrFocalLength.reset();
381     m_xFLLight.reset();
382     m_xBtnLight1.reset();
383     m_xBtnLight2.reset();
384     m_xBtnLight3.reset();
385     m_xBtnLight4.reset();
386     m_xBtnLight5.reset();
387     m_xBtnLight6.reset();
388     m_xBtnLight7.reset();
389     m_xBtnLight8.reset();
390     m_xLbLight1.reset();
391     m_xLbLight2.reset();
392     m_xLbLight3.reset();
393     m_xLbLight4.reset();
394     m_xLbLight5.reset();
395     m_xLbLight6.reset();
396     m_xLbLight7.reset();
397     m_xLbLight8.reset();
398     m_xBtnLightColor.reset();
399     m_xLbAmbientlight.reset();
400     m_xBtnAmbientColor.reset();
401     m_xFLTexture.reset();
402     m_xBtnTexLuminance.reset();
403     m_xBtnTexColor.reset();
404     m_xBtnTexReplace.reset();
405     m_xBtnTexModulate.reset();
406     m_xBtnTexObjectX.reset();
407     m_xBtnTexParallelX.reset();
408     m_xBtnTexCircleX.reset();
409     m_xBtnTexObjectY.reset();
410     m_xBtnTexParallelY.reset();
411     m_xBtnTexCircleY.reset();
412     m_xBtnTexFilter.reset();
413     m_xFLMaterial.reset();
414     m_xLbMatFavorites.reset();
415     m_xLbMatColor.reset();
416     m_xBtnMatColor.reset();
417     m_xLbMatEmission.reset();
418     m_xBtnEmissionColor.reset();
419     m_xFLMatSpecular.reset();
420     m_xLbMatSpecular.reset();
421     m_xBtnSpecularColor.reset();
422     m_xMtrMatSpecularIntensity.reset();
423     m_xCtlPreviewWin.reset();
424     m_xCtlPreview.reset();
425 
426     m_xCtlLightPreview.reset();
427     m_xCtlLightPreviewWin.reset();
428     m_xLightPreview.reset();
429     m_xBtn_Corner.reset();
430     m_xVertScale.reset();
431     m_xHoriScale.reset();
432     m_xLightPreviewGrid.reset();
433 
434     m_xBtnConvertTo3D.reset();
435     m_xBtnLatheObject.reset();
436     m_xBtnPerspective.reset();
437 
438     SfxDockingWindow::dispose();
439 }
440 
Construct()441 void Svx3DWin::Construct()
442 {
443     m_xBtnGeo->set_active(true);
444     ClickViewTypeHdl(*m_xBtnGeo);
445     m_xLightPreviewGrid->hide();
446 }
447 
Reset()448 void Svx3DWin::Reset()
449 {
450     // Various initializations, default is AllAttributes
451     m_xLbShademode->set_active( 0 );
452     m_xMtrMatSpecularIntensity->set_value( 50, FieldUnit::PERCENT );
453 
454     m_xBtnLight1->set_active(true);
455     m_xBtnUpdate->set_active(true);
456     ClickUpdateHdl(*m_xBtnUpdate);
457 
458     // Select nothing, to avoid errors when selecting the first
459     m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(0);
460     m_xCtlLightPreview->CheckSelection();
461 }
462 
Update(SfxItemSet const & rAttrs)463 void Svx3DWin::Update( SfxItemSet const & rAttrs )
464 {
465     // remember 2d attributes
466     if(mpRemember2DAttributes)
467         mpRemember2DAttributes->ClearItem();
468     else
469         mpRemember2DAttributes = std::make_unique<SfxItemSetFixed
470             <SDRATTR_START, SDRATTR_SHADOW_LAST,
471             SDRATTR_3D_FIRST, SDRATTR_3D_LAST>>(*rAttrs.GetPool());
472 
473     SfxWhichIter aIter(*mpRemember2DAttributes);
474     sal_uInt16 nWhich(aIter.FirstWhich());
475 
476     while(nWhich)
477     {
478         SfxItemState eState = rAttrs.GetItemState(nWhich, false);
479         if(SfxItemState::INVALID == eState)
480             mpRemember2DAttributes->InvalidateItem(nWhich);
481         else if(SfxItemState::SET == eState)
482             mpRemember2DAttributes->Put(rAttrs.Get(nWhich, false));
483 
484         nWhich = aIter.NextWhich();
485     }
486 
487     // construct field values
488     const SfxPoolItem* pItem;
489 
490     // Possible determine PoolUnit
491     if( !mpImpl->pPool )
492     {
493         mpImpl->pPool = rAttrs.GetPool();
494         DBG_ASSERT( mpImpl->pPool, "Where is the Pool? ");
495         ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
496     }
497     eFUnit = GetModuleFieldUnit( rAttrs );
498 
499 
500     // Segment Number Can be changed? and other states
501     SfxItemState eState = rAttrs.GetItemState( SID_ATTR_3D_INTERN, false, &pItem );
502     if( SfxItemState::SET == eState )
503     {
504         sal_uInt32 nState = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
505         bool bExtrude = ( nState & 2 );
506         bool bSphere  = ( nState & 4 );
507         bool bCube    = ( nState & 8 );
508 
509         bool bChart = ( nState & 32 ); // Chart
510 
511         if( !bChart )
512         {
513             // For cube objects are no segments set
514             m_xFLSegments->set_sensitive(!bCube);
515 
516             m_xFtPercentDiagonal->set_sensitive( !bCube && !bSphere );
517             m_xMtrPercentDiagonal->set_sensitive( !bCube && !bSphere );
518             m_xFtBackscale->set_sensitive( !bCube && !bSphere );
519             m_xMtrBackscale->set_sensitive( !bCube && !bSphere );
520             m_xFtDepth->set_sensitive( !bCube && !bSphere );
521             m_xMtrDepth->set_sensitive( !bCube && !bSphere );
522             if( bCube )
523             {
524                 m_xNumHorizontal->set_text(u""_ustr);
525                 m_xNumVertical->set_text(u""_ustr);
526             }
527             if( bCube || bSphere )
528             {
529                 m_xMtrPercentDiagonal->set_text(u""_ustr);
530                 m_xMtrBackscale->set_text(u""_ustr);
531                 m_xMtrDepth->set_text(u""_ustr);
532             }
533 
534             // There is a final angle only for Lathe objects.
535             m_xFtEndAngle->set_sensitive( !bExtrude && !bCube && !bSphere );
536             m_xMtrEndAngle->set_sensitive( !bExtrude && !bCube && !bSphere );
537             if( bExtrude || bCube || bSphere )
538                 m_xMtrEndAngle->set_text(u""_ustr);
539         }
540         else
541         {
542             // Geometry
543             m_xNumHorizontal->set_text(u""_ustr);
544             m_xNumVertical->set_text(u""_ustr);
545             m_xFLSegments->set_sensitive( false );
546             m_xFtEndAngle->set_sensitive( false );
547             m_xMtrEndAngle->set_sensitive( false );
548             m_xMtrEndAngle->set_text(u""_ustr);
549             m_xFtDepth->set_sensitive( false );
550             m_xMtrDepth->set_sensitive( false );
551             m_xMtrDepth->set_text(u""_ustr);
552 
553             // Representation
554             m_xFLShadow->set_sensitive(false);
555 
556             m_xMtrDistance->set_text(u""_ustr);
557             m_xMtrFocalLength->set_text(u""_ustr);
558             m_xFLCamera->set_sensitive( false );
559 
560             //Lower Range
561             m_xBtnConvertTo3D->set_sensitive( false );
562             m_xBtnLatheObject->set_sensitive( false );
563         }
564     }
565     // Bitmap fill ? -> Status
566     bool bBitmap(false);
567     eState = rAttrs.GetItemState(XATTR_FILLSTYLE);
568     if(eState != SfxItemState::INVALID)
569     {
570         drawing::FillStyle eXFS = rAttrs.Get(XATTR_FILLSTYLE).GetValue();
571         bBitmap = (eXFS == drawing::FillStyle_BITMAP || eXFS == drawing::FillStyle_GRADIENT || eXFS == drawing::FillStyle_HATCH);
572     }
573 
574     m_xFLTexture->set_sensitive(bBitmap);
575 
576     // Geometry
577     // Number of segments (horizontal)
578     if( m_xNumHorizontal->get_sensitive() )
579     {
580         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_HORZ_SEGS);
581         if(eState != SfxItemState::INVALID)
582         {
583             sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_HORZ_SEGS).GetValue();
584             if (nValue != static_cast<sal_uInt32>(m_xNumHorizontal->get_value()))
585             {
586                 m_xNumHorizontal->set_value( nValue );
587                 bUpdate = true;
588             }
589             else if( m_xNumHorizontal->get_text().isEmpty() )
590                 m_xNumHorizontal->set_value( nValue );
591         }
592         else
593         {
594             if( !m_xNumHorizontal->get_text().isEmpty() )
595             {
596                 m_xNumHorizontal->set_text(u""_ustr);
597                 bUpdate = true;
598             }
599         }
600     }
601 
602     //Number of segments (vertical)
603     if( m_xNumVertical->get_sensitive() )
604     {
605         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_VERT_SEGS);
606         if( eState != SfxItemState::INVALID )
607         {
608             sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_VERT_SEGS).GetValue();
609             if( nValue != static_cast<sal_uInt32>(m_xNumVertical->get_value()) )
610             {
611                 m_xNumVertical->set_value( nValue );
612                 bUpdate = true;
613             }
614             else if( m_xNumVertical->get_text().isEmpty() )
615                 m_xNumVertical->set_value( nValue );
616         }
617         else
618         {
619             if( !m_xNumVertical->get_text().isEmpty() )
620             {
621                 m_xNumVertical->set_text(u""_ustr);
622                 bUpdate = true;
623             }
624         }
625     }
626 
627     // Depth
628     if( m_xMtrDepth->get_sensitive() )
629     {
630         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DEPTH);
631         if( eState != SfxItemState::INVALID )
632         {
633             sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_DEPTH).GetValue();
634             sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDepth, ePoolUnit);
635             if( nValue != nValue2 )
636             {
637                 if( eFUnit != m_xMtrDepth->get_unit() )
638                     SetFieldUnit(*m_xMtrDepth, eFUnit);
639 
640                 SetMetricValue(*m_xMtrDepth, nValue, ePoolUnit);
641                 bUpdate = true;
642             }
643             else if( m_xMtrDepth->get_text().isEmpty() )
644                 m_xMtrDepth->set_value(m_xMtrDepth->get_value(FieldUnit::NONE), FieldUnit::NONE);
645         }
646         else
647         {
648             if( !m_xMtrDepth->get_text().isEmpty() )
649             {
650                 m_xMtrDepth->set_text(u""_ustr);
651                 bUpdate = true;
652             }
653         }
654     }
655 
656     // Double walled / Double sided
657     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DOUBLE_SIDED);
658     if( eState != SfxItemState::INVALID )
659     {
660         bool bValue = rAttrs.Get(SDRATTR_3DOBJ_DOUBLE_SIDED).GetValue();
661         if( bValue != m_xBtnDoubleSided->get_active() )
662         {
663             m_xBtnDoubleSided->set_active( bValue );
664             bUpdate = true;
665         }
666         else if( m_xBtnDoubleSided->get_state() == TRISTATE_INDET )
667             m_xBtnDoubleSided->set_active( bValue );
668     }
669     else
670     {
671         if( m_xBtnDoubleSided->get_state() != TRISTATE_INDET )
672         {
673             m_xBtnDoubleSided->set_state( TRISTATE_INDET );
674             bUpdate = true;
675         }
676     }
677 
678     // Edge rounding
679     if( m_xMtrPercentDiagonal->get_sensitive() )
680     {
681         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
682         if( eState != SfxItemState::INVALID )
683         {
684             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_PERCENT_DIAGONAL).GetValue();
685             if( nValue != m_xMtrPercentDiagonal->get_value(FieldUnit::PERCENT) )
686             {
687                 m_xMtrPercentDiagonal->set_value(nValue, FieldUnit::PERCENT);
688                 bUpdate = true;
689             }
690             else if( m_xMtrPercentDiagonal->get_text().isEmpty() )
691                 m_xMtrPercentDiagonal->set_value(nValue, FieldUnit::PERCENT);
692         }
693         else
694         {
695             if( !m_xMtrPercentDiagonal->get_text().isEmpty() )
696             {
697                 m_xMtrPercentDiagonal->set_text(u""_ustr);
698                 bUpdate = true;
699             }
700         }
701     }
702 
703     // Depth scaling
704     if( m_xMtrBackscale->get_sensitive() )
705     {
706         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_BACKSCALE);
707         if( eState != SfxItemState::INVALID )
708         {
709             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_BACKSCALE).GetValue();
710             if( nValue != m_xMtrBackscale->get_value(FieldUnit::PERCENT) )
711             {
712                 m_xMtrBackscale->set_value(nValue, FieldUnit::PERCENT);
713                 bUpdate = true;
714             }
715             else if( m_xMtrBackscale->get_text().isEmpty() )
716                 m_xMtrBackscale->set_value(nValue, FieldUnit::PERCENT);
717         }
718         else
719         {
720             if( !m_xMtrBackscale->get_text().isEmpty() )
721             {
722                 m_xMtrBackscale->set_text(u""_ustr);
723                 bUpdate = true;
724             }
725         }
726     }
727 
728     // End angle
729     if( m_xMtrEndAngle->get_sensitive() )
730     {
731         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_END_ANGLE);
732         if( eState != SfxItemState::INVALID )
733         {
734             sal_Int32 nValue = rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE).GetValue();
735             if( nValue != m_xMtrEndAngle->get_value(FieldUnit::DEGREE) )
736             {
737                 m_xMtrEndAngle->set_value(nValue, FieldUnit::DEGREE);
738                 bUpdate = true;
739             }
740         }
741         else
742         {
743             if( !m_xMtrEndAngle->get_text().isEmpty() )
744             {
745                 m_xMtrEndAngle->set_text(u""_ustr);
746                 bUpdate = true;
747             }
748         }
749     }
750 
751     // Normal type
752     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_KIND);
753     if( eState != SfxItemState::INVALID )
754     {
755         sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_NORMALS_KIND).GetValue();
756 
757         if( ( !m_xBtnNormalsObj->get_active() && nValue == 0 ) ||
758             ( !m_xBtnNormalsFlat->get_active() && nValue == 1 ) ||
759             ( !m_xBtnNormalsSphere->get_active() && nValue == 2 ) )
760         {
761             m_xBtnNormalsObj->set_active( nValue == 0 );
762             m_xBtnNormalsFlat->set_active( nValue == 1 );
763             m_xBtnNormalsSphere->set_active( nValue == 2 );
764             bUpdate = true;
765         }
766     }
767     else
768     {
769         if( m_xBtnNormalsObj->get_active() ||
770             m_xBtnNormalsFlat->get_active() ||
771             m_xBtnNormalsSphere->get_active() )
772         {
773             m_xBtnNormalsObj->set_active( false );
774             m_xBtnNormalsFlat->set_active( false );
775             m_xBtnNormalsSphere->set_active( false );
776             bUpdate = true;
777         }
778     }
779 
780     // Normal inverted
781     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_INVERT);
782     if( eState != SfxItemState::INVALID )
783     {
784         bool bValue = rAttrs.Get(SDRATTR_3DOBJ_NORMALS_INVERT).GetValue();
785         if( bValue != m_xBtnNormalsInvert->get_active() )
786         {
787             m_xBtnNormalsInvert->set_active( bValue );
788             bUpdate = true;
789         }
790         else if( m_xBtnNormalsInvert->get_state() == TRISTATE_INDET )
791             m_xBtnNormalsInvert->set_active( bValue );
792     }
793     else
794     {
795         if( m_xBtnNormalsInvert->get_state() != TRISTATE_INDET )
796         {
797             m_xBtnNormalsInvert->set_state( TRISTATE_INDET );
798             bUpdate = true;
799         }
800     }
801 
802     // 2-sided lighting
803     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
804     if( eState != SfxItemState::INVALID )
805     {
806         bool bValue = rAttrs.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING).GetValue();
807         if( bValue != m_xBtnTwoSidedLighting->get_active() )
808         {
809             m_xBtnTwoSidedLighting->set_active( bValue );
810             bUpdate = true;
811         }
812         else if( m_xBtnTwoSidedLighting->get_state() == TRISTATE_INDET )
813             m_xBtnTwoSidedLighting->set_active( bValue );
814     }
815     else
816     {
817         if( m_xBtnTwoSidedLighting->get_state() != TRISTATE_INDET )
818         {
819             m_xBtnTwoSidedLighting->set_state( TRISTATE_INDET );
820             bUpdate = true;
821         }
822     }
823 
824     // Representation
825     // Shademode
826     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADE_MODE);
827     if( eState != SfxItemState::INVALID )
828     {
829         sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DSCENE_SHADE_MODE).GetValue();
830         if( nValue != m_xLbShademode->get_active() )
831         {
832             m_xLbShademode->set_active( nValue );
833             bUpdate = true;
834         }
835     }
836     else
837     {
838         if( m_xLbShademode->get_active() != 0 )
839         {
840             m_xLbShademode->set_active(-1);
841             bUpdate = true;
842         }
843     }
844 
845     // 3D-Shadow
846     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_SHADOW_3D);
847     if( eState != SfxItemState::INVALID )
848     {
849         bool bValue = rAttrs.Get(SDRATTR_3DOBJ_SHADOW_3D).GetValue();
850         if( bValue != m_xBtnShadow3d->get_active() )
851         {
852             m_xBtnShadow3d->set_active( bValue );
853             m_xFtSlant->set_sensitive( bValue );
854             m_xMtrSlant->set_sensitive( bValue );
855             bUpdate = true;
856         }
857         else if( m_xBtnShadow3d->get_state() == TRISTATE_INDET )
858             m_xBtnShadow3d->set_active( bValue );
859     }
860     else
861     {
862         if( m_xBtnShadow3d->get_state() != TRISTATE_INDET )
863         {
864             m_xBtnShadow3d->set_state( TRISTATE_INDET );
865             bUpdate = true;
866         }
867     }
868 
869     // Inclination (Shadow)
870     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADOW_SLANT);
871     if( eState != SfxItemState::INVALID )
872     {
873         sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DSCENE_SHADOW_SLANT).GetValue();
874         if( nValue != m_xMtrSlant->get_value(FieldUnit::DEGREE) )
875         {
876             m_xMtrSlant->set_value(nValue, FieldUnit::DEGREE);
877             bUpdate = true;
878         }
879     }
880     else
881     {
882         if( !m_xMtrSlant->get_text().isEmpty() )
883         {
884             m_xMtrSlant->set_text(u""_ustr);
885             bUpdate = true;
886         }
887     }
888 
889     // Distance
890     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_DISTANCE);
891     if( eState != SfxItemState::INVALID )
892     {
893         sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DSCENE_DISTANCE).GetValue();
894         sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDistance, ePoolUnit);
895         if( nValue != nValue2 )
896         {
897             if( eFUnit != m_xMtrDistance->get_unit() )
898                 SetFieldUnit(*m_xMtrDistance, eFUnit);
899 
900             SetMetricValue(*m_xMtrDistance, nValue, ePoolUnit);
901             bUpdate = true;
902         }
903     }
904     else
905     {
906         if( !m_xMtrDepth->get_text().isEmpty() )
907         {
908             m_xMtrDepth->set_text(u""_ustr);
909             bUpdate = true;
910         }
911     }
912 
913     // Focal length
914     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_FOCAL_LENGTH);
915     if( eState != SfxItemState::INVALID )
916     {
917         sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue();
918         sal_uInt32 nValue2 = GetCoreValue(*m_xMtrFocalLength, ePoolUnit);
919         if( nValue != nValue2 )
920         {
921             if( eFUnit != m_xMtrFocalLength->get_unit() )
922                 SetFieldUnit(*m_xMtrFocalLength, eFUnit);
923 
924             SetMetricValue(*m_xMtrFocalLength, nValue, ePoolUnit);
925             bUpdate = true;
926         }
927     }
928     else
929     {
930         if( !m_xMtrFocalLength->get_text().isEmpty() )
931         {
932             m_xMtrFocalLength->set_text(u""_ustr);
933             bUpdate = true;
934         }
935     }
936 
937 // Lighting
938     Color aColor;
939     // Light 1 (Color)
940     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_1);
941     if( eState != SfxItemState::INVALID )
942     {
943         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1).GetValue();
944         ColorListBox* pLb = m_xLbLight1.get();
945         if( aColor != pLb->GetSelectEntryColor() )
946         {
947             LBSelectColor( pLb, aColor );
948             bUpdate = true;
949         }
950     }
951     else
952     {
953         if (!m_xLbLight1->IsNoSelection())
954         {
955             m_xLbLight1->SetNoSelection();
956             bUpdate = true;
957         }
958     }
959     // Light 1 (on/off)
960     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_1);
961     if( eState != SfxItemState::INVALID )
962     {
963         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_1).GetValue();
964         if (bOn != m_xBtnLight1->isLightOn())
965         {
966             m_xBtnLight1->switchLightOn(bOn);
967             bUpdate = true;
968         }
969         if( m_xBtnLight1->get_state() == TRISTATE_INDET )
970             m_xBtnLight1->set_active( m_xBtnLight1->get_active() );
971     }
972     else
973     {
974         if( m_xBtnLight1->get_state() != TRISTATE_INDET )
975         {
976             m_xBtnLight1->set_state( TRISTATE_INDET );
977             bUpdate = true;
978         }
979     }
980     // Light 1 (direction)
981     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_1);
982     if( eState != SfxItemState::INVALID )
983     {
984         bUpdate = true;
985     }
986 
987     //Light 2 (color)
988     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_2);
989     if( eState != SfxItemState::INVALID )
990     {
991         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2).GetValue();
992         ColorListBox* pLb = m_xLbLight2.get();
993         if( aColor != pLb->GetSelectEntryColor() )
994         {
995             LBSelectColor( pLb, aColor );
996             bUpdate = true;
997         }
998     }
999     else
1000     {
1001         if (!m_xLbLight2->IsNoSelection())
1002         {
1003             m_xLbLight2->SetNoSelection();
1004             bUpdate = true;
1005         }
1006     }
1007     // Light 2 (on/off)
1008     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_2);
1009     if( eState != SfxItemState::INVALID )
1010     {
1011         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_2).GetValue();
1012         if (bOn != m_xBtnLight2->isLightOn())
1013         {
1014             m_xBtnLight2->switchLightOn(bOn);
1015             bUpdate = true;
1016         }
1017         if( m_xBtnLight2->get_state() == TRISTATE_INDET )
1018             m_xBtnLight2->set_active( m_xBtnLight2->get_active() );
1019     }
1020     else
1021     {
1022         if( m_xBtnLight2->get_state() != TRISTATE_INDET )
1023         {
1024             m_xBtnLight2->set_state( TRISTATE_INDET );
1025             bUpdate = true;
1026         }
1027     }
1028     //Light 2 (Direction)
1029     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_2);
1030     if( eState != SfxItemState::INVALID )
1031     {
1032         bUpdate = true;
1033     }
1034 
1035     //Light 3 (color)
1036     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1037     if( eState != SfxItemState::INVALID )
1038     {
1039         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3).GetValue();
1040         ColorListBox* pLb = m_xLbLight3.get();
1041         if( aColor != pLb->GetSelectEntryColor() )
1042         {
1043             LBSelectColor( pLb, aColor );
1044             bUpdate = true;
1045         }
1046     }
1047     else
1048     {
1049         if (!m_xLbLight3->IsNoSelection())
1050         {
1051             m_xLbLight3->SetNoSelection();
1052             bUpdate = true;
1053         }
1054     }
1055     // Light 3 (on/off)
1056     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_3);
1057     if( eState != SfxItemState::INVALID )
1058     {
1059         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_3).GetValue();
1060         if (bOn != m_xBtnLight3->isLightOn())
1061         {
1062             m_xBtnLight3->switchLightOn(bOn);
1063             bUpdate = true;
1064         }
1065         if( m_xBtnLight3->get_state() == TRISTATE_INDET )
1066             m_xBtnLight3->set_active( m_xBtnLight3->get_active() );
1067     }
1068     else
1069     {
1070         if( m_xBtnLight3->get_state() != TRISTATE_INDET )
1071         {
1072             m_xBtnLight3->set_state( TRISTATE_INDET );
1073             bUpdate = true;
1074         }
1075     }
1076     // Light 3 (Direction)
1077     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_3);
1078     if( eState != SfxItemState::INVALID )
1079     {
1080         bUpdate = true;
1081     }
1082 
1083     // Light 4 (Color)
1084     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_4);
1085     if( eState != SfxItemState::INVALID )
1086     {
1087         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4).GetValue();
1088         ColorListBox* pLb = m_xLbLight4.get();
1089         if( aColor != pLb->GetSelectEntryColor() )
1090         {
1091             LBSelectColor( pLb, aColor );
1092             bUpdate = true;
1093         }
1094     }
1095     else
1096     {
1097         if (!m_xLbLight4->IsNoSelection())
1098         {
1099             m_xLbLight4->SetNoSelection();
1100             bUpdate = true;
1101         }
1102     }
1103     // Light 4 (on/off)
1104     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_4);
1105     if( eState != SfxItemState::INVALID )
1106     {
1107         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_4).GetValue();
1108         if (bOn != m_xBtnLight4->isLightOn())
1109         {
1110             m_xBtnLight4->switchLightOn(bOn);
1111             bUpdate = true;
1112         }
1113         if( m_xBtnLight4->get_state() == TRISTATE_INDET )
1114             m_xBtnLight4->set_active( m_xBtnLight4->get_active() );
1115     }
1116     else
1117     {
1118         if( m_xBtnLight4->get_state() != TRISTATE_INDET )
1119         {
1120             m_xBtnLight4->set_state( TRISTATE_INDET );
1121             bUpdate = true;
1122         }
1123     }
1124     // Light 4 (direction)
1125     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_4);
1126     if( eState != SfxItemState::INVALID )
1127     {
1128         bUpdate = true;
1129     }
1130 
1131     // Light 5 (color)
1132     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_5);
1133     if( eState != SfxItemState::INVALID )
1134     {
1135         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5).GetValue();
1136         ColorListBox* pLb = m_xLbLight5.get();
1137         if( aColor != pLb->GetSelectEntryColor() )
1138         {
1139             LBSelectColor( pLb, aColor );
1140             bUpdate = true;
1141         }
1142     }
1143     else
1144     {
1145         if (!m_xLbLight5->IsNoSelection())
1146         {
1147             m_xLbLight5->SetNoSelection();
1148             bUpdate = true;
1149         }
1150     }
1151     // Light 5 (on/off)
1152     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_5);
1153     if( eState != SfxItemState::INVALID )
1154     {
1155         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_5).GetValue();
1156         if (bOn != m_xBtnLight5->isLightOn())
1157         {
1158             m_xBtnLight5->switchLightOn(bOn);
1159             bUpdate = true;
1160         }
1161         if( m_xBtnLight5->get_state() == TRISTATE_INDET )
1162             m_xBtnLight5->set_active( m_xBtnLight5->get_active() );
1163     }
1164     else
1165     {
1166         if( m_xBtnLight5->get_state() != TRISTATE_INDET )
1167         {
1168             m_xBtnLight5->set_state( TRISTATE_INDET );
1169             bUpdate = true;
1170         }
1171     }
1172     // Light 5 (direction)
1173     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_5);
1174     if( eState != SfxItemState::INVALID )
1175     {
1176         bUpdate = true;
1177     }
1178 
1179     // Light 6 (color)
1180     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_6);
1181     if( eState != SfxItemState::INVALID )
1182     {
1183         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6).GetValue();
1184         ColorListBox* pLb = m_xLbLight6.get();
1185         if( aColor != pLb->GetSelectEntryColor() )
1186         {
1187             LBSelectColor( pLb, aColor );
1188             bUpdate = true;
1189         }
1190     }
1191     else
1192     {
1193         if (!m_xLbLight6->IsNoSelection())
1194         {
1195             m_xLbLight6->SetNoSelection();
1196             bUpdate = true;
1197         }
1198     }
1199     // Light 6 (on/off)
1200     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_6);
1201     if( eState != SfxItemState::INVALID )
1202     {
1203         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_6).GetValue();
1204         if (bOn != m_xBtnLight6->isLightOn())
1205         {
1206             m_xBtnLight6->switchLightOn(bOn);
1207             bUpdate = true;
1208         }
1209         if( m_xBtnLight6->get_state() == TRISTATE_INDET )
1210             m_xBtnLight6->set_active( m_xBtnLight6->get_active() );
1211     }
1212     else
1213     {
1214         if( m_xBtnLight6->get_state() != TRISTATE_INDET )
1215         {
1216             m_xBtnLight6->set_state( TRISTATE_INDET );
1217             bUpdate = true;
1218         }
1219     }
1220     // Light 6 (direction)
1221     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_6);
1222     if( eState != SfxItemState::INVALID )
1223     {
1224         bUpdate = true;
1225     }
1226 
1227     // Light 7 (color)
1228     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_7);
1229     if( eState != SfxItemState::INVALID )
1230     {
1231         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7).GetValue();
1232         ColorListBox* pLb = m_xLbLight7.get();
1233         if( aColor != pLb->GetSelectEntryColor() )
1234         {
1235             LBSelectColor( pLb, aColor );
1236             bUpdate = true;
1237         }
1238     }
1239     else
1240     {
1241         if (!m_xLbLight7->IsNoSelection())
1242         {
1243             m_xLbLight7->SetNoSelection();
1244             bUpdate = true;
1245         }
1246     }
1247     // Light 7 (on/off)
1248     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_7);
1249     if( eState != SfxItemState::INVALID )
1250     {
1251         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_7).GetValue();
1252         if (bOn != m_xBtnLight7->isLightOn())
1253         {
1254             m_xBtnLight7->switchLightOn(bOn);
1255             bUpdate = true;
1256         }
1257         if( m_xBtnLight7->get_state() == TRISTATE_INDET )
1258             m_xBtnLight7->set_active( m_xBtnLight7->get_active() );
1259     }
1260     else
1261     {
1262         if( m_xBtnLight7->get_state() != TRISTATE_INDET )
1263         {
1264             m_xBtnLight7->set_state( TRISTATE_INDET );
1265             bUpdate = true;
1266         }
1267     }
1268     // Light 7 (direction)
1269     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_7);
1270     if( eState != SfxItemState::INVALID )
1271     {
1272         bUpdate = true;
1273     }
1274 
1275     // Light 8 (color)
1276     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_8);
1277     if( eState != SfxItemState::INVALID )
1278     {
1279         aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8).GetValue();
1280         ColorListBox* pLb = m_xLbLight8.get();
1281         if( aColor != pLb->GetSelectEntryColor() )
1282         {
1283             LBSelectColor( pLb, aColor );
1284             bUpdate = true;
1285         }
1286     }
1287     else
1288     {
1289         if (!m_xLbLight8->IsNoSelection())
1290         {
1291             m_xLbLight8->SetNoSelection();
1292             bUpdate = true;
1293         }
1294     }
1295     // Light 8 (on/off)
1296     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_8);
1297     if( eState != SfxItemState::INVALID )
1298     {
1299         bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_8).GetValue();
1300         if (bOn != m_xBtnLight8->isLightOn())
1301         {
1302             m_xBtnLight8->switchLightOn(bOn);
1303             bUpdate = true;
1304         }
1305         if( m_xBtnLight8->get_state() == TRISTATE_INDET )
1306             m_xBtnLight8->set_active( m_xBtnLight8->get_active() );
1307     }
1308     else
1309     {
1310         if( m_xBtnLight8->get_state() != TRISTATE_INDET )
1311         {
1312             m_xBtnLight8->set_state( TRISTATE_INDET );
1313             bUpdate = true;
1314         }
1315     }
1316     // Light 8 (direction)
1317     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_8);
1318     if( eState != SfxItemState::INVALID )
1319     {
1320         bUpdate = true;
1321     }
1322 
1323     // Ambient light
1324     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_AMBIENTCOLOR);
1325     if( eState != SfxItemState::INVALID )
1326     {
1327         aColor = rAttrs.Get(SDRATTR_3DSCENE_AMBIENTCOLOR).GetValue();
1328         ColorListBox* pLb = m_xLbAmbientlight.get();
1329         if( aColor != pLb->GetSelectEntryColor() )
1330         {
1331             LBSelectColor( pLb, aColor );
1332             bUpdate = true;
1333         }
1334     }
1335     else
1336     {
1337         if (!m_xLbAmbientlight->IsNoSelection())
1338         {
1339             m_xLbAmbientlight->SetNoSelection();
1340             bUpdate = true;
1341         }
1342     }
1343 
1344 
1345 // Textures
1346     // Art
1347     if( bBitmap )
1348     {
1349         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_KIND);
1350         if( eState != SfxItemState::INVALID )
1351         {
1352             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_KIND).GetValue();
1353             drawing::TextureKind2 objTextKind = static_cast<drawing::TextureKind2>(nValue);
1354 
1355             if( ( !m_xBtnTexLuminance->get_active() && objTextKind == css::drawing::TextureKind2_LUMINANCE ) ||
1356                 ( !m_xBtnTexColor->get_active() && objTextKind == css::drawing::TextureKind2_COLOR ) )
1357             {
1358                 m_xBtnTexLuminance->set_active( objTextKind == css::drawing::TextureKind2_LUMINANCE );
1359                 m_xBtnTexColor->set_active( objTextKind == css::drawing::TextureKind2_COLOR );
1360                 bUpdate = true;
1361             }
1362         }
1363         else
1364         {
1365             if( m_xBtnTexLuminance->get_active() ||
1366                 m_xBtnTexColor->get_active() )
1367             {
1368                 m_xBtnTexLuminance->set_active( false );
1369                 m_xBtnTexColor->set_active( false );
1370                 bUpdate = true;
1371             }
1372         }
1373 
1374         // Mode
1375         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_MODE);
1376         if( eState != SfxItemState::INVALID )
1377         {
1378             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_MODE).GetValue();
1379 
1380             if( ( !m_xBtnTexReplace->get_active() && nValue == 1 ) ||
1381                 ( !m_xBtnTexModulate->get_active() && nValue == 2 ) )
1382             {
1383                 m_xBtnTexReplace->set_active( nValue == 1 );
1384                 m_xBtnTexModulate->set_active( nValue == 2 );
1385                 bUpdate = true;
1386             }
1387         }
1388         else
1389         {
1390             if( m_xBtnTexReplace->get_active() ||
1391                 m_xBtnTexModulate->get_active() )
1392             {
1393                 m_xBtnTexReplace->set_active( false );
1394                 m_xBtnTexModulate->set_active( false );
1395                 bUpdate = true;
1396             }
1397         }
1398 
1399         // Projection X
1400         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
1401         if( eState != SfxItemState::INVALID )
1402         {
1403             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X).GetValue();
1404 
1405             if( ( !m_xBtnTexObjectX->get_active() && nValue == 0 ) ||
1406                 ( !m_xBtnTexParallelX->get_active() && nValue == 1 ) ||
1407                 ( !m_xBtnTexCircleX->get_active() && nValue == 2 ) )
1408             {
1409                 m_xBtnTexObjectX->set_active( nValue == 0 );
1410                 m_xBtnTexParallelX->set_active( nValue == 1 );
1411                 m_xBtnTexCircleX->set_active( nValue == 2 );
1412                 bUpdate = true;
1413             }
1414         }
1415         else
1416         {
1417             if( m_xBtnTexObjectX->get_active() ||
1418                 m_xBtnTexParallelX->get_active() ||
1419                 m_xBtnTexCircleX->get_active() )
1420             {
1421                 m_xBtnTexObjectX->set_active( false );
1422                 m_xBtnTexParallelX->set_active( false );
1423                 m_xBtnTexCircleX->set_active( false );
1424                 bUpdate = true;
1425             }
1426         }
1427 
1428         // Projection Y
1429         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
1430         if( eState != SfxItemState::INVALID )
1431         {
1432             sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y).GetValue();
1433 
1434             if( ( !m_xBtnTexObjectY->get_active() && nValue == 0 ) ||
1435                 ( !m_xBtnTexParallelY->get_active() && nValue == 1 ) ||
1436                 ( !m_xBtnTexCircleY->get_active() && nValue == 2 ) )
1437             {
1438                 m_xBtnTexObjectY->set_active( nValue == 0 );
1439                 m_xBtnTexParallelY->set_active( nValue == 1 );
1440                 m_xBtnTexCircleY->set_active( nValue == 2 );
1441                 bUpdate = true;
1442             }
1443         }
1444         else
1445         {
1446             if( m_xBtnTexObjectY->get_active() ||
1447                 m_xBtnTexParallelY->get_active() ||
1448                 m_xBtnTexCircleY->get_active() )
1449             {
1450                 m_xBtnTexObjectY->set_active( false );
1451                 m_xBtnTexParallelY->set_active( false );
1452                 m_xBtnTexCircleY->set_active( false );
1453                 bUpdate = true;
1454             }
1455         }
1456 
1457         // Filter
1458         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_FILTER);
1459         if( eState != SfxItemState::INVALID )
1460         {
1461             bool bValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_FILTER).GetValue();
1462             if( bValue != m_xBtnTexFilter->get_active() )
1463             {
1464                 m_xBtnTexFilter->set_active( bValue );
1465                 bUpdate = true;
1466             }
1467             if( m_xBtnTexFilter->get_state() == TRISTATE_INDET )
1468                 m_xBtnTexFilter->set_active( bValue );
1469         }
1470         else
1471         {
1472             if( m_xBtnTexFilter->get_state() != TRISTATE_INDET )
1473             {
1474                 m_xBtnTexFilter->set_state( TRISTATE_INDET );
1475                 bUpdate = true;
1476             }
1477         }
1478     }
1479 
1480 
1481     // Material Favorites
1482     m_xLbMatFavorites->set_active( 0 );
1483 
1484     // Object color
1485     eState = rAttrs.GetItemState(XATTR_FILLCOLOR);
1486     if( eState != SfxItemState::INVALID )
1487     {
1488         aColor = rAttrs.Get(XATTR_FILLCOLOR).GetColorValue();
1489         ColorListBox* pLb = m_xLbMatColor.get();
1490         if( aColor != pLb->GetSelectEntryColor() )
1491         {
1492             LBSelectColor( pLb, aColor );
1493             bUpdate = true;
1494         }
1495     }
1496     else
1497     {
1498         if (!m_xLbMatColor->IsNoSelection())
1499         {
1500             m_xLbMatColor->SetNoSelection();
1501             bUpdate = true;
1502         }
1503     }
1504 
1505     // Self-luminous color
1506     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_EMISSION);
1507     if( eState != SfxItemState::INVALID )
1508     {
1509         aColor = rAttrs.Get(SDRATTR_3DOBJ_MAT_EMISSION).GetValue();
1510         ColorListBox* pLb = m_xLbMatEmission.get();
1511         if( aColor != pLb->GetSelectEntryColor() )
1512         {
1513             LBSelectColor( pLb, aColor );
1514             bUpdate = true;
1515         }
1516     }
1517     else
1518     {
1519         if (!m_xLbMatEmission->IsNoSelection())
1520         {
1521             m_xLbMatEmission->SetNoSelection();
1522             bUpdate = true;
1523         }
1524     }
1525 
1526     // Specular
1527     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR);
1528     if( eState != SfxItemState::INVALID )
1529     {
1530         aColor = rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR).GetValue();
1531         ColorListBox* pLb = m_xLbMatSpecular.get();
1532         if( aColor != pLb->GetSelectEntryColor() )
1533         {
1534             LBSelectColor( pLb, aColor );
1535             bUpdate = true;
1536         }
1537     }
1538     else
1539     {
1540         if (!m_xLbMatSpecular->IsNoSelection())
1541         {
1542             m_xLbMatSpecular->SetNoSelection();
1543             bUpdate = true;
1544         }
1545     }
1546 
1547     // Specular Intensity
1548     eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
1549     if( eState != SfxItemState::INVALID )
1550     {
1551         sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY).GetValue();
1552         if( nValue != m_xMtrMatSpecularIntensity->get_value(FieldUnit::PERCENT) )
1553         {
1554             m_xMtrMatSpecularIntensity->set_value(nValue, FieldUnit::PERCENT);
1555             bUpdate = true;
1556         }
1557     }
1558     else
1559     {
1560         if( !m_xMtrMatSpecularIntensity->get_text().isEmpty() )
1561         {
1562             m_xMtrMatSpecularIntensity->set_text(u""_ustr);
1563             bUpdate = true;
1564         }
1565     }
1566 
1567 
1568 // Other
1569     // Perspective
1570     eState = rAttrs.GetItemState(SDRATTR_3DSCENE_PERSPECTIVE);
1571     if( eState != SfxItemState::INVALID )
1572     {
1573         ProjectionType ePT = static_cast<ProjectionType>(rAttrs.Get(SDRATTR_3DSCENE_PERSPECTIVE).GetValue());
1574         if( ( !m_xBtnPerspective->get_active() && ePT == ProjectionType::Perspective ) ||
1575             ( m_xBtnPerspective->get_active() && ePT == ProjectionType::Parallel ) )
1576         {
1577             m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective );
1578             bUpdate = true;
1579         }
1580         if( m_xBtnPerspective->get_state() == TRISTATE_INDET )
1581             m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective );
1582     }
1583     else
1584     {
1585         if( m_xBtnPerspective->get_state() != TRISTATE_INDET )
1586         {
1587             m_xBtnPerspective->set_state( TRISTATE_INDET );
1588             bUpdate = true;
1589         }
1590     }
1591 
1592     if( !bUpdate )
1593     {
1594         // however the 2D attributes may be different. Compare these and decide
1595 
1596         bUpdate = true;
1597     }
1598 
1599     // Update preview
1600     SfxItemSet aSet(rAttrs);
1601 
1602     // set LineStyle hard to drawing::LineStyle_NONE when it's not set so that
1603     // the default (drawing::LineStyle_SOLID) is not used for 3d preview
1604     if(SfxItemState::SET != aSet.GetItemState(XATTR_LINESTYLE, false))
1605         aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
1606 
1607     // set FillColor hard to WHITE when it's SfxItemState::INVALID so that
1608     // the default (Blue7) is not used for 3d preview
1609     if(SfxItemState::INVALID == aSet.GetItemState(XATTR_FILLCOLOR, false))
1610         aSet.Put(XFillColorItem(OUString(), COL_WHITE));
1611 
1612     m_xCtlPreview->Set3DAttributes(aSet);
1613     m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes(aSet);
1614 
1615     // try to select light corresponding to active button
1616     sal_uInt32 nNumber(0xffffffff);
1617 
1618     if(m_xBtnLight1->get_active())
1619         nNumber = 0;
1620     else if(m_xBtnLight2->get_active())
1621         nNumber = 1;
1622     else if(m_xBtnLight3->get_active())
1623         nNumber = 2;
1624     else if(m_xBtnLight4->get_active())
1625         nNumber = 3;
1626     else if(m_xBtnLight5->get_active())
1627         nNumber = 4;
1628     else if(m_xBtnLight6->get_active())
1629         nNumber = 5;
1630     else if(m_xBtnLight7->get_active())
1631         nNumber = 6;
1632     else if(m_xBtnLight8->get_active())
1633         nNumber = 7;
1634 
1635     if(nNumber != 0xffffffff)
1636     {
1637         m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(nNumber);
1638     }
1639 
1640     // handle state of converts possible
1641     m_xBtnConvertTo3D->set_sensitive(pConvertTo3DItem->GetState());
1642     m_xBtnLatheObject->set_sensitive(pConvertTo3DLatheItem->GetState());
1643 }
1644 
1645 
GetAttr(SfxItemSet & rAttrs)1646 void Svx3DWin::GetAttr( SfxItemSet& rAttrs )
1647 {
1648     // get remembered 2d attributes from the dialog
1649     if(mpRemember2DAttributes)
1650     {
1651         SfxWhichIter aIter(*mpRemember2DAttributes);
1652         sal_uInt16 nWhich(aIter.FirstWhich());
1653 
1654         while(nWhich)
1655         {
1656             SfxItemState eState = aIter.GetItemState(false);
1657             if(SfxItemState::INVALID == eState)
1658                 rAttrs.InvalidateItem(nWhich);
1659             else if(SfxItemState::SET == eState)
1660                 rAttrs.Put(mpRemember2DAttributes->Get(nWhich, false));
1661 
1662             nWhich = aIter.NextWhich();
1663         }
1664     }
1665 
1666 //Others must stand as the front on all sides
1667     // Perspective
1668     if( m_xBtnPerspective->get_state() != TRISTATE_INDET )
1669     {
1670         ProjectionType nValue;
1671         if( m_xBtnPerspective->get_active() )
1672             nValue = ProjectionType::Perspective;
1673         else
1674             nValue = ProjectionType::Parallel;
1675         rAttrs.Put(Svx3DPerspectiveItem(nValue));
1676     }
1677     else
1678         rAttrs.InvalidateItem(SDRATTR_3DSCENE_PERSPECTIVE);
1679 
1680 // Geometry
1681     // Possible determine PoolUnit (in this case this has not happened in Update() )
1682     if( !mpImpl->pPool )
1683     {
1684         OSL_FAIL( "No Pool in GetAttr()! May be incompatible to drviewsi.cxx ?" );
1685         mpImpl->pPool = rAttrs.GetPool();
1686         DBG_ASSERT( mpImpl->pPool, "Where is the Pool?" );
1687         ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
1688 
1689         eFUnit = GetModuleFieldUnit( rAttrs );
1690     }
1691 
1692     // Number of segments (horizontal)
1693     if( !m_xNumHorizontal->get_text().isEmpty() )
1694     {
1695         sal_uInt32 nValue = static_cast<sal_uInt32>(m_xNumHorizontal->get_value());
1696         rAttrs.Put(makeSvx3DHorizontalSegmentsItem(nValue));
1697     }
1698     else
1699         rAttrs.InvalidateItem(SDRATTR_3DOBJ_HORZ_SEGS);
1700 
1701     //  Number of segments (vertical)
1702     if( !m_xNumVertical->get_text().isEmpty() )
1703     {
1704         sal_uInt32 nValue = static_cast<sal_uInt32>(m_xNumVertical->get_value());
1705         rAttrs.Put(makeSvx3DVerticalSegmentsItem(nValue));
1706     }
1707     else
1708         rAttrs.InvalidateItem(SDRATTR_3DOBJ_VERT_SEGS);
1709 
1710     // Depth
1711     if( !m_xMtrDepth->get_text().isEmpty() )
1712     {
1713         sal_uInt32 nValue = GetCoreValue(*m_xMtrDepth, ePoolUnit);
1714         rAttrs.Put(makeSvx3DDepthItem(nValue));
1715     }
1716     else
1717         rAttrs.InvalidateItem(SDRATTR_3DOBJ_DEPTH);
1718 
1719     // Double-sided
1720     TriState eState = m_xBtnDoubleSided->get_state();
1721     if( eState != TRISTATE_INDET )
1722     {
1723         bool bValue = TRISTATE_TRUE == eState;
1724         rAttrs.Put(makeSvx3DDoubleSidedItem(bValue));
1725     }
1726     else
1727         rAttrs.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED);
1728 
1729     // Edge rounding
1730     if( !m_xMtrPercentDiagonal->get_text().isEmpty() )
1731     {
1732         sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrPercentDiagonal->get_value(FieldUnit::PERCENT));
1733         rAttrs.Put(makeSvx3DPercentDiagonalItem(nValue));
1734     }
1735     else
1736         rAttrs.InvalidateItem(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
1737 
1738     // Depth scale
1739     if( !m_xMtrBackscale->get_text().isEmpty() )
1740     {
1741         sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrBackscale->get_value(FieldUnit::PERCENT));
1742         rAttrs.Put(makeSvx3DBackscaleItem(nValue));
1743     }
1744     else
1745         rAttrs.InvalidateItem(SDRATTR_3DOBJ_BACKSCALE);
1746 
1747     // End angle
1748     if( !m_xMtrEndAngle->get_text().isEmpty() )
1749     {
1750         sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrEndAngle->get_value(FieldUnit::DEGREE));
1751         rAttrs.Put(makeSvx3DEndAngleItem(nValue));
1752     }
1753     else
1754         rAttrs.InvalidateItem(SDRATTR_3DOBJ_END_ANGLE);
1755 
1756     // Normal type
1757     sal_uInt16 nValue = 99;
1758     if( m_xBtnNormalsObj->get_active() )
1759         nValue = 0;
1760     else if( m_xBtnNormalsFlat->get_active() )
1761         nValue = 1;
1762     else if( m_xBtnNormalsSphere->get_active() )
1763         nValue = 2;
1764 
1765     if( nValue <= 2 )
1766         rAttrs.Put(Svx3DNormalsKindItem(nValue));
1767     else
1768         rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND);
1769 
1770     // Normal inverted
1771     eState = m_xBtnNormalsInvert->get_state();
1772     if( eState != TRISTATE_INDET )
1773     {
1774         bool bValue = TRISTATE_TRUE == eState;
1775         rAttrs.Put(makeSvx3DNormalsInvertItem(bValue));
1776     }
1777     else
1778         rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT);
1779 
1780     // 2-sided lighting
1781     eState = m_xBtnTwoSidedLighting->get_state();
1782     if( eState != TRISTATE_INDET )
1783     {
1784         bool bValue = TRISTATE_TRUE == eState;
1785         rAttrs.Put(makeSvx3DTwoSidedLightingItem(bValue));
1786     }
1787     else
1788         rAttrs.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
1789 
1790 // Representation
1791     // Shade mode
1792     if( m_xLbShademode->get_active() != -1 )
1793     {
1794         nValue = m_xLbShademode->get_active();
1795         rAttrs.Put(Svx3DShadeModeItem(nValue));
1796     }
1797     else
1798         rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE);
1799 
1800     // 3D-Shadow
1801     eState = m_xBtnShadow3d->get_state();
1802     if( eState != TRISTATE_INDET )
1803     {
1804         bool bValue = TRISTATE_TRUE == eState;
1805         rAttrs.Put(makeSvx3DShadow3DItem(bValue));
1806         rAttrs.Put(makeSdrShadowItem(bValue));
1807     }
1808     else
1809     {
1810         rAttrs.InvalidateItem(SDRATTR_3DOBJ_SHADOW_3D);
1811         rAttrs.InvalidateItem(SDRATTR_SHADOW);
1812     }
1813 
1814     // Slant (Shadow)
1815     if( !m_xMtrSlant->get_text().isEmpty() )
1816     {
1817         sal_uInt16 nValue2 = static_cast<sal_uInt16>(m_xMtrSlant->get_value(FieldUnit::DEGREE));
1818         rAttrs.Put(makeSvx3DShadowSlantItem(nValue2));
1819     }
1820     else
1821         rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADOW_SLANT);
1822 
1823     // Distance
1824     if( !m_xMtrDistance->get_text().isEmpty() )
1825     {
1826         sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDistance, ePoolUnit);
1827         rAttrs.Put(makeSvx3DDistanceItem(nValue2));
1828     }
1829     else
1830         rAttrs.InvalidateItem(SDRATTR_3DSCENE_DISTANCE);
1831 
1832     // Focal length
1833     if( !m_xMtrFocalLength->get_text().isEmpty() )
1834     {
1835         sal_uInt32 nValue2 = GetCoreValue(*m_xMtrFocalLength, ePoolUnit);
1836         rAttrs.Put(makeSvx3DFocalLengthItem(nValue2));
1837     }
1838     else
1839         rAttrs.InvalidateItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
1840 
1841     // Lighting
1842     Color aColor;
1843     const SfxItemSet aLightItemSet(m_xCtlLightPreview->GetSvx3DLightControl().Get3DAttributes());
1844 
1845     // Light 1 color
1846     if (!m_xLbLight1->IsNoSelection())
1847     {
1848         aColor = m_xLbLight1->GetSelectEntryColor();
1849         rAttrs.Put(makeSvx3DLightcolor1Item(aColor));
1850     }
1851     else
1852         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1);
1853     // Light 1 (on/off)
1854     eState = m_xBtnLight1->get_state();
1855     if( eState != TRISTATE_INDET )
1856     {
1857         bool bValue = m_xBtnLight1->isLightOn();
1858         rAttrs.Put(makeSvx3DLightOnOff1Item(bValue));
1859 
1860         // Light 1 (direction)
1861         if( bValue )
1862         {
1863             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1));
1864         }
1865     }
1866     else
1867         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_1);
1868 
1869 
1870     // Light 2 color
1871     if (!m_xLbLight2->IsNoSelection())
1872     {
1873         aColor = m_xLbLight2->GetSelectEntryColor();
1874         rAttrs.Put(makeSvx3DLightcolor2Item(aColor));
1875     }
1876     else
1877         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2);
1878     // Light 2 (on/off)
1879     eState = m_xBtnLight2->get_state();
1880     if( eState != TRISTATE_INDET )
1881     {
1882         bool bValue = m_xBtnLight2->isLightOn();
1883         rAttrs.Put(makeSvx3DLightOnOff2Item(bValue));
1884 
1885         // Light 2 (direction)
1886         if( bValue )
1887         {
1888             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2));
1889         }
1890     }
1891     else
1892         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_2);
1893 
1894     // Light 3 color
1895     if (!m_xLbLight3->IsNoSelection())
1896     {
1897         aColor = m_xLbLight3->GetSelectEntryColor();
1898         rAttrs.Put(makeSvx3DLightcolor3Item(aColor));
1899     }
1900     else
1901         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1902     // Light 3 (on/off)
1903     eState = m_xBtnLight3->get_state();
1904     if( eState != TRISTATE_INDET )
1905     {
1906         bool bValue = m_xBtnLight3->isLightOn();
1907         rAttrs.Put(makeSvx3DLightOnOff3Item(bValue));
1908 
1909         // Light 3 (direction)
1910         if( bValue )
1911         {
1912             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3));
1913         }
1914     }
1915     else
1916         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_3);
1917 
1918     // Light 4 color
1919     if (!m_xLbLight4->IsNoSelection())
1920     {
1921         aColor = m_xLbLight4->GetSelectEntryColor();
1922         rAttrs.Put(makeSvx3DLightcolor4Item(aColor));
1923     }
1924     else
1925         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4);
1926     // Light 4 (on/off)
1927     eState = m_xBtnLight4->get_state();
1928     if( eState != TRISTATE_INDET )
1929     {
1930         bool bValue = m_xBtnLight4->isLightOn();
1931         rAttrs.Put(makeSvx3DLightOnOff4Item(bValue));
1932 
1933         // Light 4 (direction)
1934         if( bValue )
1935         {
1936             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4));
1937         }
1938     }
1939     else
1940         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_4);
1941 
1942     // Light 5 color
1943     if (!m_xLbLight5->IsNoSelection())
1944     {
1945         aColor = m_xLbLight5->GetSelectEntryColor();
1946         rAttrs.Put(makeSvx3DLightcolor5Item(aColor));
1947     }
1948     else
1949         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5);
1950     // Light 5 (on/off)
1951     eState = m_xBtnLight5->get_state();
1952     if( eState != TRISTATE_INDET )
1953     {
1954         bool bValue = m_xBtnLight5->isLightOn();
1955         rAttrs.Put(makeSvx3DLightOnOff5Item(bValue));
1956 
1957         // Light 5 (direction)
1958         if( bValue )
1959         {
1960             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5));
1961         }
1962     }
1963     else
1964         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_5);
1965 
1966     // Light 6 color
1967     if (!m_xLbLight6->IsNoSelection())
1968     {
1969         aColor = m_xLbLight6->GetSelectEntryColor();
1970         rAttrs.Put(makeSvx3DLightcolor6Item(aColor));
1971     }
1972     else
1973         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6);
1974     // Light 6 (on/off)
1975     eState = m_xBtnLight6->get_state();
1976     if( eState != TRISTATE_INDET )
1977     {
1978         bool bValue = m_xBtnLight6->isLightOn();
1979         rAttrs.Put(makeSvx3DLightOnOff6Item(bValue));
1980 
1981         // Light 6 (direction)
1982         if( bValue )
1983         {
1984             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6));
1985         }
1986     }
1987     else
1988         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_6);
1989 
1990     // Light 7 color
1991     if (!m_xLbLight7->IsNoSelection())
1992     {
1993         aColor = m_xLbLight7->GetSelectEntryColor();
1994         rAttrs.Put(makeSvx3DLightcolor7Item(aColor));
1995     }
1996     else
1997         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7);
1998     // Light 7 (on/off)
1999     eState = m_xBtnLight7->get_state();
2000     if( eState != TRISTATE_INDET )
2001     {
2002         bool bValue = m_xBtnLight7->isLightOn();
2003         rAttrs.Put(makeSvx3DLightOnOff7Item(bValue));
2004 
2005         // Light 7 (direction)
2006         if( bValue )
2007         {
2008             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7));
2009         }
2010     }
2011     else
2012         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_7);
2013 
2014     // Light 8 color
2015     if (!m_xLbLight8->IsNoSelection())
2016     {
2017         aColor = m_xLbLight8->GetSelectEntryColor();
2018         rAttrs.Put(makeSvx3DLightcolor8Item(aColor));
2019     }
2020     else
2021         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8);
2022     // Light 8 (on/off)
2023     eState = m_xBtnLight8->get_state();
2024     if( eState != TRISTATE_INDET )
2025     {
2026         bool bValue = m_xBtnLight8->isLightOn();
2027         rAttrs.Put(makeSvx3DLightOnOff8Item(bValue));
2028 
2029         // Light 8 (direction)
2030         if( bValue )
2031         {
2032             rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8));
2033         }
2034     }
2035     else
2036         rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_8);
2037 
2038     // Ambient light
2039     if (!m_xLbAmbientlight->IsNoSelection())
2040     {
2041         aColor = m_xLbAmbientlight->GetSelectEntryColor();
2042         rAttrs.Put(makeSvx3DAmbientcolorItem(aColor));
2043     }
2044     else
2045         rAttrs.InvalidateItem(SDRATTR_3DSCENE_AMBIENTCOLOR);
2046 
2047 // Textures
2048     // Art
2049     drawing::TextureKind2 objTextKind = css::drawing::TextureKind2_LUMINANCE;
2050     bool bSet = false;
2051     if( m_xBtnTexLuminance->get_active() )
2052     {
2053         objTextKind = css::drawing::TextureKind2_LUMINANCE;
2054         bSet = true;
2055     }
2056     else if( m_xBtnTexColor->get_active() )
2057     {
2058         objTextKind = css::drawing::TextureKind2_COLOR;
2059         bSet = true;
2060     }
2061 
2062     if(bSet)
2063         rAttrs.Put(Svx3DTextureKindItem(static_cast<sal_uInt16>(objTextKind)));
2064     else
2065         rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_KIND);
2066 
2067 
2068     // Mode
2069     nValue = 99;
2070     if( m_xBtnTexReplace->get_active() )
2071         nValue = 1;
2072     else if( m_xBtnTexModulate->get_active() )
2073         nValue = 2;
2074 
2075     if( nValue == 1 || nValue == 2 )
2076         rAttrs.Put(Svx3DTextureModeItem(nValue));
2077     else
2078         rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_MODE);
2079 
2080     // X projection
2081     nValue = 99;
2082     if( m_xBtnTexObjectX->get_active() )
2083         nValue = 0;
2084     else if( m_xBtnTexParallelX->get_active() )
2085         nValue = 1;
2086     else if( m_xBtnTexCircleX->get_active() )
2087         nValue = 2;
2088 
2089     if( nValue <= 2 )
2090         rAttrs.Put(Svx3DTextureProjectionXItem(nValue));
2091     else
2092         rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
2093 
2094     // Y projection
2095     nValue = 99;
2096     if( m_xBtnTexObjectY->get_active() )
2097         nValue = 0;
2098     else if( m_xBtnTexParallelY->get_active() )
2099         nValue = 1;
2100     else if( m_xBtnTexCircleY->get_active() )
2101         nValue = 2;
2102 
2103     if( nValue <= 2 )
2104         rAttrs.Put(Svx3DTextureProjectionYItem(nValue));
2105     else
2106         rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
2107 
2108 
2109     // Filter
2110     eState = m_xBtnTexFilter->get_state();
2111     if( eState != TRISTATE_INDET )
2112     {
2113         bool bValue = TRISTATE_TRUE == eState;
2114         rAttrs.Put(makeSvx3DTextureFilterItem(bValue));
2115     }
2116     else
2117         rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER);
2118 
2119 
2120 // Material
2121     // Object color
2122     if (!m_xLbMatColor->IsNoSelection())
2123     {
2124         aColor = m_xLbMatColor->GetSelectEntryColor();
2125         rAttrs.Put( XFillColorItem( u""_ustr, aColor) );
2126     }
2127     else
2128     {
2129         rAttrs.InvalidateItem( XATTR_FILLCOLOR );
2130     }
2131 
2132     // luminous color
2133     if (!m_xLbMatEmission->IsNoSelection())
2134     {
2135         aColor = m_xLbMatEmission->GetSelectEntryColor();
2136         rAttrs.Put(makeSvx3DMaterialEmissionItem(aColor));
2137     }
2138     else
2139         rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_EMISSION);
2140 
2141     // Specular
2142     if (!m_xLbMatSpecular->IsNoSelection())
2143     {
2144         aColor = m_xLbMatSpecular->GetSelectEntryColor();
2145         rAttrs.Put(makeSvx3DMaterialSpecularItem(aColor));
2146     }
2147     else
2148         rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR);
2149 
2150     // Specular intensity
2151     if( !m_xMtrMatSpecularIntensity->get_text().isEmpty() )
2152     {
2153         sal_uInt16 nValue2 = static_cast<sal_uInt16>(m_xMtrMatSpecularIntensity->get_value(FieldUnit::PERCENT));
2154         rAttrs.Put(makeSvx3DMaterialSpecularIntensityItem(nValue2));
2155     }
2156     else
2157         rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
2158 }
2159 
Resize()2160 void Svx3DWin::Resize()
2161 {
2162     Size aWinSize( GetOutputSizePixel() ); // why rSize in Resizing()?
2163 
2164     if( aWinSize.Height() >= GetMinOutputSizePixel().Height() &&
2165         aWinSize.Width() >= GetMinOutputSizePixel().Width() )
2166     {
2167         // Hide
2168         m_xBtnUpdate->hide();
2169         m_xBtnAssign->hide();
2170 
2171         m_xBtnConvertTo3D->hide();
2172         m_xBtnLatheObject->hide();
2173         m_xBtnPerspective->hide();
2174 
2175         m_xCtlPreview->Hide();
2176         m_xLightPreviewGrid->hide();
2177 
2178         m_xFLGeometrie->hide();
2179         m_xFLRepresentation->hide();
2180         m_xFLLight->hide();
2181         m_xFLTexture->hide();
2182         m_xFLMaterial->hide();
2183 
2184         // Show
2185         m_xBtnUpdate->show();
2186         m_xBtnAssign->show();
2187 
2188         m_xBtnConvertTo3D->show();
2189         m_xBtnLatheObject->show();
2190         m_xBtnPerspective->show();
2191 
2192         if( m_xBtnGeo->get_active() )
2193             ClickViewTypeHdl(*m_xBtnGeo);
2194         if( m_xBtnRepresentation->get_active() )
2195             ClickViewTypeHdl(*m_xBtnRepresentation);
2196         if( m_xBtnLight->get_active() )
2197             ClickViewTypeHdl(*m_xBtnLight);
2198         if( m_xBtnTexture->get_active() )
2199             ClickViewTypeHdl(*m_xBtnTexture);
2200         if( m_xBtnMaterial->get_active() )
2201             ClickViewTypeHdl(*m_xBtnMaterial);
2202     }
2203 
2204     SfxDockingWindow::Resize();
2205 }
2206 
IMPL_LINK_NOARG(Svx3DWin,ClickUpdateHdl,weld::Toggleable &,void)2207 IMPL_LINK_NOARG(Svx3DWin, ClickUpdateHdl, weld::Toggleable&, void)
2208 {
2209     bUpdate = m_xBtnUpdate->get_active();
2210 
2211     if( bUpdate )
2212     {
2213         SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2214         if (pDispatcher != nullptr)
2215         {
2216             SfxBoolItem aItem( SID_3D_STATE, true );
2217             pDispatcher->ExecuteList(SID_3D_STATE,
2218                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2219         }
2220     }
2221     else
2222     {
2223         // Controls can be disabled during certain circumstances
2224     }
2225 }
2226 
IMPL_LINK_NOARG(Svx3DWin,ClickAssignHdl,weld::Button &,void)2227 IMPL_LINK_NOARG(Svx3DWin, ClickAssignHdl, weld::Button&, void)
2228 {
2229     SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2230     if (pDispatcher != nullptr)
2231     {
2232         SfxBoolItem aItem( SID_3D_ASSIGN, true );
2233         pDispatcher->ExecuteList(SID_3D_ASSIGN,
2234             SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2235     }
2236 }
2237 
IMPL_LINK(Svx3DWin,ClickViewTypeHdl,weld::Button &,rBtn,void)2238 IMPL_LINK( Svx3DWin, ClickViewTypeHdl, weld::Button&, rBtn, void )
2239 {
2240     // Since the permanent updating of the preview would be too expensive
2241     bool bUpdatePreview = m_xBtnLight->get_active();
2242 
2243     m_xBtnGeo->set_active(m_xBtnGeo.get() == &rBtn);
2244     m_xBtnRepresentation->set_active(m_xBtnRepresentation.get() == &rBtn);
2245     m_xBtnLight->set_active(m_xBtnLight.get() == &rBtn);
2246     m_xBtnTexture->set_active(m_xBtnTexture.get() == &rBtn);
2247     m_xBtnMaterial->set_active(m_xBtnMaterial.get() == &rBtn);
2248 
2249     if( m_xBtnGeo->get_active() )
2250         eViewType = ViewType3D::Geo;
2251     if( m_xBtnRepresentation->get_active() )
2252         eViewType = ViewType3D::Representation;
2253     if( m_xBtnLight->get_active() )
2254         eViewType = ViewType3D::Light;
2255     if( m_xBtnTexture->get_active() )
2256         eViewType = ViewType3D::Texture;
2257     if( m_xBtnMaterial->get_active() )
2258         eViewType = ViewType3D::Material;
2259 
2260     // Geometry
2261     if( eViewType == ViewType3D::Geo )
2262     {
2263         m_xFLSegments->show();
2264         m_xFLGeometrie->show();
2265         m_xFLNormals->show();
2266     }
2267     else
2268     {
2269         m_xFLSegments->hide();
2270         m_xFLGeometrie->hide();
2271         m_xFLNormals->hide();
2272     }
2273 
2274     // Representation
2275     if( eViewType == ViewType3D::Representation )
2276     {
2277         m_xFLShadow->show();
2278         m_xFLCamera->show();
2279         m_xFLRepresentation->show();
2280     }
2281     else
2282     {
2283         m_xFLShadow->hide();
2284         m_xFLCamera->hide();
2285         m_xFLRepresentation->hide();
2286     }
2287 
2288     // Lighting
2289     if( eViewType == ViewType3D::Light )
2290     {
2291         m_xFLLight->show();
2292 
2293         ColorListBox* pLb = GetCLbByButton();
2294         if( pLb )
2295             pLb->show();
2296 
2297         m_xLightPreviewGrid->show();
2298         m_xCtlPreview->Hide();
2299     }
2300     else
2301     {
2302         m_xFLLight->hide();
2303 
2304         if( !m_xCtlPreview->IsVisible() )
2305         {
2306             m_xCtlPreview->Show();
2307             m_xLightPreviewGrid->hide();
2308         }
2309     }
2310 
2311     // Textures
2312     if (eViewType == ViewType3D::Texture)
2313         m_xFLTexture->show();
2314     else
2315         m_xFLTexture->hide();
2316 
2317     // Material
2318     if( eViewType == ViewType3D::Material )
2319     {
2320         m_xFLMatSpecular->show();
2321         m_xFLMaterial->show();
2322     }
2323     else
2324     {
2325         m_xFLMatSpecular->hide();
2326         m_xFLMaterial->hide();
2327     }
2328     if( bUpdatePreview && !m_xBtnLight->get_active() )
2329         UpdatePreview();
2330 }
2331 
IMPL_LINK(Svx3DWin,ClickHdl,weld::Button &,rBtn,void)2332 IMPL_LINK( Svx3DWin, ClickHdl, weld::Button&, rBtn, void )
2333 {
2334     bool bUpdatePreview = false;
2335     sal_uInt16 nSId = 0;
2336 
2337     if( &rBtn == m_xBtnConvertTo3D.get() )
2338     {
2339         nSId = SID_CONVERT_TO_3D;
2340     }
2341     else if( &rBtn == m_xBtnLatheObject.get() )
2342     {
2343         nSId = SID_CONVERT_TO_3D_LATHE_FAST;
2344     }
2345     // Geometry
2346     else if( &rBtn == m_xBtnNormalsObj.get() ||
2347              &rBtn == m_xBtnNormalsFlat.get() ||
2348              &rBtn == m_xBtnNormalsSphere.get() )
2349     {
2350         m_xBtnNormalsObj->set_active( &rBtn == m_xBtnNormalsObj.get() );
2351         m_xBtnNormalsFlat->set_active( &rBtn == m_xBtnNormalsFlat.get() );
2352         m_xBtnNormalsSphere->set_active( &rBtn == m_xBtnNormalsSphere.get() );
2353         bUpdatePreview = true;
2354     }
2355     else if( &rBtn == m_xBtnLight1->get_widget() ||
2356              &rBtn == m_xBtnLight2->get_widget() ||
2357              &rBtn == m_xBtnLight3->get_widget() ||
2358              &rBtn == m_xBtnLight4->get_widget() ||
2359              &rBtn == m_xBtnLight5->get_widget() ||
2360              &rBtn == m_xBtnLight6->get_widget() ||
2361              &rBtn == m_xBtnLight7->get_widget() ||
2362              &rBtn == m_xBtnLight8->get_widget() )
2363     {
2364         // Lighting
2365         LightButton* pToggleBtn = GetLbByButton(&rBtn);
2366 
2367         ColorListBox* pLb = GetCLbByButton(pToggleBtn);
2368         pLb->show();
2369 
2370         bool bIsChecked = pToggleBtn->get_prev_active();
2371 
2372         if (pToggleBtn != m_xBtnLight1.get() && m_xBtnLight1->get_active())
2373         {
2374             m_xBtnLight1->set_active( false );
2375             m_xBtnLight1->set_prev_active(false);
2376             m_xLbLight1->hide();
2377         }
2378         if (pToggleBtn != m_xBtnLight2.get() && m_xBtnLight2->get_active())
2379         {
2380             m_xBtnLight2->set_active( false );
2381             m_xBtnLight2->set_prev_active(false);
2382             m_xLbLight2->hide();
2383         }
2384         if( pToggleBtn != m_xBtnLight3.get() && m_xBtnLight3->get_active() )
2385         {
2386             m_xBtnLight3->set_active( false );
2387             m_xBtnLight3->set_prev_active(false);
2388             m_xLbLight3->hide();
2389         }
2390         if( pToggleBtn != m_xBtnLight4.get() && m_xBtnLight4->get_active() )
2391         {
2392             m_xBtnLight4->set_active( false );
2393             m_xBtnLight4->set_prev_active(false);
2394             m_xLbLight4->hide();
2395         }
2396         if( pToggleBtn != m_xBtnLight5.get() && m_xBtnLight5->get_active() )
2397         {
2398             m_xBtnLight5->set_active( false );
2399             m_xBtnLight5->set_prev_active(false);
2400             m_xLbLight5->hide();
2401         }
2402         if( pToggleBtn != m_xBtnLight6.get() && m_xBtnLight6->get_active() )
2403         {
2404             m_xBtnLight6->set_active( false );
2405             m_xBtnLight6->set_prev_active(false);
2406             m_xLbLight6->hide();
2407         }
2408         if( pToggleBtn != m_xBtnLight7.get() && m_xBtnLight7->get_active() )
2409         {
2410             m_xBtnLight7->set_active( false );
2411             m_xBtnLight7->set_prev_active(false);
2412             m_xLbLight7->hide();
2413         }
2414         if( pToggleBtn != m_xBtnLight8.get() && m_xBtnLight8->get_active() )
2415         {
2416             m_xBtnLight8->set_active( false );
2417             m_xBtnLight8->set_prev_active(false);
2418             m_xLbLight8->hide();
2419         }
2420 
2421         //update light button
2422         pToggleBtn->set_active(true);
2423         pToggleBtn->set_prev_active(true);
2424         if (bIsChecked)
2425             pToggleBtn->switchLightOn(!pToggleBtn->isLightOn());
2426 
2427         bool bEnable = pToggleBtn->isLightOn();
2428         m_xBtnLightColor->set_sensitive( bEnable );
2429         pLb->set_sensitive( bEnable );
2430 
2431         ClickLight(*pToggleBtn);
2432         bUpdatePreview = true;
2433     }
2434     // Textures
2435     else if( &rBtn == m_xBtnTexLuminance.get() ||
2436              &rBtn == m_xBtnTexColor.get() )
2437     {
2438         m_xBtnTexLuminance->set_active( &rBtn == m_xBtnTexLuminance.get() );
2439         m_xBtnTexColor->set_active( &rBtn == m_xBtnTexColor.get() );
2440         bUpdatePreview = true;
2441     }
2442     else if( &rBtn == m_xBtnTexReplace.get() ||
2443              &rBtn == m_xBtnTexModulate.get() )
2444     {
2445         m_xBtnTexReplace->set_active( &rBtn == m_xBtnTexReplace.get() );
2446         m_xBtnTexModulate->set_active( &rBtn == m_xBtnTexModulate.get() );
2447         bUpdatePreview = true;
2448     }
2449     else if( &rBtn == m_xBtnTexParallelX.get() ||
2450              &rBtn == m_xBtnTexCircleX.get() ||
2451              &rBtn == m_xBtnTexObjectX.get() )
2452     {
2453         m_xBtnTexParallelX->set_active( &rBtn == m_xBtnTexParallelX.get() );
2454         m_xBtnTexCircleX->set_active( &rBtn == m_xBtnTexCircleX.get() );
2455         m_xBtnTexObjectX->set_active( &rBtn == m_xBtnTexObjectX.get() );
2456         bUpdatePreview = true;
2457     }
2458     else if( &rBtn == m_xBtnTexParallelY.get() ||
2459              &rBtn == m_xBtnTexCircleY.get() ||
2460              &rBtn == m_xBtnTexObjectY.get() )
2461     {
2462         m_xBtnTexParallelY->set_active( &rBtn == m_xBtnTexParallelY.get() );
2463         m_xBtnTexCircleY->set_active( &rBtn == m_xBtnTexCircleY.get() );
2464         m_xBtnTexObjectY->set_active( &rBtn == m_xBtnTexObjectY.get() );
2465         bUpdatePreview = true;
2466     }
2467     else if (&rBtn == m_xBtnShadow3d.get())
2468     {
2469         m_xFtSlant->set_sensitive( m_xBtnShadow3d->get_active() );
2470         m_xMtrSlant->set_sensitive( m_xBtnShadow3d->get_active() );
2471         bUpdatePreview = true;
2472     }
2473     // Other (no groups)
2474     else
2475     {
2476         bUpdatePreview = true;
2477     }
2478 
2479     if( nSId > 0 )
2480     {
2481         SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2482         if (pDispatcher != nullptr)
2483         {
2484             SfxBoolItem aItem( nSId, true );
2485             pDispatcher->ExecuteList(nSId,
2486                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2487         }
2488     }
2489     else if( bUpdatePreview )
2490         UpdatePreview();
2491 }
2492 
IMPL_LINK(Svx3DWin,ClickColorHdl,weld::Button &,rBtn,void)2493 IMPL_LINK( Svx3DWin, ClickColorHdl, weld::Button&, rBtn, void)
2494 {
2495     SvColorDialog aColorDlg;
2496     ColorListBox* pLb;
2497 
2498     if( &rBtn == m_xBtnLightColor.get() )
2499         pLb = GetCLbByButton();
2500     else if( &rBtn == m_xBtnAmbientColor.get() )
2501         pLb = m_xLbAmbientlight.get();
2502     else if( &rBtn == m_xBtnMatColor.get() )
2503         pLb = m_xLbMatColor.get();
2504     else if( &rBtn == m_xBtnEmissionColor.get() )
2505         pLb = m_xLbMatEmission.get();
2506     else // if( &rBtn == m_xBtnSpecularColor.get() )
2507         pLb = m_xLbMatSpecular.get();
2508 
2509     Color aColor = pLb->GetSelectEntryColor();
2510 
2511     aColorDlg.SetColor( aColor );
2512     if( aColorDlg.Execute(GetFrameWeld()) == RET_OK )
2513     {
2514         aColor = aColorDlg.GetColor();
2515         LBSelectColor(pLb, aColor);
2516         SelectColorHdl(*pLb);
2517     }
2518 }
2519 
IMPL_LINK(Svx3DWin,SelectHdl,weld::ComboBox &,rListBox,void)2520 IMPL_LINK( Svx3DWin, SelectHdl, weld::ComboBox&, rListBox, void )
2521 {
2522     bool bUpdatePreview = false;
2523 
2524     // Material
2525     if (&rListBox == m_xLbMatFavorites.get())
2526     {
2527         Color aColObj( COL_WHITE );
2528         Color aColEmis( COL_BLACK );
2529         Color aColSpec( COL_WHITE );
2530         sal_uInt16 nSpecIntens = 20;
2531 
2532         switch( m_xLbMatFavorites->get_active() )
2533         {
2534             case 1: // Metall
2535             {
2536                 aColObj = Color(230,230,255);
2537                 aColEmis = Color(10,10,30);
2538                 aColSpec = Color(200,200,200);
2539                 nSpecIntens = 20;
2540             }
2541             break;
2542 
2543             case 2: // Gold
2544             {
2545                 aColObj = Color(230,255,0);
2546                 aColEmis = Color(51,0,0);
2547                 aColSpec = Color(255,255,240);
2548                 nSpecIntens = 20;
2549             }
2550             break;
2551 
2552             case 3: // Chrome
2553             {
2554                 aColObj = Color(36,117,153);
2555                 aColEmis = Color(18,30,51);
2556                 aColSpec = Color(230,230,255);
2557                 nSpecIntens = 2;
2558             }
2559             break;
2560 
2561             case 4: // Plastic
2562             {
2563                 aColObj = Color(255,48,57);
2564                 aColEmis = Color(35,0,0);
2565                 aColSpec = Color(179,202,204);
2566                 nSpecIntens = 60;
2567             }
2568             break;
2569 
2570             case 5: // Wood
2571             {
2572                 aColObj = Color(153,71,1);
2573                 aColEmis = Color(21,22,0);
2574                 aColSpec = Color(255,255,153);
2575                 nSpecIntens = 75;
2576             }
2577             break;
2578         }
2579         LBSelectColor( m_xLbMatColor.get(), aColObj );
2580         LBSelectColor( m_xLbMatEmission.get(), aColEmis );
2581         LBSelectColor( m_xLbMatSpecular.get(), aColSpec );
2582         m_xMtrMatSpecularIntensity->set_value(nSpecIntens, FieldUnit::PERCENT);
2583 
2584         bUpdatePreview = true;
2585     }
2586     else if (&rListBox == m_xLbShademode.get())
2587         bUpdatePreview = true;
2588 
2589     if( bUpdatePreview )
2590         UpdatePreview();
2591 }
2592 
IMPL_LINK(Svx3DWin,SelectColorHdl,ColorListBox &,rListBox,void)2593 IMPL_LINK( Svx3DWin, SelectColorHdl, ColorListBox&, rListBox, void )
2594 {
2595     bool bUpdatePreview = false;
2596 
2597     if( &rListBox == m_xLbMatColor.get() ||
2598         &rListBox == m_xLbMatEmission.get() ||
2599         &rListBox == m_xLbMatSpecular.get() )
2600     {
2601         m_xLbMatFavorites->set_active( 0 );
2602         bUpdatePreview = true;
2603     }
2604     // Lighting
2605     else if( &rListBox == m_xLbAmbientlight.get() )
2606     {
2607         bUpdatePreview = true;
2608     }
2609     else if( &rListBox == m_xLbLight1.get() ||
2610              &rListBox == m_xLbLight2.get() ||
2611              &rListBox == m_xLbLight3.get() ||
2612              &rListBox == m_xLbLight4.get() ||
2613              &rListBox == m_xLbLight5.get() ||
2614              &rListBox == m_xLbLight6.get() ||
2615              &rListBox == m_xLbLight7.get() ||
2616              &rListBox == m_xLbLight8.get() )
2617     {
2618         bUpdatePreview = true;
2619     }
2620 
2621     if( bUpdatePreview )
2622         UpdatePreview();
2623 }
2624 
IMPL_LINK_NOARG(Svx3DWin,ModifyMetricHdl,weld::MetricSpinButton &,void)2625 IMPL_LINK_NOARG( Svx3DWin, ModifyMetricHdl, weld::MetricSpinButton&, void )
2626 {
2627     UpdatePreview();
2628 }
2629 
IMPL_LINK_NOARG(Svx3DWin,ModifySpinHdl,weld::SpinButton &,void)2630 IMPL_LINK_NOARG( Svx3DWin, ModifySpinHdl, weld::SpinButton&, void )
2631 {
2632     UpdatePreview();
2633 }
2634 
ClickLight(const LightButton & rBtn)2635 void Svx3DWin::ClickLight(const LightButton& rBtn)
2636 {
2637     sal_uInt16 nLightSource = GetLightSource( &rBtn );
2638     ColorListBox* pLb = GetCLbByButton( &rBtn );
2639     Color aColor( pLb->GetSelectEntryColor() );
2640     SfxItemSet aLightItemSet(m_xCtlLightPreview->GetSvx3DLightControl().Get3DAttributes());
2641     const bool bOnOff(rBtn.isLightOn());
2642 
2643     switch(nLightSource)
2644     {
2645         case 0: aLightItemSet.Put(makeSvx3DLightcolor1Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff1Item(bOnOff)); break;
2646         case 1: aLightItemSet.Put(makeSvx3DLightcolor2Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff2Item(bOnOff)); break;
2647         case 2: aLightItemSet.Put(makeSvx3DLightcolor3Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff3Item(bOnOff)); break;
2648         case 3: aLightItemSet.Put(makeSvx3DLightcolor4Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff4Item(bOnOff)); break;
2649         case 4: aLightItemSet.Put(makeSvx3DLightcolor5Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff5Item(bOnOff)); break;
2650         case 5: aLightItemSet.Put(makeSvx3DLightcolor6Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff6Item(bOnOff)); break;
2651         case 6: aLightItemSet.Put(makeSvx3DLightcolor7Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff7Item(bOnOff)); break;
2652         default:
2653         case 7: aLightItemSet.Put(makeSvx3DLightcolor8Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff8Item(bOnOff)); break;
2654     }
2655 
2656     m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes(aLightItemSet);
2657     m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(nLightSource);
2658     m_xCtlLightPreview->CheckSelection();
2659 }
2660 
IMPL_LINK_NOARG(Svx3DWin,ChangeSelectionCallbackHdl,SvxLightCtl3D *,void)2661 IMPL_LINK_NOARG(Svx3DWin, ChangeSelectionCallbackHdl, SvxLightCtl3D*, void)
2662 {
2663     const sal_uInt32 nLight(m_xCtlLightPreview->GetSvx3DLightControl().GetSelectedLight());
2664     weld::Button* pBtn = nullptr;
2665 
2666     switch( nLight )
2667     {
2668         case 0: pBtn = m_xBtnLight1->get_widget(); break;
2669         case 1: pBtn = m_xBtnLight2->get_widget(); break;
2670         case 2: pBtn = m_xBtnLight3->get_widget(); break;
2671         case 3: pBtn = m_xBtnLight4->get_widget(); break;
2672         case 4: pBtn = m_xBtnLight5->get_widget(); break;
2673         case 5: pBtn = m_xBtnLight6->get_widget(); break;
2674         case 6: pBtn = m_xBtnLight7->get_widget(); break;
2675         case 7: pBtn = m_xBtnLight8->get_widget(); break;
2676         default: break;
2677     }
2678 
2679     if (pBtn)
2680         ClickHdl(*pBtn);
2681     else
2682     {
2683         // Status: No lamp selected
2684         if( m_xBtnLight1->get_active() )
2685         {
2686             m_xBtnLight1->set_active( false );
2687             m_xLbLight1->set_sensitive( false );
2688         }
2689         else if( m_xBtnLight2->get_active() )
2690         {
2691             m_xBtnLight2->set_active( false );
2692             m_xLbLight2->set_sensitive( false );
2693         }
2694         else if( m_xBtnLight3->get_active() )
2695         {
2696             m_xBtnLight3->set_active( false );
2697             m_xLbLight3->set_sensitive( false );
2698         }
2699         else if( m_xBtnLight4->get_active() )
2700         {
2701             m_xBtnLight4->set_active( false );
2702             m_xLbLight4->set_sensitive( false );
2703         }
2704         else if( m_xBtnLight5->get_active() )
2705         {
2706             m_xBtnLight5->set_active( false );
2707             m_xLbLight5->set_sensitive( false );
2708         }
2709         else if( m_xBtnLight6->get_active() )
2710         {
2711             m_xBtnLight6->set_active( false );
2712             m_xLbLight6->set_sensitive( false );
2713         }
2714         else if( m_xBtnLight7->get_active() )
2715         {
2716             m_xBtnLight7->set_active( false );
2717             m_xLbLight7->set_sensitive( false );
2718         }
2719         else if( m_xBtnLight8->get_active() )
2720         {
2721             m_xBtnLight8->set_active( false );
2722             m_xLbLight8->set_sensitive( false );
2723         }
2724         m_xBtnLightColor->set_sensitive( false );
2725     }
2726 }
2727 
2728 namespace
2729 {
lcl_makeColorName(const Color & rColor)2730     OUString lcl_makeColorName(const Color& rColor)
2731     {
2732         OUString aStr = SvxResId(RID_SVXFLOAT3D_FIX_R) +
2733                         OUString::number(rColor.GetRed()) +
2734                         " " +
2735                         SvxResId(RID_SVXFLOAT3D_FIX_G) +
2736                         OUString::number(rColor.GetGreen()) +
2737                         " " +
2738                         SvxResId(RID_SVXFLOAT3D_FIX_B) +
2739                         OUString::number(rColor.GetBlue());
2740         return aStr;
2741     }
2742 }
2743 
2744 // Method to ensure that the LB is also associated with a color
LBSelectColor(ColorListBox * pLb,const Color & rColor)2745 void Svx3DWin::LBSelectColor( ColorListBox* pLb, const Color& rColor )
2746 {
2747     pLb->SetNoSelection();
2748     pLb->SelectEntry({rColor, lcl_makeColorName(rColor)});
2749 }
2750 
UpdatePreview()2751 void Svx3DWin::UpdatePreview()
2752 {
2753     if(!pModel)
2754     {
2755         pModel.reset(new FmFormModel());
2756     }
2757 
2758     // Get Itemset
2759     SfxItemSetFixed<SDRATTR_START, SDRATTR_END> aSet( pModel->GetItemPool() );
2760 
2761     // Get Attributes and set the preview
2762     GetAttr( aSet );
2763     m_xCtlPreview->Set3DAttributes( aSet );
2764     m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes( aSet );
2765 }
2766 
2767 
2768 // document is to be reloaded, destroy remembered ItemSet
DocumentReload()2769 void Svx3DWin::DocumentReload()
2770 {
2771     mpRemember2DAttributes.reset();
2772 }
2773 
InitColorLB()2774 void Svx3DWin::InitColorLB()
2775 {
2776     // First...
2777     Color aColWhite( COL_WHITE );
2778     Color aColBlack( COL_BLACK );
2779     m_xLbLight1->SelectEntry( aColWhite );
2780     m_xLbLight2->SelectEntry( aColWhite );
2781     m_xLbLight3->SelectEntry( aColWhite );
2782     m_xLbLight4->SelectEntry( aColWhite );
2783     m_xLbLight5->SelectEntry( aColWhite );
2784     m_xLbLight6->SelectEntry( aColWhite );
2785     m_xLbLight7->SelectEntry( aColWhite );
2786     m_xLbLight8->SelectEntry( aColWhite );
2787     m_xLbAmbientlight->SelectEntry( aColBlack );
2788     m_xLbMatColor->SelectEntry( aColWhite );
2789     m_xLbMatEmission->SelectEntry( aColBlack );
2790     m_xLbMatSpecular->SelectEntry( aColWhite );
2791 }
2792 
GetLightSource(const LightButton * pBtn) const2793 sal_uInt16 Svx3DWin::GetLightSource( const LightButton* pBtn ) const
2794 {
2795     sal_uInt16 nLight = 8;
2796 
2797     if (pBtn == m_xBtnLight1.get())
2798         nLight = 0;
2799     else if (pBtn == m_xBtnLight2.get())
2800         nLight = 1;
2801     else if( pBtn == m_xBtnLight3.get() )
2802         nLight = 2;
2803     else if( pBtn == m_xBtnLight4.get() )
2804         nLight = 3;
2805     else if( pBtn == m_xBtnLight5.get() )
2806         nLight = 4;
2807     else if( pBtn == m_xBtnLight6.get() )
2808         nLight = 5;
2809     else if( pBtn == m_xBtnLight7.get() )
2810         nLight = 6;
2811     else if( pBtn == m_xBtnLight8.get() )
2812         nLight = 7;
2813 
2814     return nLight;
2815 };
2816 
GetCLbByButton(const LightButton * pBtn)2817 ColorListBox* Svx3DWin::GetCLbByButton( const LightButton* pBtn )
2818 {
2819     ColorListBox* pLb = nullptr;
2820 
2821     if( pBtn == nullptr )
2822     {
2823         if( m_xBtnLight1->get_active() )
2824             pLb = m_xLbLight1.get();
2825         else if( m_xBtnLight2->get_active() )
2826             pLb = m_xLbLight2.get();
2827         else if( m_xBtnLight3->get_active() )
2828             pLb = m_xLbLight3.get();
2829         else if( m_xBtnLight4->get_active() )
2830             pLb = m_xLbLight4.get();
2831         else if( m_xBtnLight5->get_active() )
2832             pLb = m_xLbLight5.get();
2833         else if( m_xBtnLight6->get_active() )
2834             pLb = m_xLbLight6.get();
2835         else if( m_xBtnLight7->get_active() )
2836             pLb = m_xLbLight7.get();
2837         else if( m_xBtnLight8->get_active() )
2838             pLb = m_xLbLight8.get();
2839     }
2840     else
2841     {
2842         if( pBtn == m_xBtnLight1.get() )
2843             pLb = m_xLbLight1.get();
2844         else if (pBtn == m_xBtnLight2.get())
2845             pLb = m_xLbLight2.get();
2846         else if( pBtn == m_xBtnLight3.get() )
2847             pLb = m_xLbLight3.get();
2848         else if( pBtn == m_xBtnLight4.get() )
2849             pLb = m_xLbLight4.get();
2850         else if( pBtn == m_xBtnLight5.get() )
2851             pLb = m_xLbLight5.get();
2852         else if( pBtn == m_xBtnLight6.get() )
2853             pLb = m_xLbLight6.get();
2854         else if( pBtn == m_xBtnLight7.get() )
2855             pLb = m_xLbLight7.get();
2856         else if( pBtn == m_xBtnLight8.get() )
2857             pLb = m_xLbLight8.get();
2858     }
2859     return pLb;
2860 };
2861 
GetLbByButton(const weld::Button * pBtn)2862 LightButton* Svx3DWin::GetLbByButton( const weld::Button* pBtn )
2863 {
2864     LightButton* pLb = nullptr;
2865 
2866     if( pBtn == m_xBtnLight1->get_widget() )
2867         pLb = m_xBtnLight1.get();
2868     else if (pBtn == m_xBtnLight2->get_widget() )
2869         pLb = m_xBtnLight2.get();
2870     else if( pBtn == m_xBtnLight3->get_widget() )
2871         pLb = m_xBtnLight3.get();
2872     else if( pBtn == m_xBtnLight4->get_widget() )
2873         pLb = m_xBtnLight4.get();
2874     else if( pBtn == m_xBtnLight5->get_widget() )
2875         pLb = m_xBtnLight5.get();
2876     else if( pBtn == m_xBtnLight6->get_widget() )
2877         pLb = m_xBtnLight6.get();
2878     else if( pBtn == m_xBtnLight7->get_widget() )
2879         pLb = m_xBtnLight7.get();
2880     else if( pBtn == m_xBtnLight8->get_widget() )
2881         pLb = m_xBtnLight8.get();
2882 
2883     return pLb;
2884 };
2885 
2886 // Derivation from SfxChildWindow as "containers" for effects
Svx3DChildWindow(vcl::Window * _pParent,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)2887 Svx3DChildWindow::Svx3DChildWindow( vcl::Window* _pParent,
2888                                                          sal_uInt16 nId,
2889                                                          SfxBindings* pBindings,
2890                                                          SfxChildWinInfo* pInfo ) :
2891     SfxChildWindow( _pParent, nId )
2892 {
2893     VclPtr<Svx3DWin> pWin = VclPtr<Svx3DWin>::Create( pBindings, this, _pParent );
2894     SetWindow(pWin);
2895 
2896     pWin->Initialize( pInfo );
2897 }
2898 
Svx3DCtrlItem(sal_uInt16 _nId,SfxBindings * _pBindings)2899 Svx3DCtrlItem::Svx3DCtrlItem( sal_uInt16 _nId,
2900                                 SfxBindings* _pBindings) :
2901     SfxControllerItem( _nId, *_pBindings )
2902 {
2903 }
2904 
2905 
StateChangedAtToolBoxControl(sal_uInt16,SfxItemState,const SfxPoolItem *)2906 void Svx3DCtrlItem::StateChangedAtToolBoxControl( sal_uInt16 /*nSId*/,
2907                         SfxItemState /*eState*/, const SfxPoolItem* /*pItem*/ )
2908 {
2909 }
2910 
2911 // ControllerItem for Status Slot SID_CONVERT_TO_3D
2912 
SvxConvertTo3DItem(sal_uInt16 _nId,SfxBindings * _pBindings)2913 SvxConvertTo3DItem::SvxConvertTo3DItem(sal_uInt16 _nId, SfxBindings* _pBindings)
2914 :   SfxControllerItem(_nId, *_pBindings),
2915     bState(false)
2916 {
2917 }
2918 
StateChangedAtToolBoxControl(sal_uInt16,SfxItemState eState,const SfxPoolItem *)2919 void SvxConvertTo3DItem::StateChangedAtToolBoxControl(sal_uInt16 /*_nId*/, SfxItemState eState, const SfxPoolItem* /*pState*/)
2920 {
2921     bool bNewState = (eState != SfxItemState::DISABLED);
2922     if(bNewState != bState)
2923     {
2924         bState = bNewState;
2925         SfxDispatcher* pDispatcher = LocalGetDispatcher(&GetBindings());
2926         if (pDispatcher != nullptr)
2927         {
2928             SfxBoolItem aItem( SID_3D_STATE, true );
2929             pDispatcher->ExecuteList(SID_3D_STATE,
2930                     SfxCallMode::ASYNCHRON|SfxCallMode::RECORD, { &aItem });
2931         }
2932     }
2933 }
2934 
LightButton(std::unique_ptr<weld::ToggleButton> xButton)2935 LightButton::LightButton(std::unique_ptr<weld::ToggleButton> xButton)
2936     : m_xButton(std::move(xButton))
2937     , m_bLightOn(false)
2938     , m_bButtonPrevActive(false)
2939 {
2940     m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF);
2941 }
2942 
switchLightOn(bool bOn)2943 void LightButton::switchLightOn(bool bOn)
2944 {
2945     if (m_bLightOn == bOn)
2946         return;
2947     m_bLightOn = bOn;
2948     if (m_bLightOn)
2949         m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_ON);
2950     else
2951         m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF);
2952 }
2953 
2954 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2955