1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <comphelper/propertyvalue.hxx>
23 #include <svtools/toolbarmenu.hxx>
24 #include <vcl/toolbox.hxx>
26 #include <svx/strings.hrc>
27 #include <svx/svdtrans.hxx>
28 #include <svx/dialmgr.hxx>
31 #include "extrusioncontrols.hxx"
32 #include <extrusiondepthdialog.hxx>
34 #include <bitmaps.hlst>
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::com::sun::star::util
;
39 using namespace ::com::sun::star::graphic
;
44 const sal_Int32 gSkewList
[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
45 constexpr OUString g_sExtrusionDirection
= u
".uno:ExtrusionDirection"_ustr
;
46 constexpr OUString g_sExtrusionProjection
= u
".uno:ExtrusionProjection"_ustr
;
47 constexpr OUString EMPTY
= u
""_ustr
;
49 constexpr OUString aLightOffBmps
[] =
51 RID_SVXBMP_LIGHT_OFF_FROM_TOP_LEFT
,
52 RID_SVXBMP_LIGHT_OFF_FROM_TOP
,
53 RID_SVXBMP_LIGHT_OFF_FROM_TOP_RIGHT
,
54 RID_SVXBMP_LIGHT_OFF_FROM_LEFT
,
56 RID_SVXBMP_LIGHT_OFF_FROM_RIGHT
,
57 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_LEFT
,
58 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM
,
59 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_RIGHT
62 constexpr OUString aLightOnBmps
[] =
64 RID_SVXBMP_LIGHT_ON_FROM_TOP_LEFT
,
65 RID_SVXBMP_LIGHT_ON_FROM_TOP
,
66 RID_SVXBMP_LIGHT_ON_FROM_TOP_RIGHT
,
67 RID_SVXBMP_LIGHT_ON_FROM_LEFT
,
69 RID_SVXBMP_LIGHT_ON_FROM_RIGHT
,
70 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_LEFT
,
71 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM
,
72 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_RIGHT
75 constexpr OUString aLightPreviewBmps
[] =
77 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_LEFT
,
78 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP
,
79 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_RIGHT
,
80 RID_SVXBMP_LIGHT_PREVIEW_FROM_LEFT
,
81 RID_SVXBMP_LIGHT_PREVIEW_FROM_FRONT
,
82 RID_SVXBMP_LIGHT_PREVIEW_FROM_RIGHT
,
83 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT
,
84 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM
,
85 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT
88 constexpr OUString aDirectionBmps
[] =
90 RID_SVXBMP_DIRECTION_DIRECTION_NW
,
91 RID_SVXBMP_DIRECTION_DIRECTION_N
,
92 RID_SVXBMP_DIRECTION_DIRECTION_NE
,
93 RID_SVXBMP_DIRECTION_DIRECTION_W
,
94 RID_SVXBMP_DIRECTION_DIRECTION_NONE
,
95 RID_SVXBMP_DIRECTION_DIRECTION_E
,
96 RID_SVXBMP_DIRECTION_DIRECTION_SW
,
97 RID_SVXBMP_DIRECTION_DIRECTION_S
,
98 RID_SVXBMP_DIRECTION_DIRECTION_SE
101 static TranslateId aDirectionStrs
[] =
103 RID_SVXSTR_DIRECTION_NW
,
104 RID_SVXSTR_DIRECTION_N
,
105 RID_SVXSTR_DIRECTION_NE
,
106 RID_SVXSTR_DIRECTION_W
,
107 RID_SVXSTR_DIRECTION_NONE
,
108 RID_SVXSTR_DIRECTION_E
,
109 RID_SVXSTR_DIRECTION_SW
,
110 RID_SVXSTR_DIRECTION_S
,
111 RID_SVXSTR_DIRECTION_SE
114 ExtrusionDirectionWindow::ExtrusionDirectionWindow(
115 svt::PopupWindowController
* pControl
,
116 weld::Widget
* pParent
)
117 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, u
"svx/ui/directionwindow.ui"_ustr
, u
"DirectionWindow"_ustr
)
118 , mxControl(pControl
)
119 , mxDirectionSet(new ValueSet(nullptr))
120 , mxDirectionSetWin(new weld::CustomWeld(*m_xBuilder
, u
"valueset"_ustr
, *mxDirectionSet
))
121 , mxPerspective(m_xBuilder
->weld_radio_button(u
"perspective"_ustr
))
122 , mxParallel(m_xBuilder
->weld_radio_button(u
"parallel"_ustr
))
124 mxDirectionSet
->SetStyle(WB_TABSTOP
| WB_MENUSTYLEVALUESET
| WB_FLATVALUESET
| WB_NOBORDER
| WB_NO_DIRECTSELECT
);
126 for (sal_uInt16 i
= DIRECTION_NW
; i
<= DIRECTION_SE
; ++i
)
128 maImgDirection
[i
] = Image(StockImage::Yes
, aDirectionBmps
[i
]);
131 mxDirectionSet
->SetSelectHdl( LINK( this, ExtrusionDirectionWindow
, SelectValueSetHdl
) );
132 mxDirectionSet
->SetColCount( 3 );
133 mxDirectionSet
->EnableFullItemMode( false );
135 for (sal_uInt16 i
= DIRECTION_NW
; i
<= DIRECTION_SE
; ++i
)
137 mxDirectionSet
->InsertItem(i
+ 1, maImgDirection
[i
], SvxResId(aDirectionStrs
[i
]));
141 mxDirectionSet
->GetDrawingArea()->set_size_request(aSize
.Width(), aSize
.Height());
142 mxDirectionSet
->SetOutputSizePixel(aSize
);
144 mxPerspective
->connect_toggled(LINK(this, ExtrusionDirectionWindow
, SelectToolbarMenuHdl
));
146 AddStatusListener( g_sExtrusionDirection
);
147 AddStatusListener( g_sExtrusionProjection
);
150 void ExtrusionDirectionWindow::GrabFocus()
152 mxDirectionSet
->GrabFocus();
155 ExtrusionDirectionWindow::~ExtrusionDirectionWindow()
159 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew
, bool bEnabled
)
162 for( nItemId
= DIRECTION_NW
; nItemId
<= DIRECTION_SE
; nItemId
++ )
164 if( gSkewList
[nItemId
] == nSkew
)
168 if( nItemId
<= DIRECTION_SE
)
170 mxDirectionSet
->SelectItem( nItemId
+1 );
174 mxDirectionSet
->SetNoSelection();
178 mxDirectionSet
->Enable();
180 mxDirectionSet
->Disable();
183 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection
, bool bEnabled
)
185 mxPerspective
->set_active(nProjection
== 0 && bEnabled
);
186 mxParallel
->set_active(nProjection
== 1 && bEnabled
);
187 mxPerspective
->set_sensitive(bEnabled
);
188 mxParallel
->set_sensitive(bEnabled
);
191 void ExtrusionDirectionWindow::statusChanged(
192 const css::frame::FeatureStateEvent
& Event
195 if( Event
.FeatureURL
.Main
== g_sExtrusionDirection
)
197 if( !Event
.IsEnabled
)
199 implSetDirection( -1, false );
203 sal_Int32 nValue
= 0;
204 if( Event
.State
>>= nValue
)
205 implSetDirection( nValue
, true );
208 else if( Event
.FeatureURL
.Main
== g_sExtrusionProjection
)
210 if( !Event
.IsEnabled
)
212 implSetProjection( -1, false );
216 sal_Int32 nValue
= 0;
217 if( Event
.State
>>= nValue
)
218 implSetProjection( nValue
, true );
223 IMPL_LINK_NOARG(ExtrusionDirectionWindow
, SelectValueSetHdl
, ValueSet
*, void)
225 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
226 g_sExtrusionDirection
.copy(5),
227 gSkewList
[mxDirectionSet
->GetSelectedItemId()-1]) };
229 mxControl
->dispatchCommand( g_sExtrusionDirection
, aArgs
);
231 mxControl
->EndPopupMode();
234 IMPL_LINK_NOARG(ExtrusionDirectionWindow
, SelectToolbarMenuHdl
, weld::Toggleable
&, void)
236 int nProjection
= mxPerspective
->get_active() ? 0 : 1;
238 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
239 g_sExtrusionProjection
.copy(5), static_cast<sal_Int32
>(nProjection
)) };
241 mxControl
->dispatchCommand( g_sExtrusionProjection
, aArgs
);
242 implSetProjection( nProjection
, true );
244 mxControl
->EndPopupMode();
247 ExtrusionDirectionControl::ExtrusionDirectionControl(
248 const Reference
< XComponentContext
>& rxContext
249 ) : svt::PopupWindowController(
251 Reference
< css::frame::XFrame
>(),
252 u
".uno:ExtrusionDirectionFloater"_ustr
257 std::unique_ptr
<WeldToolbarPopup
> ExtrusionDirectionControl::weldPopupWindow()
259 return std::make_unique
<ExtrusionDirectionWindow
>(this, m_pToolbar
);
262 VclPtr
<vcl::Window
> ExtrusionDirectionControl::createVclPopupWindow( vcl::Window
* pParent
)
264 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
265 std::make_unique
<ExtrusionDirectionWindow
>(this, pParent
->GetFrameWeld()));
267 mxInterimPopover
->Show();
269 return mxInterimPopover
;
273 void SAL_CALL
ExtrusionDirectionControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
275 svt::PopupWindowController::initialize( aArguments
);
277 ToolBox
* pToolBox
= nullptr;
279 if ( getToolboxId( nId
, &pToolBox
) )
280 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
286 OUString
ExtrusionDirectionControl::getImplementationName()
288 return u
"com.sun.star.comp.svx.ExtrusionDirectionController"_ustr
;
292 Sequence
< OUString
> ExtrusionDirectionControl::getSupportedServiceNames()
294 return { u
"com.sun.star.frame.ToolbarController"_ustr
};
298 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
299 com_sun_star_comp_svx_ExtrusionDirectionControl_get_implementation(
300 css::uno::XComponentContext
* xContext
,
301 css::uno::Sequence
<css::uno::Any
> const &)
303 return cppu::acquire(new ExtrusionDirectionControl(xContext
));
307 ExtrusionDepthDialog::ExtrusionDepthDialog(weld::Window
* pParent
, double fDepth
, FieldUnit eDefaultUnit
)
308 : GenericDialogController(pParent
, u
"svx/ui/extrustiondepthdialog.ui"_ustr
, u
"ExtrustionDepthDialog"_ustr
)
309 , m_xMtrDepth(m_xBuilder
->weld_metric_spin_button(u
"depth"_ustr
, eDefaultUnit
))
311 m_xMtrDepth
->set_value(static_cast<int>(fDepth
) * 100, FieldUnit::MM_100TH
);
314 ExtrusionDepthDialog::~ExtrusionDepthDialog()
318 double ExtrusionDepthDialog::getDepth() const
320 return static_cast<double>(m_xMtrDepth
->get_value(FieldUnit::MM_100TH
)) / 100.0;
323 double const aDepthListInch
[] = { 0, 1270,2540,5080,10160 };
324 double const aDepthListMM
[] = { 0, 1000, 2500, 5000, 10000 };
326 constexpr OUString
gsExtrusionDepth( u
".uno:ExtrusionDepth"_ustr
);
327 constexpr OUString
gsMetricUnit( u
".uno:MetricUnit"_ustr
);
329 ExtrusionDepthWindow::ExtrusionDepthWindow(svt::PopupWindowController
* pControl
, weld::Widget
* pParent
)
330 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, u
"svx/ui/depthwindow.ui"_ustr
, u
"DepthWindow"_ustr
)
331 , mxControl(pControl
)
332 , mxDepth0(m_xBuilder
->weld_radio_button(u
"depth0"_ustr
))
333 , mxDepth1(m_xBuilder
->weld_radio_button(u
"depth1"_ustr
))
334 , mxDepth2(m_xBuilder
->weld_radio_button(u
"depth2"_ustr
))
335 , mxDepth3(m_xBuilder
->weld_radio_button(u
"depth3"_ustr
))
336 , mxDepth4(m_xBuilder
->weld_radio_button(u
"depth4"_ustr
))
337 , mxInfinity(m_xBuilder
->weld_radio_button(u
"infinity"_ustr
))
338 , mxCustom(m_xBuilder
->weld_radio_button(u
"custom"_ustr
))
339 , meUnit(FieldUnit::NONE
)
341 , mbSettingValue(false)
342 , mbCommandDispatched(false)
344 mxDepth0
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
345 mxDepth1
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
346 mxDepth2
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
347 mxDepth3
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
348 mxDepth4
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
349 mxInfinity
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
350 mxCustom
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
351 mxCustom
->connect_mouse_release(LINK(this, ExtrusionDepthWindow
, MouseReleaseHdl
));
353 AddStatusListener( gsExtrusionDepth
);
354 AddStatusListener( gsMetricUnit
);
357 void ExtrusionDepthWindow::GrabFocus()
359 mxDepth0
->grab_focus();
362 void ExtrusionDepthWindow::implSetDepth( double fDepth
)
366 bool bSettingValue
= mbSettingValue
;
367 mbSettingValue
= true;
369 mxCustom
->set_active(true);
370 bool bIsMetric
= IsMetric(meUnit
);
371 mxDepth0
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[0] : aDepthListInch
[0]));
372 mxDepth1
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[1] : aDepthListInch
[1]));
373 mxDepth2
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[2] : aDepthListInch
[2]));
374 mxDepth3
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[3] : aDepthListInch
[3]));
375 mxDepth4
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[4] : aDepthListInch
[4]));
376 mxInfinity
->set_active(fDepth
>= 338666);
378 mbSettingValue
= bSettingValue
;
381 void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit
)
385 const TranslateId aDepths
[] =
394 const TranslateId aDepthsInch
[] =
396 RID_SVXSTR_DEPTH_0_INCH
,
397 RID_SVXSTR_DEPTH_1_INCH
,
398 RID_SVXSTR_DEPTH_2_INCH
,
399 RID_SVXSTR_DEPTH_3_INCH
,
400 RID_SVXSTR_DEPTH_4_INCH
403 static_assert(SAL_N_ELEMENTS(aDepths
) == SAL_N_ELEMENTS(aDepthsInch
));
405 const TranslateId
* pResource
= IsMetric(eUnit
) ? aDepths
: aDepthsInch
;
407 mxDepth0
->set_label(SvxResId(pResource
[0]));
408 mxDepth1
->set_label(SvxResId(pResource
[1]));
409 mxDepth2
->set_label(SvxResId(pResource
[2]));
410 mxDepth3
->set_label(SvxResId(pResource
[3]));
411 mxDepth4
->set_label(SvxResId(pResource
[4]));
414 void ExtrusionDepthWindow::statusChanged(
415 const css::frame::FeatureStateEvent
& Event
418 if( Event
.FeatureURL
.Main
== gsExtrusionDepth
)
420 if( !Event
.IsEnabled
)
427 if( Event
.State
>>= fValue
)
428 implSetDepth( fValue
);
431 else if( Event
.FeatureURL
.Main
== gsMetricUnit
)
433 if( Event
.IsEnabled
)
435 sal_Int32 nValue
= 0;
436 if( Event
.State
>>= nValue
)
438 implFillStrings( static_cast<FieldUnit
>(nValue
) );
440 implSetDepth( mfDepth
);
446 void ExtrusionDepthWindow::DispatchDepthDialog()
448 Sequence
< PropertyValue
> aArgs
{
449 comphelper::makePropertyValue(u
"Depth"_ustr
, mfDepth
),
450 comphelper::makePropertyValue(u
"Metric"_ustr
, static_cast<sal_Int32
>( meUnit
))
453 rtl::Reference
<svt::PopupWindowController
> xControl(mxControl
);
454 xControl
->EndPopupMode();
455 xControl
->dispatchCommand(u
".uno:ExtrusionDepthDialog"_ustr
, aArgs
);
456 mbCommandDispatched
= true;
459 IMPL_LINK(ExtrusionDepthWindow
, SelectHdl
, weld::Toggleable
&, rButton
, void)
461 if (mbSettingValue
|| !rButton
.get_active())
464 // see MouseReleaseHdl for mbCommandDispatched check, there's no guarantee
465 // this toggle will happen before that mouse release though it does in
466 // practice for vcl and gtk
467 if (mbCommandDispatched
)
470 if (mxCustom
->get_active())
471 DispatchDepthDialog();
476 if (mxInfinity
->get_active())
483 if (mxDepth0
->get_active())
485 else if (mxDepth1
->get_active())
487 else if (mxDepth2
->get_active())
489 else if (mxDepth3
->get_active())
494 fDepth
= IsMetric( meUnit
) ? aDepthListMM
[nSelected
] : aDepthListInch
[nSelected
];
497 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
498 gsExtrusionDepth
.copy(5), fDepth
) };
500 mxControl
->dispatchCommand( gsExtrusionDepth
, aArgs
);
501 mbCommandDispatched
= true;
502 implSetDepth( fDepth
);
504 mxControl
->EndPopupMode();
508 IMPL_LINK_NOARG(ExtrusionDepthWindow
, MouseReleaseHdl
, const MouseEvent
&, bool)
511 tdf#145296 if the "custom" radiobutton was presented preselected as
512 toggled on and the user clicked on it then there's no toggled signal sent
513 because the item was already toggled on and didn't change state.
515 So if that happens launch the custom spacing dialog explicitly here on
518 if (mxCustom
->get_active() && !mbCommandDispatched
)
520 DispatchDepthDialog();
526 // ExtrusionDirectionControl
527 ExtrusionDepthController::ExtrusionDepthController(
528 const Reference
< XComponentContext
>& rxContext
529 ) : svt::PopupWindowController(
531 Reference
< css::frame::XFrame
>(),
532 u
".uno:ExtrusionDepthFloater"_ustr
537 std::unique_ptr
<WeldToolbarPopup
> ExtrusionDepthController::weldPopupWindow()
539 return std::make_unique
<ExtrusionDepthWindow
>(this, m_pToolbar
);
542 VclPtr
<vcl::Window
> ExtrusionDepthController::createVclPopupWindow( vcl::Window
* pParent
)
544 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
545 std::make_unique
<ExtrusionDepthWindow
>(this, pParent
->GetFrameWeld()));
547 mxInterimPopover
->Show();
549 return mxInterimPopover
;
553 void SAL_CALL
ExtrusionDepthController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
555 svt::PopupWindowController::initialize( aArguments
);
557 ToolBox
* pToolBox
= nullptr;
559 if ( getToolboxId( nId
, &pToolBox
) )
560 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
566 OUString
ExtrusionDepthController::getImplementationName()
568 return u
"com.sun.star.comp.svx.ExtrusionDepthController"_ustr
;
572 Sequence
< OUString
> ExtrusionDepthController::getSupportedServiceNames()
574 return { u
"com.sun.star.frame.ToolbarController"_ustr
};
578 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
579 com_sun_star_comp_svx_ExtrusionDepthController_get_implementation(
580 css::uno::XComponentContext
* xContext
,
581 css::uno::Sequence
<css::uno::Any
> const &)
583 return cppu::acquire(new ExtrusionDepthController(xContext
));
587 constexpr OUString g_sExtrusionLightingDirection
= u
".uno:ExtrusionLightingDirection"_ustr
;
588 constexpr OUString g_sExtrusionLightingIntensity
= u
".uno:ExtrusionLightingIntensity"_ustr
;
590 ExtrusionLightingWindow::ExtrusionLightingWindow(svt::PopupWindowController
* pControl
,
591 weld::Widget
* pParent
)
592 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, u
"svx/ui/lightingwindow.ui"_ustr
, u
"LightingWindow"_ustr
)
593 , mxControl(pControl
)
594 , mxLightingSet(new ValueSet(nullptr))
595 , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder
, u
"valueset"_ustr
, *mxLightingSet
))
596 , mxBright(m_xBuilder
->weld_radio_button(u
"bright"_ustr
))
597 , mxNormal(m_xBuilder
->weld_radio_button(u
"normal"_ustr
))
598 , mxDim(m_xBuilder
->weld_radio_button(u
"dim"_ustr
))
600 mxLightingSet
->SetStyle(WB_TABSTOP
| WB_MENUSTYLEVALUESET
| WB_FLATVALUESET
| WB_NOBORDER
| WB_NO_DIRECTSELECT
);
602 for (sal_uInt16 i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; ++i
)
604 if( i
!= FROM_FRONT
)
606 maImgLightingOff
[i
] = Image(StockImage::Yes
, aLightOffBmps
[i
]);
607 maImgLightingOn
[i
] = Image(StockImage::Yes
, aLightOnBmps
[i
]);
609 maImgLightingPreview
[i
] = Image(StockImage::Yes
, aLightPreviewBmps
[i
]);
612 mxLightingSet
->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING
);
614 mxLightingSet
->SetSelectHdl( LINK( this, ExtrusionLightingWindow
, SelectValueSetHdl
) );
615 mxLightingSet
->SetColCount( 3 );
616 mxLightingSet
->EnableFullItemMode( false );
618 for (sal_uInt16 i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; ++i
)
620 if( i
!= FROM_FRONT
)
622 mxLightingSet
->InsertItem( i
+1, maImgLightingOff
[i
] );
626 mxLightingSet
->InsertItem( 5, maImgLightingPreview
[FROM_FRONT
] );
630 mxLightingSet
->GetDrawingArea()->set_size_request(aSize
.Width(), aSize
.Height());
631 mxLightingSet
->SetOutputSizePixel(aSize
);
633 mxBright
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
634 mxNormal
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
635 mxDim
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
637 AddStatusListener( g_sExtrusionLightingDirection
);
638 AddStatusListener( g_sExtrusionLightingIntensity
);
641 void ExtrusionLightingWindow::GrabFocus()
643 mxLightingSet
->GrabFocus();
646 ExtrusionLightingWindow::~ExtrusionLightingWindow()
650 void ExtrusionLightingWindow::implSetIntensity( int nLevel
, bool bEnabled
)
652 mxBright
->set_sensitive(bEnabled
);
653 mxBright
->set_active(nLevel
== 0 && bEnabled
);
654 mxNormal
->set_sensitive(bEnabled
);
655 mxNormal
->set_active(nLevel
== 1 && bEnabled
);
656 mxDim
->set_sensitive(bEnabled
);
657 mxDim
->set_active(nLevel
== 2 && bEnabled
);
660 void ExtrusionLightingWindow::implSetDirection( int nDirection
, bool bEnabled
)
663 nDirection
= FROM_FRONT
;
666 for( nItemId
= FROM_TOP_LEFT
; nItemId
<= FROM_BOTTOM_RIGHT
; nItemId
++ )
668 if( nItemId
== FROM_FRONT
)
670 mxLightingSet
->SetItemImage( nItemId
+ 1, maImgLightingPreview
[ nDirection
] );
674 mxLightingSet
->SetItemImage(
676 static_cast<sal_uInt16
>(nDirection
) == nItemId
? maImgLightingOn
[nItemId
] : maImgLightingOff
[nItemId
]
682 mxLightingSet
->Enable();
684 mxLightingSet
->Disable();
687 void ExtrusionLightingWindow::statusChanged(
688 const css::frame::FeatureStateEvent
& Event
691 if( Event
.FeatureURL
.Main
== g_sExtrusionLightingIntensity
)
693 if( !Event
.IsEnabled
)
695 implSetIntensity( 0, false );
699 sal_Int32 nValue
= 0;
700 if( Event
.State
>>= nValue
)
701 implSetIntensity( nValue
, true );
704 else if( Event
.FeatureURL
.Main
== g_sExtrusionLightingDirection
)
706 if( !Event
.IsEnabled
)
708 implSetDirection( 0, false );
712 sal_Int32 nValue
= 0;
713 if( Event
.State
>>= nValue
)
714 implSetDirection( nValue
, true );
719 IMPL_LINK_NOARG(ExtrusionLightingWindow
, SelectValueSetHdl
, ValueSet
*, void)
721 sal_Int32 nDirection
= mxLightingSet
->GetSelectedItemId();
723 if( (nDirection
> 0) && (nDirection
< 10) )
727 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
728 g_sExtrusionLightingDirection
.copy(5), nDirection
) };
730 mxControl
->dispatchCommand( g_sExtrusionLightingDirection
, aArgs
);
732 implSetDirection( nDirection
, true );
735 mxControl
->EndPopupMode();
738 IMPL_LINK(ExtrusionLightingWindow
, SelectToolbarMenuHdl
, weld::Toggleable
&, rButton
, void)
740 if (!rButton
.get_active())
744 if (mxBright
->get_active())
746 else if (mxNormal
->get_active())
751 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
752 g_sExtrusionLightingIntensity
.copy(5), static_cast<sal_Int32
>(nLevel
)) };
754 mxControl
->dispatchCommand( g_sExtrusionLightingIntensity
, aArgs
);
756 implSetIntensity( nLevel
, true );
758 mxControl
->EndPopupMode();
761 ExtrusionLightingControl::ExtrusionLightingControl(
762 const Reference
< XComponentContext
>& rxContext
763 ) : svt::PopupWindowController( rxContext
,
764 Reference
< css::frame::XFrame
>(),
765 u
".uno:ExtrusionDirectionFloater"_ustr
770 std::unique_ptr
<WeldToolbarPopup
> ExtrusionLightingControl::weldPopupWindow()
772 return std::make_unique
<ExtrusionLightingWindow
>(this, m_pToolbar
);
775 VclPtr
<vcl::Window
> ExtrusionLightingControl::createVclPopupWindow( vcl::Window
* pParent
)
777 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
778 std::make_unique
<ExtrusionLightingWindow
>(this, pParent
->GetFrameWeld()));
780 mxInterimPopover
->Show();
782 return mxInterimPopover
;
786 void SAL_CALL
ExtrusionLightingControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
788 svt::PopupWindowController::initialize( aArguments
);
790 ToolBox
* pToolBox
= nullptr;
792 if ( getToolboxId( nId
, &pToolBox
) )
793 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
799 OUString
ExtrusionLightingControl::getImplementationName()
801 return u
"com.sun.star.comp.svx.ExtrusionLightingController"_ustr
;
805 Sequence
< OUString
> ExtrusionLightingControl::getSupportedServiceNames()
807 return { u
"com.sun.star.frame.ToolbarController"_ustr
};
811 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
812 com_sun_star_comp_svx_ExtrusionLightingControl_get_implementation(
813 css::uno::XComponentContext
* xContext
,
814 css::uno::Sequence
<css::uno::Any
> const &)
816 return cppu::acquire(new ExtrusionLightingControl(xContext
));
820 constexpr OUString g_sExtrusionSurface
= u
".uno:ExtrusionSurface"_ustr
;
822 ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(svt::PopupWindowController
* pControl
, weld::Widget
* pParent
)
823 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, u
"svx/ui/surfacewindow.ui"_ustr
, u
"SurfaceWindow"_ustr
)
824 , mxControl(pControl
)
825 , mxWireFrame(m_xBuilder
->weld_radio_button(u
"wireframe"_ustr
))
826 , mxMatt(m_xBuilder
->weld_radio_button(u
"matt"_ustr
))
827 , mxPlastic(m_xBuilder
->weld_radio_button(u
"plastic"_ustr
))
828 , mxMetal(m_xBuilder
->weld_radio_button(u
"metal"_ustr
))
829 , mxMetalMSO(m_xBuilder
->weld_radio_button(u
"metalMSO"_ustr
))
831 mxWireFrame
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
832 mxMatt
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
833 mxPlastic
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
834 mxMetal
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
835 mxMetalMSO
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
837 AddStatusListener( g_sExtrusionSurface
);
840 void ExtrusionSurfaceWindow::GrabFocus()
842 mxWireFrame
->grab_focus();
845 void ExtrusionSurfaceWindow::implSetSurface( int nSurface
, bool bEnabled
)
847 mxWireFrame
->set_active(nSurface
== 0 && bEnabled
);
848 mxWireFrame
->set_sensitive(bEnabled
);
849 mxMatt
->set_active(nSurface
== 1 && bEnabled
);
850 mxMatt
->set_sensitive(bEnabled
);
851 mxPlastic
->set_active(nSurface
== 2 && bEnabled
);
852 mxPlastic
->set_sensitive(bEnabled
);
853 mxMetal
->set_active(nSurface
== 3 && bEnabled
);
854 mxMetal
->set_sensitive(bEnabled
);
855 mxMetalMSO
->set_active(nSurface
== 4 && bEnabled
);
856 mxMetalMSO
->set_sensitive(bEnabled
);
859 void ExtrusionSurfaceWindow::statusChanged(
860 const css::frame::FeatureStateEvent
& Event
863 if( Event
.FeatureURL
.Main
!= g_sExtrusionSurface
)
866 if( !Event
.IsEnabled
)
868 implSetSurface( 0, false );
872 sal_Int32 nValue
= 0;
873 if( Event
.State
>>= nValue
)
874 implSetSurface( nValue
, true );
878 IMPL_LINK(ExtrusionSurfaceWindow
, SelectHdl
, weld::Toggleable
&, rButton
, void)
880 if (!rButton
.get_active())
884 if (mxWireFrame
->get_active())
886 else if (mxMatt
->get_active())
888 else if (mxPlastic
->get_active())
890 else if (mxMetal
->get_active())
895 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
896 g_sExtrusionSurface
.copy(5), nSurface
) };
898 mxControl
->dispatchCommand( g_sExtrusionSurface
, aArgs
);
900 implSetSurface( nSurface
, true );
902 mxControl
->EndPopupMode();
905 ExtrusionSurfaceControl::ExtrusionSurfaceControl(
906 const Reference
< XComponentContext
>& rxContext
908 : svt::PopupWindowController(
910 Reference
< css::frame::XFrame
>(),
911 u
".uno:ExtrusionSurfaceFloater"_ustr
916 std::unique_ptr
<WeldToolbarPopup
> ExtrusionSurfaceControl::weldPopupWindow()
918 return std::make_unique
<ExtrusionSurfaceWindow
>(this, m_pToolbar
);
921 VclPtr
<vcl::Window
> ExtrusionSurfaceControl::createVclPopupWindow( vcl::Window
* pParent
)
923 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
924 std::make_unique
<ExtrusionSurfaceWindow
>(this, pParent
->GetFrameWeld()));
926 mxInterimPopover
->Show();
928 return mxInterimPopover
;
932 void SAL_CALL
ExtrusionSurfaceControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
934 svt::PopupWindowController::initialize( aArguments
);
936 ToolBox
* pToolBox
= nullptr;
938 if ( getToolboxId( nId
, &pToolBox
) )
939 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
945 OUString
ExtrusionSurfaceControl::getImplementationName()
947 return u
"com.sun.star.comp.svx.ExtrusionSurfaceController"_ustr
;
951 Sequence
< OUString
> ExtrusionSurfaceControl::getSupportedServiceNames()
953 return { u
"com.sun.star.frame.ToolbarController"_ustr
};
957 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
958 com_sun_star_comp_svx_ExtrusionSurfaceControl_get_implementation(
959 css::uno::XComponentContext
* xContext
,
960 css::uno::Sequence
<css::uno::Any
> const &)
962 return cppu::acquire(new ExtrusionSurfaceControl(xContext
));
967 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */