summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-02-21 11:25:16 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-02-23 07:15:28 +0100
commitb37a46fdf91dbc66f6ddc1c070aec70716d94a01 (patch)
tree7d510a7e319563743fbb84032346fa2c62e674eb /include
parentfecc5d4a4423938de6d07dd57e6a98160bf91f3e (diff)
tdf#115938: Properly detect shadow size control's changed state
This change makes sure that only if the shadow size edit box' text is changed, it is converted to the size in twips. It sets wrapper's default value on each SetControlValue, to return proper initial size when the size text wasn't modified. Also both ExampleSet and OutSet in SfxTabDialog's Reset handler are processed to set relevant items back to initial value; otherwise, as the restored item (marked as unchanged) will be absent in tab's result set, it would not modify the old items in the two, and they would keep previous modified values. Change-Id: Ie4362811968c6e6cbe0f9229bd3c9b29462f5704 Reviewed-on: https://gerrit.libreoffice.org/50196 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/controlwrapper.hxx7
-rw-r--r--include/sfx2/itemconnect.hxx17
2 files changed, 17 insertions, 7 deletions
diff --git a/include/sfx2/controlwrapper.hxx b/include/sfx2/controlwrapper.hxx
index c130ae1c7328..746a0821a9a8 100644
--- a/include/sfx2/controlwrapper.hxx
+++ b/include/sfx2/controlwrapper.hxx
@@ -259,6 +259,7 @@ public:
virtual ValueT GetControlValue() const SAL_OVERRIDE;
virtual void SetControlValue( ValueT nValue ) SAL_OVERRIDE;
+ bool IsControlValueChanged() const;
private:
FieldUnit meUnit;
@@ -480,6 +481,12 @@ void MetricFieldWrapper< ValueT >::SetControlValue( ValueT nValue )
this->GetControl().SetValue( this->GetControl().Normalize( static_cast< sal_Int64 >( nValue ) ), meUnit );
}
+template< typename ValueT >
+bool MetricFieldWrapper< ValueT >::IsControlValueChanged() const
+{
+ return this->GetControl().IsValueChangedFromSaved();
+}
+
template< typename ValueT >
ValueT ListBoxWrapper< ValueT >::GetControlValue() const
diff --git a/include/sfx2/itemconnect.hxx b/include/sfx2/itemconnect.hxx
index a14361103bce..a4a122cddaac 100644
--- a/include/sfx2/itemconnect.hxx
+++ b/include/sfx2/itemconnect.hxx
@@ -243,6 +243,7 @@ protected:
ItemWrapperType maItemWrp;
std::unique_ptr<ControlWrpT> mxCtrlWrp;
+ bool mbModified;
};
@@ -393,7 +394,8 @@ ItemControlConnection< ItemWrpT, ControlWrpT >::ItemControlConnection(
sal_uInt16 nSlot, ControlWrpT* pNewCtrlWrp, ItemConnFlags nFlags ) :
ItemConnectionBase( nFlags ),
maItemWrp( nSlot ),
- mxCtrlWrp( pNewCtrlWrp )
+ mxCtrlWrp( pNewCtrlWrp ),
+ mbModified( false )
{
}
@@ -402,7 +404,8 @@ ItemControlConnection< ItemWrpT, ControlWrpT >::ItemControlConnection(
sal_uInt16 nSlot, ControlType& rControl, ItemConnFlags nFlags ) :
ItemConnectionBase( nFlags ),
maItemWrp( nSlot ),
- mxCtrlWrp( new ControlWrpT( rControl ) )
+ mxCtrlWrp( new ControlWrpT( rControl ) ),
+ mbModified( false )
{
}
@@ -425,6 +428,7 @@ void ItemControlConnection< ItemWrpT, ControlWrpT >::Reset( const SfxItemSet* pI
mxCtrlWrp->SetControlDontKnow( pItem == nullptr );
if( pItem )
mxCtrlWrp->SetControlValue( maItemWrp.GetItemValue( *pItem ) );
+ mbModified = false;
}
template< typename ItemWrpT, typename ControlWrpT >
@@ -432,7 +436,6 @@ bool ItemControlConnection< ItemWrpT, ControlWrpT >::FillItemSet(
SfxItemSet& rDestSet, const SfxItemSet& rOldSet )
{
const ItemType* pOldItem = maItemWrp.GetUniqueItem( rOldSet );
- bool bChanged = false;
if( !mxCtrlWrp->IsControlDontKnow() )
{
// first store the control value in a local variable
@@ -440,7 +443,7 @@ bool ItemControlConnection< ItemWrpT, ControlWrpT >::FillItemSet(
// convert to item value type -> possible to convert i.e. from 'T' to 'const T&'
ItemValueType aNewValue( aCtrlValue );
// do not rely on existence of ItemValueType::operator!=
- if( !pOldItem || !(maItemWrp.GetItemValue( *pOldItem ) == aNewValue) )
+ if( mbModified || !pOldItem || !(maItemWrp.GetItemValue( *pOldItem ) == aNewValue) )
{
sal_uInt16 nWhich = ItemWrapperHelper::GetWhichId( rDestSet, maItemWrp.GetSlotId() );
std::unique_ptr< ItemType > xItem(
@@ -448,12 +451,12 @@ bool ItemControlConnection< ItemWrpT, ControlWrpT >::FillItemSet(
xItem->SetWhich( nWhich );
maItemWrp.SetItemValue( *xItem, aNewValue );
rDestSet.Put( *xItem );
- bChanged = true;
+ mbModified = true;
}
}
- if( !bChanged )
+ if( !mbModified )
ItemWrapperHelper::RemoveDefaultItem( rDestSet, rOldSet, maItemWrp.GetSlotId() );
- return bChanged;
+ return mbModified;
}