diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-13 11:12:50 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-07-15 23:44:08 +0200 |
commit | 388f2fa9fcabe1b2adaff282fa9509216f3af6de (patch) | |
tree | 7f3f9bf662aaafbdcf8ed80c29cbeed8418042f5 /chart2 | |
parent | 1c269727b470c03f0ea538cad7e1331fd569a579 (diff) |
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
(cherry picked from commit 1d38cb365543924f9c50014e6b2227e77de1d0c9)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Conflicts:
xmloff/source/chart/SchXMLExport.cxx
sd/source/ui/view/sdview3.cxx
chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
chart2/source/controller/main/ChartTransferable.cxx
chart2/source/controller/main/ChartTransferable.hxx
chart2/source/model/main/Axis.cxx
chart2/source/model/template/ChartTypeTemplate.cxx
chart2/source/tools/AxisHelper.cxx
chart2/source/view/main/ChartView.cxx
comphelper/source/container/embeddedobjectcontainer.cxx
dbaccess/source/ui/browser/dbexchange.cxx
dbaccess/source/ui/inc/JoinExchange.hxx
dbaccess/source/ui/inc/TableRowExchange.hxx
dbaccess/source/ui/inc/dbexchange.hxx
dbaccess/source/ui/querydesign/JoinExchange.cxx
dbaccess/source/ui/tabledesign/TableRowExchange.cxx
embeddedobj/source/commonembedding/persistence.cxx
embeddedobj/source/inc/commonembobj.hxx
include/comphelper/embeddedobjectcontainer.hxx
include/svtools/embedtransfer.hxx
include/svtools/stringtransfer.hxx
include/svtools/transfer.hxx
include/svx/dbaexchange.hxx
include/svx/dbaobjectex.hxx
include/svx/fmview.hxx
include/svx/galmisc.hxx
include/svx/svdobj.hxx
include/svx/svdoole2.hxx
include/svx/svdxcgv.hxx
include/svx/view3d.hxx
include/svx/xmlexchg.hxx
include/xmloff/xmlexp.hxx
reportdesign/source/ui/dlg/GroupExchange.cxx
reportdesign/source/ui/dlg/GroupExchange.hxx
reportdesign/source/ui/inc/dlgedclip.hxx
reportdesign/source/ui/report/dlgedclip.cxx
sc/inc/column.hxx
sc/source/ui/app/drwtrans.cxx
sc/source/ui/app/lnktrans.cxx
sc/source/ui/app/seltrans.cxx
sc/source/ui/app/transobj.cxx
sc/source/ui/inc/drwtrans.hxx
sc/source/ui/inc/lnktrans.hxx
sc/source/ui/inc/seltrans.hxx
sc/source/ui/inc/transobj.hxx
sc/source/ui/inc/viewfunc.hxx
sc/source/ui/view/viewfun5.cxx
sc/source/ui/view/viewfun7.cxx
sd/source/ui/app/sdxfer.cxx
sd/source/ui/dlg/sdtreelb.cxx
sd/source/ui/inc/TabControl.hxx
sd/source/ui/inc/View.hxx
sd/source/ui/inc/sdtreelb.hxx
sd/source/ui/inc/sdxfer.hxx
sd/source/ui/view/sdview2.cxx
sd/source/ui/view/tabcontr.cxx
sfx2/source/doc/objxtor.cxx
svtools/source/misc/embedtransfer.cxx
svtools/source/misc/stringtransfer.cxx
svtools/source/misc/transfer.cxx
svtools/source/misc/transfer2.cxx
svx/source/engine3d/view3d.cxx
svx/source/fmcomp/dbaexchange.cxx
svx/source/fmcomp/dbaobjectex.cxx
svx/source/fmcomp/xmlexchg.cxx
svx/source/form/fmexch.cxx
svx/source/form/fmview.cxx
svx/source/gallery2/galmisc.cxx
svx/source/inc/fmexch.hxx
svx/source/svdraw/svdoole2.cxx
svx/source/svdraw/svdxcgv.cxx
svx/source/tbxctrls/colrctrl.cxx
sw/source/core/uibase/dochdl/swdtflvr.cxx
sw/source/core/uibase/inc/swdtflvr.hxx
sw/source/core/undo/unins.cxx
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
(cherry picked from commit 4ee53683df4beda260aff26d2c9e56fe643f45bb)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'chart2')
16 files changed, 87 insertions, 95 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 665ea5301656..28226dcce600 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -637,9 +637,8 @@ const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties() aWrappedProperties.push_back( new WrappedProperty("Visible","Show") ); aWrappedProperties.push_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") ); aWrappedProperties.push_back( new WrappedDirectStateProperty("TextBreak","TextBreak") ); - WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact ); - aWrappedProperties.push_back( pWrappedNumberFormatProperty ); - aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) ); + aWrappedProperties.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) ); + aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact) ); aWrappedProperties.push_back( new WrappedProperty("StackedText","StackCharacters") ); aWrappedProperties.push_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") ); { diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index 9b5b622c5d7e..a50778214083 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -698,9 +698,8 @@ const std::vector< WrappedProperty* > DataSeriesPointWrapper::createWrappedPrope WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact ); aWrappedProperties.push_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact ) ); - WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact ); - aWrappedProperties.push_back( pWrappedNumberFormatProperty ); - aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) ); + aWrappedProperties.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) ); + aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact) ); } WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx index a4010a81e4e2..5370d117e39f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx @@ -33,16 +33,10 @@ WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< C : WrappedDirectStateProperty( "NumberFormat", "NumberFormat" ) , m_spChart2ModelContact(spChart2ModelContact) { - m_aOuterValue = getPropertyDefault( 0 ); } WrappedNumberFormatProperty::~WrappedNumberFormatProperty() { - if( m_pWrappedLinkNumberFormatProperty ) - { - if( m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty == this ) - m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty = 0; - } } void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -52,19 +46,8 @@ void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, cons if( ! (rOuterValue >>= nFormat) ) throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", 0, 0 ); - m_aOuterValue = rOuterValue; if(xInnerPropertySet.is()) - { - bool bUseSourceFormat = !xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue(); - if( bUseSourceFormat ) - { - uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) - bUseSourceFormat = false; - } - if( !bUseSourceFormat ) - xInnerPropertySet->setPropertyValue( m_aInnerName, this->convertOuterToInnerValue( rOuterValue ) ); - } + xInnerPropertySet->setPropertyValue(getInnerName(), this->convertOuterToInnerValue(rOuterValue)); } Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -75,7 +58,7 @@ Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XProp OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue"); return Any(); } - Any aRet( xInnerPropertySet->getPropertyValue( m_aInnerName )); + Any aRet( xInnerPropertySet->getPropertyValue(getInnerName())); if( !aRet.hasValue() ) { sal_Int32 nKey = 0; @@ -98,23 +81,14 @@ Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPr return uno::makeAny( sal_Int32( 0 ) ); } -WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty ) - : WrappedProperty( "LinkNumberFormatToSource", OUString() ) - , m_pWrappedNumberFormatProperty( pWrappedNumberFormatProperty ) +WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact ) : + WrappedDirectStateProperty("LinkNumberFormatToSource", "LinkNumberFormatToSource"), + m_pChart2ModelContact(pChart2ModelContact) { - if( m_pWrappedNumberFormatProperty ) - { - m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = this; - } } WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty() { - if( m_pWrappedNumberFormatProperty ) - { - if( m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty == this ) - m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = 0; - } } void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -126,31 +100,7 @@ void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, return; } - bool bLinkFormat = false; - if( rOuterValue >>= bLinkFormat ) - { - Any aValue; - if( bLinkFormat ) - { - if( m_pWrappedNumberFormatProperty ) - { - uno::Reference< chart2::XChartDocument > xChartDoc( m_pWrappedNumberFormatProperty->m_spChart2ModelContact->getChart2Document() ); - if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) - return; - } - } - else - { - if( m_pWrappedNumberFormatProperty ) - { - aValue = m_pWrappedNumberFormatProperty->getPropertyValue( xInnerPropertySet ); - } - else - aValue <<= sal_Int32( 0 ); - } - - xInnerPropertySet->setPropertyValue( "NumberFormat", aValue ); - } + xInnerPropertySet->setPropertyValue(getInnerName(), rOuterValue); } Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -161,8 +111,8 @@ Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::X OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue"); return getPropertyDefault(0); } - bool bLink = ! xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue(); - return uno::makeAny( bLink ); + + return xInnerPropertySet->getPropertyValue(getInnerName()); } Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx index 63a562c72e87..96020808e9c9 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx @@ -49,14 +49,12 @@ public: friend class WrappedLinkNumberFormatProperty; private: ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - mutable ::com::sun::star::uno::Any m_aOuterValue; - WrappedLinkNumberFormatProperty* m_pWrappedLinkNumberFormatProperty; }; -class WrappedLinkNumberFormatProperty : public WrappedProperty +class WrappedLinkNumberFormatProperty : public WrappedDirectStateProperty { public: - WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty ); + WrappedLinkNumberFormatProperty( const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact ); virtual ~WrappedLinkNumberFormatProperty(); virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const @@ -68,9 +66,8 @@ public: virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - friend class WrappedNumberFormatProperty; private: - WrappedNumberFormatProperty* m_pWrappedNumberFormatProperty; + boost::shared_ptr<Chart2ModelContact> m_pChart2ModelContact; }; } //namespace wrapper diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 328dd8cad1b0..7974dc185c7c 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -425,8 +425,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI case SID_ATTR_NUMBERFORMAT_SOURCE: { - bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( "NumberFormat" ).hasValue()); - rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet )); + bool bLinkToSource = true; + GetPropertySet()->getPropertyValue("LinkNumberFormatToSource") >>= bLinkToSource; + rOutItemSet.Put(SfxBoolItem(nWhichId, bLinkToSource)); } break; @@ -932,7 +933,9 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet bool bUseSourceFormat = (static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() ); - bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( "NumberFormat").hasValue()); + GetPropertySet()->setPropertyValue("LinkNumberFormatToSource", uno::makeAny(bUseSourceFormat)); + + bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("NumberFormat").hasValue(); bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet); if( bChangedOtherwise ) diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx index 154db84f5955..0857de3f1612 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.cxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -103,8 +103,8 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable ); if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK )) { - Sequence< sal_Int8 > aBytes; - if( aDataHelper.GetSequence( SOT_FORMATSTR_ID_LINK, aBytes )) + Sequence<sal_Int8> aBytes = aDataHelper.GetSequence(SOT_FORMATSTR_ID_LINK, OUString()); + if (aBytes.getLength()) { ::std::vector< OUString > aStrings( lcl_getStringsFromByteSequence( aBytes )); if( aStrings.size() >= 3 && aStrings[0] == "soffice" ) diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx index f072b2122a48..e7d7d2b91613 100644 --- a/chart2/source/controller/main/ChartTransferable.cxx +++ b/chart2/source/controller/main/ChartTransferable.cxx @@ -75,7 +75,7 @@ void ChartTransferable::AddSupportedFormats() AddFormat( SOT_FORMAT_BITMAP ); } -sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); sal_Bool bResult = sal_False; diff --git a/chart2/source/controller/main/ChartTransferable.hxx b/chart2/source/controller/main/ChartTransferable.hxx index efbd1b3b9a53..9ae5aaf183fd 100644 --- a/chart2/source/controller/main/ChartTransferable.hxx +++ b/chart2/source/controller/main/ChartTransferable.hxx @@ -43,7 +43,7 @@ protected: // implementation of TransferableHelper methods virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index cee36faa2378..ce44fd7b64dc 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -548,6 +548,7 @@ sal_Int32 XMLFilter::impl_Export( const Reference< lang::XComponent > & xDocumentComp, const Sequence< beans::PropertyValue > & rMediaDescriptor ) { + m_aMediaDescriptor = rMediaDescriptor; //save sal_Int32 nWarning = 0; @@ -751,9 +752,7 @@ sal_Int32 XMLFilter::impl_ExportStream( if ( !xFilter.is() ) return ERRCODE_SFX_GENERAL; - uno::Sequence < beans::PropertyValue > aMediaDesc(0); - //@todo? filter properties? ... url? ... - xFilter->filter( aMediaDesc ); + xFilter->filter(m_aMediaDescriptor); } catch (const uno::Exception& rEx) { diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx index 648e25f45f5c..d8bb956f50d2 100644 --- a/chart2/source/model/inc/XMLFilter.hxx +++ b/chart2/source/model/inc/XMLFilter.hxx @@ -152,6 +152,9 @@ private: ::com::sun::star::lang::XComponent > m_xTargetDoc; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xSourceDoc; + + css::uno::Sequence<css::beans::PropertyValue> m_aMediaDescriptor; + OUString m_sDocumentHandler; // when set it will be set as doc handler volatile bool m_bCancelOperation; diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index f8a3b90448f1..c4780684271c 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -65,7 +65,8 @@ enum PROP_AXIS_CROSSOVER_POSITION, PROP_AXIS_CROSSOVER_VALUE, PROP_AXIS_DISPLAY_LABELS, - PROP_AXIS_NUMBER_FORMAT, + PROP_AXIS_NUMBERFORMAT, + PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, PROP_AXIS_LABEL_POSITION, PROP_AXIS_TEXT_ROTATION, PROP_AXIS_TEXT_BREAK, @@ -110,10 +111,17 @@ void lcl_AddPropertiesToVector( rOutProperties.push_back( Property( "NumberFormat", - PROP_AXIS_NUMBER_FORMAT, - ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + PROP_AXIS_NUMBERFORMAT, + cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEVOID )); + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( "LinkNumberFormatToSource", + PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); rOutProperties.push_back( Property( "LabelPosition", @@ -199,6 +207,7 @@ private: ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ); ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false ); diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx index 443101d3556e..2aa4ca9af789 100644 --- a/chart2/source/model/main/DataPointProperties.cxx +++ b/chart2/source/model/main/DataPointProperties.cxx @@ -281,7 +281,14 @@ void DataPointProperties::AddPropertiesToVector( PROP_DATAPOINT_NUMBER_FORMAT, ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEVOID )); + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( "LinkNumberFormatToSource", + PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); //additional 'PercentageNumberFormat' rOutProperties.push_back( @@ -409,6 +416,8 @@ void DataPointProperties::AddDefaultsToMap( PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_PERCENT_DIAGONAL, 0 ); PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 ); + + PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, true); } } // namespace chart diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx index 596adf88451b..2d7258aca510 100644 --- a/chart2/source/model/main/DataPointProperties.hxx +++ b/chart2/source/model/main/DataPointProperties.hxx @@ -62,6 +62,7 @@ public: PROP_DATAPOINT_LABEL, PROP_DATAPOINT_LABEL_SEPARATOR, PROP_DATAPOINT_NUMBER_FORMAT, + PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, PROP_DATAPOINT_PERCENTAGE_NUMBER_FORMAT, PROP_DATAPOINT_LABEL_PLACEMENT, PROP_DATAPOINT_REFERENCE_DIAGRAM_SIZE, diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index b1ac7d22436d..8ff85632f802 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -454,9 +454,8 @@ void SAL_CALL ChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram if( xAxisProp.is()) { // set number format to source format - uno::Any aValue( xAxisProp->getPropertyValue("NumberFormat")); - if( aValue.hasValue()) - xAxisProp->setPropertyValue("NumberFormat", uno::Any()); + xAxisProp->setPropertyValue("LinkNumberFormatToSource", uno::makeAny(true)); + xAxisProp->setPropertyValue("NumberFormat", uno::Any()); } } } @@ -754,9 +753,8 @@ void ChartTypeTemplate::adaptAxes( if( xAxisProp.is()) { // set number format to source format - uno::Any aValue( xAxisProp->getPropertyValue("NumberFormat")); - if( aValue.hasValue()) - xAxisProp->setPropertyValue("NumberFormat", uno::Any()); + xAxisProp->setPropertyValue("LinkNumberFormatToSource", uno::makeAny(true)); + xAxisProp->setPropertyValue("NumberFormat", uno::Any()); } } } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 4b372ca4275e..8291ca6145e1 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -145,7 +145,16 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() && !( xProp->getPropertyValue( "NumberFormat" ) >>= nNumberFormatKey ) ) + if (!xProp.is()) + return 0; + + bool bLinkToSource = true; + xProp->getPropertyValue("LinkNumberFormatToSource") >>= bLinkToSource; + xProp->getPropertyValue("NumberFormat") >>= nNumberFormatKey; + + sal_Int32 nOldNumberFormat = nNumberFormatKey; + + if (bLinkToSource) { bool bFormatSet = false; //check whether we have a percent scale -> use percent format @@ -314,7 +323,11 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( } } } + + if (nOldNumberFormat != nNumberFormatKey) + xProp->setPropertyValue("NumberFormat", uno::makeAny(nNumberFormatKey)); } + return nNumberFormatKey; } diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index f501aa956d75..c519aef18d85 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1787,8 +1787,16 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( if( !xSeriesOrPointProp.is() ) return nFormat; - OUString aPropName( "NumberFormat" ); - if( !(xSeriesOrPointProp->getPropertyValue(aPropName) >>= nFormat) ) + bool bLinkToSource = true; + try + { + xSeriesOrPointProp->getPropertyValue("LinkNumberFormatToSource") >>= bLinkToSource; + } + catch ( const beans::UnknownPropertyException& ) {} + + xSeriesOrPointProp->getPropertyValue("NumberFormat") >>= nFormat; + sal_Int32 nOldFormat = nFormat; + if (bLinkToSource) { uno::Reference< chart2::XChartType > xChartType( DataSeriesHelper::getChartTypeOfSeries( xSeries, xDiagram ) ); @@ -1796,7 +1804,7 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( if( ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( xChartType ) ) { uno::Reference< beans::XPropertySet > xAttachedAxisProps( DiagramHelper::getAttachedAxis( xSeries, xDiagram ), uno::UNO_QUERY ); - if( xAttachedAxisProps.is() && ( xAttachedAxisProps->getPropertyValue( aPropName ) >>= nFormat ) ) + if( xAttachedAxisProps.is() && ( xAttachedAxisProps->getPropertyValue("NumberFormat") >>= nFormat ) ) bFormatFound = true; } if( !bFormatFound ) @@ -1813,7 +1821,11 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex ); } } + + if (nFormat >= 0 && nOldFormat != nFormat) + xSeriesOrPointProp->setPropertyValue("NumberFormat", uno::makeAny(nFormat)); } + if(nFormat<0) nFormat=0; return nFormat; |