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::lang
;
38 using namespace ::com::sun::star::beans
;
39 using namespace ::com::sun::star::util
;
40 using namespace ::com::sun::star::graphic
;
45 const sal_Int32 gSkewList
[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
46 constexpr OUStringLiteral g_sExtrusionDirection
= u
".uno:ExtrusionDirection";
47 constexpr OUStringLiteral g_sExtrusionProjection
= u
".uno:ExtrusionProjection";
48 constexpr OUStringLiteral EMPTY
= u
"";
50 constexpr rtl::OUStringConstExpr aLightOffBmps
[] =
52 RID_SVXBMP_LIGHT_OFF_FROM_TOP_LEFT
,
53 RID_SVXBMP_LIGHT_OFF_FROM_TOP
,
54 RID_SVXBMP_LIGHT_OFF_FROM_TOP_RIGHT
,
55 RID_SVXBMP_LIGHT_OFF_FROM_LEFT
,
57 RID_SVXBMP_LIGHT_OFF_FROM_RIGHT
,
58 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_LEFT
,
59 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM
,
60 RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_RIGHT
63 constexpr rtl::OUStringConstExpr aLightOnBmps
[] =
65 RID_SVXBMP_LIGHT_ON_FROM_TOP_LEFT
,
66 RID_SVXBMP_LIGHT_ON_FROM_TOP
,
67 RID_SVXBMP_LIGHT_ON_FROM_TOP_RIGHT
,
68 RID_SVXBMP_LIGHT_ON_FROM_LEFT
,
70 RID_SVXBMP_LIGHT_ON_FROM_RIGHT
,
71 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_LEFT
,
72 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM
,
73 RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_RIGHT
76 constexpr rtl::OUStringConstExpr aLightPreviewBmps
[] =
78 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_LEFT
,
79 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP
,
80 RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_RIGHT
,
81 RID_SVXBMP_LIGHT_PREVIEW_FROM_LEFT
,
82 RID_SVXBMP_LIGHT_PREVIEW_FROM_FRONT
,
83 RID_SVXBMP_LIGHT_PREVIEW_FROM_RIGHT
,
84 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT
,
85 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM
,
86 RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT
89 constexpr rtl::OUStringConstExpr aDirectionBmps
[] =
91 RID_SVXBMP_DIRECTION_DIRECTION_NW
,
92 RID_SVXBMP_DIRECTION_DIRECTION_N
,
93 RID_SVXBMP_DIRECTION_DIRECTION_NE
,
94 RID_SVXBMP_DIRECTION_DIRECTION_W
,
95 RID_SVXBMP_DIRECTION_DIRECTION_NONE
,
96 RID_SVXBMP_DIRECTION_DIRECTION_E
,
97 RID_SVXBMP_DIRECTION_DIRECTION_SW
,
98 RID_SVXBMP_DIRECTION_DIRECTION_S
,
99 RID_SVXBMP_DIRECTION_DIRECTION_SE
102 static TranslateId aDirectionStrs
[] =
104 RID_SVXSTR_DIRECTION_NW
,
105 RID_SVXSTR_DIRECTION_N
,
106 RID_SVXSTR_DIRECTION_NE
,
107 RID_SVXSTR_DIRECTION_W
,
108 RID_SVXSTR_DIRECTION_NONE
,
109 RID_SVXSTR_DIRECTION_E
,
110 RID_SVXSTR_DIRECTION_SW
,
111 RID_SVXSTR_DIRECTION_S
,
112 RID_SVXSTR_DIRECTION_SE
115 ExtrusionDirectionWindow::ExtrusionDirectionWindow(
116 svt::PopupWindowController
* pControl
,
117 weld::Widget
* pParent
)
118 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, "svx/ui/directionwindow.ui", "DirectionWindow")
119 , mxControl(pControl
)
120 , mxDirectionSet(new ValueSet(nullptr))
121 , mxDirectionSetWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *mxDirectionSet
))
122 , mxPerspective(m_xBuilder
->weld_radio_button("perspective"))
123 , mxParallel(m_xBuilder
->weld_radio_button("parallel"))
125 mxDirectionSet
->SetStyle(WB_TABSTOP
| WB_MENUSTYLEVALUESET
| WB_FLATVALUESET
| WB_NOBORDER
| WB_NO_DIRECTSELECT
);
127 for (sal_uInt16 i
= DIRECTION_NW
; i
<= DIRECTION_SE
; ++i
)
129 maImgDirection
[i
] = Image(StockImage::Yes
, OUString(aDirectionBmps
[i
]));
132 mxDirectionSet
->SetSelectHdl( LINK( this, ExtrusionDirectionWindow
, SelectValueSetHdl
) );
133 mxDirectionSet
->SetColCount( 3 );
134 mxDirectionSet
->EnableFullItemMode( false );
136 for (sal_uInt16 i
= DIRECTION_NW
; i
<= DIRECTION_SE
; ++i
)
138 mxDirectionSet
->InsertItem(i
+ 1, maImgDirection
[i
], SvxResId(aDirectionStrs
[i
]));
142 mxDirectionSet
->GetDrawingArea()->set_size_request(aSize
.Width(), aSize
.Height());
143 mxDirectionSet
->SetOutputSizePixel(aSize
);
145 mxPerspective
->connect_toggled(LINK(this, ExtrusionDirectionWindow
, SelectToolbarMenuHdl
));
147 AddStatusListener( g_sExtrusionDirection
);
148 AddStatusListener( g_sExtrusionProjection
);
151 void ExtrusionDirectionWindow::GrabFocus()
153 mxDirectionSet
->GrabFocus();
156 ExtrusionDirectionWindow::~ExtrusionDirectionWindow()
160 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew
, bool bEnabled
)
163 for( nItemId
= DIRECTION_NW
; nItemId
<= DIRECTION_SE
; nItemId
++ )
165 if( gSkewList
[nItemId
] == nSkew
)
169 if( nItemId
<= DIRECTION_SE
)
171 mxDirectionSet
->SelectItem( nItemId
+1 );
175 mxDirectionSet
->SetNoSelection();
179 mxDirectionSet
->Enable();
181 mxDirectionSet
->Disable();
184 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection
, bool bEnabled
)
186 mxPerspective
->set_active(nProjection
== 0 && bEnabled
);
187 mxParallel
->set_active(nProjection
== 1 && bEnabled
);
188 mxPerspective
->set_sensitive(bEnabled
);
189 mxParallel
->set_sensitive(bEnabled
);
192 void ExtrusionDirectionWindow::statusChanged(
193 const css::frame::FeatureStateEvent
& Event
196 if( Event
.FeatureURL
.Main
== g_sExtrusionDirection
)
198 if( !Event
.IsEnabled
)
200 implSetDirection( -1, false );
204 sal_Int32 nValue
= 0;
205 if( Event
.State
>>= nValue
)
206 implSetDirection( nValue
, true );
209 else if( Event
.FeatureURL
.Main
== g_sExtrusionProjection
)
211 if( !Event
.IsEnabled
)
213 implSetProjection( -1, false );
217 sal_Int32 nValue
= 0;
218 if( Event
.State
>>= nValue
)
219 implSetProjection( nValue
, true );
224 IMPL_LINK_NOARG(ExtrusionDirectionWindow
, SelectValueSetHdl
, ValueSet
*, void)
226 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
227 OUString(g_sExtrusionDirection
).copy(5),
228 gSkewList
[mxDirectionSet
->GetSelectedItemId()-1]) };
230 mxControl
->dispatchCommand( g_sExtrusionDirection
, aArgs
);
232 mxControl
->EndPopupMode();
235 IMPL_LINK_NOARG(ExtrusionDirectionWindow
, SelectToolbarMenuHdl
, weld::Toggleable
&, void)
237 int nProjection
= mxPerspective
->get_active() ? 0 : 1;
239 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
240 OUString(g_sExtrusionProjection
).copy(5), static_cast<sal_Int32
>(nProjection
)) };
242 mxControl
->dispatchCommand( g_sExtrusionProjection
, aArgs
);
243 implSetProjection( nProjection
, true );
245 mxControl
->EndPopupMode();
248 ExtrusionDirectionControl::ExtrusionDirectionControl(
249 const Reference
< XComponentContext
>& rxContext
250 ) : svt::PopupWindowController(
252 Reference
< css::frame::XFrame
>(),
253 ".uno:ExtrusionDirectionFloater"
258 std::unique_ptr
<WeldToolbarPopup
> ExtrusionDirectionControl::weldPopupWindow()
260 return std::make_unique
<ExtrusionDirectionWindow
>(this, m_pToolbar
);
263 VclPtr
<vcl::Window
> ExtrusionDirectionControl::createVclPopupWindow( vcl::Window
* pParent
)
265 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
266 std::make_unique
<ExtrusionDirectionWindow
>(this, pParent
->GetFrameWeld()));
268 mxInterimPopover
->Show();
270 return mxInterimPopover
;
274 void SAL_CALL
ExtrusionDirectionControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
276 svt::PopupWindowController::initialize( aArguments
);
278 ToolBox
* pToolBox
= nullptr;
280 if ( getToolboxId( nId
, &pToolBox
) )
281 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
287 OUString
ExtrusionDirectionControl::getImplementationName()
289 return "com.sun.star.comp.svx.ExtrusionDirectionController";
293 Sequence
< OUString
> ExtrusionDirectionControl::getSupportedServiceNames()
295 return { "com.sun.star.frame.ToolbarController" };
299 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
300 com_sun_star_comp_svx_ExtrusionDirectionControl_get_implementation(
301 css::uno::XComponentContext
* xContext
,
302 css::uno::Sequence
<css::uno::Any
> const &)
304 return cppu::acquire(new ExtrusionDirectionControl(xContext
));
308 ExtrusionDepthDialog::ExtrusionDepthDialog(weld::Window
* pParent
, double fDepth
, FieldUnit eDefaultUnit
)
309 : GenericDialogController(pParent
, "svx/ui/extrustiondepthdialog.ui", "ExtrustionDepthDialog")
310 , m_xMtrDepth(m_xBuilder
->weld_metric_spin_button("depth", eDefaultUnit
))
312 m_xMtrDepth
->set_value(static_cast<int>(fDepth
) * 100, FieldUnit::MM_100TH
);
315 ExtrusionDepthDialog::~ExtrusionDepthDialog()
319 double ExtrusionDepthDialog::getDepth() const
321 return static_cast<double>(m_xMtrDepth
->get_value(FieldUnit::MM_100TH
)) / 100.0;
324 double const aDepthListInch
[] = { 0, 1270,2540,5080,10160 };
325 double const aDepthListMM
[] = { 0, 1000, 2500, 5000, 10000 };
327 constexpr OUStringLiteral
gsExtrusionDepth( u
".uno:ExtrusionDepth" );
328 constexpr OUStringLiteral
gsMetricUnit( u
".uno:MetricUnit" );
330 ExtrusionDepthWindow::ExtrusionDepthWindow(svt::PopupWindowController
* pControl
, weld::Widget
* pParent
)
331 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, "svx/ui/depthwindow.ui", "DepthWindow")
332 , mxControl(pControl
)
333 , mxDepth0(m_xBuilder
->weld_radio_button("depth0"))
334 , mxDepth1(m_xBuilder
->weld_radio_button("depth1"))
335 , mxDepth2(m_xBuilder
->weld_radio_button("depth2"))
336 , mxDepth3(m_xBuilder
->weld_radio_button("depth3"))
337 , mxDepth4(m_xBuilder
->weld_radio_button("depth4"))
338 , mxInfinity(m_xBuilder
->weld_radio_button("infinity"))
339 , mxCustom(m_xBuilder
->weld_radio_button("custom"))
340 , meUnit(FieldUnit::NONE
)
342 , mbSettingValue(false)
343 , mbCommandDispatched(false)
345 mxDepth0
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
346 mxDepth1
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
347 mxDepth2
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
348 mxDepth3
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
349 mxDepth4
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
350 mxInfinity
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
351 mxCustom
->connect_toggled(LINK(this, ExtrusionDepthWindow
, SelectHdl
));
352 mxCustom
->connect_mouse_release(LINK(this, ExtrusionDepthWindow
, MouseReleaseHdl
));
354 AddStatusListener( gsExtrusionDepth
);
355 AddStatusListener( gsMetricUnit
);
358 void ExtrusionDepthWindow::GrabFocus()
360 mxDepth0
->grab_focus();
363 void ExtrusionDepthWindow::implSetDepth( double fDepth
)
367 bool bSettingValue
= mbSettingValue
;
368 mbSettingValue
= true;
370 mxCustom
->set_active(true);
371 bool bIsMetric
= IsMetric(meUnit
);
372 mxDepth0
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[0] : aDepthListInch
[0]));
373 mxDepth1
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[1] : aDepthListInch
[1]));
374 mxDepth2
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[2] : aDepthListInch
[2]));
375 mxDepth3
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[3] : aDepthListInch
[3]));
376 mxDepth4
->set_active(fDepth
== (bIsMetric
? aDepthListMM
[4] : aDepthListInch
[4]));
377 mxInfinity
->set_active(fDepth
>= 338666);
379 mbSettingValue
= bSettingValue
;
382 void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit
)
386 const TranslateId aDepths
[] =
395 const TranslateId aDepthsInch
[] =
397 RID_SVXSTR_DEPTH_0_INCH
,
398 RID_SVXSTR_DEPTH_1_INCH
,
399 RID_SVXSTR_DEPTH_2_INCH
,
400 RID_SVXSTR_DEPTH_3_INCH
,
401 RID_SVXSTR_DEPTH_4_INCH
404 static_assert(SAL_N_ELEMENTS(aDepths
) == SAL_N_ELEMENTS(aDepthsInch
));
406 const TranslateId
* pResource
= IsMetric(eUnit
) ? aDepths
: aDepthsInch
;
408 mxDepth0
->set_label(SvxResId(pResource
[0]));
409 mxDepth1
->set_label(SvxResId(pResource
[1]));
410 mxDepth2
->set_label(SvxResId(pResource
[2]));
411 mxDepth3
->set_label(SvxResId(pResource
[3]));
412 mxDepth4
->set_label(SvxResId(pResource
[4]));
415 void ExtrusionDepthWindow::statusChanged(
416 const css::frame::FeatureStateEvent
& Event
419 if( Event
.FeatureURL
.Main
== gsExtrusionDepth
)
421 if( !Event
.IsEnabled
)
428 if( Event
.State
>>= fValue
)
429 implSetDepth( fValue
);
432 else if( Event
.FeatureURL
.Main
== gsMetricUnit
)
434 if( Event
.IsEnabled
)
436 sal_Int32 nValue
= 0;
437 if( Event
.State
>>= nValue
)
439 implFillStrings( static_cast<FieldUnit
>(nValue
) );
441 implSetDepth( mfDepth
);
447 void ExtrusionDepthWindow::DispatchDepthDialog()
449 Sequence
< PropertyValue
> aArgs
{
450 comphelper::makePropertyValue("Depth", mfDepth
),
451 comphelper::makePropertyValue("Metric", static_cast<sal_Int32
>( meUnit
))
454 rtl::Reference
<svt::PopupWindowController
> xControl(mxControl
);
455 xControl
->EndPopupMode();
456 xControl
->dispatchCommand(".uno:ExtrusionDepthDialog", aArgs
);
457 mbCommandDispatched
= true;
460 IMPL_LINK(ExtrusionDepthWindow
, SelectHdl
, weld::Toggleable
&, rButton
, void)
462 if (mbSettingValue
|| !rButton
.get_active())
465 // see MouseReleaseHdl for mbCommandDispatched check, there's no guarantee
466 // this toggle will happen before that mouse release though it does in
467 // practice for vcl and gtk
468 if (mbCommandDispatched
)
471 if (mxCustom
->get_active())
472 DispatchDepthDialog();
477 if (mxInfinity
->get_active())
484 if (mxDepth0
->get_active())
486 else if (mxDepth1
->get_active())
488 else if (mxDepth2
->get_active())
490 else if (mxDepth3
->get_active())
495 fDepth
= IsMetric( meUnit
) ? aDepthListMM
[nSelected
] : aDepthListInch
[nSelected
];
498 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
499 OUString(gsExtrusionDepth
).copy(5), fDepth
) };
501 mxControl
->dispatchCommand( gsExtrusionDepth
, aArgs
);
502 mbCommandDispatched
= true;
503 implSetDepth( fDepth
);
505 mxControl
->EndPopupMode();
509 IMPL_LINK_NOARG(ExtrusionDepthWindow
, MouseReleaseHdl
, const MouseEvent
&, bool)
512 tdf#145296 if the "custom" radiobutton was presented preselected as
513 toggled on and the user clicked on it then there's no toggled signal sent
514 because the item was already toggled on and didn't change state.
516 So if that happens launch the custom spacing dialog explicitly here on
519 if (mxCustom
->get_active() && !mbCommandDispatched
)
521 DispatchDepthDialog();
527 // ExtrusionDirectionControl
528 ExtrusionDepthController::ExtrusionDepthController(
529 const Reference
< XComponentContext
>& rxContext
530 ) : svt::PopupWindowController(
532 Reference
< css::frame::XFrame
>(),
533 ".uno:ExtrusionDepthFloater"
538 std::unique_ptr
<WeldToolbarPopup
> ExtrusionDepthController::weldPopupWindow()
540 return std::make_unique
<ExtrusionDepthWindow
>(this, m_pToolbar
);
543 VclPtr
<vcl::Window
> ExtrusionDepthController::createVclPopupWindow( vcl::Window
* pParent
)
545 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
546 std::make_unique
<ExtrusionDepthWindow
>(this, pParent
->GetFrameWeld()));
548 mxInterimPopover
->Show();
550 return mxInterimPopover
;
554 void SAL_CALL
ExtrusionDepthController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
556 svt::PopupWindowController::initialize( aArguments
);
558 ToolBox
* pToolBox
= nullptr;
560 if ( getToolboxId( nId
, &pToolBox
) )
561 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
567 OUString
ExtrusionDepthController::getImplementationName()
569 return "com.sun.star.comp.svx.ExtrusionDepthController";
573 Sequence
< OUString
> ExtrusionDepthController::getSupportedServiceNames()
575 return { "com.sun.star.frame.ToolbarController" };
579 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
580 com_sun_star_comp_svx_ExtrusionDepthController_get_implementation(
581 css::uno::XComponentContext
* xContext
,
582 css::uno::Sequence
<css::uno::Any
> const &)
584 return cppu::acquire(new ExtrusionDepthController(xContext
));
588 constexpr OUStringLiteral g_sExtrusionLightingDirection
= u
".uno:ExtrusionLightingDirection";
589 constexpr OUStringLiteral g_sExtrusionLightingIntensity
= u
".uno:ExtrusionLightingIntensity";
591 ExtrusionLightingWindow::ExtrusionLightingWindow(svt::PopupWindowController
* pControl
,
592 weld::Widget
* pParent
)
593 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, "svx/ui/lightingwindow.ui", "LightingWindow")
594 , mxControl(pControl
)
595 , mxLightingSet(new ValueSet(nullptr))
596 , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *mxLightingSet
))
597 , mxBright(m_xBuilder
->weld_radio_button("bright"))
598 , mxNormal(m_xBuilder
->weld_radio_button("normal"))
599 , mxDim(m_xBuilder
->weld_radio_button("dim"))
601 mxLightingSet
->SetStyle(WB_TABSTOP
| WB_MENUSTYLEVALUESET
| WB_FLATVALUESET
| WB_NOBORDER
| WB_NO_DIRECTSELECT
);
603 for (sal_uInt16 i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; ++i
)
605 if( i
!= FROM_FRONT
)
607 maImgLightingOff
[i
] = Image(StockImage::Yes
, OUString(aLightOffBmps
[i
]));
608 maImgLightingOn
[i
] = Image(StockImage::Yes
, OUString(aLightOnBmps
[i
]));
610 maImgLightingPreview
[i
] = Image(StockImage::Yes
, OUString(aLightPreviewBmps
[i
]));
613 mxLightingSet
->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING
);
615 mxLightingSet
->SetSelectHdl( LINK( this, ExtrusionLightingWindow
, SelectValueSetHdl
) );
616 mxLightingSet
->SetColCount( 3 );
617 mxLightingSet
->EnableFullItemMode( false );
619 for (sal_uInt16 i
= FROM_TOP_LEFT
; i
<= FROM_BOTTOM_RIGHT
; ++i
)
621 if( i
!= FROM_FRONT
)
623 mxLightingSet
->InsertItem( i
+1, maImgLightingOff
[i
] );
627 mxLightingSet
->InsertItem( 5, maImgLightingPreview
[FROM_FRONT
] );
631 mxLightingSet
->GetDrawingArea()->set_size_request(aSize
.Width(), aSize
.Height());
632 mxLightingSet
->SetOutputSizePixel(aSize
);
634 mxBright
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
635 mxNormal
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
636 mxDim
->connect_toggled(LINK(this, ExtrusionLightingWindow
, SelectToolbarMenuHdl
));
638 AddStatusListener( g_sExtrusionLightingDirection
);
639 AddStatusListener( g_sExtrusionLightingIntensity
);
642 void ExtrusionLightingWindow::GrabFocus()
644 mxLightingSet
->GrabFocus();
647 ExtrusionLightingWindow::~ExtrusionLightingWindow()
651 void ExtrusionLightingWindow::implSetIntensity( int nLevel
, bool bEnabled
)
653 mxBright
->set_sensitive(bEnabled
);
654 mxBright
->set_active(nLevel
== 0 && bEnabled
);
655 mxNormal
->set_sensitive(bEnabled
);
656 mxNormal
->set_active(nLevel
== 1 && bEnabled
);
657 mxDim
->set_sensitive(bEnabled
);
658 mxDim
->set_active(nLevel
== 2 && bEnabled
);
661 void ExtrusionLightingWindow::implSetDirection( int nDirection
, bool bEnabled
)
664 nDirection
= FROM_FRONT
;
667 for( nItemId
= FROM_TOP_LEFT
; nItemId
<= FROM_BOTTOM_RIGHT
; nItemId
++ )
669 if( nItemId
== FROM_FRONT
)
671 mxLightingSet
->SetItemImage( nItemId
+ 1, maImgLightingPreview
[ nDirection
] );
675 mxLightingSet
->SetItemImage(
677 static_cast<sal_uInt16
>(nDirection
) == nItemId
? maImgLightingOn
[nItemId
] : maImgLightingOff
[nItemId
]
683 mxLightingSet
->Enable();
685 mxLightingSet
->Disable();
688 void ExtrusionLightingWindow::statusChanged(
689 const css::frame::FeatureStateEvent
& Event
692 if( Event
.FeatureURL
.Main
== g_sExtrusionLightingIntensity
)
694 if( !Event
.IsEnabled
)
696 implSetIntensity( 0, false );
700 sal_Int32 nValue
= 0;
701 if( Event
.State
>>= nValue
)
702 implSetIntensity( nValue
, true );
705 else if( Event
.FeatureURL
.Main
== g_sExtrusionLightingDirection
)
707 if( !Event
.IsEnabled
)
709 implSetDirection( 0, false );
713 sal_Int32 nValue
= 0;
714 if( Event
.State
>>= nValue
)
715 implSetDirection( nValue
, true );
720 IMPL_LINK_NOARG(ExtrusionLightingWindow
, SelectValueSetHdl
, ValueSet
*, void)
722 sal_Int32 nDirection
= mxLightingSet
->GetSelectedItemId();
724 if( (nDirection
> 0) && (nDirection
< 10) )
728 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
729 OUString(g_sExtrusionLightingDirection
).copy(5), nDirection
) };
731 mxControl
->dispatchCommand( g_sExtrusionLightingDirection
, aArgs
);
733 implSetDirection( nDirection
, true );
736 mxControl
->EndPopupMode();
739 IMPL_LINK(ExtrusionLightingWindow
, SelectToolbarMenuHdl
, weld::Toggleable
&, rButton
, void)
741 if (!rButton
.get_active())
745 if (mxBright
->get_active())
747 else if (mxNormal
->get_active())
752 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
753 OUString(g_sExtrusionLightingIntensity
).copy(5), static_cast<sal_Int32
>(nLevel
)) };
755 mxControl
->dispatchCommand( g_sExtrusionLightingIntensity
, aArgs
);
757 implSetIntensity( nLevel
, true );
759 mxControl
->EndPopupMode();
762 ExtrusionLightingControl::ExtrusionLightingControl(
763 const Reference
< XComponentContext
>& rxContext
764 ) : svt::PopupWindowController( rxContext
,
765 Reference
< css::frame::XFrame
>(),
766 ".uno:ExtrusionDirectionFloater"
771 std::unique_ptr
<WeldToolbarPopup
> ExtrusionLightingControl::weldPopupWindow()
773 return std::make_unique
<ExtrusionLightingWindow
>(this, m_pToolbar
);
776 VclPtr
<vcl::Window
> ExtrusionLightingControl::createVclPopupWindow( vcl::Window
* pParent
)
778 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
779 std::make_unique
<ExtrusionLightingWindow
>(this, pParent
->GetFrameWeld()));
781 mxInterimPopover
->Show();
783 return mxInterimPopover
;
787 void SAL_CALL
ExtrusionLightingControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
789 svt::PopupWindowController::initialize( aArguments
);
791 ToolBox
* pToolBox
= nullptr;
793 if ( getToolboxId( nId
, &pToolBox
) )
794 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
800 OUString
ExtrusionLightingControl::getImplementationName()
802 return "com.sun.star.comp.svx.ExtrusionLightingController";
806 Sequence
< OUString
> ExtrusionLightingControl::getSupportedServiceNames()
808 return { "com.sun.star.frame.ToolbarController" };
812 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
813 com_sun_star_comp_svx_ExtrusionLightingControl_get_implementation(
814 css::uno::XComponentContext
* xContext
,
815 css::uno::Sequence
<css::uno::Any
> const &)
817 return cppu::acquire(new ExtrusionLightingControl(xContext
));
821 constexpr OUStringLiteral g_sExtrusionSurface
= u
".uno:ExtrusionSurface";
823 ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(svt::PopupWindowController
* pControl
, weld::Widget
* pParent
)
824 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, "svx/ui/surfacewindow.ui", "SurfaceWindow")
825 , mxControl(pControl
)
826 , mxWireFrame(m_xBuilder
->weld_radio_button("wireframe"))
827 , mxMatt(m_xBuilder
->weld_radio_button("matt"))
828 , mxPlastic(m_xBuilder
->weld_radio_button("plastic"))
829 , mxMetal(m_xBuilder
->weld_radio_button("metal"))
830 , mxMetalMSO(m_xBuilder
->weld_radio_button("metalMSO"))
832 mxWireFrame
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
833 mxMatt
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
834 mxPlastic
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
835 mxMetal
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
836 mxMetalMSO
->connect_toggled(LINK(this, ExtrusionSurfaceWindow
, SelectHdl
));
838 AddStatusListener( g_sExtrusionSurface
);
841 void ExtrusionSurfaceWindow::GrabFocus()
843 mxWireFrame
->grab_focus();
846 void ExtrusionSurfaceWindow::implSetSurface( int nSurface
, bool bEnabled
)
848 mxWireFrame
->set_active(nSurface
== 0 && bEnabled
);
849 mxWireFrame
->set_sensitive(bEnabled
);
850 mxMatt
->set_active(nSurface
== 1 && bEnabled
);
851 mxMatt
->set_sensitive(bEnabled
);
852 mxPlastic
->set_active(nSurface
== 2 && bEnabled
);
853 mxPlastic
->set_sensitive(bEnabled
);
854 mxMetal
->set_active(nSurface
== 3 && bEnabled
);
855 mxMetal
->set_sensitive(bEnabled
);
856 mxMetalMSO
->set_active(nSurface
== 4 && bEnabled
);
857 mxMetalMSO
->set_sensitive(bEnabled
);
860 void ExtrusionSurfaceWindow::statusChanged(
861 const css::frame::FeatureStateEvent
& Event
864 if( Event
.FeatureURL
.Main
!= g_sExtrusionSurface
)
867 if( !Event
.IsEnabled
)
869 implSetSurface( 0, false );
873 sal_Int32 nValue
= 0;
874 if( Event
.State
>>= nValue
)
875 implSetSurface( nValue
, true );
879 IMPL_LINK(ExtrusionSurfaceWindow
, SelectHdl
, weld::Toggleable
&, rButton
, void)
881 if (!rButton
.get_active())
885 if (mxWireFrame
->get_active())
887 else if (mxMatt
->get_active())
889 else if (mxPlastic
->get_active())
891 else if (mxMetal
->get_active())
896 Sequence
< PropertyValue
> aArgs
{ comphelper::makePropertyValue(
897 OUString(g_sExtrusionSurface
).copy(5), nSurface
) };
899 mxControl
->dispatchCommand( g_sExtrusionSurface
, aArgs
);
901 implSetSurface( nSurface
, true );
903 mxControl
->EndPopupMode();
906 ExtrusionSurfaceControl::ExtrusionSurfaceControl(
907 const Reference
< XComponentContext
>& rxContext
909 : svt::PopupWindowController(
911 Reference
< css::frame::XFrame
>(),
912 ".uno:ExtrusionSurfaceFloater"
917 std::unique_ptr
<WeldToolbarPopup
> ExtrusionSurfaceControl::weldPopupWindow()
919 return std::make_unique
<ExtrusionSurfaceWindow
>(this, m_pToolbar
);
922 VclPtr
<vcl::Window
> ExtrusionSurfaceControl::createVclPopupWindow( vcl::Window
* pParent
)
924 mxInterimPopover
= VclPtr
<InterimToolbarPopup
>::Create(getFrameInterface(), pParent
,
925 std::make_unique
<ExtrusionSurfaceWindow
>(this, pParent
->GetFrameWeld()));
927 mxInterimPopover
->Show();
929 return mxInterimPopover
;
933 void SAL_CALL
ExtrusionSurfaceControl::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
935 svt::PopupWindowController::initialize( aArguments
);
937 ToolBox
* pToolBox
= nullptr;
939 if ( getToolboxId( nId
, &pToolBox
) )
940 pToolBox
->SetItemBits( nId
, pToolBox
->GetItemBits( nId
) | ToolBoxItemBits::DROPDOWNONLY
);
946 OUString
ExtrusionSurfaceControl::getImplementationName()
948 return "com.sun.star.comp.svx.ExtrusionSurfaceController";
952 Sequence
< OUString
> ExtrusionSurfaceControl::getSupportedServiceNames()
954 return { "com.sun.star.frame.ToolbarController" };
958 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
959 com_sun_star_comp_svx_ExtrusionSurfaceControl_get_implementation(
960 css::uno::XComponentContext
* xContext
,
961 css::uno::Sequence
<css::uno::Any
> const &)
963 return cppu::acquire(new ExtrusionSurfaceControl(xContext
));
968 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */