diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-08 12:07:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-09 15:17:04 +0200 |
commit | 15ea661bec6e38f4b4b641ed79bd5591345fefbd (patch) | |
tree | a9a8c17a99b7c0356d8ba3d77c1b5f582cdfc43f /sd/source/ui | |
parent | 7ceee0f1ec0e349d0df4980d7fdedbd13c7917c5 (diff) |
tdf#120377 weld cluster of animation pages and dialog
Change-Id: Ia5a9880c1e6d88141bd654a9cc761b289f27c249
Reviewed-on: https://gerrit.libreoffice.org/61542
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/animations/CustomAnimationDialog.cxx | 1414 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationDialog.hxx | 53 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.cxx | 41 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.hxx | 2 |
4 files changed, 1106 insertions, 404 deletions
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx index 7ce429ece102..85a14a373463 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationDialog.cxx @@ -175,6 +175,86 @@ Control* PresetPropertyBox::getControl() return mpControl; } +SdPropertySubControl::~SdPropertySubControl() +{ +} + +class SdPresetPropertyBox : public SdPropertySubControl +{ +public: + SdPresetPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const OUString& aPresetId, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& rPresetId ) override; + +private: + std::map< sal_uInt16, OUString > maPropertyValues; + Link<LinkParamNone*,void> maModifyLink; + std::unique_ptr<weld::ComboBox> mxControl; + + DECL_LINK(OnSelect, weld::ComboBox&, void); +}; + +SdPresetPropertyBox::SdPresetPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const OUString& aPresetId, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyLink(rModifyHdl) + , mxControl(mxBuilder->weld_combo_box("combo")) +{ + mxControl->connect_changed(LINK(this, SdPresetPropertyBox, OnSelect)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_PRESETPROPERTYBOX); + mxControl->show(); + pLabel->set_mnemonic_widget(mxControl.get()); + setValue(rValue, aPresetId); +} + +IMPL_LINK_NOARG(SdPresetPropertyBox, OnSelect, weld::ComboBox&, void) +{ + maModifyLink.Call(nullptr); +} + +void SdPresetPropertyBox::setValue( const Any& rValue, const OUString& rPresetId ) +{ + if (mxControl) + { + mxControl->freeze(); + mxControl->clear(); + int nPos = -1; + + const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets(); + CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor( rPresetId ); + if( pDescriptor.get() ) + { + + OUString aPropertyValue; + rValue >>= aPropertyValue; + + std::vector<OUString> aSubTypes( pDescriptor->getSubTypes() ); + + mxControl->set_sensitive(!aSubTypes.empty()); + + for( auto& aSubType : aSubTypes ) + { + mxControl->append_text(rPresets.getUINameForProperty(aSubType)); + if(aSubType == aPropertyValue) + nPos = mxControl->get_count() - 1; + maPropertyValues[nPos] = aSubType; + } + } + else + { + mxControl->set_sensitive(false); + } + mxControl->thaw(); + if (nPos != -1) + mxControl->set_active(nPos); + } +} + +Any SdPresetPropertyBox::getValue() +{ + return makeAny(maPropertyValues[mxControl->get_active()]); +} + class ColorPropertyBox : public PropertySubControl { public: @@ -236,6 +316,58 @@ Control* ColorPropertyBox::getControl() return mpControl; } +class SdColorPropertyBox : public SdPropertySubControl +{ +public: + SdColorPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, weld::Window* pTopLevel, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& rPresetId ) override; + +private: + Link<LinkParamNone*,void> maModifyLink; + std::unique_ptr<ColorListBox> mxControl; + + DECL_LINK(OnSelect, ColorListBox&, void); +}; + +SdColorPropertyBox::SdColorPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, weld::Window* pTopLevel, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyLink(rModifyHdl) + , mxControl(new ColorListBox(mxBuilder->weld_menu_button("color"), pTopLevel)) +{ + mxControl->SetSelectHdl(LINK(this, SdColorPropertyBox, OnSelect)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_COLORPROPERTYBOX); + pLabel->set_mnemonic_widget(&mxControl->get_widget()); + mxControl->show(); + + sal_Int32 nColor = 0; + rValue >>= nColor; + mxControl->SelectEntry(Color(nColor)); +} + +IMPL_LINK_NOARG(SdColorPropertyBox, OnSelect, ColorListBox&, void) +{ + maModifyLink.Call(nullptr); +} + +void SdColorPropertyBox::setValue( const Any& rValue, const OUString& ) +{ + if (mxControl) + { + sal_Int32 nColor = 0; + rValue >>= nColor; + + mxControl->SetNoSelection(); + mxControl->SelectEntry(Color(nColor)); + } +} + +Any SdColorPropertyBox::getValue() +{ + return makeAny(sal_Int32(mxControl->GetSelectEntryColor().GetRGBColor())); +} + class FontPropertyBox : public PropertySubControl { public: @@ -316,6 +448,84 @@ Control* FontPropertyBox::getControl() return mpControl; } +class SdFontPropertyBox : public SdPropertySubControl +{ +public: + SdFontPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue(const Any& rValue, const OUString& rPresetId) override; + +private: + Link<LinkParamNone*,void> maModifyHdl; + std::unique_ptr<weld::ComboBox> mxControl; + + DECL_LINK(ControlSelectHdl, weld::ComboBox&, void); +}; + +SdFontPropertyBox::SdFontPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl(rModifyHdl) + , mxControl(mxBuilder->weld_combo_box("fontname")) +{ + mxControl->connect_changed(LINK(this, SdFontPropertyBox, ControlSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_FONTPROPERTYBOX); + mxControl->show(); + pLabel->set_mnemonic_widget(mxControl.get()); + + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem; + + const FontList* pFontList = nullptr; + bool bMustDelete = false; + + if (pDocSh && ( (pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != nullptr)) + pFontList = static_cast<const SvxFontListItem*>(pItem)->GetFontList(); + + if (!pFontList) + { + pFontList = new FontList(Application::GetDefaultDevice(), nullptr); + bMustDelete = true; + } + + mxControl->freeze(); + + sal_uInt16 nFontCount = pFontList->GetFontNameCount(); + for (sal_uInt16 i = 0; i < nFontCount; ++i) + { + const FontMetric& rFontMetric = pFontList->GetFontName(i); + mxControl->append_text(rFontMetric.GetFamilyName()); + } + + mxControl->thaw(); + + if( bMustDelete ) + delete pFontList; + + setValue( rValue, OUString() ); +} + +IMPL_LINK_NOARG(SdFontPropertyBox, ControlSelectHdl, weld::ComboBox&, void) +{ + maModifyHdl.Call(nullptr); +} + +void SdFontPropertyBox::setValue( const Any& rValue, const OUString& ) +{ + if (mxControl) + { + OUString aFontName; + rValue >>= aFontName; + mxControl->set_entry_text(aFontName); + } +} + +Any SdFontPropertyBox::getValue() +{ + OUString aFontName(mxControl->get_active_text()); + return makeAny(aFontName); +} + class DropdownMenuBox : public Edit { public: @@ -477,6 +687,69 @@ Control* CharHeightPropertyBox::getControl() return mpControl; } +class SdCharHeightPropertyBox : public SdPropertySubControl +{ +public: + SdCharHeightPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& ) override; + + DECL_LINK(implMenuSelectHdl, const OString& rIdent, void); + +private: + Link<LinkParamNone*,void> maModifyHdl; + std::unique_ptr<weld::MetricSpinButton> mxMetric; + std::unique_ptr<weld::MenuButton> mxControl; + + DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void); +}; + +SdCharHeightPropertyBox::SdCharHeightPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl(rModifyHdl) + , mxMetric(mxBuilder->weld_metric_spin_button("fontsize", FUNIT_PERCENT)) + , mxControl(mxBuilder->weld_menu_button("fontsizemenu")) +{ + mxMetric->connect_value_changed(LINK(this, SdCharHeightPropertyBox, EditModifyHdl)); + mxMetric->set_help_id(HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX); + mxMetric->show(); + pLabel->set_mnemonic_widget(&mxMetric->get_widget()); + + mxControl->connect_selected(LINK(this, SdCharHeightPropertyBox, implMenuSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX); + mxControl->show(); + + setValue(rValue, OUString()); +} + +IMPL_LINK_NOARG(SdCharHeightPropertyBox, EditModifyHdl, weld::MetricSpinButton&, void) +{ + maModifyHdl.Call(nullptr); +} + +IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OString&, rIdent, void) +{ + sal_Int32 nValue = rIdent.toInt32(); + mxMetric->set_value(nValue, FUNIT_PERCENT); + EditModifyHdl(*mxMetric); +} + +void SdCharHeightPropertyBox::setValue( const Any& rValue, const OUString& ) +{ + if (mxMetric) + { + double fValue = 0.0; + rValue >>= fValue; + mxMetric->set_value(static_cast<long>(fValue * 100.0), FUNIT_PERCENT); + } +} + +Any SdCharHeightPropertyBox::getValue() +{ + return makeAny(static_cast<double>(mxMetric->get_value(FUNIT_PERCENT)) / 100.0); +} + class TransparencyPropertyBox : public PropertySubControl { public: @@ -576,6 +849,91 @@ Control* TransparencyPropertyBox::getControl() return mpControl; } +class SdTransparencyPropertyBox : public SdPropertySubControl +{ +public: + SdTransparencyPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& rPresetId ) override; + + DECL_LINK(implMenuSelectHdl, const OString&, void); + DECL_LINK(implModifyHdl, weld::MetricSpinButton&, void); + + void updateMenu(); + +private: + Link<LinkParamNone*,void> maModifyHdl; + + std::unique_ptr<weld::MetricSpinButton> mxMetric; + std::unique_ptr<weld::MenuButton> mxControl; +}; + +SdTransparencyPropertyBox::SdTransparencyPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl(rModifyHdl) + , mxMetric(mxBuilder->weld_metric_spin_button("transparent", FUNIT_PERCENT)) + , mxControl(mxBuilder->weld_menu_button("transparentmenu")) +{ + for (sal_Int32 i = 25; i < 101; i += 25) + { + OUString aStr(unicode::formatPercent(i, + Application::GetSettings().GetUILanguageTag())); + mxControl->append_item_check(OUString::number(i), aStr); + } + + mxControl->connect_selected(LINK(this, SdTransparencyPropertyBox, implMenuSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX); + mxControl->show(); + + mxMetric->connect_value_changed(LINK(this, SdTransparencyPropertyBox, implModifyHdl)); + mxMetric->set_help_id(HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX); + mxMetric->show(); + pLabel->set_mnemonic_widget(&mxMetric->get_widget()); + + setValue(rValue, OUString()); +} + +void SdTransparencyPropertyBox::updateMenu() +{ + sal_Int64 nValue = mxMetric->get_value(FUNIT_PERCENT); + for (sal_uInt16 i = 25; i < 101; i += 25) + mxControl->set_item_active(OString::number(i), nValue == i); +} + +IMPL_LINK_NOARG(SdTransparencyPropertyBox, implModifyHdl, weld::MetricSpinButton&, void) +{ + updateMenu(); + maModifyHdl.Call(nullptr); +} + +IMPL_LINK(SdTransparencyPropertyBox, implMenuSelectHdl, const OString&, rIdent, void) +{ + auto nValue = rIdent.toInt32(); + if (nValue != mxMetric->get_value(FUNIT_PERCENT)) + { + mxMetric->set_value(nValue, FUNIT_PERCENT); + implModifyHdl(*mxMetric); + } +} + +void SdTransparencyPropertyBox::setValue(const Any& rValue, const OUString&) +{ + if (mxMetric) + { + double fValue = 0.0; + rValue >>= fValue; + long nValue = static_cast<long>(fValue * 100); + mxMetric->set_value(nValue, FUNIT_PERCENT); + updateMenu(); + } +} + +Any SdTransparencyPropertyBox::getValue() +{ + return makeAny(static_cast<double>(mxMetric->get_value(FUNIT_PERCENT)) / 100.0); +} + class RotationPropertyBox : public PropertySubControl { public: @@ -695,6 +1053,105 @@ Control* RotationPropertyBox::getControl() return mpControl; } +class SdRotationPropertyBox : public SdPropertySubControl +{ +public: + SdRotationPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& ) override; + + DECL_LINK(implMenuSelectHdl, const OString&, void); + DECL_LINK(implModifyHdl, weld::MetricSpinButton&, void); + + void updateMenu(); + +private: + Link<LinkParamNone*,void> maModifyHdl; + + std::unique_ptr<weld::MetricSpinButton> mxMetric; + std::unique_ptr<weld::MenuButton> mxControl; +}; + +SdRotationPropertyBox::SdRotationPropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl(rModifyHdl) + , mxMetric(mxBuilder->weld_metric_spin_button("rotate", FUNIT_DEGREE)) + , mxControl(mxBuilder->weld_menu_button("rotatemenu")) +{ + mxMetric->connect_value_changed(LINK( this, SdRotationPropertyBox, implModifyHdl)); + mxMetric->set_help_id(HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX); + mxMetric->show(); + pLabel->set_mnemonic_widget(&mxMetric->get_widget()); + + mxControl->connect_selected(LINK(this, SdRotationPropertyBox, implMenuSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX); + mxControl->show(); + + setValue(rValue, OUString()); +} + +void SdRotationPropertyBox::updateMenu() +{ + sal_Int64 nValue = mxMetric->get_value(FUNIT_DEGREE); + bool bDirection = nValue >= 0; + nValue = (nValue < 0 ? -nValue : nValue); + + mxControl->set_item_active("90", nValue == 90); + mxControl->set_item_active("180", nValue == 180); + mxControl->set_item_active("360", nValue == 360); + mxControl->set_item_active("720", nValue == 720); + + mxControl->set_item_active("closewise", bDirection); + mxControl->set_item_active("counterclock", !bDirection); +} + +IMPL_LINK_NOARG(SdRotationPropertyBox, implModifyHdl, weld::MetricSpinButton&, void) +{ + updateMenu(); + maModifyHdl.Call(nullptr); +} + +IMPL_LINK(SdRotationPropertyBox, implMenuSelectHdl, const OString&, rIdent, void) +{ + auto nValue = mxMetric->get_value(FUNIT_DEGREE); + bool bDirection = nValue >= 0; + nValue = (nValue < 0 ? -nValue : nValue); + + if (rIdent == "clockwise") + bDirection = true; + else if (rIdent == "counterclock") + bDirection = false; + else + nValue = rIdent.toInt32(); + + if( !bDirection ) + nValue = -nValue; + + if (nValue != mxMetric->get_value(FUNIT_DEGREE)) + { + mxMetric->set_value(nValue, FUNIT_DEGREE); + implModifyHdl(*mxMetric); + } +} + +void SdRotationPropertyBox::setValue( const Any& rValue, const OUString& ) +{ + if (mxMetric) + { + double fValue = 0.0; + rValue >>= fValue; + long nValue = static_cast<long>(fValue); + mxMetric->set_value(nValue, FUNIT_DEGREE); + updateMenu(); + } +} + +Any SdRotationPropertyBox::getValue() +{ + return makeAny(static_cast<double>(mxMetric->get_value(FUNIT_DEGREE))); +} + class ScalePropertyBox : public PropertySubControl { public: @@ -716,7 +1173,7 @@ private: VclPtr<DropdownMenuBox> mpControl; VclPtr<PopupMenu> mpMenu; VclPtr<MetricField> mpMetric; - Link<LinkParamNone*,void> const maModifyHdl; + Link<LinkParamNone*,void> maModifyHdl; int mnDirection; }; @@ -873,6 +1330,165 @@ Control* ScalePropertyBox::getControl() return mpControl; } +class SdScalePropertyBox : public SdPropertySubControl +{ +public: + SdScalePropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& ) override; + + DECL_LINK(implMenuSelectHdl, const OString&, void); + DECL_LINK(implModifyHdl, weld::MetricSpinButton&, void); + + void updateMenu(); + +private: + Link<LinkParamNone*,void> const maModifyHdl; + int mnDirection; + + std::unique_ptr<weld::MetricSpinButton> mxMetric; + std::unique_ptr<weld::MenuButton> mxControl; +}; + +SdScalePropertyBox::SdScalePropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl( rModifyHdl ) + , mxMetric(mxBuilder->weld_metric_spin_button("scale", FUNIT_PERCENT)) + , mxControl(mxBuilder->weld_menu_button("scalemenu")) +{ + mxControl->connect_selected(LINK(this, SdScalePropertyBox, implMenuSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX); + mxControl->show(); + + mxMetric->connect_value_changed(LINK(this, SdScalePropertyBox, implModifyHdl)); + mxMetric->set_help_id(HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX); + mxMetric->show(); + pLabel->set_mnemonic_widget(&mxMetric->get_widget()); + + setValue(rValue, OUString()); +} + +void SdScalePropertyBox::updateMenu() +{ + auto nValue = mxMetric->get_value(FUNIT_PERCENT); + + mxControl->set_item_active("25scale", nValue == 25); + mxControl->set_item_active("50scale", nValue == 50); + mxControl->set_item_active("150scale", nValue == 150); + mxControl->set_item_active("400scale", nValue == 400); + + mxControl->set_item_active("hori", mnDirection == 1); + mxControl->set_item_active("vert", mnDirection == 2); + mxControl->set_item_active("both", mnDirection == 3); +} + +IMPL_LINK_NOARG(SdScalePropertyBox, implModifyHdl, weld::MetricSpinButton&, void) +{ + updateMenu(); + maModifyHdl.Call(nullptr); +} + +IMPL_LINK(SdScalePropertyBox, implMenuSelectHdl, const OString&, rIdent, void) +{ + auto nValue = mxMetric->get_value(FUNIT_PERCENT); + + int nDirection = mnDirection; + + if (rIdent == "hori") + nDirection = 1; + else if (rIdent == "veri") + nDirection = 2; + else if (rIdent == "both") + nDirection = 3; + else + nValue = rIdent.toInt32(); + + bool bModified = false; + + if( nDirection != mnDirection ) + { + mnDirection = nDirection; + bModified = true; + } + + if (nValue != mxMetric->get_value(FUNIT_PERCENT)) + { + mxMetric->set_value(nValue, FUNIT_PERCENT); + bModified = true; + } + + if(bModified) + { + implModifyHdl(*mxMetric); + updateMenu(); + } +} + +void SdScalePropertyBox::setValue(const Any& rValue, const OUString&) +{ + if (mxMetric) + { + ValuePair aValues; + rValue >>= aValues; + + double fValue1 = 0.0; + double fValue2 = 0.0; + + aValues.First >>= fValue1; + aValues.Second >>= fValue2; + + if( fValue2 == 0.0 ) + mnDirection = 1; + else if( fValue1 == 0.0 ) + mnDirection = 2; + else + mnDirection = 3; + + // Shrink animation is represented by negative value + // Shrink factor is calculated as (1 + $fValue) + // e.g 1 + (-0.75) = 0.25 => shrink to 25% of the size + // 0.25 = -0.75 + 1 + if ( fValue1 < 0.0 ) + fValue1 += 1; + if ( fValue2 < 0.0 ) + fValue2 += 1; + + long nValue; + if( fValue1 ) + nValue = static_cast<long>(fValue1 * 100.0); + else + nValue = static_cast<long>(fValue2 * 100.0); + mxMetric->set_value(nValue, FUNIT_PERCENT); + updateMenu(); + } +} + +Any SdScalePropertyBox::getValue() +{ + double fValue1 = static_cast<double>(mxMetric->get_value(FUNIT_PERCENT)) / 100.0; + + // Shrink animation is represented by value < 1 (< 100%) + // Shrink factor is calculated as (1 + $fValue) + // e.g shrink to 25% of the size: 0.25 = 1 + $fValue => + // $fValue = -0.75; -0.75 = 0.25 -1 + if ( fValue1 < 1.0 ) + fValue1 -= 1; + + double fValue2 = fValue1; + + if( mnDirection == 1 ) + fValue2 = 0.0; + else if( mnDirection == 2 ) + fValue1 = 0.0; + + ValuePair aValues; + aValues.First <<= fValue1; + aValues.Second <<= fValue2; + + return makeAny( aValues ); +} + class FontStylePropertyBox : public PropertySubControl { public: @@ -993,17 +1609,119 @@ Control* FontStylePropertyBox::getControl() return mpControl; } -class CustomAnimationEffectTabPage : public TabPage +class SdFontStylePropertyBox : public SdPropertySubControl { public: - CustomAnimationEffectTabPage( vcl::Window* pParent, const STLPropertySet* pSet ); - virtual ~CustomAnimationEffectTabPage() override; - virtual void dispose() override; + SdFontStylePropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl); + + virtual Any getValue() override; + virtual void setValue( const Any& rValue, const OUString& ) override; + + DECL_LINK(implMenuSelectHdl, const OString&, void); + + void update(); + +private: + float mfFontWeight; + awt::FontSlant meFontSlant; + sal_Int16 mnFontUnderline; + Link<LinkParamNone*,void> maModifyHdl; + + std::unique_ptr<weld::Entry> mxEdit; + std::unique_ptr<weld::MenuButton> mxControl; +}; + +SdFontStylePropertyBox::SdFontStylePropertyBox(sal_Int32 nControlType, weld::Label* pLabel, weld::Container* pParent, const Any& rValue, const Link<LinkParamNone*,void>& rModifyHdl ) + : SdPropertySubControl(pParent, nControlType) + , maModifyHdl( rModifyHdl ) + , mxEdit(mxBuilder->weld_entry("entry")) + , mxControl(mxBuilder->weld_menu_button("entrymenu")) +{ + mxEdit->set_text(SdResId(STR_CUSTOMANIMATION_SAMPLE)); + mxEdit->set_help_id(HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX); + pLabel->set_mnemonic_widget(mxEdit.get()); + mxEdit->show(); + + mxControl->connect_selected(LINK(this, SdFontStylePropertyBox, implMenuSelectHdl)); + mxControl->set_help_id(HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX); + mxControl->show(); + + setValue(rValue, OUString()); +} + +void SdFontStylePropertyBox::update() +{ + // update menu + mxControl->set_item_active("bold", mfFontWeight == awt::FontWeight::BOLD); + mxControl->set_item_active("italic", meFontSlant == awt::FontSlant_ITALIC); + mxControl->set_item_active("underline", mnFontUnderline != awt::FontUnderline::NONE ); + + // update sample edit + vcl::Font aFont(mxEdit->get_font()); + aFont.SetWeight(mfFontWeight == awt::FontWeight::BOLD ? WEIGHT_BOLD : WEIGHT_NORMAL); + aFont.SetItalic(meFontSlant == awt::FontSlant_ITALIC ? ITALIC_NORMAL : ITALIC_NONE); + aFont.SetUnderline(mnFontUnderline == awt::FontUnderline::NONE ? LINESTYLE_NONE : LINESTYLE_SINGLE); + mxEdit->set_font(aFont); +} + +IMPL_LINK(SdFontStylePropertyBox, implMenuSelectHdl, const OString&, rIdent, void) +{ + if (rIdent == "bold") + { + if( mfFontWeight == awt::FontWeight::BOLD ) + mfFontWeight = awt::FontWeight::NORMAL; + else + mfFontWeight = awt::FontWeight::BOLD; + } + else if (rIdent == "italic") + { + if( meFontSlant == awt::FontSlant_ITALIC ) + meFontSlant = awt::FontSlant_NONE; + else + meFontSlant = awt::FontSlant_ITALIC; + } + else if (rIdent == "underline") + { + if( mnFontUnderline == awt::FontUnderline::SINGLE ) + mnFontUnderline = awt::FontUnderline::NONE; + else + mnFontUnderline = awt::FontUnderline::SINGLE; + } + + update(); + maModifyHdl.Call(nullptr); +} + +void SdFontStylePropertyBox::setValue( const Any& rValue, const OUString& ) +{ + Sequence<Any> aValues; + rValue >>= aValues; + + aValues[0] >>= mfFontWeight; + aValues[1] >>= meFontSlant; + aValues[2] >>= mnFontUnderline; + + update(); +} + +Any SdFontStylePropertyBox::getValue() +{ + Sequence<Any> aValues(3); + aValues[0] <<= mfFontWeight; + aValues[1] <<= meFontSlant; + aValues[2] <<= mnFontUnderline; + return makeAny( aValues ); +} + +class CustomAnimationEffectTabPage +{ +public: + CustomAnimationEffectTabPage(weld::Container* pParent, weld::Window* pDialog, const STLPropertySet* pSet); void update( STLPropertySet* pSet ); - DECL_LINK( implSelectHdl, ListBox&, void ); - DECL_LINK( implClickHdl, Button*, void ); - void implHdl(Control const *); + DECL_LINK(implSelectHdl, weld::ComboBox&, void); + DECL_LINK(implClickHdl, weld::Button&, void); + void implHdl(const weld::Widget*); private: void updateControlStates(); @@ -1012,62 +1730,66 @@ private: sal_Int32 getSoundObject( const OUString& rStr ); void openSoundFileDialog(); void onSoundPreview(); + weld::Window* GetFrameWeld() const { return mpDialog; } private: ::std::vector< OUString > maSoundList; bool mbHasText; const STLPropertySet* mpSet; - - VclPtr<VclFrame> mpSettings; - VclPtr<FixedText> mpFTProperty1; - VclPtr<PropertyControl> mpLBProperty1; - VclPtr<VclHBox> mpPlaceholderBox; - VclPtr<CheckBox> mpCBSmoothStart; - VclPtr<CheckBox> mpCBSmoothEnd; - - VclPtr<FixedText> mpFTSound; - VclPtr<ListBox> mpLBSound; - VclPtr<PushButton> mpPBSoundPreview; - VclPtr<FixedText> mpFTAfterEffect; - VclPtr<ListBox> mpLBAfterEffect; - VclPtr<FixedText> mpFTDimColor; - VclPtr<SvxColorListBox> mpCLBDimColor; - VclPtr<FixedText> mpFTTextAnim; - VclPtr<ListBox> mpLBTextAnim; - VclPtr<MetricField> mpMFTextDelay; - VclPtr<FixedText> mpFTTextDelay; - - css::uno::Reference< css::media::XPlayer > mxPlayer; + css::uno::Reference<css::media::XPlayer> mxPlayer; + + weld::Window* mpDialog; + std::unique_ptr<weld::Builder> mxBuilder; + std::unique_ptr<weld::Container> mxContainer; + std::unique_ptr<weld::Widget> mxSettings; + std::unique_ptr<weld::Label> mxFTProperty1; + std::unique_ptr<weld::Container> mxPlaceholderBox; + std::unique_ptr<weld::CheckButton> mxCBSmoothStart; + std::unique_ptr<weld::CheckButton> mxCBSmoothEnd; + std::unique_ptr<weld::Label> mxFTSound; + std::unique_ptr<weld::ComboBox> mxLBSound; + std::unique_ptr<weld::Button> mxPBSoundPreview; + std::unique_ptr<weld::Label> mxFTAfterEffect; + std::unique_ptr<weld::ComboBox> mxLBAfterEffect; + std::unique_ptr<weld::Label> mxFTDimColor; + std::unique_ptr<ColorListBox> mxCLBDimColor; + std::unique_ptr<weld::Label> mxFTTextAnim; + std::unique_ptr<weld::ComboBox> mxLBTextAnim; + std::unique_ptr<weld::MetricSpinButton> mxMFTextDelay; + std::unique_ptr<weld::Label> mxFTTextDelay; + std::unique_ptr<SdPropertySubControl> mxLBSubControl; }; -CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent, const STLPropertySet* pSet ) -: TabPage( pParent, "EffectTab", "modules/simpress/ui/customanimationeffecttab.ui" ), mbHasText( false ), mpSet(pSet ) -{ - get(mpSettings, "settings" ); - get(mpFTProperty1, "prop_label1" ); - get(mpLBProperty1, "prop_list1" ); - get(mpPlaceholderBox, "placeholder" ); - get(mpCBSmoothStart, "smooth_start" ); - get(mpCBSmoothEnd, "smooth_end" ); - get(mpFTSound, "sound_label"); - get(mpLBSound, "sound_list" ); - get(mpPBSoundPreview, "sound_preview" ); - get(mpFTAfterEffect, "aeffect_label" ); - get(mpLBAfterEffect, "aeffect_list" ); - get(mpFTDimColor, "dim_color_label" ); - get(mpCLBDimColor, "dim_color_list" ); - mpCLBDimColor->SelectEntry(COL_BLACK); - get(mpFTTextAnim, "text_animation_label" ); - get(mpLBTextAnim, "text_animation_list" ); - get(mpMFTextDelay,"text_delay" ); - get(mpFTTextDelay,"text_delay_label" ); +CustomAnimationEffectTabPage::CustomAnimationEffectTabPage(weld::Container* pParent, weld::Window* pDialog, const STLPropertySet* pSet) + : mbHasText(false) + , mpSet(pSet) + , mpDialog(pDialog) + , mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationeffecttab.ui")) + , mxContainer(mxBuilder->weld_container("EffectTab")) + , mxSettings(mxBuilder->weld_widget("settings")) + , mxFTProperty1(mxBuilder->weld_label("prop_label1")) + , mxPlaceholderBox(mxBuilder->weld_container("placeholder")) + , mxCBSmoothStart(mxBuilder->weld_check_button("smooth_start")) + , mxCBSmoothEnd(mxBuilder->weld_check_button("smooth_end")) + , mxFTSound(mxBuilder->weld_label("sound_label")) + , mxLBSound(mxBuilder->weld_combo_box("sound_list")) + , mxPBSoundPreview(mxBuilder->weld_button("sound_preview")) + , mxFTAfterEffect(mxBuilder->weld_label("aeffect_label")) + , mxLBAfterEffect(mxBuilder->weld_combo_box("aeffect_list")) + , mxFTDimColor(mxBuilder->weld_label("dim_color_label")) + , mxCLBDimColor(new ColorListBox(mxBuilder->weld_menu_button("dim_color_list"), pDialog)) + , mxFTTextAnim(mxBuilder->weld_label("text_animation_label")) + , mxLBTextAnim(mxBuilder->weld_combo_box("text_animation_list")) + , mxMFTextDelay(mxBuilder->weld_metric_spin_button("text_delay", FUNIT_PERCENT)) + , mxFTTextDelay(mxBuilder->weld_label("text_delay_label")) +{ + mxCLBDimColor->SelectEntry(COL_BLACK); // fill the soundbox fillSoundListBox(); - mpLBSound->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) ); - - mpPBSoundPreview->SetClickHdl( LINK( this, CustomAnimationEffectTabPage, implClickHdl ) ); + mxLBSound->connect_changed(LINK(this, CustomAnimationEffectTabPage, implSelectHdl)); + mxPBSoundPreview->connect_clicked(LINK(this, CustomAnimationEffectTabPage, implClickHdl)); // only show settings if all selected effects have the same preset-id if( pSet->getPropertyState( nHandlePresetId ) != STLPropertyState::Ambiguous ) @@ -1089,40 +1811,40 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent if( !aPropertyName.isEmpty() ) { - mpSettings->Show(); - mpFTProperty1->SetText( aPropertyName ); + mxSettings->show(); + mxFTProperty1->set_label(aPropertyName); } // get property value const Any aValue( pSet->getPropertyValue( nHandleProperty1Value ) ); // create property sub control - mpLBProperty1->setSubControl( PropertySubControl::create( nType, mpPlaceholderBox, aValue, aPresetId, Link<LinkParamNone*,void>() )); + mxLBSubControl = SdPropertySubControl::create(nType, mxFTProperty1.get(), mxPlaceholderBox.get(), mpDialog, aValue, aPresetId, Link<LinkParamNone*,void>()); } } - mpFTProperty1->Enable( mpLBProperty1->IsEnabled() ); + mxFTProperty1->set_sensitive(mxPlaceholderBox->get_sensitive()); // accelerate & decelerate if( pSet->getPropertyState( nHandleAccelerate ) == STLPropertyState::Direct ) { - mpCBSmoothStart->Show(); - mpCBSmoothEnd->Show(); + mxCBSmoothStart->show(); + mxCBSmoothEnd->show(); double fTemp = 0.0; pSet->getPropertyValue( nHandleAccelerate ) >>= fTemp; - mpCBSmoothStart->Check( fTemp > 0.0 ); + mxCBSmoothStart->set_active( fTemp > 0.0 ); pSet->getPropertyValue( nHandleDecelerate ) >>= fTemp; - mpCBSmoothEnd->Check( fTemp > 0.0 ); + mxCBSmoothEnd->set_active( fTemp > 0.0 ); } } // init after effect controls - mpLBAfterEffect->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) ); - mpLBTextAnim->SetSelectHdl( LINK( this, CustomAnimationEffectTabPage, implSelectHdl ) ); + mxLBAfterEffect->connect_changed(LINK(this, CustomAnimationEffectTabPage, implSelectHdl)); + mxLBTextAnim->connect_changed(LINK(this, CustomAnimationEffectTabPage, implSelectHdl)); if( (pSet->getPropertyState( nHandleHasAfterEffect ) != STLPropertyState::Ambiguous) && (pSet->getPropertyState( nHandleAfterEffectOnNextEffect ) != STLPropertyState::Ambiguous) && @@ -1145,7 +1867,7 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent sal_Int32 nColor = 0; aDimColor >>= nColor; Color aColor = Color(nColor); - mpCLBDimColor->SelectEntry(aColor); + mxCLBDimColor->SelectEntry(aColor); } else { @@ -1155,7 +1877,7 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent } } - mpLBAfterEffect->SelectEntryPos( nPos ); + mxLBAfterEffect->set_active(nPos); } if( pSet->getPropertyState( nHandleHasText ) != STLPropertyState::Ambiguous ) @@ -1165,7 +1887,7 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent { if( pSet->getPropertyState( nHandleIterateType ) != STLPropertyState::Ambiguous) { - sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND; + int nPos = -1; sal_Int32 nIterateType = 0; pSet->getPropertyValue( nHandleIterateType ) >>= nIterateType; @@ -1176,22 +1898,22 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent case TextAnimationType::BY_LETTER: nPos = 2; break; } - mpLBTextAnim->SelectEntryPos( nPos ); + mxLBTextAnim->set_active(nPos); } if( pSet->getPropertyState( nHandleIterateInterval ) != STLPropertyState::Default ) { double fIterateInterval = 0.0; pSet->getPropertyValue( nHandleIterateInterval ) >>= fIterateInterval; - mpMFTextDelay->SetValue( static_cast<long>(fIterateInterval*10) ); + mxMFTextDelay->set_value(static_cast<long>(fIterateInterval*10), FUNIT_NONE); } } else { - mpFTTextAnim->Enable( false ); - mpLBTextAnim->Enable( false ); - mpMFTextDelay->Enable( false ); - mpFTTextDelay->Enable( false ); + mxFTTextAnim->set_sensitive(false); + mxLBTextAnim->set_sensitive(false); + mxMFTextDelay->set_sensitive(false); + mxFTTextDelay->set_sensitive(false); } @@ -1228,89 +1950,62 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage( vcl::Window* pParent nPos = static_cast<sal_Int32>(maSoundList.size())+2; maSoundList.push_back( aSoundURL ); INetURLObject aURL( aSoundURL ); - nPos = mpLBSound->InsertEntry( aURL.GetBase(), nPos ); + mxLBSound->insert_text(nPos, aURL.GetBase()); } } } - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - mpLBSound->SelectEntryPos( nPos ); + if( nPos != -1) + mxLBSound->set_active(nPos); } updateControlStates(); } -CustomAnimationEffectTabPage::~CustomAnimationEffectTabPage() -{ - disposeOnce(); -} - -void CustomAnimationEffectTabPage::dispose() -{ - clearSoundListBox(); - mpSettings.clear(); - mpFTProperty1.clear(); - mpLBProperty1.clear(); - mpPlaceholderBox.clear(); - mpCBSmoothStart.clear(); - mpCBSmoothEnd.clear(); - mpFTSound.clear(); - mpLBSound.clear(); - mpPBSoundPreview.clear(); - mpFTAfterEffect.clear(); - mpLBAfterEffect.clear(); - mpFTDimColor.clear(); - mpCLBDimColor.clear(); - mpFTTextAnim.clear(); - mpLBTextAnim.clear(); - mpMFTextDelay.clear(); - mpFTTextDelay.clear(); - TabPage::dispose(); -} - void CustomAnimationEffectTabPage::updateControlStates() { - sal_Int32 nPos = mpLBAfterEffect->GetSelectedEntryPos(); - mpCLBDimColor->Enable( nPos == 1 ); - mpFTDimColor->Enable( nPos == 1 ); + auto nPos = mxLBAfterEffect->get_active(); + mxCLBDimColor->set_sensitive( nPos == 1 ); + mxFTDimColor->set_sensitive( nPos == 1 ); if( mbHasText ) { - nPos = mpLBTextAnim->GetSelectedEntryPos(); - mpMFTextDelay->Enable( nPos != 0 ); - mpFTTextDelay->Enable( nPos != 0 ); + nPos = mxLBTextAnim->get_active(); + mxMFTextDelay->set_sensitive( nPos != 0 ); + mxFTTextDelay->set_sensitive( nPos != 0 ); } - nPos = mpLBSound->GetSelectedEntryPos(); - mpPBSoundPreview->Enable( nPos >= 2 ); + nPos = mxLBSound->get_active(); + mxPBSoundPreview->set_sensitive( nPos >= 2 ); } -IMPL_LINK( CustomAnimationEffectTabPage, implClickHdl, Button*, pBtn, void ) +IMPL_LINK(CustomAnimationEffectTabPage, implClickHdl, weld::Button&, rBtn, void) { - implHdl(pBtn); + implHdl(&rBtn); } -IMPL_LINK( CustomAnimationEffectTabPage, implSelectHdl, ListBox&, rListBox, void ) + +IMPL_LINK(CustomAnimationEffectTabPage, implSelectHdl, weld::ComboBox&, rListBox, void) { implHdl(&rListBox); } -void CustomAnimationEffectTabPage::implHdl(Control const * pControl ) +void CustomAnimationEffectTabPage::implHdl(const weld::Widget* pControl) { - if( pControl == mpLBTextAnim ) + if (pControl == mxLBTextAnim.get()) { - if( mpMFTextDelay->GetValue() == 0 ) - mpMFTextDelay->SetValue( 100 ); + if (mxMFTextDelay->get_value(FUNIT_NONE) == 0) + mxMFTextDelay->set_value(100, FUNIT_NONE); } - else if( pControl == mpLBSound ) + else if (pControl == mxLBSound.get()) { - sal_Int32 nPos = mpLBSound->GetSelectedEntryPos(); - if( nPos == (mpLBSound->GetEntryCount() - 1) ) + auto nPos = mxLBSound->get_active(); + if (nPos == (mxLBSound->get_count() - 1)) { openSoundFileDialog(); } } - else if( pControl == mpPBSoundPreview ) + else if (pControl == mxPBSoundPreview.get()) { onSoundPreview(); } @@ -1320,9 +2015,9 @@ void CustomAnimationEffectTabPage::implHdl(Control const * pControl ) void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) { - if( mpLBProperty1->getSubControl() ) + if (mxLBSubControl) { - Any aNewValue( mpLBProperty1->getSubControl()->getValue() ); + Any aNewValue(mxLBSubControl->getValue()); Any aOldValue; if( mpSet->getPropertyState( nHandleProperty1Value ) != STLPropertyState::Ambiguous) aOldValue = mpSet->getPropertyValue( nHandleProperty1Value ); @@ -1331,11 +2026,11 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleProperty1Value, aNewValue ); } - if( mpCBSmoothStart->IsVisible() ) + if (mxCBSmoothStart->get_visible()) { // set selected value for accelerate if different than in original set - double fTemp = mpCBSmoothStart->IsChecked() ? 0.5 : 0.0; + double fTemp = mxCBSmoothStart->get_active() ? 0.5 : 0.0; double fOldTemp = 0.0; if(mpSet->getPropertyState( nHandleAccelerate ) != STLPropertyState::Ambiguous) @@ -1347,7 +2042,7 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleAccelerate, makeAny( fTemp ) ); // set selected value for decelerate if different than in original set - fTemp = mpCBSmoothEnd->IsChecked() ? 0.5 : 0.0; + fTemp = mxCBSmoothEnd->get_active() ? 0.5 : 0.0; if(mpSet->getPropertyState( nHandleDecelerate ) != STLPropertyState::Ambiguous) mpSet->getPropertyValue( nHandleDecelerate ) >>= fOldTemp; @@ -1358,8 +2053,8 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleDecelerate, makeAny( fTemp ) ); } - sal_Int32 nPos = mpLBAfterEffect->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + auto nPos = mxLBAfterEffect->get_active(); + if (nPos != -1) { bool bAfterEffect = nPos != 0; @@ -1376,7 +2071,7 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) Any aDimColor; if( nPos == 1 ) { - Color aSelectedColor = mpCLBDimColor->GetSelectEntryColor(); + Color aSelectedColor = mxCLBDimColor->GetSelectEntryColor(); aDimColor <<= aSelectedColor.GetRGBColor(); } @@ -1394,8 +2089,8 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleAfterEffectOnNextEffect, makeAny( bAfterEffectOnNextEffect ) ); } - nPos = mpLBTextAnim->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + nPos = mxLBTextAnim->get_active(); + if (nPos != -1) { sal_Int16 nIterateType; @@ -1417,7 +2112,7 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) } { - double fIterateInterval = static_cast< double >( mpMFTextDelay->GetValue() ) / 10; + double fIterateInterval = static_cast<double>(mxMFTextDelay->get_value(FUNIT_NONE)) / 10; double fOldIterateInterval = -1.0; if( mpSet->getPropertyState( nHandleIterateInterval ) != STLPropertyState::Ambiguous ) @@ -1427,8 +2122,8 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleIterateInterval, makeAny( fIterateInterval ) ); } - nPos = mpLBSound->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + nPos = mxLBSound->get_active(); + if (nPos != -1) { Any aNewSoundURL, aOldSoundURL( makeAny( sal_Int32(0) ) ); @@ -1460,20 +2155,20 @@ void CustomAnimationEffectTabPage::fillSoundListBox() GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, maSoundList ); GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, maSoundList ); - mpLBSound->InsertEntry( SdResId(STR_CUSTOMANIMATION_NO_SOUND) ); - mpLBSound->InsertEntry( SdResId(STR_CUSTOMANIMATION_STOP_PREVIOUS_SOUND) ); + mxLBSound->append_text( SdResId(STR_CUSTOMANIMATION_NO_SOUND) ); + mxLBSound->append_text( SdResId(STR_CUSTOMANIMATION_STOP_PREVIOUS_SOUND) ); for(const OUString & rString : maSoundList) { INetURLObject aURL( rString ); - mpLBSound->InsertEntry( aURL.GetBase() ); + mxLBSound->append_text( aURL.GetBase() ); } - mpLBSound->InsertEntry( SdResId(STR_CUSTOMANIMATION_BROWSE_SOUND) ); + mxLBSound->append_text( SdResId(STR_CUSTOMANIMATION_BROWSE_SOUND) ); } void CustomAnimationEffectTabPage::clearSoundListBox() { maSoundList.clear(); - mpLBSound->Clear(); + mxLBSound->clear(); } sal_Int32 CustomAnimationEffectTabPage::getSoundObject( const OUString& rStr ) @@ -1540,12 +2235,12 @@ void CustomAnimationEffectTabPage::openSoundFileDialog() if( !bValidSoundFile ) nPos = 0; - mpLBSound->SelectEntryPos( nPos ); + mxLBSound->set_active(nPos); } void CustomAnimationEffectTabPage::onSoundPreview() { - const sal_Int32 nPos = mpLBSound->GetSelectedEntryPos(); + const auto nPos = mxLBSound->get_active(); if( nPos >= 2 ) try { @@ -1559,67 +2254,61 @@ void CustomAnimationEffectTabPage::onSoundPreview() } } -class CustomAnimationDurationTabPage : public TabPage +class CustomAnimationDurationTabPage { public: - CustomAnimationDurationTabPage( vcl::Window* pParent, const STLPropertySet* pSet ); - virtual ~CustomAnimationDurationTabPage() override; - virtual void dispose() override; + CustomAnimationDurationTabPage(weld::Container* pParent, const STLPropertySet* pSet); void update( STLPropertySet* pSet ); - DECL_LINK( implControlHdl, ListBox&, void ); - DECL_LINK( implClickHdl, Button*, void ); - DECL_LINK( DurationModifiedHdl, Edit&, void ); - void implHdl(Control const *); + DECL_LINK(implControlHdl, weld::ComboBox&, void); + DECL_LINK(implClickHdl, weld::Button&, void); + DECL_LINK(DurationModifiedHdl, weld::MetricSpinButton&, void); + void implHdl(const weld::Widget*); private: const STLPropertySet* mpSet; - VclPtr<FixedText> mpFTStart; - VclPtr<ListBox> mpLBStart; - VclPtr<FixedText> mpFTStartDelay; - VclPtr<MetricField> mpMFStartDelay; - VclPtr<FixedText> mpFTDuration; - VclPtr<MetricBox> mpCBXDuration; - VclPtr<FixedText> mpFTRepeat; - VclPtr<ListBox> mpCBRepeat; - VclPtr<CheckBox> mpCBXRewind; - VclPtr<RadioButton> mpRBClickSequence; - VclPtr<RadioButton> mpRBInteractive; - VclPtr<ListBox> mpLBTrigger; + std::unique_ptr<weld::Builder> mxBuilder; + std::unique_ptr<weld::Container> mxContainer; + std::unique_ptr<weld::Label> mxFTStart; + std::unique_ptr<weld::ComboBox> mxLBStart; + std::unique_ptr<weld::Label> mxFTStartDelay; + std::unique_ptr<weld::MetricSpinButton> mxMFStartDelay; + std::unique_ptr<weld::Label> mxFTDuration; + std::unique_ptr<weld::MetricSpinButton> mxCBXDuration; + std::unique_ptr<weld::Label> mxFTRepeat; + std::unique_ptr<weld::ComboBox> mxCBRepeat; + std::unique_ptr<weld::CheckButton> mxCBXRewind; + std::unique_ptr<weld::RadioButton> mxRBClickSequence; + std::unique_ptr<weld::RadioButton> mxRBInteractive; + std::unique_ptr<weld::ComboBox> mxLBTrigger; }; -CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pParent, const STLPropertySet* pSet) -: TabPage( pParent, "TimingTab", "modules/simpress/ui/customanimationtimingtab.ui" ), mpSet( pSet ) -{ - get(mpFTStart,"start_label" ); - get(mpLBStart, "start_list" ); - get(mpFTStartDelay, "delay_label" ); - get(mpMFStartDelay, "delay_value" ); - get(mpFTDuration, "duration_label" ); - get(mpCBXDuration, "anim_duration" ); - get(mpFTRepeat, "repeat_label" ); - get(mpCBRepeat, "repeat_list" ); - get(mpCBXRewind, "rewind" ); - get(mpRBClickSequence, "rb_click_sequence" ); - get(mpRBInteractive, "rb_interactive" ); - get(mpLBTrigger, "trigger_list"); - mpLBTrigger->set_width_request(approximate_char_width() * 40); - - fillRepeatComboBox( mpCBRepeat ); - - //fillDurationMetricComboBox - mpCBXDuration->InsertValue(50, FUNIT_CUSTOM); - mpCBXDuration->InsertValue(100, FUNIT_CUSTOM); - mpCBXDuration->InsertValue(200, FUNIT_CUSTOM); - mpCBXDuration->InsertValue(300, FUNIT_CUSTOM); - mpCBXDuration->InsertValue(500, FUNIT_CUSTOM); - mpCBXDuration->AdaptDropDownLineCountToMaximum(); - - mpRBClickSequence->SetClickHdl( LINK( this, CustomAnimationDurationTabPage, implClickHdl ) ); - mpLBTrigger->SetSelectHdl( LINK( this, CustomAnimationDurationTabPage, implControlHdl ) ); - mpCBXDuration->SetModifyHdl(LINK( this, CustomAnimationDurationTabPage, DurationModifiedHdl)); +CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(weld::Container* pParent, const STLPropertySet* pSet) + : mpSet(pSet) + , mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationtimingtab.ui")) + , mxContainer(mxBuilder->weld_container("TimingTab")) + , mxFTStart(mxBuilder->weld_label("start_label")) + , mxLBStart(mxBuilder->weld_combo_box("start_list")) + , mxFTStartDelay(mxBuilder->weld_label("delay_label")) + , mxMFStartDelay(mxBuilder->weld_metric_spin_button("delay_value", FUNIT_SECOND)) + , mxFTDuration(mxBuilder->weld_label("duration_label")) + , mxCBXDuration(mxBuilder->weld_metric_spin_button("anim_duration", FUNIT_SECOND)) + , mxFTRepeat(mxBuilder->weld_label("repeat_label")) + , mxCBRepeat(mxBuilder->weld_combo_box("repeat_list")) + , mxCBXRewind(mxBuilder->weld_check_button("rewind")) + , mxRBClickSequence(mxBuilder->weld_radio_button("rb_click_sequence")) + , mxRBInteractive(mxBuilder->weld_radio_button("rb_interactive")) + , mxLBTrigger(mxBuilder->weld_combo_box("trigger_list")) +{ + mxLBTrigger->set_size_request(mxLBTrigger->get_approximate_digit_width() * 20, -1); + + fillRepeatComboBox(*mxCBRepeat); + + mxRBClickSequence->connect_clicked(LINK(this, CustomAnimationDurationTabPage, implClickHdl)); + mxLBTrigger->connect_changed(LINK(this, CustomAnimationDurationTabPage, implControlHdl)); + mxCBXDuration->connect_value_changed(LINK( this, CustomAnimationDurationTabPage, DurationModifiedHdl)); if( pSet->getPropertyState( nHandleStart ) != STLPropertyState::Ambiguous ) { @@ -1631,14 +2320,14 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar case EffectNodeType::WITH_PREVIOUS: nPos = 1; break; case EffectNodeType::AFTER_PREVIOUS: nPos = 2; break; } - mpLBStart->SelectEntryPos( nPos ); + mxLBStart->set_active(nPos); } if( pSet->getPropertyState( nHandleBegin ) != STLPropertyState::Ambiguous ) { double fBegin = 0.0; pSet->getPropertyValue( nHandleBegin ) >>= fBegin; - mpMFStartDelay->SetValue( static_cast<long>(fBegin*10) ); + mxMFStartDelay->set_value(static_cast<long>(fBegin*10), FUNIT_NONE); } if( pSet->getPropertyState( nHandleDuration ) != STLPropertyState::Ambiguous ) @@ -1648,15 +2337,15 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar if( fDuration == 0.001 ) { - mpFTDuration->Disable(); - mpCBXDuration->Disable(); - mpFTRepeat->Disable(); - mpCBRepeat->Disable(); - mpCBXRewind->Disable(); + mxFTDuration->set_sensitive(false); + mxCBXDuration->set_sensitive(false); + mxFTRepeat->set_sensitive(false); + mxCBRepeat->set_sensitive(false); + mxCBXRewind->set_sensitive(false); } else { - mpCBXDuration->SetValue( fDuration*100.0 ); + mxCBXDuration->set_value(fDuration * 100.0, FUNIT_NONE); } } @@ -1669,7 +2358,7 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar if( aRepeatCount.hasValue() ) aRepeatCount >>= fRepeat; - sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND; + auto nPos = -1; if( fRepeat == 0 ) nPos = 0; @@ -1684,10 +2373,10 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar else if( fRepeat == 10.0 ) nPos = 5; - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - mpCBRepeat->SelectEntryPos( nPos ); + if (nPos != -1) + mxCBRepeat->set_active(nPos); else - mpCBRepeat->SetText(OUString::number(fRepeat)); + mxCBRepeat->set_entry_text(OUString::number(fRepeat)); } else if( aRepeatCount.getValueType() == ::cppu::UnoType<Timing>::get() ) { @@ -1695,7 +2384,7 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar if( pSet->getPropertyState( nHandleEnd ) != STLPropertyState::Ambiguous ) aEnd = pSet->getPropertyValue( nHandleEnd ); - mpCBRepeat->SelectEntryPos( aEnd.hasValue() ? 6 : 7 ); + mxCBRepeat->set_active(aEnd.hasValue() ? 6 : 7); } } @@ -1704,11 +2393,11 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar sal_Int16 nFill = 0; if( pSet->getPropertyValue( nHandleRewind ) >>= nFill ) { - mpCBXRewind->Check( nFill == AnimationFill::REMOVE ); + mxCBXRewind->set_active(nFill == AnimationFill::REMOVE); } else { - mpCBXRewind->SetState( TRISTATE_INDET ); + mxCBXRewind->set_state(TRISTATE_INDET); } } @@ -1718,8 +2407,8 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar { pSet->getPropertyValue( nHandleTrigger ) >>= xTrigger; - mpRBInteractive->Check( xTrigger.is() ); - mpRBClickSequence->Check( !xTrigger.is() ); + mxRBInteractive->set_active(xTrigger.is()); + mxRBClickSequence->set_active(!xTrigger.is()); } Reference< XDrawPage > xCurrentPage; @@ -1746,72 +2435,49 @@ CustomAnimationDurationTabPage::CustomAnimationDurationTabPage(vcl::Window* pPar } OUString aDescription( getShapeDescription( xShape, true ) ); - sal_Int32 nPos = mpLBTrigger->InsertEntry( aDescription ); - - mpLBTrigger->SetEntryData( nPos, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nShape)) ); - if( xShape == xTrigger ) - mpLBTrigger->SelectEntryPos( nPos ); + mxLBTrigger->append(OUString::number(nShape), aDescription); + auto nPos = mxLBTrigger->get_count() - 1; + if (xShape == xTrigger) + mxLBTrigger->set_active(nPos); } } } -CustomAnimationDurationTabPage::~CustomAnimationDurationTabPage() -{ - disposeOnce(); -} - -void CustomAnimationDurationTabPage::dispose() -{ - mpFTStart.clear(); - mpLBStart.clear(); - mpFTStartDelay.clear(); - mpMFStartDelay.clear(); - mpFTDuration.clear(); - mpCBXDuration.clear(); - mpFTRepeat.clear(); - mpCBRepeat.clear(); - mpCBXRewind.clear(); - mpRBClickSequence.clear(); - mpRBInteractive.clear(); - mpLBTrigger.clear(); - TabPage::dispose(); -} - -IMPL_LINK( CustomAnimationDurationTabPage, implClickHdl, Button*, pBtn, void ) +IMPL_LINK(CustomAnimationDurationTabPage, implClickHdl, weld::Button&, rBtn, void) { - implHdl(pBtn); + implHdl(&rBtn); } -IMPL_LINK( CustomAnimationDurationTabPage, implControlHdl, ListBox&, rListBox, void ) +IMPL_LINK(CustomAnimationDurationTabPage, implControlHdl, weld::ComboBox&, rListBox, void) { implHdl(&rListBox); } -IMPL_LINK_NOARG(CustomAnimationDurationTabPage, DurationModifiedHdl, Edit&, void) +IMPL_LINK_NOARG(CustomAnimationDurationTabPage, DurationModifiedHdl, weld::MetricSpinButton&, void) { - if(!(mpCBXDuration->GetText()).isEmpty() ) + if (!mxCBXDuration->get_text().isEmpty()) { - double duration_value = static_cast<double>(mpCBXDuration->GetValue()); + double duration_value = static_cast<double>(mxCBXDuration->get_value(FUNIT_NONE)); if(duration_value <= 0.0) - mpCBXDuration->SetValue(1); + mxCBXDuration->set_value(1, FUNIT_NONE); else - mpCBXDuration->SetValue(duration_value); + mxCBXDuration->set_value(duration_value, FUNIT_NONE); } } -void CustomAnimationDurationTabPage::implHdl( Control const * pControl ) +void CustomAnimationDurationTabPage::implHdl(const weld::Widget* pControl) { - if( pControl == mpLBTrigger ) + if (pControl == mxLBTrigger.get()) { - mpRBClickSequence->Check( false ); - mpRBInteractive->Check(); + mxRBClickSequence->set_active(false); + mxRBInteractive->set_active(true); } } void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) { - sal_Int32 nPos = mpLBStart->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + auto nPos = mxLBStart->get_active(); + if (nPos != -1) { sal_Int16 nStart; sal_Int16 nOldStart = -1; @@ -1832,7 +2498,7 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) } { - double fBegin = static_cast<double>( mpMFStartDelay->GetValue()) / 10.0; + double fBegin = static_cast<double>(mxMFStartDelay->get_value(FUNIT_NONE)) / 10.0; double fOldBegin = -1.0; if( mpSet->getPropertyState( nHandleBegin ) != STLPropertyState::Ambiguous ) @@ -1842,8 +2508,8 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleBegin, makeAny( fBegin ) ); } - nPos = mpCBRepeat->GetSelectedEntryPos(); - if( (nPos != LISTBOX_ENTRY_NOTFOUND) || (!mpCBRepeat->GetText().isEmpty()) ) + nPos = mxCBRepeat->get_active(); + if (nPos != -1 || !mxCBRepeat->get_active_text().isEmpty()) { Any aRepeatCount; Any aEnd; @@ -1866,7 +2532,7 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) break; default: { - OUString aText(mpCBRepeat->GetEntry(nPos)); + OUString aText(mxCBRepeat->get_text(nPos)); if( !aText.isEmpty() ) aRepeatCount <<= aText.toDouble(); } @@ -1889,9 +2555,9 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) double fDuration = -1.0; - if(!(mpCBXDuration->GetText()).isEmpty() ) + if (!mxCBXDuration->get_text().isEmpty()) { - double duration_value = static_cast<double>(mpCBXDuration->GetValue()); + double duration_value = static_cast<double>(mxCBXDuration->get_value(FUNIT_NONE)); if(duration_value > 0) fDuration = duration_value/100.0; @@ -1908,9 +2574,9 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleDuration, makeAny( fDuration ) ); } - if( mpCBXRewind->GetState() != TRISTATE_INDET ) + if (mxCBXRewind->get_state() != TRISTATE_INDET) { - sal_Int16 nFill = mpCBXRewind->IsChecked() ? AnimationFill::REMOVE : AnimationFill::HOLD; + sal_Int16 nFill = mxCBXRewind->get_active() ? AnimationFill::REMOVE : AnimationFill::HOLD; bool bSet = true; @@ -1927,12 +2593,12 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) Reference< XShape > xTrigger; - if( mpRBInteractive->IsChecked() ) + if (mxRBInteractive->get_active()) { - nPos = mpLBTrigger->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + nPos = mxLBTrigger->get_active(); + if (nPos != -1) { - sal_Int32 nShape = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(mpLBTrigger->GetEntryData( nPos ))); + sal_Int32 nShape = mxLBTrigger->get_id(nPos).toInt32(); Reference< XDrawPage > xCurrentPage; mpSet->getPropertyValue( nHandleCurrentPage ) >>= xCurrentPage; @@ -1942,7 +2608,7 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) } } - if( xTrigger.is() || mpRBClickSequence->IsChecked() ) + if (xTrigger.is() || mxRBClickSequence->get_active()) { Any aNewValue( makeAny( xTrigger ) ); Any aOldValue; @@ -1955,50 +2621,49 @@ void CustomAnimationDurationTabPage::update( STLPropertySet* pSet ) } } -class CustomAnimationTextAnimTabPage : public TabPage +class CustomAnimationTextAnimTabPage { public: - CustomAnimationTextAnimTabPage( vcl::Window* pParent, const STLPropertySet* pSet ); - virtual ~CustomAnimationTextAnimTabPage() override; - virtual void dispose() override; + CustomAnimationTextAnimTabPage(weld::Container* pParent, const STLPropertySet* pSet); void update( STLPropertySet* pSet ); void updateControlStates(); - DECL_LINK(implSelectHdl, ListBox&, void); + DECL_LINK(implSelectHdl, weld::ComboBox&, void); private: - VclPtr<FixedText> maFTGroupText; - VclPtr<ListBox> maLBGroupText; - VclPtr<CheckBox> maCBXGroupAuto; - VclPtr<MetricField> maMFGroupAuto; - VclPtr<CheckBox> maCBXAnimateForm; - VclPtr<CheckBox> maCBXReverse; - const STLPropertySet* mpSet; - bool mbHasVisibleShapes; + + std::unique_ptr<weld::Builder> mxBuilder; + std::unique_ptr<weld::Container> mxContainer; + std::unique_ptr<weld::Label> mxFTGroupText; + std::unique_ptr<weld::ComboBox> mxLBGroupText; + std::unique_ptr<weld::CheckButton> mxCBXGroupAuto; + std::unique_ptr<weld::MetricSpinButton> mxMFGroupAuto; + std::unique_ptr<weld::CheckButton> mxCBXAnimateForm; + std::unique_ptr<weld::CheckButton> mxCBXReverse; }; -CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(vcl::Window* pParent, const STLPropertySet* pSet) -: TabPage( pParent, "TextAnimationTab", "modules/simpress/ui/customanimationtexttab.ui" ), - mpSet( pSet ), - mbHasVisibleShapes(true) +CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(weld::Container* pParent, const STLPropertySet* pSet) + : mpSet(pSet) + , mbHasVisibleShapes(true) + , mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationtexttab.ui")) + , mxContainer(mxBuilder->weld_container("TextAnimationTab")) + , mxFTGroupText(mxBuilder->weld_label("group_text_label")) + , mxLBGroupText(mxBuilder->weld_combo_box("group_text_list")) + , mxCBXGroupAuto(mxBuilder->weld_check_button("auto_after")) + , mxMFGroupAuto(mxBuilder->weld_metric_spin_button("auto_after_value",FUNIT_SECOND)) + , mxCBXAnimateForm(mxBuilder->weld_check_button("animate_shape")) + , mxCBXReverse(mxBuilder->weld_check_button("reverse_order")) { - get( maFTGroupText, "group_text_label" ); - get( maLBGroupText, "group_text_list" ); - get( maCBXGroupAuto, "auto_after" ); - get( maMFGroupAuto, "auto_after_value" ); - get( maCBXAnimateForm, "animate_shape" ); - get( maCBXReverse, "reverse_order" ); - - maLBGroupText->SetSelectHdl( LINK( this, CustomAnimationTextAnimTabPage, implSelectHdl ) ); + mxLBGroupText->connect_changed(LINK(this, CustomAnimationTextAnimTabPage, implSelectHdl)); if( pSet->getPropertyState( nHandleTextGrouping ) != STLPropertyState::Ambiguous ) { sal_Int32 nTextGrouping = 0; if( pSet->getPropertyValue( nHandleTextGrouping ) >>= nTextGrouping ) - maLBGroupText->SelectEntryPos( nTextGrouping + 1 ); + mxLBGroupText->set_active(nTextGrouping + 1); } if( pSet->getPropertyState( nHandleHasVisibleShape ) != STLPropertyState::Ambiguous ) @@ -2009,37 +2674,37 @@ CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(vcl::Window* pPar double fTextGroupingAuto = 0.0; if( pSet->getPropertyValue( nHandleTextGroupingAuto ) >>= fTextGroupingAuto ) { - maCBXGroupAuto->Check( fTextGroupingAuto >= 0.0 ); + mxCBXGroupAuto->set_active(fTextGroupingAuto >= 0.0); if( fTextGroupingAuto >= 0.0 ) - maMFGroupAuto->SetValue( static_cast<long>(fTextGroupingAuto*10) ); + mxMFGroupAuto->set_value(static_cast<long>(fTextGroupingAuto*10), FUNIT_NONE); } } else { - maCBXGroupAuto->SetState( TRISTATE_INDET ); + mxCBXGroupAuto->set_state( TRISTATE_INDET ); } - maCBXAnimateForm->SetState( TRISTATE_INDET ); + mxCBXAnimateForm->set_state( TRISTATE_INDET ); if( pSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState::Ambiguous ) { bool bAnimateForm = false; if( pSet->getPropertyValue( nHandleAnimateForm ) >>= bAnimateForm ) { - maCBXAnimateForm->Check( bAnimateForm ); + mxCBXAnimateForm->set_active( bAnimateForm ); } } else { - maCBXAnimateForm->Enable( false ); + mxCBXAnimateForm->set_sensitive(false); } - maCBXReverse->SetState( TRISTATE_INDET ); + mxCBXReverse->set_state(TRISTATE_INDET); if( pSet->getPropertyState( nHandleTextReverse ) != STLPropertyState::Ambiguous ) { bool bTextReverse = false; if( pSet->getPropertyValue( nHandleTextReverse ) >>= bTextReverse ) { - maCBXReverse->Check( bTextReverse ); + mxCBXReverse->set_active( bTextReverse ); } } @@ -2052,7 +2717,7 @@ CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(vcl::Window* pPar sal_Int32 nPos = 6; while( (nPos > 2) && (nPos > nMaxParaDepth) ) { - maLBGroupText->RemoveEntry( nPos ); + mxLBGroupText->remove(nPos); nPos--; } } @@ -2060,26 +2725,10 @@ CustomAnimationTextAnimTabPage::CustomAnimationTextAnimTabPage(vcl::Window* pPar updateControlStates(); } -CustomAnimationTextAnimTabPage::~CustomAnimationTextAnimTabPage() -{ - disposeOnce(); -} - -void CustomAnimationTextAnimTabPage::dispose() -{ - maFTGroupText.clear(); - maLBGroupText.clear(); - maCBXGroupAuto.clear(); - maMFGroupAuto.clear(); - maCBXAnimateForm.clear(); - maCBXReverse.clear(); - TabPage::dispose(); -} - void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet ) { - sal_Int32 nPos = maLBGroupText->GetSelectedEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + auto nPos = mxLBGroupText->get_active(); + if (nPos != -1) { sal_Int32 nTextGrouping = nPos - 1; sal_Int32 nOldGrouping = -2; @@ -2091,9 +2740,9 @@ void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet ) pSet->setPropertyValue( nHandleTextGrouping, makeAny( nTextGrouping ) ); } - if( nPos > 0 ) + if (nPos != 0) { - bool bTextReverse = maCBXReverse->IsChecked(); + bool bTextReverse = mxCBXReverse->get_active(); bool bOldTextReverse = !bTextReverse; if(mpSet->getPropertyState( nHandleTextReverse ) != STLPropertyState::Ambiguous) @@ -2104,7 +2753,7 @@ void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet ) if( nPos > 1 ) { - double fTextGroupingAuto = maCBXGroupAuto->IsChecked() ? maMFGroupAuto->GetValue() / 10.0 : -1.0; + double fTextGroupingAuto = mxCBXGroupAuto->get_active() ? mxMFGroupAuto->get_value(FUNIT_NONE) / 10.0 : -1.0; double fOldTextGroupingAuto = -2.0; if(mpSet->getPropertyState( nHandleTextGroupingAuto ) != STLPropertyState::Ambiguous) @@ -2117,9 +2766,9 @@ void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet ) //#i120049# impress crashes when modifying the "Random effects" animation //effect's trigger condition to "Start effect on click of". //If this control is disabled, we should ignore its value - if (maCBXAnimateForm->IsEnabled()) + if (mxCBXAnimateForm->get_sensitive()) { - bool bAnimateForm = maCBXAnimateForm->IsChecked(); + bool bAnimateForm = mxCBXAnimateForm->get_active(); bool bOldAnimateForm = !bAnimateForm; if(mpSet->getPropertyState( nHandleAnimateForm ) != STLPropertyState::Ambiguous) @@ -2132,90 +2781,66 @@ void CustomAnimationTextAnimTabPage::update( STLPropertySet* pSet ) void CustomAnimationTextAnimTabPage::updateControlStates() { - sal_Int32 nPos = maLBGroupText->GetSelectedEntryPos(); + auto nPos = mxLBGroupText->get_active(); - maCBXGroupAuto->Enable( nPos > 1 ); - maMFGroupAuto->Enable( nPos > 1 ); - maCBXReverse->Enable( nPos > 0 ); + mxCBXGroupAuto->set_sensitive( nPos > 1 ); + mxMFGroupAuto->set_sensitive( nPos > 1 ); + mxCBXReverse->set_sensitive( nPos > 0 ); if( !mbHasVisibleShapes && nPos > 0 ) { - maCBXAnimateForm->Check(false); - maCBXAnimateForm->Enable(false); + mxCBXAnimateForm->set_active(false); + mxCBXAnimateForm->set_sensitive(false); } else { - maCBXAnimateForm->Enable(); + mxCBXAnimateForm->set_sensitive(true); } } -IMPL_LINK_NOARG(CustomAnimationTextAnimTabPage, implSelectHdl, ListBox&, void) +IMPL_LINK_NOARG(CustomAnimationTextAnimTabPage, implSelectHdl, weld::ComboBox&, void) { updateControlStates(); } -CustomAnimationDialog::CustomAnimationDialog(vcl::Window* pParent, std::unique_ptr<STLPropertySet> pSet, const OString& sPage) -: TabDialog( pParent, "CustomAnimationProperties", "modules/simpress/ui/customanimationproperties.ui") -, mpSet( std::move(pSet) ) +CustomAnimationDialog::CustomAnimationDialog(weld::Window* pParent, std::unique_ptr<STLPropertySet> pSet, const OString& rPage) + : GenericDialogController(pParent, "modules/simpress/ui/customanimationproperties.ui", "CustomAnimationProperties") + , mxSet(std::move(pSet)) + , mxTabControl(m_xBuilder->weld_notebook("tabs")) + , mxDurationTabPage(new CustomAnimationDurationTabPage(mxTabControl->get_page("timing"), mxSet.get())) + , mxEffectTabPage(new CustomAnimationEffectTabPage(mxTabControl->get_page("effect"), m_xDialog.get(), mxSet.get())) { - get(mpTabControl, "tabs"); - - sal_uInt16 nEffectId = mpTabControl->GetPageId("effect"); - sal_uInt16 nTimingId = mpTabControl->GetPageId("timing"); - sal_uInt16 nTextAnimId = mpTabControl->GetPageId("textanim"); - - mpEffectTabPage = VclPtr<CustomAnimationEffectTabPage>::Create( mpTabControl, mpSet.get() ); - mpTabControl->SetTabPage( nEffectId, mpEffectTabPage ); - mpDurationTabPage = VclPtr<CustomAnimationDurationTabPage>::Create( mpTabControl, mpSet.get() ); - mpTabControl->SetTabPage( nTimingId, mpDurationTabPage ); - bool bHasText = false; - if( mpSet->getPropertyState( nHandleHasText ) != STLPropertyState::Ambiguous ) - mpSet->getPropertyValue( nHandleHasText ) >>= bHasText; + if( mxSet->getPropertyState( nHandleHasText ) != STLPropertyState::Ambiguous ) + mxSet->getPropertyValue( nHandleHasText ) >>= bHasText; if( bHasText ) { - mpTextAnimTabPage = VclPtr<CustomAnimationTextAnimTabPage>::Create( mpTabControl, mpSet.get() ); - mpTabControl->SetTabPage( nTextAnimId, mpTextAnimTabPage ); + mxTextAnimTabPage.reset(new CustomAnimationTextAnimTabPage(mxTabControl->get_page("textanim"), mxSet.get())); } else { - mpTextAnimTabPage = nullptr; - mpTabControl->RemovePage( nTextAnimId ); + mxTabControl->remove_page("textanim"); } - if (!sPage.isEmpty()) - mpTabControl->SelectTabPage(mpTabControl->GetPageId(sPage)); + if (!rPage.isEmpty()) + mxTabControl->set_current_page(rPage); } CustomAnimationDialog::~CustomAnimationDialog() { - disposeOnce(); -} - -void CustomAnimationDialog::dispose() -{ - mpEffectTabPage.disposeAndClear(); - mpDurationTabPage.disposeAndClear(); - mpTextAnimTabPage.disposeAndClear(); - - mpSet.reset(); - mpResultSet.reset(); - - mpTabControl.clear(); - TabDialog::dispose(); } STLPropertySet* CustomAnimationDialog::getResultSet() { - mpResultSet = createDefaultSet(); + mxResultSet = createDefaultSet(); - mpEffectTabPage->update( mpResultSet.get() ); - mpDurationTabPage->update( mpResultSet.get() ); - if( mpTextAnimTabPage ) - mpTextAnimTabPage->update( mpResultSet.get() ); + mxEffectTabPage->update( mxResultSet.get() ); + mxDurationTabPage->update( mxResultSet.get() ); + if (mxTextAnimTabPage) + mxTextAnimTabPage->update( mxResultSet.get() ); - return mpResultSet.get(); + return mxResultSet.get(); } std::unique_ptr<STLPropertySet> CustomAnimationDialog::createDefaultSet() @@ -2362,6 +2987,53 @@ std::unique_ptr<PropertySubControl> PropertySubControl::create( sal_Int32 nType, return pSubControl; } +std::unique_ptr<SdPropertySubControl> SdPropertySubControl::create(sal_Int32 nType, weld::Label* pLabel, weld::Container* pParent, weld::Window* pTopLevel, const Any& rValue, const OUString& rPresetId, const Link<LinkParamNone*,void>& rModifyHdl) +{ + std::unique_ptr<SdPropertySubControl> pSubControl; + switch( nType ) + { + case nPropertyTypeDirection: + case nPropertyTypeSpokes: + case nPropertyTypeZoom: + pSubControl.reset( new SdPresetPropertyBox( nType, pLabel, pParent, rValue, rPresetId, rModifyHdl ) ); + break; + + case nPropertyTypeColor: + case nPropertyTypeFillColor: + case nPropertyTypeFirstColor: + case nPropertyTypeCharColor: + case nPropertyTypeLineColor: + pSubControl.reset( new SdColorPropertyBox( nType, pLabel, pParent, pTopLevel, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeFont: + pSubControl.reset( new SdFontPropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeCharHeight: + pSubControl.reset( new SdCharHeightPropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeRotate: + pSubControl.reset( new SdRotationPropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeTransparency: + pSubControl.reset( new SdTransparencyPropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeScale: + pSubControl.reset( new SdScalePropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + + case nPropertyTypeCharDecoration: + pSubControl.reset( new SdFontStylePropertyBox( nType, pLabel, pParent, rValue, rModifyHdl ) ); + break; + } + + return pSubControl; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/animations/CustomAnimationDialog.hxx b/sd/source/ui/animations/CustomAnimationDialog.hxx index 8f19c1d6005f..47474b28255f 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.hxx +++ b/sd/source/ui/animations/CustomAnimationDialog.hxx @@ -24,6 +24,7 @@ #include <CustomAnimationPreset.hxx> #include <vcl/tabdlg.hxx> #include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> class TabControl; class OKButton; @@ -118,6 +119,38 @@ protected: sal_Int32 const mnType; }; +class SdPropertySubControl +{ +public: + explicit SdPropertySubControl(weld::Container* pParent, sal_Int32 nType) + : mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationfragment.ui")) + , mxContainer(mxBuilder->weld_container("EffectFragment")) + , mnType( nType ) + { + } + + virtual ~SdPropertySubControl(); + + virtual css::uno::Any getValue() = 0; + virtual void setValue( const css::uno::Any& rValue, const OUString& rPresetId ) = 0; + + static std::unique_ptr<SdPropertySubControl> + create( sal_Int32 nType, + weld::Label* pLabel, + weld::Container* pParent, + weld::Window* pTopLevel, + const css::uno::Any& rValue, + const OUString& rPresetId, + const Link<LinkParamNone*,void>& rModifyHdl ); + + sal_Int32 getControlType() const { return mnType; } + +protected: + std::unique_ptr<weld::Builder> mxBuilder; + std::unique_ptr<weld::Container> mxContainer; + sal_Int32 mnType; +}; + class PropertyControl : public ListBox { public: @@ -139,27 +172,25 @@ class CustomAnimationEffectTabPage; class CustomAnimationTextAnimTabPage; class STLPropertySet; -class CustomAnimationDialog : public TabDialog +class CustomAnimationDialog : public weld::GenericDialogController { public: - CustomAnimationDialog(vcl::Window* pParent, std::unique_ptr<STLPropertySet> pSet, const OString& Page); + CustomAnimationDialog(weld::Window* pParent, std::unique_ptr<STLPropertySet> pSet, const OString& Page); virtual ~CustomAnimationDialog() override; - virtual void dispose() override; STLPropertySet* getResultSet(); - STLPropertySet* getPropertySet() const { return mpSet.get(); } + STLPropertySet* getPropertySet() const { return mxSet.get(); } static std::unique_ptr<STLPropertySet> createDefaultSet(); private: - std::unique_ptr<STLPropertySet> mpSet; - std::unique_ptr<STLPropertySet> mpResultSet; - - VclPtr<TabControl> mpTabControl; + std::unique_ptr<STLPropertySet> mxSet; + std::unique_ptr<STLPropertySet> mxResultSet; - VclPtr<CustomAnimationDurationTabPage> mpDurationTabPage; - VclPtr<CustomAnimationEffectTabPage> mpEffectTabPage; - VclPtr<CustomAnimationTextAnimTabPage> mpTextAnimTabPage; + std::unique_ptr<weld::Notebook> mxTabControl; + std::unique_ptr<CustomAnimationDurationTabPage> mxDurationTabPage; + std::unique_ptr<CustomAnimationEffectTabPage> mxEffectTabPage; + std::unique_ptr<CustomAnimationTextAnimTabPage> mxTextAnimTabPage; }; } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index a1837725974c..c32b1788c201 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -107,21 +107,21 @@ using ::com::sun::star::uno::Exception; namespace sd { -void fillRepeatComboBox( ListBox* pBox ) +void fillRepeatComboBox(weld::ComboBox& rBox) { OUString aNone( SdResId( STR_CUSTOMANIMATION_REPEAT_NONE ) ); - pBox->InsertEntry(aNone); - pBox->InsertEntry(OUString::number(2)); - pBox->InsertEntry(OUString::number(3)); - pBox->InsertEntry(OUString::number(4)); - pBox->InsertEntry(OUString::number(5)); - pBox->InsertEntry(OUString::number(10)); + rBox.append_text(aNone); + rBox.append_text(OUString::number(2)); + rBox.append_text(OUString::number(3)); + rBox.append_text(OUString::number(4)); + rBox.append_text(OUString::number(5)); + rBox.append_text(OUString::number(10)); OUString aUntilClick( SdResId( STR_CUSTOMANIMATION_REPEAT_UNTIL_NEXT_CLICK ) ); - pBox->InsertEntry(aUntilClick); + rBox.append_text(aUntilClick); OUString aEndOfSlide( SdResId( STR_CUSTOMANIMATION_REPEAT_UNTIL_END_OF_SLIDE ) ); - pBox->InsertEntry(aEndOfSlide); + rBox.append_text(aEndOfSlide); } CustomAnimationPane::CustomAnimationPane( Window* pParent, ViewShellBase& rBase, @@ -1664,21 +1664,20 @@ void CustomAnimationPane::changeSelection( STLPropertySet const * pResultSet, ST } } -void CustomAnimationPane::showOptions(const OString& sPage) +void CustomAnimationPane::showOptions(const OString& rPage) { - std::unique_ptr<STLPropertySet> pSet = createSelectionSet(); + std::unique_ptr<STLPropertySet> xSet = createSelectionSet(); - auto pDlg = VclPtr<CustomAnimationDialog>::Create(this, std::move(pSet), sPage); + std::shared_ptr<CustomAnimationDialog> xDlg(new CustomAnimationDialog(GetFrameWeld(), std::move(xSet), rPage)); - pDlg->StartExecuteAsync([=](sal_Int32 nResult){ - if (nResult ) - { - addUndo(); - changeSelection( pDlg->getResultSet(), pDlg->getPropertySet() ); - updateControls(); - } - pDlg->disposeOnce(); - }); + weld::DialogController::runAsync(xDlg, [=](sal_Int32 nResult){ + if (nResult ) + { + addUndo(); + changeSelection(xDlg->getResultSet(), xDlg->getPropertySet()); + updateControls(); + } + }); } void CustomAnimationPane::onChangeCurrentPage() diff --git a/sd/source/ui/animations/CustomAnimationPane.hxx b/sd/source/ui/animations/CustomAnimationPane.hxx index abc84f5910fe..1c8bd070c784 100644 --- a/sd/source/ui/animations/CustomAnimationPane.hxx +++ b/sd/source/ui/animations/CustomAnimationPane.hxx @@ -194,7 +194,7 @@ private: ScopeLock maSelectionLock; }; -void fillRepeatComboBox( ListBox* pBox ); +void fillRepeatComboBox(weld::ComboBox& rBox); } |