LibreOffice Module svx (master) 1
extrusioncontrols.cxx
Go to the documentation of this file.
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
24#include <vcl/toolbox.hxx>
25
26#include <svx/strings.hrc>
27#include <svx/svdtrans.hxx>
28#include <svx/dialmgr.hxx>
29
30#include <helpids.h>
31#include "extrusioncontrols.hxx"
33
34#include <bitmaps.hlst>
35
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::lang;
38using namespace ::com::sun::star::beans;
39using namespace ::com::sun::star::util;
40using namespace ::com::sun::star::graphic;
41
42namespace svx
43{
44
45const sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
46constexpr OUStringLiteral g_sExtrusionDirection = u".uno:ExtrusionDirection";
47constexpr OUStringLiteral g_sExtrusionProjection = u".uno:ExtrusionProjection";
48constexpr OUStringLiteral EMPTY = u"";
49
50constexpr rtl::OUStringConstExpr aLightOffBmps[] =
51{
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,
56 EMPTY,
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
61};
62
63constexpr rtl::OUStringConstExpr aLightOnBmps[] =
64{
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,
69 EMPTY,
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
74};
75
76constexpr rtl::OUStringConstExpr aLightPreviewBmps[] =
77{
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
87};
88
89constexpr rtl::OUStringConstExpr aDirectionBmps[] =
90{
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
100};
101
103{
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
113};
114
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"))
124{
126
127 for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
128 {
129 maImgDirection[i] = Image(StockImage::Yes, OUString(aDirectionBmps[i]));
130 }
131
132 mxDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectValueSetHdl ) );
133 mxDirectionSet->SetColCount( 3 );
134 mxDirectionSet->EnableFullItemMode( false );
135
136 for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
137 {
139 }
140
141 Size aSize(72, 72);
142 mxDirectionSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
143 mxDirectionSet->SetOutputSizePixel(aSize);
144
145 mxPerspective->connect_toggled(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl));
146
149}
150
152{
153 mxDirectionSet->GrabFocus();
154}
155
157{
158}
159
160void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
161{
162 sal_uInt16 nItemId;
163 for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
164 {
165 if( gSkewList[nItemId] == nSkew )
166 break;
167 }
168
169 if( nItemId <= DIRECTION_SE )
170 {
171 mxDirectionSet->SelectItem( nItemId+1 );
172 }
173 else
174 {
175 mxDirectionSet->SetNoSelection();
176 }
177
178 if (bEnabled)
179 mxDirectionSet->Enable();
180 else
181 mxDirectionSet->Disable();
182}
183
184void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
185{
186 mxPerspective->set_active(nProjection == 0 && bEnabled);
187 mxParallel->set_active(nProjection == 1 && bEnabled);
188 mxPerspective->set_sensitive(bEnabled);
189 mxParallel->set_sensitive(bEnabled);
190}
191
193 const css::frame::FeatureStateEvent& Event
194)
195{
196 if( Event.FeatureURL.Main == g_sExtrusionDirection )
197 {
198 if( !Event.IsEnabled )
199 {
200 implSetDirection( -1, false );
201 }
202 else
203 {
204 sal_Int32 nValue = 0;
205 if( Event.State >>= nValue )
206 implSetDirection( nValue, true );
207 }
208 }
209 else if( Event.FeatureURL.Main == g_sExtrusionProjection )
210 {
211 if( !Event.IsEnabled )
212 {
213 implSetProjection( -1, false );
214 }
215 else
216 {
217 sal_Int32 nValue = 0;
218 if( Event.State >>= nValue )
219 implSetProjection( nValue, true );
220 }
221 }
222}
223
225{
226 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
227 OUString(g_sExtrusionDirection).copy(5),
228 gSkewList[mxDirectionSet->GetSelectedItemId()-1]) };
229
230 mxControl->dispatchCommand( g_sExtrusionDirection, aArgs );
231
232 mxControl->EndPopupMode();
233}
234
236{
237 int nProjection = mxPerspective->get_active() ? 0 : 1;
238
239 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
240 OUString(g_sExtrusionProjection).copy(5), static_cast<sal_Int32>(nProjection)) };
241
242 mxControl->dispatchCommand( g_sExtrusionProjection, aArgs );
243 implSetProjection( nProjection, true );
244
245 mxControl->EndPopupMode();
246}
247
249 const Reference< XComponentContext >& rxContext
250) : svt::PopupWindowController(
251 rxContext,
252 Reference< css::frame::XFrame >(),
253 ".uno:ExtrusionDirectionFloater"
254 )
255{
256}
257
258std::unique_ptr<WeldToolbarPopup> ExtrusionDirectionControl::weldPopupWindow()
259{
260 return std::make_unique<ExtrusionDirectionWindow>(this, m_pToolbar);
261}
262
264{
265 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
266 std::make_unique<ExtrusionDirectionWindow>(this, pParent->GetFrameWeld()));
267
268 mxInterimPopover->Show();
269
270 return mxInterimPopover;
271}
272
273// XInitialization
274void SAL_CALL ExtrusionDirectionControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
275{
276 svt::PopupWindowController::initialize( aArguments );
277
278 ToolBox* pToolBox = nullptr;
280 if ( getToolboxId( nId, &pToolBox ) )
281 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
282}
283
284// XServiceInfo
285
286
288{
289 return "com.sun.star.comp.svx.ExtrusionDirectionController";
290}
291
292
294{
295 return { "com.sun.star.frame.ToolbarController" };
296}
297
298
299extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
301 css::uno::XComponentContext* xContext,
302 css::uno::Sequence<css::uno::Any> const &)
303{
304 return cppu::acquire(new ExtrusionDirectionControl(xContext));
305}
306
307
309 : GenericDialogController(pParent, "svx/ui/extrustiondepthdialog.ui", "ExtrustionDepthDialog")
310 , m_xMtrDepth(m_xBuilder->weld_metric_spin_button("depth", eDefaultUnit))
311{
312 m_xMtrDepth->set_value(static_cast<int>(fDepth) * 100, FieldUnit::MM_100TH);
313}
314
316{
317}
318
320{
321 return static_cast<double>(m_xMtrDepth->get_value(FieldUnit::MM_100TH)) / 100.0;
322}
323
324double const aDepthListInch[] = { 0, 1270,2540,5080,10160 };
325double const aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
326
327constexpr OUStringLiteral gsExtrusionDepth( u".uno:ExtrusionDepth" );
328constexpr OUStringLiteral gsMetricUnit( u".uno:MetricUnit" );
329
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)
341 , mfDepth( -1.0 )
342 , mbSettingValue(false)
343 , mbCommandDispatched(false)
344{
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));
353
356}
357
359{
360 mxDepth0->grab_focus();
361}
362
364{
365 mfDepth = fDepth;
366
367 bool bSettingValue = mbSettingValue;
368 mbSettingValue = true;
369
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);
378
379 mbSettingValue = bSettingValue;
380}
381
383{
384 meUnit = eUnit;
385
386 const TranslateId aDepths[] =
387 {
388 RID_SVXSTR_DEPTH_0,
389 RID_SVXSTR_DEPTH_1,
390 RID_SVXSTR_DEPTH_2,
391 RID_SVXSTR_DEPTH_3,
392 RID_SVXSTR_DEPTH_4
393 };
394
395 const TranslateId aDepthsInch[] =
396 {
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
402 };
403
404 static_assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
405
406 const TranslateId* pResource = IsMetric(eUnit) ? aDepths : aDepthsInch;
407
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]));
413}
414
416 const css::frame::FeatureStateEvent& Event
417)
418{
419 if( Event.FeatureURL.Main == gsExtrusionDepth )
420 {
421 if( !Event.IsEnabled )
422 {
423 implSetDepth( 0 );
424 }
425 else
426 {
427 double fValue = 0.0;
428 if( Event.State >>= fValue )
429 implSetDepth( fValue );
430 }
431 }
432 else if( Event.FeatureURL.Main == gsMetricUnit )
433 {
434 if( Event.IsEnabled )
435 {
436 sal_Int32 nValue = 0;
437 if( Event.State >>= nValue )
438 {
439 implFillStrings( static_cast<FieldUnit>(nValue) );
440 if( mfDepth >= 0.0 )
442 }
443 }
444 }
445}
446
448{
449 Sequence< PropertyValue > aArgs{
451 comphelper::makePropertyValue("Metric", static_cast<sal_Int32>( meUnit ))
452 };
453
455 xControl->EndPopupMode();
456 xControl->dispatchCommand(".uno:ExtrusionDepthDialog", aArgs);
457 mbCommandDispatched = true;
458}
459
461{
462 if (mbSettingValue || !rButton.get_active())
463 return;
464
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)
469 return;
470
471 if (mxCustom->get_active())
472 DispatchDepthDialog();
473 else
474 {
475 double fDepth;
476
477 if (mxInfinity->get_active())
478 {
479 fDepth = 338666.6;
480 }
481 else
482 {
483 int nSelected;
484 if (mxDepth0->get_active())
485 nSelected = 0;
486 else if (mxDepth1->get_active())
487 nSelected = 1;
488 else if (mxDepth2->get_active())
489 nSelected = 2;
490 else if (mxDepth3->get_active())
491 nSelected = 3;
492 else
493 nSelected = 4;
494
495 fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
496 }
497
498 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
499 OUString(gsExtrusionDepth).copy(5), fDepth) };
500
501 mxControl->dispatchCommand( gsExtrusionDepth, aArgs );
502 mbCommandDispatched = true;
503 implSetDepth( fDepth );
504
505 mxControl->EndPopupMode();
506 }
507}
508
509IMPL_LINK_NOARG(ExtrusionDepthWindow, MouseReleaseHdl, const MouseEvent&, bool)
510{
511 /*
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.
515
516 So if that happens launch the custom spacing dialog explicitly here on
517 mouse release.
518 */
519 if (mxCustom->get_active() && !mbCommandDispatched)
520 {
521 DispatchDepthDialog();
522 return true;
523 }
524 return false;
525}
526
527// ExtrusionDirectionControl
529 const Reference< XComponentContext >& rxContext
530) : svt::PopupWindowController(
531 rxContext,
532 Reference< css::frame::XFrame >(),
533 ".uno:ExtrusionDepthFloater"
534 )
535{
536}
537
538std::unique_ptr<WeldToolbarPopup> ExtrusionDepthController::weldPopupWindow()
539{
540 return std::make_unique<ExtrusionDepthWindow>(this, m_pToolbar);
541}
542
544{
545 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
546 std::make_unique<ExtrusionDepthWindow>(this, pParent->GetFrameWeld()));
547
548 mxInterimPopover->Show();
549
550 return mxInterimPopover;
551}
552
553// XInitialization
554void SAL_CALL ExtrusionDepthController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
555{
556 svt::PopupWindowController::initialize( aArguments );
557
558 ToolBox* pToolBox = nullptr;
560 if ( getToolboxId( nId, &pToolBox ) )
561 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
562}
563
564// XServiceInfo
565
566
568{
569 return "com.sun.star.comp.svx.ExtrusionDepthController";
570}
571
572
574{
575 return { "com.sun.star.frame.ToolbarController" };
576}
577
578
579extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
581 css::uno::XComponentContext* xContext,
582 css::uno::Sequence<css::uno::Any> const &)
583{
584 return cppu::acquire(new ExtrusionDepthController(xContext));
585}
586
587
588constexpr OUStringLiteral g_sExtrusionLightingDirection = u".uno:ExtrusionLightingDirection";
589constexpr OUStringLiteral g_sExtrusionLightingIntensity = u".uno:ExtrusionLightingIntensity";
590
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"))
600{
602
603 for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
604 {
605 if( i != FROM_FRONT )
606 {
607 maImgLightingOff[i] = Image(StockImage::Yes, OUString(aLightOffBmps[i]));
608 maImgLightingOn[i] = Image(StockImage::Yes, OUString(aLightOnBmps[i]));
609 }
610 maImgLightingPreview[i] = Image(StockImage::Yes, OUString(aLightPreviewBmps[i]));
611 }
612
614
615 mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
616 mxLightingSet->SetColCount( 3 );
617 mxLightingSet->EnableFullItemMode( false );
618
619 for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
620 {
621 if( i != FROM_FRONT )
622 {
623 mxLightingSet->InsertItem( i+1, maImgLightingOff[i] );
624 }
625 else
626 {
628 }
629 }
630 Size aSize(72, 72);
631 mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
632 mxLightingSet->SetOutputSizePixel(aSize);
633
634 mxBright->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
635 mxNormal->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
636 mxDim->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
637
640}
641
643{
644 mxLightingSet->GrabFocus();
645}
646
648{
649}
650
651void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
652{
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);
659}
660
661void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
662{
663 if( !bEnabled )
664 nDirection = FROM_FRONT;
665
666 sal_uInt16 nItemId;
667 for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
668 {
669 if( nItemId == FROM_FRONT )
670 {
671 mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
672 }
673 else
674 {
675 mxLightingSet->SetItemImage(
676 nItemId + 1,
677 static_cast<sal_uInt16>(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
678 );
679 }
680 }
681
682 if (bEnabled)
683 mxLightingSet->Enable();
684 else
685 mxLightingSet->Disable();
686}
687
689 const css::frame::FeatureStateEvent& Event
690)
691{
692 if( Event.FeatureURL.Main == g_sExtrusionLightingIntensity )
693 {
694 if( !Event.IsEnabled )
695 {
696 implSetIntensity( 0, false );
697 }
698 else
699 {
700 sal_Int32 nValue = 0;
701 if( Event.State >>= nValue )
702 implSetIntensity( nValue, true );
703 }
704 }
705 else if( Event.FeatureURL.Main == g_sExtrusionLightingDirection )
706 {
707 if( !Event.IsEnabled )
708 {
709 implSetDirection( 0, false );
710 }
711 else
712 {
713 sal_Int32 nValue = 0;
714 if( Event.State >>= nValue )
715 implSetDirection( nValue, true );
716 }
717 }
718}
719
721{
722 sal_Int32 nDirection = mxLightingSet->GetSelectedItemId();
723
724 if( (nDirection > 0) && (nDirection < 10) )
725 {
726 nDirection--;
727
728 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
729 OUString(g_sExtrusionLightingDirection).copy(5), nDirection) };
730
731 mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs );
732
733 implSetDirection( nDirection, true );
734 }
735
736 mxControl->EndPopupMode();
737}
738
739IMPL_LINK(ExtrusionLightingWindow, SelectToolbarMenuHdl, weld::Toggleable&, rButton, void)
740{
741 if (!rButton.get_active())
742 return;
743
744 int nLevel;
745 if (mxBright->get_active())
746 nLevel = 0;
747 else if (mxNormal->get_active())
748 nLevel = 1;
749 else
750 nLevel = 2;
751
752 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
753 OUString(g_sExtrusionLightingIntensity).copy(5), static_cast<sal_Int32>(nLevel)) };
754
755 mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
756
757 implSetIntensity( nLevel, true );
758
759 mxControl->EndPopupMode();
760}
761
763 const Reference< XComponentContext >& rxContext
764) : svt::PopupWindowController( rxContext,
765 Reference< css::frame::XFrame >(),
766 ".uno:ExtrusionDirectionFloater"
767 )
768{
769}
770
771std::unique_ptr<WeldToolbarPopup> ExtrusionLightingControl::weldPopupWindow()
772{
773 return std::make_unique<ExtrusionLightingWindow>(this, m_pToolbar);
774}
775
777{
778 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
779 std::make_unique<ExtrusionLightingWindow>(this, pParent->GetFrameWeld()));
780
781 mxInterimPopover->Show();
782
783 return mxInterimPopover;
784}
785
786// XInitialization
787void SAL_CALL ExtrusionLightingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
788{
789 svt::PopupWindowController::initialize( aArguments );
790
791 ToolBox* pToolBox = nullptr;
793 if ( getToolboxId( nId, &pToolBox ) )
794 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
795}
796
797// XServiceInfo
798
799
801{
802 return "com.sun.star.comp.svx.ExtrusionLightingController";
803}
804
805
807{
808 return { "com.sun.star.frame.ToolbarController" };
809}
810
811
812extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
814 css::uno::XComponentContext* xContext,
815 css::uno::Sequence<css::uno::Any> const &)
816{
817 return cppu::acquire(new ExtrusionLightingControl(xContext));
818}
819
820
821constexpr OUStringLiteral g_sExtrusionSurface = u".uno:ExtrusionSurface";
822
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"))
831{
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));
837
839}
840
842{
843 mxWireFrame->grab_focus();
844}
845
846void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
847{
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);
858}
859
861 const css::frame::FeatureStateEvent& Event
862)
863{
864 if( Event.FeatureURL.Main != g_sExtrusionSurface )
865 return;
866
867 if( !Event.IsEnabled )
868 {
869 implSetSurface( 0, false );
870 }
871 else
872 {
873 sal_Int32 nValue = 0;
874 if( Event.State >>= nValue )
875 implSetSurface( nValue, true );
876 }
877}
878
880{
881 if (!rButton.get_active())
882 return;
883
884 sal_Int32 nSurface;
885 if (mxWireFrame->get_active())
886 nSurface = 0;
887 else if (mxMatt->get_active())
888 nSurface = 1;
889 else if (mxPlastic->get_active())
890 nSurface = 2;
891 else if (mxMetal->get_active())
892 nSurface = 3;
893 else
894 nSurface = 4;
895
896 Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
897 OUString(g_sExtrusionSurface).copy(5), nSurface) };
898
899 mxControl->dispatchCommand( g_sExtrusionSurface, aArgs );
900
901 implSetSurface( nSurface, true );
902
903 mxControl->EndPopupMode();
904}
905
907 const Reference< XComponentContext >& rxContext
908)
909: svt::PopupWindowController(
910 rxContext,
911 Reference< css::frame::XFrame >(),
912 ".uno:ExtrusionSurfaceFloater"
913 )
914{
915}
916
917std::unique_ptr<WeldToolbarPopup> ExtrusionSurfaceControl::weldPopupWindow()
918{
919 return std::make_unique<ExtrusionSurfaceWindow>(this, m_pToolbar);
920}
921
923{
924 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
925 std::make_unique<ExtrusionSurfaceWindow>(this, pParent->GetFrameWeld()));
926
927 mxInterimPopover->Show();
928
929 return mxInterimPopover;
930}
931
932// XInitialization
933void SAL_CALL ExtrusionSurfaceControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
934{
935 svt::PopupWindowController::initialize( aArguments );
936
937 ToolBox* pToolBox = nullptr;
939 if ( getToolboxId( nId, &pToolBox ) )
940 pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
941}
942
943// XServiceInfo
944
945
947{
948 return "com.sun.star.comp.svx.ExtrusionSurfaceController";
949}
950
951
953{
954 return { "com.sun.star.frame.ToolbarController" };
955}
956
957
958extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
960 css::uno::XComponentContext* xContext,
961 css::uno::Sequence<css::uno::Any> const &)
962{
963 return cppu::acquire(new ExtrusionSurfaceControl(xContext));
964}
965
966}
967
968/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Height() const
constexpr tools::Long Width() const
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
static VclPtr< reference_type > Create(Arg &&... arg)
void AddStatusListener(const OUString &rCommandURL)
VclPtr< InterimToolbarPopup > mxInterimPopover
virtual OUString SAL_CALL getImplementationName() override
ExtrusionDepthController(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
virtual ~ExtrusionDepthDialog() override
std::unique_ptr< weld::MetricSpinButton > m_xMtrDepth
ExtrusionDepthDialog(weld::Window *pParent, double fDepth, FieldUnit eDefaultUnit)
std::unique_ptr< weld::RadioButton > mxDepth4
void implSetDepth(double fDepth)
virtual void GrabFocus() override
ExtrusionDepthWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxDepth0
void implFillStrings(FieldUnit eUnit)
std::unique_ptr< weld::RadioButton > mxCustom
std::unique_ptr< weld::RadioButton > mxDepth3
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
std::unique_ptr< weld::RadioButton > mxDepth2
std::unique_ptr< weld::RadioButton > mxInfinity
std::unique_ptr< weld::RadioButton > mxDepth1
rtl::Reference< svt::PopupWindowController > mxControl
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
ExtrusionDirectionControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
ExtrusionDirectionWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxParallel
void implSetDirection(sal_Int32 nSkew, bool bEnabled)
virtual void GrabFocus() override
std::unique_ptr< weld::RadioButton > mxPerspective
void implSetProjection(sal_Int32 nProjection, bool bEnabled)
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
std::unique_ptr< ValueSet > mxDirectionSet
virtual ~ExtrusionDirectionWindow() override
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
virtual OUString SAL_CALL getImplementationName() override
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
ExtrusionLightingControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
ExtrusionLightingWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxDim
std::unique_ptr< ValueSet > mxLightingSet
virtual ~ExtrusionLightingWindow() override
std::unique_ptr< weld::RadioButton > mxNormal
std::unique_ptr< weld::RadioButton > mxBright
void implSetDirection(int nDirection, bool bEnabled)
void implSetIntensity(int nLevel, bool bEnabled)
virtual void GrabFocus() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
ExtrusionSurfaceControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
std::unique_ptr< weld::RadioButton > mxMetalMSO
std::unique_ptr< weld::RadioButton > mxMetal
ExtrusionSurfaceWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxWireFrame
std::unique_ptr< weld::RadioButton > mxPlastic
virtual void GrabFocus() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
void implSetSurface(int nSurface, bool bEnabled)
std::unique_ptr< weld::RadioButton > mxMatt
weld::Window * GetFrameWeld() const
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
float u
#define DIRECTION_NW
#define FROM_FRONT
#define FROM_BOTTOM_RIGHT
#define DIRECTION_SE
#define FROM_TOP_LEFT
FieldUnit
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
constexpr OStringLiteral HID_VALUESET_EXTRUSION_LIGHTING
Definition: helpids.h:42
Sequence< PropertyValue > aArguments
#define SAL_N_ELEMENTS(arr)
NONE
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Reference
void copy(const fs::path &src, const fs::path &dest)
int i
constexpr OUStringLiteral g_sExtrusionLightingIntensity
double const aDepthListMM[]
IMPL_LINK(HangulHanjaConversionDialog, ClickByCharacterHdl, weld::Toggleable &, rBox, void)
constexpr OUStringLiteral EMPTY
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionLightingControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral g_sExtrusionDirection
constexpr OUStringLiteral gsExtrusionDepth(u".uno:ExtrusionDepth")
constexpr rtl::OUStringConstExpr aLightPreviewBmps[]
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionDirectionControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionDepthController_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
const sal_Int32 gSkewList[]
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionSurfaceControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral gsMetricUnit(u".uno:MetricUnit")
constexpr OUStringLiteral g_sExtrusionLightingDirection
constexpr OUStringLiteral g_sExtrusionSurface
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, ValueSet *, void)
constexpr OUStringLiteral g_sExtrusionProjection
constexpr rtl::OUStringConstExpr aLightOnBmps[]
constexpr rtl::OUStringConstExpr aLightOffBmps[]
double const aDepthListInch[]
static TranslateId aDirectionStrs[]
constexpr rtl::OUStringConstExpr aDirectionBmps[]
sal_Int16 nId
bool IsMetric(MapUnit eU)
Definition: svdtrans.hxx:242
#define WB_FLATVALUESET
#define WB_MENUSTYLEVALUESET
#define WB_NO_DIRECTSELECT
WinBits const WB_TABSTOP
WinBits const WB_NOBORDER