Coverage Report

Created: 2025-12-31 10:39

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